@vkontakte/videoplayer-statistics 1.0.52-dev.f8fa60d9.0 → 1.0.53-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es2018.cjs.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @vkontakte/videoplayer-statistics v1.0.52-dev.f8fa60d9.0
3
- * Thu, 15 Aug 2024 18:55:46 GMT
4
- * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-52/doc/
2
+ * @vkontakte/videoplayer-statistics v1.0.53-beta.0
3
+ * Wed, 21 Aug 2024 12:58:20 GMT
4
+ * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-53/doc/
5
5
  */
6
- "use strict";var V=Object.defineProperty;var he=Object.getOwnPropertyDescriptor;var fe=Object.getOwnPropertyNames;var ge=Object.prototype.hasOwnProperty;var me=(n,e)=>{for(var i in e)V(n,i,{get:e[i],enumerable:!0})},be=(n,e,i,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of fe(e))!ge.call(n,o)&&o!==i&&V(n,o,{get:()=>e[o],enumerable:!(t=he(e,o))||t.enumerable});return n};var ve=n=>be(V({},"__esModule",{value:!0}),n);var Pe={};me(Pe,{ApiEnv:()=>E,ConnectionType:()=>L,ContentType:()=>k,InteractiveInterfaceClick:()=>U,OneStat:()=>M,Quality:()=>w,SeekAction:()=>$,VERSION:()=>x});module.exports=ve(Pe);var E=(r=>(r.PROD="prod",r.VK_ALIAS="vk_alias",r.VIDEOTEST="videotest",r.TEST="test",r.OKCDN="okcdn",r.AUTO="auto",r))(E||{}),w=(c=>(c.Q144P="mobile",c.Q240P="lowest",c.Q360P="low",c.Q480P="medium",c.Q720P="high",c.Q1080P="fullhd",c.Q1440P="quadhd",c.Q2160P="ultrahd",c.UNKNOWN="unknown",c))(w||{}),k=(l=>(l.MP4="mp4",l.DASH="dash",l.DASH_SEP="dash_sep",l.ONDEMAND_DASH="ondemand_dash",l.HLS="hls",l.ONDEMAND_HLS="ondemand_hls",l.WEBM="webm",l.AV1="av1",l.ONDEMAND_DASH_LIVE="ondemand_dash_live",l.ONDEMAND_HLS_LIVE="ondemand_hls_live",l.WEBRTC="webrtc",l.UNKNOWN="unknown",l.RTMP="rtmp",l))(k||{});var L=(t=>(t.HTTP1="http1",t.HTTP2="http2",t.HTTP3="http3",t))(L||{});var $=(h=>(h.SLIDER="slider",h.DOUBLE_TAP="double_tap",h.TIME_CODE="time_code",h.EPISODE="episode",h.REWIND="rewind",h.LIVE="live",h.UNKNOWN="unknown",h))($||{}),U=(d=>(d.GRAPH_SHOW="iGraphShow",d.GRAPH_HIDE="iGraphHide",d.NEXT_AREA="iNextChapterArea",d.NEXT_BUTTON="iNextChapterBtn",d.WATCH_AGAIN="iWatchAgainBtn",d))(U||{}),Y={action_play:"ap",action_play_interactive:"api",first_bytes:"fb",player_ready:"pr",first_frame:"ff",seek:"sk",watch_coverage_record:"wr",watch_coverage_live:"wl",empty_buffer:"eb",action_stop:"as",close_at_empty_buffer:"cb",content_error:"er",player_interface_click:"pc",next_movie:"nm",track_switch:"ts",failover:"fo"},X={vsid:"si",isid:"is",vid:"vi",place:"pl",quality:"qt",cdn_host:"ch",stat_type:"st",param:"pm",vk_app_id:"va",track_code:"tc",connection_type:"cnt",connection_reused:"cr",cached_data:"cd",live:"lv",muted:"mu",mode:"mo",subtitles:"sb",failover:"fo",download_speed:"ds",manual_quality:"mq",ref_domain:"rd",direct_url:"du"},J={unknown:"un",mobile:"m",lowest:"ls",low:"l",medium:"md",high:"h",fullhd:"f",quadhd:"q",ultrahd:"u"},Z={pip:"pi",fullscreen:"fs",external:"ex",prefetch:"pr",airplay:"ap",chromecast:"cc",invisible:"iv"};var ee=require("@vkontakte/videoplayer-shared"),Ie={apiEnv:"vk_alias",requestRetryCount:1,firstFlushTime:5e3,flushDebounceTime:1e4,flushMaxWait:6e4,storageExpiration:36*60*60*1e3,watchCoverageInterval:15e3,disabledOperations:[],disabledCustomFields:[],shorten:!0,maxLoops:100,embedUrlParams:[],useBeacon:!0,synchronizeTime:!0,debugLog:!1,backoff:{start:1e3,factor:1.5,max:5*60*1e3,random:.1}},te=n=>(0,ee.fillWithDefault)(n,Ie);function W(){let n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),e=new Array(36),i=0,t,o;for(o=0;o<36;o++)o===8||o===13||o===18||o===23?e[o]="-":o===14?e[o]="4":(i<=2&&(i=33554432+Math.random()*16777216|0),t=i&15,i=i>>4,e[o]=n[o===19?t&3|8:t]);return e.join("")}var a=require("@vkontakte/videoplayer-shared"),B=require("@vkontakte/videoplayer-shared");var ie=n=>{var o;let{operation:e,custom:i}=n,t=Object.fromEntries(Object.entries(i).map(([d,r])=>{var c,g,m;let h=(c=X[d])!=null?c:d,f=r;return r&&(d==="mode"?f=(g=Z[r])!=null?g:r:d==="quality"&&(f=(m=J[r])!=null?m:r)),[h,f]}));return{...n,operation:(o=Y[e])!=null?o:e,custom:t}};var x="1.0.52-dev.f8fa60d9.0",oe="CIOPGQJGDIHBABABA",H={prod:"https://api.ok.ru",vk_alias:"https://api.mycdn.me",videotest:"https://videotestapi.ok.ru/api",test:"https://apitest.ok.ru",okcdn:"https://api.okcdn.ru",auto:""};var I=require("@vkontakte/videoplayer-shared");var C=class{constructor(e){this.consequentAuthErrors=0;this.authorized$=new I.ValueSubject(!1);this.params=e}async authorize(e){return this.authToken=e!=null?e:await this.refreshAuthToken(),this._authorizeWithBackoff()}logBeacon(e){let i="log.externalLog",t=this.createLogParams(e),o=this.sessionKey;if(!o)return;this.params.apiTransport.sendBeacon(i,t,o)||this.logRequest(e)}async logRequest(e){var r;let i="log.externalLog",t=this.createLogParams(e),o=(r=this.sessionKey)!=null?r:await this._authorizeWithBackoff();if(!o)return;let d=async(h,f=this.params.config.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(i,t,o)}catch(c){if(!c||!("error_code"in c)){this.params.error$.next({id:"logRequestUnknown",category:I.ErrorCategory.NETWORK,message:`Unknown ${i} error`,thrown:c});return}let g=c==null?void 0:c.error_code;switch(g){case 102:case 103:case 104:return this.authorized$.next(!1),this.sessionKey=await this._authorizeWithBackoff(),f>0?d(h,f-1):void 0;case 401:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorizeWithBackoff(),f>0?d(h,f-1):void 0;default:{this.params.error$.next({id:`LogRequest#${g}`,category:I.ErrorCategory.EXTERNAL_API,message:`${i} error`,data:c});return}}}};return d(e)}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}async refreshAuthToken(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=this.params.refreshAuthToken().finally(()=>{this.refreshAuthTokenPromise=void 0})),this.refreshAuthTokenPromise}createLogParams(e){return{collector:"ok.mobile.apps.video",data:JSON.stringify({application:`@vkontakte/videoplayer-statistics:${x}`,platform:this.params.mobile?"M_WEB":"WEB",items:this.params.config.shorten?e.map(ie):e})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();let e=(0,I.getExponentialDelay)(this.consequentAuthErrors,this.params.config.backoff);return new Promise(i=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout(()=>{this._authorize().then(i).catch(t=>this.params.error$.next({id:"AuthorizeBackoff",category:I.ErrorCategory.NETWORK,message:"Otherwise unhandled error in authorization",thrown:t})).finally(()=>this.backoffTimeoutId=0)},e))})}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);let e="auth.anonymLogin",i={session_data:{version:2,device_id:this.params.uuid,client_version:x.split("-")[0],client_type:"SDK_JS"}};return this.authToken!==void 0&&(i.session_data.auth_token=this.authToken,i.session_data.version=3),this.authorizePromise=this.params.apiTransport.sendRequest(e,i).then(t=>{var o;return(!t||!t.session_key)&&this.params.error$.next({id:"AuthorizeFailed",category:I.ErrorCategory.EXTERNAL_API,message:"No session key",data:t}),this.sessionKey=(o=t==null?void 0:t.session_key)!=null?o:void 0,this.sessionKey}).catch(async t=>{this.sessionKey=void 0;let o=t==null?void 0:t.error_code;switch(o){case 401:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}o?this.params.error$.next({id:`Authorize#${o}`,category:I.ErrorCategory.EXTERNAL_API,message:"authorize error",data:t}):this.params.error$.next({id:"AuthorizeUnknown",category:I.ErrorCategory.NETWORK,message:"authorize error",thrown:t})}).finally(()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise}};var S=require("@vkontakte/videoplayer-shared");var T=class{constructor(e){this.params=e,this.apiKey=e.apiKey,this.apiEnv=e.config.apiEnv,this.apiBaseUrl=H[this.apiEnv],this.timeSynchronisation=e.timeSynchronisation,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){var e;if(this.apiEnv!=="auto"||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{let i=atob("aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ="),o=await(await fetch(i,{method:"GET",mode:"cors",cache:"no-cache"})).json(),d=(e=o==null?void 0:o.Answer[0])==null?void 0:e.data;if(!d)throw new Error("Wrong DNS response");return d}catch(i){return this.params.error$.next({id:"OneStat:ApiTransport:resolveApiBaseUrl",category:S.ErrorCategory.NETWORK,message:"Unhandled resolve api base url error",thrown:i}),H.vk_alias}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(e,i,t){if(!window.Blob||!window.navigator.sendBeacon)return!1;let o=this._prepareQueryParams({method:e,queryParams:i,sessionKey:t}),d=new window.Blob([o.toString()],{type:"application/x-www-form-urlencoded"});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,d)}catch(r){this.params.error$.next({id:"OneStat:ApiTransport:sendBeacon",category:S.ErrorCategory.NETWORK,message:"Unhandled beacon error",thrown:r,data:{method:e,params:i}})}return!1}async sendRequest(e,i,t){let o=(0,S.now)(),d=r=>{if(r instanceof TypeError&&["Failed to fetch","NetworkError when attempting to fetch resource."].includes(r.message)){this.params.error$.next({id:"Network",category:S.ErrorCategory.NETWORK,message:"Request failed",thrown:r});return}this.params.error$.next({id:"OneStat:ApiTransport:sendRequest",category:S.ErrorCategory.NETWORK,message:"Unhandled request error",thrown:r,data:{method:e,params:i,sessionKey:t,time:(0,S.now)()-o}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),fetch(`${this.apiBaseUrl}/fb.do`,{method:"post",headers:{"Content-type":"application/x-www-form-urlencoded"},body:this._prepareQueryParams({method:e,queryParams:i,sessionKey:t})}).then(r=>{var g,m;let h=Number(r.headers.get("content-length"))===0,f=new Date((g=r.headers.get("date"))!=null?g:"").getTime(),c=(0,S.now)()-o;if(isFinite(f)&&((m=this.timeSynchronisation)==null||m.addServerTime(f,c)),!h)return r.json().then(s=>Object.prototype.hasOwnProperty.call(s,"error_msg")?Promise.reject(s):s,d)},d)}_prepareQueryParams(e){let i=new URLSearchParams({format:"JSON",method:e.method,application_key:this.apiKey});return e.sessionKey!==void 0&&i.append("session_key",e.sessionKey),Object.entries(e.queryParams).forEach(([t,o])=>i.append(t,typeof o=="string"?o:JSON.stringify(o))),i}};var v=require("@vkontakte/videoplayer-shared"),R="onestat_events",K=n=>e=>e.timestamp+n>=(0,v.now)(),O=class{constructor(e){this.unsaltedStorage=[];this.isPaused=!1;this.isUrgent=e=>{let{operation:i}=e;return["action_play","watch_coverage_record","watch_coverage_live"].includes(i)};this.params=e,this.api=e.api,this.error$=e.error$,this.userSalt=e.userSalt,this.loggerDebugLog=e.debugLogger.createComponentLog("stat logger"),this.firstFlush=(0,v.debounceFn)(()=>this.safeFlush(),this.params.config.firstFlushTime,{maxWait:this.params.config.firstFlushTime});let i=v.safeStorage.isPersistent()?this.params.config.flushMaxWait:0;this.debouncedFlush=(0,v.debounceFn)(()=>this.safeFlush(),this.params.config.flushDebounceTime,{maxWait:i}),this.subscription=this.api.authorized$.subscribe(t=>{t&&this.debouncedFlush()}),this.housekeepStorage()}safeFlush(){var e;try{this.flush()}catch(i){this.error$.next({id:"LoggerError",category:v.ErrorCategory.WTF,message:(e=String(i))!=null?e:"Unknown logger error",thrown:i})}}readFromStorage(){let e=v.safeStorage.get(R);try{return e?JSON.parse(e):{}}catch(i){}return{}}addToStorage(e){var d;if(!this.userSalt){this.unsaltedStorage.push(e);return}let i=this.readFromStorage(),o=((d=i[this.userSalt])!=null?d:[]).filter(K(this.params.config.storageExpiration));v.safeStorage.set(R,JSON.stringify({...i,[this.userSalt]:[...o,e]}))}getFromStorage(){var t;return this.userSalt?((t=this.readFromStorage()[this.userSalt])!=null?t:[]).filter(K(this.params.config.storageExpiration)):this.unsaltedStorage}markStorageSent(){if(!this.userSalt){this.unsaltedStorage=[];return}let e=this.readFromStorage();delete e[this.userSalt],v.safeStorage.set(R,JSON.stringify(e))}housekeepStorage(){let e=this.readFromStorage();for(let[i,t]of Object.entries(e)){let o=t.filter(K(this.params.config.storageExpiration));o.length?e[i]=o:delete e[i],this.loggerDebugLog({message:`${t.length} retrieved from storage, ${o.length} of them actual`})}v.safeStorage.set(R,JSON.stringify(e))}log(e){this.addToStorage(e),!this.isPaused&&(this.isUrgent(e)?this.flush():this.lastVsid!==e.custom.vsid?this.firstFlush():this.debouncedFlush(),this.lastVsid=e.custom.vsid)}flush(e=!1){let i=this.getFromStorage();i.length!==0&&(this.api.authorized$.getValue()?(e&&this.params.config.useBeacon?(this.loggerDebugLog({message:`Flushing ${i.length} events through beacon`}),this.api.logBeacon(i)):(this.loggerDebugLog({message:`Flushing ${i.length} events`}),this.api.logRequest(i)),this.markStorageSent()):this.api.authorize(),this.firstFlush.cancel(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe(),this.firstFlush.cancel(),this.debouncedFlush.cancel()}};var u=require("@vkontakte/videoplayer-core"),q=require("@vkontakte/videoplayer-shared");var se=n=>n&&{[u.VideoQuality.INVARIANT]:"unknown",[u.VideoQuality.Q_144P]:"mobile",[u.VideoQuality.Q_240P]:"lowest",[u.VideoQuality.Q_360P]:"low",[u.VideoQuality.Q_480P]:"medium",[u.VideoQuality.Q_720P]:"high",[u.VideoQuality.Q_1080P]:"fullhd",[u.VideoQuality.Q_1440P]:"quadhd",[u.VideoQuality.Q_2160P]:"ultrahd",[u.VideoQuality.Q_4320P]:"unknown"}[n],z=n=>n&&{[u.HttpConnectionType.HTTP1]:"http1",[u.HttpConnectionType.HTTP2]:"http2",[u.HttpConnectionType.QUIC]:"http3"}[n],re=n=>{if(n!==void 0)switch(n){case u.VideoFormat.MPEG:return"mp4";case u.VideoFormat.DASH:case u.VideoFormat.DASH_LIVE:case u.VideoFormat.DASH_STREAMS:return"dash";case u.VideoFormat.DASH_SEP:return"dash_sep";case u.VideoFormat.DASH_ONDEMAND:return"ondemand_dash";case u.VideoFormat.DASH_WEBM:case u.VideoFormat.DASH_LIVE_WEBM:return"webm";case u.VideoFormat.DASH_WEBM_AV1:return"av1";case u.VideoFormat.DASH_LIVE_CMAF:return"ondemand_dash_live";case u.VideoFormat.HLS:case u.VideoFormat.HLS_LIVE:return"hls";case u.VideoFormat.HLS_ONDEMAND:return"ondemand_hls";case u.VideoFormat.HLS_LIVE_CMAF:return"ondemand_hls_live";case u.VideoFormat.WEB_RTC_LIVE:return"webrtc";default:return(0,q.assertNever)(n)}},N=n=>{if(n!==void 0)switch(n){case u.Surface.NONE:case u.Surface.INLINE:return;case u.Surface.FULLSCREEN:return"fullscreen";case u.Surface.SECOND_SCREEN:return"chromecast";case u.Surface.PIP:return"pip";case u.Surface.INVISIBLE:return"invisible";default:return(0,q.assertNever)(n)}},ne=n=>{switch(n){case"slow-2g":return"poor";case"2g":return"poor";case"3g":return"good";case"4g":return"excellent"}};var D=class{constructor(e){this.offset=void 0;this.offset=e}getOffset(){var e;return(e=this.offset)!=null?e:0}setOffset(e){this.offset=e}now(){var e;return Date.now()+((e=this.offset)!=null?e:0)}date(e=new Date){var i;return e.setTime(e.getTime()+((i=this.offset)!=null?i:0)),e}addServerTime(e,i){let t=Date.now(),o=e-t-i/2;if(Math.abs(o)<1e3){this.offset=0;return}this.offset===void 0?this.offset=Math.round(o):this.offset=Math.round(.2*o+(1-.2)*this.offset)}};var ae=()=>Math.floor(Math.random()*4294967296).toString(36).padStart(7,"0"),de=()=>Math.floor(Math.random()*18446744073709552e3).toString(36).padStart(13,"0");var Q=require("@vkontakte/videoplayer-core"),p=require("@vkontakte/videoplayer-shared"),ue=(n,e)=>new p.Observable(i=>{let t=new p.Subscription,o=(0,p.merge)((0,p.fromEvent)(window,"beforeunload"),n.events.willDestruct$),d=new p.ValueSubject(void 0),r;t.add(n.info.isLive$.pipe((0,p.filterChanged)()).subscribe(P=>{r&&(r.unsubscribe(),d.next(void 0)),P?r=n.info.liveTime$.pipe((0,p.map)(F=>F&&F/1e3)).subscribe(d):r=n.info.position$.subscribe(d),t.add(r)}));let{playing$:h,paused$:f}=n.events,c=n.events.willSeek$.pipe((0,p.filter)(()=>n.info.playbackState$.getValue()===Q.PlaybackState.PLAYING)),g=n.events.seeked$.pipe((0,p.filter)(()=>n.info.playbackState$.getValue()===Q.PlaybackState.PLAYING)),m=!1,s=new p.Subject;t.add(c.subscribe(()=>{m||s.next(),m=!0})),t.add(g.subscribe(()=>m=!1));let l=new p.Subject,b=new p.Subject,y=(0,p.merge)(h,g,l),_=(0,p.merge)(f,s,o,n.events.looped$,b),A,ce=()=>A=d.getValue(),le=()=>{let P=d.getValue();(0,p.isNullable)(A)||A===P||(0,p.isNullable)(P)||(i.next({from:A,to:P}),A=void 0)},pe=()=>{b.next(),l.next()};if(t.add(y.subscribe(ce)),t.add(_.subscribe(le)),e.forceInterval&&isFinite(e.forceInterval)){let P=0;t.add(y.subscribe(()=>P=window.setTimeout(pe,e.forceInterval))),t.add(_.subscribe(()=>window.clearTimeout(P)))}return t});var ye="_one-stat_",j=`${ye}uuid`,G=()=>{let n=new a.Subscription;return{subscription:n,subscribe:(e,i)=>{e&&n.add(e.subscribe(i))}}},M=class{constructor(e,i){this.subscription=new a.Subscription;this.debugLogger=new B.Logger;this.oneStatDebugLog=this.debugLogger.createComponentLog("onestat");this.loopCounter=0;this.disabled=!1;this.vsid$=new a.ValueSubject(void 0);this.isid$=new a.ValueSubject(void 0);this.seekAction$=new a.ValueSubject("unknown");var f,c,g;this.statContext=e,this.config=te((f=i.config)!=null?f:{}),(0,a.isNonNullable)(i.apiEnv)&&(this.config.apiEnv=i.apiEnv),this.config.synchronizeTime&&(this.timeSynchronisation=new D);let t=new a.Subject;this.experimental={error$:t};let o=a.safeStorage.get(j);o?o.startsWith('"')&&o.endsWith('"')?(this.uuid=o.replaceAll('"',""),a.safeStorage.set(j,this.uuid)):this.uuid=o:(this.uuid=W(),a.safeStorage.set(j,this.uuid)),this.resetViewSession(),i.useIsid&&this.isid$.next((c=i.isid)!=null?c:de());let d=new T({apiKey:oe,config:this.config,error$:t,timeSynchronisation:this.timeSynchronisation});this.api=new C({config:this.config,apiTransport:d,refreshAuthToken:i.refreshAuthToken,mobile:(g=this.statContext.mobile)!=null?g:!1,uuid:this.uuid,error$:t}),this.logger=new O({config:this.config,debugLogger:this.debugLogger,api:this.api,error$:t,userSalt:i.userSalt});let{isEmbed:r,host:h}=(0,B.detectEmbed)();this.isEmbed=r,this.embedParent=h,this.subscribe()}updateContext(e){this.statContext={...this.statContext,...e}}attachTo(e){let i=new a.Subscription,t=(s,l)=>i.add(s.subscribe(l));t(e.events.willStart$,()=>{let s=e.info.position$.getValue();this.logActionPlay({position:s}),this.statContext.projectId&&this.logActionPlayInteractive()}),t(e.events.looped$,()=>{this.resetViewSession(),++this.loopCounter>this.config.maxLoops&&(this.disabled=!0),this.logActionPlay({position:e.info.position$.getValue()})}),t(e.events.seeked$,()=>{this.logSeek({action:this.seekAction$.getValue(),time:e.info.position$.getValue()}),this.seekAction$.next("unknown")}),t(e.events.paused$,()=>{this.logPause({position:e.info.position$.getValue()})}),t(e.events.willResume$,()=>{this.logPlay()}),t(e.events.started$,()=>{this.statContext.clip&&this.logWatchCoverageRecord({start:0,end:0})}),t(e.events.playing$,()=>{this.logPlaying()}),t(ue(e,{forceInterval:this.config.watchCoverageInterval}),s=>{let l=e.info.isLive$.getValue(),b={start:parseFloat(s.from.toFixed(3)),end:parseFloat(s.to.toFixed(3))};l?this.logWatchCoverageLive(b):this.logWatchCoverageRecord(b)});let o;t(e.info.isStalled$,s=>{s?o=(0,a.now)():((0,a.isNonNullable)(o)&&this.logEmptyBuffer({duration:(0,a.now)()-o}),o=void 0)});let d=!1;i.add(e.events.fatalError$.pipe((0,a.once)()).subscribe(()=>d=!0)),t(e.events.willStop$,()=>{if(e.info.isStalled$.getValue()){let l=(0,a.isNonNullable)(o)?(0,a.now)()-o:void 0;this.logCloseAtEmptyBuffer({duration:l!=null?l:0}),o=void 0}else d||this.logActionStop()}),t(e.events.managedError$,({id:s})=>{this.logError({fatal:!1,errorType:s})}),t(e.events.fatalError$,({id:s})=>{this.logError({fatal:!0,errorType:s})});let r,h,f=!1;t(e.events.firstBytes$,s=>{r=(0,a.now)(),this.logFirstBytes({time:s})}),t(e.events.willStart$,()=>h=(0,a.now)()),t(e.info.currentBuffer$,s=>{!f&&s&&s.end-s.start>0&&(0,a.isNonNullable)(r)&&(this.logPlayerReady({duration:(0,a.now)()-r}),f=!0)}),t(e.events.firstFrame$,()=>{(0,a.isNonNullable)(r)&&!f&&(this.logPlayerReady({duration:(0,a.now)()-r}),f=!0),(0,a.isNonNullable)(h)&&this.logFirstFrame({time:(0,a.now)()-h})});let c;t(e.info.currentVideoStream$,s=>{s&&(c&&s.id!==c&&this.logTrackSwitch(s),c=s.id)});let g;t(e.info.currentAudioStream$,s=>{s&&(g&&s.id!==g&&this.logTrackSwitch(s),g=s.id)}),t(e.info.atLiveEdge$,s=>this.updateContext({liveEdge:s})),t((0,a.combine)({muted:e.info.muted$,volume:e.info.volume$}),({muted:s,volume:l})=>this.updateContext({audible:!s&&l>0})),t(e.info.currentQuality$,s=>this.updateContext({quality:se(s)})),t(e.info.isAutoQualityEnabled$,s=>this.updateContext({autoQuality:s})),t(e.info.currentFormat$,s=>this.updateContext({contentType:re(s)})),t(e.info.currentPlaybackRate$,s=>this.updateContext({rate:s})),t(e.info.is3DVideo$,s=>this.updateContext({is3d:s}));let m;return t(e.info.hostname$,s=>{let l=m!==void 0&&m!==s;this.updateContext({cdnHostname:s,failover:l}),l&&this.logFailover(s),m=s}),t(e.info.throughputEstimation$,s=>this.updateContext({downloadSpeed:s})),t(e.info.httpConnectionType$,s=>{this.statContext.firstConnectionType||this.updateContext({firstConnectionType:z(s)}),this.updateContext({connectionType:z(s)})}),t(e.info.httpConnectionReused$,s=>{(0,a.isNullable)(this.statContext.firstConnectionReused)&&this.updateContext({firstConnectionReused:s}),this.updateContext({connectionReused:s})}),t(e.info.surface$,s=>this.updateContext({mode:N(s)})),t((0,a.combine)({current:e.info.currentTextTrack$,available:e.info.availableTextTracks$}),({current:s,available:l})=>{let b=l.find(({id:_})=>_===s),y=b&&(b.isAuto?`${b.language}_auto`:b.language);this.updateContext({subtitles:y})}),this.player=e,this.uiEvents&&this.attachToUi(this.uiEvents),this.resubscribeBeforeunload(),this.subscription.add(i),i}attachToUi(e){this.uiEvents=e;let{subscription:i,subscribe:t}=G();return this.player&&(t(e.actionRewind$,()=>{this.player&&(this.resetViewSession(),this.logActionPlay({position:this.player.info.position$.getValue()}))}),t(e.actionSeek$,this.seekAction$),t(e.inPiP$,o=>{var r;let d=o?"pip":N((r=this.player)==null?void 0:r.info.surface$.getValue());this.updateContext({mode:d})}),t(e.inFullscreen$,o=>{var r;let d=o?"fullscreen":N((r=this.player)==null?void 0:r.info.surface$.getValue());this.updateContext({mode:d})}),t(e.actionSetSubtitle$,o=>this.updateContext({subtitles:o})),t(e.nextMovie$,o=>this.logNextMovie(o)),this.resubscribeBeforeunload(),this.subscription.add(i)),i}attachToAds(e){let{subscription:i,subscribe:t}=G();return t(e.slotRequested$,()=>this.logAdSlotRequest()),t(e.started$,o=>this.logAdStarted(o)),t(e.paused$,()=>this.logAdPaused()),t(e.resumed$,()=>this.logAdResumed()),t(e.ended$,()=>this.logAdEnded()),t(e.skipped$,()=>this.logAdSkipped()),t(e.clicked$,()=>this.logAdClicked()),this.resubscribeBeforeunload(),this.subscription.add(i),i}attachToInteractive(e){let{subscription:i,subscribe:t}=G();return t(e.click$,o=>this.logInterfaceClick(o)),t(e.nextMovie$,o=>this.logNextMovie(o)),this.resubscribeBeforeunload(),this.subscription.add(i),i}authorize(e){return this.api.authorize(e)}pause(){this.logger.pause(),this.oneStatDebugLog({message:"paused"})}resume(){this.logger.resume(),this.oneStatDebugLog({message:"resumed"})}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}resetViewSession(){this.oneStatDebugLog({message:"VSID reset"}),this.vsid$.next(ae())}getDeviceId(){return this.uuid}setFieldBlacklist(){}logInited(){}logReady(e){this.log({operation:"player_ready",param:String(e.time)})}logStarted(...e){this.logActionPlay(...e)}logPlay(){this.log({operation:"play_toggle"})}logPlaying(){this.log({operation:"playing"})}logPause(e){this.log({operation:"pause",param:String(Math.round(e.position))})}logSeek(e){this.log({operation:"seek",param:e.action,time:e.time})}logFirstBytes(e){this.log({operation:"first_bytes",param:String(e.time)})}logFirstFrame(e){this.log({operation:"first_frame",param:String(e.time)})}logError(e){this.log({operation:"content_error",param:`${e.fatal?"fatal":"recoverable"}_${e.errorType}`})}logWatchCoverageRecord(e){this.log({operation:"watch_coverage_record",param:`${e.start}-${e.end}`})}logWatchCoverageLive(e){var d,r;let i=(r=(d=this.timeSynchronisation)==null?void 0:d.getOffset())!=null?r:0,t=e.start+i,o=e.end+i;this.log({operation:"watch_coverage_live",param:`${t}-${o}`})}logEmptyBuffer(e){this.log({operation:"empty_buffer",param:String(e.duration)})}logDownloadSpeed(){}logAdSlotRequest(){this.log({operation:"adv",param:"slot_request"})}logAdStarted(e){this.log({operation:"adv",param:e})}logAdPaused(){this.log({operation:"adv",param:"pause"})}logAdResumed(){this.log({operation:"adv",param:"resume"})}logAdEnded(){this.log({operation:"adv",param:"ended"})}logAdSkipped(){this.log({operation:"adv",param:"skip"})}logAdClicked(){this.log({operation:"adv",param:"click"})}logInterfaceClick(e){this.log({operation:"player_interface_click",param:e})}logNextMovie(e){this.log({operation:"next_movie",param:String(e)})}subscribe(){this.resubscribeBeforeunload();let e=window.navigator.connection;e&&"onchange"in e&&"effectiveType"in e&&this.subscription.add((0,a.merge)((0,a.fromEvent)(e,"change"),(0,a.observableFrom)(["init"])).subscribe(()=>this.updateContext({network:ne(e.effectiveType)}))),this.config.debugLog&&this.debugLogger.log$.subscribe(i=>{console.debug("%c stat ","background:#fa6470;",`component: ${i.component}.`,i.message)})}resubscribeBeforeunload(){var e;(e=this.beforeunloadSubscription)==null||e.unsubscribe(),this.beforeunloadSubscription=(0,a.fromEvent)(window,"beforeunload").subscribe(()=>this.logger.flush(!0)),this.subscription.add(this.beforeunloadSubscription)}logPlayerReady(e){this.log({operation:"player_ready",param:String(Math.round(e.duration))})}logActionPlay(e){this.log({operation:"action_play",param:String(Math.round(e.position))})}logActionPlayInteractive(){this.statContext.projectId&&this.log({operation:"action_play_interactive",param:String(this.statContext.movieId)},{vid:this.statContext.projectId})}logFailover(e){this.log({operation:"failover",param:e})}logCloseAtEmptyBuffer(e){this.log({operation:"close_at_empty_buffer",param:String(Math.round(e.duration))})}logActionStop(){this.log({operation:"action_stop"})}logTrackSwitch(e){this.log({operation:"track_switch",param:e.id})}log(e,i={}){if(this.disabled){this.oneStatDebugLog({message:`operation ${e.operation} but statistics is disabled`});return}if(this.config.disabledOperations.includes(e.operation)){this.oneStatDebugLog({message:`operation ${e.operation} but it is disabled`});return}this.oneStatDebugLog({message:`operation ${e.operation} ${e.param}`});let t=this.createLogItem(e,i);this.logger.log(t)}createLogItem({operation:e,param:i,time:t},o={}){var l,b;let d=(b=(l=this.timeSynchronisation)==null?void 0:l.now())!=null?b:(0,a.now)(),r=this.vsid$.getValue();(0,a.assertNonNullable)(r);let h=this.isid$.getValue(),f=e==="empty_buffer"||e==="close_at_empty_buffer"?this.statContext.connectionType:this.statContext.firstConnectionType,c=this.statContext.firstConnectionReused,g,m;if(this.isEmbed){g=this.embedParent;let y=[...new URLSearchParams(location.search).entries()].filter(([_,A])=>this.config.embedUrlParams.includes(_));m=new URLSearchParams(y).toString()}else this.statContext.place==="direct"&&((this.statContext.refDomain||document.referrer)&&(g=new URL(this.statContext.refDomain||document.referrer).hostname),m=location.href.substring(0,1024));let s={vsid:r,isid:h,vid:this.statContext.movieId,ct:this.statContext.contentType,place:this.isEmbed?"embed":this.statContext.place,quality:this.statContext.quality,cdn_host:this.statContext.cdnHostname,stat_type:this.statContext.autoplay===!0?"auto":this.statContext.autoplay===!1?"":void 0,param:i,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode,connection_type:f,connection_reused:c===!0?1:c===!1?0:void 0,cached_data:this.statContext.cached===!0?1:this.statContext.cached===!1?0:void 0,live:this.statContext.liveEdge?1:void 0,muted:this.statContext.audible===!1?1:void 0,mode:this.statContext.mode,subtitles:this.statContext.subtitles,download_speed:this.statContext.downloadSpeed,manual_quality:this.statContext.autoQuality?void 0:1,ref_domain:g,direct_url:m,rate:this.statContext.rate===1||(0,a.isNullable)(this.statContext.rate)?void 0:this.statContext.rate.toFixed(2),view_360:this.statContext.is3d?1:void 0,aid:this.statContext.albumId,vk_playlist_id:this.statContext.vkPlaylistId,...o};for(let y of this.config.disabledCustomFields)delete s[y];return{operation:e,type:1,time:t,network:this.statContext.network,timestamp:d,custom:s}}};
6
+ "use strict";var kc=Object.create;var Be=Object.defineProperty;var Dc=Object.getOwnPropertyDescriptor;var $c=Object.getOwnPropertyNames;var Mc=Object.getPrototypeOf,jc=Object.prototype.hasOwnProperty;var n=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Fc=(r,e)=>{for(var t in e)Be(r,t,{get:e[t],enumerable:!0})},Ai=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of $c(e))!jc.call(r,o)&&o!==t&&Be(r,o,{get:()=>e[o],enumerable:!(i=Dc(e,o))||i.enumerable});return r};var Ni=(r,e,t)=>(t=r!=null?kc(Mc(r)):{},Ai(e||!r||!r.__esModule?Be(t,"default",{value:r,enumerable:!0}):t,r)),Bc=r=>Ai(Be({},"__esModule",{value:!0}),r);var Fi=n(()=>{"use strict"});var E=n((jr,Bi)=>{"use strict";var he=function(r){return r&&r.Math===Math&&r};Bi.exports=he(typeof globalThis=="object"&&globalThis)||he(typeof window=="object"&&window)||he(typeof self=="object"&&self)||he(typeof global=="object"&&global)||he(typeof jr=="object"&&jr)||function(){return this}()||Function("return this")()});var q=n((cm,Ui)=>{"use strict";Ui.exports=function(r){try{return!!r()}catch(e){return!0}}});var ge=n((lm,Vi)=>{"use strict";var Vc=q();Vi.exports=!Vc(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Fr=n((fm,Hi)=>{"use strict";var Gc=ge(),Wi=Function.prototype,Gi=Wi.apply,Ki=Wi.call;Hi.exports=typeof Reflect=="object"&&Reflect.apply||(Gc?Ki.bind(Gi):function(){return Ki.apply(Gi,arguments)})});var R=n((dm,Yi)=>{"use strict";var zi=ge(),Qi=Function.prototype,Br=Qi.call,Kc=zi&&Qi.bind.bind(Br,Br);Yi.exports=zi?Kc:function(r){return function(){return Br.apply(r,arguments)}}});var me=n((pm,Xi)=>{"use strict";var Ji=R(),Wc=Ji({}.toString),Hc=Ji("".slice);Xi.exports=function(r){return Hc(Wc(r),8,-1)}});var Ur=n((vm,Zi)=>{"use strict";var zc=me(),Qc=R();Zi.exports=function(r){if(zc(r)==="Function")return Qc(r)}});var P=n((hm,eo)=>{"use strict";var Vr=typeof document=="object"&&document.all;eo.exports=typeof Vr=="undefined"&&Vr!==void 0?function(r){return typeof r=="function"||r===Vr}:function(r){return typeof r=="function"}});var x=n((gm,ro)=>{"use strict";var Yc=q();ro.exports=!Yc(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var C=n((mm,to)=>{"use strict";var Jc=ge(),We=Function.prototype.call;to.exports=Jc?We.bind(We):function(){return We.apply(We,arguments)}});var ao=n(no=>{"use strict";var io={}.propertyIsEnumerable,oo=Object.getOwnPropertyDescriptor,Xc=oo&&!io.call({1:2},1);no.f=Xc?function(e){var t=oo(this,e);return!!t&&t.enumerable}:io});var be=n((ym,so)=>{"use strict";so.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var co=n((Im,uo)=>{"use strict";var Zc=R(),el=q(),rl=me(),Gr=Object,tl=Zc("".split);uo.exports=el(function(){return!Gr("z").propertyIsEnumerable(0)})?function(r){return rl(r)==="String"?tl(r,""):Gr(r)}:Gr});var ye=n((Sm,lo)=>{"use strict";lo.exports=function(r){return r==null}});var He=n((Em,fo)=>{"use strict";var il=ye(),ol=TypeError;fo.exports=function(r){if(il(r))throw new ol("Can't call method on "+r);return r}});var Z=n((Pm,po)=>{"use strict";var nl=co(),al=He();po.exports=function(r){return nl(al(r))}});var A=n((Tm,vo)=>{"use strict";var sl=P();vo.exports=function(r){return typeof r=="object"?r!==null:sl(r)}});var ze=n((qm,ho)=>{"use strict";ho.exports={}});var j=n((Om,mo)=>{"use strict";var Kr=ze(),Wr=E(),ul=P(),go=function(r){return ul(r)?r:void 0};mo.exports=function(r,e){return arguments.length<2?go(Kr[r])||go(Wr[r]):Kr[r]&&Kr[r][e]||Wr[r]&&Wr[r][e]}});var Qe=n((_m,bo)=>{"use strict";var cl=R();bo.exports=cl({}.isPrototypeOf)});var ee=n((wm,So)=>{"use strict";var ll=E(),yo=ll.navigator,Io=yo&&yo.userAgent;So.exports=Io?String(Io):""});var zr=n((Rm,_o)=>{"use strict";var Oo=E(),Hr=ee(),Eo=Oo.process,Po=Oo.Deno,To=Eo&&Eo.versions||Po&&Po.version,qo=To&&To.v8,N,Ye;qo&&(N=qo.split("."),Ye=N[0]>0&&N[0]<4?1:+(N[0]+N[1]));!Ye&&Hr&&(N=Hr.match(/Edge\/(\d+)/),(!N||N[1]>=74)&&(N=Hr.match(/Chrome\/(\d+)/),N&&(Ye=+N[1])));_o.exports=Ye});var Qr=n((xm,Ro)=>{"use strict";var wo=zr(),fl=q(),dl=E(),pl=dl.String;Ro.exports=!!Object.getOwnPropertySymbols&&!fl(function(){var r=Symbol("symbol detection");return!pl(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&wo&&wo<41})});var Yr=n((Cm,xo)=>{"use strict";var vl=Qr();xo.exports=vl&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Jr=n((Am,Co)=>{"use strict";var hl=j(),gl=P(),ml=Qe(),bl=Yr(),yl=Object;Co.exports=bl?function(r){return typeof r=="symbol"}:function(r){var e=hl("Symbol");return gl(e)&&ml(e.prototype,yl(r))}});var Ie=n((Nm,Ao)=>{"use strict";var Il=String;Ao.exports=function(r){try{return Il(r)}catch(e){return"Object"}}});var F=n((Lm,No)=>{"use strict";var Sl=P(),El=Ie(),Pl=TypeError;No.exports=function(r){if(Sl(r))return r;throw new Pl(El(r)+" is not a function")}});var Je=n((km,Lo)=>{"use strict";var Tl=F(),ql=ye();Lo.exports=function(r,e){var t=r[e];return ql(t)?void 0:Tl(t)}});var Do=n((Dm,ko)=>{"use strict";var Xr=C(),Zr=P(),et=A(),Ol=TypeError;ko.exports=function(r,e){var t,i;if(e==="string"&&Zr(t=r.toString)&&!et(i=Xr(t,r))||Zr(t=r.valueOf)&&!et(i=Xr(t,r))||e!=="string"&&Zr(t=r.toString)&&!et(i=Xr(t,r)))return i;throw new Ol("Can't convert object to primitive value")}});var D=n(($m,$o)=>{"use strict";$o.exports=!0});var Fo=n((Mm,jo)=>{"use strict";var Mo=E(),_l=Object.defineProperty;jo.exports=function(r,e){try{_l(Mo,r,{value:e,configurable:!0,writable:!0})}catch(t){Mo[r]=e}return e}});var Se=n((jm,Vo)=>{"use strict";var wl=D(),Rl=E(),xl=Fo(),Bo="__core-js_shared__",Uo=Vo.exports=Rl[Bo]||xl(Bo,{});(Uo.versions||(Uo.versions=[])).push({version:"3.38.0",mode:wl?"pure":"global",copyright:"\xA9 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var rt=n((Fm,Ko)=>{"use strict";var Go=Se();Ko.exports=function(r,e){return Go[r]||(Go[r]=e||{})}});var tt=n((Bm,Wo)=>{"use strict";var Cl=He(),Al=Object;Wo.exports=function(r){return Al(Cl(r))}});var $=n((Um,Ho)=>{"use strict";var Nl=R(),Ll=tt(),kl=Nl({}.hasOwnProperty);Ho.exports=Object.hasOwn||function(e,t){return kl(Ll(e),t)}});var it=n((Vm,zo)=>{"use strict";var Dl=R(),$l=0,Ml=Math.random(),jl=Dl(1 .toString);zo.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+jl(++$l+Ml,36)}});var O=n((Gm,Yo)=>{"use strict";var Fl=E(),Bl=rt(),Qo=$(),Ul=it(),Vl=Qr(),Gl=Yr(),re=Fl.Symbol,ot=Bl("wks"),Kl=Gl?re.for||re:re&&re.withoutSetter||Ul;Yo.exports=function(r){return Qo(ot,r)||(ot[r]=Vl&&Qo(re,r)?re[r]:Kl("Symbol."+r)),ot[r]}});var en=n((Km,Zo)=>{"use strict";var Wl=C(),Jo=A(),Xo=Jr(),Hl=Je(),zl=Do(),Ql=O(),Yl=TypeError,Jl=Ql("toPrimitive");Zo.exports=function(r,e){if(!Jo(r)||Xo(r))return r;var t=Hl(r,Jl),i;if(t){if(e===void 0&&(e="default"),i=Wl(t,r,e),!Jo(i)||Xo(i))return i;throw new Yl("Can't convert object to primitive value")}return e===void 0&&(e="number"),zl(r,e)}});var nt=n((Wm,rn)=>{"use strict";var Xl=en(),Zl=Jr();rn.exports=function(r){var e=Xl(r,"string");return Zl(e)?e:e+""}});var Xe=n((Hm,on)=>{"use strict";var ef=E(),tn=A(),at=ef.document,rf=tn(at)&&tn(at.createElement);on.exports=function(r){return rf?at.createElement(r):{}}});var st=n((zm,nn)=>{"use strict";var tf=x(),of=q(),nf=Xe();nn.exports=!tf&&!of(function(){return Object.defineProperty(nf("div"),"a",{get:function(){return 7}}).a!==7})});var un=n(sn=>{"use strict";var af=x(),sf=C(),uf=ao(),cf=be(),lf=Z(),ff=nt(),df=$(),pf=st(),an=Object.getOwnPropertyDescriptor;sn.f=af?an:function(e,t){if(e=lf(e),t=ff(t),pf)try{return an(e,t)}catch(i){}if(df(e,t))return cf(!sf(uf.f,e,t),e[t])}});var ut=n((Ym,cn)=>{"use strict";var vf=q(),hf=P(),gf=/#|\.prototype\./,Ee=function(r,e){var t=bf[mf(r)];return t===If?!0:t===yf?!1:hf(e)?vf(e):!!e},mf=Ee.normalize=function(r){return String(r).replace(gf,".").toLowerCase()},bf=Ee.data={},yf=Ee.NATIVE="N",If=Ee.POLYFILL="P";cn.exports=Ee});var Pe=n((Jm,fn)=>{"use strict";var ln=Ur(),Sf=F(),Ef=ge(),Pf=ln(ln.bind);fn.exports=function(r,e){return Sf(r),e===void 0?r:Ef?Pf(r,e):function(){return r.apply(e,arguments)}}});var ct=n((Xm,dn)=>{"use strict";var Tf=x(),qf=q();dn.exports=Tf&&qf(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var B=n((Zm,pn)=>{"use strict";var Of=A(),_f=String,wf=TypeError;pn.exports=function(r){if(Of(r))return r;throw new wf(_f(r)+" is not an object")}});var W=n(hn=>{"use strict";var Rf=x(),xf=st(),Cf=ct(),Ze=B(),vn=nt(),Af=TypeError,lt=Object.defineProperty,Nf=Object.getOwnPropertyDescriptor,ft="enumerable",dt="configurable",pt="writable";hn.f=Rf?Cf?function(e,t,i){if(Ze(e),t=vn(t),Ze(i),typeof e=="function"&&t==="prototype"&&"value"in i&&pt in i&&!i[pt]){var o=Nf(e,t);o&&o[pt]&&(e[t]=i.value,i={configurable:dt in i?i[dt]:o[dt],enumerable:ft in i?i[ft]:o[ft],writable:!1})}return lt(e,t,i)}:lt:function(e,t,i){if(Ze(e),t=vn(t),Ze(i),xf)try{return lt(e,t,i)}catch(o){}if("get"in i||"set"in i)throw new Af("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var te=n((rb,gn)=>{"use strict";var Lf=x(),kf=W(),Df=be();gn.exports=Lf?function(r,e,t){return kf.f(r,e,Df(1,t))}:function(r,e,t){return r[e]=t,r}});var M=n((tb,bn)=>{"use strict";var Te=E(),$f=Fr(),Mf=Ur(),jf=P(),Ff=un().f,Bf=ut(),ie=ze(),Uf=Pe(),oe=te(),mn=$();Se();var Vf=function(r){var e=function(t,i,o){if(this instanceof e){switch(arguments.length){case 0:return new r;case 1:return new r(t);case 2:return new r(t,i)}return new r(t,i,o)}return $f(r,this,arguments)};return e.prototype=r.prototype,e};bn.exports=function(r,e){var t=r.target,i=r.global,o=r.stat,a=r.proto,u=i?Te:o?Te[t]:Te[t]&&Te[t].prototype,d=i?ie:ie[t]||oe(ie,t,{})[t],p=d.prototype,c,f,v,s,l,m,I,S,y;for(s in e)c=Bf(i?s:t+(o?".":"#")+s,r.forced),f=!c&&u&&mn(u,s),m=d[s],f&&(r.dontCallGetSet?(y=Ff(u,s),I=y&&y.value):I=u[s]),l=f&&I?I:e[s],!(!c&&!a&&typeof m==typeof l)&&(r.bind&&f?S=Uf(l,Te):r.wrap&&f?S=Vf(l):a&&jf(l)?S=Mf(l):S=l,(r.sham||l&&l.sham||m&&m.sham)&&oe(S,"sham",!0),oe(d,s,S),a&&(v=t+"Prototype",mn(ie,v)||oe(ie,v,{}),oe(ie[v],s,l),r.real&&p&&(c||!p[s])&&oe(p,s,l)))}});var vt=n((ib,yn)=>{"use strict";var qe=E(),Gf=ee(),Kf=me(),er=function(r){return Gf.slice(0,r.length)===r};yn.exports=function(){return er("Bun/")?"BUN":er("Cloudflare-Workers")?"CLOUDFLARE":er("Deno/")?"DENO":er("Node.js/")?"NODE":qe.Bun&&typeof Bun.version=="string"?"BUN":qe.Deno&&typeof Deno.version=="object"?"DENO":Kf(qe.process)==="process"?"NODE":qe.window&&qe.document?"BROWSER":"REST"}()});var rr=n((ob,In)=>{"use strict";var Wf=vt();In.exports=Wf==="NODE"});var ne=n((nb,Sn)=>{"use strict";var Hf=te();Sn.exports=function(r,e,t,i){return i&&i.enumerable?r[e]=t:Hf(r,e,t),r}});var Pn=n((ab,En)=>{"use strict";var zf=R(),Qf=F();En.exports=function(r,e,t){try{return zf(Qf(Object.getOwnPropertyDescriptor(r,e)[t]))}catch(i){}}});var qn=n((sb,Tn)=>{"use strict";var Yf=A();Tn.exports=function(r){return Yf(r)||r===null}});var _n=n((ub,On)=>{"use strict";var Jf=qn(),Xf=String,Zf=TypeError;On.exports=function(r){if(Jf(r))return r;throw new Zf("Can't set "+Xf(r)+" as a prototype")}});var ht=n((cb,wn)=>{"use strict";var ed=Pn(),rd=A(),td=He(),id=_n();wn.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var r=!1,e={},t;try{t=ed(Object.prototype,"__proto__","set"),t(e,[]),r=e instanceof Array}catch(i){}return function(o,a){return td(o),id(a),rd(o)&&(r?t(o,a):o.__proto__=a),o}}():void 0)});var tr=n((lb,xn)=>{"use strict";var od=O(),nd=od("toStringTag"),Rn={};Rn[nd]="z";xn.exports=String(Rn)==="[object z]"});var or=n((fb,Cn)=>{"use strict";var ad=tr(),sd=P(),ir=me(),ud=O(),cd=ud("toStringTag"),ld=Object,fd=ir(function(){return arguments}())==="Arguments",dd=function(r,e){try{return r[e]}catch(t){}};Cn.exports=ad?ir:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=dd(e=ld(r),cd))=="string"?t:fd?ir(e):(i=ir(e))==="Object"&&sd(e.callee)?"Arguments":i}});var Nn=n((db,An)=>{"use strict";var pd=tr(),vd=or();An.exports=pd?{}.toString:function(){return"[object "+vd(this)+"]"}});var Oe=n((pb,kn)=>{"use strict";var hd=tr(),gd=W().f,md=te(),bd=$(),yd=Nn(),Id=O(),Ln=Id("toStringTag");kn.exports=function(r,e,t,i){var o=t?r:r&&r.prototype;o&&(bd(o,Ln)||gd(o,Ln,{configurable:!0,value:e}),i&&!hd&&md(o,"toString",yd))}});var $n=n((vb,Dn)=>{"use strict";var Sd=W();Dn.exports=function(r,e,t){return Sd.f(r,e,t)}});var Fn=n((hb,jn)=>{"use strict";var Ed=j(),Pd=$n(),Td=O(),qd=x(),Mn=Td("species");jn.exports=function(r){var e=Ed(r);qd&&e&&!e[Mn]&&Pd(e,Mn,{configurable:!0,get:function(){return this}})}});var Un=n((gb,Bn)=>{"use strict";var Od=Qe(),_d=TypeError;Bn.exports=function(r,e){if(Od(e,r))return r;throw new _d("Incorrect invocation")}});var mt=n((mb,Vn)=>{"use strict";var wd=R(),Rd=P(),gt=Se(),xd=wd(Function.toString);Rd(gt.inspectSource)||(gt.inspectSource=function(r){return xd(r)});Vn.exports=gt.inspectSource});var Qn=n((bb,zn)=>{"use strict";var Cd=R(),Ad=q(),Gn=P(),Nd=or(),Ld=j(),kd=mt(),Kn=function(){},Wn=Ld("Reflect","construct"),bt=/^\s*(?:class|function)\b/,Dd=Cd(bt.exec),$d=!bt.test(Kn),_e=function(e){if(!Gn(e))return!1;try{return Wn(Kn,[],e),!0}catch(t){return!1}},Hn=function(e){if(!Gn(e))return!1;switch(Nd(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return $d||!!Dd(bt,kd(e))}catch(t){return!0}};Hn.sham=!0;zn.exports=!Wn||Ad(function(){var r;return _e(_e.call)||!_e(Object)||!_e(function(){r=!0})||r})?Hn:_e});var Jn=n((yb,Yn)=>{"use strict";var Md=Qn(),jd=Ie(),Fd=TypeError;Yn.exports=function(r){if(Md(r))return r;throw new Fd(jd(r)+" is not a constructor")}});var yt=n((Ib,Zn)=>{"use strict";var Xn=B(),Bd=Jn(),Ud=ye(),Vd=O(),Gd=Vd("species");Zn.exports=function(r,e){var t=Xn(r).constructor,i;return t===void 0||Ud(i=Xn(t)[Gd])?e:Bd(i)}});var It=n((Sb,ea)=>{"use strict";var Kd=j();ea.exports=Kd("document","documentElement")});var ta=n((Eb,ra)=>{"use strict";var Wd=R();ra.exports=Wd([].slice)});var oa=n((Pb,ia)=>{"use strict";var Hd=TypeError;ia.exports=function(r,e){if(r<e)throw new Hd("Not enough arguments");return r}});var St=n((Tb,na)=>{"use strict";var zd=ee();na.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(zd)});var xt=n((qb,va)=>{"use strict";var _=E(),Qd=Fr(),Yd=Pe(),aa=P(),Jd=$(),pa=q(),sa=It(),Xd=ta(),ua=Xe(),Zd=oa(),ep=St(),rp=rr(),_t=_.setImmediate,wt=_.clearImmediate,tp=_.process,Et=_.Dispatch,ip=_.Function,ca=_.MessageChannel,op=_.String,Pt=0,we={},la="onreadystatechange",Re,H,Tt,qt;pa(function(){Re=_.location});var Rt=function(r){if(Jd(we,r)){var e=we[r];delete we[r],e()}},Ot=function(r){return function(){Rt(r)}},fa=function(r){Rt(r.data)},da=function(r){_.postMessage(op(r),Re.protocol+"//"+Re.host)};(!_t||!wt)&&(_t=function(e){Zd(arguments.length,1);var t=aa(e)?e:ip(e),i=Xd(arguments,1);return we[++Pt]=function(){Qd(t,void 0,i)},H(Pt),Pt},wt=function(e){delete we[e]},rp?H=function(r){tp.nextTick(Ot(r))}:Et&&Et.now?H=function(r){Et.now(Ot(r))}:ca&&!ep?(Tt=new ca,qt=Tt.port2,Tt.port1.onmessage=fa,H=Yd(qt.postMessage,qt)):_.addEventListener&&aa(_.postMessage)&&!_.importScripts&&Re&&Re.protocol!=="file:"&&!pa(da)?(H=da,_.addEventListener("message",fa,!1)):la in ua("script")?H=function(r){sa.appendChild(ua("script"))[la]=function(){sa.removeChild(this),Rt(r)}}:H=function(r){setTimeout(Ot(r),0)});va.exports={set:_t,clear:wt}});var ma=n((Ob,ga)=>{"use strict";var ha=E(),np=x(),ap=Object.getOwnPropertyDescriptor;ga.exports=function(r){if(!np)return ha[r];var e=ap(ha,r);return e&&e.value}});var Ct=n((_b,ya)=>{"use strict";var ba=function(){this.head=null,this.tail=null};ba.prototype={add:function(r){var e={item:r,next:null},t=this.tail;t?t.next=e:this.head=e,this.tail=e},get:function(){var r=this.head;if(r){var e=this.head=r.next;return e===null&&(this.tail=null),r.item}}};ya.exports=ba});var Sa=n((wb,Ia)=>{"use strict";var sp=ee();Ia.exports=/ipad|iphone|ipod/i.test(sp)&&typeof Pebble!="undefined"});var Pa=n((Rb,Ea)=>{"use strict";var up=ee();Ea.exports=/web0s(?!.*chrome)/i.test(up)});var xa=n((xb,Ra)=>{"use strict";var se=E(),cp=ma(),Ta=Pe(),At=xt().set,lp=Ct(),fp=St(),dp=Sa(),pp=Pa(),Nt=rr(),qa=se.MutationObserver||se.WebKitMutationObserver,Oa=se.document,_a=se.process,nr=se.Promise,Dt=cp("queueMicrotask"),ae,Lt,kt,ar,wa;Dt||(xe=new lp,Ce=function(){var r,e;for(Nt&&(r=_a.domain)&&r.exit();e=xe.get();)try{e()}catch(t){throw xe.head&&ae(),t}r&&r.enter()},!fp&&!Nt&&!pp&&qa&&Oa?(Lt=!0,kt=Oa.createTextNode(""),new qa(Ce).observe(kt,{characterData:!0}),ae=function(){kt.data=Lt=!Lt}):!dp&&nr&&nr.resolve?(ar=nr.resolve(void 0),ar.constructor=nr,wa=Ta(ar.then,ar),ae=function(){wa(Ce)}):Nt?ae=function(){_a.nextTick(Ce)}:(At=Ta(At,se),ae=function(){At(Ce)}),Dt=function(r){xe.head||ae(),xe.add(r)});var xe,Ce;Ra.exports=Dt});var Aa=n((Cb,Ca)=>{"use strict";Ca.exports=function(r,e){try{arguments.length===1?console.error(r):console.error(r,e)}catch(t){}}});var sr=n((Ab,Na)=>{"use strict";Na.exports=function(r){try{return{error:!1,value:r()}}catch(e){return{error:!0,value:e}}}});var Da=n((Nb,ka)=>{"use strict";var vp=E(),hp=P(),La=vp.WeakMap;ka.exports=hp(La)&&/native code/.test(String(La))});var ur=n((Lb,Ma)=>{"use strict";var gp=rt(),mp=it(),$a=gp("keys");Ma.exports=function(r){return $a[r]||($a[r]=mp(r))}});var cr=n((kb,ja)=>{"use strict";ja.exports={}});var Ft=n((Db,Ua)=>{"use strict";var bp=Da(),Ba=E(),yp=A(),Ip=te(),$t=$(),Mt=Se(),Sp=ur(),Ep=cr(),Fa="Object already initialized",jt=Ba.TypeError,Pp=Ba.WeakMap,lr,Ae,fr,Tp=function(r){return fr(r)?Ae(r):lr(r,{})},qp=function(r){return function(e){var t;if(!yp(e)||(t=Ae(e)).type!==r)throw new jt("Incompatible receiver, "+r+" required");return t}};bp||Mt.state?(L=Mt.state||(Mt.state=new Pp),L.get=L.get,L.has=L.has,L.set=L.set,lr=function(r,e){if(L.has(r))throw new jt(Fa);return e.facade=r,L.set(r,e),e},Ae=function(r){return L.get(r)||{}},fr=function(r){return L.has(r)}):(z=Sp("state"),Ep[z]=!0,lr=function(r,e){if($t(r,z))throw new jt(Fa);return e.facade=r,Ip(r,z,e),e},Ae=function(r){return $t(r,z)?r[z]:{}},fr=function(r){return $t(r,z)});var L,z;Ua.exports={set:lr,get:Ae,has:fr,enforce:Tp,getterFor:qp}});var Q=n(($b,Va)=>{"use strict";var Op=E();Va.exports=Op.Promise});var ue=n((Mb,Ha)=>{"use strict";var _p=E(),Ne=Q(),wp=P(),Rp=ut(),xp=mt(),Cp=O(),Ga=vt(),Ap=D(),Bt=zr(),Ka=Ne&&Ne.prototype,Np=Cp("species"),Ut=!1,Wa=wp(_p.PromiseRejectionEvent),Lp=Rp("Promise",function(){var r=xp(Ne),e=r!==String(Ne);if(!e&&Bt===66||Ap&&!(Ka.catch&&Ka.finally))return!0;if(!Bt||Bt<51||!/native code/.test(r)){var t=new Ne(function(a){a(1)}),i=function(a){a(function(){},function(){})},o=t.constructor={};if(o[Np]=i,Ut=t.then(function(){})instanceof i,!Ut)return!0}return!e&&(Ga==="BROWSER"||Ga==="DENO")&&!Wa});Ha.exports={CONSTRUCTOR:Lp,REJECTION_EVENT:Wa,SUBCLASSING:Ut}});var ce=n((jb,Qa)=>{"use strict";var za=F(),kp=TypeError,Dp=function(r){var e,t;this.promise=new r(function(i,o){if(e!==void 0||t!==void 0)throw new kp("Bad Promise constructor");e=i,t=o}),this.resolve=za(e),this.reject=za(t)};Qa.exports.f=function(r){return new Dp(r)}});var vs=n(()=>{"use strict";var $p=M(),Mp=D(),hr=rr(),K=E(),pe=C(),Ya=ne(),Ja=ht(),jp=Oe(),Fp=Fn(),Bp=F(),vr=P(),Up=A(),Vp=Un(),Gp=yt(),ts=xt().set,Ht=xa(),Kp=Aa(),Wp=sr(),Hp=Ct(),is=Ft(),gr=Q(),zt=ue(),os=ce(),mr="Promise",ns=zt.CONSTRUCTOR,zp=zt.REJECTION_EVENT,Qp=zt.SUBCLASSING,Vt=is.getterFor(mr),Yp=is.set,le=gr&&gr.prototype,Y=gr,dr=le,as=K.TypeError,Gt=K.document,Qt=K.process,Kt=os.f,Jp=Kt,Xp=!!(Gt&&Gt.createEvent&&K.dispatchEvent),ss="unhandledrejection",Zp="rejectionhandled",Xa=0,us=1,ev=2,Yt=1,cs=2,pr,Za,rv,es,ls=function(r){var e;return Up(r)&&vr(e=r.then)?e:!1},fs=function(r,e){var t=e.value,i=e.state===us,o=i?r.ok:r.fail,a=r.resolve,u=r.reject,d=r.domain,p,c,f;try{o?(i||(e.rejection===cs&&iv(e),e.rejection=Yt),o===!0?p=t:(d&&d.enter(),p=o(t),d&&(d.exit(),f=!0)),p===r.promise?u(new as("Promise-chain cycle")):(c=ls(p))?pe(c,p,a,u):a(p)):u(t)}catch(v){d&&!f&&d.exit(),u(v)}},ds=function(r,e){r.notified||(r.notified=!0,Ht(function(){for(var t=r.reactions,i;i=t.get();)fs(i,r);r.notified=!1,e&&!r.rejection&&tv(r)}))},ps=function(r,e,t){var i,o;Xp?(i=Gt.createEvent("Event"),i.promise=e,i.reason=t,i.initEvent(r,!1,!0),K.dispatchEvent(i)):i={promise:e,reason:t},!zp&&(o=K["on"+r])?o(i):r===ss&&Kp("Unhandled promise rejection",t)},tv=function(r){pe(ts,K,function(){var e=r.facade,t=r.value,i=rs(r),o;if(i&&(o=Wp(function(){hr?Qt.emit("unhandledRejection",t,e):ps(ss,e,t)}),r.rejection=hr||rs(r)?cs:Yt,o.error))throw o.value})},rs=function(r){return r.rejection!==Yt&&!r.parent},iv=function(r){pe(ts,K,function(){var e=r.facade;hr?Qt.emit("rejectionHandled",e):ps(Zp,e,r.value)})},fe=function(r,e,t){return function(i){r(e,i,t)}},de=function(r,e,t){r.done||(r.done=!0,t&&(r=t),r.value=e,r.state=ev,ds(r,!0))},Wt=function(r,e,t){if(!r.done){r.done=!0,t&&(r=t);try{if(r.facade===e)throw new as("Promise can't be resolved itself");var i=ls(e);i?Ht(function(){var o={done:!1};try{pe(i,e,fe(Wt,o,r),fe(de,o,r))}catch(a){de(o,a,r)}}):(r.value=e,r.state=us,ds(r,!1))}catch(o){de({done:!1},o,r)}}};if(ns&&(Y=function(e){Vp(this,dr),Bp(e),pe(pr,this);var t=Vt(this);try{e(fe(Wt,t),fe(de,t))}catch(i){de(t,i)}},dr=Y.prototype,pr=function(e){Yp(this,{type:mr,done:!1,notified:!1,parent:!1,reactions:new Hp,rejection:!1,state:Xa,value:void 0})},pr.prototype=Ya(dr,"then",function(e,t){var i=Vt(this),o=Kt(Gp(this,Y));return i.parent=!0,o.ok=vr(e)?e:!0,o.fail=vr(t)&&t,o.domain=hr?Qt.domain:void 0,i.state===Xa?i.reactions.add(o):Ht(function(){fs(o,i)}),o.promise}),Za=function(){var r=new pr,e=Vt(r);this.promise=r,this.resolve=fe(Wt,e),this.reject=fe(de,e)},os.f=Kt=function(r){return r===Y||r===rv?new Za(r):Jp(r)},!Mp&&vr(gr)&&le!==Object.prototype)){es=le.then,Qp||Ya(le,"then",function(e,t){var i=this;return new Y(function(o,a){pe(es,i,o,a)}).then(e,t)},{unsafe:!0});try{delete le.constructor}catch(r){}Ja&&Ja(le,dr)}$p({global:!0,constructor:!0,wrap:!0,forced:ns},{Promise:Y});jp(Y,mr,!1,!0);Fp(mr)});var J=n((Ub,hs)=>{"use strict";hs.exports={}});var ms=n((Vb,gs)=>{"use strict";var ov=O(),nv=J(),av=ov("iterator"),sv=Array.prototype;gs.exports=function(r){return r!==void 0&&(nv.Array===r||sv[av]===r)}});var ys=n((Gb,bs)=>{"use strict";var uv=Math.ceil,cv=Math.floor;bs.exports=Math.trunc||function(e){var t=+e;return(t>0?cv:uv)(t)}});var Jt=n((Kb,Is)=>{"use strict";var lv=ys();Is.exports=function(r){var e=+r;return e!==e||e===0?0:lv(e)}});var Es=n((Wb,Ss)=>{"use strict";var fv=Jt(),dv=Math.min;Ss.exports=function(r){var e=fv(r);return e>0?dv(e,9007199254740991):0}});var Xt=n((Hb,Ps)=>{"use strict";var pv=Es();Ps.exports=function(r){return pv(r.length)}});var Zt=n((zb,qs)=>{"use strict";var vv=or(),Ts=Je(),hv=ye(),gv=J(),mv=O(),bv=mv("iterator");qs.exports=function(r){if(!hv(r))return Ts(r,bv)||Ts(r,"@@iterator")||gv[vv(r)]}});var _s=n((Qb,Os)=>{"use strict";var yv=C(),Iv=F(),Sv=B(),Ev=Ie(),Pv=Zt(),Tv=TypeError;Os.exports=function(r,e){var t=arguments.length<2?Pv(r):e;if(Iv(t))return Sv(yv(t,r));throw new Tv(Ev(r)+" is not iterable")}});var xs=n((Yb,Rs)=>{"use strict";var qv=C(),ws=B(),Ov=Je();Rs.exports=function(r,e,t){var i,o;ws(r);try{if(i=Ov(r,"return"),!i){if(e==="throw")throw t;return t}i=qv(i,r)}catch(a){o=!0,i=a}if(e==="throw")throw t;if(o)throw i;return ws(i),t}});var yr=n((Jb,Ls)=>{"use strict";var _v=Pe(),wv=C(),Rv=B(),xv=Ie(),Cv=ms(),Av=Xt(),Cs=Qe(),Nv=_s(),Lv=Zt(),As=xs(),kv=TypeError,br=function(r,e){this.stopped=r,this.result=e},Ns=br.prototype;Ls.exports=function(r,e,t){var i=t&&t.that,o=!!(t&&t.AS_ENTRIES),a=!!(t&&t.IS_RECORD),u=!!(t&&t.IS_ITERATOR),d=!!(t&&t.INTERRUPTED),p=_v(e,i),c,f,v,s,l,m,I,S=function(T){return c&&As(c,"normal",T),new br(!0,T)},y=function(T){return o?(Rv(T),d?p(T[0],T[1],S):p(T[0],T[1])):d?p(T,S):p(T)};if(a)c=r.iterator;else if(u)c=r;else{if(f=Lv(r),!f)throw new kv(xv(r)+" is not iterable");if(Cv(f)){for(v=0,s=Av(r);s>v;v++)if(l=y(r[v]),l&&Cs(Ns,l))return l;return new br(!1)}c=Nv(r,f)}for(m=a?r.next:c.next;!(I=wv(m,c)).done;){try{l=y(I.value)}catch(T){As(c,"throw",T)}if(typeof l=="object"&&l&&Cs(Ns,l))return l}return new br(!1)}});var js=n((Xb,Ms)=>{"use strict";var Dv=O(),Ds=Dv("iterator"),$s=!1;try{ks=0,ei={next:function(){return{done:!!ks++}},return:function(){$s=!0}},ei[Ds]=function(){return this},Array.from(ei,function(){throw 2})}catch(r){}var ks,ei;Ms.exports=function(r,e){try{if(!e&&!$s)return!1}catch(o){return!1}var t=!1;try{var i={};i[Ds]=function(){return{next:function(){return{done:t=!0}}}},r(i)}catch(o){}return t}});var ri=n((Zb,Fs)=>{"use strict";var $v=Q(),Mv=js(),jv=ue().CONSTRUCTOR;Fs.exports=jv||!Mv(function(r){$v.all(r).then(void 0,function(){})})});var Bs=n(()=>{"use strict";var Fv=M(),Bv=C(),Uv=F(),Vv=ce(),Gv=sr(),Kv=yr(),Wv=ri();Fv({target:"Promise",stat:!0,forced:Wv},{all:function(e){var t=this,i=Vv.f(t),o=i.resolve,a=i.reject,u=Gv(function(){var d=Uv(t.resolve),p=[],c=0,f=1;Kv(e,function(v){var s=c++,l=!1;f++,Bv(d,t,v).then(function(m){l||(l=!0,p[s]=m,--f||o(p))},a)}),--f||o(p)});return u.error&&a(u.value),i.promise}})});var Vs=n(()=>{"use strict";var Hv=M(),zv=D(),Qv=ue().CONSTRUCTOR,ii=Q(),Yv=j(),Jv=P(),Xv=ne(),Us=ii&&ii.prototype;Hv({target:"Promise",proto:!0,forced:Qv,real:!0},{catch:function(r){return this.then(void 0,r)}});!zv&&Jv(ii)&&(ti=Yv("Promise").prototype.catch,Us.catch!==ti&&Xv(Us,"catch",ti,{unsafe:!0}));var ti});var Gs=n(()=>{"use strict";var Zv=M(),eh=C(),rh=F(),th=ce(),ih=sr(),oh=yr(),nh=ri();Zv({target:"Promise",stat:!0,forced:nh},{race:function(e){var t=this,i=th.f(t),o=i.reject,a=ih(function(){var u=rh(t.resolve);oh(e,function(d){eh(u,t,d).then(i.resolve,o)})});return a.error&&o(a.value),i.promise}})});var Ks=n(()=>{"use strict";var ah=M(),sh=ce(),uh=ue().CONSTRUCTOR;ah({target:"Promise",stat:!0,forced:uh},{reject:function(e){var t=sh.f(this),i=t.reject;return i(e),t.promise}})});var oi=n((uy,Ws)=>{"use strict";var ch=B(),lh=A(),fh=ce();Ws.exports=function(r,e){if(ch(r),lh(e)&&e.constructor===r)return e;var t=fh.f(r),i=t.resolve;return i(e),t.promise}});var Qs=n(()=>{"use strict";var dh=M(),ph=j(),Hs=D(),vh=Q(),zs=ue().CONSTRUCTOR,hh=oi(),gh=ph("Promise"),mh=Hs&&!zs;dh({target:"Promise",stat:!0,forced:Hs||zs},{resolve:function(e){return hh(mh&&this===gh?vh:this,e)}})});var Ys=n(()=>{"use strict";vs();Bs();Vs();Gs();Ks();Qs()});var eu=n(()=>{"use strict";var bh=M(),yh=D(),Ir=Q(),Ih=q(),Xs=j(),Zs=P(),Sh=yt(),Js=oi(),Eh=ne(),ai=Ir&&Ir.prototype,Ph=!!Ir&&Ih(function(){ai.finally.call({then:function(){}},function(){})});bh({target:"Promise",proto:!0,real:!0,forced:Ph},{finally:function(r){var e=Sh(this,Xs("Promise")),t=Zs(r);return this.then(t?function(i){return Js(e,r()).then(function(){return i})}:r,t?function(i){return Js(e,r()).then(function(){throw i})}:r)}});!yh&&Zs(Ir)&&(ni=Xs("Promise").prototype.finally,ai.finally!==ni&&Eh(ai,"finally",ni,{unsafe:!0}));var ni});var tu=n((hy,ru)=>{"use strict";var Th=j();ru.exports=Th});var ou=n((gy,iu)=>{"use strict";Fi();Ys();eu();var qh=tu();iu.exports=qh("Promise","finally")});var au=n((my,nu)=>{"use strict";var Oh=ou();nu.exports=Oh});var uu=n((by,su)=>{"use strict";var _h=au();su.exports=_h});var lu=n((yy,cu)=>{"use strict";cu.exports=function(){}});var pu=n((Iy,du)=>{"use strict";var si=x(),wh=$(),fu=Function.prototype,Rh=si&&Object.getOwnPropertyDescriptor,ui=wh(fu,"name"),xh=ui&&function(){}.name==="something",Ch=ui&&(!si||si&&Rh(fu,"name").configurable);du.exports={EXISTS:ui,PROPER:xh,CONFIGURABLE:Ch}});var hu=n((Sy,vu)=>{"use strict";var Ah=Jt(),Nh=Math.max,Lh=Math.min;vu.exports=function(r,e){var t=Ah(r);return t<0?Nh(t+e,0):Lh(t,e)}});var bu=n((Ey,mu)=>{"use strict";var kh=Z(),Dh=hu(),$h=Xt(),gu=function(r){return function(e,t,i){var o=kh(e),a=$h(o);if(a===0)return!r&&-1;var u=Dh(i,a),d;if(r&&t!==t){for(;a>u;)if(d=o[u++],d!==d)return!0}else for(;a>u;u++)if((r||u in o)&&o[u]===t)return r||u||0;return!r&&-1}};mu.exports={includes:gu(!0),indexOf:gu(!1)}});var Su=n((Py,Iu)=>{"use strict";var Mh=R(),ci=$(),jh=Z(),Fh=bu().indexOf,Bh=cr(),yu=Mh([].push);Iu.exports=function(r,e){var t=jh(r),i=0,o=[],a;for(a in t)!ci(Bh,a)&&ci(t,a)&&yu(o,a);for(;e.length>i;)ci(t,a=e[i++])&&(~Fh(o,a)||yu(o,a));return o}});var li=n((Ty,Eu)=>{"use strict";Eu.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var Tu=n((qy,Pu)=>{"use strict";var Uh=Su(),Vh=li();Pu.exports=Object.keys||function(e){return Uh(e,Vh)}});var Ou=n(qu=>{"use strict";var Gh=x(),Kh=ct(),Wh=W(),Hh=B(),zh=Z(),Qh=Tu();qu.f=Gh&&!Kh?Object.defineProperties:function(e,t){Hh(e);for(var i=zh(t),o=Qh(t),a=o.length,u=0,d;a>u;)Wh.f(e,d=o[u++],i[d]);return e}});var vi=n((_y,Nu)=>{"use strict";var Yh=B(),Jh=Ou(),_u=li(),Xh=cr(),Zh=It(),eg=Xe(),rg=ur(),wu=">",Ru="<",di="prototype",pi="script",Cu=rg("IE_PROTO"),fi=function(){},Au=function(r){return Ru+pi+wu+r+Ru+"/"+pi+wu},xu=function(r){r.write(Au("")),r.close();var e=r.parentWindow.Object;return r=null,e},tg=function(){var r=eg("iframe"),e="java"+pi+":",t;return r.style.display="none",Zh.appendChild(r),r.src=String(e),t=r.contentWindow.document,t.open(),t.write(Au("document.F=Object")),t.close(),t.F},Sr,Er=function(){try{Sr=new ActiveXObject("htmlfile")}catch(e){}Er=typeof document!="undefined"?document.domain&&Sr?xu(Sr):tg():xu(Sr);for(var r=_u.length;r--;)delete Er[di][_u[r]];return Er()};Xh[Cu]=!0;Nu.exports=Object.create||function(e,t){var i;return e!==null?(fi[di]=Yh(e),i=new fi,fi[di]=null,i[Cu]=e):i=Er(),t===void 0?i:Jh.f(i,t)}});var ku=n((wy,Lu)=>{"use strict";var ig=q();Lu.exports=!ig(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var gi=n((Ry,$u)=>{"use strict";var og=$(),ng=P(),ag=tt(),sg=ur(),ug=ku(),Du=sg("IE_PROTO"),hi=Object,cg=hi.prototype;$u.exports=ug?hi.getPrototypeOf:function(r){var e=ag(r);if(og(e,Du))return e[Du];var t=e.constructor;return ng(t)&&e instanceof t?t.prototype:e instanceof hi?cg:null}});var Ii=n((xy,Fu)=>{"use strict";var lg=q(),fg=P(),dg=A(),pg=vi(),Mu=gi(),vg=ne(),hg=O(),gg=D(),yi=hg("iterator"),ju=!1,U,mi,bi;[].keys&&(bi=[].keys(),"next"in bi?(mi=Mu(Mu(bi)),mi!==Object.prototype&&(U=mi)):ju=!0);var mg=!dg(U)||lg(function(){var r={};return U[yi].call(r)!==r});mg?U={}:gg&&(U=pg(U));fg(U[yi])||vg(U,yi,function(){return this});Fu.exports={IteratorPrototype:U,BUGGY_SAFARI_ITERATORS:ju}});var Uu=n((Cy,Bu)=>{"use strict";var bg=Ii().IteratorPrototype,yg=vi(),Ig=be(),Sg=Oe(),Eg=J(),Pg=function(){return this};Bu.exports=function(r,e,t,i){var o=e+" Iterator";return r.prototype=yg(bg,{next:Ig(+!i,t)}),Sg(r,o,!1,!0),Eg[o]=Pg,r}});var Zu=n((Ay,Xu)=>{"use strict";var Tg=M(),qg=C(),Pr=D(),Yu=pu(),Og=P(),_g=Uu(),Vu=gi(),Gu=ht(),wg=Oe(),Rg=te(),Si=ne(),xg=O(),Ku=J(),Ju=Ii(),Cg=Yu.PROPER,Ag=Yu.CONFIGURABLE,Wu=Ju.IteratorPrototype,Tr=Ju.BUGGY_SAFARI_ITERATORS,Le=xg("iterator"),Hu="keys",ke="values",zu="entries",Qu=function(){return this};Xu.exports=function(r,e,t,i,o,a,u){_g(t,e,i);var d=function(y){if(y===o&&s)return s;if(!Tr&&y&&y in f)return f[y];switch(y){case Hu:return function(){return new t(this,y)};case ke:return function(){return new t(this,y)};case zu:return function(){return new t(this,y)}}return function(){return new t(this)}},p=e+" Iterator",c=!1,f=r.prototype,v=f[Le]||f["@@iterator"]||o&&f[o],s=!Tr&&v||d(o),l=e==="Array"&&f.entries||v,m,I,S;if(l&&(m=Vu(l.call(new r)),m!==Object.prototype&&m.next&&(!Pr&&Vu(m)!==Wu&&(Gu?Gu(m,Wu):Og(m[Le])||Si(m,Le,Qu)),wg(m,p,!0,!0),Pr&&(Ku[p]=Qu))),Cg&&o===ke&&v&&v.name!==ke&&(!Pr&&Ag?Rg(f,"name",ke):(c=!0,s=function(){return qg(v,this)})),o)if(I={values:d(ke),keys:a?s:d(Hu),entries:d(zu)},u)for(S in I)(Tr||c||!(S in f))&&Si(f,S,I[S]);else Tg({target:e,proto:!0,forced:Tr||c},I);return(!Pr||u)&&f[Le]!==s&&Si(f,Le,s,{name:o}),Ku[e]=s,I}});var rc=n((Ny,ec)=>{"use strict";ec.exports=function(r,e){return{value:r,done:e}}});var Pi=n((Ly,ac)=>{"use strict";var Ng=Z(),Ei=lu(),tc=J(),oc=Ft(),Lg=W().f,kg=Zu(),qr=rc(),Dg=D(),$g=x(),nc="Array Iterator",Mg=oc.set,jg=oc.getterFor(nc);ac.exports=kg(Array,"Array",function(r,e){Mg(this,{type:nc,target:Ng(r),index:0,kind:e})},function(){var r=jg(this),e=r.target,t=r.index++;if(!e||t>=e.length)return r.target=void 0,qr(void 0,!0);switch(r.kind){case"keys":return qr(t,!1);case"values":return qr(e[t],!1)}return qr([t,e[t]],!1)},"values");var ic=tc.Arguments=tc.Array;Ei("keys");Ei("values");Ei("entries");if(!Dg&&$g&&ic.name!=="values")try{Lg(ic,"name",{value:"values"})}catch(r){}});var uc=n((ky,sc)=>{"use strict";var Fg=x(),Bg=W(),Ug=be();sc.exports=function(r,e,t){Fg?Bg.f(r,e,Ug(0,t)):r[e]=t}});var cc=n(()=>{"use strict";var Vg=M(),Gg=yr(),Kg=uc();Vg({target:"Object",stat:!0},{fromEntries:function(e){var t={};return Gg(e,function(i,o){Kg(t,i,o)},{AS_ENTRIES:!0}),t}})});var fc=n((My,lc)=>{"use strict";Pi();cc();var Wg=ze();lc.exports=Wg.Object.fromEntries});var pc=n((jy,dc)=>{"use strict";dc.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}});var hc=n(()=>{"use strict";Pi();var Hg=pc(),zg=E(),Qg=Oe(),vc=J();for(Or in Hg)Qg(zg[Or],Or),vc[Or]=vc.Array;var Or});var mc=n((Uy,gc)=>{"use strict";var Yg=fc();hc();gc.exports=Yg});var yc=n((Vy,bc)=>{"use strict";var Jg=mc();bc.exports=Jg});var Zg={};Fc(Zg,{ApiEnv:()=>X,ConnectionType:()=>Ge,ContentType:()=>Ve,InteractiveInterfaceClick:()=>$r,OneStat:()=>Lr,Quality:()=>Ue,SeekAction:()=>Ke,VERSION:()=>De});module.exports=Bc(Zg);var X=(u=>(u.PROD="prod",u.VK_ALIAS="vk_alias",u.VIDEOTEST="videotest",u.TEST="test",u.OKCDN="okcdn",u.AUTO="auto",u))(X||{}),Ue=(c=>(c.Q144P="mobile",c.Q240P="lowest",c.Q360P="low",c.Q480P="medium",c.Q720P="high",c.Q1080P="fullhd",c.Q1440P="quadhd",c.Q2160P="ultrahd",c.UNKNOWN="unknown",c))(Ue||{}),Ve=(l=>(l.MP4="mp4",l.DASH="dash",l.DASH_SEP="dash_sep",l.ONDEMAND_DASH="ondemand_dash",l.HLS="hls",l.ONDEMAND_HLS="ondemand_hls",l.WEBM="webm",l.AV1="av1",l.ONDEMAND_DASH_LIVE="ondemand_dash_live",l.ONDEMAND_HLS_LIVE="ondemand_hls_live",l.WEBRTC="webrtc",l.UNKNOWN="unknown",l.RTMP="rtmp",l))(Ve||{});var Ge=(i=>(i.HTTP1="http1",i.HTTP2="http2",i.HTTP3="http3",i))(Ge||{});var Ke=(d=>(d.SLIDER="slider",d.DOUBLE_TAP="double_tap",d.TIME_CODE="time_code",d.EPISODE="episode",d.REWIND="rewind",d.LIVE="live",d.UNKNOWN="unknown",d))(Ke||{}),$r=(a=>(a.GRAPH_SHOW="iGraphShow",a.GRAPH_HIDE="iGraphHide",a.NEXT_AREA="iNextChapterArea",a.NEXT_BUTTON="iNextChapterBtn",a.WATCH_AGAIN="iWatchAgainBtn",a))($r||{}),Li={action_play:"ap",action_play_interactive:"api",first_bytes:"fb",player_ready:"pr",first_frame:"ff",seek:"sk",watch_coverage_record:"wr",watch_coverage_live:"wl",empty_buffer:"eb",action_stop:"as",close_at_empty_buffer:"cb",content_error:"er",player_interface_click:"pc",next_movie:"nm",track_switch:"ts",failover:"fo"},ki={vsid:"si",isid:"is",vid:"vi",place:"pl",quality:"qt",cdn_host:"ch",stat_type:"st",param:"pm",vk_app_id:"va",track_code:"tc",connection_type:"cnt",connection_reused:"cr",cached_data:"cd",live:"lv",muted:"mu",mode:"mo",subtitles:"sb",failover:"fo",download_speed:"ds",manual_quality:"mq",ref_domain:"rd",direct_url:"du"},Di={unknown:"un",mobile:"m",lowest:"ls",low:"l",medium:"md",high:"h",fullhd:"f",quadhd:"q",ultrahd:"u"},$i={pip:"pi",fullscreen:"fs",external:"ex",prefetch:"pr",airplay:"ap",chromecast:"cc",invisible:"iv"};var Mi=require("@vkontakte/videoplayer-shared"),Uc={apiEnv:"vk_alias",requestRetryCount:1,firstFlushTime:5e3,flushDebounceTime:1e4,flushMaxWait:6e4,storageExpiration:36*60*60*1e3,watchCoverageInterval:15e3,disabledOperations:[],disabledCustomFields:[],shorten:!0,maxLoops:100,embedUrlParams:[],useBeacon:!0,synchronizeTime:!0,debugLog:!1,backoff:{start:1e3,factor:1.5,max:5*60*1e3,random:.1}},ji=r=>(0,Mi.fillWithDefault)(r,Uc);function Mr(){let r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),e=new Array(36),t=0,i,o;for(o=0;o<36;o++)o===8||o===13||o===18||o===23?e[o]="-":o===14?e[o]="4":(t<=2&&(t=33554432+Math.random()*16777216|0),i=t&15,t=t>>4,e[o]=r[o===19?i&3|8:i]);return e.join("")}var h=require("@vkontakte/videoplayer-shared"),kr=require("@vkontakte/videoplayer-shared");var _r=Ni(uu(),1);var Ic=Ni(yc(),1);var Sc=r=>{var o;let{operation:e,custom:t}=r,i=(0,Ic.default)(Object.entries(t).map(([a,u])=>{var c,f,v;let d=(c=ki[a])!=null?c:a,p=u;return u&&(a==="mode"?p=(f=$i[u])!=null?f:u:a==="quality"&&(p=(v=Di[u])!=null?v:u)),[d,p]}));return{...r,operation:(o=Li[e])!=null?o:e,custom:i}};var De="1.0.53-beta.0",Ec="CIOPGQJGDIHBABABA",Ti={prod:"https://api.ok.ru",vk_alias:"https://api.mycdn.me",videotest:"https://videotestapi.ok.ru/api",test:"https://apitest.ok.ru",okcdn:"https://api.okcdn.ru",auto:""};var k=require("@vkontakte/videoplayer-shared");var $e=class{constructor(e){this.consequentAuthErrors=0;this.authorized$=new k.ValueSubject(!1);this.params=e}async authorize(e){return this.authToken=e!=null?e:await this.refreshAuthToken(),this._authorizeWithBackoff()}logBeacon(e){let t="log.externalLog",i=this.createLogParams(e),o=this.sessionKey;if(!o)return;this.params.apiTransport.sendBeacon(t,i,o)||this.logRequest(e)}async logRequest(e){var u;let t="log.externalLog",i=this.createLogParams(e),o=(u=this.sessionKey)!=null?u:await this._authorizeWithBackoff();if(!o)return;let a=async(d,p=this.params.config.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(t,i,o)}catch(c){if(!c||!("error_code"in c)){this.params.error$.next({id:"logRequestUnknown",category:k.ErrorCategory.NETWORK,message:`Unknown ${t} error`,thrown:c});return}let f=c==null?void 0:c.error_code;switch(f){case 102:case 103:case 104:return this.authorized$.next(!1),this.sessionKey=await this._authorizeWithBackoff(),p>0?a(d,p-1):void 0;case 401:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorizeWithBackoff(),p>0?a(d,p-1):void 0;default:{this.params.error$.next({id:`LogRequest#${f}`,category:k.ErrorCategory.EXTERNAL_API,message:`${t} error`,data:c});return}}}};return a(e)}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}async refreshAuthToken(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=(0,_r.default)(this.params.refreshAuthToken(),()=>{this.refreshAuthTokenPromise=void 0})),this.refreshAuthTokenPromise}createLogParams(e){return{collector:"ok.mobile.apps.video",data:JSON.stringify({application:`@vkontakte/videoplayer-statistics:${De}`,platform:this.params.mobile?"M_WEB":"WEB",items:this.params.config.shorten?e.map(Sc):e})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();let e=(0,k.getExponentialDelay)(this.consequentAuthErrors,this.params.config.backoff);return new Promise(t=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout(()=>{(0,_r.default)(this._authorize().then(t).catch(i=>this.params.error$.next({id:"AuthorizeBackoff",category:k.ErrorCategory.NETWORK,message:"Otherwise unhandled error in authorization",thrown:i})),()=>this.backoffTimeoutId=0)},e))})}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);let e="auth.anonymLogin",t={session_data:{version:2,device_id:this.params.deviceId,client_version:De.split("-")[0],client_type:"SDK_JS"}};return this.authToken!==void 0&&(t.session_data.auth_token=this.authToken,t.session_data.version=3),this.authorizePromise=(0,_r.default)(this.params.apiTransport.sendRequest(e,t).then(i=>{var o;return(!i||!i.session_key)&&this.params.error$.next({id:"AuthorizeFailed",category:k.ErrorCategory.EXTERNAL_API,message:"No session key",data:i}),this.sessionKey=(o=i==null?void 0:i.session_key)!=null?o:void 0,this.sessionKey}).catch(async i=>{this.sessionKey=void 0;let o=i==null?void 0:i.error_code;switch(o){case 401:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}o?this.params.error$.next({id:`Authorize#${o}`,category:k.ErrorCategory.EXTERNAL_API,message:"authorize error",data:i}):this.params.error$.next({id:"AuthorizeUnknown",category:k.ErrorCategory.NETWORK,message:"authorize error",thrown:i})}),()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise}};var wr=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,t,i){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:i})}removeEventListener(e,t){if(!(e in this.listeners))return;let i=this.listeners[e];for(let o=0,a=i.length;o<a;o++)if(i[o].callback===t){i.splice(o,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let i=this.listeners[e.type].slice();for(let o=0,a=i.length;o<a;o++){let u=i[o];try{u.callback.call(this,e)}catch(d){Promise.resolve().then(()=>{throw d})}u.options&&u.options.once&&this.removeEventListener(e.type,u.callback)}return!e.defaultPrevented}},ve=class extends wr{constructor(){super(),this.listeners||wr.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,e)),super.dispatchEvent(e)}},Me=class{constructor(){Object.defineProperty(this,"signal",{value:new ve,writable:!0,configurable:!0})}abort(e){let t;try{t=new Event("abort")}catch(o){typeof document!="undefined"?document.createEvent?(t=document.createEvent("Event"),t.initEvent("abort",!1,!1)):(t=document.createEventObject(),t.type="abort"):t={type:"abort",bubbles:!1,cancelable:!1}}let i=e;if(i===void 0)if(typeof document=="undefined")i=new Error("This operation was aborted"),i.name="AbortError";else try{i=new DOMException("signal is aborted without reason")}catch(o){i=new Error("This operation was aborted"),i.name="AbortError"}this.signal.reason=i,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}};typeof Symbol!="undefined"&&Symbol.toStringTag&&(Me.prototype[Symbol.toStringTag]="AbortController",ve.prototype[Symbol.toStringTag]="AbortSignal");function Rr(r){return r.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof r.Request=="function"&&!r.Request.prototype.hasOwnProperty("signal")||!r.AbortController}function qi(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o=!1}=r;if(!Rr({fetch:e,Request:t,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:e,Request:a};let a=t;(a&&!a.prototype.hasOwnProperty("signal")||o)&&(a=function(c,f){let v;f&&f.signal&&(v=f.signal,delete f.signal);let s=new t(c,f);return v&&Object.defineProperty(s,"signal",{writable:!1,enumerable:!1,configurable:!0,value:v}),s},a.prototype=t.prototype);let u=e;return{fetch:(p,c)=>{let f=a&&a.prototype.isPrototypeOf(p)?p.signal:c?c.signal:void 0;if(f){let v;try{v=new DOMException("Aborted","AbortError")}catch(l){v=new Error("Aborted"),v.name="AbortError"}if(f.aborted)return Promise.reject(v);let s=new Promise((l,m)=>{f.addEventListener("abort",()=>m(v),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([s,u(p,c)])}return u(p,c)},Request:a}}var je=Rr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Pc=je?qi({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Oi=je?Pc.fetch:window.fetch,cI=je?Pc.Request:window.Request,lI=je?Me:window.AbortController,fI=je?ve:window.AbortSignal;var V=require("@vkontakte/videoplayer-shared");var Fe=class{constructor(e){this.params=e,this.apiKey=e.apiKey,this.apiEnv=e.config.apiEnv,this.apiBaseUrl=Ti[this.apiEnv],this.timeSynchronisation=e.timeSynchronisation,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){var e;if(this.apiEnv!=="auto"||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{let t=atob("aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ="),o=await(await Oi(t,{method:"GET",mode:"cors",cache:"no-cache"})).json(),a=(e=o==null?void 0:o.Answer[0])==null?void 0:e.data;if(!a)throw new Error("Wrong DNS response");return a}catch(t){return this.params.error$.next({id:"OneStat:ApiTransport:resolveApiBaseUrl",category:V.ErrorCategory.NETWORK,message:"Unhandled resolve api base url error",thrown:t}),Ti.vk_alias}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(e,t,i){if(!window.Blob||!window.navigator.sendBeacon)return!1;let o=this._prepareQueryParams({method:e,queryParams:t,sessionKey:i}),a=new window.Blob([o.toString()],{type:"application/x-www-form-urlencoded"});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,a)}catch(u){this.params.error$.next({id:"OneStat:ApiTransport:sendBeacon",category:V.ErrorCategory.NETWORK,message:"Unhandled beacon error",thrown:u,data:{method:e,params:t}})}return!1}async sendRequest(e,t,i){let o=(0,V.now)(),a=u=>{if(u instanceof TypeError&&["Failed to fetch","NetworkError when attempting to fetch resource."].includes(u.message)){this.params.error$.next({id:"Network",category:V.ErrorCategory.NETWORK,message:"Request failed",thrown:u});return}this.params.error$.next({id:"OneStat:ApiTransport:sendRequest",category:V.ErrorCategory.NETWORK,message:"Unhandled request error",thrown:u,data:{method:e,params:t,sessionKey:i,time:(0,V.now)()-o}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),Oi(`${this.apiBaseUrl}/fb.do`,{method:"post",headers:{"Content-type":"application/x-www-form-urlencoded"},body:this._prepareQueryParams({method:e,queryParams:t,sessionKey:i})}).then(u=>{var f,v;let d=Number(u.headers.get("content-length"))===0,p=new Date((f=u.headers.get("date"))!=null?f:"").getTime(),c=(0,V.now)()-o;if(isFinite(p)&&((v=this.timeSynchronisation)==null||v.addServerTime(p,c)),!d)return u.json().then(s=>Object.prototype.hasOwnProperty.call(s,"error_msg")?Promise.reject(s):s,a)},a)}_prepareQueryParams(e){let t=new URLSearchParams({format:"JSON",method:e.method,application_key:this.apiKey});return e.sessionKey!==void 0&&t.append("session_key",e.sessionKey),Object.entries(e.queryParams).forEach(([i,o])=>t.append(i,typeof o=="string"?o:JSON.stringify(o))),t}};var w=require("@vkontakte/videoplayer-shared"),xr="onestat_events",_i=r=>e=>e.timestamp+r>=(0,w.now)(),Cr=class{constructor(e){this.unsaltedStorage=[];this.isPaused=!1;this.isUrgent=e=>{let{operation:t}=e;return["action_play","watch_coverage_record","watch_coverage_live"].includes(t)};this.params=e,this.api=e.api,this.error$=e.error$,this.userSalt=e.userSalt,this.loggerDebugLog=e.debugLogger.createComponentLog("stat logger"),this.firstFlush=(0,w.debounceFn)(()=>this.safeFlush(),this.params.config.firstFlushTime,{maxWait:this.params.config.firstFlushTime});let t=w.safeStorage.isPersistent()?this.params.config.flushMaxWait:0;this.debouncedFlush=(0,w.debounceFn)(()=>this.safeFlush(),this.params.config.flushDebounceTime,{maxWait:t}),this.subscription=this.api.authorized$.subscribe(i=>{i&&this.debouncedFlush()}),this.housekeepStorage()}safeFlush(){var e;try{this.flush()}catch(t){this.error$.next({id:"LoggerError",category:w.ErrorCategory.WTF,message:(e=String(t))!=null?e:"Unknown logger error",thrown:t})}}readFromStorage(){let e=w.safeStorage.get(xr);try{return e?JSON.parse(e):{}}catch(t){}return{}}addToStorage(e){var a;if(!this.userSalt){this.unsaltedStorage.push(e);return}let t=this.readFromStorage(),o=((a=t[this.userSalt])!=null?a:[]).filter(_i(this.params.config.storageExpiration));w.safeStorage.set(xr,JSON.stringify({...t,[this.userSalt]:[...o,e]}))}getFromStorage(){var i;return this.userSalt?((i=this.readFromStorage()[this.userSalt])!=null?i:[]).filter(_i(this.params.config.storageExpiration)):this.unsaltedStorage}markStorageSent(){if(!this.userSalt){this.unsaltedStorage=[];return}let e=this.readFromStorage();delete e[this.userSalt],w.safeStorage.set(xr,JSON.stringify(e))}housekeepStorage(){let e=this.readFromStorage();for(let[t,i]of Object.entries(e)){let o=i.filter(_i(this.params.config.storageExpiration));o.length?e[t]=o:delete e[t],this.loggerDebugLog({message:`${i.length} retrieved from storage, ${o.length} of them actual`})}w.safeStorage.set(xr,JSON.stringify(e))}log(e){this.addToStorage(e),!this.isPaused&&(this.isUrgent(e)?this.flush():this.lastVsid!==e.custom.vsid?this.firstFlush():this.debouncedFlush(),this.lastVsid=e.custom.vsid)}flush(e=!1){let t=this.getFromStorage();t.length!==0&&(this.api.authorized$.getValue()?(e&&this.params.config.useBeacon?(this.loggerDebugLog({message:`Flushing ${t.length} events through beacon`}),this.api.logBeacon(t)):(this.loggerDebugLog({message:`Flushing ${t.length} events`}),this.api.logRequest(t)),this.markStorageSent()):this.api.authorize(),this.firstFlush.cancel(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe(),this.firstFlush.cancel(),this.debouncedFlush.cancel()}};var g=require("@vkontakte/videoplayer-core"),wi=require("@vkontakte/videoplayer-shared");var Tc=r=>r&&{[g.VideoQuality.INVARIANT]:"unknown",[g.VideoQuality.Q_144P]:"mobile",[g.VideoQuality.Q_240P]:"lowest",[g.VideoQuality.Q_360P]:"low",[g.VideoQuality.Q_480P]:"medium",[g.VideoQuality.Q_720P]:"high",[g.VideoQuality.Q_1080P]:"fullhd",[g.VideoQuality.Q_1440P]:"quadhd",[g.VideoQuality.Q_2160P]:"ultrahd",[g.VideoQuality.Q_4320P]:"unknown"}[r],Ri=r=>r&&{[g.HttpConnectionType.HTTP1]:"http1",[g.HttpConnectionType.HTTP2]:"http2",[g.HttpConnectionType.QUIC]:"http3"}[r],qc=r=>{if(r!==void 0)switch(r){case g.VideoFormat.MPEG:return"mp4";case g.VideoFormat.DASH:case g.VideoFormat.DASH_LIVE:case g.VideoFormat.DASH_STREAMS:return"dash";case g.VideoFormat.DASH_SEP:return"dash_sep";case g.VideoFormat.DASH_ONDEMAND:return"ondemand_dash";case g.VideoFormat.DASH_WEBM:case g.VideoFormat.DASH_LIVE_WEBM:return"webm";case g.VideoFormat.DASH_WEBM_AV1:return"av1";case g.VideoFormat.DASH_LIVE_CMAF:return"ondemand_dash_live";case g.VideoFormat.HLS:case g.VideoFormat.HLS_LIVE:return"hls";case g.VideoFormat.HLS_ONDEMAND:return"ondemand_hls";case g.VideoFormat.HLS_LIVE_CMAF:return"ondemand_hls_live";case g.VideoFormat.WEB_RTC_LIVE:return"webrtc";default:return(0,wi.assertNever)(r)}},Ar=r=>{if(r!==void 0)switch(r){case g.Surface.NONE:case g.Surface.INLINE:return;case g.Surface.FULLSCREEN:return"fullscreen";case g.Surface.SECOND_SCREEN:return"chromecast";case g.Surface.PIP:return"pip";case g.Surface.INVISIBLE:return"invisible";default:return(0,wi.assertNever)(r)}},Oc=r=>{switch(r){case"slow-2g":return"poor";case"2g":return"poor";case"3g":return"good";case"4g":return"excellent"}};var Nr=class{constructor(e){this.offset=void 0;this.offset=e}getOffset(){var e;return(e=this.offset)!=null?e:0}setOffset(e){this.offset=e}now(){var e;return Date.now()+((e=this.offset)!=null?e:0)}date(e=new Date){var t;return e.setTime(e.getTime()+((t=this.offset)!=null?t:0)),e}addServerTime(e,t){let i=Date.now(),o=e-i-t/2;if(Math.abs(o)<1e3){this.offset=0;return}this.offset===void 0?this.offset=Math.round(o):this.offset=Math.round(.2*o+(1-.2)*this.offset)}};var _c=()=>Math.floor(Math.random()*4294967296).toString(36).padStart(7,"0"),wc=()=>Math.floor(Math.random()*18446744073709552e3).toString(36).padStart(13,"0");var xi=require("@vkontakte/videoplayer-core"),b=require("@vkontakte/videoplayer-shared"),Rc=(r,e)=>new b.Observable(t=>{let i=new b.Subscription,o=(0,b.merge)((0,b.fromEvent)(window,"beforeunload"),r.events.willDestruct$),a=new b.ValueSubject(void 0),u;i.add(r.info.isLive$.pipe((0,b.filterChanged)()).subscribe(G=>{u&&(u.unsubscribe(),a.next(void 0)),G?u=r.info.liveTime$.pipe((0,b.map)(Dr=>Dr&&Dr/1e3)).subscribe(a):u=r.info.position$.subscribe(a),i.add(u)}));let{playing$:d,paused$:p}=r.events,c=r.events.willSeek$.pipe((0,b.filter)(()=>r.info.playbackState$.getValue()===xi.PlaybackState.PLAYING)),f=r.events.seeked$.pipe((0,b.filter)(()=>r.info.playbackState$.getValue()===xi.PlaybackState.PLAYING)),v=!1,s=new b.Subject;i.add(c.subscribe(()=>{v||s.next(),v=!0})),i.add(f.subscribe(()=>v=!1));let l=new b.Subject,m=new b.Subject,I=(0,b.merge)(d,f,l),S=(0,b.merge)(p,s,o,r.events.looped$,m),y,T=()=>y=a.getValue(),Nc=()=>{let G=a.getValue();(0,b.isNullable)(y)||y===G||(0,b.isNullable)(G)||(t.next({from:y,to:G}),y=void 0)},Lc=()=>{m.next(),l.next()};if(i.add(I.subscribe(T)),i.add(S.subscribe(Nc)),e.forceInterval&&isFinite(e.forceInterval)){let G=0;i.add(I.subscribe(()=>G=window.setTimeout(Lc,e.forceInterval))),i.add(S.subscribe(()=>window.clearTimeout(G)))}return i});var Ac="_one-stat_",xc=`${Ac}uuid`,Cc=`${Ac}deviceId`,Ci=()=>{let r=new h.Subscription;return{subscription:r,subscribe:(e,t)=>{e&&r.add(e.subscribe(t))}}},Lr=class{constructor(e,t){this.subscription=new h.Subscription;this.debugLogger=new kr.Logger;this.oneStatDebugLog=this.debugLogger.createComponentLog("onestat");this.loopCounter=0;this.disabled=!1;this.vsid$=new h.ValueSubject(void 0);this.isid$=new h.ValueSubject(void 0);this.seekAction$=new h.ValueSubject("unknown");var c,f,v;this.statContext=e,this.config=ji((c=t.config)!=null?c:{}),(0,h.isNonNullable)(t.apiEnv)&&(this.config.apiEnv=t.apiEnv),this.config.synchronizeTime&&(this.timeSynchronisation=new Nr);let i=new h.Subject;this.experimental={error$:i},h.safeStorage.get(xc)&&h.safeStorage.remove(xc);let a=h.safeStorage.get(Cc);this.statContext.deviceId?this.deviceId=this.statContext.deviceId:a?this.deviceId=a:(this.deviceId=Mr(),h.safeStorage.set(Cc,this.deviceId)),this.resetViewSession(),t.useIsid&&this.isid$.next((f=t.isid)!=null?f:wc());let u=new Fe({apiKey:Ec,config:this.config,error$:i,timeSynchronisation:this.timeSynchronisation});this.api=new $e({config:this.config,apiTransport:u,refreshAuthToken:t.refreshAuthToken,mobile:(v=this.statContext.mobile)!=null?v:!1,deviceId:this.deviceId,error$:i}),this.logger=new Cr({config:this.config,debugLogger:this.debugLogger,api:this.api,error$:i,userSalt:t.userSalt});let{isEmbed:d,host:p}=(0,kr.detectEmbed)();this.isEmbed=d,this.embedParent=p,this.subscribe()}updateContext(e){this.statContext={...this.statContext,...e}}attachTo(e){let t=new h.Subscription,i=(s,l)=>t.add(s.subscribe(l));i(e.events.willStart$,()=>{let s=e.info.position$.getValue();this.logActionPlay({position:s}),this.statContext.projectId&&this.logActionPlayInteractive()}),i(e.events.looped$,()=>{this.resetViewSession(),++this.loopCounter>this.config.maxLoops&&(this.disabled=!0),this.logActionPlay({position:e.info.position$.getValue()})}),i(e.events.seeked$,()=>{this.logSeek({action:this.seekAction$.getValue(),time:e.info.position$.getValue()}),this.seekAction$.next("unknown")}),i(e.events.paused$,()=>{this.logPause({position:e.info.position$.getValue()})}),i(e.events.willResume$,()=>{this.logPlay()}),i(e.events.started$,()=>{this.statContext.clip&&this.logWatchCoverageRecord({start:0,end:0})}),i(e.events.playing$,()=>{this.logPlaying()}),i(Rc(e,{forceInterval:this.config.watchCoverageInterval}),s=>{let l=e.info.isLive$.getValue(),m={start:parseFloat(s.from.toFixed(3)),end:parseFloat(s.to.toFixed(3))};l?this.logWatchCoverageLive(m):this.logWatchCoverageRecord(m)});let o;i(e.info.isStalled$,s=>{s?o=(0,h.now)():((0,h.isNonNullable)(o)&&this.logEmptyBuffer({duration:(0,h.now)()-o}),o=void 0)});let a=!1;t.add(e.events.fatalError$.pipe((0,h.once)()).subscribe(()=>a=!0)),i(e.events.willStop$,()=>{if(e.info.isStalled$.getValue()){let l=(0,h.isNonNullable)(o)?(0,h.now)()-o:void 0;this.logCloseAtEmptyBuffer({duration:l!=null?l:0}),o=void 0}else a||this.logActionStop()}),i(e.events.managedError$,({id:s})=>{this.logError({fatal:!1,errorType:s})}),i(e.events.fatalError$,({id:s})=>{this.logError({fatal:!0,errorType:s})});let u,d,p=!1;i(e.events.firstBytes$,s=>{u=(0,h.now)(),this.logFirstBytes({time:s})}),i(e.events.willStart$,()=>d=(0,h.now)()),i(e.info.currentBuffer$,s=>{!p&&s&&s.end-s.start>0&&(0,h.isNonNullable)(u)&&(this.logPlayerReady({duration:(0,h.now)()-u}),p=!0)}),i(e.events.firstFrame$,()=>{(0,h.isNonNullable)(u)&&!p&&(this.logPlayerReady({duration:(0,h.now)()-u}),p=!0),(0,h.isNonNullable)(d)&&this.logFirstFrame({time:(0,h.now)()-d})});let c;i(e.info.currentVideoStream$,s=>{s&&(c&&s.id!==c&&this.logTrackSwitch(s),c=s.id)});let f;i(e.info.currentAudioStream$,s=>{s&&(f&&s.id!==f&&this.logTrackSwitch(s),f=s.id)}),i(e.info.atLiveEdge$,s=>this.updateContext({liveEdge:s})),i((0,h.combine)({muted:e.info.muted$,volume:e.info.volume$}),({muted:s,volume:l})=>this.updateContext({audible:!s&&l>0})),i(e.info.currentQuality$,s=>this.updateContext({quality:Tc(s)})),i(e.info.isAutoQualityEnabled$,s=>this.updateContext({autoQuality:s})),i(e.info.currentFormat$,s=>this.updateContext({contentType:qc(s)})),i(e.info.currentPlaybackRate$,s=>this.updateContext({rate:s})),i(e.info.is3DVideo$,s=>this.updateContext({is3d:s}));let v;return i(e.info.hostname$,s=>{let l=v!==void 0&&v!==s;this.updateContext({cdnHostname:s,failover:l}),l&&this.logFailover(s),v=s}),i(e.info.throughputEstimation$,s=>this.updateContext({downloadSpeed:s})),i(e.info.httpConnectionType$,s=>{this.statContext.firstConnectionType||this.updateContext({firstConnectionType:Ri(s)}),this.updateContext({connectionType:Ri(s)})}),i(e.info.httpConnectionReused$,s=>{(0,h.isNullable)(this.statContext.firstConnectionReused)&&this.updateContext({firstConnectionReused:s}),this.updateContext({connectionReused:s})}),i(e.info.surface$,s=>this.updateContext({mode:Ar(s)})),i((0,h.combine)({current:e.info.currentTextTrack$,available:e.info.availableTextTracks$}),({current:s,available:l})=>{let m=l.find(({id:S})=>S===s),I=m&&(m.isAuto?`${m.language}_auto`:m.language);this.updateContext({subtitles:I})}),this.player=e,this.uiEvents&&this.attachToUi(this.uiEvents),this.resubscribeBeforeunload(),this.subscription.add(t),t}attachToUi(e){this.uiEvents=e;let{subscription:t,subscribe:i}=Ci();return this.player&&(i(e.actionRewind$,()=>{this.player&&(this.resetViewSession(),this.logActionPlay({position:this.player.info.position$.getValue()}))}),i(e.actionSeek$,this.seekAction$),i(e.inPiP$,o=>{var u;let a=o?"pip":Ar((u=this.player)==null?void 0:u.info.surface$.getValue());this.updateContext({mode:a})}),i(e.inFullscreen$,o=>{var u;let a=o?"fullscreen":Ar((u=this.player)==null?void 0:u.info.surface$.getValue());this.updateContext({mode:a})}),i(e.actionSetSubtitle$,o=>this.updateContext({subtitles:o})),i(e.nextMovie$,o=>this.logNextMovie(o)),this.resubscribeBeforeunload(),this.subscription.add(t)),t}attachToAds(e){let{subscription:t,subscribe:i}=Ci();return i(e.slotRequested$,()=>this.logAdSlotRequest()),i(e.started$,o=>this.logAdStarted(o)),i(e.paused$,()=>this.logAdPaused()),i(e.resumed$,()=>this.logAdResumed()),i(e.ended$,()=>this.logAdEnded()),i(e.skipped$,()=>this.logAdSkipped()),i(e.clicked$,()=>this.logAdClicked()),this.resubscribeBeforeunload(),this.subscription.add(t),t}attachToInteractive(e){let{subscription:t,subscribe:i}=Ci();return i(e.click$,o=>this.logInterfaceClick(o)),i(e.nextMovie$,o=>this.logNextMovie(o)),this.resubscribeBeforeunload(),this.subscription.add(t),t}authorize(e){return this.api.authorize(e)}pause(){this.logger.pause(),this.oneStatDebugLog({message:"paused"})}resume(){this.logger.resume(),this.oneStatDebugLog({message:"resumed"})}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}resetViewSession(){this.oneStatDebugLog({message:"VSID reset"}),this.vsid$.next(_c())}getDeviceId(){return this.deviceId}setFieldBlacklist(){}logInited(){}logReady(e){this.log({operation:"player_ready",param:String(e.time)})}logStarted(...e){this.logActionPlay(...e)}logPlay(){this.log({operation:"play_toggle"})}logPlaying(){this.log({operation:"playing"})}logPause(e){this.log({operation:"pause",param:String(Math.round(e.position))})}logSeek(e){this.log({operation:"seek",param:e.action,time:e.time})}logFirstBytes(e){this.log({operation:"first_bytes",param:String(e.time)})}logFirstFrame(e){this.log({operation:"first_frame",param:String(e.time)})}logError(e){this.log({operation:"content_error",param:`${e.fatal?"fatal":"recoverable"}_${e.errorType}`})}logWatchCoverageRecord(e){this.log({operation:"watch_coverage_record",param:`${e.start}-${e.end}`},{in_history:this.statContext.inHistory?1:void 0})}logWatchCoverageLive(e){var a,u;let t=(u=(a=this.timeSynchronisation)==null?void 0:a.getOffset())!=null?u:0,i=e.start+t,o=e.end+t;this.log({operation:"watch_coverage_live",param:`${i}-${o}`},{in_history:this.statContext.inHistory?1:void 0})}logEmptyBuffer(e){this.log({operation:"empty_buffer",param:String(e.duration)})}logDownloadSpeed(){}logAdSlotRequest(){this.log({operation:"adv",param:"slot_request"})}logAdStarted(e){this.log({operation:"adv",param:e})}logAdPaused(){this.log({operation:"adv",param:"pause"})}logAdResumed(){this.log({operation:"adv",param:"resume"})}logAdEnded(){this.log({operation:"adv",param:"ended"})}logAdSkipped(){this.log({operation:"adv",param:"skip"})}logAdClicked(){this.log({operation:"adv",param:"click"})}logInterfaceClick(e){this.log({operation:"player_interface_click",param:e})}logNextMovie(e){this.log({operation:"next_movie",param:String(e)})}subscribe(){this.resubscribeBeforeunload();let e=window.navigator.connection;e&&"onchange"in e&&"effectiveType"in e&&this.subscription.add((0,h.merge)((0,h.fromEvent)(e,"change"),(0,h.observableFrom)(["init"])).subscribe(()=>this.updateContext({network:Oc(e.effectiveType)}))),this.config.debugLog&&this.debugLogger.log$.subscribe(t=>{console.debug("%c stat ","background:#fa6470;",`component: ${t.component}.`,t.message)})}resubscribeBeforeunload(){var e;(e=this.beforeunloadSubscription)==null||e.unsubscribe(),this.beforeunloadSubscription=(0,h.fromEvent)(window,"beforeunload").subscribe(()=>this.logger.flush(!0)),this.subscription.add(this.beforeunloadSubscription)}logPlayerReady(e){this.log({operation:"player_ready",param:String(Math.round(e.duration))})}logActionPlay(e){this.log({operation:"action_play",param:String(Math.round(e.position))})}logActionPlayInteractive(){this.statContext.projectId&&this.log({operation:"action_play_interactive",param:String(this.statContext.movieId)},{vid:this.statContext.projectId})}logFailover(e){this.log({operation:"failover",param:e})}logCloseAtEmptyBuffer(e){this.log({operation:"close_at_empty_buffer",param:String(Math.round(e.duration))})}logActionStop(){this.log({operation:"action_stop"})}logTrackSwitch(e){this.log({operation:"track_switch",param:e.id})}log(e,t={}){if(this.disabled){this.oneStatDebugLog({message:`operation ${e.operation} but statistics is disabled`});return}if(this.config.disabledOperations.includes(e.operation)){this.oneStatDebugLog({message:`operation ${e.operation} but it is disabled`});return}this.oneStatDebugLog({message:`operation ${e.operation} ${e.param}`});let i=this.createLogItem(e,t);this.logger.log(i)}createLogItem({operation:e,param:t,time:i},o={}){var l,m;let a=(m=(l=this.timeSynchronisation)==null?void 0:l.now())!=null?m:(0,h.now)(),u=this.vsid$.getValue();(0,h.assertNonNullable)(u);let d=this.isid$.getValue(),p=e==="empty_buffer"||e==="close_at_empty_buffer"?this.statContext.connectionType:this.statContext.firstConnectionType,c=this.statContext.firstConnectionReused,f,v;if(this.isEmbed){f=this.embedParent;let I=[...new URLSearchParams(location.search).entries()].filter(([S,y])=>this.config.embedUrlParams.includes(S));v=new URLSearchParams(I).toString()}else this.statContext.place==="direct"&&((this.statContext.refDomain||document.referrer)&&(f=new URL(this.statContext.refDomain||document.referrer).hostname),v=location.href.substring(0,1024));let s={vsid:u,isid:d,vid:this.statContext.movieId,ct:this.statContext.contentType,place:this.isEmbed?"embed":this.statContext.place,quality:this.statContext.quality,cdn_host:this.statContext.cdnHostname,stat_type:this.statContext.autoplay===!0?"auto":this.statContext.autoplay===!1?"":void 0,param:t,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode,connection_type:p,connection_reused:c===!0?1:c===!1?0:void 0,cached_data:this.statContext.cached===!0?1:this.statContext.cached===!1?0:void 0,live:this.statContext.liveEdge?1:void 0,muted:this.statContext.audible===!1?1:void 0,mode:this.statContext.mode,subtitles:this.statContext.subtitles,download_speed:this.statContext.downloadSpeed,manual_quality:this.statContext.autoQuality?void 0:1,ref_domain:f,direct_url:v,rate:this.statContext.rate===1||(0,h.isNullable)(this.statContext.rate)?void 0:this.statContext.rate.toFixed(2),view_360:this.statContext.is3d?1:void 0,aid:this.statContext.albumId,vk_playlist_id:this.statContext.vkPlaylistId,...o};for(let I of this.config.disabledCustomFields)delete s[I];return{operation:e,type:1,time:i,network:this.statContext.network,timestamp:a,custom:s}}};
package/es2018.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @vkontakte/videoplayer-statistics v1.0.52-dev.f8fa60d9.0
3
- * Thu, 15 Aug 2024 18:55:46 GMT
4
- * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-52/doc/
2
+ * @vkontakte/videoplayer-statistics v1.0.53-beta.0
3
+ * Wed, 21 Aug 2024 12:58:20 GMT
4
+ * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-53/doc/
5
5
  */
6
- var E=(r=>(r.PROD="prod",r.VK_ALIAS="vk_alias",r.VIDEOTEST="videotest",r.TEST="test",r.OKCDN="okcdn",r.AUTO="auto",r))(E||{}),D=(d=>(d.Q144P="mobile",d.Q240P="lowest",d.Q360P="low",d.Q480P="medium",d.Q720P="high",d.Q1080P="fullhd",d.Q1440P="quadhd",d.Q2160P="ultrahd",d.UNKNOWN="unknown",d))(D||{}),M=(u=>(u.MP4="mp4",u.DASH="dash",u.DASH_SEP="dash_sep",u.ONDEMAND_DASH="ondemand_dash",u.HLS="hls",u.ONDEMAND_HLS="ondemand_hls",u.WEBM="webm",u.AV1="av1",u.ONDEMAND_DASH_LIVE="ondemand_dash_live",u.ONDEMAND_HLS_LIVE="ondemand_hls_live",u.WEBRTC="webrtc",u.UNKNOWN="unknown",u.RTMP="rtmp",u))(M||{});var B=(t=>(t.HTTP1="http1",t.HTTP2="http2",t.HTTP3="http3",t))(B||{});var F=(c=>(c.SLIDER="slider",c.DOUBLE_TAP="double_tap",c.TIME_CODE="time_code",c.EPISODE="episode",c.REWIND="rewind",c.LIVE="live",c.UNKNOWN="unknown",c))(F||{}),ee=(n=>(n.GRAPH_SHOW="iGraphShow",n.GRAPH_HIDE="iGraphHide",n.NEXT_AREA="iNextChapterArea",n.NEXT_BUTTON="iNextChapterBtn",n.WATCH_AGAIN="iWatchAgainBtn",n))(ee||{}),te={action_play:"ap",action_play_interactive:"api",first_bytes:"fb",player_ready:"pr",first_frame:"ff",seek:"sk",watch_coverage_record:"wr",watch_coverage_live:"wl",empty_buffer:"eb",action_stop:"as",close_at_empty_buffer:"cb",content_error:"er",player_interface_click:"pc",next_movie:"nm",track_switch:"ts",failover:"fo"},ie={vsid:"si",isid:"is",vid:"vi",place:"pl",quality:"qt",cdn_host:"ch",stat_type:"st",param:"pm",vk_app_id:"va",track_code:"tc",connection_type:"cnt",connection_reused:"cr",cached_data:"cd",live:"lv",muted:"mu",mode:"mo",subtitles:"sb",failover:"fo",download_speed:"ds",manual_quality:"mq",ref_domain:"rd",direct_url:"du"},oe={unknown:"un",mobile:"m",lowest:"ls",low:"l",medium:"md",high:"h",fullhd:"f",quadhd:"q",ultrahd:"u"},se={pip:"pi",fullscreen:"fs",external:"ex",prefetch:"pr",airplay:"ap",chromecast:"cc",invisible:"iv"};import{fillWithDefault as Ee}from"@vkontakte/videoplayer-shared";var xe={apiEnv:"vk_alias",requestRetryCount:1,firstFlushTime:5e3,flushDebounceTime:1e4,flushMaxWait:6e4,storageExpiration:36*60*60*1e3,watchCoverageInterval:15e3,disabledOperations:[],disabledCustomFields:[],shorten:!0,maxLoops:100,embedUrlParams:[],useBeacon:!0,synchronizeTime:!0,debugLog:!1,backoff:{start:1e3,factor:1.5,max:5*60*1e3,random:.1}},re=a=>Ee(a,xe);function V(){let a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),e=new Array(36),i=0,t,o;for(o=0;o<36;o++)o===8||o===13||o===18||o===23?e[o]="-":o===14?e[o]="4":(i<=2&&(i=33554432+Math.random()*16777216|0),t=i&15,i=i>>4,e[o]=a[o===19?t&3|8:t]);return e.join("")}import{assertNonNullable as Be,combine as Ie,fromEvent as Se,isNonNullable as A,isNullable as ye,merge as Fe,now as b,observableFrom as Ve,once as Ue,safeStorage as j,Subject as We,Subscription as J,ValueSubject as G}from"@vkontakte/videoplayer-shared";import{Logger as He,detectEmbed as Ke}from"@vkontakte/videoplayer-shared";var ne=a=>{var o;let{operation:e,custom:i}=a,t=Object.fromEntries(Object.entries(i).map(([n,r])=>{var d,p,h;let c=(d=ie[n])!=null?d:n,l=r;return r&&(n==="mode"?l=(p=se[r])!=null?p:r:n==="quality"&&(l=(h=oe[r])!=null?h:r)),[c,l]}));return{...a,operation:(o=te[e])!=null?o:e,custom:t}};var w="1.0.52-dev.f8fa60d9.0",ae="CIOPGQJGDIHBABABA",U={prod:"https://api.ok.ru",vk_alias:"https://api.mycdn.me",videotest:"https://videotestapi.ok.ru/api",test:"https://apitest.ok.ru",okcdn:"https://api.okcdn.ru",auto:""};import{ValueSubject as Ce,getExponentialDelay as Te,ErrorCategory as P}from"@vkontakte/videoplayer-shared";var x=class{constructor(e){this.consequentAuthErrors=0;this.authorized$=new Ce(!1);this.params=e}async authorize(e){return this.authToken=e!=null?e:await this.refreshAuthToken(),this._authorizeWithBackoff()}logBeacon(e){let i="log.externalLog",t=this.createLogParams(e),o=this.sessionKey;if(!o)return;this.params.apiTransport.sendBeacon(i,t,o)||this.logRequest(e)}async logRequest(e){var r;let i="log.externalLog",t=this.createLogParams(e),o=(r=this.sessionKey)!=null?r:await this._authorizeWithBackoff();if(!o)return;let n=async(c,l=this.params.config.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(i,t,o)}catch(d){if(!d||!("error_code"in d)){this.params.error$.next({id:"logRequestUnknown",category:P.NETWORK,message:`Unknown ${i} error`,thrown:d});return}let p=d==null?void 0:d.error_code;switch(p){case 102:case 103:case 104:return this.authorized$.next(!1),this.sessionKey=await this._authorizeWithBackoff(),l>0?n(c,l-1):void 0;case 401:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorizeWithBackoff(),l>0?n(c,l-1):void 0;default:{this.params.error$.next({id:`LogRequest#${p}`,category:P.EXTERNAL_API,message:`${i} error`,data:d});return}}}};return n(e)}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}async refreshAuthToken(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=this.params.refreshAuthToken().finally(()=>{this.refreshAuthTokenPromise=void 0})),this.refreshAuthTokenPromise}createLogParams(e){return{collector:"ok.mobile.apps.video",data:JSON.stringify({application:`@vkontakte/videoplayer-statistics:${w}`,platform:this.params.mobile?"M_WEB":"WEB",items:this.params.config.shorten?e.map(ne):e})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();let e=Te(this.consequentAuthErrors,this.params.config.backoff);return new Promise(i=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout(()=>{this._authorize().then(i).catch(t=>this.params.error$.next({id:"AuthorizeBackoff",category:P.NETWORK,message:"Otherwise unhandled error in authorization",thrown:t})).finally(()=>this.backoffTimeoutId=0)},e))})}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);let e="auth.anonymLogin",i={session_data:{version:2,device_id:this.params.uuid,client_version:w.split("-")[0],client_type:"SDK_JS"}};return this.authToken!==void 0&&(i.session_data.auth_token=this.authToken,i.session_data.version=3),this.authorizePromise=this.params.apiTransport.sendRequest(e,i).then(t=>{var o;return(!t||!t.session_key)&&this.params.error$.next({id:"AuthorizeFailed",category:P.EXTERNAL_API,message:"No session key",data:t}),this.sessionKey=(o=t==null?void 0:t.session_key)!=null?o:void 0,this.sessionKey}).catch(async t=>{this.sessionKey=void 0;let o=t==null?void 0:t.error_code;switch(o){case 401:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}o?this.params.error$.next({id:`Authorize#${o}`,category:P.EXTERNAL_API,message:"authorize error",data:t}):this.params.error$.next({id:"AuthorizeUnknown",category:P.NETWORK,message:"authorize error",thrown:t})}).finally(()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise}};import{ErrorCategory as k,now as W}from"@vkontakte/videoplayer-shared";var C=class{constructor(e){this.params=e,this.apiKey=e.apiKey,this.apiEnv=e.config.apiEnv,this.apiBaseUrl=U[this.apiEnv],this.timeSynchronisation=e.timeSynchronisation,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){var e;if(this.apiEnv!=="auto"||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{let i=atob("aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ="),o=await(await fetch(i,{method:"GET",mode:"cors",cache:"no-cache"})).json(),n=(e=o==null?void 0:o.Answer[0])==null?void 0:e.data;if(!n)throw new Error("Wrong DNS response");return n}catch(i){return this.params.error$.next({id:"OneStat:ApiTransport:resolveApiBaseUrl",category:k.NETWORK,message:"Unhandled resolve api base url error",thrown:i}),U.vk_alias}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(e,i,t){if(!window.Blob||!window.navigator.sendBeacon)return!1;let o=this._prepareQueryParams({method:e,queryParams:i,sessionKey:t}),n=new window.Blob([o.toString()],{type:"application/x-www-form-urlencoded"});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,n)}catch(r){this.params.error$.next({id:"OneStat:ApiTransport:sendBeacon",category:k.NETWORK,message:"Unhandled beacon error",thrown:r,data:{method:e,params:i}})}return!1}async sendRequest(e,i,t){let o=W(),n=r=>{if(r instanceof TypeError&&["Failed to fetch","NetworkError when attempting to fetch resource."].includes(r.message)){this.params.error$.next({id:"Network",category:k.NETWORK,message:"Request failed",thrown:r});return}this.params.error$.next({id:"OneStat:ApiTransport:sendRequest",category:k.NETWORK,message:"Unhandled request error",thrown:r,data:{method:e,params:i,sessionKey:t,time:W()-o}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),fetch(`${this.apiBaseUrl}/fb.do`,{method:"post",headers:{"Content-type":"application/x-www-form-urlencoded"},body:this._prepareQueryParams({method:e,queryParams:i,sessionKey:t})}).then(r=>{var p,h;let c=Number(r.headers.get("content-length"))===0,l=new Date((p=r.headers.get("date"))!=null?p:"").getTime(),d=W()-o;if(isFinite(l)&&((h=this.timeSynchronisation)==null||h.addServerTime(l,d)),!c)return r.json().then(s=>Object.prototype.hasOwnProperty.call(s,"error_msg")?Promise.reject(s):s,n)},n)}_prepareQueryParams(e){let i=new URLSearchParams({format:"JSON",method:e.method,application_key:this.apiKey});return e.sessionKey!==void 0&&i.append("session_key",e.sessionKey),Object.entries(e.queryParams).forEach(([t,o])=>i.append(t,typeof o=="string"?o:JSON.stringify(o))),i}};import{ErrorCategory as we,now as ke,safeStorage as T,debounceFn as de}from"@vkontakte/videoplayer-shared";var L="onestat_events",H=a=>e=>e.timestamp+a>=ke(),$=class{constructor(e){this.unsaltedStorage=[];this.isPaused=!1;this.isUrgent=e=>{let{operation:i}=e;return["action_play","watch_coverage_record","watch_coverage_live"].includes(i)};this.params=e,this.api=e.api,this.error$=e.error$,this.userSalt=e.userSalt,this.loggerDebugLog=e.debugLogger.createComponentLog("stat logger"),this.firstFlush=de(()=>this.safeFlush(),this.params.config.firstFlushTime,{maxWait:this.params.config.firstFlushTime});let i=T.isPersistent()?this.params.config.flushMaxWait:0;this.debouncedFlush=de(()=>this.safeFlush(),this.params.config.flushDebounceTime,{maxWait:i}),this.subscription=this.api.authorized$.subscribe(t=>{t&&this.debouncedFlush()}),this.housekeepStorage()}safeFlush(){var e;try{this.flush()}catch(i){this.error$.next({id:"LoggerError",category:we.WTF,message:(e=String(i))!=null?e:"Unknown logger error",thrown:i})}}readFromStorage(){let e=T.get(L);try{return e?JSON.parse(e):{}}catch(i){}return{}}addToStorage(e){var n;if(!this.userSalt){this.unsaltedStorage.push(e);return}let i=this.readFromStorage(),o=((n=i[this.userSalt])!=null?n:[]).filter(H(this.params.config.storageExpiration));T.set(L,JSON.stringify({...i,[this.userSalt]:[...o,e]}))}getFromStorage(){var t;return this.userSalt?((t=this.readFromStorage()[this.userSalt])!=null?t:[]).filter(H(this.params.config.storageExpiration)):this.unsaltedStorage}markStorageSent(){if(!this.userSalt){this.unsaltedStorage=[];return}let e=this.readFromStorage();delete e[this.userSalt],T.set(L,JSON.stringify(e))}housekeepStorage(){let e=this.readFromStorage();for(let[i,t]of Object.entries(e)){let o=t.filter(H(this.params.config.storageExpiration));o.length?e[i]=o:delete e[i],this.loggerDebugLog({message:`${t.length} retrieved from storage, ${o.length} of them actual`})}T.set(L,JSON.stringify(e))}log(e){this.addToStorage(e),!this.isPaused&&(this.isUrgent(e)?this.flush():this.lastVsid!==e.custom.vsid?this.firstFlush():this.debouncedFlush(),this.lastVsid=e.custom.vsid)}flush(e=!1){let i=this.getFromStorage();i.length!==0&&(this.api.authorized$.getValue()?(e&&this.params.config.useBeacon?(this.loggerDebugLog({message:`Flushing ${i.length} events through beacon`}),this.api.logBeacon(i)):(this.loggerDebugLog({message:`Flushing ${i.length} events`}),this.api.logRequest(i)),this.markStorageSent()):this.api.authorize(),this.firstFlush.cancel(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe(),this.firstFlush.cancel(),this.debouncedFlush.cancel()}};import{HttpConnectionType as K,Surface as _,VideoFormat as f,VideoQuality as m}from"@vkontakte/videoplayer-core";import{assertNever as ue}from"@vkontakte/videoplayer-shared";var ce=a=>a&&{[m.INVARIANT]:"unknown",[m.Q_144P]:"mobile",[m.Q_240P]:"lowest",[m.Q_360P]:"low",[m.Q_480P]:"medium",[m.Q_720P]:"high",[m.Q_1080P]:"fullhd",[m.Q_1440P]:"quadhd",[m.Q_2160P]:"ultrahd",[m.Q_4320P]:"unknown"}[a],q=a=>a&&{[K.HTTP1]:"http1",[K.HTTP2]:"http2",[K.QUIC]:"http3"}[a],le=a=>{if(a!==void 0)switch(a){case f.MPEG:return"mp4";case f.DASH:case f.DASH_LIVE:case f.DASH_STREAMS:return"dash";case f.DASH_SEP:return"dash_sep";case f.DASH_ONDEMAND:return"ondemand_dash";case f.DASH_WEBM:case f.DASH_LIVE_WEBM:return"webm";case f.DASH_WEBM_AV1:return"av1";case f.DASH_LIVE_CMAF:return"ondemand_dash_live";case f.HLS:case f.HLS_LIVE:return"hls";case f.HLS_ONDEMAND:return"ondemand_hls";case f.HLS_LIVE_CMAF:return"ondemand_hls_live";case f.WEB_RTC_LIVE:return"webrtc";default:return ue(a)}},R=a=>{if(a!==void 0)switch(a){case _.NONE:case _.INLINE:return;case _.FULLSCREEN:return"fullscreen";case _.SECOND_SCREEN:return"chromecast";case _.PIP:return"pip";case _.INVISIBLE:return"invisible";default:return ue(a)}},pe=a=>{switch(a){case"slow-2g":return"poor";case"2g":return"poor";case"3g":return"good";case"4g":return"excellent"}};var O=class{constructor(e){this.offset=void 0;this.offset=e}getOffset(){var e;return(e=this.offset)!=null?e:0}setOffset(e){this.offset=e}now(){var e;return Date.now()+((e=this.offset)!=null?e:0)}date(e=new Date){var i;return e.setTime(e.getTime()+((i=this.offset)!=null?i:0)),e}addServerTime(e,i){let t=Date.now(),o=e-t-i/2;if(Math.abs(o)<1e3){this.offset=0;return}this.offset===void 0?this.offset=Math.round(o):this.offset=Math.round(.2*o+(1-.2)*this.offset)}};var he=()=>Math.floor(Math.random()*4294967296).toString(36).padStart(7,"0"),fe=()=>Math.floor(Math.random()*18446744073709552e3).toString(36).padStart(13,"0");import{PlaybackState as ge}from"@vkontakte/videoplayer-core";import{filter as me,filterChanged as $e,fromEvent as Re,isNullable as be,map as Oe,merge as z,Observable as Ne,Subject as Q,Subscription as De,ValueSubject as Me}from"@vkontakte/videoplayer-shared";var ve=(a,e)=>new Ne(i=>{let t=new De,o=z(Re(window,"beforeunload"),a.events.willDestruct$),n=new Me(void 0),r;t.add(a.info.isLive$.pipe($e()).subscribe(I=>{r&&(r.unsubscribe(),n.next(void 0)),I?r=a.info.liveTime$.pipe(Oe(N=>N&&N/1e3)).subscribe(n):r=a.info.position$.subscribe(n),t.add(r)}));let{playing$:c,paused$:l}=a.events,d=a.events.willSeek$.pipe(me(()=>a.info.playbackState$.getValue()===ge.PLAYING)),p=a.events.seeked$.pipe(me(()=>a.info.playbackState$.getValue()===ge.PLAYING)),h=!1,s=new Q;t.add(d.subscribe(()=>{h||s.next(),h=!0})),t.add(p.subscribe(()=>h=!1));let u=new Q,g=new Q,v=z(c,p,u),S=z(l,s,o,a.events.looped$,g),y,Pe=()=>y=n.getValue(),_e=()=>{let I=n.getValue();be(y)||y===I||be(I)||(i.next({from:y,to:I}),y=void 0)},Ae=()=>{g.next(),u.next()};if(t.add(v.subscribe(Pe)),t.add(S.subscribe(_e)),e.forceInterval&&isFinite(e.forceInterval)){let I=0;t.add(v.subscribe(()=>I=window.setTimeout(Ae,e.forceInterval))),t.add(S.subscribe(()=>window.clearTimeout(I)))}return t});var qe="_one-stat_",Y=`${qe}uuid`,X=()=>{let a=new J;return{subscription:a,subscribe:(e,i)=>{e&&a.add(e.subscribe(i))}}},Z=class{constructor(e,i){this.subscription=new J;this.debugLogger=new He;this.oneStatDebugLog=this.debugLogger.createComponentLog("onestat");this.loopCounter=0;this.disabled=!1;this.vsid$=new G(void 0);this.isid$=new G(void 0);this.seekAction$=new G("unknown");var l,d,p;this.statContext=e,this.config=re((l=i.config)!=null?l:{}),A(i.apiEnv)&&(this.config.apiEnv=i.apiEnv),this.config.synchronizeTime&&(this.timeSynchronisation=new O);let t=new We;this.experimental={error$:t};let o=j.get(Y);o?o.startsWith('"')&&o.endsWith('"')?(this.uuid=o.replaceAll('"',""),j.set(Y,this.uuid)):this.uuid=o:(this.uuid=V(),j.set(Y,this.uuid)),this.resetViewSession(),i.useIsid&&this.isid$.next((d=i.isid)!=null?d:fe());let n=new C({apiKey:ae,config:this.config,error$:t,timeSynchronisation:this.timeSynchronisation});this.api=new x({config:this.config,apiTransport:n,refreshAuthToken:i.refreshAuthToken,mobile:(p=this.statContext.mobile)!=null?p:!1,uuid:this.uuid,error$:t}),this.logger=new $({config:this.config,debugLogger:this.debugLogger,api:this.api,error$:t,userSalt:i.userSalt});let{isEmbed:r,host:c}=Ke();this.isEmbed=r,this.embedParent=c,this.subscribe()}updateContext(e){this.statContext={...this.statContext,...e}}attachTo(e){let i=new J,t=(s,u)=>i.add(s.subscribe(u));t(e.events.willStart$,()=>{let s=e.info.position$.getValue();this.logActionPlay({position:s}),this.statContext.projectId&&this.logActionPlayInteractive()}),t(e.events.looped$,()=>{this.resetViewSession(),++this.loopCounter>this.config.maxLoops&&(this.disabled=!0),this.logActionPlay({position:e.info.position$.getValue()})}),t(e.events.seeked$,()=>{this.logSeek({action:this.seekAction$.getValue(),time:e.info.position$.getValue()}),this.seekAction$.next("unknown")}),t(e.events.paused$,()=>{this.logPause({position:e.info.position$.getValue()})}),t(e.events.willResume$,()=>{this.logPlay()}),t(e.events.started$,()=>{this.statContext.clip&&this.logWatchCoverageRecord({start:0,end:0})}),t(e.events.playing$,()=>{this.logPlaying()}),t(ve(e,{forceInterval:this.config.watchCoverageInterval}),s=>{let u=e.info.isLive$.getValue(),g={start:parseFloat(s.from.toFixed(3)),end:parseFloat(s.to.toFixed(3))};u?this.logWatchCoverageLive(g):this.logWatchCoverageRecord(g)});let o;t(e.info.isStalled$,s=>{s?o=b():(A(o)&&this.logEmptyBuffer({duration:b()-o}),o=void 0)});let n=!1;i.add(e.events.fatalError$.pipe(Ue()).subscribe(()=>n=!0)),t(e.events.willStop$,()=>{if(e.info.isStalled$.getValue()){let u=A(o)?b()-o:void 0;this.logCloseAtEmptyBuffer({duration:u!=null?u:0}),o=void 0}else n||this.logActionStop()}),t(e.events.managedError$,({id:s})=>{this.logError({fatal:!1,errorType:s})}),t(e.events.fatalError$,({id:s})=>{this.logError({fatal:!0,errorType:s})});let r,c,l=!1;t(e.events.firstBytes$,s=>{r=b(),this.logFirstBytes({time:s})}),t(e.events.willStart$,()=>c=b()),t(e.info.currentBuffer$,s=>{!l&&s&&s.end-s.start>0&&A(r)&&(this.logPlayerReady({duration:b()-r}),l=!0)}),t(e.events.firstFrame$,()=>{A(r)&&!l&&(this.logPlayerReady({duration:b()-r}),l=!0),A(c)&&this.logFirstFrame({time:b()-c})});let d;t(e.info.currentVideoStream$,s=>{s&&(d&&s.id!==d&&this.logTrackSwitch(s),d=s.id)});let p;t(e.info.currentAudioStream$,s=>{s&&(p&&s.id!==p&&this.logTrackSwitch(s),p=s.id)}),t(e.info.atLiveEdge$,s=>this.updateContext({liveEdge:s})),t(Ie({muted:e.info.muted$,volume:e.info.volume$}),({muted:s,volume:u})=>this.updateContext({audible:!s&&u>0})),t(e.info.currentQuality$,s=>this.updateContext({quality:ce(s)})),t(e.info.isAutoQualityEnabled$,s=>this.updateContext({autoQuality:s})),t(e.info.currentFormat$,s=>this.updateContext({contentType:le(s)})),t(e.info.currentPlaybackRate$,s=>this.updateContext({rate:s})),t(e.info.is3DVideo$,s=>this.updateContext({is3d:s}));let h;return t(e.info.hostname$,s=>{let u=h!==void 0&&h!==s;this.updateContext({cdnHostname:s,failover:u}),u&&this.logFailover(s),h=s}),t(e.info.throughputEstimation$,s=>this.updateContext({downloadSpeed:s})),t(e.info.httpConnectionType$,s=>{this.statContext.firstConnectionType||this.updateContext({firstConnectionType:q(s)}),this.updateContext({connectionType:q(s)})}),t(e.info.httpConnectionReused$,s=>{ye(this.statContext.firstConnectionReused)&&this.updateContext({firstConnectionReused:s}),this.updateContext({connectionReused:s})}),t(e.info.surface$,s=>this.updateContext({mode:R(s)})),t(Ie({current:e.info.currentTextTrack$,available:e.info.availableTextTracks$}),({current:s,available:u})=>{let g=u.find(({id:S})=>S===s),v=g&&(g.isAuto?`${g.language}_auto`:g.language);this.updateContext({subtitles:v})}),this.player=e,this.uiEvents&&this.attachToUi(this.uiEvents),this.resubscribeBeforeunload(),this.subscription.add(i),i}attachToUi(e){this.uiEvents=e;let{subscription:i,subscribe:t}=X();return this.player&&(t(e.actionRewind$,()=>{this.player&&(this.resetViewSession(),this.logActionPlay({position:this.player.info.position$.getValue()}))}),t(e.actionSeek$,this.seekAction$),t(e.inPiP$,o=>{var r;let n=o?"pip":R((r=this.player)==null?void 0:r.info.surface$.getValue());this.updateContext({mode:n})}),t(e.inFullscreen$,o=>{var r;let n=o?"fullscreen":R((r=this.player)==null?void 0:r.info.surface$.getValue());this.updateContext({mode:n})}),t(e.actionSetSubtitle$,o=>this.updateContext({subtitles:o})),t(e.nextMovie$,o=>this.logNextMovie(o)),this.resubscribeBeforeunload(),this.subscription.add(i)),i}attachToAds(e){let{subscription:i,subscribe:t}=X();return t(e.slotRequested$,()=>this.logAdSlotRequest()),t(e.started$,o=>this.logAdStarted(o)),t(e.paused$,()=>this.logAdPaused()),t(e.resumed$,()=>this.logAdResumed()),t(e.ended$,()=>this.logAdEnded()),t(e.skipped$,()=>this.logAdSkipped()),t(e.clicked$,()=>this.logAdClicked()),this.resubscribeBeforeunload(),this.subscription.add(i),i}attachToInteractive(e){let{subscription:i,subscribe:t}=X();return t(e.click$,o=>this.logInterfaceClick(o)),t(e.nextMovie$,o=>this.logNextMovie(o)),this.resubscribeBeforeunload(),this.subscription.add(i),i}authorize(e){return this.api.authorize(e)}pause(){this.logger.pause(),this.oneStatDebugLog({message:"paused"})}resume(){this.logger.resume(),this.oneStatDebugLog({message:"resumed"})}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}resetViewSession(){this.oneStatDebugLog({message:"VSID reset"}),this.vsid$.next(he())}getDeviceId(){return this.uuid}setFieldBlacklist(){}logInited(){}logReady(e){this.log({operation:"player_ready",param:String(e.time)})}logStarted(...e){this.logActionPlay(...e)}logPlay(){this.log({operation:"play_toggle"})}logPlaying(){this.log({operation:"playing"})}logPause(e){this.log({operation:"pause",param:String(Math.round(e.position))})}logSeek(e){this.log({operation:"seek",param:e.action,time:e.time})}logFirstBytes(e){this.log({operation:"first_bytes",param:String(e.time)})}logFirstFrame(e){this.log({operation:"first_frame",param:String(e.time)})}logError(e){this.log({operation:"content_error",param:`${e.fatal?"fatal":"recoverable"}_${e.errorType}`})}logWatchCoverageRecord(e){this.log({operation:"watch_coverage_record",param:`${e.start}-${e.end}`})}logWatchCoverageLive(e){var n,r;let i=(r=(n=this.timeSynchronisation)==null?void 0:n.getOffset())!=null?r:0,t=e.start+i,o=e.end+i;this.log({operation:"watch_coverage_live",param:`${t}-${o}`})}logEmptyBuffer(e){this.log({operation:"empty_buffer",param:String(e.duration)})}logDownloadSpeed(){}logAdSlotRequest(){this.log({operation:"adv",param:"slot_request"})}logAdStarted(e){this.log({operation:"adv",param:e})}logAdPaused(){this.log({operation:"adv",param:"pause"})}logAdResumed(){this.log({operation:"adv",param:"resume"})}logAdEnded(){this.log({operation:"adv",param:"ended"})}logAdSkipped(){this.log({operation:"adv",param:"skip"})}logAdClicked(){this.log({operation:"adv",param:"click"})}logInterfaceClick(e){this.log({operation:"player_interface_click",param:e})}logNextMovie(e){this.log({operation:"next_movie",param:String(e)})}subscribe(){this.resubscribeBeforeunload();let e=window.navigator.connection;e&&"onchange"in e&&"effectiveType"in e&&this.subscription.add(Fe(Se(e,"change"),Ve(["init"])).subscribe(()=>this.updateContext({network:pe(e.effectiveType)}))),this.config.debugLog&&this.debugLogger.log$.subscribe(i=>{console.debug("%c stat ","background:#fa6470;",`component: ${i.component}.`,i.message)})}resubscribeBeforeunload(){var e;(e=this.beforeunloadSubscription)==null||e.unsubscribe(),this.beforeunloadSubscription=Se(window,"beforeunload").subscribe(()=>this.logger.flush(!0)),this.subscription.add(this.beforeunloadSubscription)}logPlayerReady(e){this.log({operation:"player_ready",param:String(Math.round(e.duration))})}logActionPlay(e){this.log({operation:"action_play",param:String(Math.round(e.position))})}logActionPlayInteractive(){this.statContext.projectId&&this.log({operation:"action_play_interactive",param:String(this.statContext.movieId)},{vid:this.statContext.projectId})}logFailover(e){this.log({operation:"failover",param:e})}logCloseAtEmptyBuffer(e){this.log({operation:"close_at_empty_buffer",param:String(Math.round(e.duration))})}logActionStop(){this.log({operation:"action_stop"})}logTrackSwitch(e){this.log({operation:"track_switch",param:e.id})}log(e,i={}){if(this.disabled){this.oneStatDebugLog({message:`operation ${e.operation} but statistics is disabled`});return}if(this.config.disabledOperations.includes(e.operation)){this.oneStatDebugLog({message:`operation ${e.operation} but it is disabled`});return}this.oneStatDebugLog({message:`operation ${e.operation} ${e.param}`});let t=this.createLogItem(e,i);this.logger.log(t)}createLogItem({operation:e,param:i,time:t},o={}){var u,g;let n=(g=(u=this.timeSynchronisation)==null?void 0:u.now())!=null?g:b(),r=this.vsid$.getValue();Be(r);let c=this.isid$.getValue(),l=e==="empty_buffer"||e==="close_at_empty_buffer"?this.statContext.connectionType:this.statContext.firstConnectionType,d=this.statContext.firstConnectionReused,p,h;if(this.isEmbed){p=this.embedParent;let v=[...new URLSearchParams(location.search).entries()].filter(([S,y])=>this.config.embedUrlParams.includes(S));h=new URLSearchParams(v).toString()}else this.statContext.place==="direct"&&((this.statContext.refDomain||document.referrer)&&(p=new URL(this.statContext.refDomain||document.referrer).hostname),h=location.href.substring(0,1024));let s={vsid:r,isid:c,vid:this.statContext.movieId,ct:this.statContext.contentType,place:this.isEmbed?"embed":this.statContext.place,quality:this.statContext.quality,cdn_host:this.statContext.cdnHostname,stat_type:this.statContext.autoplay===!0?"auto":this.statContext.autoplay===!1?"":void 0,param:i,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode,connection_type:l,connection_reused:d===!0?1:d===!1?0:void 0,cached_data:this.statContext.cached===!0?1:this.statContext.cached===!1?0:void 0,live:this.statContext.liveEdge?1:void 0,muted:this.statContext.audible===!1?1:void 0,mode:this.statContext.mode,subtitles:this.statContext.subtitles,download_speed:this.statContext.downloadSpeed,manual_quality:this.statContext.autoQuality?void 0:1,ref_domain:p,direct_url:h,rate:this.statContext.rate===1||ye(this.statContext.rate)?void 0:this.statContext.rate.toFixed(2),view_360:this.statContext.is3d?1:void 0,aid:this.statContext.albumId,vk_playlist_id:this.statContext.vkPlaylistId,...o};for(let v of this.config.disabledCustomFields)delete s[v];return{operation:e,type:1,time:t,network:this.statContext.network,timestamp:n,custom:s}}};export{E as ApiEnv,B as ConnectionType,M as ContentType,ee as InteractiveInterfaceClick,Z as OneStat,D as Quality,F as SeekAction,w as VERSION};
6
+ var Hc=Object.create;var Di=Object.defineProperty;var zc=Object.getOwnPropertyDescriptor;var Qc=Object.getOwnPropertyNames;var Yc=Object.getPrototypeOf,Jc=Object.prototype.hasOwnProperty;var n=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Xc=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Qc(e))!Jc.call(r,o)&&o!==t&&Di(r,o,{get:()=>e[o],enumerable:!(i=zc(e,o))||i.enumerable});return r};var $i=(r,e,t)=>(t=r!=null?Hc(Yc(r)):{},Xc(e||!r||!r.__esModule?Di(t,"default",{value:r,enumerable:!0}):t,r));var Gi=n(()=>{"use strict"});var y=n((Mr,Ki)=>{"use strict";var he=function(r){return r&&r.Math===Math&&r};Ki.exports=he(typeof globalThis=="object"&&globalThis)||he(typeof window=="object"&&window)||he(typeof self=="object"&&self)||he(typeof global=="object"&&global)||he(typeof Mr=="object"&&Mr)||function(){return this}()||Function("return this")()});var P=n((Mm,Wi)=>{"use strict";Wi.exports=function(r){try{return!!r()}catch(e){return!0}}});var ge=n((jm,Hi)=>{"use strict";var rl=P();Hi.exports=!rl(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var jr=n((Fm,Ji)=>{"use strict";var tl=ge(),Yi=Function.prototype,zi=Yi.apply,Qi=Yi.call;Ji.exports=typeof Reflect=="object"&&Reflect.apply||(tl?Qi.bind(zi):function(){return Qi.apply(zi,arguments)})});var O=n((Bm,eo)=>{"use strict";var Xi=ge(),Zi=Function.prototype,Fr=Zi.call,il=Xi&&Zi.bind.bind(Fr,Fr);eo.exports=Xi?il:function(r){return function(){return Fr.apply(r,arguments)}}});var me=n((Um,to)=>{"use strict";var ro=O(),ol=ro({}.toString),nl=ro("".slice);to.exports=function(r){return nl(ol(r),8,-1)}});var Br=n((Vm,io)=>{"use strict";var al=me(),sl=O();io.exports=function(r){if(al(r)==="Function")return sl(r)}});var I=n((Gm,oo)=>{"use strict";var Ur=typeof document=="object"&&document.all;oo.exports=typeof Ur=="undefined"&&Ur!==void 0?function(r){return typeof r=="function"||r===Ur}:function(r){return typeof r=="function"}});var _=n((Km,no)=>{"use strict";var ul=P();no.exports=!ul(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var w=n((Wm,ao)=>{"use strict";var cl=ge(),Be=Function.prototype.call;ao.exports=cl?Be.bind(Be):function(){return Be.apply(Be,arguments)}});var lo=n(co=>{"use strict";var so={}.propertyIsEnumerable,uo=Object.getOwnPropertyDescriptor,ll=uo&&!so.call({1:2},1);co.f=ll?function(e){var t=uo(this,e);return!!t&&t.enumerable}:so});var be=n((zm,fo)=>{"use strict";fo.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var vo=n((Qm,po)=>{"use strict";var fl=O(),dl=P(),pl=me(),Vr=Object,vl=fl("".split);po.exports=dl(function(){return!Vr("z").propertyIsEnumerable(0)})?function(r){return pl(r)==="String"?vl(r,""):Vr(r)}:Vr});var ye=n((Ym,ho)=>{"use strict";ho.exports=function(r){return r==null}});var Ue=n((Jm,go)=>{"use strict";var hl=ye(),gl=TypeError;go.exports=function(r){if(hl(r))throw new gl("Can't call method on "+r);return r}});var Q=n((Xm,mo)=>{"use strict";var ml=vo(),bl=Ue();mo.exports=function(r){return ml(bl(r))}});var R=n((Zm,bo)=>{"use strict";var yl=I();bo.exports=function(r){return typeof r=="object"?r!==null:yl(r)}});var Ve=n((eb,yo)=>{"use strict";yo.exports={}});var D=n((rb,So)=>{"use strict";var Gr=Ve(),Kr=y(),Il=I(),Io=function(r){return Il(r)?r:void 0};So.exports=function(r,e){return arguments.length<2?Io(Gr[r])||Io(Kr[r]):Gr[r]&&Gr[r][e]||Kr[r]&&Kr[r][e]}});var Ge=n((tb,Eo)=>{"use strict";var Sl=O();Eo.exports=Sl({}.isPrototypeOf)});var Y=n((ib,qo)=>{"use strict";var El=y(),Po=El.navigator,To=Po&&Po.userAgent;qo.exports=To?String(To):""});var Hr=n((ob,Co)=>{"use strict";var xo=y(),Wr=Y(),Oo=xo.process,_o=xo.Deno,wo=Oo&&Oo.versions||_o&&_o.version,Ro=wo&&wo.v8,x,Ke;Ro&&(x=Ro.split("."),Ke=x[0]>0&&x[0]<4?1:+(x[0]+x[1]));!Ke&&Wr&&(x=Wr.match(/Edge\/(\d+)/),(!x||x[1]>=74)&&(x=Wr.match(/Chrome\/(\d+)/),x&&(Ke=+x[1])));Co.exports=Ke});var zr=n((nb,No)=>{"use strict";var Ao=Hr(),Pl=P(),Tl=y(),ql=Tl.String;No.exports=!!Object.getOwnPropertySymbols&&!Pl(function(){var r=Symbol("symbol detection");return!ql(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Ao&&Ao<41})});var Qr=n((ab,Lo)=>{"use strict";var Ol=zr();Lo.exports=Ol&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Yr=n((sb,ko)=>{"use strict";var _l=D(),wl=I(),Rl=Ge(),xl=Qr(),Cl=Object;ko.exports=xl?function(r){return typeof r=="symbol"}:function(r){var e=_l("Symbol");return wl(e)&&Rl(e.prototype,Cl(r))}});var Ie=n((ub,Do)=>{"use strict";var Al=String;Do.exports=function(r){try{return Al(r)}catch(e){return"Object"}}});var $=n((cb,$o)=>{"use strict";var Nl=I(),Ll=Ie(),kl=TypeError;$o.exports=function(r){if(Nl(r))return r;throw new kl(Ll(r)+" is not a function")}});var We=n((lb,Mo)=>{"use strict";var Dl=$(),$l=ye();Mo.exports=function(r,e){var t=r[e];return $l(t)?void 0:Dl(t)}});var Fo=n((fb,jo)=>{"use strict";var Jr=w(),Xr=I(),Zr=R(),Ml=TypeError;jo.exports=function(r,e){var t,i;if(e==="string"&&Xr(t=r.toString)&&!Zr(i=Jr(t,r))||Xr(t=r.valueOf)&&!Zr(i=Jr(t,r))||e!=="string"&&Xr(t=r.toString)&&!Zr(i=Jr(t,r)))return i;throw new Ml("Can't convert object to primitive value")}});var A=n((db,Bo)=>{"use strict";Bo.exports=!0});var Go=n((pb,Vo)=>{"use strict";var Uo=y(),jl=Object.defineProperty;Vo.exports=function(r,e){try{jl(Uo,r,{value:e,configurable:!0,writable:!0})}catch(t){Uo[r]=e}return e}});var Se=n((vb,Ho)=>{"use strict";var Fl=A(),Bl=y(),Ul=Go(),Ko="__core-js_shared__",Wo=Ho.exports=Bl[Ko]||Ul(Ko,{});(Wo.versions||(Wo.versions=[])).push({version:"3.38.0",mode:Fl?"pure":"global",copyright:"\xA9 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var et=n((hb,Qo)=>{"use strict";var zo=Se();Qo.exports=function(r,e){return zo[r]||(zo[r]=e||{})}});var rt=n((gb,Yo)=>{"use strict";var Vl=Ue(),Gl=Object;Yo.exports=function(r){return Gl(Vl(r))}});var N=n((mb,Jo)=>{"use strict";var Kl=O(),Wl=rt(),Hl=Kl({}.hasOwnProperty);Jo.exports=Object.hasOwn||function(e,t){return Hl(Wl(e),t)}});var tt=n((bb,Xo)=>{"use strict";var zl=O(),Ql=0,Yl=Math.random(),Jl=zl(1 .toString);Xo.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Jl(++Ql+Yl,36)}});var T=n((yb,en)=>{"use strict";var Xl=y(),Zl=et(),Zo=N(),ef=tt(),rf=zr(),tf=Qr(),J=Xl.Symbol,it=Zl("wks"),of=tf?J.for||J:J&&J.withoutSetter||ef;en.exports=function(r){return Zo(it,r)||(it[r]=rf&&Zo(J,r)?J[r]:of("Symbol."+r)),it[r]}});var nn=n((Ib,on)=>{"use strict";var nf=w(),rn=R(),tn=Yr(),af=We(),sf=Fo(),uf=T(),cf=TypeError,lf=uf("toPrimitive");on.exports=function(r,e){if(!rn(r)||tn(r))return r;var t=af(r,lf),i;if(t){if(e===void 0&&(e="default"),i=nf(t,r,e),!rn(i)||tn(i))return i;throw new cf("Can't convert object to primitive value")}return e===void 0&&(e="number"),sf(r,e)}});var ot=n((Sb,an)=>{"use strict";var ff=nn(),df=Yr();an.exports=function(r){var e=ff(r,"string");return df(e)?e:e+""}});var He=n((Eb,un)=>{"use strict";var pf=y(),sn=R(),nt=pf.document,vf=sn(nt)&&sn(nt.createElement);un.exports=function(r){return vf?nt.createElement(r):{}}});var at=n((Pb,cn)=>{"use strict";var hf=_(),gf=P(),mf=He();cn.exports=!hf&&!gf(function(){return Object.defineProperty(mf("div"),"a",{get:function(){return 7}}).a!==7})});var dn=n(fn=>{"use strict";var bf=_(),yf=w(),If=lo(),Sf=be(),Ef=Q(),Pf=ot(),Tf=N(),qf=at(),ln=Object.getOwnPropertyDescriptor;fn.f=bf?ln:function(e,t){if(e=Ef(e),t=Pf(t),qf)try{return ln(e,t)}catch(i){}if(Tf(e,t))return Sf(!yf(If.f,e,t),e[t])}});var st=n((qb,pn)=>{"use strict";var Of=P(),_f=I(),wf=/#|\.prototype\./,Ee=function(r,e){var t=xf[Rf(r)];return t===Af?!0:t===Cf?!1:_f(e)?Of(e):!!e},Rf=Ee.normalize=function(r){return String(r).replace(wf,".").toLowerCase()},xf=Ee.data={},Cf=Ee.NATIVE="N",Af=Ee.POLYFILL="P";pn.exports=Ee});var Pe=n((Ob,hn)=>{"use strict";var vn=Br(),Nf=$(),Lf=ge(),kf=vn(vn.bind);hn.exports=function(r,e){return Nf(r),e===void 0?r:Lf?kf(r,e):function(){return r.apply(e,arguments)}}});var ut=n((_b,gn)=>{"use strict";var Df=_(),$f=P();gn.exports=Df&&$f(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var M=n((wb,mn)=>{"use strict";var Mf=R(),jf=String,Ff=TypeError;mn.exports=function(r){if(Mf(r))return r;throw new Ff(jf(r)+" is not an object")}});var V=n(yn=>{"use strict";var Bf=_(),Uf=at(),Vf=ut(),ze=M(),bn=ot(),Gf=TypeError,ct=Object.defineProperty,Kf=Object.getOwnPropertyDescriptor,lt="enumerable",ft="configurable",dt="writable";yn.f=Bf?Vf?function(e,t,i){if(ze(e),t=bn(t),ze(i),typeof e=="function"&&t==="prototype"&&"value"in i&&dt in i&&!i[dt]){var o=Kf(e,t);o&&o[dt]&&(e[t]=i.value,i={configurable:ft in i?i[ft]:o[ft],enumerable:lt in i?i[lt]:o[lt],writable:!1})}return ct(e,t,i)}:ct:function(e,t,i){if(ze(e),t=bn(t),ze(i),Uf)try{return ct(e,t,i)}catch(o){}if("get"in i||"set"in i)throw new Gf("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var X=n((xb,In)=>{"use strict";var Wf=_(),Hf=V(),zf=be();In.exports=Wf?function(r,e,t){return Hf.f(r,e,zf(1,t))}:function(r,e,t){return r[e]=t,r}});var L=n((Cb,En)=>{"use strict";var Te=y(),Qf=jr(),Yf=Br(),Jf=I(),Xf=dn().f,Zf=st(),Z=Ve(),ed=Pe(),ee=X(),Sn=N();Se();var rd=function(r){var e=function(t,i,o){if(this instanceof e){switch(arguments.length){case 0:return new r;case 1:return new r(t);case 2:return new r(t,i)}return new r(t,i,o)}return Qf(r,this,arguments)};return e.prototype=r.prototype,e};En.exports=function(r,e){var t=r.target,i=r.global,o=r.stat,a=r.proto,u=i?Te:o?Te[t]:Te[t]&&Te[t].prototype,d=i?Z:Z[t]||ee(Z,t,{})[t],p=d.prototype,c,f,v,s,l,h,m,b,g;for(s in e)c=Zf(i?s:t+(o?".":"#")+s,r.forced),f=!c&&u&&Sn(u,s),h=d[s],f&&(r.dontCallGetSet?(g=Xf(u,s),m=g&&g.value):m=u[s]),l=f&&m?m:e[s],!(!c&&!a&&typeof h==typeof l)&&(r.bind&&f?b=ed(l,Te):r.wrap&&f?b=rd(l):a&&Jf(l)?b=Yf(l):b=l,(r.sham||l&&l.sham||h&&h.sham)&&ee(b,"sham",!0),ee(d,s,b),a&&(v=t+"Prototype",Sn(Z,v)||ee(Z,v,{}),ee(Z[v],s,l),r.real&&p&&(c||!p[s])&&ee(p,s,l)))}});var pt=n((Ab,Pn)=>{"use strict";var qe=y(),td=Y(),id=me(),Qe=function(r){return td.slice(0,r.length)===r};Pn.exports=function(){return Qe("Bun/")?"BUN":Qe("Cloudflare-Workers")?"CLOUDFLARE":Qe("Deno/")?"DENO":Qe("Node.js/")?"NODE":qe.Bun&&typeof Bun.version=="string"?"BUN":qe.Deno&&typeof Deno.version=="object"?"DENO":id(qe.process)==="process"?"NODE":qe.window&&qe.document?"BROWSER":"REST"}()});var Ye=n((Nb,Tn)=>{"use strict";var od=pt();Tn.exports=od==="NODE"});var re=n((Lb,qn)=>{"use strict";var nd=X();qn.exports=function(r,e,t,i){return i&&i.enumerable?r[e]=t:nd(r,e,t),r}});var _n=n((kb,On)=>{"use strict";var ad=O(),sd=$();On.exports=function(r,e,t){try{return ad(sd(Object.getOwnPropertyDescriptor(r,e)[t]))}catch(i){}}});var Rn=n((Db,wn)=>{"use strict";var ud=R();wn.exports=function(r){return ud(r)||r===null}});var Cn=n(($b,xn)=>{"use strict";var cd=Rn(),ld=String,fd=TypeError;xn.exports=function(r){if(cd(r))return r;throw new fd("Can't set "+ld(r)+" as a prototype")}});var vt=n((Mb,An)=>{"use strict";var dd=_n(),pd=R(),vd=Ue(),hd=Cn();An.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var r=!1,e={},t;try{t=dd(Object.prototype,"__proto__","set"),t(e,[]),r=e instanceof Array}catch(i){}return function(o,a){return vd(o),hd(a),pd(o)&&(r?t(o,a):o.__proto__=a),o}}():void 0)});var Je=n((jb,Ln)=>{"use strict";var gd=T(),md=gd("toStringTag"),Nn={};Nn[md]="z";Ln.exports=String(Nn)==="[object z]"});var Ze=n((Fb,kn)=>{"use strict";var bd=Je(),yd=I(),Xe=me(),Id=T(),Sd=Id("toStringTag"),Ed=Object,Pd=Xe(function(){return arguments}())==="Arguments",Td=function(r,e){try{return r[e]}catch(t){}};kn.exports=bd?Xe:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=Td(e=Ed(r),Sd))=="string"?t:Pd?Xe(e):(i=Xe(e))==="Object"&&yd(e.callee)?"Arguments":i}});var $n=n((Bb,Dn)=>{"use strict";var qd=Je(),Od=Ze();Dn.exports=qd?{}.toString:function(){return"[object "+Od(this)+"]"}});var Oe=n((Ub,jn)=>{"use strict";var _d=Je(),wd=V().f,Rd=X(),xd=N(),Cd=$n(),Ad=T(),Mn=Ad("toStringTag");jn.exports=function(r,e,t,i){var o=t?r:r&&r.prototype;o&&(xd(o,Mn)||wd(o,Mn,{configurable:!0,value:e}),i&&!_d&&Rd(o,"toString",Cd))}});var Bn=n((Vb,Fn)=>{"use strict";var Nd=V();Fn.exports=function(r,e,t){return Nd.f(r,e,t)}});var Gn=n((Gb,Vn)=>{"use strict";var Ld=D(),kd=Bn(),Dd=T(),$d=_(),Un=Dd("species");Vn.exports=function(r){var e=Ld(r);$d&&e&&!e[Un]&&kd(e,Un,{configurable:!0,get:function(){return this}})}});var Wn=n((Kb,Kn)=>{"use strict";var Md=Ge(),jd=TypeError;Kn.exports=function(r,e){if(Md(e,r))return r;throw new jd("Incorrect invocation")}});var gt=n((Wb,Hn)=>{"use strict";var Fd=O(),Bd=I(),ht=Se(),Ud=Fd(Function.toString);Bd(ht.inspectSource)||(ht.inspectSource=function(r){return Ud(r)});Hn.exports=ht.inspectSource});var Zn=n((Hb,Xn)=>{"use strict";var Vd=O(),Gd=P(),zn=I(),Kd=Ze(),Wd=D(),Hd=gt(),Qn=function(){},Yn=Wd("Reflect","construct"),mt=/^\s*(?:class|function)\b/,zd=Vd(mt.exec),Qd=!mt.test(Qn),_e=function(e){if(!zn(e))return!1;try{return Yn(Qn,[],e),!0}catch(t){return!1}},Jn=function(e){if(!zn(e))return!1;switch(Kd(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Qd||!!zd(mt,Hd(e))}catch(t){return!0}};Jn.sham=!0;Xn.exports=!Yn||Gd(function(){var r;return _e(_e.call)||!_e(Object)||!_e(function(){r=!0})||r})?Jn:_e});var ra=n((zb,ea)=>{"use strict";var Yd=Zn(),Jd=Ie(),Xd=TypeError;ea.exports=function(r){if(Yd(r))return r;throw new Xd(Jd(r)+" is not a constructor")}});var bt=n((Qb,ia)=>{"use strict";var ta=M(),Zd=ra(),ep=ye(),rp=T(),tp=rp("species");ia.exports=function(r,e){var t=ta(r).constructor,i;return t===void 0||ep(i=ta(t)[tp])?e:Zd(i)}});var yt=n((Yb,oa)=>{"use strict";var ip=D();oa.exports=ip("document","documentElement")});var aa=n((Jb,na)=>{"use strict";var op=O();na.exports=op([].slice)});var ua=n((Xb,sa)=>{"use strict";var np=TypeError;sa.exports=function(r,e){if(r<e)throw new np("Not enough arguments");return r}});var It=n((Zb,ca)=>{"use strict";var ap=Y();ca.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(ap)});var Rt=n((ey,ba)=>{"use strict";var q=y(),sp=jr(),up=Pe(),la=I(),cp=N(),ma=P(),fa=yt(),lp=aa(),da=He(),fp=ua(),dp=It(),pp=Ye(),Ot=q.setImmediate,_t=q.clearImmediate,vp=q.process,St=q.Dispatch,hp=q.Function,pa=q.MessageChannel,gp=q.String,Et=0,we={},va="onreadystatechange",Re,G,Pt,Tt;ma(function(){Re=q.location});var wt=function(r){if(cp(we,r)){var e=we[r];delete we[r],e()}},qt=function(r){return function(){wt(r)}},ha=function(r){wt(r.data)},ga=function(r){q.postMessage(gp(r),Re.protocol+"//"+Re.host)};(!Ot||!_t)&&(Ot=function(e){fp(arguments.length,1);var t=la(e)?e:hp(e),i=lp(arguments,1);return we[++Et]=function(){sp(t,void 0,i)},G(Et),Et},_t=function(e){delete we[e]},pp?G=function(r){vp.nextTick(qt(r))}:St&&St.now?G=function(r){St.now(qt(r))}:pa&&!dp?(Pt=new pa,Tt=Pt.port2,Pt.port1.onmessage=ha,G=up(Tt.postMessage,Tt)):q.addEventListener&&la(q.postMessage)&&!q.importScripts&&Re&&Re.protocol!=="file:"&&!ma(ga)?(G=ga,q.addEventListener("message",ha,!1)):va in da("script")?G=function(r){fa.appendChild(da("script"))[va]=function(){fa.removeChild(this),wt(r)}}:G=function(r){setTimeout(qt(r),0)});ba.exports={set:Ot,clear:_t}});var Sa=n((ry,Ia)=>{"use strict";var ya=y(),mp=_(),bp=Object.getOwnPropertyDescriptor;Ia.exports=function(r){if(!mp)return ya[r];var e=bp(ya,r);return e&&e.value}});var xt=n((ty,Pa)=>{"use strict";var Ea=function(){this.head=null,this.tail=null};Ea.prototype={add:function(r){var e={item:r,next:null},t=this.tail;t?t.next=e:this.head=e,this.tail=e},get:function(){var r=this.head;if(r){var e=this.head=r.next;return e===null&&(this.tail=null),r.item}}};Pa.exports=Ea});var qa=n((iy,Ta)=>{"use strict";var yp=Y();Ta.exports=/ipad|iphone|ipod/i.test(yp)&&typeof Pebble!="undefined"});var _a=n((oy,Oa)=>{"use strict";var Ip=Y();Oa.exports=/web0s(?!.*chrome)/i.test(Ip)});var La=n((ny,Na)=>{"use strict";var ie=y(),Sp=Sa(),wa=Pe(),Ct=Rt().set,Ep=xt(),Pp=It(),Tp=qa(),qp=_a(),At=Ye(),Ra=ie.MutationObserver||ie.WebKitMutationObserver,xa=ie.document,Ca=ie.process,er=ie.Promise,kt=Sp("queueMicrotask"),te,Nt,Lt,rr,Aa;kt||(xe=new Ep,Ce=function(){var r,e;for(At&&(r=Ca.domain)&&r.exit();e=xe.get();)try{e()}catch(t){throw xe.head&&te(),t}r&&r.enter()},!Pp&&!At&&!qp&&Ra&&xa?(Nt=!0,Lt=xa.createTextNode(""),new Ra(Ce).observe(Lt,{characterData:!0}),te=function(){Lt.data=Nt=!Nt}):!Tp&&er&&er.resolve?(rr=er.resolve(void 0),rr.constructor=er,Aa=wa(rr.then,rr),te=function(){Aa(Ce)}):At?te=function(){Ca.nextTick(Ce)}:(Ct=wa(Ct,ie),te=function(){Ct(Ce)}),kt=function(r){xe.head||te(),xe.add(r)});var xe,Ce;Na.exports=kt});var Da=n((ay,ka)=>{"use strict";ka.exports=function(r,e){try{arguments.length===1?console.error(r):console.error(r,e)}catch(t){}}});var tr=n((sy,$a)=>{"use strict";$a.exports=function(r){try{return{error:!1,value:r()}}catch(e){return{error:!0,value:e}}}});var Fa=n((uy,ja)=>{"use strict";var Op=y(),_p=I(),Ma=Op.WeakMap;ja.exports=_p(Ma)&&/native code/.test(String(Ma))});var ir=n((cy,Ua)=>{"use strict";var wp=et(),Rp=tt(),Ba=wp("keys");Ua.exports=function(r){return Ba[r]||(Ba[r]=Rp(r))}});var or=n((ly,Va)=>{"use strict";Va.exports={}});var jt=n((fy,Wa)=>{"use strict";var xp=Fa(),Ka=y(),Cp=R(),Ap=X(),Dt=N(),$t=Se(),Np=ir(),Lp=or(),Ga="Object already initialized",Mt=Ka.TypeError,kp=Ka.WeakMap,nr,Ae,ar,Dp=function(r){return ar(r)?Ae(r):nr(r,{})},$p=function(r){return function(e){var t;if(!Cp(e)||(t=Ae(e)).type!==r)throw new Mt("Incompatible receiver, "+r+" required");return t}};xp||$t.state?(C=$t.state||($t.state=new kp),C.get=C.get,C.has=C.has,C.set=C.set,nr=function(r,e){if(C.has(r))throw new Mt(Ga);return e.facade=r,C.set(r,e),e},Ae=function(r){return C.get(r)||{}},ar=function(r){return C.has(r)}):(K=Np("state"),Lp[K]=!0,nr=function(r,e){if(Dt(r,K))throw new Mt(Ga);return e.facade=r,Ap(r,K,e),e},Ae=function(r){return Dt(r,K)?r[K]:{}},ar=function(r){return Dt(r,K)});var C,K;Wa.exports={set:nr,get:Ae,has:ar,enforce:Dp,getterFor:$p}});var W=n((dy,Ha)=>{"use strict";var Mp=y();Ha.exports=Mp.Promise});var oe=n((py,Ja)=>{"use strict";var jp=y(),Ne=W(),Fp=I(),Bp=st(),Up=gt(),Vp=T(),za=pt(),Gp=A(),Ft=Hr(),Qa=Ne&&Ne.prototype,Kp=Vp("species"),Bt=!1,Ya=Fp(jp.PromiseRejectionEvent),Wp=Bp("Promise",function(){var r=Up(Ne),e=r!==String(Ne);if(!e&&Ft===66||Gp&&!(Qa.catch&&Qa.finally))return!0;if(!Ft||Ft<51||!/native code/.test(r)){var t=new Ne(function(a){a(1)}),i=function(a){a(function(){},function(){})},o=t.constructor={};if(o[Kp]=i,Bt=t.then(function(){})instanceof i,!Bt)return!0}return!e&&(za==="BROWSER"||za==="DENO")&&!Ya});Ja.exports={CONSTRUCTOR:Wp,REJECTION_EVENT:Ya,SUBCLASSING:Bt}});var ne=n((vy,Za)=>{"use strict";var Xa=$(),Hp=TypeError,zp=function(r){var e,t;this.promise=new r(function(i,o){if(e!==void 0||t!==void 0)throw new Hp("Bad Promise constructor");e=i,t=o}),this.resolve=Xa(e),this.reject=Xa(t)};Za.exports.f=function(r){return new zp(r)}});var bs=n(()=>{"use strict";var Qp=L(),Yp=A(),lr=Ye(),U=y(),ce=w(),es=re(),rs=vt(),Jp=Oe(),Xp=Gn(),Zp=$(),cr=I(),ev=R(),rv=Wn(),tv=bt(),as=Rt().set,Wt=La(),iv=Da(),ov=tr(),nv=xt(),ss=jt(),fr=W(),Ht=oe(),us=ne(),dr="Promise",cs=Ht.CONSTRUCTOR,av=Ht.REJECTION_EVENT,sv=Ht.SUBCLASSING,Ut=ss.getterFor(dr),uv=ss.set,ae=fr&&fr.prototype,H=fr,sr=ae,ls=U.TypeError,Vt=U.document,zt=U.process,Gt=us.f,cv=Gt,lv=!!(Vt&&Vt.createEvent&&U.dispatchEvent),fs="unhandledrejection",fv="rejectionhandled",ts=0,ds=1,dv=2,Qt=1,ps=2,ur,is,pv,os,vs=function(r){var e;return ev(r)&&cr(e=r.then)?e:!1},hs=function(r,e){var t=e.value,i=e.state===ds,o=i?r.ok:r.fail,a=r.resolve,u=r.reject,d=r.domain,p,c,f;try{o?(i||(e.rejection===ps&&hv(e),e.rejection=Qt),o===!0?p=t:(d&&d.enter(),p=o(t),d&&(d.exit(),f=!0)),p===r.promise?u(new ls("Promise-chain cycle")):(c=vs(p))?ce(c,p,a,u):a(p)):u(t)}catch(v){d&&!f&&d.exit(),u(v)}},gs=function(r,e){r.notified||(r.notified=!0,Wt(function(){for(var t=r.reactions,i;i=t.get();)hs(i,r);r.notified=!1,e&&!r.rejection&&vv(r)}))},ms=function(r,e,t){var i,o;lv?(i=Vt.createEvent("Event"),i.promise=e,i.reason=t,i.initEvent(r,!1,!0),U.dispatchEvent(i)):i={promise:e,reason:t},!av&&(o=U["on"+r])?o(i):r===fs&&iv("Unhandled promise rejection",t)},vv=function(r){ce(as,U,function(){var e=r.facade,t=r.value,i=ns(r),o;if(i&&(o=ov(function(){lr?zt.emit("unhandledRejection",t,e):ms(fs,e,t)}),r.rejection=lr||ns(r)?ps:Qt,o.error))throw o.value})},ns=function(r){return r.rejection!==Qt&&!r.parent},hv=function(r){ce(as,U,function(){var e=r.facade;lr?zt.emit("rejectionHandled",e):ms(fv,e,r.value)})},se=function(r,e,t){return function(i){r(e,i,t)}},ue=function(r,e,t){r.done||(r.done=!0,t&&(r=t),r.value=e,r.state=dv,gs(r,!0))},Kt=function(r,e,t){if(!r.done){r.done=!0,t&&(r=t);try{if(r.facade===e)throw new ls("Promise can't be resolved itself");var i=vs(e);i?Wt(function(){var o={done:!1};try{ce(i,e,se(Kt,o,r),se(ue,o,r))}catch(a){ue(o,a,r)}}):(r.value=e,r.state=ds,gs(r,!1))}catch(o){ue({done:!1},o,r)}}};if(cs&&(H=function(e){rv(this,sr),Zp(e),ce(ur,this);var t=Ut(this);try{e(se(Kt,t),se(ue,t))}catch(i){ue(t,i)}},sr=H.prototype,ur=function(e){uv(this,{type:dr,done:!1,notified:!1,parent:!1,reactions:new nv,rejection:!1,state:ts,value:void 0})},ur.prototype=es(sr,"then",function(e,t){var i=Ut(this),o=Gt(tv(this,H));return i.parent=!0,o.ok=cr(e)?e:!0,o.fail=cr(t)&&t,o.domain=lr?zt.domain:void 0,i.state===ts?i.reactions.add(o):Wt(function(){hs(o,i)}),o.promise}),is=function(){var r=new ur,e=Ut(r);this.promise=r,this.resolve=se(Kt,e),this.reject=se(ue,e)},us.f=Gt=function(r){return r===H||r===pv?new is(r):cv(r)},!Yp&&cr(fr)&&ae!==Object.prototype)){os=ae.then,sv||es(ae,"then",function(e,t){var i=this;return new H(function(o,a){ce(os,i,o,a)}).then(e,t)},{unsafe:!0});try{delete ae.constructor}catch(r){}rs&&rs(ae,sr)}Qp({global:!0,constructor:!0,wrap:!0,forced:cs},{Promise:H});Jp(H,dr,!1,!0);Xp(dr)});var z=n((my,ys)=>{"use strict";ys.exports={}});var Ss=n((by,Is)=>{"use strict";var gv=T(),mv=z(),bv=gv("iterator"),yv=Array.prototype;Is.exports=function(r){return r!==void 0&&(mv.Array===r||yv[bv]===r)}});var Ps=n((yy,Es)=>{"use strict";var Iv=Math.ceil,Sv=Math.floor;Es.exports=Math.trunc||function(e){var t=+e;return(t>0?Sv:Iv)(t)}});var Yt=n((Iy,Ts)=>{"use strict";var Ev=Ps();Ts.exports=function(r){var e=+r;return e!==e||e===0?0:Ev(e)}});var Os=n((Sy,qs)=>{"use strict";var Pv=Yt(),Tv=Math.min;qs.exports=function(r){var e=Pv(r);return e>0?Tv(e,9007199254740991):0}});var Jt=n((Ey,_s)=>{"use strict";var qv=Os();_s.exports=function(r){return qv(r.length)}});var Xt=n((Py,Rs)=>{"use strict";var Ov=Ze(),ws=We(),_v=ye(),wv=z(),Rv=T(),xv=Rv("iterator");Rs.exports=function(r){if(!_v(r))return ws(r,xv)||ws(r,"@@iterator")||wv[Ov(r)]}});var Cs=n((Ty,xs)=>{"use strict";var Cv=w(),Av=$(),Nv=M(),Lv=Ie(),kv=Xt(),Dv=TypeError;xs.exports=function(r,e){var t=arguments.length<2?kv(r):e;if(Av(t))return Nv(Cv(t,r));throw new Dv(Lv(r)+" is not iterable")}});var Ls=n((qy,Ns)=>{"use strict";var $v=w(),As=M(),Mv=We();Ns.exports=function(r,e,t){var i,o;As(r);try{if(i=Mv(r,"return"),!i){if(e==="throw")throw t;return t}i=$v(i,r)}catch(a){o=!0,i=a}if(e==="throw")throw t;if(o)throw i;return As(i),t}});var vr=n((Oy,Ms)=>{"use strict";var jv=Pe(),Fv=w(),Bv=M(),Uv=Ie(),Vv=Ss(),Gv=Jt(),ks=Ge(),Kv=Cs(),Wv=Xt(),Ds=Ls(),Hv=TypeError,pr=function(r,e){this.stopped=r,this.result=e},$s=pr.prototype;Ms.exports=function(r,e,t){var i=t&&t.that,o=!!(t&&t.AS_ENTRIES),a=!!(t&&t.IS_RECORD),u=!!(t&&t.IS_ITERATOR),d=!!(t&&t.INTERRUPTED),p=jv(e,i),c,f,v,s,l,h,m,b=function(S){return c&&Ds(c,"normal",S),new pr(!0,S)},g=function(S){return o?(Bv(S),d?p(S[0],S[1],b):p(S[0],S[1])):d?p(S,b):p(S)};if(a)c=r.iterator;else if(u)c=r;else{if(f=Wv(r),!f)throw new Hv(Uv(r)+" is not iterable");if(Vv(f)){for(v=0,s=Gv(r);s>v;v++)if(l=g(r[v]),l&&ks($s,l))return l;return new pr(!1)}c=Kv(r,f)}for(h=a?r.next:c.next;!(m=Fv(h,c)).done;){try{l=g(m.value)}catch(S){Ds(c,"throw",S)}if(typeof l=="object"&&l&&ks($s,l))return l}return new pr(!1)}});var Vs=n((_y,Us)=>{"use strict";var zv=T(),Fs=zv("iterator"),Bs=!1;try{js=0,Zt={next:function(){return{done:!!js++}},return:function(){Bs=!0}},Zt[Fs]=function(){return this},Array.from(Zt,function(){throw 2})}catch(r){}var js,Zt;Us.exports=function(r,e){try{if(!e&&!Bs)return!1}catch(o){return!1}var t=!1;try{var i={};i[Fs]=function(){return{next:function(){return{done:t=!0}}}},r(i)}catch(o){}return t}});var ei=n((wy,Gs)=>{"use strict";var Qv=W(),Yv=Vs(),Jv=oe().CONSTRUCTOR;Gs.exports=Jv||!Yv(function(r){Qv.all(r).then(void 0,function(){})})});var Ks=n(()=>{"use strict";var Xv=L(),Zv=w(),eh=$(),rh=ne(),th=tr(),ih=vr(),oh=ei();Xv({target:"Promise",stat:!0,forced:oh},{all:function(e){var t=this,i=rh.f(t),o=i.resolve,a=i.reject,u=th(function(){var d=eh(t.resolve),p=[],c=0,f=1;ih(e,function(v){var s=c++,l=!1;f++,Zv(d,t,v).then(function(h){l||(l=!0,p[s]=h,--f||o(p))},a)}),--f||o(p)});return u.error&&a(u.value),i.promise}})});var Hs=n(()=>{"use strict";var nh=L(),ah=A(),sh=oe().CONSTRUCTOR,ti=W(),uh=D(),ch=I(),lh=re(),Ws=ti&&ti.prototype;nh({target:"Promise",proto:!0,forced:sh,real:!0},{catch:function(r){return this.then(void 0,r)}});!ah&&ch(ti)&&(ri=uh("Promise").prototype.catch,Ws.catch!==ri&&lh(Ws,"catch",ri,{unsafe:!0}));var ri});var zs=n(()=>{"use strict";var fh=L(),dh=w(),ph=$(),vh=ne(),hh=tr(),gh=vr(),mh=ei();fh({target:"Promise",stat:!0,forced:mh},{race:function(e){var t=this,i=vh.f(t),o=i.reject,a=hh(function(){var u=ph(t.resolve);gh(e,function(d){dh(u,t,d).then(i.resolve,o)})});return a.error&&o(a.value),i.promise}})});var Qs=n(()=>{"use strict";var bh=L(),yh=ne(),Ih=oe().CONSTRUCTOR;bh({target:"Promise",stat:!0,forced:Ih},{reject:function(e){var t=yh.f(this),i=t.reject;return i(e),t.promise}})});var ii=n(($y,Ys)=>{"use strict";var Sh=M(),Eh=R(),Ph=ne();Ys.exports=function(r,e){if(Sh(r),Eh(e)&&e.constructor===r)return e;var t=Ph.f(r),i=t.resolve;return i(e),t.promise}});var Zs=n(()=>{"use strict";var Th=L(),qh=D(),Js=A(),Oh=W(),Xs=oe().CONSTRUCTOR,_h=ii(),wh=qh("Promise"),Rh=Js&&!Xs;Th({target:"Promise",stat:!0,forced:Js||Xs},{resolve:function(e){return _h(Rh&&this===wh?Oh:this,e)}})});var eu=n(()=>{"use strict";bs();Ks();Hs();zs();Qs();Zs()});var ou=n(()=>{"use strict";var xh=L(),Ch=A(),hr=W(),Ah=P(),tu=D(),iu=I(),Nh=bt(),ru=ii(),Lh=re(),ni=hr&&hr.prototype,kh=!!hr&&Ah(function(){ni.finally.call({then:function(){}},function(){})});xh({target:"Promise",proto:!0,real:!0,forced:kh},{finally:function(r){var e=Nh(this,tu("Promise")),t=iu(r);return this.then(t?function(i){return ru(e,r()).then(function(){return i})}:r,t?function(i){return ru(e,r()).then(function(){throw i})}:r)}});!Ch&&iu(hr)&&(oi=tu("Promise").prototype.finally,ni.finally!==oi&&Lh(ni,"finally",oi,{unsafe:!0}));var oi});var au=n((Gy,nu)=>{"use strict";var Dh=D();nu.exports=Dh});var uu=n((Ky,su)=>{"use strict";Gi();eu();ou();var $h=au();su.exports=$h("Promise","finally")});var lu=n((Wy,cu)=>{"use strict";var Mh=uu();cu.exports=Mh});var du=n((Hy,fu)=>{"use strict";var jh=lu();fu.exports=jh});var vu=n((zy,pu)=>{"use strict";pu.exports=function(){}});var mu=n((Qy,gu)=>{"use strict";var ai=_(),Fh=N(),hu=Function.prototype,Bh=ai&&Object.getOwnPropertyDescriptor,si=Fh(hu,"name"),Uh=si&&function(){}.name==="something",Vh=si&&(!ai||ai&&Bh(hu,"name").configurable);gu.exports={EXISTS:si,PROPER:Uh,CONFIGURABLE:Vh}});var yu=n((Yy,bu)=>{"use strict";var Gh=Yt(),Kh=Math.max,Wh=Math.min;bu.exports=function(r,e){var t=Gh(r);return t<0?Kh(t+e,0):Wh(t,e)}});var Eu=n((Jy,Su)=>{"use strict";var Hh=Q(),zh=yu(),Qh=Jt(),Iu=function(r){return function(e,t,i){var o=Hh(e),a=Qh(o);if(a===0)return!r&&-1;var u=zh(i,a),d;if(r&&t!==t){for(;a>u;)if(d=o[u++],d!==d)return!0}else for(;a>u;u++)if((r||u in o)&&o[u]===t)return r||u||0;return!r&&-1}};Su.exports={includes:Iu(!0),indexOf:Iu(!1)}});var qu=n((Xy,Tu)=>{"use strict";var Yh=O(),ui=N(),Jh=Q(),Xh=Eu().indexOf,Zh=or(),Pu=Yh([].push);Tu.exports=function(r,e){var t=Jh(r),i=0,o=[],a;for(a in t)!ui(Zh,a)&&ui(t,a)&&Pu(o,a);for(;e.length>i;)ui(t,a=e[i++])&&(~Xh(o,a)||Pu(o,a));return o}});var ci=n((Zy,Ou)=>{"use strict";Ou.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var wu=n((eI,_u)=>{"use strict";var eg=qu(),rg=ci();_u.exports=Object.keys||function(e){return eg(e,rg)}});var xu=n(Ru=>{"use strict";var tg=_(),ig=ut(),og=V(),ng=M(),ag=Q(),sg=wu();Ru.f=tg&&!ig?Object.defineProperties:function(e,t){ng(e);for(var i=ag(t),o=sg(t),a=o.length,u=0,d;a>u;)og.f(e,d=o[u++],i[d]);return e}});var pi=n((tI,$u)=>{"use strict";var ug=M(),cg=xu(),Cu=ci(),lg=or(),fg=yt(),dg=He(),pg=ir(),Au=">",Nu="<",fi="prototype",di="script",ku=pg("IE_PROTO"),li=function(){},Du=function(r){return Nu+di+Au+r+Nu+"/"+di+Au},Lu=function(r){r.write(Du("")),r.close();var e=r.parentWindow.Object;return r=null,e},vg=function(){var r=dg("iframe"),e="java"+di+":",t;return r.style.display="none",fg.appendChild(r),r.src=String(e),t=r.contentWindow.document,t.open(),t.write(Du("document.F=Object")),t.close(),t.F},gr,mr=function(){try{gr=new ActiveXObject("htmlfile")}catch(e){}mr=typeof document!="undefined"?document.domain&&gr?Lu(gr):vg():Lu(gr);for(var r=Cu.length;r--;)delete mr[fi][Cu[r]];return mr()};lg[ku]=!0;$u.exports=Object.create||function(e,t){var i;return e!==null?(li[fi]=ug(e),i=new li,li[fi]=null,i[ku]=e):i=mr(),t===void 0?i:cg.f(i,t)}});var ju=n((iI,Mu)=>{"use strict";var hg=P();Mu.exports=!hg(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var hi=n((oI,Bu)=>{"use strict";var gg=N(),mg=I(),bg=rt(),yg=ir(),Ig=ju(),Fu=yg("IE_PROTO"),vi=Object,Sg=vi.prototype;Bu.exports=Ig?vi.getPrototypeOf:function(r){var e=bg(r);if(gg(e,Fu))return e[Fu];var t=e.constructor;return mg(t)&&e instanceof t?t.prototype:e instanceof vi?Sg:null}});var yi=n((nI,Gu)=>{"use strict";var Eg=P(),Pg=I(),Tg=R(),qg=pi(),Uu=hi(),Og=re(),_g=T(),wg=A(),bi=_g("iterator"),Vu=!1,j,gi,mi;[].keys&&(mi=[].keys(),"next"in mi?(gi=Uu(Uu(mi)),gi!==Object.prototype&&(j=gi)):Vu=!0);var Rg=!Tg(j)||Eg(function(){var r={};return j[bi].call(r)!==r});Rg?j={}:wg&&(j=qg(j));Pg(j[bi])||Og(j,bi,function(){return this});Gu.exports={IteratorPrototype:j,BUGGY_SAFARI_ITERATORS:Vu}});var Wu=n((aI,Ku)=>{"use strict";var xg=yi().IteratorPrototype,Cg=pi(),Ag=be(),Ng=Oe(),Lg=z(),kg=function(){return this};Ku.exports=function(r,e,t,i){var o=e+" Iterator";return r.prototype=Cg(xg,{next:Ag(+!i,t)}),Ng(r,o,!1,!0),Lg[o]=kg,r}});var ic=n((sI,tc)=>{"use strict";var Dg=L(),$g=w(),br=A(),ec=mu(),Mg=I(),jg=Wu(),Hu=hi(),zu=vt(),Fg=Oe(),Bg=X(),Ii=re(),Ug=T(),Qu=z(),rc=yi(),Vg=ec.PROPER,Gg=ec.CONFIGURABLE,Yu=rc.IteratorPrototype,yr=rc.BUGGY_SAFARI_ITERATORS,Le=Ug("iterator"),Ju="keys",ke="values",Xu="entries",Zu=function(){return this};tc.exports=function(r,e,t,i,o,a,u){jg(t,e,i);var d=function(g){if(g===o&&s)return s;if(!yr&&g&&g in f)return f[g];switch(g){case Ju:return function(){return new t(this,g)};case ke:return function(){return new t(this,g)};case Xu:return function(){return new t(this,g)}}return function(){return new t(this)}},p=e+" Iterator",c=!1,f=r.prototype,v=f[Le]||f["@@iterator"]||o&&f[o],s=!yr&&v||d(o),l=e==="Array"&&f.entries||v,h,m,b;if(l&&(h=Hu(l.call(new r)),h!==Object.prototype&&h.next&&(!br&&Hu(h)!==Yu&&(zu?zu(h,Yu):Mg(h[Le])||Ii(h,Le,Zu)),Fg(h,p,!0,!0),br&&(Qu[p]=Zu))),Vg&&o===ke&&v&&v.name!==ke&&(!br&&Gg?Bg(f,"name",ke):(c=!0,s=function(){return $g(v,this)})),o)if(m={values:d(ke),keys:a?s:d(Ju),entries:d(Xu)},u)for(b in m)(yr||c||!(b in f))&&Ii(f,b,m[b]);else Dg({target:e,proto:!0,forced:yr||c},m);return(!br||u)&&f[Le]!==s&&Ii(f,Le,s,{name:o}),Qu[e]=s,m}});var nc=n((uI,oc)=>{"use strict";oc.exports=function(r,e){return{value:r,done:e}}});var Ei=n((cI,lc)=>{"use strict";var Kg=Q(),Si=vu(),ac=z(),uc=jt(),Wg=V().f,Hg=ic(),Ir=nc(),zg=A(),Qg=_(),cc="Array Iterator",Yg=uc.set,Jg=uc.getterFor(cc);lc.exports=Hg(Array,"Array",function(r,e){Yg(this,{type:cc,target:Kg(r),index:0,kind:e})},function(){var r=Jg(this),e=r.target,t=r.index++;if(!e||t>=e.length)return r.target=void 0,Ir(void 0,!0);switch(r.kind){case"keys":return Ir(t,!1);case"values":return Ir(e[t],!1)}return Ir([t,e[t]],!1)},"values");var sc=ac.Arguments=ac.Array;Si("keys");Si("values");Si("entries");if(!zg&&Qg&&sc.name!=="values")try{Wg(sc,"name",{value:"values"})}catch(r){}});var dc=n((lI,fc)=>{"use strict";var Xg=_(),Zg=V(),em=be();fc.exports=function(r,e,t){Xg?Zg.f(r,e,em(0,t)):r[e]=t}});var pc=n(()=>{"use strict";var rm=L(),tm=vr(),im=dc();rm({target:"Object",stat:!0},{fromEntries:function(e){var t={};return tm(e,function(i,o){im(t,i,o)},{AS_ENTRIES:!0}),t}})});var hc=n((pI,vc)=>{"use strict";Ei();pc();var om=Ve();vc.exports=om.Object.fromEntries});var mc=n((vI,gc)=>{"use strict";gc.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}});var yc=n(()=>{"use strict";Ei();var nm=mc(),am=y(),sm=Oe(),bc=z();for(Sr in nm)sm(am[Sr],Sr),bc[Sr]=bc.Array;var Sr});var Sc=n((mI,Ic)=>{"use strict";var um=hc();yc();Ic.exports=um});var Pc=n((bI,Ec)=>{"use strict";var cm=Sc();Ec.exports=cm});var ve=(u=>(u.PROD="prod",u.VK_ALIAS="vk_alias",u.VIDEOTEST="videotest",u.TEST="test",u.OKCDN="okcdn",u.AUTO="auto",u))(ve||{}),Nr=(c=>(c.Q144P="mobile",c.Q240P="lowest",c.Q360P="low",c.Q480P="medium",c.Q720P="high",c.Q1080P="fullhd",c.Q1440P="quadhd",c.Q2160P="ultrahd",c.UNKNOWN="unknown",c))(Nr||{}),Lr=(l=>(l.MP4="mp4",l.DASH="dash",l.DASH_SEP="dash_sep",l.ONDEMAND_DASH="ondemand_dash",l.HLS="hls",l.ONDEMAND_HLS="ondemand_hls",l.WEBM="webm",l.AV1="av1",l.ONDEMAND_DASH_LIVE="ondemand_dash_live",l.ONDEMAND_HLS_LIVE="ondemand_hls_live",l.WEBRTC="webrtc",l.UNKNOWN="unknown",l.RTMP="rtmp",l))(Lr||{});var kr=(i=>(i.HTTP1="http1",i.HTTP2="http2",i.HTTP3="http3",i))(kr||{});var Dr=(d=>(d.SLIDER="slider",d.DOUBLE_TAP="double_tap",d.TIME_CODE="time_code",d.EPISODE="episode",d.REWIND="rewind",d.LIVE="live",d.UNKNOWN="unknown",d))(Dr||{}),Mi=(a=>(a.GRAPH_SHOW="iGraphShow",a.GRAPH_HIDE="iGraphHide",a.NEXT_AREA="iNextChapterArea",a.NEXT_BUTTON="iNextChapterBtn",a.WATCH_AGAIN="iWatchAgainBtn",a))(Mi||{}),ji={action_play:"ap",action_play_interactive:"api",first_bytes:"fb",player_ready:"pr",first_frame:"ff",seek:"sk",watch_coverage_record:"wr",watch_coverage_live:"wl",empty_buffer:"eb",action_stop:"as",close_at_empty_buffer:"cb",content_error:"er",player_interface_click:"pc",next_movie:"nm",track_switch:"ts",failover:"fo"},Fi={vsid:"si",isid:"is",vid:"vi",place:"pl",quality:"qt",cdn_host:"ch",stat_type:"st",param:"pm",vk_app_id:"va",track_code:"tc",connection_type:"cnt",connection_reused:"cr",cached_data:"cd",live:"lv",muted:"mu",mode:"mo",subtitles:"sb",failover:"fo",download_speed:"ds",manual_quality:"mq",ref_domain:"rd",direct_url:"du"},Bi={unknown:"un",mobile:"m",lowest:"ls",low:"l",medium:"md",high:"h",fullhd:"f",quadhd:"q",ultrahd:"u"},Ui={pip:"pi",fullscreen:"fs",external:"ex",prefetch:"pr",airplay:"ap",chromecast:"cc",invisible:"iv"};import{fillWithDefault as Zc}from"@vkontakte/videoplayer-shared";var el={apiEnv:"vk_alias",requestRetryCount:1,firstFlushTime:5e3,flushDebounceTime:1e4,flushMaxWait:6e4,storageExpiration:36*60*60*1e3,watchCoverageInterval:15e3,disabledOperations:[],disabledCustomFields:[],shorten:!0,maxLoops:100,embedUrlParams:[],useBeacon:!0,synchronizeTime:!0,debugLog:!1,backoff:{start:1e3,factor:1.5,max:5*60*1e3,random:.1}},Vi=r=>Zc(r,el);function $r(){let r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),e=new Array(36),t=0,i,o;for(o=0;o<36;o++)o===8||o===13||o===18||o===23?e[o]="-":o===14?e[o]="4":(t<=2&&(t=33554432+Math.random()*16777216|0),i=t&15,t=t>>4,e[o]=r[o===19?i&3|8:i]);return e.join("")}import{assertNonNullable as Sm,combine as jc,fromEvent as Fc,isNonNullable as pe,isNullable as Bc,merge as Em,now as F,observableFrom as Pm,once as Tm,safeStorage as Cr,Subject as qm,Subscription as Li,ValueSubject as Ai}from"@vkontakte/videoplayer-shared";import{Logger as Om,detectEmbed as _m}from"@vkontakte/videoplayer-shared";var Pr=$i(du(),1);var Tc=$i(Pc(),1);var qc=r=>{var o;let{operation:e,custom:t}=r,i=(0,Tc.default)(Object.entries(t).map(([a,u])=>{var c,f,v;let d=(c=Fi[a])!=null?c:a,p=u;return u&&(a==="mode"?p=(f=Ui[u])!=null?f:u:a==="quality"&&(p=(v=Bi[u])!=null?v:u)),[d,p]}));return{...r,operation:(o=ji[e])!=null?o:e,custom:i}};var Er="1.0.53-beta.0",Oc="CIOPGQJGDIHBABABA",Pi={prod:"https://api.ok.ru",vk_alias:"https://api.mycdn.me",videotest:"https://videotestapi.ok.ru/api",test:"https://apitest.ok.ru",okcdn:"https://api.okcdn.ru",auto:""};import{ValueSubject as lm,getExponentialDelay as fm,ErrorCategory as le}from"@vkontakte/videoplayer-shared";var De=class{constructor(e){this.consequentAuthErrors=0;this.authorized$=new lm(!1);this.params=e}async authorize(e){return this.authToken=e!=null?e:await this.refreshAuthToken(),this._authorizeWithBackoff()}logBeacon(e){let t="log.externalLog",i=this.createLogParams(e),o=this.sessionKey;if(!o)return;this.params.apiTransport.sendBeacon(t,i,o)||this.logRequest(e)}async logRequest(e){var u;let t="log.externalLog",i=this.createLogParams(e),o=(u=this.sessionKey)!=null?u:await this._authorizeWithBackoff();if(!o)return;let a=async(d,p=this.params.config.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(t,i,o)}catch(c){if(!c||!("error_code"in c)){this.params.error$.next({id:"logRequestUnknown",category:le.NETWORK,message:`Unknown ${t} error`,thrown:c});return}let f=c==null?void 0:c.error_code;switch(f){case 102:case 103:case 104:return this.authorized$.next(!1),this.sessionKey=await this._authorizeWithBackoff(),p>0?a(d,p-1):void 0;case 401:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorizeWithBackoff(),p>0?a(d,p-1):void 0;default:{this.params.error$.next({id:`LogRequest#${f}`,category:le.EXTERNAL_API,message:`${t} error`,data:c});return}}}};return a(e)}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}async refreshAuthToken(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=(0,Pr.default)(this.params.refreshAuthToken(),()=>{this.refreshAuthTokenPromise=void 0})),this.refreshAuthTokenPromise}createLogParams(e){return{collector:"ok.mobile.apps.video",data:JSON.stringify({application:`@vkontakte/videoplayer-statistics:${Er}`,platform:this.params.mobile?"M_WEB":"WEB",items:this.params.config.shorten?e.map(qc):e})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();let e=fm(this.consequentAuthErrors,this.params.config.backoff);return new Promise(t=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout(()=>{(0,Pr.default)(this._authorize().then(t).catch(i=>this.params.error$.next({id:"AuthorizeBackoff",category:le.NETWORK,message:"Otherwise unhandled error in authorization",thrown:i})),()=>this.backoffTimeoutId=0)},e))})}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);let e="auth.anonymLogin",t={session_data:{version:2,device_id:this.params.deviceId,client_version:Er.split("-")[0],client_type:"SDK_JS"}};return this.authToken!==void 0&&(t.session_data.auth_token=this.authToken,t.session_data.version=3),this.authorizePromise=(0,Pr.default)(this.params.apiTransport.sendRequest(e,t).then(i=>{var o;return(!i||!i.session_key)&&this.params.error$.next({id:"AuthorizeFailed",category:le.EXTERNAL_API,message:"No session key",data:i}),this.sessionKey=(o=i==null?void 0:i.session_key)!=null?o:void 0,this.sessionKey}).catch(async i=>{this.sessionKey=void 0;let o=i==null?void 0:i.error_code;switch(o){case 401:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}o?this.params.error$.next({id:`Authorize#${o}`,category:le.EXTERNAL_API,message:"authorize error",data:i}):this.params.error$.next({id:"AuthorizeUnknown",category:le.NETWORK,message:"authorize error",thrown:i})}),()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise}};var Tr=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,t,i){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:i})}removeEventListener(e,t){if(!(e in this.listeners))return;let i=this.listeners[e];for(let o=0,a=i.length;o<a;o++)if(i[o].callback===t){i.splice(o,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let i=this.listeners[e.type].slice();for(let o=0,a=i.length;o<a;o++){let u=i[o];try{u.callback.call(this,e)}catch(d){Promise.resolve().then(()=>{throw d})}u.options&&u.options.once&&this.removeEventListener(e.type,u.callback)}return!e.defaultPrevented}},fe=class extends Tr{constructor(){super(),this.listeners||Tr.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,e)),super.dispatchEvent(e)}},$e=class{constructor(){Object.defineProperty(this,"signal",{value:new fe,writable:!0,configurable:!0})}abort(e){let t;try{t=new Event("abort")}catch(o){typeof document!="undefined"?document.createEvent?(t=document.createEvent("Event"),t.initEvent("abort",!1,!1)):(t=document.createEventObject(),t.type="abort"):t={type:"abort",bubbles:!1,cancelable:!1}}let i=e;if(i===void 0)if(typeof document=="undefined")i=new Error("This operation was aborted"),i.name="AbortError";else try{i=new DOMException("signal is aborted without reason")}catch(o){i=new Error("This operation was aborted"),i.name="AbortError"}this.signal.reason=i,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}};typeof Symbol!="undefined"&&Symbol.toStringTag&&($e.prototype[Symbol.toStringTag]="AbortController",fe.prototype[Symbol.toStringTag]="AbortSignal");function qr(r){return r.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof r.Request=="function"&&!r.Request.prototype.hasOwnProperty("signal")||!r.AbortController}function Ti(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o=!1}=r;if(!qr({fetch:e,Request:t,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:e,Request:a};let a=t;(a&&!a.prototype.hasOwnProperty("signal")||o)&&(a=function(c,f){let v;f&&f.signal&&(v=f.signal,delete f.signal);let s=new t(c,f);return v&&Object.defineProperty(s,"signal",{writable:!1,enumerable:!1,configurable:!0,value:v}),s},a.prototype=t.prototype);let u=e;return{fetch:(p,c)=>{let f=a&&a.prototype.isPrototypeOf(p)?p.signal:c?c.signal:void 0;if(f){let v;try{v=new DOMException("Aborted","AbortError")}catch(l){v=new Error("Aborted"),v.name="AbortError"}if(f.aborted)return Promise.reject(v);let s=new Promise((l,h)=>{f.addEventListener("abort",()=>h(v),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([s,u(p,c)])}return u(p,c)},Request:a}}var Me=qr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),_c=Me?Ti({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,qi=Me?_c.fetch:window.fetch,jI=Me?_c.Request:window.Request,FI=Me?$e:window.AbortController,BI=Me?fe:window.AbortSignal;import{ErrorCategory as Or,now as Oi}from"@vkontakte/videoplayer-shared";var je=class{constructor(e){this.params=e,this.apiKey=e.apiKey,this.apiEnv=e.config.apiEnv,this.apiBaseUrl=Pi[this.apiEnv],this.timeSynchronisation=e.timeSynchronisation,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){var e;if(this.apiEnv!=="auto"||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{let t=atob("aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ="),o=await(await qi(t,{method:"GET",mode:"cors",cache:"no-cache"})).json(),a=(e=o==null?void 0:o.Answer[0])==null?void 0:e.data;if(!a)throw new Error("Wrong DNS response");return a}catch(t){return this.params.error$.next({id:"OneStat:ApiTransport:resolveApiBaseUrl",category:Or.NETWORK,message:"Unhandled resolve api base url error",thrown:t}),Pi.vk_alias}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(e,t,i){if(!window.Blob||!window.navigator.sendBeacon)return!1;let o=this._prepareQueryParams({method:e,queryParams:t,sessionKey:i}),a=new window.Blob([o.toString()],{type:"application/x-www-form-urlencoded"});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,a)}catch(u){this.params.error$.next({id:"OneStat:ApiTransport:sendBeacon",category:Or.NETWORK,message:"Unhandled beacon error",thrown:u,data:{method:e,params:t}})}return!1}async sendRequest(e,t,i){let o=Oi(),a=u=>{if(u instanceof TypeError&&["Failed to fetch","NetworkError when attempting to fetch resource."].includes(u.message)){this.params.error$.next({id:"Network",category:Or.NETWORK,message:"Request failed",thrown:u});return}this.params.error$.next({id:"OneStat:ApiTransport:sendRequest",category:Or.NETWORK,message:"Unhandled request error",thrown:u,data:{method:e,params:t,sessionKey:i,time:Oi()-o}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),qi(`${this.apiBaseUrl}/fb.do`,{method:"post",headers:{"Content-type":"application/x-www-form-urlencoded"},body:this._prepareQueryParams({method:e,queryParams:t,sessionKey:i})}).then(u=>{var f,v;let d=Number(u.headers.get("content-length"))===0,p=new Date((f=u.headers.get("date"))!=null?f:"").getTime(),c=Oi()-o;if(isFinite(p)&&((v=this.timeSynchronisation)==null||v.addServerTime(p,c)),!d)return u.json().then(s=>Object.prototype.hasOwnProperty.call(s,"error_msg")?Promise.reject(s):s,a)},a)}_prepareQueryParams(e){let t=new URLSearchParams({format:"JSON",method:e.method,application_key:this.apiKey});return e.sessionKey!==void 0&&t.append("session_key",e.sessionKey),Object.entries(e.queryParams).forEach(([i,o])=>t.append(i,typeof o=="string"?o:JSON.stringify(o))),t}};import{ErrorCategory as dm,now as pm,safeStorage as Fe,debounceFn as wc}from"@vkontakte/videoplayer-shared";var _r="onestat_events",_i=r=>e=>e.timestamp+r>=pm(),wr=class{constructor(e){this.unsaltedStorage=[];this.isPaused=!1;this.isUrgent=e=>{let{operation:t}=e;return["action_play","watch_coverage_record","watch_coverage_live"].includes(t)};this.params=e,this.api=e.api,this.error$=e.error$,this.userSalt=e.userSalt,this.loggerDebugLog=e.debugLogger.createComponentLog("stat logger"),this.firstFlush=wc(()=>this.safeFlush(),this.params.config.firstFlushTime,{maxWait:this.params.config.firstFlushTime});let t=Fe.isPersistent()?this.params.config.flushMaxWait:0;this.debouncedFlush=wc(()=>this.safeFlush(),this.params.config.flushDebounceTime,{maxWait:t}),this.subscription=this.api.authorized$.subscribe(i=>{i&&this.debouncedFlush()}),this.housekeepStorage()}safeFlush(){var e;try{this.flush()}catch(t){this.error$.next({id:"LoggerError",category:dm.WTF,message:(e=String(t))!=null?e:"Unknown logger error",thrown:t})}}readFromStorage(){let e=Fe.get(_r);try{return e?JSON.parse(e):{}}catch(t){}return{}}addToStorage(e){var a;if(!this.userSalt){this.unsaltedStorage.push(e);return}let t=this.readFromStorage(),o=((a=t[this.userSalt])!=null?a:[]).filter(_i(this.params.config.storageExpiration));Fe.set(_r,JSON.stringify({...t,[this.userSalt]:[...o,e]}))}getFromStorage(){var i;return this.userSalt?((i=this.readFromStorage()[this.userSalt])!=null?i:[]).filter(_i(this.params.config.storageExpiration)):this.unsaltedStorage}markStorageSent(){if(!this.userSalt){this.unsaltedStorage=[];return}let e=this.readFromStorage();delete e[this.userSalt],Fe.set(_r,JSON.stringify(e))}housekeepStorage(){let e=this.readFromStorage();for(let[t,i]of Object.entries(e)){let o=i.filter(_i(this.params.config.storageExpiration));o.length?e[t]=o:delete e[t],this.loggerDebugLog({message:`${i.length} retrieved from storage, ${o.length} of them actual`})}Fe.set(_r,JSON.stringify(e))}log(e){this.addToStorage(e),!this.isPaused&&(this.isUrgent(e)?this.flush():this.lastVsid!==e.custom.vsid?this.firstFlush():this.debouncedFlush(),this.lastVsid=e.custom.vsid)}flush(e=!1){let t=this.getFromStorage();t.length!==0&&(this.api.authorized$.getValue()?(e&&this.params.config.useBeacon?(this.loggerDebugLog({message:`Flushing ${t.length} events through beacon`}),this.api.logBeacon(t)):(this.loggerDebugLog({message:`Flushing ${t.length} events`}),this.api.logRequest(t)),this.markStorageSent()):this.api.authorize(),this.firstFlush.cancel(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe(),this.firstFlush.cancel(),this.debouncedFlush.cancel()}};import{HttpConnectionType as wi,Surface as de,VideoFormat as E,VideoQuality as k}from"@vkontakte/videoplayer-core";import{assertNever as Rc}from"@vkontakte/videoplayer-shared";var xc=r=>r&&{[k.INVARIANT]:"unknown",[k.Q_144P]:"mobile",[k.Q_240P]:"lowest",[k.Q_360P]:"low",[k.Q_480P]:"medium",[k.Q_720P]:"high",[k.Q_1080P]:"fullhd",[k.Q_1440P]:"quadhd",[k.Q_2160P]:"ultrahd",[k.Q_4320P]:"unknown"}[r],Ri=r=>r&&{[wi.HTTP1]:"http1",[wi.HTTP2]:"http2",[wi.QUIC]:"http3"}[r],Cc=r=>{if(r!==void 0)switch(r){case E.MPEG:return"mp4";case E.DASH:case E.DASH_LIVE:case E.DASH_STREAMS:return"dash";case E.DASH_SEP:return"dash_sep";case E.DASH_ONDEMAND:return"ondemand_dash";case E.DASH_WEBM:case E.DASH_LIVE_WEBM:return"webm";case E.DASH_WEBM_AV1:return"av1";case E.DASH_LIVE_CMAF:return"ondemand_dash_live";case E.HLS:case E.HLS_LIVE:return"hls";case E.HLS_ONDEMAND:return"ondemand_hls";case E.HLS_LIVE_CMAF:return"ondemand_hls_live";case E.WEB_RTC_LIVE:return"webrtc";default:return Rc(r)}},Rr=r=>{if(r!==void 0)switch(r){case de.NONE:case de.INLINE:return;case de.FULLSCREEN:return"fullscreen";case de.SECOND_SCREEN:return"chromecast";case de.PIP:return"pip";case de.INVISIBLE:return"invisible";default:return Rc(r)}},Ac=r=>{switch(r){case"slow-2g":return"poor";case"2g":return"poor";case"3g":return"good";case"4g":return"excellent"}};var xr=class{constructor(e){this.offset=void 0;this.offset=e}getOffset(){var e;return(e=this.offset)!=null?e:0}setOffset(e){this.offset=e}now(){var e;return Date.now()+((e=this.offset)!=null?e:0)}date(e=new Date){var t;return e.setTime(e.getTime()+((t=this.offset)!=null?t:0)),e}addServerTime(e,t){let i=Date.now(),o=e-i-t/2;if(Math.abs(o)<1e3){this.offset=0;return}this.offset===void 0?this.offset=Math.round(o):this.offset=Math.round(.2*o+(1-.2)*this.offset)}};var Nc=()=>Math.floor(Math.random()*4294967296).toString(36).padStart(7,"0"),Lc=()=>Math.floor(Math.random()*18446744073709552e3).toString(36).padStart(13,"0");import{PlaybackState as kc}from"@vkontakte/videoplayer-core";import{filter as Dc,filterChanged as hm,fromEvent as gm,isNullable as $c,map as mm,merge as xi,Observable as bm,Subject as Ci,Subscription as ym,ValueSubject as Im}from"@vkontakte/videoplayer-shared";var Mc=(r,e)=>new bm(t=>{let i=new ym,o=xi(gm(window,"beforeunload"),r.events.willDestruct$),a=new Im(void 0),u;i.add(r.info.isLive$.pipe(hm()).subscribe(B=>{u&&(u.unsubscribe(),a.next(void 0)),B?u=r.info.liveTime$.pipe(mm(Ar=>Ar&&Ar/1e3)).subscribe(a):u=r.info.position$.subscribe(a),i.add(u)}));let{playing$:d,paused$:p}=r.events,c=r.events.willSeek$.pipe(Dc(()=>r.info.playbackState$.getValue()===kc.PLAYING)),f=r.events.seeked$.pipe(Dc(()=>r.info.playbackState$.getValue()===kc.PLAYING)),v=!1,s=new Ci;i.add(c.subscribe(()=>{v||s.next(),v=!0})),i.add(f.subscribe(()=>v=!1));let l=new Ci,h=new Ci,m=xi(d,f,l),b=xi(p,s,o,r.events.looped$,h),g,S=()=>g=a.getValue(),Kc=()=>{let B=a.getValue();$c(g)||g===B||$c(B)||(t.next({from:g,to:B}),g=void 0)},Wc=()=>{h.next(),l.next()};if(i.add(m.subscribe(S)),i.add(b.subscribe(Kc)),e.forceInterval&&isFinite(e.forceInterval)){let B=0;i.add(m.subscribe(()=>B=window.setTimeout(Wc,e.forceInterval))),i.add(b.subscribe(()=>window.clearTimeout(B)))}return i});var Gc="_one-stat_",Uc=`${Gc}uuid`,Vc=`${Gc}deviceId`,Ni=()=>{let r=new Li;return{subscription:r,subscribe:(e,t)=>{e&&r.add(e.subscribe(t))}}},ki=class{constructor(e,t){this.subscription=new Li;this.debugLogger=new Om;this.oneStatDebugLog=this.debugLogger.createComponentLog("onestat");this.loopCounter=0;this.disabled=!1;this.vsid$=new Ai(void 0);this.isid$=new Ai(void 0);this.seekAction$=new Ai("unknown");var c,f,v;this.statContext=e,this.config=Vi((c=t.config)!=null?c:{}),pe(t.apiEnv)&&(this.config.apiEnv=t.apiEnv),this.config.synchronizeTime&&(this.timeSynchronisation=new xr);let i=new qm;this.experimental={error$:i},Cr.get(Uc)&&Cr.remove(Uc);let a=Cr.get(Vc);this.statContext.deviceId?this.deviceId=this.statContext.deviceId:a?this.deviceId=a:(this.deviceId=$r(),Cr.set(Vc,this.deviceId)),this.resetViewSession(),t.useIsid&&this.isid$.next((f=t.isid)!=null?f:Lc());let u=new je({apiKey:Oc,config:this.config,error$:i,timeSynchronisation:this.timeSynchronisation});this.api=new De({config:this.config,apiTransport:u,refreshAuthToken:t.refreshAuthToken,mobile:(v=this.statContext.mobile)!=null?v:!1,deviceId:this.deviceId,error$:i}),this.logger=new wr({config:this.config,debugLogger:this.debugLogger,api:this.api,error$:i,userSalt:t.userSalt});let{isEmbed:d,host:p}=_m();this.isEmbed=d,this.embedParent=p,this.subscribe()}updateContext(e){this.statContext={...this.statContext,...e}}attachTo(e){let t=new Li,i=(s,l)=>t.add(s.subscribe(l));i(e.events.willStart$,()=>{let s=e.info.position$.getValue();this.logActionPlay({position:s}),this.statContext.projectId&&this.logActionPlayInteractive()}),i(e.events.looped$,()=>{this.resetViewSession(),++this.loopCounter>this.config.maxLoops&&(this.disabled=!0),this.logActionPlay({position:e.info.position$.getValue()})}),i(e.events.seeked$,()=>{this.logSeek({action:this.seekAction$.getValue(),time:e.info.position$.getValue()}),this.seekAction$.next("unknown")}),i(e.events.paused$,()=>{this.logPause({position:e.info.position$.getValue()})}),i(e.events.willResume$,()=>{this.logPlay()}),i(e.events.started$,()=>{this.statContext.clip&&this.logWatchCoverageRecord({start:0,end:0})}),i(e.events.playing$,()=>{this.logPlaying()}),i(Mc(e,{forceInterval:this.config.watchCoverageInterval}),s=>{let l=e.info.isLive$.getValue(),h={start:parseFloat(s.from.toFixed(3)),end:parseFloat(s.to.toFixed(3))};l?this.logWatchCoverageLive(h):this.logWatchCoverageRecord(h)});let o;i(e.info.isStalled$,s=>{s?o=F():(pe(o)&&this.logEmptyBuffer({duration:F()-o}),o=void 0)});let a=!1;t.add(e.events.fatalError$.pipe(Tm()).subscribe(()=>a=!0)),i(e.events.willStop$,()=>{if(e.info.isStalled$.getValue()){let l=pe(o)?F()-o:void 0;this.logCloseAtEmptyBuffer({duration:l!=null?l:0}),o=void 0}else a||this.logActionStop()}),i(e.events.managedError$,({id:s})=>{this.logError({fatal:!1,errorType:s})}),i(e.events.fatalError$,({id:s})=>{this.logError({fatal:!0,errorType:s})});let u,d,p=!1;i(e.events.firstBytes$,s=>{u=F(),this.logFirstBytes({time:s})}),i(e.events.willStart$,()=>d=F()),i(e.info.currentBuffer$,s=>{!p&&s&&s.end-s.start>0&&pe(u)&&(this.logPlayerReady({duration:F()-u}),p=!0)}),i(e.events.firstFrame$,()=>{pe(u)&&!p&&(this.logPlayerReady({duration:F()-u}),p=!0),pe(d)&&this.logFirstFrame({time:F()-d})});let c;i(e.info.currentVideoStream$,s=>{s&&(c&&s.id!==c&&this.logTrackSwitch(s),c=s.id)});let f;i(e.info.currentAudioStream$,s=>{s&&(f&&s.id!==f&&this.logTrackSwitch(s),f=s.id)}),i(e.info.atLiveEdge$,s=>this.updateContext({liveEdge:s})),i(jc({muted:e.info.muted$,volume:e.info.volume$}),({muted:s,volume:l})=>this.updateContext({audible:!s&&l>0})),i(e.info.currentQuality$,s=>this.updateContext({quality:xc(s)})),i(e.info.isAutoQualityEnabled$,s=>this.updateContext({autoQuality:s})),i(e.info.currentFormat$,s=>this.updateContext({contentType:Cc(s)})),i(e.info.currentPlaybackRate$,s=>this.updateContext({rate:s})),i(e.info.is3DVideo$,s=>this.updateContext({is3d:s}));let v;return i(e.info.hostname$,s=>{let l=v!==void 0&&v!==s;this.updateContext({cdnHostname:s,failover:l}),l&&this.logFailover(s),v=s}),i(e.info.throughputEstimation$,s=>this.updateContext({downloadSpeed:s})),i(e.info.httpConnectionType$,s=>{this.statContext.firstConnectionType||this.updateContext({firstConnectionType:Ri(s)}),this.updateContext({connectionType:Ri(s)})}),i(e.info.httpConnectionReused$,s=>{Bc(this.statContext.firstConnectionReused)&&this.updateContext({firstConnectionReused:s}),this.updateContext({connectionReused:s})}),i(e.info.surface$,s=>this.updateContext({mode:Rr(s)})),i(jc({current:e.info.currentTextTrack$,available:e.info.availableTextTracks$}),({current:s,available:l})=>{let h=l.find(({id:b})=>b===s),m=h&&(h.isAuto?`${h.language}_auto`:h.language);this.updateContext({subtitles:m})}),this.player=e,this.uiEvents&&this.attachToUi(this.uiEvents),this.resubscribeBeforeunload(),this.subscription.add(t),t}attachToUi(e){this.uiEvents=e;let{subscription:t,subscribe:i}=Ni();return this.player&&(i(e.actionRewind$,()=>{this.player&&(this.resetViewSession(),this.logActionPlay({position:this.player.info.position$.getValue()}))}),i(e.actionSeek$,this.seekAction$),i(e.inPiP$,o=>{var u;let a=o?"pip":Rr((u=this.player)==null?void 0:u.info.surface$.getValue());this.updateContext({mode:a})}),i(e.inFullscreen$,o=>{var u;let a=o?"fullscreen":Rr((u=this.player)==null?void 0:u.info.surface$.getValue());this.updateContext({mode:a})}),i(e.actionSetSubtitle$,o=>this.updateContext({subtitles:o})),i(e.nextMovie$,o=>this.logNextMovie(o)),this.resubscribeBeforeunload(),this.subscription.add(t)),t}attachToAds(e){let{subscription:t,subscribe:i}=Ni();return i(e.slotRequested$,()=>this.logAdSlotRequest()),i(e.started$,o=>this.logAdStarted(o)),i(e.paused$,()=>this.logAdPaused()),i(e.resumed$,()=>this.logAdResumed()),i(e.ended$,()=>this.logAdEnded()),i(e.skipped$,()=>this.logAdSkipped()),i(e.clicked$,()=>this.logAdClicked()),this.resubscribeBeforeunload(),this.subscription.add(t),t}attachToInteractive(e){let{subscription:t,subscribe:i}=Ni();return i(e.click$,o=>this.logInterfaceClick(o)),i(e.nextMovie$,o=>this.logNextMovie(o)),this.resubscribeBeforeunload(),this.subscription.add(t),t}authorize(e){return this.api.authorize(e)}pause(){this.logger.pause(),this.oneStatDebugLog({message:"paused"})}resume(){this.logger.resume(),this.oneStatDebugLog({message:"resumed"})}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}resetViewSession(){this.oneStatDebugLog({message:"VSID reset"}),this.vsid$.next(Nc())}getDeviceId(){return this.deviceId}setFieldBlacklist(){}logInited(){}logReady(e){this.log({operation:"player_ready",param:String(e.time)})}logStarted(...e){this.logActionPlay(...e)}logPlay(){this.log({operation:"play_toggle"})}logPlaying(){this.log({operation:"playing"})}logPause(e){this.log({operation:"pause",param:String(Math.round(e.position))})}logSeek(e){this.log({operation:"seek",param:e.action,time:e.time})}logFirstBytes(e){this.log({operation:"first_bytes",param:String(e.time)})}logFirstFrame(e){this.log({operation:"first_frame",param:String(e.time)})}logError(e){this.log({operation:"content_error",param:`${e.fatal?"fatal":"recoverable"}_${e.errorType}`})}logWatchCoverageRecord(e){this.log({operation:"watch_coverage_record",param:`${e.start}-${e.end}`},{in_history:this.statContext.inHistory?1:void 0})}logWatchCoverageLive(e){var a,u;let t=(u=(a=this.timeSynchronisation)==null?void 0:a.getOffset())!=null?u:0,i=e.start+t,o=e.end+t;this.log({operation:"watch_coverage_live",param:`${i}-${o}`},{in_history:this.statContext.inHistory?1:void 0})}logEmptyBuffer(e){this.log({operation:"empty_buffer",param:String(e.duration)})}logDownloadSpeed(){}logAdSlotRequest(){this.log({operation:"adv",param:"slot_request"})}logAdStarted(e){this.log({operation:"adv",param:e})}logAdPaused(){this.log({operation:"adv",param:"pause"})}logAdResumed(){this.log({operation:"adv",param:"resume"})}logAdEnded(){this.log({operation:"adv",param:"ended"})}logAdSkipped(){this.log({operation:"adv",param:"skip"})}logAdClicked(){this.log({operation:"adv",param:"click"})}logInterfaceClick(e){this.log({operation:"player_interface_click",param:e})}logNextMovie(e){this.log({operation:"next_movie",param:String(e)})}subscribe(){this.resubscribeBeforeunload();let e=window.navigator.connection;e&&"onchange"in e&&"effectiveType"in e&&this.subscription.add(Em(Fc(e,"change"),Pm(["init"])).subscribe(()=>this.updateContext({network:Ac(e.effectiveType)}))),this.config.debugLog&&this.debugLogger.log$.subscribe(t=>{console.debug("%c stat ","background:#fa6470;",`component: ${t.component}.`,t.message)})}resubscribeBeforeunload(){var e;(e=this.beforeunloadSubscription)==null||e.unsubscribe(),this.beforeunloadSubscription=Fc(window,"beforeunload").subscribe(()=>this.logger.flush(!0)),this.subscription.add(this.beforeunloadSubscription)}logPlayerReady(e){this.log({operation:"player_ready",param:String(Math.round(e.duration))})}logActionPlay(e){this.log({operation:"action_play",param:String(Math.round(e.position))})}logActionPlayInteractive(){this.statContext.projectId&&this.log({operation:"action_play_interactive",param:String(this.statContext.movieId)},{vid:this.statContext.projectId})}logFailover(e){this.log({operation:"failover",param:e})}logCloseAtEmptyBuffer(e){this.log({operation:"close_at_empty_buffer",param:String(Math.round(e.duration))})}logActionStop(){this.log({operation:"action_stop"})}logTrackSwitch(e){this.log({operation:"track_switch",param:e.id})}log(e,t={}){if(this.disabled){this.oneStatDebugLog({message:`operation ${e.operation} but statistics is disabled`});return}if(this.config.disabledOperations.includes(e.operation)){this.oneStatDebugLog({message:`operation ${e.operation} but it is disabled`});return}this.oneStatDebugLog({message:`operation ${e.operation} ${e.param}`});let i=this.createLogItem(e,t);this.logger.log(i)}createLogItem({operation:e,param:t,time:i},o={}){var l,h;let a=(h=(l=this.timeSynchronisation)==null?void 0:l.now())!=null?h:F(),u=this.vsid$.getValue();Sm(u);let d=this.isid$.getValue(),p=e==="empty_buffer"||e==="close_at_empty_buffer"?this.statContext.connectionType:this.statContext.firstConnectionType,c=this.statContext.firstConnectionReused,f,v;if(this.isEmbed){f=this.embedParent;let m=[...new URLSearchParams(location.search).entries()].filter(([b,g])=>this.config.embedUrlParams.includes(b));v=new URLSearchParams(m).toString()}else this.statContext.place==="direct"&&((this.statContext.refDomain||document.referrer)&&(f=new URL(this.statContext.refDomain||document.referrer).hostname),v=location.href.substring(0,1024));let s={vsid:u,isid:d,vid:this.statContext.movieId,ct:this.statContext.contentType,place:this.isEmbed?"embed":this.statContext.place,quality:this.statContext.quality,cdn_host:this.statContext.cdnHostname,stat_type:this.statContext.autoplay===!0?"auto":this.statContext.autoplay===!1?"":void 0,param:t,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode,connection_type:p,connection_reused:c===!0?1:c===!1?0:void 0,cached_data:this.statContext.cached===!0?1:this.statContext.cached===!1?0:void 0,live:this.statContext.liveEdge?1:void 0,muted:this.statContext.audible===!1?1:void 0,mode:this.statContext.mode,subtitles:this.statContext.subtitles,download_speed:this.statContext.downloadSpeed,manual_quality:this.statContext.autoQuality?void 0:1,ref_domain:f,direct_url:v,rate:this.statContext.rate===1||Bc(this.statContext.rate)?void 0:this.statContext.rate.toFixed(2),view_360:this.statContext.is3d?1:void 0,aid:this.statContext.albumId,vk_playlist_id:this.statContext.vkPlaylistId,...o};for(let m of this.config.disabledCustomFields)delete s[m];return{operation:e,type:1,time:i,network:this.statContext.network,timestamp:a,custom:s}}};export{ve as ApiEnv,kr as ConnectionType,Lr as ContentType,Mi as InteractiveInterfaceClick,ki as OneStat,Nr as Quality,Dr as SeekAction,Er as VERSION};