@vkontakte/videoplayer-shared 1.0.38-dev.c2293902.0 → 1.0.38-dev.df616f9c.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es2015.cjs.js +3 -3
- package/es2015.esm.js +3 -3
- package/es2018.cjs.js +3 -3
- package/es2018.esm.js +3 -3
- package/esnext.cjs.js +3 -3
- package/esnext.esm.js +3 -3
- package/evergreen.esm.js +3 -3
- package/package.json +1 -1
- package/types/utils/detectBrowser.d.ts +33 -0
- package/types/utils/index.d.ts +2 -1
- package/types/utils/clientChecker.d.ts +0 -52
package/es2015.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-shared v1.0.38-dev.
|
|
3
|
-
*
|
|
2
|
+
* @vkontakte/videoplayer-shared v1.0.38-dev.df616f9c.0
|
|
3
|
+
* Fri, 16 Aug 2024 08:31:38 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-38/doc/
|
|
5
5
|
*/
|
|
6
|
-
"use strict";var L=Object.defineProperty,lt=Object.defineProperties,ct=Object.getOwnPropertyDescriptor,ut=Object.getOwnPropertyDescriptors,pt=Object.getOwnPropertyNames,Te=Object.getOwnPropertySymbols;var he=Object.prototype.hasOwnProperty,bt=Object.prototype.propertyIsEnumerable;var Ie=Math.pow,ve=(r,e,t)=>e in r?L(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,w=(r,e)=>{for(var t in e||(e={}))he.call(e,t)&&ve(r,t,e[t]);if(Te)for(var t of Te(e))bt.call(e,t)&&ve(r,t,e[t]);return r},V=(r,e)=>lt(r,ut(e));var xe=(r,e)=>{for(var t in e)L(r,t,{get:e[t],enumerable:!0})},dt=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of pt(e))!he.call(r,i)&&i!==t&&L(r,i,{get:()=>e[i],enumerable:!(n=ct(e,i))||n.enumerable});return r};var ft=r=>dt(L({},"__esModule",{value:!0}),r);var M=(r,e,t)=>new Promise((n,i)=>{var s=c=>{try{o(t.next(c))}catch(u){i(u)}},a=c=>{try{o(t.throw(c))}catch(u){i(u)}},o=c=>c.done?n(c.value):Promise.resolve(c.value).then(s,a);o((t=t.apply(r,e)).next())});var Ct={};xe(Ct,{CC:()=>ke,ErrorCategory:()=>Ze,InterfaceLanguage:()=>tt,Logger:()=>N,Observable:()=>l,Subject:()=>I,Subscription:()=>m,VERSION:()=>ge,VKNumericLanguage:()=>et,ValueSubject:()=>R,VideoQuality:()=>D,abortable:()=>Pe,addScript:()=>Re,areQualitiesExact:()=>ze,assertEmptyArray:()=>Se,assertNever:()=>h,assertNonNullable:()=>Oe,assertNotEmptyArray:()=>Ee,assertNullable:()=>we,assertQualityIsExact:()=>je,buffer:()=>$,checkNever:()=>ye,clearVideoElement:()=>qe,cloneDeep:()=>Ge,cloneDeepWith:()=>S,combine:()=>q,debounce:()=>J,debounceFn:()=>F,detectEmbed:()=>Ve,fillWithDefault:()=>We,filter:()=>re,filterChanged:()=>ie,fromEvent:()=>Xe,getExponentialDelay:()=>Le,getHighestQuality:()=>Qe,interval:()=>Ye,isHigher:()=>Me,isHigherOrEqual:()=>Ne,isInvariantQuality:()=>B,isLower:()=>U,isLowerOrEqual:()=>_e,isNonNullable:()=>y,isNullable:()=>_,loadVKLangPack:()=>St,map:()=>A,mapTo:()=>se,merge:()=>K,noop:()=>x,now:()=>Ce,observableFrom:()=>$e,observeElementSize:()=>He,once:()=>ae,pairwise:()=>ce,safeStorage:()=>Q,tap:()=>pe,throttle:()=>ee,throttleFn:()=>z,timeCodeToString:()=>gt,timeout:()=>Ke,videoHeightToQuality:()=>Ue,videoQualityToHeight:()=>Fe,videoSizeToQuality:()=>Be});module.exports=ft(Ct);var ge="1.0.38-dev.c2293902.0";var m=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(t=>typeof t=="function"?t():t.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var h=r=>{throw new Error(`${r} is value of unexpected type`)},ye=r=>{};var x=()=>{};var l=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,t){var a;let n;t?typeof t=="function"?n={next:t,error:x}:n={next:o=>t.next(o),error:o=>{var c;return(c=t.error)==null?void 0:c.call(t,o)}}:n={next:x,error:x};let i=typeof e=="function"?{next:o=>{try{e(o)}catch(c){n.next(c)}},error:o=>n.next(o)}:{next:o=>e.next(o),error:o=>e.error?e.error(o):n.next(o)},s;try{s=this._subscribe(i)}catch(o){(a=i.error)==null||a.call(i,o)}return new m().add(()=>{switch(i.next=x,i.error=x,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return h(s)}})}pipe(...e){return e.reduce((t,n)=>n(t),this)}_subscribe(e){}};var I=class extends l{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(t){this.subscribers.forEach(n=>n.next(t))}error(t){this.subscribers.forEach(n=>{var i;return(i=n.error)==null?void 0:i.call(n,t)})}_subscribe(t){let n=this.keyCounter++;return this.subscribers.set(n,t),new m().add(()=>this.subscribers.delete(n))}};var N=class{constructor(){this.log$=new I;this.logs=[];this.log=e=>{let t=V(w({},e),{timestamp:Date.now()});this.logs.push(t),this.log$.next(t)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...t)=>{let n;try{n=e(...t)}catch(i){n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(t=>w({component:e},t))}};function Oe(r,e='Assertion "value is not nullable" failed'){if(r==null)throw new Error(e)}function we(r,e='Assertion "value is nullable" failed'){if(r!=null)throw new Error(e)}function y(r){return typeof r!="undefined"&&r!==null}function _(r){return r==null}function Ee(r,e){if(!(r!=null&&r.length))throw new Error(e)}function Se(r,e){if(r!=null&&r.length)throw new Error(e)}var Re=(r,e,t)=>new Promise((n,i)=>{e.addEventListener("abort",()=>{o(),u.remove()});let s=()=>{o(),i()},a=()=>{o(),n()},o=()=>{c&&clearTimeout(c),u.removeEventListener("load",a),u.removeEventListener("error",s)},c;t&&(c=window.setTimeout(s,t));let u=document.createElement("script");u.addEventListener("load",a),u.addEventListener("error",s),u.src=r,document.head.appendChild(u)});var Ae,Ce=typeof((Ae=window.performance)==null?void 0:Ae.now)=="function"?()=>window.performance.now():()=>Date.now();var Pe=(r,e)=>(...t)=>M(void 0,null,function*(){var a;let n=e(...t),i=r.aborted,s;for(;!i&&!r.aborted;)try{let o=yield n.next(s);i=(a=o.done)!=null?a:!1,s=o.value}catch(o){yield n.throw(o)}return s});var G=class{constructor(){this.detect()}get browser(){return this._currentBrowser}get device(){return this._currentDevice}get isTouch(){return this._maxTouchPoints>0}get isIOS(){return["iPhone","iPad","iPod"].includes(this.device)}get isMac(){return this.device==="Mac"}get isApple(){return this.isIOS||this.isMac}get isIphoneOrOldIpad(){if(!this.isApple||!this.isTouch)return!1;let e=this.device==="iPad"||(window==null?void 0:window.screen.width)>700,t=this._iosVersion;return!e||e&&!!t&&t<16}get isAndroid(){return this.device==="Android"}get isMobile(){var e,t;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test((e=navigator.appVersion)!=null?e:navigator.userAgent)||((t=navigator==null?void 0:navigator.userAgentData)==null?void 0:t.mobile)}get iOSVersion(){return this._iosVersion}get macVersion(){return this._macVersion}get isYandex(){return this.browser==="Yandex"}get isSafari(){return this.browser==="Safari"}get isSamsungBrowser(){return this.browser==="SamsungBrowser"}get isHDR(){return this._isHdr}detect(){var n;let{userAgent:e,maxTouchPoints:t}=navigator;try{this._maxTouchPoints=t,this._isHdr=!!((n=matchMedia("(dynamic-range: high)"))!=null&&n.matches)}catch(i){console.error(i)}this.detectBrowser(e),this.detectDevice(e),this.isIOS&&this.detectIOSVersion(),this.isMac&&this.detectMacVersion()}detectBrowser(e){try{let t=/yabrowser/i.test(e)?"Yandex":void 0,n=/samsungbrowser/i.test(e)?"SamsungBrowser":void 0,i=/chrome|crios/i.test(e)?"Chrome":void 0,s=/chromium/i.test(e)?"Chromium":void 0,a=/firefox|fxios/i.test(e)?"Firefox":void 0,o=/webkit|safari|khtml/i.test(e)?"Safari":void 0,c=/opr\//i.test(e)?"Opera":void 0,u=/edg/i.test(e)?"Edge":void 0;this._currentBrowser=t||n||a||c||u||i||s||o||"Rest"}catch(t){console.error(t)}}detectDevice(e){try{let t=/android/i.test(e)?"Android":void 0,n=/iphone/i.test(e)?"iPhone":void 0,i=/ipad/i.test(e)?"iPad":void 0,s=/ipod/i.test(e)?"iPod":void 0,a=/mac/i.test(e)?"Mac":void 0,o=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(e)?"RestMobile":void 0;this._currentDevice=t||n||i||s||o||a||"Desktop"}catch(t){console.error(t)}}detectIOSVersion(){try{let{userAgent:e}=window.navigator,t=e.match(/Version\/(\d+(\.\d+)?)/i);if(!t)return;let n=t[1],i=parseFloat(n);if(isNaN(i))return;this._iosVersion=i}catch(e){console.error(e)}}detectMacVersion(){try{let{userAgent:e}=window.navigator,t=e.match(/Version\/(\d+)/);if(!t)return;let n=t[1],i=parseInt(n,10);if(isNaN(i))return;this._macVersion=i}catch(e){console.error(e)}}},ke=new G;var Le=(r,{start:e=0,factor:t=2,max:n=1/0,min:i=e,random:s=0}={})=>{let a=e;return a*=Ie(t,r),a*=1+(Math.random()*s*2-s),a=Math.round(a),a=Math.min(a,n),a=Math.max(a,i),a};var Q={};xe(Q,{clear:()=>xt,get:()=>Tt,has:()=>ht,isPersistent:()=>mt,remove:()=>It,set:()=>vt});var d,O,H=`vk-videoplayer-dummy-key-${Math.random()}`,E=()=>{if(O!==void 0)return O;try{localStorage.setItem(H,"test"),localStorage.removeItem(H),O=0}catch(r){if(r instanceof DOMException||r instanceof TypeError)try{sessionStorage.getItem(H),O=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)O=2;else throw e}else throw r}return O===2&&(d=new Map),O},mt=()=>E()===0,Tt=r=>{var t,n;let e=E();switch(e){case 0:return(t=localStorage.getItem(r))!=null?t:void 0;case 1:return(n=sessionStorage.getItem(r))!=null?n:void 0;case 2:return d==null?void 0:d.get(r);default:h(e)}},vt=(r,e)=>{let t=E();switch(t){case 0:try{localStorage.setItem(r,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(r,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void(d==null?void 0:d.set(r,e));default:h(t)}},ht=r=>{var t;let e=E();switch(e){case 0:return r in localStorage;case 1:return r in sessionStorage;case 2:return(t=d==null?void 0:d.has(r))!=null?t:!1;default:return h(e),!1}},It=r=>{let e=E();switch(e){case 0:return localStorage.removeItem(r);case 1:return sessionStorage.removeItem(r);case 2:return void(d==null?void 0:d.delete(r));default:h(e)}},xt=()=>{let r=E();switch(r){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return d==null?void 0:d.clear();default:h(r)}};var Ve=()=>{let r,e;try{r=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?r=!0:(r=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let t=e?new URL(e).hostname:void 0;return{isEmbed:r,host:t}};var D=(f=>(f.INVARIANT="Invariant quality",f.Q_144P="144p",f.Q_240P="240p",f.Q_360P="360p",f.Q_480P="480p",f.Q_720P="720p",f.Q_1080P="1080p",f.Q_1440P="1440p",f.Q_2160P="2160p",f.Q_4320P="4320p",f))(D||{});var T={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"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}},Me=(r,e)=>T[r].height>T[e].height,Ne=(r,e)=>T[r].height>=T[e].height,U=(r,e)=>T[r].height<T[e].height,_e=(r,e)=>T[r].height<=T[e].height,Qe=r=>r.sort((e,t)=>e===t?0:e==="Invariant quality"?1:t==="Invariant quality"?-1:U(e,t)?1:-1)[0],De=Object.keys(T).sort((r,e)=>U(r,e)?-1:1),Ue=(r,e=.02)=>[...De].find(n=>T[n].height*(1+e)>=r),Be=({width:r,height:e})=>{let t=Math.min(r,e),n=Math.max(r,e);return De.find(i=>{let s=T[i];return s.width>=n&&s.height>=t})},Fe=r=>T[r].height,B=r=>r==="Invariant quality",ze=r=>r.every(e=>!B(e));function je(r){if(B(r))throw new Error("Expected exact quality")}var We=(r,e)=>{let t={};for(let n of Object.keys(e)){let i=e[n],s=r[n];Array.isArray(i)&&Array.isArray(s)?t[n]=s:typeof i=="object"&&typeof s=="object"?t[n]=We(s,i):t[n]=n in r?s:i}return t};var gt=r=>{let e="";return r>=3600&&(e+=Math.floor(r/3600)+"h",r=r%3600),r>=60&&(e+=Math.floor(r/60)+"m",r=r%60),r>0&&(e+=Math.floor(r)+"s"),e};function F(r,e=0,t){let n,i,s,a,o,c,u=0,f=!1,b=!1,j=!0,be=!e&&e!==0&&typeof window.requestAnimationFrame=="function";t&&(f=!!t.leading,b="maxWait"in t,s=t!=null&&t.maxWait?Math.max(+(t==null?void 0:t.maxWait)||0,e):s,j="trailing"in t?!!t.trailing:j);function W(p){let v=n,g=i;return n=i=void 0,u=p,a=r.apply(g,v),a}function C(p,v){return be?(o&&window.cancelAnimationFrame(o),window.requestAnimationFrame(p)):setTimeout(p,v)}function rt(p){if(be){window.cancelAnimationFrame(p);return}clearTimeout(p)}function nt(p){return u=p,o=C(P,e),f?W(p):a}function it(p){let v=p-c,g=p-u,me=e-v;return b?Math.min(me,s-g):me}function de(p){let v=p-c,g=p-u;return c===void 0||v>=e||v<0||b&&g>=s}function P(){let p=Date.now();if(de(p))return fe(p);o=C(P,it(p))}function fe(p){return o=void 0,j&&n?W(p):(n=i=void 0,a)}function ot(){o!==void 0&&rt(o),u=0,n=c=i=o=void 0}function st(){return o===void 0?a:fe(Date.now())}function at(){return o!==void 0}function k(...p){let v=Date.now(),g=de(v);if(n=p,i=this,c=v,g){if(o===void 0)return nt(c);if(b)return o=C(P,e),W(c)}return o===void 0&&(o=C(P,e)),a}return k.cancel=ot,k.flush=st,k.pending=at,k}var z=(r,e=0,t)=>F(r,e,V(w(w({},{leading:!0,trailing:!0}),t),{maxWait:e}));var S=(r,e)=>{if(r===null||typeof r!="object")return r;let t=Array.isArray(r)?[]:{};for(let n in r){if(typeof e=="function"){let i=e(r[n],n,r,t);if(i!==void 0){t[n]=i;continue}}typeof r[n]=="object"?t[n]=S(r[n],e):t[n]=r[n]}return t};var Ge=r=>S(r);var yt=300,He=(r,e=yt)=>new l(t=>{let{width:n,height:i}=r.getBoundingClientRect();if(t.next({width:n,height:i}),!window.ResizeObserver)return;let s=new ResizeObserver(z(a=>{let o=a[0];if(!o)return;let c,u;o.contentBoxSize&&o.contentBoxSize[0]?(u=o.contentBoxSize[0].blockSize,c=o.contentBoxSize[0].inlineSize):o.contentRect&&(c=o.contentRect.width,u=o.contentRect.height),y(c)&&y(u)&&t.next({width:c,height:u})},e));return s.observe(r),()=>s.disconnect()});var qe=r=>{r.removeAttribute("src"),r.load()};var R=class extends I{constructor(t){super();this.value=t}next(t){super.next(this.value=t)}error(t){super.error(this.value=t)}getValue(){return this.value}_subscribe(t){let n=super._subscribe(t);return t.next(this.value),n}};function q(r){return new l(e=>{let t={},n=Object.keys(r).length,i=s=>a=>{s in t||n--,t[s]=a,n===0&&e.next(t)};return Object.entries(r).reduce((s,[a,o])=>s.add(o.subscribe(i(a))),new m)})}function K(...r){return new l(e=>r.reduce((t,n)=>t.add(n.subscribe(e)),new m))}var Ke=r=>new l(e=>{let t=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},r);return()=>window.clearTimeout(t)});var Ye=r=>new l(e=>{let t=window.setInterval(()=>e.next(),r);return()=>{t&&(window.clearInterval(t),t=void 0)}});var $e=r=>new l(e=>{r.forEach(t=>e.next(t))});var Xe=(r,e)=>new l(t=>{let n=i=>t.next(i);return r.addEventListener(e,n),()=>r.removeEventListener(e,n)});function $(r){return e=>new l(t=>e.subscribe(new Y(t,r)))}var Y=class{constructor(e,t){this.destination=e;this.size=t;this.lastValues=[]}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};var Ot={leading:!1,trailing:!0};function J(r,e=Ot){return t=>new l(n=>t.subscribe(new X(n,r,e)))}var X=class{constructor(e,t,n){this.destination=e;this.time=t;this.config=n}next(e){this.lastValue=e,y(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(t){if(this.destination.error)this.destination.error(t);else throw t}this.timeout=void 0},this.time)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};var wt={leading:!0,trailing:!1};function ee(r,e=wt){return t=>new l(n=>t.subscribe(new Z(n,r,e)))}var Z=class{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=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function re(r){return e=>new l(t=>e.subscribe(new te(t,r)))}var te=class{constructor(e,t){this.destination=e;this.predicate=t}next(e){let t;try{t=this.predicate(e)}catch(n){throw this.error(n),n}t&&this.destination.next(e)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function ie(r=(e,t)=>e===t){return e=>new l(t=>e.subscribe(new ne(t,r)))}var Je={},ne=class{constructor(e,t){this.destination=e;this.predicate=t;this.lastValue=Je}next(e){let t;try{t=this.lastValue===Je||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}t&&this.destination.next(e)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function A(r){return e=>new l(t=>e.subscribe(new oe(t,r)))}var oe=class{constructor(e,t){this.destination=e;this.mapper=t}next(e){let t;try{t=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(t)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function se(r){return A(()=>r)}function ae(){return r=>new l(e=>{let t=!1,n=!1,i=r.subscribe(s=>{t||(t=!0,e.next(s)),n&&i.unsubscribe()},s=>{var a;t=!0,(a=e.error)==null||a.call(e,s),n&&i.unsubscribe()});return n=!0,t&&i.unsubscribe(),i})}function ce(){return r=>new l(e=>r.subscribe(new le(e)))}var le=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let t=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([t,e])}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function pe(r){return e=>new l(t=>e.subscribe(new ue(t,r)))}var ue=class{constructor(e,t){this.destination=e;this.effect=t}next(e){try{this.effect(e)}catch(t){throw this.error(t),t}this.destination.next(e)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};var Ze=(o=>(o.NETWORK="network",o.VIDEO_PIPELINE="video_pipeline",o.EXTERNAL_API="external_api",o.PARSER="parser",o.DOM="dom",o.WTF="wtf",o.FATAL="fatal",o))(Ze||{});var et=(b=>(b.Armenian="58",b.Azerbaijani="57",b.Belarusian="114",b.English="3",b.Kazakh="97",b.Portuguese="73",b.Russian="0",b.Spanish="4",b.Ukrainian="1",b.Uzbek="65",b.Vietnamese="75",b))(et||{}),Et="vk.com",St=(r,e,t)=>M(void 0,null,function*(){let n=new URL(`https://${Et}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),r!==void 0&&n.searchParams.set("lang",r);let s=yield(yield fetch(n.toString())).json();return Rt(s,t)}),Rt=(r,e)=>Object.fromEntries(Object.entries(r.keys).map(([t,n])=>[t.substring(`${e}_`.length),At(n)])),At=r=>Array.isArray(r)?r[0]:r;var tt=(t=>(t.RU="ru",t.EN="en",t))(tt||{});
|
|
6
|
+
"use strict";var Q=Object.defineProperty,ft=Object.defineProperties,mt=Object.getOwnPropertyDescriptor,Tt=Object.getOwnPropertyDescriptors,vt=Object.getOwnPropertyNames,Ie=Object.getOwnPropertySymbols;var he=Object.prototype.hasOwnProperty,It=Object.prototype.propertyIsEnumerable;var ge=Math.pow,xe=(t,e,r)=>e in t?Q(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,w=(t,e)=>{for(var r in e||(e={}))he.call(e,r)&&xe(t,r,e[r]);if(Ie)for(var r of Ie(e))It.call(e,r)&&xe(t,r,e[r]);return t},D=(t,e)=>ft(t,Tt(e));var ye=(t,e)=>{for(var r in e)Q(t,r,{get:e[r],enumerable:!0})},xt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of vt(e))!he.call(t,i)&&i!==r&&Q(t,i,{get:()=>e[i],enumerable:!(n=mt(e,i))||n.enumerable});return t};var ht=t=>xt(Q({},"__esModule",{value:!0}),t);var _=(t,e,r)=>new Promise((n,i)=>{var s=a=>{try{o(r.next(a))}catch(p){i(p)}},u=a=>{try{o(r.throw(a))}catch(p){i(p)}},o=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,u);o((r=r.apply(t,e)).next())});var Qt={};ye(Qt,{CurrentClientBrowser:()=>H,CurrentClientDevice:()=>K,ErrorCategory:()=>it,InterfaceLanguage:()=>at,Logger:()=>U,Observable:()=>l,Subject:()=>x,Subscription:()=>m,VERSION:()=>Oe,VKNumericLanguage:()=>st,ValueSubject:()=>k,VideoQuality:()=>z,abortable:()=>Pe,addScript:()=>Ce,areQualitiesExact:()=>Ke,assertEmptyArray:()=>Re,assertNever:()=>I,assertNonNullable:()=>Ee,assertNotEmptyArray:()=>Ae,assertNullable:()=>Se,assertQualityIsExact:()=>$e,buffer:()=>Z,checkNever:()=>we,clearVideoElement:()=>Ze,cloneDeep:()=>Xe,cloneDeepWith:()=>C,combine:()=>Y,debounce:()=>te,debounceFn:()=>G,detectEmbed:()=>Ue,fillWithDefault:()=>Ye,filter:()=>ie,filterChanged:()=>ae,fromEvent:()=>nt,getCurrentBrowser:()=>E,getExponentialDelay:()=>_e,getHighestQuality:()=>je,getIOSVersion:()=>Ne,interval:()=>tt,isAndroid:()=>Ve,isHigher:()=>Fe,isHigherOrEqual:()=>Be,isIOS:()=>Me,isInvariantQuality:()=>W,isLower:()=>j,isLowerOrEqual:()=>ze,isMacLike:()=>Qe,isMobile:()=>De,isNonNullable:()=>y,isNullable:()=>F,loadVKLangPack:()=>Mt,map:()=>L,mapTo:()=>ue,merge:()=>X,noop:()=>h,now:()=>Le,observableFrom:()=>rt,observeElementSize:()=>Je,once:()=>ce,pairwise:()=>be,safeStorage:()=>B,tap:()=>fe,throttle:()=>ne,throttleFn:()=>q,timeCodeToString:()=>Rt,timeout:()=>et,videoHeightToQuality:()=>Ge,videoQualityToHeight:()=>He,videoSizeToQuality:()=>qe});module.exports=ht(Qt);var Oe="1.0.38-dev.df616f9c.0";var m=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(r=>typeof r=="function"?r():r.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var I=t=>{throw new Error(`${t} is value of unexpected type`)},we=t=>{};var h=()=>{};var l=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,r){var u;let n;r?typeof r=="function"?n={next:r,error:h}:n={next:o=>r.next(o),error:o=>{var a;return(a=r.error)==null?void 0:a.call(r,o)}}:n={next:h,error:h};let i=typeof e=="function"?{next:o=>{try{e(o)}catch(a){n.next(a)}},error:o=>n.next(o)}:{next:o=>e.next(o),error:o=>e.error?e.error(o):n.next(o)},s;try{s=this._subscribe(i)}catch(o){(u=i.error)==null||u.call(i,o)}return new m().add(()=>{switch(i.next=h,i.error=h,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return I(s)}})}pipe(...e){return e.reduce((r,n)=>n(r),this)}_subscribe(e){}};var x=class extends l{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(r){this.subscribers.forEach(n=>n.next(r))}error(r){this.subscribers.forEach(n=>{var i;return(i=n.error)==null?void 0:i.call(n,r)})}_subscribe(r){let n=this.keyCounter++;return this.subscribers.set(n,r),new m().add(()=>this.subscribers.delete(n))}};var U=class{constructor(){this.log$=new x;this.logs=[];this.log=e=>{let r=D(w({},e),{timestamp:Date.now()});this.logs.push(r),this.log$.next(r)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...r)=>{let n;try{n=e(...r)}catch(i){n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(r=>w({component:e},r))}};function Ee(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function Se(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function y(t){return typeof t!="undefined"&&t!==null}function F(t){return t==null}function Ae(t,e){if(!(t!=null&&t.length))throw new Error(e)}function Re(t,e){if(t!=null&&t.length)throw new Error(e)}var Ce=(t,e,r)=>new Promise((n,i)=>{e.addEventListener("abort",()=>{o(),p.remove()});let s=()=>{o(),i()},u=()=>{o(),n()},o=()=>{a&&clearTimeout(a),p.removeEventListener("load",u),p.removeEventListener("error",s)},a;r&&(a=window.setTimeout(s,r));let p=document.createElement("script");p.addEventListener("load",u),p.addEventListener("error",s),p.src=t,document.head.appendChild(p)});var ke,Le=typeof((ke=window.performance)==null?void 0:ke.now)=="function"?()=>window.performance.now():()=>Date.now();var Pe=(t,e)=>(...r)=>_(void 0,null,function*(){var u;let n=e(...r),i=t.aborted,s;for(;!i&&!t.aborted;)try{let o=yield n.next(s);i=(u=o.done)!=null?u:!1,s=o.value}catch(o){yield n.throw(o)}return s});var H=(c=>(c.Unknown="Unknown",c.Yandex="Yandex",c.Chrome="Chrome",c.Chromium="Chromium",c.Firefox="Firefox",c.Safari="Safari",c.Opera="Opera",c.Edge="Edge",c.SamsungBrowser="SamsungBrowser",c.Rest="Rest",c))(H||{}),K=(a=>(a.Unknown="Unknown",a.Android="Android",a.iPhone="iPhone",a.iPad="iPad",a.iPod="iPod",a.RestMobile="RestMobile",a.Mac="Mac",a.Desktop="Desktop",a))(K||{}),E=()=>{let{userAgent:t}=window.navigator,e=/yabrowser/i.test(t)?"Yandex":void 0,r=/samsungbrowser/i.test(t)?"SamsungBrowser":void 0,n=/chrome|crios/i.test(t)?"Chrome":void 0,i=/chromium/i.test(t)?"Chromium":void 0,s=/firefox|fxios/i.test(t)?"Firefox":void 0,u=/webkit|safari|khtml/i.test(t)?"Safari":void 0,o=/opr\//i.test(t)?"Opera":void 0,a=/edg/i.test(t)?"Edge":void 0,p=/android/i.test(t)?"Android":void 0,c=/iphone/i.test(t)?"iPhone":void 0,d=/ipad/i.test(t)?"iPad":void 0,A=/ipod/i.test(t)?"iPod":void 0,P=/mac/i.test(t)?"Mac":void 0,R=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(t)?"RestMobile":void 0;return{browser:e||r||s||o||a||n||i||u||"Rest",device:p||c||d||A||R||P||"Desktop"}},Me=(t=!1)=>{let r=["iPhone","iPad","iPod"].includes(E().device);if(!t)return r;let{userAgent:n,maxTouchPoints:i}=window.navigator;return!!(r||/macintosh/i.test(n)&&i>0)},Ne=()=>{let{userAgent:t}=window.navigator,e=t.match(/Version\/(\d+(\.\d+)?)/i);if(!e)return null;let r=e[1],n=parseFloat(r);return isNaN(n)?null:n},gt=()=>{let{device:t}=E(),{userAgent:e,maxTouchPoints:r}=window.navigator,n=/linux/i.test(e),i=r>0;return t==="Desktop"&&n&&i},Ve=()=>E().device==="Android"||gt(),Qe=()=>["Mac","iPhone","iPad","iPod"].includes(E().device),De=()=>{var t,e;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test((t=navigator.appVersion)!=null?t:navigator.userAgent)||((e=navigator==null?void 0:navigator.userAgentData)==null?void 0:e.mobile)};var _e=(t,{start:e=0,factor:r=2,max:n=1/0,min:i=e,random:s=0}={})=>{let u=e;return u*=ge(r,t),u*=1+(Math.random()*s*2-s),u=Math.round(u),u=Math.min(u,n),u=Math.max(u,i),u};var B={};ye(B,{clear:()=>At,get:()=>Ot,has:()=>Et,isPersistent:()=>yt,remove:()=>St,set:()=>wt});var f,O,$=`vk-videoplayer-dummy-key-${Math.random()}`,S=()=>{if(O!==void 0)return O;try{localStorage.setItem($,"test"),localStorage.removeItem($),O=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem($),O=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)O=2;else throw e}else throw t}return O===2&&(f=new Map),O},yt=()=>S()===0,Ot=t=>{var r,n;let e=S();switch(e){case 0:return(r=localStorage.getItem(t))!=null?r:void 0;case 1:return(n=sessionStorage.getItem(t))!=null?n:void 0;case 2:return f==null?void 0:f.get(t);default:I(e)}},wt=(t,e)=>{let r=S();switch(r){case 0:try{localStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void(f==null?void 0:f.set(t,e));default:I(r)}},Et=t=>{var r;let e=S();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return(r=f==null?void 0:f.has(t))!=null?r:!1;default:return I(e),!1}},St=t=>{let e=S();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:return void(f==null?void 0:f.delete(t));default:I(e)}},At=()=>{let t=S();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return f==null?void 0:f.clear();default:I(t)}};var Ue=()=>{let t,e;try{t=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?t=!0:(t=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let r=e?new URL(e).hostname:void 0;return{isEmbed:t,host:r}};var z=(c=>(c.INVARIANT="Invariant quality",c.Q_144P="144p",c.Q_240P="240p",c.Q_360P="360p",c.Q_480P="480p",c.Q_720P="720p",c.Q_1080P="1080p",c.Q_1440P="1440p",c.Q_2160P="2160p",c.Q_4320P="4320p",c))(z||{});var T={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"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}},Fe=(t,e)=>T[t].height>T[e].height,Be=(t,e)=>T[t].height>=T[e].height,j=(t,e)=>T[t].height<T[e].height,ze=(t,e)=>T[t].height<=T[e].height,je=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:j(e,r)?1:-1)[0],We=Object.keys(T).sort((t,e)=>j(t,e)?-1:1),Ge=(t,e=.02)=>[...We].find(n=>T[n].height*(1+e)>=t),qe=({width:t,height:e})=>{let r=Math.min(t,e),n=Math.max(t,e);return We.find(i=>{let s=T[i];return s.width>=n&&s.height>=r})},He=t=>T[t].height,W=t=>t==="Invariant quality",Ke=t=>t.every(e=>!W(e));function $e(t){if(W(t))throw new Error("Expected exact quality")}var Ye=(t,e)=>{let r={};for(let n of Object.keys(e)){let i=e[n],s=t[n];Array.isArray(i)&&Array.isArray(s)?r[n]=s:typeof i=="object"&&typeof s=="object"?r[n]=Ye(s,i):r[n]=n in t?s:i}return r};var Rt=t=>{let e="";return t>=3600&&(e+=Math.floor(t/3600)+"h",t=t%3600),t>=60&&(e+=Math.floor(t/60)+"m",t=t%60),t>0&&(e+=Math.floor(t)+"s"),e};function G(t,e=0,r){let n,i,s,u,o,a,p=0,c=!1,d=!1,A=!0,P=!e&&e!==0&&typeof window.requestAnimationFrame=="function";r&&(c=!!r.leading,d="maxWait"in r,s=r!=null&&r.maxWait?Math.max(+(r==null?void 0:r.maxWait)||0,e):s,A="trailing"in r?!!r.trailing:A);function R(b){let v=n,g=i;return n=i=void 0,p=b,u=t.apply(g,v),u}function M(b,v){return P?(o&&window.cancelAnimationFrame(o),window.requestAnimationFrame(b)):setTimeout(b,v)}function lt(b){if(P){window.cancelAnimationFrame(b);return}clearTimeout(b)}function ut(b){return p=b,o=M(N,e),c?R(b):u}function ct(b){let v=b-a,g=b-p,ve=e-v;return d?Math.min(ve,s-g):ve}function me(b){let v=b-a,g=b-p;return a===void 0||v>=e||v<0||d&&g>=s}function N(){let b=Date.now();if(me(b))return Te(b);o=M(N,ct(b))}function Te(b){return o=void 0,A&&n?R(b):(n=i=void 0,u)}function pt(){o!==void 0&<(o),p=0,n=a=i=o=void 0}function bt(){return o===void 0?u:Te(Date.now())}function dt(){return o!==void 0}function V(...b){let v=Date.now(),g=me(v);if(n=b,i=this,a=v,g){if(o===void 0)return ut(a);if(d)return o=M(N,e),R(a)}return o===void 0&&(o=M(N,e)),u}return V.cancel=pt,V.flush=bt,V.pending=dt,V}var q=(t,e=0,r)=>G(t,e,D(w(w({},{leading:!0,trailing:!0}),r),{maxWait:e}));var C=(t,e)=>{if(t===null||typeof t!="object")return t;let r=Array.isArray(t)?[]:{};for(let n in t){if(typeof e=="function"){let i=e(t[n],n,t,r);if(i!==void 0){r[n]=i;continue}}typeof t[n]=="object"?r[n]=C(t[n],e):r[n]=t[n]}return r};var Xe=t=>C(t);var Ct=300,Je=(t,e=Ct)=>new l(r=>{let{width:n,height:i}=t.getBoundingClientRect();if(r.next({width:n,height:i}),!window.ResizeObserver)return;let s=new ResizeObserver(q(u=>{let o=u[0];if(!o)return;let a,p;o.contentBoxSize&&o.contentBoxSize[0]?(p=o.contentBoxSize[0].blockSize,a=o.contentBoxSize[0].inlineSize):o.contentRect&&(a=o.contentRect.width,p=o.contentRect.height),y(a)&&y(p)&&r.next({width:a,height:p})},e));return s.observe(t),()=>s.disconnect()});var Ze=t=>{t.removeAttribute("src"),t.load()};var k=class extends x{constructor(r){super();this.value=r}next(r){super.next(this.value=r)}error(r){super.error(this.value=r)}getValue(){return this.value}_subscribe(r){let n=super._subscribe(r);return r.next(this.value),n}};function Y(t){return new l(e=>{let r={},n=Object.keys(t).length,i=s=>u=>{s in r||n--,r[s]=u,n===0&&e.next(r)};return Object.entries(t).reduce((s,[u,o])=>s.add(o.subscribe(i(u))),new m)})}function X(...t){return new l(e=>t.reduce((r,n)=>r.add(n.subscribe(e)),new m))}var et=t=>new l(e=>{let r=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},t);return()=>window.clearTimeout(r)});var tt=t=>new l(e=>{let r=window.setInterval(()=>e.next(),t);return()=>{r&&(window.clearInterval(r),r=void 0)}});var rt=t=>new l(e=>{t.forEach(r=>e.next(r))});var nt=(t,e)=>new l(r=>{let n=i=>r.next(i);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)});function Z(t){return e=>new l(r=>e.subscribe(new J(r,t)))}var J=class{constructor(e,r){this.destination=e;this.size=r;this.lastValues=[]}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};var kt={leading:!1,trailing:!0};function te(t,e=kt){return r=>new l(n=>r.subscribe(new ee(n,t,e)))}var ee=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,y(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(r){if(this.destination.error)this.destination.error(r);else throw r}this.timeout=void 0},this.time)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};var Lt={leading:!0,trailing:!1};function ne(t,e=Lt){return r=>new l(n=>r.subscribe(new re(n,t,e)))}var re=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,F(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function ie(t){return e=>new l(r=>e.subscribe(new oe(r,t)))}var oe=class{constructor(e,r){this.destination=e;this.predicate=r}next(e){let r;try{r=this.predicate(e)}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function ae(t=(e,r)=>e===r){return e=>new l(r=>e.subscribe(new se(r,t)))}var ot={},se=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=ot}next(e){let r;try{r=this.lastValue===ot||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function L(t){return e=>new l(r=>e.subscribe(new le(r,t)))}var le=class{constructor(e,r){this.destination=e;this.mapper=r}next(e){let r;try{r=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(r)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function ue(t){return L(()=>t)}function ce(){return t=>new l(e=>{let r=!1,n=!1,i=t.subscribe(s=>{r||(r=!0,e.next(s)),n&&i.unsubscribe()},s=>{var u;r=!0,(u=e.error)==null||u.call(e,s),n&&i.unsubscribe()});return n=!0,r&&i.unsubscribe(),i})}function be(){return t=>new l(e=>t.subscribe(new pe(e)))}var pe=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let r=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([r,e])}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function fe(t){return e=>new l(r=>e.subscribe(new de(r,t)))}var de=class{constructor(e,r){this.destination=e;this.effect=r}next(e){try{this.effect(e)}catch(r){throw this.error(r),r}this.destination.next(e)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};var it=(o=>(o.NETWORK="network",o.VIDEO_PIPELINE="video_pipeline",o.EXTERNAL_API="external_api",o.PARSER="parser",o.DOM="dom",o.WTF="wtf",o.FATAL="fatal",o))(it||{});var st=(d=>(d.Armenian="58",d.Azerbaijani="57",d.Belarusian="114",d.English="3",d.Kazakh="97",d.Portuguese="73",d.Russian="0",d.Spanish="4",d.Ukrainian="1",d.Uzbek="65",d.Vietnamese="75",d))(st||{}),Pt="vk.com",Mt=(t,e,r)=>_(void 0,null,function*(){let n=new URL(`https://${Pt}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),t!==void 0&&n.searchParams.set("lang",t);let s=yield(yield fetch(n.toString())).json();return Nt(s,r)}),Nt=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,n])=>[r.substring(`${e}_`.length),Vt(n)])),Vt=t=>Array.isArray(t)?t[0]:t;var at=(r=>(r.RU="ru",r.EN="en",r))(at||{});
|
package/es2015.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-shared v1.0.38-dev.
|
|
3
|
-
*
|
|
2
|
+
* @vkontakte/videoplayer-shared v1.0.38-dev.df616f9c.0
|
|
3
|
+
* Fri, 16 Aug 2024 08:31:38 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-38/doc/
|
|
5
5
|
*/
|
|
6
|
-
var se=Object.defineProperty,Ae=Object.defineProperties;var Ce=Object.getOwnPropertyDescriptors;var ie=Object.getOwnPropertySymbols;var Pe=Object.prototype.hasOwnProperty,ke=Object.prototype.propertyIsEnumerable;var ae=Math.pow,oe=(r,e,t)=>e in r?se(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,O=(r,e)=>{for(var t in e||(e={}))Pe.call(e,t)&&oe(r,t,e[t]);if(ie)for(var t of ie(e))ke.call(e,t)&&oe(r,t,e[t]);return r},C=(r,e)=>Ae(r,Ce(e));var Le=(r,e)=>{for(var t in e)se(r,t,{get:e[t],enumerable:!0})};var P=(r,e,t)=>new Promise((n,o)=>{var s=c=>{try{i(t.next(c))}catch(u){o(u)}},a=c=>{try{i(t.throw(c))}catch(u){o(u)}},i=c=>c.done?n(c.value):Promise.resolve(c.value).then(s,a);i((t=t.apply(r,e)).next())});var Ve="1.0.38-dev.c2293902.0";var m=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(t=>typeof t=="function"?t():t.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var h=r=>{throw new Error(`${r} is value of unexpected type`)},Me=r=>{};var g=()=>{};var l=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,t){var a;let n;t?typeof t=="function"?n={next:t,error:g}:n={next:i=>t.next(i),error:i=>{var c;return(c=t.error)==null?void 0:c.call(t,i)}}:n={next:g,error:g};let o=typeof e=="function"?{next:i=>{try{e(i)}catch(c){n.next(c)}},error:i=>n.next(i)}:{next:i=>e.next(i),error:i=>e.error?e.error(i):n.next(i)},s;try{s=this._subscribe(o)}catch(i){(a=o.error)==null||a.call(o,i)}return new m().add(()=>{switch(o.next=g,o.error=g,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return h(s)}})}pipe(...e){return e.reduce((t,n)=>n(t),this)}_subscribe(e){}};var I=class extends l{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(t){this.subscribers.forEach(n=>n.next(t))}error(t){this.subscribers.forEach(n=>{var o;return(o=n.error)==null?void 0:o.call(n,t)})}_subscribe(t){let n=this.keyCounter++;return this.subscribers.set(n,t),new m().add(()=>this.subscribers.delete(n))}};var _=class{constructor(){this.log$=new I;this.logs=[];this.log=e=>{let t=C(O({},e),{timestamp:Date.now()});this.logs.push(t),this.log$.next(t)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...t)=>{let n;try{n=e(...t)}catch(o){n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(t=>O({component:e},t))}};function Ne(r,e='Assertion "value is not nullable" failed'){if(r==null)throw new Error(e)}function _e(r,e='Assertion "value is nullable" failed'){if(r!=null)throw new Error(e)}function w(r){return typeof r!="undefined"&&r!==null}function Q(r){return r==null}function Qe(r,e){if(!(r!=null&&r.length))throw new Error(e)}function De(r,e){if(r!=null&&r.length)throw new Error(e)}var Ue=(r,e,t)=>new Promise((n,o)=>{e.addEventListener("abort",()=>{i(),u.remove()});let s=()=>{i(),o()},a=()=>{i(),n()},i=()=>{c&&clearTimeout(c),u.removeEventListener("load",a),u.removeEventListener("error",s)},c;t&&(c=window.setTimeout(s,t));let u=document.createElement("script");u.addEventListener("load",a),u.addEventListener("error",s),u.src=r,document.head.appendChild(u)});var le,Be=typeof((le=window.performance)==null?void 0:le.now)=="function"?()=>window.performance.now():()=>Date.now();var Fe=(r,e)=>(...t)=>P(void 0,null,function*(){var a;let n=e(...t),o=r.aborted,s;for(;!o&&!r.aborted;)try{let i=yield n.next(s);o=(a=i.done)!=null?a:!1,s=i.value}catch(i){yield n.throw(i)}return s});var D=class{constructor(){this.detect()}get browser(){return this._currentBrowser}get device(){return this._currentDevice}get isTouch(){return this._maxTouchPoints>0}get isIOS(){return["iPhone","iPad","iPod"].includes(this.device)}get isMac(){return this.device==="Mac"}get isApple(){return this.isIOS||this.isMac}get isIphoneOrOldIpad(){if(!this.isApple||!this.isTouch)return!1;let e=this.device==="iPad"||(window==null?void 0:window.screen.width)>700,t=this._iosVersion;return!e||e&&!!t&&t<16}get isAndroid(){return this.device==="Android"}get isMobile(){var e,t;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test((e=navigator.appVersion)!=null?e:navigator.userAgent)||((t=navigator==null?void 0:navigator.userAgentData)==null?void 0:t.mobile)}get iOSVersion(){return this._iosVersion}get macVersion(){return this._macVersion}get isYandex(){return this.browser==="Yandex"}get isSafari(){return this.browser==="Safari"}get isSamsungBrowser(){return this.browser==="SamsungBrowser"}get isHDR(){return this._isHdr}detect(){var n;let{userAgent:e,maxTouchPoints:t}=navigator;try{this._maxTouchPoints=t,this._isHdr=!!((n=matchMedia("(dynamic-range: high)"))!=null&&n.matches)}catch(o){console.error(o)}this.detectBrowser(e),this.detectDevice(e),this.isIOS&&this.detectIOSVersion(),this.isMac&&this.detectMacVersion()}detectBrowser(e){try{let t=/yabrowser/i.test(e)?"Yandex":void 0,n=/samsungbrowser/i.test(e)?"SamsungBrowser":void 0,o=/chrome|crios/i.test(e)?"Chrome":void 0,s=/chromium/i.test(e)?"Chromium":void 0,a=/firefox|fxios/i.test(e)?"Firefox":void 0,i=/webkit|safari|khtml/i.test(e)?"Safari":void 0,c=/opr\//i.test(e)?"Opera":void 0,u=/edg/i.test(e)?"Edge":void 0;this._currentBrowser=t||n||a||c||u||o||s||i||"Rest"}catch(t){console.error(t)}}detectDevice(e){try{let t=/android/i.test(e)?"Android":void 0,n=/iphone/i.test(e)?"iPhone":void 0,o=/ipad/i.test(e)?"iPad":void 0,s=/ipod/i.test(e)?"iPod":void 0,a=/mac/i.test(e)?"Mac":void 0,i=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(e)?"RestMobile":void 0;this._currentDevice=t||n||o||s||i||a||"Desktop"}catch(t){console.error(t)}}detectIOSVersion(){try{let{userAgent:e}=window.navigator,t=e.match(/Version\/(\d+(\.\d+)?)/i);if(!t)return;let n=t[1],o=parseFloat(n);if(isNaN(o))return;this._iosVersion=o}catch(e){console.error(e)}}detectMacVersion(){try{let{userAgent:e}=window.navigator,t=e.match(/Version\/(\d+)/);if(!t)return;let n=t[1],o=parseInt(n,10);if(isNaN(o))return;this._macVersion=o}catch(e){console.error(e)}}},ze=new D;var je=(r,{start:e=0,factor:t=2,max:n=1/0,min:o=e,random:s=0}={})=>{let a=e;return a*=ae(t,r),a*=1+(Math.random()*s*2-s),a=Math.round(a),a=Math.min(a,n),a=Math.max(a,o),a};var B={};Le(B,{clear:()=>Ye,get:()=>Ge,has:()=>qe,isPersistent:()=>We,remove:()=>Ke,set:()=>He});var d,y,U=`vk-videoplayer-dummy-key-${Math.random()}`,E=()=>{if(y!==void 0)return y;try{localStorage.setItem(U,"test"),localStorage.removeItem(U),y=0}catch(r){if(r instanceof DOMException||r instanceof TypeError)try{sessionStorage.getItem(U),y=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)y=2;else throw e}else throw r}return y===2&&(d=new Map),y},We=()=>E()===0,Ge=r=>{var t,n;let e=E();switch(e){case 0:return(t=localStorage.getItem(r))!=null?t:void 0;case 1:return(n=sessionStorage.getItem(r))!=null?n:void 0;case 2:return d==null?void 0:d.get(r);default:h(e)}},He=(r,e)=>{let t=E();switch(t){case 0:try{localStorage.setItem(r,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(r,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void(d==null?void 0:d.set(r,e));default:h(t)}},qe=r=>{var t;let e=E();switch(e){case 0:return r in localStorage;case 1:return r in sessionStorage;case 2:return(t=d==null?void 0:d.has(r))!=null?t:!1;default:return h(e),!1}},Ke=r=>{let e=E();switch(e){case 0:return localStorage.removeItem(r);case 1:return sessionStorage.removeItem(r);case 2:return void(d==null?void 0:d.delete(r));default:h(e)}},Ye=()=>{let r=E();switch(r){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return d==null?void 0:d.clear();default:h(r)}};var $e=()=>{let r,e;try{r=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?r=!0:(r=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let t=e?new URL(e).hostname:void 0;return{isEmbed:r,host:t}};var F=(f=>(f.INVARIANT="Invariant quality",f.Q_144P="144p",f.Q_240P="240p",f.Q_360P="360p",f.Q_480P="480p",f.Q_720P="720p",f.Q_1080P="1080p",f.Q_1440P="1440p",f.Q_2160P="2160p",f.Q_4320P="4320p",f))(F||{});var T={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"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}},Xe=(r,e)=>T[r].height>T[e].height,Je=(r,e)=>T[r].height>=T[e].height,z=(r,e)=>T[r].height<T[e].height,Ze=(r,e)=>T[r].height<=T[e].height,et=r=>r.sort((e,t)=>e===t?0:e==="Invariant quality"?1:t==="Invariant quality"?-1:z(e,t)?1:-1)[0],ce=Object.keys(T).sort((r,e)=>z(r,e)?-1:1),tt=(r,e=.02)=>[...ce].find(n=>T[n].height*(1+e)>=r),rt=({width:r,height:e})=>{let t=Math.min(r,e),n=Math.max(r,e);return ce.find(o=>{let s=T[o];return s.width>=n&&s.height>=t})},nt=r=>T[r].height,j=r=>r==="Invariant quality",it=r=>r.every(e=>!j(e));function ot(r){if(j(r))throw new Error("Expected exact quality")}var st=(r,e)=>{let t={};for(let n of Object.keys(e)){let o=e[n],s=r[n];Array.isArray(o)&&Array.isArray(s)?t[n]=s:typeof o=="object"&&typeof s=="object"?t[n]=st(s,o):t[n]=n in r?s:o}return t};var tr=r=>{let e="";return r>=3600&&(e+=Math.floor(r/3600)+"h",r=r%3600),r>=60&&(e+=Math.floor(r/60)+"m",r=r%60),r>0&&(e+=Math.floor(r)+"s"),e};function W(r,e=0,t){let n,o,s,a,i,c,u=0,f=!1,b=!1,M=!0,ee=!e&&e!==0&&typeof window.requestAnimationFrame=="function";t&&(f=!!t.leading,b="maxWait"in t,s=t!=null&&t.maxWait?Math.max(+(t==null?void 0:t.maxWait)||0,e):s,M="trailing"in t?!!t.trailing:M);function N(p){let v=n,x=o;return n=o=void 0,u=p,a=r.apply(x,v),a}function S(p,v){return ee?(i&&window.cancelAnimationFrame(i),window.requestAnimationFrame(p)):setTimeout(p,v)}function ye(p){if(ee){window.cancelAnimationFrame(p);return}clearTimeout(p)}function Oe(p){return u=p,i=S(R,e),f?N(p):a}function we(p){let v=p-c,x=p-u,ne=e-v;return b?Math.min(ne,s-x):ne}function te(p){let v=p-c,x=p-u;return c===void 0||v>=e||v<0||b&&x>=s}function R(){let p=Date.now();if(te(p))return re(p);i=S(R,we(p))}function re(p){return i=void 0,M&&n?N(p):(n=o=void 0,a)}function Ee(){i!==void 0&&ye(i),u=0,n=c=o=i=void 0}function Se(){return i===void 0?a:re(Date.now())}function Re(){return i!==void 0}function A(...p){let v=Date.now(),x=te(v);if(n=p,o=this,c=v,x){if(i===void 0)return Oe(c);if(b)return i=S(R,e),N(c)}return i===void 0&&(i=S(R,e)),a}return A.cancel=Ee,A.flush=Se,A.pending=Re,A}var G=(r,e=0,t)=>W(r,e,C(O(O({},{leading:!0,trailing:!0}),t),{maxWait:e}));var k=(r,e)=>{if(r===null||typeof r!="object")return r;let t=Array.isArray(r)?[]:{};for(let n in r){if(typeof e=="function"){let o=e(r[n],n,r,t);if(o!==void 0){t[n]=o;continue}}typeof r[n]=="object"?t[n]=k(r[n],e):t[n]=r[n]}return t};var at=r=>k(r);var lt=300,ct=(r,e=lt)=>new l(t=>{let{width:n,height:o}=r.getBoundingClientRect();if(t.next({width:n,height:o}),!window.ResizeObserver)return;let s=new ResizeObserver(G(a=>{let i=a[0];if(!i)return;let c,u;i.contentBoxSize&&i.contentBoxSize[0]?(u=i.contentBoxSize[0].blockSize,c=i.contentBoxSize[0].inlineSize):i.contentRect&&(c=i.contentRect.width,u=i.contentRect.height),w(c)&&w(u)&&t.next({width:c,height:u})},e));return s.observe(r),()=>s.disconnect()});var ut=r=>{r.removeAttribute("src"),r.load()};var L=class extends I{constructor(t){super();this.value=t}next(t){super.next(this.value=t)}error(t){super.error(this.value=t)}getValue(){return this.value}_subscribe(t){let n=super._subscribe(t);return t.next(this.value),n}};function ue(r){return new l(e=>{let t={},n=Object.keys(r).length,o=s=>a=>{s in t||n--,t[s]=a,n===0&&e.next(t)};return Object.entries(r).reduce((s,[a,i])=>s.add(i.subscribe(o(a))),new m)})}function pe(...r){return new l(e=>r.reduce((t,n)=>t.add(n.subscribe(e)),new m))}var pt=r=>new l(e=>{let t=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},r);return()=>window.clearTimeout(t)});var bt=r=>new l(e=>{let t=window.setInterval(()=>e.next(),r);return()=>{t&&(window.clearInterval(t),t=void 0)}});var dt=r=>new l(e=>{r.forEach(t=>e.next(t))});var ft=(r,e)=>new l(t=>{let n=o=>t.next(o);return r.addEventListener(e,n),()=>r.removeEventListener(e,n)});function be(r){return e=>new l(t=>e.subscribe(new H(t,r)))}var H=class{constructor(e,t){this.destination=e;this.size=t;this.lastValues=[]}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};var mt={leading:!1,trailing:!0};function de(r,e=mt){return t=>new l(n=>t.subscribe(new q(n,r,e)))}var q=class{constructor(e,t,n){this.destination=e;this.time=t;this.config=n}next(e){this.lastValue=e,w(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(t){if(this.destination.error)this.destination.error(t);else throw t}this.timeout=void 0},this.time)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};var Tt={leading:!0,trailing:!1};function fe(r,e=Tt){return t=>new l(n=>t.subscribe(new K(n,r,e)))}var K=class{constructor(e,t,n){this.destination=e;this.time=t;this.config=n}next(e){this.lastValue=e,Q(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function me(r){return e=>new l(t=>e.subscribe(new Y(t,r)))}var Y=class{constructor(e,t){this.destination=e;this.predicate=t}next(e){let t;try{t=this.predicate(e)}catch(n){throw this.error(n),n}t&&this.destination.next(e)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function ve(r=(e,t)=>e===t){return e=>new l(t=>e.subscribe(new $(t,r)))}var Te={},$=class{constructor(e,t){this.destination=e;this.predicate=t;this.lastValue=Te}next(e){let t;try{t=this.lastValue===Te||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}t&&this.destination.next(e)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function V(r){return e=>new l(t=>e.subscribe(new X(t,r)))}var X=class{constructor(e,t){this.destination=e;this.mapper=t}next(e){let t;try{t=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(t)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function he(r){return V(()=>r)}function Ie(){return r=>new l(e=>{let t=!1,n=!1,o=r.subscribe(s=>{t||(t=!0,e.next(s)),n&&o.unsubscribe()},s=>{var a;t=!0,(a=e.error)==null||a.call(e,s),n&&o.unsubscribe()});return n=!0,t&&o.unsubscribe(),o})}function xe(){return r=>new l(e=>r.subscribe(new J(e)))}var J=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let t=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([t,e])}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function ge(r){return e=>new l(t=>e.subscribe(new Z(t,r)))}var Z=class{constructor(e,t){this.destination=e;this.effect=t}next(e){try{this.effect(e)}catch(t){throw this.error(t),t}this.destination.next(e)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};var vt=(i=>(i.NETWORK="network",i.VIDEO_PIPELINE="video_pipeline",i.EXTERNAL_API="external_api",i.PARSER="parser",i.DOM="dom",i.WTF="wtf",i.FATAL="fatal",i))(vt||{});var ht=(b=>(b.Armenian="58",b.Azerbaijani="57",b.Belarusian="114",b.English="3",b.Kazakh="97",b.Portuguese="73",b.Russian="0",b.Spanish="4",b.Ukrainian="1",b.Uzbek="65",b.Vietnamese="75",b))(ht||{}),It="vk.com",qn=(r,e,t)=>P(void 0,null,function*(){let n=new URL(`https://${It}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),r!==void 0&&n.searchParams.set("lang",r);let s=yield(yield fetch(n.toString())).json();return xt(s,t)}),xt=(r,e)=>Object.fromEntries(Object.entries(r.keys).map(([t,n])=>[t.substring(`${e}_`.length),gt(n)])),gt=r=>Array.isArray(r)?r[0]:r;var yt=(t=>(t.RU="ru",t.EN="en",t))(yt||{});export{ze as CC,vt as ErrorCategory,yt as InterfaceLanguage,_ as Logger,l as Observable,I as Subject,m as Subscription,Ve as VERSION,ht as VKNumericLanguage,L as ValueSubject,F as VideoQuality,Fe as abortable,Ue as addScript,it as areQualitiesExact,De as assertEmptyArray,h as assertNever,Ne as assertNonNullable,Qe as assertNotEmptyArray,_e as assertNullable,ot as assertQualityIsExact,be as buffer,Me as checkNever,ut as clearVideoElement,at as cloneDeep,k as cloneDeepWith,ue as combine,de as debounce,W as debounceFn,$e as detectEmbed,st as fillWithDefault,me as filter,ve as filterChanged,ft as fromEvent,je as getExponentialDelay,et as getHighestQuality,bt as interval,Xe as isHigher,Je as isHigherOrEqual,j as isInvariantQuality,z as isLower,Ze as isLowerOrEqual,w as isNonNullable,Q as isNullable,qn as loadVKLangPack,V as map,he as mapTo,pe as merge,g as noop,Be as now,dt as observableFrom,ct as observeElementSize,Ie as once,xe as pairwise,B as safeStorage,ge as tap,fe as throttle,G as throttleFn,tr as timeCodeToString,pt as timeout,tt as videoHeightToQuality,nt as videoQualityToHeight,rt as videoSizeToQuality};
|
|
6
|
+
var se=Object.defineProperty,ke=Object.defineProperties;var Le=Object.getOwnPropertyDescriptors;var oe=Object.getOwnPropertySymbols;var Pe=Object.prototype.hasOwnProperty,Me=Object.prototype.propertyIsEnumerable;var ae=Math.pow,ie=(t,e,r)=>e in t?se(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,O=(t,e)=>{for(var r in e||(e={}))Pe.call(e,r)&&ie(t,r,e[r]);if(oe)for(var r of oe(e))Me.call(e,r)&&ie(t,r,e[r]);return t},M=(t,e)=>ke(t,Le(e));var Ne=(t,e)=>{for(var r in e)se(t,r,{get:e[r],enumerable:!0})};var N=(t,e,r)=>new Promise((n,i)=>{var s=a=>{try{o(r.next(a))}catch(p){i(p)}},l=a=>{try{o(r.throw(a))}catch(p){i(p)}},o=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,l);o((r=r.apply(t,e)).next())});var Ve="1.0.38-dev.df616f9c.0";var m=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(r=>typeof r=="function"?r():r.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var I=t=>{throw new Error(`${t} is value of unexpected type`)},Qe=t=>{};var g=()=>{};var u=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,r){var l;let n;r?typeof r=="function"?n={next:r,error:g}:n={next:o=>r.next(o),error:o=>{var a;return(a=r.error)==null?void 0:a.call(r,o)}}:n={next:g,error:g};let i=typeof e=="function"?{next:o=>{try{e(o)}catch(a){n.next(a)}},error:o=>n.next(o)}:{next:o=>e.next(o),error:o=>e.error?e.error(o):n.next(o)},s;try{s=this._subscribe(i)}catch(o){(l=i.error)==null||l.call(i,o)}return new m().add(()=>{switch(i.next=g,i.error=g,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return I(s)}})}pipe(...e){return e.reduce((r,n)=>n(r),this)}_subscribe(e){}};var x=class extends u{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(r){this.subscribers.forEach(n=>n.next(r))}error(r){this.subscribers.forEach(n=>{var i;return(i=n.error)==null?void 0:i.call(n,r)})}_subscribe(r){let n=this.keyCounter++;return this.subscribers.set(n,r),new m().add(()=>this.subscribers.delete(n))}};var _=class{constructor(){this.log$=new x;this.logs=[];this.log=e=>{let r=M(O({},e),{timestamp:Date.now()});this.logs.push(r),this.log$.next(r)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...r)=>{let n;try{n=e(...r)}catch(i){n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(r=>O({component:e},r))}};function De(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function _e(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function w(t){return typeof t!="undefined"&&t!==null}function U(t){return t==null}function Ue(t,e){if(!(t!=null&&t.length))throw new Error(e)}function Fe(t,e){if(t!=null&&t.length)throw new Error(e)}var Be=(t,e,r)=>new Promise((n,i)=>{e.addEventListener("abort",()=>{o(),p.remove()});let s=()=>{o(),i()},l=()=>{o(),n()},o=()=>{a&&clearTimeout(a),p.removeEventListener("load",l),p.removeEventListener("error",s)},a;r&&(a=window.setTimeout(s,r));let p=document.createElement("script");p.addEventListener("load",l),p.addEventListener("error",s),p.src=t,document.head.appendChild(p)});var le,ze=typeof((le=window.performance)==null?void 0:le.now)=="function"?()=>window.performance.now():()=>Date.now();var je=(t,e)=>(...r)=>N(void 0,null,function*(){var l;let n=e(...r),i=t.aborted,s;for(;!i&&!t.aborted;)try{let o=yield n.next(s);i=(l=o.done)!=null?l:!1,s=o.value}catch(o){yield n.throw(o)}return s});var ue=(c=>(c.Unknown="Unknown",c.Yandex="Yandex",c.Chrome="Chrome",c.Chromium="Chromium",c.Firefox="Firefox",c.Safari="Safari",c.Opera="Opera",c.Edge="Edge",c.SamsungBrowser="SamsungBrowser",c.Rest="Rest",c))(ue||{}),ce=(a=>(a.Unknown="Unknown",a.Android="Android",a.iPhone="iPhone",a.iPad="iPad",a.iPod="iPod",a.RestMobile="RestMobile",a.Mac="Mac",a.Desktop="Desktop",a))(ce||{}),R=()=>{let{userAgent:t}=window.navigator,e=/yabrowser/i.test(t)?"Yandex":void 0,r=/samsungbrowser/i.test(t)?"SamsungBrowser":void 0,n=/chrome|crios/i.test(t)?"Chrome":void 0,i=/chromium/i.test(t)?"Chromium":void 0,s=/firefox|fxios/i.test(t)?"Firefox":void 0,l=/webkit|safari|khtml/i.test(t)?"Safari":void 0,o=/opr\//i.test(t)?"Opera":void 0,a=/edg/i.test(t)?"Edge":void 0,p=/android/i.test(t)?"Android":void 0,c=/iphone/i.test(t)?"iPhone":void 0,d=/ipad/i.test(t)?"iPad":void 0,S=/ipod/i.test(t)?"iPod":void 0,C=/mac/i.test(t)?"Mac":void 0,A=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(t)?"RestMobile":void 0;return{browser:e||r||s||o||a||n||i||l||"Rest",device:p||c||d||S||A||C||"Desktop"}},We=(t=!1)=>{let r=["iPhone","iPad","iPod"].includes(R().device);if(!t)return r;let{userAgent:n,maxTouchPoints:i}=window.navigator;return!!(r||/macintosh/i.test(n)&&i>0)},Ge=()=>{let{userAgent:t}=window.navigator,e=t.match(/Version\/(\d+(\.\d+)?)/i);if(!e)return null;let r=e[1],n=parseFloat(r);return isNaN(n)?null:n},qe=()=>{let{device:t}=R(),{userAgent:e,maxTouchPoints:r}=window.navigator,n=/linux/i.test(e),i=r>0;return t==="Desktop"&&n&&i},He=()=>R().device==="Android"||qe(),Ke=()=>["Mac","iPhone","iPad","iPod"].includes(R().device),$e=()=>{var t,e;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test((t=navigator.appVersion)!=null?t:navigator.userAgent)||((e=navigator==null?void 0:navigator.userAgentData)==null?void 0:e.mobile)};var Ye=(t,{start:e=0,factor:r=2,max:n=1/0,min:i=e,random:s=0}={})=>{let l=e;return l*=ae(r,t),l*=1+(Math.random()*s*2-s),l=Math.round(l),l=Math.min(l,n),l=Math.max(l,i),l};var B={};Ne(B,{clear:()=>rt,get:()=>Je,has:()=>et,isPersistent:()=>Xe,remove:()=>tt,set:()=>Ze});var f,y,F=`vk-videoplayer-dummy-key-${Math.random()}`,E=()=>{if(y!==void 0)return y;try{localStorage.setItem(F,"test"),localStorage.removeItem(F),y=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem(F),y=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)y=2;else throw e}else throw t}return y===2&&(f=new Map),y},Xe=()=>E()===0,Je=t=>{var r,n;let e=E();switch(e){case 0:return(r=localStorage.getItem(t))!=null?r:void 0;case 1:return(n=sessionStorage.getItem(t))!=null?n:void 0;case 2:return f==null?void 0:f.get(t);default:I(e)}},Ze=(t,e)=>{let r=E();switch(r){case 0:try{localStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void(f==null?void 0:f.set(t,e));default:I(r)}},et=t=>{var r;let e=E();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return(r=f==null?void 0:f.has(t))!=null?r:!1;default:return I(e),!1}},tt=t=>{let e=E();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:return void(f==null?void 0:f.delete(t));default:I(e)}},rt=()=>{let t=E();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return f==null?void 0:f.clear();default:I(t)}};var nt=()=>{let t,e;try{t=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?t=!0:(t=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let r=e?new URL(e).hostname:void 0;return{isEmbed:t,host:r}};var z=(c=>(c.INVARIANT="Invariant quality",c.Q_144P="144p",c.Q_240P="240p",c.Q_360P="360p",c.Q_480P="480p",c.Q_720P="720p",c.Q_1080P="1080p",c.Q_1440P="1440p",c.Q_2160P="2160p",c.Q_4320P="4320p",c))(z||{});var T={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"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}},ot=(t,e)=>T[t].height>T[e].height,it=(t,e)=>T[t].height>=T[e].height,j=(t,e)=>T[t].height<T[e].height,st=(t,e)=>T[t].height<=T[e].height,at=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:j(e,r)?1:-1)[0],pe=Object.keys(T).sort((t,e)=>j(t,e)?-1:1),lt=(t,e=.02)=>[...pe].find(n=>T[n].height*(1+e)>=t),ut=({width:t,height:e})=>{let r=Math.min(t,e),n=Math.max(t,e);return pe.find(i=>{let s=T[i];return s.width>=n&&s.height>=r})},ct=t=>T[t].height,W=t=>t==="Invariant quality",pt=t=>t.every(e=>!W(e));function bt(t){if(W(t))throw new Error("Expected exact quality")}var dt=(t,e)=>{let r={};for(let n of Object.keys(e)){let i=e[n],s=t[n];Array.isArray(i)&&Array.isArray(s)?r[n]=s:typeof i=="object"&&typeof s=="object"?r[n]=dt(s,i):r[n]=n in t?s:i}return r};var lr=t=>{let e="";return t>=3600&&(e+=Math.floor(t/3600)+"h",t=t%3600),t>=60&&(e+=Math.floor(t/60)+"m",t=t%60),t>0&&(e+=Math.floor(t)+"s"),e};function G(t,e=0,r){let n,i,s,l,o,a,p=0,c=!1,d=!1,S=!0,C=!e&&e!==0&&typeof window.requestAnimationFrame=="function";r&&(c=!!r.leading,d="maxWait"in r,s=r!=null&&r.maxWait?Math.max(+(r==null?void 0:r.maxWait)||0,e):s,S="trailing"in r?!!r.trailing:S);function A(b){let v=n,h=i;return n=i=void 0,p=b,l=t.apply(h,v),l}function k(b,v){return C?(o&&window.cancelAnimationFrame(o),window.requestAnimationFrame(b)):setTimeout(b,v)}function we(b){if(C){window.cancelAnimationFrame(b);return}clearTimeout(b)}function Ee(b){return p=b,o=k(L,e),c?A(b):l}function Se(b){let v=b-a,h=b-p,ne=e-v;return d?Math.min(ne,s-h):ne}function te(b){let v=b-a,h=b-p;return a===void 0||v>=e||v<0||d&&h>=s}function L(){let b=Date.now();if(te(b))return re(b);o=k(L,Se(b))}function re(b){return o=void 0,S&&n?A(b):(n=i=void 0,l)}function Ae(){o!==void 0&&we(o),p=0,n=a=i=o=void 0}function Re(){return o===void 0?l:re(Date.now())}function Ce(){return o!==void 0}function P(...b){let v=Date.now(),h=te(v);if(n=b,i=this,a=v,h){if(o===void 0)return Ee(a);if(d)return o=k(L,e),A(a)}return o===void 0&&(o=k(L,e)),l}return P.cancel=Ae,P.flush=Re,P.pending=Ce,P}var q=(t,e=0,r)=>G(t,e,M(O(O({},{leading:!0,trailing:!0}),r),{maxWait:e}));var V=(t,e)=>{if(t===null||typeof t!="object")return t;let r=Array.isArray(t)?[]:{};for(let n in t){if(typeof e=="function"){let i=e(t[n],n,t,r);if(i!==void 0){r[n]=i;continue}}typeof t[n]=="object"?r[n]=V(t[n],e):r[n]=t[n]}return r};var ft=t=>V(t);var mt=300,Tt=(t,e=mt)=>new u(r=>{let{width:n,height:i}=t.getBoundingClientRect();if(r.next({width:n,height:i}),!window.ResizeObserver)return;let s=new ResizeObserver(q(l=>{let o=l[0];if(!o)return;let a,p;o.contentBoxSize&&o.contentBoxSize[0]?(p=o.contentBoxSize[0].blockSize,a=o.contentBoxSize[0].inlineSize):o.contentRect&&(a=o.contentRect.width,p=o.contentRect.height),w(a)&&w(p)&&r.next({width:a,height:p})},e));return s.observe(t),()=>s.disconnect()});var vt=t=>{t.removeAttribute("src"),t.load()};var Q=class extends x{constructor(r){super();this.value=r}next(r){super.next(this.value=r)}error(r){super.error(this.value=r)}getValue(){return this.value}_subscribe(r){let n=super._subscribe(r);return r.next(this.value),n}};function be(t){return new u(e=>{let r={},n=Object.keys(t).length,i=s=>l=>{s in r||n--,r[s]=l,n===0&&e.next(r)};return Object.entries(t).reduce((s,[l,o])=>s.add(o.subscribe(i(l))),new m)})}function de(...t){return new u(e=>t.reduce((r,n)=>r.add(n.subscribe(e)),new m))}var It=t=>new u(e=>{let r=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},t);return()=>window.clearTimeout(r)});var xt=t=>new u(e=>{let r=window.setInterval(()=>e.next(),t);return()=>{r&&(window.clearInterval(r),r=void 0)}});var ht=t=>new u(e=>{t.forEach(r=>e.next(r))});var gt=(t,e)=>new u(r=>{let n=i=>r.next(i);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)});function fe(t){return e=>new u(r=>e.subscribe(new H(r,t)))}var H=class{constructor(e,r){this.destination=e;this.size=r;this.lastValues=[]}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};var yt={leading:!1,trailing:!0};function me(t,e=yt){return r=>new u(n=>r.subscribe(new K(n,t,e)))}var K=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,w(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(r){if(this.destination.error)this.destination.error(r);else throw r}this.timeout=void 0},this.time)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};var Ot={leading:!0,trailing:!1};function Te(t,e=Ot){return r=>new u(n=>r.subscribe(new $(n,t,e)))}var $=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,U(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function ve(t){return e=>new u(r=>e.subscribe(new Y(r,t)))}var Y=class{constructor(e,r){this.destination=e;this.predicate=r}next(e){let r;try{r=this.predicate(e)}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function xe(t=(e,r)=>e===r){return e=>new u(r=>e.subscribe(new X(r,t)))}var Ie={},X=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=Ie}next(e){let r;try{r=this.lastValue===Ie||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function D(t){return e=>new u(r=>e.subscribe(new J(r,t)))}var J=class{constructor(e,r){this.destination=e;this.mapper=r}next(e){let r;try{r=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(r)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function he(t){return D(()=>t)}function ge(){return t=>new u(e=>{let r=!1,n=!1,i=t.subscribe(s=>{r||(r=!0,e.next(s)),n&&i.unsubscribe()},s=>{var l;r=!0,(l=e.error)==null||l.call(e,s),n&&i.unsubscribe()});return n=!0,r&&i.unsubscribe(),i})}function ye(){return t=>new u(e=>t.subscribe(new Z(e)))}var Z=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let r=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([r,e])}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function Oe(t){return e=>new u(r=>e.subscribe(new ee(r,t)))}var ee=class{constructor(e,r){this.destination=e;this.effect=r}next(e){try{this.effect(e)}catch(r){throw this.error(r),r}this.destination.next(e)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};var wt=(o=>(o.NETWORK="network",o.VIDEO_PIPELINE="video_pipeline",o.EXTERNAL_API="external_api",o.PARSER="parser",o.DOM="dom",o.WTF="wtf",o.FATAL="fatal",o))(wt||{});var Et=(d=>(d.Armenian="58",d.Azerbaijani="57",d.Belarusian="114",d.English="3",d.Kazakh="97",d.Portuguese="73",d.Russian="0",d.Spanish="4",d.Ukrainian="1",d.Uzbek="65",d.Vietnamese="75",d))(Et||{}),St="vk.com",eo=(t,e,r)=>N(void 0,null,function*(){let n=new URL(`https://${St}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),t!==void 0&&n.searchParams.set("lang",t);let s=yield(yield fetch(n.toString())).json();return At(s,r)}),At=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,n])=>[r.substring(`${e}_`.length),Rt(n)])),Rt=t=>Array.isArray(t)?t[0]:t;var Ct=(r=>(r.RU="ru",r.EN="en",r))(Ct||{});export{ue as CurrentClientBrowser,ce as CurrentClientDevice,wt as ErrorCategory,Ct as InterfaceLanguage,_ as Logger,u as Observable,x as Subject,m as Subscription,Ve as VERSION,Et as VKNumericLanguage,Q as ValueSubject,z as VideoQuality,je as abortable,Be as addScript,pt as areQualitiesExact,Fe as assertEmptyArray,I as assertNever,De as assertNonNullable,Ue as assertNotEmptyArray,_e as assertNullable,bt as assertQualityIsExact,fe as buffer,Qe as checkNever,vt as clearVideoElement,ft as cloneDeep,V as cloneDeepWith,be as combine,me as debounce,G as debounceFn,nt as detectEmbed,dt as fillWithDefault,ve as filter,xe as filterChanged,gt as fromEvent,R as getCurrentBrowser,Ye as getExponentialDelay,at as getHighestQuality,Ge as getIOSVersion,xt as interval,He as isAndroid,ot as isHigher,it as isHigherOrEqual,We as isIOS,W as isInvariantQuality,j as isLower,st as isLowerOrEqual,Ke as isMacLike,$e as isMobile,w as isNonNullable,U as isNullable,eo as loadVKLangPack,D as map,he as mapTo,de as merge,g as noop,ze as now,ht as observableFrom,Tt as observeElementSize,ge as once,ye as pairwise,B as safeStorage,Oe as tap,Te as throttle,q as throttleFn,lr as timeCodeToString,It as timeout,lt as videoHeightToQuality,ct as videoQualityToHeight,ut as videoSizeToQuality};
|
package/es2018.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-shared v1.0.38-dev.
|
|
3
|
-
*
|
|
2
|
+
* @vkontakte/videoplayer-shared v1.0.38-dev.df616f9c.0
|
|
3
|
+
* Fri, 16 Aug 2024 08:31:38 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-38/doc/
|
|
5
5
|
*/
|
|
6
|
-
"use strict";var F=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var nt=Object.prototype.hasOwnProperty;var de=(r,e)=>{for(var t in e)F(r,t,{get:e[t],enumerable:!0})},it=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of rt(e))!nt.call(r,i)&&i!==t&&F(r,i,{get:()=>e[i],enumerable:!(n=tt(e,i))||n.enumerable});return r};var ot=r=>it(F({},"__esModule",{value:!0}),r);var xt={};de(xt,{CC:()=>we,ErrorCategory:()=>He,InterfaceLanguage:()=>Ke,Logger:()=>k,Observable:()=>a,Subject:()=>I,Subscription:()=>m,VERSION:()=>fe,VKNumericLanguage:()=>qe,ValueSubject:()=>S,VideoQuality:()=>M,abortable:()=>Oe,addScript:()=>xe,areQualitiesExact:()=>Ne,assertEmptyArray:()=>Ie,assertNever:()=>h,assertNonNullable:()=>Te,assertNotEmptyArray:()=>he,assertNullable:()=>ve,assertQualityIsExact:()=>_e,buffer:()=>q,checkNever:()=>me,clearVideoElement:()=>Be,cloneDeep:()=>De,cloneDeepWith:()=>E,combine:()=>W,debounce:()=>Y,debounceFn:()=>Q,detectEmbed:()=>Se,fillWithDefault:()=>Qe,filter:()=>Z,filterChanged:()=>te,fromEvent:()=>We,getExponentialDelay:()=>Ee,getHighestQuality:()=>Pe,interval:()=>ze,isHigher:()=>Re,isHigherOrEqual:()=>Ae,isInvariantQuality:()=>_,isLower:()=>N,isLowerOrEqual:()=>Ce,isNonNullable:()=>y,isNullable:()=>L,loadVKLangPack:()=>vt,map:()=>R,mapTo:()=>ne,merge:()=>G,noop:()=>x,now:()=>ye,observableFrom:()=>je,observeElementSize:()=>Ue,once:()=>ie,pairwise:()=>se,safeStorage:()=>V,tap:()=>le,throttle:()=>X,throttleFn:()=>D,timeCodeToString:()=>bt,timeout:()=>Fe,videoHeightToQuality:()=>Le,videoQualityToHeight:()=>Me,videoSizeToQuality:()=>Ve});module.exports=ot(xt);var fe="1.0.38-dev.c2293902.0";var m=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(t=>typeof t=="function"?t():t.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var h=r=>{throw new Error(`${r} is value of unexpected type`)},me=r=>{};var x=()=>{};var a=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,t){var l;let n;t?typeof t=="function"?n={next:t,error:x}:n={next:o=>t.next(o),error:o=>{var u;return(u=t.error)==null?void 0:u.call(t,o)}}:n={next:x,error:x};let i=typeof e=="function"?{next:o=>{try{e(o)}catch(u){n.next(u)}},error:o=>n.next(o)}:{next:o=>e.next(o),error:o=>e.error?e.error(o):n.next(o)},s;try{s=this._subscribe(i)}catch(o){(l=i.error)==null||l.call(i,o)}return new m().add(()=>{switch(i.next=x,i.error=x,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return h(s)}})}pipe(...e){return e.reduce((t,n)=>n(t),this)}_subscribe(e){}};var I=class extends a{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(t){this.subscribers.forEach(n=>n.next(t))}error(t){this.subscribers.forEach(n=>{var i;return(i=n.error)==null?void 0:i.call(n,t)})}_subscribe(t){let n=this.keyCounter++;return this.subscribers.set(n,t),new m().add(()=>this.subscribers.delete(n))}};var k=class{constructor(){this.log$=new I;this.logs=[];this.log=e=>{let t={...e,timestamp:Date.now()};this.logs.push(t),this.log$.next(t)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...t)=>{let n;try{n=e(...t)}catch(i){n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(t=>({component:e,...t}))}};function Te(r,e='Assertion "value is not nullable" failed'){if(r==null)throw new Error(e)}function ve(r,e='Assertion "value is nullable" failed'){if(r!=null)throw new Error(e)}function y(r){return typeof r!="undefined"&&r!==null}function L(r){return r==null}function he(r,e){if(!(r!=null&&r.length))throw new Error(e)}function Ie(r,e){if(r!=null&&r.length)throw new Error(e)}var xe=(r,e,t)=>new Promise((n,i)=>{e.addEventListener("abort",()=>{o(),p.remove()});let s=()=>{o(),i()},l=()=>{o(),n()},o=()=>{u&&clearTimeout(u),p.removeEventListener("load",l),p.removeEventListener("error",s)},u;t&&(u=window.setTimeout(s,t));let p=document.createElement("script");p.addEventListener("load",l),p.addEventListener("error",s),p.src=r,document.head.appendChild(p)});var ge,ye=typeof((ge=window.performance)==null?void 0:ge.now)=="function"?()=>window.performance.now():()=>Date.now();var Oe=(r,e)=>async(...t)=>{var l;let n=e(...t),i=r.aborted,s;for(;!i&&!r.aborted;)try{let o=await n.next(s);i=(l=o.done)!=null?l:!1,s=o.value}catch(o){await n.throw(o)}return s};var z=class{constructor(){this.detect()}get browser(){return this._currentBrowser}get device(){return this._currentDevice}get isTouch(){return this._maxTouchPoints>0}get isIOS(){return["iPhone","iPad","iPod"].includes(this.device)}get isMac(){return this.device==="Mac"}get isApple(){return this.isIOS||this.isMac}get isIphoneOrOldIpad(){if(!this.isApple||!this.isTouch)return!1;let e=this.device==="iPad"||(window==null?void 0:window.screen.width)>700,t=this._iosVersion;return!e||e&&!!t&&t<16}get isAndroid(){return this.device==="Android"}get isMobile(){var e,t;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test((e=navigator.appVersion)!=null?e:navigator.userAgent)||((t=navigator==null?void 0:navigator.userAgentData)==null?void 0:t.mobile)}get iOSVersion(){return this._iosVersion}get macVersion(){return this._macVersion}get isYandex(){return this.browser==="Yandex"}get isSafari(){return this.browser==="Safari"}get isSamsungBrowser(){return this.browser==="SamsungBrowser"}get isHDR(){return this._isHdr}detect(){var n;let{userAgent:e,maxTouchPoints:t}=navigator;try{this._maxTouchPoints=t,this._isHdr=!!((n=matchMedia("(dynamic-range: high)"))!=null&&n.matches)}catch(i){console.error(i)}this.detectBrowser(e),this.detectDevice(e),this.isIOS&&this.detectIOSVersion(),this.isMac&&this.detectMacVersion()}detectBrowser(e){try{let t=/yabrowser/i.test(e)?"Yandex":void 0,n=/samsungbrowser/i.test(e)?"SamsungBrowser":void 0,i=/chrome|crios/i.test(e)?"Chrome":void 0,s=/chromium/i.test(e)?"Chromium":void 0,l=/firefox|fxios/i.test(e)?"Firefox":void 0,o=/webkit|safari|khtml/i.test(e)?"Safari":void 0,u=/opr\//i.test(e)?"Opera":void 0,p=/edg/i.test(e)?"Edge":void 0;this._currentBrowser=t||n||l||u||p||i||s||o||"Rest"}catch(t){console.error(t)}}detectDevice(e){try{let t=/android/i.test(e)?"Android":void 0,n=/iphone/i.test(e)?"iPhone":void 0,i=/ipad/i.test(e)?"iPad":void 0,s=/ipod/i.test(e)?"iPod":void 0,l=/mac/i.test(e)?"Mac":void 0,o=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(e)?"RestMobile":void 0;this._currentDevice=t||n||i||s||o||l||"Desktop"}catch(t){console.error(t)}}detectIOSVersion(){try{let{userAgent:e}=window.navigator,t=e.match(/Version\/(\d+(\.\d+)?)/i);if(!t)return;let n=t[1],i=parseFloat(n);if(isNaN(i))return;this._iosVersion=i}catch(e){console.error(e)}}detectMacVersion(){try{let{userAgent:e}=window.navigator,t=e.match(/Version\/(\d+)/);if(!t)return;let n=t[1],i=parseInt(n,10);if(isNaN(i))return;this._macVersion=i}catch(e){console.error(e)}}},we=new z;var Ee=(r,{start:e=0,factor:t=2,max:n=1/0,min:i=e,random:s=0}={})=>{let l=e;return l*=t**r,l*=1+(Math.random()*s*2-s),l=Math.round(l),l=Math.min(l,n),l=Math.max(l,i),l};var V={};de(V,{clear:()=>pt,get:()=>at,has:()=>ct,isPersistent:()=>st,remove:()=>ut,set:()=>lt});var d,O,j=`vk-videoplayer-dummy-key-${Math.random()}`,w=()=>{if(O!==void 0)return O;try{localStorage.setItem(j,"test"),localStorage.removeItem(j),O=0}catch(r){if(r instanceof DOMException||r instanceof TypeError)try{sessionStorage.getItem(j),O=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)O=2;else throw e}else throw r}return O===2&&(d=new Map),O},st=()=>w()===0,at=r=>{var t,n;let e=w();switch(e){case 0:return(t=localStorage.getItem(r))!=null?t:void 0;case 1:return(n=sessionStorage.getItem(r))!=null?n:void 0;case 2:return d==null?void 0:d.get(r);default:h(e)}},lt=(r,e)=>{let t=w();switch(t){case 0:try{localStorage.setItem(r,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(r,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void(d==null?void 0:d.set(r,e));default:h(t)}},ct=r=>{var t;let e=w();switch(e){case 0:return r in localStorage;case 1:return r in sessionStorage;case 2:return(t=d==null?void 0:d.has(r))!=null?t:!1;default:return h(e),!1}},ut=r=>{let e=w();switch(e){case 0:return localStorage.removeItem(r);case 1:return sessionStorage.removeItem(r);case 2:return void(d==null?void 0:d.delete(r));default:h(e)}},pt=()=>{let r=w();switch(r){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return d==null?void 0:d.clear();default:h(r)}};var Se=()=>{let r,e;try{r=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?r=!0:(r=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let t=e?new URL(e).hostname:void 0;return{isEmbed:r,host:t}};var M=(f=>(f.INVARIANT="Invariant quality",f.Q_144P="144p",f.Q_240P="240p",f.Q_360P="360p",f.Q_480P="480p",f.Q_720P="720p",f.Q_1080P="1080p",f.Q_1440P="1440p",f.Q_2160P="2160p",f.Q_4320P="4320p",f))(M||{});var T={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"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}},Re=(r,e)=>T[r].height>T[e].height,Ae=(r,e)=>T[r].height>=T[e].height,N=(r,e)=>T[r].height<T[e].height,Ce=(r,e)=>T[r].height<=T[e].height,Pe=r=>r.sort((e,t)=>e===t?0:e==="Invariant quality"?1:t==="Invariant quality"?-1:N(e,t)?1:-1)[0],ke=Object.keys(T).sort((r,e)=>N(r,e)?-1:1),Le=(r,e=.02)=>[...ke].find(n=>T[n].height*(1+e)>=r),Ve=({width:r,height:e})=>{let t=Math.min(r,e),n=Math.max(r,e);return ke.find(i=>{let s=T[i];return s.width>=n&&s.height>=t})},Me=r=>T[r].height,_=r=>r==="Invariant quality",Ne=r=>r.every(e=>!_(e));function _e(r){if(_(r))throw new Error("Expected exact quality")}var Qe=(r,e)=>{let t={};for(let n of Object.keys(e)){let i=e[n],s=r[n];Array.isArray(i)&&Array.isArray(s)?t[n]=s:typeof i=="object"&&typeof s=="object"?t[n]=Qe(s,i):t[n]=n in r?s:i}return t};var bt=r=>{let e="";return r>=3600&&(e+=Math.floor(r/3600)+"h",r=r%3600),r>=60&&(e+=Math.floor(r/60)+"m",r=r%60),r>0&&(e+=Math.floor(r)+"s"),e};function Q(r,e=0,t){let n,i,s,l,o,u,p=0,f=!1,b=!1,U=!0,ce=!e&&e!==0&&typeof window.requestAnimationFrame=="function";t&&(f=!!t.leading,b="maxWait"in t,s=t!=null&&t.maxWait?Math.max(+(t==null?void 0:t.maxWait)||0,e):s,U="trailing"in t?!!t.trailing:U);function B(c){let v=n,g=i;return n=i=void 0,p=c,l=r.apply(g,v),l}function A(c,v){return ce?(o&&window.cancelAnimationFrame(o),window.requestAnimationFrame(c)):setTimeout(c,v)}function Ye(c){if(ce){window.cancelAnimationFrame(c);return}clearTimeout(c)}function $e(c){return p=c,o=A(C,e),f?B(c):l}function Xe(c){let v=c-u,g=c-p,be=e-v;return b?Math.min(be,s-g):be}function ue(c){let v=c-u,g=c-p;return u===void 0||v>=e||v<0||b&&g>=s}function C(){let c=Date.now();if(ue(c))return pe(c);o=A(C,Xe(c))}function pe(c){return o=void 0,U&&n?B(c):(n=i=void 0,l)}function Je(){o!==void 0&&Ye(o),p=0,n=u=i=o=void 0}function Ze(){return o===void 0?l:pe(Date.now())}function et(){return o!==void 0}function P(...c){let v=Date.now(),g=ue(v);if(n=c,i=this,u=v,g){if(o===void 0)return $e(u);if(b)return o=A(C,e),B(u)}return o===void 0&&(o=A(C,e)),l}return P.cancel=Je,P.flush=Ze,P.pending=et,P}var D=(r,e=0,t)=>Q(r,e,{...{leading:!0,trailing:!0},...t,maxWait:e});var E=(r,e)=>{if(r===null||typeof r!="object")return r;let t=Array.isArray(r)?[]:{};for(let n in r){if(typeof e=="function"){let i=e(r[n],n,r,t);if(i!==void 0){t[n]=i;continue}}typeof r[n]=="object"?t[n]=E(r[n],e):t[n]=r[n]}return t};var De=r=>E(r);var dt=300,Ue=(r,e=dt)=>new a(t=>{let{width:n,height:i}=r.getBoundingClientRect();if(t.next({width:n,height:i}),!window.ResizeObserver)return;let s=new ResizeObserver(D(l=>{let o=l[0];if(!o)return;let u,p;o.contentBoxSize&&o.contentBoxSize[0]?(p=o.contentBoxSize[0].blockSize,u=o.contentBoxSize[0].inlineSize):o.contentRect&&(u=o.contentRect.width,p=o.contentRect.height),y(u)&&y(p)&&t.next({width:u,height:p})},e));return s.observe(r),()=>s.disconnect()});var Be=r=>{r.removeAttribute("src"),r.load()};var S=class extends I{constructor(t){super();this.value=t}next(t){super.next(this.value=t)}error(t){super.error(this.value=t)}getValue(){return this.value}_subscribe(t){let n=super._subscribe(t);return t.next(this.value),n}};function W(r){return new a(e=>{let t={},n=Object.keys(r).length,i=s=>l=>{s in t||n--,t[s]=l,n===0&&e.next(t)};return Object.entries(r).reduce((s,[l,o])=>s.add(o.subscribe(i(l))),new m)})}function G(...r){return new a(e=>r.reduce((t,n)=>t.add(n.subscribe(e)),new m))}var Fe=r=>new a(e=>{let t=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},r);return()=>window.clearTimeout(t)});var ze=r=>new a(e=>{let t=window.setInterval(()=>e.next(),r);return()=>{t&&(window.clearInterval(t),t=void 0)}});var je=r=>new a(e=>{r.forEach(t=>e.next(t))});var We=(r,e)=>new a(t=>{let n=i=>t.next(i);return r.addEventListener(e,n),()=>r.removeEventListener(e,n)});function q(r){return e=>new a(t=>e.subscribe(new H(t,r)))}var H=class{constructor(e,t){this.destination=e;this.size=t;this.lastValues=[]}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};var ft={leading:!1,trailing:!0};function Y(r,e=ft){return t=>new a(n=>t.subscribe(new K(n,r,e)))}var K=class{constructor(e,t,n){this.destination=e;this.time=t;this.config=n}next(e){this.lastValue=e,y(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(t){if(this.destination.error)this.destination.error(t);else throw t}this.timeout=void 0},this.time)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};var mt={leading:!0,trailing:!1};function X(r,e=mt){return t=>new a(n=>t.subscribe(new $(n,r,e)))}var $=class{constructor(e,t,n){this.destination=e;this.time=t;this.config=n}next(e){this.lastValue=e,L(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function Z(r){return e=>new a(t=>e.subscribe(new J(t,r)))}var J=class{constructor(e,t){this.destination=e;this.predicate=t}next(e){let t;try{t=this.predicate(e)}catch(n){throw this.error(n),n}t&&this.destination.next(e)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function te(r=(e,t)=>e===t){return e=>new a(t=>e.subscribe(new ee(t,r)))}var Ge={},ee=class{constructor(e,t){this.destination=e;this.predicate=t;this.lastValue=Ge}next(e){let t;try{t=this.lastValue===Ge||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}t&&this.destination.next(e)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function R(r){return e=>new a(t=>e.subscribe(new re(t,r)))}var re=class{constructor(e,t){this.destination=e;this.mapper=t}next(e){let t;try{t=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(t)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function ne(r){return R(()=>r)}function ie(){return r=>new a(e=>{let t=!1,n=!1,i=r.subscribe(s=>{t||(t=!0,e.next(s)),n&&i.unsubscribe()},s=>{var l;t=!0,(l=e.error)==null||l.call(e,s),n&&i.unsubscribe()});return n=!0,t&&i.unsubscribe(),i})}function se(){return r=>new a(e=>r.subscribe(new oe(e)))}var oe=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let t=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([t,e])}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function le(r){return e=>new a(t=>e.subscribe(new ae(t,r)))}var ae=class{constructor(e,t){this.destination=e;this.effect=t}next(e){try{this.effect(e)}catch(t){throw this.error(t),t}this.destination.next(e)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};var He=(o=>(o.NETWORK="network",o.VIDEO_PIPELINE="video_pipeline",o.EXTERNAL_API="external_api",o.PARSER="parser",o.DOM="dom",o.WTF="wtf",o.FATAL="fatal",o))(He||{});var qe=(b=>(b.Armenian="58",b.Azerbaijani="57",b.Belarusian="114",b.English="3",b.Kazakh="97",b.Portuguese="73",b.Russian="0",b.Spanish="4",b.Ukrainian="1",b.Uzbek="65",b.Vietnamese="75",b))(qe||{}),Tt="vk.com",vt=async(r,e,t)=>{let n=new URL(`https://${Tt}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),r!==void 0&&n.searchParams.set("lang",r);let s=await(await fetch(n.toString())).json();return ht(s,t)},ht=(r,e)=>Object.fromEntries(Object.entries(r.keys).map(([t,n])=>[t.substring(`${e}_`.length),It(n)])),It=r=>Array.isArray(r)?r[0]:r;var Ke=(t=>(t.RU="ru",t.EN="en",t))(Ke||{});
|
|
6
|
+
"use strict";var j=Object.defineProperty;var at=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var ut=Object.prototype.hasOwnProperty;var me=(t,e)=>{for(var r in e)j(t,r,{get:e[r],enumerable:!0})},ct=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of lt(e))!ut.call(t,i)&&i!==r&&j(t,i,{get:()=>e[i],enumerable:!(n=at(e,i))||n.enumerable});return t};var pt=t=>ct(j({},"__esModule",{value:!0}),t);var At={};me(At,{CurrentClientBrowser:()=>W,CurrentClientDevice:()=>G,ErrorCategory:()=>Je,InterfaceLanguage:()=>et,Logger:()=>V,Observable:()=>a,Subject:()=>x,Subscription:()=>m,VERSION:()=>Te,VKNumericLanguage:()=>Ze,ValueSubject:()=>C,VideoQuality:()=>_,abortable:()=>Ee,addScript:()=>ye,areQualitiesExact:()=>Be,assertEmptyArray:()=>ge,assertNever:()=>I,assertNonNullable:()=>Ie,assertNotEmptyArray:()=>he,assertNullable:()=>xe,assertQualityIsExact:()=>ze,buffer:()=>Y,checkNever:()=>ve,clearVideoElement:()=>qe,cloneDeep:()=>We,cloneDeepWith:()=>R,combine:()=>H,debounce:()=>J,debounceFn:()=>B,detectEmbed:()=>Pe,fillWithDefault:()=>je,filter:()=>re,filterChanged:()=>oe,fromEvent:()=>Ye,getCurrentBrowser:()=>w,getExponentialDelay:()=>Le,getHighestQuality:()=>Qe,getIOSVersion:()=>Ae,interval:()=>Ke,isAndroid:()=>Re,isHigher:()=>Me,isHigherOrEqual:()=>Ne,isIOS:()=>Se,isInvariantQuality:()=>F,isLower:()=>U,isLowerOrEqual:()=>Ve,isMacLike:()=>Ce,isMobile:()=>ke,isNonNullable:()=>y,isNullable:()=>Q,loadVKLangPack:()=>wt,map:()=>k,mapTo:()=>se,merge:()=>K,noop:()=>h,now:()=>we,observableFrom:()=>$e,observeElementSize:()=>Ge,once:()=>ae,pairwise:()=>ue,safeStorage:()=>D,tap:()=>pe,throttle:()=>ee,throttleFn:()=>z,timeCodeToString:()=>xt,timeout:()=>He,videoHeightToQuality:()=>_e,videoQualityToHeight:()=>Fe,videoSizeToQuality:()=>Ue});module.exports=pt(At);var Te="1.0.38-dev.df616f9c.0";var m=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(r=>typeof r=="function"?r():r.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var I=t=>{throw new Error(`${t} is value of unexpected type`)},ve=t=>{};var h=()=>{};var a=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,r){var l;let n;r?typeof r=="function"?n={next:r,error:h}:n={next:o=>r.next(o),error:o=>{var u;return(u=r.error)==null?void 0:u.call(r,o)}}:n={next:h,error:h};let i=typeof e=="function"?{next:o=>{try{e(o)}catch(u){n.next(u)}},error:o=>n.next(o)}:{next:o=>e.next(o),error:o=>e.error?e.error(o):n.next(o)},s;try{s=this._subscribe(i)}catch(o){(l=i.error)==null||l.call(i,o)}return new m().add(()=>{switch(i.next=h,i.error=h,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return I(s)}})}pipe(...e){return e.reduce((r,n)=>n(r),this)}_subscribe(e){}};var x=class extends a{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(r){this.subscribers.forEach(n=>n.next(r))}error(r){this.subscribers.forEach(n=>{var i;return(i=n.error)==null?void 0:i.call(n,r)})}_subscribe(r){let n=this.keyCounter++;return this.subscribers.set(n,r),new m().add(()=>this.subscribers.delete(n))}};var V=class{constructor(){this.log$=new x;this.logs=[];this.log=e=>{let r={...e,timestamp:Date.now()};this.logs.push(r),this.log$.next(r)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...r)=>{let n;try{n=e(...r)}catch(i){n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(r=>({component:e,...r}))}};function Ie(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function xe(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function y(t){return typeof t!="undefined"&&t!==null}function Q(t){return t==null}function he(t,e){if(!(t!=null&&t.length))throw new Error(e)}function ge(t,e){if(t!=null&&t.length)throw new Error(e)}var ye=(t,e,r)=>new Promise((n,i)=>{e.addEventListener("abort",()=>{o(),b.remove()});let s=()=>{o(),i()},l=()=>{o(),n()},o=()=>{u&&clearTimeout(u),b.removeEventListener("load",l),b.removeEventListener("error",s)},u;r&&(u=window.setTimeout(s,r));let b=document.createElement("script");b.addEventListener("load",l),b.addEventListener("error",s),b.src=t,document.head.appendChild(b)});var Oe,we=typeof((Oe=window.performance)==null?void 0:Oe.now)=="function"?()=>window.performance.now():()=>Date.now();var Ee=(t,e)=>async(...r)=>{var l;let n=e(...r),i=t.aborted,s;for(;!i&&!t.aborted;)try{let o=await n.next(s);i=(l=o.done)!=null?l:!1,s=o.value}catch(o){await n.throw(o)}return s};var W=(c=>(c.Unknown="Unknown",c.Yandex="Yandex",c.Chrome="Chrome",c.Chromium="Chromium",c.Firefox="Firefox",c.Safari="Safari",c.Opera="Opera",c.Edge="Edge",c.SamsungBrowser="SamsungBrowser",c.Rest="Rest",c))(W||{}),G=(u=>(u.Unknown="Unknown",u.Android="Android",u.iPhone="iPhone",u.iPad="iPad",u.iPod="iPod",u.RestMobile="RestMobile",u.Mac="Mac",u.Desktop="Desktop",u))(G||{}),w=()=>{let{userAgent:t}=window.navigator,e=/yabrowser/i.test(t)?"Yandex":void 0,r=/samsungbrowser/i.test(t)?"SamsungBrowser":void 0,n=/chrome|crios/i.test(t)?"Chrome":void 0,i=/chromium/i.test(t)?"Chromium":void 0,s=/firefox|fxios/i.test(t)?"Firefox":void 0,l=/webkit|safari|khtml/i.test(t)?"Safari":void 0,o=/opr\//i.test(t)?"Opera":void 0,u=/edg/i.test(t)?"Edge":void 0,b=/android/i.test(t)?"Android":void 0,c=/iphone/i.test(t)?"iPhone":void 0,d=/ipad/i.test(t)?"iPad":void 0,S=/ipod/i.test(t)?"iPod":void 0,L=/mac/i.test(t)?"Mac":void 0,A=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(t)?"RestMobile":void 0;return{browser:e||r||s||o||u||n||i||l||"Rest",device:b||c||d||S||A||L||"Desktop"}},Se=(t=!1)=>{let r=["iPhone","iPad","iPod"].includes(w().device);if(!t)return r;let{userAgent:n,maxTouchPoints:i}=window.navigator;return!!(r||/macintosh/i.test(n)&&i>0)},Ae=()=>{let{userAgent:t}=window.navigator,e=t.match(/Version\/(\d+(\.\d+)?)/i);if(!e)return null;let r=e[1],n=parseFloat(r);return isNaN(n)?null:n},bt=()=>{let{device:t}=w(),{userAgent:e,maxTouchPoints:r}=window.navigator,n=/linux/i.test(e),i=r>0;return t==="Desktop"&&n&&i},Re=()=>w().device==="Android"||bt(),Ce=()=>["Mac","iPhone","iPad","iPod"].includes(w().device),ke=()=>{var t,e;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test((t=navigator.appVersion)!=null?t:navigator.userAgent)||((e=navigator==null?void 0:navigator.userAgentData)==null?void 0:e.mobile)};var Le=(t,{start:e=0,factor:r=2,max:n=1/0,min:i=e,random:s=0}={})=>{let l=e;return l*=r**t,l*=1+(Math.random()*s*2-s),l=Math.round(l),l=Math.min(l,n),l=Math.max(l,i),l};var D={};me(D,{clear:()=>It,get:()=>ft,has:()=>Tt,isPersistent:()=>dt,remove:()=>vt,set:()=>mt});var f,O,q=`vk-videoplayer-dummy-key-${Math.random()}`,E=()=>{if(O!==void 0)return O;try{localStorage.setItem(q,"test"),localStorage.removeItem(q),O=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem(q),O=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)O=2;else throw e}else throw t}return O===2&&(f=new Map),O},dt=()=>E()===0,ft=t=>{var r,n;let e=E();switch(e){case 0:return(r=localStorage.getItem(t))!=null?r:void 0;case 1:return(n=sessionStorage.getItem(t))!=null?n:void 0;case 2:return f==null?void 0:f.get(t);default:I(e)}},mt=(t,e)=>{let r=E();switch(r){case 0:try{localStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void(f==null?void 0:f.set(t,e));default:I(r)}},Tt=t=>{var r;let e=E();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return(r=f==null?void 0:f.has(t))!=null?r:!1;default:return I(e),!1}},vt=t=>{let e=E();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:return void(f==null?void 0:f.delete(t));default:I(e)}},It=()=>{let t=E();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return f==null?void 0:f.clear();default:I(t)}};var Pe=()=>{let t,e;try{t=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?t=!0:(t=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let r=e?new URL(e).hostname:void 0;return{isEmbed:t,host:r}};var _=(c=>(c.INVARIANT="Invariant quality",c.Q_144P="144p",c.Q_240P="240p",c.Q_360P="360p",c.Q_480P="480p",c.Q_720P="720p",c.Q_1080P="1080p",c.Q_1440P="1440p",c.Q_2160P="2160p",c.Q_4320P="4320p",c))(_||{});var T={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"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}},Me=(t,e)=>T[t].height>T[e].height,Ne=(t,e)=>T[t].height>=T[e].height,U=(t,e)=>T[t].height<T[e].height,Ve=(t,e)=>T[t].height<=T[e].height,Qe=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:U(e,r)?1:-1)[0],De=Object.keys(T).sort((t,e)=>U(t,e)?-1:1),_e=(t,e=.02)=>[...De].find(n=>T[n].height*(1+e)>=t),Ue=({width:t,height:e})=>{let r=Math.min(t,e),n=Math.max(t,e);return De.find(i=>{let s=T[i];return s.width>=n&&s.height>=r})},Fe=t=>T[t].height,F=t=>t==="Invariant quality",Be=t=>t.every(e=>!F(e));function ze(t){if(F(t))throw new Error("Expected exact quality")}var je=(t,e)=>{let r={};for(let n of Object.keys(e)){let i=e[n],s=t[n];Array.isArray(i)&&Array.isArray(s)?r[n]=s:typeof i=="object"&&typeof s=="object"?r[n]=je(s,i):r[n]=n in t?s:i}return r};var xt=t=>{let e="";return t>=3600&&(e+=Math.floor(t/3600)+"h",t=t%3600),t>=60&&(e+=Math.floor(t/60)+"m",t=t%60),t>0&&(e+=Math.floor(t)+"s"),e};function B(t,e=0,r){let n,i,s,l,o,u,b=0,c=!1,d=!1,S=!0,L=!e&&e!==0&&typeof window.requestAnimationFrame=="function";r&&(c=!!r.leading,d="maxWait"in r,s=r!=null&&r.maxWait?Math.max(+(r==null?void 0:r.maxWait)||0,e):s,S="trailing"in r?!!r.trailing:S);function A(p){let v=n,g=i;return n=i=void 0,b=p,l=t.apply(g,v),l}function P(p,v){return L?(o&&window.cancelAnimationFrame(o),window.requestAnimationFrame(p)):setTimeout(p,v)}function tt(p){if(L){window.cancelAnimationFrame(p);return}clearTimeout(p)}function rt(p){return b=p,o=P(M,e),c?A(p):l}function nt(p){let v=p-u,g=p-b,fe=e-v;return d?Math.min(fe,s-g):fe}function be(p){let v=p-u,g=p-b;return u===void 0||v>=e||v<0||d&&g>=s}function M(){let p=Date.now();if(be(p))return de(p);o=P(M,nt(p))}function de(p){return o=void 0,S&&n?A(p):(n=i=void 0,l)}function ot(){o!==void 0&&tt(o),b=0,n=u=i=o=void 0}function it(){return o===void 0?l:de(Date.now())}function st(){return o!==void 0}function N(...p){let v=Date.now(),g=be(v);if(n=p,i=this,u=v,g){if(o===void 0)return rt(u);if(d)return o=P(M,e),A(u)}return o===void 0&&(o=P(M,e)),l}return N.cancel=ot,N.flush=it,N.pending=st,N}var z=(t,e=0,r)=>B(t,e,{...{leading:!0,trailing:!0},...r,maxWait:e});var R=(t,e)=>{if(t===null||typeof t!="object")return t;let r=Array.isArray(t)?[]:{};for(let n in t){if(typeof e=="function"){let i=e(t[n],n,t,r);if(i!==void 0){r[n]=i;continue}}typeof t[n]=="object"?r[n]=R(t[n],e):r[n]=t[n]}return r};var We=t=>R(t);var ht=300,Ge=(t,e=ht)=>new a(r=>{let{width:n,height:i}=t.getBoundingClientRect();if(r.next({width:n,height:i}),!window.ResizeObserver)return;let s=new ResizeObserver(z(l=>{let o=l[0];if(!o)return;let u,b;o.contentBoxSize&&o.contentBoxSize[0]?(b=o.contentBoxSize[0].blockSize,u=o.contentBoxSize[0].inlineSize):o.contentRect&&(u=o.contentRect.width,b=o.contentRect.height),y(u)&&y(b)&&r.next({width:u,height:b})},e));return s.observe(t),()=>s.disconnect()});var qe=t=>{t.removeAttribute("src"),t.load()};var C=class extends x{constructor(r){super();this.value=r}next(r){super.next(this.value=r)}error(r){super.error(this.value=r)}getValue(){return this.value}_subscribe(r){let n=super._subscribe(r);return r.next(this.value),n}};function H(t){return new a(e=>{let r={},n=Object.keys(t).length,i=s=>l=>{s in r||n--,r[s]=l,n===0&&e.next(r)};return Object.entries(t).reduce((s,[l,o])=>s.add(o.subscribe(i(l))),new m)})}function K(...t){return new a(e=>t.reduce((r,n)=>r.add(n.subscribe(e)),new m))}var He=t=>new a(e=>{let r=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},t);return()=>window.clearTimeout(r)});var Ke=t=>new a(e=>{let r=window.setInterval(()=>e.next(),t);return()=>{r&&(window.clearInterval(r),r=void 0)}});var $e=t=>new a(e=>{t.forEach(r=>e.next(r))});var Ye=(t,e)=>new a(r=>{let n=i=>r.next(i);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)});function Y(t){return e=>new a(r=>e.subscribe(new $(r,t)))}var $=class{constructor(e,r){this.destination=e;this.size=r;this.lastValues=[]}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};var gt={leading:!1,trailing:!0};function J(t,e=gt){return r=>new a(n=>r.subscribe(new X(n,t,e)))}var X=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,y(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(r){if(this.destination.error)this.destination.error(r);else throw r}this.timeout=void 0},this.time)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};var yt={leading:!0,trailing:!1};function ee(t,e=yt){return r=>new a(n=>r.subscribe(new Z(n,t,e)))}var Z=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,Q(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function re(t){return e=>new a(r=>e.subscribe(new te(r,t)))}var te=class{constructor(e,r){this.destination=e;this.predicate=r}next(e){let r;try{r=this.predicate(e)}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function oe(t=(e,r)=>e===r){return e=>new a(r=>e.subscribe(new ne(r,t)))}var Xe={},ne=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=Xe}next(e){let r;try{r=this.lastValue===Xe||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function k(t){return e=>new a(r=>e.subscribe(new ie(r,t)))}var ie=class{constructor(e,r){this.destination=e;this.mapper=r}next(e){let r;try{r=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(r)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function se(t){return k(()=>t)}function ae(){return t=>new a(e=>{let r=!1,n=!1,i=t.subscribe(s=>{r||(r=!0,e.next(s)),n&&i.unsubscribe()},s=>{var l;r=!0,(l=e.error)==null||l.call(e,s),n&&i.unsubscribe()});return n=!0,r&&i.unsubscribe(),i})}function ue(){return t=>new a(e=>t.subscribe(new le(e)))}var le=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let r=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([r,e])}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function pe(t){return e=>new a(r=>e.subscribe(new ce(r,t)))}var ce=class{constructor(e,r){this.destination=e;this.effect=r}next(e){try{this.effect(e)}catch(r){throw this.error(r),r}this.destination.next(e)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};var Je=(o=>(o.NETWORK="network",o.VIDEO_PIPELINE="video_pipeline",o.EXTERNAL_API="external_api",o.PARSER="parser",o.DOM="dom",o.WTF="wtf",o.FATAL="fatal",o))(Je||{});var Ze=(d=>(d.Armenian="58",d.Azerbaijani="57",d.Belarusian="114",d.English="3",d.Kazakh="97",d.Portuguese="73",d.Russian="0",d.Spanish="4",d.Ukrainian="1",d.Uzbek="65",d.Vietnamese="75",d))(Ze||{}),Ot="vk.com",wt=async(t,e,r)=>{let n=new URL(`https://${Ot}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),t!==void 0&&n.searchParams.set("lang",t);let s=await(await fetch(n.toString())).json();return Et(s,r)},Et=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,n])=>[r.substring(`${e}_`.length),St(n)])),St=t=>Array.isArray(t)?t[0]:t;var et=(r=>(r.RU="ru",r.EN="en",r))(et||{});
|
package/es2018.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-shared v1.0.38-dev.
|
|
3
|
-
*
|
|
2
|
+
* @vkontakte/videoplayer-shared v1.0.38-dev.df616f9c.0
|
|
3
|
+
* Fri, 16 Aug 2024 08:31:38 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-38/doc/
|
|
5
5
|
*/
|
|
6
|
-
var ge=Object.defineProperty;var ye=(r,e)=>{for(var t in e)ge(r,t,{get:e[t],enumerable:!0})};var Oe="1.0.38-dev.c2293902.0";var m=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(t=>typeof t=="function"?t():t.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var h=r=>{throw new Error(`${r} is value of unexpected type`)},we=r=>{};var g=()=>{};var l=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,t){var a;let n;t?typeof t=="function"?n={next:t,error:g}:n={next:i=>t.next(i),error:i=>{var u;return(u=t.error)==null?void 0:u.call(t,i)}}:n={next:g,error:g};let o=typeof e=="function"?{next:i=>{try{e(i)}catch(u){n.next(u)}},error:i=>n.next(i)}:{next:i=>e.next(i),error:i=>e.error?e.error(i):n.next(i)},s;try{s=this._subscribe(o)}catch(i){(a=o.error)==null||a.call(o,i)}return new m().add(()=>{switch(o.next=g,o.error=g,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return h(s)}})}pipe(...e){return e.reduce((t,n)=>n(t),this)}_subscribe(e){}};var I=class extends l{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(t){this.subscribers.forEach(n=>n.next(t))}error(t){this.subscribers.forEach(n=>{var o;return(o=n.error)==null?void 0:o.call(n,t)})}_subscribe(t){let n=this.keyCounter++;return this.subscribers.set(n,t),new m().add(()=>this.subscribers.delete(n))}};var V=class{constructor(){this.log$=new I;this.logs=[];this.log=e=>{let t={...e,timestamp:Date.now()};this.logs.push(t),this.log$.next(t)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...t)=>{let n;try{n=e(...t)}catch(o){n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(t=>({component:e,...t}))}};function Ee(r,e='Assertion "value is not nullable" failed'){if(r==null)throw new Error(e)}function Se(r,e='Assertion "value is nullable" failed'){if(r!=null)throw new Error(e)}function O(r){return typeof r!="undefined"&&r!==null}function M(r){return r==null}function Re(r,e){if(!(r!=null&&r.length))throw new Error(e)}function Ae(r,e){if(r!=null&&r.length)throw new Error(e)}var Ce=(r,e,t)=>new Promise((n,o)=>{e.addEventListener("abort",()=>{i(),p.remove()});let s=()=>{i(),o()},a=()=>{i(),n()},i=()=>{u&&clearTimeout(u),p.removeEventListener("load",a),p.removeEventListener("error",s)},u;t&&(u=window.setTimeout(s,t));let p=document.createElement("script");p.addEventListener("load",a),p.addEventListener("error",s),p.src=r,document.head.appendChild(p)});var te,Pe=typeof((te=window.performance)==null?void 0:te.now)=="function"?()=>window.performance.now():()=>Date.now();var ke=(r,e)=>async(...t)=>{var a;let n=e(...t),o=r.aborted,s;for(;!o&&!r.aborted;)try{let i=await n.next(s);o=(a=i.done)!=null?a:!1,s=i.value}catch(i){await n.throw(i)}return s};var N=class{constructor(){this.detect()}get browser(){return this._currentBrowser}get device(){return this._currentDevice}get isTouch(){return this._maxTouchPoints>0}get isIOS(){return["iPhone","iPad","iPod"].includes(this.device)}get isMac(){return this.device==="Mac"}get isApple(){return this.isIOS||this.isMac}get isIphoneOrOldIpad(){if(!this.isApple||!this.isTouch)return!1;let e=this.device==="iPad"||(window==null?void 0:window.screen.width)>700,t=this._iosVersion;return!e||e&&!!t&&t<16}get isAndroid(){return this.device==="Android"}get isMobile(){var e,t;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test((e=navigator.appVersion)!=null?e:navigator.userAgent)||((t=navigator==null?void 0:navigator.userAgentData)==null?void 0:t.mobile)}get iOSVersion(){return this._iosVersion}get macVersion(){return this._macVersion}get isYandex(){return this.browser==="Yandex"}get isSafari(){return this.browser==="Safari"}get isSamsungBrowser(){return this.browser==="SamsungBrowser"}get isHDR(){return this._isHdr}detect(){var n;let{userAgent:e,maxTouchPoints:t}=navigator;try{this._maxTouchPoints=t,this._isHdr=!!((n=matchMedia("(dynamic-range: high)"))!=null&&n.matches)}catch(o){console.error(o)}this.detectBrowser(e),this.detectDevice(e),this.isIOS&&this.detectIOSVersion(),this.isMac&&this.detectMacVersion()}detectBrowser(e){try{let t=/yabrowser/i.test(e)?"Yandex":void 0,n=/samsungbrowser/i.test(e)?"SamsungBrowser":void 0,o=/chrome|crios/i.test(e)?"Chrome":void 0,s=/chromium/i.test(e)?"Chromium":void 0,a=/firefox|fxios/i.test(e)?"Firefox":void 0,i=/webkit|safari|khtml/i.test(e)?"Safari":void 0,u=/opr\//i.test(e)?"Opera":void 0,p=/edg/i.test(e)?"Edge":void 0;this._currentBrowser=t||n||a||u||p||o||s||i||"Rest"}catch(t){console.error(t)}}detectDevice(e){try{let t=/android/i.test(e)?"Android":void 0,n=/iphone/i.test(e)?"iPhone":void 0,o=/ipad/i.test(e)?"iPad":void 0,s=/ipod/i.test(e)?"iPod":void 0,a=/mac/i.test(e)?"Mac":void 0,i=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(e)?"RestMobile":void 0;this._currentDevice=t||n||o||s||i||a||"Desktop"}catch(t){console.error(t)}}detectIOSVersion(){try{let{userAgent:e}=window.navigator,t=e.match(/Version\/(\d+(\.\d+)?)/i);if(!t)return;let n=t[1],o=parseFloat(n);if(isNaN(o))return;this._iosVersion=o}catch(e){console.error(e)}}detectMacVersion(){try{let{userAgent:e}=window.navigator,t=e.match(/Version\/(\d+)/);if(!t)return;let n=t[1],o=parseInt(n,10);if(isNaN(o))return;this._macVersion=o}catch(e){console.error(e)}}},Le=new N;var Ve=(r,{start:e=0,factor:t=2,max:n=1/0,min:o=e,random:s=0}={})=>{let a=e;return a*=t**r,a*=1+(Math.random()*s*2-s),a=Math.round(a),a=Math.min(a,n),a=Math.max(a,o),a};var Q={};ye(Q,{clear:()=>Ue,get:()=>Ne,has:()=>Qe,isPersistent:()=>Me,remove:()=>De,set:()=>_e});var d,y,_=`vk-videoplayer-dummy-key-${Math.random()}`,w=()=>{if(y!==void 0)return y;try{localStorage.setItem(_,"test"),localStorage.removeItem(_),y=0}catch(r){if(r instanceof DOMException||r instanceof TypeError)try{sessionStorage.getItem(_),y=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)y=2;else throw e}else throw r}return y===2&&(d=new Map),y},Me=()=>w()===0,Ne=r=>{var t,n;let e=w();switch(e){case 0:return(t=localStorage.getItem(r))!=null?t:void 0;case 1:return(n=sessionStorage.getItem(r))!=null?n:void 0;case 2:return d==null?void 0:d.get(r);default:h(e)}},_e=(r,e)=>{let t=w();switch(t){case 0:try{localStorage.setItem(r,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(r,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void(d==null?void 0:d.set(r,e));default:h(t)}},Qe=r=>{var t;let e=w();switch(e){case 0:return r in localStorage;case 1:return r in sessionStorage;case 2:return(t=d==null?void 0:d.has(r))!=null?t:!1;default:return h(e),!1}},De=r=>{let e=w();switch(e){case 0:return localStorage.removeItem(r);case 1:return sessionStorage.removeItem(r);case 2:return void(d==null?void 0:d.delete(r));default:h(e)}},Ue=()=>{let r=w();switch(r){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return d==null?void 0:d.clear();default:h(r)}};var Be=()=>{let r,e;try{r=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?r=!0:(r=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let t=e?new URL(e).hostname:void 0;return{isEmbed:r,host:t}};var D=(f=>(f.INVARIANT="Invariant quality",f.Q_144P="144p",f.Q_240P="240p",f.Q_360P="360p",f.Q_480P="480p",f.Q_720P="720p",f.Q_1080P="1080p",f.Q_1440P="1440p",f.Q_2160P="2160p",f.Q_4320P="4320p",f))(D||{});var T={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"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}},Fe=(r,e)=>T[r].height>T[e].height,ze=(r,e)=>T[r].height>=T[e].height,U=(r,e)=>T[r].height<T[e].height,je=(r,e)=>T[r].height<=T[e].height,We=r=>r.sort((e,t)=>e===t?0:e==="Invariant quality"?1:t==="Invariant quality"?-1:U(e,t)?1:-1)[0],re=Object.keys(T).sort((r,e)=>U(r,e)?-1:1),Ge=(r,e=.02)=>[...re].find(n=>T[n].height*(1+e)>=r),He=({width:r,height:e})=>{let t=Math.min(r,e),n=Math.max(r,e);return re.find(o=>{let s=T[o];return s.width>=n&&s.height>=t})},qe=r=>T[r].height,B=r=>r==="Invariant quality",Ke=r=>r.every(e=>!B(e));function Ye(r){if(B(r))throw new Error("Expected exact quality")}var $e=(r,e)=>{let t={};for(let n of Object.keys(e)){let o=e[n],s=r[n];Array.isArray(o)&&Array.isArray(s)?t[n]=s:typeof o=="object"&&typeof s=="object"?t[n]=$e(s,o):t[n]=n in r?s:o}return t};var zt=r=>{let e="";return r>=3600&&(e+=Math.floor(r/3600)+"h",r=r%3600),r>=60&&(e+=Math.floor(r/60)+"m",r=r%60),r>0&&(e+=Math.floor(r)+"s"),e};function F(r,e=0,t){let n,o,s,a,i,u,p=0,f=!1,b=!1,k=!0,X=!e&&e!==0&&typeof window.requestAnimationFrame=="function";t&&(f=!!t.leading,b="maxWait"in t,s=t!=null&&t.maxWait?Math.max(+(t==null?void 0:t.maxWait)||0,e):s,k="trailing"in t?!!t.trailing:k);function L(c){let v=n,x=o;return n=o=void 0,p=c,a=r.apply(x,v),a}function E(c,v){return X?(i&&window.cancelAnimationFrame(i),window.requestAnimationFrame(c)):setTimeout(c,v)}function me(c){if(X){window.cancelAnimationFrame(c);return}clearTimeout(c)}function Te(c){return p=c,i=E(S,e),f?L(c):a}function ve(c){let v=c-u,x=c-p,ee=e-v;return b?Math.min(ee,s-x):ee}function J(c){let v=c-u,x=c-p;return u===void 0||v>=e||v<0||b&&x>=s}function S(){let c=Date.now();if(J(c))return Z(c);i=E(S,ve(c))}function Z(c){return i=void 0,k&&n?L(c):(n=o=void 0,a)}function he(){i!==void 0&&me(i),p=0,n=u=o=i=void 0}function Ie(){return i===void 0?a:Z(Date.now())}function xe(){return i!==void 0}function R(...c){let v=Date.now(),x=J(v);if(n=c,o=this,u=v,x){if(i===void 0)return Te(u);if(b)return i=E(S,e),L(u)}return i===void 0&&(i=E(S,e)),a}return R.cancel=he,R.flush=Ie,R.pending=xe,R}var z=(r,e=0,t)=>F(r,e,{...{leading:!0,trailing:!0},...t,maxWait:e});var A=(r,e)=>{if(r===null||typeof r!="object")return r;let t=Array.isArray(r)?[]:{};for(let n in r){if(typeof e=="function"){let o=e(r[n],n,r,t);if(o!==void 0){t[n]=o;continue}}typeof r[n]=="object"?t[n]=A(r[n],e):t[n]=r[n]}return t};var Xe=r=>A(r);var Je=300,Ze=(r,e=Je)=>new l(t=>{let{width:n,height:o}=r.getBoundingClientRect();if(t.next({width:n,height:o}),!window.ResizeObserver)return;let s=new ResizeObserver(z(a=>{let i=a[0];if(!i)return;let u,p;i.contentBoxSize&&i.contentBoxSize[0]?(p=i.contentBoxSize[0].blockSize,u=i.contentBoxSize[0].inlineSize):i.contentRect&&(u=i.contentRect.width,p=i.contentRect.height),O(u)&&O(p)&&t.next({width:u,height:p})},e));return s.observe(r),()=>s.disconnect()});var et=r=>{r.removeAttribute("src"),r.load()};var C=class extends I{constructor(t){super();this.value=t}next(t){super.next(this.value=t)}error(t){super.error(this.value=t)}getValue(){return this.value}_subscribe(t){let n=super._subscribe(t);return t.next(this.value),n}};function ne(r){return new l(e=>{let t={},n=Object.keys(r).length,o=s=>a=>{s in t||n--,t[s]=a,n===0&&e.next(t)};return Object.entries(r).reduce((s,[a,i])=>s.add(i.subscribe(o(a))),new m)})}function ie(...r){return new l(e=>r.reduce((t,n)=>t.add(n.subscribe(e)),new m))}var tt=r=>new l(e=>{let t=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},r);return()=>window.clearTimeout(t)});var rt=r=>new l(e=>{let t=window.setInterval(()=>e.next(),r);return()=>{t&&(window.clearInterval(t),t=void 0)}});var nt=r=>new l(e=>{r.forEach(t=>e.next(t))});var it=(r,e)=>new l(t=>{let n=o=>t.next(o);return r.addEventListener(e,n),()=>r.removeEventListener(e,n)});function oe(r){return e=>new l(t=>e.subscribe(new j(t,r)))}var j=class{constructor(e,t){this.destination=e;this.size=t;this.lastValues=[]}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};var ot={leading:!1,trailing:!0};function se(r,e=ot){return t=>new l(n=>t.subscribe(new W(n,r,e)))}var W=class{constructor(e,t,n){this.destination=e;this.time=t;this.config=n}next(e){this.lastValue=e,O(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(t){if(this.destination.error)this.destination.error(t);else throw t}this.timeout=void 0},this.time)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};var st={leading:!0,trailing:!1};function ae(r,e=st){return t=>new l(n=>t.subscribe(new G(n,r,e)))}var G=class{constructor(e,t,n){this.destination=e;this.time=t;this.config=n}next(e){this.lastValue=e,M(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function le(r){return e=>new l(t=>e.subscribe(new H(t,r)))}var H=class{constructor(e,t){this.destination=e;this.predicate=t}next(e){let t;try{t=this.predicate(e)}catch(n){throw this.error(n),n}t&&this.destination.next(e)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function ue(r=(e,t)=>e===t){return e=>new l(t=>e.subscribe(new q(t,r)))}var ce={},q=class{constructor(e,t){this.destination=e;this.predicate=t;this.lastValue=ce}next(e){let t;try{t=this.lastValue===ce||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}t&&this.destination.next(e)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function P(r){return e=>new l(t=>e.subscribe(new K(t,r)))}var K=class{constructor(e,t){this.destination=e;this.mapper=t}next(e){let t;try{t=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(t)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function pe(r){return P(()=>r)}function be(){return r=>new l(e=>{let t=!1,n=!1,o=r.subscribe(s=>{t||(t=!0,e.next(s)),n&&o.unsubscribe()},s=>{var a;t=!0,(a=e.error)==null||a.call(e,s),n&&o.unsubscribe()});return n=!0,t&&o.unsubscribe(),o})}function de(){return r=>new l(e=>r.subscribe(new Y(e)))}var Y=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let t=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([t,e])}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function fe(r){return e=>new l(t=>e.subscribe(new $(t,r)))}var $=class{constructor(e,t){this.destination=e;this.effect=t}next(e){try{this.effect(e)}catch(t){throw this.error(t),t}this.destination.next(e)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};var at=(i=>(i.NETWORK="network",i.VIDEO_PIPELINE="video_pipeline",i.EXTERNAL_API="external_api",i.PARSER="parser",i.DOM="dom",i.WTF="wtf",i.FATAL="fatal",i))(at||{});var lt=(b=>(b.Armenian="58",b.Azerbaijani="57",b.Belarusian="114",b.English="3",b.Kazakh="97",b.Portuguese="73",b.Russian="0",b.Spanish="4",b.Ukrainian="1",b.Uzbek="65",b.Vietnamese="75",b))(lt||{}),ct="vk.com",Vn=async(r,e,t)=>{let n=new URL(`https://${ct}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),r!==void 0&&n.searchParams.set("lang",r);let s=await(await fetch(n.toString())).json();return ut(s,t)},ut=(r,e)=>Object.fromEntries(Object.entries(r.keys).map(([t,n])=>[t.substring(`${e}_`.length),pt(n)])),pt=r=>Array.isArray(r)?r[0]:r;var bt=(t=>(t.RU="ru",t.EN="en",t))(bt||{});export{Le as CC,at as ErrorCategory,bt as InterfaceLanguage,V as Logger,l as Observable,I as Subject,m as Subscription,Oe as VERSION,lt as VKNumericLanguage,C as ValueSubject,D as VideoQuality,ke as abortable,Ce as addScript,Ke as areQualitiesExact,Ae as assertEmptyArray,h as assertNever,Ee as assertNonNullable,Re as assertNotEmptyArray,Se as assertNullable,Ye as assertQualityIsExact,oe as buffer,we as checkNever,et as clearVideoElement,Xe as cloneDeep,A as cloneDeepWith,ne as combine,se as debounce,F as debounceFn,Be as detectEmbed,$e as fillWithDefault,le as filter,ue as filterChanged,it as fromEvent,Ve as getExponentialDelay,We as getHighestQuality,rt as interval,Fe as isHigher,ze as isHigherOrEqual,B as isInvariantQuality,U as isLower,je as isLowerOrEqual,O as isNonNullable,M as isNullable,Vn as loadVKLangPack,P as map,pe as mapTo,ie as merge,g as noop,Pe as now,nt as observableFrom,Ze as observeElementSize,be as once,de as pairwise,Q as safeStorage,fe as tap,ae as throttle,z as throttleFn,zt as timeCodeToString,tt as timeout,Ge as videoHeightToQuality,qe as videoQualityToHeight,He as videoSizeToQuality};
|
|
6
|
+
var Oe=Object.defineProperty;var we=(t,e)=>{for(var r in e)Oe(t,r,{get:e[r],enumerable:!0})};var Ee="1.0.38-dev.df616f9c.0";var m=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(r=>typeof r=="function"?r():r.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var I=t=>{throw new Error(`${t} is value of unexpected type`)},Se=t=>{};var g=()=>{};var a=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,r){var l;let n;r?typeof r=="function"?n={next:r,error:g}:n={next:o=>r.next(o),error:o=>{var u;return(u=r.error)==null?void 0:u.call(r,o)}}:n={next:g,error:g};let i=typeof e=="function"?{next:o=>{try{e(o)}catch(u){n.next(u)}},error:o=>n.next(o)}:{next:o=>e.next(o),error:o=>e.error?e.error(o):n.next(o)},s;try{s=this._subscribe(i)}catch(o){(l=i.error)==null||l.call(i,o)}return new m().add(()=>{switch(i.next=g,i.error=g,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return I(s)}})}pipe(...e){return e.reduce((r,n)=>n(r),this)}_subscribe(e){}};var x=class extends a{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(r){this.subscribers.forEach(n=>n.next(r))}error(r){this.subscribers.forEach(n=>{var i;return(i=n.error)==null?void 0:i.call(n,r)})}_subscribe(r){let n=this.keyCounter++;return this.subscribers.set(n,r),new m().add(()=>this.subscribers.delete(n))}};var V=class{constructor(){this.log$=new x;this.logs=[];this.log=e=>{let r={...e,timestamp:Date.now()};this.logs.push(r),this.log$.next(r)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...r)=>{let n;try{n=e(...r)}catch(i){n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(r=>({component:e,...r}))}};function Ae(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function Re(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function O(t){return typeof t!="undefined"&&t!==null}function Q(t){return t==null}function Ce(t,e){if(!(t!=null&&t.length))throw new Error(e)}function ke(t,e){if(t!=null&&t.length)throw new Error(e)}var Le=(t,e,r)=>new Promise((n,i)=>{e.addEventListener("abort",()=>{o(),b.remove()});let s=()=>{o(),i()},l=()=>{o(),n()},o=()=>{u&&clearTimeout(u),b.removeEventListener("load",l),b.removeEventListener("error",s)},u;r&&(u=window.setTimeout(s,r));let b=document.createElement("script");b.addEventListener("load",l),b.addEventListener("error",s),b.src=t,document.head.appendChild(b)});var te,Pe=typeof((te=window.performance)==null?void 0:te.now)=="function"?()=>window.performance.now():()=>Date.now();var Me=(t,e)=>async(...r)=>{var l;let n=e(...r),i=t.aborted,s;for(;!i&&!t.aborted;)try{let o=await n.next(s);i=(l=o.done)!=null?l:!1,s=o.value}catch(o){await n.throw(o)}return s};var re=(c=>(c.Unknown="Unknown",c.Yandex="Yandex",c.Chrome="Chrome",c.Chromium="Chromium",c.Firefox="Firefox",c.Safari="Safari",c.Opera="Opera",c.Edge="Edge",c.SamsungBrowser="SamsungBrowser",c.Rest="Rest",c))(re||{}),ne=(u=>(u.Unknown="Unknown",u.Android="Android",u.iPhone="iPhone",u.iPad="iPad",u.iPod="iPod",u.RestMobile="RestMobile",u.Mac="Mac",u.Desktop="Desktop",u))(ne||{}),A=()=>{let{userAgent:t}=window.navigator,e=/yabrowser/i.test(t)?"Yandex":void 0,r=/samsungbrowser/i.test(t)?"SamsungBrowser":void 0,n=/chrome|crios/i.test(t)?"Chrome":void 0,i=/chromium/i.test(t)?"Chromium":void 0,s=/firefox|fxios/i.test(t)?"Firefox":void 0,l=/webkit|safari|khtml/i.test(t)?"Safari":void 0,o=/opr\//i.test(t)?"Opera":void 0,u=/edg/i.test(t)?"Edge":void 0,b=/android/i.test(t)?"Android":void 0,c=/iphone/i.test(t)?"iPhone":void 0,d=/ipad/i.test(t)?"iPad":void 0,E=/ipod/i.test(t)?"iPod":void 0,R=/mac/i.test(t)?"Mac":void 0,S=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(t)?"RestMobile":void 0;return{browser:e||r||s||o||u||n||i||l||"Rest",device:b||c||d||E||S||R||"Desktop"}},Ne=(t=!1)=>{let r=["iPhone","iPad","iPod"].includes(A().device);if(!t)return r;let{userAgent:n,maxTouchPoints:i}=window.navigator;return!!(r||/macintosh/i.test(n)&&i>0)},Ve=()=>{let{userAgent:t}=window.navigator,e=t.match(/Version\/(\d+(\.\d+)?)/i);if(!e)return null;let r=e[1],n=parseFloat(r);return isNaN(n)?null:n},Qe=()=>{let{device:t}=A(),{userAgent:e,maxTouchPoints:r}=window.navigator,n=/linux/i.test(e),i=r>0;return t==="Desktop"&&n&&i},De=()=>A().device==="Android"||Qe(),_e=()=>["Mac","iPhone","iPad","iPod"].includes(A().device),Ue=()=>{var t,e;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test((t=navigator.appVersion)!=null?t:navigator.userAgent)||((e=navigator==null?void 0:navigator.userAgentData)==null?void 0:e.mobile)};var Fe=(t,{start:e=0,factor:r=2,max:n=1/0,min:i=e,random:s=0}={})=>{let l=e;return l*=r**t,l*=1+(Math.random()*s*2-s),l=Math.round(l),l=Math.min(l,n),l=Math.max(l,i),l};var _={};we(_,{clear:()=>qe,get:()=>ze,has:()=>We,isPersistent:()=>Be,remove:()=>Ge,set:()=>je});var f,y,D=`vk-videoplayer-dummy-key-${Math.random()}`,w=()=>{if(y!==void 0)return y;try{localStorage.setItem(D,"test"),localStorage.removeItem(D),y=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem(D),y=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)y=2;else throw e}else throw t}return y===2&&(f=new Map),y},Be=()=>w()===0,ze=t=>{var r,n;let e=w();switch(e){case 0:return(r=localStorage.getItem(t))!=null?r:void 0;case 1:return(n=sessionStorage.getItem(t))!=null?n:void 0;case 2:return f==null?void 0:f.get(t);default:I(e)}},je=(t,e)=>{let r=w();switch(r){case 0:try{localStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void(f==null?void 0:f.set(t,e));default:I(r)}},We=t=>{var r;let e=w();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return(r=f==null?void 0:f.has(t))!=null?r:!1;default:return I(e),!1}},Ge=t=>{let e=w();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:return void(f==null?void 0:f.delete(t));default:I(e)}},qe=()=>{let t=w();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return f==null?void 0:f.clear();default:I(t)}};var He=()=>{let t,e;try{t=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?t=!0:(t=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let r=e?new URL(e).hostname:void 0;return{isEmbed:t,host:r}};var U=(c=>(c.INVARIANT="Invariant quality",c.Q_144P="144p",c.Q_240P="240p",c.Q_360P="360p",c.Q_480P="480p",c.Q_720P="720p",c.Q_1080P="1080p",c.Q_1440P="1440p",c.Q_2160P="2160p",c.Q_4320P="4320p",c))(U||{});var T={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"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}},Ke=(t,e)=>T[t].height>T[e].height,$e=(t,e)=>T[t].height>=T[e].height,F=(t,e)=>T[t].height<T[e].height,Ye=(t,e)=>T[t].height<=T[e].height,Xe=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:F(e,r)?1:-1)[0],oe=Object.keys(T).sort((t,e)=>F(t,e)?-1:1),Je=(t,e=.02)=>[...oe].find(n=>T[n].height*(1+e)>=t),Ze=({width:t,height:e})=>{let r=Math.min(t,e),n=Math.max(t,e);return oe.find(i=>{let s=T[i];return s.width>=n&&s.height>=r})},et=t=>T[t].height,B=t=>t==="Invariant quality",tt=t=>t.every(e=>!B(e));function rt(t){if(B(t))throw new Error("Expected exact quality")}var nt=(t,e)=>{let r={};for(let n of Object.keys(e)){let i=e[n],s=t[n];Array.isArray(i)&&Array.isArray(s)?r[n]=s:typeof i=="object"&&typeof s=="object"?r[n]=nt(s,i):r[n]=n in t?s:i}return r};var $t=t=>{let e="";return t>=3600&&(e+=Math.floor(t/3600)+"h",t=t%3600),t>=60&&(e+=Math.floor(t/60)+"m",t=t%60),t>0&&(e+=Math.floor(t)+"s"),e};function z(t,e=0,r){let n,i,s,l,o,u,b=0,c=!1,d=!1,E=!0,R=!e&&e!==0&&typeof window.requestAnimationFrame=="function";r&&(c=!!r.leading,d="maxWait"in r,s=r!=null&&r.maxWait?Math.max(+(r==null?void 0:r.maxWait)||0,e):s,E="trailing"in r?!!r.trailing:E);function S(p){let v=n,h=i;return n=i=void 0,b=p,l=t.apply(h,v),l}function C(p,v){return R?(o&&window.cancelAnimationFrame(o),window.requestAnimationFrame(p)):setTimeout(p,v)}function ve(p){if(R){window.cancelAnimationFrame(p);return}clearTimeout(p)}function Ie(p){return b=p,o=C(k,e),c?S(p):l}function xe(p){let v=p-u,h=p-b,ee=e-v;return d?Math.min(ee,s-h):ee}function J(p){let v=p-u,h=p-b;return u===void 0||v>=e||v<0||d&&h>=s}function k(){let p=Date.now();if(J(p))return Z(p);o=C(k,xe(p))}function Z(p){return o=void 0,E&&n?S(p):(n=i=void 0,l)}function he(){o!==void 0&&ve(o),b=0,n=u=i=o=void 0}function ge(){return o===void 0?l:Z(Date.now())}function ye(){return o!==void 0}function L(...p){let v=Date.now(),h=J(v);if(n=p,i=this,u=v,h){if(o===void 0)return Ie(u);if(d)return o=C(k,e),S(u)}return o===void 0&&(o=C(k,e)),l}return L.cancel=he,L.flush=ge,L.pending=ye,L}var j=(t,e=0,r)=>z(t,e,{...{leading:!0,trailing:!0},...r,maxWait:e});var P=(t,e)=>{if(t===null||typeof t!="object")return t;let r=Array.isArray(t)?[]:{};for(let n in t){if(typeof e=="function"){let i=e(t[n],n,t,r);if(i!==void 0){r[n]=i;continue}}typeof t[n]=="object"?r[n]=P(t[n],e):r[n]=t[n]}return r};var ot=t=>P(t);var it=300,st=(t,e=it)=>new a(r=>{let{width:n,height:i}=t.getBoundingClientRect();if(r.next({width:n,height:i}),!window.ResizeObserver)return;let s=new ResizeObserver(j(l=>{let o=l[0];if(!o)return;let u,b;o.contentBoxSize&&o.contentBoxSize[0]?(b=o.contentBoxSize[0].blockSize,u=o.contentBoxSize[0].inlineSize):o.contentRect&&(u=o.contentRect.width,b=o.contentRect.height),O(u)&&O(b)&&r.next({width:u,height:b})},e));return s.observe(t),()=>s.disconnect()});var at=t=>{t.removeAttribute("src"),t.load()};var M=class extends x{constructor(r){super();this.value=r}next(r){super.next(this.value=r)}error(r){super.error(this.value=r)}getValue(){return this.value}_subscribe(r){let n=super._subscribe(r);return r.next(this.value),n}};function ie(t){return new a(e=>{let r={},n=Object.keys(t).length,i=s=>l=>{s in r||n--,r[s]=l,n===0&&e.next(r)};return Object.entries(t).reduce((s,[l,o])=>s.add(o.subscribe(i(l))),new m)})}function se(...t){return new a(e=>t.reduce((r,n)=>r.add(n.subscribe(e)),new m))}var lt=t=>new a(e=>{let r=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},t);return()=>window.clearTimeout(r)});var ut=t=>new a(e=>{let r=window.setInterval(()=>e.next(),t);return()=>{r&&(window.clearInterval(r),r=void 0)}});var ct=t=>new a(e=>{t.forEach(r=>e.next(r))});var pt=(t,e)=>new a(r=>{let n=i=>r.next(i);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)});function ae(t){return e=>new a(r=>e.subscribe(new W(r,t)))}var W=class{constructor(e,r){this.destination=e;this.size=r;this.lastValues=[]}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};var bt={leading:!1,trailing:!0};function le(t,e=bt){return r=>new a(n=>r.subscribe(new G(n,t,e)))}var G=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,O(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(r){if(this.destination.error)this.destination.error(r);else throw r}this.timeout=void 0},this.time)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};var dt={leading:!0,trailing:!1};function ue(t,e=dt){return r=>new a(n=>r.subscribe(new q(n,t,e)))}var q=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,Q(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function ce(t){return e=>new a(r=>e.subscribe(new H(r,t)))}var H=class{constructor(e,r){this.destination=e;this.predicate=r}next(e){let r;try{r=this.predicate(e)}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function be(t=(e,r)=>e===r){return e=>new a(r=>e.subscribe(new K(r,t)))}var pe={},K=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=pe}next(e){let r;try{r=this.lastValue===pe||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function N(t){return e=>new a(r=>e.subscribe(new $(r,t)))}var $=class{constructor(e,r){this.destination=e;this.mapper=r}next(e){let r;try{r=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(r)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function de(t){return N(()=>t)}function fe(){return t=>new a(e=>{let r=!1,n=!1,i=t.subscribe(s=>{r||(r=!0,e.next(s)),n&&i.unsubscribe()},s=>{var l;r=!0,(l=e.error)==null||l.call(e,s),n&&i.unsubscribe()});return n=!0,r&&i.unsubscribe(),i})}function me(){return t=>new a(e=>t.subscribe(new Y(e)))}var Y=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let r=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([r,e])}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function Te(t){return e=>new a(r=>e.subscribe(new X(r,t)))}var X=class{constructor(e,r){this.destination=e;this.effect=r}next(e){try{this.effect(e)}catch(r){throw this.error(r),r}this.destination.next(e)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};var ft=(o=>(o.NETWORK="network",o.VIDEO_PIPELINE="video_pipeline",o.EXTERNAL_API="external_api",o.PARSER="parser",o.DOM="dom",o.WTF="wtf",o.FATAL="fatal",o))(ft||{});var mt=(d=>(d.Armenian="58",d.Azerbaijani="57",d.Belarusian="114",d.English="3",d.Kazakh="97",d.Portuguese="73",d.Russian="0",d.Spanish="4",d.Ukrainian="1",d.Uzbek="65",d.Vietnamese="75",d))(mt||{}),Tt="vk.com",Fn=async(t,e,r)=>{let n=new URL(`https://${Tt}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),t!==void 0&&n.searchParams.set("lang",t);let s=await(await fetch(n.toString())).json();return vt(s,r)},vt=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,n])=>[r.substring(`${e}_`.length),It(n)])),It=t=>Array.isArray(t)?t[0]:t;var xt=(r=>(r.RU="ru",r.EN="en",r))(xt||{});export{re as CurrentClientBrowser,ne as CurrentClientDevice,ft as ErrorCategory,xt as InterfaceLanguage,V as Logger,a as Observable,x as Subject,m as Subscription,Ee as VERSION,mt as VKNumericLanguage,M as ValueSubject,U as VideoQuality,Me as abortable,Le as addScript,tt as areQualitiesExact,ke as assertEmptyArray,I as assertNever,Ae as assertNonNullable,Ce as assertNotEmptyArray,Re as assertNullable,rt as assertQualityIsExact,ae as buffer,Se as checkNever,at as clearVideoElement,ot as cloneDeep,P as cloneDeepWith,ie as combine,le as debounce,z as debounceFn,He as detectEmbed,nt as fillWithDefault,ce as filter,be as filterChanged,pt as fromEvent,A as getCurrentBrowser,Fe as getExponentialDelay,Xe as getHighestQuality,Ve as getIOSVersion,ut as interval,De as isAndroid,Ke as isHigher,$e as isHigherOrEqual,Ne as isIOS,B as isInvariantQuality,F as isLower,Ye as isLowerOrEqual,_e as isMacLike,Ue as isMobile,O as isNonNullable,Q as isNullable,Fn as loadVKLangPack,N as map,de as mapTo,se as merge,g as noop,Pe as now,ct as observableFrom,st as observeElementSize,fe as once,me as pairwise,_ as safeStorage,Te as tap,ue as throttle,j as throttleFn,$t as timeCodeToString,lt as timeout,Je as videoHeightToQuality,et as videoQualityToHeight,Ze as videoSizeToQuality};
|
package/esnext.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-shared v1.0.38-dev.
|
|
3
|
-
*
|
|
2
|
+
* @vkontakte/videoplayer-shared v1.0.38-dev.df616f9c.0
|
|
3
|
+
* Fri, 16 Aug 2024 08:31:38 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-38/doc/
|
|
5
5
|
*/
|
|
6
|
-
"use strict";var B=Object.defineProperty;var et=Object.getOwnPropertyDescriptor;var tt=Object.getOwnPropertyNames;var rt=Object.prototype.hasOwnProperty;var de=(t,e)=>{for(var r in e)B(t,r,{get:e[r],enumerable:!0})},nt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of tt(e))!rt.call(t,i)&&i!==r&&B(t,i,{get:()=>e[i],enumerable:!(n=et(e,i))||n.enumerable});return t};var it=t=>nt(B({},"__esModule",{value:!0}),t);var It={};de(It,{CC:()=>Oe,ErrorCategory:()=>Ge,InterfaceLanguage:()=>qe,Logger:()=>k,Observable:()=>l,Subject:()=>h,Subscription:()=>f,VERSION:()=>fe,VKNumericLanguage:()=>He,ValueSubject:()=>S,VideoQuality:()=>V,abortable:()=>ye,addScript:()=>ge,areQualitiesExact:()=>Me,assertEmptyArray:()=>Ie,assertNever:()=>v,assertNonNullable:()=>Te,assertNotEmptyArray:()=>he,assertNullable:()=>ve,assertQualityIsExact:()=>Ne,buffer:()=>q,checkNever:()=>me,clearVideoElement:()=>Ue,cloneDeep:()=>Qe,cloneDeepWith:()=>E,combine:()=>W,debounce:()=>Y,debounceFn:()=>_,detectEmbed:()=>Ee,fillWithDefault:()=>_e,filter:()=>Z,filterChanged:()=>te,fromEvent:()=>je,getExponentialDelay:()=>we,getHighestQuality:()=>Ce,interval:()=>Fe,isHigher:()=>Se,isHigherOrEqual:()=>Re,isInvariantQuality:()=>N,isLower:()=>M,isLowerOrEqual:()=>Ae,isNonNullable:()=>x,isNullable:()=>L,loadVKLangPack:()=>Tt,map:()=>R,mapTo:()=>ne,merge:()=>G,noop:()=>I,now:()=>xe,observableFrom:()=>ze,observeElementSize:()=>De,once:()=>ie,pairwise:()=>se,safeStorage:()=>j,tap:()=>le,throttle:()=>X,throttleFn:()=>Q,timeCodeToString:()=>pt,timeout:()=>Be,videoHeightToQuality:()=>ke,videoQualityToHeight:()=>Ve,videoSizeToQuality:()=>Le});module.exports=it(It);var fe="1.0.38-dev.c2293902.0";var f=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(r=>typeof r=="function"?r():r.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var v=t=>{throw new Error(`${t} is value of unexpected type`)},me=t=>{};var I=()=>{};var l=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,r){let n;r?typeof r=="function"?n={next:r,error:I}:n={next:o=>r.next(o),error:o=>r.error?.(o)}:n={next:I,error:I};let i=typeof e=="function"?{next:o=>{try{e(o)}catch(a){n.next(a)}},error:o=>n.next(o)}:{next:o=>e.next(o),error:o=>e.error?e.error(o):n.next(o)},s;try{s=this._subscribe(i)}catch(o){i.error?.(o)}return new f().add(()=>{switch(i.next=I,i.error=I,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return v(s)}})}pipe(...e){return e.reduce((r,n)=>n(r),this)}_subscribe(e){}};var h=class extends l{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(r){this.subscribers.forEach(n=>n.next(r))}error(r){this.subscribers.forEach(n=>n.error?.(r))}_subscribe(r){let n=this.keyCounter++;return this.subscribers.set(n,r),new f().add(()=>this.subscribers.delete(n))}};var k=class{constructor(){this.log$=new h;this.logs=[];this.log=e=>{let r={...e,timestamp:Date.now()};this.logs.push(r),this.log$.next(r)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...r)=>{let n;try{n=e(...r)}catch{n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(r=>({component:e,...r}))}};function Te(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function ve(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function x(t){return typeof t<"u"&&t!==null}function L(t){return t==null}function he(t,e){if(!t?.length)throw new Error(e)}function Ie(t,e){if(t?.length)throw new Error(e)}var ge=(t,e,r)=>new Promise((n,i)=>{e.addEventListener("abort",()=>{a(),c.remove()});let s=()=>{a(),i()},o=()=>{a(),n()},a=()=>{p&&clearTimeout(p),c.removeEventListener("load",o),c.removeEventListener("error",s)},p;r&&(p=window.setTimeout(s,r));let c=document.createElement("script");c.addEventListener("load",o),c.addEventListener("error",s),c.src=t,document.head.appendChild(c)});var xe=typeof window.performance?.now=="function"?()=>window.performance.now():()=>Date.now();var ye=(t,e)=>async(...r)=>{let n=e(...r),i=t.aborted,s;for(;!i&&!t.aborted;)try{let o=await n.next(s);i=o.done??!1,s=o.value}catch(o){await n.throw(o)}return s};var F=class{constructor(){this.detect()}get browser(){return this._currentBrowser}get device(){return this._currentDevice}get isTouch(){return this._maxTouchPoints>0}get isIOS(){return["iPhone","iPad","iPod"].includes(this.device)}get isMac(){return this.device==="Mac"}get isApple(){return this.isIOS||this.isMac}get isIphoneOrOldIpad(){if(!this.isApple||!this.isTouch)return!1;let e=this.device==="iPad"||window?.screen.width>700,r=this._iosVersion;return!e||e&&!!r&&r<16}get isAndroid(){return this.device==="Android"}get isMobile(){return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(navigator.appVersion??navigator.userAgent)||navigator?.userAgentData?.mobile}get iOSVersion(){return this._iosVersion}get macVersion(){return this._macVersion}get isYandex(){return this.browser==="Yandex"}get isSafari(){return this.browser==="Safari"}get isSamsungBrowser(){return this.browser==="SamsungBrowser"}get isHDR(){return this._isHdr}detect(){let{userAgent:e,maxTouchPoints:r}=navigator;try{this._maxTouchPoints=r,this._isHdr=!!matchMedia("(dynamic-range: high)")?.matches}catch(n){console.error(n)}this.detectBrowser(e),this.detectDevice(e),this.isIOS&&this.detectIOSVersion(),this.isMac&&this.detectMacVersion()}detectBrowser(e){try{let r=/yabrowser/i.test(e)?"Yandex":void 0,n=/samsungbrowser/i.test(e)?"SamsungBrowser":void 0,i=/chrome|crios/i.test(e)?"Chrome":void 0,s=/chromium/i.test(e)?"Chromium":void 0,o=/firefox|fxios/i.test(e)?"Firefox":void 0,a=/webkit|safari|khtml/i.test(e)?"Safari":void 0,p=/opr\//i.test(e)?"Opera":void 0,c=/edg/i.test(e)?"Edge":void 0;this._currentBrowser=r||n||o||p||c||i||s||a||"Rest"}catch(r){console.error(r)}}detectDevice(e){try{let r=/android/i.test(e)?"Android":void 0,n=/iphone/i.test(e)?"iPhone":void 0,i=/ipad/i.test(e)?"iPad":void 0,s=/ipod/i.test(e)?"iPod":void 0,o=/mac/i.test(e)?"Mac":void 0,a=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(e)?"RestMobile":void 0;this._currentDevice=r||n||i||s||a||o||"Desktop"}catch(r){console.error(r)}}detectIOSVersion(){try{let{userAgent:e}=window.navigator,r=e.match(/Version\/(\d+(\.\d+)?)/i);if(!r)return;let n=r[1],i=parseFloat(n);if(isNaN(i))return;this._iosVersion=i}catch(e){console.error(e)}}detectMacVersion(){try{let{userAgent:e}=window.navigator,r=e.match(/Version\/(\d+)/);if(!r)return;let n=r[1],i=parseInt(n,10);if(isNaN(i))return;this._macVersion=i}catch(e){console.error(e)}}},Oe=new F;var we=(t,{start:e=0,factor:r=2,max:n=1/0,min:i=e,random:s=0}={})=>{let o=e;return o*=r**t,o*=1+(Math.random()*s*2-s),o=Math.round(o),o=Math.min(o,n),o=Math.max(o,i),o};var j={};de(j,{clear:()=>ct,get:()=>st,has:()=>lt,isPersistent:()=>ot,remove:()=>ut,set:()=>at});var O,y,z=`vk-videoplayer-dummy-key-${Math.random()}`,w=()=>{if(y!==void 0)return y;try{localStorage.setItem(z,"test"),localStorage.removeItem(z),y=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem(z),y=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)y=2;else throw e}else throw t}return y===2&&(O=new Map),y},ot=()=>w()===0,st=t=>{let e=w();switch(e){case 0:return localStorage.getItem(t)??void 0;case 1:return sessionStorage.getItem(t)??void 0;case 2:return O?.get(t);default:v(e)}},at=(t,e)=>{let r=w();switch(r){case 0:try{localStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void O?.set(t,e);default:v(r)}},lt=t=>{let e=w();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return O?.has(t)??!1;default:return v(e),!1}},ut=t=>{let e=w();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:return void O?.delete(t);default:v(e)}},ct=()=>{let t=w();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return O?.clear();default:v(t)}};var Ee=()=>{let t,e;try{t=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?t=!0:(t=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let r=e?new URL(e).hostname:void 0;return{isEmbed:t,host:r}};var V=(d=>(d.INVARIANT="Invariant quality",d.Q_144P="144p",d.Q_240P="240p",d.Q_360P="360p",d.Q_480P="480p",d.Q_720P="720p",d.Q_1080P="1080p",d.Q_1440P="1440p",d.Q_2160P="2160p",d.Q_4320P="4320p",d))(V||{});var m={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"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=(t,e)=>m[t].height>m[e].height,Re=(t,e)=>m[t].height>=m[e].height,M=(t,e)=>m[t].height<m[e].height,Ae=(t,e)=>m[t].height<=m[e].height,Ce=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:M(e,r)?1:-1)[0],Pe=Object.keys(m).sort((t,e)=>M(t,e)?-1:1),ke=(t,e=.02)=>[...Pe].find(n=>m[n].height*(1+e)>=t),Le=({width:t,height:e})=>{let r=Math.min(t,e),n=Math.max(t,e);return Pe.find(i=>{let s=m[i];return s.width>=n&&s.height>=r})},Ve=t=>m[t].height,N=t=>t==="Invariant quality",Me=t=>t.every(e=>!N(e));function Ne(t){if(N(t))throw new Error("Expected exact quality")}var _e=(t,e)=>{let r={};for(let n of Object.keys(e)){let i=e[n],s=t[n];Array.isArray(i)&&Array.isArray(s)?r[n]=s:typeof i=="object"&&typeof s=="object"?r[n]=_e(s,i):r[n]=n in t?s:i}return r};var pt=t=>{let e="";return t>=3600&&(e+=Math.floor(t/3600)+"h",t=t%3600),t>=60&&(e+=Math.floor(t/60)+"m",t=t%60),t>0&&(e+=Math.floor(t)+"s"),e};function _(t,e=0,r){let n,i,s,o,a,p,c=0,d=!1,b=!1,D=!0,ue=!e&&e!==0&&typeof window.requestAnimationFrame=="function";r&&(d=!!r.leading,b="maxWait"in r,s=r?.maxWait?Math.max(+r?.maxWait||0,e):s,D="trailing"in r?!!r.trailing:D);function U(u){let T=n,g=i;return n=i=void 0,c=u,o=t.apply(g,T),o}function A(u,T){return ue?(a&&window.cancelAnimationFrame(a),window.requestAnimationFrame(u)):setTimeout(u,T)}function Ke(u){if(ue){window.cancelAnimationFrame(u);return}clearTimeout(u)}function Ye(u){return c=u,a=A(C,e),d?U(u):o}function $e(u){let T=u-p,g=u-c,be=e-T;return b?Math.min(be,s-g):be}function ce(u){let T=u-p,g=u-c;return p===void 0||T>=e||T<0||b&&g>=s}function C(){let u=Date.now();if(ce(u))return pe(u);a=A(C,$e(u))}function pe(u){return a=void 0,D&&n?U(u):(n=i=void 0,o)}function Xe(){a!==void 0&&Ke(a),c=0,n=p=i=a=void 0}function Je(){return a===void 0?o:pe(Date.now())}function Ze(){return a!==void 0}function P(...u){let T=Date.now(),g=ce(T);if(n=u,i=this,p=T,g){if(a===void 0)return Ye(p);if(b)return a=A(C,e),U(p)}return a===void 0&&(a=A(C,e)),o}return P.cancel=Xe,P.flush=Je,P.pending=Ze,P}var Q=(t,e=0,r)=>_(t,e,{...{leading:!0,trailing:!0},...r,maxWait:e});var E=(t,e)=>{if(t===null||typeof t!="object")return t;let r=Array.isArray(t)?[]:{};for(let n in t){if(typeof e=="function"){let i=e(t[n],n,t,r);if(i!==void 0){r[n]=i;continue}}typeof t[n]=="object"?r[n]=E(t[n],e):r[n]=t[n]}return r};var Qe=t=>E(t);var bt=300,De=(t,e=bt)=>new l(r=>{let{width:n,height:i}=t.getBoundingClientRect();if(r.next({width:n,height:i}),!window.ResizeObserver)return;let s=new ResizeObserver(Q(o=>{let a=o[0];if(!a)return;let p,c;a.contentBoxSize&&a.contentBoxSize[0]?(c=a.contentBoxSize[0].blockSize,p=a.contentBoxSize[0].inlineSize):a.contentRect&&(p=a.contentRect.width,c=a.contentRect.height),x(p)&&x(c)&&r.next({width:p,height:c})},e));return s.observe(t),()=>s.disconnect()});var Ue=t=>{t.removeAttribute("src"),t.load()};var S=class extends h{constructor(r){super();this.value=r}next(r){super.next(this.value=r)}error(r){super.error(this.value=r)}getValue(){return this.value}_subscribe(r){let n=super._subscribe(r);return r.next(this.value),n}};function W(t){return new l(e=>{let r={},n=Object.keys(t).length,i=s=>o=>{s in r||n--,r[s]=o,n===0&&e.next(r)};return Object.entries(t).reduce((s,[o,a])=>s.add(a.subscribe(i(o))),new f)})}function G(...t){return new l(e=>t.reduce((r,n)=>r.add(n.subscribe(e)),new f))}var Be=t=>new l(e=>{let r=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},t);return()=>window.clearTimeout(r)});var Fe=t=>new l(e=>{let r=window.setInterval(()=>e.next(),t);return()=>{r&&(window.clearInterval(r),r=void 0)}});var ze=t=>new l(e=>{t.forEach(r=>e.next(r))});var je=(t,e)=>new l(r=>{let n=i=>r.next(i);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)});function q(t){return e=>new l(r=>e.subscribe(new H(r,t)))}var H=class{constructor(e,r){this.destination=e;this.size=r;this.lastValues=[]}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 dt={leading:!1,trailing:!0};function Y(t,e=dt){return r=>new l(n=>r.subscribe(new K(n,t,e)))}var K=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,x(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(r){if(this.destination.error)this.destination.error(r);else throw r}this.timeout=void 0},this.time)}error(e){this.destination.error?.(e)}};var ft={leading:!0,trailing:!1};function X(t,e=ft){return r=>new l(n=>r.subscribe(new $(n,t,e)))}var $=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,L(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){this.destination.error?.(e)}};function Z(t){return e=>new l(r=>e.subscribe(new J(r,t)))}var J=class{constructor(e,r){this.destination=e;this.predicate=r}next(e){let r;try{r=this.predicate(e)}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function te(t=(e,r)=>e===r){return e=>new l(r=>e.subscribe(new ee(r,t)))}var We={},ee=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=We}next(e){let r;try{r=this.lastValue===We||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function R(t){return e=>new l(r=>e.subscribe(new re(r,t)))}var re=class{constructor(e,r){this.destination=e;this.mapper=r}next(e){let r;try{r=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(r)}error(e){this.destination.error?.(e)}};function ne(t){return R(()=>t)}function ie(){return t=>new l(e=>{let r=!1,n=!1,i=t.subscribe(s=>{r||(r=!0,e.next(s)),n&&i.unsubscribe()},s=>{r=!0,e.error?.(s),n&&i.unsubscribe()});return n=!0,r&&i.unsubscribe(),i})}function se(){return t=>new l(e=>t.subscribe(new oe(e)))}var oe=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let r=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([r,e])}error(e){this.destination.error?.(e)}};function le(t){return e=>new l(r=>e.subscribe(new ae(r,t)))}var ae=class{constructor(e,r){this.destination=e;this.effect=r}next(e){try{this.effect(e)}catch(r){throw this.error(r),r}this.destination.next(e)}error(e){this.destination.error?.(e)}};var Ge=(a=>(a.NETWORK="network",a.VIDEO_PIPELINE="video_pipeline",a.EXTERNAL_API="external_api",a.PARSER="parser",a.DOM="dom",a.WTF="wtf",a.FATAL="fatal",a))(Ge||{});var He=(b=>(b.Armenian="58",b.Azerbaijani="57",b.Belarusian="114",b.English="3",b.Kazakh="97",b.Portuguese="73",b.Russian="0",b.Spanish="4",b.Ukrainian="1",b.Uzbek="65",b.Vietnamese="75",b))(He||{}),mt="vk.com",Tt=async(t,e,r)=>{let n=new URL(`https://${mt}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),t!==void 0&&n.searchParams.set("lang",t);let s=await(await fetch(n.toString())).json();return vt(s,r)},vt=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,n])=>[r.substring(`${e}_`.length),ht(n)])),ht=t=>Array.isArray(t)?t[0]:t;var qe=(r=>(r.RU="ru",r.EN="en",r))(qe||{});
|
|
6
|
+
"use strict";var z=Object.defineProperty;var st=Object.getOwnPropertyDescriptor;var at=Object.getOwnPropertyNames;var lt=Object.prototype.hasOwnProperty;var me=(t,e)=>{for(var r in e)z(t,r,{get:e[r],enumerable:!0})},ut=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of at(e))!lt.call(t,o)&&o!==r&&z(t,o,{get:()=>e[o],enumerable:!(n=st(e,o))||n.enumerable});return t};var ct=t=>ut(z({},"__esModule",{value:!0}),t);var St={};me(St,{CurrentClientBrowser:()=>j,CurrentClientDevice:()=>W,ErrorCategory:()=>Xe,InterfaceLanguage:()=>Ze,Logger:()=>V,Observable:()=>l,Subject:()=>I,Subscription:()=>f,VERSION:()=>Te,VKNumericLanguage:()=>Je,ValueSubject:()=>C,VideoQuality:()=>D,abortable:()=>we,addScript:()=>ye,areQualitiesExact:()=>Fe,assertEmptyArray:()=>he,assertNever:()=>v,assertNonNullable:()=>Ie,assertNotEmptyArray:()=>ge,assertNullable:()=>xe,assertQualityIsExact:()=>Be,buffer:()=>Y,checkNever:()=>ve,clearVideoElement:()=>Ge,cloneDeep:()=>je,cloneDeepWith:()=>R,combine:()=>H,debounce:()=>J,debounceFn:()=>F,detectEmbed:()=>Le,fillWithDefault:()=>ze,filter:()=>re,filterChanged:()=>oe,fromEvent:()=>$e,getCurrentBrowser:()=>O,getExponentialDelay:()=>ke,getHighestQuality:()=>Ve,getIOSVersion:()=>Se,interval:()=>He,isAndroid:()=>Ae,isHigher:()=>Pe,isHigherOrEqual:()=>Me,isIOS:()=>Ee,isInvariantQuality:()=>U,isLower:()=>_,isLowerOrEqual:()=>Ne,isMacLike:()=>Re,isMobile:()=>Ce,isNonNullable:()=>h,isNullable:()=>Q,loadVKLangPack:()=>Ot,map:()=>k,mapTo:()=>se,merge:()=>K,noop:()=>x,now:()=>Oe,observableFrom:()=>Ke,observeElementSize:()=>We,once:()=>ae,pairwise:()=>ue,safeStorage:()=>q,tap:()=>pe,throttle:()=>ee,throttleFn:()=>B,timeCodeToString:()=>It,timeout:()=>qe,videoHeightToQuality:()=>De,videoQualityToHeight:()=>Ue,videoSizeToQuality:()=>_e});module.exports=ct(St);var Te="1.0.38-dev.df616f9c.0";var f=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(r=>typeof r=="function"?r():r.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var v=t=>{throw new Error(`${t} is value of unexpected type`)},ve=t=>{};var x=()=>{};var l=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,r){let n;r?typeof r=="function"?n={next:r,error:x}:n={next:i=>r.next(i),error:i=>r.error?.(i)}:n={next:x,error:x};let o=typeof e=="function"?{next:i=>{try{e(i)}catch(a){n.next(a)}},error:i=>n.next(i)}:{next:i=>e.next(i),error:i=>e.error?e.error(i):n.next(i)},s;try{s=this._subscribe(o)}catch(i){o.error?.(i)}return new f().add(()=>{switch(o.next=x,o.error=x,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return v(s)}})}pipe(...e){return e.reduce((r,n)=>n(r),this)}_subscribe(e){}};var I=class extends l{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(r){this.subscribers.forEach(n=>n.next(r))}error(r){this.subscribers.forEach(n=>n.error?.(r))}_subscribe(r){let n=this.keyCounter++;return this.subscribers.set(n,r),new f().add(()=>this.subscribers.delete(n))}};var V=class{constructor(){this.log$=new I;this.logs=[];this.log=e=>{let r={...e,timestamp:Date.now()};this.logs.push(r),this.log$.next(r)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...r)=>{let n;try{n=e(...r)}catch{n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(r=>({component:e,...r}))}};function Ie(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function xe(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function h(t){return typeof t<"u"&&t!==null}function Q(t){return t==null}function ge(t,e){if(!t?.length)throw new Error(e)}function he(t,e){if(t?.length)throw new Error(e)}var ye=(t,e,r)=>new Promise((n,o)=>{e.addEventListener("abort",()=>{a(),b.remove()});let s=()=>{a(),o()},i=()=>{a(),n()},a=()=>{u&&clearTimeout(u),b.removeEventListener("load",i),b.removeEventListener("error",s)},u;r&&(u=window.setTimeout(s,r));let b=document.createElement("script");b.addEventListener("load",i),b.addEventListener("error",s),b.src=t,document.head.appendChild(b)});var Oe=typeof window.performance?.now=="function"?()=>window.performance.now():()=>Date.now();var we=(t,e)=>async(...r)=>{let n=e(...r),o=t.aborted,s;for(;!o&&!t.aborted;)try{let i=await n.next(s);o=i.done??!1,s=i.value}catch(i){await n.throw(i)}return s};var j=(c=>(c.Unknown="Unknown",c.Yandex="Yandex",c.Chrome="Chrome",c.Chromium="Chromium",c.Firefox="Firefox",c.Safari="Safari",c.Opera="Opera",c.Edge="Edge",c.SamsungBrowser="SamsungBrowser",c.Rest="Rest",c))(j||{}),W=(u=>(u.Unknown="Unknown",u.Android="Android",u.iPhone="iPhone",u.iPad="iPad",u.iPod="iPod",u.RestMobile="RestMobile",u.Mac="Mac",u.Desktop="Desktop",u))(W||{}),O=()=>{let{userAgent:t}=window.navigator,e=/yabrowser/i.test(t)?"Yandex":void 0,r=/samsungbrowser/i.test(t)?"SamsungBrowser":void 0,n=/chrome|crios/i.test(t)?"Chrome":void 0,o=/chromium/i.test(t)?"Chromium":void 0,s=/firefox|fxios/i.test(t)?"Firefox":void 0,i=/webkit|safari|khtml/i.test(t)?"Safari":void 0,a=/opr\//i.test(t)?"Opera":void 0,u=/edg/i.test(t)?"Edge":void 0,b=/android/i.test(t)?"Android":void 0,c=/iphone/i.test(t)?"iPhone":void 0,d=/ipad/i.test(t)?"iPad":void 0,S=/ipod/i.test(t)?"iPod":void 0,L=/mac/i.test(t)?"Mac":void 0,A=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(t)?"RestMobile":void 0;return{browser:e||r||s||a||u||n||o||i||"Rest",device:b||c||d||S||A||L||"Desktop"}},Ee=(t=!1)=>{let r=["iPhone","iPad","iPod"].includes(O().device);if(!t)return r;let{userAgent:n,maxTouchPoints:o}=window.navigator;return!!(r||/macintosh/i.test(n)&&o>0)},Se=()=>{let{userAgent:t}=window.navigator,e=t.match(/Version\/(\d+(\.\d+)?)/i);if(!e)return null;let r=e[1],n=parseFloat(r);return isNaN(n)?null:n},pt=()=>{let{device:t}=O(),{userAgent:e,maxTouchPoints:r}=window.navigator,n=/linux/i.test(e),o=r>0;return t==="Desktop"&&n&&o},Ae=()=>O().device==="Android"||pt(),Re=()=>["Mac","iPhone","iPad","iPod"].includes(O().device),Ce=()=>/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(navigator.appVersion??navigator.userAgent)||navigator?.userAgentData?.mobile;var ke=(t,{start:e=0,factor:r=2,max:n=1/0,min:o=e,random:s=0}={})=>{let i=e;return i*=r**t,i*=1+(Math.random()*s*2-s),i=Math.round(i),i=Math.min(i,n),i=Math.max(i,o),i};var q={};me(q,{clear:()=>vt,get:()=>dt,has:()=>mt,isPersistent:()=>bt,remove:()=>Tt,set:()=>ft});var w,y,G=`vk-videoplayer-dummy-key-${Math.random()}`,E=()=>{if(y!==void 0)return y;try{localStorage.setItem(G,"test"),localStorage.removeItem(G),y=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem(G),y=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)y=2;else throw e}else throw t}return y===2&&(w=new Map),y},bt=()=>E()===0,dt=t=>{let e=E();switch(e){case 0:return localStorage.getItem(t)??void 0;case 1:return sessionStorage.getItem(t)??void 0;case 2:return w?.get(t);default:v(e)}},ft=(t,e)=>{let r=E();switch(r){case 0:try{localStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void w?.set(t,e);default:v(r)}},mt=t=>{let e=E();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return w?.has(t)??!1;default:return v(e),!1}},Tt=t=>{let e=E();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:return void w?.delete(t);default:v(e)}},vt=()=>{let t=E();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return w?.clear();default:v(t)}};var Le=()=>{let t,e;try{t=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?t=!0:(t=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let r=e?new URL(e).hostname:void 0;return{isEmbed:t,host:r}};var D=(c=>(c.INVARIANT="Invariant quality",c.Q_144P="144p",c.Q_240P="240p",c.Q_360P="360p",c.Q_480P="480p",c.Q_720P="720p",c.Q_1080P="1080p",c.Q_1440P="1440p",c.Q_2160P="2160p",c.Q_4320P="4320p",c))(D||{});var m={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"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}},Pe=(t,e)=>m[t].height>m[e].height,Me=(t,e)=>m[t].height>=m[e].height,_=(t,e)=>m[t].height<m[e].height,Ne=(t,e)=>m[t].height<=m[e].height,Ve=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:_(e,r)?1:-1)[0],Qe=Object.keys(m).sort((t,e)=>_(t,e)?-1:1),De=(t,e=.02)=>[...Qe].find(n=>m[n].height*(1+e)>=t),_e=({width:t,height:e})=>{let r=Math.min(t,e),n=Math.max(t,e);return Qe.find(o=>{let s=m[o];return s.width>=n&&s.height>=r})},Ue=t=>m[t].height,U=t=>t==="Invariant quality",Fe=t=>t.every(e=>!U(e));function Be(t){if(U(t))throw new Error("Expected exact quality")}var ze=(t,e)=>{let r={};for(let n of Object.keys(e)){let o=e[n],s=t[n];Array.isArray(o)&&Array.isArray(s)?r[n]=s:typeof o=="object"&&typeof s=="object"?r[n]=ze(s,o):r[n]=n in t?s:o}return r};var It=t=>{let e="";return t>=3600&&(e+=Math.floor(t/3600)+"h",t=t%3600),t>=60&&(e+=Math.floor(t/60)+"m",t=t%60),t>0&&(e+=Math.floor(t)+"s"),e};function F(t,e=0,r){let n,o,s,i,a,u,b=0,c=!1,d=!1,S=!0,L=!e&&e!==0&&typeof window.requestAnimationFrame=="function";r&&(c=!!r.leading,d="maxWait"in r,s=r?.maxWait?Math.max(+r?.maxWait||0,e):s,S="trailing"in r?!!r.trailing:S);function A(p){let T=n,g=o;return n=o=void 0,b=p,i=t.apply(g,T),i}function P(p,T){return L?(a&&window.cancelAnimationFrame(a),window.requestAnimationFrame(p)):setTimeout(p,T)}function et(p){if(L){window.cancelAnimationFrame(p);return}clearTimeout(p)}function tt(p){return b=p,a=P(M,e),c?A(p):i}function rt(p){let T=p-u,g=p-b,fe=e-T;return d?Math.min(fe,s-g):fe}function be(p){let T=p-u,g=p-b;return u===void 0||T>=e||T<0||d&&g>=s}function M(){let p=Date.now();if(be(p))return de(p);a=P(M,rt(p))}function de(p){return a=void 0,S&&n?A(p):(n=o=void 0,i)}function nt(){a!==void 0&&et(a),b=0,n=u=o=a=void 0}function ot(){return a===void 0?i:de(Date.now())}function it(){return a!==void 0}function N(...p){let T=Date.now(),g=be(T);if(n=p,o=this,u=T,g){if(a===void 0)return tt(u);if(d)return a=P(M,e),A(u)}return a===void 0&&(a=P(M,e)),i}return N.cancel=nt,N.flush=ot,N.pending=it,N}var B=(t,e=0,r)=>F(t,e,{...{leading:!0,trailing:!0},...r,maxWait:e});var R=(t,e)=>{if(t===null||typeof t!="object")return t;let r=Array.isArray(t)?[]:{};for(let n in t){if(typeof e=="function"){let o=e(t[n],n,t,r);if(o!==void 0){r[n]=o;continue}}typeof t[n]=="object"?r[n]=R(t[n],e):r[n]=t[n]}return r};var je=t=>R(t);var xt=300,We=(t,e=xt)=>new l(r=>{let{width:n,height:o}=t.getBoundingClientRect();if(r.next({width:n,height:o}),!window.ResizeObserver)return;let s=new ResizeObserver(B(i=>{let a=i[0];if(!a)return;let u,b;a.contentBoxSize&&a.contentBoxSize[0]?(b=a.contentBoxSize[0].blockSize,u=a.contentBoxSize[0].inlineSize):a.contentRect&&(u=a.contentRect.width,b=a.contentRect.height),h(u)&&h(b)&&r.next({width:u,height:b})},e));return s.observe(t),()=>s.disconnect()});var Ge=t=>{t.removeAttribute("src"),t.load()};var C=class extends I{constructor(r){super();this.value=r}next(r){super.next(this.value=r)}error(r){super.error(this.value=r)}getValue(){return this.value}_subscribe(r){let n=super._subscribe(r);return r.next(this.value),n}};function H(t){return new l(e=>{let r={},n=Object.keys(t).length,o=s=>i=>{s in r||n--,r[s]=i,n===0&&e.next(r)};return Object.entries(t).reduce((s,[i,a])=>s.add(a.subscribe(o(i))),new f)})}function K(...t){return new l(e=>t.reduce((r,n)=>r.add(n.subscribe(e)),new f))}var qe=t=>new l(e=>{let r=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},t);return()=>window.clearTimeout(r)});var He=t=>new l(e=>{let r=window.setInterval(()=>e.next(),t);return()=>{r&&(window.clearInterval(r),r=void 0)}});var Ke=t=>new l(e=>{t.forEach(r=>e.next(r))});var $e=(t,e)=>new l(r=>{let n=o=>r.next(o);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)});function Y(t){return e=>new l(r=>e.subscribe(new $(r,t)))}var $=class{constructor(e,r){this.destination=e;this.size=r;this.lastValues=[]}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 gt={leading:!1,trailing:!0};function J(t,e=gt){return r=>new l(n=>r.subscribe(new X(n,t,e)))}var X=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,h(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(r){if(this.destination.error)this.destination.error(r);else throw r}this.timeout=void 0},this.time)}error(e){this.destination.error?.(e)}};var ht={leading:!0,trailing:!1};function ee(t,e=ht){return r=>new l(n=>r.subscribe(new Z(n,t,e)))}var Z=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,Q(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){this.destination.error?.(e)}};function re(t){return e=>new l(r=>e.subscribe(new te(r,t)))}var te=class{constructor(e,r){this.destination=e;this.predicate=r}next(e){let r;try{r=this.predicate(e)}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function oe(t=(e,r)=>e===r){return e=>new l(r=>e.subscribe(new ne(r,t)))}var Ye={},ne=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=Ye}next(e){let r;try{r=this.lastValue===Ye||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function k(t){return e=>new l(r=>e.subscribe(new ie(r,t)))}var ie=class{constructor(e,r){this.destination=e;this.mapper=r}next(e){let r;try{r=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(r)}error(e){this.destination.error?.(e)}};function se(t){return k(()=>t)}function ae(){return t=>new l(e=>{let r=!1,n=!1,o=t.subscribe(s=>{r||(r=!0,e.next(s)),n&&o.unsubscribe()},s=>{r=!0,e.error?.(s),n&&o.unsubscribe()});return n=!0,r&&o.unsubscribe(),o})}function ue(){return t=>new l(e=>t.subscribe(new le(e)))}var le=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let r=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([r,e])}error(e){this.destination.error?.(e)}};function pe(t){return e=>new l(r=>e.subscribe(new ce(r,t)))}var ce=class{constructor(e,r){this.destination=e;this.effect=r}next(e){try{this.effect(e)}catch(r){throw this.error(r),r}this.destination.next(e)}error(e){this.destination.error?.(e)}};var Xe=(a=>(a.NETWORK="network",a.VIDEO_PIPELINE="video_pipeline",a.EXTERNAL_API="external_api",a.PARSER="parser",a.DOM="dom",a.WTF="wtf",a.FATAL="fatal",a))(Xe||{});var Je=(d=>(d.Armenian="58",d.Azerbaijani="57",d.Belarusian="114",d.English="3",d.Kazakh="97",d.Portuguese="73",d.Russian="0",d.Spanish="4",d.Ukrainian="1",d.Uzbek="65",d.Vietnamese="75",d))(Je||{}),yt="vk.com",Ot=async(t,e,r)=>{let n=new URL(`https://${yt}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),t!==void 0&&n.searchParams.set("lang",t);let s=await(await fetch(n.toString())).json();return wt(s,r)},wt=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,n])=>[r.substring(`${e}_`.length),Et(n)])),Et=t=>Array.isArray(t)?t[0]:t;var Ze=(r=>(r.RU="ru",r.EN="en",r))(Ze||{});
|
package/esnext.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-shared v1.0.38-dev.
|
|
3
|
-
*
|
|
2
|
+
* @vkontakte/videoplayer-shared v1.0.38-dev.df616f9c.0
|
|
3
|
+
* Fri, 16 Aug 2024 08:31:38 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-38/doc/
|
|
5
5
|
*/
|
|
6
|
-
var ge=Object.defineProperty;var xe=(t,e)=>{for(var r in e)ge(t,r,{get:e[r],enumerable:!0})};var ye="1.0.38-dev.c2293902.0";var f=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(r=>typeof r=="function"?r():r.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var v=t=>{throw new Error(`${t} is value of unexpected type`)},Oe=t=>{};var g=()=>{};var l=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,r){let n;r?typeof r=="function"?n={next:r,error:g}:n={next:o=>r.next(o),error:o=>r.error?.(o)}:n={next:g,error:g};let i=typeof e=="function"?{next:o=>{try{e(o)}catch(a){n.next(a)}},error:o=>n.next(o)}:{next:o=>e.next(o),error:o=>e.error?e.error(o):n.next(o)},s;try{s=this._subscribe(i)}catch(o){i.error?.(o)}return new f().add(()=>{switch(i.next=g,i.error=g,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return v(s)}})}pipe(...e){return e.reduce((r,n)=>n(r),this)}_subscribe(e){}};var h=class extends l{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(r){this.subscribers.forEach(n=>n.next(r))}error(r){this.subscribers.forEach(n=>n.error?.(r))}_subscribe(r){let n=this.keyCounter++;return this.subscribers.set(n,r),new f().add(()=>this.subscribers.delete(n))}};var V=class{constructor(){this.log$=new h;this.logs=[];this.log=e=>{let r={...e,timestamp:Date.now()};this.logs.push(r),this.log$.next(r)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...r)=>{let n;try{n=e(...r)}catch{n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(r=>({component:e,...r}))}};function we(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function Ee(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function y(t){return typeof t<"u"&&t!==null}function M(t){return t==null}function Se(t,e){if(!t?.length)throw new Error(e)}function Re(t,e){if(t?.length)throw new Error(e)}var Ae=(t,e,r)=>new Promise((n,i)=>{e.addEventListener("abort",()=>{a(),c.remove()});let s=()=>{a(),i()},o=()=>{a(),n()},a=()=>{p&&clearTimeout(p),c.removeEventListener("load",o),c.removeEventListener("error",s)},p;r&&(p=window.setTimeout(s,r));let c=document.createElement("script");c.addEventListener("load",o),c.addEventListener("error",s),c.src=t,document.head.appendChild(c)});var Ce=typeof window.performance?.now=="function"?()=>window.performance.now():()=>Date.now();var Pe=(t,e)=>async(...r)=>{let n=e(...r),i=t.aborted,s;for(;!i&&!t.aborted;)try{let o=await n.next(s);i=o.done??!1,s=o.value}catch(o){await n.throw(o)}return s};var N=class{constructor(){this.detect()}get browser(){return this._currentBrowser}get device(){return this._currentDevice}get isTouch(){return this._maxTouchPoints>0}get isIOS(){return["iPhone","iPad","iPod"].includes(this.device)}get isMac(){return this.device==="Mac"}get isApple(){return this.isIOS||this.isMac}get isIphoneOrOldIpad(){if(!this.isApple||!this.isTouch)return!1;let e=this.device==="iPad"||window?.screen.width>700,r=this._iosVersion;return!e||e&&!!r&&r<16}get isAndroid(){return this.device==="Android"}get isMobile(){return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(navigator.appVersion??navigator.userAgent)||navigator?.userAgentData?.mobile}get iOSVersion(){return this._iosVersion}get macVersion(){return this._macVersion}get isYandex(){return this.browser==="Yandex"}get isSafari(){return this.browser==="Safari"}get isSamsungBrowser(){return this.browser==="SamsungBrowser"}get isHDR(){return this._isHdr}detect(){let{userAgent:e,maxTouchPoints:r}=navigator;try{this._maxTouchPoints=r,this._isHdr=!!matchMedia("(dynamic-range: high)")?.matches}catch(n){console.error(n)}this.detectBrowser(e),this.detectDevice(e),this.isIOS&&this.detectIOSVersion(),this.isMac&&this.detectMacVersion()}detectBrowser(e){try{let r=/yabrowser/i.test(e)?"Yandex":void 0,n=/samsungbrowser/i.test(e)?"SamsungBrowser":void 0,i=/chrome|crios/i.test(e)?"Chrome":void 0,s=/chromium/i.test(e)?"Chromium":void 0,o=/firefox|fxios/i.test(e)?"Firefox":void 0,a=/webkit|safari|khtml/i.test(e)?"Safari":void 0,p=/opr\//i.test(e)?"Opera":void 0,c=/edg/i.test(e)?"Edge":void 0;this._currentBrowser=r||n||o||p||c||i||s||a||"Rest"}catch(r){console.error(r)}}detectDevice(e){try{let r=/android/i.test(e)?"Android":void 0,n=/iphone/i.test(e)?"iPhone":void 0,i=/ipad/i.test(e)?"iPad":void 0,s=/ipod/i.test(e)?"iPod":void 0,o=/mac/i.test(e)?"Mac":void 0,a=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(e)?"RestMobile":void 0;this._currentDevice=r||n||i||s||a||o||"Desktop"}catch(r){console.error(r)}}detectIOSVersion(){try{let{userAgent:e}=window.navigator,r=e.match(/Version\/(\d+(\.\d+)?)/i);if(!r)return;let n=r[1],i=parseFloat(n);if(isNaN(i))return;this._iosVersion=i}catch(e){console.error(e)}}detectMacVersion(){try{let{userAgent:e}=window.navigator,r=e.match(/Version\/(\d+)/);if(!r)return;let n=r[1],i=parseInt(n,10);if(isNaN(i))return;this._macVersion=i}catch(e){console.error(e)}}},ke=new N;var Le=(t,{start:e=0,factor:r=2,max:n=1/0,min:i=e,random:s=0}={})=>{let o=e;return o*=r**t,o*=1+(Math.random()*s*2-s),o=Math.round(o),o=Math.min(o,n),o=Math.max(o,i),o};var ee={};xe(ee,{clear:()=>De,get:()=>Me,has:()=>_e,isPersistent:()=>Ve,remove:()=>Qe,set:()=>Ne});var O,x,_=`vk-videoplayer-dummy-key-${Math.random()}`,w=()=>{if(x!==void 0)return x;try{localStorage.setItem(_,"test"),localStorage.removeItem(_),x=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem(_),x=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)x=2;else throw e}else throw t}return x===2&&(O=new Map),x},Ve=()=>w()===0,Me=t=>{let e=w();switch(e){case 0:return localStorage.getItem(t)??void 0;case 1:return sessionStorage.getItem(t)??void 0;case 2:return O?.get(t);default:v(e)}},Ne=(t,e)=>{let r=w();switch(r){case 0:try{localStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void O?.set(t,e);default:v(r)}},_e=t=>{let e=w();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return O?.has(t)??!1;default:return v(e),!1}},Qe=t=>{let e=w();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:return void O?.delete(t);default:v(e)}},De=()=>{let t=w();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return O?.clear();default:v(t)}};var Ue=()=>{let t,e;try{t=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?t=!0:(t=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let r=e?new URL(e).hostname:void 0;return{isEmbed:t,host:r}};var Q=(d=>(d.INVARIANT="Invariant quality",d.Q_144P="144p",d.Q_240P="240p",d.Q_360P="360p",d.Q_480P="480p",d.Q_720P="720p",d.Q_1080P="1080p",d.Q_1440P="1440p",d.Q_2160P="2160p",d.Q_4320P="4320p",d))(Q||{});var m={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"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}},Be=(t,e)=>m[t].height>m[e].height,Fe=(t,e)=>m[t].height>=m[e].height,D=(t,e)=>m[t].height<m[e].height,ze=(t,e)=>m[t].height<=m[e].height,je=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:D(e,r)?1:-1)[0],te=Object.keys(m).sort((t,e)=>D(t,e)?-1:1),We=(t,e=.02)=>[...te].find(n=>m[n].height*(1+e)>=t),Ge=({width:t,height:e})=>{let r=Math.min(t,e),n=Math.max(t,e);return te.find(i=>{let s=m[i];return s.width>=n&&s.height>=r})},He=t=>m[t].height,U=t=>t==="Invariant quality",qe=t=>t.every(e=>!U(e));function Ke(t){if(U(t))throw new Error("Expected exact quality")}var Ye=(t,e)=>{let r={};for(let n of Object.keys(e)){let i=e[n],s=t[n];Array.isArray(i)&&Array.isArray(s)?r[n]=s:typeof i=="object"&&typeof s=="object"?r[n]=Ye(s,i):r[n]=n in t?s:i}return r};var Ft=t=>{let e="";return t>=3600&&(e+=Math.floor(t/3600)+"h",t=t%3600),t>=60&&(e+=Math.floor(t/60)+"m",t=t%60),t>0&&(e+=Math.floor(t)+"s"),e};function B(t,e=0,r){let n,i,s,o,a,p,c=0,d=!1,b=!1,k=!0,$=!e&&e!==0&&typeof window.requestAnimationFrame=="function";r&&(d=!!r.leading,b="maxWait"in r,s=r?.maxWait?Math.max(+r?.maxWait||0,e):s,k="trailing"in r?!!r.trailing:k);function L(u){let T=n,I=i;return n=i=void 0,c=u,o=t.apply(I,T),o}function E(u,T){return $?(a&&window.cancelAnimationFrame(a),window.requestAnimationFrame(u)):setTimeout(u,T)}function fe(u){if($){window.cancelAnimationFrame(u);return}clearTimeout(u)}function me(u){return c=u,a=E(S,e),d?L(u):o}function Te(u){let T=u-p,I=u-c,Z=e-T;return b?Math.min(Z,s-I):Z}function X(u){let T=u-p,I=u-c;return p===void 0||T>=e||T<0||b&&I>=s}function S(){let u=Date.now();if(X(u))return J(u);a=E(S,Te(u))}function J(u){return a=void 0,k&&n?L(u):(n=i=void 0,o)}function ve(){a!==void 0&&fe(a),c=0,n=p=i=a=void 0}function he(){return a===void 0?o:J(Date.now())}function Ie(){return a!==void 0}function R(...u){let T=Date.now(),I=X(T);if(n=u,i=this,p=T,I){if(a===void 0)return me(p);if(b)return a=E(S,e),L(p)}return a===void 0&&(a=E(S,e)),o}return R.cancel=ve,R.flush=he,R.pending=Ie,R}var F=(t,e=0,r)=>B(t,e,{...{leading:!0,trailing:!0},...r,maxWait:e});var A=(t,e)=>{if(t===null||typeof t!="object")return t;let r=Array.isArray(t)?[]:{};for(let n in t){if(typeof e=="function"){let i=e(t[n],n,t,r);if(i!==void 0){r[n]=i;continue}}typeof t[n]=="object"?r[n]=A(t[n],e):r[n]=t[n]}return r};var $e=t=>A(t);var Xe=300,Je=(t,e=Xe)=>new l(r=>{let{width:n,height:i}=t.getBoundingClientRect();if(r.next({width:n,height:i}),!window.ResizeObserver)return;let s=new ResizeObserver(F(o=>{let a=o[0];if(!a)return;let p,c;a.contentBoxSize&&a.contentBoxSize[0]?(c=a.contentBoxSize[0].blockSize,p=a.contentBoxSize[0].inlineSize):a.contentRect&&(p=a.contentRect.width,c=a.contentRect.height),y(p)&&y(c)&&r.next({width:p,height:c})},e));return s.observe(t),()=>s.disconnect()});var Ze=t=>{t.removeAttribute("src"),t.load()};var C=class extends h{constructor(r){super();this.value=r}next(r){super.next(this.value=r)}error(r){super.error(this.value=r)}getValue(){return this.value}_subscribe(r){let n=super._subscribe(r);return r.next(this.value),n}};function re(t){return new l(e=>{let r={},n=Object.keys(t).length,i=s=>o=>{s in r||n--,r[s]=o,n===0&&e.next(r)};return Object.entries(t).reduce((s,[o,a])=>s.add(a.subscribe(i(o))),new f)})}function ne(...t){return new l(e=>t.reduce((r,n)=>r.add(n.subscribe(e)),new f))}var et=t=>new l(e=>{let r=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},t);return()=>window.clearTimeout(r)});var tt=t=>new l(e=>{let r=window.setInterval(()=>e.next(),t);return()=>{r&&(window.clearInterval(r),r=void 0)}});var rt=t=>new l(e=>{t.forEach(r=>e.next(r))});var nt=(t,e)=>new l(r=>{let n=i=>r.next(i);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)});function ie(t){return e=>new l(r=>e.subscribe(new z(r,t)))}var z=class{constructor(e,r){this.destination=e;this.size=r;this.lastValues=[]}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 it={leading:!1,trailing:!0};function oe(t,e=it){return r=>new l(n=>r.subscribe(new j(n,t,e)))}var j=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,y(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(r){if(this.destination.error)this.destination.error(r);else throw r}this.timeout=void 0},this.time)}error(e){this.destination.error?.(e)}};var ot={leading:!0,trailing:!1};function se(t,e=ot){return r=>new l(n=>r.subscribe(new W(n,t,e)))}var W=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,M(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){this.destination.error?.(e)}};function ae(t){return e=>new l(r=>e.subscribe(new G(r,t)))}var G=class{constructor(e,r){this.destination=e;this.predicate=r}next(e){let r;try{r=this.predicate(e)}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function ue(t=(e,r)=>e===r){return e=>new l(r=>e.subscribe(new H(r,t)))}var le={},H=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=le}next(e){let r;try{r=this.lastValue===le||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function P(t){return e=>new l(r=>e.subscribe(new q(r,t)))}var q=class{constructor(e,r){this.destination=e;this.mapper=r}next(e){let r;try{r=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(r)}error(e){this.destination.error?.(e)}};function ce(t){return P(()=>t)}function pe(){return t=>new l(e=>{let r=!1,n=!1,i=t.subscribe(s=>{r||(r=!0,e.next(s)),n&&i.unsubscribe()},s=>{r=!0,e.error?.(s),n&&i.unsubscribe()});return n=!0,r&&i.unsubscribe(),i})}function be(){return t=>new l(e=>t.subscribe(new K(e)))}var K=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let r=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([r,e])}error(e){this.destination.error?.(e)}};function de(t){return e=>new l(r=>e.subscribe(new Y(r,t)))}var Y=class{constructor(e,r){this.destination=e;this.effect=r}next(e){try{this.effect(e)}catch(r){throw this.error(r),r}this.destination.next(e)}error(e){this.destination.error?.(e)}};var st=(a=>(a.NETWORK="network",a.VIDEO_PIPELINE="video_pipeline",a.EXTERNAL_API="external_api",a.PARSER="parser",a.DOM="dom",a.WTF="wtf",a.FATAL="fatal",a))(st||{});var at=(b=>(b.Armenian="58",b.Azerbaijani="57",b.Belarusian="114",b.English="3",b.Kazakh="97",b.Portuguese="73",b.Russian="0",b.Spanish="4",b.Ukrainian="1",b.Uzbek="65",b.Vietnamese="75",b))(at||{}),lt="vk.com",Ln=async(t,e,r)=>{let n=new URL(`https://${lt}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),t!==void 0&&n.searchParams.set("lang",t);let s=await(await fetch(n.toString())).json();return ut(s,r)},ut=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,n])=>[r.substring(`${e}_`.length),ct(n)])),ct=t=>Array.isArray(t)?t[0]:t;var pt=(r=>(r.RU="ru",r.EN="en",r))(pt||{});export{ke as CC,st as ErrorCategory,pt as InterfaceLanguage,V as Logger,l as Observable,h as Subject,f as Subscription,ye as VERSION,at as VKNumericLanguage,C as ValueSubject,Q as VideoQuality,Pe as abortable,Ae as addScript,qe as areQualitiesExact,Re as assertEmptyArray,v as assertNever,we as assertNonNullable,Se as assertNotEmptyArray,Ee as assertNullable,Ke as assertQualityIsExact,ie as buffer,Oe as checkNever,Ze as clearVideoElement,$e as cloneDeep,A as cloneDeepWith,re as combine,oe as debounce,B as debounceFn,Ue as detectEmbed,Ye as fillWithDefault,ae as filter,ue as filterChanged,nt as fromEvent,Le as getExponentialDelay,je as getHighestQuality,tt as interval,Be as isHigher,Fe as isHigherOrEqual,U as isInvariantQuality,D as isLower,ze as isLowerOrEqual,y as isNonNullable,M as isNullable,Ln as loadVKLangPack,P as map,ce as mapTo,ne as merge,g as noop,Ce as now,rt as observableFrom,Je as observeElementSize,pe as once,be as pairwise,ee as safeStorage,de as tap,se as throttle,F as throttleFn,Ft as timeCodeToString,et as timeout,We as videoHeightToQuality,He as videoQualityToHeight,Ge as videoSizeToQuality};
|
|
6
|
+
var ye=Object.defineProperty;var Oe=(t,e)=>{for(var r in e)ye(t,r,{get:e[r],enumerable:!0})};var we="1.0.38-dev.df616f9c.0";var f=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(r=>typeof r=="function"?r():r.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var v=t=>{throw new Error(`${t} is value of unexpected type`)},Ee=t=>{};var g=()=>{};var l=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,r){let n;r?typeof r=="function"?n={next:r,error:g}:n={next:o=>r.next(o),error:o=>r.error?.(o)}:n={next:g,error:g};let s=typeof e=="function"?{next:o=>{try{e(o)}catch(a){n.next(a)}},error:o=>n.next(o)}:{next:o=>e.next(o),error:o=>e.error?e.error(o):n.next(o)},i;try{i=this._subscribe(s)}catch(o){s.error?.(o)}return new f().add(()=>{switch(s.next=g,s.error=g,typeof i){case"function":i();return;case"object":i.unsubscribe();return;case"undefined":return;default:return v(i)}})}pipe(...e){return e.reduce((r,n)=>n(r),this)}_subscribe(e){}};var I=class extends l{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(r){this.subscribers.forEach(n=>n.next(r))}error(r){this.subscribers.forEach(n=>n.error?.(r))}_subscribe(r){let n=this.keyCounter++;return this.subscribers.set(n,r),new f().add(()=>this.subscribers.delete(n))}};var V=class{constructor(){this.log$=new I;this.logs=[];this.log=e=>{let r={...e,timestamp:Date.now()};this.logs.push(r),this.log$.next(r)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...r)=>{let n;try{n=e(...r)}catch{n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(r=>({component:e,...r}))}};function Se(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function Ae(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function y(t){return typeof t<"u"&&t!==null}function Q(t){return t==null}function Re(t,e){if(!t?.length)throw new Error(e)}function Ce(t,e){if(t?.length)throw new Error(e)}var ke=(t,e,r)=>new Promise((n,s)=>{e.addEventListener("abort",()=>{a(),b.remove()});let i=()=>{a(),s()},o=()=>{a(),n()},a=()=>{u&&clearTimeout(u),b.removeEventListener("load",o),b.removeEventListener("error",i)},u;r&&(u=window.setTimeout(i,r));let b=document.createElement("script");b.addEventListener("load",o),b.addEventListener("error",i),b.src=t,document.head.appendChild(b)});var Le=typeof window.performance?.now=="function"?()=>window.performance.now():()=>Date.now();var Pe=(t,e)=>async(...r)=>{let n=e(...r),s=t.aborted,i;for(;!s&&!t.aborted;)try{let o=await n.next(i);s=o.done??!1,i=o.value}catch(o){await n.throw(o)}return i};var ee=(c=>(c.Unknown="Unknown",c.Yandex="Yandex",c.Chrome="Chrome",c.Chromium="Chromium",c.Firefox="Firefox",c.Safari="Safari",c.Opera="Opera",c.Edge="Edge",c.SamsungBrowser="SamsungBrowser",c.Rest="Rest",c))(ee||{}),te=(u=>(u.Unknown="Unknown",u.Android="Android",u.iPhone="iPhone",u.iPad="iPad",u.iPod="iPod",u.RestMobile="RestMobile",u.Mac="Mac",u.Desktop="Desktop",u))(te||{}),A=()=>{let{userAgent:t}=window.navigator,e=/yabrowser/i.test(t)?"Yandex":void 0,r=/samsungbrowser/i.test(t)?"SamsungBrowser":void 0,n=/chrome|crios/i.test(t)?"Chrome":void 0,s=/chromium/i.test(t)?"Chromium":void 0,i=/firefox|fxios/i.test(t)?"Firefox":void 0,o=/webkit|safari|khtml/i.test(t)?"Safari":void 0,a=/opr\//i.test(t)?"Opera":void 0,u=/edg/i.test(t)?"Edge":void 0,b=/android/i.test(t)?"Android":void 0,c=/iphone/i.test(t)?"iPhone":void 0,d=/ipad/i.test(t)?"iPad":void 0,E=/ipod/i.test(t)?"iPod":void 0,R=/mac/i.test(t)?"Mac":void 0,S=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(t)?"RestMobile":void 0;return{browser:e||r||i||a||u||n||s||o||"Rest",device:b||c||d||E||S||R||"Desktop"}},Me=(t=!1)=>{let r=["iPhone","iPad","iPod"].includes(A().device);if(!t)return r;let{userAgent:n,maxTouchPoints:s}=window.navigator;return!!(r||/macintosh/i.test(n)&&s>0)},Ne=()=>{let{userAgent:t}=window.navigator,e=t.match(/Version\/(\d+(\.\d+)?)/i);if(!e)return null;let r=e[1],n=parseFloat(r);return isNaN(n)?null:n},Ve=()=>{let{device:t}=A(),{userAgent:e,maxTouchPoints:r}=window.navigator,n=/linux/i.test(e),s=r>0;return t==="Desktop"&&n&&s},Qe=()=>A().device==="Android"||Ve(),De=()=>["Mac","iPhone","iPad","iPod"].includes(A().device),_e=()=>/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(navigator.appVersion??navigator.userAgent)||navigator?.userAgentData?.mobile;var Ue=(t,{start:e=0,factor:r=2,max:n=1/0,min:s=e,random:i=0}={})=>{let o=e;return o*=r**t,o*=1+(Math.random()*i*2-i),o=Math.round(o),o=Math.min(o,n),o=Math.max(o,s),o};var re={};Oe(re,{clear:()=>Ge,get:()=>Be,has:()=>je,isPersistent:()=>Fe,remove:()=>We,set:()=>ze});var O,h,D=`vk-videoplayer-dummy-key-${Math.random()}`,w=()=>{if(h!==void 0)return h;try{localStorage.setItem(D,"test"),localStorage.removeItem(D),h=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem(D),h=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)h=2;else throw e}else throw t}return h===2&&(O=new Map),h},Fe=()=>w()===0,Be=t=>{let e=w();switch(e){case 0:return localStorage.getItem(t)??void 0;case 1:return sessionStorage.getItem(t)??void 0;case 2:return O?.get(t);default:v(e)}},ze=(t,e)=>{let r=w();switch(r){case 0:try{localStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void O?.set(t,e);default:v(r)}},je=t=>{let e=w();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return O?.has(t)??!1;default:return v(e),!1}},We=t=>{let e=w();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:return void O?.delete(t);default:v(e)}},Ge=()=>{let t=w();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return O?.clear();default:v(t)}};var qe=()=>{let t,e;try{t=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?t=!0:(t=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let r=e?new URL(e).hostname:void 0;return{isEmbed:t,host:r}};var _=(c=>(c.INVARIANT="Invariant quality",c.Q_144P="144p",c.Q_240P="240p",c.Q_360P="360p",c.Q_480P="480p",c.Q_720P="720p",c.Q_1080P="1080p",c.Q_1440P="1440p",c.Q_2160P="2160p",c.Q_4320P="4320p",c))(_||{});var m={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"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}},He=(t,e)=>m[t].height>m[e].height,Ke=(t,e)=>m[t].height>=m[e].height,U=(t,e)=>m[t].height<m[e].height,$e=(t,e)=>m[t].height<=m[e].height,Ye=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:U(e,r)?1:-1)[0],ne=Object.keys(m).sort((t,e)=>U(t,e)?-1:1),Xe=(t,e=.02)=>[...ne].find(n=>m[n].height*(1+e)>=t),Je=({width:t,height:e})=>{let r=Math.min(t,e),n=Math.max(t,e);return ne.find(s=>{let i=m[s];return i.width>=n&&i.height>=r})},Ze=t=>m[t].height,F=t=>t==="Invariant quality",et=t=>t.every(e=>!F(e));function tt(t){if(F(t))throw new Error("Expected exact quality")}var rt=(t,e)=>{let r={};for(let n of Object.keys(e)){let s=e[n],i=t[n];Array.isArray(s)&&Array.isArray(i)?r[n]=i:typeof s=="object"&&typeof i=="object"?r[n]=rt(i,s):r[n]=n in t?i:s}return r};var Kt=t=>{let e="";return t>=3600&&(e+=Math.floor(t/3600)+"h",t=t%3600),t>=60&&(e+=Math.floor(t/60)+"m",t=t%60),t>0&&(e+=Math.floor(t)+"s"),e};function B(t,e=0,r){let n,s,i,o,a,u,b=0,c=!1,d=!1,E=!0,R=!e&&e!==0&&typeof window.requestAnimationFrame=="function";r&&(c=!!r.leading,d="maxWait"in r,i=r?.maxWait?Math.max(+r?.maxWait||0,e):i,E="trailing"in r?!!r.trailing:E);function S(p){let T=n,x=s;return n=s=void 0,b=p,o=t.apply(x,T),o}function C(p,T){return R?(a&&window.cancelAnimationFrame(a),window.requestAnimationFrame(p)):setTimeout(p,T)}function Te(p){if(R){window.cancelAnimationFrame(p);return}clearTimeout(p)}function ve(p){return b=p,a=C(k,e),c?S(p):o}function Ie(p){let T=p-u,x=p-b,Z=e-T;return d?Math.min(Z,i-x):Z}function X(p){let T=p-u,x=p-b;return u===void 0||T>=e||T<0||d&&x>=i}function k(){let p=Date.now();if(X(p))return J(p);a=C(k,Ie(p))}function J(p){return a=void 0,E&&n?S(p):(n=s=void 0,o)}function xe(){a!==void 0&&Te(a),b=0,n=u=s=a=void 0}function ge(){return a===void 0?o:J(Date.now())}function he(){return a!==void 0}function L(...p){let T=Date.now(),x=X(T);if(n=p,s=this,u=T,x){if(a===void 0)return ve(u);if(d)return a=C(k,e),S(u)}return a===void 0&&(a=C(k,e)),o}return L.cancel=xe,L.flush=ge,L.pending=he,L}var z=(t,e=0,r)=>B(t,e,{...{leading:!0,trailing:!0},...r,maxWait:e});var P=(t,e)=>{if(t===null||typeof t!="object")return t;let r=Array.isArray(t)?[]:{};for(let n in t){if(typeof e=="function"){let s=e(t[n],n,t,r);if(s!==void 0){r[n]=s;continue}}typeof t[n]=="object"?r[n]=P(t[n],e):r[n]=t[n]}return r};var nt=t=>P(t);var ot=300,it=(t,e=ot)=>new l(r=>{let{width:n,height:s}=t.getBoundingClientRect();if(r.next({width:n,height:s}),!window.ResizeObserver)return;let i=new ResizeObserver(z(o=>{let a=o[0];if(!a)return;let u,b;a.contentBoxSize&&a.contentBoxSize[0]?(b=a.contentBoxSize[0].blockSize,u=a.contentBoxSize[0].inlineSize):a.contentRect&&(u=a.contentRect.width,b=a.contentRect.height),y(u)&&y(b)&&r.next({width:u,height:b})},e));return i.observe(t),()=>i.disconnect()});var st=t=>{t.removeAttribute("src"),t.load()};var M=class extends I{constructor(r){super();this.value=r}next(r){super.next(this.value=r)}error(r){super.error(this.value=r)}getValue(){return this.value}_subscribe(r){let n=super._subscribe(r);return r.next(this.value),n}};function oe(t){return new l(e=>{let r={},n=Object.keys(t).length,s=i=>o=>{i in r||n--,r[i]=o,n===0&&e.next(r)};return Object.entries(t).reduce((i,[o,a])=>i.add(a.subscribe(s(o))),new f)})}function ie(...t){return new l(e=>t.reduce((r,n)=>r.add(n.subscribe(e)),new f))}var at=t=>new l(e=>{let r=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},t);return()=>window.clearTimeout(r)});var lt=t=>new l(e=>{let r=window.setInterval(()=>e.next(),t);return()=>{r&&(window.clearInterval(r),r=void 0)}});var ut=t=>new l(e=>{t.forEach(r=>e.next(r))});var ct=(t,e)=>new l(r=>{let n=s=>r.next(s);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)});function se(t){return e=>new l(r=>e.subscribe(new j(r,t)))}var j=class{constructor(e,r){this.destination=e;this.size=r;this.lastValues=[]}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 pt={leading:!1,trailing:!0};function ae(t,e=pt){return r=>new l(n=>r.subscribe(new W(n,t,e)))}var W=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,y(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(r){if(this.destination.error)this.destination.error(r);else throw r}this.timeout=void 0},this.time)}error(e){this.destination.error?.(e)}};var bt={leading:!0,trailing:!1};function le(t,e=bt){return r=>new l(n=>r.subscribe(new G(n,t,e)))}var G=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,Q(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){this.destination.error?.(e)}};function ue(t){return e=>new l(r=>e.subscribe(new q(r,t)))}var q=class{constructor(e,r){this.destination=e;this.predicate=r}next(e){let r;try{r=this.predicate(e)}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function pe(t=(e,r)=>e===r){return e=>new l(r=>e.subscribe(new H(r,t)))}var ce={},H=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=ce}next(e){let r;try{r=this.lastValue===ce||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function N(t){return e=>new l(r=>e.subscribe(new K(r,t)))}var K=class{constructor(e,r){this.destination=e;this.mapper=r}next(e){let r;try{r=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(r)}error(e){this.destination.error?.(e)}};function be(t){return N(()=>t)}function de(){return t=>new l(e=>{let r=!1,n=!1,s=t.subscribe(i=>{r||(r=!0,e.next(i)),n&&s.unsubscribe()},i=>{r=!0,e.error?.(i),n&&s.unsubscribe()});return n=!0,r&&s.unsubscribe(),s})}function fe(){return t=>new l(e=>t.subscribe(new $(e)))}var $=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let r=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([r,e])}error(e){this.destination.error?.(e)}};function me(t){return e=>new l(r=>e.subscribe(new Y(r,t)))}var Y=class{constructor(e,r){this.destination=e;this.effect=r}next(e){try{this.effect(e)}catch(r){throw this.error(r),r}this.destination.next(e)}error(e){this.destination.error?.(e)}};var dt=(a=>(a.NETWORK="network",a.VIDEO_PIPELINE="video_pipeline",a.EXTERNAL_API="external_api",a.PARSER="parser",a.DOM="dom",a.WTF="wtf",a.FATAL="fatal",a))(dt||{});var ft=(d=>(d.Armenian="58",d.Azerbaijani="57",d.Belarusian="114",d.English="3",d.Kazakh="97",d.Portuguese="73",d.Russian="0",d.Spanish="4",d.Ukrainian="1",d.Uzbek="65",d.Vietnamese="75",d))(ft||{}),mt="vk.com",Un=async(t,e,r)=>{let n=new URL(`https://${mt}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),t!==void 0&&n.searchParams.set("lang",t);let i=await(await fetch(n.toString())).json();return Tt(i,r)},Tt=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,n])=>[r.substring(`${e}_`.length),vt(n)])),vt=t=>Array.isArray(t)?t[0]:t;var It=(r=>(r.RU="ru",r.EN="en",r))(It||{});export{ee as CurrentClientBrowser,te as CurrentClientDevice,dt as ErrorCategory,It as InterfaceLanguage,V as Logger,l as Observable,I as Subject,f as Subscription,we as VERSION,ft as VKNumericLanguage,M as ValueSubject,_ as VideoQuality,Pe as abortable,ke as addScript,et as areQualitiesExact,Ce as assertEmptyArray,v as assertNever,Se as assertNonNullable,Re as assertNotEmptyArray,Ae as assertNullable,tt as assertQualityIsExact,se as buffer,Ee as checkNever,st as clearVideoElement,nt as cloneDeep,P as cloneDeepWith,oe as combine,ae as debounce,B as debounceFn,qe as detectEmbed,rt as fillWithDefault,ue as filter,pe as filterChanged,ct as fromEvent,A as getCurrentBrowser,Ue as getExponentialDelay,Ye as getHighestQuality,Ne as getIOSVersion,lt as interval,Qe as isAndroid,He as isHigher,Ke as isHigherOrEqual,Me as isIOS,F as isInvariantQuality,U as isLower,$e as isLowerOrEqual,De as isMacLike,_e as isMobile,y as isNonNullable,Q as isNullable,Un as loadVKLangPack,N as map,be as mapTo,ie as merge,g as noop,Le as now,ut as observableFrom,it as observeElementSize,de as once,fe as pairwise,re as safeStorage,me as tap,le as throttle,z as throttleFn,Kt as timeCodeToString,at as timeout,Xe as videoHeightToQuality,Ze as videoQualityToHeight,Je as videoSizeToQuality};
|
package/evergreen.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-shared v1.0.38-dev.
|
|
3
|
-
*
|
|
2
|
+
* @vkontakte/videoplayer-shared v1.0.38-dev.df616f9c.0
|
|
3
|
+
* Fri, 16 Aug 2024 08:31:38 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-38/doc/
|
|
5
5
|
*/
|
|
6
|
-
var ge=Object.defineProperty;var xe=(t,e)=>{for(var r in e)ge(t,r,{get:e[r],enumerable:!0})};var ye="1.0.38-dev.c2293902.0";var f=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(r=>typeof r=="function"?r():r.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var v=t=>{throw new Error(`${t} is value of unexpected type`)},Oe=t=>{};var g=()=>{};var l=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,r){let n;r?typeof r=="function"?n={next:r,error:g}:n={next:o=>r.next(o),error:o=>r.error?.(o)}:n={next:g,error:g};let i=typeof e=="function"?{next:o=>{try{e(o)}catch(a){n.next(a)}},error:o=>n.next(o)}:{next:o=>e.next(o),error:o=>e.error?e.error(o):n.next(o)},s;try{s=this._subscribe(i)}catch(o){i.error?.(o)}return new f().add(()=>{switch(i.next=g,i.error=g,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return v(s)}})}pipe(...e){return e.reduce((r,n)=>n(r),this)}_subscribe(e){}};var h=class extends l{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(r){this.subscribers.forEach(n=>n.next(r))}error(r){this.subscribers.forEach(n=>n.error?.(r))}_subscribe(r){let n=this.keyCounter++;return this.subscribers.set(n,r),new f().add(()=>this.subscribers.delete(n))}};var V=class{constructor(){this.log$=new h;this.logs=[];this.log=e=>{let r={...e,timestamp:Date.now()};this.logs.push(r),this.log$.next(r)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...r)=>{let n;try{n=e(...r)}catch{n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(r=>({component:e,...r}))}};function we(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function Ee(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function y(t){return typeof t<"u"&&t!==null}function M(t){return t==null}function Se(t,e){if(!t?.length)throw new Error(e)}function Re(t,e){if(t?.length)throw new Error(e)}var Ae=(t,e,r)=>new Promise((n,i)=>{e.addEventListener("abort",()=>{a(),c.remove()});let s=()=>{a(),i()},o=()=>{a(),n()},a=()=>{p&&clearTimeout(p),c.removeEventListener("load",o),c.removeEventListener("error",s)},p;r&&(p=window.setTimeout(s,r));let c=document.createElement("script");c.addEventListener("load",o),c.addEventListener("error",s),c.src=t,document.head.appendChild(c)});var Ce=typeof window.performance?.now=="function"?()=>window.performance.now():()=>Date.now();var Pe=(t,e)=>async(...r)=>{let n=e(...r),i=t.aborted,s;for(;!i&&!t.aborted;)try{let o=await n.next(s);i=o.done??!1,s=o.value}catch(o){await n.throw(o)}return s};var N=class{constructor(){this.detect()}get browser(){return this._currentBrowser}get device(){return this._currentDevice}get isTouch(){return this._maxTouchPoints>0}get isIOS(){return["iPhone","iPad","iPod"].includes(this.device)}get isMac(){return this.device==="Mac"}get isApple(){return this.isIOS||this.isMac}get isIphoneOrOldIpad(){if(!this.isApple||!this.isTouch)return!1;let e=this.device==="iPad"||window?.screen.width>700,r=this._iosVersion;return!e||e&&!!r&&r<16}get isAndroid(){return this.device==="Android"}get isMobile(){return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(navigator.appVersion??navigator.userAgent)||navigator?.userAgentData?.mobile}get iOSVersion(){return this._iosVersion}get macVersion(){return this._macVersion}get isYandex(){return this.browser==="Yandex"}get isSafari(){return this.browser==="Safari"}get isSamsungBrowser(){return this.browser==="SamsungBrowser"}get isHDR(){return this._isHdr}detect(){let{userAgent:e,maxTouchPoints:r}=navigator;try{this._maxTouchPoints=r,this._isHdr=!!matchMedia("(dynamic-range: high)")?.matches}catch(n){console.error(n)}this.detectBrowser(e),this.detectDevice(e),this.isIOS&&this.detectIOSVersion(),this.isMac&&this.detectMacVersion()}detectBrowser(e){try{let r=/yabrowser/i.test(e)?"Yandex":void 0,n=/samsungbrowser/i.test(e)?"SamsungBrowser":void 0,i=/chrome|crios/i.test(e)?"Chrome":void 0,s=/chromium/i.test(e)?"Chromium":void 0,o=/firefox|fxios/i.test(e)?"Firefox":void 0,a=/webkit|safari|khtml/i.test(e)?"Safari":void 0,p=/opr\//i.test(e)?"Opera":void 0,c=/edg/i.test(e)?"Edge":void 0;this._currentBrowser=r||n||o||p||c||i||s||a||"Rest"}catch(r){console.error(r)}}detectDevice(e){try{let r=/android/i.test(e)?"Android":void 0,n=/iphone/i.test(e)?"iPhone":void 0,i=/ipad/i.test(e)?"iPad":void 0,s=/ipod/i.test(e)?"iPod":void 0,o=/mac/i.test(e)?"Mac":void 0,a=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(e)?"RestMobile":void 0;this._currentDevice=r||n||i||s||a||o||"Desktop"}catch(r){console.error(r)}}detectIOSVersion(){try{let{userAgent:e}=window.navigator,r=e.match(/Version\/(\d+(\.\d+)?)/i);if(!r)return;let n=r[1],i=parseFloat(n);if(isNaN(i))return;this._iosVersion=i}catch(e){console.error(e)}}detectMacVersion(){try{let{userAgent:e}=window.navigator,r=e.match(/Version\/(\d+)/);if(!r)return;let n=r[1],i=parseInt(n,10);if(isNaN(i))return;this._macVersion=i}catch(e){console.error(e)}}},ke=new N;var Le=(t,{start:e=0,factor:r=2,max:n=1/0,min:i=e,random:s=0}={})=>{let o=e;return o*=r**t,o*=1+(Math.random()*s*2-s),o=Math.round(o),o=Math.min(o,n),o=Math.max(o,i),o};var ee={};xe(ee,{clear:()=>De,get:()=>Me,has:()=>_e,isPersistent:()=>Ve,remove:()=>Qe,set:()=>Ne});var O,x,_=`vk-videoplayer-dummy-key-${Math.random()}`,w=()=>{if(x!==void 0)return x;try{localStorage.setItem(_,"test"),localStorage.removeItem(_),x=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem(_),x=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)x=2;else throw e}else throw t}return x===2&&(O=new Map),x},Ve=()=>w()===0,Me=t=>{let e=w();switch(e){case 0:return localStorage.getItem(t)??void 0;case 1:return sessionStorage.getItem(t)??void 0;case 2:return O?.get(t);default:v(e)}},Ne=(t,e)=>{let r=w();switch(r){case 0:try{localStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void O?.set(t,e);default:v(r)}},_e=t=>{let e=w();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return O?.has(t)??!1;default:return v(e),!1}},Qe=t=>{let e=w();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:return void O?.delete(t);default:v(e)}},De=()=>{let t=w();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return O?.clear();default:v(t)}};var Ue=()=>{let t,e;try{t=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?t=!0:(t=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let r=e?new URL(e).hostname:void 0;return{isEmbed:t,host:r}};var Q=(d=>(d.INVARIANT="Invariant quality",d.Q_144P="144p",d.Q_240P="240p",d.Q_360P="360p",d.Q_480P="480p",d.Q_720P="720p",d.Q_1080P="1080p",d.Q_1440P="1440p",d.Q_2160P="2160p",d.Q_4320P="4320p",d))(Q||{});var m={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"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}},Be=(t,e)=>m[t].height>m[e].height,Fe=(t,e)=>m[t].height>=m[e].height,D=(t,e)=>m[t].height<m[e].height,ze=(t,e)=>m[t].height<=m[e].height,je=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:D(e,r)?1:-1)[0],te=Object.keys(m).sort((t,e)=>D(t,e)?-1:1),We=(t,e=.02)=>[...te].find(n=>m[n].height*(1+e)>=t),Ge=({width:t,height:e})=>{let r=Math.min(t,e),n=Math.max(t,e);return te.find(i=>{let s=m[i];return s.width>=n&&s.height>=r})},He=t=>m[t].height,U=t=>t==="Invariant quality",qe=t=>t.every(e=>!U(e));function Ke(t){if(U(t))throw new Error("Expected exact quality")}var Ye=(t,e)=>{let r={};for(let n of Object.keys(e)){let i=e[n],s=t[n];Array.isArray(i)&&Array.isArray(s)?r[n]=s:typeof i=="object"&&typeof s=="object"?r[n]=Ye(s,i):r[n]=n in t?s:i}return r};var Ft=t=>{let e="";return t>=3600&&(e+=Math.floor(t/3600)+"h",t=t%3600),t>=60&&(e+=Math.floor(t/60)+"m",t=t%60),t>0&&(e+=Math.floor(t)+"s"),e};function B(t,e=0,r){let n,i,s,o,a,p,c=0,d=!1,b=!1,k=!0,$=!e&&e!==0&&typeof window.requestAnimationFrame=="function";r&&(d=!!r.leading,b="maxWait"in r,s=r?.maxWait?Math.max(+r?.maxWait||0,e):s,k="trailing"in r?!!r.trailing:k);function L(u){let T=n,I=i;return n=i=void 0,c=u,o=t.apply(I,T),o}function E(u,T){return $?(a&&window.cancelAnimationFrame(a),window.requestAnimationFrame(u)):setTimeout(u,T)}function fe(u){if($){window.cancelAnimationFrame(u);return}clearTimeout(u)}function me(u){return c=u,a=E(S,e),d?L(u):o}function Te(u){let T=u-p,I=u-c,Z=e-T;return b?Math.min(Z,s-I):Z}function X(u){let T=u-p,I=u-c;return p===void 0||T>=e||T<0||b&&I>=s}function S(){let u=Date.now();if(X(u))return J(u);a=E(S,Te(u))}function J(u){return a=void 0,k&&n?L(u):(n=i=void 0,o)}function ve(){a!==void 0&&fe(a),c=0,n=p=i=a=void 0}function he(){return a===void 0?o:J(Date.now())}function Ie(){return a!==void 0}function R(...u){let T=Date.now(),I=X(T);if(n=u,i=this,p=T,I){if(a===void 0)return me(p);if(b)return a=E(S,e),L(p)}return a===void 0&&(a=E(S,e)),o}return R.cancel=ve,R.flush=he,R.pending=Ie,R}var F=(t,e=0,r)=>B(t,e,{...{leading:!0,trailing:!0},...r,maxWait:e});var A=(t,e)=>{if(t===null||typeof t!="object")return t;let r=Array.isArray(t)?[]:{};for(let n in t){if(typeof e=="function"){let i=e(t[n],n,t,r);if(i!==void 0){r[n]=i;continue}}typeof t[n]=="object"?r[n]=A(t[n],e):r[n]=t[n]}return r};var $e=t=>A(t);var Xe=300,Je=(t,e=Xe)=>new l(r=>{let{width:n,height:i}=t.getBoundingClientRect();if(r.next({width:n,height:i}),!window.ResizeObserver)return;let s=new ResizeObserver(F(o=>{let a=o[0];if(!a)return;let p,c;a.contentBoxSize&&a.contentBoxSize[0]?(c=a.contentBoxSize[0].blockSize,p=a.contentBoxSize[0].inlineSize):a.contentRect&&(p=a.contentRect.width,c=a.contentRect.height),y(p)&&y(c)&&r.next({width:p,height:c})},e));return s.observe(t),()=>s.disconnect()});var Ze=t=>{t.removeAttribute("src"),t.load()};var C=class extends h{constructor(r){super();this.value=r}next(r){super.next(this.value=r)}error(r){super.error(this.value=r)}getValue(){return this.value}_subscribe(r){let n=super._subscribe(r);return r.next(this.value),n}};function re(t){return new l(e=>{let r={},n=Object.keys(t).length,i=s=>o=>{s in r||n--,r[s]=o,n===0&&e.next(r)};return Object.entries(t).reduce((s,[o,a])=>s.add(a.subscribe(i(o))),new f)})}function ne(...t){return new l(e=>t.reduce((r,n)=>r.add(n.subscribe(e)),new f))}var et=t=>new l(e=>{let r=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},t);return()=>window.clearTimeout(r)});var tt=t=>new l(e=>{let r=window.setInterval(()=>e.next(),t);return()=>{r&&(window.clearInterval(r),r=void 0)}});var rt=t=>new l(e=>{t.forEach(r=>e.next(r))});var nt=(t,e)=>new l(r=>{let n=i=>r.next(i);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)});function ie(t){return e=>new l(r=>e.subscribe(new z(r,t)))}var z=class{constructor(e,r){this.destination=e;this.size=r;this.lastValues=[]}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 it={leading:!1,trailing:!0};function oe(t,e=it){return r=>new l(n=>r.subscribe(new j(n,t,e)))}var j=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,y(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(r){if(this.destination.error)this.destination.error(r);else throw r}this.timeout=void 0},this.time)}error(e){this.destination.error?.(e)}};var ot={leading:!0,trailing:!1};function se(t,e=ot){return r=>new l(n=>r.subscribe(new W(n,t,e)))}var W=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,M(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){this.destination.error?.(e)}};function ae(t){return e=>new l(r=>e.subscribe(new G(r,t)))}var G=class{constructor(e,r){this.destination=e;this.predicate=r}next(e){let r;try{r=this.predicate(e)}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function ue(t=(e,r)=>e===r){return e=>new l(r=>e.subscribe(new H(r,t)))}var le={},H=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=le}next(e){let r;try{r=this.lastValue===le||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function P(t){return e=>new l(r=>e.subscribe(new q(r,t)))}var q=class{constructor(e,r){this.destination=e;this.mapper=r}next(e){let r;try{r=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(r)}error(e){this.destination.error?.(e)}};function ce(t){return P(()=>t)}function pe(){return t=>new l(e=>{let r=!1,n=!1,i=t.subscribe(s=>{r||(r=!0,e.next(s)),n&&i.unsubscribe()},s=>{r=!0,e.error?.(s),n&&i.unsubscribe()});return n=!0,r&&i.unsubscribe(),i})}function be(){return t=>new l(e=>t.subscribe(new K(e)))}var K=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let r=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([r,e])}error(e){this.destination.error?.(e)}};function de(t){return e=>new l(r=>e.subscribe(new Y(r,t)))}var Y=class{constructor(e,r){this.destination=e;this.effect=r}next(e){try{this.effect(e)}catch(r){throw this.error(r),r}this.destination.next(e)}error(e){this.destination.error?.(e)}};var st=(a=>(a.NETWORK="network",a.VIDEO_PIPELINE="video_pipeline",a.EXTERNAL_API="external_api",a.PARSER="parser",a.DOM="dom",a.WTF="wtf",a.FATAL="fatal",a))(st||{});var at=(b=>(b.Armenian="58",b.Azerbaijani="57",b.Belarusian="114",b.English="3",b.Kazakh="97",b.Portuguese="73",b.Russian="0",b.Spanish="4",b.Ukrainian="1",b.Uzbek="65",b.Vietnamese="75",b))(at||{}),lt="vk.com",Ln=async(t,e,r)=>{let n=new URL(`https://${lt}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),t!==void 0&&n.searchParams.set("lang",t);let s=await(await fetch(n.toString())).json();return ut(s,r)},ut=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,n])=>[r.substring(`${e}_`.length),ct(n)])),ct=t=>Array.isArray(t)?t[0]:t;var pt=(r=>(r.RU="ru",r.EN="en",r))(pt||{});export{ke as CC,st as ErrorCategory,pt as InterfaceLanguage,V as Logger,l as Observable,h as Subject,f as Subscription,ye as VERSION,at as VKNumericLanguage,C as ValueSubject,Q as VideoQuality,Pe as abortable,Ae as addScript,qe as areQualitiesExact,Re as assertEmptyArray,v as assertNever,we as assertNonNullable,Se as assertNotEmptyArray,Ee as assertNullable,Ke as assertQualityIsExact,ie as buffer,Oe as checkNever,Ze as clearVideoElement,$e as cloneDeep,A as cloneDeepWith,re as combine,oe as debounce,B as debounceFn,Ue as detectEmbed,Ye as fillWithDefault,ae as filter,ue as filterChanged,nt as fromEvent,Le as getExponentialDelay,je as getHighestQuality,tt as interval,Be as isHigher,Fe as isHigherOrEqual,U as isInvariantQuality,D as isLower,ze as isLowerOrEqual,y as isNonNullable,M as isNullable,Ln as loadVKLangPack,P as map,ce as mapTo,ne as merge,g as noop,Ce as now,rt as observableFrom,Je as observeElementSize,pe as once,be as pairwise,ee as safeStorage,de as tap,se as throttle,F as throttleFn,Ft as timeCodeToString,et as timeout,We as videoHeightToQuality,He as videoQualityToHeight,Ge as videoSizeToQuality};
|
|
6
|
+
var ye=Object.defineProperty;var Oe=(t,e)=>{for(var r in e)ye(t,r,{get:e[r],enumerable:!0})};var we="1.0.38-dev.df616f9c.0";var f=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(r=>typeof r=="function"?r():r.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var v=t=>{throw new Error(`${t} is value of unexpected type`)},Ee=t=>{};var g=()=>{};var l=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,r){let n;r?typeof r=="function"?n={next:r,error:g}:n={next:o=>r.next(o),error:o=>r.error?.(o)}:n={next:g,error:g};let s=typeof e=="function"?{next:o=>{try{e(o)}catch(a){n.next(a)}},error:o=>n.next(o)}:{next:o=>e.next(o),error:o=>e.error?e.error(o):n.next(o)},i;try{i=this._subscribe(s)}catch(o){s.error?.(o)}return new f().add(()=>{switch(s.next=g,s.error=g,typeof i){case"function":i();return;case"object":i.unsubscribe();return;case"undefined":return;default:return v(i)}})}pipe(...e){return e.reduce((r,n)=>n(r),this)}_subscribe(e){}};var I=class extends l{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(r){this.subscribers.forEach(n=>n.next(r))}error(r){this.subscribers.forEach(n=>n.error?.(r))}_subscribe(r){let n=this.keyCounter++;return this.subscribers.set(n,r),new f().add(()=>this.subscribers.delete(n))}};var V=class{constructor(){this.log$=new I;this.logs=[];this.log=e=>{let r={...e,timestamp:Date.now()};this.logs.push(r),this.log$.next(r)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...r)=>{let n;try{n=e(...r)}catch{n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(r=>({component:e,...r}))}};function Se(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function Ae(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function y(t){return typeof t<"u"&&t!==null}function Q(t){return t==null}function Re(t,e){if(!t?.length)throw new Error(e)}function Ce(t,e){if(t?.length)throw new Error(e)}var ke=(t,e,r)=>new Promise((n,s)=>{e.addEventListener("abort",()=>{a(),b.remove()});let i=()=>{a(),s()},o=()=>{a(),n()},a=()=>{u&&clearTimeout(u),b.removeEventListener("load",o),b.removeEventListener("error",i)},u;r&&(u=window.setTimeout(i,r));let b=document.createElement("script");b.addEventListener("load",o),b.addEventListener("error",i),b.src=t,document.head.appendChild(b)});var Le=typeof window.performance?.now=="function"?()=>window.performance.now():()=>Date.now();var Pe=(t,e)=>async(...r)=>{let n=e(...r),s=t.aborted,i;for(;!s&&!t.aborted;)try{let o=await n.next(i);s=o.done??!1,i=o.value}catch(o){await n.throw(o)}return i};var ee=(c=>(c.Unknown="Unknown",c.Yandex="Yandex",c.Chrome="Chrome",c.Chromium="Chromium",c.Firefox="Firefox",c.Safari="Safari",c.Opera="Opera",c.Edge="Edge",c.SamsungBrowser="SamsungBrowser",c.Rest="Rest",c))(ee||{}),te=(u=>(u.Unknown="Unknown",u.Android="Android",u.iPhone="iPhone",u.iPad="iPad",u.iPod="iPod",u.RestMobile="RestMobile",u.Mac="Mac",u.Desktop="Desktop",u))(te||{}),A=()=>{let{userAgent:t}=window.navigator,e=/yabrowser/i.test(t)?"Yandex":void 0,r=/samsungbrowser/i.test(t)?"SamsungBrowser":void 0,n=/chrome|crios/i.test(t)?"Chrome":void 0,s=/chromium/i.test(t)?"Chromium":void 0,i=/firefox|fxios/i.test(t)?"Firefox":void 0,o=/webkit|safari|khtml/i.test(t)?"Safari":void 0,a=/opr\//i.test(t)?"Opera":void 0,u=/edg/i.test(t)?"Edge":void 0,b=/android/i.test(t)?"Android":void 0,c=/iphone/i.test(t)?"iPhone":void 0,d=/ipad/i.test(t)?"iPad":void 0,E=/ipod/i.test(t)?"iPod":void 0,R=/mac/i.test(t)?"Mac":void 0,S=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(t)?"RestMobile":void 0;return{browser:e||r||i||a||u||n||s||o||"Rest",device:b||c||d||E||S||R||"Desktop"}},Me=(t=!1)=>{let r=["iPhone","iPad","iPod"].includes(A().device);if(!t)return r;let{userAgent:n,maxTouchPoints:s}=window.navigator;return!!(r||/macintosh/i.test(n)&&s>0)},Ne=()=>{let{userAgent:t}=window.navigator,e=t.match(/Version\/(\d+(\.\d+)?)/i);if(!e)return null;let r=e[1],n=parseFloat(r);return isNaN(n)?null:n},Ve=()=>{let{device:t}=A(),{userAgent:e,maxTouchPoints:r}=window.navigator,n=/linux/i.test(e),s=r>0;return t==="Desktop"&&n&&s},Qe=()=>A().device==="Android"||Ve(),De=()=>["Mac","iPhone","iPad","iPod"].includes(A().device),_e=()=>/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(navigator.appVersion??navigator.userAgent)||navigator?.userAgentData?.mobile;var Ue=(t,{start:e=0,factor:r=2,max:n=1/0,min:s=e,random:i=0}={})=>{let o=e;return o*=r**t,o*=1+(Math.random()*i*2-i),o=Math.round(o),o=Math.min(o,n),o=Math.max(o,s),o};var re={};Oe(re,{clear:()=>Ge,get:()=>Be,has:()=>je,isPersistent:()=>Fe,remove:()=>We,set:()=>ze});var O,h,D=`vk-videoplayer-dummy-key-${Math.random()}`,w=()=>{if(h!==void 0)return h;try{localStorage.setItem(D,"test"),localStorage.removeItem(D),h=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem(D),h=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)h=2;else throw e}else throw t}return h===2&&(O=new Map),h},Fe=()=>w()===0,Be=t=>{let e=w();switch(e){case 0:return localStorage.getItem(t)??void 0;case 1:return sessionStorage.getItem(t)??void 0;case 2:return O?.get(t);default:v(e)}},ze=(t,e)=>{let r=w();switch(r){case 0:try{localStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void O?.set(t,e);default:v(r)}},je=t=>{let e=w();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return O?.has(t)??!1;default:return v(e),!1}},We=t=>{let e=w();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:return void O?.delete(t);default:v(e)}},Ge=()=>{let t=w();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return O?.clear();default:v(t)}};var qe=()=>{let t,e;try{t=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?t=!0:(t=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let r=e?new URL(e).hostname:void 0;return{isEmbed:t,host:r}};var _=(c=>(c.INVARIANT="Invariant quality",c.Q_144P="144p",c.Q_240P="240p",c.Q_360P="360p",c.Q_480P="480p",c.Q_720P="720p",c.Q_1080P="1080p",c.Q_1440P="1440p",c.Q_2160P="2160p",c.Q_4320P="4320p",c))(_||{});var m={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"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}},He=(t,e)=>m[t].height>m[e].height,Ke=(t,e)=>m[t].height>=m[e].height,U=(t,e)=>m[t].height<m[e].height,$e=(t,e)=>m[t].height<=m[e].height,Ye=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:U(e,r)?1:-1)[0],ne=Object.keys(m).sort((t,e)=>U(t,e)?-1:1),Xe=(t,e=.02)=>[...ne].find(n=>m[n].height*(1+e)>=t),Je=({width:t,height:e})=>{let r=Math.min(t,e),n=Math.max(t,e);return ne.find(s=>{let i=m[s];return i.width>=n&&i.height>=r})},Ze=t=>m[t].height,F=t=>t==="Invariant quality",et=t=>t.every(e=>!F(e));function tt(t){if(F(t))throw new Error("Expected exact quality")}var rt=(t,e)=>{let r={};for(let n of Object.keys(e)){let s=e[n],i=t[n];Array.isArray(s)&&Array.isArray(i)?r[n]=i:typeof s=="object"&&typeof i=="object"?r[n]=rt(i,s):r[n]=n in t?i:s}return r};var Kt=t=>{let e="";return t>=3600&&(e+=Math.floor(t/3600)+"h",t=t%3600),t>=60&&(e+=Math.floor(t/60)+"m",t=t%60),t>0&&(e+=Math.floor(t)+"s"),e};function B(t,e=0,r){let n,s,i,o,a,u,b=0,c=!1,d=!1,E=!0,R=!e&&e!==0&&typeof window.requestAnimationFrame=="function";r&&(c=!!r.leading,d="maxWait"in r,i=r?.maxWait?Math.max(+r?.maxWait||0,e):i,E="trailing"in r?!!r.trailing:E);function S(p){let T=n,x=s;return n=s=void 0,b=p,o=t.apply(x,T),o}function C(p,T){return R?(a&&window.cancelAnimationFrame(a),window.requestAnimationFrame(p)):setTimeout(p,T)}function Te(p){if(R){window.cancelAnimationFrame(p);return}clearTimeout(p)}function ve(p){return b=p,a=C(k,e),c?S(p):o}function Ie(p){let T=p-u,x=p-b,Z=e-T;return d?Math.min(Z,i-x):Z}function X(p){let T=p-u,x=p-b;return u===void 0||T>=e||T<0||d&&x>=i}function k(){let p=Date.now();if(X(p))return J(p);a=C(k,Ie(p))}function J(p){return a=void 0,E&&n?S(p):(n=s=void 0,o)}function xe(){a!==void 0&&Te(a),b=0,n=u=s=a=void 0}function ge(){return a===void 0?o:J(Date.now())}function he(){return a!==void 0}function L(...p){let T=Date.now(),x=X(T);if(n=p,s=this,u=T,x){if(a===void 0)return ve(u);if(d)return a=C(k,e),S(u)}return a===void 0&&(a=C(k,e)),o}return L.cancel=xe,L.flush=ge,L.pending=he,L}var z=(t,e=0,r)=>B(t,e,{...{leading:!0,trailing:!0},...r,maxWait:e});var P=(t,e)=>{if(t===null||typeof t!="object")return t;let r=Array.isArray(t)?[]:{};for(let n in t){if(typeof e=="function"){let s=e(t[n],n,t,r);if(s!==void 0){r[n]=s;continue}}typeof t[n]=="object"?r[n]=P(t[n],e):r[n]=t[n]}return r};var nt=t=>P(t);var ot=300,it=(t,e=ot)=>new l(r=>{let{width:n,height:s}=t.getBoundingClientRect();if(r.next({width:n,height:s}),!window.ResizeObserver)return;let i=new ResizeObserver(z(o=>{let a=o[0];if(!a)return;let u,b;a.contentBoxSize&&a.contentBoxSize[0]?(b=a.contentBoxSize[0].blockSize,u=a.contentBoxSize[0].inlineSize):a.contentRect&&(u=a.contentRect.width,b=a.contentRect.height),y(u)&&y(b)&&r.next({width:u,height:b})},e));return i.observe(t),()=>i.disconnect()});var st=t=>{t.removeAttribute("src"),t.load()};var M=class extends I{constructor(r){super();this.value=r}next(r){super.next(this.value=r)}error(r){super.error(this.value=r)}getValue(){return this.value}_subscribe(r){let n=super._subscribe(r);return r.next(this.value),n}};function oe(t){return new l(e=>{let r={},n=Object.keys(t).length,s=i=>o=>{i in r||n--,r[i]=o,n===0&&e.next(r)};return Object.entries(t).reduce((i,[o,a])=>i.add(a.subscribe(s(o))),new f)})}function ie(...t){return new l(e=>t.reduce((r,n)=>r.add(n.subscribe(e)),new f))}var at=t=>new l(e=>{let r=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},t);return()=>window.clearTimeout(r)});var lt=t=>new l(e=>{let r=window.setInterval(()=>e.next(),t);return()=>{r&&(window.clearInterval(r),r=void 0)}});var ut=t=>new l(e=>{t.forEach(r=>e.next(r))});var ct=(t,e)=>new l(r=>{let n=s=>r.next(s);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)});function se(t){return e=>new l(r=>e.subscribe(new j(r,t)))}var j=class{constructor(e,r){this.destination=e;this.size=r;this.lastValues=[]}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 pt={leading:!1,trailing:!0};function ae(t,e=pt){return r=>new l(n=>r.subscribe(new W(n,t,e)))}var W=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,y(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(r){if(this.destination.error)this.destination.error(r);else throw r}this.timeout=void 0},this.time)}error(e){this.destination.error?.(e)}};var bt={leading:!0,trailing:!1};function le(t,e=bt){return r=>new l(n=>r.subscribe(new G(n,t,e)))}var G=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,Q(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){this.destination.error?.(e)}};function ue(t){return e=>new l(r=>e.subscribe(new q(r,t)))}var q=class{constructor(e,r){this.destination=e;this.predicate=r}next(e){let r;try{r=this.predicate(e)}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function pe(t=(e,r)=>e===r){return e=>new l(r=>e.subscribe(new H(r,t)))}var ce={},H=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=ce}next(e){let r;try{r=this.lastValue===ce||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function N(t){return e=>new l(r=>e.subscribe(new K(r,t)))}var K=class{constructor(e,r){this.destination=e;this.mapper=r}next(e){let r;try{r=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(r)}error(e){this.destination.error?.(e)}};function be(t){return N(()=>t)}function de(){return t=>new l(e=>{let r=!1,n=!1,s=t.subscribe(i=>{r||(r=!0,e.next(i)),n&&s.unsubscribe()},i=>{r=!0,e.error?.(i),n&&s.unsubscribe()});return n=!0,r&&s.unsubscribe(),s})}function fe(){return t=>new l(e=>t.subscribe(new $(e)))}var $=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let r=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([r,e])}error(e){this.destination.error?.(e)}};function me(t){return e=>new l(r=>e.subscribe(new Y(r,t)))}var Y=class{constructor(e,r){this.destination=e;this.effect=r}next(e){try{this.effect(e)}catch(r){throw this.error(r),r}this.destination.next(e)}error(e){this.destination.error?.(e)}};var dt=(a=>(a.NETWORK="network",a.VIDEO_PIPELINE="video_pipeline",a.EXTERNAL_API="external_api",a.PARSER="parser",a.DOM="dom",a.WTF="wtf",a.FATAL="fatal",a))(dt||{});var ft=(d=>(d.Armenian="58",d.Azerbaijani="57",d.Belarusian="114",d.English="3",d.Kazakh="97",d.Portuguese="73",d.Russian="0",d.Spanish="4",d.Ukrainian="1",d.Uzbek="65",d.Vietnamese="75",d))(ft||{}),mt="vk.com",Un=async(t,e,r)=>{let n=new URL(`https://${mt}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),t!==void 0&&n.searchParams.set("lang",t);let i=await(await fetch(n.toString())).json();return Tt(i,r)},Tt=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,n])=>[r.substring(`${e}_`.length),vt(n)])),vt=t=>Array.isArray(t)?t[0]:t;var It=(r=>(r.RU="ru",r.EN="en",r))(It||{});export{ee as CurrentClientBrowser,te as CurrentClientDevice,dt as ErrorCategory,It as InterfaceLanguage,V as Logger,l as Observable,I as Subject,f as Subscription,we as VERSION,ft as VKNumericLanguage,M as ValueSubject,_ as VideoQuality,Pe as abortable,ke as addScript,et as areQualitiesExact,Ce as assertEmptyArray,v as assertNever,Se as assertNonNullable,Re as assertNotEmptyArray,Ae as assertNullable,tt as assertQualityIsExact,se as buffer,Ee as checkNever,st as clearVideoElement,nt as cloneDeep,P as cloneDeepWith,oe as combine,ae as debounce,B as debounceFn,qe as detectEmbed,rt as fillWithDefault,ue as filter,pe as filterChanged,ct as fromEvent,A as getCurrentBrowser,Ue as getExponentialDelay,Ye as getHighestQuality,Ne as getIOSVersion,lt as interval,Qe as isAndroid,He as isHigher,Ke as isHigherOrEqual,Me as isIOS,F as isInvariantQuality,U as isLower,$e as isLowerOrEqual,De as isMacLike,_e as isMobile,y as isNonNullable,Q as isNullable,Un as loadVKLangPack,N as map,be as mapTo,ie as merge,g as noop,Le as now,ut as observableFrom,it as observeElementSize,de as once,fe as pairwise,re as safeStorage,me as tap,le as throttle,z as throttleFn,Kt as timeCodeToString,at as timeout,Xe as videoHeightToQuality,Ze as videoQualityToHeight,Je as videoSizeToQuality};
|
package/package.json
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare enum CurrentClientBrowser {
|
|
2
|
+
Unknown = "Unknown",
|
|
3
|
+
Yandex = "Yandex",
|
|
4
|
+
Chrome = "Chrome",
|
|
5
|
+
Chromium = "Chromium",
|
|
6
|
+
Firefox = "Firefox",
|
|
7
|
+
Safari = "Safari",
|
|
8
|
+
Opera = "Opera",
|
|
9
|
+
Edge = "Edge",
|
|
10
|
+
SamsungBrowser = "SamsungBrowser",
|
|
11
|
+
Rest = "Rest"
|
|
12
|
+
}
|
|
13
|
+
export declare enum CurrentClientDevice {
|
|
14
|
+
Unknown = "Unknown",
|
|
15
|
+
Android = "Android",
|
|
16
|
+
iPhone = "iPhone",
|
|
17
|
+
iPad = "iPad",
|
|
18
|
+
iPod = "iPod",
|
|
19
|
+
RestMobile = "RestMobile",
|
|
20
|
+
Mac = "Mac",
|
|
21
|
+
Desktop = "Desktop"
|
|
22
|
+
}
|
|
23
|
+
export type ICurrentBrowserInfo = {
|
|
24
|
+
browser: CurrentClientBrowser;
|
|
25
|
+
device: CurrentClientDevice;
|
|
26
|
+
};
|
|
27
|
+
export declare const getCurrentBrowser: () => ICurrentBrowserInfo;
|
|
28
|
+
export declare const isIOS: (checkForceDesktop?: boolean) => boolean;
|
|
29
|
+
export declare const getIOSVersion: () => number | null;
|
|
30
|
+
export declare const isAndroidForcedDesktop: () => boolean;
|
|
31
|
+
export declare const isAndroid: () => boolean;
|
|
32
|
+
export declare const isMacLike: () => boolean;
|
|
33
|
+
export declare const isMobile: () => any;
|
package/types/utils/index.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ export { addScript } from './addScript';
|
|
|
6
6
|
export type { Milliseconds, bps, Byte, Seconds, Kbps, Mbps, Percentage } from './semanticTypes';
|
|
7
7
|
export { now } from './now';
|
|
8
8
|
export { abortable } from './abortable';
|
|
9
|
-
export {
|
|
9
|
+
export { getCurrentBrowser, CurrentClientBrowser, CurrentClientDevice, isIOS, getIOSVersion, isMacLike, isMobile, isAndroid } from './detectBrowser';
|
|
10
|
+
export type { ICurrentBrowserInfo } from './detectBrowser';
|
|
10
11
|
export { getExponentialDelay, ExponentialBackoffConfig } from './exponentialBackoff';
|
|
11
12
|
export * as safeStorage from './iframeSafeStorage';
|
|
12
13
|
export { detectEmbed } from './detectEmbed';
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
export declare enum CurrentClientBrowser {
|
|
2
|
-
Unknown = "Unknown",
|
|
3
|
-
Yandex = "Yandex",
|
|
4
|
-
Chrome = "Chrome",
|
|
5
|
-
Chromium = "Chromium",
|
|
6
|
-
Firefox = "Firefox",
|
|
7
|
-
Safari = "Safari",
|
|
8
|
-
Opera = "Opera",
|
|
9
|
-
Edge = "Edge",
|
|
10
|
-
SamsungBrowser = "SamsungBrowser",
|
|
11
|
-
Rest = "Rest"
|
|
12
|
-
}
|
|
13
|
-
export declare enum CurrentClientDevice {
|
|
14
|
-
Unknown = "Unknown",
|
|
15
|
-
Android = "Android",
|
|
16
|
-
iPhone = "iPhone",
|
|
17
|
-
iPad = "iPad",
|
|
18
|
-
iPod = "iPod",
|
|
19
|
-
RestMobile = "RestMobile",
|
|
20
|
-
Mac = "Mac",
|
|
21
|
-
Desktop = "Desktop"
|
|
22
|
-
}
|
|
23
|
-
export declare class ClientChecker {
|
|
24
|
-
private _currentBrowser;
|
|
25
|
-
private _currentDevice;
|
|
26
|
-
private _iosVersion;
|
|
27
|
-
private _macVersion;
|
|
28
|
-
private _maxTouchPoints;
|
|
29
|
-
private _isHdr;
|
|
30
|
-
constructor();
|
|
31
|
-
get browser(): CurrentClientBrowser;
|
|
32
|
-
get device(): CurrentClientDevice;
|
|
33
|
-
get isTouch(): boolean;
|
|
34
|
-
get isIOS(): boolean;
|
|
35
|
-
get isMac(): boolean;
|
|
36
|
-
get isApple(): boolean;
|
|
37
|
-
get isIphoneOrOldIpad(): boolean;
|
|
38
|
-
get isAndroid(): boolean;
|
|
39
|
-
get isMobile(): boolean;
|
|
40
|
-
get iOSVersion(): number | undefined;
|
|
41
|
-
get macVersion(): number | undefined;
|
|
42
|
-
get isYandex(): boolean;
|
|
43
|
-
get isSafari(): boolean;
|
|
44
|
-
get isSamsungBrowser(): boolean;
|
|
45
|
-
get isHDR(): boolean;
|
|
46
|
-
detect(): void;
|
|
47
|
-
private detectBrowser;
|
|
48
|
-
private detectDevice;
|
|
49
|
-
private detectIOSVersion;
|
|
50
|
-
private detectMacVersion;
|
|
51
|
-
}
|
|
52
|
-
export declare const CC: ClientChecker;
|