@vkontakte/videoplayer-shared 1.0.85-dev.200a948d7.0 → 1.0.85-dev.2ff58f4df.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,7 +1,7 @@
1
1
  /**
2
- * @vkontakte/videoplayer-shared v1.0.85-dev.200a948d7.0
3
- * Fri, 13 Mar 2026 17:31:35 GMT
2
+ * @vkontakte/videoplayer-shared v1.0.85-dev.2ff58f4df.0
3
+ * Mon, 16 Mar 2026 12:20:36 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-85/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=globalThis;if(i.__svelte_safe_instanceof===void 0){let e=[];i.__svelte_safe_instanceof=(t,n,r)=>{if(typeof n!=`function`){let i={location:r??`unknown`,leftType:typeof t,rightType:typeof n,rightValue:String(n),stack:Error().stack??``};return e.push(i),console.error(`[svelte-instanceof] FAIL: location=${i.location}, rightType=${i.rightType}, rightValue=${i.rightValue}`),console.error(`[svelte-instanceof] stack:`,i.stack),!1}return t instanceof n},i.__svelte_instanceof_log=e}var a=`1.0.85-dev.200a948d7.0`;class o{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 s=e=>{throw Error(`${e} is value of unexpected type`)},c=e=>{},l=()=>{},u=e=>{throw console.error(e),e},d=e=>{console.error(e)};class f{suppressErrors=!1;constructor(e){e&&(this._subscribe=e)}setSuppressErrors(e){this.suppressErrors=e}subscribe(e,t){let n=this.suppressErrors?d:u,r;r=t?typeof t==`function`?{next:t,error:l}:{next:e=>t.next(e),error:e=>t.error?.(e)}:{next:n,error:l};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)},a;try{a=this._subscribe(i)}catch(e){i.error?.(e)}return new o().add(()=>{switch(i.next=l,i.error=l,typeof a){case`function`:a();return;case`object`:a.unsubscribe();return;case`undefined`:return;default:return s(a)}})}pipe(...e){return e.reduce((e,t)=>t(e),this)}_subscribe(e){}}class p extends f{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 o().add(()=>this.subscribers.delete(t))}}class m{log$=new p;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 h(e,t=`Assertion "value is not nullable" failed`){if(e==null)throw Error(t)}function g(e,t=`Assertion "value is nullable" failed`){if(e!=null)throw Error(t)}function _(e){return e!=null}function v(e){return e==null}var y=e=>Object.fromEntries(Object.entries(e).filter(([e,t])=>_(t)));function b(e,t){if(!e?.length)throw Error(t)}function x(e,t){if(e?.length)throw Error(t)}var S=()=>globalThis,C=(e=S())=>!!(e.window&&e.screen),w=(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=S().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)}),T=typeof S().performance?.now==`function`?()=>S().performance.now():()=>Date.now(),E=(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},ee=(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:()=>re,remove:()=>ae,isPersistent:()=>te,has:()=>ie,get:()=>ne,clear:()=>oe});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},te=()=>j()===0,ne=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:s(t)}},re=(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:s(n)}},ie=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 s(t),!1}},ae=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:s(t)}},oe=()=>{let e=j();switch(e){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return O?.clear();default:s(e)}},se=()=>{let e,t=[],n=S();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}},ce=(e,t)=>N[e].height>N[t].height,le=(e,t)=>N[e].height>=N[t].height,P=(e,t)=>N[e].height<N[t].height,ue=(e,t)=>N[e].height<=N[t].height,de=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),fe=(e,t=.02)=>[...F].find(n=>N[n].height*(1+t)>=e),pe=({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})},me=e=>N[e].height,I=e=>e===`Invariant quality`,he=e=>e.every(e=>!I(e));function ge(e){if(I(e))throw Error(`Expected exact quality`)}var _e=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=(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]=L(a,i):n[r]=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 R(e,t=0,n){let r,i,a,o,s,c,l=0,u=!1,d=!1,f=!0,p=!t&&t!==0&&typeof S().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&&S().cancelAnimationFrame(s),S().requestAnimationFrame(e)):setTimeout(e,t)}function g(e){if(p){S().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 x(e);s=h(b,v(e))}function x(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:x(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 z=(e,t=0,n)=>R(e,t,{leading:!0,trailing:!0,...n,maxWait:t}),B=(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]=B(e[r],t):n[r]=e[r]}return n},ye=e=>B(e);class V extends p{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 o().add(()=>this.subscribers.delete(t))}}class be extends p{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 xe(e){return new f(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 o)})}function Se(...e){return new f(t=>e.reduce((e,n)=>e.add(n.subscribe(t)),new o))}var Ce=e=>new f(t=>{let n=S().setTimeout(()=>{try{t.next()}catch(e){if(t.error)t.error(e);else throw e}},e);return()=>S().clearTimeout(n)}),we=e=>new f(t=>{let n=S(),r=n.setInterval(()=>t.next(),e);return()=>{r&&=(n.clearInterval(r),void 0)}}),Te=e=>new f(t=>{e.forEach(e=>t.next(e))}),Ee=(e,t)=>new f(n=>{let r=e=>n.next(e);return e.addEventListener(t,r),()=>e.removeEventListener(t,r)});class De extends o{remove(e){this.subscriptions=this.subscriptions.filter(t=>t!==e)}}function Oe(e){return t=>new f(n=>t.subscribe(new ke(n,e)))}class ke{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 Ae={leading:!1,trailing:!0};function je(e,t=Ae){return n=>new f(r=>n.subscribe(new Me(r,e,t)))}class Me{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=S();_(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 Ne={leading:!0,trailing:!1};function Pe(e,t=Ne){return n=>new f(r=>n.subscribe(new Fe(r,e,t)))}class Fe{destination;time;config;lastValue;timeout;constructor(e,t,n){this.destination=e,this.time=t,this.config=n}next(e){this.lastValue=e,v(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=S().setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){this.destination.error?.(e)}}function Ie(e){return t=>new f(n=>t.subscribe(new Le(n,e)))}class Le{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 Re=(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)},ze=(e,t)=>e instanceof Object&&t instanceof Object?Re(e,t):e===t;function Be(e=ze){return t=>new f(n=>t.subscribe(new Ve(n,e)))}var H={};class Ve{destination;predicate;lastValue=H;constructor(e,t){this.destination=e,this.predicate=t}next(e){let t;try{t=this.lastValue===H||!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 U(e){return t=>new f(n=>t.subscribe(new He(n,e)))}class He{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 Ue(e){return U(()=>e)}function We(){return e=>new f(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 Ge(){return e=>new f(t=>e.subscribe(new Ke(t)))}class Ke{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 qe(e){return t=>new f(n=>t.subscribe(new Je(n,e)))}class Je{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 Ye(e){return t=>new f(n=>t.subscribe(new Xe(n,e)))}class Xe{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 Ze(e=0){return t=>{let n=0,r=new V(e),i=t.subscribe(r),a=e=>()=>{e.unsubscribe(),n--,n===0&&i.unsubscribe()};return new f(e=>(n++,a(r.subscribe(e))))}}var Qe=300,$e=(e,t=Qe)=>new f(n=>{let r=S(),{width:i,height:a}=e.getBoundingClientRect();if(n.next({width:i,height:a}),!C(r))return;let o=new r.ResizeObserver(z(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),_(r)&&_(i)&&n.next({width:r,height:i})},t));return o.observe(e),()=>o.disconnect()}),W=(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=W(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,t=!1)=>{t&&(e.innerHTML=``),e.removeAttribute(`src`),e.load()},tt=e=>{let t;try{t=new URL(e)}catch{return!1}return t.protocol===`https:`},nt=(e,t)=>!(e.right<t.left||e.left>t.right||e.bottom<t.top||e.top>t.bottom),rt=(()=>{let e=0;return()=>{let t=e;return e=(e+1)%(2**53-1),t}})(),it=e=>e!==void 0&&e!==``?e:rt().toString();function at(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 ot(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 G=e=>e instanceof DOMException&&(e.name===`AbortError`||e.code===20),st=e=>{if(!G(e))throw e},ct=e=>t=>n=>{let r=typeof n==`object`;n==null||r&&!Object.keys(n).length||e(t,r?W(n):{value:n})},K=(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 q{dynamicImportTimeout=5e3;span;context;childTracers=[];initPromise;static rootTracer;static dynamicImportStatus=`not_started`;static dynamicImports;static dynamicImportPromise;constructor({name:e,getParentContext:t}){q.dynamicImportStatus===`not_started`&&(q.dynamicImportPromise=this.loadOpentelemetry());let n=Date.now();this.initPromise=q.dynamicImportPromise.then(r=>{q.dynamicImportStatus===`completed`&&this.init({name:e,getParentContext:t},n)})}init({name:e,getParentContext:t},n){this.span=q.rootTracer.startSpan(e,{startTime:n},t?.()),this.context=q.dynamicImports.opentelemetryApi.trace.setSpan(q.dynamicImports.opentelemetryApi.context.active(),this.span)}async loadOpentelemetry(){if(q.dynamicImportStatus===`not_started`){q.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]);q.dynamicImports={opentelemetryApi:n,opentelemetrySdk:r,tracer:i},q.dynamicImportStatus=`completed`}catch{q.dynamicImportStatus=`failed`}}}isComponentTracerNotInitialized(){return v(this.span)||q.dynamicImportStatus===`failed`}log(e,t){let n=Date.now();this.initPromise.then(r=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...K(t),type:`log`},n)})}error(e,t){let n=Date.now();this.initPromise.then(r=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...K(t),type:`error`},n)})}critical(e,t){let n=Date.now();this.initPromise.then(r=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...K(t),type:`critical`},n)})}createComponentTracer(e){let t=new q({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 lt extends q{spanExporter;constructor(){super({name:`Root`})}init({name:e,getParentContext:t},n){let r=q.dynamicImports.tracer.initTracerOpenTelemetry({serviceName:`videoplayer-sdk-web`,appToken:`L9SBoka6ZWk4xPjaK7tmfSfYvMhcge7nvGDjpdMmscb`,spanLimits:{attributeCountLimit:1/0,eventCountLimit:1/0,attributePerEventCountLimit:1/0}}).getProvider(),i=new q.dynamicImports.tracer.TracerMemorySpanExporter;this.spanExporter=i,r.addSpanProcessor(new q.dynamicImports.tracer.TracerAllSpansProcessor({startedSpansExporter:i})),q.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 J{fakeTraceId;constructor(e){}log(e,t){}error(e,t){}critical(e,t){}createComponentTracer(e){return new J({name:e})}end(){}getFinishedSpans(){}getTraceId(){return this.fakeTraceId}}class ut{static createRootTracer(e=!1){return e?new lt:new J}}var Y;(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`})(Y||={});var X;(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`})(X||={});var dt=`vk.com`,ft=async(e,t,n)=>{let r=new URL(`https://${dt}/js/lang-pack.js`);return r.searchParams.set(`format`,`json`),r.searchParams.set(`name`,t),e!==void 0&&r.searchParams.set(`lang`,e),pt(await(await fetch(r.toString())).json(),n)},pt=(e,t)=>Object.fromEntries(Object.entries(e.keys).map(([e,n])=>[e.substring(`${t}_`.length),mt(n)])),mt=e=>Array.isArray(e)?e[0]:e,ht;(e=>{e.RU=`ru`,e.EN=`en`})(ht||={});var Z=`__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[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 _t={};r(_t,{subscribe:()=>xt,push:()=>bt,destroy:()=>yt,create:()=>vt});var Q=new Map,vt=(e,t)=>Q.set(e,t??[]),yt=e=>Q.delete(e),bt=(e,t)=>{let n=Q.get(e);n&&(typeof n==`function`?n(t):n.push(t))},xt=(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)}},St=`gW5EerTD5QhAnsbpF7Hd2NSMRteYIUUMjFbSyI68Pf5`,Ct=e=>y({id:e.id,message:e.message,category:e.category,data:wt(e.data),httpCode:e.httpCode,UVBackendErrorCode:e.UVBackendErrorCode});function wt(e){switch(typeof e){case`boolean`:case`string`:case`number`:return e;case`object`:try{return JSON.stringify(e)}catch{return}default:return}}var Tt=e=>{if(e.thrown instanceof Error)return e.thrown;let t=Error(e.message);return t.name=e.id,t},Et=()=>{try{let{origin:e,pathname:t,search:n,hostname:r}=S().document.location;return r===`localhost`?void 0:{url:e+t,...new URLSearchParams(n).entries().reduce((e,[t,n])=>(e[`url.${t}`]=n,e),{})}}catch(e){console.error(e)}};class ${static tracerErrorMap=new Map;static appTracerModule=null;static loadPromise=null;dynamicImportTimeout=5e3;componentName;subscription=new o;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(Tt(e),{severity:t?.severity??(e.traceAsLog?`debug`:void 0),keys:{...this.context,...Ct(e),...Et()}})}addSubscription(e){this.subscription.add(e)}destroy(){this.subscription.unsubscribe()}async init(){try{if(await $.loadPromise,$.tracerErrorMap.has(this.componentName)||v($.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:St,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(){_($.loadPromise)||($.loadPromise=(async()=>{try{let e=new Promise((e,t)=>S().setTimeout(t,this.dynamicImportTimeout));$.appTracerModule=await Promise.race([e,import(`@apptracer/sdk/lite`)])}catch{$.loadPromise=null}})())}}export{y as withoutNullable,pe as videoSizeToQuality,me as videoQualityToHeight,fe as videoHeightToQuality,Ce as timeout,ve as timeCodeToString,z as throttleFn,Pe as throttle,qe as tap,st as suppressAbort,Ye as skip,Ze as shareReplay,D as safeStorage,Ge as pairwise,We as once,$e as observeElementSize,Te as observableFrom,T as now,l as noop,Se as merge,Ue as mapTo,U as map,ft as loadVKLangPack,tt as isValidURL,v as isNullable,_ as isNonNullable,ue as isLowerOrEqual,P as isLower,I as isInvariantQuality,nt as isIntersecting,le as isHigherOrEqual,ce as isHigher,C as isBrowserWindow,G as isAbortError,we as interval,at as interpolate,S as getWindow,_e as getVideoQualityLabel,ct as getTraceSubscriptionMethod,ot as getRangeAroundIndex,it as getPlayerId,de as getHighestQuality,ee as getExponentialDelay,Ee as fromEvent,W as flattenObject,Be as filterChanged,Ie as filter,L as fillWithDefault,_t as devNull,se as detectEmbed,R as debounceFn,je as debounce,xe as combine,B as cloneDeepWith,ye as cloneDeep,et as clearVideoElement,c as checkNever,Oe as buffer,ge as assertQualityIsExact,g as assertNullable,b as assertNotEmptyArray,h as assertNonNullable,s as assertNever,x as assertEmptyArray,he as areQualitiesExact,w as addScript,E as abortable,M as VideoQuality,be as ValueSubject,X as VKNumericLanguage,a as VERSION,ut as TracerFactory,De as SubscriptionRemovable,o as Subscription,p as Subject,V as ReplaySubject,f as Observable,m as Logger,gt as InternalsExposure,ht as InterfaceLanguage,Z as INTERNAL_EXPOSE_GLOBAL_KEY,Y 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={};try{let e=globalThis;for(let t of[`Comment`,`Node`,`EventTarget`,`HTMLElement`,`HTMLMediaElement`,`ShadowRoot`,`Date`,`Map`,`Set`,`Error`])typeof e[t]==`function`&&(i[t]=e[t])}catch{}var a=globalThis;a.__svelte_safe_instanceof===void 0&&(a.__svelte_safe_instanceof=(e,t,n)=>{let r=t;if(typeof t!=`function`){let e=n?.split(`:`)[1];if(e&&e in i&&(r=i[e]),typeof r!=`function`&&e===`Comment`)try{r=globalThis.document.createComment(``).constructor}catch{}if(typeof r!=`function`)return!1}return e instanceof r});var o=`1.0.85-dev.2ff58f4df.0`;class s{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 c=e=>{throw Error(`${e} is value of unexpected type`)},l=e=>{},u=()=>{},d=e=>{throw console.error(e),e},f=e=>{console.error(e)};class p{suppressErrors=!1;constructor(e){e&&(this._subscribe=e)}setSuppressErrors(e){this.suppressErrors=e}subscribe(e,t){let n=this.suppressErrors?f:d,r;r=t?typeof t==`function`?{next:t,error:u}:{next:e=>t.next(e),error:e=>t.error?.(e)}:{next:n,error:u};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)},a;try{a=this._subscribe(i)}catch(e){i.error?.(e)}return new s().add(()=>{switch(i.next=u,i.error=u,typeof a){case`function`:a();return;case`object`:a.unsubscribe();return;case`undefined`:return;default:return c(a)}})}pipe(...e){return e.reduce((e,t)=>t(e),this)}_subscribe(e){}}class m extends p{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 s().add(()=>this.subscribers.delete(t))}}class h{log$=new m;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 ee(e,t=`Assertion "value is not nullable" failed`){if(e==null)throw Error(t)}function te(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(),ne=(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},re=(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:()=>oe,remove:()=>ce,isPersistent:()=>ie,has:()=>se,get:()=>ae,clear:()=>le});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},ie=()=>k()===0,ae=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:c(t)}},oe=(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:c(n)}},se=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 c(t),!1}},ce=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:c(t)}},le=()=>{let e=k();switch(e){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return E?.clear();default:c(e)}},ue=()=>{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}},de=(e,t)=>j[e].height>j[t].height,fe=(e,t)=>j[e].height>=j[t].height,M=(e,t)=>j[e].height<j[t].height,pe=(e,t)=>j[e].height<=j[t].height,me=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),he=(e,t=.02)=>[...N].find(n=>j[n].height*(1+t)>=e),ge=({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})},_e=e=>j[e].height,P=e=>e===`Invariant quality`,ve=e=>e.every(e=>!P(e));function ye(e){if(P(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``}},F=(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]=F(a,i):n[r]=i:n[r]=r in e?a:i}return n},xe=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 ee(e){if(p){x().cancelAnimationFrame(e);return}clearTimeout(e)}function te(e){return l=e,s=h(v,t),u?m(e):o}function g(e){let n=e-c,r=e-l,i=t-n;return d?Math.min(i,a-r):i}function _(e){let n=e-c,r=e-l;return c===void 0||n>=t||n<0||d&&r>=a}function v(){let e=Date.now();if(_(e))return y(e);s=h(v,g(e))}function y(e){return s=void 0,f&&r?m(e):(r=i=void 0,o)}function b(){s!==void 0&&ee(s),l=0,r=c=i=s=void 0}function S(){return s===void 0?o:y(Date.now())}function C(){return s!==void 0}function w(...e){let n=Date.now(),a=_(n);if(r=e,i=this,c=n,a){if(s===void 0)return te(c);if(d)return s=h(v,t),m(c)}return s===void 0&&(s=h(v,t)),o}return w.cancel=b,w.flush=S,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},Se=e=>R(e);class z extends m{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 s().add(()=>this.subscribers.delete(t))}}class Ce extends m{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 we(e){return new p(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 s)})}function Te(...e){return new p(t=>e.reduce((e,n)=>e.add(n.subscribe(t)),new s))}var Ee=e=>new p(t=>{let n=x().setTimeout(()=>{try{t.next()}catch(e){if(t.error)t.error(e);else throw e}},e);return()=>x().clearTimeout(n)}),De=e=>new p(t=>{let n=x(),r=n.setInterval(()=>t.next(),e);return()=>{r&&=(n.clearInterval(r),void 0)}}),Oe=e=>new p(t=>{e.forEach(e=>t.next(e))}),ke=(e,t)=>new p(n=>{let r=e=>n.next(e);return e.addEventListener(t,r),()=>e.removeEventListener(t,r)});class Ae extends s{remove(e){this.subscriptions=this.subscriptions.filter(t=>t!==e)}}function je(e){return t=>new p(n=>t.subscribe(new Me(n,e)))}class Me{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 Ne={leading:!1,trailing:!0};function Pe(e,t=Ne){return n=>new p(r=>n.subscribe(new Fe(r,e,t)))}class Fe{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 Ie={leading:!0,trailing:!1};function Le(e,t=Ie){return n=>new p(r=>n.subscribe(new Re(r,e,t)))}class Re{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 ze(e){return t=>new p(n=>t.subscribe(new Be(n,e)))}class Be{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 Ve=(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)},He=(e,t)=>e instanceof Object&&t instanceof Object?Ve(e,t):e===t;function Ue(e=He){return t=>new p(n=>t.subscribe(new We(n,e)))}var B={};class We{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 p(n=>t.subscribe(new Ge(n,e)))}class Ge{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 Ke(e){return V(()=>e)}function qe(){return e=>new p(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 Je(){return e=>new p(t=>e.subscribe(new Ye(t)))}class Ye{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 Xe(e){return t=>new p(n=>t.subscribe(new Ze(n,e)))}class Ze{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 Qe(e){return t=>new p(n=>t.subscribe(new $e(n,e)))}class $e{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 et(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 p(e=>(n++,a(r.subscribe(e))))}}var tt=300,nt=(e,t=tt)=>new p(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},rt=(e,t=!1)=>{t&&(e.innerHTML=``),e.removeAttribute(`src`),e.load()},it=e=>{let t;try{t=new URL(e)}catch{return!1}return t.protocol===`https:`},at=(e,t)=>!(e.right<t.left||e.left>t.right||e.bottom<t.top||e.top>t.bottom),ot=(()=>{let e=0;return()=>{let t=e;return e=(e+1)%(2**53-1),t}})(),st=e=>e!==void 0&&e!==``?e:ot().toString();function ct(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 lt(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),ut=e=>{if(!U(e))throw e},dt=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 ft 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 pt{static createRootTracer(e=!1){return e?new ft: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 mt=`vk.com`,ht=async(e,t,n)=>{let r=new URL(`https://${mt}/js/lang-pack.js`);return r.searchParams.set(`format`,`json`),r.searchParams.set(`name`,t),e!==void 0&&r.searchParams.set(`lang`,e),gt(await(await fetch(r.toString())).json(),n)},gt=(e,t)=>Object.fromEntries(Object.entries(e.keys).map(([e,n])=>[e.substring(`${t}_`.length),_t(n)])),_t=e=>Array.isArray(e)?e[0]:e,Y;(e=>{e.RU=`ru`,e.EN=`en`})(Y||={});var X=`__vk_vp_internals_exposure`;class vt{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:()=>St,push:()=>xt,destroy:()=>bt,create:()=>yt});var Q=new Map,yt=(e,t)=>Q.set(e,t??[]),bt=e=>Q.delete(e),xt=(e,t)=>{let n=Q.get(e);n&&(typeof n==`function`?n(t):n.push(t))},St=(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)}},Ct=`gW5EerTD5QhAnsbpF7Hd2NSMRteYIUUMjFbSyI68Pf5`,wt=e=>v({id:e.id,message:e.message,category:e.category,data:Tt(e.data),httpCode:e.httpCode,UVBackendErrorCode:e.UVBackendErrorCode});function Tt(e){switch(typeof e){case`boolean`:case`string`:case`number`:return e;case`object`:try{return JSON.stringify(e)}catch{return}default:return}}var Et=e=>{if(e.thrown instanceof Error)return e.thrown;let t=Error(e.message);return t.name=e.id,t},Dt=()=>{try{let{origin:e,pathname:t,search:n,hostname:r}=x().document.location;return r===`localhost`?void 0:{url:e+t,...new URLSearchParams(n).entries().reduce((e,[t,n])=>(e[`url.${t}`]=n,e),{})}}catch(e){console.error(e)}};class ${static tracerErrorMap=new Map;static appTracerModule=null;static loadPromise=null;dynamicImportTimeout=5e3;componentName;subscription=new s;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(Et(e),{severity:t?.severity??(e.traceAsLog?`debug`:void 0),keys:{...this.context,...wt(e),...Dt()}})}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:Ct,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,ge as videoSizeToQuality,_e as videoQualityToHeight,he as videoHeightToQuality,Ee as timeout,xe as timeCodeToString,L as throttleFn,Le as throttle,Xe as tap,ut as suppressAbort,Qe as skip,et as shareReplay,T as safeStorage,Je as pairwise,qe as once,nt as observeElementSize,Oe as observableFrom,w as now,u as noop,Te as merge,Ke as mapTo,V as map,ht as loadVKLangPack,it as isValidURL,_ as isNullable,g as isNonNullable,pe as isLowerOrEqual,M as isLower,P as isInvariantQuality,at as isIntersecting,fe as isHigherOrEqual,de as isHigher,S as isBrowserWindow,U as isAbortError,De as interval,ct as interpolate,x as getWindow,be as getVideoQualityLabel,dt as getTraceSubscriptionMethod,lt as getRangeAroundIndex,st as getPlayerId,me as getHighestQuality,re as getExponentialDelay,ke as fromEvent,H as flattenObject,Ue as filterChanged,ze as filter,F as fillWithDefault,Z as devNull,ue as detectEmbed,I as debounceFn,Pe as debounce,we as combine,R as cloneDeepWith,Se as cloneDeep,rt as clearVideoElement,l as checkNever,je as buffer,ye as assertQualityIsExact,te as assertNullable,y as assertNotEmptyArray,ee as assertNonNullable,c as assertNever,b as assertEmptyArray,ve as areQualitiesExact,C as addScript,ne as abortable,A as VideoQuality,Ce as ValueSubject,J as VKNumericLanguage,o as VERSION,pt as TracerFactory,Ae as SubscriptionRemovable,s as Subscription,m as Subject,z as ReplaySubject,p as Observable,h as Logger,vt as InternalsExposure,Y as InterfaceLanguage,X as INTERNAL_EXPOSE_GLOBAL_KEY,q as ErrorCategory,$ as AppTracer};
7
7
  //# sourceMappingURL=evergreen.esm.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vkontakte/videoplayer-shared",
3
- "version": "1.0.85-dev.200a948d7.0",
3
+ "version": "1.0.85-dev.2ff58f4df.0",
4
4
  "author": "vk.com",
5
5
  "description": "Shared code for vk.com videoplayer",
6
6
  "homepage": "https://vk.com",
@@ -1,17 +1,14 @@
1
1
  /**
2
- * Безопасный перехватчик instanceof для Svelte 5 runtime.
2
+ * Защита Svelte 5 runtime от перезаписи глобальных DOM-конструкторов.
3
3
  *
4
- * Svelte 5 при инициализации каждого модуля проверяет:
5
- * globalThis.__svelte_safe_instanceof || function(l, r) { return l instanceof r; }
4
+ * Проблема: на vk.com сторонний код (GraphQL operations) перезаписывает
5
+ * `globalThis.Comment` объектом `{ onDone: ... }`. Svelte runtime использует
6
+ * `value instanceof Comment` для определения типа DOM-нод, и падает с
7
+ * "TypeError: Illegal invocation" / "Right-hand side of instanceof is not callable".
6
8
  *
7
- * Если RHS (правая часть) instanceof undefined или не function,
8
- * нативный instanceof бросает TypeError. Это происходит в кросс-iframe
9
- * сценариях, когда DOM-конструкторы (Comment, EventTarget и т.д.)
10
- * берутся из другого window-контекста.
11
- *
12
- * Этот модуль устанавливает безопасную обёртку, которая:
13
- * - логирует проблемный вызов с location и стектрейсом
14
- * - возвращает false вместо throw
9
+ * Решение: сохраняем ссылки на нативные DOM-конструкторы при загрузке модуля
10
+ * (до того как их перезапишут), и в `__svelte_safe_instanceof` подставляем
11
+ * нативный конструктор вместо перезаписанного.
15
12
  *
16
13
  * ВАЖНО: должен загружаться ДО любого Svelte-модуля (через shared → первый в графе зависимостей).
17
14
  */