@vkontakte/videoplayer-core 2.0.102-beta.3 → 2.0.103-dev.c555938f.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/es2015.cjs.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @vkontakte/videoplayer-core v2.0.102-beta.3
3
- * Tue, 21 May 2024 11:58:06 GMT
4
- * https://st.mycdn.me/static/vkontakte-videoplayer/2-0-102/doc/
2
+ * @vkontakte/videoplayer-core v2.0.103-dev.c555938f.0
3
+ * Tue, 28 May 2024 09:13:35 GMT
4
+ * https://st.mycdn.me/static/vkontakte-videoplayer/2-0-103/doc/
5
5
  */
6
- "use strict";var Vu=Object.create;var Ya=Object.defineProperty;var Fu=Object.getOwnPropertyDescriptor;var Uu=Object.getOwnPropertyNames;var ju=Object.getPrototypeOf,Hu=Object.prototype.hasOwnProperty;var Gu=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Uu(e))!Hu.call(i,s)&&s!==t&&Ya(i,s,{get:()=>e[s],enumerable:!(r=Fu(e,s))||r.enumerable});return i};var Yu=(i,e,t)=>(t=i!=null?Vu(ju(i)):{},Gu(e||!i||!i.__esModule?Ya(t,"default",{value:i,enumerable:!0}):t,i));var a=require("@vkontakte/videoplayer-shared/es2015.cjs.js");const Bo="2.0.102-beta.3";exports.PlaybackState=void 0;(function(i){i.STOPPED="stopped",i.READY="ready",i.PLAYING="playing",i.PAUSED="paused"})(exports.PlaybackState||(exports.PlaybackState={}));exports.VideoFormat=void 0;(function(i){i.MPEG="MPEG",i.DASH="DASH_SEP",i.DASH_SEP="DASH_SEP",i.DASH_SEP_VK="DASH_SEP",i.DASH_WEBM="DASH_WEBM",i.DASH_WEBM_AV1="DASH_WEBM_AV1",i.DASH_WEBM_VK="DASH_WEBM",i.DASH_ONDEMAND="DASH_ONDEMAND",i.DASH_ONDEMAND_VK="DASH_ONDEMAND",i.DASH_LIVE="DASH_LIVE",i.DASH_LIVE_CMAF="DASH_LIVE_CMAF",i.DASH_LIVE_WEBM="DASH_LIVE_WEBM",i.HLS="HLS",i.HLS_ONDEMAND="HLS_ONDEMAND",i.HLS_JS="HLS",i.HLS_LIVE="HLS_LIVE",i.HLS_LIVE_CMAF="HLS_LIVE_CMAF",i.WEB_RTC_LIVE="WEB_RTC_LIVE"})(exports.VideoFormat||(exports.VideoFormat={}));var le;(function(i){i.SCREEN="SCREEN",i.CHROMECAST="CHROMECAST"})(le||(le={}));exports.ChromecastState=void 0;(function(i){i.NOT_AVAILABLE="NOT_AVAILABLE",i.AVAILABLE="AVAILABLE",i.CONNECTING="CONNECTING",i.CONNECTED="CONNECTED"})(exports.ChromecastState||(exports.ChromecastState={}));exports.HttpConnectionType=void 0;(function(i){i.HTTP1="http1",i.HTTP2="http2",i.QUIC="quic"})(exports.HttpConnectionType||(exports.HttpConnectionType={}));var N;(function(i){i.None="none",i.Requested="requested",i.Applying="applying"})(N||(N={}));exports.Surface=void 0;(function(i){i.NONE="none",i.INLINE="inline",i.FULLSCREEN="fullscreen",i.SECOND_SCREEN="second_screen",i.PIP="pip"})(exports.Surface||(exports.Surface={}));function G(i,e,t,r){function s(n){return n instanceof t?n:new t(function(o){o(n)})}return new(t||(t=Promise))(function(n,o){function l(c){try{u(r.next(c))}catch(h){o(h)}}function d(c){try{u(r.throw(c))}catch(h){o(h)}}function u(c){c.done?n(c.value):s(c.value).then(l,d)}u((r=r.apply(i,e||[])).next())})}function C(i){return this instanceof C?(this.v=i,this):new C(i)}function fe(i,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(i,e||[]),s,n=[];return s={},o("next"),o("throw"),o("return"),s[Symbol.asyncIterator]=function(){return this},s;function o(f){r[f]&&(s[f]=function(p){return new Promise(function(v,m){n.push([f,p,v,m])>1||l(f,p)})})}function l(f,p){try{d(r[f](p))}catch(v){h(n[0][3],v)}}function d(f){f.value instanceof C?Promise.resolve(f.value.v).then(u,c):h(n[0][2],f)}function u(f){l("next",f)}function c(f){l("throw",f)}function h(f,p){f(p),n.shift(),n.length&&l(n[0][0],n[0][1])}}var qu=i=>new Promise((e,t)=>{const r=document.createElement("script");r.setAttribute("src",i),r.onload=()=>e,r.onerror=()=>t,document.body.appendChild(r)});class Wu{constructor(e){var t;this.connection$=new a.ValueSubject(void 0),this.castState$=new a.ValueSubject(exports.ChromecastState.NOT_AVAILABLE),this.errorEvent$=new a.Subject,this.realCastState$=new a.ValueSubject(exports.ChromecastState.NOT_AVAILABLE),this.subscription=new a.Subscription,this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastInitializer");const r="chrome"in window;if(this.log({message:`[constructor] receiverApplicationId: ${this.params.receiverApplicationId}, isDisabled: ${this.params.isDisabled}, isSupported: ${r}`}),e.isDisabled||!r)return;const s=a.isNonNullable((t=window.chrome)===null||t===void 0?void 0:t.cast),n=!!window.__onGCastApiAvailable;s?this.initializeCastApi():(window.__onGCastApiAvailable=o=>{delete window.__onGCastApiAvailable,o&&this.initializeCastApi()},n||qu("https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1").catch(()=>this.errorEvent$.next({id:"ChromecastLoading",category:a.ErrorCategory.NETWORK,message:"Script loading failed!"})))}connect(){var e;(e=cast.framework.CastContext.getInstance())===null||e===void 0||e.requestSession()}disconnect(){var e,t;(t=(e=cast.framework.CastContext.getInstance())===null||e===void 0?void 0:e.getCurrentSession())===null||t===void 0||t.endSession(!0)}stopMedia(){return new Promise((e,t)=>{var r,s,n;(n=(s=(r=cast.framework.CastContext.getInstance())===null||r===void 0?void 0:r.getCurrentSession())===null||s===void 0?void 0:s.getMediaSession())===null||n===void 0||n.stop(new chrome.cast.media.StopRequest,e,t)})}toggleConnection(){a.isNonNullable(this.connection$.getValue())?this.disconnect():this.connect()}setVolume(e){const t=this.connection$.getValue();a.isNullable(t)||(t.remotePlayer.volumeLevel=e,t.remotePlayerController.setVolumeLevel())}setMuted(e){const t=this.connection$.getValue();a.isNullable(t)||e!==t.remotePlayer.isMuted&&t.remotePlayerController.muteOrUnmute()}destroy(){this.subscription.unsubscribe()}initListeners(){const e=new cast.framework.RemotePlayer,t=new cast.framework.RemotePlayerController(e),r=cast.framework.CastContext.getInstance();this.subscription.add(a.fromEvent(r,cast.framework.CastContextEventType.SESSION_STATE_CHANGED).subscribe(s=>{var n,o;switch(s.sessionState){case cast.framework.SessionState.SESSION_STARTED:case cast.framework.SessionState.SESSION_STARTING:case cast.framework.SessionState.SESSION_RESUMED:this.contentId=(o=(n=r.getCurrentSession())===null||n===void 0?void 0:n.getMediaSession())===null||o===void 0?void 0:o.media.contentId;break;case cast.framework.SessionState.NO_SESSION:case cast.framework.SessionState.SESSION_ENDING:case cast.framework.SessionState.SESSION_ENDED:case cast.framework.SessionState.SESSION_START_FAILED:this.contentId=void 0;break;default:return a.assertNever(s.sessionState)}})).add(a.merge(a.fromEvent(r,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe(a.tap(s=>{this.log({message:`[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: ${JSON.stringify(s)}`})}),a.map(s=>s.castState)),a.observableFrom([r.getCastState()])).pipe(a.filterChanged(),a.map(zu),a.tap(s=>{this.log({message:`realCastState$: ${s}`})})).subscribe(this.realCastState$)).add(this.realCastState$.subscribe(s=>{var n;const o=s===exports.ChromecastState.CONNECTED,l=a.isNonNullable(this.connection$.getValue());if(o&&!l){const d=r.getCurrentSession();a.assertNonNullable(d);const u=d.getCastDevice(),c=(n=d.getMediaSession())===null||n===void 0?void 0:n.media.contentId;(a.isNullable(c)||c===this.contentId)&&(this.log({message:"connection created"}),this.connection$.next({remotePlayer:e,remotePlayerController:t,session:d,castDevice:u}))}else!o&&l&&(this.log({message:"connection destroyed"}),this.connection$.next(void 0));this.castState$.next(s===exports.ChromecastState.CONNECTED?a.isNonNullable(this.connection$.getValue())?exports.ChromecastState.CONNECTED:exports.ChromecastState.AVAILABLE:s)}))}initializeCastApi(){var e;let t,r,s;try{t=cast.framework.CastContext.getInstance(),r=chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,s=chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}catch(n){return}try{t.setOptions({receiverApplicationId:(e=this.params.receiverApplicationId)!==null&&e!==void 0?e:r,autoJoinPolicy:s}),this.initListeners()}catch(n){this.errorEvent$.next({id:"ChromecastInitializer",category:a.ErrorCategory.EXTERNAL_API,message:"[initializeCastApi] failed",thrown:n})}}}const zu=i=>{switch(i){case cast.framework.CastState.NO_DEVICES_AVAILABLE:return exports.ChromecastState.NOT_AVAILABLE;case cast.framework.CastState.NOT_CONNECTED:return exports.ChromecastState.AVAILABLE;case cast.framework.CastState.CONNECTING:return exports.ChromecastState.CONNECTING;case cast.framework.CastState.CONNECTED:return exports.ChromecastState.CONNECTED;default:return a.assertNever(i)}};var xr=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function lr(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Ee=function(i){try{return!!i()}catch(e){return!0}},Qu=Ee,ur=!Qu(function(){var i=function(){}.bind();return typeof i!="function"||i.hasOwnProperty("prototype")}),Vo=ur,Fo=Function.prototype,_s=Fo.call,Ku=Vo&&Fo.bind.bind(_s,_s),$e=Vo?Ku:function(i){return function(){return _s.apply(i,arguments)}},Uo=$e,Ju=Uo({}.toString),Xu=Uo("".slice),hi=function(i){return Xu(Ju(i),8,-1)},Zu=$e,ec=Ee,tc=hi,Nr=Object,ic=Zu("".split),rc=ec(function(){return!Nr("z").propertyIsEnumerable(0)})?function(i){return tc(i)=="String"?ic(i,""):Nr(i)}:Nr,fi=function(i){return i==null},sc=fi,ac=TypeError,ra=function(i){if(sc(i))throw ac("Can't call method on "+i);return i},nc=rc,oc=ra,pi=function(i){return nc(oc(i))},Yt={},Ci=function(i){return i&&i.Math==Math&&i},ne=Ci(typeof globalThis=="object"&&globalThis)||Ci(typeof window=="object"&&window)||Ci(typeof self=="object"&&self)||Ci(typeof xr=="object"&&xr)||function(){return this}()||xr||Function("return this")(),Ds=typeof document=="object"&&document.all,lc=typeof Ds=="undefined"&&Ds!==void 0,jo={all:Ds,IS_HTMLDDA:lc},Ho=jo,uc=Ho.all,ie=Ho.IS_HTMLDDA?function(i){return typeof i=="function"||i===uc}:function(i){return typeof i=="function"},cc=ne,dc=ie,qa=cc.WeakMap,hc=dc(qa)&&/native code/.test(String(qa)),Wa=ie,Go=jo,fc=Go.all,Ye=Go.IS_HTMLDDA?function(i){return typeof i=="object"?i!==null:Wa(i)||i===fc}:function(i){return typeof i=="object"?i!==null:Wa(i)},pc=Ee,et=!pc(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),mt={},mc=ne,za=Ye,Ls=mc.document,vc=za(Ls)&&za(Ls.createElement),sa=function(i){return vc?Ls.createElement(i):{}},Sc=et,bc=Ee,gc=sa,Yo=!Sc&&!bc(function(){return Object.defineProperty(gc("div"),"a",{get:function(){return 7}}).a!=7}),yc=et,Tc=Ee,qo=yc&&Tc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),Ec=Ye,$c=String,kc=TypeError,qe=function(i){if(Ec(i))return i;throw kc($c(i)+" is not an object")},Pc=ur,Ii=Function.prototype.call,ve=Pc?Ii.bind(Ii):function(){return Ii.apply(Ii,arguments)},aa={},Or=aa,Mr=ne,Ac=ie,Qa=function(i){return Ac(i)?i:void 0},vt=function(i,e){return arguments.length<2?Qa(Or[i])||Qa(Mr[i]):Or[i]&&Or[i][e]||Mr[i]&&Mr[i][e]},wc=$e,cr=wc({}.isPrototypeOf),dr=typeof navigator!="undefined"&&String(navigator.userAgent)||"",Wo=ne,Br=dr,Ka=Wo.process,Ja=Wo.Deno,Xa=Ka&&Ka.versions||Ja&&Ja.version,Za=Xa&&Xa.v8,Ae,Zi;Za&&(Ae=Za.split("."),Zi=Ae[0]>0&&Ae[0]<4?1:+(Ae[0]+Ae[1]));!Zi&&Br&&(Ae=Br.match(/Edge\/(\d+)/),(!Ae||Ae[1]>=74)&&(Ae=Br.match(/Chrome\/(\d+)/),Ae&&(Zi=+Ae[1])));var zo=Zi,en=zo,Cc=Ee,Ic=ne,Rc=Ic.String,Qo=!!Object.getOwnPropertySymbols&&!Cc(function(){var i=Symbol();return!Rc(i)||!(Object(i)instanceof Symbol)||!Symbol.sham&&en&&en<41}),_c=Qo,Ko=_c&&!Symbol.sham&&typeof Symbol.iterator=="symbol",Dc=vt,Lc=ie,xc=cr,Nc=Ko,Oc=Object,Jo=Nc?function(i){return typeof i=="symbol"}:function(i){var e=Dc("Symbol");return Lc(e)&&xc(e.prototype,Oc(i))},Mc=String,hr=function(i){try{return Mc(i)}catch(e){return"Object"}},Bc=ie,Vc=hr,Fc=TypeError,St=function(i){if(Bc(i))return i;throw Fc(Vc(i)+" is not a function")},Uc=St,jc=fi,fr=function(i,e){var t=i[e];return jc(t)?void 0:Uc(t)},Vr=ve,Fr=ie,Ur=Ye,Hc=TypeError,Gc=function(i,e){var t,r;if(e==="string"&&Fr(t=i.toString)&&!Ur(r=Vr(t,i))||Fr(t=i.valueOf)&&!Ur(r=Vr(t,i))||e!=="string"&&Fr(t=i.toString)&&!Ur(r=Vr(t,i)))return r;throw Hc("Can't convert object to primitive value")},Xo={exports:{}},Yc=!0,tn=ne,qc=Object.defineProperty,Wc=function(i,e){try{qc(tn,i,{value:e,configurable:!0,writable:!0})}catch(t){tn[i]=e}return e},zc=ne,Qc=Wc,rn="__core-js_shared__",Kc=zc[rn]||Qc(rn,{}),na=Kc,sn=na;(Xo.exports=function(i,e){return sn[i]||(sn[i]=e!==void 0?e:{})})("versions",[]).push({version:"3.31.0",mode:"pure",copyright:"\xA9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.31.0/LICENSE",source:"https://github.com/zloirock/core-js"});var Zo=Xo.exports,Jc=ra,Xc=Object,pr=function(i){return Xc(Jc(i))},Zc=$e,ed=pr,td=Zc({}.hasOwnProperty),Be=Object.hasOwn||function(e,t){return td(ed(e),t)},id=$e,rd=0,sd=Math.random(),ad=id(1 .toString),el=function(i){return"Symbol("+(i===void 0?"":i)+")_"+ad(++rd+sd,36)},nd=ne,od=Zo,an=Be,ld=el,ud=Qo,cd=Ko,Mt=nd.Symbol,jr=od("wks"),dd=cd?Mt.for||Mt:Mt&&Mt.withoutSetter||ld,de=function(i){return an(jr,i)||(jr[i]=ud&&an(Mt,i)?Mt[i]:dd("Symbol."+i)),jr[i]},hd=ve,nn=Ye,on=Jo,fd=fr,pd=Gc,md=de,vd=TypeError,Sd=md("toPrimitive"),bd=function(i,e){if(!nn(i)||on(i))return i;var t=fd(i,Sd),r;if(t){if(e===void 0&&(e="default"),r=hd(t,i,e),!nn(r)||on(r))return r;throw vd("Can't convert object to primitive value")}return e===void 0&&(e="number"),pd(i,e)},gd=bd,yd=Jo,oa=function(i){var e=gd(i,"string");return yd(e)?e:e+""},Td=et,Ed=Yo,$d=qo,Ri=qe,ln=oa,kd=TypeError,Hr=Object.defineProperty,Pd=Object.getOwnPropertyDescriptor,Gr="enumerable",Yr="configurable",qr="writable";mt.f=Td?$d?function(e,t,r){if(Ri(e),t=ln(t),Ri(r),typeof e=="function"&&t==="prototype"&&"value"in r&&qr in r&&!r[qr]){var s=Pd(e,t);s&&s[qr]&&(e[t]=r.value,r={configurable:Yr in r?r[Yr]:s[Yr],enumerable:Gr in r?r[Gr]:s[Gr],writable:!1})}return Hr(e,t,r)}:Hr:function(e,t,r){if(Ri(e),t=ln(t),Ri(r),Ed)try{return Hr(e,t,r)}catch(s){}if("get"in r||"set"in r)throw kd("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var mr=function(i,e){return{enumerable:!(i&1),configurable:!(i&2),writable:!(i&4),value:e}},Ad=et,wd=mt,Cd=mr,mi=Ad?function(i,e,t){return wd.f(i,e,Cd(1,t))}:function(i,e,t){return i[e]=t,i},Id=Zo,Rd=el,un=Id("keys"),la=function(i){return un[i]||(un[i]=Rd(i))},ua={},_d=hc,tl=ne,Dd=Ye,Ld=mi,Wr=Be,zr=na,xd=la,Nd=ua,cn="Object already initialized",xs=tl.TypeError,Od=tl.WeakMap,er,li,tr,Md=function(i){return tr(i)?li(i):er(i,{})},Bd=function(i){return function(e){var t;if(!Dd(e)||(t=li(e)).type!==i)throw xs("Incompatible receiver, "+i+" required");return t}};if(_d||zr.state){var _e=zr.state||(zr.state=new Od);_e.get=_e.get,_e.has=_e.has,_e.set=_e.set,er=function(i,e){if(_e.has(i))throw xs(cn);return e.facade=i,_e.set(i,e),e},li=function(i){return _e.get(i)||{}},tr=function(i){return _e.has(i)}}else{var It=xd("state");Nd[It]=!0,er=function(i,e){if(Wr(i,It))throw xs(cn);return e.facade=i,Ld(i,It,e),e},li=function(i){return Wr(i,It)?i[It]:{}},tr=function(i){return Wr(i,It)}}var il={set:er,get:li,has:tr,enforce:Md,getterFor:Bd},Vd=ur,rl=Function.prototype,dn=rl.apply,hn=rl.call,sl=typeof Reflect=="object"&&Reflect.apply||(Vd?hn.bind(dn):function(){return hn.apply(dn,arguments)}),Fd=hi,Ud=$e,al=function(i){if(Fd(i)==="Function")return Ud(i)},ca={},nl={},ol={}.propertyIsEnumerable,ll=Object.getOwnPropertyDescriptor,jd=ll&&!ol.call({1:2},1);nl.f=jd?function(e){var t=ll(this,e);return!!t&&t.enumerable}:ol;var Hd=et,Gd=ve,Yd=nl,qd=mr,Wd=pi,zd=oa,Qd=Be,Kd=Yo,fn=Object.getOwnPropertyDescriptor;ca.f=Hd?fn:function(e,t){if(e=Wd(e),t=zd(t),Kd)try{return fn(e,t)}catch(r){}if(Qd(e,t))return qd(!Gd(Yd.f,e,t),e[t])};var Jd=Ee,Xd=ie,Zd=/#|\.prototype\./,vi=function(i,e){var t=th[eh(i)];return t==rh?!0:t==ih?!1:Xd(e)?Jd(e):!!e},eh=vi.normalize=function(i){return String(i).replace(Zd,".").toLowerCase()},th=vi.data={},ih=vi.NATIVE="N",rh=vi.POLYFILL="P",ul=vi,pn=al,sh=St,ah=ur,nh=pn(pn.bind),vr=function(i,e){return sh(i),e===void 0?i:ah?nh(i,e):function(){return i.apply(e,arguments)}},_i=ne,oh=sl,lh=al,uh=ie,ch=ca.f,dh=ul,Rt=aa,hh=vr,_t=mi,mn=Be,fh=function(i){var e=function(t,r,s){if(this instanceof e){switch(arguments.length){case 0:return new i;case 1:return new i(t);case 2:return new i(t,r)}return new i(t,r,s)}return oh(i,this,arguments)};return e.prototype=i.prototype,e},Ce=function(i,e){var t=i.target,r=i.global,s=i.stat,n=i.proto,o=r?_i:s?_i[t]:(_i[t]||{}).prototype,l=r?Rt:Rt[t]||_t(Rt,t,{})[t],d=l.prototype,u,c,h,f,p,v,m,S,b;for(f in e)u=dh(r?f:t+(s?".":"#")+f,i.forced),c=!u&&o&&mn(o,f),v=l[f],c&&(i.dontCallGetSet?(b=ch(o,f),m=b&&b.value):m=o[f]),p=c&&m?m:e[f],!(c&&typeof v==typeof p)&&(i.bind&&c?S=hh(p,_i):i.wrap&&c?S=fh(p):n&&uh(p)?S=lh(p):S=p,(i.sham||p&&p.sham||v&&v.sham)&&_t(S,"sham",!0),_t(l,f,S),n&&(h=t+"Prototype",mn(Rt,h)||_t(Rt,h,{}),_t(Rt[h],f,p),i.real&&d&&(u||!d[f])&&_t(d,f,p)))},Ns=et,ph=Be,cl=Function.prototype,mh=Ns&&Object.getOwnPropertyDescriptor,da=ph(cl,"name"),vh=da&&function(){}.name==="something",Sh=da&&(!Ns||Ns&&mh(cl,"name").configurable),bh={EXISTS:da,PROPER:vh,CONFIGURABLE:Sh},dl={},gh=Math.ceil,yh=Math.floor,Th=Math.trunc||function(e){var t=+e;return(t>0?yh:gh)(t)},Eh=Th,ha=function(i){var e=+i;return e!==e||e===0?0:Eh(e)},$h=ha,kh=Math.max,Ph=Math.min,Ah=function(i,e){var t=$h(i);return t<0?kh(t+e,0):Ph(t,e)},wh=ha,Ch=Math.min,Ih=function(i){return i>0?Ch(wh(i),9007199254740991):0},Rh=Ih,fa=function(i){return Rh(i.length)},_h=pi,Dh=Ah,Lh=fa,vn=function(i){return function(e,t,r){var s=_h(e),n=Lh(s),o=Dh(r,n),l;if(i&&t!=t){for(;n>o;)if(l=s[o++],l!=l)return!0}else for(;n>o;o++)if((i||o in s)&&s[o]===t)return i||o||0;return!i&&-1}},xh={includes:vn(!0),indexOf:vn(!1)},Nh=$e,Qr=Be,Oh=pi,Mh=xh.indexOf,Bh=ua,Sn=Nh([].push),Vh=function(i,e){var t=Oh(i),r=0,s=[],n;for(n in t)!Qr(Bh,n)&&Qr(t,n)&&Sn(s,n);for(;e.length>r;)Qr(t,n=e[r++])&&(~Mh(s,n)||Sn(s,n));return s},hl=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Fh=Vh,Uh=hl,jh=Object.keys||function(e){return Fh(e,Uh)},Hh=et,Gh=qo,Yh=mt,qh=qe,Wh=pi,zh=jh;dl.f=Hh&&!Gh?Object.defineProperties:function(e,t){qh(e);for(var r=Wh(t),s=zh(t),n=s.length,o=0,l;n>o;)Yh.f(e,l=s[o++],r[l]);return e};var Qh=vt,fl=Qh("document","documentElement"),Kh=qe,Jh=dl,bn=hl,Xh=ua,Zh=fl,ef=sa,tf=la,gn=">",yn="<",Os="prototype",Ms="script",pl=tf("IE_PROTO"),Kr=function(){},ml=function(i){return yn+Ms+gn+i+yn+"/"+Ms+gn},Tn=function(i){i.write(ml("")),i.close();var e=i.parentWindow.Object;return i=null,e},rf=function(){var i=ef("iframe"),e="java"+Ms+":",t;return i.style.display="none",Zh.appendChild(i),i.src=String(e),t=i.contentWindow.document,t.open(),t.write(ml("document.F=Object")),t.close(),t.F},Di,Qi=function(){try{Di=new ActiveXObject("htmlfile")}catch(e){}Qi=typeof document!="undefined"?document.domain&&Di?Tn(Di):rf():Tn(Di);for(var i=bn.length;i--;)delete Qi[Os][bn[i]];return Qi()};Xh[pl]=!0;var vl=Object.create||function(e,t){var r;return e!==null?(Kr[Os]=Kh(e),r=new Kr,Kr[Os]=null,r[pl]=e):r=Qi(),t===void 0?r:Jh.f(r,t)},sf=Ee,af=!sf(function(){function i(){}return i.prototype.constructor=null,Object.getPrototypeOf(new i)!==i.prototype}),nf=Be,of=ie,lf=pr,uf=la,cf=af,En=uf("IE_PROTO"),Bs=Object,df=Bs.prototype,Sl=cf?Bs.getPrototypeOf:function(i){var e=lf(i);if(nf(e,En))return e[En];var t=e.constructor;return of(t)&&e instanceof t?t.prototype:e instanceof Bs?df:null},hf=mi,pa=function(i,e,t,r){return r&&r.enumerable?i[e]=t:hf(i,e,t),i},ff=Ee,pf=ie,mf=Ye,vf=vl,$n=Sl,Sf=pa,bf=de,Vs=bf("iterator"),bl=!1,He,Jr,Xr;[].keys&&(Xr=[].keys(),"next"in Xr?(Jr=$n($n(Xr)),Jr!==Object.prototype&&(He=Jr)):bl=!0);var gf=!mf(He)||ff(function(){var i={};return He[Vs].call(i)!==i});gf?He={}:He=vf(He);pf(He[Vs])||Sf(He,Vs,function(){return this});var gl={IteratorPrototype:He,BUGGY_SAFARI_ITERATORS:bl},yf=de,Tf=yf("toStringTag"),yl={};yl[Tf]="z";var ma=String(yl)==="[object z]",Ef=ma,$f=ie,Ki=hi,kf=de,Pf=kf("toStringTag"),Af=Object,wf=Ki(function(){return arguments}())=="Arguments",Cf=function(i,e){try{return i[e]}catch(t){}},Si=Ef?Ki:function(i){var e,t,r;return i===void 0?"Undefined":i===null?"Null":typeof(t=Cf(e=Af(i),Pf))=="string"?t:wf?Ki(e):(r=Ki(e))=="Object"&&$f(e.callee)?"Arguments":r},If=ma,Rf=Si,_f=If?{}.toString:function(){return"[object "+Rf(this)+"]"},Df=ma,Lf=mt.f,xf=mi,Nf=Be,Of=_f,Mf=de,kn=Mf("toStringTag"),va=function(i,e,t,r){if(i){var s=t?i:i.prototype;Nf(s,kn)||Lf(s,kn,{configurable:!0,value:e}),r&&!Df&&xf(s,"toString",Of)}},Bf=gl.IteratorPrototype,Vf=vl,Ff=mr,Uf=va,jf=Yt,Hf=function(){return this},Gf=function(i,e,t,r){var s=e+" Iterator";return i.prototype=Vf(Bf,{next:Ff(+!r,t)}),Uf(i,s,!1,!0),jf[s]=Hf,i},Yf=Ce,qf=ve,Tl=bh,Wf=Gf,zf=Sl,Qf=va,Pn=pa,Kf=de,An=Yt,El=gl,Jf=Tl.PROPER;Tl.CONFIGURABLE;El.IteratorPrototype;var Li=El.BUGGY_SAFARI_ITERATORS,Zr=Kf("iterator"),wn="keys",xi="values",Cn="entries",Xf=function(){return this},Zf=function(i,e,t,r,s,n,o){Wf(t,e,r);var l=function(b){if(b===s&&f)return f;if(!Li&&b in c)return c[b];switch(b){case wn:return function(){return new t(this,b)};case xi:return function(){return new t(this,b)};case Cn:return function(){return new t(this,b)}}return function(){return new t(this)}},d=e+" Iterator",u=!1,c=i.prototype,h=c[Zr]||c["@@iterator"]||s&&c[s],f=!Li&&h||l(s),p=e=="Array"&&c.entries||h,v,m,S;if(p&&(v=zf(p.call(new i)),v!==Object.prototype&&v.next&&(Qf(v,d,!0,!0),An[d]=Xf)),Jf&&s==xi&&h&&h.name!==xi&&(u=!0,f=function(){return qf(h,this)}),s)if(m={values:l(xi),keys:n?f:l(wn),entries:l(Cn)},o)for(S in m)(Li||u||!(S in c))&&Pn(c,S,m[S]);else Yf({target:e,proto:!0,forced:Li||u},m);return o&&c[Zr]!==f&&Pn(c,Zr,f,{name:s}),An[e]=f,m},ep=function(i,e){return{value:i,done:e}},tp=pi,In=Yt,$l=il;mt.f;var ip=Zf,Ni=ep,kl="Array Iterator",rp=$l.set,sp=$l.getterFor(kl);ip(Array,"Array",function(i,e){rp(this,{type:kl,target:tp(i),index:0,kind:e})},function(){var i=sp(this),e=i.target,t=i.kind,r=i.index++;return!e||r>=e.length?(i.target=void 0,Ni(void 0,!0)):t=="keys"?Ni(r,!1):t=="values"?Ni(e[r],!1):Ni([r,e[r]],!1)},"values");In.Arguments=In.Array;var ap=de,np=Yt,op=ap("iterator"),lp=Array.prototype,up=function(i){return i!==void 0&&(np.Array===i||lp[op]===i)},cp=Si,Rn=fr,dp=fi,hp=Yt,fp=de,pp=fp("iterator"),Pl=function(i){if(!dp(i))return Rn(i,pp)||Rn(i,"@@iterator")||hp[cp(i)]},mp=ve,vp=St,Sp=qe,bp=hr,gp=Pl,yp=TypeError,Tp=function(i,e){var t=arguments.length<2?gp(i):e;if(vp(t))return Sp(mp(t,i));throw yp(bp(i)+" is not iterable")},Ep=ve,_n=qe,$p=fr,kp=function(i,e,t){var r,s;_n(i);try{if(r=$p(i,"return"),!r){if(e==="throw")throw t;return t}r=Ep(r,i)}catch(n){s=!0,r=n}if(e==="throw")throw t;if(s)throw r;return _n(r),t},Pp=vr,Ap=ve,wp=qe,Cp=hr,Ip=up,Rp=fa,Dn=cr,_p=Tp,Dp=Pl,Ln=kp,Lp=TypeError,Ji=function(i,e){this.stopped=i,this.result=e},xn=Ji.prototype,Sa=function(i,e,t){var r=t&&t.that,s=!!(t&&t.AS_ENTRIES),n=!!(t&&t.IS_RECORD),o=!!(t&&t.IS_ITERATOR),l=!!(t&&t.INTERRUPTED),d=Pp(e,r),u,c,h,f,p,v,m,S=function(y){return u&&Ln(u,"normal",y),new Ji(!0,y)},b=function(y){return s?(wp(y),l?d(y[0],y[1],S):d(y[0],y[1])):l?d(y,S):d(y)};if(n)u=i.iterator;else if(o)u=i;else{if(c=Dp(i),!c)throw Lp(Cp(i)+" is not iterable");if(Ip(c)){for(h=0,f=Rp(i);f>h;h++)if(p=b(i[h]),p&&Dn(xn,p))return p;return new Ji(!1)}u=_p(i,c)}for(v=n?i.next:u.next;!(m=Ap(v,u)).done;){try{p=b(m.value)}catch(y){Ln(u,"throw",y)}if(typeof p=="object"&&p&&Dn(xn,p))return p}return new Ji(!1)},xp=oa,Np=mt,Op=mr,Mp=function(i,e,t){var r=xp(e);r in i?Np.f(i,r,Op(0,t)):i[r]=t},Bp=Ce,Vp=Sa,Fp=Mp;Bp({target:"Object",stat:!0},{fromEntries:function(e){var t={};return Vp(e,function(r,s){Fp(t,r,s)},{AS_ENTRIES:!0}),t}});var Up=aa,jp=Up.Object.fromEntries,Hp={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},Gp=Hp,Yp=ne,qp=Si,Wp=mi,Nn=Yt,zp=de,On=zp("toStringTag");for(var es in Gp){var Mn=Yp[es],ts=Mn&&Mn.prototype;ts&&qp(ts)!==On&&Wp(ts,On,es),Nn[es]=Nn.Array}var Qp=jp,Kp=Qp,Jp=Kp,Xp=Jp,ir=lr(Xp),Zp=hi,Sr=typeof process!="undefined"&&Zp(process)=="process",em=mt,tm=function(i,e,t){return em.f(i,e,t)},im=vt,rm=tm,sm=de,am=et,Bn=sm("species"),nm=function(i){var e=im(i);am&&e&&!e[Bn]&&rm(e,Bn,{configurable:!0,get:function(){return this}})},om=cr,lm=TypeError,um=function(i,e){if(om(e,i))return i;throw lm("Incorrect invocation")},cm=$e,dm=ie,Fs=na,hm=cm(Function.toString);dm(Fs.inspectSource)||(Fs.inspectSource=function(i){return hm(i)});var Al=Fs.inspectSource,fm=$e,pm=Ee,wl=ie,mm=Si,vm=vt,Sm=Al,Cl=function(){},bm=[],Il=vm("Reflect","construct"),ba=/^\s*(?:class|function)\b/,gm=fm(ba.exec),ym=!ba.exec(Cl),ei=function(e){if(!wl(e))return!1;try{return Il(Cl,bm,e),!0}catch(t){return!1}},Rl=function(e){if(!wl(e))return!1;switch(mm(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return ym||!!gm(ba,Sm(e))}catch(t){return!0}};Rl.sham=!0;var Tm=!Il||pm(function(){var i;return ei(ei.call)||!ei(Object)||!ei(function(){i=!0})||i})?Rl:ei,Em=Tm,$m=hr,km=TypeError,Pm=function(i){if(Em(i))return i;throw km($m(i)+" is not a constructor")},Vn=qe,Am=Pm,wm=fi,Cm=de,Im=Cm("species"),_l=function(i,e){var t=Vn(i).constructor,r;return t===void 0||wm(r=Vn(t)[Im])?e:Am(r)},Rm=$e,_m=Rm([].slice),Dm=TypeError,Lm=function(i,e){if(i<e)throw Dm("Not enough arguments");return i},xm=dr,Dl=/(?:ipad|iphone|ipod).*applewebkit/i.test(xm),me=ne,Nm=sl,Om=vr,Fn=ie,Mm=Be,Ll=Ee,Un=fl,Bm=_m,jn=sa,Vm=Lm,Fm=Dl,Um=Sr,Us=me.setImmediate,js=me.clearImmediate,jm=me.process,is=me.Dispatch,Hm=me.Function,Hn=me.MessageChannel,Gm=me.String,rs=0,si={},Gn="onreadystatechange",ui,ot,ss,as;Ll(function(){ui=me.location});var ga=function(i){if(Mm(si,i)){var e=si[i];delete si[i],e()}},ns=function(i){return function(){ga(i)}},Yn=function(i){ga(i.data)},qn=function(i){me.postMessage(Gm(i),ui.protocol+"//"+ui.host)};(!Us||!js)&&(Us=function(e){Vm(arguments.length,1);var t=Fn(e)?e:Hm(e),r=Bm(arguments,1);return si[++rs]=function(){Nm(t,void 0,r)},ot(rs),rs},js=function(e){delete si[e]},Um?ot=function(i){jm.nextTick(ns(i))}:is&&is.now?ot=function(i){is.now(ns(i))}:Hn&&!Fm?(ss=new Hn,as=ss.port2,ss.port1.onmessage=Yn,ot=Om(as.postMessage,as)):me.addEventListener&&Fn(me.postMessage)&&!me.importScripts&&ui&&ui.protocol!=="file:"&&!Ll(qn)?(ot=qn,me.addEventListener("message",Yn,!1)):Gn in jn("script")?ot=function(i){Un.appendChild(jn("script"))[Gn]=function(){Un.removeChild(this),ga(i)}}:ot=function(i){setTimeout(ns(i),0)});var xl={set:Us,clear:js},Nl=function(){this.head=null,this.tail=null};Nl.prototype={add:function(i){var e={item:i,next:null},t=this.tail;t?t.next=e:this.head=e,this.tail=e},get:function(){var i=this.head;if(i){var e=this.head=i.next;return e===null&&(this.tail=null),i.item}}};var Ol=Nl,Ym=dr,qm=/ipad|iphone|ipod/i.test(Ym)&&typeof Pebble!="undefined",Wm=dr,zm=/web0s(?!.*chrome)/i.test(Wm),ft=ne,Wn=vr,Qm=ca.f,os=xl.set,Km=Ol,Jm=Dl,Xm=qm,Zm=zm,ls=Sr,zn=ft.MutationObserver||ft.WebKitMutationObserver,Qn=ft.document,Kn=ft.process,Oi=ft.Promise,Jn=Qm(ft,"queueMicrotask"),Hs=Jn&&Jn.value,Dt,us,cs,Mi,Xn;if(!Hs){var Bi=new Km,Vi=function(){var i,e;for(ls&&(i=Kn.domain)&&i.exit();e=Bi.get();)try{e()}catch(t){throw Bi.head&&Dt(),t}i&&i.enter()};!Jm&&!ls&&!Zm&&zn&&Qn?(us=!0,cs=Qn.createTextNode(""),new zn(Vi).observe(cs,{characterData:!0}),Dt=function(){cs.data=us=!us}):!Xm&&Oi&&Oi.resolve?(Mi=Oi.resolve(void 0),Mi.constructor=Oi,Xn=Wn(Mi.then,Mi),Dt=function(){Xn(Vi)}):ls?Dt=function(){Kn.nextTick(Vi)}:(os=Wn(os,ft),Dt=function(){os(Vi)}),Hs=function(i){Bi.head||Dt(),Bi.add(i)}}var ev=Hs,tv=function(i,e){try{arguments.length==1?console.error(i):console.error(i,e)}catch(t){}},ya=function(i){try{return{error:!1,value:i()}}catch(e){return{error:!0,value:e}}},iv=ne,qt=iv.Promise,Ml=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",rv=Ml,sv=Sr,av=!rv&&!sv&&typeof window=="object"&&typeof document=="object",nv=ne,ai=qt,ov=ie,lv=ul,uv=Al,cv=de,dv=av,hv=Ml,ds=zo,Zn=ai&&ai.prototype,fv=cv("species"),Gs=!1,Bl=ov(nv.PromiseRejectionEvent),pv=lv("Promise",function(){var i=uv(ai),e=i!==String(ai);if(!e&&ds===66||!(Zn.catch&&Zn.finally))return!0;if(!ds||ds<51||!/native code/.test(i)){var t=new ai(function(n){n(1)}),r=function(n){n(function(){},function(){})},s=t.constructor={};if(s[fv]=r,Gs=t.then(function(){})instanceof r,!Gs)return!0}return!e&&(dv||hv)&&!Bl}),bi={CONSTRUCTOR:pv,REJECTION_EVENT:Bl,SUBCLASSING:Gs},Wt={},eo=St,mv=TypeError,vv=function(i){var e,t;this.promise=new i(function(r,s){if(e!==void 0||t!==void 0)throw mv("Bad Promise constructor");e=r,t=s}),this.resolve=eo(e),this.reject=eo(t)};Wt.f=function(i){return new vv(i)};var Sv=Ce,rr=Sr,Ze=ne,gi=ve,bv=pa,gv=va,yv=nm,Tv=St,Ys=ie,Ev=Ye,$v=um,kv=_l,Vl=xl.set,Ta=ev,Pv=tv,Av=ya,wv=Ol,Fl=il,qs=qt,Ea=bi,Ul=Wt,br="Promise",jl=Ea.CONSTRUCTOR,Cv=Ea.REJECTION_EVENT;Ea.SUBCLASSING;var hs=Fl.getterFor(br),Iv=Fl.set,Rv=qs&&qs.prototype,Bt=qs,fs=Rv,Hl=Ze.TypeError,Ws=Ze.document,$a=Ze.process,zs=Ul.f,_v=zs,Dv=!!(Ws&&Ws.createEvent&&Ze.dispatchEvent),Gl="unhandledrejection",Lv="rejectionhandled",to=0,Yl=1,xv=2,ka=1,ql=2,Fi,io,Nv,Wl=function(i){var e;return Ev(i)&&Ys(e=i.then)?e:!1},zl=function(i,e){var t=e.value,r=e.state==Yl,s=r?i.ok:i.fail,n=i.resolve,o=i.reject,l=i.domain,d,u,c;try{s?(r||(e.rejection===ql&&Mv(e),e.rejection=ka),s===!0?d=t:(l&&l.enter(),d=s(t),l&&(l.exit(),c=!0)),d===i.promise?o(Hl("Promise-chain cycle")):(u=Wl(d))?gi(u,d,n,o):n(d)):o(t)}catch(h){l&&!c&&l.exit(),o(h)}},Ql=function(i,e){i.notified||(i.notified=!0,Ta(function(){for(var t=i.reactions,r;r=t.get();)zl(r,i);i.notified=!1,e&&!i.rejection&&Ov(i)}))},Kl=function(i,e,t){var r,s;Dv?(r=Ws.createEvent("Event"),r.promise=e,r.reason=t,r.initEvent(i,!1,!0),Ze.dispatchEvent(r)):r={promise:e,reason:t},!Cv&&(s=Ze["on"+i])?s(r):i===Gl&&Pv("Unhandled promise rejection",t)},Ov=function(i){gi(Vl,Ze,function(){var e=i.facade,t=i.value,r=ro(i),s;if(r&&(s=Av(function(){rr?$a.emit("unhandledRejection",t,e):Kl(Gl,e,t)}),i.rejection=rr||ro(i)?ql:ka,s.error))throw s.value})},ro=function(i){return i.rejection!==ka&&!i.parent},Mv=function(i){gi(Vl,Ze,function(){var e=i.facade;rr?$a.emit("rejectionHandled",e):Kl(Lv,e,i.value)})},Vt=function(i,e,t){return function(r){i(e,r,t)}},Ut=function(i,e,t){i.done||(i.done=!0,t&&(i=t),i.value=e,i.state=xv,Ql(i,!0))},Qs=function(i,e,t){if(!i.done){i.done=!0,t&&(i=t);try{if(i.facade===e)throw Hl("Promise can't be resolved itself");var r=Wl(e);r?Ta(function(){var s={done:!1};try{gi(r,e,Vt(Qs,s,i),Vt(Ut,s,i))}catch(n){Ut(s,n,i)}}):(i.value=e,i.state=Yl,Ql(i,!1))}catch(s){Ut({done:!1},s,i)}}};jl&&(Bt=function(e){$v(this,fs),Tv(e),gi(Fi,this);var t=hs(this);try{e(Vt(Qs,t),Vt(Ut,t))}catch(r){Ut(t,r)}},fs=Bt.prototype,Fi=function(e){Iv(this,{type:br,done:!1,notified:!1,parent:!1,reactions:new wv,rejection:!1,state:to,value:void 0})},Fi.prototype=bv(fs,"then",function(e,t){var r=hs(this),s=zs(kv(this,Bt));return r.parent=!0,s.ok=Ys(e)?e:!0,s.fail=Ys(t)&&t,s.domain=rr?$a.domain:void 0,r.state==to?r.reactions.add(s):Ta(function(){zl(s,r)}),s.promise}),io=function(){var i=new Fi,e=hs(i);this.promise=i,this.resolve=Vt(Qs,e),this.reject=Vt(Ut,e)},Ul.f=zs=function(i){return i===Bt||i===Nv?new io(i):_v(i)});Sv({global:!0,constructor:!0,wrap:!0,forced:jl},{Promise:Bt});gv(Bt,br,!1,!0);yv(br);var Bv=de,Jl=Bv("iterator"),Xl=!1;try{var Vv=0,so={next:function(){return{done:!!Vv++}},return:function(){Xl=!0}};so[Jl]=function(){return this},Array.from(so,function(){throw 2})}catch(i){}var Fv=function(i,e){if(!e&&!Xl)return!1;var t=!1;try{var r={};r[Jl]=function(){return{next:function(){return{done:t=!0}}}},i(r)}catch(s){}return t},Uv=qt,jv=Fv,Hv=bi.CONSTRUCTOR,Zl=Hv||!jv(function(i){Uv.all(i).then(void 0,function(){})}),Gv=Ce,Yv=ve,qv=St,Wv=Wt,zv=ya,Qv=Sa,Kv=Zl;Gv({target:"Promise",stat:!0,forced:Kv},{all:function(e){var t=this,r=Wv.f(t),s=r.resolve,n=r.reject,o=zv(function(){var l=qv(t.resolve),d=[],u=0,c=1;Qv(e,function(h){var f=u++,p=!1;c++,Yv(l,t,h).then(function(v){p||(p=!0,d[f]=v,--c||s(d))},n)}),--c||s(d)});return o.error&&n(o.value),r.promise}});var Jv=Ce,Xv=bi.CONSTRUCTOR,ao=qt;ao&&ao.prototype;Jv({target:"Promise",proto:!0,forced:Xv,real:!0},{catch:function(i){return this.then(void 0,i)}});var Zv=Ce,eS=ve,tS=St,iS=Wt,rS=ya,sS=Sa,aS=Zl;Zv({target:"Promise",stat:!0,forced:aS},{race:function(e){var t=this,r=iS.f(t),s=r.reject,n=rS(function(){var o=tS(t.resolve);sS(e,function(l){eS(o,t,l).then(r.resolve,s)})});return n.error&&s(n.value),r.promise}});var nS=Ce,oS=ve,lS=Wt,uS=bi.CONSTRUCTOR;nS({target:"Promise",stat:!0,forced:uS},{reject:function(e){var t=lS.f(this);return oS(t.reject,void 0,e),t.promise}});var cS=qe,dS=Ye,hS=Wt,eu=function(i,e){if(cS(i),dS(e)&&e.constructor===i)return e;var t=hS.f(i),r=t.resolve;return r(e),t.promise},fS=Ce,pS=vt,mS=Yc,vS=qt,SS=bi.CONSTRUCTOR,bS=eu,gS=pS("Promise"),yS=!SS;fS({target:"Promise",stat:!0,forced:mS},{resolve:function(e){return bS(yS&&this===gS?vS:this,e)}});var TS=Ce,Ks=qt,ES=Ee,$S=vt,kS=ie,PS=_l,no=eu,AS=Ks&&Ks.prototype,wS=!!Ks&&ES(function(){AS.finally.call({then:function(){}},function(){})});TS({target:"Promise",proto:!0,real:!0,forced:wS},{finally:function(i){var e=PS(this,$S("Promise")),t=kS(i);return this.then(t?function(r){return no(e,i()).then(function(){return r})}:i,t?function(r){return no(e,i()).then(function(){throw r})}:i)}});var CS=vt,Pa=CS,IS=Pa,RS=IS("Promise","finally"),_S=RS,DS=_S,LS=DS,xS=LS,Aa=lr(xS),re;(function(i){i[i.OFFSET_P=0]="OFFSET_P",i[i.PLAYBACK_SHIFT=1]="PLAYBACK_SHIFT",i[i.DASH_CMAF_OFFSET_P=2]="DASH_CMAF_OFFSET_P"})(re||(re={}));var we=(i,e=0,t=re.OFFSET_P)=>{switch(t){case re.OFFSET_P:return i.replace("_offset_p",e===0?"":"_"+e.toFixed(0));case re.PLAYBACK_SHIFT:{if(e===0)return i;const r=new URL(i);return r.searchParams.append("playback_shift",e.toFixed(0)),r.toString()}case re.DASH_CMAF_OFFSET_P:{const r=new URL(i);return!r.searchParams.get("offset_p")&&e===0?i:(r.searchParams.set("offset_p",e.toFixed(0)),r.toString())}default:a.assertNever(t)}return i};const oo=(i,e)=>{var t;switch(e){case re.OFFSET_P:return NaN;case re.PLAYBACK_SHIFT:{const r=new URL(i);return Number(r.searchParams.get("playback_shift"))}case re.DASH_CMAF_OFFSET_P:{const r=new URL(i);return Number((t=r.searchParams.get("offset_p"))!==null&&t!==void 0?t:0)}default:a.assertNever(e)}};var w=(i,e,t=!1)=>{const r=i.getTransition();(t||!r||r.to===e)&&i.setState(e)};class Z{constructor(e){this.transitionStarted$=new a.Subject,this.transitionEnded$=new a.Subject,this.transitionUpdated$=new a.Subject,this.forceChanged$=new a.Subject,this.stateChangeStarted$=a.merge(this.transitionStarted$,this.transitionUpdated$),this.stateChangeEnded$=a.merge(this.transitionEnded$,this.forceChanged$),this.state=e,this.prevState=void 0}setState(e){const t=this.transition,r=this.state;this.transition=void 0,this.prevState=r,this.state=e,t?t.to===e?this.transitionEnded$.next(t):this.forceChanged$.next({from:t.from,to:e,canceledTransition:t}):this.forceChanged$.next({from:r,to:e,canceledTransition:t})}startTransitionTo(e){const t=this.transition,r=this.state;r===e||a.isNonNullable(t)&&t.to===e||(this.prevState=r,this.state=e,t?(this.transition={from:t.from,to:e,canceledTransition:t},this.transitionUpdated$.next(this.transition)):(this.transition={from:r,to:e},this.transitionStarted$.next(this.transition)))}getTransition(){return this.transition}getState(){return this.state}getPrevState(){return this.prevState}}const NS=i=>{switch(i){case exports.VideoFormat.MPEG:case exports.VideoFormat.DASH_SEP:case exports.VideoFormat.DASH_ONDEMAND:case exports.VideoFormat.DASH_WEBM:case exports.VideoFormat.DASH_WEBM_AV1:case exports.VideoFormat.HLS:case exports.VideoFormat.HLS_ONDEMAND:return!1;case exports.VideoFormat.DASH_LIVE:case exports.VideoFormat.DASH_LIVE_CMAF:case exports.VideoFormat.HLS_LIVE:case exports.VideoFormat.HLS_LIVE_CMAF:case exports.VideoFormat.DASH_LIVE_WEBM:case exports.VideoFormat.WEB_RTC_LIVE:return!0;default:return a.assertNever(i)}};var D;(function(i){i.STOPPED="stopped",i.READY="ready",i.PLAYING="playing",i.PAUSED="paused"})(D||(D={}));const OS=5,MS=5,BS=500,lo=7e3;class VS{constructor(e){this.subscription=new a.Subscription,this.loadMediaTimeoutSubscription=new a.Subscription,this.videoState=new Z(D.STOPPED),this.syncPlayback=()=>{const r=this.videoState.getState(),s=this.videoState.getTransition(),n=this.params.desiredState.playbackState.getState(),o=this.params.desiredState.playbackState.getTransition(),l=this.params.desiredState.seekState.getState();if(this.log({message:`[syncPlayback] videoState: ${r}; videoTransition: ${JSON.stringify(s)}; desiredPlaybackState: ${n}; desiredPlaybackStateTransition: ${this.params.desiredState.playbackState.getTransition()}; seekState: ${JSON.stringify(l)};`}),n===exports.PlaybackState.STOPPED){r!==D.STOPPED&&(this.videoState.startTransitionTo(D.STOPPED),this.stop());return}if(!s){if((o==null?void 0:o.to)!==exports.PlaybackState.PAUSED&&l.state===N.Requested&&r!==D.STOPPED){this.seek(l.position/1e3);return}switch(n){case exports.PlaybackState.READY:{switch(r){case D.PLAYING:case D.PAUSED:case D.READY:break;case D.STOPPED:this.videoState.startTransitionTo(D.READY),this.prepare();break;default:a.assertNever(r)}break}case exports.PlaybackState.PLAYING:{switch(r){case D.PLAYING:break;case D.PAUSED:this.videoState.startTransitionTo(D.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case D.READY:this.videoState.startTransitionTo(D.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case D.STOPPED:this.videoState.startTransitionTo(D.READY),this.prepare();break;default:a.assertNever(r)}break}case exports.PlaybackState.PAUSED:{switch(r){case D.PLAYING:this.videoState.startTransitionTo(D.PAUSED),this.params.connection.remotePlayerController.playOrPause();break;case D.PAUSED:break;case D.READY:this.videoState.startTransitionTo(D.PAUSED),this.videoState.setState(D.PAUSED);break;case D.STOPPED:this.videoState.startTransitionTo(D.READY),this.prepare();break;default:a.assertNever(r)}break}default:a.assertNever(n)}}},this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastProvider"),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(NS(e.format)),this.params.output.isAudioAvailable$.next(!0),this.handleRemoteVolumeChange({volume:this.params.connection.remotePlayer.volumeLevel,muted:this.params.connection.remotePlayer.isMuted});const t=this.params.connection.session.getMediaSession();t&&this.restoreSession(t),this.subscribe()}destroy(){this.log({message:"[destroy]"}),this.subscription.unsubscribe()}subscribe(){this.subscription.add(this.loadMediaTimeoutSubscription);const e=new a.Subscription;this.subscription.add(e),this.subscription.add(a.merge(this.videoState.stateChangeStarted$.pipe(a.map(s=>`stateChangeStarted$ ${JSON.stringify(s)}`)),this.videoState.stateChangeEnded$.pipe(a.map(s=>`stateChangeEnded$ ${JSON.stringify(s)}`))).subscribe(s=>this.log({message:`[videoState] ${s}`})));const t=(s,n)=>this.subscription.add(s.subscribe(n));if(this.params.output.isLive$.getValue())this.params.output.position$.next(0),this.params.output.duration$.next(0);else{const s=new a.Subject;e.add(s.pipe(a.debounce(BS)).subscribe(()=>{this.params.output.seekedEvent$.next()}));let n=NaN;e.add(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED).subscribe(o=>{this.logRemoteEvent(o);const l=o.value;this.params.output.position$.next(l),(this.params.desiredState.seekState.getState().state===N.Applying||Math.abs(l-n)>OS)&&s.next(l),n=l})),e.add(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.DURATION_CHANGED).subscribe(o=>{this.logRemoteEvent(o),this.params.output.duration$.next(o.value)}))}t(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED),s=>{this.logRemoteEvent(s),s.value?this.handleRemoteReady():(this.handleRemoteStop(),e.unsubscribe())}),t(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),s=>{this.logRemoteEvent(s),s.value?this.handleRemotePause():this.handleRemotePlay()}),t(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED),s=>{this.logRemoteEvent(s);const{remotePlayer:n}=this.params.connection,o=s.value,l=this.params.output.isBuffering$.getValue(),d=o===chrome.cast.media.PlayerState.BUFFERING;switch(l!==d&&this.params.output.isBuffering$.next(d),o){case chrome.cast.media.PlayerState.IDLE:!this.params.output.isLive$.getValue()&&n.duration-n.currentTime<MS&&this.params.output.endedEvent$.next(),this.handleRemoteStop(),w(this.params.desiredState.playbackState,exports.PlaybackState.STOPPED);break;case chrome.cast.media.PlayerState.PAUSED:{this.handleRemotePause();break}case chrome.cast.media.PlayerState.PLAYING:this.handleRemotePlay();break;case chrome.cast.media.PlayerState.BUFFERING:break;default:a.assertNever(o)}}),t(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED),s=>{this.logRemoteEvent(s),this.handleRemoteVolumeChange({volume:s.value})}),t(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),s=>{this.logRemoteEvent(s),this.handleRemoteVolumeChange({muted:s.value})});const r=a.merge(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,a.observableFrom(["init"])).pipe(a.debounce(0));t(r,this.syncPlayback)}restoreSession(e){this.log({message:"restoreSession"});const{remotePlayer:t}=this.params.connection;if(e.playerState!==chrome.cast.media.PlayerState.IDLE){t.isPaused?(this.videoState.setState(D.PAUSED),w(this.params.desiredState.playbackState,exports.PlaybackState.PAUSED)):(this.videoState.setState(D.PLAYING),w(this.params.desiredState.playbackState,exports.PlaybackState.PLAYING));const r=this.params.output.isLive$.getValue();this.params.output.duration$.next(r?0:t.duration),this.params.output.position$.next(r?0:t.currentTime),this.params.desiredState.seekState.setState({state:N.None})}}prepare(){const e=this.params.format;this.log({message:`[prepare] format: ${e}`});const t=this.createMediaInfo(e),r=this.createLoadRequest(t);this.loadMedia(r)}handleRemotePause(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===D.PAUSED||e===D.PLAYING)&&(this.videoState.setState(D.PAUSED),w(this.params.desiredState.playbackState,exports.PlaybackState.PAUSED))}handleRemotePlay(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===D.PLAYING||e===D.PAUSED)&&(this.videoState.setState(D.PLAYING),w(this.params.desiredState.playbackState,exports.PlaybackState.PLAYING))}handleRemoteReady(){var e;const t=this.videoState.getTransition();(t==null?void 0:t.to)===D.READY&&this.videoState.setState(D.READY),((e=this.params.desiredState.playbackState.getTransition())===null||e===void 0?void 0:e.to)===exports.PlaybackState.READY&&w(this.params.desiredState.playbackState,exports.PlaybackState.READY)}handleRemoteStop(){this.videoState.getState()!==D.STOPPED&&this.videoState.setState(D.STOPPED)}handleRemoteVolumeChange(e){var t,r;const s=this.params.output.volume$.getValue(),n={volume:(t=e.volume)!==null&&t!==void 0?t:s.volume,muted:(r=e.muted)!==null&&r!==void 0?r:s.muted};(n.volume!==s.volume||n.muted!==n.muted)&&this.params.output.volume$.next(n)}seek(e){this.params.output.willSeekEvent$.next();const{remotePlayer:t,remotePlayerController:r}=this.params.connection;t.currentTime=e,r.seek()}stop(){const{remotePlayerController:e}=this.params.connection;e.stop()}createMediaInfo(e){var t;const r=this.params.source;let s,n,o;switch(e){case exports.VideoFormat.MPEG:{const c=r[e];a.assertNonNullable(c);const h=a.getHighestQuality(Object.keys(c));a.assertNonNullable(h);const f=c[h];a.assertNonNullable(f),s=f,n="video/mp4",o=chrome.cast.media.StreamType.BUFFERED;break}case exports.VideoFormat.HLS:case exports.VideoFormat.HLS_ONDEMAND:{const c=r[e];a.assertNonNullable(c),s=c.url,n="application/x-mpegurl",o=chrome.cast.media.StreamType.BUFFERED;break}case exports.VideoFormat.DASH_SEP:case exports.VideoFormat.DASH_ONDEMAND:case exports.VideoFormat.DASH_WEBM:case exports.VideoFormat.DASH_WEBM_AV1:{const c=r[e];a.assertNonNullable(c),s=c.url,n="application/dash+xml",o=chrome.cast.media.StreamType.BUFFERED;break}case exports.VideoFormat.DASH_LIVE_CMAF:{const c=r[e];a.assertNonNullable(c),s=c.url,n="application/dash+xml",o=chrome.cast.media.StreamType.LIVE;break}case exports.VideoFormat.HLS_LIVE:case exports.VideoFormat.HLS_LIVE_CMAF:{const c=r[e];a.assertNonNullable(c),s=we(c.url),n="application/x-mpegurl",o=chrome.cast.media.StreamType.LIVE;break}case exports.VideoFormat.DASH_LIVE:case exports.VideoFormat.WEB_RTC_LIVE:{const c="Unsupported format for Chromecast",h=new Error(c);throw this.params.output.error$.next({id:"ChromecastProvider.createMediaInfo()",category:a.ErrorCategory.VIDEO_PIPELINE,message:c,thrown:h}),h}case exports.VideoFormat.DASH_LIVE_WEBM:throw new Error("DASH_LIVE_WEBM is no longer supported");default:return a.assertNever(e)}const l=new chrome.cast.media.MediaInfo((t=this.params.meta.videoId)!==null&&t!==void 0?t:s,n);l.contentUrl=s,l.streamType=o,l.metadata=new chrome.cast.media.GenericMediaMetadata;const{title:d,subtitle:u}=this.params.meta;return a.isNonNullable(d)&&(l.metadata.title=d),a.isNonNullable(u)&&(l.metadata.subtitle=u),l}createLoadRequest(e){const t=new chrome.cast.media.LoadRequest(e);t.autoplay=!1;const r=this.params.desiredState.seekState.getState();return r.state===N.Applying||r.state===N.Requested?t.currentTime=this.params.output.isLive$.getValue()?0:r.position/1e3:t.currentTime=0,t}loadMedia(e){const t=this.params.connection.session.loadMedia(e),r=new Promise((s,n)=>{this.loadMediaTimeoutSubscription.add(a.timeout(lo).subscribe(()=>n(`timeout(${lo})`)))});Aa(Promise.race([t,r]).then(()=>{this.log({message:`[loadMedia] completed, format: ${this.params.format}`}),this.params.desiredState.seekState.getState().state===N.Applying&&this.params.output.seekedEvent$.next(),this.handleRemoteReady()},s=>{const n=`[prepare] loadMedia failed, format: ${this.params.format}, reason: ${s}`;this.log({message:n}),this.params.output.error$.next({id:"ChromecastProvider.loadMedia",category:a.ErrorCategory.VIDEO_PIPELINE,message:n,thrown:s})}),()=>{this.loadMediaTimeoutSubscription.unsubscribe()})}logRemoteEvent(e){this.log({message:`[remoteEvent] ${JSON.stringify(e)}`})}}const wa=i=>{i.removeAttribute("src"),i.load()},FS=i=>{try{i.pause(),i.playbackRate=0,wa(i),i.remove()}catch(e){console.error(e)}};class US{constructor(){this.attribute="data-pool-reused"}get(e){return e.hasAttribute(this.attribute)}set(e,t){e.toggleAttribute(this.attribute,t)}delete(e){e.removeAttribute(this.attribute)}}const Js=window.WeakMap?new WeakMap:new US,bt=i=>{let e=i.querySelector("video");const t=!!e;return e?wa(e):(e=document.createElement("video"),i.appendChild(e)),Js.set(e,t),e.setAttribute("crossorigin","anonymous"),e.setAttribute("playsinline","playsinline"),e.controls=!1,e.setAttribute("poster","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),e},gt=i=>{const e=Js.get(i);Js.delete(i),e?wa(i):FS(i)},Ue=(i,e,t,{equal:r=(o,l)=>o===l,changed$:s,onError:n}={})=>{const o=i.getState(),l=e(),d=a.isNullable(s),u=new a.Subscription;return s&&u.add(s.subscribe(c=>{const h=i.getState();r(c,h)&&i.setState(c)},n)),r(l,o)||(t(o),d&&i.setState(o)),u.add(i.stateChangeStarted$.subscribe(c=>{t(c.to),d&&i.setState(c.to)},n)),u},yi=(i,e,t)=>Ue(e,()=>i.loop,r=>{a.isNonNullable(r)&&(i.loop=r)},{onError:t}),yt=(i,e,t,r)=>Ue(e,()=>({muted:i.muted,volume:i.volume}),s=>{a.isNonNullable(s)&&(i.muted=s.muted,i.volume=s.volume)},{equal:(s,n)=>s===n||(s==null?void 0:s.muted)===(n==null?void 0:n.muted)&&(s==null?void 0:s.volume)===(n==null?void 0:n.volume),changed$:t,onError:r}),zt=(i,e,t,r)=>Ue(e,()=>i.playbackRate,s=>{a.isNonNullable(s)&&(i.playbackRate=s)},{changed$:t,onError:r}),jS=i=>["__",i.language,i.label].join("|"),HS=(i,e)=>{if(i.id===e)return!0;const[t,r,s]=e.split("|");return i.language===r&&i.label===s};class tt{constructor(){this.available$=new a.Subject,this.current$=new a.ValueSubject(void 0),this.error$=new a.Subject,this.subscription=new a.Subscription,this.externalTracks=new Map,this.internalTracks=new Map}connect(e,t,r){this.video=e,this.cueSettings=t.textTrackCuesSettings,this.subscribe();const s=n=>{this.error$.next({id:"TextTracksManager",category:a.ErrorCategory.WTF,message:"Generic HtmlVideoTextTrackManager error",thrown:n})};this.subscription.add(this.available$.subscribe(r.availableTextTracks$)),this.subscription.add(this.current$.subscribe(r.currentTextTrack$)),this.subscription.add(this.error$.subscribe(r.error$)),this.subscription.add(Ue(t.internalTextTracks,()=>Object.values(this.internalTracks),n=>{a.isNonNullable(n)&&this.setInternal(n)},{equal:(n,o)=>a.isNonNullable(n)&&a.isNonNullable(o)&&n.length===o.length&&n.every(({id:l},d)=>l===o[d].id),changed$:this.available$.pipe(a.map(n=>n.filter(({type:o})=>o==="internal"))),onError:s})),this.subscription.add(Ue(t.externalTextTracks,()=>Object.values(this.externalTracks),n=>{a.isNonNullable(n)&&this.setExternal(n)},{equal:(n,o)=>a.isNonNullable(n)&&a.isNonNullable(o)&&n.length===o.length&&n.every(({id:l},d)=>l===o[d].id),changed$:this.available$.pipe(a.map(n=>n.filter(({type:o})=>o==="external"))),onError:s})),this.subscription.add(Ue(t.currentTextTrack,()=>{if(this.video)return;const n=this.htmlTextTracksAsArray().find(({mode:o})=>o==="showing");return n&&this.htmlTextTrackToITextTrack(n).id},n=>this.select(n),{changed$:this.current$,onError:s})),this.subscription.add(Ue(t.textTrackCuesSettings,()=>({}),()=>{if(this.video)for(const n of this.htmlTextTracksAsArray())this.applyCueSettings(n.cues),this.applyCueSettings(n.activeCues)}))}subscribe(){a.assertNonNullable(this.video);const{textTracks:e}=this.video;this.subscription.add(a.fromEvent(e,"addtrack").subscribe(()=>{const r=this.current$.getValue();r&&this.select(r)})),this.subscription.add(a.merge(a.fromEvent(e,"addtrack"),a.fromEvent(e,"removetrack"),a.observableFrom(["init"])).pipe(a.map(()=>this.htmlTextTracksAsArray().map(r=>this.htmlTextTrackToITextTrack(r))),a.filterChanged((r,s)=>r.length===s.length&&r.every(({id:n},o)=>n===s[o].id))).subscribe(this.available$)),this.subscription.add(a.merge(a.fromEvent(e,"change"),a.observableFrom(["init"])).pipe(a.map(()=>this.htmlTextTracksAsArray().find(({mode:r})=>r==="showing")),a.map(r=>r&&this.htmlTextTrackToITextTrack(r).id),a.filterChanged()).subscribe(this.current$));const t=r=>{var s,n;return this.applyCueSettings((n=(s=r.target)===null||s===void 0?void 0:s.activeCues)!==null&&n!==void 0?n:null)};this.subscription.add(a.fromEvent(e,"addtrack").subscribe(r=>{var s,n;(s=r.track)===null||s===void 0||s.addEventListener("cuechange",t);const o=l=>{var d,u,c,h,f;const p=(u=(d=l.target)===null||d===void 0?void 0:d.cues)!==null&&u!==void 0?u:null;p&&p.length&&(this.applyCueSettings((h=(c=l.target)===null||c===void 0?void 0:c.cues)!==null&&h!==void 0?h:null),(f=l.target)===null||f===void 0||f.removeEventListener("cuechange",o))};(n=r.track)===null||n===void 0||n.addEventListener("cuechange",o)})),this.subscription.add(a.fromEvent(e,"removetrack").subscribe(r=>{var s;(s=r.track)===null||s===void 0||s.removeEventListener("cuechange",t)}))}applyCueSettings(e){if(!e||!e.length)return;const t=this.cueSettings.getState();for(const r of Array.from(e)){const s=r;a.isNonNullable(t.align)&&(s.align=t.align),a.isNonNullable(t.position)&&(s.position=t.position),a.isNonNullable(t.size)&&(s.size=t.size),a.isNonNullable(t.line)&&(s.line=t.line)}}htmlTextTracksAsArray(e=!1){a.assertNonNullable(this.video);const t=[...this.video.textTracks];return e?t:t.filter(tt.isHealthyTrack)}htmlTextTrackToITextTrack(e){var t,r;const{language:s,label:n}=e,o=e.id?e.id:jS(e),l=this.externalTracks.has(o),d=o.includes("auto");return l?{id:o,type:"external",isAuto:d,language:s,label:n,url:(t=this.externalTracks.get(o))===null||t===void 0?void 0:t.url}:{id:o,type:"internal",isAuto:d,language:s,label:n,url:(r=this.internalTracks.get(o))===null||r===void 0?void 0:r.url}}static isHealthyTrack(e){return!(e.kind==="metadata"||e.groupId||e.id===""&&e.label===""&&e.language==="")}setExternal(e){this.internalTracks.size>0&&Array.from(this.internalTracks).forEach(([,t])=>this.detach(t)),e.filter(({id:t})=>!this.externalTracks.has(t)).forEach(t=>this.attach(t)),Array.from(this.externalTracks).filter(([t])=>!e.find(r=>r.id===t)).forEach(([,t])=>this.detach(t))}setInternal(e){const t=[...this.externalTracks];e.filter(({id:r,language:s,isAuto:n})=>!this.internalTracks.has(r)&&!t.some(([,o])=>o.language===s&&o.isAuto===n)).forEach(r=>this.attach(r)),Array.from(this.internalTracks).filter(([r])=>!e.find(s=>s.id===r)).forEach(([,r])=>this.detach(r))}select(e){a.assertNonNullable(this.video);for(const t of this.htmlTextTracksAsArray(!0))t.mode="showing";for(const t of this.htmlTextTracksAsArray(!0))(a.isNullable(e)||!HS(t,e))&&(t.mode="disabled")}destroy(){if(this.subscription.unsubscribe(),this.video)for(const e of Array.from(this.video.getElementsByTagName("track"))){const t=e.getAttribute("id");t&&this.externalTracks.has(t)&&this.video.removeChild(e)}this.externalTracks.clear()}attach(e){a.assertNonNullable(this.video);const t=document.createElement("track");t.setAttribute("src",e.url),t.setAttribute("id",e.id),e.label&&t.setAttribute("label",e.label),e.language&&t.setAttribute("srclang",e.language),e.type==="external"?this.externalTracks.set(e.id,e):e.type==="internal"&&this.internalTracks.set(e.id,e),this.video.appendChild(t)}detach(e){a.assertNonNullable(this.video);const t=Array.prototype.find.call(this.video.getElementsByTagName("track"),r=>r.getAttribute("id")===e.id);t&&this.video.removeChild(t),e.type==="external"?this.externalTracks.delete(e.id):e.type==="internal"&&this.internalTracks.delete(e.id)}}class Ca{constructor(){this.pausedTime=0,this.streamOffset=0,this.pauseTimestamp=0}getTotalPausedTime(){return this.pausedTime+this.getCurrentPausedTime()}getCurrentPausedTime(){return this.pauseTimestamp>0?Date.now()-this.pauseTimestamp:0}getStreamOffset(){return this.streamOffset}getTotalOffset(){return this.getTotalPausedTime()+this.streamOffset}pause(){this.pauseTimestamp===0&&(this.pauseTimestamp=Date.now())}resume(){this.pauseTimestamp>0&&(this.pausedTime+=this.getCurrentPausedTime(),this.pauseTimestamp=0)}resetTo(e,t=!1){this.streamOffset=e,this.pauseTimestamp=0,this.pausedTime=0,t&&this.pause()}}const tu=i=>{var e;let t=i;for(;!(t instanceof Document)&&!(t instanceof ShadowRoot)&&t!==null;)t=t==null?void 0:t.parentNode;return(e=t)!==null&&e!==void 0?e:void 0},uo=i=>{const e=tu(i);return!!(e&&e.fullscreenElement&&e.fullscreenElement===i)},GS=i=>{const e=tu(i);return!!(e&&e.pictureInPictureElement&&e.pictureInPictureElement===i)},YS=3;var qS=(i,e,t=YS)=>{let r=0,s=0;for(let n=0;n<i.length;n++){const o=i.start(n),l=i.end(n);if(o<=e&&e<=l){if(r=o,s=l,!t)return{from:r,to:s};for(let d=n-1;d>=0;d--)i.end(d)+t>=r&&(r=i.start(d));for(let d=n+1;d<i.length;d++)i.start(d)-t<=s&&(s=i.end(d))}}return{from:r,to:s}};const Tt=i=>{const e=T=>a.fromEvent(i,T).pipe(a.mapTo(void 0)),t=["waiting","pause","canplay","play","canplaythrough","playing","seeking","seeked","ended"],r=a.merge(...t.map(T=>a.fromEvent(i,T))).pipe(a.map(T=>T.type==="ended"?i.readyState<2:i.readyState<3),a.filterChanged()),s=a.merge(a.fromEvent(i,"progress"),a.fromEvent(i,"timeupdate")).pipe(a.map(()=>qS(i.buffered,i.currentTime))),o=a.getCurrentBrowser().browser===a.CurrentClientBrowser.Safari?a.combine({play:e("play").pipe(a.once()),playing:e("playing")}).pipe(a.mapTo(void 0)):e("playing"),l=a.fromEvent(i,"volumechange").pipe(a.map(()=>({muted:i.muted,volume:i.volume}))),d=a.fromEvent(i,"ratechange").pipe(a.map(()=>i.playbackRate)),u=a.fromEvent(i,"error").pipe(a.filter(()=>!!(i.error||i.played.length)),a.map(()=>{var T;const E=i.error;return{id:E?`MediaError#${E.code}`:"HtmlVideoError",category:a.ErrorCategory.VIDEO_PIPELINE,message:E?E.message:"Error event from HTML video element",thrown:(T=i.error)!==null&&T!==void 0?T:void 0}})),c=a.fromEvent(i,"timeupdate").pipe(a.map(()=>i.currentTime)),h=new a.Subject,f=.3;let p;c.subscribe(T=>{i.loop&&a.isNonNullable(p)&&a.isNonNullable(T)&&p>=i.duration-f&&T<=f&&h.next(p),p=T});const v=a.fromEvent(i,"enterpictureinpicture"),m=a.fromEvent(i,"leavepictureinpicture"),S=new a.ValueSubject(GS(i));v.subscribe(()=>S.next(!0)),m.subscribe(()=>S.next(!1));const b=new a.ValueSubject(uo(i));return a.fromEvent(i,"fullscreenchange").pipe(a.map(()=>uo(i))).subscribe(b),{playing$:o,pause$:e("pause").pipe(a.filter(()=>!i.error)),canplay$:e("canplay"),ended$:e("ended"),looped$:h,error$:u,seeked$:e("seeked"),seeking$:e("seeking"),progress$:e("progress"),loadStart$:e("loadstart"),loadedMetadata$:e("loadedmetadata"),loadedData$:e("loadeddata"),timeUpdate$:c,durationChange$:a.fromEvent(i,"durationchange").pipe(a.map(()=>i.duration)),isBuffering$:r,currentBuffer$:s,volumeState$:l,playbackRateState$:d,inPiP$:S,inFullscreen$:b}};var gr=i=>{switch(i){case"mobile":return a.VideoQuality.Q_144P;case"lowest":return a.VideoQuality.Q_240P;case"low":return a.VideoQuality.Q_360P;case"sd":case"medium":return a.VideoQuality.Q_480P;case"hd":case"high":return a.VideoQuality.Q_720P;case"fullhd":case"full":return a.VideoQuality.Q_1080P;case"quadhd":case"quad":return a.VideoQuality.Q_1440P;case"ultrahd":case"ultra":return a.VideoQuality.Q_2160P}},WS=Ce,zS=pr,QS=fa,KS=ha;WS({target:"Array",proto:!0},{at:function(e){var t=zS(this),r=QS(t),s=KS(e),n=s>=0?s:r+s;return n<0||n>=r?void 0:t[n]}});var JS=Pa,XS=JS("Array","at"),ZS=XS,eb=ZS,tb=eb,ib=tb,Fe=lr(ib);let Ia=!1,je={};const rb=i=>{Ia=i},sb=()=>{je={}},ab=i=>{i(je)},Ui=(i,e)=>{var t;Ia&&(je.meta=(t=je.meta)!==null&&t!==void 0?t:{},je.meta[i]=e)};class xe{constructor(e){this.name=e}next(e){var t,r;if(!Ia)return;je.series=(t=je.series)!==null&&t!==void 0?t:{};const s=(r=je.series[this.name])!==null&&r!==void 0?r:[];s.push([Date.now(),e]),je.series[this.name]=s}}var dt;(function(i){i.FitsContainer="FitsContainer",i.FitsThroughput="FitsThroughput",i.Buffer="Buffer",i.DroppedFramesLimit="DroppedFramesLimit",i.FitsQualityLimits="FitsQualityLimits"})(dt||(dt={}));const nb=new xe("best_bitrate"),ob=(i,e,t)=>(e-t)*Math.pow(2,-10*i)+t;class lb{constructor(){this.history={}}recordSelection(e){this.history[e.id]=a.now()}recordSwitch(e){this.last=e}clear(){this.last=void 0,this.history={}}}const ub='Assertion "ABR Tracks is empty array" failed',yr=(i,{container:e,throughput:t,tuning:r,limits:s,reserve:n=0,forwardBufferHealth:o,playbackRate:l,current:d,history:u,droppedVideoMaxQualityLimit:c,abrLogger:h})=>{var f,p,v,m,S;a.assertNotEmptyArray(i,ub);const b=r.usePixelRatio&&(f=window.devicePixelRatio)!==null&&f!==void 0?f:1,y=r.limitByContainer&&e&&e.width>0&&e.height>0&&{width:e.width*b*r.containerSizeFactor,height:e.height*b*r.containerSizeFactor},T=y&&a.videoSizeToQuality(y),E=r.considerPlaybackRate&&a.isNonNullable(l)?l:1,$=i.filter(R=>!a.isInvariantQuality(R.quality)).sort((R,P)=>a.isHigher(R.quality,P.quality)?-1:1),O=(p=Fe($,-1))===null||p===void 0?void 0:p.quality,M=(v=Fe($,0))===null||v===void 0?void 0:v.quality,F=a.isNullable(s)||a.isNonNullable(s.min)&&a.isNonNullable(s.max)&&a.isLower(s.max,s.min)||a.isNonNullable(s.min)&&M&&a.isHigher(s.min,M)||a.isNonNullable(s.max)&&O&&a.isLower(s.max,O),x=E*ob(o!=null?o:.5,r.bitrateFactorAtEmptyBuffer,r.bitrateFactorAtFullBuffer),U={},I=$.filter(R=>(T?a.isLower(R.quality,T):!0)?(a.isNonNullable(t)&&isFinite(t)&&a.isNonNullable(R.bitrate)?t-n>=R.bitrate*x:!0)?r.lazyQualitySwitch&&a.isNonNullable(r.minBufferToSwitchUp)&&d&&!a.isInvariantQuality(d.quality)&&(o!=null?o:0)<r.minBufferToSwitchUp&&a.isHigher(R.quality,d.quality)?(U[R.quality]=dt.Buffer,!1):!!c&&a.isHigherOrEqual(R.quality,c)?(U[R.quality]=dt.DroppedFramesLimit,!1):F||(a.isNullable(s.max)||a.isLowerOrEqual(R.quality,s.max))&&(a.isNullable(s.min)||a.isHigherOrEqual(R.quality,s.min))?!0:(U[R.quality]=dt.FitsQualityLimits,!1):(U[R.quality]=dt.FitsThroughput,!1):(U[R.quality]=dt.FitsContainer,!1))[0];I&&I.bitrate&&nb.next(I.bitrate);const A=(m=I!=null?I:$[Math.ceil(($.length-1)/2)])!==null&&m!==void 0?m:i[0];A.quality!==((S=u==null?void 0:u.last)===null||S===void 0?void 0:S.quality)&&h({message:`
6
+ "use strict";var Vu=Object.create;var Ya=Object.defineProperty;var Fu=Object.getOwnPropertyDescriptor;var Uu=Object.getOwnPropertyNames;var ju=Object.getPrototypeOf,Hu=Object.prototype.hasOwnProperty;var Gu=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Uu(e))!Hu.call(i,s)&&s!==t&&Ya(i,s,{get:()=>e[s],enumerable:!(r=Fu(e,s))||r.enumerable});return i};var Yu=(i,e,t)=>(t=i!=null?Vu(ju(i)):{},Gu(e||!i||!i.__esModule?Ya(t,"default",{value:i,enumerable:!0}):t,i));var a=require("@vkontakte/videoplayer-shared/es2015.cjs.js");const Bo="2.0.103-dev.c555938f.0";exports.PlaybackState=void 0;(function(i){i.STOPPED="stopped",i.READY="ready",i.PLAYING="playing",i.PAUSED="paused"})(exports.PlaybackState||(exports.PlaybackState={}));exports.VideoFormat=void 0;(function(i){i.MPEG="MPEG",i.DASH="DASH_SEP",i.DASH_SEP="DASH_SEP",i.DASH_SEP_VK="DASH_SEP",i.DASH_WEBM="DASH_WEBM",i.DASH_WEBM_AV1="DASH_WEBM_AV1",i.DASH_WEBM_VK="DASH_WEBM",i.DASH_ONDEMAND="DASH_ONDEMAND",i.DASH_ONDEMAND_VK="DASH_ONDEMAND",i.DASH_LIVE="DASH_LIVE",i.DASH_LIVE_CMAF="DASH_LIVE_CMAF",i.DASH_LIVE_WEBM="DASH_LIVE_WEBM",i.HLS="HLS",i.HLS_ONDEMAND="HLS_ONDEMAND",i.HLS_JS="HLS",i.HLS_LIVE="HLS_LIVE",i.HLS_LIVE_CMAF="HLS_LIVE_CMAF",i.WEB_RTC_LIVE="WEB_RTC_LIVE"})(exports.VideoFormat||(exports.VideoFormat={}));var le;(function(i){i.SCREEN="SCREEN",i.CHROMECAST="CHROMECAST"})(le||(le={}));exports.ChromecastState=void 0;(function(i){i.NOT_AVAILABLE="NOT_AVAILABLE",i.AVAILABLE="AVAILABLE",i.CONNECTING="CONNECTING",i.CONNECTED="CONNECTED"})(exports.ChromecastState||(exports.ChromecastState={}));exports.HttpConnectionType=void 0;(function(i){i.HTTP1="http1",i.HTTP2="http2",i.QUIC="quic"})(exports.HttpConnectionType||(exports.HttpConnectionType={}));var N;(function(i){i.None="none",i.Requested="requested",i.Applying="applying"})(N||(N={}));exports.Surface=void 0;(function(i){i.NONE="none",i.INLINE="inline",i.FULLSCREEN="fullscreen",i.SECOND_SCREEN="second_screen",i.PIP="pip"})(exports.Surface||(exports.Surface={}));function G(i,e,t,r){function s(n){return n instanceof t?n:new t(function(o){o(n)})}return new(t||(t=Promise))(function(n,o){function l(c){try{u(r.next(c))}catch(h){o(h)}}function d(c){try{u(r.throw(c))}catch(h){o(h)}}function u(c){c.done?n(c.value):s(c.value).then(l,d)}u((r=r.apply(i,e||[])).next())})}function C(i){return this instanceof C?(this.v=i,this):new C(i)}function fe(i,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(i,e||[]),s,n=[];return s={},o("next"),o("throw"),o("return"),s[Symbol.asyncIterator]=function(){return this},s;function o(f){r[f]&&(s[f]=function(p){return new Promise(function(v,m){n.push([f,p,v,m])>1||l(f,p)})})}function l(f,p){try{d(r[f](p))}catch(v){h(n[0][3],v)}}function d(f){f.value instanceof C?Promise.resolve(f.value.v).then(u,c):h(n[0][2],f)}function u(f){l("next",f)}function c(f){l("throw",f)}function h(f,p){f(p),n.shift(),n.length&&l(n[0][0],n[0][1])}}var qu=i=>new Promise((e,t)=>{const r=document.createElement("script");r.setAttribute("src",i),r.onload=()=>e,r.onerror=()=>t,document.body.appendChild(r)});class Wu{constructor(e){var t;this.connection$=new a.ValueSubject(void 0),this.castState$=new a.ValueSubject(exports.ChromecastState.NOT_AVAILABLE),this.errorEvent$=new a.Subject,this.realCastState$=new a.ValueSubject(exports.ChromecastState.NOT_AVAILABLE),this.subscription=new a.Subscription,this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastInitializer");const r="chrome"in window;if(this.log({message:`[constructor] receiverApplicationId: ${this.params.receiverApplicationId}, isDisabled: ${this.params.isDisabled}, isSupported: ${r}`}),e.isDisabled||!r)return;const s=a.isNonNullable((t=window.chrome)===null||t===void 0?void 0:t.cast),n=!!window.__onGCastApiAvailable;s?this.initializeCastApi():(window.__onGCastApiAvailable=o=>{delete window.__onGCastApiAvailable,o&&this.initializeCastApi()},n||qu("https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1").catch(()=>this.errorEvent$.next({id:"ChromecastLoading",category:a.ErrorCategory.NETWORK,message:"Script loading failed!"})))}connect(){var e;(e=cast.framework.CastContext.getInstance())===null||e===void 0||e.requestSession()}disconnect(){var e,t;(t=(e=cast.framework.CastContext.getInstance())===null||e===void 0?void 0:e.getCurrentSession())===null||t===void 0||t.endSession(!0)}stopMedia(){return new Promise((e,t)=>{var r,s,n;(n=(s=(r=cast.framework.CastContext.getInstance())===null||r===void 0?void 0:r.getCurrentSession())===null||s===void 0?void 0:s.getMediaSession())===null||n===void 0||n.stop(new chrome.cast.media.StopRequest,e,t)})}toggleConnection(){a.isNonNullable(this.connection$.getValue())?this.disconnect():this.connect()}setVolume(e){const t=this.connection$.getValue();a.isNullable(t)||(t.remotePlayer.volumeLevel=e,t.remotePlayerController.setVolumeLevel())}setMuted(e){const t=this.connection$.getValue();a.isNullable(t)||e!==t.remotePlayer.isMuted&&t.remotePlayerController.muteOrUnmute()}destroy(){this.subscription.unsubscribe()}initListeners(){const e=new cast.framework.RemotePlayer,t=new cast.framework.RemotePlayerController(e),r=cast.framework.CastContext.getInstance();this.subscription.add(a.fromEvent(r,cast.framework.CastContextEventType.SESSION_STATE_CHANGED).subscribe(s=>{var n,o;switch(s.sessionState){case cast.framework.SessionState.SESSION_STARTED:case cast.framework.SessionState.SESSION_STARTING:case cast.framework.SessionState.SESSION_RESUMED:this.contentId=(o=(n=r.getCurrentSession())===null||n===void 0?void 0:n.getMediaSession())===null||o===void 0?void 0:o.media.contentId;break;case cast.framework.SessionState.NO_SESSION:case cast.framework.SessionState.SESSION_ENDING:case cast.framework.SessionState.SESSION_ENDED:case cast.framework.SessionState.SESSION_START_FAILED:this.contentId=void 0;break;default:return a.assertNever(s.sessionState)}})).add(a.merge(a.fromEvent(r,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe(a.tap(s=>{this.log({message:`[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: ${JSON.stringify(s)}`})}),a.map(s=>s.castState)),a.observableFrom([r.getCastState()])).pipe(a.filterChanged(),a.map(zu),a.tap(s=>{this.log({message:`realCastState$: ${s}`})})).subscribe(this.realCastState$)).add(this.realCastState$.subscribe(s=>{var n;const o=s===exports.ChromecastState.CONNECTED,l=a.isNonNullable(this.connection$.getValue());if(o&&!l){const d=r.getCurrentSession();a.assertNonNullable(d);const u=d.getCastDevice(),c=(n=d.getMediaSession())===null||n===void 0?void 0:n.media.contentId;(a.isNullable(c)||c===this.contentId)&&(this.log({message:"connection created"}),this.connection$.next({remotePlayer:e,remotePlayerController:t,session:d,castDevice:u}))}else!o&&l&&(this.log({message:"connection destroyed"}),this.connection$.next(void 0));this.castState$.next(s===exports.ChromecastState.CONNECTED?a.isNonNullable(this.connection$.getValue())?exports.ChromecastState.CONNECTED:exports.ChromecastState.AVAILABLE:s)}))}initializeCastApi(){var e;let t,r,s;try{t=cast.framework.CastContext.getInstance(),r=chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,s=chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}catch(n){return}try{t.setOptions({receiverApplicationId:(e=this.params.receiverApplicationId)!==null&&e!==void 0?e:r,autoJoinPolicy:s}),this.initListeners()}catch(n){this.errorEvent$.next({id:"ChromecastInitializer",category:a.ErrorCategory.EXTERNAL_API,message:"[initializeCastApi] failed",thrown:n})}}}const zu=i=>{switch(i){case cast.framework.CastState.NO_DEVICES_AVAILABLE:return exports.ChromecastState.NOT_AVAILABLE;case cast.framework.CastState.NOT_CONNECTED:return exports.ChromecastState.AVAILABLE;case cast.framework.CastState.CONNECTING:return exports.ChromecastState.CONNECTING;case cast.framework.CastState.CONNECTED:return exports.ChromecastState.CONNECTED;default:return a.assertNever(i)}};var xr=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function lr(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Ee=function(i){try{return!!i()}catch(e){return!0}},Qu=Ee,ur=!Qu(function(){var i=function(){}.bind();return typeof i!="function"||i.hasOwnProperty("prototype")}),Vo=ur,Fo=Function.prototype,_s=Fo.call,Ku=Vo&&Fo.bind.bind(_s,_s),$e=Vo?Ku:function(i){return function(){return _s.apply(i,arguments)}},Uo=$e,Ju=Uo({}.toString),Xu=Uo("".slice),hi=function(i){return Xu(Ju(i),8,-1)},Zu=$e,ec=Ee,tc=hi,Nr=Object,ic=Zu("".split),rc=ec(function(){return!Nr("z").propertyIsEnumerable(0)})?function(i){return tc(i)=="String"?ic(i,""):Nr(i)}:Nr,fi=function(i){return i==null},sc=fi,ac=TypeError,ra=function(i){if(sc(i))throw ac("Can't call method on "+i);return i},nc=rc,oc=ra,pi=function(i){return nc(oc(i))},Yt={},Ci=function(i){return i&&i.Math==Math&&i},ne=Ci(typeof globalThis=="object"&&globalThis)||Ci(typeof window=="object"&&window)||Ci(typeof self=="object"&&self)||Ci(typeof xr=="object"&&xr)||function(){return this}()||xr||Function("return this")(),Ds=typeof document=="object"&&document.all,lc=typeof Ds=="undefined"&&Ds!==void 0,jo={all:Ds,IS_HTMLDDA:lc},Ho=jo,uc=Ho.all,ie=Ho.IS_HTMLDDA?function(i){return typeof i=="function"||i===uc}:function(i){return typeof i=="function"},cc=ne,dc=ie,qa=cc.WeakMap,hc=dc(qa)&&/native code/.test(String(qa)),Wa=ie,Go=jo,fc=Go.all,Ye=Go.IS_HTMLDDA?function(i){return typeof i=="object"?i!==null:Wa(i)||i===fc}:function(i){return typeof i=="object"?i!==null:Wa(i)},pc=Ee,et=!pc(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),mt={},mc=ne,za=Ye,Ls=mc.document,vc=za(Ls)&&za(Ls.createElement),sa=function(i){return vc?Ls.createElement(i):{}},Sc=et,bc=Ee,gc=sa,Yo=!Sc&&!bc(function(){return Object.defineProperty(gc("div"),"a",{get:function(){return 7}}).a!=7}),yc=et,Tc=Ee,qo=yc&&Tc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),Ec=Ye,$c=String,kc=TypeError,qe=function(i){if(Ec(i))return i;throw kc($c(i)+" is not an object")},Pc=ur,Ii=Function.prototype.call,ve=Pc?Ii.bind(Ii):function(){return Ii.apply(Ii,arguments)},aa={},Or=aa,Mr=ne,Ac=ie,Qa=function(i){return Ac(i)?i:void 0},vt=function(i,e){return arguments.length<2?Qa(Or[i])||Qa(Mr[i]):Or[i]&&Or[i][e]||Mr[i]&&Mr[i][e]},wc=$e,cr=wc({}.isPrototypeOf),dr=typeof navigator!="undefined"&&String(navigator.userAgent)||"",Wo=ne,Br=dr,Ka=Wo.process,Ja=Wo.Deno,Xa=Ka&&Ka.versions||Ja&&Ja.version,Za=Xa&&Xa.v8,Ae,Zi;Za&&(Ae=Za.split("."),Zi=Ae[0]>0&&Ae[0]<4?1:+(Ae[0]+Ae[1]));!Zi&&Br&&(Ae=Br.match(/Edge\/(\d+)/),(!Ae||Ae[1]>=74)&&(Ae=Br.match(/Chrome\/(\d+)/),Ae&&(Zi=+Ae[1])));var zo=Zi,en=zo,Cc=Ee,Ic=ne,Rc=Ic.String,Qo=!!Object.getOwnPropertySymbols&&!Cc(function(){var i=Symbol();return!Rc(i)||!(Object(i)instanceof Symbol)||!Symbol.sham&&en&&en<41}),_c=Qo,Ko=_c&&!Symbol.sham&&typeof Symbol.iterator=="symbol",Dc=vt,Lc=ie,xc=cr,Nc=Ko,Oc=Object,Jo=Nc?function(i){return typeof i=="symbol"}:function(i){var e=Dc("Symbol");return Lc(e)&&xc(e.prototype,Oc(i))},Mc=String,hr=function(i){try{return Mc(i)}catch(e){return"Object"}},Bc=ie,Vc=hr,Fc=TypeError,St=function(i){if(Bc(i))return i;throw Fc(Vc(i)+" is not a function")},Uc=St,jc=fi,fr=function(i,e){var t=i[e];return jc(t)?void 0:Uc(t)},Vr=ve,Fr=ie,Ur=Ye,Hc=TypeError,Gc=function(i,e){var t,r;if(e==="string"&&Fr(t=i.toString)&&!Ur(r=Vr(t,i))||Fr(t=i.valueOf)&&!Ur(r=Vr(t,i))||e!=="string"&&Fr(t=i.toString)&&!Ur(r=Vr(t,i)))return r;throw Hc("Can't convert object to primitive value")},Xo={exports:{}},Yc=!0,tn=ne,qc=Object.defineProperty,Wc=function(i,e){try{qc(tn,i,{value:e,configurable:!0,writable:!0})}catch(t){tn[i]=e}return e},zc=ne,Qc=Wc,rn="__core-js_shared__",Kc=zc[rn]||Qc(rn,{}),na=Kc,sn=na;(Xo.exports=function(i,e){return sn[i]||(sn[i]=e!==void 0?e:{})})("versions",[]).push({version:"3.31.0",mode:"pure",copyright:"\xA9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.31.0/LICENSE",source:"https://github.com/zloirock/core-js"});var Zo=Xo.exports,Jc=ra,Xc=Object,pr=function(i){return Xc(Jc(i))},Zc=$e,ed=pr,td=Zc({}.hasOwnProperty),Be=Object.hasOwn||function(e,t){return td(ed(e),t)},id=$e,rd=0,sd=Math.random(),ad=id(1 .toString),el=function(i){return"Symbol("+(i===void 0?"":i)+")_"+ad(++rd+sd,36)},nd=ne,od=Zo,an=Be,ld=el,ud=Qo,cd=Ko,Mt=nd.Symbol,jr=od("wks"),dd=cd?Mt.for||Mt:Mt&&Mt.withoutSetter||ld,de=function(i){return an(jr,i)||(jr[i]=ud&&an(Mt,i)?Mt[i]:dd("Symbol."+i)),jr[i]},hd=ve,nn=Ye,on=Jo,fd=fr,pd=Gc,md=de,vd=TypeError,Sd=md("toPrimitive"),bd=function(i,e){if(!nn(i)||on(i))return i;var t=fd(i,Sd),r;if(t){if(e===void 0&&(e="default"),r=hd(t,i,e),!nn(r)||on(r))return r;throw vd("Can't convert object to primitive value")}return e===void 0&&(e="number"),pd(i,e)},gd=bd,yd=Jo,oa=function(i){var e=gd(i,"string");return yd(e)?e:e+""},Td=et,Ed=Yo,$d=qo,Ri=qe,ln=oa,kd=TypeError,Hr=Object.defineProperty,Pd=Object.getOwnPropertyDescriptor,Gr="enumerable",Yr="configurable",qr="writable";mt.f=Td?$d?function(e,t,r){if(Ri(e),t=ln(t),Ri(r),typeof e=="function"&&t==="prototype"&&"value"in r&&qr in r&&!r[qr]){var s=Pd(e,t);s&&s[qr]&&(e[t]=r.value,r={configurable:Yr in r?r[Yr]:s[Yr],enumerable:Gr in r?r[Gr]:s[Gr],writable:!1})}return Hr(e,t,r)}:Hr:function(e,t,r){if(Ri(e),t=ln(t),Ri(r),Ed)try{return Hr(e,t,r)}catch(s){}if("get"in r||"set"in r)throw kd("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var mr=function(i,e){return{enumerable:!(i&1),configurable:!(i&2),writable:!(i&4),value:e}},Ad=et,wd=mt,Cd=mr,mi=Ad?function(i,e,t){return wd.f(i,e,Cd(1,t))}:function(i,e,t){return i[e]=t,i},Id=Zo,Rd=el,un=Id("keys"),la=function(i){return un[i]||(un[i]=Rd(i))},ua={},_d=hc,tl=ne,Dd=Ye,Ld=mi,Wr=Be,zr=na,xd=la,Nd=ua,cn="Object already initialized",xs=tl.TypeError,Od=tl.WeakMap,er,li,tr,Md=function(i){return tr(i)?li(i):er(i,{})},Bd=function(i){return function(e){var t;if(!Dd(e)||(t=li(e)).type!==i)throw xs("Incompatible receiver, "+i+" required");return t}};if(_d||zr.state){var _e=zr.state||(zr.state=new Od);_e.get=_e.get,_e.has=_e.has,_e.set=_e.set,er=function(i,e){if(_e.has(i))throw xs(cn);return e.facade=i,_e.set(i,e),e},li=function(i){return _e.get(i)||{}},tr=function(i){return _e.has(i)}}else{var It=xd("state");Nd[It]=!0,er=function(i,e){if(Wr(i,It))throw xs(cn);return e.facade=i,Ld(i,It,e),e},li=function(i){return Wr(i,It)?i[It]:{}},tr=function(i){return Wr(i,It)}}var il={set:er,get:li,has:tr,enforce:Md,getterFor:Bd},Vd=ur,rl=Function.prototype,dn=rl.apply,hn=rl.call,sl=typeof Reflect=="object"&&Reflect.apply||(Vd?hn.bind(dn):function(){return hn.apply(dn,arguments)}),Fd=hi,Ud=$e,al=function(i){if(Fd(i)==="Function")return Ud(i)},ca={},nl={},ol={}.propertyIsEnumerable,ll=Object.getOwnPropertyDescriptor,jd=ll&&!ol.call({1:2},1);nl.f=jd?function(e){var t=ll(this,e);return!!t&&t.enumerable}:ol;var Hd=et,Gd=ve,Yd=nl,qd=mr,Wd=pi,zd=oa,Qd=Be,Kd=Yo,fn=Object.getOwnPropertyDescriptor;ca.f=Hd?fn:function(e,t){if(e=Wd(e),t=zd(t),Kd)try{return fn(e,t)}catch(r){}if(Qd(e,t))return qd(!Gd(Yd.f,e,t),e[t])};var Jd=Ee,Xd=ie,Zd=/#|\.prototype\./,vi=function(i,e){var t=th[eh(i)];return t==rh?!0:t==ih?!1:Xd(e)?Jd(e):!!e},eh=vi.normalize=function(i){return String(i).replace(Zd,".").toLowerCase()},th=vi.data={},ih=vi.NATIVE="N",rh=vi.POLYFILL="P",ul=vi,pn=al,sh=St,ah=ur,nh=pn(pn.bind),vr=function(i,e){return sh(i),e===void 0?i:ah?nh(i,e):function(){return i.apply(e,arguments)}},_i=ne,oh=sl,lh=al,uh=ie,ch=ca.f,dh=ul,Rt=aa,hh=vr,_t=mi,mn=Be,fh=function(i){var e=function(t,r,s){if(this instanceof e){switch(arguments.length){case 0:return new i;case 1:return new i(t);case 2:return new i(t,r)}return new i(t,r,s)}return oh(i,this,arguments)};return e.prototype=i.prototype,e},Ce=function(i,e){var t=i.target,r=i.global,s=i.stat,n=i.proto,o=r?_i:s?_i[t]:(_i[t]||{}).prototype,l=r?Rt:Rt[t]||_t(Rt,t,{})[t],d=l.prototype,u,c,h,f,p,v,m,S,b;for(f in e)u=dh(r?f:t+(s?".":"#")+f,i.forced),c=!u&&o&&mn(o,f),v=l[f],c&&(i.dontCallGetSet?(b=ch(o,f),m=b&&b.value):m=o[f]),p=c&&m?m:e[f],!(c&&typeof v==typeof p)&&(i.bind&&c?S=hh(p,_i):i.wrap&&c?S=fh(p):n&&uh(p)?S=lh(p):S=p,(i.sham||p&&p.sham||v&&v.sham)&&_t(S,"sham",!0),_t(l,f,S),n&&(h=t+"Prototype",mn(Rt,h)||_t(Rt,h,{}),_t(Rt[h],f,p),i.real&&d&&(u||!d[f])&&_t(d,f,p)))},Ns=et,ph=Be,cl=Function.prototype,mh=Ns&&Object.getOwnPropertyDescriptor,da=ph(cl,"name"),vh=da&&function(){}.name==="something",Sh=da&&(!Ns||Ns&&mh(cl,"name").configurable),bh={EXISTS:da,PROPER:vh,CONFIGURABLE:Sh},dl={},gh=Math.ceil,yh=Math.floor,Th=Math.trunc||function(e){var t=+e;return(t>0?yh:gh)(t)},Eh=Th,ha=function(i){var e=+i;return e!==e||e===0?0:Eh(e)},$h=ha,kh=Math.max,Ph=Math.min,Ah=function(i,e){var t=$h(i);return t<0?kh(t+e,0):Ph(t,e)},wh=ha,Ch=Math.min,Ih=function(i){return i>0?Ch(wh(i),9007199254740991):0},Rh=Ih,fa=function(i){return Rh(i.length)},_h=pi,Dh=Ah,Lh=fa,vn=function(i){return function(e,t,r){var s=_h(e),n=Lh(s),o=Dh(r,n),l;if(i&&t!=t){for(;n>o;)if(l=s[o++],l!=l)return!0}else for(;n>o;o++)if((i||o in s)&&s[o]===t)return i||o||0;return!i&&-1}},xh={includes:vn(!0),indexOf:vn(!1)},Nh=$e,Qr=Be,Oh=pi,Mh=xh.indexOf,Bh=ua,Sn=Nh([].push),Vh=function(i,e){var t=Oh(i),r=0,s=[],n;for(n in t)!Qr(Bh,n)&&Qr(t,n)&&Sn(s,n);for(;e.length>r;)Qr(t,n=e[r++])&&(~Mh(s,n)||Sn(s,n));return s},hl=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Fh=Vh,Uh=hl,jh=Object.keys||function(e){return Fh(e,Uh)},Hh=et,Gh=qo,Yh=mt,qh=qe,Wh=pi,zh=jh;dl.f=Hh&&!Gh?Object.defineProperties:function(e,t){qh(e);for(var r=Wh(t),s=zh(t),n=s.length,o=0,l;n>o;)Yh.f(e,l=s[o++],r[l]);return e};var Qh=vt,fl=Qh("document","documentElement"),Kh=qe,Jh=dl,bn=hl,Xh=ua,Zh=fl,ef=sa,tf=la,gn=">",yn="<",Os="prototype",Ms="script",pl=tf("IE_PROTO"),Kr=function(){},ml=function(i){return yn+Ms+gn+i+yn+"/"+Ms+gn},Tn=function(i){i.write(ml("")),i.close();var e=i.parentWindow.Object;return i=null,e},rf=function(){var i=ef("iframe"),e="java"+Ms+":",t;return i.style.display="none",Zh.appendChild(i),i.src=String(e),t=i.contentWindow.document,t.open(),t.write(ml("document.F=Object")),t.close(),t.F},Di,Qi=function(){try{Di=new ActiveXObject("htmlfile")}catch(e){}Qi=typeof document!="undefined"?document.domain&&Di?Tn(Di):rf():Tn(Di);for(var i=bn.length;i--;)delete Qi[Os][bn[i]];return Qi()};Xh[pl]=!0;var vl=Object.create||function(e,t){var r;return e!==null?(Kr[Os]=Kh(e),r=new Kr,Kr[Os]=null,r[pl]=e):r=Qi(),t===void 0?r:Jh.f(r,t)},sf=Ee,af=!sf(function(){function i(){}return i.prototype.constructor=null,Object.getPrototypeOf(new i)!==i.prototype}),nf=Be,of=ie,lf=pr,uf=la,cf=af,En=uf("IE_PROTO"),Bs=Object,df=Bs.prototype,Sl=cf?Bs.getPrototypeOf:function(i){var e=lf(i);if(nf(e,En))return e[En];var t=e.constructor;return of(t)&&e instanceof t?t.prototype:e instanceof Bs?df:null},hf=mi,pa=function(i,e,t,r){return r&&r.enumerable?i[e]=t:hf(i,e,t),i},ff=Ee,pf=ie,mf=Ye,vf=vl,$n=Sl,Sf=pa,bf=de,Vs=bf("iterator"),bl=!1,He,Jr,Xr;[].keys&&(Xr=[].keys(),"next"in Xr?(Jr=$n($n(Xr)),Jr!==Object.prototype&&(He=Jr)):bl=!0);var gf=!mf(He)||ff(function(){var i={};return He[Vs].call(i)!==i});gf?He={}:He=vf(He);pf(He[Vs])||Sf(He,Vs,function(){return this});var gl={IteratorPrototype:He,BUGGY_SAFARI_ITERATORS:bl},yf=de,Tf=yf("toStringTag"),yl={};yl[Tf]="z";var ma=String(yl)==="[object z]",Ef=ma,$f=ie,Ki=hi,kf=de,Pf=kf("toStringTag"),Af=Object,wf=Ki(function(){return arguments}())=="Arguments",Cf=function(i,e){try{return i[e]}catch(t){}},Si=Ef?Ki:function(i){var e,t,r;return i===void 0?"Undefined":i===null?"Null":typeof(t=Cf(e=Af(i),Pf))=="string"?t:wf?Ki(e):(r=Ki(e))=="Object"&&$f(e.callee)?"Arguments":r},If=ma,Rf=Si,_f=If?{}.toString:function(){return"[object "+Rf(this)+"]"},Df=ma,Lf=mt.f,xf=mi,Nf=Be,Of=_f,Mf=de,kn=Mf("toStringTag"),va=function(i,e,t,r){if(i){var s=t?i:i.prototype;Nf(s,kn)||Lf(s,kn,{configurable:!0,value:e}),r&&!Df&&xf(s,"toString",Of)}},Bf=gl.IteratorPrototype,Vf=vl,Ff=mr,Uf=va,jf=Yt,Hf=function(){return this},Gf=function(i,e,t,r){var s=e+" Iterator";return i.prototype=Vf(Bf,{next:Ff(+!r,t)}),Uf(i,s,!1,!0),jf[s]=Hf,i},Yf=Ce,qf=ve,Tl=bh,Wf=Gf,zf=Sl,Qf=va,Pn=pa,Kf=de,An=Yt,El=gl,Jf=Tl.PROPER;Tl.CONFIGURABLE;El.IteratorPrototype;var Li=El.BUGGY_SAFARI_ITERATORS,Zr=Kf("iterator"),wn="keys",xi="values",Cn="entries",Xf=function(){return this},Zf=function(i,e,t,r,s,n,o){Wf(t,e,r);var l=function(b){if(b===s&&f)return f;if(!Li&&b in c)return c[b];switch(b){case wn:return function(){return new t(this,b)};case xi:return function(){return new t(this,b)};case Cn:return function(){return new t(this,b)}}return function(){return new t(this)}},d=e+" Iterator",u=!1,c=i.prototype,h=c[Zr]||c["@@iterator"]||s&&c[s],f=!Li&&h||l(s),p=e=="Array"&&c.entries||h,v,m,S;if(p&&(v=zf(p.call(new i)),v!==Object.prototype&&v.next&&(Qf(v,d,!0,!0),An[d]=Xf)),Jf&&s==xi&&h&&h.name!==xi&&(u=!0,f=function(){return qf(h,this)}),s)if(m={values:l(xi),keys:n?f:l(wn),entries:l(Cn)},o)for(S in m)(Li||u||!(S in c))&&Pn(c,S,m[S]);else Yf({target:e,proto:!0,forced:Li||u},m);return o&&c[Zr]!==f&&Pn(c,Zr,f,{name:s}),An[e]=f,m},ep=function(i,e){return{value:i,done:e}},tp=pi,In=Yt,$l=il;mt.f;var ip=Zf,Ni=ep,kl="Array Iterator",rp=$l.set,sp=$l.getterFor(kl);ip(Array,"Array",function(i,e){rp(this,{type:kl,target:tp(i),index:0,kind:e})},function(){var i=sp(this),e=i.target,t=i.kind,r=i.index++;return!e||r>=e.length?(i.target=void 0,Ni(void 0,!0)):t=="keys"?Ni(r,!1):t=="values"?Ni(e[r],!1):Ni([r,e[r]],!1)},"values");In.Arguments=In.Array;var ap=de,np=Yt,op=ap("iterator"),lp=Array.prototype,up=function(i){return i!==void 0&&(np.Array===i||lp[op]===i)},cp=Si,Rn=fr,dp=fi,hp=Yt,fp=de,pp=fp("iterator"),Pl=function(i){if(!dp(i))return Rn(i,pp)||Rn(i,"@@iterator")||hp[cp(i)]},mp=ve,vp=St,Sp=qe,bp=hr,gp=Pl,yp=TypeError,Tp=function(i,e){var t=arguments.length<2?gp(i):e;if(vp(t))return Sp(mp(t,i));throw yp(bp(i)+" is not iterable")},Ep=ve,_n=qe,$p=fr,kp=function(i,e,t){var r,s;_n(i);try{if(r=$p(i,"return"),!r){if(e==="throw")throw t;return t}r=Ep(r,i)}catch(n){s=!0,r=n}if(e==="throw")throw t;if(s)throw r;return _n(r),t},Pp=vr,Ap=ve,wp=qe,Cp=hr,Ip=up,Rp=fa,Dn=cr,_p=Tp,Dp=Pl,Ln=kp,Lp=TypeError,Ji=function(i,e){this.stopped=i,this.result=e},xn=Ji.prototype,Sa=function(i,e,t){var r=t&&t.that,s=!!(t&&t.AS_ENTRIES),n=!!(t&&t.IS_RECORD),o=!!(t&&t.IS_ITERATOR),l=!!(t&&t.INTERRUPTED),d=Pp(e,r),u,c,h,f,p,v,m,S=function(y){return u&&Ln(u,"normal",y),new Ji(!0,y)},b=function(y){return s?(wp(y),l?d(y[0],y[1],S):d(y[0],y[1])):l?d(y,S):d(y)};if(n)u=i.iterator;else if(o)u=i;else{if(c=Dp(i),!c)throw Lp(Cp(i)+" is not iterable");if(Ip(c)){for(h=0,f=Rp(i);f>h;h++)if(p=b(i[h]),p&&Dn(xn,p))return p;return new Ji(!1)}u=_p(i,c)}for(v=n?i.next:u.next;!(m=Ap(v,u)).done;){try{p=b(m.value)}catch(y){Ln(u,"throw",y)}if(typeof p=="object"&&p&&Dn(xn,p))return p}return new Ji(!1)},xp=oa,Np=mt,Op=mr,Mp=function(i,e,t){var r=xp(e);r in i?Np.f(i,r,Op(0,t)):i[r]=t},Bp=Ce,Vp=Sa,Fp=Mp;Bp({target:"Object",stat:!0},{fromEntries:function(e){var t={};return Vp(e,function(r,s){Fp(t,r,s)},{AS_ENTRIES:!0}),t}});var Up=aa,jp=Up.Object.fromEntries,Hp={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},Gp=Hp,Yp=ne,qp=Si,Wp=mi,Nn=Yt,zp=de,On=zp("toStringTag");for(var es in Gp){var Mn=Yp[es],ts=Mn&&Mn.prototype;ts&&qp(ts)!==On&&Wp(ts,On,es),Nn[es]=Nn.Array}var Qp=jp,Kp=Qp,Jp=Kp,Xp=Jp,ir=lr(Xp),Zp=hi,Sr=typeof process!="undefined"&&Zp(process)=="process",em=mt,tm=function(i,e,t){return em.f(i,e,t)},im=vt,rm=tm,sm=de,am=et,Bn=sm("species"),nm=function(i){var e=im(i);am&&e&&!e[Bn]&&rm(e,Bn,{configurable:!0,get:function(){return this}})},om=cr,lm=TypeError,um=function(i,e){if(om(e,i))return i;throw lm("Incorrect invocation")},cm=$e,dm=ie,Fs=na,hm=cm(Function.toString);dm(Fs.inspectSource)||(Fs.inspectSource=function(i){return hm(i)});var Al=Fs.inspectSource,fm=$e,pm=Ee,wl=ie,mm=Si,vm=vt,Sm=Al,Cl=function(){},bm=[],Il=vm("Reflect","construct"),ba=/^\s*(?:class|function)\b/,gm=fm(ba.exec),ym=!ba.exec(Cl),ei=function(e){if(!wl(e))return!1;try{return Il(Cl,bm,e),!0}catch(t){return!1}},Rl=function(e){if(!wl(e))return!1;switch(mm(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return ym||!!gm(ba,Sm(e))}catch(t){return!0}};Rl.sham=!0;var Tm=!Il||pm(function(){var i;return ei(ei.call)||!ei(Object)||!ei(function(){i=!0})||i})?Rl:ei,Em=Tm,$m=hr,km=TypeError,Pm=function(i){if(Em(i))return i;throw km($m(i)+" is not a constructor")},Vn=qe,Am=Pm,wm=fi,Cm=de,Im=Cm("species"),_l=function(i,e){var t=Vn(i).constructor,r;return t===void 0||wm(r=Vn(t)[Im])?e:Am(r)},Rm=$e,_m=Rm([].slice),Dm=TypeError,Lm=function(i,e){if(i<e)throw Dm("Not enough arguments");return i},xm=dr,Dl=/(?:ipad|iphone|ipod).*applewebkit/i.test(xm),me=ne,Nm=sl,Om=vr,Fn=ie,Mm=Be,Ll=Ee,Un=fl,Bm=_m,jn=sa,Vm=Lm,Fm=Dl,Um=Sr,Us=me.setImmediate,js=me.clearImmediate,jm=me.process,is=me.Dispatch,Hm=me.Function,Hn=me.MessageChannel,Gm=me.String,rs=0,si={},Gn="onreadystatechange",ui,ot,ss,as;Ll(function(){ui=me.location});var ga=function(i){if(Mm(si,i)){var e=si[i];delete si[i],e()}},ns=function(i){return function(){ga(i)}},Yn=function(i){ga(i.data)},qn=function(i){me.postMessage(Gm(i),ui.protocol+"//"+ui.host)};(!Us||!js)&&(Us=function(e){Vm(arguments.length,1);var t=Fn(e)?e:Hm(e),r=Bm(arguments,1);return si[++rs]=function(){Nm(t,void 0,r)},ot(rs),rs},js=function(e){delete si[e]},Um?ot=function(i){jm.nextTick(ns(i))}:is&&is.now?ot=function(i){is.now(ns(i))}:Hn&&!Fm?(ss=new Hn,as=ss.port2,ss.port1.onmessage=Yn,ot=Om(as.postMessage,as)):me.addEventListener&&Fn(me.postMessage)&&!me.importScripts&&ui&&ui.protocol!=="file:"&&!Ll(qn)?(ot=qn,me.addEventListener("message",Yn,!1)):Gn in jn("script")?ot=function(i){Un.appendChild(jn("script"))[Gn]=function(){Un.removeChild(this),ga(i)}}:ot=function(i){setTimeout(ns(i),0)});var xl={set:Us,clear:js},Nl=function(){this.head=null,this.tail=null};Nl.prototype={add:function(i){var e={item:i,next:null},t=this.tail;t?t.next=e:this.head=e,this.tail=e},get:function(){var i=this.head;if(i){var e=this.head=i.next;return e===null&&(this.tail=null),i.item}}};var Ol=Nl,Ym=dr,qm=/ipad|iphone|ipod/i.test(Ym)&&typeof Pebble!="undefined",Wm=dr,zm=/web0s(?!.*chrome)/i.test(Wm),ft=ne,Wn=vr,Qm=ca.f,os=xl.set,Km=Ol,Jm=Dl,Xm=qm,Zm=zm,ls=Sr,zn=ft.MutationObserver||ft.WebKitMutationObserver,Qn=ft.document,Kn=ft.process,Oi=ft.Promise,Jn=Qm(ft,"queueMicrotask"),Hs=Jn&&Jn.value,Dt,us,cs,Mi,Xn;if(!Hs){var Bi=new Km,Vi=function(){var i,e;for(ls&&(i=Kn.domain)&&i.exit();e=Bi.get();)try{e()}catch(t){throw Bi.head&&Dt(),t}i&&i.enter()};!Jm&&!ls&&!Zm&&zn&&Qn?(us=!0,cs=Qn.createTextNode(""),new zn(Vi).observe(cs,{characterData:!0}),Dt=function(){cs.data=us=!us}):!Xm&&Oi&&Oi.resolve?(Mi=Oi.resolve(void 0),Mi.constructor=Oi,Xn=Wn(Mi.then,Mi),Dt=function(){Xn(Vi)}):ls?Dt=function(){Kn.nextTick(Vi)}:(os=Wn(os,ft),Dt=function(){os(Vi)}),Hs=function(i){Bi.head||Dt(),Bi.add(i)}}var ev=Hs,tv=function(i,e){try{arguments.length==1?console.error(i):console.error(i,e)}catch(t){}},ya=function(i){try{return{error:!1,value:i()}}catch(e){return{error:!0,value:e}}},iv=ne,qt=iv.Promise,Ml=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",rv=Ml,sv=Sr,av=!rv&&!sv&&typeof window=="object"&&typeof document=="object",nv=ne,ai=qt,ov=ie,lv=ul,uv=Al,cv=de,dv=av,hv=Ml,ds=zo,Zn=ai&&ai.prototype,fv=cv("species"),Gs=!1,Bl=ov(nv.PromiseRejectionEvent),pv=lv("Promise",function(){var i=uv(ai),e=i!==String(ai);if(!e&&ds===66||!(Zn.catch&&Zn.finally))return!0;if(!ds||ds<51||!/native code/.test(i)){var t=new ai(function(n){n(1)}),r=function(n){n(function(){},function(){})},s=t.constructor={};if(s[fv]=r,Gs=t.then(function(){})instanceof r,!Gs)return!0}return!e&&(dv||hv)&&!Bl}),bi={CONSTRUCTOR:pv,REJECTION_EVENT:Bl,SUBCLASSING:Gs},Wt={},eo=St,mv=TypeError,vv=function(i){var e,t;this.promise=new i(function(r,s){if(e!==void 0||t!==void 0)throw mv("Bad Promise constructor");e=r,t=s}),this.resolve=eo(e),this.reject=eo(t)};Wt.f=function(i){return new vv(i)};var Sv=Ce,rr=Sr,Ze=ne,gi=ve,bv=pa,gv=va,yv=nm,Tv=St,Ys=ie,Ev=Ye,$v=um,kv=_l,Vl=xl.set,Ta=ev,Pv=tv,Av=ya,wv=Ol,Fl=il,qs=qt,Ea=bi,Ul=Wt,br="Promise",jl=Ea.CONSTRUCTOR,Cv=Ea.REJECTION_EVENT;Ea.SUBCLASSING;var hs=Fl.getterFor(br),Iv=Fl.set,Rv=qs&&qs.prototype,Bt=qs,fs=Rv,Hl=Ze.TypeError,Ws=Ze.document,$a=Ze.process,zs=Ul.f,_v=zs,Dv=!!(Ws&&Ws.createEvent&&Ze.dispatchEvent),Gl="unhandledrejection",Lv="rejectionhandled",to=0,Yl=1,xv=2,ka=1,ql=2,Fi,io,Nv,Wl=function(i){var e;return Ev(i)&&Ys(e=i.then)?e:!1},zl=function(i,e){var t=e.value,r=e.state==Yl,s=r?i.ok:i.fail,n=i.resolve,o=i.reject,l=i.domain,d,u,c;try{s?(r||(e.rejection===ql&&Mv(e),e.rejection=ka),s===!0?d=t:(l&&l.enter(),d=s(t),l&&(l.exit(),c=!0)),d===i.promise?o(Hl("Promise-chain cycle")):(u=Wl(d))?gi(u,d,n,o):n(d)):o(t)}catch(h){l&&!c&&l.exit(),o(h)}},Ql=function(i,e){i.notified||(i.notified=!0,Ta(function(){for(var t=i.reactions,r;r=t.get();)zl(r,i);i.notified=!1,e&&!i.rejection&&Ov(i)}))},Kl=function(i,e,t){var r,s;Dv?(r=Ws.createEvent("Event"),r.promise=e,r.reason=t,r.initEvent(i,!1,!0),Ze.dispatchEvent(r)):r={promise:e,reason:t},!Cv&&(s=Ze["on"+i])?s(r):i===Gl&&Pv("Unhandled promise rejection",t)},Ov=function(i){gi(Vl,Ze,function(){var e=i.facade,t=i.value,r=ro(i),s;if(r&&(s=Av(function(){rr?$a.emit("unhandledRejection",t,e):Kl(Gl,e,t)}),i.rejection=rr||ro(i)?ql:ka,s.error))throw s.value})},ro=function(i){return i.rejection!==ka&&!i.parent},Mv=function(i){gi(Vl,Ze,function(){var e=i.facade;rr?$a.emit("rejectionHandled",e):Kl(Lv,e,i.value)})},Vt=function(i,e,t){return function(r){i(e,r,t)}},Ut=function(i,e,t){i.done||(i.done=!0,t&&(i=t),i.value=e,i.state=xv,Ql(i,!0))},Qs=function(i,e,t){if(!i.done){i.done=!0,t&&(i=t);try{if(i.facade===e)throw Hl("Promise can't be resolved itself");var r=Wl(e);r?Ta(function(){var s={done:!1};try{gi(r,e,Vt(Qs,s,i),Vt(Ut,s,i))}catch(n){Ut(s,n,i)}}):(i.value=e,i.state=Yl,Ql(i,!1))}catch(s){Ut({done:!1},s,i)}}};jl&&(Bt=function(e){$v(this,fs),Tv(e),gi(Fi,this);var t=hs(this);try{e(Vt(Qs,t),Vt(Ut,t))}catch(r){Ut(t,r)}},fs=Bt.prototype,Fi=function(e){Iv(this,{type:br,done:!1,notified:!1,parent:!1,reactions:new wv,rejection:!1,state:to,value:void 0})},Fi.prototype=bv(fs,"then",function(e,t){var r=hs(this),s=zs(kv(this,Bt));return r.parent=!0,s.ok=Ys(e)?e:!0,s.fail=Ys(t)&&t,s.domain=rr?$a.domain:void 0,r.state==to?r.reactions.add(s):Ta(function(){zl(s,r)}),s.promise}),io=function(){var i=new Fi,e=hs(i);this.promise=i,this.resolve=Vt(Qs,e),this.reject=Vt(Ut,e)},Ul.f=zs=function(i){return i===Bt||i===Nv?new io(i):_v(i)});Sv({global:!0,constructor:!0,wrap:!0,forced:jl},{Promise:Bt});gv(Bt,br,!1,!0);yv(br);var Bv=de,Jl=Bv("iterator"),Xl=!1;try{var Vv=0,so={next:function(){return{done:!!Vv++}},return:function(){Xl=!0}};so[Jl]=function(){return this},Array.from(so,function(){throw 2})}catch(i){}var Fv=function(i,e){if(!e&&!Xl)return!1;var t=!1;try{var r={};r[Jl]=function(){return{next:function(){return{done:t=!0}}}},i(r)}catch(s){}return t},Uv=qt,jv=Fv,Hv=bi.CONSTRUCTOR,Zl=Hv||!jv(function(i){Uv.all(i).then(void 0,function(){})}),Gv=Ce,Yv=ve,qv=St,Wv=Wt,zv=ya,Qv=Sa,Kv=Zl;Gv({target:"Promise",stat:!0,forced:Kv},{all:function(e){var t=this,r=Wv.f(t),s=r.resolve,n=r.reject,o=zv(function(){var l=qv(t.resolve),d=[],u=0,c=1;Qv(e,function(h){var f=u++,p=!1;c++,Yv(l,t,h).then(function(v){p||(p=!0,d[f]=v,--c||s(d))},n)}),--c||s(d)});return o.error&&n(o.value),r.promise}});var Jv=Ce,Xv=bi.CONSTRUCTOR,ao=qt;ao&&ao.prototype;Jv({target:"Promise",proto:!0,forced:Xv,real:!0},{catch:function(i){return this.then(void 0,i)}});var Zv=Ce,eS=ve,tS=St,iS=Wt,rS=ya,sS=Sa,aS=Zl;Zv({target:"Promise",stat:!0,forced:aS},{race:function(e){var t=this,r=iS.f(t),s=r.reject,n=rS(function(){var o=tS(t.resolve);sS(e,function(l){eS(o,t,l).then(r.resolve,s)})});return n.error&&s(n.value),r.promise}});var nS=Ce,oS=ve,lS=Wt,uS=bi.CONSTRUCTOR;nS({target:"Promise",stat:!0,forced:uS},{reject:function(e){var t=lS.f(this);return oS(t.reject,void 0,e),t.promise}});var cS=qe,dS=Ye,hS=Wt,eu=function(i,e){if(cS(i),dS(e)&&e.constructor===i)return e;var t=hS.f(i),r=t.resolve;return r(e),t.promise},fS=Ce,pS=vt,mS=Yc,vS=qt,SS=bi.CONSTRUCTOR,bS=eu,gS=pS("Promise"),yS=!SS;fS({target:"Promise",stat:!0,forced:mS},{resolve:function(e){return bS(yS&&this===gS?vS:this,e)}});var TS=Ce,Ks=qt,ES=Ee,$S=vt,kS=ie,PS=_l,no=eu,AS=Ks&&Ks.prototype,wS=!!Ks&&ES(function(){AS.finally.call({then:function(){}},function(){})});TS({target:"Promise",proto:!0,real:!0,forced:wS},{finally:function(i){var e=PS(this,$S("Promise")),t=kS(i);return this.then(t?function(r){return no(e,i()).then(function(){return r})}:i,t?function(r){return no(e,i()).then(function(){throw r})}:i)}});var CS=vt,Pa=CS,IS=Pa,RS=IS("Promise","finally"),_S=RS,DS=_S,LS=DS,xS=LS,Aa=lr(xS),re;(function(i){i[i.OFFSET_P=0]="OFFSET_P",i[i.PLAYBACK_SHIFT=1]="PLAYBACK_SHIFT",i[i.DASH_CMAF_OFFSET_P=2]="DASH_CMAF_OFFSET_P"})(re||(re={}));var we=(i,e=0,t=re.OFFSET_P)=>{switch(t){case re.OFFSET_P:return i.replace("_offset_p",e===0?"":"_"+e.toFixed(0));case re.PLAYBACK_SHIFT:{if(e===0)return i;const r=new URL(i);return r.searchParams.append("playback_shift",e.toFixed(0)),r.toString()}case re.DASH_CMAF_OFFSET_P:{const r=new URL(i);return!r.searchParams.get("offset_p")&&e===0?i:(r.searchParams.set("offset_p",e.toFixed(0)),r.toString())}default:a.assertNever(t)}return i};const oo=(i,e)=>{var t;switch(e){case re.OFFSET_P:return NaN;case re.PLAYBACK_SHIFT:{const r=new URL(i);return Number(r.searchParams.get("playback_shift"))}case re.DASH_CMAF_OFFSET_P:{const r=new URL(i);return Number((t=r.searchParams.get("offset_p"))!==null&&t!==void 0?t:0)}default:a.assertNever(e)}};var w=(i,e,t=!1)=>{const r=i.getTransition();(t||!r||r.to===e)&&i.setState(e)};class Z{constructor(e){this.transitionStarted$=new a.Subject,this.transitionEnded$=new a.Subject,this.transitionUpdated$=new a.Subject,this.forceChanged$=new a.Subject,this.stateChangeStarted$=a.merge(this.transitionStarted$,this.transitionUpdated$),this.stateChangeEnded$=a.merge(this.transitionEnded$,this.forceChanged$),this.state=e,this.prevState=void 0}setState(e){const t=this.transition,r=this.state;this.transition=void 0,this.prevState=r,this.state=e,t?t.to===e?this.transitionEnded$.next(t):this.forceChanged$.next({from:t.from,to:e,canceledTransition:t}):this.forceChanged$.next({from:r,to:e,canceledTransition:t})}startTransitionTo(e){const t=this.transition,r=this.state;r===e||a.isNonNullable(t)&&t.to===e||(this.prevState=r,this.state=e,t?(this.transition={from:t.from,to:e,canceledTransition:t},this.transitionUpdated$.next(this.transition)):(this.transition={from:r,to:e},this.transitionStarted$.next(this.transition)))}getTransition(){return this.transition}getState(){return this.state}getPrevState(){return this.prevState}}const NS=i=>{switch(i){case exports.VideoFormat.MPEG:case exports.VideoFormat.DASH_SEP:case exports.VideoFormat.DASH_ONDEMAND:case exports.VideoFormat.DASH_WEBM:case exports.VideoFormat.DASH_WEBM_AV1:case exports.VideoFormat.HLS:case exports.VideoFormat.HLS_ONDEMAND:return!1;case exports.VideoFormat.DASH_LIVE:case exports.VideoFormat.DASH_LIVE_CMAF:case exports.VideoFormat.HLS_LIVE:case exports.VideoFormat.HLS_LIVE_CMAF:case exports.VideoFormat.DASH_LIVE_WEBM:case exports.VideoFormat.WEB_RTC_LIVE:return!0;default:return a.assertNever(i)}};var D;(function(i){i.STOPPED="stopped",i.READY="ready",i.PLAYING="playing",i.PAUSED="paused"})(D||(D={}));const OS=5,MS=5,BS=500,lo=7e3;class VS{constructor(e){this.subscription=new a.Subscription,this.loadMediaTimeoutSubscription=new a.Subscription,this.videoState=new Z(D.STOPPED),this.syncPlayback=()=>{const r=this.videoState.getState(),s=this.videoState.getTransition(),n=this.params.desiredState.playbackState.getState(),o=this.params.desiredState.playbackState.getTransition(),l=this.params.desiredState.seekState.getState();if(this.log({message:`[syncPlayback] videoState: ${r}; videoTransition: ${JSON.stringify(s)}; desiredPlaybackState: ${n}; desiredPlaybackStateTransition: ${this.params.desiredState.playbackState.getTransition()}; seekState: ${JSON.stringify(l)};`}),n===exports.PlaybackState.STOPPED){r!==D.STOPPED&&(this.videoState.startTransitionTo(D.STOPPED),this.stop());return}if(!s){if((o==null?void 0:o.to)!==exports.PlaybackState.PAUSED&&l.state===N.Requested&&r!==D.STOPPED){this.seek(l.position/1e3);return}switch(n){case exports.PlaybackState.READY:{switch(r){case D.PLAYING:case D.PAUSED:case D.READY:break;case D.STOPPED:this.videoState.startTransitionTo(D.READY),this.prepare();break;default:a.assertNever(r)}break}case exports.PlaybackState.PLAYING:{switch(r){case D.PLAYING:break;case D.PAUSED:this.videoState.startTransitionTo(D.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case D.READY:this.videoState.startTransitionTo(D.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case D.STOPPED:this.videoState.startTransitionTo(D.READY),this.prepare();break;default:a.assertNever(r)}break}case exports.PlaybackState.PAUSED:{switch(r){case D.PLAYING:this.videoState.startTransitionTo(D.PAUSED),this.params.connection.remotePlayerController.playOrPause();break;case D.PAUSED:break;case D.READY:this.videoState.startTransitionTo(D.PAUSED),this.videoState.setState(D.PAUSED);break;case D.STOPPED:this.videoState.startTransitionTo(D.READY),this.prepare();break;default:a.assertNever(r)}break}default:a.assertNever(n)}}},this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastProvider"),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(NS(e.format)),this.params.output.isAudioAvailable$.next(!0),this.handleRemoteVolumeChange({volume:this.params.connection.remotePlayer.volumeLevel,muted:this.params.connection.remotePlayer.isMuted});const t=this.params.connection.session.getMediaSession();t&&this.restoreSession(t),this.subscribe()}destroy(){this.log({message:"[destroy]"}),this.subscription.unsubscribe()}subscribe(){this.subscription.add(this.loadMediaTimeoutSubscription);const e=new a.Subscription;this.subscription.add(e),this.subscription.add(a.merge(this.videoState.stateChangeStarted$.pipe(a.map(s=>`stateChangeStarted$ ${JSON.stringify(s)}`)),this.videoState.stateChangeEnded$.pipe(a.map(s=>`stateChangeEnded$ ${JSON.stringify(s)}`))).subscribe(s=>this.log({message:`[videoState] ${s}`})));const t=(s,n)=>this.subscription.add(s.subscribe(n));if(this.params.output.isLive$.getValue())this.params.output.position$.next(0),this.params.output.duration$.next(0);else{const s=new a.Subject;e.add(s.pipe(a.debounce(BS)).subscribe(()=>{this.params.output.seekedEvent$.next()}));let n=NaN;e.add(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED).subscribe(o=>{this.logRemoteEvent(o);const l=o.value;this.params.output.position$.next(l),(this.params.desiredState.seekState.getState().state===N.Applying||Math.abs(l-n)>OS)&&s.next(l),n=l})),e.add(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.DURATION_CHANGED).subscribe(o=>{this.logRemoteEvent(o),this.params.output.duration$.next(o.value)}))}t(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED),s=>{this.logRemoteEvent(s),s.value?this.handleRemoteReady():(this.handleRemoteStop(),e.unsubscribe())}),t(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),s=>{this.logRemoteEvent(s),s.value?this.handleRemotePause():this.handleRemotePlay()}),t(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED),s=>{this.logRemoteEvent(s);const{remotePlayer:n}=this.params.connection,o=s.value,l=this.params.output.isBuffering$.getValue(),d=o===chrome.cast.media.PlayerState.BUFFERING;switch(l!==d&&this.params.output.isBuffering$.next(d),o){case chrome.cast.media.PlayerState.IDLE:!this.params.output.isLive$.getValue()&&n.duration-n.currentTime<MS&&this.params.output.endedEvent$.next(),this.handleRemoteStop(),w(this.params.desiredState.playbackState,exports.PlaybackState.STOPPED);break;case chrome.cast.media.PlayerState.PAUSED:{this.handleRemotePause();break}case chrome.cast.media.PlayerState.PLAYING:this.handleRemotePlay();break;case chrome.cast.media.PlayerState.BUFFERING:break;default:a.assertNever(o)}}),t(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED),s=>{this.logRemoteEvent(s),this.handleRemoteVolumeChange({volume:s.value})}),t(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),s=>{this.logRemoteEvent(s),this.handleRemoteVolumeChange({muted:s.value})});const r=a.merge(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,a.observableFrom(["init"])).pipe(a.debounce(0));t(r,this.syncPlayback)}restoreSession(e){this.log({message:"restoreSession"});const{remotePlayer:t}=this.params.connection;if(e.playerState!==chrome.cast.media.PlayerState.IDLE){t.isPaused?(this.videoState.setState(D.PAUSED),w(this.params.desiredState.playbackState,exports.PlaybackState.PAUSED)):(this.videoState.setState(D.PLAYING),w(this.params.desiredState.playbackState,exports.PlaybackState.PLAYING));const r=this.params.output.isLive$.getValue();this.params.output.duration$.next(r?0:t.duration),this.params.output.position$.next(r?0:t.currentTime),this.params.desiredState.seekState.setState({state:N.None})}}prepare(){const e=this.params.format;this.log({message:`[prepare] format: ${e}`});const t=this.createMediaInfo(e),r=this.createLoadRequest(t);this.loadMedia(r)}handleRemotePause(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===D.PAUSED||e===D.PLAYING)&&(this.videoState.setState(D.PAUSED),w(this.params.desiredState.playbackState,exports.PlaybackState.PAUSED))}handleRemotePlay(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===D.PLAYING||e===D.PAUSED)&&(this.videoState.setState(D.PLAYING),w(this.params.desiredState.playbackState,exports.PlaybackState.PLAYING))}handleRemoteReady(){var e;const t=this.videoState.getTransition();(t==null?void 0:t.to)===D.READY&&this.videoState.setState(D.READY),((e=this.params.desiredState.playbackState.getTransition())===null||e===void 0?void 0:e.to)===exports.PlaybackState.READY&&w(this.params.desiredState.playbackState,exports.PlaybackState.READY)}handleRemoteStop(){this.videoState.getState()!==D.STOPPED&&this.videoState.setState(D.STOPPED)}handleRemoteVolumeChange(e){var t,r;const s=this.params.output.volume$.getValue(),n={volume:(t=e.volume)!==null&&t!==void 0?t:s.volume,muted:(r=e.muted)!==null&&r!==void 0?r:s.muted};(n.volume!==s.volume||n.muted!==n.muted)&&this.params.output.volume$.next(n)}seek(e){this.params.output.willSeekEvent$.next();const{remotePlayer:t,remotePlayerController:r}=this.params.connection;t.currentTime=e,r.seek()}stop(){const{remotePlayerController:e}=this.params.connection;e.stop()}createMediaInfo(e){var t;const r=this.params.source;let s,n,o;switch(e){case exports.VideoFormat.MPEG:{const c=r[e];a.assertNonNullable(c);const h=a.getHighestQuality(Object.keys(c));a.assertNonNullable(h);const f=c[h];a.assertNonNullable(f),s=f,n="video/mp4",o=chrome.cast.media.StreamType.BUFFERED;break}case exports.VideoFormat.HLS:case exports.VideoFormat.HLS_ONDEMAND:{const c=r[e];a.assertNonNullable(c),s=c.url,n="application/x-mpegurl",o=chrome.cast.media.StreamType.BUFFERED;break}case exports.VideoFormat.DASH_SEP:case exports.VideoFormat.DASH_ONDEMAND:case exports.VideoFormat.DASH_WEBM:case exports.VideoFormat.DASH_WEBM_AV1:{const c=r[e];a.assertNonNullable(c),s=c.url,n="application/dash+xml",o=chrome.cast.media.StreamType.BUFFERED;break}case exports.VideoFormat.DASH_LIVE_CMAF:{const c=r[e];a.assertNonNullable(c),s=c.url,n="application/dash+xml",o=chrome.cast.media.StreamType.LIVE;break}case exports.VideoFormat.HLS_LIVE:case exports.VideoFormat.HLS_LIVE_CMAF:{const c=r[e];a.assertNonNullable(c),s=we(c.url),n="application/x-mpegurl",o=chrome.cast.media.StreamType.LIVE;break}case exports.VideoFormat.DASH_LIVE:case exports.VideoFormat.WEB_RTC_LIVE:{const c="Unsupported format for Chromecast",h=new Error(c);throw this.params.output.error$.next({id:"ChromecastProvider.createMediaInfo()",category:a.ErrorCategory.VIDEO_PIPELINE,message:c,thrown:h}),h}case exports.VideoFormat.DASH_LIVE_WEBM:throw new Error("DASH_LIVE_WEBM is no longer supported");default:return a.assertNever(e)}const l=new chrome.cast.media.MediaInfo((t=this.params.meta.videoId)!==null&&t!==void 0?t:s,n);l.contentUrl=s,l.streamType=o,l.metadata=new chrome.cast.media.GenericMediaMetadata;const{title:d,subtitle:u}=this.params.meta;return a.isNonNullable(d)&&(l.metadata.title=d),a.isNonNullable(u)&&(l.metadata.subtitle=u),l}createLoadRequest(e){const t=new chrome.cast.media.LoadRequest(e);t.autoplay=!1;const r=this.params.desiredState.seekState.getState();return r.state===N.Applying||r.state===N.Requested?t.currentTime=this.params.output.isLive$.getValue()?0:r.position/1e3:t.currentTime=0,t}loadMedia(e){const t=this.params.connection.session.loadMedia(e),r=new Promise((s,n)=>{this.loadMediaTimeoutSubscription.add(a.timeout(lo).subscribe(()=>n(`timeout(${lo})`)))});Aa(Promise.race([t,r]).then(()=>{this.log({message:`[loadMedia] completed, format: ${this.params.format}`}),this.params.desiredState.seekState.getState().state===N.Applying&&this.params.output.seekedEvent$.next(),this.handleRemoteReady()},s=>{const n=`[prepare] loadMedia failed, format: ${this.params.format}, reason: ${s}`;this.log({message:n}),this.params.output.error$.next({id:"ChromecastProvider.loadMedia",category:a.ErrorCategory.VIDEO_PIPELINE,message:n,thrown:s})}),()=>{this.loadMediaTimeoutSubscription.unsubscribe()})}logRemoteEvent(e){this.log({message:`[remoteEvent] ${JSON.stringify(e)}`})}}const wa=i=>{i.removeAttribute("src"),i.load()},FS=i=>{try{i.pause(),i.playbackRate=0,wa(i),i.remove()}catch(e){console.error(e)}};class US{constructor(){this.attribute="data-pool-reused"}get(e){return e.hasAttribute(this.attribute)}set(e,t){e.toggleAttribute(this.attribute,t)}delete(e){e.removeAttribute(this.attribute)}}const Js=window.WeakMap?new WeakMap:new US,bt=i=>{let e=i.querySelector("video");const t=!!e;return e?wa(e):(e=document.createElement("video"),i.appendChild(e)),Js.set(e,t),e.setAttribute("crossorigin","anonymous"),e.setAttribute("playsinline","playsinline"),e.controls=!1,e.setAttribute("poster","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),e},gt=i=>{const e=Js.get(i);Js.delete(i),e?wa(i):FS(i)},Ue=(i,e,t,{equal:r=(o,l)=>o===l,changed$:s,onError:n}={})=>{const o=i.getState(),l=e(),d=a.isNullable(s),u=new a.Subscription;return s&&u.add(s.subscribe(c=>{const h=i.getState();r(c,h)&&i.setState(c)},n)),r(l,o)||(t(o),d&&i.setState(o)),u.add(i.stateChangeStarted$.subscribe(c=>{t(c.to),d&&i.setState(c.to)},n)),u},yi=(i,e,t)=>Ue(e,()=>i.loop,r=>{a.isNonNullable(r)&&(i.loop=r)},{onError:t}),yt=(i,e,t,r)=>Ue(e,()=>({muted:i.muted,volume:i.volume}),s=>{a.isNonNullable(s)&&(i.muted=s.muted,i.volume=s.volume)},{equal:(s,n)=>s===n||(s==null?void 0:s.muted)===(n==null?void 0:n.muted)&&(s==null?void 0:s.volume)===(n==null?void 0:n.volume),changed$:t,onError:r}),zt=(i,e,t,r)=>Ue(e,()=>i.playbackRate,s=>{a.isNonNullable(s)&&(i.playbackRate=s)},{changed$:t,onError:r}),jS=i=>["__",i.language,i.label].join("|"),HS=(i,e)=>{if(i.id===e)return!0;const[t,r,s]=e.split("|");return i.language===r&&i.label===s};class tt{constructor(){this.available$=new a.Subject,this.current$=new a.ValueSubject(void 0),this.error$=new a.Subject,this.subscription=new a.Subscription,this.externalTracks=new Map,this.internalTracks=new Map}connect(e,t,r){this.video=e,this.cueSettings=t.textTrackCuesSettings,this.subscribe();const s=n=>{this.error$.next({id:"TextTracksManager",category:a.ErrorCategory.WTF,message:"Generic HtmlVideoTextTrackManager error",thrown:n})};this.subscription.add(this.available$.subscribe(r.availableTextTracks$)),this.subscription.add(this.current$.subscribe(r.currentTextTrack$)),this.subscription.add(this.error$.subscribe(r.error$)),this.subscription.add(Ue(t.internalTextTracks,()=>Object.values(this.internalTracks),n=>{a.isNonNullable(n)&&this.setInternal(n)},{equal:(n,o)=>a.isNonNullable(n)&&a.isNonNullable(o)&&n.length===o.length&&n.every(({id:l},d)=>l===o[d].id),changed$:this.available$.pipe(a.map(n=>n.filter(({type:o})=>o==="internal"))),onError:s})),this.subscription.add(Ue(t.externalTextTracks,()=>Object.values(this.externalTracks),n=>{a.isNonNullable(n)&&this.setExternal(n)},{equal:(n,o)=>a.isNonNullable(n)&&a.isNonNullable(o)&&n.length===o.length&&n.every(({id:l},d)=>l===o[d].id),changed$:this.available$.pipe(a.map(n=>n.filter(({type:o})=>o==="external"))),onError:s})),this.subscription.add(Ue(t.currentTextTrack,()=>{if(this.video)return;const n=this.htmlTextTracksAsArray().find(({mode:o})=>o==="showing");return n&&this.htmlTextTrackToITextTrack(n).id},n=>this.select(n),{changed$:this.current$,onError:s})),this.subscription.add(Ue(t.textTrackCuesSettings,()=>({}),()=>{if(this.video)for(const n of this.htmlTextTracksAsArray())this.applyCueSettings(n.cues),this.applyCueSettings(n.activeCues)}))}subscribe(){a.assertNonNullable(this.video);const{textTracks:e}=this.video;this.subscription.add(a.fromEvent(e,"addtrack").subscribe(()=>{const r=this.current$.getValue();r&&this.select(r)})),this.subscription.add(a.merge(a.fromEvent(e,"addtrack"),a.fromEvent(e,"removetrack"),a.observableFrom(["init"])).pipe(a.map(()=>this.htmlTextTracksAsArray().map(r=>this.htmlTextTrackToITextTrack(r))),a.filterChanged((r,s)=>r.length===s.length&&r.every(({id:n},o)=>n===s[o].id))).subscribe(this.available$)),this.subscription.add(a.merge(a.fromEvent(e,"change"),a.observableFrom(["init"])).pipe(a.map(()=>this.htmlTextTracksAsArray().find(({mode:r})=>r==="showing")),a.map(r=>r&&this.htmlTextTrackToITextTrack(r).id),a.filterChanged()).subscribe(this.current$));const t=r=>{var s,n;return this.applyCueSettings((n=(s=r.target)===null||s===void 0?void 0:s.activeCues)!==null&&n!==void 0?n:null)};this.subscription.add(a.fromEvent(e,"addtrack").subscribe(r=>{var s,n;(s=r.track)===null||s===void 0||s.addEventListener("cuechange",t);const o=l=>{var d,u,c,h,f;const p=(u=(d=l.target)===null||d===void 0?void 0:d.cues)!==null&&u!==void 0?u:null;p&&p.length&&(this.applyCueSettings((h=(c=l.target)===null||c===void 0?void 0:c.cues)!==null&&h!==void 0?h:null),(f=l.target)===null||f===void 0||f.removeEventListener("cuechange",o))};(n=r.track)===null||n===void 0||n.addEventListener("cuechange",o)})),this.subscription.add(a.fromEvent(e,"removetrack").subscribe(r=>{var s;(s=r.track)===null||s===void 0||s.removeEventListener("cuechange",t)}))}applyCueSettings(e){if(!e||!e.length)return;const t=this.cueSettings.getState();for(const r of Array.from(e)){const s=r;a.isNonNullable(t.align)&&(s.align=t.align),a.isNonNullable(t.position)&&(s.position=t.position),a.isNonNullable(t.size)&&(s.size=t.size),a.isNonNullable(t.line)&&(s.line=t.line)}}htmlTextTracksAsArray(e=!1){a.assertNonNullable(this.video);const t=[...this.video.textTracks];return e?t:t.filter(tt.isHealthyTrack)}htmlTextTrackToITextTrack(e){var t,r;const{language:s,label:n}=e,o=e.id?e.id:jS(e),l=this.externalTracks.has(o),d=o.includes("auto");return l?{id:o,type:"external",isAuto:d,language:s,label:n,url:(t=this.externalTracks.get(o))===null||t===void 0?void 0:t.url}:{id:o,type:"internal",isAuto:d,language:s,label:n,url:(r=this.internalTracks.get(o))===null||r===void 0?void 0:r.url}}static isHealthyTrack(e){return!(e.kind==="metadata"||e.groupId||e.id===""&&e.label===""&&e.language==="")}setExternal(e){this.internalTracks.size>0&&Array.from(this.internalTracks).forEach(([,t])=>this.detach(t)),e.filter(({id:t})=>!this.externalTracks.has(t)).forEach(t=>this.attach(t)),Array.from(this.externalTracks).filter(([t])=>!e.find(r=>r.id===t)).forEach(([,t])=>this.detach(t))}setInternal(e){const t=[...this.externalTracks];e.filter(({id:r,language:s,isAuto:n})=>!this.internalTracks.has(r)&&!t.some(([,o])=>o.language===s&&o.isAuto===n)).forEach(r=>this.attach(r)),Array.from(this.internalTracks).filter(([r])=>!e.find(s=>s.id===r)).forEach(([,r])=>this.detach(r))}select(e){a.assertNonNullable(this.video);for(const t of this.htmlTextTracksAsArray(!0))t.mode="showing";for(const t of this.htmlTextTracksAsArray(!0))(a.isNullable(e)||!HS(t,e))&&(t.mode="disabled")}destroy(){if(this.subscription.unsubscribe(),this.video)for(const e of Array.from(this.video.getElementsByTagName("track"))){const t=e.getAttribute("id");t&&this.externalTracks.has(t)&&this.video.removeChild(e)}this.externalTracks.clear()}attach(e){a.assertNonNullable(this.video);const t=document.createElement("track");t.setAttribute("src",e.url),t.setAttribute("id",e.id),e.label&&t.setAttribute("label",e.label),e.language&&t.setAttribute("srclang",e.language),e.type==="external"?this.externalTracks.set(e.id,e):e.type==="internal"&&this.internalTracks.set(e.id,e),this.video.appendChild(t)}detach(e){a.assertNonNullable(this.video);const t=Array.prototype.find.call(this.video.getElementsByTagName("track"),r=>r.getAttribute("id")===e.id);t&&this.video.removeChild(t),e.type==="external"?this.externalTracks.delete(e.id):e.type==="internal"&&this.internalTracks.delete(e.id)}}class Ca{constructor(){this.pausedTime=0,this.streamOffset=0,this.pauseTimestamp=0}getTotalPausedTime(){return this.pausedTime+this.getCurrentPausedTime()}getCurrentPausedTime(){return this.pauseTimestamp>0?Date.now()-this.pauseTimestamp:0}getStreamOffset(){return this.streamOffset}getTotalOffset(){return this.getTotalPausedTime()+this.streamOffset}pause(){this.pauseTimestamp===0&&(this.pauseTimestamp=Date.now())}resume(){this.pauseTimestamp>0&&(this.pausedTime+=this.getCurrentPausedTime(),this.pauseTimestamp=0)}resetTo(e,t=!1){this.streamOffset=e,this.pauseTimestamp=0,this.pausedTime=0,t&&this.pause()}}const tu=i=>{var e;let t=i;for(;!(t instanceof Document)&&!(t instanceof ShadowRoot)&&t!==null;)t=t==null?void 0:t.parentNode;return(e=t)!==null&&e!==void 0?e:void 0},uo=i=>{const e=tu(i);return!!(e&&e.fullscreenElement&&e.fullscreenElement===i)},GS=i=>{const e=tu(i);return!!(e&&e.pictureInPictureElement&&e.pictureInPictureElement===i)},YS=3;var qS=(i,e,t=YS)=>{let r=0,s=0;for(let n=0;n<i.length;n++){const o=i.start(n),l=i.end(n);if(o<=e&&e<=l){if(r=o,s=l,!t)return{from:r,to:s};for(let d=n-1;d>=0;d--)i.end(d)+t>=r&&(r=i.start(d));for(let d=n+1;d<i.length;d++)i.start(d)-t<=s&&(s=i.end(d))}}return{from:r,to:s}};const Tt=i=>{const e=T=>a.fromEvent(i,T).pipe(a.mapTo(void 0)),t=["waiting","pause","canplay","play","canplaythrough","playing","seeking","seeked","ended"],r=a.merge(...t.map(T=>a.fromEvent(i,T))).pipe(a.map(T=>T.type==="ended"?i.readyState<2:i.readyState<3),a.filterChanged()),s=a.merge(a.fromEvent(i,"progress"),a.fromEvent(i,"timeupdate")).pipe(a.map(()=>qS(i.buffered,i.currentTime))),o=a.getCurrentBrowser().browser===a.CurrentClientBrowser.Safari?a.combine({play:e("play").pipe(a.once()),playing:e("playing")}).pipe(a.mapTo(void 0)):e("playing"),l=a.fromEvent(i,"volumechange").pipe(a.map(()=>({muted:i.muted,volume:i.volume}))),d=a.fromEvent(i,"ratechange").pipe(a.map(()=>i.playbackRate)),u=a.fromEvent(i,"error").pipe(a.filter(()=>!!(i.error||i.played.length)),a.map(()=>{var T;const E=i.error;return{id:E?`MediaError#${E.code}`:"HtmlVideoError",category:a.ErrorCategory.VIDEO_PIPELINE,message:E?E.message:"Error event from HTML video element",thrown:(T=i.error)!==null&&T!==void 0?T:void 0}})),c=a.fromEvent(i,"timeupdate").pipe(a.map(()=>i.currentTime)),h=new a.Subject,f=.3;let p;c.subscribe(T=>{i.loop&&a.isNonNullable(p)&&a.isNonNullable(T)&&p>=i.duration-f&&T<=f&&h.next(p),p=T});const v=a.fromEvent(i,"enterpictureinpicture"),m=a.fromEvent(i,"leavepictureinpicture"),S=new a.ValueSubject(GS(i));v.subscribe(()=>S.next(!0)),m.subscribe(()=>S.next(!1));const b=new a.ValueSubject(uo(i));return a.fromEvent(i,"fullscreenchange").pipe(a.map(()=>uo(i))).subscribe(b),{playing$:o,pause$:e("pause").pipe(a.filter(()=>!i.error)),canplay$:e("canplay"),ended$:e("ended"),looped$:h,error$:u,seeked$:e("seeked"),seeking$:e("seeking"),progress$:e("progress"),loadStart$:e("loadstart"),loadedMetadata$:e("loadedmetadata"),loadedData$:e("loadeddata"),timeUpdate$:c,durationChange$:a.fromEvent(i,"durationchange").pipe(a.map(()=>i.duration)),isBuffering$:r,currentBuffer$:s,volumeState$:l,playbackRateState$:d,inPiP$:S,inFullscreen$:b}};var gr=i=>{switch(i){case"mobile":return a.VideoQuality.Q_144P;case"lowest":return a.VideoQuality.Q_240P;case"low":return a.VideoQuality.Q_360P;case"sd":case"medium":return a.VideoQuality.Q_480P;case"hd":case"high":return a.VideoQuality.Q_720P;case"fullhd":case"full":return a.VideoQuality.Q_1080P;case"quadhd":case"quad":return a.VideoQuality.Q_1440P;case"ultrahd":case"ultra":return a.VideoQuality.Q_2160P}},WS=Ce,zS=pr,QS=fa,KS=ha;WS({target:"Array",proto:!0},{at:function(e){var t=zS(this),r=QS(t),s=KS(e),n=s>=0?s:r+s;return n<0||n>=r?void 0:t[n]}});var JS=Pa,XS=JS("Array","at"),ZS=XS,eb=ZS,tb=eb,ib=tb,Fe=lr(ib);let Ia=!1,je={};const rb=i=>{Ia=i},sb=()=>{je={}},ab=i=>{i(je)},Ui=(i,e)=>{var t;Ia&&(je.meta=(t=je.meta)!==null&&t!==void 0?t:{},je.meta[i]=e)};class xe{constructor(e){this.name=e}next(e){var t,r;if(!Ia)return;je.series=(t=je.series)!==null&&t!==void 0?t:{};const s=(r=je.series[this.name])!==null&&r!==void 0?r:[];s.push([Date.now(),e]),je.series[this.name]=s}}var dt;(function(i){i.FitsContainer="FitsContainer",i.FitsThroughput="FitsThroughput",i.Buffer="Buffer",i.DroppedFramesLimit="DroppedFramesLimit",i.FitsQualityLimits="FitsQualityLimits"})(dt||(dt={}));const nb=new xe("best_bitrate"),ob=(i,e,t)=>(e-t)*Math.pow(2,-10*i)+t;class lb{constructor(){this.history={}}recordSelection(e){this.history[e.id]=a.now()}recordSwitch(e){this.last=e}clear(){this.last=void 0,this.history={}}}const ub='Assertion "ABR Tracks is empty array" failed',yr=(i,{container:e,throughput:t,tuning:r,limits:s,reserve:n=0,forwardBufferHealth:o,playbackRate:l,current:d,history:u,droppedVideoMaxQualityLimit:c,abrLogger:h})=>{var f,p,v,m,S;a.assertNotEmptyArray(i,ub);const b=r.usePixelRatio&&(f=window.devicePixelRatio)!==null&&f!==void 0?f:1,y=r.limitByContainer&&e&&e.width>0&&e.height>0&&{width:e.width*b*r.containerSizeFactor,height:e.height*b*r.containerSizeFactor},T=y&&a.videoSizeToQuality(y),E=r.considerPlaybackRate&&a.isNonNullable(l)?l:1,$=i.filter(R=>!a.isInvariantQuality(R.quality)).sort((R,P)=>a.isHigher(R.quality,P.quality)?-1:1),O=(p=Fe($,-1))===null||p===void 0?void 0:p.quality,M=(v=Fe($,0))===null||v===void 0?void 0:v.quality,F=a.isNullable(s)||a.isNonNullable(s.min)&&a.isNonNullable(s.max)&&a.isLower(s.max,s.min)||a.isNonNullable(s.min)&&M&&a.isHigher(s.min,M)||a.isNonNullable(s.max)&&O&&a.isLower(s.max,O),x=E*ob(o!=null?o:.5,r.bitrateFactorAtEmptyBuffer,r.bitrateFactorAtFullBuffer),U={},I=$.filter(R=>(T?a.isLower(R.quality,T):!0)?(a.isNonNullable(t)&&isFinite(t)&&a.isNonNullable(R.bitrate)?t-n>=R.bitrate*x:!0)?r.lazyQualitySwitch&&a.isNonNullable(r.minBufferToSwitchUp)&&d&&!a.isInvariantQuality(d.quality)&&(o!=null?o:0)<r.minBufferToSwitchUp&&a.isHigher(R.quality,d.quality)?(U[R.quality]=dt.Buffer,!1):!!c&&a.isHigherOrEqual(R.quality,c)?(U[R.quality]=dt.DroppedFramesLimit,!1):F||(a.isNullable(s.max)||a.isLowerOrEqual(R.quality,s.max))&&(a.isNullable(s.min)||a.isHigherOrEqual(R.quality,s.min))?!0:(U[R.quality]=dt.FitsQualityLimits,!1):(U[R.quality]=dt.FitsThroughput,!1):(U[R.quality]=dt.FitsContainer,!1))[0];I&&I.bitrate&&nb.next(I.bitrate);const A=(m=I!=null?I:$[Math.ceil(($.length-1)/2)])!==null&&m!==void 0?m:i[0];A.quality!==((S=u==null?void 0:u.last)===null||S===void 0?void 0:S.quality)&&h({message:`
7
7
  [available tracks]
8
8
  ${i.map(R=>`{ id: ${R.id}, quality: ${R.quality}, bitrate: ${R.bitrate} }`).join(`
9
9
  `)}