obi-sdk 0.19.20 → 0.19.22-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,121 +1,55 @@
1
- (function(){"use strict";var Cs,te,hf,Ui,pf,ff,mf,gf,Nu,Du,Lu,vf,go={},yf=[],Rw=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,vo=Array.isArray;function Ln(n,e){for(var t in e)n[t]=e[t];return n}function Uu(n){n&&n.parentNode&&n.parentNode.removeChild(n)}function Fu(n,e,t){var i,r,o,s={};for(o in e)o=="key"?i=e[o]:o=="ref"?r=e[o]:s[o]=e[o];if(arguments.length>2&&(s.children=arguments.length>3?Cs.call(arguments,2):t),typeof n=="function"&&n.defaultProps!=null)for(o in n.defaultProps)s[o]==null&&(s[o]=n.defaultProps[o]);return Ts(n,s,i,r,null)}function Ts(n,e,t,i,r){var o={type:n,props:e,key:t,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++hf,__i:-1,__u:0};return r==null&&te.vnode!=null&&te.vnode(o),o}function St(n){return n.children}function Un(n,e){this.props=n,this.context=e}function mr(n,e){if(e==null)return n.__?mr(n.__,n.__i+1):null;for(var t;e<n.__k.length;e++)if((t=n.__k[e])!=null&&t.__e!=null)return t.__e;return typeof n.type=="function"?mr(n):null}function bf(n){var e,t;if((n=n.__)!=null&&n.__c!=null){for(n.__e=n.__c.base=null,e=0;e<n.__k.length;e++)if((t=n.__k[e])!=null&&t.__e!=null){n.__e=n.__c.base=t.__e;break}return bf(n)}}function Bu(n){(!n.__d&&(n.__d=!0)&&Ui.push(n)&&!xs.__r++||pf!=te.debounceRendering)&&((pf=te.debounceRendering)||ff)(xs)}function xs(){for(var n,e,t,i,r,o,s,a=1;Ui.length;)Ui.length>a&&Ui.sort(mf),n=Ui.shift(),a=Ui.length,n.__d&&(t=void 0,r=(i=(e=n).__v).__e,o=[],s=[],e.__P&&((t=Ln({},i)).__v=i.__v+1,te.vnode&&te.vnode(t),ju(e.__P,t,i,e.__n,e.__P.namespaceURI,32&i.__u?[r]:null,o,r??mr(i),!!(32&i.__u),s),t.__v=i.__v,t.__.__k[t.__i]=t,Cf(o,t,s),t.__e!=r&&bf(t)));xs.__r=0}function _f(n,e,t,i,r,o,s,a,c,u,l){var d,h,p,m,f,g,y=i&&i.__k||yf,b=e.length;for(c=Pw(t,e,y,c,b),d=0;d<b;d++)(p=t.__k[d])!=null&&(h=p.__i==-1?go:y[p.__i]||go,p.__i=d,g=ju(n,p,h,r,o,s,a,c,u,l),m=p.__e,p.ref&&h.ref!=p.ref&&(h.ref&&Vu(h.ref,null,p),l.push(p.ref,p.__c||m,p)),f==null&&m!=null&&(f=m),4&p.__u||h.__k===p.__k?c=kf(p,c,n):typeof p.type=="function"&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-7);return t.__e=f,c}function Pw(n,e,t,i,r){var o,s,a,c,u,l=t.length,d=l,h=0;for(n.__k=new Array(r),o=0;o<r;o++)(s=e[o])!=null&&typeof s!="boolean"&&typeof s!="function"?(c=o+h,(s=n.__k[o]=typeof s=="string"||typeof s=="number"||typeof s=="bigint"||s.constructor==String?Ts(null,s,null,null,null):vo(s)?Ts(St,{children:s},null,null,null):s.constructor==null&&s.__b>0?Ts(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):s).__=n,s.__b=n.__b+1,a=null,(u=s.__i=Ow(s,t,c,d))!=-1&&(d--,(a=t[u])&&(a.__u|=2)),a==null||a.__v==null?(u==-1&&(r>l?h--:r<l&&h++),typeof s.type!="function"&&(s.__u|=4)):u!=c&&(u==c-1?h--:u==c+1?h++:(u>c?h--:h++,s.__u|=4))):n.__k[o]=null;if(d)for(o=0;o<l;o++)(a=t[o])!=null&&!(2&a.__u)&&(a.__e==i&&(i=mr(a)),xf(a,a));return i}function kf(n,e,t){var i,r;if(typeof n.type=="function"){for(i=n.__k,r=0;i&&r<i.length;r++)i[r]&&(i[r].__=n,e=kf(i[r],e,t));return e}n.__e!=e&&(e&&n.type&&!t.contains(e)&&(e=mr(n)),t.insertBefore(n.__e,e||null),e=n.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function Es(n,e){return e=e||[],n==null||typeof n=="boolean"||(vo(n)?n.some(function(t){Es(t,e)}):e.push(n)),e}function Ow(n,e,t,i){var r,o,s=n.key,a=n.type,c=e[t];if(c===null&&n.key==null||c&&s==c.key&&a==c.type&&!(2&c.__u))return t;if(i>(c!=null&&!(2&c.__u)?1:0))for(r=t-1,o=t+1;r>=0||o<e.length;){if(r>=0){if((c=e[r])&&!(2&c.__u)&&s==c.key&&a==c.type)return r;r--}if(o<e.length){if((c=e[o])&&!(2&c.__u)&&s==c.key&&a==c.type)return o;o++}}return-1}function Sf(n,e,t){e[0]=="-"?n.setProperty(e,t??""):n[e]=t==null?"":typeof t!="number"||Rw.test(e)?t:t+"px"}function Is(n,e,t,i,r){var o;e:if(e=="style")if(typeof t=="string")n.style.cssText=t;else{if(typeof i=="string"&&(n.style.cssText=i=""),i)for(e in i)t&&e in t||Sf(n.style,e,"");if(t)for(e in t)i&&t[e]==i[e]||Sf(n.style,e,t[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(gf,"$1")),e=e.toLowerCase()in n||e=="onFocusOut"||e=="onFocusIn"?e.toLowerCase().slice(2):e.slice(2),n.l||(n.l={}),n.l[e+o]=t,t?i?t.u=i.u:(t.u=Nu,n.addEventListener(e,o?Lu:Du,o)):n.removeEventListener(e,o?Lu:Du,o);else{if(r=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in n)try{n[e]=t??"";break e}catch{}typeof t=="function"||(t==null||t===!1&&e[4]!="-"?n.removeAttribute(e):n.setAttribute(e,e=="popover"&&t==1?"":t))}}function wf(n){return function(e){if(this.l){var t=this.l[e.type+n];if(e.t==null)e.t=Nu++;else if(e.t<t.u)return;return t(te.event?te.event(e):e)}}}function ju(n,e,t,i,r,o,s,a,c,u){var l,d,h,p,m,f,g,y,b,S,w,k,C,x,I,P,D,A=e.type;if(e.constructor!=null)return null;128&t.__u&&(c=!!(32&t.__u),o=[a=e.__e=t.__e]),(l=te.__b)&&l(e);e:if(typeof A=="function")try{if(y=e.props,b="prototype"in A&&A.prototype.render,S=(l=A.contextType)&&i[l.__c],w=l?S?S.props.value:l.__:i,t.__c?g=(d=e.__c=t.__c).__=d.__E:(b?e.__c=d=new A(y,w):(e.__c=d=new Un(y,w),d.constructor=A,d.render=Mw),S&&S.sub(d),d.props=y,d.state||(d.state={}),d.context=w,d.__n=i,h=d.__d=!0,d.__h=[],d._sb=[]),b&&d.__s==null&&(d.__s=d.state),b&&A.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=Ln({},d.__s)),Ln(d.__s,A.getDerivedStateFromProps(y,d.__s))),p=d.props,m=d.state,d.__v=e,h)b&&A.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),b&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(b&&A.getDerivedStateFromProps==null&&y!==p&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(y,w),!d.__e&&d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(y,d.__s,w)===!1||e.__v==t.__v){for(e.__v!=t.__v&&(d.props=y,d.state=d.__s,d.__d=!1),e.__e=t.__e,e.__k=t.__k,e.__k.some(function(L){L&&(L.__=e)}),k=0;k<d._sb.length;k++)d.__h.push(d._sb[k]);d._sb=[],d.__h.length&&s.push(d);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(y,d.__s,w),b&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(p,m,f)})}if(d.context=w,d.props=y,d.__P=n,d.__e=!1,C=te.__r,x=0,b){for(d.state=d.__s,d.__d=!1,C&&C(e),l=d.render(d.props,d.state,d.context),I=0;I<d._sb.length;I++)d.__h.push(d._sb[I]);d._sb=[]}else do d.__d=!1,C&&C(e),l=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++x<25);d.state=d.__s,d.getChildContext!=null&&(i=Ln(Ln({},i),d.getChildContext())),b&&!h&&d.getSnapshotBeforeUpdate!=null&&(f=d.getSnapshotBeforeUpdate(p,m)),P=l,l!=null&&l.type===St&&l.key==null&&(P=Tf(l.props.children)),a=_f(n,vo(P)?P:[P],e,t,i,r,o,s,a,c,u),d.base=e.__e,e.__u&=-161,d.__h.length&&s.push(d),g&&(d.__E=d.__=null)}catch(L){if(e.__v=null,c||o!=null)if(L.then){for(e.__u|=c?160:128;a&&a.nodeType==8&&a.nextSibling;)a=a.nextSibling;o[o.indexOf(a)]=null,e.__e=a}else for(D=o.length;D--;)Uu(o[D]);else e.__e=t.__e,e.__k=t.__k;te.__e(L,e,t)}else o==null&&e.__v==t.__v?(e.__k=t.__k,e.__e=t.__e):a=e.__e=Aw(t.__e,e,t,i,r,o,s,c,u);return(l=te.diffed)&&l(e),128&e.__u?void 0:a}function Cf(n,e,t){for(var i=0;i<t.length;i++)Vu(t[i],t[++i],t[++i]);te.__c&&te.__c(e,n),n.some(function(r){try{n=r.__h,r.__h=[],n.some(function(o){o.call(r)})}catch(o){te.__e(o,r.__v)}})}function Tf(n){return typeof n!="object"||n==null||n.__b&&n.__b>0?n:vo(n)?n.map(Tf):Ln({},n)}function Aw(n,e,t,i,r,o,s,a,c){var u,l,d,h,p,m,f,g=t.props,y=e.props,b=e.type;if(b=="svg"?r="http://www.w3.org/2000/svg":b=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),o!=null){for(u=0;u<o.length;u++)if((p=o[u])&&"setAttribute"in p==!!b&&(b?p.localName==b:p.nodeType==3)){n=p,o[u]=null;break}}if(n==null){if(b==null)return document.createTextNode(y);n=document.createElementNS(r,b,y.is&&y),a&&(te.__m&&te.__m(e,o),a=!1),o=null}if(b==null)g===y||a&&n.data==y||(n.data=y);else{if(o=o&&Cs.call(n.childNodes),g=t.props||go,!a&&o!=null)for(g={},u=0;u<n.attributes.length;u++)g[(p=n.attributes[u]).name]=p.value;for(u in g)if(p=g[u],u!="children"){if(u=="dangerouslySetInnerHTML")d=p;else if(!(u in y)){if(u=="value"&&"defaultValue"in y||u=="checked"&&"defaultChecked"in y)continue;Is(n,u,null,p,r)}}for(u in y)p=y[u],u=="children"?h=p:u=="dangerouslySetInnerHTML"?l=p:u=="value"?m=p:u=="checked"?f=p:a&&typeof p!="function"||g[u]===p||Is(n,u,p,g[u],r);if(l)a||d&&(l.__html==d.__html||l.__html==n.innerHTML)||(n.innerHTML=l.__html),e.__k=[];else if(d&&(n.innerHTML=""),_f(e.type=="template"?n.content:n,vo(h)?h:[h],e,t,i,b=="foreignObject"?"http://www.w3.org/1999/xhtml":r,o,s,o?o[0]:t.__k&&mr(t,0),a,c),o!=null)for(u=o.length;u--;)Uu(o[u]);a||(u="value",b=="progress"&&m==null?n.removeAttribute("value"):m!=null&&(m!==n[u]||b=="progress"&&!m||b=="option"&&m!=g[u])&&Is(n,u,m,g[u],r),u="checked",f!=null&&f!=n[u]&&Is(n,u,f,g[u],r))}return n}function Vu(n,e,t){try{if(typeof n=="function"){var i=typeof n.__u=="function";i&&n.__u(),i&&e==null||(n.__u=n(e))}else n.current=e}catch(r){te.__e(r,t)}}function xf(n,e,t){var i,r;if(te.unmount&&te.unmount(n),(i=n.ref)&&(i.current&&i.current!=n.__e||Vu(i,null,e)),(i=n.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(o){te.__e(o,e)}i.base=i.__P=null}if(i=n.__k)for(r=0;r<i.length;r++)i[r]&&xf(i[r],e,t||typeof n.type!="function");t||Uu(n.__e),n.__c=n.__=n.__e=void 0}function Mw(n,e,t){return this.constructor(n,t)}function Nw(n,e,t){var i,r,o,s;e==document&&(e=document.documentElement),te.__&&te.__(n,e),r=(i=typeof t=="function")?null:t&&t.__k||e.__k,o=[],s=[],ju(e,n=(!i&&t||e).__k=Fu(St,null,[n]),r||go,go,e.namespaceURI,!i&&t?[t]:r?null:e.firstChild?Cs.call(e.childNodes):null,o,!i&&t?t:r?r.__e:e.firstChild,i,s),Cf(o,n,s)}function Dw(n){function e(t){var i,r;return this.getChildContext||(i=new Set,(r={})[e.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){i=null},this.shouldComponentUpdate=function(o){this.props.value!=o.value&&i.forEach(function(s){s.__e=!0,Bu(s)})},this.sub=function(o){i.add(o);var s=o.componentWillUnmount;o.componentWillUnmount=function(){i&&i.delete(o),s&&s.call(o)}}),t.children}return e.__c="__cC"+vf++,e.__=n,e.Provider=e.__l=(e.Consumer=function(t,i){return t.children(i)}).contextType=e,e}Cs=yf.slice,te={__e:function(n,e,t,i){for(var r,o,s;e=e.__;)if((r=e.__c)&&!r.__)try{if((o=r.constructor)&&o.getDerivedStateFromError!=null&&(r.setState(o.getDerivedStateFromError(n)),s=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(n,i||{}),s=r.__d),s)return r.__E=r}catch(a){n=a}throw n}},hf=0,Un.prototype.setState=function(n,e){var t;t=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Ln({},this.state),typeof n=="function"&&(n=n(Ln({},t),this.props)),n&&Ln(t,n),n!=null&&this.__v&&(e&&this._sb.push(e),Bu(this))},Un.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),Bu(this))},Un.prototype.render=St,Ui=[],ff=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,mf=function(n,e){return n.__v.__b-e.__v.__b},xs.__r=0,gf=/(PointerCapture)$|Capture$/i,Nu=0,Du=wf(!1),Lu=wf(!0),vf=0;var Lw=0;function _(n,e,t,i,r,o){e||(e={});var s,a,c=e;if("ref"in c)for(a in c={},e)a=="ref"?s=e[a]:c[a]=e[a];var u={type:n,props:c,key:t,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Lw,__i:-1,__u:0,__source:r,__self:o};if(typeof n=="function"&&(s=n.defaultProps))for(a in s)c[a]===void 0&&(c[a]=s[a]);return te.vnode&&te.vnode(u),u}var Fi,je,zu,Ef,yo=0,If=[],Qe=te,Rf=Qe.__b,Pf=Qe.__r,Of=Qe.diffed,Af=Qe.__c,Mf=Qe.unmount,Nf=Qe.__;function bo(n,e){Qe.__h&&Qe.__h(je,n,yo||e),yo=0;var t=je.__H||(je.__H={__:[],__h:[]});return n>=t.__.length&&t.__.push({}),t.__[n]}function de(n){return yo=1,Uw(Uf,n)}function Uw(n,e,t){var i=bo(Fi++,2);if(i.t=n,!i.__c&&(i.__=[t?t(e):Uf(void 0,e),function(a){var c=i.__N?i.__N[0]:i.__[0],u=i.t(c,a);c!==u&&(i.__N=[u,i.__[1]],i.__c.setState({}))}],i.__c=je,!je.__f)){var r=function(a,c,u){if(!i.__c.__H)return!0;var l=i.__c.__H.__.filter(function(h){return!!h.__c});if(l.every(function(h){return!h.__N}))return!o||o.call(this,a,c,u);var d=i.__c.props!==a;return l.forEach(function(h){if(h.__N){var p=h.__[0];h.__=h.__N,h.__N=void 0,p!==h.__[0]&&(d=!0)}}),o&&o.call(this,a,c,u)||d};je.__f=!0;var o=je.shouldComponentUpdate,s=je.componentWillUpdate;je.componentWillUpdate=function(a,c,u){if(this.__e){var l=o;o=void 0,r(a,c,u),o=l}s&&s.call(this,a,c,u)},je.shouldComponentUpdate=r}return i.__N||i.__}function Dt(n,e){var t=bo(Fi++,3);!Qe.__s&&Gu(t.__H,e)&&(t.__=n,t.u=e,je.__H.__h.push(t))}function Rs(n,e){var t=bo(Fi++,4);!Qe.__s&&Gu(t.__H,e)&&(t.__=n,t.u=e,je.__h.push(t))}function bn(n){return yo=5,qu(function(){return{current:n}},[])}function qu(n,e){var t=bo(Fi++,7);return Gu(t.__H,e)&&(t.__=n(),t.__H=e,t.__h=n),t.__}function Fw(n,e){return yo=8,qu(function(){return n},e)}function Df(n){var e=je.context[n.__c],t=bo(Fi++,9);return t.c=n,e?(t.__==null&&(t.__=!0,e.sub(je)),e.props.value):n.__}function Bw(){for(var n;n=If.shift();)if(n.__P&&n.__H)try{n.__H.__h.forEach(Ps),n.__H.__h.forEach(Wu),n.__H.__h=[]}catch(e){n.__H.__h=[],Qe.__e(e,n.__v)}}Qe.__b=function(n){je=null,Rf&&Rf(n)},Qe.__=function(n,e){n&&e.__k&&e.__k.__m&&(n.__m=e.__k.__m),Nf&&Nf(n,e)},Qe.__r=function(n){Pf&&Pf(n),Fi=0;var e=(je=n.__c).__H;e&&(zu===je?(e.__h=[],je.__h=[],e.__.forEach(function(t){t.__N&&(t.__=t.__N),t.u=t.__N=void 0})):(e.__h.forEach(Ps),e.__h.forEach(Wu),e.__h=[],Fi=0)),zu=je},Qe.diffed=function(n){Of&&Of(n);var e=n.__c;e&&e.__H&&(e.__H.__h.length&&(If.push(e)!==1&&Ef===Qe.requestAnimationFrame||((Ef=Qe.requestAnimationFrame)||jw)(Bw)),e.__H.__.forEach(function(t){t.u&&(t.__H=t.u),t.u=void 0})),zu=je=null},Qe.__c=function(n,e){e.some(function(t){try{t.__h.forEach(Ps),t.__h=t.__h.filter(function(i){return!i.__||Wu(i)})}catch(i){e.some(function(r){r.__h&&(r.__h=[])}),e=[],Qe.__e(i,t.__v)}}),Af&&Af(n,e)},Qe.unmount=function(n){Mf&&Mf(n);var e,t=n.__c;t&&t.__H&&(t.__H.__.forEach(function(i){try{Ps(i)}catch(r){e=r}}),t.__H=void 0,e&&Qe.__e(e,t.__v))};var Lf=typeof requestAnimationFrame=="function";function jw(n){var e,t=function(){clearTimeout(i),Lf&&cancelAnimationFrame(e),setTimeout(n)},i=setTimeout(t,100);Lf&&(e=requestAnimationFrame(t))}function Ps(n){var e=je,t=n.__c;typeof t=="function"&&(n.__c=void 0,t()),je=e}function Wu(n){var e=je;n.__c=n.__(),je=e}function Gu(n,e){return!n||n.length!==e.length||e.some(function(t,i){return t!==n[i]})}function Uf(n,e){return typeof e=="function"?e(n):e}function Vw({size:n=24,color:e="#000"}){return _("svg",{xmlns:"http://www.w3.org/2000/svg",width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:e,"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-x-icon lucide-x",children:[_("path",{d:"M18 6 6 18"}),_("path",{d:"m6 6 12 12"})]})}function Ff({onClose:n}){return _("button",{class:"obi-button obi-close-button",onClick:n,"aria-label":"Close",type:"button",children:_(Vw,{})})}function Bf({open:n=!1,children:e,onClose:t,size:i="medium"}){const r=bn(null),o=bn(null);Dt(()=>{const u=r.current;u&&(n&&!u.open?u.showModal():!n&&u.open&&(o.current="programmatic",u.close()))},[n]);const s=u=>{const l=r.current;u.target===l&&(o.current="user-initiated",l==null||l.close())},a=u=>{u.preventDefault(),o.current||(o.current="user-initiated");const l=o.current;o.current=null,t==null||t(l)},c=()=>{var u;o.current="user-initiated",(u=r.current)==null||u.close()};return Dt(()=>{const u=r.current;if(u)return u.addEventListener("click",s),u.addEventListener("close",a),()=>{u.removeEventListener("click",s),u.removeEventListener("close",a)}},[t]),_("dialog",{ref:r,className:`modal-${i}`,children:[_(Ff,{onClose:c}),_("div",{class:"modal-content",children:n?typeof e=="function"?e():e:null})]})}function $u(n){const{children:e,className:t="",...i}=n;return _("div",{className:`${t} obi-panel`,...i,children:e})}function Os({className:n="",isActive:e=!1,speakingStatus:t,onClick:i,onMouseEnter:r,onMouseLeave:o,children:s}){let a=`obi-pill container ${e&&"active"}`;return t==="user-speaking"&&(a+=" user-speaking"),t==="busy"&&(a+=" busy"),_("div",{className:a,onMouseEnter:r,onMouseLeave:o,children:_("div",{className:`obi-pill pill ${n}`,onClick:i,children:s})})}function zw({className:n="",active:e,speakingStatus:t,onClick:i,onMouseEnter:r,onMouseLeave:o,children:s,...a}){const c=`obi-pill2 container ${e?"active":""} ${t==="user-speaking"?"user-speaking":""} ${n}`;return _("div",{className:c,...a,children:_("div",{className:"pill",onClick:i,onMouseEnter:r,onMouseLeave:o,children:s})})}function qw({className:n="",active:e,speakingStatus:t,onClick:i,onMouseEnter:r,onMouseLeave:o,children:s,...a}){const c=`obi-pill-up container ${e?"active":""} ${t==="user-speaking"?"user-speaking":""} ${n}`;return _("div",{className:c,...a,children:_("div",{className:"pill",onClick:i,onMouseEnter:r,onMouseLeave:o,children:s})})}function Bi({type:n,size:e=24}){return _("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:Ww(n)})}function Ww(n){switch(n){case"pause":return _(St,{children:[_("rect",{x:"14",y:"3",width:"5",height:"18",rx:"1"}),_("rect",{x:"5",y:"3",width:"5",height:"18",rx:"1"})]});case"play":return _(St,{children:_("path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z"})});case"close":return _(St,{children:[_("path",{d:"M18 6 6 18"}),_("path",{d:"m6 6 12 12"})]});case"message":return _(St,{children:_("path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z"})});case"minimize":return _(St,{children:[_("path",{d:"m14 10 7-7"}),_("path",{d:"M20 10h-6V4"}),_("path",{d:"m3 21 7-7"}),_("path",{d:"M4 14h6v6"})]});case"voice":return _(St,{children:[_("path",{d:"M2 10v3"}),_("path",{d:"M6 6v11"}),_("path",{d:"M10 3v18"}),_("path",{d:"M14 8v7"}),_("path",{d:"M18 5v13"}),_("path",{d:"M22 10v3"})]});case"open":return _(St,{children:[_("path",{d:"M12 7v14"}),_("path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z"})]})}}const Hu=Dw(null);function Gw({children:n}){const e=Df(Hu);if(!e)throw new Error("PopoutTarget must be used within a Popout component");const{controlledOpen:t,isOpen:i,setIsOpen:r,setAnimating:o,targetRef:s,trigger:a,onChange:c,delayMs:u}=e,l=bn(null),d=jf(s,o),[h,p]=de(!1);Dt(()=>{t!==void 0&&t!==h&&(t?f():g()),p(t)},[t]),Dt(()=>()=>{l.current&&clearTimeout(l.current)},[]);function m(){l.current&&(clearTimeout(l.current),l.current=null)}function f(){m(),u>0?l.current=setTimeout(()=>{c==null||c(!0),r(!0),l.current=null},u):(c==null||c(!0),r(!0))}function g(){m(),c==null||c(!1),r(!1)}const y=()=>{a==="click"&&(i?g():f())};function b(){a==="hover"&&f()}function S(){a==="hover"&&g()}return _("div",{ref:d,class:"target",onClick:y,onMouseEnter:b,onMouseLeave:S,children:n})}function $w({children:n}){const e=Df(Hu);if(!e)throw new Error("PopoutContent must be used within a Popout component");const{isOpen:t,animating:i,setAnimating:r,targetRef:o,contentRef:s}=e,a=jf(s,r);return Rs(()=>{if(t&&!i&&o.current&&s.current){const c=s.current;if(!c)return;const u=o.current;if(!u)return;const l=c.getBoundingClientRect(),d=u.getBoundingClientRect(),h=d.right-d.left;c.style.top=`${l.top-l.bottom-(8+e.offset)}px`,c.style.left=`${-(l.right-l.left-h)/2}px`}},[t,i]),t?_("div",{ref:a,class:"content",style:{opacity:i?0:1},children:n}):null}function Lt({trigger:n="click",open:e,onChange:t,children:i,delayMs:r=0,offset:o=0,className:s=""}){const[a,c]=de(!1),[u,l]=de(!1),d=bn(null),h=bn(null),p={controlledOpen:e,isOpen:a,setIsOpen:c,animating:u,setAnimating:l,targetRef:d,contentRef:h,trigger:n,onChange:t,delayMs:r,offset:o};return _(Hu.Provider,{value:p,children:_("div",{class:`obi-popout ${s}`,children:i})})}Lt.Target=Gw,Lt.Content=$w;function jf(n,e){const t=bn(null),i=bn(null),r=bn(!0),o=Fw(s=>{if(n.current=s,!s){i.current&&(i.current.disconnect(),i.current=null),r.current=!0;return}function a(){if(r.current){r.current=!1;return}t.current?clearTimeout(t.current):e(!0),t.current=setTimeout(()=>{e(!1),t.current=null},200)}i.current=new ResizeObserver(a),i.current.observe(s,{box:"border-box"})},[]);return Dt(()=>()=>{i.current&&(i.current.disconnect(),i.current=null)},[]),o}function nn({className:n,onClick:e,type:t,disabled:i,title:r}){const o={cancel:_(Bi,{type:"close",size:16}),pause:_(Bi,{type:"pause",size:16}),play:_(Bi,{type:"play",size:16}),message:_(Bi,{type:"message",size:16}),minimize:_(Bi,{type:"minimize",size:16}),voice:_(Bi,{type:"voice",size:16}),open:_(Bi,{type:"open",size:16})}[t],s={cancel:"",pause:"",play:"",message:"",minimize:"",voice:"",open:""}[t],a=_("button",{class:`obi-button obi-round-button ${s} ${n}`,onClick:i?void 0:e,disabled:i,children:o});return r?_(Lt,{className:"obi-round-button-popout",trigger:"hover",delayMs:200,offset:9,children:[_(Lt.Target,{children:a}),_(Lt.Content,{children:_("div",{className:"obi-round-button-title",children:r})})]}):a}const Vf=8,As=8,Hw=50,Kw=.7,gr=3;function zf({getBands:n,color:e="white"}){const t=bn(null);return Dt(()=>{if(!n)return;const i=setInterval(()=>{try{const r=n();if(!t.current)return;const o=t.current.querySelectorAll(".bar"),s=r&&r.length>0?r.slice(0,As).map(a=>{const c=Math.abs(a);return Math.min(c/Kw*Vf,Vf)||gr}):Array(As).fill(gr);for(;s.length<As;)s.push(gr);s.forEach((a,c)=>{if(a<gr&&(a=gr),o[c]){const u=a*2;o[c].style.height=`${u}px`,o[c].style.display=a>0?"block":"none"}})}catch(r){console.warn("Error updating equaliser:",r)}},Hw);return()=>{clearInterval(i)}},[n]),_("div",{className:"obi-equaliser",ref:t,children:Array.from({length:As},(i,r)=>_("div",{className:"column",children:_("div",{className:"bar",style:{height:`${gr}px`,backgroundColor:e,display:"block"}})},r))})}function ei({className:n,children:e,onClick:t}){return t?_("button",{class:`obi-button obi-message ${n} clickable`,onClick:t,children:e}):_("div",{class:`obi-message ${n}`,children:e})}const Yw=8;function qf({color:n="white"}){return _("div",{className:"obi-loading-dots",children:Array.from({length:Yw},(e,t)=>_("div",{className:"column",children:[_("div",{className:"bar",style:{backgroundColor:n,animationDelay:`${t*.15}s`}}),_("div",{className:"dot",style:{backgroundColor:n}})]},t))})}function Xw({onContinue:n,onWrapUp:e}){return _($u,{className:"obi-exit-survey",children:_(Zw,{onContinue:n,onWrapUp:()=>{e()}})})}function Jw({onOtherSelect:n,onReasonSelect:e,onClose:t}){const[i,r]=de("reason"),o=s=>{s==="other"?(n(),r("other-reason")):e(s)};return _($u,{className:`obi-exit-survey ${i==="reason"?"obi-exit-survey-reason":""}`,children:i==="reason"?_(Qw,{onReasonSelect:o}):_(eC,{onReasonSelect:o,onClose:t})})}function Zw({onContinue:n,onWrapUp:e}){return _("div",{className:"obi-exit-survey-container",children:[_("h2",{className:"obi-exit-survey-title",children:"Wrapping up early?"}),_("div",{className:"obi-exit-survey-options",children:[_("button",{className:"obi-button obi-exit-survey-button obi-exit-survey-button-continue",onClick:n,type:"button",children:"No, let's continue"}),_("button",{className:"obi-button obi-exit-survey-button obi-exit-survey-button-wrap-up",onClick:e,type:"button",children:"Yes, let's wrap up"})]})]})}function Qw({onReasonSelect:n}){return _("div",{className:"obi-exit-survey-container obi-exit-survey-reason-container",children:[_("div",{className:"obi-exit-survey-header",children:_("h2",{className:"obi-exit-survey-title obi-exit-survey-reason-title",children:"Quick feedback?"})}),_("div",{className:"obi-exit-survey-options obi-exit-survey-reason-options",children:[_("button",{className:"obi-button obi-exit-survey-button obi-exit-survey-reason-button",onClick:()=>n("do-later"),type:"button",children:"Will do later"}),_("button",{className:"obi-button obi-exit-survey-button obi-exit-survey-reason-button",onClick:()=>n("cant-talk"),type:"button",children:"Can't talk right now"}),_("button",{className:"obi-button obi-exit-survey-button obi-exit-survey-reason-button",onClick:()=>n("prefer-written"),type:"button",children:"Prefer written instructions"}),_("button",{className:"obi-button obi-exit-survey-button obi-exit-survey-reason-button",onClick:()=>n("technical-issues"),type:"button",children:"Experienced technical issues"})]})]})}function eC({onReasonSelect:n,onClose:e}){const[t,i]=de("");return _("div",{className:"obi-exit-survey-container obi-exit-survey-reason-container",children:[_("div",{className:"obi-exit-survey-header",children:[_(Ff,{onClose:e}),_("h2",{className:"obi-exit-survey-title obi-exit-survey-reason-title",children:"Tell us more"})]}),_("div",{className:"obi-exit-survey-options obi-exit-survey-reason-options",children:[_("textarea",{className:"obi-exit-survey-button obi-exit-survey-reason-button",placeholder:"What's on your mind?",value:t,onChange:r=>i(r.target.value)}),_("button",{className:"obi-button obi-exit-survey-button obi-exit-survey-button-wrap-up",onClick:()=>n("other-feedback",t),type:"button",children:"Send feedback"})]})]})}function tC(n,e){for(var t in e)n[t]=e[t];return n}function Wf(n,e){for(var t in n)if(t!=="__source"&&!(t in e))return!0;for(var i in e)if(i!=="__source"&&n[i]!==e[i])return!0;return!1}function Gf(n,e){this.props=n,this.context=e}(Gf.prototype=new Un).isPureReactComponent=!0,Gf.prototype.shouldComponentUpdate=function(n,e){return Wf(this.props,n)||Wf(this.state,e)};var $f=te.__b;te.__b=function(n){n.type&&n.type.__f&&n.ref&&(n.props.ref=n.ref,n.ref=null),$f&&$f(n)};var nC=te.__e;te.__e=function(n,e,t,i){if(n.then){for(var r,o=e;o=o.__;)if((r=o.__c)&&r.__c)return e.__e==null&&(e.__e=t.__e,e.__k=t.__k),r.__c(n,e)}nC(n,e,t,i)};var Hf=te.unmount;function Kf(n,e,t){return n&&(n.__c&&n.__c.__H&&(n.__c.__H.__.forEach(function(i){typeof i.__c=="function"&&i.__c()}),n.__c.__H=null),(n=tC({},n)).__c!=null&&(n.__c.__P===t&&(n.__c.__P=e),n.__c.__e=!0,n.__c=null),n.__k=n.__k&&n.__k.map(function(i){return Kf(i,e,t)})),n}function Yf(n,e,t){return n&&t&&(n.__v=null,n.__k=n.__k&&n.__k.map(function(i){return Yf(i,e,t)}),n.__c&&n.__c.__P===e&&(n.__e&&t.appendChild(n.__e),n.__c.__e=!0,n.__c.__P=t)),n}function Ku(){this.__u=0,this.o=null,this.__b=null}function Xf(n){var e=n.__.__c;return e&&e.__a&&e.__a(n)}function Ms(){this.i=null,this.l=null}te.unmount=function(n){var e=n.__c;e&&e.__R&&e.__R(),e&&32&n.__u&&(n.type=null),Hf&&Hf(n)},(Ku.prototype=new Un).__c=function(n,e){var t=e.__c,i=this;i.o==null&&(i.o=[]),i.o.push(t);var r=Xf(i.__v),o=!1,s=function(){o||(o=!0,t.__R=null,r?r(a):a())};t.__R=s;var a=function(){if(!--i.__u){if(i.state.__a){var c=i.state.__a;i.__v.__k[0]=Yf(c,c.__c.__P,c.__c.__O)}var u;for(i.setState({__a:i.__b=null});u=i.o.pop();)u.forceUpdate()}};i.__u++||32&e.__u||i.setState({__a:i.__b=i.__v.__k[0]}),n.then(s,s)},Ku.prototype.componentWillUnmount=function(){this.o=[]},Ku.prototype.render=function(n,e){if(this.__b){if(this.__v.__k){var t=document.createElement("div"),i=this.__v.__k[0].__c;this.__v.__k[0]=Kf(this.__b,t,i.__O=i.__P)}this.__b=null}var r=e.__a&&Fu(St,null,n.fallback);return r&&(r.__u&=-33),[Fu(St,null,e.__a?null:n.children),r]};var Jf=function(n,e,t){if(++t[1]===t[0]&&n.l.delete(e),n.props.revealOrder&&(n.props.revealOrder[0]!=="t"||!n.l.size))for(t=n.i;t;){for(;t.length>3;)t.pop()();if(t[1]<t[0])break;n.i=t=t[2]}};(Ms.prototype=new Un).__a=function(n){var e=this,t=Xf(e.__v),i=e.l.get(n);return i[0]++,function(r){var o=function(){e.props.revealOrder?(i.push(r),Jf(e,n,i)):r()};t?t(o):o()}},Ms.prototype.render=function(n){this.i=null,this.l=new Map;var e=Es(n.children);n.revealOrder&&n.revealOrder[0]==="b"&&e.reverse();for(var t=e.length;t--;)this.l.set(e[t],this.i=[1,0,this.i]);return n.children},Ms.prototype.componentDidUpdate=Ms.prototype.componentDidMount=function(){var n=this;this.l.forEach(function(e,t){Jf(n,t,e)})};var iC=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,rC=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,oC=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,sC=/[A-Z0-9]/g,aC=typeof document<"u",cC=function(n){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(n)};Un.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(n){Object.defineProperty(Un.prototype,n,{configurable:!0,get:function(){return this["UNSAFE_"+n]},set:function(e){Object.defineProperty(this,n,{configurable:!0,writable:!0,value:e})}})});var Zf=te.event;function uC(){}function lC(){return this.cancelBubble}function dC(){return this.defaultPrevented}te.event=function(n){return Zf&&(n=Zf(n)),n.persist=uC,n.isPropagationStopped=lC,n.isDefaultPrevented=dC,n.nativeEvent=n};var hC={enumerable:!1,configurable:!0,get:function(){return this.class}},Qf=te.vnode;te.vnode=function(n){typeof n.type=="string"&&function(e){var t=e.props,i=e.type,r={},o=i.indexOf("-")===-1;for(var s in t){var a=t[s];if(!(s==="value"&&"defaultValue"in t&&a==null||aC&&s==="children"&&i==="noscript"||s==="class"||s==="className")){var c=s.toLowerCase();s==="defaultValue"&&"value"in t&&t.value==null?s="value":s==="download"&&a===!0?a="":c==="translate"&&a==="no"?a=!1:c[0]==="o"&&c[1]==="n"?c==="ondoubleclick"?s="ondblclick":c!=="onchange"||i!=="input"&&i!=="textarea"||cC(t.type)?c==="onfocus"?s="onfocusin":c==="onblur"?s="onfocusout":oC.test(s)&&(s=c):c=s="oninput":o&&rC.test(s)?s=s.replace(sC,"-$&").toLowerCase():a===null&&(a=void 0),c==="oninput"&&r[s=c]&&(s="oninputCapture"),r[s]=a}}i=="select"&&r.multiple&&Array.isArray(r.value)&&(r.value=Es(t.children).forEach(function(u){u.props.selected=r.value.indexOf(u.props.value)!=-1})),i=="select"&&r.defaultValue!=null&&(r.value=Es(t.children).forEach(function(u){u.props.selected=r.multiple?r.defaultValue.indexOf(u.props.value)!=-1:r.defaultValue==u.props.value})),t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,"className",hC)):(t.className&&!t.class||t.class&&t.className)&&(r.class=r.className=t.className),e.props=r}(n),n.$$typeof=iC,Qf&&Qf(n)};var em=te.__r;te.__r=function(n){em&&em(n),n.__c};var tm=te.diffed;te.diffed=function(n){tm&&tm(n);var e=n.props,t=n.__e;t!=null&&n.type==="textarea"&&"value"in e&&e.value!==t.value&&(t.value=e.value==null?"":e.value)};function pC(n){const{placeholder:e="Type your message...",value:t,defaultValue:i,onChange:r,onSend:o,onCancel:s,onExpand:a,isLoading:c=!1,disabled:u=!1,maxLength:l=500,children:d}=n,[h,p]=de(t||i||""),[m,f]=de((t||i||"").length>24),g=bn(null);Rs(()=>{m&&(a==null||a(!0))},[]);const y=t!==void 0?t:h,b=k=>{const C=k.currentTarget.value;t===void 0&&p(C),r==null||r(C)},S=k=>{k.key==="Escape"&&(p(t||i||""),f(!1),s==null||s()),k.key==="Enter"&&!k.shiftKey&&y.trim()&&(k.preventDefault(),p(t||i||""),f(!1),w()),(y||"").length>=24&&!m&&(f(!0),a==null||a(!0))};Dt(()=>{g.current&&g.current.focus()},[g.current]);const w=()=>{!y.trim()||c||u||(o==null||o(y.trim()),t===void 0&&p(""))};return _("div",{className:`obi-message-input ${m?"expanded":""}`,children:[_("div",{className:"container",children:_("textarea",{ref:g,className:"field",placeholder:e,value:y,onInput:b,onKeyDown:S,disabled:u||c,maxLength:l,rows:1})}),_("div",{className:"button-container",children:[m&&_("div",{children:d}),_("button",{className:"obi-button send",onClick:w,disabled:!y.trim()||c||u,type:"button",children:_("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:_("path",{d:"M6.00016 10.6673V1.33398M6.00016 1.33398L1.3335 6.00065M6.00016 1.33398L10.6668 6.00065",stroke:"#F3F3F3","stroke-width":"1.6","stroke-linecap":"round","stroke-linejoin":"round"})})})]})]})}function fC(n){const{currentStep:e,totalSteps:t,stepNames:i,className:r}=n,o=Array.from({length:t},(c,u)=>({isCompleted:u<e,stepNumber:u+1})),s=i[e-1]||`Step ${e}`,a=`${e}/${t} \u2022 ${s}`;return _("div",{class:`obi-course-progress ${r||""}`,children:[_("div",{class:"obi-course-progress-steps",children:o.map((c,u)=>_("div",{class:"obi-course-progress-container",children:_("div",{class:`obi-course-progress-step ${c.isCompleted?"completed":""}`})},u))}),_("div",{class:"obi-course-progress-description",children:a})]})}function nm({className:n="",size:e=64}){return _("svg",{width:e,height:e,viewBox:"0 0 256 256",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:_("path",{d:"M158.803 0L160.352 0.0399439C176.267 0.844061 188.922 13.9634 188.922 30.0311C188.922 46.6174 175.438 60.0653 158.803 60.0656H99.0263L98.9061 60.0722C78.8071 61.4795 62.6269 77.004 60.2644 96.7673L60.241 96.9704V158.93L60.2644 159.13C62.7406 179.86 80.4234 195.934 101.881 195.935H153.842C176.993 195.935 195.759 177.223 195.759 154.14V96.9138L195.799 95.3693C196.606 79.5009 209.766 66.8827 225.881 66.8827C242.515 66.8834 256 80.328 256 96.9138V159.086L255.963 160.564C255.225 175.748 243.176 187.971 228.038 189.038V189.214C207.121 190.591 190.4 207.263 189.019 228.119H188.842C187.738 243.7 174.712 256 158.803 256H96.4491C79.8147 256 66.3309 242.555 66.3302 225.969C66.3302 225.673 66.3349 225.375 66.3436 225.077H66.3503H66.3035C63.3344 206.008 47.4427 190.589 27.8321 189.231L27.8354 189.031C12.2702 187.868 0.000167669 174.905 0 159.086V96.9138L0.0367222 95.4192C0.791087 80.0787 13.0909 67.7634 28.453 66.9293C47.7697 65.3039 63.3522 50.3234 66.2969 31.4658L66.3469 31.1595L66.3369 30.85C66.3301 30.5933 66.3302 30.3238 66.3302 30.0311C66.3309 13.4454 79.8148 0.000165137 96.4491 0H158.803Z",fill:"currentColor"})})}function mC(n){const{disabled:e,inPlan:t,isPaused:i}=n,[r,o]=de(null),[s,a]=de(n.isActive??n.defaultIsActive??!1),[c,u]=de(!1),[l,d]=de(n.cancelling??!1),[h,p]=de(n.messaging??!1),[m,f]=de(!1),[g,y]=de(h),[b,S]=de(!1);Rs(()=>{n.messaging!==void 0&&p(n.messaging)},[n.messaging]);function w(){a(!0),u(!1),S(!0),n.messaging!==void 0&&p(n.messaging)}function k(){}function C(){r&&(clearTimeout(r),o(null))}function x(){o(setTimeout(()=>{a(n.defaultIsActive??!1),S(!1)},400))}function I(ye){var Nt;f(!1),(Nt=n.onMessage)==null||Nt.call(n,ye)}function P(){var ye;p(!1),f(!1),a(!1),u(!0),(ye=n.onMinimize)==null||ye.call(n)}function D(){var ye;p(!1),d(!0),f(!1),(ye=n.onCancelClick)==null||ye.call(n)}function A(){var ye;t||((ye=n.onOpen)==null||ye.call(n))}function L(ye){var Nt,lr,yn,Dn,Zn,Li;switch(ye){case"need-help":(Nt=n.onMessage)==null||Nt.call(n,"I'm struggling, can you look at my screen and help me out."),(lr=n.onOneClickAction)==null||lr.call(n,"need-help");break;case"continue":(yn=n.onMessage)==null||yn.call(n,"Okay, let's continue."),(Dn=n.onOneClickAction)==null||Dn.call(n,"continue");break;case"say-again":(Zn=n.onMessage)==null||Zn.call(n,"Please say that again."),(Li=n.onOneClickAction)==null||Li.call(n,"say-again");break}}function V(ye){var Nt;n.messaging===void 0&&((Nt=n.onMessagingChange)==null||Nt.call(n,ye),p(ye)),ye||f(!1)}const Y=n.isActive??((s||t)&&!c&&!e),O=Y&&t,F=Y&&t&&!m,X=n.speakingStatus==="user-speaking",K=n.speakingStatus==="thinking",Q=n.speakingStatus==="busy",Ce=Y&&!t&&!l&&b,Ge=Y&&t&&i&&!X&&!l,Ie=Y&&t&&!Ge&&!X&&h!==g&&!l,dt=Y&&t&&i&&X&&!l,Me=Y&&t&&!i&&X&&!l,Pe=Y&&t&&!i&&Q&&!l,ie=h&&X,Ze=Ce||Ge||dt||Me||Ie||l,kt=400,Gt=Y&&t&&!m,ur=Ce?5:10;return Rs(()=>{y(h)},[X]),!t&&!l?_(gC,{...n}):!t&&l?_(vC,{onOtherSelect:()=>{var ye;(ye=n.onCancelReasonOther)==null||ye.call(n)},onCancelReason:ye=>{var Nt;a(n.defaultIsActive??!1),d(!1),(Nt=n.onCancelReason)==null||Nt.call(n,ye)},onClose:()=>{a(n.defaultIsActive??!1),d(!1)}}):_($u,{className:`obi-widget-panel ${O?"expanded":""} ${m?"maximized":""} ${h?"messaging":""} ${Q?"tool-usage":""}`,children:[_("div",{className:`obi-widget ${Y?"active":""} ${t?"in-plan":""}`,onMouseEnter:C,onMouseLeave:x,children:[F&&_(nn,{type:"cancel",onClick:D,disabled:l,title:"Cancel session"}),F&&!i&&_(nn,{type:"pause",onClick:n.onPause,title:"Pause session"}),F&&i&&_(nn,{type:"play",onClick:n.onUnpause,title:"Unpause session"}),_(Lt,{className:"obi-widget-popout",open:Ze,trigger:null,delayMs:kt,offset:ur,children:[_(Lt.Target,{children:[ie&&_(pC,{value:n.message,defaultValue:"Okay, let's continue.",onCancel:()=>V(!1),onSend:I,onExpand:f,onChange:n.onMessageChange,children:_("div",{className:"obi-widget-buttons",children:[_(nn,{type:"cancel",onClick:D,disabled:l,title:"Cancel session"}),!i&&_(nn,{type:"pause",onClick:n.onPause,title:"Pause session"}),i&&_(nn,{type:"play",onClick:n.onUnpause,title:"Unpause session"}),_(nn,{type:h?"voice":"message",disabled:n.messaging!==void 0,onClick:()=>V(!h),title:h?"Voice input":"Text input"}),_(nn,{type:"minimize",onClick:P,title:"Minimize widget"})]})}),!ie&&_(Os,{className:Y&&!t?"button":"",isActive:Y,speakingStatus:n.speakingStatus,onClick:A,onMouseEnter:w,onMouseLeave:k,children:[Y&&!t&&!Pe&&_("span",{className:"obi-widget-pill-text",children:"Tutorials"}),Y&&t&&Pe&&_("span",{className:"obi-widget-pill-text",children:"Searching knowledge ..."}),Y&&t&&!K&&!Pe&&_(zf,{getBands:n.spectrum}),Y&&K&&!Pe&&_(qf,{})]})]}),_(Lt.Content,{children:_("div",{onMouseLeave:x,children:[Ce&&_(ei,{onClick:A,children:"Click to see all"}),Ge&&_(ei,{children:"Session will pause shortly"}),Ie&&_(ei,{children:["Switched to ",h?"chat":"voice"]}),dt&&_(ei,{children:"Paused"}),Me&&_("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"4px"},children:[_(ei,{onClick:()=>L("need-help"),children:"Need help"}),_(ei,{onClick:()=>L("continue"),children:"Continue"}),_(ei,{onClick:()=>L("say-again"),children:"Say again"})]}),l&&_(Xw,{onContinue:()=>{var ye;(ye=n.onCancelAbort)==null||ye.call(n),d(!1),n.messaging!==void 0&&p(n.messaging)},onWrapUp:()=>{var ye;(ye=n.onCancel)==null||ye.call(n)}})]})})]}),F&&_(nn,{type:h?"voice":"message",disabled:n.messaging!==void 0,onClick:()=>V(!h),title:h?"Voice input":"Text input"}),F&&_(nn,{type:"minimize",onClick:P,title:"Minimize widget"})]}),Gt&&n.courseProgress&&_("div",{className:`obi-course-progress-container ${h?"expanded":""}`,children:_(fC,{currentStep:n.courseProgress.currentStep,totalSteps:n.courseProgress.totalSteps,stepNames:n.courseProgress.stepNames})})]})}function gC(n){const{disabled:e,completedTutorials:t,totalTutorials:i,agentName:r}=n,[o,s]=de(null),[a,c]=de(n.isActive??n.defaultIsActive??!1),[u,l]=de(!1),[d,h]=de(n.hovered??!1);function p(){var I;c(!0),l(!1),h(!0),(I=n.onHover)==null||I.call(n,!0)}function m(){}function f(){o&&(clearTimeout(o),s(null))}function g(){a&&s(setTimeout(()=>{var I;c(n.defaultIsActive??!1),h(!1),(I=n.onHover)==null||I.call(n,!1)},400))}function y(){c(!1),l(!0)}function b(){var I;(I=n.onOpen)==null||I.call(n)}const S=n.hovered??(d&&!u),w=n.isActive??(a&&!e&&!u),k=w&&S,C=`round-button ${w?"active":""}`;let x=`${r||"Obi"}`;return t!==void 0&&i!==void 0&&t>=0&&i>0&&(x=`${t}/${i} completed`),_("div",{className:"obi-widget-out-of-plan-container",children:_("div",{className:`obi-widget-out-of-plan ${S?"hover":""} ${w?"active":""}`,onMouseEnter:f,onMouseLeave:g,children:[_("div",{className:C,style:{width:"30px",height:"30px"}}),_(Lt,{className:"obi-widget-popout",open:k,trigger:null,delayMs:400,offset:5,children:[_(Lt.Target,{children:_(qw,{className:w?"button":"",active:w,onClick:b,onMouseEnter:p,onMouseLeave:m,children:_("span",{className:"text",children:[_(nm,{size:16}),x]})})}),_(Lt.Content,{children:_("div",{onMouseLeave:g,children:_(ei,{className:"message",onClick:b,children:"Click to see all"})})})]}),_(nn,{className:C,type:"minimize",onClick:y,title:"Minimize widget"})]})})}function vC(n){return _("div",{className:"obi-widget-out-of-plan-container",children:_("div",{className:"obi-widget-out-of-plan",children:_(Lt,{className:"obi-widget-popout",open:!0,trigger:null,delayMs:100,offset:5,children:[_(Lt.Target,{children:_(zw,{active:!1})}),_(Lt.Content,{children:_(Jw,{onOtherSelect:()=>{var e;(e=n.onOtherSelect)==null||e.call(n)},onReasonSelect:(e,t)=>{var i;(i=n.onCancelReason)==null||i.call(n,e,t)},onClose:()=>{var e;(e=n.onClose)==null||e.call(n)}})})]})})})}function yC({open:n=!1,children:e,onClose:t}){return _(Bf,{open:n,onClose:t,children:_("div",{className:"tour content-area",children:n?typeof e=="function"?e():e:null})})}function vr({title:n="",subtitle:e="",agentName:t="Obi",buttonText:i="Continue",speakingState:r=null,actionDisabled:o=!1,href:s=null,centerVisual:a,description:c,button:u,onAction:l}){const[d,h]=de(o),[p,m]=de(!1),[f,g]=de(r);return Dt(()=>{p||(r==="listening"&&f!=="listening"&&d&&h(!1),r!=="listening"&&!d&&h(!0)),g(r)},[r,d]),Dt(()=>{h(o)},[o]),_("div",{className:"tour-content",children:_("div",{className:"container",children:[_("div",{className:"header",children:[_("h1",{className:"title",children:n}),_("p",{className:"subtitle",children:e})]}),_("div",{className:"visual",style:{background:"var(--obi-color-tint)"},children:a}),_("div",{className:"description",children:c}),_("div",{className:"button-container",children:u||_(s?"a":"button",{className:`action-button ${d?"disabled":""}`,onClick:()=>{d||(h(!0),m(!0),l==null||l())},disabled:d,...s?{href:s,target:"_blank",rel:"noopener noreferrer"}:{type:"button"},children:_("span",{className:"button-text",children:(()=>{switch(r){case"thinking":return"Loading...";case"speaking":return`${t} is speaking`;default:return i}})()})})})]})})}function bC({logoUrl:n="",appName:e="App"}){const[t,i]=de(!1),[r,o]=de(!1),s=()=>{i(!0)},a=()=>{o(!0),i(!1)},c={container:{display:"block"},logoContainer:{width:"480px",height:"240px",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"center",position:"relative",overflow:"hidden"},backgroundPattern:{position:"absolute",inset:0,zIndex:0,background:"#F5F5F5",backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='277' height='195' viewBox='0 0 277 195' fill='none'%3E%3Cpath opacity='0.4' d='M341.308 0.75C380.279 0.750001 411.872 24.3772 411.872 53.5229C411.872 82.6685 380.279 106.296 341.308 106.296H215.792C176.964 108.335 145.691 130.837 141.128 159.475V256.616C145.912 286.659 180.089 309.954 221.548 309.954H330.872C375.607 309.954 411.872 282.833 411.872 249.377V159.069C411.872 129.923 443.465 106.296 482.436 106.296C521.407 106.296 553 129.923 553 159.069V257.181C553 285.058 524.099 307.88 487.483 309.815C489.264 309.902 491.061 309.954 492.871 309.954C448.137 309.954 411.872 337.076 411.872 370.532C411.872 369.177 411.803 367.834 411.686 366.502C409.098 393.885 378.582 415.5 341.308 415.5H210.118C171.147 415.5 139.554 391.873 139.554 362.727C139.554 362.204 139.565 361.683 139.585 361.163C133.564 332.156 100.023 309.954 59.5488 309.954C61.4544 309.954 63.3441 309.9 65.2169 309.803C28.7434 307.76 -8.57239e-07 284.982 0 257.181V159.069C1.64632e-06 130.901 29.5078 107.89 66.6662 106.377C64.3207 106.224 61.9472 106.141 59.5488 106.141C100.012 106.141 133.54 83.951 139.575 54.9552C139.558 54.4793 139.554 54.0018 139.554 53.5229C139.554 24.3772 171.147 0.75 210.118 0.75H341.308Z' fill='white'/%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"190px 60px",backgroundSize:"300px 225px"},logoWrapper:{background:"#888888",width:"120px",height:"120px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"4px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",zIndex:10,overflow:"hidden"},appLogo:{width:"120px",height:"120px",objectFit:"cover",display:n&&!t&&r?"block":"none"},placeholderLogo:{width:"60px",height:"60px",background:"rgba(255, 255, 255, 0.2)",borderRadius:"4px",display:!n||t||!r?"flex":"none",alignItems:"center",justifyContent:"center",color:"rgba(255, 255, 255, 0.8)",fontSize:"24px",fontWeight:"bold"}};return _("div",{style:c.container,children:_("div",{style:c.logoContainer,children:[_("div",{style:c.backgroundPattern}),_("div",{style:c.logoWrapper,children:[n&&_("img",{style:c.appLogo,src:n,alt:`${e} logo`,onError:s,onLoad:a}),_("div",{style:c.placeholderLogo,children:e.charAt(0).toUpperCase()})]})]})})}function _C({session:n,speakingState:e,onAction:t}){const i=n.appName?`Navigate to ${n.appName}`:"Navigate to app",r=n.appName?`Open ${n.appName}`:"Open app",o=n.appName?`Enjoy the tutorial in ${n.appName}`:"Enjoy the tutorial";return _(vr,{title:i,subtitle:"Click the button below to open the app",agentName:n.agentName||"Obi",buttonText:r,speakingState:e,actionDisabled:!0,href:n.url,description:o,centerVisual:_(bC,{logoUrl:n.appLogoUrl,appName:n.appName}),onAction:t})}function kC({}){return _("div",{style:{borderRadius:"15px",boxShadow:"0 0 20px 2px var(--obi-color-primary)",backgroundColor:"var(--obi-color-primary)",transform:"scale(1.6)"},children:_(Os,{isActive:!0,children:_("div",{className:"obi-static-voice-visual",children:[_("div",{className:"column",children:_("div",{className:"bar bar-1"})}),_("div",{className:"column",children:_("div",{className:"bar bar-2"})}),_("div",{className:"column",children:_("div",{className:"bar bar-3"})}),_("div",{className:"column",children:_("div",{className:"bar bar-4"})}),_("div",{className:"column",children:_("div",{className:"bar bar-5"})}),_("div",{className:"column",children:_("div",{className:"bar bar-6"})}),_("div",{className:"column",children:_("div",{className:"bar bar-7"})}),_("div",{className:"column",children:_("div",{className:"bar bar-8"})})]})})})}function SC({session:n,speakingState:e,onAction:t}){return _(vr,{title:n.name,subtitle:"AI voice-guided tutorial",description:n.description,buttonText:"Start now",agentName:n.agentName||"Obi",speakingState:e,centerVisual:_(kC,{}),onAction:t})}function wC(){const n={host:{display:"block",position:"relative",width:"100%",height:"100%"},container:{position:"relative",width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},permissionDialog:{boxSizing:"border-box",display:"flex",flexDirection:"row",justifyContent:"flex-start",alignItems:"center",padding:"16px 20px",gap:"16px",position:"absolute",width:"344px",height:"125px",left:"calc(50% - 344px/2)",top:"calc(50% - 125px/2)",background:"#FFFFFF",border:"1px solid #E5E7EB",boxShadow:"0px 10px 15px -3px rgba(0, 0, 0, 0.1), 0px 4px 6px -2px rgba(0, 0, 0, 0.05)",borderRadius:"8px"},permissionContent:{width:"100%",display:"flex",flexDirection:"column",gap:"16px"},permissionContentTop:{display:"flex",flexDirection:"row",alignItems:"center",padding:"0px",gap:"16px"},micIconContainer:{color:"var(--obi-color-text)",boxSizing:"border-box",display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",padding:"12px",gap:"8px",width:"48px",height:"48px",background:"#F9FAFB",border:"1px solid #D1D5DB",borderRadius:"6px",flex:"none",order:0,flexGrow:0},micIcon:{width:"24px",height:"24px",flex:"none",order:0,flexGrow:0},permissionText:{flex:1,height:"24px",fontFamily:"'Inter', sans-serif",fontStyle:"normal",fontWeight:500,fontSize:"16px",lineHeight:"24px",display:"flex",alignItems:"center",color:"#111827",flexGrow:1,order:1},allowButton:{alignSelf:"flex-end",boxSizing:"border-box",display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",padding:"10px 20px",gap:"8px",minWidth:"80px",height:"40px",background:"#F9FAFB",border:"1px solid #D1D5DB",borderRadius:"6px",flex:"none",order:2,flexGrow:0,cursor:"pointer",fontFamily:"'Inter', sans-serif",fontStyle:"normal",fontWeight:500,fontSize:"14px",lineHeight:"20px",color:"#374151"},cursorPointer:{position:"absolute",width:"24px",height:"24px",right:"80px",bottom:"60px",zIndex:3,animation:"pointToAllow 2s ease-in-out infinite"},cursorSvg:{width:"100%",height:"100%",filter:"drop-shadow(0px 1px 1.8px rgba(0, 0, 0, 0.65))"}};return _("div",{style:n.host,children:[_("style",{children:`
2
- @keyframes pointToAllow {
3
- 0%, 100% { transform: translate(0, 0); }
4
- 50% { transform: translate(2px, -1px); }
5
- }
6
- `}),_("div",{style:n.container,children:[_("div",{style:n.permissionDialog,children:_("div",{style:n.permissionContent,children:[_("div",{style:n.permissionContentTop,children:[_("div",{style:n.micIconContainer,children:_("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:n.micIcon,children:[_("path",{d:"M12 19v3"}),_("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),_("rect",{x:"9",y:"2",width:"6",height:"13",rx:"3"})]})}),_("div",{style:n.permissionText,children:"Use your microphone"})]}),_("button",{style:n.allowButton,children:"Allow"})]})}),_("div",{style:n.cursorPointer,children:_("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:n.cursorSvg,children:[_("path",{d:"M12.586 12.586 19 19"}),_("path",{d:"M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z"})]})})]})]})}function CC({session:n,speakingState:e,onAction:t}){return _(vr,{title:"Connect your microphone",subtitle:"Watch for the prompt in your browser",agentName:n.agentName||"Obi",buttonText:"Continue",speakingState:e,actionDisabled:!0,description:`${n.agentName||"Obi"} will guide you through the tutorial by talking with you.`,centerVisual:_(wC,{}),onAction:t})}function TC({}){return _("div",{style:{borderRadius:"15px",boxShadow:"0 0 20px 2px var(--obi-color-primary)",backgroundColor:"var(--obi-color-primary)",transform:"scale(1.6)"},children:_(Os,{isActive:!0,children:_(qf,{})})})}function xC({session:n,speakingState:e,onAction:t}){return _(vr,{title:"Can you hear me?",subtitle:`Make sure your sound is on so you can hear ${n.agentName||"Obi"}`,agentName:n.agentName||"Obi",speakingState:e,actionDisabled:!0,description:`${n.agentName||"Obi"} will guide you through the tutorial by talking with you.`,centerVisual:_(TC,{}),onAction:t})}function EC(){const n={container:{display:"flex",justifyContent:"center",alignItems:"center"},skeletonContainer:{display:"flex",flexDirection:"column",flexShrink:0,gap:"10px",alignItems:"center",padding:"20px",margin:"0 auto",background:"white",borderRadius:"12px",border:"0.569px solid #E4E4E7",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",height:"234px",width:"344px"},headerSection:{display:"flex",position:"relative",gap:"16px",alignItems:"center",alignSelf:"stretch"},avatar:{position:"relative",background:"#F4F4F5",borderRadius:"50%",height:"55px",width:"55px",flexShrink:0,overflow:"hidden"},textLines:{display:"flex",position:"relative",flexDirection:"column",gap:"10px",alignItems:"flex-start",alignSelf:"stretch",width:"100%"},textLine:{position:"relative",borderRadius:"2px",background:"#F4F4F5",height:"18px",alignSelf:"stretch",overflow:"hidden"},contentSection:{display:"flex",position:"relative",flexDirection:"column",flexShrink:0,gap:"16px",justifyContent:"center",alignItems:"flex-start",alignSelf:"stretch",height:"62px"},contentBlock:{position:"relative",alignSelf:"stretch",borderRadius:"2px",background:"#F4F4F5",flex:"1 0 0",overflow:"hidden"},shimmer:{position:"absolute",top:0,left:"-150px",height:"100%",width:"150px",background:"linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent)",animation:"skeleton-loading 2s infinite"}};return _("div",{style:n.container,children:[_("style",{children:`
7
- @keyframes skeleton-loading {
8
- 0% { transform: translateX(-150px); }
9
- 50% { transform: translateX(344px); }
10
- 100% { transform: translateX(344px); }
11
- }
12
- `}),_("article",{style:n.skeletonContainer,role:"status","aria-label":"Loading content",children:[_("section",{style:n.headerSection,children:[_("div",{style:n.avatar,role:"img","aria-label":"Loading avatar",children:_("div",{style:n.shimmer})}),_("div",{style:n.textLines,children:[_("div",{style:n.textLine,role:"presentation","aria-label":"Loading text line 1",children:_("div",{style:n.shimmer})}),_("div",{style:n.textLine,role:"presentation","aria-label":"Loading text line 2",children:_("div",{style:n.shimmer})})]})]}),_("section",{style:n.contentSection,children:_("div",{style:n.contentBlock,role:"presentation","aria-label":"Loading card content",children:_("div",{style:n.shimmer})})})]})]})}function IC({}){const n={host:{display:"block"},shareContainer:{width:"480px",height:"240px",borderRadius:"12px",display:"grid",placeItems:"center",overflow:"hidden",position:"relative",backgroundColor:"var(--obi-color-tint)"},controlsRow:{zIndex:10,gridRowStart:1,gridColumnStart:1,display:"flex",alignSelf:"flex-start",marginTop:"36px",alignItems:"center",gap:"8px"},monitorIconContainer:{display:"flex",height:"40px",width:"40px",aspectRatio:"1",alignItems:"center",justifyContent:"center",gap:"8px",borderRadius:"2px",border:"1px solid #E4E4E7",background:"#F8FAFC",padding:"8px"},monitorIcon:{width:"24px",height:"24px",color:"#111827"},tabSelector:{display:"flex",width:"260px",height:"40px",padding:"4px",alignItems:"center",borderRadius:"2px",background:"#E4E4E7"},tabButton:e=>({display:"flex",flex:1,alignSelf:"stretch",alignItems:"center",justifyContent:"center",gap:"10px",borderRadius:"2px",padding:"6px 12px",border:"none",cursor:"pointer",fontFamily:"'Satoshi', sans-serif",fontSize:"14px",fontWeight:500,opacity:e?1:.4,background:e?"white":"#F8FAFC",boxShadow:e?"0 1px 2px 0 rgba(0, 0, 0, 0.05)":"none"}),skeletonContainer:{marginTop:"104px",gridColumnStart:1,gridRowStart:1,alignSelf:"center"}};return _("div",{style:n.host,children:_("div",{style:n.shareContainer,children:[_("div",{style:n.controlsRow,children:[_("div",{style:n.monitorIconContainer,children:_("svg",{style:n.monitorIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[_("rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",ry:"2"}),_("line",{x1:"8",x2:"16",y1:"21",y2:"21"}),_("line",{x1:"12",x2:"12",y1:"17",y2:"21"})]})}),_("div",{style:n.tabSelector,children:[_("button",{style:n.tabButton(!1),children:"Tab"}),_("button",{style:n.tabButton(!0),children:"Window"})]})]}),_("div",{style:n.skeletonContainer,children:_(EC,{})})]})})}function RC({session:n,speakingState:e,onAction:t}){return _(vr,{title:"Connect your screen",subtitle:"Watch for the prompt in your browser",agentName:n.agentName||"Obi",buttonText:"Share screen",speakingState:e,description:`${n.agentName||"Obi"} will guide you through ${n.appName||"the app"} by watching your screen.`,centerVisual:_(IC,{}),actionDisabled:!0,onAction:t})}function PC({spectrum:n}){return _("div",{style:{borderRadius:"15px",boxShadow:"0 0 20px 2px var(--obi-color-primary)",backgroundColor:"var(--obi-color-primary)",transform:"scale(1.6)"},children:_(Os,{isActive:!0,children:_(zf,{getBands:n})})})}function OC({session:n,speakingState:e,spectrum:t,onAction:i}){return _(vr,{title:"Overview",subtitle:`${n.agentName||"Obi"} will start your tutorial in a moment`,agentName:n.agentName||"Obi",speakingState:e,description:`Get ready to explore ${n.appName||"the app"} with ${n.agentName||"Obi"}.`,centerVisual:_(PC,{spectrum:t}),actionDisabled:!0,onAction:i})}function AC({id:n,name:e,description:t,duration:i=10,order:r=0,selected:o=!1,completed:s=!1,onClick:a}){return _("div",{className:`course-container ${o?"selected":""}`,onClick:()=>{a==null||a({id:n,name:e,description:t,duration:i,order:r})},children:[_("div",{className:"header-row",children:[_("h2",{className:"course-title",children:e}),s&&_("span",{className:"duration",children:"Completed"})]}),t&&_("p",{className:"course-description",children:t})]})}function MC({courses:n=[],selectedCourseId:e=null,loading:t=!1,error:i="",onCourseSelect:r}){const[o,s]=de(""),a=l=>{const d=l.currentTarget;s(d.value)},c=l=>{r==null||r(l)};if(t)return _("div",{className:"loading",children:"Loading..."});if(i)return _("div",{className:"error",children:i});if(!n||n.length===0)return _("div",{className:"empty",children:"No courses available"});const u=n.filter(l=>l.name.toLowerCase().includes(o.toLowerCase())||(l.description||"").toLowerCase().includes(o.toLowerCase()));return _("div",{className:"tour-select",children:[_("div",{className:"controls",children:[_("div",{className:"tabs",children:_("button",{className:"tab active",children:"All"})}),_("div",{className:"filter",children:[_("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:_("path",{d:"M10.0417 8.75002H9.42087L9.20004 8.53502C9.96921 7.63585 10.4417 6.47502 10.4417 5.20835C10.4417 2.56085 8.32254 0.441681 5.67504 0.441681C3.02754 0.441681 0.908374 2.56085 0.908374 5.20835C0.908374 7.85585 3.02754 9.97502 5.67504 9.97502C6.94171 9.97502 8.10254 9.50252 9.00171 8.73335L9.22671 8.95418V9.57502L13.2167 13.5592L14.375 12.4008L10.0417 8.75002ZM5.67504 8.75002C3.72754 8.75002 2.15837 7.18085 2.15837 5.20835C2.15837 3.23585 3.72754 1.66668 5.67504 1.66668C7.62254 1.66668 9.19171 3.23585 9.19171 5.20835C9.19171 7.18085 7.62254 8.75002 5.67504 8.75002Z",fill:"#6B7280"})}),_("input",{type:"text",placeholder:"Search...",value:o,onInput:a})]})]}),_("div",{className:"course-grid",children:u.sort((l,d)=>(l.order||0)-(d.order||0)).map(l=>{const d=l.id===e;return _(AC,{id:l.id,name:l.name,description:l.description||"",duration:l.duration,order:l.order||0,completed:l.completed,selected:d,onClick:c},l.id)})})]})}function NC({open:n,courses:e=[],loading:t=!1,error:i="",agentName:r="Obi",productName:o,onClose:s,onCourseSelect:a,onCourseHighlight:c}){const[u,l]=de(null),d=p=>{l(p),c==null||c(p)},h=()=>{u&&a&&a(u)};return _(Bf,{open:n,onClose:s,size:"large",children:_("div",{className:"tour-select-modal-container",children:[_("div",{className:"header",children:[_("div",{className:"icon",style:{color:"white"},children:_(nm,{})}),_("div",{className:"title-section",children:t?_(St,{children:[_("div",{className:"skeleton skeleton-title"}),_("div",{className:"skeleton skeleton-subtitle"})]}):_(St,{children:[_("h1",{children:[r," AI Training Assistant"]}),_("p",{className:"subtitle",children:["Start a tutorial and learn how to use ",o," through an interactive conversation."]})]})})]}),_("div",{className:"course-list-wrapper",children:_(MC,{courses:e,selectedCourseId:(u==null?void 0:u.id)||"",loading:t,error:i,onCourseSelect:d})}),_("div",{className:"footer",children:[_("button",{className:"obi-button footer-button",onClick:h,disabled:!u,children:[_("span",{children:"Get started"}),_("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none",children:_("path",{d:"M3.83325 8.00065H13.1666M13.1666 8.00065L8.49992 3.33398M13.1666 8.00065L8.49992 12.6673",stroke:u?"#FAFAFA":"#999","stroke-width":"1.33","stroke-linecap":"round","stroke-linejoin":"round"})})]}),_("p",{className:"footer-text",children:"Sessions are securely recorded for quality improvement purposes."})]})]})})}function DC({session:n,sessionState:e,speakingState:t,spectrum:i,onStart:r,onContinue:o,onShareMicrophone:s,onShareScreen:a,onModalChange:c}){const[u,l]=de(null);function d(p){u!==p&&(c==null||c(p),l(p))}function h(){e==="connecting"||e==="connected"||!e?r==null||r():e==="volume-check"||e==="mic-check"?o==null||o():e==="mic-share"?s==null||s():e==="screen-share"&&(a==null||a())}return qu(()=>{switch(e){case null:case"connecting":case"connected":return d("session-start"),_(SC,{session:n,speakingState:t,onAction:h});case"volume-check":return d("voice-guidance"),_(xC,{session:n,speakingState:t,onAction:h});case"mic-check":return d("overview"),_(OC,{session:n,speakingState:t,spectrum:i,onAction:h});case"mic-share":return d("share-mic"),_(CC,{session:n,speakingState:t,onAction:h});case"screen-share":return d("share-screen"),_(RC,{session:n,speakingState:t,onAction:h});case"navigate":return d("navigate"),_(_C,{session:n,speakingState:t,onAction:h});default:return null}},[e,t,r,o,s,a])}function LC(n){const{session:e,sessionState:t,speakingState:i,spectrum:r,onClose:o,onStart:s,onContinue:a,onShareMicrophone:c,onShareScreen:u,onModalChange:l}=n,[d,h]=de(null);function p(g){l==null||l(g),h(g)}function m(g){o(g,d),h(null)}const f=(n.open??!0)&&(!t||t==="connecting"||t==="connected"||t==="volume-check"||t==="mic-check"||t==="mic-share"||t==="screen-share"||t==="navigate");return _(yC,{open:f,onClose:m,children:()=>_(DC,{session:e,sessionState:t,speakingState:i,spectrum:r,onStart:s,onContinue:a,onShareMicrophone:c,onShareScreen:u,onModalChange:p})})}const UC={identify:()=>{},track:()=>{},page:()=>{},reset:()=>{}};let im=null;function FC(n){im=n}function fe(){return im||UC}const BC=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,rm="9.23.0",yr=globalThis;function jC(n,e,t=yr){const i=t.__SENTRY__=t.__SENTRY__||{},r=i[rm]=i[rm]||{};return r[n]||(r[n]=e())}const VC="Sentry Logger ",om=["debug","info","warn","error","log","assert","trace"],sm={};function zC(n){if(!("console"in yr))return n();const e=yr.console,t={},i=Object.keys(sm);i.forEach(r=>{const o=sm[r];t[r]=e[r],e[r]=o});try{return n()}finally{i.forEach(r=>{e[r]=t[r]})}}function qC(){let n=!1;const e={enable:()=>{n=!0},disable:()=>{n=!1},isEnabled:()=>n};return BC?om.forEach(t=>{e[t]=(...i)=>{n&&zC(()=>{yr.console[t](`${VC}[${t}]:`,...i)})}}):om.forEach(t=>{e[t]=()=>{}}),e}jC("logger",qC);const am=1e3;function WC(){return Date.now()/am}function GC(){const{performance:n}=yr;if(!(n!=null&&n.now))return WC;const e=Date.now()-n.now(),t=n.timeOrigin==null?e:n.timeOrigin;return()=>(t+n.now())/am}GC();const cm=50,br="?",um=/\(error: (.*)\)/,lm=/captureMessage|captureException/;function $C(...n){const e=n.sort((t,i)=>t[0]-i[0]).map(t=>t[1]);return(t,i=0,r=0)=>{const o=[],s=t.split(`
13
- `);for(let a=i;a<s.length;a++){const c=s[a];if(c.length>1024)continue;const u=um.test(c)?c.replace(um,"$1"):c;if(!u.match(/\S*Error: /)){for(const l of e){const d=l(u);if(d){o.push(d);break}}if(o.length>=cm+r)break}}return HC(o.slice(r))}}function HC(n){if(!n.length)return[];const e=Array.from(n);return/sentryWrapped/.test(Ns(e).function||"")&&e.pop(),e.reverse(),lm.test(Ns(e).function||"")&&(e.pop(),lm.test(Ns(e).function||"")&&e.pop()),e.slice(0,cm).map(t=>({...t,filename:t.filename||Ns(e).filename,function:t.function||br}))}function Ns(n){return n[n.length-1]||{}}var dm;(function(n){n[n.PENDING=0]="PENDING";const e=1;n[n.RESOLVED=e]="RESOLVED";const t=2;n[n.REJECTED=t]="REJECTED"})(dm||(dm={})),yr._sentryClientToLogBufferMap=new WeakMap,typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const KC=30,YC=50;function Yu(n,e,t,i){const r={filename:n,function:e==="<anonymous>"?br:e,in_app:!0};return t!==void 0&&(r.lineno=t),i!==void 0&&(r.colno=i),r}const XC=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,JC=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,ZC=/\((\S*)(?::(\d+))(?::(\d+))\)/,QC=n=>{const e=XC.exec(n);if(e){const[,i,r,o]=e;return Yu(i,br,+r,+o)}const t=JC.exec(n);if(t){if(t[2]&&t[2].indexOf("eval")===0){const o=ZC.exec(t[2]);o&&(t[2]=o[1],t[3]=o[2],t[4]=o[3])}const[i,r]=hm(t[1]||br,t[2]);return Yu(r,i,t[3]?+t[3]:void 0,t[4]?+t[4]:void 0)}},e1=[KC,QC],t1=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,n1=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;$C(...[e1,[YC,n=>{const e=t1.exec(n);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const r=n1.exec(e[3]);r&&(e[1]=e[1]||"eval",e[3]=r[1],e[4]=r[2],e[5]="")}let t=e[3],i=e[1]||br;return[i,t]=hm(i,t),Yu(t,i,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}}]]);const hm=(n,e)=>{const t=n.indexOf("safari-extension")!==-1,i=n.indexOf("safari-web-extension")!==-1;return t||i?[n.indexOf("@")!==-1?n.split("@")[0]:br,t?`safari-extension:${e}`:`safari-web-extension:${e}`]:[n,e]};typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;var W;if(typeof window>"u"){var pm={hostname:""};W={crypto:{randomUUID:function(){throw Error("unsupported")}},navigator:{userAgent:"",onLine:!0},document:{createElement:function(){return{}},location:pm,referrer:""},screen:{width:0,height:0},location:pm,addEventListener:function(){},removeEventListener:function(){}}}else W=window;function fm(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,i=new Array(e);t<e;t++)i[t]=n[t];return i}function mm(n,e,t,i,r,o,s){try{var a=n[o](s),c=a.value}catch(u){t(u);return}a.done?e(c):Promise.resolve(c).then(i,r)}function Xu(n){return function(){var e=this,t=arguments;return new Promise(function(i,r){var o=n.apply(e,t);function s(c){mm(o,i,r,s,a,"next",c)}function a(c){mm(o,i,r,s,a,"throw",c)}s(void 0)})}}function Ds(n,e,t){return gm()?Ds=Reflect.construct:Ds=function(i,r,o){var s=[null];s.push.apply(s,r);var a=Function.bind.apply(i,s),c=new a;return o&&ko(c,o.prototype),c},Ds.apply(null,arguments)}function i1(n,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,i.key,i)}}function mt(n,e,t){return e&&i1(n.prototype,e),n}function me(){return me=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},me.apply(this,arguments)}function Ju(n){return Ju=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Ju(n)}function wt(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&ko(n,e)}function ne(n,e){return e!=null&&typeof Symbol<"u"&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](n):n instanceof e}function r1(n){return Function.toString.call(n).indexOf("[native code]")!==-1}function _o(n,e){if(n==null)return{};var t={},i=Object.keys(n),r,o;for(o=0;o<i.length;o++)r=i[o],!(e.indexOf(r)>=0)&&(t[r]=n[r]);return t}function ko(n,e){return ko=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},ko(n,e)}function oe(n){"@swc/helpers - typeof";return n&&typeof Symbol<"u"&&n.constructor===Symbol?"symbol":typeof n}function o1(n,e){if(n){if(typeof n=="string")return fm(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);if(t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set")return Array.from(t);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return fm(n,e)}}function Ls(n){var e=typeof Map=="function"?new Map:void 0;return Ls=function(t){if(t===null||!r1(t))return t;if(typeof t!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e<"u"){if(e.has(t))return e.get(t);e.set(t,i)}function i(){return Ds(t,arguments,Ju(this).constructor)}return i.prototype=Object.create(t.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),ko(i,t)},Ls(n)}function gm(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(gm=function(){return!!n})()}function H(n,e){var t=typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t)return(t=t.call(n)).next.bind(t);if(Array.isArray(n)||(t=o1(n))||e){t&&(n=t);var i=0;return function(){return i>=n.length?{done:!0}:{done:!1,value:n[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function So(n,e){var t,i,r,o,s={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(u){return function(l){return c([u,l])}}function c(u){if(t)throw new TypeError("Generator is already executing.");for(;s;)try{if(t=1,i&&(r=u[0]&2?i.return:u[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,u[1])).done)return r;switch(i=0,r&&(u=[u[0]&2,r.value]),u[0]){case 0:case 1:r=u;break;case 4:return s.label++,{value:u[1],done:!1};case 5:s.label++,i=u[1],u=[0];continue;case 7:u=s.ops.pop(),s.trys.pop();continue;default:if(r=s.trys,!(r=r.length>0&&r[r.length-1])&&(u[0]===6||u[0]===2)){s=0;continue}if(u[0]===3&&(!r||u[1]>r[0]&&u[1]<r[3])){s.label=u[1];break}if(u[0]===6&&s.label<r[1]){s.label=r[1],r=u;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(u);break}r[2]&&s.ops.pop(),s.trys.pop();continue}u=e.call(n,s)}catch(l){u=[6,l],i=0}finally{t=r=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function vm(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}var s1=Object.defineProperty,a1=function(n,e,t){return e in n?s1(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t},z=function(n,e,t){return a1(n,(typeof e>"u"?"undefined":oe(e))!=="symbol"?e+"":e,t)},ym,c1=Object.defineProperty,u1=function(n,e,t){return e in n?c1(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t},bm=function(n,e,t){return u1(n,(typeof e>"u"?"undefined":oe(e))!=="symbol"?e+"":e,t)},ct=function(n){return n[n.Document=0]="Document",n[n.DocumentType=1]="DocumentType",n[n.Element=2]="Element",n[n.Text=3]="Text",n[n.CDATA=4]="CDATA",n[n.Comment=5]="Comment",n}(ct||{}),_m={Node:["childNodes","parentNode","parentElement","textContent"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},km={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},Us={},l1=function(){return!!globalThis.Zone};function Zu(n){if(Us[n])return Us[n];var e=globalThis[n],t=e.prototype,i=n in _m?_m[n]:void 0,r=!!(i&&i.every(function(l){var d,h;return!!((h=(d=Object.getOwnPropertyDescriptor(t,l))==null?void 0:d.get)!=null&&h.toString().includes("[native code]"))})),o=n in km?km[n]:void 0,s=!!(o&&o.every(function(l){var d;return typeof t[l]=="function"&&((d=t[l])==null?void 0:d.toString().includes("[native code]"))}));if(r&&s&&!l1())return Us[n]=e.prototype,e.prototype;try{var a=document.createElement("iframe");document.body.appendChild(a);var c=a.contentWindow;if(!c)return e.prototype;var u=c[n].prototype;return document.body.removeChild(a),u?Us[n]=u:t}catch{return t}}var Qu={};function ti(n,e,t){var i,r=n+"."+String(t);if(Qu[r])return Qu[r].call(e);var o=Zu(n),s=(i=Object.getOwnPropertyDescriptor(o,t))==null?void 0:i.get;return s?(Qu[r]=s,s.call(e)):e[t]}var el={};function Sm(n,e,t){var i=n+"."+String(t);if(el[i])return el[i].bind(e);var r=Zu(n),o=r[t];return typeof o!="function"?e[t]:(el[i]=o,o.bind(e))}function d1(n){return ti("Node",n,"childNodes")}function h1(n){return ti("Node",n,"parentNode")}function p1(n){return ti("Node",n,"parentElement")}function f1(n){return ti("Node",n,"textContent")}function m1(n,e){return Sm("Node",n,"contains")(e)}function g1(n){return Sm("Node",n,"getRootNode")()}function v1(n){return!n||!("host"in n)?null:ti("ShadowRoot",n,"host")}function y1(n){return n.styleSheets}function b1(n){return!n||!("shadowRoot"in n)?null:ti("Element",n,"shadowRoot")}function _1(n,e){return ti("Element",n,"querySelector")(e)}function k1(n,e){return ti("Element",n,"querySelectorAll")(e)}function S1(){return Zu("MutationObserver").constructor}var Ct={childNodes:d1,parentNode:h1,parentElement:p1,textContent:f1,contains:m1,getRootNode:g1,host:v1,styleSheets:y1,shadowRoot:b1,querySelector:_1,querySelectorAll:k1,mutationObserver:S1};function wm(n){return n.nodeType===n.ELEMENT_NODE}function wo(n){var e=n&&"host"in n&&"mode"in n&&Ct.host(n)||null;return!!(e&&"shadowRoot"in e&&Ct.shadowRoot(e)===n)}function Co(n){return Object.prototype.toString.call(n)==="[object ShadowRoot]"}function w1(n){return n.includes(" background-clip: text;")&&!n.includes(" -webkit-background-clip: text;")&&(n=n.replace(/\sbackground-clip:\s*text;/g," -webkit-background-clip: text; background-clip: text;")),n}function C1(n){var e=n.cssText;if(e.split('"').length<3)return e;var t=["@import","url("+JSON.stringify(n.href)+")"];return n.layerName===""?t.push("layer"):n.layerName&&t.push("layer("+n.layerName+")"),n.supportsText&&t.push("supports("+n.supportsText+")"),n.media.length&&t.push(n.media.mediaText),t.join(" ")+";"}function tl(n){try{var e=n.rules||n.cssRules;if(!e)return null;var t=n.href;!t&&n.ownerNode&&n.ownerNode.ownerDocument&&(t=n.ownerNode.ownerDocument.location.href);var i=Array.from(e,function(r){return Cm(r,t)}).join("");return w1(i)}catch{return null}}function Cm(n,e){if(x1(n)){var t;try{t=tl(n.styleSheet)||C1(n)}catch{t=n.cssText}return n.styleSheet.href?Fs(t,n.styleSheet.href):t}else{var i=n.cssText;return E1(n)&&n.selectorText.includes(":")&&(i=T1(i)),e?Fs(i,e):i}}function T1(n){var e=/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;return n.replace(e,"$1\\$2")}function x1(n){return"styleSheet"in n}function E1(n){return"selectorText"in n}var Tm=function(){function n(){bm(this,"idNodeMap",new Map),bm(this,"nodeMetaMap",new WeakMap)}var e=n.prototype;return e.getId=function(t){var i;if(!t)return-1;var r=(i=this.getMeta(t))==null?void 0:i.id;return r??-1},e.getNode=function(t){return this.idNodeMap.get(t)||null},e.getIds=function(){return Array.from(this.idNodeMap.keys())},e.getMeta=function(t){return this.nodeMetaMap.get(t)||null},e.removeNodeFromMap=function(t){var i=this,r=this.getId(t);this.idNodeMap.delete(r),t.childNodes&&t.childNodes.forEach(function(o){return i.removeNodeFromMap(o)})},e.has=function(t){return this.idNodeMap.has(t)},e.hasNode=function(t){return this.nodeMetaMap.has(t)},e.add=function(t,i){var r=i.id;this.idNodeMap.set(r,t),this.nodeMetaMap.set(t,i)},e.replace=function(t,i){var r=this.getNode(t);if(r){var o=this.nodeMetaMap.get(r);o&&this.nodeMetaMap.set(i,o)}this.idNodeMap.set(t,i)},e.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},n}();function I1(){return new Tm}function nl(n){var e=n.element,t=n.maskInputOptions,i=n.tagName,r=n.type,o=n.value,s=n.maskInputFn,a=o||"",c=r&&ji(r);return(t[i.toLowerCase()]||c&&t[c])&&(s?a=s(a,e):a="*".repeat(a.length)),a}function ji(n){return n.toLowerCase()}var xm="__rrweb_original__";function R1(n){var e=n.getContext("2d");if(!e)return!0;for(var t=50,i=0;i<n.width;i+=t)for(var r=0;r<n.height;r+=t){var o=e.getImageData,s=xm in o?o[xm]:o,a=new Uint32Array(s.call(e,i,r,Math.min(t,n.width-i),Math.min(t,n.height-r)).data.buffer);if(a.some(function(c){return c!==0}))return!1}return!0}function il(n){var e=n.type;return n.hasAttribute("data-rr-is-password")?"password":e?ji(e):null}function Em(n,e){var t;try{t=new URL(n,e??window.location.href)}catch{return null}var i=/\.([0-9a-z]+)(?:$)/i,r=t.pathname.match(i),o;return(o=r==null?void 0:r[1])!=null?o:null}function P1(n){var e="";return n.indexOf("//")>-1?e=n.split("/").slice(0,3).join("/"):e=n.split("/")[0],e=e.split("?")[0],e}var O1=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,A1=/^(?:[a-z+]+:)?\/\//i,M1=/^www\..*/i,N1=/^(data:)([^,]*),(.*)/i;function Fs(n,e){return(n||"").replace(O1,function(t,i,r,o,s,a){var c=r||s||a,u=i||o||"";if(!c)return t;if(A1.test(c)||M1.test(c)||N1.test(c))return"url("+u+c+u+")";if(c[0]==="/")return"url("+u+(P1(e)+c)+u+")";var l=e.split("/"),d=c.split("/");l.pop();for(var h=H(d),p;!(p=h()).done;){var m=p.value;m!=="."&&(m===".."?l.pop():l.push(m))}return"url("+u+l.join("/")+u+")"})}function rl(n){return n.replace(/(\/\*[^*]*\*\/)|[\s;]/g,"")}function D1(n,e){var t=Array.from(e.childNodes),i=[];if(t.length>1&&n&&typeof n=="string"){for(var r=rl(n),o=1;o<t.length;o++)if(t[o].textContent&&typeof t[o].textContent=="string")for(var s=rl(t[o].textContent),a=3;a<s.length;a++){var c=s.substring(0,a);if(r.split(c).length===2){for(var u=r.indexOf(c),l=u;l<n.length;l++)if(rl(n.substring(0,l)).length===u){i.push(n.substring(0,l)),n=n.substring(l);break}break}}}return i.push(n),i}function L1(n,e){return D1(n,e).join("/* rr_split */")}var U1=1,F1=new RegExp("[^a-z0-9-_:]"),To=-2;function Im(){return U1++}function B1(n){if(ne(n,HTMLFormElement))return"form";var e=ji(n.tagName);return F1.test(e)?"div":e}var _r,Rm,j1=/^[^ \t\n\r\u000c]+/,V1=/^[, \t\n\r\u000c]+/;function z1(n,e){if(e.trim()==="")return e;var t=0;function i(u){var l,d=u.exec(e.substring(t));return d?(l=d[0],t+=l.length,l):""}for(var r=[];i(V1),!(t>=e.length);){var o=i(j1);if(o.slice(-1)===",")o=Bs(n,o.substring(0,o.length-1)),r.push(o);else{var s="";o=Bs(n,o);for(var a=!1;;){var c=e.charAt(t);if(c===""){r.push((o+s).trim());break}else if(a)c===")"&&(a=!1);else if(c===","){t+=1,r.push((o+s).trim());break}else c==="("&&(a=!0);s+=c,t+=1}}}return r.join(", ")}var Pm=new WeakMap;function Bs(n,e){return!e||e.trim()===""?e:ol(n,e)}function q1(n){return!!(n.tagName==="svg"||n.ownerSVGElement)}function ol(n,e){var t=Pm.get(n);if(t||(t=n.createElement("a"),Pm.set(n,t)),!e)e="";else if(e.startsWith("blob:")||e.startsWith("data:"))return e;return t.setAttribute("href",e),t.href}function Om(n,e,t,i){return i&&(t==="src"||t==="href"&&!(e==="use"&&i[0]==="#")||t==="xlink:href"&&i[0]!=="#"||t==="background"&&(e==="table"||e==="td"||e==="th")?Bs(n,i):t==="srcset"?z1(n,i):t==="style"?Fs(i,ol(n)):e==="object"&&t==="data"?Bs(n,i):i)}function Am(n,e,t){return(n==="video"||n==="audio")&&e==="autoplay"}function W1(n,e,t){try{if(typeof e=="string"){if(n.classList.contains(e))return!0}else for(var i=n.classList.length;i--;){var r=n.classList[i];if(e.test(r))return!0}if(t)return n.matches(t)}catch{}return!1}function js(n,e,t){if(!n)return!1;if(n.nodeType!==n.ELEMENT_NODE)return t?js(Ct.parentNode(n),e,t):!1;for(var i=n.classList.length;i--;){var r=n.classList[i];if(e.test(r))return!0}return t?js(Ct.parentNode(n),e,t):!1}function Mm(n,e,t,i){var r;if(wm(n)){if(r=n,!Ct.childNodes(r).length)return!1}else{if(Ct.parentElement(n)===null)return!1;r=Ct.parentElement(n)}try{if(typeof e=="string"){if(i){if(r.closest("."+e))return!0}else if(r.classList.contains(e))return!0}else if(js(r,e,i))return!0;if(t){if(i){if(r.closest(t))return!0}else if(r.matches(t))return!0}}catch{}return!1}function G1(n,e,t){var i=n.contentWindow;if(i){var r=!1,o;try{o=i.document.readyState}catch{return}if(o!=="complete"){var s=setTimeout(function(){r||(e(),r=!0)},t);n.addEventListener("load",function(){clearTimeout(s),r=!0,e()});return}var a="about:blank";if(i.location.href!==a||n.src===a||n.src==="")return setTimeout(e,0),n.addEventListener("load",e);n.addEventListener("load",e)}}function $1(n,e,t){var i=!1,r;try{r=n.sheet}catch{return}if(!r){var o=setTimeout(function(){i||(e(),i=!0)},t);n.addEventListener("load",function(){clearTimeout(o),i=!0,e()})}}function H1(n,e){var t=e.doc,i=e.mirror,r=e.blockClass,o=e.blockSelector,s=e.needsMask,a=e.inlineStylesheet,c=e.maskInputOptions,u=c===void 0?{}:c,l=e.maskTextFn,d=e.maskInputFn,h=e.dataURLOptions,p=h===void 0?{}:h,m=e.inlineImages,f=e.recordCanvas,g=e.keepIframeSrcFn,y=e.newlyAddedElement,b=y===void 0?!1:y,S=e.cssCaptured,w=S===void 0?!1:S,k=K1(t,i);switch(n.nodeType){case n.DOCUMENT_NODE:return n.compatMode!=="CSS1Compat"?{type:ct.Document,childNodes:[],compatMode:n.compatMode}:{type:ct.Document,childNodes:[]};case n.DOCUMENT_TYPE_NODE:return{type:ct.DocumentType,name:n.name,publicId:n.publicId,systemId:n.systemId,rootId:k};case n.ELEMENT_NODE:return X1(n,{doc:t,blockClass:r,blockSelector:o,inlineStylesheet:a,maskInputOptions:u,maskInputFn:d,dataURLOptions:p,inlineImages:m,recordCanvas:f,keepIframeSrcFn:g,newlyAddedElement:b,rootId:k});case n.TEXT_NODE:return Y1(n,{doc:t,needsMask:s,maskTextFn:l,rootId:k,cssCaptured:w});case n.CDATA_SECTION_NODE:return{type:ct.CDATA,textContent:"",rootId:k};case n.COMMENT_NODE:return{type:ct.Comment,textContent:Ct.textContent(n)||"",rootId:k};default:return!1}}function K1(n,e){if(e.hasNode(n)){var t=e.getId(n);return t===1?void 0:t}}function Y1(n,e){var t=e.needsMask,i=e.maskTextFn,r=e.rootId,o=e.cssCaptured,s=Ct.parentNode(n),a=s&&s.tagName,c="",u=a==="STYLE"?!0:void 0,l=a==="SCRIPT"?!0:void 0;return l?c="SCRIPT_PLACEHOLDER":o||(c=Ct.textContent(n),u&&c&&(c=Fs(c,ol(e.doc)))),!u&&!l&&c&&t&&(c=i?i(c,Ct.parentElement(n)):c.replace(/[\S]/g,"*")),{type:ct.Text,textContent:c||"",rootId:r}}function X1(n,e){for(var t=e.doc,i=e.blockClass,r=e.blockSelector,o=e.inlineStylesheet,s=e.maskInputOptions,a=s===void 0?{}:s,c=e.maskInputFn,u=e.dataURLOptions,l=u===void 0?{}:u,d=e.inlineImages,h=e.recordCanvas,p=e.keepIframeSrcFn,m=e.newlyAddedElement,f=m===void 0?!1:m,g=e.rootId,y=W1(n,i,r),b=B1(n),S={},w=n.attributes.length,k=0;k<w;k++){var C=n.attributes[k];Am(b,C.name,C.value)||(S[C.name]=Om(t,b,ji(C.name),C.value))}if(b==="link"&&o){var x=Array.from(t.styleSheets).find(function(Me){return Me.href===n.href}),I=null;x&&(I=tl(x)),I&&(delete S.rel,delete S.href,S._cssText=I)}if(b==="style"&&n.sheet){var P=tl(n.sheet);P&&(n.childNodes.length>1&&(P=L1(P,n)),S._cssText=P)}if(b==="input"||b==="textarea"||b==="select"){var D=n.value,A=n.checked;S.type!=="radio"&&S.type!=="checkbox"&&S.type!=="submit"&&S.type!=="button"&&D?S.value=nl({element:n,type:il(n),tagName:b,value:D,maskInputOptions:a,maskInputFn:c}):A&&(S.checked=A)}if(b==="option"&&(n.selected&&!a.select?S.selected=!0:delete S.selected),b==="dialog"&&n.open&&(S.rr_open_mode=n.matches("dialog:modal")?"modal":"non-modal"),b==="canvas"&&h){if(n.__context==="2d")R1(n)||(S.rr_dataURL=n.toDataURL(l.type,l.quality));else if(!("__context"in n)){var L=n.toDataURL(l.type,l.quality),V=t.createElement("canvas");V.width=n.width,V.height=n.height;var Y=V.toDataURL(l.type,l.quality);L!==Y&&(S.rr_dataURL=L)}}if(b==="img"&&d){_r||(_r=t.createElement("canvas"),Rm=_r.getContext("2d"));var O=n,F=O.currentSrc||O.getAttribute("src")||"<unknown-src>",X=O.crossOrigin,K=function(){O.removeEventListener("load",K);try{_r.width=O.naturalWidth,_r.height=O.naturalHeight,Rm.drawImage(O,0,0),S.rr_dataURL=_r.toDataURL(l.type,l.quality)}catch(Me){if(O.crossOrigin!=="anonymous"){O.crossOrigin="anonymous",O.complete&&O.naturalWidth!==0?K():O.addEventListener("load",K);return}else console.warn("Cannot inline img src="+F+"! Error: "+Me)}O.crossOrigin==="anonymous"&&(X?S.crossOrigin=X:O.removeAttribute("crossorigin"))};O.complete&&O.naturalWidth!==0?K():O.addEventListener("load",K)}if(b==="audio"||b==="video"){var Q=S;Q.rr_mediaState=n.paused?"paused":"played",Q.rr_mediaCurrentTime=n.currentTime,Q.rr_mediaPlaybackRate=n.playbackRate,Q.rr_mediaMuted=n.muted,Q.rr_mediaLoop=n.loop,Q.rr_mediaVolume=n.volume}if(f||(n.scrollLeft&&(S.rr_scrollLeft=n.scrollLeft),n.scrollTop&&(S.rr_scrollTop=n.scrollTop)),y){var Ce=n.getBoundingClientRect(),Ge=Ce.width,Ie=Ce.height;S={class:S.class,rr_width:""+Ge+"px",rr_height:""+Ie+"px"}}b==="iframe"&&!p(S.src)&&(n.contentDocument||(S.rr_src=S.src),delete S.src);var dt;try{customElements.get(b)&&(dt=!0)}catch{}return{type:ct.Element,tagName:b,attributes:S,childNodes:[],isSVG:q1(n)||void 0,needBlock:y,rootId:g,isCustom:dt}}function Ne(n){return n==null?"":n.toLowerCase()}function J1(n,e){return!!(e.comment&&n.type===ct.Comment||n.type===ct.Element&&(e.script&&(n.tagName==="script"||n.tagName==="link"&&(n.attributes.rel==="preload"||n.attributes.rel==="modulepreload")&&n.attributes.as==="script"||n.tagName==="link"&&n.attributes.rel==="prefetch"&&typeof n.attributes.href=="string"&&Em(n.attributes.href)==="js")||e.headFavicon&&(n.tagName==="link"&&n.attributes.rel==="shortcut icon"||n.tagName==="meta"&&(Ne(n.attributes.name).match(/^msapplication-tile(image|color)$/)||Ne(n.attributes.name)==="application-name"||Ne(n.attributes.rel)==="icon"||Ne(n.attributes.rel)==="apple-touch-icon"||Ne(n.attributes.rel)==="shortcut icon"))||n.tagName==="meta"&&(e.headMetaDescKeywords&&Ne(n.attributes.name).match(/^description|keywords$/)||e.headMetaSocial&&(Ne(n.attributes.property).match(/^(og|twitter|fb):/)||Ne(n.attributes.name).match(/^(og|twitter):/)||Ne(n.attributes.name)==="pinterest")||e.headMetaRobots&&(Ne(n.attributes.name)==="robots"||Ne(n.attributes.name)==="googlebot"||Ne(n.attributes.name)==="bingbot")||e.headMetaHttpEquiv&&n.attributes["http-equiv"]!==void 0||e.headMetaAuthorship&&(Ne(n.attributes.name)==="author"||Ne(n.attributes.name)==="generator"||Ne(n.attributes.name)==="framework"||Ne(n.attributes.name)==="publisher"||Ne(n.attributes.name)==="progid"||Ne(n.attributes.property).match(/^article:/)||Ne(n.attributes.property).match(/^product:/))||e.headMetaVerification&&(Ne(n.attributes.name)==="google-site-verification"||Ne(n.attributes.name)==="yandex-verification"||Ne(n.attributes.name)==="csrf-token"||Ne(n.attributes.name)==="p:domain_verify"||Ne(n.attributes.name)==="verify-v1"||Ne(n.attributes.name)==="verification"||Ne(n.attributes.name)==="shopify-checkout-api-token"))))}function kr(n,e){var t=e.doc,i=e.mirror,r=e.blockClass,o=e.blockSelector,s=e.maskTextClass,a=e.maskTextSelector,c=e.skipChild,u=c===void 0?!1:c,l=e.inlineStylesheet,d=l===void 0?!0:l,h=e.maskInputOptions,p=h===void 0?{}:h,m=e.maskTextFn,f=e.maskInputFn,g=e.slimDOMOptions,y=e.dataURLOptions,b=y===void 0?{}:y,S=e.inlineImages,w=S===void 0?!1:S,k=e.recordCanvas,C=k===void 0?!1:k,x=e.onSerialize,I=e.onIframeLoad,P=e.iframeLoadTimeout,D=P===void 0?5e3:P,A=e.onStylesheetLoad,L=e.stylesheetLoadTimeout,V=L===void 0?5e3:L,Y=e.keepIframeSrcFn,O=Y===void 0?function(){return!1}:Y,F=e.newlyAddedElement,X=F===void 0?!1:F,K=e.cssCaptured,Q=K===void 0?!1:K,Ce=e.needsMask,Ge=e.preserveWhiteSpace,Ie=Ge===void 0?!0:Ge;if(!Ce){var dt=Ce===void 0;Ce=Mm(n,s,a,dt)}var Me=H1(n,{doc:t,mirror:i,blockClass:r,blockSelector:o,needsMask:Ce,inlineStylesheet:d,maskInputOptions:p,maskTextFn:m,maskInputFn:f,dataURLOptions:b,inlineImages:w,recordCanvas:C,keepIframeSrcFn:O,newlyAddedElement:X,cssCaptured:Q});if(!Me)return console.warn(n,"not serialized"),null;var Pe;i.hasNode(n)?Pe=i.getId(n):J1(Me,g)||!Ie&&Me.type===ct.Text&&!Me.textContent.replace(/^\s+|\s+$/gm,"").length?Pe=To:Pe=Im();var ie=Object.assign(Me,{id:Pe});if(i.add(n,ie),Pe===To)return null;x&&x(n);var Ze=!u;if(ie.type===ct.Element){Ze=Ze&&!ie.needBlock,delete ie.needBlock;var kt=Ct.shadowRoot(n);kt&&Co(kt)&&(ie.isShadowHost=!0)}if((ie.type===ct.Document||ie.type===ct.Element)&&Ze){g.headWhitespace&&ie.type===ct.Element&&ie.tagName==="head"&&(Ie=!1);var Gt={doc:t,mirror:i,blockClass:r,blockSelector:o,needsMask:Ce,maskTextClass:s,maskTextSelector:a,skipChild:u,inlineStylesheet:d,maskInputOptions:p,maskTextFn:m,maskInputFn:f,slimDOMOptions:g,dataURLOptions:b,inlineImages:w,recordCanvas:C,preserveWhiteSpace:Ie,onSerialize:x,onIframeLoad:I,iframeLoadTimeout:D,onStylesheetLoad:A,stylesheetLoadTimeout:V,keepIframeSrcFn:O,cssCaptured:!1};if(!(ie.type===ct.Element&&ie.tagName==="textarea"&&ie.attributes.value!==void 0)){ie.type===ct.Element&&ie.attributes._cssText!==void 0&&typeof ie.attributes._cssText=="string"&&(Gt.cssCaptured=!0);for(var ur=H(Array.from(Ct.childNodes(n))),ye;!(ye=ur()).done;){var Nt=ye.value,lr=kr(Nt,Gt);lr&&ie.childNodes.push(lr)}}var yn=null;if(wm(n)&&(yn=Ct.shadowRoot(n)))for(var Dn=H(Array.from(Ct.childNodes(yn))),Zn;!(Zn=Dn()).done;){var Li=Zn.value,mo=kr(Li,Gt);mo&&(Co(yn)&&(mo.isShadow=!0),ie.childNodes.push(mo))}}var dr=Ct.parentNode(n);return dr&&wo(dr)&&Co(dr)&&(ie.isShadow=!0),ie.type===ct.Element&&ie.tagName==="iframe"&&G1(n,function(){var Qn=n.contentDocument;if(Qn&&I){var hr=kr(Qn,{doc:Qn,mirror:i,blockClass:r,blockSelector:o,needsMask:Ce,maskTextClass:s,maskTextSelector:a,skipChild:!1,inlineStylesheet:d,maskInputOptions:p,maskTextFn:m,maskInputFn:f,slimDOMOptions:g,dataURLOptions:b,inlineImages:w,recordCanvas:C,preserveWhiteSpace:Ie,onSerialize:x,onIframeLoad:I,iframeLoadTimeout:D,onStylesheetLoad:A,stylesheetLoadTimeout:V,keepIframeSrcFn:O});hr&&I(n,hr)}},D),ie.type===ct.Element&&ie.tagName==="link"&&typeof ie.attributes.rel=="string"&&(ie.attributes.rel==="stylesheet"||ie.attributes.rel==="preload"&&typeof ie.attributes.href=="string"&&Em(ie.attributes.href)==="css")&&$1(n,function(){if(A){var Qn=kr(n,{doc:t,mirror:i,blockClass:r,blockSelector:o,needsMask:Ce,maskTextClass:s,maskTextSelector:a,skipChild:!1,inlineStylesheet:d,maskInputOptions:p,maskTextFn:m,maskInputFn:f,slimDOMOptions:g,dataURLOptions:b,inlineImages:w,recordCanvas:C,preserveWhiteSpace:Ie,onSerialize:x,onIframeLoad:I,iframeLoadTimeout:D,onStylesheetLoad:A,stylesheetLoadTimeout:V,keepIframeSrcFn:O});Qn&&A(n,Qn)}},V),ie}function Z1(n,e){var t=e||{},i=t.mirror,r=i===void 0?new Tm:i,o=t.blockClass,s=o===void 0?"rr-block":o,a=t.blockSelector,c=a===void 0?null:a,u=t.maskTextClass,l=u===void 0?"rr-mask":u,d=t.maskTextSelector,h=d===void 0?null:d,p=t.inlineStylesheet,m=p===void 0?!0:p,f=t.inlineImages,g=f===void 0?!1:f,y=t.recordCanvas,b=y===void 0?!1:y,S=t.maskAllInputs,w=S===void 0?!1:S,k=t.maskTextFn,C=t.maskInputFn,x=t.slimDOM,I=x===void 0?!1:x,P=t.dataURLOptions,D=t.preserveWhiteSpace,A=t.onSerialize,L=t.onIframeLoad,V=t.iframeLoadTimeout,Y=t.onStylesheetLoad,O=t.stylesheetLoadTimeout,F=t.keepIframeSrcFn,X=F===void 0?function(){return!1}:F,K=w===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:w===!1?{password:!0}:w,Q=I===!0||I==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:I==="all",headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:I===!1?{}:I;return kr(n,{doc:n,mirror:r,blockClass:s,blockSelector:c,maskTextClass:l,maskTextSelector:h,skipChild:!1,inlineStylesheet:m,maskInputOptions:K,maskTextFn:k,maskInputFn:C,slimDOMOptions:Q,dataURLOptions:P,inlineImages:g,recordCanvas:b,preserveWhiteSpace:D,onSerialize:A,onIframeLoad:L,iframeLoadTimeout:V,onStylesheetLoad:Y,stylesheetLoadTimeout:O,keepIframeSrcFn:X,newlyAddedElement:!1})}function Q1(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function eT(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var t=function i(){return ne(this,i)?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(i){var r=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:function(){return n[i]}})}),t}var sl={exports:{}},De=String,Nm=function(){return{isColorSupported:!1,reset:De,bold:De,dim:De,italic:De,underline:De,inverse:De,hidden:De,strikethrough:De,black:De,red:De,green:De,yellow:De,blue:De,magenta:De,cyan:De,white:De,gray:De,bgBlack:De,bgRed:De,bgGreen:De,bgYellow:De,bgBlue:De,bgMagenta:De,bgCyan:De,bgWhite:De}};sl.exports=Nm(),sl.exports.createColors=Nm;var tT=sl.exports,nT={},iT=Object.freeze(Object.defineProperty({__proto__:null,default:nT},Symbol.toStringTag,{value:"Module"})),et=eT(iT),Dm=tT,Lm=et,al=function(n){wt(e,n);function e(i,r,o,s,a,c){var u;return u=n.call(this,i)||this,u.name="CssSyntaxError",u.reason=i,a&&(u.file=a),s&&(u.source=s),c&&(u.plugin=c),typeof r<"u"&&typeof o<"u"&&(typeof r=="number"?(u.line=r,u.column=o):(u.line=r.line,u.column=r.column,u.endLine=o.line,u.endColumn=o.column)),u.setMessage(),Error.captureStackTrace&&Error.captureStackTrace(u,e),u}var t=e.prototype;return t.setMessage=function(){this.message=this.plugin?this.plugin+": ":"",this.message+=this.file?this.file:"<css input>",typeof this.line<"u"&&(this.message+=":"+this.line+":"+this.column),this.message+=": "+this.reason},t.showSourceCode=function(i){var r=this;if(!this.source)return"";var o=this.source;i==null&&(i=Dm.isColorSupported),Lm&&i&&(o=Lm(o));var s=o.split(/\r?\n/),a=Math.max(this.line-3,0),c=Math.min(this.line+2,s.length),u=String(c).length,l,d;if(i){var h=Dm.createColors(!0),p=h.bold,m=h.gray,f=h.red;l=function(g){return p(f(g))},d=function(g){return m(g)}}else l=d=function(g){return g};return s.slice(a,c).map(function(g,y){var b=a+1+y,S=" "+(" "+b).slice(-u)+" | ";if(b===r.line){var w=d(S.replace(/\d/g," "))+g.slice(0,r.column-1).replace(/[^\t]/g," ");return l(">")+d(S)+g+`
14
- `+w+l("^")}return" "+d(S)+g}).join(`
15
- `)},t.toString=function(){var i=this.showSourceCode();return i&&(i=`
16
-
17
- `+i+`
18
- `),this.name+": "+this.message+i},e}(Ls(Error)),cl=al;al.default=al;var ni={};ni.isClean=Symbol("isClean"),ni.my=Symbol("my");var Um={after:`
19
- `,beforeClose:`
20
- `,beforeComment:`
21
- `,beforeDecl:`
22
- `,beforeOpen:" ",beforeRule:`
23
- `,colon:": ",commentLeft:" ",commentRight:" ",emptyBody:"",indent:" ",semicolon:!1};function rT(n){return n[0].toUpperCase()+n.slice(1)}var ul=function(){function n(t){this.builder=t}var e=n.prototype;return e.atrule=function(t,i){var r="@"+t.name,o=t.params?this.rawValue(t,"params"):"";if(typeof t.raws.afterName<"u"?r+=t.raws.afterName:o&&(r+=" "),t.nodes)this.block(t,r+o);else{var s=(t.raws.between||"")+(i?";":"");this.builder(r+o+s,t)}},e.beforeAfter=function(t,i){var r;t.type==="decl"?r=this.raw(t,null,"beforeDecl"):t.type==="comment"?r=this.raw(t,null,"beforeComment"):i==="before"?r=this.raw(t,null,"beforeRule"):r=this.raw(t,null,"beforeClose");for(var o=t.parent,s=0;o&&o.type!=="root";)s+=1,o=o.parent;if(r.includes(`
24
- `)){var a=this.raw(t,null,"indent");if(a.length)for(var c=0;c<s;c++)r+=a}return r},e.block=function(t,i){var r=this.raw(t,"between","beforeOpen");this.builder(i+r+"{",t,"start");var o;t.nodes&&t.nodes.length?(this.body(t),o=this.raw(t,"after")):o=this.raw(t,"after","emptyBody"),o&&this.builder(o),this.builder("}",t,"end")},e.body=function(t){for(var i=t.nodes.length-1;i>0&&t.nodes[i].type==="comment";)i-=1;for(var r=this.raw(t,"semicolon"),o=0;o<t.nodes.length;o++){var s=t.nodes[o],a=this.raw(s,"before");a&&this.builder(a),this.stringify(s,i!==o||r)}},e.comment=function(t){var i=this.raw(t,"left","commentLeft"),r=this.raw(t,"right","commentRight");this.builder("/*"+i+t.text+r+"*/",t)},e.decl=function(t,i){var r=this.raw(t,"between","colon"),o=t.prop+r+this.rawValue(t,"value");t.important&&(o+=t.raws.important||" !important"),i&&(o+=";"),this.builder(o,t)},e.document=function(t){this.body(t)},e.raw=function(t,i,r){var o;if(r||(r=i),i&&(o=t.raws[i],typeof o<"u"))return o;var s=t.parent;if(r==="before"&&(!s||s.type==="root"&&s.first===t||s&&s.type==="document"))return"";if(!s)return Um[r];var a=t.root();if(a.rawCache||(a.rawCache={}),typeof a.rawCache[r]<"u")return a.rawCache[r];if(r==="before"||r==="after")return this.beforeAfter(t,r);var c="raw"+rT(r);return this[c]?o=this[c](a,t):a.walk(function(u){if(o=u.raws[i],typeof o<"u")return!1}),typeof o>"u"&&(o=Um[r]),a.rawCache[r]=o,o},e.rawBeforeClose=function(t){var i;return t.walk(function(r){if(r.nodes&&r.nodes.length>0&&typeof r.raws.after<"u")return i=r.raws.after,i.includes(`
25
- `)&&(i=i.replace(/[^\n]+$/,"")),!1}),i&&(i=i.replace(/\S/g,"")),i},e.rawBeforeComment=function(t,i){var r;return t.walkComments(function(o){if(typeof o.raws.before<"u")return r=o.raws.before,r.includes(`
26
- `)&&(r=r.replace(/[^\n]+$/,"")),!1}),typeof r>"u"?r=this.raw(i,null,"beforeDecl"):r&&(r=r.replace(/\S/g,"")),r},e.rawBeforeDecl=function(t,i){var r;return t.walkDecls(function(o){if(typeof o.raws.before<"u")return r=o.raws.before,r.includes(`
27
- `)&&(r=r.replace(/[^\n]+$/,"")),!1}),typeof r>"u"?r=this.raw(i,null,"beforeRule"):r&&(r=r.replace(/\S/g,"")),r},e.rawBeforeOpen=function(t){var i;return t.walk(function(r){if(r.type!=="decl"&&(i=r.raws.between,typeof i<"u"))return!1}),i},e.rawBeforeRule=function(t){var i;return t.walk(function(r){if(r.nodes&&(r.parent!==t||t.first!==r)&&typeof r.raws.before<"u")return i=r.raws.before,i.includes(`
28
- `)&&(i=i.replace(/[^\n]+$/,"")),!1}),i&&(i=i.replace(/\S/g,"")),i},e.rawColon=function(t){var i;return t.walkDecls(function(r){if(typeof r.raws.between<"u")return i=r.raws.between.replace(/[^\s:]/g,""),!1}),i},e.rawEmptyBody=function(t){var i;return t.walk(function(r){if(r.nodes&&r.nodes.length===0&&(i=r.raws.after,typeof i<"u"))return!1}),i},e.rawIndent=function(t){if(t.raws.indent)return t.raws.indent;var i;return t.walk(function(r){var o=r.parent;if(o&&o!==t&&o.parent&&o.parent===t&&typeof r.raws.before<"u"){var s=r.raws.before.split(`
29
- `);return i=s[s.length-1],i=i.replace(/\S/g,""),!1}}),i},e.rawSemicolon=function(t){var i;return t.walk(function(r){if(r.nodes&&r.nodes.length&&r.last.type==="decl"&&(i=r.raws.semicolon,typeof i<"u"))return!1}),i},e.rawValue=function(t,i){var r=t[i],o=t.raws[i];return o&&o.value===r?o.raw:r},e.root=function(t){this.body(t),t.raws.after&&this.builder(t.raws.after)},e.rule=function(t){this.block(t,this.rawValue(t,"selector")),t.raws.ownSemicolon&&this.builder(t.raws.ownSemicolon,t,"end")},e.stringify=function(t,i){if(!this[t.type])throw new Error("Unknown AST node type "+t.type+". Maybe you need to change PostCSS stringifier.");this[t.type](t,i)},n}(),Fm=ul;ul.default=ul;var oT=Fm;function ll(n,e){var t=new oT(e);t.stringify(n)}var Vs=ll;ll.default=ll;var zs=ni.isClean,sT=ni.my,aT=cl,cT=Fm,uT=Vs;function dl(n,e){var t=new n.constructor;for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)&&i!=="proxyCache"){var r=n[i],o=typeof r>"u"?"undefined":oe(r);i==="parent"&&o==="object"?e&&(t[i]=e):i==="source"?t[i]=r:Array.isArray(r)?t[i]=r.map(function(s){return dl(s,t)}):(o==="object"&&r!==null&&(r=dl(r)),t[i]=r)}return t}var hl=function(){function n(t){t===void 0&&(t={}),this.raws={},this[zs]=!1,this[sT]=!0;for(var i in t)if(i==="nodes"){this.nodes=[];for(var r=H(t[i]),o;!(o=r()).done;){var s=o.value;typeof s.clone=="function"?this.append(s.clone()):this.append(s)}}else this[i]=t[i]}var e=n.prototype;return e.addToError=function(t){if(t.postcssNode=this,t.stack&&this.source&&/\n\s{4}at /.test(t.stack)){var i=this.source;t.stack=t.stack.replace(/\n\s{4}at /,"$&"+i.input.from+":"+i.start.line+":"+i.start.column+"$&")}return t},e.after=function(t){return this.parent.insertAfter(this,t),this},e.assign=function(t){t===void 0&&(t={});for(var i in t)this[i]=t[i];return this},e.before=function(t){return this.parent.insertBefore(this,t),this},e.cleanRaws=function(t){delete this.raws.before,delete this.raws.after,t||delete this.raws.between},e.clone=function(t){t===void 0&&(t={});var i=dl(this);for(var r in t)i[r]=t[r];return i},e.cloneAfter=function(t){t===void 0&&(t={});var i=this.clone(t);return this.parent.insertAfter(this,i),i},e.cloneBefore=function(t){t===void 0&&(t={});var i=this.clone(t);return this.parent.insertBefore(this,i),i},e.error=function(t,i){if(i===void 0&&(i={}),this.source){var r=this.rangeBy(i),o=r.end,s=r.start;return this.source.input.error(t,{column:s.column,line:s.line},{column:o.column,line:o.line},i)}return new aT(t)},e.getProxyProcessor=function(){return{get:function(t,i){return i==="proxyOf"?t:i==="root"?function(){return t.root().toProxy()}:t[i]},set:function(t,i,r){return t[i]===r||(t[i]=r,(i==="prop"||i==="value"||i==="name"||i==="params"||i==="important"||i==="text")&&t.markDirty()),!0}}},e.markDirty=function(){if(this[zs]){this[zs]=!1;for(var t=this;t=t.parent;)t[zs]=!1}},e.next=function(){if(this.parent){var t=this.parent.index(this);return this.parent.nodes[t+1]}},e.positionBy=function(t,i){var r=this.source.start;if(t.index)r=this.positionInside(t.index,i);else if(t.word){i=this.toString();var o=i.indexOf(t.word);o!==-1&&(r=this.positionInside(o,i))}return r},e.positionInside=function(t,i){for(var r=i||this.toString(),o=this.source.start.column,s=this.source.start.line,a=0;a<t;a++)r[a]===`
30
- `?(o=1,s+=1):o+=1;return{column:o,line:s}},e.prev=function(){if(this.parent){var t=this.parent.index(this);return this.parent.nodes[t-1]}},e.rangeBy=function(t){var i={column:this.source.start.column,line:this.source.start.line},r=this.source.end?{column:this.source.end.column+1,line:this.source.end.line}:{column:i.column+1,line:i.line};if(t.word){var o=this.toString(),s=o.indexOf(t.word);s!==-1&&(i=this.positionInside(s,o),r=this.positionInside(s+t.word.length,o))}else t.start?i={column:t.start.column,line:t.start.line}:t.index&&(i=this.positionInside(t.index)),t.end?r={column:t.end.column,line:t.end.line}:typeof t.endIndex=="number"?r=this.positionInside(t.endIndex):t.index&&(r=this.positionInside(t.index+1));return(r.line<i.line||r.line===i.line&&r.column<=i.column)&&(r={column:i.column+1,line:i.line}),{end:r,start:i}},e.raw=function(t,i){var r=new cT;return r.raw(this,t,i)},e.remove=function(){return this.parent&&this.parent.removeChild(this),this.parent=void 0,this},e.replaceWith=function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];if(this.parent){for(var o=this,s=!1,a=H(i),c;!(c=a()).done;){var u=c.value;u===this?s=!0:s?(this.parent.insertAfter(o,u),o=u):this.parent.insertBefore(o,u)}s||this.remove()}return this},e.root=function(){for(var t=this;t.parent&&t.parent.type!=="document";)t=t.parent;return t},e.toJSON=function(t,i){var r={},o=i==null;i=i||new Map;var s=0;for(var a in this)if(Object.prototype.hasOwnProperty.call(this,a)&&!(a==="parent"||a==="proxyCache")){var c=this[a];if(Array.isArray(c))r[a]=c.map(function(l){return(typeof l>"u"?"undefined":oe(l))==="object"&&l.toJSON?l.toJSON(null,i):l});else if((typeof c>"u"?"undefined":oe(c))==="object"&&c.toJSON)r[a]=c.toJSON(null,i);else if(a==="source"){var u=i.get(c.input);u==null&&(u=s,i.set(c.input,s),s++),r[a]={end:c.end,inputId:u,start:c.start}}else r[a]=c}return o&&(r.inputs=[].concat(i.keys()).map(function(l){return l.toJSON()})),r},e.toProxy=function(){return this.proxyCache||(this.proxyCache=new Proxy(this,this.getProxyProcessor())),this.proxyCache},e.toString=function(t){t===void 0&&(t=uT),t.stringify&&(t=t.stringify);var i="";return t(this,function(r){i+=r}),i},e.warn=function(t,i,r){var o={node:this};for(var s in r)o[s]=r[s];return t.warn(i,o)},mt(n,[{key:"proxyOf",get:function(){return this}}]),n}(),qs=hl;hl.default=hl;var lT=qs,pl=function(n){wt(e,n);function e(t){var i;return t&&typeof t.value<"u"&&typeof t.value!="string"&&(t=me({},t,{value:String(t.value)})),i=n.call(this,t)||this,i.type="decl",i}return mt(e,[{key:"variable",get:function(){return this.prop.startsWith("--")||this.prop[0]==="$"}}]),e}(lT),Ws=pl;pl.default=pl;var dT="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",hT=function(n){n===void 0&&(n=21);for(var e="",t=n;t--;)e+=dT[Math.random()*64|0];return e},pT={nanoid:hT},Bm=et.SourceMapConsumer,jm=et.SourceMapGenerator,fT=et.existsSync,mT=et.readFileSync,fl=et.dirname,gT=et.join;function vT(n){return Buffer?Buffer.from(n,"base64").toString():window.atob(n)}var ml=function(){function n(t,i){if(i.map!==!1){this.loadAnnotation(t),this.inline=this.startWith(this.annotation,"data:");var r=i.map?i.map.prev:void 0,o=this.loadMap(i.from,r);!this.mapFile&&i.from&&(this.mapFile=i.from),this.mapFile&&(this.root=fl(this.mapFile)),o&&(this.text=o)}}var e=n.prototype;return e.consumer=function(){return this.consumerCache||(this.consumerCache=new Bm(this.text)),this.consumerCache},e.decodeInline=function(t){var i=/^data:application\/json;charset=utf-?8;base64,/,r=/^data:application\/json;base64,/,o=/^data:application\/json;charset=utf-?8,/,s=/^data:application\/json,/;if(o.test(t)||s.test(t))return decodeURIComponent(t.substr(RegExp.lastMatch.length));if(i.test(t)||r.test(t))return vT(t.substr(RegExp.lastMatch.length));var a=t.match(/data:application\/json;([^,]+),/)[1];throw new Error("Unsupported source map encoding "+a)},e.getAnnotationURL=function(t){return t.replace(/^\/\*\s*# sourceMappingURL=/,"").trim()},e.isMap=function(t){return(typeof t>"u"?"undefined":oe(t))!=="object"?!1:typeof t.mappings=="string"||typeof t._mappings=="string"||Array.isArray(t.sections)},e.loadAnnotation=function(t){var i=t.match(/\/\*\s*# sourceMappingURL=/gm);if(i){var r=t.lastIndexOf(i.pop()),o=t.indexOf("*/",r);r>-1&&o>-1&&(this.annotation=this.getAnnotationURL(t.substring(r,o)))}},e.loadFile=function(t){if(this.root=fl(t),fT(t))return this.mapFile=t,mT(t,"utf-8").toString().trim()},e.loadMap=function(t,i){if(i===!1)return!1;if(i){if(typeof i=="string")return i;if(typeof i=="function"){var r=i(t);if(r){var o=this.loadFile(r);if(!o)throw new Error("Unable to load previous source map: "+r.toString());return o}}else{if(ne(i,Bm))return jm.fromSourceMap(i).toString();if(ne(i,jm))return i.toString();if(this.isMap(i))return JSON.stringify(i);throw new Error("Unsupported previous source map format: "+i.toString())}}else{if(this.inline)return this.decodeInline(this.annotation);if(this.annotation){var s=this.annotation;return t&&(s=gT(fl(t),s)),this.loadFile(s)}}},e.startWith=function(t,i){return t?t.substr(0,i.length)===i:!1},e.withContent=function(){return!!(this.consumer().sourcesContent&&this.consumer().sourcesContent.length>0)},n}(),Vm=ml;ml.default=ml;var yT=et.SourceMapConsumer,bT=et.SourceMapGenerator,zm=et.fileURLToPath,Gs=et.pathToFileURL,gl=et.isAbsolute,vl=et.resolve,_T=pT.nanoid,yl=et,qm=cl,kT=Vm,bl=Symbol("fromOffsetCache"),ST=!!(yT&&bT),Wm=!!(vl&&gl),$s=function(){function n(t,i){if(i===void 0&&(i={}),t===null||typeof t>"u"||(typeof t>"u"?"undefined":oe(t))==="object"&&!t.toString)throw new Error("PostCSS received "+t+" instead of CSS string");if(this.css=t.toString(),this.css[0]==="\uFEFF"||this.css[0]==="\uFFFE"?(this.hasBOM=!0,this.css=this.css.slice(1)):this.hasBOM=!1,i.from&&(!Wm||/^\w+:\/\//.test(i.from)||gl(i.from)?this.file=i.from:this.file=vl(i.from)),Wm&&ST){var r=new kT(this.css,i);if(r.text){this.map=r;var o=r.consumer().file;!this.file&&o&&(this.file=this.mapResolve(o))}}this.file||(this.id="<input css "+_T(6)+">"),this.map&&(this.map.file=this.from)}var e=n.prototype;return e.error=function(t,i,r,o){o===void 0&&(o={});var s,a,c;if(i&&(typeof i>"u"?"undefined":oe(i))==="object"){var u=i,l=r;if(typeof u.offset=="number"){var d=this.fromOffset(u.offset);i=d.line,r=d.col}else i=u.line,r=u.column;if(typeof l.offset=="number"){var h=this.fromOffset(l.offset);a=h.line,c=h.col}else a=l.line,c=l.column}else if(!r){var p=this.fromOffset(i);i=p.line,r=p.col}var m=this.origin(i,r,a,c);return m?s=new qm(t,m.endLine===void 0?m.line:{column:m.column,line:m.line},m.endLine===void 0?m.column:{column:m.endColumn,line:m.endLine},m.source,m.file,o.plugin):s=new qm(t,a===void 0?i:{column:r,line:i},a===void 0?r:{column:c,line:a},this.css,this.file,o.plugin),s.input={column:r,endColumn:c,endLine:a,line:i,source:this.css},this.file&&(Gs&&(s.input.url=Gs(this.file).toString()),s.input.file=this.file),s},e.fromOffset=function(t){var i,r;if(this[bl])r=this[bl];else{var o=this.css.split(`
31
- `);r=new Array(o.length);for(var s=0,a=0,c=o.length;a<c;a++)r[a]=s,s+=o[a].length+1;this[bl]=r}i=r[r.length-1];var u=0;if(t>=i)u=r.length-1;else for(var l=r.length-2,d;u<l;)if(d=u+(l-u>>1),t<r[d])l=d-1;else if(t>=r[d+1])u=d+1;else{u=d;break}return{col:t-r[u]+1,line:u+1}},e.mapResolve=function(t){return/^\w+:\/\//.test(t)?t:vl(this.map.consumer().sourceRoot||this.map.root||".",t)},e.origin=function(t,i,r,o){if(!this.map)return!1;var s=this.map.consumer(),a=s.originalPositionFor({column:i,line:t});if(!a.source)return!1;var c;typeof r=="number"&&(c=s.originalPositionFor({column:o,line:r}));var u;gl(a.source)?u=Gs(a.source):u=new URL(a.source,this.map.consumer().sourceRoot||Gs(this.map.mapFile));var l={column:a.column,endColumn:c&&c.column,endLine:c&&c.line,line:a.line,url:u.toString()};if(u.protocol==="file:")if(zm)l.file=zm(u);else throw new Error("file: protocol is not available in this PostCSS build");var d=s.sourceContentFor(a.source);return d&&(l.source=d),l},e.toJSON=function(){for(var t={},i=0,r=["hasBOM","css","file","id"];i<r.length;i++){var o=r[i];this[o]!=null&&(t[o]=this[o])}return this.map&&(t.map=me({},this.map),t.map.consumerCache&&(t.map.consumerCache=void 0)),t},mt(n,[{key:"from",get:function(){return this.file||this.id}}]),n}(),Hs=$s;$s.default=$s,yl&&yl.registerInput&&yl.registerInput($s);var Gm=et.SourceMapConsumer,Ks=et.SourceMapGenerator,Ys=et.dirname,$m=et.relative,Hm=et.resolve,Km=et.sep,Ym=et.pathToFileURL,wT=Hs,CT=!!(Gm&&Ks),TT=!!(Ys&&Hm&&$m&&Km),xT=function(){function n(t,i,r,o){this.stringify=t,this.mapOpts=r.map||{},this.root=i,this.opts=r,this.css=o,this.originalCSS=o,this.usesFileUrls=!this.mapOpts.from&&this.mapOpts.absolute,this.memoizedFileURLs=new Map,this.memoizedPaths=new Map,this.memoizedURLs=new Map}var e=n.prototype;return e.addAnnotation=function(){var t;this.isInline()?t="data:application/json;base64,"+this.toBase64(this.map.toString()):typeof this.mapOpts.annotation=="string"?t=this.mapOpts.annotation:typeof this.mapOpts.annotation=="function"?t=this.mapOpts.annotation(this.opts.to,this.root):t=this.outputFile()+".map";var i=`
32
- `;this.css.includes(`\r
33
- `)&&(i=`\r
34
- `),this.css+=i+"/*# sourceMappingURL="+t+" */"},e.applyPrevMaps=function(){for(var t=H(this.previous()),i;!(i=t()).done;){var r=i.value,o=this.toUrl(this.path(r.file)),s=r.root||Ys(r.file),a=void 0;this.mapOpts.sourcesContent===!1?(a=new Gm(r.text),a.sourcesContent&&(a.sourcesContent=null)):a=r.consumer(),this.map.applySourceMap(a,o,this.toUrl(this.path(s)))}},e.clearAnnotation=function(){if(this.mapOpts.annotation!==!1)if(this.root)for(var t,i=this.root.nodes.length-1;i>=0;i--)t=this.root.nodes[i],t.type==="comment"&&t.text.indexOf("# sourceMappingURL=")===0&&this.root.removeChild(i);else this.css&&(this.css=this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm,""))},e.generate=function(){if(this.clearAnnotation(),TT&&CT&&this.isMap())return this.generateMap();var t="";return this.stringify(this.root,function(i){t+=i}),[t]},e.generateMap=function(){if(this.root)this.generateString();else if(this.previous().length===1){var t=this.previous()[0].consumer();t.file=this.outputFile(),this.map=Ks.fromSourceMap(t,{ignoreInvalidMapping:!0})}else this.map=new Ks({file:this.outputFile(),ignoreInvalidMapping:!0}),this.map.addMapping({generated:{column:0,line:1},original:{column:0,line:1},source:this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>"});return this.isSourcesContent()&&this.setSourcesContent(),this.root&&this.previous().length>0&&this.applyPrevMaps(),this.isAnnotation()&&this.addAnnotation(),this.isInline()?[this.css]:[this.css,this.map]},e.generateString=function(){var t=this;this.css="",this.map=new Ks({file:this.outputFile(),ignoreInvalidMapping:!0});var i=1,r=1,o="<no source>",s={generated:{column:0,line:0},original:{column:0,line:0},source:""},a,c;this.stringify(this.root,function(u,l,d){if(t.css+=u,l&&d!=="end"&&(s.generated.line=i,s.generated.column=r-1,l.source&&l.source.start?(s.source=t.sourcePath(l),s.original.line=l.source.start.line,s.original.column=l.source.start.column-1,t.map.addMapping(s)):(s.source=o,s.original.line=1,s.original.column=0,t.map.addMapping(s))),a=u.match(/\n/g),a?(i+=a.length,c=u.lastIndexOf(`
35
- `),r=u.length-c):r+=u.length,l&&d!=="start"){var h=l.parent||{raws:{}},p=l.type==="decl"||l.type==="atrule"&&!l.nodes;(!p||l!==h.last||h.raws.semicolon)&&(l.source&&l.source.end?(s.source=t.sourcePath(l),s.original.line=l.source.end.line,s.original.column=l.source.end.column-1,s.generated.line=i,s.generated.column=r-2,t.map.addMapping(s)):(s.source=o,s.original.line=1,s.original.column=0,s.generated.line=i,s.generated.column=r-1,t.map.addMapping(s)))}})},e.isAnnotation=function(){return this.isInline()?!0:typeof this.mapOpts.annotation<"u"?this.mapOpts.annotation:this.previous().length?this.previous().some(function(t){return t.annotation}):!0},e.isInline=function(){if(typeof this.mapOpts.inline<"u")return this.mapOpts.inline;var t=this.mapOpts.annotation;return typeof t<"u"&&t!==!0?!1:this.previous().length?this.previous().some(function(i){return i.inline}):!0},e.isMap=function(){return typeof this.opts.map<"u"?!!this.opts.map:this.previous().length>0},e.isSourcesContent=function(){return typeof this.mapOpts.sourcesContent<"u"?this.mapOpts.sourcesContent:this.previous().length?this.previous().some(function(t){return t.withContent()}):!0},e.outputFile=function(){return this.opts.to?this.path(this.opts.to):this.opts.from?this.path(this.opts.from):"to.css"},e.path=function(t){if(this.mapOpts.absolute||t.charCodeAt(0)===60||/^\w+:\/\//.test(t))return t;var i=this.memoizedPaths.get(t);if(i)return i;var r=this.opts.to?Ys(this.opts.to):".";typeof this.mapOpts.annotation=="string"&&(r=Ys(Hm(r,this.mapOpts.annotation)));var o=$m(r,t);return this.memoizedPaths.set(t,o),o},e.previous=function(){var t=this;if(!this.previousMaps)if(this.previousMaps=[],this.root)this.root.walk(function(r){if(r.source&&r.source.input.map){var o=r.source.input.map;t.previousMaps.includes(o)||t.previousMaps.push(o)}});else{var i=new wT(this.originalCSS,this.opts);i.map&&this.previousMaps.push(i.map)}return this.previousMaps},e.setSourcesContent=function(){var t=this,i={};if(this.root)this.root.walk(function(o){if(o.source){var s=o.source.input.from;if(s&&!i[s]){i[s]=!0;var a=t.usesFileUrls?t.toFileUrl(s):t.toUrl(t.path(s));t.map.setSourceContent(a,o.source.input.css)}}});else if(this.css){var r=this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>";this.map.setSourceContent(r,this.css)}},e.sourcePath=function(t){return this.mapOpts.from?this.toUrl(this.mapOpts.from):this.usesFileUrls?this.toFileUrl(t.source.input.from):this.toUrl(this.path(t.source.input.from))},e.toBase64=function(t){return Buffer?Buffer.from(t).toString("base64"):window.btoa(unescape(encodeURIComponent(t)))},e.toFileUrl=function(t){var i=this.memoizedFileURLs.get(t);if(i)return i;if(Ym){var r=Ym(t).toString();return this.memoizedFileURLs.set(t,r),r}else throw new Error("`map.absolute` option is not available in this PostCSS build")},e.toUrl=function(t){var i=this.memoizedURLs.get(t);if(i)return i;Km==="\\"&&(t=t.replace(/\\/g,"/"));var r=encodeURI(t).replace(/[#?]/g,encodeURIComponent);return this.memoizedURLs.set(t,r),r},n}(),Xm=xT,ET=qs,_l=function(n){wt(e,n);function e(t){var i;return i=n.call(this,t)||this,i.type="comment",i}return e}(ET),Xs=_l;_l.default=_l;var Jm=ni.isClean,Zm=ni.my,Qm=Ws,eg=Xs,IT=qs,tg,kl,Sl,ng;function ig(n){return n.map(function(e){return e.nodes&&(e.nodes=ig(e.nodes)),delete e.source,e})}function rg(n){if(n[Jm]=!1,n.proxyOf.nodes)for(var e=H(n.proxyOf.nodes),t;!(t=e()).done;){var i=t.value;rg(i)}}var Fn=function(n){wt(e,n);function e(){return n.apply(this,arguments)||this}var t=e.prototype;return t.append=function(){for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];for(var s=H(r),a;!(a=s()).done;)for(var c=a.value,u=this.normalize(c,this.last),l=H(u),d;!(d=l()).done;){var h=d.value;this.proxyOf.nodes.push(h)}return this.markDirty(),this},t.cleanRaws=function(i){if(n.prototype.cleanRaws.call(this,i),this.nodes)for(var r=H(this.nodes),o;!(o=r()).done;){var s=o.value;s.cleanRaws(i)}},t.each=function(i){if(this.proxyOf.nodes){for(var r=this.getIterator(),o,s;this.indexes[r]<this.proxyOf.nodes.length&&(o=this.indexes[r],s=i(this.proxyOf.nodes[o],o),s!==!1);)this.indexes[r]+=1;return delete this.indexes[r],s}},t.every=function(i){return this.nodes.every(i)},t.getIterator=function(){this.lastEach||(this.lastEach=0),this.indexes||(this.indexes={}),this.lastEach+=1;var i=this.lastEach;return this.indexes[i]=0,i},t.getProxyProcessor=function(){return{get:function(i,r){return r==="proxyOf"?i:i[r]?r==="each"||typeof r=="string"&&r.startsWith("walk")?function(){for(var o=arguments.length,s=new Array(o),a=0;a<o;a++)s[a]=arguments[a];var c;return(c=i)[r].apply(c,[].concat(s.map(function(u){return typeof u=="function"?function(l,d){return u(l.toProxy(),d)}:u})))}:r==="every"||r==="some"?function(o){return i[r](function(s){for(var a=arguments.length,c=new Array(a>1?a-1:0),u=1;u<a;u++)c[u-1]=arguments[u];return o.apply(void 0,[].concat([s.toProxy()],c))})}:r==="root"?function(){return i.root().toProxy()}:r==="nodes"?i.nodes.map(function(o){return o.toProxy()}):r==="first"||r==="last"?i[r].toProxy():i[r]:i[r]},set:function(i,r,o){return i[r]===o||(i[r]=o,(r==="name"||r==="params"||r==="selector")&&i.markDirty()),!0}}},t.index=function(i){return typeof i=="number"?i:(i.proxyOf&&(i=i.proxyOf),this.proxyOf.nodes.indexOf(i))},t.insertAfter=function(i,r){var o=this.index(i),s=this.normalize(r,this.proxyOf.nodes[o]).reverse();o=this.index(i);for(var a=H(s),c;!(c=a()).done;){var u=c.value;this.proxyOf.nodes.splice(o+1,0,u)}var l;for(var d in this.indexes)l=this.indexes[d],o<l&&(this.indexes[d]=l+s.length);return this.markDirty(),this},t.insertBefore=function(i,r){var o=this.index(i),s=o===0?"prepend":!1,a=this.normalize(r,this.proxyOf.nodes[o],s).reverse();o=this.index(i);for(var c=H(a),u;!(u=c()).done;){var l=u.value;this.proxyOf.nodes.splice(o,0,l)}var d;for(var h in this.indexes)d=this.indexes[h],o<=d&&(this.indexes[h]=d+a.length);return this.markDirty(),this},t.normalize=function(i,r){var o=this;if(typeof i=="string")i=ig(tg(i).nodes);else if(typeof i>"u")i=[];else if(Array.isArray(i)){i=i.slice(0);for(var s=H(i),a;!(a=s()).done;){var c=a.value;c.parent&&c.parent.removeChild(c,"ignore")}}else if(i.type==="root"&&this.type!=="document"){i=i.nodes.slice(0);for(var u=H(i),l;!(l=u()).done;){var d=l.value;d.parent&&d.parent.removeChild(d,"ignore")}}else if(i.type)i=[i];else if(i.prop){if(typeof i.value>"u")throw new Error("Value field is missed in node creation");typeof i.value!="string"&&(i.value=String(i.value)),i=[new Qm(i)]}else if(i.selector)i=[new kl(i)];else if(i.name)i=[new Sl(i)];else if(i.text)i=[new eg(i)];else throw new Error("Unknown node type in node creation");var h=i.map(function(p){return p[Zm]||e.rebuild(p),p=p.proxyOf,p.parent&&p.parent.removeChild(p),p[Jm]&&rg(p),typeof p.raws.before>"u"&&r&&typeof r.raws.before<"u"&&(p.raws.before=r.raws.before.replace(/\S/g,"")),p.parent=o.proxyOf,p});return h},t.prepend=function(){for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];r=r.reverse();for(var s=H(r),a;!(a=s()).done;){for(var c=a.value,u=this.normalize(c,this.first,"prepend").reverse(),l=H(u),d;!(d=l()).done;){var h=d.value;this.proxyOf.nodes.unshift(h)}for(var p in this.indexes)this.indexes[p]=this.indexes[p]+u.length}return this.markDirty(),this},t.push=function(i){return i.parent=this,this.proxyOf.nodes.push(i),this},t.removeAll=function(){for(var i=H(this.proxyOf.nodes),r;!(r=i()).done;){var o=r.value;o.parent=void 0}return this.proxyOf.nodes=[],this.markDirty(),this},t.removeChild=function(i){i=this.index(i),this.proxyOf.nodes[i].parent=void 0,this.proxyOf.nodes.splice(i,1);var r;for(var o in this.indexes)r=this.indexes[o],r>=i&&(this.indexes[o]=r-1);return this.markDirty(),this},t.replaceValues=function(i,r,o){return o||(o=r,r={}),this.walkDecls(function(s){r.props&&!r.props.includes(s.prop)||r.fast&&!s.value.includes(r.fast)||(s.value=s.value.replace(i,o))}),this.markDirty(),this},t.some=function(i){return this.nodes.some(i)},t.walk=function(i){return this.each(function(r,o){var s;try{s=i(r,o)}catch(a){throw r.addToError(a)}return s!==!1&&r.walk&&(s=r.walk(i)),s})},t.walkAtRules=function(i,r){return r?ne(i,RegExp)?this.walk(function(o,s){if(o.type==="atrule"&&i.test(o.name))return r(o,s)}):this.walk(function(o,s){if(o.type==="atrule"&&o.name===i)return r(o,s)}):(r=i,this.walk(function(o,s){if(o.type==="atrule")return r(o,s)}))},t.walkComments=function(i){return this.walk(function(r,o){if(r.type==="comment")return i(r,o)})},t.walkDecls=function(i,r){return r?ne(i,RegExp)?this.walk(function(o,s){if(o.type==="decl"&&i.test(o.prop))return r(o,s)}):this.walk(function(o,s){if(o.type==="decl"&&o.prop===i)return r(o,s)}):(r=i,this.walk(function(o,s){if(o.type==="decl")return r(o,s)}))},t.walkRules=function(i,r){return r?ne(i,RegExp)?this.walk(function(o,s){if(o.type==="rule"&&i.test(o.selector))return r(o,s)}):this.walk(function(o,s){if(o.type==="rule"&&o.selector===i)return r(o,s)}):(r=i,this.walk(function(o,s){if(o.type==="rule")return r(o,s)}))},mt(e,[{key:"first",get:function(){if(this.proxyOf.nodes)return this.proxyOf.nodes[0]}},{key:"last",get:function(){if(this.proxyOf.nodes)return this.proxyOf.nodes[this.proxyOf.nodes.length-1]}}]),e}(IT);Fn.registerParse=function(n){tg=n},Fn.registerRule=function(n){kl=n},Fn.registerAtRule=function(n){Sl=n},Fn.registerRoot=function(n){ng=n};var Vi=Fn;Fn.default=Fn,Fn.rebuild=function(n){n.type==="atrule"?Object.setPrototypeOf(n,Sl.prototype):n.type==="rule"?Object.setPrototypeOf(n,kl.prototype):n.type==="decl"?Object.setPrototypeOf(n,Qm.prototype):n.type==="comment"?Object.setPrototypeOf(n,eg.prototype):n.type==="root"&&Object.setPrototypeOf(n,ng.prototype),n[Zm]=!0,n.nodes&&n.nodes.forEach(function(e){Fn.rebuild(e)})};var RT=Vi,og,sg,xo=function(n){wt(e,n);function e(i){var r;return r=n.call(this,me({type:"document"},i))||this,r.nodes||(r.nodes=[]),r}var t=e.prototype;return t.toResult=function(i){i===void 0&&(i={});var r=new og(new sg,this,i);return r.stringify()},e}(RT);xo.registerLazyResult=function(n){og=n},xo.registerProcessor=function(n){sg=n};var wl=xo;xo.default=xo;var ag={},cg=function(n){ag[n]||(ag[n]=!0,typeof console<"u"&&console.warn&&console.warn(n))},Cl=function(){function n(t,i){if(i===void 0&&(i={}),this.type="warning",this.text=t,i.node&&i.node.source){var r=i.node.rangeBy(i);this.line=r.start.line,this.column=r.start.column,this.endLine=r.end.line,this.endColumn=r.end.column}for(var o in i)this[o]=i[o]}var e=n.prototype;return e.toString=function(){return this.node?this.node.error(this.text,{index:this.index,plugin:this.plugin,word:this.word}).message:this.plugin?this.plugin+": "+this.text:this.text},n}(),ug=Cl;Cl.default=Cl;var PT=ug,Tl=function(){function n(t,i,r){this.processor=t,this.messages=[],this.root=i,this.opts=r,this.css=void 0,this.map=void 0}var e=n.prototype;return e.toString=function(){return this.css},e.warn=function(t,i){i===void 0&&(i={}),i.plugin||this.lastPlugin&&this.lastPlugin.postcssPlugin&&(i.plugin=this.lastPlugin.postcssPlugin);var r=new PT(t,i);return this.messages.push(r),r},e.warnings=function(){return this.messages.filter(function(t){return t.type==="warning"})},mt(n,[{key:"content",get:function(){return this.css}}]),n}(),xl=Tl;Tl.default=Tl;var El="'".charCodeAt(0),lg='"'.charCodeAt(0),Js="\\".charCodeAt(0),dg="/".charCodeAt(0),Zs=`
36
- `.charCodeAt(0),Eo=" ".charCodeAt(0),Qs="\f".charCodeAt(0),ea=" ".charCodeAt(0),ta="\r".charCodeAt(0),OT="[".charCodeAt(0),AT="]".charCodeAt(0),MT="(".charCodeAt(0),NT=")".charCodeAt(0),DT="{".charCodeAt(0),LT="}".charCodeAt(0),UT=";".charCodeAt(0),FT="*".charCodeAt(0),BT=":".charCodeAt(0),jT="@".charCodeAt(0),na=/[\t\n\f\r "#'()/;[\\\]{}]/g,ia=/[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,VT=/.[\r\n"'(/\\]/,hg=/[\da-f]/i,zT=function(n,e){e===void 0&&(e={});var t=n.css.valueOf(),i=e.ignoreErrors,r,o,s,a,c,u,l,d,h,p,m=t.length,f=0,g=[],y=[];function b(){return f}function S(x){throw n.error("Unclosed "+x,f)}function w(){return y.length===0&&f>=m}function k(x){if(y.length)return y.pop();if(!(f>=m)){var I=x?x.ignoreUnclosed:!1;switch(r=t.charCodeAt(f),r){case Zs:case Eo:case ea:case ta:case Qs:{o=f;do o+=1,r=t.charCodeAt(o);while(r===Eo||r===Zs||r===ea||r===ta||r===Qs);p=["space",t.slice(f,o)],f=o-1;break}case OT:case AT:case DT:case LT:case BT:case UT:case NT:{var P=String.fromCharCode(r);p=[P,P,f];break}case MT:{if(d=g.length?g.pop()[1]:"",h=t.charCodeAt(f+1),d==="url"&&h!==El&&h!==lg&&h!==Eo&&h!==Zs&&h!==ea&&h!==Qs&&h!==ta){o=f;do{if(u=!1,o=t.indexOf(")",o+1),o===-1)if(i||I){o=f;break}else S("bracket");for(l=o;t.charCodeAt(l-1)===Js;)l-=1,u=!u}while(u);p=["brackets",t.slice(f,o+1),f,o],f=o}else o=t.indexOf(")",f+1),a=t.slice(f,o+1),o===-1||VT.test(a)?p=["(","(",f]:(p=["brackets",a,f,o],f=o);break}case El:case lg:{s=r===El?"'":'"',o=f;do{if(u=!1,o=t.indexOf(s,o+1),o===-1)if(i||I){o=f+1;break}else S("string");for(l=o;t.charCodeAt(l-1)===Js;)l-=1,u=!u}while(u);p=["string",t.slice(f,o+1),f,o],f=o;break}case jT:{na.lastIndex=f+1,na.test(t),na.lastIndex===0?o=t.length-1:o=na.lastIndex-2,p=["at-word",t.slice(f,o+1),f,o],f=o;break}case Js:{for(o=f,c=!0;t.charCodeAt(o+1)===Js;)o+=1,c=!c;if(r=t.charCodeAt(o+1),c&&r!==dg&&r!==Eo&&r!==Zs&&r!==ea&&r!==ta&&r!==Qs&&(o+=1,hg.test(t.charAt(o)))){for(;hg.test(t.charAt(o+1));)o+=1;t.charCodeAt(o+1)===Eo&&(o+=1)}p=["word",t.slice(f,o+1),f,o],f=o;break}default:{r===dg&&t.charCodeAt(f+1)===FT?(o=t.indexOf("*/",f+2)+1,o===0&&(i||I?o=t.length:S("comment")),p=["comment",t.slice(f,o+1),f,o],f=o):(ia.lastIndex=f+1,ia.test(t),ia.lastIndex===0?o=t.length-1:o=ia.lastIndex-2,p=["word",t.slice(f,o+1),f,o],g.push(p),f=o);break}}return f++,p}}function C(x){y.push(x)}return{back:C,endOfFile:w,nextToken:k,position:b}},pg=Vi,ra=function(n){wt(e,n);function e(i){var r;return r=n.call(this,i)||this,r.type="atrule",r}var t=e.prototype;return t.append=function(){for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];var s;return this.proxyOf.nodes||(this.nodes=[]),(s=n.prototype.append).call.apply(s,[].concat([this],r))},t.prepend=function(){for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];var s;return this.proxyOf.nodes||(this.nodes=[]),(s=n.prototype.prepend).call.apply(s,[].concat([this],r))},e}(pg),Il=ra;ra.default=ra,pg.registerAtRule(ra);var fg=Vi,mg,gg,Sr=function(n){wt(e,n);function e(i){var r;return r=n.call(this,i)||this,r.type="root",r.nodes||(r.nodes=[]),r}var t=e.prototype;return t.normalize=function(i,r,o){var s=n.prototype.normalize.call(this,i);if(r){if(o==="prepend")this.nodes.length>1?r.raws.before=this.nodes[1].raws.before:delete r.raws.before;else if(this.first!==r)for(var a=H(s),c;!(c=a()).done;){var u=c.value;u.raws.before=r.raws.before}}return s},t.removeChild=function(i,r){var o=this.index(i);return!r&&o===0&&this.nodes.length>1&&(this.nodes[1].raws.before=this.nodes[o].raws.before),n.prototype.removeChild.call(this,i)},t.toResult=function(i){i===void 0&&(i={});var r=new mg(new gg,this,i);return r.stringify()},e}(fg);Sr.registerLazyResult=function(n){mg=n},Sr.registerProcessor=function(n){gg=n};var Io=Sr;Sr.default=Sr,fg.registerRoot(Sr);var Ro={comma:function(n){return Ro.split(n,[","],!0)},space:function(n){var e=[" ",`
37
- `," "];return Ro.split(n,e)},split:function(n,e,t){for(var i=[],r="",o=!1,s=0,a=!1,c="",u=!1,l=H(n),d;!(d=l()).done;){var h=d.value;u?u=!1:h==="\\"?u=!0:a?h===c&&(a=!1):h==='"'||h==="'"?(a=!0,c=h):h==="("?s+=1:h===")"?s>0&&(s-=1):s===0&&e.includes(h)&&(o=!0),o?(r!==""&&i.push(r.trim()),r="",o=!1):r+=h}return(t||r!=="")&&i.push(r.trim()),i}},vg=Ro;Ro.default=Ro;var yg=Vi,qT=vg,oa=function(n){wt(e,n);function e(t){var i;return i=n.call(this,t)||this,i.type="rule",i.nodes||(i.nodes=[]),i}return mt(e,[{key:"selectors",get:function(){return qT.comma(this.selector)},set:function(t){var i=this.selector?this.selector.match(/,\s*/):null,r=i?i[0]:","+this.raw("between","beforeOpen");this.selector=t.join(r)}}]),e}(yg),Rl=oa;oa.default=oa,yg.registerRule(oa);var WT=Ws,GT=zT,$T=Xs,HT=Il,KT=Io,bg=Rl,_g={empty:!0,space:!0};function YT(n){for(var e=n.length-1;e>=0;e--){var t=n[e],i=t[3]||t[2];if(i)return i}}var XT=function(){function n(t){this.input=t,this.root=new KT,this.current=this.root,this.spaces="",this.semicolon=!1,this.createTokenizer(),this.root.source={input:t,start:{column:1,line:1,offset:0}}}var e=n.prototype;return e.atrule=function(t){var i=new HT;i.name=t[1].slice(1),i.name===""&&this.unnamedAtrule(i,t),this.init(i,t[2]);for(var r,o,s,a=!1,c=!1,u=[],l=[];!this.tokenizer.endOfFile();){if(t=this.tokenizer.nextToken(),r=t[0],r==="("||r==="["?l.push(r==="("?")":"]"):r==="{"&&l.length>0?l.push("}"):r===l[l.length-1]&&l.pop(),l.length===0)if(r===";"){i.source.end=this.getPosition(t[2]),i.source.end.offset++,this.semicolon=!0;break}else if(r==="{"){c=!0;break}else if(r==="}"){if(u.length>0){for(s=u.length-1,o=u[s];o&&o[0]==="space";)o=u[--s];o&&(i.source.end=this.getPosition(o[3]||o[2]),i.source.end.offset++)}this.end(t);break}else u.push(t);else u.push(t);if(this.tokenizer.endOfFile()){a=!0;break}}i.raws.between=this.spacesAndCommentsFromEnd(u),u.length?(i.raws.afterName=this.spacesAndCommentsFromStart(u),this.raw(i,"params",u),a&&(t=u[u.length-1],i.source.end=this.getPosition(t[3]||t[2]),i.source.end.offset++,this.spaces=i.raws.between,i.raws.between="")):(i.raws.afterName="",i.params=""),c&&(i.nodes=[],this.current=i)},e.checkMissedSemicolon=function(t){var i=this.colon(t);if(i!==!1){for(var r=0,o,s=i-1;s>=0&&(o=t[s],!(o[0]!=="space"&&(r+=1,r===2)));s--);throw this.input.error("Missed semicolon",o[0]==="word"?o[3]+1:o[2])}},e.colon=function(t){for(var i=0,r,o,s,a=H(t.entries()),c;!(c=a()).done;){var u=c.value,l=u[0],d=u[1];if(r=d,o=r[0],o==="("&&(i+=1),o===")"&&(i-=1),i===0&&o===":")if(!s)this.doubleColon(r);else{if(s[0]==="word"&&s[1]==="progid")continue;return l}s=r}return!1},e.comment=function(t){var i=new $T;this.init(i,t[2]),i.source.end=this.getPosition(t[3]||t[2]),i.source.end.offset++;var r=t[1].slice(2,-2);if(/^\s*$/.test(r))i.text="",i.raws.left=r,i.raws.right="";else{var o=r.match(/^(\s*)([^]*\S)(\s*)$/);i.text=o[2],i.raws.left=o[1],i.raws.right=o[3]}},e.createTokenizer=function(){this.tokenizer=GT(this.input)},e.decl=function(t,i){var r=new WT;this.init(r,t[0][2]);var o=t[t.length-1];for(o[0]===";"&&(this.semicolon=!0,t.pop()),r.source.end=this.getPosition(o[3]||o[2]||YT(t)),r.source.end.offset++;t[0][0]!=="word";)t.length===1&&this.unknownWord(t),r.raws.before+=t.shift()[1];for(r.source.start=this.getPosition(t[0][2]),r.prop="";t.length;){var s=t[0][0];if(s===":"||s==="space"||s==="comment")break;r.prop+=t.shift()[1]}r.raws.between="";for(var a;t.length;)if(a=t.shift(),a[0]===":"){r.raws.between+=a[1];break}else a[0]==="word"&&/\w/.test(a[1])&&this.unknownWord([a]),r.raws.between+=a[1];(r.prop[0]==="_"||r.prop[0]==="*")&&(r.raws.before+=r.prop[0],r.prop=r.prop.slice(1));for(var c=[],u;t.length&&(u=t[0][0],!(u!=="space"&&u!=="comment"));)c.push(t.shift());this.precheckMissedSemicolon(t);for(var l=t.length-1;l>=0;l--){if(a=t[l],a[1].toLowerCase()==="!important"){r.important=!0;var d=this.stringFrom(t,l);d=this.spacesFromEnd(t)+d,d!==" !important"&&(r.raws.important=d);break}else if(a[1].toLowerCase()==="important"){for(var h=t.slice(0),p="",m=l;m>0;m--){var f=h[m][0];if(p.trim().indexOf("!")===0&&f!=="space")break;p=h.pop()[1]+p}p.trim().indexOf("!")===0&&(r.important=!0,r.raws.important=p,t=h)}if(a[0]!=="space"&&a[0]!=="comment")break}var g=t.some(function(y){return y[0]!=="space"&&y[0]!=="comment"});g&&(r.raws.between+=c.map(function(y){return y[1]}).join(""),c=[]),this.raw(r,"value",c.concat(t),i),r.value.includes(":")&&!i&&this.checkMissedSemicolon(t)},e.doubleColon=function(t){throw this.input.error("Double colon",{offset:t[2]},{offset:t[2]+t[1].length})},e.emptyRule=function(t){var i=new bg;this.init(i,t[2]),i.selector="",i.raws.between="",this.current=i},e.end=function(t){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.spaces="",this.current.parent?(this.current.source.end=this.getPosition(t[2]),this.current.source.end.offset++,this.current=this.current.parent):this.unexpectedClose(t)},e.endFile=function(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.root.source.end=this.getPosition(this.tokenizer.position())},e.freeSemicolon=function(t){if(this.spaces+=t[1],this.current.nodes){var i=this.current.nodes[this.current.nodes.length-1];i&&i.type==="rule"&&!i.raws.ownSemicolon&&(i.raws.ownSemicolon=this.spaces,this.spaces="")}},e.getPosition=function(t){var i=this.input.fromOffset(t);return{column:i.col,line:i.line,offset:t}},e.init=function(t,i){this.current.push(t),t.source={input:this.input,start:this.getPosition(i)},t.raws.before=this.spaces,this.spaces="",t.type!=="comment"&&(this.semicolon=!1)},e.other=function(t){for(var i=!1,r=null,o=!1,s=null,a=[],c=t[1].startsWith("--"),u=[],l=t;l;){if(r=l[0],u.push(l),r==="("||r==="[")s||(s=l),a.push(r==="("?")":"]");else if(c&&o&&r==="{")s||(s=l),a.push("}");else if(a.length===0)if(r===";")if(o){this.decl(u,c);return}else break;else if(r==="{"){this.rule(u);return}else if(r==="}"){this.tokenizer.back(u.pop()),i=!0;break}else r===":"&&(o=!0);else r===a[a.length-1]&&(a.pop(),a.length===0&&(s=null));l=this.tokenizer.nextToken()}if(this.tokenizer.endOfFile()&&(i=!0),a.length>0&&this.unclosedBracket(s),i&&o){if(!c)for(;u.length&&(l=u[u.length-1][0],!(l!=="space"&&l!=="comment"));)this.tokenizer.back(u.pop());this.decl(u,c)}else this.unknownWord(u)},e.parse=function(){for(var t;!this.tokenizer.endOfFile();)switch(t=this.tokenizer.nextToken(),t[0]){case"space":this.spaces+=t[1];break;case";":this.freeSemicolon(t);break;case"}":this.end(t);break;case"comment":this.comment(t);break;case"at-word":this.atrule(t);break;case"{":this.emptyRule(t);break;default:this.other(t);break}this.endFile()},e.precheckMissedSemicolon=function(){},e.raw=function(t,i,r,o){for(var s,a,c=r.length,u="",l=!0,d,h,p=0;p<c;p+=1)s=r[p],a=s[0],a==="space"&&p===c-1&&!o?l=!1:a==="comment"?(h=r[p-1]?r[p-1][0]:"empty",d=r[p+1]?r[p+1][0]:"empty",!_g[h]&&!_g[d]?u.slice(-1)===","?l=!1:u+=s[1]:l=!1):u+=s[1];if(!l){var m=r.reduce(function(f,g){return f+g[1]},"");t.raws[i]={raw:m,value:u}}t[i]=u},e.rule=function(t){t.pop();var i=new bg;this.init(i,t[0][2]),i.raws.between=this.spacesAndCommentsFromEnd(t),this.raw(i,"selector",t),this.current=i},e.spacesAndCommentsFromEnd=function(t){for(var i,r="";t.length&&(i=t[t.length-1][0],!(i!=="space"&&i!=="comment"));)r=t.pop()[1]+r;return r},e.spacesAndCommentsFromStart=function(t){for(var i,r="";t.length&&(i=t[0][0],!(i!=="space"&&i!=="comment"));)r+=t.shift()[1];return r},e.spacesFromEnd=function(t){for(var i,r="";t.length&&(i=t[t.length-1][0],i==="space");)r=t.pop()[1]+r;return r},e.stringFrom=function(t,i){for(var r="",o=i;o<t.length;o++)r+=t[o][1];return t.splice(i,t.length-i),r},e.unclosedBlock=function(){var t=this.current.source.start;throw this.input.error("Unclosed block",t.line,t.column)},e.unclosedBracket=function(t){throw this.input.error("Unclosed bracket",{offset:t[2]},{offset:t[2]+1})},e.unexpectedClose=function(t){throw this.input.error("Unexpected }",{offset:t[2]},{offset:t[2]+1})},e.unknownWord=function(t){throw this.input.error("Unknown word",{offset:t[0][2]},{offset:t[0][2]+t[0][1].length})},e.unnamedAtrule=function(t,i){throw this.input.error("At-rule without name",{offset:i[2]},{offset:i[2]+i[1].length})},n}(),JT=XT,ZT=Vi,QT=JT,ex=Hs;function sa(n,e){var t=new ex(n,e),i=new QT(t);try{i.parse()}catch(r){throw process.env.NODE_ENV!=="production"&&r.name==="CssSyntaxError"&&e&&e.from&&(/\.scss$/i.test(e.from)?r.message+=`
38
- You tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser`:/\.sass/i.test(e.from)?r.message+=`
39
- You tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser`:/\.less$/i.test(e.from)&&(r.message+=`
40
- You tried to parse Less with the standard CSS parser; try again with the postcss-less parser`)),r}return i.root}var Pl=sa;sa.default=sa,ZT.registerParse(sa);var _n=ni.isClean,tx=ni.my,nx=Xm,ix=Vs,rx=Vi,ox=wl,sx=cg,kg=xl,ax=Pl,cx=Io,ux={atrule:"AtRule",comment:"Comment",decl:"Declaration",document:"Document",root:"Root",rule:"Rule"},lx={AtRule:!0,AtRuleExit:!0,Comment:!0,CommentExit:!0,Declaration:!0,DeclarationExit:!0,Document:!0,DocumentExit:!0,Once:!0,OnceExit:!0,postcssPlugin:!0,prepare:!0,Root:!0,RootExit:!0,Rule:!0,RuleExit:!0},dx={Once:!0,postcssPlugin:!0,prepare:!0},wr=0;function Po(n){return(typeof n>"u"?"undefined":oe(n))==="object"&&typeof n.then=="function"}function Sg(n){var e=!1,t=ux[n.type];return n.type==="decl"?e=n.prop.toLowerCase():n.type==="atrule"&&(e=n.name.toLowerCase()),e&&n.append?[t,t+"-"+e,wr,t+"Exit",t+"Exit-"+e]:e?[t,t+"-"+e,t+"Exit",t+"Exit-"+e]:n.append?[t,wr,t+"Exit"]:[t,t+"Exit"]}function wg(n){var e;return n.type==="document"?e=["Document",wr,"DocumentExit"]:n.type==="root"?e=["Root",wr,"RootExit"]:e=Sg(n),{eventIndex:0,events:e,iterator:0,node:n,visitorIndex:0,visitors:[]}}function Ol(n){return n[_n]=!1,n.nodes&&n.nodes.forEach(function(e){return Ol(e)}),n}var Al={},Cr=function(){function n(t,i,r){var o=this;this.stringified=!1,this.processed=!1;var s;if((typeof i>"u"?"undefined":oe(i))==="object"&&i!==null&&(i.type==="root"||i.type==="document"))s=Ol(i);else if(ne(i,n)||ne(i,kg))s=Ol(i.root),i.map&&(typeof r.map>"u"&&(r.map={}),r.map.inline||(r.map.inline=!1),r.map.prev=i.map);else{var a=ax;r.syntax&&(a=r.syntax.parse),r.parser&&(a=r.parser),a.parse&&(a=a.parse);try{s=a(i,r)}catch(c){this.processed=!0,this.error=c}s&&!s[tx]&&rx.rebuild(s)}this.result=new kg(t,s,r),this.helpers=me({},Al,{postcss:Al,result:this.result}),this.plugins=this.processor.plugins.map(function(c){return(typeof c>"u"?"undefined":oe(c))==="object"&&c.prepare?me({},c,c.prepare(o.result)):c})}var e=n.prototype;return e.async=function(){return this.error?Promise.reject(this.error):this.processed?Promise.resolve(this.result):(this.processing||(this.processing=this.runAsync()),this.processing)},e.catch=function(t){return this.async().catch(t)},e.finally=function(t){return this.async().then(t,t)},e.getAsyncError=function(){throw new Error("Use process(css).then(cb) to work with async plugins")},e.handleError=function(t,i){var r=this.result.lastPlugin;try{if(i&&i.addToError(t),this.error=t,t.name==="CssSyntaxError"&&!t.plugin)t.plugin=r.postcssPlugin,t.setMessage();else if(r.postcssVersion&&process.env.NODE_ENV!=="production"){var o=r.postcssPlugin,s=r.postcssVersion,a=this.result.processor.version,c=s.split("."),u=a.split(".");(c[0]!==u[0]||parseInt(c[1])>parseInt(u[1]))&&console.error("Unknown error from PostCSS plugin. Your current PostCSS version is "+a+", but "+o+" uses "+s+". Perhaps this is the source of the error below.")}}catch(l){console&&console.error&&console.error(l)}return t},e.prepareVisitors=function(){var t=this;this.listeners={};for(var i=function(u,l,d){t.listeners[l]||(t.listeners[l]=[]),t.listeners[l].push([u,d])},r=H(this.plugins),o;!(o=r()).done;){var s=o.value;if((typeof s>"u"?"undefined":oe(s))==="object")for(var a in s){if(!lx[a]&&/^[A-Z]/.test(a))throw new Error("Unknown event "+a+" in "+s.postcssPlugin+". Try to update PostCSS ("+this.processor.version+" now).");if(!dx[a])if(oe(s[a])==="object")for(var c in s[a])c==="*"?i(s,a,s[a][c]):i(s,a+"-"+c.toLowerCase(),s[a][c]);else typeof s[a]=="function"&&i(s,a,s[a])}}this.hasListener=Object.keys(this.listeners).length>0},e.runAsync=function(){var t=this;return Xu(function(){var i,r,o,s,a,c,u,l,d,h,p,m;return So(this,function(f){switch(f.label){case 0:t.plugin=0,i=0,f.label=1;case 1:if(!(i<t.plugins.length))return[3,6];if(r=t.plugins[i],o=t.runOnRoot(r),!Po(o))return[3,5];f.label=2;case 2:return f.trys.push([2,4,,5]),[4,o];case 3:return f.sent(),[3,5];case 4:throw s=f.sent(),t.handleError(s);case 5:return i++,[3,1];case 6:if(t.prepareVisitors(),!t.hasListener)return[3,18];a=t.result.root,f.label=7;case 7:if(a[_n])return[3,14];a[_n]=!0,c=[wg(a)],f.label=8;case 8:if(!(c.length>0))return[3,13];if(u=t.visitTick(c),!Po(u))return[3,12];f.label=9;case 9:return f.trys.push([9,11,,12]),[4,u];case 10:return f.sent(),[3,12];case 11:throw l=f.sent(),d=c[c.length-1].node,t.handleError(l,d);case 12:return[3,8];case 13:return[3,7];case 14:if(!t.listeners.OnceExit)return[3,18];h=function(){var g,y,b,S,w;return So(this,function(k){switch(k.label){case 0:g=m.value,y=g[0],b=g[1],t.result.lastPlugin=y,k.label=1;case 1:return k.trys.push([1,6,,7]),a.type!=="document"?[3,3]:(S=a.nodes.map(function(C){return b(C,t.helpers)}),[4,Promise.all(S)]);case 2:return k.sent(),[3,5];case 3:return[4,b(a,t.helpers)];case 4:k.sent(),k.label=5;case 5:return[3,7];case 6:throw w=k.sent(),t.handleError(w);case 7:return[2]}})},p=H(t.listeners.OnceExit),f.label=15;case 15:return(m=p()).done?[3,18]:[5,vm(h())];case 16:f.sent(),f.label=17;case 17:return[3,15];case 18:return t.processed=!0,[2,t.stringify()]}})})()},e.runOnRoot=function(t){var i=this;this.result.lastPlugin=t;try{if((typeof t>"u"?"undefined":oe(t))==="object"&&t.Once){if(this.result.root.type==="document"){var r=this.result.root.nodes.map(function(o){return t.Once(o,i.helpers)});return Po(r[0])?Promise.all(r):r}return t.Once(this.result.root,this.helpers)}else if(typeof t=="function")return t(this.result.root,this.result)}catch(o){throw this.handleError(o)}},e.stringify=function(){if(this.error)throw this.error;if(this.stringified)return this.result;this.stringified=!0,this.sync();var t=this.result.opts,i=ix;t.syntax&&(i=t.syntax.stringify),t.stringifier&&(i=t.stringifier),i.stringify&&(i=i.stringify);var r=new nx(i,this.result.root,this.result.opts),o=r.generate();return this.result.css=o[0],this.result.map=o[1],this.result},e.sync=function(){if(this.error)throw this.error;if(this.processed)return this.result;if(this.processed=!0,this.processing)throw this.getAsyncError();for(var t=H(this.plugins),i;!(i=t()).done;){var r=i.value,o=this.runOnRoot(r);if(Po(o))throw this.getAsyncError()}if(this.prepareVisitors(),this.hasListener){for(var s=this.result.root;!s[_n];)s[_n]=!0,this.walkSync(s);if(this.listeners.OnceExit)if(s.type==="document")for(var a=H(s.nodes),c;!(c=a()).done;){var u=c.value;this.visitSync(this.listeners.OnceExit,u)}else this.visitSync(this.listeners.OnceExit,s)}return this.result},e.then=function(t,i){return process.env.NODE_ENV!=="production"&&("from"in this.opts||sx("Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.")),this.async().then(t,i)},e.toString=function(){return this.css},e.visitSync=function(t,i){for(var r=H(t),o;!(o=r()).done;){var s=o.value,a=s[0],c=s[1];this.result.lastPlugin=a;var u=void 0;try{u=c(i,this.helpers)}catch(l){throw this.handleError(l,i.proxyOf)}if(i.type!=="root"&&i.type!=="document"&&!i.parent)return!0;if(Po(u))throw this.getAsyncError()}},e.visitTick=function(t){var i=t[t.length-1],r=i.node,o=i.visitors;if(r.type!=="root"&&r.type!=="document"&&!r.parent){t.pop();return}if(o.length>0&&i.visitorIndex<o.length){var s=o[i.visitorIndex],a=s[0],c=s[1];i.visitorIndex+=1,i.visitorIndex===o.length&&(i.visitors=[],i.visitorIndex=0),this.result.lastPlugin=a;try{return c(r.toProxy(),this.helpers)}catch(p){throw this.handleError(p,r)}}if(i.iterator!==0){for(var u=i.iterator,l;l=r.nodes[r.indexes[u]];)if(r.indexes[u]+=1,!l[_n]){l[_n]=!0,t.push(wg(l));return}i.iterator=0,delete r.indexes[u]}for(var d=i.events;i.eventIndex<d.length;){var h=d[i.eventIndex];if(i.eventIndex+=1,h===wr){r.nodes&&r.nodes.length&&(r[_n]=!0,i.iterator=r.getIterator());return}else if(this.listeners[h]){i.visitors=this.listeners[h];return}}t.pop()},e.walkSync=function(t){var i=this;t[_n]=!0;for(var r=Sg(t),o=H(r),s;!(s=o()).done;){var a=s.value;if(a===wr)t.nodes&&t.each(function(u){u[_n]||i.walkSync(u)});else{var c=this.listeners[a];if(c&&this.visitSync(c,t.toProxy()))return}}},e.warnings=function(){return this.sync().warnings()},mt(n,[{key:"content",get:function(){return this.stringify().content}},{key:"css",get:function(){return this.stringify().css}},{key:"map",get:function(){return this.stringify().map}},{key:"messages",get:function(){return this.sync().messages}},{key:"opts",get:function(){return this.result.opts}},{key:"processor",get:function(){return this.result.processor}},{key:"root",get:function(){return this.sync().root}},{key:Symbol.toStringTag,get:function(){return"LazyResult"}}]),n}();Cr.registerPostcss=function(n){Al=n};var Cg=Cr;Cr.default=Cr,cx.registerLazyResult(Cr),ox.registerLazyResult(Cr);var hx=Xm,px=Vs,fx=cg,mx=Pl,gx=xl,Ml=function(){function n(t,i,r){i=i.toString(),this.stringified=!1,this._processor=t,this._css=i,this._opts=r,this._map=void 0;var o,s=px;this.result=new gx(this._processor,o,this._opts),this.result.css=i;var a=this;Object.defineProperty(this.result,"root",{get:function(){return a.root}});var c=new hx(s,o,this._opts,i);if(c.isMap()){var u=c.generate(),l=u[0],d=u[1];l&&(this.result.css=l),d&&(this.result.map=d)}else c.clearAnnotation(),this.result.css=c.css}var e=n.prototype;return e.async=function(){return this.error?Promise.reject(this.error):Promise.resolve(this.result)},e.catch=function(t){return this.async().catch(t)},e.finally=function(t){return this.async().then(t,t)},e.sync=function(){if(this.error)throw this.error;return this.result},e.then=function(t,i){return process.env.NODE_ENV!=="production"&&("from"in this._opts||fx("Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.")),this.async().then(t,i)},e.toString=function(){return this._css},e.warnings=function(){return[]},mt(n,[{key:"content",get:function(){return this.result.css}},{key:"css",get:function(){return this.result.css}},{key:"map",get:function(){return this.result.map}},{key:"messages",get:function(){return[]}},{key:"opts",get:function(){return this.result.opts}},{key:"processor",get:function(){return this.result.processor}},{key:"root",get:function(){if(this._root)return this._root;var t,i=mx;try{t=i(this._css,this._opts)}catch(r){this.error=r}if(this.error)throw this.error;return this._root=t,t}},{key:Symbol.toStringTag,get:function(){return"NoWorkResult"}}]),n}(),vx=Ml;Ml.default=Ml;var yx=vx,bx=Cg,_x=wl,kx=Io,Oo=function(){function n(t){t===void 0&&(t=[]),this.version="8.4.38",this.plugins=this.normalize(t)}var e=n.prototype;return e.normalize=function(t){for(var i=[],r=H(t),o;!(o=r()).done;){var s=o.value;if(s.postcss===!0?s=s():s.postcss&&(s=s.postcss),(typeof s>"u"?"undefined":oe(s))==="object"&&Array.isArray(s.plugins))i=i.concat(s.plugins);else if((typeof s>"u"?"undefined":oe(s))==="object"&&s.postcssPlugin)i.push(s);else if(typeof s=="function")i.push(s);else if((typeof s>"u"?"undefined":oe(s))==="object"&&(s.parse||s.stringify)){if(process.env.NODE_ENV!=="production")throw new Error("PostCSS syntaxes cannot be used as plugins. Instead, please use one of the syntax/parser/stringifier options as outlined in your PostCSS runner documentation.")}else throw new Error(s+" is not a PostCSS plugin")}return i},e.process=function(t,i){return i===void 0&&(i={}),!this.plugins.length&&!i.parser&&!i.stringifier&&!i.syntax?new yx(this,t,i):new bx(this,t,i)},e.use=function(t){return this.plugins=this.plugins.concat(this.normalize([t])),this},n}(),Sx=Oo;Oo.default=Oo,kx.registerProcessor(Oo),_x.registerProcessor(Oo);var wx=Ws,Cx=Vm,Tx=Xs,xx=Il,Ex=Hs,Ix=Io,Rx=Rl;function Ao(n,e){if(Array.isArray(n))return n.map(function(d){return Ao(d)});var t=n.inputs,i=_o(n,["inputs"]);if(t){e=[];for(var r=H(t),o;!(o=r()).done;){var s=o.value,a=me({},s,{__proto__:Ex.prototype});a.map&&(a.map=me({},a.map,{__proto__:Cx.prototype})),e.push(a)}}if(i.nodes&&(i.nodes=n.nodes.map(function(d){return Ao(d,e)})),i.source){var c=i.source,u=c.inputId,l=_o(c,["inputId"]);i.source=l,u!=null&&(i.source.input=e[u])}if(i.type==="root")return new Ix(i);if(i.type==="decl")return new wx(i);if(i.type==="rule")return new Rx(i);if(i.type==="comment")return new Tx(i);if(i.type==="atrule")return new xx(i);throw new Error("Unknown node type: "+n.type)}var Px=Ao;Ao.default=Ao;var Ox=cl,Tg=Ws,Ax=Cg,Mx=Vi,Nl=Sx,Nx=Vs,Dx=Px,xg=wl,Lx=ug,Eg=Xs,Ig=Il,Ux=xl,Fx=Hs,Bx=Pl,jx=vg,Rg=Rl,Pg=Io,Vx=qs;function Te(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];return e.length===1&&Array.isArray(e[0])&&(e=e[0]),new Nl(e)}Te.plugin=function(n,e){var t=!1;function i(){for(var o=arguments.length,s=new Array(o),a=0;a<o;a++)s[a]=arguments[a];console&&console.warn&&!t&&(t=!0,console.warn(n+`: postcss.plugin was deprecated. Migration guide:
41
- https://evilmartians.com/chronicles/postcss-8-plugin-migration`),process.env.LANG&&process.env.LANG.startsWith("cn")&&console.warn(n+`: \u91CC\u9762 postcss.plugin \u88AB\u5F03\u7528. \u8FC1\u79FB\u6307\u5357:
42
- https://www.w3ctech.com/topic/2226`));var c=e.apply(void 0,[].concat(s));return c.postcssPlugin=n,c.postcssVersion=new Nl().version,c}var r;return Object.defineProperty(i,"postcss",{get:function(){return r||(r=i()),r}}),i.process=function(o,s,a){return Te([i(a)]).process(o,s)},i},Te.stringify=Nx,Te.parse=Bx,Te.fromJSON=Dx,Te.list=jx,Te.comment=function(n){return new Eg(n)},Te.atRule=function(n){return new Ig(n)},Te.decl=function(n){return new Tg(n)},Te.rule=function(n){return new Rg(n)},Te.root=function(n){return new Pg(n)},Te.document=function(n){return new xg(n)},Te.CssSyntaxError=Ox,Te.Declaration=Tg,Te.Container=Mx,Te.Processor=Nl,Te.Document=xg,Te.Comment=Eg,Te.Warning=Lx,Te.AtRule=Ig,Te.Result=Ux,Te.Input=Fx,Te.Rule=Rg,Te.Root=Pg,Te.Node=Vx,Ax.registerPostcss(Te);var zx=Te;Te.default=Te;var Ve=Q1(zx);Ve.stringify,Ve.fromJSON,Ve.plugin,Ve.parse,Ve.list,Ve.document,Ve.comment,Ve.atRule,Ve.rule,Ve.decl,Ve.root,Ve.CssSyntaxError,Ve.Declaration,Ve.Container,Ve.Processor,Ve.Document,Ve.Comment,Ve.Warning,Ve.AtRule,Ve.Result,Ve.Input,Ve.Rule,Ve.Root,Ve.Node;var qx=Object.defineProperty,Wx=function(n,e,t){return e in n?qx(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t},Ht=function(n,e,t){return Wx(n,(typeof e>"u"?"undefined":oe(e))!=="symbol"?e+"":e,t)};function Gx(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function $x(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var t=function i(){return ne(this,i)?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(i){var r=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:function(){return n[i]}})}),t}var Dl={exports:{}},Le=String,Og=function(){return{isColorSupported:!1,reset:Le,bold:Le,dim:Le,italic:Le,underline:Le,inverse:Le,hidden:Le,strikethrough:Le,black:Le,red:Le,green:Le,yellow:Le,blue:Le,magenta:Le,cyan:Le,white:Le,gray:Le,bgBlack:Le,bgRed:Le,bgGreen:Le,bgYellow:Le,bgBlue:Le,bgMagenta:Le,bgCyan:Le,bgWhite:Le}};Dl.exports=Og(),Dl.exports.createColors=Og;var Hx=Dl.exports,Kx={},Yx=Object.freeze(Object.defineProperty({__proto__:null,default:Kx},Symbol.toStringTag,{value:"Module"})),tt=$x(Yx),Ag=Hx,Mg=tt,Ll=function(n){wt(e,n);function e(i,r,o,s,a,c){var u;return u=n.call(this,i)||this,u.name="CssSyntaxError",u.reason=i,a&&(u.file=a),s&&(u.source=s),c&&(u.plugin=c),typeof r<"u"&&typeof o<"u"&&(typeof r=="number"?(u.line=r,u.column=o):(u.line=r.line,u.column=r.column,u.endLine=o.line,u.endColumn=o.column)),u.setMessage(),Error.captureStackTrace&&Error.captureStackTrace(u,e),u}var t=e.prototype;return t.setMessage=function(){this.message=this.plugin?this.plugin+": ":"",this.message+=this.file?this.file:"<css input>",typeof this.line<"u"&&(this.message+=":"+this.line+":"+this.column),this.message+=": "+this.reason},t.showSourceCode=function(i){var r=this;if(!this.source)return"";var o=this.source;i==null&&(i=Ag.isColorSupported),Mg&&i&&(o=Mg(o));var s=o.split(/\r?\n/),a=Math.max(this.line-3,0),c=Math.min(this.line+2,s.length),u=String(c).length,l,d;if(i){var h=Ag.createColors(!0),p=h.bold,m=h.gray,f=h.red;l=function(g){return p(f(g))},d=function(g){return m(g)}}else l=d=function(g){return g};return s.slice(a,c).map(function(g,y){var b=a+1+y,S=" "+(" "+b).slice(-u)+" | ";if(b===r.line){var w=d(S.replace(/\d/g," "))+g.slice(0,r.column-1).replace(/[^\t]/g," ");return l(">")+d(S)+g+`
43
- `+w+l("^")}return" "+d(S)+g}).join(`
44
- `)},t.toString=function(){var i=this.showSourceCode();return i&&(i=`
45
-
46
- `+i+`
47
- `),this.name+": "+this.message+i},e}(Ls(Error)),Ul=Ll;Ll.default=Ll;var ii={};ii.isClean=Symbol("isClean"),ii.my=Symbol("my");var Ng={after:`
48
- `,beforeClose:`
49
- `,beforeComment:`
50
- `,beforeDecl:`
51
- `,beforeOpen:" ",beforeRule:`
52
- `,colon:": ",commentLeft:" ",commentRight:" ",emptyBody:"",indent:" ",semicolon:!1};function Xx(n){return n[0].toUpperCase()+n.slice(1)}var Fl=function(){function n(t){this.builder=t}var e=n.prototype;return e.atrule=function(t,i){var r="@"+t.name,o=t.params?this.rawValue(t,"params"):"";if(typeof t.raws.afterName<"u"?r+=t.raws.afterName:o&&(r+=" "),t.nodes)this.block(t,r+o);else{var s=(t.raws.between||"")+(i?";":"");this.builder(r+o+s,t)}},e.beforeAfter=function(t,i){var r;t.type==="decl"?r=this.raw(t,null,"beforeDecl"):t.type==="comment"?r=this.raw(t,null,"beforeComment"):i==="before"?r=this.raw(t,null,"beforeRule"):r=this.raw(t,null,"beforeClose");for(var o=t.parent,s=0;o&&o.type!=="root";)s+=1,o=o.parent;if(r.includes(`
53
- `)){var a=this.raw(t,null,"indent");if(a.length)for(var c=0;c<s;c++)r+=a}return r},e.block=function(t,i){var r=this.raw(t,"between","beforeOpen");this.builder(i+r+"{",t,"start");var o;t.nodes&&t.nodes.length?(this.body(t),o=this.raw(t,"after")):o=this.raw(t,"after","emptyBody"),o&&this.builder(o),this.builder("}",t,"end")},e.body=function(t){for(var i=t.nodes.length-1;i>0&&t.nodes[i].type==="comment";)i-=1;for(var r=this.raw(t,"semicolon"),o=0;o<t.nodes.length;o++){var s=t.nodes[o],a=this.raw(s,"before");a&&this.builder(a),this.stringify(s,i!==o||r)}},e.comment=function(t){var i=this.raw(t,"left","commentLeft"),r=this.raw(t,"right","commentRight");this.builder("/*"+i+t.text+r+"*/",t)},e.decl=function(t,i){var r=this.raw(t,"between","colon"),o=t.prop+r+this.rawValue(t,"value");t.important&&(o+=t.raws.important||" !important"),i&&(o+=";"),this.builder(o,t)},e.document=function(t){this.body(t)},e.raw=function(t,i,r){var o;if(r||(r=i),i&&(o=t.raws[i],typeof o<"u"))return o;var s=t.parent;if(r==="before"&&(!s||s.type==="root"&&s.first===t||s&&s.type==="document"))return"";if(!s)return Ng[r];var a=t.root();if(a.rawCache||(a.rawCache={}),typeof a.rawCache[r]<"u")return a.rawCache[r];if(r==="before"||r==="after")return this.beforeAfter(t,r);var c="raw"+Xx(r);return this[c]?o=this[c](a,t):a.walk(function(u){if(o=u.raws[i],typeof o<"u")return!1}),typeof o>"u"&&(o=Ng[r]),a.rawCache[r]=o,o},e.rawBeforeClose=function(t){var i;return t.walk(function(r){if(r.nodes&&r.nodes.length>0&&typeof r.raws.after<"u")return i=r.raws.after,i.includes(`
54
- `)&&(i=i.replace(/[^\n]+$/,"")),!1}),i&&(i=i.replace(/\S/g,"")),i},e.rawBeforeComment=function(t,i){var r;return t.walkComments(function(o){if(typeof o.raws.before<"u")return r=o.raws.before,r.includes(`
55
- `)&&(r=r.replace(/[^\n]+$/,"")),!1}),typeof r>"u"?r=this.raw(i,null,"beforeDecl"):r&&(r=r.replace(/\S/g,"")),r},e.rawBeforeDecl=function(t,i){var r;return t.walkDecls(function(o){if(typeof o.raws.before<"u")return r=o.raws.before,r.includes(`
56
- `)&&(r=r.replace(/[^\n]+$/,"")),!1}),typeof r>"u"?r=this.raw(i,null,"beforeRule"):r&&(r=r.replace(/\S/g,"")),r},e.rawBeforeOpen=function(t){var i;return t.walk(function(r){if(r.type!=="decl"&&(i=r.raws.between,typeof i<"u"))return!1}),i},e.rawBeforeRule=function(t){var i;return t.walk(function(r){if(r.nodes&&(r.parent!==t||t.first!==r)&&typeof r.raws.before<"u")return i=r.raws.before,i.includes(`
57
- `)&&(i=i.replace(/[^\n]+$/,"")),!1}),i&&(i=i.replace(/\S/g,"")),i},e.rawColon=function(t){var i;return t.walkDecls(function(r){if(typeof r.raws.between<"u")return i=r.raws.between.replace(/[^\s:]/g,""),!1}),i},e.rawEmptyBody=function(t){var i;return t.walk(function(r){if(r.nodes&&r.nodes.length===0&&(i=r.raws.after,typeof i<"u"))return!1}),i},e.rawIndent=function(t){if(t.raws.indent)return t.raws.indent;var i;return t.walk(function(r){var o=r.parent;if(o&&o!==t&&o.parent&&o.parent===t&&typeof r.raws.before<"u"){var s=r.raws.before.split(`
58
- `);return i=s[s.length-1],i=i.replace(/\S/g,""),!1}}),i},e.rawSemicolon=function(t){var i;return t.walk(function(r){if(r.nodes&&r.nodes.length&&r.last.type==="decl"&&(i=r.raws.semicolon,typeof i<"u"))return!1}),i},e.rawValue=function(t,i){var r=t[i],o=t.raws[i];return o&&o.value===r?o.raw:r},e.root=function(t){this.body(t),t.raws.after&&this.builder(t.raws.after)},e.rule=function(t){this.block(t,this.rawValue(t,"selector")),t.raws.ownSemicolon&&this.builder(t.raws.ownSemicolon,t,"end")},e.stringify=function(t,i){if(!this[t.type])throw new Error("Unknown AST node type "+t.type+". Maybe you need to change PostCSS stringifier.");this[t.type](t,i)},n}(),Dg=Fl;Fl.default=Fl;var Jx=Dg;function Bl(n,e){var t=new Jx(e);t.stringify(n)}var aa=Bl;Bl.default=Bl;var ca=ii.isClean,Zx=ii.my,Qx=Ul,eE=Dg,tE=aa;function jl(n,e){var t=new n.constructor;for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)&&i!=="proxyCache"){var r=n[i],o=typeof r>"u"?"undefined":oe(r);i==="parent"&&o==="object"?e&&(t[i]=e):i==="source"?t[i]=r:Array.isArray(r)?t[i]=r.map(function(s){return jl(s,t)}):(o==="object"&&r!==null&&(r=jl(r)),t[i]=r)}return t}var Vl=function(){function n(t){t===void 0&&(t={}),this.raws={},this[ca]=!1,this[Zx]=!0;for(var i in t)if(i==="nodes"){this.nodes=[];for(var r=H(t[i]),o;!(o=r()).done;){var s=o.value;typeof s.clone=="function"?this.append(s.clone()):this.append(s)}}else this[i]=t[i]}var e=n.prototype;return e.addToError=function(t){if(t.postcssNode=this,t.stack&&this.source&&/\n\s{4}at /.test(t.stack)){var i=this.source;t.stack=t.stack.replace(/\n\s{4}at /,"$&"+i.input.from+":"+i.start.line+":"+i.start.column+"$&")}return t},e.after=function(t){return this.parent.insertAfter(this,t),this},e.assign=function(t){t===void 0&&(t={});for(var i in t)this[i]=t[i];return this},e.before=function(t){return this.parent.insertBefore(this,t),this},e.cleanRaws=function(t){delete this.raws.before,delete this.raws.after,t||delete this.raws.between},e.clone=function(t){t===void 0&&(t={});var i=jl(this);for(var r in t)i[r]=t[r];return i},e.cloneAfter=function(t){t===void 0&&(t={});var i=this.clone(t);return this.parent.insertAfter(this,i),i},e.cloneBefore=function(t){t===void 0&&(t={});var i=this.clone(t);return this.parent.insertBefore(this,i),i},e.error=function(t,i){if(i===void 0&&(i={}),this.source){var r=this.rangeBy(i),o=r.end,s=r.start;return this.source.input.error(t,{column:s.column,line:s.line},{column:o.column,line:o.line},i)}return new Qx(t)},e.getProxyProcessor=function(){return{get:function(t,i){return i==="proxyOf"?t:i==="root"?function(){return t.root().toProxy()}:t[i]},set:function(t,i,r){return t[i]===r||(t[i]=r,(i==="prop"||i==="value"||i==="name"||i==="params"||i==="important"||i==="text")&&t.markDirty()),!0}}},e.markDirty=function(){if(this[ca]){this[ca]=!1;for(var t=this;t=t.parent;)t[ca]=!1}},e.next=function(){if(this.parent){var t=this.parent.index(this);return this.parent.nodes[t+1]}},e.positionBy=function(t,i){var r=this.source.start;if(t.index)r=this.positionInside(t.index,i);else if(t.word){i=this.toString();var o=i.indexOf(t.word);o!==-1&&(r=this.positionInside(o,i))}return r},e.positionInside=function(t,i){for(var r=i||this.toString(),o=this.source.start.column,s=this.source.start.line,a=0;a<t;a++)r[a]===`
59
- `?(o=1,s+=1):o+=1;return{column:o,line:s}},e.prev=function(){if(this.parent){var t=this.parent.index(this);return this.parent.nodes[t-1]}},e.rangeBy=function(t){var i={column:this.source.start.column,line:this.source.start.line},r=this.source.end?{column:this.source.end.column+1,line:this.source.end.line}:{column:i.column+1,line:i.line};if(t.word){var o=this.toString(),s=o.indexOf(t.word);s!==-1&&(i=this.positionInside(s,o),r=this.positionInside(s+t.word.length,o))}else t.start?i={column:t.start.column,line:t.start.line}:t.index&&(i=this.positionInside(t.index)),t.end?r={column:t.end.column,line:t.end.line}:typeof t.endIndex=="number"?r=this.positionInside(t.endIndex):t.index&&(r=this.positionInside(t.index+1));return(r.line<i.line||r.line===i.line&&r.column<=i.column)&&(r={column:i.column+1,line:i.line}),{end:r,start:i}},e.raw=function(t,i){var r=new eE;return r.raw(this,t,i)},e.remove=function(){return this.parent&&this.parent.removeChild(this),this.parent=void 0,this},e.replaceWith=function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];if(this.parent){for(var o=this,s=!1,a=H(i),c;!(c=a()).done;){var u=c.value;u===this?s=!0:s?(this.parent.insertAfter(o,u),o=u):this.parent.insertBefore(o,u)}s||this.remove()}return this},e.root=function(){for(var t=this;t.parent&&t.parent.type!=="document";)t=t.parent;return t},e.toJSON=function(t,i){var r={},o=i==null;i=i||new Map;var s=0;for(var a in this)if(Object.prototype.hasOwnProperty.call(this,a)&&!(a==="parent"||a==="proxyCache")){var c=this[a];if(Array.isArray(c))r[a]=c.map(function(l){return(typeof l>"u"?"undefined":oe(l))==="object"&&l.toJSON?l.toJSON(null,i):l});else if((typeof c>"u"?"undefined":oe(c))==="object"&&c.toJSON)r[a]=c.toJSON(null,i);else if(a==="source"){var u=i.get(c.input);u==null&&(u=s,i.set(c.input,s),s++),r[a]={end:c.end,inputId:u,start:c.start}}else r[a]=c}return o&&(r.inputs=[].concat(i.keys()).map(function(l){return l.toJSON()})),r},e.toProxy=function(){return this.proxyCache||(this.proxyCache=new Proxy(this,this.getProxyProcessor())),this.proxyCache},e.toString=function(t){t===void 0&&(t=tE),t.stringify&&(t=t.stringify);var i="";return t(this,function(r){i+=r}),i},e.warn=function(t,i,r){var o={node:this};for(var s in r)o[s]=r[s];return t.warn(i,o)},mt(n,[{key:"proxyOf",get:function(){return this}}]),n}(),ua=Vl;Vl.default=Vl;var nE=ua,zl=function(n){wt(e,n);function e(t){var i;return t&&typeof t.value<"u"&&typeof t.value!="string"&&(t=me({},t,{value:String(t.value)})),i=n.call(this,t)||this,i.type="decl",i}return mt(e,[{key:"variable",get:function(){return this.prop.startsWith("--")||this.prop[0]==="$"}}]),e}(nE),la=zl;zl.default=zl;var iE="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",rE=function(n){n===void 0&&(n=21);for(var e="",t=n;t--;)e+=iE[Math.random()*64|0];return e},oE={nanoid:rE},Lg=tt.SourceMapConsumer,Ug=tt.SourceMapGenerator,sE=tt.existsSync,aE=tt.readFileSync,ql=tt.dirname,cE=tt.join;function uE(n){return Buffer?Buffer.from(n,"base64").toString():window.atob(n)}var Wl=function(){function n(t,i){if(i.map!==!1){this.loadAnnotation(t),this.inline=this.startWith(this.annotation,"data:");var r=i.map?i.map.prev:void 0,o=this.loadMap(i.from,r);!this.mapFile&&i.from&&(this.mapFile=i.from),this.mapFile&&(this.root=ql(this.mapFile)),o&&(this.text=o)}}var e=n.prototype;return e.consumer=function(){return this.consumerCache||(this.consumerCache=new Lg(this.text)),this.consumerCache},e.decodeInline=function(t){var i=/^data:application\/json;charset=utf-?8;base64,/,r=/^data:application\/json;base64,/,o=/^data:application\/json;charset=utf-?8,/,s=/^data:application\/json,/;if(o.test(t)||s.test(t))return decodeURIComponent(t.substr(RegExp.lastMatch.length));if(i.test(t)||r.test(t))return uE(t.substr(RegExp.lastMatch.length));var a=t.match(/data:application\/json;([^,]+),/)[1];throw new Error("Unsupported source map encoding "+a)},e.getAnnotationURL=function(t){return t.replace(/^\/\*\s*# sourceMappingURL=/,"").trim()},e.isMap=function(t){return(typeof t>"u"?"undefined":oe(t))!=="object"?!1:typeof t.mappings=="string"||typeof t._mappings=="string"||Array.isArray(t.sections)},e.loadAnnotation=function(t){var i=t.match(/\/\*\s*# sourceMappingURL=/gm);if(i){var r=t.lastIndexOf(i.pop()),o=t.indexOf("*/",r);r>-1&&o>-1&&(this.annotation=this.getAnnotationURL(t.substring(r,o)))}},e.loadFile=function(t){if(this.root=ql(t),sE(t))return this.mapFile=t,aE(t,"utf-8").toString().trim()},e.loadMap=function(t,i){if(i===!1)return!1;if(i){if(typeof i=="string")return i;if(typeof i=="function"){var r=i(t);if(r){var o=this.loadFile(r);if(!o)throw new Error("Unable to load previous source map: "+r.toString());return o}}else{if(ne(i,Lg))return Ug.fromSourceMap(i).toString();if(ne(i,Ug))return i.toString();if(this.isMap(i))return JSON.stringify(i);throw new Error("Unsupported previous source map format: "+i.toString())}}else{if(this.inline)return this.decodeInline(this.annotation);if(this.annotation){var s=this.annotation;return t&&(s=cE(ql(t),s)),this.loadFile(s)}}},e.startWith=function(t,i){return t?t.substr(0,i.length)===i:!1},e.withContent=function(){return!!(this.consumer().sourcesContent&&this.consumer().sourcesContent.length>0)},n}(),Fg=Wl;Wl.default=Wl;var lE=tt.SourceMapConsumer,dE=tt.SourceMapGenerator,Bg=tt.fileURLToPath,da=tt.pathToFileURL,Gl=tt.isAbsolute,$l=tt.resolve,hE=oE.nanoid,Hl=tt,jg=Ul,pE=Fg,Kl=Symbol("fromOffsetCache"),fE=!!(lE&&dE),Vg=!!($l&&Gl),ha=function(){function n(t,i){if(i===void 0&&(i={}),t===null||typeof t>"u"||(typeof t>"u"?"undefined":oe(t))==="object"&&!t.toString)throw new Error("PostCSS received "+t+" instead of CSS string");if(this.css=t.toString(),this.css[0]==="\uFEFF"||this.css[0]==="\uFFFE"?(this.hasBOM=!0,this.css=this.css.slice(1)):this.hasBOM=!1,i.from&&(!Vg||/^\w+:\/\//.test(i.from)||Gl(i.from)?this.file=i.from:this.file=$l(i.from)),Vg&&fE){var r=new pE(this.css,i);if(r.text){this.map=r;var o=r.consumer().file;!this.file&&o&&(this.file=this.mapResolve(o))}}this.file||(this.id="<input css "+hE(6)+">"),this.map&&(this.map.file=this.from)}var e=n.prototype;return e.error=function(t,i,r,o){o===void 0&&(o={});var s,a,c;if(i&&(typeof i>"u"?"undefined":oe(i))==="object"){var u=i,l=r;if(typeof u.offset=="number"){var d=this.fromOffset(u.offset);i=d.line,r=d.col}else i=u.line,r=u.column;if(typeof l.offset=="number"){var h=this.fromOffset(l.offset);a=h.line,c=h.col}else a=l.line,c=l.column}else if(!r){var p=this.fromOffset(i);i=p.line,r=p.col}var m=this.origin(i,r,a,c);return m?s=new jg(t,m.endLine===void 0?m.line:{column:m.column,line:m.line},m.endLine===void 0?m.column:{column:m.endColumn,line:m.endLine},m.source,m.file,o.plugin):s=new jg(t,a===void 0?i:{column:r,line:i},a===void 0?r:{column:c,line:a},this.css,this.file,o.plugin),s.input={column:r,endColumn:c,endLine:a,line:i,source:this.css},this.file&&(da&&(s.input.url=da(this.file).toString()),s.input.file=this.file),s},e.fromOffset=function(t){var i,r;if(this[Kl])r=this[Kl];else{var o=this.css.split(`
60
- `);r=new Array(o.length);for(var s=0,a=0,c=o.length;a<c;a++)r[a]=s,s+=o[a].length+1;this[Kl]=r}i=r[r.length-1];var u=0;if(t>=i)u=r.length-1;else for(var l=r.length-2,d;u<l;)if(d=u+(l-u>>1),t<r[d])l=d-1;else if(t>=r[d+1])u=d+1;else{u=d;break}return{col:t-r[u]+1,line:u+1}},e.mapResolve=function(t){return/^\w+:\/\//.test(t)?t:$l(this.map.consumer().sourceRoot||this.map.root||".",t)},e.origin=function(t,i,r,o){if(!this.map)return!1;var s=this.map.consumer(),a=s.originalPositionFor({column:i,line:t});if(!a.source)return!1;var c;typeof r=="number"&&(c=s.originalPositionFor({column:o,line:r}));var u;Gl(a.source)?u=da(a.source):u=new URL(a.source,this.map.consumer().sourceRoot||da(this.map.mapFile));var l={column:a.column,endColumn:c&&c.column,endLine:c&&c.line,line:a.line,url:u.toString()};if(u.protocol==="file:")if(Bg)l.file=Bg(u);else throw new Error("file: protocol is not available in this PostCSS build");var d=s.sourceContentFor(a.source);return d&&(l.source=d),l},e.toJSON=function(){for(var t={},i=0,r=["hasBOM","css","file","id"];i<r.length;i++){var o=r[i];this[o]!=null&&(t[o]=this[o])}return this.map&&(t.map=me({},this.map),t.map.consumerCache&&(t.map.consumerCache=void 0)),t},mt(n,[{key:"from",get:function(){return this.file||this.id}}]),n}(),pa=ha;ha.default=ha,Hl&&Hl.registerInput&&Hl.registerInput(ha);var zg=tt.SourceMapConsumer,fa=tt.SourceMapGenerator,ma=tt.dirname,qg=tt.relative,Wg=tt.resolve,Gg=tt.sep,$g=tt.pathToFileURL,mE=pa,gE=!!(zg&&fa),vE=!!(ma&&Wg&&qg&&Gg),yE=function(){function n(t,i,r,o){this.stringify=t,this.mapOpts=r.map||{},this.root=i,this.opts=r,this.css=o,this.originalCSS=o,this.usesFileUrls=!this.mapOpts.from&&this.mapOpts.absolute,this.memoizedFileURLs=new Map,this.memoizedPaths=new Map,this.memoizedURLs=new Map}var e=n.prototype;return e.addAnnotation=function(){var t;this.isInline()?t="data:application/json;base64,"+this.toBase64(this.map.toString()):typeof this.mapOpts.annotation=="string"?t=this.mapOpts.annotation:typeof this.mapOpts.annotation=="function"?t=this.mapOpts.annotation(this.opts.to,this.root):t=this.outputFile()+".map";var i=`
61
- `;this.css.includes(`\r
62
- `)&&(i=`\r
63
- `),this.css+=i+"/*# sourceMappingURL="+t+" */"},e.applyPrevMaps=function(){for(var t=H(this.previous()),i;!(i=t()).done;){var r=i.value,o=this.toUrl(this.path(r.file)),s=r.root||ma(r.file),a=void 0;this.mapOpts.sourcesContent===!1?(a=new zg(r.text),a.sourcesContent&&(a.sourcesContent=null)):a=r.consumer(),this.map.applySourceMap(a,o,this.toUrl(this.path(s)))}},e.clearAnnotation=function(){if(this.mapOpts.annotation!==!1)if(this.root)for(var t,i=this.root.nodes.length-1;i>=0;i--)t=this.root.nodes[i],t.type==="comment"&&t.text.indexOf("# sourceMappingURL=")===0&&this.root.removeChild(i);else this.css&&(this.css=this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm,""))},e.generate=function(){if(this.clearAnnotation(),vE&&gE&&this.isMap())return this.generateMap();var t="";return this.stringify(this.root,function(i){t+=i}),[t]},e.generateMap=function(){if(this.root)this.generateString();else if(this.previous().length===1){var t=this.previous()[0].consumer();t.file=this.outputFile(),this.map=fa.fromSourceMap(t,{ignoreInvalidMapping:!0})}else this.map=new fa({file:this.outputFile(),ignoreInvalidMapping:!0}),this.map.addMapping({generated:{column:0,line:1},original:{column:0,line:1},source:this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>"});return this.isSourcesContent()&&this.setSourcesContent(),this.root&&this.previous().length>0&&this.applyPrevMaps(),this.isAnnotation()&&this.addAnnotation(),this.isInline()?[this.css]:[this.css,this.map]},e.generateString=function(){var t=this;this.css="",this.map=new fa({file:this.outputFile(),ignoreInvalidMapping:!0});var i=1,r=1,o="<no source>",s={generated:{column:0,line:0},original:{column:0,line:0},source:""},a,c;this.stringify(this.root,function(u,l,d){if(t.css+=u,l&&d!=="end"&&(s.generated.line=i,s.generated.column=r-1,l.source&&l.source.start?(s.source=t.sourcePath(l),s.original.line=l.source.start.line,s.original.column=l.source.start.column-1,t.map.addMapping(s)):(s.source=o,s.original.line=1,s.original.column=0,t.map.addMapping(s))),a=u.match(/\n/g),a?(i+=a.length,c=u.lastIndexOf(`
64
- `),r=u.length-c):r+=u.length,l&&d!=="start"){var h=l.parent||{raws:{}},p=l.type==="decl"||l.type==="atrule"&&!l.nodes;(!p||l!==h.last||h.raws.semicolon)&&(l.source&&l.source.end?(s.source=t.sourcePath(l),s.original.line=l.source.end.line,s.original.column=l.source.end.column-1,s.generated.line=i,s.generated.column=r-2,t.map.addMapping(s)):(s.source=o,s.original.line=1,s.original.column=0,s.generated.line=i,s.generated.column=r-1,t.map.addMapping(s)))}})},e.isAnnotation=function(){return this.isInline()?!0:typeof this.mapOpts.annotation<"u"?this.mapOpts.annotation:this.previous().length?this.previous().some(function(t){return t.annotation}):!0},e.isInline=function(){if(typeof this.mapOpts.inline<"u")return this.mapOpts.inline;var t=this.mapOpts.annotation;return typeof t<"u"&&t!==!0?!1:this.previous().length?this.previous().some(function(i){return i.inline}):!0},e.isMap=function(){return typeof this.opts.map<"u"?!!this.opts.map:this.previous().length>0},e.isSourcesContent=function(){return typeof this.mapOpts.sourcesContent<"u"?this.mapOpts.sourcesContent:this.previous().length?this.previous().some(function(t){return t.withContent()}):!0},e.outputFile=function(){return this.opts.to?this.path(this.opts.to):this.opts.from?this.path(this.opts.from):"to.css"},e.path=function(t){if(this.mapOpts.absolute||t.charCodeAt(0)===60||/^\w+:\/\//.test(t))return t;var i=this.memoizedPaths.get(t);if(i)return i;var r=this.opts.to?ma(this.opts.to):".";typeof this.mapOpts.annotation=="string"&&(r=ma(Wg(r,this.mapOpts.annotation)));var o=qg(r,t);return this.memoizedPaths.set(t,o),o},e.previous=function(){var t=this;if(!this.previousMaps)if(this.previousMaps=[],this.root)this.root.walk(function(r){if(r.source&&r.source.input.map){var o=r.source.input.map;t.previousMaps.includes(o)||t.previousMaps.push(o)}});else{var i=new mE(this.originalCSS,this.opts);i.map&&this.previousMaps.push(i.map)}return this.previousMaps},e.setSourcesContent=function(){var t=this,i={};if(this.root)this.root.walk(function(o){if(o.source){var s=o.source.input.from;if(s&&!i[s]){i[s]=!0;var a=t.usesFileUrls?t.toFileUrl(s):t.toUrl(t.path(s));t.map.setSourceContent(a,o.source.input.css)}}});else if(this.css){var r=this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>";this.map.setSourceContent(r,this.css)}},e.sourcePath=function(t){return this.mapOpts.from?this.toUrl(this.mapOpts.from):this.usesFileUrls?this.toFileUrl(t.source.input.from):this.toUrl(this.path(t.source.input.from))},e.toBase64=function(t){return Buffer?Buffer.from(t).toString("base64"):window.btoa(unescape(encodeURIComponent(t)))},e.toFileUrl=function(t){var i=this.memoizedFileURLs.get(t);if(i)return i;if($g){var r=$g(t).toString();return this.memoizedFileURLs.set(t,r),r}else throw new Error("`map.absolute` option is not available in this PostCSS build")},e.toUrl=function(t){var i=this.memoizedURLs.get(t);if(i)return i;Gg==="\\"&&(t=t.replace(/\\/g,"/"));var r=encodeURI(t).replace(/[#?]/g,encodeURIComponent);return this.memoizedURLs.set(t,r),r},n}(),Hg=yE,bE=ua,Yl=function(n){wt(e,n);function e(t){var i;return i=n.call(this,t)||this,i.type="comment",i}return e}(bE),ga=Yl;Yl.default=Yl;var Kg=ii.isClean,Yg=ii.my,Xg=la,Jg=ga,_E=ua,Zg,Xl,Jl,Qg;function ev(n){return n.map(function(e){return e.nodes&&(e.nodes=ev(e.nodes)),delete e.source,e})}function tv(n){if(n[Kg]=!1,n.proxyOf.nodes)for(var e=H(n.proxyOf.nodes),t;!(t=e()).done;){var i=t.value;tv(i)}}var Bn=function(n){wt(e,n);function e(){return n.apply(this,arguments)||this}var t=e.prototype;return t.append=function(){for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];for(var s=H(r),a;!(a=s()).done;)for(var c=a.value,u=this.normalize(c,this.last),l=H(u),d;!(d=l()).done;){var h=d.value;this.proxyOf.nodes.push(h)}return this.markDirty(),this},t.cleanRaws=function(i){if(n.prototype.cleanRaws.call(this,i),this.nodes)for(var r=H(this.nodes),o;!(o=r()).done;){var s=o.value;s.cleanRaws(i)}},t.each=function(i){if(this.proxyOf.nodes){for(var r=this.getIterator(),o,s;this.indexes[r]<this.proxyOf.nodes.length&&(o=this.indexes[r],s=i(this.proxyOf.nodes[o],o),s!==!1);)this.indexes[r]+=1;return delete this.indexes[r],s}},t.every=function(i){return this.nodes.every(i)},t.getIterator=function(){this.lastEach||(this.lastEach=0),this.indexes||(this.indexes={}),this.lastEach+=1;var i=this.lastEach;return this.indexes[i]=0,i},t.getProxyProcessor=function(){return{get:function(i,r){return r==="proxyOf"?i:i[r]?r==="each"||typeof r=="string"&&r.startsWith("walk")?function(){for(var o=arguments.length,s=new Array(o),a=0;a<o;a++)s[a]=arguments[a];var c;return(c=i)[r].apply(c,[].concat(s.map(function(u){return typeof u=="function"?function(l,d){return u(l.toProxy(),d)}:u})))}:r==="every"||r==="some"?function(o){return i[r](function(s){for(var a=arguments.length,c=new Array(a>1?a-1:0),u=1;u<a;u++)c[u-1]=arguments[u];return o.apply(void 0,[].concat([s.toProxy()],c))})}:r==="root"?function(){return i.root().toProxy()}:r==="nodes"?i.nodes.map(function(o){return o.toProxy()}):r==="first"||r==="last"?i[r].toProxy():i[r]:i[r]},set:function(i,r,o){return i[r]===o||(i[r]=o,(r==="name"||r==="params"||r==="selector")&&i.markDirty()),!0}}},t.index=function(i){return typeof i=="number"?i:(i.proxyOf&&(i=i.proxyOf),this.proxyOf.nodes.indexOf(i))},t.insertAfter=function(i,r){var o=this.index(i),s=this.normalize(r,this.proxyOf.nodes[o]).reverse();o=this.index(i);for(var a=H(s),c;!(c=a()).done;){var u=c.value;this.proxyOf.nodes.splice(o+1,0,u)}var l;for(var d in this.indexes)l=this.indexes[d],o<l&&(this.indexes[d]=l+s.length);return this.markDirty(),this},t.insertBefore=function(i,r){var o=this.index(i),s=o===0?"prepend":!1,a=this.normalize(r,this.proxyOf.nodes[o],s).reverse();o=this.index(i);for(var c=H(a),u;!(u=c()).done;){var l=u.value;this.proxyOf.nodes.splice(o,0,l)}var d;for(var h in this.indexes)d=this.indexes[h],o<=d&&(this.indexes[h]=d+a.length);return this.markDirty(),this},t.normalize=function(i,r){var o=this;if(typeof i=="string")i=ev(Zg(i).nodes);else if(typeof i>"u")i=[];else if(Array.isArray(i)){i=i.slice(0);for(var s=H(i),a;!(a=s()).done;){var c=a.value;c.parent&&c.parent.removeChild(c,"ignore")}}else if(i.type==="root"&&this.type!=="document"){i=i.nodes.slice(0);for(var u=H(i),l;!(l=u()).done;){var d=l.value;d.parent&&d.parent.removeChild(d,"ignore")}}else if(i.type)i=[i];else if(i.prop){if(typeof i.value>"u")throw new Error("Value field is missed in node creation");typeof i.value!="string"&&(i.value=String(i.value)),i=[new Xg(i)]}else if(i.selector)i=[new Xl(i)];else if(i.name)i=[new Jl(i)];else if(i.text)i=[new Jg(i)];else throw new Error("Unknown node type in node creation");var h=i.map(function(p){return p[Yg]||e.rebuild(p),p=p.proxyOf,p.parent&&p.parent.removeChild(p),p[Kg]&&tv(p),typeof p.raws.before>"u"&&r&&typeof r.raws.before<"u"&&(p.raws.before=r.raws.before.replace(/\S/g,"")),p.parent=o.proxyOf,p});return h},t.prepend=function(){for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];r=r.reverse();for(var s=H(r),a;!(a=s()).done;){for(var c=a.value,u=this.normalize(c,this.first,"prepend").reverse(),l=H(u),d;!(d=l()).done;){var h=d.value;this.proxyOf.nodes.unshift(h)}for(var p in this.indexes)this.indexes[p]=this.indexes[p]+u.length}return this.markDirty(),this},t.push=function(i){return i.parent=this,this.proxyOf.nodes.push(i),this},t.removeAll=function(){for(var i=H(this.proxyOf.nodes),r;!(r=i()).done;){var o=r.value;o.parent=void 0}return this.proxyOf.nodes=[],this.markDirty(),this},t.removeChild=function(i){i=this.index(i),this.proxyOf.nodes[i].parent=void 0,this.proxyOf.nodes.splice(i,1);var r;for(var o in this.indexes)r=this.indexes[o],r>=i&&(this.indexes[o]=r-1);return this.markDirty(),this},t.replaceValues=function(i,r,o){return o||(o=r,r={}),this.walkDecls(function(s){r.props&&!r.props.includes(s.prop)||r.fast&&!s.value.includes(r.fast)||(s.value=s.value.replace(i,o))}),this.markDirty(),this},t.some=function(i){return this.nodes.some(i)},t.walk=function(i){return this.each(function(r,o){var s;try{s=i(r,o)}catch(a){throw r.addToError(a)}return s!==!1&&r.walk&&(s=r.walk(i)),s})},t.walkAtRules=function(i,r){return r?ne(i,RegExp)?this.walk(function(o,s){if(o.type==="atrule"&&i.test(o.name))return r(o,s)}):this.walk(function(o,s){if(o.type==="atrule"&&o.name===i)return r(o,s)}):(r=i,this.walk(function(o,s){if(o.type==="atrule")return r(o,s)}))},t.walkComments=function(i){return this.walk(function(r,o){if(r.type==="comment")return i(r,o)})},t.walkDecls=function(i,r){return r?ne(i,RegExp)?this.walk(function(o,s){if(o.type==="decl"&&i.test(o.prop))return r(o,s)}):this.walk(function(o,s){if(o.type==="decl"&&o.prop===i)return r(o,s)}):(r=i,this.walk(function(o,s){if(o.type==="decl")return r(o,s)}))},t.walkRules=function(i,r){return r?ne(i,RegExp)?this.walk(function(o,s){if(o.type==="rule"&&i.test(o.selector))return r(o,s)}):this.walk(function(o,s){if(o.type==="rule"&&o.selector===i)return r(o,s)}):(r=i,this.walk(function(o,s){if(o.type==="rule")return r(o,s)}))},mt(e,[{key:"first",get:function(){if(this.proxyOf.nodes)return this.proxyOf.nodes[0]}},{key:"last",get:function(){if(this.proxyOf.nodes)return this.proxyOf.nodes[this.proxyOf.nodes.length-1]}}]),e}(_E);Bn.registerParse=function(n){Zg=n},Bn.registerRule=function(n){Xl=n},Bn.registerAtRule=function(n){Jl=n},Bn.registerRoot=function(n){Qg=n};var zi=Bn;Bn.default=Bn,Bn.rebuild=function(n){n.type==="atrule"?Object.setPrototypeOf(n,Jl.prototype):n.type==="rule"?Object.setPrototypeOf(n,Xl.prototype):n.type==="decl"?Object.setPrototypeOf(n,Xg.prototype):n.type==="comment"?Object.setPrototypeOf(n,Jg.prototype):n.type==="root"&&Object.setPrototypeOf(n,Qg.prototype),n[Yg]=!0,n.nodes&&n.nodes.forEach(function(e){Bn.rebuild(e)})};var kE=zi,nv,iv,Mo=function(n){wt(e,n);function e(i){var r;return r=n.call(this,me({type:"document"},i))||this,r.nodes||(r.nodes=[]),r}var t=e.prototype;return t.toResult=function(i){i===void 0&&(i={});var r=new nv(new iv,this,i);return r.stringify()},e}(kE);Mo.registerLazyResult=function(n){nv=n},Mo.registerProcessor=function(n){iv=n};var Zl=Mo;Mo.default=Mo;var rv={},ov=function(n){rv[n]||(rv[n]=!0,typeof console<"u"&&console.warn&&console.warn(n))},Ql=function(){function n(t,i){if(i===void 0&&(i={}),this.type="warning",this.text=t,i.node&&i.node.source){var r=i.node.rangeBy(i);this.line=r.start.line,this.column=r.start.column,this.endLine=r.end.line,this.endColumn=r.end.column}for(var o in i)this[o]=i[o]}var e=n.prototype;return e.toString=function(){return this.node?this.node.error(this.text,{index:this.index,plugin:this.plugin,word:this.word}).message:this.plugin?this.plugin+": "+this.text:this.text},n}(),sv=Ql;Ql.default=Ql;var SE=sv,ed=function(){function n(t,i,r){this.processor=t,this.messages=[],this.root=i,this.opts=r,this.css=void 0,this.map=void 0}var e=n.prototype;return e.toString=function(){return this.css},e.warn=function(t,i){i===void 0&&(i={}),i.plugin||this.lastPlugin&&this.lastPlugin.postcssPlugin&&(i.plugin=this.lastPlugin.postcssPlugin);var r=new SE(t,i);return this.messages.push(r),r},e.warnings=function(){return this.messages.filter(function(t){return t.type==="warning"})},mt(n,[{key:"content",get:function(){return this.css}}]),n}(),td=ed;ed.default=ed;var nd="'".charCodeAt(0),av='"'.charCodeAt(0),va="\\".charCodeAt(0),cv="/".charCodeAt(0),ya=`
65
- `.charCodeAt(0),No=" ".charCodeAt(0),ba="\f".charCodeAt(0),_a=" ".charCodeAt(0),ka="\r".charCodeAt(0),wE="[".charCodeAt(0),CE="]".charCodeAt(0),TE="(".charCodeAt(0),xE=")".charCodeAt(0),EE="{".charCodeAt(0),IE="}".charCodeAt(0),RE=";".charCodeAt(0),PE="*".charCodeAt(0),OE=":".charCodeAt(0),AE="@".charCodeAt(0),Sa=/[\t\n\f\r "#'()/;[\\\]{}]/g,wa=/[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,ME=/.[\r\n"'(/\\]/,uv=/[\da-f]/i,NE=function(n,e){e===void 0&&(e={});var t=n.css.valueOf(),i=e.ignoreErrors,r,o,s,a,c,u,l,d,h,p,m=t.length,f=0,g=[],y=[];function b(){return f}function S(x){throw n.error("Unclosed "+x,f)}function w(){return y.length===0&&f>=m}function k(x){if(y.length)return y.pop();if(!(f>=m)){var I=x?x.ignoreUnclosed:!1;switch(r=t.charCodeAt(f),r){case ya:case No:case _a:case ka:case ba:{o=f;do o+=1,r=t.charCodeAt(o);while(r===No||r===ya||r===_a||r===ka||r===ba);p=["space",t.slice(f,o)],f=o-1;break}case wE:case CE:case EE:case IE:case OE:case RE:case xE:{var P=String.fromCharCode(r);p=[P,P,f];break}case TE:{if(d=g.length?g.pop()[1]:"",h=t.charCodeAt(f+1),d==="url"&&h!==nd&&h!==av&&h!==No&&h!==ya&&h!==_a&&h!==ba&&h!==ka){o=f;do{if(u=!1,o=t.indexOf(")",o+1),o===-1)if(i||I){o=f;break}else S("bracket");for(l=o;t.charCodeAt(l-1)===va;)l-=1,u=!u}while(u);p=["brackets",t.slice(f,o+1),f,o],f=o}else o=t.indexOf(")",f+1),a=t.slice(f,o+1),o===-1||ME.test(a)?p=["(","(",f]:(p=["brackets",a,f,o],f=o);break}case nd:case av:{s=r===nd?"'":'"',o=f;do{if(u=!1,o=t.indexOf(s,o+1),o===-1)if(i||I){o=f+1;break}else S("string");for(l=o;t.charCodeAt(l-1)===va;)l-=1,u=!u}while(u);p=["string",t.slice(f,o+1),f,o],f=o;break}case AE:{Sa.lastIndex=f+1,Sa.test(t),Sa.lastIndex===0?o=t.length-1:o=Sa.lastIndex-2,p=["at-word",t.slice(f,o+1),f,o],f=o;break}case va:{for(o=f,c=!0;t.charCodeAt(o+1)===va;)o+=1,c=!c;if(r=t.charCodeAt(o+1),c&&r!==cv&&r!==No&&r!==ya&&r!==_a&&r!==ka&&r!==ba&&(o+=1,uv.test(t.charAt(o)))){for(;uv.test(t.charAt(o+1));)o+=1;t.charCodeAt(o+1)===No&&(o+=1)}p=["word",t.slice(f,o+1),f,o],f=o;break}default:{r===cv&&t.charCodeAt(f+1)===PE?(o=t.indexOf("*/",f+2)+1,o===0&&(i||I?o=t.length:S("comment")),p=["comment",t.slice(f,o+1),f,o],f=o):(wa.lastIndex=f+1,wa.test(t),wa.lastIndex===0?o=t.length-1:o=wa.lastIndex-2,p=["word",t.slice(f,o+1),f,o],g.push(p),f=o);break}}return f++,p}}function C(x){y.push(x)}return{back:C,endOfFile:w,nextToken:k,position:b}},lv=zi,Ca=function(n){wt(e,n);function e(i){var r;return r=n.call(this,i)||this,r.type="atrule",r}var t=e.prototype;return t.append=function(){for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];var s;return this.proxyOf.nodes||(this.nodes=[]),(s=n.prototype.append).call.apply(s,[].concat([this],r))},t.prepend=function(){for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];var s;return this.proxyOf.nodes||(this.nodes=[]),(s=n.prototype.prepend).call.apply(s,[].concat([this],r))},e}(lv),id=Ca;Ca.default=Ca,lv.registerAtRule(Ca);var dv=zi,hv,pv,Tr=function(n){wt(e,n);function e(i){var r;return r=n.call(this,i)||this,r.type="root",r.nodes||(r.nodes=[]),r}var t=e.prototype;return t.normalize=function(i,r,o){var s=n.prototype.normalize.call(this,i);if(r){if(o==="prepend")this.nodes.length>1?r.raws.before=this.nodes[1].raws.before:delete r.raws.before;else if(this.first!==r)for(var a=H(s),c;!(c=a()).done;){var u=c.value;u.raws.before=r.raws.before}}return s},t.removeChild=function(i,r){var o=this.index(i);return!r&&o===0&&this.nodes.length>1&&(this.nodes[1].raws.before=this.nodes[o].raws.before),n.prototype.removeChild.call(this,i)},t.toResult=function(i){i===void 0&&(i={});var r=new hv(new pv,this,i);return r.stringify()},e}(dv);Tr.registerLazyResult=function(n){hv=n},Tr.registerProcessor=function(n){pv=n};var Do=Tr;Tr.default=Tr,dv.registerRoot(Tr);var Lo={comma:function(n){return Lo.split(n,[","],!0)},space:function(n){var e=[" ",`
66
- `," "];return Lo.split(n,e)},split:function(n,e,t){for(var i=[],r="",o=!1,s=0,a=!1,c="",u=!1,l=H(n),d;!(d=l()).done;){var h=d.value;u?u=!1:h==="\\"?u=!0:a?h===c&&(a=!1):h==='"'||h==="'"?(a=!0,c=h):h==="("?s+=1:h===")"?s>0&&(s-=1):s===0&&e.includes(h)&&(o=!0),o?(r!==""&&i.push(r.trim()),r="",o=!1):r+=h}return(t||r!=="")&&i.push(r.trim()),i}},fv=Lo;Lo.default=Lo;var mv=zi,DE=fv,Ta=function(n){wt(e,n);function e(t){var i;return i=n.call(this,t)||this,i.type="rule",i.nodes||(i.nodes=[]),i}return mt(e,[{key:"selectors",get:function(){return DE.comma(this.selector)},set:function(t){var i=this.selector?this.selector.match(/,\s*/):null,r=i?i[0]:","+this.raw("between","beforeOpen");this.selector=t.join(r)}}]),e}(mv),rd=Ta;Ta.default=Ta,mv.registerRule(Ta);var LE=la,UE=NE,FE=ga,BE=id,jE=Do,gv=rd,vv={empty:!0,space:!0};function VE(n){for(var e=n.length-1;e>=0;e--){var t=n[e],i=t[3]||t[2];if(i)return i}}var zE=function(){function n(t){this.input=t,this.root=new jE,this.current=this.root,this.spaces="",this.semicolon=!1,this.createTokenizer(),this.root.source={input:t,start:{column:1,line:1,offset:0}}}var e=n.prototype;return e.atrule=function(t){var i=new BE;i.name=t[1].slice(1),i.name===""&&this.unnamedAtrule(i,t),this.init(i,t[2]);for(var r,o,s,a=!1,c=!1,u=[],l=[];!this.tokenizer.endOfFile();){if(t=this.tokenizer.nextToken(),r=t[0],r==="("||r==="["?l.push(r==="("?")":"]"):r==="{"&&l.length>0?l.push("}"):r===l[l.length-1]&&l.pop(),l.length===0)if(r===";"){i.source.end=this.getPosition(t[2]),i.source.end.offset++,this.semicolon=!0;break}else if(r==="{"){c=!0;break}else if(r==="}"){if(u.length>0){for(s=u.length-1,o=u[s];o&&o[0]==="space";)o=u[--s];o&&(i.source.end=this.getPosition(o[3]||o[2]),i.source.end.offset++)}this.end(t);break}else u.push(t);else u.push(t);if(this.tokenizer.endOfFile()){a=!0;break}}i.raws.between=this.spacesAndCommentsFromEnd(u),u.length?(i.raws.afterName=this.spacesAndCommentsFromStart(u),this.raw(i,"params",u),a&&(t=u[u.length-1],i.source.end=this.getPosition(t[3]||t[2]),i.source.end.offset++,this.spaces=i.raws.between,i.raws.between="")):(i.raws.afterName="",i.params=""),c&&(i.nodes=[],this.current=i)},e.checkMissedSemicolon=function(t){var i=this.colon(t);if(i!==!1){for(var r=0,o,s=i-1;s>=0&&(o=t[s],!(o[0]!=="space"&&(r+=1,r===2)));s--);throw this.input.error("Missed semicolon",o[0]==="word"?o[3]+1:o[2])}},e.colon=function(t){for(var i=0,r,o,s,a=H(t.entries()),c;!(c=a()).done;){var u=c.value,l=u[0],d=u[1];if(r=d,o=r[0],o==="("&&(i+=1),o===")"&&(i-=1),i===0&&o===":")if(!s)this.doubleColon(r);else{if(s[0]==="word"&&s[1]==="progid")continue;return l}s=r}return!1},e.comment=function(t){var i=new FE;this.init(i,t[2]),i.source.end=this.getPosition(t[3]||t[2]),i.source.end.offset++;var r=t[1].slice(2,-2);if(/^\s*$/.test(r))i.text="",i.raws.left=r,i.raws.right="";else{var o=r.match(/^(\s*)([^]*\S)(\s*)$/);i.text=o[2],i.raws.left=o[1],i.raws.right=o[3]}},e.createTokenizer=function(){this.tokenizer=UE(this.input)},e.decl=function(t,i){var r=new LE;this.init(r,t[0][2]);var o=t[t.length-1];for(o[0]===";"&&(this.semicolon=!0,t.pop()),r.source.end=this.getPosition(o[3]||o[2]||VE(t)),r.source.end.offset++;t[0][0]!=="word";)t.length===1&&this.unknownWord(t),r.raws.before+=t.shift()[1];for(r.source.start=this.getPosition(t[0][2]),r.prop="";t.length;){var s=t[0][0];if(s===":"||s==="space"||s==="comment")break;r.prop+=t.shift()[1]}r.raws.between="";for(var a;t.length;)if(a=t.shift(),a[0]===":"){r.raws.between+=a[1];break}else a[0]==="word"&&/\w/.test(a[1])&&this.unknownWord([a]),r.raws.between+=a[1];(r.prop[0]==="_"||r.prop[0]==="*")&&(r.raws.before+=r.prop[0],r.prop=r.prop.slice(1));for(var c=[],u;t.length&&(u=t[0][0],!(u!=="space"&&u!=="comment"));)c.push(t.shift());this.precheckMissedSemicolon(t);for(var l=t.length-1;l>=0;l--){if(a=t[l],a[1].toLowerCase()==="!important"){r.important=!0;var d=this.stringFrom(t,l);d=this.spacesFromEnd(t)+d,d!==" !important"&&(r.raws.important=d);break}else if(a[1].toLowerCase()==="important"){for(var h=t.slice(0),p="",m=l;m>0;m--){var f=h[m][0];if(p.trim().indexOf("!")===0&&f!=="space")break;p=h.pop()[1]+p}p.trim().indexOf("!")===0&&(r.important=!0,r.raws.important=p,t=h)}if(a[0]!=="space"&&a[0]!=="comment")break}var g=t.some(function(y){return y[0]!=="space"&&y[0]!=="comment"});g&&(r.raws.between+=c.map(function(y){return y[1]}).join(""),c=[]),this.raw(r,"value",c.concat(t),i),r.value.includes(":")&&!i&&this.checkMissedSemicolon(t)},e.doubleColon=function(t){throw this.input.error("Double colon",{offset:t[2]},{offset:t[2]+t[1].length})},e.emptyRule=function(t){var i=new gv;this.init(i,t[2]),i.selector="",i.raws.between="",this.current=i},e.end=function(t){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.spaces="",this.current.parent?(this.current.source.end=this.getPosition(t[2]),this.current.source.end.offset++,this.current=this.current.parent):this.unexpectedClose(t)},e.endFile=function(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.root.source.end=this.getPosition(this.tokenizer.position())},e.freeSemicolon=function(t){if(this.spaces+=t[1],this.current.nodes){var i=this.current.nodes[this.current.nodes.length-1];i&&i.type==="rule"&&!i.raws.ownSemicolon&&(i.raws.ownSemicolon=this.spaces,this.spaces="")}},e.getPosition=function(t){var i=this.input.fromOffset(t);return{column:i.col,line:i.line,offset:t}},e.init=function(t,i){this.current.push(t),t.source={input:this.input,start:this.getPosition(i)},t.raws.before=this.spaces,this.spaces="",t.type!=="comment"&&(this.semicolon=!1)},e.other=function(t){for(var i=!1,r=null,o=!1,s=null,a=[],c=t[1].startsWith("--"),u=[],l=t;l;){if(r=l[0],u.push(l),r==="("||r==="[")s||(s=l),a.push(r==="("?")":"]");else if(c&&o&&r==="{")s||(s=l),a.push("}");else if(a.length===0)if(r===";")if(o){this.decl(u,c);return}else break;else if(r==="{"){this.rule(u);return}else if(r==="}"){this.tokenizer.back(u.pop()),i=!0;break}else r===":"&&(o=!0);else r===a[a.length-1]&&(a.pop(),a.length===0&&(s=null));l=this.tokenizer.nextToken()}if(this.tokenizer.endOfFile()&&(i=!0),a.length>0&&this.unclosedBracket(s),i&&o){if(!c)for(;u.length&&(l=u[u.length-1][0],!(l!=="space"&&l!=="comment"));)this.tokenizer.back(u.pop());this.decl(u,c)}else this.unknownWord(u)},e.parse=function(){for(var t;!this.tokenizer.endOfFile();)switch(t=this.tokenizer.nextToken(),t[0]){case"space":this.spaces+=t[1];break;case";":this.freeSemicolon(t);break;case"}":this.end(t);break;case"comment":this.comment(t);break;case"at-word":this.atrule(t);break;case"{":this.emptyRule(t);break;default:this.other(t);break}this.endFile()},e.precheckMissedSemicolon=function(){},e.raw=function(t,i,r,o){for(var s,a,c=r.length,u="",l=!0,d,h,p=0;p<c;p+=1)s=r[p],a=s[0],a==="space"&&p===c-1&&!o?l=!1:a==="comment"?(h=r[p-1]?r[p-1][0]:"empty",d=r[p+1]?r[p+1][0]:"empty",!vv[h]&&!vv[d]?u.slice(-1)===","?l=!1:u+=s[1]:l=!1):u+=s[1];if(!l){var m=r.reduce(function(f,g){return f+g[1]},"");t.raws[i]={raw:m,value:u}}t[i]=u},e.rule=function(t){t.pop();var i=new gv;this.init(i,t[0][2]),i.raws.between=this.spacesAndCommentsFromEnd(t),this.raw(i,"selector",t),this.current=i},e.spacesAndCommentsFromEnd=function(t){for(var i,r="";t.length&&(i=t[t.length-1][0],!(i!=="space"&&i!=="comment"));)r=t.pop()[1]+r;return r},e.spacesAndCommentsFromStart=function(t){for(var i,r="";t.length&&(i=t[0][0],!(i!=="space"&&i!=="comment"));)r+=t.shift()[1];return r},e.spacesFromEnd=function(t){for(var i,r="";t.length&&(i=t[t.length-1][0],i==="space");)r=t.pop()[1]+r;return r},e.stringFrom=function(t,i){for(var r="",o=i;o<t.length;o++)r+=t[o][1];return t.splice(i,t.length-i),r},e.unclosedBlock=function(){var t=this.current.source.start;throw this.input.error("Unclosed block",t.line,t.column)},e.unclosedBracket=function(t){throw this.input.error("Unclosed bracket",{offset:t[2]},{offset:t[2]+1})},e.unexpectedClose=function(t){throw this.input.error("Unexpected }",{offset:t[2]},{offset:t[2]+1})},e.unknownWord=function(t){throw this.input.error("Unknown word",{offset:t[0][2]},{offset:t[0][2]+t[0][1].length})},e.unnamedAtrule=function(t,i){throw this.input.error("At-rule without name",{offset:i[2]},{offset:i[2]+i[1].length})},n}(),qE=zE,WE=zi,GE=qE,$E=pa;function xa(n,e){var t=new $E(n,e),i=new GE(t);try{i.parse()}catch(r){throw process.env.NODE_ENV!=="production"&&r.name==="CssSyntaxError"&&e&&e.from&&(/\.scss$/i.test(e.from)?r.message+=`
67
- You tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser`:/\.sass/i.test(e.from)?r.message+=`
68
- You tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser`:/\.less$/i.test(e.from)&&(r.message+=`
69
- You tried to parse Less with the standard CSS parser; try again with the postcss-less parser`)),r}return i.root}var od=xa;xa.default=xa,WE.registerParse(xa);var kn=ii.isClean,HE=ii.my,KE=Hg,YE=aa,XE=zi,JE=Zl,ZE=ov,yv=td,QE=od,eI=Do,tI={atrule:"AtRule",comment:"Comment",decl:"Declaration",document:"Document",root:"Root",rule:"Rule"},nI={AtRule:!0,AtRuleExit:!0,Comment:!0,CommentExit:!0,Declaration:!0,DeclarationExit:!0,Document:!0,DocumentExit:!0,Once:!0,OnceExit:!0,postcssPlugin:!0,prepare:!0,Root:!0,RootExit:!0,Rule:!0,RuleExit:!0},iI={Once:!0,postcssPlugin:!0,prepare:!0},xr=0;function Uo(n){return(typeof n>"u"?"undefined":oe(n))==="object"&&typeof n.then=="function"}function bv(n){var e=!1,t=tI[n.type];return n.type==="decl"?e=n.prop.toLowerCase():n.type==="atrule"&&(e=n.name.toLowerCase()),e&&n.append?[t,t+"-"+e,xr,t+"Exit",t+"Exit-"+e]:e?[t,t+"-"+e,t+"Exit",t+"Exit-"+e]:n.append?[t,xr,t+"Exit"]:[t,t+"Exit"]}function _v(n){var e;return n.type==="document"?e=["Document",xr,"DocumentExit"]:n.type==="root"?e=["Root",xr,"RootExit"]:e=bv(n),{eventIndex:0,events:e,iterator:0,node:n,visitorIndex:0,visitors:[]}}function sd(n){return n[kn]=!1,n.nodes&&n.nodes.forEach(function(e){return sd(e)}),n}var ad={},Er=function(){function n(t,i,r){var o=this;this.stringified=!1,this.processed=!1;var s;if((typeof i>"u"?"undefined":oe(i))==="object"&&i!==null&&(i.type==="root"||i.type==="document"))s=sd(i);else if(ne(i,n)||ne(i,yv))s=sd(i.root),i.map&&(typeof r.map>"u"&&(r.map={}),r.map.inline||(r.map.inline=!1),r.map.prev=i.map);else{var a=QE;r.syntax&&(a=r.syntax.parse),r.parser&&(a=r.parser),a.parse&&(a=a.parse);try{s=a(i,r)}catch(c){this.processed=!0,this.error=c}s&&!s[HE]&&XE.rebuild(s)}this.result=new yv(t,s,r),this.helpers=me({},ad,{postcss:ad,result:this.result}),this.plugins=this.processor.plugins.map(function(c){return(typeof c>"u"?"undefined":oe(c))==="object"&&c.prepare?me({},c,c.prepare(o.result)):c})}var e=n.prototype;return e.async=function(){return this.error?Promise.reject(this.error):this.processed?Promise.resolve(this.result):(this.processing||(this.processing=this.runAsync()),this.processing)},e.catch=function(t){return this.async().catch(t)},e.finally=function(t){return this.async().then(t,t)},e.getAsyncError=function(){throw new Error("Use process(css).then(cb) to work with async plugins")},e.handleError=function(t,i){var r=this.result.lastPlugin;try{if(i&&i.addToError(t),this.error=t,t.name==="CssSyntaxError"&&!t.plugin)t.plugin=r.postcssPlugin,t.setMessage();else if(r.postcssVersion&&process.env.NODE_ENV!=="production"){var o=r.postcssPlugin,s=r.postcssVersion,a=this.result.processor.version,c=s.split("."),u=a.split(".");(c[0]!==u[0]||parseInt(c[1])>parseInt(u[1]))&&console.error("Unknown error from PostCSS plugin. Your current PostCSS version is "+a+", but "+o+" uses "+s+". Perhaps this is the source of the error below.")}}catch(l){console&&console.error&&console.error(l)}return t},e.prepareVisitors=function(){var t=this;this.listeners={};for(var i=function(u,l,d){t.listeners[l]||(t.listeners[l]=[]),t.listeners[l].push([u,d])},r=H(this.plugins),o;!(o=r()).done;){var s=o.value;if((typeof s>"u"?"undefined":oe(s))==="object")for(var a in s){if(!nI[a]&&/^[A-Z]/.test(a))throw new Error("Unknown event "+a+" in "+s.postcssPlugin+". Try to update PostCSS ("+this.processor.version+" now).");if(!iI[a])if(oe(s[a])==="object")for(var c in s[a])c==="*"?i(s,a,s[a][c]):i(s,a+"-"+c.toLowerCase(),s[a][c]);else typeof s[a]=="function"&&i(s,a,s[a])}}this.hasListener=Object.keys(this.listeners).length>0},e.runAsync=function(){var t=this;return Xu(function(){var i,r,o,s,a,c,u,l,d,h,p,m;return So(this,function(f){switch(f.label){case 0:t.plugin=0,i=0,f.label=1;case 1:if(!(i<t.plugins.length))return[3,6];if(r=t.plugins[i],o=t.runOnRoot(r),!Uo(o))return[3,5];f.label=2;case 2:return f.trys.push([2,4,,5]),[4,o];case 3:return f.sent(),[3,5];case 4:throw s=f.sent(),t.handleError(s);case 5:return i++,[3,1];case 6:if(t.prepareVisitors(),!t.hasListener)return[3,18];a=t.result.root,f.label=7;case 7:if(a[kn])return[3,14];a[kn]=!0,c=[_v(a)],f.label=8;case 8:if(!(c.length>0))return[3,13];if(u=t.visitTick(c),!Uo(u))return[3,12];f.label=9;case 9:return f.trys.push([9,11,,12]),[4,u];case 10:return f.sent(),[3,12];case 11:throw l=f.sent(),d=c[c.length-1].node,t.handleError(l,d);case 12:return[3,8];case 13:return[3,7];case 14:if(!t.listeners.OnceExit)return[3,18];h=function(){var g,y,b,S,w;return So(this,function(k){switch(k.label){case 0:g=m.value,y=g[0],b=g[1],t.result.lastPlugin=y,k.label=1;case 1:return k.trys.push([1,6,,7]),a.type!=="document"?[3,3]:(S=a.nodes.map(function(C){return b(C,t.helpers)}),[4,Promise.all(S)]);case 2:return k.sent(),[3,5];case 3:return[4,b(a,t.helpers)];case 4:k.sent(),k.label=5;case 5:return[3,7];case 6:throw w=k.sent(),t.handleError(w);case 7:return[2]}})},p=H(t.listeners.OnceExit),f.label=15;case 15:return(m=p()).done?[3,18]:[5,vm(h())];case 16:f.sent(),f.label=17;case 17:return[3,15];case 18:return t.processed=!0,[2,t.stringify()]}})})()},e.runOnRoot=function(t){var i=this;this.result.lastPlugin=t;try{if((typeof t>"u"?"undefined":oe(t))==="object"&&t.Once){if(this.result.root.type==="document"){var r=this.result.root.nodes.map(function(o){return t.Once(o,i.helpers)});return Uo(r[0])?Promise.all(r):r}return t.Once(this.result.root,this.helpers)}else if(typeof t=="function")return t(this.result.root,this.result)}catch(o){throw this.handleError(o)}},e.stringify=function(){if(this.error)throw this.error;if(this.stringified)return this.result;this.stringified=!0,this.sync();var t=this.result.opts,i=YE;t.syntax&&(i=t.syntax.stringify),t.stringifier&&(i=t.stringifier),i.stringify&&(i=i.stringify);var r=new KE(i,this.result.root,this.result.opts),o=r.generate();return this.result.css=o[0],this.result.map=o[1],this.result},e.sync=function(){if(this.error)throw this.error;if(this.processed)return this.result;if(this.processed=!0,this.processing)throw this.getAsyncError();for(var t=H(this.plugins),i;!(i=t()).done;){var r=i.value,o=this.runOnRoot(r);if(Uo(o))throw this.getAsyncError()}if(this.prepareVisitors(),this.hasListener){for(var s=this.result.root;!s[kn];)s[kn]=!0,this.walkSync(s);if(this.listeners.OnceExit)if(s.type==="document")for(var a=H(s.nodes),c;!(c=a()).done;){var u=c.value;this.visitSync(this.listeners.OnceExit,u)}else this.visitSync(this.listeners.OnceExit,s)}return this.result},e.then=function(t,i){return process.env.NODE_ENV!=="production"&&("from"in this.opts||ZE("Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.")),this.async().then(t,i)},e.toString=function(){return this.css},e.visitSync=function(t,i){for(var r=H(t),o;!(o=r()).done;){var s=o.value,a=s[0],c=s[1];this.result.lastPlugin=a;var u=void 0;try{u=c(i,this.helpers)}catch(l){throw this.handleError(l,i.proxyOf)}if(i.type!=="root"&&i.type!=="document"&&!i.parent)return!0;if(Uo(u))throw this.getAsyncError()}},e.visitTick=function(t){var i=t[t.length-1],r=i.node,o=i.visitors;if(r.type!=="root"&&r.type!=="document"&&!r.parent){t.pop();return}if(o.length>0&&i.visitorIndex<o.length){var s=o[i.visitorIndex],a=s[0],c=s[1];i.visitorIndex+=1,i.visitorIndex===o.length&&(i.visitors=[],i.visitorIndex=0),this.result.lastPlugin=a;try{return c(r.toProxy(),this.helpers)}catch(p){throw this.handleError(p,r)}}if(i.iterator!==0){for(var u=i.iterator,l;l=r.nodes[r.indexes[u]];)if(r.indexes[u]+=1,!l[kn]){l[kn]=!0,t.push(_v(l));return}i.iterator=0,delete r.indexes[u]}for(var d=i.events;i.eventIndex<d.length;){var h=d[i.eventIndex];if(i.eventIndex+=1,h===xr){r.nodes&&r.nodes.length&&(r[kn]=!0,i.iterator=r.getIterator());return}else if(this.listeners[h]){i.visitors=this.listeners[h];return}}t.pop()},e.walkSync=function(t){var i=this;t[kn]=!0;for(var r=bv(t),o=H(r),s;!(s=o()).done;){var a=s.value;if(a===xr)t.nodes&&t.each(function(u){u[kn]||i.walkSync(u)});else{var c=this.listeners[a];if(c&&this.visitSync(c,t.toProxy()))return}}},e.warnings=function(){return this.sync().warnings()},mt(n,[{key:"content",get:function(){return this.stringify().content}},{key:"css",get:function(){return this.stringify().css}},{key:"map",get:function(){return this.stringify().map}},{key:"messages",get:function(){return this.sync().messages}},{key:"opts",get:function(){return this.result.opts}},{key:"processor",get:function(){return this.result.processor}},{key:"root",get:function(){return this.sync().root}},{key:Symbol.toStringTag,get:function(){return"LazyResult"}}]),n}();Er.registerPostcss=function(n){ad=n};var kv=Er;Er.default=Er,eI.registerLazyResult(Er),JE.registerLazyResult(Er);var rI=Hg,oI=aa,sI=ov,aI=od,cI=td,cd=function(){function n(t,i,r){i=i.toString(),this.stringified=!1,this._processor=t,this._css=i,this._opts=r,this._map=void 0;var o,s=oI;this.result=new cI(this._processor,o,this._opts),this.result.css=i;var a=this;Object.defineProperty(this.result,"root",{get:function(){return a.root}});var c=new rI(s,o,this._opts,i);if(c.isMap()){var u=c.generate(),l=u[0],d=u[1];l&&(this.result.css=l),d&&(this.result.map=d)}else c.clearAnnotation(),this.result.css=c.css}var e=n.prototype;return e.async=function(){return this.error?Promise.reject(this.error):Promise.resolve(this.result)},e.catch=function(t){return this.async().catch(t)},e.finally=function(t){return this.async().then(t,t)},e.sync=function(){if(this.error)throw this.error;return this.result},e.then=function(t,i){return process.env.NODE_ENV!=="production"&&("from"in this._opts||sI("Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.")),this.async().then(t,i)},e.toString=function(){return this._css},e.warnings=function(){return[]},mt(n,[{key:"content",get:function(){return this.result.css}},{key:"css",get:function(){return this.result.css}},{key:"map",get:function(){return this.result.map}},{key:"messages",get:function(){return[]}},{key:"opts",get:function(){return this.result.opts}},{key:"processor",get:function(){return this.result.processor}},{key:"root",get:function(){if(this._root)return this._root;var t,i=aI;try{t=i(this._css,this._opts)}catch(r){this.error=r}if(this.error)throw this.error;return this._root=t,t}},{key:Symbol.toStringTag,get:function(){return"NoWorkResult"}}]),n}(),uI=cd;cd.default=cd;var lI=uI,dI=kv,hI=Zl,pI=Do,Fo=function(){function n(t){t===void 0&&(t=[]),this.version="8.4.38",this.plugins=this.normalize(t)}var e=n.prototype;return e.normalize=function(t){for(var i=[],r=H(t),o;!(o=r()).done;){var s=o.value;if(s.postcss===!0?s=s():s.postcss&&(s=s.postcss),(typeof s>"u"?"undefined":oe(s))==="object"&&Array.isArray(s.plugins))i=i.concat(s.plugins);else if((typeof s>"u"?"undefined":oe(s))==="object"&&s.postcssPlugin)i.push(s);else if(typeof s=="function")i.push(s);else if((typeof s>"u"?"undefined":oe(s))==="object"&&(s.parse||s.stringify)){if(process.env.NODE_ENV!=="production")throw new Error("PostCSS syntaxes cannot be used as plugins. Instead, please use one of the syntax/parser/stringifier options as outlined in your PostCSS runner documentation.")}else throw new Error(s+" is not a PostCSS plugin")}return i},e.process=function(t,i){return i===void 0&&(i={}),!this.plugins.length&&!i.parser&&!i.stringifier&&!i.syntax?new lI(this,t,i):new dI(this,t,i)},e.use=function(t){return this.plugins=this.plugins.concat(this.normalize([t])),this},n}(),fI=Fo;Fo.default=Fo,pI.registerProcessor(Fo),hI.registerProcessor(Fo);var mI=la,gI=Fg,vI=ga,yI=id,bI=pa,_I=Do,kI=rd;function Bo(n,e){if(Array.isArray(n))return n.map(function(d){return Bo(d)});var t=n.inputs,i=_o(n,["inputs"]);if(t){e=[];for(var r=H(t),o;!(o=r()).done;){var s=o.value,a=me({},s,{__proto__:bI.prototype});a.map&&(a.map=me({},a.map,{__proto__:gI.prototype})),e.push(a)}}if(i.nodes&&(i.nodes=n.nodes.map(function(d){return Bo(d,e)})),i.source){var c=i.source,u=c.inputId,l=_o(c,["inputId"]);i.source=l,u!=null&&(i.source.input=e[u])}if(i.type==="root")return new _I(i);if(i.type==="decl")return new mI(i);if(i.type==="rule")return new kI(i);if(i.type==="comment")return new vI(i);if(i.type==="atrule")return new yI(i);throw new Error("Unknown node type: "+n.type)}var SI=Bo;Bo.default=Bo;var wI=Ul,Sv=la,CI=kv,TI=zi,ud=fI,xI=aa,EI=SI,wv=Zl,II=sv,Cv=ga,Tv=id,RI=td,PI=pa,OI=od,AI=fv,xv=rd,Ev=Do,MI=ua;function xe(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];return e.length===1&&Array.isArray(e[0])&&(e=e[0]),new ud(e)}xe.plugin=function(n,e){var t=!1;function i(){for(var o=arguments.length,s=new Array(o),a=0;a<o;a++)s[a]=arguments[a];console&&console.warn&&!t&&(t=!0,console.warn(n+`: postcss.plugin was deprecated. Migration guide:
70
- https://evilmartians.com/chronicles/postcss-8-plugin-migration`),process.env.LANG&&process.env.LANG.startsWith("cn")&&console.warn(n+`: \u91CC\u9762 postcss.plugin \u88AB\u5F03\u7528. \u8FC1\u79FB\u6307\u5357:
71
- https://www.w3ctech.com/topic/2226`));var c=e.apply(void 0,[].concat(s));return c.postcssPlugin=n,c.postcssVersion=new ud().version,c}var r;return Object.defineProperty(i,"postcss",{get:function(){return r||(r=i()),r}}),i.process=function(o,s,a){return xe([i(a)]).process(o,s)},i},xe.stringify=xI,xe.parse=OI,xe.fromJSON=EI,xe.list=AI,xe.comment=function(n){return new Cv(n)},xe.atRule=function(n){return new Tv(n)},xe.decl=function(n){return new Sv(n)},xe.rule=function(n){return new xv(n)},xe.root=function(n){return new Ev(n)},xe.document=function(n){return new wv(n)},xe.CssSyntaxError=wI,xe.Declaration=Sv,xe.Container=TI,xe.Processor=ud,xe.Document=wv,xe.Comment=Cv,xe.Warning=II,xe.AtRule=Tv,xe.Result=RI,xe.Input=PI,xe.Rule=xv,xe.Root=Ev,xe.Node=MI,CI.registerPostcss(xe);var NI=xe;xe.default=xe;var ze=Gx(NI);ze.stringify,ze.fromJSON,ze.plugin,ze.parse,ze.list,ze.document,ze.comment,ze.atRule,ze.rule,ze.decl,ze.root,ze.CssSyntaxError,ze.Declaration,ze.Container,ze.Processor,ze.Document,ze.Comment,ze.Warning,ze.AtRule,ze.Result,ze.Input,ze.Rule,ze.Root,ze.Node;var DI=function(){function n(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];Ht(this,"parentElement",null),Ht(this,"parentNode",null),Ht(this,"ownerDocument"),Ht(this,"firstChild",null),Ht(this,"lastChild",null),Ht(this,"previousSibling",null),Ht(this,"nextSibling",null),Ht(this,"ELEMENT_NODE",1),Ht(this,"TEXT_NODE",3),Ht(this,"nodeType"),Ht(this,"nodeName"),Ht(this,"RRNodeType")}var e=n.prototype;return e.contains=function(t){if(ne(t,n)){if(t.ownerDocument!==this.ownerDocument)return!1;if(t===this)return!0}else return!1;for(;t.parentNode;){if(t.parentNode===this)return!0;t=t.parentNode}return!1},e.appendChild=function(t){throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.")},e.insertBefore=function(t,i){throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.")},e.removeChild=function(t){throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.")},e.toString=function(){return"RRNode"},mt(n,[{key:"childNodes",get:function(){for(var t=[],i=this.firstChild;i;)t.push(i),i=i.nextSibling;return t}}]),n}(),Iv={Node:["childNodes","parentNode","parentElement","textContent"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},Rv={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},Ea={},LI=function(){return!!globalThis.Zone};function ld(n){if(Ea[n])return Ea[n];var e=globalThis[n],t=e.prototype,i=n in Iv?Iv[n]:void 0,r=!!(i&&i.every(function(l){var d,h;return!!((h=(d=Object.getOwnPropertyDescriptor(t,l))==null?void 0:d.get)!=null&&h.toString().includes("[native code]"))})),o=n in Rv?Rv[n]:void 0,s=!!(o&&o.every(function(l){var d;return typeof t[l]=="function"&&((d=t[l])==null?void 0:d.toString().includes("[native code]"))}));if(r&&s&&!LI())return Ea[n]=e.prototype,e.prototype;try{var a=document.createElement("iframe");document.body.appendChild(a);var c=a.contentWindow;if(!c)return e.prototype;var u=c[n].prototype;return document.body.removeChild(a),u?Ea[n]=u:t}catch{return t}}var dd={};function ri(n,e,t){var i,r=n+"."+String(t);if(dd[r])return dd[r].call(e);var o=ld(n),s=(i=Object.getOwnPropertyDescriptor(o,t))==null?void 0:i.get;return s?(dd[r]=s,s.call(e)):e[t]}var hd={};function Pv(n,e,t){var i=n+"."+String(t);if(hd[i])return hd[i].bind(e);var r=ld(n),o=r[t];return typeof o!="function"?e[t]:(hd[i]=o,o.bind(e))}function UI(n){return ri("Node",n,"childNodes")}function FI(n){return ri("Node",n,"parentNode")}function BI(n){return ri("Node",n,"parentElement")}function jI(n){return ri("Node",n,"textContent")}function VI(n,e){return Pv("Node",n,"contains")(e)}function zI(n){return Pv("Node",n,"getRootNode")()}function qI(n){return!n||!("host"in n)?null:ri("ShadowRoot",n,"host")}function WI(n){return n.styleSheets}function GI(n){return!n||!("shadowRoot"in n)?null:ri("Element",n,"shadowRoot")}function $I(n,e){return ri("Element",n,"querySelector")(e)}function HI(n,e){return ri("Element",n,"querySelectorAll")(e)}function Ov(){return ld("MutationObserver").constructor}var se={childNodes:UI,parentNode:FI,parentElement:BI,textContent:jI,contains:VI,getRootNode:zI,host:qI,styleSheets:WI,shadowRoot:GI,querySelector:$I,querySelectorAll:HI,mutationObserver:Ov};function It(n,e,t){t===void 0&&(t=document);var i={capture:!0,passive:!0};return t.addEventListener(n,e,i),function(){return t.removeEventListener(n,e,i)}}var Ir=`Please stop import mirror directly. Instead of that,\r
72
- now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
73
- or you can use record.mirror to access the mirror instance during recording.`,Av={map:{},getId:function(){return console.error(Ir),-1},getNode:function(){return console.error(Ir),null},removeNodeFromMap:function(){console.error(Ir)},has:function(){return console.error(Ir),!1},reset:function(){console.error(Ir)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(Av=new Proxy(Av,{get:function(n,e,t){return e==="map"&&console.error(Ir),Reflect.get(n,e,t)}}));function jo(n,e,t){t===void 0&&(t={});var i=null,r=0;return function(){for(var o=arguments.length,s=new Array(o),a=0;a<o;a++)s[a]=arguments[a];var c=Date.now();!r&&t.leading===!1&&(r=c);var u=e-(c-r),l=this;u<=0||u>e?(i&&(clearTimeout(i),i=null),r=c,n.apply(l,s)):!i&&t.trailing!==!1&&(i=setTimeout(function(){r=t.leading===!1?0:Date.now(),i=null,n.apply(l,s)},u))}}function Ia(n,e,t,i,r){r===void 0&&(r=window);var o=r.Object.getOwnPropertyDescriptor(n,e);return r.Object.defineProperty(n,e,i?t:{set:function(s){var a=this;setTimeout(function(){t.set.call(a,s)},0),o&&o.set&&o.set.call(this,s)}}),function(){return Ia(n,e,o||{},!0)}}function Rr(n,e,t){try{if(!(e in n))return function(){};var i=n[e],r=t(i);return typeof r=="function"&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__rrweb_original__:{enumerable:!1,value:i}})),n[e]=r,function(){n[e]=i}}catch{return function(){}}}var Ra=Date.now;/[1-9][0-9]{12}/.test(Date.now().toString())||(Ra=function(){return new Date().getTime()});function Mv(n){var e,t,i,r,o=n.document;return{left:o.scrollingElement?o.scrollingElement.scrollLeft:n.pageXOffset!==void 0?n.pageXOffset:o.documentElement.scrollLeft||(o==null?void 0:o.body)&&((e=se.parentElement(o.body))==null?void 0:e.scrollLeft)||((t=o==null?void 0:o.body)==null?void 0:t.scrollLeft)||0,top:o.scrollingElement?o.scrollingElement.scrollTop:n.pageYOffset!==void 0?n.pageYOffset:(o==null?void 0:o.documentElement.scrollTop)||(o==null?void 0:o.body)&&((i=se.parentElement(o.body))==null?void 0:i.scrollTop)||((r=o==null?void 0:o.body)==null?void 0:r.scrollTop)||0}}function Nv(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Dv(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function Lv(n){if(!n)return null;var e=n.nodeType===n.ELEMENT_NODE?n:se.parentElement(n);return e}function Rt(n,e,t,i){if(!n)return!1;var r=Lv(n);if(!r)return!1;try{if(typeof e=="string"){if(r.classList.contains(e)||i&&r.closest("."+e)!==null)return!0}else if(js(r,e,i))return!0}catch{}return!!(t&&(r.matches(t)||i&&r.closest(t)!==null))}function KI(n,e){return e.getId(n)!==-1}function pd(n,e,t){return n.tagName==="TITLE"&&t.headTitleMutations?!0:e.getId(n)===To}function Uv(n,e){if(wo(n))return!1;var t=e.getId(n);if(!e.has(t))return!0;var i=se.parentNode(n);return i&&i.nodeType===n.DOCUMENT_NODE?!1:i?Uv(i,e):!0}function fd(n){return!!n.changedTouches}function YI(n){n===void 0&&(n=window),"NodeList"in n&&!n.NodeList.prototype.forEach&&(n.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in n&&!n.DOMTokenList.prototype.forEach&&(n.DOMTokenList.prototype.forEach=Array.prototype.forEach)}function Fv(n,e){return!!(n.nodeName==="IFRAME"&&e.getMeta(n))}function Bv(n,e){return!!(n.nodeName==="LINK"&&n.nodeType===n.ELEMENT_NODE&&n.getAttribute&&n.getAttribute("rel")==="stylesheet"&&e.getMeta(n))}function md(n){return n?ne(n,DI)&&"shadowRoot"in n?!!n.shadowRoot:!!se.shadowRoot(n):!1}var XI=function(){function n(){z(this,"id",1),z(this,"styleIDMap",new WeakMap),z(this,"idStyleMap",new Map)}var e=n.prototype;return e.getId=function(t){var i;return(i=this.styleIDMap.get(t))!=null?i:-1},e.has=function(t){return this.styleIDMap.has(t)},e.add=function(t,i){if(this.has(t))return this.getId(t);var r;return i===void 0?r=this.id++:r=i,this.styleIDMap.set(t,r),this.idStyleMap.set(r,t),r},e.getStyle=function(t){return this.idStyleMap.get(t)||null},e.reset=function(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1},e.generateId=function(){return this.id++},n}();function jv(n){var e,t=null;return"getRootNode"in n&&((e=se.getRootNode(n))==null?void 0:e.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&se.host(se.getRootNode(n))&&(t=se.host(se.getRootNode(n))),t}function JI(n){for(var e=n,t;t=jv(e);)e=t;return e}function ZI(n){var e=n.ownerDocument;if(!e)return!1;var t=JI(n);return se.contains(e,t)}function Vv(n){var e=n.ownerDocument;return e?se.contains(e,n)||ZI(n):!1}var ce=function(n){return n[n.DomContentLoaded=0]="DomContentLoaded",n[n.Load=1]="Load",n[n.FullSnapshot=2]="FullSnapshot",n[n.IncrementalSnapshot=3]="IncrementalSnapshot",n[n.Meta=4]="Meta",n[n.Custom=5]="Custom",n[n.Plugin=6]="Plugin",n}(ce||{}),Z=function(n){return n[n.Mutation=0]="Mutation",n[n.MouseMove=1]="MouseMove",n[n.MouseInteraction=2]="MouseInteraction",n[n.Scroll=3]="Scroll",n[n.ViewportResize=4]="ViewportResize",n[n.Input=5]="Input",n[n.TouchMove=6]="TouchMove",n[n.MediaInteraction=7]="MediaInteraction",n[n.StyleSheetRule=8]="StyleSheetRule",n[n.CanvasMutation=9]="CanvasMutation",n[n.Font=10]="Font",n[n.Log=11]="Log",n[n.Drag=12]="Drag",n[n.StyleDeclaration=13]="StyleDeclaration",n[n.Selection=14]="Selection",n[n.AdoptedStyleSheet=15]="AdoptedStyleSheet",n[n.CustomElement=16]="CustomElement",n}(Z||{}),Ut=function(n){return n[n.MouseUp=0]="MouseUp",n[n.MouseDown=1]="MouseDown",n[n.Click=2]="Click",n[n.ContextMenu=3]="ContextMenu",n[n.DblClick=4]="DblClick",n[n.Focus=5]="Focus",n[n.Blur=6]="Blur",n[n.TouchStart=7]="TouchStart",n[n.TouchMove_Departed=8]="TouchMove_Departed",n[n.TouchEnd=9]="TouchEnd",n[n.TouchCancel=10]="TouchCancel",n}(Ut||{}),jn=function(n){return n[n.Mouse=0]="Mouse",n[n.Pen=1]="Pen",n[n.Touch=2]="Touch",n}(jn||{}),Pr=function(n){return n[n["2D"]=0]="2D",n[n.WebGL=1]="WebGL",n[n.WebGL2=2]="WebGL2",n}(Pr||{}),Or=function(n){return n[n.Play=0]="Play",n[n.Pause=1]="Pause",n[n.Seeked=2]="Seeked",n[n.VolumeChange=3]="VolumeChange",n[n.RateChange=4]="RateChange",n}(Or||{}),zv=function(n){return n[n.Document=0]="Document",n[n.DocumentType=1]="DocumentType",n[n.Element=2]="Element",n[n.Text=3]="Text",n[n.CDATA=4]="CDATA",n[n.Comment=5]="Comment",n}(zv||{});function qv(n){return"__ln"in n}var QI=function(){function n(){z(this,"length",0),z(this,"head",null),z(this,"tail",null)}var e=n.prototype;return e.get=function(t){if(t>=this.length)throw new Error("Position outside of list range");for(var i=this.head,r=0;r<t;r++)i=(i==null?void 0:i.next)||null;return i},e.addNode=function(t){var i={value:t,previous:null,next:null};if(t.__ln=i,t.previousSibling&&qv(t.previousSibling)){var r=t.previousSibling.__ln.next;i.next=r,i.previous=t.previousSibling.__ln,t.previousSibling.__ln.next=i,r&&(r.previous=i)}else if(t.nextSibling&&qv(t.nextSibling)&&t.nextSibling.__ln.previous){var o=t.nextSibling.__ln.previous;i.previous=o,i.next=t.nextSibling.__ln,t.nextSibling.__ln.previous=i,o&&(o.next=i)}else this.head&&(this.head.previous=i),i.next=this.head,this.head=i;i.next===null&&(this.tail=i),this.length++},e.removeNode=function(t){var i=t.__ln;this.head&&(i.previous?(i.previous.next=i.next,i.next?i.next.previous=i.previous:this.tail=i.previous):(this.head=i.next,this.head?this.head.previous=null:this.tail=null),t.__ln&&delete t.__ln,this.length--)},n}(),Wv=function(n,e){return n+"@"+e},eR=function(){function n(){var t=this;z(this,"frozen",!1),z(this,"locked",!1),z(this,"texts",[]),z(this,"attributes",[]),z(this,"attributeMap",new WeakMap),z(this,"removes",[]),z(this,"mapRemoves",[]),z(this,"movedMap",{}),z(this,"addedSet",new Set),z(this,"movedSet",new Set),z(this,"droppedSet",new Set),z(this,"removesSubTreeCache",new Set),z(this,"mutationCb"),z(this,"blockClass"),z(this,"blockSelector"),z(this,"maskTextClass"),z(this,"maskTextSelector"),z(this,"inlineStylesheet"),z(this,"maskInputOptions"),z(this,"maskTextFn"),z(this,"maskInputFn"),z(this,"keepIframeSrcFn"),z(this,"recordCanvas"),z(this,"inlineImages"),z(this,"slimDOMOptions"),z(this,"dataURLOptions"),z(this,"doc"),z(this,"mirror"),z(this,"iframeManager"),z(this,"stylesheetManager"),z(this,"shadowDomManager"),z(this,"canvasManager"),z(this,"processedNodeManager"),z(this,"unattachedDoc"),z(this,"processMutations",function(i){i.forEach(t.processMutation),t.emit()}),z(this,"emit",function(){if(!(t.frozen||t.locked)){for(var i=[],r=new Set,o=new QI,s=function(A){for(var L=A,V=To;V===To;)L=L&&L.nextSibling,V=L&&t.mirror.getId(L);return V},a=function(A){var L=se.parentNode(A);if(!(!L||!Vv(A))){var V=!1;if(A.nodeType===Node.TEXT_NODE){var Y=L.tagName;if(Y==="TEXTAREA")return;Y==="STYLE"&&t.addedSet.has(L)&&(V=!0)}var O=wo(L)?t.mirror.getId(jv(A)):t.mirror.getId(L),F=s(A);if(O===-1||F===-1)return o.addNode(A);var X=kr(A,{doc:t.doc,mirror:t.mirror,blockClass:t.blockClass,blockSelector:t.blockSelector,maskTextClass:t.maskTextClass,maskTextSelector:t.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:t.inlineStylesheet,maskInputOptions:t.maskInputOptions,maskTextFn:t.maskTextFn,maskInputFn:t.maskInputFn,slimDOMOptions:t.slimDOMOptions,dataURLOptions:t.dataURLOptions,recordCanvas:t.recordCanvas,inlineImages:t.inlineImages,onSerialize:function(K){Fv(K,t.mirror)&&t.iframeManager.addIframe(K),Bv(K,t.mirror)&&t.stylesheetManager.trackLinkElement(K),md(A)&&t.shadowDomManager.addShadowRoot(se.shadowRoot(A),t.doc)},onIframeLoad:function(K,Q){t.iframeManager.attachIframe(K,Q),t.shadowDomManager.observeAttachShadow(K)},onStylesheetLoad:function(K,Q){t.stylesheetManager.attachLinkElement(K,Q)},cssCaptured:V});X&&(i.push({parentId:O,nextId:F,node:X}),r.add(X.id))}};t.mapRemoves.length;)t.mirror.removeNodeFromMap(t.mapRemoves.shift());for(var c=H(t.movedSet),u;!(u=c()).done;){var l=u.value;Gv(t.removesSubTreeCache,l,t.mirror)&&!t.movedSet.has(se.parentNode(l))||a(l)}for(var d=H(t.addedSet),h;!(h=d()).done;){var p=h.value;!$v(t.droppedSet,p)&&!Gv(t.removesSubTreeCache,p,t.mirror)||$v(t.movedSet,p)?a(p):t.droppedSet.add(p)}for(var m=null;o.length;){var f=null;if(m){var g=t.mirror.getId(se.parentNode(m.value)),y=s(m.value);g!==-1&&y!==-1&&(f=m)}if(!f)for(var b=o.tail;b;){var S=b;if(b=b.previous,S){var w=t.mirror.getId(se.parentNode(S.value)),k=s(S.value);if(k===-1)continue;if(w!==-1){f=S;break}else{var C=S.value,x=se.parentNode(C);if(x&&x.nodeType===Node.DOCUMENT_FRAGMENT_NODE){var I=se.host(x),P=t.mirror.getId(I);if(P!==-1){f=S;break}}}}}if(!f){for(;o.head;)o.removeNode(o.head.value);break}m=f.previous,o.removeNode(f.value),a(f.value)}var D={texts:t.texts.map(function(A){var L=A.node,V=se.parentNode(L);return V&&V.tagName==="TEXTAREA"&&t.genTextAreaValueMutation(V),{id:t.mirror.getId(L),value:A.value}}).filter(function(A){return!r.has(A.id)}).filter(function(A){return t.mirror.has(A.id)}),attributes:t.attributes.map(function(A){var L=A.attributes;if(typeof L.style=="string"){var V=JSON.stringify(A.styleDiff),Y=JSON.stringify(A._unchangedStyles);V.length<L.style.length&&(V+Y).split("var(").length===L.style.split("var(").length&&(L.style=A.styleDiff)}return{id:t.mirror.getId(A.node),attributes:L}}).filter(function(A){return!r.has(A.id)}).filter(function(A){return t.mirror.has(A.id)}),removes:t.removes,adds:i};!D.texts.length&&!D.attributes.length&&!D.removes.length&&!D.adds.length||(t.texts=[],t.attributes=[],t.attributeMap=new WeakMap,t.removes=[],t.addedSet=new Set,t.movedSet=new Set,t.droppedSet=new Set,t.removesSubTreeCache=new Set,t.movedMap={},t.mutationCb(D))}}),z(this,"genTextAreaValueMutation",function(i){var r=t.attributeMap.get(i);r||(r={node:i,attributes:{},styleDiff:{},_unchangedStyles:{}},t.attributes.push(r),t.attributeMap.set(i,r)),r.attributes.value=Array.from(se.childNodes(i),function(o){return se.textContent(o)||""}).join("")}),z(this,"processMutation",function(i){if(!pd(i.target,t.mirror,t.slimDOMOptions))switch(i.type){case"characterData":{var r=se.textContent(i.target);!Rt(i.target,t.blockClass,t.blockSelector,!1)&&r!==i.oldValue&&t.texts.push({value:Mm(i.target,t.maskTextClass,t.maskTextSelector,!0)&&r?t.maskTextFn?t.maskTextFn(r,Lv(i.target)):r.replace(/[\S]/g,"*"):r,node:i.target});break}case"attributes":{var o=i.target,s=i.attributeName,a=i.target.getAttribute(s);if(s==="value"){var c=il(o);a=nl({element:o,maskInputOptions:t.maskInputOptions,tagName:o.tagName,type:c,value:a,maskInputFn:t.maskInputFn})}if(Rt(i.target,t.blockClass,t.blockSelector,!1)||a===i.oldValue)return;var u=t.attributeMap.get(i.target);if(o.tagName==="IFRAME"&&s==="src"&&!t.keepIframeSrcFn(a))if(!o.contentDocument)s="rr_src";else return;if(u||(u={node:i.target,attributes:{},styleDiff:{},_unchangedStyles:{}},t.attributes.push(u),t.attributeMap.set(i.target,u)),s==="type"&&o.tagName==="INPUT"&&(i.oldValue||"").toLowerCase()==="password"&&o.setAttribute("data-rr-is-password","true"),!Am(o.tagName,s))if(u.attributes[s]=Om(t.doc,ji(o.tagName),ji(s),a),s==="style"){if(!t.unattachedDoc)try{t.unattachedDoc=document.implementation.createHTMLDocument()}catch{t.unattachedDoc=t.doc}var l=t.unattachedDoc.createElement("span");i.oldValue&&l.setAttribute("style",i.oldValue);for(var d=H(Array.from(o.style)),h;!(h=d()).done;){var p=h.value,m=o.style.getPropertyValue(p),f=o.style.getPropertyPriority(p);m!==l.style.getPropertyValue(p)||f!==l.style.getPropertyPriority(p)?f===""?u.styleDiff[p]=m:u.styleDiff[p]=[m,f]:u._unchangedStyles[p]=[m,f]}for(var g=H(Array.from(l.style)),y;!(y=g()).done;){var b=y.value;o.style.getPropertyValue(b)===""&&(u.styleDiff[b]=!1)}}else s==="open"&&o.tagName==="DIALOG"&&(o.matches("dialog:modal")?u.attributes.rr_open_mode="modal":u.attributes.rr_open_mode="non-modal");break}case"childList":{if(Rt(i.target,t.blockClass,t.blockSelector,!0))return;if(i.target.tagName==="TEXTAREA"){t.genTextAreaValueMutation(i.target);return}i.addedNodes.forEach(function(S){return t.genAdds(S,i.target)}),i.removedNodes.forEach(function(S){var w=t.mirror.getId(S),k=wo(i.target)?t.mirror.getId(se.host(i.target)):t.mirror.getId(i.target);Rt(i.target,t.blockClass,t.blockSelector,!1)||pd(S,t.mirror,t.slimDOMOptions)||!KI(S,t.mirror)||(t.addedSet.has(S)?(gd(t.addedSet,S),t.droppedSet.add(S)):t.addedSet.has(i.target)&&w===-1||Uv(i.target,t.mirror)||(t.movedSet.has(S)&&t.movedMap[Wv(w,k)]?gd(t.movedSet,S):(t.removes.push({parentId:k,id:w,isShadow:wo(i.target)&&Co(i.target)?!0:void 0}),tR(S,t.removesSubTreeCache))),t.mapRemoves.push(S))});break}}}),z(this,"genAdds",function(i,r){if(!t.processedNodeManager.inOtherBuffer(i,t)&&!(t.addedSet.has(i)||t.movedSet.has(i))){if(t.mirror.hasNode(i)){if(pd(i,t.mirror,t.slimDOMOptions))return;t.movedSet.add(i);var o=null;r&&t.mirror.hasNode(r)&&(o=t.mirror.getId(r)),o&&o!==-1&&(t.movedMap[Wv(t.mirror.getId(i),o)]=!0)}else t.addedSet.add(i),t.droppedSet.delete(i);Rt(i,t.blockClass,t.blockSelector,!1)||(se.childNodes(i).forEach(function(s){return t.genAdds(s)}),md(i)&&se.childNodes(se.shadowRoot(i)).forEach(function(s){t.processedNodeManager.add(s,t),t.genAdds(s,i)}))}})}var e=n.prototype;return e.init=function(t){var i=this;["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(function(r){i[r]=t[r]})},e.freeze=function(){this.frozen=!0,this.canvasManager.freeze()},e.unfreeze=function(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()},e.isFrozen=function(){return this.frozen},e.lock=function(){this.locked=!0,this.canvasManager.lock()},e.unlock=function(){this.locked=!1,this.canvasManager.unlock(),this.emit()},e.reset=function(){this.shadowDomManager.reset(),this.canvasManager.reset()},n}();function gd(n,e){n.delete(e),se.childNodes(e).forEach(function(t){return gd(n,t)})}function tR(n,e){for(var t=[n];t.length;){var i=t.pop();e.has(i)||(e.add(i),se.childNodes(i).forEach(function(r){return t.push(r)}))}}function Gv(n,e,t){return n.size===0?!1:nR(n,e)}function nR(n,e,t){var i=se.parentNode(e);return i?n.has(i):!1}function $v(n,e){return n.size===0?!1:Hv(n,e)}function Hv(n,e){var t=se.parentNode(e);return t?n.has(t)?!0:Hv(n,t):!1}var Vo;function iR(n){Vo=n}function rR(){Vo=void 0}var he=function(n){if(!Vo)return n;var e=function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];try{return n.apply(void 0,[].concat(i))}catch(o){if(Vo&&Vo(o)===!0)return;throw o}};return e},qi=[];function zo(n){try{if("composedPath"in n){var e=n.composedPath();if(e.length)return e[0]}else if("path"in n&&n.path.length)return n.path[0]}catch{}return n&&n.target}function Kv(n,e){var t=new eR;qi.push(t),t.init(n);var i=new(Ov())(he(t.processMutations.bind(t)));return i.observe(e,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),i}function oR(n){var e=n.mousemoveCb,t=n.sampling,i=n.doc,r=n.mirror;if(t.mousemove===!1)return function(){};var o=typeof t.mousemove=="number"?t.mousemove:50,s=typeof t.mousemoveCallback=="number"?t.mousemoveCallback:500,a=[],c,u=jo(he(function(h){var p=Date.now()-c;e(a.map(function(m){return m.timeOffset-=p,m}),h),a=[],c=null}),s),l=he(jo(he(function(h){var p=zo(h),m=fd(h)?h.changedTouches[0]:h,f=m.clientX,g=m.clientY;c||(c=Ra()),a.push({x:f,y:g,id:r.getId(p),timeOffset:Ra()-c}),u(typeof DragEvent<"u"&&ne(h,DragEvent)?Z.Drag:ne(h,MouseEvent)?Z.MouseMove:Z.TouchMove)}),o,{trailing:!1})),d=[It("mousemove",l,i),It("touchmove",l,i),It("drag",l,i)];return he(function(){d.forEach(function(h){return h()})})}function sR(n){var e=n.mouseInteractionCb,t=n.doc,i=n.mirror,r=n.blockClass,o=n.blockSelector,s=n.sampling;if(s.mouseInteraction===!1)return function(){};var a=s.mouseInteraction===!0||s.mouseInteraction===void 0?{}:s.mouseInteraction,c=[],u=null,l=function(d){return function(h){var p=zo(h);if(!Rt(p,r,o,!0)){var m=null,f=d;if("pointerType"in h){switch(h.pointerType){case"mouse":m=jn.Mouse;break;case"touch":m=jn.Touch;break;case"pen":m=jn.Pen;break}m===jn.Touch?Ut[d]===Ut.MouseDown?f="TouchStart":Ut[d]===Ut.MouseUp&&(f="TouchEnd"):jn.Pen}else fd(h)&&(m=jn.Touch);m!==null?(u=m,(f.startsWith("Touch")&&m===jn.Touch||f.startsWith("Mouse")&&m===jn.Mouse)&&(m=null)):Ut[d]===Ut.Click&&(m=u,u=null);var g=fd(h)?h.changedTouches[0]:h;if(g){var y=i.getId(p),b=g.clientX,S=g.clientY;he(e)(me({type:Ut[f],id:y,x:b,y:S},m!==null&&{pointerType:m}))}}}};return Object.keys(Ut).filter(function(d){return Number.isNaN(Number(d))&&!d.endsWith("_Departed")&&a[d]!==!1}).forEach(function(d){var h=ji(d),p=l(d);if(window.PointerEvent)switch(Ut[d]){case Ut.MouseDown:case Ut.MouseUp:h=h.replace("mouse","pointer");break;case Ut.TouchStart:case Ut.TouchEnd:return}c.push(It(h,p,t))}),he(function(){c.forEach(function(d){return d()})})}function Yv(n){var e=n.scrollCb,t=n.doc,i=n.mirror,r=n.blockClass,o=n.blockSelector,s=n.sampling,a=he(jo(he(function(c){var u=zo(c);if(!(!u||Rt(u,r,o,!0))){var l=i.getId(u);if(u===t&&t.defaultView){var d=Mv(t.defaultView);e({id:l,x:d.left,y:d.top})}else e({id:l,x:u.scrollLeft,y:u.scrollTop})}}),s.scroll||100));return It("scroll",a,t)}function aR(n,e){var t=n.viewportResizeCb,i=e.win,r=-1,o=-1,s=he(jo(he(function(){var a=Nv(),c=Dv();(r!==a||o!==c)&&(t({width:Number(c),height:Number(a)}),r=a,o=c)}),200));return It("resize",s,i)}var cR=["INPUT","TEXTAREA","SELECT"],Xv=new WeakMap;function uR(n){var e=n.inputCb,t=n.doc,i=n.mirror,r=n.blockClass,o=n.blockSelector,s=n.ignoreClass,a=n.ignoreSelector,c=n.maskInputOptions,u=n.maskInputFn,l=n.sampling,d=n.userTriggeredOnInput;function h(w){var k=zo(w),C=w.isTrusted,x=k&&k.tagName;if(k&&x==="OPTION"&&(k=se.parentElement(k)),!(!k||!x||cR.indexOf(x)<0||Rt(k,r,o,!0))&&!(k.classList.contains(s)||a&&k.matches(a))){var I=k.value,P=!1,D=il(k)||"";D==="radio"||D==="checkbox"?P=k.checked:(c[x.toLowerCase()]||c[D])&&(I=nl({element:k,maskInputOptions:c,tagName:x,type:D,value:I,maskInputFn:u})),p(k,d?{text:I,isChecked:P,userTriggered:C}:{text:I,isChecked:P});var A=k.name;D==="radio"&&A&&P&&t.querySelectorAll('input[type="radio"][name="'+A+'"]').forEach(function(L){if(L!==k){var V=L.value;p(L,d?{text:V,isChecked:!P,userTriggered:!1}:{text:V,isChecked:!P})}})}}function p(w,k){var C=Xv.get(w);if(!C||C.text!==k.text||C.isChecked!==k.isChecked){Xv.set(w,k);var x=i.getId(w);he(e)(me({},k,{id:x}))}}var m=l.input==="last"?["change"]:["input","change"],f=m.map(function(w){return It(w,he(h),t)}),g=t.defaultView;if(!g)return function(){f.forEach(function(w){return w()})};var y=g.Object.getOwnPropertyDescriptor(g.HTMLInputElement.prototype,"value"),b=[[g.HTMLInputElement.prototype,"value"],[g.HTMLInputElement.prototype,"checked"],[g.HTMLSelectElement.prototype,"value"],[g.HTMLTextAreaElement.prototype,"value"],[g.HTMLSelectElement.prototype,"selectedIndex"],[g.HTMLOptionElement.prototype,"selected"]];if(y&&y.set){var S;(S=f).push.apply(S,[].concat(b.map(function(w){return Ia(w[0],w[1],{set:function(){he(h)({target:this,isTrusted:!1})}},!1,g)})))}return he(function(){f.forEach(function(w){return w()})})}function Pa(n){var e=[];function t(i,r){if(Oa("CSSGroupingRule")&&ne(i.parentRule,CSSGroupingRule)||Oa("CSSMediaRule")&&ne(i.parentRule,CSSMediaRule)||Oa("CSSSupportsRule")&&ne(i.parentRule,CSSSupportsRule)||Oa("CSSConditionRule")&&ne(i.parentRule,CSSConditionRule)){var o=Array.from(i.parentRule.cssRules),s=o.indexOf(i);r.unshift(s)}else if(i.parentStyleSheet){var a=Array.from(i.parentStyleSheet.cssRules),c=a.indexOf(i);r.unshift(c)}return r}return t(n,e)}function oi(n,e,t){var i,r;return n?(n.ownerNode?i=e.getId(n.ownerNode):r=t.getId(n),{styleId:r,id:i}):{}}function lR(n,e){var t=n.styleSheetRuleCb,i=n.mirror,r=n.stylesheetManager,o=e.win;if(!o.CSSStyleSheet||!o.CSSStyleSheet.prototype)return function(){};var s=o.CSSStyleSheet.prototype.insertRule;o.CSSStyleSheet.prototype.insertRule=new Proxy(s,{apply:he(function(h,p,m){var f=m[0],g=m[1],y=oi(p,i,r.styleMirror),b=y.id,S=y.styleId;return(b&&b!==-1||S&&S!==-1)&&t({id:b,styleId:S,adds:[{rule:f,index:g}]}),h.apply(p,m)})}),o.CSSStyleSheet.prototype.addRule=function(h,p,m){m===void 0&&(m=this.cssRules.length);var f=h+" { "+p+" }";return o.CSSStyleSheet.prototype.insertRule.apply(this,[f,m])};var a=o.CSSStyleSheet.prototype.deleteRule;o.CSSStyleSheet.prototype.deleteRule=new Proxy(a,{apply:he(function(h,p,m){var f=m[0],g=oi(p,i,r.styleMirror),y=g.id,b=g.styleId;return(y&&y!==-1||b&&b!==-1)&&t({id:y,styleId:b,removes:[{index:f}]}),h.apply(p,m)})}),o.CSSStyleSheet.prototype.removeRule=function(h){return o.CSSStyleSheet.prototype.deleteRule.apply(this,[h])};var c;o.CSSStyleSheet.prototype.replace&&(c=o.CSSStyleSheet.prototype.replace,o.CSSStyleSheet.prototype.replace=new Proxy(c,{apply:he(function(h,p,m){var f=m[0],g=oi(p,i,r.styleMirror),y=g.id,b=g.styleId;return(y&&y!==-1||b&&b!==-1)&&t({id:y,styleId:b,replace:f}),h.apply(p,m)})}));var u;o.CSSStyleSheet.prototype.replaceSync&&(u=o.CSSStyleSheet.prototype.replaceSync,o.CSSStyleSheet.prototype.replaceSync=new Proxy(u,{apply:he(function(h,p,m){var f=m[0],g=oi(p,i,r.styleMirror),y=g.id,b=g.styleId;return(y&&y!==-1||b&&b!==-1)&&t({id:y,styleId:b,replaceSync:f}),h.apply(p,m)})}));var l={};Aa("CSSGroupingRule")?l.CSSGroupingRule=o.CSSGroupingRule:(Aa("CSSMediaRule")&&(l.CSSMediaRule=o.CSSMediaRule),Aa("CSSConditionRule")&&(l.CSSConditionRule=o.CSSConditionRule),Aa("CSSSupportsRule")&&(l.CSSSupportsRule=o.CSSSupportsRule));var d={};return Object.entries(l).forEach(function(h){var p=h[0],m=h[1];d[p]={insertRule:m.prototype.insertRule,deleteRule:m.prototype.deleteRule},m.prototype.insertRule=new Proxy(d[p].insertRule,{apply:he(function(f,g,y){var b=y[0],S=y[1],w=oi(g.parentStyleSheet,i,r.styleMirror),k=w.id,C=w.styleId;return(k&&k!==-1||C&&C!==-1)&&t({id:k,styleId:C,adds:[{rule:b,index:[].concat(Pa(g),[S||0])}]}),f.apply(g,y)})}),m.prototype.deleteRule=new Proxy(d[p].deleteRule,{apply:he(function(f,g,y){var b=y[0],S=oi(g.parentStyleSheet,i,r.styleMirror),w=S.id,k=S.styleId;return(w&&w!==-1||k&&k!==-1)&&t({id:w,styleId:k,removes:[{index:[].concat(Pa(g),[b])}]}),f.apply(g,y)})})}),he(function(){o.CSSStyleSheet.prototype.insertRule=s,o.CSSStyleSheet.prototype.deleteRule=a,c&&(o.CSSStyleSheet.prototype.replace=c),u&&(o.CSSStyleSheet.prototype.replaceSync=u),Object.entries(l).forEach(function(h){var p=h[0],m=h[1];m.prototype.insertRule=d[p].insertRule,m.prototype.deleteRule=d[p].deleteRule})})}function Jv(n,e){var t=n.mirror,i=n.stylesheetManager,r,o,s,a=null;e.nodeName==="#document"?a=t.getId(e):a=t.getId(se.host(e));var c=e.nodeName==="#document"?(r=e.defaultView)==null?void 0:r.Document:(s=(o=e.ownerDocument)==null?void 0:o.defaultView)==null?void 0:s.ShadowRoot,u=c!=null&&c.prototype?Object.getOwnPropertyDescriptor(c==null?void 0:c.prototype,"adoptedStyleSheets"):void 0;return a===null||a===-1||!c||!u?function(){}:(Object.defineProperty(e,"adoptedStyleSheets",{configurable:u.configurable,enumerable:u.enumerable,get:function(){var l;return(l=u.get)==null?void 0:l.call(this)},set:function(l){var d,h=(d=u.set)==null?void 0:d.call(this,l);if(a!==null&&a!==-1)try{i.adoptStyleSheets(l,a)}catch{}return h}}),he(function(){Object.defineProperty(e,"adoptedStyleSheets",{configurable:u.configurable,enumerable:u.enumerable,get:u.get,set:u.set})}))}function dR(n,e){var t=n.styleDeclarationCb,i=n.mirror,r=n.ignoreCSSAttributes,o=n.stylesheetManager,s=e.win,a=s.CSSStyleDeclaration.prototype.setProperty;s.CSSStyleDeclaration.prototype.setProperty=new Proxy(a,{apply:he(function(u,l,d){var h,p=d[0],m=d[1],f=d[2];if(r.has(p))return a.apply(l,[p,m,f]);var g=oi((h=l.parentRule)==null?void 0:h.parentStyleSheet,i,o.styleMirror),y=g.id,b=g.styleId;return(y&&y!==-1||b&&b!==-1)&&t({id:y,styleId:b,set:{property:p,value:m,priority:f},index:Pa(l.parentRule)}),u.apply(l,d)})});var c=s.CSSStyleDeclaration.prototype.removeProperty;return s.CSSStyleDeclaration.prototype.removeProperty=new Proxy(c,{apply:he(function(u,l,d){var h,p=d[0];if(r.has(p))return c.apply(l,[p]);var m=oi((h=l.parentRule)==null?void 0:h.parentStyleSheet,i,o.styleMirror),f=m.id,g=m.styleId;return(f&&f!==-1||g&&g!==-1)&&t({id:f,styleId:g,remove:{property:p},index:Pa(l.parentRule)}),u.apply(l,d)})}),he(function(){s.CSSStyleDeclaration.prototype.setProperty=a,s.CSSStyleDeclaration.prototype.removeProperty=c})}function hR(n){var e=n.mediaInteractionCb,t=n.blockClass,i=n.blockSelector,r=n.mirror,o=n.sampling,s=n.doc,a=he(function(u){return jo(he(function(l){var d=zo(l);if(!(!d||Rt(d,t,i,!0))){var h=d.currentTime,p=d.volume,m=d.muted,f=d.playbackRate,g=d.loop;e({type:u,id:r.getId(d),currentTime:h,volume:p,muted:m,playbackRate:f,loop:g})}}),o.media||500)}),c=[It("play",a(Or.Play),s),It("pause",a(Or.Pause),s),It("seeked",a(Or.Seeked),s),It("volumechange",a(Or.VolumeChange),s),It("ratechange",a(Or.RateChange),s)];return he(function(){c.forEach(function(u){return u()})})}function pR(n){var e=n.fontCb,t=n.doc,i=t.defaultView;if(!i)return function(){};var r=[],o=new WeakMap,s=i.FontFace;i.FontFace=function(c,u,l){var d=new s(c,u,l);return o.set(d,{family:c,buffer:typeof u!="string",descriptors:l,fontSource:typeof u=="string"?u:JSON.stringify(Array.from(new Uint8Array(u)))}),d};var a=Rr(t.fonts,"add",function(c){return function(u){return setTimeout(he(function(){var l=o.get(u);l&&(e(l),o.delete(u))}),0),c.apply(this,[u])}});return r.push(function(){i.FontFace=s}),r.push(a),he(function(){r.forEach(function(c){return c()})})}function fR(n){var e=n.doc,t=n.mirror,i=n.blockClass,r=n.blockSelector,o=n.selectionCb,s=!0,a=he(function(){var c=e.getSelection();if(!(!c||s&&(c!=null&&c.isCollapsed))){s=c.isCollapsed||!1;for(var u=[],l=c.rangeCount||0,d=0;d<l;d++){var h=c.getRangeAt(d),p=h.startContainer,m=h.startOffset,f=h.endContainer,g=h.endOffset,y=Rt(p,i,r,!0)||Rt(f,i,r,!0);y||u.push({start:t.getId(p),startOffset:m,end:t.getId(f),endOffset:g})}o({ranges:u})}});return a(),It("selectionchange",a)}function mR(n){var e=n.doc,t=n.customElementCb,i=e.defaultView;if(!i||!i.customElements)return function(){};var r=Rr(i.customElements,"define",function(o){return function(s,a,c){try{t({define:{name:s}})}catch{console.warn("Custom element callback failed for "+s)}return o.apply(this,[s,a,c])}});return r}function gR(n,e){var t=n.mutationCb,i=n.mousemoveCb,r=n.mouseInteractionCb,o=n.scrollCb,s=n.viewportResizeCb,a=n.inputCb,c=n.mediaInteractionCb,u=n.styleSheetRuleCb,l=n.styleDeclarationCb,d=n.canvasMutationCb,h=n.fontCb,p=n.selectionCb,m=n.customElementCb;n.mutationCb=function(){for(var f=arguments.length,g=new Array(f),y=0;y<f;y++)g[y]=arguments[y];if(e.mutation){var b;(b=e).mutation.apply(b,[].concat(g))}t.apply(void 0,[].concat(g))},n.mousemoveCb=function(){for(var f=arguments.length,g=new Array(f),y=0;y<f;y++)g[y]=arguments[y];if(e.mousemove){var b;(b=e).mousemove.apply(b,[].concat(g))}i.apply(void 0,[].concat(g))},n.mouseInteractionCb=function(){for(var f=arguments.length,g=new Array(f),y=0;y<f;y++)g[y]=arguments[y];if(e.mouseInteraction){var b;(b=e).mouseInteraction.apply(b,[].concat(g))}r.apply(void 0,[].concat(g))},n.scrollCb=function(){for(var f=arguments.length,g=new Array(f),y=0;y<f;y++)g[y]=arguments[y];if(e.scroll){var b;(b=e).scroll.apply(b,[].concat(g))}o.apply(void 0,[].concat(g))},n.viewportResizeCb=function(){for(var f=arguments.length,g=new Array(f),y=0;y<f;y++)g[y]=arguments[y];if(e.viewportResize){var b;(b=e).viewportResize.apply(b,[].concat(g))}s.apply(void 0,[].concat(g))},n.inputCb=function(){for(var f=arguments.length,g=new Array(f),y=0;y<f;y++)g[y]=arguments[y];if(e.input){var b;(b=e).input.apply(b,[].concat(g))}a.apply(void 0,[].concat(g))},n.mediaInteractionCb=function(){for(var f=arguments.length,g=new Array(f),y=0;y<f;y++)g[y]=arguments[y];if(e.mediaInteaction){var b;(b=e).mediaInteaction.apply(b,[].concat(g))}c.apply(void 0,[].concat(g))},n.styleSheetRuleCb=function(){for(var f=arguments.length,g=new Array(f),y=0;y<f;y++)g[y]=arguments[y];if(e.styleSheetRule){var b;(b=e).styleSheetRule.apply(b,[].concat(g))}u.apply(void 0,[].concat(g))},n.styleDeclarationCb=function(){for(var f=arguments.length,g=new Array(f),y=0;y<f;y++)g[y]=arguments[y];if(e.styleDeclaration){var b;(b=e).styleDeclaration.apply(b,[].concat(g))}l.apply(void 0,[].concat(g))},n.canvasMutationCb=function(){for(var f=arguments.length,g=new Array(f),y=0;y<f;y++)g[y]=arguments[y];if(e.canvasMutation){var b;(b=e).canvasMutation.apply(b,[].concat(g))}d.apply(void 0,[].concat(g))},n.fontCb=function(){for(var f=arguments.length,g=new Array(f),y=0;y<f;y++)g[y]=arguments[y];if(e.font){var b;(b=e).font.apply(b,[].concat(g))}h.apply(void 0,[].concat(g))},n.selectionCb=function(){for(var f=arguments.length,g=new Array(f),y=0;y<f;y++)g[y]=arguments[y];if(e.selection){var b;(b=e).selection.apply(b,[].concat(g))}p.apply(void 0,[].concat(g))},n.customElementCb=function(){for(var f=arguments.length,g=new Array(f),y=0;y<f;y++)g[y]=arguments[y];if(e.customElement){var b;(b=e).customElement.apply(b,[].concat(g))}m.apply(void 0,[].concat(g))}}function vR(n,e){e===void 0&&(e={});var t=n.doc.defaultView;if(!t)return function(){};gR(n,e);var i;n.recordDOM&&(i=Kv(n,n.doc));var r=oR(n),o=sR(n),s=Yv(n),a=aR(n,{win:t}),c=uR(n),u=hR(n),l=function(){},d=function(){},h=function(){},p=function(){};n.recordDOM&&(l=lR(n,{win:t}),d=Jv(n,n.doc),h=dR(n,{win:t}),n.collectFonts&&(p=pR(n)));for(var m=fR(n),f=mR(n),g=[],y=H(n.plugins),b;!(b=y()).done;){var S=b.value;g.push(S.observer(S.callback,t,S.options))}return he(function(){qi.forEach(function(w){return w.reset()}),i==null||i.disconnect(),r(),o(),s(),a(),c(),u(),l(),d(),h(),p(),m(),f(),g.forEach(function(w){return w()})})}function Oa(n){return typeof window[n]<"u"}function Aa(n){return!!(typeof window[n]<"u"&&window[n].prototype&&"insertRule"in window[n].prototype&&"deleteRule"in window[n].prototype)}for(var Zv=function(){function n(t){z(this,"iframeIdToRemoteIdMap",new WeakMap),z(this,"iframeRemoteIdToIdMap",new WeakMap),this.generateIdFn=t}var e=n.prototype;return e.getId=function(t,i,r,o){var s=r||this.getIdToRemoteIdMap(t),a=o||this.getRemoteIdToIdMap(t),c=s.get(i);return c||(c=this.generateIdFn(),s.set(i,c),a.set(c,i)),c},e.getIds=function(t,i){var r=this,o=this.getIdToRemoteIdMap(t),s=this.getRemoteIdToIdMap(t);return i.map(function(a){return r.getId(t,a,o,s)})},e.getRemoteId=function(t,i,r){var o=r||this.getRemoteIdToIdMap(t);if(typeof i!="number")return i;var s=o.get(i);return s||-1},e.getRemoteIds=function(t,i){var r=this,o=this.getRemoteIdToIdMap(t);return i.map(function(s){return r.getRemoteId(t,s,o)})},e.reset=function(t){if(!t){this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap;return}this.iframeIdToRemoteIdMap.delete(t),this.iframeRemoteIdToIdMap.delete(t)},e.getIdToRemoteIdMap=function(t){var i=this.iframeIdToRemoteIdMap.get(t);return i||(i=new Map,this.iframeIdToRemoteIdMap.set(t,i)),i},e.getRemoteIdToIdMap=function(t){var i=this.iframeRemoteIdToIdMap.get(t);return i||(i=new Map,this.iframeRemoteIdToIdMap.set(t,i)),i},n}(),yR=function(){function n(t){z(this,"iframes",new WeakMap),z(this,"crossOriginIframeMap",new WeakMap),z(this,"crossOriginIframeMirror",new Zv(Im)),z(this,"crossOriginIframeStyleMirror"),z(this,"crossOriginIframeRootIdMap",new WeakMap),z(this,"mirror"),z(this,"mutationCb"),z(this,"wrappedEmit"),z(this,"loadListener"),z(this,"stylesheetManager"),z(this,"recordCrossOriginIframes"),this.mutationCb=t.mutationCb,this.wrappedEmit=t.wrappedEmit,this.stylesheetManager=t.stylesheetManager,this.recordCrossOriginIframes=t.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Zv(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=t.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}var e=n.prototype;return e.addIframe=function(t){this.iframes.set(t,!0),t.contentWindow&&this.crossOriginIframeMap.set(t.contentWindow,t)},e.addLoadListener=function(t){this.loadListener=t},e.attachIframe=function(t,i){var r,o;this.mutationCb({adds:[{parentId:this.mirror.getId(t),nextId:null,node:i}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),this.recordCrossOriginIframes&&((r=t.contentWindow)==null||r.addEventListener("message",this.handleMessage.bind(this))),(o=this.loadListener)==null||o.call(this,t),t.contentDocument&&t.contentDocument.adoptedStyleSheets&&t.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(t.contentDocument.adoptedStyleSheets,this.mirror.getId(t.contentDocument))},e.handleMessage=function(t){var i=t;if(!(i.data.type!=="rrweb"||i.origin!==i.data.origin)){var r=t.source;if(r){var o=this.crossOriginIframeMap.get(t.source);if(o){var s=this.transformCrossOriginEvent(o,i.data.event);s&&this.wrappedEmit(s,i.data.isCheckout)}}}},e.transformCrossOriginEvent=function(t,i){var r=this,o;switch(i.type){case ce.FullSnapshot:{this.crossOriginIframeMirror.reset(t),this.crossOriginIframeStyleMirror.reset(t),this.replaceIdOnNode(i.data.node,t);var s=i.data.node.id;return this.crossOriginIframeRootIdMap.set(t,s),this.patchRootIdOnNode(i.data.node,s),{timestamp:i.timestamp,type:ce.IncrementalSnapshot,data:{source:Z.Mutation,adds:[{parentId:this.mirror.getId(t),nextId:null,node:i.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case ce.Meta:case ce.Load:case ce.DomContentLoaded:return!1;case ce.Plugin:return i;case ce.Custom:return this.replaceIds(i.data.payload,t,["id","parentId","previousId","nextId"]),i;case ce.IncrementalSnapshot:switch(i.data.source){case Z.Mutation:return i.data.adds.forEach(function(a){r.replaceIds(a,t,["parentId","nextId","previousId"]),r.replaceIdOnNode(a.node,t);var c=r.crossOriginIframeRootIdMap.get(t);c&&r.patchRootIdOnNode(a.node,c)}),i.data.removes.forEach(function(a){r.replaceIds(a,t,["parentId","id"])}),i.data.attributes.forEach(function(a){r.replaceIds(a,t,["id"])}),i.data.texts.forEach(function(a){r.replaceIds(a,t,["id"])}),i;case Z.Drag:case Z.TouchMove:case Z.MouseMove:return i.data.positions.forEach(function(a){r.replaceIds(a,t,["id"])}),i;case Z.ViewportResize:return!1;case Z.MediaInteraction:case Z.MouseInteraction:case Z.Scroll:case Z.CanvasMutation:case Z.Input:return this.replaceIds(i.data,t,["id"]),i;case Z.StyleSheetRule:case Z.StyleDeclaration:return this.replaceIds(i.data,t,["id"]),this.replaceStyleIds(i.data,t,["styleId"]),i;case Z.Font:return i;case Z.Selection:return i.data.ranges.forEach(function(a){r.replaceIds(a,t,["start","end"])}),i;case Z.AdoptedStyleSheet:return this.replaceIds(i.data,t,["id"]),this.replaceStyleIds(i.data,t,["styleIds"]),(o=i.data.styles)==null||o.forEach(function(a){r.replaceStyleIds(a,t,["styleId"])}),i}}return!1},e.replace=function(t,i,r,o){for(var s=H(o),a;!(a=s()).done;){var c=a.value;!Array.isArray(i[c])&&typeof i[c]!="number"||(Array.isArray(i[c])?i[c]=t.getIds(r,i[c]):i[c]=t.getId(r,i[c]))}return i},e.replaceIds=function(t,i,r){return this.replace(this.crossOriginIframeMirror,t,i,r)},e.replaceStyleIds=function(t,i,r){return this.replace(this.crossOriginIframeStyleMirror,t,i,r)},e.replaceIdOnNode=function(t,i){var r=this;this.replaceIds(t,i,["id","rootId"]),"childNodes"in t&&t.childNodes.forEach(function(o){r.replaceIdOnNode(o,i)})},e.patchRootIdOnNode=function(t,i){var r=this;t.type!==zv.Document&&!t.rootId&&(t.rootId=i),"childNodes"in t&&t.childNodes.forEach(function(o){r.patchRootIdOnNode(o,i)})},n}(),bR=function(){function n(t){z(this,"shadowDoms",new WeakSet),z(this,"mutationCb"),z(this,"scrollCb"),z(this,"bypassOptions"),z(this,"mirror"),z(this,"restoreHandlers",[]),this.mutationCb=t.mutationCb,this.scrollCb=t.scrollCb,this.bypassOptions=t.bypassOptions,this.mirror=t.mirror,this.init()}var e=n.prototype;return e.init=function(){this.reset(),this.patchAttachShadow(Element,document)},e.addShadowRoot=function(t,i){var r=this;if(Co(t)&&!this.shadowDoms.has(t)){this.shadowDoms.add(t);var o=Kv(me({},this.bypassOptions,{doc:i,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),t);this.restoreHandlers.push(function(){return o.disconnect()}),this.restoreHandlers.push(Yv(me({},this.bypassOptions,{scrollCb:this.scrollCb,doc:t,mirror:this.mirror}))),setTimeout(function(){t.adoptedStyleSheets&&t.adoptedStyleSheets.length>0&&r.bypassOptions.stylesheetManager.adoptStyleSheets(t.adoptedStyleSheets,r.mirror.getId(se.host(t))),r.restoreHandlers.push(Jv({mirror:r.mirror,stylesheetManager:r.bypassOptions.stylesheetManager},t))},0)}},e.observeAttachShadow=function(t){!t.contentWindow||!t.contentDocument||this.patchAttachShadow(t.contentWindow.Element,t.contentDocument)},e.patchAttachShadow=function(t,i){var r=this;this.restoreHandlers.push(Rr(t.prototype,"attachShadow",function(o){return function(s){var a=o.call(this,s),c=se.shadowRoot(this);return c&&Vv(this)&&r.addShadowRoot(c,i),a}}))},e.reset=function(){this.restoreHandlers.forEach(function(t){try{t()}catch{}}),this.restoreHandlers=[],this.shadowDoms=new WeakSet},n}(),Ar="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",_R=typeof Uint8Array>"u"?[]:new Uint8Array(256),Ma=0;Ma<Ar.length;Ma++)_R[Ar.charCodeAt(Ma)]=Ma;var kR=function(n){var e=new Uint8Array(n),t,i=e.length,r="";for(t=0;t<i;t+=3)r+=Ar[e[t]>>2],r+=Ar[(e[t]&3)<<4|e[t+1]>>4],r+=Ar[(e[t+1]&15)<<2|e[t+2]>>6],r+=Ar[e[t+2]&63];return i%3===2?r=r.substring(0,r.length-1)+"=":i%3===1&&(r=r.substring(0,r.length-2)+"=="),r},Qv=new Map;function SR(n,e){var t=Qv.get(n);return t||(t=new Map,Qv.set(n,t)),t.has(e)||t.set(e,[]),t.get(e)}var e0=function(n,e,t){if(!(!n||!(n0(n,e)||(typeof n>"u"?"undefined":oe(n))==="object"))){var i=n.constructor.name,r=SR(t,i),o=r.indexOf(n);return o===-1&&(o=r.length,r.push(n)),o}};function Na(n,e,t){if(ne(n,Array))return n.map(function(m){return Na(m,e,t)});if(n===null)return n;if(ne(n,Float32Array)||ne(n,Float64Array)||ne(n,Int32Array)||ne(n,Uint32Array)||ne(n,Uint8Array)||ne(n,Uint16Array)||ne(n,Int16Array)||ne(n,Int8Array)||ne(n,Uint8ClampedArray)){var i=n.constructor.name;return{rr_type:i,args:[Object.values(n)]}}else if(ne(n,ArrayBuffer)){var r=n.constructor.name,o=kR(n);return{rr_type:r,base64:o}}else if(ne(n,DataView)){var s=n.constructor.name;return{rr_type:s,args:[Na(n.buffer,e,t),n.byteOffset,n.byteLength]}}else if(ne(n,HTMLImageElement)){var a=n.constructor.name,c=n.src;return{rr_type:a,src:c}}else if(ne(n,HTMLCanvasElement)){var u="HTMLImageElement",l=n.toDataURL();return{rr_type:u,src:l}}else if(ne(n,ImageData)){var d=n.constructor.name;return{rr_type:d,args:[Na(n.data,e,t),n.width,n.height]}}else if(n0(n,e)||(typeof n>"u"?"undefined":oe(n))==="object"){var h=n.constructor.name,p=e0(n,e,t);return{rr_type:h,index:p}}return n}var t0=function(n,e,t){return n.map(function(i){return Na(i,e,t)})},n0=function(n,e){var t=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"],i=t.filter(function(r){return typeof e[r]=="function"});return!!i.find(function(r){return ne(n,e[r])})};function wR(n,e,t,i){for(var r=function(){var u=c.value;try{if(typeof e.CanvasRenderingContext2D.prototype[u]!="function")return"continue";var l=Rr(e.CanvasRenderingContext2D.prototype,u,function(h){return function(){for(var p=this,m=arguments.length,f=new Array(m),g=0;g<m;g++)f[g]=arguments[g];return Rt(this.canvas,t,i,!0)||setTimeout(function(){var y=t0(f,e,p);n(p.canvas,{type:Pr["2D"],property:u,args:y})},0),h.apply(this,f)}});o.push(l)}catch{var d=Ia(e.CanvasRenderingContext2D.prototype,u,{set:function(h){n(this.canvas,{type:Pr["2D"],property:u,args:[h],setter:!0})}});o.push(d)}},o=[],s=Object.getOwnPropertyNames(e.CanvasRenderingContext2D.prototype),a=H(s),c;!(c=a()).done;)r();return function(){o.forEach(function(u){return u()})}}function CR(n){return n==="experimental-webgl"?"webgl":n}function i0(n,e,t,i){var r=[];try{var o=Rr(n.HTMLCanvasElement.prototype,"getContext",function(s){return function(a){for(var c=arguments.length,u=new Array(c>1?c-1:0),l=1;l<c;l++)u[l-1]=arguments[l];if(!Rt(this,e,t,!0)){var d=CR(a);if("__context"in this||(this.__context=d),i&&["webgl","webgl2"].includes(d))if(u[0]&&oe(u[0])==="object"){var h=u[0];h.preserveDrawingBuffer||(h.preserveDrawingBuffer=!0)}else u.splice(0,1,{preserveDrawingBuffer:!0})}return s.apply(this,[].concat([a],u))}});r.push(o)}catch{console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return function(){r.forEach(function(s){return s()})}}function r0(n,e,t,i,r,o){for(var s=function(){var d=l.value;if(["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(d))return"continue";try{if(typeof n[d]!="function")return"continue";var h=Rr(n,d,function(m){return function(){for(var f=arguments.length,g=new Array(f),y=0;y<f;y++)g[y]=arguments[y];var b=m.apply(this,g);if(e0(b,o,this),"tagName"in this.canvas&&!Rt(this.canvas,i,r,!0)){var S=t0(g,o,this),w={type:e,property:d,args:S};t(this.canvas,w)}return b}});a.push(h)}catch{var p=Ia(n,d,{set:function(m){t(this.canvas,{type:e,property:d,args:[m],setter:!0})}});a.push(p)}},a=[],c=Object.getOwnPropertyNames(n),u=H(c),l;!(l=u()).done;)s();return a}function TR(n,e,t,i){var r,o=[];if((r=o).push.apply(r,[].concat(r0(e.WebGLRenderingContext.prototype,Pr.WebGL,n,t,i,e))),typeof e.WebGL2RenderingContext<"u"){var s;(s=o).push.apply(s,[].concat(r0(e.WebGL2RenderingContext.prototype,Pr.WebGL2,n,t,i,e)))}return function(){o.forEach(function(a){return a()})}}var o0="KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=",xR=function(n){return Uint8Array.from(atob(n),function(e){return e.charCodeAt(0)})},s0=typeof window<"u"&&window.Blob&&new Blob([xR(o0)],{type:"text/javascript;charset=utf-8"});function ER(n){var e;try{if(e=s0&&(window.URL||window.webkitURL).createObjectURL(s0),!e)throw"";var t=new Worker(e,{name:n==null?void 0:n.name});return t.addEventListener("error",function(){(window.URL||window.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+o0,{name:n==null?void 0:n.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}var IR=function(){function n(t){var i=this;z(this,"pendingCanvasMutations",new Map),z(this,"rafStamps",{latestId:0,invokeId:null}),z(this,"mirror"),z(this,"mutationCb"),z(this,"resetObservers"),z(this,"frozen",!1),z(this,"locked",!1),z(this,"processMutation",function(d,h){var p=i.rafStamps.invokeId&&i.rafStamps.latestId!==i.rafStamps.invokeId;(p||!i.rafStamps.invokeId)&&(i.rafStamps.invokeId=i.rafStamps.latestId),i.pendingCanvasMutations.has(d)||i.pendingCanvasMutations.set(d,[]),i.pendingCanvasMutations.get(d).push(h)});var r=t.sampling,o=r===void 0?"all":r,s=t.win,a=t.blockClass,c=t.blockSelector,u=t.recordCanvas,l=t.dataURLOptions;this.mutationCb=t.mutationCb,this.mirror=t.mirror,u&&o==="all"&&this.initCanvasMutationObserver(s,a,c),u&&typeof o=="number"&&this.initCanvasFPSObserver(o,s,a,c,{dataURLOptions:l})}var e=n.prototype;return e.reset=function(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()},e.freeze=function(){this.frozen=!0},e.unfreeze=function(){this.frozen=!1},e.lock=function(){this.locked=!0},e.unlock=function(){this.locked=!1},e.initCanvasFPSObserver=function(t,i,r,o,s){var a=this,c=i0(i,r,o,!0),u=new Map,l=new ER;l.onmessage=function(g){var y=g.data.id;if(u.set(y,!1),"base64"in g.data){var b=g.data,S=b.base64,w=b.type,k=b.width,C=b.height;a.mutationCb({id:y,type:Pr["2D"],commands:[{property:"clearRect",args:[0,0,k,C]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:S}],type:w}]},0,0]}]})}};var d=1e3/t,h=0,p,m=function(){var g=[];return i.document.querySelectorAll("canvas").forEach(function(y){Rt(y,r,o,!0)||g.push(y)}),g},f=function(g){if(h&&g-h<d){p=requestAnimationFrame(f);return}h=g;var y=a;m().forEach(Xu(function(b){var S,w,k,C;return So(this,function(x){switch(x.label){case 0:return w=y.mirror.getId(b),u.get(w)?[2]:b.width===0||b.height===0?[2]:(u.set(w,!0),["webgl","webgl2"].includes(b.__context)&&(k=b.getContext(b.__context),((S=k==null?void 0:k.getContextAttributes())==null?void 0:S.preserveDrawingBuffer)===!1&&k.clear(k.COLOR_BUFFER_BIT)),[4,createImageBitmap(b)]);case 1:return C=x.sent(),l.postMessage({id:w,bitmap:C,width:b.width,height:b.height,dataURLOptions:s.dataURLOptions},[C]),[2]}})})),p=requestAnimationFrame(f)};p=requestAnimationFrame(f),this.resetObservers=function(){c(),cancelAnimationFrame(p)}},e.initCanvasMutationObserver=function(t,i,r){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();var o=i0(t,i,r,!1),s=wR(this.processMutation.bind(this),t,i,r),a=TR(this.processMutation.bind(this),t,i,r);this.resetObservers=function(){o(),s(),a()}},e.startPendingCanvasMutationFlusher=function(){var t=this;requestAnimationFrame(function(){return t.flushPendingCanvasMutations()})},e.startRAFTimestamping=function(){var t=this,i=function(r){t.rafStamps.latestId=r,requestAnimationFrame(i)};requestAnimationFrame(i)},e.flushPendingCanvasMutations=function(){var t=this;this.pendingCanvasMutations.forEach(function(i,r){var o=t.mirror.getId(r);t.flushPendingCanvasMutationFor(r,o)}),requestAnimationFrame(function(){return t.flushPendingCanvasMutations()})},e.flushPendingCanvasMutationFor=function(t,i){if(!(this.frozen||this.locked)){var r=this.pendingCanvasMutations.get(t);if(!(!r||i===-1)){var o=r.map(function(a){a.type;var c=_o(a,["type"]);return c}),s=r[0].type;this.mutationCb({id:i,type:s,commands:o}),this.pendingCanvasMutations.delete(t)}}},n}(),RR=function(){function n(t){z(this,"trackedLinkElements",new WeakSet),z(this,"mutationCb"),z(this,"adoptedStyleSheetCb"),z(this,"styleMirror",new XI),this.mutationCb=t.mutationCb,this.adoptedStyleSheetCb=t.adoptedStyleSheetCb}var e=n.prototype;return e.attachLinkElement=function(t,i){"_cssText"in i.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:i.id,attributes:i.attributes}]}),this.trackLinkElement(t)},e.trackLinkElement=function(t){this.trackedLinkElements.has(t)||(this.trackedLinkElements.add(t),this.trackStylesheetInLinkElement(t))},e.adoptStyleSheets=function(t,i){var r,o=function(){var l=u.value,d=void 0;r.styleMirror.has(l)?d=r.styleMirror.getId(l):(d=r.styleMirror.add(l),a.push({styleId:d,rules:Array.from(l.rules||CSSRule,function(h,p){return{rule:Cm(h,l.href),index:p}})})),s.styleIds.push(d)};if(t.length!==0){for(var s={id:i,styleIds:[]},a=[],c=H(t),u;!(u=c()).done;)r=this,o();a.length>0&&(s.styles=a),this.adoptedStyleSheetCb(s)}},e.reset=function(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet},e.trackStylesheetInLinkElement=function(t){},n}(),PR=function(){function n(){z(this,"nodeMap",new WeakMap),z(this,"active",!1)}var e=n.prototype;return e.inOtherBuffer=function(t,i){var r=this.nodeMap.get(t);return r&&Array.from(r).some(function(o){return o!==i})},e.add=function(t,i){var r=this;this.active||(this.active=!0,requestAnimationFrame(function(){r.nodeMap=new WeakMap,r.active=!1})),this.nodeMap.set(t,(this.nodeMap.get(t)||new Set).add(i))},e.destroy=function(){},n}(),He,Da,vd,La=!1;try{if(Array.from([1],function(n){return n*2})[0]!==2){var yd=document.createElement("iframe");document.body.appendChild(yd),Array.from=((ym=yd.contentWindow)==null?void 0:ym.Array.from)||Array.from,document.body.removeChild(yd)}}catch{}var rn=I1();function si(n){n===void 0&&(n={});var e=n.emit,t=n.checkoutEveryNms,i=n.checkoutEveryNth,r=n.blockClass,o=r===void 0?"rr-block":r,s=n.blockSelector,a=s===void 0?null:s,c=n.ignoreClass,u=c===void 0?"rr-ignore":c,l=n.ignoreSelector,d=l===void 0?null:l,h=n.maskTextClass,p=h===void 0?"rr-mask":h,m=n.maskTextSelector,f=m===void 0?null:m,g=n.inlineStylesheet,y=g===void 0?!0:g,b=n.maskAllInputs,S=n.maskInputOptions,w=n.slimDOMOptions,k=n.maskInputFn,C=n.maskTextFn,x=n.hooks,I=n.packFn,P=n.sampling,D=P===void 0?{}:P,A=n.dataURLOptions,L=A===void 0?{}:A,V=n.mousemoveWait,Y=n.recordDOM,O=Y===void 0?!0:Y,F=n.recordCanvas,X=F===void 0?!1:F,K=n.recordCrossOriginIframes,Q=K===void 0?!1:K,Ce=n.recordAfter,Ge=Ce===void 0?n.recordAfter==="DOMContentLoaded"?n.recordAfter:"load":Ce,Ie=n.userTriggeredOnInput,dt=Ie===void 0?!1:Ie,Me=n.collectFonts,Pe=Me===void 0?!1:Me,ie=n.inlineImages,Ze=ie===void 0?!1:ie,kt=n.plugins,Gt=n.keepIframeSrcFn,ur=Gt===void 0?function(){return!1}:Gt,ye=n.ignoreCSSAttributes,Nt=ye===void 0?new Set([]):ye,lr=n.errorHandler;iR(lr);var yn=Q?window.parent===window:!0,Dn=!1;if(!yn)try{window.parent.document&&(Dn=!1)}catch{Dn=!0}if(yn&&!e)throw new Error("emit function is required");if(!yn&&!Dn)return function(){};V!==void 0&&D.mousemove===void 0&&(D.mousemove=V),rn.reset();var Zn=b===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:S!==void 0?S:{password:!0},Li=w===!0||w==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:w==="all",headMetaDescKeywords:w==="all",headTitleMutations:w==="all"}:w||{};YI();var mo,dr=0,Qn=function(Oe){for(var tn=H(kt||[]),J;!(J=tn()).done;){var $e=J.value;$e.eventProcessor&&(Oe=$e.eventProcessor(Oe))}return I&&!Dn&&(Oe=I(Oe)),Oe};He=function(Oe,tn){var J,$e=Oe;if($e.timestamp=Ra(),(J=qi[0])!=null&&J.isFrozen()&&$e.type!==ce.FullSnapshot&&!($e.type===ce.IncrementalSnapshot&&$e.data.source===Z.Mutation)&&qi.forEach(function(h4){return h4.unfreeze()}),yn)e==null||e(Qn($e),tn);else if(Dn){var u4={type:"rrweb",event:Qn($e),origin:window.location.origin,isCheckout:tn};window.parent.postMessage(u4,"*")}if($e.type===ce.FullSnapshot)mo=$e,dr=0;else if($e.type===ce.IncrementalSnapshot){if($e.data.source===Z.Mutation&&$e.data.isAttachIframe)return;dr++;var l4=i&&dr>=i,d4=t&&$e.timestamp-mo.timestamp>t;(l4||d4)&&Da(!0)}};for(var hr=function(Oe){He({type:ce.IncrementalSnapshot,data:me({source:Z.Mutation},Oe)})},Cw=function(Oe){return He({type:ce.IncrementalSnapshot,data:me({source:Z.Scroll},Oe)})},Tw=function(Oe){return He({type:ce.IncrementalSnapshot,data:me({source:Z.CanvasMutation},Oe)})},a4=function(Oe){return He({type:ce.IncrementalSnapshot,data:me({source:Z.AdoptedStyleSheet},Oe)})},pr=new RR({mutationCb:hr,adoptedStyleSheetCb:a4}),fr=new yR({mirror:rn,mutationCb:hr,stylesheetManager:pr,recordCrossOriginIframes:Q,wrappedEmit:He}),c4=H(kt||[]),xw;!(xw=c4()).done;){var Ew=xw.value;Ew.getMirror&&Ew.getMirror({nodeMirror:rn,crossOriginIframeMirror:fr.crossOriginIframeMirror,crossOriginIframeStyleMirror:fr.crossOriginIframeStyleMirror})}var lf=new PR;vd=new IR({recordCanvas:X,mutationCb:Tw,win:window,blockClass:o,blockSelector:a,mirror:rn,sampling:D.canvas,dataURLOptions:L});var Mu=new bR({mutationCb:hr,scrollCb:Cw,bypassOptions:{blockClass:o,blockSelector:a,maskTextClass:p,maskTextSelector:f,inlineStylesheet:y,maskInputOptions:Zn,dataURLOptions:L,maskTextFn:C,maskInputFn:k,recordCanvas:X,inlineImages:Ze,sampling:D,slimDOMOptions:Li,iframeManager:fr,stylesheetManager:pr,canvasManager:vd,keepIframeSrcFn:ur,processedNodeManager:lf},mirror:rn});Da=function(Oe){if(Oe===void 0&&(Oe=!1),!!O){He({type:ce.Meta,data:{href:window.location.href,width:Dv(),height:Nv()}},Oe),pr.reset(),Mu.init(),qi.forEach(function(J){return J.lock()});var tn=Z1(document,{mirror:rn,blockClass:o,blockSelector:a,maskTextClass:p,maskTextSelector:f,inlineStylesheet:y,maskAllInputs:Zn,maskTextFn:C,maskInputFn:k,slimDOM:Li,dataURLOptions:L,recordCanvas:X,inlineImages:Ze,onSerialize:function(J){Fv(J,rn)&&fr.addIframe(J),Bv(J,rn)&&pr.trackLinkElement(J),md(J)&&Mu.addShadowRoot(se.shadowRoot(J),document)},onIframeLoad:function(J,$e){fr.attachIframe(J,$e),Mu.observeAttachShadow(J)},onStylesheetLoad:function(J,$e){pr.attachLinkElement(J,$e)},keepIframeSrcFn:ur});if(!tn)return console.warn("Failed to snapshot the document");He({type:ce.FullSnapshot,data:{node:tn,initialOffset:Mv(window)}},Oe),qi.forEach(function(J){return J.unlock()}),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&pr.adoptStyleSheets(document.adoptedStyleSheets,rn.getId(document))}};try{var ws=[],Iw=function(Oe){var tn;return he(vR)({mutationCb:hr,mousemoveCb:function(J,$e){return He({type:ce.IncrementalSnapshot,data:{source:$e,positions:J}})},mouseInteractionCb:function(J){return He({type:ce.IncrementalSnapshot,data:me({source:Z.MouseInteraction},J)})},scrollCb:Cw,viewportResizeCb:function(J){return He({type:ce.IncrementalSnapshot,data:me({source:Z.ViewportResize},J)})},inputCb:function(J){return He({type:ce.IncrementalSnapshot,data:me({source:Z.Input},J)})},mediaInteractionCb:function(J){return He({type:ce.IncrementalSnapshot,data:me({source:Z.MediaInteraction},J)})},styleSheetRuleCb:function(J){return He({type:ce.IncrementalSnapshot,data:me({source:Z.StyleSheetRule},J)})},styleDeclarationCb:function(J){return He({type:ce.IncrementalSnapshot,data:me({source:Z.StyleDeclaration},J)})},canvasMutationCb:Tw,fontCb:function(J){return He({type:ce.IncrementalSnapshot,data:me({source:Z.Font},J)})},selectionCb:function(J){He({type:ce.IncrementalSnapshot,data:me({source:Z.Selection},J)})},customElementCb:function(J){He({type:ce.IncrementalSnapshot,data:me({source:Z.CustomElement},J)})},blockClass:o,ignoreClass:u,ignoreSelector:d,maskTextClass:p,maskTextSelector:f,maskInputOptions:Zn,inlineStylesheet:y,sampling:D,recordDOM:O,recordCanvas:X,inlineImages:Ze,userTriggeredOnInput:dt,collectFonts:Pe,doc:Oe,maskInputFn:k,maskTextFn:C,keepIframeSrcFn:ur,blockSelector:a,slimDOMOptions:Li,dataURLOptions:L,mirror:rn,iframeManager:fr,stylesheetManager:pr,shadowDomManager:Mu,processedNodeManager:lf,canvasManager:vd,ignoreCSSAttributes:Nt,plugins:((tn=kt==null?void 0:kt.filter(function(J){return J.observer}))==null?void 0:tn.map(function(J){return{observer:J.observer,options:J.options,callback:function($e){return He({type:ce.Plugin,data:{plugin:J.name,payload:$e}})}}}))||[]},x)};fr.addLoadListener(function(Oe){try{ws.push(Iw(Oe.contentDocument))}catch(tn){console.warn(tn)}});var df=function(){Da(),ws.push(Iw(document)),La=!0};return document.readyState==="interactive"||document.readyState==="complete"?df():(ws.push(It("DOMContentLoaded",function(){He({type:ce.DomContentLoaded,data:{}}),Ge==="DOMContentLoaded"&&df()})),ws.push(It("load",function(){He({type:ce.Load,data:{}}),Ge==="load"&&df()},window))),function(){ws.forEach(function(Oe){return Oe()}),lf.destroy(),La=!1,rR()}}catch(Oe){console.warn(Oe)}}si.addCustomEvent=function(n,e){if(!La)throw new Error("please add custom event after start recording");He({type:ce.Custom,data:{tag:n,payload:e}})},si.freezePage=function(){qi.forEach(function(n){return n.freeze()})},si.takeFullSnapshot=function(n){if(!La)throw new Error("please take full snapshot after start recording");Da(n)},si.mirror=rn;var a0;(function(n){n[n.NotStarted=0]="NotStarted",n[n.Running=1]="Running",n[n.Stopped=2]="Stopped"})(a0||(a0={})),si.addCustomEvent,si.freezePage,si.takeFullSnapshot;var c0=W.setImmediate,ai,bd,_d,u0=Object.prototype.toString,OR=typeof c0<"u"?function(n){return c0(n)}:setTimeout;try{Object.defineProperty({},"x",{}),ai=function(n,e,t,i){return Object.defineProperty(n,e,{value:t,writable:!0,configurable:i!==!1})}}catch{ai=function(n,e,t){return n[e]=t,n}}_d=function(){var n,e,t;function i(r,o){this.fn=r,this.self=o,this.next=void 0}return{add:function(r,o){t=new i(r,o),e?e.next=t:n=t,e=t,t=void 0},drain:function(){var r=n;for(n=e=bd=void 0;r;)r.fn.call(r.self),r=r.next}}}();function Ua(n,e){_d.add(n,e),bd||(bd=OR(_d.drain))}function l0(n){var e,t=typeof n;return n!==null&&(t==="object"||t==="function")&&(e=n.then),typeof e=="function"?e:!1}function kd(){for(var n=0;n<this.chain.length;n++)AR(this,this.state===1?this.chain[n].success:this.chain[n].failure,this.chain[n]);this.chain.length=0}function AR(n,e,t){var i,r;try{e===!1?t.reject(n.msg):(e===!0?i=n.msg:i=e.call(void 0,n.msg),i===t.promise?t.reject(TypeError("Promise-chain cycle")):(r=l0(i))?r.call(i,t.resolve,t.reject):t.resolve(i))}catch(o){t.reject(o)}}function d0(n){var e,t=this;if(!t.triggered){t.triggered=!0,t.def&&(t=t.def);try{(e=l0(n))?Ua(function(){var i=new p0(t);try{e.call(n,function(){d0.apply(i,arguments)},function(){qo.apply(i,arguments)})}catch(r){qo.call(i,r)}}):(t.msg=n,t.state=1,t.chain.length>0&&Ua(kd,t))}catch(i){qo.call(new p0(t),i)}}}function qo(n){var e=this;e.triggered||(e.triggered=!0,e.def&&(e=e.def),e.msg=n,e.state=2,e.chain.length>0&&Ua(kd,e))}function h0(n,e,t,i){for(var r=0;r<e.length;r++)(function(o){n.resolve(e[o]).then(function(s){t(o,s)},i)})(r)}function p0(n){this.def=n,this.triggered=!1}function MR(n){this.promise=n,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function ci(n){if(typeof n!="function")throw TypeError("Not a function");if(this.__NPO__!==0)throw TypeError("Not a promise");this.__NPO__=1;var e=new MR(this);this.then=function(t,i){var r={success:typeof t=="function"?t:!0,failure:typeof i=="function"?i:!1};return r.promise=new this.constructor(function(o,s){if(typeof o!="function"||typeof s!="function")throw TypeError("Not a function");r.resolve=o,r.reject=s}),e.chain.push(r),e.state!==0&&Ua(kd,e),r.promise},this.catch=function(t){return this.then(void 0,t)};try{n.call(void 0,function(t){d0.call(e,t)},function(t){qo.call(e,t)})}catch(t){qo.call(e,t)}}var f0=ai({},"constructor",ci,!1);ci.prototype=f0,ai(f0,"__NPO__",0,!1),ai(ci,"resolve",function(n){var e=this;return n&&typeof n=="object"&&n.__NPO__===1?n:new e(function(t,i){if(typeof t!="function"||typeof i!="function")throw TypeError("Not a function");t(n)})}),ai(ci,"reject",function(n){return new this(function(e,t){if(typeof e!="function"||typeof t!="function")throw TypeError("Not a function");t(n)})}),ai(ci,"all",function(n){var e=this;return u0.call(n)!=="[object Array]"?e.reject(TypeError("Not an array")):n.length===0?e.resolve([]):new e(function(t,i){if(typeof t!="function"||typeof i!="function")throw TypeError("Not a function");var r=n.length,o=Array(r),s=0;h0(e,n,function(a,c){o[a]=c,++s===r&&t(o)},i)})}),ai(ci,"race",function(n){var e=this;return u0.call(n)!=="[object Array]"?e.reject(TypeError("Not an array")):new e(function(t,i){if(typeof t!="function"||typeof i!="function")throw TypeError("Not a function");h0(e,n,function(r,o){t(o)},i)})});var ke;typeof Promise<"u"&&Promise.toString().indexOf("[native code]")!==-1?ke=Promise:ke=ci;var on={DEBUG:!1,LIB_VERSION:"2.68.0"},Wo=24*60*60*1e3,Sd=8*1e3,Fa=Array.prototype,NR=Function.prototype,m0=Object.prototype,Wi=Fa.slice,Go=m0.toString,Ba=m0.hasOwnProperty,ot=W.console,ui=W.navigator,be=W.document,ja=W.opera,g0=W.screen,Vn=ui.userAgent,wd=NR.bind,v0=Fa.forEach,y0=Fa.indexOf,b0=Fa.map,DR=Array.isArray,Cd={},v={trim:function(n){return n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}},_e={log:function(){if(on.DEBUG&&!v.isUndefined(ot)&&ot)try{ot.log.apply(ot,arguments)}catch{v.each(arguments,function(n){ot.log(n)})}},warn:function(){if(on.DEBUG&&!v.isUndefined(ot)&&ot){var n=["Mixpanel warning:"].concat(v.toArray(arguments));try{ot.warn.apply(ot,n)}catch{v.each(n,function(e){ot.warn(e)})}}},error:function(){if(on.DEBUG&&!v.isUndefined(ot)&&ot){var n=["Mixpanel error:"].concat(v.toArray(arguments));try{ot.error.apply(ot,n)}catch{v.each(n,function(e){ot.error(e)})}}},critical:function(){if(!v.isUndefined(ot)&&ot){var n=["Mixpanel error:"].concat(v.toArray(arguments));try{ot.error.apply(ot,n)}catch{v.each(n,function(e){ot.error(e)})}}}},Td=function(n,e){return function(){return arguments[0]="["+e+"] "+arguments[0],n.apply(_e,arguments)}},Gi=function(n){return{log:Td(_e.log,n),error:Td(_e.error,n),critical:Td(_e.critical,n)}},xd=function(n){return function(){try{return n.apply(this,arguments)}catch(e){_e.critical("Implementation error. Please turn on debug and contact support@mixpanel.com."),on.DEBUG&&_e.critical(e)}}},_0=function(n){var e=n.prototype;for(var t in e)typeof e[t]=="function"&&(e[t]=xd(e[t]))};v.bind=function(n,e){var t,i;if(wd&&n.bind===wd)return wd.apply(n,Wi.call(arguments,1));if(!v.isFunction(n))throw new TypeError;return t=Wi.call(arguments,2),i=function(){if(!(this instanceof i))return n.apply(e,t.concat(Wi.call(arguments)));var r={};r.prototype=n.prototype;var o=new r;r.prototype=null;var s=n.apply(o,t.concat(Wi.call(arguments)));return Object(s)===s?s:o},i},v.each=function(n,e,t){if(n!=null){if(v0&&n.forEach===v0)n.forEach(e,t);else if(n.length===+n.length){for(var i=0,r=n.length;i<r;i++)if(i in n&&e.call(t,n[i],i,n)===Cd)return}else for(var o in n)if(Ba.call(n,o)&&e.call(t,n[o],o,n)===Cd)return}},v.extend=function(n){return v.each(Wi.call(arguments,1),function(e){for(var t in e)e[t]!==void 0&&(n[t]=e[t])}),n},v.isArray=DR||function(n){return Go.call(n)==="[object Array]"},v.isFunction=function(n){try{return/^\s*\bfunction\b/.test(n)}catch{return!1}},v.isArguments=function(n){return!!(n&&Ba.call(n,"callee"))},v.toArray=function(n){return n?n.toArray?n.toArray():v.isArray(n)||v.isArguments(n)?Wi.call(n):v.values(n):[]},v.map=function(n,e,t){if(b0&&n.map===b0)return n.map(e,t);var i=[];return v.each(n,function(r){i.push(e.call(t,r))}),i},v.keys=function(n){var e=[];return n===null||v.each(n,function(t,i){e[e.length]=i}),e},v.values=function(n){var e=[];return n===null||v.each(n,function(t){e[e.length]=t}),e},v.include=function(n,e){var t=!1;return n===null?t:y0&&n.indexOf===y0?n.indexOf(e)!=-1:(v.each(n,function(i){if(t||(t=i===e))return Cd}),t)},v.includes=function(n,e){return n.indexOf(e)!==-1},v.inherit=function(n,e){return n.prototype=new e,n.prototype.constructor=n,n.superclass=e.prototype,n},v.isObject=function(n){return n===Object(n)&&!v.isArray(n)},v.isEmptyObject=function(n){if(v.isObject(n)){for(var e in n)if(Ba.call(n,e))return!1;return!0}return!1},v.isUndefined=function(n){return n===void 0},v.isString=function(n){return Go.call(n)=="[object String]"},v.isDate=function(n){return Go.call(n)=="[object Date]"},v.isNumber=function(n){return Go.call(n)=="[object Number]"},v.isElement=function(n){return!!(n&&n.nodeType===1)},v.encodeDates=function(n){return v.each(n,function(e,t){v.isDate(e)?n[t]=v.formatDate(e):v.isObject(e)&&(n[t]=v.encodeDates(e))}),n},v.timestamp=function(){return Date.now=Date.now||function(){return+new Date},Date.now()},v.formatDate=function(n){function e(t){return t<10?"0"+t:t}return n.getUTCFullYear()+"-"+e(n.getUTCMonth()+1)+"-"+e(n.getUTCDate())+"T"+e(n.getUTCHours())+":"+e(n.getUTCMinutes())+":"+e(n.getUTCSeconds())},v.strip_empty_properties=function(n){var e={};return v.each(n,function(t,i){v.isString(t)&&t.length>0&&(e[i]=t)}),e},v.truncate=function(n,e){var t;return typeof n=="string"?t=n.slice(0,e):v.isArray(n)?(t=[],v.each(n,function(i){t.push(v.truncate(i,e))})):v.isObject(n)?(t={},v.each(n,function(i,r){t[r]=v.truncate(i,e)})):t=n,t},v.JSONEncode=function(){return function(n){var e=n,t=function(r){var o=/[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,s={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};return o.lastIndex=0,o.test(r)?'"'+r.replace(o,function(a){var c=s[a];return typeof c=="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+r+'"'},i=function(r,o){var s="",a=" ",c=0,u="",l="",d=0,h=s,p=[],m=o[r];switch(m&&typeof m=="object"&&typeof m.toJSON=="function"&&(m=m.toJSON(r)),typeof m){case"string":return t(m);case"number":return isFinite(m)?String(m):"null";case"boolean":case"null":return String(m);case"object":if(!m)return"null";if(s+=a,p=[],Go.apply(m)==="[object Array]"){for(d=m.length,c=0;c<d;c+=1)p[c]=i(c,m)||"null";return l=p.length===0?"[]":s?`[
74
- `+s+p.join(`,
75
- `+s)+`
76
- `+h+"]":"["+p.join(",")+"]",s=h,l}for(u in m)Ba.call(m,u)&&(l=i(u,m),l&&p.push(t(u)+(s?": ":":")+l));return l=p.length===0?"{}":s?"{"+p.join(",")+h+"}":"{"+p.join(",")+"}",s=h,l}};return i("",{"":e})}}(),v.JSONDecode=function(){var n,e,t={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
77
- `,r:"\r",t:" "},i,r=function(p){var m=new SyntaxError(p);throw m.at=n,m.text=i,m},o=function(p){return p&&p!==e&&r("Expected '"+p+"' instead of '"+e+"'"),e=i.charAt(n),n+=1,e},s=function(){var p,m="";for(e==="-"&&(m="-",o("-"));e>="0"&&e<="9";)m+=e,o();if(e===".")for(m+=".";o()&&e>="0"&&e<="9";)m+=e;if(e==="e"||e==="E")for(m+=e,o(),(e==="-"||e==="+")&&(m+=e,o());e>="0"&&e<="9";)m+=e,o();if(p=+m,!isFinite(p))r("Bad number");else return p},a=function(){var p,m,f="",g;if(e==='"')for(;o();){if(e==='"')return o(),f;if(e==="\\")if(o(),e==="u"){for(g=0,m=0;m<4&&(p=parseInt(o(),16),!!isFinite(p));m+=1)g=g*16+p;f+=String.fromCharCode(g)}else if(typeof t[e]=="string")f+=t[e];else break;else f+=e}r("Bad string")},c=function(){for(;e&&e<=" ";)o()},u=function(){switch(e){case"t":return o("t"),o("r"),o("u"),o("e"),!0;case"f":return o("f"),o("a"),o("l"),o("s"),o("e"),!1;case"n":return o("n"),o("u"),o("l"),o("l"),null}r('Unexpected "'+e+'"')},l,d=function(){var p=[];if(e==="["){if(o("["),c(),e==="]")return o("]"),p;for(;e;){if(p.push(l()),c(),e==="]")return o("]"),p;o(","),c()}}r("Bad array")},h=function(){var p,m={};if(e==="{"){if(o("{"),c(),e==="}")return o("}"),m;for(;e;){if(p=a(),c(),o(":"),Object.hasOwnProperty.call(m,p)&&r('Duplicate key "'+p+'"'),m[p]=l(),c(),e==="}")return o("}"),m;o(","),c()}}r("Bad object")};return l=function(){switch(c(),e){case"{":return h();case"[":return d();case'"':return a();case"-":return s();default:return e>="0"&&e<="9"?s():u()}},function(p){var m;return i=p,n=0,e=" ",m=l(),c(),e&&r("Syntax error"),m}}(),v.base64Encode=function(n){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",t,i,r,o,s,a,c,u,l=0,d=0,h="",p=[];if(!n)return n;n=v.utf8Encode(n);do t=n.charCodeAt(l++),i=n.charCodeAt(l++),r=n.charCodeAt(l++),u=t<<16|i<<8|r,o=u>>18&63,s=u>>12&63,a=u>>6&63,c=u&63,p[d++]=e.charAt(o)+e.charAt(s)+e.charAt(a)+e.charAt(c);while(l<n.length);switch(h=p.join(""),n.length%3){case 1:h=h.slice(0,-2)+"==";break;case 2:h=h.slice(0,-1)+"=";break}return h},v.utf8Encode=function(n){n=(n+"").replace(/\r\n/g,`
78
- `).replace(/\r/g,`
79
- `);var e="",t,i,r=0,o;for(t=i=0,r=n.length,o=0;o<r;o++){var s=n.charCodeAt(o),a=null;s<128?i++:s>127&&s<2048?a=String.fromCharCode(s>>6|192,s&63|128):a=String.fromCharCode(s>>12|224,s>>6&63|128,s&63|128),a!==null&&(i>t&&(e+=n.substring(t,i)),e+=a,t=i=o+1)}return i>t&&(e+=n.substring(t,n.length)),e},v.UUID=function(){try{return W.crypto.randomUUID()}catch{for(var n=new Array(36),e=0;e<36;e++)n[e]=Math.floor(Math.random()*16);return n[14]=4,n[19]=n[19]&=-5,n[19]=n[19]|=8,n[8]=n[13]=n[18]=n[23]="-",v.map(n,function(t){return t.toString(16)}).join("")}};var k0=["ahrefsbot","ahrefssiteaudit","amazonbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","facebookexternal","petalbot","pinterest","screaming frog","yahoo! slurp","yandex","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleweblight","mediapartners-google","storebot-google"];v.isBlockedUA=function(n){var e;for(n=n.toLowerCase(),e=0;e<k0.length;e++)if(n.indexOf(k0[e])!==-1)return!0;return!1},v.HTTPBuildQuery=function(n,e){var t,i,r=[];return v.isUndefined(e)&&(e="&"),v.each(n,function(o,s){t=encodeURIComponent(o.toString()),i=encodeURIComponent(s),r[r.length]=i+"="+t}),r.join(e)},v.getQueryParam=function(n,e){e=e.replace(/[[]/g,"\\[").replace(/[\]]/g,"\\]");var t="[\\?&]"+e+"=([^&#]*)",i=new RegExp(t),r=i.exec(n);if(r===null||r&&typeof r[1]!="string"&&r[1].length)return"";var o=r[1];try{o=decodeURIComponent(o)}catch{_e.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},v.cookie={get:function(n){for(var e=n+"=",t=be.cookie.split(";"),i=0;i<t.length;i++){for(var r=t[i];r.charAt(0)==" ";)r=r.substring(1,r.length);if(r.indexOf(e)===0)return decodeURIComponent(r.substring(e.length,r.length))}return null},parse:function(n){var e;try{e=v.JSONDecode(v.cookie.get(n))||{}}catch{}return e},set_seconds:function(n,e,t,i,r,o,s){var a="",c="",u="";if(s)a="; domain="+s;else if(i){var l=C0(be.location.hostname);a=l?"; domain=."+l:""}if(t){var d=new Date;d.setTime(d.getTime()+t*1e3),c="; expires="+d.toGMTString()}o&&(r=!0,u="; SameSite=None"),r&&(u+="; secure"),be.cookie=n+"="+encodeURIComponent(e)+c+"; path=/"+a+u},set:function(n,e,t,i,r,o,s){var a="",c="",u="";if(s)a="; domain="+s;else if(i){var l=C0(be.location.hostname);a=l?"; domain=."+l:""}if(t){var d=new Date;d.setTime(d.getTime()+t*24*60*60*1e3),c="; expires="+d.toGMTString()}o&&(r=!0,u="; SameSite=None"),r&&(u+="; secure");var h=n+"="+encodeURIComponent(e)+c+"; path=/"+a+u;return be.cookie=h,h},remove:function(n,e,t){v.cookie.set(n,"",-1,e,!1,!1,t)}};var S0=function(n){var e=!0;try{var t="__mplss_"+Rd(8),i="xyz";n.setItem(t,i),n.getItem(t)!==i&&(e=!1),n.removeItem(t)}catch{e=!1}return e},Ed=null,$o=function(n,e){return Ed!==null&&!e?Ed:Ed=S0(n||W.localStorage)},Id=null,LR=function(n,e){return Id!==null&&!e?Id:Id=S0(n||W.sessionStorage)};function w0(n,e,t){var i=function(r){_e.error(e+" error: "+r)};return{is_supported:function(r){var o=t(n,r);return o||_e.error(e+" unsupported"),o},error:i,get:function(r){try{return n.getItem(r)}catch(o){i(o)}return null},parse:function(r){try{return v.JSONDecode(n.getItem(r))||{}}catch{}return null},set:function(r,o){try{n.setItem(r,o)}catch(s){i(s)}},remove:function(r){try{n.removeItem(r)}catch(o){i(o)}}}}v.localStorage=w0(W.localStorage,"localStorage",$o),v.sessionStorage=w0(W.sessionStorage,"sessionStorage",LR),v.register_event=function(){var n=function(i,r,o,s,a){if(!i){_e.error("No valid element provided to register_event");return}if(i.addEventListener&&!s)i.addEventListener(r,o,!!a);else{var c="on"+r,u=i[c];i[c]=e(i,o,u)}};function e(i,r,o){var s=function(a){if(a=a||t(W.event),!!a){var c=!0,u,l;return v.isFunction(o)&&(u=o(a)),l=r.call(i,a),(u===!1||l===!1)&&(c=!1),c}};return s}function t(i){return i&&(i.preventDefault=t.preventDefault,i.stopPropagation=t.stopPropagation),i}return t.preventDefault=function(){this.returnValue=!1},t.stopPropagation=function(){this.cancelBubble=!0},n}();var UR=new RegExp('^(\\w*)\\[(\\w+)([=~\\|\\^\\$\\*]?)=?"?([^\\]"]*)"?\\]$');v.dom_query=function(){function n(r){return r.all?r.all:r.getElementsByTagName("*")}var e=/[\t\r\n]/g;function t(r,o){var s=" "+o+" ";return(" "+r.className+" ").replace(e," ").indexOf(s)>=0}function i(r){if(!be.getElementsByTagName)return[];var o=r.split(" "),s,a,c,u,l,d,h,p,m,f,g=[be];for(d=0;d<o.length;d++){if(s=o[d].replace(/^\s+/,"").replace(/\s+$/,""),s.indexOf("#")>-1){a=s.split("#"),c=a[0];var y=a[1],b=be.getElementById(y);if(!b||c&&b.nodeName.toLowerCase()!=c)return[];g=[b];continue}if(s.indexOf(".")>-1){a=s.split("."),c=a[0];var S=a[1];for(c||(c="*"),u=[],l=0,h=0;h<g.length;h++)for(c=="*"?m=n(g[h]):m=g[h].getElementsByTagName(c),p=0;p<m.length;p++)u[l++]=m[p];for(g=[],f=0,h=0;h<u.length;h++)u[h].className&&v.isString(u[h].className)&&t(u[h],S)&&(g[f++]=u[h]);continue}var w=s.match(UR);if(w){c=w[1];var k=w[2],C=w[3],x=w[4];for(c||(c="*"),u=[],l=0,h=0;h<g.length;h++)for(c=="*"?m=n(g[h]):m=g[h].getElementsByTagName(c),p=0;p<m.length;p++)u[l++]=m[p];g=[],f=0;var I;switch(C){case"=":I=function(P){return P.getAttribute(k)==x};break;case"~":I=function(P){return P.getAttribute(k).match(new RegExp("\\b"+x+"\\b"))};break;case"|":I=function(P){return P.getAttribute(k).match(new RegExp("^"+x+"-?"))};break;case"^":I=function(P){return P.getAttribute(k).indexOf(x)===0};break;case"$":I=function(P){return P.getAttribute(k).lastIndexOf(x)==P.getAttribute(k).length-x.length};break;case"*":I=function(P){return P.getAttribute(k).indexOf(x)>-1};break;default:I=function(P){return P.getAttribute(k)}}for(g=[],f=0,h=0;h<u.length;h++)I(u[h])&&(g[f++]=u[h]);continue}for(c=s,u=[],l=0,h=0;h<g.length;h++)for(m=g[h].getElementsByTagName(c),p=0;p<m.length;p++)u[l++]=m[p];g=u}return g}return function(r){return v.isElement(r)?[r]:v.isObject(r)&&!v.isUndefined(r.length)?r:i.call(this,r)}}();var FR=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","utm_id","utm_source_platform","utm_campaign_id","utm_creative_format","utm_marketing_tactic"],BR=["dclid","fbclid","gclid","ko_click_id","li_fat_id","msclkid","sccid","ttclid","twclid","wbraid"];v.info={campaignParams:function(n){var e="",t={};return v.each(FR,function(i){e=v.getQueryParam(be.URL,i),e.length?t[i]=e:n!==void 0&&(t[i]=n)}),t},clickParams:function(){var n="",e={};return v.each(BR,function(t){n=v.getQueryParam(be.URL,t),n.length&&(e[t]=n)}),e},marketingParams:function(){return v.extend(v.info.campaignParams(),v.info.clickParams())},searchEngine:function(n){return n.search("https?://(.*)google.([^/?]*)")===0?"google":n.search("https?://(.*)bing.com")===0?"bing":n.search("https?://(.*)yahoo.com")===0?"yahoo":n.search("https?://(.*)duckduckgo.com")===0?"duckduckgo":null},searchInfo:function(n){var e=v.info.searchEngine(n),t=e!="yahoo"?"q":"p",i={};if(e!==null){i.$search_engine=e;var r=v.getQueryParam(n,t);r.length&&(i.mp_keyword=r)}return i},browser:function(n,e,t){return e=e||"",t||v.includes(n," OPR/")?v.includes(n,"Mini")?"Opera Mini":"Opera":/(BlackBerry|PlayBook|BB10)/i.test(n)?"BlackBerry":v.includes(n,"IEMobile")||v.includes(n,"WPDesktop")?"Internet Explorer Mobile":v.includes(n,"SamsungBrowser/")?"Samsung Internet":v.includes(n,"Edge")||v.includes(n,"Edg/")?"Microsoft Edge":v.includes(n,"FBIOS")?"Facebook Mobile":v.includes(n,"Whale/")?"Whale Browser":v.includes(n,"Chrome")?"Chrome":v.includes(n,"CriOS")?"Chrome iOS":v.includes(n,"UCWEB")||v.includes(n,"UCBrowser")?"UC Browser":v.includes(n,"FxiOS")?"Firefox iOS":v.includes(e,"Apple")?v.includes(n,"Mobile")?"Mobile Safari":"Safari":v.includes(n,"Android")?"Android Mobile":v.includes(n,"Konqueror")?"Konqueror":v.includes(n,"Firefox")?"Firefox":v.includes(n,"MSIE")||v.includes(n,"Trident/")?"Internet Explorer":v.includes(n,"Gecko")?"Mozilla":""},browserVersion:function(n,e,t){var i=v.info.browser(n,e,t),r={"Internet Explorer Mobile":/rv:(\d+(\.\d+)?)/,"Microsoft Edge":/Edge?\/(\d+(\.\d+)?)/,Chrome:/Chrome\/(\d+(\.\d+)?)/,"Chrome iOS":/CriOS\/(\d+(\.\d+)?)/,"UC Browser":/(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/,Safari:/Version\/(\d+(\.\d+)?)/,"Mobile Safari":/Version\/(\d+(\.\d+)?)/,Opera:/(Opera|OPR)\/(\d+(\.\d+)?)/,Firefox:/Firefox\/(\d+(\.\d+)?)/,"Firefox iOS":/FxiOS\/(\d+(\.\d+)?)/,Konqueror:/Konqueror:(\d+(\.\d+)?)/,BlackBerry:/BlackBerry (\d+(\.\d+)?)/,"Android Mobile":/android\s(\d+(\.\d+)?)/,"Samsung Internet":/SamsungBrowser\/(\d+(\.\d+)?)/,"Internet Explorer":/(rv:|MSIE )(\d+(\.\d+)?)/,Mozilla:/rv:(\d+(\.\d+)?)/,"Whale Browser":/Whale\/(\d+(\.\d+)?)/},o=r[i];if(o===void 0)return null;var s=n.match(o);return s?parseFloat(s[s.length-2]):null},os:function(){var n=Vn;return/Windows/i.test(n)?/Phone/.test(n)||/WPDesktop/.test(n)?"Windows Phone":"Windows":/(iPhone|iPad|iPod)/.test(n)?"iOS":/Android/.test(n)?"Android":/(BlackBerry|PlayBook|BB10)/i.test(n)?"BlackBerry":/Mac/i.test(n)?"Mac OS X":/Linux/.test(n)?"Linux":/CrOS/.test(n)?"Chrome OS":""},device:function(n){return/Windows Phone/i.test(n)||/WPDesktop/.test(n)?"Windows Phone":/iPad/.test(n)?"iPad":/iPod/.test(n)?"iPod Touch":/iPhone/.test(n)?"iPhone":/(BlackBerry|PlayBook|BB10)/i.test(n)?"BlackBerry":/Android/.test(n)?"Android":""},referringDomain:function(n){var e=n.split("/");return e.length>=3?e[2]:""},currentUrl:function(){return W.location.href},properties:function(n){return typeof n!="object"&&(n={}),v.extend(v.strip_empty_properties({$os:v.info.os(),$browser:v.info.browser(Vn,ui.vendor,ja),$referrer:be.referrer,$referring_domain:v.info.referringDomain(be.referrer),$device:v.info.device(Vn)}),{$current_url:v.info.currentUrl(),$browser_version:v.info.browserVersion(Vn,ui.vendor,ja),$screen_height:g0.height,$screen_width:g0.width,mp_lib:"web",$lib_version:on.LIB_VERSION,$insert_id:Rd(),time:v.timestamp()/1e3},v.strip_empty_properties(n))},people_properties:function(){return v.extend(v.strip_empty_properties({$os:v.info.os(),$browser:v.info.browser(Vn,ui.vendor,ja)}),{$browser_version:v.info.browserVersion(Vn,ui.vendor,ja)})},mpPageViewProperties:function(){return v.strip_empty_properties({current_page_title:be.title,current_domain:W.location.hostname,current_url_path:W.location.pathname,current_url_protocol:W.location.protocol,current_url_search:W.location.search})}};var jR=function(n,e){var t=null,i=[];return function(r){var o=this;return i.push(r),t||(t=new ke(function(s){setTimeout(function(){var a=n.apply(o,[i]);t=null,i=[],s(a)},e)})),t}},Rd=function(n){var e=Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10);return n?e.substring(0,n):e},VR=/[a-z0-9][a-z0-9-]*\.[a-z]+$/i,zR=/[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i,C0=function(n){var e=zR,t=n.split("."),i=t[t.length-1];(i.length>4||i==="com"||i==="org")&&(e=VR);var r=n.match(e);return r?r[0]:""},qR=function(){var n=W.navigator.onLine;return v.isUndefined(n)||n},li=function(){},Mr=null,Va=null;typeof JSON<"u"&&(Mr=JSON.stringify,Va=JSON.parse),Mr=Mr||v.JSONEncode,Va=Va||v.JSONDecode,v.info=v.info,v.info.browser=v.info.browser,v.info.browserVersion=v.info.browserVersion,v.info.device=v.info.device,v.info.properties=v.info.properties,v.isBlockedUA=v.isBlockedUA,v.isEmptyObject=v.isEmptyObject,v.isObject=v.isObject,v.JSONDecode=v.JSONDecode,v.JSONEncode=v.JSONEncode,v.toArray=v.toArray,v.NPO=ci;var WR="mixpanelBrowserDb",T0="mixpanelRecordingEvents",Pd="mixpanelRecordingRegistry",GR=1,$R=[T0,Pd],Sn=function(n){this.dbPromise=null,this.storeName=n};Sn.prototype._openDb=function(){return new ke(function(n,e){var t=W.indexedDB.open(WR,GR);t.onerror=function(){e(t.error)},t.onsuccess=function(){n(t.result)},t.onupgradeneeded=function(i){var r=i.target.result;$R.forEach(function(o){r.createObjectStore(o)})}})},Sn.prototype.init=function(){return W.indexedDB?(this.dbPromise||(this.dbPromise=this._openDb()),this.dbPromise.then(function(n){return n instanceof W.IDBDatabase?ke.resolve():ke.reject(n)})):ke.reject("indexedDB is not supported in this browser")},Sn.prototype.makeTransaction=function(n,e){var t=this.storeName,i=function(r){return new ke(function(o,s){var a=r.transaction(t,n);a.oncomplete=function(){o(a)},a.onabort=a.onerror=function(){s(a.error)},e(a.objectStore(t))})};return this.dbPromise.then(i).catch((function(r){return r&&r.name==="InvalidStateError"?(this.dbPromise=this._openDb(),this.dbPromise.then(i)):ke.reject(r)}).bind(this))},Sn.prototype.setItem=function(n,e){return this.makeTransaction("readwrite",function(t){t.put(e,n)})},Sn.prototype.getItem=function(n){var e;return this.makeTransaction("readonly",function(t){e=t.get(n)}).then(function(){return e.result})},Sn.prototype.removeItem=function(n){return this.makeTransaction("readwrite",function(e){e.delete(n)})},Sn.prototype.getAll=function(){var n;return this.makeTransaction("readonly",function(e){n=e.getAll()}).then(function(){return n.result})};var HR="__mp_opt_in_out_";function KR(n,e){I0(!0,n,e)}function YR(n,e){I0(!1,n,e)}function XR(n,e){return E0(n,e)==="1"}function x0(n,e){if(ZR(e))return _e.warn('This browser has "Do Not Track" enabled. This will prevent the Mixpanel SDK from sending any data. To ignore the "Do Not Track" browser setting, initialize the Mixpanel instance with the config "ignore_dnt: true"'),!0;var t=E0(n,e)==="0";return t&&_e.warn("You are opted out of Mixpanel tracking. This will prevent the Mixpanel SDK from sending any data."),t}function di(n){return Md(n,function(e){return this.get_config(e)})}function hi(n){return Md(n,function(e){return this._get_config(e)})}function Nr(n){return Md(n,function(e){return this._get_config(e)})}function JR(n,e){e=e||{},Od(e).remove(Ad(n,e),!!e.crossSubdomainCookie,e.cookieDomain)}function Od(n){return n=n||{},n.persistenceType==="localStorage"?v.localStorage:v.cookie}function Ad(n,e){return e=e||{},(e.persistencePrefix||HR)+n}function E0(n,e){return Od(e).get(Ad(n,e))}function ZR(n){if(n&&n.ignoreDnt)return!1;var e=n&&n.window||W,t=e.navigator||{},i=!1;return v.each([t.doNotTrack,t.msDoNotTrack,e.doNotTrack],function(r){v.includes([!0,1,"1","yes"],r)&&(i=!0)}),i}function I0(n,e,t){if(!v.isString(e)||!e.length){_e.error("gdpr."+(n?"optIn":"optOut")+" called with an invalid token");return}t=t||{},Od(t).set(Ad(e,t),n?1:0,v.isNumber(t.cookieExpiration)?t.cookieExpiration:null,!!t.crossSubdomainCookie,!!t.secureCookie,!!t.crossSiteCookie,t.cookieDomain),t.track&&n&&t.track(t.trackEventName||"$opt_in",t.trackProperties,{send_immediately:!0})}function Md(n,e){return function(){var t=!1;try{var i=e.call(this,"token"),r=e.call(this,"ignore_dnt"),o=e.call(this,"opt_out_tracking_persistence_type"),s=e.call(this,"opt_out_tracking_cookie_prefix"),a=e.call(this,"window");i&&(t=x0(i,{ignoreDnt:r,persistenceType:o,persistencePrefix:s,window:a}))}catch(u){_e.error("Unexpected error when checking tracking opt-out status: "+u)}if(!t)return n.apply(this,arguments);var c=arguments[arguments.length-1];typeof c=="function"&&c(0)}}var QR=Gi("lock"),R0=function(n,e){e=e||{},this.storageKey=n,this.storage=e.storage||W.localStorage,this.pollIntervalMS=e.pollIntervalMS||100,this.timeoutMS=e.timeoutMS||2e3,this.promiseImpl=e.promiseImpl||ke};R0.prototype.withLock=function(n,e){var t=this.promiseImpl;return new t(v.bind(function(i,r){var o=e||new Date().getTime()+"|"+Math.random(),s=new Date().getTime(),a=this.storageKey,c=this.pollIntervalMS,u=this.timeoutMS,l=this.storage,d=a+":X",h=a+":Y",p=a+":Z",m=function(S){if(new Date().getTime()-s>u){QR.error("Timeout waiting for mutex on "+a+"; clearing lock. ["+o+"]"),l.removeItem(p),l.removeItem(h),y();return}setTimeout(function(){try{S()}catch(w){r(w)}},c*(Math.random()+.1))},f=function(S,w){S()?w():m(function(){f(S,w)})},g=function(){var S=l.getItem(h);return S&&S!==o?!1:(l.setItem(h,o),l.getItem(h)===o?!0:($o(l,!0)||r(new Error("localStorage support dropped while acquiring lock")),!1))},y=function(){l.setItem(d,o),f(g,function(){if(l.getItem(d)===o){b();return}m(function(){if(l.getItem(h)!==o){y();return}f(function(){return!l.getItem(p)},b)})})},b=function(){l.setItem(p,"1");var S=function(){l.removeItem(p),l.getItem(h)===o&&l.removeItem(h),l.getItem(d)===o&&l.removeItem(d)};n().then(function(w){S(),i(w)}).catch(function(w){S(),r(w)})};try{if($o(l,!0))y();else throw new Error("localStorage support check failed")}catch(S){r(S)}},this))};var Ho=function(n){this.storage=n||W.localStorage};Ho.prototype.init=function(){return ke.resolve()},Ho.prototype.setItem=function(n,e){return new ke(v.bind(function(t,i){try{this.storage.setItem(n,Mr(e))}catch(r){i(r)}t()},this))},Ho.prototype.getItem=function(n){return new ke(v.bind(function(e,t){var i;try{i=Va(this.storage.getItem(n))}catch(r){t(r)}e(i)},this))},Ho.prototype.removeItem=function(n){return new ke(v.bind(function(e,t){try{this.storage.removeItem(n)}catch(i){t(i)}e()},this))};var P0=Gi("batch"),wn=function(n,e){e=e||{},this.storageKey=n,this.usePersistence=e.usePersistence,this.usePersistence&&(this.queueStorage=e.queueStorage||new Ho,this.lock=new R0(n,{storage:e.sharedLockStorage||W.localStorage,timeoutMS:e.sharedLockTimeoutMS})),this.reportError=e.errorReporter||v.bind(P0.error,P0),this.pid=e.pid||null,this.memQueue=[],this.initialized=!1,e.enqueueThrottleMs?this.enqueuePersisted=jR(v.bind(this._enqueuePersisted,this),e.enqueueThrottleMs):this.enqueuePersisted=v.bind(function(t){return this._enqueuePersisted([t])},this)};wn.prototype.ensureInit=function(){return this.initialized?ke.resolve():this.queueStorage.init().then(v.bind(function(){this.initialized=!0},this)).catch(v.bind(function(n){this.reportError("Error initializing queue persistence. Disabling persistence",n),this.initialized=!0,this.usePersistence=!1},this))},wn.prototype.enqueue=function(n,e){var t={id:Rd(),flushAfter:new Date().getTime()+e*2,payload:n};return this.usePersistence?this.enqueuePersisted(t):(this.memQueue.push(t),ke.resolve(!0))},wn.prototype._enqueuePersisted=function(n){var e=v.bind(function(){return this.ensureInit().then(v.bind(function(){return this.readFromStorage()},this)).then(v.bind(function(t){return this.saveToStorage(t.concat(n))},this)).then(v.bind(function(t){return t&&(this.memQueue=this.memQueue.concat(n)),t},this)).catch(v.bind(function(t){return this.reportError("Error enqueueing items",t,n),!1},this))},this);return this.lock.withLock(e,this.pid).catch(v.bind(function(t){return this.reportError("Error acquiring storage lock",t),!1},this))},wn.prototype.fillBatch=function(n){var e=this.memQueue.slice(0,n);return this.usePersistence&&e.length<n?this.ensureInit().then(v.bind(function(){return this.readFromStorage()},this)).then(v.bind(function(t){if(t.length){var i={};v.each(e,function(s){i[s.id]=!0});for(var r=0;r<t.length;r++){var o=t[r];if(new Date().getTime()>o.flushAfter&&!i[o.id]&&(o.orphaned=!0,e.push(o),e.length>=n))break}}return e},this)):ke.resolve(e)};var O0=function(n,e){var t=[];return v.each(n,function(i){i.id&&!e[i.id]&&t.push(i)}),t};wn.prototype.removeItemsByID=function(n){var e={};if(v.each(n,function(i){e[i]=!0}),this.memQueue=O0(this.memQueue,e),this.usePersistence){var t=v.bind(function(){return this.ensureInit().then(v.bind(function(){return this.readFromStorage()},this)).then(v.bind(function(i){return i=O0(i,e),this.saveToStorage(i)},this)).then(v.bind(function(){return this.readFromStorage()},this)).then(v.bind(function(i){for(var r=0;r<i.length;r++){var o=i[r];if(o.id&&e[o.id])throw new Error("Item not removed from storage")}return!0},this)).catch(v.bind(function(i){return this.reportError("Error removing items",i,n),!1},this))},this);return this.lock.withLock(t,this.pid).catch(v.bind(function(i){return this.reportError("Error acquiring storage lock",i),$o(this.lock.storage,!0)?!1:t().then(v.bind(function(r){return r||this.queueStorage.removeItem(this.storageKey).then(function(){return r})},this)).catch(v.bind(function(r){return this.reportError("Error clearing queue",r),!1},this))},this))}else return ke.resolve(!0)};var A0=function(n,e){var t=[];return v.each(n,function(i){var r=i.id;if(r in e){var o=e[r];o!==null&&(i.payload=o,t.push(i))}else t.push(i)}),t};wn.prototype.updatePayloads=function(n){return this.memQueue=A0(this.memQueue,n),this.usePersistence?this.lock.withLock(v.bind(function(){return this.ensureInit().then(v.bind(function(){return this.readFromStorage()},this)).then(v.bind(function(e){return e=A0(e,n),this.saveToStorage(e)},this)).catch(v.bind(function(e){return this.reportError("Error updating items",n,e),!1},this))},this),this.pid).catch(v.bind(function(e){return this.reportError("Error acquiring storage lock",e),!1},this)):ke.resolve(!0)},wn.prototype.readFromStorage=function(){return this.ensureInit().then(v.bind(function(){return this.queueStorage.getItem(this.storageKey)},this)).then(v.bind(function(n){return n&&(v.isArray(n)||(this.reportError("Invalid storage entry:",n),n=null)),n||[]},this)).catch(v.bind(function(n){return this.reportError("Error retrieving queue",n),[]},this))},wn.prototype.saveToStorage=function(n){return this.ensureInit().then(v.bind(function(){return this.queueStorage.setItem(this.storageKey,n)},this)).then(function(){return!0}).catch(v.bind(function(e){return this.reportError("Error saving queue",e),!1},this))},wn.prototype.clear=function(){return this.memQueue=[],this.usePersistence?this.ensureInit().then(v.bind(function(){return this.queueStorage.removeItem(this.storageKey)},this)):ke.resolve()};var eP=10*60*1e3,Ko=Gi("batch"),Kt=function(n,e){this.errorReporter=e.errorReporter,this.queue=new wn(n,{errorReporter:v.bind(this.reportError,this),queueStorage:e.queueStorage,sharedLockStorage:e.sharedLockStorage,sharedLockTimeoutMS:e.sharedLockTimeoutMS,usePersistence:e.usePersistence,enqueueThrottleMs:e.enqueueThrottleMs}),this.libConfig=e.libConfig,this.sendRequest=e.sendRequestFunc,this.beforeSendHook=e.beforeSendHook,this.stopAllBatching=e.stopAllBatchingFunc,this.batchSize=this.libConfig.batch_size,this.flushInterval=this.libConfig.batch_flush_interval_ms,this.stopped=!this.libConfig.batch_autostart,this.consecutiveRemovalFailures=0,this.itemIdsSentSuccessfully={},this.flushOnlyOnInterval=e.flushOnlyOnInterval||!1,this._flushPromise=null};Kt.prototype.enqueue=function(n){return this.queue.enqueue(n,this.flushInterval)},Kt.prototype.start=function(){return this.stopped=!1,this.consecutiveRemovalFailures=0,this.flush()},Kt.prototype.stop=function(){this.stopped=!0,this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=null)},Kt.prototype.clear=function(){return this.queue.clear()},Kt.prototype.resetBatchSize=function(){this.batchSize=this.libConfig.batch_size},Kt.prototype.resetFlush=function(){this.scheduleFlush(this.libConfig.batch_flush_interval_ms)},Kt.prototype.scheduleFlush=function(n){this.flushInterval=n,this.stopped||(this.timeoutID=setTimeout(v.bind(function(){this.stopped||(this._flushPromise=this.flush())},this),this.flushInterval))},Kt.prototype.sendRequestPromise=function(n,e){return new ke(v.bind(function(t){this.sendRequest(n,e,t)},this))},Kt.prototype.flush=function(n){if(this.requestInProgress)return Ko.log("Flush: Request already in progress"),ke.resolve();this.requestInProgress=!0,n=n||{};var e=this.libConfig.batch_request_timeout_ms,t=new Date().getTime(),i=this.batchSize;return this.queue.fillBatch(i).then(v.bind(function(r){var o=r.length===i,s=[],a={};if(v.each(r,function(d){var h=d.payload;if(this.beforeSendHook&&!d.orphaned&&(h=this.beforeSendHook(h)),h){h.event&&h.properties&&(h.properties=v.extend({},h.properties,{mp_sent_by_lib_version:on.LIB_VERSION}));var p=!0,m=d.id;m?(this.itemIdsSentSuccessfully[m]||0)>5&&(this.reportError("[dupe] item ID sent too many times, not sending",{item:d,batchSize:r.length,timesSent:this.itemIdsSentSuccessfully[m]}),p=!1):this.reportError("[dupe] found item with no ID",{item:d}),p&&s.push(h)}a[d.id]=h},this),s.length<1)return this.requestInProgress=!1,this.resetFlush(),ke.resolve();var c=v.bind(function(){return this.queue.removeItemsByID(v.map(r,function(d){return d.id})).then(v.bind(function(d){return v.each(r,v.bind(function(h){var p=h.id;p?(this.itemIdsSentSuccessfully[p]=this.itemIdsSentSuccessfully[p]||0,this.itemIdsSentSuccessfully[p]++,this.itemIdsSentSuccessfully[p]>5&&this.reportError("[dupe] item ID sent too many times",{item:h,batchSize:r.length,timesSent:this.itemIdsSentSuccessfully[p]})):this.reportError("[dupe] found item with no ID while removing",{item:h})},this)),d?(this.consecutiveRemovalFailures=0,this.flushOnlyOnInterval&&!o?(this.resetFlush(),ke.resolve()):this.flush()):(++this.consecutiveRemovalFailures>5?(this.reportError("Too many queue failures; disabling batching system."),this.stopAllBatching()):this.resetFlush(),ke.resolve())},this))},this),u=v.bind(function(d){this.requestInProgress=!1;try{if(n.unloading)return this.queue.updatePayloads(a);if(v.isObject(d)&&d.error==="timeout"&&new Date().getTime()-t>=e)return this.reportError("Network timeout; retrying"),this.flush();if(v.isObject(d)&&(d.httpStatusCode>=500||d.httpStatusCode===429||d.httpStatusCode<=0&&!qR()||d.error==="timeout")){var h=this.flushInterval*2;return d.retryAfter&&(h=parseInt(d.retryAfter,10)*1e3||h),h=Math.min(eP,h),this.reportError("Error; retry in "+h+" ms"),this.scheduleFlush(h),ke.resolve()}else if(v.isObject(d)&&d.httpStatusCode===413)if(r.length>1){var p=Math.max(1,Math.floor(i/2));return this.batchSize=Math.min(this.batchSize,p,r.length-1),this.reportError("413 response; reducing batch size to "+this.batchSize),this.resetFlush(),ke.resolve()}else return this.reportError("Single-event request too large; dropping",r),this.resetBatchSize(),c();else return c()}catch(m){this.reportError("Error handling API response",m),this.resetFlush()}},this),l={method:"POST",verbose:!0,ignore_json_errors:!0,timeout_ms:e};return n.unloading&&(l.transport="sendBeacon"),Ko.log("MIXPANEL REQUEST:",s),this.sendRequestPromise(s,l).then(u)},this)).catch(v.bind(function(r){this.reportError("Error flushing request queue",r),this.resetFlush()},this))},Kt.prototype.reportError=function(n,e){if(Ko.error.apply(Ko.error,arguments),this.errorReporter)try{e instanceof Error||(e=new Error(n)),this.errorReporter(n,e)}catch(t){Ko.error(t)}};var Nd=function(n){var e=Date.now();return!n||e>n.maxExpires||e>n.idleExpires},tP=250,Dr=Gi("recorder"),M0=W.CompressionStream,nP={batch_size:1e3,batch_flush_interval_ms:10*1e3,batch_request_timeout_ms:90*1e3,batch_autostart:!0},iP=new Set([Z.MouseMove,Z.MouseInteraction,Z.Scroll,Z.ViewportResize,Z.Input,Z.TouchMove,Z.MediaInteraction,Z.Drag,Z.Selection]);function rP(n){return n.type===ce.IncrementalSnapshot&&iP.has(n.data.source)}var gt=function(n){this._mixpanel=n.mixpanelInstance,this._onIdleTimeout=n.onIdleTimeout||li,this._onMaxLengthReached=n.onMaxLengthReached||li,this._onBatchSent=n.onBatchSent||li,this._rrwebRecord=n.rrwebRecord||null,this._stopRecording=null,this.replayId=n.replayId,this.batchStartUrl=n.batchStartUrl||null,this.replayStartUrl=n.replayStartUrl||null,this.idleExpires=n.idleExpires||null,this.maxExpires=n.maxExpires||null,this.replayStartTime=n.replayStartTime||null,this.seqNo=n.seqNo||0,this.idleTimeoutId=null,this.maxTimeoutId=null,this.recordMaxMs=Wo,this.recordMinMs=0;var e=$o(n.sharedLockStorage,!0);this.batcherKey="__mprec_"+this.getConfig("name")+"_"+this.getConfig("token")+"_"+this.replayId,this.queueStorage=new Sn(T0),this.batcher=new Kt(this.batcherKey,{errorReporter:this.reportError.bind(this),flushOnlyOnInterval:!0,libConfig:nP,sendRequestFunc:this.flushEventsWithOptOut.bind(this),queueStorage:this.queueStorage,sharedLockStorage:n.sharedLockStorage,usePersistence:e,stopAllBatchingFunc:this.stopRecording.bind(this),enqueueThrottleMs:tP,sharedLockTimeoutMS:10*1e3})};gt.prototype.getUserIdInfo=function(){if(this.finalFlushUserIdInfo)return this.finalFlushUserIdInfo;var n={distinct_id:String(this._mixpanel.get_distinct_id())},e=this._mixpanel.get_property("$device_id");e&&(n.$device_id=e);var t=this._mixpanel.get_property("$user_id");return t&&(n.$user_id=t),n},gt.prototype.unloadPersistedData=function(){return this.batcher.stop(),this.batcher.flush().then((function(){return this.queueStorage.removeItem(this.batcherKey)}).bind(this))},gt.prototype.getConfig=function(n){return this._mixpanel.get_config(n)},gt.prototype.get_config=function(n){return this.getConfig(n)},gt.prototype.startRecording=function(n){if(this._rrwebRecord===null){this.reportError("rrweb record function not provided. ");return}if(this._stopRecording!==null){Dr.log("Recording already in progress, skipping startRecording.");return}this.recordMaxMs=this.getConfig("record_max_ms"),this.recordMaxMs>Wo&&(this.recordMaxMs=Wo,Dr.critical("record_max_ms cannot be greater than "+Wo+"ms. Capping value.")),this.maxExpires||(this.maxExpires=new Date().getTime()+this.recordMaxMs),this.recordMinMs=this.getConfig("record_min_ms"),this.recordMinMs>Sd&&(this.recordMinMs=Sd,Dr.critical("record_min_ms cannot be greater than "+Sd+"ms. Capping value.")),this.replayStartTime||(this.replayStartTime=new Date().getTime(),this.batchStartUrl=v.info.currentUrl(),this.replayStartUrl=v.info.currentUrl()),n||this.recordMinMs>0?this.batcher.stop():this.batcher.start();var e=(function(){clearTimeout(this.idleTimeoutId);var r=this.getConfig("record_idle_timeout_ms");this.idleTimeoutId=setTimeout(this._onIdleTimeout,r),this.idleExpires=new Date().getTime()+r}).bind(this);e();var t=this.getConfig("record_block_selector");(t===""||t===null)&&(t=void 0);try{this._stopRecording=this._rrwebRecord({emit:(function(r){if(this.idleExpires&&this.idleExpires<r.timestamp){this._onIdleTimeout();return}rP(r)&&(this.batcher.stopped&&new Date().getTime()-this.replayStartTime>=this.recordMinMs&&this.batcher.start(),e()),this.__enqueuePromise=this.batcher.enqueue(r)}).bind(this),blockClass:this.getConfig("record_block_class"),blockSelector:t,collectFonts:this.getConfig("record_collect_fonts"),dataURLOptions:{type:"image/webp",quality:.6},maskAllInputs:!0,maskTextClass:this.getConfig("record_mask_text_class"),maskTextSelector:this.getConfig("record_mask_text_selector"),recordCanvas:this.getConfig("record_canvas"),sampling:{canvas:15}})}catch(r){this.reportError("Unexpected error when starting rrweb recording.",r)}if(typeof this._stopRecording!="function"){this.reportError("rrweb failed to start, skipping this recording."),this._stopRecording=null,this.stopRecording();return}var i=this.maxExpires-new Date().getTime();this.maxTimeoutId=setTimeout(this._onMaxLengthReached.bind(this),i)},gt.prototype.stopRecording=function(n){if(this.finalFlushUserIdInfo=this.getUserIdInfo(),!this.isRrwebStopped()){try{this._stopRecording()}catch(t){this.reportError("Error with rrweb stopRecording",t)}this._stopRecording=null}var e;return this.batcher.stopped?e=this.batcher.clear():n||(e=this.batcher.flush()),this.batcher.stop(),clearTimeout(this.idleTimeoutId),clearTimeout(this.maxTimeoutId),e},gt.prototype.isRrwebStopped=function(){return this._stopRecording===null},gt.prototype.flushEventsWithOptOut=function(n,e,t){var i=(function(r){r===0&&(this.stopRecording(),t({error:"Tracking has been opted out, stopping recording."}))}).bind(this);this._flushEvents(n,e,t,i)},gt.prototype.serialize=function(){var n;try{n=this._mixpanel.get_tab_id()}catch(e){this.reportError("Error getting tab ID for serialization ",e),n=null}return{replayId:this.replayId,seqNo:this.seqNo,replayStartTime:this.replayStartTime,batchStartUrl:this.batchStartUrl,replayStartUrl:this.replayStartUrl,idleExpires:this.idleExpires,maxExpires:this.maxExpires,tabId:n}},gt.deserialize=function(n,e){var t=new gt(v.extend({},e,{replayId:n.replayId,batchStartUrl:n.batchStartUrl,replayStartUrl:n.replayStartUrl,idleExpires:n.idleExpires,maxExpires:n.maxExpires,replayStartTime:n.replayStartTime,seqNo:n.seqNo,sharedLockStorage:e.sharedLockStorage}));return t},gt.prototype._sendRequest=function(n,e,t,i){var r=(function(s,a){s.status===200&&this.replayId===n&&(this.seqNo++,this.batchStartUrl=v.info.currentUrl()),this._onBatchSent(),i({status:0,httpStatusCode:s.status,responseBody:a,retryAfter:s.headers.get("Retry-After")})}).bind(this),o=this._mixpanel.get_api_host&&this._mixpanel.get_api_host("record")||this.getConfig("api_host");W.fetch(o+"/"+this.getConfig("api_routes").record+"?"+new URLSearchParams(e),{method:"POST",headers:{Authorization:"Basic "+btoa(this.getConfig("token")+":"),"Content-Type":"application/octet-stream"},body:t}).then(function(s){s.json().then(function(a){r(s,a)}).catch(function(a){i({error:a})})}).catch(function(s){i({error:s,httpStatusCode:0})})},gt.prototype._flushEvents=di(function(n,e,t){var i=n.length;if(i>0){for(var r=this.replayId,o=1/0,s=-1/0,a=!1,c=0;c<i;c++)o=Math.min(o,n[c].timestamp),s=Math.max(s,n[c].timestamp),n[c].type===ce.FullSnapshot&&(a=!0);if(this.seqNo===0){if(!a){t({error:"First batch does not contain a full snapshot. Aborting recording."}),this.stopRecording(!0);return}this.replayStartTime=o}else this.replayStartTime||(this.reportError("Replay start time not set but seqNo is not 0. Using current batch start time as a fallback."),this.replayStartTime=o);var u=s-this.replayStartTime,l={$current_url:this.batchStartUrl,$lib_version:on.LIB_VERSION,batch_start_time:o/1e3,mp_lib:"web",replay_id:r,replay_length_ms:u,replay_start_time:this.replayStartTime/1e3,replay_start_url:this.replayStartUrl,seq:this.seqNo},d=JSON.stringify(n);if(Object.assign(l,this.getUserIdInfo()),M0){var h=new Blob([d],{type:"application/json"}).stream(),p=h.pipeThrough(new M0("gzip"));new Response(p).blob().then((function(m){l.format="gzip",this._sendRequest(r,l,m,t)}).bind(this))}else l.format="body",this._sendRequest(r,l,d,t)}}),gt.prototype.reportError=function(n,e){Dr.error.apply(Dr.error,arguments);try{!e&&!(n instanceof Error)&&(n=new Error(n)),this.getConfig("error_reporter")(n,e)}catch(t){Dr.error(t)}};var Lr=function(n){this.idb=new Sn(Pd),this.errorReporter=n.errorReporter,this.mixpanelInstance=n.mixpanelInstance,this.sharedLockStorage=n.sharedLockStorage};Lr.prototype.handleError=function(n){this.errorReporter("IndexedDB error: ",n)},Lr.prototype.setActiveRecording=function(n){var e=n.tabId;return e?this.idb.init().then((function(){return this.idb.setItem(e,n)}).bind(this)).catch(this.handleError.bind(this)):(console.warn("No tab ID is set, cannot persist recording metadata."),ke.resolve())},Lr.prototype.getActiveRecording=function(){return this.idb.init().then((function(){return this.idb.getItem(this.mixpanelInstance.get_tab_id())}).bind(this)).then((function(n){return Nd(n)?null:n}).bind(this)).catch(this.handleError.bind(this))},Lr.prototype.clearActiveRecording=function(){return this.getActiveRecording().then((function(n){if(n)return n.maxExpires=0,this.setActiveRecording(n)}).bind(this)).catch(this.handleError.bind(this))},Lr.prototype.flushInactiveRecordings=function(){return this.idb.init().then((function(){return this.idb.getAll()}).bind(this)).then((function(n){var e=n.filter(function(t){return Nd(t)}).map((function(t){var i=gt.deserialize(t,{mixpanelInstance:this.mixpanelInstance,sharedLockStorage:this.sharedLockStorage});return i.unloadPersistedData().then((function(){return this.idb.removeItem(t.tabId)}).bind(this)).catch(this.handleError.bind(this))}).bind(this));return ke.all(e)}).bind(this)).catch(this.handleError.bind(this))};var Yo=Gi("recorder"),zn=function(n,e,t){this.mixpanelInstance=n,this.rrwebRecord=e||si,this.sharedLockStorage=t,this.recordingRegistry=new Lr({mixpanelInstance:this.mixpanelInstance,errorReporter:Yo.error,sharedLockStorage:t}),this._flushInactivePromise=this.recordingRegistry.flushInactiveRecordings(),this.activeRecording=null,this.stopRecordingInProgress=!1};zn.prototype.startRecording=function(n){if(n=n||{},this.activeRecording&&!this.activeRecording.isRrwebStopped()){Yo.log("Recording already in progress, skipping startRecording.");return}var e=(function(){Yo.log("Idle timeout reached, restarting recording."),this.resetRecording()}).bind(this),t=(function(){Yo.log("Max recording length reached, stopping recording."),this.resetRecording()}).bind(this),i=(function(){this.recordingRegistry.setActiveRecording(this.activeRecording.serialize()),this.__flushPromise=this.activeRecording.batcher._flushPromise}).bind(this),r={mixpanelInstance:this.mixpanelInstance,onBatchSent:i,onIdleTimeout:e,onMaxLengthReached:t,replayId:v.UUID(),rrwebRecord:this.rrwebRecord,sharedLockStorage:this.sharedLockStorage};return n.activeSerializedRecording?this.activeRecording=gt.deserialize(n.activeSerializedRecording,r):this.activeRecording=new gt(r),this.activeRecording.startRecording(n.shouldStopBatcher),this.recordingRegistry.setActiveRecording(this.activeRecording.serialize())},zn.prototype.stopRecording=function(){return this.stopRecordingInProgress=!0,this._stopCurrentRecording(!1,!0).then((function(){return this.recordingRegistry.clearActiveRecording()}).bind(this)).then((function(){this.stopRecordingInProgress=!1}).bind(this))},zn.prototype.pauseRecording=function(){return this._stopCurrentRecording(!1)},zn.prototype._stopCurrentRecording=function(n,e){if(this.activeRecording){var t=this.activeRecording.stopRecording(n);return e&&(this.activeRecording=null),t}return ke.resolve()},zn.prototype.resumeRecording=function(n){return this.activeRecording&&this.activeRecording.isRrwebStopped()?(this.activeRecording.startRecording(!1),ke.resolve(null)):this.recordingRegistry.getActiveRecording().then((function(e){return e&&!this.stopRecordingInProgress?this.startRecording({activeSerializedRecording:e}):n?this.startRecording({shouldStopBatcher:!1}):(Yo.log("No resumable recording found."),null)}).bind(this))},zn.prototype.resetRecording=function(){this.stopRecording(),this.startRecording({shouldStopBatcher:!0})},zn.prototype.getActiveReplayId=function(){return this.activeRecording&&!this.activeRecording.isRrwebStopped()?this.activeRecording.replayId:null},Object.defineProperty(zn.prototype,"replayId",{get:function(){return this.getActiveReplayId()}}),W.__mp_recorder=zn;var za="change",$i="click",N0="hashchange",Ur="mp_locationchange",D0="popstate",L0="scrollend",Dd="submit",oP=["clientX","clientY","offsetX","offsetY","pageX","pageY","screenX","screenY","x","y"],U0=["mp-include"],Ld=["mp-no-track"],F0=Ld.concat(["mp-sensitive"]),sP=["aria-label","aria-labelledby","aria-describedby","href","name","role","title","type"],Pt=Gi("autocapture");function Ud(n){for(var e={},t=B0(n).split(" "),i=0;i<t.length;i++){var r=t[i];r&&(e[r]=!0)}return e}function B0(n){switch(typeof n.className){case"string":return n.className;case"object":return n.className.baseVal||n.getAttribute("class")||"";default:return""}}function aP(n){if(n.previousElementSibling)return n.previousElementSibling;do n=n.previousSibling;while(n&&!z0(n));return n}function j0(n,e,t,i,r,o){var s={$classes:B0(n).split(" "),$tag_name:n.tagName.toLowerCase()},a=n.id;a&&(s.$id=a),jd(n,e,r,o)&&v.each(sP.concat(i),function(d){if(n.hasAttribute(d)&&!t[d]){var h=n.getAttribute(d);qa(h)&&(s["$attr-"+d]=h)}});for(var c=1,u=1,l=n;l=aP(l);)c++,l.tagName===n.tagName&&u++;return s.$nth_child=c,s.$nth_of_type=u,s}function cP(n,e){var t=e.allowElementCallback,i=e.allowSelectors||[],r=e.blockAttrs||[],o=e.blockElementCallback,s=e.blockSelectors||[],a=e.captureTextContent||!1,c=e.captureExtraAttrs||[],u=e.capturedForHeatMap||!1,l={};v.each(r,function(k){l[k]=!0});var d=null,h=typeof n.target>"u"?n.srcElement:n.target;if(q0(h)&&(h=h.parentNode),dP(h,n)&&Fd(h,n,t,i)&&!Bd(h,n,o,s)){for(var p=[h],m=h;m.parentNode&&!Cn(m,"body");)p.push(m.parentNode),m=m.parentNode;var f=[],g,y=!1;if(v.each(p,function(k){var C=jd(k,n,t,i);!l.href&&k.tagName.toLowerCase()==="a"&&(g=k.getAttribute("href"),g=C&&qa(g)&&g),Bd(k,n,o,s)&&(y=!0),f.push(j0(k,n,l,c,t,i))},this),!y){var b=be.documentElement;if(d={$event_type:n.type,$host:W.location.host,$pathname:W.location.pathname,$elements:f,$el_attr__href:g,$viewportHeight:Math.max(b.clientHeight,W.innerHeight||0),$viewportWidth:Math.max(b.clientWidth,W.innerWidth||0),$pageHeight:be.body.offsetHeight||0,$pageWidth:be.body.offsetWidth||0},v.each(c,function(k){if(!l[k]&&h.hasAttribute(k)){var C=h.getAttribute(k);qa(C)&&(d["$el_attr__"+k]=C)}}),a&&(S=V0(h,n,t,i),S&&S.length&&(d.$el_text=S)),n.type===$i&&(v.each(oP,function(k){k in n&&(d["$"+k]=n[k])}),u&&(d.$captured_for_heatmap=!0),h=uP(n)),a){var S=V0(h,n,t,i);S&&S.length&&(d.$el_text=S)}if(h){if(!Fd(h,n,t,i)||Bd(h,n,o,s))return null;var w=j0(h,n,l,c,t,i);d.$target=w,d.$el_classes=w.$classes,v.extend(d,v.strip_empty_properties({$el_id:w.$id,$el_tag_name:w.$tag_name}))}}}return d}function V0(n,e,t,i){var r="";return jd(n,e,t,i)&&n.childNodes&&n.childNodes.length&&v.each(n.childNodes,function(o){q0(o)&&o.textContent&&(r+=v.trim(o.textContent).split(/(\s+)/).filter(qa).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255))}),v.trim(r)}function uP(n){for(var e=n.target,t=n.composedPath(),i=0;i<t.length;i++){var r=t[i];if(Cn(r,"a")||Cn(r,"button")||Cn(r,"input")||Cn(r,"select")||r.getAttribute&&r.getAttribute("role")==="button"){e=r;break}if(r===e)break}return e}function Fd(n,e,t,i){if(t)try{if(!t(n,e))return!1}catch(s){return Pt.critical("Error while checking element in allowElementCallback",s),!1}if(!i.length)return!0;for(var r=0;r<i.length;r++){var o=i[r];try{if(n.matches(o))return!0}catch(s){Pt.critical("Error while checking selector: "+o,s)}}return!1}function Bd(n,e,t,i){var r;if(t)try{if(t(n,e))return!0}catch(a){return Pt.critical("Error while checking element in blockElementCallback",a),!0}if(i&&i.length)for(r=0;r<i.length;r++){var o=i[r];try{if(n.matches(o))return!0}catch(a){Pt.critical("Error while checking selector: "+o,a)}}var s=Ud(n);for(r=0;r<Ld.length;r++)if(s[Ld[r]])return!0;return!1}function z0(n){return n&&n.nodeType===1}function Cn(n,e){return n&&n.tagName&&n.tagName.toLowerCase()===e.toLowerCase()}function q0(n){return n&&n.nodeType===3}function lP(){try{var n=be.createElement("div");return!!n.matches}catch{return!1}}function dP(n,e){if(!n||Cn(n,"html")||!z0(n))return!1;var t=n.tagName.toLowerCase();switch(t){case"form":return e.type===Dd;case"input":return["button","submit"].indexOf(n.getAttribute("type"))===-1?e.type===za:e.type===$i;case"select":case"textarea":return e.type===za;default:return e.type===$i}}function jd(n,e,t,i){var r;if(!Fd(n,e,t,i))return!1;for(var o=n;o.parentNode&&!Cn(o,"body");o=o.parentNode){var s=Ud(o);for(r=0;r<F0.length;r++)if(s[F0[r]])return!1}var a=Ud(n);for(r=0;r<U0.length;r++)if(a[U0[r]])return!0;if(Cn(n,"input")||Cn(n,"select")||Cn(n,"textarea")||n.getAttribute("contenteditable")==="true")return!1;var c=n.type||"";if(typeof c=="string")switch(c.toLowerCase()){case"hidden":return!1;case"password":return!1}var u=n.name||n.id||"";if(typeof u=="string"){var l=/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i;if(l.test(u.replace(/[^a-zA-Z0-9]/g,"")))return!1}return!0}function qa(n){if(n===null||v.isUndefined(n))return!1;if(typeof n=="string"){n=v.trim(n);var e=/^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/;if(e.test((n||"").replace(/[- ]/g,"")))return!1;var t=/(^\d{3}-?\d{2}-?\d{4}$)/;if(t.test(n))return!1}return!0}var hP=30,pP=1e3,fP=4;function W0(){this.clicks=[]}W0.prototype.isRageClick=function(n,e,t){t=t||{};var i=t.threshold_px||hP,r=t.timeout_ms||pP,o=t.click_count||fP,s=Date.now(),a=this.clicks[this.clicks.length-1];if(a&&s-a.timestamp<r&&Math.sqrt(Math.pow(n-a.x,2)+Math.pow(e-a.y,2))<i){if(this.clicks.push({x:n,y:e,timestamp:s}),this.clicks.length>=o)return this.clicks=[],!0}else this.clicks=[{x:n,y:e,timestamp:s}];return!1};var G0="autocapture",mP="track_pageview",$0="full-url",gP="url-with-path-and-query-string",vP="url-with-path",yP="allow_element_callback",H0="allow_selectors",K0="allow_url_regexes",Y0="block_attrs",X0="block_element_callback",J0="block_selectors",Z0="block_url_regexes",Q0="capture_extra_attrs",ey="capture_text_content",ty="scroll_capture_all",ny="scroll_depth_percent_checkpoints",Wa="click",Vd="input",iy="pageview",ry="rage_click",zd="scroll",qd="submit",ht={};ht[H0]=[],ht[K0]=[],ht[Y0]=[],ht[X0]=null,ht[J0]=[],ht[Z0]=[],ht[Q0]=[],ht[ey]=!1,ht[ty]=!1,ht[ny]=[25,50,75,100],ht[Wa]=!0,ht[Vd]=!0,ht[iy]=$0,ht[ry]=!0,ht[zd]=!0,ht[qd]=!0;var Ga={$mp_autocapture:!0},oy="$mp_click",bP="$mp_input_change",sy="$mp_rage_click",_P="$mp_scroll",kP="$mp_submit",Ot=function(n){this.mp=n};Ot.prototype.init=function(){if(!lP()){Pt.critical("Autocapture unavailable: missing required DOM APIs");return}this.initPageviewTracking(),this.initClickTracking(),this.initInputTracking(),this.initScrollTracking(),this.initSubmitTracking(),this.initRageClickTracking()},Ot.prototype.getFullConfig=function(){var n=this.mp.get_config(G0);return n?v.isObject(n)?v.extend({},ht,n):ht:{}},Ot.prototype.getConfig=function(n){return this.getFullConfig()[n]},Ot.prototype.currentUrlBlocked=function(){var n,e=v.info.currentUrl(),t=this.getConfig(K0)||[];if(t.length){var i=!1;for(n=0;n<t.length;n++){var r=t[n];try{if(e.match(r)){i=!0;break}}catch(s){return Pt.critical("Error while checking block URL regex: "+r,s),!0}}if(!i)return!0}var o=this.getConfig(Z0)||[];if(!o||!o.length)return!1;for(n=0;n<o.length;n++)try{if(e.match(o[n]))return!0}catch(s){return Pt.critical("Error while checking block URL regex: "+o[n],s),!0}return!1},Ot.prototype.pageviewTrackingConfig=function(){return this.mp.get_config(G0)?this.getConfig(iy):this.mp.get_config(mP)},Ot.prototype.trackDomEvent=function(n,e){if(!this.currentUrlBlocked()){var t=this.mp.is_recording_heatmap_data()&&(e===oy&&!this.getConfig(Wa)||e===sy&&!this._getRageClickConfig()),i=cP(n,{allowElementCallback:this.getConfig(yP),allowSelectors:this.getConfig(H0),blockAttrs:this.getConfig(Y0),blockElementCallback:this.getConfig(X0),blockSelectors:this.getConfig(J0),captureExtraAttrs:this.getConfig(Q0),captureTextContent:this.getConfig(ey),capturedForHeatMap:t});i&&(v.extend(i,Ga),this.mp.track(e,i))}},Ot.prototype._getRageClickConfig=function(){var n=this.getConfig(ry);return n?n===!0?{}:typeof n=="object"?n:{}:null},Ot.prototype.initClickTracking=function(){W.removeEventListener($i,this.listenerClick),!(!this.getConfig(Wa)&&!this.mp.get_config("record_heatmap_data"))&&(Pt.log("Initializing click tracking"),this.listenerClick=W.addEventListener($i,(function(n){!this.getConfig(Wa)&&!this.mp.is_recording_heatmap_data()||this.trackDomEvent(n,oy)}).bind(this)))},Ot.prototype.initInputTracking=function(){W.removeEventListener(za,this.listenerChange),this.getConfig(Vd)&&(Pt.log("Initializing input tracking"),this.listenerChange=W.addEventListener(za,(function(n){this.getConfig(Vd)&&this.trackDomEvent(n,bP)}).bind(this)))},Ot.prototype.initPageviewTracking=function(){if(W.removeEventListener(D0,this.listenerPopstate),W.removeEventListener(N0,this.listenerHashchange),W.removeEventListener(Ur,this.listenerLocationchange),!!this.pageviewTrackingConfig()){Pt.log("Initializing pageview tracking");var n="",e=!1;this.currentUrlBlocked()||(e=this.mp.track_pageview(Ga)),e&&(n=v.info.currentUrl()),this.listenerPopstate=W.addEventListener(D0,function(){W.dispatchEvent(new Event(Ur))}),this.listenerHashchange=W.addEventListener(N0,function(){W.dispatchEvent(new Event(Ur))});var t=W.history.pushState;typeof t=="function"&&(W.history.pushState=function(r,o,s){t.call(W.history,r,o,s),W.dispatchEvent(new Event(Ur))});var i=W.history.replaceState;typeof i=="function"&&(W.history.replaceState=function(r,o,s){i.call(W.history,r,o,s),W.dispatchEvent(new Event(Ur))}),this.listenerLocationchange=W.addEventListener(Ur,xd((function(){if(!this.currentUrlBlocked()){var r=v.info.currentUrl(),o=!1,s=r.split("#")[0].split("?")[0]!==n.split("#")[0].split("?")[0],a=this.pageviewTrackingConfig();if(a===$0?o=r!==n:a===gP?o=r.split("#")[0]!==n.split("#")[0]:a===vP&&(o=s),o){var c=this.mp.track_pageview(Ga);c&&(n=r),s&&(this.lastScrollCheckpoint=0,Pt.log("Path change: re-initializing scroll depth checkpoints"))}}}).bind(this)))}},Ot.prototype.initRageClickTracking=function(){W.removeEventListener($i,this.listenerRageClick);var n=this._getRageClickConfig();!n&&!this.mp.get_config("record_heatmap_data")||(Pt.log("Initializing rage click tracking"),this._rageClickTracker||(this._rageClickTracker=new W0),this.listenerRageClick=(function(e){var t=this._getRageClickConfig();!t&&!this.mp.is_recording_heatmap_data()||this.currentUrlBlocked()||this._rageClickTracker.isRageClick(e.pageX,e.pageY,t)&&this.trackDomEvent(e,sy)}).bind(this),W.addEventListener($i,this.listenerRageClick))},Ot.prototype.initScrollTracking=function(){W.removeEventListener(L0,this.listenerScroll),this.getConfig(zd)&&(Pt.log("Initializing scroll tracking"),this.lastScrollCheckpoint=0,this.listenerScroll=W.addEventListener(L0,xd((function(){if(this.getConfig(zd)&&!this.currentUrlBlocked()){var n=this.getConfig(ty),e=(this.getConfig(ny)||[]).slice().sort(function(c,u){return c-u}),t=W.scrollY,i=v.extend({$scroll_top:t},Ga);try{var r=be.body.scrollHeight,o=Math.round(t/(r-W.innerHeight)*100);if(i.$scroll_height=r,i.$scroll_percentage=o,o>this.lastScrollCheckpoint)for(var s=0;s<e.length;s++){var a=e[s];o>=a&&this.lastScrollCheckpoint<a&&(i.$scroll_checkpoint=a,this.lastScrollCheckpoint=a,n=!0)}}catch(c){Pt.critical("Error while calculating scroll percentage",c)}n&&this.mp.track(_P,i)}}).bind(this))))},Ot.prototype.initSubmitTracking=function(){W.removeEventListener(Dd,this.listenerSubmit),this.getConfig(qd)&&(Pt.log("Initializing submit tracking"),this.listenerSubmit=W.addEventListener(Dd,(function(n){this.getConfig(qd)&&this.trackDomEvent(n,kP)}).bind(this)))},_0(Ot);var SP=W.fetch,At=Gi("flags"),$a="flags",Ha="context",Wd={};Wd[Ha]={};var ae=function(n){this.getFullApiRoute=n.getFullApiRoute,this.getMpConfig=n.getConfigFunc,this.setMpConfig=n.setConfigFunc,this.getMpProperty=n.getPropertyFunc,this.track=n.trackingFunc};ae.prototype.init=function(){if(!wP()){At.critical("Feature Flags unavailable: missing minimum required APIs");return}this.flags=null,this.fetchFlags(),this.trackedFeatures=new Set},ae.prototype.getFullConfig=function(){var n=this.getMpConfig($a);return n?v.isObject(n)?v.extend({},Wd,n):Wd:{}},ae.prototype.getConfig=function(n){return this.getFullConfig()[n]},ae.prototype.isSystemEnabled=function(){return!!this.getMpConfig($a)},ae.prototype.updateContext=function(n,e){if(!this.isSystemEnabled())return At.critical("Feature Flags not enabled, cannot update context"),Promise.resolve();var t=this.getMpConfig($a);v.isObject(t)||(t={});var i=e&&e.replace?{}:this.getConfig(Ha);return t[Ha]=v.extend({},i,n),this.setMpConfig($a,t),this.fetchFlags()},ae.prototype.areFlagsReady=function(){return this.isSystemEnabled()||At.error("Feature Flags not enabled"),!!this.flags},ae.prototype.fetchFlags=function(){if(!this.isSystemEnabled())return Promise.resolve();var n=this.getMpProperty("distinct_id"),e=this.getMpProperty("$device_id");At.log("Fetching flags for distinct ID: "+n);var t={context:v.extend({distinct_id:n,device_id:e},this.getConfig(Ha))};return this._fetchInProgressStartTime=Date.now(),this.fetchPromise=W.fetch(this.getFullApiRoute(),{method:"POST",headers:{Authorization:"Basic "+btoa(this.getMpConfig("token")+":"),"Content-Type":"application/octet-stream"},body:JSON.stringify(t)}).then((function(i){return this.markFetchComplete(),i.json().then((function(r){var o=r.flags;if(!o)throw new Error("No flags in API response");var s=new Map;v.each(o,function(a,c){s.set(c,{key:a.variant_key,value:a.variant_value})}),this.flags=s}).bind(this)).catch((function(r){this.markFetchComplete(),At.error(r)}).bind(this))}).bind(this)).catch((function(i){this.markFetchComplete(),At.error(i)}).bind(this)),this.fetchPromise},ae.prototype.markFetchComplete=function(){if(!this._fetchInProgressStartTime){At.error("Fetch in progress started time not set, cannot mark fetch complete");return}this._fetchStartTime=this._fetchInProgressStartTime,this._fetchCompleteTime=Date.now(),this._fetchLatency=this._fetchCompleteTime-this._fetchStartTime,this._fetchInProgressStartTime=null},ae.prototype.getVariant=function(n,e){return this.fetchPromise?this.fetchPromise.then((function(){return this.getVariantSync(n,e)}).bind(this)).catch(function(t){return At.error(t),e}):new Promise(function(t){At.critical("Feature Flags not initialized"),t(e)})},ae.prototype.getVariantSync=function(n,e){if(!this.areFlagsReady())return At.log("Flags not loaded yet"),e;var t=this.flags.get(n);return t?(this.trackFeatureCheck(n,t),t):(At.log('No flag found: "'+n+'"'),e)},ae.prototype.getVariantValue=function(n,e){return this.getVariant(n,{value:e}).then(function(t){return t.value}).catch(function(t){return At.error(t),e})},ae.prototype.getFeatureData=function(n,e){return At.critical("mixpanel.flags.get_feature_data() is deprecated and will be removed in a future release. Use mixpanel.flags.get_variant_value() instead."),this.getVariantValue(n,e)},ae.prototype.getVariantValueSync=function(n,e){return this.getVariantSync(n,{value:e}).value},ae.prototype.isEnabled=function(n,e){return this.getVariantValue(n).then((function(){return this.isEnabledSync(n,e)}).bind(this)).catch(function(t){return At.error(t),e})},ae.prototype.isEnabledSync=function(n,e){e=e||!1;var t=this.getVariantValueSync(n,e);return t!==!0&&t!==!1&&(At.error('Feature flag "'+n+'" value: '+t+" is not a boolean; returning fallback value: "+e),t=e),t},ae.prototype.trackFeatureCheck=function(n,e){this.trackedFeatures.has(n)||(this.trackedFeatures.add(n),this.track("$experiment_started",{"Experiment name":n,"Variant name":e.key,$experiment_type:"feature_flag","Variant fetch start time":new Date(this._fetchStartTime).toISOString(),"Variant fetch complete time":new Date(this._fetchCompleteTime).toISOString(),"Variant fetch latency (ms)":this._fetchLatency}))};function wP(){return!!SP&&typeof Promise<"u"&&typeof Map<"u"&&typeof Set<"u"}_0(ae),ae.prototype.are_flags_ready=ae.prototype.areFlagsReady,ae.prototype.get_variant=ae.prototype.getVariant,ae.prototype.get_variant_sync=ae.prototype.getVariantSync,ae.prototype.get_variant_value=ae.prototype.getVariantValue,ae.prototype.get_variant_value_sync=ae.prototype.getVariantValueSync,ae.prototype.is_enabled=ae.prototype.isEnabled,ae.prototype.is_enabled_sync=ae.prototype.isEnabledSync,ae.prototype.update_context=ae.prototype.updateContext,ae.prototype.get_feature_data=ae.prototype.getFeatureData;var qn=function(){};qn.prototype.create_properties=function(){},qn.prototype.event_handler=function(){},qn.prototype.after_track_handler=function(){},qn.prototype.init=function(n){return this.mp=n,this},qn.prototype.track=function(n,e,t,i){var r=this,o=v.dom_query(n);if(o.length===0){_e.error("The DOM query ("+n+") returned 0 elements");return}return v.each(o,function(s){v.register_event(s,this.override_event,function(a){var c={},u=r.create_properties(t,this),l=r.mp.get_config("track_links_timeout");r.event_handler(a,this,c),window.setTimeout(r.track_callback(i,u,c,!0),l),r.mp.track(e,u,r.track_callback(i,u,c))})},this),!0},qn.prototype.track_callback=function(n,e,t,i){i=i||!1;var r=this;return function(){t.callback_fired||(t.callback_fired=!0,!(n&&n(i,e)===!1)&&r.after_track_handler(e,t,i))}},qn.prototype.create_properties=function(n,e){var t;return typeof n=="function"?t=n(e):t=v.extend({},n),t};var Fr=function(){this.override_event="click"};v.inherit(Fr,qn),Fr.prototype.create_properties=function(n,e){var t=Fr.superclass.create_properties.apply(this,arguments);return e.href&&(t.url=e.href),t},Fr.prototype.event_handler=function(n,e,t){t.new_tab=n.which===2||n.metaKey||n.ctrlKey||e.target==="_blank",t.href=e.href,t.new_tab||n.preventDefault()},Fr.prototype.after_track_handler=function(n,e){e.new_tab||setTimeout(function(){window.location=e.href},0)};var Ka=function(){this.override_event="submit"};v.inherit(Ka,qn),Ka.prototype.event_handler=function(n,e,t){t.element=e,n.preventDefault()},Ka.prototype.after_track_handler=function(n,e){setTimeout(function(){e.element.submit()},0)};var pi="$set",Br="$set_once",sn="$unset",Hi="$add",Tn="$append",Ki="$union",Wn="$remove",CP="$delete",ay={set_action:function(n,e){var t={},i={};return v.isObject(n)?v.each(n,function(r,o){this._is_reserved_property(o)||(i[o]=r)},this):i[n]=e,t[pi]=i,t},unset_action:function(n){var e={},t=[];return v.isArray(n)||(n=[n]),v.each(n,function(i){this._is_reserved_property(i)||t.push(i)},this),e[sn]=t,e},set_once_action:function(n,e){var t={},i={};return v.isObject(n)?v.each(n,function(r,o){this._is_reserved_property(o)||(i[o]=r)},this):i[n]=e,t[Br]=i,t},union_action:function(n,e){var t={},i={};return v.isObject(n)?v.each(n,function(r,o){this._is_reserved_property(o)||(i[o]=v.isArray(r)?r:[r])},this):i[n]=v.isArray(e)?e:[e],t[Ki]=i,t},append_action:function(n,e){var t={},i={};return v.isObject(n)?v.each(n,function(r,o){this._is_reserved_property(o)||(i[o]=r)},this):i[n]=e,t[Tn]=i,t},remove_action:function(n,e){var t={},i={};return v.isObject(n)?v.each(n,function(r,o){this._is_reserved_property(o)||(i[o]=r)},this):i[n]=e,t[Wn]=i,t},delete_action:function(){var n={};return n[CP]="",n}},Ue=function(){};v.extend(Ue.prototype,ay),Ue.prototype._init=function(n,e,t){this._mixpanel=n,this._group_key=e,this._group_id=t},Ue.prototype.set=Nr(function(n,e,t){var i=this.set_action(n,e);return v.isObject(n)&&(t=e),this._send_request(i,t)}),Ue.prototype.set_once=Nr(function(n,e,t){var i=this.set_once_action(n,e);return v.isObject(n)&&(t=e),this._send_request(i,t)}),Ue.prototype.unset=Nr(function(n,e){var t=this.unset_action(n);return this._send_request(t,e)}),Ue.prototype.union=Nr(function(n,e,t){v.isObject(n)&&(t=e);var i=this.union_action(n,e);return this._send_request(i,t)}),Ue.prototype.delete=Nr(function(n){var e=this.delete_action();return this._send_request(e,n)}),Ue.prototype.remove=Nr(function(n,e,t){var i=this.remove_action(n,e);return this._send_request(i,t)}),Ue.prototype._send_request=function(n,e){n.$group_key=this._group_key,n.$group_id=this._group_id,n.$token=this._get_config("token");var t=v.encodeDates(n);return this._mixpanel._track_or_batch({type:"groups",data:t,endpoint:this._mixpanel.get_api_host("groups")+"/"+this._get_config("api_routes").groups,batcher:this._mixpanel.request_batchers.groups},e)},Ue.prototype._is_reserved_property=function(n){return n==="$group_key"||n==="$group_id"},Ue.prototype._get_config=function(n){return this._mixpanel.get_config(n)},Ue.prototype.toString=function(){return this._mixpanel.toString()+".group."+this._group_key+"."+this._group_id},Ue.prototype.remove=Ue.prototype.remove,Ue.prototype.set=Ue.prototype.set,Ue.prototype.set_once=Ue.prototype.set_once,Ue.prototype.union=Ue.prototype.union,Ue.prototype.unset=Ue.prototype.unset,Ue.prototype.toString=Ue.prototype.toString;var ee=function(){};v.extend(ee.prototype,ay),ee.prototype._init=function(n){this._mixpanel=n},ee.prototype.set=hi(function(n,e,t){var i=this.set_action(n,e);return v.isObject(n)&&(t=e),this._get_config("save_referrer")&&this._mixpanel.persistence.update_referrer_info(document.referrer),i[pi]=v.extend({},v.info.people_properties(),i[pi]),this._send_request(i,t)}),ee.prototype.set_once=hi(function(n,e,t){var i=this.set_once_action(n,e);return v.isObject(n)&&(t=e),this._send_request(i,t)}),ee.prototype.unset=hi(function(n,e){var t=this.unset_action(n);return this._send_request(t,e)}),ee.prototype.increment=hi(function(n,e,t){var i={},r={};return v.isObject(n)?(v.each(n,function(o,s){if(!this._is_reserved_property(s))if(isNaN(parseFloat(o))){_e.error("Invalid increment value passed to mixpanel.people.increment - must be a number");return}else r[s]=o},this),t=e):(v.isUndefined(e)&&(e=1),r[n]=e),i[Hi]=r,this._send_request(i,t)}),ee.prototype.append=hi(function(n,e,t){v.isObject(n)&&(t=e);var i=this.append_action(n,e);return this._send_request(i,t)}),ee.prototype.remove=hi(function(n,e,t){v.isObject(n)&&(t=e);var i=this.remove_action(n,e);return this._send_request(i,t)}),ee.prototype.union=hi(function(n,e,t){v.isObject(n)&&(t=e);var i=this.union_action(n,e);return this._send_request(i,t)}),ee.prototype.track_charge=hi(function(){_e.error("mixpanel.people.track_charge() is deprecated and no longer has any effect.")}),ee.prototype.clear_charges=function(n){return this.set("$transactions",[],n)},ee.prototype.delete_user=function(){if(!this._identify_called()){_e.error("mixpanel.people.delete_user() requires you to call identify() first");return}var n={$delete:this._mixpanel.get_distinct_id()};return this._send_request(n)},ee.prototype.toString=function(){return this._mixpanel.toString()+".people"},ee.prototype._send_request=function(n,e){n.$token=this._get_config("token"),n.$distinct_id=this._mixpanel.get_distinct_id();var t=this._mixpanel.get_property("$device_id"),i=this._mixpanel.get_property("$user_id"),r=this._mixpanel.get_property("$had_persisted_distinct_id");t&&(n.$device_id=t),i&&(n.$user_id=i),r&&(n.$had_persisted_distinct_id=r);var o=v.encodeDates(n);return this._identify_called()?this._mixpanel._track_or_batch({type:"people",data:o,endpoint:this._mixpanel.get_api_host("people")+"/"+this._get_config("api_routes").engage,batcher:this._mixpanel.request_batchers.people},e):(this._enqueue(n),v.isUndefined(e)||(this._get_config("verbose")?e({status:-1,error:null}):e(-1)),v.truncate(o,255))},ee.prototype._get_config=function(n){return this._mixpanel.get_config(n)},ee.prototype._identify_called=function(){return this._mixpanel._flags.identify_called===!0},ee.prototype._enqueue=function(n){pi in n?this._mixpanel.persistence._add_to_people_queue(pi,n):Br in n?this._mixpanel.persistence._add_to_people_queue(Br,n):sn in n?this._mixpanel.persistence._add_to_people_queue(sn,n):Hi in n?this._mixpanel.persistence._add_to_people_queue(Hi,n):Tn in n?this._mixpanel.persistence._add_to_people_queue(Tn,n):Wn in n?this._mixpanel.persistence._add_to_people_queue(Wn,n):Ki in n?this._mixpanel.persistence._add_to_people_queue(Ki,n):_e.error("Invalid call to _enqueue():",n)},ee.prototype._flush_one_queue=function(n,e,t,i){var r=this,o=v.extend({},this._mixpanel.persistence.load_queue(n)),s=o;!v.isUndefined(o)&&v.isObject(o)&&!v.isEmptyObject(o)&&(r._mixpanel.persistence._pop_from_people_queue(n,o),r._mixpanel.persistence.save(),i&&(s=i(o)),e.call(r,s,function(a,c){a===0&&r._mixpanel.persistence._add_to_people_queue(n,o),v.isUndefined(t)||t(a,c)}))},ee.prototype._flush=function(n,e,t,i,r,o,s){var a=this;this._flush_one_queue(pi,this.set,n),this._flush_one_queue(Br,this.set_once,i),this._flush_one_queue(sn,this.unset,o,function(g){return v.keys(g)}),this._flush_one_queue(Hi,this.increment,e),this._flush_one_queue(Ki,this.union,r);var c=this._mixpanel.persistence.load_queue(Tn);if(!v.isUndefined(c)&&v.isArray(c)&&c.length)for(var u,l=function(g,y){g===0&&a._mixpanel.persistence._add_to_people_queue(Tn,u),v.isUndefined(t)||t(g,y)},d=c.length-1;d>=0;d--)c=this._mixpanel.persistence.load_queue(Tn),u=c.pop(),a._mixpanel.persistence.save(),v.isEmptyObject(u)||a.append(u,l);var h=this._mixpanel.persistence.load_queue(Wn);if(!v.isUndefined(h)&&v.isArray(h)&&h.length)for(var p,m=function(g,y){g===0&&a._mixpanel.persistence._add_to_people_queue(Wn,p),v.isUndefined(s)||s(g,y)},f=h.length-1;f>=0;f--)h=this._mixpanel.persistence.load_queue(Wn),p=h.pop(),a._mixpanel.persistence.save(),v.isEmptyObject(p)||a.remove(p,m)},ee.prototype._is_reserved_property=function(n){return n==="$distinct_id"||n==="$token"||n==="$device_id"||n==="$user_id"||n==="$had_persisted_distinct_id"},ee.prototype.set=ee.prototype.set,ee.prototype.set_once=ee.prototype.set_once,ee.prototype.unset=ee.prototype.unset,ee.prototype.increment=ee.prototype.increment,ee.prototype.append=ee.prototype.append,ee.prototype.remove=ee.prototype.remove,ee.prototype.union=ee.prototype.union,ee.prototype.track_charge=ee.prototype.track_charge,ee.prototype.clear_charges=ee.prototype.clear_charges,ee.prototype.delete_user=ee.prototype.delete_user,ee.prototype.toString=ee.prototype.toString;var Gd="__mps",$d="__mpso",Hd="__mpus",Kd="__mpa",Yd="__mpap",Xd="__mpr",Jd="__mpu",cy="$people_distinct_id",Ya="__alias",Xo="__timers",TP=[Gd,$d,Hd,Kd,Yd,Xd,Jd,cy,Ya,Xo],re=function(n){this.props={},this.campaign_params_saved=!1,n.persistence_name?this.name="mp_"+n.persistence_name:this.name="mp_"+n.token+"_mixpanel";var e=n.persistence;e!=="cookie"&&e!=="localStorage"&&(_e.critical("Unknown persistence type "+e+"; falling back to cookie"),e=n.persistence="cookie"),e==="localStorage"&&v.localStorage.is_supported()?this.storage=v.localStorage:this.storage=v.cookie,this.load(),this.update_config(n),this.upgrade(),this.save()};re.prototype.properties=function(){var n={};return this.load(),v.each(this.props,function(e,t){v.include(TP,t)||(n[t]=e)}),n},re.prototype.load=function(){if(!this.disabled){var n=this.storage.parse(this.name);n&&(this.props=v.extend({},n))}},re.prototype.upgrade=function(){var n,e;this.storage===v.localStorage?(n=v.cookie.parse(this.name),v.cookie.remove(this.name),v.cookie.remove(this.name,!0),n&&this.register_once(n)):this.storage===v.cookie&&(e=v.localStorage.parse(this.name),v.localStorage.remove(this.name),e&&this.register_once(e))},re.prototype.save=function(){this.disabled||this.storage.set(this.name,Mr(this.props),this.expire_days,this.cross_subdomain,this.secure,this.cross_site,this.cookie_domain)},re.prototype.load_prop=function(n){return this.load(),this.props[n]},re.prototype.remove=function(){this.storage.remove(this.name,!1,this.cookie_domain),this.storage.remove(this.name,!0,this.cookie_domain)},re.prototype.clear=function(){this.remove(),this.props={}},re.prototype.register_once=function(n,e,t){return v.isObject(n)?(typeof e>"u"&&(e="None"),this.expire_days=typeof t>"u"?this.default_expiry:t,this.load(),v.each(n,function(i,r){(!this.props.hasOwnProperty(r)||this.props[r]===e)&&(this.props[r]=i)},this),this.save(),!0):!1},re.prototype.register=function(n,e){return v.isObject(n)?(this.expire_days=typeof e>"u"?this.default_expiry:e,this.load(),v.extend(this.props,n),this.save(),!0):!1},re.prototype.unregister=function(n){this.load(),n in this.props&&(delete this.props[n],this.save())},re.prototype.update_search_keyword=function(n){this.register(v.info.searchInfo(n))},re.prototype.update_referrer_info=function(n){this.register_once({$initial_referrer:n||"$direct",$initial_referring_domain:v.info.referringDomain(n)||"$direct"},"")},re.prototype.get_referrer_info=function(){return v.strip_empty_properties({$initial_referrer:this.props.$initial_referrer,$initial_referring_domain:this.props.$initial_referring_domain})},re.prototype.update_config=function(n){this.default_expiry=this.expire_days=n.cookie_expiration,this.set_disabled(n.disable_persistence),this.set_cookie_domain(n.cookie_domain),this.set_cross_site(n.cross_site_cookie),this.set_cross_subdomain(n.cross_subdomain_cookie),this.set_secure(n.secure_cookie)},re.prototype.set_disabled=function(n){this.disabled=n,this.disabled?this.remove():this.save()},re.prototype.set_cookie_domain=function(n){n!==this.cookie_domain&&(this.remove(),this.cookie_domain=n,this.save())},re.prototype.set_cross_site=function(n){n!==this.cross_site&&(this.cross_site=n,this.remove(),this.save())},re.prototype.set_cross_subdomain=function(n){n!==this.cross_subdomain&&(this.cross_subdomain=n,this.remove(),this.save())},re.prototype.get_cross_subdomain=function(){return this.cross_subdomain},re.prototype.set_secure=function(n){n!==this.secure&&(this.secure=!!n,this.remove(),this.save())},re.prototype._add_to_people_queue=function(n,e){var t=this._get_queue_key(n),i=e[n],r=this._get_or_create_queue(pi),o=this._get_or_create_queue(Br),s=this._get_or_create_queue(sn),a=this._get_or_create_queue(Hi),c=this._get_or_create_queue(Ki),u=this._get_or_create_queue(Wn,[]),l=this._get_or_create_queue(Tn,[]);t===Gd?(v.extend(r,i),this._pop_from_people_queue(Hi,i),this._pop_from_people_queue(Ki,i),this._pop_from_people_queue(sn,i)):t===$d?(v.each(i,function(d,h){h in o||(o[h]=d)}),this._pop_from_people_queue(sn,i)):t===Hd?v.each(i,function(d){v.each([r,o,a,c],function(h){d in h&&delete h[d]}),v.each(l,function(h){d in h&&delete h[d]}),s[d]=!0}):t===Kd?(v.each(i,function(d,h){h in r?r[h]+=d:(h in a||(a[h]=0),a[h]+=d)},this),this._pop_from_people_queue(sn,i)):t===Jd?(v.each(i,function(d,h){v.isArray(d)&&(h in c||(c[h]=[]),v.each(d,function(p){v.include(c[h],p)||c[h].push(p)}))}),this._pop_from_people_queue(sn,i)):t===Xd?(u.push(i),this._pop_from_people_queue(Tn,i)):t===Yd&&(l.push(i),this._pop_from_people_queue(sn,i)),_e.log("MIXPANEL PEOPLE REQUEST (QUEUED, PENDING IDENTIFY):"),_e.log(e),this.save()},re.prototype._pop_from_people_queue=function(n,e){var t=this.props[this._get_queue_key(n)];v.isUndefined(t)||v.each(e,function(i,r){n===Tn||n===Wn?v.each(t,function(o){o[r]===i&&delete o[r]}):delete t[r]},this)},re.prototype.load_queue=function(n){return this.load_prop(this._get_queue_key(n))},re.prototype._get_queue_key=function(n){if(n===pi)return Gd;if(n===Br)return $d;if(n===sn)return Hd;if(n===Hi)return Kd;if(n===Tn)return Yd;if(n===Wn)return Xd;if(n===Ki)return Jd;_e.error("Invalid queue:",n)},re.prototype._get_or_create_queue=function(n,e){var t=this._get_queue_key(n);return e=v.isUndefined(e)?{}:e,this.props[t]||(this.props[t]=e)},re.prototype.set_event_timer=function(n,e){var t=this.load_prop(Xo)||{};t[n]=e,this.props[Xo]=t,this.save()},re.prototype.remove_event_timer=function(n){var e=this.load_prop(Xo)||{},t=e[n];return v.isUndefined(t)||(delete this.props[Xo][n],this.save()),t};var Zd,uy=function(n,e){throw new Error(n+" not available in this build.")},Tt,ly=0,xP=1,EP=function(n){return n},Yt="mixpanel",dy="base64",IP="json",Qd="$device:",jr=W.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest,hy=!jr&&Vn.indexOf("MSIE")===-1&&Vn.indexOf("Mozilla")===-1,Xa=null;ui.sendBeacon&&(Xa=function(){return ui.sendBeacon.apply(ui,arguments)});var py={track:"track/",engage:"engage/",groups:"groups/",record:"record/",flags:"flags/"},fy={api_host:"https://api-js.mixpanel.com",api_hosts:{},api_routes:py,api_extra_query_params:{},api_method:"POST",api_transport:"XHR",api_payload_format:dy,app_host:"https://mixpanel.com",autocapture:!1,cdn:"https://cdn.mxpnl.com",cross_site_cookie:!1,cross_subdomain_cookie:!0,error_reporter:li,flags:!1,persistence:"cookie",persistence_name:"",cookie_domain:"",cookie_name:"",loaded:li,mp_loader:null,track_marketing:!0,track_pageview:!1,skip_first_touch_marketing:!1,store_google:!0,stop_utm_persistence:!1,save_referrer:!0,test:!1,verbose:!1,img:!1,debug:!1,track_links_timeout:300,cookie_expiration:365,upgrade:!1,disable_persistence:!1,disable_cookie:!1,secure_cookie:!1,ip:!0,opt_out_tracking_by_default:!1,opt_out_persistence_by_default:!1,opt_out_tracking_persistence_type:"localStorage",opt_out_tracking_cookie_prefix:null,property_blacklist:[],xhr_headers:{},ignore_dnt:!1,batch_requests:!0,batch_size:50,batch_flush_interval_ms:5e3,batch_request_timeout_ms:9e4,batch_autostart:!0,hooks:{},record_block_class:new RegExp("^(mp-block|fs-exclude|amp-block|rr-block|ph-no-capture)$"),record_block_selector:"img, video, audio",record_canvas:!1,record_collect_fonts:!1,record_heatmap_data:!1,record_idle_timeout_ms:30*60*1e3,record_mask_text_class:new RegExp("^(mp-mask|fs-mask|amp-mask|rr-mask|ph-mask)$"),record_mask_text_selector:"*",record_max_ms:Wo,record_min_ms:0,record_sessions_percent:0,recorder_src:"https://cdn.mxpnl.com/libs/mixpanel-recorder.min.js"},my=!1,E=function(){},eh=function(n,e,t){var i,r=t===Yt?Tt:Tt[t];if(r&&Zd===ly)i=r;else{if(r&&!v.isArray(r)){_e.error("You have already initialized "+t);return}i=new E}if(i._cached_groups={},i._init(n,e,t),i.people=new ee,i.people._init(i),!i.get_config("skip_first_touch_marketing")){var o=v.info.campaignParams(null),s={},a=!1;v.each(o,function(c,u){s["initial_"+u]=c,c&&(a=!0)}),a&&i.people.set_once(s)}return on.DEBUG=on.DEBUG||i.get_config("debug"),!v.isUndefined(r)&&v.isArray(r)&&(i._execute_array.call(i.people,r.people),i._execute_array(r)),i};E.prototype.init=function(n,e,t){if(v.isUndefined(t)){this.report_error("You must name your new library: init(token, config, name)");return}if(t===Yt){this.report_error("You must initialize the main mixpanel object right after you include the Mixpanel js snippet");return}var i=eh(n,e,t);return Tt[t]=i,i._loaded(),i},E.prototype._init=function(n,e,t){e=e||{},this.__loaded=!0,this.config={};var i={};if(!("api_payload_format"in e)){var r=e.api_host||fy.api_host;r.match(/\.mixpanel\.com/)&&(i.api_payload_format=IP)}if(this.set_config(v.extend({},fy,i,e,{name:t,token:n,callback_fn:(t===Yt?t:Yt+"."+t)+"._jsc"})),this._jsc=li,this.__dom_loaded_queue=[],this.__request_queue=[],this.__disabled_events=[],this._flags={disable_all_events:!1,identify_called:!1},this.request_batchers={},this._batch_requests=this.get_config("batch_requests"),this._batch_requests){if(!v.localStorage.is_supported(!0)||!jr)this._batch_requests=!1,_e.log("Turning off Mixpanel request-queueing; needs XHR and localStorage support"),v.each(this.get_batcher_configs(),function(a){_e.log("Clearing batch queue "+a.queue_key),v.localStorage.remove(a.queue_key)});else if(this.init_batchers(),Xa&&W.addEventListener){var o=v.bind(function(){this.request_batchers.events.stopped||this.request_batchers.events.flush({unloading:!0})},this);W.addEventListener("pagehide",function(a){a.persisted&&o()}),W.addEventListener("visibilitychange",function(){be.visibilityState==="hidden"&&o()})}}this.persistence=this.cookie=new re(this.config),this.unpersisted_superprops={},this._gdpr_init();var s=v.UUID();this.get_distinct_id()||this.register_once({distinct_id:Qd+s,$device_id:s},""),this.flags=new ae({getFullApiRoute:v.bind(function(){return this.get_api_host("flags")+"/"+this.get_config("api_routes").flags},this),getConfigFunc:v.bind(this.get_config,this),setConfigFunc:v.bind(this.set_config,this),getPropertyFunc:v.bind(this.get_property,this),trackingFunc:v.bind(this.track,this)}),this.flags.init(),this.flags=this.flags,this.autocapture=new Ot(this),this.autocapture.init(),this._init_tab_id(),this._check_and_start_session_recording()},E.prototype._init_tab_id=function(){if(v.sessionStorage.is_supported())try{var n=this.get_config("name")+"_"+this.get_config("token"),e="mp_tab_id_"+n,t="mp_gen_new_tab_id_"+n;(v.sessionStorage.get(t)||!v.sessionStorage.get(e))&&v.sessionStorage.set(e,"$tab-"+v.UUID()),v.sessionStorage.set(t,"1"),this.tab_id=v.sessionStorage.get(e),W.addEventListener("beforeunload",function(){v.sessionStorage.remove(t)})}catch(i){this.report_error("Error initializing tab id",i)}else this.report_error("Session storage is not supported, cannot keep track of unique tab ID.")},E.prototype.get_tab_id=function(){return this.tab_id||null},E.prototype._should_load_recorder=function(){var n=new Sn(Pd),e=this.get_tab_id();return n.init().then(function(){return n.getAll()}).then(function(t){for(var i=0;i<t.length;i++)if(Nd(t[i])||t[i].tabId===e)return!0;return!1}).catch(v.bind(function(t){this.report_error("Error checking recording registry",t)},this))},E.prototype._check_and_start_session_recording=di(function(n){if(!W.MutationObserver){_e.critical("Browser does not support MutationObserver; skipping session recording");return}var e=v.bind(function(i){var r=v.bind(function(){this._recorder=this._recorder||new W.__mp_recorder(this),this._recorder.resumeRecording(i)},this);v.isUndefined(W.__mp_recorder)?uy(this.get_config("recorder_src"),r):r()},this),t=this.get_config("record_sessions_percent")>0&&Math.random()*100<=this.get_config("record_sessions_percent");n||t?e(!0):this._should_load_recorder().then(function(i){i&&e(!1)})}),E.prototype.start_session_recording=function(){this._check_and_start_session_recording(!0)},E.prototype.stop_session_recording=function(){return this._recorder?this._recorder.stopRecording():Promise.resolve()},E.prototype.pause_session_recording=function(){return this._recorder?this._recorder.pauseRecording():Promise.resolve()},E.prototype.resume_session_recording=function(){return this._recorder?this._recorder.resumeRecording():Promise.resolve()},E.prototype.is_recording_heatmap_data=function(){return this._get_session_replay_id()&&this.get_config("record_heatmap_data")},E.prototype.get_session_recording_properties=function(){var n={},e=this._get_session_replay_id();return e&&(n.$mp_replay_id=e),n},E.prototype.get_session_replay_url=function(){var n=null,e=this._get_session_replay_id();if(e){var t=v.HTTPBuildQuery({replay_id:e,distinct_id:this.get_distinct_id(),token:this.get_config("token")});n="https://mixpanel.com/projects/replay-redirect?"+t}return n},E.prototype._get_session_replay_id=function(){var n=null;return this._recorder&&(n=this._recorder.replayId),n||null},E.prototype.__get_recorder=function(){return this._recorder},E.prototype._loaded=function(){if(this.get_config("loaded")(this),this._set_default_superprops(),this.people.set_once(this.persistence.get_referrer_info()),this.get_config("store_google")&&this.get_config("stop_utm_persistence")){var n=v.info.campaignParams(null);v.each(n,(function(e,t){this.unregister(t)}).bind(this))}},E.prototype._set_default_superprops=function(){this.persistence.update_search_keyword(be.referrer),this.get_config("store_google")&&!this.get_config("stop_utm_persistence")&&this.register(v.info.campaignParams()),this.get_config("save_referrer")&&this.persistence.update_referrer_info(be.referrer)},E.prototype._dom_loaded=function(){v.each(this.__dom_loaded_queue,function(n){this._track_dom.apply(this,n)},this),this.has_opted_out_tracking()||v.each(this.__request_queue,function(n){this._send_request.apply(this,n)},this),delete this.__dom_loaded_queue,delete this.__request_queue},E.prototype._track_dom=function(n,e){if(this.get_config("img"))return this.report_error("You can't use DOM tracking functions with img = true."),!1;if(!my)return this.__dom_loaded_queue.push([n,e]),!1;var t=new n().init(this);return t.track.apply(t,e)},E.prototype._prepare_callback=function(n,e){if(v.isUndefined(n))return null;if(jr){var t=function(s){n(s,e)};return t}else{var i=this._jsc,r=""+Math.floor(Math.random()*1e8),o=this.get_config("callback_fn")+"["+r+"]";return i[r]=function(s){delete i[r],n(s,e)},o}},E.prototype._send_request=function(n,e,t,i){var r=!0;if(hy)return this.__request_queue.push(arguments),r;var o={method:this.get_config("api_method"),transport:this.get_config("api_transport"),verbose:this.get_config("verbose")},s=null;!i&&(v.isFunction(t)||typeof t=="string")&&(i=t,t=null),t=v.extend(o,t||{}),jr||(t.method="GET");var a=t.method==="POST",c=Xa&&a&&t.transport.toLowerCase()==="sendbeacon",u=t.verbose;e.verbose&&(u=!0),this.get_config("test")&&(e.test=1),u&&(e.verbose=1),this.get_config("img")&&(e.img=1),jr||(i?e.callback=i:(u||this.get_config("test"))&&(e.callback="(function(){})")),e.ip=this.get_config("ip")?1:0,e._=new Date().getTime().toString(),a&&(s="data="+encodeURIComponent(e.data),delete e.data),v.extend(e,this.get_config("api_extra_query_params")),n+="?"+v.HTTPBuildQuery(e);var l=this;if("img"in e){var d=be.createElement("img");d.src=n,be.body.appendChild(d)}else if(c){try{r=Xa(n,s)}catch(y){l.report_error(y),r=!1}try{i&&i(r?1:0)}catch(y){l.report_error(y)}}else if(jr)try{var h=new XMLHttpRequest;h.open(t.method,n,!0);var p=this.get_config("xhr_headers");if(a&&(p["Content-Type"]="application/x-www-form-urlencoded"),v.each(p,function(y,b){h.setRequestHeader(b,y)}),t.timeout_ms&&typeof h.timeout<"u"){h.timeout=t.timeout_ms;var m=new Date().getTime()}h.withCredentials=!0,h.onreadystatechange=function(){if(h.readyState===4)if(h.status===200){if(i)if(u){var y;try{y=v.JSONDecode(h.responseText)}catch(w){if(l.report_error(w),t.ignore_json_errors)y=h.responseText;else return}i(y)}else i(Number(h.responseText))}else{var b;if(h.timeout&&!h.status&&new Date().getTime()-m>=h.timeout?b="timeout":b="Bad HTTP status: "+h.status+" "+h.statusText,l.report_error(b),i)if(u){var S=h.responseHeaders||{};i({status:0,httpStatusCode:h.status,error:b,retryAfter:S["Retry-After"]})}else i(0)}},h.send(s)}catch(y){l.report_error(y),r=!1}else{var f=be.createElement("script");f.type="text/javascript",f.async=!0,f.defer=!0,f.src=n;var g=be.getElementsByTagName("script")[0];g.parentNode.insertBefore(f,g)}return r},E.prototype._execute_array=function(n){var e,t=[],i=[],r=[];v.each(n,function(s){s&&(e=s[0],v.isArray(e)?r.push(s):typeof s=="function"?s.call(this):v.isArray(s)&&e==="alias"?t.push(s):v.isArray(s)&&e.indexOf("track")!==-1&&typeof this[e]=="function"?r.push(s):i.push(s))},this);var o=function(s,a){v.each(s,function(c){if(v.isArray(c[0])){var u=a;v.each(c,function(l){u=u[l[0]].apply(u,l.slice(1))})}else this[c[0]].apply(this,c.slice(1))},a)};o(t,this),o(i,this),o(r,this)},E.prototype.are_batchers_initialized=function(){return!!this.request_batchers.events},E.prototype.get_batcher_configs=function(){var n="__mpq_"+this.get_config("token");return this._batcher_configs=this._batcher_configs||{events:{type:"events",api_name:"track",queue_key:n+"_ev"},people:{type:"people",api_name:"engage",queue_key:n+"_pp"},groups:{type:"groups",api_name:"groups",queue_key:n+"_gr"}},this._batcher_configs},E.prototype.init_batchers=function(){if(!this.are_batchers_initialized()){var n=v.bind(function(t){return new Kt(t.queue_key,{libConfig:this.config,errorReporter:this.get_config("error_reporter"),sendRequestFunc:v.bind(function(i,r,o){var s=this.get_config("api_routes");this._send_request(this.get_api_host(t.api_name)+"/"+s[t.api_name],this._encode_data_for_request(i),r,this._prepare_callback(o,i))},this),beforeSendHook:v.bind(function(i){return this._run_hook("before_send_"+t.type,i)},this),stopAllBatchingFunc:v.bind(this.stop_batch_senders,this),usePersistence:!0})},this),e=this.get_batcher_configs();this.request_batchers={events:n(e.events),people:n(e.people),groups:n(e.groups)}}this.get_config("batch_autostart")&&this.start_batch_senders()},E.prototype.start_batch_senders=function(){this._batchers_were_started=!0,this.are_batchers_initialized()&&(this._batch_requests=!0,v.each(this.request_batchers,function(n){n.start()}))},E.prototype.stop_batch_senders=function(){this._batch_requests=!1,v.each(this.request_batchers,function(n){n.stop(),n.clear()})},E.prototype.push=function(n){this._execute_array([n])},E.prototype.disable=function(n){typeof n>"u"?this._flags.disable_all_events=!0:this.__disabled_events=this.__disabled_events.concat(n)},E.prototype._encode_data_for_request=function(n){var e=Mr(n);return this.get_config("api_payload_format")===dy&&(e=v.base64Encode(e)),{data:e}},E.prototype._track_or_batch=function(n,e){var t=v.truncate(n.data,255),i=n.endpoint,r=n.batcher,o=n.should_send_immediately,s=n.send_request_options||{};e=e||li;var a=!0,c=v.bind(function(){return s.skip_hooks||(t=this._run_hook("before_send_"+n.type,t)),t?(_e.log("MIXPANEL REQUEST:"),_e.log(t),this._send_request(i,this._encode_data_for_request(t),s,this._prepare_callback(e,t))):null},this);return this._batch_requests&&!o?r.enqueue(t).then(function(u){u?e(1,t):c()}):a=c(),a&&t},E.prototype.track=di(function(n,e,t,i){!i&&typeof t=="function"&&(i=t,t=null),t=t||{};var r=t.transport;r&&(t.transport=r);var o=t.send_immediately;if(typeof i!="function"&&(i=li),v.isUndefined(n)){this.report_error("No event name provided to mixpanel.track");return}if(this._event_is_disabled(n)){i(0);return}e=v.extend({},e),e.token=this.get_config("token");var s=this.persistence.remove_event_timer(n);if(!v.isUndefined(s)){var a=new Date().getTime()-s;e.$duration=parseFloat((a/1e3).toFixed(3))}this._set_default_superprops();var c=this.get_config("track_marketing")?v.info.marketingParams():{};e=v.extend({},v.info.properties({mp_loader:this.get_config("mp_loader")}),c,this.persistence.properties(),this.unpersisted_superprops,this.get_session_recording_properties(),e);var u=this.get_config("property_blacklist");v.isArray(u)?v.each(u,function(h){delete e[h]}):this.report_error("Invalid value for property_blacklist config: "+u);var l={event:n,properties:e},d=this._track_or_batch({type:"events",data:l,endpoint:this.get_api_host("events")+"/"+this.get_config("api_routes").track,batcher:this.request_batchers.events,should_send_immediately:o,send_request_options:t},i);return d}),E.prototype.set_group=di(function(n,e,t){v.isArray(e)||(e=[e]);var i={};return i[n]=e,this.register(i),this.people.set(n,e,t)}),E.prototype.add_group=di(function(n,e,t){var i=this.get_property(n),r={};return i===void 0?(r[n]=[e],this.register(r)):i.indexOf(e)===-1&&(i.push(e),r[n]=i,this.register(r)),this.people.union(n,e,t)}),E.prototype.remove_group=di(function(n,e,t){var i=this.get_property(n);if(i!==void 0){var r=i.indexOf(e);r>-1&&(i.splice(r,1),this.register({group_key:i})),i.length===0&&this.unregister(n)}return this.people.remove(n,e,t)}),E.prototype.track_with_groups=di(function(n,e,t,i){var r=v.extend({},e||{});return v.each(t,function(o,s){o!=null&&(r[s]=o)}),this.track(n,r,i)}),E.prototype._create_map_key=function(n,e){return n+"_"+JSON.stringify(e)},E.prototype._remove_group_from_cache=function(n,e){delete this._cached_groups[this._create_map_key(n,e)]},E.prototype.get_group=function(n,e){var t=this._create_map_key(n,e),i=this._cached_groups[t];return(i===void 0||i._group_key!==n||i._group_id!==e)&&(i=new Ue,i._init(this,n,e),this._cached_groups[t]=i),i},E.prototype.track_pageview=di(function(n,e){typeof n!="object"&&(n={}),e=e||{};var t=e.event_name||"$mp_web_page_view",i=v.extend(v.info.mpPageViewProperties(),v.info.campaignParams(),v.info.clickParams()),r=v.extend({},i,n);return this.track(t,r)}),E.prototype.track_links=function(){return this._track_dom.call(this,Fr,arguments)},E.prototype.track_forms=function(){return this._track_dom.call(this,Ka,arguments)},E.prototype.time_event=function(n){if(v.isUndefined(n)){this.report_error("No event name provided to mixpanel.time_event");return}this._event_is_disabled(n)||this.persistence.set_event_timer(n,new Date().getTime())};var RP={persistent:!0},th=function(n){var e;return v.isObject(n)?e=n:v.isUndefined(n)?e={}:e={days:n},v.extend({},RP,e)};E.prototype.register=function(n,e){var t=th(e);t.persistent?this.persistence.register(n,t.days):v.extend(this.unpersisted_superprops,n)},E.prototype.register_once=function(n,e,t){var i=th(t);i.persistent?this.persistence.register_once(n,e,i.days):(typeof e>"u"&&(e="None"),v.each(n,function(r,o){(!this.unpersisted_superprops.hasOwnProperty(o)||this.unpersisted_superprops[o]===e)&&(this.unpersisted_superprops[o]=r)},this))},E.prototype.unregister=function(n,e){e=th(e),e.persistent?this.persistence.unregister(n):delete this.unpersisted_superprops[n]},E.prototype._register_single=function(n,e){var t={};t[n]=e,this.register(t)},E.prototype.identify=function(n,e,t,i,r,o,s,a){var c=this.get_distinct_id();if(n&&c!==n){if(typeof n=="string"&&n.indexOf(Qd)===0)return this.report_error("distinct_id cannot have $device: prefix"),-1;this.register({$user_id:n})}if(!this.get_property("$device_id")){var u=c;this.register_once({$had_persisted_distinct_id:!0,$device_id:u},"")}n!==c&&n!==this.get_property(Ya)&&(this.unregister(Ya),this.register({distinct_id:n})),this._flags.identify_called=!0,this.people._flush(e,t,i,r,o,s,a),n!==c&&this.track("$identify",{distinct_id:n,$anon_distinct_id:c},{skip_hooks:!0}),n!==c&&this.flags.fetchFlags()},E.prototype.reset=function(){this.stop_session_recording(),this.persistence.clear(),this._flags.identify_called=!1;var n=v.UUID();this.register_once({distinct_id:Qd+n,$device_id:n},""),this._check_and_start_session_recording()},E.prototype.get_distinct_id=function(){return this.get_property("distinct_id")},E.prototype.alias=function(n,e){if(n===this.get_property(cy))return this.report_error("Attempting to create alias for existing People user - aborting."),-2;var t=this;return v.isUndefined(e)&&(e=this.get_distinct_id()),n!==e?(this._register_single(Ya,n),this.track("$create_alias",{alias:n,distinct_id:e},{skip_hooks:!0},function(){t.identify(n)})):(this.report_error("alias matches current distinct_id - skipping api call."),this.identify(n),-1)},E.prototype.name_tag=function(n){this._register_single("mp_name_tag",n)},E.prototype.set_config=function(n){if(v.isObject(n)){v.extend(this.config,n);var e=n.batch_size;e&&v.each(this.request_batchers,function(t){t.resetBatchSize()}),this.get_config("persistence_name")||(this.config.persistence_name=this.config.cookie_name),this.get_config("disable_persistence")||(this.config.disable_persistence=this.config.disable_cookie),this.persistence&&this.persistence.update_config(this.config),on.DEBUG=on.DEBUG||this.get_config("debug"),("autocapture"in n||"record_heatmap_data"in n)&&this.autocapture&&this.autocapture.init()}},E.prototype.get_config=function(n){return this.config[n]},E.prototype._run_hook=function(n){var e=(this.config.hooks[n]||EP).apply(this,Wi.call(arguments,1));return typeof e>"u"&&(this.report_error(n+" hook did not return a value"),e=null),e},E.prototype.get_property=function(n){return this.persistence.load_prop([n])},E.prototype.get_api_host=function(n){return this.get_config("api_hosts")[n]||this.get_config("api_host")},E.prototype.toString=function(){var n=this.get_config("name");return n!==Yt&&(n=Yt+"."+n),n},E.prototype._event_is_disabled=function(n){return v.isBlockedUA(Vn)||this._flags.disable_all_events||v.include(this.__disabled_events,n)},E.prototype._gdpr_init=function(){var n=this.get_config("opt_out_tracking_persistence_type")==="localStorage";n&&v.localStorage.is_supported()&&(!this.has_opted_in_tracking()&&this.has_opted_in_tracking({persistence_type:"cookie"})&&this.opt_in_tracking({enable_persistence:!1}),!this.has_opted_out_tracking()&&this.has_opted_out_tracking({persistence_type:"cookie"})&&this.opt_out_tracking({clear_persistence:!1}),this.clear_opt_in_out_tracking({persistence_type:"cookie",enable_persistence:!1})),this.has_opted_out_tracking()?this._gdpr_update_persistence({clear_persistence:!0}):!this.has_opted_in_tracking()&&(this.get_config("opt_out_tracking_by_default")||v.cookie.get("mp_optout"))&&(v.cookie.remove("mp_optout"),this.opt_out_tracking({clear_persistence:this.get_config("opt_out_persistence_by_default")}))},E.prototype._gdpr_update_persistence=function(n){var e;if(n&&n.clear_persistence)e=!0;else if(n&&n.enable_persistence)e=!1;else return;!this.get_config("disable_persistence")&&this.persistence.disabled!==e&&this.persistence.set_disabled(e),e?(this.stop_batch_senders(),this.stop_session_recording()):this._batchers_were_started&&this.start_batch_senders()},E.prototype._gdpr_call_func=function(n,e){return e=v.extend({track:v.bind(this.track,this),persistence_type:this.get_config("opt_out_tracking_persistence_type"),cookie_prefix:this.get_config("opt_out_tracking_cookie_prefix"),cookie_expiration:this.get_config("cookie_expiration"),cross_site_cookie:this.get_config("cross_site_cookie"),cross_subdomain_cookie:this.get_config("cross_subdomain_cookie"),cookie_domain:this.get_config("cookie_domain"),secure_cookie:this.get_config("secure_cookie"),ignore_dnt:this.get_config("ignore_dnt")},e),v.localStorage.is_supported()||(e.persistence_type="cookie"),n(this.get_config("token"),{track:e.track,trackEventName:e.track_event_name,trackProperties:e.track_properties,persistenceType:e.persistence_type,persistencePrefix:e.cookie_prefix,cookieDomain:e.cookie_domain,cookieExpiration:e.cookie_expiration,crossSiteCookie:e.cross_site_cookie,crossSubdomainCookie:e.cross_subdomain_cookie,secureCookie:e.secure_cookie,ignoreDnt:e.ignore_dnt})},E.prototype.opt_in_tracking=function(n){n=v.extend({enable_persistence:!0},n),this._gdpr_call_func(KR,n),this._gdpr_update_persistence(n)},E.prototype.opt_out_tracking=function(n){n=v.extend({clear_persistence:!0,delete_user:!0},n),n.delete_user&&this.people&&this.people._identify_called()&&(this.people.delete_user(),this.people.clear_charges()),this._gdpr_call_func(YR,n),this._gdpr_update_persistence(n)},E.prototype.has_opted_in_tracking=function(n){return this._gdpr_call_func(XR,n)},E.prototype.has_opted_out_tracking=function(n){return this._gdpr_call_func(x0,n)},E.prototype.clear_opt_in_out_tracking=function(n){n=v.extend({enable_persistence:!0},n),this._gdpr_call_func(JR,n),this._gdpr_update_persistence(n)},E.prototype.report_error=function(n,e){_e.error.apply(_e.error,arguments);try{!e&&!(n instanceof Error)&&(n=new Error(n)),this.get_config("error_reporter")(n,e)}catch(t){_e.error(t)}},E.prototype.init=E.prototype.init,E.prototype.reset=E.prototype.reset,E.prototype.disable=E.prototype.disable,E.prototype.time_event=E.prototype.time_event,E.prototype.track=E.prototype.track,E.prototype.track_links=E.prototype.track_links,E.prototype.track_forms=E.prototype.track_forms,E.prototype.track_pageview=E.prototype.track_pageview,E.prototype.register=E.prototype.register,E.prototype.register_once=E.prototype.register_once,E.prototype.unregister=E.prototype.unregister,E.prototype.identify=E.prototype.identify,E.prototype.alias=E.prototype.alias,E.prototype.name_tag=E.prototype.name_tag,E.prototype.set_config=E.prototype.set_config,E.prototype.get_config=E.prototype.get_config,E.prototype.get_api_host=E.prototype.get_api_host,E.prototype.get_property=E.prototype.get_property,E.prototype.get_distinct_id=E.prototype.get_distinct_id,E.prototype.toString=E.prototype.toString,E.prototype.opt_out_tracking=E.prototype.opt_out_tracking,E.prototype.opt_in_tracking=E.prototype.opt_in_tracking,E.prototype.has_opted_out_tracking=E.prototype.has_opted_out_tracking,E.prototype.has_opted_in_tracking=E.prototype.has_opted_in_tracking,E.prototype.clear_opt_in_out_tracking=E.prototype.clear_opt_in_out_tracking,E.prototype.get_group=E.prototype.get_group,E.prototype.set_group=E.prototype.set_group,E.prototype.add_group=E.prototype.add_group,E.prototype.remove_group=E.prototype.remove_group,E.prototype.track_with_groups=E.prototype.track_with_groups,E.prototype.start_batch_senders=E.prototype.start_batch_senders,E.prototype.stop_batch_senders=E.prototype.stop_batch_senders,E.prototype.start_session_recording=E.prototype.start_session_recording,E.prototype.stop_session_recording=E.prototype.stop_session_recording,E.prototype.pause_session_recording=E.prototype.pause_session_recording,E.prototype.resume_session_recording=E.prototype.resume_session_recording,E.prototype.get_session_recording_properties=E.prototype.get_session_recording_properties,E.prototype.get_session_replay_url=E.prototype.get_session_replay_url,E.prototype.get_tab_id=E.prototype.get_tab_id,E.prototype.DEFAULT_API_ROUTES=py,E.prototype.__get_recorder=E.prototype.__get_recorder,re.prototype.properties=re.prototype.properties,re.prototype.update_search_keyword=re.prototype.update_search_keyword,re.prototype.update_referrer_info=re.prototype.update_referrer_info,re.prototype.get_cross_subdomain=re.prototype.get_cross_subdomain,re.prototype.clear=re.prototype.clear;var Vr={},PP=function(){v.each(Vr,function(n,e){e!==Yt&&(Tt[e]=n)}),Tt._=v},OP=function(){Tt.init=function(n,e,t){if(t)return Tt[t]||(Tt[t]=Vr[t]=eh(n,e,t),Tt[t]._loaded()),Tt[t];var i=Tt;Vr[Yt]?i=Vr[Yt]:n&&(i=eh(n,e,Yt),i._loaded(),Vr[Yt]=i),Tt=i,Zd===xP&&(W[Yt]=Tt),PP()}},AP=function(){function n(){n.done||(n.done=!0,my=!0,hy=!1,v.each(Vr,function(i){i._dom_loaded()}))}function e(){try{be.documentElement.doScroll("left")}catch{setTimeout(e,1);return}n()}if(be.addEventListener)be.readyState==="complete"?n():be.addEventListener("DOMContentLoaded",n,!1);else if(be.attachEvent){be.attachEvent("onreadystatechange",n);var t=!1;try{t=W.frameElement===null}catch{}be.documentElement.doScroll&&t&&e()}v.register_event(W,"load",n,!0)};function MP(n){return uy=n,Zd=ly,Tt=new E,OP(),Tt.init(),AP(),Tt}function NP(n,e){e()}var zr=MP(NP);function DP(n,e={}){const t=e.instanceName||`obi_${Math.random().toString(36).slice(2)}`;try{zr.init(n,{debug:e.debug===!0,track_pageview:!1,persistence:"localStorage",...e.config||{}},t)}catch{}const i=zr?zr.get_instance?zr.get_instance(t):zr[t]:null,r={identify:(o,s)=>{var a;if(i&&i.__loaded)try{i.identify(o),s&&((a=i==null?void 0:i.people)!=null&&a.set)&&i.people.set(s)}catch{}},track:(o,s)=>{if(i&&i.__loaded)try{i.track(o,s||{})}catch{}},page:(o,s)=>{if(i&&i.__loaded)try{i.track("page-viewed",{name:o,...s||{}})}catch{}},reset:()=>{if(i&&i.__loaded)try{i.reset()}catch{}}};return typeof document<"u"&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&zr.track("tab-focus-changed",{page_url:window.location.href},{transport:"sendBeacon"})}),r}function LP(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var gy={exports:{}};(function(n){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function r(c,u,l){this.fn=c,this.context=u,this.once=l||!1}function o(c,u,l,d,h){if(typeof l!="function")throw new TypeError("The listener must be a function");var p=new r(l,d||c,h),m=t?t+u:u;return c._events[m]?c._events[m].fn?c._events[m]=[c._events[m],p]:c._events[m].push(p):(c._events[m]=p,c._eventsCount++),c}function s(c,u){--c._eventsCount===0?c._events=new i:delete c._events[u]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var u=[],l,d;if(this._eventsCount===0)return u;for(d in l=this._events)e.call(l,d)&&u.push(t?d.slice(1):d);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(l)):u},a.prototype.listeners=function(u){var l=t?t+u:u,d=this._events[l];if(!d)return[];if(d.fn)return[d.fn];for(var h=0,p=d.length,m=new Array(p);h<p;h++)m[h]=d[h].fn;return m},a.prototype.listenerCount=function(u){var l=t?t+u:u,d=this._events[l];return d?d.fn?1:d.length:0},a.prototype.emit=function(u,l,d,h,p,m){var f=t?t+u:u;if(!this._events[f])return!1;var g=this._events[f],y=arguments.length,b,S;if(g.fn){switch(g.once&&this.removeListener(u,g.fn,void 0,!0),y){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,l),!0;case 3:return g.fn.call(g.context,l,d),!0;case 4:return g.fn.call(g.context,l,d,h),!0;case 5:return g.fn.call(g.context,l,d,h,p),!0;case 6:return g.fn.call(g.context,l,d,h,p,m),!0}for(S=1,b=new Array(y-1);S<y;S++)b[S-1]=arguments[S];g.fn.apply(g.context,b)}else{var w=g.length,k;for(S=0;S<w;S++)switch(g[S].once&&this.removeListener(u,g[S].fn,void 0,!0),y){case 1:g[S].fn.call(g[S].context);break;case 2:g[S].fn.call(g[S].context,l);break;case 3:g[S].fn.call(g[S].context,l,d);break;case 4:g[S].fn.call(g[S].context,l,d,h);break;default:if(!b)for(k=1,b=new Array(y-1);k<y;k++)b[k-1]=arguments[k];g[S].fn.apply(g[S].context,b)}}return!0},a.prototype.on=function(u,l,d){return o(this,u,l,d,!1)},a.prototype.once=function(u,l,d){return o(this,u,l,d,!0)},a.prototype.removeListener=function(u,l,d,h){var p=t?t+u:u;if(!this._events[p])return this;if(!l)return s(this,p),this;var m=this._events[p];if(m.fn)m.fn===l&&(!h||m.once)&&(!d||m.context===d)&&s(this,p);else{for(var f=0,g=[],y=m.length;f<y;f++)(m[f].fn!==l||h&&!m[f].once||d&&m[f].context!==d)&&g.push(m[f]);g.length?this._events[p]=g.length===1?g[0]:g:s(this,p)}return this},a.prototype.removeAllListeners=function(u){var l;return u?(l=t?t+u:u,this._events[l]&&s(this,l)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,n.exports=a})(gy);var UP=gy.exports;const nh=LP(UP);var ih=function(n,e){return ih=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])},ih(n,e)};function an(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");ih(n,e);function t(){this.constructor=n}n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var rh=function(){return rh=Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++){t=arguments[i];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},rh.apply(this,arguments)};function Mt(n,e,t,i){function r(o){return o instanceof t?o:new t(function(s){s(o)})}return new(t||(t=Promise))(function(o,s){function a(l){try{u(i.next(l))}catch(d){s(d)}}function c(l){try{u(i.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):r(l.value).then(a,c)}u((i=i.apply(n,e||[])).next())})}function xt(n,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},i,r,o,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(u){return function(l){return c([u,l])}}function c(u){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,u[0]&&(t=0)),t;)try{if(i=1,r&&(o=u[0]&2?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[u[0]&2,o.value]),u[0]){case 0:case 1:o=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,r=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){t.label=u[1];break}if(u[0]===6&&t.label<o[1]){t.label=o[1],o=u;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(u);break}o[2]&&t.ops.pop(),t.trys.pop();continue}u=e.call(n,t)}catch(l){u=[6,l],r=0}finally{i=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function Ja(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,o;i<r;i++)(o||!(i in e))&&(o||(o=Array.prototype.slice.call(e,0,i)),o[i]=e[i]);return n.concat(o||Array.prototype.slice.call(e))}typeof SuppressedError=="function"&&SuppressedError;for(var Gn=function(){function n(e,t,i,r){this.left=e,this.top=t,this.width=i,this.height=r}return n.prototype.add=function(e,t,i,r){return new n(this.left+e,this.top+t,this.width+i,this.height+r)},n.fromClientRect=function(e,t){return new n(t.left+e.windowBounds.left,t.top+e.windowBounds.top,t.width,t.height)},n.fromDOMRectList=function(e,t){var i=Array.from(t).find(function(r){return r.width!==0});return i?new n(i.left+e.windowBounds.left,i.top+e.windowBounds.top,i.width,i.height):n.EMPTY},n.EMPTY=new n(0,0,0,0),n}(),Za=function(n,e){return Gn.fromClientRect(n,e.getBoundingClientRect())},FP=function(n){var e=n.body,t=n.documentElement;if(!e||!t)throw new Error("Unable to get document size");var i=Math.max(Math.max(e.scrollWidth,t.scrollWidth),Math.max(e.offsetWidth,t.offsetWidth),Math.max(e.clientWidth,t.clientWidth)),r=Math.max(Math.max(e.scrollHeight,t.scrollHeight),Math.max(e.offsetHeight,t.offsetHeight),Math.max(e.clientHeight,t.clientHeight));return new Gn(0,0,i,r)},Qa=function(n){for(var e=[],t=0,i=n.length;t<i;){var r=n.charCodeAt(t++);if(r>=55296&&r<=56319&&t<i){var o=n.charCodeAt(t++);(o&64512)===56320?e.push(((r&1023)<<10)+(o&1023)+65536):(e.push(r),t--)}else e.push(r)}return e},nt=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];if(String.fromCodePoint)return String.fromCodePoint.apply(String,n);var t=n.length;if(!t)return"";for(var i=[],r=-1,o="";++r<t;){var s=n[r];s<=65535?i.push(s):(s-=65536,i.push((s>>10)+55296,s%1024+56320)),(r+1===t||i.length>16384)&&(o+=String.fromCharCode.apply(String,i),i.length=0)}return o},vy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",BP=typeof Uint8Array>"u"?[]:new Uint8Array(256),ec=0;ec<vy.length;ec++)BP[vy.charCodeAt(ec)]=ec;typeof SuppressedError=="function"&&SuppressedError;for(var yy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",jP=typeof Uint8Array>"u"?[]:new Uint8Array(256),tc=0;tc<yy.length;tc++)jP[yy.charCodeAt(tc)]=tc;for(var by="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",VP=typeof Uint8Array>"u"?[]:new Uint8Array(256),nc=0;nc<by.length;nc++)VP[by.charCodeAt(nc)]=nc;var zP=1,_y=2,ky=3,qP=5,Sy=8,wy=10,WP=25,GP=30,$P=37,HP=42,Cy="!",fi="\xD7",KP="\xF7",Ty=[zP,_y,ky,qP],YP=[wy,Sy],XP=function(n,e){var t=[],i=[],r=[];return n.forEach(function(o,s){throw new Error("UnicodeTrie not initialized")}),[i,t,r]},JP=function(n,e){for(var t=n;t>=0;){var i=e[t];if(i===wy)t--;else return i}return 0},ZP=function(n,e,t,i,r){if(t[i]===0)return fi;var o=i-1;if(Array.isArray(r)&&r[o]===!0)return fi;var s=o-1,a=o+1,c=e[o];s>=0&&e[s];var u=e[a];if(c===_y&&u===ky)return fi;if(Ty.indexOf(c)!==-1)return Cy;if(Ty.indexOf(u)!==-1||YP.indexOf(u)!==-1)return fi;if(JP(o,e)===Sy)return KP;throw new Error("UnicodeTrie not initialized")},QP=function(n,e){e||(e={lineBreak:"normal",wordBreak:"normal"});var t=XP(n,e.lineBreak),i=t[0],r=t[1],o=t[2];(e.wordBreak==="break-all"||e.wordBreak==="break-word")&&(r=r.map(function(a){return[WP,GP,HP].indexOf(a)!==-1?$P:a}));var s=e.wordBreak==="keep-all"?o.map(function(a,c){return a&&n[c]>=19968&&n[c]<=40959}):void 0;return[i,r,s]},e2=function(){function n(e,t,i,r){this.codePoints=e,this.required=t===Cy,this.start=i,this.end=r}return n.prototype.slice=function(){return nt.apply(void 0,this.codePoints.slice(this.start,this.end))},n}(),t2=function(n,e){var t=Qa(n),i=QP(t,e),r=i[0],o=i[1],s=i[2],a=t.length,c=0,u=0;return{next:function(){if(u>=a)return{done:!0,value:null};for(var l=fi;u<a&&(l=ZP(t,o,r,++u,s))===fi;);if(l!==fi||u===a){var d=new e2(t,l,c,u);return c=u,{value:d,done:!1}}return{done:!0,value:null}}}},n2=1,i2=2,Jo=4,xy=8,ic=10,Ey=47,Zo=92,r2=9,o2=32,rc=34,Qo=61,s2=35,a2=36,c2=37,oc=39,sc=40,es=41,u2=95,Ft=45,l2=33,d2=60,h2=62,p2=64,f2=91,m2=93,g2=61,v2=123,ac=63,y2=125,Iy=124,b2=126,_2=128,Ry=65533,oh=42,Yi=43,k2=44,S2=58,w2=59,ts=46,C2=0,T2=8,x2=11,E2=14,I2=31,R2=127,xn=-1,Py=48,Oy=97,Ay=101,P2=102,O2=117,A2=122,My=65,Ny=69,Dy=70,M2=85,N2=90,Et=function(n){return n>=Py&&n<=57},D2=function(n){return n>=55296&&n<=57343},qr=function(n){return Et(n)||n>=My&&n<=Dy||n>=Oy&&n<=P2},L2=function(n){return n>=Oy&&n<=A2},U2=function(n){return n>=My&&n<=N2},F2=function(n){return L2(n)||U2(n)},B2=function(n){return n>=_2},cc=function(n){return n===ic||n===r2||n===o2},uc=function(n){return F2(n)||B2(n)||n===u2},Ly=function(n){return uc(n)||Et(n)||n===Ft},j2=function(n){return n>=C2&&n<=T2||n===x2||n>=E2&&n<=I2||n===R2},mi=function(n,e){return n!==Zo?!1:e!==ic},lc=function(n,e,t){return n===Ft?uc(e)||mi(e,t):uc(n)?!0:!!(n===Zo&&mi(n,e))},sh=function(n,e,t){return n===Yi||n===Ft?Et(e)?!0:e===ts&&Et(t):Et(n===ts?e:n)},V2=function(n){var e=0,t=1;(n[e]===Yi||n[e]===Ft)&&(n[e]===Ft&&(t=-1),e++);for(var i=[];Et(n[e]);)i.push(n[e++]);var r=i.length?parseInt(nt.apply(void 0,i),10):0;n[e]===ts&&e++;for(var o=[];Et(n[e]);)o.push(n[e++]);var s=o.length,a=s?parseInt(nt.apply(void 0,o),10):0;(n[e]===Ny||n[e]===Ay)&&e++;var c=1;(n[e]===Yi||n[e]===Ft)&&(n[e]===Ft&&(c=-1),e++);for(var u=[];Et(n[e]);)u.push(n[e++]);var l=u.length?parseInt(nt.apply(void 0,u),10):0;return t*(r+a*Math.pow(10,-s))*Math.pow(10,c*l)},z2={type:2},q2={type:3},W2={type:4},G2={type:13},$2={type:8},H2={type:21},K2={type:9},Y2={type:10},X2={type:11},J2={type:12},Z2={type:14},dc={type:23},Q2={type:1},eO={type:25},tO={type:24},nO={type:26},iO={type:27},rO={type:28},oO={type:29},sO={type:31},ah={type:32},Uy=function(){function n(){this._value=[]}return n.prototype.write=function(e){this._value=this._value.concat(Qa(e))},n.prototype.read=function(){for(var e=[],t=this.consumeToken();t!==ah;)e.push(t),t=this.consumeToken();return e},n.prototype.consumeToken=function(){var e=this.consumeCodePoint();switch(e){case rc:return this.consumeStringToken(rc);case s2:var t=this.peekCodePoint(0),i=this.peekCodePoint(1),r=this.peekCodePoint(2);if(Ly(t)||mi(i,r)){var o=lc(t,i,r)?i2:n2,s=this.consumeName();return{type:5,value:s,flags:o}}break;case a2:if(this.peekCodePoint(0)===Qo)return this.consumeCodePoint(),G2;break;case oc:return this.consumeStringToken(oc);case sc:return z2;case es:return q2;case oh:if(this.peekCodePoint(0)===Qo)return this.consumeCodePoint(),Z2;break;case Yi:if(sh(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case k2:return W2;case Ft:var a=e,c=this.peekCodePoint(0),u=this.peekCodePoint(1);if(sh(a,c,u))return this.reconsumeCodePoint(e),this.consumeNumericToken();if(lc(a,c,u))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();if(c===Ft&&u===h2)return this.consumeCodePoint(),this.consumeCodePoint(),tO;break;case ts:if(sh(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case Ey:if(this.peekCodePoint(0)===oh)for(this.consumeCodePoint();;){var l=this.consumeCodePoint();if(l===oh&&(l=this.consumeCodePoint(),l===Ey))return this.consumeToken();if(l===xn)return this.consumeToken()}break;case S2:return nO;case w2:return iO;case d2:if(this.peekCodePoint(0)===l2&&this.peekCodePoint(1)===Ft&&this.peekCodePoint(2)===Ft)return this.consumeCodePoint(),this.consumeCodePoint(),eO;break;case p2:var d=this.peekCodePoint(0),h=this.peekCodePoint(1),p=this.peekCodePoint(2);if(lc(d,h,p)){var s=this.consumeName();return{type:7,value:s}}break;case f2:return rO;case Zo:if(mi(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();break;case m2:return oO;case g2:if(this.peekCodePoint(0)===Qo)return this.consumeCodePoint(),$2;break;case v2:return X2;case y2:return J2;case O2:case M2:var m=this.peekCodePoint(0),f=this.peekCodePoint(1);return m===Yi&&(qr(f)||f===ac)&&(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(e),this.consumeIdentLikeToken();case Iy:if(this.peekCodePoint(0)===Qo)return this.consumeCodePoint(),K2;if(this.peekCodePoint(0)===Iy)return this.consumeCodePoint(),H2;break;case b2:if(this.peekCodePoint(0)===Qo)return this.consumeCodePoint(),Y2;break;case xn:return ah}return cc(e)?(this.consumeWhiteSpace(),sO):Et(e)?(this.reconsumeCodePoint(e),this.consumeNumericToken()):uc(e)?(this.reconsumeCodePoint(e),this.consumeIdentLikeToken()):{type:6,value:nt(e)}},n.prototype.consumeCodePoint=function(){var e=this._value.shift();return typeof e>"u"?-1:e},n.prototype.reconsumeCodePoint=function(e){this._value.unshift(e)},n.prototype.peekCodePoint=function(e){return e>=this._value.length?-1:this._value[e]},n.prototype.consumeUnicodeRangeToken=function(){for(var e=[],t=this.consumeCodePoint();qr(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();for(var i=!1;t===ac&&e.length<6;)e.push(t),t=this.consumeCodePoint(),i=!0;if(i){var r=parseInt(nt.apply(void 0,e.map(function(c){return c===ac?Py:c})),16),o=parseInt(nt.apply(void 0,e.map(function(c){return c===ac?Dy:c})),16);return{type:30,start:r,end:o}}var s=parseInt(nt.apply(void 0,e),16);if(this.peekCodePoint(0)===Ft&&qr(this.peekCodePoint(1))){this.consumeCodePoint(),t=this.consumeCodePoint();for(var a=[];qr(t)&&a.length<6;)a.push(t),t=this.consumeCodePoint();var o=parseInt(nt.apply(void 0,a),16);return{type:30,start:s,end:o}}else return{type:30,start:s,end:s}},n.prototype.consumeIdentLikeToken=function(){var e=this.consumeName();return e.toLowerCase()==="url"&&this.peekCodePoint(0)===sc?(this.consumeCodePoint(),this.consumeUrlToken()):this.peekCodePoint(0)===sc?(this.consumeCodePoint(),{type:19,value:e}):{type:20,value:e}},n.prototype.consumeUrlToken=function(){var e=[];if(this.consumeWhiteSpace(),this.peekCodePoint(0)===xn)return{type:22,value:""};var t=this.peekCodePoint(0);if(t===oc||t===rc){var i=this.consumeStringToken(this.consumeCodePoint());return i.type===0&&(this.consumeWhiteSpace(),this.peekCodePoint(0)===xn||this.peekCodePoint(0)===es)?(this.consumeCodePoint(),{type:22,value:i.value}):(this.consumeBadUrlRemnants(),dc)}for(;;){var r=this.consumeCodePoint();if(r===xn||r===es)return{type:22,value:nt.apply(void 0,e)};if(cc(r))return this.consumeWhiteSpace(),this.peekCodePoint(0)===xn||this.peekCodePoint(0)===es?(this.consumeCodePoint(),{type:22,value:nt.apply(void 0,e)}):(this.consumeBadUrlRemnants(),dc);if(r===rc||r===oc||r===sc||j2(r))return this.consumeBadUrlRemnants(),dc;if(r===Zo)if(mi(r,this.peekCodePoint(0)))e.push(this.consumeEscapedCodePoint());else return this.consumeBadUrlRemnants(),dc;else e.push(r)}},n.prototype.consumeWhiteSpace=function(){for(;cc(this.peekCodePoint(0));)this.consumeCodePoint()},n.prototype.consumeBadUrlRemnants=function(){for(;;){var e=this.consumeCodePoint();if(e===es||e===xn)return;mi(e,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}},n.prototype.consumeStringSlice=function(e){for(var t=5e4,i="";e>0;){var r=Math.min(t,e);i+=nt.apply(void 0,this._value.splice(0,r)),e-=r}return this._value.shift(),i},n.prototype.consumeStringToken=function(e){var t="",i=0;do{var r=this._value[i];if(r===xn||r===void 0||r===e)return t+=this.consumeStringSlice(i),{type:0,value:t};if(r===ic)return this._value.splice(0,i),Q2;if(r===Zo){var o=this._value[i+1];o!==xn&&o!==void 0&&(o===ic?(t+=this.consumeStringSlice(i),i=-1,this._value.shift()):mi(r,o)&&(t+=this.consumeStringSlice(i),t+=nt(this.consumeEscapedCodePoint()),i=-1))}i++}while(!0)},n.prototype.consumeNumber=function(){var e=[],t=Jo,i=this.peekCodePoint(0);for((i===Yi||i===Ft)&&e.push(this.consumeCodePoint());Et(this.peekCodePoint(0));)e.push(this.consumeCodePoint());i=this.peekCodePoint(0);var r=this.peekCodePoint(1);if(i===ts&&Et(r))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=xy;Et(this.peekCodePoint(0));)e.push(this.consumeCodePoint());i=this.peekCodePoint(0),r=this.peekCodePoint(1);var o=this.peekCodePoint(2);if((i===Ny||i===Ay)&&((r===Yi||r===Ft)&&Et(o)||Et(r)))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=xy;Et(this.peekCodePoint(0));)e.push(this.consumeCodePoint());return[V2(e),t]},n.prototype.consumeNumericToken=function(){var e=this.consumeNumber(),t=e[0],i=e[1],r=this.peekCodePoint(0),o=this.peekCodePoint(1),s=this.peekCodePoint(2);if(lc(r,o,s)){var a=this.consumeName();return{type:15,number:t,flags:i,unit:a}}return r===c2?(this.consumeCodePoint(),{type:16,number:t,flags:i}):{type:17,number:t,flags:i}},n.prototype.consumeEscapedCodePoint=function(){var e=this.consumeCodePoint();if(qr(e)){for(var t=nt(e);qr(this.peekCodePoint(0))&&t.length<6;)t+=nt(this.consumeCodePoint());cc(this.peekCodePoint(0))&&this.consumeCodePoint();var i=parseInt(t,16);return i===0||D2(i)||i>1114111?Ry:i}return e===xn?Ry:e},n.prototype.consumeName=function(){for(var e="";;){var t=this.consumeCodePoint();if(Ly(t))e+=nt(t);else if(mi(t,this.peekCodePoint(0)))e+=nt(this.consumeEscapedCodePoint());else return this.reconsumeCodePoint(t),e}},n}(),Fy=function(){function n(e){this._tokens=e}return n.create=function(e){var t=new Uy;return t.write(e),new n(t.read())},n.parseValue=function(e){return n.create(e).parseComponentValue()},n.parseValues=function(e){return n.create(e).parseComponentValues()},n.prototype.parseComponentValue=function(){for(var e=this.consumeToken();e.type===31;)e=this.consumeToken();if(e.type===32)throw new SyntaxError("Error parsing CSS component value, unexpected EOF");this.reconsumeToken(e);var t=this.consumeComponentValue();do e=this.consumeToken();while(e.type===31);if(e.type===32)return t;throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one")},n.prototype.parseComponentValues=function(){for(var e=[];;){var t=this.consumeComponentValue();if(t.type===32)return e;e.push(t),e.push()}},n.prototype.consumeComponentValue=function(){var e=this.consumeToken();switch(e.type){case 11:case 28:case 2:return this.consumeSimpleBlock(e.type);case 19:return this.consumeFunction(e)}return e},n.prototype.consumeSimpleBlock=function(e){for(var t={type:e,values:[]},i=this.consumeToken();;){if(i.type===32||cO(i,e))return t;this.reconsumeToken(i),t.values.push(this.consumeComponentValue()),i=this.consumeToken()}},n.prototype.consumeFunction=function(e){for(var t={name:e.value,values:[],type:18};;){var i=this.consumeToken();if(i.type===32||i.type===3)return t;this.reconsumeToken(i),t.values.push(this.consumeComponentValue())}},n.prototype.consumeToken=function(){var e=this._tokens.shift();return typeof e>"u"?ah:e},n.prototype.reconsumeToken=function(e){this._tokens.unshift(e)},n}(),gi=function(n){return n.type===15},st=function(n){return n.type===17},ue=function(n){return n.type===20},aO=function(n){return n.type===0},ch=function(n,e){return ue(n)&&n.value===e},By=function(n){return n.type!==31},vt=function(n){return n.type!==31&&n.type!==4},En=function(n){var e=[],t=[];return n.forEach(function(i){if(i.type===4){if(t.length===0)throw new Error("Error parsing function args, zero tokens for arg");e.push(t),t=[];return}i.type!==31&&t.push(i)}),t.length&&e.push(t),e},cO=function(n,e){return e===11&&n.type===12||e===28&&n.type===29?!0:e===2&&n.type===3},vi=function(n){return n.type===17||n.type===15},Fe=function(n){return n.type===16||vi(n)},jy=function(n){return n.length>1?[n[0],n[1]]:[n[0]]},yt={type:17,number:0,flags:Jo},uh={type:16,number:50,flags:Jo},yi={type:16,number:100,flags:Jo},ns=function(n,e,t){var i=n[0],r=n[1];return[Ee(i,e),Ee(typeof r<"u"?r:i,t)]},Ee=function(n,e){if(n.type===16)return n.number/100*e;if(gi(n))switch(n.unit){case"rem":case"em":return 16*n.number;case"px":default:return n.number}return n.number},Vy="deg",zy="grad",qy="rad",Wy="turn",hc={name:"angle",parse:function(n,e){if(e.type===15)switch(e.unit){case Vy:return Math.PI*e.number/180;case zy:return Math.PI/200*e.number;case qy:return e.number;case Wy:return Math.PI*2*e.number}throw new Error("Unsupported angle type")}},Gy=function(n){return n.type===15&&(n.unit===Vy||n.unit===zy||n.unit===qy||n.unit===Wy)},$y=function(n){var e=n.filter(ue).map(function(t){return t.value}).join(" ");switch(e){case"to bottom right":case"to right bottom":case"left top":case"top left":return[yt,yt];case"to top":case"bottom":return Xt(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[yt,yi];case"to right":case"left":return Xt(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[yi,yi];case"to bottom":case"top":return Xt(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[yi,yt];case"to left":case"right":return Xt(270)}return 0},Xt=function(n){return Math.PI*n/180},bi=function(n){return(255&n)===0},pt=function(n){var e=255&n,t=255&n>>8,i=255&n>>16,r=255&n>>24;return e<255?"rgba(".concat(r,",").concat(i,",").concat(t,",").concat(e/255,")"):"rgb(".concat(r,",").concat(i,",").concat(t,")")},In=function(n,e,t,i){return(n<<24|e<<16|t<<8|Math.round(i*255)<<0)>>>0},pc=function(n,e){if(n.type===17)return n.number;if(n.type===16){var t=e===3?1:255;return e===3?n.number/100*t:Math.round(n.number/100*t)}return 0},Xi=function(n){return(n[0].type===20?n[0].value:"unknown")==="from"},Ke=function(n,e,t){return Math.min(Math.max(n,e),t)},Bt=function(n,e){return[n[0]*e[0]+n[1]*e[1]+n[2]*e[2],n[3]*e[0]+n[4]*e[1]+n[5]*e[2],n[6]*e[0]+n[7]*e[1]+n[8]*e[2]]},uO=function(n){return In(Ke(Math.round(n[0]*255),0,255),Ke(Math.round(n[1]*255),0,255),Ke(Math.round(n[2]*255),0,255),Ke(n[3],0,1))},lh=function(n){var e=n[0],t=n[1],i=n[2],r=n[3],o=Ji([e,t,i]);return In(Ke(Math.round(o[0]*255),0,255),Ke(Math.round(o[1]*255),0,255),Ke(Math.round(o[2]*255),0,255),r)},is=function(n){var e=_i([n[0],n[1],n[2]]);return lh([e[0],e[1],e[2],n[3]])},lO=function(n,e){if(Xi(e.filter(vt)))throw new Error("Relative color not supported for lab()");var t=fc(e),i=t[0],r=t[1],o=t[2],s=t[3],a=Ji(_i(vc([i,r,o])));return In(Ke(Math.round(a[0]*255),0,255),Ke(Math.round(a[1]*255),0,255),Ke(Math.round(a[2]*255),0,255),s)},dO=function(n,e){if(Xi(e.filter(vt)))throw new Error("Relative color not supported for oklab()");var t=fc(e),i=t[0],r=t[1],o=t[2],s=t[3],a=Ji(_i(gc([i,r,o])));return In(Ke(Math.round(a[0]*255),0,255),Ke(Math.round(a[1]*255),0,255),Ke(Math.round(a[2]*255),0,255),s)},hO=function(n,e){if(Xi(e.filter(vt)))throw new Error("Relative color not supported for oklch()");var t=Xy(e),i=t[0],r=t[1],o=t[2],s=t[3],a=Ji(_i(gc(mc([i,r,o]))));return In(Ke(Math.round(a[0]*255),0,255),Ke(Math.round(a[1]*255),0,255),Ke(Math.round(a[2]*255),0,255),s)},pO=function(n,e){if(Xi(e.filter(vt)))throw new Error("Relative color not supported for lch()");var t=Yy(e),i=t[0],r=t[1],o=t[2],s=t[3],a=Ji(_i(vc(mc([i,r,o]))));return In(Ke(Math.round(a[0]*255),0,255),Ke(Math.round(a[1]*255),0,255),Ke(Math.round(a[2]*255),0,255),s)},Hy=function(n,e){var t=e.filter(vt),i=t[0],r=t[1],o=t[2],s=t[3],a=(i.type===17?Xt(i.number):hc.parse(n,i))/(Math.PI*2),c=Fe(r)?r.number/100:0,u=Fe(o)?o.number/100:0,l=typeof s<"u"&&Fe(s)?Ee(s,1):1;return[a,c,u,l]},Ky=function(n,e){if(Xi(e))throw new Error("Relative color not supported for hsl()");var t=Hy(n,e),i=t[0],r=t[1],o=t[2],s=t[3],a=Zy([i,r,o]);return In(a[0]*255,a[1]*255,a[2]*255,r===0?1:s)},Yy=function(n){var e=n.filter(vt),t=Fe(e[0])?e[0].number:0,i=Fe(e[1])?e[1].number:0,r=st(e[2])||gi(e[2])?e[2].number:0,o=typeof e[4]<"u"&&Fe(e[4])?Ee(e[4],1):1;return[t,i,r,o]},fc=function(n){var e=n.filter(vt),t=e[0].type===16?e[0].number/100:st(e[0])?e[0].number:0,i=e[1].type===16?e[1].number/100:st(e[1])?e[1].number:0,r=st(e[2])||gi(e[2])?e[2].number:0,o=typeof e[4]<"u"&&Fe(e[4])?Ee(e[4],1):1;return[t,i,r,o]},Xy=function(n){var e=n.filter(vt),t=e[0].type===16?e[0].number/100:st(e[0])?e[0].number:0,i=e[1].type===16?e[1].number/100:st(e[1])?e[1].number:0,r=st(e[2])||gi(e[2])?e[2].number:0,o=typeof e[4]<"u"&&Fe(e[4])?Ee(e[4],1):1;return[t,i,r,o]},Jy=function(n){return Bt([1.0479297925449969,.022946870601609652,-.05019226628920524,.02962780877005599,.9904344267538799,-.017073799063418826,-.009243040646204504,.015055191490298152,.7518742814281371],n)},dh=function(n){return Bt([.955473421488075,-.02309845494876471,.06325924320057072,-.0283697093338637,1.0099953980813041,.021041441191917323,.012314014864481998,-.020507649298898964,1.330365926242124],n)},hh=function(n,e,t){return t<0&&(t+=1),t>=1&&(t-=1),t<1/6?(e-n)*t*6+n:t<1/2?e:t<2/3?(e-n)*6*(2/3-t)+n:n},Zy=function(n){var e=n[0],t=n[1],i=n[2];if(t===0)return[i*255,i*255,i*255];var r=i<=.5?i*(t+1):i+t-i*t,o=i*2-r,s=hh(o,r,e+1/3),a=hh(o,r,e),c=hh(o,r,e-1/3);return[s,a,c]},mc=function(n){var e=n[0],t=n[1],i=n[2];return t<0&&(t=0),isNaN(i)&&(i=0),[e,t*Math.cos(i*Math.PI/180),t*Math.sin(i*Math.PI/180)]},gc=function(n){var e=Bt([1,.3963377773761749,.2158037573099136,1,-.1055613458156586,-.0638541728258133,1,-.0894841775298119,-1.2914855480194092],n),t=e.map(function(i){return Math.pow(i,3)});return Bt([1.2268798758459243,-.5578149944602171,.2813910456659647,-.0405757452148008,1.112286803280317,-.0717110580655164,-.0763729366746601,-.4214933324022432,1.5869240198367816],t)},vc=function(n){var e=(n[0]+16)/116,t=n[1]/500+e,i=e-n[2]/200,r=24389/27,o=24/116,s=[(t>o?Math.pow(t,3):(116*t-16)/r)*.3457/.3585,n[0]>8?Math.pow(e,3):n[0]/r,(i>o?Math.pow(i,3):(116*i-16)/r)*(1-.3457-.3585)/.3585];return dh([s[0],s[1],s[2]])},fO=function(n,e){var t=e.filter(vt);if(t.length===3){var i=t.map(pc),r=i[0],o=i[1],s=i[2],a=fh([r/255,o/255,s/255]),c=ph([a[0],a[1],a[2]]),u=c[0],l=c[1],d=c[2];return[u,l,d,1]}if(t.length===4){var h=t.map(pc),r=h[0],o=h[1],s=h[2],p=h[3],a=fh([r/255,o/255,s/255]),m=ph([a[0],a[1],a[2]]),u=m[0],l=m[1],d=m[2];return[u,l,d,p]}return[0,0,0,1]},mO=function(n,e){var t=Hy(n,e),i=t[0],r=t[1],o=t[2],s=t[3],a=fh(Zy([i,r,o])),c=ph([a[0],a[1],a[2]]),u=c[0],l=c[1],d=c[2];return[u,l,d,s]},gO=function(n,e){var t=fc(e),i=t[0],r=t[1],o=t[2],s=t[3],a=vc([i,r,o]),c=a[0],u=a[1],l=a[2];return[c,u,l,s]},vO=function(n,e){var t=Yy(e),i=t[0],r=t[1],o=t[2],s=t[3],a=vc(mc([i,r,o])),c=a[0],u=a[1],l=a[2];return[c,u,l,s]},yO=function(n,e){var t=Xy(e),i=t[0],r=t[1],o=t[2],s=t[3],a=gc(mc([i,r,o])),c=a[0],u=a[1],l=a[2];return[c,u,l,s]},bO=function(n,e){var t=fc(e),i=t[0],r=t[1],o=t[2],s=t[3],a=gc([i,r,o]),c=a[0],u=a[1],l=a[2];return[c,u,l,s]},_O=function(n){return dh([n[0],n[1],n[2]])},Qy=function(n){return n},kO=function(n){var e=Jy([n[0],n[2],n[3]]),t=e[0],i=e[1],r=e[2];return[t,i,r,n[3]]},eb=function(n){return is([n[0],n[1],n[2],n[3]])},SO=function(n){var e=_O([n[0],n[1],n[2]]);return is([e[0],e[1],e[2],n[3]])},_i=function(n){return Bt([3.2409699419045226,-1.537383177570094,-.4986107602930034,-.9692436362808796,1.8759675015077202,.04155505740717559,.05563007969699366,-.20397695888897652,1.0569715142428786],n)},ph=function(n){return Bt([.41239079926595934,.357584339383878,.1804807884018343,.21263900587151027,.715168678767756,.07219231536073371,.01933081871559182,.11919477979462598,.9505321522496607],n)},Ji=function(n){return n.map(function(e){var t=e<0?-1:1,i=Math.abs(e);return i>.0031308?t*(1.055*Math.pow(i,1/2.4)-.055):12.92*e})},fh=function(n){return n.map(function(e){var t=e<0?-1:1,i=Math.abs(e);return i<=.04045?e/12.92:t*Math.pow((i+.055)/1.055,2.4)})},wO=function(n){var e=Ji(_i([n[0],n[1],n[2]])),t=e[0],i=e[1],r=e[2];return[t,i,r,n[3]]},CO=function(n){var e=_i([n[0],n[1],n[2]]),t=e[0],i=e[1],r=e[2];return[Ke(Math.round(t*255),0,255),Ke(Math.round(i*255),0,255),Ke(Math.round(r*255),0,255),n[3]]},TO=function(n){return Bt([.4865709486482162,.26566769316909306,.1982172852343625,.2289745640697488,.6917385218365064,.079286914093745,0,.04511338185890264,1.043944368900976],n)},xO=function(n){return Bt([2.493496911941425,-.9313836179191239,-.40271078445071684,-.8294889695615747,1.7626640603183463,.023624685841943577,.03584583024378447,-.07617238926804182,.9568845240076872],n)},EO=function(n){return n.map(function(e){var t=e<0?-1:1,i=e*t;return i<=.04045?e/12.92:t*Math.pow((e+.055)/1.055,2.4)||0})},IO=function(n){return Ji(n)},RO=function(n){var e=EO([n[0],n[1],n[2]]);return TO([e[0],e[1],e[2]])},PO=function(n){var e=IO(xO([n[0],n[1],n[2]])),t=e[0],i=e[1],r=e[2];return[t,i,r,n[3]]},OO=function(n){var e=RO([n[0],n[1],n[2]]);return is([e[0],e[1],e[2],n[3]])},AO=function(n){return Bt([2.0415879038107465,-.5650069742788596,-.34473135077832956,-.9692436362808795,1.8759675015077202,.04155505740717557,.013444280632031142,-.11836239223101838,1.0151749943912054],n)},MO=function(n){return Bt([.5766690429101305,.1855582379065463,.1882286462349947,.29734497525053605,.6273635662554661,.0752914584939978,.02703136138641234,.07068885253582723,.9913375368376388],n)},NO=function(n){var e=n.map(function(t){var i=t<0?-1:1,r=Math.abs(t);return i*Math.pow(r,2.19921875)});return[e[0],e[1],e[2]]},DO=function(n){var e=n.map(function(t){var i=t<0?-1:1,r=Math.abs(t);return i*Math.pow(r,.4547069271758437)});return[e[0],e[1],e[2]]},LO=function(n){var e=DO(AO([n[0],n[1],n[2]])),t=e[0],i=e[1],r=e[2];return[t,i,r,n[3]]},UO=function(n){var e=_i(MO(NO([n[0],n[1],n[2]])));return lh([e[0],e[1],e[2],n[3]])},FO=function(n){return Bt([.7977666449006423,.13518129740053308,.0313477341283922,.2880748288194013,.711835234241873,8993693872564e-17,0,0,.8251046025104602],n)},BO=function(n){return Bt([1.3457868816471583,-.25557208737979464,-.05110186497554526,-.5446307051249019,1.5082477428451468,.02052744743642139,0,0,1.2119675456389452],n)},jO=function(n){return n.map(function(e){return e<16/512?e/16:Math.pow(e,1.8)})},VO=function(n){return n.map(function(e){return e>1/512?Math.pow(e,1/1.8):e*16})},zO=function(n){var e=jO([n[0],n[1],n[2]]);return dh(FO([e[0],e[1],e[2]]))},qO=function(n){var e=VO(BO(Jy([n[0],n[1],n[2]]))),t=e[0],i=e[1],r=e[2];return[t,i,r,n[3]]},WO=function(n){var e=zO([n[0],n[1],n[2]]);return is([e[0],e[1],e[2],n[3]])},yc=1.09929682680944,tb=.018053968510807,GO=function(n){return n.map(function(e){return e<tb*4.5?e/4.5:Math.pow((e+yc-1)/yc,1/.45)})},$O=function(n){return n.map(function(e){return e>=tb?yc*Math.pow(e,.45)-(yc-1):4.5*e})},HO=function(n){return Bt([.6369580483012914,.14461690358620832,.1688809751641721,.2627002120112671,.6779980715188708,.05930171646986196,0,.028072693049087428,1.060985057710791],n)},KO=function(n){return Bt([1.716651187971268,-.355670783776392,-.25336628137366,-.666684351832489,1.616481236634939,.0157685458139111,.017639857445311,-.042770613257809,.942103121235474],n)},YO=function(n){var e=GO([n[0],n[1],n[2]]);return HO([e[0],e[1],e[2]])},XO=function(n){var e=$O(KO([n[0],n[1],n[2]])),t=e[0],i=e[1],r=e[2];return[t,i,r,n[3]]},JO=function(n){var e=YO([n[0],n[1],n[2]]);return is([e[0],e[1],e[2],n[3]])},ki={name:"color",parse:function(n,e){if(e.type===18){var t=tA[e.name];if(typeof t>"u")throw new Error('Attempting to parse an unsupported color function "'.concat(e.name,'"'));return t(n,e.values)}if(e.type===5){var i=nb(e),r=i[0],o=i[1],s=i[2],a=i[3];return In(r,o,s,a)}if(e.type===20){var c=Rn[e.value.toUpperCase()];if(typeof c<"u")return c}return Rn.TRANSPARENT}},nb=function(n){if(n.value.length===3){var e=n.value.substring(0,1),t=n.value.substring(1,2),i=n.value.substring(2,3);return[parseInt(e+e,16),parseInt(t+t,16),parseInt(i+i,16),1]}if(n.value.length===4){var e=n.value.substring(0,1),t=n.value.substring(1,2),i=n.value.substring(2,3),r=n.value.substring(3,4);return[parseInt(e+e,16),parseInt(t+t,16),parseInt(i+i,16),parseInt(r+r,16)/255]}if(n.value.length===6){var e=n.value.substring(0,2),t=n.value.substring(2,4),i=n.value.substring(4,6);return[parseInt(e,16),parseInt(t,16),parseInt(i,16),1]}if(n.value.length===8){var e=n.value.substring(0,2),t=n.value.substring(2,4),i=n.value.substring(4,6),r=n.value.substring(6,8);return[parseInt(e,16),parseInt(t,16),parseInt(i,16),parseInt(r,16)/255]}return[0,0,0,1]},ib=function(n,e){var t=e.filter(vt);if(Xi(t))throw new Error("Relative color not supported for rgb()");if(t.length===3){var i=t.map(pc),r=i[0],o=i[1],s=i[2];return In(r,o,s,1)}if(t.length===4){var a=t.map(pc),r=a[0],o=a[1],s=a[2],c=a[3];return In(r,o,s,c)}return 0},ZO=function(n,e){var t=e.filter(vt),i=t[0].type===20?t[0].value:"unknown",r=!Xi(t);if(r){var o=i,s=rb[o];if(typeof s>"u")throw new Error('Attempting to parse an unsupported color space "'.concat(o,'" for color() function'));var a=st(t[1])?t[1].number:0,c=st(t[2])?t[2].number:0,u=st(t[3])?t[3].number:0,l=t.length>4&&t[4].type===6&&t[4].value==="/"&&st(t[5])?t[5].number:1;return s([a,c,u,l])}else{var d=function(O,F){if(st(F))return F.number;var X=function(Ie){return Ie==="r"||Ie==="x"?0:Ie==="g"||Ie==="y"?1:2};if(ue(F)){var K=X(F.value);return O[K]}var Q=function(Ie){for(var dt=Ie.filter(vt),Me="(",Pe=0,ie=dt;Pe<ie.length;Pe++){var Ze=ie[Pe];Me+=Ze.type===18&&Ze.name==="calc"?Q(Ze.values):st(Ze)?Ze.number:Ze.type===6||ue(Ze)?Ze.value:""}return Me+=")",Me};if(F.type===18){var Ce=F.values.filter(vt);if(F.name==="calc"){var Ge=Q(Ce).replace(/r|x/,O[0].toString()).replace(/g|y/,O[1].toString()).replace(/b|z/,O[2].toString());return new Function("return "+Ge)()}}return null},h=t[1].type===18?t[1].name:ue(t[1])||t[1].type===5?"rgb":"unknown",p=ue(t[2])?t[2].value:"unknown",m=t[1].type===18?t[1].values:ue(t[1])?[t[1]]:[];if(ue(t[1])){var f=Rn[t[1].value.toUpperCase()];if(typeof f>"u")throw new Error("Attempting to use unknown color in relative color 'from'");var g=Wr(n,t[1].value),y=255&g,b=255&g>>8,S=255&g>>16,w=255&g>>24;m=[{type:17,number:w,flags:1},{type:17,number:S,flags:1},{type:17,number:b,flags:1},{type:17,number:y>1?y/255:y,flags:1}]}else if(t[1].type===5){var k=nb(t[1]),w=k[0],S=k[1],b=k[2],y=k[3];m=[{type:17,number:w,flags:1},{type:17,number:S,flags:1},{type:17,number:b,flags:1},{type:17,number:y>1?y/255:y,flags:1}]}if(m.length===0)throw new Error("Attempting to use unknown color in relative color 'from'");if(p==="unknown")throw new Error("Attempting to use unknown colorspace in relative color 'to'");var C=QO[h],x=eA[p],I=rb[p];if(typeof C>"u")throw new Error('Attempting to parse an unsupported color space "'.concat(h,'" for color() function'));if(typeof x>"u")throw new Error('Attempting to parse an unsupported color space "'.concat(p,'" for color() function'));var P=C(n,m),D=x(P),a=d(D,t[3]),c=d(D,t[4]),u=d(D,t[5]),l=t.length>6&&t[6].type===6&&t[6].value==="/"&&st(t[7])?t[7].number:1;if(a===null||c===null||u===null)throw new Error("Invalid relative color in color() function");return I([a,c,u,l])}},rb={srgb:uO,"srgb-linear":lh,"display-p3":OO,"a98-rgb":UO,"prophoto-rgb":WO,xyz:eb,"xyz-d50":SO,"xyz-d65":eb,rec2020:JO},QO={rgb:fO,hsl:mO,lab:gO,lch:vO,oklab:bO,oklch:yO},eA={srgb:wO,"srgb-linear":CO,"display-p3":PO,"a98-rgb":LO,"prophoto-rgb":qO,xyz:Qy,"xyz-d50":kO,"xyz-d65":Qy,rec2020:XO},tA={hsl:Ky,hsla:Ky,rgb:ib,rgba:ib,lch:pO,oklch:hO,oklab:dO,lab:lO,color:ZO},Wr=function(n,e){return ki.parse(n,Fy.create(e).parseComponentValue())},Rn={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},nA={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:function(n,e){return e.map(function(t){if(ue(t))switch(t.value){case"padding-box":return 1;case"content-box":return 2}return 0})}},iA={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},bc=function(n,e){var t=ki.parse(n,e[0]),i=e[1];return i&&Fe(i)?{color:t,stop:i}:{color:t,stop:null}},ob=function(n,e){var t=n[0],i=n[n.length-1];t.stop===null&&(t.stop=yt),i.stop===null&&(i.stop=yi);for(var r=[],o=0,s=0;s<n.length;s++){var a=n[s].stop;if(a!==null){var c=Ee(a,e);c>o?r.push(c):r.push(o),o=c}else r.push(null)}for(var u=null,s=0;s<r.length;s++){var l=r[s];if(l===null)u===null&&(u=s);else if(u!==null){for(var d=s-u,h=r[u-1],p=(l-h)/(d+1),m=1;m<=d;m++)r[u+m-1]=p*m;u=null}}return n.map(function(f,g){var y=f.color;return{color:y,stop:Math.max(Math.min(1,r[g]/e),0)}})},rA=function(n,e,t){var i=e/2,r=t/2,o=Ee(n[0],e)-i,s=r-Ee(n[1],t);return(Math.atan2(s,o)+Math.PI*2)%(Math.PI*2)},oA=function(n,e,t){var i=typeof n=="number"?n:rA(n,e,t),r=Math.abs(e*Math.sin(i))+Math.abs(t*Math.cos(i)),o=e/2,s=t/2,a=r/2,c=Math.sin(i-Math.PI/2)*a,u=Math.cos(i-Math.PI/2)*a;return[r,o-u,o+u,s-c,s+c]},cn=function(n,e){return Math.sqrt(n*n+e*e)},sb=function(n,e,t,i,r){var o=[[0,0],[0,e],[n,0],[n,e]];return o.reduce(function(s,a){var c=a[0],u=a[1],l=cn(t-c,i-u);return(r?l<s.optimumDistance:l>s.optimumDistance)?{optimumCorner:a,optimumDistance:l}:s},{optimumDistance:r?1/0:-1/0,optimumCorner:null}).optimumCorner},sA=function(n,e,t,i,r){var o=0,s=0;switch(n.size){case 0:n.shape===0?o=s=Math.min(Math.abs(e),Math.abs(e-i),Math.abs(t),Math.abs(t-r)):n.shape===1&&(o=Math.min(Math.abs(e),Math.abs(e-i)),s=Math.min(Math.abs(t),Math.abs(t-r)));break;case 2:if(n.shape===0)o=s=Math.min(cn(e,t),cn(e,t-r),cn(e-i,t),cn(e-i,t-r));else if(n.shape===1){var a=Math.min(Math.abs(t),Math.abs(t-r))/Math.min(Math.abs(e),Math.abs(e-i)),c=sb(i,r,e,t,!0),u=c[0],l=c[1];o=cn(u-e,(l-t)/a),s=a*o}break;case 1:n.shape===0?o=s=Math.max(Math.abs(e),Math.abs(e-i),Math.abs(t),Math.abs(t-r)):n.shape===1&&(o=Math.max(Math.abs(e),Math.abs(e-i)),s=Math.max(Math.abs(t),Math.abs(t-r)));break;case 3:if(n.shape===0)o=s=Math.max(cn(e,t),cn(e,t-r),cn(e-i,t),cn(e-i,t-r));else if(n.shape===1){var a=Math.max(Math.abs(t),Math.abs(t-r))/Math.max(Math.abs(e),Math.abs(e-i)),d=sb(i,r,e,t,!1),u=d[0],l=d[1];o=cn(u-e,(l-t)/a),s=a*o}break}return Array.isArray(n.size)&&(o=Ee(n.size[0],i),s=n.size.length===2?Ee(n.size[1],r):o),[o,s]},aA=function(n,e){var t=Xt(180),i=[];return En(e).forEach(function(r,o){if(o===0){var s=r[0];if(s.type===20&&s.value==="to"){t=$y(r);return}else if(Gy(s)){t=hc.parse(n,s);return}}var a=bc(n,r);i.push(a)}),{angle:t,stops:i,type:1}},_c=function(n,e){var t=Xt(180),i=[];return En(e).forEach(function(r,o){if(o===0){var s=r[0];if(s.type===20&&["top","left","right","bottom"].indexOf(s.value)!==-1){t=$y(r);return}else if(Gy(s)){t=(hc.parse(n,s)+Xt(270))%Xt(360);return}}var a=bc(n,r);i.push(a)}),{angle:t,stops:i,type:1}},cA=function(n,e){var t=Xt(180),i=[],r=1,o=0,s=3,a=[];return En(e).forEach(function(c,u){var l=c[0];if(u===0){if(ue(l)&&l.value==="linear"){r=1;return}else if(ue(l)&&l.value==="radial"){r=2;return}}if(l.type===18){if(l.name==="from"){var d=ki.parse(n,l.values[0]);i.push({stop:yt,color:d})}else if(l.name==="to"){var d=ki.parse(n,l.values[0]);i.push({stop:yi,color:d})}else if(l.name==="color-stop"){var h=l.values.filter(vt);if(h.length===2){var d=ki.parse(n,h[1]),p=h[0];st(p)&&i.push({stop:{type:16,number:p.number*100,flags:p.flags},color:d})}}}}),r===1?{angle:(t+Xt(180))%Xt(360),stops:i,type:r}:{size:s,shape:o,stops:i,position:a,type:r}},ab="closest-side",cb="farthest-side",ub="closest-corner",lb="farthest-corner",db="circle",hb="ellipse",pb="cover",fb="contain",uA=function(n,e){var t=0,i=3,r=[],o=[];return En(e).forEach(function(s,a){var c=!0;if(a===0){var u=!1;c=s.reduce(function(d,h){if(u)if(ue(h))switch(h.value){case"center":return o.push(uh),d;case"top":case"left":return o.push(yt),d;case"right":case"bottom":return o.push(yi),d}else(Fe(h)||vi(h))&&o.push(h);else if(ue(h))switch(h.value){case db:return t=0,!1;case hb:return t=1,!1;case"at":return u=!0,!1;case ab:return i=0,!1;case pb:case cb:return i=1,!1;case fb:case ub:return i=2,!1;case lb:return i=3,!1}else if(vi(h)||Fe(h))return Array.isArray(i)||(i=[]),i.push(h),!1;return d},c)}if(c){var l=bc(n,s);r.push(l)}}),{size:i,shape:t,stops:r,position:o,type:2}},kc=function(n,e){var t=0,i=3,r=[],o=[];return En(e).forEach(function(s,a){var c=!0;if(a===0?c=s.reduce(function(l,d){if(ue(d))switch(d.value){case"center":return o.push(uh),!1;case"top":case"left":return o.push(yt),!1;case"right":case"bottom":return o.push(yi),!1}else if(Fe(d)||vi(d))return o.push(d),!1;return l},c):a===1&&(c=s.reduce(function(l,d){if(ue(d))switch(d.value){case db:return t=0,!1;case hb:return t=1,!1;case fb:case ab:return i=0,!1;case cb:return i=1,!1;case ub:return i=2,!1;case pb:case lb:return i=3,!1}else if(vi(d)||Fe(d))return Array.isArray(i)||(i=[]),i.push(d),!1;return l},c)),c){var u=bc(n,s);r.push(u)}}),{size:i,shape:t,stops:r,position:o,type:2}},lA=function(n){return n.type===1},dA=function(n){return n.type===2},mh={name:"image",parse:function(n,e){if(e.type===22){var t={url:e.value,type:0};return n.cache.addImage(e.value),t}if(e.type===18){var i=mb[e.name];if(typeof i>"u")throw new Error('Attempting to parse an unsupported image function "'.concat(e.name,'"'));return i(n,e.values)}throw new Error("Unsupported image type ".concat(e.type))}};function hA(n){return!(n.type===20&&n.value==="none")&&(n.type!==18||!!mb[n.name])}var mb={"linear-gradient":aA,"-moz-linear-gradient":_c,"-ms-linear-gradient":_c,"-o-linear-gradient":_c,"-webkit-linear-gradient":_c,"radial-gradient":uA,"-moz-radial-gradient":kc,"-ms-radial-gradient":kc,"-o-radial-gradient":kc,"-webkit-radial-gradient":kc,"-webkit-gradient":cA},pA={name:"background-image",initialValue:"none",type:1,prefix:!1,parse:function(n,e){if(e.length===0)return[];var t=e[0];return t.type===20&&t.value==="none"?[]:e.filter(function(i){return vt(i)&&hA(i)}).map(function(i){return mh.parse(n,i)})}},fA={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:function(n,e){return e.map(function(t){if(ue(t))switch(t.value){case"padding-box":return 1;case"content-box":return 2}return 0})}},mA={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:function(n,e){return En(e).map(function(t){return t.filter(Fe)}).map(jy)}},gA={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:function(n,e){return En(e).map(function(t){return t.filter(ue).map(function(i){return i.value}).join(" ")}).map(vA)}},vA=function(n){switch(n){case"no-repeat":return 1;case"repeat-x":case"repeat no-repeat":return 2;case"repeat-y":case"no-repeat repeat":return 3;case"repeat":default:return 0}},Gr;(function(n){n.AUTO="auto",n.CONTAIN="contain",n.COVER="cover"})(Gr||(Gr={}));var yA={name:"background-size",initialValue:"0",prefix:!1,type:1,parse:function(n,e){return En(e).map(function(t){return t.filter(bA)})}},bA=function(n){return ue(n)||Fe(n)},Sc=function(n){return{name:"border-".concat(n,"-color"),initialValue:"transparent",prefix:!1,type:3,format:"color"}},_A=Sc("top"),kA=Sc("right"),SA=Sc("bottom"),wA=Sc("left"),wc=function(n){return{name:"border-radius-".concat(n),initialValue:"0 0",prefix:!1,type:1,parse:function(e,t){return jy(t.filter(Fe))}}},CA=wc("top-left"),TA=wc("top-right"),xA=wc("bottom-right"),EA=wc("bottom-left"),Cc=function(n){return{name:"border-".concat(n,"-style"),initialValue:"solid",prefix:!1,type:2,parse:function(e,t){switch(t){case"none":return 0;case"dashed":return 2;case"dotted":return 3;case"double":return 4}return 1}}},IA=Cc("top"),RA=Cc("right"),PA=Cc("bottom"),OA=Cc("left"),Tc=function(n){return{name:"border-".concat(n,"-width"),initialValue:"0",type:0,prefix:!1,parse:function(e,t){return gi(t)?t.number:0}}},AA=Tc("top"),MA=Tc("right"),NA=Tc("bottom"),DA=Tc("left"),LA={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},UA={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:function(n,e){switch(e){case"rtl":return 1;case"ltr":default:return 0}}},FA={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:function(n,e){return e.filter(ue).reduce(function(t,i){return t|BA(i.value)},0)}},BA=function(n){switch(n){case"block":case"-webkit-box":return 2;case"inline":return 4;case"run-in":return 8;case"flow":return 16;case"flow-root":return 32;case"table":return 64;case"flex":case"-webkit-flex":return 128;case"grid":case"-ms-grid":return 256;case"ruby":return 512;case"subgrid":return 1024;case"list-item":return 2048;case"table-row-group":return 4096;case"table-header-group":return 8192;case"table-footer-group":return 16384;case"table-row":return 32768;case"table-cell":return 65536;case"table-column-group":return 131072;case"table-column":return 262144;case"table-caption":return 524288;case"ruby-base":return 1048576;case"ruby-text":return 2097152;case"ruby-base-container":return 4194304;case"ruby-text-container":return 8388608;case"contents":return 16777216;case"inline-block":return 33554432;case"inline-list-item":return 67108864;case"inline-table":return 134217728;case"inline-flex":return 268435456;case"inline-grid":return 536870912}return 0},jA={name:"float",initialValue:"none",prefix:!1,type:2,parse:function(n,e){switch(e){case"left":return 1;case"right":return 2;case"inline-start":return 3;case"inline-end":return 4}return 0}},VA={name:"letter-spacing",initialValue:"0",prefix:!1,type:0,parse:function(n,e){return e.type===20&&e.value==="normal"?0:e.type===17||e.type===15?e.number:0}},xc;(function(n){n.NORMAL="normal",n.STRICT="strict"})(xc||(xc={}));var zA={name:"line-break",initialValue:"normal",prefix:!1,type:2,parse:function(n,e){switch(e){case"strict":return xc.STRICT;case"normal":default:return xc.NORMAL}}},qA={name:"line-height",initialValue:"normal",prefix:!1,type:4},gb=function(n,e){return ue(n)&&n.value==="normal"?1.2*e:n.type===17?e*n.number:Fe(n)?Ee(n,e):e},WA={name:"list-style-image",initialValue:"none",type:0,prefix:!1,parse:function(n,e){return e.type===20&&e.value==="none"?null:mh.parse(n,e)}},GA={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:function(n,e){switch(e){case"inside":return 0;case"outside":default:return 1}}},gh={name:"list-style-type",initialValue:"none",prefix:!1,type:2,parse:function(n,e){switch(e){case"disc":return 0;case"circle":return 1;case"square":return 2;case"decimal":return 3;case"cjk-decimal":return 4;case"decimal-leading-zero":return 5;case"lower-roman":return 6;case"upper-roman":return 7;case"lower-greek":return 8;case"lower-alpha":return 9;case"upper-alpha":return 10;case"arabic-indic":return 11;case"armenian":return 12;case"bengali":return 13;case"cambodian":return 14;case"cjk-earthly-branch":return 15;case"cjk-heavenly-stem":return 16;case"cjk-ideographic":return 17;case"devanagari":return 18;case"ethiopic-numeric":return 19;case"georgian":return 20;case"gujarati":return 21;case"gurmukhi":return 22;case"hebrew":return 52;case"hiragana":return 23;case"hiragana-iroha":return 24;case"japanese-formal":return 25;case"japanese-informal":return 26;case"kannada":return 27;case"katakana":return 28;case"katakana-iroha":return 29;case"khmer":return 30;case"korean-hangul-formal":return 31;case"korean-hanja-formal":return 32;case"korean-hanja-informal":return 33;case"lao":return 34;case"lower-armenian":return 35;case"malayalam":return 36;case"mongolian":return 37;case"myanmar":return 38;case"oriya":return 39;case"persian":return 40;case"simp-chinese-formal":return 41;case"simp-chinese-informal":return 42;case"tamil":return 43;case"telugu":return 44;case"thai":return 45;case"tibetan":return 46;case"trad-chinese-formal":return 47;case"trad-chinese-informal":return 48;case"upper-armenian":return 49;case"disclosure-open":return 50;case"disclosure-closed":return 51;case"none":default:return-1}}},Ec=function(n){return{name:"margin-".concat(n),initialValue:"0",prefix:!1,type:4}},$A=Ec("top"),HA=Ec("right"),KA=Ec("bottom"),YA=Ec("left"),XA={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:function(n,e){return e.filter(ue).map(function(t){switch(t.value){case"hidden":return 1;case"scroll":return 2;case"clip":return 3;case"auto":return 4;case"visible":default:return 0}})}},JA={name:"overflow-wrap",initialValue:"normal",prefix:!1,type:2,parse:function(n,e){switch(e){case"break-word":return"break-word";case"normal":default:return"normal"}}},Ic=function(n){return{name:"padding-".concat(n),initialValue:"0",prefix:!1,type:3,format:"length-percentage"}},ZA=Ic("top"),QA=Ic("right"),eM=Ic("bottom"),tM=Ic("left"),nM={name:"text-align",initialValue:"left",prefix:!1,type:2,parse:function(n,e){switch(e){case"right":return 2;case"center":case"justify":return 1;case"left":default:return 0}}},iM={name:"position",initialValue:"static",prefix:!1,type:2,parse:function(n,e){switch(e){case"relative":return 1;case"absolute":return 2;case"fixed":return 3;case"sticky":return 4}return 0}},rM={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:function(n,e){return e.length===1&&ch(e[0],"none")?[]:En(e).map(function(t){for(var i={color:Rn.TRANSPARENT,offsetX:yt,offsetY:yt,blur:yt},r=0,o=0;o<t.length;o++){var s=t[o];vi(s)?(r===0?i.offsetX=s:r===1?i.offsetY=s:i.blur=s,r++):i.color=ki.parse(n,s)}return i})}},oM={name:"text-transform",initialValue:"none",prefix:!1,type:2,parse:function(n,e){switch(e){case"uppercase":return 2;case"lowercase":return 1;case"capitalize":return 3}return 0}},sM={name:"transform",initialValue:"none",prefix:!0,type:0,parse:function(n,e){if(e.type===20&&e.value==="none")return null;if(e.type===18){var t=uM[e.name];if(typeof t>"u")throw new Error('Attempting to parse an unsupported transform function "'.concat(e.name,'"'));return t(e.values)}return null}},aM=function(n){var e=n.filter(function(t){return t.type===17}).map(function(t){return t.number});return e.length===6?e:null},cM=function(n){var e=n.filter(function(c){return c.type===17}).map(function(c){return c.number}),t=e[0],i=e[1];e[2],e[3];var r=e[4],o=e[5];e[6],e[7],e[8],e[9],e[10],e[11];var s=e[12],a=e[13];return e[14],e[15],e.length===16?[t,i,r,o,s,a]:null},uM={matrix:aM,matrix3d:cM},vb={type:16,number:50,flags:Jo},lM=[vb,vb],dM={name:"transform-origin",initialValue:"50% 50%",prefix:!0,type:1,parse:function(n,e){var t=e.filter(Fe);return t.length!==2?lM:[t[0],t[1]]}},hM={name:"visible",initialValue:"none",prefix:!1,type:2,parse:function(n,e){switch(e){case"hidden":return 1;case"collapse":return 2;case"visible":default:return 0}}},rs;(function(n){n.NORMAL="normal",n.BREAK_ALL="break-all",n.KEEP_ALL="keep-all"})(rs||(rs={}));var pM={name:"word-break",initialValue:"normal",prefix:!1,type:2,parse:function(n,e){switch(e){case"break-all":return rs.BREAK_ALL;case"keep-all":return rs.KEEP_ALL;case"normal":default:return rs.NORMAL}}},fM={name:"z-index",initialValue:"auto",prefix:!1,type:0,parse:function(n,e){if(e.type===20)return{auto:!0,order:0};if(st(e))return{auto:!1,order:e.number};throw new Error("Invalid z-index number parsed")}},yb={name:"time",parse:function(n,e){if(e.type===15)switch(e.unit.toLowerCase()){case"s":return 1e3*e.number;case"ms":return e.number}throw new Error("Unsupported time type")}},mM={name:"opacity",initialValue:"1",type:0,prefix:!1,parse:function(n,e){return st(e)?e.number:1}},gM={name:"text-decoration-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},vM={name:"text-decoration-line",initialValue:"none",prefix:!1,type:1,parse:function(n,e){return e.filter(ue).map(function(t){switch(t.value){case"underline":return 1;case"overline":return 2;case"line-through":return 3;case"none":return 4}return 0}).filter(function(t){return t!==0})}},yM={name:"font-family",initialValue:"",prefix:!1,type:1,parse:function(n,e){var t=[],i=[];return e.forEach(function(r){switch(r.type){case 20:case 0:t.push(r.value);break;case 17:t.push(r.number.toString());break;case 4:i.push(t.join(" ")),t.length=0;break}}),t.length&&i.push(t.join(" ")),i.map(function(r){return r.indexOf(" ")===-1?r:"'".concat(r,"'")})}},bM={name:"font-size",initialValue:"0",prefix:!1,type:3,format:"length"},_M={name:"font-weight",initialValue:"normal",type:0,prefix:!1,parse:function(n,e){if(st(e))return e.number;if(ue(e))switch(e.value){case"bold":return 700;case"normal":default:return 400}return 400}},kM={name:"font-variant",initialValue:"none",type:1,prefix:!1,parse:function(n,e){return e.filter(ue).map(function(t){return t.value})}},SM={name:"font-style",initialValue:"normal",prefix:!1,type:2,parse:function(n,e){switch(e){case"oblique":return"oblique";case"italic":return"italic";case"normal":default:return"normal"}}},ut=function(n,e){return(n&e)!==0},wM={name:"content",initialValue:"none",type:1,prefix:!1,parse:function(n,e){if(e.length===0)return[];var t=e[0];return t.type===20&&t.value==="none"?[]:e}},CM={name:"counter-increment",initialValue:"none",prefix:!0,type:1,parse:function(n,e){if(e.length===0)return null;var t=e[0];if(t.type===20&&t.value==="none")return null;for(var i=[],r=e.filter(By),o=0;o<r.length;o++){var s=r[o],a=r[o+1];if(s.type===20){var c=a&&st(a)?a.number:1;i.push({counter:s.value,increment:c})}}return i}},TM={name:"counter-reset",initialValue:"none",prefix:!0,type:1,parse:function(n,e){if(e.length===0)return[];for(var t=[],i=e.filter(By),r=0;r<i.length;r++){var o=i[r],s=i[r+1];if(ue(o)&&o.value!=="none"){var a=s&&st(s)?s.number:0;t.push({counter:o.value,reset:a})}}return t}},xM={name:"duration",initialValue:"0s",prefix:!1,type:1,parse:function(n,e){return e.filter(gi).map(function(t){return yb.parse(n,t)})}},EM={name:"quotes",initialValue:"none",prefix:!0,type:1,parse:function(n,e){if(e.length===0)return null;var t=e[0];if(t.type===20&&t.value==="none")return null;var i=[],r=e.filter(aO);if(r.length%2!==0)return null;for(var o=0;o<r.length;o+=2){var s=r[o].value,a=r[o+1].value;i.push({open:s,close:a})}return i}},bb=function(n,e,t){if(!n)return"";var i=n[Math.min(e,n.length-1)];return i?t?i.open:i.close:""},IM={name:"box-shadow",initialValue:"none",type:1,prefix:!1,parse:function(n,e){return e.length===1&&ch(e[0],"none")?[]:En(e).map(function(t){for(var i={color:255,offsetX:yt,offsetY:yt,blur:yt,spread:yt,inset:!1},r=0,o=0;o<t.length;o++){var s=t[o];ch(s,"inset")?i.inset=!0:vi(s)?(r===0?i.offsetX=s:r===1?i.offsetY=s:r===2?i.blur=s:i.spread=s,r++):i.color=ki.parse(n,s)}return i})}},RM={name:"paint-order",initialValue:"normal",prefix:!1,type:1,parse:function(n,e){var t=[0,1,2],i=[];return e.filter(ue).forEach(function(r){switch(r.value){case"stroke":i.push(1);break;case"fill":i.push(0);break;case"markers":i.push(2);break}}),t.forEach(function(r){i.indexOf(r)===-1&&i.push(r)}),i}},PM={name:"-webkit-text-stroke-color",initialValue:"currentcolor",prefix:!1,type:3,format:"color"},OM={name:"-webkit-text-stroke-width",initialValue:"0",type:0,prefix:!1,parse:function(n,e){return gi(e)?e.number:0}},AM={name:"objectFit",initialValue:"fill",prefix:!1,type:1,parse:function(n,e){return e.filter(ue).reduce(function(t,i){return t|MM(i.value)},0)}},MM=function(n){switch(n){case"contain":return 2;case"cover":return 4;case"none":return 8;case"scale-down":return 16}return 0},NM=function(){function n(e,t){var i,r;this.animationDuration=$(e,xM,t.animationDuration),this.backgroundClip=$(e,nA,t.backgroundClip),this.backgroundColor=$(e,iA,t.backgroundColor),this.backgroundImage=$(e,pA,t.backgroundImage),this.backgroundOrigin=$(e,fA,t.backgroundOrigin),this.backgroundPosition=$(e,mA,t.backgroundPosition),this.backgroundRepeat=$(e,gA,t.backgroundRepeat),this.backgroundSize=$(e,yA,t.backgroundSize),this.borderTopColor=$(e,_A,t.borderTopColor),this.borderRightColor=$(e,kA,t.borderRightColor),this.borderBottomColor=$(e,SA,t.borderBottomColor),this.borderLeftColor=$(e,wA,t.borderLeftColor),this.borderTopLeftRadius=$(e,CA,t.borderTopLeftRadius),this.borderTopRightRadius=$(e,TA,t.borderTopRightRadius),this.borderBottomRightRadius=$(e,xA,t.borderBottomRightRadius),this.borderBottomLeftRadius=$(e,EA,t.borderBottomLeftRadius),this.borderTopStyle=$(e,IA,t.borderTopStyle),this.borderRightStyle=$(e,RA,t.borderRightStyle),this.borderBottomStyle=$(e,PA,t.borderBottomStyle),this.borderLeftStyle=$(e,OA,t.borderLeftStyle),this.borderTopWidth=$(e,AA,t.borderTopWidth),this.borderRightWidth=$(e,MA,t.borderRightWidth),this.borderBottomWidth=$(e,NA,t.borderBottomWidth),this.borderLeftWidth=$(e,DA,t.borderLeftWidth),this.boxShadow=$(e,IM,t.boxShadow),this.color=$(e,LA,t.color),this.direction=$(e,UA,t.direction),this.display=$(e,FA,t.display),this.float=$(e,jA,t.cssFloat),this.fontFamily=$(e,yM,t.fontFamily),this.fontSize=$(e,bM,t.fontSize),this.fontStyle=$(e,SM,t.fontStyle),this.fontVariant=$(e,kM,t.fontVariant),this.fontWeight=$(e,_M,t.fontWeight),this.letterSpacing=$(e,VA,t.letterSpacing),this.lineBreak=$(e,zA,t.lineBreak),this.lineHeight=$(e,qA,t.lineHeight),this.listStyleImage=$(e,WA,t.listStyleImage),this.listStylePosition=$(e,GA,t.listStylePosition),this.listStyleType=$(e,gh,t.listStyleType),this.marginTop=$(e,$A,t.marginTop),this.marginRight=$(e,HA,t.marginRight),this.marginBottom=$(e,KA,t.marginBottom),this.marginLeft=$(e,YA,t.marginLeft),this.opacity=$(e,mM,t.opacity);var o=$(e,XA,t.overflow);this.overflowX=o[0],this.overflowY=o[o.length>1?1:0],this.overflowWrap=$(e,JA,t.overflowWrap),this.paddingTop=$(e,ZA,t.paddingTop),this.paddingRight=$(e,QA,t.paddingRight),this.paddingBottom=$(e,eM,t.paddingBottom),this.paddingLeft=$(e,tM,t.paddingLeft),this.paintOrder=$(e,RM,t.paintOrder),this.position=$(e,iM,t.position),this.textAlign=$(e,nM,t.textAlign),this.textDecorationColor=$(e,gM,(i=t.textDecorationColor)!==null&&i!==void 0?i:t.color),this.textDecorationLine=$(e,vM,(r=t.textDecorationLine)!==null&&r!==void 0?r:t.textDecoration),this.textShadow=$(e,rM,t.textShadow),this.textTransform=$(e,oM,t.textTransform),this.transform=$(e,sM,t.transform),this.transformOrigin=$(e,dM,t.transformOrigin),this.visibility=$(e,hM,t.visibility),this.webkitTextStrokeColor=$(e,PM,t.webkitTextStrokeColor),this.webkitTextStrokeWidth=$(e,OM,t.webkitTextStrokeWidth),this.wordBreak=$(e,pM,t.wordBreak),this.zIndex=$(e,fM,t.zIndex),this.objectFit=$(e,AM,t.objectFit)}return n.prototype.isVisible=function(){return this.display>0&&this.opacity>0&&this.visibility===0},n.prototype.isTransparent=function(){return bi(this.backgroundColor)},n.prototype.isTransformed=function(){return this.transform!==null},n.prototype.isPositioned=function(){return this.position!==0},n.prototype.isPositionedWithZIndex=function(){return this.isPositioned()&&!this.zIndex.auto},n.prototype.isFloating=function(){return this.float!==0},n.prototype.isInlineLevel=function(){return ut(this.display,4)||ut(this.display,33554432)||ut(this.display,268435456)||ut(this.display,536870912)||ut(this.display,67108864)||ut(this.display,134217728)},n}(),DM=function(){function n(e,t){this.content=$(e,wM,t.content),this.quotes=$(e,EM,t.quotes)}return n}(),_b=function(){function n(e,t){this.counterIncrement=$(e,CM,t.counterIncrement),this.counterReset=$(e,TM,t.counterReset)}return n}(),$=function(n,e,t){var i=new Uy,r=t!==null&&typeof t<"u"?t.toString():e.initialValue;i.write(r);var o=new Fy(i.read());switch(e.type){case 2:var s=o.parseComponentValue();return e.parse(n,ue(s)?s.value:e.initialValue);case 0:return e.parse(n,o.parseComponentValue());case 1:return e.parse(n,o.parseComponentValues());case 4:return o.parseComponentValue();case 3:switch(e.format){case"angle":return hc.parse(n,o.parseComponentValue());case"color":return ki.parse(n,o.parseComponentValue());case"image":return mh.parse(n,o.parseComponentValue());case"length":var a=o.parseComponentValue();return vi(a)?a:yt;case"length-percentage":var c=o.parseComponentValue();return Fe(c)?c:yt;case"time":return yb.parse(n,o.parseComponentValue())}break}},LM="data-html2canvas-debug",UM=function(n){var e=n.getAttribute(LM);switch(e){case"all":return 1;case"clone":return 2;case"parse":return 3;case"render":return 4;default:return 0}},vh=function(n,e){var t=UM(n);return t===1||e===t},Pn=function(){function n(e,t){this.context=e,this.textNodes=[],this.elements=[],this.flags=0,vh(t,3),this.styles=new NM(e,window.getComputedStyle(t,null)),Ih(t)&&(this.styles.animationDuration.some(function(i){return i>0})&&(t.style.animationDuration="0s"),this.styles.transform!==null&&(t.style.transform="none")),this.bounds=Za(this.context,t),vh(t,4)&&(this.flags|=16)}return n}();typeof SuppressedError=="function"&&SuppressedError;for(var kb="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",FM=typeof Uint8Array>"u"?[]:new Uint8Array(256),Rc=0;Rc<kb.length;Rc++)FM[kb.charCodeAt(Rc)]=Rc;for(var Sb="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",BM=typeof Uint8Array>"u"?[]:new Uint8Array(256),Pc=0;Pc<Sb.length;Pc++)BM[Sb.charCodeAt(Pc)]=Pc;var jM=1,yh=2,bh=3,wb=4,Cb=5,VM=7,Tb=8,_h=9,kh=10,xb=11,Eb=12,Ib=13,Rb=14,Sh=15,zM=function(n){for(var e=[],t=0,i=n.length;t<i;){var r=n.charCodeAt(t++);if(r>=55296&&r<=56319&&t<i){var o=n.charCodeAt(t++);(o&64512)===56320?e.push(((r&1023)<<10)+(o&1023)+65536):(e.push(r),t--)}else e.push(r)}return e},qM=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];if(String.fromCodePoint)return String.fromCodePoint.apply(String,n);var t=n.length;if(!t)return"";for(var i=[],r=-1,o="";++r<t;){var s=n[r];s<=65535?i.push(s):(s-=65536,i.push((s>>10)+55296,s%1024+56320)),(r+1===t||i.length>16384)&&(o+=String.fromCharCode.apply(String,i),i.length=0)}return o},Jt="\xD7",wh="\xF7",WM=function(n){throw new Error("UnicodeTrie not initialized")},GM=function(n,e,t){var i=t-2,r=e[i],o=e[t-1],s=e[t];if(o===yh&&s===bh)return Jt;if(o===yh||o===bh||o===wb||s===yh||s===bh||s===wb)return wh;if(o===Tb&&[Tb,_h,xb,Eb].indexOf(s)!==-1||(o===xb||o===_h)&&(s===_h||s===kh)||(o===Eb||o===kh)&&s===kh||s===Ib||s===Cb||s===VM||o===jM)return Jt;if(o===Ib&&s===Rb){for(;r===Cb;)r=e[--i];if(r===Rb)return Jt}if(o===Sh&&s===Sh){for(var a=0;r===Sh;)a++,r=e[--i];if(a%2===0)return Jt}return wh},$M=function(n){var e=zM(n),t=e.length,i=0,r=0,o=e.map(WM);return{next:function(){if(i>=t)return{done:!0,value:null};for(var s=Jt;i<t&&(s=GM(e,o,++i))===Jt;);if(s!==Jt||i===t){var a=qM.apply(null,e.slice(r,i));return r=i,{value:a,done:!1}}return{done:!0,value:null}}}},HM=function(n){for(var e=$M(n),t=[],i;!(i=e.next()).done;)i.value&&t.push(i.value.slice());return t},KM=function(n){var e=123;if(n.createRange){var t=n.createRange();if(t.getBoundingClientRect){var i=n.createElement("boundtest");i.style.height="".concat(e,"px"),i.style.display="block",n.body.appendChild(i),t.selectNode(i);var r=t.getBoundingClientRect(),o=Math.round(r.height);if(n.body.removeChild(i),o===e)return!0}}return!1},YM=function(n){var e=n.createElement("boundtest");e.style.width="50px",e.style.display="block",e.style.fontSize="12px",e.style.letterSpacing="0px",e.style.wordSpacing="0px",n.body.appendChild(e);var t=n.createRange();e.innerHTML=typeof"".repeat=="function"?"&#128104;".repeat(10):"";var i=e.firstChild,r=Qa(i.data).map(function(c){return nt(c)}),o=0,s={},a=r.every(function(c,u){t.setStart(i,o),t.setEnd(i,o+c.length);var l=t.getBoundingClientRect();o+=c.length;var d=l.x>s.x||l.y>s.y;return s=l,u===0?!0:d});return n.body.removeChild(e),a},XM=function(){return typeof new Image().crossOrigin<"u"},JM=function(){return typeof new XMLHttpRequest().responseType=="string"},ZM=function(n){var e=new Image,t=n.createElement("canvas"),i=t.getContext("2d");if(!i)return!1;e.src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>";try{i.drawImage(e,0,0),t.toDataURL()}catch{return!1}return!0},Pb=function(n){return n[0]===0&&n[1]===255&&n[2]===0&&n[3]===255},QM=function(n){var e=n.createElement("canvas"),t=100;e.width=t,e.height=t;var i=e.getContext("2d");if(!i)return Promise.reject(!1);i.fillStyle="rgb(0, 255, 0)",i.fillRect(0,0,t,t);var r=new Image,o=e.toDataURL();r.src=o;var s=Ch(t,t,0,0,r);return i.fillStyle="red",i.fillRect(0,0,t,t),Ob(s).then(function(a){i.drawImage(a,0,0);var c=i.getImageData(0,0,t,t).data;i.fillStyle="red",i.fillRect(0,0,t,t);var u=n.createElement("div");return u.style.backgroundImage="url(".concat(o,")"),u.style.height="".concat(t,"px"),Pb(c)?Ob(Ch(t,t,0,0,u)):Promise.reject(!1)}).then(function(a){return i.drawImage(a,0,0),Pb(i.getImageData(0,0,t,t).data)}).catch(function(){return!1})},Ch=function(n,e,t,i,r){var o="http://www.w3.org/2000/svg",s=document.createElementNS(o,"svg"),a=document.createElementNS(o,"foreignObject");return s.setAttributeNS(null,"width",n.toString()),s.setAttributeNS(null,"height",e.toString()),a.setAttributeNS(null,"width","100%"),a.setAttributeNS(null,"height","100%"),a.setAttributeNS(null,"x",t.toString()),a.setAttributeNS(null,"y",i.toString()),a.setAttributeNS(null,"externalResourcesRequired","true"),s.appendChild(a),a.appendChild(r),s},Ob=function(n){return new Promise(function(e,t){var i=new Image;i.onload=function(){return e(i)},i.onerror=t,i.src="data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(new XMLSerializer().serializeToString(n)))})},bt={get SUPPORT_RANGE_BOUNDS(){var n=KM(document);return Object.defineProperty(bt,"SUPPORT_RANGE_BOUNDS",{value:n}),n},get SUPPORT_WORD_BREAKING(){var n=bt.SUPPORT_RANGE_BOUNDS&&YM(document);return Object.defineProperty(bt,"SUPPORT_WORD_BREAKING",{value:n}),n},get SUPPORT_SVG_DRAWING(){var n=ZM(document);return Object.defineProperty(bt,"SUPPORT_SVG_DRAWING",{value:n}),n},get SUPPORT_FOREIGNOBJECT_DRAWING(){var n=typeof Array.from=="function"&&typeof window.fetch=="function"?QM(document):Promise.resolve(!1);return Object.defineProperty(bt,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:n}),n},get SUPPORT_CORS_IMAGES(){var n=XM();return Object.defineProperty(bt,"SUPPORT_CORS_IMAGES",{value:n}),n},get SUPPORT_RESPONSE_TYPE(){var n=JM();return Object.defineProperty(bt,"SUPPORT_RESPONSE_TYPE",{value:n}),n},get SUPPORT_CORS_XHR(){var n="withCredentials"in new XMLHttpRequest;return Object.defineProperty(bt,"SUPPORT_CORS_XHR",{value:n}),n},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){var n=!!(typeof Intl<"u"&&Intl.Segmenter);return Object.defineProperty(bt,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:n}),n}},os=function(){function n(e,t){this.text=e,this.bounds=t}return n}(),eN=function(n,e,t,i){var r=iN(e,t),o=[],s=0;return r.forEach(function(a){if(t.textDecorationLine.length||a.trim().length>0)if(bt.SUPPORT_RANGE_BOUNDS){var c=Ab(i,s,a.length).getClientRects();if(c.length>1){var u=Th(a),l=0;u.forEach(function(h){o.push(new os(h,Gn.fromDOMRectList(n,Ab(i,l+s,h.length).getClientRects()))),l+=h.length})}else o.push(new os(a,Gn.fromDOMRectList(n,c)))}else{var d=i.splitText(a.length);o.push(new os(a,tN(n,i))),i=d}else bt.SUPPORT_RANGE_BOUNDS||(i=i.splitText(a.length));s+=a.length}),o},tN=function(n,e){var t=e.ownerDocument;if(t){var i=t.createElement("html2canvaswrapper");i.appendChild(e.cloneNode(!0));var r=e.parentNode;if(r){r.replaceChild(i,e);var o=Za(n,i);return i.firstChild&&r.replaceChild(i.firstChild,i),o}}return Gn.EMPTY},Ab=function(n,e,t){var i=n.ownerDocument;if(!i)throw new Error("Node has no owner document");var r=i.createRange();return r.setStart(n,e),r.setEnd(n,e+t),r},Th=function(n){if(bt.SUPPORT_NATIVE_TEXT_SEGMENTATION){var e=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(e.segment(n)).map(function(t){return t.segment})}return HM(n)},nN=function(n,e){if(bt.SUPPORT_NATIVE_TEXT_SEGMENTATION){var t=new Intl.Segmenter(void 0,{granularity:"word"});return Array.from(t.segment(n)).map(function(i){return i.segment})}return oN(n,e)},iN=function(n,e){return e.letterSpacing!==0?Th(n):nN(n,e)},rN=[32,160,4961,65792,65793,4153,4241],oN=function(n,e){for(var t=t2(n,{lineBreak:e.lineBreak,wordBreak:e.overflowWrap==="break-word"?"break-word":e.wordBreak}),i=[],r,o=function(){if(r.value){var s=r.value.slice(),a=Qa(s),c="";a.forEach(function(u){rN.indexOf(u)===-1?c+=nt(u):(c.length&&i.push(c),i.push(nt(u)),c="")}),c.length&&i.push(c)}};!(r=t.next()).done;)o();return i},sN=function(){function n(e,t,i){this.text=aN(t.data,i.textTransform),this.textBounds=eN(e,this.text,i,t)}return n}(),aN=function(n,e){switch(e){case 1:return n.toLowerCase();case 3:return n.replace(cN,uN);case 2:return n.toUpperCase();default:return n}},cN=/(^|\s|:|-|\(|\))([a-z])/g,uN=function(n,e,t){return n.length>0?e+t.toUpperCase():n},Mb=function(n){an(e,n);function e(t,i){var r=n.call(this,t,i)||this;return r.src=i.currentSrc||i.src,r.intrinsicWidth=i.naturalWidth,r.intrinsicHeight=i.naturalHeight,r.context.cache.addImage(r.src),r}return e}(Pn),Nb=function(n){an(e,n);function e(t,i){var r=n.call(this,t,i)||this;return r.canvas=i,r.intrinsicWidth=i.width,r.intrinsicHeight=i.height,r}return e}(Pn),Db=function(n){an(e,n);function e(t,i){var r=n.call(this,t,i)||this,o=new XMLSerializer,s=Za(t,i);return i.setAttribute("width","".concat(s.width,"px")),i.setAttribute("height","".concat(s.height,"px")),r.svg="data:image/svg+xml,".concat(encodeURIComponent(o.serializeToString(i))),r.intrinsicWidth=i.width.baseVal.value,r.intrinsicHeight=i.height.baseVal.value,r.context.cache.addImage(r.svg),r}return e}(Pn),Lb=function(n){an(e,n);function e(t,i){var r=n.call(this,t,i)||this;return r.value=i.value,r}return e}(Pn),xh=function(n){an(e,n);function e(t,i){var r=n.call(this,t,i)||this;return r.start=i.start,r.reversed=typeof i.reversed=="boolean"&&i.reversed===!0,r}return e}(Pn),lN=[{type:15,flags:0,unit:"px",number:3}],dN=[{type:16,flags:0,number:50}],hN=function(n){return n.width>n.height?new Gn(n.left+(n.width-n.height)/2,n.top,n.height,n.height):n.width<n.height?new Gn(n.left,n.top+(n.height-n.width)/2,n.width,n.width):n},pN=function(n){var e=n.type===fN?new Array(n.value.length+1).join("\u2022"):n.value;return e.length===0?n.placeholder||"":e},Oc="checkbox",Ac="radio",fN="password",Ub=707406591,Eh=function(n){an(e,n);function e(t,i){var r=n.call(this,t,i)||this;switch(r.type=i.type.toLowerCase(),r.checked=i.checked,r.value=pN(i),(r.type===Oc||r.type===Ac)&&(r.styles.backgroundColor=3739148031,r.styles.borderTopColor=r.styles.borderRightColor=r.styles.borderBottomColor=r.styles.borderLeftColor=2779096575,r.styles.borderTopWidth=r.styles.borderRightWidth=r.styles.borderBottomWidth=r.styles.borderLeftWidth=1,r.styles.borderTopStyle=r.styles.borderRightStyle=r.styles.borderBottomStyle=r.styles.borderLeftStyle=1,r.styles.backgroundClip=[0],r.styles.backgroundOrigin=[0],r.bounds=hN(r.bounds)),r.type){case Oc:r.styles.borderTopRightRadius=r.styles.borderTopLeftRadius=r.styles.borderBottomRightRadius=r.styles.borderBottomLeftRadius=lN;break;case Ac:r.styles.borderTopRightRadius=r.styles.borderTopLeftRadius=r.styles.borderBottomRightRadius=r.styles.borderBottomLeftRadius=dN;break}return r}return e}(Pn),Fb=function(n){an(e,n);function e(t,i){var r=n.call(this,t,i)||this,o=i.options[i.selectedIndex||0];return r.value=o&&o.text||"",r}return e}(Pn),Bb=function(n){an(e,n);function e(t,i){var r=n.call(this,t,i)||this;return r.value=i.value,r}return e}(Pn),jb=function(n){an(e,n);function e(t,i){var r=n.call(this,t,i)||this;r.src=i.src,r.width=parseInt(i.width,10)||0,r.height=parseInt(i.height,10)||0,r.backgroundColor=r.styles.backgroundColor;try{if(i.contentWindow&&i.contentWindow.document&&i.contentWindow.document.documentElement){r.tree=zb(t,i.contentWindow.document.documentElement);var o=i.contentWindow.document.documentElement?Wr(t,getComputedStyle(i.contentWindow.document.documentElement).backgroundColor):Rn.TRANSPARENT,s=i.contentWindow.document.body?Wr(t,getComputedStyle(i.contentWindow.document.body).backgroundColor):Rn.TRANSPARENT;r.backgroundColor=bi(o)?bi(s)?r.styles.backgroundColor:s:o}}catch{}return r}return e}(Pn),mN=["OL","UL","MENU"],Mc=function(n,e,t,i){for(var r=e.firstChild,o=void 0;r;r=o)if(o=r.nextSibling,qb(r)&&r.data.length>0)t.textNodes.push(new sN(n,r,t.styles));else if($r(r))if(Yb(r)&&r.assignedNodes)r.assignedNodes().forEach(function(a){return Mc(n,a,t,i)});else{var s=Vb(n,r);s.styles.isVisible()&&(gN(r,s,i)?s.flags|=4:vN(s.styles)&&(s.flags|=2),mN.indexOf(r.tagName)!==-1&&(s.flags|=8),t.elements.push(s),r.slot,r.shadowRoot?Mc(n,r.shadowRoot,s,i):!Dc(r)&&!Wb(r)&&!Lc(r)&&Mc(n,r,s,i))}},Vb=function(n,e){return Ph(e)?new Mb(n,e):Gb(e)?new Nb(n,e):Wb(e)?new Db(n,e):yN(e)?new Lb(n,e):bN(e)?new xh(n,e):_N(e)?new Eh(n,e):Lc(e)?new Fb(n,e):Dc(e)?new Bb(n,e):Hb(e)?new jb(n,e):new Pn(n,e)},zb=function(n,e){var t=Vb(n,e);return t.flags|=4,Mc(n,e,t,t),t},gN=function(n,e,t){return e.styles.isPositionedWithZIndex()||e.styles.opacity<1||e.styles.isTransformed()||Rh(n)&&t.styles.isTransparent()},vN=function(n){return n.isPositioned()||n.isFloating()},qb=function(n){return n.nodeType===Node.TEXT_NODE},$r=function(n){return n.nodeType===Node.ELEMENT_NODE},Ih=function(n){return $r(n)&&typeof n.style<"u"&&!Nc(n)},Nc=function(n){return typeof n.className=="object"},yN=function(n){return n.tagName==="LI"},bN=function(n){return n.tagName==="OL"},_N=function(n){return n.tagName==="INPUT"},kN=function(n){return n.tagName==="HTML"},Wb=function(n){return n.tagName==="svg"},Rh=function(n){return n.tagName==="BODY"},Gb=function(n){return n.tagName==="CANVAS"},$b=function(n){return n.tagName==="VIDEO"},Ph=function(n){return n.tagName==="IMG"},Hb=function(n){return n.tagName==="IFRAME"},Kb=function(n){return n.tagName==="STYLE"},SN=function(n){return n.tagName==="SCRIPT"},Dc=function(n){return n.tagName==="TEXTAREA"},Lc=function(n){return n.tagName==="SELECT"},Yb=function(n){return n.tagName==="SLOT"},Xb=function(n){return n.tagName.indexOf("-")>0},wN=function(){function n(){this.counters={}}return n.prototype.getCounterValue=function(e){var t=this.counters[e];return t&&t.length?t[t.length-1]:1},n.prototype.getCounterValues=function(e){var t=this.counters[e];return t||[]},n.prototype.pop=function(e){var t=this;e.forEach(function(i){return t.counters[i].pop()})},n.prototype.parse=function(e){var t=this,i=e.counterIncrement,r=e.counterReset,o=!0;i!==null&&i.forEach(function(a){var c=t.counters[a.counter];c&&a.increment!==0&&(o=!1,c.length||c.push(1),c[Math.max(0,c.length-1)]+=a.increment)});var s=[];return o&&r.forEach(function(a){var c=t.counters[a.counter];s.push(a.counter),c||(c=t.counters[a.counter]=[]),c.push(a.reset)}),s},n}(),Jb={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]},Zb={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["\u0554","\u0553","\u0552","\u0551","\u0550","\u054F","\u054E","\u054D","\u054C","\u054B","\u054A","\u0549","\u0548","\u0547","\u0546","\u0545","\u0544","\u0543","\u0542","\u0541","\u0540","\u053F","\u053E","\u053D","\u053C","\u053B","\u053A","\u0539","\u0538","\u0537","\u0536","\u0535","\u0534","\u0533","\u0532","\u0531"]},CN={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:["\u05D9\u05F3","\u05D8\u05F3","\u05D7\u05F3","\u05D6\u05F3","\u05D5\u05F3","\u05D4\u05F3","\u05D3\u05F3","\u05D2\u05F3","\u05D1\u05F3","\u05D0\u05F3","\u05EA","\u05E9","\u05E8","\u05E7","\u05E6","\u05E4","\u05E2","\u05E1","\u05E0","\u05DE","\u05DC","\u05DB","\u05D9\u05D8","\u05D9\u05D7","\u05D9\u05D6","\u05D8\u05D6","\u05D8\u05D5","\u05D9","\u05D8","\u05D7","\u05D6","\u05D5","\u05D4","\u05D3","\u05D2","\u05D1","\u05D0"]},TN={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["\u10F5","\u10F0","\u10EF","\u10F4","\u10EE","\u10ED","\u10EC","\u10EB","\u10EA","\u10E9","\u10E8","\u10E7","\u10E6","\u10E5","\u10E4","\u10F3","\u10E2","\u10E1","\u10E0","\u10DF","\u10DE","\u10DD","\u10F2","\u10DC","\u10DB","\u10DA","\u10D9","\u10D8","\u10D7","\u10F1","\u10D6","\u10D5","\u10D4","\u10D3","\u10D2","\u10D1","\u10D0"]},Hr=function(n,e,t,i,r,o){return n<e||n>t?as(n,r,o.length>0):i.integers.reduce(function(s,a,c){for(;n>=a;)n-=a,s+=i.values[c];return s},"")+o},Qb=function(n,e,t,i){var r="";do t||n--,r=i(n)+r,n/=e;while(n*e>=e);return r},it=function(n,e,t,i,r){var o=t-e+1;return(n<0?"-":"")+(Qb(Math.abs(n),o,i,function(s){return nt(Math.floor(s%o)+e)})+r)},Zi=function(n,e,t){t===void 0&&(t=". ");var i=e.length;return Qb(Math.abs(n),i,!1,function(r){return e[Math.floor(r%i)]})+t},Kr=1,Si=2,wi=4,ss=8,$n=function(n,e,t,i,r,o){if(n<-9999||n>9999)return as(n,4,r.length>0);var s=Math.abs(n),a=r;if(s===0)return e[0]+a;for(var c=0;s>0&&c<=4;c++){var u=s%10;u===0&&ut(o,Kr)&&a!==""?a=e[u]+a:u>1||u===1&&c===0||u===1&&c===1&&ut(o,Si)||u===1&&c===1&&ut(o,wi)&&n>100||u===1&&c>1&&ut(o,ss)?a=e[u]+(c>0?t[c-1]:"")+a:u===1&&c>0&&(a=t[c-1]+a),s=Math.floor(s/10)}return(n<0?i:"")+a},e_="\u5341\u767E\u5343\u842C",t_="\u62FE\u4F70\u4EDF\u842C",n_="\u30DE\u30A4\u30CA\u30B9",Oh="\uB9C8\uC774\uB108\uC2A4",as=function(n,e,t){var i=t?". ":"",r=t?"\u3001":"",o=t?", ":"",s=t?" ":"";switch(e){case 0:return"\u2022"+s;case 1:return"\u25E6"+s;case 2:return"\u25FE"+s;case 5:var a=it(n,48,57,!0,i);return a.length<4?"0".concat(a):a;case 4:return Zi(n,"\u3007\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D",r);case 6:return Hr(n,1,3999,Jb,3,i).toLowerCase();case 7:return Hr(n,1,3999,Jb,3,i);case 8:return it(n,945,969,!1,i);case 9:return it(n,97,122,!1,i);case 10:return it(n,65,90,!1,i);case 11:return it(n,1632,1641,!0,i);case 12:case 49:return Hr(n,1,9999,Zb,3,i);case 35:return Hr(n,1,9999,Zb,3,i).toLowerCase();case 13:return it(n,2534,2543,!0,i);case 14:case 30:return it(n,6112,6121,!0,i);case 15:return Zi(n,"\u5B50\u4E11\u5BC5\u536F\u8FB0\u5DF3\u5348\u672A\u7533\u9149\u620C\u4EA5",r);case 16:return Zi(n,"\u7532\u4E59\u4E19\u4E01\u620A\u5DF1\u5E9A\u8F9B\u58EC\u7678",r);case 17:case 48:return $n(n,"\u96F6\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D",e_,"\u8CA0",r,Si|wi|ss);case 47:return $n(n,"\u96F6\u58F9\u8CB3\u53C3\u8086\u4F0D\u9678\u67D2\u634C\u7396",t_,"\u8CA0",r,Kr|Si|wi|ss);case 42:return $n(n,"\u96F6\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D",e_,"\u8D1F",r,Si|wi|ss);case 41:return $n(n,"\u96F6\u58F9\u8D30\u53C1\u8086\u4F0D\u9646\u67D2\u634C\u7396",t_,"\u8D1F",r,Kr|Si|wi|ss);case 26:return $n(n,"\u3007\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D","\u5341\u767E\u5343\u4E07",n_,r,0);case 25:return $n(n,"\u96F6\u58F1\u5F10\u53C2\u56DB\u4F0D\u516D\u4E03\u516B\u4E5D","\u62FE\u767E\u5343\u4E07",n_,r,Kr|Si|wi);case 31:return $n(n,"\uC601\uC77C\uC774\uC0BC\uC0AC\uC624\uC721\uCE60\uD314\uAD6C","\uC2ED\uBC31\uCC9C\uB9CC",Oh,o,Kr|Si|wi);case 33:return $n(n,"\u96F6\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D","\u5341\u767E\u5343\u842C",Oh,o,0);case 32:return $n(n,"\u96F6\u58F9\u8CB3\u53C3\u56DB\u4E94\u516D\u4E03\u516B\u4E5D","\u62FE\u767E\u5343",Oh,o,Kr|Si|wi);case 18:return it(n,2406,2415,!0,i);case 20:return Hr(n,1,19999,TN,3,i);case 21:return it(n,2790,2799,!0,i);case 22:return it(n,2662,2671,!0,i);case 52:return Hr(n,1,10999,CN,3,i);case 23:return Zi(n,"\u3042\u3044\u3046\u3048\u304A\u304B\u304D\u304F\u3051\u3053\u3055\u3057\u3059\u305B\u305D\u305F\u3061\u3064\u3066\u3068\u306A\u306B\u306C\u306D\u306E\u306F\u3072\u3075\u3078\u307B\u307E\u307F\u3080\u3081\u3082\u3084\u3086\u3088\u3089\u308A\u308B\u308C\u308D\u308F\u3090\u3091\u3092\u3093");case 24:return Zi(n,"\u3044\u308D\u306F\u306B\u307B\u3078\u3068\u3061\u308A\u306C\u308B\u3092\u308F\u304B\u3088\u305F\u308C\u305D\u3064\u306D\u306A\u3089\u3080\u3046\u3090\u306E\u304A\u304F\u3084\u307E\u3051\u3075\u3053\u3048\u3066\u3042\u3055\u304D\u3086\u3081\u307F\u3057\u3091\u3072\u3082\u305B\u3059");case 27:return it(n,3302,3311,!0,i);case 28:return Zi(n,"\u30A2\u30A4\u30A6\u30A8\u30AA\u30AB\u30AD\u30AF\u30B1\u30B3\u30B5\u30B7\u30B9\u30BB\u30BD\u30BF\u30C1\u30C4\u30C6\u30C8\u30CA\u30CB\u30CC\u30CD\u30CE\u30CF\u30D2\u30D5\u30D8\u30DB\u30DE\u30DF\u30E0\u30E1\u30E2\u30E4\u30E6\u30E8\u30E9\u30EA\u30EB\u30EC\u30ED\u30EF\u30F0\u30F1\u30F2\u30F3",r);case 29:return Zi(n,"\u30A4\u30ED\u30CF\u30CB\u30DB\u30D8\u30C8\u30C1\u30EA\u30CC\u30EB\u30F2\u30EF\u30AB\u30E8\u30BF\u30EC\u30BD\u30C4\u30CD\u30CA\u30E9\u30E0\u30A6\u30F0\u30CE\u30AA\u30AF\u30E4\u30DE\u30B1\u30D5\u30B3\u30A8\u30C6\u30A2\u30B5\u30AD\u30E6\u30E1\u30DF\u30B7\u30F1\u30D2\u30E2\u30BB\u30B9",r);case 34:return it(n,3792,3801,!0,i);case 37:return it(n,6160,6169,!0,i);case 38:return it(n,4160,4169,!0,i);case 39:return it(n,2918,2927,!0,i);case 40:return it(n,1776,1785,!0,i);case 43:return it(n,3046,3055,!0,i);case 44:return it(n,3174,3183,!0,i);case 45:return it(n,3664,3673,!0,i);case 46:return it(n,3872,3881,!0,i);case 3:default:return it(n,48,57,!0,i)}},i_="data-html2canvas-ignore",r_=function(){function n(e,t,i){if(this.context=e,this.options=i,this.scrolledElements=[],this.referenceElement=t,this.counters=new wN,this.quoteDepth=0,!t.ownerDocument)throw new Error("Cloned element does not have an owner document");this.documentElement=this.cloneNode(t.ownerDocument.documentElement,!1)}return n.prototype.toIFrame=function(e,t){var i=this,r=xN(e,t);if(!r.contentWindow)return Promise.reject("Unable to find iframe window");var o=e.defaultView.pageXOffset,s=e.defaultView.pageYOffset,a=r.contentWindow,c=a.document,u=RN(r).then(function(){return Mt(i,void 0,void 0,function(){var h,p;return xt(this,function(m){switch(m.label){case 0:return this.scrolledElements.forEach(MN),a&&(a.scrollTo(t.left,t.top),/(iPad|iPhone|iPod)/g.test(navigator.userAgent)&&(a.scrollY!==t.top||a.scrollX!==t.left)&&(this.context.logger.warn("Unable to restore scroll position for cloned document"),this.context.windowBounds=this.context.windowBounds.add(a.scrollX-t.left,a.scrollY-t.top,0,0))),h=this.options.onclone,p=this.clonedReferenceElement,typeof p>"u"?[2,Promise.reject("Error finding the ".concat(this.referenceElement.nodeName," in the cloned document"))]:c.fonts&&c.fonts.ready?[4,c.fonts.ready]:[3,2];case 1:m.sent(),m.label=2;case 2:return/(AppleWebKit)/g.test(navigator.userAgent)?[4,IN(c)]:[3,4];case 3:m.sent(),m.label=4;case 4:return typeof h=="function"?[2,Promise.resolve().then(function(){return h(c,p)}).then(function(){return r})]:[2,r]}})})}),l=c.baseURI;c.open(),c.write("".concat(ON(document.doctype),"<html></html>")),AN(this.referenceElement.ownerDocument,o,s);var d=c.adoptNode(this.documentElement);return FN(d,l),c.replaceChild(d,c.documentElement),c.close(),u},n.prototype.createElementClone=function(e){if(vh(e,2),Gb(e))return this.createCanvasClone(e);if($b(e))return this.createVideoClone(e);if(Kb(e))return this.createStyleClone(e);var t=e.cloneNode(!1);return Ph(t)&&(Ph(e)&&e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),t.loading==="lazy"&&(t.loading="eager")),Xb(t)?this.createCustomElementClone(t):t},n.prototype.createCustomElementClone=function(e){var t=document.createElement("html2canvascustomelement");return Ah(e.style,t),t},n.prototype.createStyleClone=function(e){try{var t=e.sheet;if(t&&t.cssRules){var i=[].slice.call(t.cssRules,0).reduce(function(o,s){return s&&typeof s.cssText=="string"?o+s.cssText:o},""),r=e.cloneNode(!1);return r.textContent=i,r}}catch(o){if(this.context.logger.error("Unable to access cssRules property",o),o.name!=="SecurityError")throw o}return e.cloneNode(!1)},n.prototype.createCanvasClone=function(e){var t;if(this.options.inlineImages&&e.ownerDocument){var i=e.ownerDocument.createElement("img");try{return i.src=e.toDataURL(),i}catch{this.context.logger.info("Unable to inline canvas contents, canvas is tainted",e)}}var r=e.cloneNode(!1);try{r.width=e.width,r.height=e.height;var o=e.getContext("2d"),s=r.getContext("2d",{willReadFrequently:!0});if(s)if(!this.options.allowTaint&&o)s.putImageData(o.getImageData(0,0,e.width,e.height),0,0);else{var a=(t=e.getContext("webgl2"))!==null&&t!==void 0?t:e.getContext("webgl");if(a){var c=a.getContextAttributes();(c==null?void 0:c.preserveDrawingBuffer)===!1&&this.context.logger.warn("Unable to clone WebGL context as it has preserveDrawingBuffer=false",e)}s.drawImage(e,0,0)}return r}catch{this.context.logger.info("Unable to clone canvas as it is tainted",e)}return r},n.prototype.createVideoClone=function(e){var t=e.ownerDocument.createElement("canvas");t.width=e.offsetWidth,t.height=e.offsetHeight;var i=t.getContext("2d");try{return i&&(i.drawImage(e,0,0,t.width,t.height),this.options.allowTaint||i.getImageData(0,0,t.width,t.height)),t}catch{this.context.logger.info("Unable to clone video as it is tainted",e)}var r=e.ownerDocument.createElement("canvas");return r.width=e.offsetWidth,r.height=e.offsetHeight,r},n.prototype.appendChildNode=function(e,t,i){(!$r(t)||!SN(t)&&!t.hasAttribute(i_)&&(typeof this.options.ignoreElements!="function"||!this.options.ignoreElements(t)))&&(!this.options.copyStyles||!$r(t)||!Kb(t))&&e.appendChild(this.cloneNode(t,i))},n.prototype.cloneChildNodes=function(e,t,i){for(var r=this,o=e.shadowRoot?e.shadowRoot.firstChild:e.firstChild;o;o=o.nextSibling)if($r(o)&&Yb(o)&&typeof o.assignedNodes=="function"){var s=o.assignedNodes();s.length&&s.forEach(function(a){return r.appendChildNode(t,a,i)})}else this.appendChildNode(t,o,i)},n.prototype.cloneNode=function(e,t){if(qb(e))return document.createTextNode(e.data);if(!e.ownerDocument)return e.cloneNode(!1);var i=e.ownerDocument.defaultView;if(i&&$r(e)&&(Ih(e)||Nc(e))){var r=this.createElementClone(e);r.style.transitionProperty="none";var o=i.getComputedStyle(e),s=i.getComputedStyle(e,":before"),a=i.getComputedStyle(e,":after");this.referenceElement===e&&Ih(r)&&(this.clonedReferenceElement=r),Rh(r)&&LN(r);var c=this.counters.parse(new _b(this.context,o)),u=this.resolvePseudoContent(e,r,s,cs.BEFORE);Xb(e)&&(t=!0),$b(e)||this.cloneChildNodes(e,r,t),u&&r.insertBefore(u,r.firstChild);var l=this.resolvePseudoContent(e,r,a,cs.AFTER);return l&&r.appendChild(l),this.counters.pop(c),(o&&(this.options.copyStyles||Nc(e))&&!Hb(e)||t)&&Ah(o,r),(e.scrollTop!==0||e.scrollLeft!==0)&&this.scrolledElements.push([r,e.scrollLeft,e.scrollTop]),(Dc(e)||Lc(e))&&(Dc(r)||Lc(r))&&(r.value=e.value),r}return e.cloneNode(!1)},n.prototype.resolvePseudoContent=function(e,t,i,r){var o=this;if(i){var s=i.content,a=t.ownerDocument;if(!(!a||!s||s==="none"||s==="-moz-alt-content"||i.display==="none")){this.counters.parse(new _b(this.context,i));var c=new DM(this.context,i),u=a.createElement("html2canvaspseudoelement");Ah(i,u),c.content.forEach(function(d){if(d.type===0)u.appendChild(a.createTextNode(d.value));else if(d.type===22){var h=a.createElement("img");h.src=d.value,h.style.opacity="1",u.appendChild(h)}else if(d.type===18){if(d.name==="attr"){var p=d.values.filter(ue);p.length&&u.appendChild(a.createTextNode(e.getAttribute(p[0].value)||""))}else if(d.name==="counter"){var m=d.values.filter(vt),f=m[0],g=m[1];if(f&&ue(f)){var y=o.counters.getCounterValue(f.value),b=g&&ue(g)?gh.parse(o.context,g.value):3;u.appendChild(a.createTextNode(as(y,b,!1)))}}else if(d.name==="counters"){var S=d.values.filter(vt),f=S[0],w=S[1],g=S[2];if(f&&ue(f)){var k=o.counters.getCounterValues(f.value),C=g&&ue(g)?gh.parse(o.context,g.value):3,x=w&&w.type===0?w.value:"",I=k.map(function(A){return as(A,C,!1)}).join(x);u.appendChild(a.createTextNode(I))}}}else if(d.type===20)switch(d.value){case"open-quote":u.appendChild(a.createTextNode(bb(c.quotes,o.quoteDepth++,!0)));break;case"close-quote":u.appendChild(a.createTextNode(bb(c.quotes,--o.quoteDepth,!1)));break;default:u.appendChild(a.createTextNode(d.value))}}),u.className="".concat(Mh," ").concat(Nh);var l=r===cs.BEFORE?" ".concat(Mh):" ".concat(Nh);return Nc(t)?t.className.baseValue+=l:t.className+=l,u}}},n.destroy=function(e){return e.parentNode?(e.parentNode.removeChild(e),!0):!1},n}(),cs;(function(n){n[n.BEFORE=0]="BEFORE",n[n.AFTER=1]="AFTER"})(cs||(cs={}));var xN=function(n,e){var t=n.createElement("iframe");return t.className="html2canvas-container",t.style.visibility="hidden",t.style.position="fixed",t.style.left="-10000px",t.style.top="0px",t.style.border="0",t.width=e.width.toString(),t.height=e.height.toString(),t.scrolling="no",t.setAttribute(i_,"true"),n.body.appendChild(t),t},EN=function(n){return new Promise(function(e){if(n.complete){e();return}if(!n.src){e();return}n.onload=e,n.onerror=e})},IN=function(n){return Promise.all([].slice.call(n.images,0).map(EN))},RN=function(n){return new Promise(function(e,t){var i=n.contentWindow;if(!i)return t("No window assigned for iframe");var r=i.document;i.onload=n.onload=function(){i.onload=n.onload=null;var o=setInterval(function(){r.body.childNodes.length>0&&r.readyState==="complete"&&(clearInterval(o),e(n))},50)}})},PN=["all","d","content"],Ah=function(n,e){for(var t=n.length-1;t>=0;t--){var i=n.item(t);PN.indexOf(i)===-1&&e.style.setProperty(i,n.getPropertyValue(i))}return e},ON=function(n){var e="";return n&&(e+="<!DOCTYPE ",n.name&&(e+=n.name),n.internalSubset&&(e+=n.internalSubset),n.publicId&&(e+='"'.concat(n.publicId,'"')),n.systemId&&(e+='"'.concat(n.systemId,'"')),e+=">"),e},AN=function(n,e,t){n&&n.defaultView&&(e!==n.defaultView.pageXOffset||t!==n.defaultView.pageYOffset)&&n.defaultView.scrollTo(e,t)},MN=function(n){var e=n[0],t=n[1],i=n[2];e.scrollLeft=t,e.scrollTop=i},NN=":before",DN=":after",Mh="___html2canvas___pseudoelement_before",Nh="___html2canvas___pseudoelement_after",o_=`{
1
+ (function(){"use strict";function op(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Ko={exports:{}};(function(n){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function r(c,l,u){this.fn=c,this.context=l,this.once=u||!1}function s(c,l,u,d,h){if(typeof u!="function")throw new TypeError("The listener must be a function");var f=new r(u,d||c,h),p=t?t+l:l;return c._events[p]?c._events[p].fn?c._events[p]=[c._events[p],f]:c._events[p].push(f):(c._events[p]=f,c._eventsCount++),c}function a(c,l){--c._eventsCount===0?c._events=new i:delete c._events[l]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var l=[],u,d;if(this._eventsCount===0)return l;for(d in u=this._events)e.call(u,d)&&l.push(t?d.slice(1):d);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(u)):l},o.prototype.listeners=function(l){var u=t?t+l:l,d=this._events[u];if(!d)return[];if(d.fn)return[d.fn];for(var h=0,f=d.length,p=new Array(f);h<f;h++)p[h]=d[h].fn;return p},o.prototype.listenerCount=function(l){var u=t?t+l:l,d=this._events[u];return d?d.fn?1:d.length:0},o.prototype.emit=function(l,u,d,h,f,p){var g=t?t+l:l;if(!this._events[g])return!1;var v=this._events[g],b=arguments.length,S,x;if(v.fn){switch(v.once&&this.removeListener(l,v.fn,void 0,!0),b){case 1:return v.fn.call(v.context),!0;case 2:return v.fn.call(v.context,u),!0;case 3:return v.fn.call(v.context,u,d),!0;case 4:return v.fn.call(v.context,u,d,h),!0;case 5:return v.fn.call(v.context,u,d,h,f),!0;case 6:return v.fn.call(v.context,u,d,h,f,p),!0}for(x=1,S=new Array(b-1);x<b;x++)S[x-1]=arguments[x];v.fn.apply(v.context,S)}else{var k=v.length,T;for(x=0;x<k;x++)switch(v[x].once&&this.removeListener(l,v[x].fn,void 0,!0),b){case 1:v[x].fn.call(v[x].context);break;case 2:v[x].fn.call(v[x].context,u);break;case 3:v[x].fn.call(v[x].context,u,d);break;case 4:v[x].fn.call(v[x].context,u,d,h);break;default:if(!S)for(T=1,S=new Array(b-1);T<b;T++)S[T-1]=arguments[T];v[x].fn.apply(v[x].context,S)}}return!0},o.prototype.on=function(l,u,d){return s(this,l,u,d,!1)},o.prototype.once=function(l,u,d){return s(this,l,u,d,!0)},o.prototype.removeListener=function(l,u,d,h){var f=t?t+l:l;if(!this._events[f])return this;if(!u)return a(this,f),this;var p=this._events[f];if(p.fn)p.fn===u&&(!h||p.once)&&(!d||p.context===d)&&a(this,f);else{for(var g=0,v=[],b=p.length;g<b;g++)(p[g].fn!==u||h&&!p[g].once||d&&p[g].context!==d)&&v.push(p[g]);v.length?this._events[f]=v.length===1?v[0]:v:a(this,f)}return this},o.prototype.removeAllListeners=function(l){var u;return l?(u=t?t+l:l,this._events[u]&&a(this,u)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,n.exports=o})(Ko);var cp=Ko.exports;const Cs=op(cp);var xs=function(n,e){return xs=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])},xs(n,e)};function tt(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");xs(n,e);function t(){this.constructor=n}n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var ws=function(){return ws=Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++){t=arguments[i];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},ws.apply(this,arguments)};function De(n,e,t,i){function r(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function o(u){try{l(i.next(u))}catch(d){a(d)}}function c(u){try{l(i.throw(u))}catch(d){a(d)}}function l(u){u.done?s(u.value):r(u.value).then(o,c)}l((i=i.apply(n,e||[])).next())})}function Oe(n,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=o(0),a.throw=o(1),a.return=o(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(u){return c([l,u])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(t=0)),t;)try{if(i=1,r&&(s=l[0]&2?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,r=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){t.label=l[1];break}if(l[0]===6&&t.label<s[1]){t.label=s[1],s=l;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(l);break}s[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(u){l=[6,u],r=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function Ii(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,s;i<r;i++)(s||!(i in e))&&(s||(s=Array.prototype.slice.call(e,0,i)),s[i]=e[i]);return n.concat(s||Array.prototype.slice.call(e))}typeof SuppressedError=="function"&&SuppressedError;for(var xt=function(){function n(e,t,i,r){this.left=e,this.top=t,this.width=i,this.height=r}return n.prototype.add=function(e,t,i,r){return new n(this.left+e,this.top+t,this.width+i,this.height+r)},n.fromClientRect=function(e,t){return new n(t.left+e.windowBounds.left,t.top+e.windowBounds.top,t.width,t.height)},n.fromDOMRectList=function(e,t){var i=Array.from(t).find(function(r){return r.width!==0});return i?new n(i.left+e.windowBounds.left,i.top+e.windowBounds.top,i.width,i.height):n.EMPTY},n.EMPTY=new n(0,0,0,0),n}(),Oi=function(n,e){return xt.fromClientRect(n,e.getBoundingClientRect())},lp=function(n){var e=n.body,t=n.documentElement;if(!e||!t)throw new Error("Unable to get document size");var i=Math.max(Math.max(e.scrollWidth,t.scrollWidth),Math.max(e.offsetWidth,t.offsetWidth),Math.max(e.clientWidth,t.clientWidth)),r=Math.max(Math.max(e.scrollHeight,t.scrollHeight),Math.max(e.offsetHeight,t.offsetHeight),Math.max(e.clientHeight,t.clientHeight));return new xt(0,0,i,r)},Ai=function(n){for(var e=[],t=0,i=n.length;t<i;){var r=n.charCodeAt(t++);if(r>=55296&&r<=56319&&t<i){var s=n.charCodeAt(t++);(s&64512)===56320?e.push(((r&1023)<<10)+(s&1023)+65536):(e.push(r),t--)}else e.push(r)}return e},me=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];if(String.fromCodePoint)return String.fromCodePoint.apply(String,n);var t=n.length;if(!t)return"";for(var i=[],r=-1,s="";++r<t;){var a=n[r];a<=65535?i.push(a):(a-=65536,i.push((a>>10)+55296,a%1024+56320)),(r+1===t||i.length>16384)&&(s+=String.fromCharCode.apply(String,i),i.length=0)}return s},$o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",up=typeof Uint8Array>"u"?[]:new Uint8Array(256),Ni=0;Ni<$o.length;Ni++)up[$o.charCodeAt(Ni)]=Ni;typeof SuppressedError=="function"&&SuppressedError;for(var Yo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",dp=typeof Uint8Array>"u"?[]:new Uint8Array(256),Mi=0;Mi<Yo.length;Mi++)dp[Yo.charCodeAt(Mi)]=Mi;for(var Xo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",hp=typeof Uint8Array>"u"?[]:new Uint8Array(256),Li=0;Li<Xo.length;Li++)hp[Xo.charCodeAt(Li)]=Li;var fp=1,Jo=2,Qo=3,pp=5,Zo=8,ec=10,mp=25,gp=30,vp=37,bp=42,tc="!",Mt="\xD7",yp="\xF7",nc=[fp,Jo,Qo,pp],kp=[ec,Zo],Tp=function(n,e){var t=[],i=[],r=[];return n.forEach(function(s,a){throw new Error("UnicodeTrie not initialized")}),[i,t,r]},Sp=function(n,e){for(var t=n;t>=0;){var i=e[t];if(i===ec)t--;else return i}return 0},Cp=function(n,e,t,i,r){if(t[i]===0)return Mt;var s=i-1;if(Array.isArray(r)&&r[s]===!0)return Mt;var a=s-1,o=s+1,c=e[s];a>=0&&e[a];var l=e[o];if(c===Jo&&l===Qo)return Mt;if(nc.indexOf(c)!==-1)return tc;if(nc.indexOf(l)!==-1||kp.indexOf(l)!==-1)return Mt;if(Sp(s,e)===Zo)return yp;throw new Error("UnicodeTrie not initialized")},xp=function(n,e){e||(e={lineBreak:"normal",wordBreak:"normal"});var t=Tp(n,e.lineBreak),i=t[0],r=t[1],s=t[2];(e.wordBreak==="break-all"||e.wordBreak==="break-word")&&(r=r.map(function(o){return[mp,gp,bp].indexOf(o)!==-1?vp:o}));var a=e.wordBreak==="keep-all"?s.map(function(o,c){return o&&n[c]>=19968&&n[c]<=40959}):void 0;return[i,r,a]},wp=function(){function n(e,t,i,r){this.codePoints=e,this.required=t===tc,this.start=i,this.end=r}return n.prototype.slice=function(){return me.apply(void 0,this.codePoints.slice(this.start,this.end))},n}(),_p=function(n,e){var t=Ai(n),i=xp(t,e),r=i[0],s=i[1],a=i[2],o=t.length,c=0,l=0;return{next:function(){if(l>=o)return{done:!0,value:null};for(var u=Mt;l<o&&(u=Cp(t,s,r,++l,a))===Mt;);if(u!==Mt||l===o){var d=new wp(t,u,c,l);return c=l,{value:d,done:!1}}return{done:!0,value:null}}}},Ep=1,Pp=2,Zn=4,ic=8,Di=10,rc=47,ei=92,Rp=9,Ip=32,Ui=34,ti=61,Op=35,Ap=36,Np=37,Bi=39,Fi=40,ni=41,Mp=95,Ue=45,Lp=33,Dp=60,Up=62,Bp=64,Fp=91,jp=93,Vp=61,Gp=123,ji=63,Wp=125,sc=124,zp=126,Hp=128,ac=65533,_s=42,sn=43,qp=44,Kp=58,$p=59,ii=46,Yp=0,Xp=8,Jp=11,Qp=14,Zp=31,em=127,pt=-1,oc=48,cc=97,lc=101,tm=102,nm=117,im=122,uc=65,dc=69,hc=70,rm=85,sm=90,Ae=function(n){return n>=oc&&n<=57},am=function(n){return n>=55296&&n<=57343},Cn=function(n){return Ae(n)||n>=uc&&n<=hc||n>=cc&&n<=tm},om=function(n){return n>=cc&&n<=im},cm=function(n){return n>=uc&&n<=sm},lm=function(n){return om(n)||cm(n)},um=function(n){return n>=Hp},Vi=function(n){return n===Di||n===Rp||n===Ip},Gi=function(n){return lm(n)||um(n)||n===Mp},fc=function(n){return Gi(n)||Ae(n)||n===Ue},dm=function(n){return n>=Yp&&n<=Xp||n===Jp||n>=Qp&&n<=Zp||n===em},Lt=function(n,e){return n!==ei?!1:e!==Di},Wi=function(n,e,t){return n===Ue?Gi(e)||Lt(e,t):Gi(n)?!0:!!(n===ei&&Lt(n,e))},Es=function(n,e,t){return n===sn||n===Ue?Ae(e)?!0:e===ii&&Ae(t):Ae(n===ii?e:n)},hm=function(n){var e=0,t=1;(n[e]===sn||n[e]===Ue)&&(n[e]===Ue&&(t=-1),e++);for(var i=[];Ae(n[e]);)i.push(n[e++]);var r=i.length?parseInt(me.apply(void 0,i),10):0;n[e]===ii&&e++;for(var s=[];Ae(n[e]);)s.push(n[e++]);var a=s.length,o=a?parseInt(me.apply(void 0,s),10):0;(n[e]===dc||n[e]===lc)&&e++;var c=1;(n[e]===sn||n[e]===Ue)&&(n[e]===Ue&&(c=-1),e++);for(var l=[];Ae(n[e]);)l.push(n[e++]);var u=l.length?parseInt(me.apply(void 0,l),10):0;return t*(r+o*Math.pow(10,-a))*Math.pow(10,c*u)},fm={type:2},pm={type:3},mm={type:4},gm={type:13},vm={type:8},bm={type:21},ym={type:9},km={type:10},Tm={type:11},Sm={type:12},Cm={type:14},zi={type:23},xm={type:1},wm={type:25},_m={type:24},Em={type:26},Pm={type:27},Rm={type:28},Im={type:29},Om={type:31},Ps={type:32},pc=function(){function n(){this._value=[]}return n.prototype.write=function(e){this._value=this._value.concat(Ai(e))},n.prototype.read=function(){for(var e=[],t=this.consumeToken();t!==Ps;)e.push(t),t=this.consumeToken();return e},n.prototype.consumeToken=function(){var e=this.consumeCodePoint();switch(e){case Ui:return this.consumeStringToken(Ui);case Op:var t=this.peekCodePoint(0),i=this.peekCodePoint(1),r=this.peekCodePoint(2);if(fc(t)||Lt(i,r)){var s=Wi(t,i,r)?Pp:Ep,a=this.consumeName();return{type:5,value:a,flags:s}}break;case Ap:if(this.peekCodePoint(0)===ti)return this.consumeCodePoint(),gm;break;case Bi:return this.consumeStringToken(Bi);case Fi:return fm;case ni:return pm;case _s:if(this.peekCodePoint(0)===ti)return this.consumeCodePoint(),Cm;break;case sn:if(Es(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case qp:return mm;case Ue:var o=e,c=this.peekCodePoint(0),l=this.peekCodePoint(1);if(Es(o,c,l))return this.reconsumeCodePoint(e),this.consumeNumericToken();if(Wi(o,c,l))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();if(c===Ue&&l===Up)return this.consumeCodePoint(),this.consumeCodePoint(),_m;break;case ii:if(Es(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case rc:if(this.peekCodePoint(0)===_s)for(this.consumeCodePoint();;){var u=this.consumeCodePoint();if(u===_s&&(u=this.consumeCodePoint(),u===rc))return this.consumeToken();if(u===pt)return this.consumeToken()}break;case Kp:return Em;case $p:return Pm;case Dp:if(this.peekCodePoint(0)===Lp&&this.peekCodePoint(1)===Ue&&this.peekCodePoint(2)===Ue)return this.consumeCodePoint(),this.consumeCodePoint(),wm;break;case Bp:var d=this.peekCodePoint(0),h=this.peekCodePoint(1),f=this.peekCodePoint(2);if(Wi(d,h,f)){var a=this.consumeName();return{type:7,value:a}}break;case Fp:return Rm;case ei:if(Lt(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();break;case jp:return Im;case Vp:if(this.peekCodePoint(0)===ti)return this.consumeCodePoint(),vm;break;case Gp:return Tm;case Wp:return Sm;case nm:case rm:var p=this.peekCodePoint(0),g=this.peekCodePoint(1);return p===sn&&(Cn(g)||g===ji)&&(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(e),this.consumeIdentLikeToken();case sc:if(this.peekCodePoint(0)===ti)return this.consumeCodePoint(),ym;if(this.peekCodePoint(0)===sc)return this.consumeCodePoint(),bm;break;case zp:if(this.peekCodePoint(0)===ti)return this.consumeCodePoint(),km;break;case pt:return Ps}return Vi(e)?(this.consumeWhiteSpace(),Om):Ae(e)?(this.reconsumeCodePoint(e),this.consumeNumericToken()):Gi(e)?(this.reconsumeCodePoint(e),this.consumeIdentLikeToken()):{type:6,value:me(e)}},n.prototype.consumeCodePoint=function(){var e=this._value.shift();return typeof e>"u"?-1:e},n.prototype.reconsumeCodePoint=function(e){this._value.unshift(e)},n.prototype.peekCodePoint=function(e){return e>=this._value.length?-1:this._value[e]},n.prototype.consumeUnicodeRangeToken=function(){for(var e=[],t=this.consumeCodePoint();Cn(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();for(var i=!1;t===ji&&e.length<6;)e.push(t),t=this.consumeCodePoint(),i=!0;if(i){var r=parseInt(me.apply(void 0,e.map(function(c){return c===ji?oc:c})),16),s=parseInt(me.apply(void 0,e.map(function(c){return c===ji?hc:c})),16);return{type:30,start:r,end:s}}var a=parseInt(me.apply(void 0,e),16);if(this.peekCodePoint(0)===Ue&&Cn(this.peekCodePoint(1))){this.consumeCodePoint(),t=this.consumeCodePoint();for(var o=[];Cn(t)&&o.length<6;)o.push(t),t=this.consumeCodePoint();var s=parseInt(me.apply(void 0,o),16);return{type:30,start:a,end:s}}else return{type:30,start:a,end:a}},n.prototype.consumeIdentLikeToken=function(){var e=this.consumeName();return e.toLowerCase()==="url"&&this.peekCodePoint(0)===Fi?(this.consumeCodePoint(),this.consumeUrlToken()):this.peekCodePoint(0)===Fi?(this.consumeCodePoint(),{type:19,value:e}):{type:20,value:e}},n.prototype.consumeUrlToken=function(){var e=[];if(this.consumeWhiteSpace(),this.peekCodePoint(0)===pt)return{type:22,value:""};var t=this.peekCodePoint(0);if(t===Bi||t===Ui){var i=this.consumeStringToken(this.consumeCodePoint());return i.type===0&&(this.consumeWhiteSpace(),this.peekCodePoint(0)===pt||this.peekCodePoint(0)===ni)?(this.consumeCodePoint(),{type:22,value:i.value}):(this.consumeBadUrlRemnants(),zi)}for(;;){var r=this.consumeCodePoint();if(r===pt||r===ni)return{type:22,value:me.apply(void 0,e)};if(Vi(r))return this.consumeWhiteSpace(),this.peekCodePoint(0)===pt||this.peekCodePoint(0)===ni?(this.consumeCodePoint(),{type:22,value:me.apply(void 0,e)}):(this.consumeBadUrlRemnants(),zi);if(r===Ui||r===Bi||r===Fi||dm(r))return this.consumeBadUrlRemnants(),zi;if(r===ei)if(Lt(r,this.peekCodePoint(0)))e.push(this.consumeEscapedCodePoint());else return this.consumeBadUrlRemnants(),zi;else e.push(r)}},n.prototype.consumeWhiteSpace=function(){for(;Vi(this.peekCodePoint(0));)this.consumeCodePoint()},n.prototype.consumeBadUrlRemnants=function(){for(;;){var e=this.consumeCodePoint();if(e===ni||e===pt)return;Lt(e,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}},n.prototype.consumeStringSlice=function(e){for(var t=5e4,i="";e>0;){var r=Math.min(t,e);i+=me.apply(void 0,this._value.splice(0,r)),e-=r}return this._value.shift(),i},n.prototype.consumeStringToken=function(e){var t="",i=0;do{var r=this._value[i];if(r===pt||r===void 0||r===e)return t+=this.consumeStringSlice(i),{type:0,value:t};if(r===Di)return this._value.splice(0,i),xm;if(r===ei){var s=this._value[i+1];s!==pt&&s!==void 0&&(s===Di?(t+=this.consumeStringSlice(i),i=-1,this._value.shift()):Lt(r,s)&&(t+=this.consumeStringSlice(i),t+=me(this.consumeEscapedCodePoint()),i=-1))}i++}while(!0)},n.prototype.consumeNumber=function(){var e=[],t=Zn,i=this.peekCodePoint(0);for((i===sn||i===Ue)&&e.push(this.consumeCodePoint());Ae(this.peekCodePoint(0));)e.push(this.consumeCodePoint());i=this.peekCodePoint(0);var r=this.peekCodePoint(1);if(i===ii&&Ae(r))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=ic;Ae(this.peekCodePoint(0));)e.push(this.consumeCodePoint());i=this.peekCodePoint(0),r=this.peekCodePoint(1);var s=this.peekCodePoint(2);if((i===dc||i===lc)&&((r===sn||r===Ue)&&Ae(s)||Ae(r)))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=ic;Ae(this.peekCodePoint(0));)e.push(this.consumeCodePoint());return[hm(e),t]},n.prototype.consumeNumericToken=function(){var e=this.consumeNumber(),t=e[0],i=e[1],r=this.peekCodePoint(0),s=this.peekCodePoint(1),a=this.peekCodePoint(2);if(Wi(r,s,a)){var o=this.consumeName();return{type:15,number:t,flags:i,unit:o}}return r===Np?(this.consumeCodePoint(),{type:16,number:t,flags:i}):{type:17,number:t,flags:i}},n.prototype.consumeEscapedCodePoint=function(){var e=this.consumeCodePoint();if(Cn(e)){for(var t=me(e);Cn(this.peekCodePoint(0))&&t.length<6;)t+=me(this.consumeCodePoint());Vi(this.peekCodePoint(0))&&this.consumeCodePoint();var i=parseInt(t,16);return i===0||am(i)||i>1114111?ac:i}return e===pt?ac:e},n.prototype.consumeName=function(){for(var e="";;){var t=this.consumeCodePoint();if(fc(t))e+=me(t);else if(Lt(t,this.peekCodePoint(0)))e+=me(this.consumeEscapedCodePoint());else return this.reconsumeCodePoint(t),e}},n}(),mc=function(){function n(e){this._tokens=e}return n.create=function(e){var t=new pc;return t.write(e),new n(t.read())},n.parseValue=function(e){return n.create(e).parseComponentValue()},n.parseValues=function(e){return n.create(e).parseComponentValues()},n.prototype.parseComponentValue=function(){for(var e=this.consumeToken();e.type===31;)e=this.consumeToken();if(e.type===32)throw new SyntaxError("Error parsing CSS component value, unexpected EOF");this.reconsumeToken(e);var t=this.consumeComponentValue();do e=this.consumeToken();while(e.type===31);if(e.type===32)return t;throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one")},n.prototype.parseComponentValues=function(){for(var e=[];;){var t=this.consumeComponentValue();if(t.type===32)return e;e.push(t),e.push()}},n.prototype.consumeComponentValue=function(){var e=this.consumeToken();switch(e.type){case 11:case 28:case 2:return this.consumeSimpleBlock(e.type);case 19:return this.consumeFunction(e)}return e},n.prototype.consumeSimpleBlock=function(e){for(var t={type:e,values:[]},i=this.consumeToken();;){if(i.type===32||Nm(i,e))return t;this.reconsumeToken(i),t.values.push(this.consumeComponentValue()),i=this.consumeToken()}},n.prototype.consumeFunction=function(e){for(var t={name:e.value,values:[],type:18};;){var i=this.consumeToken();if(i.type===32||i.type===3)return t;this.reconsumeToken(i),t.values.push(this.consumeComponentValue())}},n.prototype.consumeToken=function(){var e=this._tokens.shift();return typeof e>"u"?Ps:e},n.prototype.reconsumeToken=function(e){this._tokens.unshift(e)},n}(),Dt=function(n){return n.type===15},ye=function(n){return n.type===17},H=function(n){return n.type===20},Am=function(n){return n.type===0},Rs=function(n,e){return H(n)&&n.value===e},gc=function(n){return n.type!==31},Ee=function(n){return n.type!==31&&n.type!==4},mt=function(n){var e=[],t=[];return n.forEach(function(i){if(i.type===4){if(t.length===0)throw new Error("Error parsing function args, zero tokens for arg");e.push(t),t=[];return}i.type!==31&&t.push(i)}),t.length&&e.push(t),e},Nm=function(n,e){return e===11&&n.type===12||e===28&&n.type===29?!0:e===2&&n.type===3},Ut=function(n){return n.type===17||n.type===15},ae=function(n){return n.type===16||Ut(n)},vc=function(n){return n.length>1?[n[0],n[1]]:[n[0]]},Pe={type:17,number:0,flags:Zn},Is={type:16,number:50,flags:Zn},Bt={type:16,number:100,flags:Zn},ri=function(n,e,t){var i=n[0],r=n[1];return[te(i,e),te(typeof r<"u"?r:i,t)]},te=function(n,e){if(n.type===16)return n.number/100*e;if(Dt(n))switch(n.unit){case"rem":case"em":return 16*n.number;case"px":default:return n.number}return n.number},bc="deg",yc="grad",kc="rad",Tc="turn",Hi={name:"angle",parse:function(n,e){if(e.type===15)switch(e.unit){case bc:return Math.PI*e.number/180;case yc:return Math.PI/200*e.number;case kc:return e.number;case Tc:return Math.PI*2*e.number}throw new Error("Unsupported angle type")}},Sc=function(n){return n.type===15&&(n.unit===bc||n.unit===yc||n.unit===kc||n.unit===Tc)},Cc=function(n){var e=n.filter(H).map(function(t){return t.value}).join(" ");switch(e){case"to bottom right":case"to right bottom":case"left top":case"top left":return[Pe,Pe];case"to top":case"bottom":return Ye(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[Pe,Bt];case"to right":case"left":return Ye(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[Bt,Bt];case"to bottom":case"top":return Ye(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[Bt,Pe];case"to left":case"right":return Ye(270)}return 0},Ye=function(n){return Math.PI*n/180},Ft=function(n){return(255&n)===0},xe=function(n){var e=255&n,t=255&n>>8,i=255&n>>16,r=255&n>>24;return e<255?"rgba(".concat(r,",").concat(i,",").concat(t,",").concat(e/255,")"):"rgb(".concat(r,",").concat(i,",").concat(t,")")},gt=function(n,e,t,i){return(n<<24|e<<16|t<<8|Math.round(i*255)<<0)>>>0},qi=function(n,e){if(n.type===17)return n.number;if(n.type===16){var t=e===3?1:255;return e===3?n.number/100*t:Math.round(n.number/100*t)}return 0},an=function(n){return(n[0].type===20?n[0].value:"unknown")==="from"},de=function(n,e,t){return Math.min(Math.max(n,e),t)},Be=function(n,e){return[n[0]*e[0]+n[1]*e[1]+n[2]*e[2],n[3]*e[0]+n[4]*e[1]+n[5]*e[2],n[6]*e[0]+n[7]*e[1]+n[8]*e[2]]},Mm=function(n){return gt(de(Math.round(n[0]*255),0,255),de(Math.round(n[1]*255),0,255),de(Math.round(n[2]*255),0,255),de(n[3],0,1))},Os=function(n){var e=n[0],t=n[1],i=n[2],r=n[3],s=on([e,t,i]);return gt(de(Math.round(s[0]*255),0,255),de(Math.round(s[1]*255),0,255),de(Math.round(s[2]*255),0,255),r)},si=function(n){var e=jt([n[0],n[1],n[2]]);return Os([e[0],e[1],e[2],n[3]])},Lm=function(n,e){if(an(e.filter(Ee)))throw new Error("Relative color not supported for lab()");var t=Ki(e),i=t[0],r=t[1],s=t[2],a=t[3],o=on(jt(Xi([i,r,s])));return gt(de(Math.round(o[0]*255),0,255),de(Math.round(o[1]*255),0,255),de(Math.round(o[2]*255),0,255),a)},Dm=function(n,e){if(an(e.filter(Ee)))throw new Error("Relative color not supported for oklab()");var t=Ki(e),i=t[0],r=t[1],s=t[2],a=t[3],o=on(jt(Yi([i,r,s])));return gt(de(Math.round(o[0]*255),0,255),de(Math.round(o[1]*255),0,255),de(Math.round(o[2]*255),0,255),a)},Um=function(n,e){if(an(e.filter(Ee)))throw new Error("Relative color not supported for oklch()");var t=Ec(e),i=t[0],r=t[1],s=t[2],a=t[3],o=on(jt(Yi($i([i,r,s]))));return gt(de(Math.round(o[0]*255),0,255),de(Math.round(o[1]*255),0,255),de(Math.round(o[2]*255),0,255),a)},Bm=function(n,e){if(an(e.filter(Ee)))throw new Error("Relative color not supported for lch()");var t=_c(e),i=t[0],r=t[1],s=t[2],a=t[3],o=on(jt(Xi($i([i,r,s]))));return gt(de(Math.round(o[0]*255),0,255),de(Math.round(o[1]*255),0,255),de(Math.round(o[2]*255),0,255),a)},xc=function(n,e){var t=e.filter(Ee),i=t[0],r=t[1],s=t[2],a=t[3],o=(i.type===17?Ye(i.number):Hi.parse(n,i))/(Math.PI*2),c=ae(r)?r.number/100:0,l=ae(s)?s.number/100:0,u=typeof a<"u"&&ae(a)?te(a,1):1;return[o,c,l,u]},wc=function(n,e){if(an(e))throw new Error("Relative color not supported for hsl()");var t=xc(n,e),i=t[0],r=t[1],s=t[2],a=t[3],o=Rc([i,r,s]);return gt(o[0]*255,o[1]*255,o[2]*255,r===0?1:a)},_c=function(n){var e=n.filter(Ee),t=ae(e[0])?e[0].number:0,i=ae(e[1])?e[1].number:0,r=ye(e[2])||Dt(e[2])?e[2].number:0,s=typeof e[4]<"u"&&ae(e[4])?te(e[4],1):1;return[t,i,r,s]},Ki=function(n){var e=n.filter(Ee),t=e[0].type===16?e[0].number/100:ye(e[0])?e[0].number:0,i=e[1].type===16?e[1].number/100:ye(e[1])?e[1].number:0,r=ye(e[2])||Dt(e[2])?e[2].number:0,s=typeof e[4]<"u"&&ae(e[4])?te(e[4],1):1;return[t,i,r,s]},Ec=function(n){var e=n.filter(Ee),t=e[0].type===16?e[0].number/100:ye(e[0])?e[0].number:0,i=e[1].type===16?e[1].number/100:ye(e[1])?e[1].number:0,r=ye(e[2])||Dt(e[2])?e[2].number:0,s=typeof e[4]<"u"&&ae(e[4])?te(e[4],1):1;return[t,i,r,s]},Pc=function(n){return Be([1.0479297925449969,.022946870601609652,-.05019226628920524,.02962780877005599,.9904344267538799,-.017073799063418826,-.009243040646204504,.015055191490298152,.7518742814281371],n)},As=function(n){return Be([.955473421488075,-.02309845494876471,.06325924320057072,-.0283697093338637,1.0099953980813041,.021041441191917323,.012314014864481998,-.020507649298898964,1.330365926242124],n)},Ns=function(n,e,t){return t<0&&(t+=1),t>=1&&(t-=1),t<1/6?(e-n)*t*6+n:t<1/2?e:t<2/3?(e-n)*6*(2/3-t)+n:n},Rc=function(n){var e=n[0],t=n[1],i=n[2];if(t===0)return[i*255,i*255,i*255];var r=i<=.5?i*(t+1):i+t-i*t,s=i*2-r,a=Ns(s,r,e+1/3),o=Ns(s,r,e),c=Ns(s,r,e-1/3);return[a,o,c]},$i=function(n){var e=n[0],t=n[1],i=n[2];return t<0&&(t=0),isNaN(i)&&(i=0),[e,t*Math.cos(i*Math.PI/180),t*Math.sin(i*Math.PI/180)]},Yi=function(n){var e=Be([1,.3963377773761749,.2158037573099136,1,-.1055613458156586,-.0638541728258133,1,-.0894841775298119,-1.2914855480194092],n),t=e.map(function(i){return Math.pow(i,3)});return Be([1.2268798758459243,-.5578149944602171,.2813910456659647,-.0405757452148008,1.112286803280317,-.0717110580655164,-.0763729366746601,-.4214933324022432,1.5869240198367816],t)},Xi=function(n){var e=(n[0]+16)/116,t=n[1]/500+e,i=e-n[2]/200,r=24389/27,s=24/116,a=[(t>s?Math.pow(t,3):(116*t-16)/r)*.3457/.3585,n[0]>8?Math.pow(e,3):n[0]/r,(i>s?Math.pow(i,3):(116*i-16)/r)*(1-.3457-.3585)/.3585];return As([a[0],a[1],a[2]])},Fm=function(n,e){var t=e.filter(Ee);if(t.length===3){var i=t.map(qi),r=i[0],s=i[1],a=i[2],o=Ls([r/255,s/255,a/255]),c=Ms([o[0],o[1],o[2]]),l=c[0],u=c[1],d=c[2];return[l,u,d,1]}if(t.length===4){var h=t.map(qi),r=h[0],s=h[1],a=h[2],f=h[3],o=Ls([r/255,s/255,a/255]),p=Ms([o[0],o[1],o[2]]),l=p[0],u=p[1],d=p[2];return[l,u,d,f]}return[0,0,0,1]},jm=function(n,e){var t=xc(n,e),i=t[0],r=t[1],s=t[2],a=t[3],o=Ls(Rc([i,r,s])),c=Ms([o[0],o[1],o[2]]),l=c[0],u=c[1],d=c[2];return[l,u,d,a]},Vm=function(n,e){var t=Ki(e),i=t[0],r=t[1],s=t[2],a=t[3],o=Xi([i,r,s]),c=o[0],l=o[1],u=o[2];return[c,l,u,a]},Gm=function(n,e){var t=_c(e),i=t[0],r=t[1],s=t[2],a=t[3],o=Xi($i([i,r,s])),c=o[0],l=o[1],u=o[2];return[c,l,u,a]},Wm=function(n,e){var t=Ec(e),i=t[0],r=t[1],s=t[2],a=t[3],o=Yi($i([i,r,s])),c=o[0],l=o[1],u=o[2];return[c,l,u,a]},zm=function(n,e){var t=Ki(e),i=t[0],r=t[1],s=t[2],a=t[3],o=Yi([i,r,s]),c=o[0],l=o[1],u=o[2];return[c,l,u,a]},Hm=function(n){return As([n[0],n[1],n[2]])},Ic=function(n){return n},qm=function(n){var e=Pc([n[0],n[2],n[3]]),t=e[0],i=e[1],r=e[2];return[t,i,r,n[3]]},Oc=function(n){return si([n[0],n[1],n[2],n[3]])},Km=function(n){var e=Hm([n[0],n[1],n[2]]);return si([e[0],e[1],e[2],n[3]])},jt=function(n){return Be([3.2409699419045226,-1.537383177570094,-.4986107602930034,-.9692436362808796,1.8759675015077202,.04155505740717559,.05563007969699366,-.20397695888897652,1.0569715142428786],n)},Ms=function(n){return Be([.41239079926595934,.357584339383878,.1804807884018343,.21263900587151027,.715168678767756,.07219231536073371,.01933081871559182,.11919477979462598,.9505321522496607],n)},on=function(n){return n.map(function(e){var t=e<0?-1:1,i=Math.abs(e);return i>.0031308?t*(1.055*Math.pow(i,1/2.4)-.055):12.92*e})},Ls=function(n){return n.map(function(e){var t=e<0?-1:1,i=Math.abs(e);return i<=.04045?e/12.92:t*Math.pow((i+.055)/1.055,2.4)})},$m=function(n){var e=on(jt([n[0],n[1],n[2]])),t=e[0],i=e[1],r=e[2];return[t,i,r,n[3]]},Ym=function(n){var e=jt([n[0],n[1],n[2]]),t=e[0],i=e[1],r=e[2];return[de(Math.round(t*255),0,255),de(Math.round(i*255),0,255),de(Math.round(r*255),0,255),n[3]]},Xm=function(n){return Be([.4865709486482162,.26566769316909306,.1982172852343625,.2289745640697488,.6917385218365064,.079286914093745,0,.04511338185890264,1.043944368900976],n)},Jm=function(n){return Be([2.493496911941425,-.9313836179191239,-.40271078445071684,-.8294889695615747,1.7626640603183463,.023624685841943577,.03584583024378447,-.07617238926804182,.9568845240076872],n)},Qm=function(n){return n.map(function(e){var t=e<0?-1:1,i=e*t;return i<=.04045?e/12.92:t*Math.pow((e+.055)/1.055,2.4)||0})},Zm=function(n){return on(n)},eg=function(n){var e=Qm([n[0],n[1],n[2]]);return Xm([e[0],e[1],e[2]])},tg=function(n){var e=Zm(Jm([n[0],n[1],n[2]])),t=e[0],i=e[1],r=e[2];return[t,i,r,n[3]]},ng=function(n){var e=eg([n[0],n[1],n[2]]);return si([e[0],e[1],e[2],n[3]])},ig=function(n){return Be([2.0415879038107465,-.5650069742788596,-.34473135077832956,-.9692436362808795,1.8759675015077202,.04155505740717557,.013444280632031142,-.11836239223101838,1.0151749943912054],n)},rg=function(n){return Be([.5766690429101305,.1855582379065463,.1882286462349947,.29734497525053605,.6273635662554661,.0752914584939978,.02703136138641234,.07068885253582723,.9913375368376388],n)},sg=function(n){var e=n.map(function(t){var i=t<0?-1:1,r=Math.abs(t);return i*Math.pow(r,2.19921875)});return[e[0],e[1],e[2]]},ag=function(n){var e=n.map(function(t){var i=t<0?-1:1,r=Math.abs(t);return i*Math.pow(r,.4547069271758437)});return[e[0],e[1],e[2]]},og=function(n){var e=ag(ig([n[0],n[1],n[2]])),t=e[0],i=e[1],r=e[2];return[t,i,r,n[3]]},cg=function(n){var e=jt(rg(sg([n[0],n[1],n[2]])));return Os([e[0],e[1],e[2],n[3]])},lg=function(n){return Be([.7977666449006423,.13518129740053308,.0313477341283922,.2880748288194013,.711835234241873,8993693872564e-17,0,0,.8251046025104602],n)},ug=function(n){return Be([1.3457868816471583,-.25557208737979464,-.05110186497554526,-.5446307051249019,1.5082477428451468,.02052744743642139,0,0,1.2119675456389452],n)},dg=function(n){return n.map(function(e){return e<16/512?e/16:Math.pow(e,1.8)})},hg=function(n){return n.map(function(e){return e>1/512?Math.pow(e,1/1.8):e*16})},fg=function(n){var e=dg([n[0],n[1],n[2]]);return As(lg([e[0],e[1],e[2]]))},pg=function(n){var e=hg(ug(Pc([n[0],n[1],n[2]]))),t=e[0],i=e[1],r=e[2];return[t,i,r,n[3]]},mg=function(n){var e=fg([n[0],n[1],n[2]]);return si([e[0],e[1],e[2],n[3]])},Ji=1.09929682680944,Ac=.018053968510807,gg=function(n){return n.map(function(e){return e<Ac*4.5?e/4.5:Math.pow((e+Ji-1)/Ji,1/.45)})},vg=function(n){return n.map(function(e){return e>=Ac?Ji*Math.pow(e,.45)-(Ji-1):4.5*e})},bg=function(n){return Be([.6369580483012914,.14461690358620832,.1688809751641721,.2627002120112671,.6779980715188708,.05930171646986196,0,.028072693049087428,1.060985057710791],n)},yg=function(n){return Be([1.716651187971268,-.355670783776392,-.25336628137366,-.666684351832489,1.616481236634939,.0157685458139111,.017639857445311,-.042770613257809,.942103121235474],n)},kg=function(n){var e=gg([n[0],n[1],n[2]]);return bg([e[0],e[1],e[2]])},Tg=function(n){var e=vg(yg([n[0],n[1],n[2]])),t=e[0],i=e[1],r=e[2];return[t,i,r,n[3]]},Sg=function(n){var e=kg([n[0],n[1],n[2]]);return si([e[0],e[1],e[2],n[3]])},Vt={name:"color",parse:function(n,e){if(e.type===18){var t=_g[e.name];if(typeof t>"u")throw new Error('Attempting to parse an unsupported color function "'.concat(e.name,'"'));return t(n,e.values)}if(e.type===5){var i=Nc(e),r=i[0],s=i[1],a=i[2],o=i[3];return gt(r,s,a,o)}if(e.type===20){var c=vt[e.value.toUpperCase()];if(typeof c<"u")return c}return vt.TRANSPARENT}},Nc=function(n){if(n.value.length===3){var e=n.value.substring(0,1),t=n.value.substring(1,2),i=n.value.substring(2,3);return[parseInt(e+e,16),parseInt(t+t,16),parseInt(i+i,16),1]}if(n.value.length===4){var e=n.value.substring(0,1),t=n.value.substring(1,2),i=n.value.substring(2,3),r=n.value.substring(3,4);return[parseInt(e+e,16),parseInt(t+t,16),parseInt(i+i,16),parseInt(r+r,16)/255]}if(n.value.length===6){var e=n.value.substring(0,2),t=n.value.substring(2,4),i=n.value.substring(4,6);return[parseInt(e,16),parseInt(t,16),parseInt(i,16),1]}if(n.value.length===8){var e=n.value.substring(0,2),t=n.value.substring(2,4),i=n.value.substring(4,6),r=n.value.substring(6,8);return[parseInt(e,16),parseInt(t,16),parseInt(i,16),parseInt(r,16)/255]}return[0,0,0,1]},Mc=function(n,e){var t=e.filter(Ee);if(an(t))throw new Error("Relative color not supported for rgb()");if(t.length===3){var i=t.map(qi),r=i[0],s=i[1],a=i[2];return gt(r,s,a,1)}if(t.length===4){var o=t.map(qi),r=o[0],s=o[1],a=o[2],c=o[3];return gt(r,s,a,c)}return 0},Cg=function(n,e){var t=e.filter(Ee),i=t[0].type===20?t[0].value:"unknown",r=!an(t);if(r){var s=i,a=Lc[s];if(typeof a>"u")throw new Error('Attempting to parse an unsupported color space "'.concat(s,'" for color() function'));var o=ye(t[1])?t[1].number:0,c=ye(t[2])?t[2].number:0,l=ye(t[3])?t[3].number:0,u=t.length>4&&t[4].type===6&&t[4].value==="/"&&ye(t[5])?t[5].number:1;return a([o,c,l,u])}else{var d=function(A,j){if(ye(j))return j.number;var K=function(_e){return _e==="r"||_e==="x"?0:_e==="g"||_e==="y"?1:2};if(H(j)){var Q=K(j.value);return A[Q]}var se=function(_e){for(var et=_e.filter(Ee),qe="(",Te=0,Nt=et;Te<Nt.length;Te++){var Ke=Nt[Te];qe+=Ke.type===18&&Ke.name==="calc"?se(Ke.values):ye(Ke)?Ke.number:Ke.type===6||H(Ke)?Ke.value:""}return qe+=")",qe};if(j.type===18){var Me=j.values.filter(Ee);if(j.name==="calc"){var Le=se(Me).replace(/r|x/,A[0].toString()).replace(/g|y/,A[1].toString()).replace(/b|z/,A[2].toString());return new Function("return "+Le)()}}return null},h=t[1].type===18?t[1].name:H(t[1])||t[1].type===5?"rgb":"unknown",f=H(t[2])?t[2].value:"unknown",p=t[1].type===18?t[1].values:H(t[1])?[t[1]]:[];if(H(t[1])){var g=vt[t[1].value.toUpperCase()];if(typeof g>"u")throw new Error("Attempting to use unknown color in relative color 'from'");var v=xn(n,t[1].value),b=255&v,S=255&v>>8,x=255&v>>16,k=255&v>>24;p=[{type:17,number:k,flags:1},{type:17,number:x,flags:1},{type:17,number:S,flags:1},{type:17,number:b>1?b/255:b,flags:1}]}else if(t[1].type===5){var T=Nc(t[1]),k=T[0],x=T[1],S=T[2],b=T[3];p=[{type:17,number:k,flags:1},{type:17,number:x,flags:1},{type:17,number:S,flags:1},{type:17,number:b>1?b/255:b,flags:1}]}if(p.length===0)throw new Error("Attempting to use unknown color in relative color 'from'");if(f==="unknown")throw new Error("Attempting to use unknown colorspace in relative color 'to'");var C=xg[h],_=wg[f],R=Lc[f];if(typeof C>"u")throw new Error('Attempting to parse an unsupported color space "'.concat(h,'" for color() function'));if(typeof _>"u")throw new Error('Attempting to parse an unsupported color space "'.concat(f,'" for color() function'));var I=C(n,p),D=_(I),o=d(D,t[3]),c=d(D,t[4]),l=d(D,t[5]),u=t.length>6&&t[6].type===6&&t[6].value==="/"&&ye(t[7])?t[7].number:1;if(o===null||c===null||l===null)throw new Error("Invalid relative color in color() function");return R([o,c,l,u])}},Lc={srgb:Mm,"srgb-linear":Os,"display-p3":ng,"a98-rgb":cg,"prophoto-rgb":mg,xyz:Oc,"xyz-d50":Km,"xyz-d65":Oc,rec2020:Sg},xg={rgb:Fm,hsl:jm,lab:Vm,lch:Gm,oklab:zm,oklch:Wm},wg={srgb:$m,"srgb-linear":Ym,"display-p3":tg,"a98-rgb":og,"prophoto-rgb":pg,xyz:Ic,"xyz-d50":qm,"xyz-d65":Ic,rec2020:Tg},_g={hsl:wc,hsla:wc,rgb:Mc,rgba:Mc,lch:Bm,oklch:Um,oklab:Dm,lab:Lm,color:Cg},xn=function(n,e){return Vt.parse(n,mc.create(e).parseComponentValue())},vt={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},Eg={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:function(n,e){return e.map(function(t){if(H(t))switch(t.value){case"padding-box":return 1;case"content-box":return 2}return 0})}},Pg={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},Qi=function(n,e){var t=Vt.parse(n,e[0]),i=e[1];return i&&ae(i)?{color:t,stop:i}:{color:t,stop:null}},Dc=function(n,e){var t=n[0],i=n[n.length-1];t.stop===null&&(t.stop=Pe),i.stop===null&&(i.stop=Bt);for(var r=[],s=0,a=0;a<n.length;a++){var o=n[a].stop;if(o!==null){var c=te(o,e);c>s?r.push(c):r.push(s),s=c}else r.push(null)}for(var l=null,a=0;a<r.length;a++){var u=r[a];if(u===null)l===null&&(l=a);else if(l!==null){for(var d=a-l,h=r[l-1],f=(u-h)/(d+1),p=1;p<=d;p++)r[l+p-1]=f*p;l=null}}return n.map(function(g,v){var b=g.color;return{color:b,stop:Math.max(Math.min(1,r[v]/e),0)}})},Rg=function(n,e,t){var i=e/2,r=t/2,s=te(n[0],e)-i,a=r-te(n[1],t);return(Math.atan2(a,s)+Math.PI*2)%(Math.PI*2)},Ig=function(n,e,t){var i=typeof n=="number"?n:Rg(n,e,t),r=Math.abs(e*Math.sin(i))+Math.abs(t*Math.cos(i)),s=e/2,a=t/2,o=r/2,c=Math.sin(i-Math.PI/2)*o,l=Math.cos(i-Math.PI/2)*o;return[r,s-l,s+l,a-c,a+c]},nt=function(n,e){return Math.sqrt(n*n+e*e)},Uc=function(n,e,t,i,r){var s=[[0,0],[0,e],[n,0],[n,e]];return s.reduce(function(a,o){var c=o[0],l=o[1],u=nt(t-c,i-l);return(r?u<a.optimumDistance:u>a.optimumDistance)?{optimumCorner:o,optimumDistance:u}:a},{optimumDistance:r?1/0:-1/0,optimumCorner:null}).optimumCorner},Og=function(n,e,t,i,r){var s=0,a=0;switch(n.size){case 0:n.shape===0?s=a=Math.min(Math.abs(e),Math.abs(e-i),Math.abs(t),Math.abs(t-r)):n.shape===1&&(s=Math.min(Math.abs(e),Math.abs(e-i)),a=Math.min(Math.abs(t),Math.abs(t-r)));break;case 2:if(n.shape===0)s=a=Math.min(nt(e,t),nt(e,t-r),nt(e-i,t),nt(e-i,t-r));else if(n.shape===1){var o=Math.min(Math.abs(t),Math.abs(t-r))/Math.min(Math.abs(e),Math.abs(e-i)),c=Uc(i,r,e,t,!0),l=c[0],u=c[1];s=nt(l-e,(u-t)/o),a=o*s}break;case 1:n.shape===0?s=a=Math.max(Math.abs(e),Math.abs(e-i),Math.abs(t),Math.abs(t-r)):n.shape===1&&(s=Math.max(Math.abs(e),Math.abs(e-i)),a=Math.max(Math.abs(t),Math.abs(t-r)));break;case 3:if(n.shape===0)s=a=Math.max(nt(e,t),nt(e,t-r),nt(e-i,t),nt(e-i,t-r));else if(n.shape===1){var o=Math.max(Math.abs(t),Math.abs(t-r))/Math.max(Math.abs(e),Math.abs(e-i)),d=Uc(i,r,e,t,!1),l=d[0],u=d[1];s=nt(l-e,(u-t)/o),a=o*s}break}return Array.isArray(n.size)&&(s=te(n.size[0],i),a=n.size.length===2?te(n.size[1],r):s),[s,a]},Ag=function(n,e){var t=Ye(180),i=[];return mt(e).forEach(function(r,s){if(s===0){var a=r[0];if(a.type===20&&a.value==="to"){t=Cc(r);return}else if(Sc(a)){t=Hi.parse(n,a);return}}var o=Qi(n,r);i.push(o)}),{angle:t,stops:i,type:1}},Zi=function(n,e){var t=Ye(180),i=[];return mt(e).forEach(function(r,s){if(s===0){var a=r[0];if(a.type===20&&["top","left","right","bottom"].indexOf(a.value)!==-1){t=Cc(r);return}else if(Sc(a)){t=(Hi.parse(n,a)+Ye(270))%Ye(360);return}}var o=Qi(n,r);i.push(o)}),{angle:t,stops:i,type:1}},Ng=function(n,e){var t=Ye(180),i=[],r=1,s=0,a=3,o=[];return mt(e).forEach(function(c,l){var u=c[0];if(l===0){if(H(u)&&u.value==="linear"){r=1;return}else if(H(u)&&u.value==="radial"){r=2;return}}if(u.type===18){if(u.name==="from"){var d=Vt.parse(n,u.values[0]);i.push({stop:Pe,color:d})}else if(u.name==="to"){var d=Vt.parse(n,u.values[0]);i.push({stop:Bt,color:d})}else if(u.name==="color-stop"){var h=u.values.filter(Ee);if(h.length===2){var d=Vt.parse(n,h[1]),f=h[0];ye(f)&&i.push({stop:{type:16,number:f.number*100,flags:f.flags},color:d})}}}}),r===1?{angle:(t+Ye(180))%Ye(360),stops:i,type:r}:{size:a,shape:s,stops:i,position:o,type:r}},Bc="closest-side",Fc="farthest-side",jc="closest-corner",Vc="farthest-corner",Gc="circle",Wc="ellipse",zc="cover",Hc="contain",Mg=function(n,e){var t=0,i=3,r=[],s=[];return mt(e).forEach(function(a,o){var c=!0;if(o===0){var l=!1;c=a.reduce(function(d,h){if(l)if(H(h))switch(h.value){case"center":return s.push(Is),d;case"top":case"left":return s.push(Pe),d;case"right":case"bottom":return s.push(Bt),d}else(ae(h)||Ut(h))&&s.push(h);else if(H(h))switch(h.value){case Gc:return t=0,!1;case Wc:return t=1,!1;case"at":return l=!0,!1;case Bc:return i=0,!1;case zc:case Fc:return i=1,!1;case Hc:case jc:return i=2,!1;case Vc:return i=3,!1}else if(Ut(h)||ae(h))return Array.isArray(i)||(i=[]),i.push(h),!1;return d},c)}if(c){var u=Qi(n,a);r.push(u)}}),{size:i,shape:t,stops:r,position:s,type:2}},er=function(n,e){var t=0,i=3,r=[],s=[];return mt(e).forEach(function(a,o){var c=!0;if(o===0?c=a.reduce(function(u,d){if(H(d))switch(d.value){case"center":return s.push(Is),!1;case"top":case"left":return s.push(Pe),!1;case"right":case"bottom":return s.push(Bt),!1}else if(ae(d)||Ut(d))return s.push(d),!1;return u},c):o===1&&(c=a.reduce(function(u,d){if(H(d))switch(d.value){case Gc:return t=0,!1;case Wc:return t=1,!1;case Hc:case Bc:return i=0,!1;case Fc:return i=1,!1;case jc:return i=2,!1;case zc:case Vc:return i=3,!1}else if(Ut(d)||ae(d))return Array.isArray(i)||(i=[]),i.push(d),!1;return u},c)),c){var l=Qi(n,a);r.push(l)}}),{size:i,shape:t,stops:r,position:s,type:2}},Lg=function(n){return n.type===1},Dg=function(n){return n.type===2},Ds={name:"image",parse:function(n,e){if(e.type===22){var t={url:e.value,type:0};return n.cache.addImage(e.value),t}if(e.type===18){var i=qc[e.name];if(typeof i>"u")throw new Error('Attempting to parse an unsupported image function "'.concat(e.name,'"'));return i(n,e.values)}throw new Error("Unsupported image type ".concat(e.type))}};function Ug(n){return!(n.type===20&&n.value==="none")&&(n.type!==18||!!qc[n.name])}var qc={"linear-gradient":Ag,"-moz-linear-gradient":Zi,"-ms-linear-gradient":Zi,"-o-linear-gradient":Zi,"-webkit-linear-gradient":Zi,"radial-gradient":Mg,"-moz-radial-gradient":er,"-ms-radial-gradient":er,"-o-radial-gradient":er,"-webkit-radial-gradient":er,"-webkit-gradient":Ng},Bg={name:"background-image",initialValue:"none",type:1,prefix:!1,parse:function(n,e){if(e.length===0)return[];var t=e[0];return t.type===20&&t.value==="none"?[]:e.filter(function(i){return Ee(i)&&Ug(i)}).map(function(i){return Ds.parse(n,i)})}},Fg={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:function(n,e){return e.map(function(t){if(H(t))switch(t.value){case"padding-box":return 1;case"content-box":return 2}return 0})}},jg={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:function(n,e){return mt(e).map(function(t){return t.filter(ae)}).map(vc)}},Vg={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:function(n,e){return mt(e).map(function(t){return t.filter(H).map(function(i){return i.value}).join(" ")}).map(Gg)}},Gg=function(n){switch(n){case"no-repeat":return 1;case"repeat-x":case"repeat no-repeat":return 2;case"repeat-y":case"no-repeat repeat":return 3;case"repeat":default:return 0}},wn;(function(n){n.AUTO="auto",n.CONTAIN="contain",n.COVER="cover"})(wn||(wn={}));var Wg={name:"background-size",initialValue:"0",prefix:!1,type:1,parse:function(n,e){return mt(e).map(function(t){return t.filter(zg)})}},zg=function(n){return H(n)||ae(n)},tr=function(n){return{name:"border-".concat(n,"-color"),initialValue:"transparent",prefix:!1,type:3,format:"color"}},Hg=tr("top"),qg=tr("right"),Kg=tr("bottom"),$g=tr("left"),nr=function(n){return{name:"border-radius-".concat(n),initialValue:"0 0",prefix:!1,type:1,parse:function(e,t){return vc(t.filter(ae))}}},Yg=nr("top-left"),Xg=nr("top-right"),Jg=nr("bottom-right"),Qg=nr("bottom-left"),ir=function(n){return{name:"border-".concat(n,"-style"),initialValue:"solid",prefix:!1,type:2,parse:function(e,t){switch(t){case"none":return 0;case"dashed":return 2;case"dotted":return 3;case"double":return 4}return 1}}},Zg=ir("top"),e0=ir("right"),t0=ir("bottom"),n0=ir("left"),rr=function(n){return{name:"border-".concat(n,"-width"),initialValue:"0",type:0,prefix:!1,parse:function(e,t){return Dt(t)?t.number:0}}},i0=rr("top"),r0=rr("right"),s0=rr("bottom"),a0=rr("left"),o0={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},c0={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:function(n,e){switch(e){case"rtl":return 1;case"ltr":default:return 0}}},l0={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:function(n,e){return e.filter(H).reduce(function(t,i){return t|u0(i.value)},0)}},u0=function(n){switch(n){case"block":case"-webkit-box":return 2;case"inline":return 4;case"run-in":return 8;case"flow":return 16;case"flow-root":return 32;case"table":return 64;case"flex":case"-webkit-flex":return 128;case"grid":case"-ms-grid":return 256;case"ruby":return 512;case"subgrid":return 1024;case"list-item":return 2048;case"table-row-group":return 4096;case"table-header-group":return 8192;case"table-footer-group":return 16384;case"table-row":return 32768;case"table-cell":return 65536;case"table-column-group":return 131072;case"table-column":return 262144;case"table-caption":return 524288;case"ruby-base":return 1048576;case"ruby-text":return 2097152;case"ruby-base-container":return 4194304;case"ruby-text-container":return 8388608;case"contents":return 16777216;case"inline-block":return 33554432;case"inline-list-item":return 67108864;case"inline-table":return 134217728;case"inline-flex":return 268435456;case"inline-grid":return 536870912}return 0},d0={name:"float",initialValue:"none",prefix:!1,type:2,parse:function(n,e){switch(e){case"left":return 1;case"right":return 2;case"inline-start":return 3;case"inline-end":return 4}return 0}},h0={name:"letter-spacing",initialValue:"0",prefix:!1,type:0,parse:function(n,e){return e.type===20&&e.value==="normal"?0:e.type===17||e.type===15?e.number:0}},sr;(function(n){n.NORMAL="normal",n.STRICT="strict"})(sr||(sr={}));var f0={name:"line-break",initialValue:"normal",prefix:!1,type:2,parse:function(n,e){switch(e){case"strict":return sr.STRICT;case"normal":default:return sr.NORMAL}}},p0={name:"line-height",initialValue:"normal",prefix:!1,type:4},Kc=function(n,e){return H(n)&&n.value==="normal"?1.2*e:n.type===17?e*n.number:ae(n)?te(n,e):e},m0={name:"list-style-image",initialValue:"none",type:0,prefix:!1,parse:function(n,e){return e.type===20&&e.value==="none"?null:Ds.parse(n,e)}},g0={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:function(n,e){switch(e){case"inside":return 0;case"outside":default:return 1}}},Us={name:"list-style-type",initialValue:"none",prefix:!1,type:2,parse:function(n,e){switch(e){case"disc":return 0;case"circle":return 1;case"square":return 2;case"decimal":return 3;case"cjk-decimal":return 4;case"decimal-leading-zero":return 5;case"lower-roman":return 6;case"upper-roman":return 7;case"lower-greek":return 8;case"lower-alpha":return 9;case"upper-alpha":return 10;case"arabic-indic":return 11;case"armenian":return 12;case"bengali":return 13;case"cambodian":return 14;case"cjk-earthly-branch":return 15;case"cjk-heavenly-stem":return 16;case"cjk-ideographic":return 17;case"devanagari":return 18;case"ethiopic-numeric":return 19;case"georgian":return 20;case"gujarati":return 21;case"gurmukhi":return 22;case"hebrew":return 52;case"hiragana":return 23;case"hiragana-iroha":return 24;case"japanese-formal":return 25;case"japanese-informal":return 26;case"kannada":return 27;case"katakana":return 28;case"katakana-iroha":return 29;case"khmer":return 30;case"korean-hangul-formal":return 31;case"korean-hanja-formal":return 32;case"korean-hanja-informal":return 33;case"lao":return 34;case"lower-armenian":return 35;case"malayalam":return 36;case"mongolian":return 37;case"myanmar":return 38;case"oriya":return 39;case"persian":return 40;case"simp-chinese-formal":return 41;case"simp-chinese-informal":return 42;case"tamil":return 43;case"telugu":return 44;case"thai":return 45;case"tibetan":return 46;case"trad-chinese-formal":return 47;case"trad-chinese-informal":return 48;case"upper-armenian":return 49;case"disclosure-open":return 50;case"disclosure-closed":return 51;case"none":default:return-1}}},ar=function(n){return{name:"margin-".concat(n),initialValue:"0",prefix:!1,type:4}},v0=ar("top"),b0=ar("right"),y0=ar("bottom"),k0=ar("left"),T0={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:function(n,e){return e.filter(H).map(function(t){switch(t.value){case"hidden":return 1;case"scroll":return 2;case"clip":return 3;case"auto":return 4;case"visible":default:return 0}})}},S0={name:"overflow-wrap",initialValue:"normal",prefix:!1,type:2,parse:function(n,e){switch(e){case"break-word":return"break-word";case"normal":default:return"normal"}}},or=function(n){return{name:"padding-".concat(n),initialValue:"0",prefix:!1,type:3,format:"length-percentage"}},C0=or("top"),x0=or("right"),w0=or("bottom"),_0=or("left"),E0={name:"text-align",initialValue:"left",prefix:!1,type:2,parse:function(n,e){switch(e){case"right":return 2;case"center":case"justify":return 1;case"left":default:return 0}}},P0={name:"position",initialValue:"static",prefix:!1,type:2,parse:function(n,e){switch(e){case"relative":return 1;case"absolute":return 2;case"fixed":return 3;case"sticky":return 4}return 0}},R0={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:function(n,e){return e.length===1&&Rs(e[0],"none")?[]:mt(e).map(function(t){for(var i={color:vt.TRANSPARENT,offsetX:Pe,offsetY:Pe,blur:Pe},r=0,s=0;s<t.length;s++){var a=t[s];Ut(a)?(r===0?i.offsetX=a:r===1?i.offsetY=a:i.blur=a,r++):i.color=Vt.parse(n,a)}return i})}},I0={name:"text-transform",initialValue:"none",prefix:!1,type:2,parse:function(n,e){switch(e){case"uppercase":return 2;case"lowercase":return 1;case"capitalize":return 3}return 0}},O0={name:"transform",initialValue:"none",prefix:!0,type:0,parse:function(n,e){if(e.type===20&&e.value==="none")return null;if(e.type===18){var t=M0[e.name];if(typeof t>"u")throw new Error('Attempting to parse an unsupported transform function "'.concat(e.name,'"'));return t(e.values)}return null}},A0=function(n){var e=n.filter(function(t){return t.type===17}).map(function(t){return t.number});return e.length===6?e:null},N0=function(n){var e=n.filter(function(c){return c.type===17}).map(function(c){return c.number}),t=e[0],i=e[1];e[2],e[3];var r=e[4],s=e[5];e[6],e[7],e[8],e[9],e[10],e[11];var a=e[12],o=e[13];return e[14],e[15],e.length===16?[t,i,r,s,a,o]:null},M0={matrix:A0,matrix3d:N0},$c={type:16,number:50,flags:Zn},L0=[$c,$c],D0={name:"transform-origin",initialValue:"50% 50%",prefix:!0,type:1,parse:function(n,e){var t=e.filter(ae);return t.length!==2?L0:[t[0],t[1]]}},U0={name:"visible",initialValue:"none",prefix:!1,type:2,parse:function(n,e){switch(e){case"hidden":return 1;case"collapse":return 2;case"visible":default:return 0}}},ai;(function(n){n.NORMAL="normal",n.BREAK_ALL="break-all",n.KEEP_ALL="keep-all"})(ai||(ai={}));var B0={name:"word-break",initialValue:"normal",prefix:!1,type:2,parse:function(n,e){switch(e){case"break-all":return ai.BREAK_ALL;case"keep-all":return ai.KEEP_ALL;case"normal":default:return ai.NORMAL}}},F0={name:"z-index",initialValue:"auto",prefix:!1,type:0,parse:function(n,e){if(e.type===20)return{auto:!0,order:0};if(ye(e))return{auto:!1,order:e.number};throw new Error("Invalid z-index number parsed")}},Yc={name:"time",parse:function(n,e){if(e.type===15)switch(e.unit.toLowerCase()){case"s":return 1e3*e.number;case"ms":return e.number}throw new Error("Unsupported time type")}},j0={name:"opacity",initialValue:"1",type:0,prefix:!1,parse:function(n,e){return ye(e)?e.number:1}},V0={name:"text-decoration-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},G0={name:"text-decoration-line",initialValue:"none",prefix:!1,type:1,parse:function(n,e){return e.filter(H).map(function(t){switch(t.value){case"underline":return 1;case"overline":return 2;case"line-through":return 3;case"none":return 4}return 0}).filter(function(t){return t!==0})}},W0={name:"font-family",initialValue:"",prefix:!1,type:1,parse:function(n,e){var t=[],i=[];return e.forEach(function(r){switch(r.type){case 20:case 0:t.push(r.value);break;case 17:t.push(r.number.toString());break;case 4:i.push(t.join(" ")),t.length=0;break}}),t.length&&i.push(t.join(" ")),i.map(function(r){return r.indexOf(" ")===-1?r:"'".concat(r,"'")})}},z0={name:"font-size",initialValue:"0",prefix:!1,type:3,format:"length"},H0={name:"font-weight",initialValue:"normal",type:0,prefix:!1,parse:function(n,e){if(ye(e))return e.number;if(H(e))switch(e.value){case"bold":return 700;case"normal":default:return 400}return 400}},q0={name:"font-variant",initialValue:"none",type:1,prefix:!1,parse:function(n,e){return e.filter(H).map(function(t){return t.value})}},K0={name:"font-style",initialValue:"normal",prefix:!1,type:2,parse:function(n,e){switch(e){case"oblique":return"oblique";case"italic":return"italic";case"normal":default:return"normal"}}},Se=function(n,e){return(n&e)!==0},$0={name:"content",initialValue:"none",type:1,prefix:!1,parse:function(n,e){if(e.length===0)return[];var t=e[0];return t.type===20&&t.value==="none"?[]:e}},Y0={name:"counter-increment",initialValue:"none",prefix:!0,type:1,parse:function(n,e){if(e.length===0)return null;var t=e[0];if(t.type===20&&t.value==="none")return null;for(var i=[],r=e.filter(gc),s=0;s<r.length;s++){var a=r[s],o=r[s+1];if(a.type===20){var c=o&&ye(o)?o.number:1;i.push({counter:a.value,increment:c})}}return i}},X0={name:"counter-reset",initialValue:"none",prefix:!0,type:1,parse:function(n,e){if(e.length===0)return[];for(var t=[],i=e.filter(gc),r=0;r<i.length;r++){var s=i[r],a=i[r+1];if(H(s)&&s.value!=="none"){var o=a&&ye(a)?a.number:0;t.push({counter:s.value,reset:o})}}return t}},J0={name:"duration",initialValue:"0s",prefix:!1,type:1,parse:function(n,e){return e.filter(Dt).map(function(t){return Yc.parse(n,t)})}},Q0={name:"quotes",initialValue:"none",prefix:!0,type:1,parse:function(n,e){if(e.length===0)return null;var t=e[0];if(t.type===20&&t.value==="none")return null;var i=[],r=e.filter(Am);if(r.length%2!==0)return null;for(var s=0;s<r.length;s+=2){var a=r[s].value,o=r[s+1].value;i.push({open:a,close:o})}return i}},Xc=function(n,e,t){if(!n)return"";var i=n[Math.min(e,n.length-1)];return i?t?i.open:i.close:""},Z0={name:"box-shadow",initialValue:"none",type:1,prefix:!1,parse:function(n,e){return e.length===1&&Rs(e[0],"none")?[]:mt(e).map(function(t){for(var i={color:255,offsetX:Pe,offsetY:Pe,blur:Pe,spread:Pe,inset:!1},r=0,s=0;s<t.length;s++){var a=t[s];Rs(a,"inset")?i.inset=!0:Ut(a)?(r===0?i.offsetX=a:r===1?i.offsetY=a:r===2?i.blur=a:i.spread=a,r++):i.color=Vt.parse(n,a)}return i})}},ev={name:"paint-order",initialValue:"normal",prefix:!1,type:1,parse:function(n,e){var t=[0,1,2],i=[];return e.filter(H).forEach(function(r){switch(r.value){case"stroke":i.push(1);break;case"fill":i.push(0);break;case"markers":i.push(2);break}}),t.forEach(function(r){i.indexOf(r)===-1&&i.push(r)}),i}},tv={name:"-webkit-text-stroke-color",initialValue:"currentcolor",prefix:!1,type:3,format:"color"},nv={name:"-webkit-text-stroke-width",initialValue:"0",type:0,prefix:!1,parse:function(n,e){return Dt(e)?e.number:0}},iv={name:"objectFit",initialValue:"fill",prefix:!1,type:1,parse:function(n,e){return e.filter(H).reduce(function(t,i){return t|rv(i.value)},0)}},rv=function(n){switch(n){case"contain":return 2;case"cover":return 4;case"none":return 8;case"scale-down":return 16}return 0},sv=function(){function n(e,t){var i,r;this.animationDuration=F(e,J0,t.animationDuration),this.backgroundClip=F(e,Eg,t.backgroundClip),this.backgroundColor=F(e,Pg,t.backgroundColor),this.backgroundImage=F(e,Bg,t.backgroundImage),this.backgroundOrigin=F(e,Fg,t.backgroundOrigin),this.backgroundPosition=F(e,jg,t.backgroundPosition),this.backgroundRepeat=F(e,Vg,t.backgroundRepeat),this.backgroundSize=F(e,Wg,t.backgroundSize),this.borderTopColor=F(e,Hg,t.borderTopColor),this.borderRightColor=F(e,qg,t.borderRightColor),this.borderBottomColor=F(e,Kg,t.borderBottomColor),this.borderLeftColor=F(e,$g,t.borderLeftColor),this.borderTopLeftRadius=F(e,Yg,t.borderTopLeftRadius),this.borderTopRightRadius=F(e,Xg,t.borderTopRightRadius),this.borderBottomRightRadius=F(e,Jg,t.borderBottomRightRadius),this.borderBottomLeftRadius=F(e,Qg,t.borderBottomLeftRadius),this.borderTopStyle=F(e,Zg,t.borderTopStyle),this.borderRightStyle=F(e,e0,t.borderRightStyle),this.borderBottomStyle=F(e,t0,t.borderBottomStyle),this.borderLeftStyle=F(e,n0,t.borderLeftStyle),this.borderTopWidth=F(e,i0,t.borderTopWidth),this.borderRightWidth=F(e,r0,t.borderRightWidth),this.borderBottomWidth=F(e,s0,t.borderBottomWidth),this.borderLeftWidth=F(e,a0,t.borderLeftWidth),this.boxShadow=F(e,Z0,t.boxShadow),this.color=F(e,o0,t.color),this.direction=F(e,c0,t.direction),this.display=F(e,l0,t.display),this.float=F(e,d0,t.cssFloat),this.fontFamily=F(e,W0,t.fontFamily),this.fontSize=F(e,z0,t.fontSize),this.fontStyle=F(e,K0,t.fontStyle),this.fontVariant=F(e,q0,t.fontVariant),this.fontWeight=F(e,H0,t.fontWeight),this.letterSpacing=F(e,h0,t.letterSpacing),this.lineBreak=F(e,f0,t.lineBreak),this.lineHeight=F(e,p0,t.lineHeight),this.listStyleImage=F(e,m0,t.listStyleImage),this.listStylePosition=F(e,g0,t.listStylePosition),this.listStyleType=F(e,Us,t.listStyleType),this.marginTop=F(e,v0,t.marginTop),this.marginRight=F(e,b0,t.marginRight),this.marginBottom=F(e,y0,t.marginBottom),this.marginLeft=F(e,k0,t.marginLeft),this.opacity=F(e,j0,t.opacity);var s=F(e,T0,t.overflow);this.overflowX=s[0],this.overflowY=s[s.length>1?1:0],this.overflowWrap=F(e,S0,t.overflowWrap),this.paddingTop=F(e,C0,t.paddingTop),this.paddingRight=F(e,x0,t.paddingRight),this.paddingBottom=F(e,w0,t.paddingBottom),this.paddingLeft=F(e,_0,t.paddingLeft),this.paintOrder=F(e,ev,t.paintOrder),this.position=F(e,P0,t.position),this.textAlign=F(e,E0,t.textAlign),this.textDecorationColor=F(e,V0,(i=t.textDecorationColor)!==null&&i!==void 0?i:t.color),this.textDecorationLine=F(e,G0,(r=t.textDecorationLine)!==null&&r!==void 0?r:t.textDecoration),this.textShadow=F(e,R0,t.textShadow),this.textTransform=F(e,I0,t.textTransform),this.transform=F(e,O0,t.transform),this.transformOrigin=F(e,D0,t.transformOrigin),this.visibility=F(e,U0,t.visibility),this.webkitTextStrokeColor=F(e,tv,t.webkitTextStrokeColor),this.webkitTextStrokeWidth=F(e,nv,t.webkitTextStrokeWidth),this.wordBreak=F(e,B0,t.wordBreak),this.zIndex=F(e,F0,t.zIndex),this.objectFit=F(e,iv,t.objectFit)}return n.prototype.isVisible=function(){return this.display>0&&this.opacity>0&&this.visibility===0},n.prototype.isTransparent=function(){return Ft(this.backgroundColor)},n.prototype.isTransformed=function(){return this.transform!==null},n.prototype.isPositioned=function(){return this.position!==0},n.prototype.isPositionedWithZIndex=function(){return this.isPositioned()&&!this.zIndex.auto},n.prototype.isFloating=function(){return this.float!==0},n.prototype.isInlineLevel=function(){return Se(this.display,4)||Se(this.display,33554432)||Se(this.display,268435456)||Se(this.display,536870912)||Se(this.display,67108864)||Se(this.display,134217728)},n}(),av=function(){function n(e,t){this.content=F(e,$0,t.content),this.quotes=F(e,Q0,t.quotes)}return n}(),Jc=function(){function n(e,t){this.counterIncrement=F(e,Y0,t.counterIncrement),this.counterReset=F(e,X0,t.counterReset)}return n}(),F=function(n,e,t){var i=new pc,r=t!==null&&typeof t<"u"?t.toString():e.initialValue;i.write(r);var s=new mc(i.read());switch(e.type){case 2:var a=s.parseComponentValue();return e.parse(n,H(a)?a.value:e.initialValue);case 0:return e.parse(n,s.parseComponentValue());case 1:return e.parse(n,s.parseComponentValues());case 4:return s.parseComponentValue();case 3:switch(e.format){case"angle":return Hi.parse(n,s.parseComponentValue());case"color":return Vt.parse(n,s.parseComponentValue());case"image":return Ds.parse(n,s.parseComponentValue());case"length":var o=s.parseComponentValue();return Ut(o)?o:Pe;case"length-percentage":var c=s.parseComponentValue();return ae(c)?c:Pe;case"time":return Yc.parse(n,s.parseComponentValue())}break}},ov="data-html2canvas-debug",cv=function(n){var e=n.getAttribute(ov);switch(e){case"all":return 1;case"clone":return 2;case"parse":return 3;case"render":return 4;default:return 0}},Bs=function(n,e){var t=cv(n);return t===1||e===t},bt=function(){function n(e,t){this.context=e,this.textNodes=[],this.elements=[],this.flags=0,Bs(t,3),this.styles=new sv(e,window.getComputedStyle(t,null)),Ys(t)&&(this.styles.animationDuration.some(function(i){return i>0})&&(t.style.animationDuration="0s"),this.styles.transform!==null&&(t.style.transform="none")),this.bounds=Oi(this.context,t),Bs(t,4)&&(this.flags|=16)}return n}();typeof SuppressedError=="function"&&SuppressedError;for(var Qc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",lv=typeof Uint8Array>"u"?[]:new Uint8Array(256),cr=0;cr<Qc.length;cr++)lv[Qc.charCodeAt(cr)]=cr;for(var Zc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",uv=typeof Uint8Array>"u"?[]:new Uint8Array(256),lr=0;lr<Zc.length;lr++)uv[Zc.charCodeAt(lr)]=lr;var dv=1,Fs=2,js=3,el=4,tl=5,hv=7,nl=8,Vs=9,Gs=10,il=11,rl=12,sl=13,al=14,Ws=15,fv=function(n){for(var e=[],t=0,i=n.length;t<i;){var r=n.charCodeAt(t++);if(r>=55296&&r<=56319&&t<i){var s=n.charCodeAt(t++);(s&64512)===56320?e.push(((r&1023)<<10)+(s&1023)+65536):(e.push(r),t--)}else e.push(r)}return e},pv=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];if(String.fromCodePoint)return String.fromCodePoint.apply(String,n);var t=n.length;if(!t)return"";for(var i=[],r=-1,s="";++r<t;){var a=n[r];a<=65535?i.push(a):(a-=65536,i.push((a>>10)+55296,a%1024+56320)),(r+1===t||i.length>16384)&&(s+=String.fromCharCode.apply(String,i),i.length=0)}return s},Xe="\xD7",zs="\xF7",mv=function(n){throw new Error("UnicodeTrie not initialized")},gv=function(n,e,t){var i=t-2,r=e[i],s=e[t-1],a=e[t];if(s===Fs&&a===js)return Xe;if(s===Fs||s===js||s===el||a===Fs||a===js||a===el)return zs;if(s===nl&&[nl,Vs,il,rl].indexOf(a)!==-1||(s===il||s===Vs)&&(a===Vs||a===Gs)||(s===rl||s===Gs)&&a===Gs||a===sl||a===tl||a===hv||s===dv)return Xe;if(s===sl&&a===al){for(;r===tl;)r=e[--i];if(r===al)return Xe}if(s===Ws&&a===Ws){for(var o=0;r===Ws;)o++,r=e[--i];if(o%2===0)return Xe}return zs},vv=function(n){var e=fv(n),t=e.length,i=0,r=0,s=e.map(mv);return{next:function(){if(i>=t)return{done:!0,value:null};for(var a=Xe;i<t&&(a=gv(e,s,++i))===Xe;);if(a!==Xe||i===t){var o=pv.apply(null,e.slice(r,i));return r=i,{value:o,done:!1}}return{done:!0,value:null}}}},bv=function(n){for(var e=vv(n),t=[],i;!(i=e.next()).done;)i.value&&t.push(i.value.slice());return t},yv=function(n){var e=123;if(n.createRange){var t=n.createRange();if(t.getBoundingClientRect){var i=n.createElement("boundtest");i.style.height="".concat(e,"px"),i.style.display="block",n.body.appendChild(i),t.selectNode(i);var r=t.getBoundingClientRect(),s=Math.round(r.height);if(n.body.removeChild(i),s===e)return!0}}return!1},kv=function(n){var e=n.createElement("boundtest");e.style.width="50px",e.style.display="block",e.style.fontSize="12px",e.style.letterSpacing="0px",e.style.wordSpacing="0px",n.body.appendChild(e);var t=n.createRange();e.innerHTML=typeof"".repeat=="function"?"&#128104;".repeat(10):"";var i=e.firstChild,r=Ai(i.data).map(function(c){return me(c)}),s=0,a={},o=r.every(function(c,l){t.setStart(i,s),t.setEnd(i,s+c.length);var u=t.getBoundingClientRect();s+=c.length;var d=u.x>a.x||u.y>a.y;return a=u,l===0?!0:d});return n.body.removeChild(e),o},Tv=function(){return typeof new Image().crossOrigin<"u"},Sv=function(){return typeof new XMLHttpRequest().responseType=="string"},Cv=function(n){var e=new Image,t=n.createElement("canvas"),i=t.getContext("2d");if(!i)return!1;e.src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>";try{i.drawImage(e,0,0),t.toDataURL()}catch{return!1}return!0},ol=function(n){return n[0]===0&&n[1]===255&&n[2]===0&&n[3]===255},xv=function(n){var e=n.createElement("canvas"),t=100;e.width=t,e.height=t;var i=e.getContext("2d");if(!i)return Promise.reject(!1);i.fillStyle="rgb(0, 255, 0)",i.fillRect(0,0,t,t);var r=new Image,s=e.toDataURL();r.src=s;var a=Hs(t,t,0,0,r);return i.fillStyle="red",i.fillRect(0,0,t,t),cl(a).then(function(o){i.drawImage(o,0,0);var c=i.getImageData(0,0,t,t).data;i.fillStyle="red",i.fillRect(0,0,t,t);var l=n.createElement("div");return l.style.backgroundImage="url(".concat(s,")"),l.style.height="".concat(t,"px"),ol(c)?cl(Hs(t,t,0,0,l)):Promise.reject(!1)}).then(function(o){return i.drawImage(o,0,0),ol(i.getImageData(0,0,t,t).data)}).catch(function(){return!1})},Hs=function(n,e,t,i,r){var s="http://www.w3.org/2000/svg",a=document.createElementNS(s,"svg"),o=document.createElementNS(s,"foreignObject");return a.setAttributeNS(null,"width",n.toString()),a.setAttributeNS(null,"height",e.toString()),o.setAttributeNS(null,"width","100%"),o.setAttributeNS(null,"height","100%"),o.setAttributeNS(null,"x",t.toString()),o.setAttributeNS(null,"y",i.toString()),o.setAttributeNS(null,"externalResourcesRequired","true"),a.appendChild(o),o.appendChild(r),a},cl=function(n){return new Promise(function(e,t){var i=new Image;i.onload=function(){return e(i)},i.onerror=t,i.src="data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(new XMLSerializer().serializeToString(n)))})},Re={get SUPPORT_RANGE_BOUNDS(){var n=yv(document);return Object.defineProperty(Re,"SUPPORT_RANGE_BOUNDS",{value:n}),n},get SUPPORT_WORD_BREAKING(){var n=Re.SUPPORT_RANGE_BOUNDS&&kv(document);return Object.defineProperty(Re,"SUPPORT_WORD_BREAKING",{value:n}),n},get SUPPORT_SVG_DRAWING(){var n=Cv(document);return Object.defineProperty(Re,"SUPPORT_SVG_DRAWING",{value:n}),n},get SUPPORT_FOREIGNOBJECT_DRAWING(){var n=typeof Array.from=="function"&&typeof window.fetch=="function"?xv(document):Promise.resolve(!1);return Object.defineProperty(Re,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:n}),n},get SUPPORT_CORS_IMAGES(){var n=Tv();return Object.defineProperty(Re,"SUPPORT_CORS_IMAGES",{value:n}),n},get SUPPORT_RESPONSE_TYPE(){var n=Sv();return Object.defineProperty(Re,"SUPPORT_RESPONSE_TYPE",{value:n}),n},get SUPPORT_CORS_XHR(){var n="withCredentials"in new XMLHttpRequest;return Object.defineProperty(Re,"SUPPORT_CORS_XHR",{value:n}),n},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){var n=!!(typeof Intl<"u"&&Intl.Segmenter);return Object.defineProperty(Re,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:n}),n}},oi=function(){function n(e,t){this.text=e,this.bounds=t}return n}(),wv=function(n,e,t,i){var r=Pv(e,t),s=[],a=0;return r.forEach(function(o){if(t.textDecorationLine.length||o.trim().length>0)if(Re.SUPPORT_RANGE_BOUNDS){var c=ll(i,a,o.length).getClientRects();if(c.length>1){var l=qs(o),u=0;l.forEach(function(h){s.push(new oi(h,xt.fromDOMRectList(n,ll(i,u+a,h.length).getClientRects()))),u+=h.length})}else s.push(new oi(o,xt.fromDOMRectList(n,c)))}else{var d=i.splitText(o.length);s.push(new oi(o,_v(n,i))),i=d}else Re.SUPPORT_RANGE_BOUNDS||(i=i.splitText(o.length));a+=o.length}),s},_v=function(n,e){var t=e.ownerDocument;if(t){var i=t.createElement("html2canvaswrapper");i.appendChild(e.cloneNode(!0));var r=e.parentNode;if(r){r.replaceChild(i,e);var s=Oi(n,i);return i.firstChild&&r.replaceChild(i.firstChild,i),s}}return xt.EMPTY},ll=function(n,e,t){var i=n.ownerDocument;if(!i)throw new Error("Node has no owner document");var r=i.createRange();return r.setStart(n,e),r.setEnd(n,e+t),r},qs=function(n){if(Re.SUPPORT_NATIVE_TEXT_SEGMENTATION){var e=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(e.segment(n)).map(function(t){return t.segment})}return bv(n)},Ev=function(n,e){if(Re.SUPPORT_NATIVE_TEXT_SEGMENTATION){var t=new Intl.Segmenter(void 0,{granularity:"word"});return Array.from(t.segment(n)).map(function(i){return i.segment})}return Iv(n,e)},Pv=function(n,e){return e.letterSpacing!==0?qs(n):Ev(n,e)},Rv=[32,160,4961,65792,65793,4153,4241],Iv=function(n,e){for(var t=_p(n,{lineBreak:e.lineBreak,wordBreak:e.overflowWrap==="break-word"?"break-word":e.wordBreak}),i=[],r,s=function(){if(r.value){var a=r.value.slice(),o=Ai(a),c="";o.forEach(function(l){Rv.indexOf(l)===-1?c+=me(l):(c.length&&i.push(c),i.push(me(l)),c="")}),c.length&&i.push(c)}};!(r=t.next()).done;)s();return i},Ov=function(){function n(e,t,i){this.text=Av(t.data,i.textTransform),this.textBounds=wv(e,this.text,i,t)}return n}(),Av=function(n,e){switch(e){case 1:return n.toLowerCase();case 3:return n.replace(Nv,Mv);case 2:return n.toUpperCase();default:return n}},Nv=/(^|\s|:|-|\(|\))([a-z])/g,Mv=function(n,e,t){return n.length>0?e+t.toUpperCase():n},ul=function(n){tt(e,n);function e(t,i){var r=n.call(this,t,i)||this;return r.src=i.currentSrc||i.src,r.intrinsicWidth=i.naturalWidth,r.intrinsicHeight=i.naturalHeight,r.context.cache.addImage(r.src),r}return e}(bt),dl=function(n){tt(e,n);function e(t,i){var r=n.call(this,t,i)||this;return r.canvas=i,r.intrinsicWidth=i.width,r.intrinsicHeight=i.height,r}return e}(bt),hl=function(n){tt(e,n);function e(t,i){var r=n.call(this,t,i)||this,s=new XMLSerializer,a=Oi(t,i);return i.setAttribute("width","".concat(a.width,"px")),i.setAttribute("height","".concat(a.height,"px")),r.svg="data:image/svg+xml,".concat(encodeURIComponent(s.serializeToString(i))),r.intrinsicWidth=i.width.baseVal.value,r.intrinsicHeight=i.height.baseVal.value,r.context.cache.addImage(r.svg),r}return e}(bt),fl=function(n){tt(e,n);function e(t,i){var r=n.call(this,t,i)||this;return r.value=i.value,r}return e}(bt),Ks=function(n){tt(e,n);function e(t,i){var r=n.call(this,t,i)||this;return r.start=i.start,r.reversed=typeof i.reversed=="boolean"&&i.reversed===!0,r}return e}(bt),Lv=[{type:15,flags:0,unit:"px",number:3}],Dv=[{type:16,flags:0,number:50}],Uv=function(n){return n.width>n.height?new xt(n.left+(n.width-n.height)/2,n.top,n.height,n.height):n.width<n.height?new xt(n.left,n.top+(n.height-n.width)/2,n.width,n.width):n},Bv=function(n){var e=n.type===Fv?new Array(n.value.length+1).join("\u2022"):n.value;return e.length===0?n.placeholder||"":e},ur="checkbox",dr="radio",Fv="password",pl=707406591,$s=function(n){tt(e,n);function e(t,i){var r=n.call(this,t,i)||this;switch(r.type=i.type.toLowerCase(),r.checked=i.checked,r.value=Bv(i),(r.type===ur||r.type===dr)&&(r.styles.backgroundColor=3739148031,r.styles.borderTopColor=r.styles.borderRightColor=r.styles.borderBottomColor=r.styles.borderLeftColor=2779096575,r.styles.borderTopWidth=r.styles.borderRightWidth=r.styles.borderBottomWidth=r.styles.borderLeftWidth=1,r.styles.borderTopStyle=r.styles.borderRightStyle=r.styles.borderBottomStyle=r.styles.borderLeftStyle=1,r.styles.backgroundClip=[0],r.styles.backgroundOrigin=[0],r.bounds=Uv(r.bounds)),r.type){case ur:r.styles.borderTopRightRadius=r.styles.borderTopLeftRadius=r.styles.borderBottomRightRadius=r.styles.borderBottomLeftRadius=Lv;break;case dr:r.styles.borderTopRightRadius=r.styles.borderTopLeftRadius=r.styles.borderBottomRightRadius=r.styles.borderBottomLeftRadius=Dv;break}return r}return e}(bt),ml=function(n){tt(e,n);function e(t,i){var r=n.call(this,t,i)||this,s=i.options[i.selectedIndex||0];return r.value=s&&s.text||"",r}return e}(bt),gl=function(n){tt(e,n);function e(t,i){var r=n.call(this,t,i)||this;return r.value=i.value,r}return e}(bt),vl=function(n){tt(e,n);function e(t,i){var r=n.call(this,t,i)||this;r.src=i.src,r.width=parseInt(i.width,10)||0,r.height=parseInt(i.height,10)||0,r.backgroundColor=r.styles.backgroundColor;try{if(i.contentWindow&&i.contentWindow.document&&i.contentWindow.document.documentElement){r.tree=yl(t,i.contentWindow.document.documentElement);var s=i.contentWindow.document.documentElement?xn(t,getComputedStyle(i.contentWindow.document.documentElement).backgroundColor):vt.TRANSPARENT,a=i.contentWindow.document.body?xn(t,getComputedStyle(i.contentWindow.document.body).backgroundColor):vt.TRANSPARENT;r.backgroundColor=Ft(s)?Ft(a)?r.styles.backgroundColor:a:s}}catch{}return r}return e}(bt),jv=["OL","UL","MENU"],hr=function(n,e,t,i){for(var r=e.firstChild,s=void 0;r;r=s)if(s=r.nextSibling,kl(r)&&r.data.length>0)t.textNodes.push(new Ov(n,r,t.styles));else if(_n(r))if(_l(r)&&r.assignedNodes)r.assignedNodes().forEach(function(o){return hr(n,o,t,i)});else{var a=bl(n,r);a.styles.isVisible()&&(Vv(r,a,i)?a.flags|=4:Gv(a.styles)&&(a.flags|=2),jv.indexOf(r.tagName)!==-1&&(a.flags|=8),t.elements.push(a),r.slot,r.shadowRoot?hr(n,r.shadowRoot,a,i):!pr(r)&&!Tl(r)&&!mr(r)&&hr(n,r,a,i))}},bl=function(n,e){return Js(e)?new ul(n,e):Sl(e)?new dl(n,e):Tl(e)?new hl(n,e):Wv(e)?new fl(n,e):zv(e)?new Ks(n,e):Hv(e)?new $s(n,e):mr(e)?new ml(n,e):pr(e)?new gl(n,e):xl(e)?new vl(n,e):new bt(n,e)},yl=function(n,e){var t=bl(n,e);return t.flags|=4,hr(n,e,t,t),t},Vv=function(n,e,t){return e.styles.isPositionedWithZIndex()||e.styles.opacity<1||e.styles.isTransformed()||Xs(n)&&t.styles.isTransparent()},Gv=function(n){return n.isPositioned()||n.isFloating()},kl=function(n){return n.nodeType===Node.TEXT_NODE},_n=function(n){return n.nodeType===Node.ELEMENT_NODE},Ys=function(n){return _n(n)&&typeof n.style<"u"&&!fr(n)},fr=function(n){return typeof n.className=="object"},Wv=function(n){return n.tagName==="LI"},zv=function(n){return n.tagName==="OL"},Hv=function(n){return n.tagName==="INPUT"},qv=function(n){return n.tagName==="HTML"},Tl=function(n){return n.tagName==="svg"},Xs=function(n){return n.tagName==="BODY"},Sl=function(n){return n.tagName==="CANVAS"},Cl=function(n){return n.tagName==="VIDEO"},Js=function(n){return n.tagName==="IMG"},xl=function(n){return n.tagName==="IFRAME"},wl=function(n){return n.tagName==="STYLE"},Kv=function(n){return n.tagName==="SCRIPT"},pr=function(n){return n.tagName==="TEXTAREA"},mr=function(n){return n.tagName==="SELECT"},_l=function(n){return n.tagName==="SLOT"},El=function(n){return n.tagName.indexOf("-")>0},$v=function(){function n(){this.counters={}}return n.prototype.getCounterValue=function(e){var t=this.counters[e];return t&&t.length?t[t.length-1]:1},n.prototype.getCounterValues=function(e){var t=this.counters[e];return t||[]},n.prototype.pop=function(e){var t=this;e.forEach(function(i){return t.counters[i].pop()})},n.prototype.parse=function(e){var t=this,i=e.counterIncrement,r=e.counterReset,s=!0;i!==null&&i.forEach(function(o){var c=t.counters[o.counter];c&&o.increment!==0&&(s=!1,c.length||c.push(1),c[Math.max(0,c.length-1)]+=o.increment)});var a=[];return s&&r.forEach(function(o){var c=t.counters[o.counter];a.push(o.counter),c||(c=t.counters[o.counter]=[]),c.push(o.reset)}),a},n}(),Pl={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]},Rl={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["\u0554","\u0553","\u0552","\u0551","\u0550","\u054F","\u054E","\u054D","\u054C","\u054B","\u054A","\u0549","\u0548","\u0547","\u0546","\u0545","\u0544","\u0543","\u0542","\u0541","\u0540","\u053F","\u053E","\u053D","\u053C","\u053B","\u053A","\u0539","\u0538","\u0537","\u0536","\u0535","\u0534","\u0533","\u0532","\u0531"]},Yv={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:["\u05D9\u05F3","\u05D8\u05F3","\u05D7\u05F3","\u05D6\u05F3","\u05D5\u05F3","\u05D4\u05F3","\u05D3\u05F3","\u05D2\u05F3","\u05D1\u05F3","\u05D0\u05F3","\u05EA","\u05E9","\u05E8","\u05E7","\u05E6","\u05E4","\u05E2","\u05E1","\u05E0","\u05DE","\u05DC","\u05DB","\u05D9\u05D8","\u05D9\u05D7","\u05D9\u05D6","\u05D8\u05D6","\u05D8\u05D5","\u05D9","\u05D8","\u05D7","\u05D6","\u05D5","\u05D4","\u05D3","\u05D2","\u05D1","\u05D0"]},Xv={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["\u10F5","\u10F0","\u10EF","\u10F4","\u10EE","\u10ED","\u10EC","\u10EB","\u10EA","\u10E9","\u10E8","\u10E7","\u10E6","\u10E5","\u10E4","\u10F3","\u10E2","\u10E1","\u10E0","\u10DF","\u10DE","\u10DD","\u10F2","\u10DC","\u10DB","\u10DA","\u10D9","\u10D8","\u10D7","\u10F1","\u10D6","\u10D5","\u10D4","\u10D3","\u10D2","\u10D1","\u10D0"]},En=function(n,e,t,i,r,s){return n<e||n>t?li(n,r,s.length>0):i.integers.reduce(function(a,o,c){for(;n>=o;)n-=o,a+=i.values[c];return a},"")+s},Il=function(n,e,t,i){var r="";do t||n--,r=i(n)+r,n/=e;while(n*e>=e);return r},ge=function(n,e,t,i,r){var s=t-e+1;return(n<0?"-":"")+(Il(Math.abs(n),s,i,function(a){return me(Math.floor(a%s)+e)})+r)},cn=function(n,e,t){t===void 0&&(t=". ");var i=e.length;return Il(Math.abs(n),i,!1,function(r){return e[Math.floor(r%i)]})+t},Pn=1,Gt=2,Wt=4,ci=8,wt=function(n,e,t,i,r,s){if(n<-9999||n>9999)return li(n,4,r.length>0);var a=Math.abs(n),o=r;if(a===0)return e[0]+o;for(var c=0;a>0&&c<=4;c++){var l=a%10;l===0&&Se(s,Pn)&&o!==""?o=e[l]+o:l>1||l===1&&c===0||l===1&&c===1&&Se(s,Gt)||l===1&&c===1&&Se(s,Wt)&&n>100||l===1&&c>1&&Se(s,ci)?o=e[l]+(c>0?t[c-1]:"")+o:l===1&&c>0&&(o=t[c-1]+o),a=Math.floor(a/10)}return(n<0?i:"")+o},Ol="\u5341\u767E\u5343\u842C",Al="\u62FE\u4F70\u4EDF\u842C",Nl="\u30DE\u30A4\u30CA\u30B9",Qs="\uB9C8\uC774\uB108\uC2A4",li=function(n,e,t){var i=t?". ":"",r=t?"\u3001":"",s=t?", ":"",a=t?" ":"";switch(e){case 0:return"\u2022"+a;case 1:return"\u25E6"+a;case 2:return"\u25FE"+a;case 5:var o=ge(n,48,57,!0,i);return o.length<4?"0".concat(o):o;case 4:return cn(n,"\u3007\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D",r);case 6:return En(n,1,3999,Pl,3,i).toLowerCase();case 7:return En(n,1,3999,Pl,3,i);case 8:return ge(n,945,969,!1,i);case 9:return ge(n,97,122,!1,i);case 10:return ge(n,65,90,!1,i);case 11:return ge(n,1632,1641,!0,i);case 12:case 49:return En(n,1,9999,Rl,3,i);case 35:return En(n,1,9999,Rl,3,i).toLowerCase();case 13:return ge(n,2534,2543,!0,i);case 14:case 30:return ge(n,6112,6121,!0,i);case 15:return cn(n,"\u5B50\u4E11\u5BC5\u536F\u8FB0\u5DF3\u5348\u672A\u7533\u9149\u620C\u4EA5",r);case 16:return cn(n,"\u7532\u4E59\u4E19\u4E01\u620A\u5DF1\u5E9A\u8F9B\u58EC\u7678",r);case 17:case 48:return wt(n,"\u96F6\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D",Ol,"\u8CA0",r,Gt|Wt|ci);case 47:return wt(n,"\u96F6\u58F9\u8CB3\u53C3\u8086\u4F0D\u9678\u67D2\u634C\u7396",Al,"\u8CA0",r,Pn|Gt|Wt|ci);case 42:return wt(n,"\u96F6\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D",Ol,"\u8D1F",r,Gt|Wt|ci);case 41:return wt(n,"\u96F6\u58F9\u8D30\u53C1\u8086\u4F0D\u9646\u67D2\u634C\u7396",Al,"\u8D1F",r,Pn|Gt|Wt|ci);case 26:return wt(n,"\u3007\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D","\u5341\u767E\u5343\u4E07",Nl,r,0);case 25:return wt(n,"\u96F6\u58F1\u5F10\u53C2\u56DB\u4F0D\u516D\u4E03\u516B\u4E5D","\u62FE\u767E\u5343\u4E07",Nl,r,Pn|Gt|Wt);case 31:return wt(n,"\uC601\uC77C\uC774\uC0BC\uC0AC\uC624\uC721\uCE60\uD314\uAD6C","\uC2ED\uBC31\uCC9C\uB9CC",Qs,s,Pn|Gt|Wt);case 33:return wt(n,"\u96F6\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D","\u5341\u767E\u5343\u842C",Qs,s,0);case 32:return wt(n,"\u96F6\u58F9\u8CB3\u53C3\u56DB\u4E94\u516D\u4E03\u516B\u4E5D","\u62FE\u767E\u5343",Qs,s,Pn|Gt|Wt);case 18:return ge(n,2406,2415,!0,i);case 20:return En(n,1,19999,Xv,3,i);case 21:return ge(n,2790,2799,!0,i);case 22:return ge(n,2662,2671,!0,i);case 52:return En(n,1,10999,Yv,3,i);case 23:return cn(n,"\u3042\u3044\u3046\u3048\u304A\u304B\u304D\u304F\u3051\u3053\u3055\u3057\u3059\u305B\u305D\u305F\u3061\u3064\u3066\u3068\u306A\u306B\u306C\u306D\u306E\u306F\u3072\u3075\u3078\u307B\u307E\u307F\u3080\u3081\u3082\u3084\u3086\u3088\u3089\u308A\u308B\u308C\u308D\u308F\u3090\u3091\u3092\u3093");case 24:return cn(n,"\u3044\u308D\u306F\u306B\u307B\u3078\u3068\u3061\u308A\u306C\u308B\u3092\u308F\u304B\u3088\u305F\u308C\u305D\u3064\u306D\u306A\u3089\u3080\u3046\u3090\u306E\u304A\u304F\u3084\u307E\u3051\u3075\u3053\u3048\u3066\u3042\u3055\u304D\u3086\u3081\u307F\u3057\u3091\u3072\u3082\u305B\u3059");case 27:return ge(n,3302,3311,!0,i);case 28:return cn(n,"\u30A2\u30A4\u30A6\u30A8\u30AA\u30AB\u30AD\u30AF\u30B1\u30B3\u30B5\u30B7\u30B9\u30BB\u30BD\u30BF\u30C1\u30C4\u30C6\u30C8\u30CA\u30CB\u30CC\u30CD\u30CE\u30CF\u30D2\u30D5\u30D8\u30DB\u30DE\u30DF\u30E0\u30E1\u30E2\u30E4\u30E6\u30E8\u30E9\u30EA\u30EB\u30EC\u30ED\u30EF\u30F0\u30F1\u30F2\u30F3",r);case 29:return cn(n,"\u30A4\u30ED\u30CF\u30CB\u30DB\u30D8\u30C8\u30C1\u30EA\u30CC\u30EB\u30F2\u30EF\u30AB\u30E8\u30BF\u30EC\u30BD\u30C4\u30CD\u30CA\u30E9\u30E0\u30A6\u30F0\u30CE\u30AA\u30AF\u30E4\u30DE\u30B1\u30D5\u30B3\u30A8\u30C6\u30A2\u30B5\u30AD\u30E6\u30E1\u30DF\u30B7\u30F1\u30D2\u30E2\u30BB\u30B9",r);case 34:return ge(n,3792,3801,!0,i);case 37:return ge(n,6160,6169,!0,i);case 38:return ge(n,4160,4169,!0,i);case 39:return ge(n,2918,2927,!0,i);case 40:return ge(n,1776,1785,!0,i);case 43:return ge(n,3046,3055,!0,i);case 44:return ge(n,3174,3183,!0,i);case 45:return ge(n,3664,3673,!0,i);case 46:return ge(n,3872,3881,!0,i);case 3:default:return ge(n,48,57,!0,i)}},Ml="data-html2canvas-ignore",Ll=function(){function n(e,t,i){if(this.context=e,this.options=i,this.scrolledElements=[],this.referenceElement=t,this.counters=new $v,this.quoteDepth=0,!t.ownerDocument)throw new Error("Cloned element does not have an owner document");this.documentElement=this.cloneNode(t.ownerDocument.documentElement,!1)}return n.prototype.toIFrame=function(e,t){var i=this,r=Jv(e,t);if(!r.contentWindow)return Promise.reject("Unable to find iframe window");var s=e.defaultView.pageXOffset,a=e.defaultView.pageYOffset,o=r.contentWindow,c=o.document,l=eb(r).then(function(){return De(i,void 0,void 0,function(){var h,f;return Oe(this,function(p){switch(p.label){case 0:return this.scrolledElements.forEach(rb),o&&(o.scrollTo(t.left,t.top),/(iPad|iPhone|iPod)/g.test(navigator.userAgent)&&(o.scrollY!==t.top||o.scrollX!==t.left)&&(this.context.logger.warn("Unable to restore scroll position for cloned document"),this.context.windowBounds=this.context.windowBounds.add(o.scrollX-t.left,o.scrollY-t.top,0,0))),h=this.options.onclone,f=this.clonedReferenceElement,typeof f>"u"?[2,Promise.reject("Error finding the ".concat(this.referenceElement.nodeName," in the cloned document"))]:c.fonts&&c.fonts.ready?[4,c.fonts.ready]:[3,2];case 1:p.sent(),p.label=2;case 2:return/(AppleWebKit)/g.test(navigator.userAgent)?[4,Zv(c)]:[3,4];case 3:p.sent(),p.label=4;case 4:return typeof h=="function"?[2,Promise.resolve().then(function(){return h(c,f)}).then(function(){return r})]:[2,r]}})})}),u=c.baseURI;c.open(),c.write("".concat(nb(document.doctype),"<html></html>")),ib(this.referenceElement.ownerDocument,s,a);var d=c.adoptNode(this.documentElement);return lb(d,u),c.replaceChild(d,c.documentElement),c.close(),l},n.prototype.createElementClone=function(e){if(Bs(e,2),Sl(e))return this.createCanvasClone(e);if(Cl(e))return this.createVideoClone(e);if(wl(e))return this.createStyleClone(e);var t=e.cloneNode(!1);return Js(t)&&(Js(e)&&e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),t.loading==="lazy"&&(t.loading="eager")),El(t)?this.createCustomElementClone(t):t},n.prototype.createCustomElementClone=function(e){var t=document.createElement("html2canvascustomelement");return Zs(e.style,t),t},n.prototype.createStyleClone=function(e){try{var t=e.sheet;if(t&&t.cssRules){var i=[].slice.call(t.cssRules,0).reduce(function(s,a){return a&&typeof a.cssText=="string"?s+a.cssText:s},""),r=e.cloneNode(!1);return r.textContent=i,r}}catch(s){if(this.context.logger.error("Unable to access cssRules property",s),s.name!=="SecurityError")throw s}return e.cloneNode(!1)},n.prototype.createCanvasClone=function(e){var t;if(this.options.inlineImages&&e.ownerDocument){var i=e.ownerDocument.createElement("img");try{return i.src=e.toDataURL(),i}catch{this.context.logger.info("Unable to inline canvas contents, canvas is tainted",e)}}var r=e.cloneNode(!1);try{r.width=e.width,r.height=e.height;var s=e.getContext("2d"),a=r.getContext("2d",{willReadFrequently:!0});if(a)if(!this.options.allowTaint&&s)a.putImageData(s.getImageData(0,0,e.width,e.height),0,0);else{var o=(t=e.getContext("webgl2"))!==null&&t!==void 0?t:e.getContext("webgl");if(o){var c=o.getContextAttributes();(c==null?void 0:c.preserveDrawingBuffer)===!1&&this.context.logger.warn("Unable to clone WebGL context as it has preserveDrawingBuffer=false",e)}a.drawImage(e,0,0)}return r}catch{this.context.logger.info("Unable to clone canvas as it is tainted",e)}return r},n.prototype.createVideoClone=function(e){var t=e.ownerDocument.createElement("canvas");t.width=e.offsetWidth,t.height=e.offsetHeight;var i=t.getContext("2d");try{return i&&(i.drawImage(e,0,0,t.width,t.height),this.options.allowTaint||i.getImageData(0,0,t.width,t.height)),t}catch{this.context.logger.info("Unable to clone video as it is tainted",e)}var r=e.ownerDocument.createElement("canvas");return r.width=e.offsetWidth,r.height=e.offsetHeight,r},n.prototype.appendChildNode=function(e,t,i){(!_n(t)||!Kv(t)&&!t.hasAttribute(Ml)&&(typeof this.options.ignoreElements!="function"||!this.options.ignoreElements(t)))&&(!this.options.copyStyles||!_n(t)||!wl(t))&&e.appendChild(this.cloneNode(t,i))},n.prototype.cloneChildNodes=function(e,t,i){for(var r=this,s=e.shadowRoot?e.shadowRoot.firstChild:e.firstChild;s;s=s.nextSibling)if(_n(s)&&_l(s)&&typeof s.assignedNodes=="function"){var a=s.assignedNodes();a.length&&a.forEach(function(o){return r.appendChildNode(t,o,i)})}else this.appendChildNode(t,s,i)},n.prototype.cloneNode=function(e,t){if(kl(e))return document.createTextNode(e.data);if(!e.ownerDocument)return e.cloneNode(!1);var i=e.ownerDocument.defaultView;if(i&&_n(e)&&(Ys(e)||fr(e))){var r=this.createElementClone(e);r.style.transitionProperty="none";var s=i.getComputedStyle(e),a=i.getComputedStyle(e,":before"),o=i.getComputedStyle(e,":after");this.referenceElement===e&&Ys(r)&&(this.clonedReferenceElement=r),Xs(r)&&ob(r);var c=this.counters.parse(new Jc(this.context,s)),l=this.resolvePseudoContent(e,r,a,ui.BEFORE);El(e)&&(t=!0),Cl(e)||this.cloneChildNodes(e,r,t),l&&r.insertBefore(l,r.firstChild);var u=this.resolvePseudoContent(e,r,o,ui.AFTER);return u&&r.appendChild(u),this.counters.pop(c),(s&&(this.options.copyStyles||fr(e))&&!xl(e)||t)&&Zs(s,r),(e.scrollTop!==0||e.scrollLeft!==0)&&this.scrolledElements.push([r,e.scrollLeft,e.scrollTop]),(pr(e)||mr(e))&&(pr(r)||mr(r))&&(r.value=e.value),r}return e.cloneNode(!1)},n.prototype.resolvePseudoContent=function(e,t,i,r){var s=this;if(i){var a=i.content,o=t.ownerDocument;if(!(!o||!a||a==="none"||a==="-moz-alt-content"||i.display==="none")){this.counters.parse(new Jc(this.context,i));var c=new av(this.context,i),l=o.createElement("html2canvaspseudoelement");Zs(i,l),c.content.forEach(function(d){if(d.type===0)l.appendChild(o.createTextNode(d.value));else if(d.type===22){var h=o.createElement("img");h.src=d.value,h.style.opacity="1",l.appendChild(h)}else if(d.type===18){if(d.name==="attr"){var f=d.values.filter(H);f.length&&l.appendChild(o.createTextNode(e.getAttribute(f[0].value)||""))}else if(d.name==="counter"){var p=d.values.filter(Ee),g=p[0],v=p[1];if(g&&H(g)){var b=s.counters.getCounterValue(g.value),S=v&&H(v)?Us.parse(s.context,v.value):3;l.appendChild(o.createTextNode(li(b,S,!1)))}}else if(d.name==="counters"){var x=d.values.filter(Ee),g=x[0],k=x[1],v=x[2];if(g&&H(g)){var T=s.counters.getCounterValues(g.value),C=v&&H(v)?Us.parse(s.context,v.value):3,_=k&&k.type===0?k.value:"",R=T.map(function(U){return li(U,C,!1)}).join(_);l.appendChild(o.createTextNode(R))}}}else if(d.type===20)switch(d.value){case"open-quote":l.appendChild(o.createTextNode(Xc(c.quotes,s.quoteDepth++,!0)));break;case"close-quote":l.appendChild(o.createTextNode(Xc(c.quotes,--s.quoteDepth,!1)));break;default:l.appendChild(o.createTextNode(d.value))}}),l.className="".concat(ea," ").concat(ta);var u=r===ui.BEFORE?" ".concat(ea):" ".concat(ta);return fr(t)?t.className.baseValue+=u:t.className+=u,l}}},n.destroy=function(e){return e.parentNode?(e.parentNode.removeChild(e),!0):!1},n}(),ui;(function(n){n[n.BEFORE=0]="BEFORE",n[n.AFTER=1]="AFTER"})(ui||(ui={}));var Jv=function(n,e){var t=n.createElement("iframe");return t.className="html2canvas-container",t.style.visibility="hidden",t.style.position="fixed",t.style.left="-10000px",t.style.top="0px",t.style.border="0",t.width=e.width.toString(),t.height=e.height.toString(),t.scrolling="no",t.setAttribute(Ml,"true"),n.body.appendChild(t),t},Qv=function(n){return new Promise(function(e){if(n.complete){e();return}if(!n.src){e();return}n.onload=e,n.onerror=e})},Zv=function(n){return Promise.all([].slice.call(n.images,0).map(Qv))},eb=function(n){return new Promise(function(e,t){var i=n.contentWindow;if(!i)return t("No window assigned for iframe");var r=i.document;i.onload=n.onload=function(){i.onload=n.onload=null;var s=setInterval(function(){r.body.childNodes.length>0&&r.readyState==="complete"&&(clearInterval(s),e(n))},50)}})},tb=["all","d","content"],Zs=function(n,e){for(var t=n.length-1;t>=0;t--){var i=n.item(t);tb.indexOf(i)===-1&&e.style.setProperty(i,n.getPropertyValue(i))}return e},nb=function(n){var e="";return n&&(e+="<!DOCTYPE ",n.name&&(e+=n.name),n.internalSubset&&(e+=n.internalSubset),n.publicId&&(e+='"'.concat(n.publicId,'"')),n.systemId&&(e+='"'.concat(n.systemId,'"')),e+=">"),e},ib=function(n,e,t){n&&n.defaultView&&(e!==n.defaultView.pageXOffset||t!==n.defaultView.pageYOffset)&&n.defaultView.scrollTo(e,t)},rb=function(n){var e=n[0],t=n[1],i=n[2];e.scrollLeft=t,e.scrollTop=i},sb=":before",ab=":after",ea="___html2canvas___pseudoelement_before",ta="___html2canvas___pseudoelement_after",Dl=`{
80
2
  content: "" !important;
81
3
  display: none !important;
82
- }`,LN=function(n){UN(n,".".concat(Mh).concat(NN).concat(o_,`
83
- .`).concat(Nh).concat(DN).concat(o_))},UN=function(n,e){var t=n.ownerDocument;if(t){var i=t.createElement("style");i.textContent=e,n.appendChild(i)}},FN=function(n,e){var t,i=n.ownerDocument.createElement("base");i.href=e;var r=n.getElementsByTagName("head").item(0);r==null||r.insertBefore(i,(t=r==null?void 0:r.firstChild)!==null&&t!==void 0?t:null)},Dh=function(){function n(){}return n.getOrigin=function(e){var t=n._link;return t?(t.href=e,t.href=t.href,t.protocol+t.hostname+t.port):"about:blank"},n.isSameOrigin=function(e){return n.getOrigin(e)===n._origin},n.setContext=function(e){n._link=e.document.createElement("a"),n._origin=n.getOrigin(e.location.href)},n._origin="about:blank",n}(),BN=function(){function n(e,t){this.context=e,this._options=t,this._cache={}}return n.prototype.addImage=function(e){var t=Promise.resolve();return this.has(e)||(Uh(e)||qN(e))&&(this._cache[e]=this.loadImage(e)).catch(function(){}),t},n.prototype.match=function(e){return this._cache[e]},n.prototype.loadImage=function(e){return Mt(this,void 0,void 0,function(){var t,i,r,o,s,a=this;return xt(this,function(c){switch(c.label){case 0:return typeof this._options.customIsSameOrigin!="function"?[3,2]:[4,this._options.customIsSameOrigin(e,Dh.isSameOrigin)];case 1:return i=c.sent(),[3,3];case 2:i=Dh.isSameOrigin(e),c.label=3;case 3:return t=i,r=!Lh(e)&&this._options.useCORS===!0&&bt.SUPPORT_CORS_IMAGES&&!t,o=!Lh(e)&&!t&&!Uh(e)&&typeof this._options.proxy=="string"&&bt.SUPPORT_CORS_XHR&&!r,!t&&this._options.allowTaint===!1&&!Lh(e)&&!Uh(e)&&!o&&!r?[2]:(s=e,o?[4,this.proxy(s)]:[3,5]);case 4:s=c.sent(),c.label=5;case 5:return this.context.logger.debug("Added image ".concat(e.substring(0,256))),[4,new Promise(function(u,l){var d=new Image;d.onload=function(){return u(d)},d.onerror=l,(WN(s)||r)&&(d.crossOrigin="anonymous"),d.src=s,d.complete===!0&&setTimeout(function(){return u(d)},500),a._options.imageTimeout>0&&setTimeout(function(){return l("Timed out (".concat(a._options.imageTimeout,"ms) loading image"))},a._options.imageTimeout)})];case 6:return[2,c.sent()]}})})},n.prototype.has=function(e){return typeof this._cache[e]<"u"},n.prototype.keys=function(){return Promise.resolve(Object.keys(this._cache))},n.prototype.proxy=function(e){var t=this,i=this._options.proxy;if(!i)throw new Error("No proxy defined");var r=e.substring(0,256);return new Promise(function(o,s){var a=bt.SUPPORT_RESPONSE_TYPE?"blob":"text",c=new XMLHttpRequest;c.onload=function(){if(c.status===200)if(a==="text")o(c.response);else{var d=new FileReader;d.addEventListener("load",function(){return o(d.result)},!1),d.addEventListener("error",function(h){return s(h)},!1),d.readAsDataURL(c.response)}else s("Failed to proxy resource ".concat(r," with status code ").concat(c.status))},c.onerror=s;var u=i.indexOf("?")>-1?"&":"?";if(c.open("GET","".concat(i).concat(u,"url=").concat(encodeURIComponent(e),"&responseType=").concat(a)),a!=="text"&&c instanceof XMLHttpRequest&&(c.responseType=a),t._options.imageTimeout){var l=t._options.imageTimeout;c.timeout=l,c.ontimeout=function(){return s("Timed out (".concat(l,"ms) proxying ").concat(r))}}c.send()})},n}(),jN=/^data:image\/svg\+xml/i,VN=/^data:image\/.*;base64,/i,zN=/^data:image\/.*/i,qN=function(n){return bt.SUPPORT_SVG_DRAWING||!GN(n)},Lh=function(n){return zN.test(n)},WN=function(n){return VN.test(n)},Uh=function(n){return n.substr(0,4)==="blob"},GN=function(n){return n.substr(-3).toLowerCase()==="svg"||jN.test(n)},G=function(){function n(e,t){this.type=0,this.x=e,this.y=t}return n.prototype.add=function(e,t){return new n(this.x+e,this.y+t)},n}(),Yr=function(n,e,t){return new G(n.x+(e.x-n.x)*t,n.y+(e.y-n.y)*t)},Uc=function(){function n(e,t,i,r){this.type=1,this.start=e,this.startControl=t,this.endControl=i,this.end=r}return n.prototype.subdivide=function(e,t){var i=Yr(this.start,this.startControl,e),r=Yr(this.startControl,this.endControl,e),o=Yr(this.endControl,this.end,e),s=Yr(i,r,e),a=Yr(r,o,e),c=Yr(s,a,e);return t?new n(this.start,i,s,c):new n(c,a,o,this.end)},n.prototype.add=function(e,t){return new n(this.start.add(e,t),this.startControl.add(e,t),this.endControl.add(e,t),this.end.add(e,t))},n.prototype.reverse=function(){return new n(this.end,this.endControl,this.startControl,this.start)},n}(),Zt=function(n){return n.type===1},$N=function(){function n(e){var t=e.styles,i=e.bounds,r=ns(t.borderTopLeftRadius,i.width,i.height),o=r[0],s=r[1],a=ns(t.borderTopRightRadius,i.width,i.height),c=a[0],u=a[1],l=ns(t.borderBottomRightRadius,i.width,i.height),d=l[0],h=l[1],p=ns(t.borderBottomLeftRadius,i.width,i.height),m=p[0],f=p[1],g=[];g.push((o+c)/i.width),g.push((m+d)/i.width),g.push((s+f)/i.height),g.push((u+h)/i.height);var y=Math.max.apply(Math,g);y>1&&(o/=y,s/=y,c/=y,u/=y,d/=y,h/=y,m/=y,f/=y);var b=i.width-c,S=i.height-h,w=i.width-d,k=i.height-f,C=t.borderTopWidth,x=t.borderRightWidth,I=t.borderBottomWidth,P=t.borderLeftWidth,D=Ee(t.paddingTop,e.bounds.width),A=Ee(t.paddingRight,e.bounds.width),L=Ee(t.paddingBottom,e.bounds.width),V=Ee(t.paddingLeft,e.bounds.width);this.topLeftBorderDoubleOuterBox=o>0||s>0?qe(i.left+P/3,i.top+C/3,o-P/3,s-C/3,Se.TOP_LEFT):new G(i.left+P/3,i.top+C/3),this.topRightBorderDoubleOuterBox=o>0||s>0?qe(i.left+b,i.top+C/3,c-x/3,u-C/3,Se.TOP_RIGHT):new G(i.left+i.width-x/3,i.top+C/3),this.bottomRightBorderDoubleOuterBox=d>0||h>0?qe(i.left+w,i.top+S,d-x/3,h-I/3,Se.BOTTOM_RIGHT):new G(i.left+i.width-x/3,i.top+i.height-I/3),this.bottomLeftBorderDoubleOuterBox=m>0||f>0?qe(i.left+P/3,i.top+k,m-P/3,f-I/3,Se.BOTTOM_LEFT):new G(i.left+P/3,i.top+i.height-I/3),this.topLeftBorderDoubleInnerBox=o>0||s>0?qe(i.left+P*2/3,i.top+C*2/3,o-P*2/3,s-C*2/3,Se.TOP_LEFT):new G(i.left+P*2/3,i.top+C*2/3),this.topRightBorderDoubleInnerBox=o>0||s>0?qe(i.left+b,i.top+C*2/3,c-x*2/3,u-C*2/3,Se.TOP_RIGHT):new G(i.left+i.width-x*2/3,i.top+C*2/3),this.bottomRightBorderDoubleInnerBox=d>0||h>0?qe(i.left+w,i.top+S,d-x*2/3,h-I*2/3,Se.BOTTOM_RIGHT):new G(i.left+i.width-x*2/3,i.top+i.height-I*2/3),this.bottomLeftBorderDoubleInnerBox=m>0||f>0?qe(i.left+P*2/3,i.top+k,m-P*2/3,f-I*2/3,Se.BOTTOM_LEFT):new G(i.left+P*2/3,i.top+i.height-I*2/3),this.topLeftBorderStroke=o>0||s>0?qe(i.left+P/2,i.top+C/2,o-P/2,s-C/2,Se.TOP_LEFT):new G(i.left+P/2,i.top+C/2),this.topRightBorderStroke=o>0||s>0?qe(i.left+b,i.top+C/2,c-x/2,u-C/2,Se.TOP_RIGHT):new G(i.left+i.width-x/2,i.top+C/2),this.bottomRightBorderStroke=d>0||h>0?qe(i.left+w,i.top+S,d-x/2,h-I/2,Se.BOTTOM_RIGHT):new G(i.left+i.width-x/2,i.top+i.height-I/2),this.bottomLeftBorderStroke=m>0||f>0?qe(i.left+P/2,i.top+k,m-P/2,f-I/2,Se.BOTTOM_LEFT):new G(i.left+P/2,i.top+i.height-I/2),this.topLeftBorderBox=o>0||s>0?qe(i.left,i.top,o,s,Se.TOP_LEFT):new G(i.left,i.top),this.topRightBorderBox=c>0||u>0?qe(i.left+b,i.top,c,u,Se.TOP_RIGHT):new G(i.left+i.width,i.top),this.bottomRightBorderBox=d>0||h>0?qe(i.left+w,i.top+S,d,h,Se.BOTTOM_RIGHT):new G(i.left+i.width,i.top+i.height),this.bottomLeftBorderBox=m>0||f>0?qe(i.left,i.top+k,m,f,Se.BOTTOM_LEFT):new G(i.left,i.top+i.height),this.topLeftPaddingBox=o>0||s>0?qe(i.left+P,i.top+C,Math.max(0,o-P),Math.max(0,s-C),Se.TOP_LEFT):new G(i.left+P,i.top+C),this.topRightPaddingBox=c>0||u>0?qe(i.left+Math.min(b,i.width-x),i.top+C,b>i.width+x?0:Math.max(0,c-x),Math.max(0,u-C),Se.TOP_RIGHT):new G(i.left+i.width-x,i.top+C),this.bottomRightPaddingBox=d>0||h>0?qe(i.left+Math.min(w,i.width-P),i.top+Math.min(S,i.height-I),Math.max(0,d-x),Math.max(0,h-I),Se.BOTTOM_RIGHT):new G(i.left+i.width-x,i.top+i.height-I),this.bottomLeftPaddingBox=m>0||f>0?qe(i.left+P,i.top+Math.min(k,i.height-I),Math.max(0,m-P),Math.max(0,f-I),Se.BOTTOM_LEFT):new G(i.left+P,i.top+i.height-I),this.topLeftContentBox=o>0||s>0?qe(i.left+P+V,i.top+C+D,Math.max(0,o-(P+V)),Math.max(0,s-(C+D)),Se.TOP_LEFT):new G(i.left+P+V,i.top+C+D),this.topRightContentBox=c>0||u>0?qe(i.left+Math.min(b,i.width+P+V),i.top+C+D,b>i.width+P+V?0:c-P+V,u-(C+D),Se.TOP_RIGHT):new G(i.left+i.width-(x+A),i.top+C+D),this.bottomRightContentBox=d>0||h>0?qe(i.left+Math.min(w,i.width-(P+V)),i.top+Math.min(S,i.height+C+D),Math.max(0,d-(x+A)),h-(I+L),Se.BOTTOM_RIGHT):new G(i.left+i.width-(x+A),i.top+i.height-(I+L)),this.bottomLeftContentBox=m>0||f>0?qe(i.left+P+V,i.top+k,Math.max(0,m-(P+V)),f-(I+L),Se.BOTTOM_LEFT):new G(i.left+P+V,i.top+i.height-(I+L))}return n}(),Se;(function(n){n[n.TOP_LEFT=0]="TOP_LEFT",n[n.TOP_RIGHT=1]="TOP_RIGHT",n[n.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",n[n.BOTTOM_LEFT=3]="BOTTOM_LEFT"})(Se||(Se={}));var qe=function(n,e,t,i,r){var o=4*((Math.sqrt(2)-1)/3),s=t*o,a=i*o,c=n+t,u=e+i;switch(r){case Se.TOP_LEFT:return new Uc(new G(n,u),new G(n,u-a),new G(c-s,e),new G(c,e));case Se.TOP_RIGHT:return new Uc(new G(n,e),new G(n+s,e),new G(c,u-a),new G(c,u));case Se.BOTTOM_RIGHT:return new Uc(new G(c,e),new G(c,e+a),new G(n+s,u),new G(n,u));case Se.BOTTOM_LEFT:default:return new Uc(new G(c,u),new G(c-s,u),new G(n,e+a),new G(n,e))}},Fc=function(n){return[n.topLeftBorderBox,n.topRightBorderBox,n.bottomRightBorderBox,n.bottomLeftBorderBox]},HN=function(n){return[n.topLeftContentBox,n.topRightContentBox,n.bottomRightContentBox,n.bottomLeftContentBox]},Bc=function(n){return[n.topLeftPaddingBox,n.topRightPaddingBox,n.bottomRightPaddingBox,n.bottomLeftPaddingBox]},KN=function(){function n(e,t,i){this.offsetX=e,this.offsetY=t,this.matrix=i,this.type=0,this.target=6}return n}(),jc=function(){function n(e,t){this.path=e,this.target=t,this.type=1}return n}(),YN=function(){function n(e){this.opacity=e,this.type=2,this.target=6}return n}(),XN=function(n){return n.type===0},s_=function(n){return n.type===1},JN=function(n){return n.type===2},a_=function(n,e){return n.length===e.length?n.some(function(t,i){return t===e[i]}):!1},ZN=function(n,e,t,i,r){return n.map(function(o,s){switch(s){case 0:return o.add(e,t);case 1:return o.add(e+i,t);case 2:return o.add(e+i,t+r);case 3:return o.add(e,t+r)}return o})},c_=function(){function n(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]}return n}(),u_=function(){function n(e,t){if(this.container=e,this.parent=t,this.effects=[],this.curves=new $N(this.container),this.container.styles.opacity<1&&this.effects.push(new YN(this.container.styles.opacity)),this.container.styles.transform!==null){var i=this.container.bounds.left+this.container.styles.transformOrigin[0].number,r=this.container.bounds.top+this.container.styles.transformOrigin[1].number,o=this.container.styles.transform;this.effects.push(new KN(i,r,o))}if(this.container.styles.overflowX!==0){var s=Fc(this.curves),a=Bc(this.curves);a_(s,a)?this.effects.push(new jc(s,6)):(this.effects.push(new jc(s,2)),this.effects.push(new jc(a,4)))}}return n.prototype.getEffects=function(e){for(var t=[2,3].indexOf(this.container.styles.position)===-1,i=this.parent,r=this.effects.slice(0);i;){var o=i.effects.filter(function(c){return!s_(c)});if(t||i.container.styles.position!==0||!i.parent){if(t=[2,3].indexOf(i.container.styles.position)===-1,i.container.styles.overflowX!==0){var s=Fc(i.curves),a=Bc(i.curves);a_(s,a)||r.unshift(new jc(a,6))}r.unshift.apply(r,o)}else r.unshift.apply(r,o);i=i.parent}return r.filter(function(c){return ut(c.target,e)})},n}(),Fh=function(n,e,t,i){n.container.elements.forEach(function(r){var o=ut(r.flags,4),s=ut(r.flags,2),a=new u_(r,n);ut(r.styles.display,2048)&&i.push(a);var c=ut(r.flags,8)?[]:i;if(o||s){var u=o||r.styles.isPositioned()?t:e,l=new c_(a);if(r.styles.isPositioned()||r.styles.opacity<1||r.styles.isTransformed()){var d=r.styles.zIndex.order;if(d<0){var h=0;u.negativeZIndex.some(function(m,f){return d>m.element.container.styles.zIndex.order?(h=f,!1):h>0}),u.negativeZIndex.splice(h,0,l)}else if(d>0){var p=0;u.positiveZIndex.some(function(m,f){return d>=m.element.container.styles.zIndex.order?(p=f+1,!1):p>0}),u.positiveZIndex.splice(p,0,l)}else u.zeroOrAutoZIndexOrTransformedOrOpacity.push(l)}else r.styles.isFloating()?u.nonPositionedFloats.push(l):u.nonPositionedInlineLevel.push(l);Fh(a,l,o?l:t,c)}else r.styles.isInlineLevel()?e.inlineLevel.push(a):e.nonInlineLevel.push(a),Fh(a,e,t,c);ut(r.flags,8)&&l_(r,c)})},l_=function(n,e){for(var t=n instanceof xh?n.start:1,i=n instanceof xh?n.reversed:!1,r=0;r<e.length;r++){var o=e[r];o.container instanceof Lb&&typeof o.container.value=="number"&&o.container.value!==0&&(t=o.container.value),o.listValue=as(t,o.container.styles.listStyleType,!0),t+=i?-1:1}},QN=function(n){var e=new u_(n,null),t=new c_(e),i=[];return Fh(e,t,t,i),l_(e.container,i),t},d_=function(n,e){switch(e){case 0:return Qt(n.topLeftBorderBox,n.topLeftPaddingBox,n.topRightBorderBox,n.topRightPaddingBox);case 1:return Qt(n.topRightBorderBox,n.topRightPaddingBox,n.bottomRightBorderBox,n.bottomRightPaddingBox);case 2:return Qt(n.bottomRightBorderBox,n.bottomRightPaddingBox,n.bottomLeftBorderBox,n.bottomLeftPaddingBox);case 3:default:return Qt(n.bottomLeftBorderBox,n.bottomLeftPaddingBox,n.topLeftBorderBox,n.topLeftPaddingBox)}},eD=function(n,e){switch(e){case 0:return Qt(n.topLeftBorderBox,n.topLeftBorderDoubleOuterBox,n.topRightBorderBox,n.topRightBorderDoubleOuterBox);case 1:return Qt(n.topRightBorderBox,n.topRightBorderDoubleOuterBox,n.bottomRightBorderBox,n.bottomRightBorderDoubleOuterBox);case 2:return Qt(n.bottomRightBorderBox,n.bottomRightBorderDoubleOuterBox,n.bottomLeftBorderBox,n.bottomLeftBorderDoubleOuterBox);case 3:default:return Qt(n.bottomLeftBorderBox,n.bottomLeftBorderDoubleOuterBox,n.topLeftBorderBox,n.topLeftBorderDoubleOuterBox)}},tD=function(n,e){switch(e){case 0:return Qt(n.topLeftBorderDoubleInnerBox,n.topLeftPaddingBox,n.topRightBorderDoubleInnerBox,n.topRightPaddingBox);case 1:return Qt(n.topRightBorderDoubleInnerBox,n.topRightPaddingBox,n.bottomRightBorderDoubleInnerBox,n.bottomRightPaddingBox);case 2:return Qt(n.bottomRightBorderDoubleInnerBox,n.bottomRightPaddingBox,n.bottomLeftBorderDoubleInnerBox,n.bottomLeftPaddingBox);case 3:default:return Qt(n.bottomLeftBorderDoubleInnerBox,n.bottomLeftPaddingBox,n.topLeftBorderDoubleInnerBox,n.topLeftPaddingBox)}},nD=function(n,e){switch(e){case 0:return Vc(n.topLeftBorderStroke,n.topRightBorderStroke);case 1:return Vc(n.topRightBorderStroke,n.bottomRightBorderStroke);case 2:return Vc(n.bottomRightBorderStroke,n.bottomLeftBorderStroke);case 3:default:return Vc(n.bottomLeftBorderStroke,n.topLeftBorderStroke)}},Vc=function(n,e){var t=[];return Zt(n)?t.push(n.subdivide(.5,!1)):t.push(n),Zt(e)?t.push(e.subdivide(.5,!0)):t.push(e),t},Qt=function(n,e,t,i){var r=[];return Zt(n)?r.push(n.subdivide(.5,!1)):r.push(n),Zt(t)?r.push(t.subdivide(.5,!0)):r.push(t),Zt(i)?r.push(i.subdivide(.5,!0).reverse()):r.push(i),Zt(e)?r.push(e.subdivide(.5,!1).reverse()):r.push(e),r},h_=function(n){var e=n.bounds,t=n.styles;return e.add(t.borderLeftWidth,t.borderTopWidth,-(t.borderRightWidth+t.borderLeftWidth),-(t.borderTopWidth+t.borderBottomWidth))},zc=function(n){var e=n.styles,t=n.bounds,i=Ee(e.paddingLeft,t.width),r=Ee(e.paddingRight,t.width),o=Ee(e.paddingTop,t.width),s=Ee(e.paddingBottom,t.width);return t.add(i+e.borderLeftWidth,o+e.borderTopWidth,-(e.borderRightWidth+e.borderLeftWidth+i+r),-(e.borderTopWidth+e.borderBottomWidth+o+s))},iD=function(n,e){return n===0?e.bounds:n===2?zc(e):h_(e)},rD=function(n,e){return n===0?e.bounds:n===2?zc(e):h_(e)},Bh=function(n,e,t){var i=iD(Jr(n.styles.backgroundOrigin,e),n),r=rD(Jr(n.styles.backgroundClip,e),n),o=oD(Jr(n.styles.backgroundSize,e),t,i),s=o[0],a=o[1],c=ns(Jr(n.styles.backgroundPosition,e),i.width-s,i.height-a),u=sD(Jr(n.styles.backgroundRepeat,e),c,o,i,r),l=Math.round(i.left+c[0]),d=Math.round(i.top+c[1]);return s=Math.max(1,s),a=Math.max(1,a),[u,l,d,s,a]},Xr=function(n){return ue(n)&&n.value===Gr.AUTO},qc=function(n){return typeof n=="number"},oD=function(n,e,t){var i=e[0],r=e[1],o=e[2],s=n[0],a=n[1];if(!s)return[0,0];if(Fe(s)&&a&&Fe(a))return[Ee(s,t.width),Ee(a,t.height)];var c=qc(o);if(ue(s)&&(s.value===Gr.CONTAIN||s.value===Gr.COVER)){if(qc(o)){var u=t.width/t.height;return u<o!=(s.value===Gr.COVER)?[t.width,t.width/o]:[t.height*o,t.height]}return[t.width,t.height]}var l=qc(i),d=qc(r),h=l||d;if(Xr(s)&&(!a||Xr(a))){if(l&&d)return[i,r];if(!c&&!h)return[t.width,t.height];if(h&&c){var p=l?i:r*o,m=d?r:i/o;return[p,m]}var f=l?i:t.width,g=d?r:t.height;return[f,g]}if(c){var y=0,b=0;return Fe(s)?y=Ee(s,t.width):Fe(a)&&(b=Ee(a,t.height)),Xr(s)?y=b*o:(!a||Xr(a))&&(b=y/o),[y,b]}var S=null,w=null;if(Fe(s)?S=Ee(s,t.width):a&&Fe(a)&&(w=Ee(a,t.height)),S!==null&&(!a||Xr(a))&&(w=l&&d?S/i*r:t.height),w!==null&&Xr(s)&&(S=l&&d?w/r*i:t.width),S!==null&&w!==null)return[S,w];throw new Error("Unable to calculate background-size for element")},Jr=function(n,e){var t=n[e];return typeof t>"u"?n[0]:t},sD=function(n,e,t,i,r){var o=e[0],s=e[1],a=t[0],c=t[1];switch(n){case 2:return[new G(Math.round(i.left),Math.round(i.top+s)),new G(Math.round(i.left+i.width),Math.round(i.top+s)),new G(Math.round(i.left+i.width),Math.round(c+i.top+s)),new G(Math.round(i.left),Math.round(c+i.top+s))];case 3:return[new G(Math.round(i.left+o),Math.round(i.top)),new G(Math.round(i.left+o+a),Math.round(i.top)),new G(Math.round(i.left+o+a),Math.round(i.height+i.top)),new G(Math.round(i.left+o),Math.round(i.height+i.top))];case 1:return[new G(Math.round(i.left+o),Math.round(i.top+s)),new G(Math.round(i.left+o+a),Math.round(i.top+s)),new G(Math.round(i.left+o+a),Math.round(i.top+s+c)),new G(Math.round(i.left+o),Math.round(i.top+s+c))];default:return[new G(Math.round(r.left),Math.round(r.top)),new G(Math.round(r.left+r.width),Math.round(r.top)),new G(Math.round(r.left+r.width),Math.round(r.height+r.top)),new G(Math.round(r.left),Math.round(r.height+r.top))]}},aD="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",p_="Hidden Text",cD=function(){function n(e){this._data={},this._document=e}return n.prototype.parseMetrics=function(e,t){var i=this._document.createElement("div"),r=this._document.createElement("img"),o=this._document.createElement("span"),s=this._document.body;i.style.visibility="hidden",i.style.fontFamily=e,i.style.fontSize=t,i.style.margin="0",i.style.padding="0",i.style.whiteSpace="nowrap",s.appendChild(i),r.src=aD,r.width=1,r.height=1,r.style.margin="0",r.style.padding="0",r.style.verticalAlign="baseline",o.style.fontFamily=e,o.style.fontSize=t,o.style.margin="0",o.style.padding="0",o.appendChild(this._document.createTextNode(p_)),i.appendChild(o),i.appendChild(r);var a=r.offsetTop-o.offsetTop+2;i.removeChild(o),i.appendChild(this._document.createTextNode(p_)),i.style.lineHeight="normal",r.style.verticalAlign="super";var c=r.offsetTop-i.offsetTop+2;return s.removeChild(i),{baseline:a,middle:c}},n.prototype.getMetrics=function(e,t){var i="".concat(e," ").concat(t);return typeof this._data[i]>"u"&&(this._data[i]=this.parseMetrics(e,t)),this._data[i]},n}(),f_=function(){function n(e,t){this.context=e,this.options=t}return n}(),uD=1e4,lD=function(n){an(e,n);function e(t,i){var r=n.call(this,t,i)||this;return r._activeEffects=[],r.canvas=i.canvas?i.canvas:document.createElement("canvas"),r.ctx=r.canvas.getContext("2d"),i.canvas||(r.canvas.width=Math.floor(i.width*i.scale),r.canvas.height=Math.floor(i.height*i.scale),r.canvas.style.width="".concat(i.width,"px"),r.canvas.style.height="".concat(i.height,"px")),r.fontMetrics=new cD(document),r.ctx.scale(r.options.scale,r.options.scale),r.ctx.translate(-i.x,-i.y),r.ctx.textBaseline="bottom",r._activeEffects=[],r.context.logger.debug("Canvas renderer initialized (".concat(i.width,"x").concat(i.height,") with scale ").concat(i.scale)),r}return e.prototype.applyEffects=function(t){for(var i=this;this._activeEffects.length;)this.popEffect();t.forEach(function(r){return i.applyEffect(r)})},e.prototype.applyEffect=function(t){this.ctx.save(),JN(t)&&(this.ctx.globalAlpha=t.opacity),XN(t)&&(this.ctx.translate(t.offsetX,t.offsetY),this.ctx.transform(t.matrix[0],t.matrix[1],t.matrix[2],t.matrix[3],t.matrix[4],t.matrix[5]),this.ctx.translate(-t.offsetX,-t.offsetY)),s_(t)&&(this.path(t.path),this.ctx.clip()),this._activeEffects.push(t)},e.prototype.popEffect=function(){this._activeEffects.pop(),this.ctx.restore()},e.prototype.renderStack=function(t){return Mt(this,void 0,void 0,function(){var i;return xt(this,function(r){switch(r.label){case 0:return i=t.element.container.styles,i.isVisible()?[4,this.renderStackContent(t)]:[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}})})},e.prototype.renderNode=function(t){return Mt(this,void 0,void 0,function(){return xt(this,function(i){switch(i.label){case 0:return ut(t.container.flags,16),t.container.styles.isVisible()?[4,this.renderNodeBackgroundAndBorders(t)]:[3,3];case 1:return i.sent(),[4,this.renderNodeContent(t)];case 2:i.sent(),i.label=3;case 3:return[2]}})})},e.prototype.renderTextWithLetterSpacing=function(t,i,r){var o=this;if(i===0)navigator.userAgent.indexOf("Firefox")===-1?(this.ctx.textBaseline="ideographic",this.ctx.fillText(t.text,t.bounds.left,t.bounds.top+t.bounds.height)):this.ctx.fillText(t.text,t.bounds.left,t.bounds.top+r);else{var s=Th(t.text);s.reduce(function(a,c){return o.ctx.fillText(c,a,t.bounds.top+r),a+o.ctx.measureText(c).width},t.bounds.left)}},e.prototype.createFontStyle=function(t){var i=t.fontVariant.filter(function(s){return s==="normal"||s==="small-caps"}).join(""),r=mD(t.fontFamily).join(", "),o=gi(t.fontSize)?"".concat(t.fontSize.number).concat(t.fontSize.unit):"".concat(t.fontSize.number,"px");return[[t.fontStyle,i,t.fontWeight,o,r].join(" "),r,o]},e.prototype.renderTextNode=function(t,i){return Mt(this,void 0,void 0,function(){var r,o,s=this;return xt(this,function(a){return r=this.createFontStyle(i)[0],this.ctx.font=r,this.ctx.direction=i.direction===1?"rtl":"ltr",this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic",o=i.paintOrder,t.textBounds.forEach(function(c){o.forEach(function(u){switch(u){case 0:s.ctx.fillStyle=pt(i.color),s.renderTextWithLetterSpacing(c,i.letterSpacing,i.fontSize.number);var l=i.textShadow;if(l.length&&c.text.trim().length&&(l.slice(0).reverse().forEach(function(h){s.ctx.shadowColor=pt(h.color),s.ctx.shadowOffsetX=h.offsetX.number*s.options.scale,s.ctx.shadowOffsetY=h.offsetY.number*s.options.scale,s.ctx.shadowBlur=h.blur.number,s.renderTextWithLetterSpacing(c,i.letterSpacing,i.fontSize.number)}),s.ctx.shadowColor="",s.ctx.shadowOffsetX=0,s.ctx.shadowOffsetY=0,s.ctx.shadowBlur=0),i.textDecorationLine.length){s.ctx.fillStyle=pt(i.textDecorationColor||i.color);var d=1;i.textDecorationLine.forEach(function(h){switch(h){case 1:s.ctx.fillRect(c.bounds.left,c.bounds.top+c.bounds.height-d,c.bounds.width,d);break;case 2:s.ctx.fillRect(c.bounds.left,c.bounds.top,c.bounds.width,d);break;case 3:s.ctx.fillRect(c.bounds.left,c.bounds.top+(c.bounds.height/2-d/2),c.bounds.width,d);break}})}break;case 1:i.webkitTextStrokeWidth&&c.text.trim().length&&(s.ctx.strokeStyle=pt(i.webkitTextStrokeColor),s.ctx.lineWidth=i.webkitTextStrokeWidth,s.ctx.lineJoin=window.chrome?"miter":"round",s.ctx.strokeText(c.text,c.bounds.left,c.bounds.top+c.bounds.height)),s.ctx.strokeStyle="",s.ctx.lineWidth=0,s.ctx.lineJoin="miter";break}})}),[2]})})},e.prototype.renderReplacedElement=function(t,i,r){var o=r.naturalWidth||t.intrinsicWidth,s=r.naturalHeight||t.intrinsicHeight;if(r&&o>0&&s>0){var a=zc(t),c=Bc(i);this.path(c),this.ctx.save(),this.ctx.clip();var u=0,l=0,d=o,h=s,p=a.left,m=a.top,f=a.width,g=a.height,y=t.styles.objectFit,b=f/g,S=d/h;if(y===2)S>b?(g=f/S,m+=(a.height-g)/2):(f=g*S,p+=(a.width-f)/2);else if(y===4)S>b?(d=h*b,u+=(o-d)/2):(h=d/b,l+=(s-h)/2);else if(y===8)d>f?(u+=(d-f)/2,d=f):(p+=(f-d)/2,f=d),h>g?(l+=(h-g)/2,h=g):(m+=(g-h)/2,g=h);else if(y===16){var w=S>b?f:g*S,k=d>f?d:f;w<k?S>b?(g=f/S,m+=(a.height-g)/2):(f=g*S,p+=(a.width-f)/2):(d>f?(u+=(d-f)/2,d=f):(p+=(f-d)/2,f=d),h>g?(l+=(h-g)/2,h=g):(m+=(g-h)/2,g=h))}this.ctx.drawImage(r,u,l,d,h,p,m,f,g),this.ctx.restore()}},e.prototype.renderNodeContent=function(t){return Mt(this,void 0,void 0,function(){var i,r,o,s,a,c,S,S,u,l,d,h,k,p,m,f,C,g,y,b,S,w,k,C;return xt(this,function(x){switch(x.label){case 0:this.applyEffects(t.getEffects(4)),i=t.container,r=t.curves,o=i.styles,s=0,a=i.textNodes,x.label=1;case 1:return s<a.length?(c=a[s],[4,this.renderTextNode(c,o)]):[3,4];case 2:x.sent(),x.label=3;case 3:return s++,[3,1];case 4:if(!(i instanceof Mb))return[3,8];x.label=5;case 5:return x.trys.push([5,7,,8]),[4,this.context.cache.match(i.src)];case 6:return S=x.sent(),this.renderReplacedElement(i,r,S),[3,8];case 7:return x.sent(),this.context.logger.error("Error loading image ".concat(i.src)),[3,8];case 8:if(i instanceof Nb&&this.renderReplacedElement(i,r,i.canvas),!(i instanceof Db))return[3,12];x.label=9;case 9:return x.trys.push([9,11,,12]),[4,this.context.cache.match(i.svg)];case 10:return S=x.sent(),this.renderReplacedElement(i,r,S),[3,12];case 11:return x.sent(),this.context.logger.error("Error loading svg ".concat(i.svg.substring(0,255))),[3,12];case 12:return i instanceof jb&&i.tree?(u=new e(this.context,{scale:this.options.scale,backgroundColor:i.backgroundColor,x:0,y:0,width:i.width,height:i.height}),[4,u.render(i.tree)]):[3,14];case 13:l=x.sent(),i.width&&i.height&&this.ctx.drawImage(l,0,0,i.width,i.height,i.bounds.left,i.bounds.top,i.bounds.width,i.bounds.height),x.label=14;case 14:if(i instanceof Eh&&(d=Math.min(i.bounds.width,i.bounds.height),i.type===Oc?i.checked&&(this.ctx.save(),this.path([new G(i.bounds.left+d*.39363,i.bounds.top+d*.79),new G(i.bounds.left+d*.16,i.bounds.top+d*.5549),new G(i.bounds.left+d*.27347,i.bounds.top+d*.44071),new G(i.bounds.left+d*.39694,i.bounds.top+d*.5649),new G(i.bounds.left+d*.72983,i.bounds.top+d*.23),new G(i.bounds.left+d*.84,i.bounds.top+d*.34085),new G(i.bounds.left+d*.39363,i.bounds.top+d*.79)]),this.ctx.fillStyle=pt(Ub),this.ctx.fill(),this.ctx.restore()):i.type===Ac&&i.checked&&(this.ctx.save(),this.ctx.beginPath(),this.ctx.arc(i.bounds.left+d/2,i.bounds.top+d/2,d/4,0,Math.PI*2,!0),this.ctx.fillStyle=pt(Ub),this.ctx.fill(),this.ctx.restore())),dD(i)&&i.value.length){switch(h=this.createFontStyle(o),k=h[0],p=h[1],m=h[2],f=this.fontMetrics.getMetrics(p,m).baseline,this.ctx.font=k,this.ctx.fillStyle=pt(o.color),this.ctx.textBaseline="alphabetic",this.ctx.textAlign=pD(i.styles.textAlign),C=zc(i),g=0,i.styles.textAlign){case 1:g+=C.width/2;break;case 2:g+=C.width;break}y=C.add(g,0,0,-C.height/2+1),this.ctx.save(),this.path([new G(C.left,C.top),new G(C.left+C.width,C.top),new G(C.left+C.width,C.top+C.height),new G(C.left,C.top+C.height)]),this.ctx.clip(),this.renderTextWithLetterSpacing(new os(i.value,y),o.letterSpacing,f),this.ctx.restore(),this.ctx.textBaseline="alphabetic",this.ctx.textAlign="left"}if(!ut(i.styles.display,2048))return[3,20];if(i.styles.listStyleImage===null)return[3,19];if(b=i.styles.listStyleImage,b.type!==0)return[3,18];S=void 0,w=b.url,x.label=15;case 15:return x.trys.push([15,17,,18]),[4,this.context.cache.match(w)];case 16:return S=x.sent(),this.ctx.drawImage(S,i.bounds.left-(S.width+10),i.bounds.top),[3,18];case 17:return x.sent(),this.context.logger.error("Error loading list-style-image ".concat(w)),[3,18];case 18:return[3,20];case 19:t.listValue&&i.styles.listStyleType!==-1&&(k=this.createFontStyle(o)[0],this.ctx.font=k,this.ctx.fillStyle=pt(o.color),this.ctx.textBaseline="middle",this.ctx.textAlign="right",C=new Gn(i.bounds.left,i.bounds.top+Ee(i.styles.paddingTop,i.bounds.width),i.bounds.width,gb(o.lineHeight,o.fontSize.number)/2+1),this.renderTextWithLetterSpacing(new os(t.listValue,C),o.letterSpacing,gb(o.lineHeight,o.fontSize.number)/2+2),this.ctx.textBaseline="bottom",this.ctx.textAlign="left"),x.label=20;case 20:return[2]}})})},e.prototype.renderStackContent=function(t){return Mt(this,void 0,void 0,function(){var i,r,y,o,s,y,a,c,y,u,l,y,d,h,y,p,m,y,f,g,y;return xt(this,function(b){switch(b.label){case 0:return ut(t.element.container.flags,16),[4,this.renderNodeBackgroundAndBorders(t.element)];case 1:b.sent(),i=0,r=t.negativeZIndex,b.label=2;case 2:return i<r.length?(y=r[i],[4,this.renderStack(y)]):[3,5];case 3:b.sent(),b.label=4;case 4:return i++,[3,2];case 5:return[4,this.renderNodeContent(t.element)];case 6:b.sent(),o=0,s=t.nonInlineLevel,b.label=7;case 7:return o<s.length?(y=s[o],[4,this.renderNode(y)]):[3,10];case 8:b.sent(),b.label=9;case 9:return o++,[3,7];case 10:a=0,c=t.nonPositionedFloats,b.label=11;case 11:return a<c.length?(y=c[a],[4,this.renderStack(y)]):[3,14];case 12:b.sent(),b.label=13;case 13:return a++,[3,11];case 14:u=0,l=t.nonPositionedInlineLevel,b.label=15;case 15:return u<l.length?(y=l[u],[4,this.renderStack(y)]):[3,18];case 16:b.sent(),b.label=17;case 17:return u++,[3,15];case 18:d=0,h=t.inlineLevel,b.label=19;case 19:return d<h.length?(y=h[d],[4,this.renderNode(y)]):[3,22];case 20:b.sent(),b.label=21;case 21:return d++,[3,19];case 22:p=0,m=t.zeroOrAutoZIndexOrTransformedOrOpacity,b.label=23;case 23:return p<m.length?(y=m[p],[4,this.renderStack(y)]):[3,26];case 24:b.sent(),b.label=25;case 25:return p++,[3,23];case 26:f=0,g=t.positiveZIndex,b.label=27;case 27:return f<g.length?(y=g[f],[4,this.renderStack(y)]):[3,30];case 28:b.sent(),b.label=29;case 29:return f++,[3,27];case 30:return[2]}})})},e.prototype.mask=function(t){this.ctx.beginPath(),this.ctx.moveTo(0,0),this.ctx.lineTo(this.canvas.width,0),this.ctx.lineTo(this.canvas.width,this.canvas.height),this.ctx.lineTo(0,this.canvas.height),this.ctx.lineTo(0,0),this.formatPath(t.slice(0).reverse()),this.ctx.closePath()},e.prototype.path=function(t){this.ctx.beginPath(),this.formatPath(t),this.ctx.closePath()},e.prototype.formatPath=function(t){var i=this;t.forEach(function(r,o){var s=Zt(r)?r.start:r;o===0?i.ctx.moveTo(s.x,s.y):i.ctx.lineTo(s.x,s.y),Zt(r)&&i.ctx.bezierCurveTo(r.startControl.x,r.startControl.y,r.endControl.x,r.endControl.y,r.end.x,r.end.y)})},e.prototype.renderRepeat=function(t,i,r,o){this.path(t),this.ctx.fillStyle=i,this.ctx.translate(r,o),this.ctx.fill(),this.ctx.translate(-r,-o)},e.prototype.resizeImage=function(t,i,r){var o,s=(o=this.canvas.ownerDocument)!==null&&o!==void 0?o:document,a=s.createElement("canvas");a.width=Math.max(1,i),a.height=Math.max(1,r);var c=a.getContext("2d");return c.drawImage(t,0,0,t.width,t.height,0,0,i,r),a},e.prototype.renderBackgroundImage=function(t){return Mt(this,void 0,void 0,function(){var i,r,o,s,a,c;return xt(this,function(u){switch(u.label){case 0:i=t.styles.backgroundImage.length-1,r=function(l){var d,h,p,m,f,L,K,Q,O,F,D,g,L,K,Q,O,F,y,b,S,w,k,C,x,I,P,D,A,L,V,Y,O,F,X,K,Q,Ce,Ge,Ie,dt,Me,Pe,ie,Ze;return xt(this,function(kt){switch(kt.label){case 0:if(l.type!==0)return[3,5];d=void 0,h=l.url,kt.label=1;case 1:return kt.trys.push([1,3,,4]),[4,o.context.cache.match(h)];case 2:return d=kt.sent(),[3,4];case 3:return kt.sent(),o.context.logger.error("Error loading background-image ".concat(h)),[3,4];case 4:return d&&(p=isNaN(d.width)||d.width===0?1:d.width,m=isNaN(d.height)||d.height===0?1:d.height,f=Bh(t,i,[p,m,p/m]),L=f[0],K=f[1],Q=f[2],O=f[3],F=f[4],D=o.ctx.createPattern(o.resizeImage(d,O,F),"repeat"),o.renderRepeat(L,D,K,Q)),[3,6];case 5:lA(l)?(g=Bh(t,i,[null,null,null]),L=g[0],K=g[1],Q=g[2],O=g[3],F=g[4],y=oA(l.angle,O,F),b=y[0],S=y[1],w=y[2],k=y[3],C=y[4],x=document.createElement("canvas"),x.width=O,x.height=F,I=x.getContext("2d"),P=I.createLinearGradient(S,k,w,C),ob(l.stops,b||1).forEach(function(Gt){return P.addColorStop(Gt.stop,pt(Gt.color))}),I.fillStyle=P,I.fillRect(0,0,O,F),O>0&&F>0&&(D=o.ctx.createPattern(x,"repeat"),o.renderRepeat(L,D,K,Q))):dA(l)&&(A=Bh(t,i,[null,null,null]),L=A[0],V=A[1],Y=A[2],O=A[3],F=A[4],X=l.position.length===0?[uh]:l.position,K=Ee(X[0],O),Q=Ee(X[X.length-1],F),Ce=sA(l,K,Q,O,F),Ge=Ce[0],Ie=Ce[1],Ge>0&&Ie>0&&(dt=o.ctx.createRadialGradient(V+K,Y+Q,0,V+K,Y+Q,Ge),ob(l.stops,Ge*2).forEach(function(Gt){return dt.addColorStop(Gt.stop,pt(Gt.color))}),o.path(L),o.ctx.fillStyle=dt,Ge!==Ie?(Me=t.bounds.left+.5*t.bounds.width,Pe=t.bounds.top+.5*t.bounds.height,ie=Ie/Ge,Ze=1/ie,o.ctx.save(),o.ctx.translate(Me,Pe),o.ctx.transform(1,0,0,ie,0,0),o.ctx.translate(-Me,-Pe),o.ctx.fillRect(V,Ze*(Y-Pe)+Pe,O,F*Ze),o.ctx.restore()):o.ctx.fill())),kt.label=6;case 6:return i--,[2]}})},o=this,s=0,a=t.styles.backgroundImage.slice(0).reverse(),u.label=1;case 1:return s<a.length?(c=a[s],[5,r(c)]):[3,4];case 2:u.sent(),u.label=3;case 3:return s++,[3,1];case 4:return[2]}})})},e.prototype.renderSolidBorder=function(t,i,r){return Mt(this,void 0,void 0,function(){return xt(this,function(o){return this.path(d_(r,i)),this.ctx.fillStyle=pt(t),this.ctx.fill(),[2]})})},e.prototype.renderDoubleBorder=function(t,i,r,o){return Mt(this,void 0,void 0,function(){var s,a;return xt(this,function(c){switch(c.label){case 0:return i<3?[4,this.renderSolidBorder(t,r,o)]:[3,2];case 1:return c.sent(),[2];case 2:return s=eD(o,r),this.path(s),this.ctx.fillStyle=pt(t),this.ctx.fill(),a=tD(o,r),this.path(a),this.ctx.fill(),[2]}})})},e.prototype.renderNodeBackgroundAndBorders=function(t){return Mt(this,void 0,void 0,function(){var i,r,o,s,a,c,u,l,d=this;return xt(this,function(h){switch(h.label){case 0:return this.applyEffects(t.getEffects(2)),i=t.container.styles,r=!bi(i.backgroundColor)||i.backgroundImage.length,o=[{style:i.borderTopStyle,color:i.borderTopColor,width:i.borderTopWidth},{style:i.borderRightStyle,color:i.borderRightColor,width:i.borderRightWidth},{style:i.borderBottomStyle,color:i.borderBottomColor,width:i.borderBottomWidth},{style:i.borderLeftStyle,color:i.borderLeftColor,width:i.borderLeftWidth}],s=hD(Jr(i.backgroundClip,0),t.curves),r||i.boxShadow.length?(this.ctx.save(),this.path(s),this.ctx.clip(),bi(i.backgroundColor)||(this.ctx.fillStyle=pt(i.backgroundColor),this.ctx.fill()),[4,this.renderBackgroundImage(t.container)]):[3,2];case 1:h.sent(),this.ctx.restore(),i.boxShadow.slice(0).reverse().forEach(function(p){d.ctx.save();var m=Fc(t.curves),f=p.inset?0:uD,g=ZN(m,-f+(p.inset?1:-1)*p.spread.number,(p.inset?1:-1)*p.spread.number,p.spread.number*(p.inset?-2:2),p.spread.number*(p.inset?-2:2));p.inset?(d.path(m),d.ctx.clip(),d.mask(g)):(d.mask(m),d.ctx.clip(),d.path(g)),d.ctx.shadowOffsetX=p.offsetX.number+f,d.ctx.shadowOffsetY=p.offsetY.number,d.ctx.shadowColor=pt(p.color),d.ctx.shadowBlur=p.blur.number,d.ctx.fillStyle=p.inset?pt(p.color):"rgba(0,0,0,1)",d.ctx.fill(),d.ctx.restore()}),h.label=2;case 2:a=0,c=0,u=o,h.label=3;case 3:return c<u.length?(l=u[c],l.style!==0&&!bi(l.color)&&l.width>0?l.style!==2?[3,5]:[4,this.renderDashedDottedBorder(l.color,l.width,a,t.curves,2)]:[3,11]):[3,13];case 4:return h.sent(),[3,11];case 5:return l.style!==3?[3,7]:[4,this.renderDashedDottedBorder(l.color,l.width,a,t.curves,3)];case 6:return h.sent(),[3,11];case 7:return l.style!==4?[3,9]:[4,this.renderDoubleBorder(l.color,l.width,a,t.curves)];case 8:return h.sent(),[3,11];case 9:return[4,this.renderSolidBorder(l.color,a,t.curves)];case 10:h.sent(),h.label=11;case 11:a++,h.label=12;case 12:return c++,[3,3];case 13:return[2]}})})},e.prototype.renderDashedDottedBorder=function(t,i,r,o,s){return Mt(this,void 0,void 0,function(){var a,c,u,l,d,h,p,m,f,g,y,b,S,w,k,C,k,C;return xt(this,function(x){return this.ctx.save(),a=nD(o,r),c=d_(o,r),s===2&&(this.path(c),this.ctx.clip()),Zt(c[0])?(u=c[0].start.x,l=c[0].start.y):(u=c[0].x,l=c[0].y),Zt(c[1])?(d=c[1].end.x,h=c[1].end.y):(d=c[1].x,h=c[1].y),r===0||r===2?p=Math.abs(u-d):p=Math.abs(l-h),this.ctx.beginPath(),s===3?this.formatPath(a):this.formatPath(c.slice(0,2)),m=i<3?i*3:i*2,f=i<3?i*2:i,s===3&&(m=i,f=i),g=!0,p<=m*2?g=!1:p<=m*2+f?(y=p/(2*m+f),m*=y,f*=y):(b=Math.floor((p+f)/(m+f)),S=(p-b*m)/(b-1),w=(p-(b+1)*m)/b,f=w<=0||Math.abs(f-S)<Math.abs(f-w)?S:w),g&&(s===3?this.ctx.setLineDash([0,m+f]):this.ctx.setLineDash([m,f])),s===3?(this.ctx.lineCap="round",this.ctx.lineWidth=i):this.ctx.lineWidth=i*2+1.1,this.ctx.strokeStyle=pt(t),this.ctx.stroke(),this.ctx.setLineDash([]),s===2&&(Zt(c[0])&&(k=c[3],C=c[0],this.ctx.beginPath(),this.formatPath([new G(k.end.x,k.end.y),new G(C.start.x,C.start.y)]),this.ctx.stroke()),Zt(c[1])&&(k=c[1],C=c[2],this.ctx.beginPath(),this.formatPath([new G(k.end.x,k.end.y),new G(C.start.x,C.start.y)]),this.ctx.stroke())),this.ctx.restore(),[2]})})},e.prototype.render=function(t){return Mt(this,void 0,void 0,function(){var i;return xt(this,function(r){switch(r.label){case 0:return this.options.backgroundColor&&(this.ctx.fillStyle=pt(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height)),i=QN(t),[4,this.renderStack(i)];case 1:return r.sent(),this.applyEffects([]),[2,this.canvas]}})})},e}(f_),dD=function(n){return n instanceof Bb||n instanceof Fb?!0:n instanceof Eh&&n.type!==Ac&&n.type!==Oc},hD=function(n,e){switch(n){case 0:return Fc(e);case 2:return HN(e);case 1:default:return Bc(e)}},pD=function(n){switch(n){case 1:return"center";case 2:return"right";case 0:default:return"left"}},fD=["-apple-system","system-ui"],mD=function(n){return/iPhone OS 15_(0|1)/.test(window.navigator.userAgent)?n.filter(function(e){return fD.indexOf(e)===-1}):n},gD=function(n){an(e,n);function e(t,i){var r=n.call(this,t,i)||this;return r.canvas=i.canvas?i.canvas:document.createElement("canvas"),r.ctx=r.canvas.getContext("2d"),r.options=i,r.canvas.width=Math.floor(i.width*i.scale),r.canvas.height=Math.floor(i.height*i.scale),r.canvas.style.width="".concat(i.width,"px"),r.canvas.style.height="".concat(i.height,"px"),r.ctx.scale(r.options.scale,r.options.scale),r.ctx.translate(-i.x,-i.y),r.context.logger.debug("EXPERIMENTAL ForeignObject renderer initialized (".concat(i.width,"x").concat(i.height," at ").concat(i.x,",").concat(i.y,") with scale ").concat(i.scale)),r}return e.prototype.render=function(t){return Mt(this,void 0,void 0,function(){var i,r;return xt(this,function(o){switch(o.label){case 0:return i=Ch(this.options.width*this.options.scale,this.options.height*this.options.scale,this.options.scale,this.options.scale,t),[4,vD(i)];case 1:return r=o.sent(),this.options.backgroundColor&&(this.ctx.fillStyle=pt(this.options.backgroundColor),this.ctx.fillRect(0,0,this.options.width*this.options.scale,this.options.height*this.options.scale)),this.ctx.drawImage(r,-this.options.x*this.options.scale,-this.options.y*this.options.scale),[2,this.canvas]}})})},e}(f_),vD=function(n){return new Promise(function(e,t){var i=new Image;i.onload=function(){e(i)},i.onerror=t,i.src="data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(new XMLSerializer().serializeToString(n)))})},yD=function(){function n(e){var t=e.id,i=e.enabled;this.id=t,this.enabled=i,this.start=Date.now()}return n.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.enabled&&(typeof window<"u"&&window.console?(()=>{}).apply(console,Ja([this.id,"".concat(this.getTime(),"ms")],e,!1)):this.info.apply(this,e))},n.prototype.getTime=function(){return Date.now()-this.start},n.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.enabled&&typeof window<"u"&&window.console&&typeof console.info=="function"&&console.info.apply(console,Ja([this.id,"".concat(this.getTime(),"ms")],e,!1))},n.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.enabled&&(typeof window<"u"&&window.console&&typeof console.warn=="function"?console.warn.apply(console,Ja([this.id,"".concat(this.getTime(),"ms")],e,!1)):this.info.apply(this,e))},n.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.enabled&&(typeof window<"u"&&window.console&&typeof console.error=="function"?console.error.apply(console,Ja([this.id,"".concat(this.getTime(),"ms")],e,!1)):this.info.apply(this,e))},n.instances={},n}(),bD=function(){function n(e,t){var i;this.windowBounds=t,this.instanceName="#".concat(n.instanceCount++),this.logger=new yD({id:this.instanceName,enabled:e.logging}),this.cache=(i=e.cache)!==null&&i!==void 0?i:new BN(this,e)}return n.instanceCount=1,n}(),_D=function(n,e){return e===void 0&&(e={}),kD(n,e)};typeof window<"u"&&Dh.setContext(window);var kD=function(n,e){return Mt(void 0,void 0,void 0,function(){var t,i,r,o,s,a,c,u,l,d,h,p,m,f,g,y,b,S,w,k,x,C,x,I,P,D,A,L,V,Y,O,F,X,K,Q,Ce,Ge,Ie,dt,Me;return xt(this,function(Pe){switch(Pe.label){case 0:if(!n||typeof n!="object")return[2,Promise.reject("Invalid element provided as first argument")];if(t=n.ownerDocument,!t)throw new Error("Element is not attached to a Document");if(i=t.defaultView,!i)throw new Error("Document is not attached to a Window");return r={allowTaint:(I=e.allowTaint)!==null&&I!==void 0?I:!1,imageTimeout:(P=e.imageTimeout)!==null&&P!==void 0?P:15e3,proxy:e.proxy,useCORS:(D=e.useCORS)!==null&&D!==void 0?D:!1,customIsSameOrigin:e.customIsSameOrigin},o=rh({logging:(A=e.logging)!==null&&A!==void 0?A:!0,cache:e.cache},r),s={windowWidth:(L=e.windowWidth)!==null&&L!==void 0?L:i.innerWidth,windowHeight:(V=e.windowHeight)!==null&&V!==void 0?V:i.innerHeight,scrollX:(Y=e.scrollX)!==null&&Y!==void 0?Y:i.pageXOffset,scrollY:(O=e.scrollY)!==null&&O!==void 0?O:i.pageYOffset},a=new Gn(s.scrollX,s.scrollY,s.windowWidth,s.windowHeight),c=new bD(o,a),u=(F=e.foreignObjectRendering)!==null&&F!==void 0?F:!1,l={allowTaint:(X=e.allowTaint)!==null&&X!==void 0?X:!1,onclone:e.onclone,ignoreElements:e.ignoreElements,inlineImages:u,copyStyles:u},c.logger.debug("Starting document clone with size ".concat(a.width,"x").concat(a.height," scrolled to ").concat(-a.left,",").concat(-a.top)),d=new r_(c,n,l),h=d.clonedReferenceElement,h?[4,d.toIFrame(t,a)]:[2,Promise.reject("Unable to find element in cloned iframe")];case 1:return p=Pe.sent(),m=Rh(h)||kN(h)?FP(h.ownerDocument):Za(c,h),f=m.width,g=m.height,y=m.left,b=m.top,S=SD(c,h,e.backgroundColor),w={canvas:e.canvas,backgroundColor:S,scale:(Q=(K=e.scale)!==null&&K!==void 0?K:i.devicePixelRatio)!==null&&Q!==void 0?Q:1,x:((Ce=e.x)!==null&&Ce!==void 0?Ce:0)+y,y:((Ge=e.y)!==null&&Ge!==void 0?Ge:0)+b,width:(Ie=e.width)!==null&&Ie!==void 0?Ie:Math.ceil(f),height:(dt=e.height)!==null&&dt!==void 0?dt:Math.ceil(g)},u?(c.logger.debug("Document cloned, using foreign object rendering"),x=new gD(c,w),[4,x.render(h)]):[3,3];case 2:return k=Pe.sent(),[3,5];case 3:return c.logger.debug("Document cloned, element located at ".concat(y,",").concat(b," with size ").concat(f,"x").concat(g," using computed rendering")),c.logger.debug("Starting DOM parsing"),C=zb(c,h),S===C.styles.backgroundColor&&(C.styles.backgroundColor=Rn.TRANSPARENT),c.logger.debug("Starting renderer for element at ".concat(w.x,",").concat(w.y," with size ").concat(w.width,"x").concat(w.height)),x=new lD(c,w),[4,x.render(C)];case 4:k=Pe.sent(),Pe.label=5;case 5:return(!((Me=e.removeContainer)!==null&&Me!==void 0)||Me)&&(r_.destroy(p)||c.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore")),c.logger.debug("Finished rendering"),[2,k]}})})},SD=function(n,e,t){var i=e.ownerDocument,r=i.documentElement?Wr(n,getComputedStyle(i.documentElement).backgroundColor):Rn.TRANSPARENT,o=i.body?Wr(n,getComputedStyle(i.body).backgroundColor):Rn.TRANSPARENT,s=typeof t=="string"?Wr(n,t):t===null?Rn.TRANSPARENT:4294967295;return e===i.documentElement?bi(r)?bi(o)?s:o:r:s};function wD(n,e){return e.forEach(function(t){t&&typeof t!="string"&&!Array.isArray(t)&&Object.keys(t).forEach(function(i){if(i!=="default"&&!(i in n)){var r=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(n,i,r.get?r:{enumerable:!0,get:function(){return t[i]}})}})}),Object.freeze(n)}var CD=Object.defineProperty,TD=(n,e,t)=>e in n?CD(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,m_=(n,e,t)=>TD(n,typeof e!="symbol"?e+"":e,t);class jt{constructor(){m_(this,"_locking"),m_(this,"_locks"),this._locking=Promise.resolve(),this._locks=0}isLocked(){return this._locks>0}lock(){this._locks+=1;let e;const t=new Promise(r=>e=()=>{this._locks-=1,r()}),i=this._locking.then(()=>e);return this._locking=this._locking.then(()=>t),i}}function Ye(n,e){if(!n)throw new Error(e)}const xD=34028234663852886e22,ED=-34028234663852886e22,ID=4294967295,RD=2147483647,PD=-2147483648;function Wc(n){if(typeof n!="number")throw new Error("invalid int 32: "+typeof n);if(!Number.isInteger(n)||n>RD||n<PD)throw new Error("invalid int 32: "+n)}function jh(n){if(typeof n!="number")throw new Error("invalid uint 32: "+typeof n);if(!Number.isInteger(n)||n>ID||n<0)throw new Error("invalid uint 32: "+n)}function g_(n){if(typeof n!="number")throw new Error("invalid float 32: "+typeof n);if(Number.isFinite(n)&&(n>xD||n<ED))throw new Error("invalid float 32: "+n)}const v_=Symbol("@bufbuild/protobuf/enum-type");function OD(n){const e=n[v_];return Ye(e,"missing enum type on enum object"),e}function y_(n,e,t,i){n[v_]=b_(e,t.map(r=>({no:r.no,name:r.name,localName:n[r.no]})))}function b_(n,e,t){const i=Object.create(null),r=Object.create(null),o=[];for(const s of e){const a=__(s);o.push(a),i[s.name]=a,r[s.no]=a}return{typeName:n,values:o,findName(s){return i[s]},findNumber(s){return r[s]}}}function AD(n,e,t){const i={};for(const r of e){const o=__(r);i[o.localName]=o.no,i[o.no]=o.localName}return y_(i,n,e),i}function __(n){return"localName"in n?n:Object.assign(Object.assign({},n),{localName:n.name})}class Vh{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){const i=this.getType(),r=i.runtime.bin,o=r.makeReadOptions(t);return r.readMessage(this,o.readerFactory(e),e.byteLength,o),this}fromJson(e,t){const i=this.getType(),r=i.runtime.json,o=r.makeReadOptions(t);return r.readMessage(i,e,o,this),this}fromJsonString(e,t){let i;try{i=JSON.parse(e)}catch(r){throw new Error("cannot decode ".concat(this.getType().typeName," from JSON: ").concat(r instanceof Error?r.message:String(r)))}return this.fromJson(i,t)}toBinary(e){const t=this.getType(),i=t.runtime.bin,r=i.makeWriteOptions(e),o=r.writerFactory();return i.writeMessage(this,o,r),o.finish()}toJson(e){const t=this.getType(),i=t.runtime.json,r=i.makeWriteOptions(e);return i.writeMessage(this,r)}toJsonString(e){var t;const i=this.toJson(e);return JSON.stringify(i,null,(t=e==null?void 0:e.prettySpaces)!==null&&t!==void 0?t:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function MD(n,e,t,i){var r;const o=(r=i==null?void 0:i.localName)!==null&&r!==void 0?r:e.substring(e.lastIndexOf(".")+1),s={[o]:function(a){n.util.initFields(this),n.util.initPartial(a,this)}}[o];return Object.setPrototypeOf(s.prototype,new Vh),Object.assign(s,{runtime:n,typeName:e,fields:n.util.newFieldList(t),fromBinary(a,c){return new s().fromBinary(a,c)},fromJson(a,c){return new s().fromJson(a,c)},fromJsonString(a,c){return new s().fromJsonString(a,c)},equals(a,c){return n.util.equals(s,a,c)}}),s}function ND(){let n=0,e=0;for(let i=0;i<28;i+=7){let r=this.buf[this.pos++];if(n|=(r&127)<<i,!(r&128))return this.assertBounds(),[n,e]}let t=this.buf[this.pos++];if(n|=(t&15)<<28,e=(t&112)>>4,!(t&128))return this.assertBounds(),[n,e];for(let i=3;i<=31;i+=7){let r=this.buf[this.pos++];if(e|=(r&127)<<i,!(r&128))return this.assertBounds(),[n,e]}throw new Error("invalid varint")}function zh(n,e,t){for(let o=0;o<28;o=o+7){const s=n>>>o,a=!(!(s>>>7)&&e==0),c=(a?s|128:s)&255;if(t.push(c),!a)return}const i=n>>>28&15|(e&7)<<4,r=!!(e>>3);if(t.push((r?i|128:i)&255),!!r){for(let o=3;o<31;o=o+7){const s=e>>>o,a=!!(s>>>7),c=(a?s|128:s)&255;if(t.push(c),!a)return}t.push(e>>>31&1)}}const Gc=4294967296;function k_(n){const e=n[0]==="-";e&&(n=n.slice(1));const t=1e6;let i=0,r=0;function o(s,a){const c=Number(n.slice(s,a));r*=t,i=i*t+c,i>=Gc&&(r=r+(i/Gc|0),i=i%Gc)}return o(-24,-18),o(-18,-12),o(-12,-6),o(-6),e?w_(i,r):qh(i,r)}function DD(n,e){let t=qh(n,e);const i=t.hi&2147483648;i&&(t=w_(t.lo,t.hi));const r=S_(t.lo,t.hi);return i?"-"+r:r}function S_(n,e){if({lo:n,hi:e}=LD(n,e),e<=2097151)return String(Gc*e+n);const t=n&16777215,i=(n>>>24|e<<8)&16777215,r=e>>16&65535;let o=t+i*6777216+r*6710656,s=i+r*8147497,a=r*2;const c=1e7;return o>=c&&(s+=Math.floor(o/c),o%=c),s>=c&&(a+=Math.floor(s/c),s%=c),a.toString()+C_(s)+C_(o)}function LD(n,e){return{lo:n>>>0,hi:e>>>0}}function qh(n,e){return{lo:n|0,hi:e|0}}function w_(n,e){return e=~e,n?n=~n+1:e+=1,qh(n,e)}const C_=n=>{const e=String(n);return"0000000".slice(e.length)+e};function T_(n,e){if(n>=0){for(;n>127;)e.push(n&127|128),n=n>>>7;e.push(n)}else{for(let t=0;t<9;t++)e.push(n&127|128),n=n>>7;e.push(1)}}function UD(){let n=this.buf[this.pos++],e=n&127;if(!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<7,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<14,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<21,!(n&128))return this.assertBounds(),e;n=this.buf[this.pos++],e|=(n&15)<<28;for(let t=5;n&128&&t<10;t++)n=this.buf[this.pos++];if(n&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}function FD(){const n=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof n.getBigInt64=="function"&&typeof n.getBigUint64=="function"&&typeof n.setBigInt64=="function"&&typeof n.setBigUint64=="function"&&(typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){const r=BigInt("-9223372036854775808"),o=BigInt("9223372036854775807"),s=BigInt("0"),a=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(c){const u=typeof c=="bigint"?c:BigInt(c);if(u>o||u<r)throw new Error("int64 invalid: ".concat(c));return u},uParse(c){const u=typeof c=="bigint"?c:BigInt(c);if(u>a||u<s)throw new Error("uint64 invalid: ".concat(c));return u},enc(c){return n.setBigInt64(0,this.parse(c),!0),{lo:n.getInt32(0,!0),hi:n.getInt32(4,!0)}},uEnc(c){return n.setBigInt64(0,this.uParse(c),!0),{lo:n.getInt32(0,!0),hi:n.getInt32(4,!0)}},dec(c,u){return n.setInt32(0,c,!0),n.setInt32(4,u,!0),n.getBigInt64(0,!0)},uDec(c,u){return n.setInt32(0,c,!0),n.setInt32(4,u,!0),n.getBigUint64(0,!0)}}}const t=r=>Ye(/^-?[0-9]+$/.test(r),"int64 invalid: ".concat(r)),i=r=>Ye(/^[0-9]+$/.test(r),"uint64 invalid: ".concat(r));return{zero:"0",supported:!1,parse(r){return typeof r!="string"&&(r=r.toString()),t(r),r},uParse(r){return typeof r!="string"&&(r=r.toString()),i(r),r},enc(r){return typeof r!="string"&&(r=r.toString()),t(r),k_(r)},uEnc(r){return typeof r!="string"&&(r=r.toString()),i(r),k_(r)},dec(r,o){return DD(r,o)},uDec(r,o){return S_(r,o)}}}const We=FD();var M;(function(n){n[n.DOUBLE=1]="DOUBLE",n[n.FLOAT=2]="FLOAT",n[n.INT64=3]="INT64",n[n.UINT64=4]="UINT64",n[n.INT32=5]="INT32",n[n.FIXED64=6]="FIXED64",n[n.FIXED32=7]="FIXED32",n[n.BOOL=8]="BOOL",n[n.STRING=9]="STRING",n[n.BYTES=12]="BYTES",n[n.UINT32=13]="UINT32",n[n.SFIXED32=15]="SFIXED32",n[n.SFIXED64=16]="SFIXED64",n[n.SINT32=17]="SINT32",n[n.SINT64=18]="SINT64"})(M||(M={}));var Ci;(function(n){n[n.BIGINT=0]="BIGINT",n[n.STRING=1]="STRING"})(Ci||(Ci={}));function Ti(n,e,t){if(e===t)return!0;if(n==M.BYTES){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}switch(n){case M.UINT64:case M.FIXED64:case M.INT64:case M.SFIXED64:case M.SINT64:return e==t}return!1}function Zr(n,e){switch(n){case M.BOOL:return!1;case M.UINT64:case M.FIXED64:case M.INT64:case M.SFIXED64:case M.SINT64:return e==0?We.zero:"0";case M.DOUBLE:case M.FLOAT:return 0;case M.BYTES:return new Uint8Array(0);case M.STRING:return"";default:return 0}}function x_(n,e){switch(n){case M.BOOL:return e===!1;case M.STRING:return e==="";case M.BYTES:return e instanceof Uint8Array&&!e.byteLength;default:return e==0}}var rt;(function(n){n[n.Varint=0]="Varint",n[n.Bit64=1]="Bit64",n[n.LengthDelimited=2]="LengthDelimited",n[n.StartGroup=3]="StartGroup",n[n.EndGroup=4]="EndGroup",n[n.Bit32=5]="Bit32"})(rt||(rt={}));class BD{constructor(e){this.stack=[],this.textEncoder=e??new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let r=0;r<this.chunks.length;r++)e+=this.chunks[r].length;let t=new Uint8Array(e),i=0;for(let r=0;r<this.chunks.length;r++)t.set(this.chunks[r],i),i+=this.chunks[r].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|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(jh(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return Wc(e),T_(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){g_(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){jh(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){Wc(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return Wc(e),e=(e<<1^e>>31)>>>0,T_(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),i=new DataView(t.buffer),r=We.enc(e);return i.setInt32(0,r.lo,!0),i.setInt32(4,r.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),i=new DataView(t.buffer),r=We.uEnc(e);return i.setInt32(0,r.lo,!0),i.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=We.enc(e);return zh(t.lo,t.hi,this.buf),this}sint64(e){let t=We.enc(e),i=t.hi>>31,r=t.lo<<1^i,o=(t.hi<<1|t.lo>>>31)^i;return zh(r,o,this.buf),this}uint64(e){let t=We.uEnc(e);return zh(t.lo,t.hi,this.buf),this}}class jD{constructor(e,t){this.varint64=ND,this.uint32=UD,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t??new TextDecoder}tag(){let e=this.uint32(),t=e>>>3,i=e&7;if(t<=0||i<0||i>5)throw new Error("illegal tag: field no "+t+" wire type "+i);return[t,i]}skip(e,t){let i=this.pos;switch(e){case rt.Varint:for(;this.buf[this.pos++]&128;);break;case rt.Bit64:this.pos+=4;case rt.Bit32:this.pos+=4;break;case rt.LengthDelimited:let r=this.uint32();this.pos+=r;break;case rt.StartGroup:for(;;){const[o,s]=this.tag();if(s===rt.EndGroup){if(t!==void 0&&o!==t)throw new Error("invalid end group tag");break}this.skip(s,o)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(i,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return We.dec(...this.varint64())}uint64(){return We.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),i=-(e&1);return e=(e>>>1|(t&1)<<31)^i,t=t>>>1^i,We.dec(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return We.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return We.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 VD(n,e,t,i){let r;return{typeName:e,extendee:t,get field(){if(!r){const o=typeof i=="function"?i():i;o.name=e.split(".").pop(),o.jsonName="[".concat(e,"]"),r=n.util.newFieldList([o]).list()[0]}return r},runtime:n}}function E_(n){const e=n.field.localName,t=Object.create(null);return t[e]=zD(n),[t,()=>t[e]]}function zD(n){const e=n.field;if(e.repeated)return[];if(e.default!==void 0)return e.default;switch(e.kind){case"enum":return e.T.values[0].no;case"scalar":return Zr(e.T,e.L);case"message":const t=e.T,i=new t;return t.fieldWrapper?t.fieldWrapper.unwrapField(i):i;case"map":throw"map fields are not allowed to be extensions"}}function qD(n,e){if(!e.repeated&&(e.kind=="enum"||e.kind=="scalar")){for(let t=n.length-1;t>=0;--t)if(n[t].no==e.no)return[n[t]];return[]}return n.filter(t=>t.no===e.no)}let Hn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),$c=[];for(let n=0;n<Hn.length;n++)$c[Hn[n].charCodeAt(0)]=n;$c["-".charCodeAt(0)]=Hn.indexOf("+"),$c["_".charCodeAt(0)]=Hn.indexOf("/");const I_={dec(n){let e=n.length*3/4;n[n.length-2]=="="?e-=2:n[n.length-1]=="="&&(e-=1);let t=new Uint8Array(e),i=0,r=0,o,s=0;for(let a=0;a<n.length;a++){if(o=$c[n.charCodeAt(a)],o===void 0)switch(n[a]){case"=":r=0;case`
84
- `:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(r){case 0:s=o,r=1;break;case 1:t[i++]=s<<2|(o&48)>>4,s=o,r=2;break;case 2:t[i++]=(s&15)<<4|(o&60)>>2,s=o,r=3;break;case 3:t[i++]=(s&3)<<6|o,r=0;break}}if(r==1)throw Error("invalid base64 string.");return t.subarray(0,i)},enc(n){let e="",t=0,i,r=0;for(let o=0;o<n.length;o++)switch(i=n[o],t){case 0:e+=Hn[i>>2],r=(i&3)<<4,t=1;break;case 1:e+=Hn[r|i>>4],r=(i&15)<<2,t=2;break;case 2:e+=Hn[r|i>>6],e+=Hn[i&63],t=0;break}return t&&(e+=Hn[r],e+="=",t==1&&(e+="=")),e}};function WD(n,e,t){P_(e,n);const i=e.runtime.bin.makeReadOptions(t),r=qD(n.getType().runtime.bin.listUnknownFields(n),e.field),[o,s]=E_(e);for(const a of r)e.runtime.bin.readField(o,i.readerFactory(a.data),e.field,a.wireType,i);return s()}function GD(n,e,t,i){P_(e,n);const r=e.runtime.bin.makeReadOptions(i),o=e.runtime.bin.makeWriteOptions(i);if(R_(n,e)){const u=n.getType().runtime.bin.listUnknownFields(n).filter(l=>l.no!=e.field.no);n.getType().runtime.bin.discardUnknownFields(n);for(const l of u)n.getType().runtime.bin.onUnknownField(n,l.no,l.wireType,l.data)}const s=o.writerFactory();let a=e.field;!a.opt&&!a.repeated&&(a.kind=="enum"||a.kind=="scalar")&&(a=Object.assign(Object.assign({},e.field),{opt:!0})),e.runtime.bin.writeField(a,t,s,o);const c=r.readerFactory(s.finish());for(;c.pos<c.len;){const[u,l]=c.tag(),d=c.skip(l,u);n.getType().runtime.bin.onUnknownField(n,u,l,d)}}function R_(n,e){const t=n.getType();return e.extendee.typeName===t.typeName&&!!t.runtime.bin.listUnknownFields(n).find(i=>i.no==e.field.no)}function P_(n,e){Ye(n.extendee.typeName==e.getType().typeName,"extension ".concat(n.typeName," can only be applied to message ").concat(n.extendee.typeName))}function O_(n,e){const t=n.localName;if(n.repeated)return e[t].length>0;if(n.oneof)return e[n.oneof.localName].case===t;switch(n.kind){case"enum":case"scalar":return n.opt||n.req?e[t]!==void 0:n.kind=="enum"?e[t]!==n.T.values[0].no:!x_(n.T,e[t]);case"message":return e[t]!==void 0;case"map":return Object.keys(e[t]).length>0}}function A_(n,e){const t=n.localName,i=!n.opt&&!n.req;if(n.repeated)e[t]=[];else if(n.oneof)e[n.oneof.localName]={case:void 0};else switch(n.kind){case"map":e[t]={};break;case"enum":e[t]=i?n.T.values[0].no:void 0;break;case"scalar":e[t]=i?Zr(n.T,n.L):void 0;break;case"message":e[t]=void 0;break}}function Qi(n,e){if(n===null||typeof n!="object"||!Object.getOwnPropertyNames(Vh.prototype).every(i=>i in n&&typeof n[i]=="function"))return!1;const t=n.getType();return t===null||typeof t!="function"||!("typeName"in t)||typeof t.typeName!="string"?!1:e===void 0?!0:t.typeName==e.typeName}function M_(n,e){return Qi(e)||!n.fieldWrapper?e:n.fieldWrapper.wrapField(e)}M.DOUBLE,M.FLOAT,M.INT64,M.UINT64,M.INT32,M.UINT32,M.BOOL,M.STRING,M.BYTES;const N_={ignoreUnknownFields:!1},D_={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function $D(n){return n?Object.assign(Object.assign({},N_),n):N_}function HD(n){return n?Object.assign(Object.assign({},D_),n):D_}const Hc=Symbol(),Kc=Symbol();function KD(){return{makeReadOptions:$D,makeWriteOptions:HD,readMessage(n,e,t,i){if(e==null||Array.isArray(e)||typeof e!="object")throw new Error("cannot decode message ".concat(n.typeName," from JSON: ").concat(On(e)));i=i??new n;const r=new Map,o=t.typeRegistry;for(const[s,a]of Object.entries(e)){const c=n.fields.findJsonName(s);if(c){if(c.oneof){if(a===null&&c.kind=="scalar")continue;const u=r.get(c.oneof);if(u!==void 0)throw new Error("cannot decode message ".concat(n.typeName,' from JSON: multiple keys for oneof "').concat(c.oneof.name,'" present: "').concat(u,'", "').concat(s,'"'));r.set(c.oneof,s)}L_(i,a,c,t,n)}else{let u=!1;if(o!=null&&o.findExtension&&s.startsWith("[")&&s.endsWith("]")){const l=o.findExtension(s.substring(1,s.length-1));if(l&&l.extendee.typeName==n.typeName){u=!0;const[d,h]=E_(l);L_(d,a,l.field,t,l),GD(i,l,h(),t)}}if(!u&&!t.ignoreUnknownFields)throw new Error("cannot decode message ".concat(n.typeName,' from JSON: key "').concat(s,'" is unknown'))}}return i},writeMessage(n,e){const t=n.getType(),i={};let r;try{for(r of t.fields.byNumber()){if(!O_(r,n)){if(r.req)throw"required field not set";if(!e.emitDefaultValues||!XD(r))continue}const s=r.oneof?n[r.oneof.localName].value:n[r.localName],a=U_(r,s,e);a!==void 0&&(i[e.useProtoFieldName?r.name:r.jsonName]=a)}const o=e.typeRegistry;if(o!=null&&o.findExtensionFor)for(const s of t.runtime.bin.listUnknownFields(n)){const a=o.findExtensionFor(t.typeName,s.no);if(a&&R_(n,a)){const c=WD(n,a,e),u=U_(a.field,c,e);u!==void 0&&(i[a.field.jsonName]=u)}}}catch(o){const s=r?"cannot encode field ".concat(t.typeName,".").concat(r.name," to JSON"):"cannot encode message ".concat(t.typeName," to JSON"),a=o instanceof Error?o.message:String(o);throw new Error(s+(a.length>0?": ".concat(a):""))}return i},readScalar(n,e,t){return us(n,e,t??Ci.BIGINT,!0)},writeScalar(n,e,t){if(e!==void 0&&(t||x_(n,e)))return Yc(n,e)},debug:On}}function On(n){if(n===null)return"null";switch(typeof n){case"object":return Array.isArray(n)?"array":"object";case"string":return n.length>100?"string":'"'.concat(n.split('"').join('\\"'),'"');default:return String(n)}}function L_(n,e,t,i,r){let o=t.localName;if(t.repeated){if(Ye(t.kind!="map"),e===null)return;if(!Array.isArray(e))throw new Error("cannot decode field ".concat(r.typeName,".").concat(t.name," from JSON: ").concat(On(e)));const s=n[o];for(const a of e){if(a===null)throw new Error("cannot decode field ".concat(r.typeName,".").concat(t.name," from JSON: ").concat(On(a)));switch(t.kind){case"message":s.push(t.T.fromJson(a,i));break;case"enum":const c=Wh(t.T,a,i.ignoreUnknownFields,!0);c!==Kc&&s.push(c);break;case"scalar":try{s.push(us(t.T,a,t.L,!0))}catch(u){let l="cannot decode field ".concat(r.typeName,".").concat(t.name," from JSON: ").concat(On(a));throw u instanceof Error&&u.message.length>0&&(l+=": ".concat(u.message)),new Error(l)}break}}}else if(t.kind=="map"){if(e===null)return;if(typeof e!="object"||Array.isArray(e))throw new Error("cannot decode field ".concat(r.typeName,".").concat(t.name," from JSON: ").concat(On(e)));const s=n[o];for(const[a,c]of Object.entries(e)){if(c===null)throw new Error("cannot decode field ".concat(r.typeName,".").concat(t.name," from JSON: map value null"));let u;try{u=YD(t.K,a)}catch(l){let d="cannot decode map key for field ".concat(r.typeName,".").concat(t.name," from JSON: ").concat(On(e));throw l instanceof Error&&l.message.length>0&&(d+=": ".concat(l.message)),new Error(d)}switch(t.V.kind){case"message":s[u]=t.V.T.fromJson(c,i);break;case"enum":const l=Wh(t.V.T,c,i.ignoreUnknownFields,!0);l!==Kc&&(s[u]=l);break;case"scalar":try{s[u]=us(t.V.T,c,Ci.BIGINT,!0)}catch(d){let h="cannot decode map value for field ".concat(r.typeName,".").concat(t.name," from JSON: ").concat(On(e));throw d instanceof Error&&d.message.length>0&&(h+=": ".concat(d.message)),new Error(h)}break}}}else switch(t.oneof&&(n=n[t.oneof.localName]={case:o},o="value"),t.kind){case"message":const s=t.T;if(e===null&&s.typeName!="google.protobuf.Value")return;let a=n[o];Qi(a)?a.fromJson(e,i):(n[o]=a=s.fromJson(e,i),s.fieldWrapper&&!t.oneof&&(n[o]=s.fieldWrapper.unwrapField(a)));break;case"enum":const c=Wh(t.T,e,i.ignoreUnknownFields,!1);switch(c){case Hc:A_(t,n);break;case Kc:break;default:n[o]=c;break}break;case"scalar":try{const u=us(t.T,e,t.L,!1);switch(u){case Hc:A_(t,n);break;default:n[o]=u;break}}catch(u){let l="cannot decode field ".concat(r.typeName,".").concat(t.name," from JSON: ").concat(On(e));throw u instanceof Error&&u.message.length>0&&(l+=": ".concat(u.message)),new Error(l)}break}}function YD(n,e){if(n===M.BOOL)switch(e){case"true":e=!0;break;case"false":e=!1;break}return us(n,e,Ci.BIGINT,!0).toString()}function us(n,e,t,i){if(e===null)return i?Zr(n,t):Hc;switch(n){case M.DOUBLE:case M.FLOAT:if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""||typeof e=="string"&&e.trim().length!==e.length||typeof e!="string"&&typeof e!="number")break;const r=Number(e);if(Number.isNaN(r)||!Number.isFinite(r))break;return n==M.FLOAT&&g_(r),r;case M.INT32:case M.FIXED32:case M.SFIXED32:case M.SINT32:case M.UINT32:let o;if(typeof e=="number"?o=e:typeof e=="string"&&e.length>0&&e.trim().length===e.length&&(o=Number(e)),o===void 0)break;return n==M.UINT32||n==M.FIXED32?jh(o):Wc(o),o;case M.INT64:case M.SFIXED64:case M.SINT64:if(typeof e!="number"&&typeof e!="string")break;const s=We.parse(e);return t?s.toString():s;case M.FIXED64:case M.UINT64:if(typeof e!="number"&&typeof e!="string")break;const a=We.uParse(e);return t?a.toString():a;case M.BOOL:if(typeof e!="boolean")break;return e;case M.STRING:if(typeof e!="string")break;try{encodeURIComponent(e)}catch{throw new Error("invalid UTF8")}return e;case M.BYTES:if(e==="")return new Uint8Array(0);if(typeof e!="string")break;return I_.dec(e)}throw new Error}function Wh(n,e,t,i){if(e===null)return n.typeName=="google.protobuf.NullValue"?0:i?n.values[0].no:Hc;switch(typeof e){case"number":if(Number.isInteger(e))return e;break;case"string":const r=n.findName(e);if(r!==void 0)return r.no;if(t)return Kc;break}throw new Error("cannot decode enum ".concat(n.typeName," from JSON: ").concat(On(e)))}function XD(n){return n.repeated||n.kind=="map"?!0:!(n.oneof||n.kind=="message"||n.opt||n.req)}function U_(n,e,t){if(n.kind=="map"){Ye(typeof e=="object"&&e!=null);const i={},r=Object.entries(e);switch(n.V.kind){case"scalar":for(const[s,a]of r)i[s.toString()]=Yc(n.V.T,a);break;case"message":for(const[s,a]of r)i[s.toString()]=a.toJson(t);break;case"enum":const o=n.V.T;for(const[s,a]of r)i[s.toString()]=Gh(o,a,t.enumAsInteger);break}return t.emitDefaultValues||r.length>0?i:void 0}if(n.repeated){Ye(Array.isArray(e));const i=[];switch(n.kind){case"scalar":for(let r=0;r<e.length;r++)i.push(Yc(n.T,e[r]));break;case"enum":for(let r=0;r<e.length;r++)i.push(Gh(n.T,e[r],t.enumAsInteger));break;case"message":for(let r=0;r<e.length;r++)i.push(e[r].toJson(t));break}return t.emitDefaultValues||i.length>0?i:void 0}switch(n.kind){case"scalar":return Yc(n.T,e);case"enum":return Gh(n.T,e,t.enumAsInteger);case"message":return M_(n.T,e).toJson(t)}}function Gh(n,e,t){var i;if(Ye(typeof e=="number"),n.typeName=="google.protobuf.NullValue")return null;if(t)return e;const r=n.findNumber(e);return(i=r==null?void 0:r.name)!==null&&i!==void 0?i:e}function Yc(n,e){switch(n){case M.INT32:case M.SFIXED32:case M.SINT32:case M.FIXED32:case M.UINT32:return Ye(typeof e=="number"),e;case M.FLOAT:case M.DOUBLE:return Ye(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e;case M.STRING:return Ye(typeof e=="string"),e;case M.BOOL:return Ye(typeof e=="boolean"),e;case M.UINT64:case M.FIXED64:case M.INT64:case M.SFIXED64:case M.SINT64:return Ye(typeof e=="bigint"||typeof e=="string"||typeof e=="number"),e.toString();case M.BYTES:return Ye(e instanceof Uint8Array),I_.enc(e)}}const Qr=Symbol("@bufbuild/protobuf/unknown-fields"),F_={readUnknownFields:!0,readerFactory:n=>new jD(n)},B_={writeUnknownFields:!0,writerFactory:()=>new BD};function JD(n){return n?Object.assign(Object.assign({},F_),n):F_}function ZD(n){return n?Object.assign(Object.assign({},B_),n):B_}function QD(){return{makeReadOptions:JD,makeWriteOptions:ZD,listUnknownFields(n){var e;return(e=n[Qr])!==null&&e!==void 0?e:[]},discardUnknownFields(n){delete n[Qr]},writeUnknownFields(n,e){const i=n[Qr];if(i)for(const r of i)e.tag(r.no,r.wireType).raw(r.data)},onUnknownField(n,e,t,i){const r=n;Array.isArray(r[Qr])||(r[Qr]=[]),r[Qr].push({no:e,wireType:t,data:i})},readMessage(n,e,t,i,r){const o=n.getType(),s=r?e.len:e.pos+t;let a,c;for(;e.pos<s&&([a,c]=e.tag(),!(r===!0&&c==rt.EndGroup));){const u=o.fields.find(a);if(!u){const l=e.skip(c,a);i.readUnknownFields&&this.onUnknownField(n,a,c,l);continue}j_(n,e,u,c,i)}if(r&&(c!=rt.EndGroup||a!==t))throw new Error("invalid end group tag")},readField:j_,writeMessage(n,e,t){const i=n.getType();for(const r of i.fields.byNumber()){if(!O_(r,n)){if(r.req)throw new Error("cannot encode field ".concat(i.typeName,".").concat(r.name," to binary: required field not set"));continue}const o=r.oneof?n[r.oneof.localName].value:n[r.localName];V_(r,o,e,t)}return t.writeUnknownFields&&this.writeUnknownFields(n,e),e},writeField(n,e,t,i){e!==void 0&&V_(n,e,t,i)}}}function j_(n,e,t,i,r){let{repeated:o,localName:s}=t;switch(t.oneof&&(n=n[t.oneof.localName],n.case!=s&&delete n.value,n.case=s,s="value"),t.kind){case"scalar":case"enum":const a=t.kind=="enum"?M.INT32:t.T;let c=Jc;if(t.kind=="scalar"&&t.L>0&&(c=tL),o){let h=n[s];if(i==rt.LengthDelimited&&a!=M.STRING&&a!=M.BYTES){let m=e.uint32()+e.pos;for(;e.pos<m;)h.push(c(e,a))}else h.push(c(e,a))}else n[s]=c(e,a);break;case"message":const u=t.T;o?n[s].push(Xc(e,new u,r,t)):Qi(n[s])?Xc(e,n[s],r,t):(n[s]=Xc(e,new u,r,t),u.fieldWrapper&&!t.oneof&&!t.repeated&&(n[s]=u.fieldWrapper.unwrapField(n[s])));break;case"map":let[l,d]=eL(t,e,r);n[s][l]=d;break}}function Xc(n,e,t,i){const r=e.getType().runtime.bin,o=i==null?void 0:i.delimited;return r.readMessage(e,n,o?i.no:n.uint32(),t,o),e}function eL(n,e,t){const i=e.uint32(),r=e.pos+i;let o,s;for(;e.pos<r;){const[a]=e.tag();switch(a){case 1:o=Jc(e,n.K);break;case 2:switch(n.V.kind){case"scalar":s=Jc(e,n.V.T);break;case"enum":s=e.int32();break;case"message":s=Xc(e,new n.V.T,t,void 0);break}break}}if(o===void 0&&(o=Zr(n.K,Ci.BIGINT)),typeof o!="string"&&typeof o!="number"&&(o=o.toString()),s===void 0)switch(n.V.kind){case"scalar":s=Zr(n.V.T,Ci.BIGINT);break;case"enum":s=n.V.T.values[0].no;break;case"message":s=new n.V.T;break}return[o,s]}function tL(n,e){const t=Jc(n,e);return typeof t=="bigint"?t.toString():t}function Jc(n,e){switch(e){case M.STRING:return n.string();case M.BOOL:return n.bool();case M.DOUBLE:return n.double();case M.FLOAT:return n.float();case M.INT32:return n.int32();case M.INT64:return n.int64();case M.UINT64:return n.uint64();case M.FIXED64:return n.fixed64();case M.BYTES:return n.bytes();case M.FIXED32:return n.fixed32();case M.SFIXED32:return n.sfixed32();case M.SFIXED64:return n.sfixed64();case M.SINT64:return n.sint64();case M.UINT32:return n.uint32();case M.SINT32:return n.sint32()}}function V_(n,e,t,i){Ye(e!==void 0);const r=n.repeated;switch(n.kind){case"scalar":case"enum":let o=n.kind=="enum"?M.INT32:n.T;if(r)if(Ye(Array.isArray(e)),n.packed)iL(t,o,n.no,e);else for(const s of e)ls(t,o,n.no,s);else ls(t,o,n.no,e);break;case"message":if(r){Ye(Array.isArray(e));for(const s of e)z_(t,i,n,s)}else z_(t,i,n,e);break;case"map":Ye(typeof e=="object"&&e!=null);for(const[s,a]of Object.entries(e))nL(t,i,n,s,a);break}}function nL(n,e,t,i,r){n.tag(t.no,rt.LengthDelimited),n.fork();let o=i;switch(t.K){case M.INT32:case M.FIXED32:case M.UINT32:case M.SFIXED32:case M.SINT32:o=Number.parseInt(i);break;case M.BOOL:Ye(i=="true"||i=="false"),o=i=="true";break}switch(ls(n,t.K,1,o),t.V.kind){case"scalar":ls(n,t.V.T,2,r);break;case"enum":ls(n,M.INT32,2,r);break;case"message":Ye(r!==void 0),n.tag(2,rt.LengthDelimited).bytes(r.toBinary(e));break}n.join()}function z_(n,e,t,i){const r=M_(t.T,i);t.delimited?n.tag(t.no,rt.StartGroup).raw(r.toBinary(e)).tag(t.no,rt.EndGroup):n.tag(t.no,rt.LengthDelimited).bytes(r.toBinary(e))}function ls(n,e,t,i){Ye(i!==void 0);let[r,o]=q_(e);n.tag(t,r)[o](i)}function iL(n,e,t,i){if(!i.length)return;n.tag(t,rt.LengthDelimited).fork();let[,r]=q_(e);for(let o=0;o<i.length;o++)n[r](i[o]);n.join()}function q_(n){let e=rt.Varint;switch(n){case M.BYTES:case M.STRING:e=rt.LengthDelimited;break;case M.DOUBLE:case M.FIXED64:case M.SFIXED64:e=rt.Bit64;break;case M.FIXED32:case M.SFIXED32:case M.FLOAT:e=rt.Bit32;break}const t=M[n].toLowerCase();return[e,t]}function rL(){return{setEnumType:y_,initPartial(n,e){if(n===void 0)return;const t=e.getType();for(const i of t.fields.byMember()){const r=i.localName,o=e,s=n;if(s[r]!=null)switch(i.kind){case"oneof":const a=s[r].case;if(a===void 0)continue;const c=i.findField(a);let u=s[r].value;c&&c.kind=="message"&&!Qi(u,c.T)?u=new c.T(u):c&&c.kind==="scalar"&&c.T===M.BYTES&&(u=ds(u)),o[r]={case:a,value:u};break;case"scalar":case"enum":let l=s[r];i.T===M.BYTES&&(l=i.repeated?l.map(ds):ds(l)),o[r]=l;break;case"map":switch(i.V.kind){case"scalar":case"enum":if(i.V.T===M.BYTES)for(const[p,m]of Object.entries(s[r]))o[r][p]=ds(m);else Object.assign(o[r],s[r]);break;case"message":const h=i.V.T;for(const p of Object.keys(s[r])){let m=s[r][p];h.fieldWrapper||(m=new h(m)),o[r][p]=m}break}break;case"message":const d=i.T;if(i.repeated)o[r]=s[r].map(h=>Qi(h,d)?h:new d(h));else{const h=s[r];d.fieldWrapper?d.typeName==="google.protobuf.BytesValue"?o[r]=ds(h):o[r]=h:o[r]=Qi(h,d)?h:new d(h)}break}}},equals(n,e,t){return e===t?!0:!e||!t?!1:n.fields.byMember().every(i=>{const r=e[i.localName],o=t[i.localName];if(i.repeated){if(r.length!==o.length)return!1;switch(i.kind){case"message":return r.every((s,a)=>i.T.equals(s,o[a]));case"scalar":return r.every((s,a)=>Ti(i.T,s,o[a]));case"enum":return r.every((s,a)=>Ti(M.INT32,s,o[a]))}throw new Error("repeated cannot contain ".concat(i.kind))}switch(i.kind){case"message":return i.T.equals(r,o);case"enum":return Ti(M.INT32,r,o);case"scalar":return Ti(i.T,r,o);case"oneof":if(r.case!==o.case)return!1;const s=i.findField(r.case);if(s===void 0)return!0;switch(s.kind){case"message":return s.T.equals(r.value,o.value);case"enum":return Ti(M.INT32,r.value,o.value);case"scalar":return Ti(s.T,r.value,o.value)}throw new Error("oneof cannot contain ".concat(s.kind));case"map":const a=Object.keys(r).concat(Object.keys(o));switch(i.V.kind){case"message":const c=i.V.T;return a.every(l=>c.equals(r[l],o[l]));case"enum":return a.every(l=>Ti(M.INT32,r[l],o[l]));case"scalar":const u=i.V.T;return a.every(l=>Ti(u,r[l],o[l]))}break}})},clone(n){const e=n.getType(),t=new e,i=t;for(const r of e.fields.byMember()){const o=n[r.localName];let s;if(r.repeated)s=o.map(Zc);else if(r.kind=="map"){s=i[r.localName];for(const[a,c]of Object.entries(o))s[a]=Zc(c)}else r.kind=="oneof"?s=r.findField(o.case)?{case:o.case,value:Zc(o.value)}:{case:void 0}:s=Zc(o);i[r.localName]=s}for(const r of e.runtime.bin.listUnknownFields(n))e.runtime.bin.onUnknownField(i,r.no,r.wireType,r.data);return t}}}function Zc(n){if(n===void 0)return n;if(Qi(n))return n.clone();if(n instanceof Uint8Array){const e=new Uint8Array(n.byteLength);return e.set(n),e}return n}function ds(n){return n instanceof Uint8Array?n:new Uint8Array(n)}function oL(n,e,t){return{syntax:n,json:KD(),bin:QD(),util:Object.assign(Object.assign({},rL()),{newFieldList:e,initFields:t}),makeMessageType(i,r,o){return MD(this,i,r,o)},makeEnum:AD,makeEnumType:b_,getEnumType:OD,makeExtension(i,r,o){return VD(this,i,r,o)}}}class sL{constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){const t={};for(const i of this.list())t[i.jsonName]=t[i.name]=i;this.jsonNames=t}return this.jsonNames[e]}find(e){if(!this.numbers){const t={};for(const i of this.list())t[i.no]=i;this.numbers=t}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 i of this.list())i.oneof?i.oneof!==t&&(t=i.oneof,e.push(t)):e.push(i)}return this.members}}function W_(n,e){const t=G_(n);return e?t:hL(dL(t))}function aL(n){return W_(n,!1)}const cL=G_;function G_(n){let e=!1;const t=[];for(let i=0;i<n.length;i++){let r=n.charAt(i);switch(r){case"_":e=!0;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":t.push(r),e=!1;break;default:e&&(e=!1,r=r.toUpperCase()),t.push(r);break}}return t.join("")}const uL=new Set(["constructor","toString","toJSON","valueOf"]),lL=new Set(["getType","clone","equals","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","toObject"]),$_=n=>"".concat(n,"$"),dL=n=>lL.has(n)?$_(n):n,hL=n=>uL.has(n)?$_(n):n;class pL{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=aL(e)}addField(e){Ye(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 t=0;t<this.fields.length;t++)this._lookup[this.fields[t].localName]=this.fields[t]}return this._lookup[e]}}function fL(n,e){var t,i,r,o,s,a;const c=[];let u;for(const l of typeof n=="function"?n():n){const d=l;if(d.localName=W_(l.name,l.oneof!==void 0),d.jsonName=(t=l.jsonName)!==null&&t!==void 0?t:cL(l.name),d.repeated=(i=l.repeated)!==null&&i!==void 0?i:!1,l.kind=="scalar"&&(d.L=(r=l.L)!==null&&r!==void 0?r:Ci.BIGINT),d.delimited=(o=l.delimited)!==null&&o!==void 0?o:!1,d.req=(s=l.req)!==null&&s!==void 0?s:!1,d.opt=(a=l.opt)!==null&&a!==void 0?a:!1,l.packed===void 0&&(d.packed=l.kind=="enum"||l.kind=="scalar"&&l.T!=M.BYTES&&l.T!=M.STRING),l.oneof!==void 0){const h=typeof l.oneof=="string"?l.oneof:l.oneof.name;(!u||u.name!=h)&&(u=new pL(h)),d.oneof=u,u.addField(d)}c.push(d)}return c}const R=oL("proto3",n=>new sL(n,e=>fL(e)),n=>{for(const e of n.getType().fields.byMember()){if(e.opt)continue;const t=e.localName,i=n;if(e.repeated){i[t]=[];continue}switch(e.kind){case"oneof":i[t]={case:void 0};break;case"enum":i[t]=0;break;case"map":i[t]={};break;case"scalar":i[t]=Zr(e.T,e.L);break}}});class Vt extends Vh{constructor(e){super(),this.seconds=We.zero,this.nanos=0,R.util.initPartial(e,this)}fromJson(e,t){if(typeof e!="string")throw new Error("cannot decode google.protobuf.Timestamp from JSON: ".concat(R.json.debug(e)));const i=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(!i)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");const r=Date.parse(i[1]+"-"+i[2]+"-"+i[3]+"T"+i[4]+":"+i[5]+":"+i[6]+(i[8]?i[8]:"Z"));if(Number.isNaN(r))throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");if(r<Date.parse("0001-01-01T00:00:00Z")||r>Date.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=We.parse(r/1e3),this.nanos=0,i[7]&&(this.nanos=parseInt("1"+i[7]+"0".repeat(9-i[7].length))-1e9),this}toJson(e){const t=Number(this.seconds)*1e3;if(t<Date.parse("0001-01-01T00:00:00Z")||t>Date.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 i="Z";if(this.nanos>0){const r=(this.nanos+1e9).toString().substring(1);r.substring(3)==="000000"?i="."+r.substring(0,3)+"Z":r.substring(6)==="000"?i="."+r.substring(0,6)+"Z":i="."+r+"Z"}return new Date(t).toISOString().replace(".000Z",i)}toDate(){return new Date(Number(this.seconds)*1e3+Math.ceil(this.nanos/1e6))}static now(){return Vt.fromDate(new Date)}static fromDate(e){const t=e.getTime();return new Vt({seconds:We.parse(Math.floor(t/1e3)),nanos:t%1e3*1e6})}static fromBinary(e,t){return new Vt().fromBinary(e,t)}static fromJson(e,t){return new Vt().fromJson(e,t)}static fromJsonString(e,t){return new Vt().fromJsonString(e,t)}static equals(e,t){return R.util.equals(Vt,e,t)}}Vt.runtime=R,Vt.typeName="google.protobuf.Timestamp",Vt.fields=R.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);const mL=R.makeMessageType("livekit.MetricsBatch",()=>[{no:1,name:"timestamp_ms",kind:"scalar",T:3},{no:2,name:"normalized_timestamp",kind:"message",T:Vt},{no:3,name:"str_data",kind:"scalar",T:9,repeated:!0},{no:4,name:"time_series",kind:"message",T:gL,repeated:!0},{no:5,name:"events",kind:"message",T:yL,repeated:!0}]),gL=R.makeMessageType("livekit.TimeSeriesMetric",()=>[{no:1,name:"label",kind:"scalar",T:13},{no:2,name:"participant_identity",kind:"scalar",T:13},{no:3,name:"track_sid",kind:"scalar",T:13},{no:4,name:"samples",kind:"message",T:vL,repeated:!0},{no:5,name:"rid",kind:"scalar",T:13}]),vL=R.makeMessageType("livekit.MetricSample",()=>[{no:1,name:"timestamp_ms",kind:"scalar",T:3},{no:2,name:"normalized_timestamp",kind:"message",T:Vt},{no:3,name:"value",kind:"scalar",T:2}]),yL=R.makeMessageType("livekit.EventMetric",()=>[{no:1,name:"label",kind:"scalar",T:13},{no:2,name:"participant_identity",kind:"scalar",T:13},{no:3,name:"track_sid",kind:"scalar",T:13},{no:4,name:"start_timestamp_ms",kind:"scalar",T:3},{no:5,name:"end_timestamp_ms",kind:"scalar",T:3,opt:!0},{no:6,name:"normalized_start_timestamp",kind:"message",T:Vt},{no:7,name:"normalized_end_timestamp",kind:"message",T:Vt,opt:!0},{no:8,name:"metadata",kind:"scalar",T:9},{no:9,name:"rid",kind:"scalar",T:13}]),H_=R.makeEnum("livekit.BackupCodecPolicy",[{no:0,name:"PREFER_REGRESSION"},{no:1,name:"SIMULCAST"},{no:2,name:"REGRESSION"}]),un=R.makeEnum("livekit.TrackType",[{no:0,name:"AUDIO"},{no:1,name:"VIDEO"},{no:2,name:"DATA"}]),at=R.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"}]),eo=R.makeEnum("livekit.VideoQuality",[{no:0,name:"LOW"},{no:1,name:"MEDIUM"},{no:2,name:"HIGH"},{no:3,name:"OFF"}]),hs=R.makeEnum("livekit.ConnectionQuality",[{no:0,name:"POOR"},{no:1,name:"GOOD"},{no:2,name:"EXCELLENT"},{no:3,name:"LOST"}]),ps=R.makeEnum("livekit.ClientConfigSetting",[{no:0,name:"UNSET"},{no:1,name:"DISABLED"},{no:2,name:"ENABLED"}]),ln=R.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"},{no:10,name:"ROOM_CLOSED"},{no:11,name:"USER_UNAVAILABLE"},{no:12,name:"USER_REJECTED"},{no:13,name:"SIP_TRUNK_FAILURE"},{no:14,name:"CONNECTION_TIMEOUT"}]),to=R.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"}]),bL=R.makeEnum("livekit.SubscriptionError",[{no:0,name:"SE_UNKNOWN"},{no:1,name:"SE_CODEC_UNSUPPORTED"},{no:2,name:"SE_TRACK_NOTFOUND"}]),dn=R.makeEnum("livekit.AudioTrackFeature",[{no:0,name:"TF_STEREO"},{no:1,name:"TF_NO_DTX"},{no:2,name:"TF_AUTO_GAIN_CONTROL"},{no:3,name:"TF_ECHO_CANCELLATION"},{no:4,name:"TF_NOISE_SUPPRESSION"},{no:5,name:"TF_ENHANCED_NOISE_CANCELLATION"},{no:6,name:"TF_PRECONNECT_BUFFER"}]),Qc=R.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:15,name:"creation_time_ms",kind:"scalar",T:3},{no:6,name:"turn_password",kind:"scalar",T:9},{no:7,name:"enabled_codecs",kind:"message",T:eu,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:sk}]),eu=R.makeMessageType("livekit.Codec",()=>[{no:1,name:"mime",kind:"scalar",T:9},{no:2,name:"fmtp_line",kind:"scalar",T:9}]),_L=R.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:R.getEnumType(at),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},{no:12,name:"can_subscribe_metrics",kind:"scalar",T:8}]),er=R.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:R.getEnumType(no)},{no:4,name:"tracks",kind:"message",T:io,repeated:!0},{no:5,name:"metadata",kind:"scalar",T:9},{no:6,name:"joined_at",kind:"scalar",T:3},{no:17,name:"joined_at_ms",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:_L},{no:12,name:"region",kind:"scalar",T:9},{no:13,name:"is_publisher",kind:"scalar",T:8},{no:14,name:"kind",kind:"enum",T:R.getEnumType(tu)},{no:15,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:16,name:"disconnect_reason",kind:"enum",T:R.getEnumType(ln)},{no:18,name:"kind_details",kind:"enum",T:R.getEnumType(kL),repeated:!0}]),no=R.makeEnum("livekit.ParticipantInfo.State",[{no:0,name:"JOINING"},{no:1,name:"JOINED"},{no:2,name:"ACTIVE"},{no:3,name:"DISCONNECTED"}]),tu=R.makeEnum("livekit.ParticipantInfo.Kind",[{no:0,name:"STANDARD"},{no:1,name:"INGRESS"},{no:2,name:"EGRESS"},{no:3,name:"SIP"},{no:4,name:"AGENT"}]),kL=R.makeEnum("livekit.ParticipantInfo.KindDetail",[{no:0,name:"CLOUD_AGENT"},{no:1,name:"FORWARDED"}]),$t=R.makeEnum("livekit.Encryption.Type",[{no:0,name:"NONE"},{no:1,name:"GCM"},{no:2,name:"CUSTOM"}]),SL=R.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:tr,repeated:!0}]),io=R.makeMessageType("livekit.TrackInfo",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"type",kind:"enum",T:R.getEnumType(un)},{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:R.getEnumType(at)},{no:10,name:"layers",kind:"message",T:tr,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:SL,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:R.getEnumType($t)},{no:17,name:"stream",kind:"scalar",T:9},{no:18,name:"version",kind:"message",T:sk},{no:19,name:"audio_features",kind:"enum",T:R.getEnumType(dn),repeated:!0},{no:20,name:"backup_codec_policy",kind:"enum",T:R.getEnumType(H_)}]),tr=R.makeMessageType("livekit.VideoLayer",()=>[{no:1,name:"quality",kind:"enum",T:R.getEnumType(eo)},{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}]),zt=R.makeMessageType("livekit.DataPacket",()=>[{no:1,name:"kind",kind:"enum",T:R.getEnumType(ge)},{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:Y_,oneof:"value"},{no:3,name:"speaker",kind:"message",T:wL,oneof:"value"},{no:6,name:"sip_dtmf",kind:"message",T:X_,oneof:"value"},{no:7,name:"transcription",kind:"message",T:CL,oneof:"value"},{no:8,name:"metrics",kind:"message",T:mL,oneof:"value"},{no:9,name:"chat_message",kind:"message",T:$h,oneof:"value"},{no:10,name:"rpc_request",kind:"message",T:J_,oneof:"value"},{no:11,name:"rpc_ack",kind:"message",T:Z_,oneof:"value"},{no:12,name:"rpc_response",kind:"message",T:Q_,oneof:"value"},{no:13,name:"stream_header",kind:"message",T:Kh,oneof:"value"},{no:14,name:"stream_chunk",kind:"message",T:Yh,oneof:"value"},{no:15,name:"stream_trailer",kind:"message",T:Xh,oneof:"value"}]),ge=R.makeEnum("livekit.DataPacket.Kind",[{no:0,name:"RELIABLE"},{no:1,name:"LOSSY"}]),wL=R.makeMessageType("livekit.ActiveSpeakerUpdate",()=>[{no:1,name:"speakers",kind:"message",T:K_,repeated:!0}]),K_=R.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}]),Y_=R.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},{no:8,name:"id",kind:"scalar",T:9,opt:!0},{no:9,name:"start_time",kind:"scalar",T:4,opt:!0},{no:10,name:"end_time",kind:"scalar",T:4,opt:!0},{no:11,name:"nonce",kind:"scalar",T:12}]),X_=R.makeMessageType("livekit.SipDTMF",()=>[{no:3,name:"code",kind:"scalar",T:13},{no:4,name:"digit",kind:"scalar",T:9}]),CL=R.makeMessageType("livekit.Transcription",()=>[{no:2,name:"transcribed_participant_identity",kind:"scalar",T:9},{no:3,name:"track_id",kind:"scalar",T:9},{no:4,name:"segments",kind:"message",T:TL,repeated:!0}]),TL=R.makeMessageType("livekit.TranscriptionSegment",()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"text",kind:"scalar",T:9},{no:3,name:"start_time",kind:"scalar",T:4},{no:4,name:"end_time",kind:"scalar",T:4},{no:5,name:"final",kind:"scalar",T:8},{no:6,name:"language",kind:"scalar",T:9}]),$h=R.makeMessageType("livekit.ChatMessage",()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"timestamp",kind:"scalar",T:3},{no:3,name:"edit_timestamp",kind:"scalar",T:3,opt:!0},{no:4,name:"message",kind:"scalar",T:9},{no:5,name:"deleted",kind:"scalar",T:8},{no:6,name:"generated",kind:"scalar",T:8}]),J_=R.makeMessageType("livekit.RpcRequest",()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"method",kind:"scalar",T:9},{no:3,name:"payload",kind:"scalar",T:9},{no:4,name:"response_timeout_ms",kind:"scalar",T:13},{no:5,name:"version",kind:"scalar",T:13}]),Z_=R.makeMessageType("livekit.RpcAck",()=>[{no:1,name:"request_id",kind:"scalar",T:9}]),Q_=R.makeMessageType("livekit.RpcResponse",()=>[{no:1,name:"request_id",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:9,oneof:"value"},{no:3,name:"error",kind:"message",T:ek,oneof:"value"}]),ek=R.makeMessageType("livekit.RpcError",()=>[{no:1,name:"code",kind:"scalar",T:13},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"data",kind:"scalar",T:9}]),tk=R.makeMessageType("livekit.ParticipantTracks",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"track_sids",kind:"scalar",T:9,repeated:!0}]),xL=R.makeMessageType("livekit.ServerInfo",()=>[{no:1,name:"edition",kind:"enum",T:R.getEnumType(nk)},{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},{no:7,name:"agent_protocol",kind:"scalar",T:5}]),nk=R.makeEnum("livekit.ServerInfo.Edition",[{no:0,name:"Standard"},{no:1,name:"Cloud"}]),EL=R.makeMessageType("livekit.ClientInfo",()=>[{no:1,name:"sdk",kind:"enum",T:R.getEnumType(ik)},{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},{no:11,name:"other_sdks",kind:"scalar",T:9}]),ik=R.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"},{no:11,name:"UNITY_WEB"},{no:12,name:"NODE"},{no:13,name:"UNREAL"}]),rk=R.makeMessageType("livekit.ClientConfiguration",()=>[{no:1,name:"video",kind:"message",T:ok},{no:2,name:"screen",kind:"message",T:ok},{no:3,name:"resume_connection",kind:"enum",T:R.getEnumType(ps)},{no:4,name:"disabled_codecs",kind:"message",T:IL},{no:5,name:"force_relay",kind:"enum",T:R.getEnumType(ps)}]),ok=R.makeMessageType("livekit.VideoConfiguration",()=>[{no:1,name:"hardware_encoder",kind:"enum",T:R.getEnumType(ps)}]),IL=R.makeMessageType("livekit.DisabledCodecs",()=>[{no:1,name:"codecs",kind:"message",T:eu,repeated:!0},{no:2,name:"publish",kind:"message",T:eu,repeated:!0}]),sk=R.makeMessageType("livekit.TimedVersion",()=>[{no:1,name:"unix_micro",kind:"scalar",T:3},{no:2,name:"ticks",kind:"scalar",T:5}]),Hh=R.makeEnum("livekit.DataStream.OperationType",[{no:0,name:"CREATE"},{no:1,name:"UPDATE"},{no:2,name:"DELETE"},{no:3,name:"REACTION"}]),ak=R.makeMessageType("livekit.DataStream.TextHeader",()=>[{no:1,name:"operation_type",kind:"enum",T:R.getEnumType(Hh)},{no:2,name:"version",kind:"scalar",T:5},{no:3,name:"reply_to_stream_id",kind:"scalar",T:9},{no:4,name:"attached_stream_ids",kind:"scalar",T:9,repeated:!0},{no:5,name:"generated",kind:"scalar",T:8}],{localName:"DataStream_TextHeader"}),ck=R.makeMessageType("livekit.DataStream.ByteHeader",()=>[{no:1,name:"name",kind:"scalar",T:9}],{localName:"DataStream_ByteHeader"}),Kh=R.makeMessageType("livekit.DataStream.Header",()=>[{no:1,name:"stream_id",kind:"scalar",T:9},{no:2,name:"timestamp",kind:"scalar",T:3},{no:3,name:"topic",kind:"scalar",T:9},{no:4,name:"mime_type",kind:"scalar",T:9},{no:5,name:"total_length",kind:"scalar",T:4,opt:!0},{no:7,name:"encryption_type",kind:"enum",T:R.getEnumType($t)},{no:8,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:9,name:"text_header",kind:"message",T:ak,oneof:"content_header"},{no:10,name:"byte_header",kind:"message",T:ck,oneof:"content_header"}],{localName:"DataStream_Header"}),Yh=R.makeMessageType("livekit.DataStream.Chunk",()=>[{no:1,name:"stream_id",kind:"scalar",T:9},{no:2,name:"chunk_index",kind:"scalar",T:4},{no:3,name:"content",kind:"scalar",T:12},{no:4,name:"version",kind:"scalar",T:5},{no:5,name:"iv",kind:"scalar",T:12,opt:!0}],{localName:"DataStream_Chunk"}),Xh=R.makeMessageType("livekit.DataStream.Trailer",()=>[{no:1,name:"stream_id",kind:"scalar",T:9},{no:2,name:"reason",kind:"scalar",T:9},{no:3,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}}],{localName:"DataStream_Trailer"}),hn=R.makeEnum("livekit.SignalTarget",[{no:0,name:"PUBLISHER"},{no:1,name:"SUBSCRIBER"}]),Jh=R.makeEnum("livekit.StreamState",[{no:0,name:"ACTIVE"},{no:1,name:"PAUSED"}]),RL=R.makeEnum("livekit.CandidateProtocol",[{no:0,name:"UDP"},{no:1,name:"TCP"},{no:2,name:"TLS"}]),PL=R.makeMessageType("livekit.SignalRequest",()=>[{no:1,name:"offer",kind:"message",T:nr,oneof:"message"},{no:2,name:"answer",kind:"message",T:nr,oneof:"message"},{no:3,name:"trickle",kind:"message",T:ep,oneof:"message"},{no:4,name:"add_track",kind:"message",T:Qh,oneof:"message"},{no:5,name:"mute",kind:"message",T:tp,oneof:"message"},{no:6,name:"subscription",kind:"message",T:nu,oneof:"message"},{no:7,name:"track_setting",kind:"message",T:lk,oneof:"message"},{no:8,name:"leave",kind:"message",T:iu,oneof:"message"},{no:10,name:"update_layers",kind:"message",T:hk,oneof:"message"},{no:11,name:"subscription_permission",kind:"message",T:gk,oneof:"message"},{no:12,name:"sync_state",kind:"message",T:vk,oneof:"message"},{no:13,name:"simulate",kind:"message",T:An,oneof:"message"},{no:14,name:"ping",kind:"scalar",T:3,oneof:"message"},{no:15,name:"update_metadata",kind:"message",T:pk,oneof:"message"},{no:16,name:"ping_req",kind:"message",T:bk,oneof:"message"},{no:17,name:"update_audio_track",kind:"message",T:dk,oneof:"message"},{no:18,name:"update_video_track",kind:"message",T:DL,oneof:"message"}]),uk=R.makeMessageType("livekit.SignalResponse",()=>[{no:1,name:"join",kind:"message",T:OL,oneof:"message"},{no:2,name:"answer",kind:"message",T:nr,oneof:"message"},{no:3,name:"offer",kind:"message",T:nr,oneof:"message"},{no:4,name:"trickle",kind:"message",T:ep,oneof:"message"},{no:5,name:"update",kind:"message",T:NL,oneof:"message"},{no:6,name:"track_published",kind:"message",T:np,oneof:"message"},{no:8,name:"leave",kind:"message",T:iu,oneof:"message"},{no:9,name:"mute",kind:"message",T:tp,oneof:"message"},{no:10,name:"speakers_changed",kind:"message",T:LL,oneof:"message"},{no:11,name:"room_update",kind:"message",T:UL,oneof:"message"},{no:12,name:"connection_quality",kind:"message",T:BL,oneof:"message"},{no:13,name:"stream_state_update",kind:"message",T:VL,oneof:"message"},{no:14,name:"subscribed_quality_update",kind:"message",T:qL,oneof:"message"},{no:15,name:"subscription_permission_update",kind:"message",T:WL,oneof:"message"},{no:16,name:"refresh_token",kind:"scalar",T:9,oneof:"message"},{no:17,name:"track_unpublished",kind:"message",T:ML,oneof:"message"},{no:18,name:"pong",kind:"scalar",T:3,oneof:"message"},{no:19,name:"reconnect",kind:"message",T:AL,oneof:"message"},{no:20,name:"pong_resp",kind:"message",T:$L,oneof:"message"},{no:21,name:"subscription_response",kind:"message",T:YL,oneof:"message"},{no:22,name:"request_response",kind:"message",T:XL,oneof:"message"},{no:23,name:"track_subscribed",kind:"message",T:JL,oneof:"message"},{no:24,name:"room_moved",kind:"message",T:GL,oneof:"message"}]),Zh=R.makeMessageType("livekit.SimulcastCodec",()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"cid",kind:"scalar",T:9}]),Qh=R.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:R.getEnumType(un)},{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:R.getEnumType(at)},{no:9,name:"layers",kind:"message",T:tr,repeated:!0},{no:10,name:"simulcast_codecs",kind:"message",T:Zh,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:R.getEnumType($t)},{no:15,name:"stream",kind:"scalar",T:9},{no:16,name:"backup_codec_policy",kind:"enum",T:R.getEnumType(H_)},{no:17,name:"audio_features",kind:"enum",T:R.getEnumType(dn),repeated:!0}]),ep=R.makeMessageType("livekit.TrickleRequest",()=>[{no:1,name:"candidateInit",kind:"scalar",T:9},{no:2,name:"target",kind:"enum",T:R.getEnumType(hn)},{no:3,name:"final",kind:"scalar",T:8}]),tp=R.makeMessageType("livekit.MuteTrackRequest",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"muted",kind:"scalar",T:8}]),OL=R.makeMessageType("livekit.JoinResponse",()=>[{no:1,name:"room",kind:"message",T:Qc},{no:2,name:"participant",kind:"message",T:er},{no:3,name:"other_participants",kind:"message",T:er,repeated:!0},{no:4,name:"server_version",kind:"scalar",T:9},{no:5,name:"ice_servers",kind:"message",T:fk,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:rk},{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:xL},{no:13,name:"sif_trailer",kind:"scalar",T:12},{no:14,name:"enabled_publish_codecs",kind:"message",T:eu,repeated:!0},{no:15,name:"fast_publish",kind:"scalar",T:8}]),AL=R.makeMessageType("livekit.ReconnectResponse",()=>[{no:1,name:"ice_servers",kind:"message",T:fk,repeated:!0},{no:2,name:"client_configuration",kind:"message",T:rk}]),np=R.makeMessageType("livekit.TrackPublishedResponse",()=>[{no:1,name:"cid",kind:"scalar",T:9},{no:2,name:"track",kind:"message",T:io}]),ML=R.makeMessageType("livekit.TrackUnpublishedResponse",()=>[{no:1,name:"track_sid",kind:"scalar",T:9}]),nr=R.makeMessageType("livekit.SessionDescription",()=>[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"sdp",kind:"scalar",T:9}]),NL=R.makeMessageType("livekit.ParticipantUpdate",()=>[{no:1,name:"participants",kind:"message",T:er,repeated:!0}]),nu=R.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:tk,repeated:!0}]),lk=R.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:R.getEnumType(eo)},{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}]),dk=R.makeMessageType("livekit.UpdateLocalAudioTrack",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"features",kind:"enum",T:R.getEnumType(dn),repeated:!0}]),DL=R.makeMessageType("livekit.UpdateLocalVideoTrack",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"width",kind:"scalar",T:13},{no:3,name:"height",kind:"scalar",T:13}]),iu=R.makeMessageType("livekit.LeaveRequest",()=>[{no:1,name:"can_reconnect",kind:"scalar",T:8},{no:2,name:"reason",kind:"enum",T:R.getEnumType(ln)},{no:3,name:"action",kind:"enum",T:R.getEnumType(ro)},{no:4,name:"regions",kind:"message",T:HL}]),ro=R.makeEnum("livekit.LeaveRequest.Action",[{no:0,name:"DISCONNECT"},{no:1,name:"RESUME"},{no:2,name:"RECONNECT"}]),hk=R.makeMessageType("livekit.UpdateVideoLayers",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"layers",kind:"message",T:tr,repeated:!0}]),pk=R.makeMessageType("livekit.UpdateParticipantMetadata",()=>[{no:1,name:"metadata",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:4,name:"request_id",kind:"scalar",T:13}]),fk=R.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}]),LL=R.makeMessageType("livekit.SpeakersChanged",()=>[{no:1,name:"speakers",kind:"message",T:K_,repeated:!0}]),UL=R.makeMessageType("livekit.RoomUpdate",()=>[{no:1,name:"room",kind:"message",T:Qc}]),FL=R.makeMessageType("livekit.ConnectionQualityInfo",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"quality",kind:"enum",T:R.getEnumType(hs)},{no:3,name:"score",kind:"scalar",T:2}]),BL=R.makeMessageType("livekit.ConnectionQualityUpdate",()=>[{no:1,name:"updates",kind:"message",T:FL,repeated:!0}]),jL=R.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:R.getEnumType(Jh)}]),VL=R.makeMessageType("livekit.StreamStateUpdate",()=>[{no:1,name:"stream_states",kind:"message",T:jL,repeated:!0}]),ip=R.makeMessageType("livekit.SubscribedQuality",()=>[{no:1,name:"quality",kind:"enum",T:R.getEnumType(eo)},{no:2,name:"enabled",kind:"scalar",T:8}]),zL=R.makeMessageType("livekit.SubscribedCodec",()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"qualities",kind:"message",T:ip,repeated:!0}]),qL=R.makeMessageType("livekit.SubscribedQualityUpdate",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"subscribed_qualities",kind:"message",T:ip,repeated:!0},{no:3,name:"subscribed_codecs",kind:"message",T:zL,repeated:!0}]),mk=R.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}]),gk=R.makeMessageType("livekit.SubscriptionPermission",()=>[{no:1,name:"all_participants",kind:"scalar",T:8},{no:2,name:"track_permissions",kind:"message",T:mk,repeated:!0}]),WL=R.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}]),GL=R.makeMessageType("livekit.RoomMovedResponse",()=>[{no:1,name:"room",kind:"message",T:Qc},{no:2,name:"token",kind:"scalar",T:9},{no:3,name:"participant",kind:"message",T:er},{no:4,name:"other_participants",kind:"message",T:er,repeated:!0}]),vk=R.makeMessageType("livekit.SyncState",()=>[{no:1,name:"answer",kind:"message",T:nr},{no:2,name:"subscription",kind:"message",T:nu},{no:3,name:"publish_tracks",kind:"message",T:np,repeated:!0},{no:4,name:"data_channels",kind:"message",T:yk,repeated:!0},{no:5,name:"offer",kind:"message",T:nr},{no:6,name:"track_sids_disabled",kind:"scalar",T:9,repeated:!0}]),yk=R.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:R.getEnumType(hn)}]),An=R.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:R.getEnumType(RL),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"},{no:9,name:"leave_request_full_reconnect",kind:"scalar",T:8,oneof:"scenario"}]),bk=R.makeMessageType("livekit.Ping",()=>[{no:1,name:"timestamp",kind:"scalar",T:3},{no:2,name:"rtt",kind:"scalar",T:3}]),$L=R.makeMessageType("livekit.Pong",()=>[{no:1,name:"last_ping_timestamp",kind:"scalar",T:3},{no:2,name:"timestamp",kind:"scalar",T:3}]),HL=R.makeMessageType("livekit.RegionSettings",()=>[{no:1,name:"regions",kind:"message",T:KL,repeated:!0}]),KL=R.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}]),YL=R.makeMessageType("livekit.SubscriptionResponse",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"err",kind:"enum",T:R.getEnumType(bL)}]),XL=R.makeMessageType("livekit.RequestResponse",()=>[{no:1,name:"request_id",kind:"scalar",T:13},{no:2,name:"reason",kind:"enum",T:R.getEnumType(rp)},{no:3,name:"message",kind:"scalar",T:9}]),rp=R.makeEnum("livekit.RequestResponse.Reason",[{no:0,name:"OK"},{no:1,name:"NOT_FOUND"},{no:2,name:"NOT_ALLOWED"},{no:3,name:"LIMIT_EXCEEDED"}]),JL=R.makeMessageType("livekit.TrackSubscribed",()=>[{no:1,name:"track_sid",kind:"scalar",T:9}]);function ZL(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var ru={exports:{}},QL=ru.exports,_k;function e3(){return _k||(_k=1,function(n){(function(e,t){n.exports?n.exports=t():e.log=t()})(QL,function(){var e=function(){},t="undefined",i=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),r=["trace","debug","info","warn","error"],o={},s=null;function a(f,g){var y=f[g];if(typeof y.bind=="function")return y.bind(f);try{return Function.prototype.bind.call(y,f)}catch{return function(){return Function.prototype.apply.apply(y,[f,arguments])}}}function c(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function u(f){return f==="debug"&&(f="log"),typeof console===t?!1:f==="trace"&&i?c:console[f]!==void 0?a(console,f):console.log!==void 0?a(console,"log"):e}function l(){for(var f=this.getLevel(),g=0;g<r.length;g++){var y=r[g];this[y]=g<f?e:this.methodFactory(y,f,this.name)}if(this.log=this.debug,typeof console===t&&f<this.levels.SILENT)return"No console available for logging"}function d(f){return function(){typeof console!==t&&(l.call(this),this[f].apply(this,arguments))}}function h(f,g,y){return u(f)||d.apply(this,arguments)}function p(f,g){var y=this,b,S,w,k="loglevel";typeof f=="string"?k+=":"+f:typeof f=="symbol"&&(k=void 0);function C(A){var L=(r[A]||"silent").toUpperCase();if(!(typeof window===t||!k)){try{window.localStorage[k]=L;return}catch{}try{window.document.cookie=encodeURIComponent(k)+"="+L+";"}catch{}}}function x(){var A;if(!(typeof window===t||!k)){try{A=window.localStorage[k]}catch{}if(typeof A===t)try{var L=window.document.cookie,V=encodeURIComponent(k),Y=L.indexOf(V+"=");Y!==-1&&(A=/^([^;]+)/.exec(L.slice(Y+V.length+1))[1])}catch{}return y.levels[A]===void 0&&(A=void 0),A}}function I(){if(!(typeof window===t||!k)){try{window.localStorage.removeItem(k)}catch{}try{window.document.cookie=encodeURIComponent(k)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function P(A){var L=A;if(typeof L=="string"&&y.levels[L.toUpperCase()]!==void 0&&(L=y.levels[L.toUpperCase()]),typeof L=="number"&&L>=0&&L<=y.levels.SILENT)return L;throw new TypeError("log.setLevel() called with invalid level: "+A)}y.name=f,y.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},y.methodFactory=g||h,y.getLevel=function(){return w??S??b},y.setLevel=function(A,L){return w=P(A),L!==!1&&C(w),l.call(y)},y.setDefaultLevel=function(A){S=P(A),x()||y.setLevel(A,!1)},y.resetLevel=function(){w=null,I(),l.call(y)},y.enableAll=function(A){y.setLevel(y.levels.TRACE,A)},y.disableAll=function(A){y.setLevel(y.levels.SILENT,A)},y.rebuild=function(){if(s!==y&&(b=P(s.getLevel())),l.call(y),s===y)for(var A in o)o[A].rebuild()},b=P(s?s.getLevel():"WARN");var D=x();D!=null&&(w=P(D)),l.call(y)}s=new p,s.getLogger=function(g){if(typeof g!="symbol"&&typeof g!="string"||g==="")throw new TypeError("You must supply a name when creating a logger.");var y=o[g];return y||(y=o[g]=new p(g,s.methodFactory)),y};var m=typeof window!==t?window.log:void 0;return s.noConflict=function(){return typeof window!==t&&window.log===s&&(window.log=m),s},s.getLoggers=function(){return o},s.default=s,s})}(ru)),ru.exports}var ou=e3(),op;(function(n){n[n.trace=0]="trace",n[n.debug=1]="debug",n[n.info=2]="info",n[n.warn=3]="warn",n[n.error=4]="error",n[n.silent=5]="silent"})(op||(op={}));var pn;(function(n){n.Default="livekit",n.Room="livekit-room",n.Participant="livekit-participant",n.Track="livekit-track",n.Publication="livekit-track-publication",n.Engine="livekit-engine",n.Signal="livekit-signal",n.PCManager="livekit-pc-manager",n.PCTransport="livekit-pc-transport",n.E2EE="lk-e2ee"})(pn||(pn={}));let le=ou.getLogger("livekit");Object.values(pn).map(n=>ou.getLogger(n)),le.setDefaultLevel(op.info);function Kn(n){const e=ou.getLogger(n);return e.setDefaultLevel(le.getLevel()),e}const t3=ou.getLogger("lk-e2ee"),fs=7e3,n3=[0,300,2*2*300,3*3*300,4*4*300,fs,fs,fs,fs,fs];class i3{constructor(e){this._retryDelays=e!==void 0?[...e]:n3}nextRetryDelayInMs(e){if(e.retryCount>=this._retryDelays.length)return null;const t=this._retryDelays[e.retryCount];return e.retryCount<=1?t:t+Math.random()*1e3}}function r3(n,e){var t={};for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(n);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(n,i[r])&&(t[i[r]]=n[i[r]]);return t}function T(n,e,t,i){function r(o){return o instanceof t?o:new t(function(s){s(o)})}return new(t||(t=Promise))(function(o,s){function a(l){try{u(i.next(l))}catch(d){s(d)}}function c(l){try{u(i.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):r(l.value).then(a,c)}u((i=i.apply(n,e||[])).next())})}function kk(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function xi(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof kk=="function"?kk(n):n[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(o){t[o]=n[o]&&function(s){return new Promise(function(a,c){s=n[o](s),r(a,c,s.done,s.value)})}}function r(o,s,a,c){Promise.resolve(c).then(function(u){o({value:u,done:a})},s)}}typeof SuppressedError=="function"&&SuppressedError;var su={exports:{}},Sk;function o3(){if(Sk)return su.exports;Sk=1;var n=typeof Reflect=="object"?Reflect:null,e=n&&typeof n.apply=="function"?n.apply:function(k,C,x){return Function.prototype.apply.call(k,C,x)},t;n&&typeof n.ownKeys=="function"?t=n.ownKeys:Object.getOwnPropertySymbols?t=function(k){return Object.getOwnPropertyNames(k).concat(Object.getOwnPropertySymbols(k))}:t=function(k){return Object.getOwnPropertyNames(k)};function i(w){console&&console.warn&&console.warn(w)}var r=Number.isNaN||function(k){return k!==k};function o(){o.init.call(this)}su.exports=o,su.exports.once=y,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(w){if(typeof w!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof w)}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(w){if(typeof w!="number"||w<0||r(w))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+w+".");s=w}}),o.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(k){if(typeof k!="number"||k<0||r(k))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+k+".");return this._maxListeners=k,this};function c(w){return w._maxListeners===void 0?o.defaultMaxListeners:w._maxListeners}o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(k){for(var C=[],x=1;x<arguments.length;x++)C.push(arguments[x]);var I=k==="error",P=this._events;if(P!==void 0)I=I&&P.error===void 0;else if(!I)return!1;if(I){var D;if(C.length>0&&(D=C[0]),D instanceof Error)throw D;var A=new Error("Unhandled error."+(D?" ("+D.message+")":""));throw A.context=D,A}var L=P[k];if(L===void 0)return!1;if(typeof L=="function")e(L,this,C);else for(var V=L.length,Y=m(L,V),x=0;x<V;++x)e(Y[x],this,C);return!0};function u(w,k,C,x){var I,P,D;if(a(C),P=w._events,P===void 0?(P=w._events=Object.create(null),w._eventsCount=0):(P.newListener!==void 0&&(w.emit("newListener",k,C.listener?C.listener:C),P=w._events),D=P[k]),D===void 0)D=P[k]=C,++w._eventsCount;else if(typeof D=="function"?D=P[k]=x?[C,D]:[D,C]:x?D.unshift(C):D.push(C),I=c(w),I>0&&D.length>I&&!D.warned){D.warned=!0;var A=new Error("Possible EventEmitter memory leak detected. "+D.length+" "+String(k)+" listeners added. Use emitter.setMaxListeners() to increase limit");A.name="MaxListenersExceededWarning",A.emitter=w,A.type=k,A.count=D.length,i(A)}return w}o.prototype.addListener=function(k,C){return u(this,k,C,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(k,C){return u(this,k,C,!0)};function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(w,k,C){var x={fired:!1,wrapFn:void 0,target:w,type:k,listener:C},I=l.bind(x);return I.listener=C,x.wrapFn=I,I}o.prototype.once=function(k,C){return a(C),this.on(k,d(this,k,C)),this},o.prototype.prependOnceListener=function(k,C){return a(C),this.prependListener(k,d(this,k,C)),this},o.prototype.removeListener=function(k,C){var x,I,P,D,A;if(a(C),I=this._events,I===void 0)return this;if(x=I[k],x===void 0)return this;if(x===C||x.listener===C)--this._eventsCount===0?this._events=Object.create(null):(delete I[k],I.removeListener&&this.emit("removeListener",k,x.listener||C));else if(typeof x!="function"){for(P=-1,D=x.length-1;D>=0;D--)if(x[D]===C||x[D].listener===C){A=x[D].listener,P=D;break}if(P<0)return this;P===0?x.shift():f(x,P),x.length===1&&(I[k]=x[0]),I.removeListener!==void 0&&this.emit("removeListener",k,A||C)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(k){var C,x,I;if(x=this._events,x===void 0)return this;if(x.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):x[k]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete x[k]),this;if(arguments.length===0){var P=Object.keys(x),D;for(I=0;I<P.length;++I)D=P[I],D!=="removeListener"&&this.removeAllListeners(D);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(C=x[k],typeof C=="function")this.removeListener(k,C);else if(C!==void 0)for(I=C.length-1;I>=0;I--)this.removeListener(k,C[I]);return this};function h(w,k,C){var x=w._events;if(x===void 0)return[];var I=x[k];return I===void 0?[]:typeof I=="function"?C?[I.listener||I]:[I]:C?g(I):m(I,I.length)}o.prototype.listeners=function(k){return h(this,k,!0)},o.prototype.rawListeners=function(k){return h(this,k,!1)},o.listenerCount=function(w,k){return typeof w.listenerCount=="function"?w.listenerCount(k):p.call(w,k)},o.prototype.listenerCount=p;function p(w){var k=this._events;if(k!==void 0){var C=k[w];if(typeof C=="function")return 1;if(C!==void 0)return C.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function m(w,k){for(var C=new Array(k),x=0;x<k;++x)C[x]=w[x];return C}function f(w,k){for(;k+1<w.length;k++)w[k]=w[k+1];w.pop()}function g(w){for(var k=new Array(w.length),C=0;C<k.length;++C)k[C]=w[C].listener||w[C];return k}function y(w,k){return new Promise(function(C,x){function I(D){w.removeListener(k,P),x(D)}function P(){typeof w.removeListener=="function"&&w.removeListener("error",I),C([].slice.call(arguments))}S(w,k,P,{once:!0}),k!=="error"&&b(w,I,{once:!0})})}function b(w,k,C){typeof w.on=="function"&&S(w,"error",k,C)}function S(w,k,C,x){if(typeof w.on=="function")x.once?w.once(k,C):w.on(k,C);else if(typeof w.addEventListener=="function")w.addEventListener(k,function I(P){x.once&&w.removeEventListener(k,I),C(P)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof w)}return su.exports}var Mn=o3();let wk=!0,Ck=!0;function au(n,e,t){const i=n.match(e);return i&&i.length>=t&&parseInt(i[t],10)}function ir(n,e,t){if(!n.RTCPeerConnection)return;const i=n.RTCPeerConnection.prototype,r=i.addEventListener;i.addEventListener=function(s,a){if(s!==e)return r.apply(this,arguments);const c=u=>{const l=t(u);l&&(a.handleEvent?a.handleEvent(l):a(l))};return this._eventMap=this._eventMap||{},this._eventMap[e]||(this._eventMap[e]=new Map),this._eventMap[e].set(a,c),r.apply(this,[s,c])};const o=i.removeEventListener;i.removeEventListener=function(s,a){if(s!==e||!this._eventMap||!this._eventMap[e])return o.apply(this,arguments);if(!this._eventMap[e].has(a))return o.apply(this,arguments);const c=this._eventMap[e].get(a);return this._eventMap[e].delete(a),this._eventMap[e].size===0&&delete this._eventMap[e],Object.keys(this._eventMap).length===0&&delete this._eventMap,o.apply(this,[s,c])},Object.defineProperty(i,"on"+e,{get(){return this["_on"+e]},set(s){this["_on"+e]&&(this.removeEventListener(e,this["_on"+e]),delete this["_on"+e]),s&&this.addEventListener(e,this["_on"+e]=s)},enumerable:!0,configurable:!0})}function s3(n){return typeof n!="boolean"?new Error("Argument type: "+typeof n+". Please use a boolean."):(wk=n,n?"adapter.js logging disabled":"adapter.js logging enabled")}function a3(n){return typeof n!="boolean"?new Error("Argument type: "+typeof n+". Please use a boolean."):(Ck=!n,"adapter.js deprecation warnings "+(n?"disabled":"enabled"))}function Tk(){if(typeof window=="object"){if(wk)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function sp(n,e){Ck&&console.warn(n+" is deprecated, please use "+e+" instead.")}function c3(n){const e={browser:null,version:null};if(typeof n>"u"||!n.navigator||!n.navigator.userAgent)return e.browser="Not a browser.",e;const{navigator:t}=n;if(t.userAgentData&&t.userAgentData.brands){const i=t.userAgentData.brands.find(r=>r.brand==="Chromium");if(i)return{browser:"chrome",version:parseInt(i.version,10)}}if(t.mozGetUserMedia)e.browser="firefox",e.version=au(t.userAgent,/Firefox\/(\d+)\./,1);else if(t.webkitGetUserMedia||n.isSecureContext===!1&&n.webkitRTCPeerConnection)e.browser="chrome",e.version=au(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(n.RTCPeerConnection&&t.userAgent.match(/AppleWebKit\/(\d+)\./))e.browser="safari",e.version=au(t.userAgent,/AppleWebKit\/(\d+)\./,1),e.supportsUnifiedPlan=n.RTCRtpTransceiver&&"currentDirection"in n.RTCRtpTransceiver.prototype;else return e.browser="Not a supported browser.",e;return e}function xk(n){return Object.prototype.toString.call(n)==="[object Object]"}function Ek(n){return xk(n)?Object.keys(n).reduce(function(e,t){const i=xk(n[t]),r=i?Ek(n[t]):n[t],o=i&&!Object.keys(r).length;return r===void 0||o?e:Object.assign(e,{[t]:r})},{}):n}function ap(n,e,t){!e||t.has(e.id)||(t.set(e.id,e),Object.keys(e).forEach(i=>{i.endsWith("Id")?ap(n,n.get(e[i]),t):i.endsWith("Ids")&&e[i].forEach(r=>{ap(n,n.get(r),t)})}))}function Ik(n,e,t){const i=t?"outbound-rtp":"inbound-rtp",r=new Map;if(e===null)return r;const o=[];return n.forEach(s=>{s.type==="track"&&s.trackIdentifier===e.id&&o.push(s)}),o.forEach(s=>{n.forEach(a=>{a.type===i&&a.trackId===s.id&&ap(n,a,r)})}),r}const Rk=Tk;function Pk(n,e){const t=n&&n.navigator;if(!t.mediaDevices)return;const i=function(a){if(typeof a!="object"||a.mandatory||a.optional)return a;const c={};return Object.keys(a).forEach(u=>{if(u==="require"||u==="advanced"||u==="mediaSource")return;const l=typeof a[u]=="object"?a[u]:{ideal:a[u]};l.exact!==void 0&&typeof l.exact=="number"&&(l.min=l.max=l.exact);const d=function(h,p){return h?h+p.charAt(0).toUpperCase()+p.slice(1):p==="deviceId"?"sourceId":p};if(l.ideal!==void 0){c.optional=c.optional||[];let h={};typeof l.ideal=="number"?(h[d("min",u)]=l.ideal,c.optional.push(h),h={},h[d("max",u)]=l.ideal,c.optional.push(h)):(h[d("",u)]=l.ideal,c.optional.push(h))}l.exact!==void 0&&typeof l.exact!="number"?(c.mandatory=c.mandatory||{},c.mandatory[d("",u)]=l.exact):["min","max"].forEach(h=>{l[h]!==void 0&&(c.mandatory=c.mandatory||{},c.mandatory[d(h,u)]=l[h])})}),a.advanced&&(c.optional=(c.optional||[]).concat(a.advanced)),c},r=function(a,c){if(e.version>=61)return c(a);if(a=JSON.parse(JSON.stringify(a)),a&&typeof a.audio=="object"){const u=function(l,d,h){d in l&&!(h in l)&&(l[h]=l[d],delete l[d])};a=JSON.parse(JSON.stringify(a)),u(a.audio,"autoGainControl","googAutoGainControl"),u(a.audio,"noiseSuppression","googNoiseSuppression"),a.audio=i(a.audio)}if(a&&typeof a.video=="object"){let u=a.video.facingMode;u=u&&(typeof u=="object"?u:{ideal:u});const l=e.version<66;if(u&&(u.exact==="user"||u.exact==="environment"||u.ideal==="user"||u.ideal==="environment")&&!(t.mediaDevices.getSupportedConstraints&&t.mediaDevices.getSupportedConstraints().facingMode&&!l)){delete a.video.facingMode;let d;if(u.exact==="environment"||u.ideal==="environment"?d=["back","rear"]:(u.exact==="user"||u.ideal==="user")&&(d=["front"]),d)return t.mediaDevices.enumerateDevices().then(h=>{h=h.filter(m=>m.kind==="videoinput");let p=h.find(m=>d.some(f=>m.label.toLowerCase().includes(f)));return!p&&h.length&&d.includes("back")&&(p=h[h.length-1]),p&&(a.video.deviceId=u.exact?{exact:p.deviceId}:{ideal:p.deviceId}),a.video=i(a.video),Rk("chrome: "+JSON.stringify(a)),c(a)})}a.video=i(a.video)}return Rk("chrome: "+JSON.stringify(a)),c(a)},o=function(a){return e.version>=64?a:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[a.name]||a.name,message:a.message,constraint:a.constraint||a.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}},s=function(a,c,u){r(a,l=>{t.webkitGetUserMedia(l,c,d=>{u&&u(o(d))})})};if(t.getUserMedia=s.bind(t),t.mediaDevices.getUserMedia){const a=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(c){return r(c,u=>a(u).then(l=>{if(u.audio&&!l.getAudioTracks().length||u.video&&!l.getVideoTracks().length)throw l.getTracks().forEach(d=>{d.stop()}),new DOMException("","NotFoundError");return l},l=>Promise.reject(o(l))))}}}function Ok(n){n.MediaStream=n.MediaStream||n.webkitMediaStream}function Ak(n){if(typeof n=="object"&&n.RTCPeerConnection&&!("ontrack"in n.RTCPeerConnection.prototype)){Object.defineProperty(n.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(t){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=t)},enumerable:!0,configurable:!0});const e=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=i=>{i.stream.addEventListener("addtrack",r=>{let o;n.RTCPeerConnection.prototype.getReceivers?o=this.getReceivers().find(a=>a.track&&a.track.id===r.track.id):o={track:r.track};const s=new Event("track");s.track=r.track,s.receiver=o,s.transceiver={receiver:o},s.streams=[i.stream],this.dispatchEvent(s)}),i.stream.getTracks().forEach(r=>{let o;n.RTCPeerConnection.prototype.getReceivers?o=this.getReceivers().find(a=>a.track&&a.track.id===r.id):o={track:r};const s=new Event("track");s.track=r,s.receiver=o,s.transceiver={receiver:o},s.streams=[i.stream],this.dispatchEvent(s)})},this.addEventListener("addstream",this._ontrackpoly)),e.apply(this,arguments)}}else ir(n,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e))}function Mk(n){if(typeof n=="object"&&n.RTCPeerConnection&&!("getSenders"in n.RTCPeerConnection.prototype)&&"createDTMFSender"in n.RTCPeerConnection.prototype){const e=function(r,o){return{track:o,get dtmf(){return this._dtmf===void 0&&(o.kind==="audio"?this._dtmf=r.createDTMFSender(o):this._dtmf=null),this._dtmf},_pc:r}};if(!n.RTCPeerConnection.prototype.getSenders){n.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const r=n.RTCPeerConnection.prototype.addTrack;n.RTCPeerConnection.prototype.addTrack=function(a,c){let u=r.apply(this,arguments);return u||(u=e(this,a),this._senders.push(u)),u};const o=n.RTCPeerConnection.prototype.removeTrack;n.RTCPeerConnection.prototype.removeTrack=function(a){o.apply(this,arguments);const c=this._senders.indexOf(a);c!==-1&&this._senders.splice(c,1)}}const t=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(o){this._senders=this._senders||[],t.apply(this,[o]),o.getTracks().forEach(s=>{this._senders.push(e(this,s))})};const i=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(o){this._senders=this._senders||[],i.apply(this,[o]),o.getTracks().forEach(s=>{const a=this._senders.find(c=>c.track===s);a&&this._senders.splice(this._senders.indexOf(a),1)})}}else if(typeof n=="object"&&n.RTCPeerConnection&&"getSenders"in n.RTCPeerConnection.prototype&&"createDTMFSender"in n.RTCPeerConnection.prototype&&n.RTCRtpSender&&!("dtmf"in n.RTCRtpSender.prototype)){const e=n.RTCPeerConnection.prototype.getSenders;n.RTCPeerConnection.prototype.getSenders=function(){const i=e.apply(this,[]);return i.forEach(r=>r._pc=this),i},Object.defineProperty(n.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function Nk(n){if(!(typeof n=="object"&&n.RTCPeerConnection&&n.RTCRtpSender&&n.RTCRtpReceiver))return;if(!("getStats"in n.RTCRtpSender.prototype)){const t=n.RTCPeerConnection.prototype.getSenders;t&&(n.RTCPeerConnection.prototype.getSenders=function(){const o=t.apply(this,[]);return o.forEach(s=>s._pc=this),o});const i=n.RTCPeerConnection.prototype.addTrack;i&&(n.RTCPeerConnection.prototype.addTrack=function(){const o=i.apply(this,arguments);return o._pc=this,o}),n.RTCRtpSender.prototype.getStats=function(){const o=this;return this._pc.getStats().then(s=>Ik(s,o.track,!0))}}if(!("getStats"in n.RTCRtpReceiver.prototype)){const t=n.RTCPeerConnection.prototype.getReceivers;t&&(n.RTCPeerConnection.prototype.getReceivers=function(){const r=t.apply(this,[]);return r.forEach(o=>o._pc=this),r}),ir(n,"track",i=>(i.receiver._pc=i.srcElement,i)),n.RTCRtpReceiver.prototype.getStats=function(){const r=this;return this._pc.getStats().then(o=>Ik(o,r.track,!1))}}if(!("getStats"in n.RTCRtpSender.prototype&&"getStats"in n.RTCRtpReceiver.prototype))return;const e=n.RTCPeerConnection.prototype.getStats;n.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof n.MediaStreamTrack){const i=arguments[0];let r,o,s;return this.getSenders().forEach(a=>{a.track===i&&(r?s=!0:r=a)}),this.getReceivers().forEach(a=>(a.track===i&&(o?s=!0:o=a),a.track===i)),s||r&&o?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):r?r.getStats():o?o.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return e.apply(this,arguments)}}function Dk(n){n.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(s=>this._shimmedLocalStreams[s][0])};const e=n.RTCPeerConnection.prototype.addTrack;n.RTCPeerConnection.prototype.addTrack=function(s,a){if(!a)return e.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const c=e.apply(this,arguments);return this._shimmedLocalStreams[a.id]?this._shimmedLocalStreams[a.id].indexOf(c)===-1&&this._shimmedLocalStreams[a.id].push(c):this._shimmedLocalStreams[a.id]=[a,c],c};const t=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(s){this._shimmedLocalStreams=this._shimmedLocalStreams||{},s.getTracks().forEach(u=>{if(this.getSenders().find(d=>d.track===u))throw new DOMException("Track already exists.","InvalidAccessError")});const a=this.getSenders();t.apply(this,arguments);const c=this.getSenders().filter(u=>a.indexOf(u)===-1);this._shimmedLocalStreams[s.id]=[s].concat(c)};const i=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(s){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[s.id],i.apply(this,arguments)};const r=n.RTCPeerConnection.prototype.removeTrack;n.RTCPeerConnection.prototype.removeTrack=function(s){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},s&&Object.keys(this._shimmedLocalStreams).forEach(a=>{const c=this._shimmedLocalStreams[a].indexOf(s);c!==-1&&this._shimmedLocalStreams[a].splice(c,1),this._shimmedLocalStreams[a].length===1&&delete this._shimmedLocalStreams[a]}),r.apply(this,arguments)}}function Lk(n,e){if(!n.RTCPeerConnection)return;if(n.RTCPeerConnection.prototype.addTrack&&e.version>=65)return Dk(n);const t=n.RTCPeerConnection.prototype.getLocalStreams;n.RTCPeerConnection.prototype.getLocalStreams=function(){const l=t.apply(this);return this._reverseStreams=this._reverseStreams||{},l.map(d=>this._reverseStreams[d.id])};const i=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(l){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},l.getTracks().forEach(d=>{if(this.getSenders().find(p=>p.track===d))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[l.id]){const d=new n.MediaStream(l.getTracks());this._streams[l.id]=d,this._reverseStreams[d.id]=l,l=d}i.apply(this,[l])};const r=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(l){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},r.apply(this,[this._streams[l.id]||l]),delete this._reverseStreams[this._streams[l.id]?this._streams[l.id].id:l.id],delete this._streams[l.id]},n.RTCPeerConnection.prototype.addTrack=function(l,d){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const h=[].slice.call(arguments,1);if(h.length!==1||!h[0].getTracks().find(f=>f===l))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(f=>f.track===l))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const m=this._streams[d.id];if(m)m.addTrack(l),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const f=new n.MediaStream([l]);this._streams[d.id]=f,this._reverseStreams[f.id]=d,this.addStream(f)}return this.getSenders().find(f=>f.track===l)};function o(u,l){let d=l.sdp;return Object.keys(u._reverseStreams||[]).forEach(h=>{const p=u._reverseStreams[h],m=u._streams[p.id];d=d.replace(new RegExp(m.id,"g"),p.id)}),new RTCSessionDescription({type:l.type,sdp:d})}function s(u,l){let d=l.sdp;return Object.keys(u._reverseStreams||[]).forEach(h=>{const p=u._reverseStreams[h],m=u._streams[p.id];d=d.replace(new RegExp(p.id,"g"),m.id)}),new RTCSessionDescription({type:l.type,sdp:d})}["createOffer","createAnswer"].forEach(function(u){const l=n.RTCPeerConnection.prototype[u],d={[u](){const h=arguments;return arguments.length&&typeof arguments[0]=="function"?l.apply(this,[m=>{const f=o(this,m);h[0].apply(null,[f])},m=>{h[1]&&h[1].apply(null,m)},arguments[2]]):l.apply(this,arguments).then(m=>o(this,m))}};n.RTCPeerConnection.prototype[u]=d[u]});const a=n.RTCPeerConnection.prototype.setLocalDescription;n.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type?a.apply(this,arguments):(arguments[0]=s(this,arguments[0]),a.apply(this,arguments))};const c=Object.getOwnPropertyDescriptor(n.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(n.RTCPeerConnection.prototype,"localDescription",{get(){const u=c.get.apply(this);return u.type===""?u:o(this,u)}}),n.RTCPeerConnection.prototype.removeTrack=function(l){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!l._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(l._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};let h;Object.keys(this._streams).forEach(p=>{this._streams[p].getTracks().find(f=>l.track===f)&&(h=this._streams[p])}),h&&(h.getTracks().length===1?this.removeStream(this._reverseStreams[h.id]):h.removeTrack(l.track),this.dispatchEvent(new Event("negotiationneeded")))}}function cp(n,e){!n.RTCPeerConnection&&n.webkitRTCPeerConnection&&(n.RTCPeerConnection=n.webkitRTCPeerConnection),n.RTCPeerConnection&&e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){const i=n.RTCPeerConnection.prototype[t],r={[t](){return arguments[0]=new(t==="addIceCandidate"?n.RTCIceCandidate:n.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}};n.RTCPeerConnection.prototype[t]=r[t]})}function Uk(n,e){ir(n,"negotiationneeded",t=>{const i=t.target;if(!((e.version<72||i.getConfiguration&&i.getConfiguration().sdpSemantics==="plan-b")&&i.signalingState!=="stable"))return t})}var Fk=Object.freeze({__proto__:null,fixNegotiationNeeded:Uk,shimAddTrackRemoveTrack:Lk,shimAddTrackRemoveTrackWithNative:Dk,shimGetSendersWithDtmf:Mk,shimGetUserMedia:Pk,shimMediaStream:Ok,shimOnTrack:Ak,shimPeerConnection:cp,shimSenderReceiverGetStats:Nk});function Bk(n,e){const t=n&&n.navigator,i=n&&n.MediaStreamTrack;if(t.getUserMedia=function(r,o,s){sp("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),t.mediaDevices.getUserMedia(r).then(o,s)},!(e.version>55&&"autoGainControl"in t.mediaDevices.getSupportedConstraints())){const r=function(s,a,c){a in s&&!(c in s)&&(s[c]=s[a],delete s[a])},o=t.mediaDevices.getUserMedia.bind(t.mediaDevices);if(t.mediaDevices.getUserMedia=function(s){return typeof s=="object"&&typeof s.audio=="object"&&(s=JSON.parse(JSON.stringify(s)),r(s.audio,"autoGainControl","mozAutoGainControl"),r(s.audio,"noiseSuppression","mozNoiseSuppression")),o(s)},i&&i.prototype.getSettings){const s=i.prototype.getSettings;i.prototype.getSettings=function(){const a=s.apply(this,arguments);return r(a,"mozAutoGainControl","autoGainControl"),r(a,"mozNoiseSuppression","noiseSuppression"),a}}if(i&&i.prototype.applyConstraints){const s=i.prototype.applyConstraints;i.prototype.applyConstraints=function(a){return this.kind==="audio"&&typeof a=="object"&&(a=JSON.parse(JSON.stringify(a)),r(a,"autoGainControl","mozAutoGainControl"),r(a,"noiseSuppression","mozNoiseSuppression")),s.apply(this,[a])}}}}function u3(n,e){n.navigator.mediaDevices&&"getDisplayMedia"in n.navigator.mediaDevices||n.navigator.mediaDevices&&(n.navigator.mediaDevices.getDisplayMedia=function(i){if(!(i&&i.video)){const r=new DOMException("getDisplayMedia without video constraints is undefined");return r.name="NotFoundError",r.code=8,Promise.reject(r)}return i.video===!0?i.video={mediaSource:e}:i.video.mediaSource=e,n.navigator.mediaDevices.getUserMedia(i)})}function jk(n){typeof n=="object"&&n.RTCTrackEvent&&"receiver"in n.RTCTrackEvent.prototype&&!("transceiver"in n.RTCTrackEvent.prototype)&&Object.defineProperty(n.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function up(n,e){if(typeof n!="object"||!(n.RTCPeerConnection||n.mozRTCPeerConnection))return;!n.RTCPeerConnection&&n.mozRTCPeerConnection&&(n.RTCPeerConnection=n.mozRTCPeerConnection),e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(r){const o=n.RTCPeerConnection.prototype[r],s={[r](){return arguments[0]=new(r==="addIceCandidate"?n.RTCIceCandidate:n.RTCSessionDescription)(arguments[0]),o.apply(this,arguments)}};n.RTCPeerConnection.prototype[r]=s[r]});const t={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},i=n.RTCPeerConnection.prototype.getStats;n.RTCPeerConnection.prototype.getStats=function(){const[o,s,a]=arguments;return i.apply(this,[o||null]).then(c=>{if(e.version<53&&!s)try{c.forEach(u=>{u.type=t[u.type]||u.type})}catch(u){if(u.name!=="TypeError")throw u;c.forEach((l,d)=>{c.set(d,Object.assign({},l,{type:t[l.type]||l.type}))})}return c}).then(s,a)}}function Vk(n){if(!(typeof n=="object"&&n.RTCPeerConnection&&n.RTCRtpSender)||n.RTCRtpSender&&"getStats"in n.RTCRtpSender.prototype)return;const e=n.RTCPeerConnection.prototype.getSenders;e&&(n.RTCPeerConnection.prototype.getSenders=function(){const r=e.apply(this,[]);return r.forEach(o=>o._pc=this),r});const t=n.RTCPeerConnection.prototype.addTrack;t&&(n.RTCPeerConnection.prototype.addTrack=function(){const r=t.apply(this,arguments);return r._pc=this,r}),n.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function zk(n){if(!(typeof n=="object"&&n.RTCPeerConnection&&n.RTCRtpSender)||n.RTCRtpSender&&"getStats"in n.RTCRtpReceiver.prototype)return;const e=n.RTCPeerConnection.prototype.getReceivers;e&&(n.RTCPeerConnection.prototype.getReceivers=function(){const i=e.apply(this,[]);return i.forEach(r=>r._pc=this),i}),ir(n,"track",t=>(t.receiver._pc=t.srcElement,t)),n.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function qk(n){!n.RTCPeerConnection||"removeStream"in n.RTCPeerConnection.prototype||(n.RTCPeerConnection.prototype.removeStream=function(t){sp("removeStream","removeTrack"),this.getSenders().forEach(i=>{i.track&&t.getTracks().includes(i.track)&&this.removeTrack(i)})})}function Wk(n){n.DataChannel&&!n.RTCDataChannel&&(n.RTCDataChannel=n.DataChannel)}function Gk(n){if(!(typeof n=="object"&&n.RTCPeerConnection))return;const e=n.RTCPeerConnection.prototype.addTransceiver;e&&(n.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];let i=arguments[1]&&arguments[1].sendEncodings;i===void 0&&(i=[]),i=[...i];const r=i.length>0;r&&i.forEach(s=>{if("rid"in s&&!/^[a-z0-9]{0,16}$/i.test(s.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in s&&!(parseFloat(s.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in s&&!(parseFloat(s.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const o=e.apply(this,arguments);if(r){const{sender:s}=o,a=s.getParameters();(!("encodings"in a)||a.encodings.length===1&&Object.keys(a.encodings[0]).length===0)&&(a.encodings=i,s.sendEncodings=i,this.setParametersPromises.push(s.setParameters(a).then(()=>{delete s.sendEncodings}).catch(()=>{delete s.sendEncodings})))}return o})}function $k(n){if(!(typeof n=="object"&&n.RTCRtpSender))return;const e=n.RTCRtpSender.prototype.getParameters;e&&(n.RTCRtpSender.prototype.getParameters=function(){const i=e.apply(this,arguments);return"encodings"in i||(i.encodings=[].concat(this.sendEncodings||[{}])),i})}function Hk(n){if(!(typeof n=="object"&&n.RTCPeerConnection))return;const e=n.RTCPeerConnection.prototype.createOffer;n.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}function Kk(n){if(!(typeof n=="object"&&n.RTCPeerConnection))return;const e=n.RTCPeerConnection.prototype.createAnswer;n.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}var Yk=Object.freeze({__proto__:null,shimAddTransceiver:Gk,shimCreateAnswer:Kk,shimCreateOffer:Hk,shimGetDisplayMedia:u3,shimGetParameters:$k,shimGetUserMedia:Bk,shimOnTrack:jk,shimPeerConnection:up,shimRTCDataChannel:Wk,shimReceiverGetStats:zk,shimRemoveStream:qk,shimSenderGetStats:Vk});function Xk(n){if(!(typeof n!="object"||!n.RTCPeerConnection)){if("getLocalStreams"in n.RTCPeerConnection.prototype||(n.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in n.RTCPeerConnection.prototype)){const e=n.RTCPeerConnection.prototype.addTrack;n.RTCPeerConnection.prototype.addStream=function(i){this._localStreams||(this._localStreams=[]),this._localStreams.includes(i)||this._localStreams.push(i),i.getAudioTracks().forEach(r=>e.call(this,r,i)),i.getVideoTracks().forEach(r=>e.call(this,r,i))},n.RTCPeerConnection.prototype.addTrack=function(i){for(var r=arguments.length,o=new Array(r>1?r-1:0),s=1;s<r;s++)o[s-1]=arguments[s];return o&&o.forEach(a=>{this._localStreams?this._localStreams.includes(a)||this._localStreams.push(a):this._localStreams=[a]}),e.apply(this,arguments)}}"removeStream"in n.RTCPeerConnection.prototype||(n.RTCPeerConnection.prototype.removeStream=function(t){this._localStreams||(this._localStreams=[]);const i=this._localStreams.indexOf(t);if(i===-1)return;this._localStreams.splice(i,1);const r=t.getTracks();this.getSenders().forEach(o=>{r.includes(o.track)&&this.removeTrack(o)})})}}function Jk(n){if(!(typeof n!="object"||!n.RTCPeerConnection)&&("getRemoteStreams"in n.RTCPeerConnection.prototype||(n.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in n.RTCPeerConnection.prototype))){Object.defineProperty(n.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(t){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=t),this.addEventListener("track",this._onaddstreampoly=i=>{i.streams.forEach(r=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(r))return;this._remoteStreams.push(r);const o=new Event("addstream");o.stream=r,this.dispatchEvent(o)})})}});const e=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(){const i=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(r){r.streams.forEach(o=>{if(i._remoteStreams||(i._remoteStreams=[]),i._remoteStreams.indexOf(o)>=0)return;i._remoteStreams.push(o);const s=new Event("addstream");s.stream=o,i.dispatchEvent(s)})}),e.apply(i,arguments)}}}function Zk(n){if(typeof n!="object"||!n.RTCPeerConnection)return;const e=n.RTCPeerConnection.prototype,t=e.createOffer,i=e.createAnswer,r=e.setLocalDescription,o=e.setRemoteDescription,s=e.addIceCandidate;e.createOffer=function(u,l){const d=arguments.length>=2?arguments[2]:arguments[0],h=t.apply(this,[d]);return l?(h.then(u,l),Promise.resolve()):h},e.createAnswer=function(u,l){const d=arguments.length>=2?arguments[2]:arguments[0],h=i.apply(this,[d]);return l?(h.then(u,l),Promise.resolve()):h};let a=function(c,u,l){const d=r.apply(this,[c]);return l?(d.then(u,l),Promise.resolve()):d};e.setLocalDescription=a,a=function(c,u,l){const d=o.apply(this,[c]);return l?(d.then(u,l),Promise.resolve()):d},e.setRemoteDescription=a,a=function(c,u,l){const d=s.apply(this,[c]);return l?(d.then(u,l),Promise.resolve()):d},e.addIceCandidate=a}function Qk(n){const e=n&&n.navigator;if(e.mediaDevices&&e.mediaDevices.getUserMedia){const t=e.mediaDevices,i=t.getUserMedia.bind(t);e.mediaDevices.getUserMedia=r=>i(eS(r))}!e.getUserMedia&&e.mediaDevices&&e.mediaDevices.getUserMedia&&(e.getUserMedia=(function(i,r,o){e.mediaDevices.getUserMedia(i).then(r,o)}).bind(e))}function eS(n){return n&&n.video!==void 0?Object.assign({},n,{video:Ek(n.video)}):n}function tS(n){if(!n.RTCPeerConnection)return;const e=n.RTCPeerConnection;n.RTCPeerConnection=function(i,r){if(i&&i.iceServers){const o=[];for(let s=0;s<i.iceServers.length;s++){let a=i.iceServers[s];a.urls===void 0&&a.url?(sp("RTCIceServer.url","RTCIceServer.urls"),a=JSON.parse(JSON.stringify(a)),a.urls=a.url,delete a.url,o.push(a)):o.push(i.iceServers[s])}i.iceServers=o}return new e(i,r)},n.RTCPeerConnection.prototype=e.prototype,"generateCertificate"in e&&Object.defineProperty(n.RTCPeerConnection,"generateCertificate",{get(){return e.generateCertificate}})}function nS(n){typeof n=="object"&&n.RTCTrackEvent&&"receiver"in n.RTCTrackEvent.prototype&&!("transceiver"in n.RTCTrackEvent.prototype)&&Object.defineProperty(n.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function iS(n){const e=n.RTCPeerConnection.prototype.createOffer;n.RTCPeerConnection.prototype.createOffer=function(i){if(i){typeof i.offerToReceiveAudio<"u"&&(i.offerToReceiveAudio=!!i.offerToReceiveAudio);const r=this.getTransceivers().find(s=>s.receiver.track.kind==="audio");i.offerToReceiveAudio===!1&&r?r.direction==="sendrecv"?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":r.direction==="recvonly"&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):i.offerToReceiveAudio===!0&&!r&&this.addTransceiver("audio",{direction:"recvonly"}),typeof i.offerToReceiveVideo<"u"&&(i.offerToReceiveVideo=!!i.offerToReceiveVideo);const o=this.getTransceivers().find(s=>s.receiver.track.kind==="video");i.offerToReceiveVideo===!1&&o?o.direction==="sendrecv"?o.setDirection?o.setDirection("sendonly"):o.direction="sendonly":o.direction==="recvonly"&&(o.setDirection?o.setDirection("inactive"):o.direction="inactive"):i.offerToReceiveVideo===!0&&!o&&this.addTransceiver("video",{direction:"recvonly"})}return e.apply(this,arguments)}}function rS(n){typeof n!="object"||n.AudioContext||(n.AudioContext=n.webkitAudioContext)}var oS=Object.freeze({__proto__:null,shimAudioContext:rS,shimCallbacksAPI:Zk,shimConstraints:eS,shimCreateOfferLegacy:iS,shimGetUserMedia:Qk,shimLocalStreamsAPI:Xk,shimRTCIceServerUrls:tS,shimRemoteStreamsAPI:Jk,shimTrackEventTransceiver:nS}),lp={exports:{}},sS;function l3(){return sS||(sS=1,function(n){const e={};e.generateIdentifier=function(){return Math.random().toString(36).substring(2,12)},e.localCName=e.generateIdentifier(),e.splitLines=function(t){return t.trim().split(`
4
+ }`,ob=function(n){cb(n,".".concat(ea).concat(sb).concat(Dl,`
5
+ .`).concat(ta).concat(ab).concat(Dl))},cb=function(n,e){var t=n.ownerDocument;if(t){var i=t.createElement("style");i.textContent=e,n.appendChild(i)}},lb=function(n,e){var t,i=n.ownerDocument.createElement("base");i.href=e;var r=n.getElementsByTagName("head").item(0);r==null||r.insertBefore(i,(t=r==null?void 0:r.firstChild)!==null&&t!==void 0?t:null)},na=function(){function n(){}return n.getOrigin=function(e){var t=n._link;return t?(t.href=e,t.href=t.href,t.protocol+t.hostname+t.port):"about:blank"},n.isSameOrigin=function(e){return n.getOrigin(e)===n._origin},n.setContext=function(e){n._link=e.document.createElement("a"),n._origin=n.getOrigin(e.location.href)},n._origin="about:blank",n}(),ub=function(){function n(e,t){this.context=e,this._options=t,this._cache={}}return n.prototype.addImage=function(e){var t=Promise.resolve();return this.has(e)||(ra(e)||pb(e))&&(this._cache[e]=this.loadImage(e)).catch(function(){}),t},n.prototype.match=function(e){return this._cache[e]},n.prototype.loadImage=function(e){return De(this,void 0,void 0,function(){var t,i,r,s,a,o=this;return Oe(this,function(c){switch(c.label){case 0:return typeof this._options.customIsSameOrigin!="function"?[3,2]:[4,this._options.customIsSameOrigin(e,na.isSameOrigin)];case 1:return i=c.sent(),[3,3];case 2:i=na.isSameOrigin(e),c.label=3;case 3:return t=i,r=!ia(e)&&this._options.useCORS===!0&&Re.SUPPORT_CORS_IMAGES&&!t,s=!ia(e)&&!t&&!ra(e)&&typeof this._options.proxy=="string"&&Re.SUPPORT_CORS_XHR&&!r,!t&&this._options.allowTaint===!1&&!ia(e)&&!ra(e)&&!s&&!r?[2]:(a=e,s?[4,this.proxy(a)]:[3,5]);case 4:a=c.sent(),c.label=5;case 5:return this.context.logger.debug("Added image ".concat(e.substring(0,256))),[4,new Promise(function(l,u){var d=new Image;d.onload=function(){return l(d)},d.onerror=u,(mb(a)||r)&&(d.crossOrigin="anonymous"),d.src=a,d.complete===!0&&setTimeout(function(){return l(d)},500),o._options.imageTimeout>0&&setTimeout(function(){return u("Timed out (".concat(o._options.imageTimeout,"ms) loading image"))},o._options.imageTimeout)})];case 6:return[2,c.sent()]}})})},n.prototype.has=function(e){return typeof this._cache[e]<"u"},n.prototype.keys=function(){return Promise.resolve(Object.keys(this._cache))},n.prototype.proxy=function(e){var t=this,i=this._options.proxy;if(!i)throw new Error("No proxy defined");var r=e.substring(0,256);return new Promise(function(s,a){var o=Re.SUPPORT_RESPONSE_TYPE?"blob":"text",c=new XMLHttpRequest;c.onload=function(){if(c.status===200)if(o==="text")s(c.response);else{var d=new FileReader;d.addEventListener("load",function(){return s(d.result)},!1),d.addEventListener("error",function(h){return a(h)},!1),d.readAsDataURL(c.response)}else a("Failed to proxy resource ".concat(r," with status code ").concat(c.status))},c.onerror=a;var l=i.indexOf("?")>-1?"&":"?";if(c.open("GET","".concat(i).concat(l,"url=").concat(encodeURIComponent(e),"&responseType=").concat(o)),o!=="text"&&c instanceof XMLHttpRequest&&(c.responseType=o),t._options.imageTimeout){var u=t._options.imageTimeout;c.timeout=u,c.ontimeout=function(){return a("Timed out (".concat(u,"ms) proxying ").concat(r))}}c.send()})},n}(),db=/^data:image\/svg\+xml/i,hb=/^data:image\/.*;base64,/i,fb=/^data:image\/.*/i,pb=function(n){return Re.SUPPORT_SVG_DRAWING||!gb(n)},ia=function(n){return fb.test(n)},mb=function(n){return hb.test(n)},ra=function(n){return n.substr(0,4)==="blob"},gb=function(n){return n.substr(-3).toLowerCase()==="svg"||db.test(n)},B=function(){function n(e,t){this.type=0,this.x=e,this.y=t}return n.prototype.add=function(e,t){return new n(this.x+e,this.y+t)},n}(),Rn=function(n,e,t){return new B(n.x+(e.x-n.x)*t,n.y+(e.y-n.y)*t)},gr=function(){function n(e,t,i,r){this.type=1,this.start=e,this.startControl=t,this.endControl=i,this.end=r}return n.prototype.subdivide=function(e,t){var i=Rn(this.start,this.startControl,e),r=Rn(this.startControl,this.endControl,e),s=Rn(this.endControl,this.end,e),a=Rn(i,r,e),o=Rn(r,s,e),c=Rn(a,o,e);return t?new n(this.start,i,a,c):new n(c,o,s,this.end)},n.prototype.add=function(e,t){return new n(this.start.add(e,t),this.startControl.add(e,t),this.endControl.add(e,t),this.end.add(e,t))},n.prototype.reverse=function(){return new n(this.end,this.endControl,this.startControl,this.start)},n}(),Je=function(n){return n.type===1},vb=function(){function n(e){var t=e.styles,i=e.bounds,r=ri(t.borderTopLeftRadius,i.width,i.height),s=r[0],a=r[1],o=ri(t.borderTopRightRadius,i.width,i.height),c=o[0],l=o[1],u=ri(t.borderBottomRightRadius,i.width,i.height),d=u[0],h=u[1],f=ri(t.borderBottomLeftRadius,i.width,i.height),p=f[0],g=f[1],v=[];v.push((s+c)/i.width),v.push((p+d)/i.width),v.push((a+g)/i.height),v.push((l+h)/i.height);var b=Math.max.apply(Math,v);b>1&&(s/=b,a/=b,c/=b,l/=b,d/=b,h/=b,p/=b,g/=b);var S=i.width-c,x=i.height-h,k=i.width-d,T=i.height-g,C=t.borderTopWidth,_=t.borderRightWidth,R=t.borderBottomWidth,I=t.borderLeftWidth,D=te(t.paddingTop,e.bounds.width),U=te(t.paddingRight,e.bounds.width),V=te(t.paddingBottom,e.bounds.width),G=te(t.paddingLeft,e.bounds.width);this.topLeftBorderDoubleOuterBox=s>0||a>0?ce(i.left+I/3,i.top+C/3,s-I/3,a-C/3,Z.TOP_LEFT):new B(i.left+I/3,i.top+C/3),this.topRightBorderDoubleOuterBox=s>0||a>0?ce(i.left+S,i.top+C/3,c-_/3,l-C/3,Z.TOP_RIGHT):new B(i.left+i.width-_/3,i.top+C/3),this.bottomRightBorderDoubleOuterBox=d>0||h>0?ce(i.left+k,i.top+x,d-_/3,h-R/3,Z.BOTTOM_RIGHT):new B(i.left+i.width-_/3,i.top+i.height-R/3),this.bottomLeftBorderDoubleOuterBox=p>0||g>0?ce(i.left+I/3,i.top+T,p-I/3,g-R/3,Z.BOTTOM_LEFT):new B(i.left+I/3,i.top+i.height-R/3),this.topLeftBorderDoubleInnerBox=s>0||a>0?ce(i.left+I*2/3,i.top+C*2/3,s-I*2/3,a-C*2/3,Z.TOP_LEFT):new B(i.left+I*2/3,i.top+C*2/3),this.topRightBorderDoubleInnerBox=s>0||a>0?ce(i.left+S,i.top+C*2/3,c-_*2/3,l-C*2/3,Z.TOP_RIGHT):new B(i.left+i.width-_*2/3,i.top+C*2/3),this.bottomRightBorderDoubleInnerBox=d>0||h>0?ce(i.left+k,i.top+x,d-_*2/3,h-R*2/3,Z.BOTTOM_RIGHT):new B(i.left+i.width-_*2/3,i.top+i.height-R*2/3),this.bottomLeftBorderDoubleInnerBox=p>0||g>0?ce(i.left+I*2/3,i.top+T,p-I*2/3,g-R*2/3,Z.BOTTOM_LEFT):new B(i.left+I*2/3,i.top+i.height-R*2/3),this.topLeftBorderStroke=s>0||a>0?ce(i.left+I/2,i.top+C/2,s-I/2,a-C/2,Z.TOP_LEFT):new B(i.left+I/2,i.top+C/2),this.topRightBorderStroke=s>0||a>0?ce(i.left+S,i.top+C/2,c-_/2,l-C/2,Z.TOP_RIGHT):new B(i.left+i.width-_/2,i.top+C/2),this.bottomRightBorderStroke=d>0||h>0?ce(i.left+k,i.top+x,d-_/2,h-R/2,Z.BOTTOM_RIGHT):new B(i.left+i.width-_/2,i.top+i.height-R/2),this.bottomLeftBorderStroke=p>0||g>0?ce(i.left+I/2,i.top+T,p-I/2,g-R/2,Z.BOTTOM_LEFT):new B(i.left+I/2,i.top+i.height-R/2),this.topLeftBorderBox=s>0||a>0?ce(i.left,i.top,s,a,Z.TOP_LEFT):new B(i.left,i.top),this.topRightBorderBox=c>0||l>0?ce(i.left+S,i.top,c,l,Z.TOP_RIGHT):new B(i.left+i.width,i.top),this.bottomRightBorderBox=d>0||h>0?ce(i.left+k,i.top+x,d,h,Z.BOTTOM_RIGHT):new B(i.left+i.width,i.top+i.height),this.bottomLeftBorderBox=p>0||g>0?ce(i.left,i.top+T,p,g,Z.BOTTOM_LEFT):new B(i.left,i.top+i.height),this.topLeftPaddingBox=s>0||a>0?ce(i.left+I,i.top+C,Math.max(0,s-I),Math.max(0,a-C),Z.TOP_LEFT):new B(i.left+I,i.top+C),this.topRightPaddingBox=c>0||l>0?ce(i.left+Math.min(S,i.width-_),i.top+C,S>i.width+_?0:Math.max(0,c-_),Math.max(0,l-C),Z.TOP_RIGHT):new B(i.left+i.width-_,i.top+C),this.bottomRightPaddingBox=d>0||h>0?ce(i.left+Math.min(k,i.width-I),i.top+Math.min(x,i.height-R),Math.max(0,d-_),Math.max(0,h-R),Z.BOTTOM_RIGHT):new B(i.left+i.width-_,i.top+i.height-R),this.bottomLeftPaddingBox=p>0||g>0?ce(i.left+I,i.top+Math.min(T,i.height-R),Math.max(0,p-I),Math.max(0,g-R),Z.BOTTOM_LEFT):new B(i.left+I,i.top+i.height-R),this.topLeftContentBox=s>0||a>0?ce(i.left+I+G,i.top+C+D,Math.max(0,s-(I+G)),Math.max(0,a-(C+D)),Z.TOP_LEFT):new B(i.left+I+G,i.top+C+D),this.topRightContentBox=c>0||l>0?ce(i.left+Math.min(S,i.width+I+G),i.top+C+D,S>i.width+I+G?0:c-I+G,l-(C+D),Z.TOP_RIGHT):new B(i.left+i.width-(_+U),i.top+C+D),this.bottomRightContentBox=d>0||h>0?ce(i.left+Math.min(k,i.width-(I+G)),i.top+Math.min(x,i.height+C+D),Math.max(0,d-(_+U)),h-(R+V),Z.BOTTOM_RIGHT):new B(i.left+i.width-(_+U),i.top+i.height-(R+V)),this.bottomLeftContentBox=p>0||g>0?ce(i.left+I+G,i.top+T,Math.max(0,p-(I+G)),g-(R+V),Z.BOTTOM_LEFT):new B(i.left+I+G,i.top+i.height-(R+V))}return n}(),Z;(function(n){n[n.TOP_LEFT=0]="TOP_LEFT",n[n.TOP_RIGHT=1]="TOP_RIGHT",n[n.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",n[n.BOTTOM_LEFT=3]="BOTTOM_LEFT"})(Z||(Z={}));var ce=function(n,e,t,i,r){var s=4*((Math.sqrt(2)-1)/3),a=t*s,o=i*s,c=n+t,l=e+i;switch(r){case Z.TOP_LEFT:return new gr(new B(n,l),new B(n,l-o),new B(c-a,e),new B(c,e));case Z.TOP_RIGHT:return new gr(new B(n,e),new B(n+a,e),new B(c,l-o),new B(c,l));case Z.BOTTOM_RIGHT:return new gr(new B(c,e),new B(c,e+o),new B(n+a,l),new B(n,l));case Z.BOTTOM_LEFT:default:return new gr(new B(c,l),new B(c-a,l),new B(n,e+o),new B(n,e))}},vr=function(n){return[n.topLeftBorderBox,n.topRightBorderBox,n.bottomRightBorderBox,n.bottomLeftBorderBox]},bb=function(n){return[n.topLeftContentBox,n.topRightContentBox,n.bottomRightContentBox,n.bottomLeftContentBox]},br=function(n){return[n.topLeftPaddingBox,n.topRightPaddingBox,n.bottomRightPaddingBox,n.bottomLeftPaddingBox]},yb=function(){function n(e,t,i){this.offsetX=e,this.offsetY=t,this.matrix=i,this.type=0,this.target=6}return n}(),yr=function(){function n(e,t){this.path=e,this.target=t,this.type=1}return n}(),kb=function(){function n(e){this.opacity=e,this.type=2,this.target=6}return n}(),Tb=function(n){return n.type===0},Ul=function(n){return n.type===1},Sb=function(n){return n.type===2},Bl=function(n,e){return n.length===e.length?n.some(function(t,i){return t===e[i]}):!1},Cb=function(n,e,t,i,r){return n.map(function(s,a){switch(a){case 0:return s.add(e,t);case 1:return s.add(e+i,t);case 2:return s.add(e+i,t+r);case 3:return s.add(e,t+r)}return s})},Fl=function(){function n(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]}return n}(),jl=function(){function n(e,t){if(this.container=e,this.parent=t,this.effects=[],this.curves=new vb(this.container),this.container.styles.opacity<1&&this.effects.push(new kb(this.container.styles.opacity)),this.container.styles.transform!==null){var i=this.container.bounds.left+this.container.styles.transformOrigin[0].number,r=this.container.bounds.top+this.container.styles.transformOrigin[1].number,s=this.container.styles.transform;this.effects.push(new yb(i,r,s))}if(this.container.styles.overflowX!==0){var a=vr(this.curves),o=br(this.curves);Bl(a,o)?this.effects.push(new yr(a,6)):(this.effects.push(new yr(a,2)),this.effects.push(new yr(o,4)))}}return n.prototype.getEffects=function(e){for(var t=[2,3].indexOf(this.container.styles.position)===-1,i=this.parent,r=this.effects.slice(0);i;){var s=i.effects.filter(function(c){return!Ul(c)});if(t||i.container.styles.position!==0||!i.parent){if(t=[2,3].indexOf(i.container.styles.position)===-1,i.container.styles.overflowX!==0){var a=vr(i.curves),o=br(i.curves);Bl(a,o)||r.unshift(new yr(o,6))}r.unshift.apply(r,s)}else r.unshift.apply(r,s);i=i.parent}return r.filter(function(c){return Se(c.target,e)})},n}(),sa=function(n,e,t,i){n.container.elements.forEach(function(r){var s=Se(r.flags,4),a=Se(r.flags,2),o=new jl(r,n);Se(r.styles.display,2048)&&i.push(o);var c=Se(r.flags,8)?[]:i;if(s||a){var l=s||r.styles.isPositioned()?t:e,u=new Fl(o);if(r.styles.isPositioned()||r.styles.opacity<1||r.styles.isTransformed()){var d=r.styles.zIndex.order;if(d<0){var h=0;l.negativeZIndex.some(function(p,g){return d>p.element.container.styles.zIndex.order?(h=g,!1):h>0}),l.negativeZIndex.splice(h,0,u)}else if(d>0){var f=0;l.positiveZIndex.some(function(p,g){return d>=p.element.container.styles.zIndex.order?(f=g+1,!1):f>0}),l.positiveZIndex.splice(f,0,u)}else l.zeroOrAutoZIndexOrTransformedOrOpacity.push(u)}else r.styles.isFloating()?l.nonPositionedFloats.push(u):l.nonPositionedInlineLevel.push(u);sa(o,u,s?u:t,c)}else r.styles.isInlineLevel()?e.inlineLevel.push(o):e.nonInlineLevel.push(o),sa(o,e,t,c);Se(r.flags,8)&&Vl(r,c)})},Vl=function(n,e){for(var t=n instanceof Ks?n.start:1,i=n instanceof Ks?n.reversed:!1,r=0;r<e.length;r++){var s=e[r];s.container instanceof fl&&typeof s.container.value=="number"&&s.container.value!==0&&(t=s.container.value),s.listValue=li(t,s.container.styles.listStyleType,!0),t+=i?-1:1}},xb=function(n){var e=new jl(n,null),t=new Fl(e),i=[];return sa(e,t,t,i),Vl(e.container,i),t},Gl=function(n,e){switch(e){case 0:return Qe(n.topLeftBorderBox,n.topLeftPaddingBox,n.topRightBorderBox,n.topRightPaddingBox);case 1:return Qe(n.topRightBorderBox,n.topRightPaddingBox,n.bottomRightBorderBox,n.bottomRightPaddingBox);case 2:return Qe(n.bottomRightBorderBox,n.bottomRightPaddingBox,n.bottomLeftBorderBox,n.bottomLeftPaddingBox);case 3:default:return Qe(n.bottomLeftBorderBox,n.bottomLeftPaddingBox,n.topLeftBorderBox,n.topLeftPaddingBox)}},wb=function(n,e){switch(e){case 0:return Qe(n.topLeftBorderBox,n.topLeftBorderDoubleOuterBox,n.topRightBorderBox,n.topRightBorderDoubleOuterBox);case 1:return Qe(n.topRightBorderBox,n.topRightBorderDoubleOuterBox,n.bottomRightBorderBox,n.bottomRightBorderDoubleOuterBox);case 2:return Qe(n.bottomRightBorderBox,n.bottomRightBorderDoubleOuterBox,n.bottomLeftBorderBox,n.bottomLeftBorderDoubleOuterBox);case 3:default:return Qe(n.bottomLeftBorderBox,n.bottomLeftBorderDoubleOuterBox,n.topLeftBorderBox,n.topLeftBorderDoubleOuterBox)}},_b=function(n,e){switch(e){case 0:return Qe(n.topLeftBorderDoubleInnerBox,n.topLeftPaddingBox,n.topRightBorderDoubleInnerBox,n.topRightPaddingBox);case 1:return Qe(n.topRightBorderDoubleInnerBox,n.topRightPaddingBox,n.bottomRightBorderDoubleInnerBox,n.bottomRightPaddingBox);case 2:return Qe(n.bottomRightBorderDoubleInnerBox,n.bottomRightPaddingBox,n.bottomLeftBorderDoubleInnerBox,n.bottomLeftPaddingBox);case 3:default:return Qe(n.bottomLeftBorderDoubleInnerBox,n.bottomLeftPaddingBox,n.topLeftBorderDoubleInnerBox,n.topLeftPaddingBox)}},Eb=function(n,e){switch(e){case 0:return kr(n.topLeftBorderStroke,n.topRightBorderStroke);case 1:return kr(n.topRightBorderStroke,n.bottomRightBorderStroke);case 2:return kr(n.bottomRightBorderStroke,n.bottomLeftBorderStroke);case 3:default:return kr(n.bottomLeftBorderStroke,n.topLeftBorderStroke)}},kr=function(n,e){var t=[];return Je(n)?t.push(n.subdivide(.5,!1)):t.push(n),Je(e)?t.push(e.subdivide(.5,!0)):t.push(e),t},Qe=function(n,e,t,i){var r=[];return Je(n)?r.push(n.subdivide(.5,!1)):r.push(n),Je(t)?r.push(t.subdivide(.5,!0)):r.push(t),Je(i)?r.push(i.subdivide(.5,!0).reverse()):r.push(i),Je(e)?r.push(e.subdivide(.5,!1).reverse()):r.push(e),r},Wl=function(n){var e=n.bounds,t=n.styles;return e.add(t.borderLeftWidth,t.borderTopWidth,-(t.borderRightWidth+t.borderLeftWidth),-(t.borderTopWidth+t.borderBottomWidth))},Tr=function(n){var e=n.styles,t=n.bounds,i=te(e.paddingLeft,t.width),r=te(e.paddingRight,t.width),s=te(e.paddingTop,t.width),a=te(e.paddingBottom,t.width);return t.add(i+e.borderLeftWidth,s+e.borderTopWidth,-(e.borderRightWidth+e.borderLeftWidth+i+r),-(e.borderTopWidth+e.borderBottomWidth+s+a))},Pb=function(n,e){return n===0?e.bounds:n===2?Tr(e):Wl(e)},Rb=function(n,e){return n===0?e.bounds:n===2?Tr(e):Wl(e)},aa=function(n,e,t){var i=Pb(On(n.styles.backgroundOrigin,e),n),r=Rb(On(n.styles.backgroundClip,e),n),s=Ib(On(n.styles.backgroundSize,e),t,i),a=s[0],o=s[1],c=ri(On(n.styles.backgroundPosition,e),i.width-a,i.height-o),l=Ob(On(n.styles.backgroundRepeat,e),c,s,i,r),u=Math.round(i.left+c[0]),d=Math.round(i.top+c[1]);return a=Math.max(1,a),o=Math.max(1,o),[l,u,d,a,o]},In=function(n){return H(n)&&n.value===wn.AUTO},Sr=function(n){return typeof n=="number"},Ib=function(n,e,t){var i=e[0],r=e[1],s=e[2],a=n[0],o=n[1];if(!a)return[0,0];if(ae(a)&&o&&ae(o))return[te(a,t.width),te(o,t.height)];var c=Sr(s);if(H(a)&&(a.value===wn.CONTAIN||a.value===wn.COVER)){if(Sr(s)){var l=t.width/t.height;return l<s!=(a.value===wn.COVER)?[t.width,t.width/s]:[t.height*s,t.height]}return[t.width,t.height]}var u=Sr(i),d=Sr(r),h=u||d;if(In(a)&&(!o||In(o))){if(u&&d)return[i,r];if(!c&&!h)return[t.width,t.height];if(h&&c){var f=u?i:r*s,p=d?r:i/s;return[f,p]}var g=u?i:t.width,v=d?r:t.height;return[g,v]}if(c){var b=0,S=0;return ae(a)?b=te(a,t.width):ae(o)&&(S=te(o,t.height)),In(a)?b=S*s:(!o||In(o))&&(S=b/s),[b,S]}var x=null,k=null;if(ae(a)?x=te(a,t.width):o&&ae(o)&&(k=te(o,t.height)),x!==null&&(!o||In(o))&&(k=u&&d?x/i*r:t.height),k!==null&&In(a)&&(x=u&&d?k/r*i:t.width),x!==null&&k!==null)return[x,k];throw new Error("Unable to calculate background-size for element")},On=function(n,e){var t=n[e];return typeof t>"u"?n[0]:t},Ob=function(n,e,t,i,r){var s=e[0],a=e[1],o=t[0],c=t[1];switch(n){case 2:return[new B(Math.round(i.left),Math.round(i.top+a)),new B(Math.round(i.left+i.width),Math.round(i.top+a)),new B(Math.round(i.left+i.width),Math.round(c+i.top+a)),new B(Math.round(i.left),Math.round(c+i.top+a))];case 3:return[new B(Math.round(i.left+s),Math.round(i.top)),new B(Math.round(i.left+s+o),Math.round(i.top)),new B(Math.round(i.left+s+o),Math.round(i.height+i.top)),new B(Math.round(i.left+s),Math.round(i.height+i.top))];case 1:return[new B(Math.round(i.left+s),Math.round(i.top+a)),new B(Math.round(i.left+s+o),Math.round(i.top+a)),new B(Math.round(i.left+s+o),Math.round(i.top+a+c)),new B(Math.round(i.left+s),Math.round(i.top+a+c))];default:return[new B(Math.round(r.left),Math.round(r.top)),new B(Math.round(r.left+r.width),Math.round(r.top)),new B(Math.round(r.left+r.width),Math.round(r.height+r.top)),new B(Math.round(r.left),Math.round(r.height+r.top))]}},Ab="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",zl="Hidden Text",Nb=function(){function n(e){this._data={},this._document=e}return n.prototype.parseMetrics=function(e,t){var i=this._document.createElement("div"),r=this._document.createElement("img"),s=this._document.createElement("span"),a=this._document.body;i.style.visibility="hidden",i.style.fontFamily=e,i.style.fontSize=t,i.style.margin="0",i.style.padding="0",i.style.whiteSpace="nowrap",a.appendChild(i),r.src=Ab,r.width=1,r.height=1,r.style.margin="0",r.style.padding="0",r.style.verticalAlign="baseline",s.style.fontFamily=e,s.style.fontSize=t,s.style.margin="0",s.style.padding="0",s.appendChild(this._document.createTextNode(zl)),i.appendChild(s),i.appendChild(r);var o=r.offsetTop-s.offsetTop+2;i.removeChild(s),i.appendChild(this._document.createTextNode(zl)),i.style.lineHeight="normal",r.style.verticalAlign="super";var c=r.offsetTop-i.offsetTop+2;return a.removeChild(i),{baseline:o,middle:c}},n.prototype.getMetrics=function(e,t){var i="".concat(e," ").concat(t);return typeof this._data[i]>"u"&&(this._data[i]=this.parseMetrics(e,t)),this._data[i]},n}(),Hl=function(){function n(e,t){this.context=e,this.options=t}return n}(),Mb=1e4,Lb=function(n){tt(e,n);function e(t,i){var r=n.call(this,t,i)||this;return r._activeEffects=[],r.canvas=i.canvas?i.canvas:document.createElement("canvas"),r.ctx=r.canvas.getContext("2d"),i.canvas||(r.canvas.width=Math.floor(i.width*i.scale),r.canvas.height=Math.floor(i.height*i.scale),r.canvas.style.width="".concat(i.width,"px"),r.canvas.style.height="".concat(i.height,"px")),r.fontMetrics=new Nb(document),r.ctx.scale(r.options.scale,r.options.scale),r.ctx.translate(-i.x,-i.y),r.ctx.textBaseline="bottom",r._activeEffects=[],r.context.logger.debug("Canvas renderer initialized (".concat(i.width,"x").concat(i.height,") with scale ").concat(i.scale)),r}return e.prototype.applyEffects=function(t){for(var i=this;this._activeEffects.length;)this.popEffect();t.forEach(function(r){return i.applyEffect(r)})},e.prototype.applyEffect=function(t){this.ctx.save(),Sb(t)&&(this.ctx.globalAlpha=t.opacity),Tb(t)&&(this.ctx.translate(t.offsetX,t.offsetY),this.ctx.transform(t.matrix[0],t.matrix[1],t.matrix[2],t.matrix[3],t.matrix[4],t.matrix[5]),this.ctx.translate(-t.offsetX,-t.offsetY)),Ul(t)&&(this.path(t.path),this.ctx.clip()),this._activeEffects.push(t)},e.prototype.popEffect=function(){this._activeEffects.pop(),this.ctx.restore()},e.prototype.renderStack=function(t){return De(this,void 0,void 0,function(){var i;return Oe(this,function(r){switch(r.label){case 0:return i=t.element.container.styles,i.isVisible()?[4,this.renderStackContent(t)]:[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}})})},e.prototype.renderNode=function(t){return De(this,void 0,void 0,function(){return Oe(this,function(i){switch(i.label){case 0:return Se(t.container.flags,16),t.container.styles.isVisible()?[4,this.renderNodeBackgroundAndBorders(t)]:[3,3];case 1:return i.sent(),[4,this.renderNodeContent(t)];case 2:i.sent(),i.label=3;case 3:return[2]}})})},e.prototype.renderTextWithLetterSpacing=function(t,i,r){var s=this;if(i===0)navigator.userAgent.indexOf("Firefox")===-1?(this.ctx.textBaseline="ideographic",this.ctx.fillText(t.text,t.bounds.left,t.bounds.top+t.bounds.height)):this.ctx.fillText(t.text,t.bounds.left,t.bounds.top+r);else{var a=qs(t.text);a.reduce(function(o,c){return s.ctx.fillText(c,o,t.bounds.top+r),o+s.ctx.measureText(c).width},t.bounds.left)}},e.prototype.createFontStyle=function(t){var i=t.fontVariant.filter(function(a){return a==="normal"||a==="small-caps"}).join(""),r=jb(t.fontFamily).join(", "),s=Dt(t.fontSize)?"".concat(t.fontSize.number).concat(t.fontSize.unit):"".concat(t.fontSize.number,"px");return[[t.fontStyle,i,t.fontWeight,s,r].join(" "),r,s]},e.prototype.renderTextNode=function(t,i){return De(this,void 0,void 0,function(){var r,s,a=this;return Oe(this,function(o){return r=this.createFontStyle(i)[0],this.ctx.font=r,this.ctx.direction=i.direction===1?"rtl":"ltr",this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic",s=i.paintOrder,t.textBounds.forEach(function(c){s.forEach(function(l){switch(l){case 0:a.ctx.fillStyle=xe(i.color),a.renderTextWithLetterSpacing(c,i.letterSpacing,i.fontSize.number);var u=i.textShadow;if(u.length&&c.text.trim().length&&(u.slice(0).reverse().forEach(function(h){a.ctx.shadowColor=xe(h.color),a.ctx.shadowOffsetX=h.offsetX.number*a.options.scale,a.ctx.shadowOffsetY=h.offsetY.number*a.options.scale,a.ctx.shadowBlur=h.blur.number,a.renderTextWithLetterSpacing(c,i.letterSpacing,i.fontSize.number)}),a.ctx.shadowColor="",a.ctx.shadowOffsetX=0,a.ctx.shadowOffsetY=0,a.ctx.shadowBlur=0),i.textDecorationLine.length){a.ctx.fillStyle=xe(i.textDecorationColor||i.color);var d=1;i.textDecorationLine.forEach(function(h){switch(h){case 1:a.ctx.fillRect(c.bounds.left,c.bounds.top+c.bounds.height-d,c.bounds.width,d);break;case 2:a.ctx.fillRect(c.bounds.left,c.bounds.top,c.bounds.width,d);break;case 3:a.ctx.fillRect(c.bounds.left,c.bounds.top+(c.bounds.height/2-d/2),c.bounds.width,d);break}})}break;case 1:i.webkitTextStrokeWidth&&c.text.trim().length&&(a.ctx.strokeStyle=xe(i.webkitTextStrokeColor),a.ctx.lineWidth=i.webkitTextStrokeWidth,a.ctx.lineJoin=window.chrome?"miter":"round",a.ctx.strokeText(c.text,c.bounds.left,c.bounds.top+c.bounds.height)),a.ctx.strokeStyle="",a.ctx.lineWidth=0,a.ctx.lineJoin="miter";break}})}),[2]})})},e.prototype.renderReplacedElement=function(t,i,r){var s=r.naturalWidth||t.intrinsicWidth,a=r.naturalHeight||t.intrinsicHeight;if(r&&s>0&&a>0){var o=Tr(t),c=br(i);this.path(c),this.ctx.save(),this.ctx.clip();var l=0,u=0,d=s,h=a,f=o.left,p=o.top,g=o.width,v=o.height,b=t.styles.objectFit,S=g/v,x=d/h;if(b===2)x>S?(v=g/x,p+=(o.height-v)/2):(g=v*x,f+=(o.width-g)/2);else if(b===4)x>S?(d=h*S,l+=(s-d)/2):(h=d/S,u+=(a-h)/2);else if(b===8)d>g?(l+=(d-g)/2,d=g):(f+=(g-d)/2,g=d),h>v?(u+=(h-v)/2,h=v):(p+=(v-h)/2,v=h);else if(b===16){var k=x>S?g:v*x,T=d>g?d:g;k<T?x>S?(v=g/x,p+=(o.height-v)/2):(g=v*x,f+=(o.width-g)/2):(d>g?(l+=(d-g)/2,d=g):(f+=(g-d)/2,g=d),h>v?(u+=(h-v)/2,h=v):(p+=(v-h)/2,v=h))}this.ctx.drawImage(r,l,u,d,h,f,p,g,v),this.ctx.restore()}},e.prototype.renderNodeContent=function(t){return De(this,void 0,void 0,function(){var i,r,s,a,o,c,x,x,l,u,d,h,T,f,p,g,C,v,b,S,x,k,T,C;return Oe(this,function(_){switch(_.label){case 0:this.applyEffects(t.getEffects(4)),i=t.container,r=t.curves,s=i.styles,a=0,o=i.textNodes,_.label=1;case 1:return a<o.length?(c=o[a],[4,this.renderTextNode(c,s)]):[3,4];case 2:_.sent(),_.label=3;case 3:return a++,[3,1];case 4:if(!(i instanceof ul))return[3,8];_.label=5;case 5:return _.trys.push([5,7,,8]),[4,this.context.cache.match(i.src)];case 6:return x=_.sent(),this.renderReplacedElement(i,r,x),[3,8];case 7:return _.sent(),this.context.logger.error("Error loading image ".concat(i.src)),[3,8];case 8:if(i instanceof dl&&this.renderReplacedElement(i,r,i.canvas),!(i instanceof hl))return[3,12];_.label=9;case 9:return _.trys.push([9,11,,12]),[4,this.context.cache.match(i.svg)];case 10:return x=_.sent(),this.renderReplacedElement(i,r,x),[3,12];case 11:return _.sent(),this.context.logger.error("Error loading svg ".concat(i.svg.substring(0,255))),[3,12];case 12:return i instanceof vl&&i.tree?(l=new e(this.context,{scale:this.options.scale,backgroundColor:i.backgroundColor,x:0,y:0,width:i.width,height:i.height}),[4,l.render(i.tree)]):[3,14];case 13:u=_.sent(),i.width&&i.height&&this.ctx.drawImage(u,0,0,i.width,i.height,i.bounds.left,i.bounds.top,i.bounds.width,i.bounds.height),_.label=14;case 14:if(i instanceof $s&&(d=Math.min(i.bounds.width,i.bounds.height),i.type===ur?i.checked&&(this.ctx.save(),this.path([new B(i.bounds.left+d*.39363,i.bounds.top+d*.79),new B(i.bounds.left+d*.16,i.bounds.top+d*.5549),new B(i.bounds.left+d*.27347,i.bounds.top+d*.44071),new B(i.bounds.left+d*.39694,i.bounds.top+d*.5649),new B(i.bounds.left+d*.72983,i.bounds.top+d*.23),new B(i.bounds.left+d*.84,i.bounds.top+d*.34085),new B(i.bounds.left+d*.39363,i.bounds.top+d*.79)]),this.ctx.fillStyle=xe(pl),this.ctx.fill(),this.ctx.restore()):i.type===dr&&i.checked&&(this.ctx.save(),this.ctx.beginPath(),this.ctx.arc(i.bounds.left+d/2,i.bounds.top+d/2,d/4,0,Math.PI*2,!0),this.ctx.fillStyle=xe(pl),this.ctx.fill(),this.ctx.restore())),Db(i)&&i.value.length){switch(h=this.createFontStyle(s),T=h[0],f=h[1],p=h[2],g=this.fontMetrics.getMetrics(f,p).baseline,this.ctx.font=T,this.ctx.fillStyle=xe(s.color),this.ctx.textBaseline="alphabetic",this.ctx.textAlign=Bb(i.styles.textAlign),C=Tr(i),v=0,i.styles.textAlign){case 1:v+=C.width/2;break;case 2:v+=C.width;break}b=C.add(v,0,0,-C.height/2+1),this.ctx.save(),this.path([new B(C.left,C.top),new B(C.left+C.width,C.top),new B(C.left+C.width,C.top+C.height),new B(C.left,C.top+C.height)]),this.ctx.clip(),this.renderTextWithLetterSpacing(new oi(i.value,b),s.letterSpacing,g),this.ctx.restore(),this.ctx.textBaseline="alphabetic",this.ctx.textAlign="left"}if(!Se(i.styles.display,2048))return[3,20];if(i.styles.listStyleImage===null)return[3,19];if(S=i.styles.listStyleImage,S.type!==0)return[3,18];x=void 0,k=S.url,_.label=15;case 15:return _.trys.push([15,17,,18]),[4,this.context.cache.match(k)];case 16:return x=_.sent(),this.ctx.drawImage(x,i.bounds.left-(x.width+10),i.bounds.top),[3,18];case 17:return _.sent(),this.context.logger.error("Error loading list-style-image ".concat(k)),[3,18];case 18:return[3,20];case 19:t.listValue&&i.styles.listStyleType!==-1&&(T=this.createFontStyle(s)[0],this.ctx.font=T,this.ctx.fillStyle=xe(s.color),this.ctx.textBaseline="middle",this.ctx.textAlign="right",C=new xt(i.bounds.left,i.bounds.top+te(i.styles.paddingTop,i.bounds.width),i.bounds.width,Kc(s.lineHeight,s.fontSize.number)/2+1),this.renderTextWithLetterSpacing(new oi(t.listValue,C),s.letterSpacing,Kc(s.lineHeight,s.fontSize.number)/2+2),this.ctx.textBaseline="bottom",this.ctx.textAlign="left"),_.label=20;case 20:return[2]}})})},e.prototype.renderStackContent=function(t){return De(this,void 0,void 0,function(){var i,r,b,s,a,b,o,c,b,l,u,b,d,h,b,f,p,b,g,v,b;return Oe(this,function(S){switch(S.label){case 0:return Se(t.element.container.flags,16),[4,this.renderNodeBackgroundAndBorders(t.element)];case 1:S.sent(),i=0,r=t.negativeZIndex,S.label=2;case 2:return i<r.length?(b=r[i],[4,this.renderStack(b)]):[3,5];case 3:S.sent(),S.label=4;case 4:return i++,[3,2];case 5:return[4,this.renderNodeContent(t.element)];case 6:S.sent(),s=0,a=t.nonInlineLevel,S.label=7;case 7:return s<a.length?(b=a[s],[4,this.renderNode(b)]):[3,10];case 8:S.sent(),S.label=9;case 9:return s++,[3,7];case 10:o=0,c=t.nonPositionedFloats,S.label=11;case 11:return o<c.length?(b=c[o],[4,this.renderStack(b)]):[3,14];case 12:S.sent(),S.label=13;case 13:return o++,[3,11];case 14:l=0,u=t.nonPositionedInlineLevel,S.label=15;case 15:return l<u.length?(b=u[l],[4,this.renderStack(b)]):[3,18];case 16:S.sent(),S.label=17;case 17:return l++,[3,15];case 18:d=0,h=t.inlineLevel,S.label=19;case 19:return d<h.length?(b=h[d],[4,this.renderNode(b)]):[3,22];case 20:S.sent(),S.label=21;case 21:return d++,[3,19];case 22:f=0,p=t.zeroOrAutoZIndexOrTransformedOrOpacity,S.label=23;case 23:return f<p.length?(b=p[f],[4,this.renderStack(b)]):[3,26];case 24:S.sent(),S.label=25;case 25:return f++,[3,23];case 26:g=0,v=t.positiveZIndex,S.label=27;case 27:return g<v.length?(b=v[g],[4,this.renderStack(b)]):[3,30];case 28:S.sent(),S.label=29;case 29:return g++,[3,27];case 30:return[2]}})})},e.prototype.mask=function(t){this.ctx.beginPath(),this.ctx.moveTo(0,0),this.ctx.lineTo(this.canvas.width,0),this.ctx.lineTo(this.canvas.width,this.canvas.height),this.ctx.lineTo(0,this.canvas.height),this.ctx.lineTo(0,0),this.formatPath(t.slice(0).reverse()),this.ctx.closePath()},e.prototype.path=function(t){this.ctx.beginPath(),this.formatPath(t),this.ctx.closePath()},e.prototype.formatPath=function(t){var i=this;t.forEach(function(r,s){var a=Je(r)?r.start:r;s===0?i.ctx.moveTo(a.x,a.y):i.ctx.lineTo(a.x,a.y),Je(r)&&i.ctx.bezierCurveTo(r.startControl.x,r.startControl.y,r.endControl.x,r.endControl.y,r.end.x,r.end.y)})},e.prototype.renderRepeat=function(t,i,r,s){this.path(t),this.ctx.fillStyle=i,this.ctx.translate(r,s),this.ctx.fill(),this.ctx.translate(-r,-s)},e.prototype.resizeImage=function(t,i,r){var s,a=(s=this.canvas.ownerDocument)!==null&&s!==void 0?s:document,o=a.createElement("canvas");o.width=Math.max(1,i),o.height=Math.max(1,r);var c=o.getContext("2d");return c.drawImage(t,0,0,t.width,t.height,0,0,i,r),o},e.prototype.renderBackgroundImage=function(t){return De(this,void 0,void 0,function(){var i,r,s,a,o,c;return Oe(this,function(l){switch(l.label){case 0:i=t.styles.backgroundImage.length-1,r=function(u){var d,h,f,p,g,V,Q,se,A,j,D,v,V,Q,se,A,j,b,S,x,k,T,C,_,R,I,D,U,V,G,z,A,j,K,Q,se,Me,Le,_e,et,qe,Te,Nt,Ke;return Oe(this,function(rn){switch(rn.label){case 0:if(u.type!==0)return[3,5];d=void 0,h=u.url,rn.label=1;case 1:return rn.trys.push([1,3,,4]),[4,s.context.cache.match(h)];case 2:return d=rn.sent(),[3,4];case 3:return rn.sent(),s.context.logger.error("Error loading background-image ".concat(h)),[3,4];case 4:return d&&(f=isNaN(d.width)||d.width===0?1:d.width,p=isNaN(d.height)||d.height===0?1:d.height,g=aa(t,i,[f,p,f/p]),V=g[0],Q=g[1],se=g[2],A=g[3],j=g[4],D=s.ctx.createPattern(s.resizeImage(d,A,j),"repeat"),s.renderRepeat(V,D,Q,se)),[3,6];case 5:Lg(u)?(v=aa(t,i,[null,null,null]),V=v[0],Q=v[1],se=v[2],A=v[3],j=v[4],b=Ig(u.angle,A,j),S=b[0],x=b[1],k=b[2],T=b[3],C=b[4],_=document.createElement("canvas"),_.width=A,_.height=j,R=_.getContext("2d"),I=R.createLinearGradient(x,T,k,C),Dc(u.stops,S||1).forEach(function(Sn){return I.addColorStop(Sn.stop,xe(Sn.color))}),R.fillStyle=I,R.fillRect(0,0,A,j),A>0&&j>0&&(D=s.ctx.createPattern(_,"repeat"),s.renderRepeat(V,D,Q,se))):Dg(u)&&(U=aa(t,i,[null,null,null]),V=U[0],G=U[1],z=U[2],A=U[3],j=U[4],K=u.position.length===0?[Is]:u.position,Q=te(K[0],A),se=te(K[K.length-1],j),Me=Og(u,Q,se,A,j),Le=Me[0],_e=Me[1],Le>0&&_e>0&&(et=s.ctx.createRadialGradient(G+Q,z+se,0,G+Q,z+se,Le),Dc(u.stops,Le*2).forEach(function(Sn){return et.addColorStop(Sn.stop,xe(Sn.color))}),s.path(V),s.ctx.fillStyle=et,Le!==_e?(qe=t.bounds.left+.5*t.bounds.width,Te=t.bounds.top+.5*t.bounds.height,Nt=_e/Le,Ke=1/Nt,s.ctx.save(),s.ctx.translate(qe,Te),s.ctx.transform(1,0,0,Nt,0,0),s.ctx.translate(-qe,-Te),s.ctx.fillRect(G,Ke*(z-Te)+Te,A,j*Ke),s.ctx.restore()):s.ctx.fill())),rn.label=6;case 6:return i--,[2]}})},s=this,a=0,o=t.styles.backgroundImage.slice(0).reverse(),l.label=1;case 1:return a<o.length?(c=o[a],[5,r(c)]):[3,4];case 2:l.sent(),l.label=3;case 3:return a++,[3,1];case 4:return[2]}})})},e.prototype.renderSolidBorder=function(t,i,r){return De(this,void 0,void 0,function(){return Oe(this,function(s){return this.path(Gl(r,i)),this.ctx.fillStyle=xe(t),this.ctx.fill(),[2]})})},e.prototype.renderDoubleBorder=function(t,i,r,s){return De(this,void 0,void 0,function(){var a,o;return Oe(this,function(c){switch(c.label){case 0:return i<3?[4,this.renderSolidBorder(t,r,s)]:[3,2];case 1:return c.sent(),[2];case 2:return a=wb(s,r),this.path(a),this.ctx.fillStyle=xe(t),this.ctx.fill(),o=_b(s,r),this.path(o),this.ctx.fill(),[2]}})})},e.prototype.renderNodeBackgroundAndBorders=function(t){return De(this,void 0,void 0,function(){var i,r,s,a,o,c,l,u,d=this;return Oe(this,function(h){switch(h.label){case 0:return this.applyEffects(t.getEffects(2)),i=t.container.styles,r=!Ft(i.backgroundColor)||i.backgroundImage.length,s=[{style:i.borderTopStyle,color:i.borderTopColor,width:i.borderTopWidth},{style:i.borderRightStyle,color:i.borderRightColor,width:i.borderRightWidth},{style:i.borderBottomStyle,color:i.borderBottomColor,width:i.borderBottomWidth},{style:i.borderLeftStyle,color:i.borderLeftColor,width:i.borderLeftWidth}],a=Ub(On(i.backgroundClip,0),t.curves),r||i.boxShadow.length?(this.ctx.save(),this.path(a),this.ctx.clip(),Ft(i.backgroundColor)||(this.ctx.fillStyle=xe(i.backgroundColor),this.ctx.fill()),[4,this.renderBackgroundImage(t.container)]):[3,2];case 1:h.sent(),this.ctx.restore(),i.boxShadow.slice(0).reverse().forEach(function(f){d.ctx.save();var p=vr(t.curves),g=f.inset?0:Mb,v=Cb(p,-g+(f.inset?1:-1)*f.spread.number,(f.inset?1:-1)*f.spread.number,f.spread.number*(f.inset?-2:2),f.spread.number*(f.inset?-2:2));f.inset?(d.path(p),d.ctx.clip(),d.mask(v)):(d.mask(p),d.ctx.clip(),d.path(v)),d.ctx.shadowOffsetX=f.offsetX.number+g,d.ctx.shadowOffsetY=f.offsetY.number,d.ctx.shadowColor=xe(f.color),d.ctx.shadowBlur=f.blur.number,d.ctx.fillStyle=f.inset?xe(f.color):"rgba(0,0,0,1)",d.ctx.fill(),d.ctx.restore()}),h.label=2;case 2:o=0,c=0,l=s,h.label=3;case 3:return c<l.length?(u=l[c],u.style!==0&&!Ft(u.color)&&u.width>0?u.style!==2?[3,5]:[4,this.renderDashedDottedBorder(u.color,u.width,o,t.curves,2)]:[3,11]):[3,13];case 4:return h.sent(),[3,11];case 5:return u.style!==3?[3,7]:[4,this.renderDashedDottedBorder(u.color,u.width,o,t.curves,3)];case 6:return h.sent(),[3,11];case 7:return u.style!==4?[3,9]:[4,this.renderDoubleBorder(u.color,u.width,o,t.curves)];case 8:return h.sent(),[3,11];case 9:return[4,this.renderSolidBorder(u.color,o,t.curves)];case 10:h.sent(),h.label=11;case 11:o++,h.label=12;case 12:return c++,[3,3];case 13:return[2]}})})},e.prototype.renderDashedDottedBorder=function(t,i,r,s,a){return De(this,void 0,void 0,function(){var o,c,l,u,d,h,f,p,g,v,b,S,x,k,T,C,T,C;return Oe(this,function(_){return this.ctx.save(),o=Eb(s,r),c=Gl(s,r),a===2&&(this.path(c),this.ctx.clip()),Je(c[0])?(l=c[0].start.x,u=c[0].start.y):(l=c[0].x,u=c[0].y),Je(c[1])?(d=c[1].end.x,h=c[1].end.y):(d=c[1].x,h=c[1].y),r===0||r===2?f=Math.abs(l-d):f=Math.abs(u-h),this.ctx.beginPath(),a===3?this.formatPath(o):this.formatPath(c.slice(0,2)),p=i<3?i*3:i*2,g=i<3?i*2:i,a===3&&(p=i,g=i),v=!0,f<=p*2?v=!1:f<=p*2+g?(b=f/(2*p+g),p*=b,g*=b):(S=Math.floor((f+g)/(p+g)),x=(f-S*p)/(S-1),k=(f-(S+1)*p)/S,g=k<=0||Math.abs(g-x)<Math.abs(g-k)?x:k),v&&(a===3?this.ctx.setLineDash([0,p+g]):this.ctx.setLineDash([p,g])),a===3?(this.ctx.lineCap="round",this.ctx.lineWidth=i):this.ctx.lineWidth=i*2+1.1,this.ctx.strokeStyle=xe(t),this.ctx.stroke(),this.ctx.setLineDash([]),a===2&&(Je(c[0])&&(T=c[3],C=c[0],this.ctx.beginPath(),this.formatPath([new B(T.end.x,T.end.y),new B(C.start.x,C.start.y)]),this.ctx.stroke()),Je(c[1])&&(T=c[1],C=c[2],this.ctx.beginPath(),this.formatPath([new B(T.end.x,T.end.y),new B(C.start.x,C.start.y)]),this.ctx.stroke())),this.ctx.restore(),[2]})})},e.prototype.render=function(t){return De(this,void 0,void 0,function(){var i;return Oe(this,function(r){switch(r.label){case 0:return this.options.backgroundColor&&(this.ctx.fillStyle=xe(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height)),i=xb(t),[4,this.renderStack(i)];case 1:return r.sent(),this.applyEffects([]),[2,this.canvas]}})})},e}(Hl),Db=function(n){return n instanceof gl||n instanceof ml?!0:n instanceof $s&&n.type!==dr&&n.type!==ur},Ub=function(n,e){switch(n){case 0:return vr(e);case 2:return bb(e);case 1:default:return br(e)}},Bb=function(n){switch(n){case 1:return"center";case 2:return"right";case 0:default:return"left"}},Fb=["-apple-system","system-ui"],jb=function(n){return/iPhone OS 15_(0|1)/.test(window.navigator.userAgent)?n.filter(function(e){return Fb.indexOf(e)===-1}):n},Vb=function(n){tt(e,n);function e(t,i){var r=n.call(this,t,i)||this;return r.canvas=i.canvas?i.canvas:document.createElement("canvas"),r.ctx=r.canvas.getContext("2d"),r.options=i,r.canvas.width=Math.floor(i.width*i.scale),r.canvas.height=Math.floor(i.height*i.scale),r.canvas.style.width="".concat(i.width,"px"),r.canvas.style.height="".concat(i.height,"px"),r.ctx.scale(r.options.scale,r.options.scale),r.ctx.translate(-i.x,-i.y),r.context.logger.debug("EXPERIMENTAL ForeignObject renderer initialized (".concat(i.width,"x").concat(i.height," at ").concat(i.x,",").concat(i.y,") with scale ").concat(i.scale)),r}return e.prototype.render=function(t){return De(this,void 0,void 0,function(){var i,r;return Oe(this,function(s){switch(s.label){case 0:return i=Hs(this.options.width*this.options.scale,this.options.height*this.options.scale,this.options.scale,this.options.scale,t),[4,Gb(i)];case 1:return r=s.sent(),this.options.backgroundColor&&(this.ctx.fillStyle=xe(this.options.backgroundColor),this.ctx.fillRect(0,0,this.options.width*this.options.scale,this.options.height*this.options.scale)),this.ctx.drawImage(r,-this.options.x*this.options.scale,-this.options.y*this.options.scale),[2,this.canvas]}})})},e}(Hl),Gb=function(n){return new Promise(function(e,t){var i=new Image;i.onload=function(){e(i)},i.onerror=t,i.src="data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(new XMLSerializer().serializeToString(n)))})},Wb=function(){function n(e){var t=e.id,i=e.enabled;this.id=t,this.enabled=i,this.start=Date.now()}return n.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.enabled&&(typeof window<"u"&&window.console?(()=>{}).apply(console,Ii([this.id,"".concat(this.getTime(),"ms")],e,!1)):this.info.apply(this,e))},n.prototype.getTime=function(){return Date.now()-this.start},n.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.enabled&&typeof window<"u"&&window.console&&typeof console.info=="function"&&console.info.apply(console,Ii([this.id,"".concat(this.getTime(),"ms")],e,!1))},n.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.enabled&&(typeof window<"u"&&window.console&&typeof console.warn=="function"?console.warn.apply(console,Ii([this.id,"".concat(this.getTime(),"ms")],e,!1)):this.info.apply(this,e))},n.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.enabled&&(typeof window<"u"&&window.console&&typeof console.error=="function"?console.error.apply(console,Ii([this.id,"".concat(this.getTime(),"ms")],e,!1)):this.info.apply(this,e))},n.instances={},n}(),zb=function(){function n(e,t){var i;this.windowBounds=t,this.instanceName="#".concat(n.instanceCount++),this.logger=new Wb({id:this.instanceName,enabled:e.logging}),this.cache=(i=e.cache)!==null&&i!==void 0?i:new ub(this,e)}return n.instanceCount=1,n}(),Hb=function(n,e){return e===void 0&&(e={}),qb(n,e)};typeof window<"u"&&na.setContext(window);var qb=function(n,e){return De(void 0,void 0,void 0,function(){var t,i,r,s,a,o,c,l,u,d,h,f,p,g,v,b,S,x,k,T,_,C,_,R,I,D,U,V,G,z,A,j,K,Q,se,Me,Le,_e,et,qe;return Oe(this,function(Te){switch(Te.label){case 0:if(!n||typeof n!="object")return[2,Promise.reject("Invalid element provided as first argument")];if(t=n.ownerDocument,!t)throw new Error("Element is not attached to a Document");if(i=t.defaultView,!i)throw new Error("Document is not attached to a Window");return r={allowTaint:(R=e.allowTaint)!==null&&R!==void 0?R:!1,imageTimeout:(I=e.imageTimeout)!==null&&I!==void 0?I:15e3,proxy:e.proxy,useCORS:(D=e.useCORS)!==null&&D!==void 0?D:!1,customIsSameOrigin:e.customIsSameOrigin},s=ws({logging:(U=e.logging)!==null&&U!==void 0?U:!0,cache:e.cache},r),a={windowWidth:(V=e.windowWidth)!==null&&V!==void 0?V:i.innerWidth,windowHeight:(G=e.windowHeight)!==null&&G!==void 0?G:i.innerHeight,scrollX:(z=e.scrollX)!==null&&z!==void 0?z:i.pageXOffset,scrollY:(A=e.scrollY)!==null&&A!==void 0?A:i.pageYOffset},o=new xt(a.scrollX,a.scrollY,a.windowWidth,a.windowHeight),c=new zb(s,o),l=(j=e.foreignObjectRendering)!==null&&j!==void 0?j:!1,u={allowTaint:(K=e.allowTaint)!==null&&K!==void 0?K:!1,onclone:e.onclone,ignoreElements:e.ignoreElements,inlineImages:l,copyStyles:l},c.logger.debug("Starting document clone with size ".concat(o.width,"x").concat(o.height," scrolled to ").concat(-o.left,",").concat(-o.top)),d=new Ll(c,n,u),h=d.clonedReferenceElement,h?[4,d.toIFrame(t,o)]:[2,Promise.reject("Unable to find element in cloned iframe")];case 1:return f=Te.sent(),p=Xs(h)||qv(h)?lp(h.ownerDocument):Oi(c,h),g=p.width,v=p.height,b=p.left,S=p.top,x=Kb(c,h,e.backgroundColor),k={canvas:e.canvas,backgroundColor:x,scale:(se=(Q=e.scale)!==null&&Q!==void 0?Q:i.devicePixelRatio)!==null&&se!==void 0?se:1,x:((Me=e.x)!==null&&Me!==void 0?Me:0)+b,y:((Le=e.y)!==null&&Le!==void 0?Le:0)+S,width:(_e=e.width)!==null&&_e!==void 0?_e:Math.ceil(g),height:(et=e.height)!==null&&et!==void 0?et:Math.ceil(v)},l?(c.logger.debug("Document cloned, using foreign object rendering"),_=new Vb(c,k),[4,_.render(h)]):[3,3];case 2:return T=Te.sent(),[3,5];case 3:return c.logger.debug("Document cloned, element located at ".concat(b,",").concat(S," with size ").concat(g,"x").concat(v," using computed rendering")),c.logger.debug("Starting DOM parsing"),C=yl(c,h),x===C.styles.backgroundColor&&(C.styles.backgroundColor=vt.TRANSPARENT),c.logger.debug("Starting renderer for element at ".concat(k.x,",").concat(k.y," with size ").concat(k.width,"x").concat(k.height)),_=new Lb(c,k),[4,_.render(C)];case 4:T=Te.sent(),Te.label=5;case 5:return(!((qe=e.removeContainer)!==null&&qe!==void 0)||qe)&&(Ll.destroy(f)||c.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore")),c.logger.debug("Finished rendering"),[2,T]}})})},Kb=function(n,e,t){var i=e.ownerDocument,r=i.documentElement?xn(n,getComputedStyle(i.documentElement).backgroundColor):vt.TRANSPARENT,s=i.body?xn(n,getComputedStyle(i.body).backgroundColor):vt.TRANSPARENT,a=typeof t=="string"?xn(n,t):t===null?vt.TRANSPARENT:4294967295;return e===i.documentElement?Ft(r)?Ft(s)?a:s:r:a};function $b(n,e){return e.forEach(function(t){t&&typeof t!="string"&&!Array.isArray(t)&&Object.keys(t).forEach(function(i){if(i!=="default"&&!(i in n)){var r=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(n,i,r.get?r:{enumerable:!0,get:function(){return t[i]}})}})}),Object.freeze(n)}var Yb=Object.defineProperty,Xb=(n,e,t)=>e in n?Yb(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ql=(n,e,t)=>Xb(n,typeof e!="symbol"?e+"":e,t);let Fe=class{constructor(){ql(this,"_locking"),ql(this,"_locks"),this._locking=Promise.resolve(),this._locks=0}isLocked(){return this._locks>0}lock(){this._locks+=1;let e;const t=new Promise(r=>e=()=>{this._locks-=1,r()}),i=this._locking.then(()=>e);return this._locking=this._locking.then(()=>t),i}};function he(n,e){if(!n)throw new Error(e)}const Jb=34028234663852886e22,Qb=-34028234663852886e22,Zb=4294967295,ey=2147483647,ty=-2147483648;function Cr(n){if(typeof n!="number")throw new Error("invalid int 32: "+typeof n);if(!Number.isInteger(n)||n>ey||n<ty)throw new Error("invalid int 32: "+n)}function oa(n){if(typeof n!="number")throw new Error("invalid uint 32: "+typeof n);if(!Number.isInteger(n)||n>Zb||n<0)throw new Error("invalid uint 32: "+n)}function Kl(n){if(typeof n!="number")throw new Error("invalid float 32: "+typeof n);if(Number.isFinite(n)&&(n>Jb||n<Qb))throw new Error("invalid float 32: "+n)}const $l=Symbol("@bufbuild/protobuf/enum-type");function ny(n){const e=n[$l];return he(e,"missing enum type on enum object"),e}function Yl(n,e,t,i){n[$l]=Xl(e,t.map(r=>({no:r.no,name:r.name,localName:n[r.no]})))}function Xl(n,e,t){const i=Object.create(null),r=Object.create(null),s=[];for(const a of e){const o=Jl(a);s.push(o),i[a.name]=o,r[a.no]=o}return{typeName:n,values:s,findName(a){return i[a]},findNumber(a){return r[a]}}}function iy(n,e,t){const i={};for(const r of e){const s=Jl(r);i[s.localName]=s.no,i[s.no]=s.localName}return Yl(i,n,e),i}function Jl(n){return"localName"in n?n:Object.assign(Object.assign({},n),{localName:n.name})}class ca{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){const i=this.getType(),r=i.runtime.bin,s=r.makeReadOptions(t);return r.readMessage(this,s.readerFactory(e),e.byteLength,s),this}fromJson(e,t){const i=this.getType(),r=i.runtime.json,s=r.makeReadOptions(t);return r.readMessage(i,e,s,this),this}fromJsonString(e,t){let i;try{i=JSON.parse(e)}catch(r){throw new Error("cannot decode ".concat(this.getType().typeName," from JSON: ").concat(r instanceof Error?r.message:String(r)))}return this.fromJson(i,t)}toBinary(e){const t=this.getType(),i=t.runtime.bin,r=i.makeWriteOptions(e),s=r.writerFactory();return i.writeMessage(this,s,r),s.finish()}toJson(e){const t=this.getType(),i=t.runtime.json,r=i.makeWriteOptions(e);return i.writeMessage(this,r)}toJsonString(e){var t;const i=this.toJson(e);return JSON.stringify(i,null,(t=e==null?void 0:e.prettySpaces)!==null&&t!==void 0?t:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function ry(n,e,t,i){var r;const s=(r=i==null?void 0:i.localName)!==null&&r!==void 0?r:e.substring(e.lastIndexOf(".")+1),a={[s]:function(o){n.util.initFields(this),n.util.initPartial(o,this)}}[s];return Object.setPrototypeOf(a.prototype,new ca),Object.assign(a,{runtime:n,typeName:e,fields:n.util.newFieldList(t),fromBinary(o,c){return new a().fromBinary(o,c)},fromJson(o,c){return new a().fromJson(o,c)},fromJsonString(o,c){return new a().fromJsonString(o,c)},equals(o,c){return n.util.equals(a,o,c)}}),a}function sy(){let n=0,e=0;for(let i=0;i<28;i+=7){let r=this.buf[this.pos++];if(n|=(r&127)<<i,!(r&128))return this.assertBounds(),[n,e]}let t=this.buf[this.pos++];if(n|=(t&15)<<28,e=(t&112)>>4,!(t&128))return this.assertBounds(),[n,e];for(let i=3;i<=31;i+=7){let r=this.buf[this.pos++];if(e|=(r&127)<<i,!(r&128))return this.assertBounds(),[n,e]}throw new Error("invalid varint")}function la(n,e,t){for(let s=0;s<28;s=s+7){const a=n>>>s,o=!(!(a>>>7)&&e==0),c=(o?a|128:a)&255;if(t.push(c),!o)return}const i=n>>>28&15|(e&7)<<4,r=!!(e>>3);if(t.push((r?i|128:i)&255),!!r){for(let s=3;s<31;s=s+7){const a=e>>>s,o=!!(a>>>7),c=(o?a|128:a)&255;if(t.push(c),!o)return}t.push(e>>>31&1)}}const xr=4294967296;function Ql(n){const e=n[0]==="-";e&&(n=n.slice(1));const t=1e6;let i=0,r=0;function s(a,o){const c=Number(n.slice(a,o));r*=t,i=i*t+c,i>=xr&&(r=r+(i/xr|0),i=i%xr)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),e?eu(i,r):ua(i,r)}function ay(n,e){let t=ua(n,e);const i=t.hi&2147483648;i&&(t=eu(t.lo,t.hi));const r=Zl(t.lo,t.hi);return i?"-"+r:r}function Zl(n,e){if({lo:n,hi:e}=oy(n,e),e<=2097151)return String(xr*e+n);const t=n&16777215,i=(n>>>24|e<<8)&16777215,r=e>>16&65535;let s=t+i*6777216+r*6710656,a=i+r*8147497,o=r*2;const c=1e7;return s>=c&&(a+=Math.floor(s/c),s%=c),a>=c&&(o+=Math.floor(a/c),a%=c),o.toString()+tu(a)+tu(s)}function oy(n,e){return{lo:n>>>0,hi:e>>>0}}function ua(n,e){return{lo:n|0,hi:e|0}}function eu(n,e){return e=~e,n?n=~n+1:e+=1,ua(n,e)}const tu=n=>{const e=String(n);return"0000000".slice(e.length)+e};function nu(n,e){if(n>=0){for(;n>127;)e.push(n&127|128),n=n>>>7;e.push(n)}else{for(let t=0;t<9;t++)e.push(n&127|128),n=n>>7;e.push(1)}}function cy(){let n=this.buf[this.pos++],e=n&127;if(!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<7,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<14,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<21,!(n&128))return this.assertBounds(),e;n=this.buf[this.pos++],e|=(n&15)<<28;for(let t=5;n&128&&t<10;t++)n=this.buf[this.pos++];if(n&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}function ly(){const n=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof n.getBigInt64=="function"&&typeof n.getBigUint64=="function"&&typeof n.setBigInt64=="function"&&typeof n.setBigUint64=="function"&&(typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){const r=BigInt("-9223372036854775808"),s=BigInt("9223372036854775807"),a=BigInt("0"),o=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(c){const l=typeof c=="bigint"?c:BigInt(c);if(l>s||l<r)throw new Error("int64 invalid: ".concat(c));return l},uParse(c){const l=typeof c=="bigint"?c:BigInt(c);if(l>o||l<a)throw new Error("uint64 invalid: ".concat(c));return l},enc(c){return n.setBigInt64(0,this.parse(c),!0),{lo:n.getInt32(0,!0),hi:n.getInt32(4,!0)}},uEnc(c){return n.setBigInt64(0,this.uParse(c),!0),{lo:n.getInt32(0,!0),hi:n.getInt32(4,!0)}},dec(c,l){return n.setInt32(0,c,!0),n.setInt32(4,l,!0),n.getBigInt64(0,!0)},uDec(c,l){return n.setInt32(0,c,!0),n.setInt32(4,l,!0),n.getBigUint64(0,!0)}}}const t=r=>he(/^-?[0-9]+$/.test(r),"int64 invalid: ".concat(r)),i=r=>he(/^[0-9]+$/.test(r),"uint64 invalid: ".concat(r));return{zero:"0",supported:!1,parse(r){return typeof r!="string"&&(r=r.toString()),t(r),r},uParse(r){return typeof r!="string"&&(r=r.toString()),i(r),r},enc(r){return typeof r!="string"&&(r=r.toString()),t(r),Ql(r)},uEnc(r){return typeof r!="string"&&(r=r.toString()),i(r),Ql(r)},dec(r,s){return ay(r,s)},uDec(r,s){return Zl(r,s)}}}const le=ly();var E;(function(n){n[n.DOUBLE=1]="DOUBLE",n[n.FLOAT=2]="FLOAT",n[n.INT64=3]="INT64",n[n.UINT64=4]="UINT64",n[n.INT32=5]="INT32",n[n.FIXED64=6]="FIXED64",n[n.FIXED32=7]="FIXED32",n[n.BOOL=8]="BOOL",n[n.STRING=9]="STRING",n[n.BYTES=12]="BYTES",n[n.UINT32=13]="UINT32",n[n.SFIXED32=15]="SFIXED32",n[n.SFIXED64=16]="SFIXED64",n[n.SINT32=17]="SINT32",n[n.SINT64=18]="SINT64"})(E||(E={}));var zt;(function(n){n[n.BIGINT=0]="BIGINT",n[n.STRING=1]="STRING"})(zt||(zt={}));function Ht(n,e,t){if(e===t)return!0;if(n==E.BYTES){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}switch(n){case E.UINT64:case E.FIXED64:case E.INT64:case E.SFIXED64:case E.SINT64:return e==t}return!1}function An(n,e){switch(n){case E.BOOL:return!1;case E.UINT64:case E.FIXED64:case E.INT64:case E.SFIXED64:case E.SINT64:return e==0?le.zero:"0";case E.DOUBLE:case E.FLOAT:return 0;case E.BYTES:return new Uint8Array(0);case E.STRING:return"";default:return 0}}function iu(n,e){switch(n){case E.BOOL:return e===!1;case E.STRING:return e==="";case E.BYTES:return e instanceof Uint8Array&&!e.byteLength;default:return e==0}}var ve;(function(n){n[n.Varint=0]="Varint",n[n.Bit64=1]="Bit64",n[n.LengthDelimited=2]="LengthDelimited",n[n.StartGroup=3]="StartGroup",n[n.EndGroup=4]="EndGroup",n[n.Bit32=5]="Bit32"})(ve||(ve={}));class uy{constructor(e){this.stack=[],this.textEncoder=e??new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let r=0;r<this.chunks.length;r++)e+=this.chunks[r].length;let t=new Uint8Array(e),i=0;for(let r=0;r<this.chunks.length;r++)t.set(this.chunks[r],i),i+=this.chunks[r].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|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(oa(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return Cr(e),nu(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){Kl(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){oa(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){Cr(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return Cr(e),e=(e<<1^e>>31)>>>0,nu(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),i=new DataView(t.buffer),r=le.enc(e);return i.setInt32(0,r.lo,!0),i.setInt32(4,r.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),i=new DataView(t.buffer),r=le.uEnc(e);return i.setInt32(0,r.lo,!0),i.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=le.enc(e);return la(t.lo,t.hi,this.buf),this}sint64(e){let t=le.enc(e),i=t.hi>>31,r=t.lo<<1^i,s=(t.hi<<1|t.lo>>>31)^i;return la(r,s,this.buf),this}uint64(e){let t=le.uEnc(e);return la(t.lo,t.hi,this.buf),this}}class dy{constructor(e,t){this.varint64=sy,this.uint32=cy,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t??new TextDecoder}tag(){let e=this.uint32(),t=e>>>3,i=e&7;if(t<=0||i<0||i>5)throw new Error("illegal tag: field no "+t+" wire type "+i);return[t,i]}skip(e,t){let i=this.pos;switch(e){case ve.Varint:for(;this.buf[this.pos++]&128;);break;case ve.Bit64:this.pos+=4;case ve.Bit32:this.pos+=4;break;case ve.LengthDelimited:let r=this.uint32();this.pos+=r;break;case ve.StartGroup:for(;;){const[s,a]=this.tag();if(a===ve.EndGroup){if(t!==void 0&&s!==t)throw new Error("invalid end group tag");break}this.skip(a,s)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(i,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return le.dec(...this.varint64())}uint64(){return le.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),i=-(e&1);return e=(e>>>1|(t&1)<<31)^i,t=t>>>1^i,le.dec(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return le.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return le.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 hy(n,e,t,i){let r;return{typeName:e,extendee:t,get field(){if(!r){const s=typeof i=="function"?i():i;s.name=e.split(".").pop(),s.jsonName="[".concat(e,"]"),r=n.util.newFieldList([s]).list()[0]}return r},runtime:n}}function ru(n){const e=n.field.localName,t=Object.create(null);return t[e]=fy(n),[t,()=>t[e]]}function fy(n){const e=n.field;if(e.repeated)return[];if(e.default!==void 0)return e.default;switch(e.kind){case"enum":return e.T.values[0].no;case"scalar":return An(e.T,e.L);case"message":const t=e.T,i=new t;return t.fieldWrapper?t.fieldWrapper.unwrapField(i):i;case"map":throw"map fields are not allowed to be extensions"}}function py(n,e){if(!e.repeated&&(e.kind=="enum"||e.kind=="scalar")){for(let t=n.length-1;t>=0;--t)if(n[t].no==e.no)return[n[t]];return[]}return n.filter(t=>t.no===e.no)}let _t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),wr=[];for(let n=0;n<_t.length;n++)wr[_t[n].charCodeAt(0)]=n;wr["-".charCodeAt(0)]=_t.indexOf("+"),wr["_".charCodeAt(0)]=_t.indexOf("/");const su={dec(n){let e=n.length*3/4;n[n.length-2]=="="?e-=2:n[n.length-1]=="="&&(e-=1);let t=new Uint8Array(e),i=0,r=0,s,a=0;for(let o=0;o<n.length;o++){if(s=wr[n.charCodeAt(o)],s===void 0)switch(n[o]){case"=":r=0;case`
6
+ `:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(r){case 0:a=s,r=1;break;case 1:t[i++]=a<<2|(s&48)>>4,a=s,r=2;break;case 2:t[i++]=(a&15)<<4|(s&60)>>2,a=s,r=3;break;case 3:t[i++]=(a&3)<<6|s,r=0;break}}if(r==1)throw Error("invalid base64 string.");return t.subarray(0,i)},enc(n){let e="",t=0,i,r=0;for(let s=0;s<n.length;s++)switch(i=n[s],t){case 0:e+=_t[i>>2],r=(i&3)<<4,t=1;break;case 1:e+=_t[r|i>>4],r=(i&15)<<2,t=2;break;case 2:e+=_t[r|i>>6],e+=_t[i&63],t=0;break}return t&&(e+=_t[r],e+="=",t==1&&(e+="=")),e}};function my(n,e,t){ou(e,n);const i=e.runtime.bin.makeReadOptions(t),r=py(n.getType().runtime.bin.listUnknownFields(n),e.field),[s,a]=ru(e);for(const o of r)e.runtime.bin.readField(s,i.readerFactory(o.data),e.field,o.wireType,i);return a()}function gy(n,e,t,i){ou(e,n);const r=e.runtime.bin.makeReadOptions(i),s=e.runtime.bin.makeWriteOptions(i);if(au(n,e)){const l=n.getType().runtime.bin.listUnknownFields(n).filter(u=>u.no!=e.field.no);n.getType().runtime.bin.discardUnknownFields(n);for(const u of l)n.getType().runtime.bin.onUnknownField(n,u.no,u.wireType,u.data)}const a=s.writerFactory();let o=e.field;!o.opt&&!o.repeated&&(o.kind=="enum"||o.kind=="scalar")&&(o=Object.assign(Object.assign({},e.field),{opt:!0})),e.runtime.bin.writeField(o,t,a,s);const c=r.readerFactory(a.finish());for(;c.pos<c.len;){const[l,u]=c.tag(),d=c.skip(u,l);n.getType().runtime.bin.onUnknownField(n,l,u,d)}}function au(n,e){const t=n.getType();return e.extendee.typeName===t.typeName&&!!t.runtime.bin.listUnknownFields(n).find(i=>i.no==e.field.no)}function ou(n,e){he(n.extendee.typeName==e.getType().typeName,"extension ".concat(n.typeName," can only be applied to message ").concat(n.extendee.typeName))}function cu(n,e){const t=n.localName;if(n.repeated)return e[t].length>0;if(n.oneof)return e[n.oneof.localName].case===t;switch(n.kind){case"enum":case"scalar":return n.opt||n.req?e[t]!==void 0:n.kind=="enum"?e[t]!==n.T.values[0].no:!iu(n.T,e[t]);case"message":return e[t]!==void 0;case"map":return Object.keys(e[t]).length>0}}function lu(n,e){const t=n.localName,i=!n.opt&&!n.req;if(n.repeated)e[t]=[];else if(n.oneof)e[n.oneof.localName]={case:void 0};else switch(n.kind){case"map":e[t]={};break;case"enum":e[t]=i?n.T.values[0].no:void 0;break;case"scalar":e[t]=i?An(n.T,n.L):void 0;break;case"message":e[t]=void 0;break}}function ln(n,e){if(n===null||typeof n!="object"||!Object.getOwnPropertyNames(ca.prototype).every(i=>i in n&&typeof n[i]=="function"))return!1;const t=n.getType();return t===null||typeof t!="function"||!("typeName"in t)||typeof t.typeName!="string"?!1:e===void 0?!0:t.typeName==e.typeName}function uu(n,e){return ln(e)||!n.fieldWrapper?e:n.fieldWrapper.wrapField(e)}E.DOUBLE,E.FLOAT,E.INT64,E.UINT64,E.INT32,E.UINT32,E.BOOL,E.STRING,E.BYTES;const du={ignoreUnknownFields:!1},hu={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function vy(n){return n?Object.assign(Object.assign({},du),n):du}function by(n){return n?Object.assign(Object.assign({},hu),n):hu}const _r=Symbol(),Er=Symbol();function yy(){return{makeReadOptions:vy,makeWriteOptions:by,readMessage(n,e,t,i){if(e==null||Array.isArray(e)||typeof e!="object")throw new Error("cannot decode message ".concat(n.typeName," from JSON: ").concat(yt(e)));i=i??new n;const r=new Map,s=t.typeRegistry;for(const[a,o]of Object.entries(e)){const c=n.fields.findJsonName(a);if(c){if(c.oneof){if(o===null&&c.kind=="scalar")continue;const l=r.get(c.oneof);if(l!==void 0)throw new Error("cannot decode message ".concat(n.typeName,' from JSON: multiple keys for oneof "').concat(c.oneof.name,'" present: "').concat(l,'", "').concat(a,'"'));r.set(c.oneof,a)}fu(i,o,c,t,n)}else{let l=!1;if(s!=null&&s.findExtension&&a.startsWith("[")&&a.endsWith("]")){const u=s.findExtension(a.substring(1,a.length-1));if(u&&u.extendee.typeName==n.typeName){l=!0;const[d,h]=ru(u);fu(d,o,u.field,t,u),gy(i,u,h(),t)}}if(!l&&!t.ignoreUnknownFields)throw new Error("cannot decode message ".concat(n.typeName,' from JSON: key "').concat(a,'" is unknown'))}}return i},writeMessage(n,e){const t=n.getType(),i={};let r;try{for(r of t.fields.byNumber()){if(!cu(r,n)){if(r.req)throw"required field not set";if(!e.emitDefaultValues||!Ty(r))continue}const a=r.oneof?n[r.oneof.localName].value:n[r.localName],o=pu(r,a,e);o!==void 0&&(i[e.useProtoFieldName?r.name:r.jsonName]=o)}const s=e.typeRegistry;if(s!=null&&s.findExtensionFor)for(const a of t.runtime.bin.listUnknownFields(n)){const o=s.findExtensionFor(t.typeName,a.no);if(o&&au(n,o)){const c=my(n,o,e),l=pu(o.field,c,e);l!==void 0&&(i[o.field.jsonName]=l)}}}catch(s){const a=r?"cannot encode field ".concat(t.typeName,".").concat(r.name," to JSON"):"cannot encode message ".concat(t.typeName," to JSON"),o=s instanceof Error?s.message:String(s);throw new Error(a+(o.length>0?": ".concat(o):""))}return i},readScalar(n,e,t){return di(n,e,t??zt.BIGINT,!0)},writeScalar(n,e,t){if(e!==void 0&&(t||iu(n,e)))return Pr(n,e)},debug:yt}}function yt(n){if(n===null)return"null";switch(typeof n){case"object":return Array.isArray(n)?"array":"object";case"string":return n.length>100?"string":'"'.concat(n.split('"').join('\\"'),'"');default:return String(n)}}function fu(n,e,t,i,r){let s=t.localName;if(t.repeated){if(he(t.kind!="map"),e===null)return;if(!Array.isArray(e))throw new Error("cannot decode field ".concat(r.typeName,".").concat(t.name," from JSON: ").concat(yt(e)));const a=n[s];for(const o of e){if(o===null)throw new Error("cannot decode field ".concat(r.typeName,".").concat(t.name," from JSON: ").concat(yt(o)));switch(t.kind){case"message":a.push(t.T.fromJson(o,i));break;case"enum":const c=da(t.T,o,i.ignoreUnknownFields,!0);c!==Er&&a.push(c);break;case"scalar":try{a.push(di(t.T,o,t.L,!0))}catch(l){let u="cannot decode field ".concat(r.typeName,".").concat(t.name," from JSON: ").concat(yt(o));throw l instanceof Error&&l.message.length>0&&(u+=": ".concat(l.message)),new Error(u)}break}}}else if(t.kind=="map"){if(e===null)return;if(typeof e!="object"||Array.isArray(e))throw new Error("cannot decode field ".concat(r.typeName,".").concat(t.name," from JSON: ").concat(yt(e)));const a=n[s];for(const[o,c]of Object.entries(e)){if(c===null)throw new Error("cannot decode field ".concat(r.typeName,".").concat(t.name," from JSON: map value null"));let l;try{l=ky(t.K,o)}catch(u){let d="cannot decode map key for field ".concat(r.typeName,".").concat(t.name," from JSON: ").concat(yt(e));throw u instanceof Error&&u.message.length>0&&(d+=": ".concat(u.message)),new Error(d)}switch(t.V.kind){case"message":a[l]=t.V.T.fromJson(c,i);break;case"enum":const u=da(t.V.T,c,i.ignoreUnknownFields,!0);u!==Er&&(a[l]=u);break;case"scalar":try{a[l]=di(t.V.T,c,zt.BIGINT,!0)}catch(d){let h="cannot decode map value for field ".concat(r.typeName,".").concat(t.name," from JSON: ").concat(yt(e));throw d instanceof Error&&d.message.length>0&&(h+=": ".concat(d.message)),new Error(h)}break}}}else switch(t.oneof&&(n=n[t.oneof.localName]={case:s},s="value"),t.kind){case"message":const a=t.T;if(e===null&&a.typeName!="google.protobuf.Value")return;let o=n[s];ln(o)?o.fromJson(e,i):(n[s]=o=a.fromJson(e,i),a.fieldWrapper&&!t.oneof&&(n[s]=a.fieldWrapper.unwrapField(o)));break;case"enum":const c=da(t.T,e,i.ignoreUnknownFields,!1);switch(c){case _r:lu(t,n);break;case Er:break;default:n[s]=c;break}break;case"scalar":try{const l=di(t.T,e,t.L,!1);switch(l){case _r:lu(t,n);break;default:n[s]=l;break}}catch(l){let u="cannot decode field ".concat(r.typeName,".").concat(t.name," from JSON: ").concat(yt(e));throw l instanceof Error&&l.message.length>0&&(u+=": ".concat(l.message)),new Error(u)}break}}function ky(n,e){if(n===E.BOOL)switch(e){case"true":e=!0;break;case"false":e=!1;break}return di(n,e,zt.BIGINT,!0).toString()}function di(n,e,t,i){if(e===null)return i?An(n,t):_r;switch(n){case E.DOUBLE:case E.FLOAT:if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""||typeof e=="string"&&e.trim().length!==e.length||typeof e!="string"&&typeof e!="number")break;const r=Number(e);if(Number.isNaN(r)||!Number.isFinite(r))break;return n==E.FLOAT&&Kl(r),r;case E.INT32:case E.FIXED32:case E.SFIXED32:case E.SINT32:case E.UINT32:let s;if(typeof e=="number"?s=e:typeof e=="string"&&e.length>0&&e.trim().length===e.length&&(s=Number(e)),s===void 0)break;return n==E.UINT32||n==E.FIXED32?oa(s):Cr(s),s;case E.INT64:case E.SFIXED64:case E.SINT64:if(typeof e!="number"&&typeof e!="string")break;const a=le.parse(e);return t?a.toString():a;case E.FIXED64:case E.UINT64:if(typeof e!="number"&&typeof e!="string")break;const o=le.uParse(e);return t?o.toString():o;case E.BOOL:if(typeof e!="boolean")break;return e;case E.STRING:if(typeof e!="string")break;try{encodeURIComponent(e)}catch{throw new Error("invalid UTF8")}return e;case E.BYTES:if(e==="")return new Uint8Array(0);if(typeof e!="string")break;return su.dec(e)}throw new Error}function da(n,e,t,i){if(e===null)return n.typeName=="google.protobuf.NullValue"?0:i?n.values[0].no:_r;switch(typeof e){case"number":if(Number.isInteger(e))return e;break;case"string":const r=n.findName(e);if(r!==void 0)return r.no;if(t)return Er;break}throw new Error("cannot decode enum ".concat(n.typeName," from JSON: ").concat(yt(e)))}function Ty(n){return n.repeated||n.kind=="map"?!0:!(n.oneof||n.kind=="message"||n.opt||n.req)}function pu(n,e,t){if(n.kind=="map"){he(typeof e=="object"&&e!=null);const i={},r=Object.entries(e);switch(n.V.kind){case"scalar":for(const[a,o]of r)i[a.toString()]=Pr(n.V.T,o);break;case"message":for(const[a,o]of r)i[a.toString()]=o.toJson(t);break;case"enum":const s=n.V.T;for(const[a,o]of r)i[a.toString()]=ha(s,o,t.enumAsInteger);break}return t.emitDefaultValues||r.length>0?i:void 0}if(n.repeated){he(Array.isArray(e));const i=[];switch(n.kind){case"scalar":for(let r=0;r<e.length;r++)i.push(Pr(n.T,e[r]));break;case"enum":for(let r=0;r<e.length;r++)i.push(ha(n.T,e[r],t.enumAsInteger));break;case"message":for(let r=0;r<e.length;r++)i.push(e[r].toJson(t));break}return t.emitDefaultValues||i.length>0?i:void 0}switch(n.kind){case"scalar":return Pr(n.T,e);case"enum":return ha(n.T,e,t.enumAsInteger);case"message":return uu(n.T,e).toJson(t)}}function ha(n,e,t){var i;if(he(typeof e=="number"),n.typeName=="google.protobuf.NullValue")return null;if(t)return e;const r=n.findNumber(e);return(i=r==null?void 0:r.name)!==null&&i!==void 0?i:e}function Pr(n,e){switch(n){case E.INT32:case E.SFIXED32:case E.SINT32:case E.FIXED32:case E.UINT32:return he(typeof e=="number"),e;case E.FLOAT:case E.DOUBLE:return he(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e;case E.STRING:return he(typeof e=="string"),e;case E.BOOL:return he(typeof e=="boolean"),e;case E.UINT64:case E.FIXED64:case E.INT64:case E.SFIXED64:case E.SINT64:return he(typeof e=="bigint"||typeof e=="string"||typeof e=="number"),e.toString();case E.BYTES:return he(e instanceof Uint8Array),su.enc(e)}}const Nn=Symbol("@bufbuild/protobuf/unknown-fields"),mu={readUnknownFields:!0,readerFactory:n=>new dy(n)},gu={writeUnknownFields:!0,writerFactory:()=>new uy};function Sy(n){return n?Object.assign(Object.assign({},mu),n):mu}function Cy(n){return n?Object.assign(Object.assign({},gu),n):gu}function xy(){return{makeReadOptions:Sy,makeWriteOptions:Cy,listUnknownFields(n){var e;return(e=n[Nn])!==null&&e!==void 0?e:[]},discardUnknownFields(n){delete n[Nn]},writeUnknownFields(n,e){const i=n[Nn];if(i)for(const r of i)e.tag(r.no,r.wireType).raw(r.data)},onUnknownField(n,e,t,i){const r=n;Array.isArray(r[Nn])||(r[Nn]=[]),r[Nn].push({no:e,wireType:t,data:i})},readMessage(n,e,t,i,r){const s=n.getType(),a=r?e.len:e.pos+t;let o,c;for(;e.pos<a&&([o,c]=e.tag(),!(r===!0&&c==ve.EndGroup));){const l=s.fields.find(o);if(!l){const u=e.skip(c,o);i.readUnknownFields&&this.onUnknownField(n,o,c,u);continue}vu(n,e,l,c,i)}if(r&&(c!=ve.EndGroup||o!==t))throw new Error("invalid end group tag")},readField:vu,writeMessage(n,e,t){const i=n.getType();for(const r of i.fields.byNumber()){if(!cu(r,n)){if(r.req)throw new Error("cannot encode field ".concat(i.typeName,".").concat(r.name," to binary: required field not set"));continue}const s=r.oneof?n[r.oneof.localName].value:n[r.localName];bu(r,s,e,t)}return t.writeUnknownFields&&this.writeUnknownFields(n,e),e},writeField(n,e,t,i){e!==void 0&&bu(n,e,t,i)}}}function vu(n,e,t,i,r){let{repeated:s,localName:a}=t;switch(t.oneof&&(n=n[t.oneof.localName],n.case!=a&&delete n.value,n.case=a,a="value"),t.kind){case"scalar":case"enum":const o=t.kind=="enum"?E.INT32:t.T;let c=Ir;if(t.kind=="scalar"&&t.L>0&&(c=_y),s){let h=n[a];if(i==ve.LengthDelimited&&o!=E.STRING&&o!=E.BYTES){let p=e.uint32()+e.pos;for(;e.pos<p;)h.push(c(e,o))}else h.push(c(e,o))}else n[a]=c(e,o);break;case"message":const l=t.T;s?n[a].push(Rr(e,new l,r,t)):ln(n[a])?Rr(e,n[a],r,t):(n[a]=Rr(e,new l,r,t),l.fieldWrapper&&!t.oneof&&!t.repeated&&(n[a]=l.fieldWrapper.unwrapField(n[a])));break;case"map":let[u,d]=wy(t,e,r);n[a][u]=d;break}}function Rr(n,e,t,i){const r=e.getType().runtime.bin,s=i==null?void 0:i.delimited;return r.readMessage(e,n,s?i.no:n.uint32(),t,s),e}function wy(n,e,t){const i=e.uint32(),r=e.pos+i;let s,a;for(;e.pos<r;){const[o]=e.tag();switch(o){case 1:s=Ir(e,n.K);break;case 2:switch(n.V.kind){case"scalar":a=Ir(e,n.V.T);break;case"enum":a=e.int32();break;case"message":a=Rr(e,new n.V.T,t,void 0);break}break}}if(s===void 0&&(s=An(n.K,zt.BIGINT)),typeof s!="string"&&typeof s!="number"&&(s=s.toString()),a===void 0)switch(n.V.kind){case"scalar":a=An(n.V.T,zt.BIGINT);break;case"enum":a=n.V.T.values[0].no;break;case"message":a=new n.V.T;break}return[s,a]}function _y(n,e){const t=Ir(n,e);return typeof t=="bigint"?t.toString():t}function Ir(n,e){switch(e){case E.STRING:return n.string();case E.BOOL:return n.bool();case E.DOUBLE:return n.double();case E.FLOAT:return n.float();case E.INT32:return n.int32();case E.INT64:return n.int64();case E.UINT64:return n.uint64();case E.FIXED64:return n.fixed64();case E.BYTES:return n.bytes();case E.FIXED32:return n.fixed32();case E.SFIXED32:return n.sfixed32();case E.SFIXED64:return n.sfixed64();case E.SINT64:return n.sint64();case E.UINT32:return n.uint32();case E.SINT32:return n.sint32()}}function bu(n,e,t,i){he(e!==void 0);const r=n.repeated;switch(n.kind){case"scalar":case"enum":let s=n.kind=="enum"?E.INT32:n.T;if(r)if(he(Array.isArray(e)),n.packed)Py(t,s,n.no,e);else for(const a of e)hi(t,s,n.no,a);else hi(t,s,n.no,e);break;case"message":if(r){he(Array.isArray(e));for(const a of e)yu(t,i,n,a)}else yu(t,i,n,e);break;case"map":he(typeof e=="object"&&e!=null);for(const[a,o]of Object.entries(e))Ey(t,i,n,a,o);break}}function Ey(n,e,t,i,r){n.tag(t.no,ve.LengthDelimited),n.fork();let s=i;switch(t.K){case E.INT32:case E.FIXED32:case E.UINT32:case E.SFIXED32:case E.SINT32:s=Number.parseInt(i);break;case E.BOOL:he(i=="true"||i=="false"),s=i=="true";break}switch(hi(n,t.K,1,s),t.V.kind){case"scalar":hi(n,t.V.T,2,r);break;case"enum":hi(n,E.INT32,2,r);break;case"message":he(r!==void 0),n.tag(2,ve.LengthDelimited).bytes(r.toBinary(e));break}n.join()}function yu(n,e,t,i){const r=uu(t.T,i);t.delimited?n.tag(t.no,ve.StartGroup).raw(r.toBinary(e)).tag(t.no,ve.EndGroup):n.tag(t.no,ve.LengthDelimited).bytes(r.toBinary(e))}function hi(n,e,t,i){he(i!==void 0);let[r,s]=ku(e);n.tag(t,r)[s](i)}function Py(n,e,t,i){if(!i.length)return;n.tag(t,ve.LengthDelimited).fork();let[,r]=ku(e);for(let s=0;s<i.length;s++)n[r](i[s]);n.join()}function ku(n){let e=ve.Varint;switch(n){case E.BYTES:case E.STRING:e=ve.LengthDelimited;break;case E.DOUBLE:case E.FIXED64:case E.SFIXED64:e=ve.Bit64;break;case E.FIXED32:case E.SFIXED32:case E.FLOAT:e=ve.Bit32;break}const t=E[n].toLowerCase();return[e,t]}function Ry(){return{setEnumType:Yl,initPartial(n,e){if(n===void 0)return;const t=e.getType();for(const i of t.fields.byMember()){const r=i.localName,s=e,a=n;if(a[r]!=null)switch(i.kind){case"oneof":const o=a[r].case;if(o===void 0)continue;const c=i.findField(o);let l=a[r].value;c&&c.kind=="message"&&!ln(l,c.T)?l=new c.T(l):c&&c.kind==="scalar"&&c.T===E.BYTES&&(l=fi(l)),s[r]={case:o,value:l};break;case"scalar":case"enum":let u=a[r];i.T===E.BYTES&&(u=i.repeated?u.map(fi):fi(u)),s[r]=u;break;case"map":switch(i.V.kind){case"scalar":case"enum":if(i.V.T===E.BYTES)for(const[f,p]of Object.entries(a[r]))s[r][f]=fi(p);else Object.assign(s[r],a[r]);break;case"message":const h=i.V.T;for(const f of Object.keys(a[r])){let p=a[r][f];h.fieldWrapper||(p=new h(p)),s[r][f]=p}break}break;case"message":const d=i.T;if(i.repeated)s[r]=a[r].map(h=>ln(h,d)?h:new d(h));else{const h=a[r];d.fieldWrapper?d.typeName==="google.protobuf.BytesValue"?s[r]=fi(h):s[r]=h:s[r]=ln(h,d)?h:new d(h)}break}}},equals(n,e,t){return e===t?!0:!e||!t?!1:n.fields.byMember().every(i=>{const r=e[i.localName],s=t[i.localName];if(i.repeated){if(r.length!==s.length)return!1;switch(i.kind){case"message":return r.every((a,o)=>i.T.equals(a,s[o]));case"scalar":return r.every((a,o)=>Ht(i.T,a,s[o]));case"enum":return r.every((a,o)=>Ht(E.INT32,a,s[o]))}throw new Error("repeated cannot contain ".concat(i.kind))}switch(i.kind){case"message":return i.T.equals(r,s);case"enum":return Ht(E.INT32,r,s);case"scalar":return Ht(i.T,r,s);case"oneof":if(r.case!==s.case)return!1;const a=i.findField(r.case);if(a===void 0)return!0;switch(a.kind){case"message":return a.T.equals(r.value,s.value);case"enum":return Ht(E.INT32,r.value,s.value);case"scalar":return Ht(a.T,r.value,s.value)}throw new Error("oneof cannot contain ".concat(a.kind));case"map":const o=Object.keys(r).concat(Object.keys(s));switch(i.V.kind){case"message":const c=i.V.T;return o.every(u=>c.equals(r[u],s[u]));case"enum":return o.every(u=>Ht(E.INT32,r[u],s[u]));case"scalar":const l=i.V.T;return o.every(u=>Ht(l,r[u],s[u]))}break}})},clone(n){const e=n.getType(),t=new e,i=t;for(const r of e.fields.byMember()){const s=n[r.localName];let a;if(r.repeated)a=s.map(Or);else if(r.kind=="map"){a=i[r.localName];for(const[o,c]of Object.entries(s))a[o]=Or(c)}else r.kind=="oneof"?a=r.findField(s.case)?{case:s.case,value:Or(s.value)}:{case:void 0}:a=Or(s);i[r.localName]=a}for(const r of e.runtime.bin.listUnknownFields(n))e.runtime.bin.onUnknownField(i,r.no,r.wireType,r.data);return t}}}function Or(n){if(n===void 0)return n;if(ln(n))return n.clone();if(n instanceof Uint8Array){const e=new Uint8Array(n.byteLength);return e.set(n),e}return n}function fi(n){return n instanceof Uint8Array?n:new Uint8Array(n)}function Iy(n,e,t){return{syntax:n,json:yy(),bin:xy(),util:Object.assign(Object.assign({},Ry()),{newFieldList:e,initFields:t}),makeMessageType(i,r,s){return ry(this,i,r,s)},makeEnum:iy,makeEnumType:Xl,getEnumType:ny,makeExtension(i,r,s){return hy(this,i,r,s)}}}class Oy{constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){const t={};for(const i of this.list())t[i.jsonName]=t[i.name]=i;this.jsonNames=t}return this.jsonNames[e]}find(e){if(!this.numbers){const t={};for(const i of this.list())t[i.no]=i;this.numbers=t}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 i of this.list())i.oneof?i.oneof!==t&&(t=i.oneof,e.push(t)):e.push(i)}return this.members}}function Tu(n,e){const t=Su(n);return e?t:Uy(Dy(t))}function Ay(n){return Tu(n,!1)}const Ny=Su;function Su(n){let e=!1;const t=[];for(let i=0;i<n.length;i++){let r=n.charAt(i);switch(r){case"_":e=!0;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":t.push(r),e=!1;break;default:e&&(e=!1,r=r.toUpperCase()),t.push(r);break}}return t.join("")}const My=new Set(["constructor","toString","toJSON","valueOf"]),Ly=new Set(["getType","clone","equals","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","toObject"]),Cu=n=>"".concat(n,"$"),Dy=n=>Ly.has(n)?Cu(n):n,Uy=n=>My.has(n)?Cu(n):n;class By{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=Ay(e)}addField(e){he(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 t=0;t<this.fields.length;t++)this._lookup[this.fields[t].localName]=this.fields[t]}return this._lookup[e]}}function Fy(n,e){var t,i,r,s,a,o;const c=[];let l;for(const u of typeof n=="function"?n():n){const d=u;if(d.localName=Tu(u.name,u.oneof!==void 0),d.jsonName=(t=u.jsonName)!==null&&t!==void 0?t:Ny(u.name),d.repeated=(i=u.repeated)!==null&&i!==void 0?i:!1,u.kind=="scalar"&&(d.L=(r=u.L)!==null&&r!==void 0?r:zt.BIGINT),d.delimited=(s=u.delimited)!==null&&s!==void 0?s:!1,d.req=(a=u.req)!==null&&a!==void 0?a:!1,d.opt=(o=u.opt)!==null&&o!==void 0?o:!1,u.packed===void 0&&(d.packed=u.kind=="enum"||u.kind=="scalar"&&u.T!=E.BYTES&&u.T!=E.STRING),u.oneof!==void 0){const h=typeof u.oneof=="string"?u.oneof:u.oneof.name;(!l||l.name!=h)&&(l=new By(h)),d.oneof=l,l.addField(d)}c.push(d)}return c}const w=Iy("proto3",n=>new Oy(n,e=>Fy(e)),n=>{for(const e of n.getType().fields.byMember()){if(e.opt)continue;const t=e.localName,i=n;if(e.repeated){i[t]=[];continue}switch(e.kind){case"oneof":i[t]={case:void 0};break;case"enum":i[t]=0;break;case"map":i[t]={};break;case"scalar":i[t]=An(e.T,e.L);break}}});class je extends ca{constructor(e){super(),this.seconds=le.zero,this.nanos=0,w.util.initPartial(e,this)}fromJson(e,t){if(typeof e!="string")throw new Error("cannot decode google.protobuf.Timestamp from JSON: ".concat(w.json.debug(e)));const i=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(!i)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");const r=Date.parse(i[1]+"-"+i[2]+"-"+i[3]+"T"+i[4]+":"+i[5]+":"+i[6]+(i[8]?i[8]:"Z"));if(Number.isNaN(r))throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");if(r<Date.parse("0001-01-01T00:00:00Z")||r>Date.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=le.parse(r/1e3),this.nanos=0,i[7]&&(this.nanos=parseInt("1"+i[7]+"0".repeat(9-i[7].length))-1e9),this}toJson(e){const t=Number(this.seconds)*1e3;if(t<Date.parse("0001-01-01T00:00:00Z")||t>Date.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 i="Z";if(this.nanos>0){const r=(this.nanos+1e9).toString().substring(1);r.substring(3)==="000000"?i="."+r.substring(0,3)+"Z":r.substring(6)==="000"?i="."+r.substring(0,6)+"Z":i="."+r+"Z"}return new Date(t).toISOString().replace(".000Z",i)}toDate(){return new Date(Number(this.seconds)*1e3+Math.ceil(this.nanos/1e6))}static now(){return je.fromDate(new Date)}static fromDate(e){const t=e.getTime();return new je({seconds:le.parse(Math.floor(t/1e3)),nanos:t%1e3*1e6})}static fromBinary(e,t){return new je().fromBinary(e,t)}static fromJson(e,t){return new je().fromJson(e,t)}static fromJsonString(e,t){return new je().fromJsonString(e,t)}static equals(e,t){return w.util.equals(je,e,t)}}je.runtime=w,je.typeName="google.protobuf.Timestamp",je.fields=w.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);const jy=w.makeMessageType("livekit.MetricsBatch",()=>[{no:1,name:"timestamp_ms",kind:"scalar",T:3},{no:2,name:"normalized_timestamp",kind:"message",T:je},{no:3,name:"str_data",kind:"scalar",T:9,repeated:!0},{no:4,name:"time_series",kind:"message",T:Vy,repeated:!0},{no:5,name:"events",kind:"message",T:Wy,repeated:!0}]),Vy=w.makeMessageType("livekit.TimeSeriesMetric",()=>[{no:1,name:"label",kind:"scalar",T:13},{no:2,name:"participant_identity",kind:"scalar",T:13},{no:3,name:"track_sid",kind:"scalar",T:13},{no:4,name:"samples",kind:"message",T:Gy,repeated:!0},{no:5,name:"rid",kind:"scalar",T:13}]),Gy=w.makeMessageType("livekit.MetricSample",()=>[{no:1,name:"timestamp_ms",kind:"scalar",T:3},{no:2,name:"normalized_timestamp",kind:"message",T:je},{no:3,name:"value",kind:"scalar",T:2}]),Wy=w.makeMessageType("livekit.EventMetric",()=>[{no:1,name:"label",kind:"scalar",T:13},{no:2,name:"participant_identity",kind:"scalar",T:13},{no:3,name:"track_sid",kind:"scalar",T:13},{no:4,name:"start_timestamp_ms",kind:"scalar",T:3},{no:5,name:"end_timestamp_ms",kind:"scalar",T:3,opt:!0},{no:6,name:"normalized_start_timestamp",kind:"message",T:je},{no:7,name:"normalized_end_timestamp",kind:"message",T:je,opt:!0},{no:8,name:"metadata",kind:"scalar",T:9},{no:9,name:"rid",kind:"scalar",T:13}]),xu=w.makeEnum("livekit.BackupCodecPolicy",[{no:0,name:"PREFER_REGRESSION"},{no:1,name:"SIMULCAST"},{no:2,name:"REGRESSION"}]),it=w.makeEnum("livekit.TrackType",[{no:0,name:"AUDIO"},{no:1,name:"VIDEO"},{no:2,name:"DATA"}]),ke=w.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"}]),Mn=w.makeEnum("livekit.VideoQuality",[{no:0,name:"LOW"},{no:1,name:"MEDIUM"},{no:2,name:"HIGH"},{no:3,name:"OFF"}]),pi=w.makeEnum("livekit.ConnectionQuality",[{no:0,name:"POOR"},{no:1,name:"GOOD"},{no:2,name:"EXCELLENT"},{no:3,name:"LOST"}]),mi=w.makeEnum("livekit.ClientConfigSetting",[{no:0,name:"UNSET"},{no:1,name:"DISABLED"},{no:2,name:"ENABLED"}]),rt=w.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"},{no:10,name:"ROOM_CLOSED"},{no:11,name:"USER_UNAVAILABLE"},{no:12,name:"USER_REJECTED"},{no:13,name:"SIP_TRUNK_FAILURE"},{no:14,name:"CONNECTION_TIMEOUT"}]),Ln=w.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"}]),zy=w.makeEnum("livekit.SubscriptionError",[{no:0,name:"SE_UNKNOWN"},{no:1,name:"SE_CODEC_UNSUPPORTED"},{no:2,name:"SE_TRACK_NOTFOUND"}]),st=w.makeEnum("livekit.AudioTrackFeature",[{no:0,name:"TF_STEREO"},{no:1,name:"TF_NO_DTX"},{no:2,name:"TF_AUTO_GAIN_CONTROL"},{no:3,name:"TF_ECHO_CANCELLATION"},{no:4,name:"TF_NOISE_SUPPRESSION"},{no:5,name:"TF_ENHANCED_NOISE_CANCELLATION"},{no:6,name:"TF_PRECONNECT_BUFFER"}]),Ar=w.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:15,name:"creation_time_ms",kind:"scalar",T:3},{no:6,name:"turn_password",kind:"scalar",T:9},{no:7,name:"enabled_codecs",kind:"message",T:Nr,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:Uu}]),Nr=w.makeMessageType("livekit.Codec",()=>[{no:1,name:"mime",kind:"scalar",T:9},{no:2,name:"fmtp_line",kind:"scalar",T:9}]),Hy=w.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:w.getEnumType(ke),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},{no:12,name:"can_subscribe_metrics",kind:"scalar",T:8}]),un=w.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:w.getEnumType(Dn)},{no:4,name:"tracks",kind:"message",T:Un,repeated:!0},{no:5,name:"metadata",kind:"scalar",T:9},{no:6,name:"joined_at",kind:"scalar",T:3},{no:17,name:"joined_at_ms",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:Hy},{no:12,name:"region",kind:"scalar",T:9},{no:13,name:"is_publisher",kind:"scalar",T:8},{no:14,name:"kind",kind:"enum",T:w.getEnumType(Mr)},{no:15,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:16,name:"disconnect_reason",kind:"enum",T:w.getEnumType(rt)},{no:18,name:"kind_details",kind:"enum",T:w.getEnumType(qy),repeated:!0}]),Dn=w.makeEnum("livekit.ParticipantInfo.State",[{no:0,name:"JOINING"},{no:1,name:"JOINED"},{no:2,name:"ACTIVE"},{no:3,name:"DISCONNECTED"}]),Mr=w.makeEnum("livekit.ParticipantInfo.Kind",[{no:0,name:"STANDARD"},{no:1,name:"INGRESS"},{no:2,name:"EGRESS"},{no:3,name:"SIP"},{no:4,name:"AGENT"}]),qy=w.makeEnum("livekit.ParticipantInfo.KindDetail",[{no:0,name:"CLOUD_AGENT"},{no:1,name:"FORWARDED"}]),$e=w.makeEnum("livekit.Encryption.Type",[{no:0,name:"NONE"},{no:1,name:"GCM"},{no:2,name:"CUSTOM"}]),Ky=w.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:dn,repeated:!0}]),Un=w.makeMessageType("livekit.TrackInfo",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"type",kind:"enum",T:w.getEnumType(it)},{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:w.getEnumType(ke)},{no:10,name:"layers",kind:"message",T:dn,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:Ky,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:w.getEnumType($e)},{no:17,name:"stream",kind:"scalar",T:9},{no:18,name:"version",kind:"message",T:Uu},{no:19,name:"audio_features",kind:"enum",T:w.getEnumType(st),repeated:!0},{no:20,name:"backup_codec_policy",kind:"enum",T:w.getEnumType(xu)}]),dn=w.makeMessageType("livekit.VideoLayer",()=>[{no:1,name:"quality",kind:"enum",T:w.getEnumType(Mn)},{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}]),Ve=w.makeMessageType("livekit.DataPacket",()=>[{no:1,name:"kind",kind:"enum",T:w.getEnumType(X)},{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:_u,oneof:"value"},{no:3,name:"speaker",kind:"message",T:$y,oneof:"value"},{no:6,name:"sip_dtmf",kind:"message",T:Eu,oneof:"value"},{no:7,name:"transcription",kind:"message",T:Yy,oneof:"value"},{no:8,name:"metrics",kind:"message",T:jy,oneof:"value"},{no:9,name:"chat_message",kind:"message",T:fa,oneof:"value"},{no:10,name:"rpc_request",kind:"message",T:Pu,oneof:"value"},{no:11,name:"rpc_ack",kind:"message",T:Ru,oneof:"value"},{no:12,name:"rpc_response",kind:"message",T:Iu,oneof:"value"},{no:13,name:"stream_header",kind:"message",T:ma,oneof:"value"},{no:14,name:"stream_chunk",kind:"message",T:ga,oneof:"value"},{no:15,name:"stream_trailer",kind:"message",T:va,oneof:"value"}]),X=w.makeEnum("livekit.DataPacket.Kind",[{no:0,name:"RELIABLE"},{no:1,name:"LOSSY"}]),$y=w.makeMessageType("livekit.ActiveSpeakerUpdate",()=>[{no:1,name:"speakers",kind:"message",T:wu,repeated:!0}]),wu=w.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}]),_u=w.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},{no:8,name:"id",kind:"scalar",T:9,opt:!0},{no:9,name:"start_time",kind:"scalar",T:4,opt:!0},{no:10,name:"end_time",kind:"scalar",T:4,opt:!0},{no:11,name:"nonce",kind:"scalar",T:12}]),Eu=w.makeMessageType("livekit.SipDTMF",()=>[{no:3,name:"code",kind:"scalar",T:13},{no:4,name:"digit",kind:"scalar",T:9}]),Yy=w.makeMessageType("livekit.Transcription",()=>[{no:2,name:"transcribed_participant_identity",kind:"scalar",T:9},{no:3,name:"track_id",kind:"scalar",T:9},{no:4,name:"segments",kind:"message",T:Xy,repeated:!0}]),Xy=w.makeMessageType("livekit.TranscriptionSegment",()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"text",kind:"scalar",T:9},{no:3,name:"start_time",kind:"scalar",T:4},{no:4,name:"end_time",kind:"scalar",T:4},{no:5,name:"final",kind:"scalar",T:8},{no:6,name:"language",kind:"scalar",T:9}]),fa=w.makeMessageType("livekit.ChatMessage",()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"timestamp",kind:"scalar",T:3},{no:3,name:"edit_timestamp",kind:"scalar",T:3,opt:!0},{no:4,name:"message",kind:"scalar",T:9},{no:5,name:"deleted",kind:"scalar",T:8},{no:6,name:"generated",kind:"scalar",T:8}]),Pu=w.makeMessageType("livekit.RpcRequest",()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"method",kind:"scalar",T:9},{no:3,name:"payload",kind:"scalar",T:9},{no:4,name:"response_timeout_ms",kind:"scalar",T:13},{no:5,name:"version",kind:"scalar",T:13}]),Ru=w.makeMessageType("livekit.RpcAck",()=>[{no:1,name:"request_id",kind:"scalar",T:9}]),Iu=w.makeMessageType("livekit.RpcResponse",()=>[{no:1,name:"request_id",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:9,oneof:"value"},{no:3,name:"error",kind:"message",T:Ou,oneof:"value"}]),Ou=w.makeMessageType("livekit.RpcError",()=>[{no:1,name:"code",kind:"scalar",T:13},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"data",kind:"scalar",T:9}]),Au=w.makeMessageType("livekit.ParticipantTracks",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"track_sids",kind:"scalar",T:9,repeated:!0}]),Jy=w.makeMessageType("livekit.ServerInfo",()=>[{no:1,name:"edition",kind:"enum",T:w.getEnumType(Nu)},{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},{no:7,name:"agent_protocol",kind:"scalar",T:5}]),Nu=w.makeEnum("livekit.ServerInfo.Edition",[{no:0,name:"Standard"},{no:1,name:"Cloud"}]),Qy=w.makeMessageType("livekit.ClientInfo",()=>[{no:1,name:"sdk",kind:"enum",T:w.getEnumType(Mu)},{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},{no:11,name:"other_sdks",kind:"scalar",T:9}]),Mu=w.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"},{no:11,name:"UNITY_WEB"},{no:12,name:"NODE"},{no:13,name:"UNREAL"}]),Lu=w.makeMessageType("livekit.ClientConfiguration",()=>[{no:1,name:"video",kind:"message",T:Du},{no:2,name:"screen",kind:"message",T:Du},{no:3,name:"resume_connection",kind:"enum",T:w.getEnumType(mi)},{no:4,name:"disabled_codecs",kind:"message",T:Zy},{no:5,name:"force_relay",kind:"enum",T:w.getEnumType(mi)}]),Du=w.makeMessageType("livekit.VideoConfiguration",()=>[{no:1,name:"hardware_encoder",kind:"enum",T:w.getEnumType(mi)}]),Zy=w.makeMessageType("livekit.DisabledCodecs",()=>[{no:1,name:"codecs",kind:"message",T:Nr,repeated:!0},{no:2,name:"publish",kind:"message",T:Nr,repeated:!0}]),Uu=w.makeMessageType("livekit.TimedVersion",()=>[{no:1,name:"unix_micro",kind:"scalar",T:3},{no:2,name:"ticks",kind:"scalar",T:5}]),pa=w.makeEnum("livekit.DataStream.OperationType",[{no:0,name:"CREATE"},{no:1,name:"UPDATE"},{no:2,name:"DELETE"},{no:3,name:"REACTION"}]),Bu=w.makeMessageType("livekit.DataStream.TextHeader",()=>[{no:1,name:"operation_type",kind:"enum",T:w.getEnumType(pa)},{no:2,name:"version",kind:"scalar",T:5},{no:3,name:"reply_to_stream_id",kind:"scalar",T:9},{no:4,name:"attached_stream_ids",kind:"scalar",T:9,repeated:!0},{no:5,name:"generated",kind:"scalar",T:8}],{localName:"DataStream_TextHeader"}),Fu=w.makeMessageType("livekit.DataStream.ByteHeader",()=>[{no:1,name:"name",kind:"scalar",T:9}],{localName:"DataStream_ByteHeader"}),ma=w.makeMessageType("livekit.DataStream.Header",()=>[{no:1,name:"stream_id",kind:"scalar",T:9},{no:2,name:"timestamp",kind:"scalar",T:3},{no:3,name:"topic",kind:"scalar",T:9},{no:4,name:"mime_type",kind:"scalar",T:9},{no:5,name:"total_length",kind:"scalar",T:4,opt:!0},{no:7,name:"encryption_type",kind:"enum",T:w.getEnumType($e)},{no:8,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:9,name:"text_header",kind:"message",T:Bu,oneof:"content_header"},{no:10,name:"byte_header",kind:"message",T:Fu,oneof:"content_header"}],{localName:"DataStream_Header"}),ga=w.makeMessageType("livekit.DataStream.Chunk",()=>[{no:1,name:"stream_id",kind:"scalar",T:9},{no:2,name:"chunk_index",kind:"scalar",T:4},{no:3,name:"content",kind:"scalar",T:12},{no:4,name:"version",kind:"scalar",T:5},{no:5,name:"iv",kind:"scalar",T:12,opt:!0}],{localName:"DataStream_Chunk"}),va=w.makeMessageType("livekit.DataStream.Trailer",()=>[{no:1,name:"stream_id",kind:"scalar",T:9},{no:2,name:"reason",kind:"scalar",T:9},{no:3,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}}],{localName:"DataStream_Trailer"}),at=w.makeEnum("livekit.SignalTarget",[{no:0,name:"PUBLISHER"},{no:1,name:"SUBSCRIBER"}]),ba=w.makeEnum("livekit.StreamState",[{no:0,name:"ACTIVE"},{no:1,name:"PAUSED"}]),ek=w.makeEnum("livekit.CandidateProtocol",[{no:0,name:"UDP"},{no:1,name:"TCP"},{no:2,name:"TLS"}]),tk=w.makeMessageType("livekit.SignalRequest",()=>[{no:1,name:"offer",kind:"message",T:hn,oneof:"message"},{no:2,name:"answer",kind:"message",T:hn,oneof:"message"},{no:3,name:"trickle",kind:"message",T:Ta,oneof:"message"},{no:4,name:"add_track",kind:"message",T:ka,oneof:"message"},{no:5,name:"mute",kind:"message",T:Sa,oneof:"message"},{no:6,name:"subscription",kind:"message",T:Lr,oneof:"message"},{no:7,name:"track_setting",kind:"message",T:Vu,oneof:"message"},{no:8,name:"leave",kind:"message",T:Dr,oneof:"message"},{no:10,name:"update_layers",kind:"message",T:Wu,oneof:"message"},{no:11,name:"subscription_permission",kind:"message",T:Ku,oneof:"message"},{no:12,name:"sync_state",kind:"message",T:$u,oneof:"message"},{no:13,name:"simulate",kind:"message",T:kt,oneof:"message"},{no:14,name:"ping",kind:"scalar",T:3,oneof:"message"},{no:15,name:"update_metadata",kind:"message",T:zu,oneof:"message"},{no:16,name:"ping_req",kind:"message",T:Xu,oneof:"message"},{no:17,name:"update_audio_track",kind:"message",T:Gu,oneof:"message"},{no:18,name:"update_video_track",kind:"message",T:ak,oneof:"message"}]),ju=w.makeMessageType("livekit.SignalResponse",()=>[{no:1,name:"join",kind:"message",T:nk,oneof:"message"},{no:2,name:"answer",kind:"message",T:hn,oneof:"message"},{no:3,name:"offer",kind:"message",T:hn,oneof:"message"},{no:4,name:"trickle",kind:"message",T:Ta,oneof:"message"},{no:5,name:"update",kind:"message",T:sk,oneof:"message"},{no:6,name:"track_published",kind:"message",T:Ca,oneof:"message"},{no:8,name:"leave",kind:"message",T:Dr,oneof:"message"},{no:9,name:"mute",kind:"message",T:Sa,oneof:"message"},{no:10,name:"speakers_changed",kind:"message",T:ok,oneof:"message"},{no:11,name:"room_update",kind:"message",T:ck,oneof:"message"},{no:12,name:"connection_quality",kind:"message",T:uk,oneof:"message"},{no:13,name:"stream_state_update",kind:"message",T:hk,oneof:"message"},{no:14,name:"subscribed_quality_update",kind:"message",T:pk,oneof:"message"},{no:15,name:"subscription_permission_update",kind:"message",T:mk,oneof:"message"},{no:16,name:"refresh_token",kind:"scalar",T:9,oneof:"message"},{no:17,name:"track_unpublished",kind:"message",T:rk,oneof:"message"},{no:18,name:"pong",kind:"scalar",T:3,oneof:"message"},{no:19,name:"reconnect",kind:"message",T:ik,oneof:"message"},{no:20,name:"pong_resp",kind:"message",T:vk,oneof:"message"},{no:21,name:"subscription_response",kind:"message",T:kk,oneof:"message"},{no:22,name:"request_response",kind:"message",T:Tk,oneof:"message"},{no:23,name:"track_subscribed",kind:"message",T:Sk,oneof:"message"},{no:24,name:"room_moved",kind:"message",T:gk,oneof:"message"}]),ya=w.makeMessageType("livekit.SimulcastCodec",()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"cid",kind:"scalar",T:9}]),ka=w.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:w.getEnumType(it)},{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:w.getEnumType(ke)},{no:9,name:"layers",kind:"message",T:dn,repeated:!0},{no:10,name:"simulcast_codecs",kind:"message",T:ya,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:w.getEnumType($e)},{no:15,name:"stream",kind:"scalar",T:9},{no:16,name:"backup_codec_policy",kind:"enum",T:w.getEnumType(xu)},{no:17,name:"audio_features",kind:"enum",T:w.getEnumType(st),repeated:!0}]),Ta=w.makeMessageType("livekit.TrickleRequest",()=>[{no:1,name:"candidateInit",kind:"scalar",T:9},{no:2,name:"target",kind:"enum",T:w.getEnumType(at)},{no:3,name:"final",kind:"scalar",T:8}]),Sa=w.makeMessageType("livekit.MuteTrackRequest",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"muted",kind:"scalar",T:8}]),nk=w.makeMessageType("livekit.JoinResponse",()=>[{no:1,name:"room",kind:"message",T:Ar},{no:2,name:"participant",kind:"message",T:un},{no:3,name:"other_participants",kind:"message",T:un,repeated:!0},{no:4,name:"server_version",kind:"scalar",T:9},{no:5,name:"ice_servers",kind:"message",T:Hu,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:Lu},{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:Jy},{no:13,name:"sif_trailer",kind:"scalar",T:12},{no:14,name:"enabled_publish_codecs",kind:"message",T:Nr,repeated:!0},{no:15,name:"fast_publish",kind:"scalar",T:8}]),ik=w.makeMessageType("livekit.ReconnectResponse",()=>[{no:1,name:"ice_servers",kind:"message",T:Hu,repeated:!0},{no:2,name:"client_configuration",kind:"message",T:Lu}]),Ca=w.makeMessageType("livekit.TrackPublishedResponse",()=>[{no:1,name:"cid",kind:"scalar",T:9},{no:2,name:"track",kind:"message",T:Un}]),rk=w.makeMessageType("livekit.TrackUnpublishedResponse",()=>[{no:1,name:"track_sid",kind:"scalar",T:9}]),hn=w.makeMessageType("livekit.SessionDescription",()=>[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"sdp",kind:"scalar",T:9}]),sk=w.makeMessageType("livekit.ParticipantUpdate",()=>[{no:1,name:"participants",kind:"message",T:un,repeated:!0}]),Lr=w.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:Au,repeated:!0}]),Vu=w.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:w.getEnumType(Mn)},{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}]),Gu=w.makeMessageType("livekit.UpdateLocalAudioTrack",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"features",kind:"enum",T:w.getEnumType(st),repeated:!0}]),ak=w.makeMessageType("livekit.UpdateLocalVideoTrack",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"width",kind:"scalar",T:13},{no:3,name:"height",kind:"scalar",T:13}]),Dr=w.makeMessageType("livekit.LeaveRequest",()=>[{no:1,name:"can_reconnect",kind:"scalar",T:8},{no:2,name:"reason",kind:"enum",T:w.getEnumType(rt)},{no:3,name:"action",kind:"enum",T:w.getEnumType(Bn)},{no:4,name:"regions",kind:"message",T:bk}]),Bn=w.makeEnum("livekit.LeaveRequest.Action",[{no:0,name:"DISCONNECT"},{no:1,name:"RESUME"},{no:2,name:"RECONNECT"}]),Wu=w.makeMessageType("livekit.UpdateVideoLayers",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"layers",kind:"message",T:dn,repeated:!0}]),zu=w.makeMessageType("livekit.UpdateParticipantMetadata",()=>[{no:1,name:"metadata",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:4,name:"request_id",kind:"scalar",T:13}]),Hu=w.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}]),ok=w.makeMessageType("livekit.SpeakersChanged",()=>[{no:1,name:"speakers",kind:"message",T:wu,repeated:!0}]),ck=w.makeMessageType("livekit.RoomUpdate",()=>[{no:1,name:"room",kind:"message",T:Ar}]),lk=w.makeMessageType("livekit.ConnectionQualityInfo",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"quality",kind:"enum",T:w.getEnumType(pi)},{no:3,name:"score",kind:"scalar",T:2}]),uk=w.makeMessageType("livekit.ConnectionQualityUpdate",()=>[{no:1,name:"updates",kind:"message",T:lk,repeated:!0}]),dk=w.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:w.getEnumType(ba)}]),hk=w.makeMessageType("livekit.StreamStateUpdate",()=>[{no:1,name:"stream_states",kind:"message",T:dk,repeated:!0}]),xa=w.makeMessageType("livekit.SubscribedQuality",()=>[{no:1,name:"quality",kind:"enum",T:w.getEnumType(Mn)},{no:2,name:"enabled",kind:"scalar",T:8}]),fk=w.makeMessageType("livekit.SubscribedCodec",()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"qualities",kind:"message",T:xa,repeated:!0}]),pk=w.makeMessageType("livekit.SubscribedQualityUpdate",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"subscribed_qualities",kind:"message",T:xa,repeated:!0},{no:3,name:"subscribed_codecs",kind:"message",T:fk,repeated:!0}]),qu=w.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}]),Ku=w.makeMessageType("livekit.SubscriptionPermission",()=>[{no:1,name:"all_participants",kind:"scalar",T:8},{no:2,name:"track_permissions",kind:"message",T:qu,repeated:!0}]),mk=w.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}]),gk=w.makeMessageType("livekit.RoomMovedResponse",()=>[{no:1,name:"room",kind:"message",T:Ar},{no:2,name:"token",kind:"scalar",T:9},{no:3,name:"participant",kind:"message",T:un},{no:4,name:"other_participants",kind:"message",T:un,repeated:!0}]),$u=w.makeMessageType("livekit.SyncState",()=>[{no:1,name:"answer",kind:"message",T:hn},{no:2,name:"subscription",kind:"message",T:Lr},{no:3,name:"publish_tracks",kind:"message",T:Ca,repeated:!0},{no:4,name:"data_channels",kind:"message",T:Yu,repeated:!0},{no:5,name:"offer",kind:"message",T:hn},{no:6,name:"track_sids_disabled",kind:"scalar",T:9,repeated:!0}]),Yu=w.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:w.getEnumType(at)}]),kt=w.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:w.getEnumType(ek),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"},{no:9,name:"leave_request_full_reconnect",kind:"scalar",T:8,oneof:"scenario"}]),Xu=w.makeMessageType("livekit.Ping",()=>[{no:1,name:"timestamp",kind:"scalar",T:3},{no:2,name:"rtt",kind:"scalar",T:3}]),vk=w.makeMessageType("livekit.Pong",()=>[{no:1,name:"last_ping_timestamp",kind:"scalar",T:3},{no:2,name:"timestamp",kind:"scalar",T:3}]),bk=w.makeMessageType("livekit.RegionSettings",()=>[{no:1,name:"regions",kind:"message",T:yk,repeated:!0}]),yk=w.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}]),kk=w.makeMessageType("livekit.SubscriptionResponse",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"err",kind:"enum",T:w.getEnumType(zy)}]),Tk=w.makeMessageType("livekit.RequestResponse",()=>[{no:1,name:"request_id",kind:"scalar",T:13},{no:2,name:"reason",kind:"enum",T:w.getEnumType(wa)},{no:3,name:"message",kind:"scalar",T:9}]),wa=w.makeEnum("livekit.RequestResponse.Reason",[{no:0,name:"OK"},{no:1,name:"NOT_FOUND"},{no:2,name:"NOT_ALLOWED"},{no:3,name:"LIMIT_EXCEEDED"}]),Sk=w.makeMessageType("livekit.TrackSubscribed",()=>[{no:1,name:"track_sid",kind:"scalar",T:9}]);function Ck(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Ur={exports:{}},xk=Ur.exports,Ju;function wk(){return Ju||(Ju=1,function(n){(function(e,t){n.exports?n.exports=t():e.log=t()})(xk,function(){var e=function(){},t="undefined",i=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),r=["trace","debug","info","warn","error"],s={},a=null;function o(g,v){var b=g[v];if(typeof b.bind=="function")return b.bind(g);try{return Function.prototype.bind.call(b,g)}catch{return function(){return Function.prototype.apply.apply(b,[g,arguments])}}}function c(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function l(g){return g==="debug"&&(g="log"),typeof console===t?!1:g==="trace"&&i?c:console[g]!==void 0?o(console,g):console.log!==void 0?o(console,"log"):e}function u(){for(var g=this.getLevel(),v=0;v<r.length;v++){var b=r[v];this[b]=v<g?e:this.methodFactory(b,g,this.name)}if(this.log=this.debug,typeof console===t&&g<this.levels.SILENT)return"No console available for logging"}function d(g){return function(){typeof console!==t&&(u.call(this),this[g].apply(this,arguments))}}function h(g,v,b){return l(g)||d.apply(this,arguments)}function f(g,v){var b=this,S,x,k,T="loglevel";typeof g=="string"?T+=":"+g:typeof g=="symbol"&&(T=void 0);function C(U){var V=(r[U]||"silent").toUpperCase();if(!(typeof window===t||!T)){try{window.localStorage[T]=V;return}catch{}try{window.document.cookie=encodeURIComponent(T)+"="+V+";"}catch{}}}function _(){var U;if(!(typeof window===t||!T)){try{U=window.localStorage[T]}catch{}if(typeof U===t)try{var V=window.document.cookie,G=encodeURIComponent(T),z=V.indexOf(G+"=");z!==-1&&(U=/^([^;]+)/.exec(V.slice(z+G.length+1))[1])}catch{}return b.levels[U]===void 0&&(U=void 0),U}}function R(){if(!(typeof window===t||!T)){try{window.localStorage.removeItem(T)}catch{}try{window.document.cookie=encodeURIComponent(T)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function I(U){var V=U;if(typeof V=="string"&&b.levels[V.toUpperCase()]!==void 0&&(V=b.levels[V.toUpperCase()]),typeof V=="number"&&V>=0&&V<=b.levels.SILENT)return V;throw new TypeError("log.setLevel() called with invalid level: "+U)}b.name=g,b.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},b.methodFactory=v||h,b.getLevel=function(){return k??x??S},b.setLevel=function(U,V){return k=I(U),V!==!1&&C(k),u.call(b)},b.setDefaultLevel=function(U){x=I(U),_()||b.setLevel(U,!1)},b.resetLevel=function(){k=null,R(),u.call(b)},b.enableAll=function(U){b.setLevel(b.levels.TRACE,U)},b.disableAll=function(U){b.setLevel(b.levels.SILENT,U)},b.rebuild=function(){if(a!==b&&(S=I(a.getLevel())),u.call(b),a===b)for(var U in s)s[U].rebuild()},S=I(a?a.getLevel():"WARN");var D=_();D!=null&&(k=I(D)),u.call(b)}a=new f,a.getLogger=function(v){if(typeof v!="symbol"&&typeof v!="string"||v==="")throw new TypeError("You must supply a name when creating a logger.");var b=s[v];return b||(b=s[v]=new f(v,a.methodFactory)),b};var p=typeof window!==t?window.log:void 0;return a.noConflict=function(){return typeof window!==t&&window.log===a&&(window.log=p),a},a.getLoggers=function(){return s},a.default=a,a})}(Ur)),Ur.exports}var Br=wk(),_a;(function(n){n[n.trace=0]="trace",n[n.debug=1]="debug",n[n.info=2]="info",n[n.warn=3]="warn",n[n.error=4]="error",n[n.silent=5]="silent"})(_a||(_a={}));var ot;(function(n){n.Default="livekit",n.Room="livekit-room",n.Participant="livekit-participant",n.Track="livekit-track",n.Publication="livekit-track-publication",n.Engine="livekit-engine",n.Signal="livekit-signal",n.PCManager="livekit-pc-manager",n.PCTransport="livekit-pc-transport",n.E2EE="lk-e2ee"})(ot||(ot={}));let q=Br.getLogger("livekit");Object.values(ot).map(n=>Br.getLogger(n)),q.setDefaultLevel(_a.info);function Et(n){const e=Br.getLogger(n);return e.setDefaultLevel(q.getLevel()),e}const _k=Br.getLogger("lk-e2ee"),gi=7e3,Ek=[0,300,2*2*300,3*3*300,4*4*300,gi,gi,gi,gi,gi];class Pk{constructor(e){this._retryDelays=e!==void 0?[...e]:Ek}nextRetryDelayInMs(e){if(e.retryCount>=this._retryDelays.length)return null;const t=this._retryDelays[e.retryCount];return e.retryCount<=1?t:t+Math.random()*1e3}}function Rk(n,e){var t={};for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(n);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(n,i[r])&&(t[i[r]]=n[i[r]]);return t}function y(n,e,t,i){function r(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function o(u){try{l(i.next(u))}catch(d){a(d)}}function c(u){try{l(i.throw(u))}catch(d){a(d)}}function l(u){u.done?s(u.value):r(u.value).then(o,c)}l((i=i.apply(n,e||[])).next())})}function Qu(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function qt(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof Qu=="function"?Qu(n):n[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(s){t[s]=n[s]&&function(a){return new Promise(function(o,c){a=n[s](a),r(o,c,a.done,a.value)})}}function r(s,a,o,c){Promise.resolve(c).then(function(l){s({value:l,done:o})},a)}}typeof SuppressedError=="function"&&SuppressedError;var Fr={exports:{}},Zu;function Ik(){if(Zu)return Fr.exports;Zu=1;var n=typeof Reflect=="object"?Reflect:null,e=n&&typeof n.apply=="function"?n.apply:function(T,C,_){return Function.prototype.apply.call(T,C,_)},t;n&&typeof n.ownKeys=="function"?t=n.ownKeys:Object.getOwnPropertySymbols?t=function(T){return Object.getOwnPropertyNames(T).concat(Object.getOwnPropertySymbols(T))}:t=function(T){return Object.getOwnPropertyNames(T)};function i(k){console&&console.warn&&console.warn(k)}var r=Number.isNaN||function(T){return T!==T};function s(){s.init.call(this)}Fr.exports=s,Fr.exports.once=b,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var a=10;function o(k){if(typeof k!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof k)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(k){if(typeof k!="number"||k<0||r(k))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+k+".");a=k}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(T){if(typeof T!="number"||T<0||r(T))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+T+".");return this._maxListeners=T,this};function c(k){return k._maxListeners===void 0?s.defaultMaxListeners:k._maxListeners}s.prototype.getMaxListeners=function(){return c(this)},s.prototype.emit=function(T){for(var C=[],_=1;_<arguments.length;_++)C.push(arguments[_]);var R=T==="error",I=this._events;if(I!==void 0)R=R&&I.error===void 0;else if(!R)return!1;if(R){var D;if(C.length>0&&(D=C[0]),D instanceof Error)throw D;var U=new Error("Unhandled error."+(D?" ("+D.message+")":""));throw U.context=D,U}var V=I[T];if(V===void 0)return!1;if(typeof V=="function")e(V,this,C);else for(var G=V.length,z=p(V,G),_=0;_<G;++_)e(z[_],this,C);return!0};function l(k,T,C,_){var R,I,D;if(o(C),I=k._events,I===void 0?(I=k._events=Object.create(null),k._eventsCount=0):(I.newListener!==void 0&&(k.emit("newListener",T,C.listener?C.listener:C),I=k._events),D=I[T]),D===void 0)D=I[T]=C,++k._eventsCount;else if(typeof D=="function"?D=I[T]=_?[C,D]:[D,C]:_?D.unshift(C):D.push(C),R=c(k),R>0&&D.length>R&&!D.warned){D.warned=!0;var U=new Error("Possible EventEmitter memory leak detected. "+D.length+" "+String(T)+" listeners added. Use emitter.setMaxListeners() to increase limit");U.name="MaxListenersExceededWarning",U.emitter=k,U.type=T,U.count=D.length,i(U)}return k}s.prototype.addListener=function(T,C){return l(this,T,C,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(T,C){return l(this,T,C,!0)};function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(k,T,C){var _={fired:!1,wrapFn:void 0,target:k,type:T,listener:C},R=u.bind(_);return R.listener=C,_.wrapFn=R,R}s.prototype.once=function(T,C){return o(C),this.on(T,d(this,T,C)),this},s.prototype.prependOnceListener=function(T,C){return o(C),this.prependListener(T,d(this,T,C)),this},s.prototype.removeListener=function(T,C){var _,R,I,D,U;if(o(C),R=this._events,R===void 0)return this;if(_=R[T],_===void 0)return this;if(_===C||_.listener===C)--this._eventsCount===0?this._events=Object.create(null):(delete R[T],R.removeListener&&this.emit("removeListener",T,_.listener||C));else if(typeof _!="function"){for(I=-1,D=_.length-1;D>=0;D--)if(_[D]===C||_[D].listener===C){U=_[D].listener,I=D;break}if(I<0)return this;I===0?_.shift():g(_,I),_.length===1&&(R[T]=_[0]),R.removeListener!==void 0&&this.emit("removeListener",T,U||C)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(T){var C,_,R;if(_=this._events,_===void 0)return this;if(_.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):_[T]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete _[T]),this;if(arguments.length===0){var I=Object.keys(_),D;for(R=0;R<I.length;++R)D=I[R],D!=="removeListener"&&this.removeAllListeners(D);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(C=_[T],typeof C=="function")this.removeListener(T,C);else if(C!==void 0)for(R=C.length-1;R>=0;R--)this.removeListener(T,C[R]);return this};function h(k,T,C){var _=k._events;if(_===void 0)return[];var R=_[T];return R===void 0?[]:typeof R=="function"?C?[R.listener||R]:[R]:C?v(R):p(R,R.length)}s.prototype.listeners=function(T){return h(this,T,!0)},s.prototype.rawListeners=function(T){return h(this,T,!1)},s.listenerCount=function(k,T){return typeof k.listenerCount=="function"?k.listenerCount(T):f.call(k,T)},s.prototype.listenerCount=f;function f(k){var T=this._events;if(T!==void 0){var C=T[k];if(typeof C=="function")return 1;if(C!==void 0)return C.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function p(k,T){for(var C=new Array(T),_=0;_<T;++_)C[_]=k[_];return C}function g(k,T){for(;T+1<k.length;T++)k[T]=k[T+1];k.pop()}function v(k){for(var T=new Array(k.length),C=0;C<T.length;++C)T[C]=k[C].listener||k[C];return T}function b(k,T){return new Promise(function(C,_){function R(D){k.removeListener(T,I),_(D)}function I(){typeof k.removeListener=="function"&&k.removeListener("error",R),C([].slice.call(arguments))}x(k,T,I,{once:!0}),T!=="error"&&S(k,R,{once:!0})})}function S(k,T,C){typeof k.on=="function"&&x(k,"error",T,C)}function x(k,T,C,_){if(typeof k.on=="function")_.once?k.once(T,C):k.on(T,C);else if(typeof k.addEventListener=="function")k.addEventListener(T,function R(I){_.once&&k.removeEventListener(T,R),C(I)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof k)}return Fr.exports}var Tt=Ik();let ed=!0,td=!0;function jr(n,e,t){const i=n.match(e);return i&&i.length>=t&&parseInt(i[t],10)}function fn(n,e,t){if(!n.RTCPeerConnection)return;const i=n.RTCPeerConnection.prototype,r=i.addEventListener;i.addEventListener=function(a,o){if(a!==e)return r.apply(this,arguments);const c=l=>{const u=t(l);u&&(o.handleEvent?o.handleEvent(u):o(u))};return this._eventMap=this._eventMap||{},this._eventMap[e]||(this._eventMap[e]=new Map),this._eventMap[e].set(o,c),r.apply(this,[a,c])};const s=i.removeEventListener;i.removeEventListener=function(a,o){if(a!==e||!this._eventMap||!this._eventMap[e])return s.apply(this,arguments);if(!this._eventMap[e].has(o))return s.apply(this,arguments);const c=this._eventMap[e].get(o);return this._eventMap[e].delete(o),this._eventMap[e].size===0&&delete this._eventMap[e],Object.keys(this._eventMap).length===0&&delete this._eventMap,s.apply(this,[a,c])},Object.defineProperty(i,"on"+e,{get(){return this["_on"+e]},set(a){this["_on"+e]&&(this.removeEventListener(e,this["_on"+e]),delete this["_on"+e]),a&&this.addEventListener(e,this["_on"+e]=a)},enumerable:!0,configurable:!0})}function Ok(n){return typeof n!="boolean"?new Error("Argument type: "+typeof n+". Please use a boolean."):(ed=n,n?"adapter.js logging disabled":"adapter.js logging enabled")}function Ak(n){return typeof n!="boolean"?new Error("Argument type: "+typeof n+". Please use a boolean."):(td=!n,"adapter.js deprecation warnings "+(n?"disabled":"enabled"))}function nd(){if(typeof window=="object"){if(ed)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function Ea(n,e){td&&console.warn(n+" is deprecated, please use "+e+" instead.")}function Nk(n){const e={browser:null,version:null};if(typeof n>"u"||!n.navigator||!n.navigator.userAgent)return e.browser="Not a browser.",e;const{navigator:t}=n;if(t.userAgentData&&t.userAgentData.brands){const i=t.userAgentData.brands.find(r=>r.brand==="Chromium");if(i)return{browser:"chrome",version:parseInt(i.version,10)}}if(t.mozGetUserMedia)e.browser="firefox",e.version=jr(t.userAgent,/Firefox\/(\d+)\./,1);else if(t.webkitGetUserMedia||n.isSecureContext===!1&&n.webkitRTCPeerConnection)e.browser="chrome",e.version=jr(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(n.RTCPeerConnection&&t.userAgent.match(/AppleWebKit\/(\d+)\./))e.browser="safari",e.version=jr(t.userAgent,/AppleWebKit\/(\d+)\./,1),e.supportsUnifiedPlan=n.RTCRtpTransceiver&&"currentDirection"in n.RTCRtpTransceiver.prototype;else return e.browser="Not a supported browser.",e;return e}function id(n){return Object.prototype.toString.call(n)==="[object Object]"}function rd(n){return id(n)?Object.keys(n).reduce(function(e,t){const i=id(n[t]),r=i?rd(n[t]):n[t],s=i&&!Object.keys(r).length;return r===void 0||s?e:Object.assign(e,{[t]:r})},{}):n}function Pa(n,e,t){!e||t.has(e.id)||(t.set(e.id,e),Object.keys(e).forEach(i=>{i.endsWith("Id")?Pa(n,n.get(e[i]),t):i.endsWith("Ids")&&e[i].forEach(r=>{Pa(n,n.get(r),t)})}))}function sd(n,e,t){const i=t?"outbound-rtp":"inbound-rtp",r=new Map;if(e===null)return r;const s=[];return n.forEach(a=>{a.type==="track"&&a.trackIdentifier===e.id&&s.push(a)}),s.forEach(a=>{n.forEach(o=>{o.type===i&&o.trackId===a.id&&Pa(n,o,r)})}),r}const ad=nd;function od(n,e){const t=n&&n.navigator;if(!t.mediaDevices)return;const i=function(o){if(typeof o!="object"||o.mandatory||o.optional)return o;const c={};return Object.keys(o).forEach(l=>{if(l==="require"||l==="advanced"||l==="mediaSource")return;const u=typeof o[l]=="object"?o[l]:{ideal:o[l]};u.exact!==void 0&&typeof u.exact=="number"&&(u.min=u.max=u.exact);const d=function(h,f){return h?h+f.charAt(0).toUpperCase()+f.slice(1):f==="deviceId"?"sourceId":f};if(u.ideal!==void 0){c.optional=c.optional||[];let h={};typeof u.ideal=="number"?(h[d("min",l)]=u.ideal,c.optional.push(h),h={},h[d("max",l)]=u.ideal,c.optional.push(h)):(h[d("",l)]=u.ideal,c.optional.push(h))}u.exact!==void 0&&typeof u.exact!="number"?(c.mandatory=c.mandatory||{},c.mandatory[d("",l)]=u.exact):["min","max"].forEach(h=>{u[h]!==void 0&&(c.mandatory=c.mandatory||{},c.mandatory[d(h,l)]=u[h])})}),o.advanced&&(c.optional=(c.optional||[]).concat(o.advanced)),c},r=function(o,c){if(e.version>=61)return c(o);if(o=JSON.parse(JSON.stringify(o)),o&&typeof o.audio=="object"){const l=function(u,d,h){d in u&&!(h in u)&&(u[h]=u[d],delete u[d])};o=JSON.parse(JSON.stringify(o)),l(o.audio,"autoGainControl","googAutoGainControl"),l(o.audio,"noiseSuppression","googNoiseSuppression"),o.audio=i(o.audio)}if(o&&typeof o.video=="object"){let l=o.video.facingMode;l=l&&(typeof l=="object"?l:{ideal:l});const u=e.version<66;if(l&&(l.exact==="user"||l.exact==="environment"||l.ideal==="user"||l.ideal==="environment")&&!(t.mediaDevices.getSupportedConstraints&&t.mediaDevices.getSupportedConstraints().facingMode&&!u)){delete o.video.facingMode;let d;if(l.exact==="environment"||l.ideal==="environment"?d=["back","rear"]:(l.exact==="user"||l.ideal==="user")&&(d=["front"]),d)return t.mediaDevices.enumerateDevices().then(h=>{h=h.filter(p=>p.kind==="videoinput");let f=h.find(p=>d.some(g=>p.label.toLowerCase().includes(g)));return!f&&h.length&&d.includes("back")&&(f=h[h.length-1]),f&&(o.video.deviceId=l.exact?{exact:f.deviceId}:{ideal:f.deviceId}),o.video=i(o.video),ad("chrome: "+JSON.stringify(o)),c(o)})}o.video=i(o.video)}return ad("chrome: "+JSON.stringify(o)),c(o)},s=function(o){return e.version>=64?o:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[o.name]||o.name,message:o.message,constraint:o.constraint||o.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}},a=function(o,c,l){r(o,u=>{t.webkitGetUserMedia(u,c,d=>{l&&l(s(d))})})};if(t.getUserMedia=a.bind(t),t.mediaDevices.getUserMedia){const o=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(c){return r(c,l=>o(l).then(u=>{if(l.audio&&!u.getAudioTracks().length||l.video&&!u.getVideoTracks().length)throw u.getTracks().forEach(d=>{d.stop()}),new DOMException("","NotFoundError");return u},u=>Promise.reject(s(u))))}}}function cd(n){n.MediaStream=n.MediaStream||n.webkitMediaStream}function ld(n){if(typeof n=="object"&&n.RTCPeerConnection&&!("ontrack"in n.RTCPeerConnection.prototype)){Object.defineProperty(n.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(t){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=t)},enumerable:!0,configurable:!0});const e=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=i=>{i.stream.addEventListener("addtrack",r=>{let s;n.RTCPeerConnection.prototype.getReceivers?s=this.getReceivers().find(o=>o.track&&o.track.id===r.track.id):s={track:r.track};const a=new Event("track");a.track=r.track,a.receiver=s,a.transceiver={receiver:s},a.streams=[i.stream],this.dispatchEvent(a)}),i.stream.getTracks().forEach(r=>{let s;n.RTCPeerConnection.prototype.getReceivers?s=this.getReceivers().find(o=>o.track&&o.track.id===r.id):s={track:r};const a=new Event("track");a.track=r,a.receiver=s,a.transceiver={receiver:s},a.streams=[i.stream],this.dispatchEvent(a)})},this.addEventListener("addstream",this._ontrackpoly)),e.apply(this,arguments)}}else fn(n,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e))}function ud(n){if(typeof n=="object"&&n.RTCPeerConnection&&!("getSenders"in n.RTCPeerConnection.prototype)&&"createDTMFSender"in n.RTCPeerConnection.prototype){const e=function(r,s){return{track:s,get dtmf(){return this._dtmf===void 0&&(s.kind==="audio"?this._dtmf=r.createDTMFSender(s):this._dtmf=null),this._dtmf},_pc:r}};if(!n.RTCPeerConnection.prototype.getSenders){n.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const r=n.RTCPeerConnection.prototype.addTrack;n.RTCPeerConnection.prototype.addTrack=function(o,c){let l=r.apply(this,arguments);return l||(l=e(this,o),this._senders.push(l)),l};const s=n.RTCPeerConnection.prototype.removeTrack;n.RTCPeerConnection.prototype.removeTrack=function(o){s.apply(this,arguments);const c=this._senders.indexOf(o);c!==-1&&this._senders.splice(c,1)}}const t=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(s){this._senders=this._senders||[],t.apply(this,[s]),s.getTracks().forEach(a=>{this._senders.push(e(this,a))})};const i=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(s){this._senders=this._senders||[],i.apply(this,[s]),s.getTracks().forEach(a=>{const o=this._senders.find(c=>c.track===a);o&&this._senders.splice(this._senders.indexOf(o),1)})}}else if(typeof n=="object"&&n.RTCPeerConnection&&"getSenders"in n.RTCPeerConnection.prototype&&"createDTMFSender"in n.RTCPeerConnection.prototype&&n.RTCRtpSender&&!("dtmf"in n.RTCRtpSender.prototype)){const e=n.RTCPeerConnection.prototype.getSenders;n.RTCPeerConnection.prototype.getSenders=function(){const i=e.apply(this,[]);return i.forEach(r=>r._pc=this),i},Object.defineProperty(n.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function dd(n){if(!(typeof n=="object"&&n.RTCPeerConnection&&n.RTCRtpSender&&n.RTCRtpReceiver))return;if(!("getStats"in n.RTCRtpSender.prototype)){const t=n.RTCPeerConnection.prototype.getSenders;t&&(n.RTCPeerConnection.prototype.getSenders=function(){const s=t.apply(this,[]);return s.forEach(a=>a._pc=this),s});const i=n.RTCPeerConnection.prototype.addTrack;i&&(n.RTCPeerConnection.prototype.addTrack=function(){const s=i.apply(this,arguments);return s._pc=this,s}),n.RTCRtpSender.prototype.getStats=function(){const s=this;return this._pc.getStats().then(a=>sd(a,s.track,!0))}}if(!("getStats"in n.RTCRtpReceiver.prototype)){const t=n.RTCPeerConnection.prototype.getReceivers;t&&(n.RTCPeerConnection.prototype.getReceivers=function(){const r=t.apply(this,[]);return r.forEach(s=>s._pc=this),r}),fn(n,"track",i=>(i.receiver._pc=i.srcElement,i)),n.RTCRtpReceiver.prototype.getStats=function(){const r=this;return this._pc.getStats().then(s=>sd(s,r.track,!1))}}if(!("getStats"in n.RTCRtpSender.prototype&&"getStats"in n.RTCRtpReceiver.prototype))return;const e=n.RTCPeerConnection.prototype.getStats;n.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof n.MediaStreamTrack){const i=arguments[0];let r,s,a;return this.getSenders().forEach(o=>{o.track===i&&(r?a=!0:r=o)}),this.getReceivers().forEach(o=>(o.track===i&&(s?a=!0:s=o),o.track===i)),a||r&&s?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):r?r.getStats():s?s.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return e.apply(this,arguments)}}function hd(n){n.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(a=>this._shimmedLocalStreams[a][0])};const e=n.RTCPeerConnection.prototype.addTrack;n.RTCPeerConnection.prototype.addTrack=function(a,o){if(!o)return e.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const c=e.apply(this,arguments);return this._shimmedLocalStreams[o.id]?this._shimmedLocalStreams[o.id].indexOf(c)===-1&&this._shimmedLocalStreams[o.id].push(c):this._shimmedLocalStreams[o.id]=[o,c],c};const t=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(a){this._shimmedLocalStreams=this._shimmedLocalStreams||{},a.getTracks().forEach(l=>{if(this.getSenders().find(d=>d.track===l))throw new DOMException("Track already exists.","InvalidAccessError")});const o=this.getSenders();t.apply(this,arguments);const c=this.getSenders().filter(l=>o.indexOf(l)===-1);this._shimmedLocalStreams[a.id]=[a].concat(c)};const i=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(a){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[a.id],i.apply(this,arguments)};const r=n.RTCPeerConnection.prototype.removeTrack;n.RTCPeerConnection.prototype.removeTrack=function(a){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},a&&Object.keys(this._shimmedLocalStreams).forEach(o=>{const c=this._shimmedLocalStreams[o].indexOf(a);c!==-1&&this._shimmedLocalStreams[o].splice(c,1),this._shimmedLocalStreams[o].length===1&&delete this._shimmedLocalStreams[o]}),r.apply(this,arguments)}}function fd(n,e){if(!n.RTCPeerConnection)return;if(n.RTCPeerConnection.prototype.addTrack&&e.version>=65)return hd(n);const t=n.RTCPeerConnection.prototype.getLocalStreams;n.RTCPeerConnection.prototype.getLocalStreams=function(){const u=t.apply(this);return this._reverseStreams=this._reverseStreams||{},u.map(d=>this._reverseStreams[d.id])};const i=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(u){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},u.getTracks().forEach(d=>{if(this.getSenders().find(f=>f.track===d))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[u.id]){const d=new n.MediaStream(u.getTracks());this._streams[u.id]=d,this._reverseStreams[d.id]=u,u=d}i.apply(this,[u])};const r=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(u){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},r.apply(this,[this._streams[u.id]||u]),delete this._reverseStreams[this._streams[u.id]?this._streams[u.id].id:u.id],delete this._streams[u.id]},n.RTCPeerConnection.prototype.addTrack=function(u,d){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const h=[].slice.call(arguments,1);if(h.length!==1||!h[0].getTracks().find(g=>g===u))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(g=>g.track===u))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const p=this._streams[d.id];if(p)p.addTrack(u),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const g=new n.MediaStream([u]);this._streams[d.id]=g,this._reverseStreams[g.id]=d,this.addStream(g)}return this.getSenders().find(g=>g.track===u)};function s(l,u){let d=u.sdp;return Object.keys(l._reverseStreams||[]).forEach(h=>{const f=l._reverseStreams[h],p=l._streams[f.id];d=d.replace(new RegExp(p.id,"g"),f.id)}),new RTCSessionDescription({type:u.type,sdp:d})}function a(l,u){let d=u.sdp;return Object.keys(l._reverseStreams||[]).forEach(h=>{const f=l._reverseStreams[h],p=l._streams[f.id];d=d.replace(new RegExp(f.id,"g"),p.id)}),new RTCSessionDescription({type:u.type,sdp:d})}["createOffer","createAnswer"].forEach(function(l){const u=n.RTCPeerConnection.prototype[l],d={[l](){const h=arguments;return arguments.length&&typeof arguments[0]=="function"?u.apply(this,[p=>{const g=s(this,p);h[0].apply(null,[g])},p=>{h[1]&&h[1].apply(null,p)},arguments[2]]):u.apply(this,arguments).then(p=>s(this,p))}};n.RTCPeerConnection.prototype[l]=d[l]});const o=n.RTCPeerConnection.prototype.setLocalDescription;n.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type?o.apply(this,arguments):(arguments[0]=a(this,arguments[0]),o.apply(this,arguments))};const c=Object.getOwnPropertyDescriptor(n.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(n.RTCPeerConnection.prototype,"localDescription",{get(){const l=c.get.apply(this);return l.type===""?l:s(this,l)}}),n.RTCPeerConnection.prototype.removeTrack=function(u){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!u._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(u._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};let h;Object.keys(this._streams).forEach(f=>{this._streams[f].getTracks().find(g=>u.track===g)&&(h=this._streams[f])}),h&&(h.getTracks().length===1?this.removeStream(this._reverseStreams[h.id]):h.removeTrack(u.track),this.dispatchEvent(new Event("negotiationneeded")))}}function Ra(n,e){!n.RTCPeerConnection&&n.webkitRTCPeerConnection&&(n.RTCPeerConnection=n.webkitRTCPeerConnection),n.RTCPeerConnection&&e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){const i=n.RTCPeerConnection.prototype[t],r={[t](){return arguments[0]=new(t==="addIceCandidate"?n.RTCIceCandidate:n.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}};n.RTCPeerConnection.prototype[t]=r[t]})}function pd(n,e){fn(n,"negotiationneeded",t=>{const i=t.target;if(!((e.version<72||i.getConfiguration&&i.getConfiguration().sdpSemantics==="plan-b")&&i.signalingState!=="stable"))return t})}var md=Object.freeze({__proto__:null,fixNegotiationNeeded:pd,shimAddTrackRemoveTrack:fd,shimAddTrackRemoveTrackWithNative:hd,shimGetSendersWithDtmf:ud,shimGetUserMedia:od,shimMediaStream:cd,shimOnTrack:ld,shimPeerConnection:Ra,shimSenderReceiverGetStats:dd});function gd(n,e){const t=n&&n.navigator,i=n&&n.MediaStreamTrack;if(t.getUserMedia=function(r,s,a){Ea("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),t.mediaDevices.getUserMedia(r).then(s,a)},!(e.version>55&&"autoGainControl"in t.mediaDevices.getSupportedConstraints())){const r=function(a,o,c){o in a&&!(c in a)&&(a[c]=a[o],delete a[o])},s=t.mediaDevices.getUserMedia.bind(t.mediaDevices);if(t.mediaDevices.getUserMedia=function(a){return typeof a=="object"&&typeof a.audio=="object"&&(a=JSON.parse(JSON.stringify(a)),r(a.audio,"autoGainControl","mozAutoGainControl"),r(a.audio,"noiseSuppression","mozNoiseSuppression")),s(a)},i&&i.prototype.getSettings){const a=i.prototype.getSettings;i.prototype.getSettings=function(){const o=a.apply(this,arguments);return r(o,"mozAutoGainControl","autoGainControl"),r(o,"mozNoiseSuppression","noiseSuppression"),o}}if(i&&i.prototype.applyConstraints){const a=i.prototype.applyConstraints;i.prototype.applyConstraints=function(o){return this.kind==="audio"&&typeof o=="object"&&(o=JSON.parse(JSON.stringify(o)),r(o,"autoGainControl","mozAutoGainControl"),r(o,"noiseSuppression","mozNoiseSuppression")),a.apply(this,[o])}}}}function Mk(n,e){n.navigator.mediaDevices&&"getDisplayMedia"in n.navigator.mediaDevices||n.navigator.mediaDevices&&(n.navigator.mediaDevices.getDisplayMedia=function(i){if(!(i&&i.video)){const r=new DOMException("getDisplayMedia without video constraints is undefined");return r.name="NotFoundError",r.code=8,Promise.reject(r)}return i.video===!0?i.video={mediaSource:e}:i.video.mediaSource=e,n.navigator.mediaDevices.getUserMedia(i)})}function vd(n){typeof n=="object"&&n.RTCTrackEvent&&"receiver"in n.RTCTrackEvent.prototype&&!("transceiver"in n.RTCTrackEvent.prototype)&&Object.defineProperty(n.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Ia(n,e){if(typeof n!="object"||!(n.RTCPeerConnection||n.mozRTCPeerConnection))return;!n.RTCPeerConnection&&n.mozRTCPeerConnection&&(n.RTCPeerConnection=n.mozRTCPeerConnection),e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(r){const s=n.RTCPeerConnection.prototype[r],a={[r](){return arguments[0]=new(r==="addIceCandidate"?n.RTCIceCandidate:n.RTCSessionDescription)(arguments[0]),s.apply(this,arguments)}};n.RTCPeerConnection.prototype[r]=a[r]});const t={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},i=n.RTCPeerConnection.prototype.getStats;n.RTCPeerConnection.prototype.getStats=function(){const[s,a,o]=arguments;return i.apply(this,[s||null]).then(c=>{if(e.version<53&&!a)try{c.forEach(l=>{l.type=t[l.type]||l.type})}catch(l){if(l.name!=="TypeError")throw l;c.forEach((u,d)=>{c.set(d,Object.assign({},u,{type:t[u.type]||u.type}))})}return c}).then(a,o)}}function bd(n){if(!(typeof n=="object"&&n.RTCPeerConnection&&n.RTCRtpSender)||n.RTCRtpSender&&"getStats"in n.RTCRtpSender.prototype)return;const e=n.RTCPeerConnection.prototype.getSenders;e&&(n.RTCPeerConnection.prototype.getSenders=function(){const r=e.apply(this,[]);return r.forEach(s=>s._pc=this),r});const t=n.RTCPeerConnection.prototype.addTrack;t&&(n.RTCPeerConnection.prototype.addTrack=function(){const r=t.apply(this,arguments);return r._pc=this,r}),n.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function yd(n){if(!(typeof n=="object"&&n.RTCPeerConnection&&n.RTCRtpSender)||n.RTCRtpSender&&"getStats"in n.RTCRtpReceiver.prototype)return;const e=n.RTCPeerConnection.prototype.getReceivers;e&&(n.RTCPeerConnection.prototype.getReceivers=function(){const i=e.apply(this,[]);return i.forEach(r=>r._pc=this),i}),fn(n,"track",t=>(t.receiver._pc=t.srcElement,t)),n.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function kd(n){!n.RTCPeerConnection||"removeStream"in n.RTCPeerConnection.prototype||(n.RTCPeerConnection.prototype.removeStream=function(t){Ea("removeStream","removeTrack"),this.getSenders().forEach(i=>{i.track&&t.getTracks().includes(i.track)&&this.removeTrack(i)})})}function Td(n){n.DataChannel&&!n.RTCDataChannel&&(n.RTCDataChannel=n.DataChannel)}function Sd(n){if(!(typeof n=="object"&&n.RTCPeerConnection))return;const e=n.RTCPeerConnection.prototype.addTransceiver;e&&(n.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];let i=arguments[1]&&arguments[1].sendEncodings;i===void 0&&(i=[]),i=[...i];const r=i.length>0;r&&i.forEach(a=>{if("rid"in a&&!/^[a-z0-9]{0,16}$/i.test(a.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in a&&!(parseFloat(a.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in a&&!(parseFloat(a.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const s=e.apply(this,arguments);if(r){const{sender:a}=s,o=a.getParameters();(!("encodings"in o)||o.encodings.length===1&&Object.keys(o.encodings[0]).length===0)&&(o.encodings=i,a.sendEncodings=i,this.setParametersPromises.push(a.setParameters(o).then(()=>{delete a.sendEncodings}).catch(()=>{delete a.sendEncodings})))}return s})}function Cd(n){if(!(typeof n=="object"&&n.RTCRtpSender))return;const e=n.RTCRtpSender.prototype.getParameters;e&&(n.RTCRtpSender.prototype.getParameters=function(){const i=e.apply(this,arguments);return"encodings"in i||(i.encodings=[].concat(this.sendEncodings||[{}])),i})}function xd(n){if(!(typeof n=="object"&&n.RTCPeerConnection))return;const e=n.RTCPeerConnection.prototype.createOffer;n.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}function wd(n){if(!(typeof n=="object"&&n.RTCPeerConnection))return;const e=n.RTCPeerConnection.prototype.createAnswer;n.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}var _d=Object.freeze({__proto__:null,shimAddTransceiver:Sd,shimCreateAnswer:wd,shimCreateOffer:xd,shimGetDisplayMedia:Mk,shimGetParameters:Cd,shimGetUserMedia:gd,shimOnTrack:vd,shimPeerConnection:Ia,shimRTCDataChannel:Td,shimReceiverGetStats:yd,shimRemoveStream:kd,shimSenderGetStats:bd});function Ed(n){if(!(typeof n!="object"||!n.RTCPeerConnection)){if("getLocalStreams"in n.RTCPeerConnection.prototype||(n.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in n.RTCPeerConnection.prototype)){const e=n.RTCPeerConnection.prototype.addTrack;n.RTCPeerConnection.prototype.addStream=function(i){this._localStreams||(this._localStreams=[]),this._localStreams.includes(i)||this._localStreams.push(i),i.getAudioTracks().forEach(r=>e.call(this,r,i)),i.getVideoTracks().forEach(r=>e.call(this,r,i))},n.RTCPeerConnection.prototype.addTrack=function(i){for(var r=arguments.length,s=new Array(r>1?r-1:0),a=1;a<r;a++)s[a-1]=arguments[a];return s&&s.forEach(o=>{this._localStreams?this._localStreams.includes(o)||this._localStreams.push(o):this._localStreams=[o]}),e.apply(this,arguments)}}"removeStream"in n.RTCPeerConnection.prototype||(n.RTCPeerConnection.prototype.removeStream=function(t){this._localStreams||(this._localStreams=[]);const i=this._localStreams.indexOf(t);if(i===-1)return;this._localStreams.splice(i,1);const r=t.getTracks();this.getSenders().forEach(s=>{r.includes(s.track)&&this.removeTrack(s)})})}}function Pd(n){if(!(typeof n!="object"||!n.RTCPeerConnection)&&("getRemoteStreams"in n.RTCPeerConnection.prototype||(n.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in n.RTCPeerConnection.prototype))){Object.defineProperty(n.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(t){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=t),this.addEventListener("track",this._onaddstreampoly=i=>{i.streams.forEach(r=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(r))return;this._remoteStreams.push(r);const s=new Event("addstream");s.stream=r,this.dispatchEvent(s)})})}});const e=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(){const i=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(r){r.streams.forEach(s=>{if(i._remoteStreams||(i._remoteStreams=[]),i._remoteStreams.indexOf(s)>=0)return;i._remoteStreams.push(s);const a=new Event("addstream");a.stream=s,i.dispatchEvent(a)})}),e.apply(i,arguments)}}}function Rd(n){if(typeof n!="object"||!n.RTCPeerConnection)return;const e=n.RTCPeerConnection.prototype,t=e.createOffer,i=e.createAnswer,r=e.setLocalDescription,s=e.setRemoteDescription,a=e.addIceCandidate;e.createOffer=function(l,u){const d=arguments.length>=2?arguments[2]:arguments[0],h=t.apply(this,[d]);return u?(h.then(l,u),Promise.resolve()):h},e.createAnswer=function(l,u){const d=arguments.length>=2?arguments[2]:arguments[0],h=i.apply(this,[d]);return u?(h.then(l,u),Promise.resolve()):h};let o=function(c,l,u){const d=r.apply(this,[c]);return u?(d.then(l,u),Promise.resolve()):d};e.setLocalDescription=o,o=function(c,l,u){const d=s.apply(this,[c]);return u?(d.then(l,u),Promise.resolve()):d},e.setRemoteDescription=o,o=function(c,l,u){const d=a.apply(this,[c]);return u?(d.then(l,u),Promise.resolve()):d},e.addIceCandidate=o}function Id(n){const e=n&&n.navigator;if(e.mediaDevices&&e.mediaDevices.getUserMedia){const t=e.mediaDevices,i=t.getUserMedia.bind(t);e.mediaDevices.getUserMedia=r=>i(Od(r))}!e.getUserMedia&&e.mediaDevices&&e.mediaDevices.getUserMedia&&(e.getUserMedia=(function(i,r,s){e.mediaDevices.getUserMedia(i).then(r,s)}).bind(e))}function Od(n){return n&&n.video!==void 0?Object.assign({},n,{video:rd(n.video)}):n}function Ad(n){if(!n.RTCPeerConnection)return;const e=n.RTCPeerConnection;n.RTCPeerConnection=function(i,r){if(i&&i.iceServers){const s=[];for(let a=0;a<i.iceServers.length;a++){let o=i.iceServers[a];o.urls===void 0&&o.url?(Ea("RTCIceServer.url","RTCIceServer.urls"),o=JSON.parse(JSON.stringify(o)),o.urls=o.url,delete o.url,s.push(o)):s.push(i.iceServers[a])}i.iceServers=s}return new e(i,r)},n.RTCPeerConnection.prototype=e.prototype,"generateCertificate"in e&&Object.defineProperty(n.RTCPeerConnection,"generateCertificate",{get(){return e.generateCertificate}})}function Nd(n){typeof n=="object"&&n.RTCTrackEvent&&"receiver"in n.RTCTrackEvent.prototype&&!("transceiver"in n.RTCTrackEvent.prototype)&&Object.defineProperty(n.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Md(n){const e=n.RTCPeerConnection.prototype.createOffer;n.RTCPeerConnection.prototype.createOffer=function(i){if(i){typeof i.offerToReceiveAudio<"u"&&(i.offerToReceiveAudio=!!i.offerToReceiveAudio);const r=this.getTransceivers().find(a=>a.receiver.track.kind==="audio");i.offerToReceiveAudio===!1&&r?r.direction==="sendrecv"?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":r.direction==="recvonly"&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):i.offerToReceiveAudio===!0&&!r&&this.addTransceiver("audio",{direction:"recvonly"}),typeof i.offerToReceiveVideo<"u"&&(i.offerToReceiveVideo=!!i.offerToReceiveVideo);const s=this.getTransceivers().find(a=>a.receiver.track.kind==="video");i.offerToReceiveVideo===!1&&s?s.direction==="sendrecv"?s.setDirection?s.setDirection("sendonly"):s.direction="sendonly":s.direction==="recvonly"&&(s.setDirection?s.setDirection("inactive"):s.direction="inactive"):i.offerToReceiveVideo===!0&&!s&&this.addTransceiver("video",{direction:"recvonly"})}return e.apply(this,arguments)}}function Ld(n){typeof n!="object"||n.AudioContext||(n.AudioContext=n.webkitAudioContext)}var Dd=Object.freeze({__proto__:null,shimAudioContext:Ld,shimCallbacksAPI:Rd,shimConstraints:Od,shimCreateOfferLegacy:Md,shimGetUserMedia:Id,shimLocalStreamsAPI:Ed,shimRTCIceServerUrls:Ad,shimRemoteStreamsAPI:Pd,shimTrackEventTransceiver:Nd}),Oa={exports:{}},Ud;function Lk(){return Ud||(Ud=1,function(n){const e={};e.generateIdentifier=function(){return Math.random().toString(36).substring(2,12)},e.localCName=e.generateIdentifier(),e.splitLines=function(t){return t.trim().split(`
85
7
  `).map(i=>i.trim())},e.splitSections=function(t){return t.split(`
86
- m=`).map((r,o)=>(o>0?"m="+r:r).trim()+`\r
87
- `)},e.getDescription=function(t){const i=e.splitSections(t);return i&&i[0]},e.getMediaSections=function(t){const i=e.splitSections(t);return i.shift(),i},e.matchPrefix=function(t,i){return e.splitLines(t).filter(r=>r.indexOf(i)===0)},e.parseCandidate=function(t){let i;t.indexOf("a=candidate:")===0?i=t.substring(12).split(" "):i=t.substring(10).split(" ");const r={foundation:i[0],component:{1:"rtp",2:"rtcp"}[i[1]]||i[1],protocol:i[2].toLowerCase(),priority:parseInt(i[3],10),ip:i[4],address:i[4],port:parseInt(i[5],10),type:i[7]};for(let o=8;o<i.length;o+=2)switch(i[o]){case"raddr":r.relatedAddress=i[o+1];break;case"rport":r.relatedPort=parseInt(i[o+1],10);break;case"tcptype":r.tcpType=i[o+1];break;case"ufrag":r.ufrag=i[o+1],r.usernameFragment=i[o+1];break;default:r[i[o]]===void 0&&(r[i[o]]=i[o+1]);break}return r},e.writeCandidate=function(t){const i=[];i.push(t.foundation);const r=t.component;r==="rtp"?i.push(1):r==="rtcp"?i.push(2):i.push(r),i.push(t.protocol.toUpperCase()),i.push(t.priority),i.push(t.address||t.ip),i.push(t.port);const o=t.type;return i.push("typ"),i.push(o),o!=="host"&&t.relatedAddress&&t.relatedPort&&(i.push("raddr"),i.push(t.relatedAddress),i.push("rport"),i.push(t.relatedPort)),t.tcpType&&t.protocol.toLowerCase()==="tcp"&&(i.push("tcptype"),i.push(t.tcpType)),(t.usernameFragment||t.ufrag)&&(i.push("ufrag"),i.push(t.usernameFragment||t.ufrag)),"candidate:"+i.join(" ")},e.parseIceOptions=function(t){return t.substring(14).split(" ")},e.parseRtpMap=function(t){let i=t.substring(9).split(" ");const r={payloadType:parseInt(i.shift(),10)};return i=i[0].split("/"),r.name=i[0],r.clockRate=parseInt(i[1],10),r.channels=i.length===3?parseInt(i[2],10):1,r.numChannels=r.channels,r},e.writeRtpMap=function(t){let i=t.payloadType;t.preferredPayloadType!==void 0&&(i=t.preferredPayloadType);const r=t.channels||t.numChannels||1;return"a=rtpmap:"+i+" "+t.name+"/"+t.clockRate+(r!==1?"/"+r:"")+`\r
8
+ m=`).map((r,s)=>(s>0?"m="+r:r).trim()+`\r
9
+ `)},e.getDescription=function(t){const i=e.splitSections(t);return i&&i[0]},e.getMediaSections=function(t){const i=e.splitSections(t);return i.shift(),i},e.matchPrefix=function(t,i){return e.splitLines(t).filter(r=>r.indexOf(i)===0)},e.parseCandidate=function(t){let i;t.indexOf("a=candidate:")===0?i=t.substring(12).split(" "):i=t.substring(10).split(" ");const r={foundation:i[0],component:{1:"rtp",2:"rtcp"}[i[1]]||i[1],protocol:i[2].toLowerCase(),priority:parseInt(i[3],10),ip:i[4],address:i[4],port:parseInt(i[5],10),type:i[7]};for(let s=8;s<i.length;s+=2)switch(i[s]){case"raddr":r.relatedAddress=i[s+1];break;case"rport":r.relatedPort=parseInt(i[s+1],10);break;case"tcptype":r.tcpType=i[s+1];break;case"ufrag":r.ufrag=i[s+1],r.usernameFragment=i[s+1];break;default:r[i[s]]===void 0&&(r[i[s]]=i[s+1]);break}return r},e.writeCandidate=function(t){const i=[];i.push(t.foundation);const r=t.component;r==="rtp"?i.push(1):r==="rtcp"?i.push(2):i.push(r),i.push(t.protocol.toUpperCase()),i.push(t.priority),i.push(t.address||t.ip),i.push(t.port);const s=t.type;return i.push("typ"),i.push(s),s!=="host"&&t.relatedAddress&&t.relatedPort&&(i.push("raddr"),i.push(t.relatedAddress),i.push("rport"),i.push(t.relatedPort)),t.tcpType&&t.protocol.toLowerCase()==="tcp"&&(i.push("tcptype"),i.push(t.tcpType)),(t.usernameFragment||t.ufrag)&&(i.push("ufrag"),i.push(t.usernameFragment||t.ufrag)),"candidate:"+i.join(" ")},e.parseIceOptions=function(t){return t.substring(14).split(" ")},e.parseRtpMap=function(t){let i=t.substring(9).split(" ");const r={payloadType:parseInt(i.shift(),10)};return i=i[0].split("/"),r.name=i[0],r.clockRate=parseInt(i[1],10),r.channels=i.length===3?parseInt(i[2],10):1,r.numChannels=r.channels,r},e.writeRtpMap=function(t){let i=t.payloadType;t.preferredPayloadType!==void 0&&(i=t.preferredPayloadType);const r=t.channels||t.numChannels||1;return"a=rtpmap:"+i+" "+t.name+"/"+t.clockRate+(r!==1?"/"+r:"")+`\r
88
10
  `},e.parseExtmap=function(t){const i=t.substring(9).split(" ");return{id:parseInt(i[0],10),direction:i[0].indexOf("/")>0?i[0].split("/")[1]:"sendrecv",uri:i[1],attributes:i.slice(2).join(" ")}},e.writeExtmap=function(t){return"a=extmap:"+(t.id||t.preferredId)+(t.direction&&t.direction!=="sendrecv"?"/"+t.direction:"")+" "+t.uri+(t.attributes?" "+t.attributes:"")+`\r
89
- `},e.parseFmtp=function(t){const i={};let r;const o=t.substring(t.indexOf(" ")+1).split(";");for(let s=0;s<o.length;s++)r=o[s].trim().split("="),i[r[0].trim()]=r[1];return i},e.writeFmtp=function(t){let i="",r=t.payloadType;if(t.preferredPayloadType!==void 0&&(r=t.preferredPayloadType),t.parameters&&Object.keys(t.parameters).length){const o=[];Object.keys(t.parameters).forEach(s=>{t.parameters[s]!==void 0?o.push(s+"="+t.parameters[s]):o.push(s)}),i+="a=fmtp:"+r+" "+o.join(";")+`\r
90
- `}return i},e.parseRtcpFb=function(t){const i=t.substring(t.indexOf(" ")+1).split(" ");return{type:i.shift(),parameter:i.join(" ")}},e.writeRtcpFb=function(t){let i="",r=t.payloadType;return t.preferredPayloadType!==void 0&&(r=t.preferredPayloadType),t.rtcpFeedback&&t.rtcpFeedback.length&&t.rtcpFeedback.forEach(o=>{i+="a=rtcp-fb:"+r+" "+o.type+(o.parameter&&o.parameter.length?" "+o.parameter:"")+`\r
91
- `}),i},e.parseSsrcMedia=function(t){const i=t.indexOf(" "),r={ssrc:parseInt(t.substring(7,i),10)},o=t.indexOf(":",i);return o>-1?(r.attribute=t.substring(i+1,o),r.value=t.substring(o+1)):r.attribute=t.substring(i+1),r},e.parseSsrcGroup=function(t){const i=t.substring(13).split(" ");return{semantics:i.shift(),ssrcs:i.map(r=>parseInt(r,10))}},e.getMid=function(t){const i=e.matchPrefix(t,"a=mid:")[0];if(i)return i.substring(6)},e.parseFingerprint=function(t){const i=t.substring(14).split(" ");return{algorithm:i[0].toLowerCase(),value:i[1].toUpperCase()}},e.getDtlsParameters=function(t,i){return{role:"auto",fingerprints:e.matchPrefix(t+i,"a=fingerprint:").map(e.parseFingerprint)}},e.writeDtlsParameters=function(t,i){let r="a=setup:"+i+`\r
92
- `;return t.fingerprints.forEach(o=>{r+="a=fingerprint:"+o.algorithm+" "+o.value+`\r
11
+ `},e.parseFmtp=function(t){const i={};let r;const s=t.substring(t.indexOf(" ")+1).split(";");for(let a=0;a<s.length;a++)r=s[a].trim().split("="),i[r[0].trim()]=r[1];return i},e.writeFmtp=function(t){let i="",r=t.payloadType;if(t.preferredPayloadType!==void 0&&(r=t.preferredPayloadType),t.parameters&&Object.keys(t.parameters).length){const s=[];Object.keys(t.parameters).forEach(a=>{t.parameters[a]!==void 0?s.push(a+"="+t.parameters[a]):s.push(a)}),i+="a=fmtp:"+r+" "+s.join(";")+`\r
12
+ `}return i},e.parseRtcpFb=function(t){const i=t.substring(t.indexOf(" ")+1).split(" ");return{type:i.shift(),parameter:i.join(" ")}},e.writeRtcpFb=function(t){let i="",r=t.payloadType;return t.preferredPayloadType!==void 0&&(r=t.preferredPayloadType),t.rtcpFeedback&&t.rtcpFeedback.length&&t.rtcpFeedback.forEach(s=>{i+="a=rtcp-fb:"+r+" "+s.type+(s.parameter&&s.parameter.length?" "+s.parameter:"")+`\r
13
+ `}),i},e.parseSsrcMedia=function(t){const i=t.indexOf(" "),r={ssrc:parseInt(t.substring(7,i),10)},s=t.indexOf(":",i);return s>-1?(r.attribute=t.substring(i+1,s),r.value=t.substring(s+1)):r.attribute=t.substring(i+1),r},e.parseSsrcGroup=function(t){const i=t.substring(13).split(" ");return{semantics:i.shift(),ssrcs:i.map(r=>parseInt(r,10))}},e.getMid=function(t){const i=e.matchPrefix(t,"a=mid:")[0];if(i)return i.substring(6)},e.parseFingerprint=function(t){const i=t.substring(14).split(" ");return{algorithm:i[0].toLowerCase(),value:i[1].toUpperCase()}},e.getDtlsParameters=function(t,i){return{role:"auto",fingerprints:e.matchPrefix(t+i,"a=fingerprint:").map(e.parseFingerprint)}},e.writeDtlsParameters=function(t,i){let r="a=setup:"+i+`\r
14
+ `;return t.fingerprints.forEach(s=>{r+="a=fingerprint:"+s.algorithm+" "+s.value+`\r
93
15
  `}),r},e.parseCryptoLine=function(t){const i=t.substring(9).split(" ");return{tag:parseInt(i[0],10),cryptoSuite:i[1],keyParams:i[2],sessionParams:i.slice(3)}},e.writeCryptoLine=function(t){return"a=crypto:"+t.tag+" "+t.cryptoSuite+" "+(typeof t.keyParams=="object"?e.writeCryptoKeyParams(t.keyParams):t.keyParams)+(t.sessionParams?" "+t.sessionParams.join(" "):"")+`\r
94
- `},e.parseCryptoKeyParams=function(t){if(t.indexOf("inline:")!==0)return null;const i=t.substring(7).split("|");return{keyMethod:"inline",keySalt:i[0],lifeTime:i[1],mkiValue:i[2]?i[2].split(":")[0]:void 0,mkiLength:i[2]?i[2].split(":")[1]:void 0}},e.writeCryptoKeyParams=function(t){return t.keyMethod+":"+t.keySalt+(t.lifeTime?"|"+t.lifeTime:"")+(t.mkiValue&&t.mkiLength?"|"+t.mkiValue+":"+t.mkiLength:"")},e.getCryptoParameters=function(t,i){return e.matchPrefix(t+i,"a=crypto:").map(e.parseCryptoLine)},e.getIceParameters=function(t,i){const r=e.matchPrefix(t+i,"a=ice-ufrag:")[0],o=e.matchPrefix(t+i,"a=ice-pwd:")[0];return r&&o?{usernameFragment:r.substring(12),password:o.substring(10)}:null},e.writeIceParameters=function(t){let i="a=ice-ufrag:"+t.usernameFragment+`\r
16
+ `},e.parseCryptoKeyParams=function(t){if(t.indexOf("inline:")!==0)return null;const i=t.substring(7).split("|");return{keyMethod:"inline",keySalt:i[0],lifeTime:i[1],mkiValue:i[2]?i[2].split(":")[0]:void 0,mkiLength:i[2]?i[2].split(":")[1]:void 0}},e.writeCryptoKeyParams=function(t){return t.keyMethod+":"+t.keySalt+(t.lifeTime?"|"+t.lifeTime:"")+(t.mkiValue&&t.mkiLength?"|"+t.mkiValue+":"+t.mkiLength:"")},e.getCryptoParameters=function(t,i){return e.matchPrefix(t+i,"a=crypto:").map(e.parseCryptoLine)},e.getIceParameters=function(t,i){const r=e.matchPrefix(t+i,"a=ice-ufrag:")[0],s=e.matchPrefix(t+i,"a=ice-pwd:")[0];return r&&s?{usernameFragment:r.substring(12),password:s.substring(10)}:null},e.writeIceParameters=function(t){let i="a=ice-ufrag:"+t.usernameFragment+`\r
95
17
  a=ice-pwd:`+t.password+`\r
96
18
  `;return t.iceLite&&(i+=`a=ice-lite\r
97
- `),i},e.parseRtpParameters=function(t){const i={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},o=e.splitLines(t)[0].split(" ");i.profile=o[2];for(let a=3;a<o.length;a++){const c=o[a],u=e.matchPrefix(t,"a=rtpmap:"+c+" ")[0];if(u){const l=e.parseRtpMap(u),d=e.matchPrefix(t,"a=fmtp:"+c+" ");switch(l.parameters=d.length?e.parseFmtp(d[0]):{},l.rtcpFeedback=e.matchPrefix(t,"a=rtcp-fb:"+c+" ").map(e.parseRtcpFb),i.codecs.push(l),l.name.toUpperCase()){case"RED":case"ULPFEC":i.fecMechanisms.push(l.name.toUpperCase());break}}}e.matchPrefix(t,"a=extmap:").forEach(a=>{i.headerExtensions.push(e.parseExtmap(a))});const s=e.matchPrefix(t,"a=rtcp-fb:* ").map(e.parseRtcpFb);return i.codecs.forEach(a=>{s.forEach(c=>{a.rtcpFeedback.find(l=>l.type===c.type&&l.parameter===c.parameter)||a.rtcpFeedback.push(c)})}),i},e.writeRtpDescription=function(t,i){let r="";r+="m="+t+" ",r+=i.codecs.length>0?"9":"0",r+=" "+(i.profile||"UDP/TLS/RTP/SAVPF")+" ",r+=i.codecs.map(s=>s.preferredPayloadType!==void 0?s.preferredPayloadType:s.payloadType).join(" ")+`\r
19
+ `),i},e.parseRtpParameters=function(t){const i={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},s=e.splitLines(t)[0].split(" ");i.profile=s[2];for(let o=3;o<s.length;o++){const c=s[o],l=e.matchPrefix(t,"a=rtpmap:"+c+" ")[0];if(l){const u=e.parseRtpMap(l),d=e.matchPrefix(t,"a=fmtp:"+c+" ");switch(u.parameters=d.length?e.parseFmtp(d[0]):{},u.rtcpFeedback=e.matchPrefix(t,"a=rtcp-fb:"+c+" ").map(e.parseRtcpFb),i.codecs.push(u),u.name.toUpperCase()){case"RED":case"ULPFEC":i.fecMechanisms.push(u.name.toUpperCase());break}}}e.matchPrefix(t,"a=extmap:").forEach(o=>{i.headerExtensions.push(e.parseExtmap(o))});const a=e.matchPrefix(t,"a=rtcp-fb:* ").map(e.parseRtcpFb);return i.codecs.forEach(o=>{a.forEach(c=>{o.rtcpFeedback.find(u=>u.type===c.type&&u.parameter===c.parameter)||o.rtcpFeedback.push(c)})}),i},e.writeRtpDescription=function(t,i){let r="";r+="m="+t+" ",r+=i.codecs.length>0?"9":"0",r+=" "+(i.profile||"UDP/TLS/RTP/SAVPF")+" ",r+=i.codecs.map(a=>a.preferredPayloadType!==void 0?a.preferredPayloadType:a.payloadType).join(" ")+`\r
98
20
  `,r+=`c=IN IP4 0.0.0.0\r
99
21
  `,r+=`a=rtcp:9 IN IP4 0.0.0.0\r
100
- `,i.codecs.forEach(s=>{r+=e.writeRtpMap(s),r+=e.writeFmtp(s),r+=e.writeRtcpFb(s)});let o=0;return i.codecs.forEach(s=>{s.maxptime>o&&(o=s.maxptime)}),o>0&&(r+="a=maxptime:"+o+`\r
101
- `),i.headerExtensions&&i.headerExtensions.forEach(s=>{r+=e.writeExtmap(s)}),r},e.parseRtpEncodingParameters=function(t){const i=[],r=e.parseRtpParameters(t),o=r.fecMechanisms.indexOf("RED")!==-1,s=r.fecMechanisms.indexOf("ULPFEC")!==-1,a=e.matchPrefix(t,"a=ssrc:").map(h=>e.parseSsrcMedia(h)).filter(h=>h.attribute==="cname"),c=a.length>0&&a[0].ssrc;let u;const l=e.matchPrefix(t,"a=ssrc-group:FID").map(h=>h.substring(17).split(" ").map(m=>parseInt(m,10)));l.length>0&&l[0].length>1&&l[0][0]===c&&(u=l[0][1]),r.codecs.forEach(h=>{if(h.name.toUpperCase()==="RTX"&&h.parameters.apt){let p={ssrc:c,codecPayloadType:parseInt(h.parameters.apt,10)};c&&u&&(p.rtx={ssrc:u}),i.push(p),o&&(p=JSON.parse(JSON.stringify(p)),p.fec={ssrc:c,mechanism:s?"red+ulpfec":"red"},i.push(p))}}),i.length===0&&c&&i.push({ssrc:c});let d=e.matchPrefix(t,"b=");return d.length&&(d[0].indexOf("b=TIAS:")===0?d=parseInt(d[0].substring(7),10):d[0].indexOf("b=AS:")===0?d=parseInt(d[0].substring(5),10)*1e3*.95-50*40*8:d=void 0,i.forEach(h=>{h.maxBitrate=d})),i},e.parseRtcpParameters=function(t){const i={},r=e.matchPrefix(t,"a=ssrc:").map(a=>e.parseSsrcMedia(a)).filter(a=>a.attribute==="cname")[0];r&&(i.cname=r.value,i.ssrc=r.ssrc);const o=e.matchPrefix(t,"a=rtcp-rsize");i.reducedSize=o.length>0,i.compound=o.length===0;const s=e.matchPrefix(t,"a=rtcp-mux");return i.mux=s.length>0,i},e.writeRtcpParameters=function(t){let i="";return t.reducedSize&&(i+=`a=rtcp-rsize\r
22
+ `,i.codecs.forEach(a=>{r+=e.writeRtpMap(a),r+=e.writeFmtp(a),r+=e.writeRtcpFb(a)});let s=0;return i.codecs.forEach(a=>{a.maxptime>s&&(s=a.maxptime)}),s>0&&(r+="a=maxptime:"+s+`\r
23
+ `),i.headerExtensions&&i.headerExtensions.forEach(a=>{r+=e.writeExtmap(a)}),r},e.parseRtpEncodingParameters=function(t){const i=[],r=e.parseRtpParameters(t),s=r.fecMechanisms.indexOf("RED")!==-1,a=r.fecMechanisms.indexOf("ULPFEC")!==-1,o=e.matchPrefix(t,"a=ssrc:").map(h=>e.parseSsrcMedia(h)).filter(h=>h.attribute==="cname"),c=o.length>0&&o[0].ssrc;let l;const u=e.matchPrefix(t,"a=ssrc-group:FID").map(h=>h.substring(17).split(" ").map(p=>parseInt(p,10)));u.length>0&&u[0].length>1&&u[0][0]===c&&(l=u[0][1]),r.codecs.forEach(h=>{if(h.name.toUpperCase()==="RTX"&&h.parameters.apt){let f={ssrc:c,codecPayloadType:parseInt(h.parameters.apt,10)};c&&l&&(f.rtx={ssrc:l}),i.push(f),s&&(f=JSON.parse(JSON.stringify(f)),f.fec={ssrc:c,mechanism:a?"red+ulpfec":"red"},i.push(f))}}),i.length===0&&c&&i.push({ssrc:c});let d=e.matchPrefix(t,"b=");return d.length&&(d[0].indexOf("b=TIAS:")===0?d=parseInt(d[0].substring(7),10):d[0].indexOf("b=AS:")===0?d=parseInt(d[0].substring(5),10)*1e3*.95-50*40*8:d=void 0,i.forEach(h=>{h.maxBitrate=d})),i},e.parseRtcpParameters=function(t){const i={},r=e.matchPrefix(t,"a=ssrc:").map(o=>e.parseSsrcMedia(o)).filter(o=>o.attribute==="cname")[0];r&&(i.cname=r.value,i.ssrc=r.ssrc);const s=e.matchPrefix(t,"a=rtcp-rsize");i.reducedSize=s.length>0,i.compound=s.length===0;const a=e.matchPrefix(t,"a=rtcp-mux");return i.mux=a.length>0,i},e.writeRtcpParameters=function(t){let i="";return t.reducedSize&&(i+=`a=rtcp-rsize\r
102
24
  `),t.mux&&(i+=`a=rtcp-mux\r
103
25
  `),t.ssrc!==void 0&&t.cname&&(i+="a=ssrc:"+t.ssrc+" cname:"+t.cname+`\r
104
- `),i},e.parseMsid=function(t){let i;const r=e.matchPrefix(t,"a=msid:");if(r.length===1)return i=r[0].substring(7).split(" "),{stream:i[0],track:i[1]};const o=e.matchPrefix(t,"a=ssrc:").map(s=>e.parseSsrcMedia(s)).filter(s=>s.attribute==="msid");if(o.length>0)return i=o[0].value.split(" "),{stream:i[0],track:i[1]}},e.parseSctpDescription=function(t){const i=e.parseMLine(t),r=e.matchPrefix(t,"a=max-message-size:");let o;r.length>0&&(o=parseInt(r[0].substring(19),10)),isNaN(o)&&(o=65536);const s=e.matchPrefix(t,"a=sctp-port:");if(s.length>0)return{port:parseInt(s[0].substring(12),10),protocol:i.fmt,maxMessageSize:o};const a=e.matchPrefix(t,"a=sctpmap:");if(a.length>0){const c=a[0].substring(10).split(" ");return{port:parseInt(c[0],10),protocol:c[1],maxMessageSize:o}}},e.writeSctpDescription=function(t,i){let r=[];return t.protocol!=="DTLS/SCTP"?r=["m="+t.kind+" 9 "+t.protocol+" "+i.protocol+`\r
26
+ `),i},e.parseMsid=function(t){let i;const r=e.matchPrefix(t,"a=msid:");if(r.length===1)return i=r[0].substring(7).split(" "),{stream:i[0],track:i[1]};const s=e.matchPrefix(t,"a=ssrc:").map(a=>e.parseSsrcMedia(a)).filter(a=>a.attribute==="msid");if(s.length>0)return i=s[0].value.split(" "),{stream:i[0],track:i[1]}},e.parseSctpDescription=function(t){const i=e.parseMLine(t),r=e.matchPrefix(t,"a=max-message-size:");let s;r.length>0&&(s=parseInt(r[0].substring(19),10)),isNaN(s)&&(s=65536);const a=e.matchPrefix(t,"a=sctp-port:");if(a.length>0)return{port:parseInt(a[0].substring(12),10),protocol:i.fmt,maxMessageSize:s};const o=e.matchPrefix(t,"a=sctpmap:");if(o.length>0){const c=o[0].substring(10).split(" ");return{port:parseInt(c[0],10),protocol:c[1],maxMessageSize:s}}},e.writeSctpDescription=function(t,i){let r=[];return t.protocol!=="DTLS/SCTP"?r=["m="+t.kind+" 9 "+t.protocol+" "+i.protocol+`\r
105
27
  `,`c=IN IP4 0.0.0.0\r
106
28
  `,"a=sctp-port:"+i.port+`\r
107
29
  `]:r=["m="+t.kind+" 9 "+t.protocol+" "+i.port+`\r
108
30
  `,`c=IN IP4 0.0.0.0\r
109
31
  `,"a=sctpmap:"+i.port+" "+i.protocol+` 65535\r
110
32
  `],i.maxMessageSize!==void 0&&r.push("a=max-message-size:"+i.maxMessageSize+`\r
111
- `),r.join("")},e.generateSessionId=function(){return Math.random().toString().substr(2,22)},e.writeSessionBoilerplate=function(t,i,r){let o;const s=i!==void 0?i:2;return t?o=t:o=e.generateSessionId(),`v=0\r
112
- o=`+(r||"thisisadapterortc")+" "+o+" "+s+` IN IP4 127.0.0.1\r
33
+ `),r.join("")},e.generateSessionId=function(){return Math.random().toString().substr(2,22)},e.writeSessionBoilerplate=function(t,i,r){let s;const a=i!==void 0?i:2;return t?s=t:s=e.generateSessionId(),`v=0\r
34
+ o=`+(r||"thisisadapterortc")+" "+s+" "+a+` IN IP4 127.0.0.1\r
113
35
  s=-\r
114
36
  t=0 0\r
115
- `},e.getDirection=function(t,i){const r=e.splitLines(t);for(let o=0;o<r.length;o++)switch(r[o]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[o].substring(2)}return i?e.getDirection(i):"sendrecv"},e.getKind=function(t){return e.splitLines(t)[0].split(" ")[0].substring(2)},e.isRejected=function(t){return t.split(" ",2)[1]==="0"},e.parseMLine=function(t){const r=e.splitLines(t)[0].substring(2).split(" ");return{kind:r[0],port:parseInt(r[1],10),protocol:r[2],fmt:r.slice(3).join(" ")}},e.parseOLine=function(t){const r=e.matchPrefix(t,"o=")[0].substring(2).split(" ");return{username:r[0],sessionId:r[1],sessionVersion:parseInt(r[2],10),netType:r[3],addressType:r[4],address:r[5]}},e.isValidSDP=function(t){if(typeof t!="string"||t.length===0)return!1;const i=e.splitLines(t);for(let r=0;r<i.length;r++)if(i[r].length<2||i[r].charAt(1)!=="=")return!1;return!0},n.exports=e}(lp)),lp.exports}var aS=l3(),oo=ZL(aS),d3=wD({__proto__:null,default:oo},[aS]);function cu(n){if(!n.RTCIceCandidate||n.RTCIceCandidate&&"foundation"in n.RTCIceCandidate.prototype)return;const e=n.RTCIceCandidate;n.RTCIceCandidate=function(i){if(typeof i=="object"&&i.candidate&&i.candidate.indexOf("a=")===0&&(i=JSON.parse(JSON.stringify(i)),i.candidate=i.candidate.substring(2)),i.candidate&&i.candidate.length){const r=new e(i),o=oo.parseCandidate(i.candidate);for(const s in o)s in r||Object.defineProperty(r,s,{value:o[s]});return r.toJSON=function(){return{candidate:r.candidate,sdpMid:r.sdpMid,sdpMLineIndex:r.sdpMLineIndex,usernameFragment:r.usernameFragment}},r}return new e(i)},n.RTCIceCandidate.prototype=e.prototype,ir(n,"icecandidate",t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new n.RTCIceCandidate(t.candidate),writable:"false"}),t))}function dp(n){!n.RTCIceCandidate||n.RTCIceCandidate&&"relayProtocol"in n.RTCIceCandidate.prototype||ir(n,"icecandidate",e=>{if(e.candidate){const t=oo.parseCandidate(e.candidate.candidate);t.type==="relay"&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e})}function uu(n,e){if(!n.RTCPeerConnection)return;"sctp"in n.RTCPeerConnection.prototype||Object.defineProperty(n.RTCPeerConnection.prototype,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp}});const t=function(a){if(!a||!a.sdp)return!1;const c=oo.splitSections(a.sdp);return c.shift(),c.some(u=>{const l=oo.parseMLine(u);return l&&l.kind==="application"&&l.protocol.indexOf("SCTP")!==-1})},i=function(a){const c=a.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(c===null||c.length<2)return-1;const u=parseInt(c[1],10);return u!==u?-1:u},r=function(a){let c=65536;return e.browser==="firefox"&&(e.version<57?a===-1?c=16384:c=2147483637:e.version<60?c=e.version===57?65535:65536:c=2147483637),c},o=function(a,c){let u=65536;e.browser==="firefox"&&e.version===57&&(u=65535);const l=oo.matchPrefix(a.sdp,"a=max-message-size:");return l.length>0?u=parseInt(l[0].substring(19),10):e.browser==="firefox"&&c!==-1&&(u=2147483637),u},s=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,e.browser==="chrome"&&e.version>=76){const{sdpSemantics:c}=this.getConfiguration();c==="plan-b"&&Object.defineProperty(this,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp},enumerable:!0,configurable:!0})}if(t(arguments[0])){const c=i(arguments[0]),u=r(c),l=o(arguments[0],c);let d;u===0&&l===0?d=Number.POSITIVE_INFINITY:u===0||l===0?d=Math.max(u,l):d=Math.min(u,l);const h={};Object.defineProperty(h,"maxMessageSize",{get(){return d}}),this._sctp=h}return s.apply(this,arguments)}}function lu(n){if(!(n.RTCPeerConnection&&"createDataChannel"in n.RTCPeerConnection.prototype))return;function e(i,r){const o=i.send;i.send=function(){const a=arguments[0],c=a.length||a.size||a.byteLength;if(i.readyState==="open"&&r.sctp&&c>r.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+r.sctp.maxMessageSize+" bytes)");return o.apply(i,arguments)}}const t=n.RTCPeerConnection.prototype.createDataChannel;n.RTCPeerConnection.prototype.createDataChannel=function(){const r=t.apply(this,arguments);return e(r,this),r},ir(n,"datachannel",i=>(e(i.channel,i.target),i))}function hp(n){if(!n.RTCPeerConnection||"connectionState"in n.RTCPeerConnection.prototype)return;const e=n.RTCPeerConnection.prototype;Object.defineProperty(e,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(e,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(t){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),t&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=t)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(t=>{const i=e[t];e[t]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=r=>{const o=r.target;if(o._lastConnectionState!==o.connectionState){o._lastConnectionState=o.connectionState;const s=new Event("connectionstatechange",r);o.dispatchEvent(s)}return r},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),i.apply(this,arguments)}})}function pp(n,e){if(!n.RTCPeerConnection||e.browser==="chrome"&&e.version>=71||e.browser==="safari"&&e.version>=605)return;const t=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(r){if(r&&r.sdp&&r.sdp.indexOf(`
116
- a=extmap-allow-mixed`)!==-1){const o=r.sdp.split(`
117
- `).filter(s=>s.trim()!=="a=extmap-allow-mixed").join(`
118
- `);n.RTCSessionDescription&&r instanceof n.RTCSessionDescription?arguments[0]=new n.RTCSessionDescription({type:r.type,sdp:o}):r.sdp=o}return t.apply(this,arguments)}}function du(n,e){if(!(n.RTCPeerConnection&&n.RTCPeerConnection.prototype))return;const t=n.RTCPeerConnection.prototype.addIceCandidate;!t||t.length===0||(n.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(e.browser==="chrome"&&e.version<78||e.browser==="firefox"&&e.version<68||e.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():t.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}function hu(n,e){if(!(n.RTCPeerConnection&&n.RTCPeerConnection.prototype))return;const t=n.RTCPeerConnection.prototype.setLocalDescription;!t||t.length===0||(n.RTCPeerConnection.prototype.setLocalDescription=function(){let r=arguments[0]||{};if(typeof r!="object"||r.type&&r.sdp)return t.apply(this,arguments);if(r={type:r.type,sdp:r.sdp},!r.type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":r.type="offer";break;default:r.type="answer";break}return r.sdp||r.type!=="offer"&&r.type!=="answer"?t.apply(this,[r]):(r.type==="offer"?this.createOffer:this.createAnswer).apply(this).then(s=>t.apply(this,[s]))})}var h3=Object.freeze({__proto__:null,removeExtmapAllowMixed:pp,shimAddIceCandidateNullOrEmpty:du,shimConnectionState:hp,shimMaxMessageSize:uu,shimParameterlessSetLocalDescription:hu,shimRTCIceCandidate:cu,shimRTCIceCandidateRelayProtocol:dp,shimSendThrowTypeError:lu});function p3(){let{window:n}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0};const t=Tk,i=c3(n),r={browserDetails:i,commonShim:h3,extractVersion:au,disableLog:s3,disableWarnings:a3,sdp:d3};switch(i.browser){case"chrome":if(!Fk||!cp||!e.shimChrome)return t("Chrome shim is not included in this adapter release."),r;if(i.version===null)return t("Chrome shim can not determine version, not shimming."),r;t("adapter.js shimming chrome."),r.browserShim=Fk,du(n,i),hu(n),Pk(n,i),Ok(n),cp(n,i),Ak(n),Lk(n,i),Mk(n),Nk(n),Uk(n,i),cu(n),dp(n),hp(n),uu(n,i),lu(n),pp(n,i);break;case"firefox":if(!Yk||!up||!e.shimFirefox)return t("Firefox shim is not included in this adapter release."),r;t("adapter.js shimming firefox."),r.browserShim=Yk,du(n,i),hu(n),Bk(n,i),up(n,i),jk(n),qk(n),Vk(n),zk(n),Wk(n),Gk(n),$k(n),Hk(n),Kk(n),cu(n),hp(n),uu(n,i),lu(n);break;case"safari":if(!oS||!e.shimSafari)return t("Safari shim is not included in this adapter release."),r;t("adapter.js shimming safari."),r.browserShim=oS,du(n,i),hu(n),tS(n),iS(n),Zk(n),Xk(n),Jk(n),nS(n),Qk(n),rS(n),cu(n),dp(n),uu(n,i),lu(n),pp(n,i);break;default:t("Unsupported browser!");break}return r}p3({window:typeof window>"u"?void 0:window});const f3=10,pu="lk_e2ee",m3={sharedKey:!1,ratchetSalt:"LKFrameEncryptionKey",ratchetWindowSize:8,failureTolerance:f3,keyringSize:16};var Ei;(function(n){n.SetKey="setKey",n.RatchetRequest="ratchetRequest",n.KeyRatcheted="keyRatcheted"})(Ei||(Ei={}));var cS;(function(n){n.KeyRatcheted="keyRatcheted"})(cS||(cS={}));var Ii;(function(n){n.ParticipantEncryptionStatusChanged="participantEncryptionStatusChanged",n.EncryptionError="encryptionError"})(Ii||(Ii={}));var uS;(function(n){n.Error="cryptorError"})(uS||(uS={}));function g3(){return v3()||fp()}function fp(){return typeof window.RTCRtpScriptTransform<"u"}function v3(){return typeof window.RTCRtpSender<"u"&&typeof window.RTCRtpSender.prototype.createEncodedStreams<"u"}class v4 extends Mn.EventEmitter{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(),this.onKeyRatcheted=(t,i,r)=>{le.debug("key ratcheted event received",{ratchetResult:t,participantId:i,keyIndex:r})},this.keyInfoMap=new Map,this.options=Object.assign(Object.assign({},m3),e),this.on(Ei.KeyRatcheted,this.onKeyRatcheted)}onSetEncryptionKey(e,t,i){const r={key:e,participantIdentity:t,keyIndex:i};if(!this.options.sharedKey&&!t)throw new Error("participant identity needs to be passed for encryption key if sharedKey option is false");this.keyInfoMap.set("".concat(t??"shared","-").concat(i??0),r),this.emit(Ei.SetKey,r)}getKeys(){return Array.from(this.keyInfoMap.values())}getOptions(){return this.options}ratchetKey(e,t){this.emit(Ei.RatchetRequest,e,t)}}class Ri extends Error{constructor(e,t){super(t||"an error has occured"),this.name="LiveKitError",this.code=e}}var pe;(function(n){n[n.NotAllowed=0]="NotAllowed",n[n.ServerUnreachable=1]="ServerUnreachable",n[n.InternalError=2]="InternalError",n[n.Cancelled=3]="Cancelled",n[n.LeaveRequest=4]="LeaveRequest"})(pe||(pe={}));class Ae extends Ri{constructor(e,t,i,r){super(1,e),this.name="ConnectionError",this.status=i,this.reason=t,this.context=r,this.reasonName=pe[t]}}class mp extends Ri{constructor(e){super(21,e??"device is unsupported"),this.name="DeviceUnsupportedError"}}class Yn extends Ri{constructor(e){super(20,e??"track is invalid"),this.name="TrackInvalidError"}}class y3 extends Ri{constructor(e){super(10,e??"unsupported server"),this.name="UnsupportedServer"}}class lt extends Ri{constructor(e){super(12,e??"unexpected connection state"),this.name="UnexpectedConnectionState"}}class gp extends Ri{constructor(e){super(13,e??"unable to negotiate"),this.name="NegotiationError"}}class vp extends Ri{constructor(e,t){super(15,e),this.name="PublishTrackError",this.status=t}}class lS extends Ri{constructor(e,t){super(15,e),this.reason=t,this.reasonName=typeof t=="string"?t:rp[t]}}var fu;(function(n){n.PermissionDenied="PermissionDenied",n.NotFound="NotFound",n.DeviceInUse="DeviceInUse",n.Other="Other"})(fu||(fu={})),function(n){function e(t){if(t&&"name"in t)return t.name==="NotFoundError"||t.name==="DevicesNotFoundError"?n.NotFound:t.name==="NotAllowedError"||t.name==="PermissionDeniedError"?n.PermissionDenied:t.name==="NotReadableError"||t.name==="TrackStartError"?n.DeviceInUse:n.Other}n.getFailure=e}(fu||(fu={}));var dS;(function(n){n[n.InvalidKey=0]="InvalidKey",n[n.MissingKey=1]="MissingKey",n[n.InternalError=2]="InternalError"})(dS||(dS={}));var U;(function(n){n.Connected="connected",n.Reconnecting="reconnecting",n.SignalReconnecting="signalReconnecting",n.Reconnected="reconnected",n.Disconnected="disconnected",n.ConnectionStateChanged="connectionStateChanged",n.Moved="moved",n.MediaDevicesChanged="mediaDevicesChanged",n.ParticipantConnected="participantConnected",n.ParticipantDisconnected="participantDisconnected",n.TrackPublished="trackPublished",n.TrackSubscribed="trackSubscribed",n.TrackSubscriptionFailed="trackSubscriptionFailed",n.TrackUnpublished="trackUnpublished",n.TrackUnsubscribed="trackUnsubscribed",n.TrackMuted="trackMuted",n.TrackUnmuted="trackUnmuted",n.LocalTrackPublished="localTrackPublished",n.LocalTrackUnpublished="localTrackUnpublished",n.LocalAudioSilenceDetected="localAudioSilenceDetected",n.ActiveSpeakersChanged="activeSpeakersChanged",n.ParticipantMetadataChanged="participantMetadataChanged",n.ParticipantNameChanged="participantNameChanged",n.ParticipantAttributesChanged="participantAttributesChanged",n.ParticipantActive="participantActive",n.RoomMetadataChanged="roomMetadataChanged",n.DataReceived="dataReceived",n.SipDTMFReceived="sipDTMFReceived",n.TranscriptionReceived="transcriptionReceived",n.ConnectionQualityChanged="connectionQualityChanged",n.TrackStreamStateChanged="trackStreamStateChanged",n.TrackSubscriptionPermissionChanged="trackSubscriptionPermissionChanged",n.TrackSubscriptionStatusChanged="trackSubscriptionStatusChanged",n.AudioPlaybackStatusChanged="audioPlaybackChanged",n.VideoPlaybackStatusChanged="videoPlaybackChanged",n.MediaDevicesError="mediaDevicesError",n.ParticipantPermissionsChanged="participantPermissionsChanged",n.SignalConnected="signalConnected",n.RecordingStatusChanged="recordingStatusChanged",n.ParticipantEncryptionStatusChanged="participantEncryptionStatusChanged",n.EncryptionError="encryptionError",n.DCBufferStatusChanged="dcBufferStatusChanged",n.ActiveDeviceChanged="activeDeviceChanged",n.ChatMessage="chatMessage",n.LocalTrackSubscribed="localTrackSubscribed",n.MetricsReceived="metricsReceived"})(U||(U={}));var q;(function(n){n.TrackPublished="trackPublished",n.TrackSubscribed="trackSubscribed",n.TrackSubscriptionFailed="trackSubscriptionFailed",n.TrackUnpublished="trackUnpublished",n.TrackUnsubscribed="trackUnsubscribed",n.TrackMuted="trackMuted",n.TrackUnmuted="trackUnmuted",n.LocalTrackPublished="localTrackPublished",n.LocalTrackUnpublished="localTrackUnpublished",n.ParticipantMetadataChanged="participantMetadataChanged",n.ParticipantNameChanged="participantNameChanged",n.DataReceived="dataReceived",n.SipDTMFReceived="sipDTMFReceived",n.TranscriptionReceived="transcriptionReceived",n.IsSpeakingChanged="isSpeakingChanged",n.ConnectionQualityChanged="connectionQualityChanged",n.TrackStreamStateChanged="trackStreamStateChanged",n.TrackSubscriptionPermissionChanged="trackSubscriptionPermissionChanged",n.TrackSubscriptionStatusChanged="trackSubscriptionStatusChanged",n.MediaDevicesError="mediaDevicesError",n.AudioStreamAcquired="audioStreamAcquired",n.ParticipantPermissionsChanged="participantPermissionsChanged",n.PCTrackAdded="pcTrackAdded",n.AttributesChanged="attributesChanged",n.LocalTrackSubscribed="localTrackSubscribed",n.ChatMessage="chatMessage",n.Active="active"})(q||(q={}));var j;(function(n){n.TransportsCreated="transportsCreated",n.Connected="connected",n.Disconnected="disconnected",n.Resuming="resuming",n.Resumed="resumed",n.Restarting="restarting",n.Restarted="restarted",n.SignalResumed="signalResumed",n.SignalRestarted="signalRestarted",n.Closing="closing",n.MediaTrackAdded="mediaTrackAdded",n.ActiveSpeakersUpdate="activeSpeakersUpdate",n.DataPacketReceived="dataPacketReceived",n.RTPVideoMapUpdate="rtpVideoMapUpdate",n.DCBufferStatusChanged="dcBufferStatusChanged",n.ParticipantUpdate="participantUpdate",n.RoomUpdate="roomUpdate",n.SpeakersChanged="speakersChanged",n.StreamStateChanged="streamStateChanged",n.ConnectionQualityUpdate="connectionQualityUpdate",n.SubscriptionError="subscriptionError",n.SubscriptionPermissionUpdate="subscriptionPermissionUpdate",n.RemoteMute="remoteMute",n.SubscribedQualityUpdate="subscribedQualityUpdate",n.LocalTrackUnpublished="localTrackUnpublished",n.LocalTrackSubscribed="localTrackSubscribed",n.Offline="offline",n.SignalRequestResponse="signalRequestResponse",n.SignalConnected="signalConnected",n.RoomMoved="roomMoved"})(j||(j={}));var B;(function(n){n.Message="message",n.Muted="muted",n.Unmuted="unmuted",n.Restarted="restarted",n.Ended="ended",n.Subscribed="subscribed",n.Unsubscribed="unsubscribed",n.UpdateSettings="updateSettings",n.UpdateSubscription="updateSubscription",n.AudioPlaybackStarted="audioPlaybackStarted",n.AudioPlaybackFailed="audioPlaybackFailed",n.AudioSilenceDetected="audioSilenceDetected",n.VisibilityChanged="visibilityChanged",n.VideoDimensionsChanged="videoDimensionsChanged",n.VideoPlaybackStarted="videoPlaybackStarted",n.VideoPlaybackFailed="videoPlaybackFailed",n.ElementAttached="elementAttached",n.ElementDetached="elementDetached",n.UpstreamPaused="upstreamPaused",n.UpstreamResumed="upstreamResumed",n.SubscriptionPermissionChanged="subscriptionPermissionChanged",n.SubscriptionStatusChanged="subscriptionStatusChanged",n.SubscriptionFailed="subscriptionFailed",n.TrackProcessorUpdate="trackProcessorUpdate",n.AudioTrackFeatureUpdate="audioTrackFeatureUpdate",n.TranscriptionReceived="transcriptionReceived",n.TimeSyncUpdate="timeSyncUpdate"})(B||(B={}));function b3(n){return typeof n>"u"?n:typeof structuredClone=="function"?structuredClone(n):JSON.parse(JSON.stringify(n))}const _3=/version\/(\d+(\.?_?\d+)+)/i;let yp;function fn(n){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;if(typeof n>"u"&&typeof navigator>"u")return;const t=(n??navigator.userAgent).toLowerCase();if(yp===void 0||e){const i=k3.find(r=>{let{test:o}=r;return o.test(t)});yp=i==null?void 0:i.describe(t)}return yp}const k3=[{test:/firefox|iceweasel|fxios/i,describe(n){return{name:"Firefox",version:mu(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,n),os:n.toLowerCase().includes("fxios")?"iOS":void 0,osVersion:bp(n)}}},{test:/chrom|crios|crmo/i,describe(n){return{name:"Chrome",version:mu(/(?:chrome|chromium|crios|crmo)\/(\d+(\.?_?\d+)+)/i,n),os:n.toLowerCase().includes("crios")?"iOS":void 0,osVersion:bp(n)}}},{test:/safari|applewebkit/i,describe(n){return{name:"Safari",version:mu(_3,n),os:n.includes("mobile/")?"iOS":"macOS",osVersion:bp(n)}}}];function mu(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1;const i=e.match(n);return i&&i.length>=t&&i[t]||""}function bp(n){return n.includes("mac os")?mu(/\(.+?(\d+_\d+(:?_\d+)?)/,n,1).replace(/_/g,"."):void 0}var S3="2.13.0";const w3=S3,C3=16;class _t{}_t.setTimeout=function(){return setTimeout(...arguments)},_t.setInterval=function(){return setInterval(...arguments)},_t.clearTimeout=function(){return clearTimeout(...arguments)},_t.clearInterval=function(){return clearInterval(...arguments)};const T3=5e3,ms=[];var en;(function(n){n[n.LOW=0]="LOW",n[n.MEDIUM=1]="MEDIUM",n[n.HIGH=2]="HIGH"})(en||(en={}));class N extends Mn.EventEmitter{constructor(e,t){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var r;super(),this.attachedElements=[],this.isMuted=!1,this.streamState=N.StreamState.Active,this.isInBackground=!1,this._currentBitrate=0,this.log=le,this.appVisibilityChangedListener=()=>{this.backgroundTimeout&&clearTimeout(this.backgroundTimeout),document.visibilityState==="hidden"?this.backgroundTimeout=setTimeout(()=>this.handleAppVisibilityChanged(),T3):this.handleAppVisibilityChanged()},this.log=Kn((r=i.loggerName)!==null&&r!==void 0?r:pn.Track),this.loggerContextCb=i.loggerContextCb,this.setMaxListeners(100),this.kind=t,this._mediaStreamTrack=e,this._mediaStreamID=e.id,this.source=N.Source.Unknown}get logContext(){var e;return Object.assign(Object.assign({},(e=this.loggerContextCb)===null||e===void 0?void 0:e.call(this)),we(this))}get currentBitrate(){return this._currentBitrate}get mediaStreamTrack(){return this._mediaStreamTrack}get mediaStreamID(){return this._mediaStreamID}attach(e){let t="audio";this.kind===N.Kind.Video&&(t="video"),this.attachedElements.length===0&&this.kind===N.Kind.Video&&this.addAppVisibilityListener(),e||(t==="audio"&&(ms.forEach(o=>{o.parentElement===null&&!e&&(e=o)}),e&&ms.splice(ms.indexOf(e),1)),e||(e=document.createElement(t))),this.attachedElements.includes(e)||this.attachedElements.push(e),so(this.mediaStreamTrack,e);const i=e.srcObject.getTracks(),r=i.some(o=>o.kind==="audio");return e.play().then(()=>{this.emit(r?B.AudioPlaybackStarted:B.VideoPlaybackStarted)}).catch(o=>{o.name==="NotAllowedError"?this.emit(r?B.AudioPlaybackFailed:B.VideoPlaybackFailed,o):o.name==="AbortError"?le.debug("".concat(r?"audio":"video"," playback aborted, likely due to new play request")):le.warn("could not playback ".concat(r?"audio":"video"),o),r&&e&&i.some(s=>s.kind==="video")&&o.name==="NotAllowedError"&&(e.muted=!0,e.play().catch(()=>{}))}),this.emit(B.ElementAttached,e),e}detach(e){try{if(e){ao(this.mediaStreamTrack,e);const i=this.attachedElements.indexOf(e);return i>=0&&(this.attachedElements.splice(i,1),this.recycleElement(e),this.emit(B.ElementDetached,e)),e}const t=[];return this.attachedElements.forEach(i=>{ao(this.mediaStreamTrack,i),t.push(i),this.recycleElement(i),this.emit(B.ElementDetached,i)}),this.attachedElements=[],t}finally{this.attachedElements.length===0&&this.removeAppVisibilityListener()}}stop(){this.stopMonitor(),this._mediaStreamTrack.stop()}enable(){this._mediaStreamTrack.enabled=!0}disable(){this._mediaStreamTrack.enabled=!1}stopMonitor(){this.monitorInterval&&clearInterval(this.monitorInterval),this.timeSyncHandle&&cancelAnimationFrame(this.timeSyncHandle)}updateLoggerOptions(e){e.loggerName&&(this.log=Kn(e.loggerName)),e.loggerContextCb&&(this.loggerContextCb=e.loggerContextCb)}recycleElement(e){if(e instanceof HTMLAudioElement){let t=!0;e.pause(),ms.forEach(i=>{i.parentElement||(t=!1)}),t&&ms.push(e)}}handleAppVisibilityChanged(){return T(this,void 0,void 0,function*(){this.isInBackground=document.visibilityState==="hidden",!this.isInBackground&&this.kind===N.Kind.Video&&setTimeout(()=>this.attachedElements.forEach(e=>e.play().catch(()=>{})),0)})}addAppVisibilityListener(){Wt()?(this.isInBackground=document.visibilityState==="hidden",document.addEventListener("visibilitychange",this.appVisibilityChangedListener)):this.isInBackground=!1}removeAppVisibilityListener(){Wt()&&document.removeEventListener("visibilitychange",this.appVisibilityChangedListener)}}function so(n,e){let t;e.srcObject instanceof MediaStream?t=e.srcObject:t=new MediaStream;let i;n.kind==="audio"?i=t.getAudioTracks():i=t.getVideoTracks(),i.includes(n)||(i.forEach(r=>{t.removeTrack(r)}),t.addTrack(n)),(!Pi()||!(e instanceof HTMLVideoElement))&&(e.autoplay=!0),e.muted=t.getAudioTracks().length===0,e instanceof HTMLVideoElement&&(e.playsInline=!0),e.srcObject!==t&&(e.srcObject=t,(Pi()||co())&&e instanceof HTMLVideoElement&&setTimeout(()=>{e.srcObject=t,e.play().catch(()=>{})},0))}function ao(n,e){if(e.srcObject instanceof MediaStream){const t=e.srcObject;t.removeTrack(n),t.getTracks().length>0?e.srcObject=t:e.srcObject=null}}(function(n){let e;(function(u){u.Audio="audio",u.Video="video",u.Unknown="unknown"})(e=n.Kind||(n.Kind={}));let t;(function(u){u.Camera="camera",u.Microphone="microphone",u.ScreenShare="screen_share",u.ScreenShareAudio="screen_share_audio",u.Unknown="unknown"})(t=n.Source||(n.Source={}));let i;(function(u){u.Active="active",u.Paused="paused",u.Unknown="unknown"})(i=n.StreamState||(n.StreamState={}));function r(u){switch(u){case e.Audio:return un.AUDIO;case e.Video:return un.VIDEO;default:return un.DATA}}n.kindToProto=r;function o(u){switch(u){case un.AUDIO:return e.Audio;case un.VIDEO:return e.Video;default:return e.Unknown}}n.kindFromProto=o;function s(u){switch(u){case t.Camera:return at.CAMERA;case t.Microphone:return at.MICROPHONE;case t.ScreenShare:return at.SCREEN_SHARE;case t.ScreenShareAudio:return at.SCREEN_SHARE_AUDIO;default:return at.UNKNOWN}}n.sourceToProto=s;function a(u){switch(u){case at.CAMERA:return t.Camera;case at.MICROPHONE:return t.Microphone;case at.SCREEN_SHARE:return t.ScreenShare;case at.SCREEN_SHARE_AUDIO:return t.ScreenShareAudio;default:return t.Unknown}}n.sourceFromProto=a;function c(u){switch(u){case Jh.ACTIVE:return i.Active;case Jh.PAUSED:return i.Paused;default:return i.Unknown}}n.streamStateFromProto=c})(N||(N={}));class Re{constructor(e,t,i,r,o){if(typeof e=="object")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(t!==void 0&&i!==void 0)this.width=e,this.height=t,this.aspectRatio=e/t,this.encoding={maxBitrate:i,maxFramerate:r,priority:o};else throw new TypeError("Unsupported options: provide at least width, height and maxBitrate")}get resolution(){return{width:this.width,height:this.height,frameRate:this.encoding.maxFramerate,aspectRatio:this.aspectRatio}}}const x3=["vp8","h264"],E3=["vp8","h264","vp9","av1"];function I3(n){return!!x3.find(e=>e===n)}var hS;(function(n){n[n.PREFER_REGRESSION=0]="PREFER_REGRESSION",n[n.SIMULCAST=1]="SIMULCAST",n[n.REGRESSION=2]="REGRESSION"})(hS||(hS={}));var _p;(function(n){n.telephone={maxBitrate:12e3},n.speech={maxBitrate:24e3},n.music={maxBitrate:48e3},n.musicStereo={maxBitrate:64e3},n.musicHighQuality={maxBitrate:96e3},n.musicHighQualityStereo={maxBitrate:128e3}})(_p||(_p={}));const gs={h90:new Re(160,90,9e4,20),h180:new Re(320,180,16e4,20),h216:new Re(384,216,18e4,20),h360:new Re(640,360,45e4,20),h540:new Re(960,540,8e5,25),h720:new Re(1280,720,17e5,30),h1080:new Re(1920,1080,3e6,30),h1440:new Re(2560,1440,5e6,30),h2160:new Re(3840,2160,8e6,30)},kp={h120:new Re(160,120,7e4,20),h180:new Re(240,180,125e3,20),h240:new Re(320,240,14e4,20),h360:new Re(480,360,33e4,20),h480:new Re(640,480,5e5,20),h540:new Re(720,540,6e5,25),h720:new Re(960,720,13e5,30),h1080:new Re(1440,1080,23e5,30),h1440:new Re(1920,1440,38e5,30)},Sp={h360fps3:new Re(640,360,2e5,3,"medium"),h360fps15:new Re(640,360,4e5,15,"medium"),h720fps5:new Re(1280,720,8e5,5,"medium"),h720fps15:new Re(1280,720,15e5,15,"medium"),h720fps30:new Re(1280,720,2e6,30,"medium"),h1080fps15:new Re(1920,1080,25e5,15,"medium"),h1080fps30:new Re(1920,1080,5e6,30,"medium"),original:new Re(0,0,7e6,30,"medium")},R3="|",pS="https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension";function P3(n){const e=n.split(R3);return e.length>1?[e[0],n.substr(e[0].length+1)]:[n,""]}function qt(n){return T(this,void 0,void 0,function*(){return new Promise(e=>_t.setTimeout(e,n))})}function wp(){return"addTransceiver"in RTCPeerConnection.prototype}function Cp(){return"addTrack"in RTCPeerConnection.prototype}function O3(){if(!("getCapabilities"in RTCRtpSender)||Pi())return!1;const n=RTCRtpSender.getCapabilities("video");let e=!1;if(n){for(const t of n.codecs)if(t.mimeType==="video/AV1"){e=!0;break}}return e}function A3(){if(!("getCapabilities"in RTCRtpSender)||co())return!1;if(Pi()){const t=fn();if(t!=null&&t.version&&rr(t.version,"16")<0)return!1}const n=RTCRtpSender.getCapabilities("video");let e=!1;if(n){for(const t of n.codecs)if(t.mimeType==="video/VP9"){e=!0;break}}return e}function vs(n){return n==="av1"||n==="vp9"}function Tp(n){return document?(n||(n=document.createElement("audio")),"setSinkId"in n):!1}function M3(){return typeof RTCPeerConnection>"u"?!1:wp()||Cp()}function co(){var n;return((n=fn())===null||n===void 0?void 0:n.name)==="Firefox"}function Pi(){var n;return((n=fn())===null||n===void 0?void 0:n.name)==="Safari"}function N3(){const n=fn();return(n==null?void 0:n.name)==="Safari"&&n.version.startsWith("17.")}function fS(){var n,e;return Wt()?(e=(n=navigator.userAgentData)===null||n===void 0?void 0:n.mobile)!==null&&e!==void 0?e:/Tablet|iPad|Mobile|Android|BlackBerry/.test(navigator.userAgent):!1}function D3(){const n=fn(),e="17.2";if(n)return n.name!=="Safari"&&n.os!=="iOS"||n.os==="iOS"&&n.osVersion&&rr(e,n.osVersion)>=0?!0:n.name==="Safari"&&rr(e,n.version)>=0}function Wt(){return typeof document<"u"}function Nn(){return navigator.product=="ReactNative"}function xp(n){return n.hostname.endsWith(".livekit.cloud")||n.hostname.endsWith(".livekit.run")}function mS(){if(global&&global.LiveKitReactNativeGlobal)return global.LiveKitReactNativeGlobal}function gS(){if(!Nn())return;let n=mS();if(n)return n.platform}function vS(){if(Wt())return window.devicePixelRatio;if(Nn()){let n=mS();if(n)return n.devicePixelRatio}return 1}function rr(n,e){const t=n.split("."),i=e.split("."),r=Math.min(t.length,i.length);for(let o=0;o<r;++o){const s=parseInt(t[o],10),a=parseInt(i[o],10);if(s>a)return 1;if(s<a)return-1;if(o===r-1&&s===a)return 0}return n===""&&e!==""?-1:e===""?1:t.length==i.length?0:t.length<i.length?-1:1}function L3(n){for(const e of n)e.target.handleResize(e)}function U3(n){for(const e of n)e.target.handleVisibilityChanged(e)}let Ep=null;const yS=()=>(Ep||(Ep=new ResizeObserver(L3)),Ep);let Ip=null;const bS=()=>(Ip||(Ip=new IntersectionObserver(U3,{root:null,rootMargin:"0px"})),Ip);function F3(){var n;const e=new EL({sdk:ik.JS,protocol:C3,version:w3});return Nn()&&(e.os=(n=gS())!==null&&n!==void 0?n:""),e}function _S(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:16,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:16,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;const r=document.createElement("canvas");r.width=n,r.height=e;const o=r.getContext("2d");o==null||o.fillRect(0,0,r.width,r.height),i&&o&&(o.beginPath(),o.arc(n/2,e/2,50,0,Math.PI*2,!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=t,a}let ys;function Rp(){if(!ys){const n=new AudioContext,e=n.createOscillator(),t=n.createGain();t.gain.setValueAtTime(0,0);const i=n.createMediaStreamDestination();if(e.connect(t),t.connect(i),e.start(),[ys]=i.stream.getAudioTracks(),!ys)throw Error("Could not get empty media stream audio track");ys.enabled=!1}return ys.clone()}class Pp{constructor(e,t){this.onFinally=t,this.promise=new Promise((i,r)=>T(this,void 0,void 0,function*(){this.resolve=i,this.reject=r,e&&(yield e(i,r))})).finally(()=>{var i;return(i=this.onFinally)===null||i===void 0?void 0:i.call(this)})}}function B3(n){return E3.includes(n)}function Oi(n){if(typeof n=="string"||typeof n=="number")return n;if(Array.isArray(n))return n[0];if(n.exact)return Array.isArray(n.exact)?n.exact[0]:n.exact;if(n.ideal)return Array.isArray(n.ideal)?n.ideal[0]:n.ideal;throw Error("could not unwrap constraint")}function j3(n){return n.startsWith("http")?n.replace(/^(http)/,"ws"):n}function Op(n){return n.startsWith("ws")?n.replace(/^(ws)/,"http"):n}function V3(n,e){return n.segments.map(t=>{let{id:i,text:r,language:o,startTime:s,endTime:a,final:c}=t;var u;const l=(u=e.get(i))!==null&&u!==void 0?u:Date.now(),d=Date.now();return c?e.delete(i):e.set(i,l),{id:i,text:r,startTime:Number.parseInt(s.toString()),endTime:Number.parseInt(a.toString()),final:c,language:o,firstReceivedTime:l,lastReceivedTime:d}})}function z3(n){const{id:e,timestamp:t,message:i,editTimestamp:r}=n;return{id:e,timestamp:Number.parseInt(t.toString()),editTimestamp:r?Number.parseInt(r.toString()):void 0,message:i}}function kS(n){switch(n.reason){case pe.LeaveRequest:return n.context;case pe.Cancelled:return ln.CLIENT_INITIATED;case pe.NotAllowed:return ln.USER_REJECTED;case pe.ServerUnreachable:return ln.JOIN_FAILURE;default:return ln.UNKNOWN_REASON}}function gu(n){return n!==void 0?Number(n):void 0}function or(n){return n!==void 0?BigInt(n):void 0}function uo(n){return!!n&&!(n instanceof MediaStreamTrack)&&n.isLocal}function Xn(n){return!!n&&n.kind==N.Kind.Audio}function lo(n){return!!n&&n.kind==N.Kind.Video}function Ai(n){return uo(n)&&lo(n)}function sr(n){return uo(n)&&Xn(n)}function Ap(n){return!!n&&!n.isLocal}function q3(n){return!!n&&!n.isLocal}function Mp(n){return Ap(n)&&lo(n)}function W3(n){return n.isLocal}function G3(n,e){const t=[];let i=new TextEncoder().encode(n);for(;i.length>e;){let r=e;for(;r>0;){const o=i[r];if(o!==void 0&&(o&192)!==128)break;r--}t.push(i.slice(0,r)),i=i.slice(r)}return i.length>0&&t.push(i),t}function SS(n,e,t){var i,r,o,s;const{optionsWithoutProcessor:a,audioProcessor:c,videoProcessor:u}=xS(n??{}),l=e==null?void 0:e.processor,d=t==null?void 0:t.processor,h=a??{};return h.audio===!0&&(h.audio={}),h.video===!0&&(h.video={}),h.audio&&(Np(h.audio,e),(i=(o=h.audio).deviceId)!==null&&i!==void 0||(o.deviceId={ideal:"default"}),(c||l)&&(h.audio.processor=c??l)),h.video&&(Np(h.video,t),(r=(s=h.video).deviceId)!==null&&r!==void 0||(s.deviceId={ideal:"default"}),(u||d)&&(h.video.processor=u??d)),h}function Np(n,e){return Object.keys(e).forEach(t=>{n[t]===void 0&&(n[t]=e[t])}),n}function Dp(n){var e,t,i,r;const o={};if(n.video)if(typeof n.video=="object"){const s={},a=s,c=n.video;Object.keys(c).forEach(u=>{switch(u){case"resolution":Np(a,c.resolution);break;default:a[u]=c[u]}}),o.video=s,(e=(i=o.video).deviceId)!==null&&e!==void 0||(i.deviceId={ideal:"default"})}else o.video=n.video?{deviceId:{ideal:"default"}}:!1;else o.video=!1;return n.audio?typeof n.audio=="object"?(o.audio=n.audio,(t=(r=o.audio).deviceId)!==null&&t!==void 0||(r.deviceId={ideal:"default"})):o.audio={deviceId:{ideal:"default"}}:o.audio=!1,o}function wS(n){return T(this,arguments,void 0,function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:200;return function*(){const i=CS();if(i){const r=i.createAnalyser();r.fftSize=2048;const o=r.frequencyBinCount,s=new Uint8Array(o);i.createMediaStreamSource(new MediaStream([e.mediaStreamTrack])).connect(r),yield qt(t),r.getByteTimeDomainData(s);const c=s.some(u=>u!==128&&u!==0);return i.close(),!c}return!1}()})}function CS(){var n;const e=typeof window<"u"&&(window.AudioContext||window.webkitAudioContext);if(e){const t=new e({latencyHint:"interactive"});if(t.state==="suspended"&&typeof window<"u"&&(!((n=window.document)===null||n===void 0)&&n.body)){const i=()=>T(this,void 0,void 0,function*(){var r;try{t.state==="suspended"&&(yield t.resume())}catch(o){console.warn("Error trying to auto-resume audio context",o)}(r=window.document.body)===null||r===void 0||r.removeEventListener("click",i)});window.document.body.addEventListener("click",i)}return t}}function $3(n){return n==="audioinput"?N.Source.Microphone:n==="videoinput"?N.Source.Camera:N.Source.Unknown}function TS(n){return n===N.Source.Microphone?"audioinput":n===N.Source.Camera?"videoinput":void 0}function H3(n){var e,t;let i=(e=n.video)!==null&&e!==void 0?e:!0;return n.resolution&&n.resolution.width>0&&n.resolution.height>0&&(i=typeof i=="boolean"?{}:i,Pi()?i=Object.assign(Object.assign({},i),{width:{max:n.resolution.width},height:{max:n.resolution.height},frameRate:n.resolution.frameRate}):i=Object.assign(Object.assign({},i),{width:{ideal:n.resolution.width},height:{ideal:n.resolution.height},frameRate:n.resolution.frameRate})),{audio:(t=n.audio)!==null&&t!==void 0?t:!1,video:i,controller:n.controller,selfBrowserSurface:n.selfBrowserSurface,surfaceSwitching:n.surfaceSwitching,systemAudio:n.systemAudio,preferCurrentTab:n.preferCurrentTab}}function vu(n){return n.split("/")[1].toLowerCase()}function K3(n){const e=[];return n.forEach(t=>{t.track!==void 0&&e.push(new np({cid:t.track.mediaStreamID,track:t.trackInfo}))}),e}function we(n){return"mediaStreamTrack"in n?{trackID:n.sid,source:n.source,muted:n.isMuted,enabled:n.mediaStreamTrack.enabled,kind:n.kind,streamID:n.mediaStreamID,streamTrackID:n.mediaStreamTrack.id}:{trackID:n.trackSid,enabled:n.isEnabled,muted:n.isMuted,trackInfo:Object.assign({mimeType:n.mimeType,name:n.trackName,encrypted:n.isEncrypted,kind:n.kind,source:n.source},n.track?we(n.track):{})}}function Y3(){return typeof RTCRtpReceiver<"u"&&"getSynchronizationSources"in RTCRtpReceiver}function X3(n,e){var t;n===void 0&&(n={}),e===void 0&&(e={});const i=[...Object.keys(e),...Object.keys(n)],r={};for(const o of i)n[o]!==e[o]&&(r[o]=(t=e[o])!==null&&t!==void 0?t:"");return r}function xS(n){const e=Object.assign({},n);let t,i;return typeof e.audio=="object"&&e.audio.processor&&(t=e.audio.processor,e.audio=Object.assign(Object.assign({},e.audio),{processor:void 0})),typeof e.video=="object"&&e.video.processor&&(i=e.video.processor,e.video=Object.assign(Object.assign({},e.video),{processor:void 0})),{audioProcessor:t,videoProcessor:i,optionsWithoutProcessor:b3(e)}}function J3(n){switch(n){case at.CAMERA:return N.Source.Camera;case at.MICROPHONE:return N.Source.Microphone;case at.SCREEN_SHARE:return N.Source.ScreenShare;case at.SCREEN_SHARE_AUDIO:return N.Source.ScreenShareAudio;default:return N.Source.Unknown}}class Z3 extends Mn.EventEmitter{constructor(e){super(),this.onWorkerMessage=t=>{var i,r;const{kind:o,data:s}=t.data;switch(o){case"error":le.error(s.error.message),this.emit(Ii.EncryptionError,s.error);break;case"initAck":s.enabled&&this.keyProvider.getKeys().forEach(a=>{this.postKey(a)});break;case"enable":if(s.enabled&&this.keyProvider.getKeys().forEach(a=>{this.postKey(a)}),this.encryptionEnabled!==s.enabled&&s.participantIdentity===((i=this.room)===null||i===void 0?void 0:i.localParticipant.identity))this.emit(Ii.ParticipantEncryptionStatusChanged,s.enabled,this.room.localParticipant),this.encryptionEnabled=s.enabled;else if(s.participantIdentity){const a=(r=this.room)===null||r===void 0?void 0:r.getParticipantByIdentity(s.participantIdentity);if(!a)throw TypeError("couldn't set encryption status, participant not found".concat(s.participantIdentity));this.emit(Ii.ParticipantEncryptionStatusChanged,s.enabled,a)}break;case"ratchetKey":this.keyProvider.emit(Ei.KeyRatcheted,s.ratchetResult,s.participantIdentity,s.keyIndex);break}},this.onWorkerError=t=>{le.error("e2ee worker encountered an error:",{error:t.error}),this.emit(Ii.EncryptionError,t.error)},this.keyProvider=e.keyProvider,this.worker=e.worker,this.encryptionEnabled=!1}setup(e){if(!g3())throw new mp("tried to setup end-to-end encryption on an unsupported browser");if(le.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:t3.getLevel()}};this.worker&&(le.info("initializing worker",{worker:this.worker}),this.worker.onmessage=this.onWorkerMessage,this.worker.onerror=this.onWorkerError,this.worker.postMessage(t))}}setParticipantCryptorEnabled(e,t){le.debug("set e2ee to ".concat(e," for participant ").concat(t)),this.postEnable(e,t)}setSifTrailer(e){!e||e.length===0?le.warn("ignoring server sent trailer as it's empty"):this.postSifTrailer(e)}setupEngine(e){e.on(j.RTPVideoMapUpdate,t=>{this.postRTPMap(t)})}setupEventListeners(e,t){e.on(U.TrackPublished,(i,r)=>this.setParticipantCryptorEnabled(i.trackInfo.encryption!==$t.NONE,r.identity)),e.on(U.ConnectionStateChanged,i=>{i===ve.Connected&&e.remoteParticipants.forEach(r=>{r.trackPublications.forEach(o=>{this.setParticipantCryptorEnabled(o.trackInfo.encryption!==$t.NONE,r.identity)})})}).on(U.TrackUnsubscribed,(i,r,o)=>{var s;const a={kind:"removeTransform",data:{participantIdentity:o.identity,trackId:i.mediaStreamID}};(s=this.worker)===null||s===void 0||s.postMessage(a)}).on(U.TrackSubscribed,(i,r,o)=>{this.setupE2EEReceiver(i,o.identity,r.trackInfo)}).on(U.SignalConnected,()=>{if(!this.room)throw new TypeError("expected room to be present on signal connect");t.getKeys().forEach(i=>{this.postKey(i)}),this.setParticipantCryptorEnabled(this.room.localParticipant.isE2EEEnabled,this.room.localParticipant.identity)}),e.localParticipant.on(q.LocalTrackPublished,i=>T(this,void 0,void 0,function*(){this.setupE2EESender(i.track,i.track.sender)})),t.on(Ei.SetKey,i=>this.postKey(i)).on(Ei.RatchetRequest,(i,r)=>this.postRatchetRequest(i,r))}postRatchetRequest(e,t){if(!this.worker)throw Error("could not ratchet key, worker is missing");const i={kind:"ratchetRequest",data:{participantIdentity:e,keyIndex:t}};this.worker.postMessage(i)}postKey(e){let{key:t,participantIdentity:i,keyIndex:r}=e;var o;if(!this.worker)throw Error("could not set key, worker is missing");const s={kind:"setKey",data:{participantIdentity:i,isPublisher:i===((o=this.room)===null||o===void 0?void 0:o.localParticipant.identity),key:t,keyIndex:r}};this.worker.postMessage(s)}postEnable(e,t){if(this.worker){const i={kind:"enable",data:{enabled:e,participantIdentity:t}};this.worker.postMessage(i)}else throw new ReferenceError("failed to enable e2ee, worker is not ready")}postRTPMap(e){var t;if(!this.worker)throw TypeError("could not post rtp map, worker is missing");if(!(!((t=this.room)===null||t===void 0)&&t.localParticipant.identity))throw TypeError("could not post rtp map, local participant identity is missing");const i={kind:"setRTPMap",data:{map:e,participantIdentity:this.room.localParticipant.identity}};this.worker.postMessage(i)}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,i){if(e.receiver){if(!(i!=null&&i.mimeType)||i.mimeType==="")throw new TypeError("MimeType missing from trackInfo, cannot set up E2EE cryptor");this.handleReceiver(e.receiver,e.mediaStreamID,t,e.kind==="video"?vu(i.mimeType):void 0)}}setupE2EESender(e,t){if(!uo(e)||!t){t||le.warn("early return because sender is not ready");return}this.handleSender(t,e.mediaStreamID,void 0)}handleReceiver(e,t,i,r){return T(this,void 0,void 0,function*(){if(this.worker){if(fp()){const o={kind:"decode",participantIdentity:i,trackId:t,codec:r};e.transform=new RTCRtpScriptTransform(this.worker,o)}else{if(pu in e&&r){const c={kind:"updateCodec",data:{trackId:t,codec:r,participantIdentity:i}};this.worker.postMessage(c);return}let o=e.writableStream,s=e.readableStream;if(!o||!s){const c=e.createEncodedStreams();e.writableStream=c.writable,o=c.writable,e.readableStream=c.readable,s=c.readable}const a={kind:"decode",data:{readableStream:s,writableStream:o,trackId:t,codec:r,participantIdentity:i}};this.worker.postMessage(a,[s,o])}e[pu]=!0}})}handleSender(e,t,i){var r;if(!(pu in e||!this.worker)){if(!(!((r=this.room)===null||r===void 0)&&r.localParticipant.identity)||this.room.localParticipant.identity==="")throw TypeError("local identity needs to be known in order to set up encrypted sender");if(fp()){le.info("initialize script transform");const o={kind:"encode",participantIdentity:this.room.localParticipant.identity,trackId:t,codec:i};e.transform=new RTCRtpScriptTransform(this.worker,o)}else{le.info("initialize encoded streams");const o=e.createEncodedStreams(),s={kind:"encode",data:{readableStream:o.readable,writableStream:o.writable,codec:i,trackId:t,participantIdentity:this.room.localParticipant.identity}};this.worker.postMessage(s,[o.readable,o.writable])}e[pu]=!0}}}const Lp="default";class ft{constructor(){this._previousDevices=[]}static getInstance(){return this.instance===void 0&&(this.instance=new ft),this.instance}get previousDevices(){return this._previousDevices}getDevices(e){return T(this,arguments,void 0,function(t){var i=this;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return function*(){var o;if(((o=ft.userMediaPromiseMap)===null||o===void 0?void 0:o.size)>0){le.debug("awaiting getUserMedia promise");try{t?yield ft.userMediaPromiseMap.get(t):yield Promise.all(ft.userMediaPromiseMap.values())}catch{le.warn("error waiting for media permissons")}}let s=yield navigator.mediaDevices.enumerateDevices();if(r&&!(Pi()&&i.hasDeviceInUse(t))&&(s.filter(c=>c.kind===t).length===0||s.some(c=>{const u=c.label==="",l=t?c.kind===t:!0;return u&&l}))){const c={video:t!=="audioinput"&&t!=="audiooutput",audio:t!=="videoinput"&&{deviceId:{ideal:"default"}}},u=yield navigator.mediaDevices.getUserMedia(c);s=yield navigator.mediaDevices.enumerateDevices(),u.getTracks().forEach(l=>{l.stop()})}return i._previousDevices=s,t&&(s=s.filter(a=>a.kind===t)),s}()})}normalizeDeviceId(e,t,i){return T(this,void 0,void 0,function*(){if(t!==Lp)return t;const r=yield this.getDevices(e),o=r.find(a=>a.deviceId===Lp);if(!o){le.warn("could not reliably determine default device");return}const s=r.find(a=>a.deviceId!==Lp&&a.groupId===(i??o.groupId));if(!s){le.warn("could not reliably determine default device");return}return s==null?void 0:s.deviceId})}hasDeviceInUse(e){return e?ft.userMediaPromiseMap.has(e):ft.userMediaPromiseMap.size>0}}ft.mediaDeviceKinds=["audioinput","audiooutput","videoinput"],ft.userMediaPromiseMap=new Map;var bs;(function(n){n[n.WAITING=0]="WAITING",n[n.RUNNING=1]="RUNNING",n[n.COMPLETED=2]="COMPLETED"})(bs||(bs={}));class Q3{constructor(){this.pendingTasks=new Map,this.taskMutex=new jt,this.nextTaskIndex=0}run(e){return T(this,void 0,void 0,function*(){const t={id:this.nextTaskIndex++,enqueuedAt:Date.now(),status:bs.WAITING};this.pendingTasks.set(t.id,t);const i=yield this.taskMutex.lock();try{return t.executedAt=Date.now(),t.status=bs.RUNNING,yield e()}finally{t.status=bs.COMPLETED,this.pendingTasks.delete(t.id),i()}})}flush(){return T(this,void 0,void 0,function*(){return this.run(()=>T(this,void 0,void 0,function*(){}))})}snapshot(){return Array.from(this.pendingTasks.values())}}function eU(n,e){const t=new URL(j3(n));return e.forEach((i,r)=>{t.searchParams.set(r,i)}),ES(t,"rtc")}function tU(n){const e=new URL(Op(n));return ES(e,"validate")}function nU(n){return n.endsWith("/")?n:"".concat(n,"/")}function ES(n,e){return n.pathname="".concat(nU(n.pathname)).concat(e),n.toString()}const iU=["syncState","trickle","offer","answer","simulate","leave"];function rU(n){const e=iU.indexOf(n.case)>=0;return le.trace("request allowed to bypass queue:",{canPass:e,req:n}),e}var Be;(function(n){n[n.CONNECTING=0]="CONNECTING",n[n.CONNECTED=1]="CONNECTED",n[n.RECONNECTING=2]="RECONNECTING",n[n.DISCONNECTING=3]="DISCONNECTING",n[n.DISCONNECTED=4]="DISCONNECTED"})(Be||(Be={}));class Up{get currentState(){return this.state}get isDisconnected(){return this.state===Be.DISCONNECTING||this.state===Be.DISCONNECTED}get isEstablishingConnection(){return this.state===Be.CONNECTING||this.state===Be.RECONNECTING}getNextRequestId(){return this._requestId+=1,this._requestId}constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var i;this.rtt=0,this.state=Be.DISCONNECTED,this.log=le,this._requestId=0,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=Kn((i=t.loggerName)!==null&&i!==void 0?i:pn.Signal),this.loggerContextCb=t.loggerContextCb,this.useJSON=e,this.requestQueue=new Q3,this.queuedRequests=[],this.closingLock=new jt,this.connectionLock=new jt,this.state=Be.DISCONNECTED}get logContext(){var e,t;return(t=(e=this.loggerContextCb)===null||e===void 0?void 0:e.call(this))!==null&&t!==void 0?t:{}}join(e,t,i,r){return T(this,void 0,void 0,function*(){return this.state=Be.CONNECTING,this.options=i,yield this.connect(e,t,i,r)})}reconnect(e,t,i,r){return T(this,void 0,void 0,function*(){if(!this.options){this.log.warn("attempted to reconnect without signal options being set, ignoring",this.logContext);return}return this.state=Be.RECONNECTING,this.clearPingInterval(),yield this.connect(e,t,Object.assign(Object.assign({},this.options),{reconnect:!0,sid:i,reconnectReason:r}))})}connect(e,t,i,r){this.connectOptions=i;const o=F3(),s=oU(t,o,i),a=eU(e,s),c=tU(a);return new Promise((u,l)=>T(this,void 0,void 0,function*(){const d=yield this.connectionLock.lock();try{const h=()=>T(this,void 0,void 0,function*(){this.close(),clearTimeout(p),l(new Ae("room connection has been cancelled (signal)",pe.Cancelled))}),p=setTimeout(()=>{this.close(),l(new Ae("room connection has timed out (signal)",pe.ServerUnreachable))},i.websocketTimeout);r!=null&&r.aborted&&h(),r==null||r.addEventListener("abort",h);const m=new URL(a);m.searchParams.has("access_token")&&m.searchParams.set("access_token","<redacted>"),this.log.debug("connecting to ".concat(m),Object.assign({reconnect:i.reconnect,reconnectReason:i.reconnectReason},this.logContext)),this.ws&&(yield this.close(!1)),this.ws=new WebSocket(a),this.ws.binaryType="arraybuffer",this.ws.onopen=()=>{clearTimeout(p)},this.ws.onerror=f=>T(this,void 0,void 0,function*(){if(this.state!==Be.CONNECTED){this.state=Be.DISCONNECTED,clearTimeout(p);try{const g=yield fetch(c);if(g.status.toFixed(0).startsWith("4")){const y=yield g.text();l(new Ae(y,pe.NotAllowed,g.status))}else l(new Ae("Encountered unknown websocket error during connection: ".concat(f.toString()),pe.InternalError,g.status))}catch(g){l(new Ae(g instanceof Error?g.message:"server was not reachable",pe.ServerUnreachable))}return}this.handleWSError(f)}),this.ws.onmessage=f=>T(this,void 0,void 0,function*(){var g,y,b;let S;if(typeof f.data=="string"){const w=JSON.parse(f.data);S=uk.fromJson(w,{ignoreUnknownFields:!0})}else if(f.data instanceof ArrayBuffer)S=uk.fromBinary(new Uint8Array(f.data));else{this.log.error("could not decode websocket message: ".concat(typeof f.data),this.logContext);return}if(this.state!==Be.CONNECTED){let w=!1;if(((g=S.message)===null||g===void 0?void 0:g.case)==="join"?(this.state=Be.CONNECTED,r==null||r.removeEventListener("abort",h),this.pingTimeoutDuration=S.message.value.pingTimeout,this.pingIntervalDuration=S.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()),u(S.message.value)):this.state===Be.RECONNECTING&&S.message.case!=="leave"?(this.state=Be.CONNECTED,r==null||r.removeEventListener("abort",h),this.startPingInterval(),((y=S.message)===null||y===void 0?void 0:y.case)==="reconnect"?u(S.message.value):(this.log.debug("declaring signal reconnected without reconnect response received",this.logContext),u(void 0),w=!0)):this.isEstablishingConnection&&S.message.case==="leave"?l(new Ae("Received leave request while trying to (re)connect",pe.LeaveRequest,void 0,S.message.value.reason)):i.reconnect||l(new Ae("did not receive join response, got ".concat((b=S.message)===null||b===void 0?void 0:b.case," instead"),pe.InternalError)),!w)return}this.signalLatency&&(yield qt(this.signalLatency)),this.handleSignalResponse(S)}),this.ws.onclose=f=>{this.isEstablishingConnection&&l(new Ae("Websocket got closed during a (re)connection attempt",pe.InternalError)),this.log.warn("websocket closed",Object.assign(Object.assign({},this.logContext),{reason:f.reason,code:f.code,wasClean:f.wasClean,state:this.state})),this.handleOnClose(f.reason)}}finally{d()}}))}close(){return T(this,arguments,void 0,function(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return function*(){const i=yield e.closingLock.lock();try{if(e.clearPingInterval(),t&&(e.state=Be.DISCONNECTING),e.ws){e.ws.onmessage=null,e.ws.onopen=null,e.ws.onclose=null;const r=new Promise(o=>{e.ws?e.ws.onclose=()=>{o()}:o()});e.ws.readyState<e.ws.CLOSING&&(e.ws.close(),yield Promise.race([r,qt(250)])),e.ws=void 0}}finally{t&&(e.state=Be.DISCONNECTED),i()}}()})}sendOffer(e){this.log.debug("sending offer",Object.assign(Object.assign({},this.logContext),{offerSdp:e.sdp})),this.sendRequest({case:"offer",value:yu(e)})}sendAnswer(e){return this.log.debug("sending answer",Object.assign(Object.assign({},this.logContext),{answerSdp:e.sdp})),this.sendRequest({case:"answer",value:yu(e)})}sendIceCandidate(e,t){return this.log.debug("sending ice candidate",Object.assign(Object.assign({},this.logContext),{candidate:e})),this.sendRequest({case:"trickle",value:new ep({candidateInit:JSON.stringify(e),target:t})})}sendMuteTrack(e,t){return this.sendRequest({case:"mute",value:new tp({sid:e,muted:t})})}sendAddTrack(e){return this.sendRequest({case:"addTrack",value:e})}sendUpdateLocalMetadata(e,t){return T(this,arguments,void 0,function(i,r){var o=this;let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return function*(){const a=o.getNextRequestId();return yield o.sendRequest({case:"updateMetadata",value:new pk({requestId:a,metadata:i,name:r,attributes:s})}),a}()})}sendUpdateTrackSettings(e){this.sendRequest({case:"trackSetting",value:e})}sendUpdateSubscription(e){return this.sendRequest({case:"subscription",value:e})}sendSyncState(e){return this.sendRequest({case:"syncState",value:e})}sendUpdateVideoLayers(e,t){return this.sendRequest({case:"updateLayers",value:new hk({trackSid:e,layers:t})})}sendUpdateSubscriptionPermissions(e,t){return this.sendRequest({case:"subscriptionPermission",value:new gk({allParticipants:e,trackPermissions:t})})}sendSimulateScenario(e){return this.sendRequest({case:"simulate",value:e})}sendPing(){return Promise.all([this.sendRequest({case:"ping",value:We.parse(Date.now())}),this.sendRequest({case:"pingReq",value:new bk({timestamp:We.parse(Date.now()),rtt:We.parse(this.rtt)})})])}sendUpdateLocalAudioTrack(e,t){return this.sendRequest({case:"updateAudioTrack",value:new dk({trackSid:e,features:t})})}sendLeave(){return this.sendRequest({case:"leave",value:new iu({reason:ln.CLIENT_INITIATED,action:ro.DISCONNECT})})}sendRequest(e){return T(this,arguments,void 0,function(t){var i=this;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return function*(){if(!r&&!rU(t)&&i.state===Be.RECONNECTING){i.queuedRequests.push(()=>T(i,void 0,void 0,function*(){yield this.sendRequest(t,!0)}));return}if(r||(yield i.requestQueue.flush()),i.signalLatency&&(yield qt(i.signalLatency)),!i.ws||i.ws.readyState!==i.ws.OPEN){i.log.error("cannot send signal request before connected, type: ".concat(t==null?void 0:t.case),i.logContext);return}const s=new PL({message:t});try{i.useJSON?i.ws.send(s.toJsonString()):i.ws.send(s.toBinary())}catch(a){i.log.error("error sending signal message",Object.assign(Object.assign({},i.logContext),{error:a}))}}()})}handleSignalResponse(e){var t,i;const r=e.message;if(r==null){this.log.debug("received unsupported message",this.logContext);return}let o=!1;if(r.case==="answer"){const s=IS(r.value);this.onAnswer&&this.onAnswer(s)}else if(r.case==="offer"){const s=IS(r.value);this.onOffer&&this.onOffer(s)}else if(r.case==="trickle"){const s=JSON.parse(r.value.candidateInit);this.onTrickle&&this.onTrickle(s,r.value.target)}else r.case==="update"?this.onParticipantUpdate&&this.onParticipantUpdate((t=r.value.participants)!==null&&t!==void 0?t:[]):r.case==="trackPublished"?this.onLocalTrackPublished&&this.onLocalTrackPublished(r.value):r.case==="speakersChanged"?this.onSpeakersChanged&&this.onSpeakersChanged((i=r.value.speakers)!==null&&i!==void 0?i:[]):r.case==="leave"?this.onLeave&&this.onLeave(r.value):r.case==="mute"?this.onRemoteMuteChanged&&this.onRemoteMuteChanged(r.value.sid,r.value.muted):r.case==="roomUpdate"?this.onRoomUpdate&&r.value.room&&this.onRoomUpdate(r.value.room):r.case==="connectionQuality"?this.onConnectionQuality&&this.onConnectionQuality(r.value):r.case==="streamStateUpdate"?this.onStreamStateUpdate&&this.onStreamStateUpdate(r.value):r.case==="subscribedQualityUpdate"?this.onSubscribedQualityUpdate&&this.onSubscribedQualityUpdate(r.value):r.case==="subscriptionPermissionUpdate"?this.onSubscriptionPermissionUpdate&&this.onSubscriptionPermissionUpdate(r.value):r.case==="refreshToken"?this.onTokenRefresh&&this.onTokenRefresh(r.value):r.case==="trackUnpublished"?this.onLocalTrackUnpublished&&this.onLocalTrackUnpublished(r.value):r.case==="subscriptionResponse"?this.onSubscriptionError&&this.onSubscriptionError(r.value):r.case==="pong"||(r.case==="pongResp"?(this.rtt=Date.now()-Number.parseInt(r.value.lastPingTimestamp.toString()),this.resetPingTimeout(),o=!0):r.case==="requestResponse"?this.onRequestResponse&&this.onRequestResponse(r.value):r.case==="trackSubscribed"?this.onLocalTrackSubscribed&&this.onLocalTrackSubscribed(r.value.trackSid):r.case==="roomMoved"?(this.onTokenRefresh&&this.onTokenRefresh(r.value.token),this.onRoomMoved&&this.onRoomMoved(r.value)):this.log.debug("unsupported message",Object.assign(Object.assign({},this.logContext),{msgCase:r.case})));o||this.resetPingTimeout()}setReconnected(){for(;this.queuedRequests.length>0;){const e=this.queuedRequests.shift();e&&this.requestQueue.run(e)}}handleOnClose(e){return T(this,void 0,void 0,function*(){if(this.state===Be.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(){if(this.clearPingTimeout(),!this.pingTimeoutDuration){this.log.warn("ping timeout duration not set",this.logContext);return}this.pingTimeout=_t.setTimeout(()=>{this.log.warn("ping timeout triggered. last pong received at: ".concat(new Date(Date.now()-this.pingTimeoutDuration*1e3).toUTCString()),this.logContext),this.handleOnClose("ping timeout")},this.pingTimeoutDuration*1e3)}clearPingTimeout(){this.pingTimeout&&_t.clearTimeout(this.pingTimeout)}startPingInterval(){if(this.clearPingInterval(),this.resetPingTimeout(),!this.pingIntervalDuration){this.log.warn("ping interval duration not set",this.logContext);return}this.log.debug("start ping interval",this.logContext),this.pingInterval=_t.setInterval(()=>{this.sendPing()},this.pingIntervalDuration*1e3)}clearPingInterval(){this.log.debug("clearing ping interval",this.logContext),this.clearPingTimeout(),this.pingInterval&&_t.clearInterval(this.pingInterval)}}function IS(n){const e={type:"offer",sdp:n.sdp};switch(n.type){case"answer":case"offer":case"pranswer":case"rollback":e.type=n.type;break}return e}function yu(n){return new nr({sdp:n.sdp,type:n.type})}function oU(n,e,t){var i;const r=new URLSearchParams;return r.set("access_token",n),t.reconnect&&(r.set("reconnect","1"),t.sid&&r.set("sid",t.sid)),r.set("auto_subscribe",t.autoSubscribe?"1":"0"),r.set("sdk",Nn()?"reactnative":"js"),r.set("version",e.version),r.set("protocol",e.protocol.toString()),e.deviceModel&&r.set("device_model",e.deviceModel),e.os&&r.set("os",e.os),e.osVersion&&r.set("os_version",e.osVersion),e.browser&&r.set("browser",e.browser),e.browserVersion&&r.set("browser_version",e.browserVersion),t.adaptiveStream&&r.set("adaptive_stream","1"),t.reconnectReason&&r.set("reconnect_reason",t.reconnectReason.toString()),!((i=navigator.connection)===null||i===void 0)&&i.type&&r.set("network",navigator.connection.type),r}var mn={},Fp={},Bp={exports:{}},RS;function jp(){if(RS)return Bp.exports;RS=1;var n=Bp.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 e.address!=null?"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 e.subtype!=null?"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 e.sessionConfig!=null?"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+=e.raddr!=null?" raddr %s rport %d":"%v%v",t+=e.tcptype!=null?" tcptype %s":"%v",e.generation!=null&&(t+=" generation %d"),t+=e["network-id"]!=null?" network-id %d":"%v",t+=e["network-cost"]!=null?" network-cost %d":"%v",t}},{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 e.attribute!=null&&(t+=" %s",e.value!=null&&(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 e.maxMessageSize!=null?"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"+(e.clksrcExt!=null?"=%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+=e.id!=null?"id=%s %s":"%v%s",t+=e.mediaClockValue!=null?"=%s":"",t+=e.rateNumerator!=null?" rate=%s":"",t+=e.rateDenominator!=null?"/%s":"",t}},{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"]}]};return Object.keys(n).forEach(function(e){var t=n[e];t.forEach(function(i){i.reg||(i.reg=/(.*)/),i.format||(i.format="%s")})}),Bp.exports}var PS;function sU(){return PS||(PS=1,function(n){var e=function(a){return String(Number(a))===a?Number(a):a},t=function(a,c,u,l){if(l&&!u)c[l]=e(a[1]);else for(var d=0;d<u.length;d+=1)a[d+1]!=null&&(c[u[d]]=e(a[d+1]))},i=function(a,c,u){var l=a.name&&a.names;a.push&&!c[a.push]?c[a.push]=[]:l&&!c[a.name]&&(c[a.name]={});var d=a.push?{}:l?c[a.name]:c;t(u.match(a.reg),d,a.names,a.name),a.push&&c[a.push].push(d)},r=jp(),o=RegExp.prototype.test.bind(/^([a-z])=(.*)/);n.parse=function(a){var c={},u=[],l=c;return a.split(/(\r\n|\r|\n)/).filter(o).forEach(function(d){var h=d[0],p=d.slice(2);h==="m"&&(u.push({rtp:[],fmtp:[]}),l=u[u.length-1]);for(var m=0;m<(r[h]||[]).length;m+=1){var f=r[h][m];if(f.reg.test(p))return i(f,l,p)}}),c.media=u,c};var s=function(a,c){var u=c.split(/=(.+)/,2);return u.length===2?a[u[0]]=e(u[1]):u.length===1&&c.length>1&&(a[u[0]]=void 0),a};n.parseParams=function(a){return a.split(/;\s?/).reduce(s,{})},n.parseFmtpConfig=n.parseParams,n.parsePayloads=function(a){return a.toString().split(" ").map(Number)},n.parseRemoteCandidates=function(a){for(var c=[],u=a.split(" ").map(e),l=0;l<u.length;l+=3)c.push({component:u[l],ip:u[l+1],port:u[l+2]});return c},n.parseImageAttributes=function(a){return a.split(" ").map(function(c){return c.substring(1,c.length-1).split(",").reduce(s,{})})},n.parseSimulcastStreamList=function(a){return a.split(";").map(function(c){return c.split(",").map(function(u){var l,d=!1;return u[0]!=="~"?l=e(u):(l=e(u.substring(1,u.length)),d=!0),{scid:l,paused:d}})})}}(Fp)),Fp}var Vp,OS;function aU(){if(OS)return Vp;OS=1;var n=jp(),e=/%[sdv%]/g,t=function(s){var a=1,c=arguments,u=c.length;return s.replace(e,function(l){if(a>=u)return l;var d=c[a];switch(a+=1,l){case"%%":return"%";case"%s":return String(d);case"%d":return Number(d);case"%v":return""}})},i=function(s,a,c){var u=a.format instanceof Function?a.format(a.push?c:c[a.name]):a.format,l=[s+"="+u];if(a.names)for(var d=0;d<a.names.length;d+=1){var h=a.names[d];a.name?l.push(c[a.name][h]):l.push(c[a.names[d]])}else l.push(c[a.name]);return t.apply(null,l)},r=["v","o","s","i","u","e","p","c","b","t","r","z","a"],o=["i","c","b","a"];return Vp=function(s,a){a=a||{},s.version==null&&(s.version=0),s.name==null&&(s.name=" "),s.media.forEach(function(d){d.payloads==null&&(d.payloads="")});var c=a.outerOrder||r,u=a.innerOrder||o,l=[];return c.forEach(function(d){n[d].forEach(function(h){h.name in s&&s[h.name]!=null?l.push(i(d,h,s)):h.push in s&&s[h.push]!=null&&s[h.push].forEach(function(p){l.push(i(d,h,p))})})}),s.media.forEach(function(d){l.push(i("m",n.m[0],d)),u.forEach(function(h){n[h].forEach(function(p){p.name in d&&d[p.name]!=null?l.push(i(h,p,d)):p.push in d&&d[p.push]!=null&&d[p.push].forEach(function(m){l.push(i(h,p,m))})})})}),l.join(`\r
37
+ `},e.getDirection=function(t,i){const r=e.splitLines(t);for(let s=0;s<r.length;s++)switch(r[s]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[s].substring(2)}return i?e.getDirection(i):"sendrecv"},e.getKind=function(t){return e.splitLines(t)[0].split(" ")[0].substring(2)},e.isRejected=function(t){return t.split(" ",2)[1]==="0"},e.parseMLine=function(t){const r=e.splitLines(t)[0].substring(2).split(" ");return{kind:r[0],port:parseInt(r[1],10),protocol:r[2],fmt:r.slice(3).join(" ")}},e.parseOLine=function(t){const r=e.matchPrefix(t,"o=")[0].substring(2).split(" ");return{username:r[0],sessionId:r[1],sessionVersion:parseInt(r[2],10),netType:r[3],addressType:r[4],address:r[5]}},e.isValidSDP=function(t){if(typeof t!="string"||t.length===0)return!1;const i=e.splitLines(t);for(let r=0;r<i.length;r++)if(i[r].length<2||i[r].charAt(1)!=="=")return!1;return!0},n.exports=e}(Oa)),Oa.exports}var Bd=Lk(),Fn=Ck(Bd),Dk=$b({__proto__:null,default:Fn},[Bd]);function Vr(n){if(!n.RTCIceCandidate||n.RTCIceCandidate&&"foundation"in n.RTCIceCandidate.prototype)return;const e=n.RTCIceCandidate;n.RTCIceCandidate=function(i){if(typeof i=="object"&&i.candidate&&i.candidate.indexOf("a=")===0&&(i=JSON.parse(JSON.stringify(i)),i.candidate=i.candidate.substring(2)),i.candidate&&i.candidate.length){const r=new e(i),s=Fn.parseCandidate(i.candidate);for(const a in s)a in r||Object.defineProperty(r,a,{value:s[a]});return r.toJSON=function(){return{candidate:r.candidate,sdpMid:r.sdpMid,sdpMLineIndex:r.sdpMLineIndex,usernameFragment:r.usernameFragment}},r}return new e(i)},n.RTCIceCandidate.prototype=e.prototype,fn(n,"icecandidate",t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new n.RTCIceCandidate(t.candidate),writable:"false"}),t))}function Aa(n){!n.RTCIceCandidate||n.RTCIceCandidate&&"relayProtocol"in n.RTCIceCandidate.prototype||fn(n,"icecandidate",e=>{if(e.candidate){const t=Fn.parseCandidate(e.candidate.candidate);t.type==="relay"&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e})}function Gr(n,e){if(!n.RTCPeerConnection)return;"sctp"in n.RTCPeerConnection.prototype||Object.defineProperty(n.RTCPeerConnection.prototype,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp}});const t=function(o){if(!o||!o.sdp)return!1;const c=Fn.splitSections(o.sdp);return c.shift(),c.some(l=>{const u=Fn.parseMLine(l);return u&&u.kind==="application"&&u.protocol.indexOf("SCTP")!==-1})},i=function(o){const c=o.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(c===null||c.length<2)return-1;const l=parseInt(c[1],10);return l!==l?-1:l},r=function(o){let c=65536;return e.browser==="firefox"&&(e.version<57?o===-1?c=16384:c=2147483637:e.version<60?c=e.version===57?65535:65536:c=2147483637),c},s=function(o,c){let l=65536;e.browser==="firefox"&&e.version===57&&(l=65535);const u=Fn.matchPrefix(o.sdp,"a=max-message-size:");return u.length>0?l=parseInt(u[0].substring(19),10):e.browser==="firefox"&&c!==-1&&(l=2147483637),l},a=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,e.browser==="chrome"&&e.version>=76){const{sdpSemantics:c}=this.getConfiguration();c==="plan-b"&&Object.defineProperty(this,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp},enumerable:!0,configurable:!0})}if(t(arguments[0])){const c=i(arguments[0]),l=r(c),u=s(arguments[0],c);let d;l===0&&u===0?d=Number.POSITIVE_INFINITY:l===0||u===0?d=Math.max(l,u):d=Math.min(l,u);const h={};Object.defineProperty(h,"maxMessageSize",{get(){return d}}),this._sctp=h}return a.apply(this,arguments)}}function Wr(n){if(!(n.RTCPeerConnection&&"createDataChannel"in n.RTCPeerConnection.prototype))return;function e(i,r){const s=i.send;i.send=function(){const o=arguments[0],c=o.length||o.size||o.byteLength;if(i.readyState==="open"&&r.sctp&&c>r.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+r.sctp.maxMessageSize+" bytes)");return s.apply(i,arguments)}}const t=n.RTCPeerConnection.prototype.createDataChannel;n.RTCPeerConnection.prototype.createDataChannel=function(){const r=t.apply(this,arguments);return e(r,this),r},fn(n,"datachannel",i=>(e(i.channel,i.target),i))}function Na(n){if(!n.RTCPeerConnection||"connectionState"in n.RTCPeerConnection.prototype)return;const e=n.RTCPeerConnection.prototype;Object.defineProperty(e,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(e,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(t){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),t&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=t)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(t=>{const i=e[t];e[t]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=r=>{const s=r.target;if(s._lastConnectionState!==s.connectionState){s._lastConnectionState=s.connectionState;const a=new Event("connectionstatechange",r);s.dispatchEvent(a)}return r},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),i.apply(this,arguments)}})}function Ma(n,e){if(!n.RTCPeerConnection||e.browser==="chrome"&&e.version>=71||e.browser==="safari"&&e.version>=605)return;const t=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(r){if(r&&r.sdp&&r.sdp.indexOf(`
38
+ a=extmap-allow-mixed`)!==-1){const s=r.sdp.split(`
39
+ `).filter(a=>a.trim()!=="a=extmap-allow-mixed").join(`
40
+ `);n.RTCSessionDescription&&r instanceof n.RTCSessionDescription?arguments[0]=new n.RTCSessionDescription({type:r.type,sdp:s}):r.sdp=s}return t.apply(this,arguments)}}function zr(n,e){if(!(n.RTCPeerConnection&&n.RTCPeerConnection.prototype))return;const t=n.RTCPeerConnection.prototype.addIceCandidate;!t||t.length===0||(n.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(e.browser==="chrome"&&e.version<78||e.browser==="firefox"&&e.version<68||e.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():t.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}function Hr(n,e){if(!(n.RTCPeerConnection&&n.RTCPeerConnection.prototype))return;const t=n.RTCPeerConnection.prototype.setLocalDescription;!t||t.length===0||(n.RTCPeerConnection.prototype.setLocalDescription=function(){let r=arguments[0]||{};if(typeof r!="object"||r.type&&r.sdp)return t.apply(this,arguments);if(r={type:r.type,sdp:r.sdp},!r.type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":r.type="offer";break;default:r.type="answer";break}return r.sdp||r.type!=="offer"&&r.type!=="answer"?t.apply(this,[r]):(r.type==="offer"?this.createOffer:this.createAnswer).apply(this).then(a=>t.apply(this,[a]))})}var Uk=Object.freeze({__proto__:null,removeExtmapAllowMixed:Ma,shimAddIceCandidateNullOrEmpty:zr,shimConnectionState:Na,shimMaxMessageSize:Gr,shimParameterlessSetLocalDescription:Hr,shimRTCIceCandidate:Vr,shimRTCIceCandidateRelayProtocol:Aa,shimSendThrowTypeError:Wr});function Bk(){let{window:n}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0};const t=nd,i=Nk(n),r={browserDetails:i,commonShim:Uk,extractVersion:jr,disableLog:Ok,disableWarnings:Ak,sdp:Dk};switch(i.browser){case"chrome":if(!md||!Ra||!e.shimChrome)return t("Chrome shim is not included in this adapter release."),r;if(i.version===null)return t("Chrome shim can not determine version, not shimming."),r;t("adapter.js shimming chrome."),r.browserShim=md,zr(n,i),Hr(n),od(n,i),cd(n),Ra(n,i),ld(n),fd(n,i),ud(n),dd(n),pd(n,i),Vr(n),Aa(n),Na(n),Gr(n,i),Wr(n),Ma(n,i);break;case"firefox":if(!_d||!Ia||!e.shimFirefox)return t("Firefox shim is not included in this adapter release."),r;t("adapter.js shimming firefox."),r.browserShim=_d,zr(n,i),Hr(n),gd(n,i),Ia(n,i),vd(n),kd(n),bd(n),yd(n),Td(n),Sd(n),Cd(n),xd(n),wd(n),Vr(n),Na(n),Gr(n,i),Wr(n);break;case"safari":if(!Dd||!e.shimSafari)return t("Safari shim is not included in this adapter release."),r;t("adapter.js shimming safari."),r.browserShim=Dd,zr(n,i),Hr(n),Ad(n),Md(n),Rd(n),Ed(n),Pd(n),Nd(n),Id(n),Ld(n),Vr(n),Aa(n),Gr(n,i),Wr(n),Ma(n,i);break;default:t("Unsupported browser!");break}return r}Bk({window:typeof window>"u"?void 0:window});const Fk=10,qr="lk_e2ee",jk={sharedKey:!1,ratchetSalt:"LKFrameEncryptionKey",ratchetWindowSize:8,failureTolerance:Fk,keyringSize:16};var Kt;(function(n){n.SetKey="setKey",n.RatchetRequest="ratchetRequest",n.KeyRatcheted="keyRatcheted"})(Kt||(Kt={}));var Fd;(function(n){n.KeyRatcheted="keyRatcheted"})(Fd||(Fd={}));var $t;(function(n){n.ParticipantEncryptionStatusChanged="participantEncryptionStatusChanged",n.EncryptionError="encryptionError"})($t||($t={}));var jd;(function(n){n.Error="cryptorError"})(jd||(jd={}));function Vk(){return Gk()||La()}function La(){return typeof window.RTCRtpScriptTransform<"u"}function Gk(){return typeof window.RTCRtpSender<"u"&&typeof window.RTCRtpSender.prototype.createEncodedStreams<"u"}class ox extends Tt.EventEmitter{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(),this.onKeyRatcheted=(t,i,r)=>{q.debug("key ratcheted event received",{ratchetResult:t,participantId:i,keyIndex:r})},this.keyInfoMap=new Map,this.options=Object.assign(Object.assign({},jk),e),this.on(Kt.KeyRatcheted,this.onKeyRatcheted)}onSetEncryptionKey(e,t,i){const r={key:e,participantIdentity:t,keyIndex:i};if(!this.options.sharedKey&&!t)throw new Error("participant identity needs to be passed for encryption key if sharedKey option is false");this.keyInfoMap.set("".concat(t??"shared","-").concat(i??0),r),this.emit(Kt.SetKey,r)}getKeys(){return Array.from(this.keyInfoMap.values())}getOptions(){return this.options}ratchetKey(e,t){this.emit(Kt.RatchetRequest,e,t)}}class Yt extends Error{constructor(e,t){super(t||"an error has occured"),this.name="LiveKitError",this.code=e}}var $;(function(n){n[n.NotAllowed=0]="NotAllowed",n[n.ServerUnreachable=1]="ServerUnreachable",n[n.InternalError=2]="InternalError",n[n.Cancelled=3]="Cancelled",n[n.LeaveRequest=4]="LeaveRequest"})($||($={}));class ie extends Yt{constructor(e,t,i,r){super(1,e),this.name="ConnectionError",this.status=i,this.reason=t,this.context=r,this.reasonName=$[t]}}class Da extends Yt{constructor(e){super(21,e??"device is unsupported"),this.name="DeviceUnsupportedError"}}class Pt extends Yt{constructor(e){super(20,e??"track is invalid"),this.name="TrackInvalidError"}}class Wk extends Yt{constructor(e){super(10,e??"unsupported server"),this.name="UnsupportedServer"}}class Ce extends Yt{constructor(e){super(12,e??"unexpected connection state"),this.name="UnexpectedConnectionState"}}class Ua extends Yt{constructor(e){super(13,e??"unable to negotiate"),this.name="NegotiationError"}}class Ba extends Yt{constructor(e,t){super(15,e),this.name="PublishTrackError",this.status=t}}class Vd extends Yt{constructor(e,t){super(15,e),this.reason=t,this.reasonName=typeof t=="string"?t:wa[t]}}var Kr;(function(n){n.PermissionDenied="PermissionDenied",n.NotFound="NotFound",n.DeviceInUse="DeviceInUse",n.Other="Other"})(Kr||(Kr={})),function(n){function e(t){if(t&&"name"in t)return t.name==="NotFoundError"||t.name==="DevicesNotFoundError"?n.NotFound:t.name==="NotAllowedError"||t.name==="PermissionDeniedError"?n.PermissionDenied:t.name==="NotReadableError"||t.name==="TrackStartError"?n.DeviceInUse:n.Other}n.getFailure=e}(Kr||(Kr={}));var Gd;(function(n){n[n.InvalidKey=0]="InvalidKey",n[n.MissingKey=1]="MissingKey",n[n.InternalError=2]="InternalError"})(Gd||(Gd={}));var O;(function(n){n.Connected="connected",n.Reconnecting="reconnecting",n.SignalReconnecting="signalReconnecting",n.Reconnected="reconnected",n.Disconnected="disconnected",n.ConnectionStateChanged="connectionStateChanged",n.Moved="moved",n.MediaDevicesChanged="mediaDevicesChanged",n.ParticipantConnected="participantConnected",n.ParticipantDisconnected="participantDisconnected",n.TrackPublished="trackPublished",n.TrackSubscribed="trackSubscribed",n.TrackSubscriptionFailed="trackSubscriptionFailed",n.TrackUnpublished="trackUnpublished",n.TrackUnsubscribed="trackUnsubscribed",n.TrackMuted="trackMuted",n.TrackUnmuted="trackUnmuted",n.LocalTrackPublished="localTrackPublished",n.LocalTrackUnpublished="localTrackUnpublished",n.LocalAudioSilenceDetected="localAudioSilenceDetected",n.ActiveSpeakersChanged="activeSpeakersChanged",n.ParticipantMetadataChanged="participantMetadataChanged",n.ParticipantNameChanged="participantNameChanged",n.ParticipantAttributesChanged="participantAttributesChanged",n.ParticipantActive="participantActive",n.RoomMetadataChanged="roomMetadataChanged",n.DataReceived="dataReceived",n.SipDTMFReceived="sipDTMFReceived",n.TranscriptionReceived="transcriptionReceived",n.ConnectionQualityChanged="connectionQualityChanged",n.TrackStreamStateChanged="trackStreamStateChanged",n.TrackSubscriptionPermissionChanged="trackSubscriptionPermissionChanged",n.TrackSubscriptionStatusChanged="trackSubscriptionStatusChanged",n.AudioPlaybackStatusChanged="audioPlaybackChanged",n.VideoPlaybackStatusChanged="videoPlaybackChanged",n.MediaDevicesError="mediaDevicesError",n.ParticipantPermissionsChanged="participantPermissionsChanged",n.SignalConnected="signalConnected",n.RecordingStatusChanged="recordingStatusChanged",n.ParticipantEncryptionStatusChanged="participantEncryptionStatusChanged",n.EncryptionError="encryptionError",n.DCBufferStatusChanged="dcBufferStatusChanged",n.ActiveDeviceChanged="activeDeviceChanged",n.ChatMessage="chatMessage",n.LocalTrackSubscribed="localTrackSubscribed",n.MetricsReceived="metricsReceived"})(O||(O={}));var L;(function(n){n.TrackPublished="trackPublished",n.TrackSubscribed="trackSubscribed",n.TrackSubscriptionFailed="trackSubscriptionFailed",n.TrackUnpublished="trackUnpublished",n.TrackUnsubscribed="trackUnsubscribed",n.TrackMuted="trackMuted",n.TrackUnmuted="trackUnmuted",n.LocalTrackPublished="localTrackPublished",n.LocalTrackUnpublished="localTrackUnpublished",n.ParticipantMetadataChanged="participantMetadataChanged",n.ParticipantNameChanged="participantNameChanged",n.DataReceived="dataReceived",n.SipDTMFReceived="sipDTMFReceived",n.TranscriptionReceived="transcriptionReceived",n.IsSpeakingChanged="isSpeakingChanged",n.ConnectionQualityChanged="connectionQualityChanged",n.TrackStreamStateChanged="trackStreamStateChanged",n.TrackSubscriptionPermissionChanged="trackSubscriptionPermissionChanged",n.TrackSubscriptionStatusChanged="trackSubscriptionStatusChanged",n.MediaDevicesError="mediaDevicesError",n.AudioStreamAcquired="audioStreamAcquired",n.ParticipantPermissionsChanged="participantPermissionsChanged",n.PCTrackAdded="pcTrackAdded",n.AttributesChanged="attributesChanged",n.LocalTrackSubscribed="localTrackSubscribed",n.ChatMessage="chatMessage",n.Active="active"})(L||(L={}));var M;(function(n){n.TransportsCreated="transportsCreated",n.Connected="connected",n.Disconnected="disconnected",n.Resuming="resuming",n.Resumed="resumed",n.Restarting="restarting",n.Restarted="restarted",n.SignalResumed="signalResumed",n.SignalRestarted="signalRestarted",n.Closing="closing",n.MediaTrackAdded="mediaTrackAdded",n.ActiveSpeakersUpdate="activeSpeakersUpdate",n.DataPacketReceived="dataPacketReceived",n.RTPVideoMapUpdate="rtpVideoMapUpdate",n.DCBufferStatusChanged="dcBufferStatusChanged",n.ParticipantUpdate="participantUpdate",n.RoomUpdate="roomUpdate",n.SpeakersChanged="speakersChanged",n.StreamStateChanged="streamStateChanged",n.ConnectionQualityUpdate="connectionQualityUpdate",n.SubscriptionError="subscriptionError",n.SubscriptionPermissionUpdate="subscriptionPermissionUpdate",n.RemoteMute="remoteMute",n.SubscribedQualityUpdate="subscribedQualityUpdate",n.LocalTrackUnpublished="localTrackUnpublished",n.LocalTrackSubscribed="localTrackSubscribed",n.Offline="offline",n.SignalRequestResponse="signalRequestResponse",n.SignalConnected="signalConnected",n.RoomMoved="roomMoved"})(M||(M={}));var N;(function(n){n.Message="message",n.Muted="muted",n.Unmuted="unmuted",n.Restarted="restarted",n.Ended="ended",n.Subscribed="subscribed",n.Unsubscribed="unsubscribed",n.UpdateSettings="updateSettings",n.UpdateSubscription="updateSubscription",n.AudioPlaybackStarted="audioPlaybackStarted",n.AudioPlaybackFailed="audioPlaybackFailed",n.AudioSilenceDetected="audioSilenceDetected",n.VisibilityChanged="visibilityChanged",n.VideoDimensionsChanged="videoDimensionsChanged",n.VideoPlaybackStarted="videoPlaybackStarted",n.VideoPlaybackFailed="videoPlaybackFailed",n.ElementAttached="elementAttached",n.ElementDetached="elementDetached",n.UpstreamPaused="upstreamPaused",n.UpstreamResumed="upstreamResumed",n.SubscriptionPermissionChanged="subscriptionPermissionChanged",n.SubscriptionStatusChanged="subscriptionStatusChanged",n.SubscriptionFailed="subscriptionFailed",n.TrackProcessorUpdate="trackProcessorUpdate",n.AudioTrackFeatureUpdate="audioTrackFeatureUpdate",n.TranscriptionReceived="transcriptionReceived",n.TimeSyncUpdate="timeSyncUpdate"})(N||(N={}));function zk(n){return typeof n>"u"?n:typeof structuredClone=="function"?structuredClone(n):JSON.parse(JSON.stringify(n))}const Hk=/version\/(\d+(\.?_?\d+)+)/i;let Fa;function ct(n){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;if(typeof n>"u"&&typeof navigator>"u")return;const t=(n??navigator.userAgent).toLowerCase();if(Fa===void 0||e){const i=qk.find(r=>{let{test:s}=r;return s.test(t)});Fa=i==null?void 0:i.describe(t)}return Fa}const qk=[{test:/firefox|iceweasel|fxios/i,describe(n){return{name:"Firefox",version:$r(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,n),os:n.toLowerCase().includes("fxios")?"iOS":void 0,osVersion:ja(n)}}},{test:/chrom|crios|crmo/i,describe(n){return{name:"Chrome",version:$r(/(?:chrome|chromium|crios|crmo)\/(\d+(\.?_?\d+)+)/i,n),os:n.toLowerCase().includes("crios")?"iOS":void 0,osVersion:ja(n)}}},{test:/safari|applewebkit/i,describe(n){return{name:"Safari",version:$r(Hk,n),os:n.includes("mobile/")?"iOS":"macOS",osVersion:ja(n)}}}];function $r(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1;const i=e.match(n);return i&&i.length>=t&&i[t]||""}function ja(n){return n.includes("mac os")?$r(/\(.+?(\d+_\d+(:?_\d+)?)/,n,1).replace(/_/g,"."):void 0}var Kk="2.13.0";const $k=Kk,Yk=16;class Ie{}Ie.setTimeout=function(){return setTimeout(...arguments)},Ie.setInterval=function(){return setInterval(...arguments)},Ie.clearTimeout=function(){return clearTimeout(...arguments)},Ie.clearInterval=function(){return clearInterval(...arguments)};const Xk=5e3,vi=[];var Ze;(function(n){n[n.LOW=0]="LOW",n[n.MEDIUM=1]="MEDIUM",n[n.HIGH=2]="HIGH"})(Ze||(Ze={}));class P extends Tt.EventEmitter{constructor(e,t){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var r;super(),this.attachedElements=[],this.isMuted=!1,this.streamState=P.StreamState.Active,this.isInBackground=!1,this._currentBitrate=0,this.log=q,this.appVisibilityChangedListener=()=>{this.backgroundTimeout&&clearTimeout(this.backgroundTimeout),document.visibilityState==="hidden"?this.backgroundTimeout=setTimeout(()=>this.handleAppVisibilityChanged(),Xk):this.handleAppVisibilityChanged()},this.log=Et((r=i.loggerName)!==null&&r!==void 0?r:ot.Track),this.loggerContextCb=i.loggerContextCb,this.setMaxListeners(100),this.kind=t,this._mediaStreamTrack=e,this._mediaStreamID=e.id,this.source=P.Source.Unknown}get logContext(){var e;return Object.assign(Object.assign({},(e=this.loggerContextCb)===null||e===void 0?void 0:e.call(this)),ee(this))}get currentBitrate(){return this._currentBitrate}get mediaStreamTrack(){return this._mediaStreamTrack}get mediaStreamID(){return this._mediaStreamID}attach(e){let t="audio";this.kind===P.Kind.Video&&(t="video"),this.attachedElements.length===0&&this.kind===P.Kind.Video&&this.addAppVisibilityListener(),e||(t==="audio"&&(vi.forEach(s=>{s.parentElement===null&&!e&&(e=s)}),e&&vi.splice(vi.indexOf(e),1)),e||(e=document.createElement(t))),this.attachedElements.includes(e)||this.attachedElements.push(e),jn(this.mediaStreamTrack,e);const i=e.srcObject.getTracks(),r=i.some(s=>s.kind==="audio");return e.play().then(()=>{this.emit(r?N.AudioPlaybackStarted:N.VideoPlaybackStarted)}).catch(s=>{s.name==="NotAllowedError"?this.emit(r?N.AudioPlaybackFailed:N.VideoPlaybackFailed,s):s.name==="AbortError"?q.debug("".concat(r?"audio":"video"," playback aborted, likely due to new play request")):q.warn("could not playback ".concat(r?"audio":"video"),s),r&&e&&i.some(a=>a.kind==="video")&&s.name==="NotAllowedError"&&(e.muted=!0,e.play().catch(()=>{}))}),this.emit(N.ElementAttached,e),e}detach(e){try{if(e){Vn(this.mediaStreamTrack,e);const i=this.attachedElements.indexOf(e);return i>=0&&(this.attachedElements.splice(i,1),this.recycleElement(e),this.emit(N.ElementDetached,e)),e}const t=[];return this.attachedElements.forEach(i=>{Vn(this.mediaStreamTrack,i),t.push(i),this.recycleElement(i),this.emit(N.ElementDetached,i)}),this.attachedElements=[],t}finally{this.attachedElements.length===0&&this.removeAppVisibilityListener()}}stop(){this.stopMonitor(),this._mediaStreamTrack.stop()}enable(){this._mediaStreamTrack.enabled=!0}disable(){this._mediaStreamTrack.enabled=!1}stopMonitor(){this.monitorInterval&&clearInterval(this.monitorInterval),this.timeSyncHandle&&cancelAnimationFrame(this.timeSyncHandle)}updateLoggerOptions(e){e.loggerName&&(this.log=Et(e.loggerName)),e.loggerContextCb&&(this.loggerContextCb=e.loggerContextCb)}recycleElement(e){if(e instanceof HTMLAudioElement){let t=!0;e.pause(),vi.forEach(i=>{i.parentElement||(t=!1)}),t&&vi.push(e)}}handleAppVisibilityChanged(){return y(this,void 0,void 0,function*(){this.isInBackground=document.visibilityState==="hidden",!this.isInBackground&&this.kind===P.Kind.Video&&setTimeout(()=>this.attachedElements.forEach(e=>e.play().catch(()=>{})),0)})}addAppVisibilityListener(){We()?(this.isInBackground=document.visibilityState==="hidden",document.addEventListener("visibilitychange",this.appVisibilityChangedListener)):this.isInBackground=!1}removeAppVisibilityListener(){We()&&document.removeEventListener("visibilitychange",this.appVisibilityChangedListener)}}function jn(n,e){let t;e.srcObject instanceof MediaStream?t=e.srcObject:t=new MediaStream;let i;n.kind==="audio"?i=t.getAudioTracks():i=t.getVideoTracks(),i.includes(n)||(i.forEach(r=>{t.removeTrack(r)}),t.addTrack(n)),(!Xt()||!(e instanceof HTMLVideoElement))&&(e.autoplay=!0),e.muted=t.getAudioTracks().length===0,e instanceof HTMLVideoElement&&(e.playsInline=!0),e.srcObject!==t&&(e.srcObject=t,(Xt()||Gn())&&e instanceof HTMLVideoElement&&setTimeout(()=>{e.srcObject=t,e.play().catch(()=>{})},0))}function Vn(n,e){if(e.srcObject instanceof MediaStream){const t=e.srcObject;t.removeTrack(n),t.getTracks().length>0?e.srcObject=t:e.srcObject=null}}(function(n){let e;(function(l){l.Audio="audio",l.Video="video",l.Unknown="unknown"})(e=n.Kind||(n.Kind={}));let t;(function(l){l.Camera="camera",l.Microphone="microphone",l.ScreenShare="screen_share",l.ScreenShareAudio="screen_share_audio",l.Unknown="unknown"})(t=n.Source||(n.Source={}));let i;(function(l){l.Active="active",l.Paused="paused",l.Unknown="unknown"})(i=n.StreamState||(n.StreamState={}));function r(l){switch(l){case e.Audio:return it.AUDIO;case e.Video:return it.VIDEO;default:return it.DATA}}n.kindToProto=r;function s(l){switch(l){case it.AUDIO:return e.Audio;case it.VIDEO:return e.Video;default:return e.Unknown}}n.kindFromProto=s;function a(l){switch(l){case t.Camera:return ke.CAMERA;case t.Microphone:return ke.MICROPHONE;case t.ScreenShare:return ke.SCREEN_SHARE;case t.ScreenShareAudio:return ke.SCREEN_SHARE_AUDIO;default:return ke.UNKNOWN}}n.sourceToProto=a;function o(l){switch(l){case ke.CAMERA:return t.Camera;case ke.MICROPHONE:return t.Microphone;case ke.SCREEN_SHARE:return t.ScreenShare;case ke.SCREEN_SHARE_AUDIO:return t.ScreenShareAudio;default:return t.Unknown}}n.sourceFromProto=o;function c(l){switch(l){case ba.ACTIVE:return i.Active;case ba.PAUSED:return i.Paused;default:return i.Unknown}}n.streamStateFromProto=c})(P||(P={}));class ne{constructor(e,t,i,r,s){if(typeof e=="object")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(t!==void 0&&i!==void 0)this.width=e,this.height=t,this.aspectRatio=e/t,this.encoding={maxBitrate:i,maxFramerate:r,priority:s};else throw new TypeError("Unsupported options: provide at least width, height and maxBitrate")}get resolution(){return{width:this.width,height:this.height,frameRate:this.encoding.maxFramerate,aspectRatio:this.aspectRatio}}}const Jk=["vp8","h264"],Qk=["vp8","h264","vp9","av1"];function Zk(n){return!!Jk.find(e=>e===n)}var Wd;(function(n){n[n.PREFER_REGRESSION=0]="PREFER_REGRESSION",n[n.SIMULCAST=1]="SIMULCAST",n[n.REGRESSION=2]="REGRESSION"})(Wd||(Wd={}));var Va;(function(n){n.telephone={maxBitrate:12e3},n.speech={maxBitrate:24e3},n.music={maxBitrate:48e3},n.musicStereo={maxBitrate:64e3},n.musicHighQuality={maxBitrate:96e3},n.musicHighQualityStereo={maxBitrate:128e3}})(Va||(Va={}));const bi={h90:new ne(160,90,9e4,20),h180:new ne(320,180,16e4,20),h216:new ne(384,216,18e4,20),h360:new ne(640,360,45e4,20),h540:new ne(960,540,8e5,25),h720:new ne(1280,720,17e5,30),h1080:new ne(1920,1080,3e6,30),h1440:new ne(2560,1440,5e6,30),h2160:new ne(3840,2160,8e6,30)},Ga={h120:new ne(160,120,7e4,20),h180:new ne(240,180,125e3,20),h240:new ne(320,240,14e4,20),h360:new ne(480,360,33e4,20),h480:new ne(640,480,5e5,20),h540:new ne(720,540,6e5,25),h720:new ne(960,720,13e5,30),h1080:new ne(1440,1080,23e5,30),h1440:new ne(1920,1440,38e5,30)},Wa={h360fps3:new ne(640,360,2e5,3,"medium"),h360fps15:new ne(640,360,4e5,15,"medium"),h720fps5:new ne(1280,720,8e5,5,"medium"),h720fps15:new ne(1280,720,15e5,15,"medium"),h720fps30:new ne(1280,720,2e6,30,"medium"),h1080fps15:new ne(1920,1080,25e5,15,"medium"),h1080fps30:new ne(1920,1080,5e6,30,"medium"),original:new ne(0,0,7e6,30,"medium")},eT="|",zd="https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension";function tT(n){const e=n.split(eT);return e.length>1?[e[0],n.substr(e[0].length+1)]:[n,""]}function Ge(n){return y(this,void 0,void 0,function*(){return new Promise(e=>Ie.setTimeout(e,n))})}function za(){return"addTransceiver"in RTCPeerConnection.prototype}function Ha(){return"addTrack"in RTCPeerConnection.prototype}function nT(){if(!("getCapabilities"in RTCRtpSender)||Xt())return!1;const n=RTCRtpSender.getCapabilities("video");let e=!1;if(n){for(const t of n.codecs)if(t.mimeType==="video/AV1"){e=!0;break}}return e}function iT(){if(!("getCapabilities"in RTCRtpSender)||Gn())return!1;if(Xt()){const t=ct();if(t!=null&&t.version&&pn(t.version,"16")<0)return!1}const n=RTCRtpSender.getCapabilities("video");let e=!1;if(n){for(const t of n.codecs)if(t.mimeType==="video/VP9"){e=!0;break}}return e}function yi(n){return n==="av1"||n==="vp9"}function qa(n){return document?(n||(n=document.createElement("audio")),"setSinkId"in n):!1}function rT(){return typeof RTCPeerConnection>"u"?!1:za()||Ha()}function Gn(){var n;return((n=ct())===null||n===void 0?void 0:n.name)==="Firefox"}function Xt(){var n;return((n=ct())===null||n===void 0?void 0:n.name)==="Safari"}function sT(){const n=ct();return(n==null?void 0:n.name)==="Safari"&&n.version.startsWith("17.")}function Hd(){var n,e;return We()?(e=(n=navigator.userAgentData)===null||n===void 0?void 0:n.mobile)!==null&&e!==void 0?e:/Tablet|iPad|Mobile|Android|BlackBerry/.test(navigator.userAgent):!1}function aT(){const n=ct(),e="17.2";if(n)return n.name!=="Safari"&&n.os!=="iOS"||n.os==="iOS"&&n.osVersion&&pn(e,n.osVersion)>=0?!0:n.name==="Safari"&&pn(e,n.version)>=0}function We(){return typeof document<"u"}function St(){return navigator.product=="ReactNative"}function Ka(n){return n.hostname.endsWith(".livekit.cloud")||n.hostname.endsWith(".livekit.run")}function qd(){if(global&&global.LiveKitReactNativeGlobal)return global.LiveKitReactNativeGlobal}function Kd(){if(!St())return;let n=qd();if(n)return n.platform}function $d(){if(We())return window.devicePixelRatio;if(St()){let n=qd();if(n)return n.devicePixelRatio}return 1}function pn(n,e){const t=n.split("."),i=e.split("."),r=Math.min(t.length,i.length);for(let s=0;s<r;++s){const a=parseInt(t[s],10),o=parseInt(i[s],10);if(a>o)return 1;if(a<o)return-1;if(s===r-1&&a===o)return 0}return n===""&&e!==""?-1:e===""?1:t.length==i.length?0:t.length<i.length?-1:1}function oT(n){for(const e of n)e.target.handleResize(e)}function cT(n){for(const e of n)e.target.handleVisibilityChanged(e)}let $a=null;const Yd=()=>($a||($a=new ResizeObserver(oT)),$a);let Ya=null;const Xd=()=>(Ya||(Ya=new IntersectionObserver(cT,{root:null,rootMargin:"0px"})),Ya);function lT(){var n;const e=new Qy({sdk:Mu.JS,protocol:Yk,version:$k});return St()&&(e.os=(n=Kd())!==null&&n!==void 0?n:""),e}function Jd(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:16,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:16,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;const r=document.createElement("canvas");r.width=n,r.height=e;const s=r.getContext("2d");s==null||s.fillRect(0,0,r.width,r.height),i&&s&&(s.beginPath(),s.arc(n/2,e/2,50,0,Math.PI*2,!0),s.closePath(),s.fillStyle="grey",s.fill());const a=r.captureStream(),[o]=a.getTracks();if(!o)throw Error("Could not get empty media stream video track");return o.enabled=t,o}let ki;function Xa(){if(!ki){const n=new AudioContext,e=n.createOscillator(),t=n.createGain();t.gain.setValueAtTime(0,0);const i=n.createMediaStreamDestination();if(e.connect(t),t.connect(i),e.start(),[ki]=i.stream.getAudioTracks(),!ki)throw Error("Could not get empty media stream audio track");ki.enabled=!1}return ki.clone()}class Ja{constructor(e,t){this.onFinally=t,this.promise=new Promise((i,r)=>y(this,void 0,void 0,function*(){this.resolve=i,this.reject=r,e&&(yield e(i,r))})).finally(()=>{var i;return(i=this.onFinally)===null||i===void 0?void 0:i.call(this)})}}function uT(n){return Qk.includes(n)}function Jt(n){if(typeof n=="string"||typeof n=="number")return n;if(Array.isArray(n))return n[0];if(n.exact)return Array.isArray(n.exact)?n.exact[0]:n.exact;if(n.ideal)return Array.isArray(n.ideal)?n.ideal[0]:n.ideal;throw Error("could not unwrap constraint")}function dT(n){return n.startsWith("http")?n.replace(/^(http)/,"ws"):n}function Qa(n){return n.startsWith("ws")?n.replace(/^(ws)/,"http"):n}function hT(n,e){return n.segments.map(t=>{let{id:i,text:r,language:s,startTime:a,endTime:o,final:c}=t;var l;const u=(l=e.get(i))!==null&&l!==void 0?l:Date.now(),d=Date.now();return c?e.delete(i):e.set(i,u),{id:i,text:r,startTime:Number.parseInt(a.toString()),endTime:Number.parseInt(o.toString()),final:c,language:s,firstReceivedTime:u,lastReceivedTime:d}})}function fT(n){const{id:e,timestamp:t,message:i,editTimestamp:r}=n;return{id:e,timestamp:Number.parseInt(t.toString()),editTimestamp:r?Number.parseInt(r.toString()):void 0,message:i}}function Qd(n){switch(n.reason){case $.LeaveRequest:return n.context;case $.Cancelled:return rt.CLIENT_INITIATED;case $.NotAllowed:return rt.USER_REJECTED;case $.ServerUnreachable:return rt.JOIN_FAILURE;default:return rt.UNKNOWN_REASON}}function Yr(n){return n!==void 0?Number(n):void 0}function mn(n){return n!==void 0?BigInt(n):void 0}function Wn(n){return!!n&&!(n instanceof MediaStreamTrack)&&n.isLocal}function Rt(n){return!!n&&n.kind==P.Kind.Audio}function zn(n){return!!n&&n.kind==P.Kind.Video}function Qt(n){return Wn(n)&&zn(n)}function gn(n){return Wn(n)&&Rt(n)}function Za(n){return!!n&&!n.isLocal}function pT(n){return!!n&&!n.isLocal}function eo(n){return Za(n)&&zn(n)}function mT(n){return n.isLocal}function gT(n,e){const t=[];let i=new TextEncoder().encode(n);for(;i.length>e;){let r=e;for(;r>0;){const s=i[r];if(s!==void 0&&(s&192)!==128)break;r--}t.push(i.slice(0,r)),i=i.slice(r)}return i.length>0&&t.push(i),t}function Zd(n,e,t){var i,r,s,a;const{optionsWithoutProcessor:o,audioProcessor:c,videoProcessor:l}=ih(n??{}),u=e==null?void 0:e.processor,d=t==null?void 0:t.processor,h=o??{};return h.audio===!0&&(h.audio={}),h.video===!0&&(h.video={}),h.audio&&(to(h.audio,e),(i=(s=h.audio).deviceId)!==null&&i!==void 0||(s.deviceId={ideal:"default"}),(c||u)&&(h.audio.processor=c??u)),h.video&&(to(h.video,t),(r=(a=h.video).deviceId)!==null&&r!==void 0||(a.deviceId={ideal:"default"}),(l||d)&&(h.video.processor=l??d)),h}function to(n,e){return Object.keys(e).forEach(t=>{n[t]===void 0&&(n[t]=e[t])}),n}function no(n){var e,t,i,r;const s={};if(n.video)if(typeof n.video=="object"){const a={},o=a,c=n.video;Object.keys(c).forEach(l=>{switch(l){case"resolution":to(o,c.resolution);break;default:o[l]=c[l]}}),s.video=a,(e=(i=s.video).deviceId)!==null&&e!==void 0||(i.deviceId={ideal:"default"})}else s.video=n.video?{deviceId:{ideal:"default"}}:!1;else s.video=!1;return n.audio?typeof n.audio=="object"?(s.audio=n.audio,(t=(r=s.audio).deviceId)!==null&&t!==void 0||(r.deviceId={ideal:"default"})):s.audio={deviceId:{ideal:"default"}}:s.audio=!1,s}function eh(n){return y(this,arguments,void 0,function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:200;return function*(){const i=th();if(i){const r=i.createAnalyser();r.fftSize=2048;const s=r.frequencyBinCount,a=new Uint8Array(s);i.createMediaStreamSource(new MediaStream([e.mediaStreamTrack])).connect(r),yield Ge(t),r.getByteTimeDomainData(a);const c=a.some(l=>l!==128&&l!==0);return i.close(),!c}return!1}()})}function th(){var n;const e=typeof window<"u"&&(window.AudioContext||window.webkitAudioContext);if(e){const t=new e({latencyHint:"interactive"});if(t.state==="suspended"&&typeof window<"u"&&(!((n=window.document)===null||n===void 0)&&n.body)){const i=()=>y(this,void 0,void 0,function*(){var r;try{t.state==="suspended"&&(yield t.resume())}catch(s){console.warn("Error trying to auto-resume audio context",s)}(r=window.document.body)===null||r===void 0||r.removeEventListener("click",i)});window.document.body.addEventListener("click",i)}return t}}function vT(n){return n==="audioinput"?P.Source.Microphone:n==="videoinput"?P.Source.Camera:P.Source.Unknown}function nh(n){return n===P.Source.Microphone?"audioinput":n===P.Source.Camera?"videoinput":void 0}function bT(n){var e,t;let i=(e=n.video)!==null&&e!==void 0?e:!0;return n.resolution&&n.resolution.width>0&&n.resolution.height>0&&(i=typeof i=="boolean"?{}:i,Xt()?i=Object.assign(Object.assign({},i),{width:{max:n.resolution.width},height:{max:n.resolution.height},frameRate:n.resolution.frameRate}):i=Object.assign(Object.assign({},i),{width:{ideal:n.resolution.width},height:{ideal:n.resolution.height},frameRate:n.resolution.frameRate})),{audio:(t=n.audio)!==null&&t!==void 0?t:!1,video:i,controller:n.controller,selfBrowserSurface:n.selfBrowserSurface,surfaceSwitching:n.surfaceSwitching,systemAudio:n.systemAudio,preferCurrentTab:n.preferCurrentTab}}function Xr(n){return n.split("/")[1].toLowerCase()}function yT(n){const e=[];return n.forEach(t=>{t.track!==void 0&&e.push(new Ca({cid:t.track.mediaStreamID,track:t.trackInfo}))}),e}function ee(n){return"mediaStreamTrack"in n?{trackID:n.sid,source:n.source,muted:n.isMuted,enabled:n.mediaStreamTrack.enabled,kind:n.kind,streamID:n.mediaStreamID,streamTrackID:n.mediaStreamTrack.id}:{trackID:n.trackSid,enabled:n.isEnabled,muted:n.isMuted,trackInfo:Object.assign({mimeType:n.mimeType,name:n.trackName,encrypted:n.isEncrypted,kind:n.kind,source:n.source},n.track?ee(n.track):{})}}function kT(){return typeof RTCRtpReceiver<"u"&&"getSynchronizationSources"in RTCRtpReceiver}function TT(n,e){var t;n===void 0&&(n={}),e===void 0&&(e={});const i=[...Object.keys(e),...Object.keys(n)],r={};for(const s of i)n[s]!==e[s]&&(r[s]=(t=e[s])!==null&&t!==void 0?t:"");return r}function ih(n){const e=Object.assign({},n);let t,i;return typeof e.audio=="object"&&e.audio.processor&&(t=e.audio.processor,e.audio=Object.assign(Object.assign({},e.audio),{processor:void 0})),typeof e.video=="object"&&e.video.processor&&(i=e.video.processor,e.video=Object.assign(Object.assign({},e.video),{processor:void 0})),{audioProcessor:t,videoProcessor:i,optionsWithoutProcessor:zk(e)}}function ST(n){switch(n){case ke.CAMERA:return P.Source.Camera;case ke.MICROPHONE:return P.Source.Microphone;case ke.SCREEN_SHARE:return P.Source.ScreenShare;case ke.SCREEN_SHARE_AUDIO:return P.Source.ScreenShareAudio;default:return P.Source.Unknown}}class CT extends Tt.EventEmitter{constructor(e){super(),this.onWorkerMessage=t=>{var i,r;const{kind:s,data:a}=t.data;switch(s){case"error":q.error(a.error.message),this.emit($t.EncryptionError,a.error);break;case"initAck":a.enabled&&this.keyProvider.getKeys().forEach(o=>{this.postKey(o)});break;case"enable":if(a.enabled&&this.keyProvider.getKeys().forEach(o=>{this.postKey(o)}),this.encryptionEnabled!==a.enabled&&a.participantIdentity===((i=this.room)===null||i===void 0?void 0:i.localParticipant.identity))this.emit($t.ParticipantEncryptionStatusChanged,a.enabled,this.room.localParticipant),this.encryptionEnabled=a.enabled;else if(a.participantIdentity){const o=(r=this.room)===null||r===void 0?void 0:r.getParticipantByIdentity(a.participantIdentity);if(!o)throw TypeError("couldn't set encryption status, participant not found".concat(a.participantIdentity));this.emit($t.ParticipantEncryptionStatusChanged,a.enabled,o)}break;case"ratchetKey":this.keyProvider.emit(Kt.KeyRatcheted,a.ratchetResult,a.participantIdentity,a.keyIndex);break}},this.onWorkerError=t=>{q.error("e2ee worker encountered an error:",{error:t.error}),this.emit($t.EncryptionError,t.error)},this.keyProvider=e.keyProvider,this.worker=e.worker,this.encryptionEnabled=!1}setup(e){if(!Vk())throw new Da("tried to setup end-to-end encryption on an unsupported browser");if(q.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:_k.getLevel()}};this.worker&&(q.info("initializing worker",{worker:this.worker}),this.worker.onmessage=this.onWorkerMessage,this.worker.onerror=this.onWorkerError,this.worker.postMessage(t))}}setParticipantCryptorEnabled(e,t){q.debug("set e2ee to ".concat(e," for participant ").concat(t)),this.postEnable(e,t)}setSifTrailer(e){!e||e.length===0?q.warn("ignoring server sent trailer as it's empty"):this.postSifTrailer(e)}setupEngine(e){e.on(M.RTPVideoMapUpdate,t=>{this.postRTPMap(t)})}setupEventListeners(e,t){e.on(O.TrackPublished,(i,r)=>this.setParticipantCryptorEnabled(i.trackInfo.encryption!==$e.NONE,r.identity)),e.on(O.ConnectionStateChanged,i=>{i===J.Connected&&e.remoteParticipants.forEach(r=>{r.trackPublications.forEach(s=>{this.setParticipantCryptorEnabled(s.trackInfo.encryption!==$e.NONE,r.identity)})})}).on(O.TrackUnsubscribed,(i,r,s)=>{var a;const o={kind:"removeTransform",data:{participantIdentity:s.identity,trackId:i.mediaStreamID}};(a=this.worker)===null||a===void 0||a.postMessage(o)}).on(O.TrackSubscribed,(i,r,s)=>{this.setupE2EEReceiver(i,s.identity,r.trackInfo)}).on(O.SignalConnected,()=>{if(!this.room)throw new TypeError("expected room to be present on signal connect");t.getKeys().forEach(i=>{this.postKey(i)}),this.setParticipantCryptorEnabled(this.room.localParticipant.isE2EEEnabled,this.room.localParticipant.identity)}),e.localParticipant.on(L.LocalTrackPublished,i=>y(this,void 0,void 0,function*(){this.setupE2EESender(i.track,i.track.sender)})),t.on(Kt.SetKey,i=>this.postKey(i)).on(Kt.RatchetRequest,(i,r)=>this.postRatchetRequest(i,r))}postRatchetRequest(e,t){if(!this.worker)throw Error("could not ratchet key, worker is missing");const i={kind:"ratchetRequest",data:{participantIdentity:e,keyIndex:t}};this.worker.postMessage(i)}postKey(e){let{key:t,participantIdentity:i,keyIndex:r}=e;var s;if(!this.worker)throw Error("could not set key, worker is missing");const a={kind:"setKey",data:{participantIdentity:i,isPublisher:i===((s=this.room)===null||s===void 0?void 0:s.localParticipant.identity),key:t,keyIndex:r}};this.worker.postMessage(a)}postEnable(e,t){if(this.worker){const i={kind:"enable",data:{enabled:e,participantIdentity:t}};this.worker.postMessage(i)}else throw new ReferenceError("failed to enable e2ee, worker is not ready")}postRTPMap(e){var t;if(!this.worker)throw TypeError("could not post rtp map, worker is missing");if(!(!((t=this.room)===null||t===void 0)&&t.localParticipant.identity))throw TypeError("could not post rtp map, local participant identity is missing");const i={kind:"setRTPMap",data:{map:e,participantIdentity:this.room.localParticipant.identity}};this.worker.postMessage(i)}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,i){if(e.receiver){if(!(i!=null&&i.mimeType)||i.mimeType==="")throw new TypeError("MimeType missing from trackInfo, cannot set up E2EE cryptor");this.handleReceiver(e.receiver,e.mediaStreamID,t,e.kind==="video"?Xr(i.mimeType):void 0)}}setupE2EESender(e,t){if(!Wn(e)||!t){t||q.warn("early return because sender is not ready");return}this.handleSender(t,e.mediaStreamID,void 0)}handleReceiver(e,t,i,r){return y(this,void 0,void 0,function*(){if(this.worker){if(La()){const s={kind:"decode",participantIdentity:i,trackId:t,codec:r};e.transform=new RTCRtpScriptTransform(this.worker,s)}else{if(qr in e&&r){const c={kind:"updateCodec",data:{trackId:t,codec:r,participantIdentity:i}};this.worker.postMessage(c);return}let s=e.writableStream,a=e.readableStream;if(!s||!a){const c=e.createEncodedStreams();e.writableStream=c.writable,s=c.writable,e.readableStream=c.readable,a=c.readable}const o={kind:"decode",data:{readableStream:a,writableStream:s,trackId:t,codec:r,participantIdentity:i}};this.worker.postMessage(o,[a,s])}e[qr]=!0}})}handleSender(e,t,i){var r;if(!(qr in e||!this.worker)){if(!(!((r=this.room)===null||r===void 0)&&r.localParticipant.identity)||this.room.localParticipant.identity==="")throw TypeError("local identity needs to be known in order to set up encrypted sender");if(La()){q.info("initialize script transform");const s={kind:"encode",participantIdentity:this.room.localParticipant.identity,trackId:t,codec:i};e.transform=new RTCRtpScriptTransform(this.worker,s)}else{q.info("initialize encoded streams");const s=e.createEncodedStreams(),a={kind:"encode",data:{readableStream:s.readable,writableStream:s.writable,codec:i,trackId:t,participantIdentity:this.room.localParticipant.identity}};this.worker.postMessage(a,[s.readable,s.writable])}e[qr]=!0}}}const io="default";class we{constructor(){this._previousDevices=[]}static getInstance(){return this.instance===void 0&&(this.instance=new we),this.instance}get previousDevices(){return this._previousDevices}getDevices(e){return y(this,arguments,void 0,function(t){var i=this;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return function*(){var s;if(((s=we.userMediaPromiseMap)===null||s===void 0?void 0:s.size)>0){q.debug("awaiting getUserMedia promise");try{t?yield we.userMediaPromiseMap.get(t):yield Promise.all(we.userMediaPromiseMap.values())}catch{q.warn("error waiting for media permissons")}}let a=yield navigator.mediaDevices.enumerateDevices();if(r&&!(Xt()&&i.hasDeviceInUse(t))&&(a.filter(c=>c.kind===t).length===0||a.some(c=>{const l=c.label==="",u=t?c.kind===t:!0;return l&&u}))){const c={video:t!=="audioinput"&&t!=="audiooutput",audio:t!=="videoinput"&&{deviceId:{ideal:"default"}}},l=yield navigator.mediaDevices.getUserMedia(c);a=yield navigator.mediaDevices.enumerateDevices(),l.getTracks().forEach(u=>{u.stop()})}return i._previousDevices=a,t&&(a=a.filter(o=>o.kind===t)),a}()})}normalizeDeviceId(e,t,i){return y(this,void 0,void 0,function*(){if(t!==io)return t;const r=yield this.getDevices(e),s=r.find(o=>o.deviceId===io);if(!s){q.warn("could not reliably determine default device");return}const a=r.find(o=>o.deviceId!==io&&o.groupId===(i??s.groupId));if(!a){q.warn("could not reliably determine default device");return}return a==null?void 0:a.deviceId})}hasDeviceInUse(e){return e?we.userMediaPromiseMap.has(e):we.userMediaPromiseMap.size>0}}we.mediaDeviceKinds=["audioinput","audiooutput","videoinput"],we.userMediaPromiseMap=new Map;var Ti;(function(n){n[n.WAITING=0]="WAITING",n[n.RUNNING=1]="RUNNING",n[n.COMPLETED=2]="COMPLETED"})(Ti||(Ti={}));class xT{constructor(){this.pendingTasks=new Map,this.taskMutex=new Fe,this.nextTaskIndex=0}run(e){return y(this,void 0,void 0,function*(){const t={id:this.nextTaskIndex++,enqueuedAt:Date.now(),status:Ti.WAITING};this.pendingTasks.set(t.id,t);const i=yield this.taskMutex.lock();try{return t.executedAt=Date.now(),t.status=Ti.RUNNING,yield e()}finally{t.status=Ti.COMPLETED,this.pendingTasks.delete(t.id),i()}})}flush(){return y(this,void 0,void 0,function*(){return this.run(()=>y(this,void 0,void 0,function*(){}))})}snapshot(){return Array.from(this.pendingTasks.values())}}function wT(n,e){const t=new URL(dT(n));return e.forEach((i,r)=>{t.searchParams.set(r,i)}),rh(t,"rtc")}function _T(n){const e=new URL(Qa(n));return rh(e,"validate")}function ET(n){return n.endsWith("/")?n:"".concat(n,"/")}function rh(n,e){return n.pathname="".concat(ET(n.pathname)).concat(e),n.toString()}const PT=["syncState","trickle","offer","answer","simulate","leave"];function RT(n){const e=PT.indexOf(n.case)>=0;return q.trace("request allowed to bypass queue:",{canPass:e,req:n}),e}var oe;(function(n){n[n.CONNECTING=0]="CONNECTING",n[n.CONNECTED=1]="CONNECTED",n[n.RECONNECTING=2]="RECONNECTING",n[n.DISCONNECTING=3]="DISCONNECTING",n[n.DISCONNECTED=4]="DISCONNECTED"})(oe||(oe={}));class ro{get currentState(){return this.state}get isDisconnected(){return this.state===oe.DISCONNECTING||this.state===oe.DISCONNECTED}get isEstablishingConnection(){return this.state===oe.CONNECTING||this.state===oe.RECONNECTING}getNextRequestId(){return this._requestId+=1,this._requestId}constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var i;this.rtt=0,this.state=oe.DISCONNECTED,this.log=q,this._requestId=0,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=Et((i=t.loggerName)!==null&&i!==void 0?i:ot.Signal),this.loggerContextCb=t.loggerContextCb,this.useJSON=e,this.requestQueue=new xT,this.queuedRequests=[],this.closingLock=new Fe,this.connectionLock=new Fe,this.state=oe.DISCONNECTED}get logContext(){var e,t;return(t=(e=this.loggerContextCb)===null||e===void 0?void 0:e.call(this))!==null&&t!==void 0?t:{}}join(e,t,i,r){return y(this,void 0,void 0,function*(){return this.state=oe.CONNECTING,this.options=i,yield this.connect(e,t,i,r)})}reconnect(e,t,i,r){return y(this,void 0,void 0,function*(){if(!this.options){this.log.warn("attempted to reconnect without signal options being set, ignoring",this.logContext);return}return this.state=oe.RECONNECTING,this.clearPingInterval(),yield this.connect(e,t,Object.assign(Object.assign({},this.options),{reconnect:!0,sid:i,reconnectReason:r}))})}connect(e,t,i,r){this.connectOptions=i;const s=lT(),a=IT(t,s,i),o=wT(e,a),c=_T(o);return new Promise((l,u)=>y(this,void 0,void 0,function*(){const d=yield this.connectionLock.lock();try{const h=()=>y(this,void 0,void 0,function*(){this.close(),clearTimeout(f),u(new ie("room connection has been cancelled (signal)",$.Cancelled))}),f=setTimeout(()=>{this.close(),u(new ie("room connection has timed out (signal)",$.ServerUnreachable))},i.websocketTimeout);r!=null&&r.aborted&&h(),r==null||r.addEventListener("abort",h);const p=new URL(o);p.searchParams.has("access_token")&&p.searchParams.set("access_token","<redacted>"),this.log.debug("connecting to ".concat(p),Object.assign({reconnect:i.reconnect,reconnectReason:i.reconnectReason},this.logContext)),this.ws&&(yield this.close(!1)),this.ws=new WebSocket(o),this.ws.binaryType="arraybuffer",this.ws.onopen=()=>{clearTimeout(f)},this.ws.onerror=g=>y(this,void 0,void 0,function*(){if(this.state!==oe.CONNECTED){this.state=oe.DISCONNECTED,clearTimeout(f);try{const v=yield fetch(c);if(v.status.toFixed(0).startsWith("4")){const b=yield v.text();u(new ie(b,$.NotAllowed,v.status))}else u(new ie("Encountered unknown websocket error during connection: ".concat(g.toString()),$.InternalError,v.status))}catch(v){u(new ie(v instanceof Error?v.message:"server was not reachable",$.ServerUnreachable))}return}this.handleWSError(g)}),this.ws.onmessage=g=>y(this,void 0,void 0,function*(){var v,b,S;let x;if(typeof g.data=="string"){const k=JSON.parse(g.data);x=ju.fromJson(k,{ignoreUnknownFields:!0})}else if(g.data instanceof ArrayBuffer)x=ju.fromBinary(new Uint8Array(g.data));else{this.log.error("could not decode websocket message: ".concat(typeof g.data),this.logContext);return}if(this.state!==oe.CONNECTED){let k=!1;if(((v=x.message)===null||v===void 0?void 0:v.case)==="join"?(this.state=oe.CONNECTED,r==null||r.removeEventListener("abort",h),this.pingTimeoutDuration=x.message.value.pingTimeout,this.pingIntervalDuration=x.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()),l(x.message.value)):this.state===oe.RECONNECTING&&x.message.case!=="leave"?(this.state=oe.CONNECTED,r==null||r.removeEventListener("abort",h),this.startPingInterval(),((b=x.message)===null||b===void 0?void 0:b.case)==="reconnect"?l(x.message.value):(this.log.debug("declaring signal reconnected without reconnect response received",this.logContext),l(void 0),k=!0)):this.isEstablishingConnection&&x.message.case==="leave"?u(new ie("Received leave request while trying to (re)connect",$.LeaveRequest,void 0,x.message.value.reason)):i.reconnect||u(new ie("did not receive join response, got ".concat((S=x.message)===null||S===void 0?void 0:S.case," instead"),$.InternalError)),!k)return}this.signalLatency&&(yield Ge(this.signalLatency)),this.handleSignalResponse(x)}),this.ws.onclose=g=>{this.isEstablishingConnection&&u(new ie("Websocket got closed during a (re)connection attempt",$.InternalError)),this.log.warn("websocket closed",Object.assign(Object.assign({},this.logContext),{reason:g.reason,code:g.code,wasClean:g.wasClean,state:this.state})),this.handleOnClose(g.reason)}}finally{d()}}))}close(){return y(this,arguments,void 0,function(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return function*(){const i=yield e.closingLock.lock();try{if(e.clearPingInterval(),t&&(e.state=oe.DISCONNECTING),e.ws){e.ws.onmessage=null,e.ws.onopen=null,e.ws.onclose=null;const r=new Promise(s=>{e.ws?e.ws.onclose=()=>{s()}:s()});e.ws.readyState<e.ws.CLOSING&&(e.ws.close(),yield Promise.race([r,Ge(250)])),e.ws=void 0}}finally{t&&(e.state=oe.DISCONNECTED),i()}}()})}sendOffer(e){this.log.debug("sending offer",Object.assign(Object.assign({},this.logContext),{offerSdp:e.sdp})),this.sendRequest({case:"offer",value:Jr(e)})}sendAnswer(e){return this.log.debug("sending answer",Object.assign(Object.assign({},this.logContext),{answerSdp:e.sdp})),this.sendRequest({case:"answer",value:Jr(e)})}sendIceCandidate(e,t){return this.log.debug("sending ice candidate",Object.assign(Object.assign({},this.logContext),{candidate:e})),this.sendRequest({case:"trickle",value:new Ta({candidateInit:JSON.stringify(e),target:t})})}sendMuteTrack(e,t){return this.sendRequest({case:"mute",value:new Sa({sid:e,muted:t})})}sendAddTrack(e){return this.sendRequest({case:"addTrack",value:e})}sendUpdateLocalMetadata(e,t){return y(this,arguments,void 0,function(i,r){var s=this;let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return function*(){const o=s.getNextRequestId();return yield s.sendRequest({case:"updateMetadata",value:new zu({requestId:o,metadata:i,name:r,attributes:a})}),o}()})}sendUpdateTrackSettings(e){this.sendRequest({case:"trackSetting",value:e})}sendUpdateSubscription(e){return this.sendRequest({case:"subscription",value:e})}sendSyncState(e){return this.sendRequest({case:"syncState",value:e})}sendUpdateVideoLayers(e,t){return this.sendRequest({case:"updateLayers",value:new Wu({trackSid:e,layers:t})})}sendUpdateSubscriptionPermissions(e,t){return this.sendRequest({case:"subscriptionPermission",value:new Ku({allParticipants:e,trackPermissions:t})})}sendSimulateScenario(e){return this.sendRequest({case:"simulate",value:e})}sendPing(){return Promise.all([this.sendRequest({case:"ping",value:le.parse(Date.now())}),this.sendRequest({case:"pingReq",value:new Xu({timestamp:le.parse(Date.now()),rtt:le.parse(this.rtt)})})])}sendUpdateLocalAudioTrack(e,t){return this.sendRequest({case:"updateAudioTrack",value:new Gu({trackSid:e,features:t})})}sendLeave(){return this.sendRequest({case:"leave",value:new Dr({reason:rt.CLIENT_INITIATED,action:Bn.DISCONNECT})})}sendRequest(e){return y(this,arguments,void 0,function(t){var i=this;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return function*(){if(!r&&!RT(t)&&i.state===oe.RECONNECTING){i.queuedRequests.push(()=>y(i,void 0,void 0,function*(){yield this.sendRequest(t,!0)}));return}if(r||(yield i.requestQueue.flush()),i.signalLatency&&(yield Ge(i.signalLatency)),!i.ws||i.ws.readyState!==i.ws.OPEN){i.log.error("cannot send signal request before connected, type: ".concat(t==null?void 0:t.case),i.logContext);return}const a=new tk({message:t});try{i.useJSON?i.ws.send(a.toJsonString()):i.ws.send(a.toBinary())}catch(o){i.log.error("error sending signal message",Object.assign(Object.assign({},i.logContext),{error:o}))}}()})}handleSignalResponse(e){var t,i;const r=e.message;if(r==null){this.log.debug("received unsupported message",this.logContext);return}let s=!1;if(r.case==="answer"){const a=sh(r.value);this.onAnswer&&this.onAnswer(a)}else if(r.case==="offer"){const a=sh(r.value);this.onOffer&&this.onOffer(a)}else if(r.case==="trickle"){const a=JSON.parse(r.value.candidateInit);this.onTrickle&&this.onTrickle(a,r.value.target)}else r.case==="update"?this.onParticipantUpdate&&this.onParticipantUpdate((t=r.value.participants)!==null&&t!==void 0?t:[]):r.case==="trackPublished"?this.onLocalTrackPublished&&this.onLocalTrackPublished(r.value):r.case==="speakersChanged"?this.onSpeakersChanged&&this.onSpeakersChanged((i=r.value.speakers)!==null&&i!==void 0?i:[]):r.case==="leave"?this.onLeave&&this.onLeave(r.value):r.case==="mute"?this.onRemoteMuteChanged&&this.onRemoteMuteChanged(r.value.sid,r.value.muted):r.case==="roomUpdate"?this.onRoomUpdate&&r.value.room&&this.onRoomUpdate(r.value.room):r.case==="connectionQuality"?this.onConnectionQuality&&this.onConnectionQuality(r.value):r.case==="streamStateUpdate"?this.onStreamStateUpdate&&this.onStreamStateUpdate(r.value):r.case==="subscribedQualityUpdate"?this.onSubscribedQualityUpdate&&this.onSubscribedQualityUpdate(r.value):r.case==="subscriptionPermissionUpdate"?this.onSubscriptionPermissionUpdate&&this.onSubscriptionPermissionUpdate(r.value):r.case==="refreshToken"?this.onTokenRefresh&&this.onTokenRefresh(r.value):r.case==="trackUnpublished"?this.onLocalTrackUnpublished&&this.onLocalTrackUnpublished(r.value):r.case==="subscriptionResponse"?this.onSubscriptionError&&this.onSubscriptionError(r.value):r.case==="pong"||(r.case==="pongResp"?(this.rtt=Date.now()-Number.parseInt(r.value.lastPingTimestamp.toString()),this.resetPingTimeout(),s=!0):r.case==="requestResponse"?this.onRequestResponse&&this.onRequestResponse(r.value):r.case==="trackSubscribed"?this.onLocalTrackSubscribed&&this.onLocalTrackSubscribed(r.value.trackSid):r.case==="roomMoved"?(this.onTokenRefresh&&this.onTokenRefresh(r.value.token),this.onRoomMoved&&this.onRoomMoved(r.value)):this.log.debug("unsupported message",Object.assign(Object.assign({},this.logContext),{msgCase:r.case})));s||this.resetPingTimeout()}setReconnected(){for(;this.queuedRequests.length>0;){const e=this.queuedRequests.shift();e&&this.requestQueue.run(e)}}handleOnClose(e){return y(this,void 0,void 0,function*(){if(this.state===oe.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(){if(this.clearPingTimeout(),!this.pingTimeoutDuration){this.log.warn("ping timeout duration not set",this.logContext);return}this.pingTimeout=Ie.setTimeout(()=>{this.log.warn("ping timeout triggered. last pong received at: ".concat(new Date(Date.now()-this.pingTimeoutDuration*1e3).toUTCString()),this.logContext),this.handleOnClose("ping timeout")},this.pingTimeoutDuration*1e3)}clearPingTimeout(){this.pingTimeout&&Ie.clearTimeout(this.pingTimeout)}startPingInterval(){if(this.clearPingInterval(),this.resetPingTimeout(),!this.pingIntervalDuration){this.log.warn("ping interval duration not set",this.logContext);return}this.log.debug("start ping interval",this.logContext),this.pingInterval=Ie.setInterval(()=>{this.sendPing()},this.pingIntervalDuration*1e3)}clearPingInterval(){this.log.debug("clearing ping interval",this.logContext),this.clearPingTimeout(),this.pingInterval&&Ie.clearInterval(this.pingInterval)}}function sh(n){const e={type:"offer",sdp:n.sdp};switch(n.type){case"answer":case"offer":case"pranswer":case"rollback":e.type=n.type;break}return e}function Jr(n){return new hn({sdp:n.sdp,type:n.type})}function IT(n,e,t){var i;const r=new URLSearchParams;return r.set("access_token",n),t.reconnect&&(r.set("reconnect","1"),t.sid&&r.set("sid",t.sid)),r.set("auto_subscribe",t.autoSubscribe?"1":"0"),r.set("sdk",St()?"reactnative":"js"),r.set("version",e.version),r.set("protocol",e.protocol.toString()),e.deviceModel&&r.set("device_model",e.deviceModel),e.os&&r.set("os",e.os),e.osVersion&&r.set("os_version",e.osVersion),e.browser&&r.set("browser",e.browser),e.browserVersion&&r.set("browser_version",e.browserVersion),t.adaptiveStream&&r.set("adaptive_stream","1"),t.reconnectReason&&r.set("reconnect_reason",t.reconnectReason.toString()),!((i=navigator.connection)===null||i===void 0)&&i.type&&r.set("network",navigator.connection.type),r}var lt={},so={},ao={exports:{}},ah;function oo(){if(ah)return ao.exports;ah=1;var n=ao.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 e.address!=null?"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 e.subtype!=null?"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 e.sessionConfig!=null?"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+=e.raddr!=null?" raddr %s rport %d":"%v%v",t+=e.tcptype!=null?" tcptype %s":"%v",e.generation!=null&&(t+=" generation %d"),t+=e["network-id"]!=null?" network-id %d":"%v",t+=e["network-cost"]!=null?" network-cost %d":"%v",t}},{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 e.attribute!=null&&(t+=" %s",e.value!=null&&(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 e.maxMessageSize!=null?"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"+(e.clksrcExt!=null?"=%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+=e.id!=null?"id=%s %s":"%v%s",t+=e.mediaClockValue!=null?"=%s":"",t+=e.rateNumerator!=null?" rate=%s":"",t+=e.rateDenominator!=null?"/%s":"",t}},{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"]}]};return Object.keys(n).forEach(function(e){var t=n[e];t.forEach(function(i){i.reg||(i.reg=/(.*)/),i.format||(i.format="%s")})}),ao.exports}var oh;function OT(){return oh||(oh=1,function(n){var e=function(o){return String(Number(o))===o?Number(o):o},t=function(o,c,l,u){if(u&&!l)c[u]=e(o[1]);else for(var d=0;d<l.length;d+=1)o[d+1]!=null&&(c[l[d]]=e(o[d+1]))},i=function(o,c,l){var u=o.name&&o.names;o.push&&!c[o.push]?c[o.push]=[]:u&&!c[o.name]&&(c[o.name]={});var d=o.push?{}:u?c[o.name]:c;t(l.match(o.reg),d,o.names,o.name),o.push&&c[o.push].push(d)},r=oo(),s=RegExp.prototype.test.bind(/^([a-z])=(.*)/);n.parse=function(o){var c={},l=[],u=c;return o.split(/(\r\n|\r|\n)/).filter(s).forEach(function(d){var h=d[0],f=d.slice(2);h==="m"&&(l.push({rtp:[],fmtp:[]}),u=l[l.length-1]);for(var p=0;p<(r[h]||[]).length;p+=1){var g=r[h][p];if(g.reg.test(f))return i(g,u,f)}}),c.media=l,c};var a=function(o,c){var l=c.split(/=(.+)/,2);return l.length===2?o[l[0]]=e(l[1]):l.length===1&&c.length>1&&(o[l[0]]=void 0),o};n.parseParams=function(o){return o.split(/;\s?/).reduce(a,{})},n.parseFmtpConfig=n.parseParams,n.parsePayloads=function(o){return o.toString().split(" ").map(Number)},n.parseRemoteCandidates=function(o){for(var c=[],l=o.split(" ").map(e),u=0;u<l.length;u+=3)c.push({component:l[u],ip:l[u+1],port:l[u+2]});return c},n.parseImageAttributes=function(o){return o.split(" ").map(function(c){return c.substring(1,c.length-1).split(",").reduce(a,{})})},n.parseSimulcastStreamList=function(o){return o.split(";").map(function(c){return c.split(",").map(function(l){var u,d=!1;return l[0]!=="~"?u=e(l):(u=e(l.substring(1,l.length)),d=!0),{scid:u,paused:d}})})}}(so)),so}var co,ch;function AT(){if(ch)return co;ch=1;var n=oo(),e=/%[sdv%]/g,t=function(a){var o=1,c=arguments,l=c.length;return a.replace(e,function(u){if(o>=l)return u;var d=c[o];switch(o+=1,u){case"%%":return"%";case"%s":return String(d);case"%d":return Number(d);case"%v":return""}})},i=function(a,o,c){var l=o.format instanceof Function?o.format(o.push?c:c[o.name]):o.format,u=[a+"="+l];if(o.names)for(var d=0;d<o.names.length;d+=1){var h=o.names[d];o.name?u.push(c[o.name][h]):u.push(c[o.names[d]])}else u.push(c[o.name]);return t.apply(null,u)},r=["v","o","s","i","u","e","p","c","b","t","r","z","a"],s=["i","c","b","a"];return co=function(a,o){o=o||{},a.version==null&&(a.version=0),a.name==null&&(a.name=" "),a.media.forEach(function(d){d.payloads==null&&(d.payloads="")});var c=o.outerOrder||r,l=o.innerOrder||s,u=[];return c.forEach(function(d){n[d].forEach(function(h){h.name in a&&a[h.name]!=null?u.push(i(d,h,a)):h.push in a&&a[h.push]!=null&&a[h.push].forEach(function(f){u.push(i(d,h,f))})})}),a.media.forEach(function(d){u.push(i("m",n.m[0],d)),l.forEach(function(h){n[h].forEach(function(f){f.name in d&&d[f.name]!=null?u.push(i(h,f,d)):f.push in d&&d[f.push]!=null&&d[f.push].forEach(function(p){u.push(i(h,f,p))})})})}),u.join(`\r
119
41
  `)+`\r
120
- `},Vp}var AS;function cU(){if(AS)return mn;AS=1;var n=sU(),e=aU(),t=jp();return mn.grammar=t,mn.write=e,mn.parse=n.parse,mn.parseParams=n.parseParams,mn.parseFmtpConfig=n.parseFmtpConfig,mn.parsePayloads=n.parsePayloads,mn.parseRemoteCandidates=n.parseRemoteCandidates,mn.parseImageAttributes=n.parseImageAttributes,mn.parseSimulcastStreamList=n.parseSimulcastStreamList,mn}var Mi=cU();function zp(n,e,t){var i,r,o;e===void 0&&(e=50),t===void 0&&(t={});var s=(i=t.isImmediate)!=null&&i,a=(r=t.callback)!=null&&r,c=t.maxWait,u=Date.now(),l=[];function d(){if(c!==void 0){var p=Date.now()-u;if(p+e>=c)return c-p}return e}var h=function(){var p=[].slice.call(arguments),m=this;return new Promise(function(f,g){var y=s&&o===void 0;if(o!==void 0&&clearTimeout(o),o=setTimeout(function(){if(o=void 0,u=Date.now(),!s){var S=n.apply(m,p);a&&a(S),l.forEach(function(w){return(0,w.resolve)(S)}),l=[]}},d()),y){var b=n.apply(m,p);return a&&a(b),f(b)}l.push({resolve:f,reject:g})})};return h.cancel=function(p){o!==void 0&&clearTimeout(o),l.forEach(function(m){return(0,m.reject)(p)}),l=[]},h}const uU=.7,lU=20,ho={NegotiationStarted:"negotiationStarted",NegotiationComplete:"negotiationComplete",RTPVideoPayloadTypes:"rtpVideoPayloadTypes"};class MS extends Mn.EventEmitter{get pc(){return this._pc||(this._pc=this.createPC()),this._pc}constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var i;super(),this.log=le,this.ddExtID=0,this.pendingCandidates=[],this.restartingIce=!1,this.renegotiate=!1,this.trackBitrates=[],this.remoteStereoMids=[],this.remoteNackMids=[],this.negotiate=zp(r=>T(this,void 0,void 0,function*(){this.emit(ho.NegotiationStarted);try{yield this.createAndSendOffer()}catch(o){if(r)r(o);else throw o}}),lU),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=Kn((i=t.loggerName)!==null&&i!==void 0?i:pn.PCTransport),this.loggerOptions=t,this.config=e,this._pc=this.createPC()}createPC(){const e=new RTCPeerConnection(this.config);return e.onicecandidate=t=>{var i;t.candidate&&((i=this.onIceCandidate)===null||i===void 0||i.call(this,t.candidate))},e.onicecandidateerror=t=>{var i;(i=this.onIceCandidateError)===null||i===void 0||i.call(this,t)},e.oniceconnectionstatechange=()=>{var t;(t=this.onIceConnectionStateChange)===null||t===void 0||t.call(this,e.iceConnectionState)},e.onsignalingstatechange=()=>{var t;(t=this.onSignalingStatechange)===null||t===void 0||t.call(this,e.signalingState)},e.onconnectionstatechange=()=>{var t;(t=this.onConnectionStateChange)===null||t===void 0||t.call(this,e.connectionState)},e.ondatachannel=t=>{var i;(i=this.onDataChannel)===null||i===void 0||i.call(this,t)},e.ontrack=t=>{var i;(i=this.onTrack)===null||i===void 0||i.call(this,t)},e}get logContext(){var e,t;return Object.assign({},(t=(e=this.loggerOptions).loggerContextCb)===null||t===void 0?void 0:t.call(e))}get isICEConnected(){return this._pc!==null&&(this.pc.iceConnectionState==="connected"||this.pc.iceConnectionState==="completed")}addIceCandidate(e){return T(this,void 0,void 0,function*(){if(this.pc.remoteDescription&&!this.restartingIce)return this.pc.addIceCandidate(e);this.pendingCandidates.push(e)})}setRemoteDescription(e){return T(this,void 0,void 0,function*(){var t;let i;if(e.type==="offer"){let{stereoMids:r,nackMids:o}=dU(e);this.remoteStereoMids=r,this.remoteNackMids=o}else if(e.type==="answer"){const r=Mi.parse((t=e.sdp)!==null&&t!==void 0?t:"");r.media.forEach(o=>{o.type==="audio"&&this.trackBitrates.some(s=>{if(!s.transceiver||o.mid!=s.transceiver.mid)return!1;let a=0;if(o.rtp.some(u=>u.codec.toUpperCase()===s.codec.toUpperCase()?(a=u.payload,!0):!1),a===0)return!0;let c=!1;for(const u of o.fmtp)if(u.payload===a){u.config=u.config.split(";").filter(l=>!l.includes("maxaveragebitrate")).join(";"),s.maxbr>0&&(u.config+=";maxaveragebitrate=".concat(s.maxbr*1e3)),c=!0;break}return c||s.maxbr>0&&o.fmtp.push({payload:a,config:"maxaveragebitrate=".concat(s.maxbr*1e3)}),!0})}),i=Mi.write(r)}yield this.setMungedSDP(e,i,!0),this.pendingCandidates.forEach(r=>{this.pc.addIceCandidate(r)}),this.pendingCandidates=[],this.restartingIce=!1,this.renegotiate?(this.renegotiate=!1,yield this.createAndSendOffer()):e.type==="answer"&&(this.emit(ho.NegotiationComplete),e.sdp&&Mi.parse(e.sdp).media.forEach(o=>{o.type==="video"&&this.emit(ho.RTPVideoPayloadTypes,o.rtp)}))})}createAndSendOffer(e){return T(this,void 0,void 0,function*(){var t;if(this.onOffer===void 0)return;if(e!=null&&e.iceRestart&&(this.log.debug("restarting ICE",this.logContext),this.restartingIce=!0),this._pc&&this._pc.signalingState==="have-local-offer"){const o=this._pc.remoteDescription;if(e!=null&&e.iceRestart&&o)yield this._pc.setRemoteDescription(o);else{this.renegotiate=!0;return}}else if(!this._pc||this._pc.signalingState==="closed"){this.log.warn("could not createOffer with closed peer connection",this.logContext);return}this.log.debug("starting to negotiate",this.logContext);const i=yield this.pc.createOffer(e);this.log.debug("original offer",Object.assign({sdp:i.sdp},this.logContext));const r=Mi.parse((t=i.sdp)!==null&&t!==void 0?t:"");r.media.forEach(o=>{DS(o),o.type==="audio"?NS(o,[],[]):o.type==="video"&&this.trackBitrates.some(s=>{if(!o.msid||!s.cid||!o.msid.includes(s.cid))return!1;let a=0;if(o.rtp.some(u=>u.codec.toUpperCase()===s.codec.toUpperCase()?(a=u.payload,!0):!1),a===0||(vs(s.codec)&&this.ensureVideoDDExtensionForSVC(o,r),s.codec!=="av1"))return!0;const c=Math.round(s.maxbr*uU);for(const u of o.fmtp)if(u.payload===a){u.config.includes("x-google-start-bitrate")||(u.config+=";x-google-start-bitrate=".concat(c));break}return!0})}),yield this.setMungedSDP(i,Mi.write(r)),this.onOffer(i)})}createAndSetAnswer(){return T(this,void 0,void 0,function*(){var e;const t=yield this.pc.createAnswer(),i=Mi.parse((e=t.sdp)!==null&&e!==void 0?e:"");return i.media.forEach(r=>{DS(r),r.type==="audio"&&NS(r,this.remoteStereoMids,this.remoteNackMids)}),yield this.setMungedSDP(t,Mi.write(i)),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 lt("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 lt("PC closed, cannot configure");return(t=this._pc)===null||t===void 0?void 0:t.setConfiguration(e)}canRemoveTrack(){var e;return!!(!((e=this._pc)===null||e===void 0)&&e.removeTrack)}removeTrack(e){var t;return(t=this._pc)===null||t===void 0?void 0:t.removeTrack(e)}getConnectionState(){var e,t;return(t=(e=this._pc)===null||e===void 0?void 0:e.connectionState)!==null&&t!==void 0?t:"closed"}getICEConnectionState(){var e,t;return(t=(e=this._pc)===null||e===void 0?void 0:e.iceConnectionState)!==null&&t!==void 0?t:"closed"}getSignallingState(){var e,t;return(t=(e=this._pc)===null||e===void 0?void 0:e.signalingState)!==null&&t!==void 0?t:"closed"}getTransceivers(){var e,t;return(t=(e=this._pc)===null||e===void 0?void 0:e.getTransceivers())!==null&&t!==void 0?t:[]}getSenders(){var e,t;return(t=(e=this._pc)===null||e===void 0?void 0:e.getSenders())!==null&&t!==void 0?t:[]}getLocalDescription(){var e;return(e=this._pc)===null||e===void 0?void 0:e.localDescription}getRemoteDescription(){var e;return(e=this.pc)===null||e===void 0?void 0:e.remoteDescription}getStats(){return this.pc.getStats()}getConnectedAddress(){return T(this,void 0,void 0,function*(){var e;if(!this._pc)return;let t="";const i=new Map,r=new Map;if((yield this._pc.getStats()).forEach(a=>{switch(a.type){case"transport":t=a.selectedCandidatePairId;break;case"candidate-pair":t===""&&a.selected&&(t=a.id),i.set(a.id,a);break;case"remote-candidate":r.set(a.id,"".concat(a.address,":").concat(a.port));break}}),t==="")return;const s=(e=i.get(t))===null||e===void 0?void 0:e.remoteCandidateId;if(s!==void 0)return r.get(s)})}setMungedSDP(e,t,i){return T(this,void 0,void 0,function*(){if(t){const r=e.sdp;e.sdp=t;try{this.log.debug("setting munged ".concat(i?"remote":"local"," description"),this.logContext),i?yield this.pc.setRemoteDescription(e):yield this.pc.setLocalDescription(e);return}catch(o){this.log.warn("not able to set ".concat(e.type,", falling back to unmodified sdp"),Object.assign(Object.assign({},this.logContext),{error:o,sdp:t})),e.sdp=r}}try{i?yield this.pc.setRemoteDescription(e):yield this.pc.setLocalDescription(e)}catch(r){let o="unknown error";r instanceof Error?o=r.message:typeof r=="string"&&(o=r);const s={error:o,sdp:e.sdp};throw!i&&this.pc.remoteDescription&&(s.remoteSdp=this.pc.remoteDescription),this.log.error("unable to set ".concat(e.type),Object.assign(Object.assign({},this.logContext),{fields:s})),new gp(o)}})}ensureVideoDDExtensionForSVC(e,t){var i,r;if(!((i=e.ext)===null||i===void 0?void 0:i.some(s=>s.uri===pS))){if(this.ddExtID===0){let s=0;t.media.forEach(a=>{var c;a.type==="video"&&((c=a.ext)===null||c===void 0||c.forEach(u=>{u.value>s&&(s=u.value)}))}),this.ddExtID=s+1}(r=e.ext)===null||r===void 0||r.push({value:this.ddExtID,uri:pS})}}}function NS(n,e,t){let i=0;n.rtp.some(r=>r.codec==="opus"?(i=r.payload,!0):!1),i>0&&(n.rtcpFb||(n.rtcpFb=[]),t.includes(n.mid)&&!n.rtcpFb.some(r=>r.payload===i&&r.type==="nack")&&n.rtcpFb.push({payload:i,type:"nack"}),e.includes(n.mid)&&n.fmtp.some(r=>r.payload===i?(r.config.includes("stereo=1")||(r.config+=";stereo=1"),!0):!1))}function dU(n){var e;const t=[],i=[],r=Mi.parse((e=n.sdp)!==null&&e!==void 0?e:"");let o=0;return r.media.forEach(s=>{var a;s.type==="audio"&&(s.rtp.some(c=>c.codec==="opus"?(o=c.payload,!0):!1),!((a=s.rtcpFb)===null||a===void 0)&&a.some(c=>c.payload===o&&c.type==="nack")&&i.push(s.mid),s.fmtp.some(c=>c.payload===o?(c.config.includes("sprop-stereo=1")&&t.push(s.mid),!0):!1))}),{stereoMids:t,nackMids:i}}function DS(n){if(n.connection){const e=n.connection.ip.indexOf(":")>=0;(n.connection.version===4&&e||n.connection.version===6&&!e)&&(n.connection.ip="0.0.0.0",n.connection.version=4)}}const qp="vp8",hU={audioPreset:_p.music,dtx:!0,red:!0,forceStereo:!1,simulcast:!0,screenShareEncoding:Sp.h1080fps15.encoding,stopMicTrackOnMute:!1,videoCodec:qp,backupCodec:!0},LS={deviceId:{ideal:"default"},autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0,voiceIsolation:!0},US={deviceId:{ideal:"default"},resolution:gs.h720.resolution},pU={adaptiveStream:!1,dynacast:!1,stopLocalTrackOnUnpublish:!0,reconnectPolicy:new i3,disconnectOnPageLeave:!0,webAudioMix:!1},Wp={autoSubscribe:!0,maxRetries:1,peerConnectionTimeout:15e3,websocketTimeout:15e3};var Xe;(function(n){n[n.NEW=0]="NEW",n[n.CONNECTING=1]="CONNECTING",n[n.CONNECTED=2]="CONNECTED",n[n.FAILED=3]="FAILED",n[n.CLOSING=4]="CLOSING",n[n.CLOSED=5]="CLOSED"})(Xe||(Xe={}));class fU{get needsPublisher(){return this.isPublisherConnectionRequired}get needsSubscriber(){return this.isSubscriberConnectionRequired}get currentState(){return this.state}constructor(e,t,i){var r;this.peerConnectionTimeout=Wp.peerConnectionTimeout,this.log=le,this.updateState=()=>{var o;const s=this.state,a=this.requiredTransports.map(c=>c.getConnectionState());a.every(c=>c==="connected")?this.state=Xe.CONNECTED:a.some(c=>c==="failed")?this.state=Xe.FAILED:a.some(c=>c==="connecting")?this.state=Xe.CONNECTING:a.every(c=>c==="closed")?this.state=Xe.CLOSED:a.some(c=>c==="closed")?this.state=Xe.CLOSING:a.every(c=>c==="new")&&(this.state=Xe.NEW),s!==this.state&&(this.log.debug("pc state change: from ".concat(Xe[s]," to ").concat(Xe[this.state]),this.logContext),(o=this.onStateChange)===null||o===void 0||o.call(this,this.state,this.publisher.getConnectionState(),this.subscriber.getConnectionState()))},this.log=Kn((r=i.loggerName)!==null&&r!==void 0?r:pn.PCManager),this.loggerOptions=i,this.isPublisherConnectionRequired=!t,this.isSubscriberConnectionRequired=t,this.publisher=new MS(e,i),this.subscriber=new MS(e,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=o=>{var s;(s=this.onIceCandidate)===null||s===void 0||s.call(this,o,hn.PUBLISHER)},this.subscriber.onIceCandidate=o=>{var s;(s=this.onIceCandidate)===null||s===void 0||s.call(this,o,hn.SUBSCRIBER)},this.subscriber.onDataChannel=o=>{var s;(s=this.onDataChannel)===null||s===void 0||s.call(this,o)},this.subscriber.onTrack=o=>{var s;(s=this.onTrack)===null||s===void 0||s.call(this,o)},this.publisher.onOffer=o=>{var s;(s=this.onPublisherOffer)===null||s===void 0||s.call(this,o)},this.state=Xe.NEW,this.connectionLock=new jt,this.remoteOfferLock=new jt}get logContext(){var e,t;return Object.assign({},(t=(e=this.loggerOptions).loggerContextCb)===null||t===void 0?void 0:t.call(e))}requirePublisher(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.isPublisherConnectionRequired=e,this.updateState()}requireSubscriber(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!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 T(this,void 0,void 0,function*(){if(this.publisher&&this.publisher.getSignallingState()!=="closed"){const e=this.publisher;for(const t of e.getSenders())try{e.canRemoveTrack()&&e.removeTrack(t)}catch(i){this.log.warn("could not removeTrack",Object.assign(Object.assign({},this.logContext),{error:i}))}}yield Promise.all([this.publisher.close(),this.subscriber.close()]),this.updateState()})}triggerIceRestart(){return T(this,void 0,void 0,function*(){this.subscriber.restartingIce=!0,this.needsPublisher&&(yield this.createAndSendPublisherOffer({iceRestart:!0}))})}addIceCandidate(e,t){return T(this,void 0,void 0,function*(){t===hn.PUBLISHER?yield this.publisher.addIceCandidate(e):yield this.subscriber.addIceCandidate(e)})}createSubscriberAnswerFromOffer(e){return T(this,void 0,void 0,function*(){this.log.debug("received server offer",Object.assign(Object.assign({},this.logContext),{RTCSdpType:e.type,sdp:e.sdp,signalingState:this.subscriber.getSignallingState().toString()}));const t=yield this.remoteOfferLock.lock();try{return yield this.subscriber.setRemoteDescription(e),yield this.subscriber.createAndSetAnswer()}finally{t()}})}updateConfiguration(e,t){this.publisher.setConfiguration(e),this.subscriber.setConfiguration(e),t&&this.triggerIceRestart()}ensurePCTransportConnection(e,t){return T(this,void 0,void 0,function*(){var i;const r=yield this.connectionLock.lock();try{this.isPublisherConnectionRequired&&this.publisher.getConnectionState()!=="connected"&&this.publisher.getConnectionState()!=="connecting"&&(this.log.debug("negotiation required, start negotiating",this.logContext),this.publisher.negotiate()),yield Promise.all((i=this.requiredTransports)===null||i===void 0?void 0:i.map(o=>this.ensureTransportConnected(o,e,t)))}finally{r()}})}negotiate(e){return T(this,void 0,void 0,function*(){return new Promise((t,i)=>T(this,void 0,void 0,function*(){const r=setTimeout(()=>{i("negotiation timed out")},this.peerConnectionTimeout),o=()=>{clearTimeout(r),i("negotiation aborted")};e.signal.addEventListener("abort",o),this.publisher.once(ho.NegotiationStarted,()=>{e.signal.aborted||this.publisher.once(ho.NegotiationComplete,()=>{clearTimeout(r),t()})}),yield this.publisher.negotiate(s=>{clearTimeout(r),i(s)})}))})}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===hn.PUBLISHER?this.publisher.getConnectedAddress():e===hn.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){return T(this,arguments,void 0,function(i,r){var o=this;let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.peerConnectionTimeout;return function*(){if(i.getConnectionState()!=="connected")return new Promise((c,u)=>T(o,void 0,void 0,function*(){const l=()=>{this.log.warn("abort transport connection",this.logContext),_t.clearTimeout(d),u(new Ae("room connection has been cancelled",pe.Cancelled))};r!=null&&r.signal.aborted&&l(),r==null||r.signal.addEventListener("abort",l);const d=_t.setTimeout(()=>{r==null||r.signal.removeEventListener("abort",l),u(new Ae("could not establish pc connection",pe.InternalError))},s);for(;this.state!==Xe.CONNECTED;)if(yield qt(50),r!=null&&r.signal.aborted){u(new Ae("room connection has been cancelled",pe.Cancelled));return}_t.clearTimeout(d),r==null||r.signal.removeEventListener("abort",l),c()}))}()})}}class Je extends Error{constructor(e,t,i){super(t),this.code=e,this.message=BS(t,Je.MAX_MESSAGE_BYTES),this.data=i?BS(i,Je.MAX_DATA_BYTES):void 0}static fromProto(e){return new Je(e.code,e.message,e.data)}toProto(){return new ek({code:this.code,message:this.message,data:this.data})}static builtIn(e,t){return new Je(Je.ErrorCode[e],Je.ErrorMessage[e],t)}}Je.MAX_MESSAGE_BYTES=256,Je.MAX_DATA_BYTES=15360,Je.ErrorCode={APPLICATION_ERROR:1500,CONNECTION_TIMEOUT:1501,RESPONSE_TIMEOUT:1502,RECIPIENT_DISCONNECTED:1503,RESPONSE_PAYLOAD_TOO_LARGE:1504,SEND_FAILED:1505,UNSUPPORTED_METHOD:1400,RECIPIENT_NOT_FOUND:1401,REQUEST_PAYLOAD_TOO_LARGE:1402,UNSUPPORTED_SERVER:1403,UNSUPPORTED_VERSION:1404},Je.ErrorMessage={APPLICATION_ERROR:"Application error in method handler",CONNECTION_TIMEOUT:"Connection timeout",RESPONSE_TIMEOUT:"Response timeout",RECIPIENT_DISCONNECTED:"Recipient disconnected",RESPONSE_PAYLOAD_TOO_LARGE:"Response payload too large",SEND_FAILED:"Failed to send",UNSUPPORTED_METHOD:"Method not supported at destination",RECIPIENT_NOT_FOUND:"Recipient not found",REQUEST_PAYLOAD_TOO_LARGE:"Request payload too large",UNSUPPORTED_SERVER:"RPC not supported by server",UNSUPPORTED_VERSION:"Unsupported RPC version"};const FS=15360;function Gp(n){return new TextEncoder().encode(n).length}function BS(n,e){if(Gp(n)<=e)return n;let t=0,i=n.length;const r=new TextEncoder;for(;t<i;){const o=Math.floor((t+i+1)/2);r.encode(n.slice(0,o)).length<=e?t=o:i=o-1}return n.slice(0,t)}const $p=2e3;function bu(n,e){if(!e)return 0;let t,i;return"bytesReceived"in n?(t=n.bytesReceived,i=e.bytesReceived):"bytesSent"in n&&(t=n.bytesSent,i=e.bytesSent),t===void 0||i===void 0||n.timestamp===void 0||e.timestamp===void 0?0:(t-i)*8*1e3/(n.timestamp-e.timestamp)}const mU=1e3;class jS extends N{get sender(){return this._sender}set sender(e){this._sender=e}get constraints(){return this._constraints}constructor(e,t,i){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,o=arguments.length>4?arguments[4]:void 0;super(e,t,o),this.manuallyStopped=!1,this._isUpstreamPaused=!1,this.handleTrackMuteEvent=()=>this.debouncedTrackMuteHandler().catch(()=>this.log.debug("track mute bounce got cancelled by an unmute event",this.logContext)),this.debouncedTrackMuteHandler=zp(()=>T(this,void 0,void 0,function*(){yield this.pauseUpstream()}),5e3),this.handleTrackUnmuteEvent=()=>T(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(B.Ended,this)},this.reacquireTrack=!1,this.providedByUser=r,this.muteLock=new jt,this.pauseUpstreamLock=new jt,this.processorLock=new jt,this.restartLock=new jt,this.setMediaStreamTrack(e,!0),this._constraints=e.getConstraints(),i&&(this._constraints=i)}get id(){return this._mediaStreamTrack.id}get dimensions(){if(this.kind!==N.Kind.Video)return;const{width:e,height:t}=this._mediaStreamTrack.getSettings();if(e&&t)return{width:e,height:t}}get isUpstreamPaused(){return this._isUpstreamPaused}get isUserProvided(){return this.providedByUser}get mediaStreamTrack(){var e,t;return(t=(e=this.processor)===null||e===void 0?void 0:e.processedTrack)!==null&&t!==void 0?t:this._mediaStreamTrack}get isLocal(){return!0}getSourceTrackSettings(){return this._mediaStreamTrack.getSettings()}setMediaStreamTrack(e,t){return T(this,void 0,void 0,function*(){var i;if(e===this._mediaStreamTrack&&!t)return;this._mediaStreamTrack&&(this.attachedElements.forEach(o=>{ao(this._mediaStreamTrack,o)}),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());let r;if(this.processor&&e){const o=yield this.processorLock.lock();try{if(this.log.debug("restarting processor",this.logContext),this.kind==="unknown")throw TypeError("cannot set processor on track of unknown kind");this.processorElement&&(so(e,this.processorElement),this.processorElement.muted=!0),yield this.processor.restart({track:e,kind:this.kind,element:this.processorElement}),r=this.processor.processedTrack}finally{o()}}this.sender&&((i=this.sender.transport)===null||i===void 0?void 0:i.state)!=="closed"&&(yield this.sender.replaceTrack(r??e)),!this.providedByUser&&this._mediaStreamTrack!==e&&this._mediaStreamTrack.stop(),this._mediaStreamTrack=e,e&&(this._mediaStreamTrack.enabled=!this.isMuted,yield this.resumeUpstream(),this.attachedElements.forEach(o=>{so(r??e,o)}))})}waitForDimensions(){return T(this,arguments,void 0,function(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:mU;return function*(){var i;if(e.kind===N.Kind.Audio)throw new Error("cannot get dimensions for audio tracks");((i=fn())===null||i===void 0?void 0:i.os)==="iOS"&&(yield qt(10));const r=Date.now();for(;Date.now()-r<t;){const o=e.dimensions;if(o)return o;yield qt(50)}throw new Yn("unable to get track dimensions after timeout")}()})}setDeviceId(e){return T(this,void 0,void 0,function*(){return this._constraints.deviceId===e&&this._mediaStreamTrack.getSettings().deviceId===Oi(e)||(this._constraints.deviceId=e,this.isMuted)?!0:(yield this.restartTrack(),Oi(e)===this._mediaStreamTrack.getSettings().deviceId)})}getDeviceId(){return T(this,arguments,void 0,function(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return function*(){if(e.source===N.Source.ScreenShare)return;const{deviceId:i,groupId:r}=e._mediaStreamTrack.getSettings(),o=e.kind===N.Kind.Audio?"audioinput":"videoinput";return t?ft.getInstance().normalizeDeviceId(o,i,r):i}()})}mute(){return T(this,void 0,void 0,function*(){return this.setTrackMuted(!0),this})}unmute(){return T(this,void 0,void 0,function*(){return this.setTrackMuted(!1),this})}replaceTrack(e,t){return T(this,void 0,void 0,function*(){if(!this.sender)throw new Yn("unable to replace an unpublished track");let i,r;return typeof t=="boolean"?i=t:t!==void 0&&(i=t.userProvidedTrack,r=t.stopProcessor),this.providedByUser=i??!0,this.log.debug("replace MediaStreamTrack",this.logContext),yield this.setMediaStreamTrack(e),r&&this.processor&&(yield this.stopProcessor()),this})}restart(e){return T(this,void 0,void 0,function*(){this.manuallyStopped=!1;const t=yield this.restartLock.lock();try{e||(e=this._constraints);const{deviceId:i,facingMode:r}=e,o=r3(e,["deviceId","facingMode"]);this.log.debug("restarting track with constraints",Object.assign(Object.assign({},this.logContext),{constraints:e}));const s={audio:!1,video:!1};this.kind===N.Kind.Video?s.video=i||r?{deviceId:i,facingMode:r}:!0:s.audio=i?{deviceId:i}:!0,this.attachedElements.forEach(u=>{ao(this.mediaStreamTrack,u)}),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this._mediaStreamTrack.stop();const c=(yield navigator.mediaDevices.getUserMedia(s)).getTracks()[0];return yield c.applyConstraints(o),c.addEventListener("ended",this.handleEnded),this.log.debug("re-acquired MediaStreamTrack",this.logContext),yield this.setMediaStreamTrack(c),this._constraints=e,this.emit(B.Restarted,this),this.manuallyStopped&&(this.log.warn("track was stopped during a restart, stopping restarted track",this.logContext),this.stop()),this}finally{t()}})}setTrackMuted(e){this.log.debug("setting ".concat(this.kind," track ").concat(e?"muted":"unmuted"),this.logContext),!(this.isMuted===e&&this._mediaStreamTrack.enabled!==e)&&(this.isMuted=e,this._mediaStreamTrack.enabled=!e,this.emit(e?B.Muted:B.Unmuted,this))}get needsReAcquisition(){return this._mediaStreamTrack.readyState!=="live"||this._mediaStreamTrack.muted||!this._mediaStreamTrack.enabled||this.reacquireTrack}handleAppVisibilityChanged(){const e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return T(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),fS()&&(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;this.manuallyStopped=!0,super.stop(),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this._mediaStreamTrack.removeEventListener("mute",this.handleTrackMuteEvent),this._mediaStreamTrack.removeEventListener("unmute",this.handleTrackUnmuteEvent),(e=this.processor)===null||e===void 0||e.destroy(),this.processor=void 0}pauseUpstream(){return T(this,void 0,void 0,function*(){var e;const t=yield this.pauseUpstreamLock.lock();try{if(this._isUpstreamPaused===!0)return;if(!this.sender){this.log.warn("unable to pause upstream for an unpublished track",this.logContext);return}this._isUpstreamPaused=!0,this.emit(B.UpstreamPaused,this);const i=fn();if((i==null?void 0:i.name)==="Safari"&&rr(i.version,"12.0")<0)throw new mp("pauseUpstream is not supported on Safari < 12.");((e=this.sender.transport)===null||e===void 0?void 0:e.state)!=="closed"&&(yield this.sender.replaceTrack(null))}finally{t()}})}resumeUpstream(){return T(this,void 0,void 0,function*(){var e;const t=yield this.pauseUpstreamLock.lock();try{if(this._isUpstreamPaused===!1)return;if(!this.sender){this.log.warn("unable to resume upstream for an unpublished track",this.logContext);return}this._isUpstreamPaused=!1,this.emit(B.UpstreamResumed,this),((e=this.sender.transport)===null||e===void 0?void 0:e.state)!=="closed"&&(yield this.sender.replaceTrack(this.mediaStreamTrack))}finally{t()}})}getRTCStatsReport(){return T(this,void 0,void 0,function*(){var e;return!((e=this.sender)===null||e===void 0)&&e.getStats?yield this.sender.getStats():void 0})}setProcessor(e){return T(this,arguments,void 0,function(t){var i=this;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return function*(){var o;const s=yield i.processorLock.lock();try{i.log.debug("setting up processor",i.logContext);const a=document.createElement(i.kind),c={kind:i.kind,track:i._mediaStreamTrack,element:a,audioContext:i.audioContext};if(yield t.init(c),i.log.debug("processor initialized",i.logContext),i.processor&&(yield i.stopProcessor()),i.kind==="unknown")throw TypeError("cannot set processor on track of unknown kind");if(so(i._mediaStreamTrack,a),a.muted=!0,a.play().catch(u=>i.log.error("failed to play processor element",Object.assign(Object.assign({},i.logContext),{error:u}))),i.processor=t,i.processorElement=a,i.processor.processedTrack){for(const u of i.attachedElements)u!==i.processorElement&&r&&(ao(i._mediaStreamTrack,u),so(i.processor.processedTrack,u));yield(o=i.sender)===null||o===void 0?void 0:o.replaceTrack(i.processor.processedTrack)}i.emit(B.TrackProcessorUpdate,i.processor)}finally{s()}}()})}getProcessor(){return this.processor}stopProcessor(){return T(this,arguments,void 0,function(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return function*(){var i,r;e.processor&&(e.log.debug("stopping processor",e.logContext),(i=e.processor.processedTrack)===null||i===void 0||i.stop(),yield e.processor.destroy(),e.processor=void 0,t||((r=e.processorElement)===null||r===void 0||r.remove(),e.processorElement=void 0),yield e._mediaStreamTrack.applyConstraints(e._constraints),yield e.setMediaStreamTrack(e._mediaStreamTrack,!0),e.emit(B.TrackProcessorUpdate))}()})}}class _u extends jS{get enhancedNoiseCancellation(){return this.isKrispNoiseFilterEnabled}constructor(e,t){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,r=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0;super(e,N.Kind.Audio,t,i,o),this.stopOnMute=!1,this.isKrispNoiseFilterEnabled=!1,this.monitorSender=()=>T(this,void 0,void 0,function*(){if(!this.sender){this._currentBitrate=0;return}let s;try{s=yield this.getSenderStats()}catch(a){this.log.error("could not get audio sender stats",Object.assign(Object.assign({},this.logContext),{error:a}));return}s&&this.prevStats&&(this._currentBitrate=bu(s,this.prevStats)),this.prevStats=s}),this.handleKrispNoiseFilterEnable=()=>{this.isKrispNoiseFilterEnabled=!0,this.log.debug("Krisp noise filter enabled",this.logContext),this.emit(B.AudioTrackFeatureUpdate,this,dn.TF_ENHANCED_NOISE_CANCELLATION,!0)},this.handleKrispNoiseFilterDisable=()=>{this.isKrispNoiseFilterEnabled=!1,this.log.debug("Krisp noise filter disabled",this.logContext),this.emit(B.AudioTrackFeatureUpdate,this,dn.TF_ENHANCED_NOISE_CANCELLATION,!1)},this.audioContext=r,this.checkForSilence()}mute(){const e=Object.create(null,{mute:{get:()=>super.mute}});return T(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===N.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 T(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 i=this._constraints.deviceId&&this._mediaStreamTrack.getSettings().deviceId!==Oi(this._constraints.deviceId);return this.source===N.Source.Microphone&&(this.stopOnMute||this._mediaStreamTrack.readyState==="ended"||i)&&!this.isUserProvided&&(this.log.debug("reacquiring mic track",this.logContext),yield this.restartTrack()),yield e.unmute.call(this),this}finally{t()}})}restartTrack(e){return T(this,void 0,void 0,function*(){let t;if(e){const i=Dp({audio:e});typeof i.audio!="boolean"&&(t=i.audio)}yield this.restart(t)})}restart(e){const t=Object.create(null,{restart:{get:()=>super.restart}});return T(this,void 0,void 0,function*(){const i=yield t.restart.call(this,e);return this.checkForSilence(),i})}startMonitor(){Wt()&&(this.monitorInterval||(this.monitorInterval=setInterval(()=>{this.monitorSender()},$p)))}setProcessor(e){return T(this,void 0,void 0,function*(){var t;const i=yield this.processorLock.lock();try{if(!Nn()&&!this.audioContext)throw Error("Audio context needs to be set on LocalAudioTrack in order to enable processors");this.processor&&(yield this.stopProcessor());const r={kind:this.kind,track:this._mediaStreamTrack,audioContext:this.audioContext};this.log.debug("setting up audio processor ".concat(e.name),this.logContext),yield e.init(r),this.processor=e,this.processor.processedTrack&&(yield(t=this.sender)===null||t===void 0?void 0:t.replaceTrack(this.processor.processedTrack),this.processor.processedTrack.addEventListener("enable-lk-krisp-noise-filter",this.handleKrispNoiseFilterEnable),this.processor.processedTrack.addEventListener("disable-lk-krisp-noise-filter",this.handleKrispNoiseFilterDisable)),this.emit(B.TrackProcessorUpdate,this.processor)}finally{i()}})}setAudioContext(e){this.audioContext=e}getSenderStats(){return T(this,void 0,void 0,function*(){var e;if(!(!((e=this.sender)===null||e===void 0)&&e.getStats))return;const t=yield this.sender.getStats();let i;return t.forEach(r=>{r.type==="outbound-rtp"&&(i={type:"audio",streamId:r.id,packetsSent:r.packetsSent,packetsLost:r.packetsLost,bytesSent:r.bytesSent,timestamp:r.timestamp,roundTripTime:r.roundTripTime,jitter:r.jitter})}),i})}checkForSilence(){return T(this,void 0,void 0,function*(){const e=yield wS(this);return e&&(this.isMuted||this.log.warn("silence detected on local audio track",this.logContext),this.emit(B.AudioSilenceDetected)),e})}}function gU(n,e,t){switch(n.kind){case"audio":return new _u(n,e,!1,void 0,t);case"video":return new Su(n,e,!1,t);default:throw new Yn("unsupported track type: ".concat(n.kind))}}const vU=Object.values(gs),yU=Object.values(kp),bU=Object.values(Sp),_U=[gs.h180,gs.h360],kU=[kp.h180,kp.h360],SU=n=>[{scaleResolutionDownBy:2,fps:n.encoding.maxFramerate}].map(t=>{var i,r;return new Re(Math.floor(n.width/t.scaleResolutionDownBy),Math.floor(n.height/t.scaleResolutionDownBy),Math.max(15e4,Math.floor(n.encoding.maxBitrate/(Math.pow(t.scaleResolutionDownBy,2)*(((i=n.encoding.maxFramerate)!==null&&i!==void 0?i:30)/((r=t.fps)!==null&&r!==void 0?r:30))))),t.fps,n.encoding.priority)}),Hp=["q","h","f"];function Kp(n,e,t,i){var r,o;let s=i==null?void 0:i.videoEncoding;n&&(s=i==null?void 0:i.screenShareEncoding);const a=i==null?void 0:i.simulcast,c=i==null?void 0:i.scalabilityMode,u=i==null?void 0:i.videoCodec;if(!s&&!a&&!c||!e||!t)return[{}];s||(s=CU(n,e,t,u),le.debug("using video encoding",s));const l=s.maxFramerate,d=new Re(e,t,s.maxBitrate,s.maxFramerate,s.priority);if(c&&vs(u)){const m=new ku(c),f=[];if(m.spatial>3)throw new Error("unsupported scalabilityMode: ".concat(c));const g=fn();if(Pi()||Nn()||(g==null?void 0:g.name)==="Chrome"&&rr(g==null?void 0:g.version,"113")<0){const y=m.suffix=="h"?2:3;for(let b=0;b<m.spatial;b+=1)f.push({rid:Hp[2-b],maxBitrate:s.maxBitrate/Math.pow(y,b),maxFramerate:d.encoding.maxFramerate});f[0].scalabilityMode=c}else f.push({maxBitrate:s.maxBitrate,maxFramerate:d.encoding.maxFramerate,scalabilityMode:c});return d.encoding.priority&&(f[0].priority=d.encoding.priority,f[0].networkPriority=d.encoding.priority),le.debug("using svc encoding",{encodings:f}),f}if(!a)return[s];let h=[];n?h=(r=zS(i==null?void 0:i.screenShareSimulcastLayers))!==null&&r!==void 0?r:VS(n,d):h=(o=zS(i==null?void 0:i.videoSimulcastLayers))!==null&&o!==void 0?o:VS(n,d);let p;if(h.length>0){const m=h[0];h.length>1&&([,p]=h);const f=Math.max(e,t);if(f>=960&&p)return Yp(e,t,[m,p,d],l);if(f>=480)return Yp(e,t,[m,d],l)}return Yp(e,t,[d])}function wU(n,e,t){var i,r,o,s;if(!t.backupCodec||t.backupCodec===!0||t.backupCodec.codec===t.videoCodec)return;e!==t.backupCodec.codec&&le.warn("requested a different codec than specified as backup",{serverRequested:e,backup:t.backupCodec.codec}),t.videoCodec=e,t.videoEncoding=t.backupCodec.encoding;const a=n.mediaStreamTrack.getSettings(),c=(i=a.width)!==null&&i!==void 0?i:(r=n.dimensions)===null||r===void 0?void 0:r.width,u=(o=a.height)!==null&&o!==void 0?o:(s=n.dimensions)===null||s===void 0?void 0:s.height;return n.source===N.Source.ScreenShare&&t.simulcast&&(t.simulcast=!1),Kp(n.source===N.Source.ScreenShare,c,u,t)}function CU(n,e,t,i){const r=TU(n,e,t);let{encoding:o}=r[0];const s=Math.max(e,t);for(let a=0;a<r.length;a+=1){const c=r[a];if(o=c.encoding,c.width>=s)break}if(i)switch(i){case"av1":o=Object.assign({},o),o.maxBitrate=o.maxBitrate*.7;break;case"vp9":o=Object.assign({},o),o.maxBitrate=o.maxBitrate*.85;break}return o}function TU(n,e,t){if(n)return bU;const i=e>t?e/t:t/e;return Math.abs(i-16/9)<Math.abs(i-4/3)?vU:yU}function VS(n,e){if(n)return SU(e);const{width:t,height:i}=e,r=t>i?t/i:i/t;return Math.abs(r-16/9)<Math.abs(r-4/3)?_U:kU}function Yp(n,e,t,i){const r=[];if(t.forEach((o,s)=>{if(s>=Hp.length)return;const a=Math.min(n,e),u={rid:Hp[s],scaleResolutionDownBy:Math.max(1,a/Math.min(o.width,o.height)),maxBitrate:o.encoding.maxBitrate},l=i&&o.encoding.maxFramerate?Math.min(i,o.encoding.maxFramerate):o.encoding.maxFramerate;l&&(u.maxFramerate=l);const d=co()||s===0;o.encoding.priority&&d&&(u.priority=o.encoding.priority,u.networkPriority=o.encoding.priority),r.push(u)}),Nn()&&gS()==="ios"){let o;r.forEach(a=>{o?a.maxFramerate&&a.maxFramerate>o&&(o=a.maxFramerate):o=a.maxFramerate});let s=!0;r.forEach(a=>{var c;a.maxFramerate!=o&&(s&&(s=!1,le.info("Simulcast on iOS React-Native requires all encodings to share the same framerate.")),le.info('Setting framerate of encoding "'.concat((c=a.rid)!==null&&c!==void 0?c:"",'" to ').concat(o)),a.maxFramerate=o)})}return r}function zS(n){if(n)return n.sort((e,t)=>{const{encoding:i}=e,{encoding:r}=t;return i.maxBitrate>r.maxBitrate?1:i.maxBitrate<r.maxBitrate?-1:i.maxBitrate===r.maxBitrate&&i.maxFramerate&&r.maxFramerate?i.maxFramerate>r.maxFramerate?1:-1:0})}class ku{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((e=this.suffix)!==null&&e!==void 0?e:"")}}function xU(n){return n.source===N.Source.ScreenShare||n.constraints.height&&Oi(n.constraints.height)>=1080?"maintain-resolution":"balanced"}const EU=5e3;class Su extends jS{get sender(){return this._sender}set sender(e){this._sender=e,this.degradationPreference&&this.setDegradationPreference(this.degradationPreference)}constructor(e,t){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,r=arguments.length>3?arguments[3]:void 0;super(e,N.Kind.Video,t,i,r),this.simulcastCodecs=new Map,this.degradationPreference="balanced",this.monitorSender=()=>T(this,void 0,void 0,function*(){if(!this.sender){this._currentBitrate=0;return}let o;try{o=yield this.getSenderStats()}catch(a){this.log.error("could not get audio sender stats",Object.assign(Object.assign({},this.logContext),{error:a}));return}const s=new Map(o.map(a=>[a.rid,a]));if(this.prevStats){let a=0;s.forEach((c,u)=>{var l;const d=(l=this.prevStats)===null||l===void 0?void 0:l.get(u);a+=bu(c,d)}),this._currentBitrate=a}this.prevStats=s}),this.senderLock=new jt}get isSimulcast(){return!!(this.sender&&this.sender.getParameters().encodings.length>1)}startMonitor(e){var t;if(this.signalClient=e,!Wt())return;const i=(t=this.sender)===null||t===void 0?void 0:t.getParameters();i&&(this.encodings=i.encodings),!this.monitorInterval&&(this.monitorInterval=setInterval(()=>{this.monitorSender()},$p))}stop(){this._mediaStreamTrack.getConstraints(),this.simulcastCodecs.forEach(e=>{e.mediaStreamTrack.stop()}),super.stop()}pauseUpstream(){const e=Object.create(null,{pauseUpstream:{get:()=>super.pauseUpstream}});return T(this,void 0,void 0,function*(){var t,i,r,o,s;yield e.pauseUpstream.call(this);try{for(var a=!0,c=xi(this.simulcastCodecs.values()),u;u=yield c.next(),t=u.done,!t;a=!0)o=u.value,a=!1,yield(s=o.sender)===null||s===void 0?void 0:s.replaceTrack(null)}catch(l){i={error:l}}finally{try{!a&&!t&&(r=c.return)&&(yield r.call(c))}finally{if(i)throw i.error}}})}resumeUpstream(){const e=Object.create(null,{resumeUpstream:{get:()=>super.resumeUpstream}});return T(this,void 0,void 0,function*(){var t,i,r,o,s;yield e.resumeUpstream.call(this);try{for(var a=!0,c=xi(this.simulcastCodecs.values()),u;u=yield c.next(),t=u.done,!t;a=!0){o=u.value,a=!1;const l=o;yield(s=l.sender)===null||s===void 0?void 0:s.replaceTrack(l.mediaStreamTrack)}}catch(l){i={error:l}}finally{try{!a&&!t&&(r=c.return)&&(yield r.call(c))}finally{if(i)throw i.error}}})}mute(){const e=Object.create(null,{mute:{get:()=>super.mute}});return T(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===N.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 T(this,void 0,void 0,function*(){const t=yield this.muteLock.lock();try{return this.isMuted?(this.source===N.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(){return T(this,void 0,void 0,function*(){var e;if(!(!((e=this.sender)===null||e===void 0)&&e.getStats))return[];const t=[],i=yield this.sender.getStats();return i.forEach(r=>{var o;if(r.type==="outbound-rtp"){const s={type:"video",streamId:r.id,frameHeight:r.frameHeight,frameWidth:r.frameWidth,framesPerSecond:r.framesPerSecond,framesSent:r.framesSent,firCount:r.firCount,pliCount:r.pliCount,nackCount:r.nackCount,packetsSent:r.packetsSent,bytesSent:r.bytesSent,qualityLimitationReason:r.qualityLimitationReason,qualityLimitationDurations:r.qualityLimitationDurations,qualityLimitationResolutionChanges:r.qualityLimitationResolutionChanges,rid:(o=r.rid)!==null&&o!==void 0?o:r.id,retransmittedPacketsSent:r.retransmittedPacketsSent,targetBitrate:r.targetBitrate,timestamp:r.timestamp},a=i.get(r.remoteId);a&&(s.jitter=a.jitter,s.packetsLost=a.packetsLost,s.roundTripTime=a.roundTripTime),t.push(s)}}),t.sort((r,o)=>{var s,a;return((s=o.frameWidth)!==null&&s!==void 0?s:0)-((a=r.frameWidth)!==null&&a!==void 0?a:0)}),t})}setPublishingQuality(e){const t=[];for(let i=en.LOW;i<=en.HIGH;i+=1)t.push(new ip({quality:i,enabled:i<=e}));this.log.debug("setting publishing quality. max quality ".concat(e),this.logContext),this.setPublishingLayers(t)}restartTrack(e){return T(this,void 0,void 0,function*(){var t,i,r,o,s;let a;if(e){const d=Dp({video:e});typeof d.video!="boolean"&&(a=d.video)}yield this.restart(a);try{for(var c=!0,u=xi(this.simulcastCodecs.values()),l;l=yield u.next(),t=l.done,!t;c=!0){o=l.value,c=!1;const d=o;d.sender&&((s=d.sender.transport)===null||s===void 0?void 0:s.state)!=="closed"&&(d.mediaStreamTrack=this.mediaStreamTrack.clone(),yield d.sender.replaceTrack(d.mediaStreamTrack))}}catch(d){i={error:d}}finally{try{!c&&!t&&(r=u.return)&&(yield r.call(u))}finally{if(i)throw i.error}}})}setProcessor(e){const t=Object.create(null,{setProcessor:{get:()=>super.setProcessor}});return T(this,arguments,void 0,function(i){var r=this;let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return function*(){var s,a,c,u,l,d;if(yield t.setProcessor.call(r,i,o),!((l=r.processor)===null||l===void 0)&&l.processedTrack)try{for(var h=!0,p=xi(r.simulcastCodecs.values()),m;m=yield p.next(),s=m.done,!s;h=!0)u=m.value,h=!1,yield(d=u.sender)===null||d===void 0?void 0:d.replaceTrack(r.processor.processedTrack)}catch(f){a={error:f}}finally{try{!h&&!s&&(c=p.return)&&(yield c.call(p))}finally{if(a)throw a.error}}}()})}setDegradationPreference(e){return T(this,void 0,void 0,function*(){if(this.degradationPreference=e,this.sender)try{this.log.debug("setting degradationPreference to ".concat(e),this.logContext);const t=this.sender.getParameters();t.degradationPreference=e,this.sender.setParameters(t)}catch(t){this.log.warn("failed to set degradationPreference",Object.assign({error:t},this.logContext))}})}addSimulcastTrack(e,t){if(this.simulcastCodecs.has(e)){this.log.error("".concat(e," already added, skipping adding simulcast codec"),this.logContext);return}const i={codec:e,mediaStreamTrack:this.mediaStreamTrack.clone(),sender:void 0,encodings:t};return this.simulcastCodecs.set(e,i),i}setSimulcastTrackSender(e,t){const i=this.simulcastCodecs.get(e);i&&(i.sender=t,setTimeout(()=>{this.subscribedCodecs&&this.setPublishingCodecs(this.subscribedCodecs)},EU))}setPublishingCodecs(e){return T(this,void 0,void 0,function*(){var t,i,r,o,s,a,c;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 u=[];try{for(t=!0,i=xi(e);r=yield i.next(),o=r.done,!o;t=!0){c=r.value,t=!1;const l=c;if(!this.codec||this.codec===l.codec)yield this.setPublishingLayers(l.qualities);else{const d=this.simulcastCodecs.get(l.codec);if(this.log.debug("try setPublishingCodec for ".concat(l.codec),Object.assign(Object.assign({},this.logContext),{simulcastCodecInfo:d})),!d||!d.sender){for(const h of l.qualities)if(h.enabled){u.push(l.codec);break}}else d.encodings&&(this.log.debug("try setPublishingLayersForSender ".concat(l.codec),this.logContext),yield qS(d.sender,d.encodings,l.qualities,this.senderLock,this.log,this.logContext))}}}catch(l){s={error:l}}finally{try{!t&&!o&&(a=i.return)&&(yield a.call(i))}finally{if(s)throw s.error}}return u})}setPublishingLayers(e){return T(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 qS(this.sender,this.encodings,e,this.senderLock,this.log,this.logContext))})}handleAppVisibilityChanged(){const e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return T(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),fS()&&this.isInBackground&&this.source===N.Source.Camera&&(this._mediaStreamTrack.enabled=!1)})}}function qS(n,e,t,i,r,o){return T(this,void 0,void 0,function*(){const s=yield i.lock();r.debug("setPublishingLayersForSender",Object.assign(Object.assign({},o),{sender:n,qualities:t,senderEncodings:e}));try{const a=n.getParameters(),{encodings:c}=a;if(!c)return;if(c.length!==e.length){r.warn("cannot set publishing layers, encodings mismatch",Object.assign(Object.assign({},o),{encodings:c,senderEncodings:e}));return}let u=!1;const l=fn();if((l==null?void 0:l.name)==="Chrome"&&rr(l==null?void 0:l.version,"133")>0&&c[0].scalabilityMode){const h=c[0],p=new ku(h.scalabilityMode);let m=eo.OFF;if(t.forEach(f=>{f.enabled&&(m===eo.OFF||f.quality>m)&&(m=f.quality)}),m===eo.OFF)h.active&&(h.active=!1,u=!0);else if(!h.active||p.spatial!==m+1){u=!0,h.active=!0;const f=new ku(e[0].scalabilityMode);p.spatial=m+1,p.suffix=f.suffix,p.spatial===1&&(p.suffix=void 0),h.scalabilityMode=p.toString(),h.scaleResolutionDownBy=Math.pow(2,2-m),e[0].maxBitrate&&(h.maxBitrate=e[0].maxBitrate/(h.scaleResolutionDownBy*h.scaleResolutionDownBy))}}else c.forEach((h,p)=>{var m;let f=(m=h.rid)!==null&&m!==void 0?m:"";f===""&&(f="q");const g=WS(f),y=t.find(b=>b.quality===g);y&&h.active!==y.enabled&&(u=!0,h.active=y.enabled,r.debug("setting layer ".concat(y.quality," to ").concat(h.active?"enabled":"disabled"),o),co()&&(y.enabled?(h.scaleResolutionDownBy=e[p].scaleResolutionDownBy,h.maxBitrate=e[p].maxBitrate,h.maxFrameRate=e[p].maxFrameRate):(h.scaleResolutionDownBy=4,h.maxBitrate=10,h.maxFrameRate=2)))});u&&(a.encodings=c,r.debug("setting encodings",Object.assign(Object.assign({},o),{encodings:a.encodings})),yield n.setParameters(a))}finally{s()}})}function WS(n){switch(n){case"f":return en.HIGH;case"h":return en.MEDIUM;case"q":return en.LOW;default:return en.HIGH}}function GS(n,e,t,i){if(!t)return[new tr({quality:en.HIGH,width:n,height:e,bitrate:0,ssrc:0})];if(i){const r=t[0].scalabilityMode,o=new ku(r),s=[],a=o.suffix=="h"?1.5:2,c=o.suffix=="h"?2:3;for(let u=0;u<o.spatial;u+=1)s.push(new tr({quality:Math.min(en.HIGH,o.spatial-1)-u,width:Math.ceil(n/Math.pow(a,u)),height:Math.ceil(e/Math.pow(a,u)),bitrate:t[0].maxBitrate?Math.ceil(t[0].maxBitrate/Math.pow(c,u)):0,ssrc:0}));return s}return t.map(r=>{var o,s,a;const c=(o=r.scaleResolutionDownBy)!==null&&o!==void 0?o:1;let u=WS((s=r.rid)!==null&&s!==void 0?s:"");return new tr({quality:u,width:Math.ceil(n/c),height:Math.ceil(e/c),bitrate:(a=r.maxBitrate)!==null&&a!==void 0?a:0,ssrc:0})})}const $S="_lossy",HS="_reliable",IU=2*1e3,Xp="leave-reconnect";var gn;(function(n){n[n.New=0]="New",n[n.Connected=1]="Connected",n[n.Disconnected=2]="Disconnected",n[n.Reconnecting=3]="Reconnecting",n[n.Closed=4]="Closed"})(gn||(gn={}));class RU extends Mn.EventEmitter{get isClosed(){return this._isClosed}get pendingReconnect(){return!!this.reconnectTimeout}constructor(e){var t;super(),this.options=e,this.rtcConfig={},this.peerConnectionTimeout=Wp.peerConnectionTimeout,this.fullReconnectOnNext=!1,this.subscriberPrimary=!1,this.pcState=gn.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=le,this.handleDataChannel=i=>T(this,[i],void 0,function(r){var o=this;let{channel:s}=r;return function*(){if(s){if(s.label===HS)o.reliableDCSub=s;else if(s.label===$S)o.lossyDCSub=s;else return;o.log.debug("on data channel ".concat(s.id,", ").concat(s.label),o.logContext),s.onmessage=o.handleDataMessage}}()}),this.handleDataMessage=i=>T(this,void 0,void 0,function*(){var r,o;const s=yield this.dataProcessLock.lock();try{let a;if(i.data instanceof ArrayBuffer)a=i.data;else if(i.data instanceof Blob)a=yield i.data.arrayBuffer();else{this.log.error("unsupported data type",Object.assign(Object.assign({},this.logContext),{data:i.data}));return}const c=zt.fromBinary(new Uint8Array(a));((r=c.value)===null||r===void 0?void 0:r.case)==="speaker"?this.emit(j.ActiveSpeakersUpdate,c.value.value.speakers):(((o=c.value)===null||o===void 0?void 0:o.case)==="user"&&OU(c,c.value.value),this.emit(j.DataPacketReceived,c))}finally{s()}}),this.handleDataError=i=>{const o=i.currentTarget.maxRetransmits===0?"lossy":"reliable";if(i instanceof ErrorEvent&&i.error){const{error:s}=i.error;this.log.error("DataChannel error on ".concat(o,": ").concat(i.message),Object.assign(Object.assign({},this.logContext),{error:s}))}else this.log.error("Unknown DataChannel error on ".concat(o),Object.assign(Object.assign({},this.logContext),{event:i}))},this.handleBufferedAmountLow=i=>{const o=i.currentTarget.maxRetransmits===0?ge.LOSSY:ge.RELIABLE;this.updateAndEmitDCBufferStatus(o)},this.handleDisconnect=(i,r)=>{if(this._isClosed)return;this.log.warn("".concat(i," disconnected"),this.logContext),this.reconnectAttempts===0&&(this.reconnectStart=Date.now());const o=c=>{this.log.warn("could not recover connection after ".concat(this.reconnectAttempts," attempts, ").concat(c,"ms. giving up"),this.logContext),this.emit(j.Disconnected),this.close()},s=Date.now()-this.reconnectStart;let a=this.getNextRetryDelay({elapsedMs:s,retryCount:this.reconnectAttempts});if(a===null){o(s);return}i===Xp&&(a=0),this.log.debug("reconnecting in ".concat(a,"ms"),this.logContext),this.clearReconnectTimeout(),this.token&&this.regionUrlProvider&&this.regionUrlProvider.updateToken(this.token),this.reconnectTimeout=_t.setTimeout(()=>this.attemptReconnect(r).finally(()=>this.reconnectTimeout=void 0),a)},this.waitForRestarted=()=>new Promise((i,r)=>{this.pcState===gn.Connected&&i();const o=()=>{this.off(j.Disconnected,s),i()},s=()=>{this.off(j.Restarted,o),r()};this.once(j.Restarted,o),this.once(j.Disconnected,s)}),this.updateAndEmitDCBufferStatus=i=>{const r=this.isBufferStatusLow(i);typeof r<"u"&&r!==this.dcBufferStatus.get(i)&&(this.dcBufferStatus.set(i,r),this.emit(j.DCBufferStatusChanged,r,i))},this.isBufferStatusLow=i=>{const r=this.dataChannelForKind(i);if(r)return r.bufferedAmount<=r.bufferedAmountLowThreshold},this.handleBrowserOnLine=()=>{this.client.currentState===Be.RECONNECTING&&(this.clearReconnectTimeout(),this.attemptReconnect(to.RR_SIGNAL_DISCONNECTED))},this.log=Kn((t=e.loggerName)!==null&&t!==void 0?t:pn.Engine),this.loggerOptions={loggerName:e.loggerName,loggerContextCb:()=>this.logContext},this.client=new Up(void 0,this.loggerOptions),this.client.signalLatency=this.options.expSignalLatency,this.reconnectPolicy=this.options.reconnectPolicy,this.registerOnLineListener(),this.closingLock=new jt,this.dataProcessLock=new jt,this.dcBufferStatus=new Map([[ge.LOSSY,!0],[ge.RELIABLE,!0]]),this.client.onParticipantUpdate=i=>this.emit(j.ParticipantUpdate,i),this.client.onConnectionQuality=i=>this.emit(j.ConnectionQualityUpdate,i),this.client.onRoomUpdate=i=>this.emit(j.RoomUpdate,i),this.client.onSubscriptionError=i=>this.emit(j.SubscriptionError,i),this.client.onSubscriptionPermissionUpdate=i=>this.emit(j.SubscriptionPermissionUpdate,i),this.client.onSpeakersChanged=i=>this.emit(j.SpeakersChanged,i),this.client.onStreamStateUpdate=i=>this.emit(j.StreamStateChanged,i),this.client.onRequestResponse=i=>this.emit(j.SignalRequestResponse,i)}get logContext(){var e,t,i,r,o,s,a,c;return{room:(t=(e=this.latestJoinResponse)===null||e===void 0?void 0:e.room)===null||t===void 0?void 0:t.name,roomID:(r=(i=this.latestJoinResponse)===null||i===void 0?void 0:i.room)===null||r===void 0?void 0:r.sid,participant:(s=(o=this.latestJoinResponse)===null||o===void 0?void 0:o.participant)===null||s===void 0?void 0:s.identity,pID:(c=(a=this.latestJoinResponse)===null||a===void 0?void 0:a.participant)===null||c===void 0?void 0:c.sid}}join(e,t,i,r){return T(this,void 0,void 0,function*(){this.url=e,this.token=t,this.signalOpts=i,this.maxJoinAttempts=i.maxRetries;try{this.joinAttempts+=1,this.setupSignalClientCallbacks();const o=yield this.client.join(e,t,i,r);return this._isClosed=!1,this.latestJoinResponse=o,this.subscriberPrimary=o.subscriberPrimary,this.pcManager||(yield this.configure(o)),(!this.subscriberPrimary||o.fastPublish)&&this.negotiate(),this.clientConfiguration=o.clientConfiguration,setTimeout(()=>{this.emit(j.SignalConnected)},10),o}catch(o){if(o instanceof Ae&&o.reason===pe.ServerUnreachable&&(this.log.warn("Couldn't connect to server, attempt ".concat(this.joinAttempts," of ").concat(this.maxJoinAttempts),this.logContext),this.joinAttempts<this.maxJoinAttempts))return this.join(e,t,i,r);throw o}})}close(){return T(this,void 0,void 0,function*(){const e=yield this.closingLock.lock();if(this.isClosed){e();return}try{this._isClosed=!0,this.joinAttempts=0,this.emit(j.Closing),this.removeAllListeners(),this.deregisterOnLineListener(),this.clearPendingReconnect(),yield this.cleanupPeerConnections(),yield this.cleanupClient()}finally{e()}})}cleanupPeerConnections(){return T(this,void 0,void 0,function*(){var e;yield(e=this.pcManager)===null||e===void 0?void 0:e.close(),this.pcManager=void 0;const t=i=>{i&&(i.close(),i.onbufferedamountlow=null,i.onclose=null,i.onclosing=null,i.onerror=null,i.onmessage=null,i.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 T(this,void 0,void 0,function*(){yield this.client.close(),this.client.resetCallbacks()})}addTrack(e){if(this.pendingTrackResolvers[e.cid])throw new Yn("a track with the same ID has already been published");return new Promise((t,i)=>{const r=setTimeout(()=>{delete this.pendingTrackResolvers[e.cid],i(new Ae("publication of local track timed out, no response from server",pe.InternalError))},1e4);this.pendingTrackResolvers[e.cid]={resolve:o=>{clearTimeout(r),t(o)},reject:()=>{clearTimeout(r),i(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(t){this.log.warn("failed to remove track",Object.assign(Object.assign({},this.logContext),{error:t}))}return!1}updateMuteStatus(e,t){this.client.sendMuteTrack(e,t)}get dataSubscriberReadyState(){var e;return(e=this.reliableDCSub)===null||e===void 0?void 0:e.readyState}getConnectedServerAddress(){return T(this,void 0,void 0,function*(){var e;return(e=this.pcManager)===null||e===void 0?void 0:e.getConnectedAddress()})}setRegionUrlProvider(e){this.regionUrlProvider=e}configure(e){return T(this,void 0,void 0,function*(){var t,i;if(this.pcManager&&this.pcManager.currentState!==Xe.NEW)return;this.participantSid=(t=e.participant)===null||t===void 0?void 0:t.sid;const r=this.makeRTCConfiguration(e);this.pcManager=new fU(r,e.subscriberPrimary,this.loggerOptions),this.emit(j.TransportsCreated,this.pcManager.publisher,this.pcManager.subscriber),this.pcManager.onIceCandidate=(o,s)=>{this.client.sendIceCandidate(o,s)},this.pcManager.onPublisherOffer=o=>{this.client.sendOffer(o)},this.pcManager.onDataChannel=this.handleDataChannel,this.pcManager.onStateChange=(o,s,a)=>T(this,void 0,void 0,function*(){if(this.log.debug("primary PC state changed ".concat(o),this.logContext),["closed","disconnected","failed"].includes(s)&&(this.publisherConnectionPromise=void 0),o===Xe.CONNECTED){const l=this.pcState===gn.New;this.pcState=gn.Connected,l&&this.emit(j.Connected,e)}else o===Xe.FAILED&&this.pcState===gn.Connected&&(this.pcState=gn.Disconnected,this.handleDisconnect("peerconnection failed",a==="failed"?to.RR_SUBSCRIBER_FAILED:to.RR_PUBLISHER_FAILED));const c=this.client.isDisconnected||this.client.currentState===Be.RECONNECTING,u=[Xe.FAILED,Xe.CLOSING,Xe.CLOSED].includes(o);c&&u&&!this._isClosed&&this.emit(j.Offline)}),this.pcManager.onTrack=o=>{this.emit(j.MediaTrackAdded,o.track,o.streams[0],o.receiver)},PU((i=e.serverInfo)===null||i===void 0?void 0:i.protocol)||this.createDataChannels()})}setupSignalClientCallbacks(){this.client.onAnswer=e=>T(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.debug("got ICE candidate from peer",Object.assign(Object.assign({},this.logContext),{candidate:e,target:t})),this.pcManager.addIceCandidate(e,t))},this.client.onOffer=e=>T(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:(t=e.track)===null||t===void 0?void 0:t.sid})),!this.pendingTrackResolvers[e.cid]){this.log.error("missing track resolver for ".concat(e.cid),Object.assign(Object.assign({},this.logContext),{cid:e.cid}));return}const{resolve:i}=this.pendingTrackResolvers[e.cid];delete this.pendingTrackResolvers[e.cid],i(e.track)},this.client.onLocalTrackUnpublished=e=>{this.emit(j.LocalTrackUnpublished,e)},this.client.onLocalTrackSubscribed=e=>{this.emit(j.LocalTrackSubscribed,e)},this.client.onTokenRefresh=e=>{this.token=e},this.client.onRemoteMuteChanged=(e,t)=>{this.emit(j.RemoteMute,e,t)},this.client.onSubscribedQualityUpdate=e=>{this.emit(j.SubscribedQualityUpdate,e)},this.client.onRoomMoved=e=>{var t;this.participantSid=(t=e.participant)===null||t===void 0?void 0:t.sid,this.emit(j.RoomMoved,e)},this.client.onClose=()=>{this.handleDisconnect("signal",to.RR_SIGNAL_DISCONNECTED)},this.client.onLeave=e=>{switch(this.log.debug("client leave request",Object.assign(Object.assign({},this.logContext),{reason:e==null?void 0:e.reason})),e.regions&&this.regionUrlProvider&&(this.log.debug("updating regions",this.logContext),this.regionUrlProvider.setServerReportedRegions(e.regions)),e.action){case ro.DISCONNECT:this.emit(j.Disconnected,e==null?void 0:e.reason),this.close();break;case ro.RECONNECT:this.fullReconnectOnNext=!0,this.handleDisconnect(Xp);break;case ro.RESUME:this.handleDisconnect(Xp)}}}makeRTCConfiguration(e){var t;const i=Object.assign({},this.rtcConfig);if(!((t=this.signalOpts)===null||t===void 0)&&t.e2eeEnabled&&(this.log.debug("E2EE - setting up transports with insertable streams",this.logContext),i.encodedInsertableStreams=!0),e.iceServers&&!i.iceServers){const r=[];e.iceServers.forEach(o=>{const s={urls:o.urls};o.username&&(s.username=o.username),o.credential&&(s.credential=o.credential),r.push(s)}),i.iceServers=r}return e.clientConfiguration&&e.clientConfiguration.forceRelay===ps.ENABLED&&(i.iceTransportPolicy="relay"),i.sdpSemantics="unified-plan",i.continualGatheringPolicy="gather_continually",i}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($S,{ordered:!1,maxRetransmits:0}),this.reliableDC=this.pcManager.createPublisherDataChannel(HS,{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)}createSender(e,t,i){return T(this,void 0,void 0,function*(){if(wp())return yield this.createTransceiverRTCRtpSender(e,t,i);if(Cp())return this.log.warn("using add-track fallback",this.logContext),yield this.createRTCRtpSender(e.mediaStreamTrack);throw new lt("Required webRTC APIs not supported on this device")})}createSimulcastSender(e,t,i,r){return T(this,void 0,void 0,function*(){if(wp())return this.createSimulcastTransceiverSender(e,t,i,r);if(Cp())return this.log.debug("using add-track fallback",this.logContext),this.createRTCRtpSender(e.mediaStreamTrack);throw new lt("Cannot stream on this device")})}createTransceiverRTCRtpSender(e,t,i){return T(this,void 0,void 0,function*(){if(!this.pcManager)throw new lt("publisher is closed");const r=[];e.mediaStream&&r.push(e.mediaStream),lo(e)&&(e.codec=t.videoCodec);const o={direction:"sendonly",streams:r};return i&&(o.sendEncodings=i),(yield this.pcManager.addPublisherTransceiver(e.mediaStreamTrack,o)).sender})}createSimulcastTransceiverSender(e,t,i,r){return T(this,void 0,void 0,function*(){if(!this.pcManager)throw new lt("publisher is closed");const o={direction:"sendonly"};r&&(o.sendEncodings=r);const s=yield this.pcManager.addPublisherTransceiver(t.mediaStreamTrack,o);if(i.videoCodec)return e.setSimulcastTrackSender(i.videoCodec,s.sender),s.sender})}createRTCRtpSender(e){return T(this,void 0,void 0,function*(){if(!this.pcManager)throw new lt("publisher is closed");return this.pcManager.addPublisherTrack(e)})}attemptReconnect(e){return T(this,void 0,void 0,function*(){var t,i,r;if(!this._isClosed){if(this.attemptingReconnect){le.warn("already attempting reconnect, returning early",this.logContext);return}(((t=this.clientConfiguration)===null||t===void 0?void 0:t.resumeConnection)===ps.DISABLED||((r=(i=this.pcManager)===null||i===void 0?void 0:i.currentState)!==null&&r!==void 0?r:Xe.NEW)===Xe.NEW)&&(this.fullReconnectOnNext=!0);try{this.attemptingReconnect=!0,this.fullReconnectOnNext?yield this.restartConnection():yield this.resumeConnection(e),this.clearPendingReconnect(),this.fullReconnectOnNext=!1}catch(o){this.reconnectAttempts+=1;let s=!0;o instanceof lt?(this.log.debug("received unrecoverable error",Object.assign(Object.assign({},this.logContext),{error:o})),s=!1):o instanceof po||(this.fullReconnectOnNext=!0),s?this.handleDisconnect("reconnect",to.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(j.Disconnected),yield this.close())}finally{this.attemptingReconnect=!1}}})}getNextRetryDelay(e){try{return this.reconnectPolicy.nextRetryDelayInMs(e)}catch(t){this.log.warn("encountered error in reconnect policy",Object.assign(Object.assign({},this.logContext),{error:t}))}return null}restartConnection(e){return T(this,void 0,void 0,function*(){var t,i,r;try{if(!this.url||!this.token)throw new lt("could not reconnect, url or token not saved");this.log.info("reconnecting, attempt: ".concat(this.reconnectAttempts),this.logContext),this.emit(j.Restarting),this.client.isDisconnected||(yield this.client.sendLeave()),yield this.cleanupPeerConnections(),yield this.cleanupClient();let o;try{if(!this.signalOpts)throw this.log.warn("attempted connection restart, without signal options present",this.logContext),new po;o=yield this.join(e??this.url,this.token,this.signalOpts)}catch(s){throw s instanceof Ae&&s.reason===pe.NotAllowed?new lt("could not reconnect, token might be expired"):new po}if(this.shouldFailNext)throw this.shouldFailNext=!1,new Error("simulated failure");if(this.client.setReconnected(),this.emit(j.SignalRestarted,o),yield this.waitForPCReconnected(),this.client.currentState!==Be.CONNECTED)throw new po("Signal connection got severed during reconnect");(t=this.regionUrlProvider)===null||t===void 0||t.resetAttempts(),this.emit(j.Restarted)}catch(o){const s=yield(i=this.regionUrlProvider)===null||i===void 0?void 0:i.getNextBestRegionUrl();if(s){yield this.restartConnection(s);return}else throw(r=this.regionUrlProvider)===null||r===void 0||r.resetAttempts(),o}})}resumeConnection(e){return T(this,void 0,void 0,function*(){var t;if(!this.url||!this.token)throw new lt("could not reconnect, url or token not saved");if(!this.pcManager)throw new lt("publisher and subscriber connections unset");this.log.info("resuming signal connection, attempt ".concat(this.reconnectAttempts),this.logContext),this.emit(j.Resuming);let i;try{this.setupSignalClientCallbacks(),i=yield this.client.reconnect(this.url,this.token,this.participantSid,e)}catch(r){let o="";throw r instanceof Error&&(o=r.message,this.log.error(r.message,Object.assign(Object.assign({},this.logContext),{error:r}))),r instanceof Ae&&r.reason===pe.NotAllowed?new lt("could not reconnect, token might be expired"):r instanceof Ae&&r.reason===pe.LeaveRequest?r:new po(o)}if(this.emit(j.SignalResumed),i){const r=this.makeRTCConfiguration(i);this.pcManager.updateConfiguration(r)}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!==Be.CONNECTED)throw new po("Signal connection got severed during reconnect");this.client.setReconnected(),((t=this.reliableDC)===null||t===void 0?void 0:t.readyState)==="open"&&this.reliableDC.id===null&&this.createDataChannels(),this.emit(j.Resumed)})}waitForPCInitialConnection(e,t){return T(this,void 0,void 0,function*(){if(!this.pcManager)throw new lt("PC manager is closed");yield this.pcManager.ensurePCTransportConnection(t,e)})}waitForPCReconnected(){return T(this,void 0,void 0,function*(){this.pcState=gn.Reconnecting,this.log.debug("waiting for peer connection to reconnect",this.logContext);try{if(yield qt(IU),!this.pcManager)throw new lt("PC manager is closed");yield this.pcManager.ensurePCTransportConnection(void 0,this.peerConnectionTimeout),this.pcState=gn.Connected}catch(e){throw this.pcState=gn.Disconnected,new Ae("could not establish PC connection, ".concat(e.message),pe.InternalError)}})}publishRpcResponse(e,t,i,r){return T(this,void 0,void 0,function*(){const o=new zt({destinationIdentities:[e],kind:ge.RELIABLE,value:{case:"rpcResponse",value:new Q_({requestId:t,value:r?{case:"error",value:r.toProto()}:{case:"payload",value:i??""}})}});yield this.sendDataPacket(o,ge.RELIABLE)})}publishRpcAck(e,t){return T(this,void 0,void 0,function*(){const i=new zt({destinationIdentities:[e],kind:ge.RELIABLE,value:{case:"rpcAck",value:new Z_({requestId:t})}});yield this.sendDataPacket(i,ge.RELIABLE)})}sendDataPacket(e,t){return T(this,void 0,void 0,function*(){const i=e.toBinary();yield this.ensurePublisherConnected(t);const r=this.dataChannelForKind(t);r&&r.send(i),this.updateAndEmitDCBufferStatus(t)})}waitForBufferStatusLow(e){return new Promise((t,i)=>T(this,void 0,void 0,function*(){if(this.isBufferStatusLow(e))t();else{const r=()=>i("Engine closed");for(this.once(j.Closing,r);!this.dcBufferStatus.get(e);)yield qt(10);this.off(j.Closing,r),t()}}))}ensureDataTransportConnected(e){return T(this,arguments,void 0,function(t){var i=this;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.subscriberPrimary;return function*(){var o;if(!i.pcManager)throw new lt("PC manager is closed");const s=r?i.pcManager.subscriber:i.pcManager.publisher,a=r?"Subscriber":"Publisher";if(!s)throw new Ae("".concat(a," connection not set"),pe.InternalError);let c=!1;!r&&!i.dataChannelForKind(t,r)&&(i.createDataChannels(),c=!0),!c&&!r&&!i.pcManager.publisher.isICEConnected&&i.pcManager.publisher.getICEConnectionState()!=="checking"&&(c=!0),c&&i.negotiate();const u=i.dataChannelForKind(t,r);if((u==null?void 0:u.readyState)==="open")return;const l=new Date().getTime()+i.peerConnectionTimeout;for(;new Date().getTime()<l;){if(s.isICEConnected&&((o=i.dataChannelForKind(t,r))===null||o===void 0?void 0:o.readyState)==="open")return;yield qt(50)}throw new Ae("could not establish ".concat(a," connection, state: ").concat(s.getICEConnectionState()),pe.InternalError)}()})}ensurePublisherConnected(e){return T(this,void 0,void 0,function*(){this.publisherConnectionPromise||(this.publisherConnectionPromise=this.ensureDataTransportConnected(e,!1)),yield this.publisherConnectionPromise})}verifyTransport(){return!(!this.pcManager||this.pcManager.currentState!==Xe.CONNECTED||!this.client.ws||this.client.ws.readyState===WebSocket.CLOSED)}negotiate(){return T(this,void 0,void 0,function*(){return new Promise((e,t)=>T(this,void 0,void 0,function*(){if(!this.pcManager){t(new gp("PC manager is closed"));return}this.pcManager.requirePublisher(),this.pcManager.publisher.getTransceivers().length==0&&!this.lossyDC&&!this.reliableDC&&this.createDataChannels();const i=new AbortController,r=()=>{i.abort(),this.log.debug("engine disconnected while negotiation was ongoing",this.logContext),e()};this.isClosed&&t("cannot negotiate on closed engine"),this.on(j.Closing,r),this.pcManager.publisher.once(ho.RTPVideoPayloadTypes,o=>{const s=new Map;o.forEach(a=>{const c=a.codec.toLowerCase();B3(c)&&s.set(a.payload,c)}),this.emit(j.RTPVideoMapUpdate,s)});try{yield this.pcManager.negotiate(i),e()}catch(o){o instanceof gp&&(this.fullReconnectOnNext=!0),this.handleDisconnect("negotiation",to.RR_UNKNOWN),t(o)}finally{this.off(j.Closing,r)}}))})}dataChannelForKind(e,t){if(t){if(e===ge.LOSSY)return this.lossyDCSub;if(e===ge.RELIABLE)return this.reliableDCSub}else{if(e===ge.LOSSY)return this.lossyDC;if(e===ge.RELIABLE)return this.reliableDC}}sendSyncState(e,t){var i,r;if(!this.pcManager){this.log.warn("sync state cannot be sent without peer connection setup",this.logContext);return}const o=this.pcManager.subscriber.getLocalDescription(),s=this.pcManager.subscriber.getRemoteDescription(),a=(r=(i=this.signalOpts)===null||i===void 0?void 0:i.autoSubscribe)!==null&&r!==void 0?r:!0,c=new Array,u=new Array;e.forEach(l=>{l.isDesired!==a&&c.push(l.trackSid),l.isEnabled||u.push(l.trackSid)}),this.client.sendSyncState(new vk({answer:o?yu({sdp:o.sdp,type:o.type}):void 0,offer:s?yu({sdp:s.sdp,type:s.type}):void 0,subscription:new nu({trackSids:c,subscribe:!a,participantTracks:[]}),publishTracks:K3(t),dataChannels:this.dataChannelsInfo(),trackSidsDisabled:u}))}failNext(){this.shouldFailNext=!0}dataChannelsInfo(){const e=[],t=(i,r)=>{(i==null?void 0:i.id)!==void 0&&i.id!==null&&e.push(new yk({label:i.label,id:i.id,target:r}))};return t(this.dataChannelForKind(ge.LOSSY),hn.PUBLISHER),t(this.dataChannelForKind(ge.RELIABLE),hn.PUBLISHER),t(this.dataChannelForKind(ge.LOSSY,!0),hn.SUBSCRIBER),t(this.dataChannelForKind(ge.RELIABLE,!0),hn.SUBSCRIBER),e}clearReconnectTimeout(){this.reconnectTimeout&&_t.clearTimeout(this.reconnectTimeout)}clearPendingReconnect(){this.clearReconnectTimeout(),this.reconnectAttempts=0}registerOnLineListener(){Wt()&&window.addEventListener("online",this.handleBrowserOnLine)}deregisterOnLineListener(){Wt()&&window.removeEventListener("online",this.handleBrowserOnLine)}}class po extends Error{}function PU(n){return n!==void 0&&n>13}function OU(n,e){const t=n.participantIdentity?n.participantIdentity:e.participantIdentity;n.participantIdentity=t,e.participantIdentity=t;const i=n.destinationIdentities.length!==0?n.destinationIdentities:e.destinationIdentities;n.destinationIdentities=i,e.destinationIdentities=i}class Jp{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 xp(this.serverUrl)}getServerUrl(){return this.serverUrl}getNextBestRegionUrl(e){return T(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(i=>!this.attemptedRegions.find(r=>r.url===i.url));if(t.length>0){const i=t[0];return this.attemptedRegions.push(i),le.debug("next region: ".concat(i.region)),i.url}else return null})}resetAttempts(){this.attemptedRegions=[]}fetchRegionSettings(e){return T(this,void 0,void 0,function*(){const t=yield fetch("".concat(AU(this.serverUrl),"/regions"),{headers:{authorization:"Bearer ".concat(this.token)},signal:e});if(t.ok){const i=yield t.json();return this.lastUpdateAt=Date.now(),i}else throw new Ae("Could not fetch region settings: ".concat(t.statusText),t.status===401?pe.NotAllowed:pe.InternalError,t.status)})}setServerReportedRegions(e){this.regionSettings=e,this.lastUpdateAt=Date.now()}}function AU(n){return"".concat(n.protocol.replace("ws","http"),"//").concat(n.host,"/settings")}class KS{get info(){return this._info}constructor(e,t,i){this.reader=t,this.totalByteSize=i,this._info=e,this.bytesReceived=0}}class MU extends KS{handleChunkReceived(e){var t;this.bytesReceived+=e.content.byteLength;const i=this.totalByteSize?this.bytesReceived/this.totalByteSize:void 0;(t=this.onProgress)===null||t===void 0||t.call(this,i)}[Symbol.asyncIterator](){const e=this.reader.getReader();return{next:()=>T(this,void 0,void 0,function*(){try{const{done:t,value:i}=yield e.read();return t?{done:!0,value:void 0}:(this.handleChunkReceived(i),{done:!1,value:i.content})}catch{return{done:!0,value:void 0}}}),return(){return T(this,void 0,void 0,function*(){return e.releaseLock(),{done:!0,value:void 0}})}}}readAll(){return T(this,void 0,void 0,function*(){var e,t,i,r;let o=new Set;try{for(var s=!0,a=xi(this),c;c=yield a.next(),e=c.done,!e;s=!0){r=c.value,s=!1;const u=r;o.add(u)}}catch(u){t={error:u}}finally{try{!s&&!e&&(i=a.return)&&(yield i.call(a))}finally{if(t)throw t.error}}return Array.from(o)})}}class NU extends KS{constructor(e,t,i){super(e,t,i),this.receivedChunks=new Map}handleChunkReceived(e){var t;const i=gu(e.chunkIndex),r=this.receivedChunks.get(i);if(r&&r.version>e.version)return;this.receivedChunks.set(i,e),this.bytesReceived+=e.content.byteLength;const o=this.totalByteSize?this.bytesReceived/this.totalByteSize:void 0;(t=this.onProgress)===null||t===void 0||t.call(this,o)}[Symbol.asyncIterator](){const e=this.reader.getReader(),t=new TextDecoder;return{next:()=>T(this,void 0,void 0,function*(){try{const{done:i,value:r}=yield e.read();return i?{done:!0,value:void 0}:(this.handleChunkReceived(r),{done:!1,value:t.decode(r.content)})}catch{return{done:!0,value:void 0}}}),return(){return T(this,void 0,void 0,function*(){return e.releaseLock(),{done:!0,value:void 0}})}}}readAll(){return T(this,void 0,void 0,function*(){var e,t,i,r;let o="";try{for(var s=!0,a=xi(this),c;c=yield a.next(),e=c.done,!e;s=!0)r=c.value,s=!1,o+=r}catch(u){t={error:u}}finally{try{!s&&!e&&(i=a.return)&&(yield i.call(a))}finally{if(t)throw t.error}}return o})}}class YS{constructor(e,t,i){this.writableStream=e,this.defaultWriter=e.getWriter(),this.onClose=i,this.info=t}write(e){return this.defaultWriter.write(e)}close(){return T(this,void 0,void 0,function*(){var e;yield this.defaultWriter.close(),this.defaultWriter.releaseLock(),(e=this.onClose)===null||e===void 0||e.call(this)})}}class DU extends YS{}class LU extends YS{}class XS extends N{constructor(e,t,i,r,o){super(e,i,o),this.sid=t,this.receiver=r}get isLocal(){return!1}setMuted(e){this.isMuted!==e&&(this.isMuted=e,this._mediaStreamTrack.enabled=!e,this.emit(e?B.Muted:B.Unmuted,this))}setMediaStream(e){this.mediaStream=e;const t=i=>{i.track===this._mediaStreamTrack&&(e.removeEventListener("removetrack",t),this.receiver&&"playoutDelayHint"in this.receiver&&(this.receiver.playoutDelayHint=void 0),this.receiver=void 0,this._currentBitrate=0,this.emit(B.Ended,this))};e.addEventListener("removetrack",t)}start(){this.startMonitor(),super.enable()}stop(){this.stopMonitor(),super.disable()}getRTCStatsReport(){return T(this,void 0,void 0,function*(){var e;return!((e=this.receiver)===null||e===void 0)&&e.getStats?yield this.receiver.getStats():void 0})}setPlayoutDelay(e){this.receiver?"playoutDelayHint"in this.receiver?this.receiver.playoutDelayHint=e:this.log.warn("Playout delay not supported in this browser"):this.log.warn("Cannot set playout delay, track already ended")}getPlayoutDelay(){if(this.receiver){if("playoutDelayHint"in this.receiver)return this.receiver.playoutDelayHint;this.log.warn("Playout delay not supported in this browser")}else this.log.warn("Cannot get playout delay, track already ended");return 0}startMonitor(){this.monitorInterval||(this.monitorInterval=setInterval(()=>this.monitorReceiver(),$p)),Y3()&&this.registerTimeSyncUpdate()}registerTimeSyncUpdate(){const e=()=>{var t;this.timeSyncHandle=requestAnimationFrame(()=>e());const i=(t=this.receiver)===null||t===void 0?void 0:t.getSynchronizationSources()[0];if(i){const{timestamp:r,rtpTimestamp:o}=i;o&&this.rtpTimestamp!==o&&(this.emit(B.TimeSyncUpdate,{timestamp:r,rtpTimestamp:o}),this.rtpTimestamp=o)}};e()}}class UU extends XS{constructor(e,t,i,r,o,s){super(e,t,N.Kind.Audio,i,s),this.monitorReceiver=()=>T(this,void 0,void 0,function*(){if(!this.receiver){this._currentBitrate=0;return}const a=yield this.getReceiverStats();a&&this.prevStats&&this.receiver&&(this._currentBitrate=bu(a,this.prevStats)),this.prevStats=a}),this.audioContext=r,this.webAudioPluginNodes=[],o&&(this.sinkId=o.deviceId)}setVolume(e){var t;for(const i of this.attachedElements)this.audioContext?(t=this.gainNode)===null||t===void 0||t.gain.setTargetAtTime(e,0,.1):i.volume=e;Nn()&&this._mediaStreamTrack._setVolume(e),this.elementVolume=e}getVolume(){if(this.elementVolume)return this.elementVolume;if(Nn())return 1;let e=0;return this.attachedElements.forEach(t=>{t.volume>e&&(e=t.volume)}),e}setSinkId(e){return T(this,void 0,void 0,function*(){this.sinkId=e,yield Promise.all(this.attachedElements.map(t=>{if(Tp(t))return t.setSinkId(e)}))})}attach(e){const t=this.attachedElements.length===0;return e?super.attach(e):e=super.attach(),this.sinkId&&Tp(e)&&e.setSinkId(this.sinkId).catch(i=>{this.log.error("Failed to set sink id on remote audio track",i,this.logContext)}),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(e,t){this.disconnectWebAudio(),this.sourceNode=e.createMediaStreamSource(t.srcObject);let i=this.sourceNode;this.webAudioPluginNodes.forEach(r=>{i.connect(r),i=r}),this.gainNode=e.createGain(),i.connect(this.gainNode),this.gainNode.connect(e.destination),this.elementVolume&&this.gainNode.gain.setTargetAtTime(this.elementVolume,0,.1),e.state!=="running"&&e.resume().then(()=>{e.state!=="running"&&this.emit(B.AudioPlaybackFailed,new Error("Audio Context couldn't be started automatically"))}).catch(r=>{this.emit(B.AudioPlaybackFailed,r)})}disconnectWebAudio(){var e,t;(e=this.gainNode)===null||e===void 0||e.disconnect(),(t=this.sourceNode)===null||t===void 0||t.disconnect(),this.gainNode=void 0,this.sourceNode=void 0}getReceiverStats(){return T(this,void 0,void 0,function*(){if(!this.receiver||!this.receiver.getStats)return;const e=yield this.receiver.getStats();let t;return e.forEach(i=>{i.type==="inbound-rtp"&&(t={type:"audio",streamId:i.id,timestamp:i.timestamp,jitter:i.jitter,bytesReceived:i.bytesReceived,concealedSamples:i.concealedSamples,concealmentEvents:i.concealmentEvents,silentConcealedSamples:i.silentConcealedSamples,silentConcealmentEvents:i.silentConcealmentEvents,totalAudioEnergy:i.totalAudioEnergy,totalSamplesDuration:i.totalSamplesDuration})}),t})}}const Zp=100;class FU extends XS{constructor(e,t,i,r,o){super(e,t,N.Kind.Video,i,o),this.elementInfos=[],this.monitorReceiver=()=>T(this,void 0,void 0,function*(){if(!this.receiver){this._currentBitrate=0;return}const s=yield this.getReceiverStats();s&&this.prevStats&&this.receiver&&(this._currentBitrate=bu(s,this.prevStats)),this.prevStats=s}),this.debouncedHandleResize=zp(()=>{this.updateDimensions()},Zp),this.adaptiveStreamSettings=r}get isAdaptiveStream(){return this.adaptiveStreamSettings!==void 0}get mediaStreamTrack(){return this._mediaStreamTrack}setMuted(e){super.setMuted(e),this.attachedElements.forEach(t=>{e?ao(this._mediaStreamTrack,t):so(this._mediaStreamTrack,t)})}attach(e){if(e?super.attach(e):e=super.attach(),this.adaptiveStreamSettings&&this.elementInfos.find(t=>t.element===e)===void 0){const t=new BU(e);this.observeElementInfo(t)}return e}observeElementInfo(e){this.adaptiveStreamSettings&&this.elementInfos.find(t=>t===e)===void 0?(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){this.log.warn("stopObservingElementInfo ignored",this.logContext);return}const t=this.elementInfos.filter(i=>i===e);for(const i of t)i.stopObserving();this.elementInfos=this.elementInfos.filter(i=>i!==e),this.updateVisibility(),this.debouncedHandleResize()}detach(e){let t=[];if(e)return this.stopObservingElement(e),super.detach(e);t=super.detach();for(const i of t)this.stopObservingElement(i);return t}getDecoderImplementation(){var e;return(e=this.prevStats)===null||e===void 0?void 0:e.decoderImplementation}getReceiverStats(){return T(this,void 0,void 0,function*(){if(!this.receiver||!this.receiver.getStats)return;const e=yield this.receiver.getStats();let t,i="",r=new Map;return e.forEach(o=>{o.type==="inbound-rtp"?(i=o.codecId,t={type:"video",streamId:o.id,framesDecoded:o.framesDecoded,framesDropped:o.framesDropped,framesReceived:o.framesReceived,packetsReceived:o.packetsReceived,packetsLost:o.packetsLost,frameWidth:o.frameWidth,frameHeight:o.frameHeight,pliCount:o.pliCount,firCount:o.firCount,nackCount:o.nackCount,jitter:o.jitter,timestamp:o.timestamp,bytesReceived:o.bytesReceived,decoderImplementation:o.decoderImplementation}):o.type==="codec"&&r.set(o.id,o)}),t&&i!==""&&r.get(i)&&(t.mimeType=r.get(i).mimeType),t})}stopObservingElement(e){const t=this.elementInfos.filter(i=>i.element===e);for(const i of t)this.stopObservingElementInfo(i)}handleAppVisibilityChanged(){const e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return T(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),this.isAdaptiveStream&&this.updateVisibility()})}updateVisibility(){var e,t;const i=this.elementInfos.reduce((a,c)=>Math.max(a,c.visibilityChangedAt||0),0),r=!((t=(e=this.adaptiveStreamSettings)===null||e===void 0?void 0:e.pauseVideoInBackground)!==null&&t!==void 0)||t?this.isInBackground:!1,o=this.elementInfos.some(a=>a.pictureInPicture),s=this.elementInfos.some(a=>a.visible)&&!r||o;if(this.lastVisible!==s){if(!s&&Date.now()-i<Zp){_t.setTimeout(()=>{this.updateVisibility()},Zp);return}this.lastVisible=s,this.emit(B.VisibilityChanged,s,this)}}updateDimensions(){var e,t;let i=0,r=0;const o=this.getPixelDensity();for(const s of this.elementInfos){const a=s.width()*o,c=s.height()*o;a+c>i+r&&(i=a,r=c)}((e=this.lastDimensions)===null||e===void 0?void 0:e.width)===i&&((t=this.lastDimensions)===null||t===void 0?void 0:t.height)===r||(this.lastDimensions={width:i,height:r},this.emit(B.VideoDimensionsChanged,this.lastDimensions,this))}getPixelDensity(){var e;const t=(e=this.adaptiveStreamSettings)===null||e===void 0?void 0:e.pixelDensity;return t==="screen"?vS():t||(vS()>2?2:1)}}class BU{get visible(){return this.isPiP||this.isIntersecting}get pictureInPicture(){return this.isPiP}constructor(e,t){this.onVisibilityChanged=i=>{var r;const{target:o,isIntersecting:s}=i;o===this.element&&(this.isIntersecting=s,this.isPiP=_s(this.element),this.visibilityChangedAt=Date.now(),(r=this.handleVisibilityChanged)===null||r===void 0||r.call(this))},this.onEnterPiP=()=>{var i,r,o;(r=(i=window.documentPictureInPicture)===null||i===void 0?void 0:i.window)===null||r===void 0||r.addEventListener("pagehide",this.onLeavePiP),this.isPiP=_s(this.element),(o=this.handleVisibilityChanged)===null||o===void 0||o.call(this)},this.onLeavePiP=()=>{var i;this.isPiP=_s(this.element),(i=this.handleVisibilityChanged)===null||i===void 0||i.call(this)},this.element=e,this.isIntersecting=t??Qp(e),this.isPiP=Wt()&&_s(e),this.visibilityChangedAt=0}width(){return this.element.clientWidth}height(){return this.element.clientHeight}observe(){var e,t,i;this.isIntersecting=Qp(this.element),this.isPiP=_s(this.element),this.element.handleResize=()=>{var r;(r=this.handleResize)===null||r===void 0||r.call(this)},this.element.handleVisibilityChanged=this.onVisibilityChanged,bS().observe(this.element),yS().observe(this.element),this.element.addEventListener("enterpictureinpicture",this.onEnterPiP),this.element.addEventListener("leavepictureinpicture",this.onLeavePiP),(e=window.documentPictureInPicture)===null||e===void 0||e.addEventListener("enter",this.onEnterPiP),(i=(t=window.documentPictureInPicture)===null||t===void 0?void 0:t.window)===null||i===void 0||i.addEventListener("pagehide",this.onLeavePiP)}stopObserving(){var e,t,i,r,o;(e=bS())===null||e===void 0||e.unobserve(this.element),(t=yS())===null||t===void 0||t.unobserve(this.element),this.element.removeEventListener("enterpictureinpicture",this.onEnterPiP),this.element.removeEventListener("leavepictureinpicture",this.onLeavePiP),(i=window.documentPictureInPicture)===null||i===void 0||i.removeEventListener("enter",this.onEnterPiP),(o=(r=window.documentPictureInPicture)===null||r===void 0?void 0:r.window)===null||o===void 0||o.removeEventListener("pagehide",this.onLeavePiP)}}function _s(n){var e,t;return document.pictureInPictureElement===n?!0:!((e=window.documentPictureInPicture)===null||e===void 0)&&e.window?Qp(n,(t=window.documentPictureInPicture)===null||t===void 0?void 0:t.window):!1}function Qp(n,e){const t=e||window;let i=n.offsetTop,r=n.offsetLeft;const o=n.offsetWidth,s=n.offsetHeight,{hidden:a}=n,{display:c}=getComputedStyle(n);for(;n.offsetParent;)n=n.offsetParent,i+=n.offsetTop,r+=n.offsetLeft;return i<t.pageYOffset+t.innerHeight&&r<t.pageXOffset+t.innerWidth&&i+s>t.pageYOffset&&r+o>t.pageXOffset&&!a&&c!=="none"}class Jn extends Mn.EventEmitter{constructor(e,t,i,r){var o;super(),this.metadataMuted=!1,this.encryption=$t.NONE,this.log=le,this.handleMuted=()=>{this.emit(B.Muted)},this.handleUnmuted=()=>{this.emit(B.Unmuted)},this.log=Kn((o=r==null?void 0:r.loggerName)!==null&&o!==void 0?o:pn.Publication),this.loggerContextCb=this.loggerContextCb,this.setMaxListeners(100),this.kind=e,this.trackSid=t,this.trackName=i,this.source=N.Source.Unknown}setTrack(e){this.track&&(this.track.off(B.Muted,this.handleMuted),this.track.off(B.Unmuted,this.handleUnmuted)),this.track=e,e&&(e.on(B.Muted,this.handleMuted),e.on(B.Unmuted,this.handleUnmuted))}get logContext(){var e;return Object.assign(Object.assign({},(e=this.loggerContextCb)===null||e===void 0?void 0:e.call(this)),we(this))}get isMuted(){return this.metadataMuted}get isEnabled(){return!0}get isSubscribed(){return this.track!==void 0}get isEncrypted(){return this.encryption!==$t.NONE}get audioTrack(){if(Xn(this.track))return this.track}get videoTrack(){if(lo(this.track))return this.track}updateInfo(e){this.trackSid=e.sid,this.trackName=e.name,this.source=N.sourceFromProto(e.source),this.mimeType=e.mimeType,this.kind===N.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(n){(function(e){e.Desired="desired",e.Subscribed="subscribed",e.Unsubscribed="unsubscribed"})(n.SubscriptionStatus||(n.SubscriptionStatus={})),function(e){e.Allowed="allowed",e.NotAllowed="not_allowed"}(n.PermissionStatus||(n.PermissionStatus={}))})(Jn||(Jn={}));class ef extends Jn{get isUpstreamPaused(){var e;return(e=this.track)===null||e===void 0?void 0:e.isUpstreamPaused}constructor(e,t,i,r){super(e,t.sid,t.name,r),this.track=void 0,this.handleTrackEnded=()=>{this.emit(B.Ended)},this.updateInfo(t),this.setTrack(i)}setTrack(e){this.track&&this.track.off(B.Ended,this.handleTrackEnded),super.setTrack(e),e&&e.on(B.Ended,this.handleTrackEnded)}get isMuted(){return this.track?this.track.isMuted:super.isMuted}get audioTrack(){return super.audioTrack}get videoTrack(){return super.videoTrack}get isLocal(){return!0}mute(){return T(this,void 0,void 0,function*(){var e;return(e=this.track)===null||e===void 0?void 0:e.mute()})}unmute(){return T(this,void 0,void 0,function*(){var e;return(e=this.track)===null||e===void 0?void 0:e.unmute()})}pauseUpstream(){return T(this,void 0,void 0,function*(){var e;yield(e=this.track)===null||e===void 0?void 0:e.pauseUpstream()})}resumeUpstream(){return T(this,void 0,void 0,function*(){var e;yield(e=this.track)===null||e===void 0?void 0:e.resumeUpstream()})}getTrackFeatures(){var e;if(Xn(this.track)){const t=this.track.getSourceTrackSettings(),i=new Set;return t.autoGainControl&&i.add(dn.TF_AUTO_GAIN_CONTROL),t.echoCancellation&&i.add(dn.TF_ECHO_CANCELLATION),t.noiseSuppression&&i.add(dn.TF_NOISE_SUPPRESSION),t.channelCount&&t.channelCount>1&&i.add(dn.TF_STEREO),!((e=this.options)===null||e===void 0)&&e.dtx||i.add(dn.TF_NO_DTX),this.track.enhancedNoiseCancellation&&i.add(dn.TF_ENHANCED_NOISE_CANCELLATION),Array.from(i.values())}else return[]}}function wu(n,e){return T(this,void 0,void 0,function*(){n??(n={});let t=!1;const{audioProcessor:i,videoProcessor:r,optionsWithoutProcessor:o}=xS(n);let s=o.audio,a=o.video;if(i&&typeof o.audio=="object"&&(o.audio.processor=i),r&&typeof o.video=="object"&&(o.video.processor=r),n.audio&&typeof o.audio=="object"&&typeof o.audio.deviceId=="string"){const d=o.audio.deviceId;o.audio.deviceId={exact:d},t=!0,s=Object.assign(Object.assign({},o.audio),{deviceId:{ideal:d}})}if(o.video&&typeof o.video=="object"&&typeof o.video.deviceId=="string"){const d=o.video.deviceId;o.video.deviceId={exact:d},t=!0,a=Object.assign(Object.assign({},o.video),{deviceId:{ideal:d}})}(o.audio===!0||typeof o.audio=="object"&&!o.audio.deviceId)&&(o.audio={deviceId:"default"}),o.video===!0?o.video={deviceId:"default"}:typeof o.video=="object"&&!o.video.deviceId&&(o.video.deviceId="default");const c=SS(o,LS,US),u=Dp(c),l=navigator.mediaDevices.getUserMedia(u);o.audio&&(ft.userMediaPromiseMap.set("audioinput",l),l.catch(()=>ft.userMediaPromiseMap.delete("audioinput"))),o.video&&(ft.userMediaPromiseMap.set("videoinput",l),l.catch(()=>ft.userMediaPromiseMap.delete("videoinput")));try{const d=yield l;return yield Promise.all(d.getTracks().map(h=>T(this,void 0,void 0,function*(){const p=h.kind==="audio";let m=p?c.audio:c.video;(typeof m=="boolean"||!m)&&(m={});let f;const g=p?u.audio:u.video;typeof g!="boolean"&&(f=g);const y=h.getSettings().deviceId;f!=null&&f.deviceId&&Oi(f.deviceId)!==y?f.deviceId=y:f||(f={deviceId:y});const b=gU(h,f,e);return b.kind===N.Kind.Video?b.source=N.Source.Camera:b.kind===N.Kind.Audio&&(b.source=N.Source.Microphone),b.mediaStream=d,Xn(b)&&i?yield b.setProcessor(i):lo(b)&&r&&(yield b.setProcessor(r)),b})))}catch(d){if(!t)throw d;return wu(Object.assign(Object.assign({},n),{audio:s,video:a}),e)}})}function jU(n){return T(this,void 0,void 0,function*(){return(yield wu({audio:!1,video:n??!0}))[0]})}function VU(n){return T(this,void 0,void 0,function*(){return(yield wu({audio:n??!0,video:!1}))[0]})}var Ni;(function(n){n.Excellent="excellent",n.Good="good",n.Poor="poor",n.Lost="lost",n.Unknown="unknown"})(Ni||(Ni={}));function zU(n){switch(n){case hs.EXCELLENT:return Ni.Excellent;case hs.GOOD:return Ni.Good;case hs.POOR:return Ni.Poor;case hs.LOST:return Ni.Lost;default:return Ni.Unknown}}class JS extends Mn.EventEmitter{get logContext(){var e,t;return Object.assign({},(t=(e=this.loggerOptions)===null||e===void 0?void 0:e.loggerContextCb)===null||t===void 0?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;return((e=this.permissions)===null||e===void 0?void 0:e.agent)||this.kind===tu.AGENT}get isActive(){var e;return((e=this.participantInfo)===null||e===void 0?void 0:e.state)===no.ACTIVE}get kind(){return this._kind}get attributes(){return Object.freeze(Object.assign({},this._attributes))}constructor(e,t,i,r,o,s){let a=arguments.length>6&&arguments[6]!==void 0?arguments[6]:tu.STANDARD;var c;super(),this.audioLevel=0,this.isSpeaking=!1,this._connectionQuality=Ni.Unknown,this.log=le,this.log=Kn((c=s==null?void 0:s.loggerName)!==null&&c!==void 0?c:pn.Participant),this.loggerOptions=s,this.setMaxListeners(100),this.sid=e,this.identity=t,this.name=i,this.metadata=r,this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.trackPublications=new Map,this._kind=a,this._attributes=o??{}}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}waitUntilActive(){return this.isActive?Promise.resolve():this.activeFuture?this.activeFuture.promise:(this.activeFuture=new Pp,this.once(q.Active,()=>{var e,t;(t=(e=this.activeFuture)===null||e===void 0?void 0:e.resolve)===null||t===void 0||t.call(e),this.activeFuture=void 0}),this.activeFuture.promise)}get connectionQuality(){return this._connectionQuality}get isCameraEnabled(){var e;const t=this.getTrackPublication(N.Source.Camera);return!(!((e=t==null?void 0:t.isMuted)!==null&&e!==void 0)||e)}get isMicrophoneEnabled(){var e;const t=this.getTrackPublication(N.Source.Microphone);return!(!((e=t==null?void 0:t.isMuted)!==null&&e!==void 0)||e)}get isScreenShareEnabled(){return!!this.getTrackPublication(N.Source.ScreenShare)}get isLocal(){return!1}get joinedAt(){return this.participantInfo?new Date(Number.parseInt(this.participantInfo.joinedAt.toString())*1e3):new Date}updateInfo(e){var t;return this.participantInfo&&this.participantInfo.sid===e.sid&&this.participantInfo.version>e.version?!1:(this.identity=e.identity,this.sid=e.sid,this._setName(e.name),this._setMetadata(e.metadata),this._setAttributes(e.attributes),e.state===no.ACTIVE&&((t=this.participantInfo)===null||t===void 0?void 0:t.state)!==no.ACTIVE&&this.emit(q.Active),e.permission&&this.setPermissions(e.permission),this.participantInfo=e,!0)}_setMetadata(e){const t=this.metadata!==e,i=this.metadata;this.metadata=e,t&&this.emit(q.ParticipantMetadataChanged,i)}_setName(e){const t=this.name!==e;this.name=e,t&&this.emit(q.ParticipantNameChanged,e)}_setAttributes(e){const t=X3(this.attributes,e);this._attributes=e,Object.keys(t).length>0&&this.emit(q.AttributesChanged,t)}setPermissions(e){var t,i,r,o,s,a;const c=this.permissions,u=e.canPublish!==((t=this.permissions)===null||t===void 0?void 0:t.canPublish)||e.canSubscribe!==((i=this.permissions)===null||i===void 0?void 0:i.canSubscribe)||e.canPublishData!==((r=this.permissions)===null||r===void 0?void 0:r.canPublishData)||e.hidden!==((o=this.permissions)===null||o===void 0?void 0:o.hidden)||e.recorder!==((s=this.permissions)===null||s===void 0?void 0:s.recorder)||e.canPublishSources.length!==this.permissions.canPublishSources.length||e.canPublishSources.some((l,d)=>{var h;return l!==((h=this.permissions)===null||h===void 0?void 0:h.canPublishSources[d])})||e.canSubscribeMetrics!==((a=this.permissions)===null||a===void 0?void 0:a.canSubscribeMetrics);return this.permissions=e,u&&this.emit(q.ParticipantPermissionsChanged,c),u}setIsSpeaking(e){e!==this.isSpeaking&&(this.isSpeaking=e,e&&(this.lastSpokeAt=new Date),this.emit(q.IsSpeakingChanged,e))}setConnectionQuality(e){const t=this._connectionQuality;this._connectionQuality=zU(e),t!==this._connectionQuality&&this.emit(q.ConnectionQualityChanged,this._connectionQuality)}setDisconnected(){var e,t;this.activeFuture&&((t=(e=this.activeFuture).reject)===null||t===void 0||t.call(e,new Error("Participant disconnected")),this.activeFuture=void 0)}setAudioContext(e){this.audioContext=e,this.audioTrackPublications.forEach(t=>Xn(t.track)&&t.track.setAudioContext(e))}addTrackPublication(e){e.on(B.Muted,()=>{this.emit(q.TrackMuted,e)}),e.on(B.Unmuted,()=>{this.emit(q.TrackUnmuted,e)});const t=e;switch(t.track&&(t.track.sid=e.trackSid),this.trackPublications.set(e.trackSid,e),e.kind){case N.Kind.Audio:this.audioTrackPublications.set(e.trackSid,e);break;case N.Kind.Video:this.videoTrackPublications.set(e.trackSid,e);break}}}function qU(n){var e,t,i;if(!n.participantSid&&!n.participantIdentity)throw new Error("Invalid track permission, must provide at least one of participantIdentity and participantSid");return new mk({participantIdentity:(e=n.participantIdentity)!==null&&e!==void 0?e:"",participantSid:(t=n.participantSid)!==null&&t!==void 0?t:"",allTracks:(i=n.allowAll)!==null&&i!==void 0?i:!1,trackSids:n.allowedTrackSids||[]})}const ZS=15e3;class WU extends JS{constructor(e,t,i,r,o){super(e,t,void 0,void 0,void 0,{loggerName:r.loggerName,loggerContextCb:()=>this.engine.logContext}),this.pendingPublishing=new Set,this.pendingPublishPromises=new Map,this.participantTrackPermissions=[],this.allParticipantsAllowedToSubscribe=!0,this.encryptionType=$t.NONE,this.enabledPublishVideoCodecs=[],this.pendingAcks=new Map,this.pendingResponses=new Map,this.handleReconnecting=()=>{this.reconnectFuture||(this.reconnectFuture=new Pp)},this.handleReconnected=()=>{var s,a;(a=(s=this.reconnectFuture)===null||s===void 0?void 0:s.resolve)===null||a===void 0||a.call(s),this.reconnectFuture=void 0,this.updateTrackSubscriptionPermissions()},this.handleDisconnected=()=>{var s,a;this.reconnectFuture&&(this.reconnectFuture.promise.catch(c=>this.log.warn(c.message,this.logContext)),(a=(s=this.reconnectFuture)===null||s===void 0?void 0:s.reject)===null||a===void 0||a.call(s,"Got disconnected during reconnection attempt"),this.reconnectFuture=void 0)},this.handleSignalRequestResponse=s=>{const{requestId:a,reason:c,message:u}=s,l=this.pendingSignalRequests.get(a);l&&(c!==rp.OK&&l.reject(new lS(u,c)),this.pendingSignalRequests.delete(a))},this.handleDataPacket=s=>{switch(s.value.case){case"rpcResponse":let a=s.value.value,c=null,u=null;a.value.case==="payload"?c=a.value.value:a.value.case==="error"&&(u=Je.fromProto(a.value.value)),this.handleIncomingRpcResponse(a.requestId,c,u);break;case"rpcAck":let l=s.value.value;this.handleIncomingRpcAck(l.requestId);break}},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(s=>qU(s)))},this.onTrackUnmuted=s=>{this.onTrackMuted(s,s.isUpstreamPaused)},this.onTrackMuted=(s,a)=>{if(a===void 0&&(a=!0),!s.sid){this.log.error("could not update mute status for unpublished track",Object.assign(Object.assign({},this.logContext),we(s)));return}this.engine.updateMuteStatus(s.sid,a)},this.onTrackUpstreamPaused=s=>{this.log.debug("upstream paused",Object.assign(Object.assign({},this.logContext),we(s))),this.onTrackMuted(s,!0)},this.onTrackUpstreamResumed=s=>{this.log.debug("upstream resumed",Object.assign(Object.assign({},this.logContext),we(s))),this.onTrackMuted(s,s.isMuted)},this.onTrackFeatureUpdate=s=>{const a=this.audioTrackPublications.get(s.sid);if(!a){this.log.warn("Could not update local audio track settings, missing publication for track ".concat(s.sid),this.logContext);return}this.engine.client.sendUpdateLocalAudioTrack(a.trackSid,a.getTrackFeatures())},this.handleSubscribedQualityUpdate=s=>T(this,void 0,void 0,function*(){var a,c,u,l,d,h;if(!(!((d=this.roomOptions)===null||d===void 0)&&d.dynacast))return;const p=this.videoTrackPublications.get(s.trackSid);if(!p){this.log.warn("received subscribed quality update for unknown track",Object.assign(Object.assign({},this.logContext),{trackSid:s.trackSid}));return}if(s.subscribedCodecs.length>0){if(!p.videoTrack)return;const y=yield p.videoTrack.setPublishingCodecs(s.subscribedCodecs);try{for(var m=!0,f=xi(y),g;g=yield f.next(),a=g.done,!a;m=!0){l=g.value,m=!1;const b=l;I3(b)&&(this.log.debug("publish ".concat(b," for ").concat(p.videoTrack.sid),Object.assign(Object.assign({},this.logContext),we(p))),yield this.publishAdditionalCodecForTrack(p.videoTrack,b,p.options))}}catch(b){c={error:b}}finally{try{!m&&!a&&(u=f.return)&&(yield u.call(f))}finally{if(c)throw c.error}}}else s.subscribedQualities.length>0&&(yield(h=p.videoTrack)===null||h===void 0?void 0:h.setPublishingLayers(s.subscribedQualities))}),this.handleLocalTrackUnpublished=s=>{const a=this.trackPublications.get(s.trackSid);if(!a){this.log.warn("received unpublished event for unknown track",Object.assign(Object.assign({},this.logContext),{trackSid:s.trackSid}));return}this.unpublishTrack(a.track)},this.handleTrackEnded=s=>T(this,void 0,void 0,function*(){if(s.source===N.Source.ScreenShare||s.source===N.Source.ScreenShareAudio)this.log.debug("unpublishing local track due to TrackEnded",Object.assign(Object.assign({},this.logContext),we(s))),this.unpublishTrack(s);else if(s.isUserProvided)yield s.mute();else if(sr(s)||Ai(s))try{if(Wt())try{const a=yield navigator==null?void 0:navigator.permissions.query({name:s.source===N.Source.Camera?"camera":"microphone"});if(a&&a.state==="denied")throw this.log.warn("user has revoked access to ".concat(s.source),Object.assign(Object.assign({},this.logContext),we(s))),a.onchange=()=>{a.state!=="denied"&&(s.isMuted||s.restartTrack(),a.onchange=null)},new Error("GetUserMedia Permission denied")}catch{}s.isMuted||(this.log.debug("track ended, attempting to use a different device",Object.assign(Object.assign({},this.logContext),we(s))),sr(s)?yield s.restartTrack({deviceId:"default"}):yield s.restartTrack())}catch{this.log.warn("could not restart track, muting instead",Object.assign(Object.assign({},this.logContext),we(s))),yield s.mute()}}),this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.trackPublications=new Map,this.engine=i,this.roomOptions=r,this.setupEngine(i),this.activeDeviceMap=new Map([["audioinput","default"],["videoinput","default"],["audiooutput","default"]]),this.pendingSignalRequests=new Map,this.rpcHandlers=o}get lastCameraError(){return this.cameraError}get lastMicrophoneError(){return this.microphoneError}get isE2EEEnabled(){return this.encryptionType!==$t.NONE}getTrackPublication(e){const t=super.getTrackPublication(e);if(t)return t}getTrackPublicationByName(e){const t=super.getTrackPublicationByName(e);if(t)return t}setupEngine(e){this.engine=e,this.engine.on(j.RemoteMute,(t,i)=>{const r=this.trackPublications.get(t);!r||!r.track||(i?r.mute():r.unmute())}),this.engine.on(j.Connected,this.handleReconnected).on(j.SignalRestarted,this.handleReconnected).on(j.SignalResumed,this.handleReconnected).on(j.Restarting,this.handleReconnecting).on(j.Resuming,this.handleReconnecting).on(j.LocalTrackUnpublished,this.handleLocalTrackUnpublished).on(j.SubscribedQualityUpdate,this.handleSubscribedQualityUpdate).on(j.Disconnected,this.handleDisconnected).on(j.SignalRequestResponse,this.handleSignalRequestResponse).on(j.DataPacketReceived,this.handleDataPacket)}setMetadata(e){return T(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({metadata:e})})}setName(e){return T(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({name:e})})}setAttributes(e){return T(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({attributes:e})})}requestMetadataUpdate(e){return T(this,arguments,void 0,function(t){var i=this;let{metadata:r,name:o,attributes:s}=t;return function*(){return new Promise((a,c)=>T(i,void 0,void 0,function*(){var u,l;try{let d=!1;const h=yield this.engine.client.sendUpdateLocalMetadata((u=r??this.metadata)!==null&&u!==void 0?u:"",(l=o??this.name)!==null&&l!==void 0?l:"",s),p=performance.now();for(this.pendingSignalRequests.set(h,{resolve:a,reject:m=>{c(m),d=!0},values:{name:o,metadata:r,attributes:s}});performance.now()-p<5e3&&!d;){if((!o||this.name===o)&&(!r||this.metadata===r)&&(!s||Object.entries(s).every(m=>{let[f,g]=m;return this.attributes[f]===g||g===""&&!this.attributes[f]}))){this.pendingSignalRequests.delete(h),a();return}yield qt(50)}c(new lS("Request to update local metadata timed out","TimeoutError"))}catch(d){d instanceof Error&&c(d)}}))}()})}setCameraEnabled(e,t,i){return this.setTrackEnabled(N.Source.Camera,e,t,i)}setMicrophoneEnabled(e,t,i){return this.setTrackEnabled(N.Source.Microphone,e,t,i)}setScreenShareEnabled(e,t,i){return this.setTrackEnabled(N.Source.ScreenShare,e,t,i)}setPermissions(e){const t=this.permissions,i=super.setPermissions(e);return i&&t&&this.emit(q.ParticipantPermissionsChanged,t),i}setE2EEEnabled(e){return T(this,void 0,void 0,function*(){this.encryptionType=e?$t.GCM:$t.NONE,yield this.republishAllTracks(void 0,!1)})}setTrackEnabled(e,t,i,r){return T(this,void 0,void 0,function*(){var o,s;this.log.debug("setTrackEnabled",Object.assign(Object.assign({},this.logContext),{source:e,enabled:t})),this.republishPromise&&(yield this.republishPromise);let a=this.getTrackPublication(e);if(t)if(a)yield a.unmute();else{let c;if(this.pendingPublishing.has(e)){const u=yield this.waitForPendingPublicationOfSource(e);return u||this.log.info("waiting for pending publication promise timed out",Object.assign(Object.assign({},this.logContext),{source:e})),yield u==null?void 0:u.unmute(),u}this.pendingPublishing.add(e);try{switch(e){case N.Source.Camera:c=yield this.createTracks({video:(o=i)!==null&&o!==void 0?o:!0});break;case N.Source.Microphone:c=yield this.createTracks({audio:(s=i)!==null&&s!==void 0?s:!0});break;case N.Source.ScreenShare:c=yield this.createScreenTracks(Object.assign({},i));break;default:throw new Yn(e)}}catch(u){throw c==null||c.forEach(l=>{l.stop()}),u instanceof Error&&this.emit(q.MediaDevicesError,u),this.pendingPublishing.delete(e),u}try{const u=[];for(const d of c)this.log.info("publishing track",Object.assign(Object.assign({},this.logContext),we(d))),u.push(this.publishTrack(d,r));[a]=yield Promise.all(u)}catch(u){throw c==null||c.forEach(l=>{l.stop()}),u}finally{this.pendingPublishing.delete(e)}}else if(!(a!=null&&a.track)&&this.pendingPublishing.has(e)&&(a=yield this.waitForPendingPublicationOfSource(e),a||this.log.info("waiting for pending publication promise timed out",Object.assign(Object.assign({},this.logContext),{source:e}))),a&&a.track)if(e===N.Source.ScreenShare){a=yield this.unpublishTrack(a.track);const c=this.getTrackPublication(N.Source.ScreenShareAudio);c&&c.track&&this.unpublishTrack(c.track)}else yield a.mute();return a})}enableCameraAndMicrophone(){return T(this,void 0,void 0,function*(){if(!(this.pendingPublishing.has(N.Source.Camera)||this.pendingPublishing.has(N.Source.Microphone))){this.pendingPublishing.add(N.Source.Camera),this.pendingPublishing.add(N.Source.Microphone);try{const e=yield this.createTracks({audio:!0,video:!0});yield Promise.all(e.map(t=>this.publishTrack(t)))}finally{this.pendingPublishing.delete(N.Source.Camera),this.pendingPublishing.delete(N.Source.Microphone)}}})}createTracks(e){return T(this,void 0,void 0,function*(){var t,i;e??(e={});const r=SS(e,(t=this.roomOptions)===null||t===void 0?void 0:t.audioCaptureDefaults,(i=this.roomOptions)===null||i===void 0?void 0:i.videoCaptureDefaults);try{return(yield wu(r,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext})).map(a=>(Xn(a)&&(this.microphoneError=void 0,a.setAudioContext(this.audioContext),a.source=N.Source.Microphone,this.emit(q.AudioStreamAcquired)),lo(a)&&(this.cameraError=void 0,a.source=N.Source.Camera),a))}catch(o){throw o instanceof Error&&(e.audio&&(this.microphoneError=o),e.video&&(this.cameraError=o)),o}})}createScreenTracks(e){return T(this,void 0,void 0,function*(){if(e===void 0&&(e={}),navigator.mediaDevices.getDisplayMedia===void 0)throw new mp("getDisplayMedia not supported");e.resolution===void 0&&!N3()&&(e.resolution=Sp.h1080fps30.resolution);const t=H3(e),i=yield navigator.mediaDevices.getDisplayMedia(t),r=i.getVideoTracks();if(r.length===0)throw new Yn("no video track found");const o=new Su(r[0],void 0,!1,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});o.source=N.Source.ScreenShare,e.contentHint&&(o.mediaStreamTrack.contentHint=e.contentHint);const s=[o];if(i.getAudioTracks().length>0){this.emit(q.AudioStreamAcquired);const a=new _u(i.getAudioTracks()[0],void 0,!1,this.audioContext,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});a.source=N.Source.ScreenShareAudio,s.push(a)}return s})}publishTrack(e,t){return T(this,void 0,void 0,function*(){return this.publishOrRepublishTrack(e,t)})}publishOrRepublishTrack(e,t){return T(this,arguments,void 0,function(i,r){var o=this;let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return function*(){var a,c,u,l;sr(i)&&i.setAudioContext(o.audioContext),yield(a=o.reconnectFuture)===null||a===void 0?void 0:a.promise,o.republishPromise&&!s&&(yield o.republishPromise),uo(i)&&o.pendingPublishPromises.has(i)&&(yield o.pendingPublishPromises.get(i));let d;if(i instanceof MediaStreamTrack)d=i.getConstraints();else{d=i.constraints;let y;switch(i.source){case N.Source.Microphone:y="audioinput";break;case N.Source.Camera:y="videoinput"}y&&o.activeDeviceMap.has(y)&&(d=Object.assign(Object.assign({},d),{deviceId:o.activeDeviceMap.get(y)}))}if(i instanceof MediaStreamTrack)switch(i.kind){case"audio":i=new _u(i,d,!0,o.audioContext,{loggerName:o.roomOptions.loggerName,loggerContextCb:()=>o.logContext});break;case"video":i=new Su(i,d,!0,{loggerName:o.roomOptions.loggerName,loggerContextCb:()=>o.logContext});break;default:throw new Yn("unsupported MediaStreamTrack kind ".concat(i.kind))}else i.updateLoggerOptions({loggerName:o.roomOptions.loggerName,loggerContextCb:()=>o.logContext});let h;if(o.trackPublications.forEach(y=>{y.track&&y.track===i&&(h=y)}),h)return o.log.warn("track has already been published, skipping",Object.assign(Object.assign({},o.logContext),we(h))),h;const p="channelCount"in i.mediaStreamTrack.getSettings()&&i.mediaStreamTrack.getSettings().channelCount===2||i.mediaStreamTrack.getConstraints().channelCount===2,m=(c=r==null?void 0:r.forceStereo)!==null&&c!==void 0?c:p;m&&(r||(r={}),r.dtx===void 0&&o.log.info("Opus DTX will be disabled for stereo tracks by default. Enable them explicitly to make it work.",Object.assign(Object.assign({},o.logContext),we(i))),r.red===void 0&&o.log.info("Opus RED will be disabled for stereo tracks by default. Enable them explicitly to make it work."),(u=r.dtx)!==null&&u!==void 0||(r.dtx=!1),(l=r.red)!==null&&l!==void 0||(r.red=!1));const f=Object.assign(Object.assign({},o.roomOptions.publishDefaults),r);!D3()&&o.roomOptions.e2ee&&(o.log.info("End-to-end encryption is set up, simulcast publishing will be disabled on Safari versions and iOS browsers running iOS < v17.2",Object.assign({},o.logContext)),f.simulcast=!1),f.source&&(i.source=f.source);const g=new Promise((y,b)=>T(o,void 0,void 0,function*(){try{if(this.engine.client.currentState!==Be.CONNECTED){this.log.debug("deferring track publication until signal is connected",Object.assign(Object.assign({},this.logContext),{track:we(i)}));const S=()=>T(this,void 0,void 0,function*(){try{const w=yield this.publish(i,f,m);y(w)}catch(w){b(w)}});setTimeout(()=>{this.engine.off(j.SignalConnected,S),b(new vp("publishing rejected as engine not connected within timeout",408))},15e3),this.engine.once(j.SignalConnected,S),this.engine.on(j.Closing,()=>{this.engine.off(j.SignalConnected,S),b(new vp("publishing rejected as engine closed",499))})}else try{const S=yield this.publish(i,f,m);y(S)}catch(S){b(S)}}catch(S){b(S)}}));o.pendingPublishPromises.set(i,g);try{return yield g}catch(y){throw y}finally{o.pendingPublishPromises.delete(i)}}()})}hasPermissionsToPublish(e){if(!this.permissions)return this.log.warn("no permissions present for publishing track",Object.assign(Object.assign({},this.logContext),we(e))),!1;const{canPublish:t,canPublishSources:i}=this.permissions;return t&&(i.length===0||i.map(r=>J3(r)).includes(e.source))?!0:(this.log.warn("insufficient permissions to publish",Object.assign(Object.assign({},this.logContext),we(e))),!1)}publish(e,t,i){return T(this,void 0,void 0,function*(){var r,o,s,a,c,u,l,d,h,p;if(!this.hasPermissionsToPublish(e))throw new vp("failed to publish track, insufficient permissions",403);Array.from(this.trackPublications.values()).find(k=>uo(e)&&k.source===e.source)&&e.source!==N.Source.Unknown&&this.log.info("publishing a second track with the same source: ".concat(e.source),Object.assign(Object.assign({},this.logContext),we(e))),t.stopMicTrackOnMute&&Xn(e)&&(e.stopOnMute=!0),e.source===N.Source.ScreenShare&&co()&&(t.simulcast=!1),t.videoCodec==="av1"&&!O3()&&(t.videoCodec=void 0),t.videoCodec==="vp9"&&!A3()&&(t.videoCodec=void 0),t.videoCodec===void 0&&(t.videoCodec=qp),this.enabledPublishVideoCodecs.length>0&&(this.enabledPublishVideoCodecs.some(k=>t.videoCodec===vu(k.mime))||(t.videoCodec=vu(this.enabledPublishVideoCodecs[0].mime)));const f=t.videoCodec;e.on(B.Muted,this.onTrackMuted),e.on(B.Unmuted,this.onTrackUnmuted),e.on(B.Ended,this.handleTrackEnded),e.on(B.UpstreamPaused,this.onTrackUpstreamPaused),e.on(B.UpstreamResumed,this.onTrackUpstreamResumed),e.on(B.AudioTrackFeatureUpdate,this.onTrackFeatureUpdate);const g=new Qh({cid:e.mediaStreamTrack.id,name:t.name,type:N.kindToProto(e.kind),muted:e.isMuted,source:N.sourceToProto(e.source),disableDtx:!(!((r=t.dtx)!==null&&r!==void 0)||r),encryption:this.encryptionType,stereo:i,disableRed:this.isE2EEEnabled||!(!((o=t.red)!==null&&o!==void 0)||o),stream:t==null?void 0:t.stream,backupCodecPolicy:t==null?void 0:t.backupCodecPolicy});let y;if(e.kind===N.Kind.Video){let k={width:0,height:0};try{k=yield e.waitForDimensions()}catch{const x=(a=(s=this.roomOptions.videoCaptureDefaults)===null||s===void 0?void 0:s.resolution)!==null&&a!==void 0?a:gs.h720.resolution;k={width:x.width,height:x.height},this.log.error("could not determine track dimensions, using defaults",Object.assign(Object.assign(Object.assign({},this.logContext),we(e)),{dims:k}))}g.width=k.width,g.height=k.height,Ai(e)&&(vs(f)&&(e.source===N.Source.ScreenShare&&(t.scalabilityMode="L1T3","contentHint"in e.mediaStreamTrack&&(e.mediaStreamTrack.contentHint="motion",this.log.info("forcing contentHint to motion for screenshare with SVC codecs",Object.assign(Object.assign({},this.logContext),we(e))))),t.scalabilityMode=(c=t.scalabilityMode)!==null&&c!==void 0?c:"L3T3_KEY"),g.simulcastCodecs=[new Zh({codec:f,cid:e.mediaStreamTrack.id})],t.backupCodec===!0&&(t.backupCodec={codec:qp}),t.backupCodec&&f!==t.backupCodec.codec&&g.encryption===$t.NONE&&(this.roomOptions.dynacast||(this.roomOptions.dynacast=!0),g.simulcastCodecs.push(new Zh({codec:t.backupCodec.codec,cid:""})))),y=Kp(e.source===N.Source.ScreenShare,g.width,g.height,t),g.layers=GS(g.width,g.height,y,vs(t.videoCodec))}else e.kind===N.Kind.Audio&&(y=[{maxBitrate:(u=t.audioPreset)===null||u===void 0?void 0:u.maxBitrate,priority:(d=(l=t.audioPreset)===null||l===void 0?void 0:l.priority)!==null&&d!==void 0?d:"high",networkPriority:(p=(h=t.audioPreset)===null||h===void 0?void 0:h.priority)!==null&&p!==void 0?p:"high"}]);if(!this.engine||this.engine.isClosed)throw new lt("cannot publish track when not connected");const b=()=>T(this,void 0,void 0,function*(){var k,C,x;if(!this.engine.pcManager)throw new lt("pcManager is not ready");if(e.sender=yield this.engine.createSender(e,t,y),Ai(e)&&((k=t.degradationPreference)!==null&&k!==void 0||(t.degradationPreference=xU(e)),e.setDegradationPreference(t.degradationPreference)),y)if(co()&&e.kind===N.Kind.Audio){let I;for(const P of this.engine.pcManager.publisher.getTransceivers())if(P.sender===e.sender){I=P;break}I&&this.engine.pcManager.publisher.setTrackCodecBitrate({transceiver:I,codec:"opus",maxbr:!((C=y[0])===null||C===void 0)&&C.maxBitrate?y[0].maxBitrate/1e3:0})}else e.codec&&vs(e.codec)&&(!((x=y[0])===null||x===void 0)&&x.maxBitrate)&&this.engine.pcManager.publisher.setTrackCodecBitrate({cid:g.cid,codec:e.codec,maxbr:y[0].maxBitrate/1e3});yield this.engine.negotiate()});let S;if(this.enabledPublishVideoCodecs.length>0)S=(yield Promise.all([this.engine.addTrack(g),b()]))[0];else{S=yield this.engine.addTrack(g);let k;if(S.codecs.forEach(C=>{k===void 0&&(k=C.mimeType)}),k&&e.kind===N.Kind.Video){const C=vu(k);C!==f&&(this.log.debug("falling back to server selected codec",Object.assign(Object.assign(Object.assign({},this.logContext),we(e)),{codec:C})),t.videoCodec=C,y=Kp(e.source===N.Source.ScreenShare,g.width,g.height,t))}yield b()}const w=new ef(e.kind,S,e,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});return w.options=t,e.sid=S.sid,this.log.debug("publishing ".concat(e.kind," with encodings"),Object.assign(Object.assign({},this.logContext),{encodings:y,trackInfo:S})),Ai(e)?e.startMonitor(this.engine.client):sr(e)&&e.startMonitor(),this.addTrackPublication(w),this.emit(q.LocalTrackPublished,w),w})}get isLocal(){return!0}publishAdditionalCodecForTrack(e,t,i){return T(this,void 0,void 0,function*(){var r;if(this.encryptionType!==$t.NONE)return;let o;if(this.trackPublications.forEach(p=>{p.track&&p.track===e&&(o=p)}),!o)throw new Yn("track is not published");if(!Ai(e))throw new Yn("track is not a video track");const s=Object.assign(Object.assign({},(r=this.roomOptions)===null||r===void 0?void 0:r.publishDefaults),i),a=wU(e,t,s);if(!a){this.log.info("backup codec has been disabled, ignoring request to add additional codec for track",Object.assign(Object.assign({},this.logContext),we(e)));return}const c=e.addSimulcastTrack(t,a);if(!c)return;const u=new Qh({cid:c.mediaStreamTrack.id,type:N.kindToProto(e.kind),muted:e.isMuted,source:N.sourceToProto(e.source),sid:e.sid,simulcastCodecs:[{codec:s.videoCodec,cid:c.mediaStreamTrack.id}]});if(u.layers=GS(u.width,u.height,a),!this.engine||this.engine.isClosed)throw new lt("cannot publish track when not connected");const l=()=>T(this,void 0,void 0,function*(){yield this.engine.createSimulcastSender(e,c,s,a),yield this.engine.negotiate()}),h=(yield Promise.all([this.engine.addTrack(u),l()]))[0];this.log.debug("published ".concat(t," for track ").concat(e.sid),Object.assign(Object.assign({},this.logContext),{encodings:a,trackInfo:h}))})}unpublishTrack(e,t){return T(this,void 0,void 0,function*(){var i,r;if(uo(e)){const u=this.pendingPublishPromises.get(e);u&&(this.log.info("awaiting publish promise before attempting to unpublish",Object.assign(Object.assign({},this.logContext),we(e))),yield u)}const o=this.getPublicationForTrack(e),s=o?we(o):void 0;if(this.log.debug("unpublishing track",Object.assign(Object.assign({},this.logContext),s)),!o||!o.track){this.log.warn("track was not unpublished because no publication was found",Object.assign(Object.assign({},this.logContext),s));return}e=o.track,e.off(B.Muted,this.onTrackMuted),e.off(B.Unmuted,this.onTrackUnmuted),e.off(B.Ended,this.handleTrackEnded),e.off(B.UpstreamPaused,this.onTrackUpstreamPaused),e.off(B.UpstreamResumed,this.onTrackUpstreamResumed),e.off(B.AudioTrackFeatureUpdate,this.onTrackFeatureUpdate),t===void 0&&(t=(r=(i=this.roomOptions)===null||i===void 0?void 0:i.stopLocalTrackOnUnpublish)!==null&&r!==void 0?r:!0),t?e.stop():e.stopMonitor();let a=!1;const c=e.sender;if(e.sender=void 0,this.engine.pcManager&&this.engine.pcManager.currentState<Xe.FAILED&&c)try{for(const u of this.engine.pcManager.publisher.getTransceivers())u.sender===c&&(u.direction="inactive",a=!0);if(this.engine.removeTrack(c)&&(a=!0),Ai(e)){for(const[,u]of e.simulcastCodecs)u.sender&&(this.engine.removeTrack(u.sender)&&(a=!0),u.sender=void 0);e.simulcastCodecs.clear()}}catch(u){this.log.warn("failed to unpublish track",Object.assign(Object.assign(Object.assign({},this.logContext),s),{error:u}))}switch(this.trackPublications.delete(o.trackSid),o.kind){case N.Kind.Audio:this.audioTrackPublications.delete(o.trackSid);break;case N.Kind.Video:this.videoTrackPublications.delete(o.trackSid);break}return this.emit(q.LocalTrackUnpublished,o),o.setTrack(void 0),a&&(yield this.engine.negotiate()),o})}unpublishTracks(e){return T(this,void 0,void 0,function*(){return(yield Promise.all(e.map(i=>this.unpublishTrack(i)))).filter(i=>!!i)})}republishAllTracks(e){return T(this,arguments,void 0,function(t){var i=this;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return function*(){i.republishPromise&&(yield i.republishPromise),i.republishPromise=new Promise((o,s)=>T(i,void 0,void 0,function*(){try{const a=[];this.trackPublications.forEach(c=>{c.track&&(t&&(c.options=Object.assign(Object.assign({},c.options),t)),a.push(c))}),yield Promise.all(a.map(c=>T(this,void 0,void 0,function*(){const u=c.track;yield this.unpublishTrack(u,!1),r&&!u.isMuted&&u.source!==N.Source.ScreenShare&&u.source!==N.Source.ScreenShareAudio&&(sr(u)||Ai(u))&&!u.isUserProvided&&(this.log.debug("restarting existing track",Object.assign(Object.assign({},this.logContext),{track:c.trackSid})),yield u.restartTrack()),yield this.publishOrRepublishTrack(u,c.options,!0)}))),o()}catch(a){s(a)}finally{this.republishPromise=void 0}})),yield i.republishPromise}()})}publishData(e){return T(this,arguments,void 0,function(t){var i=this;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return function*(){const o=r.reliable?ge.RELIABLE:ge.LOSSY,s=r.destinationIdentities,a=r.topic,c=new zt({kind:o,value:{case:"user",value:new Y_({participantIdentity:i.identity,payload:t,destinationIdentities:s,topic:a})}});yield i.engine.sendDataPacket(c,o)}()})}publishDtmf(e,t){return T(this,void 0,void 0,function*(){const i=new zt({kind:ge.RELIABLE,value:{case:"sipDtmf",value:new X_({code:e,digit:t})}});yield this.engine.sendDataPacket(i,ge.RELIABLE)})}sendChatMessage(e,t){return T(this,void 0,void 0,function*(){const i={id:crypto.randomUUID(),message:e,timestamp:Date.now(),attachedFiles:t==null?void 0:t.attachments},r=new zt({value:{case:"chatMessage",value:new $h(Object.assign(Object.assign({},i),{timestamp:We.parse(i.timestamp)}))}});return yield this.engine.sendDataPacket(r,ge.RELIABLE),this.emit(q.ChatMessage,i),i})}editChatMessage(e,t){return T(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},t),{message:e,editTimestamp:Date.now()}),r=new zt({value:{case:"chatMessage",value:new $h(Object.assign(Object.assign({},i),{timestamp:We.parse(i.timestamp),editTimestamp:We.parse(i.editTimestamp)}))}});return yield this.engine.sendDataPacket(r,ge.RELIABLE),this.emit(q.ChatMessage,i),i})}sendText(e,t){return T(this,void 0,void 0,function*(){var i;const r=crypto.randomUUID(),s=new TextEncoder().encode(e).byteLength,a=(i=t==null?void 0:t.attachments)===null||i===void 0?void 0:i.map(()=>crypto.randomUUID()),c=new Array(a?a.length+1:1).fill(0),u=(d,h)=>{var p;c[h]=d;const m=c.reduce((f,g)=>f+g,0);(p=t==null?void 0:t.onProgress)===null||p===void 0||p.call(t,m)},l=yield this.streamText({streamId:r,totalSize:s,destinationIdentities:t==null?void 0:t.destinationIdentities,topic:t==null?void 0:t.topic,attachedStreamIds:a,attributes:t==null?void 0:t.attributes});return yield l.write(e),u(1,0),yield l.close(),t!=null&&t.attachments&&a&&(yield Promise.all(t.attachments.map((d,h)=>T(this,void 0,void 0,function*(){return this._sendFile(a[h],d,{topic:t.topic,mimeType:d.type,onProgress:p=>{u(p,h+1)}})})))),l.info})}streamText(e){return T(this,void 0,void 0,function*(){var t,i;const r=(t=e==null?void 0:e.streamId)!==null&&t!==void 0?t:crypto.randomUUID(),o={id:r,mimeType:"text/plain",timestamp:Date.now(),topic:(i=e==null?void 0:e.topic)!==null&&i!==void 0?i:"",size:e==null?void 0:e.totalSize,attributes:e==null?void 0:e.attributes},s=new Kh({streamId:r,mimeType:o.mimeType,topic:o.topic,timestamp:or(o.timestamp),totalLength:or(e==null?void 0:e.totalSize),attributes:o.attributes,contentHeader:{case:"textHeader",value:new ak({version:e==null?void 0:e.version,attachedStreamIds:e==null?void 0:e.attachedStreamIds,replyToStreamId:e==null?void 0:e.replyToStreamId,operationType:(e==null?void 0:e.type)==="update"?Hh.UPDATE:Hh.CREATE})}}),a=e==null?void 0:e.destinationIdentities,c=new zt({destinationIdentities:a,value:{case:"streamHeader",value:s}});yield this.engine.sendDataPacket(c,ge.RELIABLE);let u=0;const l=this,d=new WritableStream({write(m){return T(this,void 0,void 0,function*(){for(const f of G3(m,ZS)){yield l.engine.waitForBufferStatusLow(ge.RELIABLE);const g=new Yh({content:f,streamId:r,chunkIndex:or(u)}),y=new zt({destinationIdentities:a,value:{case:"streamChunk",value:g}});yield l.engine.sendDataPacket(y,ge.RELIABLE),u+=1}})},close(){return T(this,void 0,void 0,function*(){const m=new Xh({streamId:r}),f=new zt({destinationIdentities:a,value:{case:"streamTrailer",value:m}});yield l.engine.sendDataPacket(f,ge.RELIABLE)})},abort(m){console.log("Sink error:",m)}});let h=()=>T(this,void 0,void 0,function*(){yield p.close()});l.engine.once(j.Closing,h);const p=new DU(d,o,()=>this.engine.off(j.Closing,h));return p})}sendFile(e,t){return T(this,void 0,void 0,function*(){const i=crypto.randomUUID();return yield this._sendFile(i,e,t),{id:i}})}_sendFile(e,t,i){return T(this,void 0,void 0,function*(){var r;const o=yield this.streamBytes({streamId:e,totalSize:t.size,name:t.name,mimeType:(r=i==null?void 0:i.mimeType)!==null&&r!==void 0?r:t.type,topic:i==null?void 0:i.topic,destinationIdentities:i==null?void 0:i.destinationIdentities}),s=t.stream().getReader();for(;;){const{done:a,value:c}=yield s.read();if(a)break;yield o.write(c)}return yield o.close(),o.info})}streamBytes(e){return T(this,void 0,void 0,function*(){var t,i,r,o,s;const a=(t=e==null?void 0:e.streamId)!==null&&t!==void 0?t:crypto.randomUUID(),c=e==null?void 0:e.destinationIdentities,u={id:a,mimeType:(i=e==null?void 0:e.mimeType)!==null&&i!==void 0?i:"application/octet-stream",topic:(r=e==null?void 0:e.topic)!==null&&r!==void 0?r:"",timestamp:Date.now(),attributes:e==null?void 0:e.attributes,size:e==null?void 0:e.totalSize,name:(o=e==null?void 0:e.name)!==null&&o!==void 0?o:"unknown"},l=new Kh({totalLength:or((s=u.size)!==null&&s!==void 0?s:0),mimeType:u.mimeType,streamId:a,topic:u.topic,timestamp:or(Date.now()),attributes:u.attributes,contentHeader:{case:"byteHeader",value:new ck({name:u.name})}}),d=new zt({destinationIdentities:c,value:{case:"streamHeader",value:l}});yield this.engine.sendDataPacket(d,ge.RELIABLE);let h=0;const p=new jt,m=this.engine,f=this.log,g=new WritableStream({write(b){return T(this,void 0,void 0,function*(){const S=yield p.lock();let w=0;try{for(;w<b.byteLength;){const k=b.slice(w,w+ZS);yield m.waitForBufferStatusLow(ge.RELIABLE);const C=new zt({destinationIdentities:c,value:{case:"streamChunk",value:new Yh({content:k,streamId:a,chunkIndex:or(h)})}});yield m.sendDataPacket(C,ge.RELIABLE),h+=1,w+=k.byteLength}}finally{S()}})},close(){return T(this,void 0,void 0,function*(){const b=new Xh({streamId:a}),S=new zt({destinationIdentities:c,value:{case:"streamTrailer",value:b}});yield m.sendDataPacket(S,ge.RELIABLE)})},abort(b){f.error("Sink error:",b)}});return new LU(g,u)})}performRpc(e){return T(this,arguments,void 0,function(t){var i=this;let{destinationIdentity:r,method:o,payload:s,responseTimeout:a=1e4}=t;return function*(){return new Promise((u,l)=>T(i,void 0,void 0,function*(){var d,h,p,m;if(Gp(s)>FS){l(Je.builtIn("REQUEST_PAYLOAD_TOO_LARGE"));return}if(!((h=(d=this.engine.latestJoinResponse)===null||d===void 0?void 0:d.serverInfo)===null||h===void 0)&&h.version&&rr((m=(p=this.engine.latestJoinResponse)===null||p===void 0?void 0:p.serverInfo)===null||m===void 0?void 0:m.version,"1.8.0")<0){l(Je.builtIn("UNSUPPORTED_SERVER"));return}const f=crypto.randomUUID();yield this.publishRpcRequest(r,f,o,s,a-2e3);const g=setTimeout(()=>{this.pendingAcks.delete(f),l(Je.builtIn("CONNECTION_TIMEOUT")),this.pendingResponses.delete(f),clearTimeout(y)},2e3);this.pendingAcks.set(f,{resolve:()=>{clearTimeout(g)},participantIdentity:r});const y=setTimeout(()=>{this.pendingResponses.delete(f),l(Je.builtIn("RESPONSE_TIMEOUT"))},a);this.pendingResponses.set(f,{resolve:(b,S)=>{clearTimeout(y),this.pendingAcks.has(f)&&(console.warn("RPC response received before ack",f),this.pendingAcks.delete(f),clearTimeout(g)),S?l(S):u(b??"")},participantIdentity:r})}))}()})}registerRpcMethod(e,t){this.rpcHandlers.has(e)&&this.log.warn("you're overriding the RPC handler for method ".concat(e,", in the future this will throw an error")),this.rpcHandlers.set(e,t)}unregisterRpcMethod(e){this.rpcHandlers.delete(e)}setTrackSubscriptionPermissions(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];this.participantTrackPermissions=t,this.allParticipantsAllowedToSubscribe=e,this.engine.client.isDisconnected||this.updateTrackSubscriptionPermissions()}handleIncomingRpcAck(e){const t=this.pendingAcks.get(e);t?(t.resolve(),this.pendingAcks.delete(e)):console.error("Ack received for unexpected RPC request",e)}handleIncomingRpcResponse(e,t,i){const r=this.pendingResponses.get(e);r?(r.resolve(t,i),this.pendingResponses.delete(e)):console.error("Response received for unexpected RPC request",e)}publishRpcRequest(e,t,i,r,o){return T(this,void 0,void 0,function*(){const s=new zt({destinationIdentities:[e],kind:ge.RELIABLE,value:{case:"rpcRequest",value:new J_({id:t,method:i,payload:r,responseTimeoutMs:o,version:1})}});yield this.engine.sendDataPacket(s,ge.RELIABLE)})}handleParticipantDisconnected(e){for(const[t,{participantIdentity:i}]of this.pendingAcks)i===e&&this.pendingAcks.delete(t);for(const[t,{participantIdentity:i,resolve:r}]of this.pendingResponses)i===e&&(r(null,Je.builtIn("RECIPIENT_DISCONNECTED")),this.pendingResponses.delete(t))}setEnabledPublishCodecs(e){this.enabledPublishVideoCodecs=e.filter(t=>t.mime.split("/")[0].toLowerCase()==="video")}updateInfo(e){return super.updateInfo(e)?(e.tracks.forEach(t=>{var i,r;const o=this.trackPublications.get(t.sid);if(o){const s=o.isMuted||((r=(i=o.track)===null||i===void 0?void 0:i.isUpstreamPaused)!==null&&r!==void 0?r:!1);s!==t.muted&&(this.log.debug("updating server mute state after reconcile",Object.assign(Object.assign(Object.assign({},this.logContext),we(o)),{mutedOnServer:s})),this.engine.client.sendMuteTrack(t.sid,s))}}),!0):!1}getPublicationForTrack(e){let t;return this.trackPublications.forEach(i=>{const r=i.track;r&&(e instanceof MediaStreamTrack?(sr(r)||Ai(r))&&r.mediaStreamTrack===e&&(t=i):e===r&&(t=i))}),t}waitForPendingPublicationOfSource(e){return T(this,void 0,void 0,function*(){const i=Date.now();for(;Date.now()<i+1e4;){const r=Array.from(this.pendingPublishPromises.entries()).find(o=>{let[s]=o;return s.source===e});if(r)return r[1];yield qt(20)}})}}class GU extends Jn{constructor(e,t,i,r){super(e,t.sid,t.name,r),this.track=void 0,this.allowed=!0,this.disabled=!1,this.currentVideoQuality=en.HIGH,this.handleEnded=o=>{this.setTrack(void 0),this.emit(B.Ended,o)},this.handleVisibilityChange=o=>{this.log.debug("adaptivestream video visibility ".concat(this.trackSid,", visible=").concat(o),this.logContext),this.disabled=!o,this.emitTrackUpdate()},this.handleVideoDimensionsChange=o=>{this.log.debug("adaptivestream video dimensions ".concat(o.width,"x").concat(o.height),this.logContext),this.videoDimensions=o,this.emitTrackUpdate()},this.subscribed=i,this.updateInfo(t)}setSubscribed(e){const t=this.subscriptionStatus,i=this.permissionStatus;this.subscribed=e,e&&(this.allowed=!0);const r=new nu({trackSids:[this.trackSid],subscribe:this.subscribed,participantTracks:[new tk({participantSid:"",trackSids:[this.trackSid]})]});this.emit(B.UpdateSubscription,r),this.emitSubscriptionUpdateIfChanged(t),this.emitPermissionUpdateIfChanged(i)}get subscriptionStatus(){return this.subscribed===!1?Jn.SubscriptionStatus.Unsubscribed:super.isSubscribed?Jn.SubscriptionStatus.Subscribed:Jn.SubscriptionStatus.Desired}get permissionStatus(){return this.allowed?Jn.PermissionStatus.Allowed:Jn.PermissionStatus.NotAllowed}get isSubscribed(){return this.subscribed===!1?!1:super.isSubscribed}get isDesired(){return this.subscribed!==!1}get isEnabled(){return!this.disabled}get isLocal(){return!1}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,i;this.isManualOperationAllowed()&&(((t=this.videoDimensions)===null||t===void 0?void 0:t.width)===e.width&&((i=this.videoDimensions)===null||i===void 0?void 0:i.height)===e.height||(Mp(this.track)&&(this.videoDimensions=e),this.currentVideoQuality=void 0,this.emitTrackUpdate()))}setVideoFPS(e){this.isManualOperationAllowed()&&Mp(this.track)&&this.fps!==e&&(this.fps=e,this.emitTrackUpdate())}get videoQuality(){return this.currentVideoQuality}setTrack(e){const t=this.subscriptionStatus,i=this.permissionStatus,r=this.track;r!==e&&(r&&(r.off(B.VideoDimensionsChanged,this.handleVideoDimensionsChange),r.off(B.VisibilityChanged,this.handleVisibilityChange),r.off(B.Ended,this.handleEnded),r.detach(),r.stopMonitor(),this.emit(B.Unsubscribed,r)),super.setTrack(e),e&&(e.sid=this.trackSid,e.on(B.VideoDimensionsChanged,this.handleVideoDimensionsChange),e.on(B.VisibilityChanged,this.handleVisibilityChange),e.on(B.Ended,this.handleEnded),this.emit(B.Subscribed,e)),this.emitPermissionUpdateIfChanged(i),this.emitSubscriptionUpdateIfChanged(t))}setAllowed(e){const t=this.subscriptionStatus,i=this.permissionStatus;this.allowed=e,this.emitPermissionUpdateIfChanged(i),this.emitSubscriptionUpdateIfChanged(t)}setSubscriptionError(e){this.emit(B.SubscriptionFailed,e)}updateInfo(e){super.updateInfo(e);const t=this.metadataMuted;this.metadataMuted=e.muted,this.track?this.track.setMuted(e.muted):t!==e.muted&&this.emit(e.muted?B.Muted:B.Unmuted)}emitSubscriptionUpdateIfChanged(e){const t=this.subscriptionStatus;e!==t&&this.emit(B.SubscriptionStatusChanged,t,e)}emitPermissionUpdateIfChanged(e){this.permissionStatus!==e&&this.emit(B.SubscriptionPermissionChanged,this.permissionStatus,e)}isManualOperationAllowed(){return this.kind===N.Kind.Video&&this.isAdaptiveStream?(this.log.warn("adaptive stream is enabled, cannot change video track settings",this.logContext),!1):this.isDesired?!0:(this.log.warn("cannot update track settings when not subscribed",this.logContext),!1)}get isAdaptiveStream(){return Mp(this.track)&&this.track.isAdaptiveStream}emitTrackUpdate(){const e=new lk({trackSids:[this.trackSid],disabled:this.disabled,fps:this.fps});this.videoDimensions?(e.width=Math.ceil(this.videoDimensions.width),e.height=Math.ceil(this.videoDimensions.height)):this.currentVideoQuality!==void 0?e.quality=this.currentVideoQuality:e.quality=en.HIGH,this.emit(B.UpdateSettings,e)}}class Cu extends JS{static fromParticipantInfo(e,t,i){return new Cu(e,t.sid,t.identity,t.name,t.metadata,t.attributes,i,t.kind)}get logContext(){return Object.assign(Object.assign({},super.logContext),{rpID:this.sid,remoteParticipant:this.identity})}constructor(e,t,i,r,o,s,a){let c=arguments.length>7&&arguments[7]!==void 0?arguments[7]:tu.STANDARD;super(t,i||"",r,o,s,a,c),this.signalClient=e,this.trackPublications=new Map,this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.volumeMap=new Map}addTrackPublication(e){super.addTrackPublication(e),e.on(B.UpdateSettings,t=>{this.log.debug("send update settings",Object.assign(Object.assign({},this.logContext),we(e))),this.signalClient.sendUpdateTrackSettings(t)}),e.on(B.UpdateSubscription,t=>{t.participantTracks.forEach(i=>{i.participantSid=this.sid}),this.signalClient.sendUpdateSubscription(t)}),e.on(B.SubscriptionPermissionChanged,t=>{this.emit(q.TrackSubscriptionPermissionChanged,e,t)}),e.on(B.SubscriptionStatusChanged,t=>{this.emit(q.TrackSubscriptionStatusChanged,e,t)}),e.on(B.Subscribed,t=>{this.emit(q.TrackSubscribed,t,e)}),e.on(B.Unsubscribed,t=>{this.emit(q.TrackUnsubscribed,t,e)}),e.on(B.SubscriptionFailed,t=>{this.emit(q.TrackSubscriptionFailed,e.trackSid,t)})}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&&arguments[1]!==void 0?arguments[1]:N.Source.Microphone;this.volumeMap.set(t,e);const i=this.getTrackPublication(t);i&&i.track&&i.track.setVolume(e)}getVolume(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:N.Source.Microphone;const t=this.getTrackPublication(e);return t&&t.track?t.track.getVolume():this.volumeMap.get(e)}addSubscribedMediaTrack(e,t,i,r,o,s){let a=this.getTrackPublicationBySid(t);if(a||t.startsWith("TR")||this.trackPublications.forEach(l=>{!a&&e.kind===l.kind.toString()&&(a=l)}),!a){if(s===0){this.log.error("could not find published track",Object.assign(Object.assign({},this.logContext),{trackSid:t})),this.emit(q.TrackSubscriptionFailed,t);return}s===void 0&&(s=20),setTimeout(()=>{this.addSubscribedMediaTrack(e,t,i,r,o,s-1)},150);return}if(e.readyState==="ended"){this.log.error("unable to subscribe because MediaStreamTrack is ended. Do not call MediaStreamTrack.stop()",Object.assign(Object.assign({},this.logContext),we(a))),this.emit(q.TrackSubscriptionFailed,t);return}const c=e.kind==="video";let u;return c?u=new FU(e,t,r,o):u=new UU(e,t,r,this.audioContext,this.audioOutput),u.source=a.source,u.isMuted=a.isMuted,u.setMediaStream(i),u.start(),a.setTrack(u),this.volumeMap.has(a.source)&&Ap(u)&&Xn(u)&&u.setVolume(this.volumeMap.get(a.source)),a}get hasMetadata(){return!!this.participantInfo}getTrackPublicationBySid(e){return this.trackPublications.get(e)}updateInfo(e){if(!super.updateInfo(e))return!1;const t=new Map,i=new Map;return e.tracks.forEach(r=>{var o,s;let a=this.getTrackPublicationBySid(r.sid);if(a)a.updateInfo(r);else{const c=N.kindFromProto(r.type);if(!c)return;a=new GU(c,r,(o=this.signalClient.connectOptions)===null||o===void 0?void 0:o.autoSubscribe,{loggerContextCb:()=>this.logContext,loggerName:(s=this.loggerOptions)===null||s===void 0?void 0:s.loggerName}),a.updateInfo(r),i.set(r.sid,a);const u=Array.from(this.trackPublications.values()).find(l=>l.source===(a==null?void 0:a.source));u&&a.source!==N.Source.Unknown&&this.log.debug("received a second track publication for ".concat(this.identity," with the same source: ").concat(a.source),Object.assign(Object.assign({},this.logContext),{oldTrack:we(u),newTrack:we(a)})),this.addTrackPublication(a)}t.set(r.sid,a)}),this.trackPublications.forEach(r=>{t.has(r.trackSid)||(this.log.trace("detected removed track on remote participant, unpublishing",Object.assign(Object.assign({},this.logContext),we(r))),this.unpublishTrack(r.trackSid,!0))}),i.forEach(r=>{this.emit(q.TrackPublished,r)}),!0}unpublishTrack(e,t){const i=this.trackPublications.get(e);if(!i)return;const{track:r}=i;switch(r&&(r.stop(),i.setTrack(void 0)),this.trackPublications.delete(e),i.kind){case N.Kind.Audio:this.audioTrackPublications.delete(e);break;case N.Kind.Video:this.videoTrackPublications.delete(e);break}t&&this.emit(q.TrackUnpublished,i)}setAudioOutput(e){return T(this,void 0,void 0,function*(){this.audioOutput=e;const t=[];this.audioTrackPublications.forEach(i=>{var r;Xn(i.track)&&Ap(i.track)&&t.push(i.track.setSinkId((r=e.deviceId)!==null&&r!==void 0?r:"default"))}),yield Promise.all(t)})}emit(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return this.log.trace("participant event",Object.assign(Object.assign({},this.logContext),{event:e,args:i})),super.emit(e,...i)}}var ve;(function(n){n.Disconnected="disconnected",n.Connecting="connecting",n.Connected="connected",n.Reconnecting="reconnecting",n.SignalReconnecting="signalReconnecting"})(ve||(ve={}));const $U=4*1e3;class fo extends Mn.EventEmitter{constructor(e){var t,i,r,o;if(super(),t=this,this.state=ve.Disconnected,this.activeSpeakers=[],this.isE2EEEnabled=!1,this.audioEnabled=!0,this.isVideoPlaybackBlocked=!1,this.log=le,this.bufferedEvents=[],this.isResuming=!1,this.byteStreamControllers=new Map,this.textStreamControllers=new Map,this.byteStreamHandlers=new Map,this.textStreamHandlers=new Map,this.rpcHandlers=new Map,this.connect=(s,a,c)=>T(this,void 0,void 0,function*(){var u;if(!M3())throw Nn()?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 l=yield this.disconnectLock.lock();if(this.state===ve.Connected)return this.log.info("already connected to room ".concat(this.name),this.logContext),l(),Promise.resolve();if(this.connectFuture)return l(),this.connectFuture.promise;this.setAndEmitConnectionState(ve.Connecting),((u=this.regionUrlProvider)===null||u===void 0?void 0:u.getServerUrl().toString())!==s&&(this.regionUrl=void 0,this.regionUrlProvider=void 0),xp(new URL(s))&&(this.regionUrlProvider===void 0?this.regionUrlProvider=new Jp(s,a):this.regionUrlProvider.updateToken(a),this.regionUrlProvider.fetchRegionSettings().then(p=>{var m;(m=this.regionUrlProvider)===null||m===void 0||m.setServerReportedRegions(p)}).catch(p=>{this.log.warn("could not fetch region settings",Object.assign(Object.assign({},this.logContext),{error:p}))}));const d=(p,m,f)=>T(this,void 0,void 0,function*(){var g,y;this.abortController&&this.abortController.abort();const b=new AbortController;this.abortController=b,l==null||l();try{yield this.attemptConnection(f??s,a,c,b),this.abortController=void 0,p()}catch(S){if(this.regionUrlProvider&&S instanceof Ae&&S.reason!==pe.Cancelled&&S.reason!==pe.NotAllowed){let w=null;try{w=yield this.regionUrlProvider.getNextBestRegionUrl((g=this.abortController)===null||g===void 0?void 0:g.signal)}catch(k){if(k instanceof Ae&&(k.status===401||k.reason===pe.Cancelled)){this.handleDisconnect(this.options.stopLocalTrackOnUnpublish),m(k);return}}w&&!(!((y=this.abortController)===null||y===void 0)&&y.signal.aborted)?(this.log.info("Initial connection failed with ConnectionError: ".concat(S.message,". Retrying with another region: ").concat(w),this.logContext),this.recreateEngine(),yield d(p,m,w)):(this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,kS(S)),m(S))}else{let w=ln.UNKNOWN_REASON;S instanceof Ae&&(w=kS(S)),this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,w),m(S)}}}),h=this.regionUrl;return this.regionUrl=void 0,this.connectFuture=new Pp((p,m)=>{d(p,m,h)},()=>{this.clearConnectionFutures()}),this.connectFuture.promise}),this.connectSignal=(s,a,c,u,l,d)=>T(this,void 0,void 0,function*(){var h,p,m;const f=yield c.join(s,a,{autoSubscribe:u.autoSubscribe,adaptiveStream:typeof l.adaptiveStream=="object"?!0:l.adaptiveStream,maxRetries:u.maxRetries,e2eeEnabled:!!this.e2eeManager,websocketTimeout:u.websocketTimeout},d.signal);let g=f.serverInfo;if(g||(g={version:f.serverVersion,region:f.serverRegion}),this.serverInfo=g,this.log.debug("connected to Livekit Server ".concat(Object.entries(g).map(y=>{let[b,S]=y;return"".concat(b,": ").concat(S)}).join(", ")),{room:(h=f.room)===null||h===void 0?void 0:h.name,roomSid:(p=f.room)===null||p===void 0?void 0:p.sid,identity:(m=f.participant)===null||m===void 0?void 0:m.identity}),!g.version)throw new y3("unknown server version");return g.version==="0.15.1"&&this.options.dynacast&&(this.log.debug("disabling dynacast due to server version",this.logContext),l.dynacast=!1),f}),this.applyJoinResponse=s=>{const a=s.participant;if(this.localParticipant.sid=a.sid,this.localParticipant.identity=a.identity,this.localParticipant.setEnabledPublishCodecs(s.enabledPublishCodecs),this.options.e2ee&&this.e2eeManager)try{this.e2eeManager.setSifTrailer(s.sifTrailer)}catch(c){this.log.error(c instanceof Error?c.message:"Could not set SifTrailer",Object.assign(Object.assign({},this.logContext),{error:c}))}this.handleParticipantUpdates([a,...s.otherParticipants]),s.room&&this.handleRoomUpdate(s.room)},this.attemptConnection=(s,a,c,u)=>T(this,void 0,void 0,function*(){var l,d;this.state===ve.Reconnecting||this.isResuming||!((l=this.engine)===null||l===void 0)&&l.pendingReconnect?(this.log.info("Reconnection attempt replaced by new connection attempt",this.logContext),this.recreateEngine()):this.maybeCreateEngine(),!((d=this.regionUrlProvider)===null||d===void 0)&&d.isCloud()&&this.engine.setRegionUrlProvider(this.regionUrlProvider),this.acquireAudioContext(),this.connOptions=Object.assign(Object.assign({},Wp),c),this.connOptions.rtcConfig&&(this.engine.rtcConfig=this.connOptions.rtcConfig),this.connOptions.peerConnectionTimeout&&(this.engine.peerConnectionTimeout=this.connOptions.peerConnectionTimeout);try{const h=yield this.connectSignal(s,a,this.engine,this.connOptions,this.options,u);this.applyJoinResponse(h),this.setupLocalParticipantEvents(),this.emit(U.SignalConnected)}catch(h){yield this.engine.close(),this.recreateEngine();const p=new Ae("could not establish signal connection",pe.ServerUnreachable);throw h instanceof Error&&(p.message="".concat(p.message,": ").concat(h.message)),h instanceof Ae&&(p.reason=h.reason,p.status=h.status),this.log.debug("error trying to establish signal connection",Object.assign(Object.assign({},this.logContext),{error:h})),p}if(u.signal.aborted)throw yield this.engine.close(),this.recreateEngine(),new Ae("Connection attempt aborted",pe.Cancelled);try{yield this.engine.waitForPCInitialConnection(this.connOptions.peerConnectionTimeout,u)}catch(h){throw yield this.engine.close(),this.recreateEngine(),h}Wt()&&this.options.disconnectOnPageLeave&&(window.addEventListener("pagehide",this.onPageLeave),window.addEventListener("beforeunload",this.onPageLeave)),Wt()&&document.addEventListener("freeze",this.onPageLeave),this.setAndEmitConnectionState(ve.Connected),this.emit(U.Connected),this.registerConnectionReconcile()}),this.disconnect=function(){for(var s=arguments.length,a=new Array(s),c=0;c<s;c++)a[c]=arguments[c];return T(t,[...a],void 0,function(){var u=this;let l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return function*(){var d,h,p,m;const f=yield u.disconnectLock.lock();try{if(u.state===ve.Disconnected){u.log.debug("already disconnected",u.logContext);return}u.log.info("disconnect from room",Object.assign({},u.logContext)),(u.state===ve.Connecting||u.state===ve.Reconnecting||u.isResuming)&&(u.log.warn("abort connection attempt",u.logContext),(d=u.abortController)===null||d===void 0||d.abort(),(p=(h=u.connectFuture)===null||h===void 0?void 0:h.reject)===null||p===void 0||p.call(h,new Ae("Client initiated disconnect",pe.Cancelled)),u.connectFuture=void 0),!((m=u.engine)===null||m===void 0)&&m.client.isDisconnected||(yield u.engine.client.sendLeave()),u.engine&&(yield u.engine.close()),u.handleDisconnect(l,ln.CLIENT_INITIATED),u.engine=void 0}finally{f()}}()})},this.onPageLeave=()=>T(this,void 0,void 0,function*(){this.log.info("Page leave detected, disconnecting",this.logContext),yield this.disconnect()}),this.startAudio=()=>T(this,void 0,void 0,function*(){const s=[],a=fn();if(a&&a.os==="iOS"){const c="livekit-dummy-audio-el";let u=document.getElementById(c);if(!u){u=document.createElement("audio"),u.id=c,u.autoplay=!0,u.hidden=!0;const l=Rp();l.enabled=!0;const d=new MediaStream([l]);u.srcObject=d,document.addEventListener("visibilitychange",()=>{u&&(u.srcObject=document.hidden?null:d,document.hidden||(this.log.debug("page visible again, triggering startAudio to resume playback and update playback status",this.logContext),this.startAudio()))}),document.body.append(u),this.once(U.Disconnected,()=>{u==null||u.remove(),u=null})}s.push(u)}this.remoteParticipants.forEach(c=>{c.audioTrackPublications.forEach(u=>{u.track&&u.track.attachedElements.forEach(l=>{s.push(l)})})});try{yield Promise.all([this.acquireAudioContext(),...s.map(c=>(c.muted=!1,c.play()))]),this.handleAudioPlaybackStarted()}catch(c){throw this.handleAudioPlaybackFailed(c),c}}),this.startVideo=()=>T(this,void 0,void 0,function*(){const s=[];for(const a of this.remoteParticipants.values())a.videoTrackPublications.forEach(c=>{var u;(u=c.track)===null||u===void 0||u.attachedElements.forEach(l=>{s.includes(l)||s.push(l)})});yield Promise.all(s.map(a=>a.play())).then(()=>{this.handleVideoPlaybackStarted()}).catch(a=>{a.name==="NotAllowedError"?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 s of this.remoteParticipants.values())this.handleParticipantDisconnected(s.identity,s);this.setAndEmitConnectionState(ve.Reconnecting)&&this.emit(U.Reconnecting)},this.handleSignalRestarted=s=>T(this,void 0,void 0,function*(){this.log.debug("signal reconnected to server, region ".concat(s.serverRegion),Object.assign(Object.assign({},this.logContext),{region:s.serverRegion})),this.bufferedEvents=[],this.applyJoinResponse(s);try{yield this.localParticipant.republishAllTracks(void 0,!0)}catch(a){this.log.error("error trying to re-publish tracks after reconnection",Object.assign(Object.assign({},this.logContext),{error:a}))}try{yield this.engine.waitForRestarted(),this.log.debug("fully reconnected to server",Object.assign(Object.assign({},this.logContext),{region:s.serverRegion}))}catch{return}this.setAndEmitConnectionState(ve.Connected),this.emit(U.Reconnected),this.registerConnectionReconcile(),this.emitBufferedEvents()}),this.handleParticipantUpdates=s=>{s.forEach(a=>{var c;if(a.identity===this.localParticipant.identity){this.localParticipant.updateInfo(a);return}a.identity===""&&(a.identity=(c=this.sidToIdentity.get(a.sid))!==null&&c!==void 0?c:"");let u=this.remoteParticipants.get(a.identity);a.state===no.DISCONNECTED?this.handleParticipantDisconnected(a.identity,u):u=this.getOrCreateParticipant(a.identity,a)})},this.handleActiveSpeakersUpdate=s=>{const a=[],c={};s.forEach(u=>{if(c[u.sid]=!0,u.sid===this.localParticipant.sid)this.localParticipant.audioLevel=u.level,this.localParticipant.setIsSpeaking(!0),a.push(this.localParticipant);else{const l=this.getRemoteParticipantBySid(u.sid);l&&(l.audioLevel=u.level,l.setIsSpeaking(!0),a.push(l))}}),c[this.localParticipant.sid]||(this.localParticipant.audioLevel=0,this.localParticipant.setIsSpeaking(!1)),this.remoteParticipants.forEach(u=>{c[u.sid]||(u.audioLevel=0,u.setIsSpeaking(!1))}),this.activeSpeakers=a,this.emitWhenConnected(U.ActiveSpeakersChanged,a)},this.handleSpeakersChanged=s=>{const a=new Map;this.activeSpeakers.forEach(u=>{const l=this.remoteParticipants.get(u.identity);l&&l.sid!==u.sid||a.set(u.sid,u)}),s.forEach(u=>{let l=this.getRemoteParticipantBySid(u.sid);u.sid===this.localParticipant.sid&&(l=this.localParticipant),l&&(l.audioLevel=u.level,l.setIsSpeaking(u.active),u.active?a.set(u.sid,l):a.delete(u.sid))});const c=Array.from(a.values());c.sort((u,l)=>l.audioLevel-u.audioLevel),this.activeSpeakers=c,this.emitWhenConnected(U.ActiveSpeakersChanged,c)},this.handleStreamStateUpdate=s=>{s.streamStates.forEach(a=>{const c=this.getRemoteParticipantBySid(a.participantSid);if(!c)return;const u=c.getTrackPublicationBySid(a.trackSid);if(!u||!u.track)return;const l=N.streamStateFromProto(a.state);l!==u.track.streamState&&(u.track.streamState=l,c.emit(q.TrackStreamStateChanged,u,u.track.streamState),this.emitWhenConnected(U.TrackStreamStateChanged,u,u.track.streamState,c))})},this.handleSubscriptionPermissionUpdate=s=>{const a=this.getRemoteParticipantBySid(s.participantSid);if(!a)return;const c=a.getTrackPublicationBySid(s.trackSid);c&&c.setAllowed(s.allowed)},this.handleSubscriptionError=s=>{const a=Array.from(this.remoteParticipants.values()).find(u=>u.trackPublications.has(s.trackSid));if(!a)return;const c=a.getTrackPublicationBySid(s.trackSid);c&&c.setSubscriptionError(s.err)},this.handleDataPacket=s=>{const a=this.remoteParticipants.get(s.participantIdentity);if(s.value.case==="user")this.handleUserPacket(a,s.value.value,s.kind);else if(s.value.case==="transcription")this.handleTranscription(a,s.value.value);else if(s.value.case==="sipDtmf")this.handleSipDtmf(a,s.value.value);else if(s.value.case==="chatMessage")this.handleChatMessage(a,s.value.value);else if(s.value.case==="metrics")this.handleMetrics(s.value.value,a);else if(s.value.case==="streamHeader")this.handleStreamHeader(s.value.value,s.participantIdentity);else if(s.value.case==="streamChunk")this.handleStreamChunk(s.value.value);else if(s.value.case==="streamTrailer")this.handleStreamTrailer(s.value.value);else if(s.value.case==="rpcRequest"){const c=s.value.value;this.handleIncomingRpcRequest(s.participantIdentity,c.id,c.method,c.payload,c.responseTimeoutMs,c.version)}},this.handleUserPacket=(s,a,c)=>{this.emit(U.DataReceived,a.payload,s,c,a.topic),s==null||s.emit(q.DataReceived,a.payload,c)},this.handleSipDtmf=(s,a)=>{this.emit(U.SipDTMFReceived,a,s),s==null||s.emit(q.SipDTMFReceived,a)},this.bufferedSegments=new Map,this.handleTranscription=(s,a)=>{const c=a.transcribedParticipantIdentity===this.localParticipant.identity?this.localParticipant:this.getParticipantByIdentity(a.transcribedParticipantIdentity),u=c==null?void 0:c.trackPublications.get(a.trackId),l=V3(a,this.transcriptionReceivedTimes);u==null||u.emit(B.TranscriptionReceived,l),c==null||c.emit(q.TranscriptionReceived,l,u),this.emit(U.TranscriptionReceived,l,c,u)},this.handleChatMessage=(s,a)=>{const c=z3(a);this.emit(U.ChatMessage,c,s)},this.handleMetrics=(s,a)=>{this.emit(U.MetricsReceived,s,a)},this.handleAudioPlaybackStarted=()=>{this.canPlaybackAudio||(this.audioEnabled=!0,this.emit(U.AudioPlaybackStatusChanged,!0))},this.handleAudioPlaybackFailed=s=>{this.log.warn("could not playback audio",Object.assign(Object.assign({},this.logContext),{error:s})),this.canPlaybackAudio&&(this.audioEnabled=!1,this.emit(U.AudioPlaybackStatusChanged,!1))},this.handleVideoPlaybackStarted=()=>{this.isVideoPlaybackBlocked&&(this.isVideoPlaybackBlocked=!1,this.emit(U.VideoPlaybackStatusChanged,!0))},this.handleVideoPlaybackFailed=()=>{this.isVideoPlaybackBlocked||(this.isVideoPlaybackBlocked=!0,this.emit(U.VideoPlaybackStatusChanged,!1))},this.handleDeviceChange=()=>T(this,void 0,void 0,function*(){var s,a,c;const u=ft.getInstance().previousDevices,l=yield ft.getInstance().getDevices(void 0,!1),d=fn();if((d==null?void 0:d.name)==="Chrome"&&d.os!=="iOS")for(let p of l){const m=u.find(f=>f.deviceId===p.deviceId);m&&m.label!==""&&m.kind===p.kind&&m.label!==p.label&&this.getActiveDevice(p.kind)==="default"&&this.emit(U.ActiveDeviceChanged,p.kind,p.deviceId)}const h=["audiooutput","audioinput","videoinput"];for(let p of h){const m=$3(p),f=this.localParticipant.getTrackPublication(m);if(f&&(!((s=f.track)===null||s===void 0)&&s.isUserProvided))continue;const g=l.filter(b=>b.kind===p),y=this.getActiveDevice(p);if(y===((a=u.filter(b=>b.kind===p)[0])===null||a===void 0?void 0:a.deviceId)&&g.length>0&&((c=g[0])===null||c===void 0?void 0:c.deviceId)!==y){yield this.switchActiveDevice(p,g[0].deviceId);continue}p==="audioinput"&&!Pi()||p==="videoinput"||g.length>0&&!g.find(b=>b.deviceId===this.getActiveDevice(p))&&(yield this.switchActiveDevice(p,g[0].deviceId))}this.emit(U.MediaDevicesChanged)}),this.handleRoomUpdate=s=>{const a=this.roomInfo;this.roomInfo=s,a&&a.metadata!==s.metadata&&this.emitWhenConnected(U.RoomMetadataChanged,s.metadata),(a==null?void 0:a.activeRecording)!==s.activeRecording&&this.emitWhenConnected(U.RecordingStatusChanged,s.activeRecording)},this.handleConnectionQualityUpdate=s=>{s.updates.forEach(a=>{if(a.participantSid===this.localParticipant.sid){this.localParticipant.setConnectionQuality(a.quality);return}const c=this.getRemoteParticipantBySid(a.participantSid);c&&c.setConnectionQuality(a.quality)})},this.onLocalParticipantMetadataChanged=s=>{this.emit(U.ParticipantMetadataChanged,s,this.localParticipant)},this.onLocalParticipantNameChanged=s=>{this.emit(U.ParticipantNameChanged,s,this.localParticipant)},this.onLocalAttributesChanged=s=>{this.emit(U.ParticipantAttributesChanged,s,this.localParticipant)},this.onLocalTrackMuted=s=>{this.emit(U.TrackMuted,s,this.localParticipant)},this.onLocalTrackUnmuted=s=>{this.emit(U.TrackUnmuted,s,this.localParticipant)},this.onTrackProcessorUpdate=s=>{var a;(a=s==null?void 0:s.onPublish)===null||a===void 0||a.call(s,this)},this.onLocalTrackPublished=s=>T(this,void 0,void 0,function*(){var a,c,u,l,d,h;(a=s.track)===null||a===void 0||a.on(B.TrackProcessorUpdate,this.onTrackProcessorUpdate),(c=s.track)===null||c===void 0||c.on(B.Restarted,this.onLocalTrackRestarted),(d=(l=(u=s.track)===null||u===void 0?void 0:u.getProcessor())===null||l===void 0?void 0:l.onPublish)===null||d===void 0||d.call(l,this),this.emit(U.LocalTrackPublished,s,this.localParticipant),sr(s.track)&&(yield s.track.checkForSilence())&&this.emit(U.LocalAudioSilenceDetected,s);const p=yield(h=s.track)===null||h===void 0?void 0:h.getDeviceId(!1),m=TS(s.source);m&&p&&p!==this.localParticipant.activeDeviceMap.get(m)&&(this.localParticipant.activeDeviceMap.set(m,p),this.emit(U.ActiveDeviceChanged,m,p))}),this.onLocalTrackUnpublished=s=>{var a,c;(a=s.track)===null||a===void 0||a.off(B.TrackProcessorUpdate,this.onTrackProcessorUpdate),(c=s.track)===null||c===void 0||c.off(B.Restarted,this.onLocalTrackRestarted),this.emit(U.LocalTrackUnpublished,s,this.localParticipant)},this.onLocalTrackRestarted=s=>T(this,void 0,void 0,function*(){const a=yield s.getDeviceId(!1),c=TS(s.source);c&&a&&a!==this.localParticipant.activeDeviceMap.get(c)&&(this.log.debug("local track restarted, setting ".concat(c," ").concat(a," active"),this.logContext),this.localParticipant.activeDeviceMap.set(c,a),this.emit(U.ActiveDeviceChanged,c,a))}),this.onLocalConnectionQualityChanged=s=>{this.emit(U.ConnectionQualityChanged,s,this.localParticipant)},this.onMediaDevicesError=s=>{this.emit(U.MediaDevicesError,s)},this.onLocalParticipantPermissionsChanged=s=>{this.emit(U.ParticipantPermissionsChanged,s,this.localParticipant)},this.onLocalChatMessageSent=s=>{this.emit(U.ChatMessage,s,this.localParticipant)},this.setMaxListeners(100),this.remoteParticipants=new Map,this.sidToIdentity=new Map,this.options=Object.assign(Object.assign({},pU),e),this.log=Kn((i=this.options.loggerName)!==null&&i!==void 0?i:pn.Room),this.transcriptionReceivedTimes=new Map,this.options.audioCaptureDefaults=Object.assign(Object.assign({},LS),e==null?void 0:e.audioCaptureDefaults),this.options.videoCaptureDefaults=Object.assign(Object.assign({},US),e==null?void 0:e.videoCaptureDefaults),this.options.publishDefaults=Object.assign(Object.assign({},hU),e==null?void 0:e.publishDefaults),this.maybeCreateEngine(),this.disconnectLock=new jt,this.localParticipant=new WU("","",this.engine,this.options,this.rpcHandlers),this.options.videoCaptureDefaults.deviceId&&this.localParticipant.activeDeviceMap.set("videoinput",Oi(this.options.videoCaptureDefaults.deviceId)),this.options.audioCaptureDefaults.deviceId&&this.localParticipant.activeDeviceMap.set("audioinput",Oi(this.options.audioCaptureDefaults.deviceId)),!((r=this.options.audioOutput)===null||r===void 0)&&r.deviceId&&this.switchActiveDevice("audiooutput",Oi(this.options.audioOutput.deviceId)).catch(s=>this.log.warn("Could not set audio output: ".concat(s.message),this.logContext)),this.options.e2ee&&this.setupE2EE(),Wt()){const s=new AbortController;(o=navigator.mediaDevices)===null||o===void 0||o.addEventListener("devicechange",this.handleDeviceChange,{signal:s.signal}),fo.cleanupRegistry&&fo.cleanupRegistry.register(this,()=>{s.abort()})}}registerTextStreamHandler(e,t){if(this.textStreamHandlers.has(e))throw new TypeError('A text stream handler for topic "'.concat(e,'" has already been set.'));this.textStreamHandlers.set(e,t)}unregisterTextStreamHandler(e){this.textStreamHandlers.delete(e)}registerByteStreamHandler(e,t){if(this.byteStreamHandlers.has(e))throw new TypeError('A byte stream handler for topic "'.concat(e,'" has already been set.'));this.byteStreamHandlers.set(e,t)}unregisterByteStreamHandler(e){this.byteStreamHandlers.delete(e)}registerRpcMethod(e,t){if(this.rpcHandlers.has(e))throw Error("RPC handler already registered for method ".concat(e,", unregisterRpcMethod before trying to register again"));this.rpcHandlers.set(e,t)}unregisterRpcMethod(e){this.rpcHandlers.delete(e)}handleIncomingRpcRequest(e,t,i,r,o,s){return T(this,void 0,void 0,function*(){if(yield this.engine.publishRpcAck(e,t),s!==1){yield this.engine.publishRpcResponse(e,t,null,Je.builtIn("UNSUPPORTED_VERSION"));return}const a=this.rpcHandlers.get(i);if(!a){yield this.engine.publishRpcResponse(e,t,null,Je.builtIn("UNSUPPORTED_METHOD"));return}let c=null,u=null;try{const l=yield a({requestId:t,callerIdentity:e,payload:r,responseTimeout:o});Gp(l)>FS?(c=Je.builtIn("RESPONSE_PAYLOAD_TOO_LARGE"),console.warn("RPC Response payload too large for ".concat(i))):u=l}catch(l){l instanceof Je?c=l:(console.warn("Uncaught error returned by RPC handler for ".concat(i,". Returning APPLICATION_ERROR instead."),l),c=Je.builtIn("APPLICATION_ERROR"))}yield this.engine.publishRpcResponse(e,t,u,c)})}setE2EEEnabled(e){return T(this,void 0,void 0,function*(){if(this.e2eeManager)yield Promise.all([this.localParticipant.setE2EEEnabled(e)]),this.localParticipant.identity!==""&&this.e2eeManager.setParticipantCryptorEnabled(e,this.localParticipant.identity);else throw Error("e2ee not configured, please set e2ee settings within the room options")})}setupE2EE(){var e;this.options.e2ee&&("e2eeManager"in this.options.e2ee?this.e2eeManager=this.options.e2ee.e2eeManager:this.e2eeManager=new Z3(this.options.e2ee),this.e2eeManager.on(Ii.ParticipantEncryptionStatusChanged,(t,i)=>{W3(i)&&(this.isE2EEEnabled=t),this.emit(U.ParticipantEncryptionStatusChanged,t,i)}),this.e2eeManager.on(Ii.EncryptionError,t=>this.emit(U.EncryptionError,t)),(e=this.e2eeManager)===null||e===void 0||e.setup(this))}get logContext(){var e;return{room:this.name,roomID:(e=this.roomInfo)===null||e===void 0?void 0:e.sid,participant:this.localParticipant.identity,pID:this.localParticipant.sid}}get isRecording(){var e,t;return(t=(e=this.roomInfo)===null||e===void 0?void 0:e.activeRecording)!==null&&t!==void 0?t:!1}getSid(){return T(this,void 0,void 0,function*(){return this.state===ve.Disconnected?"":this.roomInfo&&this.roomInfo.sid!==""?this.roomInfo.sid:new Promise((e,t)=>{const i=r=>{r.sid!==""&&(this.engine.off(j.RoomUpdate,i),e(r.sid))};this.engine.on(j.RoomUpdate,i),this.once(U.Disconnected,()=>{this.engine.off(j.RoomUpdate,i),t("Room disconnected before room server id was available")})})})}get name(){var e,t;return(t=(e=this.roomInfo)===null||e===void 0?void 0:e.name)!==null&&t!==void 0?t:""}get metadata(){var e;return(e=this.roomInfo)===null||e===void 0?void 0:e.metadata}get numParticipants(){var e,t;return(t=(e=this.roomInfo)===null||e===void 0?void 0:e.numParticipants)!==null&&t!==void 0?t:0}get numPublishers(){var e,t;return(t=(e=this.roomInfo)===null||e===void 0?void 0:e.numPublishers)!==null&&t!==void 0?t:0}maybeCreateEngine(){this.engine&&!this.engine.isClosed||(this.engine=new RU(this.options),this.engine.on(j.ParticipantUpdate,this.handleParticipantUpdates).on(j.RoomUpdate,this.handleRoomUpdate).on(j.SpeakersChanged,this.handleSpeakersChanged).on(j.StreamStateChanged,this.handleStreamStateUpdate).on(j.ConnectionQualityUpdate,this.handleConnectionQualityUpdate).on(j.SubscriptionError,this.handleSubscriptionError).on(j.SubscriptionPermissionUpdate,this.handleSubscriptionPermissionUpdate).on(j.MediaTrackAdded,(e,t,i)=>{this.onTrackAdded(e,t,i)}).on(j.Disconnected,e=>{this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,e)}).on(j.ActiveSpeakersUpdate,this.handleActiveSpeakersUpdate).on(j.DataPacketReceived,this.handleDataPacket).on(j.Resuming,()=>{this.clearConnectionReconcile(),this.isResuming=!0,this.log.info("Resuming signal connection",this.logContext),this.setAndEmitConnectionState(ve.SignalReconnecting)&&this.emit(U.SignalReconnecting)}).on(j.Resumed,()=>{this.registerConnectionReconcile(),this.isResuming=!1,this.log.info("Resumed signal connection",this.logContext),this.updateSubscriptions(),this.emitBufferedEvents(),this.setAndEmitConnectionState(ve.Connected)&&this.emit(U.Reconnected)}).on(j.SignalResumed,()=>{this.bufferedEvents=[],(this.state===ve.Reconnecting||this.isResuming)&&this.sendSyncState()}).on(j.Restarting,this.handleRestarting).on(j.SignalRestarted,this.handleSignalRestarted).on(j.Offline,()=>{this.setAndEmitConnectionState(ve.Reconnecting)&&this.emit(U.Reconnecting)}).on(j.DCBufferStatusChanged,(e,t)=>{this.emit(U.DCBufferStatusChanged,e,t)}).on(j.LocalTrackSubscribed,e=>{const t=this.localParticipant.getTrackPublications().find(i=>{let{trackSid:r}=i;return r===e});if(!t){this.log.warn("could not find local track subscription for subscribed event",this.logContext);return}this.localParticipant.emit(q.LocalTrackSubscribed,t),this.emitWhenConnected(U.LocalTrackSubscribed,t,this.localParticipant)}).on(j.RoomMoved,e=>{this.log.debug("room moved",e),e.room&&this.handleRoomUpdate(e.room),this.remoteParticipants.forEach((t,i)=>{this.handleParticipantDisconnected(i,t)}),this.emit(U.Moved,e.room.name,e.token),e.participant?this.handleParticipantUpdates([e.participant,...e.otherParticipants]):this.handleParticipantUpdates(e.otherParticipants)}),this.localParticipant&&this.localParticipant.setupEngine(this.engine),this.e2eeManager&&this.e2eeManager.setupEngine(this.engine))}static getLocalDevices(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return ft.getInstance().getDevices(e,t)}prepareConnection(e,t){return T(this,void 0,void 0,function*(){if(this.state===ve.Disconnected){this.log.debug("prepareConnection to ".concat(e),this.logContext);try{if(xp(new URL(e))&&t){this.regionUrlProvider=new Jp(e,t);const i=yield this.regionUrlProvider.getNextBestRegionUrl();i&&this.state===ve.Disconnected&&(this.regionUrl=i,yield fetch(Op(i),{method:"HEAD"}),this.log.debug("prepared connection to ".concat(i),this.logContext))}else yield fetch(Op(e),{method:"HEAD"})}catch(i){this.log.warn("could not prepare connection",Object.assign(Object.assign({},this.logContext),{error:i}))}}})}getParticipantByIdentity(e){return this.localParticipant.identity===e?this.localParticipant:this.remoteParticipants.get(e)}clearConnectionFutures(){this.connectFuture=void 0}simulateScenario(e,t){return T(this,void 0,void 0,function*(){let i=()=>{},r;switch(e){case"signal-reconnect":yield this.engine.client.handleOnClose("simulate disconnect");break;case"speaker":r=new An({scenario:{case:"speakerUpdate",value:3}});break;case"node-failure":r=new An({scenario:{case:"nodeFailure",value:!0}});break;case"server-leave":r=new An({scenario:{case:"serverLeave",value:!0}});break;case"migration":r=new An({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=()=>T(this,void 0,void 0,function*(){yield this.engine.client.handleOnClose("simulate resume-disconnect")}),r=new An({scenario:{case:"disconnectSignalOnResume",value:!0}});break;case"disconnect-signal-on-resume-no-messages":i=()=>T(this,void 0,void 0,function*(){yield this.engine.client.handleOnClose("simulate resume-disconnect")}),r=new An({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":r=new An({scenario:{case:"switchCandidateProtocol",value:e==="force-tls"?2:1}}),i=()=>T(this,void 0,void 0,function*(){const o=this.engine.client.onLeave;o&&o(new iu({reason:ln.CLIENT_INITIATED,action:ro.RECONNECT}))});break;case"subscriber-bandwidth":if(t===void 0||typeof t!="number")throw new Error("subscriber-bandwidth requires a number as argument");r=new An({scenario:{case:"subscriberBandwidth",value:or(t)}});break;case"leave-full-reconnect":r=new An({scenario:{case:"leaveRequestFullReconnect",value:!0}})}r&&(yield this.engine.client.sendSimulateScenario(r),yield i())})}get canPlaybackAudio(){return this.audioEnabled}get canPlaybackVideo(){return!this.isVideoPlaybackBlocked}getActiveDevice(e){return this.localParticipant.activeDeviceMap.get(e)}switchActiveDevice(e,t){return T(this,arguments,void 0,function(i,r){var o=this;let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return function*(){var a,c,u,l,d,h,p,m;let f=!0,g=!1;const y=s?{exact:r}:r;if(i==="audioinput"){g=o.localParticipant.audioTrackPublications.size===0;const b=(a=o.getActiveDevice(i))!==null&&a!==void 0?a:o.options.audioCaptureDefaults.deviceId;o.options.audioCaptureDefaults.deviceId=y;const S=Array.from(o.localParticipant.audioTrackPublications.values()).filter(w=>w.source===N.Source.Microphone);try{f=(yield Promise.all(S.map(w=>{var k;return(k=w.audioTrack)===null||k===void 0?void 0:k.setDeviceId(y)}))).every(w=>w===!0)}catch(w){throw o.options.audioCaptureDefaults.deviceId=b,w}}else if(i==="videoinput"){g=o.localParticipant.videoTrackPublications.size===0;const b=(c=o.getActiveDevice(i))!==null&&c!==void 0?c:o.options.videoCaptureDefaults.deviceId;o.options.videoCaptureDefaults.deviceId=y;const S=Array.from(o.localParticipant.videoTrackPublications.values()).filter(w=>w.source===N.Source.Camera);try{f=(yield Promise.all(S.map(w=>{var k;return(k=w.videoTrack)===null||k===void 0?void 0:k.setDeviceId(y)}))).every(w=>w===!0)}catch(w){throw o.options.videoCaptureDefaults.deviceId=b,w}}else if(i==="audiooutput"){if(!Tp()&&!o.options.webAudioMix||o.options.webAudioMix&&o.audioContext&&!("setSinkId"in o.audioContext))throw new Error("cannot switch audio output, setSinkId not supported");o.options.webAudioMix&&(r=(u=yield ft.getInstance().normalizeDeviceId("audiooutput",r))!==null&&u!==void 0?u:""),(l=(m=o.options).audioOutput)!==null&&l!==void 0||(m.audioOutput={});const b=(d=o.getActiveDevice(i))!==null&&d!==void 0?d:o.options.audioOutput.deviceId;o.options.audioOutput.deviceId=r;try{o.options.webAudioMix&&((h=o.audioContext)===null||h===void 0||h.setSinkId(r)),yield Promise.all(Array.from(o.remoteParticipants.values()).map(S=>S.setAudioOutput({deviceId:r})))}catch(S){throw o.options.audioOutput.deviceId=b,S}}return(g||i==="audiooutput")&&(o.localParticipant.activeDeviceMap.set(i,i==="audiooutput"&&((p=o.options.audioOutput)===null||p===void 0?void 0:p.deviceId)||r),o.emit(U.ActiveDeviceChanged,i,r)),f}()})}setupLocalParticipantEvents(){this.localParticipant.on(q.ParticipantMetadataChanged,this.onLocalParticipantMetadataChanged).on(q.ParticipantNameChanged,this.onLocalParticipantNameChanged).on(q.AttributesChanged,this.onLocalAttributesChanged).on(q.TrackMuted,this.onLocalTrackMuted).on(q.TrackUnmuted,this.onLocalTrackUnmuted).on(q.LocalTrackPublished,this.onLocalTrackPublished).on(q.LocalTrackUnpublished,this.onLocalTrackUnpublished).on(q.ConnectionQualityChanged,this.onLocalConnectionQualityChanged).on(q.MediaDevicesError,this.onMediaDevicesError).on(q.AudioStreamAcquired,this.startAudio).on(q.ChatMessage,this.onLocalChatMessageSent).on(q.ParticipantPermissionsChanged,this.onLocalParticipantPermissionsChanged)}recreateEngine(){var e;(e=this.engine)===null||e===void 0||e.close(),this.engine=void 0,this.isResuming=!1,this.remoteParticipants.clear(),this.sidToIdentity.clear(),this.bufferedEvents=[],this.maybeCreateEngine()}onTrackAdded(e,t,i){if(this.state===ve.Connecting||this.state===ve.Reconnecting){const l=()=>{this.onTrackAdded(e,t,i),d()},d=()=>{this.off(U.Reconnected,l),this.off(U.Connected,l),this.off(U.Disconnected,d)};this.once(U.Reconnected,l),this.once(U.Connected,l),this.once(U.Disconnected,d);return}if(this.state===ve.Disconnected){this.log.warn("skipping incoming track after Room disconnected",this.logContext);return}if(e.readyState==="ended"){this.log.info("skipping incoming track as it already ended",this.logContext);return}const r=P3(t.id),o=r[0];let s=r[1],a=e.id;if(s&&s.startsWith("TR")&&(a=s),o===this.localParticipant.sid){this.log.warn("tried to create RemoteParticipant for local participant",this.logContext);return}const c=Array.from(this.remoteParticipants.values()).find(l=>l.sid===o);if(!c){this.log.error("Tried to add a track for a participant, that's not present. Sid: ".concat(o),this.logContext);return}let u;this.options.adaptiveStream&&(typeof this.options.adaptiveStream=="object"?u=this.options.adaptiveStream:u={}),c.addSubscribedMediaTrack(e,a,t,i,u)}handleDisconnect(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,t=arguments.length>1?arguments[1]:void 0;var i;if(this.clearConnectionReconcile(),this.isResuming=!1,this.bufferedEvents=[],this.transcriptionReceivedTimes.clear(),this.state!==ve.Disconnected){this.regionUrl=void 0;try{this.remoteParticipants.forEach(r=>{r.trackPublications.forEach(o=>{r.unpublishTrack(o.trackSid)})}),this.localParticipant.trackPublications.forEach(r=>{var o,s,a;r.track&&this.localParticipant.unpublishTrack(r.track,e),e?((o=r.track)===null||o===void 0||o.detach(),(s=r.track)===null||s===void 0||s.stop()):(a=r.track)===null||a===void 0||a.stopMonitor()}),this.localParticipant.off(q.ParticipantMetadataChanged,this.onLocalParticipantMetadataChanged).off(q.ParticipantNameChanged,this.onLocalParticipantNameChanged).off(q.AttributesChanged,this.onLocalAttributesChanged).off(q.TrackMuted,this.onLocalTrackMuted).off(q.TrackUnmuted,this.onLocalTrackUnmuted).off(q.LocalTrackPublished,this.onLocalTrackPublished).off(q.LocalTrackUnpublished,this.onLocalTrackUnpublished).off(q.ConnectionQualityChanged,this.onLocalConnectionQualityChanged).off(q.MediaDevicesError,this.onMediaDevicesError).off(q.AudioStreamAcquired,this.startAudio).off(q.ChatMessage,this.onLocalChatMessageSent).off(q.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&&typeof this.options.webAudioMix=="boolean"&&(this.audioContext.close(),this.audioContext=void 0),Wt()&&(window.removeEventListener("beforeunload",this.onPageLeave),window.removeEventListener("pagehide",this.onPageLeave),window.removeEventListener("freeze",this.onPageLeave),(i=navigator.mediaDevices)===null||i===void 0||i.removeEventListener("devicechange",this.handleDeviceChange))}finally{this.setAndEmitConnectionState(ve.Disconnected),this.emit(U.Disconnected,t)}}}handleParticipantDisconnected(e,t){var i;this.remoteParticipants.delete(e),t&&(t.trackPublications.forEach(r=>{t.unpublishTrack(r.trackSid,!0)}),this.emit(U.ParticipantDisconnected,t),t.setDisconnected(),(i=this.localParticipant)===null||i===void 0||i.handleParticipantDisconnected(t.identity))}handleStreamHeader(e,t){return T(this,void 0,void 0,function*(){var i;if(e.contentHeader.case==="byteHeader"){const r=this.byteStreamHandlers.get(e.topic);if(!r){this.log.debug("ignoring incoming byte stream due to no handler for topic",e.topic);return}let o;const s={id:e.streamId,name:(i=e.contentHeader.value.name)!==null&&i!==void 0?i:"unknown",mimeType:e.mimeType,size:e.totalLength?Number(e.totalLength):void 0,topic:e.topic,timestamp:gu(e.timestamp),attributes:e.attributes},a=new ReadableStream({start:c=>{o=c,this.byteStreamControllers.set(e.streamId,{info:s,controller:o,startTime:Date.now()})}});r(new MU(s,a,gu(e.totalLength)),{identity:t})}else if(e.contentHeader.case==="textHeader"){const r=this.textStreamHandlers.get(e.topic);if(!r){this.log.debug("ignoring incoming text stream due to no handler for topic",e.topic);return}let o;const s={id:e.streamId,mimeType:e.mimeType,size:e.totalLength?Number(e.totalLength):void 0,topic:e.topic,timestamp:Number(e.timestamp),attributes:e.attributes},a=new ReadableStream({start:c=>{o=c,this.textStreamControllers.set(e.streamId,{info:s,controller:o,startTime:Date.now()})}});r(new NU(s,a,gu(e.totalLength)),{identity:t})}})}handleStreamChunk(e){const t=this.byteStreamControllers.get(e.streamId);t&&e.content.length>0&&t.controller.enqueue(e);const i=this.textStreamControllers.get(e.streamId);i&&e.content.length>0&&i.controller.enqueue(e)}handleStreamTrailer(e){const t=this.textStreamControllers.get(e.streamId);t&&(t.info.attributes=Object.assign(Object.assign({},t.info.attributes),e.attributes),t.controller.close(),this.textStreamControllers.delete(e.streamId));const i=this.byteStreamControllers.get(e.streamId);i&&(i.info.attributes=Object.assign(Object.assign({},i.info.attributes),e.attributes),i.controller.close(),this.byteStreamControllers.delete(e.streamId))}acquireAudioContext(){return T(this,void 0,void 0,function*(){var e,t;if(typeof this.options.webAudioMix!="boolean"&&this.options.webAudioMix.audioContext?this.audioContext=this.options.webAudioMix.audioContext:(!this.audioContext||this.audioContext.state==="closed")&&(this.audioContext=(e=CS())!==null&&e!==void 0?e:void 0),this.options.webAudioMix&&this.remoteParticipants.forEach(r=>r.setAudioContext(this.audioContext)),this.localParticipant.setAudioContext(this.audioContext),this.audioContext&&this.audioContext.state==="suspended")try{yield Promise.race([this.audioContext.resume(),qt(200)])}catch(r){this.log.warn("Could not resume audio context",Object.assign(Object.assign({},this.logContext),{error:r}))}const i=((t=this.audioContext)===null||t===void 0?void 0:t.state)==="running";i!==this.canPlaybackAudio&&(this.audioEnabled=i,this.emit(U.AudioPlaybackStatusChanged,i))})}createParticipant(e,t){var i;let r;return t?r=Cu.fromParticipantInfo(this.engine.client,t,{loggerContextCb:()=>this.logContext,loggerName:this.options.loggerName}):r=new Cu(this.engine.client,"",e,void 0,void 0,void 0,{loggerContextCb:()=>this.logContext,loggerName:this.options.loggerName}),this.options.webAudioMix&&r.setAudioContext(this.audioContext),!((i=this.options.audioOutput)===null||i===void 0)&&i.deviceId&&r.setAudioOutput(this.options.audioOutput).catch(o=>this.log.warn("Could not set audio output: ".concat(o.message),this.logContext)),r}getOrCreateParticipant(e,t){if(this.remoteParticipants.has(e)){const r=this.remoteParticipants.get(e);return t&&r.updateInfo(t)&&this.sidToIdentity.set(t.sid,t.identity),r}const i=this.createParticipant(e,t);return this.remoteParticipants.set(e,i),this.sidToIdentity.set(t.sid,t.identity),this.emitWhenConnected(U.ParticipantConnected,i),i.on(q.TrackPublished,r=>{this.emitWhenConnected(U.TrackPublished,r,i)}).on(q.TrackSubscribed,(r,o)=>{r.kind===N.Kind.Audio?(r.on(B.AudioPlaybackStarted,this.handleAudioPlaybackStarted),r.on(B.AudioPlaybackFailed,this.handleAudioPlaybackFailed)):r.kind===N.Kind.Video&&(r.on(B.VideoPlaybackFailed,this.handleVideoPlaybackFailed),r.on(B.VideoPlaybackStarted,this.handleVideoPlaybackStarted)),this.emit(U.TrackSubscribed,r,o,i)}).on(q.TrackUnpublished,r=>{this.emit(U.TrackUnpublished,r,i)}).on(q.TrackUnsubscribed,(r,o)=>{this.emit(U.TrackUnsubscribed,r,o,i)}).on(q.TrackMuted,r=>{this.emitWhenConnected(U.TrackMuted,r,i)}).on(q.TrackUnmuted,r=>{this.emitWhenConnected(U.TrackUnmuted,r,i)}).on(q.ParticipantMetadataChanged,r=>{this.emitWhenConnected(U.ParticipantMetadataChanged,r,i)}).on(q.ParticipantNameChanged,r=>{this.emitWhenConnected(U.ParticipantNameChanged,r,i)}).on(q.AttributesChanged,r=>{this.emitWhenConnected(U.ParticipantAttributesChanged,r,i)}).on(q.ConnectionQualityChanged,r=>{this.emitWhenConnected(U.ConnectionQualityChanged,r,i)}).on(q.ParticipantPermissionsChanged,r=>{this.emitWhenConnected(U.ParticipantPermissionsChanged,r,i)}).on(q.TrackSubscriptionStatusChanged,(r,o)=>{this.emitWhenConnected(U.TrackSubscriptionStatusChanged,r,o,i)}).on(q.TrackSubscriptionFailed,(r,o)=>{this.emit(U.TrackSubscriptionFailed,r,i,o)}).on(q.TrackSubscriptionPermissionChanged,(r,o)=>{this.emitWhenConnected(U.TrackSubscriptionPermissionChanged,r,o,i)}).on(q.Active,()=>{this.emitWhenConnected(U.ParticipantActive,i)}),t&&i.updateInfo(t),i}sendSyncState(){const e=Array.from(this.remoteParticipants.values()).reduce((i,r)=>(i.push(...r.getTrackPublications()),i),[]),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&&q3(t)&&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=_t.setInterval(()=>{!this.engine||this.engine.isClosed||!this.engine.verifyTransport()?(e++,this.log.warn("detected connection state mismatch",Object.assign(Object.assign({},this.logContext),{numFailures:e,engine:this.engine?{closed:this.engine.isClosed,transportsConnected:this.engine.verifyTransport()}:void 0})),e>=3&&(this.recreateEngine(),this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,ln.STATE_MISMATCH))):e=0},$U)}clearConnectionReconcile(){this.connectionReconcileInterval&&_t.clearInterval(this.connectionReconcileInterval)}setAndEmitConnectionState(e){return e===this.state?!1:(this.state=e,this.emit(U.ConnectionStateChanged,this.state),!0)}emitBufferedEvents(){this.bufferedEvents.forEach(e=>{let[t,i]=e;this.emit(t,...i)}),this.bufferedEvents=[]}emitWhenConnected(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];if(this.state===ve.Reconnecting||this.isResuming||!this.engine||this.engine.pendingReconnect)this.bufferedEvents.push([e,i]);else if(this.state===ve.Connected)return this.emit(e,...i);return!1}simulateParticipants(e){return T(this,void 0,void 0,function*(){var t,i;const r=Object.assign({audio:!0,video:!0,useRealTracks:!1},e.publish),o=Object.assign({count:9,audio:!1,video:!0,aspectRatios:[1.66,1.7,1.3]},e.participants);if(this.handleDisconnect(),this.roomInfo=new Qc({sid:"RM_SIMULATED",name:"simulated-room",emptyTimeout:0,maxParticipants:0,creationTime:We.parse(new Date().getTime()),metadata:"",numParticipants:1,numPublishers:1,turnPassword:"",enabledCodecs:[],activeRecording:!1}),this.localParticipant.updateInfo(new er({identity:"simulated-local",name:"local-name"})),this.setupLocalParticipantEvents(),this.emit(U.SignalConnected),this.emit(U.Connected),this.setAndEmitConnectionState(ve.Connected),r.video){const s=new ef(N.Kind.Video,new io({source:at.CAMERA,sid:Math.floor(Math.random()*1e4).toString(),type:un.AUDIO,name:"video-dummy"}),new Su(r.useRealTracks?(yield window.navigator.mediaDevices.getUserMedia({video:!0})).getVideoTracks()[0]:_S(160*((t=o.aspectRatios[0])!==null&&t!==void 0?t:1),160,!0,!0),void 0,!1,{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext}),{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext});this.localParticipant.addTrackPublication(s),this.localParticipant.emit(q.LocalTrackPublished,s)}if(r.audio){const s=new ef(N.Kind.Audio,new io({source:at.MICROPHONE,sid:Math.floor(Math.random()*1e4).toString(),type:un.AUDIO}),new _u(r.useRealTracks?(yield navigator.mediaDevices.getUserMedia({audio:!0})).getAudioTracks()[0]:Rp(),void 0,!1,this.audioContext,{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext}),{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext});this.localParticipant.addTrackPublication(s),this.localParticipant.emit(q.LocalTrackPublished,s)}for(let s=0;s<o.count-1;s+=1){let a=new er({sid:Math.floor(Math.random()*1e4).toString(),identity:"simulated-".concat(s),state:no.ACTIVE,tracks:[],joinedAt:We.parse(Date.now())});const c=this.getOrCreateParticipant(a.identity,a);if(o.video){const u=_S(160*((i=o.aspectRatios[s%o.aspectRatios.length])!==null&&i!==void 0?i:1),160,!1,!0),l=new io({source:at.CAMERA,sid:Math.floor(Math.random()*1e4).toString(),type:un.AUDIO});c.addSubscribedMediaTrack(u,l.sid,new MediaStream([u]),new RTCRtpReceiver),a.tracks=[...a.tracks,l]}if(o.audio){const u=Rp(),l=new io({source:at.MICROPHONE,sid:Math.floor(Math.random()*1e4).toString(),type:un.AUDIO});c.addSubscribedMediaTrack(u,l.sid,new MediaStream([u]),new RTCRtpReceiver),a.tracks=[...a.tracks,l]}c.updateInfo(a)}})}emit(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];if(e!==U.ActiveSpeakersChanged&&e!==U.TranscriptionReceived){const o=QS(i).filter(s=>s!==void 0);this.log.debug("room event ".concat(e),Object.assign(Object.assign({},this.logContext),{event:e,args:o}))}return super.emit(e,...i)}}fo.cleanupRegistry=typeof FinalizationRegistry<"u"&&new FinalizationRegistry(n=>{n()});function QS(n){return n.map(e=>{if(e)return Array.isArray(e)?QS(e):typeof e=="object"?"logContext"in e?e.logContext:void 0:e})}var vn;(function(n){n[n.IDLE=0]="IDLE",n[n.RUNNING=1]="RUNNING",n[n.SKIPPED=2]="SKIPPED",n[n.SUCCESS=3]="SUCCESS",n[n.FAILED=4]="FAILED"})(vn||(vn={}));class Di extends Mn.EventEmitter{constructor(e,t){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};super(),this.status=vn.IDLE,this.logs=[],this.options={},this.url=e,this.token=t,this.name=this.constructor.name,this.room=new fo(i.roomOptions),this.connectOptions=i.connectOptions,this.options=i}run(e){return T(this,void 0,void 0,function*(){if(this.status!==vn.IDLE)throw Error("check is running already");this.setStatus(vn.RUNNING);try{yield this.perform()}catch(t){t instanceof Error&&(this.options.errorsAsWarnings?this.appendWarning(t.message):this.appendError(t.message))}return yield this.disconnect(),yield new Promise(t=>setTimeout(t,500)),this.status!==vn.SKIPPED&&this.setStatus(this.isSuccess()?vn.SUCCESS:vn.FAILED),e&&e(),this.getInfo()})}isSuccess(){return!this.logs.some(e=>e.level==="error")}connect(e){return T(this,void 0,void 0,function*(){return this.room.state===ve.Connected?this.room:(e||(e=this.url),yield this.room.connect(e,this.token,this.connectOptions),this.room)})}disconnect(){return T(this,void 0,void 0,function*(){this.room&&this.room.state!==ve.Disconnected&&(yield this.room.disconnect(),yield new Promise(e=>setTimeout(e,500)))})}skip(){this.setStatus(vn.SKIPPED)}switchProtocol(e){return T(this,void 0,void 0,function*(){let t=!1,i=!1;if(this.room.on(U.Reconnecting,()=>{t=!0}),this.room.once(U.Reconnected,()=>{i=!0}),this.room.simulateScenario("force-".concat(e)),yield new Promise(o=>setTimeout(o,1e3)),!t)return;const r=Date.now()+1e4;for(;Date.now()<r;){if(i)return;yield qt(100)}throw new Error("Could not reconnect using ".concat(e," protocol after 10 seconds"))})}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(e=this.room)===null||e===void 0?void 0:e.engine}getInfo(){return{logs:this.logs,name:this.name,status:this.status,description:this.description}}}class HU extends Di{get description(){return"Cloud regions"}perform(){return T(this,void 0,void 0,function*(){const e=new Jp(this.url,this.token);if(!e.isCloud()){this.skip();return}const t=[],i=new Set;for(let o=0;o<3;o++){const s=yield e.getNextBestRegionUrl();if(!s)break;if(i.has(s))continue;i.add(s);const a=yield this.checkCloudRegion(s);this.appendMessage("".concat(a.region," RTT: ").concat(a.rtt,"ms, duration: ").concat(a.duration,"ms")),t.push(a)}t.sort((o,s)=>(o.duration-s.duration)*.5+(o.rtt-s.rtt)*.5);const r=t[0];this.bestStats=r,this.appendMessage("best Cloud region: ".concat(r.region))})}getInfo(){const e=super.getInfo();return e.data=this.bestStats,e}checkCloudRegion(e){return T(this,void 0,void 0,function*(){var t,i;yield this.connect(e),this.options.protocol==="tcp"&&(yield this.switchProtocol("tcp"));const r=(t=this.room.serverInfo)===null||t===void 0?void 0:t.region;if(!r)throw new Error("Region not found");const o=yield this.room.localParticipant.streamText({topic:"test"}),s=1e3,c=1e6/s,u="A".repeat(s),l=Date.now();for(let m=0;m<c;m++)yield o.write(u);yield o.close();const d=Date.now(),h=yield(i=this.room.engine.pcManager)===null||i===void 0?void 0:i.publisher.getStats(),p={region:r,rtt:1e4,duration:d-l};return h==null||h.forEach(m=>{m.type==="candidate-pair"&&m.nominated&&(p.rtt=m.currentRoundTripTime*1e3)}),yield this.disconnect(),p})}}const tf=1e4;class KU extends Di{get description(){return"Connection via UDP vs TCP"}perform(){return T(this,void 0,void 0,function*(){const e=yield this.checkConnectionProtocol("udp"),t=yield this.checkConnectionProtocol("tcp");this.bestStats=e,e.qualityLimitationDurations.bandwidth-t.qualityLimitationDurations.bandwidth>.5||(e.packetsLost-t.packetsLost)/e.packetsSent>.01?(this.appendMessage("best connection quality via tcp"),this.bestStats=t):this.appendMessage("best connection quality via udp");const i=this.bestStats;this.appendMessage("upstream bitrate: ".concat((i.bitrateTotal/i.count/1e3/1e3).toFixed(2)," mbps")),this.appendMessage("RTT: ".concat((i.rttTotal/i.count*1e3).toFixed(2)," ms")),this.appendMessage("jitter: ".concat((i.jitterTotal/i.count*1e3).toFixed(2)," ms")),i.packetsLost>0&&this.appendWarning("packets lost: ".concat((i.packetsLost/i.packetsSent*100).toFixed(2),"%")),i.qualityLimitationDurations.bandwidth>1&&this.appendWarning("bandwidth limited ".concat((i.qualityLimitationDurations.bandwidth/(tf/1e3)*100).toFixed(2),"%")),i.qualityLimitationDurations.cpu>0&&this.appendWarning("cpu limited ".concat((i.qualityLimitationDurations.cpu/(tf/1e3)*100).toFixed(2),"%"))})}getInfo(){const e=super.getInfo();return e.data=this.bestStats,e}checkConnectionProtocol(e){return T(this,void 0,void 0,function*(){yield this.connect(),e==="tcp"?yield this.switchProtocol("tcp"):yield this.switchProtocol("udp");const t=document.createElement("canvas");t.width=1280,t.height=720;const i=t.getContext("2d");if(!i)throw new Error("Could not get canvas context");let r=0;const o=()=>{r=(r+1)%360,i.fillStyle="hsl(".concat(r,", 100%, 50%)"),i.fillRect(0,0,t.width,t.height),requestAnimationFrame(o)};o();const a=t.captureStream(30).getVideoTracks()[0],u=(yield this.room.localParticipant.publishTrack(a,{simulcast:!1,degradationPreference:"maintain-resolution",videoEncoding:{maxBitrate:2e6}})).track,l={protocol:e,packetsLost:0,packetsSent:0,qualityLimitationDurations:{},rttTotal:0,jitterTotal:0,bitrateTotal:0,count:0},d=setInterval(()=>T(this,void 0,void 0,function*(){const h=yield u.getRTCStatsReport();h==null||h.forEach(p=>{p.type==="outbound-rtp"?(l.packetsSent=p.packetsSent,l.qualityLimitationDurations=p.qualityLimitationDurations,l.bitrateTotal+=p.targetBitrate,l.count++):p.type==="remote-inbound-rtp"&&(l.packetsLost=p.packetsLost,l.rttTotal+=p.roundTripTime,l.jitterTotal+=p.jitter)})}),1e3);return yield new Promise(h=>setTimeout(h,tf)),clearInterval(d),a.stop(),t.remove(),yield this.disconnect(),l})}}class YU extends Di{get description(){return"Can publish audio"}perform(){return T(this,void 0,void 0,function*(){var e;const t=yield this.connect(),i=yield VU();if(yield wS(i,1e3))throw new Error("unable to detect audio from microphone");this.appendMessage("detected audio from microphone"),t.localParticipant.publishTrack(i),yield new Promise(a=>setTimeout(a,3e3));const o=yield(e=i.sender)===null||e===void 0?void 0:e.getStats();if(!o)throw new Error("Could not get RTCStats");let s=0;if(o.forEach(a=>{a.type==="outbound-rtp"&&(a.kind==="audio"||!a.kind&&a.mediaType==="audio")&&(s=a.packetsSent)}),s===0)throw new Error("Could not determine packets are sent");this.appendMessage("published ".concat(s," audio packets"))})}}class XU extends Di{get description(){return"Can publish video"}perform(){return T(this,void 0,void 0,function*(){var e;const t=yield this.connect(),i=yield jU();yield this.checkForVideo(i.mediaStreamTrack),t.localParticipant.publishTrack(i),yield new Promise(s=>setTimeout(s,5e3));const r=yield(e=i.sender)===null||e===void 0?void 0:e.getStats();if(!r)throw new Error("Could not get RTCStats");let o=0;if(r.forEach(s=>{s.type==="outbound-rtp"&&(s.kind==="video"||!s.kind&&s.mediaType==="video")&&(o+=s.packetsSent)}),o===0)throw new Error("Could not determine packets are sent");this.appendMessage("published ".concat(o," video packets"))})}checkForVideo(e){return T(this,void 0,void 0,function*(){const t=new MediaStream;t.addTrack(e.clone());const i=document.createElement("video");i.srcObject=t,i.muted=!0,yield new Promise(r=>{i.onplay=()=>{setTimeout(()=>{var o,s,a,c;const u=document.createElement("canvas"),l=e.getSettings(),d=(s=(o=l.width)!==null&&o!==void 0?o:i.videoWidth)!==null&&s!==void 0?s:1280,h=(c=(a=l.height)!==null&&a!==void 0?a:i.videoHeight)!==null&&c!==void 0?c:720;u.width=d,u.height=h;const p=u.getContext("2d");p.drawImage(i,0,0);const f=p.getImageData(0,0,u.width,u.height).data;let g=!0;for(let y=0;y<f.length;y+=4)if(f[y]!==0||f[y+1]!==0||f[y+2]!==0){g=!1;break}g?this.appendError("camera appears to be producing only black frames"):this.appendMessage("received video frames"),r()},1e3)},i.play()}),i.remove()})}}class JU extends Di{get description(){return"Resuming connection after interruption"}perform(){return T(this,void 0,void 0,function*(){var e;const t=yield this.connect();let i=!1,r=!1,o;const s=new Promise(u=>{setTimeout(u,5e3),o=u}),a=()=>{i=!0};t.on(U.SignalReconnecting,a).on(U.Reconnecting,a).on(U.Reconnected,()=>{r=!0,o(!0)}),(e=t.engine.client.ws)===null||e===void 0||e.close();const c=t.engine.client.onClose;if(c&&c(""),yield s,i){if(!r||t.state!==ve.Connected)throw this.appendWarning("reconnection is only possible in Redis-based configurations"),new Error("Not able to reconnect")}else throw new Error("Did not attempt to reconnect")})}}class ZU extends Di{get description(){return"Can connect via TURN"}perform(){return T(this,void 0,void 0,function*(){var e,t;const i=new Up,r=yield i.join(this.url,this.token,{autoSubscribe:!0,maxRetries:0,e2eeEnabled:!1,websocketTimeout:15e3});let o=!1,s=!1,a=!1;for(let c of r.iceServers)for(let u of c.urls)u.startsWith("turn:")?(s=!0,a=!0):u.startsWith("turns:")&&(s=!0,a=!0,o=!0),u.startsWith("stun:")&&(a=!0);a?s&&!o&&this.appendWarning("TURN is configured server side, but TURN/TLS is unavailable."):this.appendWarning("No STUN servers configured on server side."),yield i.close(),!((t=(e=this.connectOptions)===null||e===void 0?void 0:e.rtcConfig)===null||t===void 0)&&t.iceServers||s?yield this.room.connect(this.url,this.token,{rtcConfig:{iceTransportPolicy:"relay"}}):(this.appendWarning("No TURN servers configured."),this.skip(),yield new Promise(c=>setTimeout(c,0)))})}}class QU extends Di{get description(){return"Establishing WebRTC connection"}perform(){return T(this,void 0,void 0,function*(){let e=!1,t=!1;this.room.on(U.SignalConnected,()=>{const i=this.room.engine.client.onTrickle;this.room.engine.client.onTrickle=(r,o)=>{if(r.candidate){const s=new RTCIceCandidate(r);let a="".concat(s.protocol," ").concat(s.address,":").concat(s.port," ").concat(s.type);s.address&&(e5(s.address)?a+=" (private)":s.protocol==="tcp"&&s.tcpType==="passive"?(e=!0,a+=" (passive)"):s.protocol==="udp"&&(t=!0)),this.appendMessage(a)}i&&i(r,o)},this.room.engine.pcManager&&(this.room.engine.pcManager.subscriber.onIceCandidateError=r=>{r instanceof RTCPeerConnectionIceErrorEvent&&this.appendWarning("error with ICE candidate: ".concat(r.errorCode," ").concat(r.errorText," ").concat(r.url))})});try{yield this.connect(),le.info("now the room is connected")}catch(i){throw this.appendWarning("ports need to be open on firewall in order to connect."),i}e||this.appendWarning("Server is not configured for ICE/TCP"),t||this.appendWarning("No public IPv4 UDP candidates were found. Your server is likely not configured correctly")})}}function e5(n){const e=n.split(".");if(e.length===4){if(e[0]==="10")return!0;if(e[0]==="192"&&e[1]==="168")return!0;if(e[0]==="172"){const t=parseInt(e[1],10);if(t>=16&&t<=31)return!0}}return!1}class t5 extends Di{get description(){return"Connecting to signal connection via WebSocket"}perform(){return T(this,void 0,void 0,function*(){var e,t,i;(this.url.startsWith("ws:")||this.url.startsWith("http:"))&&this.appendWarning("Server is insecure, clients may block connections to it");let r=new Up;const o=yield r.join(this.url,this.token,{autoSubscribe:!0,maxRetries:0,e2eeEnabled:!1,websocketTimeout:15e3});this.appendMessage("Connected to server, version ".concat(o.serverVersion,".")),((e=o.serverInfo)===null||e===void 0?void 0:e.edition)===nk.Cloud&&(!((t=o.serverInfo)===null||t===void 0)&&t.region)&&this.appendMessage("LiveKit Cloud: ".concat((i=o.serverInfo)===null||i===void 0?void 0:i.region)),yield r.close()})}}class y4 extends Mn.EventEmitter{constructor(e,t){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};super(),this.options={},this.checkResults=new Map,this.url=e,this.token=t,this.options=i}getNextCheckId(){const e=this.checkResults.size;return this.checkResults.set(e,{logs:[],status:vn.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!==vn.FAILED)}getResults(){return Array.from(this.checkResults.values())}createAndRunCheck(e){return T(this,void 0,void 0,function*(){const t=this.getNextCheckId(),i=new e(this.url,this.token,this.options),r=s=>{this.updateCheck(t,s)};i.on("update",r);const o=yield i.run();return i.off("update",r),o})}checkWebsocket(){return T(this,void 0,void 0,function*(){return this.createAndRunCheck(t5)})}checkWebRTC(){return T(this,void 0,void 0,function*(){return this.createAndRunCheck(QU)})}checkTURN(){return T(this,void 0,void 0,function*(){return this.createAndRunCheck(ZU)})}checkReconnect(){return T(this,void 0,void 0,function*(){return this.createAndRunCheck(JU)})}checkPublishAudio(){return T(this,void 0,void 0,function*(){return this.createAndRunCheck(YU)})}checkPublishVideo(){return T(this,void 0,void 0,function*(){return this.createAndRunCheck(XU)})}checkConnectionProtocol(){return T(this,void 0,void 0,function*(){const e=yield this.createAndRunCheck(KU);if(e.data&&"protocol"in e.data){const t=e.data;this.options.protocol=t.protocol}return e})}checkCloudRegion(){return T(this,void 0,void 0,function*(){return this.createAndRunCheck(HU)})}}const n5=/\{[^{}]+\}/g;function i5(){return Math.random().toString(36).slice(2,11)}function r5(n){let{baseUrl:e="",Request:t=globalThis.Request,fetch:i=globalThis.fetch,querySerializer:r,bodySerializer:o,headers:s,...a}={...n};e=iw(e);const c=[];async function u(l,d){const{baseUrl:h,fetch:p=i,Request:m=t,headers:f,params:g={},parseAs:y="json",querySerializer:b,bodySerializer:S=o??s5,body:w,...k}=d||{};h&&(e=iw(h));let C=typeof r=="function"?r:nw(r);b&&(C=typeof b=="function"?b:nw({...typeof r=="object"?r:{},...b}));const x=w===void 0?void 0:S(w),I=x===void 0||x instanceof FormData?{}:{"Content-Type":"application/json"},P={redirect:"follow",...a,...k,body:x,headers:c5(I,s,f,g.header)};let D,A,L=new t(a5(l,{baseUrl:e,params:g,querySerializer:C}),P);for(const O in k)O in L||(L[O]=k[O]);if(c.length){D=i5(),A=Object.freeze({baseUrl:e,fetch:p,parseAs:y,querySerializer:C,bodySerializer:S});for(const O of c)if(O&&typeof O=="object"&&typeof O.onRequest=="function"){const F=await O.onRequest({request:L,schemaPath:l,params:g,options:A,id:D});if(F){if(!(F instanceof t))throw new Error("onRequest: must return new Request() when modifying the request");L=F}}}let V=await p(L);if(c.length)for(let O=c.length-1;O>=0;O--){const F=c[O];if(F&&typeof F=="object"&&typeof F.onResponse=="function"){const X=await F.onResponse({request:L,response:V,schemaPath:l,params:g,options:A,id:D});if(X){if(!(X instanceof Response))throw new Error("onResponse: must return new Response() when modifying the response");V=X}}}if(V.status===204||V.headers.get("Content-Length")==="0")return V.ok?{data:{},response:V}:{error:{},response:V};if(V.ok)return y==="stream"?{data:V.body,response:V}:{data:await V[y](),response:V};let Y=await V.text();try{Y=JSON.parse(Y)}catch{}return{error:Y,response:V}}return{GET(l,d){return u(l,{...d,method:"GET"})},PUT(l,d){return u(l,{...d,method:"PUT"})},POST(l,d){return u(l,{...d,method:"POST"})},DELETE(l,d){return u(l,{...d,method:"DELETE"})},OPTIONS(l,d){return u(l,{...d,method:"OPTIONS"})},HEAD(l,d){return u(l,{...d,method:"HEAD"})},PATCH(l,d){return u(l,{...d,method:"PATCH"})},TRACE(l,d){return u(l,{...d,method:"TRACE"})},use(...l){for(const d of l)if(d){if(typeof d!="object"||!("onRequest"in d||"onResponse"in d))throw new Error("Middleware must be an object with one of `onRequest()` or `onResponse()`");c.push(d)}},eject(...l){for(const d of l){const h=c.indexOf(d);h!==-1&&c.splice(h,1)}}}}function Tu(n,e,t){if(e==null)return"";if(typeof e=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${n}=${(t==null?void 0:t.allowReserved)===!0?e:encodeURIComponent(e)}`}function ew(n,e,t){if(!e||typeof e!="object")return"";const i=[],r={simple:",",label:".",matrix:";"}[t.style]||"&";if(t.style!=="deepObject"&&t.explode===!1){for(const a in e)i.push(a,t.allowReserved===!0?e[a]:encodeURIComponent(e[a]));const s=i.join(",");switch(t.style){case"form":return`${n}=${s}`;case"label":return`.${s}`;case"matrix":return`;${n}=${s}`;default:return s}}for(const s in e){const a=t.style==="deepObject"?`${n}[${s}]`:s;i.push(Tu(a,e[s],t))}const o=i.join(r);return t.style==="label"||t.style==="matrix"?`${r}${o}`:o}function tw(n,e,t){if(!Array.isArray(e))return"";if(t.explode===!1){const o={form:",",spaceDelimited:"%20",pipeDelimited:"|"}[t.style]||",",s=(t.allowReserved===!0?e:e.map(a=>encodeURIComponent(a))).join(o);switch(t.style){case"simple":return s;case"label":return`.${s}`;case"matrix":return`;${n}=${s}`;default:return`${n}=${s}`}}const i={simple:",",label:".",matrix:";"}[t.style]||"&",r=[];for(const o of e)t.style==="simple"||t.style==="label"?r.push(t.allowReserved===!0?o:encodeURIComponent(o)):r.push(Tu(n,o,t));return t.style==="label"||t.style==="matrix"?`${i}${r.join(i)}`:r.join(i)}function nw(n){return function(t){const i=[];if(t&&typeof t=="object")for(const r in t){const o=t[r];if(o!=null){if(Array.isArray(o)){if(o.length===0)continue;i.push(tw(r,o,{style:"form",explode:!0,...n==null?void 0:n.array,allowReserved:(n==null?void 0:n.allowReserved)||!1}));continue}if(typeof o=="object"){i.push(ew(r,o,{style:"deepObject",explode:!0,...n==null?void 0:n.object,allowReserved:(n==null?void 0:n.allowReserved)||!1}));continue}i.push(Tu(r,o,n))}}return i.join("&")}}function o5(n,e){let t=n;for(const i of n.match(n5)??[]){let r=i.substring(1,i.length-1),o=!1,s="simple";if(r.endsWith("*")&&(o=!0,r=r.substring(0,r.length-1)),r.startsWith(".")?(s="label",r=r.substring(1)):r.startsWith(";")&&(s="matrix",r=r.substring(1)),!e||e[r]===void 0||e[r]===null)continue;const a=e[r];if(Array.isArray(a)){t=t.replace(i,tw(r,a,{style:s,explode:o}));continue}if(typeof a=="object"){t=t.replace(i,ew(r,a,{style:s,explode:o}));continue}if(s==="matrix"){t=t.replace(i,`;${Tu(r,a)}`);continue}t=t.replace(i,s==="label"?`.${encodeURIComponent(a)}`:encodeURIComponent(a))}return t}function s5(n){return n instanceof FormData?n:JSON.stringify(n)}function a5(n,e){var r;let t=`${e.baseUrl}${n}`;(r=e.params)!=null&&r.path&&(t=o5(t,e.params.path));let i=e.querySerializer(e.params.query??{});return i.startsWith("?")&&(i=i.substring(1)),i&&(t+=`?${i}`),t}function c5(...n){const e=new Headers;for(const t of n){if(!t||typeof t!="object")continue;const i=t instanceof Headers?t.entries():Object.entries(t);for(const[r,o]of i)if(o===null)e.delete(r);else if(Array.isArray(o))for(const s of o)e.append(r,s);else o!==void 0&&e.set(r,o)}return e}function iw(n){return n.endsWith("/")?n.substring(0,n.length-1):n}const rw="Onboardee-Session-Token",ow="OnboardeeSessionToken";class sw{constructor(e){this.client=r5({baseUrl:e.baseUrl,headers:e.headers,fetch:e.fetch}),this.client.use({onRequest({request:t}){if(window.localStorage){const i=window.localStorage.getItem(ow);i&&t.headers.set(rw,i)}return t},onResponse({response:t}){const i=t.headers.get(rw);return i&&window.localStorage&&window.localStorage.setItem(ow,i),t}})}setAuthToken(e){this.client.use({onRequest({request:t}){return t.headers.set("Authorization",`Bearer ${e}`),t}})}setApiToken(e){this.client.use({onRequest({request:t}){return t.headers.set("Authorization",`Token ${e}`),t}})}async getAuthUrl(e){return await this.client.GET("/api/auth/{type}",{params:{path:{type:e}}})}async getConnectUrl(e){return await this.client.GET("/api/connect/{type}",{params:{path:{type:e}}})}async logout(){return await this.client.POST("/api/logout")}async getCurrentUser(){return await this.client.GET("/api/me")}async clientInitialise(e,t={}){return await this.client.POST("/api/client/{appToken}/initialise",{params:{path:{appToken:e}},body:t})}async clientStartSession(e,t){return await this.client.POST("/api/client/{appToken}/start-session",{params:{path:{appToken:e}},body:t})}async createPresignedUploadUrl(e){return await this.client.POST("/api/files",{body:e})}async createKnowledgeBlock(e){return await this.client.POST("/api/knowledge",{body:e})}async listOnboardees(){return await this.client.GET("/api/onboardees")}async getOnboardee(e){return await this.client.GET("/api/onboardees/{id}",{params:{path:{id:e}}})}async getOnboardeeWidgetConfig(e,t){return await this.client.GET("/api/onboardees/{id}/config",{params:{path:{id:e}},signal:t})}async listPlans(e){return await this.client.GET("/api/plans",{params:{query:{...e&&{client_type:e}}}})}async listPlansWithStatus(){return await this.client.GET("/api/plans-with-status")}async listProducts(){return await this.client.GET("/api/products")}async getProduct(e){return await this.client.GET("/api/products/{id}",{params:{path:{id:e}}})}async getProductAnalytics(e,t,i,r){return await this.client.GET("/api/products/{id}/analytics",{params:{path:{id:e},query:{...t&&{start_date:t},...i&&{end_date:i},...r&&{course_id:r}}}})}async createProduct(e){return await this.client.POST("/api/products",{body:e})}async updateProduct(e,t){return await this.client.PATCH("/api/products/{id}",{params:{path:{id:e}},body:t})}async getProductNavigationIndex(e){return await this.client.GET("/api/products/{id}/navigation-index",{params:{path:{id:e}}})}async replaceProductNavigationIndex(e,t){return await this.client.PUT("/api/products/{id}/navigation-index",{params:{path:{id:e}},body:t})}async listProductKnowledgeBlocks(e){return await this.client.GET("/api/products/{id}/knowledge-blocks",{params:{path:{id:e}}})}async createProductKnowledgeBlock(e,t){return await this.client.POST("/api/products/{id}/knowledge-blocks",{params:{path:{id:e}},body:t})}async searchProductKnowledgeBlocks(e,t,i){return await this.client.GET("/api/products/{id}/knowledge-blocks/search",{params:{path:{id:e},query:{q:t,...i&&{limit:i.toString()}}}})}async updateProductKnowledgeBlock(e,t,i){return await this.client.PATCH("/api/products/{id}/knowledge-blocks/{blockId}",{params:{path:{id:e,blockId:t}},body:i})}async deleteProductKnowledgeBlock(e,t){return await this.client.DELETE("/api/products/{id}/knowledge-blocks/{blockId}",{params:{path:{id:e,blockId:t}}})}async createPlan(e){return await this.client.POST("/api/plans",{body:e})}async getPlan(e){return await this.client.GET("/api/plans/{id}",{params:{path:{id:e}}})}async getAdminPlan(e){return await this.client.GET("/api/admin/plans/{id}",{params:{path:{id:e}}})}async getPlanAnalytics(e,t,i){return await this.client.GET("/api/plans/{id}/analytics",{params:{path:{id:e},query:{...t&&{start_date:t},...i&&{end_date:i}}}})}async replacePlan(e,t){return await this.client.PUT("/api/plans/{id}",{params:{path:{id:e}},body:t})}async updatePlan(e,t){return await this.client.PATCH("/api/plans/{id}",{params:{path:{id:e}},body:t})}async getPlanVideoUrl(e){return await this.client.GET("/api/plans/{id}/video-url",{params:{path:{id:e}}})}async getPlanVideoMetadata(e){return await this.client.GET("/api/plans/{id}/video-metadata",{params:{path:{id:e}}})}async deletePlan(e){return await this.client.DELETE("/api/admin/plans/{id}",{params:{path:{id:e}}})}async publishPlanRevision(e,t){return await this.client.POST("/api/plans/{id}/publish",{params:{path:{id:e}},body:t})}async listPlanRevisions(e){return await this.client.GET("/api/plans/{id}/revisions",{params:{path:{id:e}}})}async listPlanKnowledgeBlocks(e){return await this.client.GET("/api/plans/{id}/knowledge-blocks",{params:{path:{id:e}}})}async createPlanKnowledgeBlock(e,t){return await this.client.POST("/api/plans/{id}/knowledge-blocks",{params:{path:{id:e}},body:t})}async updatePlanKnowledgeBlock(e,t,i){return await this.client.PUT("/api/plans/{id}/knowledge-blocks/{blockId}",{params:{path:{id:e,blockId:t}},body:i})}async deletePlanKnowledgeBlock(e,t){return await this.client.DELETE("/api/plans/{id}/knowledge-blocks/{blockId}",{params:{path:{id:e,blockId:t}}})}async getPlanNavigationIndex(e){return await this.client.GET("/api/plans/{id}/navigation-index",{params:{path:{id:e}}})}async replacePlanNavigationIndex(e,t){return await this.client.POST("/api/plans/{id}/navigation-index",{params:{path:{id:e}},body:t})}async getRevisionNavigationIndex(e){return await this.client.GET("/api/revisions/{id}/navigation-index",{params:{path:{id:e}}})}async replaceRevisionNavigationIndex(e,t){return await this.client.PUT("/api/revisions/{id}/navigation-index",{params:{path:{id:e}},body:t})}async getPlanFAQ(e){return await this.client.GET("/api/plans/{id}/faq",{params:{path:{id:e}}})}async getRevisionFAQ(e){return await this.client.GET("/api/revisions/{id}/faq",{params:{path:{id:e}}})}async replaceRevisionFAQ(e,t){return await this.client.PUT("/api/revisions/{id}/faq",{params:{path:{id:e}},body:t})}async listRevisionKnowledgeBlocks(e){return await this.client.GET("/api/revisions/{id}/knowledge-blocks",{params:{path:{id:e}}})}async getRevisionSteps(e){return await this.client.GET("/api/revisions/{id}/steps",{params:{path:{id:e}}})}async replaceRevisionKnowledgeBlocks(e,t){return await this.client.PUT("/api/revisions/{id}/knowledge-blocks",{params:{path:{id:e}},body:t})}async createRevisionKnowledgeBlock(e,t){return await this.client.POST("/api/revisions/{id}/knowledge-blocks",{params:{path:{id:e}},body:t})}async updateRevisionKnowledgeBlock(e,t,i){return await this.client.PUT("/api/revisions/{id}/knowledge-blocks/{blockId}",{params:{path:{id:e,blockId:t}},body:i})}async deleteRevisionKnowledgeBlock(e,t){return await this.client.DELETE("/api/revisions/{id}/knowledge-blocks/{blockId}",{params:{path:{id:e,blockId:t}}})}async listSessions(e,t){const i={token:e};return t!=null&&t.productId&&(i.product_id=t.productId),t!=null&&t.startDate&&(i.start_date=t.startDate),t!=null&&t.endDate&&(i.end_date=t.endDate),await this.client.GET("/api/sessions",{params:{query:i}})}async createSession(e){return await this.client.POST("/api/sessions",{body:e})}async getSession(e){return await this.client.GET("/api/sessions/{id}",{params:{path:{id:e}}})}async startSession(e,t){return await this.client.GET("/api/sessions/{id}/start-session",{params:{path:{id:e},query:{token:t}}})}async getSessionRecording(e){return await this.client.GET("/api/sessions/{id}/recording",{params:{path:{id:e}}})}async getSessionSummary(e){return await this.client.GET("/api/sessions/{id}/summary",{params:{path:{id:e}}})}async getSessionProductUrl(e){return await this.client.GET("/api/sessions/{id}/product-url",{params:{path:{id:e}}})}async updateSession(e,t){return await this.client.PATCH("/api/sessions/{id}",{params:{path:{id:e}},body:t})}async listUserSessions(e){const t={};return e!=null&&e.productId&&(t.product_id=e.productId),e!=null&&e.courseId&&(t.course_id=e.courseId),e!=null&&e.startDate&&(t.start_date=e.startDate),e!=null&&e.endDate&&(t.end_date=e.endDate),e!=null&&e.page&&(t.page=e.page),e!=null&&e.limit&&(t.limit=e.limit),e!=null&&e.courseName&&(t.course_name=e.courseName),e!=null&&e.userName&&(t.user_name=e.userName),e!=null&&e.company&&(t.company=e.company),e!=null&&e.email&&(t.email=e.email),e!=null&&e.sortBy&&(t.sort_by=e.sortBy),e!=null&&e.sortOrder&&(t.sort_order=e.sortOrder),await this.client.GET("/api/user-sessions",{params:Object.keys(t).length>0?{query:t}:void 0})}async listUserSessionsAggregate(e){const t={};return e!=null&&e.productId&&(t.product_id=e.productId),e!=null&&e.courseId&&(t.course_id=e.courseId),e!=null&&e.startDate&&(t.start_date=e.startDate),e!=null&&e.endDate&&(t.end_date=e.endDate),await this.client.GET("/api/user-sessions-aggregate",{params:Object.keys(t).length>0?{query:t}:void 0})}async getJoinToken(e,{clientType:t,user:i}={}){return await this.client.GET("/api/join-token",{params:{query:{token:e,...t&&{client_type:t},...i&&{user:encodeURIComponent(i)}}}})}async getSessionPlan(e){return await this.client.GET("/api/sessions/{id}/plan",{params:{path:{id:e}}})}async getPlanSDK(e){return await this.client.GET("/api/plans/{uuid}/sdk",{params:{path:{uuid:e}}})}async getGraphemes(){return await this.client.GET("/api/graphemes")}async listVoices(){return await this.client.GET("/api/voices")}async generateVoiceSample(e,t){return await this.client.POST("/api/voices/generate-sample",{body:{product_id:t,voice_id:e},parseAs:"stream"})}getClient(){return this.client}}const aw="https://app.coragents.ai";class xu extends nh{constructor(e,t,i,r){super(),this.state=null,this.isPaused=!1,this.speakingState=null,this.captureScreen=null,this.sessionUuid=null,this.roomId=null,this.joinToken=null,this.roomUrl=null,this.room=null,this.startedAt=null,this.agentAnalyser=null,this.userAnalyser=null,this.appToken=e,this.planId=t,this.clientType=i,this.api=r.api||new sw({baseUrl:aw}),this.identity=r.identity||null,this.roomFactory=r.roomFactory||(o=>new fo(o)),this.captureScreen=r.captureScreen||null}async start(){this.planId,this.setState("connecting"),this.speakingStateChanged("thinking");try{const t=(await this.api.clientStartSession(this.appToken,{client_type:this.clientType,onboarding_plan:this.planId})).data;if(!(t!=null&&t.url)||!(t!=null&&t.token)||!(t!=null&&t.room)||!(t!=null&&t.session_uuid))throw new Error("Invalid room info");this.sessionUuid=t==null?void 0:t.session_uuid,this.roomId=t==null?void 0:t.room,this.joinToken=t==null?void 0:t.token,this.roomUrl=t==null?void 0:t.url,this.startedAt=Date.now(),await this.joinRoom(),this.setState("connected"),this.planId,this.sessionUuid}catch(e){console.error("[obi] error starting session",{error:e}),this.setState("error")}}async joinRoom({withMicrophone:e=!1,withStateRecovery:t=!1}={}){this.room=this.roomFactory({adaptiveStream:!0,dynacast:!0}),this.room.on(U.Disconnected,i=>{if(!this.room)return;let r=null;switch(i){case 12:r="invalid-room";break}this.shutdown(r)}),this.room.on(U.TrackSubscribed,i=>{i.kind==="audio"&&(i.attach(),i.source===N.Source.Microphone&&(this.agentAnalyser&&this.agentAnalyser.disconnect(),this.agentAnalyser=this.createFFT(i.mediaStream)))}),this.room.on(U.LocalTrackPublished,i=>{i.kind==="audio"&&(this.userAnalyser&&this.userAnalyser.disconnect(),this.userAnalyser=this.createFFT(i.audioTrack.mediaStream))}),this.room.on(U.ParticipantAttributesChanged,i=>{if(!i["lk.agent.state"])return;const r=i["lk.agent.state"];switch(r){case"speaking":this.speakingStateChanged("speaking");break;case"listening":this.state!=="connected"&&this.speakingStateChanged("listening");break;case"thinking":this.speakingStateChanged("thinking");break;default:console.warn("[obi] unknown speaking state",r)}}),this.room.on(U.DataReceived,async i=>{try{const r=new TextDecoder().decode(i),o=JSON.parse(r);switch(o.status||o.request||o.type){case"course_progress":typeof o.current_step=="number"&&typeof o.total_steps=="number"&&Array.isArray(o.step_names)&&this.emit("courseProgress",{currentStep:Math.max(1,o.current_step),totalSteps:Math.max(1,o.total_steps),stepNames:o.step_names});break;case"using_tool":this.speakingStateChanged("busy");break;case"using_tool_ended":this.speakingStateChanged("speaking");break;case"prompt_user":this.setState("volume-check");break;case"mic_check":this.setState("mic-check");break;case"share_mic":this.setState("mic-share");break;case"share_screen":this.setState("screen-share");break;case"navigate":this.setState("navigate");break;case"shutdown":this.shutdown("server-sent");break;case"transcript":this.emit("transcript",o.transcript,o.role);break;default:console.warn("[obi] unknown data received",o)}}catch(r){console.error("[obi] error parsing data",r)}}),this.room.localParticipant.registerRpcMethod("mic_check",async i=>(this.sessionUuid,await this.checkMicrophone()?"ok":"error")),this.room.localParticipant.registerRpcMethod("screen_capture",async i=>{if(!this.captureScreen)return console.error("[obi] no captureScreen function provided"),"error";let r=null,o=null;try{r=await this.captureScreen()}catch(s){r=null,s=s}if(!r||o)return console.error("[obi] error capturing screen",{error:o}),"error";try{return await this.room.localParticipant.sendFile(new File([r],"screen_capture.png",{type:"image/png"}),{mimeType:"image/png",topic:"screen_capture"}),"ok"}catch(s){return console.error("[obi] error sending screen capture",{error:s}),"error"}}),await this.room.connect(this.roomUrl,this.joinToken);for(let i=0;i<9&&!(this.room.state===ve.Connected&&this.room.remoteParticipants.size>=1);i++)await new Promise(r=>setTimeout(r,1e3));if(!(this.room.state===ve.Connected&&this.room.remoteParticipants.size>=1)){console.error("[obi] room not connected",{state:this.room.state,numParticipants:this.room.remoteParticipants.size}),this.shutdown("invalid-room");return}if(e&&await this.room.localParticipant.setMicrophoneEnabled(!0),t){let i=!1;for(const r of this.room.remoteParticipants.values())r.isSpeaking&&(i=!0);i?this.speakingState="speaking":this.speakingState="listening"}}async continue(){this.sessionUuid,this.speakingStateChanged("thinking"),await this.sendData({request:"prompt_user",success:!0})}async checkMicrophone(){let e=!1;try{e=(await navigator.permissions.query({name:"microphone"})).state==="granted"}catch(t){console.error("[obi] error checking microphone permission:",t)}return e?(this.sessionUuid,await this.room.localParticipant.setMicrophoneEnabled(!0),this.isMicShared=!0):this.sessionUuid,e&&this.clientType==="sdk"&&this.setState("in-progress"),this.emit("micCheckComplete",e),e}async shareMicrophone(){this.sessionUuid,this.speakingStateChanged("thinking");let e=null,t=null;try{e=await this.room.localParticipant.setMicrophoneEnabled(!0),this.isMicShared=!0}catch(i){i=i,this.isMicShared=!1}e?this.sessionUuid:console.error("[obi] failed to share microphone",{error:t}),await this.sendData({request:"share_mic",success:!!e}),this.clientType==="sdk"&&this.setState("in-progress")}async shareMicrophoneFailed(){this.isMicShared=!1,await this.sendData({request:"share_mic",success:!1}),this.clientType==="sdk"&&this.setState("in-progress")}async shareScreen(){this.sessionUuid,this.speakingStateChanged("thinking"),await this.room.localParticipant.setScreenShareEnabled(!0,{video:{displaySurface:"window"}}),await this.sendData({request:"share_screen",success:!0}),this.setState("navigate")}async pause(){this.muteMicrophone(),this.isPaused=!0,this.emit("paused"),await this.sendData({request:"pause"}),console.log("[obi] paused session",{sessionUuid:this.sessionUuid})}async unpause(){this.unmuteMicrophone(),this.isPaused=!1,this.emit("unpaused"),await this.sendData({request:"unpause"}),console.log("[obi] unpaused session",{sessionUuid:this.sessionUuid})}muteMicrophone(){this.sessionUuid,this.room.localParticipant.getTrackPublications().forEach(e=>{var t,i;e.handleMuted(),(i=(t=e.track)==null?void 0:t.mediaStream)==null||i.getTracks().forEach(r=>r.enabled=!1)})}unmuteMicrophone(){this.sessionUuid,this.room.localParticipant.getTrackPublications().forEach(e=>{var t,i;e.handleUnmuted(),(i=(t=e.track)==null?void 0:t.mediaStream)==null||i.getTracks().forEach(r=>r.enabled=!0)})}async stop(){this.emit("stopped"),await this.shutdown()}async shutdown(e=null){if(this.room){this.sessionUuid,e!=="server-sent"&&await this.sendData({request:"shutdown"});const t=this.room;this.room=null,await t.disconnect(),this.sessionUuid}this.sessionUuid=null,this.roomId=null,this.joinToken=null,this.roomUrl=null,this.emit("shutdown",e)}async say(e){this.speakingStateChanged("thinking"),this.isPaused&&await this.unpause(),await this.sendData({request:"say",message:e})}serialise(){return JSON.stringify({state:this.state,speakingState:this.speakingState,appToken:this.appToken,planId:this.planId,clientType:this.clientType,isPaused:this.isPaused,identity:this.identity,sessionUuid:this.sessionUuid,roomId:this.roomId,joinToken:this.joinToken,roomUrl:this.roomUrl,startedAt:this.startedAt})}audioSpectrum(){return this.speakingState==="speaking"&&this.agentAnalyser?this.normaliseSpectrum(this.agentAnalyser):this.speakingState==="listening"&&this.userAnalyser?this.normaliseSpectrum(this.userAnalyser):null}normaliseSpectrum(e){const i=e.context.sampleRate/2/e.frequencyBinCount,r=new Uint8Array(e.frequencyBinCount);e.getByteFrequencyData(r);const o=[],s=50,a=5e3,c=8,u=Math.pow(a/s,1/c);for(let l=0;l<c;l++){const d=s*Math.pow(u,l),h=s*Math.pow(u,l+1),p=Math.floor(d/i),m=Math.floor(h/i),f=Math.min(m,r.length),g=Math.min(p,f);if(g<f){const y=r.slice(g,f).reduce((b,S)=>b+S,0)/(f-g)/255;o.push(y)}else o.push(0)}return o}setState(e){this.state;const t=this.state;this.state=e,this.emit("stateChanged",e,t)}static deserialise(e,t,i,r={}){const o=JSON.parse(e),s=new xu(t,o.planId,i,r);return s.state=o.state,s.speakingState=o.speakingState,s.identity=o.identity||null,s.isPaused=o.isPaused||!1,s.sessionUuid=o.sessionUuid||null,s.roomId=o.roomId||null,s.joinToken=o.joinToken||null,s.roomUrl=o.roomUrl||null,s.startedAt=o.startedAt||null,s}speakingStateChanged(e){this.speakingState;const t=this.speakingState;this.speakingState=e,this.emit("speakingStateChanged",e,t)}async sendData(e){await this.room.localParticipant.publishData(new TextEncoder().encode(JSON.stringify(e)),{reliable:!0})}createFFT(e){const t=new AudioContext,i=t.createAnalyser();return t.createMediaStreamSource(e).connect(i),i.fftSize=2048,i.smoothingTimeConstant=.6,i}}class Eu extends nh{constructor(e,t,i={}){super(),this.state="loading",this.error=null,this.identity=null,this.product=null,this.plans=[],this.planIsCompleted=[],this.selectedPlan=null,this.selectedPlanUuid=null,this.showWidget=!1,this.session=null,this.captureScreen=null,this.appToken=e,this.clientType=t,this.api=i.api||new sw({baseUrl:i.apiBaseUrl||aw}),this.sessionFactory=i.sessionFactory||((r,o,s,a)=>new xu(r,o,s,a)),this.captureScreen=i.captureScreen||null}async initialise(e={}){var t,i,r,o,s;if(!this.appToken)throw new Error("App token is required");this.setState("loading");try{const a=await this.api.clientInitialise(this.appToken,{identity:e.identity,client_type:this.clientType});if(this.identity=e.identity||null,this.product=((t=a.data)==null?void 0:t.product)||null,this.plans=((i=a.data)==null?void 0:i.onboarding_plans)||[],this.selectedPlan=((r=a.data)==null?void 0:r.selected_plan)||null,this.planIsCompleted=((o=a.data)==null?void 0:o.plan_is_completed)||[],this.showWidget=((s=a.data)==null?void 0:s.show_widget)||!1,e.planUuid){let c=null;try{const u=await this.api.getPlanSDK(e.planUuid);if(u.error)throw new Error(`Plan not found: ${u.error}`);u.data&&(c=u.data)}catch(u){try{const l=await this.api.getSessionPlan(e.planUuid);if(l.error)throw new Error(`Session plan not found: ${l.error}`);l.data&&(c=l.data)}catch(l){console.error("[obi] error getting plan via both endpoints",{planErr:u,sessionErr:l})}}c?(this.selectedPlan=c,this.selectedPlanUuid=e.planUuid):console.warn("[obi] plan not found",{planUuid:e.planUuid})}this.identity,this.product,this.plans,this.selectedPlan,this.showWidget}catch(a){throw this.error=a instanceof Error?a:new Error(String(a)),this.setState("error"),a}finally{this.setState("ready")}}selectPlan(e){this.selectedPlan=e,this.selectedPlanUuid=(e==null?void 0:e.uuid)||null,this.emit("planSelected",e)}async startSession(e,t){return await this._stopSession(),this.session=this.sessionFactory(this.appToken,e,this.clientType,{api:this.api,identity:this.identity,captureScreen:this.captureScreen}),this.prepareSession(t),this.session.start().then(()=>{this.emit("sessionStarted",this.session)}).catch(i=>{this.session=null,console.error("[obi] error starting session",i)}),this.session}async resumeSession(e){var t,i;return this.state,(t=this.session)==null||t.state,(i=this.session)==null||i.speakingState,this.session.captureScreen=this.captureScreen,this.prepareSession(e),this.session.joinRoom({withMicrophone:!0,withStateRecovery:!0}).then(()=>{this.emit("sessionResumed",this.session)}).catch(r=>{console.error("[obi] error joining room",{error:r}),r instanceof Error&&r.message==="Room is not connected"&&this.session.stop()}),this.session}prepareSession(e){if(!this.session)throw new Error("No session to prepare");return e(this.session),this.session.on("stopped",()=>{this.emit("sessionStopped")}),this.session.on("shutdown",t=>{var i,r,o;if((i=this.session)!=null&&i.startedAt&&this.session.startedAt+5*60*1e3<Date.now()){const s=this.plans.findIndex(a=>{var c;return a.uuid===((c=this.selectedPlan)==null?void 0:c.uuid)});s!==-1&&(this.planIsCompleted[s]=!0)}(o=(r=this.session)==null?void 0:r.removeAllListeners)==null||o.call(r),this.session=null,this.selectedPlan=null,this.selectedPlanUuid=null,this.emit("sessionShutdown",t)}),this.session}async stopSession(){await this._stopSession(),this.selectedPlan&&this.selectPlan(null)}async _stopSession(){this.session&&(this.trackEvent("session-stopped",{sessionUuid:this.session.sessionUuid}),await this.session.stop(),this.session=null)}isLoading(){return this.state==="loading"}isReady(){return this.state==="ready"}serialise(){var e;return JSON.stringify({state:this.state,appToken:this.appToken,clientType:this.clientType,identity:this.identity,product:this.product,plans:this.plans,selectedPlan:this.selectedPlan,selectedPlanUuid:this.selectedPlanUuid,showWidget:this.showWidget,session:(e=this.session)==null?void 0:e.serialise(),serialisedAt:new Date().toISOString()})}static deserialise(e,t,i,r={}){const o=JSON.parse(e);if(o.serialisedAt){const a=new Date(o.serialisedAt);if(new Date().getTime()-a.getTime()>1e3*20)throw new Error("Client was serialised more than 20 seconds ago, assuming it's dead.")}else throw new Error("Client was not serialised, assuming it's dead.");const s=new Eu(t,i,r);return s.state=o.state,s.identity=o.identity||null,s.product=o.product||null,s.plans=o.plans||[],s.selectedPlan=o.selectedPlan||null,s.selectedPlanUuid=o.selectedPlanUuid||null,s.showWidget=o.showWidget||!1,o.session&&(s.session=xu.deserialise(o.session,t,i,{api:s.api})),s}setState(e){const t=this.state;this.state=e,this.emit("stateChanged",e,t)}trackEvent(e,t={}){var i,r,o;this.emit("trackEvent",e,{...t,clientType:this.clientType,planId:(i=this.selectedPlan)==null?void 0:i.uuid,productId:(r=this.product)==null?void 0:r.uuid,sessionId:(o=this.session)==null?void 0:o.sessionUuid})}}function u5(n,e,t,i){function r(o){return o instanceof t?o:new t(function(s){s(o)})}return new(t||(t=Promise))(function(o,s){function a(l){try{u(i.next(l))}catch(d){s(d)}}function c(l){try{u(i.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):r(l.value).then(a,c)}u((i=i.apply(n,e||[])).next())})}function l5(n,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},i,r,o,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(u){return function(l){return c([u,l])}}function c(u){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,u[0]&&(t=0)),t;)try{if(i=1,r&&(o=u[0]&2?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[u[0]&2,o.value]),u[0]){case 0:case 1:o=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,r=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){t.label=u[1];break}if(u[0]===6&&t.label<o[1]){t.label=o[1],o=u;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(u);break}o[2]&&t.ops.pop(),t.trys.pop();continue}u=e.call(n,t)}catch(l){u=[6,l],r=0}finally{i=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}typeof SuppressedError=="function"&&SuppressedError;for(var cw="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ks=typeof Uint8Array>"u"?[]:new Uint8Array(256),Iu=0;Iu<cw.length;Iu++)ks[cw.charCodeAt(Iu)]=Iu;for(var d5=function(n){var e=n.length*.75,t=n.length,i,r=0,o,s,a,c;n[n.length-1]==="="&&(e--,n[n.length-2]==="="&&e--);var u=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u"&&typeof Uint8Array.prototype.slice<"u"?new ArrayBuffer(e):new Array(e),l=Array.isArray(u)?u:new Uint8Array(u);for(i=0;i<t;i+=4)o=ks[n.charCodeAt(i)],s=ks[n.charCodeAt(i+1)],a=ks[n.charCodeAt(i+2)],c=ks[n.charCodeAt(i+3)],l[r++]=o<<2|s>>4,l[r++]=(s&15)<<4|a>>2,l[r++]=(a&3)<<6|c&63;return u},h5=function(n){for(var e=n.length,t=[],i=0;i<e;i+=2)t.push(n[i+1]<<8|n[i]);return t},p5=function(n){for(var e=n.length,t=[],i=0;i<e;i+=4)t.push(n[i+3]<<24|n[i+2]<<16|n[i+1]<<8|n[i]);return t},ar=5,nf=6+5,rf=2,f5=nf-ar,uw=65536>>ar,m5=1<<ar,of=m5-1,g5=1024>>ar,v5=uw+g5,y5=v5,b5=32,_5=y5+b5,k5=65536>>nf,S5=1<<f5,w5=S5-1,lw=function(n,e,t){return n.slice?n.slice(e,t):new Uint16Array(Array.prototype.slice.call(n,e,t))},C5=function(n,e,t){return n.slice?n.slice(e,t):new Uint32Array(Array.prototype.slice.call(n,e,t))},T5=function(n,e){var t=d5(n),i=Array.isArray(t)?p5(t):new Uint32Array(t),r=Array.isArray(t)?h5(t):new Uint16Array(t),o=24,s=lw(r,o/2,i[4]/2),a=i[5]===2?lw(r,(o+i[4])/2):C5(i,Math.ceil((o+i[4])/4));return new x5(i[0],i[1],i[2],i[3],s,a)},x5=function(){function n(e,t,i,r,o,s){this.initialValue=e,this.errorValue=t,this.highStart=i,this.highValueIndex=r,this.index=o,this.data=s}return n.prototype.get=function(e){var t;if(e>=0){if(e<55296||e>56319&&e<=65535)return t=this.index[e>>ar],t=(t<<rf)+(e&of),this.data[t];if(e<=65535)return t=this.index[uw+(e-55296>>ar)],t=(t<<rf)+(e&of),this.data[t];if(e<this.highStart)return t=_5-k5+(e>>nf),t=this.index[t],t+=e>>ar&w5,t=this.index[t],t=(t<<rf)+(e&of),this.data[t];if(e<=1114111)return this.data[this.highValueIndex]}return this.errorValue},n}(),dw="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",E5=typeof Uint8Array>"u"?[]:new Uint8Array(256),Ru=0;Ru<dw.length;Ru++)E5[dw.charCodeAt(Ru)]=Ru;var hw=null;function I5(n){return u5(this,void 0,void 0,function(){var e;return l5(this,function(t){switch(t.label){case 0:return hw!==null?[3,2]:[4,n()];case 1:if(e=t.sent(),!e.base64||!e.byte_length)throw new Error("Invalid graphemes response");hw=T5(e.base64,e.byte_length),t.label=2;case 2:return[2]}})})}for(var pw="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",R5=typeof Uint8Array>"u"?[]:new Uint8Array(256),Pu=0;Pu<pw.length;Pu++)R5[pw.charCodeAt(Pu)]=Pu;function P5(n,e,t,i){function r(o){return o instanceof t?o:new t(function(s){s(o)})}return new(t||(t=Promise))(function(o,s){function a(l){try{u(i.next(l))}catch(d){s(d)}}function c(l){try{u(i.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):r(l.value).then(a,c)}u((i=i.apply(n,e||[])).next())})}function O5(n,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},i,r,o,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(u){return function(l){return c([u,l])}}function c(u){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,u[0]&&(t=0)),t;)try{if(i=1,r&&(o=u[0]&2?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[u[0]&2,o.value]),u[0]){case 0:case 1:o=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,r=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){t.label=u[1];break}if(u[0]===6&&t.label<o[1]){t.label=o[1],o=u;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(u);break}o[2]&&t.ops.pop(),t.trys.pop();continue}u=e.call(n,t)}catch(l){u=[6,l],r=0}finally{i=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}typeof SuppressedError=="function"&&SuppressedError;for(var fw="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ss=typeof Uint8Array>"u"?[]:new Uint8Array(256),Ou=0;Ou<fw.length;Ou++)Ss[fw.charCodeAt(Ou)]=Ou;for(var A5=function(n){var e=n.length*.75,t=n.length,i,r=0,o,s,a,c;n[n.length-1]==="="&&(e--,n[n.length-2]==="="&&e--);var u=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u"&&typeof Uint8Array.prototype.slice<"u"?new ArrayBuffer(e):new Array(e),l=Array.isArray(u)?u:new Uint8Array(u);for(i=0;i<t;i+=4)o=Ss[n.charCodeAt(i)],s=Ss[n.charCodeAt(i+1)],a=Ss[n.charCodeAt(i+2)],c=Ss[n.charCodeAt(i+3)],l[r++]=o<<2|s>>4,l[r++]=(s&15)<<4|a>>2,l[r++]=(a&3)<<6|c&63;return u},M5=function(n){for(var e=n.length,t=[],i=0;i<e;i+=2)t.push(n[i+1]<<8|n[i]);return t},N5=function(n){for(var e=n.length,t=[],i=0;i<e;i+=4)t.push(n[i+3]<<24|n[i+2]<<16|n[i+1]<<8|n[i]);return t},cr=5,sf=6+5,af=2,D5=sf-cr,mw=65536>>cr,L5=1<<cr,cf=L5-1,U5=1024>>cr,F5=mw+U5,B5=F5,j5=32,V5=B5+j5,z5=65536>>sf,q5=1<<D5,W5=q5-1,gw=function(n,e,t){return n.slice?n.slice(e,t):new Uint16Array(Array.prototype.slice.call(n,e,t))},G5=function(n,e,t){return n.slice?n.slice(e,t):new Uint32Array(Array.prototype.slice.call(n,e,t))},$5=function(n,e){var t=A5(n),i=Array.isArray(t)?N5(t):new Uint32Array(t),r=Array.isArray(t)?M5(t):new Uint16Array(t),o=24,s=gw(r,o/2,i[4]/2),a=i[5]===2?gw(r,(o+i[4])/2):G5(i,Math.ceil((o+i[4])/4));return new H5(i[0],i[1],i[2],i[3],s,a)},H5=function(){function n(e,t,i,r,o,s){this.initialValue=e,this.errorValue=t,this.highStart=i,this.highValueIndex=r,this.index=o,this.data=s}return n.prototype.get=function(e){var t;if(e>=0){if(e<55296||e>56319&&e<=65535)return t=this.index[e>>cr],t=(t<<af)+(e&cf),this.data[t];if(e<=65535)return t=this.index[mw+(e-55296>>cr)],t=(t<<af)+(e&cf),this.data[t];if(e<this.highStart)return t=V5-z5+(e>>sf),t=this.index[t],t+=e>>cr&W5,t=this.index[t],t=(t<<af)+(e&cf),this.data[t];if(e<=1114111)return this.data[this.highValueIndex]}return this.errorValue},n}(),vw="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",K5=typeof Uint8Array>"u"?[]:new Uint8Array(256),Au=0;Au<vw.length;Au++)K5[vw.charCodeAt(Au)]=Au;var yw=null;function Y5(n){return P5(this,void 0,void 0,function(){var e;return O5(this,function(t){switch(t.label){case 0:return yw!==null?[3,2]:[4,n()];case 1:if(e=t.sent(),!e.base64||!e.byte_length)throw console.error("invalid graphemes response",e),new Error("Invalid graphemes response");yw=$5(e.base64,e.byte_length),t.label=2;case 2:return[2]}})})}const X5=`:root,:host{--obi-modal-padding: 48px 48px 32px;--obi-modal-background-color: #FFFFFF;--obi-modal-border-radius: 12px;--obi-modal-shadow: 0px 1px 2px rgba(0, 0, 0, .05);--obi-modal-xsmall-width: 320px;--obi-modal-xsmall-height: 240px;--obi-modal-small-width: 480px;--obi-modal-small-height: 400px;--obi-modal-medium-width: 640px;--obi-modal-medium-height: 545px;--obi-modal-large-width: 1200px;--obi-modal-large-height: 700px;--obi-font-family: "Satoshi", sans-serif;--obi-color-primary: #9500FF;--obi-color-primary-50: color-mix(in srgb, var(--obi-color-primary) 50%, white 50%);--obi-color-primary-30: color-mix(in srgb, var(--obi-color-primary) 30%, white 70%);--obi-color-tint: color-mix(in srgb, var(--obi-color-primary) 5%, white 95%);--obi-color-text: #18181B;--obi-course-color-selected: var(--obi-color-primary-50);--obi-course-color-tint: var(--obi-color-tint);--obi-course-progress-step-completed: #B3B3B3;--obi-course-progress-step-incomplete: #D9D9D9;--obi-course-progress-text-color: #757575;font-family:var(--obi-font-family);color:var(--obi-color-text)}.obi-button{font-family:var(--obi-font-family);color:var(--obi-color-text)}dialog{margin:auto;padding:0;border:none;border-radius:var(--obi-modal-border-radius);box-shadow:var(--obi-modal-shadow);background:var(--obi-modal-background-color);box-sizing:border-box}dialog>.modal-content{padding:var(--obi-modal-padding);box-sizing:border-box}dialog,dialog.modal-medium,dialog>.modal-content,dialog.modal-medium>.modal-content{width:var(--obi-modal-medium-width);min-height:var(--obi-modal-medium-height)}dialog.modal-xsmall,dialog.modal-xsmall>.modal-content{width:var(--obi-modal-xsmall-width);min-height:var(--obi-modal-xsmall-height)}dialog.modal-small,dialog.modal-small>.modal-content{width:var(--obi-modal-small-width);min-height:var(--obi-modal-small-height)}dialog.modal-large,dialog.modal-large>.modal-content{width:var(--obi-modal-large-width);min-height:var(--obi-modal-large-height)}dialog::backdrop{background:rgba(0,0,0,.5)}.tour-content{display:block;width:100%;height:100%}.tour-content .container{box-sizing:border-box;display:flex;flex-direction:column;align-items:center;padding:0;width:100%;height:100%}.tour-content .header{display:flex;flex-direction:column;align-items:center;padding:0;gap:16px;width:100%}.tour-content .title{width:100%;font-family:Satoshi,sans-serif;font-style:normal;font-weight:700;font-size:32px;line-height:90%;text-align:center;letter-spacing:-.03em;color:#18181b;margin:0}.tour-content .subtitle{width:100%;font-family:Satoshi,sans-serif;font-style:normal;font-weight:400;font-size:16px;line-height:140%;text-align:center;letter-spacing:-.01em;color:#18181b;margin:0}.tour-content .visual{width:480px;height:240px;margin-top:24px;border-radius:12px;display:flex;align-items:center;justify-content:center;position:relative}.tour-content .description{width:100%;min-height:48px;margin:24px 0 0;font-family:Satoshi,sans-serif;font-style:normal;font-weight:400;font-size:16px;line-height:140%;text-align:center;letter-spacing:-.01em;color:#18181b}.tour-content .button-container{display:flex;margin-top:24px;flex-direction:column;align-items:center;gap:16px;width:100%}.tour-content .action-button{box-sizing:border-box;display:flex;flex-direction:row;justify-content:center;align-items:center;padding:12px;gap:8px;min-width:200px;height:40px;background:#303030;border:1px solid #303030;border-radius:4px;cursor:pointer;text-decoration:none}.tour-content .action-button.disabled{opacity:.6;cursor:not-allowed}.tour-content .button-text{height:16px;font-family:Satoshi,sans-serif;font-style:normal;font-weight:400;font-size:16px;line-height:100%;color:#fbf3ff}.tour.content-area{flex:1;display:flex;flex-direction:column}.obi-close-button{position:absolute;top:24px;right:24px;width:24px;height:24px;cursor:pointer;border:none;background:none;padding:0;display:flex;align-items:center;justify-content:center;z-index:1}.obi-panel{box-sizing:border-box;padding:24px;background-color:#fff;box-shadow:0 16px 32px -4px #0000001f,0 4px 8px -2px #00000014,inset 0 1px #fff9;border-radius:12px}.obi-pill.container{width:96px;height:30px;display:flex;align-items:center;justify-content:center}.obi-pill.container .pill{display:flex;align-items:center;justify-content:center;width:48px;height:6px;opacity:.7;border-radius:3px;background-color:var(--obi-color-primary);transition:width .15s ease-in-out,height .15s ease-in-out,border-radius .15s ease-in-out}.obi-pill.container .pill.button{cursor:pointer}.obi-pill.container.user-speaking .pill{background-color:var(--obi-color-primary-30)}.obi-pill.container.active .pill{width:96px;height:30px;border-radius:15px;opacity:1}.obi-pill.container.busy,.obi-pill.container.busy .pill{width:220px}.obi-pill2.container{display:flex;align-items:center;justify-content:center}.obi-pill2.container .pill{display:flex;align-items:center;justify-content:center;min-width:48px;max-width:48px;height:6px;opacity:.7;border-radius:3px;border:1px solid #FFFFFF1F;background-color:var(--obi-color-primary);transform:translateY(0);overflow:hidden;white-space:nowrap;flex:0 0 auto;box-sizing:border-box;padding-left:0;padding-right:0;transition:max-width .15s ease-in-out,min-width .15s ease-in-out,height .15s ease-in-out,border-radius .15s ease-in-out,padding-left .15s ease-in-out,padding-right .15s ease-in-out}.obi-pill2.container .pill.button{cursor:pointer}.obi-pill2.container:not(.active){transition:height 0s linear .15s;height:6px}.obi-pill2.container:not(.active) .pill{transform:translateY(12px);transition:transform 0s linear .15s,max-width .15s ease-in-out,min-width .15s ease-in-out,height .15s ease-in-out,border-radius .15s ease-in-out,padding-left .15s ease-in-out,padding-right .15s ease-in-out}.obi-pill2.container.active{transition:none;height:30px}.obi-pill2.container.active .pill{transition:transform 0s,max-width .15s ease-in-out,min-width .15s ease-in-out,height .15s ease-in-out,border-radius .15s ease-in-out,padding-left .15s ease-in-out,padding-right .15s ease-in-out;max-width:1000px;height:30px;border-radius:15px;opacity:1;padding-left:14px;padding-right:14px}.obi-pill2.container.user-speaking .pill{background-color:var(--obi-color-primary-30)}.obi-pill2.container:not(.active) .pill .text{opacity:0;animation:none}.obi-pill-up.container{display:flex;align-items:flex-end;justify-content:center}.obi-pill-up.container .pill{display:flex;align-items:center;justify-content:center;min-width:48px;max-width:48px;height:6px;opacity:.7;border-radius:3px;border:1px solid #FFFFFF1F;background-color:var(--obi-color-primary);overflow:hidden;white-space:nowrap;flex:0 0 auto;box-sizing:border-box;padding-left:0;padding-right:0;transition:max-width .15s ease-in-out,min-width .15s ease-in-out,height .15s ease-in-out,border-radius .15s ease-in-out,padding-left .15s ease-in-out,padding-right .15s ease-in-out}.obi-pill-up.container .pill.button{cursor:pointer}.obi-pill-up.container:not(.active){transition:height 0s linear .15s;height:6px}.obi-pill-up.container:not(.active) .pill{transition:max-width .15s ease-in-out,min-width .15s ease-in-out,height .15s ease-in-out,border-radius .15s ease-in-out,padding-left .15s ease-in-out,padding-right .15s ease-in-out}.obi-pill-up.container.active{transition:none;height:30px}.obi-pill-up.container.active .pill{transition:max-width .15s ease-in-out,min-width .15s ease-in-out,height .15s ease-in-out,border-radius .15s ease-in-out,padding-left .15s ease-in-out,padding-right .15s ease-in-out;max-width:1000px;height:30px;border-radius:15px;opacity:1;padding-left:14px;padding-right:14px}.obi-pill-up.container.user-speaking .pill{background-color:var(--obi-color-primary-30)}.obi-pill-up.container:not(.active) .pill .text{opacity:0;animation:none}.obi-popout{position:relative;display:inline-block}.obi-popout .obi-popout-target{cursor:pointer;display:inline-block}.obi-popout .content{position:absolute;background-color:#fff0;z-index:100;animation:popout-appear .15s ease-out}@keyframes popout-appear{0%{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}.obi-round-button-popout{z-index:600}.obi-round-button{flex:0 0 auto;display:flex;align-items:center;justify-content:center;width:30px;height:30px;border-radius:50%;padding:0;box-sizing:border-box;background-color:#fff;border:1px solid #D9D9D9;box-shadow:none}.obi-round-button:hover{cursor:pointer}.obi-round-button:disabled{box-shadow:none;background-color:#f0f0f0;color:#999;cursor:not-allowed!important;pointer-events:none}.obi-round-button-title{padding:8px 16px;border-radius:12px;background-color:#fff;color:#000;font-size:14px;font-weight:400;white-space:nowrap;box-shadow:0 4px 12px #00000026,0 2px 4px #0000001a;border:1px solid rgba(0,0,0,.08);z-index:5000;pointer-events:none;-webkit-user-select:none;user-select:none;position:relative}.obi-round-button-title:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);width:0;height:0;border-left:6px solid transparent;border-right:6px solid transparent;border-top:6px solid white;filter:drop-shadow(0 2px 2px rgba(0,0,0,.1))}.obi-equaliser{display:flex;align-items:center;gap:2px;height:32px}.obi-equaliser .column{position:relative;display:flex;align-items:center;justify-content:center;width:5px;height:100%}.obi-equaliser .bar{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:3px;border-radius:2px;z-index:1}.obi-message{display:inline-flex;align-items:center;justify-content:center;padding:0 15px;text-wrap:nowrap;font-size:16px;font-weight:400;height:30px;box-sizing:border-box;background-color:#fff;border-radius:15px;border:1px solid #D9D9D9}.obi-message.clickable{box-shadow:0 4px 6px #0000001a;cursor:pointer}.obi-loading-dots{display:flex;align-items:center;gap:2px;height:32px}.obi-loading-dots .column{position:relative;display:flex;align-items:center;justify-content:center;width:5px;height:100%}.obi-loading-dots .dot{width:3px;height:3px;border-radius:2px;position:relative;z-index:2}.obi-loading-dots .bar{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:3px;border-radius:2px;z-index:1;height:0px;animation:bounce .9s ease-in-out infinite}@keyframes bounce{0%,60%,to{height:0px}30%{height:16px}}.obi-exit-survey{position:relative;width:320px;margin:0 auto;-webkit-backdrop-filter:none;backdrop-filter:none;background:white;z-index:9999}.obi-exit-survey-container{display:flex;flex-direction:column;align-items:center;padding:0;gap:16px;width:272px;flex:none;align-self:stretch}.obi-exit-survey-header{display:flex;flex-direction:column;align-items:flex-start;padding:0;gap:4px;width:272px;flex:none;align-self:stretch}.obi-exit-survey-title{width:272px;height:22px;margin:0;font-family:Satoshi,sans-serif;font-size:16px;font-weight:600;line-height:140%;text-align:center;color:#1e1e1e;flex:none;align-self:stretch}.obi-exit-survey-subtitle{width:272px;height:20px;margin:0;font-family:Satoshi,sans-serif;font-style:normal;font-weight:400;font-size:14px;line-height:140%;text-align:center;color:#757575;flex:none;align-self:stretch}.obi-exit-survey-options{display:flex;flex-direction:column;align-items:flex-start;padding:0;gap:4px;width:272px;flex:none;align-self:stretch}.obi-exit-survey-options textarea{height:80px;resize:none;outline:none}.obi-exit-survey-button{box-sizing:border-box;display:flex;flex-direction:row;justify-content:center;align-items:center;padding:12px;gap:8px;width:272px;height:44px;border-radius:12px;cursor:pointer;font-family:Satoshi,sans-serif;font-style:normal;font-weight:400;font-size:14px;line-height:140%;flex:none;align-self:stretch;transition:all .2s ease}.obi-exit-survey-button:hover{transform:translateY(-1px);box-shadow:0 4px 8px #0000001a}.obi-exit-survey-button:active{transform:translateY(0)}.obi-exit-survey-button-continue{background:rgba(255,255,255);border:1px solid rgba(217,217,217);color:#1e1e1e}.obi-exit-survey-button-continue:hover{background:rgba(255,255,255);border-color:#d9d9d9}.obi-exit-survey-button-wrap-up{background:#303030;border:1px solid rgba(217,217,217);color:#fff;font-weight:500}.obi-exit-survey-button-wrap-up:hover{background:#404040;border-color:#d9d9d9}.obi-exit-survey-reason-button{background:rgba(255,255,255);border:1px solid rgba(217,217,217);color:#1e1e1e}.obi-exit-survey-reason-button:hover{background:rgba(255,255,255);border-color:#d9d9d9}.obi-exit-survey-reason-button-secondary{display:flex;flex-direction:row;justify-content:center;align-items:center;padding:4px 6px;gap:8px;width:272px;height:28px;border-radius:4px;cursor:pointer;border:none;background:transparent;font-family:Satoshi,sans-serif;font-style:normal;font-weight:400;font-size:14px;line-height:140%;color:#5a5a5a;flex:none;align-self:stretch;transition:all .2s ease}.obi-exit-survey-reason-button-secondary:hover{background:rgba(0,0,0,.05);color:#3a3a3a}.obi-message-input{display:inline-block;position:relative}.obi-message-input .container{width:212px;height:30px;box-sizing:border-box;background:#FFFFFF;border:1px solid var(--obi-color-primary-30);border-radius:15px;display:flex;align-items:center;flex:none;order:2;flex-grow:0;transition:height .3s ease,border-radius .3s ease;animation:expandMessageInput .2s cubic-bezier(.4,0,.2,1) 0s 1 normal both}.obi-message-input.expanded .container{height:auto;min-height:140px;border-radius:15px;align-items:flex-start;padding:8px 0;animation:expandMessageInputWide .2s cubic-bezier(.4,0,.2,1) 0s 1 normal both}.obi-message-input .field{flex:1 1 0;border:none;background:transparent;outline:none;font-family:Satoshi,sans-serif;font-style:normal;font-weight:400;font-size:14px;line-height:18px;color:#000;padding:4px 3px 0 16px;height:100%;box-sizing:border-box;min-width:0;resize:none;overflow:hidden;scrollbar-width:none;transition:padding .3s ease;animation:fadeInInputField .2s cubic-bezier(.4,0,.2,1) 0s 1 normal both}.obi-message-input.expanded .field{height:auto;min-height:120px;padding:4px 16px;overflow-y:auto;line-height:18px}.obi-message-input .field::placeholder{color:#999}.obi-message-input .field:disabled{cursor:not-allowed;opacity:.6}.obi-message-input .send{position:absolute;bottom:3px;right:4px;flex-shrink:0;width:24px;height:24px;background:var(--obi-color-primary);border:none;border-radius:9999px;display:flex;justify-content:center;align-items:center;cursor:pointer;transition:all .3s ease;color:#fff}.obi-message-input.expanded .send{width:28px;height:28px;position:relative;top:0;bottom:0;margin-right:0}.obi-message-input.expanded .button-container{display:flex;justify-content:space-between;align-items:center;width:100%;margin-top:8px}.obi-message-input .send:disabled{background:#CCCCCC;cursor:not-allowed;transform:none}.obi-message-input .container:focus-within{border-color:var(--obi-color-primary);box-shadow:0 0 0 2px #9008ff1a}@keyframes expandMessageInput{0%{width:32px}to{width:212px}}@keyframes expandMessageInputWide{0%{width:212px}to{width:340px}}@keyframes fadeInInputField{0%{opacity:0}60%{opacity:0}to{opacity:1}}.obi-course-progress{display:flex;flex-direction:column;justify-content:center;align-items:flex-start;gap:6px;width:100%;min-width:0;height:24px;flex:none;order:1;align-self:stretch;flex-grow:0}.obi-course-progress-steps{display:flex;flex-direction:row;align-items:center;justify-content:space-between;padding:0;gap:2px;width:100%;height:6px;flex:none;order:0;align-self:stretch;flex-grow:0}.obi-course-progress-container{display:flex;flex-direction:column;justify-content:center;align-items:stretch;padding:2px 0;height:6px;flex:1;min-width:0}.obi-course-progress-step{width:100%;height:2px;background:var(--obi-course-progress-step-incomplete);border-radius:24px;flex:none;order:0;align-self:stretch;flex-grow:0}.obi-course-progress-step.completed{background:var(--obi-course-progress-step-completed)}.obi-course-progress-description{width:100%;height:14px;font-family:var(--obi-font-family);font-style:normal;font-weight:500;font-size:14px;line-height:100%;color:var(--obi-course-progress-text-color);flex:none;order:1;flex-grow:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.obi-widget-popout{z-index:400}.obi-widget-panel{display:flex;flex-direction:column;gap:8px;align-items:center;justify-content:center;min-width:222px;width:min-content;padding:12px;box-sizing:border-box;border-radius:27px;background:white;transition:background .1s ease-out .1s,box-shadow .1s ease-out .1s}.obi-widget-panel:not(.messaging){width:256px}.obi-widget-panel.tool-usage{width:384px}.obi-widget-panel:not(.expanded){background:transparent;border:none;box-shadow:none;transition:background .1s ease-out .1s,border .1s ease-out .1s,box-shadow .1s ease-out .1s}.obi-widget-panel.maximized{transform:translateY(-110px)}.obi-widget-panel .obi-widget{display:flex;align-items:center;min-width:192px;padding-left:58px;box-sizing:border-box;gap:4px}.obi-widget-panel .obi-widget.active.in-plan{padding-left:0}.obi-widget-panel .obi-widget.active.in-plan .obi-round-button{animation:fade-in-button .2s ease-out .15s both}.obi-widget-panel .obi-widget.active .obi-equaliser{animation:fade-in-equaliser .2s ease-out .15s both}@keyframes fade-in-button{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes fade-in-equaliser{0%{opacity:0}to{opacity:1}}.obi-widget-panel .obi-course-progress-container{display:none;width:100%;max-height:0;opacity:0;transform:translateY(-10px);overflow:hidden;transition:max-height .3s ease-in-out,opacity .3s ease-in-out,transform .3s ease-in-out}.obi-widget-panel:hover .obi-course-progress-container{display:block;max-width:22 0px;animation:expand-course-progress .3s ease-in-out forwards}.obi-widget-panel:hover .obi-course-progress-container.expanded{max-width:330px}@keyframes expand-course-progress{0%{max-height:0;opacity:0;transform:translateY(-10px)}to{max-height:40px;opacity:1;transform:translateY(0)}}.obi-widget-pill-text{font-size:16px;font-weight:400;color:#fff;opacity:0;animation:fade-in-pill-text .3s ease-in-out forwards}@keyframes fade-in-pill-text{0%{opacity:0}40%{opacity:0}to{opacity:1}}.obi-widget-buttons{display:flex;flex-direction:row;gap:4px}.obi-widget-out-of-plan{display:flex;align-items:center;gap:0}.obi-widget-out-of-plan .text{font-size:16px;color:#fff;display:inline-flex;align-items:center;gap:8px;animation:fade-in-pill-text .3s ease-in-out forwards}.obi-widget-out-of-plan .round-button{display:none;animation:fade-in-button .2s ease-out .15s both}.obi-widget-out-of-plan .message{display:none}.obi-widget-out-of-plan.active{gap:0}.obi-widget-out-of-plan.active:hover,.obi-widget-out-of-plan.active.hover{gap:4px}.obi-widget-out-of-plan.active:hover .round-button,.obi-widget-out-of-plan.active:hover .message,.obi-widget-out-of-plan.active.hover .round-button,.obi-widget-out-of-plan.active.hover .message{display:flex}.obi-static-voice-visual{display:flex;align-items:center;gap:2px;height:32px}.obi-static-voice-visual .column{position:relative;display:flex;align-items:center;justify-content:center;width:5px;height:100%}.obi-static-voice-visual .bar{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:3px;background-color:#fff;border-radius:2px;z-index:1}.obi-static-voice-visual .bar-1{height:2px}.obi-static-voice-visual .bar-2{height:6px}.obi-static-voice-visual .bar-3{height:10px}.obi-static-voice-visual .bar-4,.obi-static-voice-visual .bar-5{height:16px}.obi-static-voice-visual .bar-6{height:10px}.obi-static-voice-visual .bar-7{height:6px}.obi-static-voice-visual .bar-8{height:2px}.tour-select{display:block;font-family:Inter,sans-serif}.course-container{display:flex;padding:20px;align-items:flex-start;gap:8px;height:180px;border-radius:6px;border:1px solid rgba(0,0,0,.6);background:#fff;cursor:pointer;transition:all .2s;flex-direction:column;box-sizing:border-box;overflow:hidden}.course-container:hover{background-color:#f9fafb;border-color:#d1d5db;box-shadow:0 1px 2px #0000000d}.course-container:active{transform:scale(.98)}.course-container.selected{border-radius:6px;border:1px solid var(--obi-course-color-selected);background:var(--obi-course-color-tint)}.course-container.selected:hover{background:var(--obi-course-color-tint)}.header-row{display:flex;justify-content:space-between;align-items:flex-start;align-self:stretch;flex-shrink:0;text-align:left}.course-title{color:#000;font-family:Inter,sans-serif;font-size:20px;font-style:normal;font-weight:500;line-height:100%;letter-spacing:-.2px;margin:0}.duration{display:flex;padding:4px 12px;justify-content:center;align-items:center;gap:8px;border-radius:9999px;background:var(--obi-course-color-tint);color:#000;font-family:Inter,sans-serif;font-size:14px;font-style:normal;font-weight:500;line-height:100%;letter-spacing:-.14px;flex-shrink:0}.course-container.selected .duration{background:#fff}.course-description{flex:1 0 0;color:#0009;font-family:Inter,sans-serif;font-size:16px;font-style:normal;font-weight:400;line-height:140%;letter-spacing:-.16px;margin:0;overflow:hidden;display:-webkit-box;-webkit-line-clamp:4;-webkit-box-orient:vertical;text-align:left}.course-grid{display:grid;grid-template-columns:1fr 1fr 1fr;gap:4px;padding:0;flex:1 0 0;align-self:stretch;min-height:364px}.controls{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px}.tabs{display:flex;gap:10px}.tab{display:flex;padding:6px 12px;justify-content:center;align-items:center;align-self:stretch;border:none;background:none;cursor:pointer;font-family:Inter,sans-serif;font-size:16px;font-weight:500;color:#0006;border-bottom:2px solid transparent;transition:all .2s}.tab.active{color:#000;border-bottom:2px solid var(--obi-color-primary)}.tab:hover{color:#000}.filter{position:relative;display:flex;align-items:center;width:336px;height:40px}.filter input{color:var(--obi-color-text);caret-color:var(--obi-color-text);padding:8px 12px 8px 36px;border-radius:6px;border:1px solid rgba(0,0,0,.1);background:#fff;font-family:Inter,sans-serif;font-size:14px;line-height:20px;width:100%;height:100%;box-sizing:border-box;outline:none}.filter input:focus{outline:1px solid var(--obi-color-primary);outline-offset:-1px}.filter input::placeholder{color:#0006}.filter svg{position:absolute;left:12px;pointer-events:none}@media (max-width: 767px){.course-grid{grid-template-columns:1fr}}.loading,.error,.empty{display:flex;justify-content:center;align-items:center;margin-top:16px}.error{color:#ef4444}.tour-select-modal-container{display:flex;flex-direction:column;align-items:center;gap:24px;flex:1 0 0;align-self:stretch;font-family:Satoshi,sans-serif;color:#000;text-align:center;max-width:1200px;width:100%;min-height:600px;box-sizing:border-box}.course-list-wrapper{flex:1;overflow-y:auto;width:100%;min-height:0;max-height:424px;padding-right:3px;box-sizing:border-box}.course-list-wrapper::-webkit-scrollbar{width:3px}.course-list-wrapper::-webkit-scrollbar-track{background:transparent}.course-list-wrapper::-webkit-scrollbar-thumb{background-color:#000;border-radius:2px;min-height:20px}.course-list-wrapper::-webkit-scrollbar-thumb:hover{background-color:#333}.header{display:flex;align-items:flex-start;gap:16px;width:100%;text-align:left}.icon{display:flex;width:56px;height:56px;padding:12px;justify-content:center;align-items:center;border-radius:12px;border:1px solid var(--obi-color-primary);background:var(--obi-color-primary);box-sizing:border-box}.icon img{width:32px;height:32px;color:#fff;fill:#fff}.title-section{align-self:stretch;flex:1}.tour-select-modal-container h1{color:#18181b;font-family:Satoshi;font-size:32px;font-style:normal;font-weight:700;line-height:90%;letter-spacing:-.96px;margin:0 0 8px}.subtitle{color:#18181b;font-family:Satoshi;font-size:20px;font-style:normal;font-weight:500;line-height:90%;letter-spacing:-.6px;margin:0}.footer{display:flex;width:360px;flex-direction:column;align-items:center;gap:12px}.footer-button{display:flex;height:48px;padding:16px;justify-content:center;align-items:center;gap:8px;align-self:stretch;border-radius:6px;background:#18181b;border:none;cursor:pointer;color:#fafafa;font-family:Satoshi;font-weight:500;transition:opacity .2s ease}.footer-button:disabled{opacity:.5;cursor:not-allowed}.footer-button:not(:disabled){opacity:1}.footer-button:not(:disabled):hover{background:#27272a}.footer-text{color:#18181b;font-family:Satoshi;font-size:12px;font-style:normal;font-weight:400;line-height:100%;letter-spacing:-.12px;margin:0;text-align:center}.skeleton{background:linear-gradient(90deg,#e5e7eb 25%,#f3f4f6 50%,#e5e7eb 75%);background-size:200% 100%;animation:loading 1.5s infinite;border-radius:4px}@keyframes loading{0%{background-position:200% 0}to{background-position:-200% 0}}.skeleton-title{height:32px;width:60%;margin-bottom:12px}.skeleton-subtitle{height:20px;width:80%}
121
- `;function J5(n){let e=n.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"__DOUBLE_STAR__").replace(/\*/g,"[^/]*").replace(/__DOUBLE_STAR__/g,".*").replace(/\?/g,"[^/]");return new RegExp(`^${e}$`,"i")}function Z5(n,e){if(!e||e.length===0)return!1;const t=n.replace(/^https?:\/\//,"").replace(/\/$/,"");return e.some(i=>{try{const r=J5(i);return r.test(t)||r.test(n)}catch(r){return console.warn(`Invalid URL pattern: ${i}`,r),!1}})}function uf(n){if(!n||n.length===0)return!1;const e=window.location.origin+window.location.pathname;return Z5(e,n)}function Q5(n){var C,x,I,P,D,A,L,V,Y;const[e,t]=de(!1),[i,r]=de(!1),[o,s]=de(null),a=e4(n.sdk,c,n.shadowHost,s);function c(O){var F;(F=a.client)!=null&&F.session||(t(O),O&&fe().track("course-list-opened"))}if(!a.client)return null;const u=a.client.planIsCompleted.filter(Boolean).length===a.client.plans.length,l=t4((C=a.client.product)==null?void 0:C.widget_url_blacklist),d=u?a.completedWidgetDisplay||((x=a.client.product)==null?void 0:x.completed_widget_display):a.widgetDisplay||((I=a.client.product)==null?void 0:I.widget_display),h=a.widgetPosition||((P=a.client.product)==null?void 0:P.widget_position);let p=a.isActive;((A=(D=a.client)==null?void 0:D.product)==null?void 0:A.name)==="Canibuild"&&(p=!0);const m=a.client.session,f=!!m,g=f&&!e;let y;switch(m==null?void 0:m.speakingState){case"listening":y="user-speaking";break;case"speaking":y="agent-speaking";break;case"thinking":y="thinking";break;case"busy":y="busy";break}const b=m==null?void 0:m.isPaused,S=f||a.client.state==="ready"&&p&&!l&&(d!=="invisible"||a.client.selectedPlan),w=()=>{var O,F,X,K,Q,Ce;return{name:(O=a.client.selectedPlan)==null?void 0:O.name,description:(F=a.client.selectedPlan)==null?void 0:F.description,appName:(X=a.client.product)==null?void 0:X.name,appLogoUrl:((K=a.client.product)==null?void 0:K.logo_url)||"",url:(Q=a.client.product)==null?void 0:Q.url,agentName:((Ce=a.client.product)==null?void 0:Ce.agent_name)||"Obi"}},k=h==="bottom-right"?{position:"fixed",right:"250px",width:"max-content",transform:"translateX(50%)"}:{position:"fixed",left:"50%",transform:"translateX(-50%)",width:"max-content"};return g?k.top="calc(100vh - 100px)":k.bottom="20px",_("div",{children:[e&&_(NC,{open:e,courses:a.client.plans.map((O,F)=>{var X,K;return{id:O.uuid,name:O.name,description:O.description||"",duration:O.duration||0,completed:((K=(X=a.client)==null?void 0:X.planIsCompleted)==null?void 0:K[F])||!1}}),loading:!1,agentName:((L=a.client.product)==null?void 0:L.agent_name)||"Obi",productName:((V=a.client.product)==null?void 0:V.name)||"",onCourseHighlight:O=>{O&&fe().track("course-selected",{courseName:O.name,courseUuid:O.id})},onCourseSelect:O=>{const F=a.client.plans.find(X=>X.uuid===O.id)||null;F&&(F==null?void 0:F.uuid)!==a.client.selectedPlanUuid&&(a.client.selectPlan(F),t(!1),r(!0),fe().track("course-get-started",{courseName:O.name,courseUuid:O.id}))},onClose:O=>{O==="user-initiated"&&a.client.selectPlan(null),t(!1)}}),S&&_(St,{children:[_("div",{style:k,children:_(mC,{inPlan:f,isActive:i?!1:void 0,defaultIsActive:d!=="minimized",isPaused:b,messaging:(m==null?void 0:m.isMicShared)===!1?!0:void 0,speakingStatus:y,spectrum:()=>(m==null?void 0:m.audioSpectrum())||null,courseProgress:o,onOpen:()=>{t(!0),fe().track("course-list-opened")},onCancelClick:()=>{fe().track("close-button-clicked")},onCancelAbort:()=>{fe().track("close-confirmation-no")},onCancel:()=>{var O;(O=a.client.session)==null||O.stop(),fe().track("close-confirmation-yes")},onCancelReason:(O,F)=>{fe().track("close-survey-answered",{reason:O,reasonText:F})},onPause:()=>{var O,F;(F=(O=a.client.session)==null?void 0:O.pause)==null||F.call(O),fe().track("pause-button-clicked")},onUnpause:()=>{var O,F;(F=(O=a.client.session)==null?void 0:O.unpause)==null||F.call(O),fe().track("play-button-clicked")},onMessagingChange:O=>{var F,X,K,Q;O?((X=(F=a.client.session)==null?void 0:F.muteMicrophone)==null||X.call(F),fe().track("switch-to-chat-clicked")):((Q=(K=a.client.session)==null?void 0:K.unmuteMicrophone)==null||Q.call(K),fe().track("switch-to-voice-clicked"))},onMessageChange:O=>{fe().track("chat-input-provided",{message:O,length:O.length})},onMessage:O=>{a.say(O),fe().track("chat-message-sent",{message:O,length:O.length})},onHover:O=>{O&&!f&&fe().track("widget-hover-on")},onOneClickAction:O=>{fe().track("one-click-action-clicked",{action:O})},onMinimize:()=>{fe().track("minimise-button-clicked",{inSession:f})},agentName:((Y=a.client.product)==null?void 0:Y.agent_name)||"Obi",completedTutorials:a.client.planIsCompleted.filter(Boolean).length,totalTutorials:a.client.plans.length})}),!!a.client.selectedPlan&&_(LC,{open:!0,session:w(),sessionState:(m==null?void 0:m.state)||null,speakingState:(m==null?void 0:m.speakingState)||null,spectrum:()=>(m==null?void 0:m.audioSpectrum())||null,onModalChange:O=>{O==="session-start"?fe().track("course-screen-opened"):O==="voice-guidance"?fe().track("can-you-hear-opened"):O==="overview"?fe().track("welcome-tour-opened"):O==="share-mic"&&fe().track("connect-mic-opened")},onClose:(O,F)=>{var X,K;O==="user-initiated"&&(F==="session-start"?fe().track("course-screen-closed"):F==="voice-guidance"?fe().track("can-you-hear-closed"):F==="overview"?fe().track("welcome-tour-closed"):F==="share-mic"&&fe().track("connect-mic-closed"),((X=a.client.session)==null?void 0:X.state)==="mic-share"?(K=a.client.session)==null||K.shareMicrophoneFailed():a.client.stopSession()),r(!1)},onStart:()=>{a.client.selectedPlanUuid&&(fe().track("course-screen-continue"),a.startSession())},onContinue:()=>{m==null||m.continue(),fe().track("can-you-hear-continue")},onShareMicrophone:()=>{m==null||m.shareMicrophone(),fe().track("connect-mic-continue")}})]})]})}function e4(n,e,t,i){const[r,o]=de(0),[s,a]=de(null);return Dt(()=>{n.on("showMenu",c=>{e(c)}),n.on("configUpdated",()=>{o(c=>c+1)})},[n]),Dt(()=>{n.client&&(n.client.session&&a(n.client.session),n.client.on("sessionStarted",c=>{a(c),o(u=>u+1)}),n.client.on("sessionStopped",()=>{a(null),o(c=>c+1)}),n.client.on("sessionShutdown",()=>{o(c=>c+1)}),n.client.on("sessionResumed",()=>{o(c=>c+1)}),n.client.on("stateChanged",()=>{var c;n.client.state==="ready"&&t.style.setProperty("--obi-color-primary",((c=n.client.product)==null?void 0:c.primary_color)||"#9500FF"),o(u=>u+1)}),n.client.on("planSelected",()=>{o(c=>c+1)}))},[n,n.client]),Dt(()=>{if(!s)return;s.on("stateChanged",()=>{o(u=>u+1)}),s.on("speakingStateChanged",()=>{o(u=>u+1)}),s.on("paused",()=>{o(u=>u+1)}),s.on("unpaused",()=>{o(u=>u+1)}),s.on("micCheckComplete",u=>{u?fe().track("mic-check-granted"):fe().track("mic-check-denied")}),s.on("transcript",(u,l)=>{l==="user"&&fe().track("user-transcript",{transcript:u,role:l})});const c=u=>{i(u)};return s.on&&s.on("courseProgress",c),()=>{s.off&&s.off("courseProgress",c)}},[s]),n}function t4(n){const[e,t]=de(()=>uf(n));return Dt(()=>{t(uf(n))},[n]),Dt(()=>{n4();const i=()=>{t(uf(n))};return window.addEventListener("locationchange",i),window.addEventListener("popstate",i),window.addEventListener("hashchange",i),()=>{window.removeEventListener("locationchange",i),window.removeEventListener("popstate",i),window.removeEventListener("hashchange",i)}},[n]),e}function n4(){const n=window;if(n.__obi_history_patched)return;const{pushState:e,replaceState:t}=window.history,i=r=>function(...o){const s=r.apply(this,o);return window.dispatchEvent(new Event("locationchange")),s};window.history.pushState=i(e),window.history.replaceState=i(t),n.__obi_history_patched=!0}function i4(n){if(document.querySelector("obi-widget"))return;r4();const e=document.createElement("div");e.id="obi-host",e.style.position="fixed",e.style.zIndex="9999",document.body.appendChild(e);const t=e.attachShadow({mode:"open"}),i=document.createElement("div");i.id="obi-container",t.appendChild(i);const r=new CSSStyleSheet;r.replaceSync(X5),t.adoptedStyleSheets=[r],Nw(_(Q5,{sdk:n,shadowHost:e}),i),console.log("[obi-sdk] widget mounted")}function r4(){bw("https://fonts.cdnfonts.com/css/satoshi"),bw("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap")}function bw(n){const e=document.createElement("link");e.href=n,e.rel="stylesheet",document.head.appendChild(e)}const _w="49206C6F7665204F6269_session",kw="obi-url-params";class o4 extends nh{constructor(e){super(),this.client=null,this.isActive=!1,this.primaryColour="#9500FF",this.passivePlanUuid=null,this.commandLog=[],this.commandQueue=[],this._resumed=!1,this.dispatchCommand=(t,i)=>{var r,o,s,a,c;switch(this.commandLog.push({commandType:t,args:i}),t){case"update":this.updateConfig(i);break;case"startSession":if(!(i!=null&&i.planUuid)){console.warn("[obi] startSession command requires a planUuid",i);return}const u=(((r=this.client)==null?void 0:r.plans)||[]).find(l=>l.uuid===i.planUuid)||null;if(!u){console.warn("[obi] startSession command requires a valid planUuid",i);return}this.updateActive(!0),(s=(o=this.client)==null?void 0:o.selectPlan)==null||s.call(o,u);break;case"stopSession":(c=(a=this.client)==null?void 0:a.stopSession)==null||c.call(a);break;case"say":this.say(i);break;default:console.warn("[obi] unknown command",{commandType:t,args:i})}},e&&this.createClient(e),this.parsePassiveParams()}async createClient(e){if(this.client){this.client.appToken!==e&&console.warn("[obi] client already exists with different app token");return}let t=null;const i=this.load();if(i)try{t=Eu.deserialise(i,e,"sdk",{apiBaseUrl:"https://app.coragents.ai",captureScreen:this.captureScreen.bind(this)}),this._resumed=!0}catch(r){console.error("[obi] error loading cached client",r)}t||(t=new Eu(e,"sdk",{apiBaseUrl:"https://app.coragents.ai",captureScreen:this.captureScreen.bind(this)})),this.client=t,this.client.on("stateChanged",r=>{var o,s,a,c,u,l,d,h,p;r==="ready"&&this.updateConfig({isActive:(o=this.client)==null?void 0:o.showWidget,primaryColour:((a=(s=this.client)==null?void 0:s.product)==null?void 0:a.primary_color)||"#9500FF",widgetDisplay:((c=window==null?void 0:window.obiWidgetConfig)==null?void 0:c.widgetDisplay)||((l=(u=this.client)==null?void 0:u.product)==null?void 0:l.widget_display)||"regular",completedWidgetDisplay:((d=window==null?void 0:window.obiWidgetConfig)==null?void 0:d.completedWidgetDisplay)||((p=(h=this.client)==null?void 0:h.product)==null?void 0:p.completed_widget_display)||"regular"})}),this.client.on("sessionStarted",()=>{this.save(),this.passivePlanUuid=null}),this.client.on("sessionStopped",()=>{localStorage.removeItem("obi-client"),this.passivePlanUuid=null}),this.client.on("sessionShutdown",r=>{r==="invalid-room"&&localStorage.removeItem("obi-client")}),this.client.on("trackEvent",(r,o)=>{fe().track(r,o)}),this.client.session&&this.client.resumeSession(r=>{r.on("stateChanged",o=>{o!=="disconnecting"&&o!=="disconnected"&&o!=="error"&&o!=="connecting"&&this.save()}),r.on("paused",()=>{this.save()}),r.on("unpaused",()=>{this.save()})})}async initialise(e={}){this.commandQueue=e.queuedCommands||[],this._resumed?(this._resumed=!1,this.dispatchCommandQueue()):this.client?this.client.initialise({planUuid:this.passivePlanUuid||void 0}).then(()=>{this.emit("initialised"),this.dispatchCommandQueue()}).catch(t=>{console.error("[obi] error initialising client",t),this.emit("error",t)}):this.dispatchCommandQueue()}async updateConfig(e){await this.updateAppToken(e.apiKey),this.updateActive(e.isActive),this.updatePrimaryColour(e.primaryColour),this.updateWidgetDisplay(e.widgetDisplay),this.updateCompletedWidgetDisplay(e.completedWidgetDisplay),this.updateWidgetPosition(e.widgetPosition),await this.updateIdentity(e.user),this.updateShowMenu(e.showMenu),this.emit("configUpdated")}async updateAppToken(e){var t;e===void 0||e==((t=this.client)==null?void 0:t.appToken)||(this.passivePlanUuid,await this.createClient(e),this.client&&await this.client.initialise({planUuid:this.passivePlanUuid||void 0}).then(()=>{this.emit("initialised")}).catch(i=>{console.error("[obi] error initialising client",i),this.emit("error",i)}))}updateActive(e){e===void 0||e==this.isActive||(this.isActive=e)}updatePrimaryColour(e){e===void 0||e==this.primaryColour||(this.primaryColour=e)}updateWidgetDisplay(e){e===void 0||e==this.widgetDisplay||(this.widgetDisplay=e)}updateCompletedWidgetDisplay(e){e===void 0||e==this.completedWidgetDisplay||(this.completedWidgetDisplay=e)}updateWidgetPosition(e){e===void 0||e==this.widgetPosition||(this.widgetPosition=e)}async updateIdentity(e){var i;if(e===void 0||e==((i=this.client)==null?void 0:i.identity))return;let t=e?{...e,extra:{...e,...(e==null?void 0:e.extra)||{}}}:void 0;await this.client.initialise({identity:t,planUuid:this.passivePlanUuid||void 0}).then(()=>{this.emit("initialised")}).catch(r=>{console.error("[obi] error initialising client",r),this.emit("error",r)}),e!=null&&e.email&&fe().identify((e==null?void 0:e.email)||"",t)}updateShowMenu(e){e!==void 0&&this.emit("showMenu",e)}async say(e){var t,i,r;await((r=(i=(t=this.client)==null?void 0:t.session)==null?void 0:i.say)==null?void 0:r.call(i,e))}async startSession(){await this.client.startSession(this.client.selectedPlan.uuid,e=>{e.on("stateChanged",t=>{t!=="disconnecting"&&t!=="disconnected"&&t!=="error"&&t!=="connecting"&&this.save()})})}dispatchCommandQueue(){const e=this.commandQueue;this.commandQueue=[],e.forEach(t=>{try{this.dispatchCommand(t[0],t[1]||[])}catch(i){console.error("[obi] error dispatching command",i)}})}parsePassiveParams(){if(this.passivePlanUuid){this.passivePlanUuid;return}let e={};e=JSON.parse(localStorage.getItem(kw)||"{}"),Object.keys(e).length===0&&new URLSearchParams(window.location.search).forEach((o,s)=>{e[s]=o});const t=e[_w];if(!t)return null;const i=new URL(window.location.href);i.searchParams.delete(_w),window.history.replaceState({},"",i.toString()),i.toString(),localStorage.removeItem(kw),this.passivePlanUuid=t}mountWidget(){i4(this)}async captureScreen(){try{await I5(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.text_segmentation)),await Y5(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.css_line_breaks))}catch(e){throw console.error("[obi] error initialising unicode trie",e),e}try{return(await _D(document.documentElement,{useCORS:!0,allowTaint:!0,foreignObjectRendering:!0})).toDataURL("image/png")}catch(e){throw console.error("[obi] error capturing screen",e),e}}save(){var e;localStorage.setItem("obi-client",((e=this.client)==null?void 0:e.serialise())||"")}load(){return localStorage.getItem("obi-client")}}async function Sw(n,e){let t;try{t=window}catch{console.warn("[obi] no window object found"),t={}}return s4({appToken:n,window:t,init:e})}async function s4({appToken:n,window:e,init:t}){var o,s;if(e.obi){console.warn("[obi] obi object already found on window, skipping");return}t&&t(),n||(n=(o=e==null?void 0:e.obiWidgetConfig)==null?void 0:o.apiKey);let i;try{i=((s=e.ObiSDK)==null?void 0:s.q)||[]}catch{i=[]}const r=new o4(n);return e.ObiSDK=r.dispatchCommand,await r.initialise({queuedCommands:i}),e.obi=r,r.mountWidget(),r}function ww(){FC(DP("d37cde23ca4b5d8c7ed30653f07f9e47"))}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{Sw(void 0,ww)}):Sw(void 0,ww)})();
42
+ `},co}var lh;function NT(){if(lh)return lt;lh=1;var n=OT(),e=AT(),t=oo();return lt.grammar=t,lt.write=e,lt.parse=n.parse,lt.parseParams=n.parseParams,lt.parseFmtpConfig=n.parseFmtpConfig,lt.parsePayloads=n.parsePayloads,lt.parseRemoteCandidates=n.parseRemoteCandidates,lt.parseImageAttributes=n.parseImageAttributes,lt.parseSimulcastStreamList=n.parseSimulcastStreamList,lt}var Zt=NT();function lo(n,e,t){var i,r,s;e===void 0&&(e=50),t===void 0&&(t={});var a=(i=t.isImmediate)!=null&&i,o=(r=t.callback)!=null&&r,c=t.maxWait,l=Date.now(),u=[];function d(){if(c!==void 0){var f=Date.now()-l;if(f+e>=c)return c-f}return e}var h=function(){var f=[].slice.call(arguments),p=this;return new Promise(function(g,v){var b=a&&s===void 0;if(s!==void 0&&clearTimeout(s),s=setTimeout(function(){if(s=void 0,l=Date.now(),!a){var x=n.apply(p,f);o&&o(x),u.forEach(function(k){return(0,k.resolve)(x)}),u=[]}},d()),b){var S=n.apply(p,f);return o&&o(S),g(S)}u.push({resolve:g,reject:v})})};return h.cancel=function(f){s!==void 0&&clearTimeout(s),u.forEach(function(p){return(0,p.reject)(f)}),u=[]},h}const MT=.7,LT=20,Hn={NegotiationStarted:"negotiationStarted",NegotiationComplete:"negotiationComplete",RTPVideoPayloadTypes:"rtpVideoPayloadTypes"};class uh extends Tt.EventEmitter{get pc(){return this._pc||(this._pc=this.createPC()),this._pc}constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var i;super(),this.log=q,this.ddExtID=0,this.pendingCandidates=[],this.restartingIce=!1,this.renegotiate=!1,this.trackBitrates=[],this.remoteStereoMids=[],this.remoteNackMids=[],this.negotiate=lo(r=>y(this,void 0,void 0,function*(){this.emit(Hn.NegotiationStarted);try{yield this.createAndSendOffer()}catch(s){if(r)r(s);else throw s}}),LT),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=Et((i=t.loggerName)!==null&&i!==void 0?i:ot.PCTransport),this.loggerOptions=t,this.config=e,this._pc=this.createPC()}createPC(){const e=new RTCPeerConnection(this.config);return e.onicecandidate=t=>{var i;t.candidate&&((i=this.onIceCandidate)===null||i===void 0||i.call(this,t.candidate))},e.onicecandidateerror=t=>{var i;(i=this.onIceCandidateError)===null||i===void 0||i.call(this,t)},e.oniceconnectionstatechange=()=>{var t;(t=this.onIceConnectionStateChange)===null||t===void 0||t.call(this,e.iceConnectionState)},e.onsignalingstatechange=()=>{var t;(t=this.onSignalingStatechange)===null||t===void 0||t.call(this,e.signalingState)},e.onconnectionstatechange=()=>{var t;(t=this.onConnectionStateChange)===null||t===void 0||t.call(this,e.connectionState)},e.ondatachannel=t=>{var i;(i=this.onDataChannel)===null||i===void 0||i.call(this,t)},e.ontrack=t=>{var i;(i=this.onTrack)===null||i===void 0||i.call(this,t)},e}get logContext(){var e,t;return Object.assign({},(t=(e=this.loggerOptions).loggerContextCb)===null||t===void 0?void 0:t.call(e))}get isICEConnected(){return this._pc!==null&&(this.pc.iceConnectionState==="connected"||this.pc.iceConnectionState==="completed")}addIceCandidate(e){return y(this,void 0,void 0,function*(){if(this.pc.remoteDescription&&!this.restartingIce)return this.pc.addIceCandidate(e);this.pendingCandidates.push(e)})}setRemoteDescription(e){return y(this,void 0,void 0,function*(){var t;let i;if(e.type==="offer"){let{stereoMids:r,nackMids:s}=DT(e);this.remoteStereoMids=r,this.remoteNackMids=s}else if(e.type==="answer"){const r=Zt.parse((t=e.sdp)!==null&&t!==void 0?t:"");r.media.forEach(s=>{s.type==="audio"&&this.trackBitrates.some(a=>{if(!a.transceiver||s.mid!=a.transceiver.mid)return!1;let o=0;if(s.rtp.some(l=>l.codec.toUpperCase()===a.codec.toUpperCase()?(o=l.payload,!0):!1),o===0)return!0;let c=!1;for(const l of s.fmtp)if(l.payload===o){l.config=l.config.split(";").filter(u=>!u.includes("maxaveragebitrate")).join(";"),a.maxbr>0&&(l.config+=";maxaveragebitrate=".concat(a.maxbr*1e3)),c=!0;break}return c||a.maxbr>0&&s.fmtp.push({payload:o,config:"maxaveragebitrate=".concat(a.maxbr*1e3)}),!0})}),i=Zt.write(r)}yield this.setMungedSDP(e,i,!0),this.pendingCandidates.forEach(r=>{this.pc.addIceCandidate(r)}),this.pendingCandidates=[],this.restartingIce=!1,this.renegotiate?(this.renegotiate=!1,yield this.createAndSendOffer()):e.type==="answer"&&(this.emit(Hn.NegotiationComplete),e.sdp&&Zt.parse(e.sdp).media.forEach(s=>{s.type==="video"&&this.emit(Hn.RTPVideoPayloadTypes,s.rtp)}))})}createAndSendOffer(e){return y(this,void 0,void 0,function*(){var t;if(this.onOffer===void 0)return;if(e!=null&&e.iceRestart&&(this.log.debug("restarting ICE",this.logContext),this.restartingIce=!0),this._pc&&this._pc.signalingState==="have-local-offer"){const s=this._pc.remoteDescription;if(e!=null&&e.iceRestart&&s)yield this._pc.setRemoteDescription(s);else{this.renegotiate=!0;return}}else if(!this._pc||this._pc.signalingState==="closed"){this.log.warn("could not createOffer with closed peer connection",this.logContext);return}this.log.debug("starting to negotiate",this.logContext);const i=yield this.pc.createOffer(e);this.log.debug("original offer",Object.assign({sdp:i.sdp},this.logContext));const r=Zt.parse((t=i.sdp)!==null&&t!==void 0?t:"");r.media.forEach(s=>{hh(s),s.type==="audio"?dh(s,[],[]):s.type==="video"&&this.trackBitrates.some(a=>{if(!s.msid||!a.cid||!s.msid.includes(a.cid))return!1;let o=0;if(s.rtp.some(l=>l.codec.toUpperCase()===a.codec.toUpperCase()?(o=l.payload,!0):!1),o===0||(yi(a.codec)&&this.ensureVideoDDExtensionForSVC(s,r),a.codec!=="av1"))return!0;const c=Math.round(a.maxbr*MT);for(const l of s.fmtp)if(l.payload===o){l.config.includes("x-google-start-bitrate")||(l.config+=";x-google-start-bitrate=".concat(c));break}return!0})}),yield this.setMungedSDP(i,Zt.write(r)),this.onOffer(i)})}createAndSetAnswer(){return y(this,void 0,void 0,function*(){var e;const t=yield this.pc.createAnswer(),i=Zt.parse((e=t.sdp)!==null&&e!==void 0?e:"");return i.media.forEach(r=>{hh(r),r.type==="audio"&&dh(r,this.remoteStereoMids,this.remoteNackMids)}),yield this.setMungedSDP(t,Zt.write(i)),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 Ce("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 Ce("PC closed, cannot configure");return(t=this._pc)===null||t===void 0?void 0:t.setConfiguration(e)}canRemoveTrack(){var e;return!!(!((e=this._pc)===null||e===void 0)&&e.removeTrack)}removeTrack(e){var t;return(t=this._pc)===null||t===void 0?void 0:t.removeTrack(e)}getConnectionState(){var e,t;return(t=(e=this._pc)===null||e===void 0?void 0:e.connectionState)!==null&&t!==void 0?t:"closed"}getICEConnectionState(){var e,t;return(t=(e=this._pc)===null||e===void 0?void 0:e.iceConnectionState)!==null&&t!==void 0?t:"closed"}getSignallingState(){var e,t;return(t=(e=this._pc)===null||e===void 0?void 0:e.signalingState)!==null&&t!==void 0?t:"closed"}getTransceivers(){var e,t;return(t=(e=this._pc)===null||e===void 0?void 0:e.getTransceivers())!==null&&t!==void 0?t:[]}getSenders(){var e,t;return(t=(e=this._pc)===null||e===void 0?void 0:e.getSenders())!==null&&t!==void 0?t:[]}getLocalDescription(){var e;return(e=this._pc)===null||e===void 0?void 0:e.localDescription}getRemoteDescription(){var e;return(e=this.pc)===null||e===void 0?void 0:e.remoteDescription}getStats(){return this.pc.getStats()}getConnectedAddress(){return y(this,void 0,void 0,function*(){var e;if(!this._pc)return;let t="";const i=new Map,r=new Map;if((yield this._pc.getStats()).forEach(o=>{switch(o.type){case"transport":t=o.selectedCandidatePairId;break;case"candidate-pair":t===""&&o.selected&&(t=o.id),i.set(o.id,o);break;case"remote-candidate":r.set(o.id,"".concat(o.address,":").concat(o.port));break}}),t==="")return;const a=(e=i.get(t))===null||e===void 0?void 0:e.remoteCandidateId;if(a!==void 0)return r.get(a)})}setMungedSDP(e,t,i){return y(this,void 0,void 0,function*(){if(t){const r=e.sdp;e.sdp=t;try{this.log.debug("setting munged ".concat(i?"remote":"local"," description"),this.logContext),i?yield this.pc.setRemoteDescription(e):yield this.pc.setLocalDescription(e);return}catch(s){this.log.warn("not able to set ".concat(e.type,", falling back to unmodified sdp"),Object.assign(Object.assign({},this.logContext),{error:s,sdp:t})),e.sdp=r}}try{i?yield this.pc.setRemoteDescription(e):yield this.pc.setLocalDescription(e)}catch(r){let s="unknown error";r instanceof Error?s=r.message:typeof r=="string"&&(s=r);const a={error:s,sdp:e.sdp};throw!i&&this.pc.remoteDescription&&(a.remoteSdp=this.pc.remoteDescription),this.log.error("unable to set ".concat(e.type),Object.assign(Object.assign({},this.logContext),{fields:a})),new Ua(s)}})}ensureVideoDDExtensionForSVC(e,t){var i,r;if(!((i=e.ext)===null||i===void 0?void 0:i.some(a=>a.uri===zd))){if(this.ddExtID===0){let a=0;t.media.forEach(o=>{var c;o.type==="video"&&((c=o.ext)===null||c===void 0||c.forEach(l=>{l.value>a&&(a=l.value)}))}),this.ddExtID=a+1}(r=e.ext)===null||r===void 0||r.push({value:this.ddExtID,uri:zd})}}}function dh(n,e,t){let i=0;n.rtp.some(r=>r.codec==="opus"?(i=r.payload,!0):!1),i>0&&(n.rtcpFb||(n.rtcpFb=[]),t.includes(n.mid)&&!n.rtcpFb.some(r=>r.payload===i&&r.type==="nack")&&n.rtcpFb.push({payload:i,type:"nack"}),e.includes(n.mid)&&n.fmtp.some(r=>r.payload===i?(r.config.includes("stereo=1")||(r.config+=";stereo=1"),!0):!1))}function DT(n){var e;const t=[],i=[],r=Zt.parse((e=n.sdp)!==null&&e!==void 0?e:"");let s=0;return r.media.forEach(a=>{var o;a.type==="audio"&&(a.rtp.some(c=>c.codec==="opus"?(s=c.payload,!0):!1),!((o=a.rtcpFb)===null||o===void 0)&&o.some(c=>c.payload===s&&c.type==="nack")&&i.push(a.mid),a.fmtp.some(c=>c.payload===s?(c.config.includes("sprop-stereo=1")&&t.push(a.mid),!0):!1))}),{stereoMids:t,nackMids:i}}function hh(n){if(n.connection){const e=n.connection.ip.indexOf(":")>=0;(n.connection.version===4&&e||n.connection.version===6&&!e)&&(n.connection.ip="0.0.0.0",n.connection.version=4)}}const uo="vp8",UT={audioPreset:Va.music,dtx:!0,red:!0,forceStereo:!1,simulcast:!0,screenShareEncoding:Wa.h1080fps15.encoding,stopMicTrackOnMute:!1,videoCodec:uo,backupCodec:!0},fh={deviceId:{ideal:"default"},autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0,voiceIsolation:!0},ph={deviceId:{ideal:"default"},resolution:bi.h720.resolution},BT={adaptiveStream:!1,dynacast:!1,stopLocalTrackOnUnpublish:!0,reconnectPolicy:new Pk,disconnectOnPageLeave:!0,webAudioMix:!1},ho={autoSubscribe:!0,maxRetries:1,peerConnectionTimeout:15e3,websocketTimeout:15e3};var fe;(function(n){n[n.NEW=0]="NEW",n[n.CONNECTING=1]="CONNECTING",n[n.CONNECTED=2]="CONNECTED",n[n.FAILED=3]="FAILED",n[n.CLOSING=4]="CLOSING",n[n.CLOSED=5]="CLOSED"})(fe||(fe={}));class FT{get needsPublisher(){return this.isPublisherConnectionRequired}get needsSubscriber(){return this.isSubscriberConnectionRequired}get currentState(){return this.state}constructor(e,t,i){var r;this.peerConnectionTimeout=ho.peerConnectionTimeout,this.log=q,this.updateState=()=>{var s;const a=this.state,o=this.requiredTransports.map(c=>c.getConnectionState());o.every(c=>c==="connected")?this.state=fe.CONNECTED:o.some(c=>c==="failed")?this.state=fe.FAILED:o.some(c=>c==="connecting")?this.state=fe.CONNECTING:o.every(c=>c==="closed")?this.state=fe.CLOSED:o.some(c=>c==="closed")?this.state=fe.CLOSING:o.every(c=>c==="new")&&(this.state=fe.NEW),a!==this.state&&(this.log.debug("pc state change: from ".concat(fe[a]," to ").concat(fe[this.state]),this.logContext),(s=this.onStateChange)===null||s===void 0||s.call(this,this.state,this.publisher.getConnectionState(),this.subscriber.getConnectionState()))},this.log=Et((r=i.loggerName)!==null&&r!==void 0?r:ot.PCManager),this.loggerOptions=i,this.isPublisherConnectionRequired=!t,this.isSubscriberConnectionRequired=t,this.publisher=new uh(e,i),this.subscriber=new uh(e,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=s=>{var a;(a=this.onIceCandidate)===null||a===void 0||a.call(this,s,at.PUBLISHER)},this.subscriber.onIceCandidate=s=>{var a;(a=this.onIceCandidate)===null||a===void 0||a.call(this,s,at.SUBSCRIBER)},this.subscriber.onDataChannel=s=>{var a;(a=this.onDataChannel)===null||a===void 0||a.call(this,s)},this.subscriber.onTrack=s=>{var a;(a=this.onTrack)===null||a===void 0||a.call(this,s)},this.publisher.onOffer=s=>{var a;(a=this.onPublisherOffer)===null||a===void 0||a.call(this,s)},this.state=fe.NEW,this.connectionLock=new Fe,this.remoteOfferLock=new Fe}get logContext(){var e,t;return Object.assign({},(t=(e=this.loggerOptions).loggerContextCb)===null||t===void 0?void 0:t.call(e))}requirePublisher(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.isPublisherConnectionRequired=e,this.updateState()}requireSubscriber(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!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 y(this,void 0,void 0,function*(){if(this.publisher&&this.publisher.getSignallingState()!=="closed"){const e=this.publisher;for(const t of e.getSenders())try{e.canRemoveTrack()&&e.removeTrack(t)}catch(i){this.log.warn("could not removeTrack",Object.assign(Object.assign({},this.logContext),{error:i}))}}yield Promise.all([this.publisher.close(),this.subscriber.close()]),this.updateState()})}triggerIceRestart(){return y(this,void 0,void 0,function*(){this.subscriber.restartingIce=!0,this.needsPublisher&&(yield this.createAndSendPublisherOffer({iceRestart:!0}))})}addIceCandidate(e,t){return y(this,void 0,void 0,function*(){t===at.PUBLISHER?yield this.publisher.addIceCandidate(e):yield this.subscriber.addIceCandidate(e)})}createSubscriberAnswerFromOffer(e){return y(this,void 0,void 0,function*(){this.log.debug("received server offer",Object.assign(Object.assign({},this.logContext),{RTCSdpType:e.type,sdp:e.sdp,signalingState:this.subscriber.getSignallingState().toString()}));const t=yield this.remoteOfferLock.lock();try{return yield this.subscriber.setRemoteDescription(e),yield this.subscriber.createAndSetAnswer()}finally{t()}})}updateConfiguration(e,t){this.publisher.setConfiguration(e),this.subscriber.setConfiguration(e),t&&this.triggerIceRestart()}ensurePCTransportConnection(e,t){return y(this,void 0,void 0,function*(){var i;const r=yield this.connectionLock.lock();try{this.isPublisherConnectionRequired&&this.publisher.getConnectionState()!=="connected"&&this.publisher.getConnectionState()!=="connecting"&&(this.log.debug("negotiation required, start negotiating",this.logContext),this.publisher.negotiate()),yield Promise.all((i=this.requiredTransports)===null||i===void 0?void 0:i.map(s=>this.ensureTransportConnected(s,e,t)))}finally{r()}})}negotiate(e){return y(this,void 0,void 0,function*(){return new Promise((t,i)=>y(this,void 0,void 0,function*(){const r=setTimeout(()=>{i("negotiation timed out")},this.peerConnectionTimeout),s=()=>{clearTimeout(r),i("negotiation aborted")};e.signal.addEventListener("abort",s),this.publisher.once(Hn.NegotiationStarted,()=>{e.signal.aborted||this.publisher.once(Hn.NegotiationComplete,()=>{clearTimeout(r),t()})}),yield this.publisher.negotiate(a=>{clearTimeout(r),i(a)})}))})}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===at.PUBLISHER?this.publisher.getConnectedAddress():e===at.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){return y(this,arguments,void 0,function(i,r){var s=this;let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.peerConnectionTimeout;return function*(){if(i.getConnectionState()!=="connected")return new Promise((c,l)=>y(s,void 0,void 0,function*(){const u=()=>{this.log.warn("abort transport connection",this.logContext),Ie.clearTimeout(d),l(new ie("room connection has been cancelled",$.Cancelled))};r!=null&&r.signal.aborted&&u(),r==null||r.signal.addEventListener("abort",u);const d=Ie.setTimeout(()=>{r==null||r.signal.removeEventListener("abort",u),l(new ie("could not establish pc connection",$.InternalError))},a);for(;this.state!==fe.CONNECTED;)if(yield Ge(50),r!=null&&r.signal.aborted){l(new ie("room connection has been cancelled",$.Cancelled));return}Ie.clearTimeout(d),r==null||r.signal.removeEventListener("abort",u),c()}))}()})}}class pe extends Error{constructor(e,t,i){super(t),this.code=e,this.message=gh(t,pe.MAX_MESSAGE_BYTES),this.data=i?gh(i,pe.MAX_DATA_BYTES):void 0}static fromProto(e){return new pe(e.code,e.message,e.data)}toProto(){return new Ou({code:this.code,message:this.message,data:this.data})}static builtIn(e,t){return new pe(pe.ErrorCode[e],pe.ErrorMessage[e],t)}}pe.MAX_MESSAGE_BYTES=256,pe.MAX_DATA_BYTES=15360,pe.ErrorCode={APPLICATION_ERROR:1500,CONNECTION_TIMEOUT:1501,RESPONSE_TIMEOUT:1502,RECIPIENT_DISCONNECTED:1503,RESPONSE_PAYLOAD_TOO_LARGE:1504,SEND_FAILED:1505,UNSUPPORTED_METHOD:1400,RECIPIENT_NOT_FOUND:1401,REQUEST_PAYLOAD_TOO_LARGE:1402,UNSUPPORTED_SERVER:1403,UNSUPPORTED_VERSION:1404},pe.ErrorMessage={APPLICATION_ERROR:"Application error in method handler",CONNECTION_TIMEOUT:"Connection timeout",RESPONSE_TIMEOUT:"Response timeout",RECIPIENT_DISCONNECTED:"Recipient disconnected",RESPONSE_PAYLOAD_TOO_LARGE:"Response payload too large",SEND_FAILED:"Failed to send",UNSUPPORTED_METHOD:"Method not supported at destination",RECIPIENT_NOT_FOUND:"Recipient not found",REQUEST_PAYLOAD_TOO_LARGE:"Request payload too large",UNSUPPORTED_SERVER:"RPC not supported by server",UNSUPPORTED_VERSION:"Unsupported RPC version"};const mh=15360;function fo(n){return new TextEncoder().encode(n).length}function gh(n,e){if(fo(n)<=e)return n;let t=0,i=n.length;const r=new TextEncoder;for(;t<i;){const s=Math.floor((t+i+1)/2);r.encode(n.slice(0,s)).length<=e?t=s:i=s-1}return n.slice(0,t)}const po=2e3;function Qr(n,e){if(!e)return 0;let t,i;return"bytesReceived"in n?(t=n.bytesReceived,i=e.bytesReceived):"bytesSent"in n&&(t=n.bytesSent,i=e.bytesSent),t===void 0||i===void 0||n.timestamp===void 0||e.timestamp===void 0?0:(t-i)*8*1e3/(n.timestamp-e.timestamp)}const jT=1e3;class vh extends P{get sender(){return this._sender}set sender(e){this._sender=e}get constraints(){return this._constraints}constructor(e,t,i){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,s=arguments.length>4?arguments[4]:void 0;super(e,t,s),this.manuallyStopped=!1,this._isUpstreamPaused=!1,this.handleTrackMuteEvent=()=>this.debouncedTrackMuteHandler().catch(()=>this.log.debug("track mute bounce got cancelled by an unmute event",this.logContext)),this.debouncedTrackMuteHandler=lo(()=>y(this,void 0,void 0,function*(){yield this.pauseUpstream()}),5e3),this.handleTrackUnmuteEvent=()=>y(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(N.Ended,this)},this.reacquireTrack=!1,this.providedByUser=r,this.muteLock=new Fe,this.pauseUpstreamLock=new Fe,this.processorLock=new Fe,this.restartLock=new Fe,this.setMediaStreamTrack(e,!0),this._constraints=e.getConstraints(),i&&(this._constraints=i)}get id(){return this._mediaStreamTrack.id}get dimensions(){if(this.kind!==P.Kind.Video)return;const{width:e,height:t}=this._mediaStreamTrack.getSettings();if(e&&t)return{width:e,height:t}}get isUpstreamPaused(){return this._isUpstreamPaused}get isUserProvided(){return this.providedByUser}get mediaStreamTrack(){var e,t;return(t=(e=this.processor)===null||e===void 0?void 0:e.processedTrack)!==null&&t!==void 0?t:this._mediaStreamTrack}get isLocal(){return!0}getSourceTrackSettings(){return this._mediaStreamTrack.getSettings()}setMediaStreamTrack(e,t){return y(this,void 0,void 0,function*(){var i;if(e===this._mediaStreamTrack&&!t)return;this._mediaStreamTrack&&(this.attachedElements.forEach(s=>{Vn(this._mediaStreamTrack,s)}),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());let r;if(this.processor&&e){const s=yield this.processorLock.lock();try{if(this.log.debug("restarting processor",this.logContext),this.kind==="unknown")throw TypeError("cannot set processor on track of unknown kind");this.processorElement&&(jn(e,this.processorElement),this.processorElement.muted=!0),yield this.processor.restart({track:e,kind:this.kind,element:this.processorElement}),r=this.processor.processedTrack}finally{s()}}this.sender&&((i=this.sender.transport)===null||i===void 0?void 0:i.state)!=="closed"&&(yield this.sender.replaceTrack(r??e)),!this.providedByUser&&this._mediaStreamTrack!==e&&this._mediaStreamTrack.stop(),this._mediaStreamTrack=e,e&&(this._mediaStreamTrack.enabled=!this.isMuted,yield this.resumeUpstream(),this.attachedElements.forEach(s=>{jn(r??e,s)}))})}waitForDimensions(){return y(this,arguments,void 0,function(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:jT;return function*(){var i;if(e.kind===P.Kind.Audio)throw new Error("cannot get dimensions for audio tracks");((i=ct())===null||i===void 0?void 0:i.os)==="iOS"&&(yield Ge(10));const r=Date.now();for(;Date.now()-r<t;){const s=e.dimensions;if(s)return s;yield Ge(50)}throw new Pt("unable to get track dimensions after timeout")}()})}setDeviceId(e){return y(this,void 0,void 0,function*(){return this._constraints.deviceId===e&&this._mediaStreamTrack.getSettings().deviceId===Jt(e)||(this._constraints.deviceId=e,this.isMuted)?!0:(yield this.restartTrack(),Jt(e)===this._mediaStreamTrack.getSettings().deviceId)})}getDeviceId(){return y(this,arguments,void 0,function(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return function*(){if(e.source===P.Source.ScreenShare)return;const{deviceId:i,groupId:r}=e._mediaStreamTrack.getSettings(),s=e.kind===P.Kind.Audio?"audioinput":"videoinput";return t?we.getInstance().normalizeDeviceId(s,i,r):i}()})}mute(){return y(this,void 0,void 0,function*(){return this.setTrackMuted(!0),this})}unmute(){return y(this,void 0,void 0,function*(){return this.setTrackMuted(!1),this})}replaceTrack(e,t){return y(this,void 0,void 0,function*(){if(!this.sender)throw new Pt("unable to replace an unpublished track");let i,r;return typeof t=="boolean"?i=t:t!==void 0&&(i=t.userProvidedTrack,r=t.stopProcessor),this.providedByUser=i??!0,this.log.debug("replace MediaStreamTrack",this.logContext),yield this.setMediaStreamTrack(e),r&&this.processor&&(yield this.stopProcessor()),this})}restart(e){return y(this,void 0,void 0,function*(){this.manuallyStopped=!1;const t=yield this.restartLock.lock();try{e||(e=this._constraints);const{deviceId:i,facingMode:r}=e,s=Rk(e,["deviceId","facingMode"]);this.log.debug("restarting track with constraints",Object.assign(Object.assign({},this.logContext),{constraints:e}));const a={audio:!1,video:!1};this.kind===P.Kind.Video?a.video=i||r?{deviceId:i,facingMode:r}:!0:a.audio=i?{deviceId:i}:!0,this.attachedElements.forEach(l=>{Vn(this.mediaStreamTrack,l)}),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this._mediaStreamTrack.stop();const c=(yield navigator.mediaDevices.getUserMedia(a)).getTracks()[0];return yield c.applyConstraints(s),c.addEventListener("ended",this.handleEnded),this.log.debug("re-acquired MediaStreamTrack",this.logContext),yield this.setMediaStreamTrack(c),this._constraints=e,this.emit(N.Restarted,this),this.manuallyStopped&&(this.log.warn("track was stopped during a restart, stopping restarted track",this.logContext),this.stop()),this}finally{t()}})}setTrackMuted(e){this.log.debug("setting ".concat(this.kind," track ").concat(e?"muted":"unmuted"),this.logContext),!(this.isMuted===e&&this._mediaStreamTrack.enabled!==e)&&(this.isMuted=e,this._mediaStreamTrack.enabled=!e,this.emit(e?N.Muted:N.Unmuted,this))}get needsReAcquisition(){return this._mediaStreamTrack.readyState!=="live"||this._mediaStreamTrack.muted||!this._mediaStreamTrack.enabled||this.reacquireTrack}handleAppVisibilityChanged(){const e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return y(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),Hd()&&(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;this.manuallyStopped=!0,super.stop(),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this._mediaStreamTrack.removeEventListener("mute",this.handleTrackMuteEvent),this._mediaStreamTrack.removeEventListener("unmute",this.handleTrackUnmuteEvent),(e=this.processor)===null||e===void 0||e.destroy(),this.processor=void 0}pauseUpstream(){return y(this,void 0,void 0,function*(){var e;const t=yield this.pauseUpstreamLock.lock();try{if(this._isUpstreamPaused===!0)return;if(!this.sender){this.log.warn("unable to pause upstream for an unpublished track",this.logContext);return}this._isUpstreamPaused=!0,this.emit(N.UpstreamPaused,this);const i=ct();if((i==null?void 0:i.name)==="Safari"&&pn(i.version,"12.0")<0)throw new Da("pauseUpstream is not supported on Safari < 12.");((e=this.sender.transport)===null||e===void 0?void 0:e.state)!=="closed"&&(yield this.sender.replaceTrack(null))}finally{t()}})}resumeUpstream(){return y(this,void 0,void 0,function*(){var e;const t=yield this.pauseUpstreamLock.lock();try{if(this._isUpstreamPaused===!1)return;if(!this.sender){this.log.warn("unable to resume upstream for an unpublished track",this.logContext);return}this._isUpstreamPaused=!1,this.emit(N.UpstreamResumed,this),((e=this.sender.transport)===null||e===void 0?void 0:e.state)!=="closed"&&(yield this.sender.replaceTrack(this.mediaStreamTrack))}finally{t()}})}getRTCStatsReport(){return y(this,void 0,void 0,function*(){var e;return!((e=this.sender)===null||e===void 0)&&e.getStats?yield this.sender.getStats():void 0})}setProcessor(e){return y(this,arguments,void 0,function(t){var i=this;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return function*(){var s;const a=yield i.processorLock.lock();try{i.log.debug("setting up processor",i.logContext);const o=document.createElement(i.kind),c={kind:i.kind,track:i._mediaStreamTrack,element:o,audioContext:i.audioContext};if(yield t.init(c),i.log.debug("processor initialized",i.logContext),i.processor&&(yield i.stopProcessor()),i.kind==="unknown")throw TypeError("cannot set processor on track of unknown kind");if(jn(i._mediaStreamTrack,o),o.muted=!0,o.play().catch(l=>i.log.error("failed to play processor element",Object.assign(Object.assign({},i.logContext),{error:l}))),i.processor=t,i.processorElement=o,i.processor.processedTrack){for(const l of i.attachedElements)l!==i.processorElement&&r&&(Vn(i._mediaStreamTrack,l),jn(i.processor.processedTrack,l));yield(s=i.sender)===null||s===void 0?void 0:s.replaceTrack(i.processor.processedTrack)}i.emit(N.TrackProcessorUpdate,i.processor)}finally{a()}}()})}getProcessor(){return this.processor}stopProcessor(){return y(this,arguments,void 0,function(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return function*(){var i,r;e.processor&&(e.log.debug("stopping processor",e.logContext),(i=e.processor.processedTrack)===null||i===void 0||i.stop(),yield e.processor.destroy(),e.processor=void 0,t||((r=e.processorElement)===null||r===void 0||r.remove(),e.processorElement=void 0),yield e._mediaStreamTrack.applyConstraints(e._constraints),yield e.setMediaStreamTrack(e._mediaStreamTrack,!0),e.emit(N.TrackProcessorUpdate))}()})}}class Zr extends vh{get enhancedNoiseCancellation(){return this.isKrispNoiseFilterEnabled}constructor(e,t){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,r=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;super(e,P.Kind.Audio,t,i,s),this.stopOnMute=!1,this.isKrispNoiseFilterEnabled=!1,this.monitorSender=()=>y(this,void 0,void 0,function*(){if(!this.sender){this._currentBitrate=0;return}let a;try{a=yield this.getSenderStats()}catch(o){this.log.error("could not get audio sender stats",Object.assign(Object.assign({},this.logContext),{error:o}));return}a&&this.prevStats&&(this._currentBitrate=Qr(a,this.prevStats)),this.prevStats=a}),this.handleKrispNoiseFilterEnable=()=>{this.isKrispNoiseFilterEnabled=!0,this.log.debug("Krisp noise filter enabled",this.logContext),this.emit(N.AudioTrackFeatureUpdate,this,st.TF_ENHANCED_NOISE_CANCELLATION,!0)},this.handleKrispNoiseFilterDisable=()=>{this.isKrispNoiseFilterEnabled=!1,this.log.debug("Krisp noise filter disabled",this.logContext),this.emit(N.AudioTrackFeatureUpdate,this,st.TF_ENHANCED_NOISE_CANCELLATION,!1)},this.audioContext=r,this.checkForSilence()}mute(){const e=Object.create(null,{mute:{get:()=>super.mute}});return y(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===P.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 y(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 i=this._constraints.deviceId&&this._mediaStreamTrack.getSettings().deviceId!==Jt(this._constraints.deviceId);return this.source===P.Source.Microphone&&(this.stopOnMute||this._mediaStreamTrack.readyState==="ended"||i)&&!this.isUserProvided&&(this.log.debug("reacquiring mic track",this.logContext),yield this.restartTrack()),yield e.unmute.call(this),this}finally{t()}})}restartTrack(e){return y(this,void 0,void 0,function*(){let t;if(e){const i=no({audio:e});typeof i.audio!="boolean"&&(t=i.audio)}yield this.restart(t)})}restart(e){const t=Object.create(null,{restart:{get:()=>super.restart}});return y(this,void 0,void 0,function*(){const i=yield t.restart.call(this,e);return this.checkForSilence(),i})}startMonitor(){We()&&(this.monitorInterval||(this.monitorInterval=setInterval(()=>{this.monitorSender()},po)))}setProcessor(e){return y(this,void 0,void 0,function*(){var t;const i=yield this.processorLock.lock();try{if(!St()&&!this.audioContext)throw Error("Audio context needs to be set on LocalAudioTrack in order to enable processors");this.processor&&(yield this.stopProcessor());const r={kind:this.kind,track:this._mediaStreamTrack,audioContext:this.audioContext};this.log.debug("setting up audio processor ".concat(e.name),this.logContext),yield e.init(r),this.processor=e,this.processor.processedTrack&&(yield(t=this.sender)===null||t===void 0?void 0:t.replaceTrack(this.processor.processedTrack),this.processor.processedTrack.addEventListener("enable-lk-krisp-noise-filter",this.handleKrispNoiseFilterEnable),this.processor.processedTrack.addEventListener("disable-lk-krisp-noise-filter",this.handleKrispNoiseFilterDisable)),this.emit(N.TrackProcessorUpdate,this.processor)}finally{i()}})}setAudioContext(e){this.audioContext=e}getSenderStats(){return y(this,void 0,void 0,function*(){var e;if(!(!((e=this.sender)===null||e===void 0)&&e.getStats))return;const t=yield this.sender.getStats();let i;return t.forEach(r=>{r.type==="outbound-rtp"&&(i={type:"audio",streamId:r.id,packetsSent:r.packetsSent,packetsLost:r.packetsLost,bytesSent:r.bytesSent,timestamp:r.timestamp,roundTripTime:r.roundTripTime,jitter:r.jitter})}),i})}checkForSilence(){return y(this,void 0,void 0,function*(){const e=yield eh(this);return e&&(this.isMuted||this.log.warn("silence detected on local audio track",this.logContext),this.emit(N.AudioSilenceDetected)),e})}}function VT(n,e,t){switch(n.kind){case"audio":return new Zr(n,e,!1,void 0,t);case"video":return new ts(n,e,!1,t);default:throw new Pt("unsupported track type: ".concat(n.kind))}}const GT=Object.values(bi),WT=Object.values(Ga),zT=Object.values(Wa),HT=[bi.h180,bi.h360],qT=[Ga.h180,Ga.h360],KT=n=>[{scaleResolutionDownBy:2,fps:n.encoding.maxFramerate}].map(t=>{var i,r;return new ne(Math.floor(n.width/t.scaleResolutionDownBy),Math.floor(n.height/t.scaleResolutionDownBy),Math.max(15e4,Math.floor(n.encoding.maxBitrate/(Math.pow(t.scaleResolutionDownBy,2)*(((i=n.encoding.maxFramerate)!==null&&i!==void 0?i:30)/((r=t.fps)!==null&&r!==void 0?r:30))))),t.fps,n.encoding.priority)}),mo=["q","h","f"];function go(n,e,t,i){var r,s;let a=i==null?void 0:i.videoEncoding;n&&(a=i==null?void 0:i.screenShareEncoding);const o=i==null?void 0:i.simulcast,c=i==null?void 0:i.scalabilityMode,l=i==null?void 0:i.videoCodec;if(!a&&!o&&!c||!e||!t)return[{}];a||(a=YT(n,e,t,l),q.debug("using video encoding",a));const u=a.maxFramerate,d=new ne(e,t,a.maxBitrate,a.maxFramerate,a.priority);if(c&&yi(l)){const p=new es(c),g=[];if(p.spatial>3)throw new Error("unsupported scalabilityMode: ".concat(c));const v=ct();if(Xt()||St()||(v==null?void 0:v.name)==="Chrome"&&pn(v==null?void 0:v.version,"113")<0){const b=p.suffix=="h"?2:3;for(let S=0;S<p.spatial;S+=1)g.push({rid:mo[2-S],maxBitrate:a.maxBitrate/Math.pow(b,S),maxFramerate:d.encoding.maxFramerate});g[0].scalabilityMode=c}else g.push({maxBitrate:a.maxBitrate,maxFramerate:d.encoding.maxFramerate,scalabilityMode:c});return d.encoding.priority&&(g[0].priority=d.encoding.priority,g[0].networkPriority=d.encoding.priority),q.debug("using svc encoding",{encodings:g}),g}if(!o)return[a];let h=[];n?h=(r=yh(i==null?void 0:i.screenShareSimulcastLayers))!==null&&r!==void 0?r:bh(n,d):h=(s=yh(i==null?void 0:i.videoSimulcastLayers))!==null&&s!==void 0?s:bh(n,d);let f;if(h.length>0){const p=h[0];h.length>1&&([,f]=h);const g=Math.max(e,t);if(g>=960&&f)return vo(e,t,[p,f,d],u);if(g>=480)return vo(e,t,[p,d],u)}return vo(e,t,[d])}function $T(n,e,t){var i,r,s,a;if(!t.backupCodec||t.backupCodec===!0||t.backupCodec.codec===t.videoCodec)return;e!==t.backupCodec.codec&&q.warn("requested a different codec than specified as backup",{serverRequested:e,backup:t.backupCodec.codec}),t.videoCodec=e,t.videoEncoding=t.backupCodec.encoding;const o=n.mediaStreamTrack.getSettings(),c=(i=o.width)!==null&&i!==void 0?i:(r=n.dimensions)===null||r===void 0?void 0:r.width,l=(s=o.height)!==null&&s!==void 0?s:(a=n.dimensions)===null||a===void 0?void 0:a.height;return n.source===P.Source.ScreenShare&&t.simulcast&&(t.simulcast=!1),go(n.source===P.Source.ScreenShare,c,l,t)}function YT(n,e,t,i){const r=XT(n,e,t);let{encoding:s}=r[0];const a=Math.max(e,t);for(let o=0;o<r.length;o+=1){const c=r[o];if(s=c.encoding,c.width>=a)break}if(i)switch(i){case"av1":s=Object.assign({},s),s.maxBitrate=s.maxBitrate*.7;break;case"vp9":s=Object.assign({},s),s.maxBitrate=s.maxBitrate*.85;break}return s}function XT(n,e,t){if(n)return zT;const i=e>t?e/t:t/e;return Math.abs(i-16/9)<Math.abs(i-4/3)?GT:WT}function bh(n,e){if(n)return KT(e);const{width:t,height:i}=e,r=t>i?t/i:i/t;return Math.abs(r-16/9)<Math.abs(r-4/3)?HT:qT}function vo(n,e,t,i){const r=[];if(t.forEach((s,a)=>{if(a>=mo.length)return;const o=Math.min(n,e),l={rid:mo[a],scaleResolutionDownBy:Math.max(1,o/Math.min(s.width,s.height)),maxBitrate:s.encoding.maxBitrate},u=i&&s.encoding.maxFramerate?Math.min(i,s.encoding.maxFramerate):s.encoding.maxFramerate;u&&(l.maxFramerate=u);const d=Gn()||a===0;s.encoding.priority&&d&&(l.priority=s.encoding.priority,l.networkPriority=s.encoding.priority),r.push(l)}),St()&&Kd()==="ios"){let s;r.forEach(o=>{s?o.maxFramerate&&o.maxFramerate>s&&(s=o.maxFramerate):s=o.maxFramerate});let a=!0;r.forEach(o=>{var c;o.maxFramerate!=s&&(a&&(a=!1,q.info("Simulcast on iOS React-Native requires all encodings to share the same framerate.")),q.info('Setting framerate of encoding "'.concat((c=o.rid)!==null&&c!==void 0?c:"",'" to ').concat(s)),o.maxFramerate=s)})}return r}function yh(n){if(n)return n.sort((e,t)=>{const{encoding:i}=e,{encoding:r}=t;return i.maxBitrate>r.maxBitrate?1:i.maxBitrate<r.maxBitrate?-1:i.maxBitrate===r.maxBitrate&&i.maxFramerate&&r.maxFramerate?i.maxFramerate>r.maxFramerate?1:-1:0})}class es{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((e=this.suffix)!==null&&e!==void 0?e:"")}}function JT(n){return n.source===P.Source.ScreenShare||n.constraints.height&&Jt(n.constraints.height)>=1080?"maintain-resolution":"balanced"}const QT=5e3;class ts extends vh{get sender(){return this._sender}set sender(e){this._sender=e,this.degradationPreference&&this.setDegradationPreference(this.degradationPreference)}constructor(e,t){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,r=arguments.length>3?arguments[3]:void 0;super(e,P.Kind.Video,t,i,r),this.simulcastCodecs=new Map,this.degradationPreference="balanced",this.monitorSender=()=>y(this,void 0,void 0,function*(){if(!this.sender){this._currentBitrate=0;return}let s;try{s=yield this.getSenderStats()}catch(o){this.log.error("could not get audio sender stats",Object.assign(Object.assign({},this.logContext),{error:o}));return}const a=new Map(s.map(o=>[o.rid,o]));if(this.prevStats){let o=0;a.forEach((c,l)=>{var u;const d=(u=this.prevStats)===null||u===void 0?void 0:u.get(l);o+=Qr(c,d)}),this._currentBitrate=o}this.prevStats=a}),this.senderLock=new Fe}get isSimulcast(){return!!(this.sender&&this.sender.getParameters().encodings.length>1)}startMonitor(e){var t;if(this.signalClient=e,!We())return;const i=(t=this.sender)===null||t===void 0?void 0:t.getParameters();i&&(this.encodings=i.encodings),!this.monitorInterval&&(this.monitorInterval=setInterval(()=>{this.monitorSender()},po))}stop(){this._mediaStreamTrack.getConstraints(),this.simulcastCodecs.forEach(e=>{e.mediaStreamTrack.stop()}),super.stop()}pauseUpstream(){const e=Object.create(null,{pauseUpstream:{get:()=>super.pauseUpstream}});return y(this,void 0,void 0,function*(){var t,i,r,s,a;yield e.pauseUpstream.call(this);try{for(var o=!0,c=qt(this.simulcastCodecs.values()),l;l=yield c.next(),t=l.done,!t;o=!0)s=l.value,o=!1,yield(a=s.sender)===null||a===void 0?void 0:a.replaceTrack(null)}catch(u){i={error:u}}finally{try{!o&&!t&&(r=c.return)&&(yield r.call(c))}finally{if(i)throw i.error}}})}resumeUpstream(){const e=Object.create(null,{resumeUpstream:{get:()=>super.resumeUpstream}});return y(this,void 0,void 0,function*(){var t,i,r,s,a;yield e.resumeUpstream.call(this);try{for(var o=!0,c=qt(this.simulcastCodecs.values()),l;l=yield c.next(),t=l.done,!t;o=!0){s=l.value,o=!1;const u=s;yield(a=u.sender)===null||a===void 0?void 0:a.replaceTrack(u.mediaStreamTrack)}}catch(u){i={error:u}}finally{try{!o&&!t&&(r=c.return)&&(yield r.call(c))}finally{if(i)throw i.error}}})}mute(){const e=Object.create(null,{mute:{get:()=>super.mute}});return y(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===P.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 y(this,void 0,void 0,function*(){const t=yield this.muteLock.lock();try{return this.isMuted?(this.source===P.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(){return y(this,void 0,void 0,function*(){var e;if(!(!((e=this.sender)===null||e===void 0)&&e.getStats))return[];const t=[],i=yield this.sender.getStats();return i.forEach(r=>{var s;if(r.type==="outbound-rtp"){const a={type:"video",streamId:r.id,frameHeight:r.frameHeight,frameWidth:r.frameWidth,framesPerSecond:r.framesPerSecond,framesSent:r.framesSent,firCount:r.firCount,pliCount:r.pliCount,nackCount:r.nackCount,packetsSent:r.packetsSent,bytesSent:r.bytesSent,qualityLimitationReason:r.qualityLimitationReason,qualityLimitationDurations:r.qualityLimitationDurations,qualityLimitationResolutionChanges:r.qualityLimitationResolutionChanges,rid:(s=r.rid)!==null&&s!==void 0?s:r.id,retransmittedPacketsSent:r.retransmittedPacketsSent,targetBitrate:r.targetBitrate,timestamp:r.timestamp},o=i.get(r.remoteId);o&&(a.jitter=o.jitter,a.packetsLost=o.packetsLost,a.roundTripTime=o.roundTripTime),t.push(a)}}),t.sort((r,s)=>{var a,o;return((a=s.frameWidth)!==null&&a!==void 0?a:0)-((o=r.frameWidth)!==null&&o!==void 0?o:0)}),t})}setPublishingQuality(e){const t=[];for(let i=Ze.LOW;i<=Ze.HIGH;i+=1)t.push(new xa({quality:i,enabled:i<=e}));this.log.debug("setting publishing quality. max quality ".concat(e),this.logContext),this.setPublishingLayers(t)}restartTrack(e){return y(this,void 0,void 0,function*(){var t,i,r,s,a;let o;if(e){const d=no({video:e});typeof d.video!="boolean"&&(o=d.video)}yield this.restart(o);try{for(var c=!0,l=qt(this.simulcastCodecs.values()),u;u=yield l.next(),t=u.done,!t;c=!0){s=u.value,c=!1;const d=s;d.sender&&((a=d.sender.transport)===null||a===void 0?void 0:a.state)!=="closed"&&(d.mediaStreamTrack=this.mediaStreamTrack.clone(),yield d.sender.replaceTrack(d.mediaStreamTrack))}}catch(d){i={error:d}}finally{try{!c&&!t&&(r=l.return)&&(yield r.call(l))}finally{if(i)throw i.error}}})}setProcessor(e){const t=Object.create(null,{setProcessor:{get:()=>super.setProcessor}});return y(this,arguments,void 0,function(i){var r=this;let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return function*(){var a,o,c,l,u,d;if(yield t.setProcessor.call(r,i,s),!((u=r.processor)===null||u===void 0)&&u.processedTrack)try{for(var h=!0,f=qt(r.simulcastCodecs.values()),p;p=yield f.next(),a=p.done,!a;h=!0)l=p.value,h=!1,yield(d=l.sender)===null||d===void 0?void 0:d.replaceTrack(r.processor.processedTrack)}catch(g){o={error:g}}finally{try{!h&&!a&&(c=f.return)&&(yield c.call(f))}finally{if(o)throw o.error}}}()})}setDegradationPreference(e){return y(this,void 0,void 0,function*(){if(this.degradationPreference=e,this.sender)try{this.log.debug("setting degradationPreference to ".concat(e),this.logContext);const t=this.sender.getParameters();t.degradationPreference=e,this.sender.setParameters(t)}catch(t){this.log.warn("failed to set degradationPreference",Object.assign({error:t},this.logContext))}})}addSimulcastTrack(e,t){if(this.simulcastCodecs.has(e)){this.log.error("".concat(e," already added, skipping adding simulcast codec"),this.logContext);return}const i={codec:e,mediaStreamTrack:this.mediaStreamTrack.clone(),sender:void 0,encodings:t};return this.simulcastCodecs.set(e,i),i}setSimulcastTrackSender(e,t){const i=this.simulcastCodecs.get(e);i&&(i.sender=t,setTimeout(()=>{this.subscribedCodecs&&this.setPublishingCodecs(this.subscribedCodecs)},QT))}setPublishingCodecs(e){return y(this,void 0,void 0,function*(){var t,i,r,s,a,o,c;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 l=[];try{for(t=!0,i=qt(e);r=yield i.next(),s=r.done,!s;t=!0){c=r.value,t=!1;const u=c;if(!this.codec||this.codec===u.codec)yield this.setPublishingLayers(u.qualities);else{const d=this.simulcastCodecs.get(u.codec);if(this.log.debug("try setPublishingCodec for ".concat(u.codec),Object.assign(Object.assign({},this.logContext),{simulcastCodecInfo:d})),!d||!d.sender){for(const h of u.qualities)if(h.enabled){l.push(u.codec);break}}else d.encodings&&(this.log.debug("try setPublishingLayersForSender ".concat(u.codec),this.logContext),yield kh(d.sender,d.encodings,u.qualities,this.senderLock,this.log,this.logContext))}}}catch(u){a={error:u}}finally{try{!t&&!s&&(o=i.return)&&(yield o.call(i))}finally{if(a)throw a.error}}return l})}setPublishingLayers(e){return y(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 kh(this.sender,this.encodings,e,this.senderLock,this.log,this.logContext))})}handleAppVisibilityChanged(){const e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return y(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),Hd()&&this.isInBackground&&this.source===P.Source.Camera&&(this._mediaStreamTrack.enabled=!1)})}}function kh(n,e,t,i,r,s){return y(this,void 0,void 0,function*(){const a=yield i.lock();r.debug("setPublishingLayersForSender",Object.assign(Object.assign({},s),{sender:n,qualities:t,senderEncodings:e}));try{const o=n.getParameters(),{encodings:c}=o;if(!c)return;if(c.length!==e.length){r.warn("cannot set publishing layers, encodings mismatch",Object.assign(Object.assign({},s),{encodings:c,senderEncodings:e}));return}let l=!1;const u=ct();if((u==null?void 0:u.name)==="Chrome"&&pn(u==null?void 0:u.version,"133")>0&&c[0].scalabilityMode){const h=c[0],f=new es(h.scalabilityMode);let p=Mn.OFF;if(t.forEach(g=>{g.enabled&&(p===Mn.OFF||g.quality>p)&&(p=g.quality)}),p===Mn.OFF)h.active&&(h.active=!1,l=!0);else if(!h.active||f.spatial!==p+1){l=!0,h.active=!0;const g=new es(e[0].scalabilityMode);f.spatial=p+1,f.suffix=g.suffix,f.spatial===1&&(f.suffix=void 0),h.scalabilityMode=f.toString(),h.scaleResolutionDownBy=Math.pow(2,2-p),e[0].maxBitrate&&(h.maxBitrate=e[0].maxBitrate/(h.scaleResolutionDownBy*h.scaleResolutionDownBy))}}else c.forEach((h,f)=>{var p;let g=(p=h.rid)!==null&&p!==void 0?p:"";g===""&&(g="q");const v=Th(g),b=t.find(S=>S.quality===v);b&&h.active!==b.enabled&&(l=!0,h.active=b.enabled,r.debug("setting layer ".concat(b.quality," to ").concat(h.active?"enabled":"disabled"),s),Gn()&&(b.enabled?(h.scaleResolutionDownBy=e[f].scaleResolutionDownBy,h.maxBitrate=e[f].maxBitrate,h.maxFrameRate=e[f].maxFrameRate):(h.scaleResolutionDownBy=4,h.maxBitrate=10,h.maxFrameRate=2)))});l&&(o.encodings=c,r.debug("setting encodings",Object.assign(Object.assign({},s),{encodings:o.encodings})),yield n.setParameters(o))}finally{a()}})}function Th(n){switch(n){case"f":return Ze.HIGH;case"h":return Ze.MEDIUM;case"q":return Ze.LOW;default:return Ze.HIGH}}function Sh(n,e,t,i){if(!t)return[new dn({quality:Ze.HIGH,width:n,height:e,bitrate:0,ssrc:0})];if(i){const r=t[0].scalabilityMode,s=new es(r),a=[],o=s.suffix=="h"?1.5:2,c=s.suffix=="h"?2:3;for(let l=0;l<s.spatial;l+=1)a.push(new dn({quality:Math.min(Ze.HIGH,s.spatial-1)-l,width:Math.ceil(n/Math.pow(o,l)),height:Math.ceil(e/Math.pow(o,l)),bitrate:t[0].maxBitrate?Math.ceil(t[0].maxBitrate/Math.pow(c,l)):0,ssrc:0}));return a}return t.map(r=>{var s,a,o;const c=(s=r.scaleResolutionDownBy)!==null&&s!==void 0?s:1;let l=Th((a=r.rid)!==null&&a!==void 0?a:"");return new dn({quality:l,width:Math.ceil(n/c),height:Math.ceil(e/c),bitrate:(o=r.maxBitrate)!==null&&o!==void 0?o:0,ssrc:0})})}const Ch="_lossy",xh="_reliable",ZT=2*1e3,bo="leave-reconnect";var ut;(function(n){n[n.New=0]="New",n[n.Connected=1]="Connected",n[n.Disconnected=2]="Disconnected",n[n.Reconnecting=3]="Reconnecting",n[n.Closed=4]="Closed"})(ut||(ut={}));class eS extends Tt.EventEmitter{get isClosed(){return this._isClosed}get pendingReconnect(){return!!this.reconnectTimeout}constructor(e){var t;super(),this.options=e,this.rtcConfig={},this.peerConnectionTimeout=ho.peerConnectionTimeout,this.fullReconnectOnNext=!1,this.subscriberPrimary=!1,this.pcState=ut.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=q,this.handleDataChannel=i=>y(this,[i],void 0,function(r){var s=this;let{channel:a}=r;return function*(){if(a){if(a.label===xh)s.reliableDCSub=a;else if(a.label===Ch)s.lossyDCSub=a;else return;s.log.debug("on data channel ".concat(a.id,", ").concat(a.label),s.logContext),a.onmessage=s.handleDataMessage}}()}),this.handleDataMessage=i=>y(this,void 0,void 0,function*(){var r,s;const a=yield this.dataProcessLock.lock();try{let o;if(i.data instanceof ArrayBuffer)o=i.data;else if(i.data instanceof Blob)o=yield i.data.arrayBuffer();else{this.log.error("unsupported data type",Object.assign(Object.assign({},this.logContext),{data:i.data}));return}const c=Ve.fromBinary(new Uint8Array(o));((r=c.value)===null||r===void 0?void 0:r.case)==="speaker"?this.emit(M.ActiveSpeakersUpdate,c.value.value.speakers):(((s=c.value)===null||s===void 0?void 0:s.case)==="user"&&nS(c,c.value.value),this.emit(M.DataPacketReceived,c))}finally{a()}}),this.handleDataError=i=>{const s=i.currentTarget.maxRetransmits===0?"lossy":"reliable";if(i instanceof ErrorEvent&&i.error){const{error:a}=i.error;this.log.error("DataChannel error on ".concat(s,": ").concat(i.message),Object.assign(Object.assign({},this.logContext),{error:a}))}else this.log.error("Unknown DataChannel error on ".concat(s),Object.assign(Object.assign({},this.logContext),{event:i}))},this.handleBufferedAmountLow=i=>{const s=i.currentTarget.maxRetransmits===0?X.LOSSY:X.RELIABLE;this.updateAndEmitDCBufferStatus(s)},this.handleDisconnect=(i,r)=>{if(this._isClosed)return;this.log.warn("".concat(i," disconnected"),this.logContext),this.reconnectAttempts===0&&(this.reconnectStart=Date.now());const s=c=>{this.log.warn("could not recover connection after ".concat(this.reconnectAttempts," attempts, ").concat(c,"ms. giving up"),this.logContext),this.emit(M.Disconnected),this.close()},a=Date.now()-this.reconnectStart;let o=this.getNextRetryDelay({elapsedMs:a,retryCount:this.reconnectAttempts});if(o===null){s(a);return}i===bo&&(o=0),this.log.debug("reconnecting in ".concat(o,"ms"),this.logContext),this.clearReconnectTimeout(),this.token&&this.regionUrlProvider&&this.regionUrlProvider.updateToken(this.token),this.reconnectTimeout=Ie.setTimeout(()=>this.attemptReconnect(r).finally(()=>this.reconnectTimeout=void 0),o)},this.waitForRestarted=()=>new Promise((i,r)=>{this.pcState===ut.Connected&&i();const s=()=>{this.off(M.Disconnected,a),i()},a=()=>{this.off(M.Restarted,s),r()};this.once(M.Restarted,s),this.once(M.Disconnected,a)}),this.updateAndEmitDCBufferStatus=i=>{const r=this.isBufferStatusLow(i);typeof r<"u"&&r!==this.dcBufferStatus.get(i)&&(this.dcBufferStatus.set(i,r),this.emit(M.DCBufferStatusChanged,r,i))},this.isBufferStatusLow=i=>{const r=this.dataChannelForKind(i);if(r)return r.bufferedAmount<=r.bufferedAmountLowThreshold},this.handleBrowserOnLine=()=>{this.client.currentState===oe.RECONNECTING&&(this.clearReconnectTimeout(),this.attemptReconnect(Ln.RR_SIGNAL_DISCONNECTED))},this.log=Et((t=e.loggerName)!==null&&t!==void 0?t:ot.Engine),this.loggerOptions={loggerName:e.loggerName,loggerContextCb:()=>this.logContext},this.client=new ro(void 0,this.loggerOptions),this.client.signalLatency=this.options.expSignalLatency,this.reconnectPolicy=this.options.reconnectPolicy,this.registerOnLineListener(),this.closingLock=new Fe,this.dataProcessLock=new Fe,this.dcBufferStatus=new Map([[X.LOSSY,!0],[X.RELIABLE,!0]]),this.client.onParticipantUpdate=i=>this.emit(M.ParticipantUpdate,i),this.client.onConnectionQuality=i=>this.emit(M.ConnectionQualityUpdate,i),this.client.onRoomUpdate=i=>this.emit(M.RoomUpdate,i),this.client.onSubscriptionError=i=>this.emit(M.SubscriptionError,i),this.client.onSubscriptionPermissionUpdate=i=>this.emit(M.SubscriptionPermissionUpdate,i),this.client.onSpeakersChanged=i=>this.emit(M.SpeakersChanged,i),this.client.onStreamStateUpdate=i=>this.emit(M.StreamStateChanged,i),this.client.onRequestResponse=i=>this.emit(M.SignalRequestResponse,i)}get logContext(){var e,t,i,r,s,a,o,c;return{room:(t=(e=this.latestJoinResponse)===null||e===void 0?void 0:e.room)===null||t===void 0?void 0:t.name,roomID:(r=(i=this.latestJoinResponse)===null||i===void 0?void 0:i.room)===null||r===void 0?void 0:r.sid,participant:(a=(s=this.latestJoinResponse)===null||s===void 0?void 0:s.participant)===null||a===void 0?void 0:a.identity,pID:(c=(o=this.latestJoinResponse)===null||o===void 0?void 0:o.participant)===null||c===void 0?void 0:c.sid}}join(e,t,i,r){return y(this,void 0,void 0,function*(){this.url=e,this.token=t,this.signalOpts=i,this.maxJoinAttempts=i.maxRetries;try{this.joinAttempts+=1,this.setupSignalClientCallbacks();const s=yield this.client.join(e,t,i,r);return this._isClosed=!1,this.latestJoinResponse=s,this.subscriberPrimary=s.subscriberPrimary,this.pcManager||(yield this.configure(s)),(!this.subscriberPrimary||s.fastPublish)&&this.negotiate(),this.clientConfiguration=s.clientConfiguration,setTimeout(()=>{this.emit(M.SignalConnected)},10),s}catch(s){if(s instanceof ie&&s.reason===$.ServerUnreachable&&(this.log.warn("Couldn't connect to server, attempt ".concat(this.joinAttempts," of ").concat(this.maxJoinAttempts),this.logContext),this.joinAttempts<this.maxJoinAttempts))return this.join(e,t,i,r);throw s}})}close(){return y(this,void 0,void 0,function*(){const e=yield this.closingLock.lock();if(this.isClosed){e();return}try{this._isClosed=!0,this.joinAttempts=0,this.emit(M.Closing),this.removeAllListeners(),this.deregisterOnLineListener(),this.clearPendingReconnect(),yield this.cleanupPeerConnections(),yield this.cleanupClient()}finally{e()}})}cleanupPeerConnections(){return y(this,void 0,void 0,function*(){var e;yield(e=this.pcManager)===null||e===void 0?void 0:e.close(),this.pcManager=void 0;const t=i=>{i&&(i.close(),i.onbufferedamountlow=null,i.onclose=null,i.onclosing=null,i.onerror=null,i.onmessage=null,i.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 y(this,void 0,void 0,function*(){yield this.client.close(),this.client.resetCallbacks()})}addTrack(e){if(this.pendingTrackResolvers[e.cid])throw new Pt("a track with the same ID has already been published");return new Promise((t,i)=>{const r=setTimeout(()=>{delete this.pendingTrackResolvers[e.cid],i(new ie("publication of local track timed out, no response from server",$.InternalError))},1e4);this.pendingTrackResolvers[e.cid]={resolve:s=>{clearTimeout(r),t(s)},reject:()=>{clearTimeout(r),i(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(t){this.log.warn("failed to remove track",Object.assign(Object.assign({},this.logContext),{error:t}))}return!1}updateMuteStatus(e,t){this.client.sendMuteTrack(e,t)}get dataSubscriberReadyState(){var e;return(e=this.reliableDCSub)===null||e===void 0?void 0:e.readyState}getConnectedServerAddress(){return y(this,void 0,void 0,function*(){var e;return(e=this.pcManager)===null||e===void 0?void 0:e.getConnectedAddress()})}setRegionUrlProvider(e){this.regionUrlProvider=e}configure(e){return y(this,void 0,void 0,function*(){var t,i;if(this.pcManager&&this.pcManager.currentState!==fe.NEW)return;this.participantSid=(t=e.participant)===null||t===void 0?void 0:t.sid;const r=this.makeRTCConfiguration(e);this.pcManager=new FT(r,e.subscriberPrimary,this.loggerOptions),this.emit(M.TransportsCreated,this.pcManager.publisher,this.pcManager.subscriber),this.pcManager.onIceCandidate=(s,a)=>{this.client.sendIceCandidate(s,a)},this.pcManager.onPublisherOffer=s=>{this.client.sendOffer(s)},this.pcManager.onDataChannel=this.handleDataChannel,this.pcManager.onStateChange=(s,a,o)=>y(this,void 0,void 0,function*(){if(this.log.debug("primary PC state changed ".concat(s),this.logContext),["closed","disconnected","failed"].includes(a)&&(this.publisherConnectionPromise=void 0),s===fe.CONNECTED){const u=this.pcState===ut.New;this.pcState=ut.Connected,u&&this.emit(M.Connected,e)}else s===fe.FAILED&&this.pcState===ut.Connected&&(this.pcState=ut.Disconnected,this.handleDisconnect("peerconnection failed",o==="failed"?Ln.RR_SUBSCRIBER_FAILED:Ln.RR_PUBLISHER_FAILED));const c=this.client.isDisconnected||this.client.currentState===oe.RECONNECTING,l=[fe.FAILED,fe.CLOSING,fe.CLOSED].includes(s);c&&l&&!this._isClosed&&this.emit(M.Offline)}),this.pcManager.onTrack=s=>{this.emit(M.MediaTrackAdded,s.track,s.streams[0],s.receiver)},tS((i=e.serverInfo)===null||i===void 0?void 0:i.protocol)||this.createDataChannels()})}setupSignalClientCallbacks(){this.client.onAnswer=e=>y(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.debug("got ICE candidate from peer",Object.assign(Object.assign({},this.logContext),{candidate:e,target:t})),this.pcManager.addIceCandidate(e,t))},this.client.onOffer=e=>y(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:(t=e.track)===null||t===void 0?void 0:t.sid})),!this.pendingTrackResolvers[e.cid]){this.log.error("missing track resolver for ".concat(e.cid),Object.assign(Object.assign({},this.logContext),{cid:e.cid}));return}const{resolve:i}=this.pendingTrackResolvers[e.cid];delete this.pendingTrackResolvers[e.cid],i(e.track)},this.client.onLocalTrackUnpublished=e=>{this.emit(M.LocalTrackUnpublished,e)},this.client.onLocalTrackSubscribed=e=>{this.emit(M.LocalTrackSubscribed,e)},this.client.onTokenRefresh=e=>{this.token=e},this.client.onRemoteMuteChanged=(e,t)=>{this.emit(M.RemoteMute,e,t)},this.client.onSubscribedQualityUpdate=e=>{this.emit(M.SubscribedQualityUpdate,e)},this.client.onRoomMoved=e=>{var t;this.participantSid=(t=e.participant)===null||t===void 0?void 0:t.sid,this.emit(M.RoomMoved,e)},this.client.onClose=()=>{this.handleDisconnect("signal",Ln.RR_SIGNAL_DISCONNECTED)},this.client.onLeave=e=>{switch(this.log.debug("client leave request",Object.assign(Object.assign({},this.logContext),{reason:e==null?void 0:e.reason})),e.regions&&this.regionUrlProvider&&(this.log.debug("updating regions",this.logContext),this.regionUrlProvider.setServerReportedRegions(e.regions)),e.action){case Bn.DISCONNECT:this.emit(M.Disconnected,e==null?void 0:e.reason),this.close();break;case Bn.RECONNECT:this.fullReconnectOnNext=!0,this.handleDisconnect(bo);break;case Bn.RESUME:this.handleDisconnect(bo)}}}makeRTCConfiguration(e){var t;const i=Object.assign({},this.rtcConfig);if(!((t=this.signalOpts)===null||t===void 0)&&t.e2eeEnabled&&(this.log.debug("E2EE - setting up transports with insertable streams",this.logContext),i.encodedInsertableStreams=!0),e.iceServers&&!i.iceServers){const r=[];e.iceServers.forEach(s=>{const a={urls:s.urls};s.username&&(a.username=s.username),s.credential&&(a.credential=s.credential),r.push(a)}),i.iceServers=r}return e.clientConfiguration&&e.clientConfiguration.forceRelay===mi.ENABLED&&(i.iceTransportPolicy="relay"),i.sdpSemantics="unified-plan",i.continualGatheringPolicy="gather_continually",i}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(Ch,{ordered:!1,maxRetransmits:0}),this.reliableDC=this.pcManager.createPublisherDataChannel(xh,{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)}createSender(e,t,i){return y(this,void 0,void 0,function*(){if(za())return yield this.createTransceiverRTCRtpSender(e,t,i);if(Ha())return this.log.warn("using add-track fallback",this.logContext),yield this.createRTCRtpSender(e.mediaStreamTrack);throw new Ce("Required webRTC APIs not supported on this device")})}createSimulcastSender(e,t,i,r){return y(this,void 0,void 0,function*(){if(za())return this.createSimulcastTransceiverSender(e,t,i,r);if(Ha())return this.log.debug("using add-track fallback",this.logContext),this.createRTCRtpSender(e.mediaStreamTrack);throw new Ce("Cannot stream on this device")})}createTransceiverRTCRtpSender(e,t,i){return y(this,void 0,void 0,function*(){if(!this.pcManager)throw new Ce("publisher is closed");const r=[];e.mediaStream&&r.push(e.mediaStream),zn(e)&&(e.codec=t.videoCodec);const s={direction:"sendonly",streams:r};return i&&(s.sendEncodings=i),(yield this.pcManager.addPublisherTransceiver(e.mediaStreamTrack,s)).sender})}createSimulcastTransceiverSender(e,t,i,r){return y(this,void 0,void 0,function*(){if(!this.pcManager)throw new Ce("publisher is closed");const s={direction:"sendonly"};r&&(s.sendEncodings=r);const a=yield this.pcManager.addPublisherTransceiver(t.mediaStreamTrack,s);if(i.videoCodec)return e.setSimulcastTrackSender(i.videoCodec,a.sender),a.sender})}createRTCRtpSender(e){return y(this,void 0,void 0,function*(){if(!this.pcManager)throw new Ce("publisher is closed");return this.pcManager.addPublisherTrack(e)})}attemptReconnect(e){return y(this,void 0,void 0,function*(){var t,i,r;if(!this._isClosed){if(this.attemptingReconnect){q.warn("already attempting reconnect, returning early",this.logContext);return}(((t=this.clientConfiguration)===null||t===void 0?void 0:t.resumeConnection)===mi.DISABLED||((r=(i=this.pcManager)===null||i===void 0?void 0:i.currentState)!==null&&r!==void 0?r:fe.NEW)===fe.NEW)&&(this.fullReconnectOnNext=!0);try{this.attemptingReconnect=!0,this.fullReconnectOnNext?yield this.restartConnection():yield this.resumeConnection(e),this.clearPendingReconnect(),this.fullReconnectOnNext=!1}catch(s){this.reconnectAttempts+=1;let a=!0;s instanceof Ce?(this.log.debug("received unrecoverable error",Object.assign(Object.assign({},this.logContext),{error:s})),a=!1):s instanceof qn||(this.fullReconnectOnNext=!0),a?this.handleDisconnect("reconnect",Ln.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(M.Disconnected),yield this.close())}finally{this.attemptingReconnect=!1}}})}getNextRetryDelay(e){try{return this.reconnectPolicy.nextRetryDelayInMs(e)}catch(t){this.log.warn("encountered error in reconnect policy",Object.assign(Object.assign({},this.logContext),{error:t}))}return null}restartConnection(e){return y(this,void 0,void 0,function*(){var t,i,r;try{if(!this.url||!this.token)throw new Ce("could not reconnect, url or token not saved");this.log.info("reconnecting, attempt: ".concat(this.reconnectAttempts),this.logContext),this.emit(M.Restarting),this.client.isDisconnected||(yield this.client.sendLeave()),yield this.cleanupPeerConnections(),yield this.cleanupClient();let s;try{if(!this.signalOpts)throw this.log.warn("attempted connection restart, without signal options present",this.logContext),new qn;s=yield this.join(e??this.url,this.token,this.signalOpts)}catch(a){throw a instanceof ie&&a.reason===$.NotAllowed?new Ce("could not reconnect, token might be expired"):new qn}if(this.shouldFailNext)throw this.shouldFailNext=!1,new Error("simulated failure");if(this.client.setReconnected(),this.emit(M.SignalRestarted,s),yield this.waitForPCReconnected(),this.client.currentState!==oe.CONNECTED)throw new qn("Signal connection got severed during reconnect");(t=this.regionUrlProvider)===null||t===void 0||t.resetAttempts(),this.emit(M.Restarted)}catch(s){const a=yield(i=this.regionUrlProvider)===null||i===void 0?void 0:i.getNextBestRegionUrl();if(a){yield this.restartConnection(a);return}else throw(r=this.regionUrlProvider)===null||r===void 0||r.resetAttempts(),s}})}resumeConnection(e){return y(this,void 0,void 0,function*(){var t;if(!this.url||!this.token)throw new Ce("could not reconnect, url or token not saved");if(!this.pcManager)throw new Ce("publisher and subscriber connections unset");this.log.info("resuming signal connection, attempt ".concat(this.reconnectAttempts),this.logContext),this.emit(M.Resuming);let i;try{this.setupSignalClientCallbacks(),i=yield this.client.reconnect(this.url,this.token,this.participantSid,e)}catch(r){let s="";throw r instanceof Error&&(s=r.message,this.log.error(r.message,Object.assign(Object.assign({},this.logContext),{error:r}))),r instanceof ie&&r.reason===$.NotAllowed?new Ce("could not reconnect, token might be expired"):r instanceof ie&&r.reason===$.LeaveRequest?r:new qn(s)}if(this.emit(M.SignalResumed),i){const r=this.makeRTCConfiguration(i);this.pcManager.updateConfiguration(r)}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!==oe.CONNECTED)throw new qn("Signal connection got severed during reconnect");this.client.setReconnected(),((t=this.reliableDC)===null||t===void 0?void 0:t.readyState)==="open"&&this.reliableDC.id===null&&this.createDataChannels(),this.emit(M.Resumed)})}waitForPCInitialConnection(e,t){return y(this,void 0,void 0,function*(){if(!this.pcManager)throw new Ce("PC manager is closed");yield this.pcManager.ensurePCTransportConnection(t,e)})}waitForPCReconnected(){return y(this,void 0,void 0,function*(){this.pcState=ut.Reconnecting,this.log.debug("waiting for peer connection to reconnect",this.logContext);try{if(yield Ge(ZT),!this.pcManager)throw new Ce("PC manager is closed");yield this.pcManager.ensurePCTransportConnection(void 0,this.peerConnectionTimeout),this.pcState=ut.Connected}catch(e){throw this.pcState=ut.Disconnected,new ie("could not establish PC connection, ".concat(e.message),$.InternalError)}})}publishRpcResponse(e,t,i,r){return y(this,void 0,void 0,function*(){const s=new Ve({destinationIdentities:[e],kind:X.RELIABLE,value:{case:"rpcResponse",value:new Iu({requestId:t,value:r?{case:"error",value:r.toProto()}:{case:"payload",value:i??""}})}});yield this.sendDataPacket(s,X.RELIABLE)})}publishRpcAck(e,t){return y(this,void 0,void 0,function*(){const i=new Ve({destinationIdentities:[e],kind:X.RELIABLE,value:{case:"rpcAck",value:new Ru({requestId:t})}});yield this.sendDataPacket(i,X.RELIABLE)})}sendDataPacket(e,t){return y(this,void 0,void 0,function*(){const i=e.toBinary();yield this.ensurePublisherConnected(t);const r=this.dataChannelForKind(t);r&&r.send(i),this.updateAndEmitDCBufferStatus(t)})}waitForBufferStatusLow(e){return new Promise((t,i)=>y(this,void 0,void 0,function*(){if(this.isBufferStatusLow(e))t();else{const r=()=>i("Engine closed");for(this.once(M.Closing,r);!this.dcBufferStatus.get(e);)yield Ge(10);this.off(M.Closing,r),t()}}))}ensureDataTransportConnected(e){return y(this,arguments,void 0,function(t){var i=this;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.subscriberPrimary;return function*(){var s;if(!i.pcManager)throw new Ce("PC manager is closed");const a=r?i.pcManager.subscriber:i.pcManager.publisher,o=r?"Subscriber":"Publisher";if(!a)throw new ie("".concat(o," connection not set"),$.InternalError);let c=!1;!r&&!i.dataChannelForKind(t,r)&&(i.createDataChannels(),c=!0),!c&&!r&&!i.pcManager.publisher.isICEConnected&&i.pcManager.publisher.getICEConnectionState()!=="checking"&&(c=!0),c&&i.negotiate();const l=i.dataChannelForKind(t,r);if((l==null?void 0:l.readyState)==="open")return;const u=new Date().getTime()+i.peerConnectionTimeout;for(;new Date().getTime()<u;){if(a.isICEConnected&&((s=i.dataChannelForKind(t,r))===null||s===void 0?void 0:s.readyState)==="open")return;yield Ge(50)}throw new ie("could not establish ".concat(o," connection, state: ").concat(a.getICEConnectionState()),$.InternalError)}()})}ensurePublisherConnected(e){return y(this,void 0,void 0,function*(){this.publisherConnectionPromise||(this.publisherConnectionPromise=this.ensureDataTransportConnected(e,!1)),yield this.publisherConnectionPromise})}verifyTransport(){return!(!this.pcManager||this.pcManager.currentState!==fe.CONNECTED||!this.client.ws||this.client.ws.readyState===WebSocket.CLOSED)}negotiate(){return y(this,void 0,void 0,function*(){return new Promise((e,t)=>y(this,void 0,void 0,function*(){if(!this.pcManager){t(new Ua("PC manager is closed"));return}this.pcManager.requirePublisher(),this.pcManager.publisher.getTransceivers().length==0&&!this.lossyDC&&!this.reliableDC&&this.createDataChannels();const i=new AbortController,r=()=>{i.abort(),this.log.debug("engine disconnected while negotiation was ongoing",this.logContext),e()};this.isClosed&&t("cannot negotiate on closed engine"),this.on(M.Closing,r),this.pcManager.publisher.once(Hn.RTPVideoPayloadTypes,s=>{const a=new Map;s.forEach(o=>{const c=o.codec.toLowerCase();uT(c)&&a.set(o.payload,c)}),this.emit(M.RTPVideoMapUpdate,a)});try{yield this.pcManager.negotiate(i),e()}catch(s){s instanceof Ua&&(this.fullReconnectOnNext=!0),this.handleDisconnect("negotiation",Ln.RR_UNKNOWN),t(s)}finally{this.off(M.Closing,r)}}))})}dataChannelForKind(e,t){if(t){if(e===X.LOSSY)return this.lossyDCSub;if(e===X.RELIABLE)return this.reliableDCSub}else{if(e===X.LOSSY)return this.lossyDC;if(e===X.RELIABLE)return this.reliableDC}}sendSyncState(e,t){var i,r;if(!this.pcManager){this.log.warn("sync state cannot be sent without peer connection setup",this.logContext);return}const s=this.pcManager.subscriber.getLocalDescription(),a=this.pcManager.subscriber.getRemoteDescription(),o=(r=(i=this.signalOpts)===null||i===void 0?void 0:i.autoSubscribe)!==null&&r!==void 0?r:!0,c=new Array,l=new Array;e.forEach(u=>{u.isDesired!==o&&c.push(u.trackSid),u.isEnabled||l.push(u.trackSid)}),this.client.sendSyncState(new $u({answer:s?Jr({sdp:s.sdp,type:s.type}):void 0,offer:a?Jr({sdp:a.sdp,type:a.type}):void 0,subscription:new Lr({trackSids:c,subscribe:!o,participantTracks:[]}),publishTracks:yT(t),dataChannels:this.dataChannelsInfo(),trackSidsDisabled:l}))}failNext(){this.shouldFailNext=!0}dataChannelsInfo(){const e=[],t=(i,r)=>{(i==null?void 0:i.id)!==void 0&&i.id!==null&&e.push(new Yu({label:i.label,id:i.id,target:r}))};return t(this.dataChannelForKind(X.LOSSY),at.PUBLISHER),t(this.dataChannelForKind(X.RELIABLE),at.PUBLISHER),t(this.dataChannelForKind(X.LOSSY,!0),at.SUBSCRIBER),t(this.dataChannelForKind(X.RELIABLE,!0),at.SUBSCRIBER),e}clearReconnectTimeout(){this.reconnectTimeout&&Ie.clearTimeout(this.reconnectTimeout)}clearPendingReconnect(){this.clearReconnectTimeout(),this.reconnectAttempts=0}registerOnLineListener(){We()&&window.addEventListener("online",this.handleBrowserOnLine)}deregisterOnLineListener(){We()&&window.removeEventListener("online",this.handleBrowserOnLine)}}class qn extends Error{}function tS(n){return n!==void 0&&n>13}function nS(n,e){const t=n.participantIdentity?n.participantIdentity:e.participantIdentity;n.participantIdentity=t,e.participantIdentity=t;const i=n.destinationIdentities.length!==0?n.destinationIdentities:e.destinationIdentities;n.destinationIdentities=i,e.destinationIdentities=i}class yo{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 Ka(this.serverUrl)}getServerUrl(){return this.serverUrl}getNextBestRegionUrl(e){return y(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(i=>!this.attemptedRegions.find(r=>r.url===i.url));if(t.length>0){const i=t[0];return this.attemptedRegions.push(i),q.debug("next region: ".concat(i.region)),i.url}else return null})}resetAttempts(){this.attemptedRegions=[]}fetchRegionSettings(e){return y(this,void 0,void 0,function*(){const t=yield fetch("".concat(iS(this.serverUrl),"/regions"),{headers:{authorization:"Bearer ".concat(this.token)},signal:e});if(t.ok){const i=yield t.json();return this.lastUpdateAt=Date.now(),i}else throw new ie("Could not fetch region settings: ".concat(t.statusText),t.status===401?$.NotAllowed:$.InternalError,t.status)})}setServerReportedRegions(e){this.regionSettings=e,this.lastUpdateAt=Date.now()}}function iS(n){return"".concat(n.protocol.replace("ws","http"),"//").concat(n.host,"/settings")}class wh{get info(){return this._info}constructor(e,t,i){this.reader=t,this.totalByteSize=i,this._info=e,this.bytesReceived=0}}class rS extends wh{handleChunkReceived(e){var t;this.bytesReceived+=e.content.byteLength;const i=this.totalByteSize?this.bytesReceived/this.totalByteSize:void 0;(t=this.onProgress)===null||t===void 0||t.call(this,i)}[Symbol.asyncIterator](){const e=this.reader.getReader();return{next:()=>y(this,void 0,void 0,function*(){try{const{done:t,value:i}=yield e.read();return t?{done:!0,value:void 0}:(this.handleChunkReceived(i),{done:!1,value:i.content})}catch{return{done:!0,value:void 0}}}),return(){return y(this,void 0,void 0,function*(){return e.releaseLock(),{done:!0,value:void 0}})}}}readAll(){return y(this,void 0,void 0,function*(){var e,t,i,r;let s=new Set;try{for(var a=!0,o=qt(this),c;c=yield o.next(),e=c.done,!e;a=!0){r=c.value,a=!1;const l=r;s.add(l)}}catch(l){t={error:l}}finally{try{!a&&!e&&(i=o.return)&&(yield i.call(o))}finally{if(t)throw t.error}}return Array.from(s)})}}class sS extends wh{constructor(e,t,i){super(e,t,i),this.receivedChunks=new Map}handleChunkReceived(e){var t;const i=Yr(e.chunkIndex),r=this.receivedChunks.get(i);if(r&&r.version>e.version)return;this.receivedChunks.set(i,e),this.bytesReceived+=e.content.byteLength;const s=this.totalByteSize?this.bytesReceived/this.totalByteSize:void 0;(t=this.onProgress)===null||t===void 0||t.call(this,s)}[Symbol.asyncIterator](){const e=this.reader.getReader(),t=new TextDecoder;return{next:()=>y(this,void 0,void 0,function*(){try{const{done:i,value:r}=yield e.read();return i?{done:!0,value:void 0}:(this.handleChunkReceived(r),{done:!1,value:t.decode(r.content)})}catch{return{done:!0,value:void 0}}}),return(){return y(this,void 0,void 0,function*(){return e.releaseLock(),{done:!0,value:void 0}})}}}readAll(){return y(this,void 0,void 0,function*(){var e,t,i,r;let s="";try{for(var a=!0,o=qt(this),c;c=yield o.next(),e=c.done,!e;a=!0)r=c.value,a=!1,s+=r}catch(l){t={error:l}}finally{try{!a&&!e&&(i=o.return)&&(yield i.call(o))}finally{if(t)throw t.error}}return s})}}class _h{constructor(e,t,i){this.writableStream=e,this.defaultWriter=e.getWriter(),this.onClose=i,this.info=t}write(e){return this.defaultWriter.write(e)}close(){return y(this,void 0,void 0,function*(){var e;yield this.defaultWriter.close(),this.defaultWriter.releaseLock(),(e=this.onClose)===null||e===void 0||e.call(this)})}}class aS extends _h{}class oS extends _h{}class Eh extends P{constructor(e,t,i,r,s){super(e,i,s),this.sid=t,this.receiver=r}get isLocal(){return!1}setMuted(e){this.isMuted!==e&&(this.isMuted=e,this._mediaStreamTrack.enabled=!e,this.emit(e?N.Muted:N.Unmuted,this))}setMediaStream(e){this.mediaStream=e;const t=i=>{i.track===this._mediaStreamTrack&&(e.removeEventListener("removetrack",t),this.receiver&&"playoutDelayHint"in this.receiver&&(this.receiver.playoutDelayHint=void 0),this.receiver=void 0,this._currentBitrate=0,this.emit(N.Ended,this))};e.addEventListener("removetrack",t)}start(){this.startMonitor(),super.enable()}stop(){this.stopMonitor(),super.disable()}getRTCStatsReport(){return y(this,void 0,void 0,function*(){var e;return!((e=this.receiver)===null||e===void 0)&&e.getStats?yield this.receiver.getStats():void 0})}setPlayoutDelay(e){this.receiver?"playoutDelayHint"in this.receiver?this.receiver.playoutDelayHint=e:this.log.warn("Playout delay not supported in this browser"):this.log.warn("Cannot set playout delay, track already ended")}getPlayoutDelay(){if(this.receiver){if("playoutDelayHint"in this.receiver)return this.receiver.playoutDelayHint;this.log.warn("Playout delay not supported in this browser")}else this.log.warn("Cannot get playout delay, track already ended");return 0}startMonitor(){this.monitorInterval||(this.monitorInterval=setInterval(()=>this.monitorReceiver(),po)),kT()&&this.registerTimeSyncUpdate()}registerTimeSyncUpdate(){const e=()=>{var t;this.timeSyncHandle=requestAnimationFrame(()=>e());const i=(t=this.receiver)===null||t===void 0?void 0:t.getSynchronizationSources()[0];if(i){const{timestamp:r,rtpTimestamp:s}=i;s&&this.rtpTimestamp!==s&&(this.emit(N.TimeSyncUpdate,{timestamp:r,rtpTimestamp:s}),this.rtpTimestamp=s)}};e()}}class cS extends Eh{constructor(e,t,i,r,s,a){super(e,t,P.Kind.Audio,i,a),this.monitorReceiver=()=>y(this,void 0,void 0,function*(){if(!this.receiver){this._currentBitrate=0;return}const o=yield this.getReceiverStats();o&&this.prevStats&&this.receiver&&(this._currentBitrate=Qr(o,this.prevStats)),this.prevStats=o}),this.audioContext=r,this.webAudioPluginNodes=[],s&&(this.sinkId=s.deviceId)}setVolume(e){var t;for(const i of this.attachedElements)this.audioContext?(t=this.gainNode)===null||t===void 0||t.gain.setTargetAtTime(e,0,.1):i.volume=e;St()&&this._mediaStreamTrack._setVolume(e),this.elementVolume=e}getVolume(){if(this.elementVolume)return this.elementVolume;if(St())return 1;let e=0;return this.attachedElements.forEach(t=>{t.volume>e&&(e=t.volume)}),e}setSinkId(e){return y(this,void 0,void 0,function*(){this.sinkId=e,yield Promise.all(this.attachedElements.map(t=>{if(qa(t))return t.setSinkId(e)}))})}attach(e){const t=this.attachedElements.length===0;return e?super.attach(e):e=super.attach(),this.sinkId&&qa(e)&&e.setSinkId(this.sinkId).catch(i=>{this.log.error("Failed to set sink id on remote audio track",i,this.logContext)}),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(e,t){this.disconnectWebAudio(),this.sourceNode=e.createMediaStreamSource(t.srcObject);let i=this.sourceNode;this.webAudioPluginNodes.forEach(r=>{i.connect(r),i=r}),this.gainNode=e.createGain(),i.connect(this.gainNode),this.gainNode.connect(e.destination),this.elementVolume&&this.gainNode.gain.setTargetAtTime(this.elementVolume,0,.1),e.state!=="running"&&e.resume().then(()=>{e.state!=="running"&&this.emit(N.AudioPlaybackFailed,new Error("Audio Context couldn't be started automatically"))}).catch(r=>{this.emit(N.AudioPlaybackFailed,r)})}disconnectWebAudio(){var e,t;(e=this.gainNode)===null||e===void 0||e.disconnect(),(t=this.sourceNode)===null||t===void 0||t.disconnect(),this.gainNode=void 0,this.sourceNode=void 0}getReceiverStats(){return y(this,void 0,void 0,function*(){if(!this.receiver||!this.receiver.getStats)return;const e=yield this.receiver.getStats();let t;return e.forEach(i=>{i.type==="inbound-rtp"&&(t={type:"audio",streamId:i.id,timestamp:i.timestamp,jitter:i.jitter,bytesReceived:i.bytesReceived,concealedSamples:i.concealedSamples,concealmentEvents:i.concealmentEvents,silentConcealedSamples:i.silentConcealedSamples,silentConcealmentEvents:i.silentConcealmentEvents,totalAudioEnergy:i.totalAudioEnergy,totalSamplesDuration:i.totalSamplesDuration})}),t})}}const ko=100;class lS extends Eh{constructor(e,t,i,r,s){super(e,t,P.Kind.Video,i,s),this.elementInfos=[],this.monitorReceiver=()=>y(this,void 0,void 0,function*(){if(!this.receiver){this._currentBitrate=0;return}const a=yield this.getReceiverStats();a&&this.prevStats&&this.receiver&&(this._currentBitrate=Qr(a,this.prevStats)),this.prevStats=a}),this.debouncedHandleResize=lo(()=>{this.updateDimensions()},ko),this.adaptiveStreamSettings=r}get isAdaptiveStream(){return this.adaptiveStreamSettings!==void 0}get mediaStreamTrack(){return this._mediaStreamTrack}setMuted(e){super.setMuted(e),this.attachedElements.forEach(t=>{e?Vn(this._mediaStreamTrack,t):jn(this._mediaStreamTrack,t)})}attach(e){if(e?super.attach(e):e=super.attach(),this.adaptiveStreamSettings&&this.elementInfos.find(t=>t.element===e)===void 0){const t=new uS(e);this.observeElementInfo(t)}return e}observeElementInfo(e){this.adaptiveStreamSettings&&this.elementInfos.find(t=>t===e)===void 0?(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){this.log.warn("stopObservingElementInfo ignored",this.logContext);return}const t=this.elementInfos.filter(i=>i===e);for(const i of t)i.stopObserving();this.elementInfos=this.elementInfos.filter(i=>i!==e),this.updateVisibility(),this.debouncedHandleResize()}detach(e){let t=[];if(e)return this.stopObservingElement(e),super.detach(e);t=super.detach();for(const i of t)this.stopObservingElement(i);return t}getDecoderImplementation(){var e;return(e=this.prevStats)===null||e===void 0?void 0:e.decoderImplementation}getReceiverStats(){return y(this,void 0,void 0,function*(){if(!this.receiver||!this.receiver.getStats)return;const e=yield this.receiver.getStats();let t,i="",r=new Map;return e.forEach(s=>{s.type==="inbound-rtp"?(i=s.codecId,t={type:"video",streamId:s.id,framesDecoded:s.framesDecoded,framesDropped:s.framesDropped,framesReceived:s.framesReceived,packetsReceived:s.packetsReceived,packetsLost:s.packetsLost,frameWidth:s.frameWidth,frameHeight:s.frameHeight,pliCount:s.pliCount,firCount:s.firCount,nackCount:s.nackCount,jitter:s.jitter,timestamp:s.timestamp,bytesReceived:s.bytesReceived,decoderImplementation:s.decoderImplementation}):s.type==="codec"&&r.set(s.id,s)}),t&&i!==""&&r.get(i)&&(t.mimeType=r.get(i).mimeType),t})}stopObservingElement(e){const t=this.elementInfos.filter(i=>i.element===e);for(const i of t)this.stopObservingElementInfo(i)}handleAppVisibilityChanged(){const e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return y(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),this.isAdaptiveStream&&this.updateVisibility()})}updateVisibility(){var e,t;const i=this.elementInfos.reduce((o,c)=>Math.max(o,c.visibilityChangedAt||0),0),r=!((t=(e=this.adaptiveStreamSettings)===null||e===void 0?void 0:e.pauseVideoInBackground)!==null&&t!==void 0)||t?this.isInBackground:!1,s=this.elementInfos.some(o=>o.pictureInPicture),a=this.elementInfos.some(o=>o.visible)&&!r||s;if(this.lastVisible!==a){if(!a&&Date.now()-i<ko){Ie.setTimeout(()=>{this.updateVisibility()},ko);return}this.lastVisible=a,this.emit(N.VisibilityChanged,a,this)}}updateDimensions(){var e,t;let i=0,r=0;const s=this.getPixelDensity();for(const a of this.elementInfos){const o=a.width()*s,c=a.height()*s;o+c>i+r&&(i=o,r=c)}((e=this.lastDimensions)===null||e===void 0?void 0:e.width)===i&&((t=this.lastDimensions)===null||t===void 0?void 0:t.height)===r||(this.lastDimensions={width:i,height:r},this.emit(N.VideoDimensionsChanged,this.lastDimensions,this))}getPixelDensity(){var e;const t=(e=this.adaptiveStreamSettings)===null||e===void 0?void 0:e.pixelDensity;return t==="screen"?$d():t||($d()>2?2:1)}}class uS{get visible(){return this.isPiP||this.isIntersecting}get pictureInPicture(){return this.isPiP}constructor(e,t){this.onVisibilityChanged=i=>{var r;const{target:s,isIntersecting:a}=i;s===this.element&&(this.isIntersecting=a,this.isPiP=Si(this.element),this.visibilityChangedAt=Date.now(),(r=this.handleVisibilityChanged)===null||r===void 0||r.call(this))},this.onEnterPiP=()=>{var i,r,s;(r=(i=window.documentPictureInPicture)===null||i===void 0?void 0:i.window)===null||r===void 0||r.addEventListener("pagehide",this.onLeavePiP),this.isPiP=Si(this.element),(s=this.handleVisibilityChanged)===null||s===void 0||s.call(this)},this.onLeavePiP=()=>{var i;this.isPiP=Si(this.element),(i=this.handleVisibilityChanged)===null||i===void 0||i.call(this)},this.element=e,this.isIntersecting=t??To(e),this.isPiP=We()&&Si(e),this.visibilityChangedAt=0}width(){return this.element.clientWidth}height(){return this.element.clientHeight}observe(){var e,t,i;this.isIntersecting=To(this.element),this.isPiP=Si(this.element),this.element.handleResize=()=>{var r;(r=this.handleResize)===null||r===void 0||r.call(this)},this.element.handleVisibilityChanged=this.onVisibilityChanged,Xd().observe(this.element),Yd().observe(this.element),this.element.addEventListener("enterpictureinpicture",this.onEnterPiP),this.element.addEventListener("leavepictureinpicture",this.onLeavePiP),(e=window.documentPictureInPicture)===null||e===void 0||e.addEventListener("enter",this.onEnterPiP),(i=(t=window.documentPictureInPicture)===null||t===void 0?void 0:t.window)===null||i===void 0||i.addEventListener("pagehide",this.onLeavePiP)}stopObserving(){var e,t,i,r,s;(e=Xd())===null||e===void 0||e.unobserve(this.element),(t=Yd())===null||t===void 0||t.unobserve(this.element),this.element.removeEventListener("enterpictureinpicture",this.onEnterPiP),this.element.removeEventListener("leavepictureinpicture",this.onLeavePiP),(i=window.documentPictureInPicture)===null||i===void 0||i.removeEventListener("enter",this.onEnterPiP),(s=(r=window.documentPictureInPicture)===null||r===void 0?void 0:r.window)===null||s===void 0||s.removeEventListener("pagehide",this.onLeavePiP)}}function Si(n){var e,t;return document.pictureInPictureElement===n?!0:!((e=window.documentPictureInPicture)===null||e===void 0)&&e.window?To(n,(t=window.documentPictureInPicture)===null||t===void 0?void 0:t.window):!1}function To(n,e){const t=e||window;let i=n.offsetTop,r=n.offsetLeft;const s=n.offsetWidth,a=n.offsetHeight,{hidden:o}=n,{display:c}=getComputedStyle(n);for(;n.offsetParent;)n=n.offsetParent,i+=n.offsetTop,r+=n.offsetLeft;return i<t.pageYOffset+t.innerHeight&&r<t.pageXOffset+t.innerWidth&&i+a>t.pageYOffset&&r+s>t.pageXOffset&&!o&&c!=="none"}class It extends Tt.EventEmitter{constructor(e,t,i,r){var s;super(),this.metadataMuted=!1,this.encryption=$e.NONE,this.log=q,this.handleMuted=()=>{this.emit(N.Muted)},this.handleUnmuted=()=>{this.emit(N.Unmuted)},this.log=Et((s=r==null?void 0:r.loggerName)!==null&&s!==void 0?s:ot.Publication),this.loggerContextCb=this.loggerContextCb,this.setMaxListeners(100),this.kind=e,this.trackSid=t,this.trackName=i,this.source=P.Source.Unknown}setTrack(e){this.track&&(this.track.off(N.Muted,this.handleMuted),this.track.off(N.Unmuted,this.handleUnmuted)),this.track=e,e&&(e.on(N.Muted,this.handleMuted),e.on(N.Unmuted,this.handleUnmuted))}get logContext(){var e;return Object.assign(Object.assign({},(e=this.loggerContextCb)===null||e===void 0?void 0:e.call(this)),ee(this))}get isMuted(){return this.metadataMuted}get isEnabled(){return!0}get isSubscribed(){return this.track!==void 0}get isEncrypted(){return this.encryption!==$e.NONE}get audioTrack(){if(Rt(this.track))return this.track}get videoTrack(){if(zn(this.track))return this.track}updateInfo(e){this.trackSid=e.sid,this.trackName=e.name,this.source=P.sourceFromProto(e.source),this.mimeType=e.mimeType,this.kind===P.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(n){(function(e){e.Desired="desired",e.Subscribed="subscribed",e.Unsubscribed="unsubscribed"})(n.SubscriptionStatus||(n.SubscriptionStatus={})),function(e){e.Allowed="allowed",e.NotAllowed="not_allowed"}(n.PermissionStatus||(n.PermissionStatus={}))})(It||(It={}));class So extends It{get isUpstreamPaused(){var e;return(e=this.track)===null||e===void 0?void 0:e.isUpstreamPaused}constructor(e,t,i,r){super(e,t.sid,t.name,r),this.track=void 0,this.handleTrackEnded=()=>{this.emit(N.Ended)},this.updateInfo(t),this.setTrack(i)}setTrack(e){this.track&&this.track.off(N.Ended,this.handleTrackEnded),super.setTrack(e),e&&e.on(N.Ended,this.handleTrackEnded)}get isMuted(){return this.track?this.track.isMuted:super.isMuted}get audioTrack(){return super.audioTrack}get videoTrack(){return super.videoTrack}get isLocal(){return!0}mute(){return y(this,void 0,void 0,function*(){var e;return(e=this.track)===null||e===void 0?void 0:e.mute()})}unmute(){return y(this,void 0,void 0,function*(){var e;return(e=this.track)===null||e===void 0?void 0:e.unmute()})}pauseUpstream(){return y(this,void 0,void 0,function*(){var e;yield(e=this.track)===null||e===void 0?void 0:e.pauseUpstream()})}resumeUpstream(){return y(this,void 0,void 0,function*(){var e;yield(e=this.track)===null||e===void 0?void 0:e.resumeUpstream()})}getTrackFeatures(){var e;if(Rt(this.track)){const t=this.track.getSourceTrackSettings(),i=new Set;return t.autoGainControl&&i.add(st.TF_AUTO_GAIN_CONTROL),t.echoCancellation&&i.add(st.TF_ECHO_CANCELLATION),t.noiseSuppression&&i.add(st.TF_NOISE_SUPPRESSION),t.channelCount&&t.channelCount>1&&i.add(st.TF_STEREO),!((e=this.options)===null||e===void 0)&&e.dtx||i.add(st.TF_NO_DTX),this.track.enhancedNoiseCancellation&&i.add(st.TF_ENHANCED_NOISE_CANCELLATION),Array.from(i.values())}else return[]}}function ns(n,e){return y(this,void 0,void 0,function*(){n??(n={});let t=!1;const{audioProcessor:i,videoProcessor:r,optionsWithoutProcessor:s}=ih(n);let a=s.audio,o=s.video;if(i&&typeof s.audio=="object"&&(s.audio.processor=i),r&&typeof s.video=="object"&&(s.video.processor=r),n.audio&&typeof s.audio=="object"&&typeof s.audio.deviceId=="string"){const d=s.audio.deviceId;s.audio.deviceId={exact:d},t=!0,a=Object.assign(Object.assign({},s.audio),{deviceId:{ideal:d}})}if(s.video&&typeof s.video=="object"&&typeof s.video.deviceId=="string"){const d=s.video.deviceId;s.video.deviceId={exact:d},t=!0,o=Object.assign(Object.assign({},s.video),{deviceId:{ideal:d}})}(s.audio===!0||typeof s.audio=="object"&&!s.audio.deviceId)&&(s.audio={deviceId:"default"}),s.video===!0?s.video={deviceId:"default"}:typeof s.video=="object"&&!s.video.deviceId&&(s.video.deviceId="default");const c=Zd(s,fh,ph),l=no(c),u=navigator.mediaDevices.getUserMedia(l);s.audio&&(we.userMediaPromiseMap.set("audioinput",u),u.catch(()=>we.userMediaPromiseMap.delete("audioinput"))),s.video&&(we.userMediaPromiseMap.set("videoinput",u),u.catch(()=>we.userMediaPromiseMap.delete("videoinput")));try{const d=yield u;return yield Promise.all(d.getTracks().map(h=>y(this,void 0,void 0,function*(){const f=h.kind==="audio";let p=f?c.audio:c.video;(typeof p=="boolean"||!p)&&(p={});let g;const v=f?l.audio:l.video;typeof v!="boolean"&&(g=v);const b=h.getSettings().deviceId;g!=null&&g.deviceId&&Jt(g.deviceId)!==b?g.deviceId=b:g||(g={deviceId:b});const S=VT(h,g,e);return S.kind===P.Kind.Video?S.source=P.Source.Camera:S.kind===P.Kind.Audio&&(S.source=P.Source.Microphone),S.mediaStream=d,Rt(S)&&i?yield S.setProcessor(i):zn(S)&&r&&(yield S.setProcessor(r)),S})))}catch(d){if(!t)throw d;return ns(Object.assign(Object.assign({},n),{audio:a,video:o}),e)}})}function dS(n){return y(this,void 0,void 0,function*(){return(yield ns({audio:!1,video:n??!0}))[0]})}function hS(n){return y(this,void 0,void 0,function*(){return(yield ns({audio:n??!0,video:!1}))[0]})}var en;(function(n){n.Excellent="excellent",n.Good="good",n.Poor="poor",n.Lost="lost",n.Unknown="unknown"})(en||(en={}));function fS(n){switch(n){case pi.EXCELLENT:return en.Excellent;case pi.GOOD:return en.Good;case pi.POOR:return en.Poor;case pi.LOST:return en.Lost;default:return en.Unknown}}class Ph extends Tt.EventEmitter{get logContext(){var e,t;return Object.assign({},(t=(e=this.loggerOptions)===null||e===void 0?void 0:e.loggerContextCb)===null||t===void 0?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;return((e=this.permissions)===null||e===void 0?void 0:e.agent)||this.kind===Mr.AGENT}get isActive(){var e;return((e=this.participantInfo)===null||e===void 0?void 0:e.state)===Dn.ACTIVE}get kind(){return this._kind}get attributes(){return Object.freeze(Object.assign({},this._attributes))}constructor(e,t,i,r,s,a){let o=arguments.length>6&&arguments[6]!==void 0?arguments[6]:Mr.STANDARD;var c;super(),this.audioLevel=0,this.isSpeaking=!1,this._connectionQuality=en.Unknown,this.log=q,this.log=Et((c=a==null?void 0:a.loggerName)!==null&&c!==void 0?c:ot.Participant),this.loggerOptions=a,this.setMaxListeners(100),this.sid=e,this.identity=t,this.name=i,this.metadata=r,this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.trackPublications=new Map,this._kind=o,this._attributes=s??{}}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}waitUntilActive(){return this.isActive?Promise.resolve():this.activeFuture?this.activeFuture.promise:(this.activeFuture=new Ja,this.once(L.Active,()=>{var e,t;(t=(e=this.activeFuture)===null||e===void 0?void 0:e.resolve)===null||t===void 0||t.call(e),this.activeFuture=void 0}),this.activeFuture.promise)}get connectionQuality(){return this._connectionQuality}get isCameraEnabled(){var e;const t=this.getTrackPublication(P.Source.Camera);return!(!((e=t==null?void 0:t.isMuted)!==null&&e!==void 0)||e)}get isMicrophoneEnabled(){var e;const t=this.getTrackPublication(P.Source.Microphone);return!(!((e=t==null?void 0:t.isMuted)!==null&&e!==void 0)||e)}get isScreenShareEnabled(){return!!this.getTrackPublication(P.Source.ScreenShare)}get isLocal(){return!1}get joinedAt(){return this.participantInfo?new Date(Number.parseInt(this.participantInfo.joinedAt.toString())*1e3):new Date}updateInfo(e){var t;return this.participantInfo&&this.participantInfo.sid===e.sid&&this.participantInfo.version>e.version?!1:(this.identity=e.identity,this.sid=e.sid,this._setName(e.name),this._setMetadata(e.metadata),this._setAttributes(e.attributes),e.state===Dn.ACTIVE&&((t=this.participantInfo)===null||t===void 0?void 0:t.state)!==Dn.ACTIVE&&this.emit(L.Active),e.permission&&this.setPermissions(e.permission),this.participantInfo=e,!0)}_setMetadata(e){const t=this.metadata!==e,i=this.metadata;this.metadata=e,t&&this.emit(L.ParticipantMetadataChanged,i)}_setName(e){const t=this.name!==e;this.name=e,t&&this.emit(L.ParticipantNameChanged,e)}_setAttributes(e){const t=TT(this.attributes,e);this._attributes=e,Object.keys(t).length>0&&this.emit(L.AttributesChanged,t)}setPermissions(e){var t,i,r,s,a,o;const c=this.permissions,l=e.canPublish!==((t=this.permissions)===null||t===void 0?void 0:t.canPublish)||e.canSubscribe!==((i=this.permissions)===null||i===void 0?void 0:i.canSubscribe)||e.canPublishData!==((r=this.permissions)===null||r===void 0?void 0:r.canPublishData)||e.hidden!==((s=this.permissions)===null||s===void 0?void 0:s.hidden)||e.recorder!==((a=this.permissions)===null||a===void 0?void 0:a.recorder)||e.canPublishSources.length!==this.permissions.canPublishSources.length||e.canPublishSources.some((u,d)=>{var h;return u!==((h=this.permissions)===null||h===void 0?void 0:h.canPublishSources[d])})||e.canSubscribeMetrics!==((o=this.permissions)===null||o===void 0?void 0:o.canSubscribeMetrics);return this.permissions=e,l&&this.emit(L.ParticipantPermissionsChanged,c),l}setIsSpeaking(e){e!==this.isSpeaking&&(this.isSpeaking=e,e&&(this.lastSpokeAt=new Date),this.emit(L.IsSpeakingChanged,e))}setConnectionQuality(e){const t=this._connectionQuality;this._connectionQuality=fS(e),t!==this._connectionQuality&&this.emit(L.ConnectionQualityChanged,this._connectionQuality)}setDisconnected(){var e,t;this.activeFuture&&((t=(e=this.activeFuture).reject)===null||t===void 0||t.call(e,new Error("Participant disconnected")),this.activeFuture=void 0)}setAudioContext(e){this.audioContext=e,this.audioTrackPublications.forEach(t=>Rt(t.track)&&t.track.setAudioContext(e))}addTrackPublication(e){e.on(N.Muted,()=>{this.emit(L.TrackMuted,e)}),e.on(N.Unmuted,()=>{this.emit(L.TrackUnmuted,e)});const t=e;switch(t.track&&(t.track.sid=e.trackSid),this.trackPublications.set(e.trackSid,e),e.kind){case P.Kind.Audio:this.audioTrackPublications.set(e.trackSid,e);break;case P.Kind.Video:this.videoTrackPublications.set(e.trackSid,e);break}}}function pS(n){var e,t,i;if(!n.participantSid&&!n.participantIdentity)throw new Error("Invalid track permission, must provide at least one of participantIdentity and participantSid");return new qu({participantIdentity:(e=n.participantIdentity)!==null&&e!==void 0?e:"",participantSid:(t=n.participantSid)!==null&&t!==void 0?t:"",allTracks:(i=n.allowAll)!==null&&i!==void 0?i:!1,trackSids:n.allowedTrackSids||[]})}const Rh=15e3;class mS extends Ph{constructor(e,t,i,r,s){super(e,t,void 0,void 0,void 0,{loggerName:r.loggerName,loggerContextCb:()=>this.engine.logContext}),this.pendingPublishing=new Set,this.pendingPublishPromises=new Map,this.participantTrackPermissions=[],this.allParticipantsAllowedToSubscribe=!0,this.encryptionType=$e.NONE,this.enabledPublishVideoCodecs=[],this.pendingAcks=new Map,this.pendingResponses=new Map,this.handleReconnecting=()=>{this.reconnectFuture||(this.reconnectFuture=new Ja)},this.handleReconnected=()=>{var a,o;(o=(a=this.reconnectFuture)===null||a===void 0?void 0:a.resolve)===null||o===void 0||o.call(a),this.reconnectFuture=void 0,this.updateTrackSubscriptionPermissions()},this.handleDisconnected=()=>{var a,o;this.reconnectFuture&&(this.reconnectFuture.promise.catch(c=>this.log.warn(c.message,this.logContext)),(o=(a=this.reconnectFuture)===null||a===void 0?void 0:a.reject)===null||o===void 0||o.call(a,"Got disconnected during reconnection attempt"),this.reconnectFuture=void 0)},this.handleSignalRequestResponse=a=>{const{requestId:o,reason:c,message:l}=a,u=this.pendingSignalRequests.get(o);u&&(c!==wa.OK&&u.reject(new Vd(l,c)),this.pendingSignalRequests.delete(o))},this.handleDataPacket=a=>{switch(a.value.case){case"rpcResponse":let o=a.value.value,c=null,l=null;o.value.case==="payload"?c=o.value.value:o.value.case==="error"&&(l=pe.fromProto(o.value.value)),this.handleIncomingRpcResponse(o.requestId,c,l);break;case"rpcAck":let u=a.value.value;this.handleIncomingRpcAck(u.requestId);break}},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(a=>pS(a)))},this.onTrackUnmuted=a=>{this.onTrackMuted(a,a.isUpstreamPaused)},this.onTrackMuted=(a,o)=>{if(o===void 0&&(o=!0),!a.sid){this.log.error("could not update mute status for unpublished track",Object.assign(Object.assign({},this.logContext),ee(a)));return}this.engine.updateMuteStatus(a.sid,o)},this.onTrackUpstreamPaused=a=>{this.log.debug("upstream paused",Object.assign(Object.assign({},this.logContext),ee(a))),this.onTrackMuted(a,!0)},this.onTrackUpstreamResumed=a=>{this.log.debug("upstream resumed",Object.assign(Object.assign({},this.logContext),ee(a))),this.onTrackMuted(a,a.isMuted)},this.onTrackFeatureUpdate=a=>{const o=this.audioTrackPublications.get(a.sid);if(!o){this.log.warn("Could not update local audio track settings, missing publication for track ".concat(a.sid),this.logContext);return}this.engine.client.sendUpdateLocalAudioTrack(o.trackSid,o.getTrackFeatures())},this.handleSubscribedQualityUpdate=a=>y(this,void 0,void 0,function*(){var o,c,l,u,d,h;if(!(!((d=this.roomOptions)===null||d===void 0)&&d.dynacast))return;const f=this.videoTrackPublications.get(a.trackSid);if(!f){this.log.warn("received subscribed quality update for unknown track",Object.assign(Object.assign({},this.logContext),{trackSid:a.trackSid}));return}if(a.subscribedCodecs.length>0){if(!f.videoTrack)return;const b=yield f.videoTrack.setPublishingCodecs(a.subscribedCodecs);try{for(var p=!0,g=qt(b),v;v=yield g.next(),o=v.done,!o;p=!0){u=v.value,p=!1;const S=u;Zk(S)&&(this.log.debug("publish ".concat(S," for ").concat(f.videoTrack.sid),Object.assign(Object.assign({},this.logContext),ee(f))),yield this.publishAdditionalCodecForTrack(f.videoTrack,S,f.options))}}catch(S){c={error:S}}finally{try{!p&&!o&&(l=g.return)&&(yield l.call(g))}finally{if(c)throw c.error}}}else a.subscribedQualities.length>0&&(yield(h=f.videoTrack)===null||h===void 0?void 0:h.setPublishingLayers(a.subscribedQualities))}),this.handleLocalTrackUnpublished=a=>{const o=this.trackPublications.get(a.trackSid);if(!o){this.log.warn("received unpublished event for unknown track",Object.assign(Object.assign({},this.logContext),{trackSid:a.trackSid}));return}this.unpublishTrack(o.track)},this.handleTrackEnded=a=>y(this,void 0,void 0,function*(){if(a.source===P.Source.ScreenShare||a.source===P.Source.ScreenShareAudio)this.log.debug("unpublishing local track due to TrackEnded",Object.assign(Object.assign({},this.logContext),ee(a))),this.unpublishTrack(a);else if(a.isUserProvided)yield a.mute();else if(gn(a)||Qt(a))try{if(We())try{const o=yield navigator==null?void 0:navigator.permissions.query({name:a.source===P.Source.Camera?"camera":"microphone"});if(o&&o.state==="denied")throw this.log.warn("user has revoked access to ".concat(a.source),Object.assign(Object.assign({},this.logContext),ee(a))),o.onchange=()=>{o.state!=="denied"&&(a.isMuted||a.restartTrack(),o.onchange=null)},new Error("GetUserMedia Permission denied")}catch{}a.isMuted||(this.log.debug("track ended, attempting to use a different device",Object.assign(Object.assign({},this.logContext),ee(a))),gn(a)?yield a.restartTrack({deviceId:"default"}):yield a.restartTrack())}catch{this.log.warn("could not restart track, muting instead",Object.assign(Object.assign({},this.logContext),ee(a))),yield a.mute()}}),this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.trackPublications=new Map,this.engine=i,this.roomOptions=r,this.setupEngine(i),this.activeDeviceMap=new Map([["audioinput","default"],["videoinput","default"],["audiooutput","default"]]),this.pendingSignalRequests=new Map,this.rpcHandlers=s}get lastCameraError(){return this.cameraError}get lastMicrophoneError(){return this.microphoneError}get isE2EEEnabled(){return this.encryptionType!==$e.NONE}getTrackPublication(e){const t=super.getTrackPublication(e);if(t)return t}getTrackPublicationByName(e){const t=super.getTrackPublicationByName(e);if(t)return t}setupEngine(e){this.engine=e,this.engine.on(M.RemoteMute,(t,i)=>{const r=this.trackPublications.get(t);!r||!r.track||(i?r.mute():r.unmute())}),this.engine.on(M.Connected,this.handleReconnected).on(M.SignalRestarted,this.handleReconnected).on(M.SignalResumed,this.handleReconnected).on(M.Restarting,this.handleReconnecting).on(M.Resuming,this.handleReconnecting).on(M.LocalTrackUnpublished,this.handleLocalTrackUnpublished).on(M.SubscribedQualityUpdate,this.handleSubscribedQualityUpdate).on(M.Disconnected,this.handleDisconnected).on(M.SignalRequestResponse,this.handleSignalRequestResponse).on(M.DataPacketReceived,this.handleDataPacket)}setMetadata(e){return y(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({metadata:e})})}setName(e){return y(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({name:e})})}setAttributes(e){return y(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({attributes:e})})}requestMetadataUpdate(e){return y(this,arguments,void 0,function(t){var i=this;let{metadata:r,name:s,attributes:a}=t;return function*(){return new Promise((o,c)=>y(i,void 0,void 0,function*(){var l,u;try{let d=!1;const h=yield this.engine.client.sendUpdateLocalMetadata((l=r??this.metadata)!==null&&l!==void 0?l:"",(u=s??this.name)!==null&&u!==void 0?u:"",a),f=performance.now();for(this.pendingSignalRequests.set(h,{resolve:o,reject:p=>{c(p),d=!0},values:{name:s,metadata:r,attributes:a}});performance.now()-f<5e3&&!d;){if((!s||this.name===s)&&(!r||this.metadata===r)&&(!a||Object.entries(a).every(p=>{let[g,v]=p;return this.attributes[g]===v||v===""&&!this.attributes[g]}))){this.pendingSignalRequests.delete(h),o();return}yield Ge(50)}c(new Vd("Request to update local metadata timed out","TimeoutError"))}catch(d){d instanceof Error&&c(d)}}))}()})}setCameraEnabled(e,t,i){return this.setTrackEnabled(P.Source.Camera,e,t,i)}setMicrophoneEnabled(e,t,i){return this.setTrackEnabled(P.Source.Microphone,e,t,i)}setScreenShareEnabled(e,t,i){return this.setTrackEnabled(P.Source.ScreenShare,e,t,i)}setPermissions(e){const t=this.permissions,i=super.setPermissions(e);return i&&t&&this.emit(L.ParticipantPermissionsChanged,t),i}setE2EEEnabled(e){return y(this,void 0,void 0,function*(){this.encryptionType=e?$e.GCM:$e.NONE,yield this.republishAllTracks(void 0,!1)})}setTrackEnabled(e,t,i,r){return y(this,void 0,void 0,function*(){var s,a;this.log.debug("setTrackEnabled",Object.assign(Object.assign({},this.logContext),{source:e,enabled:t})),this.republishPromise&&(yield this.republishPromise);let o=this.getTrackPublication(e);if(t)if(o)yield o.unmute();else{let c;if(this.pendingPublishing.has(e)){const l=yield this.waitForPendingPublicationOfSource(e);return l||this.log.info("waiting for pending publication promise timed out",Object.assign(Object.assign({},this.logContext),{source:e})),yield l==null?void 0:l.unmute(),l}this.pendingPublishing.add(e);try{switch(e){case P.Source.Camera:c=yield this.createTracks({video:(s=i)!==null&&s!==void 0?s:!0});break;case P.Source.Microphone:c=yield this.createTracks({audio:(a=i)!==null&&a!==void 0?a:!0});break;case P.Source.ScreenShare:c=yield this.createScreenTracks(Object.assign({},i));break;default:throw new Pt(e)}}catch(l){throw c==null||c.forEach(u=>{u.stop()}),l instanceof Error&&this.emit(L.MediaDevicesError,l),this.pendingPublishing.delete(e),l}try{const l=[];for(const d of c)this.log.info("publishing track",Object.assign(Object.assign({},this.logContext),ee(d))),l.push(this.publishTrack(d,r));[o]=yield Promise.all(l)}catch(l){throw c==null||c.forEach(u=>{u.stop()}),l}finally{this.pendingPublishing.delete(e)}}else if(!(o!=null&&o.track)&&this.pendingPublishing.has(e)&&(o=yield this.waitForPendingPublicationOfSource(e),o||this.log.info("waiting for pending publication promise timed out",Object.assign(Object.assign({},this.logContext),{source:e}))),o&&o.track)if(e===P.Source.ScreenShare){o=yield this.unpublishTrack(o.track);const c=this.getTrackPublication(P.Source.ScreenShareAudio);c&&c.track&&this.unpublishTrack(c.track)}else yield o.mute();return o})}enableCameraAndMicrophone(){return y(this,void 0,void 0,function*(){if(!(this.pendingPublishing.has(P.Source.Camera)||this.pendingPublishing.has(P.Source.Microphone))){this.pendingPublishing.add(P.Source.Camera),this.pendingPublishing.add(P.Source.Microphone);try{const e=yield this.createTracks({audio:!0,video:!0});yield Promise.all(e.map(t=>this.publishTrack(t)))}finally{this.pendingPublishing.delete(P.Source.Camera),this.pendingPublishing.delete(P.Source.Microphone)}}})}createTracks(e){return y(this,void 0,void 0,function*(){var t,i;e??(e={});const r=Zd(e,(t=this.roomOptions)===null||t===void 0?void 0:t.audioCaptureDefaults,(i=this.roomOptions)===null||i===void 0?void 0:i.videoCaptureDefaults);try{return(yield ns(r,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext})).map(o=>(Rt(o)&&(this.microphoneError=void 0,o.setAudioContext(this.audioContext),o.source=P.Source.Microphone,this.emit(L.AudioStreamAcquired)),zn(o)&&(this.cameraError=void 0,o.source=P.Source.Camera),o))}catch(s){throw s instanceof Error&&(e.audio&&(this.microphoneError=s),e.video&&(this.cameraError=s)),s}})}createScreenTracks(e){return y(this,void 0,void 0,function*(){if(e===void 0&&(e={}),navigator.mediaDevices.getDisplayMedia===void 0)throw new Da("getDisplayMedia not supported");e.resolution===void 0&&!sT()&&(e.resolution=Wa.h1080fps30.resolution);const t=bT(e),i=yield navigator.mediaDevices.getDisplayMedia(t),r=i.getVideoTracks();if(r.length===0)throw new Pt("no video track found");const s=new ts(r[0],void 0,!1,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});s.source=P.Source.ScreenShare,e.contentHint&&(s.mediaStreamTrack.contentHint=e.contentHint);const a=[s];if(i.getAudioTracks().length>0){this.emit(L.AudioStreamAcquired);const o=new Zr(i.getAudioTracks()[0],void 0,!1,this.audioContext,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});o.source=P.Source.ScreenShareAudio,a.push(o)}return a})}publishTrack(e,t){return y(this,void 0,void 0,function*(){return this.publishOrRepublishTrack(e,t)})}publishOrRepublishTrack(e,t){return y(this,arguments,void 0,function(i,r){var s=this;let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return function*(){var o,c,l,u;gn(i)&&i.setAudioContext(s.audioContext),yield(o=s.reconnectFuture)===null||o===void 0?void 0:o.promise,s.republishPromise&&!a&&(yield s.republishPromise),Wn(i)&&s.pendingPublishPromises.has(i)&&(yield s.pendingPublishPromises.get(i));let d;if(i instanceof MediaStreamTrack)d=i.getConstraints();else{d=i.constraints;let b;switch(i.source){case P.Source.Microphone:b="audioinput";break;case P.Source.Camera:b="videoinput"}b&&s.activeDeviceMap.has(b)&&(d=Object.assign(Object.assign({},d),{deviceId:s.activeDeviceMap.get(b)}))}if(i instanceof MediaStreamTrack)switch(i.kind){case"audio":i=new Zr(i,d,!0,s.audioContext,{loggerName:s.roomOptions.loggerName,loggerContextCb:()=>s.logContext});break;case"video":i=new ts(i,d,!0,{loggerName:s.roomOptions.loggerName,loggerContextCb:()=>s.logContext});break;default:throw new Pt("unsupported MediaStreamTrack kind ".concat(i.kind))}else i.updateLoggerOptions({loggerName:s.roomOptions.loggerName,loggerContextCb:()=>s.logContext});let h;if(s.trackPublications.forEach(b=>{b.track&&b.track===i&&(h=b)}),h)return s.log.warn("track has already been published, skipping",Object.assign(Object.assign({},s.logContext),ee(h))),h;const f="channelCount"in i.mediaStreamTrack.getSettings()&&i.mediaStreamTrack.getSettings().channelCount===2||i.mediaStreamTrack.getConstraints().channelCount===2,p=(c=r==null?void 0:r.forceStereo)!==null&&c!==void 0?c:f;p&&(r||(r={}),r.dtx===void 0&&s.log.info("Opus DTX will be disabled for stereo tracks by default. Enable them explicitly to make it work.",Object.assign(Object.assign({},s.logContext),ee(i))),r.red===void 0&&s.log.info("Opus RED will be disabled for stereo tracks by default. Enable them explicitly to make it work."),(l=r.dtx)!==null&&l!==void 0||(r.dtx=!1),(u=r.red)!==null&&u!==void 0||(r.red=!1));const g=Object.assign(Object.assign({},s.roomOptions.publishDefaults),r);!aT()&&s.roomOptions.e2ee&&(s.log.info("End-to-end encryption is set up, simulcast publishing will be disabled on Safari versions and iOS browsers running iOS < v17.2",Object.assign({},s.logContext)),g.simulcast=!1),g.source&&(i.source=g.source);const v=new Promise((b,S)=>y(s,void 0,void 0,function*(){try{if(this.engine.client.currentState!==oe.CONNECTED){this.log.debug("deferring track publication until signal is connected",Object.assign(Object.assign({},this.logContext),{track:ee(i)}));const x=()=>y(this,void 0,void 0,function*(){try{const k=yield this.publish(i,g,p);b(k)}catch(k){S(k)}});setTimeout(()=>{this.engine.off(M.SignalConnected,x),S(new Ba("publishing rejected as engine not connected within timeout",408))},15e3),this.engine.once(M.SignalConnected,x),this.engine.on(M.Closing,()=>{this.engine.off(M.SignalConnected,x),S(new Ba("publishing rejected as engine closed",499))})}else try{const x=yield this.publish(i,g,p);b(x)}catch(x){S(x)}}catch(x){S(x)}}));s.pendingPublishPromises.set(i,v);try{return yield v}catch(b){throw b}finally{s.pendingPublishPromises.delete(i)}}()})}hasPermissionsToPublish(e){if(!this.permissions)return this.log.warn("no permissions present for publishing track",Object.assign(Object.assign({},this.logContext),ee(e))),!1;const{canPublish:t,canPublishSources:i}=this.permissions;return t&&(i.length===0||i.map(r=>ST(r)).includes(e.source))?!0:(this.log.warn("insufficient permissions to publish",Object.assign(Object.assign({},this.logContext),ee(e))),!1)}publish(e,t,i){return y(this,void 0,void 0,function*(){var r,s,a,o,c,l,u,d,h,f;if(!this.hasPermissionsToPublish(e))throw new Ba("failed to publish track, insufficient permissions",403);Array.from(this.trackPublications.values()).find(T=>Wn(e)&&T.source===e.source)&&e.source!==P.Source.Unknown&&this.log.info("publishing a second track with the same source: ".concat(e.source),Object.assign(Object.assign({},this.logContext),ee(e))),t.stopMicTrackOnMute&&Rt(e)&&(e.stopOnMute=!0),e.source===P.Source.ScreenShare&&Gn()&&(t.simulcast=!1),t.videoCodec==="av1"&&!nT()&&(t.videoCodec=void 0),t.videoCodec==="vp9"&&!iT()&&(t.videoCodec=void 0),t.videoCodec===void 0&&(t.videoCodec=uo),this.enabledPublishVideoCodecs.length>0&&(this.enabledPublishVideoCodecs.some(T=>t.videoCodec===Xr(T.mime))||(t.videoCodec=Xr(this.enabledPublishVideoCodecs[0].mime)));const g=t.videoCodec;e.on(N.Muted,this.onTrackMuted),e.on(N.Unmuted,this.onTrackUnmuted),e.on(N.Ended,this.handleTrackEnded),e.on(N.UpstreamPaused,this.onTrackUpstreamPaused),e.on(N.UpstreamResumed,this.onTrackUpstreamResumed),e.on(N.AudioTrackFeatureUpdate,this.onTrackFeatureUpdate);const v=new ka({cid:e.mediaStreamTrack.id,name:t.name,type:P.kindToProto(e.kind),muted:e.isMuted,source:P.sourceToProto(e.source),disableDtx:!(!((r=t.dtx)!==null&&r!==void 0)||r),encryption:this.encryptionType,stereo:i,disableRed:this.isE2EEEnabled||!(!((s=t.red)!==null&&s!==void 0)||s),stream:t==null?void 0:t.stream,backupCodecPolicy:t==null?void 0:t.backupCodecPolicy});let b;if(e.kind===P.Kind.Video){let T={width:0,height:0};try{T=yield e.waitForDimensions()}catch{const _=(o=(a=this.roomOptions.videoCaptureDefaults)===null||a===void 0?void 0:a.resolution)!==null&&o!==void 0?o:bi.h720.resolution;T={width:_.width,height:_.height},this.log.error("could not determine track dimensions, using defaults",Object.assign(Object.assign(Object.assign({},this.logContext),ee(e)),{dims:T}))}v.width=T.width,v.height=T.height,Qt(e)&&(yi(g)&&(e.source===P.Source.ScreenShare&&(t.scalabilityMode="L1T3","contentHint"in e.mediaStreamTrack&&(e.mediaStreamTrack.contentHint="motion",this.log.info("forcing contentHint to motion for screenshare with SVC codecs",Object.assign(Object.assign({},this.logContext),ee(e))))),t.scalabilityMode=(c=t.scalabilityMode)!==null&&c!==void 0?c:"L3T3_KEY"),v.simulcastCodecs=[new ya({codec:g,cid:e.mediaStreamTrack.id})],t.backupCodec===!0&&(t.backupCodec={codec:uo}),t.backupCodec&&g!==t.backupCodec.codec&&v.encryption===$e.NONE&&(this.roomOptions.dynacast||(this.roomOptions.dynacast=!0),v.simulcastCodecs.push(new ya({codec:t.backupCodec.codec,cid:""})))),b=go(e.source===P.Source.ScreenShare,v.width,v.height,t),v.layers=Sh(v.width,v.height,b,yi(t.videoCodec))}else e.kind===P.Kind.Audio&&(b=[{maxBitrate:(l=t.audioPreset)===null||l===void 0?void 0:l.maxBitrate,priority:(d=(u=t.audioPreset)===null||u===void 0?void 0:u.priority)!==null&&d!==void 0?d:"high",networkPriority:(f=(h=t.audioPreset)===null||h===void 0?void 0:h.priority)!==null&&f!==void 0?f:"high"}]);if(!this.engine||this.engine.isClosed)throw new Ce("cannot publish track when not connected");const S=()=>y(this,void 0,void 0,function*(){var T,C,_;if(!this.engine.pcManager)throw new Ce("pcManager is not ready");if(e.sender=yield this.engine.createSender(e,t,b),Qt(e)&&((T=t.degradationPreference)!==null&&T!==void 0||(t.degradationPreference=JT(e)),e.setDegradationPreference(t.degradationPreference)),b)if(Gn()&&e.kind===P.Kind.Audio){let R;for(const I of this.engine.pcManager.publisher.getTransceivers())if(I.sender===e.sender){R=I;break}R&&this.engine.pcManager.publisher.setTrackCodecBitrate({transceiver:R,codec:"opus",maxbr:!((C=b[0])===null||C===void 0)&&C.maxBitrate?b[0].maxBitrate/1e3:0})}else e.codec&&yi(e.codec)&&(!((_=b[0])===null||_===void 0)&&_.maxBitrate)&&this.engine.pcManager.publisher.setTrackCodecBitrate({cid:v.cid,codec:e.codec,maxbr:b[0].maxBitrate/1e3});yield this.engine.negotiate()});let x;if(this.enabledPublishVideoCodecs.length>0)x=(yield Promise.all([this.engine.addTrack(v),S()]))[0];else{x=yield this.engine.addTrack(v);let T;if(x.codecs.forEach(C=>{T===void 0&&(T=C.mimeType)}),T&&e.kind===P.Kind.Video){const C=Xr(T);C!==g&&(this.log.debug("falling back to server selected codec",Object.assign(Object.assign(Object.assign({},this.logContext),ee(e)),{codec:C})),t.videoCodec=C,b=go(e.source===P.Source.ScreenShare,v.width,v.height,t))}yield S()}const k=new So(e.kind,x,e,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});return k.options=t,e.sid=x.sid,this.log.debug("publishing ".concat(e.kind," with encodings"),Object.assign(Object.assign({},this.logContext),{encodings:b,trackInfo:x})),Qt(e)?e.startMonitor(this.engine.client):gn(e)&&e.startMonitor(),this.addTrackPublication(k),this.emit(L.LocalTrackPublished,k),k})}get isLocal(){return!0}publishAdditionalCodecForTrack(e,t,i){return y(this,void 0,void 0,function*(){var r;if(this.encryptionType!==$e.NONE)return;let s;if(this.trackPublications.forEach(f=>{f.track&&f.track===e&&(s=f)}),!s)throw new Pt("track is not published");if(!Qt(e))throw new Pt("track is not a video track");const a=Object.assign(Object.assign({},(r=this.roomOptions)===null||r===void 0?void 0:r.publishDefaults),i),o=$T(e,t,a);if(!o){this.log.info("backup codec has been disabled, ignoring request to add additional codec for track",Object.assign(Object.assign({},this.logContext),ee(e)));return}const c=e.addSimulcastTrack(t,o);if(!c)return;const l=new ka({cid:c.mediaStreamTrack.id,type:P.kindToProto(e.kind),muted:e.isMuted,source:P.sourceToProto(e.source),sid:e.sid,simulcastCodecs:[{codec:a.videoCodec,cid:c.mediaStreamTrack.id}]});if(l.layers=Sh(l.width,l.height,o),!this.engine||this.engine.isClosed)throw new Ce("cannot publish track when not connected");const u=()=>y(this,void 0,void 0,function*(){yield this.engine.createSimulcastSender(e,c,a,o),yield this.engine.negotiate()}),h=(yield Promise.all([this.engine.addTrack(l),u()]))[0];this.log.debug("published ".concat(t," for track ").concat(e.sid),Object.assign(Object.assign({},this.logContext),{encodings:o,trackInfo:h}))})}unpublishTrack(e,t){return y(this,void 0,void 0,function*(){var i,r;if(Wn(e)){const l=this.pendingPublishPromises.get(e);l&&(this.log.info("awaiting publish promise before attempting to unpublish",Object.assign(Object.assign({},this.logContext),ee(e))),yield l)}const s=this.getPublicationForTrack(e),a=s?ee(s):void 0;if(this.log.debug("unpublishing track",Object.assign(Object.assign({},this.logContext),a)),!s||!s.track){this.log.warn("track was not unpublished because no publication was found",Object.assign(Object.assign({},this.logContext),a));return}e=s.track,e.off(N.Muted,this.onTrackMuted),e.off(N.Unmuted,this.onTrackUnmuted),e.off(N.Ended,this.handleTrackEnded),e.off(N.UpstreamPaused,this.onTrackUpstreamPaused),e.off(N.UpstreamResumed,this.onTrackUpstreamResumed),e.off(N.AudioTrackFeatureUpdate,this.onTrackFeatureUpdate),t===void 0&&(t=(r=(i=this.roomOptions)===null||i===void 0?void 0:i.stopLocalTrackOnUnpublish)!==null&&r!==void 0?r:!0),t?e.stop():e.stopMonitor();let o=!1;const c=e.sender;if(e.sender=void 0,this.engine.pcManager&&this.engine.pcManager.currentState<fe.FAILED&&c)try{for(const l of this.engine.pcManager.publisher.getTransceivers())l.sender===c&&(l.direction="inactive",o=!0);if(this.engine.removeTrack(c)&&(o=!0),Qt(e)){for(const[,l]of e.simulcastCodecs)l.sender&&(this.engine.removeTrack(l.sender)&&(o=!0),l.sender=void 0);e.simulcastCodecs.clear()}}catch(l){this.log.warn("failed to unpublish track",Object.assign(Object.assign(Object.assign({},this.logContext),a),{error:l}))}switch(this.trackPublications.delete(s.trackSid),s.kind){case P.Kind.Audio:this.audioTrackPublications.delete(s.trackSid);break;case P.Kind.Video:this.videoTrackPublications.delete(s.trackSid);break}return this.emit(L.LocalTrackUnpublished,s),s.setTrack(void 0),o&&(yield this.engine.negotiate()),s})}unpublishTracks(e){return y(this,void 0,void 0,function*(){return(yield Promise.all(e.map(i=>this.unpublishTrack(i)))).filter(i=>!!i)})}republishAllTracks(e){return y(this,arguments,void 0,function(t){var i=this;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return function*(){i.republishPromise&&(yield i.republishPromise),i.republishPromise=new Promise((s,a)=>y(i,void 0,void 0,function*(){try{const o=[];this.trackPublications.forEach(c=>{c.track&&(t&&(c.options=Object.assign(Object.assign({},c.options),t)),o.push(c))}),yield Promise.all(o.map(c=>y(this,void 0,void 0,function*(){const l=c.track;yield this.unpublishTrack(l,!1),r&&!l.isMuted&&l.source!==P.Source.ScreenShare&&l.source!==P.Source.ScreenShareAudio&&(gn(l)||Qt(l))&&!l.isUserProvided&&(this.log.debug("restarting existing track",Object.assign(Object.assign({},this.logContext),{track:c.trackSid})),yield l.restartTrack()),yield this.publishOrRepublishTrack(l,c.options,!0)}))),s()}catch(o){a(o)}finally{this.republishPromise=void 0}})),yield i.republishPromise}()})}publishData(e){return y(this,arguments,void 0,function(t){var i=this;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return function*(){const s=r.reliable?X.RELIABLE:X.LOSSY,a=r.destinationIdentities,o=r.topic,c=new Ve({kind:s,value:{case:"user",value:new _u({participantIdentity:i.identity,payload:t,destinationIdentities:a,topic:o})}});yield i.engine.sendDataPacket(c,s)}()})}publishDtmf(e,t){return y(this,void 0,void 0,function*(){const i=new Ve({kind:X.RELIABLE,value:{case:"sipDtmf",value:new Eu({code:e,digit:t})}});yield this.engine.sendDataPacket(i,X.RELIABLE)})}sendChatMessage(e,t){return y(this,void 0,void 0,function*(){const i={id:crypto.randomUUID(),message:e,timestamp:Date.now(),attachedFiles:t==null?void 0:t.attachments},r=new Ve({value:{case:"chatMessage",value:new fa(Object.assign(Object.assign({},i),{timestamp:le.parse(i.timestamp)}))}});return yield this.engine.sendDataPacket(r,X.RELIABLE),this.emit(L.ChatMessage,i),i})}editChatMessage(e,t){return y(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},t),{message:e,editTimestamp:Date.now()}),r=new Ve({value:{case:"chatMessage",value:new fa(Object.assign(Object.assign({},i),{timestamp:le.parse(i.timestamp),editTimestamp:le.parse(i.editTimestamp)}))}});return yield this.engine.sendDataPacket(r,X.RELIABLE),this.emit(L.ChatMessage,i),i})}sendText(e,t){return y(this,void 0,void 0,function*(){var i;const r=crypto.randomUUID(),a=new TextEncoder().encode(e).byteLength,o=(i=t==null?void 0:t.attachments)===null||i===void 0?void 0:i.map(()=>crypto.randomUUID()),c=new Array(o?o.length+1:1).fill(0),l=(d,h)=>{var f;c[h]=d;const p=c.reduce((g,v)=>g+v,0);(f=t==null?void 0:t.onProgress)===null||f===void 0||f.call(t,p)},u=yield this.streamText({streamId:r,totalSize:a,destinationIdentities:t==null?void 0:t.destinationIdentities,topic:t==null?void 0:t.topic,attachedStreamIds:o,attributes:t==null?void 0:t.attributes});return yield u.write(e),l(1,0),yield u.close(),t!=null&&t.attachments&&o&&(yield Promise.all(t.attachments.map((d,h)=>y(this,void 0,void 0,function*(){return this._sendFile(o[h],d,{topic:t.topic,mimeType:d.type,onProgress:f=>{l(f,h+1)}})})))),u.info})}streamText(e){return y(this,void 0,void 0,function*(){var t,i;const r=(t=e==null?void 0:e.streamId)!==null&&t!==void 0?t:crypto.randomUUID(),s={id:r,mimeType:"text/plain",timestamp:Date.now(),topic:(i=e==null?void 0:e.topic)!==null&&i!==void 0?i:"",size:e==null?void 0:e.totalSize,attributes:e==null?void 0:e.attributes},a=new ma({streamId:r,mimeType:s.mimeType,topic:s.topic,timestamp:mn(s.timestamp),totalLength:mn(e==null?void 0:e.totalSize),attributes:s.attributes,contentHeader:{case:"textHeader",value:new Bu({version:e==null?void 0:e.version,attachedStreamIds:e==null?void 0:e.attachedStreamIds,replyToStreamId:e==null?void 0:e.replyToStreamId,operationType:(e==null?void 0:e.type)==="update"?pa.UPDATE:pa.CREATE})}}),o=e==null?void 0:e.destinationIdentities,c=new Ve({destinationIdentities:o,value:{case:"streamHeader",value:a}});yield this.engine.sendDataPacket(c,X.RELIABLE);let l=0;const u=this,d=new WritableStream({write(p){return y(this,void 0,void 0,function*(){for(const g of gT(p,Rh)){yield u.engine.waitForBufferStatusLow(X.RELIABLE);const v=new ga({content:g,streamId:r,chunkIndex:mn(l)}),b=new Ve({destinationIdentities:o,value:{case:"streamChunk",value:v}});yield u.engine.sendDataPacket(b,X.RELIABLE),l+=1}})},close(){return y(this,void 0,void 0,function*(){const p=new va({streamId:r}),g=new Ve({destinationIdentities:o,value:{case:"streamTrailer",value:p}});yield u.engine.sendDataPacket(g,X.RELIABLE)})},abort(p){console.log("Sink error:",p)}});let h=()=>y(this,void 0,void 0,function*(){yield f.close()});u.engine.once(M.Closing,h);const f=new aS(d,s,()=>this.engine.off(M.Closing,h));return f})}sendFile(e,t){return y(this,void 0,void 0,function*(){const i=crypto.randomUUID();return yield this._sendFile(i,e,t),{id:i}})}_sendFile(e,t,i){return y(this,void 0,void 0,function*(){var r;const s=yield this.streamBytes({streamId:e,totalSize:t.size,name:t.name,mimeType:(r=i==null?void 0:i.mimeType)!==null&&r!==void 0?r:t.type,topic:i==null?void 0:i.topic,destinationIdentities:i==null?void 0:i.destinationIdentities}),a=t.stream().getReader();for(;;){const{done:o,value:c}=yield a.read();if(o)break;yield s.write(c)}return yield s.close(),s.info})}streamBytes(e){return y(this,void 0,void 0,function*(){var t,i,r,s,a;const o=(t=e==null?void 0:e.streamId)!==null&&t!==void 0?t:crypto.randomUUID(),c=e==null?void 0:e.destinationIdentities,l={id:o,mimeType:(i=e==null?void 0:e.mimeType)!==null&&i!==void 0?i:"application/octet-stream",topic:(r=e==null?void 0:e.topic)!==null&&r!==void 0?r:"",timestamp:Date.now(),attributes:e==null?void 0:e.attributes,size:e==null?void 0:e.totalSize,name:(s=e==null?void 0:e.name)!==null&&s!==void 0?s:"unknown"},u=new ma({totalLength:mn((a=l.size)!==null&&a!==void 0?a:0),mimeType:l.mimeType,streamId:o,topic:l.topic,timestamp:mn(Date.now()),attributes:l.attributes,contentHeader:{case:"byteHeader",value:new Fu({name:l.name})}}),d=new Ve({destinationIdentities:c,value:{case:"streamHeader",value:u}});yield this.engine.sendDataPacket(d,X.RELIABLE);let h=0;const f=new Fe,p=this.engine,g=this.log,v=new WritableStream({write(S){return y(this,void 0,void 0,function*(){const x=yield f.lock();let k=0;try{for(;k<S.byteLength;){const T=S.slice(k,k+Rh);yield p.waitForBufferStatusLow(X.RELIABLE);const C=new Ve({destinationIdentities:c,value:{case:"streamChunk",value:new ga({content:T,streamId:o,chunkIndex:mn(h)})}});yield p.sendDataPacket(C,X.RELIABLE),h+=1,k+=T.byteLength}}finally{x()}})},close(){return y(this,void 0,void 0,function*(){const S=new va({streamId:o}),x=new Ve({destinationIdentities:c,value:{case:"streamTrailer",value:S}});yield p.sendDataPacket(x,X.RELIABLE)})},abort(S){g.error("Sink error:",S)}});return new oS(v,l)})}performRpc(e){return y(this,arguments,void 0,function(t){var i=this;let{destinationIdentity:r,method:s,payload:a,responseTimeout:o=1e4}=t;return function*(){return new Promise((l,u)=>y(i,void 0,void 0,function*(){var d,h,f,p;if(fo(a)>mh){u(pe.builtIn("REQUEST_PAYLOAD_TOO_LARGE"));return}if(!((h=(d=this.engine.latestJoinResponse)===null||d===void 0?void 0:d.serverInfo)===null||h===void 0)&&h.version&&pn((p=(f=this.engine.latestJoinResponse)===null||f===void 0?void 0:f.serverInfo)===null||p===void 0?void 0:p.version,"1.8.0")<0){u(pe.builtIn("UNSUPPORTED_SERVER"));return}const g=crypto.randomUUID();yield this.publishRpcRequest(r,g,s,a,o-2e3);const v=setTimeout(()=>{this.pendingAcks.delete(g),u(pe.builtIn("CONNECTION_TIMEOUT")),this.pendingResponses.delete(g),clearTimeout(b)},2e3);this.pendingAcks.set(g,{resolve:()=>{clearTimeout(v)},participantIdentity:r});const b=setTimeout(()=>{this.pendingResponses.delete(g),u(pe.builtIn("RESPONSE_TIMEOUT"))},o);this.pendingResponses.set(g,{resolve:(S,x)=>{clearTimeout(b),this.pendingAcks.has(g)&&(console.warn("RPC response received before ack",g),this.pendingAcks.delete(g),clearTimeout(v)),x?u(x):l(S??"")},participantIdentity:r})}))}()})}registerRpcMethod(e,t){this.rpcHandlers.has(e)&&this.log.warn("you're overriding the RPC handler for method ".concat(e,", in the future this will throw an error")),this.rpcHandlers.set(e,t)}unregisterRpcMethod(e){this.rpcHandlers.delete(e)}setTrackSubscriptionPermissions(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];this.participantTrackPermissions=t,this.allParticipantsAllowedToSubscribe=e,this.engine.client.isDisconnected||this.updateTrackSubscriptionPermissions()}handleIncomingRpcAck(e){const t=this.pendingAcks.get(e);t?(t.resolve(),this.pendingAcks.delete(e)):console.error("Ack received for unexpected RPC request",e)}handleIncomingRpcResponse(e,t,i){const r=this.pendingResponses.get(e);r?(r.resolve(t,i),this.pendingResponses.delete(e)):console.error("Response received for unexpected RPC request",e)}publishRpcRequest(e,t,i,r,s){return y(this,void 0,void 0,function*(){const a=new Ve({destinationIdentities:[e],kind:X.RELIABLE,value:{case:"rpcRequest",value:new Pu({id:t,method:i,payload:r,responseTimeoutMs:s,version:1})}});yield this.engine.sendDataPacket(a,X.RELIABLE)})}handleParticipantDisconnected(e){for(const[t,{participantIdentity:i}]of this.pendingAcks)i===e&&this.pendingAcks.delete(t);for(const[t,{participantIdentity:i,resolve:r}]of this.pendingResponses)i===e&&(r(null,pe.builtIn("RECIPIENT_DISCONNECTED")),this.pendingResponses.delete(t))}setEnabledPublishCodecs(e){this.enabledPublishVideoCodecs=e.filter(t=>t.mime.split("/")[0].toLowerCase()==="video")}updateInfo(e){return super.updateInfo(e)?(e.tracks.forEach(t=>{var i,r;const s=this.trackPublications.get(t.sid);if(s){const a=s.isMuted||((r=(i=s.track)===null||i===void 0?void 0:i.isUpstreamPaused)!==null&&r!==void 0?r:!1);a!==t.muted&&(this.log.debug("updating server mute state after reconcile",Object.assign(Object.assign(Object.assign({},this.logContext),ee(s)),{mutedOnServer:a})),this.engine.client.sendMuteTrack(t.sid,a))}}),!0):!1}getPublicationForTrack(e){let t;return this.trackPublications.forEach(i=>{const r=i.track;r&&(e instanceof MediaStreamTrack?(gn(r)||Qt(r))&&r.mediaStreamTrack===e&&(t=i):e===r&&(t=i))}),t}waitForPendingPublicationOfSource(e){return y(this,void 0,void 0,function*(){const i=Date.now();for(;Date.now()<i+1e4;){const r=Array.from(this.pendingPublishPromises.entries()).find(s=>{let[a]=s;return a.source===e});if(r)return r[1];yield Ge(20)}})}}class gS extends It{constructor(e,t,i,r){super(e,t.sid,t.name,r),this.track=void 0,this.allowed=!0,this.disabled=!1,this.currentVideoQuality=Ze.HIGH,this.handleEnded=s=>{this.setTrack(void 0),this.emit(N.Ended,s)},this.handleVisibilityChange=s=>{this.log.debug("adaptivestream video visibility ".concat(this.trackSid,", visible=").concat(s),this.logContext),this.disabled=!s,this.emitTrackUpdate()},this.handleVideoDimensionsChange=s=>{this.log.debug("adaptivestream video dimensions ".concat(s.width,"x").concat(s.height),this.logContext),this.videoDimensions=s,this.emitTrackUpdate()},this.subscribed=i,this.updateInfo(t)}setSubscribed(e){const t=this.subscriptionStatus,i=this.permissionStatus;this.subscribed=e,e&&(this.allowed=!0);const r=new Lr({trackSids:[this.trackSid],subscribe:this.subscribed,participantTracks:[new Au({participantSid:"",trackSids:[this.trackSid]})]});this.emit(N.UpdateSubscription,r),this.emitSubscriptionUpdateIfChanged(t),this.emitPermissionUpdateIfChanged(i)}get subscriptionStatus(){return this.subscribed===!1?It.SubscriptionStatus.Unsubscribed:super.isSubscribed?It.SubscriptionStatus.Subscribed:It.SubscriptionStatus.Desired}get permissionStatus(){return this.allowed?It.PermissionStatus.Allowed:It.PermissionStatus.NotAllowed}get isSubscribed(){return this.subscribed===!1?!1:super.isSubscribed}get isDesired(){return this.subscribed!==!1}get isEnabled(){return!this.disabled}get isLocal(){return!1}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,i;this.isManualOperationAllowed()&&(((t=this.videoDimensions)===null||t===void 0?void 0:t.width)===e.width&&((i=this.videoDimensions)===null||i===void 0?void 0:i.height)===e.height||(eo(this.track)&&(this.videoDimensions=e),this.currentVideoQuality=void 0,this.emitTrackUpdate()))}setVideoFPS(e){this.isManualOperationAllowed()&&eo(this.track)&&this.fps!==e&&(this.fps=e,this.emitTrackUpdate())}get videoQuality(){return this.currentVideoQuality}setTrack(e){const t=this.subscriptionStatus,i=this.permissionStatus,r=this.track;r!==e&&(r&&(r.off(N.VideoDimensionsChanged,this.handleVideoDimensionsChange),r.off(N.VisibilityChanged,this.handleVisibilityChange),r.off(N.Ended,this.handleEnded),r.detach(),r.stopMonitor(),this.emit(N.Unsubscribed,r)),super.setTrack(e),e&&(e.sid=this.trackSid,e.on(N.VideoDimensionsChanged,this.handleVideoDimensionsChange),e.on(N.VisibilityChanged,this.handleVisibilityChange),e.on(N.Ended,this.handleEnded),this.emit(N.Subscribed,e)),this.emitPermissionUpdateIfChanged(i),this.emitSubscriptionUpdateIfChanged(t))}setAllowed(e){const t=this.subscriptionStatus,i=this.permissionStatus;this.allowed=e,this.emitPermissionUpdateIfChanged(i),this.emitSubscriptionUpdateIfChanged(t)}setSubscriptionError(e){this.emit(N.SubscriptionFailed,e)}updateInfo(e){super.updateInfo(e);const t=this.metadataMuted;this.metadataMuted=e.muted,this.track?this.track.setMuted(e.muted):t!==e.muted&&this.emit(e.muted?N.Muted:N.Unmuted)}emitSubscriptionUpdateIfChanged(e){const t=this.subscriptionStatus;e!==t&&this.emit(N.SubscriptionStatusChanged,t,e)}emitPermissionUpdateIfChanged(e){this.permissionStatus!==e&&this.emit(N.SubscriptionPermissionChanged,this.permissionStatus,e)}isManualOperationAllowed(){return this.kind===P.Kind.Video&&this.isAdaptiveStream?(this.log.warn("adaptive stream is enabled, cannot change video track settings",this.logContext),!1):this.isDesired?!0:(this.log.warn("cannot update track settings when not subscribed",this.logContext),!1)}get isAdaptiveStream(){return eo(this.track)&&this.track.isAdaptiveStream}emitTrackUpdate(){const e=new Vu({trackSids:[this.trackSid],disabled:this.disabled,fps:this.fps});this.videoDimensions?(e.width=Math.ceil(this.videoDimensions.width),e.height=Math.ceil(this.videoDimensions.height)):this.currentVideoQuality!==void 0?e.quality=this.currentVideoQuality:e.quality=Ze.HIGH,this.emit(N.UpdateSettings,e)}}class is extends Ph{static fromParticipantInfo(e,t,i){return new is(e,t.sid,t.identity,t.name,t.metadata,t.attributes,i,t.kind)}get logContext(){return Object.assign(Object.assign({},super.logContext),{rpID:this.sid,remoteParticipant:this.identity})}constructor(e,t,i,r,s,a,o){let c=arguments.length>7&&arguments[7]!==void 0?arguments[7]:Mr.STANDARD;super(t,i||"",r,s,a,o,c),this.signalClient=e,this.trackPublications=new Map,this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.volumeMap=new Map}addTrackPublication(e){super.addTrackPublication(e),e.on(N.UpdateSettings,t=>{this.log.debug("send update settings",Object.assign(Object.assign({},this.logContext),ee(e))),this.signalClient.sendUpdateTrackSettings(t)}),e.on(N.UpdateSubscription,t=>{t.participantTracks.forEach(i=>{i.participantSid=this.sid}),this.signalClient.sendUpdateSubscription(t)}),e.on(N.SubscriptionPermissionChanged,t=>{this.emit(L.TrackSubscriptionPermissionChanged,e,t)}),e.on(N.SubscriptionStatusChanged,t=>{this.emit(L.TrackSubscriptionStatusChanged,e,t)}),e.on(N.Subscribed,t=>{this.emit(L.TrackSubscribed,t,e)}),e.on(N.Unsubscribed,t=>{this.emit(L.TrackUnsubscribed,t,e)}),e.on(N.SubscriptionFailed,t=>{this.emit(L.TrackSubscriptionFailed,e.trackSid,t)})}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&&arguments[1]!==void 0?arguments[1]:P.Source.Microphone;this.volumeMap.set(t,e);const i=this.getTrackPublication(t);i&&i.track&&i.track.setVolume(e)}getVolume(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:P.Source.Microphone;const t=this.getTrackPublication(e);return t&&t.track?t.track.getVolume():this.volumeMap.get(e)}addSubscribedMediaTrack(e,t,i,r,s,a){let o=this.getTrackPublicationBySid(t);if(o||t.startsWith("TR")||this.trackPublications.forEach(u=>{!o&&e.kind===u.kind.toString()&&(o=u)}),!o){if(a===0){this.log.error("could not find published track",Object.assign(Object.assign({},this.logContext),{trackSid:t})),this.emit(L.TrackSubscriptionFailed,t);return}a===void 0&&(a=20),setTimeout(()=>{this.addSubscribedMediaTrack(e,t,i,r,s,a-1)},150);return}if(e.readyState==="ended"){this.log.error("unable to subscribe because MediaStreamTrack is ended. Do not call MediaStreamTrack.stop()",Object.assign(Object.assign({},this.logContext),ee(o))),this.emit(L.TrackSubscriptionFailed,t);return}const c=e.kind==="video";let l;return c?l=new lS(e,t,r,s):l=new cS(e,t,r,this.audioContext,this.audioOutput),l.source=o.source,l.isMuted=o.isMuted,l.setMediaStream(i),l.start(),o.setTrack(l),this.volumeMap.has(o.source)&&Za(l)&&Rt(l)&&l.setVolume(this.volumeMap.get(o.source)),o}get hasMetadata(){return!!this.participantInfo}getTrackPublicationBySid(e){return this.trackPublications.get(e)}updateInfo(e){if(!super.updateInfo(e))return!1;const t=new Map,i=new Map;return e.tracks.forEach(r=>{var s,a;let o=this.getTrackPublicationBySid(r.sid);if(o)o.updateInfo(r);else{const c=P.kindFromProto(r.type);if(!c)return;o=new gS(c,r,(s=this.signalClient.connectOptions)===null||s===void 0?void 0:s.autoSubscribe,{loggerContextCb:()=>this.logContext,loggerName:(a=this.loggerOptions)===null||a===void 0?void 0:a.loggerName}),o.updateInfo(r),i.set(r.sid,o);const l=Array.from(this.trackPublications.values()).find(u=>u.source===(o==null?void 0:o.source));l&&o.source!==P.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:ee(l),newTrack:ee(o)})),this.addTrackPublication(o)}t.set(r.sid,o)}),this.trackPublications.forEach(r=>{t.has(r.trackSid)||(this.log.trace("detected removed track on remote participant, unpublishing",Object.assign(Object.assign({},this.logContext),ee(r))),this.unpublishTrack(r.trackSid,!0))}),i.forEach(r=>{this.emit(L.TrackPublished,r)}),!0}unpublishTrack(e,t){const i=this.trackPublications.get(e);if(!i)return;const{track:r}=i;switch(r&&(r.stop(),i.setTrack(void 0)),this.trackPublications.delete(e),i.kind){case P.Kind.Audio:this.audioTrackPublications.delete(e);break;case P.Kind.Video:this.videoTrackPublications.delete(e);break}t&&this.emit(L.TrackUnpublished,i)}setAudioOutput(e){return y(this,void 0,void 0,function*(){this.audioOutput=e;const t=[];this.audioTrackPublications.forEach(i=>{var r;Rt(i.track)&&Za(i.track)&&t.push(i.track.setSinkId((r=e.deviceId)!==null&&r!==void 0?r:"default"))}),yield Promise.all(t)})}emit(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return this.log.trace("participant event",Object.assign(Object.assign({},this.logContext),{event:e,args:i})),super.emit(e,...i)}}var J;(function(n){n.Disconnected="disconnected",n.Connecting="connecting",n.Connected="connected",n.Reconnecting="reconnecting",n.SignalReconnecting="signalReconnecting"})(J||(J={}));const vS=4*1e3;class Kn extends Tt.EventEmitter{constructor(e){var t,i,r,s;if(super(),t=this,this.state=J.Disconnected,this.activeSpeakers=[],this.isE2EEEnabled=!1,this.audioEnabled=!0,this.isVideoPlaybackBlocked=!1,this.log=q,this.bufferedEvents=[],this.isResuming=!1,this.byteStreamControllers=new Map,this.textStreamControllers=new Map,this.byteStreamHandlers=new Map,this.textStreamHandlers=new Map,this.rpcHandlers=new Map,this.connect=(a,o,c)=>y(this,void 0,void 0,function*(){var l;if(!rT())throw St()?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 u=yield this.disconnectLock.lock();if(this.state===J.Connected)return this.log.info("already connected to room ".concat(this.name),this.logContext),u(),Promise.resolve();if(this.connectFuture)return u(),this.connectFuture.promise;this.setAndEmitConnectionState(J.Connecting),((l=this.regionUrlProvider)===null||l===void 0?void 0:l.getServerUrl().toString())!==a&&(this.regionUrl=void 0,this.regionUrlProvider=void 0),Ka(new URL(a))&&(this.regionUrlProvider===void 0?this.regionUrlProvider=new yo(a,o):this.regionUrlProvider.updateToken(o),this.regionUrlProvider.fetchRegionSettings().then(f=>{var p;(p=this.regionUrlProvider)===null||p===void 0||p.setServerReportedRegions(f)}).catch(f=>{this.log.warn("could not fetch region settings",Object.assign(Object.assign({},this.logContext),{error:f}))}));const d=(f,p,g)=>y(this,void 0,void 0,function*(){var v,b;this.abortController&&this.abortController.abort();const S=new AbortController;this.abortController=S,u==null||u();try{yield this.attemptConnection(g??a,o,c,S),this.abortController=void 0,f()}catch(x){if(this.regionUrlProvider&&x instanceof ie&&x.reason!==$.Cancelled&&x.reason!==$.NotAllowed){let k=null;try{k=yield this.regionUrlProvider.getNextBestRegionUrl((v=this.abortController)===null||v===void 0?void 0:v.signal)}catch(T){if(T instanceof ie&&(T.status===401||T.reason===$.Cancelled)){this.handleDisconnect(this.options.stopLocalTrackOnUnpublish),p(T);return}}k&&!(!((b=this.abortController)===null||b===void 0)&&b.signal.aborted)?(this.log.info("Initial connection failed with ConnectionError: ".concat(x.message,". Retrying with another region: ").concat(k),this.logContext),this.recreateEngine(),yield d(f,p,k)):(this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,Qd(x)),p(x))}else{let k=rt.UNKNOWN_REASON;x instanceof ie&&(k=Qd(x)),this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,k),p(x)}}}),h=this.regionUrl;return this.regionUrl=void 0,this.connectFuture=new Ja((f,p)=>{d(f,p,h)},()=>{this.clearConnectionFutures()}),this.connectFuture.promise}),this.connectSignal=(a,o,c,l,u,d)=>y(this,void 0,void 0,function*(){var h,f,p;const g=yield c.join(a,o,{autoSubscribe:l.autoSubscribe,adaptiveStream:typeof u.adaptiveStream=="object"?!0:u.adaptiveStream,maxRetries:l.maxRetries,e2eeEnabled:!!this.e2eeManager,websocketTimeout:l.websocketTimeout},d.signal);let v=g.serverInfo;if(v||(v={version:g.serverVersion,region:g.serverRegion}),this.serverInfo=v,this.log.debug("connected to Livekit Server ".concat(Object.entries(v).map(b=>{let[S,x]=b;return"".concat(S,": ").concat(x)}).join(", ")),{room:(h=g.room)===null||h===void 0?void 0:h.name,roomSid:(f=g.room)===null||f===void 0?void 0:f.sid,identity:(p=g.participant)===null||p===void 0?void 0:p.identity}),!v.version)throw new Wk("unknown server version");return v.version==="0.15.1"&&this.options.dynacast&&(this.log.debug("disabling dynacast due to server version",this.logContext),u.dynacast=!1),g}),this.applyJoinResponse=a=>{const o=a.participant;if(this.localParticipant.sid=o.sid,this.localParticipant.identity=o.identity,this.localParticipant.setEnabledPublishCodecs(a.enabledPublishCodecs),this.options.e2ee&&this.e2eeManager)try{this.e2eeManager.setSifTrailer(a.sifTrailer)}catch(c){this.log.error(c instanceof Error?c.message:"Could not set SifTrailer",Object.assign(Object.assign({},this.logContext),{error:c}))}this.handleParticipantUpdates([o,...a.otherParticipants]),a.room&&this.handleRoomUpdate(a.room)},this.attemptConnection=(a,o,c,l)=>y(this,void 0,void 0,function*(){var u,d;this.state===J.Reconnecting||this.isResuming||!((u=this.engine)===null||u===void 0)&&u.pendingReconnect?(this.log.info("Reconnection attempt replaced by new connection attempt",this.logContext),this.recreateEngine()):this.maybeCreateEngine(),!((d=this.regionUrlProvider)===null||d===void 0)&&d.isCloud()&&this.engine.setRegionUrlProvider(this.regionUrlProvider),this.acquireAudioContext(),this.connOptions=Object.assign(Object.assign({},ho),c),this.connOptions.rtcConfig&&(this.engine.rtcConfig=this.connOptions.rtcConfig),this.connOptions.peerConnectionTimeout&&(this.engine.peerConnectionTimeout=this.connOptions.peerConnectionTimeout);try{const h=yield this.connectSignal(a,o,this.engine,this.connOptions,this.options,l);this.applyJoinResponse(h),this.setupLocalParticipantEvents(),this.emit(O.SignalConnected)}catch(h){yield this.engine.close(),this.recreateEngine();const f=new ie("could not establish signal connection",$.ServerUnreachable);throw h instanceof Error&&(f.message="".concat(f.message,": ").concat(h.message)),h instanceof ie&&(f.reason=h.reason,f.status=h.status),this.log.debug("error trying to establish signal connection",Object.assign(Object.assign({},this.logContext),{error:h})),f}if(l.signal.aborted)throw yield this.engine.close(),this.recreateEngine(),new ie("Connection attempt aborted",$.Cancelled);try{yield this.engine.waitForPCInitialConnection(this.connOptions.peerConnectionTimeout,l)}catch(h){throw yield this.engine.close(),this.recreateEngine(),h}We()&&this.options.disconnectOnPageLeave&&(window.addEventListener("pagehide",this.onPageLeave),window.addEventListener("beforeunload",this.onPageLeave)),We()&&document.addEventListener("freeze",this.onPageLeave),this.setAndEmitConnectionState(J.Connected),this.emit(O.Connected),this.registerConnectionReconcile()}),this.disconnect=function(){for(var a=arguments.length,o=new Array(a),c=0;c<a;c++)o[c]=arguments[c];return y(t,[...o],void 0,function(){var l=this;let u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return function*(){var d,h,f,p;const g=yield l.disconnectLock.lock();try{if(l.state===J.Disconnected){l.log.debug("already disconnected",l.logContext);return}l.log.info("disconnect from room",Object.assign({},l.logContext)),(l.state===J.Connecting||l.state===J.Reconnecting||l.isResuming)&&(l.log.warn("abort connection attempt",l.logContext),(d=l.abortController)===null||d===void 0||d.abort(),(f=(h=l.connectFuture)===null||h===void 0?void 0:h.reject)===null||f===void 0||f.call(h,new ie("Client initiated disconnect",$.Cancelled)),l.connectFuture=void 0),!((p=l.engine)===null||p===void 0)&&p.client.isDisconnected||(yield l.engine.client.sendLeave()),l.engine&&(yield l.engine.close()),l.handleDisconnect(u,rt.CLIENT_INITIATED),l.engine=void 0}finally{g()}}()})},this.onPageLeave=()=>y(this,void 0,void 0,function*(){this.log.info("Page leave detected, disconnecting",this.logContext),yield this.disconnect()}),this.startAudio=()=>y(this,void 0,void 0,function*(){const a=[],o=ct();if(o&&o.os==="iOS"){const c="livekit-dummy-audio-el";let l=document.getElementById(c);if(!l){l=document.createElement("audio"),l.id=c,l.autoplay=!0,l.hidden=!0;const u=Xa();u.enabled=!0;const d=new MediaStream([u]);l.srcObject=d,document.addEventListener("visibilitychange",()=>{l&&(l.srcObject=document.hidden?null:d,document.hidden||(this.log.debug("page visible again, triggering startAudio to resume playback and update playback status",this.logContext),this.startAudio()))}),document.body.append(l),this.once(O.Disconnected,()=>{l==null||l.remove(),l=null})}a.push(l)}this.remoteParticipants.forEach(c=>{c.audioTrackPublications.forEach(l=>{l.track&&l.track.attachedElements.forEach(u=>{a.push(u)})})});try{yield Promise.all([this.acquireAudioContext(),...a.map(c=>(c.muted=!1,c.play()))]),this.handleAudioPlaybackStarted()}catch(c){throw this.handleAudioPlaybackFailed(c),c}}),this.startVideo=()=>y(this,void 0,void 0,function*(){const a=[];for(const o of this.remoteParticipants.values())o.videoTrackPublications.forEach(c=>{var l;(l=c.track)===null||l===void 0||l.attachedElements.forEach(u=>{a.includes(u)||a.push(u)})});yield Promise.all(a.map(o=>o.play())).then(()=>{this.handleVideoPlaybackStarted()}).catch(o=>{o.name==="NotAllowedError"?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 a of this.remoteParticipants.values())this.handleParticipantDisconnected(a.identity,a);this.setAndEmitConnectionState(J.Reconnecting)&&this.emit(O.Reconnecting)},this.handleSignalRestarted=a=>y(this,void 0,void 0,function*(){this.log.debug("signal reconnected to server, region ".concat(a.serverRegion),Object.assign(Object.assign({},this.logContext),{region:a.serverRegion})),this.bufferedEvents=[],this.applyJoinResponse(a);try{yield this.localParticipant.republishAllTracks(void 0,!0)}catch(o){this.log.error("error trying to re-publish tracks after reconnection",Object.assign(Object.assign({},this.logContext),{error:o}))}try{yield this.engine.waitForRestarted(),this.log.debug("fully reconnected to server",Object.assign(Object.assign({},this.logContext),{region:a.serverRegion}))}catch{return}this.setAndEmitConnectionState(J.Connected),this.emit(O.Reconnected),this.registerConnectionReconcile(),this.emitBufferedEvents()}),this.handleParticipantUpdates=a=>{a.forEach(o=>{var c;if(o.identity===this.localParticipant.identity){this.localParticipant.updateInfo(o);return}o.identity===""&&(o.identity=(c=this.sidToIdentity.get(o.sid))!==null&&c!==void 0?c:"");let l=this.remoteParticipants.get(o.identity);o.state===Dn.DISCONNECTED?this.handleParticipantDisconnected(o.identity,l):l=this.getOrCreateParticipant(o.identity,o)})},this.handleActiveSpeakersUpdate=a=>{const o=[],c={};a.forEach(l=>{if(c[l.sid]=!0,l.sid===this.localParticipant.sid)this.localParticipant.audioLevel=l.level,this.localParticipant.setIsSpeaking(!0),o.push(this.localParticipant);else{const u=this.getRemoteParticipantBySid(l.sid);u&&(u.audioLevel=l.level,u.setIsSpeaking(!0),o.push(u))}}),c[this.localParticipant.sid]||(this.localParticipant.audioLevel=0,this.localParticipant.setIsSpeaking(!1)),this.remoteParticipants.forEach(l=>{c[l.sid]||(l.audioLevel=0,l.setIsSpeaking(!1))}),this.activeSpeakers=o,this.emitWhenConnected(O.ActiveSpeakersChanged,o)},this.handleSpeakersChanged=a=>{const o=new Map;this.activeSpeakers.forEach(l=>{const u=this.remoteParticipants.get(l.identity);u&&u.sid!==l.sid||o.set(l.sid,l)}),a.forEach(l=>{let u=this.getRemoteParticipantBySid(l.sid);l.sid===this.localParticipant.sid&&(u=this.localParticipant),u&&(u.audioLevel=l.level,u.setIsSpeaking(l.active),l.active?o.set(l.sid,u):o.delete(l.sid))});const c=Array.from(o.values());c.sort((l,u)=>u.audioLevel-l.audioLevel),this.activeSpeakers=c,this.emitWhenConnected(O.ActiveSpeakersChanged,c)},this.handleStreamStateUpdate=a=>{a.streamStates.forEach(o=>{const c=this.getRemoteParticipantBySid(o.participantSid);if(!c)return;const l=c.getTrackPublicationBySid(o.trackSid);if(!l||!l.track)return;const u=P.streamStateFromProto(o.state);u!==l.track.streamState&&(l.track.streamState=u,c.emit(L.TrackStreamStateChanged,l,l.track.streamState),this.emitWhenConnected(O.TrackStreamStateChanged,l,l.track.streamState,c))})},this.handleSubscriptionPermissionUpdate=a=>{const o=this.getRemoteParticipantBySid(a.participantSid);if(!o)return;const c=o.getTrackPublicationBySid(a.trackSid);c&&c.setAllowed(a.allowed)},this.handleSubscriptionError=a=>{const o=Array.from(this.remoteParticipants.values()).find(l=>l.trackPublications.has(a.trackSid));if(!o)return;const c=o.getTrackPublicationBySid(a.trackSid);c&&c.setSubscriptionError(a.err)},this.handleDataPacket=a=>{const o=this.remoteParticipants.get(a.participantIdentity);if(a.value.case==="user")this.handleUserPacket(o,a.value.value,a.kind);else if(a.value.case==="transcription")this.handleTranscription(o,a.value.value);else if(a.value.case==="sipDtmf")this.handleSipDtmf(o,a.value.value);else if(a.value.case==="chatMessage")this.handleChatMessage(o,a.value.value);else if(a.value.case==="metrics")this.handleMetrics(a.value.value,o);else if(a.value.case==="streamHeader")this.handleStreamHeader(a.value.value,a.participantIdentity);else if(a.value.case==="streamChunk")this.handleStreamChunk(a.value.value);else if(a.value.case==="streamTrailer")this.handleStreamTrailer(a.value.value);else if(a.value.case==="rpcRequest"){const c=a.value.value;this.handleIncomingRpcRequest(a.participantIdentity,c.id,c.method,c.payload,c.responseTimeoutMs,c.version)}},this.handleUserPacket=(a,o,c)=>{this.emit(O.DataReceived,o.payload,a,c,o.topic),a==null||a.emit(L.DataReceived,o.payload,c)},this.handleSipDtmf=(a,o)=>{this.emit(O.SipDTMFReceived,o,a),a==null||a.emit(L.SipDTMFReceived,o)},this.bufferedSegments=new Map,this.handleTranscription=(a,o)=>{const c=o.transcribedParticipantIdentity===this.localParticipant.identity?this.localParticipant:this.getParticipantByIdentity(o.transcribedParticipantIdentity),l=c==null?void 0:c.trackPublications.get(o.trackId),u=hT(o,this.transcriptionReceivedTimes);l==null||l.emit(N.TranscriptionReceived,u),c==null||c.emit(L.TranscriptionReceived,u,l),this.emit(O.TranscriptionReceived,u,c,l)},this.handleChatMessage=(a,o)=>{const c=fT(o);this.emit(O.ChatMessage,c,a)},this.handleMetrics=(a,o)=>{this.emit(O.MetricsReceived,a,o)},this.handleAudioPlaybackStarted=()=>{this.canPlaybackAudio||(this.audioEnabled=!0,this.emit(O.AudioPlaybackStatusChanged,!0))},this.handleAudioPlaybackFailed=a=>{this.log.warn("could not playback audio",Object.assign(Object.assign({},this.logContext),{error:a})),this.canPlaybackAudio&&(this.audioEnabled=!1,this.emit(O.AudioPlaybackStatusChanged,!1))},this.handleVideoPlaybackStarted=()=>{this.isVideoPlaybackBlocked&&(this.isVideoPlaybackBlocked=!1,this.emit(O.VideoPlaybackStatusChanged,!0))},this.handleVideoPlaybackFailed=()=>{this.isVideoPlaybackBlocked||(this.isVideoPlaybackBlocked=!0,this.emit(O.VideoPlaybackStatusChanged,!1))},this.handleDeviceChange=()=>y(this,void 0,void 0,function*(){var a,o,c;const l=we.getInstance().previousDevices,u=yield we.getInstance().getDevices(void 0,!1),d=ct();if((d==null?void 0:d.name)==="Chrome"&&d.os!=="iOS")for(let f of u){const p=l.find(g=>g.deviceId===f.deviceId);p&&p.label!==""&&p.kind===f.kind&&p.label!==f.label&&this.getActiveDevice(f.kind)==="default"&&this.emit(O.ActiveDeviceChanged,f.kind,f.deviceId)}const h=["audiooutput","audioinput","videoinput"];for(let f of h){const p=vT(f),g=this.localParticipant.getTrackPublication(p);if(g&&(!((a=g.track)===null||a===void 0)&&a.isUserProvided))continue;const v=u.filter(S=>S.kind===f),b=this.getActiveDevice(f);if(b===((o=l.filter(S=>S.kind===f)[0])===null||o===void 0?void 0:o.deviceId)&&v.length>0&&((c=v[0])===null||c===void 0?void 0:c.deviceId)!==b){yield this.switchActiveDevice(f,v[0].deviceId);continue}f==="audioinput"&&!Xt()||f==="videoinput"||v.length>0&&!v.find(S=>S.deviceId===this.getActiveDevice(f))&&(yield this.switchActiveDevice(f,v[0].deviceId))}this.emit(O.MediaDevicesChanged)}),this.handleRoomUpdate=a=>{const o=this.roomInfo;this.roomInfo=a,o&&o.metadata!==a.metadata&&this.emitWhenConnected(O.RoomMetadataChanged,a.metadata),(o==null?void 0:o.activeRecording)!==a.activeRecording&&this.emitWhenConnected(O.RecordingStatusChanged,a.activeRecording)},this.handleConnectionQualityUpdate=a=>{a.updates.forEach(o=>{if(o.participantSid===this.localParticipant.sid){this.localParticipant.setConnectionQuality(o.quality);return}const c=this.getRemoteParticipantBySid(o.participantSid);c&&c.setConnectionQuality(o.quality)})},this.onLocalParticipantMetadataChanged=a=>{this.emit(O.ParticipantMetadataChanged,a,this.localParticipant)},this.onLocalParticipantNameChanged=a=>{this.emit(O.ParticipantNameChanged,a,this.localParticipant)},this.onLocalAttributesChanged=a=>{this.emit(O.ParticipantAttributesChanged,a,this.localParticipant)},this.onLocalTrackMuted=a=>{this.emit(O.TrackMuted,a,this.localParticipant)},this.onLocalTrackUnmuted=a=>{this.emit(O.TrackUnmuted,a,this.localParticipant)},this.onTrackProcessorUpdate=a=>{var o;(o=a==null?void 0:a.onPublish)===null||o===void 0||o.call(a,this)},this.onLocalTrackPublished=a=>y(this,void 0,void 0,function*(){var o,c,l,u,d,h;(o=a.track)===null||o===void 0||o.on(N.TrackProcessorUpdate,this.onTrackProcessorUpdate),(c=a.track)===null||c===void 0||c.on(N.Restarted,this.onLocalTrackRestarted),(d=(u=(l=a.track)===null||l===void 0?void 0:l.getProcessor())===null||u===void 0?void 0:u.onPublish)===null||d===void 0||d.call(u,this),this.emit(O.LocalTrackPublished,a,this.localParticipant),gn(a.track)&&(yield a.track.checkForSilence())&&this.emit(O.LocalAudioSilenceDetected,a);const f=yield(h=a.track)===null||h===void 0?void 0:h.getDeviceId(!1),p=nh(a.source);p&&f&&f!==this.localParticipant.activeDeviceMap.get(p)&&(this.localParticipant.activeDeviceMap.set(p,f),this.emit(O.ActiveDeviceChanged,p,f))}),this.onLocalTrackUnpublished=a=>{var o,c;(o=a.track)===null||o===void 0||o.off(N.TrackProcessorUpdate,this.onTrackProcessorUpdate),(c=a.track)===null||c===void 0||c.off(N.Restarted,this.onLocalTrackRestarted),this.emit(O.LocalTrackUnpublished,a,this.localParticipant)},this.onLocalTrackRestarted=a=>y(this,void 0,void 0,function*(){const o=yield a.getDeviceId(!1),c=nh(a.source);c&&o&&o!==this.localParticipant.activeDeviceMap.get(c)&&(this.log.debug("local track restarted, setting ".concat(c," ").concat(o," active"),this.logContext),this.localParticipant.activeDeviceMap.set(c,o),this.emit(O.ActiveDeviceChanged,c,o))}),this.onLocalConnectionQualityChanged=a=>{this.emit(O.ConnectionQualityChanged,a,this.localParticipant)},this.onMediaDevicesError=a=>{this.emit(O.MediaDevicesError,a)},this.onLocalParticipantPermissionsChanged=a=>{this.emit(O.ParticipantPermissionsChanged,a,this.localParticipant)},this.onLocalChatMessageSent=a=>{this.emit(O.ChatMessage,a,this.localParticipant)},this.setMaxListeners(100),this.remoteParticipants=new Map,this.sidToIdentity=new Map,this.options=Object.assign(Object.assign({},BT),e),this.log=Et((i=this.options.loggerName)!==null&&i!==void 0?i:ot.Room),this.transcriptionReceivedTimes=new Map,this.options.audioCaptureDefaults=Object.assign(Object.assign({},fh),e==null?void 0:e.audioCaptureDefaults),this.options.videoCaptureDefaults=Object.assign(Object.assign({},ph),e==null?void 0:e.videoCaptureDefaults),this.options.publishDefaults=Object.assign(Object.assign({},UT),e==null?void 0:e.publishDefaults),this.maybeCreateEngine(),this.disconnectLock=new Fe,this.localParticipant=new mS("","",this.engine,this.options,this.rpcHandlers),this.options.videoCaptureDefaults.deviceId&&this.localParticipant.activeDeviceMap.set("videoinput",Jt(this.options.videoCaptureDefaults.deviceId)),this.options.audioCaptureDefaults.deviceId&&this.localParticipant.activeDeviceMap.set("audioinput",Jt(this.options.audioCaptureDefaults.deviceId)),!((r=this.options.audioOutput)===null||r===void 0)&&r.deviceId&&this.switchActiveDevice("audiooutput",Jt(this.options.audioOutput.deviceId)).catch(a=>this.log.warn("Could not set audio output: ".concat(a.message),this.logContext)),this.options.e2ee&&this.setupE2EE(),We()){const a=new AbortController;(s=navigator.mediaDevices)===null||s===void 0||s.addEventListener("devicechange",this.handleDeviceChange,{signal:a.signal}),Kn.cleanupRegistry&&Kn.cleanupRegistry.register(this,()=>{a.abort()})}}registerTextStreamHandler(e,t){if(this.textStreamHandlers.has(e))throw new TypeError('A text stream handler for topic "'.concat(e,'" has already been set.'));this.textStreamHandlers.set(e,t)}unregisterTextStreamHandler(e){this.textStreamHandlers.delete(e)}registerByteStreamHandler(e,t){if(this.byteStreamHandlers.has(e))throw new TypeError('A byte stream handler for topic "'.concat(e,'" has already been set.'));this.byteStreamHandlers.set(e,t)}unregisterByteStreamHandler(e){this.byteStreamHandlers.delete(e)}registerRpcMethod(e,t){if(this.rpcHandlers.has(e))throw Error("RPC handler already registered for method ".concat(e,", unregisterRpcMethod before trying to register again"));this.rpcHandlers.set(e,t)}unregisterRpcMethod(e){this.rpcHandlers.delete(e)}handleIncomingRpcRequest(e,t,i,r,s,a){return y(this,void 0,void 0,function*(){if(yield this.engine.publishRpcAck(e,t),a!==1){yield this.engine.publishRpcResponse(e,t,null,pe.builtIn("UNSUPPORTED_VERSION"));return}const o=this.rpcHandlers.get(i);if(!o){yield this.engine.publishRpcResponse(e,t,null,pe.builtIn("UNSUPPORTED_METHOD"));return}let c=null,l=null;try{const u=yield o({requestId:t,callerIdentity:e,payload:r,responseTimeout:s});fo(u)>mh?(c=pe.builtIn("RESPONSE_PAYLOAD_TOO_LARGE"),console.warn("RPC Response payload too large for ".concat(i))):l=u}catch(u){u instanceof pe?c=u:(console.warn("Uncaught error returned by RPC handler for ".concat(i,". Returning APPLICATION_ERROR instead."),u),c=pe.builtIn("APPLICATION_ERROR"))}yield this.engine.publishRpcResponse(e,t,l,c)})}setE2EEEnabled(e){return y(this,void 0,void 0,function*(){if(this.e2eeManager)yield Promise.all([this.localParticipant.setE2EEEnabled(e)]),this.localParticipant.identity!==""&&this.e2eeManager.setParticipantCryptorEnabled(e,this.localParticipant.identity);else throw Error("e2ee not configured, please set e2ee settings within the room options")})}setupE2EE(){var e;this.options.e2ee&&("e2eeManager"in this.options.e2ee?this.e2eeManager=this.options.e2ee.e2eeManager:this.e2eeManager=new CT(this.options.e2ee),this.e2eeManager.on($t.ParticipantEncryptionStatusChanged,(t,i)=>{mT(i)&&(this.isE2EEEnabled=t),this.emit(O.ParticipantEncryptionStatusChanged,t,i)}),this.e2eeManager.on($t.EncryptionError,t=>this.emit(O.EncryptionError,t)),(e=this.e2eeManager)===null||e===void 0||e.setup(this))}get logContext(){var e;return{room:this.name,roomID:(e=this.roomInfo)===null||e===void 0?void 0:e.sid,participant:this.localParticipant.identity,pID:this.localParticipant.sid}}get isRecording(){var e,t;return(t=(e=this.roomInfo)===null||e===void 0?void 0:e.activeRecording)!==null&&t!==void 0?t:!1}getSid(){return y(this,void 0,void 0,function*(){return this.state===J.Disconnected?"":this.roomInfo&&this.roomInfo.sid!==""?this.roomInfo.sid:new Promise((e,t)=>{const i=r=>{r.sid!==""&&(this.engine.off(M.RoomUpdate,i),e(r.sid))};this.engine.on(M.RoomUpdate,i),this.once(O.Disconnected,()=>{this.engine.off(M.RoomUpdate,i),t("Room disconnected before room server id was available")})})})}get name(){var e,t;return(t=(e=this.roomInfo)===null||e===void 0?void 0:e.name)!==null&&t!==void 0?t:""}get metadata(){var e;return(e=this.roomInfo)===null||e===void 0?void 0:e.metadata}get numParticipants(){var e,t;return(t=(e=this.roomInfo)===null||e===void 0?void 0:e.numParticipants)!==null&&t!==void 0?t:0}get numPublishers(){var e,t;return(t=(e=this.roomInfo)===null||e===void 0?void 0:e.numPublishers)!==null&&t!==void 0?t:0}maybeCreateEngine(){this.engine&&!this.engine.isClosed||(this.engine=new eS(this.options),this.engine.on(M.ParticipantUpdate,this.handleParticipantUpdates).on(M.RoomUpdate,this.handleRoomUpdate).on(M.SpeakersChanged,this.handleSpeakersChanged).on(M.StreamStateChanged,this.handleStreamStateUpdate).on(M.ConnectionQualityUpdate,this.handleConnectionQualityUpdate).on(M.SubscriptionError,this.handleSubscriptionError).on(M.SubscriptionPermissionUpdate,this.handleSubscriptionPermissionUpdate).on(M.MediaTrackAdded,(e,t,i)=>{this.onTrackAdded(e,t,i)}).on(M.Disconnected,e=>{this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,e)}).on(M.ActiveSpeakersUpdate,this.handleActiveSpeakersUpdate).on(M.DataPacketReceived,this.handleDataPacket).on(M.Resuming,()=>{this.clearConnectionReconcile(),this.isResuming=!0,this.log.info("Resuming signal connection",this.logContext),this.setAndEmitConnectionState(J.SignalReconnecting)&&this.emit(O.SignalReconnecting)}).on(M.Resumed,()=>{this.registerConnectionReconcile(),this.isResuming=!1,this.log.info("Resumed signal connection",this.logContext),this.updateSubscriptions(),this.emitBufferedEvents(),this.setAndEmitConnectionState(J.Connected)&&this.emit(O.Reconnected)}).on(M.SignalResumed,()=>{this.bufferedEvents=[],(this.state===J.Reconnecting||this.isResuming)&&this.sendSyncState()}).on(M.Restarting,this.handleRestarting).on(M.SignalRestarted,this.handleSignalRestarted).on(M.Offline,()=>{this.setAndEmitConnectionState(J.Reconnecting)&&this.emit(O.Reconnecting)}).on(M.DCBufferStatusChanged,(e,t)=>{this.emit(O.DCBufferStatusChanged,e,t)}).on(M.LocalTrackSubscribed,e=>{const t=this.localParticipant.getTrackPublications().find(i=>{let{trackSid:r}=i;return r===e});if(!t){this.log.warn("could not find local track subscription for subscribed event",this.logContext);return}this.localParticipant.emit(L.LocalTrackSubscribed,t),this.emitWhenConnected(O.LocalTrackSubscribed,t,this.localParticipant)}).on(M.RoomMoved,e=>{this.log.debug("room moved",e),e.room&&this.handleRoomUpdate(e.room),this.remoteParticipants.forEach((t,i)=>{this.handleParticipantDisconnected(i,t)}),this.emit(O.Moved,e.room.name,e.token),e.participant?this.handleParticipantUpdates([e.participant,...e.otherParticipants]):this.handleParticipantUpdates(e.otherParticipants)}),this.localParticipant&&this.localParticipant.setupEngine(this.engine),this.e2eeManager&&this.e2eeManager.setupEngine(this.engine))}static getLocalDevices(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return we.getInstance().getDevices(e,t)}prepareConnection(e,t){return y(this,void 0,void 0,function*(){if(this.state===J.Disconnected){this.log.debug("prepareConnection to ".concat(e),this.logContext);try{if(Ka(new URL(e))&&t){this.regionUrlProvider=new yo(e,t);const i=yield this.regionUrlProvider.getNextBestRegionUrl();i&&this.state===J.Disconnected&&(this.regionUrl=i,yield fetch(Qa(i),{method:"HEAD"}),this.log.debug("prepared connection to ".concat(i),this.logContext))}else yield fetch(Qa(e),{method:"HEAD"})}catch(i){this.log.warn("could not prepare connection",Object.assign(Object.assign({},this.logContext),{error:i}))}}})}getParticipantByIdentity(e){return this.localParticipant.identity===e?this.localParticipant:this.remoteParticipants.get(e)}clearConnectionFutures(){this.connectFuture=void 0}simulateScenario(e,t){return y(this,void 0,void 0,function*(){let i=()=>{},r;switch(e){case"signal-reconnect":yield this.engine.client.handleOnClose("simulate disconnect");break;case"speaker":r=new kt({scenario:{case:"speakerUpdate",value:3}});break;case"node-failure":r=new kt({scenario:{case:"nodeFailure",value:!0}});break;case"server-leave":r=new kt({scenario:{case:"serverLeave",value:!0}});break;case"migration":r=new kt({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=()=>y(this,void 0,void 0,function*(){yield this.engine.client.handleOnClose("simulate resume-disconnect")}),r=new kt({scenario:{case:"disconnectSignalOnResume",value:!0}});break;case"disconnect-signal-on-resume-no-messages":i=()=>y(this,void 0,void 0,function*(){yield this.engine.client.handleOnClose("simulate resume-disconnect")}),r=new kt({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":r=new kt({scenario:{case:"switchCandidateProtocol",value:e==="force-tls"?2:1}}),i=()=>y(this,void 0,void 0,function*(){const s=this.engine.client.onLeave;s&&s(new Dr({reason:rt.CLIENT_INITIATED,action:Bn.RECONNECT}))});break;case"subscriber-bandwidth":if(t===void 0||typeof t!="number")throw new Error("subscriber-bandwidth requires a number as argument");r=new kt({scenario:{case:"subscriberBandwidth",value:mn(t)}});break;case"leave-full-reconnect":r=new kt({scenario:{case:"leaveRequestFullReconnect",value:!0}})}r&&(yield this.engine.client.sendSimulateScenario(r),yield i())})}get canPlaybackAudio(){return this.audioEnabled}get canPlaybackVideo(){return!this.isVideoPlaybackBlocked}getActiveDevice(e){return this.localParticipant.activeDeviceMap.get(e)}switchActiveDevice(e,t){return y(this,arguments,void 0,function(i,r){var s=this;let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return function*(){var o,c,l,u,d,h,f,p;let g=!0,v=!1;const b=a?{exact:r}:r;if(i==="audioinput"){v=s.localParticipant.audioTrackPublications.size===0;const S=(o=s.getActiveDevice(i))!==null&&o!==void 0?o:s.options.audioCaptureDefaults.deviceId;s.options.audioCaptureDefaults.deviceId=b;const x=Array.from(s.localParticipant.audioTrackPublications.values()).filter(k=>k.source===P.Source.Microphone);try{g=(yield Promise.all(x.map(k=>{var T;return(T=k.audioTrack)===null||T===void 0?void 0:T.setDeviceId(b)}))).every(k=>k===!0)}catch(k){throw s.options.audioCaptureDefaults.deviceId=S,k}}else if(i==="videoinput"){v=s.localParticipant.videoTrackPublications.size===0;const S=(c=s.getActiveDevice(i))!==null&&c!==void 0?c:s.options.videoCaptureDefaults.deviceId;s.options.videoCaptureDefaults.deviceId=b;const x=Array.from(s.localParticipant.videoTrackPublications.values()).filter(k=>k.source===P.Source.Camera);try{g=(yield Promise.all(x.map(k=>{var T;return(T=k.videoTrack)===null||T===void 0?void 0:T.setDeviceId(b)}))).every(k=>k===!0)}catch(k){throw s.options.videoCaptureDefaults.deviceId=S,k}}else if(i==="audiooutput"){if(!qa()&&!s.options.webAudioMix||s.options.webAudioMix&&s.audioContext&&!("setSinkId"in s.audioContext))throw new Error("cannot switch audio output, setSinkId not supported");s.options.webAudioMix&&(r=(l=yield we.getInstance().normalizeDeviceId("audiooutput",r))!==null&&l!==void 0?l:""),(u=(p=s.options).audioOutput)!==null&&u!==void 0||(p.audioOutput={});const S=(d=s.getActiveDevice(i))!==null&&d!==void 0?d:s.options.audioOutput.deviceId;s.options.audioOutput.deviceId=r;try{s.options.webAudioMix&&((h=s.audioContext)===null||h===void 0||h.setSinkId(r)),yield Promise.all(Array.from(s.remoteParticipants.values()).map(x=>x.setAudioOutput({deviceId:r})))}catch(x){throw s.options.audioOutput.deviceId=S,x}}return(v||i==="audiooutput")&&(s.localParticipant.activeDeviceMap.set(i,i==="audiooutput"&&((f=s.options.audioOutput)===null||f===void 0?void 0:f.deviceId)||r),s.emit(O.ActiveDeviceChanged,i,r)),g}()})}setupLocalParticipantEvents(){this.localParticipant.on(L.ParticipantMetadataChanged,this.onLocalParticipantMetadataChanged).on(L.ParticipantNameChanged,this.onLocalParticipantNameChanged).on(L.AttributesChanged,this.onLocalAttributesChanged).on(L.TrackMuted,this.onLocalTrackMuted).on(L.TrackUnmuted,this.onLocalTrackUnmuted).on(L.LocalTrackPublished,this.onLocalTrackPublished).on(L.LocalTrackUnpublished,this.onLocalTrackUnpublished).on(L.ConnectionQualityChanged,this.onLocalConnectionQualityChanged).on(L.MediaDevicesError,this.onMediaDevicesError).on(L.AudioStreamAcquired,this.startAudio).on(L.ChatMessage,this.onLocalChatMessageSent).on(L.ParticipantPermissionsChanged,this.onLocalParticipantPermissionsChanged)}recreateEngine(){var e;(e=this.engine)===null||e===void 0||e.close(),this.engine=void 0,this.isResuming=!1,this.remoteParticipants.clear(),this.sidToIdentity.clear(),this.bufferedEvents=[],this.maybeCreateEngine()}onTrackAdded(e,t,i){if(this.state===J.Connecting||this.state===J.Reconnecting){const u=()=>{this.onTrackAdded(e,t,i),d()},d=()=>{this.off(O.Reconnected,u),this.off(O.Connected,u),this.off(O.Disconnected,d)};this.once(O.Reconnected,u),this.once(O.Connected,u),this.once(O.Disconnected,d);return}if(this.state===J.Disconnected){this.log.warn("skipping incoming track after Room disconnected",this.logContext);return}if(e.readyState==="ended"){this.log.info("skipping incoming track as it already ended",this.logContext);return}const r=tT(t.id),s=r[0];let a=r[1],o=e.id;if(a&&a.startsWith("TR")&&(o=a),s===this.localParticipant.sid){this.log.warn("tried to create RemoteParticipant for local participant",this.logContext);return}const c=Array.from(this.remoteParticipants.values()).find(u=>u.sid===s);if(!c){this.log.error("Tried to add a track for a participant, that's not present. Sid: ".concat(s),this.logContext);return}let l;this.options.adaptiveStream&&(typeof this.options.adaptiveStream=="object"?l=this.options.adaptiveStream:l={}),c.addSubscribedMediaTrack(e,o,t,i,l)}handleDisconnect(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,t=arguments.length>1?arguments[1]:void 0;var i;if(this.clearConnectionReconcile(),this.isResuming=!1,this.bufferedEvents=[],this.transcriptionReceivedTimes.clear(),this.state!==J.Disconnected){this.regionUrl=void 0;try{this.remoteParticipants.forEach(r=>{r.trackPublications.forEach(s=>{r.unpublishTrack(s.trackSid)})}),this.localParticipant.trackPublications.forEach(r=>{var s,a,o;r.track&&this.localParticipant.unpublishTrack(r.track,e),e?((s=r.track)===null||s===void 0||s.detach(),(a=r.track)===null||a===void 0||a.stop()):(o=r.track)===null||o===void 0||o.stopMonitor()}),this.localParticipant.off(L.ParticipantMetadataChanged,this.onLocalParticipantMetadataChanged).off(L.ParticipantNameChanged,this.onLocalParticipantNameChanged).off(L.AttributesChanged,this.onLocalAttributesChanged).off(L.TrackMuted,this.onLocalTrackMuted).off(L.TrackUnmuted,this.onLocalTrackUnmuted).off(L.LocalTrackPublished,this.onLocalTrackPublished).off(L.LocalTrackUnpublished,this.onLocalTrackUnpublished).off(L.ConnectionQualityChanged,this.onLocalConnectionQualityChanged).off(L.MediaDevicesError,this.onMediaDevicesError).off(L.AudioStreamAcquired,this.startAudio).off(L.ChatMessage,this.onLocalChatMessageSent).off(L.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&&typeof this.options.webAudioMix=="boolean"&&(this.audioContext.close(),this.audioContext=void 0),We()&&(window.removeEventListener("beforeunload",this.onPageLeave),window.removeEventListener("pagehide",this.onPageLeave),window.removeEventListener("freeze",this.onPageLeave),(i=navigator.mediaDevices)===null||i===void 0||i.removeEventListener("devicechange",this.handleDeviceChange))}finally{this.setAndEmitConnectionState(J.Disconnected),this.emit(O.Disconnected,t)}}}handleParticipantDisconnected(e,t){var i;this.remoteParticipants.delete(e),t&&(t.trackPublications.forEach(r=>{t.unpublishTrack(r.trackSid,!0)}),this.emit(O.ParticipantDisconnected,t),t.setDisconnected(),(i=this.localParticipant)===null||i===void 0||i.handleParticipantDisconnected(t.identity))}handleStreamHeader(e,t){return y(this,void 0,void 0,function*(){var i;if(e.contentHeader.case==="byteHeader"){const r=this.byteStreamHandlers.get(e.topic);if(!r){this.log.debug("ignoring incoming byte stream due to no handler for topic",e.topic);return}let s;const a={id:e.streamId,name:(i=e.contentHeader.value.name)!==null&&i!==void 0?i:"unknown",mimeType:e.mimeType,size:e.totalLength?Number(e.totalLength):void 0,topic:e.topic,timestamp:Yr(e.timestamp),attributes:e.attributes},o=new ReadableStream({start:c=>{s=c,this.byteStreamControllers.set(e.streamId,{info:a,controller:s,startTime:Date.now()})}});r(new rS(a,o,Yr(e.totalLength)),{identity:t})}else if(e.contentHeader.case==="textHeader"){const r=this.textStreamHandlers.get(e.topic);if(!r){this.log.debug("ignoring incoming text stream due to no handler for topic",e.topic);return}let s;const a={id:e.streamId,mimeType:e.mimeType,size:e.totalLength?Number(e.totalLength):void 0,topic:e.topic,timestamp:Number(e.timestamp),attributes:e.attributes},o=new ReadableStream({start:c=>{s=c,this.textStreamControllers.set(e.streamId,{info:a,controller:s,startTime:Date.now()})}});r(new sS(a,o,Yr(e.totalLength)),{identity:t})}})}handleStreamChunk(e){const t=this.byteStreamControllers.get(e.streamId);t&&e.content.length>0&&t.controller.enqueue(e);const i=this.textStreamControllers.get(e.streamId);i&&e.content.length>0&&i.controller.enqueue(e)}handleStreamTrailer(e){const t=this.textStreamControllers.get(e.streamId);t&&(t.info.attributes=Object.assign(Object.assign({},t.info.attributes),e.attributes),t.controller.close(),this.textStreamControllers.delete(e.streamId));const i=this.byteStreamControllers.get(e.streamId);i&&(i.info.attributes=Object.assign(Object.assign({},i.info.attributes),e.attributes),i.controller.close(),this.byteStreamControllers.delete(e.streamId))}acquireAudioContext(){return y(this,void 0,void 0,function*(){var e,t;if(typeof this.options.webAudioMix!="boolean"&&this.options.webAudioMix.audioContext?this.audioContext=this.options.webAudioMix.audioContext:(!this.audioContext||this.audioContext.state==="closed")&&(this.audioContext=(e=th())!==null&&e!==void 0?e:void 0),this.options.webAudioMix&&this.remoteParticipants.forEach(r=>r.setAudioContext(this.audioContext)),this.localParticipant.setAudioContext(this.audioContext),this.audioContext&&this.audioContext.state==="suspended")try{yield Promise.race([this.audioContext.resume(),Ge(200)])}catch(r){this.log.warn("Could not resume audio context",Object.assign(Object.assign({},this.logContext),{error:r}))}const i=((t=this.audioContext)===null||t===void 0?void 0:t.state)==="running";i!==this.canPlaybackAudio&&(this.audioEnabled=i,this.emit(O.AudioPlaybackStatusChanged,i))})}createParticipant(e,t){var i;let r;return t?r=is.fromParticipantInfo(this.engine.client,t,{loggerContextCb:()=>this.logContext,loggerName:this.options.loggerName}):r=new is(this.engine.client,"",e,void 0,void 0,void 0,{loggerContextCb:()=>this.logContext,loggerName:this.options.loggerName}),this.options.webAudioMix&&r.setAudioContext(this.audioContext),!((i=this.options.audioOutput)===null||i===void 0)&&i.deviceId&&r.setAudioOutput(this.options.audioOutput).catch(s=>this.log.warn("Could not set audio output: ".concat(s.message),this.logContext)),r}getOrCreateParticipant(e,t){if(this.remoteParticipants.has(e)){const r=this.remoteParticipants.get(e);return t&&r.updateInfo(t)&&this.sidToIdentity.set(t.sid,t.identity),r}const i=this.createParticipant(e,t);return this.remoteParticipants.set(e,i),this.sidToIdentity.set(t.sid,t.identity),this.emitWhenConnected(O.ParticipantConnected,i),i.on(L.TrackPublished,r=>{this.emitWhenConnected(O.TrackPublished,r,i)}).on(L.TrackSubscribed,(r,s)=>{r.kind===P.Kind.Audio?(r.on(N.AudioPlaybackStarted,this.handleAudioPlaybackStarted),r.on(N.AudioPlaybackFailed,this.handleAudioPlaybackFailed)):r.kind===P.Kind.Video&&(r.on(N.VideoPlaybackFailed,this.handleVideoPlaybackFailed),r.on(N.VideoPlaybackStarted,this.handleVideoPlaybackStarted)),this.emit(O.TrackSubscribed,r,s,i)}).on(L.TrackUnpublished,r=>{this.emit(O.TrackUnpublished,r,i)}).on(L.TrackUnsubscribed,(r,s)=>{this.emit(O.TrackUnsubscribed,r,s,i)}).on(L.TrackMuted,r=>{this.emitWhenConnected(O.TrackMuted,r,i)}).on(L.TrackUnmuted,r=>{this.emitWhenConnected(O.TrackUnmuted,r,i)}).on(L.ParticipantMetadataChanged,r=>{this.emitWhenConnected(O.ParticipantMetadataChanged,r,i)}).on(L.ParticipantNameChanged,r=>{this.emitWhenConnected(O.ParticipantNameChanged,r,i)}).on(L.AttributesChanged,r=>{this.emitWhenConnected(O.ParticipantAttributesChanged,r,i)}).on(L.ConnectionQualityChanged,r=>{this.emitWhenConnected(O.ConnectionQualityChanged,r,i)}).on(L.ParticipantPermissionsChanged,r=>{this.emitWhenConnected(O.ParticipantPermissionsChanged,r,i)}).on(L.TrackSubscriptionStatusChanged,(r,s)=>{this.emitWhenConnected(O.TrackSubscriptionStatusChanged,r,s,i)}).on(L.TrackSubscriptionFailed,(r,s)=>{this.emit(O.TrackSubscriptionFailed,r,i,s)}).on(L.TrackSubscriptionPermissionChanged,(r,s)=>{this.emitWhenConnected(O.TrackSubscriptionPermissionChanged,r,s,i)}).on(L.Active,()=>{this.emitWhenConnected(O.ParticipantActive,i)}),t&&i.updateInfo(t),i}sendSyncState(){const e=Array.from(this.remoteParticipants.values()).reduce((i,r)=>(i.push(...r.getTrackPublications()),i),[]),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&&pT(t)&&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=Ie.setInterval(()=>{!this.engine||this.engine.isClosed||!this.engine.verifyTransport()?(e++,this.log.warn("detected connection state mismatch",Object.assign(Object.assign({},this.logContext),{numFailures:e,engine:this.engine?{closed:this.engine.isClosed,transportsConnected:this.engine.verifyTransport()}:void 0})),e>=3&&(this.recreateEngine(),this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,rt.STATE_MISMATCH))):e=0},vS)}clearConnectionReconcile(){this.connectionReconcileInterval&&Ie.clearInterval(this.connectionReconcileInterval)}setAndEmitConnectionState(e){return e===this.state?!1:(this.state=e,this.emit(O.ConnectionStateChanged,this.state),!0)}emitBufferedEvents(){this.bufferedEvents.forEach(e=>{let[t,i]=e;this.emit(t,...i)}),this.bufferedEvents=[]}emitWhenConnected(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];if(this.state===J.Reconnecting||this.isResuming||!this.engine||this.engine.pendingReconnect)this.bufferedEvents.push([e,i]);else if(this.state===J.Connected)return this.emit(e,...i);return!1}simulateParticipants(e){return y(this,void 0,void 0,function*(){var t,i;const r=Object.assign({audio:!0,video:!0,useRealTracks:!1},e.publish),s=Object.assign({count:9,audio:!1,video:!0,aspectRatios:[1.66,1.7,1.3]},e.participants);if(this.handleDisconnect(),this.roomInfo=new Ar({sid:"RM_SIMULATED",name:"simulated-room",emptyTimeout:0,maxParticipants:0,creationTime:le.parse(new Date().getTime()),metadata:"",numParticipants:1,numPublishers:1,turnPassword:"",enabledCodecs:[],activeRecording:!1}),this.localParticipant.updateInfo(new un({identity:"simulated-local",name:"local-name"})),this.setupLocalParticipantEvents(),this.emit(O.SignalConnected),this.emit(O.Connected),this.setAndEmitConnectionState(J.Connected),r.video){const a=new So(P.Kind.Video,new Un({source:ke.CAMERA,sid:Math.floor(Math.random()*1e4).toString(),type:it.AUDIO,name:"video-dummy"}),new ts(r.useRealTracks?(yield window.navigator.mediaDevices.getUserMedia({video:!0})).getVideoTracks()[0]:Jd(160*((t=s.aspectRatios[0])!==null&&t!==void 0?t:1),160,!0,!0),void 0,!1,{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext}),{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext});this.localParticipant.addTrackPublication(a),this.localParticipant.emit(L.LocalTrackPublished,a)}if(r.audio){const a=new So(P.Kind.Audio,new Un({source:ke.MICROPHONE,sid:Math.floor(Math.random()*1e4).toString(),type:it.AUDIO}),new Zr(r.useRealTracks?(yield navigator.mediaDevices.getUserMedia({audio:!0})).getAudioTracks()[0]:Xa(),void 0,!1,this.audioContext,{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext}),{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext});this.localParticipant.addTrackPublication(a),this.localParticipant.emit(L.LocalTrackPublished,a)}for(let a=0;a<s.count-1;a+=1){let o=new un({sid:Math.floor(Math.random()*1e4).toString(),identity:"simulated-".concat(a),state:Dn.ACTIVE,tracks:[],joinedAt:le.parse(Date.now())});const c=this.getOrCreateParticipant(o.identity,o);if(s.video){const l=Jd(160*((i=s.aspectRatios[a%s.aspectRatios.length])!==null&&i!==void 0?i:1),160,!1,!0),u=new Un({source:ke.CAMERA,sid:Math.floor(Math.random()*1e4).toString(),type:it.AUDIO});c.addSubscribedMediaTrack(l,u.sid,new MediaStream([l]),new RTCRtpReceiver),o.tracks=[...o.tracks,u]}if(s.audio){const l=Xa(),u=new Un({source:ke.MICROPHONE,sid:Math.floor(Math.random()*1e4).toString(),type:it.AUDIO});c.addSubscribedMediaTrack(l,u.sid,new MediaStream([l]),new RTCRtpReceiver),o.tracks=[...o.tracks,u]}c.updateInfo(o)}})}emit(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];if(e!==O.ActiveSpeakersChanged&&e!==O.TranscriptionReceived){const s=Ih(i).filter(a=>a!==void 0);this.log.debug("room event ".concat(e),Object.assign(Object.assign({},this.logContext),{event:e,args:s}))}return super.emit(e,...i)}}Kn.cleanupRegistry=typeof FinalizationRegistry<"u"&&new FinalizationRegistry(n=>{n()});function Ih(n){return n.map(e=>{if(e)return Array.isArray(e)?Ih(e):typeof e=="object"?"logContext"in e?e.logContext:void 0:e})}var dt;(function(n){n[n.IDLE=0]="IDLE",n[n.RUNNING=1]="RUNNING",n[n.SKIPPED=2]="SKIPPED",n[n.SUCCESS=3]="SUCCESS",n[n.FAILED=4]="FAILED"})(dt||(dt={}));class tn extends Tt.EventEmitter{constructor(e,t){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};super(),this.status=dt.IDLE,this.logs=[],this.options={},this.url=e,this.token=t,this.name=this.constructor.name,this.room=new Kn(i.roomOptions),this.connectOptions=i.connectOptions,this.options=i}run(e){return y(this,void 0,void 0,function*(){if(this.status!==dt.IDLE)throw Error("check is running already");this.setStatus(dt.RUNNING);try{yield this.perform()}catch(t){t instanceof Error&&(this.options.errorsAsWarnings?this.appendWarning(t.message):this.appendError(t.message))}return yield this.disconnect(),yield new Promise(t=>setTimeout(t,500)),this.status!==dt.SKIPPED&&this.setStatus(this.isSuccess()?dt.SUCCESS:dt.FAILED),e&&e(),this.getInfo()})}isSuccess(){return!this.logs.some(e=>e.level==="error")}connect(e){return y(this,void 0,void 0,function*(){return this.room.state===J.Connected?this.room:(e||(e=this.url),yield this.room.connect(e,this.token,this.connectOptions),this.room)})}disconnect(){return y(this,void 0,void 0,function*(){this.room&&this.room.state!==J.Disconnected&&(yield this.room.disconnect(),yield new Promise(e=>setTimeout(e,500)))})}skip(){this.setStatus(dt.SKIPPED)}switchProtocol(e){return y(this,void 0,void 0,function*(){let t=!1,i=!1;if(this.room.on(O.Reconnecting,()=>{t=!0}),this.room.once(O.Reconnected,()=>{i=!0}),this.room.simulateScenario("force-".concat(e)),yield new Promise(s=>setTimeout(s,1e3)),!t)return;const r=Date.now()+1e4;for(;Date.now()<r;){if(i)return;yield Ge(100)}throw new Error("Could not reconnect using ".concat(e," protocol after 10 seconds"))})}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(e=this.room)===null||e===void 0?void 0:e.engine}getInfo(){return{logs:this.logs,name:this.name,status:this.status,description:this.description}}}class bS extends tn{get description(){return"Cloud regions"}perform(){return y(this,void 0,void 0,function*(){const e=new yo(this.url,this.token);if(!e.isCloud()){this.skip();return}const t=[],i=new Set;for(let s=0;s<3;s++){const a=yield e.getNextBestRegionUrl();if(!a)break;if(i.has(a))continue;i.add(a);const o=yield this.checkCloudRegion(a);this.appendMessage("".concat(o.region," RTT: ").concat(o.rtt,"ms, duration: ").concat(o.duration,"ms")),t.push(o)}t.sort((s,a)=>(s.duration-a.duration)*.5+(s.rtt-a.rtt)*.5);const r=t[0];this.bestStats=r,this.appendMessage("best Cloud region: ".concat(r.region))})}getInfo(){const e=super.getInfo();return e.data=this.bestStats,e}checkCloudRegion(e){return y(this,void 0,void 0,function*(){var t,i;yield this.connect(e),this.options.protocol==="tcp"&&(yield this.switchProtocol("tcp"));const r=(t=this.room.serverInfo)===null||t===void 0?void 0:t.region;if(!r)throw new Error("Region not found");const s=yield this.room.localParticipant.streamText({topic:"test"}),a=1e3,c=1e6/a,l="A".repeat(a),u=Date.now();for(let p=0;p<c;p++)yield s.write(l);yield s.close();const d=Date.now(),h=yield(i=this.room.engine.pcManager)===null||i===void 0?void 0:i.publisher.getStats(),f={region:r,rtt:1e4,duration:d-u};return h==null||h.forEach(p=>{p.type==="candidate-pair"&&p.nominated&&(f.rtt=p.currentRoundTripTime*1e3)}),yield this.disconnect(),f})}}const Co=1e4;class yS extends tn{get description(){return"Connection via UDP vs TCP"}perform(){return y(this,void 0,void 0,function*(){const e=yield this.checkConnectionProtocol("udp"),t=yield this.checkConnectionProtocol("tcp");this.bestStats=e,e.qualityLimitationDurations.bandwidth-t.qualityLimitationDurations.bandwidth>.5||(e.packetsLost-t.packetsLost)/e.packetsSent>.01?(this.appendMessage("best connection quality via tcp"),this.bestStats=t):this.appendMessage("best connection quality via udp");const i=this.bestStats;this.appendMessage("upstream bitrate: ".concat((i.bitrateTotal/i.count/1e3/1e3).toFixed(2)," mbps")),this.appendMessage("RTT: ".concat((i.rttTotal/i.count*1e3).toFixed(2)," ms")),this.appendMessage("jitter: ".concat((i.jitterTotal/i.count*1e3).toFixed(2)," ms")),i.packetsLost>0&&this.appendWarning("packets lost: ".concat((i.packetsLost/i.packetsSent*100).toFixed(2),"%")),i.qualityLimitationDurations.bandwidth>1&&this.appendWarning("bandwidth limited ".concat((i.qualityLimitationDurations.bandwidth/(Co/1e3)*100).toFixed(2),"%")),i.qualityLimitationDurations.cpu>0&&this.appendWarning("cpu limited ".concat((i.qualityLimitationDurations.cpu/(Co/1e3)*100).toFixed(2),"%"))})}getInfo(){const e=super.getInfo();return e.data=this.bestStats,e}checkConnectionProtocol(e){return y(this,void 0,void 0,function*(){yield this.connect(),e==="tcp"?yield this.switchProtocol("tcp"):yield this.switchProtocol("udp");const t=document.createElement("canvas");t.width=1280,t.height=720;const i=t.getContext("2d");if(!i)throw new Error("Could not get canvas context");let r=0;const s=()=>{r=(r+1)%360,i.fillStyle="hsl(".concat(r,", 100%, 50%)"),i.fillRect(0,0,t.width,t.height),requestAnimationFrame(s)};s();const o=t.captureStream(30).getVideoTracks()[0],l=(yield this.room.localParticipant.publishTrack(o,{simulcast:!1,degradationPreference:"maintain-resolution",videoEncoding:{maxBitrate:2e6}})).track,u={protocol:e,packetsLost:0,packetsSent:0,qualityLimitationDurations:{},rttTotal:0,jitterTotal:0,bitrateTotal:0,count:0},d=setInterval(()=>y(this,void 0,void 0,function*(){const h=yield l.getRTCStatsReport();h==null||h.forEach(f=>{f.type==="outbound-rtp"?(u.packetsSent=f.packetsSent,u.qualityLimitationDurations=f.qualityLimitationDurations,u.bitrateTotal+=f.targetBitrate,u.count++):f.type==="remote-inbound-rtp"&&(u.packetsLost=f.packetsLost,u.rttTotal+=f.roundTripTime,u.jitterTotal+=f.jitter)})}),1e3);return yield new Promise(h=>setTimeout(h,Co)),clearInterval(d),o.stop(),t.remove(),yield this.disconnect(),u})}}class kS extends tn{get description(){return"Can publish audio"}perform(){return y(this,void 0,void 0,function*(){var e;const t=yield this.connect(),i=yield hS();if(yield eh(i,1e3))throw new Error("unable to detect audio from microphone");this.appendMessage("detected audio from microphone"),t.localParticipant.publishTrack(i),yield new Promise(o=>setTimeout(o,3e3));const s=yield(e=i.sender)===null||e===void 0?void 0:e.getStats();if(!s)throw new Error("Could not get RTCStats");let a=0;if(s.forEach(o=>{o.type==="outbound-rtp"&&(o.kind==="audio"||!o.kind&&o.mediaType==="audio")&&(a=o.packetsSent)}),a===0)throw new Error("Could not determine packets are sent");this.appendMessage("published ".concat(a," audio packets"))})}}class TS extends tn{get description(){return"Can publish video"}perform(){return y(this,void 0,void 0,function*(){var e;const t=yield this.connect(),i=yield dS();yield this.checkForVideo(i.mediaStreamTrack),t.localParticipant.publishTrack(i),yield new Promise(a=>setTimeout(a,5e3));const r=yield(e=i.sender)===null||e===void 0?void 0:e.getStats();if(!r)throw new Error("Could not get RTCStats");let s=0;if(r.forEach(a=>{a.type==="outbound-rtp"&&(a.kind==="video"||!a.kind&&a.mediaType==="video")&&(s+=a.packetsSent)}),s===0)throw new Error("Could not determine packets are sent");this.appendMessage("published ".concat(s," video packets"))})}checkForVideo(e){return y(this,void 0,void 0,function*(){const t=new MediaStream;t.addTrack(e.clone());const i=document.createElement("video");i.srcObject=t,i.muted=!0,yield new Promise(r=>{i.onplay=()=>{setTimeout(()=>{var s,a,o,c;const l=document.createElement("canvas"),u=e.getSettings(),d=(a=(s=u.width)!==null&&s!==void 0?s:i.videoWidth)!==null&&a!==void 0?a:1280,h=(c=(o=u.height)!==null&&o!==void 0?o:i.videoHeight)!==null&&c!==void 0?c:720;l.width=d,l.height=h;const f=l.getContext("2d");f.drawImage(i,0,0);const g=f.getImageData(0,0,l.width,l.height).data;let v=!0;for(let b=0;b<g.length;b+=4)if(g[b]!==0||g[b+1]!==0||g[b+2]!==0){v=!1;break}v?this.appendError("camera appears to be producing only black frames"):this.appendMessage("received video frames"),r()},1e3)},i.play()}),i.remove()})}}class SS extends tn{get description(){return"Resuming connection after interruption"}perform(){return y(this,void 0,void 0,function*(){var e;const t=yield this.connect();let i=!1,r=!1,s;const a=new Promise(l=>{setTimeout(l,5e3),s=l}),o=()=>{i=!0};t.on(O.SignalReconnecting,o).on(O.Reconnecting,o).on(O.Reconnected,()=>{r=!0,s(!0)}),(e=t.engine.client.ws)===null||e===void 0||e.close();const c=t.engine.client.onClose;if(c&&c(""),yield a,i){if(!r||t.state!==J.Connected)throw this.appendWarning("reconnection is only possible in Redis-based configurations"),new Error("Not able to reconnect")}else throw new Error("Did not attempt to reconnect")})}}class CS extends tn{get description(){return"Can connect via TURN"}perform(){return y(this,void 0,void 0,function*(){var e,t;const i=new ro,r=yield i.join(this.url,this.token,{autoSubscribe:!0,maxRetries:0,e2eeEnabled:!1,websocketTimeout:15e3});let s=!1,a=!1,o=!1;for(let c of r.iceServers)for(let l of c.urls)l.startsWith("turn:")?(a=!0,o=!0):l.startsWith("turns:")&&(a=!0,o=!0,s=!0),l.startsWith("stun:")&&(o=!0);o?a&&!s&&this.appendWarning("TURN is configured server side, but TURN/TLS is unavailable."):this.appendWarning("No STUN servers configured on server side."),yield i.close(),!((t=(e=this.connectOptions)===null||e===void 0?void 0:e.rtcConfig)===null||t===void 0)&&t.iceServers||a?yield this.room.connect(this.url,this.token,{rtcConfig:{iceTransportPolicy:"relay"}}):(this.appendWarning("No TURN servers configured."),this.skip(),yield new Promise(c=>setTimeout(c,0)))})}}class xS extends tn{get description(){return"Establishing WebRTC connection"}perform(){return y(this,void 0,void 0,function*(){let e=!1,t=!1;this.room.on(O.SignalConnected,()=>{const i=this.room.engine.client.onTrickle;this.room.engine.client.onTrickle=(r,s)=>{if(r.candidate){const a=new RTCIceCandidate(r);let o="".concat(a.protocol," ").concat(a.address,":").concat(a.port," ").concat(a.type);a.address&&(wS(a.address)?o+=" (private)":a.protocol==="tcp"&&a.tcpType==="passive"?(e=!0,o+=" (passive)"):a.protocol==="udp"&&(t=!0)),this.appendMessage(o)}i&&i(r,s)},this.room.engine.pcManager&&(this.room.engine.pcManager.subscriber.onIceCandidateError=r=>{r instanceof RTCPeerConnectionIceErrorEvent&&this.appendWarning("error with ICE candidate: ".concat(r.errorCode," ").concat(r.errorText," ").concat(r.url))})});try{yield this.connect(),q.info("now the room is connected")}catch(i){throw this.appendWarning("ports need to be open on firewall in order to connect."),i}e||this.appendWarning("Server is not configured for ICE/TCP"),t||this.appendWarning("No public IPv4 UDP candidates were found. Your server is likely not configured correctly")})}}function wS(n){const e=n.split(".");if(e.length===4){if(e[0]==="10")return!0;if(e[0]==="192"&&e[1]==="168")return!0;if(e[0]==="172"){const t=parseInt(e[1],10);if(t>=16&&t<=31)return!0}}return!1}class _S extends tn{get description(){return"Connecting to signal connection via WebSocket"}perform(){return y(this,void 0,void 0,function*(){var e,t,i;(this.url.startsWith("ws:")||this.url.startsWith("http:"))&&this.appendWarning("Server is insecure, clients may block connections to it");let r=new ro;const s=yield r.join(this.url,this.token,{autoSubscribe:!0,maxRetries:0,e2eeEnabled:!1,websocketTimeout:15e3});this.appendMessage("Connected to server, version ".concat(s.serverVersion,".")),((e=s.serverInfo)===null||e===void 0?void 0:e.edition)===Nu.Cloud&&(!((t=s.serverInfo)===null||t===void 0)&&t.region)&&this.appendMessage("LiveKit Cloud: ".concat((i=s.serverInfo)===null||i===void 0?void 0:i.region)),yield r.close()})}}class cx extends Tt.EventEmitter{constructor(e,t){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};super(),this.options={},this.checkResults=new Map,this.url=e,this.token=t,this.options=i}getNextCheckId(){const e=this.checkResults.size;return this.checkResults.set(e,{logs:[],status:dt.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!==dt.FAILED)}getResults(){return Array.from(this.checkResults.values())}createAndRunCheck(e){return y(this,void 0,void 0,function*(){const t=this.getNextCheckId(),i=new e(this.url,this.token,this.options),r=a=>{this.updateCheck(t,a)};i.on("update",r);const s=yield i.run();return i.off("update",r),s})}checkWebsocket(){return y(this,void 0,void 0,function*(){return this.createAndRunCheck(_S)})}checkWebRTC(){return y(this,void 0,void 0,function*(){return this.createAndRunCheck(xS)})}checkTURN(){return y(this,void 0,void 0,function*(){return this.createAndRunCheck(CS)})}checkReconnect(){return y(this,void 0,void 0,function*(){return this.createAndRunCheck(SS)})}checkPublishAudio(){return y(this,void 0,void 0,function*(){return this.createAndRunCheck(kS)})}checkPublishVideo(){return y(this,void 0,void 0,function*(){return this.createAndRunCheck(TS)})}checkConnectionProtocol(){return y(this,void 0,void 0,function*(){const e=yield this.createAndRunCheck(yS);if(e.data&&"protocol"in e.data){const t=e.data;this.options.protocol=t.protocol}return e})}checkCloudRegion(){return y(this,void 0,void 0,function*(){return this.createAndRunCheck(bS)})}}const ES=/\{[^{}]+\}/g;function PS(){return Math.random().toString(36).slice(2,11)}function RS(n){let{baseUrl:e="",Request:t=globalThis.Request,fetch:i=globalThis.fetch,querySerializer:r,bodySerializer:s,headers:a,...o}={...n};e=Mh(e);const c=[];async function l(u,d){const{baseUrl:h,fetch:f=i,Request:p=t,headers:g,params:v={},parseAs:b="json",querySerializer:S,bodySerializer:x=s??OS,body:k,...T}=d||{};h&&(e=Mh(h));let C=typeof r=="function"?r:Nh(r);S&&(C=typeof S=="function"?S:Nh({...typeof r=="object"?r:{},...S}));const _=k===void 0?void 0:x(k),R=_===void 0||_ instanceof FormData?{}:{"Content-Type":"application/json"},I={redirect:"follow",...o,...T,body:_,headers:NS(R,a,g,v.header)};let D,U,V=new t(AS(u,{baseUrl:e,params:v,querySerializer:C}),I);for(const A in T)A in V||(V[A]=T[A]);if(c.length){D=PS(),U=Object.freeze({baseUrl:e,fetch:f,parseAs:b,querySerializer:C,bodySerializer:x});for(const A of c)if(A&&typeof A=="object"&&typeof A.onRequest=="function"){const j=await A.onRequest({request:V,schemaPath:u,params:v,options:U,id:D});if(j){if(!(j instanceof t))throw new Error("onRequest: must return new Request() when modifying the request");V=j}}}let G=await f(V);if(c.length)for(let A=c.length-1;A>=0;A--){const j=c[A];if(j&&typeof j=="object"&&typeof j.onResponse=="function"){const K=await j.onResponse({request:V,response:G,schemaPath:u,params:v,options:U,id:D});if(K){if(!(K instanceof Response))throw new Error("onResponse: must return new Response() when modifying the response");G=K}}}if(G.status===204||G.headers.get("Content-Length")==="0")return G.ok?{data:{},response:G}:{error:{},response:G};if(G.ok)return b==="stream"?{data:G.body,response:G}:{data:await G[b](),response:G};let z=await G.text();try{z=JSON.parse(z)}catch{}return{error:z,response:G}}return{GET(u,d){return l(u,{...d,method:"GET"})},PUT(u,d){return l(u,{...d,method:"PUT"})},POST(u,d){return l(u,{...d,method:"POST"})},DELETE(u,d){return l(u,{...d,method:"DELETE"})},OPTIONS(u,d){return l(u,{...d,method:"OPTIONS"})},HEAD(u,d){return l(u,{...d,method:"HEAD"})},PATCH(u,d){return l(u,{...d,method:"PATCH"})},TRACE(u,d){return l(u,{...d,method:"TRACE"})},use(...u){for(const d of u)if(d){if(typeof d!="object"||!("onRequest"in d||"onResponse"in d))throw new Error("Middleware must be an object with one of `onRequest()` or `onResponse()`");c.push(d)}},eject(...u){for(const d of u){const h=c.indexOf(d);h!==-1&&c.splice(h,1)}}}}function rs(n,e,t){if(e==null)return"";if(typeof e=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${n}=${(t==null?void 0:t.allowReserved)===!0?e:encodeURIComponent(e)}`}function Oh(n,e,t){if(!e||typeof e!="object")return"";const i=[],r={simple:",",label:".",matrix:";"}[t.style]||"&";if(t.style!=="deepObject"&&t.explode===!1){for(const o in e)i.push(o,t.allowReserved===!0?e[o]:encodeURIComponent(e[o]));const a=i.join(",");switch(t.style){case"form":return`${n}=${a}`;case"label":return`.${a}`;case"matrix":return`;${n}=${a}`;default:return a}}for(const a in e){const o=t.style==="deepObject"?`${n}[${a}]`:a;i.push(rs(o,e[a],t))}const s=i.join(r);return t.style==="label"||t.style==="matrix"?`${r}${s}`:s}function Ah(n,e,t){if(!Array.isArray(e))return"";if(t.explode===!1){const s={form:",",spaceDelimited:"%20",pipeDelimited:"|"}[t.style]||",",a=(t.allowReserved===!0?e:e.map(o=>encodeURIComponent(o))).join(s);switch(t.style){case"simple":return a;case"label":return`.${a}`;case"matrix":return`;${n}=${a}`;default:return`${n}=${a}`}}const i={simple:",",label:".",matrix:";"}[t.style]||"&",r=[];for(const s of e)t.style==="simple"||t.style==="label"?r.push(t.allowReserved===!0?s:encodeURIComponent(s)):r.push(rs(n,s,t));return t.style==="label"||t.style==="matrix"?`${i}${r.join(i)}`:r.join(i)}function Nh(n){return function(t){const i=[];if(t&&typeof t=="object")for(const r in t){const s=t[r];if(s!=null){if(Array.isArray(s)){if(s.length===0)continue;i.push(Ah(r,s,{style:"form",explode:!0,...n==null?void 0:n.array,allowReserved:(n==null?void 0:n.allowReserved)||!1}));continue}if(typeof s=="object"){i.push(Oh(r,s,{style:"deepObject",explode:!0,...n==null?void 0:n.object,allowReserved:(n==null?void 0:n.allowReserved)||!1}));continue}i.push(rs(r,s,n))}}return i.join("&")}}function IS(n,e){let t=n;for(const i of n.match(ES)??[]){let r=i.substring(1,i.length-1),s=!1,a="simple";if(r.endsWith("*")&&(s=!0,r=r.substring(0,r.length-1)),r.startsWith(".")?(a="label",r=r.substring(1)):r.startsWith(";")&&(a="matrix",r=r.substring(1)),!e||e[r]===void 0||e[r]===null)continue;const o=e[r];if(Array.isArray(o)){t=t.replace(i,Ah(r,o,{style:a,explode:s}));continue}if(typeof o=="object"){t=t.replace(i,Oh(r,o,{style:a,explode:s}));continue}if(a==="matrix"){t=t.replace(i,`;${rs(r,o)}`);continue}t=t.replace(i,a==="label"?`.${encodeURIComponent(o)}`:encodeURIComponent(o))}return t}function OS(n){return n instanceof FormData?n:JSON.stringify(n)}function AS(n,e){var r;let t=`${e.baseUrl}${n}`;(r=e.params)!=null&&r.path&&(t=IS(t,e.params.path));let i=e.querySerializer(e.params.query??{});return i.startsWith("?")&&(i=i.substring(1)),i&&(t+=`?${i}`),t}function NS(...n){const e=new Headers;for(const t of n){if(!t||typeof t!="object")continue;const i=t instanceof Headers?t.entries():Object.entries(t);for(const[r,s]of i)if(s===null)e.delete(r);else if(Array.isArray(s))for(const a of s)e.append(r,a);else s!==void 0&&e.set(r,s)}return e}function Mh(n){return n.endsWith("/")?n.substring(0,n.length-1):n}const Lh="Onboardee-Session-Token",Dh="OnboardeeSessionToken";class Uh{constructor(e){this.client=RS({baseUrl:e.baseUrl,headers:e.headers,fetch:e.fetch}),this.client.use({onRequest({request:t}){if(window.localStorage){const i=window.localStorage.getItem(Dh);i&&t.headers.set(Lh,i)}return t},onResponse({response:t}){const i=t.headers.get(Lh);return i&&window.localStorage&&window.localStorage.setItem(Dh,i),t}})}setAuthToken(e){this.client.use({onRequest({request:t}){return t.headers.set("Authorization",`Bearer ${e}`),t}})}setApiToken(e){this.client.use({onRequest({request:t}){return t.headers.set("Authorization",`Token ${e}`),t}})}async getAuthUrl(e){return await this.client.GET("/api/auth/{type}",{params:{path:{type:e}}})}async getConnectUrl(e){return await this.client.GET("/api/connect/{type}",{params:{path:{type:e}}})}async logout(){return await this.client.POST("/api/logout")}async getCurrentUser(){return await this.client.GET("/api/me")}async clientInitialise(e,t={}){return await this.client.POST("/api/client/{appToken}/initialise",{params:{path:{appToken:e}},body:t})}async clientStartSession(e,t){return await this.client.POST("/api/client/{appToken}/start-session",{params:{path:{appToken:e}},body:t})}async createPresignedUploadUrl(e){return await this.client.POST("/api/files",{body:e})}async createKnowledgeBlock(e){return await this.client.POST("/api/knowledge",{body:e})}async listOnboardees(){return await this.client.GET("/api/onboardees")}async getOnboardee(e){return await this.client.GET("/api/onboardees/{id}",{params:{path:{id:e}}})}async getOnboardeeWidgetConfig(e,t){return await this.client.GET("/api/onboardees/{id}/config",{params:{path:{id:e}},signal:t})}async listPlans(e){return await this.client.GET("/api/plans",{params:{query:{...e&&{client_type:e}}}})}async listPlansWithStatus(){return await this.client.GET("/api/plans-with-status")}async listProducts(){return await this.client.GET("/api/products")}async getProduct(e){return await this.client.GET("/api/products/{id}",{params:{path:{id:e}}})}async getProductAnalytics(e,t,i,r){return await this.client.GET("/api/products/{id}/analytics",{params:{path:{id:e},query:{...t&&{start_date:t},...i&&{end_date:i},...r&&{course_id:r}}}})}async createProduct(e){return await this.client.POST("/api/products",{body:e})}async updateProduct(e,t){return await this.client.PATCH("/api/products/{id}",{params:{path:{id:e}},body:t})}async getProductNavigationIndex(e){return await this.client.GET("/api/products/{id}/navigation-index",{params:{path:{id:e}}})}async replaceProductNavigationIndex(e,t){return await this.client.PUT("/api/products/{id}/navigation-index",{params:{path:{id:e}},body:{content:t.content||""}})}async listProductKnowledgeBlocks(e){return await this.client.GET("/api/products/{id}/knowledge-blocks",{params:{path:{id:e}}})}async createProductKnowledgeBlock(e,t){return await this.client.POST("/api/products/{id}/knowledge-blocks",{params:{path:{id:e}},body:t})}async searchProductKnowledgeBlocks(e,t,i){return await this.client.GET("/api/products/{id}/knowledge-blocks/search",{params:{path:{id:e},query:{q:t,...i&&{limit:i.toString()}}}})}async updateProductKnowledgeBlock(e,t,i){return await this.client.PATCH("/api/products/{id}/knowledge-blocks/{blockId}",{params:{path:{id:e,blockId:t}},body:i})}async deleteProductKnowledgeBlock(e,t){return await this.client.DELETE("/api/products/{id}/knowledge-blocks/{blockId}",{params:{path:{id:e,blockId:t}}})}async createPlan(e){return await this.client.POST("/api/plans",{body:e})}async getPlan(e){return await this.client.GET("/api/plans/{id}",{params:{path:{id:e}}})}async getAdminPlan(e){return await this.client.GET("/api/admin/plans/{id}",{params:{path:{id:e}}})}async getPlanAnalytics(e,t,i){return await this.client.GET("/api/plans/{id}/analytics",{params:{path:{id:e},query:{...t&&{start_date:t},...i&&{end_date:i}}}})}async replacePlan(e,t){return await this.client.PUT("/api/plans/{id}",{params:{path:{id:e}},body:t})}async updatePlan(e,t){return await this.client.PATCH("/api/plans/{id}",{params:{path:{id:e}},body:t})}async getPlanVideoUrl(e){return await this.client.GET("/api/plans/{id}/video-url",{params:{path:{id:e}}})}async getPlanVideoMetadata(e){return await this.client.GET("/api/plans/{id}/video-metadata",{params:{path:{id:e}}})}async deletePlan(e){return await this.client.DELETE("/api/admin/plans/{id}",{params:{path:{id:e}}})}async publishPlanRevision(e,t){return await this.client.POST("/api/plans/{id}/publish",{params:{path:{id:e}},body:t})}async listPlanRevisions(e){return await this.client.GET("/api/plans/{id}/revisions",{params:{path:{id:e}}})}async listPlanKnowledgeBlocks(e){return await this.client.GET("/api/plans/{id}/knowledge-blocks",{params:{path:{id:e}}})}async createPlanKnowledgeBlock(e,t){return await this.client.POST("/api/plans/{id}/knowledge-blocks",{params:{path:{id:e}},body:t})}async updatePlanKnowledgeBlock(e,t,i){return await this.client.PUT("/api/plans/{id}/knowledge-blocks/{blockId}",{params:{path:{id:e,blockId:t}},body:i})}async deletePlanKnowledgeBlock(e,t){return await this.client.DELETE("/api/plans/{id}/knowledge-blocks/{blockId}",{params:{path:{id:e,blockId:t}}})}async getPlanNavigationIndex(e){return await this.client.GET("/api/plans/{id}/navigation-index",{params:{path:{id:e}}})}async replacePlanNavigationIndex(e,t){return await this.client.POST("/api/plans/{id}/navigation-index",{params:{path:{id:e}},body:{content:t.content||""}})}async getRevisionNavigationIndex(e){return await this.client.GET("/api/revisions/{id}/navigation-index",{params:{path:{id:e}}})}async replaceRevisionNavigationIndex(e,t){return await this.client.PUT("/api/revisions/{id}/navigation-index",{params:{path:{id:e}},body:t})}async getPlanFAQ(e){return await this.client.GET("/api/plans/{id}/faq",{params:{path:{id:e}}})}async getRevisionFAQ(e){return await this.client.GET("/api/revisions/{id}/faq",{params:{path:{id:e}}})}async replaceRevisionFAQ(e,t){return await this.client.PUT("/api/revisions/{id}/faq",{params:{path:{id:e}},body:t})}async listRevisionKnowledgeBlocks(e){return await this.client.GET("/api/revisions/{id}/knowledge-blocks",{params:{path:{id:e}}})}async getRevisionSteps(e){return await this.client.GET("/api/revisions/{id}/steps",{params:{path:{id:e}}})}async replaceRevisionKnowledgeBlocks(e,t){return await this.client.PUT("/api/revisions/{id}/knowledge-blocks",{params:{path:{id:e}},body:t})}async createRevisionKnowledgeBlock(e,t){return await this.client.POST("/api/revisions/{id}/knowledge-blocks",{params:{path:{id:e}},body:t})}async updateRevisionKnowledgeBlock(e,t,i){return await this.client.PUT("/api/revisions/{id}/knowledge-blocks/{blockId}",{params:{path:{id:e,blockId:t}},body:i})}async deleteRevisionKnowledgeBlock(e,t){return await this.client.DELETE("/api/revisions/{id}/knowledge-blocks/{blockId}",{params:{path:{id:e,blockId:t}}})}async listSessions(e,t){const i={token:e};return t!=null&&t.productId&&(i.product_id=t.productId),t!=null&&t.startDate&&(i.start_date=t.startDate),t!=null&&t.endDate&&(i.end_date=t.endDate),await this.client.GET("/api/sessions",{params:{query:i}})}async createSession(e){return await this.client.POST("/api/sessions",{body:e})}async getSession(e){return await this.client.GET("/api/sessions/{id}",{params:{path:{id:e}}})}async startSession(e,t){return await this.client.GET("/api/sessions/{id}/start-session",{params:{path:{id:e},query:{token:t}}})}async getSessionRecording(e){return await this.client.GET("/api/sessions/{id}/recording",{params:{path:{id:e}}})}async getSessionSummary(e){return await this.client.GET("/api/sessions/{id}/summary",{params:{path:{id:e}}})}async getSessionProductUrl(e){return await this.client.GET("/api/sessions/{id}/product-url",{params:{path:{id:e}}})}async updateSession(e,t){return await this.client.PATCH("/api/sessions/{id}",{params:{path:{id:e}},body:t})}async listUserSessions(e){const t={};return e!=null&&e.productId&&(t.product_id=e.productId),e!=null&&e.courseId&&(t.course_id=e.courseId),e!=null&&e.startDate&&(t.start_date=e.startDate),e!=null&&e.endDate&&(t.end_date=e.endDate),e!=null&&e.page&&(t.page=e.page),e!=null&&e.limit&&(t.limit=e.limit),e!=null&&e.courseName&&(t.course_name=e.courseName),e!=null&&e.userName&&(t.user_name=e.userName),e!=null&&e.company&&(t.company=e.company),e!=null&&e.email&&(t.email=e.email),e!=null&&e.sortBy&&(t.sort_by=e.sortBy),e!=null&&e.sortOrder&&(t.sort_order=e.sortOrder),await this.client.GET("/api/user-sessions",{params:Object.keys(t).length>0?{query:t}:void 0})}async listUserSessionsAggregate(e){const t={};return e!=null&&e.productId&&(t.product_id=e.productId),e!=null&&e.courseId&&(t.course_id=e.courseId),e!=null&&e.startDate&&(t.start_date=e.startDate),e!=null&&e.endDate&&(t.end_date=e.endDate),await this.client.GET("/api/user-sessions-aggregate",{params:Object.keys(t).length>0?{query:t}:void 0})}async getJoinToken(e,{clientType:t,user:i}={}){return await this.client.GET("/api/join-token",{params:{query:{token:e,...t&&{client_type:t},...i&&{user:encodeURIComponent(i)}}}})}async getSessionPlan(e){return await this.client.GET("/api/sessions/{id}/plan",{params:{path:{id:e}}})}async getPlanSDK(e){return await this.client.GET("/api/plans/{uuid}/sdk",{params:{path:{uuid:e}}})}async getGraphemes(){return await this.client.GET("/api/graphemes")}async listVoices(){return await this.client.GET("/api/voices")}async generateVoiceSample(e,t){return await this.client.POST("/api/voices/generate-sample",{body:{product_id:t,voice_id:e},parseAs:"stream"})}getClient(){return this.client}}const Bh="https://app.coragents.ai";class ss extends Cs{constructor(e,t,i,r){super(),this.state=null,this.isPaused=!1,this.speakingState=null,this.captureScreen=null,this.sessionUuid=null,this.roomId=null,this.joinToken=null,this.roomUrl=null,this.room=null,this.startedAt=null,this.agentAnalyser=null,this.userAnalyser=null,this.appToken=e,this.planId=t,this.clientType=i,this.api=r.api||new Uh({baseUrl:Bh}),this.identity=r.identity||null,this.roomFactory=r.roomFactory||(s=>new Kn(s)),this.captureScreen=r.captureScreen||null}async start(){this.planId,this.setState("connecting"),this.speakingStateChanged("thinking");try{const t=(await this.api.clientStartSession(this.appToken,{client_type:this.clientType,onboarding_plan:this.planId})).data;if(!(t!=null&&t.url)||!(t!=null&&t.token)||!(t!=null&&t.room)||!(t!=null&&t.session_uuid))throw new Error("Invalid room info");this.sessionUuid=t==null?void 0:t.session_uuid,this.roomId=t==null?void 0:t.room,this.joinToken=t==null?void 0:t.token,this.roomUrl=t==null?void 0:t.url,this.startedAt=Date.now(),await this.joinRoom(),this.setState("connected"),this.planId,this.sessionUuid}catch(e){console.error("[obi] error starting session",{error:e}),this.setState("error")}}async joinRoom({withMicrophone:e=!1,withStateRecovery:t=!1}={}){this.room=this.roomFactory({adaptiveStream:!0,dynacast:!0}),this.room.on(O.Disconnected,i=>{if(!this.room)return;let r=null;switch(i){case 12:r="invalid-room";break}this.shutdown(r)}),this.room.on(O.TrackSubscribed,i=>{i.kind==="audio"&&(i.attach(),i.source===P.Source.Microphone&&(this.agentAnalyser&&this.agentAnalyser.disconnect(),this.agentAnalyser=this.createFFT(i.mediaStream)))}),this.room.on(O.LocalTrackPublished,i=>{i.kind==="audio"&&(this.userAnalyser&&this.userAnalyser.disconnect(),this.userAnalyser=this.createFFT(i.audioTrack.mediaStream))}),this.room.on(O.ParticipantAttributesChanged,i=>{if(!i["lk.agent.state"])return;const r=i["lk.agent.state"];switch(r){case"speaking":this.speakingStateChanged("speaking");break;case"listening":this.state!=="connected"&&this.speakingStateChanged("listening");break;case"thinking":this.speakingStateChanged("thinking");break;default:console.warn("[obi] unknown speaking state",r)}}),this.room.on(O.DataReceived,async i=>{try{const r=new TextDecoder().decode(i),s=JSON.parse(r);switch(s.status||s.request||s.type){case"course_progress":typeof s.current_step=="number"&&typeof s.total_steps=="number"&&Array.isArray(s.step_names)&&this.emit("courseProgress",{currentStep:Math.max(1,s.current_step),totalSteps:Math.max(1,s.total_steps),stepNames:s.step_names});break;case"using_tool":this.speakingStateChanged("busy");break;case"using_tool_ended":this.speakingStateChanged("speaking");break;case"prompt_user":this.setState("volume-check");break;case"mic_check":this.setState("mic-check");break;case"share_mic":this.setState("mic-share");break;case"share_screen":this.setState("screen-share");break;case"navigate":this.setState("navigate");break;case"shutdown":this.shutdown("server-sent");break;case"transcript":this.emit("transcript",s.transcript,s.role);break;default:console.warn("[obi] unknown data received",s)}}catch(r){console.error("[obi] error parsing data",r)}}),this.room.localParticipant.registerRpcMethod("mic_check",async i=>(this.sessionUuid,await this.checkMicrophone()?"ok":"error")),this.room.localParticipant.registerRpcMethod("screen_capture",async i=>{if(!this.captureScreen)return console.error("[obi] no captureScreen function provided"),"error";let r=null,s=null;try{r=await this.captureScreen()}catch(a){r=null,a=a}if(!r||s)return console.error("[obi] error capturing screen",{error:s}),"error";try{return await this.room.localParticipant.sendFile(new File([r],"screen_capture.png",{type:"image/png"}),{mimeType:"image/png",topic:"screen_capture"}),"ok"}catch(a){return console.error("[obi] error sending screen capture",{error:a}),"error"}}),await this.room.connect(this.roomUrl,this.joinToken);for(let i=0;i<9&&!(this.room.state===J.Connected&&this.room.remoteParticipants.size>=1);i++)await new Promise(r=>setTimeout(r,1e3));if(!(this.room.state===J.Connected&&this.room.remoteParticipants.size>=1)){console.error("[obi] room not connected",{state:this.room.state,numParticipants:this.room.remoteParticipants.size}),this.shutdown("invalid-room");return}if(e&&await this.room.localParticipant.setMicrophoneEnabled(!0),t){let i=!1;for(const r of this.room.remoteParticipants.values())r.isSpeaking&&(i=!0);i?this.speakingState="speaking":this.speakingState="listening"}}async continue(){this.sessionUuid,this.speakingStateChanged("thinking"),await this.sendData({request:"prompt_user",success:!0})}async checkMicrophone(){let e=!1;try{e=(await navigator.permissions.query({name:"microphone"})).state==="granted"}catch(t){console.error("[obi] error checking microphone permission:",t)}return e?(this.sessionUuid,await this.room.localParticipant.setMicrophoneEnabled(!0),this.isMicShared=!0):this.sessionUuid,e&&this.clientType==="sdk"&&this.setState("in-progress"),this.emit("micCheckComplete",e),e}async shareMicrophone(){this.sessionUuid,this.speakingStateChanged("thinking");let e=null,t=null;try{e=await this.room.localParticipant.setMicrophoneEnabled(!0),this.isMicShared=!0}catch(i){i=i,this.isMicShared=!1}e?this.sessionUuid:console.error("[obi] failed to share microphone",{error:t}),await this.sendData({request:"share_mic",success:!!e}),this.clientType==="sdk"&&this.setState("in-progress")}async shareMicrophoneFailed(){this.isMicShared=!1,await this.sendData({request:"share_mic",success:!1}),this.clientType==="sdk"&&this.setState("in-progress")}async shareScreen(){this.sessionUuid,this.speakingStateChanged("thinking"),await this.room.localParticipant.setScreenShareEnabled(!0,{video:{displaySurface:"window"}}),await this.sendData({request:"share_screen",success:!0}),this.setState("navigate")}async pause(){this.muteMicrophone(),this.isPaused=!0,this.emit("paused"),await this.sendData({request:"pause"}),console.log("[obi] paused session",{sessionUuid:this.sessionUuid})}async unpause(){this.unmuteMicrophone(),this.isPaused=!1,this.emit("unpaused"),await this.sendData({request:"unpause"}),console.log("[obi] unpaused session",{sessionUuid:this.sessionUuid})}muteMicrophone(){this.sessionUuid,this.room.localParticipant.getTrackPublications().forEach(e=>{var t,i;e.handleMuted(),(i=(t=e.track)==null?void 0:t.mediaStream)==null||i.getTracks().forEach(r=>r.enabled=!1)})}unmuteMicrophone(){this.sessionUuid,this.room.localParticipant.getTrackPublications().forEach(e=>{var t,i;e.handleUnmuted(),(i=(t=e.track)==null?void 0:t.mediaStream)==null||i.getTracks().forEach(r=>r.enabled=!0)})}async stop(){this.emit("stopped"),await this.shutdown()}async shutdown(e=null){if(this.room){this.sessionUuid,e!=="server-sent"&&await this.sendData({request:"shutdown"});const t=this.room;this.room=null,await t.disconnect(),this.sessionUuid}this.sessionUuid=null,this.roomId=null,this.joinToken=null,this.roomUrl=null,this.emit("shutdown",e)}async say(e){this.speakingStateChanged("thinking"),this.isPaused&&await this.unpause(),await this.sendData({request:"say",message:e})}serialise(){return JSON.stringify({state:this.state,speakingState:this.speakingState,appToken:this.appToken,planId:this.planId,clientType:this.clientType,isPaused:this.isPaused,identity:this.identity,sessionUuid:this.sessionUuid,roomId:this.roomId,joinToken:this.joinToken,roomUrl:this.roomUrl,startedAt:this.startedAt})}audioSpectrum(){return this.speakingState==="speaking"&&this.agentAnalyser?this.normaliseSpectrum(this.agentAnalyser):this.speakingState==="listening"&&this.userAnalyser?this.normaliseSpectrum(this.userAnalyser):null}normaliseSpectrum(e){const i=e.context.sampleRate/2/e.frequencyBinCount,r=new Uint8Array(e.frequencyBinCount);e.getByteFrequencyData(r);const s=[],a=50,o=5e3,c=8,l=Math.pow(o/a,1/c);for(let u=0;u<c;u++){const d=a*Math.pow(l,u),h=a*Math.pow(l,u+1),f=Math.floor(d/i),p=Math.floor(h/i),g=Math.min(p,r.length),v=Math.min(f,g);if(v<g){const b=r.slice(v,g).reduce((S,x)=>S+x,0)/(g-v)/255;s.push(b)}else s.push(0)}return s}setState(e){this.state;const t=this.state;this.state=e,this.emit("stateChanged",e,t)}static deserialise(e,t,i,r={}){const s=JSON.parse(e),a=new ss(t,s.planId,i,r);return a.state=s.state,a.speakingState=s.speakingState,a.identity=s.identity||null,a.isPaused=s.isPaused||!1,a.sessionUuid=s.sessionUuid||null,a.roomId=s.roomId||null,a.joinToken=s.joinToken||null,a.roomUrl=s.roomUrl||null,a.startedAt=s.startedAt||null,a}speakingStateChanged(e){this.speakingState;const t=this.speakingState;this.speakingState=e,this.emit("speakingStateChanged",e,t)}async sendData(e){await this.room.localParticipant.publishData(new TextEncoder().encode(JSON.stringify(e)),{reliable:!0})}createFFT(e){const t=new AudioContext,i=t.createAnalyser();return t.createMediaStreamSource(e).connect(i),i.fftSize=2048,i.smoothingTimeConstant=.6,i}}class as extends Cs{constructor(e,t,i={}){super(),this.state="loading",this.error=null,this.identity=null,this.product=null,this.plans=[],this.planIsCompleted=[],this.selectedPlan=null,this.selectedPlanUuid=null,this.showWidget=!1,this.session=null,this.captureScreen=null,this.appToken=e,this.clientType=t,this.api=i.api||new Uh({baseUrl:i.apiBaseUrl||Bh}),this.sessionFactory=i.sessionFactory||((r,s,a,o)=>new ss(r,s,a,o)),this.captureScreen=i.captureScreen||null}async initialise(e={}){var t,i,r,s,a;if(!this.appToken)throw new Error("App token is required");this.setState("loading");try{const o=await this.api.clientInitialise(this.appToken,{identity:e.identity,client_type:this.clientType});if(this.identity=e.identity||null,this.product=((t=o.data)==null?void 0:t.product)||null,this.plans=((i=o.data)==null?void 0:i.onboarding_plans)||[],this.selectedPlan=((r=o.data)==null?void 0:r.selected_plan)||null,this.planIsCompleted=((s=o.data)==null?void 0:s.plan_is_completed)||[],this.showWidget=((a=o.data)==null?void 0:a.show_widget)||!1,e.planUuid){let c=null;try{const l=await this.api.getPlanSDK(e.planUuid);if(l.error)throw new Error(`Plan not found: ${l.error}`);l.data&&(c=l.data)}catch(l){try{const u=await this.api.getSessionPlan(e.planUuid);if(u.error)throw new Error(`Session plan not found: ${u.error}`);u.data&&(c=u.data)}catch(u){console.error("[obi] error getting plan via both endpoints",{planErr:l,sessionErr:u})}}c?(this.selectedPlan=c,this.selectedPlanUuid=e.planUuid):console.warn("[obi] plan not found",{planUuid:e.planUuid})}this.identity,this.product,this.plans,this.selectedPlan,this.showWidget}catch(o){throw this.error=o instanceof Error?o:new Error(String(o)),this.setState("error"),o}finally{this.setState("ready")}}selectPlan(e){this.selectedPlan=e,this.selectedPlanUuid=(e==null?void 0:e.uuid)||null,this.emit("planSelected",e)}async startSession(e,t){return await this._stopSession(),this.session=this.sessionFactory(this.appToken,e,this.clientType,{api:this.api,identity:this.identity,captureScreen:this.captureScreen}),this.prepareSession(t),this.session.start().then(()=>{this.emit("sessionStarted",this.session)}).catch(i=>{this.session=null,console.error("[obi] error starting session",i)}),this.session}async resumeSession(e){var t,i;return this.state,(t=this.session)==null||t.state,(i=this.session)==null||i.speakingState,this.session.captureScreen=this.captureScreen,this.prepareSession(e),this.session.joinRoom({withMicrophone:!0,withStateRecovery:!0}).then(()=>{this.emit("sessionResumed",this.session)}).catch(r=>{console.error("[obi] error joining room",{error:r}),r instanceof Error&&r.message==="Room is not connected"&&this.session.stop()}),this.session}prepareSession(e){if(!this.session)throw new Error("No session to prepare");return e(this.session),this.session.on("stopped",()=>{this.emit("sessionStopped")}),this.session.on("shutdown",t=>{var i,r,s;if((i=this.session)!=null&&i.startedAt&&this.session.startedAt+5*60*1e3<Date.now()){const a=this.plans.findIndex(o=>{var c;return o.uuid===((c=this.selectedPlan)==null?void 0:c.uuid)});a!==-1&&(this.planIsCompleted[a]=!0)}(s=(r=this.session)==null?void 0:r.removeAllListeners)==null||s.call(r),this.session=null,this.selectedPlan=null,this.selectedPlanUuid=null,this.emit("sessionShutdown",t)}),this.session}async stopSession(){await this._stopSession(),this.selectedPlan&&this.selectPlan(null)}async _stopSession(){this.session&&(this.trackEvent("session-stopped",{sessionUuid:this.session.sessionUuid}),await this.session.stop(),this.session=null)}isLoading(){return this.state==="loading"}isReady(){return this.state==="ready"}serialise(){var e;return JSON.stringify({state:this.state,appToken:this.appToken,clientType:this.clientType,identity:this.identity,product:this.product,plans:this.plans,selectedPlan:this.selectedPlan,selectedPlanUuid:this.selectedPlanUuid,showWidget:this.showWidget,session:(e=this.session)==null?void 0:e.serialise(),serialisedAt:new Date().toISOString()})}static deserialise(e,t,i,r={}){const s=JSON.parse(e);if(s.serialisedAt){const o=new Date(s.serialisedAt);if(new Date().getTime()-o.getTime()>1e3*20)return null}else throw new Error("Client was not serialised, assuming it's dead.");const a=new as(t,i,r);return a.state=s.state,a.identity=s.identity||null,a.product=s.product||null,a.plans=s.plans||[],a.selectedPlan=s.selectedPlan||null,a.selectedPlanUuid=s.selectedPlanUuid||null,a.showWidget=s.showWidget||!1,s.session&&(a.session=ss.deserialise(s.session,t,i,{api:a.api})),a}setState(e){const t=this.state;this.state=e,this.emit("stateChanged",e,t)}trackEvent(e,t={}){var i,r,s;this.emit("trackEvent",e,{...t,clientType:this.clientType,planId:(i=this.selectedPlan)==null?void 0:i.uuid,productId:(r=this.product)==null?void 0:r.uuid,sessionId:(s=this.session)==null?void 0:s.sessionUuid})}}var os,W,Fh,vn,jh,Vh,Gh,Wh,xo,wo,_o,zh,Ci={},Hh=[],MS=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,xi=Array.isArray;function Ot(n,e){for(var t in e)n[t]=e[t];return n}function Eo(n){n&&n.parentNode&&n.parentNode.removeChild(n)}function Po(n,e,t){var i,r,s,a={};for(s in e)s=="key"?i=e[s]:s=="ref"?r=e[s]:a[s]=e[s];if(arguments.length>2&&(a.children=arguments.length>3?os.call(arguments,2):t),typeof n=="function"&&n.defaultProps!=null)for(s in n.defaultProps)a[s]==null&&(a[s]=n.defaultProps[s]);return cs(n,a,i,r,null)}function cs(n,e,t,i,r){var s={type:n,props:e,key:t,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++Fh,__i:-1,__u:0};return r==null&&W.vnode!=null&&W.vnode(s),s}function Ne(n){return n.children}function At(n,e){this.props=n,this.context=e}function $n(n,e){if(e==null)return n.__?$n(n.__,n.__i+1):null;for(var t;e<n.__k.length;e++)if((t=n.__k[e])!=null&&t.__e!=null)return t.__e;return typeof n.type=="function"?$n(n):null}function qh(n){var e,t;if((n=n.__)!=null&&n.__c!=null){for(n.__e=n.__c.base=null,e=0;e<n.__k.length;e++)if((t=n.__k[e])!=null&&t.__e!=null){n.__e=n.__c.base=t.__e;break}return qh(n)}}function Ro(n){(!n.__d&&(n.__d=!0)&&vn.push(n)&&!ls.__r++||jh!=W.debounceRendering)&&((jh=W.debounceRendering)||Vh)(ls)}function ls(){for(var n,e,t,i,r,s,a,o=1;vn.length;)vn.length>o&&vn.sort(Gh),n=vn.shift(),o=vn.length,n.__d&&(t=void 0,r=(i=(e=n).__v).__e,s=[],a=[],e.__P&&((t=Ot({},i)).__v=i.__v+1,W.vnode&&W.vnode(t),Io(e.__P,t,i,e.__n,e.__P.namespaceURI,32&i.__u?[r]:null,s,r??$n(i),!!(32&i.__u),a),t.__v=i.__v,t.__.__k[t.__i]=t,Jh(s,t,a),t.__e!=r&&qh(t)));ls.__r=0}function Kh(n,e,t,i,r,s,a,o,c,l,u){var d,h,f,p,g,v,b=i&&i.__k||Hh,S=e.length;for(c=LS(t,e,b,c,S),d=0;d<S;d++)(f=t.__k[d])!=null&&(h=f.__i==-1?Ci:b[f.__i]||Ci,f.__i=d,v=Io(n,f,h,r,s,a,o,c,l,u),p=f.__e,f.ref&&h.ref!=f.ref&&(h.ref&&Oo(h.ref,null,f),u.push(f.ref,f.__c||p,f)),g==null&&p!=null&&(g=p),4&f.__u||h.__k===f.__k?c=$h(f,c,n):typeof f.type=="function"&&v!==void 0?c=v:p&&(c=p.nextSibling),f.__u&=-7);return t.__e=g,c}function LS(n,e,t,i,r){var s,a,o,c,l,u=t.length,d=u,h=0;for(n.__k=new Array(r),s=0;s<r;s++)(a=e[s])!=null&&typeof a!="boolean"&&typeof a!="function"?(c=s+h,(a=n.__k[s]=typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?cs(null,a,null,null,null):xi(a)?cs(Ne,{children:a},null,null,null):a.constructor==null&&a.__b>0?cs(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a).__=n,a.__b=n.__b+1,o=null,(l=a.__i=DS(a,t,c,d))!=-1&&(d--,(o=t[l])&&(o.__u|=2)),o==null||o.__v==null?(l==-1&&(r>u?h--:r<u&&h++),typeof a.type!="function"&&(a.__u|=4)):l!=c&&(l==c-1?h--:l==c+1?h++:(l>c?h--:h++,a.__u|=4))):n.__k[s]=null;if(d)for(s=0;s<u;s++)(o=t[s])!=null&&!(2&o.__u)&&(o.__e==i&&(i=$n(o)),Zh(o,o));return i}function $h(n,e,t){var i,r;if(typeof n.type=="function"){for(i=n.__k,r=0;i&&r<i.length;r++)i[r]&&(i[r].__=n,e=$h(i[r],e,t));return e}n.__e!=e&&(e&&n.type&&!t.contains(e)&&(e=$n(n)),t.insertBefore(n.__e,e||null),e=n.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function us(n,e){return e=e||[],n==null||typeof n=="boolean"||(xi(n)?n.some(function(t){us(t,e)}):e.push(n)),e}function DS(n,e,t,i){var r,s,a=n.key,o=n.type,c=e[t];if(c===null&&n.key==null||c&&a==c.key&&o==c.type&&!(2&c.__u))return t;if(i>(c!=null&&!(2&c.__u)?1:0))for(r=t-1,s=t+1;r>=0||s<e.length;){if(r>=0){if((c=e[r])&&!(2&c.__u)&&a==c.key&&o==c.type)return r;r--}if(s<e.length){if((c=e[s])&&!(2&c.__u)&&a==c.key&&o==c.type)return s;s++}}return-1}function Yh(n,e,t){e[0]=="-"?n.setProperty(e,t??""):n[e]=t==null?"":typeof t!="number"||MS.test(e)?t:t+"px"}function ds(n,e,t,i,r){var s;e:if(e=="style")if(typeof t=="string")n.style.cssText=t;else{if(typeof i=="string"&&(n.style.cssText=i=""),i)for(e in i)t&&e in t||Yh(n.style,e,"");if(t)for(e in t)i&&t[e]==i[e]||Yh(n.style,e,t[e])}else if(e[0]=="o"&&e[1]=="n")s=e!=(e=e.replace(Wh,"$1")),e=e.toLowerCase()in n||e=="onFocusOut"||e=="onFocusIn"?e.toLowerCase().slice(2):e.slice(2),n.l||(n.l={}),n.l[e+s]=t,t?i?t.u=i.u:(t.u=xo,n.addEventListener(e,s?_o:wo,s)):n.removeEventListener(e,s?_o:wo,s);else{if(r=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in n)try{n[e]=t??"";break e}catch{}typeof t=="function"||(t==null||t===!1&&e[4]!="-"?n.removeAttribute(e):n.setAttribute(e,e=="popover"&&t==1?"":t))}}function Xh(n){return function(e){if(this.l){var t=this.l[e.type+n];if(e.t==null)e.t=xo++;else if(e.t<t.u)return;return t(W.event?W.event(e):e)}}}function Io(n,e,t,i,r,s,a,o,c,l){var u,d,h,f,p,g,v,b,S,x,k,T,C,_,R,I,D,U=e.type;if(e.constructor!=null)return null;128&t.__u&&(c=!!(32&t.__u),s=[o=e.__e=t.__e]),(u=W.__b)&&u(e);e:if(typeof U=="function")try{if(b=e.props,S="prototype"in U&&U.prototype.render,x=(u=U.contextType)&&i[u.__c],k=u?x?x.props.value:u.__:i,t.__c?v=(d=e.__c=t.__c).__=d.__E:(S?e.__c=d=new U(b,k):(e.__c=d=new At(b,k),d.constructor=U,d.render=BS),x&&x.sub(d),d.props=b,d.state||(d.state={}),d.context=k,d.__n=i,h=d.__d=!0,d.__h=[],d._sb=[]),S&&d.__s==null&&(d.__s=d.state),S&&U.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=Ot({},d.__s)),Ot(d.__s,U.getDerivedStateFromProps(b,d.__s))),f=d.props,p=d.state,d.__v=e,h)S&&U.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),S&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(S&&U.getDerivedStateFromProps==null&&b!==f&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(b,k),!d.__e&&d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(b,d.__s,k)===!1||e.__v==t.__v){for(e.__v!=t.__v&&(d.props=b,d.state=d.__s,d.__d=!1),e.__e=t.__e,e.__k=t.__k,e.__k.some(function(V){V&&(V.__=e)}),T=0;T<d._sb.length;T++)d.__h.push(d._sb[T]);d._sb=[],d.__h.length&&a.push(d);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(b,d.__s,k),S&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(f,p,g)})}if(d.context=k,d.props=b,d.__P=n,d.__e=!1,C=W.__r,_=0,S){for(d.state=d.__s,d.__d=!1,C&&C(e),u=d.render(d.props,d.state,d.context),R=0;R<d._sb.length;R++)d.__h.push(d._sb[R]);d._sb=[]}else do d.__d=!1,C&&C(e),u=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++_<25);d.state=d.__s,d.getChildContext!=null&&(i=Ot(Ot({},i),d.getChildContext())),S&&!h&&d.getSnapshotBeforeUpdate!=null&&(g=d.getSnapshotBeforeUpdate(f,p)),I=u,u!=null&&u.type===Ne&&u.key==null&&(I=Qh(u.props.children)),o=Kh(n,xi(I)?I:[I],e,t,i,r,s,a,o,c,l),d.base=e.__e,e.__u&=-161,d.__h.length&&a.push(d),v&&(d.__E=d.__=null)}catch(V){if(e.__v=null,c||s!=null)if(V.then){for(e.__u|=c?160:128;o&&o.nodeType==8&&o.nextSibling;)o=o.nextSibling;s[s.indexOf(o)]=null,e.__e=o}else for(D=s.length;D--;)Eo(s[D]);else e.__e=t.__e,e.__k=t.__k;W.__e(V,e,t)}else s==null&&e.__v==t.__v?(e.__k=t.__k,e.__e=t.__e):o=e.__e=US(t.__e,e,t,i,r,s,a,c,l);return(u=W.diffed)&&u(e),128&e.__u?void 0:o}function Jh(n,e,t){for(var i=0;i<t.length;i++)Oo(t[i],t[++i],t[++i]);W.__c&&W.__c(e,n),n.some(function(r){try{n=r.__h,r.__h=[],n.some(function(s){s.call(r)})}catch(s){W.__e(s,r.__v)}})}function Qh(n){return typeof n!="object"||n==null||n.__b&&n.__b>0?n:xi(n)?n.map(Qh):Ot({},n)}function US(n,e,t,i,r,s,a,o,c){var l,u,d,h,f,p,g,v=t.props,b=e.props,S=e.type;if(S=="svg"?r="http://www.w3.org/2000/svg":S=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),s!=null){for(l=0;l<s.length;l++)if((f=s[l])&&"setAttribute"in f==!!S&&(S?f.localName==S:f.nodeType==3)){n=f,s[l]=null;break}}if(n==null){if(S==null)return document.createTextNode(b);n=document.createElementNS(r,S,b.is&&b),o&&(W.__m&&W.__m(e,s),o=!1),s=null}if(S==null)v===b||o&&n.data==b||(n.data=b);else{if(s=s&&os.call(n.childNodes),v=t.props||Ci,!o&&s!=null)for(v={},l=0;l<n.attributes.length;l++)v[(f=n.attributes[l]).name]=f.value;for(l in v)if(f=v[l],l!="children"){if(l=="dangerouslySetInnerHTML")d=f;else if(!(l in b)){if(l=="value"&&"defaultValue"in b||l=="checked"&&"defaultChecked"in b)continue;ds(n,l,null,f,r)}}for(l in b)f=b[l],l=="children"?h=f:l=="dangerouslySetInnerHTML"?u=f:l=="value"?p=f:l=="checked"?g=f:o&&typeof f!="function"||v[l]===f||ds(n,l,f,v[l],r);if(u)o||d&&(u.__html==d.__html||u.__html==n.innerHTML)||(n.innerHTML=u.__html),e.__k=[];else if(d&&(n.innerHTML=""),Kh(e.type=="template"?n.content:n,xi(h)?h:[h],e,t,i,S=="foreignObject"?"http://www.w3.org/1999/xhtml":r,s,a,s?s[0]:t.__k&&$n(t,0),o,c),s!=null)for(l=s.length;l--;)Eo(s[l]);o||(l="value",S=="progress"&&p==null?n.removeAttribute("value"):p!=null&&(p!==n[l]||S=="progress"&&!p||S=="option"&&p!=v[l])&&ds(n,l,p,v[l],r),l="checked",g!=null&&g!=n[l]&&ds(n,l,g,v[l],r))}return n}function Oo(n,e,t){try{if(typeof n=="function"){var i=typeof n.__u=="function";i&&n.__u(),i&&e==null||(n.__u=n(e))}else n.current=e}catch(r){W.__e(r,t)}}function Zh(n,e,t){var i,r;if(W.unmount&&W.unmount(n),(i=n.ref)&&(i.current&&i.current!=n.__e||Oo(i,null,e)),(i=n.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(s){W.__e(s,e)}i.base=i.__P=null}if(i=n.__k)for(r=0;r<i.length;r++)i[r]&&Zh(i[r],e,t||typeof n.type!="function");t||Eo(n.__e),n.__c=n.__=n.__e=void 0}function BS(n,e,t){return this.constructor(n,t)}function FS(n,e,t){var i,r,s,a;e==document&&(e=document.documentElement),W.__&&W.__(n,e),r=(i=typeof t=="function")?null:t&&t.__k||e.__k,s=[],a=[],Io(e,n=(!i&&t||e).__k=Po(Ne,null,[n]),r||Ci,Ci,e.namespaceURI,!i&&t?[t]:r?null:e.firstChild?os.call(e.childNodes):null,s,!i&&t?t:r?r.__e:e.firstChild,i,a),Jh(s,n,a)}function jS(n){function e(t){var i,r;return this.getChildContext||(i=new Set,(r={})[e.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){i=null},this.shouldComponentUpdate=function(s){this.props.value!=s.value&&i.forEach(function(a){a.__e=!0,Ro(a)})},this.sub=function(s){i.add(s);var a=s.componentWillUnmount;s.componentWillUnmount=function(){i&&i.delete(s),a&&a.call(s)}}),t.children}return e.__c="__cC"+zh++,e.__=n,e.Provider=e.__l=(e.Consumer=function(t,i){return t.children(i)}).contextType=e,e}os=Hh.slice,W={__e:function(n,e,t,i){for(var r,s,a;e=e.__;)if((r=e.__c)&&!r.__)try{if((s=r.constructor)&&s.getDerivedStateFromError!=null&&(r.setState(s.getDerivedStateFromError(n)),a=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(n,i||{}),a=r.__d),a)return r.__E=r}catch(o){n=o}throw n}},Fh=0,At.prototype.setState=function(n,e){var t;t=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Ot({},this.state),typeof n=="function"&&(n=n(Ot({},t),this.props)),n&&Ot(t,n),n!=null&&this.__v&&(e&&this._sb.push(e),Ro(this))},At.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),Ro(this))},At.prototype.render=Ne,vn=[],Vh=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Gh=function(n,e){return n.__v.__b-e.__v.__b},ls.__r=0,Wh=/(PointerCapture)$|Capture$/i,xo=0,wo=Xh(!1),_o=Xh(!0),zh=0;var VS=0;function m(n,e,t,i,r,s){e||(e={});var a,o,c=e;if("ref"in c)for(o in c={},e)o=="ref"?a=e[o]:c[o]=e[o];var l={type:n,props:c,key:t,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--VS,__i:-1,__u:0,__source:r,__self:s};if(typeof n=="function"&&(a=n.defaultProps))for(o in a)c[o]===void 0&&(c[o]=a[o]);return W.vnode&&W.vnode(l),l}var bn,ue,Ao,ef,wi=0,tf=[],be=W,nf=be.__b,rf=be.__r,sf=be.diffed,af=be.__c,of=be.unmount,cf=be.__;function _i(n,e){be.__h&&be.__h(ue,n,wi||e),wi=0;var t=ue.__H||(ue.__H={__:[],__h:[]});return n>=t.__.length&&t.__.push({}),t.__[n]}function Y(n){return wi=1,GS(df,n)}function GS(n,e,t){var i=_i(bn++,2);if(i.t=n,!i.__c&&(i.__=[t?t(e):df(void 0,e),function(o){var c=i.__N?i.__N[0]:i.__[0],l=i.t(c,o);c!==l&&(i.__N=[l,i.__[1]],i.__c.setState({}))}],i.__c=ue,!ue.__f)){var r=function(o,c,l){if(!i.__c.__H)return!0;var u=i.__c.__H.__.filter(function(h){return!!h.__c});if(u.every(function(h){return!h.__N}))return!s||s.call(this,o,c,l);var d=i.__c.props!==o;return u.forEach(function(h){if(h.__N){var f=h.__[0];h.__=h.__N,h.__N=void 0,f!==h.__[0]&&(d=!0)}}),s&&s.call(this,o,c,l)||d};ue.__f=!0;var s=ue.shouldComponentUpdate,a=ue.componentWillUpdate;ue.componentWillUpdate=function(o,c,l){if(this.__e){var u=s;s=void 0,r(o,c,l),s=u}a&&a.call(this,o,c,l)},ue.shouldComponentUpdate=r}return i.__N||i.__}function ze(n,e){var t=_i(bn++,3);!be.__s&&Lo(t.__H,e)&&(t.__=n,t.u=e,ue.__H.__h.push(t))}function hs(n,e){var t=_i(bn++,4);!be.__s&&Lo(t.__H,e)&&(t.__=n,t.u=e,ue.__h.push(t))}function Ct(n){return wi=5,No(function(){return{current:n}},[])}function No(n,e){var t=_i(bn++,7);return Lo(t.__H,e)&&(t.__=n(),t.__H=e,t.__h=n),t.__}function WS(n,e){return wi=8,No(function(){return n},e)}function lf(n){var e=ue.context[n.__c],t=_i(bn++,9);return t.c=n,e?(t.__==null&&(t.__=!0,e.sub(ue)),e.props.value):n.__}function zS(){for(var n;n=tf.shift();)if(n.__P&&n.__H)try{n.__H.__h.forEach(fs),n.__H.__h.forEach(Mo),n.__H.__h=[]}catch(e){n.__H.__h=[],be.__e(e,n.__v)}}be.__b=function(n){ue=null,nf&&nf(n)},be.__=function(n,e){n&&e.__k&&e.__k.__m&&(n.__m=e.__k.__m),cf&&cf(n,e)},be.__r=function(n){rf&&rf(n),bn=0;var e=(ue=n.__c).__H;e&&(Ao===ue?(e.__h=[],ue.__h=[],e.__.forEach(function(t){t.__N&&(t.__=t.__N),t.u=t.__N=void 0})):(e.__h.forEach(fs),e.__h.forEach(Mo),e.__h=[],bn=0)),Ao=ue},be.diffed=function(n){sf&&sf(n);var e=n.__c;e&&e.__H&&(e.__H.__h.length&&(tf.push(e)!==1&&ef===be.requestAnimationFrame||((ef=be.requestAnimationFrame)||HS)(zS)),e.__H.__.forEach(function(t){t.u&&(t.__H=t.u),t.u=void 0})),Ao=ue=null},be.__c=function(n,e){e.some(function(t){try{t.__h.forEach(fs),t.__h=t.__h.filter(function(i){return!i.__||Mo(i)})}catch(i){e.some(function(r){r.__h&&(r.__h=[])}),e=[],be.__e(i,t.__v)}}),af&&af(n,e)},be.unmount=function(n){of&&of(n);var e,t=n.__c;t&&t.__H&&(t.__H.__.forEach(function(i){try{fs(i)}catch(r){e=r}}),t.__H=void 0,e&&be.__e(e,t.__v))};var uf=typeof requestAnimationFrame=="function";function HS(n){var e,t=function(){clearTimeout(i),uf&&cancelAnimationFrame(e),setTimeout(n)},i=setTimeout(t,100);uf&&(e=requestAnimationFrame(t))}function fs(n){var e=ue,t=n.__c;typeof t=="function"&&(n.__c=void 0,t()),ue=e}function Mo(n){var e=ue;n.__c=n.__(),ue=e}function Lo(n,e){return!n||n.length!==e.length||e.some(function(t,i){return t!==n[i]})}function df(n,e){return typeof e=="function"?e(n):e}function qS({size:n=24,color:e="#000"}){return m("svg",{xmlns:"http://www.w3.org/2000/svg",width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:e,"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-x-icon lucide-x",children:[m("path",{d:"M18 6 6 18"}),m("path",{d:"m6 6 12 12"})]})}function hf({onClose:n}){return m("button",{class:"obi-button obi-close-button",onClick:n,"aria-label":"Close",type:"button",children:m(qS,{})})}function ff({open:n=!1,children:e,onClose:t,size:i="medium"}){const r=Ct(null),s=Ct(null);ze(()=>{const l=r.current;l&&(n&&!l.open?l.showModal():!n&&l.open&&(s.current="programmatic",l.close()))},[n]);const a=l=>{const u=r.current;l.target===u&&(s.current="user-initiated",u==null||u.close())},o=l=>{l.preventDefault(),s.current||(s.current="user-initiated");const u=s.current;s.current=null,t==null||t(u)},c=()=>{var l;s.current="user-initiated",(l=r.current)==null||l.close()};return ze(()=>{const l=r.current;if(l)return l.addEventListener("click",a),l.addEventListener("close",o),()=>{l.removeEventListener("click",a),l.removeEventListener("close",o)}},[t]),m("dialog",{ref:r,className:`modal-${i}`,children:[m(hf,{onClose:c}),m("div",{class:"modal-content",children:n?typeof e=="function"?e():e:null})]})}function Do(n){const{children:e,className:t="",...i}=n;return m("div",{className:`${t} obi-panel`,...i,children:e})}function ps({className:n="",isActive:e=!1,speakingStatus:t,onClick:i,onMouseEnter:r,onMouseLeave:s,children:a}){let o=`obi-pill container ${e&&"active"}`;return t==="user-speaking"&&(o+=" user-speaking"),t==="busy"&&(o+=" busy"),m("div",{className:o,onMouseEnter:r,onMouseLeave:s,children:m("div",{className:`obi-pill pill ${n}`,onClick:i,children:a})})}function KS({className:n="",active:e,speakingStatus:t,onClick:i,onMouseEnter:r,onMouseLeave:s,children:a,...o}){const c=`obi-pill2 container ${e?"active":""} ${t==="user-speaking"?"user-speaking":""} ${n}`;return m("div",{className:c,...o,children:m("div",{className:"pill",onClick:i,onMouseEnter:r,onMouseLeave:s,children:a})})}function $S({className:n="",active:e,speakingStatus:t,onClick:i,onMouseEnter:r,onMouseLeave:s,children:a,...o}){const c=`obi-pill-up container ${e?"active":""} ${t==="user-speaking"?"user-speaking":""} ${n}`;return m("div",{className:c,...o,children:m("div",{className:"pill",onClick:i,onMouseEnter:r,onMouseLeave:s,children:a})})}function yn({type:n,size:e=24}){return m("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:YS(n)})}function YS(n){switch(n){case"pause":return m(Ne,{children:[m("rect",{x:"14",y:"3",width:"5",height:"18",rx:"1"}),m("rect",{x:"5",y:"3",width:"5",height:"18",rx:"1"})]});case"play":return m(Ne,{children:m("path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z"})});case"close":return m(Ne,{children:[m("path",{d:"M18 6 6 18"}),m("path",{d:"m6 6 12 12"})]});case"message":return m(Ne,{children:m("path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z"})});case"minimize":return m(Ne,{children:[m("path",{d:"m14 10 7-7"}),m("path",{d:"M20 10h-6V4"}),m("path",{d:"m3 21 7-7"}),m("path",{d:"M4 14h6v6"})]});case"voice":return m(Ne,{children:[m("path",{d:"M2 10v3"}),m("path",{d:"M6 6v11"}),m("path",{d:"M10 3v18"}),m("path",{d:"M14 8v7"}),m("path",{d:"M18 5v13"}),m("path",{d:"M22 10v3"})]});case"open":return m(Ne,{children:[m("path",{d:"M12 7v14"}),m("path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z"})]})}}const Uo=jS(null);function XS({children:n}){const e=lf(Uo);if(!e)throw new Error("PopoutTarget must be used within a Popout component");const{controlledOpen:t,isOpen:i,setIsOpen:r,setAnimating:s,targetRef:a,trigger:o,onChange:c,delayMs:l}=e,u=Ct(null),d=pf(a,s),[h,f]=Y(!1);ze(()=>{t!==void 0&&t!==h&&(t?g():v()),f(t)},[t]),ze(()=>()=>{u.current&&clearTimeout(u.current)},[]);function p(){u.current&&(clearTimeout(u.current),u.current=null)}function g(){p(),l>0?u.current=setTimeout(()=>{c==null||c(!0),r(!0),u.current=null},l):(c==null||c(!0),r(!0))}function v(){p(),c==null||c(!1),r(!1)}const b=()=>{o==="click"&&(i?v():g())};function S(){o==="hover"&&g()}function x(){o==="hover"&&v()}return m("div",{ref:d,class:"target",onClick:b,onMouseEnter:S,onMouseLeave:x,children:n})}function JS({children:n}){const e=lf(Uo);if(!e)throw new Error("PopoutContent must be used within a Popout component");const{isOpen:t,animating:i,setAnimating:r,targetRef:s,contentRef:a}=e,o=pf(a,r);return hs(()=>{if(t&&!i&&s.current&&a.current){const c=a.current;if(!c)return;const l=s.current;if(!l)return;const u=c.getBoundingClientRect(),d=l.getBoundingClientRect(),h=d.right-d.left;c.style.top=`${u.top-u.bottom-(8+e.offset)}px`,c.style.left=`${-(u.right-u.left-h)/2}px`}},[t,i]),t?m("div",{ref:o,class:"content",style:{opacity:i?0:1},children:n}):null}function He({trigger:n="click",open:e,onChange:t,children:i,delayMs:r=0,offset:s=0,className:a=""}){const[o,c]=Y(!1),[l,u]=Y(!1),d=Ct(null),h=Ct(null),f={controlledOpen:e,isOpen:o,setIsOpen:c,animating:l,setAnimating:u,targetRef:d,contentRef:h,trigger:n,onChange:t,delayMs:r,offset:s};return m(Uo.Provider,{value:f,children:m("div",{class:`obi-popout ${a}`,children:i})})}He.Target=XS,He.Content=JS;function pf(n,e){const t=Ct(null),i=Ct(null),r=Ct(!0),s=WS(a=>{if(n.current=a,!a){i.current&&(i.current.disconnect(),i.current=null),r.current=!0;return}function o(){if(r.current){r.current=!1;return}t.current?clearTimeout(t.current):e(!0),t.current=setTimeout(()=>{e(!1),t.current=null},200)}i.current=new ResizeObserver(o),i.current.observe(a,{box:"border-box"})},[]);return ze(()=>()=>{i.current&&(i.current.disconnect(),i.current=null)},[]),s}function ht({className:n,onClick:e,type:t,disabled:i,title:r}){const s={cancel:m(yn,{type:"close",size:16}),pause:m(yn,{type:"pause",size:16}),play:m(yn,{type:"play",size:16}),message:m(yn,{type:"message",size:16}),minimize:m(yn,{type:"minimize",size:16}),voice:m(yn,{type:"voice",size:16}),open:m(yn,{type:"open",size:16})}[t],a={cancel:"",pause:"",play:"",message:"",minimize:"",voice:"",open:""}[t],o=m("button",{class:`obi-button obi-round-button ${a} ${n}`,onClick:i?void 0:e,disabled:i,children:s});return r?m(He,{className:"obi-round-button-popout",trigger:"hover",delayMs:200,offset:9,children:[m(He.Target,{children:o}),m(He.Content,{children:m("div",{className:"obi-round-button-title",children:r})})]}):o}const mf=8,ms=8,QS=50,ZS=.7,Yn=3;function gf({getBands:n,color:e="white"}){const t=Ct(null);return ze(()=>{if(!n)return;const i=setInterval(()=>{try{const r=n();if(!t.current)return;const s=t.current.querySelectorAll(".bar"),a=r&&r.length>0?r.slice(0,ms).map(o=>{const c=Math.abs(o);return Math.min(c/ZS*mf,mf)||Yn}):Array(ms).fill(Yn);for(;a.length<ms;)a.push(Yn);a.forEach((o,c)=>{if(o<Yn&&(o=Yn),s[c]){const l=o*2;s[c].style.height=`${l}px`,s[c].style.display=o>0?"block":"none"}})}catch(r){console.warn("Error updating equaliser:",r)}},QS);return()=>{clearInterval(i)}},[n]),m("div",{className:"obi-equaliser",ref:t,children:Array.from({length:ms},(i,r)=>m("div",{className:"column",children:m("div",{className:"bar",style:{height:`${Yn}px`,backgroundColor:e,display:"block"}})},r))})}function nn({className:n,children:e,onClick:t}){return t?m("button",{class:`obi-button obi-message ${n} clickable`,onClick:t,children:e}):m("div",{class:`obi-message ${n}`,children:e})}const eC=8;function vf({color:n="white"}){return m("div",{className:"obi-loading-dots",children:Array.from({length:eC},(e,t)=>m("div",{className:"column",children:[m("div",{className:"bar",style:{backgroundColor:n,animationDelay:`${t*.15}s`}}),m("div",{className:"dot",style:{backgroundColor:n}})]},t))})}function tC({onContinue:n,onWrapUp:e}){return m(Do,{className:"obi-exit-survey",children:m(iC,{onContinue:n,onWrapUp:()=>{e()}})})}function nC({onOtherSelect:n,onReasonSelect:e,onClose:t}){const[i,r]=Y("reason"),s=a=>{a==="other"?(n(),r("other-reason")):e(a)};return m(Do,{className:`obi-exit-survey ${i==="reason"?"obi-exit-survey-reason":""}`,children:i==="reason"?m(rC,{onReasonSelect:s}):m(sC,{onReasonSelect:s,onClose:t})})}function iC({onContinue:n,onWrapUp:e}){return m("div",{className:"obi-exit-survey-container",children:[m("h2",{className:"obi-exit-survey-title",children:"Wrapping up early?"}),m("div",{className:"obi-exit-survey-options",children:[m("button",{className:"obi-button obi-exit-survey-button obi-exit-survey-button-continue",onClick:n,type:"button",children:"No, let's continue"}),m("button",{className:"obi-button obi-exit-survey-button obi-exit-survey-button-wrap-up",onClick:e,type:"button",children:"Yes, let's wrap up"})]})]})}function rC({onReasonSelect:n}){return m("div",{className:"obi-exit-survey-container obi-exit-survey-reason-container",children:[m("div",{className:"obi-exit-survey-header",children:m("h2",{className:"obi-exit-survey-title obi-exit-survey-reason-title",children:"Quick feedback?"})}),m("div",{className:"obi-exit-survey-options obi-exit-survey-reason-options",children:[m("button",{className:"obi-button obi-exit-survey-button obi-exit-survey-reason-button",onClick:()=>n("do-later"),type:"button",children:"Will do later"}),m("button",{className:"obi-button obi-exit-survey-button obi-exit-survey-reason-button",onClick:()=>n("cant-talk"),type:"button",children:"Can't talk right now"}),m("button",{className:"obi-button obi-exit-survey-button obi-exit-survey-reason-button",onClick:()=>n("prefer-written"),type:"button",children:"Prefer written instructions"}),m("button",{className:"obi-button obi-exit-survey-button obi-exit-survey-reason-button",onClick:()=>n("technical-issues"),type:"button",children:"Experienced technical issues"})]})]})}function sC({onReasonSelect:n,onClose:e}){const[t,i]=Y("");return m("div",{className:"obi-exit-survey-container obi-exit-survey-reason-container",children:[m("div",{className:"obi-exit-survey-header",children:[m(hf,{onClose:e}),m("h2",{className:"obi-exit-survey-title obi-exit-survey-reason-title",children:"Tell us more"})]}),m("div",{className:"obi-exit-survey-options obi-exit-survey-reason-options",children:[m("textarea",{className:"obi-exit-survey-button obi-exit-survey-reason-button",placeholder:"What's on your mind?",value:t,onChange:r=>i(r.target.value)}),m("button",{className:"obi-button obi-exit-survey-button obi-exit-survey-button-wrap-up",onClick:()=>n("other-feedback",t),type:"button",children:"Send feedback"})]})]})}function aC(n,e){for(var t in e)n[t]=e[t];return n}function bf(n,e){for(var t in n)if(t!=="__source"&&!(t in e))return!0;for(var i in e)if(i!=="__source"&&n[i]!==e[i])return!0;return!1}function yf(n,e){this.props=n,this.context=e}(yf.prototype=new At).isPureReactComponent=!0,yf.prototype.shouldComponentUpdate=function(n,e){return bf(this.props,n)||bf(this.state,e)};var kf=W.__b;W.__b=function(n){n.type&&n.type.__f&&n.ref&&(n.props.ref=n.ref,n.ref=null),kf&&kf(n)};var oC=W.__e;W.__e=function(n,e,t,i){if(n.then){for(var r,s=e;s=s.__;)if((r=s.__c)&&r.__c)return e.__e==null&&(e.__e=t.__e,e.__k=t.__k),r.__c(n,e)}oC(n,e,t,i)};var Tf=W.unmount;function Sf(n,e,t){return n&&(n.__c&&n.__c.__H&&(n.__c.__H.__.forEach(function(i){typeof i.__c=="function"&&i.__c()}),n.__c.__H=null),(n=aC({},n)).__c!=null&&(n.__c.__P===t&&(n.__c.__P=e),n.__c.__e=!0,n.__c=null),n.__k=n.__k&&n.__k.map(function(i){return Sf(i,e,t)})),n}function Cf(n,e,t){return n&&t&&(n.__v=null,n.__k=n.__k&&n.__k.map(function(i){return Cf(i,e,t)}),n.__c&&n.__c.__P===e&&(n.__e&&t.appendChild(n.__e),n.__c.__e=!0,n.__c.__P=t)),n}function Bo(){this.__u=0,this.o=null,this.__b=null}function xf(n){var e=n.__.__c;return e&&e.__a&&e.__a(n)}function gs(){this.i=null,this.l=null}W.unmount=function(n){var e=n.__c;e&&e.__R&&e.__R(),e&&32&n.__u&&(n.type=null),Tf&&Tf(n)},(Bo.prototype=new At).__c=function(n,e){var t=e.__c,i=this;i.o==null&&(i.o=[]),i.o.push(t);var r=xf(i.__v),s=!1,a=function(){s||(s=!0,t.__R=null,r?r(o):o())};t.__R=a;var o=function(){if(!--i.__u){if(i.state.__a){var c=i.state.__a;i.__v.__k[0]=Cf(c,c.__c.__P,c.__c.__O)}var l;for(i.setState({__a:i.__b=null});l=i.o.pop();)l.forceUpdate()}};i.__u++||32&e.__u||i.setState({__a:i.__b=i.__v.__k[0]}),n.then(a,a)},Bo.prototype.componentWillUnmount=function(){this.o=[]},Bo.prototype.render=function(n,e){if(this.__b){if(this.__v.__k){var t=document.createElement("div"),i=this.__v.__k[0].__c;this.__v.__k[0]=Sf(this.__b,t,i.__O=i.__P)}this.__b=null}var r=e.__a&&Po(Ne,null,n.fallback);return r&&(r.__u&=-33),[Po(Ne,null,e.__a?null:n.children),r]};var wf=function(n,e,t){if(++t[1]===t[0]&&n.l.delete(e),n.props.revealOrder&&(n.props.revealOrder[0]!=="t"||!n.l.size))for(t=n.i;t;){for(;t.length>3;)t.pop()();if(t[1]<t[0])break;n.i=t=t[2]}};(gs.prototype=new At).__a=function(n){var e=this,t=xf(e.__v),i=e.l.get(n);return i[0]++,function(r){var s=function(){e.props.revealOrder?(i.push(r),wf(e,n,i)):r()};t?t(s):s()}},gs.prototype.render=function(n){this.i=null,this.l=new Map;var e=us(n.children);n.revealOrder&&n.revealOrder[0]==="b"&&e.reverse();for(var t=e.length;t--;)this.l.set(e[t],this.i=[1,0,this.i]);return n.children},gs.prototype.componentDidUpdate=gs.prototype.componentDidMount=function(){var n=this;this.l.forEach(function(e,t){wf(n,t,e)})};var cC=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,lC=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,uC=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,dC=/[A-Z0-9]/g,hC=typeof document<"u",fC=function(n){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(n)};At.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(n){Object.defineProperty(At.prototype,n,{configurable:!0,get:function(){return this["UNSAFE_"+n]},set:function(e){Object.defineProperty(this,n,{configurable:!0,writable:!0,value:e})}})});var _f=W.event;function pC(){}function mC(){return this.cancelBubble}function gC(){return this.defaultPrevented}W.event=function(n){return _f&&(n=_f(n)),n.persist=pC,n.isPropagationStopped=mC,n.isDefaultPrevented=gC,n.nativeEvent=n};var vC={enumerable:!1,configurable:!0,get:function(){return this.class}},Ef=W.vnode;W.vnode=function(n){typeof n.type=="string"&&function(e){var t=e.props,i=e.type,r={},s=i.indexOf("-")===-1;for(var a in t){var o=t[a];if(!(a==="value"&&"defaultValue"in t&&o==null||hC&&a==="children"&&i==="noscript"||a==="class"||a==="className")){var c=a.toLowerCase();a==="defaultValue"&&"value"in t&&t.value==null?a="value":a==="download"&&o===!0?o="":c==="translate"&&o==="no"?o=!1:c[0]==="o"&&c[1]==="n"?c==="ondoubleclick"?a="ondblclick":c!=="onchange"||i!=="input"&&i!=="textarea"||fC(t.type)?c==="onfocus"?a="onfocusin":c==="onblur"?a="onfocusout":uC.test(a)&&(a=c):c=a="oninput":s&&lC.test(a)?a=a.replace(dC,"-$&").toLowerCase():o===null&&(o=void 0),c==="oninput"&&r[a=c]&&(a="oninputCapture"),r[a]=o}}i=="select"&&r.multiple&&Array.isArray(r.value)&&(r.value=us(t.children).forEach(function(l){l.props.selected=r.value.indexOf(l.props.value)!=-1})),i=="select"&&r.defaultValue!=null&&(r.value=us(t.children).forEach(function(l){l.props.selected=r.multiple?r.defaultValue.indexOf(l.props.value)!=-1:r.defaultValue==l.props.value})),t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,"className",vC)):(t.className&&!t.class||t.class&&t.className)&&(r.class=r.className=t.className),e.props=r}(n),n.$$typeof=cC,Ef&&Ef(n)};var Pf=W.__r;W.__r=function(n){Pf&&Pf(n),n.__c};var Rf=W.diffed;W.diffed=function(n){Rf&&Rf(n);var e=n.props,t=n.__e;t!=null&&n.type==="textarea"&&"value"in e&&e.value!==t.value&&(t.value=e.value==null?"":e.value)};function bC(n){const{placeholder:e="Type your message...",value:t,defaultValue:i,onChange:r,onSend:s,onCancel:a,onExpand:o,isLoading:c=!1,disabled:l=!1,maxLength:u=500,children:d}=n,[h,f]=Y(t||i||""),[p,g]=Y((t||i||"").length>24),v=Ct(null);hs(()=>{p&&(o==null||o(!0))},[]);const b=t!==void 0?t:h,S=T=>{const C=T.currentTarget.value;t===void 0&&f(C),r==null||r(C)},x=T=>{T.key==="Escape"&&(f(t||i||""),g(!1),a==null||a()),T.key==="Enter"&&!T.shiftKey&&b.trim()&&(T.preventDefault(),f(t||i||""),g(!1),k()),(b||"").length>=24&&!p&&(g(!0),o==null||o(!0))};ze(()=>{v.current&&v.current.focus()},[v.current]);const k=()=>{!b.trim()||c||l||(s==null||s(b.trim()),t===void 0&&f(""))};return m("div",{className:`obi-message-input ${p?"expanded":""}`,children:[m("div",{className:"container",children:m("textarea",{ref:v,className:"field",placeholder:e,value:b,onInput:S,onKeyDown:x,disabled:l||c,maxLength:u,rows:1})}),m("div",{className:"button-container",children:[p&&m("div",{children:d}),m("button",{className:"obi-button send",onClick:k,disabled:!b.trim()||c||l,type:"button",children:m("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:m("path",{d:"M6.00016 10.6673V1.33398M6.00016 1.33398L1.3335 6.00065M6.00016 1.33398L10.6668 6.00065",stroke:"#F3F3F3","stroke-width":"1.6","stroke-linecap":"round","stroke-linejoin":"round"})})})]})]})}function yC(n){const{currentStep:e,totalSteps:t,stepNames:i,className:r}=n,s=Array.from({length:t},(c,l)=>({isCompleted:l<e,stepNumber:l+1})),a=i[e-1]||`Step ${e}`,o=`${e}/${t} \u2022 ${a}`;return m("div",{class:`obi-course-progress ${r||""}`,children:[m("div",{class:"obi-course-progress-steps",children:s.map((c,l)=>m("div",{class:"obi-course-progress-container",children:m("div",{class:`obi-course-progress-step ${c.isCompleted?"completed":""}`})},l))}),m("div",{class:"obi-course-progress-description",children:o})]})}function If({className:n="",size:e=64}){return m("svg",{width:e,height:e,viewBox:"0 0 256 256",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:m("path",{d:"M158.803 0L160.352 0.0399439C176.267 0.844061 188.922 13.9634 188.922 30.0311C188.922 46.6174 175.438 60.0653 158.803 60.0656H99.0263L98.9061 60.0722C78.8071 61.4795 62.6269 77.004 60.2644 96.7673L60.241 96.9704V158.93L60.2644 159.13C62.7406 179.86 80.4234 195.934 101.881 195.935H153.842C176.993 195.935 195.759 177.223 195.759 154.14V96.9138L195.799 95.3693C196.606 79.5009 209.766 66.8827 225.881 66.8827C242.515 66.8834 256 80.328 256 96.9138V159.086L255.963 160.564C255.225 175.748 243.176 187.971 228.038 189.038V189.214C207.121 190.591 190.4 207.263 189.019 228.119H188.842C187.738 243.7 174.712 256 158.803 256H96.4491C79.8147 256 66.3309 242.555 66.3302 225.969C66.3302 225.673 66.3349 225.375 66.3436 225.077H66.3503H66.3035C63.3344 206.008 47.4427 190.589 27.8321 189.231L27.8354 189.031C12.2702 187.868 0.000167669 174.905 0 159.086V96.9138L0.0367222 95.4192C0.791087 80.0787 13.0909 67.7634 28.453 66.9293C47.7697 65.3039 63.3522 50.3234 66.2969 31.4658L66.3469 31.1595L66.3369 30.85C66.3301 30.5933 66.3302 30.3238 66.3302 30.0311C66.3309 13.4454 79.8148 0.000165137 96.4491 0H158.803Z",fill:"currentColor"})})}function kC(n){const{disabled:e,inPlan:t,isPaused:i}=n,[r,s]=Y(null),[a,o]=Y(n.isActive??n.defaultIsActive??!1),[c,l]=Y(!1),[u,d]=Y(n.cancelling??!1),[h,f]=Y(n.messaging??!1),[p,g]=Y(!1),[v,b]=Y(h),[S,x]=Y(!1);hs(()=>{n.messaging!==void 0&&f(n.messaging)},[n.messaging]);function k(){o(!0),l(!1),x(!0),n.messaging!==void 0&&f(n.messaging)}function T(){}function C(){r&&(clearTimeout(r),s(null))}function _(){s(setTimeout(()=>{o(n.defaultIsActive??!1),x(!1)},400))}function R(re){var ft;g(!1),(ft=n.onMessage)==null||ft.call(n,re)}function I(){var re;f(!1),g(!1),o(!1),l(!0),(re=n.onMinimize)==null||re.call(n)}function D(){var re;f(!1),d(!0),g(!1),(re=n.onCancelClick)==null||re.call(n)}function U(){var re;t||((re=n.onOpen)==null||re.call(n))}function V(re){var ft,np,ip,rp,sp,ap;switch(re){case"need-help":(ft=n.onMessage)==null||ft.call(n,"I'm struggling, can you look at my screen and help me out."),(np=n.onOneClickAction)==null||np.call(n,"need-help");break;case"continue":(ip=n.onMessage)==null||ip.call(n,"Okay, let's continue."),(rp=n.onOneClickAction)==null||rp.call(n,"continue");break;case"say-again":(sp=n.onMessage)==null||sp.call(n,"Please say that again."),(ap=n.onOneClickAction)==null||ap.call(n,"say-again");break}}function G(re){var ft;n.messaging===void 0&&((ft=n.onMessagingChange)==null||ft.call(n,re),f(re)),re||g(!1)}const z=n.isActive??((a||t)&&!c&&!e),A=z&&t,j=z&&t&&!p,K=n.speakingStatus==="user-speaking",Q=n.speakingStatus==="thinking",se=n.speakingStatus==="busy",Me=z&&!t&&!u&&S,Le=z&&t&&i&&!K&&!u,_e=z&&t&&!Le&&!K&&h!==v&&!u,et=z&&t&&i&&K&&!u,qe=z&&t&&!i&&K&&!u,Te=z&&t&&!i&&se&&!u,Nt=h&&K,Ke=Me||Le||et||qe||_e||u,rn=400,Sn=z&&t&&!p,sx=Me?5:10;return hs(()=>{b(h)},[K]),!t&&!u?m(TC,{...n}):!t&&u?m(SC,{onOtherSelect:()=>{var re;(re=n.onCancelReasonOther)==null||re.call(n)},onCancelReason:re=>{var ft;o(n.defaultIsActive??!1),d(!1),(ft=n.onCancelReason)==null||ft.call(n,re)},onClose:()=>{o(n.defaultIsActive??!1),d(!1)}}):m(Do,{className:`obi-widget-panel ${A?"expanded":""} ${p?"maximized":""} ${h?"messaging":""} ${se?"tool-usage":""}`,children:[m("div",{className:`obi-widget ${z?"active":""} ${t?"in-plan":""}`,onMouseEnter:C,onMouseLeave:_,children:[j&&m(ht,{type:"cancel",onClick:D,disabled:u,title:"Cancel session"}),j&&!i&&m(ht,{type:"pause",onClick:n.onPause,title:"Pause session"}),j&&i&&m(ht,{type:"play",onClick:n.onUnpause,title:"Unpause session"}),m(He,{className:"obi-widget-popout",open:Ke,trigger:null,delayMs:rn,offset:sx,children:[m(He.Target,{children:[Nt&&m(bC,{value:n.message,defaultValue:"Okay, let's continue.",onCancel:()=>G(!1),onSend:R,onExpand:g,onChange:n.onMessageChange,children:m("div",{className:"obi-widget-buttons",children:[m(ht,{type:"cancel",onClick:D,disabled:u,title:"Cancel session"}),!i&&m(ht,{type:"pause",onClick:n.onPause,title:"Pause session"}),i&&m(ht,{type:"play",onClick:n.onUnpause,title:"Unpause session"}),m(ht,{type:h?"voice":"message",disabled:n.messaging!==void 0,onClick:()=>G(!h),title:h?"Voice input":"Text input"}),m(ht,{type:"minimize",onClick:I,title:"Minimize widget"})]})}),!Nt&&m(ps,{className:z&&!t?"button":"",isActive:z,speakingStatus:n.speakingStatus,onClick:U,onMouseEnter:k,onMouseLeave:T,children:[z&&!t&&!Te&&m("span",{className:"obi-widget-pill-text",children:"Tutorials"}),z&&t&&Te&&m("span",{className:"obi-widget-pill-text",children:"Searching knowledge ..."}),z&&t&&!Q&&!Te&&m(gf,{getBands:n.spectrum}),z&&Q&&!Te&&m(vf,{})]})]}),m(He.Content,{children:m("div",{onMouseLeave:_,children:[Me&&m(nn,{onClick:U,children:"Click to see all"}),Le&&m(nn,{children:"Session will pause shortly"}),_e&&m(nn,{children:["Switched to ",h?"chat":"voice"]}),et&&m(nn,{children:"Paused"}),qe&&m("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"4px"},children:[m(nn,{onClick:()=>V("need-help"),children:"Need help"}),m(nn,{onClick:()=>V("continue"),children:"Continue"}),m(nn,{onClick:()=>V("say-again"),children:"Say again"})]}),u&&m(tC,{onContinue:()=>{var re;(re=n.onCancelAbort)==null||re.call(n),d(!1),n.messaging!==void 0&&f(n.messaging)},onWrapUp:()=>{var re;(re=n.onCancel)==null||re.call(n)}})]})})]}),j&&m(ht,{type:h?"voice":"message",disabled:n.messaging!==void 0,onClick:()=>G(!h),title:h?"Voice input":"Text input"}),j&&m(ht,{type:"minimize",onClick:I,title:"Minimize widget"})]}),Sn&&n.courseProgress&&m("div",{className:`obi-course-progress-container ${h?"expanded":""}`,children:m(yC,{currentStep:n.courseProgress.currentStep,totalSteps:n.courseProgress.totalSteps,stepNames:n.courseProgress.stepNames})})]})}function TC(n){const{disabled:e,completedTutorials:t,totalTutorials:i,agentName:r}=n,[s,a]=Y(null),[o,c]=Y(n.isActive??n.defaultIsActive??!1),[l,u]=Y(!1),[d,h]=Y(n.hovered??!1);function f(){var R;c(!0),u(!1),h(!0),(R=n.onHover)==null||R.call(n,!0)}function p(){}function g(){s&&(clearTimeout(s),a(null))}function v(){o&&a(setTimeout(()=>{var R;c(n.defaultIsActive??!1),h(!1),(R=n.onHover)==null||R.call(n,!1)},400))}function b(){c(!1),u(!0)}function S(){var R;(R=n.onOpen)==null||R.call(n)}const x=n.hovered??(d&&!l),k=n.isActive??(o&&!e&&!l),T=k&&x,C=`round-button ${k?"active":""}`;let _=`${r||"Obi"}`;return t!==void 0&&i!==void 0&&t>=0&&i>0&&(_=`${t}/${i} completed`),m("div",{className:"obi-widget-out-of-plan-container",children:m("div",{className:`obi-widget-out-of-plan ${x?"hover":""} ${k?"active":""}`,onMouseEnter:g,onMouseLeave:v,children:[m("div",{className:C,style:{width:"30px",height:"30px"}}),m(He,{className:"obi-widget-popout",open:T,trigger:null,delayMs:400,offset:5,children:[m(He.Target,{children:m($S,{className:k?"button":"",active:k,onClick:S,onMouseEnter:f,onMouseLeave:p,children:m("span",{className:"text",children:[m(If,{size:16}),_]})})}),m(He.Content,{children:m("div",{onMouseLeave:v,children:m(nn,{className:"message",onClick:S,children:"Click to see all"})})})]}),m(ht,{className:C,type:"minimize",onClick:b,title:"Minimize widget"})]})})}function SC(n){return m("div",{className:"obi-widget-out-of-plan-container",children:m("div",{className:"obi-widget-out-of-plan",children:m(He,{className:"obi-widget-popout",open:!0,trigger:null,delayMs:100,offset:5,children:[m(He.Target,{children:m(KS,{active:!1})}),m(He.Content,{children:m(nC,{onOtherSelect:()=>{var e;(e=n.onOtherSelect)==null||e.call(n)},onReasonSelect:(e,t)=>{var i;(i=n.onCancelReason)==null||i.call(n,e,t)},onClose:()=>{var e;(e=n.onClose)==null||e.call(n)}})})]})})})}function CC({open:n=!1,children:e,onClose:t}){return m(ff,{open:n,onClose:t,children:m("div",{className:"tour content-area",children:n?typeof e=="function"?e():e:null})})}function Xn({title:n="",subtitle:e="",agentName:t="Obi",buttonText:i="Continue",speakingState:r=null,actionDisabled:s=!1,href:a=null,centerVisual:o,description:c,button:l,onAction:u}){const[d,h]=Y(s),[f,p]=Y(!1),[g,v]=Y(r);return ze(()=>{f||(r==="listening"&&g!=="listening"&&d&&h(!1),r!=="listening"&&!d&&h(!0)),v(r)},[r,d]),ze(()=>{h(s)},[s]),m("div",{className:"tour-content",children:m("div",{className:"container",children:[m("div",{className:"header",children:[m("h1",{className:"title",children:n}),m("p",{className:"subtitle",children:e})]}),m("div",{className:"visual",style:{background:"var(--obi-color-tint)"},children:o}),m("div",{className:"description",children:c}),m("div",{className:"button-container",children:l||m(a?"a":"button",{className:`action-button ${d?"disabled":""}`,onClick:()=>{d||(h(!0),p(!0),u==null||u())},disabled:d,...a?{href:a,target:"_blank",rel:"noopener noreferrer"}:{type:"button"},children:m("span",{className:"button-text",children:(()=>{switch(r){case"thinking":return"Loading...";case"speaking":return`${t} is speaking`;default:return i}})()})})})]})})}function xC({logoUrl:n="",appName:e="App"}){const[t,i]=Y(!1),[r,s]=Y(!1),a=()=>{i(!0)},o=()=>{s(!0),i(!1)},c={container:{display:"block"},logoContainer:{width:"480px",height:"240px",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"center",position:"relative",overflow:"hidden"},backgroundPattern:{position:"absolute",inset:0,zIndex:0,background:"#F5F5F5",backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='277' height='195' viewBox='0 0 277 195' fill='none'%3E%3Cpath opacity='0.4' d='M341.308 0.75C380.279 0.750001 411.872 24.3772 411.872 53.5229C411.872 82.6685 380.279 106.296 341.308 106.296H215.792C176.964 108.335 145.691 130.837 141.128 159.475V256.616C145.912 286.659 180.089 309.954 221.548 309.954H330.872C375.607 309.954 411.872 282.833 411.872 249.377V159.069C411.872 129.923 443.465 106.296 482.436 106.296C521.407 106.296 553 129.923 553 159.069V257.181C553 285.058 524.099 307.88 487.483 309.815C489.264 309.902 491.061 309.954 492.871 309.954C448.137 309.954 411.872 337.076 411.872 370.532C411.872 369.177 411.803 367.834 411.686 366.502C409.098 393.885 378.582 415.5 341.308 415.5H210.118C171.147 415.5 139.554 391.873 139.554 362.727C139.554 362.204 139.565 361.683 139.585 361.163C133.564 332.156 100.023 309.954 59.5488 309.954C61.4544 309.954 63.3441 309.9 65.2169 309.803C28.7434 307.76 -8.57239e-07 284.982 0 257.181V159.069C1.64632e-06 130.901 29.5078 107.89 66.6662 106.377C64.3207 106.224 61.9472 106.141 59.5488 106.141C100.012 106.141 133.54 83.951 139.575 54.9552C139.558 54.4793 139.554 54.0018 139.554 53.5229C139.554 24.3772 171.147 0.75 210.118 0.75H341.308Z' fill='white'/%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"190px 60px",backgroundSize:"300px 225px"},logoWrapper:{background:"#888888",width:"120px",height:"120px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"4px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",zIndex:10,overflow:"hidden"},appLogo:{width:"120px",height:"120px",objectFit:"cover",display:n&&!t&&r?"block":"none"},placeholderLogo:{width:"60px",height:"60px",background:"rgba(255, 255, 255, 0.2)",borderRadius:"4px",display:!n||t||!r?"flex":"none",alignItems:"center",justifyContent:"center",color:"rgba(255, 255, 255, 0.8)",fontSize:"24px",fontWeight:"bold"}};return m("div",{style:c.container,children:m("div",{style:c.logoContainer,children:[m("div",{style:c.backgroundPattern}),m("div",{style:c.logoWrapper,children:[n&&m("img",{style:c.appLogo,src:n,alt:`${e} logo`,onError:a,onLoad:o}),m("div",{style:c.placeholderLogo,children:e.charAt(0).toUpperCase()})]})]})})}function wC({session:n,speakingState:e,onAction:t}){const i=n.appName?`Navigate to ${n.appName}`:"Navigate to app",r=n.appName?`Open ${n.appName}`:"Open app",s=n.appName?`Enjoy the tutorial in ${n.appName}`:"Enjoy the tutorial";return m(Xn,{title:i,subtitle:"Click the button below to open the app",agentName:n.agentName||"Obi",buttonText:r,speakingState:e,actionDisabled:!0,href:n.url,description:s,centerVisual:m(xC,{logoUrl:n.appLogoUrl,appName:n.appName}),onAction:t})}function _C({}){return m("div",{style:{borderRadius:"15px",boxShadow:"0 0 20px 2px var(--obi-color-primary)",backgroundColor:"var(--obi-color-primary)",transform:"scale(1.6)"},children:m(ps,{isActive:!0,children:m("div",{className:"obi-static-voice-visual",children:[m("div",{className:"column",children:m("div",{className:"bar bar-1"})}),m("div",{className:"column",children:m("div",{className:"bar bar-2"})}),m("div",{className:"column",children:m("div",{className:"bar bar-3"})}),m("div",{className:"column",children:m("div",{className:"bar bar-4"})}),m("div",{className:"column",children:m("div",{className:"bar bar-5"})}),m("div",{className:"column",children:m("div",{className:"bar bar-6"})}),m("div",{className:"column",children:m("div",{className:"bar bar-7"})}),m("div",{className:"column",children:m("div",{className:"bar bar-8"})})]})})})}function EC({session:n,speakingState:e,onAction:t}){return m(Xn,{title:n.name,subtitle:"AI voice-guided tutorial",description:n.description,buttonText:"Start now",agentName:n.agentName||"Obi",speakingState:e,centerVisual:m(_C,{}),onAction:t})}function PC(){const n={host:{display:"block",position:"relative",width:"100%",height:"100%"},container:{position:"relative",width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},permissionDialog:{boxSizing:"border-box",display:"flex",flexDirection:"row",justifyContent:"flex-start",alignItems:"center",padding:"16px 20px",gap:"16px",position:"absolute",width:"344px",height:"125px",left:"calc(50% - 344px/2)",top:"calc(50% - 125px/2)",background:"#FFFFFF",border:"1px solid #E5E7EB",boxShadow:"0px 10px 15px -3px rgba(0, 0, 0, 0.1), 0px 4px 6px -2px rgba(0, 0, 0, 0.05)",borderRadius:"8px"},permissionContent:{width:"100%",display:"flex",flexDirection:"column",gap:"16px"},permissionContentTop:{display:"flex",flexDirection:"row",alignItems:"center",padding:"0px",gap:"16px"},micIconContainer:{color:"var(--obi-color-text)",boxSizing:"border-box",display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",padding:"12px",gap:"8px",width:"48px",height:"48px",background:"#F9FAFB",border:"1px solid #D1D5DB",borderRadius:"6px",flex:"none",order:0,flexGrow:0},micIcon:{width:"24px",height:"24px",flex:"none",order:0,flexGrow:0},permissionText:{flex:1,height:"24px",fontFamily:"'Inter', sans-serif",fontStyle:"normal",fontWeight:500,fontSize:"16px",lineHeight:"24px",display:"flex",alignItems:"center",color:"#111827",flexGrow:1,order:1},allowButton:{alignSelf:"flex-end",boxSizing:"border-box",display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",padding:"10px 20px",gap:"8px",minWidth:"80px",height:"40px",background:"#F9FAFB",border:"1px solid #D1D5DB",borderRadius:"6px",flex:"none",order:2,flexGrow:0,cursor:"pointer",fontFamily:"'Inter', sans-serif",fontStyle:"normal",fontWeight:500,fontSize:"14px",lineHeight:"20px",color:"#374151"},cursorPointer:{position:"absolute",width:"24px",height:"24px",right:"80px",bottom:"60px",zIndex:3,animation:"pointToAllow 2s ease-in-out infinite"},cursorSvg:{width:"100%",height:"100%",filter:"drop-shadow(0px 1px 1.8px rgba(0, 0, 0, 0.65))"}};return m("div",{style:n.host,children:[m("style",{children:`
43
+ @keyframes pointToAllow {
44
+ 0%, 100% { transform: translate(0, 0); }
45
+ 50% { transform: translate(2px, -1px); }
46
+ }
47
+ `}),m("div",{style:n.container,children:[m("div",{style:n.permissionDialog,children:m("div",{style:n.permissionContent,children:[m("div",{style:n.permissionContentTop,children:[m("div",{style:n.micIconContainer,children:m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:n.micIcon,children:[m("path",{d:"M12 19v3"}),m("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),m("rect",{x:"9",y:"2",width:"6",height:"13",rx:"3"})]})}),m("div",{style:n.permissionText,children:"Use your microphone"})]}),m("button",{style:n.allowButton,children:"Allow"})]})}),m("div",{style:n.cursorPointer,children:m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:n.cursorSvg,children:[m("path",{d:"M12.586 12.586 19 19"}),m("path",{d:"M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z"})]})})]})]})}function RC({session:n,speakingState:e,onAction:t}){return m(Xn,{title:"Connect your microphone",subtitle:"Watch for the prompt in your browser",agentName:n.agentName||"Obi",buttonText:"Continue",speakingState:e,actionDisabled:!0,description:`${n.agentName||"Obi"} will guide you through the tutorial by talking with you.`,centerVisual:m(PC,{}),onAction:t})}function IC({}){return m("div",{style:{borderRadius:"15px",boxShadow:"0 0 20px 2px var(--obi-color-primary)",backgroundColor:"var(--obi-color-primary)",transform:"scale(1.6)"},children:m(ps,{isActive:!0,children:m(vf,{})})})}function OC({session:n,speakingState:e,onAction:t}){return m(Xn,{title:"Can you hear me?",subtitle:`Make sure your sound is on so you can hear ${n.agentName||"Obi"}`,agentName:n.agentName||"Obi",speakingState:e,actionDisabled:!0,description:`${n.agentName||"Obi"} will guide you through the tutorial by talking with you.`,centerVisual:m(IC,{}),onAction:t})}function AC(){const n={container:{display:"flex",justifyContent:"center",alignItems:"center"},skeletonContainer:{display:"flex",flexDirection:"column",flexShrink:0,gap:"10px",alignItems:"center",padding:"20px",margin:"0 auto",background:"white",borderRadius:"12px",border:"0.569px solid #E4E4E7",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",height:"234px",width:"344px"},headerSection:{display:"flex",position:"relative",gap:"16px",alignItems:"center",alignSelf:"stretch"},avatar:{position:"relative",background:"#F4F4F5",borderRadius:"50%",height:"55px",width:"55px",flexShrink:0,overflow:"hidden"},textLines:{display:"flex",position:"relative",flexDirection:"column",gap:"10px",alignItems:"flex-start",alignSelf:"stretch",width:"100%"},textLine:{position:"relative",borderRadius:"2px",background:"#F4F4F5",height:"18px",alignSelf:"stretch",overflow:"hidden"},contentSection:{display:"flex",position:"relative",flexDirection:"column",flexShrink:0,gap:"16px",justifyContent:"center",alignItems:"flex-start",alignSelf:"stretch",height:"62px"},contentBlock:{position:"relative",alignSelf:"stretch",borderRadius:"2px",background:"#F4F4F5",flex:"1 0 0",overflow:"hidden"},shimmer:{position:"absolute",top:0,left:"-150px",height:"100%",width:"150px",background:"linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent)",animation:"skeleton-loading 2s infinite"}};return m("div",{style:n.container,children:[m("style",{children:`
48
+ @keyframes skeleton-loading {
49
+ 0% { transform: translateX(-150px); }
50
+ 50% { transform: translateX(344px); }
51
+ 100% { transform: translateX(344px); }
52
+ }
53
+ `}),m("article",{style:n.skeletonContainer,role:"status","aria-label":"Loading content",children:[m("section",{style:n.headerSection,children:[m("div",{style:n.avatar,role:"img","aria-label":"Loading avatar",children:m("div",{style:n.shimmer})}),m("div",{style:n.textLines,children:[m("div",{style:n.textLine,role:"presentation","aria-label":"Loading text line 1",children:m("div",{style:n.shimmer})}),m("div",{style:n.textLine,role:"presentation","aria-label":"Loading text line 2",children:m("div",{style:n.shimmer})})]})]}),m("section",{style:n.contentSection,children:m("div",{style:n.contentBlock,role:"presentation","aria-label":"Loading card content",children:m("div",{style:n.shimmer})})})]})]})}function NC({}){const n={host:{display:"block"},shareContainer:{width:"480px",height:"240px",borderRadius:"12px",display:"grid",placeItems:"center",overflow:"hidden",position:"relative",backgroundColor:"var(--obi-color-tint)"},controlsRow:{zIndex:10,gridRowStart:1,gridColumnStart:1,display:"flex",alignSelf:"flex-start",marginTop:"36px",alignItems:"center",gap:"8px"},monitorIconContainer:{display:"flex",height:"40px",width:"40px",aspectRatio:"1",alignItems:"center",justifyContent:"center",gap:"8px",borderRadius:"2px",border:"1px solid #E4E4E7",background:"#F8FAFC",padding:"8px"},monitorIcon:{width:"24px",height:"24px",color:"#111827"},tabSelector:{display:"flex",width:"260px",height:"40px",padding:"4px",alignItems:"center",borderRadius:"2px",background:"#E4E4E7"},tabButton:e=>({display:"flex",flex:1,alignSelf:"stretch",alignItems:"center",justifyContent:"center",gap:"10px",borderRadius:"2px",padding:"6px 12px",border:"none",cursor:"pointer",fontFamily:"'Satoshi', sans-serif",fontSize:"14px",fontWeight:500,opacity:e?1:.4,background:e?"white":"#F8FAFC",boxShadow:e?"0 1px 2px 0 rgba(0, 0, 0, 0.05)":"none"}),skeletonContainer:{marginTop:"104px",gridColumnStart:1,gridRowStart:1,alignSelf:"center"}};return m("div",{style:n.host,children:m("div",{style:n.shareContainer,children:[m("div",{style:n.controlsRow,children:[m("div",{style:n.monitorIconContainer,children:m("svg",{style:n.monitorIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[m("rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",ry:"2"}),m("line",{x1:"8",x2:"16",y1:"21",y2:"21"}),m("line",{x1:"12",x2:"12",y1:"17",y2:"21"})]})}),m("div",{style:n.tabSelector,children:[m("button",{style:n.tabButton(!1),children:"Tab"}),m("button",{style:n.tabButton(!0),children:"Window"})]})]}),m("div",{style:n.skeletonContainer,children:m(AC,{})})]})})}function MC({session:n,speakingState:e,onAction:t}){return m(Xn,{title:"Connect your screen",subtitle:"Watch for the prompt in your browser",agentName:n.agentName||"Obi",buttonText:"Share screen",speakingState:e,description:`${n.agentName||"Obi"} will guide you through ${n.appName||"the app"} by watching your screen.`,centerVisual:m(NC,{}),actionDisabled:!0,onAction:t})}function LC({spectrum:n}){return m("div",{style:{borderRadius:"15px",boxShadow:"0 0 20px 2px var(--obi-color-primary)",backgroundColor:"var(--obi-color-primary)",transform:"scale(1.6)"},children:m(ps,{isActive:!0,children:m(gf,{getBands:n})})})}function DC({session:n,speakingState:e,spectrum:t,onAction:i}){return m(Xn,{title:"Overview",subtitle:`${n.agentName||"Obi"} will start your tutorial in a moment`,agentName:n.agentName||"Obi",speakingState:e,description:`Get ready to explore ${n.appName||"the app"} with ${n.agentName||"Obi"}.`,centerVisual:m(LC,{spectrum:t}),actionDisabled:!0,onAction:i})}function UC({id:n,name:e,description:t,duration:i=10,order:r=0,selected:s=!1,completed:a=!1,onClick:o}){return m("div",{className:`course-container ${s?"selected":""}`,onClick:()=>{o==null||o({id:n,name:e,description:t,duration:i,order:r})},children:[m("div",{className:"header-row",children:[m("h2",{className:"course-title",children:e}),a&&m("span",{className:"duration",children:"Completed"})]}),t&&m("p",{className:"course-description",children:t})]})}function BC({courses:n=[],selectedCourseId:e=null,loading:t=!1,error:i="",onCourseSelect:r}){const[s,a]=Y(""),o=u=>{const d=u.currentTarget;a(d.value)},c=u=>{r==null||r(u)};if(t)return m("div",{className:"loading",children:"Loading..."});if(i)return m("div",{className:"error",children:i});if(!n||n.length===0)return m("div",{className:"empty",children:"No courses available"});const l=n.filter(u=>u.name.toLowerCase().includes(s.toLowerCase())||(u.description||"").toLowerCase().includes(s.toLowerCase()));return m("div",{className:"tour-select",children:[m("div",{className:"controls",children:[m("div",{className:"tabs",children:m("button",{className:"tab active",children:"All"})}),m("div",{className:"filter",children:[m("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:m("path",{d:"M10.0417 8.75002H9.42087L9.20004 8.53502C9.96921 7.63585 10.4417 6.47502 10.4417 5.20835C10.4417 2.56085 8.32254 0.441681 5.67504 0.441681C3.02754 0.441681 0.908374 2.56085 0.908374 5.20835C0.908374 7.85585 3.02754 9.97502 5.67504 9.97502C6.94171 9.97502 8.10254 9.50252 9.00171 8.73335L9.22671 8.95418V9.57502L13.2167 13.5592L14.375 12.4008L10.0417 8.75002ZM5.67504 8.75002C3.72754 8.75002 2.15837 7.18085 2.15837 5.20835C2.15837 3.23585 3.72754 1.66668 5.67504 1.66668C7.62254 1.66668 9.19171 3.23585 9.19171 5.20835C9.19171 7.18085 7.62254 8.75002 5.67504 8.75002Z",fill:"#6B7280"})}),m("input",{type:"text",placeholder:"Search...",value:s,onInput:o})]})]}),m("div",{className:"course-grid",children:l.sort((u,d)=>(u.order||0)-(d.order||0)).map(u=>{const d=u.id===e;return m(UC,{id:u.id,name:u.name,description:u.description||"",duration:u.duration,order:u.order||0,completed:u.completed,selected:d,onClick:c},u.id)})})]})}function FC({open:n,courses:e=[],loading:t=!1,error:i="",agentName:r="Obi",productName:s,onClose:a,onCourseSelect:o,onCourseHighlight:c}){const[l,u]=Y(null),d=f=>{u(f),c==null||c(f)},h=()=>{l&&o&&o(l)};return m(ff,{open:n,onClose:a,size:"large",children:m("div",{className:"tour-select-modal-container",children:[m("div",{className:"header",children:[m("div",{className:"icon",style:{color:"white"},children:m(If,{})}),m("div",{className:"title-section",children:t?m(Ne,{children:[m("div",{className:"skeleton skeleton-title"}),m("div",{className:"skeleton skeleton-subtitle"})]}):m(Ne,{children:[m("h1",{children:[r," AI Training Assistant"]}),m("p",{className:"subtitle",children:["Start a tutorial and learn how to use ",s," through an interactive conversation."]})]})})]}),m("div",{className:"course-list-wrapper",children:m(BC,{courses:e,selectedCourseId:(l==null?void 0:l.id)||"",loading:t,error:i,onCourseSelect:d})}),m("div",{className:"footer",children:[m("button",{className:"obi-button footer-button",onClick:h,disabled:!l,children:[m("span",{children:"Get started"}),m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none",children:m("path",{d:"M3.83325 8.00065H13.1666M13.1666 8.00065L8.49992 3.33398M13.1666 8.00065L8.49992 12.6673",stroke:l?"#FAFAFA":"#999","stroke-width":"1.33","stroke-linecap":"round","stroke-linejoin":"round"})})]}),m("p",{className:"footer-text",children:"Sessions are securely recorded for quality improvement purposes."})]})]})})}function jC({session:n,sessionState:e,speakingState:t,spectrum:i,onStart:r,onContinue:s,onShareMicrophone:a,onShareScreen:o,onModalChange:c}){const[l,u]=Y(null);function d(f){l!==f&&(c==null||c(f),u(f))}function h(){e==="connecting"||e==="connected"||!e?r==null||r():e==="volume-check"||e==="mic-check"?s==null||s():e==="mic-share"?a==null||a():e==="screen-share"&&(o==null||o())}return No(()=>{switch(e){case null:case"connecting":case"connected":return d("session-start"),m(EC,{session:n,speakingState:t,onAction:h});case"volume-check":return d("voice-guidance"),m(OC,{session:n,speakingState:t,onAction:h});case"mic-check":return d("overview"),m(DC,{session:n,speakingState:t,spectrum:i,onAction:h});case"mic-share":return d("share-mic"),m(RC,{session:n,speakingState:t,onAction:h});case"screen-share":return d("share-screen"),m(MC,{session:n,speakingState:t,onAction:h});case"navigate":return d("navigate"),m(wC,{session:n,speakingState:t,onAction:h});default:return null}},[e,t,r,s,a,o])}function VC(n){const{session:e,sessionState:t,speakingState:i,spectrum:r,onClose:s,onStart:a,onContinue:o,onShareMicrophone:c,onShareScreen:l,onModalChange:u}=n,[d,h]=Y(null);function f(v){u==null||u(v),h(v)}function p(v){s(v,d),h(null)}const g=(n.open??!0)&&(!t||t==="connecting"||t==="connected"||t==="volume-check"||t==="mic-check"||t==="mic-share"||t==="screen-share"||t==="navigate");return m(CC,{open:g,onClose:p,children:()=>m(jC,{session:e,sessionState:t,speakingState:i,spectrum:r,onStart:a,onContinue:o,onShareMicrophone:c,onShareScreen:l,onModalChange:f})})}const GC={identify:()=>{},track:()=>{},page:()=>{},reset:()=>{}};function Ei(){return GC}const WC=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,Of="9.23.0",Jn=globalThis;function zC(n,e,t=Jn){const i=t.__SENTRY__=t.__SENTRY__||{},r=i[Of]=i[Of]||{};return r[n]||(r[n]=e())}const HC="Sentry Logger ",Af=["debug","info","warn","error","log","assert","trace"],Nf={};function qC(n){if(!("console"in Jn))return n();const e=Jn.console,t={},i=Object.keys(Nf);i.forEach(r=>{const s=Nf[r];t[r]=e[r],e[r]=s});try{return n()}finally{i.forEach(r=>{e[r]=t[r]})}}function KC(){let n=!1;const e={enable:()=>{n=!0},disable:()=>{n=!1},isEnabled:()=>n};return WC?Af.forEach(t=>{e[t]=(...i)=>{n&&qC(()=>{Jn.console[t](`${HC}[${t}]:`,...i)})}}):Af.forEach(t=>{e[t]=()=>{}}),e}zC("logger",KC);const Mf=1e3;function $C(){return Date.now()/Mf}function YC(){const{performance:n}=Jn;if(!(n!=null&&n.now))return $C;const e=Date.now()-n.now(),t=n.timeOrigin==null?e:n.timeOrigin;return()=>(t+n.now())/Mf}YC();const Lf=50,Qn="?",Df=/\(error: (.*)\)/,Uf=/captureMessage|captureException/;function XC(...n){const e=n.sort((t,i)=>t[0]-i[0]).map(t=>t[1]);return(t,i=0,r=0)=>{const s=[],a=t.split(`
54
+ `);for(let o=i;o<a.length;o++){const c=a[o];if(c.length>1024)continue;const l=Df.test(c)?c.replace(Df,"$1"):c;if(!l.match(/\S*Error: /)){for(const u of e){const d=u(l);if(d){s.push(d);break}}if(s.length>=Lf+r)break}}return JC(s.slice(r))}}function JC(n){if(!n.length)return[];const e=Array.from(n);return/sentryWrapped/.test(vs(e).function||"")&&e.pop(),e.reverse(),Uf.test(vs(e).function||"")&&(e.pop(),Uf.test(vs(e).function||"")&&e.pop()),e.slice(0,Lf).map(t=>({...t,filename:t.filename||vs(e).filename,function:t.function||Qn}))}function vs(n){return n[n.length-1]||{}}var Bf;(function(n){n[n.PENDING=0]="PENDING";const e=1;n[n.RESOLVED=e]="RESOLVED";const t=2;n[n.REJECTED=t]="REJECTED"})(Bf||(Bf={})),Jn._sentryClientToLogBufferMap=new WeakMap,typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const QC=30,ZC=50;function Fo(n,e,t,i){const r={filename:n,function:e==="<anonymous>"?Qn:e,in_app:!0};return t!==void 0&&(r.lineno=t),i!==void 0&&(r.colno=i),r}const e1=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,t1=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,n1=/\((\S*)(?::(\d+))(?::(\d+))\)/,i1=n=>{const e=e1.exec(n);if(e){const[,i,r,s]=e;return Fo(i,Qn,+r,+s)}const t=t1.exec(n);if(t){if(t[2]&&t[2].indexOf("eval")===0){const s=n1.exec(t[2]);s&&(t[2]=s[1],t[3]=s[2],t[4]=s[3])}const[i,r]=Ff(t[1]||Qn,t[2]);return Fo(r,i,t[3]?+t[3]:void 0,t[4]?+t[4]:void 0)}},r1=[QC,i1],s1=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,a1=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;XC(...[r1,[ZC,n=>{const e=s1.exec(n);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const r=a1.exec(e[3]);r&&(e[1]=e[1]||"eval",e[3]=r[1],e[4]=r[2],e[5]="")}let t=e[3],i=e[1]||Qn;return[i,t]=Ff(i,t),Fo(t,i,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}}]]);const Ff=(n,e)=>{const t=n.indexOf("safari-extension")!==-1,i=n.indexOf("safari-web-extension")!==-1;return t||i?[n.indexOf("@")!==-1?n.split("@")[0]:Qn,t?`safari-extension:${e}`:`safari-web-extension:${e}`]:[n,e]};typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;function o1(n,e,t,i){function r(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function o(u){try{l(i.next(u))}catch(d){a(d)}}function c(u){try{l(i.throw(u))}catch(d){a(d)}}function l(u){u.done?s(u.value):r(u.value).then(o,c)}l((i=i.apply(n,e||[])).next())})}function c1(n,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=o(0),a.throw=o(1),a.return=o(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(u){return c([l,u])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(t=0)),t;)try{if(i=1,r&&(s=l[0]&2?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,r=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){t.label=l[1];break}if(l[0]===6&&t.label<s[1]){t.label=s[1],s=l;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(l);break}s[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(u){l=[6,u],r=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}typeof SuppressedError=="function"&&SuppressedError;for(var jf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Pi=typeof Uint8Array>"u"?[]:new Uint8Array(256),bs=0;bs<jf.length;bs++)Pi[jf.charCodeAt(bs)]=bs;for(var l1=function(n){var e=n.length*.75,t=n.length,i,r=0,s,a,o,c;n[n.length-1]==="="&&(e--,n[n.length-2]==="="&&e--);var l=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u"&&typeof Uint8Array.prototype.slice<"u"?new ArrayBuffer(e):new Array(e),u=Array.isArray(l)?l:new Uint8Array(l);for(i=0;i<t;i+=4)s=Pi[n.charCodeAt(i)],a=Pi[n.charCodeAt(i+1)],o=Pi[n.charCodeAt(i+2)],c=Pi[n.charCodeAt(i+3)],u[r++]=s<<2|a>>4,u[r++]=(a&15)<<4|o>>2,u[r++]=(o&3)<<6|c&63;return l},u1=function(n){for(var e=n.length,t=[],i=0;i<e;i+=2)t.push(n[i+1]<<8|n[i]);return t},d1=function(n){for(var e=n.length,t=[],i=0;i<e;i+=4)t.push(n[i+3]<<24|n[i+2]<<16|n[i+1]<<8|n[i]);return t},kn=5,jo=6+5,Vo=2,h1=jo-kn,Vf=65536>>kn,f1=1<<kn,Go=f1-1,p1=1024>>kn,m1=Vf+p1,g1=m1,v1=32,b1=g1+v1,y1=65536>>jo,k1=1<<h1,T1=k1-1,Gf=function(n,e,t){return n.slice?n.slice(e,t):new Uint16Array(Array.prototype.slice.call(n,e,t))},S1=function(n,e,t){return n.slice?n.slice(e,t):new Uint32Array(Array.prototype.slice.call(n,e,t))},C1=function(n,e){var t=l1(n),i=Array.isArray(t)?d1(t):new Uint32Array(t),r=Array.isArray(t)?u1(t):new Uint16Array(t),s=24,a=Gf(r,s/2,i[4]/2),o=i[5]===2?Gf(r,(s+i[4])/2):S1(i,Math.ceil((s+i[4])/4));return new x1(i[0],i[1],i[2],i[3],a,o)},x1=function(){function n(e,t,i,r,s,a){this.initialValue=e,this.errorValue=t,this.highStart=i,this.highValueIndex=r,this.index=s,this.data=a}return n.prototype.get=function(e){var t;if(e>=0){if(e<55296||e>56319&&e<=65535)return t=this.index[e>>kn],t=(t<<Vo)+(e&Go),this.data[t];if(e<=65535)return t=this.index[Vf+(e-55296>>kn)],t=(t<<Vo)+(e&Go),this.data[t];if(e<this.highStart)return t=b1-y1+(e>>jo),t=this.index[t],t+=e>>kn&T1,t=this.index[t],t=(t<<Vo)+(e&Go),this.data[t];if(e<=1114111)return this.data[this.highValueIndex]}return this.errorValue},n}(),Wf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",w1=typeof Uint8Array>"u"?[]:new Uint8Array(256),ys=0;ys<Wf.length;ys++)w1[Wf.charCodeAt(ys)]=ys;var zf=null;function _1(n){return o1(this,void 0,void 0,function(){var e;return c1(this,function(t){switch(t.label){case 0:return zf!==null?[3,2]:[4,n()];case 1:if(e=t.sent(),!e.base64||!e.byte_length)throw new Error("Invalid graphemes response");zf=C1(e.base64,e.byte_length),t.label=2;case 2:return[2]}})})}for(var Hf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",E1=typeof Uint8Array>"u"?[]:new Uint8Array(256),ks=0;ks<Hf.length;ks++)E1[Hf.charCodeAt(ks)]=ks;function P1(n,e,t,i){function r(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function o(u){try{l(i.next(u))}catch(d){a(d)}}function c(u){try{l(i.throw(u))}catch(d){a(d)}}function l(u){u.done?s(u.value):r(u.value).then(o,c)}l((i=i.apply(n,e||[])).next())})}function R1(n,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=o(0),a.throw=o(1),a.return=o(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(u){return c([l,u])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(t=0)),t;)try{if(i=1,r&&(s=l[0]&2?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,r=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){t.label=l[1];break}if(l[0]===6&&t.label<s[1]){t.label=s[1],s=l;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(l);break}s[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(u){l=[6,u],r=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}typeof SuppressedError=="function"&&SuppressedError;for(var qf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ri=typeof Uint8Array>"u"?[]:new Uint8Array(256),Ts=0;Ts<qf.length;Ts++)Ri[qf.charCodeAt(Ts)]=Ts;for(var I1=function(n){var e=n.length*.75,t=n.length,i,r=0,s,a,o,c;n[n.length-1]==="="&&(e--,n[n.length-2]==="="&&e--);var l=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u"&&typeof Uint8Array.prototype.slice<"u"?new ArrayBuffer(e):new Array(e),u=Array.isArray(l)?l:new Uint8Array(l);for(i=0;i<t;i+=4)s=Ri[n.charCodeAt(i)],a=Ri[n.charCodeAt(i+1)],o=Ri[n.charCodeAt(i+2)],c=Ri[n.charCodeAt(i+3)],u[r++]=s<<2|a>>4,u[r++]=(a&15)<<4|o>>2,u[r++]=(o&3)<<6|c&63;return l},O1=function(n){for(var e=n.length,t=[],i=0;i<e;i+=2)t.push(n[i+1]<<8|n[i]);return t},A1=function(n){for(var e=n.length,t=[],i=0;i<e;i+=4)t.push(n[i+3]<<24|n[i+2]<<16|n[i+1]<<8|n[i]);return t},Tn=5,Wo=6+5,zo=2,N1=Wo-Tn,Kf=65536>>Tn,M1=1<<Tn,Ho=M1-1,L1=1024>>Tn,D1=Kf+L1,U1=D1,B1=32,F1=U1+B1,j1=65536>>Wo,V1=1<<N1,G1=V1-1,$f=function(n,e,t){return n.slice?n.slice(e,t):new Uint16Array(Array.prototype.slice.call(n,e,t))},W1=function(n,e,t){return n.slice?n.slice(e,t):new Uint32Array(Array.prototype.slice.call(n,e,t))},z1=function(n,e){var t=I1(n),i=Array.isArray(t)?A1(t):new Uint32Array(t),r=Array.isArray(t)?O1(t):new Uint16Array(t),s=24,a=$f(r,s/2,i[4]/2),o=i[5]===2?$f(r,(s+i[4])/2):W1(i,Math.ceil((s+i[4])/4));return new H1(i[0],i[1],i[2],i[3],a,o)},H1=function(){function n(e,t,i,r,s,a){this.initialValue=e,this.errorValue=t,this.highStart=i,this.highValueIndex=r,this.index=s,this.data=a}return n.prototype.get=function(e){var t;if(e>=0){if(e<55296||e>56319&&e<=65535)return t=this.index[e>>Tn],t=(t<<zo)+(e&Ho),this.data[t];if(e<=65535)return t=this.index[Kf+(e-55296>>Tn)],t=(t<<zo)+(e&Ho),this.data[t];if(e<this.highStart)return t=F1-j1+(e>>Wo),t=this.index[t],t+=e>>Tn&G1,t=this.index[t],t=(t<<zo)+(e&Ho),this.data[t];if(e<=1114111)return this.data[this.highValueIndex]}return this.errorValue},n}(),Yf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",q1=typeof Uint8Array>"u"?[]:new Uint8Array(256),Ss=0;Ss<Yf.length;Ss++)q1[Yf.charCodeAt(Ss)]=Ss;var Xf=null;function K1(n){return P1(this,void 0,void 0,function(){var e;return R1(this,function(t){switch(t.label){case 0:return Xf!==null?[3,2]:[4,n()];case 1:if(e=t.sent(),!e.base64||!e.byte_length)throw console.error("invalid graphemes response",e),new Error("Invalid graphemes response");Xf=z1(e.base64,e.byte_length),t.label=2;case 2:return[2]}})})}const $1=`:root,:host{--obi-modal-padding: 48px 48px 32px;--obi-modal-background-color: #FFFFFF;--obi-modal-border-radius: 12px;--obi-modal-shadow: 0px 1px 2px rgba(0, 0, 0, .05);--obi-modal-xsmall-width: 320px;--obi-modal-xsmall-height: 240px;--obi-modal-small-width: 480px;--obi-modal-small-height: 400px;--obi-modal-medium-width: 640px;--obi-modal-medium-height: 545px;--obi-modal-large-width: 1200px;--obi-modal-large-height: 700px;--obi-font-family: "Satoshi", sans-serif;--obi-color-primary: #9500FF;--obi-color-primary-50: color-mix(in srgb, var(--obi-color-primary) 50%, white 50%);--obi-color-primary-30: color-mix(in srgb, var(--obi-color-primary) 30%, white 70%);--obi-color-tint: color-mix(in srgb, var(--obi-color-primary) 5%, white 95%);--obi-color-text: #18181B;--obi-course-color-selected: var(--obi-color-primary-50);--obi-course-color-tint: var(--obi-color-tint);--obi-course-progress-step-completed: #B3B3B3;--obi-course-progress-step-incomplete: #D9D9D9;--obi-course-progress-text-color: #757575;font-family:var(--obi-font-family);color:var(--obi-color-text)}.obi-button{font-family:var(--obi-font-family);color:var(--obi-color-text)}dialog{margin:auto;padding:0;border:none;border-radius:var(--obi-modal-border-radius);box-shadow:var(--obi-modal-shadow);background:var(--obi-modal-background-color);box-sizing:border-box}dialog>.modal-content{padding:var(--obi-modal-padding);box-sizing:border-box}dialog,dialog.modal-medium,dialog>.modal-content,dialog.modal-medium>.modal-content{width:var(--obi-modal-medium-width);min-height:var(--obi-modal-medium-height)}dialog.modal-xsmall,dialog.modal-xsmall>.modal-content{width:var(--obi-modal-xsmall-width);min-height:var(--obi-modal-xsmall-height)}dialog.modal-small,dialog.modal-small>.modal-content{width:var(--obi-modal-small-width);min-height:var(--obi-modal-small-height)}dialog.modal-large,dialog.modal-large>.modal-content{width:var(--obi-modal-large-width);min-height:var(--obi-modal-large-height)}dialog::backdrop{background:rgba(0,0,0,.5)}.tour-content{display:block;width:100%;height:100%}.tour-content .container{box-sizing:border-box;display:flex;flex-direction:column;align-items:center;padding:0;width:100%;height:100%}.tour-content .header{display:flex;flex-direction:column;align-items:center;padding:0;gap:16px;width:100%}.tour-content .title{width:100%;font-family:Satoshi,sans-serif;font-style:normal;font-weight:700;font-size:32px;line-height:90%;text-align:center;letter-spacing:-.03em;color:#18181b;margin:0}.tour-content .subtitle{width:100%;font-family:Satoshi,sans-serif;font-style:normal;font-weight:400;font-size:16px;line-height:140%;text-align:center;letter-spacing:-.01em;color:#18181b;margin:0}.tour-content .visual{width:480px;height:240px;margin-top:24px;border-radius:12px;display:flex;align-items:center;justify-content:center;position:relative}.tour-content .description{width:100%;min-height:48px;margin:24px 0 0;font-family:Satoshi,sans-serif;font-style:normal;font-weight:400;font-size:16px;line-height:140%;text-align:center;letter-spacing:-.01em;color:#18181b}.tour-content .button-container{display:flex;margin-top:24px;flex-direction:column;align-items:center;gap:16px;width:100%}.tour-content .action-button{box-sizing:border-box;display:flex;flex-direction:row;justify-content:center;align-items:center;padding:12px;gap:8px;min-width:200px;height:40px;background:#303030;border:1px solid #303030;border-radius:4px;cursor:pointer;text-decoration:none}.tour-content .action-button.disabled{opacity:.6;cursor:not-allowed}.tour-content .button-text{height:16px;font-family:Satoshi,sans-serif;font-style:normal;font-weight:400;font-size:16px;line-height:100%;color:#fbf3ff}.tour.content-area{flex:1;display:flex;flex-direction:column}.obi-close-button{position:absolute;top:24px;right:24px;width:24px;height:24px;cursor:pointer;border:none;background:none;padding:0;display:flex;align-items:center;justify-content:center;z-index:1}.obi-panel{box-sizing:border-box;padding:24px;background-color:#fff;box-shadow:0 16px 32px -4px #0000001f,0 4px 8px -2px #00000014,inset 0 1px #fff9;border-radius:12px}.obi-pill.container{width:96px;height:30px;display:flex;align-items:center;justify-content:center}.obi-pill.container .pill{display:flex;align-items:center;justify-content:center;width:48px;height:6px;opacity:.7;border-radius:3px;background-color:var(--obi-color-primary);transition:width .15s ease-in-out,height .15s ease-in-out,border-radius .15s ease-in-out}.obi-pill.container .pill.button{cursor:pointer}.obi-pill.container.user-speaking .pill{background-color:var(--obi-color-primary-30)}.obi-pill.container.active .pill{width:96px;height:30px;border-radius:15px;opacity:1}.obi-pill.container.busy,.obi-pill.container.busy .pill{width:220px}.obi-pill2.container{display:flex;align-items:center;justify-content:center}.obi-pill2.container .pill{display:flex;align-items:center;justify-content:center;min-width:48px;max-width:48px;height:6px;opacity:.7;border-radius:3px;border:1px solid #FFFFFF1F;background-color:var(--obi-color-primary);transform:translateY(0);overflow:hidden;white-space:nowrap;flex:0 0 auto;box-sizing:border-box;padding-left:0;padding-right:0;transition:max-width .15s ease-in-out,min-width .15s ease-in-out,height .15s ease-in-out,border-radius .15s ease-in-out,padding-left .15s ease-in-out,padding-right .15s ease-in-out}.obi-pill2.container .pill.button{cursor:pointer}.obi-pill2.container:not(.active){transition:height 0s linear .15s;height:6px}.obi-pill2.container:not(.active) .pill{transform:translateY(12px);transition:transform 0s linear .15s,max-width .15s ease-in-out,min-width .15s ease-in-out,height .15s ease-in-out,border-radius .15s ease-in-out,padding-left .15s ease-in-out,padding-right .15s ease-in-out}.obi-pill2.container.active{transition:none;height:30px}.obi-pill2.container.active .pill{transition:transform 0s,max-width .15s ease-in-out,min-width .15s ease-in-out,height .15s ease-in-out,border-radius .15s ease-in-out,padding-left .15s ease-in-out,padding-right .15s ease-in-out;max-width:1000px;height:30px;border-radius:15px;opacity:1;padding-left:14px;padding-right:14px}.obi-pill2.container.user-speaking .pill{background-color:var(--obi-color-primary-30)}.obi-pill2.container:not(.active) .pill .text{opacity:0;animation:none}.obi-pill-up.container{display:flex;align-items:flex-end;justify-content:center}.obi-pill-up.container .pill{display:flex;align-items:center;justify-content:center;min-width:48px;max-width:48px;height:6px;opacity:.7;border-radius:3px;border:1px solid #FFFFFF1F;background-color:var(--obi-color-primary);overflow:hidden;white-space:nowrap;flex:0 0 auto;box-sizing:border-box;padding-left:0;padding-right:0;transition:max-width .15s ease-in-out,min-width .15s ease-in-out,height .15s ease-in-out,border-radius .15s ease-in-out,padding-left .15s ease-in-out,padding-right .15s ease-in-out}.obi-pill-up.container .pill.button{cursor:pointer}.obi-pill-up.container:not(.active){transition:height 0s linear .15s;height:6px}.obi-pill-up.container:not(.active) .pill{transition:max-width .15s ease-in-out,min-width .15s ease-in-out,height .15s ease-in-out,border-radius .15s ease-in-out,padding-left .15s ease-in-out,padding-right .15s ease-in-out}.obi-pill-up.container.active{transition:none;height:30px}.obi-pill-up.container.active .pill{transition:max-width .15s ease-in-out,min-width .15s ease-in-out,height .15s ease-in-out,border-radius .15s ease-in-out,padding-left .15s ease-in-out,padding-right .15s ease-in-out;max-width:1000px;height:30px;border-radius:15px;opacity:1;padding-left:14px;padding-right:14px}.obi-pill-up.container.user-speaking .pill{background-color:var(--obi-color-primary-30)}.obi-pill-up.container:not(.active) .pill .text{opacity:0;animation:none}.obi-popout{position:relative;display:inline-block}.obi-popout .obi-popout-target{cursor:pointer;display:inline-block}.obi-popout .content{position:absolute;background-color:#fff0;z-index:100;animation:popout-appear .15s ease-out}@keyframes popout-appear{0%{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}.obi-round-button-popout{z-index:600}.obi-round-button{flex:0 0 auto;display:flex;align-items:center;justify-content:center;width:30px;height:30px;border-radius:50%;padding:0;box-sizing:border-box;background-color:#fff;border:1px solid #D9D9D9;box-shadow:none}.obi-round-button:hover{cursor:pointer}.obi-round-button:disabled{box-shadow:none;background-color:#f0f0f0;color:#999;cursor:not-allowed!important;pointer-events:none}.obi-round-button-title{padding:8px 16px;border-radius:12px;background-color:#fff;color:#000;font-size:14px;font-weight:400;white-space:nowrap;box-shadow:0 4px 12px #00000026,0 2px 4px #0000001a;border:1px solid rgba(0,0,0,.08);z-index:5000;pointer-events:none;-webkit-user-select:none;user-select:none;position:relative}.obi-round-button-title:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);width:0;height:0;border-left:6px solid transparent;border-right:6px solid transparent;border-top:6px solid white;filter:drop-shadow(0 2px 2px rgba(0,0,0,.1))}.obi-equaliser{display:flex;align-items:center;gap:2px;height:32px}.obi-equaliser .column{position:relative;display:flex;align-items:center;justify-content:center;width:5px;height:100%}.obi-equaliser .bar{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:3px;border-radius:2px;z-index:1}.obi-message{display:inline-flex;align-items:center;justify-content:center;padding:0 15px;text-wrap:nowrap;font-size:16px;font-weight:400;height:30px;box-sizing:border-box;background-color:#fff;border-radius:15px;border:1px solid #D9D9D9}.obi-message.clickable{box-shadow:0 4px 6px #0000001a;cursor:pointer}.obi-loading-dots{display:flex;align-items:center;gap:2px;height:32px}.obi-loading-dots .column{position:relative;display:flex;align-items:center;justify-content:center;width:5px;height:100%}.obi-loading-dots .dot{width:3px;height:3px;border-radius:2px;position:relative;z-index:2}.obi-loading-dots .bar{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:3px;border-radius:2px;z-index:1;height:0px;animation:bounce .9s ease-in-out infinite}@keyframes bounce{0%,60%,to{height:0px}30%{height:16px}}.obi-exit-survey{position:relative;width:320px;margin:0 auto;-webkit-backdrop-filter:none;backdrop-filter:none;background:white;z-index:9999}.obi-exit-survey-container{display:flex;flex-direction:column;align-items:center;padding:0;gap:16px;width:272px;flex:none;align-self:stretch}.obi-exit-survey-header{display:flex;flex-direction:column;align-items:flex-start;padding:0;gap:4px;width:272px;flex:none;align-self:stretch}.obi-exit-survey-title{width:272px;height:22px;margin:0;font-family:Satoshi,sans-serif;font-size:16px;font-weight:600;line-height:140%;text-align:center;color:#1e1e1e;flex:none;align-self:stretch}.obi-exit-survey-subtitle{width:272px;height:20px;margin:0;font-family:Satoshi,sans-serif;font-style:normal;font-weight:400;font-size:14px;line-height:140%;text-align:center;color:#757575;flex:none;align-self:stretch}.obi-exit-survey-options{display:flex;flex-direction:column;align-items:flex-start;padding:0;gap:4px;width:272px;flex:none;align-self:stretch}.obi-exit-survey-options textarea{height:80px;resize:none;outline:none}.obi-exit-survey-button{box-sizing:border-box;display:flex;flex-direction:row;justify-content:center;align-items:center;padding:12px;gap:8px;width:272px;height:44px;border-radius:12px;cursor:pointer;font-family:Satoshi,sans-serif;font-style:normal;font-weight:400;font-size:14px;line-height:140%;flex:none;align-self:stretch;transition:all .2s ease}.obi-exit-survey-button:hover{transform:translateY(-1px);box-shadow:0 4px 8px #0000001a}.obi-exit-survey-button:active{transform:translateY(0)}.obi-exit-survey-button-continue{background:rgba(255,255,255);border:1px solid rgba(217,217,217);color:#1e1e1e}.obi-exit-survey-button-continue:hover{background:rgba(255,255,255);border-color:#d9d9d9}.obi-exit-survey-button-wrap-up{background:#303030;border:1px solid rgba(217,217,217);color:#fff;font-weight:500}.obi-exit-survey-button-wrap-up:hover{background:#404040;border-color:#d9d9d9}.obi-exit-survey-reason-button{background:rgba(255,255,255);border:1px solid rgba(217,217,217);color:#1e1e1e}.obi-exit-survey-reason-button:hover{background:rgba(255,255,255);border-color:#d9d9d9}.obi-exit-survey-reason-button-secondary{display:flex;flex-direction:row;justify-content:center;align-items:center;padding:4px 6px;gap:8px;width:272px;height:28px;border-radius:4px;cursor:pointer;border:none;background:transparent;font-family:Satoshi,sans-serif;font-style:normal;font-weight:400;font-size:14px;line-height:140%;color:#5a5a5a;flex:none;align-self:stretch;transition:all .2s ease}.obi-exit-survey-reason-button-secondary:hover{background:rgba(0,0,0,.05);color:#3a3a3a}.obi-message-input{display:inline-block;position:relative}.obi-message-input .container{width:212px;height:30px;box-sizing:border-box;background:#FFFFFF;border:1px solid var(--obi-color-primary-30);border-radius:15px;display:flex;align-items:center;flex:none;order:2;flex-grow:0;transition:height .3s ease,border-radius .3s ease;animation:expandMessageInput .2s cubic-bezier(.4,0,.2,1) 0s 1 normal both}.obi-message-input.expanded .container{height:auto;min-height:140px;border-radius:15px;align-items:flex-start;padding:8px 0;animation:expandMessageInputWide .2s cubic-bezier(.4,0,.2,1) 0s 1 normal both}.obi-message-input .field{flex:1 1 0;border:none;background:transparent;outline:none;font-family:Satoshi,sans-serif;font-style:normal;font-weight:400;font-size:14px;line-height:18px;color:#000;padding:4px 3px 0 16px;height:100%;box-sizing:border-box;min-width:0;resize:none;overflow:hidden;scrollbar-width:none;transition:padding .3s ease;animation:fadeInInputField .2s cubic-bezier(.4,0,.2,1) 0s 1 normal both}.obi-message-input.expanded .field{height:auto;min-height:120px;padding:4px 16px;overflow-y:auto;line-height:18px}.obi-message-input .field::placeholder{color:#999}.obi-message-input .field:disabled{cursor:not-allowed;opacity:.6}.obi-message-input .send{position:absolute;bottom:3px;right:4px;flex-shrink:0;width:24px;height:24px;background:var(--obi-color-primary);border:none;border-radius:9999px;display:flex;justify-content:center;align-items:center;cursor:pointer;transition:all .3s ease;color:#fff}.obi-message-input.expanded .send{width:28px;height:28px;position:relative;top:0;bottom:0;margin-right:0}.obi-message-input.expanded .button-container{display:flex;justify-content:space-between;align-items:center;width:100%;margin-top:8px}.obi-message-input .send:disabled{background:#CCCCCC;cursor:not-allowed;transform:none}.obi-message-input .container:focus-within{border-color:var(--obi-color-primary);box-shadow:0 0 0 2px #9008ff1a}@keyframes expandMessageInput{0%{width:32px}to{width:212px}}@keyframes expandMessageInputWide{0%{width:212px}to{width:340px}}@keyframes fadeInInputField{0%{opacity:0}60%{opacity:0}to{opacity:1}}.obi-course-progress{display:flex;flex-direction:column;justify-content:center;align-items:flex-start;gap:6px;width:100%;min-width:0;height:24px;flex:none;order:1;align-self:stretch;flex-grow:0}.obi-course-progress-steps{display:flex;flex-direction:row;align-items:center;justify-content:space-between;padding:0;gap:2px;width:100%;height:6px;flex:none;order:0;align-self:stretch;flex-grow:0}.obi-course-progress-container{display:flex;flex-direction:column;justify-content:center;align-items:stretch;padding:2px 0;height:6px;flex:1;min-width:0}.obi-course-progress-step{width:100%;height:2px;background:var(--obi-course-progress-step-incomplete);border-radius:24px;flex:none;order:0;align-self:stretch;flex-grow:0}.obi-course-progress-step.completed{background:var(--obi-course-progress-step-completed)}.obi-course-progress-description{width:100%;height:14px;font-family:var(--obi-font-family);font-style:normal;font-weight:500;font-size:14px;line-height:100%;color:var(--obi-course-progress-text-color);flex:none;order:1;flex-grow:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.obi-widget-popout{z-index:400}.obi-widget-panel{display:flex;flex-direction:column;gap:8px;align-items:center;justify-content:center;min-width:222px;width:min-content;padding:12px;box-sizing:border-box;border-radius:27px;background:white;transition:background .1s ease-out .1s,box-shadow .1s ease-out .1s}.obi-widget-panel:not(.messaging){width:256px}.obi-widget-panel.tool-usage{width:384px}.obi-widget-panel:not(.expanded){background:transparent;border:none;box-shadow:none;transition:background .1s ease-out .1s,border .1s ease-out .1s,box-shadow .1s ease-out .1s}.obi-widget-panel.maximized{transform:translateY(-110px)}.obi-widget-panel .obi-widget{display:flex;align-items:center;min-width:192px;padding-left:58px;box-sizing:border-box;gap:4px}.obi-widget-panel .obi-widget.active.in-plan{padding-left:0}.obi-widget-panel .obi-widget.active.in-plan .obi-round-button{animation:fade-in-button .2s ease-out .15s both}.obi-widget-panel .obi-widget.active .obi-equaliser{animation:fade-in-equaliser .2s ease-out .15s both}@keyframes fade-in-button{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes fade-in-equaliser{0%{opacity:0}to{opacity:1}}.obi-widget-panel .obi-course-progress-container{display:none;width:100%;max-height:0;opacity:0;transform:translateY(-10px);overflow:hidden;transition:max-height .3s ease-in-out,opacity .3s ease-in-out,transform .3s ease-in-out}.obi-widget-panel:hover .obi-course-progress-container{display:block;max-width:22 0px;animation:expand-course-progress .3s ease-in-out forwards}.obi-widget-panel:hover .obi-course-progress-container.expanded{max-width:330px}@keyframes expand-course-progress{0%{max-height:0;opacity:0;transform:translateY(-10px)}to{max-height:40px;opacity:1;transform:translateY(0)}}.obi-widget-pill-text{font-size:16px;font-weight:400;color:#fff;opacity:0;animation:fade-in-pill-text .3s ease-in-out forwards}@keyframes fade-in-pill-text{0%{opacity:0}40%{opacity:0}to{opacity:1}}.obi-widget-buttons{display:flex;flex-direction:row;gap:4px}.obi-widget-out-of-plan{display:flex;align-items:center;gap:0}.obi-widget-out-of-plan .text{font-size:16px;color:#fff;display:inline-flex;align-items:center;gap:8px;animation:fade-in-pill-text .3s ease-in-out forwards}.obi-widget-out-of-plan .round-button{display:none;animation:fade-in-button .2s ease-out .15s both}.obi-widget-out-of-plan .message{display:none}.obi-widget-out-of-plan.active{gap:0}.obi-widget-out-of-plan.active:hover,.obi-widget-out-of-plan.active.hover{gap:4px}.obi-widget-out-of-plan.active:hover .round-button,.obi-widget-out-of-plan.active:hover .message,.obi-widget-out-of-plan.active.hover .round-button,.obi-widget-out-of-plan.active.hover .message{display:flex}.obi-static-voice-visual{display:flex;align-items:center;gap:2px;height:32px}.obi-static-voice-visual .column{position:relative;display:flex;align-items:center;justify-content:center;width:5px;height:100%}.obi-static-voice-visual .bar{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:3px;background-color:#fff;border-radius:2px;z-index:1}.obi-static-voice-visual .bar-1{height:2px}.obi-static-voice-visual .bar-2{height:6px}.obi-static-voice-visual .bar-3{height:10px}.obi-static-voice-visual .bar-4,.obi-static-voice-visual .bar-5{height:16px}.obi-static-voice-visual .bar-6{height:10px}.obi-static-voice-visual .bar-7{height:6px}.obi-static-voice-visual .bar-8{height:2px}.tour-select{display:block;font-family:Inter,sans-serif}.course-container{display:flex;padding:20px;align-items:flex-start;gap:8px;height:180px;border-radius:6px;border:1px solid rgba(0,0,0,.6);background:#fff;cursor:pointer;transition:all .2s;flex-direction:column;box-sizing:border-box;overflow:hidden}.course-container:hover{background-color:#f9fafb;border-color:#d1d5db;box-shadow:0 1px 2px #0000000d}.course-container:active{transform:scale(.98)}.course-container.selected{border-radius:6px;border:1px solid var(--obi-course-color-selected);background:var(--obi-course-color-tint)}.course-container.selected:hover{background:var(--obi-course-color-tint)}.header-row{display:flex;justify-content:space-between;align-items:flex-start;align-self:stretch;flex-shrink:0;text-align:left}.course-title{color:#000;font-family:Inter,sans-serif;font-size:20px;font-style:normal;font-weight:500;line-height:100%;letter-spacing:-.2px;margin:0}.duration{display:flex;padding:4px 12px;justify-content:center;align-items:center;gap:8px;border-radius:9999px;background:var(--obi-course-color-tint);color:#000;font-family:Inter,sans-serif;font-size:14px;font-style:normal;font-weight:500;line-height:100%;letter-spacing:-.14px;flex-shrink:0}.course-container.selected .duration{background:#fff}.course-description{flex:1 0 0;color:#0009;font-family:Inter,sans-serif;font-size:16px;font-style:normal;font-weight:400;line-height:140%;letter-spacing:-.16px;margin:0;overflow:hidden;display:-webkit-box;-webkit-line-clamp:4;-webkit-box-orient:vertical;text-align:left}.course-grid{display:grid;grid-template-columns:1fr 1fr 1fr;gap:4px;padding:0;flex:1 0 0;align-self:stretch;min-height:364px}.controls{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px}.tabs{display:flex;gap:10px}.tab{display:flex;padding:6px 12px;justify-content:center;align-items:center;align-self:stretch;border:none;background:none;cursor:pointer;font-family:Inter,sans-serif;font-size:16px;font-weight:500;color:#0006;border-bottom:2px solid transparent;transition:all .2s}.tab.active{color:#000;border-bottom:2px solid var(--obi-color-primary)}.tab:hover{color:#000}.filter{position:relative;display:flex;align-items:center;width:336px;height:40px}.filter input{color:var(--obi-color-text);caret-color:var(--obi-color-text);padding:8px 12px 8px 36px;border-radius:6px;border:1px solid rgba(0,0,0,.1);background:#fff;font-family:Inter,sans-serif;font-size:14px;line-height:20px;width:100%;height:100%;box-sizing:border-box;outline:none}.filter input:focus{outline:1px solid var(--obi-color-primary);outline-offset:-1px}.filter input::placeholder{color:#0006}.filter svg{position:absolute;left:12px;pointer-events:none}@media (max-width: 767px){.course-grid{grid-template-columns:1fr}}.loading,.error,.empty{display:flex;justify-content:center;align-items:center;margin-top:16px}.error{color:#ef4444}.tour-select-modal-container{display:flex;flex-direction:column;align-items:center;gap:24px;flex:1 0 0;align-self:stretch;font-family:Satoshi,sans-serif;color:#000;text-align:center;max-width:1200px;width:100%;min-height:600px;box-sizing:border-box}.course-list-wrapper{flex:1;overflow-y:auto;width:100%;min-height:0;max-height:424px;padding-right:3px;box-sizing:border-box}.course-list-wrapper::-webkit-scrollbar{width:3px}.course-list-wrapper::-webkit-scrollbar-track{background:transparent}.course-list-wrapper::-webkit-scrollbar-thumb{background-color:#000;border-radius:2px;min-height:20px}.course-list-wrapper::-webkit-scrollbar-thumb:hover{background-color:#333}.header{display:flex;align-items:flex-start;gap:16px;width:100%;text-align:left}.icon{display:flex;width:56px;height:56px;padding:12px;justify-content:center;align-items:center;border-radius:12px;border:1px solid var(--obi-color-primary);background:var(--obi-color-primary);box-sizing:border-box}.icon img{width:32px;height:32px;color:#fff;fill:#fff}.title-section{align-self:stretch;flex:1}.tour-select-modal-container h1{color:#18181b;font-family:Satoshi;font-size:32px;font-style:normal;font-weight:700;line-height:90%;letter-spacing:-.96px;margin:0 0 8px}.subtitle{color:#18181b;font-family:Satoshi;font-size:20px;font-style:normal;font-weight:500;line-height:90%;letter-spacing:-.6px;margin:0}.footer{display:flex;width:360px;flex-direction:column;align-items:center;gap:12px}.footer-button{display:flex;height:48px;padding:16px;justify-content:center;align-items:center;gap:8px;align-self:stretch;border-radius:6px;background:#18181b;border:none;cursor:pointer;color:#fafafa;font-family:Satoshi;font-weight:500;transition:opacity .2s ease}.footer-button:disabled{opacity:.5;cursor:not-allowed}.footer-button:not(:disabled){opacity:1}.footer-button:not(:disabled):hover{background:#27272a}.footer-text{color:#18181b;font-family:Satoshi;font-size:12px;font-style:normal;font-weight:400;line-height:100%;letter-spacing:-.12px;margin:0;text-align:center}.skeleton{background:linear-gradient(90deg,#e5e7eb 25%,#f3f4f6 50%,#e5e7eb 75%);background-size:200% 100%;animation:loading 1.5s infinite;border-radius:4px}@keyframes loading{0%{background-position:200% 0}to{background-position:-200% 0}}.skeleton-title{height:32px;width:60%;margin-bottom:12px}.skeleton-subtitle{height:20px;width:80%}
55
+ `;function Y1(n){let e=n.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"__DOUBLE_STAR__").replace(/\*/g,"[^/]*").replace(/__DOUBLE_STAR__/g,".*").replace(/\?/g,"[^/]");return new RegExp(`^${e}$`,"i")}function X1(n,e){if(!e||e.length===0)return!1;const t=n.replace(/^https?:\/\//,"").replace(/\/$/,"");return e.some(i=>{try{const r=Y1(i);return r.test(t)||r.test(n)}catch(r){return console.warn(`Invalid URL pattern: ${i}`,r),!1}})}function qo(n){if(!n||n.length===0)return!1;const e=window.location.origin+window.location.pathname;return X1(e,n)}function J1(n){var C,_,R,I,D,U,V,G,z;const[e,t]=Y(!1),[i,r]=Y(!1),[s,a]=Y(null),o=Q1(n.sdk,c,n.shadowHost,a);function c(A){var j;(j=o.client)!=null&&j.session||t(A)}if(!o.client)return null;const l=o.client.planIsCompleted.filter(Boolean).length===o.client.plans.length,u=Z1((C=o.client.product)==null?void 0:C.widget_url_blacklist),d=l?o.completedWidgetDisplay||((_=o.client.product)==null?void 0:_.completed_widget_display):o.widgetDisplay||((R=o.client.product)==null?void 0:R.widget_display),h=o.widgetPosition||((I=o.client.product)==null?void 0:I.widget_position);let f=o.isActive;((U=(D=o.client)==null?void 0:D.product)==null?void 0:U.name)==="Canibuild"&&(f=!0);const p=o.client.session,g=!!p,v=g&&!e;let b;switch(p==null?void 0:p.speakingState){case"listening":b="user-speaking";break;case"speaking":b="agent-speaking";break;case"thinking":b="thinking";break;case"busy":b="busy";break}const S=p==null?void 0:p.isPaused,x=g||o.client.state==="ready"&&f&&!u&&(d!=="invisible"||o.client.selectedPlan),k=()=>{var A,j,K,Q,se,Me;return{name:(A=o.client.selectedPlan)==null?void 0:A.name,description:(j=o.client.selectedPlan)==null?void 0:j.description,appName:(K=o.client.product)==null?void 0:K.name,appLogoUrl:((Q=o.client.product)==null?void 0:Q.logo_url)||"",url:(se=o.client.product)==null?void 0:se.url,agentName:((Me=o.client.product)==null?void 0:Me.agent_name)||"Obi"}},T=h==="bottom-right"?{position:"fixed",right:"250px",width:"max-content",transform:"translateX(50%)"}:{position:"fixed",left:"50%",transform:"translateX(-50%)",width:"max-content"};return v?T.top="calc(100vh - 100px)":T.bottom="20px",m("div",{children:[e&&m(FC,{open:e,courses:o.client.plans.map((A,j)=>{var K,Q;return{id:A.uuid,name:A.name,description:A.description||"",duration:A.duration||0,completed:((Q=(K=o.client)==null?void 0:K.planIsCompleted)==null?void 0:Q[j])||!1}}),loading:!1,agentName:((V=o.client.product)==null?void 0:V.agent_name)||"Obi",productName:((G=o.client.product)==null?void 0:G.name)||"",onCourseHighlight:A=>{A&&Ei().track("course-selected",{courseName:A.name,courseUuid:A.id})},onCourseSelect:A=>{const j=o.client.plans.find(K=>K.uuid===A.id)||null;j&&(j==null?void 0:j.uuid)!==o.client.selectedPlanUuid&&(o.client.selectPlan(j),t(!1),r(!0),Ei().track("course-get-started",{courseName:A.name,courseUuid:A.id}))},onClose:A=>{A==="user-initiated"&&o.client.selectPlan(null),t(!1)}}),x&&m(Ne,{children:[m("div",{style:T,children:m(kC,{inPlan:g,isActive:i?!1:void 0,defaultIsActive:d!=="minimized",isPaused:S,messaging:(p==null?void 0:p.isMicShared)===!1?!0:void 0,speakingStatus:b,spectrum:()=>(p==null?void 0:p.audioSpectrum())||null,courseProgress:s,onOpen:()=>{t(!0)},onCancelClick:()=>{},onCancelAbort:()=>{},onCancel:()=>{var A;(A=o.client.session)==null||A.stop()},onCancelReason:(A,j)=>{},onPause:()=>{var A,j;(j=(A=o.client.session)==null?void 0:A.pause)==null||j.call(A)},onUnpause:()=>{var A,j;(j=(A=o.client.session)==null?void 0:A.unpause)==null||j.call(A)},onMessagingChange:A=>{var j,K,Q,se;A?(K=(j=o.client.session)==null?void 0:j.muteMicrophone)==null||K.call(j):(se=(Q=o.client.session)==null?void 0:Q.unmuteMicrophone)==null||se.call(Q)},onMessageChange:A=>{Ei().track("chat-input-provided",{message:A,length:A.length})},onMessage:A=>{o.say(A),Ei().track("chat-message-sent",{message:A,length:A.length})},onHover:A=>{},onOneClickAction:A=>{},onMinimize:()=>{},agentName:((z=o.client.product)==null?void 0:z.agent_name)||"Obi",completedTutorials:o.client.planIsCompleted.filter(Boolean).length,totalTutorials:o.client.plans.length})}),!!o.client.selectedPlan&&m(VC,{open:!0,session:k(),sessionState:(p==null?void 0:p.state)||null,speakingState:(p==null?void 0:p.speakingState)||null,spectrum:()=>(p==null?void 0:p.audioSpectrum())||null,onModalChange:A=>{},onClose:(A,j)=>{var K,Q;A==="user-initiated"&&(((K=o.client.session)==null?void 0:K.state)==="mic-share"?(Q=o.client.session)==null||Q.shareMicrophoneFailed():o.client.stopSession()),r(!1)},onStart:()=>{o.client.selectedPlanUuid&&o.startSession()},onContinue:()=>{p==null||p.continue()},onShareMicrophone:()=>{p==null||p.shareMicrophone()}})]})]})}function Q1(n,e,t,i){const[r,s]=Y(0),[a,o]=Y(null);return ze(()=>{n.on("showMenu",c=>{e(c)}),n.on("configUpdated",()=>{s(c=>c+1)})},[n]),ze(()=>{n.client&&(n.client.session&&o(n.client.session),n.client.on("sessionStarted",c=>{o(c),s(l=>l+1)}),n.client.on("sessionStopped",()=>{o(null),s(c=>c+1)}),n.client.on("sessionShutdown",()=>{s(c=>c+1)}),n.client.on("sessionResumed",()=>{s(c=>c+1)}),n.client.on("stateChanged",()=>{var c;n.client.state==="ready"&&t.style.setProperty("--obi-color-primary",((c=n.client.product)==null?void 0:c.primary_color)||"#9500FF"),s(l=>l+1)}),n.client.on("planSelected",()=>{s(c=>c+1)}))},[n,n.client]),ze(()=>{if(!a)return;a.on("stateChanged",()=>{s(l=>l+1)}),a.on("speakingStateChanged",()=>{s(l=>l+1)}),a.on("paused",()=>{s(l=>l+1)}),a.on("unpaused",()=>{s(l=>l+1)}),a.on("micCheckComplete",l=>{}),a.on("transcript",(l,u)=>{});const c=l=>{i(l)};return a.on&&a.on("courseProgress",c),()=>{a.off&&a.off("courseProgress",c)}},[a]),n}function Z1(n){const[e,t]=Y(()=>qo(n));return ze(()=>{t(qo(n))},[n]),ze(()=>{ex();const i=()=>{t(qo(n))};return window.addEventListener("locationchange",i),window.addEventListener("popstate",i),window.addEventListener("hashchange",i),()=>{window.removeEventListener("locationchange",i),window.removeEventListener("popstate",i),window.removeEventListener("hashchange",i)}},[n]),e}function ex(){const n=window;if(n.__obi_history_patched)return;const{pushState:e,replaceState:t}=window.history,i=r=>function(...s){const a=r.apply(this,s);return window.dispatchEvent(new Event("locationchange")),a};window.history.pushState=i(e),window.history.replaceState=i(t),n.__obi_history_patched=!0}function tx(n){if(document.querySelector("obi-widget"))return;nx();const e=document.createElement("div");e.id="obi-host",e.style.position="fixed",e.style.zIndex="9999",document.body.appendChild(e);const t=e.attachShadow({mode:"open"}),i=document.createElement("div");i.id="obi-container",t.appendChild(i);const r=new CSSStyleSheet;r.replaceSync($1),t.adoptedStyleSheets=[r],FS(m(J1,{sdk:n,shadowHost:e}),i),console.log("[obi-sdk] widget mounted")}function nx(){Jf("https://fonts.cdnfonts.com/css/satoshi"),Jf("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap")}function Jf(n){const e=document.createElement("link");e.href=n,e.rel="stylesheet",document.head.appendChild(e)}const Qf="49206C6F7665204F6269_session",Zf="obi-url-params";class ix extends Cs{constructor(e){super(),this.client=null,this.isActive=!1,this.primaryColour="#9500FF",this.passivePlanUuid=null,this.commandLog=[],this.commandQueue=[],this._resumed=!1,this.dispatchCommand=(t,i)=>{var r,s,a,o,c;switch(this.commandLog.push({commandType:t,args:i}),t){case"update":this.updateConfig(i);break;case"startSession":if(!(i!=null&&i.planUuid)){console.warn("[obi] startSession command requires a planUuid",i);return}const l=(((r=this.client)==null?void 0:r.plans)||[]).find(u=>u.uuid===i.planUuid)||null;if(!l){console.warn("[obi] startSession command requires a valid planUuid",i);return}this.updateActive(!0),(a=(s=this.client)==null?void 0:s.selectPlan)==null||a.call(s,l);break;case"stopSession":(c=(o=this.client)==null?void 0:o.stopSession)==null||c.call(o);break;case"say":this.say(i);break;default:console.warn("[obi] unknown command",{commandType:t,args:i})}},e&&this.createClient(e),this.parsePassiveParams()}async createClient(e){if(this.client){this.client.appToken!==e&&console.warn("[obi] client already exists with different app token");return}let t=null;const i=this.load();if(i)try{t=as.deserialise(i,e,"sdk",{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)}),t&&(this._resumed=!0)}catch(r){console.error("[obi] error loading cached client",r)}t||(t=new as(e,"sdk",{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)})),this.client=t,this.client.on("stateChanged",r=>{var s,a,o,c,l,u,d,h,f;r==="ready"&&this.updateConfig({isActive:(s=this.client)==null?void 0:s.showWidget,primaryColour:((o=(a=this.client)==null?void 0:a.product)==null?void 0:o.primary_color)||"#9500FF",widgetDisplay:((c=window==null?void 0:window.obiWidgetConfig)==null?void 0:c.widgetDisplay)||((u=(l=this.client)==null?void 0:l.product)==null?void 0:u.widget_display)||"regular",completedWidgetDisplay:((d=window==null?void 0:window.obiWidgetConfig)==null?void 0:d.completedWidgetDisplay)||((f=(h=this.client)==null?void 0:h.product)==null?void 0:f.completed_widget_display)||"regular"})}),this.client.on("sessionStarted",()=>{this.save(),this.passivePlanUuid=null}),this.client.on("sessionStopped",()=>{localStorage.removeItem("obi-client"),this.passivePlanUuid=null}),this.client.on("sessionShutdown",r=>{r==="invalid-room"&&localStorage.removeItem("obi-client")}),this.client.on("trackEvent",(r,s)=>{}),this.client.session&&this.client.resumeSession(r=>{r.on("stateChanged",s=>{s!=="disconnecting"&&s!=="disconnected"&&s!=="error"&&s!=="connecting"&&this.save()}),r.on("paused",()=>{this.save()}),r.on("unpaused",()=>{this.save()})})}async initialise(e={}){this.commandQueue=e.queuedCommands||[],this._resumed?(this._resumed=!1,this.dispatchCommandQueue()):this.client?this.client.initialise({planUuid:this.passivePlanUuid||void 0}).then(()=>{this.emit("initialised"),this.dispatchCommandQueue()}).catch(t=>{console.error("[obi] error initialising client",t),this.emit("error",t)}):this.dispatchCommandQueue()}async updateConfig(e){await this.updateAppToken(e.apiKey),this.updateActive(e.isActive),this.updatePrimaryColour(e.primaryColour),this.updateWidgetDisplay(e.widgetDisplay),this.updateCompletedWidgetDisplay(e.completedWidgetDisplay),this.updateWidgetPosition(e.widgetPosition),await this.updateIdentity(e.user),this.updateShowMenu(e.showMenu),this.emit("configUpdated")}async updateAppToken(e){var t;e===void 0||e==((t=this.client)==null?void 0:t.appToken)||(this.passivePlanUuid,await this.createClient(e),this.client&&await this.client.initialise({planUuid:this.passivePlanUuid||void 0}).then(()=>{this.emit("initialised")}).catch(i=>{console.error("[obi] error initialising client",i),this.emit("error",i)}))}updateActive(e){e===void 0||e==this.isActive||(this.isActive=e)}updatePrimaryColour(e){e===void 0||e==this.primaryColour||(this.primaryColour=e)}updateWidgetDisplay(e){e===void 0||e==this.widgetDisplay||(this.widgetDisplay=e)}updateCompletedWidgetDisplay(e){e===void 0||e==this.completedWidgetDisplay||(this.completedWidgetDisplay=e)}updateWidgetPosition(e){e===void 0||e==this.widgetPosition||(this.widgetPosition=e)}async updateIdentity(e){var i;if(e===void 0||e==((i=this.client)==null?void 0:i.identity))return;let t=e?{...e,extra:{...e,...(e==null?void 0:e.extra)||{}}}:void 0;await this.client.initialise({identity:t,planUuid:this.passivePlanUuid||void 0}).then(()=>{this.emit("initialised")}).catch(r=>{console.error("[obi] error initialising client",r),this.emit("error",r)}),e!=null&&e.email&&Ei().identify((e==null?void 0:e.email)||"",t)}updateShowMenu(e){e!==void 0&&this.emit("showMenu",e)}async say(e){var t,i,r;await((r=(i=(t=this.client)==null?void 0:t.session)==null?void 0:i.say)==null?void 0:r.call(i,e))}async startSession(){await this.client.startSession(this.client.selectedPlanUuid,e=>{e.on("stateChanged",t=>{t!=="disconnecting"&&t!=="disconnected"&&t!=="error"&&t!=="connecting"&&this.save()})})}dispatchCommandQueue(){const e=this.commandQueue;this.commandQueue=[],e.forEach(t=>{try{this.dispatchCommand(t[0],t[1]||[])}catch(i){console.error("[obi] error dispatching command",i)}})}parsePassiveParams(){if(this.passivePlanUuid){this.passivePlanUuid;return}let e={};e=JSON.parse(localStorage.getItem(Zf)||"{}"),Object.keys(e).length===0&&new URLSearchParams(window.location.search).forEach((s,a)=>{e[a]=s});const t=e[Qf];if(!t)return null;const i=new URL(window.location.href);i.searchParams.delete(Qf),window.history.replaceState({},"",i.toString()),i.toString(),localStorage.removeItem(Zf),this.passivePlanUuid=t}mountWidget(){tx(this)}async captureScreen(){try{await _1(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.text_segmentation)),await K1(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.css_line_breaks))}catch(e){throw console.error("[obi] error initialising unicode trie",e),e}try{return(await Hb(document.documentElement,{useCORS:!0,allowTaint:!0,foreignObjectRendering:!0})).toDataURL("image/png")}catch(e){throw console.error("[obi] error capturing screen",e),e}}save(){var e;localStorage.setItem("obi-client",((e=this.client)==null?void 0:e.serialise())||"")}load(){return localStorage.getItem("obi-client")}}async function ep(n,e){let t;try{t=window}catch{console.warn("[obi] no window object found"),t={}}return rx({appToken:n,window:t,init:e})}async function rx({appToken:n,window:e,init:t}){var s,a;if(e.obi){console.warn("[obi] obi object already found on window, skipping");return}t&&t(),n||(n=(s=e==null?void 0:e.obiWidgetConfig)==null?void 0:s.apiKey);let i;try{i=((a=e.ObiSDK)==null?void 0:a.q)||[]}catch{i=[]}const r=new ix(n);return e.ObiSDK=r.dispatchCommand,await r.initialise({queuedCommands:i}),e.obi=r,r.mountWidget(),r}function tp(){}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{ep(void 0,tp)}):ep(void 0,tp)})();