@vkontakte/videoplayer-core 2.0.156 → 2.0.157-dev.55dfadaf.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 +4 -4
- package/es2015.esm.js +4 -4
- package/es2018.cjs +4 -4
- package/es2018.esm.js +4 -4
- package/es2024.cjs +4 -4
- package/es2024.esm.js +4 -4
- package/esnext.cjs +4 -4
- package/esnext.esm.js +4 -4
- package/evergreen.esm.js +4 -4
- package/package.json +2 -2
package/es2015.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-core v2.0.
|
|
3
|
-
*
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/2-0-
|
|
2
|
+
* @vkontakte/videoplayer-core v2.0.157-dev.55dfadaf.0
|
|
3
|
+
* Wed, 25 Mar 2026 07:46:46 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/2-0-157/doc/
|
|
5
5
|
*/
|
|
6
6
|
const e=[`url`],t=[`url`],n=[`downloadingItems`],r=[`container`];var i=require(`@oxc-project/runtime/helpers/defineProperty`),a=require(`@oxc-project/runtime/helpers/asyncToGenerator`),o=require(`@oxc-project/runtime/helpers/objectSpread2`),s=require(`@oxc-project/runtime/helpers/awaitAsyncGenerator`),c=require(`@oxc-project/runtime/helpers/wrapAsyncGenerator`),l=require(`@oxc-project/runtime/helpers/objectWithoutProperties`),u=Object.create,d=Object.getPrototypeOf,f=Object.defineProperty,p=Object.getOwnPropertyNames,m=Object.getOwnPropertyDescriptor,h=Object.prototype.hasOwnProperty;function g(e){return this[e]}var _,v,y=(e,t,n)=>{var r=typeof e==`object`&&!!e;if(r){var i=t?_??=new WeakMap:v??=new WeakMap,a=i.get(e);if(a)return a}n=e==null?{}:u(d(e));let o=t||!e||!e.__esModule?f(n,`default`,{value:e,enumerable:!0}):n;for(let t of p(e))h.call(o,t)||f(o,t,{get:g.bind(e,t),enumerable:!0});return r&&i.set(e,o),o},b=e=>{var t=(x??=new WeakMap).get(e),n;if(t)return t;if(t=f({},`__esModule`,{value:!0}),e&&typeof e==`object`||typeof e==`function`)for(var r of p(e))h.call(t,r)||f(t,r,{get:g.bind(e,r),enumerable:!(n=m(e,r))||n.enumerable});return x.set(e,t),t},x,S=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),C=e=>e;function w(e,t){this[e]=C.bind(null,t)}var T=(e,t)=>{for(var n in t)f(e,n,{get:t[n],enumerable:!0,configurable:!0,set:w.bind(t,n)})},E=S((e,t)=>{var n=function(e){return e&&e.Math===Math&&e};t.exports=n(typeof globalThis==`object`&&globalThis)||n(typeof window==`object`&&window)||n(typeof self==`object`&&self)||n(typeof global==`object`&&global)||n(typeof e==`object`&&e)||function(){return this}()||Function(`return this`)()}),D=S((e,t)=>{t.exports=function(e){try{return!!e()}catch{return!0}}}),O=S((e,t)=>{t.exports=!D()(function(){var e=function(){}.bind();return typeof e!=`function`||e.hasOwnProperty(`prototype`)})}),ee=S((e,t)=>{var n=O(),r=Function.prototype,i=r.apply,a=r.call;t.exports=typeof Reflect==`object`&&Reflect.apply||(n?a.bind(i):function(){return a.apply(i,arguments)})}),k=S((e,t)=>{var n=O(),r=Function.prototype,i=r.call,a=n&&r.bind.bind(i,i);t.exports=n?a:function(e){return function(){return i.apply(e,arguments)}}}),te=S((e,t)=>{var n=k(),r=n({}.toString),i=n(``.slice);t.exports=function(e){return i(r(e),8,-1)}}),ne=S((e,t)=>{var n=te(),r=k();t.exports=function(e){if(n(e)===`Function`)return r(e)}}),re=S((e,t)=>{var n=typeof document==`object`&&document.all;t.exports=n===void 0&&n!==void 0?function(e){return typeof e==`function`||e===n}:function(e){return typeof e==`function`}}),A=S((e,t)=>{t.exports=!D()(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})}),ie=S((e,t)=>{var n=O(),r=Function.prototype.call;t.exports=n?r.bind(r):function(){return r.apply(r,arguments)}}),ae=S(e=>{var t={}.propertyIsEnumerable,n=Object.getOwnPropertyDescriptor;e.f=n&&!t.call({1:2},1)?function(e){var t=n(this,e);return!!t&&t.enumerable}:t}),oe=S((e,t)=>{t.exports=function(e,t){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:t}}}),se=S((e,t)=>{var n=k(),r=D(),i=te(),a=Object,o=n(``.split);t.exports=r(function(){return!a(`z`).propertyIsEnumerable(0)})?function(e){return i(e)===`String`?o(e,``):a(e)}:a}),ce=S((e,t)=>{t.exports=function(e){return e==null}}),le=S((e,t)=>{var n=ce(),r=TypeError;t.exports=function(e){if(n(e))throw new r(`Can't call method on `+e);return e}}),ue=S((e,t)=>{var n=se(),r=le();t.exports=function(e){return n(r(e))}}),de=S((e,t)=>{var n=re();t.exports=function(e){return typeof e==`object`?e!==null:n(e)}}),fe=S((e,t)=>{t.exports={}}),pe=S((e,t)=>{var n=fe(),r=E(),i=re(),a=function(e){return i(e)?e:void 0};t.exports=function(e,t){return arguments.length<2?a(n[e])||a(r[e]):n[e]&&n[e][t]||r[e]&&r[e][t]}}),me=S((e,t)=>{t.exports=k()({}.isPrototypeOf)}),he=S((e,t)=>{var n=E().navigator,r=n&&n.userAgent;t.exports=r?String(r):``}),ge=S((e,t)=>{var n=E(),r=he(),i=n.process,a=n.Deno,o=i&&i.versions||a&&a.version,s=o&&o.v8,c,l;s&&(c=s.split(`.`),l=c[0]>0&&c[0]<4?1:+(c[0]+c[1])),!l&&r&&(c=r.match(/Edge\/(\d+)/),(!c||c[1]>=74)&&(c=r.match(/Chrome\/(\d+)/),c&&(l=+c[1]))),t.exports=l}),_e=S((e,t)=>{var n=ge(),r=D(),i=E().String;t.exports=!!Object.getOwnPropertySymbols&&!r(function(){var e=Symbol(`symbol detection`);return!i(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&n&&n<41})}),ve=S((e,t)=>{t.exports=_e()&&!Symbol.sham&&typeof Symbol.iterator==`symbol`}),ye=S((e,t)=>{var n=pe(),r=re(),i=me(),a=ve(),o=Object;t.exports=a?function(e){return typeof e==`symbol`}:function(e){var t=n(`Symbol`);return r(t)&&i(t.prototype,o(e))}}),be=S((e,t)=>{var n=String;t.exports=function(e){try{return n(e)}catch{return`Object`}}}),xe=S((e,t)=>{var n=re(),r=be(),i=TypeError;t.exports=function(e){if(n(e))return e;throw new i(r(e)+` is not a function`)}}),Se=S((e,t)=>{var n=xe(),r=ce();t.exports=function(e,t){var i=e[t];return r(i)?void 0:n(i)}}),Ce=S((e,t)=>{var n=ie(),r=re(),i=de(),a=TypeError;t.exports=function(e,t){var o,s;if(t===`string`&&r(o=e.toString)&&!i(s=n(o,e))||r(o=e.valueOf)&&!i(s=n(o,e))||t!==`string`&&r(o=e.toString)&&!i(s=n(o,e)))return s;throw new a(`Can't convert object to primitive value`)}}),we=S((e,t)=>{t.exports=!0}),Te=S((e,t)=>{var n=E(),r=Object.defineProperty;t.exports=function(e,t){try{r(n,e,{value:t,configurable:!0,writable:!0})}catch{n[e]=t}return t}}),Ee=S((e,t)=>{var n=we(),r=E(),i=Te(),a=`__core-js_shared__`,o=t.exports=r[a]||i(a,{});(o.versions||=[]).push({version:`3.43.0`,mode:n?`pure`:`global`,copyright:`© 2014-2025 Denis Pushkarev (zloirock.ru)`,license:`https://github.com/zloirock/core-js/blob/v3.43.0/LICENSE`,source:`https://github.com/zloirock/core-js`})}),De=S((e,t)=>{var n=Ee();t.exports=function(e,t){return n[e]||(n[e]=t||{})}}),Oe=S((e,t)=>{var n=le(),r=Object;t.exports=function(e){return r(n(e))}}),ke=S((e,t)=>{var n=k(),r=Oe(),i=n({}.hasOwnProperty);t.exports=Object.hasOwn||function(e,t){return i(r(e),t)}}),Ae=S((e,t)=>{var n=k(),r=0,i=Math.random(),a=n(1.1.toString);t.exports=function(e){return`Symbol(`+(e===void 0?``:e)+`)_`+a(++r+i,36)}}),je=S((e,t)=>{var n=E(),r=De(),i=ke(),a=Ae(),o=_e(),s=ve(),c=n.Symbol,l=r(`wks`),u=s?c.for||c:c&&c.withoutSetter||a;t.exports=function(e){return i(l,e)||(l[e]=o&&i(c,e)?c[e]:u(`Symbol.`+e)),l[e]}}),Me=S((e,t)=>{var n=ie(),r=de(),i=ye(),a=Se(),o=Ce(),s=je(),c=TypeError,l=s(`toPrimitive`);t.exports=function(e,t){if(!r(e)||i(e))return e;var s=a(e,l),u;if(s){if(t===void 0&&(t=`default`),u=n(s,e,t),!r(u)||i(u))return u;throw new c(`Can't convert object to primitive value`)}return t===void 0&&(t=`number`),o(e,t)}}),Ne=S((e,t)=>{var n=Me(),r=ye();t.exports=function(e){var t=n(e,`string`);return r(t)?t:t+``}}),Pe=S((e,t)=>{var n=E(),r=de(),i=n.document,a=r(i)&&r(i.createElement);t.exports=function(e){return a?i.createElement(e):{}}}),Fe=S((e,t)=>{var n=A(),r=D(),i=Pe();t.exports=!n&&!r(function(){return Object.defineProperty(i(`div`),`a`,{get:function(){return 7}}).a!==7})}),Ie=S(e=>{var t=A(),n=ie(),r=ae(),i=oe(),a=ue(),o=Ne(),s=ke(),c=Fe(),l=Object.getOwnPropertyDescriptor;e.f=t?l:function(e,t){if(e=a(e),t=o(t),c)try{return l(e,t)}catch{}if(s(e,t))return i(!n(r.f,e,t),e[t])}}),Le=S((e,t)=>{var n=D(),r=re(),i=/#|\.prototype\./,a=function(e,t){var i=s[o(e)];return i===l?!0:i===c?!1:r(t)?n(t):!!t},o=a.normalize=function(e){return String(e).replace(i,`.`).toLowerCase()},s=a.data={},c=a.NATIVE=`N`,l=a.POLYFILL=`P`;t.exports=a}),Re=S((e,t)=>{var n=ne(),r=xe(),i=O(),a=n(n.bind);t.exports=function(e,t){return r(e),t===void 0?e:i?a(e,t):function(){return e.apply(t,arguments)}}}),ze=S((e,t)=>{var n=A(),r=D();t.exports=n&&r(function(){return Object.defineProperty(function(){},`prototype`,{value:42,writable:!1}).prototype!==42})}),Be=S((e,t)=>{var n=de(),r=String,i=TypeError;t.exports=function(e){if(n(e))return e;throw new i(r(e)+` is not an object`)}}),Ve=S(e=>{var t=A(),n=Fe(),r=ze(),i=Be(),a=Ne(),o=TypeError,s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=`enumerable`,u=`configurable`,d=`writable`;e.f=t?r?function(e,t,n){if(i(e),t=a(t),i(n),typeof e==`function`&&t===`prototype`&&`value`in n&&d in n&&!n[d]){var r=c(e,t);r&&r[d]&&(e[t]=n.value,n={configurable:u in n?n[u]:r[u],enumerable:l in n?n[l]:r[l],writable:!1})}return s(e,t,n)}:s:function(e,t,r){if(i(e),t=a(t),i(r),n)try{return s(e,t,r)}catch{}if(`get`in r||`set`in r)throw new o(`Accessors not supported`);return`value`in r&&(e[t]=r.value),e}}),He=S((e,t)=>{var n=A(),r=Ve(),i=oe();t.exports=n?function(e,t,n){return r.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}}),Ue=S((e,t)=>{var n=E(),r=ee(),i=ne(),a=re(),o=Ie().f,s=Le(),c=fe(),l=Re(),u=He(),d=ke();Ee();var f=function(e){var t=function(n,i,a){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(n);case 2:return new e(n,i)}return new e(n,i,a)}return r(e,this,arguments)};return t.prototype=e.prototype,t};t.exports=function(e,t){var r=e.target,p=e.global,m=e.stat,h=e.proto,g=p?n:m?n[r]:n[r]&&n[r].prototype,_=p?c:c[r]||u(c,r,{})[r],v=_.prototype,y,b,x,S,C,w,T,E,D;for(S in t)y=s(p?S:r+(m?`.`:`#`)+S,e.forced),b=!y&&g&&d(g,S),w=_[S],b&&(e.dontCallGetSet?(D=o(g,S),T=D&&D.value):T=g[S]),C=b&&T?T:t[S],!(!y&&!h&&typeof w==typeof C)&&(E=e.bind&&b?l(C,n):e.wrap&&b?f(C):h&&a(C)?i(C):C,(e.sham||C&&C.sham||w&&w.sham)&&u(E,`sham`,!0),u(_,S,E),h&&(x=r+`Prototype`,d(c,x)||u(c,x,{}),u(c[x],S,C),e.real&&v&&(y||!v[S])&&u(v,S,C)))}}),We=S((e,t)=>{var n=De(),r=Ae(),i=n(`keys`);t.exports=function(e){return i[e]||(i[e]=r(e))}}),Ge=S((e,t)=>{t.exports=!D()(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})}),Ke=S((e,t)=>{var n=ke(),r=re(),i=Oe(),a=We(),o=Ge(),s=a(`IE_PROTO`),c=Object,l=c.prototype;t.exports=o?c.getPrototypeOf:function(e){var t=i(e);if(n(t,s))return t[s];var a=t.constructor;return r(a)&&t instanceof a?a.prototype:t instanceof c?l:null}}),qe=S((e,t)=>{var n=Math.ceil,r=Math.floor;t.exports=Math.trunc||function(e){var t=+e;return(t>0?r:n)(t)}}),Je=S((e,t)=>{var n=qe();t.exports=function(e){var t=+e;return t!==t||t===0?0:n(t)}}),Ye=S((e,t)=>{var n=Je(),r=Math.max,i=Math.min;t.exports=function(e,t){var a=n(e);return a<0?r(a+t,0):i(a,t)}}),Xe=S((e,t)=>{var n=Je(),r=Math.min;t.exports=function(e){var t=n(e);return t>0?r(t,9007199254740991):0}}),Ze=S((e,t)=>{var n=Xe();t.exports=function(e){return n(e.length)}}),Qe=S((e,t)=>{var n=ue(),r=Ye(),i=Ze(),a=function(e){return function(t,a,o){var s=n(t),c=i(s);if(c===0)return!e&&-1;var l=r(o,c),u;if(e&&a!==a){for(;c>l;)if(u=s[l++],u!==u)return!0}else for(;c>l;l++)if((e||l in s)&&s[l]===a)return e||l||0;return!e&&-1}};t.exports={includes:a(!0),indexOf:a(!1)}}),$e=S((e,t)=>{t.exports={}}),et=S((e,t)=>{var n=k(),r=ke(),i=ue(),a=Qe().indexOf,o=$e(),s=n([].push);t.exports=function(e,t){var n=i(e),c=0,l=[],u;for(u in n)!r(o,u)&&r(n,u)&&s(l,u);for(;t.length>c;)r(n,u=t[c++])&&(~a(l,u)||s(l,u));return l}}),tt=S((e,t)=>{t.exports=[`constructor`,`hasOwnProperty`,`isPrototypeOf`,`propertyIsEnumerable`,`toLocaleString`,`toString`,`valueOf`]}),nt=S((e,t)=>{var n=et(),r=tt();t.exports=Object.keys||function(e){return n(e,r)}}),rt=S((e,t)=>{var n=A(),r=D(),i=k(),a=Ke(),o=nt(),s=ue(),c=ae().f,l=i(c),u=i([].push),d=n&&r(function(){var e=Object.create(null);return e[2]=2,!l(e,2)}),f=function(e){return function(t){for(var r=s(t),i=o(r),c=d&&a(r)===null,f=i.length,p=0,m=[],h;f>p;)h=i[p++],(!n||(c?h in r:l(r,h)))&&u(m,e?[h,r[h]]:r[h]);return m}};t.exports={entries:f(!0),values:f(!1)}}),it=S(()=>{var e=Ue(),t=rt().values;e({target:`Object`,stat:!0},{values:function(e){return t(e)}})}),at=S((e,t)=>{it(),t.exports=fe().Object.values}),ot=S((e,t)=>{t.exports=at()}),st=S((e,t)=>{t.exports=ot()}),ct=S((e,t)=>{t.exports=function(){}}),lt=S(()=>{var e=Ue(),t=Qe().includes,n=D(),r=ct();e({target:`Array`,proto:!0,forced:n(function(){return![,].includes()})},{includes:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),r(`includes`)}),ut=S((e,t)=>{t.exports=pe()}),dt=S((e,t)=>{lt(),t.exports=ut()(`Array`,`includes`)}),ft=S((e,t)=>{t.exports=dt()}),pt=S((e,t)=>{t.exports=ft()}),mt=S(()=>{var e=Ue(),t=rt().entries;e({target:`Object`,stat:!0},{entries:function(e){return t(e)}})}),ht=S((e,t)=>{mt(),t.exports=fe().Object.entries}),gt=S((e,t)=>{t.exports=ht()}),_t=S((e,t)=>{t.exports=gt()}),vt=S((e,t)=>{t.exports={}}),yt=S((e,t)=>{var n=E(),r=re(),i=n.WeakMap;t.exports=r(i)&&/native code/.test(String(i))}),bt=S((e,t)=>{var n=yt(),r=E(),i=de(),a=He(),o=ke(),s=Ee(),c=We(),l=$e(),u=`Object already initialized`,d=r.TypeError,f=r.WeakMap,p,m,h,g=function(e){return h(e)?m(e):p(e,{})},_=function(e){return function(t){var n;if(!i(t)||(n=m(t)).type!==e)throw new d(`Incompatible receiver, `+e+` required`);return n}};n||s.state?(v=s.state||=new f,v.get=v.get,v.has=v.has,v.set=v.set,p=function(e,t){if(v.has(e))throw new d(u);return t.facade=e,v.set(e,t),t},m=function(e){return v.get(e)||{}},h=function(e){return v.has(e)}):(y=c(`state`),l[y]=!0,p=function(e,t){if(o(e,y))throw new d(u);return t.facade=e,a(e,y,t),t},m=function(e){return o(e,y)?e[y]:{}},h=function(e){return o(e,y)});var v,y;t.exports={set:p,get:m,has:h,enforce:g,getterFor:_}}),xt=S((e,t)=>{var n=A(),r=ke(),i=Function.prototype,a=n&&Object.getOwnPropertyDescriptor,o=r(i,`name`);t.exports={EXISTS:o,PROPER:o&&function(){}.name===`something`,CONFIGURABLE:o&&(!n||n&&a(i,`name`).configurable)}}),St=S(e=>{var t=A(),n=ze(),r=Ve(),i=Be(),a=ue(),o=nt();e.f=t&&!n?Object.defineProperties:function(e,t){i(e);for(var n=a(t),s=o(t),c=s.length,l=0,u;c>l;)r.f(e,u=s[l++],n[u]);return e}}),Ct=S((e,t)=>{t.exports=pe()(`document`,`documentElement`)}),wt=S((e,t)=>{var n=Be(),r=St(),i=tt(),a=$e(),o=Ct(),s=Pe(),c=We(),l=`>`,u=`<`,d=`prototype`,f=`script`,p=c(`IE_PROTO`),m=function(){},h=function(e){return u+f+l+e+u+`/`+f+l},g=function(e){e.write(h(``)),e.close();var t=e.parentWindow.Object;return e=null,t},_=function(){var e=s(`iframe`),t=`java`+f+`:`,n;return e.style.display=`none`,o.appendChild(e),e.src=String(t),n=e.contentWindow.document,n.open(),n.write(h(`document.F=Object`)),n.close(),n.F},v,y=function(){try{v=new ActiveXObject(`htmlfile`)}catch{}y=typeof document<`u`?document.domain&&v?g(v):_():g(v);for(var e=i.length;e--;)delete y[d][i[e]];return y()};a[p]=!0,t.exports=Object.create||function(e,t){var i;return e===null?i=y():(m[d]=n(e),i=new m,m[d]=null,i[p]=e),t===void 0?i:r.f(i,t)}}),Tt=S((e,t)=>{var n=He();t.exports=function(e,t,r,i){return i&&i.enumerable?e[t]=r:n(e,t,r),e}}),Et=S((e,t)=>{var n=D(),r=re(),i=de(),a=wt(),o=Ke(),s=Tt(),c=je(),l=we(),u=c(`iterator`),d=!1,f,p,m;[].keys&&(m=[].keys(),`next`in m?(p=o(o(m)),p!==Object.prototype&&(f=p)):d=!0),!i(f)||n(function(){var e={};return f[u].call(e)!==e})?f={}:l&&(f=a(f)),r(f[u])||s(f,u,function(){return this}),t.exports={IteratorPrototype:f,BUGGY_SAFARI_ITERATORS:d}}),Dt=S((e,t)=>{var n=je()(`toStringTag`),r={};r[n]=`z`,t.exports=String(r)===`[object z]`}),Ot=S((e,t)=>{var n=Dt(),r=re(),i=te(),a=je()(`toStringTag`),o=Object,s=i(function(){return arguments}())===`Arguments`,c=function(e,t){try{return e[t]}catch{}};t.exports=n?i:function(e){var t,n,l;return e===void 0?`Undefined`:e===null?`Null`:typeof(n=c(t=o(e),a))==`string`?n:s?i(t):(l=i(t))===`Object`&&r(t.callee)?`Arguments`:l}}),kt=S((e,t)=>{var n=Dt(),r=Ot();t.exports=n?{}.toString:function(){return`[object `+r(this)+`]`}}),At=S((e,t)=>{var n=Dt(),r=Ve().f,i=He(),a=ke(),o=kt(),s=je()(`toStringTag`);t.exports=function(e,t,c,l){var u=c?e:e&&e.prototype;u&&(a(u,s)||r(u,s,{configurable:!0,value:t}),l&&!n&&i(u,`toString`,o))}}),jt=S((e,t)=>{var n=Et().IteratorPrototype,r=wt(),i=oe(),a=At(),o=vt(),s=function(){return this};t.exports=function(e,t,c,l){var u=t+` Iterator`;return e.prototype=r(n,{next:i(+!l,c)}),a(e,u,!1,!0),o[u]=s,e}}),Mt=S((e,t)=>{var n=k(),r=xe();t.exports=function(e,t,i){try{return n(r(Object.getOwnPropertyDescriptor(e,t)[i]))}catch{}}}),Nt=S((e,t)=>{var n=de();t.exports=function(e){return n(e)||e===null}}),Pt=S((e,t)=>{var n=Nt(),r=String,i=TypeError;t.exports=function(e){if(n(e))return e;throw new i(`Can't set `+r(e)+` as a prototype`)}}),Ft=S((e,t)=>{var n=Mt(),r=de(),i=le(),a=Pt();t.exports=Object.setPrototypeOf||(`__proto__`in{}?function(){var e=!1,t={},o;try{o=n(Object.prototype,`__proto__`,`set`),o(t,[]),e=t instanceof Array}catch{}return function(t,n){return i(t),a(n),r(t)&&(e?o(t,n):t.__proto__=n),t}}():void 0)}),It=S((e,t)=>{var n=Ue(),r=ie(),i=we(),a=xt(),o=re(),s=jt(),c=Ke(),l=Ft(),u=At(),d=He(),f=Tt(),p=je(),m=vt(),h=Et(),g=a.PROPER,_=a.CONFIGURABLE,v=h.IteratorPrototype,y=h.BUGGY_SAFARI_ITERATORS,b=p(`iterator`),x=`keys`,S=`values`,C=`entries`,w=function(){return this};t.exports=function(e,t,a,p,h,T,E){s(a,t,p);var D=function(e){if(e===h&&ne)return ne;if(!y&&e&&e in k)return k[e];switch(e){case x:return function(){return new a(this,e)};case S:return function(){return new a(this,e)};case C:return function(){return new a(this,e)}}return function(){return new a(this)}},O=t+` Iterator`,ee=!1,k=e.prototype,te=k[b]||k[`@@iterator`]||h&&k[h],ne=!y&&te||D(h),re=t===`Array`&&k.entries||te,A,ie,ae;if(re&&(A=c(re.call(new e)),A!==Object.prototype&&A.next&&(!i&&c(A)!==v&&(l?l(A,v):o(A[b])||f(A,b,w)),u(A,O,!0,!0),i&&(m[O]=w))),g&&h===S&&te&&te.name!==S&&(!i&&_?d(k,`name`,S):(ee=!0,ne=function(){return r(te,this)})),h)if(ie={values:D(S),keys:T?ne:D(x),entries:D(C)},E)for(ae in ie)(y||ee||!(ae in k))&&f(k,ae,ie[ae]);else n({target:t,proto:!0,forced:y||ee},ie);return(!i||E)&&k[b]!==ne&&f(k,b,ne,{name:h}),m[t]=ne,ie}}),Lt=S((e,t)=>{t.exports=function(e,t){return{value:e,done:t}}}),Rt=S((e,t)=>{var n=ue(),r=ct(),i=vt(),a=bt(),o=Ve().f,s=It(),c=Lt(),l=we(),u=A(),d=`Array Iterator`,f=a.set,p=a.getterFor(d);t.exports=s(Array,`Array`,function(e,t){f(this,{type:d,target:n(e),index:0,kind:t})},function(){var e=p(this),t=e.target,n=e.index++;if(!t||n>=t.length)return e.target=null,c(void 0,!0);switch(e.kind){case`keys`:return c(n,!1);case`values`:return c(t[n],!1)}return c([n,t[n]],!1)},`values`);var m=i.Arguments=i.Array;if(r(`keys`),r(`values`),r(`entries`),!l&&u&&m.name!==`values`)try{o(m,`name`,{value:`values`})}catch{}}),zt=S((e,t)=>{var n=je(),r=vt(),i=n(`iterator`),a=Array.prototype;t.exports=function(e){return e!==void 0&&(r.Array===e||a[i]===e)}}),Bt=S((e,t)=>{var n=Ot(),r=Se(),i=ce(),a=vt(),o=je()(`iterator`);t.exports=function(e){if(!i(e))return r(e,o)||r(e,`@@iterator`)||a[n(e)]}}),Vt=S((e,t)=>{var n=ie(),r=xe(),i=Be(),a=be(),o=Bt(),s=TypeError;t.exports=function(e,t){var c=arguments.length<2?o(e):t;if(r(c))return i(n(c,e));throw new s(a(e)+` is not iterable`)}}),Ht=S((e,t)=>{var n=ie(),r=Be(),i=Se();t.exports=function(e,t,a){var o,s;r(e);try{if(o=i(e,`return`),!o){if(t===`throw`)throw a;return a}o=n(o,e)}catch(e){s=!0,o=e}if(t===`throw`)throw a;if(s)throw o;return r(o),a}}),Ut=S((e,t)=>{var n=Re(),r=ie(),i=Be(),a=be(),o=zt(),s=Ze(),c=me(),l=Vt(),u=Bt(),d=Ht(),f=TypeError,p=function(e,t){this.stopped=e,this.result=t},m=p.prototype;t.exports=function(e,t,h){var g=h&&h.that,_=!!(h&&h.AS_ENTRIES),v=!!(h&&h.IS_RECORD),y=!!(h&&h.IS_ITERATOR),b=!!(h&&h.INTERRUPTED),x=n(t,g),S,C,w,T,E,D,O,ee=function(e){return S&&d(S,`normal`),new p(!0,e)},k=function(e){return _?(i(e),b?x(e[0],e[1],ee):x(e[0],e[1])):b?x(e,ee):x(e)};if(v)S=e.iterator;else if(y)S=e;else{if(C=u(e),!C)throw new f(a(e)+` is not iterable`);if(o(C)){for(w=0,T=s(e);T>w;w++)if(E=k(e[w]),E&&c(m,E))return E;return new p(!1)}S=l(e,C)}for(D=v?e.next:S.next;!(O=r(D,S)).done;){try{E=k(O.value)}catch(e){d(S,`throw`,e)}if(typeof E==`object`&&E&&c(m,E))return E}return new p(!1)}}),Wt=S((e,t)=>{var n=A(),r=Ve(),i=oe();t.exports=function(e,t,a){n?r.f(e,t,i(0,a)):e[t]=a}}),Gt=S(()=>{var e=Ue(),t=Ut(),n=Wt();e({target:`Object`,stat:!0},{fromEntries:function(e){var r={};return t(e,function(e,t){n(r,e,t)},{AS_ENTRIES:!0}),r}})}),Kt=S((e,t)=>{Rt(),Gt(),t.exports=fe().Object.fromEntries}),qt=S((e,t)=>{t.exports={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}}),Jt=S(()=>{Rt();var e=qt(),t=E(),n=At(),r=vt();for(i in e)n(t[i],i),r[i]=r.Array;var i}),Yt=S((e,t)=>{var n=Kt();Jt(),t.exports=n}),Xt=S((e,t)=>{t.exports=Yt()}),Zt=S((e,t)=>{var n=E(),r=he(),i=te(),a=function(e){return r.slice(0,e.length)===e};t.exports=function(){return a(`Bun/`)?`BUN`:a(`Cloudflare-Workers`)?`CLOUDFLARE`:a(`Deno/`)?`DENO`:a(`Node.js/`)?`NODE`:n.Bun&&typeof Bun.version==`string`?`BUN`:n.Deno&&typeof Deno.version==`object`?`DENO`:i(n.process)===`process`?`NODE`:n.window&&n.document?`BROWSER`:`REST`}()}),Qt=S((e,t)=>{t.exports=Zt()===`NODE`}),$t=S((e,t)=>{var n=Ve();t.exports=function(e,t,r){return n.f(e,t,r)}}),en=S((e,t)=>{var n=pe(),r=$t(),i=je(),a=A(),o=i(`species`);t.exports=function(e){var t=n(e);a&&t&&!t[o]&&r(t,o,{configurable:!0,get:function(){return this}})}}),tn=S((e,t)=>{var n=me(),r=TypeError;t.exports=function(e,t){if(n(t,e))return e;throw new r(`Incorrect invocation`)}}),nn=S((e,t)=>{var n=k(),r=re(),i=Ee(),a=n(Function.toString);r(i.inspectSource)||(i.inspectSource=function(e){return a(e)}),t.exports=i.inspectSource}),rn=S((e,t)=>{var n=k(),r=D(),i=re(),a=Ot(),o=pe(),s=nn(),c=function(){},l=o(`Reflect`,`construct`),u=/^\s*(?:class|function)\b/,d=n(u.exec),f=!u.test(c),p=function(e){if(!i(e))return!1;try{return l(c,[],e),!0}catch{return!1}},m=function(e){if(!i(e))return!1;switch(a(e)){case`AsyncFunction`:case`GeneratorFunction`:case`AsyncGeneratorFunction`:return!1}try{return f||!!d(u,s(e))}catch{return!0}};m.sham=!0,t.exports=!l||r(function(){var e;return p(p.call)||!p(Object)||!p(function(){e=!0})||e})?m:p}),an=S((e,t)=>{var n=rn(),r=be(),i=TypeError;t.exports=function(e){if(n(e))return e;throw new i(r(e)+` is not a constructor`)}}),on=S((e,t)=>{var n=Be(),r=an(),i=ce(),a=je()(`species`);t.exports=function(e,t){var o=n(e).constructor,s;return o===void 0||i(s=n(o)[a])?t:r(s)}}),sn=S((e,t)=>{t.exports=k()([].slice)}),cn=S((e,t)=>{var n=TypeError;t.exports=function(e,t){if(e<t)throw new n(`Not enough arguments`);return e}}),ln=S((e,t)=>{var n=he();t.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(n)}),un=S((e,t)=>{var n=E(),r=ee(),i=Re(),a=re(),o=ke(),s=D(),c=Ct(),l=sn(),u=Pe(),d=cn(),f=ln(),p=Qt(),m=n.setImmediate,h=n.clearImmediate,g=n.process,_=n.Dispatch,v=n.Function,y=n.MessageChannel,b=n.String,x=0,S={},C=`onreadystatechange`,w,T,O,k;s(function(){w=n.location});var te=function(e){if(o(S,e)){var t=S[e];delete S[e],t()}},ne=function(e){return function(){te(e)}},A=function(e){te(e.data)},ie=function(e){n.postMessage(b(e),w.protocol+`//`+w.host)};(!m||!h)&&(m=function(e){d(arguments.length,1);var t=a(e)?e:v(e),n=l(arguments,1);return S[++x]=function(){r(t,void 0,n)},T(x),x},h=function(e){delete S[e]},p?T=function(e){g.nextTick(ne(e))}:_&&_.now?T=function(e){_.now(ne(e))}:y&&!f?(O=new y,k=O.port2,O.port1.onmessage=A,T=i(k.postMessage,k)):n.addEventListener&&a(n.postMessage)&&!n.importScripts&&w&&w.protocol!==`file:`&&!s(ie)?(T=ie,n.addEventListener(`message`,A,!1)):T=C in u(`script`)?function(e){c.appendChild(u(`script`))[C]=function(){c.removeChild(this),te(e)}}:function(e){setTimeout(ne(e),0)}),t.exports={set:m,clear:h}}),dn=S((e,t)=>{var n=E(),r=A(),i=Object.getOwnPropertyDescriptor;t.exports=function(e){if(!r)return n[e];var t=i(n,e);return t&&t.value}}),fn=S((e,t)=>{var n=function(){this.head=null,this.tail=null};n.prototype={add:function(e){var t={item:e,next:null},n=this.tail;n?n.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return(this.head=e.next)===null&&(this.tail=null),e.item}},t.exports=n}),pn=S((e,t)=>{var n=he();t.exports=/ipad|iphone|ipod/i.test(n)&&typeof Pebble<`u`}),mn=S((e,t)=>{var n=he();t.exports=/web0s(?!.*chrome)/i.test(n)}),hn=S((e,t)=>{var n=E(),r=dn(),i=Re(),a=un().set,o=fn(),s=ln(),c=pn(),l=mn(),u=Qt(),d=n.MutationObserver||n.WebKitMutationObserver,f=n.document,p=n.process,m=n.Promise,h=r(`queueMicrotask`),g,_,v,y,b;h||=(x=new o,S=function(){var e,t;for(u&&(e=p.domain)&&e.exit();t=x.get();)try{t()}catch(e){throw x.head&&g(),e}e&&e.enter()},!s&&!u&&!l&&d&&f?(_=!0,v=f.createTextNode(``),new d(S).observe(v,{characterData:!0}),g=function(){v.data=_=!_}):!c&&m&&m.resolve?(y=m.resolve(void 0),y.constructor=m,b=i(y.then,y),g=function(){b(S)}):u?g=function(){p.nextTick(S)}:(a=i(a,n),g=function(){a(S)}),function(e){x.head||g(),x.add(e)});var x,S;t.exports=h}),gn=S((e,t)=>{t.exports=function(e,t){try{arguments.length===1?console.error(e):console.error(e,t)}catch{}}}),_n=S((e,t)=>{t.exports=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}}}),vn=S((e,t)=>{t.exports=E().Promise}),yn=S((e,t)=>{var n=E(),r=vn(),i=re(),a=Le(),o=nn(),s=je(),c=Zt(),l=we(),u=ge(),d=r&&r.prototype,f=s(`species`),p=!1,m=i(n.PromiseRejectionEvent);t.exports={CONSTRUCTOR:a(`Promise`,function(){var e=o(r),t=e!==String(r);if(!t&&u===66||l&&!(d.catch&&d.finally))return!0;if(!u||u<51||!/native code/.test(e)){var n=new r(function(e){e(1)}),i=function(e){e(function(){},function(){})},a=n.constructor={};if(a[f]=i,p=n.then(function(){})instanceof i,!p)return!0}return!t&&(c===`BROWSER`||c===`DENO`)&&!m}),REJECTION_EVENT:m,SUBCLASSING:p}}),bn=S((e,t)=>{var n=xe(),r=TypeError,i=function(e){var t,i;this.promise=new e(function(e,n){if(t!==void 0||i!==void 0)throw new r(`Bad Promise constructor`);t=e,i=n}),this.resolve=n(t),this.reject=n(i)};t.exports.f=function(e){return new i(e)}}),xn=S(()=>{var e=Ue(),t=we(),n=Qt(),r=E(),i=fe(),a=ie(),o=Tt(),s=Ft(),c=At(),l=en(),u=xe(),d=re(),f=de(),p=tn(),m=on(),h=un().set,g=hn(),_=gn(),v=_n(),y=fn(),b=bt(),x=vn(),S=yn(),C=bn(),w=`Promise`,T=S.CONSTRUCTOR,D=S.REJECTION_EVENT,O=S.SUBCLASSING,ee=b.getterFor(w),k=b.set,te=x&&x.prototype,ne=x,A=te,ae=r.TypeError,oe=r.document,se=r.process,ce=C.f,le=ce,ue=!!(oe&&oe.createEvent&&r.dispatchEvent),pe=`unhandledrejection`,me=`rejectionhandled`,he=0,ge=1,_e=2,ve=1,ye=2,be,Se,Ce,Te,Ee=function(e){var t;return f(e)&&d(t=e.then)?t:!1},De=function(e,t){var n=t.value,r=t.state===ge,i=r?e.ok:e.fail,o=e.resolve,s=e.reject,c=e.domain,l,u,d;try{i?(r||(t.rejection===ye&&Me(t),t.rejection=ve),i===!0?l=n:(c&&c.enter(),l=i(n),c&&(c.exit(),d=!0)),l===e.promise?s(new ae(`Promise-chain cycle`)):(u=Ee(l))?a(u,l,o,s):o(l)):s(n)}catch(e){c&&!d&&c.exit(),s(e)}},Oe=function(e,t){e.notified||(e.notified=!0,g(function(){for(var n=e.reactions,r;r=n.get();)De(r,e);e.notified=!1,t&&!e.rejection&&Ae(e)}))},ke=function(e,t,n){var i,a;ue?(i=oe.createEvent(`Event`),i.promise=t,i.reason=n,i.initEvent(e,!1,!0),r.dispatchEvent(i)):i={promise:t,reason:n},!D&&(a=r[`on`+e])?a(i):e===pe&&_(`Unhandled promise rejection`,n)},Ae=function(e){a(h,r,function(){var t=e.facade,r=e.value,i=je(e),a;if(i&&(a=v(function(){n?se.emit(`unhandledRejection`,r,t):ke(pe,t,r)}),e.rejection=n||je(e)?ye:ve,a.error))throw a.value})},je=function(e){return e.rejection!==ve&&!e.parent},Me=function(e){a(h,r,function(){var t=e.facade;n?se.emit(`rejectionHandled`,t):ke(me,t,e.value)})},Ne=function(e,t,n){return function(r){e(t,r,n)}},Pe=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=_e,Oe(e,!0))},Fe=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw new ae(`Promise can't be resolved itself`);var r=Ee(t);r?g(function(){var n={done:!1};try{a(r,t,Ne(Fe,n,e),Ne(Pe,n,e))}catch(t){Pe(n,t,e)}}):(e.value=t,e.state=ge,Oe(e,!1))}catch(t){Pe({done:!1},t,e)}}};if(T&&(ne=function(e){p(this,A),u(e),a(be,this);var t=ee(this);try{e(Ne(Fe,t),Ne(Pe,t))}catch(e){Pe(t,e)}},A=ne.prototype,be=function(e){k(this,{type:w,done:!1,notified:!1,parent:!1,reactions:new y,rejection:!1,state:he,value:null})},be.prototype=o(A,`then`,function(e,t){var r=ee(this),i=ce(m(this,ne));return r.parent=!0,i.ok=d(e)?e:!0,i.fail=d(t)&&t,i.domain=n?se.domain:void 0,r.state===he?r.reactions.add(i):g(function(){De(i,r)}),i.promise}),Se=function(){var e=new be,t=ee(e);this.promise=e,this.resolve=Ne(Fe,t),this.reject=Ne(Pe,t)},C.f=ce=function(e){return e===ne||e===Ce?new Se(e):le(e)},!t&&d(x)&&te!==Object.prototype)){Te=te.then,O||o(te,`then`,function(e,t){var n=this;return new ne(function(e,t){a(Te,n,e,t)}).then(e,t)},{unsafe:!0});try{delete te.constructor}catch{}s&&s(te,A)}e({global:!0,constructor:!0,wrap:!0,forced:T},{Promise:ne}),Ce=i.Promise,c(ne,w,!1,!0),l(w)}),Sn=S((e,t)=>{var n=je()(`iterator`),r=!1;try{i=0,a={next:function(){return{done:!!i++}},return:function(){r=!0}},a[n]=function(){return this},Array.from(a,function(){throw 2})}catch{}var i,a;t.exports=function(e,t){try{if(!t&&!r)return!1}catch{return!1}var i=!1;try{var a={};a[n]=function(){return{next:function(){return{done:i=!0}}}},e(a)}catch{}return i}}),Cn=S((e,t)=>{var n=vn(),r=Sn();t.exports=yn().CONSTRUCTOR||!r(function(e){n.all(e).then(void 0,function(){})})}),wn=S(()=>{var e=Ue(),t=ie(),n=xe(),r=bn(),i=_n(),a=Ut();e({target:`Promise`,stat:!0,forced:Cn()},{all:function(e){var o=this,s=r.f(o),c=s.resolve,l=s.reject,u=i(function(){var r=n(o.resolve),i=[],s=0,u=1;a(e,function(e){var n=s++,a=!1;u++,t(r,o,e).then(function(e){a||(a=!0,i[n]=e,--u||c(i))},l)}),--u||c(i)});return u.error&&l(u.value),s.promise}})}),Tn=S(()=>{var e=Ue(),t=we(),n=yn().CONSTRUCTOR,r=vn(),i=pe(),a=re(),o=Tt(),s=r&&r.prototype;e({target:`Promise`,proto:!0,forced:n,real:!0},{catch:function(e){return this.then(void 0,e)}}),!t&&a(r)&&(c=i(`Promise`).prototype.catch,s.catch!==c&&o(s,`catch`,c,{unsafe:!0}));var c}),En=S(()=>{var e=Ue(),t=ie(),n=xe(),r=bn(),i=_n(),a=Ut();e({target:`Promise`,stat:!0,forced:Cn()},{race:function(e){var o=this,s=r.f(o),c=s.reject,l=i(function(){var r=n(o.resolve);a(e,function(e){t(r,o,e).then(s.resolve,c)})});return l.error&&c(l.value),s.promise}})}),Dn=S(()=>{var e=Ue(),t=bn(),n=yn().CONSTRUCTOR;e({target:`Promise`,stat:!0,forced:n},{reject:function(e){var n=t.f(this),r=n.reject;return r(e),n.promise}})}),On=S((e,t)=>{var n=Be(),r=de(),i=bn();t.exports=function(e,t){if(n(e),r(t)&&t.constructor===e)return t;var a=i.f(e),o=a.resolve;return o(t),a.promise}}),kn=S(()=>{var e=Ue(),t=pe(),n=we(),r=vn(),i=yn().CONSTRUCTOR,a=On(),o=t(`Promise`),s=n&&!i;e({target:`Promise`,stat:!0,forced:n||i},{resolve:function(e){return a(s&&this===o?r:this,e)}})}),An=S(()=>{xn(),wn(),Tn(),En(),Dn(),kn()}),jn=S(()=>{var e=Ue(),t=we(),n=vn(),r=D(),i=pe(),a=re(),o=on(),s=On(),c=Tt(),l=n&&n.prototype;e({target:`Promise`,proto:!0,real:!0,forced:!!n&&r(function(){l.finally.call({then:function(){}},function(){})})},{finally:function(e){var t=o(this,i(`Promise`)),n=a(e);return this.then(n?function(n){return s(t,e()).then(function(){return n})}:e,n?function(n){return s(t,e()).then(function(){throw n})}:e)}}),!t&&a(n)&&(u=i(`Promise`).prototype.finally,l.finally!==u&&c(l,`finally`,u,{unsafe:!0}));var u}),Mn=S((e,t)=>{An(),jn(),t.exports=ut()(`Promise`,`finally`)}),Nn=S((e,t)=>{t.exports=Mn()}),Pn=S((e,t)=>{t.exports=Nn()}),Fn=S(()=>{var e=Ue(),t=Oe(),n=Ze(),r=Je(),i=ct();e({target:`Array`,proto:!0},{at:function(e){var i=t(this),a=n(i),o=r(e),s=o>=0?o:a+o;return s<0||s>=a?void 0:i[s]}}),i(`at`)}),In=S((e,t)=>{Fn(),t.exports=ut()(`Array`,`at`)}),Ln=S((e,t)=>{t.exports=In()}),Rn=S((e,t)=>{t.exports=Ln()}),zn=S((e,t)=>{var n=Ot(),r=String;t.exports=function(e){if(n(e)===`Symbol`)throw TypeError(`Cannot convert a Symbol value to a string`);return r(e)}}),Bn=S(()=>{var e=Ue(),t=k(),n=le(),r=Je(),i=zn(),a=D(),o=t(``.charAt);e({target:`String`,proto:!0,forced:a(function(){return`𠮷`.at(-2)!==`\ud842`})},{at:function(e){var t=i(n(this)),a=t.length,s=r(e),c=s>=0?s:a+s;return c<0||c>=a?void 0:o(t,c)}})}),Vn=S((e,t)=>{Bn(),t.exports=ut()(`String`,`at`)}),Hn=S((e,t)=>{t.exports=Vn()}),Un=S((e,t)=>{t.exports=Hn()}),Wn=S((e,t)=>{var n=te();t.exports=Array.isArray||function(e){return n(e)===`Array`}}),Gn=S((e,t)=>{var n=TypeError,r=9007199254740991;t.exports=function(e){if(e>r)throw n(`Maximum allowed index exceeded`);return e}}),Kn=S((e,t)=>{var n=Wn(),r=Ze(),i=Gn(),a=Re(),o=function(e,t,s,c,l,u,d,f){for(var p=l,m=0,h=d?a(d,f):!1,g,_;m<c;)m in s&&(g=h?h(s[m],m,t):s[m],u>0&&n(g)?(_=r(g),p=o(e,t,g,_,p,u-1)-1):(i(p+1),e[p]=g),p++),m++;return p};t.exports=o}),qn=S((e,t)=>{var n=Wn(),r=rn(),i=de(),a=je()(`species`),o=Array;t.exports=function(e){var t;return n(e)&&(t=e.constructor,r(t)&&(t===o||n(t.prototype))?t=void 0:i(t)&&(t=t[a],t===null&&(t=void 0))),t===void 0?o:t}}),Jn=S((e,t)=>{var n=qn();t.exports=function(e,t){return new(n(e))(t===0?0:t)}}),Yn=S(()=>{var e=Ue(),t=Kn(),n=xe(),r=Oe(),i=Ze(),a=Jn();e({target:`Array`,proto:!0},{flatMap:function(e){var o=r(this),s=i(o),c;return n(e),c=a(o,0),c.length=t(c,o,o,s,0,1,e,arguments.length>1?arguments[1]:void 0),c}})}),Xn=S(()=>{ct()(`flatMap`)}),Zn=S((e,t)=>{Yn(),Xn(),t.exports=ut()(`Array`,`flatMap`)}),Qn=S((e,t)=>{t.exports=Zn()}),$n=S((e,t)=>{t.exports=Qn()}),er=S((e,t)=>{t.exports=`
|
|
7
|
-
\v\f\r \xA0 \u2028\u2029`}),tr=S((e,t)=>{var n=k(),r=le(),i=zn(),a=er(),o=n(``.replace),s=RegExp(`^[`+a+`]+`),c=RegExp(`(^|[^`+a+`])[`+a+`]+$`),l=function(e){return function(t){var n=i(r(t));return e&1&&(n=o(n,s,``)),e&2&&(n=o(n,c,`$1`)),n}};t.exports={start:l(1),end:l(2),trim:l(3)}}),nr=S((e,t)=>{var n=xt().PROPER,r=D(),i=er(),a=`
`;t.exports=function(e){return r(function(){return!!i[e]()||a[e]()!==a||n&&i[e].name!==e})}}),rr=S((e,t)=>{var n=tr().start;t.exports=nr()(`trimStart`)?function(){return n(this)}:``.trimStart}),ir=S(()=>{var e=Ue(),t=rr();e({target:`String`,proto:!0,name:`trimStart`,forced:``.trimLeft!==t},{trimLeft:t})}),ar=S(()=>{ir();var e=Ue(),t=rr();e({target:`String`,proto:!0,name:`trimStart`,forced:``.trimStart!==t},{trimStart:t})}),or=S((e,t)=>{ar(),t.exports=ut()(`String`,`trimLeft`)}),sr=S((e,t)=>{t.exports=or()}),cr=S((e,t)=>{t.exports=sr()}),lr=S((e,t)=>{var n=de(),r=te(),i=je()(`match`);t.exports=function(e){var t;return n(e)&&((t=e[i])===void 0?r(e)===`RegExp`:!!t)}}),ur=S((e,t)=>{var n=E(),r=D(),i=n.RegExp;t.exports={correct:!r(function(){var e=!0;try{i(`.`,`d`)}catch{e=!1}var t={},n=``,r=e?`dgimsy`:`gimsy`,a=function(e,r){Object.defineProperty(t,e,{get:function(){return n+=r,!0}})},o={dotAll:`s`,global:`g`,ignoreCase:`i`,multiline:`m`,sticky:`y`};for(var s in e&&(o.hasIndices=`d`),o)a(s,o[s]);return Object.getOwnPropertyDescriptor(i.prototype,`flags`).get.call(t)!==r||n!==r})}}),dr=S((e,t)=>{var n=Be();t.exports=function(){var e=n(this),t=``;return e.hasIndices&&(t+=`d`),e.global&&(t+=`g`),e.ignoreCase&&(t+=`i`),e.multiline&&(t+=`m`),e.dotAll&&(t+=`s`),e.unicode&&(t+=`u`),e.unicodeSets&&(t+=`v`),e.sticky&&(t+=`y`),t}}),fr=S((e,t)=>{var n=ie(),r=ke(),i=me(),a=ur(),o=dr(),s=RegExp.prototype;t.exports=a.correct?function(e){return e.flags}:function(e){return!a.correct&&i(s,e)&&!r(e,`flags`)?n(o,e):e.flags}}),pr=S((e,t)=>{var n=k(),r=Oe(),i=Math.floor,a=n(``.charAt),o=n(``.replace),s=n(``.slice),c=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,l=/\$([$&'`]|\d{1,2})/g;t.exports=function(e,t,n,u,d,f){var p=n+e.length,m=u.length,h=l;return d!==void 0&&(d=r(d),h=c),o(f,h,function(r,o){var c;switch(a(o,0)){case`$`:return`$`;case`&`:return e;case"`":return s(t,0,n);case`'`:return s(t,p);case`<`:c=d[s(o,1,-1)];break;default:var l=+o;if(l===0)return r;if(l>m){var f=i(l/10);return f===0?r:f<=m?u[f-1]===void 0?a(o,1):u[f-1]+a(o,1):r}c=u[l-1]}return c===void 0?``:c})}}),mr=S(()=>{var e=Ue(),t=ie(),n=k(),r=le(),i=re(),a=de(),o=lr(),s=zn(),c=Se(),l=fr(),u=pr(),d=je(),f=we(),p=d(`replace`),m=TypeError,h=n(``.indexOf),g=n(``.replace),_=n(``.slice),v=Math.max;e({target:`String`,proto:!0},{replaceAll:function(e,n){var d=r(this),y,b,x,S,C,w,T,E,D,O,ee=0,k=``;if(a(e)){if(y=o(e),y&&(b=s(r(l(e))),!~h(b,`g`)))throw new m("`.replaceAll` does not allow non-global regexes");if(x=c(e,p),x)return t(x,e,d,n);if(f&&y)return g(s(d),e,n)}for(S=s(d),C=s(e),w=i(n),w||(n=s(n)),T=C.length,E=v(1,T),D=h(S,C);D!==-1;)O=w?s(n(C,D,S)):u(C,S,D,[],void 0,n),k+=_(S,ee,D)+O,ee=D+T,D=D+E>S.length?-1:h(S,C,D+E);return ee<S.length&&(k+=_(S,ee)),k}})}),hr=S((e,t)=>{mr(),t.exports=ut()(`String`,`replaceAll`)}),gr=S((e,t)=>{t.exports=hr()}),_r=S((e,t)=>{t.exports=gr()}),vr=S((e,t)=>{var n=Je(),r=zn(),i=le(),a=RangeError;t.exports=function(e){var t=r(i(this)),o=``,s=n(e);if(s<0||s===1/0)throw new a(`Wrong number of repetitions`);for(;s>0;(s>>>=1)&&(t+=t))s&1&&(o+=t);return o}}),yr=S((e,t)=>{var n=k(),r=Xe(),i=zn(),a=vr(),o=le(),s=n(a),c=n(``.slice),l=Math.ceil,u=function(e){return function(t,n,a){var u=i(o(t)),d=r(n),f=u.length,p=a===void 0?` `:i(a),m,h;return d<=f||p===``?u:(m=d-f,h=s(p,l(m/p.length)),h.length>m&&(h=c(h,0,m)),e?u+h:h+u)}};t.exports={start:u(!1),end:u(!0)}}),br=S((e,t)=>{var n=he();t.exports=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(n)}),xr=S(()=>{var e=Ue(),t=yr().start;e({target:`String`,proto:!0,forced:br()},{padStart:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})}),Sr=S((e,t)=>{xr(),t.exports=ut()(`String`,`padStart`)}),Cr=S((e,t)=>{t.exports=Sr()}),wr=S((e,t)=>{t.exports=Cr()}),Tr={};T(Tr,{isMobile:()=>ni,clientChecker:()=>P,areValidLiveRecordSources:()=>Ei,WebmCodecStrategy:()=>$c,VideoQuality:()=>Ff.VideoQuality,VideoFormat:()=>Or,VideoCodec:()=>kr,ValueSubject:()=>Ff.ValueSubject,VERSION:()=>Er,Surface:()=>Mr,Subscription:()=>Ff.Subscription,Subject:()=>Ff.Subject,SDK_VERSION:()=>If,PredefinedQualityLimits:()=>Nr,Player:()=>Pf,PlaybackState:()=>Dr,Observable:()=>Ff.Observable,HttpConnectionType:()=>jr,ChromecastState:()=>Ar}),module.exports=b(Tr);var Er=`2.0.156`,Dr;(e=>{e.STOPPED=`stopped`,e.READY=`ready`,e.PLAYING=`playing`,e.PAUSED=`paused`})(Dr||={});var Or;(e=>{e.MPEG=`MPEG`,e.DASH=`DASH`,e.DASH_SEP=`DASH_SEP`,e.DASH_SEP_VK=`DASH_SEP`,e.DASH_WEBM=`DASH_WEBM`,e.DASH_WEBM_AV1=`DASH_WEBM_AV1`,e.DASH_STREAMS=`DASH_STREAMS`,e.DASH_WEBM_VK=`DASH_WEBM`,e.DASH_ONDEMAND=`DASH_ONDEMAND`,e.DASH_ONDEMAND_VK=`DASH_ONDEMAND`,e.DASH_LIVE=`DASH_LIVE`,e.DASH_LIVE_CMAF=`DASH_LIVE_CMAF`,e.DASH_LIVE_WEBM=`DASH_LIVE_WEBM`,e.HLS=`HLS`,e.HLS_ONDEMAND=`HLS_ONDEMAND`,e.HLS_JS=`HLS`,e.HLS_FMP4=`HLS_FMP4`,e.HLS_LIVE=`HLS_LIVE`,e.HLS_LIVE_CMAF=`HLS_LIVE_CMAF`,e.WEB_RTC_LIVE=`WEB_RTC_LIVE`})(Or||={});var kr;(e=>{e.AV1=`av1`,e.VP9=`vp9`,e.AVC1=`avc1`,e.HEV1=`hev1`})(kr||={});var Ar;(e=>{e.NOT_AVAILABLE=`NOT_AVAILABLE`,e.AVAILABLE=`AVAILABLE`,e.CONNECTING=`CONNECTING`,e.CONNECTED=`CONNECTED`})(Ar||={});var jr;(e=>{e.HTTP1=`http1`,e.HTTP2=`http2`,e.QUIC=`quic`})(jr||={});var Mr;(e=>{e.NONE=`none`,e.INLINE=`inline`,e.FULLSCREEN=`fullscreen`,e.SECOND_SCREEN=`second_screen`,e.PIP=`pip`,e.INVISIBLE=`invisible`})(Mr||={});var Nr;(e=>{e.TRAFFIC_SAVING=`traffic_saving`,e.HIGH_QUALITY=`high_quality`,e.UNKNOWN=`unknown`})(Nr||={});var Pr=y(st(),1),Fr=y(pt(),1),j=require(`@vkontakte/videoplayer-shared/es2015`),Ir=e=>new Promise((t,n)=>{let r=document.createElement(`script`);r.setAttribute(`src`,e),r.onload=()=>t(),r.onerror=e=>n(e),document.body.appendChild(r)});class Lr{constructor(e){i(this,`connection$`,new j.ValueSubject(void 0)),i(this,`castState$`,new j.ValueSubject(`NOT_AVAILABLE`)),i(this,`errorEvent$`,new j.Subject),i(this,`contentId`,void 0),i(this,`realCastState$`,new j.ValueSubject(`NOT_AVAILABLE`)),i(this,`subscription`,new j.Subscription),i(this,`log`,void 0),i(this,`params`,void 0),i(this,`isDestroyed`,!1),this.params=e,this.log=this.params.dependencies.logger.createComponentLog(`ChromecastInitializer`);let t=`chrome`in window;if(this.log({message:`[constructor] receiverApplicationId: ${this.params.receiverApplicationId}, isDisabled: ${this.params.isDisabled}, isSupported: ${t}`}),e.isDisabled||!t)return;let n=j.isNonNullable(window.chrome?.cast),r=!!window.__onGCastApiAvailable;n?this.initializeCastApi():(window.__onGCastApiAvailable=e=>{delete window.__onGCastApiAvailable,e&&!this.isDestroyed&&this.initializeCastApi()},r||Ir(`https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1`).catch(()=>this.errorEvent$.next({id:`ChromecastLoading`,category:j.ErrorCategory.NETWORK,message:`Script loading failed!`})))}connect(){cast.framework.CastContext.getInstance()?.requestSession()}disconnect(){var e;(e=cast.framework.CastContext.getInstance())==null||(e=e.getCurrentSession())==null||e.endSession(!0)}stopMedia(){return new Promise((e,t)=>{var n;(n=cast.framework.CastContext.getInstance())==null||(n=n.getCurrentSession())==null||(n=n.getMediaSession())==null||n.stop(new chrome.cast.media.StopRequest,e,t)})}toggleConnection(){j.isNonNullable(this.connection$.getValue())?this.disconnect():this.connect()}setVolume(e){let t=this.connection$.getValue();j.isNullable(t)||(t.remotePlayer.volumeLevel=e,t.remotePlayerController.setVolumeLevel())}setMuted(e){let t=this.connection$.getValue();j.isNullable(t)||e!==t.remotePlayer.isMuted&&t.remotePlayerController.muteOrUnmute()}destroy(){this.isDestroyed=!0,this.subscription.unsubscribe()}initListeners(){let e=new cast.framework.RemotePlayer,t=new cast.framework.RemotePlayerController(e),n=cast.framework.CastContext.getInstance();this.subscription.add(j.fromEvent(n,cast.framework.CastContextEventType.SESSION_STATE_CHANGED).subscribe(e=>{switch(e.sessionState){case cast.framework.SessionState.SESSION_STARTED:case cast.framework.SessionState.SESSION_STARTING:case cast.framework.SessionState.SESSION_RESUMED:var t;this.contentId=(t=n.getCurrentSession())==null||(t=t.getMediaSession())==null||(t=t.media)==null?void 0:t.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 j.assertNever(e.sessionState)}})).add(j.merge(j.fromEvent(n,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe(j.tap(e=>{this.log({message:`[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: ${JSON.stringify(e)}`})}),j.map(e=>e.castState)),j.observableFrom([n.getCastState()])).pipe(j.filterChanged(),j.map(Rr),j.tap(e=>{this.log({message:`realCastState$: ${e}`})})).subscribe(this.realCastState$)).add(this.realCastState$.subscribe(r=>{let i=r===`CONNECTED`,a=j.isNonNullable(this.connection$.getValue());if(i&&!a){var o;let r=n.getCurrentSession();j.assertNonNullable(r);let i=r.getCastDevice(),a=(o=r.getMediaSession())==null||(o=o.media)==null?void 0:o.contentId;(j.isNullable(a)||a===this.contentId)&&(this.log({message:`connection created`}),this.connection$.next({remotePlayer:e,remotePlayerController:t,session:r,castDevice:i}))}else !i&&a&&(this.log({message:`connection destroyed`}),this.connection$.next(void 0));this.castState$.next(r===`CONNECTED`?j.isNonNullable(this.connection$.getValue())?`CONNECTED`:`AVAILABLE`:r)}))}initializeCastApi(){let e,t,n;try{e=cast.framework.CastContext.getInstance(),t=chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,n=chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}catch{return}try{e.setOptions({receiverApplicationId:this.params.receiverApplicationId??t,autoJoinPolicy:n}),this.initListeners()}catch(e){this.errorEvent$.next({id:`ChromecastInitializer`,category:j.ErrorCategory.EXTERNAL_API,message:`[initializeCastApi] failed`,thrown:e})}}}var Rr=e=>{switch(e){case cast.framework.CastState.NO_DEVICES_AVAILABLE:return`NOT_AVAILABLE`;case cast.framework.CastState.NOT_CONNECTED:return`AVAILABLE`;case cast.framework.CastState.CONNECTING:return`CONNECTING`;case cast.framework.CastState.CONNECTED:return`CONNECTED`;default:return j.assertNever(e)}},M=require(`@vkontakte/videoplayer-shared/es2015`),zr=require(`@vkontakte/videoplayer-shared/es2015`),Br=require(`@vkontakte/videoplayer-shared/es2015`),Vr=(e,t=0,n=0)=>{switch(n){case 0:return e.replace(`_offset_p`,t===0?``:`_`+t.toFixed(0));case 1:{if(t===0)return e;let n=new URL(e);return n.searchParams.append(`playback_shift`,t.toFixed(0)),n.toString()}case 2:{let n=new URL(e);return!n.searchParams.get(`offset_p`)&&t===0?e:(n.searchParams.set(`offset_p`,t.toFixed(0)),n.toString())}default:Br.assertNever(n)}return e},Hr=(e,t)=>{switch(t){case 0:return NaN;case 1:{let t=new URL(e);return Number(t.searchParams.get(`playback_shift`))}case 2:{let t=new URL(e);return Number(t.searchParams.get(`offset_p`)??0)}default:Br.assertNever(t)}},Ur=e=>{let{source:t,format:n,meta:r,output:i}=e,a,o,s;switch(n){case`MPEG`:{let e=t[n];zr.assertNonNullable(e);let r=zr.getHighestQuality(Object.keys(e));zr.assertNonNullable(r);let i=e[r];zr.assertNonNullable(i),a=i,o=`video/mp4`,s=Wr();break}case`HLS`:case`HLS_FMP4`:case`HLS_ONDEMAND`:{let e=t[n];zr.assertNonNullable(e),a=e.url,o=`application/x-mpegurl`,s=Wr();break}case`DASH_SEP`:case`DASH_ONDEMAND`:case`DASH_WEBM`:case`DASH_WEBM_AV1`:case`DASH_STREAMS`:{let e=t[n];zr.assertNonNullable(e),a=e.url,o=`application/dash+xml`,s=Wr();break}case`DASH_LIVE_CMAF`:{let e=t[n];zr.assertNonNullable(e),a=e.url,o=`application/dash+xml`,s=Gr();break}case`HLS_LIVE`:case`HLS_LIVE_CMAF`:{let e=t[n];zr.assertNonNullable(e),a=Vr(e.url),o=`application/x-mpegurl`,s=Gr();break}case`DASH_LIVE`:case`WEB_RTC_LIVE`:{let e=`Unsupported format for Chromecast`,t=Error(e);throw i.error$.next({id:`ChromecastProvider.createMediaInfo()`,category:zr.ErrorCategory.VIDEO_PIPELINE,message:e,thrown:t}),t}case`DASH`:case`DASH_LIVE_WEBM`:throw Error(`${n} is no longer supported`);default:return zr.assertNever(n)}let c=Kr(r.videoId??a,o);c.contentUrl=a,c.streamType=s,c.metadata=qr();let{title:l,subtitle:u}=r;return zr.isNonNullable(l)&&(c.metadata.title=l),zr.isNonNullable(u)&&(c.metadata.subtitle=u),c};function Wr(){var e;return((e=chrome.cast)==null||(e=e.media)==null||(e=e.StreamType)==null?void 0:e.BUFFERED)??`BUFFERED`}function Gr(){var e;return((e=chrome.cast)==null||(e=e.media)==null||(e=e.StreamType)==null?void 0:e.LIVE)??`LIVE`}function Kr(e,t){var n;return!((n=chrome.cast)==null||(n=n.media)==null)&&n.MediaInfo?new chrome.cast.media.MediaInfo(e,t):{contentId:e,contentType:t,metadata:{title:``,subtitle:``},streamType:Wr()}}function qr(){var e;return!((e=chrome.cast)==null||(e=e.media)==null)&&e.GenericMediaMetadata?new chrome.cast.media.GenericMediaMetadata:{images:[],metadataType:0,releaseDate:``,subtitle:``,title:``,releaseYear:1970,type:0}}var N=(e,t,n=!1)=>{let r=e.getTransition();(n||!r||r.to===t)&&e.setState(t)};class Jr{constructor(e){i(this,`params`,void 0),i(this,`interval`,0),i(this,`startVideoPosition`,void 0),i(this,`startTs`,void 0),this.params=e}start(e=0){clearInterval(this.interval),this.startVideoPosition=e,this.startTs=Date.now(),this.interval=window.setInterval(()=>{let e=(Date.now()-this.startTs)/1e3,t=this.startVideoPosition+e;this.params.output.position$.next(t)},1e3)}pause(){clearInterval(this.interval)}destroy(){clearInterval(this.interval)}}var Yr=require(`@vkontakte/videoplayer-shared/es2015`),Xr=require(`@vkontakte/videoplayer-shared/es2015`),Zr=y(pt(),1),Qr=require(`@vkontakte/videoplayer-shared/es2015`);class $r{constructor(){i(this,`_current`,void 0),i(this,`_current_version`,void 0),i(this,`_chromeVersion`,void 0),i(this,`_firefoxVersion`,void 0),i(this,`_safariVersion`,void 0),i(this,`_operaVersion`,void 0),i(this,`_edgeVersion`,void 0),i(this,`_yandexVersion`,void 0),i(this,`_isMiuiBrowser`,!1)}get current(){return this._current}get isChrome(){return this.current===`Chrome`}get isChromiumBased(){return Zr.default([`Chrome`,`Chromium`,`Opera`,`Yandex`,`Edge`,`SamsungBrowser`],this.current)}get isFirefox(){return this.current===`Firefox`}get isSafari(){return this.current===`Safari`}get isOpera(){return this.current===`Opera`}get isEdge(){return this.current===`Edge`}get isYandex(){return this.current===`Yandex`}get isSamsungBrowser(){return this.current===`SamsungBrowser`}get currentVersion(){return this._current_version}get chromeVersion(){return this._chromeVersion}get firefoxVersion(){return this._firefoxVersion}get safariVersion(){return this._safariVersion}get operaVersion(){return this._operaVersion}get edgeVersion(){return this._edgeVersion}get yandexVersion(){return this._yandexVersion}get isMiuiBrowser(){return this._isMiuiBrowser}detect(){let{userAgent:e}=navigator;try{let t=/yabrowser/i.test(e)?`Yandex`:void 0,n=/samsungbrowser/i.test(e)?`SamsungBrowser`:void 0,r=/chrome|crios/i.test(e)?`Chrome`:void 0,i=/chromium/i.test(e)?`Chromium`:void 0,a=/firefox|fxios/i.test(e)?`Firefox`:void 0,o=/webkit|safari|khtml/i.test(e)?`Safari`:void 0,s=/opr\//i.test(e)?`Opera`:void 0,c=/edg/i.test(e)?`Edge`:void 0;this._isMiuiBrowser=/(XiaoMi)|(MiuiBrowser)/i.test(e),this._current=t||n||a||s||c||r||i||o||`Rest`}catch(e){console.error(e)}this.isChrome&&this.detectChromeVersion(),this.isFirefox&&this.detectFirefoxVersion(),this.isSafari&&this.detectSafariVersion(),this.isOpera&&this.detectOperaVersion(),this.isEdge&&this.detectEdgeVersion(),this.isYandex&&this.detectYandexVersion()}detectVersion(e){try{let{userAgent:t}=Qr.getWindow().navigator,n=t.match(e);if(!n)return;let r=n[1],i=parseInt(r,10);if(!isNaN(i))return this._current_version=i,i}catch(e){console.error(e)}}detectChromeVersion(){this._chromeVersion=this.detectVersion(/Chrome\/(\d+\.\d+)/)}detectFirefoxVersion(){this._firefoxVersion=this.detectVersion(/Firefox\/(\d+\.\d+)/)}detectSafariVersion(){this._safariVersion=this.detectVersion(/Version\/(\d+)/)}detectOperaVersion(){this._operaVersion=this.detectVersion(/OPR\/(\d+\.\d+)/)}detectEdgeVersion(){this._edgeVersion=this.detectVersion(/Edg\/(\d+\.\d+)/)}detectYandexVersion(){this._yandexVersion=this.detectVersion(/YaBrowser\/(\d+\.\d+\.\d+)/)}}var ei=y(pt(),1),ti=require(`@vkontakte/videoplayer-shared/es2015`),ni=()=>{var e;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(navigator.appVersion??navigator.userAgent)||((e=navigator)==null||(e=e.userAgentData)==null?void 0:e.mobile)};class ri{constructor(e){i(this,`_displayChecker`,void 0),i(this,`_isMobile`,void 0),i(this,`_current`,void 0),i(this,`_iosVersion`,void 0),i(this,`_highEntropyValues`,{}),i(this,`_os`,{name:`Unknown`,version:`Unknown`,full:`Unknown`}),i(this,`_details`,{vendor:`Unknown`,model:`Unknown`}),this._displayChecker=e}get current(){return this._current}get os(){return this._os}get details(){return this._details}get isIOS(){return this._highEntropyValues.platform===`iOS`||this.os.name.toLowerCase().includes(`ios`)||ei.default([`iPhone`,`iPad`,`iPod`],this.current)}get isMac(){return this._highEntropyValues.platform===`macOS`||this.os.name.toLowerCase().includes(`mac`)||this.current===`Mac`}get isApple(){return this.isIOS||this.isMac}get isIphoneOrOldIpad(){if(!this.isApple||!this._displayChecker.isTouch)return!1;let e=this.current===`iPad`||this._displayChecker.width>700,t=this._iosVersion;return!e||e&&!!t&&t<16}get isAndroid(){return this._highEntropyValues.platform===`Android`||this.os.name.toLowerCase().includes(`android`)||this.current===`Android`}get isWindows(){return this.os.name.toLowerCase().includes(`windows`)}get isLinux(){return this.os.name.toLowerCase().includes(`linux`)&&!this.isAndroid}get isMobile(){return this._highEntropyValues.mobile||this._isMobile}get iOSVersion(){return this._iosVersion}detect(){let e=ti.getWindow();if(!ti.isBrowserWindow(e))return;let{userAgent:t}=e.navigator;try{this._isMobile=ni()}catch(e){console.error(`DeviceChecker: calling isMobile error - `,e)}this.detectDevice(t),this.detectOS(t),this.detectDeviceDetails(t),this.detectHighEntropyValues(),this.isIOS&&this.detectIOSVersion()}detectHighEntropyValues(){var e=this;return a(function*(){let t=ti.getWindow();if(!ti.isBrowserWindow(t))return;let{userAgentData:n}=t.navigator;if(n?.getHighEntropyValues){let t=yield n.getHighEntropyValues([`architecture`,`bitness`,`brands`,`mobile`,`platform`,`formFactor`,`model`,`platformVersion`,`wow64`]);e._highEntropyValues=t,t.platform&&(e._os.name=e.normalizeOSName(t.platform),t.platformVersion&&(e._os.version=e.normalizeOSVersion(t.platformVersion),e._os.full=`${e._os.name} ${e._os.version}`)),t.model&&(e._details.model=t.model)}})()}detectDevice(e){try{let t=/android/i.test(e)?`Android`:void 0,n=/iphone/i.test(e)?`iPhone`:void 0,r=/ipad/i.test(e)?`iPad`:void 0,i=/ipod/i.test(e)?`iPod`:void 0,a=/mac/i.test(e)?`Mac`:void 0,o=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(e)?`RestMobile`:void 0;this._current=t||n||r||i||o||a||`Desktop`}catch(e){console.error(`DeviceChecker: device detection error - `,e)}}detectOS(e){try{for(let[t,n]of[[/(windows nt) (6\.[23]); arm/i,[`Windows RT`]],[/(windows nt) (6\.3); arm/i,[`Windows RT 8.1`]],[/(windows (?:phone|mobile|iot))(?: os)?[/ ]?([\d.]+)/i,[`Windows Mobile`,2]],[/(windows)[/ ](xp|vista|7|8(\.1)?|10|11|2000|me)/i,[1,1]],[/windows nt ?([\d.]+)/i,[`Windows`,1]],[/(windows)[/ ](95|98|me|2000|xp|vista|7|8|8\.1|10|11)/i,[1,2]],[/(iphone os|cpu iphone os) ([\d_.]+)/i,[`iOS`,2]],[/(ipad os|cpu os) ([\d_.]+)/i,[`iPadOS`,2]],[/(ipod os|cpu ipod os) ([\d_.]+)/i,[`iOS`,2]],[/(?:ios|os) ([\d_.]+) like mac os x/i,[`iOS`,1]],[/cfnetwork\/.+darwin/i,[`iOS`]],[/(mac os x) ?([\d_.]+)/i,[`macOS`,2]],[/(macintosh|mac os)/i,[`macOS`]],[/(android) ([\d.]+)/i,[1,2]],[/(harmonyos)[/ ]?([\d.]*)/i,[`HarmonyOS`,2]],[/\b(ubuntu|debian|fedora|centos|arch|linux)(?:[-/ ]([\w.]+))?/i,[1,2]],[/(cros)\D*([\d.]+)/i,[`Chrome OS`,2]],[/(freebsd|openbsd|netbsd|dragonfly)[/ ]?([\w.]*)/i,[1,2]],[/(sunos|solaris)?([\d.]*)/i,[`Solaris`,2]],[/(aix)?([\d.]*)/i,[`AIX`,2]]]){let r=e.match(t);if(r){let t=n.length>0,i=n.length>1,a=`Unknown`,o=`Unknown`;if(t){let e=n[0];typeof e==`number`?e<r.length&&r[e]!==void 0&&(a=r[e]):a=e}if(i){let e=n[1];typeof e==`number`?e<r.length&&r[e]!==void 0&&(o=r[e]):e!==void 0&&(o=e)}else r[2]===void 0?r[1]!==void 0&&t&&typeof n[0]==`string`&&(o=r[1]):o=r[2];a=this.normalizeOSName(a),o=this.normalizeOSVersion(o,a),a===`iOS`&&/ipad/i.test(e)?a=`iPadOS`:a===`iPadOS`&&/ip(hone|od)/i.test(e)&&(a=`iOS`),this._os={name:a,version:o||`Unknown`,full:o&&o!==`Unknown`?`${a} ${o}`:a};break}}}catch(e){console.error(`DeviceChecker: OS detection error - `,e)}}normalizeOSName(e){if(!e)return`Unknown`;let t=e.toLowerCase();return t.includes(`windows`)?`Windows`:t.includes(`mac os`)||t.includes(`macintosh`)?`macOS`:t.includes(`iphone`)||t.includes(`ios`)?`iOS`:t.includes(`ipados`)?`iPadOS`:t.includes(`android`)?`Android`:t.includes(`harmonyos`)?`HarmonyOS`:t.includes(`linux`)?`Linux`:t.includes(`cros`)?`Chrome OS`:t.includes(`freebsd`)?`FreeBSD`:t.includes(`openbsd`)?`OpenBSD`:t.includes(`solaris`)||t.includes(`sunos`)?`Solaris`:t.includes(`aix`)?`AIX`:e}normalizeOSVersion(e,t){if(!e)return`Unknown`;if(e!==`Unknown`&&(e=e.replace(/_/g,`.`),t===`Windows`)){let t=parseFloat(e);if(!isNaN(t)){if(t>=11)return`11`;if(t>=10)return`10`;if(t===6.3)return`8.1`;if(t===6.2)return`8`;if(t===6.1)return`7`;if(t===6)return`Vista`;if(t===5.1||t===5.2)return`XP`;if(t===5)return`2000`;if(t===4)return`NT 4.0`}}return e}detectDeviceDetails(e){try{for(let[t,n]of[[/(iphone)/i,[`Apple`,`iPhone`]],[/(ipad)/i,[`Apple`,`iPad`]],[/(ipod)/i,[`Apple`,`iPod`]],[/(macintosh)/i,[`Apple`,`Macintosh`]],[/(windows[\w\-_ ]*phone)/i,[`Microsoft`,0]],[/(windows nt|win64|win32|wow64)/i,[`Microsoft`,`PC`]],[/\b(sch-i[89]0\d|shw-m380s|sm-[ptxs]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i,[`Samsung`,1]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?\d+a?|galaxy nexus)/i,[`Samsung`,1]],[/samsung[- ]((?!sm-[lr]|browser)[-\w]+)/i,[`Samsung`,1]],[/sec-(sgh\w+)/i,[`Samsung`,1]],[/smart-tv.+(samsung)/i,[`Samsung`,`Smart TV`]],[/(samsung).*tizen/i,[`Samsung`,`Smart TV`]],[/(pixel (?:c|tablet|[0-9a-z ]+))/i,[`Google`,1]],[/(pixelbook(?: go)?)/i,[`Google`,1]],[/nexus [0-9]/i,[`Google`,0]],[/(redmi[-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(mi[\w\-_ ]+)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(poco[\w ]+)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(hm[-_ ]?note?[\w ]*)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(?:xiao)?mi[\w\-_ ]+pad/i,[`Xiaomi`,0]],[/(?:huawei|honor) ?([-\w ]+)[;)]/i,[`Huawei`,1]],[/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][\dc][adnt]?)\b(?!.+d\/s)/i,[`Huawei`,1]],[/\b((?:ag[rs][2356]?k?|bah[234]?|bg[2o]|bt[kv]|cmr|cpn|db[ry]2?|jdn2|got|kob2?k?|mon|pce|scm|sht?|[tw]gr|vrd)-[ad]?[lw][0125][09]b?)/i,[`Huawei`,1]],[/(?:one)?(?:plus)? ?([a\d0]\d\d\d?)(?: b|\))/i,[`OnePlus`,1]],[/droid.+; (cph2[3-6]\d[13579]|((?:gm|hd)19|(?:ac|be|in|kb)20|(?:d[en]|eb|le|mt)21|ne22)[0-2]\d)(?: bui|\))/i,[`OnePlus`,1]],[/(oneplus)[-_ ]?([-\w]*)/i,[`OnePlus`,2]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i,[`Realme`,1]],[/(realme)[-_ ]?([-\w]*)/i,[`Realme`,2]],[/; (\w+) bui.+ oppo/i,[`OPPO`,1]],[/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i,[`OPPO`,1]],[/\b(opd2(\d{3}a?))(?: bui|\))/i,[`OPPO`,1]],[/(oppo)[-_ ]?([-\w]*)/i,[`OPPO`,2]],[/; vivo (\w+)(?: bui|\))/i,[`Vivo`,1]],[/\b(v[12]\d{3}\w?[at])(?: bui|;)/i,[`Vivo`,1]],[/(vivo)[-_ ]?([-\w]*)/i,[`Vivo`,2]],[/\bmot(?:orola)?[- ]([\w\s]+)(\)| bui)/i,[`Motorola`,1]],[/((?:moto(?! 360)[-\w() ]+|xt\d{3,4}[cgkosw+]?[-\d]*|nexus 6)(?= bui|\)))/i,[`Motorola`,1]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b/i,[`Motorola`,0]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i,[`Motorola`,0]],[/droid.+; ([a-z]?\d[0-2]{2}[a-z]{2}|[c-g]\d{4}|so[-gl]\w+|xq-[a-z]{2}\d\d)(?= bui|\))/i,[`Sony`,1]],[/sony tablet [ps]/i,[`Sony`,`Xperia Tablet`]],[/\b(?:sony)?sgp\w+(?: bui|\))/i,[`Sony`,0]],[/(sony)[-_ ]?([-\w]*)/i,[`Sony`,2]],[/\blg[-e;/ ]+(?!.*(?:browser|netcast|android tv|watch|webos))(\w+)/i,[`LG`,1]],[/\blg-?([\d\w]+) bui/i,[`LG`,1]],[/(lm(?:-?f100[nv]?|-[\w.]+)(?= bui|\))|nexus [45])/i,[`LG`,1]],[/((?=lg)?[vl]k-?\d{3}) bui/i,[`LG`,0]],[/(lg)[-_ ]?([-\w]*)/i,[`LG`,2]],[/(?:maemo|nokia).*(n900|lumia \d+|rm-\d+)/i,[`Nokia`,1]],[/nokia[-_ ]?(([-\w. ]*?))(?: bui|\)|;|\/)/i,[`Nokia`,1]],[/(nokia) (t[12][01])/i,[`Nokia`,2]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i,[`ASUS`,1]],[/(?:asus[-_ ])?(zenfone[\w\-_ ]*)/i,[`ASUS`,1]],[/(rog[\w\-_ ]*)/i,[`ASUS`,1]],[/(asus)[-_ ]?([-\w]*)/i,[`ASUS`,2]],[/lenovo[-_ ]?([-\w ]+?)(?: bui|\)|\/)/i,[`Lenovo`,1]],[/(ideatab[-\w ]+|602lv|d-42a|a101lv|a2109a|a3500-hv|s[56]000|pb-6505[my]|tb-?x?\d{3,4}(?:f[cu]|xu|[av])|yt\d?-[jx]?\d+[lfmx])(?: bui|;|\)|\/)/i,[`Lenovo`,1]],[/(thinkpad[\w\-_ ]*)/i,[`Lenovo`,0]],[/(kf[a-z]{2}[a-z]*)(?: bui|\))/i,[`Amazon`,1]],[/(alexa)webm/i,[`Amazon`,`Echo`]],[/(fire[\w\-_ ]*)/i,[`Amazon`,0]],[/(amazon)[-_ ]?([-\w]*)/i,[`Amazon`,2]],[/(?:blackberry|\(bb10;) (\w+)/i,[`BlackBerry`,1]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,[`BlackBerry`,1]],[/(playbook);[-\w),; ]+(rim)/i,[`BlackBerry`,1]],[/(microsoft); (lumia[\w ]+)/i,[`Microsoft`,2]],[/(surface duo)/i,[`Microsoft`,`Surface Duo`]],[/(surface[\w\-_ ]*)/i,[`Microsoft`,0]],[/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,[`ZTE`,2]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,[`HTC`,2]],[/(alcatel|tcl)[-_ ]?([-\w]*)/i,[1,2]],[/(meizu)[-_ ]?([-\w]*)/i,[`Meizu`,2]],[/(tecno)[-_ ]?([-\w]*)/i,[`Tecno`,2]],[/(infinix)[-_ ]?([-\w]*)/i,[`Infinix`,2]],[/(micromax)[-_ ]?([-\w]*)/i,[`Micromax`,2]],[/(lava)[-_ ]?([-\w]*)/i,[`Lava`,2]],[/(panasonic)[-_ ]?([-\w]*)/i,[`Panasonic`,2]],[/(sharp)\/?([-\w]*)/i,[`Sharp`,2]],[/(benq)[-_ ]?([-\w]*)/i,[`BenQ`,2]],[/(palm)[-_ ]?([-\w]*)/i,[`Palm`,2]],[/(vertu)[-_ ]?([-\w]*)/i,[`Vertu`,2]],[/(gionee)[-_ ]?([-\w]*)/i,[`Gionee`,2]],[/(doogee)[-_ ]?([-\w]*)/i,[`Doogee`,2]],[/(ulefone)[-_ ]?([-\w]*)/i,[`Ulefone`,2]],[/(blackview)[-_ ]?([-\w]*)/i,[`Blackview`,2]],[/(cubot)[-_ ]?([-\w]*)/i,[`Cubot`,2]],[/(umidigi)[-_ ]?([-\w]*)/i,[`UMIDIGI`,2]],[/(oukitel)[-_ ]?([-\w]*)/i,[`Oukitel`,2]],[/(fairphone)[-_ ]?([-\w]*)/i,[`Fairphone`,2]],[/(cat)[-_ ]?([-\w]*)/i,[`Cat`,2]],[/(energy)[-_ ]?([-\w]*)/i,[`Energizer`,2]],[/(land rover)[-_ ]?([-\w]*)/i,[`Land Rover`,2]],[/(shield[\w\-_ ]*)/i,[`Nvidia`,0]],[/(crkey)/i,[`Google`,`Chromecast`]],[/(roku)[\dx]*/i,[`Roku`,0]],[/(apple)[-_ ]?tv/i,[`Apple`,`TV`]],[/(amazon)[-_ ]?tv/i,[`Amazon`,`Fire TV`]],[/(google)[-_ ]?tv/i,[`Google`,`TV`]],[/(smart[\w\-_ ]*tv)/i,[0,`Smart TV`]],[/(playstation[\w\-_ ]*)/i,[`Sony`,0]],[/(nintendo[\w\-_ ]*)/i,[`Nintendo`,0]],[/(xbox[\w\-_ ]*)/i,[`Microsoft`,0]],[/(googlebot)/i,[`Google`,`Bot`]],[/(bingbot)/i,[`Microsoft`,`Bing Bot`]],[/(yandexbot)/i,[`Yandex`,`Bot`]],[/(slackbot)/i,[`Slack`,`Bot`]],[/(twitterbot)/i,[`Twitter`,`Bot`]],[/(facebookbot)/i,[`Facebook`,`Bot`]],[/(linkedinbot)/i,[`LinkedIn`,`Bot`]],[/(tesla)[-_ ]?([-\w]*)/i,[`Tesla`,2]],[/(raspberry[\w\-_ ]*)/i,[`Raspberry Pi`,0]]]){let r=e.match(t);if(r){let e=n[0],t=n[1],i=typeof e==`number`?r[e]===void 0?`Unknown`:this.normalizeVendorName(r[e]):this.normalizeVendorName(e),a=`Unknown`;typeof t==`number`?a=r[t]===void 0?`Unknown`:r[t]:t===void 0?r[1]===void 0?r[0]!==void 0&&(a=r[0]):a=r[1]:a=t,a=this.normalizeModelName(a,i),this.details.vendor=i,this.details.model=a;break}}}catch(e){console.error(`DeviceChecker: device details detection error - `,e)}}normalizeVendorName(e){return e?{apple:`Apple`,samsung:`Samsung`,google:`Google`,xiaomi:`Xiaomi`,huawei:`Huawei`,oneplus:`OnePlus`,oppo:`OPPO`,vivo:`Vivo`,realme:`Realme`,motorola:`Motorola`,sony:`Sony`,lg:`LG`,nokia:`Nokia`,asus:`ASUS`,lenovo:`Lenovo`,amazon:`Amazon`,blackberry:`BlackBerry`,microsoft:`Microsoft`,zte:`ZTE`,htc:`HTC`,alcatel:`Alcatel`,tcl:`TCL`,meizu:`Meizu`,tecno:`Tecno`,infinix:`Infinix`,micromax:`Micromax`,lava:`Lava`,panasonic:`Panasonic`,sharp:`Sharp`,benq:`BenQ`,palm:`Palm`,honor:`Honor`,nvidia:`NVIDIA`,roku:`Roku`}[e.toLowerCase()]||e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():`Unknown`}normalizeModelName(e,t){if(!e||e===`Unknown`)return e;if(e===`0`)return`Unknown`;let n=e.replace(/^build\//i,``).replace(/\s+bui$/i,``).replace(/\)$/,``).replace(/[;,)]/g,``).replace(/\s*\(.*?\)\s*/g,``).trim(),r=t.toLowerCase();return r.includes(`samsung`)?n=n.replace(/^(sm-|gt-|sgh-|sch-)/i,``):r.includes(`xiaomi`)?n=n.replace(/^(mi[\s\-_]*|redmi[\s\-_]*)/i,``):r.includes(`oneplus`)?n=n.replace(/^oneplus[\s\-_]*/i,``):r.includes(`google`)&&(n=n.replace(/^(pixel[\s\-_]*|nexus[\s\-_]*)/i,``)),n=n.replace(/_/g,` `).replace(/-/g,` `).replace(/\s+/g,` `).trim(),n?(n.length>0&&/^[a-z]/.test(n)&&(n=n.charAt(0).toUpperCase()+n.slice(1)),n):`Unknown`}detectIOSVersion(){try{let e=ti.getWindow();if(!ti.isBrowserWindow(e))return;if(this._highEntropyValues.platformVersion){let e=this._highEntropyValues.platformVersion.split(`.`).slice(0,2).join(`.`);this._iosVersion=parseFloat(e);return}if(this._os.version!==`Unknown`){let e=this._os.version.split(`.`),t=e.length>=2?`${e[0]}.${e[1]}`:e[0];this._iosVersion=parseFloat(t);return}let t=e.navigator.userAgent.match(/OS (\d+(_\d+)?)/i);t?.[1]&&(this._iosVersion=parseFloat(t[1].replace(/_/g,`.`)))}catch(e){console.error(`DeviceChecker: iOS version detection error - `,e)}}}var ii=require(`@vkontakte/videoplayer-shared/es2015`);class ai{constructor(){i(this,`_maxTouchPoints`,void 0),i(this,`_height`,void 0),i(this,`_width`,void 0),i(this,`_isHdr`,void 0),i(this,`_pixelRatio`,void 0),i(this,`_screenHeight`,void 0),i(this,`_screenWidth`,void 0),i(this,`_colorDepth`,void 0)}get isTouch(){return typeof this._maxTouchPoints==`number`?this._maxTouchPoints>1:`ontouchstart`in ii.getWindow()}get maxTouchPoints(){return this._maxTouchPoints}get height(){return this._height}get width(){return this._width}get screenHeight(){return this._screenHeight}get screenWidth(){return this._screenWidth}get pixelRatio(){return this._pixelRatio}get isHDR(){return this._isHdr}get colorDepth(){return this._colorDepth}detect(){let e=ii.getWindow();if(!ii.isBrowserWindow(e))return;let{navigator:t,screen:n}=e,{maxTouchPoints:r}=t;try{this._maxTouchPoints=r??0,this._isHdr=!!e.matchMedia(`(dynamic-range: high)`)?.matches,this._colorDepth=n.colorDepth}catch(e){console.error(e)}try{this._pixelRatio=e.devicePixelRatio||1,this._height=n.height,this._width=n.width,this._height=n.height,this._screenHeight=this._height*this._pixelRatio,this._screenWidth=this._width*this._pixelRatio}catch(e){console.error(e)}}}var oi=require(`@vkontakte/videoplayer-shared/es2015`),si=()=>window.ManagedMediaSource||window.MediaSource,ci=()=>{var e;return!!(window.ManagedMediaSource&&!((e=window.ManagedSourceBuffer)==null||(e=e.prototype)==null)&&e.appendBuffer)},li=()=>{var e;return!!(window.MediaSource&&!((e=window.SourceBuffer)==null||(e=e.prototype)==null)&&e.appendBuffer)},ui=()=>window.ManagedMediaSource?new ManagedMediaSource:new MediaSource,di=oi.getWindow().document?.createElement(`video`),fi=`video/mp4; codecs="avc1.42000a,mp4a.40.2"`,pi=`video/mp4; codecs="hev1.1.6.L93.B0"`,mi=`video/webm; codecs="vp09.00.10.08"`,hi=`video/webm; codecs="av01.0.00M.08"`,gi=`audio/mp4; codecs="mp4a.40.2"`,_i=`audio/webm; codecs="opus"`,vi;(function(){var e=a(function*(){let e=oi.getWindow();if(!oi.isBrowserWindow(e)||!(`mediaCapabilities`in e.navigator))return;let t={type:`media-source`,video:{contentType:`video/webm`,width:1280,height:720,bitrate:1e6,framerate:30}},[n,r]=yield Promise.all([e.navigator.mediaCapabilities.decodingInfo(o(o({},t),{},{video:o(o({},t.video),{},{contentType:hi})})),e.navigator.mediaCapabilities.decodingInfo(o(o({},t),{},{video:o(o({},t.video),{},{contentType:mi})}))]);vi={DASH_WEBM_AV1:n,DASH_WEBM:r}});return function(){return e.apply(this,arguments)}})()().catch(e=>{console.log(di),console.error(e)});class yi{constructor(e,t){i(this,`_video`,void 0),i(this,`_deviceChecker`,void 0),i(this,`_browserChecker`,void 0),i(this,`_protocols`,void 0),i(this,`_containers`,void 0),i(this,`_codecs`,void 0),i(this,`_nativeHlsSupported`,void 0),this._deviceChecker=e,this._browserChecker=t}get protocols(){return this._protocols}get containers(){return this._containers}get codecs(){return this._codecs}get webmDecodingInfo(){return vi}get supportedCodecs(){return Object.keys(this._codecs).filter(e=>this._codecs[e])}get nativeHlsSupported(){return this._nativeHlsSupported}detect(){let e=oi.getWindow();if(oi.isBrowserWindow(e)){this._video=e.document.createElement(`video`);try{var t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g;this._protocols={mms:ci(),mse:li(),hls:!!((t=this._video).canPlayType?.call(t,`application/x-mpegurl`)||(n=this._video).canPlayType?.call(n,`vnd.apple.mpegURL`)),webrtc:!!e.RTCPeerConnection,ws:!!e.WebSocket},this._containers={mp4:!!(r=this._video).canPlayType?.call(r,`video/mp4`),webm:!!(i=this._video).canPlayType?.call(i,`video/webm`),cmaf:!0};let _=!!(!((a=si())==null||(o=a.isTypeSupported)==null)&&o.call(a,fi)),v=!!(!((s=si())==null||(c=s.isTypeSupported)==null)&&c.call(s,pi)),y=!!(!((l=si())==null||(u=l.isTypeSupported)==null)&&u.call(l,gi));this._codecs={h264:_,h265:v,vp9:!!(!((d=si())==null||(f=d.isTypeSupported)==null)&&f.call(d,mi)),av1:!!(!((p=si())==null||(m=p.isTypeSupported)==null)&&m.call(p,hi)),aac:y,opus:!!(!((h=si())==null||(g=h.isTypeSupported)==null)&&g.call(h,_i)),mpeg:(_||v)&&y},this._nativeHlsSupported=this._protocols.hls&&this._containers.mp4}catch(e){console.error(e)}try{this.destroyVideoElement()}catch(e){console.error(`Error destroying video element:`,e)}}}destroyVideoElement(){if(!this._video)return;if(this._video.pause(),this._video.currentTime=0,this._video.removeAttribute(`src`),this._video.src=``,this._video.load(),this._video.remove){this._video.remove(),this._video=null;return}this._video.parentNode&&this._video.parentNode.removeChild(this._video);let e=this._video.cloneNode(!1);this._video.parentNode?.replaceChild(e,this._video),this._video=null}}var bi=require(`@vkontakte/videoplayer-shared/es2015`),xi=`audio/mpeg`;class Si{constructor(){i(this,`_audio`,void 0),i(this,`_containers`,void 0),i(this,`_codecs`,void 0)}supportMp3(){return this._codecs.mp3&&this._containers.mpeg}detect(){let e=bi.getWindow();if(bi.isBrowserWindow(e)){this._audio=e.document.createElement(`audio`);try{var t,n,r;this._containers={mpeg:!!(t=this._audio).canPlayType?.call(t,xi)},this._codecs={mp3:!!(!((n=si())==null||(r=n.isTypeSupported)==null)&&r.call(n,xi))}}catch(e){console.error(e)}try{this.destroyAudioElement()}catch(e){console.error(`Error destroying audio element:`,e)}}}destroyAudioElement(){if(!this._audio)return;if(this._audio.pause(),this._audio.currentTime=0,this._audio.removeAttribute(`src`),this._audio.src=``,this._audio.load(),this._audio.remove){this._audio.remove(),this._audio=null;return}this._audio.parentNode&&this._audio.parentNode.removeChild(this._audio);let e=this._audio.cloneNode(!1);this._audio.parentNode?.replaceChild(e,this._audio),this._audio=null}}class Ci{constructor(){i(this,`isInited$`,new Xr.ValueSubject(!1)),i(this,`_displayChecker`,void 0),i(this,`_deviceChecker`,void 0),i(this,`_browserChecker`,void 0),i(this,`_videoChecker`,void 0),i(this,`_audioChecker`,void 0),this._displayChecker=new ai,this._deviceChecker=new ri(this._displayChecker),this._browserChecker=new $r,this._videoChecker=new yi(this._deviceChecker,this._browserChecker),this._audioChecker=new Si,this.detect()}get display(){return this._displayChecker}get device(){return this._deviceChecker}get browser(){return this._browserChecker}get video(){return this._videoChecker}get audio(){return this._audioChecker}detect(){var e=this;return a(function*(){Xr.isBrowserWindow()&&(e._displayChecker.detect(),e._deviceChecker.detect(),e._browserChecker.detect(),e._videoChecker.detect(),e._audioChecker.detect(),e.isInited$.next(!0))})()}}var P=new Ci,wi=e=>{let{containers:t,protocols:n,codecs:r,nativeHlsSupported:i}=P.video,a=(r.h264||r.h265)&&r.aac,o=n.mse||n.mms;return e.filter(e=>{switch(e){case`DASH_SEP`:return o&&t.mp4&&a;case`DASH_WEBM`:return o&&t.webm&&r.vp9&&r.opus;case`DASH_WEBM_AV1`:return o&&t.webm&&r.av1&&r.opus;case`DASH_STREAMS`:return o&&(t.mp4&&a||t.webm&&(r.vp9||r.av1)&&(r.opus||r.aac));case`DASH_LIVE`:return o&&t.mp4&&a;case`DASH_LIVE_CMAF`:return o&&t.mp4&&a&&t.cmaf;case`DASH_ONDEMAND`:return o&&t.mp4&&a;case`HLS`:case`HLS_ONDEMAND`:case`HLS_FMP4`:case`HLS_LIVE`:case`HLS_LIVE_CMAF`:return i;case`MPEG`:return t.mp4;case`DASH`:case`DASH_LIVE_WEBM`:return!1;case`WEB_RTC_LIVE`:return n.webrtc&&n.ws&&r.h264&&(t.mp4||t.webm);default:return Yr.assertNever(e)}})},Ti=e=>{switch(e){case`MPEG`:case`DASH`:case`DASH_SEP`:case`DASH_ONDEMAND`:case`DASH_WEBM`:case`DASH_WEBM_AV1`:case`DASH_STREAMS`:case`HLS`:case`HLS_FMP4`:case`HLS_ONDEMAND`:return!1;case`DASH_LIVE`:case`DASH_LIVE_CMAF`:case`HLS_LIVE`:case`HLS_LIVE_CMAF`:case`DASH_LIVE_WEBM`:case`WEB_RTC_LIVE`:return!0;default:return Yr.assertNever(e)}},Ei=e=>wi(Object.keys(e).filter(e=>!Ti(e))).length>0;class Di{constructor(e){i(this,`subscription`,new M.Subscription),i(this,`log`,void 0),i(this,`params`,void 0),i(this,`sessionId$`,new M.ValueSubject(null)),i(this,`mediaSessionId$`,new M.ValueSubject(null)),i(this,`contentId$`,new M.ValueSubject(null)),i(this,`progressTicker`,void 0),i(this,`isMobile`,ni()),i(this,`mobileVolumeState`,{muted:!1,volume:0}),i(this,`media`,null),i(this,`lastRequestedVolume`,null),i(this,`syncMediaState`,e=>{if(M.isNullable(e))return;this.media=e,this.mediaSessionId$.next(e.mediaSessionId??null);let t=e.media?.contentId;t&&this.contentId$.next(t),this.syncPlaybackState(e);let n=e.media?.duration;M.isNonNullable(n)&&this.params.output.duration$.next(Math.max(0,n));let r=e.currentTime;if(M.isNonNullable(r)){this.params.desiredState.seekState.getState().state===`applying`&&this.params.output.seekedEvent$.next(),this.params.output.position$.next(r);let t=this.params.output.isLive$.getValue();e.playerState===`PLAYING`&&!t?this.progressTicker.start(r):this.progressTicker.pause()}}),this.params=e,this.progressTicker=new Jr(e),this.log=this.params.dependencies.logger.createComponentLog(`ChromecastPresentationApiProvider`),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(Ti(e.format)),this.subscribe()}subscribe(){let e=e=>{this.params.output.error$.next({category:M.ErrorCategory.WTF,id:`ChromecastPresentationApiProvider`,message:e?.message??`Unknown error`,thrown:e})};this.subscription.add(this.params.chromecastConnector.message$.pipe(M.filter(e=>!!e)).subscribe(e=>{this.handleMessage(e)},e)),this.subscription.add(this.sessionId$.pipe(M.filter(M.isNonNullable),M.filterChanged(),M.debounce(0)).subscribe(()=>{this.loadMedia()},e));let t=this.contentId$.pipe(M.filterChanged(),M.map(Boolean));this.subscription.add(M.combine({seekState:this.params.desiredState.seekState.stateChangeEnded$,mediaLoaded:t}).pipe(M.filter(({mediaLoaded:e})=>e)).subscribe(()=>{let e=this.params.desiredState.seekState.getState();e.state===`requested`&&this.seek(e.position/1e3)},e));let n=M.combine({playbackState:this.params.desiredState.playbackState.stateChangeStarted$,mediaLoaded:t});this.subscription.add(n.pipe(M.filter(({mediaLoaded:e})=>e),M.debounce(0)).subscribe(()=>{this.syncPlayback()},e)),this.subscription.add(n.pipe(M.filter(({mediaLoaded:e,playbackState:{from:t,to:n}})=>!e&&t===`stopped`&&n===`playing`)).subscribe(()=>{this.loadMedia()},e)),this.subscription.add(M.combine({volumeState:this.params.desiredState.volume.stateChangeStarted$.pipe(M.debounce(30)),mediaLoaded:t}).pipe(M.filter(({mediaLoaded:e})=>e)).subscribe(({volumeState:e})=>{let{muted:t,volume:n}=e.to;this.setVolume(n,t)},e))}handleMessage(e){switch(e.type){case`new_session`:case`update_session`:{var t;this.sessionId$.next(e.message.sessionId);let n=(t=e.message)==null||(t=t.media)==null?void 0:t[0];this.syncMediaState(n);let r=e.message?.receiver.volume;this.syncVolumeState(r)}break;case`v2_message`:switch(e.message?.type){case`MEDIA_STATUS`:{var n;let t=(n=e.message)==null||(n=n.status)==null?void 0:n[0];this.syncMediaState(t);break}}break}}loadMedia(){let e=Ur(this.params),t=this.media?.currentTime,n=this.params.desiredState.seekState.getState(),r=t??(n.state===`none`?0:n.position/1e3),i=this.params.desiredState.playbackState.getState()===`playing`;this.params.chromecastConnector.sendV2Message({type:`LOAD`,requestId:0,media:e,autoplay:i,currentTime:r,customData:null,activeTrackIds:null}),this.params.output.willSeekEvent$.next()}stop(){this.params.chromecastConnector.stopMedia()}play(){let e=this.mediaSessionId$.getValue();M.assertNonNullable(e,`play on null mediaSessionId`),this.params.chromecastConnector.sendV2Message({type:`PLAY`,mediaSessionId:e,customData:null})}pause(){let e=this.mediaSessionId$.getValue();M.assertNonNullable(e,`pause on null mediaSessionId`),this.params.chromecastConnector.sendV2Message({type:`PAUSE`,mediaSessionId:e,customData:null})}seek(e){let t=this.mediaSessionId$.getValue();M.assertNonNullable(t,`seek on null mediaSessionId`),this.params.chromecastConnector.sendV2Message({type:`SEEK`,currentTime:e,mediaSessionId:t}),this.params.output.willSeekEvent$.next()}setVolume(e,t){let n=e,r=`[setVolume] volume: ${e}, muted: ${t}`;this.isMobile&&(n=this.mobileVolumeState.volume,r+=`, mobile next volume: ${n}`),this.log({message:r}),this.lastRequestedVolume={volume:n,muted:t},this.params.chromecastConnector.sendV2Message({type:`SET_VOLUME`,requestId:0,volume:{level:t?0:n,muted:t?!0:null}})}syncPlaybackState({playerState:e,idleReason:t}){let n=this.params.output.isBuffering$.getValue(),r=e===`BUFFERING`;switch(n!==r&&this.params.output.isBuffering$.next(r),e){case`PAUSED`:N(this.params.desiredState.playbackState,`paused`);break;case`PLAYING`:N(this.params.desiredState.playbackState,`playing`);break;case`IDLE`:t===`FINISHED`?(this.params.output.endedEvent$.next(),N(this.params.desiredState.playbackState,`stopped`),this.contentId$.next(null)):N(this.params.desiredState.playbackState,`ready`);break;case`BUFFERING`:break}}syncPlayback(){let e=this.params.desiredState.playbackState.getState();switch(this.log({message:`[syncPlayback] ${e}`}),e){case`ready`:break;case`playing`:this.play();break;case`paused`:this.pause();break;case`stopped`:this.stop();break}}syncVolumeState(e){if(M.isNullable(e))return;let{level:t,muted:n}=e,r={muted:n??!1,volume:t??0};this.lastRequestedVolume&&=(n&&(r.volume=this.lastRequestedVolume.volume),this.lastRequestedVolume.muted&&!t&&!n&&(r.volume=this.lastRequestedVolume.volume,r.muted=!0),null);let i=`[syncVolumeState] volume: ${r.volume}, muted: ${r.muted}`;this.isMobile&&(this.mobileVolumeState.volume=r.volume,this.mobileVolumeState.muted=r.muted,r.volume=this.params.output.volume$.getValue().volume,i+=`, volume passed to state machine: ${r.volume}`),this.log({message:i}),this.params.output.volume$.next(r)}destroy(){this.progressTicker.destroy(),this.subscription.unsubscribe()}}var Oi=require(`@vkontakte/videoplayer-shared/es2015`),ki=e=>({castDevice:{friendlyName:e},remotePlayer:{},remotePlayerController:{},session:{}}),Ai=()=>String(Date.now())+String(Math.floor(Math.random()*1e5));class ji{constructor(e){i(this,`params`,void 0),i(this,`clientId`,void 0),i(this,`capabilities`,[`WEB`]),i(this,`presentationRequest$`,new Oi.ValueSubject(null)),i(this,`log`,void 0),i(this,`sessionId$`,new Oi.ValueSubject(null)),i(this,`broadcastChannel`,new BroadcastChannel(`vk_player_chromecast_events`)),i(this,`subscription`,new Oi.Subscription),i(this,`subscriptionEvents`,new Oi.Subscription),i(this,`isDestroyed`,!1),i(this,`sequenceNumber`,0),i(this,`presentationAvailable$`,new Oi.ValueSubject(!1)),i(this,`presentationConnection$`,new Oi.ValueSubject(null)),i(this,`message$`,new Oi.ValueSubject(null)),i(this,`friendlyName$`,new Oi.ValueSubject(null)),i(this,`errorEvent$`,new Oi.Subject),this.clientId=this.getClientId(),this.params=e,this.log=e.logger.createComponentLog(`ChromecastPresentationApiConnector`),this.log({message:`constructor`}),this.safeReinitPresentation(),this.subscribe()}destroy(){this.log({message:`destroy`}),this.subscription.unsubscribe(),this.subscriptionEvents.unsubscribe(),this.broadcastChannel.close(),this.isDestroyed=!0}disconnect(e=!0){this.log({message:`disconnect`}),e&&this.stopMedia(),this.presentationRequest$.next(null);let t=this.presentationConnection$.getValue();t&&t.close(),this.presentationConnection$.next(null),this.friendlyName$.next(null),this.resetSequenceNumber(),this.resetSubscriptionEvents()}stopMedia(){this.log({message:`stopMedia`}),this.sendV2Message({type:`STOP`})}reinitPresentation(e=!0){let t=this.createCastUrl(),n=new PresentationRequest(t);this.presentationRequest$.next(n),this.log({message:`PresentationRequest created`}),n.getAvailability().then(e=>{let t=()=>{this.log({message:`PresentationRequest presentation availability: ${e.value}`}),this.presentationAvailable$.next(e.value)};this.subscriptionEvents.add(Oi.fromEvent(e,`change`).subscribe(()=>{t()})),t()}).catch(()=>{this.presentationAvailable$.next(!0)}),Oi.getWindow().navigator.presentation.defaultRequest=n,e&&n.reconnect(`auto-join`).then(e=>{this.log({message:`PresentationRequest reconnect success`}),this.handleConnection(e)}).catch(()=>{this.log({message:`PresentationRequest reconnect failed`})})}safeReinitPresentation(e){try{this.reinitPresentation(e)}catch(e){this.errorEvent$.next({category:Oi.ErrorCategory.WTF,id:`ChromecastPresentationApiConnector`,message:e?.message??`reinitPresentation error`,thrown:e})}}connect(){var e=this;return a(function*(){e.log({message:`connect`});try{e.presentationRequest$.getValue()||(e.log({message:`reinitPresentation`}),e.reinitPresentation(!1));let t=e.presentationRequest$.getValue();Oi.assertNonNullable(t,`connect with null presentationRequest`);let n=yield t.start();e.handleConnection(n)}catch(t){switch(t?.name){case`AbortError`:case`NotAllowedError`:break;default:e.errorEvent$.next({category:Oi.ErrorCategory.WTF,id:`ChromecastPresentationApiConnector`,message:t?.message??`connect error`,thrown:t});break}}})()}subscribe(){this.subscription.add(Oi.fromEvent(this.broadcastChannel,`message`).subscribe(e=>{this.log({message:`broadcast connection data: ${e.data}`}),e.data===`connection`&&this.disconnect(!1)})),this.subscription.add(this.presentationAvailable$.subscribe(e=>{this.log({message:`presentationAvailable$: ${e}`})})),this.subscription.add(this.presentationConnection$.pipe(Oi.tap(e=>{this.log({message:`presentationConnection$: ${!!e}`})}),Oi.filter(e=>!!e)).subscribe(e=>{let t=Oi.fromEvent(e,`message`).subscribe(e=>{let t=JSON.parse(e.data);t.clientId===this.clientId&&(this.log({message:`[onmessage] ${e.data}`}),this.handleMessage(t),this.message$.next(t))}),n=Oi.fromEvent(e,`connect`).subscribe(()=>{this.send(`client_connect`)}),r=Oi.fromEvent(e,`close`).subscribe(e=>{switch(e.reason){case`error`:this.errorEvent$.next({category:Oi.ErrorCategory.WTF,id:`ChromecastPresentationApiConnector`,message:`Session error`,thrown:e});break;case`closed`:break}});this.subscriptionEvents.add(t),this.subscriptionEvents.add(n),this.subscriptionEvents.add(r)}))}send(e){switch(e){case`client_connect`:{let e={type:`client_connect`,message:this.clientId,sequenceNumber:-1,timeoutMillis:0,clientId:this.clientId};this.safeSend(JSON.stringify(e));break}}}sendV2Message(e){let t=this.sessionId$.getValue();if(t){let n={type:`v2_message`,sequenceNumber:this.getSequenceNumber(),timeoutMillis:0,clientId:this.clientId,message:o(o({},e),{},{sessionId:t})};this.safeSend(JSON.stringify(n))}}safeSend(e){try{this.log({message:`[send] ${e}`});let t=this.presentationConnection$.getValue();t?.state===`connected`&&t?.send(e)}catch(t){this.errorEvent$.next({category:Oi.ErrorCategory.WTF,id:`ChromecastPresentationApiConnector`,message:`PresentationConnection send error`,data:{message:e},thrown:t})}}handleMessage(e){switch(e.type){case`new_session`:case`update_session`:this.sessionId$.next(e.message.sessionId),this.friendlyName$.next(e.message.receiver.friendlyName||`Chromecast Device`);break;case`receiver_action`:e.message?.action===`stop`&&this.disconnect();break}}createCastUrl(){return`cast:${this.params.appId}?clientId=${this.clientId}&autoJoinPolicy=tab_and_origin_scoped&defaultActionPolicy=create_session&launchTimeout=60000&supportedAppTypes=${this.capabilities}&appParams=%7B%22launchCheckerParams%22%3A%7B%7D%7D`}getSequenceNumber(){let e=this.sequenceNumber;return this.sequenceNumber=(this.sequenceNumber+1)%(2**53-1),e}resetSequenceNumber(){this.sequenceNumber=0}getClientId(){let e=`__vk_player_chromecast_id`;return Oi.getWindow()[e]=Oi.getWindow()[e]||Ai()}resetSubscriptionEvents(){this.subscriptionEvents.unsubscribe(),this.subscriptionEvents=new Oi.Subscription}handleConnection(e){this.log({message:`connection available`}),this.isDestroyed?(this.log({message:`connected on already destroyed component`}),e.close()):(this.broadcastChannel.postMessage(`connection`),this.presentationConnection$.next(e))}}var Mi=require(`@vkontakte/videoplayer-shared/es2015`);class Ni{static isSupported(){return`chrome`in window&&`presentation`in navigator&&`BroadcastChannel`in window}constructor(e){i(this,`subscription`,new Mi.Subscription),i(this,`log`,void 0),i(this,`contentId`,void 0),i(this,`connection$`,new Mi.ValueSubject(void 0)),i(this,`castState$`,new Mi.ValueSubject(`NOT_AVAILABLE`)),i(this,`errorEvent$`,new Mi.Subject),i(this,`chromecastConnector`,void 0);let t=Ni.isSupported();this.log=e.dependencies.logger.createComponentLog(`ChromecastPresentationApiInitializer`),this.log({message:`[constructor] receiverApplicationId: ${e.receiverApplicationId}, isDisabled: ${e.isDisabled}, isSupported: ${t}`}),!(!t||e.isDisabled||!e.receiverApplicationId)&&(this.chromecastConnector=new ji({appId:e.receiverApplicationId,logger:e.dependencies.logger}),this.subscribe())}subscribe(){Mi.assertNonNullable(this.chromecastConnector,`subscribe with null chromecastConnector`),this.subscription.add(this.chromecastConnector.errorEvent$.subscribe(this.errorEvent$));let e=Mi.combine({connection:this.chromecastConnector.presentationConnection$,available:this.chromecastConnector.presentationAvailable$,friendlyName:this.chromecastConnector.friendlyName$.pipe(Mi.filterChanged())});this.subscription.add(e.pipe(Mi.map(({connection:e,friendlyName:t})=>!!(e&&t)),Mi.filterChanged()).subscribe(e=>{let t=this.chromecastConnector?.friendlyName$.getValue()??``;this.connection$.next(e?ki(t):void 0)})).add(e.subscribe(({available:e,connection:t})=>{e?t?this.castState$.next(`CONNECTED`):this.castState$.next(`AVAILABLE`):this.castState$.next(`NOT_AVAILABLE`)}))}connect(){this.log({message:`connect`}),this.chromecastConnector?.connect()}disconnect(){this.log({message:`disconnect`}),this.chromecastConnector?.disconnect()}stopMedia(){var e=this;return a(function*(){e.log({message:`stopMedia`}),e.chromecastConnector?.stopMedia()})()}toggleConnection(){let e=!!this.chromecastConnector?.presentationConnection$.getValue();this.log({message:`toggleConnection: isConnected - ${e}`}),e?this.disconnect():this.connect()}setVolume(e){}setMuted(e){}destroy(){this.log({message:`destroy`}),this.chromecastConnector?.destroy(),this.subscription.unsubscribe()}}var Pi=y(pt(),1),Fi=(e,...t)=>typeof e==`string`?e.includes(...t):Pi.default(e,...t),Ii=y(_t(),1),Li=y(Xt(),1),Ri=y(Pn(),1),zi=require(`@vkontakte/videoplayer-shared/es2015`);class F{constructor(e){i(this,`state`,void 0),i(this,`prevState`,void 0),i(this,`transition`,void 0),i(this,`transitionStarted$`,new zi.Subject),i(this,`transitionEnded$`,new zi.Subject),i(this,`transitionUpdated$`,new zi.Subject),i(this,`forceChanged$`,new zi.Subject),i(this,`stateChangeStarted$`,zi.merge(this.transitionStarted$,this.transitionUpdated$)),i(this,`stateChangeEnded$`,zi.merge(this.transitionEnded$,this.forceChanged$)),this.state=e,this.prevState=void 0}setState(e){let t=this.transition,n=this.state;this.transition=void 0,this.prevState=n,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:n,to:e,canceledTransition:t})}startTransitionTo(e){let t=this.transition,n=this.state;n===e||zi.isNonNullable(t)&&t.to===e||(this.prevState=n,this.state=e,t?(this.transition={from:t.from,to:e,canceledTransition:t},this.transitionUpdated$.next(this.transition)):(this.transition={from:n,to:e},this.transitionStarted$.next(this.transition)))}getTransition(){return this.transition}getState(){return this.state}getPrevState(){return this.prevState}}var Bi=require(`@vkontakte/videoplayer-shared/es2015`),Vi=5,Hi=5,Ui=500,Wi=7e3;class Gi{constructor(e){i(this,`subscription`,new Bi.Subscription),i(this,`loadMediaTimeoutSubscription`,new Bi.Subscription),i(this,`videoState`,new F(`stopped`)),i(this,`params`,void 0),i(this,`log`,void 0),i(this,`syncPlayback`,()=>{let e=this.videoState.getState(),t=this.videoState.getTransition(),n=this.params.desiredState.playbackState.getState(),r=this.params.desiredState.playbackState.getTransition(),i=this.params.desiredState.seekState.getState();if(this.log({message:`[syncPlayback] videoState: ${e}; videoTransition: ${JSON.stringify(t)}; desiredPlaybackState: ${n}; desiredPlaybackStateTransition: ${this.params.desiredState.playbackState.getTransition()}; seekState: ${JSON.stringify(i)};`}),n===`stopped`){e!==`stopped`&&(this.videoState.startTransitionTo(`stopped`),this.stop());return}if(!t){if(r?.to!==`paused`&&i.state===`requested`&&e!==`stopped`){this.seek(i.position/1e3);return}switch(n){case`ready`:switch(e){case`playing`:case`paused`:case`ready`:break;case`stopped`:this.videoState.startTransitionTo(`ready`),this.prepare();break;default:Bi.assertNever(e)}break;case`playing`:switch(e){case`playing`:break;case`paused`:this.videoState.startTransitionTo(`playing`),this.params.connection.remotePlayerController.playOrPause();break;case`ready`:this.videoState.startTransitionTo(`playing`),this.params.connection.remotePlayerController.playOrPause();break;case`stopped`:this.videoState.startTransitionTo(`ready`),this.prepare();break;default:Bi.assertNever(e)}break;case`paused`:switch(e){case`playing`:this.videoState.startTransitionTo(`paused`),this.params.connection.remotePlayerController.playOrPause();break;case`paused`:break;case`ready`:this.videoState.startTransitionTo(`paused`),this.videoState.setState(`paused`);break;case`stopped`:this.videoState.startTransitionTo(`ready`),this.prepare();break;default:Bi.assertNever(e)}break;default:Bi.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(Ti(e.format)),this.params.output.isAudioAvailable$.next(!0),this.handleRemoteVolumeChange({volume:this.params.connection.remotePlayer.volumeLevel,muted:this.params.connection.remotePlayer.isMuted});let 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);let e=new Bi.Subscription;this.subscription.add(e),this.subscription.add(Bi.merge(this.videoState.stateChangeStarted$.pipe(Bi.map(e=>`stateChangeStarted$ ${JSON.stringify(e)}`)),this.videoState.stateChangeEnded$.pipe(Bi.map(e=>`stateChangeEnded$ ${JSON.stringify(e)}`))).subscribe(e=>this.log({message:`[videoState] ${e}`})));let t=(e,t)=>this.subscription.add(e.subscribe(t));if(this.params.output.isLive$.getValue())this.params.output.position$.next(0),this.params.output.duration$.next(0);else{let t=new Bi.Subject;e.add(t.pipe(Bi.debounce(Ui)).subscribe(()=>{this.params.output.seekedEvent$.next()}));let n=NaN;e.add(Bi.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED).subscribe(e=>{this.logRemoteEvent(e);let r=e.value;this.params.output.position$.next(r),(this.params.desiredState.seekState.getState().state===`applying`||Math.abs(r-n)>Vi)&&t.next(r),n=r})),e.add(Bi.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.DURATION_CHANGED).subscribe(e=>{this.logRemoteEvent(e),this.params.output.duration$.next(e.value)}))}t(Bi.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED),t=>{this.logRemoteEvent(t),t.value?this.handleRemoteReady():(this.handleRemoteStop(),e.unsubscribe())}),t(Bi.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),e=>{this.logRemoteEvent(e),e.value?this.handleRemotePause():this.handleRemotePlay()}),t(Bi.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED),e=>{this.logRemoteEvent(e);let{remotePlayer:t}=this.params.connection,n=e.value,r=this.params.output.isBuffering$.getValue(),i=n===chrome.cast.media.PlayerState.BUFFERING;switch(r!==i&&this.params.output.isBuffering$.next(i),n){case chrome.cast.media.PlayerState.IDLE:!this.params.output.isLive$.getValue()&&t.duration-t.currentTime<Hi&&this.params.output.endedEvent$.next(),this.handleRemoteStop(),N(this.params.desiredState.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:Bi.assertNever(n)}}),t(Bi.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED),e=>{this.logRemoteEvent(e),this.handleRemoteVolumeChange({volume:e.value})}),t(Bi.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),e=>{this.logRemoteEvent(e),this.handleRemoteVolumeChange({muted:e.value})}),t(Bi.merge(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,Bi.observableFrom([`init`])).pipe(Bi.debounce(0)),this.syncPlayback)}restoreSession(e){this.log({message:`restoreSession`});let{remotePlayer:t}=this.params.connection;if(e.playerState!==chrome.cast.media.PlayerState.IDLE){t.isPaused?(this.videoState.setState(`paused`),N(this.params.desiredState.playbackState,`paused`)):(this.videoState.setState(`playing`),N(this.params.desiredState.playbackState,`playing`));let e=this.params.output.isLive$.getValue();this.params.output.duration$.next(e?0:t.duration),this.params.output.position$.next(e?0:t.currentTime),this.params.desiredState.seekState.setState({state:`none`})}}prepare(){let e=this.params.format;this.log({message:`[prepare] format: ${e}`});let t=Ur(this.params),n=this.createLoadRequest(t);this.loadMedia(n)}handleRemotePause(){let e=this.videoState.getState();(this.videoState.getTransition()?.to===`paused`||e===`playing`)&&(this.videoState.setState(`paused`),N(this.params.desiredState.playbackState,`paused`))}handleRemotePlay(){let e=this.videoState.getState();(this.videoState.getTransition()?.to===`playing`||e===`paused`)&&(this.videoState.setState(`playing`),N(this.params.desiredState.playbackState,`playing`))}handleRemoteReady(){this.videoState.getTransition()?.to===`ready`&&this.videoState.setState(`ready`),this.params.desiredState.playbackState.getTransition()?.to===`ready`&&N(this.params.desiredState.playbackState,`ready`)}handleRemoteStop(){this.videoState.getState()!==`stopped`&&this.videoState.setState(`stopped`)}handleRemoteVolumeChange(e){let t=this.params.output.volume$.getValue(),n={volume:e.volume??t.volume,muted:e.muted??t.muted};(n.volume!==t.volume||n.muted!==n.muted)&&this.params.output.volume$.next(n)}seek(e){this.params.output.willSeekEvent$.next();let{remotePlayer:t,remotePlayerController:n}=this.params.connection;t.currentTime=e,n.seek()}stop(){let{remotePlayerController:e}=this.params.connection;e.stop()}createLoadRequest(e){let t=new chrome.cast.media.LoadRequest(e);t.autoplay=!1;let n=this.params.desiredState.seekState.getState();return n.state===`applying`||n.state===`requested`?t.currentTime=this.params.output.isLive$.getValue()?0:n.position/1e3:t.currentTime=0,t}loadMedia(e){let t=this.params.connection.session.loadMedia(e),n=new Promise((e,t)=>{this.loadMediaTimeoutSubscription.add(Bi.timeout(Wi).subscribe(()=>t(`timeout(${Wi})`)))});Ri.default(Promise.race([t,n]).then(()=>{this.log({message:`[loadMedia] completed, format: ${this.params.format}`}),this.params.desiredState.seekState.getState().state===`applying`&&this.params.output.seekedEvent$.next(),this.handleRemoteReady()},e=>{let t=`[prepare] loadMedia failed, format: ${this.params.format}, reason: ${e}`;this.log({message:t}),this.params.output.error$.next({id:`ChromecastProvider.loadMedia`,category:Bi.ErrorCategory.VIDEO_PIPELINE,message:t,thrown:e})}),()=>{this.loadMediaTimeoutSubscription.unsubscribe()})}logRemoteEvent(e){this.log({message:`[remoteEvent] ${JSON.stringify(e)}`})}}var Ki=y(pt(),1),qi=require(`@vkontakte/videoplayer-shared/es2015`),Ji=require(`@vkontakte/videoplayer-shared/es2015`),Yi=(e,t)=>{try{e.pause(),e.playbackRate=0,Ji.clearVideoElement(e,t),e.remove()}catch(e){console.error(e)}},Xi=require(`@vkontakte/videoplayer-shared/es2015`),Zi=`__spvc`;class Qi{constructor(){i(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)}}var $i=qi.getWindow(),ea=$i.WeakMap?new $i.WeakMap:new Qi,ta=$i.WeakMap?new $i.WeakMap:new Map,na=(e,t=20)=>{let n=0;return Xi.fromEvent(e,`ratechange`).subscribe(r=>{n++,n>=t&&(e.currentTime=e.currentTime,n=0)})};function ra(e){e.style.position=`fixed`,e.style.left=`100%`,e.setAttribute(`data-role`,`screen`),qi.getWindow().document.body.appendChild(e)}function ia(e,t){e.style.position=``,e.style.left=``,t.appendChild(e)}var aa=(e,{audioVideoSyncRate:t,disableYandexPiP:n,clearVideoElementInnerHTML:r,reuseOwnVideoElement:i})=>{let a,o=e.querySelector(`video`),s=!!o,c=qi.getWindow().document.querySelector(`body > video[data-role=screen]`)||void 0;i?$i[Zi]=c:(c?.remove(),delete $i[Zi]),o?(a=o,qi.clearVideoElement(a,r)):c&&c===$i[Zi]?(a=c,ia(a,e)):(a=qi.getWindow().document.createElement(`video`),e.appendChild(a),i&&($i[Zi]=a)),ea.set(a,s);let l=new Xi.Subscription;return l.add(na(a,t)),ta.set(a,l),a.setAttribute(`crossorigin`,`anonymous`),a.setAttribute(`playsinline`,`playsinline`),n&&a.setAttribute(`x-yandex-pip`,`false`),a.controls=!1,a.setAttribute(`poster`,`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=`),a},oa=(e,{keepVideoElement:t,clearVideoElementInnerHTML:n,reuseOwnVideoElement:r})=>{ta.get(e)?.unsubscribe(),ta.delete(e);let i=ea.get(e);ea.delete(e),i||t?qi.clearVideoElement(e,n):r?(qi.clearVideoElement(e,n),ra(e)):Yi(e,n)},sa=y(st(),1),I=require(`@vkontakte/videoplayer-shared/es2015`),ca=require(`@vkontakte/videoplayer-shared/es2015`),la=(e,t,n,{equal:r=(e,t)=>e===t,changed$:i,onError:a}={})=>{let o=e.getState(),s=t(),c=ca.isNullable(i),l=new ca.Subscription;return i&&l.add(i.subscribe(t=>{r(t,e.getState())&&e.setState(t)},a)),r(s,o)||(n(o),c&&e.setState(o)),l.add(e.stateChangeStarted$.subscribe(t=>{n(t.to),c&&e.setState(t.to)},a)),l},ua=(e,t,n)=>la(t,()=>e.loop,t=>{ca.isNonNullable(t)&&(e.loop=t)},{onError:n}),da=(e,t,n,r,i)=>la(t,()=>({muted:e.muted,volume:e.volume}),t=>{i?.skipVideoElVolumeSync$.getValue()||ca.isNonNullable(t)&&(e.muted=t.muted,e.volume=t.volume)},{equal:(e,t)=>e===t||e?.muted===t?.muted&&e?.volume===t?.volume,changed$:n,onError:r}),fa=(e,t,n,r)=>la(t,()=>e.playbackRate,t=>{ca.isNonNullable(t)&&(e.playbackRate=t)},{changed$:n,onError:r}),pa=la,ma=e=>[`__`,e.language,e.label].join(`|`),ha=(e,t)=>{if(e.id===t)return!0;let[n,r,i]=t.split(`|`);return e.language===r&&e.label===i};class ga{constructor(e){i(this,`available$`,new I.Subject),i(this,`current$`,new I.ValueSubject(void 0)),i(this,`error$`,new I.Subject),i(this,`video`,void 0),i(this,`cueSettings`,void 0),i(this,`subscription`,new I.Subscription),i(this,`externalTracks`,new Map),i(this,`internalTracks`,new Map),i(this,`baseURL`,void 0),this.baseURL=e}connect(e,t,n){this.video=e,this.cueSettings=t.textTrackCuesSettings,this.subscribe();let r=e=>{this.error$.next({id:`TextTracksManager`,category:I.ErrorCategory.WTF,message:`Generic HtmlVideoTextTrackManager error`,thrown:e})};this.subscription.add(this.available$.subscribe(n.availableTextTracks$)),this.subscription.add(this.current$.subscribe(n.currentTextTrack$)),this.subscription.add(this.error$.subscribe(n.error$)),this.subscription.add(pa(t.internalTextTracks,()=>sa.default(this.internalTracks),e=>{I.isNonNullable(e)&&this.setInternal(e)},{equal:(e,t)=>I.isNonNullable(e)&&I.isNonNullable(t)&&e.length===t.length&&e.every(({id:e},n)=>e===t[n].id),changed$:this.available$.pipe(I.map(e=>e.filter(({type:e})=>e===`internal`))),onError:r})),this.subscription.add(pa(t.externalTextTracks,()=>sa.default(this.externalTracks),e=>{I.isNonNullable(e)&&this.setExternal(e)},{equal:(e,t)=>I.isNonNullable(e)&&I.isNonNullable(t)&&e.length===t.length&&e.every(({id:e},n)=>e===t[n].id),changed$:this.available$.pipe(I.map(e=>e.filter(({type:e})=>e===`external`))),onError:r})),this.subscription.add(pa(t.currentTextTrack,()=>{if(this.video)return;let e=this.htmlTextTracksAsArray().find(({mode:e})=>e===`showing`);return e&&this.htmlTextTrackToITextTrack(e).id},e=>this.select(e),{changed$:this.current$,onError:r})),this.subscription.add(pa(t.textTrackCuesSettings,()=>({}),()=>{if(this.video)for(let e of this.htmlTextTracksAsArray())this.applyCueSettings(e.cues),this.applyCueSettings(e.activeCues)}))}subscribe(){I.assertNonNullable(this.video);let{textTracks:e}=this.video;this.subscription.add(I.fromEvent(e,`addtrack`).subscribe(()=>{let e=this.current$.getValue();e&&this.select(e)})),this.subscription.add(I.merge(I.fromEvent(e,`addtrack`),I.fromEvent(e,`removetrack`),I.observableFrom([`init`])).pipe(I.map(()=>this.htmlTextTracksAsArray().map(e=>this.htmlTextTrackToITextTrack(e))),I.filterChanged((e,t)=>e.length===t.length&&e.every(({id:e},n)=>e===t[n].id))).subscribe(this.available$)),this.subscription.add(I.merge(I.fromEvent(e,`change`),I.observableFrom([`init`])).pipe(I.map(()=>this.htmlTextTracksAsArray().find(({mode:e})=>e===`showing`)),I.map(e=>e&&this.htmlTextTrackToITextTrack(e).id),I.filterChanged()).subscribe(this.current$));let t=e=>this.applyCueSettings(e.target?.activeCues??null);this.subscription.add(I.fromEvent(e,`addtrack`).subscribe(e=>{e.track?.addEventListener(`cuechange`,t);let n=e=>{let t=e.target?.cues??null;t&&t.length&&(this.applyCueSettings(e.target?.cues??null),e.target?.removeEventListener(`cuechange`,n))};e.track?.addEventListener(`cuechange`,n)})),this.subscription.add(I.fromEvent(e,`removetrack`).subscribe(e=>{e.track?.removeEventListener(`cuechange`,t)}))}applyCueSettings(e){if(!e||!e.length)return;let t=this.cueSettings.getState();for(let n of Array.from(e)){let e=n;I.isNonNullable(t.align)&&(e.align=t.align),I.isNonNullable(t.position)&&(e.position=t.position),I.isNonNullable(t.size)&&(e.size=t.size),I.isNonNullable(t.line)&&(e.line=t.line)}}htmlTextTracksAsArray(e=!1){I.assertNonNullable(this.video);let t=[...this.video.textTracks];return e?t:t.filter(ga.isHealthyTrack)}htmlTextTrackToITextTrack(e){let{language:t,label:n}=e,r=e.id?e.id:ma(e),i=this.externalTracks.has(r),a=(i?this.externalTracks.get(r)?.isAuto:this.internalTracks.get(r)?.isAuto)??r.includes(`auto`);return i?{id:r,type:`external`,isAuto:a,language:t,label:n,url:this.externalTracks.get(r)?.url}:{id:r,type:`internal`,isAuto:a,language:t,label:n,url:this.internalTracks.get(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(([,e])=>this.detach(e)),e.filter(({id:e})=>!this.externalTracks.has(e)).forEach(e=>this.attach(e)),Array.from(this.externalTracks).filter(([t])=>!e.find(e=>e.id===t)).forEach(([,e])=>this.detach(e))}setInternal(e){let t=[...this.externalTracks];e.filter(({id:e,language:n,isAuto:r})=>!this.internalTracks.has(e)&&!t.some(([,e])=>e.language===n&&e.isAuto===r)).forEach(e=>this.attach(e)),Array.from(this.internalTracks).filter(([t])=>!e.find(e=>e.id===t)).forEach(([,e])=>this.detach(e))}select(e){I.assertNonNullable(this.video);for(let e of this.htmlTextTracksAsArray(!0))e.mode=`showing`;for(let t of this.htmlTextTracksAsArray(!0))(I.isNullable(e)||!ha(t,e))&&(t.mode=`disabled`)}destroy(){if(this.subscription.unsubscribe(),this.video)for(let e of Array.from(this.video.getElementsByTagName(`track`))){let t=e.getAttribute(`id`);t&&this.externalTracks.has(t)&&this.video.removeChild(e)}this.externalTracks.clear()}attach(e){I.assertNonNullable(this.video);let t=document.createElement(`track`);this.baseURL?t.setAttribute(`src`,new URL(e.url,this.baseURL).toString()):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){I.assertNonNullable(this.video);let t=Array.prototype.find.call(this.video.getElementsByTagName(`track`),t=>t.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)}}var _a=ga;class va{constructor(){i(this,`pausedTime`,0),i(this,`streamOffset`,0),i(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()}}var ya=e=>{let t=e;for(;!(t instanceof Document)&&!(t instanceof ShadowRoot)&&t!==null;)t=t?.parentNode;return t??void 0},ba=e=>{let t=ya(e);return!!(t&&t.fullscreenElement&&t.fullscreenElement===e)},xa=e=>{let t=ya(e);return!!(t&&t.pictureInPictureElement&&t.pictureInPictureElement===e)},L=require(`@vkontakte/videoplayer-shared/es2015`),Sa=3,Ca=(e,t,n=Sa)=>{let r=0,i=0;for(let a=0;a<e.length;a++){let o=e.start(a),s=e.end(a);if(o<=t&&t<=s){if(r=o,i=s,!n)return{from:r,to:i};for(let t=a-1;t>=0;t--)e.end(t)+n>=r&&(r=e.start(t));for(let t=a+1;t<e.length;t++)e.start(t)-n<=i&&(i=e.end(t))}}return{from:r,to:i}},wa=e=>{let t=t=>L.fromEvent(e,t).pipe(L.mapTo(void 0),L.shareReplay(1)),n=new L.Subscription,r=()=>n.unsubscribe(),i=L.merge(L.fromEvent(e,`progress`),L.fromEvent(e,`timeupdate`)).pipe(L.map(()=>Ca(e.buffered,e.currentTime)),L.shareReplay(1)),a=P.browser.isSafari?L.combine({play:t(`play`).pipe(L.once()),playing:t(`playing`)}).pipe(L.mapTo(void 0),L.shareReplay(1)):t(`playing`),o=L.fromEvent(e,`volumechange`).pipe(L.map(()=>({muted:e.muted,volume:e.volume})),L.shareReplay(1)),s=L.fromEvent(e,`ratechange`).pipe(L.map(()=>e.playbackRate),L.shareReplay(1)),c=L.fromEvent(e,`error`).pipe(L.filter(()=>!!(e.error||e.played.length)),L.map(()=>{let t=e.error;return{id:t?`MediaError#${t.code}`:`HtmlVideoError`,category:L.ErrorCategory.VIDEO_PIPELINE,message:t?t.message:`Error event from HTML video element`,thrown:e.error??void 0}}),L.shareReplay(1)),l=L.fromEvent(e,`timeupdate`).pipe(L.map(()=>e.currentTime),L.shareReplay(1)),u=[`waiting`,`seeking`,`seeked`,`timeupdate`],d=new L.Subject,f=.3,p;n.add(L.merge(...u.map(t=>L.fromEvent(e,t))).subscribe(t=>{let n=e.currentTime;e.loop&&L.isNonNullable(p)&&L.isNonNullable(n)&&p>=e.duration-f&&n<=f&&d.next(p),p=n}));let m=t(`pause`).pipe(L.filter(()=>!e.error&&p!==e.duration),L.shareReplay(1)),h=L.fromEvent(e,`enterpictureinpicture`).pipe(L.shareReplay(1)),g=L.fromEvent(e,`leavepictureinpicture`).pipe(L.shareReplay(1)),_=new L.ValueSubject(xa(e));n.add(h.subscribe(()=>_.next(!0))),n.add(g.subscribe(()=>_.next(!1)));let v=new L.ValueSubject(ba(e)),y=L.fromEvent(e,`fullscreenchange`).pipe(L.shareReplay(1));n.add(y.pipe(L.map(()=>ba(e))).subscribe(v));let b=L.fromEvent(e,`timeupdate`).pipe(L.map(t=>e.duration-e.currentTime<.1),L.filterChanged(),L.shareReplay(1)),x=L.merge(b.pipe(L.filter(t=>!e.loop&&t)),L.fromEvent(e,`ended`)).pipe(L.throttle(1e3),L.mapTo(void 0),L.shareReplay(1)),S=L.merge(...[`waiting`,`pause`,`canplay`,`play`,`canplaythrough`,`playing`,`seeking`,`seeked`,`ended`].map(t=>L.fromEvent(e,t)),b.pipe(L.map(e=>({type:e?`ended`:`unknown`})))).pipe(L.map(t=>P.browser.isFirefox&&t.type===`ended`?e.readyState<2:e.readyState<3),L.filterChanged(),L.shareReplay(1));return{playing$:a,pause$:m,canplay$:t(`canplay`),ended$:x,looped$:d,error$:c,seeked$:t(`seeked`),seeking$:t(`seeking`),progress$:t(`progress`),loadStart$:t(`loadstart`),loadedMetadata$:t(`loadedmetadata`),loadedData$:t(`loadeddata`),timeUpdate$:l,durationChange$:L.fromEvent(e,`durationchange`).pipe(L.map(()=>e.duration),L.shareReplay(1)),isBuffering$:S,currentBuffer$:i,volumeState$:o,playbackRateState$:s,inPiP$:_,inFullscreen$:v,enterPip$:h,leavePip$:g,destroy:r}},Ta=require(`@vkontakte/videoplayer-shared/es2015`),Ea=e=>{switch(e){case`mobile`:return Ta.VideoQuality.Q_144P;case`lowest`:return Ta.VideoQuality.Q_240P;case`low`:return Ta.VideoQuality.Q_360P;case`sd`:case`medium`:return Ta.VideoQuality.Q_480P;case`hd`:case`high`:return Ta.VideoQuality.Q_720P;case`fullhd`:case`full`:return Ta.VideoQuality.Q_1080P;case`quadhd`:case`quad`:return Ta.VideoQuality.Q_1440P;case`ultrahd`:case`ultra`:return Ta.VideoQuality.Q_2160P}},Da=y(Rn(),1),Oa=y(pt(),1),ka=y(_t(),1),R=require(`@vkontakte/videoplayer-shared/es2015`),Aa=!1,ja={},Ma=e=>{Aa=e},Na=()=>{ja={}},Pa=e=>{e(ja)},Fa=(e,t)=>{Aa&&(ja.meta=ja.meta??{},ja.meta[e]=t)};class Ia{constructor(e){i(this,`name`,void 0),this.name=e}next(e){if(!Aa)return;ja.series=ja.series??{};let t=ja.series[this.name]??[];t.push([Date.now(),e]),ja.series[this.name]=t}}var La=require(`@vkontakte/videoplayer-shared/es2015`);function Ra(e,t,n){return!e.max&&e.min===t?`high_quality`:!e.min&&e.max===n?`traffic_saving`:`unknown`}function za(e,t,n){return La.isNullable(e)||La.isNonNullable(e.min)&&La.isNonNullable(e.max)&&La.isLower(e.max,e.min)||La.isNonNullable(e.min)&&La.isNonNullable(t)&&La.isHigher(e.min,t)||La.isNonNullable(e.max)&&La.isNonNullable(n)&&La.isLower(e.max,n)}function Ba({limits:e,highestAvailableHeight:t,lowestAvailableHeight:n}){return za({max:e?.max?La.videoHeightToQuality(e.max):void 0,min:e?.min?La.videoHeightToQuality(e.min):void 0},t?La.videoHeightToQuality(t):void 0,n?La.videoHeightToQuality(n):void 0)}var Va=new Ia(`best_bitrate`),Ha=(e,t,n)=>(t-n)*2**(-10*e)+n,Ua=e=>(t,n)=>e*(Number(t.bitrate)-Number(n.bitrate));class Wa{constructor(){i(this,`last`,void 0),i(this,`history`,{})}recordSelection(e){this.history[e.id]=R.now()}recordSwitch(e){this.last=e}clear(){this.last=void 0,this.history={}}}var Ga=`Assertion "ABR Tracks is empty array" failed`,Ka=new WeakMap,qa=new WeakMap,Ja=new WeakMap,Ya=(e,t,n,r)=>{let i=[...t].sort(Ua(1)),a=[...n].sort(Ua(1)),o=a.filter(t=>R.isNonNullable(t.bitrate)&&R.isNonNullable(e.bitrate)?e.bitrate/t.bitrate>r:!0),s=Da.default(a,Math.round(a.length*i.indexOf(e)/(i.length+1)))??Da.default(a,-1);return s&&Oa.default(o,s)?s:o.length?Da.default(o,-1):Da.default(a,0)},Xa=(e,t,n,r)=>{let i=Ka.get(t);i||(i=[...t].sort(Ua(1)),Ka.set(t,i));let a=Ka.get(n);a||(a=[...n].sort(Ua(1)),Ka.set(n,a));let o=Ja.get(e);o||(o=a.filter(t=>R.isNonNullable(t.bitrate)&&R.isNonNullable(e.bitrate)?e.bitrate/t.bitrate>r:!0),Ja.set(e,o));let s=Da.default(a,Math.round(a.length*i.indexOf(e)/(i.length+1)))??Da.default(a,-1);return s&&Oa.default(o,s)?s:o.length?Da.default(o,-1):Da.default(a,0)},Za=e=>`quality`in e,Qa=(e,t,n,r)=>{var i;let a=R.isNonNullable(r==null||(i=r.last)==null?void 0:i.bitrate)&&R.isNonNullable(n?.bitrate)&&r.last.bitrate<n.bitrate?e.trackCooldownIncreaseQuality:e.trackCooldownDecreaseQuality,o=n&&r&&r.history[n.id]&&R.now()-r.history[n.id]<=a&&(!r.last||n.id!==r.last.id);if(n?.id&&r&&!o&&r.recordSelection(n),o&&r?.last){let e=r.last;return r?.recordSwitch(e),t({message:`
|
|
7
|
+
\v\f\r \xA0 \u2028\u2029`}),tr=S((e,t)=>{var n=k(),r=le(),i=zn(),a=er(),o=n(``.replace),s=RegExp(`^[`+a+`]+`),c=RegExp(`(^|[^`+a+`])[`+a+`]+$`),l=function(e){return function(t){var n=i(r(t));return e&1&&(n=o(n,s,``)),e&2&&(n=o(n,c,`$1`)),n}};t.exports={start:l(1),end:l(2),trim:l(3)}}),nr=S((e,t)=>{var n=xt().PROPER,r=D(),i=er(),a=`
`;t.exports=function(e){return r(function(){return!!i[e]()||a[e]()!==a||n&&i[e].name!==e})}}),rr=S((e,t)=>{var n=tr().start;t.exports=nr()(`trimStart`)?function(){return n(this)}:``.trimStart}),ir=S(()=>{var e=Ue(),t=rr();e({target:`String`,proto:!0,name:`trimStart`,forced:``.trimLeft!==t},{trimLeft:t})}),ar=S(()=>{ir();var e=Ue(),t=rr();e({target:`String`,proto:!0,name:`trimStart`,forced:``.trimStart!==t},{trimStart:t})}),or=S((e,t)=>{ar(),t.exports=ut()(`String`,`trimLeft`)}),sr=S((e,t)=>{t.exports=or()}),cr=S((e,t)=>{t.exports=sr()}),lr=S((e,t)=>{var n=de(),r=te(),i=je()(`match`);t.exports=function(e){var t;return n(e)&&((t=e[i])===void 0?r(e)===`RegExp`:!!t)}}),ur=S((e,t)=>{var n=E(),r=D(),i=n.RegExp;t.exports={correct:!r(function(){var e=!0;try{i(`.`,`d`)}catch{e=!1}var t={},n=``,r=e?`dgimsy`:`gimsy`,a=function(e,r){Object.defineProperty(t,e,{get:function(){return n+=r,!0}})},o={dotAll:`s`,global:`g`,ignoreCase:`i`,multiline:`m`,sticky:`y`};for(var s in e&&(o.hasIndices=`d`),o)a(s,o[s]);return Object.getOwnPropertyDescriptor(i.prototype,`flags`).get.call(t)!==r||n!==r})}}),dr=S((e,t)=>{var n=Be();t.exports=function(){var e=n(this),t=``;return e.hasIndices&&(t+=`d`),e.global&&(t+=`g`),e.ignoreCase&&(t+=`i`),e.multiline&&(t+=`m`),e.dotAll&&(t+=`s`),e.unicode&&(t+=`u`),e.unicodeSets&&(t+=`v`),e.sticky&&(t+=`y`),t}}),fr=S((e,t)=>{var n=ie(),r=ke(),i=me(),a=ur(),o=dr(),s=RegExp.prototype;t.exports=a.correct?function(e){return e.flags}:function(e){return!a.correct&&i(s,e)&&!r(e,`flags`)?n(o,e):e.flags}}),pr=S((e,t)=>{var n=k(),r=Oe(),i=Math.floor,a=n(``.charAt),o=n(``.replace),s=n(``.slice),c=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,l=/\$([$&'`]|\d{1,2})/g;t.exports=function(e,t,n,u,d,f){var p=n+e.length,m=u.length,h=l;return d!==void 0&&(d=r(d),h=c),o(f,h,function(r,o){var c;switch(a(o,0)){case`$`:return`$`;case`&`:return e;case"`":return s(t,0,n);case`'`:return s(t,p);case`<`:c=d[s(o,1,-1)];break;default:var l=+o;if(l===0)return r;if(l>m){var f=i(l/10);return f===0?r:f<=m?u[f-1]===void 0?a(o,1):u[f-1]+a(o,1):r}c=u[l-1]}return c===void 0?``:c})}}),mr=S(()=>{var e=Ue(),t=ie(),n=k(),r=le(),i=re(),a=de(),o=lr(),s=zn(),c=Se(),l=fr(),u=pr(),d=je(),f=we(),p=d(`replace`),m=TypeError,h=n(``.indexOf),g=n(``.replace),_=n(``.slice),v=Math.max;e({target:`String`,proto:!0},{replaceAll:function(e,n){var d=r(this),y,b,x,S,C,w,T,E,D,O,ee=0,k=``;if(a(e)){if(y=o(e),y&&(b=s(r(l(e))),!~h(b,`g`)))throw new m("`.replaceAll` does not allow non-global regexes");if(x=c(e,p),x)return t(x,e,d,n);if(f&&y)return g(s(d),e,n)}for(S=s(d),C=s(e),w=i(n),w||(n=s(n)),T=C.length,E=v(1,T),D=h(S,C);D!==-1;)O=w?s(n(C,D,S)):u(C,S,D,[],void 0,n),k+=_(S,ee,D)+O,ee=D+T,D=D+E>S.length?-1:h(S,C,D+E);return ee<S.length&&(k+=_(S,ee)),k}})}),hr=S((e,t)=>{mr(),t.exports=ut()(`String`,`replaceAll`)}),gr=S((e,t)=>{t.exports=hr()}),_r=S((e,t)=>{t.exports=gr()}),vr=S((e,t)=>{var n=Je(),r=zn(),i=le(),a=RangeError;t.exports=function(e){var t=r(i(this)),o=``,s=n(e);if(s<0||s===1/0)throw new a(`Wrong number of repetitions`);for(;s>0;(s>>>=1)&&(t+=t))s&1&&(o+=t);return o}}),yr=S((e,t)=>{var n=k(),r=Xe(),i=zn(),a=vr(),o=le(),s=n(a),c=n(``.slice),l=Math.ceil,u=function(e){return function(t,n,a){var u=i(o(t)),d=r(n),f=u.length,p=a===void 0?` `:i(a),m,h;return d<=f||p===``?u:(m=d-f,h=s(p,l(m/p.length)),h.length>m&&(h=c(h,0,m)),e?u+h:h+u)}};t.exports={start:u(!1),end:u(!0)}}),br=S((e,t)=>{var n=he();t.exports=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(n)}),xr=S(()=>{var e=Ue(),t=yr().start;e({target:`String`,proto:!0,forced:br()},{padStart:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})}),Sr=S((e,t)=>{xr(),t.exports=ut()(`String`,`padStart`)}),Cr=S((e,t)=>{t.exports=Sr()}),wr=S((e,t)=>{t.exports=Cr()}),Tr={};T(Tr,{isMobile:()=>ni,clientChecker:()=>P,areValidLiveRecordSources:()=>Ei,WebmCodecStrategy:()=>$c,VideoQuality:()=>Ff.VideoQuality,VideoFormat:()=>Or,VideoCodec:()=>kr,ValueSubject:()=>Ff.ValueSubject,VERSION:()=>Er,Surface:()=>Mr,Subscription:()=>Ff.Subscription,Subject:()=>Ff.Subject,SDK_VERSION:()=>If,PredefinedQualityLimits:()=>Nr,Player:()=>Pf,PlaybackState:()=>Dr,Observable:()=>Ff.Observable,HttpConnectionType:()=>jr,ChromecastState:()=>Ar}),module.exports=b(Tr);var Er=`2.0.157-dev.55dfadaf.0`,Dr;(e=>{e.STOPPED=`stopped`,e.READY=`ready`,e.PLAYING=`playing`,e.PAUSED=`paused`})(Dr||={});var Or;(e=>{e.MPEG=`MPEG`,e.DASH=`DASH`,e.DASH_SEP=`DASH_SEP`,e.DASH_SEP_VK=`DASH_SEP`,e.DASH_WEBM=`DASH_WEBM`,e.DASH_WEBM_AV1=`DASH_WEBM_AV1`,e.DASH_STREAMS=`DASH_STREAMS`,e.DASH_WEBM_VK=`DASH_WEBM`,e.DASH_ONDEMAND=`DASH_ONDEMAND`,e.DASH_ONDEMAND_VK=`DASH_ONDEMAND`,e.DASH_LIVE=`DASH_LIVE`,e.DASH_LIVE_CMAF=`DASH_LIVE_CMAF`,e.DASH_LIVE_WEBM=`DASH_LIVE_WEBM`,e.HLS=`HLS`,e.HLS_ONDEMAND=`HLS_ONDEMAND`,e.HLS_JS=`HLS`,e.HLS_FMP4=`HLS_FMP4`,e.HLS_LIVE=`HLS_LIVE`,e.HLS_LIVE_CMAF=`HLS_LIVE_CMAF`,e.WEB_RTC_LIVE=`WEB_RTC_LIVE`})(Or||={});var kr;(e=>{e.AV1=`av1`,e.VP9=`vp9`,e.AVC1=`avc1`,e.HEV1=`hev1`})(kr||={});var Ar;(e=>{e.NOT_AVAILABLE=`NOT_AVAILABLE`,e.AVAILABLE=`AVAILABLE`,e.CONNECTING=`CONNECTING`,e.CONNECTED=`CONNECTED`})(Ar||={});var jr;(e=>{e.HTTP1=`http1`,e.HTTP2=`http2`,e.QUIC=`quic`})(jr||={});var Mr;(e=>{e.NONE=`none`,e.INLINE=`inline`,e.FULLSCREEN=`fullscreen`,e.SECOND_SCREEN=`second_screen`,e.PIP=`pip`,e.INVISIBLE=`invisible`})(Mr||={});var Nr;(e=>{e.TRAFFIC_SAVING=`traffic_saving`,e.HIGH_QUALITY=`high_quality`,e.UNKNOWN=`unknown`})(Nr||={});var Pr=y(st(),1),Fr=y(pt(),1),j=require(`@vkontakte/videoplayer-shared/es2015`),Ir=e=>new Promise((t,n)=>{let r=document.createElement(`script`);r.setAttribute(`src`,e),r.onload=()=>t(),r.onerror=e=>n(e),document.body.appendChild(r)});class Lr{constructor(e){i(this,`connection$`,new j.ValueSubject(void 0)),i(this,`castState$`,new j.ValueSubject(`NOT_AVAILABLE`)),i(this,`errorEvent$`,new j.Subject),i(this,`contentId`,void 0),i(this,`realCastState$`,new j.ValueSubject(`NOT_AVAILABLE`)),i(this,`subscription`,new j.Subscription),i(this,`log`,void 0),i(this,`params`,void 0),i(this,`isDestroyed`,!1),this.params=e,this.log=this.params.dependencies.logger.createComponentLog(`ChromecastInitializer`);let t=`chrome`in window;if(this.log({message:`[constructor] receiverApplicationId: ${this.params.receiverApplicationId}, isDisabled: ${this.params.isDisabled}, isSupported: ${t}`}),e.isDisabled||!t)return;let n=j.isNonNullable(window.chrome?.cast),r=!!window.__onGCastApiAvailable;n?this.initializeCastApi():(window.__onGCastApiAvailable=e=>{delete window.__onGCastApiAvailable,e&&!this.isDestroyed&&this.initializeCastApi()},r||Ir(`https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1`).catch(()=>this.errorEvent$.next({id:`ChromecastLoading`,category:j.ErrorCategory.NETWORK,message:`Script loading failed!`})))}connect(){cast.framework.CastContext.getInstance()?.requestSession()}disconnect(){var e;(e=cast.framework.CastContext.getInstance())==null||(e=e.getCurrentSession())==null||e.endSession(!0)}stopMedia(){return new Promise((e,t)=>{var n;(n=cast.framework.CastContext.getInstance())==null||(n=n.getCurrentSession())==null||(n=n.getMediaSession())==null||n.stop(new chrome.cast.media.StopRequest,e,t)})}toggleConnection(){j.isNonNullable(this.connection$.getValue())?this.disconnect():this.connect()}setVolume(e){let t=this.connection$.getValue();j.isNullable(t)||(t.remotePlayer.volumeLevel=e,t.remotePlayerController.setVolumeLevel())}setMuted(e){let t=this.connection$.getValue();j.isNullable(t)||e!==t.remotePlayer.isMuted&&t.remotePlayerController.muteOrUnmute()}destroy(){this.isDestroyed=!0,this.subscription.unsubscribe()}initListeners(){let e=new cast.framework.RemotePlayer,t=new cast.framework.RemotePlayerController(e),n=cast.framework.CastContext.getInstance();this.subscription.add(j.fromEvent(n,cast.framework.CastContextEventType.SESSION_STATE_CHANGED).subscribe(e=>{switch(e.sessionState){case cast.framework.SessionState.SESSION_STARTED:case cast.framework.SessionState.SESSION_STARTING:case cast.framework.SessionState.SESSION_RESUMED:var t;this.contentId=(t=n.getCurrentSession())==null||(t=t.getMediaSession())==null||(t=t.media)==null?void 0:t.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 j.assertNever(e.sessionState)}})).add(j.merge(j.fromEvent(n,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe(j.tap(e=>{this.log({message:`[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: ${JSON.stringify(e)}`})}),j.map(e=>e.castState)),j.observableFrom([n.getCastState()])).pipe(j.filterChanged(),j.map(Rr),j.tap(e=>{this.log({message:`realCastState$: ${e}`})})).subscribe(this.realCastState$)).add(this.realCastState$.subscribe(r=>{let i=r===`CONNECTED`,a=j.isNonNullable(this.connection$.getValue());if(i&&!a){var o;let r=n.getCurrentSession();j.assertNonNullable(r);let i=r.getCastDevice(),a=(o=r.getMediaSession())==null||(o=o.media)==null?void 0:o.contentId;(j.isNullable(a)||a===this.contentId)&&(this.log({message:`connection created`}),this.connection$.next({remotePlayer:e,remotePlayerController:t,session:r,castDevice:i}))}else !i&&a&&(this.log({message:`connection destroyed`}),this.connection$.next(void 0));this.castState$.next(r===`CONNECTED`?j.isNonNullable(this.connection$.getValue())?`CONNECTED`:`AVAILABLE`:r)}))}initializeCastApi(){let e,t,n;try{e=cast.framework.CastContext.getInstance(),t=chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,n=chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}catch{return}try{e.setOptions({receiverApplicationId:this.params.receiverApplicationId??t,autoJoinPolicy:n}),this.initListeners()}catch(e){this.errorEvent$.next({id:`ChromecastInitializer`,category:j.ErrorCategory.EXTERNAL_API,message:`[initializeCastApi] failed`,thrown:e})}}}var Rr=e=>{switch(e){case cast.framework.CastState.NO_DEVICES_AVAILABLE:return`NOT_AVAILABLE`;case cast.framework.CastState.NOT_CONNECTED:return`AVAILABLE`;case cast.framework.CastState.CONNECTING:return`CONNECTING`;case cast.framework.CastState.CONNECTED:return`CONNECTED`;default:return j.assertNever(e)}},M=require(`@vkontakte/videoplayer-shared/es2015`),zr=require(`@vkontakte/videoplayer-shared/es2015`),Br=require(`@vkontakte/videoplayer-shared/es2015`),Vr=(e,t=0,n=0)=>{switch(n){case 0:return e.replace(`_offset_p`,t===0?``:`_`+t.toFixed(0));case 1:{if(t===0)return e;let n=new URL(e);return n.searchParams.append(`playback_shift`,t.toFixed(0)),n.toString()}case 2:{let n=new URL(e);return!n.searchParams.get(`offset_p`)&&t===0?e:(n.searchParams.set(`offset_p`,t.toFixed(0)),n.toString())}default:Br.assertNever(n)}return e},Hr=(e,t)=>{switch(t){case 0:return NaN;case 1:{let t=new URL(e);return Number(t.searchParams.get(`playback_shift`))}case 2:{let t=new URL(e);return Number(t.searchParams.get(`offset_p`)??0)}default:Br.assertNever(t)}},Ur=e=>{let{source:t,format:n,meta:r,output:i}=e,a,o,s;switch(n){case`MPEG`:{let e=t[n];zr.assertNonNullable(e);let r=zr.getHighestQuality(Object.keys(e));zr.assertNonNullable(r);let i=e[r];zr.assertNonNullable(i),a=i,o=`video/mp4`,s=Wr();break}case`HLS`:case`HLS_FMP4`:case`HLS_ONDEMAND`:{let e=t[n];zr.assertNonNullable(e),a=e.url,o=`application/x-mpegurl`,s=Wr();break}case`DASH_SEP`:case`DASH_ONDEMAND`:case`DASH_WEBM`:case`DASH_WEBM_AV1`:case`DASH_STREAMS`:{let e=t[n];zr.assertNonNullable(e),a=e.url,o=`application/dash+xml`,s=Wr();break}case`DASH_LIVE_CMAF`:{let e=t[n];zr.assertNonNullable(e),a=e.url,o=`application/dash+xml`,s=Gr();break}case`HLS_LIVE`:case`HLS_LIVE_CMAF`:{let e=t[n];zr.assertNonNullable(e),a=Vr(e.url),o=`application/x-mpegurl`,s=Gr();break}case`DASH_LIVE`:case`WEB_RTC_LIVE`:{let e=`Unsupported format for Chromecast`,t=Error(e);throw i.error$.next({id:`ChromecastProvider.createMediaInfo()`,category:zr.ErrorCategory.VIDEO_PIPELINE,message:e,thrown:t}),t}case`DASH`:case`DASH_LIVE_WEBM`:throw Error(`${n} is no longer supported`);default:return zr.assertNever(n)}let c=Kr(r.videoId??a,o);c.contentUrl=a,c.streamType=s,c.metadata=qr();let{title:l,subtitle:u}=r;return zr.isNonNullable(l)&&(c.metadata.title=l),zr.isNonNullable(u)&&(c.metadata.subtitle=u),c};function Wr(){var e;return((e=chrome.cast)==null||(e=e.media)==null||(e=e.StreamType)==null?void 0:e.BUFFERED)??`BUFFERED`}function Gr(){var e;return((e=chrome.cast)==null||(e=e.media)==null||(e=e.StreamType)==null?void 0:e.LIVE)??`LIVE`}function Kr(e,t){var n;return!((n=chrome.cast)==null||(n=n.media)==null)&&n.MediaInfo?new chrome.cast.media.MediaInfo(e,t):{contentId:e,contentType:t,metadata:{title:``,subtitle:``},streamType:Wr()}}function qr(){var e;return!((e=chrome.cast)==null||(e=e.media)==null)&&e.GenericMediaMetadata?new chrome.cast.media.GenericMediaMetadata:{images:[],metadataType:0,releaseDate:``,subtitle:``,title:``,releaseYear:1970,type:0}}var N=(e,t,n=!1)=>{let r=e.getTransition();(n||!r||r.to===t)&&e.setState(t)};class Jr{constructor(e){i(this,`params`,void 0),i(this,`interval`,0),i(this,`startVideoPosition`,void 0),i(this,`startTs`,void 0),this.params=e}start(e=0){clearInterval(this.interval),this.startVideoPosition=e,this.startTs=Date.now(),this.interval=window.setInterval(()=>{let e=(Date.now()-this.startTs)/1e3,t=this.startVideoPosition+e;this.params.output.position$.next(t)},1e3)}pause(){clearInterval(this.interval)}destroy(){clearInterval(this.interval)}}var Yr=require(`@vkontakte/videoplayer-shared/es2015`),Xr=require(`@vkontakte/videoplayer-shared/es2015`),Zr=y(pt(),1),Qr=require(`@vkontakte/videoplayer-shared/es2015`);class $r{constructor(){i(this,`_current`,void 0),i(this,`_current_version`,void 0),i(this,`_chromeVersion`,void 0),i(this,`_firefoxVersion`,void 0),i(this,`_safariVersion`,void 0),i(this,`_operaVersion`,void 0),i(this,`_edgeVersion`,void 0),i(this,`_yandexVersion`,void 0),i(this,`_isMiuiBrowser`,!1)}get current(){return this._current}get isChrome(){return this.current===`Chrome`}get isChromiumBased(){return Zr.default([`Chrome`,`Chromium`,`Opera`,`Yandex`,`Edge`,`SamsungBrowser`],this.current)}get isFirefox(){return this.current===`Firefox`}get isSafari(){return this.current===`Safari`}get isOpera(){return this.current===`Opera`}get isEdge(){return this.current===`Edge`}get isYandex(){return this.current===`Yandex`}get isSamsungBrowser(){return this.current===`SamsungBrowser`}get currentVersion(){return this._current_version}get chromeVersion(){return this._chromeVersion}get firefoxVersion(){return this._firefoxVersion}get safariVersion(){return this._safariVersion}get operaVersion(){return this._operaVersion}get edgeVersion(){return this._edgeVersion}get yandexVersion(){return this._yandexVersion}get isMiuiBrowser(){return this._isMiuiBrowser}detect(){let{userAgent:e}=navigator;try{let t=/yabrowser/i.test(e)?`Yandex`:void 0,n=/samsungbrowser/i.test(e)?`SamsungBrowser`:void 0,r=/chrome|crios/i.test(e)?`Chrome`:void 0,i=/chromium/i.test(e)?`Chromium`:void 0,a=/firefox|fxios/i.test(e)?`Firefox`:void 0,o=/webkit|safari|khtml/i.test(e)?`Safari`:void 0,s=/opr\//i.test(e)?`Opera`:void 0,c=/edg/i.test(e)?`Edge`:void 0;this._isMiuiBrowser=/(XiaoMi)|(MiuiBrowser)/i.test(e),this._current=t||n||a||s||c||r||i||o||`Rest`}catch(e){console.error(e)}this.isChrome&&this.detectChromeVersion(),this.isFirefox&&this.detectFirefoxVersion(),this.isSafari&&this.detectSafariVersion(),this.isOpera&&this.detectOperaVersion(),this.isEdge&&this.detectEdgeVersion(),this.isYandex&&this.detectYandexVersion()}detectVersion(e){try{let{userAgent:t}=Qr.getWindow().navigator,n=t.match(e);if(!n)return;let r=n[1],i=parseInt(r,10);if(!isNaN(i))return this._current_version=i,i}catch(e){console.error(e)}}detectChromeVersion(){this._chromeVersion=this.detectVersion(/Chrome\/(\d+\.\d+)/)}detectFirefoxVersion(){this._firefoxVersion=this.detectVersion(/Firefox\/(\d+\.\d+)/)}detectSafariVersion(){this._safariVersion=this.detectVersion(/Version\/(\d+)/)}detectOperaVersion(){this._operaVersion=this.detectVersion(/OPR\/(\d+\.\d+)/)}detectEdgeVersion(){this._edgeVersion=this.detectVersion(/Edg\/(\d+\.\d+)/)}detectYandexVersion(){this._yandexVersion=this.detectVersion(/YaBrowser\/(\d+\.\d+\.\d+)/)}}var ei=y(pt(),1),ti=require(`@vkontakte/videoplayer-shared/es2015`),ni=()=>{var e;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(navigator.appVersion??navigator.userAgent)||((e=navigator)==null||(e=e.userAgentData)==null?void 0:e.mobile)};class ri{constructor(e){i(this,`_displayChecker`,void 0),i(this,`_isMobile`,void 0),i(this,`_current`,void 0),i(this,`_iosVersion`,void 0),i(this,`_highEntropyValues`,{}),i(this,`_os`,{name:`Unknown`,version:`Unknown`,full:`Unknown`}),i(this,`_details`,{vendor:`Unknown`,model:`Unknown`}),this._displayChecker=e}get current(){return this._current}get os(){return this._os}get details(){return this._details}get isIOS(){return this._highEntropyValues.platform===`iOS`||this.os.name.toLowerCase().includes(`ios`)||ei.default([`iPhone`,`iPad`,`iPod`],this.current)}get isMac(){return this._highEntropyValues.platform===`macOS`||this.os.name.toLowerCase().includes(`mac`)||this.current===`Mac`}get isApple(){return this.isIOS||this.isMac}get isIphoneOrOldIpad(){if(!this.isApple||!this._displayChecker.isTouch)return!1;let e=this.current===`iPad`||this._displayChecker.width>700,t=this._iosVersion;return!e||e&&!!t&&t<16}get isAndroid(){return this._highEntropyValues.platform===`Android`||this.os.name.toLowerCase().includes(`android`)||this.current===`Android`}get isWindows(){return this.os.name.toLowerCase().includes(`windows`)}get isLinux(){return this.os.name.toLowerCase().includes(`linux`)&&!this.isAndroid}get isMobile(){return this._highEntropyValues.mobile||this._isMobile}get iOSVersion(){return this._iosVersion}detect(){let e=ti.getWindow();if(!ti.isBrowserWindow(e))return;let{userAgent:t}=e.navigator;try{this._isMobile=ni()}catch(e){console.error(`DeviceChecker: calling isMobile error - `,e)}this.detectDevice(t),this.detectOS(t),this.detectDeviceDetails(t),this.detectHighEntropyValues(),this.isIOS&&this.detectIOSVersion()}detectHighEntropyValues(){var e=this;return a(function*(){let t=ti.getWindow();if(!ti.isBrowserWindow(t))return;let{userAgentData:n}=t.navigator;if(n?.getHighEntropyValues){let t=yield n.getHighEntropyValues([`architecture`,`bitness`,`brands`,`mobile`,`platform`,`formFactor`,`model`,`platformVersion`,`wow64`]);e._highEntropyValues=t,t.platform&&(e._os.name=e.normalizeOSName(t.platform),t.platformVersion&&(e._os.version=e.normalizeOSVersion(t.platformVersion),e._os.full=`${e._os.name} ${e._os.version}`)),t.model&&(e._details.model=t.model)}})()}detectDevice(e){try{let t=/android/i.test(e)?`Android`:void 0,n=/iphone/i.test(e)?`iPhone`:void 0,r=/ipad/i.test(e)?`iPad`:void 0,i=/ipod/i.test(e)?`iPod`:void 0,a=/mac/i.test(e)?`Mac`:void 0,o=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(e)?`RestMobile`:void 0;this._current=t||n||r||i||o||a||`Desktop`}catch(e){console.error(`DeviceChecker: device detection error - `,e)}}detectOS(e){try{for(let[t,n]of[[/(windows nt) (6\.[23]); arm/i,[`Windows RT`]],[/(windows nt) (6\.3); arm/i,[`Windows RT 8.1`]],[/(windows (?:phone|mobile|iot))(?: os)?[/ ]?([\d.]+)/i,[`Windows Mobile`,2]],[/(windows)[/ ](xp|vista|7|8(\.1)?|10|11|2000|me)/i,[1,1]],[/windows nt ?([\d.]+)/i,[`Windows`,1]],[/(windows)[/ ](95|98|me|2000|xp|vista|7|8|8\.1|10|11)/i,[1,2]],[/(iphone os|cpu iphone os) ([\d_.]+)/i,[`iOS`,2]],[/(ipad os|cpu os) ([\d_.]+)/i,[`iPadOS`,2]],[/(ipod os|cpu ipod os) ([\d_.]+)/i,[`iOS`,2]],[/(?:ios|os) ([\d_.]+) like mac os x/i,[`iOS`,1]],[/cfnetwork\/.+darwin/i,[`iOS`]],[/(mac os x) ?([\d_.]+)/i,[`macOS`,2]],[/(macintosh|mac os)/i,[`macOS`]],[/(android) ([\d.]+)/i,[1,2]],[/(harmonyos)[/ ]?([\d.]*)/i,[`HarmonyOS`,2]],[/\b(ubuntu|debian|fedora|centos|arch|linux)(?:[-/ ]([\w.]+))?/i,[1,2]],[/(cros)\D*([\d.]+)/i,[`Chrome OS`,2]],[/(freebsd|openbsd|netbsd|dragonfly)[/ ]?([\w.]*)/i,[1,2]],[/(sunos|solaris)?([\d.]*)/i,[`Solaris`,2]],[/(aix)?([\d.]*)/i,[`AIX`,2]]]){let r=e.match(t);if(r){let t=n.length>0,i=n.length>1,a=`Unknown`,o=`Unknown`;if(t){let e=n[0];typeof e==`number`?e<r.length&&r[e]!==void 0&&(a=r[e]):a=e}if(i){let e=n[1];typeof e==`number`?e<r.length&&r[e]!==void 0&&(o=r[e]):e!==void 0&&(o=e)}else r[2]===void 0?r[1]!==void 0&&t&&typeof n[0]==`string`&&(o=r[1]):o=r[2];a=this.normalizeOSName(a),o=this.normalizeOSVersion(o,a),a===`iOS`&&/ipad/i.test(e)?a=`iPadOS`:a===`iPadOS`&&/ip(hone|od)/i.test(e)&&(a=`iOS`),this._os={name:a,version:o||`Unknown`,full:o&&o!==`Unknown`?`${a} ${o}`:a};break}}}catch(e){console.error(`DeviceChecker: OS detection error - `,e)}}normalizeOSName(e){if(!e)return`Unknown`;let t=e.toLowerCase();return t.includes(`windows`)?`Windows`:t.includes(`mac os`)||t.includes(`macintosh`)?`macOS`:t.includes(`iphone`)||t.includes(`ios`)?`iOS`:t.includes(`ipados`)?`iPadOS`:t.includes(`android`)?`Android`:t.includes(`harmonyos`)?`HarmonyOS`:t.includes(`linux`)?`Linux`:t.includes(`cros`)?`Chrome OS`:t.includes(`freebsd`)?`FreeBSD`:t.includes(`openbsd`)?`OpenBSD`:t.includes(`solaris`)||t.includes(`sunos`)?`Solaris`:t.includes(`aix`)?`AIX`:e}normalizeOSVersion(e,t){if(!e)return`Unknown`;if(e!==`Unknown`&&(e=e.replace(/_/g,`.`),t===`Windows`)){let t=parseFloat(e);if(!isNaN(t)){if(t>=11)return`11`;if(t>=10)return`10`;if(t===6.3)return`8.1`;if(t===6.2)return`8`;if(t===6.1)return`7`;if(t===6)return`Vista`;if(t===5.1||t===5.2)return`XP`;if(t===5)return`2000`;if(t===4)return`NT 4.0`}}return e}detectDeviceDetails(e){try{for(let[t,n]of[[/(iphone)/i,[`Apple`,`iPhone`]],[/(ipad)/i,[`Apple`,`iPad`]],[/(ipod)/i,[`Apple`,`iPod`]],[/(macintosh)/i,[`Apple`,`Macintosh`]],[/(windows[\w\-_ ]*phone)/i,[`Microsoft`,0]],[/(windows nt|win64|win32|wow64)/i,[`Microsoft`,`PC`]],[/\b(sch-i[89]0\d|shw-m380s|sm-[ptxs]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i,[`Samsung`,1]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?\d+a?|galaxy nexus)/i,[`Samsung`,1]],[/samsung[- ]((?!sm-[lr]|browser)[-\w]+)/i,[`Samsung`,1]],[/sec-(sgh\w+)/i,[`Samsung`,1]],[/smart-tv.+(samsung)/i,[`Samsung`,`Smart TV`]],[/(samsung).*tizen/i,[`Samsung`,`Smart TV`]],[/(pixel (?:c|tablet|[0-9a-z ]+))/i,[`Google`,1]],[/(pixelbook(?: go)?)/i,[`Google`,1]],[/nexus [0-9]/i,[`Google`,0]],[/(redmi[-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(mi[\w\-_ ]+)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(poco[\w ]+)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(hm[-_ ]?note?[\w ]*)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(?:xiao)?mi[\w\-_ ]+pad/i,[`Xiaomi`,0]],[/(?:huawei|honor) ?([-\w ]+)[;)]/i,[`Huawei`,1]],[/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][\dc][adnt]?)\b(?!.+d\/s)/i,[`Huawei`,1]],[/\b((?:ag[rs][2356]?k?|bah[234]?|bg[2o]|bt[kv]|cmr|cpn|db[ry]2?|jdn2|got|kob2?k?|mon|pce|scm|sht?|[tw]gr|vrd)-[ad]?[lw][0125][09]b?)/i,[`Huawei`,1]],[/(?:one)?(?:plus)? ?([a\d0]\d\d\d?)(?: b|\))/i,[`OnePlus`,1]],[/droid.+; (cph2[3-6]\d[13579]|((?:gm|hd)19|(?:ac|be|in|kb)20|(?:d[en]|eb|le|mt)21|ne22)[0-2]\d)(?: bui|\))/i,[`OnePlus`,1]],[/(oneplus)[-_ ]?([-\w]*)/i,[`OnePlus`,2]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i,[`Realme`,1]],[/(realme)[-_ ]?([-\w]*)/i,[`Realme`,2]],[/; (\w+) bui.+ oppo/i,[`OPPO`,1]],[/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i,[`OPPO`,1]],[/\b(opd2(\d{3}a?))(?: bui|\))/i,[`OPPO`,1]],[/(oppo)[-_ ]?([-\w]*)/i,[`OPPO`,2]],[/; vivo (\w+)(?: bui|\))/i,[`Vivo`,1]],[/\b(v[12]\d{3}\w?[at])(?: bui|;)/i,[`Vivo`,1]],[/(vivo)[-_ ]?([-\w]*)/i,[`Vivo`,2]],[/\bmot(?:orola)?[- ]([\w\s]+)(\)| bui)/i,[`Motorola`,1]],[/((?:moto(?! 360)[-\w() ]+|xt\d{3,4}[cgkosw+]?[-\d]*|nexus 6)(?= bui|\)))/i,[`Motorola`,1]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b/i,[`Motorola`,0]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i,[`Motorola`,0]],[/droid.+; ([a-z]?\d[0-2]{2}[a-z]{2}|[c-g]\d{4}|so[-gl]\w+|xq-[a-z]{2}\d\d)(?= bui|\))/i,[`Sony`,1]],[/sony tablet [ps]/i,[`Sony`,`Xperia Tablet`]],[/\b(?:sony)?sgp\w+(?: bui|\))/i,[`Sony`,0]],[/(sony)[-_ ]?([-\w]*)/i,[`Sony`,2]],[/\blg[-e;/ ]+(?!.*(?:browser|netcast|android tv|watch|webos))(\w+)/i,[`LG`,1]],[/\blg-?([\d\w]+) bui/i,[`LG`,1]],[/(lm(?:-?f100[nv]?|-[\w.]+)(?= bui|\))|nexus [45])/i,[`LG`,1]],[/((?=lg)?[vl]k-?\d{3}) bui/i,[`LG`,0]],[/(lg)[-_ ]?([-\w]*)/i,[`LG`,2]],[/(?:maemo|nokia).*(n900|lumia \d+|rm-\d+)/i,[`Nokia`,1]],[/nokia[-_ ]?(([-\w. ]*?))(?: bui|\)|;|\/)/i,[`Nokia`,1]],[/(nokia) (t[12][01])/i,[`Nokia`,2]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i,[`ASUS`,1]],[/(?:asus[-_ ])?(zenfone[\w\-_ ]*)/i,[`ASUS`,1]],[/(rog[\w\-_ ]*)/i,[`ASUS`,1]],[/(asus)[-_ ]?([-\w]*)/i,[`ASUS`,2]],[/lenovo[-_ ]?([-\w ]+?)(?: bui|\)|\/)/i,[`Lenovo`,1]],[/(ideatab[-\w ]+|602lv|d-42a|a101lv|a2109a|a3500-hv|s[56]000|pb-6505[my]|tb-?x?\d{3,4}(?:f[cu]|xu|[av])|yt\d?-[jx]?\d+[lfmx])(?: bui|;|\)|\/)/i,[`Lenovo`,1]],[/(thinkpad[\w\-_ ]*)/i,[`Lenovo`,0]],[/(kf[a-z]{2}[a-z]*)(?: bui|\))/i,[`Amazon`,1]],[/(alexa)webm/i,[`Amazon`,`Echo`]],[/(fire[\w\-_ ]*)/i,[`Amazon`,0]],[/(amazon)[-_ ]?([-\w]*)/i,[`Amazon`,2]],[/(?:blackberry|\(bb10;) (\w+)/i,[`BlackBerry`,1]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,[`BlackBerry`,1]],[/(playbook);[-\w),; ]+(rim)/i,[`BlackBerry`,1]],[/(microsoft); (lumia[\w ]+)/i,[`Microsoft`,2]],[/(surface duo)/i,[`Microsoft`,`Surface Duo`]],[/(surface[\w\-_ ]*)/i,[`Microsoft`,0]],[/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,[`ZTE`,2]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,[`HTC`,2]],[/(alcatel|tcl)[-_ ]?([-\w]*)/i,[1,2]],[/(meizu)[-_ ]?([-\w]*)/i,[`Meizu`,2]],[/(tecno)[-_ ]?([-\w]*)/i,[`Tecno`,2]],[/(infinix)[-_ ]?([-\w]*)/i,[`Infinix`,2]],[/(micromax)[-_ ]?([-\w]*)/i,[`Micromax`,2]],[/(lava)[-_ ]?([-\w]*)/i,[`Lava`,2]],[/(panasonic)[-_ ]?([-\w]*)/i,[`Panasonic`,2]],[/(sharp)\/?([-\w]*)/i,[`Sharp`,2]],[/(benq)[-_ ]?([-\w]*)/i,[`BenQ`,2]],[/(palm)[-_ ]?([-\w]*)/i,[`Palm`,2]],[/(vertu)[-_ ]?([-\w]*)/i,[`Vertu`,2]],[/(gionee)[-_ ]?([-\w]*)/i,[`Gionee`,2]],[/(doogee)[-_ ]?([-\w]*)/i,[`Doogee`,2]],[/(ulefone)[-_ ]?([-\w]*)/i,[`Ulefone`,2]],[/(blackview)[-_ ]?([-\w]*)/i,[`Blackview`,2]],[/(cubot)[-_ ]?([-\w]*)/i,[`Cubot`,2]],[/(umidigi)[-_ ]?([-\w]*)/i,[`UMIDIGI`,2]],[/(oukitel)[-_ ]?([-\w]*)/i,[`Oukitel`,2]],[/(fairphone)[-_ ]?([-\w]*)/i,[`Fairphone`,2]],[/(cat)[-_ ]?([-\w]*)/i,[`Cat`,2]],[/(energy)[-_ ]?([-\w]*)/i,[`Energizer`,2]],[/(land rover)[-_ ]?([-\w]*)/i,[`Land Rover`,2]],[/(shield[\w\-_ ]*)/i,[`Nvidia`,0]],[/(crkey)/i,[`Google`,`Chromecast`]],[/(roku)[\dx]*/i,[`Roku`,0]],[/(apple)[-_ ]?tv/i,[`Apple`,`TV`]],[/(amazon)[-_ ]?tv/i,[`Amazon`,`Fire TV`]],[/(google)[-_ ]?tv/i,[`Google`,`TV`]],[/(smart[\w\-_ ]*tv)/i,[0,`Smart TV`]],[/(playstation[\w\-_ ]*)/i,[`Sony`,0]],[/(nintendo[\w\-_ ]*)/i,[`Nintendo`,0]],[/(xbox[\w\-_ ]*)/i,[`Microsoft`,0]],[/(googlebot)/i,[`Google`,`Bot`]],[/(bingbot)/i,[`Microsoft`,`Bing Bot`]],[/(yandexbot)/i,[`Yandex`,`Bot`]],[/(slackbot)/i,[`Slack`,`Bot`]],[/(twitterbot)/i,[`Twitter`,`Bot`]],[/(facebookbot)/i,[`Facebook`,`Bot`]],[/(linkedinbot)/i,[`LinkedIn`,`Bot`]],[/(tesla)[-_ ]?([-\w]*)/i,[`Tesla`,2]],[/(raspberry[\w\-_ ]*)/i,[`Raspberry Pi`,0]]]){let r=e.match(t);if(r){let e=n[0],t=n[1],i=typeof e==`number`?r[e]===void 0?`Unknown`:this.normalizeVendorName(r[e]):this.normalizeVendorName(e),a=`Unknown`;typeof t==`number`?a=r[t]===void 0?`Unknown`:r[t]:t===void 0?r[1]===void 0?r[0]!==void 0&&(a=r[0]):a=r[1]:a=t,a=this.normalizeModelName(a,i),this.details.vendor=i,this.details.model=a;break}}}catch(e){console.error(`DeviceChecker: device details detection error - `,e)}}normalizeVendorName(e){return e?{apple:`Apple`,samsung:`Samsung`,google:`Google`,xiaomi:`Xiaomi`,huawei:`Huawei`,oneplus:`OnePlus`,oppo:`OPPO`,vivo:`Vivo`,realme:`Realme`,motorola:`Motorola`,sony:`Sony`,lg:`LG`,nokia:`Nokia`,asus:`ASUS`,lenovo:`Lenovo`,amazon:`Amazon`,blackberry:`BlackBerry`,microsoft:`Microsoft`,zte:`ZTE`,htc:`HTC`,alcatel:`Alcatel`,tcl:`TCL`,meizu:`Meizu`,tecno:`Tecno`,infinix:`Infinix`,micromax:`Micromax`,lava:`Lava`,panasonic:`Panasonic`,sharp:`Sharp`,benq:`BenQ`,palm:`Palm`,honor:`Honor`,nvidia:`NVIDIA`,roku:`Roku`}[e.toLowerCase()]||e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():`Unknown`}normalizeModelName(e,t){if(!e||e===`Unknown`)return e;if(e===`0`)return`Unknown`;let n=e.replace(/^build\//i,``).replace(/\s+bui$/i,``).replace(/\)$/,``).replace(/[;,)]/g,``).replace(/\s*\(.*?\)\s*/g,``).trim(),r=t.toLowerCase();return r.includes(`samsung`)?n=n.replace(/^(sm-|gt-|sgh-|sch-)/i,``):r.includes(`xiaomi`)?n=n.replace(/^(mi[\s\-_]*|redmi[\s\-_]*)/i,``):r.includes(`oneplus`)?n=n.replace(/^oneplus[\s\-_]*/i,``):r.includes(`google`)&&(n=n.replace(/^(pixel[\s\-_]*|nexus[\s\-_]*)/i,``)),n=n.replace(/_/g,` `).replace(/-/g,` `).replace(/\s+/g,` `).trim(),n?(n.length>0&&/^[a-z]/.test(n)&&(n=n.charAt(0).toUpperCase()+n.slice(1)),n):`Unknown`}detectIOSVersion(){try{let e=ti.getWindow();if(!ti.isBrowserWindow(e))return;if(this._highEntropyValues.platformVersion){let e=this._highEntropyValues.platformVersion.split(`.`).slice(0,2).join(`.`);this._iosVersion=parseFloat(e);return}if(this._os.version!==`Unknown`){let e=this._os.version.split(`.`),t=e.length>=2?`${e[0]}.${e[1]}`:e[0];this._iosVersion=parseFloat(t);return}let t=e.navigator.userAgent.match(/OS (\d+(_\d+)?)/i);t?.[1]&&(this._iosVersion=parseFloat(t[1].replace(/_/g,`.`)))}catch(e){console.error(`DeviceChecker: iOS version detection error - `,e)}}}var ii=require(`@vkontakte/videoplayer-shared/es2015`);class ai{constructor(){i(this,`_maxTouchPoints`,void 0),i(this,`_height`,void 0),i(this,`_width`,void 0),i(this,`_isHdr`,void 0),i(this,`_pixelRatio`,void 0),i(this,`_screenHeight`,void 0),i(this,`_screenWidth`,void 0),i(this,`_colorDepth`,void 0)}get isTouch(){return typeof this._maxTouchPoints==`number`?this._maxTouchPoints>1:`ontouchstart`in ii.getWindow()}get maxTouchPoints(){return this._maxTouchPoints}get height(){return this._height}get width(){return this._width}get screenHeight(){return this._screenHeight}get screenWidth(){return this._screenWidth}get pixelRatio(){return this._pixelRatio}get isHDR(){return this._isHdr}get colorDepth(){return this._colorDepth}detect(){let e=ii.getWindow();if(!ii.isBrowserWindow(e))return;let{navigator:t,screen:n}=e,{maxTouchPoints:r}=t;try{this._maxTouchPoints=r??0,this._isHdr=!!e.matchMedia(`(dynamic-range: high)`)?.matches,this._colorDepth=n.colorDepth}catch(e){console.error(e)}try{this._pixelRatio=e.devicePixelRatio||1,this._height=n.height,this._width=n.width,this._height=n.height,this._screenHeight=this._height*this._pixelRatio,this._screenWidth=this._width*this._pixelRatio}catch(e){console.error(e)}}}var oi=require(`@vkontakte/videoplayer-shared/es2015`),si=()=>window.ManagedMediaSource||window.MediaSource,ci=()=>{var e;return!!(window.ManagedMediaSource&&!((e=window.ManagedSourceBuffer)==null||(e=e.prototype)==null)&&e.appendBuffer)},li=()=>{var e;return!!(window.MediaSource&&!((e=window.SourceBuffer)==null||(e=e.prototype)==null)&&e.appendBuffer)},ui=()=>window.ManagedMediaSource?new ManagedMediaSource:new MediaSource,di=oi.getWindow().document?.createElement(`video`),fi=`video/mp4; codecs="avc1.42000a,mp4a.40.2"`,pi=`video/mp4; codecs="hev1.1.6.L93.B0"`,mi=`video/webm; codecs="vp09.00.10.08"`,hi=`video/webm; codecs="av01.0.00M.08"`,gi=`audio/mp4; codecs="mp4a.40.2"`,_i=`audio/webm; codecs="opus"`,vi;(function(){var e=a(function*(){let e=oi.getWindow();if(!oi.isBrowserWindow(e)||!(`mediaCapabilities`in e.navigator))return;let t={type:`media-source`,video:{contentType:`video/webm`,width:1280,height:720,bitrate:1e6,framerate:30}},[n,r]=yield Promise.all([e.navigator.mediaCapabilities.decodingInfo(o(o({},t),{},{video:o(o({},t.video),{},{contentType:hi})})),e.navigator.mediaCapabilities.decodingInfo(o(o({},t),{},{video:o(o({},t.video),{},{contentType:mi})}))]);vi={DASH_WEBM_AV1:n,DASH_WEBM:r}});return function(){return e.apply(this,arguments)}})()().catch(e=>{console.log(di),console.error(e)});class yi{constructor(e,t){i(this,`_video`,void 0),i(this,`_deviceChecker`,void 0),i(this,`_browserChecker`,void 0),i(this,`_protocols`,void 0),i(this,`_containers`,void 0),i(this,`_codecs`,void 0),i(this,`_nativeHlsSupported`,void 0),this._deviceChecker=e,this._browserChecker=t}get protocols(){return this._protocols}get containers(){return this._containers}get codecs(){return this._codecs}get webmDecodingInfo(){return vi}get supportedCodecs(){return Object.keys(this._codecs).filter(e=>this._codecs[e])}get nativeHlsSupported(){return this._nativeHlsSupported}detect(){let e=oi.getWindow();if(oi.isBrowserWindow(e)){this._video=e.document.createElement(`video`);try{var t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g;this._protocols={mms:ci(),mse:li(),hls:!!((t=this._video).canPlayType?.call(t,`application/x-mpegurl`)||(n=this._video).canPlayType?.call(n,`vnd.apple.mpegURL`)),webrtc:!!e.RTCPeerConnection,ws:!!e.WebSocket},this._containers={mp4:!!(r=this._video).canPlayType?.call(r,`video/mp4`),webm:!!(i=this._video).canPlayType?.call(i,`video/webm`),cmaf:!0};let _=!!(!((a=si())==null||(o=a.isTypeSupported)==null)&&o.call(a,fi)),v=!!(!((s=si())==null||(c=s.isTypeSupported)==null)&&c.call(s,pi)),y=!!(!((l=si())==null||(u=l.isTypeSupported)==null)&&u.call(l,gi));this._codecs={h264:_,h265:v,vp9:!!(!((d=si())==null||(f=d.isTypeSupported)==null)&&f.call(d,mi)),av1:!!(!((p=si())==null||(m=p.isTypeSupported)==null)&&m.call(p,hi)),aac:y,opus:!!(!((h=si())==null||(g=h.isTypeSupported)==null)&&g.call(h,_i)),mpeg:(_||v)&&y},this._nativeHlsSupported=this._protocols.hls&&this._containers.mp4}catch(e){console.error(e)}try{this.destroyVideoElement()}catch(e){console.error(`Error destroying video element:`,e)}}}destroyVideoElement(){if(!this._video)return;if(this._video.pause(),this._video.currentTime=0,this._video.removeAttribute(`src`),this._video.src=``,this._video.load(),this._video.remove){this._video.remove(),this._video=null;return}this._video.parentNode&&this._video.parentNode.removeChild(this._video);let e=this._video.cloneNode(!1);this._video.parentNode?.replaceChild(e,this._video),this._video=null}}var bi=require(`@vkontakte/videoplayer-shared/es2015`),xi=`audio/mpeg`;class Si{constructor(){i(this,`_audio`,void 0),i(this,`_containers`,void 0),i(this,`_codecs`,void 0)}supportMp3(){return this._codecs.mp3&&this._containers.mpeg}detect(){let e=bi.getWindow();if(bi.isBrowserWindow(e)){this._audio=e.document.createElement(`audio`);try{var t,n,r;this._containers={mpeg:!!(t=this._audio).canPlayType?.call(t,xi)},this._codecs={mp3:!!(!((n=si())==null||(r=n.isTypeSupported)==null)&&r.call(n,xi))}}catch(e){console.error(e)}try{this.destroyAudioElement()}catch(e){console.error(`Error destroying audio element:`,e)}}}destroyAudioElement(){if(!this._audio)return;if(this._audio.pause(),this._audio.currentTime=0,this._audio.removeAttribute(`src`),this._audio.src=``,this._audio.load(),this._audio.remove){this._audio.remove(),this._audio=null;return}this._audio.parentNode&&this._audio.parentNode.removeChild(this._audio);let e=this._audio.cloneNode(!1);this._audio.parentNode?.replaceChild(e,this._audio),this._audio=null}}class Ci{constructor(){i(this,`isInited$`,new Xr.ValueSubject(!1)),i(this,`_displayChecker`,void 0),i(this,`_deviceChecker`,void 0),i(this,`_browserChecker`,void 0),i(this,`_videoChecker`,void 0),i(this,`_audioChecker`,void 0),this._displayChecker=new ai,this._deviceChecker=new ri(this._displayChecker),this._browserChecker=new $r,this._videoChecker=new yi(this._deviceChecker,this._browserChecker),this._audioChecker=new Si,this.detect()}get display(){return this._displayChecker}get device(){return this._deviceChecker}get browser(){return this._browserChecker}get video(){return this._videoChecker}get audio(){return this._audioChecker}detect(){var e=this;return a(function*(){Xr.isBrowserWindow()&&(e._displayChecker.detect(),e._deviceChecker.detect(),e._browserChecker.detect(),e._videoChecker.detect(),e._audioChecker.detect(),e.isInited$.next(!0))})()}}var P=new Ci,wi=e=>{let{containers:t,protocols:n,codecs:r,nativeHlsSupported:i}=P.video,a=(r.h264||r.h265)&&r.aac,o=n.mse||n.mms;return e.filter(e=>{switch(e){case`DASH_SEP`:return o&&t.mp4&&a;case`DASH_WEBM`:return o&&t.webm&&r.vp9&&r.opus;case`DASH_WEBM_AV1`:return o&&t.webm&&r.av1&&r.opus;case`DASH_STREAMS`:return o&&(t.mp4&&a||t.webm&&(r.vp9||r.av1)&&(r.opus||r.aac));case`DASH_LIVE`:return o&&t.mp4&&a;case`DASH_LIVE_CMAF`:return o&&t.mp4&&a&&t.cmaf;case`DASH_ONDEMAND`:return o&&t.mp4&&a;case`HLS`:case`HLS_ONDEMAND`:case`HLS_FMP4`:case`HLS_LIVE`:case`HLS_LIVE_CMAF`:return i;case`MPEG`:return t.mp4;case`DASH`:case`DASH_LIVE_WEBM`:return!1;case`WEB_RTC_LIVE`:return n.webrtc&&n.ws&&r.h264&&(t.mp4||t.webm);default:return Yr.assertNever(e)}})},Ti=e=>{switch(e){case`MPEG`:case`DASH`:case`DASH_SEP`:case`DASH_ONDEMAND`:case`DASH_WEBM`:case`DASH_WEBM_AV1`:case`DASH_STREAMS`:case`HLS`:case`HLS_FMP4`:case`HLS_ONDEMAND`:return!1;case`DASH_LIVE`:case`DASH_LIVE_CMAF`:case`HLS_LIVE`:case`HLS_LIVE_CMAF`:case`DASH_LIVE_WEBM`:case`WEB_RTC_LIVE`:return!0;default:return Yr.assertNever(e)}},Ei=e=>wi(Object.keys(e).filter(e=>!Ti(e))).length>0;class Di{constructor(e){i(this,`subscription`,new M.Subscription),i(this,`log`,void 0),i(this,`params`,void 0),i(this,`sessionId$`,new M.ValueSubject(null)),i(this,`mediaSessionId$`,new M.ValueSubject(null)),i(this,`contentId$`,new M.ValueSubject(null)),i(this,`progressTicker`,void 0),i(this,`isMobile`,ni()),i(this,`mobileVolumeState`,{muted:!1,volume:0}),i(this,`media`,null),i(this,`lastRequestedVolume`,null),i(this,`syncMediaState`,e=>{if(M.isNullable(e))return;this.media=e,this.mediaSessionId$.next(e.mediaSessionId??null);let t=e.media?.contentId;t&&this.contentId$.next(t),this.syncPlaybackState(e);let n=e.media?.duration;M.isNonNullable(n)&&this.params.output.duration$.next(Math.max(0,n));let r=e.currentTime;if(M.isNonNullable(r)){this.params.desiredState.seekState.getState().state===`applying`&&this.params.output.seekedEvent$.next(),this.params.output.position$.next(r);let t=this.params.output.isLive$.getValue();e.playerState===`PLAYING`&&!t?this.progressTicker.start(r):this.progressTicker.pause()}}),this.params=e,this.progressTicker=new Jr(e),this.log=this.params.dependencies.logger.createComponentLog(`ChromecastPresentationApiProvider`),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(Ti(e.format)),this.subscribe()}subscribe(){let e=e=>{this.params.output.error$.next({category:M.ErrorCategory.WTF,id:`ChromecastPresentationApiProvider`,message:e?.message??`Unknown error`,thrown:e})};this.subscription.add(this.params.chromecastConnector.message$.pipe(M.filter(e=>!!e)).subscribe(e=>{this.handleMessage(e)},e)),this.subscription.add(this.sessionId$.pipe(M.filter(M.isNonNullable),M.filterChanged(),M.debounce(0)).subscribe(()=>{this.loadMedia()},e));let t=this.contentId$.pipe(M.filterChanged(),M.map(Boolean));this.subscription.add(M.combine({seekState:this.params.desiredState.seekState.stateChangeEnded$,mediaLoaded:t}).pipe(M.filter(({mediaLoaded:e})=>e)).subscribe(()=>{let e=this.params.desiredState.seekState.getState();e.state===`requested`&&this.seek(e.position/1e3)},e));let n=M.combine({playbackState:this.params.desiredState.playbackState.stateChangeStarted$,mediaLoaded:t});this.subscription.add(n.pipe(M.filter(({mediaLoaded:e})=>e),M.debounce(0)).subscribe(()=>{this.syncPlayback()},e)),this.subscription.add(n.pipe(M.filter(({mediaLoaded:e,playbackState:{from:t,to:n}})=>!e&&t===`stopped`&&n===`playing`)).subscribe(()=>{this.loadMedia()},e)),this.subscription.add(M.combine({volumeState:this.params.desiredState.volume.stateChangeStarted$.pipe(M.debounce(30)),mediaLoaded:t}).pipe(M.filter(({mediaLoaded:e})=>e)).subscribe(({volumeState:e})=>{let{muted:t,volume:n}=e.to;this.setVolume(n,t)},e))}handleMessage(e){switch(e.type){case`new_session`:case`update_session`:{var t;this.sessionId$.next(e.message.sessionId);let n=(t=e.message)==null||(t=t.media)==null?void 0:t[0];this.syncMediaState(n);let r=e.message?.receiver.volume;this.syncVolumeState(r)}break;case`v2_message`:switch(e.message?.type){case`MEDIA_STATUS`:{var n;let t=(n=e.message)==null||(n=n.status)==null?void 0:n[0];this.syncMediaState(t);break}}break}}loadMedia(){let e=Ur(this.params),t=this.media?.currentTime,n=this.params.desiredState.seekState.getState(),r=t??(n.state===`none`?0:n.position/1e3),i=this.params.desiredState.playbackState.getState()===`playing`;this.params.chromecastConnector.sendV2Message({type:`LOAD`,requestId:0,media:e,autoplay:i,currentTime:r,customData:null,activeTrackIds:null}),this.params.output.willSeekEvent$.next()}stop(){this.params.chromecastConnector.stopMedia()}play(){let e=this.mediaSessionId$.getValue();M.assertNonNullable(e,`play on null mediaSessionId`),this.params.chromecastConnector.sendV2Message({type:`PLAY`,mediaSessionId:e,customData:null})}pause(){let e=this.mediaSessionId$.getValue();M.assertNonNullable(e,`pause on null mediaSessionId`),this.params.chromecastConnector.sendV2Message({type:`PAUSE`,mediaSessionId:e,customData:null})}seek(e){let t=this.mediaSessionId$.getValue();M.assertNonNullable(t,`seek on null mediaSessionId`),this.params.chromecastConnector.sendV2Message({type:`SEEK`,currentTime:e,mediaSessionId:t}),this.params.output.willSeekEvent$.next()}setVolume(e,t){let n=e,r=`[setVolume] volume: ${e}, muted: ${t}`;this.isMobile&&(n=this.mobileVolumeState.volume,r+=`, mobile next volume: ${n}`),this.log({message:r}),this.lastRequestedVolume={volume:n,muted:t},this.params.chromecastConnector.sendV2Message({type:`SET_VOLUME`,requestId:0,volume:{level:t?0:n,muted:t?!0:null}})}syncPlaybackState({playerState:e,idleReason:t}){let n=this.params.output.isBuffering$.getValue(),r=e===`BUFFERING`;switch(n!==r&&this.params.output.isBuffering$.next(r),e){case`PAUSED`:N(this.params.desiredState.playbackState,`paused`);break;case`PLAYING`:N(this.params.desiredState.playbackState,`playing`);break;case`IDLE`:t===`FINISHED`?(this.params.output.endedEvent$.next(),N(this.params.desiredState.playbackState,`stopped`),this.contentId$.next(null)):N(this.params.desiredState.playbackState,`ready`);break;case`BUFFERING`:break}}syncPlayback(){let e=this.params.desiredState.playbackState.getState();switch(this.log({message:`[syncPlayback] ${e}`}),e){case`ready`:break;case`playing`:this.play();break;case`paused`:this.pause();break;case`stopped`:this.stop();break}}syncVolumeState(e){if(M.isNullable(e))return;let{level:t,muted:n}=e,r={muted:n??!1,volume:t??0};this.lastRequestedVolume&&=(n&&(r.volume=this.lastRequestedVolume.volume),this.lastRequestedVolume.muted&&!t&&!n&&(r.volume=this.lastRequestedVolume.volume,r.muted=!0),null);let i=`[syncVolumeState] volume: ${r.volume}, muted: ${r.muted}`;this.isMobile&&(this.mobileVolumeState.volume=r.volume,this.mobileVolumeState.muted=r.muted,r.volume=this.params.output.volume$.getValue().volume,i+=`, volume passed to state machine: ${r.volume}`),this.log({message:i}),this.params.output.volume$.next(r)}destroy(){this.progressTicker.destroy(),this.subscription.unsubscribe()}}var Oi=require(`@vkontakte/videoplayer-shared/es2015`),ki=e=>({castDevice:{friendlyName:e},remotePlayer:{},remotePlayerController:{},session:{}}),Ai=()=>String(Date.now())+String(Math.floor(Math.random()*1e5));class ji{constructor(e){i(this,`params`,void 0),i(this,`clientId`,void 0),i(this,`capabilities`,[`WEB`]),i(this,`presentationRequest$`,new Oi.ValueSubject(null)),i(this,`log`,void 0),i(this,`sessionId$`,new Oi.ValueSubject(null)),i(this,`broadcastChannel`,new BroadcastChannel(`vk_player_chromecast_events`)),i(this,`subscription`,new Oi.Subscription),i(this,`subscriptionEvents`,new Oi.Subscription),i(this,`isDestroyed`,!1),i(this,`sequenceNumber`,0),i(this,`presentationAvailable$`,new Oi.ValueSubject(!1)),i(this,`presentationConnection$`,new Oi.ValueSubject(null)),i(this,`message$`,new Oi.ValueSubject(null)),i(this,`friendlyName$`,new Oi.ValueSubject(null)),i(this,`errorEvent$`,new Oi.Subject),this.clientId=this.getClientId(),this.params=e,this.log=e.logger.createComponentLog(`ChromecastPresentationApiConnector`),this.log({message:`constructor`}),this.safeReinitPresentation(),this.subscribe()}destroy(){this.log({message:`destroy`}),this.subscription.unsubscribe(),this.subscriptionEvents.unsubscribe(),this.broadcastChannel.close(),this.isDestroyed=!0}disconnect(e=!0){this.log({message:`disconnect`}),e&&this.stopMedia(),this.presentationRequest$.next(null);let t=this.presentationConnection$.getValue();t&&t.close(),this.presentationConnection$.next(null),this.friendlyName$.next(null),this.resetSequenceNumber(),this.resetSubscriptionEvents()}stopMedia(){this.log({message:`stopMedia`}),this.sendV2Message({type:`STOP`})}reinitPresentation(e=!0){let t=this.createCastUrl(),n=new PresentationRequest(t);this.presentationRequest$.next(n),this.log({message:`PresentationRequest created`}),n.getAvailability().then(e=>{let t=()=>{this.log({message:`PresentationRequest presentation availability: ${e.value}`}),this.presentationAvailable$.next(e.value)};this.subscriptionEvents.add(Oi.fromEvent(e,`change`).subscribe(()=>{t()})),t()}).catch(()=>{this.presentationAvailable$.next(!0)}),Oi.getWindow().navigator.presentation.defaultRequest=n,e&&n.reconnect(`auto-join`).then(e=>{this.log({message:`PresentationRequest reconnect success`}),this.handleConnection(e)}).catch(()=>{this.log({message:`PresentationRequest reconnect failed`})})}safeReinitPresentation(e){try{this.reinitPresentation(e)}catch(e){this.errorEvent$.next({category:Oi.ErrorCategory.WTF,id:`ChromecastPresentationApiConnector`,message:e?.message??`reinitPresentation error`,thrown:e})}}connect(){var e=this;return a(function*(){e.log({message:`connect`});try{e.presentationRequest$.getValue()||(e.log({message:`reinitPresentation`}),e.reinitPresentation(!1));let t=e.presentationRequest$.getValue();Oi.assertNonNullable(t,`connect with null presentationRequest`);let n=yield t.start();e.handleConnection(n)}catch(t){switch(t?.name){case`AbortError`:case`NotAllowedError`:break;default:e.errorEvent$.next({category:Oi.ErrorCategory.WTF,id:`ChromecastPresentationApiConnector`,message:t?.message??`connect error`,thrown:t});break}}})()}subscribe(){this.subscription.add(Oi.fromEvent(this.broadcastChannel,`message`).subscribe(e=>{this.log({message:`broadcast connection data: ${e.data}`}),e.data===`connection`&&this.disconnect(!1)})),this.subscription.add(this.presentationAvailable$.subscribe(e=>{this.log({message:`presentationAvailable$: ${e}`})})),this.subscription.add(this.presentationConnection$.pipe(Oi.tap(e=>{this.log({message:`presentationConnection$: ${!!e}`})}),Oi.filter(e=>!!e)).subscribe(e=>{let t=Oi.fromEvent(e,`message`).subscribe(e=>{let t=JSON.parse(e.data);t.clientId===this.clientId&&(this.log({message:`[onmessage] ${e.data}`}),this.handleMessage(t),this.message$.next(t))}),n=Oi.fromEvent(e,`connect`).subscribe(()=>{this.send(`client_connect`)}),r=Oi.fromEvent(e,`close`).subscribe(e=>{switch(e.reason){case`error`:this.errorEvent$.next({category:Oi.ErrorCategory.WTF,id:`ChromecastPresentationApiConnector`,message:`Session error`,thrown:e});break;case`closed`:break}});this.subscriptionEvents.add(t),this.subscriptionEvents.add(n),this.subscriptionEvents.add(r)}))}send(e){switch(e){case`client_connect`:{let e={type:`client_connect`,message:this.clientId,sequenceNumber:-1,timeoutMillis:0,clientId:this.clientId};this.safeSend(JSON.stringify(e));break}}}sendV2Message(e){let t=this.sessionId$.getValue();if(t){let n={type:`v2_message`,sequenceNumber:this.getSequenceNumber(),timeoutMillis:0,clientId:this.clientId,message:o(o({},e),{},{sessionId:t})};this.safeSend(JSON.stringify(n))}}safeSend(e){try{this.log({message:`[send] ${e}`});let t=this.presentationConnection$.getValue();t?.state===`connected`&&t?.send(e)}catch(t){this.errorEvent$.next({category:Oi.ErrorCategory.WTF,id:`ChromecastPresentationApiConnector`,message:`PresentationConnection send error`,data:{message:e},thrown:t})}}handleMessage(e){switch(e.type){case`new_session`:case`update_session`:this.sessionId$.next(e.message.sessionId),this.friendlyName$.next(e.message.receiver.friendlyName||`Chromecast Device`);break;case`receiver_action`:e.message?.action===`stop`&&this.disconnect();break}}createCastUrl(){return`cast:${this.params.appId}?clientId=${this.clientId}&autoJoinPolicy=tab_and_origin_scoped&defaultActionPolicy=create_session&launchTimeout=60000&supportedAppTypes=${this.capabilities}&appParams=%7B%22launchCheckerParams%22%3A%7B%7D%7D`}getSequenceNumber(){let e=this.sequenceNumber;return this.sequenceNumber=(this.sequenceNumber+1)%(2**53-1),e}resetSequenceNumber(){this.sequenceNumber=0}getClientId(){let e=`__vk_player_chromecast_id`;return Oi.getWindow()[e]=Oi.getWindow()[e]||Ai()}resetSubscriptionEvents(){this.subscriptionEvents.unsubscribe(),this.subscriptionEvents=new Oi.Subscription}handleConnection(e){this.log({message:`connection available`}),this.isDestroyed?(this.log({message:`connected on already destroyed component`}),e.close()):(this.broadcastChannel.postMessage(`connection`),this.presentationConnection$.next(e))}}var Mi=require(`@vkontakte/videoplayer-shared/es2015`);class Ni{static isSupported(){return`chrome`in window&&`presentation`in navigator&&`BroadcastChannel`in window}constructor(e){i(this,`subscription`,new Mi.Subscription),i(this,`log`,void 0),i(this,`contentId`,void 0),i(this,`connection$`,new Mi.ValueSubject(void 0)),i(this,`castState$`,new Mi.ValueSubject(`NOT_AVAILABLE`)),i(this,`errorEvent$`,new Mi.Subject),i(this,`chromecastConnector`,void 0);let t=Ni.isSupported();this.log=e.dependencies.logger.createComponentLog(`ChromecastPresentationApiInitializer`),this.log({message:`[constructor] receiverApplicationId: ${e.receiverApplicationId}, isDisabled: ${e.isDisabled}, isSupported: ${t}`}),!(!t||e.isDisabled||!e.receiverApplicationId)&&(this.chromecastConnector=new ji({appId:e.receiverApplicationId,logger:e.dependencies.logger}),this.subscribe())}subscribe(){Mi.assertNonNullable(this.chromecastConnector,`subscribe with null chromecastConnector`),this.subscription.add(this.chromecastConnector.errorEvent$.subscribe(this.errorEvent$));let e=Mi.combine({connection:this.chromecastConnector.presentationConnection$,available:this.chromecastConnector.presentationAvailable$,friendlyName:this.chromecastConnector.friendlyName$.pipe(Mi.filterChanged())});this.subscription.add(e.pipe(Mi.map(({connection:e,friendlyName:t})=>!!(e&&t)),Mi.filterChanged()).subscribe(e=>{let t=this.chromecastConnector?.friendlyName$.getValue()??``;this.connection$.next(e?ki(t):void 0)})).add(e.subscribe(({available:e,connection:t})=>{e?t?this.castState$.next(`CONNECTED`):this.castState$.next(`AVAILABLE`):this.castState$.next(`NOT_AVAILABLE`)}))}connect(){this.log({message:`connect`}),this.chromecastConnector?.connect()}disconnect(){this.log({message:`disconnect`}),this.chromecastConnector?.disconnect()}stopMedia(){var e=this;return a(function*(){e.log({message:`stopMedia`}),e.chromecastConnector?.stopMedia()})()}toggleConnection(){let e=!!this.chromecastConnector?.presentationConnection$.getValue();this.log({message:`toggleConnection: isConnected - ${e}`}),e?this.disconnect():this.connect()}setVolume(e){}setMuted(e){}destroy(){this.log({message:`destroy`}),this.chromecastConnector?.destroy(),this.subscription.unsubscribe()}}var Pi=y(pt(),1),Fi=(e,...t)=>typeof e==`string`?e.includes(...t):Pi.default(e,...t),Ii=y(_t(),1),Li=y(Xt(),1),Ri=y(Pn(),1),zi=require(`@vkontakte/videoplayer-shared/es2015`);class F{constructor(e){i(this,`state`,void 0),i(this,`prevState`,void 0),i(this,`transition`,void 0),i(this,`transitionStarted$`,new zi.Subject),i(this,`transitionEnded$`,new zi.Subject),i(this,`transitionUpdated$`,new zi.Subject),i(this,`forceChanged$`,new zi.Subject),i(this,`stateChangeStarted$`,zi.merge(this.transitionStarted$,this.transitionUpdated$)),i(this,`stateChangeEnded$`,zi.merge(this.transitionEnded$,this.forceChanged$)),this.state=e,this.prevState=void 0}setState(e){let t=this.transition,n=this.state;this.transition=void 0,this.prevState=n,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:n,to:e,canceledTransition:t})}startTransitionTo(e){let t=this.transition,n=this.state;n===e||zi.isNonNullable(t)&&t.to===e||(this.prevState=n,this.state=e,t?(this.transition={from:t.from,to:e,canceledTransition:t},this.transitionUpdated$.next(this.transition)):(this.transition={from:n,to:e},this.transitionStarted$.next(this.transition)))}getTransition(){return this.transition}getState(){return this.state}getPrevState(){return this.prevState}}var Bi=require(`@vkontakte/videoplayer-shared/es2015`),Vi=5,Hi=5,Ui=500,Wi=7e3;class Gi{constructor(e){i(this,`subscription`,new Bi.Subscription),i(this,`loadMediaTimeoutSubscription`,new Bi.Subscription),i(this,`videoState`,new F(`stopped`)),i(this,`params`,void 0),i(this,`log`,void 0),i(this,`syncPlayback`,()=>{let e=this.videoState.getState(),t=this.videoState.getTransition(),n=this.params.desiredState.playbackState.getState(),r=this.params.desiredState.playbackState.getTransition(),i=this.params.desiredState.seekState.getState();if(this.log({message:`[syncPlayback] videoState: ${e}; videoTransition: ${JSON.stringify(t)}; desiredPlaybackState: ${n}; desiredPlaybackStateTransition: ${this.params.desiredState.playbackState.getTransition()}; seekState: ${JSON.stringify(i)};`}),n===`stopped`){e!==`stopped`&&(this.videoState.startTransitionTo(`stopped`),this.stop());return}if(!t){if(r?.to!==`paused`&&i.state===`requested`&&e!==`stopped`){this.seek(i.position/1e3);return}switch(n){case`ready`:switch(e){case`playing`:case`paused`:case`ready`:break;case`stopped`:this.videoState.startTransitionTo(`ready`),this.prepare();break;default:Bi.assertNever(e)}break;case`playing`:switch(e){case`playing`:break;case`paused`:this.videoState.startTransitionTo(`playing`),this.params.connection.remotePlayerController.playOrPause();break;case`ready`:this.videoState.startTransitionTo(`playing`),this.params.connection.remotePlayerController.playOrPause();break;case`stopped`:this.videoState.startTransitionTo(`ready`),this.prepare();break;default:Bi.assertNever(e)}break;case`paused`:switch(e){case`playing`:this.videoState.startTransitionTo(`paused`),this.params.connection.remotePlayerController.playOrPause();break;case`paused`:break;case`ready`:this.videoState.startTransitionTo(`paused`),this.videoState.setState(`paused`);break;case`stopped`:this.videoState.startTransitionTo(`ready`),this.prepare();break;default:Bi.assertNever(e)}break;default:Bi.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(Ti(e.format)),this.params.output.isAudioAvailable$.next(!0),this.handleRemoteVolumeChange({volume:this.params.connection.remotePlayer.volumeLevel,muted:this.params.connection.remotePlayer.isMuted});let 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);let e=new Bi.Subscription;this.subscription.add(e),this.subscription.add(Bi.merge(this.videoState.stateChangeStarted$.pipe(Bi.map(e=>`stateChangeStarted$ ${JSON.stringify(e)}`)),this.videoState.stateChangeEnded$.pipe(Bi.map(e=>`stateChangeEnded$ ${JSON.stringify(e)}`))).subscribe(e=>this.log({message:`[videoState] ${e}`})));let t=(e,t)=>this.subscription.add(e.subscribe(t));if(this.params.output.isLive$.getValue())this.params.output.position$.next(0),this.params.output.duration$.next(0);else{let t=new Bi.Subject;e.add(t.pipe(Bi.debounce(Ui)).subscribe(()=>{this.params.output.seekedEvent$.next()}));let n=NaN;e.add(Bi.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED).subscribe(e=>{this.logRemoteEvent(e);let r=e.value;this.params.output.position$.next(r),(this.params.desiredState.seekState.getState().state===`applying`||Math.abs(r-n)>Vi)&&t.next(r),n=r})),e.add(Bi.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.DURATION_CHANGED).subscribe(e=>{this.logRemoteEvent(e),this.params.output.duration$.next(e.value)}))}t(Bi.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED),t=>{this.logRemoteEvent(t),t.value?this.handleRemoteReady():(this.handleRemoteStop(),e.unsubscribe())}),t(Bi.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),e=>{this.logRemoteEvent(e),e.value?this.handleRemotePause():this.handleRemotePlay()}),t(Bi.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED),e=>{this.logRemoteEvent(e);let{remotePlayer:t}=this.params.connection,n=e.value,r=this.params.output.isBuffering$.getValue(),i=n===chrome.cast.media.PlayerState.BUFFERING;switch(r!==i&&this.params.output.isBuffering$.next(i),n){case chrome.cast.media.PlayerState.IDLE:!this.params.output.isLive$.getValue()&&t.duration-t.currentTime<Hi&&this.params.output.endedEvent$.next(),this.handleRemoteStop(),N(this.params.desiredState.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:Bi.assertNever(n)}}),t(Bi.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED),e=>{this.logRemoteEvent(e),this.handleRemoteVolumeChange({volume:e.value})}),t(Bi.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),e=>{this.logRemoteEvent(e),this.handleRemoteVolumeChange({muted:e.value})}),t(Bi.merge(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,Bi.observableFrom([`init`])).pipe(Bi.debounce(0)),this.syncPlayback)}restoreSession(e){this.log({message:`restoreSession`});let{remotePlayer:t}=this.params.connection;if(e.playerState!==chrome.cast.media.PlayerState.IDLE){t.isPaused?(this.videoState.setState(`paused`),N(this.params.desiredState.playbackState,`paused`)):(this.videoState.setState(`playing`),N(this.params.desiredState.playbackState,`playing`));let e=this.params.output.isLive$.getValue();this.params.output.duration$.next(e?0:t.duration),this.params.output.position$.next(e?0:t.currentTime),this.params.desiredState.seekState.setState({state:`none`})}}prepare(){let e=this.params.format;this.log({message:`[prepare] format: ${e}`});let t=Ur(this.params),n=this.createLoadRequest(t);this.loadMedia(n)}handleRemotePause(){let e=this.videoState.getState();(this.videoState.getTransition()?.to===`paused`||e===`playing`)&&(this.videoState.setState(`paused`),N(this.params.desiredState.playbackState,`paused`))}handleRemotePlay(){let e=this.videoState.getState();(this.videoState.getTransition()?.to===`playing`||e===`paused`)&&(this.videoState.setState(`playing`),N(this.params.desiredState.playbackState,`playing`))}handleRemoteReady(){this.videoState.getTransition()?.to===`ready`&&this.videoState.setState(`ready`),this.params.desiredState.playbackState.getTransition()?.to===`ready`&&N(this.params.desiredState.playbackState,`ready`)}handleRemoteStop(){this.videoState.getState()!==`stopped`&&this.videoState.setState(`stopped`)}handleRemoteVolumeChange(e){let t=this.params.output.volume$.getValue(),n={volume:e.volume??t.volume,muted:e.muted??t.muted};(n.volume!==t.volume||n.muted!==n.muted)&&this.params.output.volume$.next(n)}seek(e){this.params.output.willSeekEvent$.next();let{remotePlayer:t,remotePlayerController:n}=this.params.connection;t.currentTime=e,n.seek()}stop(){let{remotePlayerController:e}=this.params.connection;e.stop()}createLoadRequest(e){let t=new chrome.cast.media.LoadRequest(e);t.autoplay=!1;let n=this.params.desiredState.seekState.getState();return n.state===`applying`||n.state===`requested`?t.currentTime=this.params.output.isLive$.getValue()?0:n.position/1e3:t.currentTime=0,t}loadMedia(e){let t=this.params.connection.session.loadMedia(e),n=new Promise((e,t)=>{this.loadMediaTimeoutSubscription.add(Bi.timeout(Wi).subscribe(()=>t(`timeout(${Wi})`)))});Ri.default(Promise.race([t,n]).then(()=>{this.log({message:`[loadMedia] completed, format: ${this.params.format}`}),this.params.desiredState.seekState.getState().state===`applying`&&this.params.output.seekedEvent$.next(),this.handleRemoteReady()},e=>{let t=`[prepare] loadMedia failed, format: ${this.params.format}, reason: ${e}`;this.log({message:t}),this.params.output.error$.next({id:`ChromecastProvider.loadMedia`,category:Bi.ErrorCategory.VIDEO_PIPELINE,message:t,thrown:e})}),()=>{this.loadMediaTimeoutSubscription.unsubscribe()})}logRemoteEvent(e){this.log({message:`[remoteEvent] ${JSON.stringify(e)}`})}}var Ki=y(pt(),1),qi=require(`@vkontakte/videoplayer-shared/es2015`),Ji=require(`@vkontakte/videoplayer-shared/es2015`),Yi=(e,t)=>{try{e.pause(),e.playbackRate=0,Ji.clearVideoElement(e,t),e.remove()}catch(e){console.error(e)}},Xi=require(`@vkontakte/videoplayer-shared/es2015`),Zi=`__spvc`;class Qi{constructor(){i(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)}}var $i=qi.getWindow(),ea=$i.WeakMap?new $i.WeakMap:new Qi,ta=$i.WeakMap?new $i.WeakMap:new Map,na=(e,t=20)=>{let n=0;return Xi.fromEvent(e,`ratechange`).subscribe(r=>{n++,n>=t&&(e.currentTime=e.currentTime,n=0)})};function ra(e){e.style.position=`fixed`,e.style.left=`100%`,e.setAttribute(`data-role`,`screen`),qi.getWindow().document.body.appendChild(e)}function ia(e,t){e.style.position=``,e.style.left=``,t.appendChild(e)}var aa=(e,{audioVideoSyncRate:t,disableYandexPiP:n,clearVideoElementInnerHTML:r,reuseOwnVideoElement:i})=>{let a,o=e.querySelector(`video`),s=!!o,c=qi.getWindow().document.querySelector(`body > video[data-role=screen]`)||void 0;i?$i[Zi]=c:(c?.remove(),delete $i[Zi]),o?(a=o,qi.clearVideoElement(a,r)):c&&c===$i[Zi]?(a=c,ia(a,e)):(a=qi.getWindow().document.createElement(`video`),e.appendChild(a),i&&($i[Zi]=a)),ea.set(a,s);let l=new Xi.Subscription;return l.add(na(a,t)),ta.set(a,l),a.setAttribute(`crossorigin`,`anonymous`),a.setAttribute(`playsinline`,`playsinline`),n&&a.setAttribute(`x-yandex-pip`,`false`),a.controls=!1,a.setAttribute(`poster`,`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=`),a},oa=(e,{keepVideoElement:t,clearVideoElementInnerHTML:n,reuseOwnVideoElement:r})=>{ta.get(e)?.unsubscribe(),ta.delete(e);let i=ea.get(e);ea.delete(e),i||t?qi.clearVideoElement(e,n):r?(qi.clearVideoElement(e,n),ra(e)):Yi(e,n)},sa=y(st(),1),I=require(`@vkontakte/videoplayer-shared/es2015`),ca=require(`@vkontakte/videoplayer-shared/es2015`),la=(e,t,n,{equal:r=(e,t)=>e===t,changed$:i,onError:a}={})=>{let o=e.getState(),s=t(),c=ca.isNullable(i),l=new ca.Subscription;return i&&l.add(i.subscribe(t=>{r(t,e.getState())&&e.setState(t)},a)),r(s,o)||(n(o),c&&e.setState(o)),l.add(e.stateChangeStarted$.subscribe(t=>{n(t.to),c&&e.setState(t.to)},a)),l},ua=(e,t,n)=>la(t,()=>e.loop,t=>{ca.isNonNullable(t)&&(e.loop=t)},{onError:n}),da=(e,t,n,r,i)=>la(t,()=>({muted:e.muted,volume:e.volume}),t=>{i?.skipVideoElVolumeSync$.getValue()||ca.isNonNullable(t)&&(e.muted=t.muted,e.volume=t.volume)},{equal:(e,t)=>e===t||e?.muted===t?.muted&&e?.volume===t?.volume,changed$:n,onError:r}),fa=(e,t,n,r)=>la(t,()=>e.playbackRate,t=>{ca.isNonNullable(t)&&(e.playbackRate=t)},{changed$:n,onError:r}),pa=la,ma=e=>[`__`,e.language,e.label].join(`|`),ha=(e,t)=>{if(e.id===t)return!0;let[n,r,i]=t.split(`|`);return e.language===r&&e.label===i};class ga{constructor(e){i(this,`available$`,new I.Subject),i(this,`current$`,new I.ValueSubject(void 0)),i(this,`error$`,new I.Subject),i(this,`video`,void 0),i(this,`cueSettings`,void 0),i(this,`subscription`,new I.Subscription),i(this,`externalTracks`,new Map),i(this,`internalTracks`,new Map),i(this,`baseURL`,void 0),this.baseURL=e}connect(e,t,n){this.video=e,this.cueSettings=t.textTrackCuesSettings,this.subscribe();let r=e=>{this.error$.next({id:`TextTracksManager`,category:I.ErrorCategory.WTF,message:`Generic HtmlVideoTextTrackManager error`,thrown:e})};this.subscription.add(this.available$.subscribe(n.availableTextTracks$)),this.subscription.add(this.current$.subscribe(n.currentTextTrack$)),this.subscription.add(this.error$.subscribe(n.error$)),this.subscription.add(pa(t.internalTextTracks,()=>sa.default(this.internalTracks),e=>{I.isNonNullable(e)&&this.setInternal(e)},{equal:(e,t)=>I.isNonNullable(e)&&I.isNonNullable(t)&&e.length===t.length&&e.every(({id:e},n)=>e===t[n].id),changed$:this.available$.pipe(I.map(e=>e.filter(({type:e})=>e===`internal`))),onError:r})),this.subscription.add(pa(t.externalTextTracks,()=>sa.default(this.externalTracks),e=>{I.isNonNullable(e)&&this.setExternal(e)},{equal:(e,t)=>I.isNonNullable(e)&&I.isNonNullable(t)&&e.length===t.length&&e.every(({id:e},n)=>e===t[n].id),changed$:this.available$.pipe(I.map(e=>e.filter(({type:e})=>e===`external`))),onError:r})),this.subscription.add(pa(t.currentTextTrack,()=>{if(this.video)return;let e=this.htmlTextTracksAsArray().find(({mode:e})=>e===`showing`);return e&&this.htmlTextTrackToITextTrack(e).id},e=>this.select(e),{changed$:this.current$,onError:r})),this.subscription.add(pa(t.textTrackCuesSettings,()=>({}),()=>{if(this.video)for(let e of this.htmlTextTracksAsArray())this.applyCueSettings(e.cues),this.applyCueSettings(e.activeCues)}))}subscribe(){I.assertNonNullable(this.video);let{textTracks:e}=this.video;this.subscription.add(I.fromEvent(e,`addtrack`).subscribe(()=>{let e=this.current$.getValue();e&&this.select(e)})),this.subscription.add(I.merge(I.fromEvent(e,`addtrack`),I.fromEvent(e,`removetrack`),I.observableFrom([`init`])).pipe(I.map(()=>this.htmlTextTracksAsArray().map(e=>this.htmlTextTrackToITextTrack(e))),I.filterChanged((e,t)=>e.length===t.length&&e.every(({id:e},n)=>e===t[n].id))).subscribe(this.available$)),this.subscription.add(I.merge(I.fromEvent(e,`change`),I.observableFrom([`init`])).pipe(I.map(()=>this.htmlTextTracksAsArray().find(({mode:e})=>e===`showing`)),I.map(e=>e&&this.htmlTextTrackToITextTrack(e).id),I.filterChanged()).subscribe(this.current$));let t=e=>this.applyCueSettings(e.target?.activeCues??null);this.subscription.add(I.fromEvent(e,`addtrack`).subscribe(e=>{e.track?.addEventListener(`cuechange`,t);let n=e=>{let t=e.target?.cues??null;t&&t.length&&(this.applyCueSettings(e.target?.cues??null),e.target?.removeEventListener(`cuechange`,n))};e.track?.addEventListener(`cuechange`,n)})),this.subscription.add(I.fromEvent(e,`removetrack`).subscribe(e=>{e.track?.removeEventListener(`cuechange`,t)}))}applyCueSettings(e){if(!e||!e.length)return;let t=this.cueSettings.getState();for(let n of Array.from(e)){let e=n;I.isNonNullable(t.align)&&(e.align=t.align),I.isNonNullable(t.position)&&(e.position=t.position),I.isNonNullable(t.size)&&(e.size=t.size),I.isNonNullable(t.line)&&(e.line=t.line)}}htmlTextTracksAsArray(e=!1){I.assertNonNullable(this.video);let t=[...this.video.textTracks];return e?t:t.filter(ga.isHealthyTrack)}htmlTextTrackToITextTrack(e){let{language:t,label:n}=e,r=e.id?e.id:ma(e),i=this.externalTracks.has(r),a=(i?this.externalTracks.get(r)?.isAuto:this.internalTracks.get(r)?.isAuto)??r.includes(`auto`);return i?{id:r,type:`external`,isAuto:a,language:t,label:n,url:this.externalTracks.get(r)?.url}:{id:r,type:`internal`,isAuto:a,language:t,label:n,url:this.internalTracks.get(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(([,e])=>this.detach(e)),e.filter(({id:e})=>!this.externalTracks.has(e)).forEach(e=>this.attach(e)),Array.from(this.externalTracks).filter(([t])=>!e.find(e=>e.id===t)).forEach(([,e])=>this.detach(e))}setInternal(e){let t=[...this.externalTracks];e.filter(({id:e,language:n,isAuto:r})=>!this.internalTracks.has(e)&&!t.some(([,e])=>e.language===n&&e.isAuto===r)).forEach(e=>this.attach(e)),Array.from(this.internalTracks).filter(([t])=>!e.find(e=>e.id===t)).forEach(([,e])=>this.detach(e))}select(e){I.assertNonNullable(this.video);for(let e of this.htmlTextTracksAsArray(!0))e.mode=`showing`;for(let t of this.htmlTextTracksAsArray(!0))(I.isNullable(e)||!ha(t,e))&&(t.mode=`disabled`)}destroy(){if(this.subscription.unsubscribe(),this.video)for(let e of Array.from(this.video.getElementsByTagName(`track`))){let t=e.getAttribute(`id`);t&&this.externalTracks.has(t)&&this.video.removeChild(e)}this.externalTracks.clear()}attach(e){I.assertNonNullable(this.video);let t=document.createElement(`track`);this.baseURL?t.setAttribute(`src`,new URL(e.url,this.baseURL).toString()):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){I.assertNonNullable(this.video);let t=Array.prototype.find.call(this.video.getElementsByTagName(`track`),t=>t.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)}}var _a=ga;class va{constructor(){i(this,`pausedTime`,0),i(this,`streamOffset`,0),i(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()}}var ya=e=>{let t=e;for(;!(t instanceof Document)&&!(t instanceof ShadowRoot)&&t!==null;)t=t?.parentNode;return t??void 0},ba=e=>{let t=ya(e);return!!(t&&t.fullscreenElement&&t.fullscreenElement===e)},xa=e=>{let t=ya(e);return!!(t&&t.pictureInPictureElement&&t.pictureInPictureElement===e)},L=require(`@vkontakte/videoplayer-shared/es2015`),Sa=3,Ca=(e,t,n=Sa)=>{let r=0,i=0;for(let a=0;a<e.length;a++){let o=e.start(a),s=e.end(a);if(o<=t&&t<=s){if(r=o,i=s,!n)return{from:r,to:i};for(let t=a-1;t>=0;t--)e.end(t)+n>=r&&(r=e.start(t));for(let t=a+1;t<e.length;t++)e.start(t)-n<=i&&(i=e.end(t))}}return{from:r,to:i}},wa=e=>{let t=t=>L.fromEvent(e,t).pipe(L.mapTo(void 0),L.shareReplay(1)),n=new L.Subscription,r=()=>n.unsubscribe(),i=L.merge(L.fromEvent(e,`progress`),L.fromEvent(e,`timeupdate`)).pipe(L.map(()=>Ca(e.buffered,e.currentTime)),L.shareReplay(1)),a=P.browser.isSafari?L.combine({play:t(`play`).pipe(L.once()),playing:t(`playing`)}).pipe(L.mapTo(void 0),L.shareReplay(1)):t(`playing`),o=L.fromEvent(e,`volumechange`).pipe(L.map(()=>({muted:e.muted,volume:e.volume})),L.shareReplay(1)),s=L.fromEvent(e,`ratechange`).pipe(L.map(()=>e.playbackRate),L.shareReplay(1)),c=L.fromEvent(e,`error`).pipe(L.filter(()=>!!(e.error||e.played.length)),L.map(()=>{let t=e.error;return{id:t?`MediaError#${t.code}`:`HtmlVideoError`,category:L.ErrorCategory.VIDEO_PIPELINE,message:t?t.message:`Error event from HTML video element`,thrown:e.error??void 0}}),L.shareReplay(1)),l=L.fromEvent(e,`timeupdate`).pipe(L.map(()=>e.currentTime),L.shareReplay(1)),u=[`waiting`,`seeking`,`seeked`,`timeupdate`],d=new L.Subject,f=.3,p;n.add(L.merge(...u.map(t=>L.fromEvent(e,t))).subscribe(t=>{let n=e.currentTime;e.loop&&L.isNonNullable(p)&&L.isNonNullable(n)&&p>=e.duration-f&&n<=f&&d.next(p),p=n}));let m=t(`pause`).pipe(L.filter(()=>!e.error&&p!==e.duration),L.shareReplay(1)),h=L.fromEvent(e,`enterpictureinpicture`).pipe(L.shareReplay(1)),g=L.fromEvent(e,`leavepictureinpicture`).pipe(L.shareReplay(1)),_=new L.ValueSubject(xa(e));n.add(h.subscribe(()=>_.next(!0))),n.add(g.subscribe(()=>_.next(!1)));let v=new L.ValueSubject(ba(e)),y=L.fromEvent(e,`fullscreenchange`).pipe(L.shareReplay(1));n.add(y.pipe(L.map(()=>ba(e))).subscribe(v));let b=L.fromEvent(e,`timeupdate`).pipe(L.map(t=>e.duration-e.currentTime<.1),L.filterChanged(),L.shareReplay(1)),x=L.merge(b.pipe(L.filter(t=>!e.loop&&t)),L.fromEvent(e,`ended`)).pipe(L.throttle(1e3),L.mapTo(void 0),L.shareReplay(1)),S=L.merge(...[`waiting`,`pause`,`canplay`,`play`,`canplaythrough`,`playing`,`seeking`,`seeked`,`ended`].map(t=>L.fromEvent(e,t)),b.pipe(L.map(e=>({type:e?`ended`:`unknown`})))).pipe(L.map(t=>P.browser.isFirefox&&t.type===`ended`?e.readyState<2:e.readyState<3),L.filterChanged(),L.shareReplay(1));return{playing$:a,pause$:m,canplay$:t(`canplay`),ended$:x,looped$:d,error$:c,seeked$:t(`seeked`),seeking$:t(`seeking`),progress$:t(`progress`),loadStart$:t(`loadstart`),loadedMetadata$:t(`loadedmetadata`),loadedData$:t(`loadeddata`),timeUpdate$:l,durationChange$:L.fromEvent(e,`durationchange`).pipe(L.map(()=>e.duration),L.shareReplay(1)),isBuffering$:S,currentBuffer$:i,volumeState$:o,playbackRateState$:s,inPiP$:_,inFullscreen$:v,enterPip$:h,leavePip$:g,destroy:r}},Ta=require(`@vkontakte/videoplayer-shared/es2015`),Ea=e=>{switch(e){case`mobile`:return Ta.VideoQuality.Q_144P;case`lowest`:return Ta.VideoQuality.Q_240P;case`low`:return Ta.VideoQuality.Q_360P;case`sd`:case`medium`:return Ta.VideoQuality.Q_480P;case`hd`:case`high`:return Ta.VideoQuality.Q_720P;case`fullhd`:case`full`:return Ta.VideoQuality.Q_1080P;case`quadhd`:case`quad`:return Ta.VideoQuality.Q_1440P;case`ultrahd`:case`ultra`:return Ta.VideoQuality.Q_2160P}},Da=y(Rn(),1),Oa=y(pt(),1),ka=y(_t(),1),R=require(`@vkontakte/videoplayer-shared/es2015`),Aa=!1,ja={},Ma=e=>{Aa=e},Na=()=>{ja={}},Pa=e=>{e(ja)},Fa=(e,t)=>{Aa&&(ja.meta=ja.meta??{},ja.meta[e]=t)};class Ia{constructor(e){i(this,`name`,void 0),this.name=e}next(e){if(!Aa)return;ja.series=ja.series??{};let t=ja.series[this.name]??[];t.push([Date.now(),e]),ja.series[this.name]=t}}var La=require(`@vkontakte/videoplayer-shared/es2015`);function Ra(e,t,n){return!e.max&&e.min===t?`high_quality`:!e.min&&e.max===n?`traffic_saving`:`unknown`}function za(e,t,n){return La.isNullable(e)||La.isNonNullable(e.min)&&La.isNonNullable(e.max)&&La.isLower(e.max,e.min)||La.isNonNullable(e.min)&&La.isNonNullable(t)&&La.isHigher(e.min,t)||La.isNonNullable(e.max)&&La.isNonNullable(n)&&La.isLower(e.max,n)}function Ba({limits:e,highestAvailableHeight:t,lowestAvailableHeight:n}){return za({max:e?.max?La.videoHeightToQuality(e.max):void 0,min:e?.min?La.videoHeightToQuality(e.min):void 0},t?La.videoHeightToQuality(t):void 0,n?La.videoHeightToQuality(n):void 0)}var Va=new Ia(`best_bitrate`),Ha=(e,t,n)=>(t-n)*2**(-10*e)+n,Ua=e=>(t,n)=>e*(Number(t.bitrate)-Number(n.bitrate));class Wa{constructor(){i(this,`last`,void 0),i(this,`history`,{})}recordSelection(e){this.history[e.id]=R.now()}recordSwitch(e){this.last=e}clear(){this.last=void 0,this.history={}}}var Ga=`Assertion "ABR Tracks is empty array" failed`,Ka=new WeakMap,qa=new WeakMap,Ja=new WeakMap,Ya=(e,t,n,r)=>{let i=[...t].sort(Ua(1)),a=[...n].sort(Ua(1)),o=a.filter(t=>R.isNonNullable(t.bitrate)&&R.isNonNullable(e.bitrate)?e.bitrate/t.bitrate>r:!0),s=Da.default(a,Math.round(a.length*i.indexOf(e)/(i.length+1)))??Da.default(a,-1);return s&&Oa.default(o,s)?s:o.length?Da.default(o,-1):Da.default(a,0)},Xa=(e,t,n,r)=>{let i=Ka.get(t);i||(i=[...t].sort(Ua(1)),Ka.set(t,i));let a=Ka.get(n);a||(a=[...n].sort(Ua(1)),Ka.set(n,a));let o=Ja.get(e);o||(o=a.filter(t=>R.isNonNullable(t.bitrate)&&R.isNonNullable(e.bitrate)?e.bitrate/t.bitrate>r:!0),Ja.set(e,o));let s=Da.default(a,Math.round(a.length*i.indexOf(e)/(i.length+1)))??Da.default(a,-1);return s&&Oa.default(o,s)?s:o.length?Da.default(o,-1):Da.default(a,0)},Za=e=>`quality`in e,Qa=(e,t,n,r)=>{var i;let a=R.isNonNullable(r==null||(i=r.last)==null?void 0:i.bitrate)&&R.isNonNullable(n?.bitrate)&&r.last.bitrate<n.bitrate?e.trackCooldownIncreaseQuality:e.trackCooldownDecreaseQuality,o=n&&r&&r.history[n.id]&&R.now()-r.history[n.id]<=a&&(!r.last||n.id!==r.last.id);if(n?.id&&r&&!o&&r.recordSelection(n),o&&r?.last){let e=r.last;return r?.recordSwitch(e),t({message:`
|
|
8
8
|
[last ${Za(e)?`video`:`audio`} selected] ${Za(e)?e.quality:e.bitrate}
|
|
9
9
|
`}),e}return r?.recordSwitch(n),n},$a=(e,t)=>Math.log(t)/Math.log(e),eo=({tuning:e,container:t,limits:n,panelSize:r})=>{let i=e.containerSizeFactor;if(r)return{containerSizeLimit:r,containerSizeFactor:i};if(e.usePixelRatio&&P.display.pixelRatio){let t=P.display.pixelRatio;if(e.pixelRatioMultiplier)i*=e.pixelRatioMultiplier*(t-1)+1;else{let n=e.pixelRatioLogBase,[r=0,a=0,o=0]=e.pixelRatioLogCoefficients,s=$a(n,r*t+a)+o;Number.isFinite(s)&&(i*=s)}}return R.isNonNullable(n?.min)&&R.isHigherOrEqual(n.min,e.highQualityLimit)&&(i*=2),{containerSizeLimit:e.limitByContainer&&t&&t.width>0&&t.height>0?{width:t.width*i,height:t.height*i}:void 0,containerSizeFactor:i}},to=new WeakMap,no=(e,{container:t,estimatedThroughput:n,tuning:r,limits:i,reserve:a=0,forwardBufferHealth:o,playbackRate:s,current:c,history:l,visible:u,droppedVideoMaxQualityLimit:d,stallsVideoMaxQualityLimit:f,stallsPredictedThroughput:p,abrLogger:m,panelSize:h})=>{R.assertNotEmptyArray(e,Ga);let{containerSizeFactor:g,containerSizeLimit:_}=eo({container:t,tuning:r,limits:i,panelSize:h}),v=r.considerPlaybackRate&&R.isNonNullable(s)?s:1,y=to.get(e);y||(y=e.filter(e=>!R.isInvariantQuality(e.quality)).sort((e,t)=>R.isHigher(e.quality,t.quality)?-1:1),to.set(e,y));let b=Da.default(y,-1)?.quality,x=Da.default(y,0)?.quality,S=za(i,x,b),C=v*Ha(o??.5,r.bitrateFactorAtEmptyBuffer,r.bitrateFactorAtFullBuffer),w={},T=null;for(let e of y){if(e.tvDisabled){w[e.quality]=`TvDisabled`;continue}let t=!0;if(_)if(e.size)t=e.size.width<=_.width&&e.size.height<=_.height;else{let n=_&&R.videoSizeToQuality(_);t=n?R.isLowerOrEqual(e.quality,n):!0}if(!t){w[e.quality]=`FitsContainer`;continue}let s=p||n,l=R.isNonNullable(s)&&isFinite(s)&&R.isNonNullable(e.bitrate)?s-a>=e.bitrate*C:!0,m=i?.min===e.quality;if(!l&&!m){w[e.quality]=`FitsThroughput`;continue}if(r.lazyQualitySwitch&&R.isNonNullable(r.minBufferToSwitchUp)&&c&&!R.isInvariantQuality(c.quality)&&(o??0)<r.minBufferToSwitchUp&&R.isHigher(e.quality,c.quality)){w[e.quality]=`Buffer`;continue}if(d&&R.isHigherOrEqual(e.quality,d)&&!m){w[e.quality]=`DroppedFramesLimit`;continue}if(f&&R.isHigherOrEqual(e.quality,f)&&!m){w[e.quality]=`StallsLimit`;continue}let h=S||(R.isNullable(i?.max)||R.isLowerOrEqual(e.quality,i.max))&&(R.isNullable(i?.min)||R.isHigherOrEqual(e.quality,i.min)),g=R.isNonNullable(u)&&!u?R.isLowerOrEqual(e.quality,r.backgroundVideoQualityLimit):!0;if(!h||!g){w[e.quality]=`FitsQualityLimits`;continue}T||=e}T&&T.bitrate&&Va.next(T.bitrate);let E=T??Da.default(y,-1)??e[0],D=l?.last,O=Qa(r,m,E,l);return R.isNonNullable(l)&&O.quality!==D?.quality&&m({message:`
|
|
10
10
|
[VIDEO TRACKS ABR]
|