@vkontakte/videoplayer-shared 1.0.83-dev.e26cf73b.0 → 1.0.83-dev.e547b9bb.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/evergreen.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @vkontakte/videoplayer-shared v1.0.83-dev.e26cf73b.0
3
- * Mon, 02 Mar 2026 15:52:45 GMT
2
+ * @vkontakte/videoplayer-shared v1.0.83-dev.e547b9bb.0
3
+ * Thu, 05 Mar 2026 12:18:44 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-83/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.83-dev.e26cf73b.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=(e=x())=>!!(e.window&&e.screen),ee=(e,t,n)=>new Promise((r,i)=>{t.addEventListener(`abort`,()=>{s(),l.remove()});let a=()=>{s(),i(`error`)},o=()=>{s(),r()},s=()=>{c&&clearTimeout(c),l.removeEventListener(`load`,o),l.removeEventListener(`error`,a)},c;n&&(c=x().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)}),te=typeof x().performance?.now==`function`?()=>x().performance.now():()=>Date.now(),C=(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},w=(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},T={};r(T,{set:()=>ie,remove:()=>oe,isPersistent:()=>ne,has:()=>ae,get:()=>re,clear:()=>se});var E,D,O=`vk-videoplayer-dummy-key-${Math.random()}`,k=()=>{if(D!==void 0)return D;try{localStorage.setItem(O,`test`),localStorage.removeItem(O),D=0}catch(e){if(e instanceof DOMException||e instanceof TypeError)try{sessionStorage.getItem(O),D=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)D=2;else throw e}else throw e}return D===2&&(E=new Map),D},ne=()=>k()===0,re=e=>{let t=k();switch(t){case 0:return localStorage.getItem(e)??void 0;case 1:return sessionStorage.getItem(e)??void 0;case 2:return E?.get(e);default:o(t)}},ie=(e,t)=>{let n=k();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:E?.set(e,t);return;default:o(n)}},ae=e=>{let t=k();switch(t){case 0:return e in localStorage;case 1:return e in sessionStorage;case 2:return E?.has(e)??!1;default:return o(t),!1}},oe=e=>{let t=k();switch(t){case 0:return localStorage.removeItem(e);case 1:return sessionStorage.removeItem(e);case 2:E?.delete(e);return;default:o(t)}},se=()=>{let e=k();switch(e){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return E?.clear();default:o(e)}},ce=()=>{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)}},A;(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`})(A||={});var j={"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}},le=(e,t)=>j[e].height>j[t].height,ue=(e,t)=>j[e].height>=j[t].height,M=(e,t)=>j[e].height<j[t].height,de=(e,t)=>j[e].height<=j[t].height,fe=e=>e.sort((e,t)=>e===t?0:e===`Invariant quality`?1:t===`Invariant quality`?-1:M(e,t)?1:-1)[0],N=Object.keys(j).sort((e,t)=>M(e,t)?-1:1),pe=(e,t=.02)=>[...N].find(n=>j[n].height*(1+t)>=e),me=({width:e,height:t})=>{let n=Math.min(e,t),r=Math.max(e,t);return N.find(e=>{let t=j[e];return t.width>=r&&t.height>=n})},he=e=>j[e].height,P=e=>e===`Invariant quality`,ge=e=>e.every(e=>!P(e));function _e(e){if(P(e))throw Error(`Expected exact quality`)}var ve=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``}},F=(e,t)=>{let n={};for(let r of Object.keys(t)){let i=t[r],a=e[r];Array.isArray(i)&&Array.isArray(a)?n[r]=a:typeof i==`object`&&typeof a==`object`?n[r]=F(a,i):n[r]=r in e?a:i}return n},ye=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 I(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)):setTimeout(e,t)}function g(e){if(p){x().cancelAnimationFrame(e);return}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 ee(){s!==void 0&&g(s),l=0,r=c=i=s=void 0}function te(){return s===void 0?o:S(Date.now())}function C(){return s!==void 0}function w(...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 w.cancel=ee,w.flush=te,w.pending=C,w}var L=(e,t=0,n)=>I(e,t,{leading:!0,trailing:!0,...n,maxWait:t}),R=(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]=R(e[r],t):n[r]=e[r]}return n},be=e=>R(e);class z 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 xe 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 Se(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 Ce(...e){return new d(t=>e.reduce((e,n)=>e.add(n.subscribe(t)),new a))}var we=e=>new d(t=>{let n=x().setTimeout(()=>{try{t.next()}catch(e){if(t.error)t.error(e);else throw e}},e);return()=>x().clearTimeout(n)}),Te=e=>new d(t=>{let n=x(),r=n.setInterval(()=>t.next(),e);return()=>{r&&=(n.clearInterval(r),void 0)}}),Ee=e=>new d(t=>{e.forEach(e=>t.next(e))}),De=(e,t)=>new d(n=>{let r=e=>n.next(e);return e.addEventListener(t,r),()=>e.removeEventListener(t,r)});class Oe extends a{remove(e){this.subscriptions=this.subscriptions.filter(t=>t!==e)}}function ke(e){return t=>new d(n=>t.subscribe(new Ae(n,e)))}class Ae{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 je={leading:!1,trailing:!0};function Me(e,t=je){return n=>new d(r=>n.subscribe(new Ne(r,e,t)))}class Ne{destination;time;config;lastValue;timeout;constructor(e,t,n){this.destination=e,this.time=t,this.config=n}next(e){this.lastValue=e;let t=x();g(this.timeout)?t.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=t.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 Pe={leading:!0,trailing:!1};function Fe(e,t=Pe){return n=>new d(r=>n.subscribe(new Ie(r,e,t)))}class Ie{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=x().setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){this.destination.error?.(e)}}function Le(e){return t=>new d(n=>t.subscribe(new Re(n,e)))}class Re{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 ze=(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)},Be=(e,t)=>e instanceof Object&&t instanceof Object?ze(e,t):e===t;function Ve(e=Be){return t=>new d(n=>t.subscribe(new He(n,e)))}var B={};class He{destination;predicate;lastValue=B;constructor(e,t){this.destination=e,this.predicate=t}next(e){let t;try{t=this.lastValue===B||!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 V(e){return t=>new d(n=>t.subscribe(new Ue(n,e)))}class Ue{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 We(e){return V(()=>e)}function Ge(){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 Ke(){return e=>new d(t=>e.subscribe(new qe(t)))}class qe{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 Je(e){return t=>new d(n=>t.subscribe(new Ye(n,e)))}class Ye{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 Xe(e){return t=>new d(n=>t.subscribe(new Ze(n,e)))}class Ze{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 Qe(e=0){return t=>{let n=0,r=new z(e),i=t.subscribe(r),a=e=>()=>{e.unsubscribe(),n--,n===0&&i.unsubscribe()};return new d(e=>(n++,a(r.subscribe(e))))}}var $e=300,et=(e,t=$e)=>new d(n=>{let r=x(),{width:i,height:a}=e.getBoundingClientRect();if(n.next({width:i,height:a}),!S(r))return;let o=new r.ResizeObserver(L(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()}),H=(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=H(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},tt=e=>{e.removeAttribute(`src`),e.load()},nt=e=>{let t;try{t=new URL(e)}catch{return!1}return t.protocol===`https:`},rt=(e,t)=>!(e.right<t.left||e.left>t.right||e.bottom<t.top||e.top>t.bottom),it=(()=>{let e=0;return()=>{let t=e;return e=(e+1)%(2**53-1),t}})(),at=e=>e!==void 0&&e!==``?e:it().toString();function ot(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 st(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 U=e=>e instanceof DOMException&&(e.name===`AbortError`||e.code===20),ct=e=>{if(!U(e))throw e},lt=e=>t=>n=>{let r=typeof n==`object`;n==null||r&&!Object.keys(n).length||e(t,r?H(n):{value:n})},W=(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 G{dynamicImportTimeout=5e3;span;context;childTracers=[];initPromise;static rootTracer;static dynamicImportStatus=`not_started`;static dynamicImports;static dynamicImportPromise;constructor({name:e,getParentContext:t}){G.dynamicImportStatus===`not_started`&&(G.dynamicImportPromise=this.loadOpentelemetry());let n=Date.now();this.initPromise=G.dynamicImportPromise.then(r=>{G.dynamicImportStatus===`completed`&&this.init({name:e,getParentContext:t},n)})}init({name:e,getParentContext:t},n){this.span=G.rootTracer.startSpan(e,{startTime:n},t?.()),this.context=G.dynamicImports.opentelemetryApi.trace.setSpan(G.dynamicImports.opentelemetryApi.context.active(),this.span)}async loadOpentelemetry(){if(G.dynamicImportStatus===`not_started`){G.dynamicImportStatus=`in_progress`;try{let e=new Promise((e,t)=>setTimeout(t,this.dynamicImportTimeout)),t=Promise.all([import(`@opentelemetry/api`),import(`@opentelemetry/sdk-trace-web`),import(`@apptracer/opentelemetry`)]),[n,r,i]=await Promise.race([t,e]);G.dynamicImports={opentelemetryApi:n,opentelemetrySdk:r,tracer:i},G.dynamicImportStatus=`completed`}catch{G.dynamicImportStatus=`failed`}}}isComponentTracerNotInitialized(){return _(this.span)||G.dynamicImportStatus===`failed`}log(e,t){let n=Date.now();this.initPromise.then(r=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...W(t),type:`log`},n)})}error(e,t){let n=Date.now();this.initPromise.then(r=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...W(t),type:`error`},n)})}critical(e,t){let n=Date.now();this.initPromise.then(r=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...W(t),type:`critical`},n)})}createComponentTracer(e){let t=new G({name:e,getParentContext:()=>this.context});return this.childTracers.push(t),t}end(){this.initPromise.then(e=>{this.isComponentTracerNotInitialized()||(this.childTracers.forEach(e=>e.end()),this.span.end())})}}class ut extends G{spanExporter;constructor(){super({name:`Root`})}init({name:e,getParentContext:t},n){let r=G.dynamicImports.tracer.initTracerOpenTelemetry({serviceName:`videoplayer-sdk-web`,appToken:`L9SBoka6ZWk4xPjaK7tmfSfYvMhcge7nvGDjpdMmscb`,spanLimits:{attributeCountLimit:1/0,eventCountLimit:1/0,attributePerEventCountLimit:1/0}}).getProvider(),i=new G.dynamicImports.tracer.TracerMemorySpanExporter;this.spanExporter=i,r.addSpanProcessor(new G.dynamicImports.tracer.TracerAllSpansProcessor({startedSpansExporter:i})),G.rootTracer=r.getTracer(`sdk-videoplayer-tracer`),super.init({name:e,getParentContext:t},n)}getFinishedSpans(){if(!this.isComponentTracerNotInitialized())return this.spanExporter?.getJsonData()}getTraceId(){return this.isComponentTracerNotInitialized()?``:this.span.spanContext().traceId}}class K{fakeTraceId;constructor(e){}log(e,t){}error(e,t){}critical(e,t){}createComponentTracer(e){return new K({name:e})}end(){}getFinishedSpans(){}getTraceId(){return this.fakeTraceId}}class dt{static createRootTracer(e=!1){return e?new ut:new K}}var q;(e=>{e.NETWORK=`network`,e.VIDEO_PIPELINE=`video_pipeline`,e.EXTERNAL_API=`external_api`,e.PARSER=`parser`,e.DOM=`dom`,e.WTF=`wtf`,e.FATAL=`fatal`})(q||={});var J;(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`})(J||={});var ft=`vk.com`,pt=async(e,t,n)=>{let r=new URL(`https://${ft}/js/lang-pack.js`);return r.searchParams.set(`format`,`json`),r.searchParams.set(`name`,t),e!==void 0&&r.searchParams.set(`lang`,e),mt(await(await fetch(r.toString())).json(),n)},mt=(e,t)=>Object.fromEntries(Object.entries(e.keys).map(([e,n])=>[e.substring(`${t}_`.length),ht(n)])),ht=e=>Array.isArray(e)?e[0]:e,Y;(e=>{e.RU=`ru`,e.EN=`en`})(Y||={});var X=`__vk_vp_internals_exposure`;class gt{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 Z={};r(Z,{subscribe:()=>bt,push:()=>yt,destroy:()=>vt,create:()=>_t});var Q=new Map,_t=(e,t)=>Q.set(e,t??[]),vt=e=>Q.delete(e),yt=(e,t)=>{let n=Q.get(e);n&&(typeof n==`function`?n(t):n.push(t))},bt=(e,t)=>{let n=Q.get(e);if(n){if(n&&Array.isArray(n))for(let e of n)t(e);Q.set(e,t)}},xt=`gW5EerTD5QhAnsbpF7Hd2NSMRteYIUUMjFbSyI68Pf5`,St=e=>v({id:e.id,message:e.message,category:e.category,data:Ct(e.data),httpCode:e.httpCode,UVBackendErrorCode:e.UVBackendErrorCode});function Ct(e){switch(typeof e){case`boolean`:case`string`:case`number`:return e;case`object`:try{return JSON.stringify(e)}catch{return}default:return}}var wt=e=>{let t=e.thrown instanceof Error?e.thrown:Error(e.message);return t.name=e.id,t};class ${static tracerErrorMap=new Map;static appTracerModule=null;static loadPromise=null;dynamicImportTimeout=5e3;componentName;subscription=new a;options;envParams;context;constructor(e,t,n,r){this.componentName=e,this.options=t,this.envParams=n,this.context=r,this.options.enabled&&(this.loadModule(),this.init())}error(e,t){let{blackErrorCategoryList:n,blackErrorIdList:r,sampleRate:i,whiteErrorCategoryList:a,whiteErrorIdList:o}=this.options,{id:s,category:c}=e;n.length&&n.includes(c)||r.length&&r.includes(s)||a.length&&!a.includes(c)||o.length&&!o.includes(s)||Math.random()>=i||$.tracerErrorMap.get(this.componentName)?.error(wt(e),{severity:t?.severity??(e.traceAsLog?`debug`:void 0),keys:{...this.context,...St(e)}})}addSubscription(e){this.subscription.add(e)}destroy(){this.subscription.unsubscribe()}async init(){try{if(await $.loadPromise,$.tracerErrorMap.has(this.componentName)||_($.appTracerModule))return;let{appTracerModule:e}=$,{initTracerError:t,initTracerErrorUploader:n,addTracerPlugin:r,getTracerModules:i}=e,a=i(this.componentName),o=!a.error,s=a.error??t(this.componentName,{enableUnhandledErrorsListeners:!1,stringifyErrorDataObject:!0});o&&n(this.componentName,{appToken:xt,environment:this.envParams.env,versionCode:1,versionName:this.envParams.version}),r(this.componentName,{name:`addedCategory`,errorBeforeAdd(e){let t=e.keys?.category??`wtf`;if(typeof t==`string`)return{issueKey:t}}}),$.tracerErrorMap.set(this.componentName,s)}catch{}}loadModule(){g($.loadPromise)||($.loadPromise=(async()=>{try{let e=new Promise((e,t)=>x().setTimeout(t,this.dynamicImportTimeout));$.appTracerModule=await Promise.race([e,import(`@apptracer/sdk/lite`)])}catch{$.loadPromise=null}})())}}export{v as withoutNullable,me as videoSizeToQuality,he as videoQualityToHeight,pe as videoHeightToQuality,we as timeout,ye as timeCodeToString,L as throttleFn,Fe as throttle,Je as tap,ct as suppressAbort,Xe as skip,Qe as shareReplay,T as safeStorage,Ke as pairwise,Ge as once,et as observeElementSize,Ee as observableFrom,te as now,c as noop,Ce as merge,We as mapTo,V as map,pt as loadVKLangPack,nt as isValidURL,_ as isNullable,g as isNonNullable,de as isLowerOrEqual,M as isLower,P as isInvariantQuality,rt as isIntersecting,ue as isHigherOrEqual,le as isHigher,S as isBrowserWindow,U as isAbortError,Te as interval,ot as interpolate,x as getWindow,ve as getVideoQualityLabel,lt as getTraceSubscriptionMethod,st as getRangeAroundIndex,at as getPlayerId,fe as getHighestQuality,w as getExponentialDelay,De as fromEvent,H as flattenObject,Ve as filterChanged,Le as filter,F as fillWithDefault,Z as devNull,ce as detectEmbed,I as debounceFn,Me as debounce,Se as combine,R as cloneDeepWith,be as cloneDeep,tt as clearVideoElement,s as checkNever,ke as buffer,_e as assertQualityIsExact,h as assertNullable,y as assertNotEmptyArray,m as assertNonNullable,o as assertNever,b as assertEmptyArray,ge as areQualitiesExact,ee as addScript,C as abortable,A as VideoQuality,xe as ValueSubject,J as VKNumericLanguage,i as VERSION,dt as TracerFactory,Oe as SubscriptionRemovable,a as Subscription,f as Subject,z as ReplaySubject,d as Observable,p as Logger,gt as InternalsExposure,Y as InterfaceLanguage,X as INTERNAL_EXPOSE_GLOBAL_KEY,q as ErrorCategory,$ 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.83-dev.e547b9bb.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=(e=x())=>!!(e.window&&e.screen),C=(e,t,n)=>new Promise((r,i)=>{t.addEventListener(`abort`,()=>{s(),l.remove()});let a=()=>{s(),i(`error`)},o=()=>{s(),r()},s=()=>{c&&clearTimeout(c),l.removeEventListener(`load`,o),l.removeEventListener(`error`,a)},c;n&&(c=x().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)}),w=typeof x().performance?.now==`function`?()=>x().performance.now():()=>Date.now(),T=(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},E=(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},D={};r(D,{set:()=>ne,remove:()=>ie,isPersistent:()=>ee,has:()=>re,get:()=>te,clear:()=>ae});var O,k,A=`vk-videoplayer-dummy-key-${Math.random()}`,j=()=>{if(k!==void 0)return k;try{localStorage.setItem(A,`test`),localStorage.removeItem(A),k=0}catch(e){if(e instanceof DOMException||e instanceof TypeError)try{sessionStorage.getItem(A),k=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)k=2;else throw e}else throw e}return k===2&&(O=new Map),k},ee=()=>j()===0,te=e=>{let t=j();switch(t){case 0:return localStorage.getItem(e)??void 0;case 1:return sessionStorage.getItem(e)??void 0;case 2:return O?.get(e);default:o(t)}},ne=(e,t)=>{let n=j();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:O?.set(e,t);return;default:o(n)}},re=e=>{let t=j();switch(t){case 0:return e in localStorage;case 1:return e in sessionStorage;case 2:return O?.has(e)??!1;default:return o(t),!1}},ie=e=>{let t=j();switch(t){case 0:return localStorage.removeItem(e);case 1:return sessionStorage.removeItem(e);case 2:O?.delete(e);return;default:o(t)}},ae=()=>{let e=j();switch(e){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return O?.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)}},M;(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`})(M||={});var N={"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}},se=(e,t)=>N[e].height>N[t].height,ce=(e,t)=>N[e].height>=N[t].height,P=(e,t)=>N[e].height<N[t].height,le=(e,t)=>N[e].height<=N[t].height,ue=e=>e.sort((e,t)=>e===t?0:e===`Invariant quality`?1:t===`Invariant quality`?-1:P(e,t)?1:-1)[0],F=Object.keys(N).sort((e,t)=>P(e,t)?-1:1),de=(e,t=.02)=>[...F].find(n=>N[n].height*(1+t)>=e),fe=({width:e,height:t})=>{let n=Math.min(e,t),r=Math.max(e,t);return F.find(e=>{let t=N[e];return t.width>=r&&t.height>=n})},pe=e=>N[e].height,I=e=>e===`Invariant quality`,me=e=>e.every(e=>!I(e));function he(e){if(I(e))throw Error(`Expected exact quality`)}var ge=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``}},L=`[VKVideoPlayer] Config warning:`,_e=(e,t,n,r)=>t.includes(e)?e:(console.warn(`${L} "${n}" has invalid value "${String(e)}". Using default "${String(r)}".`),r),ve=(e,t,n,r)=>{for(let i of n){let n=e[i];if(typeof n!=`number`||Number.isNaN(n)){let a=r?`${r}.${String(i)}`:String(i);console.warn(`${L} "${a}" expected a number, got "${String(n)}". Using default ${String(t[i])}.`),e[i]=t[i]}}},ye=(e,t,n)=>{for(let r of t){let t=e[r];if(t!=null&&(typeof t!=`number`||Number.isNaN(t))){let i=n?`${n}.${String(r)}`:String(r);console.warn(`${L} "${i}" expected a number, got "${String(t)}". Using undefined.`),e[r]=void 0}}},be=(e,t,n)=>{for(let r of t)if(!Array.isArray(e[r])){let t=n?`${n}.${String(r)}`:String(r);console.warn(`${L} "${t}" expected an array, got ${typeof e[r]}. Using [].`),e[r]=[]}},xe=(e,t,n)=>{for(let r of t){let t=e[r];if(t!=null&&!Array.isArray(t)){let i=n?`${n}.${String(r)}`:String(r);console.warn(`${L} "${i}" expected an array, got ${typeof t}. Using undefined.`),e[r]=void 0}}},R=(e,t,n)=>{for(let r of t){let t=e[r];if(t!=null&&typeof t!=`function`){let i=n?`${n}.${String(r)}`:String(r);console.warn(`${L} "${i}" expected a function, got ${typeof t}. Using undefined.`),e[r]=void 0}}},z=(e,t,n)=>{let r=n?new Set(n):void 0;for(let n of Object.keys(e))if(r?.has(n)){let r=e[n];if(r!=null)if(typeof r==`object`&&!Array.isArray(r))z(r,t?`${t}.${String(n)}`:String(n));else{let i=t?`${t}.${String(n)}`:String(n);console.warn(`${L} "${i}" expected an object with callbacks, got ${typeof r}. Using undefined.`),e[n]=void 0}}else R(e,[n],t)},B=(e,t)=>{let n={};for(let r of Object.keys(t)){let i=t[r],a=e[r];Array.isArray(i)?(a!=null&&!Array.isArray(a)&&console.warn(`[VKVideoPlayer] Config warning: "${String(r)}" expected to be an array, got ${typeof a}. Using default value.`),n[r]=Array.isArray(a)?a:i):typeof i==`object`&&i?typeof a==`object`&&a&&!Array.isArray(a)?n[r]=B(a,i):(a!=null&&console.warn(`[VKVideoPlayer] Config warning: "${String(r)}" expected to be an object, got ${typeof a}. Using default value.`),n[r]=i):n[r]=r in e?a:i}return n},Se=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)):setTimeout(e,t)}function g(e){if(p){x().cancelAnimationFrame(e);return}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 T(){return s!==void 0}function E(...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 E.cancel=C,E.flush=w,E.pending=T,E}var H=(e,t=0,n)=>V(e,t,{leading:!0,trailing:!0,...n,maxWait:t}),U=(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]=U(e[r],t):n[r]=e[r]}return n},Ce=e=>U(e);class W 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 we 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 Te(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 Ee(...e){return new d(t=>e.reduce((e,n)=>e.add(n.subscribe(t)),new a))}var De=e=>new d(t=>{let n=x().setTimeout(()=>{try{t.next()}catch(e){if(t.error)t.error(e);else throw e}},e);return()=>x().clearTimeout(n)}),Oe=e=>new d(t=>{let n=x(),r=n.setInterval(()=>t.next(),e);return()=>{r&&=(n.clearInterval(r),void 0)}}),ke=e=>new d(t=>{e.forEach(e=>t.next(e))}),Ae=(e,t)=>new d(n=>{let r=e=>n.next(e);return e.addEventListener(t,r),()=>e.removeEventListener(t,r)});class je extends a{remove(e){this.subscriptions=this.subscriptions.filter(t=>t!==e)}}function Me(e){return t=>new d(n=>t.subscribe(new Ne(n,e)))}class Ne{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 Pe={leading:!1,trailing:!0};function Fe(e,t=Pe){return n=>new d(r=>n.subscribe(new Ie(r,e,t)))}class Ie{destination;time;config;lastValue;timeout;constructor(e,t,n){this.destination=e,this.time=t,this.config=n}next(e){this.lastValue=e;let t=x();g(this.timeout)?t.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=t.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 Le={leading:!0,trailing:!1};function Re(e,t=Le){return n=>new d(r=>n.subscribe(new ze(r,e,t)))}class ze{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=x().setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){this.destination.error?.(e)}}function Be(e){return t=>new d(n=>t.subscribe(new Ve(n,e)))}class Ve{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 He=(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)},Ue=(e,t)=>e instanceof Object&&t instanceof Object?He(e,t):e===t;function We(e=Ue){return t=>new d(n=>t.subscribe(new Ge(n,e)))}var G={};class Ge{destination;predicate;lastValue=G;constructor(e,t){this.destination=e,this.predicate=t}next(e){let t;try{t=this.lastValue===G||!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 K(e){return t=>new d(n=>t.subscribe(new Ke(n,e)))}class Ke{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 qe(e){return K(()=>e)}function Je(){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 Ye(){return e=>new d(t=>e.subscribe(new Xe(t)))}class Xe{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 Ze(e){return t=>new d(n=>t.subscribe(new Qe(n,e)))}class Qe{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 $e(e){return t=>new d(n=>t.subscribe(new et(n,e)))}class et{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 tt(e=0){return t=>{let n=0,r=new W(e),i=t.subscribe(r),a=e=>()=>{e.unsubscribe(),n--,n===0&&i.unsubscribe()};return new d(e=>(n++,a(r.subscribe(e))))}}var nt=300,rt=(e,t=nt)=>new d(n=>{let r=x(),{width:i,height:a}=e.getBoundingClientRect();if(n.next({width:i,height:a}),!S(r))return;let o=new r.ResizeObserver(H(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()}),q=(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=q(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},it=e=>{e.removeAttribute(`src`),e.load()},at=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),st=(()=>{let e=0;return()=>{let t=e;return e=(e+1)%(2**53-1),t}})(),ct=e=>e!==void 0&&e!==``?e:st().toString();function lt(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 ut(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 dt=e=>e instanceof DOMException&&(e.name===`AbortError`||e.code===20),ft=e=>{if(!dt(e))throw e},pt=e=>t=>n=>{let r=typeof n==`object`;n==null||r&&!Object.keys(n).length||e(t,r?q(n):{value:n})},J=(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 Y{dynamicImportTimeout=5e3;span;context;childTracers=[];initPromise;static rootTracer;static dynamicImportStatus=`not_started`;static dynamicImports;static dynamicImportPromise;constructor({name:e,getParentContext:t}){Y.dynamicImportStatus===`not_started`&&(Y.dynamicImportPromise=this.loadOpentelemetry());let n=Date.now();this.initPromise=Y.dynamicImportPromise.then(r=>{Y.dynamicImportStatus===`completed`&&this.init({name:e,getParentContext:t},n)})}init({name:e,getParentContext:t},n){this.span=Y.rootTracer.startSpan(e,{startTime:n},t?.()),this.context=Y.dynamicImports.opentelemetryApi.trace.setSpan(Y.dynamicImports.opentelemetryApi.context.active(),this.span)}async loadOpentelemetry(){if(Y.dynamicImportStatus===`not_started`){Y.dynamicImportStatus=`in_progress`;try{let e=new Promise((e,t)=>setTimeout(t,this.dynamicImportTimeout)),t=Promise.all([import(`@opentelemetry/api`),import(`@opentelemetry/sdk-trace-web`),import(`@apptracer/opentelemetry`)]),[n,r,i]=await Promise.race([t,e]);Y.dynamicImports={opentelemetryApi:n,opentelemetrySdk:r,tracer:i},Y.dynamicImportStatus=`completed`}catch{Y.dynamicImportStatus=`failed`}}}isComponentTracerNotInitialized(){return _(this.span)||Y.dynamicImportStatus===`failed`}log(e,t){let n=Date.now();this.initPromise.then(r=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...J(t),type:`log`},n)})}error(e,t){let n=Date.now();this.initPromise.then(r=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...J(t),type:`error`},n)})}critical(e,t){let n=Date.now();this.initPromise.then(r=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...J(t),type:`critical`},n)})}createComponentTracer(e){let t=new Y({name:e,getParentContext:()=>this.context});return this.childTracers.push(t),t}end(){this.initPromise.then(e=>{this.isComponentTracerNotInitialized()||(this.childTracers.forEach(e=>e.end()),this.span.end())})}}class mt extends Y{spanExporter;constructor(){super({name:`Root`})}init({name:e,getParentContext:t},n){let r=Y.dynamicImports.tracer.initTracerOpenTelemetry({serviceName:`videoplayer-sdk-web`,appToken:`L9SBoka6ZWk4xPjaK7tmfSfYvMhcge7nvGDjpdMmscb`,spanLimits:{attributeCountLimit:1/0,eventCountLimit:1/0,attributePerEventCountLimit:1/0}}).getProvider(),i=new Y.dynamicImports.tracer.TracerMemorySpanExporter;this.spanExporter=i,r.addSpanProcessor(new Y.dynamicImports.tracer.TracerAllSpansProcessor({startedSpansExporter:i})),Y.rootTracer=r.getTracer(`sdk-videoplayer-tracer`),super.init({name:e,getParentContext:t},n)}getFinishedSpans(){if(!this.isComponentTracerNotInitialized())return this.spanExporter?.getJsonData()}getTraceId(){return this.isComponentTracerNotInitialized()?``:this.span.spanContext().traceId}}class X{fakeTraceId;constructor(e){}log(e,t){}error(e,t){}critical(e,t){}createComponentTracer(e){return new X({name:e})}end(){}getFinishedSpans(){}getTraceId(){return this.fakeTraceId}}class ht{static createRootTracer(e=!1){return e?new mt:new X}}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.FATAL=`fatal`})(gt||={});var _t;(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`})(_t||={});var vt=`vk.com`,yt=async(e,t,n)=>{let r=new URL(`https://${vt}/js/lang-pack.js`);return r.searchParams.set(`format`,`json`),r.searchParams.set(`name`,t),e!==void 0&&r.searchParams.set(`lang`,e),bt(await(await fetch(r.toString())).json(),n)},bt=(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,St;(e=>{e.RU=`ru`,e.EN=`en`})(St||={});var Z=`__vk_vp_internals_exposure`;class Ct{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[Z]?.[e]?.[t]??{}}initWindowObjects(){if(typeof window>`u`)return;let e=this.playerId,t=this.type;window[Z]||(window[Z]={}),window[Z][e]||(window[Z][e]={}),window[Z][e][t]||(window[Z][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[Z]&&window[Z][e]&&window[Z][e][t]&&(delete window[Z][e][t],Object.keys(window[Z][e]).length||delete window[Z][e],Object.keys(window[Z]).length||delete window[Z])}}var wt={};r(wt,{subscribe:()=>Ot,push:()=>Dt,destroy:()=>Et,create:()=>Tt});var Q=new Map,Tt=(e,t)=>Q.set(e,t??[]),Et=e=>Q.delete(e),Dt=(e,t)=>{let n=Q.get(e);n&&(typeof n==`function`?n(t):n.push(t))},Ot=(e,t)=>{let n=Q.get(e);if(n){if(n&&Array.isArray(n))for(let e of n)t(e);Q.set(e,t)}},kt=`gW5EerTD5QhAnsbpF7Hd2NSMRteYIUUMjFbSyI68Pf5`,At=e=>v({id:e.id,message:e.message,category:e.category,data:jt(e.data),httpCode:e.httpCode,UVBackendErrorCode:e.UVBackendErrorCode});function jt(e){switch(typeof e){case`boolean`:case`string`:case`number`:return e;case`object`:try{return JSON.stringify(e)}catch{return}default:return}}var Mt=e=>{let t=e.thrown instanceof Error?e.thrown:Error(e.message);return t.name=e.id,t};class ${static tracerErrorMap=new Map;static appTracerModule=null;static loadPromise=null;dynamicImportTimeout=5e3;componentName;subscription=new a;options;envParams;context;constructor(e,t,n,r){this.componentName=e,this.options=t,this.envParams=n,this.context=r,this.options.enabled&&(this.loadModule(),this.init())}error(e,t){let{blackErrorCategoryList:n,blackErrorIdList:r,sampleRate:i,whiteErrorCategoryList:a,whiteErrorIdList:o}=this.options,{id:s,category:c}=e;n.length&&n.includes(c)||r.length&&r.includes(s)||a.length&&!a.includes(c)||o.length&&!o.includes(s)||Math.random()>=i||$.tracerErrorMap.get(this.componentName)?.error(Mt(e),{severity:t?.severity??(e.traceAsLog?`debug`:void 0),keys:{...this.context,...At(e)}})}addSubscription(e){this.subscription.add(e)}destroy(){this.subscription.unsubscribe()}async init(){try{if(await $.loadPromise,$.tracerErrorMap.has(this.componentName)||_($.appTracerModule))return;let{appTracerModule:e}=$,{initTracerError:t,initTracerErrorUploader:n,addTracerPlugin:r,getTracerModules:i}=e,a=i(this.componentName),o=!a.error,s=a.error??t(this.componentName,{enableUnhandledErrorsListeners:!1,stringifyErrorDataObject:!0});o&&n(this.componentName,{appToken:kt,environment:this.envParams.env,versionCode:1,versionName:this.envParams.version}),r(this.componentName,{name:`addedCategory`,errorBeforeAdd(e){let t=e.keys?.category??`wtf`;if(typeof t==`string`)return{issueKey:t}}}),$.tracerErrorMap.set(this.componentName,s)}catch{}}loadModule(){g($.loadPromise)||($.loadPromise=(async()=>{try{let e=new Promise((e,t)=>x().setTimeout(t,this.dynamicImportTimeout));$.appTracerModule=await Promise.race([e,import(`@apptracer/sdk/lite`)])}catch{$.loadPromise=null}})())}}export{v as withoutNullable,fe as videoSizeToQuality,pe as videoQualityToHeight,de as videoHeightToQuality,ye as validateOptionalNumbers,xe as validateOptionalArrays,ve as validateNumbers,R as validateFunctions,_e as validateEnum,z as validateCallbacks,be as validateArrays,De as timeout,Se as timeCodeToString,H as throttleFn,Re as throttle,Ze as tap,ft as suppressAbort,$e as skip,tt as shareReplay,D as safeStorage,Ye as pairwise,Je as once,rt as observeElementSize,ke as observableFrom,w as now,c as noop,Ee as merge,qe as mapTo,K as map,yt as loadVKLangPack,at as isValidURL,_ as isNullable,g as isNonNullable,le as isLowerOrEqual,P as isLower,I as isInvariantQuality,ot as isIntersecting,ce as isHigherOrEqual,se as isHigher,S as isBrowserWindow,dt as isAbortError,Oe as interval,lt as interpolate,x as getWindow,ge as getVideoQualityLabel,pt as getTraceSubscriptionMethod,ut as getRangeAroundIndex,ct as getPlayerId,ue as getHighestQuality,E as getExponentialDelay,Ae as fromEvent,q as flattenObject,We as filterChanged,Be as filter,B as fillWithDefault,wt as devNull,oe as detectEmbed,V as debounceFn,Fe as debounce,Te as combine,U as cloneDeepWith,Ce as cloneDeep,it as clearVideoElement,s as checkNever,Me as buffer,he as assertQualityIsExact,h as assertNullable,y as assertNotEmptyArray,m as assertNonNullable,o as assertNever,b as assertEmptyArray,me as areQualitiesExact,C as addScript,T as abortable,L as WARN_PREFIX,M as VideoQuality,we as ValueSubject,_t as VKNumericLanguage,i as VERSION,ht as TracerFactory,je as SubscriptionRemovable,a as Subscription,f as Subject,W as ReplaySubject,d as Observable,p as Logger,Ct as InternalsExposure,St as InterfaceLanguage,Z as INTERNAL_EXPOSE_GLOBAL_KEY,gt as ErrorCategory,$ as AppTracer};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vkontakte/videoplayer-shared",
3
- "version": "1.0.83-dev.e26cf73b.0",
3
+ "version": "1.0.83-dev.e547b9bb.0",
4
4
  "author": "vk.com",
5
5
  "description": "Shared code for vk.com videoplayer",
6
6
  "homepage": "https://vk.com",
@@ -1,2 +1,40 @@
1
1
  import type { RecursivePartial } from "../types";
2
+ export declare const WARN_PREFIX = "[VKVideoPlayer] Config warning:";
3
+ /**
4
+ * Валидирует enum/union поле.
5
+ * Если значение невалидно — выводит warning и возвращает дефолтное.
6
+ */
7
+ export declare const validateEnum: <T>(value: T, allowed: string[], fieldName: string, defaultValue: T) => T;
8
+ /**
9
+ * Валидирует числовые поля объекта по списку ключей.
10
+ * Если значение не число или NaN — выводит warning и подставляет дефолт.
11
+ */
12
+ export declare const validateNumbers: <T extends Record<string, any>>(target: T, defaults: T, keys: (keyof T)[], prefix: string) => void;
13
+ /**
14
+ * Валидирует опциональные числовые поля объекта по списку ключей.
15
+ * Если значение задано, но не является числом или NaN — выводит warning и подставляет undefined.
16
+ */
17
+ export declare const validateOptionalNumbers: <T extends Record<string, any>>(target: T, keys: (keyof T)[], prefix: string) => void;
18
+ /**
19
+ * Валидирует поля-массивы объекта по списку ключей.
20
+ * Если значение не массив — выводит warning и подставляет [].
21
+ */
22
+ export declare const validateArrays: <T extends Record<string, any>>(target: T, keys: (keyof T)[], prefix: string) => void;
23
+ /**
24
+ * Валидирует опциональные поля-массивы объекта по списку ключей.
25
+ * Если значение задано, но не является массивом — выводит warning и подставляет undefined.
26
+ * Если значение undefined/null — не трогает.
27
+ */
28
+ export declare const validateOptionalArrays: <T extends Record<string, any>>(target: T, keys: (keyof T)[], prefix: string) => void;
29
+ /**
30
+ * Валидирует поля-функции объекта по списку ключей.
31
+ * Если значение задано, но не является функцией — выводит warning и подставляет undefined.
32
+ */
33
+ export declare const validateFunctions: <T extends Record<string, any>>(target: T, keys: (keyof T)[], prefix: string) => void;
34
+ /**
35
+ * Валидирует все поля объекта как функции, кроме указанных исключений.
36
+ * Полезно для объектов-коллбэков, где все поля должны быть функциями,
37
+ * а некоторые (uiInfo, adsInfo) — вложенные объекты с коллбэками.
38
+ */
39
+ export declare const validateCallbacks: <T extends Record<string, any>>(target: T, prefix: string, nestedKeys?: (keyof T)[]) => void;
2
40
  export declare const fillWithDefault: <Config extends object>(partial: RecursivePartial<Config>, defaultConfig: Config) => Config;