@vkontakte/videoplayer-shared 1.0.100-dev.ed76c949d.0 → 1.0.101-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es2015.cjs +4 -4
- package/es2015.esm.js +4 -4
- package/esnext.cjs +4 -4
- package/esnext.esm.js +4 -4
- package/evergreen.esm.js +4 -4
- package/package.json +1 -1
- package/types/AppTracer/AppTracer.d.ts +17 -2
- package/types/index.d.ts +1 -0
- package/types/reactive/combineLatest.d.ts +6 -0
- package/types/reactive/index.d.ts +1 -0
- package/types/types/DebugData.d.ts +25 -0
- package/types/types/index.d.ts +1 -0
- package/types/utils/suppressAbort.d.ts +1 -1
package/evergreen.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-shared v1.0.
|
|
3
|
-
*
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-shared v1.0.101-beta.0
|
|
3
|
+
* Mon, 31 Aug 2026 18:54:17 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-101/doc/
|
|
5
5
|
*/
|
|
6
|
-
var e=Object.defineProperty,t=e=>e;function n(e,n){this[e]=t.bind(null,n)}var r=(t,r)=>{for(var i in r)e(t,i,{get:r[i],enumerable:!0,configurable:!0,set:n.bind(r,i)})},i=`1.0.100-dev.ed76c949d.0`;class a{subscriptions=[];unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(e=>{typeof e==`function`?e():e.unsubscribe()})}add(e){return this.subscriptions.push(e),this}}var o=e=>{throw Error(`${e} is value of unexpected type`)},s=e=>{},c=()=>{},l=e=>{throw console.error(e),e},u=e=>{console.error(e)};class d{suppressErrors=!1;constructor(e){e&&(this._subscribe=e)}setSuppressErrors(e){this.suppressErrors=e}subscribe(e,t){let n=this.suppressErrors?u:l,r;r=t?typeof t==`function`?{next:t,error:c}:{next:e=>t.next(e),error:e=>t.error?.(e)}:{next:n,error:c};let i=typeof e==`function`?{next:t=>{try{let n=e(t);n instanceof Promise&&n.catch(e=>r.next(e))}catch(e){r.next(e)}},error:e=>r.next(e)}:{next:t=>e.next(t),error:t=>e.error?e.error(t):r.next(t)},s;try{s=this._subscribe(i)}catch(e){i.error?.(e)}return new a().add(()=>{switch(i.next=c,i.error=c,typeof s){case`function`:s();return;case`object`:s.unsubscribe();return;case`undefined`:return;default:return o(s)}})}pipe(...e){return e.reduce((e,t)=>t(e),this)}_subscribe(e){}}class f extends d{keyCounter=0;subscribers=new Map;constructor(){super()}next(e){this.subscribers.forEach(t=>t.next(e))}error(e){this.subscribers.forEach(t=>t.error?.(e))}_subscribe(e){let t=this.keyCounter++;return this.subscribers.set(t,e),new a().add(()=>this.subscribers.delete(t))}}class p{log$=new f;logs=[];log=e=>{let t={...e,timestamp:Date.now()};this.logs.push(t),this.log$.next(t)};createCustomLog(e){return(...t)=>{let n;try{n=e(...t)}catch{n={message:"error in `createCustomLog`",component:`Logger`}}this.log(n)}}createComponentLog(e){return this.createCustomLog(t=>({component:e,...t}))}getAllLogs=()=>this.logs}function m(e,t=`Assertion "value is not nullable" failed`){if(e==null)throw Error(t)}function h(e,t=`Assertion "value is nullable" failed`){if(e!=null)throw Error(t)}function g(e){return e!=null}function _(e){return e==null}var v=e=>Object.fromEntries(Object.entries(e).filter(([e,t])=>g(t)));function y(e,t){if(!e?.length)throw Error(t)}function b(e,t){if(e?.length)throw Error(t)}var x=()=>globalThis,S=()=>globalThis,C=(e=x())=>!!(e.window&&e.screen),w=typeof x().performance?.now==`function`?()=>x().performance.now():()=>Date.now(),ee=()=>Math.trunc(w());function T(){var e=self,t=new Map;e.onmessage=function(n){var r=n.data;if(r.type===`ping`){e.postMessage({type:`ready`});return}if(r.type===`set`){var i=r.id;r.repeat?t.set(i,{repeat:!0,handle:e.setInterval(function(){e.postMessage({type:`tick`,id:i})},r.delay)}):t.set(i,{repeat:!1,handle:e.setTimeout(function(){t.delete(i),e.postMessage({type:`tick`,id:i})},r.delay)});return}var a=t.get(r.id);a&&(a.repeat?e.clearInterval(a.handle):e.clearTimeout(a.handle),t.delete(r.id))}}var te=()=>`'use strict';(${T.toString()})();`;class ne{worker;handlers;records=new Map;ticks=0;constructor(e,t){this.worker=e,this.handlers=t,this.worker.onmessage=this.handleMessage,this.worker.onerror=this.handleError,this.worker.onmessageerror=this.handleError,this.postCommand({type:`ping`})}static create(e){let t=x();if(typeof t.Worker!=`function`||typeof t.Blob!=`function`||_(t.URL?.createObjectURL))return null;let n=t.URL.createObjectURL(new t.Blob([te()],{type:`text/javascript`}));try{return new ne(new t.Worker(n),e)}catch{return null}finally{t.URL.revokeObjectURL(n)}}get activeCount(){return this.records.size}get deliveredTicks(){return this.ticks}set(e,t,n,r){this.records.set(e,{callback:t,repeat:r,delay:n,startedAt:w()}),this.postCommand({type:`set`,id:e,delay:n,repeat:r})}clear(e){this.records.delete(e)&&this.postCommand({type:`clear`,id:e})}destroy(){let e=new Map(this.records);return this.records.clear(),this.worker.onmessage=null,this.worker.onerror=null,this.worker.onmessageerror=null,this.worker.terminate(),e}postCommand(e){this.worker.postMessage(e)}handleMessage=e=>{if(e.data.type===`ready`){this.handlers.onReady();return}let{id:t}=e.data,n=this.records.get(t);_(n)||(this.ticks++,n.repeat||this.records.delete(t),n.callback())};handleError=()=>{this.handlers.onFatalError(this.destroy())}}var E;(e=>{e.SHARED=`shared`,e.CORE=`core`,e.STATISTICS=`statistics`,e.INTERACTIVE=`interactive`,e.UI=`ui`,e.UI_TV=`ui-tv`})(E||={});var re;(e=>{e.IDLE=`idle`,e.STARTING=`starting`,e.READY=`ready`,e.FAILED=`failed`})(re||={});var ie=1,D=0,O=`idle`,k=null,A=new Map,j=new Set,ae=e=>{let t=w();for(let[n,r]of e){let e=r.repeat?r.delay:Math.max(0,r.delay-(t-r.startedAt));ue(n,r.callback,e,r.repeat)}},oe=e=>{O=`failed`,k=null,ae(e)},se=()=>{_(k)||(ae(k.destroy()),k=null),O=`idle`},ce=()=>{O===`idle`&&(O=`starting`,k=ne.create({onReady:()=>{O=`ready`},onFatalError:oe}))},le=e=>j.has(e)?(ce(),O===`ready`?k:null):null,ue=(e,t,n,r)=>{let i=S();r?A.set(e,{repeat:!0,nativeId:i.setInterval(t,n)}):A.set(e,{repeat:!1,nativeId:i.setTimeout(()=>{A.delete(e),t()},n)})},de=(e,t,n,r)=>{let i=ie++,a=le(e);return _(a)?ue(i,t,n,r):a.set(i,t,n,r),i},fe=e=>{if(_(e))return;let t=A.get(e);if(_(t)){k?.clear(e);return}A.delete(e);let n=S();t.repeat?n.clearInterval(t.nativeId):n.clearTimeout(t.nativeId)},pe=e=>({setTimeout:(t,n=0)=>de(e,t,n,!1),setInterval:(t,n=0)=>de(e,t,n,!0),clearTimeout:fe,clearInterval:fe}),me=e=>{j.clear(),e.forEach(e=>j.add(e)),j.size===0&&se()},he=e=>{D++,me(e)},ge=()=>{D!==0&&(D--,D===0&&me([]))},_e=()=>({workerModules:[...j],workerState:O,liveConsumers:D,activeWindowTimers:A.size,activeWorkerTimers:k?.activeCount??0,workerTicks:k?.deliveredTicks??0}),M=pe(`shared`),ve=(e,t,n)=>new Promise((r,i)=>{t.addEventListener(`abort`,()=>{s(),l.remove()});let a=()=>{s(),i(`error`)},o=()=>{s(),r()},s=()=>{c&&M.clearTimeout(c),l.removeEventListener(`load`,o),l.removeEventListener(`error`,a)},c;n&&(c=M.setTimeout(()=>{s(),i(`timeout`)},n));let l=document.createElement(`script`);l.addEventListener(`load`,o),l.addEventListener(`error`,a),l.src=e,document.head.appendChild(l)}),ye=(e,t)=>async(...n)=>{let r=t(...n),i=e.aborted,a;for(;!i&&!e.aborted;)try{let e=await r.next(a);i=e.done??!1,a=e.value}catch(e){await r.throw(e)}return a},be=(e,{start:t=0,factor:n=2,max:r=1/0,min:i=t,random:a=0}={})=>{let o=t;return o*=n**e,o*=1+(Math.random()*a*2-a),o=Math.round(o),o=Math.min(o,r),o=Math.max(o,i),o},xe={};r(xe,{set:()=>we,remove:()=>Ee,isPersistent:()=>Se,has:()=>Te,get:()=>Ce,clear:()=>De});var N,P,F=`vk-videoplayer-dummy-key-${Math.random()}`,I=()=>{if(P!==void 0)return P;try{localStorage.setItem(F,`test`),localStorage.removeItem(F),P=0}catch(e){if(e instanceof DOMException||e instanceof TypeError)try{sessionStorage.getItem(F),P=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)P=2;else throw e}else throw e}return P===2&&(N=new Map),P},Se=()=>I()===0,Ce=e=>{let t=I();switch(t){case 0:return localStorage.getItem(e)??void 0;case 1:return sessionStorage.getItem(e)??void 0;case 2:return N?.get(e);default:o(t)}},we=(e,t)=>{let n=I();switch(n){case 0:try{localStorage.setItem(e,t)}catch(e){if(e instanceof DOMException)console.error(e);else throw e}break;case 1:try{sessionStorage.setItem(e,t)}catch(e){if(e instanceof DOMException)console.error(e);else throw e}break;case 2:N?.set(e,t);return;default:o(n)}},Te=e=>{let t=I();switch(t){case 0:return e in localStorage;case 1:return e in sessionStorage;case 2:return N?.has(e)??!1;default:return o(t),!1}},Ee=e=>{let t=I();switch(t){case 0:return localStorage.removeItem(e);case 1:return sessionStorage.removeItem(e);case 2:N?.delete(e);return;default:o(t)}},De=()=>{let e=I();switch(e){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return N?.clear();default:o(e)}},Oe=()=>{let e,t=[],n=x();try{e=n.self!==n.top}catch(t){t instanceof DOMException&&t.name===`SecurityError`?e=!0:(e=!1,console.error(t))}try{n.location?.ancestorOrigins&&(t=[...n.location.ancestorOrigins])}catch(e){console.error(e)}try{!t.length&&n.document.referrer&&(t=[new URL(n.document.referrer).origin])}catch(e){console.error(e)}return t=t.filter(e=>URL.canParse(e)),{isEmbed:e,origins:t,topOrigin:t.at(-1),immediateOrigin:t.at(0)}},ke;(e=>{e.INVARIANT=`Invariant quality`,e.Q_144P=`144p`,e.Q_240P=`240p`,e.Q_360P=`360p`,e.Q_480P=`480p`,e.Q_576P=`576p`,e.Q_720P=`720p`,e.Q_1080P=`1080p`,e.Q_1440P=`1440p`,e.Q_2160P=`2160p`,e.Q_4320P=`4320p`})(ke||={});var L={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"576p":{width:1024,height:576},"720p":{width:1280,height:720},"1080p":{width:1920,height:1080},"1440p":{width:2560,height:1440},"2160p":{width:3840,height:2160},"4320p":{width:7680,height:4320}},Ae=(e,t)=>L[e].height>L[t].height,je=(e,t)=>L[e].height>=L[t].height,R=(e,t)=>L[e].height<L[t].height,Me=(e,t)=>L[e].height<=L[t].height,Ne=e=>e.sort((e,t)=>e===t?0:e===`Invariant quality`?1:t===`Invariant quality`?-1:R(e,t)?1:-1)[0],Pe=Object.keys(L).sort((e,t)=>R(e,t)?-1:1),Fe=(e,t=.02)=>[...Pe].find(n=>L[n].height*(1+t)>=e),Ie=({width:e,height:t})=>{let n=Math.min(e,t),r=Math.max(e,t);return Pe.find(e=>{let t=L[e];return t.width>=r&&t.height>=n})},Le=e=>L[e].height,z=e=>e===`Invariant quality`,Re=e=>e.every(e=>!z(e));function ze(e){if(z(e))throw Error(`Expected exact quality`)}var Be=e=>{switch(e){case`4320p`:return`8K`;case`2160p`:return`4K`;case`1440p`:return`QHD`;case`1080p`:return`FHD`;case`720p`:return`HD`;default:return``}},B=(e,t)=>{let n={};for(let r of Object.keys(t)){let i=t[r],a=e[r];Array.isArray(i)?n[r]=Array.isArray(a)?a:i:typeof i==`object`&&i?typeof a==`object`&&a&&!Array.isArray(a)?n[r]=B(a,i):n[r]=a??i:n[r]=r in e?a:i}return n},Ve=e=>{let t=``;return e>=3600&&(t+=Math.floor(e/3600)+`h`,e%=3600),e>=60&&(t+=Math.floor(e/60)+`m`,e%=60),e>0&&(t+=Math.floor(e)+`s`),t};function V(e,t=0,n){let r,i,a,o,s,c,l=0,u=!1,d=!1,f=!0,p=!t&&t!==0&&typeof x().requestAnimationFrame==`function`;n&&(u=!!n.leading,d=`maxWait`in n,a=n?.maxWait?Math.max(+n?.maxWait||0,t):a,f=`trailing`in n?!!n.trailing:f);function m(t){let n=r,a=i;return r=i=void 0,l=t,o=e.apply(a,n),o}function h(e,t){return p?(s&&x().cancelAnimationFrame(s),x().requestAnimationFrame(e)):M.setTimeout(e,t)}function g(e){if(p){x().cancelAnimationFrame(e);return}M.clearTimeout(e)}function _(e){return l=e,s=h(b,t),u?m(e):o}function v(e){let n=e-c,r=e-l,i=t-n;return d?Math.min(i,a-r):i}function y(e){let n=e-c,r=e-l;return c===void 0||n>=t||n<0||d&&r>=a}function b(){let e=Date.now();if(y(e))return S(e);s=h(b,v(e))}function S(e){return s=void 0,f&&r?m(e):(r=i=void 0,o)}function C(){s!==void 0&&g(s),l=0,r=c=i=s=void 0}function w(){return s===void 0?o:S(Date.now())}function ee(){return s!==void 0}function T(...e){let n=Date.now(),a=y(n);if(r=e,i=this,c=n,a){if(s===void 0)return _(c);if(d)return s=h(b,t),m(c)}return s===void 0&&(s=h(b,t)),o}return T.cancel=C,T.flush=w,T.pending=ee,T}var He=(e,t=0,n)=>V(e,t,{leading:!0,trailing:!0,...n,maxWait:t}),H=(e,t)=>{if(typeof e!=`object`||!e)return e;let n=Array.isArray(e)?[]:{};for(let r in e){if(typeof t==`function`){let i=t(e[r],r,e,n);if(i!==void 0){n[r]=i;continue}}typeof e[r]==`object`?n[r]=H(e[r],t):n[r]=e[r]}return n},Ue=e=>H(e);class We extends f{bufferSize;buffer=[];cursorEnd=-1;cursorStart=0;constructor(e){super(),this.bufferSize=e,this.buffer=Array(e)}next(e){this.cursorEnd+=1,this.cursorStart=this.cursorEnd>=this.bufferSize?this.cursorStart+1:0,this.buffer[this.cursorEnd%this.bufferSize]=e,this.subscribers.forEach(t=>t.next(e))}_subscribe(e){for(let t=this.cursorStart;t<=this.cursorEnd;t++)e.next(this.buffer[t%this.bufferSize]);let t=this.keyCounter++;return this.subscribers.set(t,e),new a().add(()=>this.subscribers.delete(t))}}class U extends f{value;constructor(e){super(),this.value=e}next(e){super.next(this.value=e)}error(e){super.error(this.value=e)}getValue(){return this.value}_subscribe(e){let t=super._subscribe(e);return e.next(this.value),t}}function Ge(e){return new d(t=>{let n={},r=Object.keys(e).length,i=e=>i=>{e in n||r--,n[e]=i,r===0&&t.next(n)};return Object.entries(e).reduce((e,[t,n])=>e.add(n.subscribe(i(t))),new a)})}function Ke(...e){return new d(t=>e.reduce((e,n)=>e.add(n.subscribe(t)),new a))}var qe=e=>new d(t=>{let n=M.setTimeout(()=>{try{t.next()}catch(e){if(t.error)t.error(e);else throw e}},e);return()=>M.clearTimeout(n)}),Je=e=>new d(t=>{let n=M.setInterval(()=>t.next(),e);return()=>{n&&=(M.clearInterval(n),void 0)}});function Ye(e){return new d(t=>{if(e instanceof Promise){let n=!1;return e.then(e=>{n||t.next(e)}).catch(e=>{n||t.error?.(e)}),()=>{n=!0}}for(let n=0;n<e.length;n++)t.next(e[n])})}var Xe=Ye,Ze=(e,t)=>new d(n=>{let r=e=>n.next(e);return e.addEventListener(t,r),()=>e.removeEventListener(t,r)});class Qe extends a{remove(e){this.subscriptions=this.subscriptions.filter(t=>t!==e)}}function $e(e){return t=>new d(n=>t.subscribe(new et(n,e)))}class et{destination;size;lastValues=[];constructor(e,t){this.destination=e,this.size=t}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){this.destination.error?.(e)}}var tt={leading:!1,trailing:!0};function nt(e,t=tt){return n=>new d(r=>n.subscribe(new rt(r,e,t)))}class rt{destination;time;config;lastValue;timeout;constructor(e,t,n){this.destination=e,this.time=t,this.config=n}next(e){this.lastValue=e,g(this.timeout)?M.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=M.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(e){if(this.destination.error)this.destination.error(e);else throw e}this.timeout=void 0},this.time)}error(e){this.destination.error?.(e)}}var it={leading:!0,trailing:!1};function at(e,t=it){return n=>new d(r=>n.subscribe(new ot(r,e,t)))}class ot{destination;time;config;lastValue;timeout;constructor(e,t,n){this.destination=e,this.time=t,this.config=n}next(e){this.lastValue=e,_(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=M.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){this.destination.error?.(e)}}function st(e){return t=>new d(n=>t.subscribe(new ct(n,e)))}class ct{destination;predicate;constructor(e,t){this.destination=e,this.predicate=t}next(e){let t;try{t=this.predicate(e)}catch(e){throw this.error(e),e}t&&this.destination.next(e)}error(e){this.destination.error?.(e)}}var lt=(e,t)=>{let n=(e,t)=>{let n=Object.keys(e);for(let r in t)if(!n.includes(r)||t[r]!==e[r])return!1;return!0};return n(e,t)&&n(t,e)},ut=(e,t)=>e instanceof Object&&t instanceof Object?lt(e,t):e===t;function dt(e=ut){return t=>new d(n=>t.subscribe(new pt(n,e)))}var ft={};class pt{destination;predicate;lastValue=ft;constructor(e,t){this.destination=e,this.predicate=t}next(e){let t;try{t=this.lastValue===ft||!this.predicate(this.lastValue,e),this.lastValue=e instanceof Object&&!Array.isArray(e)?{...e}:e}catch(e){throw this.error(e),e}t&&this.destination.next(e)}error(e){this.destination.error?.(e)}}function W(e){return t=>new d(n=>t.subscribe(new mt(n,e)))}class mt{destination;mapper;constructor(e,t){this.destination=e,this.mapper=t}next(e){let t;try{t=this.mapper(e)}catch(e){throw this.error(e),e}this.destination.next(t)}error(e){this.destination.error?.(e)}}function ht(e){return W(()=>e)}function gt(){return e=>new d(t=>{let n=!1,r=!1,i=e.subscribe(e=>{n||(n=!0,t.next(e)),r&&i.unsubscribe()},e=>{n=!0,t.error?.(e),r&&i.unsubscribe()});return r=!0,n&&i.unsubscribe(),i})}function _t(){return e=>new d(t=>e.subscribe(new vt(t)))}class vt{destination;last;hasLast=!1;constructor(e){this.destination=e}next(e){let t=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([t,e])}error(e){this.destination.error?.(e)}}function yt(e){return t=>new d(n=>t.subscribe(new bt(n,e)))}class bt{destination;effect;constructor(e,t){this.destination=e,this.effect=t}next(e){try{this.effect(e)}catch(e){throw this.error(e),e}this.destination.next(e)}error(e){this.destination.error?.(e)}}function xt(e){return t=>new d(n=>t.subscribe(new St(n,e)))}class St{destination;count;constructor(e,t){this.destination=e,this.count=t,t<0&&this.destination.error?.(Error(`Count can not be less than zero`))}next(e){this.count===0?this.destination.next(e):this.count--}error(e){this.destination.error?.(e)}}function Ct(e=0){return t=>{let n=0,r=new We(e),i=t.subscribe(r),a=e=>()=>{e.unsubscribe(),n--,n===0&&i.unsubscribe()};return new d(e=>(n++,a(r.subscribe(e))))}}var wt=300,Tt=(e,t=wt)=>new d(n=>{let r=x(),{width:i,height:a}=e.getBoundingClientRect();if(n.next({width:i,height:a}),!C(r))return;let o=new r.ResizeObserver(He(e=>{let t=e[0];if(!t)return;let r,i;t.contentBoxSize&&t.contentBoxSize[0]?(i=t.contentBoxSize[0].blockSize,r=t.contentBoxSize[0].inlineSize):t.contentRect&&(r=t.contentRect.width,i=t.contentRect.height),g(r)&&g(i)&&n.next({width:r,height:i})},t));return o.observe(e),()=>o.disconnect()}),G=(e,t=6,n=`.`)=>{let r={};for(let i in e)if(!(!e.hasOwnProperty(i)||e[i]instanceof HTMLElement||!t))if(typeof e[i]==`object`&&e[i]!==null){let a=G(e[i],t-1);for(let e in a)a.hasOwnProperty(e)&&(r[i+n+e]=a[e])}else r[i]=e[i];return r},Et=e=>{e.innerHTML=``,e.removeAttribute(`src`),e.load()},Dt=e=>{let t;try{t=new URL(e)}catch{return!1}return t.protocol===`https:`},Ot=(e,t)=>!(e.right<t.left||e.left>t.right||e.bottom<t.top||e.top>t.bottom),kt=(()=>{let e=0;return()=>{let t=e;return e=(e+1)%(2**53-1),t}})(),At=e=>e!==void 0&&e!==``?e:kt().toString();function jt(e,t,n){if(e<=t[0])return n[0];if(e>=t[t.length-1])return n[n.length-1];let r=1;for(;r<t.length&&t[r]<e;)r++;r>=t.length&&(r=t.length-1);let i=t[r-1],a=t[r],o=n[r-1],s=n[r];return e===i?o:e===a?s:o+(e-i)/(a-i)*(s-o)}function Mt(e,t,n){if(e<=0||n<0)return[];let r=[],i=Math.floor((e-1)/2),a=Math.floor(e/2),o=t-i,s=t+a;o<0&&(s+=Math.abs(o),o=0),s>n&&(o-=s-n,s=n),o=Math.max(0,o),s=Math.min(n,s);for(let e=o;e<=s;e++)r.push(e);return r}var Nt=e=>e instanceof DOMException&&(e.name===`AbortError`||e.code===20),Pt=e=>{if(!Nt(e))throw e};function Ft(e){if(e&&typeof e==`object`){if(`message`in e)return String(e.message);try{return JSON.stringify(e)}catch{return`object serialization error`}}return String(e)}class K{buffer;writeIndex=0;count=0;capacity;constructor(e){if(e<=0)throw Error(`Capacity must be greater than 0`);this.capacity=e,this.buffer=Array.from({length:e}).fill(null)}add(e){this.buffer[this.writeIndex]=e,this.writeIndex=(this.writeIndex+1)%this.capacity,this.count<this.capacity&&this.count++}*[Symbol.iterator](){if(this.count===0)return;let e=this.count<this.capacity?0:this.writeIndex;for(let t=0;t<this.count;t++){let t=this.buffer[e];g(t)&&(yield t),e=(e+1)%this.capacity}}clear(){this.buffer.fill(null),this.writeIndex=0,this.count=0}get size(){return this.count}get maxCapacity(){return this.capacity}}var It=e=>(t,n=!1)=>r=>{let i=typeof r==`object`;r==null||i&&!Object.keys(r).length||e(t,i?G(r):{value:r},n)},q=(e={})=>{let t=e=>{let t=e;return e===void 0?t=`undefined`:e===null?t=`null`:(typeof e==`number`||typeof e==`boolean`)&&(t=e.toString()),t},n={};for(let r in e)Array.isArray(e[r])?n[r]=e[r].map(t):n[r]=t(e[r]);return n};class J{dynamicImportTimeout=5e3;subscription=new a;options;span;context;childTracers=[];initPromise;getRootTracerContext;eventsBuffer=null;static dynamicImportStatus=`not_started`;static dynamicImports;static dynamicImportPromise;constructor({name:e,getParentContext:t,getRootTracerContext:n,options:r}){this.options=r??{};let{tracerEventsBufferSize:i}=this.options;g(i)&&i>0&&(this.eventsBuffer=new K(i)),J.dynamicImportStatus===`not_started`&&(J.dynamicImportPromise=this.loadOpentelemetry());let a=Date.now();this.initPromise=J.dynamicImportPromise.then(r=>{J.dynamicImportStatus===`completed`&&this.init({name:e,getParentContext:t,getRootTracerContext:n},a)})}init({name:e,getParentContext:t,getRootTracerContext:n},r){let i=n?.();if(_(i))return;let{opentelemetryApi:a}=J.dynamicImports,{context:o,trace:s}=a,{tracer:c,attributes$:l}=i;this.span=c.startSpan(e,{startTime:r},t?.()),this.context=s.setSpan(o.active(),this.span),this.getRootTracerContext=n,this.subscription.add(l.subscribe(e=>{g(e)&&this.span.setAttributes(e)}))}async loadOpentelemetry(){if(J.dynamicImportStatus===`not_started`){J.dynamicImportStatus=`in_progress`;try{let e=new Promise((e,t)=>M.setTimeout(t,this.dynamicImportTimeout)),t=Promise.all([import(`@opentelemetry/api`),import(`@opentelemetry/sdk-trace-web`),import(`@apptracer/opentelemetry`),import(`@opentelemetry/resources`),import(`@opentelemetry/semantic-conventions`)]),[n,r,i,a,o]=await Promise.race([t,e]);J.dynamicImports={opentelemetryApi:n,opentelemetrySdk:r,tracer:i,opentelemetryResources:a,opentelemetrySemanticConventions:o},J.dynamicImportStatus=`completed`}catch{J.dynamicImportStatus=`failed`}}}isComponentTracerNotInitialized(){return _(this.span)||J.dynamicImportStatus===`failed`}addEventToBuffer(e,t,n,r){g(this.eventsBuffer)&&this.eventsBuffer.add({name:e,attributes:t,type:n,timestamp:r})}addEventToSpan(e,t,n,r){this.span.addEvent(e,{...q(t),type:n},r)}log(e,t,n=!1){let r=Date.now();n?this.initPromise.then(n=>{this.isComponentTracerNotInitialized()||this.addEventToSpan(e,t,`log`,r)}):this.addEventToBuffer(e,t,`log`,r)}error(e,t,n=!1){let r=Date.now();n?this.initPromise.then(n=>{this.isComponentTracerNotInitialized()||this.addEventToSpan(e,t,`error`,r)}):this.addEventToBuffer(e,t,`error`,r)}critical(e,t,n=!1){let r=Date.now();n?this.initPromise.then(n=>{this.isComponentTracerNotInitialized()||this.addEventToSpan(e,t,`critical`,r)}):this.addEventToBuffer(e,t,`critical`,r)}createComponentTracer(e){let t=new J({name:e,getParentContext:()=>this.context,getRootTracerContext:()=>this.getRootTracerContext?.(),options:this.options});return this.childTracers.push(t),t}setSpanAttributes(e){this.span.setAttributes(q(e))}end(){this.initPromise.then(e=>{if(!this.isComponentTracerNotInitialized()){if(g(this.eventsBuffer))for(let e of this.eventsBuffer)this.addEventToSpan(e.name,e.attributes,e.type,e.timestamp);this.childTracers.forEach(e=>e.end()),this.span.end(),this.subscription.unsubscribe()}})}pause(){this.getRootTracerContext?.()?.paused$.next(!0)}resume(){this.getRootTracerContext?.()?.paused$.next(!1)}}var Lt=`gW5EerTD5QhAnsbpF7Hd2NSMRteYIUUMjFbSyI68Pf5`,Rt=e=>{class t extends e{_isPaused=!1;_pausedSpans;maxExportBatchSize;maxQueueSize;constructor(e,t){super(e,t),this.maxQueueSize=t?.maxQueueSize??2048,this.maxExportBatchSize=t?.maxExportBatchSize??512,this._pausedSpans=new K(this.maxQueueSize)}pause(){this._isPaused=!0}async resume(){if(!this._isPaused)return;this._isPaused=!1;let e=this._pausedSpans;this._pausedSpans=new K(this.maxQueueSize);let t=0;for(let n of e)super.onEnd(n),t+=1,t>=this.maxExportBatchSize&&(await new Promise(e=>M.setTimeout(()=>e(void 0),0)),t=0);e.clear(),await this.forceFlush()}onEnd(e){if(this._isPaused){this._pausedSpans.add(e);return}super.onEnd(e)}}return t};class zt extends J{attributes$=new U(null);paused$=new U(!1);constructor(e){super({name:`Root`,options:e}),this.paused$.next(!!this.options.tracerPausedAtInit)}init({name:e,getParentContext:t},n){let{tracer:r,opentelemetryResources:a,opentelemetrySdk:o,opentelemetrySemanticConventions:s}=J.dynamicImports,{TracerUploadSpanExporter:c}=r,{WebTracerProvider:l,BatchSpanProcessor:u}=o,{resourceFromAttributes:d}=a,{ATTR_SERVICE_NAME:f,ATTR_SERVICE_VERSION:p}=s,m=new(Rt(u))(new c({appToken:Lt}));this.subscription.add(this.paused$.subscribe(e=>{e?m.pause():m.resume()}));let h=new l({resource:d({[f]:`videoplayer-sdk-web`,[p]:i}),spanLimits:{attributeCountLimit:1/0,eventCountLimit:1/0,attributePerEventCountLimit:1/0},spanProcessors:[m]});h.register();let g=h.getTracer(`sdk-videoplayer-tracer`);super.init({name:e,getParentContext:t,getRootTracerContext:()=>({tracer:g,attributes$:this.attributes$,paused$:this.paused$})},n)}getTraceId(){return this.isComponentTracerNotInitialized()?``:this.span.spanContext().traceId}setSpanAttributes(e){this.attributes$.next({...this.attributes$.getValue(),...q(e)})}addSubscription(e){this.subscription.add(e)}}class Bt{fakeTraceId;constructor(e){}log(e,t,n){}error(e,t,n){}critical(e,t,n){}createComponentTracer(e){return new Bt({name:e})}end(){}getTraceId(){return this.fakeTraceId}addSubscription(e){}setSpanAttributes(e){}pause(){}resume(){}}var Vt=()=>!0,Y={level:0,filter:Vt,name:`Noname Tracer`,outputMethod:`log`};class Ht{name;filter=Vt;level=Y.level;outputMethod=Y.outputMethod;childTracers=[];constructor({name:e,level:t,filter:n,outputMethod:r}={}){this.filter=n??this.filter,this.level=t??this.level,this.outputMethod=r??this.outputMethod,this.name=e??Y.name}log(e,t,n){this.logDebug(e,t)}error(e,t,n){this.logError(e,t)}critical(e,t,n){this.logError(e,t)}createComponentTracer(e){let t=new Ht({filter:this.filter,level:this.level,name:`${this.name}/ ${e}`,outputMethod:this.outputMethod});return this.childTracers.push(t),t}end(){this.childTracers.forEach(e=>e.end()),this.childTracers=[]}setLevel(e){this.level=e,this.childTracers.forEach(t=>t.setLevel(e))}setOtputMethod(e){this.outputMethod=e,this.childTracers.forEach(t=>t.setOtputMethod(e))}setFilter(e){this.filter=e,this.childTracers.forEach(t=>t.setFilter(e))}getFinishedSpans(){}getTraceId(){return`debug_trace`}get verbose(){return this.level===0}createMessage(e,t){return[this.name,e,JSON.stringify(t)].join(`: `)}logDebug(e,t){!this.verbose||!this.filter(e,t)||x().console[this.outputMethod](this.createMessage(e,t))}logError(e,t){this.filter(e,t)&&x().console.error(this.createMessage(e,t))}addSubscription(e){}setSpanAttributes(e){}pause(){}resume(){}}class Ut{static createRootTracer(e=`fake`,t){switch(e){case`real`:return new zt(t);case`debug`:return new Ht;default:return new Bt}}}var Wt;(e=>{e.MediaError=`mediaError`,e.SegmentFetcher=`segment_fetcher`,e.Hangup=`hangup`,e.Stall=`stall`})(Wt||={});var Gt;(e=>{e.NETWORK=`network`,e.VIDEO_PIPELINE=`video_pipeline`,e.EXTERNAL_API=`external_api`,e.PARSER=`parser`,e.DOM=`dom`,e.WTF=`wtf`,e.UI=`ui`,e.CALL_FROM_EXTERNAL=`call_from_external`,e.FATAL=`fatal`})(Gt||={});var Kt;(e=>{e.Armenian=`58`,e.Azerbaijani=`57`,e.Belarusian=`114`,e.English=`3`,e.Kazakh=`97`,e.Portuguese=`73`,e.Russian=`0`,e.Spanish=`4`,e.Ukrainian=`1`,e.Uzbek=`65`,e.Vietnamese=`75`})(Kt||={});var qt=`vk.ru`,Jt=async(e,t,n)=>{let r=new URL(`https://${qt}/js/lang-pack.js`);return r.searchParams.set(`format`,`json`),r.searchParams.set(`name`,t),e!==void 0&&r.searchParams.set(`lang`,e),Yt(await(await fetch(r.toString())).json(),n)},Yt=(e,t)=>Object.fromEntries(Object.entries(e.keys).map(([e,n])=>[e.substring(`${t}_`.length),Xt(n)])),Xt=e=>Array.isArray(e)?e[0]:e,Zt;(e=>{e.RU=`ru`,e.EN=`en`})(Zt||={});var X=`__vk_vp_internals_exposure`;class Qt{playerId;type;constructor(e,t){this.playerId=t,this.type=e,this.initWindowObjects()}getWindowObject(){if(typeof window>`u`)return{};let e=this.playerId,t=this.type;return window[X]?.[e]?.[t]??{}}initWindowObjects(){if(typeof window>`u`)return;let e=this.playerId,t=this.type;window[X]||(window[X]={}),window[X][e]||(window[X][e]={}),window[X][e][t]||(window[X][e][t]={})}expose(e){typeof window>`u`||Object.assign(this.getWindowObject(),e)}destroy(){if(typeof window>`u`)return;let e=this.playerId,t=this.type;window[X]&&window[X][e]&&window[X][e][t]&&(delete window[X][e][t],Object.keys(window[X][e]).length||delete window[X][e],Object.keys(window[X]).length||delete window[X])}}var $t={};r($t,{subscribe:()=>rn,push:()=>nn,destroy:()=>tn,create:()=>en});var Z=new Map,en=(e,t)=>Z.set(e,t??[]),tn=e=>Z.delete(e),nn=(e,t)=>{let n=Z.get(e);n&&(typeof n==`function`?n(t):n.push(t))},rn=(e,t)=>{let n=Z.get(e);if(n){if(n&&Array.isArray(n))for(let e of n)t(e);Z.set(e,t)}},an=e=>v({id:e.id,message:e.message,category:e.category,data:on(e.data),httpCode:e.httpCode,UVBackendErrorCode:e.UVBackendErrorCode});function on(e){switch(typeof e){case`boolean`:case`string`:case`number`:return e;case`object`:try{return JSON.stringify(e)}catch{return}default:return}}var sn=e=>{let t=e.thrown instanceof Error?e.thrown:Error(e.message),n=e.id.length>10240?e.id.substring(0,10240):e.id;try{t.name=n}catch{t=Error(e.message),t.name=n}return t},cn=()=>{try{let{origin:e,pathname:t,search:n,hostname:r}=x()?.document?.location??{};return!r||r===`localhost`?void 0:{url:e+t,...new URLSearchParams(n).entries().reduce((e,[t,n])=>(e[`url.${t}`]=n,e),{})}}catch{}};class Q{static tracerErrorMap=new Map;static appTracerModule=null;static loadPromise=null;dynamicImportTimeout=5e3;componentName;subscription=new a;options;envParams;context;isEmbed;embedParent;beforeInitErrors=[];constructor(e,t,n,r){this.componentName=e,this.options=t,this.envParams=n,this.context={...r};let{isEmbed:i,topOrigin:a}=Oe();this.isEmbed=i,this.embedParent=a?new URL(a).hostname:void 0,this.options.enabled&&(this.loadModule(),this.init())}updateContext(e){Object.assign(this.context,e)}error(e,t){let n=Q.tracerErrorMap.get(this.componentName);if(!n){this.beforeInitErrors.push([e,t]);return}let{blackErrorCategoryList:r,blackErrorIdList:i,sampleRate:a,whiteErrorCategoryList:o,whiteErrorIdList:s}=this.options,{id:c,category:l}=e;if(!(r.length&&r.includes(l)||i.length&&i.includes(c)||o.length&&!o.includes(l)||s.length&&!s.includes(c)||Math.random()>=a))try{let r=sn(e);n?.error(r,{crashIdSource:t?.crashIdSource??r.name,severity:t?.severity??(e.traceAsLog?`debug`:void 0),...t?.issueKey?{issueKey:t.issueKey}:{},keys:{...this.context,...an(e),...cn(),...this.isEmbed&&this.embedParent&&{iframe_host:this.embedParent}}})}catch(e){console.error(e)}}addSubscription(e){this.subscription.add(e)}destroy(){this.subscription.unsubscribe()}async init(){try{if(await Q.loadPromise,Q.tracerErrorMap.has(this.componentName)||_(Q.appTracerModule))return;let{appTracerModule:e}=Q,{initTracerError:t,initTracerErrorUploader:n,getTracerModules:r}=e,i=r(this.componentName),a=!i.error,o=i.error??t(this.componentName,{enableUnhandledErrorsListeners:!1,stringifyErrorDataObject:!0});g(this.options.userId)&&o.setUserId(this.options.userId),a&&n(this.componentName,{appToken:Lt,environment:this.envParams.env,versionCode:1,versionName:this.envParams.version}),Q.tracerErrorMap.set(this.componentName,o),this.beforeInitErrors.forEach(e=>this.error.apply(this,e)),this.beforeInitErrors=[]}catch(e){console.error(e)}}loadModule(){g(Q.loadPromise)||(Q.loadPromise=(async()=>{try{let e=new Promise((e,t)=>M.setTimeout(t,this.dynamicImportTimeout));Q.appTracerModule=await Promise.race([e,import(`@apptracer/sdk/lite`)])}catch(e){Q.loadPromise=null,console.error(e)}})())}}class ln{options;symbol;constructor(e,t){this.options=t,this.symbol=Symbol(e)}}var un=()=>{let e=new Map,t=new Map,n=new Map,r=new Map,i=new Set;return{resolve(e){if(!r.has(e)){let t=n.get(e);if(!t)throw Error(`No constructor registered in DI container for ${e.name}`);r.set(e,new t)}return r.get(e)},resolveOptional(e){try{return this.resolve(e)}catch{return}},replace(e,t){r.forEach((t,n)=>{t instanceof e&&r.delete(n)}),n.set(e,t)},getToken(n){if(e.has(n.symbol))return e.get(n.symbol);if(t.has(n.symbol)){let r=t.get(n.symbol)();return e.set(n.symbol,r),r}if(n.options?.factory){let t=n.options.factory();return e.set(n.symbol,t),t}throw Error(`No value registered in DI container for token "${n.symbol.description}"`)},registerToken(t,n){e.set(t.symbol,n)},registerFactory(e,n){t.set(e.symbol,n)},hasToken(n){return e.has(n.symbol)||t.has(n.symbol)||!!n.options?.factory},registerCleanup(e){i.add(e)},clear(){i.forEach(e=>e()),i.clear(),e.clear(),t.clear(),r.clear(),n.clear()}}};class dn{_inputNode;_outputNode;_plugins=[];_destination=null;_taps=[];constructor(e){this._inputNode=e.createGain(),this._outputNode=e.createGain()}get input(){return this._inputNode}get plugins(){return this._plugins}connectTo(e){this._destination=e,this.rebuild()}addTap(e){this._taps.push(e),this._outputNode.connect(e)}hasPlugin(e){return this._plugins.some(t=>t.id===e)}addPlugin(e){this.hasPlugin(e.id)||(this._plugins.push(e),this.rebuild())}removePlugin(e){let t=this._plugins.findIndex(t=>t.id===e);t!==-1&&(this._plugins.splice(t,1),this.rebuild())}rebuild(){this._inputNode.disconnect();for(let e of this._plugins)e.outputNode.disconnect();this._outputNode.disconnect();let e=this._inputNode;for(let t of this._plugins)e.connect(t.inputNode),e=t.outputNode;e.connect(this._outputNode),this._destination!==null&&this._outputNode.connect(this._destination);for(let e of this._taps)this._outputNode.connect(e)}}class fn{_pluginChain;_element;_ctx;_sourceNode=null;_isBound=!1;constructor(e,t,n){this._element=e,this._ctx=t,this._pluginChain=new dn(t),this._pluginChain.connectTo(n)}get isBound(){return this._isBound}get plugins(){return this._pluginChain.plugins}bind(){this._isBound||=(this._sourceNode===null&&(this._sourceNode=this._ctx.createMediaElementSource(this._element)),this._sourceNode.disconnect(),this._sourceNode.connect(this._pluginChain.input),!0)}unbind(){this._isBound&&=(this._sourceNode?.disconnect(),this._sourceNode?.connect(this._ctx.destination),!1)}addPlugin(e){this._pluginChain.addPlugin(e)}removePlugin(e){this._pluginChain.removePlugin(e)}addAnalyser(e){this._pluginChain.addTap(e)}}class pn{_ctx=null;_masterGain=null;_connections=new Map;_contextEnabled=!1;_boundBeforeDisable=new Set;static isSupported(){let e=x();return g(e.AudioContext??e.webkitAudioContext)}get context(){if(_(this._ctx)){let e=x(),t=e.AudioContext??e.webkitAudioContext;this._ctx=new t}return this._ctx}get contextState(){return this._contextEnabled?this._ctx?.state??`suspended`:`suspended`}async enableContext(){this.ensureContext(),await this._ctx?.resume(),this._contextEnabled=!0;for(let e of this._boundBeforeDisable)this._connections.get(e)?.bind();this._boundBeforeDisable.clear()}async disableContext(){this._contextEnabled=!1;for(let[e,t]of this._connections)t.isBound&&(this._boundBeforeDisable.add(e),t.unbind())}async connectSource(e){this.ensureContext(),this._contextEnabled=!0,await this._ctx?.resume();let t=this._connections.get(e);if(t!==void 0){t.isBound||t.bind();return}let n=new fn(e,this.context,this._masterGain);n.bind(),this._connections.set(e,n)}disconnectSource(e){this._connections.get(e)?.unbind()}isSourceConnected(e){return this._connections.get(e)?.isBound??!1}addPlugin(e,t){let n=this._connections.get(e);if(n===void 0)throw Error(`Source is not connected. Call connectSource() first.`);n.addPlugin(t)}removePlugin(e,t){this._connections.get(e)?.removePlugin(t)}getPlugins(e){return this._connections.get(e)?.plugins??[]}createAnalyser(e){let t=this._connections.get(e);if(t===void 0)return null;let n=this.context.createAnalyser();return n.fftSize=256,n.smoothingTimeConstant=.8,t.addAnalyser(n),n}setMasterVolume(e){this._masterGain!==null&&(this._masterGain.gain.value=e)}getMasterVolume(){return this._masterGain?.gain.value??1}dispose(){this._connections.clear(),this._boundBeforeDisable.clear(),this._masterGain=null,this._contextEnabled=!1,this._ctx?.close(),this._ctx=null}ensureContext(){let e=this.context;_(this._masterGain)&&(this._masterGain=e.createGain(),this._masterGain.gain.value=1,this._masterGain.connect(e.destination))}}class mn{id=`volume-fader`;_gainNode;_duration;_curve;_fade=null;constructor(e,t){this._gainNode=e.createGain(),this._gainNode.gain.value=1,this._duration=t.duration,this._curve=t.curve??this._buildEasingCurve(t.duration/1e3)}get inputNode(){return this._gainNode}get outputNode(){return this._gainNode}get faded(){return this._fade!==null}appear(){this._startFade(0,1)}disappear(){this._startFade(1,0)}pause(){if(this._fade===null)return;let e=this._gainNode.gain,t=this._gainNode.context.currentTime,n=t-this._fade.startTime,r=Math.max(0,this._fade.remaining-n);if(r<=.001){this._finishFade();return}let i=this._sampleIndex(this._fade,t),a=this._fade.curve[i];e.cancelScheduledValues(t),e.setValueAtTime(a,t),this._fade={from:a,target:this._fade.target,startTime:t,remaining:r,curve:this._fade.curve.subarray(i)}}resume(){if(this._fade===null)return;let e=this._gainNode.context.currentTime,{from:t,target:n,remaining:r,curve:i}=this._fade;if(r<=.001||Math.abs(n-t)<.001||i.length<2){this._finishFade();return}this._fade={from:t,target:n,startTime:e,remaining:r,curve:i},this._scheduleCurve(i,t,e,r)}cancel(){this._fade!==null&&this._finishFade()}_finishFade(){if(this._fade===null)return;let e=this._gainNode.gain,t=this._gainNode.context.currentTime;e.cancelScheduledValues(t),e.setValueAtTime(this._fade.target,t),this._fade=null}_startFade(e,t){let n=this._gainNode.gain,r=this._gainNode.context.currentTime,i=this._duration/1e3;if(i<=0){n.cancelScheduledValues(r),n.setValueAtTime(t,r),this._fade=null;return}let a=new Float32Array(this._curve.length);for(let n=0;n<this._curve.length;n++)a[n]=e+(t-e)*this._curve[n];this._fade={from:a[0],target:t,startTime:r,remaining:i,curve:a},this._scheduleCurve(a,a[0],r,i)}_buildEasingCurve(e){let t=Math.max(2,Math.ceil(e*60)),n=new Float32Array(t);for(let e=0;e<t;e++){let r=e/(t-1);n[e]=(1-Math.cos(Math.PI*r))/2}return n}_scheduleCurve(e,t,n,r){let i=this._gainNode.gain;i.cancelScheduledValues(n),i.setValueAtTime(t,n),i.setValueCurveAtTime(e,n,r)}_sampleIndex(e,t){let n=t-e.startTime,r=Math.max(0,Math.min(1,n/e.remaining));return Math.min(Math.round(r*(e.curve.length-1)),e.curve.length-1)}}class hn{_filter;_source;_defaultGain;frequency;constructor(e,t,n,r){this.frequency=t,this._source=n,this._defaultGain=r,this._filter=e.createBiquadFilter(),this._filter.type=`peaking`,this._filter.frequency.value=t,this._filter.gain.value=0,this._filter.Q.value=1,this._source.connect(this._filter.gain)}get value(){return this._source.offset.value}get node(){return this._filter}set(e){this._source.offset.value=e}reset(){this.set(this._defaultGain)}dispose(){this._source.disconnect(this._filter.gain)}}class ${id=`equalizer`;static _sources=new WeakMap;_inputNode;_outputNode;_filterMap=new Map;equalizer;constructor(e,t){this._inputNode=e.createGain(),this._outputNode=e.createGain();let n=Object.entries(t).map(([e,t])=>[Number(e),t]).filter(([e])=>Number.isFinite(e)).sort((e,t)=>e[0]-t[0]),r=$._sources.get(e);_(r)&&(r=new Map,$._sources.set(e,r));for(let[t,i]of n)if(!r.has(t)){let n=e.createConstantSource();n.offset.value=i,n.start(),r.set(t,n)}let i={};for(let[t,a]of n){let n=r.get(t);if(!n)continue;let o=new hn(e,t,n,a);this._filterMap.set(t,o),i[t]=o}this.equalizer=i,this.rebuild()}get inputNode(){return this._inputNode}get outputNode(){return this._outputNode}resetAll(){for(let e of this._filterMap.values())e.reset()}dispose(){for(let e of this._filterMap.values())e.dispose()}rebuild(){this._inputNode.disconnect();for(let e of this._filterMap.values())e.node.disconnect();this._outputNode.disconnect();let e=this._inputNode;for(let t of this._filterMap.values())e.connect(t.node),e=t.node;e.connect(this._outputNode)}}var gn=-14;class _n{id=`normalizer`;_compressor;_gainNode;constructor(e,t){this._compressor=e.createDynamicsCompressor(),this._gainNode=e.createGain(),this.applyConfig(t),this._compressor.connect(this._gainNode)}get inputNode(){return this._compressor}get outputNode(){return this._gainNode}applyConfig(e){if(!Number.isFinite(e.lufs)||!Number.isFinite(e.peak)){this._gainNode.gain.value=1;return}this._compressor.threshold.value=e.peak,this._compressor.knee.value=0,this._compressor.ratio.value=20,this._compressor.attack.value=.003,this._compressor.release.value=.25;let t=(e.targetLufs??gn)-e.lufs;this._gainNode.gain.value=10**(t/20)}}export{v as withoutNullable,Ie as videoSizeToQuality,Le as videoQualityToHeight,Fe as videoHeightToQuality,qe as timeout,Ve as timeCodeToString,He as throttleFn,at as throttle,yt as tap,Pt as suppressAbort,xt as skip,Ct as shareReplay,xe as safeStorage,he as retainTimers,ge as releaseTimers,_t as pairwise,gt as once,Tt as observeElementSize,Xe as observableFrom,ee as nowInt,w as now,c as noop,Ke as merge,ht as mapTo,W as map,Jt as loadVKLangPack,Dt as isValidURL,_ as isNullable,g as isNonNullable,Me as isLowerOrEqual,R as isLower,z as isInvariantQuality,Ot as isIntersecting,je as isHigherOrEqual,Ae as isHigher,C as isBrowserWindow,Nt as isAbortError,Je as interval,jt as interpolate,x as getWindow,Be as getVideoQualityLabel,It as getTraceSubscriptionMethod,_e as getTimersDiagnostics,S as getTimerWindow,Mt as getRangeAroundIndex,At as getPlayerId,Ft as getMessageFromError,Ne as getHighestQuality,be as getExponentialDelay,Ze as fromEvent,G as flattenObject,dt as filterChanged,st as filter,B as fillWithDefault,$t as devNull,Oe as detectEmbed,V as debounceFn,nt as debounce,pe as createTimers,un as createDIContainer,Ge as combine,H as cloneDeepWith,Ue as cloneDeep,Et as clearVideoElement,s as checkNever,$e as buffer,ze as assertQualityIsExact,h as assertNullable,y as assertNotEmptyArray,m as assertNonNullable,o as assertNever,b as assertEmptyArray,Re as areQualitiesExact,ve as addScript,ye as abortable,re as WorkerState,mn as VolumeFaderPlugin,ke as VideoQuality,U as ValueSubject,Kt as VKNumericLanguage,i as VERSION,Ut as TracerFactory,E as TimerModule,Qe as SubscriptionRemovable,a as Subscription,f as Subject,We as ReplaySubject,d as Observable,_n as NormalizerPlugin,p as Logger,Qt as InternalsExposure,Zt as InterfaceLanguage,ln as InjectionToken,X as INTERNAL_EXPOSE_GLOBAL_KEY,Wt as ErrorOrigin,Gt as ErrorCategory,$ as EqualizerPlugin,K as CircularBuffer,pn as AudioGraph,Q as AppTracer};
|
|
6
|
+
var e=Object.defineProperty,t=e=>e;function n(e,n){this[e]=t.bind(null,n)}var r=(t,r)=>{for(var i in r)e(t,i,{get:r[i],enumerable:!0,configurable:!0,set:n.bind(r,i)})},i=`1.0.101-beta.0`;class a{subscriptions=[];unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(e=>{typeof e==`function`?e():e.unsubscribe()})}add(e){return this.subscriptions.push(e),this}}var o=e=>{throw Error(`${e} is value of unexpected type`)},s=e=>{},c=()=>{},l=e=>{throw console.error(e),e},u=e=>{console.error(e)};class d{suppressErrors=!1;constructor(e){e&&(this._subscribe=e)}setSuppressErrors(e){this.suppressErrors=e}subscribe(e,t){let n=this.suppressErrors?u:l,r;r=t?typeof t==`function`?{next:t,error:c}:{next:e=>t.next(e),error:e=>t.error?.(e)}:{next:n,error:c};let i=typeof e==`function`?{next:t=>{try{let n=e(t);n instanceof Promise&&n.catch(e=>r.next(e))}catch(e){r.next(e)}},error:e=>r.next(e)}:{next:t=>e.next(t),error:t=>e.error?e.error(t):r.next(t)},s;try{s=this._subscribe(i)}catch(e){i.error?.(e)}return new a().add(()=>{switch(i.next=c,i.error=c,typeof s){case`function`:s();return;case`object`:s.unsubscribe();return;case`undefined`:return;default:return o(s)}})}pipe(...e){return e.reduce((e,t)=>t(e),this)}_subscribe(e){}}class f extends d{keyCounter=0;subscribers=new Map;constructor(){super()}next(e){this.subscribers.forEach(t=>t.next(e))}error(e){this.subscribers.forEach(t=>t.error?.(e))}_subscribe(e){let t=this.keyCounter++;return this.subscribers.set(t,e),new a().add(()=>this.subscribers.delete(t))}}class p{log$=new f;logs=[];log=e=>{let t={...e,timestamp:Date.now()};this.logs.push(t),this.log$.next(t)};createCustomLog(e){return(...t)=>{let n;try{n=e(...t)}catch{n={message:"error in `createCustomLog`",component:`Logger`}}this.log(n)}}createComponentLog(e){return this.createCustomLog(t=>({component:e,...t}))}getAllLogs=()=>this.logs}function m(e,t=`Assertion "value is not nullable" failed`){if(e==null)throw Error(t)}function h(e,t=`Assertion "value is nullable" failed`){if(e!=null)throw Error(t)}function g(e){return e!=null}function _(e){return e==null}var v=e=>Object.fromEntries(Object.entries(e).filter(([e,t])=>g(t)));function y(e,t){if(!e?.length)throw Error(t)}function b(e,t){if(e?.length)throw Error(t)}var x=()=>globalThis,S=()=>globalThis,C=(e=x())=>!!(e.window&&e.screen),w=typeof x().performance?.now==`function`?()=>x().performance.now():()=>Date.now(),ee=()=>Math.trunc(w());function T(){var e=self,t=new Map;e.onmessage=function(n){var r=n.data;if(r.type===`ping`){e.postMessage({type:`ready`});return}if(r.type===`set`){var i=r.id;r.repeat?t.set(i,{repeat:!0,handle:e.setInterval(function(){e.postMessage({type:`tick`,id:i})},r.delay)}):t.set(i,{repeat:!1,handle:e.setTimeout(function(){t.delete(i),e.postMessage({type:`tick`,id:i})},r.delay)});return}var a=t.get(r.id);a&&(a.repeat?e.clearInterval(a.handle):e.clearTimeout(a.handle),t.delete(r.id))}}var te=()=>`'use strict';(${T.toString()})();`;class ne{worker;handlers;records=new Map;ticks=0;constructor(e,t){this.worker=e,this.handlers=t,this.worker.onmessage=this.handleMessage,this.worker.onerror=this.handleError,this.worker.onmessageerror=this.handleError,this.postCommand({type:`ping`})}static create(e){let t=x();if(typeof t.Worker!=`function`||typeof t.Blob!=`function`||_(t.URL?.createObjectURL))return null;let n=t.URL.createObjectURL(new t.Blob([te()],{type:`text/javascript`}));try{return new ne(new t.Worker(n),e)}catch{return null}finally{t.URL.revokeObjectURL(n)}}get activeCount(){return this.records.size}get deliveredTicks(){return this.ticks}set(e,t,n,r){this.records.set(e,{callback:t,repeat:r,delay:n,startedAt:w()}),this.postCommand({type:`set`,id:e,delay:n,repeat:r})}clear(e){this.records.delete(e)&&this.postCommand({type:`clear`,id:e})}destroy(){let e=new Map(this.records);return this.records.clear(),this.worker.onmessage=null,this.worker.onerror=null,this.worker.onmessageerror=null,this.worker.terminate(),e}postCommand(e){this.worker.postMessage(e)}handleMessage=e=>{if(e.data.type===`ready`){this.handlers.onReady();return}let{id:t}=e.data,n=this.records.get(t);_(n)||(this.ticks++,n.repeat||this.records.delete(t),n.callback())};handleError=()=>{this.handlers.onFatalError(this.destroy())}}var E;(e=>{e.SHARED=`shared`,e.CORE=`core`,e.STATISTICS=`statistics`,e.INTERACTIVE=`interactive`,e.UI=`ui`,e.UI_TV=`ui-tv`})(E||={});var re;(e=>{e.IDLE=`idle`,e.STARTING=`starting`,e.READY=`ready`,e.FAILED=`failed`})(re||={});var ie=1,D=0,O=`idle`,k=null,A=new Map,j=new Set,ae=e=>{let t=w();for(let[n,r]of e){let e=r.repeat?r.delay:Math.max(0,r.delay-(t-r.startedAt));ue(n,r.callback,e,r.repeat)}},oe=e=>{O=`failed`,k=null,ae(e)},se=()=>{_(k)||(ae(k.destroy()),k=null),O=`idle`},ce=()=>{O===`idle`&&(O=`starting`,k=ne.create({onReady:()=>{O=`ready`},onFatalError:oe}))},le=e=>j.has(e)?(ce(),O===`ready`?k:null):null,ue=(e,t,n,r)=>{let i=S();r?A.set(e,{repeat:!0,nativeId:i.setInterval(t,n)}):A.set(e,{repeat:!1,nativeId:i.setTimeout(()=>{A.delete(e),t()},n)})},de=(e,t,n,r)=>{let i=ie++,a=le(e);return _(a)?ue(i,t,n,r):a.set(i,t,n,r),i},fe=e=>{if(_(e))return;let t=A.get(e);if(_(t)){k?.clear(e);return}A.delete(e);let n=S();t.repeat?n.clearInterval(t.nativeId):n.clearTimeout(t.nativeId)},pe=e=>({setTimeout:(t,n=0)=>de(e,t,n,!1),setInterval:(t,n=0)=>de(e,t,n,!0),clearTimeout:fe,clearInterval:fe}),me=e=>{j.clear(),e.forEach(e=>j.add(e)),j.size===0&&se()},he=e=>{D++,me(e)},ge=()=>{D!==0&&(D--,D===0&&me([]))},_e=()=>({workerModules:[...j],workerState:O,liveConsumers:D,activeWindowTimers:A.size,activeWorkerTimers:k?.activeCount??0,workerTicks:k?.deliveredTicks??0}),M=pe(`shared`),ve=(e,t,n)=>new Promise((r,i)=>{t.addEventListener(`abort`,()=>{s(),l.remove()});let a=()=>{s(),i(`error`)},o=()=>{s(),r()},s=()=>{c&&M.clearTimeout(c),l.removeEventListener(`load`,o),l.removeEventListener(`error`,a)},c;n&&(c=M.setTimeout(()=>{s(),i(`timeout`)},n));let l=document.createElement(`script`);l.addEventListener(`load`,o),l.addEventListener(`error`,a),l.src=e,document.head.appendChild(l)}),ye=(e,t)=>async(...n)=>{let r=t(...n),i=e.aborted,a;for(;!i&&!e.aborted;)try{let e=await r.next(a);i=e.done??!1,a=e.value}catch(e){await r.throw(e)}return a},be=(e,{start:t=0,factor:n=2,max:r=1/0,min:i=t,random:a=0}={})=>{let o=t;return o*=n**e,o*=1+(Math.random()*a*2-a),o=Math.round(o),o=Math.min(o,r),o=Math.max(o,i),o},xe={};r(xe,{set:()=>we,remove:()=>Ee,isPersistent:()=>Se,has:()=>Te,get:()=>Ce,clear:()=>De});var N,P,F=`vk-videoplayer-dummy-key-${Math.random()}`,I=()=>{if(P!==void 0)return P;try{localStorage.setItem(F,`test`),localStorage.removeItem(F),P=0}catch(e){if(e instanceof DOMException||e instanceof TypeError)try{sessionStorage.getItem(F),P=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)P=2;else throw e}else throw e}return P===2&&(N=new Map),P},Se=()=>I()===0,Ce=e=>{let t=I();switch(t){case 0:return localStorage.getItem(e)??void 0;case 1:return sessionStorage.getItem(e)??void 0;case 2:return N?.get(e);default:o(t)}},we=(e,t)=>{let n=I();switch(n){case 0:try{localStorage.setItem(e,t)}catch(e){if(e instanceof DOMException)console.error(e);else throw e}break;case 1:try{sessionStorage.setItem(e,t)}catch(e){if(e instanceof DOMException)console.error(e);else throw e}break;case 2:N?.set(e,t);return;default:o(n)}},Te=e=>{let t=I();switch(t){case 0:return e in localStorage;case 1:return e in sessionStorage;case 2:return N?.has(e)??!1;default:return o(t),!1}},Ee=e=>{let t=I();switch(t){case 0:return localStorage.removeItem(e);case 1:return sessionStorage.removeItem(e);case 2:N?.delete(e);return;default:o(t)}},De=()=>{let e=I();switch(e){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return N?.clear();default:o(e)}},Oe=()=>{let e,t=[],n=x();try{e=n.self!==n.top}catch(t){t instanceof DOMException&&t.name===`SecurityError`?e=!0:(e=!1,console.error(t))}try{n.location?.ancestorOrigins&&(t=[...n.location.ancestorOrigins])}catch(e){console.error(e)}try{!t.length&&n.document.referrer&&(t=[new URL(n.document.referrer).origin])}catch(e){console.error(e)}return t=t.filter(e=>URL.canParse(e)),{isEmbed:e,origins:t,topOrigin:t.at(-1),immediateOrigin:t.at(0)}},ke;(e=>{e.INVARIANT=`Invariant quality`,e.Q_144P=`144p`,e.Q_240P=`240p`,e.Q_360P=`360p`,e.Q_480P=`480p`,e.Q_576P=`576p`,e.Q_720P=`720p`,e.Q_1080P=`1080p`,e.Q_1440P=`1440p`,e.Q_2160P=`2160p`,e.Q_4320P=`4320p`})(ke||={});var L={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"576p":{width:1024,height:576},"720p":{width:1280,height:720},"1080p":{width:1920,height:1080},"1440p":{width:2560,height:1440},"2160p":{width:3840,height:2160},"4320p":{width:7680,height:4320}},Ae=(e,t)=>L[e].height>L[t].height,je=(e,t)=>L[e].height>=L[t].height,R=(e,t)=>L[e].height<L[t].height,Me=(e,t)=>L[e].height<=L[t].height,Ne=e=>e.sort((e,t)=>e===t?0:e===`Invariant quality`?1:t===`Invariant quality`?-1:R(e,t)?1:-1)[0],Pe=Object.keys(L).sort((e,t)=>R(e,t)?-1:1),Fe=(e,t=.02)=>[...Pe].find(n=>L[n].height*(1+t)>=e),Ie=({width:e,height:t})=>{let n=Math.min(e,t),r=Math.max(e,t);return Pe.find(e=>{let t=L[e];return t.width>=r&&t.height>=n})},Le=e=>L[e].height,z=e=>e===`Invariant quality`,Re=e=>e.every(e=>!z(e));function ze(e){if(z(e))throw Error(`Expected exact quality`)}var Be=e=>{switch(e){case`4320p`:return`8K`;case`2160p`:return`4K`;case`1440p`:return`QHD`;case`1080p`:return`FHD`;case`720p`:return`HD`;default:return``}},B=(e,t)=>{let n={};for(let r of Object.keys(t)){let i=t[r],a=e[r];Array.isArray(i)?n[r]=Array.isArray(a)?a:i:typeof i==`object`&&i?typeof a==`object`&&a&&!Array.isArray(a)?n[r]=B(a,i):n[r]=a??i:n[r]=r in e?a:i}return n},Ve=e=>{let t=``;return e>=3600&&(t+=Math.floor(e/3600)+`h`,e%=3600),e>=60&&(t+=Math.floor(e/60)+`m`,e%=60),e>0&&(t+=Math.floor(e)+`s`),t};function V(e,t=0,n){let r,i,a,o,s,c,l=0,u=!1,d=!1,f=!0,p=!t&&t!==0&&typeof x().requestAnimationFrame==`function`;n&&(u=!!n.leading,d=`maxWait`in n,a=n?.maxWait?Math.max(+n?.maxWait||0,t):a,f=`trailing`in n?!!n.trailing:f);function m(t){let n=r,a=i;return r=i=void 0,l=t,o=e.apply(a,n),o}function h(e,t){return p?(s&&x().cancelAnimationFrame(s),x().requestAnimationFrame(e)):M.setTimeout(e,t)}function g(e){if(p){x().cancelAnimationFrame(e);return}M.clearTimeout(e)}function _(e){return l=e,s=h(b,t),u?m(e):o}function v(e){let n=e-c,r=e-l,i=t-n;return d?Math.min(i,a-r):i}function y(e){let n=e-c,r=e-l;return c===void 0||n>=t||n<0||d&&r>=a}function b(){let e=Date.now();if(y(e))return S(e);s=h(b,v(e))}function S(e){return s=void 0,f&&r?m(e):(r=i=void 0,o)}function C(){s!==void 0&&g(s),l=0,r=c=i=s=void 0}function w(){return s===void 0?o:S(Date.now())}function ee(){return s!==void 0}function T(...e){let n=Date.now(),a=y(n);if(r=e,i=this,c=n,a){if(s===void 0)return _(c);if(d)return s=h(b,t),m(c)}return s===void 0&&(s=h(b,t)),o}return T.cancel=C,T.flush=w,T.pending=ee,T}var He=(e,t=0,n)=>V(e,t,{leading:!0,trailing:!0,...n,maxWait:t}),H=(e,t)=>{if(typeof e!=`object`||!e)return e;let n=Array.isArray(e)?[]:{};for(let r in e){if(typeof t==`function`){let i=t(e[r],r,e,n);if(i!==void 0){n[r]=i;continue}}typeof e[r]==`object`?n[r]=H(e[r],t):n[r]=e[r]}return n},Ue=e=>H(e);class We extends f{bufferSize;buffer=[];cursorEnd=-1;cursorStart=0;constructor(e){super(),this.bufferSize=e,this.buffer=Array(e)}next(e){this.cursorEnd+=1,this.cursorStart=this.cursorEnd>=this.bufferSize?this.cursorStart+1:0,this.buffer[this.cursorEnd%this.bufferSize]=e,this.subscribers.forEach(t=>t.next(e))}_subscribe(e){for(let t=this.cursorStart;t<=this.cursorEnd;t++)e.next(this.buffer[t%this.bufferSize]);let t=this.keyCounter++;return this.subscribers.set(t,e),new a().add(()=>this.subscribers.delete(t))}}class U extends f{value;constructor(e){super(),this.value=e}next(e){super.next(this.value=e)}error(e){super.error(this.value=e)}getValue(){return this.value}_subscribe(e){let t=super._subscribe(e);return e.next(this.value),t}}function Ge(e){return new d(t=>{let n={},r=Object.keys(e).length,i=e=>i=>{e in n||r--,n[e]=i,r===0&&t.next(n)};return Object.entries(e).reduce((e,[t,n])=>e.add(n.subscribe(i(t))),new a)})}function Ke(...e){return new d(t=>e.reduce((e,n)=>e.add(n.subscribe(t)),new a))}var qe=e=>new d(t=>{let n=M.setTimeout(()=>{try{t.next()}catch(e){if(t.error)t.error(e);else throw e}},e);return()=>M.clearTimeout(n)}),Je=e=>new d(t=>{let n=M.setInterval(()=>t.next(),e);return()=>{n&&=(M.clearInterval(n),void 0)}});function Ye(e){return new d(t=>{if(e instanceof Promise){let n=!1;return e.then(e=>{n||t.next(e)}).catch(e=>{n||t.error?.(e)}),()=>{n=!0}}for(let n=0;n<e.length;n++)t.next(e[n])})}var Xe=Ye,Ze=(e,t)=>new d(n=>{let r=e=>n.next(e);return e.addEventListener(t,r),()=>e.removeEventListener(t,r)});class Qe extends a{remove(e){this.subscriptions=this.subscriptions.filter(t=>t!==e)}}function $e(e){return new d(t=>{let n=Array(e.length),r=e=>r=>{n[e]=r,t.next([...n])};return e.reduce((e,t,n)=>e.add(t.subscribe(r(n))),new a)})}function et(e){return t=>new d(n=>t.subscribe(new tt(n,e)))}class tt{destination;size;lastValues=[];constructor(e,t){this.destination=e,this.size=t}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){this.destination.error?.(e)}}var nt={leading:!1,trailing:!0};function rt(e,t=nt){return n=>new d(r=>n.subscribe(new it(r,e,t)))}class it{destination;time;config;lastValue;timeout;constructor(e,t,n){this.destination=e,this.time=t,this.config=n}next(e){this.lastValue=e,g(this.timeout)?M.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=M.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(e){if(this.destination.error)this.destination.error(e);else throw e}this.timeout=void 0},this.time)}error(e){this.destination.error?.(e)}}var at={leading:!0,trailing:!1};function ot(e,t=at){return n=>new d(r=>n.subscribe(new st(r,e,t)))}class st{destination;time;config;lastValue;timeout;constructor(e,t,n){this.destination=e,this.time=t,this.config=n}next(e){this.lastValue=e,_(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=M.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){this.destination.error?.(e)}}function ct(e){return t=>new d(n=>t.subscribe(new lt(n,e)))}class lt{destination;predicate;constructor(e,t){this.destination=e,this.predicate=t}next(e){let t;try{t=this.predicate(e)}catch(e){throw this.error(e),e}t&&this.destination.next(e)}error(e){this.destination.error?.(e)}}var ut=(e,t)=>{let n=(e,t)=>{let n=Object.keys(e);for(let r in t)if(!n.includes(r)||t[r]!==e[r])return!1;return!0};return n(e,t)&&n(t,e)},dt=(e,t)=>e instanceof Object&&t instanceof Object?ut(e,t):e===t;function ft(e=dt){return t=>new d(n=>t.subscribe(new mt(n,e)))}var pt={};class mt{destination;predicate;lastValue=pt;constructor(e,t){this.destination=e,this.predicate=t}next(e){let t;try{t=this.lastValue===pt||!this.predicate(this.lastValue,e),this.lastValue=e instanceof Object&&!Array.isArray(e)?{...e}:e}catch(e){throw this.error(e),e}t&&this.destination.next(e)}error(e){this.destination.error?.(e)}}function W(e){return t=>new d(n=>t.subscribe(new ht(n,e)))}class ht{destination;mapper;constructor(e,t){this.destination=e,this.mapper=t}next(e){let t;try{t=this.mapper(e)}catch(e){throw this.error(e),e}this.destination.next(t)}error(e){this.destination.error?.(e)}}function gt(e){return W(()=>e)}function _t(){return e=>new d(t=>{let n=!1,r=!1,i=e.subscribe(e=>{n||(n=!0,t.next(e)),r&&i.unsubscribe()},e=>{n=!0,t.error?.(e),r&&i.unsubscribe()});return r=!0,n&&i.unsubscribe(),i})}function vt(){return e=>new d(t=>e.subscribe(new yt(t)))}class yt{destination;last;hasLast=!1;constructor(e){this.destination=e}next(e){let t=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([t,e])}error(e){this.destination.error?.(e)}}function bt(e){return t=>new d(n=>t.subscribe(new xt(n,e)))}class xt{destination;effect;constructor(e,t){this.destination=e,this.effect=t}next(e){try{this.effect(e)}catch(e){throw this.error(e),e}this.destination.next(e)}error(e){this.destination.error?.(e)}}function St(e){return t=>new d(n=>t.subscribe(new Ct(n,e)))}class Ct{destination;count;constructor(e,t){this.destination=e,this.count=t,t<0&&this.destination.error?.(Error(`Count can not be less than zero`))}next(e){this.count===0?this.destination.next(e):this.count--}error(e){this.destination.error?.(e)}}function wt(e=0){return t=>{let n=0,r=new We(e),i=t.subscribe(r),a=e=>()=>{e.unsubscribe(),n--,n===0&&i.unsubscribe()};return new d(e=>(n++,a(r.subscribe(e))))}}var Tt=300,Et=(e,t=Tt)=>new d(n=>{let r=x(),{width:i,height:a}=e.getBoundingClientRect();if(n.next({width:i,height:a}),!C(r))return;let o=new r.ResizeObserver(He(e=>{let t=e[0];if(!t)return;let r,i;t.contentBoxSize&&t.contentBoxSize[0]?(i=t.contentBoxSize[0].blockSize,r=t.contentBoxSize[0].inlineSize):t.contentRect&&(r=t.contentRect.width,i=t.contentRect.height),g(r)&&g(i)&&n.next({width:r,height:i})},t));return o.observe(e),()=>o.disconnect()}),G=(e,t=6,n=`.`)=>{let r={};for(let i in e)if(!(!e.hasOwnProperty(i)||e[i]instanceof HTMLElement||!t))if(typeof e[i]==`object`&&e[i]!==null){let a=G(e[i],t-1);for(let e in a)a.hasOwnProperty(e)&&(r[i+n+e]=a[e])}else r[i]=e[i];return r},Dt=e=>{e.innerHTML=``,e.removeAttribute(`src`),e.load()},Ot=e=>{let t;try{t=new URL(e)}catch{return!1}return t.protocol===`https:`},kt=(e,t)=>!(e.right<t.left||e.left>t.right||e.bottom<t.top||e.top>t.bottom),At=(()=>{let e=0;return()=>{let t=e;return e=(e+1)%(2**53-1),t}})(),jt=e=>e!==void 0&&e!==``?e:At().toString();function Mt(e,t,n){if(e<=t[0])return n[0];if(e>=t[t.length-1])return n[n.length-1];let r=1;for(;r<t.length&&t[r]<e;)r++;r>=t.length&&(r=t.length-1);let i=t[r-1],a=t[r],o=n[r-1],s=n[r];return e===i?o:e===a?s:o+(e-i)/(a-i)*(s-o)}function Nt(e,t,n){if(e<=0||n<0)return[];let r=[],i=Math.floor((e-1)/2),a=Math.floor(e/2),o=t-i,s=t+a;o<0&&(s+=Math.abs(o),o=0),s>n&&(o-=s-n,s=n),o=Math.max(0,o),s=Math.min(n,s);for(let e=o;e<=s;e++)r.push(e);return r}var Pt=e=>e instanceof DOMException&&(e.name===`AbortError`||e.code===20),Ft=e=>{if(!Pt(e))throw e};function It(e){if(e&&typeof e==`object`){if(`message`in e)return String(e.message);try{return JSON.stringify(e)}catch{return`object serialization error`}}return String(e)}class K{buffer;writeIndex=0;count=0;capacity;constructor(e){if(e<=0)throw Error(`Capacity must be greater than 0`);this.capacity=e,this.buffer=Array.from({length:e}).fill(null)}add(e){this.buffer[this.writeIndex]=e,this.writeIndex=(this.writeIndex+1)%this.capacity,this.count<this.capacity&&this.count++}*[Symbol.iterator](){if(this.count===0)return;let e=this.count<this.capacity?0:this.writeIndex;for(let t=0;t<this.count;t++){let t=this.buffer[e];g(t)&&(yield t),e=(e+1)%this.capacity}}clear(){this.buffer.fill(null),this.writeIndex=0,this.count=0}get size(){return this.count}get maxCapacity(){return this.capacity}}var Lt=e=>(t,n=!1)=>r=>{let i=typeof r==`object`;r==null||i&&!Object.keys(r).length||e(t,i?G(r):{value:r},n)},q=(e={})=>{let t=e=>{let t=e;return e===void 0?t=`undefined`:e===null?t=`null`:(typeof e==`number`||typeof e==`boolean`)&&(t=e.toString()),t},n={};for(let r in e)Array.isArray(e[r])?n[r]=e[r].map(t):n[r]=t(e[r]);return n};class J{dynamicImportTimeout=5e3;subscription=new a;options;span;context;childTracers=[];initPromise;getRootTracerContext;eventsBuffer=null;static dynamicImportStatus=`not_started`;static dynamicImports;static dynamicImportPromise;constructor({name:e,getParentContext:t,getRootTracerContext:n,options:r}){this.options=r??{};let{tracerEventsBufferSize:i}=this.options;g(i)&&i>0&&(this.eventsBuffer=new K(i)),J.dynamicImportStatus===`not_started`&&(J.dynamicImportPromise=this.loadOpentelemetry());let a=Date.now();this.initPromise=J.dynamicImportPromise.then(r=>{J.dynamicImportStatus===`completed`&&this.init({name:e,getParentContext:t,getRootTracerContext:n},a)})}init({name:e,getParentContext:t,getRootTracerContext:n},r){let i=n?.();if(_(i))return;let{opentelemetryApi:a}=J.dynamicImports,{context:o,trace:s}=a,{tracer:c,attributes$:l}=i;this.span=c.startSpan(e,{startTime:r},t?.()),this.context=s.setSpan(o.active(),this.span),this.getRootTracerContext=n,this.subscription.add(l.subscribe(e=>{g(e)&&this.span.setAttributes(e)}))}async loadOpentelemetry(){if(J.dynamicImportStatus===`not_started`){J.dynamicImportStatus=`in_progress`;try{let e=new Promise((e,t)=>M.setTimeout(t,this.dynamicImportTimeout)),t=Promise.all([import(`@opentelemetry/api`),import(`@opentelemetry/sdk-trace-web`),import(`@apptracer/opentelemetry`),import(`@opentelemetry/resources`),import(`@opentelemetry/semantic-conventions`)]),[n,r,i,a,o]=await Promise.race([t,e]);J.dynamicImports={opentelemetryApi:n,opentelemetrySdk:r,tracer:i,opentelemetryResources:a,opentelemetrySemanticConventions:o},J.dynamicImportStatus=`completed`}catch{J.dynamicImportStatus=`failed`}}}isComponentTracerNotInitialized(){return _(this.span)||J.dynamicImportStatus===`failed`}addEventToBuffer(e,t,n,r){g(this.eventsBuffer)&&this.eventsBuffer.add({name:e,attributes:t,type:n,timestamp:r})}addEventToSpan(e,t,n,r){this.span.addEvent(e,{...q(t),type:n},r)}log(e,t,n=!1){let r=Date.now();n?this.initPromise.then(n=>{this.isComponentTracerNotInitialized()||this.addEventToSpan(e,t,`log`,r)}):this.addEventToBuffer(e,t,`log`,r)}error(e,t,n=!1){let r=Date.now();n?this.initPromise.then(n=>{this.isComponentTracerNotInitialized()||this.addEventToSpan(e,t,`error`,r)}):this.addEventToBuffer(e,t,`error`,r)}critical(e,t,n=!1){let r=Date.now();n?this.initPromise.then(n=>{this.isComponentTracerNotInitialized()||this.addEventToSpan(e,t,`critical`,r)}):this.addEventToBuffer(e,t,`critical`,r)}createComponentTracer(e){let t=new J({name:e,getParentContext:()=>this.context,getRootTracerContext:()=>this.getRootTracerContext?.(),options:this.options});return this.childTracers.push(t),t}setSpanAttributes(e){this.initPromise.then(t=>{this.isComponentTracerNotInitialized()||this.span.setAttributes(q(e))})}end(){this.initPromise.then(e=>{if(!this.isComponentTracerNotInitialized()){if(g(this.eventsBuffer))for(let e of this.eventsBuffer)this.addEventToSpan(e.name,e.attributes,e.type,e.timestamp);this.childTracers.forEach(e=>e.end()),this.span.end(),this.subscription.unsubscribe()}})}pause(){this.getRootTracerContext?.()?.paused$.next(!0)}resume(){this.getRootTracerContext?.()?.paused$.next(!1)}}var Rt=`gW5EerTD5QhAnsbpF7Hd2NSMRteYIUUMjFbSyI68Pf5`,zt=e=>{class t extends e{_isPaused=!1;_pausedSpans;maxExportBatchSize;maxQueueSize;constructor(e,t){super(e,t),this.maxQueueSize=t?.maxQueueSize??2048,this.maxExportBatchSize=t?.maxExportBatchSize??512,this._pausedSpans=new K(this.maxQueueSize)}pause(){this._isPaused=!0}async resume(){if(!this._isPaused)return;this._isPaused=!1;let e=this._pausedSpans;this._pausedSpans=new K(this.maxQueueSize);let t=0;for(let n of e)super.onEnd(n),t+=1,t>=this.maxExportBatchSize&&(await new Promise(e=>M.setTimeout(()=>e(void 0),0)),t=0);e.clear(),await this.forceFlush()}onEnd(e){if(this._isPaused){this._pausedSpans.add(e);return}super.onEnd(e)}}return t};class Bt extends J{attributes$=new U(null);paused$=new U(!1);constructor(e){super({name:`Root`,options:e}),this.paused$.next(!!this.options.tracerPausedAtInit)}init({name:e,getParentContext:t},n){let{tracer:r,opentelemetryResources:a,opentelemetrySdk:o,opentelemetrySemanticConventions:s}=J.dynamicImports,{TracerUploadSpanExporter:c}=r,{WebTracerProvider:l,BatchSpanProcessor:u}=o,{resourceFromAttributes:d}=a,{ATTR_SERVICE_NAME:f,ATTR_SERVICE_VERSION:p}=s,m=new(zt(u))(new c({appToken:Rt}));this.subscription.add(this.paused$.subscribe(e=>{e?m.pause():m.resume()}));let h=new l({resource:d({[f]:`videoplayer-sdk-web`,[p]:i}),spanLimits:{attributeCountLimit:1/0,eventCountLimit:1/0,attributePerEventCountLimit:1/0},spanProcessors:[m]});h.register();let g=h.getTracer(`sdk-videoplayer-tracer`);super.init({name:e,getParentContext:t,getRootTracerContext:()=>({tracer:g,attributes$:this.attributes$,paused$:this.paused$})},n)}getTraceId(){return this.isComponentTracerNotInitialized()?``:this.span.spanContext().traceId}setSpanAttributes(e){this.attributes$.next({...this.attributes$.getValue(),...q(e)})}addSubscription(e){this.subscription.add(e)}}class Vt{fakeTraceId;constructor(e){}log(e,t,n){}error(e,t,n){}critical(e,t,n){}createComponentTracer(e){return new Vt({name:e})}end(){}getTraceId(){return this.fakeTraceId}addSubscription(e){}setSpanAttributes(e){}pause(){}resume(){}}var Ht=()=>!0,Y={level:0,filter:Ht,name:`Noname Tracer`,outputMethod:`log`};class Ut{name;filter=Ht;level=Y.level;outputMethod=Y.outputMethod;childTracers=[];constructor({name:e,level:t,filter:n,outputMethod:r}={}){this.filter=n??this.filter,this.level=t??this.level,this.outputMethod=r??this.outputMethod,this.name=e??Y.name}log(e,t,n){this.logDebug(e,t)}error(e,t,n){this.logError(e,t)}critical(e,t,n){this.logError(e,t)}createComponentTracer(e){let t=new Ut({filter:this.filter,level:this.level,name:`${this.name}/ ${e}`,outputMethod:this.outputMethod});return this.childTracers.push(t),t}end(){this.childTracers.forEach(e=>e.end()),this.childTracers=[]}setLevel(e){this.level=e,this.childTracers.forEach(t=>t.setLevel(e))}setOtputMethod(e){this.outputMethod=e,this.childTracers.forEach(t=>t.setOtputMethod(e))}setFilter(e){this.filter=e,this.childTracers.forEach(t=>t.setFilter(e))}getFinishedSpans(){}getTraceId(){return`debug_trace`}get verbose(){return this.level===0}createMessage(e,t){return[this.name,e,JSON.stringify(t)].join(`: `)}logDebug(e,t){!this.verbose||!this.filter(e,t)||x().console[this.outputMethod](this.createMessage(e,t))}logError(e,t){this.filter(e,t)&&x().console.error(this.createMessage(e,t))}addSubscription(e){}setSpanAttributes(e){}pause(){}resume(){}}class Wt{static createRootTracer(e=`fake`,t){switch(e){case`real`:return new Bt(t);case`debug`:return new Ut;default:return new Vt}}}var Gt;(e=>{e.MediaError=`mediaError`,e.SegmentFetcher=`segment_fetcher`,e.SegmentAppend=`segment_append`,e.Hangup=`hangup`,e.Stall=`stall`})(Gt||={});var Kt;(e=>{e.NETWORK=`network`,e.VIDEO_PIPELINE=`video_pipeline`,e.EXTERNAL_API=`external_api`,e.PARSER=`parser`,e.DOM=`dom`,e.WTF=`wtf`,e.UI=`ui`,e.CALL_FROM_EXTERNAL=`call_from_external`,e.FATAL=`fatal`})(Kt||={});var qt;(e=>{e.Armenian=`58`,e.Azerbaijani=`57`,e.Belarusian=`114`,e.English=`3`,e.Kazakh=`97`,e.Portuguese=`73`,e.Russian=`0`,e.Spanish=`4`,e.Ukrainian=`1`,e.Uzbek=`65`,e.Vietnamese=`75`})(qt||={});var Jt=`vk.ru`,Yt=async(e,t,n)=>{let r=new URL(`https://${Jt}/js/lang-pack.js`);return r.searchParams.set(`format`,`json`),r.searchParams.set(`name`,t),e!==void 0&&r.searchParams.set(`lang`,e),Xt(await(await fetch(r.toString())).json(),n)},Xt=(e,t)=>Object.fromEntries(Object.entries(e.keys).map(([e,n])=>[e.substring(`${t}_`.length),Zt(n)])),Zt=e=>Array.isArray(e)?e[0]:e,Qt;(e=>{e.RU=`ru`,e.EN=`en`})(Qt||={});var X=`__vk_vp_internals_exposure`;class $t{playerId;type;constructor(e,t){this.playerId=t,this.type=e,this.initWindowObjects()}getWindowObject(){if(typeof window>`u`)return{};let e=this.playerId,t=this.type;return window[X]?.[e]?.[t]??{}}initWindowObjects(){if(typeof window>`u`)return;let e=this.playerId,t=this.type;window[X]||(window[X]={}),window[X][e]||(window[X][e]={}),window[X][e][t]||(window[X][e][t]={})}expose(e){typeof window>`u`||Object.assign(this.getWindowObject(),e)}destroy(){if(typeof window>`u`)return;let e=this.playerId,t=this.type;window[X]&&window[X][e]&&window[X][e][t]&&(delete window[X][e][t],Object.keys(window[X][e]).length||delete window[X][e],Object.keys(window[X]).length||delete window[X])}}var en={};r(en,{subscribe:()=>an,push:()=>rn,destroy:()=>nn,create:()=>tn});var Z=new Map,tn=(e,t)=>Z.set(e,t??[]),nn=e=>Z.delete(e),rn=(e,t)=>{let n=Z.get(e);n&&(typeof n==`function`?n(t):n.push(t))},an=(e,t)=>{let n=Z.get(e);if(n){if(n&&Array.isArray(n))for(let e of n)t(e);Z.set(e,t)}},on=e=>v({id:e.id,message:e.message,category:e.category,data:sn(e.data),httpCode:e.httpCode,UVBackendErrorCode:e.UVBackendErrorCode});function sn(e){switch(typeof e){case`boolean`:case`string`:case`number`:return e;case`object`:try{return JSON.stringify(e)}catch{return}default:return}}var cn=e=>{let t=e.thrown instanceof Error?e.thrown:Error(e.message),n=e.id.length>10240?e.id.substring(0,10240):e.id;try{t.name=n}catch{t=Error(e.message),t.name=n}return t},ln=()=>{try{let{origin:e,pathname:t,search:n,hostname:r}=x()?.document?.location??{};return!r||r===`localhost`?void 0:{url:e+t,...new URLSearchParams(n).entries().reduce((e,[t,n])=>(e[`url.${t}`]=n,e),{})}}catch{}};class Q{static tracerModulesMap=new Map;static appTracerModule=null;static loadPromise=null;dynamicImportTimeout=5e3;componentName;subscription=new a;options;envParams;context;beforeInitLogs=[];isEmbed;embedParent;beforeInitErrors=[];constructor(e,t,n,r){this.componentName=e,this.options=t,this.envParams=n,this.context={...r};let{isEmbed:i,topOrigin:a}=Oe();this.isEmbed=i,this.embedParent=a?new URL(a).hostname:void 0,this.options.enabled&&(this.loadModule(),this.init())}updateContext(e){Object.assign(this.context,e)}log(e){let t=Q.tracerModulesMap.get(this.componentName)?.log;if(_(t)){this.beforeInitLogs.push(e);return}t.log(e)}error(e,t){let n=Q.tracerModulesMap.get(this.componentName)?.error;if(!n){this.beforeInitErrors.push([e,t]);return}let{blackErrorCategoryList:r,blackErrorIdList:i,sampleRate:a,whiteErrorCategoryList:o,whiteErrorIdList:s}=this.options,{id:c,category:l}=e;if(!(r.length&&r.includes(l)||i.length&&i.includes(c)||o.length&&!o.includes(l)||s.length&&!s.includes(c)||Math.random()>=a))try{let r=cn(e);n?.error(r,{crashIdSource:t?.crashIdSource??r.name,severity:t?.severity??(e.traceAsLog?`debug`:void 0),...t?.issueKey?{issueKey:t.issueKey}:{},keys:{...this.context,...on(e),...ln(),...this.isEmbed&&this.embedParent&&{iframe_host:this.embedParent}}})}catch(e){console.error(e)}}addSubscription(e){this.subscription.add(e)}destroy(){this.subscription.unsubscribe()}async init(){try{if(await Q.loadPromise,_(Q.appTracerModule))return;let{appTracerModule:e}=Q,{initTracerError:t,initTracerErrorUploader:n,getTracerModules:r,initTracerLog:i}=e,a=Q.tracerModulesMap.get(this.componentName)??r(this.componentName),o=a.log??i(this.componentName),s=a.error??t(this.componentName,{enableUnhandledErrorsListeners:!1,stringifyErrorDataObject:!0});Q.tracerModulesMap.set(this.componentName,{error:s,log:o}),this.beforeInitLogs.forEach(e=>this.log(e)),this.beforeInitLogs=[],g(this.options.userId)&&s.setUserId(this.options.userId),_(a.error)&&n(this.componentName,{appToken:Rt,environment:this.envParams.env,versionCode:1,versionName:this.envParams.version}),this.beforeInitErrors.forEach(e=>this.error.apply(this,e)),this.beforeInitErrors=[]}catch(e){console.error(e)}}loadModule(){g(Q.loadPromise)||(Q.loadPromise=(async()=>{try{let e=new Promise((e,t)=>M.setTimeout(t,this.dynamicImportTimeout));Q.appTracerModule=await Promise.race([e,import(`@apptracer/sdk/lite`)])}catch(e){Q.loadPromise=null,console.error(e)}})())}}class un{options;symbol;constructor(e,t){this.options=t,this.symbol=Symbol(e)}}var dn=()=>{let e=new Map,t=new Map,n=new Map,r=new Map,i=new Set;return{resolve(e){if(!r.has(e)){let t=n.get(e);if(!t)throw Error(`No constructor registered in DI container for ${e.name}`);r.set(e,new t)}return r.get(e)},resolveOptional(e){try{return this.resolve(e)}catch{return}},replace(e,t){r.forEach((t,n)=>{t instanceof e&&r.delete(n)}),n.set(e,t)},getToken(n){if(e.has(n.symbol))return e.get(n.symbol);if(t.has(n.symbol)){let r=t.get(n.symbol)();return e.set(n.symbol,r),r}if(n.options?.factory){let t=n.options.factory();return e.set(n.symbol,t),t}throw Error(`No value registered in DI container for token "${n.symbol.description}"`)},registerToken(t,n){e.set(t.symbol,n)},registerFactory(e,n){t.set(e.symbol,n)},hasToken(n){return e.has(n.symbol)||t.has(n.symbol)||!!n.options?.factory},registerCleanup(e){i.add(e)},clear(){i.forEach(e=>e()),i.clear(),e.clear(),t.clear(),r.clear(),n.clear()}}};class fn{_inputNode;_outputNode;_plugins=[];_destination=null;_taps=[];constructor(e){this._inputNode=e.createGain(),this._outputNode=e.createGain()}get input(){return this._inputNode}get plugins(){return this._plugins}connectTo(e){this._destination=e,this.rebuild()}addTap(e){this._taps.push(e),this._outputNode.connect(e)}hasPlugin(e){return this._plugins.some(t=>t.id===e)}addPlugin(e){this.hasPlugin(e.id)||(this._plugins.push(e),this.rebuild())}removePlugin(e){let t=this._plugins.findIndex(t=>t.id===e);t!==-1&&(this._plugins.splice(t,1),this.rebuild())}rebuild(){this._inputNode.disconnect();for(let e of this._plugins)e.outputNode.disconnect();this._outputNode.disconnect();let e=this._inputNode;for(let t of this._plugins)e.connect(t.inputNode),e=t.outputNode;e.connect(this._outputNode),this._destination!==null&&this._outputNode.connect(this._destination);for(let e of this._taps)this._outputNode.connect(e)}}class pn{_pluginChain;_element;_ctx;_sourceNode=null;_isBound=!1;constructor(e,t,n){this._element=e,this._ctx=t,this._pluginChain=new fn(t),this._pluginChain.connectTo(n)}get isBound(){return this._isBound}get plugins(){return this._pluginChain.plugins}bind(){this._isBound||=(this._sourceNode===null&&(this._sourceNode=this._ctx.createMediaElementSource(this._element)),this._sourceNode.disconnect(),this._sourceNode.connect(this._pluginChain.input),!0)}unbind(){this._isBound&&=(this._sourceNode?.disconnect(),this._sourceNode?.connect(this._ctx.destination),!1)}addPlugin(e){this._pluginChain.addPlugin(e)}removePlugin(e){this._pluginChain.removePlugin(e)}addAnalyser(e){this._pluginChain.addTap(e)}}class mn{_ctx=null;_masterGain=null;_connections=new Map;_contextEnabled=!1;_boundBeforeDisable=new Set;static isSupported(){let e=x();return g(e.AudioContext??e.webkitAudioContext)}get context(){if(_(this._ctx)){let e=x(),t=e.AudioContext??e.webkitAudioContext;this._ctx=new t}return this._ctx}get contextState(){return this._contextEnabled?this._ctx?.state??`suspended`:`suspended`}async enableContext(){this.ensureContext(),await this._ctx?.resume(),this._contextEnabled=!0;for(let e of this._boundBeforeDisable)this._connections.get(e)?.bind();this._boundBeforeDisable.clear()}async disableContext(){this._contextEnabled=!1;for(let[e,t]of this._connections)t.isBound&&(this._boundBeforeDisable.add(e),t.unbind())}async connectSource(e){this.ensureContext(),this._contextEnabled=!0,await this._ctx?.resume();let t=this._connections.get(e);if(t!==void 0){t.isBound||t.bind();return}let n=new pn(e,this.context,this._masterGain);n.bind(),this._connections.set(e,n)}disconnectSource(e){this._connections.get(e)?.unbind()}isSourceConnected(e){return this._connections.get(e)?.isBound??!1}addPlugin(e,t){let n=this._connections.get(e);if(n===void 0)throw Error(`Source is not connected. Call connectSource() first.`);n.addPlugin(t)}removePlugin(e,t){this._connections.get(e)?.removePlugin(t)}getPlugins(e){return this._connections.get(e)?.plugins??[]}createAnalyser(e){let t=this._connections.get(e);if(t===void 0)return null;let n=this.context.createAnalyser();return n.fftSize=256,n.smoothingTimeConstant=.8,t.addAnalyser(n),n}setMasterVolume(e){this._masterGain!==null&&(this._masterGain.gain.value=e)}getMasterVolume(){return this._masterGain?.gain.value??1}dispose(){this._connections.clear(),this._boundBeforeDisable.clear(),this._masterGain=null,this._contextEnabled=!1,this._ctx?.close(),this._ctx=null}ensureContext(){let e=this.context;_(this._masterGain)&&(this._masterGain=e.createGain(),this._masterGain.gain.value=1,this._masterGain.connect(e.destination))}}class hn{id=`volume-fader`;_gainNode;_duration;_curve;_fade=null;constructor(e,t){this._gainNode=e.createGain(),this._gainNode.gain.value=1,this._duration=t.duration,this._curve=t.curve??this._buildEasingCurve(t.duration/1e3)}get inputNode(){return this._gainNode}get outputNode(){return this._gainNode}get faded(){return this._fade!==null}appear(){this._startFade(0,1)}disappear(){this._startFade(1,0)}pause(){if(this._fade===null)return;let e=this._gainNode.gain,t=this._gainNode.context.currentTime,n=t-this._fade.startTime,r=Math.max(0,this._fade.remaining-n);if(r<=.001){this._finishFade();return}let i=this._sampleIndex(this._fade,t),a=this._fade.curve[i];e.cancelScheduledValues(t),e.setValueAtTime(a,t),this._fade={from:a,target:this._fade.target,startTime:t,remaining:r,curve:this._fade.curve.subarray(i)}}resume(){if(this._fade===null)return;let e=this._gainNode.context.currentTime,{from:t,target:n,remaining:r,curve:i}=this._fade;if(r<=.001||Math.abs(n-t)<.001||i.length<2){this._finishFade();return}this._fade={from:t,target:n,startTime:e,remaining:r,curve:i},this._scheduleCurve(i,t,e,r)}cancel(){this._fade!==null&&this._finishFade()}_finishFade(){if(this._fade===null)return;let e=this._gainNode.gain,t=this._gainNode.context.currentTime;e.cancelScheduledValues(t),e.setValueAtTime(this._fade.target,t),this._fade=null}_startFade(e,t){let n=this._gainNode.gain,r=this._gainNode.context.currentTime,i=this._duration/1e3;if(i<=0){n.cancelScheduledValues(r),n.setValueAtTime(t,r),this._fade=null;return}let a=new Float32Array(this._curve.length);for(let n=0;n<this._curve.length;n++)a[n]=e+(t-e)*this._curve[n];this._fade={from:a[0],target:t,startTime:r,remaining:i,curve:a},this._scheduleCurve(a,a[0],r,i)}_buildEasingCurve(e){let t=Math.max(2,Math.ceil(e*60)),n=new Float32Array(t);for(let e=0;e<t;e++){let r=e/(t-1);n[e]=(1-Math.cos(Math.PI*r))/2}return n}_scheduleCurve(e,t,n,r){let i=this._gainNode.gain;i.cancelScheduledValues(n),i.setValueAtTime(t,n),i.setValueCurveAtTime(e,n,r)}_sampleIndex(e,t){let n=t-e.startTime,r=Math.max(0,Math.min(1,n/e.remaining));return Math.min(Math.round(r*(e.curve.length-1)),e.curve.length-1)}}class gn{_filter;_source;_defaultGain;frequency;constructor(e,t,n,r){this.frequency=t,this._source=n,this._defaultGain=r,this._filter=e.createBiquadFilter(),this._filter.type=`peaking`,this._filter.frequency.value=t,this._filter.gain.value=0,this._filter.Q.value=1,this._source.connect(this._filter.gain)}get value(){return this._source.offset.value}get node(){return this._filter}set(e){this._source.offset.value=e}reset(){this.set(this._defaultGain)}dispose(){this._source.disconnect(this._filter.gain)}}class ${id=`equalizer`;static _sources=new WeakMap;_inputNode;_outputNode;_filterMap=new Map;equalizer;constructor(e,t){this._inputNode=e.createGain(),this._outputNode=e.createGain();let n=Object.entries(t).map(([e,t])=>[Number(e),t]).filter(([e])=>Number.isFinite(e)).sort((e,t)=>e[0]-t[0]),r=$._sources.get(e);_(r)&&(r=new Map,$._sources.set(e,r));for(let[t,i]of n)if(!r.has(t)){let n=e.createConstantSource();n.offset.value=i,n.start(),r.set(t,n)}let i={};for(let[t,a]of n){let n=r.get(t);if(!n)continue;let o=new gn(e,t,n,a);this._filterMap.set(t,o),i[t]=o}this.equalizer=i,this.rebuild()}get inputNode(){return this._inputNode}get outputNode(){return this._outputNode}resetAll(){for(let e of this._filterMap.values())e.reset()}dispose(){for(let e of this._filterMap.values())e.dispose()}rebuild(){this._inputNode.disconnect();for(let e of this._filterMap.values())e.node.disconnect();this._outputNode.disconnect();let e=this._inputNode;for(let t of this._filterMap.values())e.connect(t.node),e=t.node;e.connect(this._outputNode)}}var _n=-14;class vn{id=`normalizer`;_compressor;_gainNode;constructor(e,t){this._compressor=e.createDynamicsCompressor(),this._gainNode=e.createGain(),this.applyConfig(t),this._compressor.connect(this._gainNode)}get inputNode(){return this._compressor}get outputNode(){return this._gainNode}applyConfig(e){if(!Number.isFinite(e.lufs)||!Number.isFinite(e.peak)){this._gainNode.gain.value=1;return}this._compressor.threshold.value=e.peak,this._compressor.knee.value=0,this._compressor.ratio.value=20,this._compressor.attack.value=.003,this._compressor.release.value=.25;let t=(e.targetLufs??_n)-e.lufs;this._gainNode.gain.value=10**(t/20)}}export{v as withoutNullable,Ie as videoSizeToQuality,Le as videoQualityToHeight,Fe as videoHeightToQuality,qe as timeout,Ve as timeCodeToString,He as throttleFn,ot as throttle,bt as tap,Ft as suppressAbort,St as skip,wt as shareReplay,xe as safeStorage,he as retainTimers,ge as releaseTimers,vt as pairwise,_t as once,Et as observeElementSize,Xe as observableFrom,ee as nowInt,w as now,c as noop,Ke as merge,gt as mapTo,W as map,Yt as loadVKLangPack,Ot as isValidURL,_ as isNullable,g as isNonNullable,Me as isLowerOrEqual,R as isLower,z as isInvariantQuality,kt as isIntersecting,je as isHigherOrEqual,Ae as isHigher,C as isBrowserWindow,Pt as isAbortError,Je as interval,Mt as interpolate,x as getWindow,Be as getVideoQualityLabel,Lt as getTraceSubscriptionMethod,_e as getTimersDiagnostics,S as getTimerWindow,Nt as getRangeAroundIndex,jt as getPlayerId,It as getMessageFromError,Ne as getHighestQuality,be as getExponentialDelay,Ze as fromEvent,G as flattenObject,ft as filterChanged,ct as filter,B as fillWithDefault,en as devNull,Oe as detectEmbed,V as debounceFn,rt as debounce,pe as createTimers,dn as createDIContainer,$e as combineLatest,Ge as combine,H as cloneDeepWith,Ue as cloneDeep,Dt as clearVideoElement,s as checkNever,et as buffer,ze as assertQualityIsExact,h as assertNullable,y as assertNotEmptyArray,m as assertNonNullable,o as assertNever,b as assertEmptyArray,Re as areQualitiesExact,ve as addScript,ye as abortable,re as WorkerState,hn as VolumeFaderPlugin,ke as VideoQuality,U as ValueSubject,qt as VKNumericLanguage,i as VERSION,Wt as TracerFactory,E as TimerModule,Qe as SubscriptionRemovable,a as Subscription,f as Subject,We as ReplaySubject,d as Observable,vn as NormalizerPlugin,p as Logger,$t as InternalsExposure,Qt as InterfaceLanguage,un as InjectionToken,X as INTERNAL_EXPOSE_GLOBAL_KEY,Gt as ErrorOrigin,Kt as ErrorCategory,$ as EqualizerPlugin,K as CircularBuffer,mn as AudioGraph,Q as AppTracer};
|
package/package.json
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import type { ISubscription } from "../reactive";
|
|
2
|
-
import type { ITracerError, ITracerErrorData } from "@apptracer/sdk/lite";
|
|
2
|
+
import type { ITracerError, ITracerErrorData, ITracerLog } from "@apptracer/sdk/lite";
|
|
3
3
|
import type { AppTracerSdk, IAppTracerContext, IAppTracerEnvParams, IAppTracerOptions, IComponentName } from "./types";
|
|
4
4
|
import type { IError } from "../types";
|
|
5
|
+
/**
|
|
6
|
+
* пара модулей трейсера на componentName: error + log.
|
|
7
|
+
* модули SDK создаются один раз на имя — повторная инициализация приведет к ошибке
|
|
8
|
+
*/
|
|
9
|
+
interface ITracerModules {
|
|
10
|
+
error: ITracerError;
|
|
11
|
+
log: ITracerLog;
|
|
12
|
+
}
|
|
5
13
|
export declare class AppTracer {
|
|
6
|
-
protected static readonly
|
|
14
|
+
protected static readonly tracerModulesMap: Map<IComponentName, ITracerModules>;
|
|
7
15
|
protected static appTracerModule: typeof AppTracerSdk | null;
|
|
8
16
|
protected static loadPromise: Promise<unknown> | null;
|
|
9
17
|
private readonly dynamicImportTimeout;
|
|
@@ -12,6 +20,7 @@ export declare class AppTracer {
|
|
|
12
20
|
private readonly options;
|
|
13
21
|
private readonly envParams;
|
|
14
22
|
private context;
|
|
23
|
+
private beforeInitLogs;
|
|
15
24
|
private readonly isEmbed;
|
|
16
25
|
private readonly embedParent;
|
|
17
26
|
private beforeInitErrors;
|
|
@@ -25,9 +34,15 @@ export declare class AppTracer {
|
|
|
25
34
|
/** Обновляет контекст динамически. Новые значения будут добавлены к существующим.
|
|
26
35
|
* ⚠️ у трайсера есть ограничение на длинну значения в 128 ⚠️ */
|
|
27
36
|
updateContext(context: IAppTracerContext): void;
|
|
37
|
+
/**
|
|
38
|
+
* Добавляет сообщение в лог, который прикладывается к каждому error-репорту.
|
|
39
|
+
* Лог циклический и ограничен (~64Кб), поэтому пишет в него стоит только важное.
|
|
40
|
+
*/
|
|
41
|
+
log(message: string): void;
|
|
28
42
|
error(error: IError, errorData?: Partial<Pick<ITracerErrorData, "severity" | "issueKey" | "crashIdSource">>): void;
|
|
29
43
|
addSubscription(item: Parameters<ISubscription["add"]>[0]): void;
|
|
30
44
|
destroy(): void;
|
|
31
45
|
private init;
|
|
32
46
|
private loadModule;
|
|
33
47
|
}
|
|
48
|
+
export {};
|
package/types/index.d.ts
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IObservable } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Создаёт Observable, который состоит из объектов, ключами которых являются последние значения исходных Observable.
|
|
4
|
+
* Первое событие возникает тогда, когда каждый исходный Observable выдал хотя бы одно значение.
|
|
5
|
+
*/
|
|
6
|
+
export default function combineLatest(observables: Array<IObservable<unknown>>): IObservable<unknown[]>;
|
|
@@ -10,6 +10,7 @@ export { default as interval } from "./interval";
|
|
|
10
10
|
export { default as observableFrom } from "./observableFrom";
|
|
11
11
|
export { default as fromEvent } from "./fromEvent";
|
|
12
12
|
export { default as SubscriptionRemovable } from "./SubscriptionRemovable";
|
|
13
|
+
export { default as combineLatest } from "./combineLatest";
|
|
13
14
|
export { default as buffer } from "./operators/buffer";
|
|
14
15
|
export { default as debounce } from "./operators/debounce";
|
|
15
16
|
export { default as throttle } from "./operators/throttle";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type DebugData = {
|
|
2
|
+
version?: string;
|
|
3
|
+
viewport?: string;
|
|
4
|
+
provider?: string;
|
|
5
|
+
cdn?: string;
|
|
6
|
+
id?: number;
|
|
7
|
+
volume: number;
|
|
8
|
+
muted: boolean;
|
|
9
|
+
videoSize?: string;
|
|
10
|
+
videoBuffer?: number;
|
|
11
|
+
audioBuffer?: number;
|
|
12
|
+
nativeVideoBuffer?: number;
|
|
13
|
+
nativeAudioBuffer?: number;
|
|
14
|
+
position?: number;
|
|
15
|
+
speed?: number;
|
|
16
|
+
bitrate?: number;
|
|
17
|
+
liveLatency?: number;
|
|
18
|
+
currentVideoSegmentLength?: number;
|
|
19
|
+
currentAudioSegmentLength?: number;
|
|
20
|
+
vsid?: string;
|
|
21
|
+
videoCodec?: string;
|
|
22
|
+
audioCodec?: string;
|
|
23
|
+
hdr?: boolean;
|
|
24
|
+
audioLanguage?: string;
|
|
25
|
+
};
|
package/types/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const isAbortError: (e:
|
|
1
|
+
export declare const isAbortError: (e: unknown) => e is DOMException;
|
|
2
2
|
export declare const suppressAbort: (e: Error | unknown) => void | never;
|