S&&(O=t[F=C[S]],t[F]=t[S],t[S]=O,O=s[F],s[F]=s[S],s[S]=O)};var p=t>>1;return i.unpack=function(e,s,d,h){e[0]=i.m_re[0],d[0]=i.m_im[0],s[0]=h[0]=0,e[p]=i.m_re[p],d[p]=i.m_im[p],s[p]=h[p]=0;for(var u=1;u{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=class Bisector{constructor(e){this.lower=e.start,this.upper=e.end,this.onprocess=e.process,this.position=0,this.n=0}iterate(){return this.n++,this.position=Math.floor((this.lower+this.upper)/2),this.onprocess(this.lower,this.upper,this.position)}start(){return this.iterate(),this}left(){return this.upper=this.position,this.iterate()}right(){return this.lower=this.position,this.iterate()}};t.default=i},523:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=new class{hasTypedArrays(){return!!window.Uint32Array}hasWebAssembly(){return!!window.WebAssembly}hasWebAudio(){return!(!window.AudioContext&&!window.webkitAudioContext)}hasFlash(){return!1}hasAudio(){return this.hasWebAudio()}isBlacklisted(e){return!1}isSlow(){return!1}isTooSlow(){return!1}supported(e){return"OGVDecoder"===e?this.hasWebAssembly():"OGVPlayer"===e&&(this.supported("OGVDecoder")&&this.hasAudio())}};t.default=i},408:(e,t,i)=>{"use strict";var s=i(318);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var d=s(i(580));class OGVDecoderAudioProxy extends((0,d.default)({loadedMetadata:!1,audioFormat:null,audioBuffer:null,cpuTime:0})){init(e){this.proxy("init",[],e)}processHeader(e,t){this.proxy("processHeader",[e],t,[e])}processAudio(e,t){this.proxy("processAudio",[e],t,[e])}close(){this.terminate()}}var h=OGVDecoderAudioProxy;t.default=h},319:(e,t,i)=>{"use strict";var s=i(318);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var d=s(i(580));class OGVDecoderVideoProxy extends((0,d.default)({loadedMetadata:!1,videoFormat:null,frameBuffer:null,cpuTime:0})){init(e){this.proxy("init",[],e)}processHeader(e,t){this.proxy("processHeader",[e],t,[e])}processFrame(e,t){this.proxy("processFrame",[e],t,[e])}close(){this.terminate()}sync(){this.proxy("sync",[],(()=>{}))}recycleFrame(e){this.proxy("recycleFrame",[e],(()=>{}),[e.y.bytes.buffer,e.u.bytes.buffer,e.v.bytes.buffer])}}var h=OGVDecoderVideoProxy;t.default=h},445:(e,t,i)=>{"use strict";var s=i(318);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var d=s(i(539)),h="1.8.6-20220111172545-1f60d9d",u={OGVDemuxerOggW:"ogv-demuxer-ogg-wasm.js",OGVDemuxerWebMW:"ogv-demuxer-webm-wasm.js",OGVDecoderAudioOpusW:"ogv-decoder-audio-opus-wasm.js",OGVDecoderAudioVorbisW:"ogv-decoder-audio-vorbis-wasm.js",OGVDecoderVideoTheoraW:"ogv-decoder-video-theora-wasm.js",OGVDecoderVideoVP8W:"ogv-decoder-video-vp8-wasm.js",OGVDecoderVideoVP8MTW:"ogv-decoder-video-vp8-mt-wasm.js",OGVDecoderVideoVP9W:"ogv-decoder-video-vp9-wasm.js",OGVDecoderVideoVP9SIMDW:"ogv-decoder-video-vp9-simd-wasm.js",OGVDecoderVideoVP9MTW:"ogv-decoder-video-vp9-mt-wasm.js",OGVDecoderVideoVP9SIMDMTW:"ogv-decoder-video-vp9-simd-mt-wasm.js",OGVDecoderVideoAV1W:"ogv-decoder-video-av1-wasm.js",OGVDecoderVideoAV1SIMDW:"ogv-decoder-video-av1-simd-wasm.js",OGVDecoderVideoAV1MTW:"ogv-decoder-video-av1-mt-wasm.js",OGVDecoderVideoAV1SIMDMTW:"ogv-decoder-video-av1-simd-mt-wasm.js"};var c=class OGVLoaderBase{constructor(){this.base=this.defaultBase()}defaultBase(){}wasmSupported(){return d.default.wasmSupported()}scriptForClass(e){return u[e]}urlForClass(e){var t=this.scriptForClass(e);if(t)return this.urlForScript(t);throw new Error("asked for URL for unknown class "+e)}urlForScript(e){if(e){var t=this.base;return void 0===t?t="":t+="/",t+e+"?version="+encodeURIComponent(h)}throw new Error("asked for URL for unknown script "+e)}loadClass(e,t,i){i=i||{};var s=this.getGlobal(),d=this.urlForClass(e),classWrapper=t=>((t=t||{}).locateFile=e=>"data:"===e.slice(0,5)?e:this.urlForScript(e),t.mainScriptUrlOrBlob=this.scriptForClass(e)+"?version="+encodeURIComponent(h),s[e](t));"function"==typeof s[e]?t(classWrapper):this.loadScript(d,(()=>{t(classWrapper)}))}};t.default=c},964:(e,t,i)=>{"use strict";var s=i(318);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var d=s(i(408)),h=s(i(319)),u=s(i(445)),c={audio:{proxy:d.default,worker:"ogv-worker-audio.js"},video:{proxy:h.default,worker:"ogv-worker-video.js"}},l={OGVDecoderAudioOpusW:"audio",OGVDecoderAudioVorbisW:"audio",OGVDecoderVideoTheoraW:"video",OGVDecoderVideoVP8W:"video",OGVDecoderVideoVP9W:"video",OGVDecoderVideoVP9SIMDW:"video",OGVDecoderVideoAV1W:"video",OGVDecoderVideoAV1SIMDW:"video"};class OGVLoaderWeb extends u.default{constructor(){super(),this.scriptStatus={},this.scriptCallbacks={}}getGlobal(){return window}defaultBase(){for(var e,t,i=document.querySelectorAll("script"),s=/^(?:|(.*)\/)ogv(?:-support|-es2017)?\.js(?:\?|#|$)/,d=0;d{var i=this.scriptCallbacks[e];delete this.scriptCallbacks[e],this.scriptStatus[e]="done",i.forEach((e=>{e()}))};i.addEventListener("load",done),i.addEventListener("error",done),i.src=e,document.querySelector("head").appendChild(i)}}workerProxy(e,t){var i=c[l[e]];if(!i)throw new Error("Requested worker for class with no proxy: "+e);var s,d=i.proxy,h=i.worker,u=this.urlForScript(this.scriptForClass(e)),_=this.urlForScript(h),p=function construct(t){return new d(s,e,t)};if(_.match(/^https?:|\/\//i)){var m,g,v,y,b,T=!1,k=!1;function completionCheck(){if(1==T&&1==k){var e=v+" "+y+"\nOGVLoader.base = "+JSON.stringify(f.base);try{b=new Blob([e],{type:"application/javascript"})}catch(t){window.BlobBuilder=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder,(b=new BlobBuilder).append(e),b=b.getBlob()}s=new Worker(URL.createObjectURL(b)),t((function(e){return Promise.resolve(new p(e))}))}}(m=new XMLHttpRequest).open("GET",u,!0),m.onreadystatechange=function(){4==m.readyState&&200==m.status&&(v=m.responseText,T=!0,completionCheck())},m.send(),(g=new XMLHttpRequest).open("GET",_,!0),g.onreadystatechange=function(){4==g.readyState&&200==g.status&&(y=g.responseText,k=!0,completionCheck())},g.send()}else s=new Worker(_),t((function(e){return Promise.resolve(new p(e))}))}}var f=new OGVLoaderWeb,_=f;t.default=_},759:(e,t,i)=>{"use strict";var s=i(318);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var d=s(i(309)),h={MEDIA_ERR_ABORTED:1,MEDIA_ERR_NETWORK:2,MEDIA_ERR_DECODE:3,MEDIA_ERR_SRC_NOT_SUPPORTED:4};class OGVMediaError{constructor(e,t){this.code=e,this.message=t}}(0,d.default)(OGVMediaError,h),(0,d.default)(OGVMediaError.prototype,h);var u=OGVMediaError;t.default=u},278:(e,t)=>{"use strict";function split(e,t,i){var s=e.split(t,i).map((e=>function trim(e){return e.replace(/^\s+/,"").replace(/\s+$/,"")}(e)));if("number"==typeof i)for(;s.length{"use strict";var s=i(318);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var d,h=s(i(731)),u=s(i(936)),c=s(i(848)),l=s(i(964)),f=s(i(893)),_=s(i(309)),p=s(i(759)),m=s(i(278)),g=s(i(168)),v=s(i(625)),y=(()=>{if("function"==typeof setImmediate)return setImmediate;var e=new MessageChannel,t=[];return e.port1.onmessage=e=>{t.shift()()},function nextTick(i){t.push(i),e.port2.postMessage({})}})(),b={NETWORK_EMPTY:0,NETWORK_IDLE:1,NETWORK_LOADING:2,NETWORK_NO_SOURCE:3,HAVE_NOTHING:0,HAVE_METADATA:1,HAVE_CURRENT_DATA:2,HAVE_FUTURE_DATA:3,HAVE_ENOUGH_DATA:4},T="INITIAL",k="SEEKING_END",w="LOADED",P="PRELOAD",E="READY",x="PLAYING",A="SEEKING",R="ERROR",F="NOT_SEEKING",O="BISECT_TO_TARGET",C="BISECT_TO_KEYPOINT",S="LINEAR_TO_TARGET",B="exact",D="fast";function OGVJSElement(){var e=document.createElement("ogvjs");return Object.setPrototypeOf?Object.setPrototypeOf(e,Object.getPrototypeOf(this)):e.__proto__=this.__proto__,e}d="undefined"==typeof performance||void 0===typeof performance.now?Date.now:performance.now.bind(performance),OGVJSElement.prototype=Object.create(HTMLElement.prototype,{});class OGVPlayer extends OGVJSElement{constructor(e){if(super(),(e=e||{}).base=e.base||l.default.base,this._options=e,this._instanceId="ogvjs"+ ++OGVPlayer.instanceCount,void 0!==e.worker?this._enableWorker=!!e.worker:this._enableWorker=!!window.Worker,!l.default.wasmSupported())throw new Error("WebAssembly not supported");this._enableThreading=!!e.threading,this._enableSIMD=!!e.simd,this._state=T,this._seekState=F,this._detectedType=null,this._canvas=document.createElement("canvas"),this._frameSink=null,this.className=this._instanceId,(0,_.default)(this,b),this._view=this._canvas,this._view.style.position="absolute",this._view.style.top="0",this._view.style.left="0",this._view.style.width="100%",this._view.style.height="100%",this._view.style.objectFit="contain",this.appendChild(this._view),this._startTime=d(),this._codec=null,this._audioInfo=null,this._videoInfo=null,this._actionQueue=[],this._audioFeeder=null,this._muted=!1,this._initialPlaybackPosition=0,this._initialPlaybackOffset=0,this._prebufferingAudio=!1,this._initialSeekTime=0,this._currentSrc="",this._streamEnded=!1,this._mediaError=null,this._dataEnded=!1,this._byteLength=0,this._duration=null,this._lastSeenTimestamp=null,this._nextProcessingTimer,this._nextFrameTimer=null,this._loading=!1,this._started=!1,this._paused=!0,this._ended=!1,this._startedPlaybackInDocument=!1,this._stream=void 0,this._framesProcessed=0,this._targetPerFrameTime=1e3/60,this._actualPerFrameTime=0,this._totalFrameTime=0,this._totalFrameCount=0,this._playTime=0,this._bufferTime=0,this._drawingTime=0,this._proxyTime=0,this._totalJitter=0,this._droppedAudio=0,this._delayedAudio=0,this._lateFrames=0,this._poster="",this._thumbnail=null,this._frameEndTimestamp=0,this._audioEndTimestamp=0,this._decodedFrames=[],this._pendingFrames=[],this._lastFrameDecodeTime=0,this._lastFrameVideoCpuTime=0,this._lastFrameAudioCpuTime=0,this._lastFrameDemuxerCpuTime=0,this._lastFrameDrawingTime=0,this._lastFrameBufferTime=0,this._lastFrameProxyTime=0,this._lastVideoCpuTime=0,this._lastAudioCpuTime=0,this._lastDemuxerCpuTime=0,this._lastBufferTime=0,this._lastProxyTime=0,this._lastDrawingTime=0,this._lastFrameTimestamp=0,this._currentVideoCpuTime=0,this._lastTimeUpdate=0,this._timeUpdateInterval=250,this._seekTargetTime=0,this._bisectTargetTime=0,this._seekMode=null,this._lastSeekPosition=null,this._seekBisector=null,this._didSeek=null,this._depth=0,this._needProcessing=!1,this._pendingFrame=0,this._pendingAudio=0,this._framePipelineDepth=8,this._frameParallelism=this._enableThreading?Math.min(16,navigator.hardwareConcurrency)||1:0,this._audioPipelineDepth=12,this._videoInfo=null,this._audioInfo=null,this._width=0,this._height=0,this._volume=1,this._playbackRate=1,Object.defineProperties(this,{src:{get:function getSrc(){return this.getAttribute("src")||""},set:function setSrc(e){this.setAttribute("src",e),this._loading=!1,this._prepForLoad("interactive")}},buffered:{get:function getBuffered(){var e;return e=this._stream&&this._byteLength&&this._duration?this._stream.getBufferedRanges().map((e=>e.map((e=>e/this._stream.length*this._duration)))):[[0,0]],new g.default(e)}},seekable:{get:function getSeekable(){return this.duration<1/0&&this._stream&&this._stream.seekable&&this._codec&&this._codec.seekable?new g.default([[0,this._duration]]):new g.default([])}},currentTime:{get:function getCurrentTime(){return this._state==A?this._seekTargetTime:this._codec?this._state!=x||this._paused?this._initialPlaybackOffset:this._getPlaybackTime():this._initialSeekTime},set:function setCurrentTime(e){this._seek(e,B)}},duration:{get:function getDuration(){return this._codec&&this._codec.loadedMetadata?null!==this._duration?this._duration:1/0:NaN}},paused:{get:function getPaused(){return this._paused}},ended:{get:function getEnded(){return this._ended}},seeking:{get:function getSeeking(){return this._state==A}},muted:{get:function getMuted(){return this._muted},set:function setMuted(e){this._muted=e,this._audioFeeder?this._audioFeeder.muted=this._muted:this._started&&!this._muted&&this._codec&&this._codec.hasAudio&&(this._log("unmuting: switching from timer to audio clock"),this._initAudioFeeder(),this._startPlayback(this._audioEndTimestamp)),this._fireEventAsync("volumechange")}},poster:{get:function getPoster(){return this._poster},set:function setPoster(e){if(this._poster=e,!this._started){this._thumbnail&&this.removeChild(this._thumbnail);var t=new Image;t.src=this._poster,t.className="ogvjs-poster",t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.width="100%",t.style.height="100%",t.style.objectFit="contain",t.style.visibility="hidden",t.addEventListener("load",(()=>{this._thumbnail===t&&(OGVPlayer.styleManager.appendRule("."+this._instanceId,{width:t.naturalWidth+"px",height:t.naturalHeight+"px"}),t.style.visibility="visible")})),this._thumbnail=t,this.appendChild(t)}}},videoWidth:{get:function getVideoWidth(){return this._videoInfo?this._videoInfo.displayWidth:0}},videoHeight:{get:function getVideoHeight(){return this._videoInfo?this._videoInfo.displayHeight:0}},ogvjsVideoFrameRate:{get:function getOgvJsVideoFrameRate(){return this._videoInfo?0==this._videoInfo.fps?this._totalFrameCount/(this._totalFrameTime/1e3):this._videoInfo.fps:0}},ogvjsAudioChannels:{get:function getOgvJsAudioChannels(){return this._audioInfo?this._audioInfo.channels:0}},ogvjsAudioSampleRate:{get:function getOgvJsAudioChannels(){return this._audioInfo?this._audioInfo.rate:0}},width:{get:function getWidth(){return this._width},set:function setWidth(e){this._width=parseInt(e,10),this.style.width=this._width+"px"}},height:{get:function getHeight(){return this._height},set:function setHeight(e){this._height=parseInt(e,10),this.style.height=this._height+"px"}},autoplay:{get:function getAutoplay(){return!1},set:function setAutoplay(e){}},controls:{get:function getControls(){return!1},set:function setControls(e){}},loop:{get:function getLoop(){return!1},set:function setLoop(e){}},crossOrigin:{get:function getCrossOrigin(){return null},set:function setCrossOrigin(e){}},currentSrc:{get:function getCurrentSrc(){return this._currentSrc}},defaultMuted:{get:function getDefaultMuted(){return!1}},defaultPlaybackRate:{get:function getDefaultPlaybackRate(){return 1}},error:{get:function getError(){return this._state===R?this._mediaError?this._mediaError:new p.default("unknown error occurred in media procesing"):null}},preload:{get:function getPreload(){return this.getAttribute("preload")||""},set:function setPreload(e){this.setAttribute("preload",e)}},readyState:{get:function getReadyState(){return this._stream&&this._codec&&this._codec.loadedMetadata?OGVPlayer.HAVE_ENOUGH_DATA:OGVPlayer.HAVE_NOTHING}},networkState:{get:function getNetworkState(){return this._stream?this._stream.waiting?OGVPlayer.NETWORK_LOADING:OGVPlayer.NETWORK_IDLE:this.readyState==OGVPlayer.HAVE_NOTHING?OGVPlayer.NETWORK_EMPTY:OGVPlayer.NETWORK_NO_SOURCE}},playbackRate:{get:function getPlaybackRate(){return this._playbackRate},set:function setPlaybackRate(e){var t=Number(e)||1;this._audioFeeder?this._audioFeeder.tempo=t:this._paused||(this._initialPlaybackOffset=this._getPlaybackTime(),this._initialPlaybackPosition=t*d()/1e3),this._playbackRate=t,this._fireEventAsync("ratechange")}},played:{get:function getPlayed(){return new g.default([[0,this.currentTime]])}},volume:{get:function getVolume(){return this._volume},set:function setVolume(e){this._volume=+e,this._audioFeeder&&(this._audioFeeder.volume=this._volume),this._fireEventAsync("volumechange")}}}),this.onframecallback=null,this.onloadstate=null,this.onprogress=null,this.onsuspend=null,this.onabort=null,this.onemptied=null,this.onstalled=null,this.onloadedmetadata=null,this.onloadeddata=null,this.oncanplay=null,this.oncanplaythrough=null,this.onplaying=null,this.onwaiting=null,this.onseeking=null,this.onseeked=null,this.onended=null,this.ondurationchange=null,this.ontimeupdate=null,this.onplay=null,this.onpause=null,this.onratechange=null,this.onresize=null,this.onvolumechange=null,this.onaudiofeedercreated=null}_time(e){var t=d();e();var i=d()-t;return this._lastFrameDecodeTime+=i,i}_log(e){var t=this._options;if(t.debug){var i=d()-this._startTime;t.debugFilter&&!e.match(t.debugFilter)||console.log("["+Math.round(10*i)/10+"ms] "+e)}}_fireEvent(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this._log("fireEvent "+e);var i,s="function"==typeof Event;for(var d in s?i=new CustomEvent(e):(i=document.createEvent("Event")).initEvent(e,!1,!1),t)t.hasOwnProperty(d)&&(i[d]=t[d]);var h=this.dispatchEvent(i);!s&&"resize"===e&&this.onresize&&h&&this.onresize.call(this,i)}_fireEventAsync(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this._log("fireEventAsync "+e),y((()=>{this._fireEvent(e,t)}))}static initSharedAudioContext(){c.default.initSharedAudioContext()}_initAudioFeeder(){var e=this._options,t={bufferSize:8192};e.audioContext&&(t.audioContext=e.audioContext),e.audioDestination&&(t.output=e.audioDestination),e.audioBackendFactory&&(t.backendFactory=e.audioBackendFactory);var i=this._audioFeeder=new c.default(t);i.init(this._audioInfo.channels,this._audioInfo.rate),this.onaudiofeedercreated&&this.onaudiofeedercreated(this._audioFeeder),i.bufferThreshold=1,i.volume=this.volume,i.muted=this.muted,i.tempo=this.playbackRate,i.onbufferlow=()=>{this._log("onbufferlow"),this._stream&&(this._stream.buffering||this._stream.seeking)||this._pendingAudio||this._pingProcessing()},i.onstarved=()=>{this._dataEnded?this._log("onstarved: appear to have reached end of audio"):(this._log("onstarved: halting audio due to starvation"),this._stopPlayback(),this._prebufferingAudio=!0),this._isProcessing()||this._pingProcessing(0)}}_startPlayback(e){if(this._audioFeeder){this._audioFeeder.start();var t=this._audioFeeder.getPlaybackState();this._initialPlaybackPosition=t.playbackPosition}else this._initialPlaybackPosition=this._playbackRate*d()/1e3;void 0!==e&&(this._initialPlaybackOffset=e),this._prebufferingAudio=!1,this._log("continuing at "+this._initialPlaybackPosition+", "+this._initialPlaybackOffset)}_stopPlayback(){this._initialPlaybackOffset=this._getPlaybackTime(),this._log("pausing at "+this._initialPlaybackOffset),this._audioFeeder&&this._audioFeeder.stop()}_getPlaybackTime(e){return this._prebufferingAudio||this._paused?this._initialPlaybackOffset:(this._audioFeeder?(e=e||this._audioFeeder.getPlaybackState()).playbackPosition:this._playbackRate*d()/1e3)-this._initialPlaybackPosition+this._initialPlaybackOffset}_stopVideo(){this._log("STOPPING"),this._state=T,this._seekState=F,this._started=!1,this._ended=!1,this._frameEndTimestamp=0,this._audioEndTimestamp=0,this._lastFrameDecodeTime=0,this._prebufferingAudio=!1,this._actionQueue.splice(0,this._actionQueue.length),this._stream&&(this._stream.abort(),this._stream=null,this._streamEnded=!1),this._codec&&(this._codec.close(),this._codec=null,this._pendingFrame=0,this._pendingAudio=0,this._dataEnded=!1),this._videoInfo=null,this._audioInfo=null,this._audioFeeder&&(this._audioFeeder.close(),this._audioFeeder=null),this._nextProcessingTimer&&(clearTimeout(this._nextProcessingTimer),this._nextProcessingTimer=null),this._nextFrameTimer&&(clearTimeout(this._nextFrameTimer),this._nextFrameTimer=null),this._frameSink&&(this._frameSink.clear(),this._frameSink=null),this._decodedFrames&&(this._decodedFrames=[]),this._pendingFrames&&(this._pendingFrames=[]),this._initialSeekTime=0,this._initialPlaybackPosition=0,this._initialPlaybackOffset=0,this._duration=null}_doFrameComplete(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._startedPlaybackInDocument&&!document.body.contains(this)&&y((()=>{this.stop()}));var t=d(),i=t-this._lastFrameTimestamp,s=this._actualPerFrameTime-this._targetPerFrameTime;this._totalJitter+=Math.abs(s),this._playTime+=i;var h={cpuTime:this._lastFrameDecodeTime,drawingTime:this._drawingTime-this._lastFrameDrawingTime,bufferTime:this._bufferTime-this._lastFrameBufferTime,proxyTime:this._proxyTime-this._lastFrameProxyTime,demuxerTime:0,videoTime:0,audioTime:0,clockTime:this._actualPerFrameTime,late:e.dropped,dropped:e.dropped};function n(e){return Math.round(10*e)/10}this._codec&&(h.demuxerTime=this._codec.demuxerCpuTime-this._lastFrameDemuxerCpuTime,h.videoTime+=this._currentVideoCpuTime-this._lastFrameVideoCpuTime,h.audioTime+=this._codec.audioCpuTime-this._lastFrameAudioCpuTime),h.cpuTime+=h.demuxerTime,this._lastFrameDecodeTime=0,this._lastFrameTimestamp=t,this._codec?(this._lastFrameVideoCpuTime=this._currentVideoCpuTime,this._lastFrameAudioCpuTime=this._codec.audioCpuTime,this._lastFrameDemuxerCpuTime=this._codec.demuxerCpuTime):(this._lastFrameVideoCpuTime=0,this._lastFrameAudioCpuTime=0,this._lastFrameDemuxerCpuTime=0),this._lastFrameDrawingTime=this._drawingTime,this._lastFrameBufferTime=this._bufferTime,this._lastFrameProxyTime=this._proxyTime,this._log("drew frame "+e.frameEndTimestamp+": clock time "+n(i)+" (jitter "+n(s)+") cpu: "+n(h.cpuTime)+" (mux: "+n(h.demuxerTime)+" buf: "+n(h.bufferTime)+" draw: "+n(h.drawingTime)+" proxy: "+n(h.proxyTime)+") vid: "+n(h.videoTime)+" aud: "+n(h.audioTime)),this._fireEventAsync("framecallback",h),(!this._lastTimeUpdate||t-this._lastTimeUpdate>=this._timeUpdateInterval)&&(this._lastTimeUpdate=t,this._fireEventAsync("timeupdate")),this._codec&&e.yCbCrBuffer&&this._codec.recycleFrame(e.yCbCrBuffer)}_seekStream(e){this._stream.seeking&&this._stream.abort(),this._stream.buffering&&this._stream.abort(),this._streamEnded=!1,this._dataEnded=!1,this._ended=!1,this._stream.seek(e).then((()=>{this._readBytesAndWait()})).catch((e=>{this._onStreamError(e)}))}_onStreamError(e){"AbortError"===e.name?this._log("i/o promise canceled; ignoring"):(this._log("i/o error: "+e),this._mediaError=new p.default(p.default.MEDIA_ERR_NETWORK,String(e)),this._state=R,this._stopPlayback())}_seek(e,t){if(this._log("requested seek to "+e+", mode "+t),this.readyState==this.HAVE_NOTHING)return this._log("not yet loaded; saving seek position for later"),void(this._initialSeekTime=e);if(this._stream&&!this._stream.seekable)throw new Error("Cannot seek a non-seekable stream");if(this._codec&&!this._codec.seekable)throw new Error("Cannot seek in a non-seekable file");var prepForSeek=i=>{this._stream&&this._stream.buffering&&this._stream.abort(),this._stream&&this._stream.seeking&&this._stream.abort(),this._actionQueue.splice(0,this._actionQueue.length),this._stopPlayback(),this._prebufferingAudio=!1,this._audioFeeder&&this._audioFeeder.flush(),this._state=A,this._seekTargetTime=e,this._seekMode=t,this._codec?this._codec.flush(i):i()};prepForSeek((()=>{this._isProcessing()||this._pingProcessing(0)})),this._actionQueue.push((()=>{prepForSeek((()=>{this._doSeek(e)}))}))}_doSeek(e){this._streamEnded=!1,this._dataEnded=!1,this._ended=!1,this._state=A,this._seekTargetTime=e,this._lastSeekPosition=-1,this._decodedFrames=[],this._pendingFrames=[],this._pendingFrame=0,this._pendingAudio=0,this._didSeek=!1,this._codec.seekToKeypoint(e,(t=>{if(t)return this._seekState=S,this._fireEventAsync("seeking"),this._didSeek?void 0:void this._pingProcessing();this._codec.getKeypointOffset(e,(e=>{e>0?(this._seekState=S,this._seekStream(e)):(this._seekState=O,this._startBisection(this._seekTargetTime)),this._fireEventAsync("seeking")}))}))}_startBisection(e){var t=Math.max(0,this._stream.length-65536);this._bisectTargetTime=e,this._seekBisector=new f.default({start:0,end:t,process:(e,t,i)=>i!=this._lastSeekPosition&&(this._lastSeekPosition=i,this._codec.flush((()=>{this._seekStream(i)})),!0)}),this._seekBisector.start()}_continueSeekedPlayback(){this._seekState=F,this._state=E,this._frameEndTimestamp=this._codec.frameTimestamp,this._audioEndTimestamp=this._codec.audioTimestamp,this._codec.hasAudio?this._seekTargetTime=this._codec.audioTimestamp:this._seekTargetTime=this._codec.frameTimestamp,this._initialPlaybackOffset=this._seekTargetTime;var finishedSeeking=()=>{this._lastTimeUpdate=this._seekTargetTime,this._fireEventAsync("timeupdate"),this._fireEventAsync("seeked"),this._isProcessing()||this._pingProcessing()};if(this._codec.hasVideo&&this._decodedFrames.length){var e=this._decodedFrames.shift();this._drawFrame(e.yCbCrBuffer),finishedSeeking()}else{if(this._codec.hasVideo&&this._codec.frameReady)return this._codec.decodeFrame((e=>{e&&this._drawFrame(this._codec.frameBuffer),finishedSeeking()})),void this._codec.sync();finishedSeeking()}}_drawFrame(e){this._thumbnail&&(this.removeChild(this._thumbnail),this._thumbnail=null),this._frameSink.drawFrame(e)}_doProcessLinearSeeking(){var e;if(e=this._codec.hasVideo?this._targetPerFrameTime/1e3:1/256,this._codec.hasVideo){if(this._pendingFrame)return;if(!this._codec.frameReady)return void this._codec.process((e=>{e?this._pingProcessing():this._streamEnded?(this._log("stream ended during linear seeking on video"),this._dataEnded=!0,this._continueSeekedPlayback()):this._readBytesAndWait()}));if(this._seekMode===D&&this._codec.keyframeTimestamp==this._codec.frameTimestamp)return void this._continueSeekedPlayback();if(this._codec.frameTimestamp<=this._seekTargetTime){var t=this._codec.frameTimestamp;return this._pendingFrame++,this._pendingFrames.push({frameEndTimestamp:t}),this._decodedFrames.splice(0,this._decodedFrames.length),this._codec.decodeFrame((e=>{this._pendingFrame--,this._pendingFrames.shift(),this._decodedFrames.push({yCbCrBuffer:this._codec.frameBuffer,videoCpuTime:this._codec.videoCpuTime,frameEndTimestamp:t}),this._pingProcessing()})),void this._codec.sync()}if(!this._codec.hasAudio)return void this._continueSeekedPlayback()}if(this._codec.hasAudio){if(this._pendingAudio)return;return this._codec.audioReady?this._codec.audioTimestamp+e{this._pingProcessing()})):void this._continueSeekedPlayback():void this._codec.process((e=>{e?this._pingProcessing():this._streamEnded?(this._log("stream ended during linear seeking on audio"),this._dataEnded=!0,this._continueSeekedPlayback()):this._readBytesAndWait()}))}}_doProcessBisectionSeek(){var e,t;if(this._codec.hasVideo)t=this._codec.frameTimestamp,e=this._targetPerFrameTime/1e3;else{if(!this._codec.hasAudio)throw new Error("Invalid seek state; no audio or video track available");t=this._codec.audioTimestamp,e=1/256}t<0?this._codec.process((e=>{if(e)this._pingProcessing();else if(this._streamEnded){if(this._log("stream ended during bisection seek"),!this._seekBisector.right())throw this._log("failed going back"),new Error("not sure what to do")}else this._readBytesAndWait()})):t-e/2>this._bisectTargetTime?this._seekBisector.left()||(this._log("close enough (left)"),this._seekTargetTime=t,this._continueSeekedPlayback()):t+e/20?this._targetPerFrameTime=1e3/this._videoInfo.fps:this._targetPerFrameTime=16.667,this._canvas.width=this._videoInfo.displayWidth,this._canvas.height=this._videoInfo.displayHeight,OGVPlayer.styleManager.appendRule("."+this._instanceId,{width:this._videoInfo.displayWidth+"px",height:this._videoInfo.displayHeight+"px"});var e={};void 0!==this._options.webGL&&(e.webGL=this._options.webGL),this._options.forceWebGL&&(e.webGL="required"),this._frameSink=h.default.attach(this._canvas,e)}_doProcessing(){if(this._didSeek&&(this._didSeek=!1),this._nextProcessingTimer=null,this._isProcessing(),this._depth>0)throw new Error("REENTRANCY FAIL: doProcessing recursing unexpectedly");var e=0;do{if(this._needProcessing=!1,this._depth++,this._doProcessingLoop(),this._depth--,this._needProcessing&&this._isProcessing())throw new Error("REENTRANCY FAIL: waiting on input or codec but asked to keep processing");++e>500&&(this._log("stuck in processing loop; breaking with timer"),this._needProcessing=0,this._pingProcessing(0))}while(this._needProcessing)}_doProcessingLoop(){if(this._actionQueue.length)this._actionQueue.shift()();else if(this._state==T)this._doProcessInitial();else if(this._state==k)this._doProcessSeekingEnd();else if(this._state==w)this._doProcessLoaded();else if(this._state==P)this._doProcessPreload();else if(this._state==E)this._doProcessReady();else if(this._state==A)this._doProcessSeeking();else if(this._state==x)this._doProcessPlay();else{if(this._state!=R)throw new Error("Unexpected OGVPlayer state "+this._state);this._doProcessError()}}_doProcessInitial(){if(this._codec.loadedMetadata){if(!this._codec.hasVideo&&!this._codec.hasAudio)throw new Error("No audio or video found, something is wrong");this._codec.hasAudio&&(this._audioInfo=this._codec.audioFormat),this._codec.hasVideo&&(this._videoInfo=this._codec.videoFormat,this._setupVideo()),isNaN(this._codec.duration)||(this._duration=this._codec.duration),null===this._duration&&this._stream.seekable&&"video/ogg"==this._detectedType?(this._state=k,this._lastSeenTimestamp=-1,this._codec.flush((()=>{this._seekStream(Math.max(0,this._stream.length-131072))}))):(this._state=w,this._pingProcessing())}else this._codec.process((e=>{if(e)this._pingProcessing();else{if(this._streamEnded)throw new Error("end of file before headers found");this._log("reading more cause we are out of data"),this._readBytesAndWait()}}))}_doProcessSeekingEnd(){this._codec.frameReady?(this._log("saw frame with "+this._codec.frameTimestamp),this._lastSeenTimestamp=Math.max(this._lastSeenTimestamp,this._codec.frameTimestamp),this._codec.discardFrame((()=>{this._pingProcessing()}))):this._codec.audioReady?(this._log("saw audio with "+this._codec.audioTimestamp),this._lastSeenTimestamp=Math.max(this._lastSeenTimestamp,this._codec.audioTimestamp),this._codec.discardAudio((()=>{this._pingProcessing()}))):this._codec.process((e=>{e?this._pingProcessing():this._stream.eof?(this._log("seek-duration: we are at the end: "+this._lastSeenTimestamp),this._lastSeenTimestamp>0&&(this._duration=this._lastSeenTimestamp),this._state=w,this._codec.flush((()=>{this._streamEnded=!1,this._dataEnded=!1,this._seekStream(0)}))):this._readBytesAndWait()}))}_doProcessLoaded(){this._state=P,this._fireEventAsync("loadedmetadata"),this._fireEventAsync("durationchange"),this._codec.hasVideo&&this._fireEventAsync("resize"),this._pingProcessing(0)}_doProcessPreload(){!this._codec.frameReady&&this._codec.hasVideo||!this._codec.audioReady&&this._codec.hasAudio?this._codec.process((e=>{e?this._pingProcessing():this._streamEnded?this._ended=!0:this._readBytesAndWait()})):(this._state=E,this._fireEventAsync("loadeddata"),this._pingProcessing())}_doProcessReady(){if(this._log("initial seek to "+this._initialSeekTime),this._initialSeekTime>0){var e=this._initialSeekTime;this._initialSeekTime=0,this._log("initial seek to "+e),this._doSeek(e)}else if(this._paused)this._log("paused while in ready");else{var finishStartPlaying=()=>{this._log("finishStartPlaying"),this._state=x,this._lastFrameTimestamp=d(),this._codec.hasAudio&&this._audioFeeder?this._prebufferingAudio=!0:this._startPlayback(),this._pingProcessing(0),this._fireEventAsync("play"),this._fireEventAsync("playing")};!this._codec.hasAudio||this._audioFeeder||this._muted?finishStartPlaying():(this._initAudioFeeder(),this._audioFeeder.waitUntilReady(finishStartPlaying))}}_doProcessSeeking(){if(this._seekState==F)throw new Error("seeking in invalid state (not seeking?)");if(this._seekState==O)this._doProcessBisectionSeek();else if(this._seekState==C)this._doProcessBisectionSeek();else{if(this._seekState!=S)throw new Error("Invalid seek state "+this._seekState);this._doProcessLinearSeeking()}}_doProcessPlay(){var e=this._codec;if(this._paused)this._log("paused during playback; stopping loop");else if((!e.hasAudio||e.audioReady||this._pendingAudio||this._dataEnded)&&(!e.hasVideo||e.frameReady||this._pendingFrame||this._decodedFrames.length||this._dataEnded)){var t,i,s,d=null,h=0,u=!1,c=0;if(e.hasAudio&&this._audioFeeder?(d=this._audioFeeder.getPlaybackState(),h=this._getPlaybackTime(d),u=this._dataEnded&&0==this._audioFeeder.durationBuffered,this._prebufferingAudio&&(this._audioFeeder.durationBuffered>=2*this._audioFeeder.bufferThreshold&&(!e.hasVideo||this._decodedFrames.length>=this._framePipelineDepth)||this._dataEnded)&&(this._log("prebuffering audio done; buffered to "+this._audioFeeder.durationBuffered),this._startPlayback(h),this._prebufferingAudio=!1),d.dropped!=this._droppedAudio&&this._log("dropped "+(d.dropped-this._droppedAudio)),d.delayed!=this._delayedAudio&&this._log("delayed "+(d.delayed-this._delayedAudio)),this._droppedAudio=d.dropped,this._delayedAudio=d.delayed,(t=this._audioFeeder.durationBuffered<=2*this._audioFeeder.bufferThreshold)&&(this._codec.audioReady?this._pendingAudio>=this._audioPipelineDepth&&(this._log("audio decode disabled: "+this._pendingAudio+" packets in flight"),t=!1):t=!1)):(h=this._getPlaybackTime(),t=this._codec.audioReady&&this._audioEndTimestamp0,s=this._pendingFrame+this._decodedFrames.length=l){for(var f=-1,_=0;_=0)for(;f-- >=0;){this._lateFrames++;var p=this._decodedFrames.shift();this._log("skipping already-decoded late frame at "+p.frameEndTimestamp),c=1e3*(p.frameEndTimestamp-h),this._frameEndTimestamp=p.frameEndTimestamp,this._actualPerFrameTime=this._targetPerFrameTime-c,this._framesProcessed++,p.dropped=!0,this._doFrameComplete(p)}var m=this._codec.nextKeyframeTimestamp,g=m-this._targetPerFrameTime/1e3*(this._framePipelineDepth+this._pendingFrame);if(m>=0&&m!=this._codec.frameTimestamp&&h>=g){this._log("skipping late frame at "+this._decodedFrames[0].frameEndTimestamp+" vs "+h+", expect to see keyframe at "+m);for(var v=0;v{})),this._framesProcessed++,this._doFrameComplete(k)}return void(this._isProcessing()||this._pingProcessing())}}else i&&c<=4||(i=!1)}if(s){this._log("play loop: ready to decode frame; thread depth: "+this._pendingFrame+", have buffered: "+this._decodedFrames.length),0==this._videoInfo.fps&&this._codec.frameTimestamp-this._frameEndTimestamp>0&&(this._targetPerFrameTime=1e3*(this._codec.frameTimestamp-this._frameEndTimestamp)),this._totalFrameTime+=this._targetPerFrameTime,this._totalFrameCount++;var w=this._frameEndTimestamp=this._codec.frameTimestamp;this._pendingFrame++,this._pendingFrames.push({frameEndTimestamp:w});var P=this._pendingFrames,E=!1,x=this._time((()=>{this._codec.decodeFrame((e=>{P===this._pendingFrames?(this._log("play loop callback: decoded frame"),this._pendingFrame--,this._pendingFrames.shift(),e?this._decodedFrames.push({yCbCrBuffer:this._codec.frameBuffer,videoCpuTime:this._codec.videoCpuTime,frameEndTimestamp:w}):this._log("Bad video packet or something"),this._codec.process((()=>{this._isProcessing()||this._pingProcessing(E?void 0:0)}))):this._log("play loop callback after flush, discarding")}))}));this._pendingFrame&&(E=!0,this._proxyTime+=x,this._pingProcessing(),this._dataEnded&&this._codec.sync())}else if(t){this._log("play loop: ready for audio; depth: "+this._pendingAudio),this._pendingAudio++;var A=this._codec.audioTimestamp,R=this._time((()=>{this._codec.decodeAudio((e=>{if(this._pendingAudio--,this._log("play loop callback: decoded audio"),this._audioEndTimestamp=A,e){var t=this._codec.audioBuffer;if(t&&(this._bufferTime+=this._time((()=>{this._audioFeeder&&this._audioFeeder.bufferData(t)})),!this._codec.hasVideo)){this._framesProcessed++;var i={frameEndTimestamp:this._audioEndTimestamp};this._doFrameComplete(i)}}this._isProcessing()||this._pingProcessing()}))}));this._pendingAudio&&(this._proxyTime+=R,this._codec.audioReady?this._pingProcessing():this._doProcessPlayDemux())}else if(i){this._log("play loop: ready to draw frame"),this._nextFrameTimer&&(clearTimeout(this._nextFrameTimer),this._nextFrameTimer=null),this._thumbnail&&(this.removeChild(this._thumbnail),this._thumbnail=null);var F=this._decodedFrames.shift();this._currentVideoCpuTime=F.videoCpuTime,this._drawingTime+=this._time((()=>{this._drawFrame(F.yCbCrBuffer)})),this._framesProcessed++,this._doFrameComplete(F),this._pingProcessing()}else if(!this._decodedFrames.length||this._nextFrameTimer||this._prebufferingAudio)if(this._dataEnded&&!(this._pendingAudio||this._pendingFrame||this._decodedFrames.length)){this._log("play loop: playback reached end of data "+[this._pendingAudio,this._pendingFrame,this._decodedFrames.length]);var O=0;this._codec.hasAudio&&this._audioFeeder&&(O=1e3*this._audioFeeder.durationBuffered),O>0?(this._log("play loop: ending pending "+O+" ms"),this._pingProcessing(Math.max(0,O))):(this._log("play loop: ENDING NOW: playback time "+this._getPlaybackTime()+"; frameEndTimestamp: "+this._frameEndTimestamp),this._stopPlayback(),this._prebufferingAudio=!1,this._initialPlaybackOffset=Math.max(this._audioEndTimestamp,this._frameEndTimestamp),this._ended=!0,this._paused=!0,this._fireEventAsync("pause"),this._fireEventAsync("ended"))}else this._prebufferingAudio&&(e.hasVideo&&!e.frameReady||e.hasAudio&&!e.audioReady)?(this._log("play loop: prebuffering demuxing"),this._doProcessPlayDemux()):this._log("play loop: waiting on async/timers");else{var C=c;this._log("play loop: setting a timer for drawing "+C),this._nextFrameTimer=setTimeout((()=>{this._nextFrameTimer=null,this._pingProcessing()}),C)}}else this._log("play loop: demuxing"),this._doProcessPlayDemux()}_doProcessPlayDemux(){var e=this._codec.frameReady,t=this._codec.audioReady;this._codec.process((i=>{this._codec.frameReady&&!e||this._codec.audioReady&&!t?(this._log("demuxer has packets"),this._pingProcessing()):i?(this._log("demuxer processing to find more packets"),this._pingProcessing()):(this._log("demuxer ran out of data"),this._streamEnded?(this._log("demuxer reached end of data stream"),this._dataEnded=!0,this._pingProcessing()):(this._log("demuxer loading more data"),this._readBytesAndWait()))}))}_doProcessError(){}_isProcessing(){return this._stream&&(this._stream.buffering||this._stream.seeking)||this._codec&&this._codec.processing}_readBytesAndWait(){if(this._stream.buffering||this._stream.seeking)this._log("readBytesAndWait during i/o");else{this._stream.read(32768).then((e=>{this._log("got input "+[e.byteLength]),e.byteLength&&this._actionQueue.push((()=>{this._codec.receiveInput(e,(()=>{this._pingProcessing()}))})),this._stream.eof&&(this._log("stream is at end!"),this._streamEnded=!0),this._isProcessing()||this._pingProcessing()})).catch((e=>{this._onStreamError(e)}))}}_pingProcessing(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;if(this._stream&&this._stream.waiting)this._log("waiting on input");else{this._nextProcessingTimer&&(this._log("canceling old processing timer"),clearTimeout(this._nextProcessingTimer),this._nextProcessingTimer=null);e>-1/256?this._nextProcessingTimer=setTimeout((()=>{this._pingProcessing()}),e):this._depth?this._needProcessing=!0:this._doProcessing()}}_startProcessingVideo(e){if(!this._started&&!this._codec){this._framesProcessed=0,this._bufferTime=0,this._drawingTime=0,this._proxyTime=0,this._started=!0,this._ended=!1;var t={base:this._options.base,worker:this._enableWorker,threading:this._enableThreading,simd:this._enableSIMD};this._detectedType&&(t.type=this._detectedType),this._codec=new v.default(t),this._lastVideoCpuTime=0,this._lastAudioCpuTime=0,this._lastDemuxerCpuTime=0,this._lastBufferTime=0,this._lastDrawingTime=0,this._lastProxyTime=0,this._lastFrameVideoCpuTime=0,this._lastFrameAudioCpuTime=0,this._lastFrameDemuxerCpuTime=0,this._lastFrameBufferTime=0,this._lastFrameProxyTime=0,this._lastFrameDrawingTime=0,this._currentVideoCpuTime=0,this._codec.onseek=e=>{this._didSeek=!0,this._stream&&this._seekStream(e)},this._codec.init((()=>{this._codec.receiveInput(e,(()=>{this._readBytesAndWait()}))}))}}_loadCodec(e){this._stream.read(1024).then((t=>{var i=new Uint8Array(t);i.length>4&&i[0]=="O".charCodeAt(0)&&i[1]=="g".charCodeAt(0)&&i[2]=="g".charCodeAt(0)&&i[3]=="S".charCodeAt(0)?this._detectedType="video/ogg":i.length>4&&26==i[0]&&69==i[1]&&223==i[2]&&163==i[3]?this._detectedType="video/webm":this._detectedType="video/ogg",e(t)}))}_prepForLoad(e){this._stopVideo();var doLoad=()=>{this._options.stream?this._stream=this._options.stream:this._stream=new u.default({url:this.src,cacheSize:16777216,progressive:!1}),this._stream.load().then((()=>{this._loading=!1,this._currentSrc=this.src,this._byteLength=this._stream.seekable?this._stream.length:0;var e=this._stream.headers["x-content-duration"];"string"==typeof e&&(this._duration=parseFloat(e)),this._loadCodec((e=>{this._startProcessingVideo(e)}))})).catch((e=>{this._onStreamError(e)}))};this._currentSrc="",this._loading=!0,this._actionQueue.push((()=>{e&&"none"===this.preload?this._loading=!1:doLoad()})),this._pingProcessing(0)}load(){this._prepForLoad()}canPlayType(e){var t=new m.default(e);function checkTypes(e){if(t.codecs){var i=0,s=0;return t.codecs.forEach((t=>{e.indexOf(t)>=0?i++:s++})),0===i||s>0?"":"probably"}return"maybe"}return"ogg"!==t.minor||"audio"!==t.major&&"video"!==t.major&&"application"!==t.major?"webm"!==t.minor||"audio"!==t.major&&"video"!==t.major?"":checkTypes(["vorbis","opus","vp8","vp9"]):checkTypes(["vorbis","opus","theora"])}play(){this._muted||this._options.audioContext||OGVPlayer.initSharedAudioContext(),this._paused&&(this._startedPlaybackInDocument=document.body.contains(this),this._paused=!1,this._state==A||(this._started&&this._codec&&this._codec.loadedMetadata?(this._ended&&this._stream&&this._byteLength?(this._log(".play() starting over after end"),this._seek(0)):this._log(".play() while already started"),this._state=E,this._isProcessing()||this._pingProcessing()):this._loading?this._log(".play() while loading"):(this._log(".play() before started"),this._stream||this.load())))}getPlaybackStats(){return{targetPerFrameTime:this._targetPerFrameTime,framesProcessed:this._framesProcessed,videoBytes:this._codec?this._codec.videoBytes:0,audioBytes:this._codec?this._codec.audioBytes:0,playTime:this._playTime,demuxingTime:this._codec?this._codec.demuxerCpuTime-this._lastDemuxerCpuTime:0,videoDecodingTime:this._codec?this._codec.videoCpuTime-this._lastVideoCpuTime:0,audioDecodingTime:this._codec?this._codec.audioCpuTime-this._lastAudioCpuTime:0,bufferTime:this._bufferTime-this._lastBufferTime,drawingTime:this._drawingTime-this._lastDrawingTime,proxyTime:this._proxyTime-this._lastProxyTime,droppedAudio:this._droppedAudio,delayedAudio:this._delayedAudio,jitter:this._totalJitter/this._framesProcessed,lateFrames:this._lateFrames}}resetPlaybackStats(){this._framesProcessed=0,this._playTime=0,this._codec&&(this._lastDemuxerCpuTime=this._codec.demuxerCpuTime,this._lastVideoCpuTime=this._codec.videoCpuTime,this._lastAudioCpuTime=this._codec.audioCpuTime,this._codec.videoBytes=0,this._codec.audioBytes=0),this._lastBufferTime=this._bufferTime,this._lastDrawingTime=this._drawingTime,this._lastProxyTime=this._proxyTime,this._totalJitter=0,this._totalFrameTime=0,this._totalFrameCount=0}getVideoFrameSink(){return this._frameSink}getCanvas(){return this._canvas}getVideo(){return null}pause(){this._paused||(this._nextProcessingTimer&&(clearTimeout(this._nextProcessingTimer),this._nextProcessingTimer=null),this._stopPlayback(),this._prebufferingAudio=!1,this._paused=!0,this._fireEvent("pause"))}stop(){this._stopVideo(),this._paused=!0}fastSeek(e){this._seek(+e,D)}}(0,_.default)(OGVPlayer,b),OGVPlayer.instanceCount=0,OGVPlayer.styleManager=new function StyleManager(){var e=document.createElement("style");e.type="text/css",e.textContent="ogvjs { display: inline-block; position: relative; -webkit-user-select: none; -webkit-tap-highlight-color: rgba(0,0,0,0); ",document.head.appendChild(e);var t=e.sheet;this.appendRule=function(e,i){var s=[];for(var d in i)i.hasOwnProperty(d)&&s.push(d+":"+i[d]);var h=e+"{"+s.join(";")+"}";t.insertRule(h,t.cssRules.length-1)}};var M=OGVPlayer;t.default=M},580:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function OGVProxyClass(e){return class{constructor(t,i,s){for(var d in s=s||{},this.worker=t,this.transferables=function(){var e=new ArrayBuffer(1024),i=new Uint8Array(e);try{return t.postMessage({action:"transferTest",bytes:i},[e]),!e.byteLength}catch(e){return!1}}(),e)e.hasOwnProperty(d)&&(this[d]=e[d]);this.processingQueue=0,Object.defineProperty(this,"processing",{get:function get(){return this.processingQueue>0}}),this.messageCount=0,this.pendingCallbacks={},this.worker.addEventListener("message",(e=>{this.handleMessage(e)})),this.proxy("construct",[i,s],(()=>{}))}proxy(e,t,i){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];if(!this.worker)throw'Tried to call "'+e+'" method on closed proxy object';var d="callback-"+ ++this.messageCount+"-"+e;i&&(this.pendingCallbacks[d]=i);var h={action:e,callbackId:d,args:t||[]};this.processingQueue++,this.transferables?this.worker.postMessage(h,s):this.worker.postMessage(h)}terminate(){this.worker&&(this.worker.terminate(),this.worker=null,this.processingQueue=0,this.pendingCallbacks={})}handleMessage(e){if(this.processingQueue--,"callback"===e.data.action){var t=e.data,i=t.callbackId,s=t.args,d=this.pendingCallbacks[i];if(t.props)for(var h in t.props)t.props.hasOwnProperty(h)&&(this[h]=t.props[h]);d&&(delete this.pendingCallbacks[i],d.apply(this,s))}}}};t.default=i},168:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=class OGVTimeRanges{constructor(e){this._ranges=e,this.length=e.length}start(e){if(e<0||e>this.length||e!==(0|e))throw new RangeError("Invalid index");return this._ranges[e][0]}end(e){if(e<0||e>this.length||e!==(0|e))throw new RangeError("Invalid index");return this._ranges[e][1]}};t.default=i},625:(e,t,i)=>{"use strict";var s=i(318);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var d=s(i(964));var h=class OGVWrapperCodec{constructor(e){return this.options=e||{},this.demuxer=null,this.videoDecoder=null,this.audioDecoder=null,this.flushIter=0,this.loadedMetadata=!1,this.processing=!1,Object.defineProperties(this,{duration:{get:function get(){return this.loadedMetadata?this.demuxer.duration:NaN}},hasAudio:{get:function get(){return this.loadedMetadata&&!!this.audioDecoder}},audioReady:{get:function get(){return this.hasAudio&&this.demuxer.audioReady}},audioTimestamp:{get:function get(){return this.demuxer.audioTimestamp}},audioFormat:{get:function get(){return this.hasAudio?this.audioDecoder.audioFormat:null}},audioBuffer:{get:function get(){return this.hasAudio?this.audioDecoder.audioBuffer:null}},hasVideo:{get:function get(){return this.loadedMetadata&&!!this.videoDecoder}},frameReady:{get:function get(){return this.hasVideo&&this.demuxer.frameReady}},frameTimestamp:{get:function get(){return this.demuxer.frameTimestamp}},keyframeTimestamp:{get:function get(){return this.demuxer.keyframeTimestamp}},nextKeyframeTimestamp:{get:function get(){return this.demuxer.nextKeyframeTimestamp}},videoFormat:{get:function get(){return this.hasVideo?this.videoDecoder.videoFormat:null}},frameBuffer:{get:function get(){return this.hasVideo?this.videoDecoder.frameBuffer:null}},seekable:{get:function get(){return this.demuxer.seekable}},demuxerCpuTime:{get:function get(){return this.demuxer?this.demuxer.cpuTime:0}},audioCpuTime:{get:function get(){return this.audioDecoder?this.audioDecoder.cpuTime:0}},videoCpuTime:{get:function get(){return this.videoDecoder?this.videoDecoder.cpuTime:0}}}),this.loadedDemuxerMetadata=!1,this.loadedAudioMetadata=!1,this.loadedVideoMetadata=!1,this.loadedAllMetadata=!1,this.onseek=null,this.videoBytes=0,this.audioBytes=0,this}flushSafe(e){var t=this.flushIter;return i=>{this.flushIter<=t&&e(i)}}init(e){var t;this.processing=!0,t="video/webm"===this.options.type||"audio/webm"===this.options.type?"OGVDemuxerWebMW":"OGVDemuxerOggW",d.default.loadClass(t,(t=>{t().then((t=>{this.demuxer=t,t.onseek=e=>{this.onseek&&this.onseek(e)},t.init((()=>{this.processing=!1,e()}))}))}))}close(){this.demuxer&&(this.demuxer.close(),this.demuxer=null),this.videoDecoder&&(this.videoDecoder.close(),this.videoDecoder=null),this.audioDecoder&&(this.audioDecoder.close(),this.audioDecoder=null)}receiveInput(e,t){this.demuxer.receiveInput(e,t)}process(e){if(this.processing)throw new Error("reentrancy fail on OGVWrapperCodec.process");this.processing=!0;var finish=t=>{this.processing=!1,e(t)},doProcessData=()=>{this.demuxer.process(finish)};this.demuxer.loadedMetadata&&!this.loadedDemuxerMetadata?this.loadAudioCodec((()=>{this.loadVideoCodec((()=>{this.loadedDemuxerMetadata=!0,this.loadedAudioMetadata=!this.audioDecoder,this.loadedVideoMetadata=!this.videoDecoder,this.loadedAllMetadata=this.loadedAudioMetadata&&this.loadedVideoMetadata,finish(!0)}))})):this.loadedDemuxerMetadata&&!this.loadedAudioMetadata?this.audioDecoder.loadedMetadata?(this.loadedAudioMetadata=!0,this.loadedAllMetadata=this.loadedAudioMetadata&&this.loadedVideoMetadata,finish(!0)):this.demuxer.audioReady?this.demuxer.dequeueAudioPacket(((e,t)=>{this.audioBytes+=e.byteLength,this.audioDecoder.processHeader(e,(e=>{finish(!0)}))})):doProcessData():this.loadedAudioMetadata&&!this.loadedVideoMetadata?this.videoDecoder.loadedMetadata?(this.loadedVideoMetadata=!0,this.loadedAllMetadata=this.loadedAudioMetadata&&this.loadedVideoMetadata,finish(!0)):this.demuxer.frameReady?(this.processing=!0,this.demuxer.dequeueVideoPacket((e=>{this.videoBytes+=e.byteLength,this.videoDecoder.processHeader(e,(()=>{finish(!0)}))}))):doProcessData():this.loadedVideoMetadata&&!this.loadedMetadata&&this.loadedAllMetadata?(this.loadedMetadata=!0,finish(!0)):!this.loadedMetadata||this.hasAudio&&!this.demuxer.audioReady||this.hasVideo&&!this.demuxer.frameReady?doProcessData():finish(!0)}decodeFrame(e){var t=this.flushSafe(e),i=this.frameTimestamp,s=this.keyframeTimestamp;this.demuxer.dequeueVideoPacket((e=>{this.videoBytes+=e.byteLength,this.videoDecoder.processFrame(e,(e=>{var d=this.videoDecoder.frameBuffer;d&&(d.timestamp=i,d.keyframeTimestamp=s),t(e)}))}))}decodeAudio(e){var t=this.flushSafe(e);this.demuxer.dequeueAudioPacket(((e,i)=>{this.audioBytes+=e.byteLength,this.audioDecoder.processAudio(e,(e=>{if(i){var s=this.audioDecoder.audioBuffer,d=[];for(var h of s){var u=Math.round(i*this.audioFormat.rate/1e9);u>0?d.push(h.subarray(0,h.length-Math.min(u,h.length))):d.push(h.subarray(Math.min(Math.abs(u),h.length),h.length))}this.audioDecoder.audioBuffer=d}return t(e)}))}))}discardFrame(e){this.demuxer.dequeueVideoPacket((t=>{this.videoBytes+=t.byteLength,e()}))}discardAudio(e){this.demuxer.dequeueAudioPacket(((t,i)=>{this.audioBytes+=t.byteLength,e()}))}flush(e){this.flushIter++,this.demuxer.flush(e)}sync(){this.videoDecoder&&this.videoDecoder.sync()}recycleFrame(e){this.videoDecoder&&this.videoDecoder.recycleFrame(e)}getKeypointOffset(e,t){this.demuxer.getKeypointOffset(e,t)}seekToKeypoint(e,t){this.demuxer.seekToKeypoint(e,this.flushSafe(t))}loadAudioCodec(e){if(this.demuxer.audioCodec){var t={vorbis:"OGVDecoderAudioVorbisW",opus:"OGVDecoderAudioOpusW"}[this.demuxer.audioCodec];this.processing=!0,d.default.loadClass(t,(t=>{var i={};this.demuxer.audioFormat&&(i.audioFormat=this.demuxer.audioFormat),t(i).then((t=>{this.audioDecoder=t,t.init((()=>{this.loadedAudioMetadata=t.loadedMetadata,this.processing=!1,e()}))}))}),{worker:this.options.worker})}else e()}loadVideoCodec(e){if(this.demuxer.videoCodec){var t=!!this.options.simd,i=!!this.options.threading,s={theora:"OGVDecoderVideoTheoraW",vp8:i?"OGVDecoderVideoVP8MTW":"OGVDecoderVideoVP8W",vp9:i?t?"OGVDecoderVideoVP9SIMDMTW":"OGVDecoderVideoVP9MTW":t?"OGVDecoderVideoVP9SIMDW":"OGVDecoderVideoVP9W",av1:i?t?"OGVDecoderVideoAV1SIMDMTW":"OGVDecoderVideoAV1MTW":t?"OGVDecoderVideoAV1SIMDW":"OGVDecoderVideoAV1W"}[this.demuxer.videoCodec];this.processing=!0,d.default.loadClass(s,(t=>{var s={};this.demuxer.videoFormat&&(s.videoFormat=this.demuxer.videoFormat),i&&delete window.ENVIRONMENT_IS_PTHREAD,t(s).then((t=>{this.videoDecoder=t,t.init((()=>{this.loadedVideoMetadata=t.loadedMetadata,this.processing=!1,e()}))}))}),{worker:this.options.worker&&!this.options.threading})}else e()}};t.default=h},539:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=new class WebAssemblyChecker{constructor(){this.tested=!1,this.testResult=void 0}wasmSupported(){if(!this.tested){try{"object"==typeof WebAssembly?this.testResult=function testSafariWebAssemblyBug(){var e=new Uint8Array([0,97,115,109,1,0,0,0,1,6,1,96,1,127,1,127,3,2,1,0,5,3,1,0,1,7,8,1,4,116,101,115,116,0,0,10,16,1,14,0,32,0,65,1,54,2,0,32,0,40,2,0,11]),t=new WebAssembly.Module(e);return 0!==new WebAssembly.Instance(t,{}).exports.test(4)}():this.testResult=!1}catch(e){console.log("Exception while testing WebAssembly",e),this.testResult=!1}this.tested=!0}return this.testResult}};t.default=i},309:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function extend(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])};t.default=i},431:(e,t,i)=>{"use strict";var s=function(){function defineProperties(e,t){for(var i=0;i{"use strict";var s=function(){function defineProperties(e,t){for(var i=0;i=200&&e.xhr.status<300?(e.length=getXHRLength(e.xhr),e.headers=function getXHRHeaders(e){var t={};return e.getAllResponseHeaders().split(/\r?\n/).forEach((function(e){var i=e.split(/:\s*/,2);i.length>1&&(t[i[0].toLowerCase()]=i[1])})),t}(e.xhr),e.onXHRStart()):(s(),i(new Error("HTTP error "+e.xhr.status)))}},h=function checkError(){s(),i(new Error("network error"))},u=function checkBackendOpen(){s(),t()};s=function oncomplete(){e.xhr.removeEventListener("readystatechange",d),e.xhr.removeEventListener("error",h),e.off("open",u),e._onAbort=null},e.initXHR(),e.xhr.addEventListener("readystatechange",d),e.xhr.addEventListener("error",h),e.on("open",u),e.xhr.send()}))}},{key:"bufferToOffset",value:function bufferToOffset(e){return Promise.reject(new Error("abstract"))}},{key:"abort",value:function abort(){if(this.xhr.abort(),this._onAbort){var e=this._onAbort;this._onAbort=null;var t=new Error("Aborted");t.name="AbortError",e(t)}}},{key:"initXHR",value:function initXHR(){var e=this.url;this.cachever&&(e+="?buggy_cachever="+this.cachever),this.xhr.open("GET",e);var t=null;(this.offset||this.length)&&(t="bytes="+this.offset+"-"),this.length&&(t+=this.offset+this.length-1),null!==t&&this.xhr.setRequestHeader("Range",t)}},{key:"onXHRStart",value:function onXHRStart(){throw new Error("abstract")}}]),Backend}(i(566));e.exports=d},810:(e,t,i)=>{"use strict";var s=function(){function defineProperties(e,t){for(var i=0;i0&&(this.bytesRead+=e.length,this.emit("buffer",e))}},{key:"onXHRLoad",value:function onXHRLoad(){this.onXHRProgress(),d(BinaryStringBackend.prototype.__proto__||Object.getPrototypeOf(BinaryStringBackend.prototype),"onXHRLoad",this).call(this)}}]),BinaryStringBackend}(i(828));h.supported=function(){try{return!!(new XMLHttpRequest).overrideMimeType}catch(e){return!1}},e.exports=h},828:(e,t,i)=>{"use strict";var s=function(){function defineProperties(e,t){for(var i=0;i=e)i();else{var d=null;t._onAbort=function(e){d(),s(e)};var h=function checkBuffer(){t.offset>=e&&!t.eof&&(d(),i())},u=function checkDone(){d(),i()},c=function checkError(){d(),s(new Error("error streaming"))};d=function oncomplete(){t.buffering=!1,t.off("buffer",h),t.off("done",u),t.off("error",c),t._onAbort=null},t.buffering=!0,t.on("buffer",h),t.on("done",u),t.on("error",c)}}))}},{key:"initXHR",value:function initXHR(){d(DownloadBackend.prototype.__proto__||Object.getPrototypeOf(DownloadBackend.prototype),"initXHR",this).call(this)}},{key:"onXHRStart",value:function onXHRStart(){var e=this;this.xhr.addEventListener("progress",(function(){return e.onXHRProgress()})),this.xhr.addEventListener("error",(function(){return e.onXHRError()})),this.xhr.addEventListener("load",(function(){return e.onXHRLoad()})),this.emit("open")}},{key:"onXHRProgress",value:function onXHRProgress(){throw new Error("abstract")}},{key:"onXHRError",value:function onXHRError(){this.emit("error")}},{key:"onXHRLoad",value:function onXHRLoad(){this.eof=!0,this.emit("done")}}]),DownloadBackend}(i(306));e.exports=h},761:(e,t,i)=>{"use strict";var s=i(855),d=i(810),h=i(431);var u=null;e.exports=function instantiate(e){if(!1===e.progressive)return new h(e);if(u||(u=function autoselect(){return s.supported()?s:d.supported()?d:null}()),!u)throw new Error("No supported backend class");return new u(e)}},855:(e,t,i)=>{"use strict";var s=function(){function defineProperties(e,t){for(var i=0;i{"use strict";var t=function(){function defineProperties(e,t){for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:{},t=e.buffer,i=void 0===t?void 0:t,s=e.string,d=void 0===s?void 0:s,h=e.start,u=void 0===h?0:h,c=e.end,l=void 0===c?u+(i?i.byteLength:d?d.length:0):c,f=e.prev,_=void 0===f?null:f,p=e.next,m=void 0===p?null:p,g=e.eof,v=void 0!==g&&g,y=e.empty,b=void 0===y?!(i||d):y,T=e.timestamp,k=void 0===T?Date.now():T;_classCallCheck(this,CacheItem),this.start=u,this.end=l,this.prev=_,this.next=m,this.eof=v,this.empty=b,this.timestamp=k,this.buffer=i,this.string=d,Object.defineProperty(this,"length",{get:function get(){return this.end-this.start}})}return t(CacheItem,[{key:"contains",value:function contains(e){return e>=this.start&&(e{"use strict";var s=function(){function defineProperties(e,t){for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:{},t=e.cacheSize,i=void 0===t?0:t;_classCallCheck(this,CachePool);var s=new d({eof:!0});this.head=s,this.tail=s,this.readOffset=0,this.readCursor=s,this.writeOffset=0,this.writeCursor=s,this.cacheSize=i}return s(CachePool,[{key:"bytesReadable",value:function bytesReadable(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1/0,t=this.readOffset,i=this.readCursor,s=i.last((function(i){return!i.empty&&i.start<=t+e}));return s?Math.min(e,s.end-t):0}},{key:"bytesWritable",value:function bytesWritable(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1/0,t=this.writeOffset,i=this.writeCursor;if(i.eof)return e;var s=i.last((function(i){return i.empty&&i.start<=t+e}));return s?Math.min(e,s.end-t):0}},{key:"seekRead",value:function seekRead(e){var t=this.head.first((function(t){return t.contains(e)}));if(!t)throw new Error("read seek out of range");this.readOffset=e,this.readCursor=t}},{key:"seekWrite",value:function seekWrite(e){var t=this.head.first((function(t){return t.contains(e)}));if(!t)throw new Error("write seek out of range");this.writeOffset=e,this.writeCursor=t}},{key:"readBytes",value:function readBytes(e){for(var t=e.byteLength,i=this.bytesReadable(t),s=this.readOffset,d=s+i,h=s,u=this.readCursor;u&&!u.empty&&!(u.start>=d);u=u.next){var c=Math.min(d,u.end),l=e.subarray(h-s,c-s);u.readBytes(l,h,c),h=c}return this.readOffset=h,this.readCursor=this.readCursor.first((function(e){return e.contains(h)})),i}},{key:"write",value:function write(e){var t=this.bufferItem(e),i=this.writeCursor;if(!i.empty)throw new Error("write cursor not empty");if(!i.contains(t.end)&&i.end!==t.end)throw new Error("write cursor too small");i.startthis.readOffset+this.chunkSize)&&t.push(i));if(e>this.cacheSize){t.sort((function(e,t){return e.timestamp-t.timestamp}));for(var s=0;s{"use strict";e.exports=i(91)},566:e=>{"use strict";var t=function(){function defineProperties(e,t){for(var i=0;i=0&&i.splice(s,1)}},{key:"emit",value:function emit(e,t){(this._e[e]||[]).slice().forEach((function(e){return e(t)}))}}]),TinyEvents}();e.exports=i},936:(e,t,i)=>{"use strict";var s=function(){function defineProperties(e,t){for(var i=0;i=0&&c>=e.length)return void t(null);var l=e._clampToLength(s.writeOffset+s.bytesWritable(d))-s.writeOffset;if(0===l)t(null);else{var f=e._backend=new h({url:e.url,offset:e._cache.writeOffset,length:l,cachever:e._cachever,progressive:e.progressive}),_=null,p=function checkOpen(){f!==e._backend?(_(),i(new Error("invalid state"))):(f.on("buffer",(function(t){f===e._backend&&e._cache.write(t)})),f.on("done",(function(){f===e._backend&&(-1===e.length&&(e.length=e._backend.offset+e._backend.bytesRead),e._backend=null)})),t(f))},m=function checkError(t){f!==e._backend?i(new Error("invalid state")):(e._backend=null,i(t))};_=function oncomplete(){f.off("open",p),f.off("error",m)},f.on("open",p),f.on("error",m),f.on("cachever",(function(){e._cachever++})),f.load()}}}))}},{key:"_readAhead",value:function _readAhead(){var e=this;return new Promise((function(t,i){e._backend||e.eof?t():e._openBackend().then((function(){t()})).catch((function(e){i(e)}))}))}},{key:"seek",value:function seek(e){var t=this;return new Promise((function(i,s){if(!t.loaded||t.buffering||t.seeking)throw new Error("invalid state");if(e!==(0|e)||e<0)throw new Error("invalid input");if(t.length>=0&&e>t.length)throw new Error("seek past end of file");if(!t.seekable)throw new Error("seek on non-seekable stream");t._backend&&t.abort(),t._cache.seekRead(e),t._cache.seekWrite(e),t._readAhead().then(i).catch(s)}))}},{key:"read",value:function read(e){var t=this;return this.buffer(e).then((function(e){return t.readSync(e)}))}},{key:"readSync",value:function readSync(e){var t=this.bytesAvailable(e),i=new Uint8Array(t);if(this.readBytes(i)!==t)throw new Error("failed to read expected data");return i.buffer}},{key:"readBytes",value:function readBytes(e){if(!this.loaded||this.buffering||this.seeking)throw new Error("invalid state");if(!(e instanceof Uint8Array))throw new Error("invalid input");var t=this._cache.readBytes(e);return this._readAhead(),t}},{key:"buffer",value:function buffer(e){var t=this;return new Promise((function(i,s){if(!t.loaded||t.buffering||t.seeking)throw new Error("invalid state");if(e!==(0|e)||e<0)throw new Error("invalid input");var d=t._clampToLength(t.offset+e),h=d-t.offset,u=t.bytesAvailable(h);u>=h?i(u):(t.buffering=!0,t._openBackend().then((function(i){return i?i.bufferToOffset(d).then((function(){return t.buffering=!1,t.buffer(e)})):Promise.resolve(u)})).then((function(e){t.buffering=!1,i(e)})).catch((function(e){"AbortError"!==e.name&&(t.buffering=!1),s(e)})))}))}},{key:"bytesAvailable",value:function bytesAvailable(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1/0;return this._cache.bytesReadable(e)}},{key:"abort",value:function abort(){this.loading&&(this.loading=!1),this.buffering&&(this.buffering=!1),this.seeking&&(this.seeking=!1),this._backend&&(this._backend.abort(),this._backend=null)}},{key:"getBufferedRanges",value:function getBufferedRanges(){return this._cache.ranges()}},{key:"_clampToLength",value:function _clampToLength(e){return this.length<0?e:Math.min(this.length,e)}}]),StreamFile}();e.exports=u},826:e=>{e.exports={vertex:"precision lowp float;\n\nattribute vec2 aPosition;\nattribute vec2 aLumaPosition;\nattribute vec2 aChromaPosition;\nvarying vec2 vLumaPosition;\nvarying vec2 vChromaPosition;\nvoid main() {\n gl_Position = vec4(aPosition, 0, 1);\n vLumaPosition = aLumaPosition;\n vChromaPosition = aChromaPosition;\n}\n",fragment:"// inspired by https://github.com/mbebenita/Broadway/blob/master/Player/canvas.js\n\nprecision lowp float;\n\nuniform sampler2D uTextureY;\nuniform sampler2D uTextureCb;\nuniform sampler2D uTextureCr;\nvarying vec2 vLumaPosition;\nvarying vec2 vChromaPosition;\nvoid main() {\n // Y, Cb, and Cr planes are uploaded as LUMINANCE textures.\n float fY = texture2D(uTextureY, vLumaPosition).x;\n float fCb = texture2D(uTextureCb, vChromaPosition).x;\n float fCr = texture2D(uTextureCr, vChromaPosition).x;\n\n // Premultipy the Y...\n float fYmul = fY * 1.1643828125;\n\n // And convert that to RGB!\n gl_FragColor = vec4(\n fYmul + 1.59602734375 * fCr - 0.87078515625,\n fYmul - 0.39176171875 * fCb - 0.81296875 * fCr + 0.52959375,\n fYmul + 2.017234375 * fCb - 1.081390625,\n 1\n );\n}\n",vertexStripe:"precision lowp float;\n\nattribute vec2 aPosition;\nattribute vec2 aTexturePosition;\nvarying vec2 vTexturePosition;\n\nvoid main() {\n gl_Position = vec4(aPosition, 0, 1);\n vTexturePosition = aTexturePosition;\n}\n",fragmentStripe:"// extra 'stripe' texture fiddling to work around IE 11's poor performance on gl.LUMINANCE and gl.ALPHA textures\n\nprecision lowp float;\n\nuniform sampler2D uStripe;\nuniform sampler2D uTexture;\nvarying vec2 vTexturePosition;\nvoid main() {\n // Y, Cb, and Cr planes are mapped into a pseudo-RGBA texture\n // so we can upload them without expanding the bytes on IE 11\n // which doesn't allow LUMINANCE or ALPHA textures\n // The stripe textures mark which channel to keep for each pixel.\n // Each texture extraction will contain the relevant value in one\n // channel only.\n\n float fLuminance = dot(\n texture2D(uStripe, vTexturePosition),\n texture2D(uTexture, vTexturePosition)\n );\n\n gl_FragColor = vec4(fLuminance, fLuminance, fLuminance, 1);\n}\n"}},487:e=>{!function(){"use strict";function FrameSink(e,t){throw new Error("abstract")}FrameSink.prototype.drawFrame=function(e){throw new Error("abstract")},FrameSink.prototype.clear=function(){throw new Error("abstract")},e.exports=FrameSink}()},926:(e,t,i)=>{!function(){"use strict";var t=i(487),s=i(627);function SoftwareFrameSink(e){var t=this,i=e.getContext("2d"),d=null,h=null,u=null;return t.drawFrame=function drawFrame(t){var c=t.format;e.width===c.displayWidth&&e.height===c.displayHeight||(e.width=c.displayWidth,e.height=c.displayHeight),null!==d&&d.width==c.width&&d.height==c.height||function initImageData(e,t){for(var s=(d=i.createImageData(e,t)).data,h=e*t*4,u=0;u{!function(){"use strict";var t=i(487),s=i(826);function WebGLFrameSink(e){var t,i,d=this,h=WebGLFrameSink.contextForCanvas(e);if(null===h)throw new Error("WebGL unavailable");function compileShader(e,t){var i=h.createShader(e);if(h.shaderSource(i,t),h.compileShader(i),!h.getShaderParameter(i,h.COMPILE_STATUS)){var s=h.getShaderInfoLog(i);throw h.deleteShader(i),new Error("GL shader compilation for "+e+" failed: "+s)}return i}var u,c,l,f,_,p,m,g,v,y,b=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),T={},k={},w={};function createOrReuseTexture(e,t){return T[e]&&!t||(T[e]=h.createTexture()),T[e]}function uploadTexture(e,t,i,s,d){var u=createOrReuseTexture(e,t);if(h.activeTexture(h.TEXTURE0),WebGLFrameSink.stripe){var c=!T[e+"_temp"]||t,l=createOrReuseTexture(e+"_temp",t);h.bindTexture(h.TEXTURE_2D,l),c?(h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h.NEAREST),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,h.NEAREST),h.texImage2D(h.TEXTURE_2D,0,h.RGBA,i/4,s,0,h.RGBA,h.UNSIGNED_BYTE,d)):h.texSubImage2D(h.TEXTURE_2D,0,0,0,i/4,s,h.RGBA,h.UNSIGNED_BYTE,d);var f=T[e+"_stripe"],_=!f||t;_&&(f=createOrReuseTexture(e+"_stripe",t)),h.bindTexture(h.TEXTURE_2D,f),_&&(h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h.NEAREST),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,h.NEAREST),h.texImage2D(h.TEXTURE_2D,0,h.RGBA,i,1,0,h.RGBA,h.UNSIGNED_BYTE,function buildStripe(e){if(w[e])return w[e];for(var t=e,i=new Uint32Array(t),s=0;s{!function(){"use strict";var t=i(877);e.exports={convertYCbCr:function convertYCbCr(e,i){var s=0|e.format.width,d=0|e.format.height,h=0|t(e.format.width/e.format.chromaWidth),u=0|t(e.format.height/e.format.chromaHeight),c=e.y.bytes,l=e.u.bytes,f=e.v.bytes,_=0|e.y.stride,p=0|e.u.stride,m=0|e.v.stride,g=s<<2,v=0,y=0,b=0,T=0,k=0,w=0,P=0,E=0,x=0,A=0,R=0,F=0,O=0,C=0,S=0,B=0,D=0,M=0;if(1==h&&1==u)for(P=0,E=g,M=0,B=0;B>8,i[P+1]=R-O>>8,i[P+2]=R+C>>8,P+=4,R=298*c[y++]|0,i[P]=R+F>>8,i[P+1]=R-O>>8,i[P+2]=R+C>>8,P+=4,R=298*c[b++]|0,i[E]=R+F>>8,i[E+1]=R-O>>8,i[E+2]=R+C>>8,E+=4,R=298*c[b++]|0,i[E]=R+F>>8,i[E+1]=R-O>>8,i[E+2]=R+C>>8,E+=4;P+=g,E+=g,M++}else for(w=0,B=0;B>u)*p|0,k=M*m|0,S=0;S>h)],F=(409*(A=0|f[k+D])|0)-57088|0,O=(100*x|0)+(208*A|0)-34816|0,C=(516*x|0)-70912|0,R=298*c[v++]|0,i[w]=R+F>>8,i[w+1]=R-O>>8,i[w+2]=R+C>>8,w+=4}}}()},877:e=>{!function(){"use strict";e.exports=function depower(e){for(var t=0,i=e>>1;0!=i;)i>>=1,t++;if(e!==1<{!function(){"use strict";var t=i(487),s=i(926),d=i(895),h={FrameSink:t,SoftwareFrameSink:s,WebGLFrameSink:d,attach:function(e,t){return("webGL"in(t=t||{})?t.webGL:d.isAvailable())?new d(e,t):new s(e,t)}};e.exports=h}()}},t={};function __webpack_require__(i){var s=t[i];if(void 0!==s)return s.exports;var d=t[i]={exports:{}};return e[i](d,d.exports,__webpack_require__),d.exports}var i={};return(()=>{"use strict";var e=i,t=__webpack_require__(318);Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"OGVCompat",{enumerable:!0,get:function get(){return s.default}}),Object.defineProperty(e,"OGVLoader",{enumerable:!0,get:function get(){return d.default}}),Object.defineProperty(e,"OGVMediaError",{enumerable:!0,get:function get(){return h.default}}),Object.defineProperty(e,"OGVMediaType",{enumerable:!0,get:function get(){return u.default}}),Object.defineProperty(e,"OGVPlayer",{enumerable:!0,get:function get(){return c.default}}),Object.defineProperty(e,"OGVTimeRanges",{enumerable:!0,get:function get(){return l.default}}),e.OGVVersion=void 0;var s=t(__webpack_require__(523)),d=t(__webpack_require__(964)),h=t(__webpack_require__(759)),u=t(__webpack_require__(278)),c=t(__webpack_require__(869)),l=t(__webpack_require__(168)),f="1.8.6-20220111172545-1f60d9d";e.OGVVersion=f,"object"==typeof window&&(window.OGVCompat=s.default,window.OGVLoader=d.default,window.OGVMediaError=h.default,window.OGVMediaType=u.default,window.OGVTimeRanges=l.default,window.OGVPlayer=c.default,window.OGVVersion=f)})(),i})()}));
\ No newline at end of file
diff --git a/ogvjs-1.8.6/ogv-support.js b/ogvjs-1.8.6/ogv-support.js
new file mode 100644
index 000000000..cc966c95c
--- /dev/null
+++ b/ogvjs-1.8.6/ogv-support.js
@@ -0,0 +1 @@
+(()=>{var e={575:e=>{e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},913:e=>{function t(e,t){for(var o=0;o{e.exports=function(e){return e&&e.__esModule?e:{default:e}},e.exports.__esModule=!0,e.exports.default=e.exports},8:e=>{function t(o){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(o)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},523:(e,t,o)=>{"use strict";var r=o(318);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=r(o(575)),u=r(o(913)),s=new(function(){function e(){(0,n.default)(this,e)}return(0,u.default)(e,[{key:"hasTypedArrays",value:function(){return!!window.Uint32Array}},{key:"hasWebAssembly",value:function(){return!!window.WebAssembly}},{key:"hasWebAudio",value:function(){return!(!window.AudioContext&&!window.webkitAudioContext)}},{key:"hasFlash",value:function(){return!1}},{key:"hasAudio",value:function(){return this.hasWebAudio()}},{key:"isBlacklisted",value:function(e){return!1}},{key:"isSlow",value:function(){return!1}},{key:"isTooSlow",value:function(){return!1}},{key:"supported",value:function(e){return"OGVDecoder"===e?this.hasWebAssembly():"OGVPlayer"===e&&this.supported("OGVDecoder")&&this.hasAudio()}}]),e}());t.default=s}},t={};function o(r){var n=t[r];if(void 0!==n)return n.exports;var u=t[r]={exports:{}};return e[r](u,u.exports,o),u.exports}(()=>{"use strict";var e=o(318),t=e(o(8)),r=e(o(523));"object"===("undefined"==typeof window?"undefined":(0,t.default)(window))&&(window.OGVCompat=r.default,window.OGVVersion="1.8.6-20220111172545-1f60d9d")})()})();
\ No newline at end of file
diff --git a/ogvjs-1.8.6/ogv-version.js b/ogvjs-1.8.6/ogv-version.js
new file mode 100644
index 000000000..828291abf
--- /dev/null
+++ b/ogvjs-1.8.6/ogv-version.js
@@ -0,0 +1 @@
+(()=>{var e={318:e=>{e.exports=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}},e.exports.__esModule=!0,e.exports.default=e.exports},8:e=>{function _typeof(o){return e.exports=_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,_typeof(o)}e.exports=_typeof,e.exports.__esModule=!0,e.exports.default=e.exports}},o={};function __webpack_require__(t){var r=o[t];if(void 0!==r)return r.exports;var p=o[t]={exports:{}};return e[t](p,p.exports,__webpack_require__),p.exports}(()=>{"use strict";var e=__webpack_require__(318)(__webpack_require__(8)),o="1.8.6-20220111172545-1f60d9d";"object"===("undefined"==typeof window?"undefined":(0,e.default)(window))&&(window.OGVVersion=o)})()})();
\ No newline at end of file
diff --git a/ogvjs-1.8.6/ogv-worker-audio.js b/ogvjs-1.8.6/ogv-worker-audio.js
new file mode 100644
index 000000000..42bd2b9ff
--- /dev/null
+++ b/ogvjs-1.8.6/ogv-worker-audio.js
@@ -0,0 +1 @@
+(()=>{var e={506:e=>{e.exports=function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.__esModule=!0,e.exports.default=e.exports},575:e=>{e.exports=function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},913:e=>{function _defineProperties(e,t){for(var r=0;r{function _getPrototypeOf(t){return e.exports=_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,_getPrototypeOf(t)}e.exports=_getPrototypeOf,e.exports.__esModule=!0,e.exports.default=e.exports},205:(e,t,r)=>{var o=r(489);e.exports=function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&o(e,t)},e.exports.__esModule=!0,e.exports.default=e.exports},318:e=>{e.exports=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}},e.exports.__esModule=!0,e.exports.default=e.exports},585:(e,t,r)=>{var o=r(8).default,s=r(506);e.exports=function _possibleConstructorReturn(e,t){if(t&&("object"===o(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return s(e)},e.exports.__esModule=!0,e.exports.default=e.exports},489:e=>{function _setPrototypeOf(t,r){return e.exports=_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,_setPrototypeOf(t,r)}e.exports=_setPrototypeOf,e.exports.__esModule=!0,e.exports.default=e.exports},8:e=>{function _typeof(t){return e.exports=_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,_typeof(t)}e.exports=_typeof,e.exports.__esModule=!0,e.exports.default=e.exports},445:(e,t,r)=>{"use strict";var o=r(318);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=o(r(575)),n=o(r(913)),a=o(r(539)),i="1.8.6-20220111172545-1f60d9d",u={OGVDemuxerOggW:"ogv-demuxer-ogg-wasm.js",OGVDemuxerWebMW:"ogv-demuxer-webm-wasm.js",OGVDecoderAudioOpusW:"ogv-decoder-audio-opus-wasm.js",OGVDecoderAudioVorbisW:"ogv-decoder-audio-vorbis-wasm.js",OGVDecoderVideoTheoraW:"ogv-decoder-video-theora-wasm.js",OGVDecoderVideoVP8W:"ogv-decoder-video-vp8-wasm.js",OGVDecoderVideoVP8MTW:"ogv-decoder-video-vp8-mt-wasm.js",OGVDecoderVideoVP9W:"ogv-decoder-video-vp9-wasm.js",OGVDecoderVideoVP9SIMDW:"ogv-decoder-video-vp9-simd-wasm.js",OGVDecoderVideoVP9MTW:"ogv-decoder-video-vp9-mt-wasm.js",OGVDecoderVideoVP9SIMDMTW:"ogv-decoder-video-vp9-simd-mt-wasm.js",OGVDecoderVideoAV1W:"ogv-decoder-video-av1-wasm.js",OGVDecoderVideoAV1SIMDW:"ogv-decoder-video-av1-simd-wasm.js",OGVDecoderVideoAV1MTW:"ogv-decoder-video-av1-mt-wasm.js",OGVDecoderVideoAV1SIMDMTW:"ogv-decoder-video-av1-simd-mt-wasm.js"},d=function(){function OGVLoaderBase(){(0,s.default)(this,OGVLoaderBase),this.base=this.defaultBase()}return(0,n.default)(OGVLoaderBase,[{key:"defaultBase",value:function defaultBase(){}},{key:"wasmSupported",value:function wasmSupported(){return a.default.wasmSupported()}},{key:"scriptForClass",value:function scriptForClass(e){return u[e]}},{key:"urlForClass",value:function urlForClass(e){var t=this.scriptForClass(e);if(t)return this.urlForScript(t);throw new Error("asked for URL for unknown class "+e)}},{key:"urlForScript",value:function urlForScript(e){if(e){var t=this.base;return void 0===t?t="":t+="/",t+e+"?version="+encodeURIComponent(i)}throw new Error("asked for URL for unknown script "+e)}},{key:"loadClass",value:function loadClass(e,t,r){var o=this;r=r||{};var s=this.getGlobal(),n=this.urlForClass(e),a=function classWrapper(t){return(t=t||{}).locateFile=function(e){return"data:"===e.slice(0,5)?e:o.urlForScript(e)},t.mainScriptUrlOrBlob=o.scriptForClass(e)+"?version="+encodeURIComponent(i),s[e](t)};"function"==typeof s[e]?t(a):this.loadScript(n,(function(){t(a)}))}}]),OGVLoaderBase}();t.default=d},713:(e,t,r)=>{"use strict";var o=r(318);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=o(r(575)),n=o(r(913)),a=o(r(205)),i=o(r(585)),u=o(r(754));function _createSuper(e){var t=function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function _createSuperInternal(){var r,o=(0,u.default)(e);if(t){var s=(0,u.default)(this).constructor;r=Reflect.construct(o,arguments,s)}else r=o.apply(this,arguments);return(0,i.default)(this,r)}}var d=new(function(e){(0,a.default)(OGVLoaderWorker,e);var t=_createSuper(OGVLoaderWorker);function OGVLoaderWorker(){return(0,s.default)(this,OGVLoaderWorker),t.apply(this,arguments)}return(0,n.default)(OGVLoaderWorker,[{key:"loadScript",value:function loadScript(e,t){importScripts(e),t()}},{key:"getGlobal",value:function getGlobal(){return self}}]),OGVLoaderWorker}(o(r(445)).default));t.default=d},607:(e,t,r)=>{"use strict";var o=r(318);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=new(o(r(172)).default)(["loadedMetadata","audioFormat","audioBuffer","cpuTime"],{init:function init(e,t){this.target.init(t)},processHeader:function processHeader(e,t){this.target.processHeader(e[0],(function(e){t([e])}))},processAudio:function processAudio(e,t){this.target.processAudio(e[0],(function(e){t([e])}))}});t.default=s},172:(e,t,r)=>{"use strict";var o=r(318);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=o(r(8)),n=o(r(575)),a=o(r(913)),i=o(r(713));r.g.OGVLoader=i.default;var u=function(){function OGVWorkerSupport(e,t){var r=this;(0,n.default)(this,OGVWorkerSupport),this.propList=e,this.handlers=t,this.transferables=function(){var e=new ArrayBuffer(1024),t=new Uint8Array(e);try{return postMessage({action:"transferTest",bytes:t},[e]),!e.byteLength}catch(e){return!1}}(),this.target=null,this.sentProps={},this.pendingEvents=[],this.handlers.construct=function(e,t){var o=e[0],s=e[1];i.default.loadClass(o,(function(e){e(s).then((function(e){for(r.target=e,t();r.pendingEvents.length;)r.handleEvent(r.pendingEvents.shift())}))}))},addEventListener("message",(function(e){r.workerOnMessage(e)}))}return(0,a.default)(OGVWorkerSupport,[{key:"handleEvent",value:function handleEvent(e){var t=this;this.handlers[e.action].call(this,e.args,(function(r){r=r||[];var o={},s=[];t.propList.forEach((function(e){var r=t.target[e];if(t.sentProps[e]!==r)if(t.sentProps[e]=r,"duration"==e&&isNaN(r)&&isNaN(t.sentProps[e]));else if("audioBuffer"==e){if(o[e]=r,r)for(var n=0;n{"use strict";var o=r(318);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=o(r(8)),n=o(r(575)),a=o(r(913));var i=new(function(){function WebAssemblyChecker(){(0,n.default)(this,WebAssemblyChecker),this.tested=!1,this.testResult=void 0}return(0,a.default)(WebAssemblyChecker,[{key:"wasmSupported",value:function wasmSupported(){if(!this.tested){try{"object"===("undefined"==typeof WebAssembly?"undefined":(0,s.default)(WebAssembly))?this.testResult=function testSafariWebAssemblyBug(){var e=new Uint8Array([0,97,115,109,1,0,0,0,1,6,1,96,1,127,1,127,3,2,1,0,5,3,1,0,1,7,8,1,4,116,101,115,116,0,0,10,16,1,14,0,32,0,65,1,54,2,0,32,0,40,2,0,11]),t=new WebAssembly.Module(e);return 0!==new WebAssembly.Instance(t,{}).exports.test(4)}():this.testResult=!1}catch(e){console.log("Exception while testing WebAssembly",e),this.testResult=!1}this.tested=!0}return this.testResult}}]),WebAssemblyChecker}());t.default=i}},t={};function __webpack_require__(r){var o=t[r];if(void 0!==o)return o.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,__webpack_require__),s.exports}__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),(()=>{"use strict";__webpack_require__(318)(__webpack_require__(607))})()})();
\ No newline at end of file
diff --git a/ogvjs-1.8.6/ogv-worker-video.js b/ogvjs-1.8.6/ogv-worker-video.js
new file mode 100644
index 000000000..b4f64bbc0
--- /dev/null
+++ b/ogvjs-1.8.6/ogv-worker-video.js
@@ -0,0 +1 @@
+(()=>{var e={506:e=>{e.exports=function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.__esModule=!0,e.exports.default=e.exports},575:e=>{e.exports=function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},913:e=>{function _defineProperties(e,t){for(var r=0;r{function _getPrototypeOf(t){return e.exports=_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,_getPrototypeOf(t)}e.exports=_getPrototypeOf,e.exports.__esModule=!0,e.exports.default=e.exports},205:(e,t,r)=>{var o=r(489);e.exports=function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&o(e,t)},e.exports.__esModule=!0,e.exports.default=e.exports},318:e=>{e.exports=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}},e.exports.__esModule=!0,e.exports.default=e.exports},585:(e,t,r)=>{var o=r(8).default,s=r(506);e.exports=function _possibleConstructorReturn(e,t){if(t&&("object"===o(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return s(e)},e.exports.__esModule=!0,e.exports.default=e.exports},489:e=>{function _setPrototypeOf(t,r){return e.exports=_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,_setPrototypeOf(t,r)}e.exports=_setPrototypeOf,e.exports.__esModule=!0,e.exports.default=e.exports},8:e=>{function _typeof(t){return e.exports=_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,_typeof(t)}e.exports=_typeof,e.exports.__esModule=!0,e.exports.default=e.exports},445:(e,t,r)=>{"use strict";var o=r(318);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=o(r(575)),n=o(r(913)),a=o(r(539)),i="1.8.6-20220111172545-1f60d9d",u={OGVDemuxerOggW:"ogv-demuxer-ogg-wasm.js",OGVDemuxerWebMW:"ogv-demuxer-webm-wasm.js",OGVDecoderAudioOpusW:"ogv-decoder-audio-opus-wasm.js",OGVDecoderAudioVorbisW:"ogv-decoder-audio-vorbis-wasm.js",OGVDecoderVideoTheoraW:"ogv-decoder-video-theora-wasm.js",OGVDecoderVideoVP8W:"ogv-decoder-video-vp8-wasm.js",OGVDecoderVideoVP8MTW:"ogv-decoder-video-vp8-mt-wasm.js",OGVDecoderVideoVP9W:"ogv-decoder-video-vp9-wasm.js",OGVDecoderVideoVP9SIMDW:"ogv-decoder-video-vp9-simd-wasm.js",OGVDecoderVideoVP9MTW:"ogv-decoder-video-vp9-mt-wasm.js",OGVDecoderVideoVP9SIMDMTW:"ogv-decoder-video-vp9-simd-mt-wasm.js",OGVDecoderVideoAV1W:"ogv-decoder-video-av1-wasm.js",OGVDecoderVideoAV1SIMDW:"ogv-decoder-video-av1-simd-wasm.js",OGVDecoderVideoAV1MTW:"ogv-decoder-video-av1-mt-wasm.js",OGVDecoderVideoAV1SIMDMTW:"ogv-decoder-video-av1-simd-mt-wasm.js"},c=function(){function OGVLoaderBase(){(0,s.default)(this,OGVLoaderBase),this.base=this.defaultBase()}return(0,n.default)(OGVLoaderBase,[{key:"defaultBase",value:function defaultBase(){}},{key:"wasmSupported",value:function wasmSupported(){return a.default.wasmSupported()}},{key:"scriptForClass",value:function scriptForClass(e){return u[e]}},{key:"urlForClass",value:function urlForClass(e){var t=this.scriptForClass(e);if(t)return this.urlForScript(t);throw new Error("asked for URL for unknown class "+e)}},{key:"urlForScript",value:function urlForScript(e){if(e){var t=this.base;return void 0===t?t="":t+="/",t+e+"?version="+encodeURIComponent(i)}throw new Error("asked for URL for unknown script "+e)}},{key:"loadClass",value:function loadClass(e,t,r){var o=this;r=r||{};var s=this.getGlobal(),n=this.urlForClass(e),a=function classWrapper(t){return(t=t||{}).locateFile=function(e){return"data:"===e.slice(0,5)?e:o.urlForScript(e)},t.mainScriptUrlOrBlob=o.scriptForClass(e)+"?version="+encodeURIComponent(i),s[e](t)};"function"==typeof s[e]?t(a):this.loadScript(n,(function(){t(a)}))}}]),OGVLoaderBase}();t.default=c},713:(e,t,r)=>{"use strict";var o=r(318);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=o(r(575)),n=o(r(913)),a=o(r(205)),i=o(r(585)),u=o(r(754));function _createSuper(e){var t=function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function _createSuperInternal(){var r,o=(0,u.default)(e);if(t){var s=(0,u.default)(this).constructor;r=Reflect.construct(o,arguments,s)}else r=o.apply(this,arguments);return(0,i.default)(this,r)}}var c=new(function(e){(0,a.default)(OGVLoaderWorker,e);var t=_createSuper(OGVLoaderWorker);function OGVLoaderWorker(){return(0,s.default)(this,OGVLoaderWorker),t.apply(this,arguments)}return(0,n.default)(OGVLoaderWorker,[{key:"loadScript",value:function loadScript(e,t){importScripts(e),t()}},{key:"getGlobal",value:function getGlobal(){return self}}]),OGVLoaderWorker}(o(r(445)).default));t.default=c},172:(e,t,r)=>{"use strict";var o=r(318);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=o(r(8)),n=o(r(575)),a=o(r(913)),i=o(r(713));r.g.OGVLoader=i.default;var u=function(){function OGVWorkerSupport(e,t){var r=this;(0,n.default)(this,OGVWorkerSupport),this.propList=e,this.handlers=t,this.transferables=function(){var e=new ArrayBuffer(1024),t=new Uint8Array(e);try{return postMessage({action:"transferTest",bytes:t},[e]),!e.byteLength}catch(e){return!1}}(),this.target=null,this.sentProps={},this.pendingEvents=[],this.handlers.construct=function(e,t){var o=e[0],s=e[1];i.default.loadClass(o,(function(e){e(s).then((function(e){for(r.target=e,t();r.pendingEvents.length;)r.handleEvent(r.pendingEvents.shift())}))}))},addEventListener("message",(function(e){r.workerOnMessage(e)}))}return(0,a.default)(OGVWorkerSupport,[{key:"handleEvent",value:function handleEvent(e){var t=this;this.handlers[e.action].call(this,e.args,(function(r){r=r||[];var o={},s=[];t.propList.forEach((function(e){var r=t.target[e];if(t.sentProps[e]!==r)if(t.sentProps[e]=r,"duration"==e&&isNaN(r)&&isNaN(t.sentProps[e]));else if("audioBuffer"==e){if(o[e]=r,r)for(var n=0;n{"use strict";var o=r(318);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=new(o(r(172)).default)(["loadedMetadata","videoFormat","frameBuffer","cpuTime"],{init:function init(e,t){this.target.init(t)},processHeader:function processHeader(e,t){this.target.processHeader(e[0],(function(e){t([e])}))},processFrame:function processFrame(e,t){this.target.processFrame(e[0],(function(e){t([e])}))},sync:function sync(e,t){this.target.sync(),t()},recycleFrame:function recycleFrame(e,t){this.target.recycleFrame(e[0]),t()}});t.default=s},539:(e,t,r)=>{"use strict";var o=r(318);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=o(r(8)),n=o(r(575)),a=o(r(913));var i=new(function(){function WebAssemblyChecker(){(0,n.default)(this,WebAssemblyChecker),this.tested=!1,this.testResult=void 0}return(0,a.default)(WebAssemblyChecker,[{key:"wasmSupported",value:function wasmSupported(){if(!this.tested){try{"object"===("undefined"==typeof WebAssembly?"undefined":(0,s.default)(WebAssembly))?this.testResult=function testSafariWebAssemblyBug(){var e=new Uint8Array([0,97,115,109,1,0,0,0,1,6,1,96,1,127,1,127,3,2,1,0,5,3,1,0,1,7,8,1,4,116,101,115,116,0,0,10,16,1,14,0,32,0,65,1,54,2,0,32,0,40,2,0,11]),t=new WebAssembly.Module(e);return 0!==new WebAssembly.Instance(t,{}).exports.test(4)}():this.testResult=!1}catch(e){console.log("Exception while testing WebAssembly",e),this.testResult=!1}this.tested=!0}return this.testResult}}]),WebAssemblyChecker}());t.default=i}},t={};function __webpack_require__(r){var o=t[r];if(void 0!==o)return o.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,__webpack_require__),s.exports}__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),(()=>{"use strict";__webpack_require__(318)(__webpack_require__(443))})()})();
\ No newline at end of file
diff --git a/ogvjs-1.8.6/ogv.js b/ogvjs-1.8.6/ogv.js
new file mode 100644
index 000000000..35b3ea040
--- /dev/null
+++ b/ogvjs-1.8.6/ogv.js
@@ -0,0 +1,2 @@
+/*! For license information please see ogv.js.LICENSE.txt */
+!function webpackUniversalModuleDefinition(t,i){"object"==typeof exports&&"object"==typeof module?module.exports=i():"function"==typeof define&&define.amd?define([],i):"object"==typeof exports?exports.ogvjs=i():t.ogvjs=i()}(globalThis,(function(){return(()=>{var t={506:t=>{t.exports=function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t},t.exports.__esModule=!0,t.exports.default=t.exports},575:t=>{t.exports=function _classCallCheck(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")},t.exports.__esModule=!0,t.exports.default=t.exports},913:t=>{function _defineProperties(t,i){for(var u=0;u{var d=u(331);function _get(){return"undefined"!=typeof Reflect&&Reflect.get?(t.exports=_get=Reflect.get,t.exports.__esModule=!0,t.exports.default=t.exports):(t.exports=_get=function _get(t,i,u){var c=d(t,i);if(c){var l=Object.getOwnPropertyDescriptor(c,i);return l.get?l.get.call(arguments.length<3?t:u):l.value}},t.exports.__esModule=!0,t.exports.default=t.exports),_get.apply(this,arguments)}t.exports=_get,t.exports.__esModule=!0,t.exports.default=t.exports},754:t=>{function _getPrototypeOf(i){return t.exports=_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(t){return t.__proto__||Object.getPrototypeOf(t)},t.exports.__esModule=!0,t.exports.default=t.exports,_getPrototypeOf(i)}t.exports=_getPrototypeOf,t.exports.__esModule=!0,t.exports.default=t.exports},205:(t,i,u)=>{var d=u(489);t.exports=function _inherits(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(i&&i.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),i&&d(t,i)},t.exports.__esModule=!0,t.exports.default=t.exports},318:t=>{t.exports=function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}},t.exports.__esModule=!0,t.exports.default=t.exports},585:(t,i,u)=>{var d=u(8).default,c=u(506);t.exports=function _possibleConstructorReturn(t,i){if(i&&("object"===d(i)||"function"==typeof i))return i;if(void 0!==i)throw new TypeError("Derived constructors may only return object or undefined");return c(t)},t.exports.__esModule=!0,t.exports.default=t.exports},489:t=>{function _setPrototypeOf(i,u){return t.exports=_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(t,i){return t.__proto__=i,t},t.exports.__esModule=!0,t.exports.default=t.exports,_setPrototypeOf(i,u)}t.exports=_setPrototypeOf,t.exports.__esModule=!0,t.exports.default=t.exports},331:(t,i,u)=>{var d=u(754);t.exports=function _superPropBase(t,i){for(;!Object.prototype.hasOwnProperty.call(t,i)&&null!==(t=d(t)););return t},t.exports.__esModule=!0,t.exports.default=t.exports},8:t=>{function _typeof(i){return t.exports=_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,_typeof(i)}t.exports=_typeof,t.exports.__esModule=!0,t.exports.default=t.exports},848:t=>{window,t.exports=function(t){var i={};function r(u){if(i[u])return i[u].exports;var d=i[u]={i:u,l:!1,exports:{}};return t[u].call(d.exports,d,d.exports,r),d.l=!0,d.exports}return r.m=t,r.c=i,r.d=function(t,i,u){r.o(t,i)||Object.defineProperty(t,i,{enumerable:!0,get:u})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,i){if(1&i&&(t=r(t)),8&i)return t;if(4&i&&"object"==typeof t&&t&&t.__esModule)return t;var u=Object.create(null);if(r.r(u),Object.defineProperty(u,"default",{enumerable:!0,value:t}),2&i&&"string"!=typeof t)for(var d in t)r.d(u,d,function(i){return t[i]}.bind(null,d));return u},r.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(i,"a",i),i},r.o=function(t,i){return Object.prototype.hasOwnProperty.call(t,i)},r.p="",r(r.s=1)}([function(t,i){function r(t,i){if(t<1||t!==Math.round(t))throw"Invalid channel count for BufferQueue";this.channels=t,this.bufferSize=i,this.flush()}r.prototype.flush=function(){this._buffers=[],this._pendingBuffer=this.createBuffer(this.bufferSize),this._pendingPos=0},r.prototype.sampleCount=function(){var t=0;return this._buffers.forEach((function(i){t+=i[0].length})),t},r.prototype.createBuffer=function(t){for(var i=[],u=0;u=d)return t;for(var l=[],h=0;h0?c[c.length+i]:t[0]:t[i]},h=0;hu&&(y=Math.SQRT1_2);for(var b=0;b=u&&(T=0);var k=t[T],P=new Float32Array(g);l(k,P,this._resampleLastSampleData?this._resampleLastSampleData[T]:void 0,y),h.push(P)}return this._resampleFractional=v,this._resampleLastSampleData=t,h},n.prototype.bufferData=function(t){if(!this._backend)throw"Invalid state: AudioFeeder cannot bufferData before init";var i=this._resample(t);i=this._tempoChanger.process(i),this._backend.appendBuffer(i)},n.prototype.getPlaybackState=function(){if(this._backend){var t=this._backend.getPlaybackState();return t.outputPlaybackPosition=t.playbackPosition,t.playbackPosition=this._tempoChanger.mapOutputToInputTime(t.outputPlaybackPosition),t}throw"Invalid state: AudioFeeder cannot getPlaybackState before init"},n.prototype.waitUntilReady=function(t){if(!this._backend)throw"Invalid state: AudioFeeder cannot waitUntilReady before init";this._backend.waitUntilReady(t)},n.prototype.start=function(){if(!this._backend)throw"Invalid state: AudioFeeder cannot start before init";this._backend.start()},n.prototype.stop=function(){if(!this._backend)throw"Invalid state: AudioFeeder cannot stop before init";this._backend.stop()},n.prototype.flush=function(){if(this._resampleFractional=0,this._resampleLastSampleData=void 0,!this._backend)throw"Invalid state: AudioFeeder cannot flush before init";this._tempoChanger.flush(this.durationBuffered),this._backend.flush()},n.prototype.close=function(){this._backend&&(this._backend.close(),this._backend=null)},n.prototype.onstarved=null,n.prototype.onbufferlow=null,n.isSupported=function(){return!!Float32Array&&i.isSupported()},n.initSharedAudioContext=function(){return i.isSupported()?i.initSharedAudioContext():null},t.exports=n}()},function(t,i,u){!function(){var i=window.AudioContext||window.webkitAudioContext,d=u(0),c=u(3);function o(t,i,u){var c=u.audioContext||o.initSharedAudioContext();if(this._context=c,this.output=u.output||c.destination,this.rate=c.sampleRate,this.channels=2,u.bufferSize&&(this.bufferSize=0|u.bufferSize),this.bufferThreshold=2*this.bufferSize,this._bufferQueue=new d(this.channels,this.bufferSize),this._playbackTimeAtBufferTail=c.currentTime,this._queuedTime=0,this._delayedTime=0,this._dropped=0,this._liveBuffer=this._bufferQueue.createBuffer(this.bufferSize),c.createScriptProcessor)this._node=c.createScriptProcessor(this.bufferSize,0,this.channels);else{if(!c.createJavaScriptNode)throw new Error("Bad version of web audio API?");this._node=c.createJavaScriptNode(this.bufferSize,0,this.channels)}}o.prototype.bufferSize=4096,o.prototype.bufferThreshold=8192,o.prototype._volume=1,Object.defineProperty(o.prototype,"volume",{get:function(){return this._volume},set:function(t){this._volume=+t}}),o.prototype._muted=!1,Object.defineProperty(o.prototype,"muted",{get:function(){return this._muted},set:function(t){this._muted=!!t}}),o.prototype._audioProcess=function(t){var i,u,d,l,h;h="number"==typeof t.playbackTime?t.playbackTime:this._context.currentTime+this.bufferSize/this.rate;var _=this._playbackTimeAtBufferTail;if(_0){var i=Math.round(t*this.rate),u=this._liveBuffer?this._liveBuffer[0].length:0;i>u?(this._bufferQueue.prependBuffer(this._liveBuffer),this._bufferQueue.prependBuffer(this._bufferQueue.createBuffer(i-u))):this._bufferQueue.prependBuffer(this._bufferQueue.trimBuffer(this._liveBuffer,u-i,i)),this._playbackTimeAtBufferTail-=t}this._node.onaudioprocess=null,this._node.disconnect()}},o.prototype.flush=function(){this._bufferQueue.flush()},o.prototype.close=function(){this.stop(),this._context=null},o.prototype.onstarved=null,o.prototype.onbufferlow=null,o.isSupported=function(){return!!i},o.sharedAudioContext=null,o.initSharedAudioContext=function(){if(!o.sharedAudioContext&&o.isSupported()){var t,u=new i;if(u.createScriptProcessor)t=u.createScriptProcessor(1024,0,2);else{if(!u.createJavaScriptNode)throw new Error("Bad version of web audio API?");t=u.createJavaScriptNode(1024,0,2)}t.connect(u.destination),t.disconnect(),o.sharedAudioContext=u}return o.sharedAudioContext},t.exports=o}()},function(t,i){t.exports=function(){if(void 0!==window.setImmediate)return window.setImmediate;if(window&&window.postMessage){var t=[];return window.addEventListener("message",(function(i){if(i.source===window){var u=i.data;if("object"==typeof u&&u.nextTickBrowserPingMessage){var d=t.pop();d&&d()}}})),function(i){t.push(i),window.postMessage({nextTickBrowserPingMessage:!0},document.location.toString())}}return function(t){setTimeout(t,0)}}()},function(t,i,u){var d;window,d=function(){return function(t){var i={};function r(u){if(i[u])return i[u].exports;var d=i[u]={i:u,l:!1,exports:{}};return t[u].call(d.exports,d,d.exports,r),d.l=!0,d.exports}return r.m=t,r.c=i,r.d=function(t,i,u){r.o(t,i)||Object.defineProperty(t,i,{enumerable:!0,get:u})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,i){if(1&i&&(t=r(t)),8&i)return t;if(4&i&&"object"==typeof t&&t&&t.__esModule)return t;var u=Object.create(null);if(r.r(u),Object.defineProperty(u,"default",{enumerable:!0,value:t}),2&i&&"string"!=typeof t)for(var d in t)r.d(u,d,function(i){return t[i]}.bind(null,d));return u},r.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(i,"a",i),i},r.o=function(t,i){return Object.prototype.hasOwnProperty.call(t,i)},r.p="",r(r.s=1)}([function(t,i){var u={float_array:function(t){return new Float32Array(t)},blit:function(t,i,u,d,c){u.set(t.subarray(i,i+c),d)}};t.exports=u},function(t,i,u){var d,c;d=u(0),c=u(2),t.exports=function(t){var i=(t=t||{}).sampleRate||44100,u=t.wsizeLog||11,l=t.tempo||1,h=(t.numChannels,Math.pow(2,50/1200)-1),_=1<>1),w=d.float_array(P),E=d.float_array(P),x=d.float_array(P),A=d.float_array(P),R=d.float_array(P),O=d.float_array(P),S=1+(P>>1),C=[0,0],B=[],D=[],M=[],V=[];for(k=0;k<2;k++)B.push(d.float_array(S)),D.push(d.float_array(S)),M.push(d.float_array(S)),V.push(d.float_array(P));var I=d.float_array(S),L=d.float_array(S),j=0,W=0,X=[{in_time:0,out_time:0,tempo:l}],N=0,H=0,z=1,Y=0,Q=0,K=0,$=0,Z={mapOutputToInputTime:function(t){for(var i=X.length-1;t0;)i--;var u=X[i];return u.in_time+u.tempo*(t-u.out_time)},flush:function(t){Y=0,C=[0,0],H=0,$=0,K=0;for(var i=0;i<2;i++)for(var u=0;u=0;)X.pop(),d--;X.push({in_time:j,out_time:W,tempo:l})}},getTempo:function(){return l},setTempo:function(t){y=b=m,t>=1?b=Math.round(y/t):y=Math.round(b*t),Q=(1/t-1*b/y)*y,z=function(t,i){for(var u=t.length/i|0,d=0,c=0;cu&&(u=t[d]);var c=1e-8*u,l=1,_=1;for(i[0]=1,d=2;dc&&t[d]>t[d-1]&&t[d]>=t[d+1]){var m=d+(t[d-1]-t[d+1])/(2*(t[d-1]-2*t[d]+t[d+1]));m-i[l-1]>p?(i[l++]=m,_=d):t[d]>t[_]&&(i[l-1]=m,_=d)}}return l}(k,w),x=D[p],A=M[p];if(0!=t&&0!=E){var R=0;for(K=0;Ky[R]&&R!=v;)++R;var O=R;R>0&&$-y[R-1].1*k[Math.round($)]){var j=J(i,u,$),W=b[O]+T[O]+U(j,$,b[O],y[O],l)-j;x[K]=j,A[K]=W,I[K]=Math.cos(W),L[K]=Math.sin(W)}else x[K]=J(i,u,$),A[K]=0,I[K]=1,L[K]=0}w[E]=2*_;var X=w[O=0],N=w[O+1],H=I[O],z=L[O];for(P=1;P=X&&P-X>N-P&&(X=w[++O],N=w[O+1],H=I[O],z=L[O]);var Y=i[P]*H-u[P]*z,Q=i[P]*z+u[P]*H;i[P]=Y,u[P]=Q}}else for(var K=0;Kc&&(c=Math.abs(2*p.m_re[i]));for(i=0;i<_-b;i++)Math.abs(p.m_re[i+b+t]+p.m_im[i])>c&&(c=Math.abs(p.m_re[i+b+t]+p.m_im[i]));for(i=_-b;i<_;i++)Math.abs(2*p.m_im[i])>c&&(c=Math.abs(2*p.m_im[i]));var h=1/Math.floor(1*_/(2*b));for(l*c>h&&(l=h/c),i=0;i<_;i++)v[i]+=l*p.m_re[i],v[i+b+t]+=l*p.m_im[i];return N+=2,H=2*b+t};return Z.process=function(t){var u=t[0].length,c=t[0];if(t.length>1){c=d.float_array(t[0].length);for(var h=1/t.length,p=0;p0){var T=$+K+u,k=[];for(p=0;px&&(x=$);var A=d.float_array(x);d.blit(v,0,A,0,$);for(var R=0,O=$,S=0,C=0;;){var B=_+y-K;if(R+B>u){d.blit(c,R,g,K,u-R),K+=u-R,R=u;break}B<=0?K-=2*y:(d.blit(c,R,g,K,B),R+=B,K=_-y),C=G(),j+=2*y/i,W+=C/i,(S=O+C-x)<0&&(S=0),d.blit(v,0,A,O,C-S),O+=C}d.blit(v,C-S,v,0,S),$=S;var D=[];for(p=0;p>=1;u.m_revTgt[c]=h}u.twiddleRe=d.float_array(u.m_logN),u.twiddleIm=d.float_array(u.m_logN);for(var p=1,m=0;m>1,_=c>>1,p=c;if(t)for(var m=1/c,g=0;g>=1,_>>=1,p>>=1}for(var B,D,M=u.m_revTgt,V=0;VV&&(D=i[B=M[V]],i[B]=i[V],i[V]=D,D=d[B],d[B]=d[V],d[V]=D)};var v=i>>1;return u.unpack=function(t,d,c,l){t[0]=u.m_re[0],c[0]=u.m_im[0],d[0]=l[0]=0,t[v]=u.m_re[v],c[v]=u.m_im[v],d[v]=l[v]=0;for(var h=1;h{"use strict";var d=u(318);Object.defineProperty(i,"__esModule",{value:!0}),i.default=void 0;var c=d(u(575)),l=d(u(913)),h=function(){function Bisector(t){(0,c.default)(this,Bisector),this.lower=t.start,this.upper=t.end,this.onprocess=t.process,this.position=0,this.n=0}return(0,l.default)(Bisector,[{key:"iterate",value:function iterate(){return this.n++,this.position=Math.floor((this.lower+this.upper)/2),this.onprocess(this.lower,this.upper,this.position)}},{key:"start",value:function start(){return this.iterate(),this}},{key:"left",value:function left(){return this.upper=this.position,this.iterate()}},{key:"right",value:function right(){return this.lower=this.position,this.iterate()}}]),Bisector}();i.default=h},523:(t,i,u)=>{"use strict";var d=u(318);Object.defineProperty(i,"__esModule",{value:!0}),i.default=void 0;var c=d(u(575)),l=d(u(913)),h=new(function(){function _class(){(0,c.default)(this,_class)}return(0,l.default)(_class,[{key:"hasTypedArrays",value:function hasTypedArrays(){return!!window.Uint32Array}},{key:"hasWebAssembly",value:function hasWebAssembly(){return!!window.WebAssembly}},{key:"hasWebAudio",value:function hasWebAudio(){return!(!window.AudioContext&&!window.webkitAudioContext)}},{key:"hasFlash",value:function hasFlash(){return!1}},{key:"hasAudio",value:function hasAudio(){return this.hasWebAudio()}},{key:"isBlacklisted",value:function isBlacklisted(t){return!1}},{key:"isSlow",value:function isSlow(){return!1}},{key:"isTooSlow",value:function isTooSlow(){return!1}},{key:"supported",value:function supported(t){return"OGVDecoder"===t?this.hasWebAssembly():"OGVPlayer"===t&&(this.supported("OGVDecoder")&&this.hasAudio())}}]),_class}());i.default=h},408:(t,i,u)=>{"use strict";var d=u(318);Object.defineProperty(i,"__esModule",{value:!0}),i.default=void 0;var c=d(u(575)),l=d(u(913)),h=d(u(205)),_=d(u(585)),p=d(u(754));function _createSuper(t){var i=function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function _createSuperInternal(){var u,d=(0,p.default)(t);if(i){var c=(0,p.default)(this).constructor;u=Reflect.construct(d,arguments,c)}else u=d.apply(this,arguments);return(0,_.default)(this,u)}}var m=function(t){(0,h.default)(OGVDecoderAudioProxy,t);var i=_createSuper(OGVDecoderAudioProxy);function OGVDecoderAudioProxy(){return(0,c.default)(this,OGVDecoderAudioProxy),i.apply(this,arguments)}return(0,l.default)(OGVDecoderAudioProxy,[{key:"init",value:function init(t){this.proxy("init",[],t)}},{key:"processHeader",value:function processHeader(t,i){this.proxy("processHeader",[t],i,[t])}},{key:"processAudio",value:function processAudio(t,i){this.proxy("processAudio",[t],i,[t])}},{key:"close",value:function close(){this.terminate()}}]),OGVDecoderAudioProxy}((0,d(u(580)).default)({loadedMetadata:!1,audioFormat:null,audioBuffer:null,cpuTime:0})),g=m;i.default=g},319:(t,i,u)=>{"use strict";var d=u(318);Object.defineProperty(i,"__esModule",{value:!0}),i.default=void 0;var c=d(u(575)),l=d(u(913)),h=d(u(205)),_=d(u(585)),p=d(u(754));function _createSuper(t){var i=function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function _createSuperInternal(){var u,d=(0,p.default)(t);if(i){var c=(0,p.default)(this).constructor;u=Reflect.construct(d,arguments,c)}else u=d.apply(this,arguments);return(0,_.default)(this,u)}}var m=function(t){(0,h.default)(OGVDecoderVideoProxy,t);var i=_createSuper(OGVDecoderVideoProxy);function OGVDecoderVideoProxy(){return(0,c.default)(this,OGVDecoderVideoProxy),i.apply(this,arguments)}return(0,l.default)(OGVDecoderVideoProxy,[{key:"init",value:function init(t){this.proxy("init",[],t)}},{key:"processHeader",value:function processHeader(t,i){this.proxy("processHeader",[t],i,[t])}},{key:"processFrame",value:function processFrame(t,i){this.proxy("processFrame",[t],i,[t])}},{key:"close",value:function close(){this.terminate()}},{key:"sync",value:function sync(){this.proxy("sync",[],(function(){}))}},{key:"recycleFrame",value:function recycleFrame(t){this.proxy("recycleFrame",[t],(function(){}),[t.y.bytes.buffer,t.u.bytes.buffer,t.v.bytes.buffer])}}]),OGVDecoderVideoProxy}((0,d(u(580)).default)({loadedMetadata:!1,videoFormat:null,frameBuffer:null,cpuTime:0})),g=m;i.default=g},445:(t,i,u)=>{"use strict";var d=u(318);Object.defineProperty(i,"__esModule",{value:!0}),i.default=void 0;var c=d(u(575)),l=d(u(913)),h=d(u(539)),_="1.8.6-20220111172545-1f60d9d",p={OGVDemuxerOggW:"ogv-demuxer-ogg-wasm.js",OGVDemuxerWebMW:"ogv-demuxer-webm-wasm.js",OGVDecoderAudioOpusW:"ogv-decoder-audio-opus-wasm.js",OGVDecoderAudioVorbisW:"ogv-decoder-audio-vorbis-wasm.js",OGVDecoderVideoTheoraW:"ogv-decoder-video-theora-wasm.js",OGVDecoderVideoVP8W:"ogv-decoder-video-vp8-wasm.js",OGVDecoderVideoVP8MTW:"ogv-decoder-video-vp8-mt-wasm.js",OGVDecoderVideoVP9W:"ogv-decoder-video-vp9-wasm.js",OGVDecoderVideoVP9SIMDW:"ogv-decoder-video-vp9-simd-wasm.js",OGVDecoderVideoVP9MTW:"ogv-decoder-video-vp9-mt-wasm.js",OGVDecoderVideoVP9SIMDMTW:"ogv-decoder-video-vp9-simd-mt-wasm.js",OGVDecoderVideoAV1W:"ogv-decoder-video-av1-wasm.js",OGVDecoderVideoAV1SIMDW:"ogv-decoder-video-av1-simd-wasm.js",OGVDecoderVideoAV1MTW:"ogv-decoder-video-av1-mt-wasm.js",OGVDecoderVideoAV1SIMDMTW:"ogv-decoder-video-av1-simd-mt-wasm.js"},m=function(){function OGVLoaderBase(){(0,c.default)(this,OGVLoaderBase),this.base=this.defaultBase()}return(0,l.default)(OGVLoaderBase,[{key:"defaultBase",value:function defaultBase(){}},{key:"wasmSupported",value:function wasmSupported(){return h.default.wasmSupported()}},{key:"scriptForClass",value:function scriptForClass(t){return p[t]}},{key:"urlForClass",value:function urlForClass(t){var i=this.scriptForClass(t);if(i)return this.urlForScript(i);throw new Error("asked for URL for unknown class "+t)}},{key:"urlForScript",value:function urlForScript(t){if(t){var i=this.base;return void 0===i?i="":i+="/",i+t+"?version="+encodeURIComponent(_)}throw new Error("asked for URL for unknown script "+t)}},{key:"loadClass",value:function loadClass(t,i,u){var d=this;u=u||{};var c=this.getGlobal(),l=this.urlForClass(t),h=function classWrapper(i){return(i=i||{}).locateFile=function(t){return"data:"===t.slice(0,5)?t:d.urlForScript(t)},i.mainScriptUrlOrBlob=d.scriptForClass(t)+"?version="+encodeURIComponent(_),c[t](i)};"function"==typeof c[t]?i(h):this.loadScript(l,(function(){i(h)}))}}]),OGVLoaderBase}();i.default=m},964:(t,i,u)=>{"use strict";var d=u(318);Object.defineProperty(i,"__esModule",{value:!0}),i.default=void 0;var c=d(u(575)),l=d(u(913)),h=d(u(525)),_=d(u(205)),p=d(u(585)),m=d(u(754)),g=d(u(408)),v=d(u(319)),y=d(u(445));function _createSuper(t){var i=function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function _createSuperInternal(){var u,d=(0,m.default)(t);if(i){var c=(0,m.default)(this).constructor;u=Reflect.construct(d,arguments,c)}else u=d.apply(this,arguments);return(0,p.default)(this,u)}}var b={audio:{proxy:g.default,worker:"ogv-worker-audio.js"},video:{proxy:v.default,worker:"ogv-worker-video.js"}},T={OGVDecoderAudioOpusW:"audio",OGVDecoderAudioVorbisW:"audio",OGVDecoderVideoTheoraW:"video",OGVDecoderVideoVP8W:"video",OGVDecoderVideoVP9W:"video",OGVDecoderVideoVP9SIMDW:"video",OGVDecoderVideoAV1W:"video",OGVDecoderVideoAV1SIMDW:"video"},k=new(function(t){(0,_.default)(OGVLoaderWeb,t);var i=_createSuper(OGVLoaderWeb);function OGVLoaderWeb(){var t;return(0,c.default)(this,OGVLoaderWeb),(t=i.call(this)).scriptStatus={},t.scriptCallbacks={},t}return(0,l.default)(OGVLoaderWeb,[{key:"getGlobal",value:function getGlobal(){return window}},{key:"defaultBase",value:function defaultBase(){for(var t,i,u=document.querySelectorAll("script"),d=/^(?:|(.*)\/)ogv(?:-support|-es2017)?\.js(?:\?|#|$)/,c=0;c{"use strict";var d=u(318);Object.defineProperty(i,"__esModule",{value:!0}),i.default=void 0;var c=d(u(913)),l=d(u(575)),h=d(u(309)),_={MEDIA_ERR_ABORTED:1,MEDIA_ERR_NETWORK:2,MEDIA_ERR_DECODE:3,MEDIA_ERR_SRC_NOT_SUPPORTED:4},p=(0,c.default)((function OGVMediaError(t,i){(0,l.default)(this,OGVMediaError),this.code=t,this.message=i}));(0,h.default)(p,_),(0,h.default)(p.prototype,_);var m=p;i.default=m},278:(t,i,u)=>{"use strict";var d=u(318);Object.defineProperty(i,"__esModule",{value:!0}),i.default=void 0;var c=d(u(913)),l=d(u(575));function split(t,i,u){var d=t.split(i,u).map((function(t){return function trim(t){return t.replace(/^\s+/,"").replace(/\s+$/,"")}(t)}));if("number"==typeof u)for(;d.length{"use strict";var d=u(318);Object.defineProperty(i,"__esModule",{value:!0}),i.default=void 0;var c=d(u(575)),l=d(u(913)),h=d(u(506)),_=d(u(205)),p=d(u(585)),m=d(u(754)),g=d(u(8)),v=d(u(731)),y=d(u(936)),b=d(u(848)),T=d(u(964)),k=d(u(893)),P=d(u(309)),w=d(u(759)),E=d(u(278)),x=d(u(168)),A=d(u(625));function _createSuper(t){var i=function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function _createSuperInternal(){var u,d=(0,m.default)(t);if(i){var c=(0,m.default)(this).constructor;u=Reflect.construct(d,arguments,c)}else u=d.apply(this,arguments);return(0,p.default)(this,u)}}var R,O=function(){if("function"==typeof setImmediate)return setImmediate;var t=new MessageChannel,i=[];return t.port1.onmessage=function(t){i.shift()()},function nextTick(u){i.push(u),t.port2.postMessage({})}}(),S={NETWORK_EMPTY:0,NETWORK_IDLE:1,NETWORK_LOADING:2,NETWORK_NO_SOURCE:3,HAVE_NOTHING:0,HAVE_METADATA:1,HAVE_CURRENT_DATA:2,HAVE_FUTURE_DATA:3,HAVE_ENOUGH_DATA:4},C="INITIAL",B="SEEKING_END",D="LOADED",M="PRELOAD",V="READY",I="PLAYING",L="SEEKING",j="ERROR",W="NOT_SEEKING",X="BISECT_TO_TARGET",N="BISECT_TO_KEYPOINT",H="LINEAR_TO_TARGET",z="exact",Y="fast";function OGVJSElement(){var t=document.createElement("ogvjs");return Object.setPrototypeOf?Object.setPrototypeOf(t,Object.getPrototypeOf(this)):t.__proto__=this.__proto__,t}R="undefined"==typeof performance||void 0===(0,g.default)(performance.now)?Date.now:performance.now.bind(performance),OGVJSElement.prototype=Object.create(HTMLElement.prototype,{});var Q=function(t){(0,_.default)(OGVPlayer,t);var i=_createSuper(OGVPlayer);function OGVPlayer(t){var u;if((0,c.default)(this,OGVPlayer),u=i.call(this),(t=t||{}).base=t.base||T.default.base,u._options=t,u._instanceId="ogvjs"+ ++OGVPlayer.instanceCount,void 0!==t.worker?u._enableWorker=!!t.worker:u._enableWorker=!!window.Worker,!T.default.wasmSupported())throw new Error("WebAssembly not supported");return u._enableThreading=!!t.threading,u._enableSIMD=!!t.simd,u._state=C,u._seekState=W,u._detectedType=null,u._canvas=document.createElement("canvas"),u._frameSink=null,u.className=u._instanceId,(0,P.default)((0,h.default)(u),S),u._view=u._canvas,u._view.style.position="absolute",u._view.style.top="0",u._view.style.left="0",u._view.style.width="100%",u._view.style.height="100%",u._view.style.objectFit="contain",u.appendChild(u._view),u._startTime=R(),u._codec=null,u._audioInfo=null,u._videoInfo=null,u._actionQueue=[],u._audioFeeder=null,u._muted=!1,u._initialPlaybackPosition=0,u._initialPlaybackOffset=0,u._prebufferingAudio=!1,u._initialSeekTime=0,u._currentSrc="",u._streamEnded=!1,u._mediaError=null,u._dataEnded=!1,u._byteLength=0,u._duration=null,u._lastSeenTimestamp=null,u._nextProcessingTimer,u._nextFrameTimer=null,u._loading=!1,u._started=!1,u._paused=!0,u._ended=!1,u._startedPlaybackInDocument=!1,u._stream=void 0,u._framesProcessed=0,u._targetPerFrameTime=1e3/60,u._actualPerFrameTime=0,u._totalFrameTime=0,u._totalFrameCount=0,u._playTime=0,u._bufferTime=0,u._drawingTime=0,u._proxyTime=0,u._totalJitter=0,u._droppedAudio=0,u._delayedAudio=0,u._lateFrames=0,u._poster="",u._thumbnail=null,u._frameEndTimestamp=0,u._audioEndTimestamp=0,u._decodedFrames=[],u._pendingFrames=[],u._lastFrameDecodeTime=0,u._lastFrameVideoCpuTime=0,u._lastFrameAudioCpuTime=0,u._lastFrameDemuxerCpuTime=0,u._lastFrameDrawingTime=0,u._lastFrameBufferTime=0,u._lastFrameProxyTime=0,u._lastVideoCpuTime=0,u._lastAudioCpuTime=0,u._lastDemuxerCpuTime=0,u._lastBufferTime=0,u._lastProxyTime=0,u._lastDrawingTime=0,u._lastFrameTimestamp=0,u._currentVideoCpuTime=0,u._lastTimeUpdate=0,u._timeUpdateInterval=250,u._seekTargetTime=0,u._bisectTargetTime=0,u._seekMode=null,u._lastSeekPosition=null,u._seekBisector=null,u._didSeek=null,u._depth=0,u._needProcessing=!1,u._pendingFrame=0,u._pendingAudio=0,u._framePipelineDepth=8,u._frameParallelism=u._enableThreading?Math.min(16,navigator.hardwareConcurrency)||1:0,u._audioPipelineDepth=12,u._videoInfo=null,u._audioInfo=null,u._width=0,u._height=0,u._volume=1,u._playbackRate=1,Object.defineProperties((0,h.default)(u),{src:{get:function getSrc(){return this.getAttribute("src")||""},set:function setSrc(t){this.setAttribute("src",t),this._loading=!1,this._prepForLoad("interactive")}},buffered:{get:function getBuffered(){var t,i=this;return t=this._stream&&this._byteLength&&this._duration?this._stream.getBufferedRanges().map((function(t){return t.map((function(t){return t/i._stream.length*i._duration}))})):[[0,0]],new x.default(t)}},seekable:{get:function getSeekable(){return this.duration<1/0&&this._stream&&this._stream.seekable&&this._codec&&this._codec.seekable?new x.default([[0,this._duration]]):new x.default([])}},currentTime:{get:function getCurrentTime(){return this._state==L?this._seekTargetTime:this._codec?this._state!=I||this._paused?this._initialPlaybackOffset:this._getPlaybackTime():this._initialSeekTime},set:function setCurrentTime(t){this._seek(t,z)}},duration:{get:function getDuration(){return this._codec&&this._codec.loadedMetadata?null!==this._duration?this._duration:1/0:NaN}},paused:{get:function getPaused(){return this._paused}},ended:{get:function getEnded(){return this._ended}},seeking:{get:function getSeeking(){return this._state==L}},muted:{get:function getMuted(){return this._muted},set:function setMuted(t){this._muted=t,this._audioFeeder?this._audioFeeder.muted=this._muted:this._started&&!this._muted&&this._codec&&this._codec.hasAudio&&(this._log("unmuting: switching from timer to audio clock"),this._initAudioFeeder(),this._startPlayback(this._audioEndTimestamp)),this._fireEventAsync("volumechange")}},poster:{get:function getPoster(){return this._poster},set:function setPoster(t){var i=this;if(this._poster=t,!this._started){this._thumbnail&&this.removeChild(this._thumbnail);var u=new Image;u.src=this._poster,u.className="ogvjs-poster",u.style.position="absolute",u.style.top="0",u.style.left="0",u.style.width="100%",u.style.height="100%",u.style.objectFit="contain",u.style.visibility="hidden",u.addEventListener("load",(function(){i._thumbnail===u&&(OGVPlayer.styleManager.appendRule("."+i._instanceId,{width:u.naturalWidth+"px",height:u.naturalHeight+"px"}),u.style.visibility="visible")})),this._thumbnail=u,this.appendChild(u)}}},videoWidth:{get:function getVideoWidth(){return this._videoInfo?this._videoInfo.displayWidth:0}},videoHeight:{get:function getVideoHeight(){return this._videoInfo?this._videoInfo.displayHeight:0}},ogvjsVideoFrameRate:{get:function getOgvJsVideoFrameRate(){return this._videoInfo?0==this._videoInfo.fps?this._totalFrameCount/(this._totalFrameTime/1e3):this._videoInfo.fps:0}},ogvjsAudioChannels:{get:function getOgvJsAudioChannels(){return this._audioInfo?this._audioInfo.channels:0}},ogvjsAudioSampleRate:{get:function getOgvJsAudioChannels(){return this._audioInfo?this._audioInfo.rate:0}},width:{get:function getWidth(){return this._width},set:function setWidth(t){this._width=parseInt(t,10),this.style.width=this._width+"px"}},height:{get:function getHeight(){return this._height},set:function setHeight(t){this._height=parseInt(t,10),this.style.height=this._height+"px"}},autoplay:{get:function getAutoplay(){return!1},set:function setAutoplay(t){}},controls:{get:function getControls(){return!1},set:function setControls(t){}},loop:{get:function getLoop(){return!1},set:function setLoop(t){}},crossOrigin:{get:function getCrossOrigin(){return null},set:function setCrossOrigin(t){}},currentSrc:{get:function getCurrentSrc(){return this._currentSrc}},defaultMuted:{get:function getDefaultMuted(){return!1}},defaultPlaybackRate:{get:function getDefaultPlaybackRate(){return 1}},error:{get:function getError(){return this._state===j?this._mediaError?this._mediaError:new w.default("unknown error occurred in media procesing"):null}},preload:{get:function getPreload(){return this.getAttribute("preload")||""},set:function setPreload(t){this.setAttribute("preload",t)}},readyState:{get:function getReadyState(){return this._stream&&this._codec&&this._codec.loadedMetadata?OGVPlayer.HAVE_ENOUGH_DATA:OGVPlayer.HAVE_NOTHING}},networkState:{get:function getNetworkState(){return this._stream?this._stream.waiting?OGVPlayer.NETWORK_LOADING:OGVPlayer.NETWORK_IDLE:this.readyState==OGVPlayer.HAVE_NOTHING?OGVPlayer.NETWORK_EMPTY:OGVPlayer.NETWORK_NO_SOURCE}},playbackRate:{get:function getPlaybackRate(){return this._playbackRate},set:function setPlaybackRate(t){var i=Number(t)||1;this._audioFeeder?this._audioFeeder.tempo=i:this._paused||(this._initialPlaybackOffset=this._getPlaybackTime(),this._initialPlaybackPosition=i*R()/1e3),this._playbackRate=i,this._fireEventAsync("ratechange")}},played:{get:function getPlayed(){return new x.default([[0,this.currentTime]])}},volume:{get:function getVolume(){return this._volume},set:function setVolume(t){this._volume=+t,this._audioFeeder&&(this._audioFeeder.volume=this._volume),this._fireEventAsync("volumechange")}}}),u.onframecallback=null,u.onloadstate=null,u.onprogress=null,u.onsuspend=null,u.onabort=null,u.onemptied=null,u.onstalled=null,u.onloadedmetadata=null,u.onloadeddata=null,u.oncanplay=null,u.oncanplaythrough=null,u.onplaying=null,u.onwaiting=null,u.onseeking=null,u.onseeked=null,u.onended=null,u.ondurationchange=null,u.ontimeupdate=null,u.onplay=null,u.onpause=null,u.onratechange=null,u.onresize=null,u.onvolumechange=null,u.onaudiofeedercreated=null,u}return(0,l.default)(OGVPlayer,[{key:"_time",value:function _time(t){var i=R();t();var u=R()-i;return this._lastFrameDecodeTime+=u,u}},{key:"_log",value:function _log(t){var i=this._options;if(i.debug){var u=R()-this._startTime;i.debugFilter&&!t.match(i.debugFilter)||console.log("["+Math.round(10*u)/10+"ms] "+t)}}},{key:"_fireEvent",value:function _fireEvent(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this._log("fireEvent "+t);var u,d="function"==typeof Event;for(var c in d?u=new CustomEvent(t):(u=document.createEvent("Event")).initEvent(t,!1,!1),i)i.hasOwnProperty(c)&&(u[c]=i[c]);var l=this.dispatchEvent(u);!d&&"resize"===t&&this.onresize&&l&&this.onresize.call(this,u)}},{key:"_fireEventAsync",value:function _fireEventAsync(t){var i=this,u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this._log("fireEventAsync "+t),O((function(){i._fireEvent(t,u)}))}},{key:"_initAudioFeeder",value:function _initAudioFeeder(){var t=this,i=this._options,u={bufferSize:8192};i.audioContext&&(u.audioContext=i.audioContext),i.audioDestination&&(u.output=i.audioDestination),i.audioBackendFactory&&(u.backendFactory=i.audioBackendFactory);var d=this._audioFeeder=new b.default(u);d.init(this._audioInfo.channels,this._audioInfo.rate),this.onaudiofeedercreated&&this.onaudiofeedercreated(this._audioFeeder),d.bufferThreshold=1,d.volume=this.volume,d.muted=this.muted,d.tempo=this.playbackRate,d.onbufferlow=function(){t._log("onbufferlow"),t._stream&&(t._stream.buffering||t._stream.seeking)||t._pendingAudio||t._pingProcessing()},d.onstarved=function(){t._dataEnded?t._log("onstarved: appear to have reached end of audio"):(t._log("onstarved: halting audio due to starvation"),t._stopPlayback(),t._prebufferingAudio=!0),t._isProcessing()||t._pingProcessing(0)}}},{key:"_startPlayback",value:function _startPlayback(t){if(this._audioFeeder){this._audioFeeder.start();var i=this._audioFeeder.getPlaybackState();this._initialPlaybackPosition=i.playbackPosition}else this._initialPlaybackPosition=this._playbackRate*R()/1e3;void 0!==t&&(this._initialPlaybackOffset=t),this._prebufferingAudio=!1,this._log("continuing at "+this._initialPlaybackPosition+", "+this._initialPlaybackOffset)}},{key:"_stopPlayback",value:function _stopPlayback(){this._initialPlaybackOffset=this._getPlaybackTime(),this._log("pausing at "+this._initialPlaybackOffset),this._audioFeeder&&this._audioFeeder.stop()}},{key:"_getPlaybackTime",value:function _getPlaybackTime(t){return this._prebufferingAudio||this._paused?this._initialPlaybackOffset:(this._audioFeeder?(t=t||this._audioFeeder.getPlaybackState()).playbackPosition:this._playbackRate*R()/1e3)-this._initialPlaybackPosition+this._initialPlaybackOffset}},{key:"_stopVideo",value:function _stopVideo(){this._log("STOPPING"),this._state=C,this._seekState=W,this._started=!1,this._ended=!1,this._frameEndTimestamp=0,this._audioEndTimestamp=0,this._lastFrameDecodeTime=0,this._prebufferingAudio=!1,this._actionQueue.splice(0,this._actionQueue.length),this._stream&&(this._stream.abort(),this._stream=null,this._streamEnded=!1),this._codec&&(this._codec.close(),this._codec=null,this._pendingFrame=0,this._pendingAudio=0,this._dataEnded=!1),this._videoInfo=null,this._audioInfo=null,this._audioFeeder&&(this._audioFeeder.close(),this._audioFeeder=null),this._nextProcessingTimer&&(clearTimeout(this._nextProcessingTimer),this._nextProcessingTimer=null),this._nextFrameTimer&&(clearTimeout(this._nextFrameTimer),this._nextFrameTimer=null),this._frameSink&&(this._frameSink.clear(),this._frameSink=null),this._decodedFrames&&(this._decodedFrames=[]),this._pendingFrames&&(this._pendingFrames=[]),this._initialSeekTime=0,this._initialPlaybackPosition=0,this._initialPlaybackOffset=0,this._duration=null}},{key:"_doFrameComplete",value:function _doFrameComplete(){var t=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._startedPlaybackInDocument&&!document.body.contains(this)&&O((function(){t.stop()}));var u=R(),d=u-this._lastFrameTimestamp,c=this._actualPerFrameTime-this._targetPerFrameTime;this._totalJitter+=Math.abs(c),this._playTime+=d;var l={cpuTime:this._lastFrameDecodeTime,drawingTime:this._drawingTime-this._lastFrameDrawingTime,bufferTime:this._bufferTime-this._lastFrameBufferTime,proxyTime:this._proxyTime-this._lastFrameProxyTime,demuxerTime:0,videoTime:0,audioTime:0,clockTime:this._actualPerFrameTime,late:i.dropped,dropped:i.dropped};function n(t){return Math.round(10*t)/10}this._codec&&(l.demuxerTime=this._codec.demuxerCpuTime-this._lastFrameDemuxerCpuTime,l.videoTime+=this._currentVideoCpuTime-this._lastFrameVideoCpuTime,l.audioTime+=this._codec.audioCpuTime-this._lastFrameAudioCpuTime),l.cpuTime+=l.demuxerTime,this._lastFrameDecodeTime=0,this._lastFrameTimestamp=u,this._codec?(this._lastFrameVideoCpuTime=this._currentVideoCpuTime,this._lastFrameAudioCpuTime=this._codec.audioCpuTime,this._lastFrameDemuxerCpuTime=this._codec.demuxerCpuTime):(this._lastFrameVideoCpuTime=0,this._lastFrameAudioCpuTime=0,this._lastFrameDemuxerCpuTime=0),this._lastFrameDrawingTime=this._drawingTime,this._lastFrameBufferTime=this._bufferTime,this._lastFrameProxyTime=this._proxyTime,this._log("drew frame "+i.frameEndTimestamp+": clock time "+n(d)+" (jitter "+n(c)+") cpu: "+n(l.cpuTime)+" (mux: "+n(l.demuxerTime)+" buf: "+n(l.bufferTime)+" draw: "+n(l.drawingTime)+" proxy: "+n(l.proxyTime)+") vid: "+n(l.videoTime)+" aud: "+n(l.audioTime)),this._fireEventAsync("framecallback",l),(!this._lastTimeUpdate||u-this._lastTimeUpdate>=this._timeUpdateInterval)&&(this._lastTimeUpdate=u,this._fireEventAsync("timeupdate")),this._codec&&i.yCbCrBuffer&&this._codec.recycleFrame(i.yCbCrBuffer)}},{key:"_seekStream",value:function _seekStream(t){var i=this;this._stream.seeking&&this._stream.abort(),this._stream.buffering&&this._stream.abort(),this._streamEnded=!1,this._dataEnded=!1,this._ended=!1,this._stream.seek(t).then((function(){i._readBytesAndWait()})).catch((function(t){i._onStreamError(t)}))}},{key:"_onStreamError",value:function _onStreamError(t){"AbortError"===t.name?this._log("i/o promise canceled; ignoring"):(this._log("i/o error: "+t),this._mediaError=new w.default(w.default.MEDIA_ERR_NETWORK,String(t)),this._state=j,this._stopPlayback())}},{key:"_seek",value:function _seek(t,i){var u=this;if(this._log("requested seek to "+t+", mode "+i),this.readyState==this.HAVE_NOTHING)return this._log("not yet loaded; saving seek position for later"),void(this._initialSeekTime=t);if(this._stream&&!this._stream.seekable)throw new Error("Cannot seek a non-seekable stream");if(this._codec&&!this._codec.seekable)throw new Error("Cannot seek in a non-seekable file");var d=function prepForSeek(d){u._stream&&u._stream.buffering&&u._stream.abort(),u._stream&&u._stream.seeking&&u._stream.abort(),u._actionQueue.splice(0,u._actionQueue.length),u._stopPlayback(),u._prebufferingAudio=!1,u._audioFeeder&&u._audioFeeder.flush(),u._state=L,u._seekTargetTime=t,u._seekMode=i,u._codec?u._codec.flush(d):d()};d((function(){u._isProcessing()||u._pingProcessing(0)})),this._actionQueue.push((function(){d((function(){u._doSeek(t)}))}))}},{key:"_doSeek",value:function _doSeek(t){var i=this;this._streamEnded=!1,this._dataEnded=!1,this._ended=!1,this._state=L,this._seekTargetTime=t,this._lastSeekPosition=-1,this._decodedFrames=[],this._pendingFrames=[],this._pendingFrame=0,this._pendingAudio=0,this._didSeek=!1,this._codec.seekToKeypoint(t,(function(u){if(u)return i._seekState=H,i._fireEventAsync("seeking"),i._didSeek?void 0:void i._pingProcessing();i._codec.getKeypointOffset(t,(function(t){t>0?(i._seekState=H,i._seekStream(t)):(i._seekState=X,i._startBisection(i._seekTargetTime)),i._fireEventAsync("seeking")}))}))}},{key:"_startBisection",value:function _startBisection(t){var i=this,u=Math.max(0,this._stream.length-65536);this._bisectTargetTime=t,this._seekBisector=new k.default({start:0,end:u,process:function process(t,u,d){return d!=i._lastSeekPosition&&(i._lastSeekPosition=d,i._codec.flush((function(){i._seekStream(d)})),!0)}}),this._seekBisector.start()}},{key:"_continueSeekedPlayback",value:function _continueSeekedPlayback(){var t=this;this._seekState=W,this._state=V,this._frameEndTimestamp=this._codec.frameTimestamp,this._audioEndTimestamp=this._codec.audioTimestamp,this._codec.hasAudio?this._seekTargetTime=this._codec.audioTimestamp:this._seekTargetTime=this._codec.frameTimestamp,this._initialPlaybackOffset=this._seekTargetTime;var i=function finishedSeeking(){t._lastTimeUpdate=t._seekTargetTime,t._fireEventAsync("timeupdate"),t._fireEventAsync("seeked"),t._isProcessing()||t._pingProcessing()};if(this._codec.hasVideo&&this._decodedFrames.length){var u=this._decodedFrames.shift();this._drawFrame(u.yCbCrBuffer),i()}else{if(this._codec.hasVideo&&this._codec.frameReady)return this._codec.decodeFrame((function(u){u&&t._drawFrame(t._codec.frameBuffer),i()})),void this._codec.sync();i()}}},{key:"_drawFrame",value:function _drawFrame(t){this._thumbnail&&(this.removeChild(this._thumbnail),this._thumbnail=null),this._frameSink.drawFrame(t)}},{key:"_doProcessLinearSeeking",value:function _doProcessLinearSeeking(){var t,i=this;if(t=this._codec.hasVideo?this._targetPerFrameTime/1e3:1/256,this._codec.hasVideo){if(this._pendingFrame)return;if(!this._codec.frameReady)return void this._codec.process((function(t){t?i._pingProcessing():i._streamEnded?(i._log("stream ended during linear seeking on video"),i._dataEnded=!0,i._continueSeekedPlayback()):i._readBytesAndWait()}));if(this._seekMode===Y&&this._codec.keyframeTimestamp==this._codec.frameTimestamp)return void this._continueSeekedPlayback();if(this._codec.frameTimestamp<=this._seekTargetTime){var u=this._codec.frameTimestamp;return this._pendingFrame++,this._pendingFrames.push({frameEndTimestamp:u}),this._decodedFrames.splice(0,this._decodedFrames.length),this._codec.decodeFrame((function(t){i._pendingFrame--,i._pendingFrames.shift(),i._decodedFrames.push({yCbCrBuffer:i._codec.frameBuffer,videoCpuTime:i._codec.videoCpuTime,frameEndTimestamp:u}),i._pingProcessing()})),void this._codec.sync()}if(!this._codec.hasAudio)return void this._continueSeekedPlayback()}if(this._codec.hasAudio){if(this._pendingAudio)return;return this._codec.audioReady?this._codec.audioTimestamp+tthis._bisectTargetTime?this._seekBisector.left()||(this._log("close enough (left)"),this._seekTargetTime=i,this._continueSeekedPlayback()):i+t/20?this._targetPerFrameTime=1e3/this._videoInfo.fps:this._targetPerFrameTime=16.667,this._canvas.width=this._videoInfo.displayWidth,this._canvas.height=this._videoInfo.displayHeight,OGVPlayer.styleManager.appendRule("."+this._instanceId,{width:this._videoInfo.displayWidth+"px",height:this._videoInfo.displayHeight+"px"});var t={};void 0!==this._options.webGL&&(t.webGL=this._options.webGL),this._options.forceWebGL&&(t.webGL="required"),this._frameSink=v.default.attach(this._canvas,t)}},{key:"_doProcessing",value:function _doProcessing(){if(this._didSeek&&(this._didSeek=!1),this._nextProcessingTimer=null,this._isProcessing(),this._depth>0)throw new Error("REENTRANCY FAIL: doProcessing recursing unexpectedly");var t=0;do{if(this._needProcessing=!1,this._depth++,this._doProcessingLoop(),this._depth--,this._needProcessing&&this._isProcessing())throw new Error("REENTRANCY FAIL: waiting on input or codec but asked to keep processing");++t>500&&(this._log("stuck in processing loop; breaking with timer"),this._needProcessing=0,this._pingProcessing(0))}while(this._needProcessing)}},{key:"_doProcessingLoop",value:function _doProcessingLoop(){if(this._actionQueue.length)this._actionQueue.shift()();else if(this._state==C)this._doProcessInitial();else if(this._state==B)this._doProcessSeekingEnd();else if(this._state==D)this._doProcessLoaded();else if(this._state==M)this._doProcessPreload();else if(this._state==V)this._doProcessReady();else if(this._state==L)this._doProcessSeeking();else if(this._state==I)this._doProcessPlay();else{if(this._state!=j)throw new Error("Unexpected OGVPlayer state "+this._state);this._doProcessError()}}},{key:"_doProcessInitial",value:function _doProcessInitial(){var t=this;if(this._codec.loadedMetadata){if(!this._codec.hasVideo&&!this._codec.hasAudio)throw new Error("No audio or video found, something is wrong");this._codec.hasAudio&&(this._audioInfo=this._codec.audioFormat),this._codec.hasVideo&&(this._videoInfo=this._codec.videoFormat,this._setupVideo()),isNaN(this._codec.duration)||(this._duration=this._codec.duration),null===this._duration&&this._stream.seekable&&"video/ogg"==this._detectedType?(this._state=B,this._lastSeenTimestamp=-1,this._codec.flush((function(){t._seekStream(Math.max(0,t._stream.length-131072))}))):(this._state=D,this._pingProcessing())}else this._codec.process((function(i){if(i)t._pingProcessing();else{if(t._streamEnded)throw new Error("end of file before headers found");t._log("reading more cause we are out of data"),t._readBytesAndWait()}}))}},{key:"_doProcessSeekingEnd",value:function _doProcessSeekingEnd(){var t=this;this._codec.frameReady?(this._log("saw frame with "+this._codec.frameTimestamp),this._lastSeenTimestamp=Math.max(this._lastSeenTimestamp,this._codec.frameTimestamp),this._codec.discardFrame((function(){t._pingProcessing()}))):this._codec.audioReady?(this._log("saw audio with "+this._codec.audioTimestamp),this._lastSeenTimestamp=Math.max(this._lastSeenTimestamp,this._codec.audioTimestamp),this._codec.discardAudio((function(){t._pingProcessing()}))):this._codec.process((function(i){i?t._pingProcessing():t._stream.eof?(t._log("seek-duration: we are at the end: "+t._lastSeenTimestamp),t._lastSeenTimestamp>0&&(t._duration=t._lastSeenTimestamp),t._state=D,t._codec.flush((function(){t._streamEnded=!1,t._dataEnded=!1,t._seekStream(0)}))):t._readBytesAndWait()}))}},{key:"_doProcessLoaded",value:function _doProcessLoaded(){this._state=M,this._fireEventAsync("loadedmetadata"),this._fireEventAsync("durationchange"),this._codec.hasVideo&&this._fireEventAsync("resize"),this._pingProcessing(0)}},{key:"_doProcessPreload",value:function _doProcessPreload(){var t=this;!this._codec.frameReady&&this._codec.hasVideo||!this._codec.audioReady&&this._codec.hasAudio?this._codec.process((function(i){i?t._pingProcessing():t._streamEnded?t._ended=!0:t._readBytesAndWait()})):(this._state=V,this._fireEventAsync("loadeddata"),this._pingProcessing())}},{key:"_doProcessReady",value:function _doProcessReady(){var t=this;if(this._log("initial seek to "+this._initialSeekTime),this._initialSeekTime>0){var i=this._initialSeekTime;this._initialSeekTime=0,this._log("initial seek to "+i),this._doSeek(i)}else if(this._paused)this._log("paused while in ready");else{var u=function finishStartPlaying(){t._log("finishStartPlaying"),t._state=I,t._lastFrameTimestamp=R(),t._codec.hasAudio&&t._audioFeeder?t._prebufferingAudio=!0:t._startPlayback(),t._pingProcessing(0),t._fireEventAsync("play"),t._fireEventAsync("playing")};!this._codec.hasAudio||this._audioFeeder||this._muted?u():(this._initAudioFeeder(),this._audioFeeder.waitUntilReady(u))}}},{key:"_doProcessSeeking",value:function _doProcessSeeking(){if(this._seekState==W)throw new Error("seeking in invalid state (not seeking?)");if(this._seekState==X)this._doProcessBisectionSeek();else if(this._seekState==N)this._doProcessBisectionSeek();else{if(this._seekState!=H)throw new Error("Invalid seek state "+this._seekState);this._doProcessLinearSeeking()}}},{key:"_doProcessPlay",value:function _doProcessPlay(){var t=this,i=this._codec;if(this._paused)this._log("paused during playback; stopping loop");else if((!i.hasAudio||i.audioReady||this._pendingAudio||this._dataEnded)&&(!i.hasVideo||i.frameReady||this._pendingFrame||this._decodedFrames.length||this._dataEnded)){var u,d,c,l=null,h=0,_=!1,p=0;if(i.hasAudio&&this._audioFeeder?(l=this._audioFeeder.getPlaybackState(),h=this._getPlaybackTime(l),_=this._dataEnded&&0==this._audioFeeder.durationBuffered,this._prebufferingAudio&&(this._audioFeeder.durationBuffered>=2*this._audioFeeder.bufferThreshold&&(!i.hasVideo||this._decodedFrames.length>=this._framePipelineDepth)||this._dataEnded)&&(this._log("prebuffering audio done; buffered to "+this._audioFeeder.durationBuffered),this._startPlayback(h),this._prebufferingAudio=!1),l.dropped!=this._droppedAudio&&this._log("dropped "+(l.dropped-this._droppedAudio)),l.delayed!=this._delayedAudio&&this._log("delayed "+(l.delayed-this._delayedAudio)),this._droppedAudio=l.dropped,this._delayedAudio=l.delayed,(u=this._audioFeeder.durationBuffered<=2*this._audioFeeder.bufferThreshold)&&(this._codec.audioReady?this._pendingAudio>=this._audioPipelineDepth&&(this._log("audio decode disabled: "+this._pendingAudio+" packets in flight"),u=!1):u=!1)):(h=this._getPlaybackTime(),u=this._codec.audioReady&&this._audioEndTimestamp0,c=this._pendingFrame+this._decodedFrames.length=m){for(var g=-1,v=0;v=0)for(;g-- >=0;){this._lateFrames++;var y=this._decodedFrames.shift();this._log("skipping already-decoded late frame at "+y.frameEndTimestamp),p=1e3*(y.frameEndTimestamp-h),this._frameEndTimestamp=y.frameEndTimestamp,this._actualPerFrameTime=this._targetPerFrameTime-p,this._framesProcessed++,y.dropped=!0,this._doFrameComplete(y)}var b=this._codec.nextKeyframeTimestamp,T=b-this._targetPerFrameTime/1e3*(this._framePipelineDepth+this._pendingFrame);if(b>=0&&b!=this._codec.frameTimestamp&&h>=T){this._log("skipping late frame at "+this._decodedFrames[0].frameEndTimestamp+" vs "+h+", expect to see keyframe at "+b);for(var k=0;k0&&(this._targetPerFrameTime=1e3*(this._codec.frameTimestamp-this._frameEndTimestamp)),this._totalFrameTime+=this._targetPerFrameTime,this._totalFrameCount++;var A=this._frameEndTimestamp=this._codec.frameTimestamp;this._pendingFrame++,this._pendingFrames.push({frameEndTimestamp:A});var R=this._pendingFrames,O=!1,S=this._time((function(){t._codec.decodeFrame((function(i){R===t._pendingFrames?(t._log("play loop callback: decoded frame"),t._pendingFrame--,t._pendingFrames.shift(),i?t._decodedFrames.push({yCbCrBuffer:t._codec.frameBuffer,videoCpuTime:t._codec.videoCpuTime,frameEndTimestamp:A}):t._log("Bad video packet or something"),t._codec.process((function(){t._isProcessing()||t._pingProcessing(O?void 0:0)}))):t._log("play loop callback after flush, discarding")}))}));this._pendingFrame&&(O=!0,this._proxyTime+=S,this._pingProcessing(),this._dataEnded&&this._codec.sync())}else if(u){this._log("play loop: ready for audio; depth: "+this._pendingAudio),this._pendingAudio++;var C=this._codec.audioTimestamp,B=this._time((function(){t._codec.decodeAudio((function(i){if(t._pendingAudio--,t._log("play loop callback: decoded audio"),t._audioEndTimestamp=C,i){var u=t._codec.audioBuffer;if(u&&(t._bufferTime+=t._time((function(){t._audioFeeder&&t._audioFeeder.bufferData(u)})),!t._codec.hasVideo)){t._framesProcessed++;var d={frameEndTimestamp:t._audioEndTimestamp};t._doFrameComplete(d)}}t._isProcessing()||t._pingProcessing()}))}));this._pendingAudio&&(this._proxyTime+=B,this._codec.audioReady?this._pingProcessing():this._doProcessPlayDemux())}else if(d){this._log("play loop: ready to draw frame"),this._nextFrameTimer&&(clearTimeout(this._nextFrameTimer),this._nextFrameTimer=null),this._thumbnail&&(this.removeChild(this._thumbnail),this._thumbnail=null);var D=this._decodedFrames.shift();this._currentVideoCpuTime=D.videoCpuTime,this._drawingTime+=this._time((function(){t._drawFrame(D.yCbCrBuffer)})),this._framesProcessed++,this._doFrameComplete(D),this._pingProcessing()}else if(!this._decodedFrames.length||this._nextFrameTimer||this._prebufferingAudio)if(this._dataEnded&&!(this._pendingAudio||this._pendingFrame||this._decodedFrames.length)){this._log("play loop: playback reached end of data "+[this._pendingAudio,this._pendingFrame,this._decodedFrames.length]);var M=0;this._codec.hasAudio&&this._audioFeeder&&(M=1e3*this._audioFeeder.durationBuffered),M>0?(this._log("play loop: ending pending "+M+" ms"),this._pingProcessing(Math.max(0,M))):(this._log("play loop: ENDING NOW: playback time "+this._getPlaybackTime()+"; frameEndTimestamp: "+this._frameEndTimestamp),this._stopPlayback(),this._prebufferingAudio=!1,this._initialPlaybackOffset=Math.max(this._audioEndTimestamp,this._frameEndTimestamp),this._ended=!0,this._paused=!0,this._fireEventAsync("pause"),this._fireEventAsync("ended"))}else this._prebufferingAudio&&(i.hasVideo&&!i.frameReady||i.hasAudio&&!i.audioReady)?(this._log("play loop: prebuffering demuxing"),this._doProcessPlayDemux()):this._log("play loop: waiting on async/timers");else{var V=p;this._log("play loop: setting a timer for drawing "+V),this._nextFrameTimer=setTimeout((function(){t._nextFrameTimer=null,t._pingProcessing()}),V)}}else this._log("play loop: demuxing"),this._doProcessPlayDemux()}},{key:"_doProcessPlayDemux",value:function _doProcessPlayDemux(){var t=this,i=this._codec.frameReady,u=this._codec.audioReady;this._codec.process((function(d){t._codec.frameReady&&!i||t._codec.audioReady&&!u?(t._log("demuxer has packets"),t._pingProcessing()):d?(t._log("demuxer processing to find more packets"),t._pingProcessing()):(t._log("demuxer ran out of data"),t._streamEnded?(t._log("demuxer reached end of data stream"),t._dataEnded=!0,t._pingProcessing()):(t._log("demuxer loading more data"),t._readBytesAndWait()))}))}},{key:"_doProcessError",value:function _doProcessError(){}},{key:"_isProcessing",value:function _isProcessing(){return this._stream&&(this._stream.buffering||this._stream.seeking)||this._codec&&this._codec.processing}},{key:"_readBytesAndWait",value:function _readBytesAndWait(){var t=this;if(this._stream.buffering||this._stream.seeking)this._log("readBytesAndWait during i/o");else{this._stream.read(32768).then((function(i){t._log("got input "+[i.byteLength]),i.byteLength&&t._actionQueue.push((function(){t._codec.receiveInput(i,(function(){t._pingProcessing()}))})),t._stream.eof&&(t._log("stream is at end!"),t._streamEnded=!0),t._isProcessing()||t._pingProcessing()})).catch((function(i){t._onStreamError(i)}))}}},{key:"_pingProcessing",value:function _pingProcessing(){var t=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;if(this._stream&&this._stream.waiting)this._log("waiting on input");else{this._nextProcessingTimer&&(this._log("canceling old processing timer"),clearTimeout(this._nextProcessingTimer),this._nextProcessingTimer=null);var u=-1/256;i>u?this._nextProcessingTimer=setTimeout((function(){t._pingProcessing()}),i):this._depth?this._needProcessing=!0:this._doProcessing()}}},{key:"_startProcessingVideo",value:function _startProcessingVideo(t){var i=this;if(!this._started&&!this._codec){this._framesProcessed=0,this._bufferTime=0,this._drawingTime=0,this._proxyTime=0,this._started=!0,this._ended=!1;var u={base:this._options.base,worker:this._enableWorker,threading:this._enableThreading,simd:this._enableSIMD};this._detectedType&&(u.type=this._detectedType),this._codec=new A.default(u),this._lastVideoCpuTime=0,this._lastAudioCpuTime=0,this._lastDemuxerCpuTime=0,this._lastBufferTime=0,this._lastDrawingTime=0,this._lastProxyTime=0,this._lastFrameVideoCpuTime=0,this._lastFrameAudioCpuTime=0,this._lastFrameDemuxerCpuTime=0,this._lastFrameBufferTime=0,this._lastFrameProxyTime=0,this._lastFrameDrawingTime=0,this._currentVideoCpuTime=0,this._codec.onseek=function(t){i._didSeek=!0,i._stream&&i._seekStream(t)},this._codec.init((function(){i._codec.receiveInput(t,(function(){i._readBytesAndWait()}))}))}}},{key:"_loadCodec",value:function _loadCodec(t){var i=this;this._stream.read(1024).then((function(u){var d=new Uint8Array(u);d.length>4&&d[0]=="O".charCodeAt(0)&&d[1]=="g".charCodeAt(0)&&d[2]=="g".charCodeAt(0)&&d[3]=="S".charCodeAt(0)?i._detectedType="video/ogg":d.length>4&&26==d[0]&&69==d[1]&&223==d[2]&&163==d[3]?i._detectedType="video/webm":i._detectedType="video/ogg",t(u)}))}},{key:"_prepForLoad",value:function _prepForLoad(t){var i=this;this._stopVideo();this._currentSrc="",this._loading=!0,this._actionQueue.push((function(){t&&"none"===i.preload?i._loading=!1:function doLoad(){i._options.stream?i._stream=i._options.stream:i._stream=new y.default({url:i.src,cacheSize:16777216,progressive:!1}),i._stream.load().then((function(){i._loading=!1,i._currentSrc=i.src,i._byteLength=i._stream.seekable?i._stream.length:0;var t=i._stream.headers["x-content-duration"];"string"==typeof t&&(i._duration=parseFloat(t)),i._loadCodec((function(t){i._startProcessingVideo(t)}))})).catch((function(t){i._onStreamError(t)}))}()})),this._pingProcessing(0)}},{key:"load",value:function load(){this._prepForLoad()}},{key:"canPlayType",value:function canPlayType(t){var i=new E.default(t);function checkTypes(t){if(i.codecs){var u=0,d=0;return i.codecs.forEach((function(i){t.indexOf(i)>=0?u++:d++})),0===u||d>0?"":"probably"}return"maybe"}return"ogg"!==i.minor||"audio"!==i.major&&"video"!==i.major&&"application"!==i.major?"webm"!==i.minor||"audio"!==i.major&&"video"!==i.major?"":checkTypes(["vorbis","opus","vp8","vp9"]):checkTypes(["vorbis","opus","theora"])}},{key:"play",value:function play(){this._muted||this._options.audioContext||OGVPlayer.initSharedAudioContext(),this._paused&&(this._startedPlaybackInDocument=document.body.contains(this),this._paused=!1,this._state==L||(this._started&&this._codec&&this._codec.loadedMetadata?(this._ended&&this._stream&&this._byteLength?(this._log(".play() starting over after end"),this._seek(0)):this._log(".play() while already started"),this._state=V,this._isProcessing()||this._pingProcessing()):this._loading?this._log(".play() while loading"):(this._log(".play() before started"),this._stream||this.load())))}},{key:"getPlaybackStats",value:function getPlaybackStats(){return{targetPerFrameTime:this._targetPerFrameTime,framesProcessed:this._framesProcessed,videoBytes:this._codec?this._codec.videoBytes:0,audioBytes:this._codec?this._codec.audioBytes:0,playTime:this._playTime,demuxingTime:this._codec?this._codec.demuxerCpuTime-this._lastDemuxerCpuTime:0,videoDecodingTime:this._codec?this._codec.videoCpuTime-this._lastVideoCpuTime:0,audioDecodingTime:this._codec?this._codec.audioCpuTime-this._lastAudioCpuTime:0,bufferTime:this._bufferTime-this._lastBufferTime,drawingTime:this._drawingTime-this._lastDrawingTime,proxyTime:this._proxyTime-this._lastProxyTime,droppedAudio:this._droppedAudio,delayedAudio:this._delayedAudio,jitter:this._totalJitter/this._framesProcessed,lateFrames:this._lateFrames}}},{key:"resetPlaybackStats",value:function resetPlaybackStats(){this._framesProcessed=0,this._playTime=0,this._codec&&(this._lastDemuxerCpuTime=this._codec.demuxerCpuTime,this._lastVideoCpuTime=this._codec.videoCpuTime,this._lastAudioCpuTime=this._codec.audioCpuTime,this._codec.videoBytes=0,this._codec.audioBytes=0),this._lastBufferTime=this._bufferTime,this._lastDrawingTime=this._drawingTime,this._lastProxyTime=this._proxyTime,this._totalJitter=0,this._totalFrameTime=0,this._totalFrameCount=0}},{key:"getVideoFrameSink",value:function getVideoFrameSink(){return this._frameSink}},{key:"getCanvas",value:function getCanvas(){return this._canvas}},{key:"getVideo",value:function getVideo(){return null}},{key:"pause",value:function pause(){this._paused||(this._nextProcessingTimer&&(clearTimeout(this._nextProcessingTimer),this._nextProcessingTimer=null),this._stopPlayback(),this._prebufferingAudio=!1,this._paused=!0,this._fireEvent("pause"))}},{key:"stop",value:function stop(){this._stopVideo(),this._paused=!0}},{key:"fastSeek",value:function fastSeek(t){this._seek(+t,Y)}}],[{key:"initSharedAudioContext",value:function initSharedAudioContext(){b.default.initSharedAudioContext()}}]),OGVPlayer}(OGVJSElement);(0,P.default)(Q,S),Q.instanceCount=0,Q.styleManager=new function StyleManager(){var t=document.createElement("style");t.type="text/css",t.textContent="ogvjs { display: inline-block; position: relative; -webkit-user-select: none; -webkit-tap-highlight-color: rgba(0,0,0,0); ",document.head.appendChild(t);var i=t.sheet;this.appendRule=function(t,u){var d=[];for(var c in u)u.hasOwnProperty(c)&&d.push(c+":"+u[c]);var l=t+"{"+d.join(";")+"}";i.insertRule(l,i.cssRules.length-1)}};var K=Q;i.default=K},580:(t,i,u)=>{"use strict";var d=u(318);Object.defineProperty(i,"__esModule",{value:!0}),i.default=void 0;var c=d(u(575)),l=d(u(913));var h=function OGVProxyClass(t){return function(){function _class(i,u,d){var l=this;for(var h in(0,c.default)(this,_class),d=d||{},this.worker=i,this.transferables=function(){var t=new ArrayBuffer(1024),u=new Uint8Array(t);try{return i.postMessage({action:"transferTest",bytes:u},[t]),!t.byteLength}catch(t){return!1}}(),t)t.hasOwnProperty(h)&&(this[h]=t[h]);this.processingQueue=0,Object.defineProperty(this,"processing",{get:function get(){return this.processingQueue>0}}),this.messageCount=0,this.pendingCallbacks={},this.worker.addEventListener("message",(function(t){l.handleMessage(t)})),this.proxy("construct",[u,d],(function(){}))}return(0,l.default)(_class,[{key:"proxy",value:function proxy(t,i,u){var d=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];if(!this.worker)throw'Tried to call "'+t+'" method on closed proxy object';var c="callback-"+ ++this.messageCount+"-"+t;u&&(this.pendingCallbacks[c]=u);var l={action:t,callbackId:c,args:i||[]};this.processingQueue++,this.transferables?this.worker.postMessage(l,d):this.worker.postMessage(l)}},{key:"terminate",value:function terminate(){this.worker&&(this.worker.terminate(),this.worker=null,this.processingQueue=0,this.pendingCallbacks={})}},{key:"handleMessage",value:function handleMessage(t){if(this.processingQueue--,"callback"===t.data.action){var i=t.data,u=i.callbackId,d=i.args,c=this.pendingCallbacks[u];if(i.props)for(var l in i.props)i.props.hasOwnProperty(l)&&(this[l]=i.props[l]);c&&(delete this.pendingCallbacks[u],c.apply(this,d))}}}]),_class}()};i.default=h},168:(t,i,u)=>{"use strict";var d=u(318);Object.defineProperty(i,"__esModule",{value:!0}),i.default=void 0;var c=d(u(575)),l=d(u(913)),h=function(){function OGVTimeRanges(t){(0,c.default)(this,OGVTimeRanges),this._ranges=t,this.length=t.length}return(0,l.default)(OGVTimeRanges,[{key:"start",value:function start(t){if(t<0||t>this.length||t!==(0|t))throw new RangeError("Invalid index");return this._ranges[t][0]}},{key:"end",value:function end(t){if(t<0||t>this.length||t!==(0|t))throw new RangeError("Invalid index");return this._ranges[t][1]}}]),OGVTimeRanges}();i.default=h},625:(t,i,u)=>{"use strict";var d=u(318);Object.defineProperty(i,"__esModule",{value:!0}),i.default=void 0;var c=d(u(575)),l=d(u(913)),h=d(u(964));function _createForOfIteratorHelper(t,i){var u="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!u){if(Array.isArray(t)||(u=function _unsupportedIterableToArray(t,i){if(!t)return;if("string"==typeof t)return _arrayLikeToArray(t,i);var u=Object.prototype.toString.call(t).slice(8,-1);"Object"===u&&t.constructor&&(u=t.constructor.name);if("Map"===u||"Set"===u)return Array.from(t);if("Arguments"===u||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(u))return _arrayLikeToArray(t,i)}(t))||i&&t&&"number"==typeof t.length){u&&(t=u);var d=0,c=function F(){};return{s:c,n:function n(){return d>=t.length?{done:!0}:{done:!1,value:t[d++]}},e:function e(t){throw t},f:c}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,h=!0,_=!1;return{s:function s(){u=u.call(t)},n:function n(){var t=u.next();return h=t.done,t},e:function e(t){_=!0,l=t},f:function f(){try{h||null==u.return||u.return()}finally{if(_)throw l}}}}function _arrayLikeToArray(t,i){(null==i||i>t.length)&&(i=t.length);for(var u=0,d=new Array(i);u0?l.push(_.subarray(0,_.length-Math.min(p,_.length))):l.push(_.subarray(Math.min(Math.abs(p),_.length),_.length))}}catch(t){h.e(t)}finally{h.f()}i.audioDecoder.audioBuffer=l}return u(t)}))}))}},{key:"discardFrame",value:function discardFrame(t){var i=this;this.demuxer.dequeueVideoPacket((function(u){i.videoBytes+=u.byteLength,t()}))}},{key:"discardAudio",value:function discardAudio(t){var i=this;this.demuxer.dequeueAudioPacket((function(u,d){i.audioBytes+=u.byteLength,t()}))}},{key:"flush",value:function flush(t){this.flushIter++,this.demuxer.flush(t)}},{key:"sync",value:function sync(){this.videoDecoder&&this.videoDecoder.sync()}},{key:"recycleFrame",value:function recycleFrame(t){this.videoDecoder&&this.videoDecoder.recycleFrame(t)}},{key:"getKeypointOffset",value:function getKeypointOffset(t,i){this.demuxer.getKeypointOffset(t,i)}},{key:"seekToKeypoint",value:function seekToKeypoint(t,i){this.demuxer.seekToKeypoint(t,this.flushSafe(i))}},{key:"loadAudioCodec",value:function loadAudioCodec(t){var i=this;if(this.demuxer.audioCodec){var u={vorbis:"OGVDecoderAudioVorbisW",opus:"OGVDecoderAudioOpusW"}[this.demuxer.audioCodec];this.processing=!0,h.default.loadClass(u,(function(u){var d={};i.demuxer.audioFormat&&(d.audioFormat=i.demuxer.audioFormat),u(d).then((function(u){i.audioDecoder=u,u.init((function(){i.loadedAudioMetadata=u.loadedMetadata,i.processing=!1,t()}))}))}),{worker:this.options.worker})}else t()}},{key:"loadVideoCodec",value:function loadVideoCodec(t){var i=this;if(this.demuxer.videoCodec){var u=!!this.options.simd,d=!!this.options.threading,c={theora:"OGVDecoderVideoTheoraW",vp8:d?"OGVDecoderVideoVP8MTW":"OGVDecoderVideoVP8W",vp9:d?u?"OGVDecoderVideoVP9SIMDMTW":"OGVDecoderVideoVP9MTW":u?"OGVDecoderVideoVP9SIMDW":"OGVDecoderVideoVP9W",av1:d?u?"OGVDecoderVideoAV1SIMDMTW":"OGVDecoderVideoAV1MTW":u?"OGVDecoderVideoAV1SIMDW":"OGVDecoderVideoAV1W"}[this.demuxer.videoCodec];this.processing=!0,h.default.loadClass(c,(function(u){var c={};i.demuxer.videoFormat&&(c.videoFormat=i.demuxer.videoFormat),d&&delete window.ENVIRONMENT_IS_PTHREAD,u(c).then((function(u){i.videoDecoder=u,u.init((function(){i.loadedVideoMetadata=u.loadedMetadata,i.processing=!1,t()}))}))}),{worker:this.options.worker&&!this.options.threading})}else t()}}]),OGVWrapperCodec}();i.default=_},539:(t,i,u)=>{"use strict";var d=u(318);Object.defineProperty(i,"__esModule",{value:!0}),i.default=void 0;var c=d(u(8)),l=d(u(575)),h=d(u(913));var _=new(function(){function WebAssemblyChecker(){(0,l.default)(this,WebAssemblyChecker),this.tested=!1,this.testResult=void 0}return(0,h.default)(WebAssemblyChecker,[{key:"wasmSupported",value:function wasmSupported(){if(!this.tested){try{"object"===("undefined"==typeof WebAssembly?"undefined":(0,c.default)(WebAssembly))?this.testResult=function testSafariWebAssemblyBug(){var t=new Uint8Array([0,97,115,109,1,0,0,0,1,6,1,96,1,127,1,127,3,2,1,0,5,3,1,0,1,7,8,1,4,116,101,115,116,0,0,10,16,1,14,0,32,0,65,1,54,2,0,32,0,40,2,0,11]),i=new WebAssembly.Module(t);return 0!==new WebAssembly.Instance(i,{}).exports.test(4)}():this.testResult=!1}catch(t){console.log("Exception while testing WebAssembly",t),this.testResult=!1}this.tested=!0}return this.testResult}}]),WebAssemblyChecker}());i.default=_},309:(t,i)=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.default=void 0;var u=function extend(t,i){for(var u in i)i.hasOwnProperty(u)&&(t[u]=i[u])};i.default=u},431:(t,i,u)=>{"use strict";var d=function(){function defineProperties(t,i){for(var u=0;u{"use strict";var d=function(){function defineProperties(t,i){for(var u=0;u=200&&t.xhr.status<300?(t.length=getXHRLength(t.xhr),t.headers=function getXHRHeaders(t){var i={};return t.getAllResponseHeaders().split(/\r?\n/).forEach((function(t){var u=t.split(/:\s*/,2);u.length>1&&(i[u[0].toLowerCase()]=u[1])})),i}(t.xhr),t.onXHRStart()):(d(),u(new Error("HTTP error "+t.xhr.status)))}},l=function checkError(){d(),u(new Error("network error"))},h=function checkBackendOpen(){d(),i()};d=function oncomplete(){t.xhr.removeEventListener("readystatechange",c),t.xhr.removeEventListener("error",l),t.off("open",h),t._onAbort=null},t.initXHR(),t.xhr.addEventListener("readystatechange",c),t.xhr.addEventListener("error",l),t.on("open",h),t.xhr.send()}))}},{key:"bufferToOffset",value:function bufferToOffset(t){return Promise.reject(new Error("abstract"))}},{key:"abort",value:function abort(){if(this.xhr.abort(),this._onAbort){var t=this._onAbort;this._onAbort=null;var i=new Error("Aborted");i.name="AbortError",t(i)}}},{key:"initXHR",value:function initXHR(){var t=this.url;this.cachever&&(t+="?buggy_cachever="+this.cachever),this.xhr.open("GET",t);var i=null;(this.offset||this.length)&&(i="bytes="+this.offset+"-"),this.length&&(i+=this.offset+this.length-1),null!==i&&this.xhr.setRequestHeader("Range",i)}},{key:"onXHRStart",value:function onXHRStart(){throw new Error("abstract")}}]),Backend}(u(566));t.exports=c},810:(t,i,u)=>{"use strict";var d=function(){function defineProperties(t,i){for(var u=0;u0&&(this.bytesRead+=t.length,this.emit("buffer",t))}},{key:"onXHRLoad",value:function onXHRLoad(){this.onXHRProgress(),c(BinaryStringBackend.prototype.__proto__||Object.getPrototypeOf(BinaryStringBackend.prototype),"onXHRLoad",this).call(this)}}]),BinaryStringBackend}(u(828));l.supported=function(){try{return!!(new XMLHttpRequest).overrideMimeType}catch(t){return!1}},t.exports=l},828:(t,i,u)=>{"use strict";var d=function(){function defineProperties(t,i){for(var u=0;u=t)u();else{var c=null;i._onAbort=function(t){c(),d(t)};var l=function checkBuffer(){i.offset>=t&&!i.eof&&(c(),u())},h=function checkDone(){c(),u()},_=function checkError(){c(),d(new Error("error streaming"))};c=function oncomplete(){i.buffering=!1,i.off("buffer",l),i.off("done",h),i.off("error",_),i._onAbort=null},i.buffering=!0,i.on("buffer",l),i.on("done",h),i.on("error",_)}}))}},{key:"initXHR",value:function initXHR(){c(DownloadBackend.prototype.__proto__||Object.getPrototypeOf(DownloadBackend.prototype),"initXHR",this).call(this)}},{key:"onXHRStart",value:function onXHRStart(){var t=this;this.xhr.addEventListener("progress",(function(){return t.onXHRProgress()})),this.xhr.addEventListener("error",(function(){return t.onXHRError()})),this.xhr.addEventListener("load",(function(){return t.onXHRLoad()})),this.emit("open")}},{key:"onXHRProgress",value:function onXHRProgress(){throw new Error("abstract")}},{key:"onXHRError",value:function onXHRError(){this.emit("error")}},{key:"onXHRLoad",value:function onXHRLoad(){this.eof=!0,this.emit("done")}}]),DownloadBackend}(u(306));t.exports=l},761:(t,i,u)=>{"use strict";var d=u(855),c=u(810),l=u(431);var h=null;t.exports=function instantiate(t){if(!1===t.progressive)return new l(t);if(h||(h=function autoselect(){return d.supported()?d:c.supported()?c:null}()),!h)throw new Error("No supported backend class");return new h(t)}},855:(t,i,u)=>{"use strict";var d=function(){function defineProperties(t,i){for(var u=0;u{"use strict";var i=function(){function defineProperties(t,i){for(var u=0;u0&&void 0!==arguments[0]?arguments[0]:{},i=t.buffer,u=void 0===i?void 0:i,d=t.string,c=void 0===d?void 0:d,l=t.start,h=void 0===l?0:l,_=t.end,p=void 0===_?h+(u?u.byteLength:c?c.length:0):_,m=t.prev,g=void 0===m?null:m,v=t.next,y=void 0===v?null:v,b=t.eof,T=void 0!==b&&b,k=t.empty,P=void 0===k?!(u||c):k,w=t.timestamp,E=void 0===w?Date.now():w;_classCallCheck(this,CacheItem),this.start=h,this.end=p,this.prev=g,this.next=y,this.eof=T,this.empty=P,this.timestamp=E,this.buffer=u,this.string=c,Object.defineProperty(this,"length",{get:function get(){return this.end-this.start}})}return i(CacheItem,[{key:"contains",value:function contains(t){return t>=this.start&&(t{"use strict";var d=function(){function defineProperties(t,i){for(var u=0;u0&&void 0!==arguments[0]?arguments[0]:{},i=t.cacheSize,u=void 0===i?0:i;_classCallCheck(this,CachePool);var d=new c({eof:!0});this.head=d,this.tail=d,this.readOffset=0,this.readCursor=d,this.writeOffset=0,this.writeCursor=d,this.cacheSize=u}return d(CachePool,[{key:"bytesReadable",value:function bytesReadable(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1/0,i=this.readOffset,u=this.readCursor,d=u.last((function(u){return!u.empty&&u.start<=i+t}));return d?Math.min(t,d.end-i):0}},{key:"bytesWritable",value:function bytesWritable(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1/0,i=this.writeOffset,u=this.writeCursor;if(u.eof)return t;var d=u.last((function(u){return u.empty&&u.start<=i+t}));return d?Math.min(t,d.end-i):0}},{key:"seekRead",value:function seekRead(t){var i=this.head.first((function(i){return i.contains(t)}));if(!i)throw new Error("read seek out of range");this.readOffset=t,this.readCursor=i}},{key:"seekWrite",value:function seekWrite(t){var i=this.head.first((function(i){return i.contains(t)}));if(!i)throw new Error("write seek out of range");this.writeOffset=t,this.writeCursor=i}},{key:"readBytes",value:function readBytes(t){for(var i=t.byteLength,u=this.bytesReadable(i),d=this.readOffset,c=d+u,l=d,h=this.readCursor;h&&!h.empty&&!(h.start>=c);h=h.next){var _=Math.min(c,h.end),p=t.subarray(l-d,_-d);h.readBytes(p,l,_),l=_}return this.readOffset=l,this.readCursor=this.readCursor.first((function(t){return t.contains(l)})),u}},{key:"write",value:function write(t){var i=this.bufferItem(t),u=this.writeCursor;if(!u.empty)throw new Error("write cursor not empty");if(!u.contains(i.end)&&u.end!==i.end)throw new Error("write cursor too small");u.startthis.readOffset+this.chunkSize)&&i.push(u));if(t>this.cacheSize){i.sort((function(t,i){return t.timestamp-i.timestamp}));for(var d=0;d{"use strict";t.exports=u(91)},566:t=>{"use strict";var i=function(){function defineProperties(t,i){for(var u=0;u=0&&u.splice(d,1)}},{key:"emit",value:function emit(t,i){(this._e[t]||[]).slice().forEach((function(t){return t(i)}))}}]),TinyEvents}();t.exports=u},936:(t,i,u)=>{"use strict";var d=function(){function defineProperties(t,i){for(var u=0;u=0&&_>=t.length)return void i(null);var p=t._clampToLength(d.writeOffset+d.bytesWritable(c))-d.writeOffset;if(0===p)i(null);else{var m=t._backend=new l({url:t.url,offset:t._cache.writeOffset,length:p,cachever:t._cachever,progressive:t.progressive}),g=null,v=function checkOpen(){m!==t._backend?(g(),u(new Error("invalid state"))):(m.on("buffer",(function(i){m===t._backend&&t._cache.write(i)})),m.on("done",(function(){m===t._backend&&(-1===t.length&&(t.length=t._backend.offset+t._backend.bytesRead),t._backend=null)})),i(m))},y=function checkError(i){m!==t._backend?u(new Error("invalid state")):(t._backend=null,u(i))};g=function oncomplete(){m.off("open",v),m.off("error",y)},m.on("open",v),m.on("error",y),m.on("cachever",(function(){t._cachever++})),m.load()}}}))}},{key:"_readAhead",value:function _readAhead(){var t=this;return new Promise((function(i,u){t._backend||t.eof?i():t._openBackend().then((function(){i()})).catch((function(t){u(t)}))}))}},{key:"seek",value:function seek(t){var i=this;return new Promise((function(u,d){if(!i.loaded||i.buffering||i.seeking)throw new Error("invalid state");if(t!==(0|t)||t<0)throw new Error("invalid input");if(i.length>=0&&t>i.length)throw new Error("seek past end of file");if(!i.seekable)throw new Error("seek on non-seekable stream");i._backend&&i.abort(),i._cache.seekRead(t),i._cache.seekWrite(t),i._readAhead().then(u).catch(d)}))}},{key:"read",value:function read(t){var i=this;return this.buffer(t).then((function(t){return i.readSync(t)}))}},{key:"readSync",value:function readSync(t){var i=this.bytesAvailable(t),u=new Uint8Array(i);if(this.readBytes(u)!==i)throw new Error("failed to read expected data");return u.buffer}},{key:"readBytes",value:function readBytes(t){if(!this.loaded||this.buffering||this.seeking)throw new Error("invalid state");if(!(t instanceof Uint8Array))throw new Error("invalid input");var i=this._cache.readBytes(t);return this._readAhead(),i}},{key:"buffer",value:function buffer(t){var i=this;return new Promise((function(u,d){if(!i.loaded||i.buffering||i.seeking)throw new Error("invalid state");if(t!==(0|t)||t<0)throw new Error("invalid input");var c=i._clampToLength(i.offset+t),l=c-i.offset,h=i.bytesAvailable(l);h>=l?u(h):(i.buffering=!0,i._openBackend().then((function(u){return u?u.bufferToOffset(c).then((function(){return i.buffering=!1,i.buffer(t)})):Promise.resolve(h)})).then((function(t){i.buffering=!1,u(t)})).catch((function(t){"AbortError"!==t.name&&(i.buffering=!1),d(t)})))}))}},{key:"bytesAvailable",value:function bytesAvailable(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1/0;return this._cache.bytesReadable(t)}},{key:"abort",value:function abort(){this.loading&&(this.loading=!1),this.buffering&&(this.buffering=!1),this.seeking&&(this.seeking=!1),this._backend&&(this._backend.abort(),this._backend=null)}},{key:"getBufferedRanges",value:function getBufferedRanges(){return this._cache.ranges()}},{key:"_clampToLength",value:function _clampToLength(t){return this.length<0?t:Math.min(this.length,t)}}]),StreamFile}();t.exports=h},826:t=>{t.exports={vertex:"precision lowp float;\n\nattribute vec2 aPosition;\nattribute vec2 aLumaPosition;\nattribute vec2 aChromaPosition;\nvarying vec2 vLumaPosition;\nvarying vec2 vChromaPosition;\nvoid main() {\n gl_Position = vec4(aPosition, 0, 1);\n vLumaPosition = aLumaPosition;\n vChromaPosition = aChromaPosition;\n}\n",fragment:"// inspired by https://github.com/mbebenita/Broadway/blob/master/Player/canvas.js\n\nprecision lowp float;\n\nuniform sampler2D uTextureY;\nuniform sampler2D uTextureCb;\nuniform sampler2D uTextureCr;\nvarying vec2 vLumaPosition;\nvarying vec2 vChromaPosition;\nvoid main() {\n // Y, Cb, and Cr planes are uploaded as LUMINANCE textures.\n float fY = texture2D(uTextureY, vLumaPosition).x;\n float fCb = texture2D(uTextureCb, vChromaPosition).x;\n float fCr = texture2D(uTextureCr, vChromaPosition).x;\n\n // Premultipy the Y...\n float fYmul = fY * 1.1643828125;\n\n // And convert that to RGB!\n gl_FragColor = vec4(\n fYmul + 1.59602734375 * fCr - 0.87078515625,\n fYmul - 0.39176171875 * fCb - 0.81296875 * fCr + 0.52959375,\n fYmul + 2.017234375 * fCb - 1.081390625,\n 1\n );\n}\n",vertexStripe:"precision lowp float;\n\nattribute vec2 aPosition;\nattribute vec2 aTexturePosition;\nvarying vec2 vTexturePosition;\n\nvoid main() {\n gl_Position = vec4(aPosition, 0, 1);\n vTexturePosition = aTexturePosition;\n}\n",fragmentStripe:"// extra 'stripe' texture fiddling to work around IE 11's poor performance on gl.LUMINANCE and gl.ALPHA textures\n\nprecision lowp float;\n\nuniform sampler2D uStripe;\nuniform sampler2D uTexture;\nvarying vec2 vTexturePosition;\nvoid main() {\n // Y, Cb, and Cr planes are mapped into a pseudo-RGBA texture\n // so we can upload them without expanding the bytes on IE 11\n // which doesn't allow LUMINANCE or ALPHA textures\n // The stripe textures mark which channel to keep for each pixel.\n // Each texture extraction will contain the relevant value in one\n // channel only.\n\n float fLuminance = dot(\n texture2D(uStripe, vTexturePosition),\n texture2D(uTexture, vTexturePosition)\n );\n\n gl_FragColor = vec4(fLuminance, fLuminance, fLuminance, 1);\n}\n"}},487:t=>{!function(){"use strict";function FrameSink(t,i){throw new Error("abstract")}FrameSink.prototype.drawFrame=function(t){throw new Error("abstract")},FrameSink.prototype.clear=function(){throw new Error("abstract")},t.exports=FrameSink}()},926:(t,i,u)=>{!function(){"use strict";var i=u(487),d=u(627);function SoftwareFrameSink(t){var i=this,u=t.getContext("2d"),c=null,l=null,h=null;return i.drawFrame=function drawFrame(i){var _=i.format;t.width===_.displayWidth&&t.height===_.displayHeight||(t.width=_.displayWidth,t.height=_.displayHeight),null!==c&&c.width==_.width&&c.height==_.height||function initImageData(t,i){for(var d=(c=u.createImageData(t,i)).data,l=t*i*4,h=0;h{!function(){"use strict";var i=u(487),d=u(826);function WebGLFrameSink(t){var i,u,c=this,l=WebGLFrameSink.contextForCanvas(t);if(null===l)throw new Error("WebGL unavailable");function compileShader(t,i){var u=l.createShader(t);if(l.shaderSource(u,i),l.compileShader(u),!l.getShaderParameter(u,l.COMPILE_STATUS)){var d=l.getShaderInfoLog(u);throw l.deleteShader(u),new Error("GL shader compilation for "+t+" failed: "+d)}return u}var h,_,p,m,g,v,y,b,T,k,P=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),w={},E={},x={};function createOrReuseTexture(t,i){return w[t]&&!i||(w[t]=l.createTexture()),w[t]}function uploadTexture(t,i,u,d,c){var h=createOrReuseTexture(t,i);if(l.activeTexture(l.TEXTURE0),WebGLFrameSink.stripe){var _=!w[t+"_temp"]||i,p=createOrReuseTexture(t+"_temp",i);l.bindTexture(l.TEXTURE_2D,p),_?(l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.NEAREST),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.NEAREST),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,u/4,d,0,l.RGBA,l.UNSIGNED_BYTE,c)):l.texSubImage2D(l.TEXTURE_2D,0,0,0,u/4,d,l.RGBA,l.UNSIGNED_BYTE,c);var m=w[t+"_stripe"],g=!m||i;g&&(m=createOrReuseTexture(t+"_stripe",i)),l.bindTexture(l.TEXTURE_2D,m),g&&(l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.NEAREST),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.NEAREST),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,u,1,0,l.RGBA,l.UNSIGNED_BYTE,function buildStripe(t){if(x[t])return x[t];for(var i=t,u=new Uint32Array(i),d=0;d{!function(){"use strict";var i=u(877);t.exports={convertYCbCr:function convertYCbCr(t,u){var d=0|t.format.width,c=0|t.format.height,l=0|i(t.format.width/t.format.chromaWidth),h=0|i(t.format.height/t.format.chromaHeight),_=t.y.bytes,p=t.u.bytes,m=t.v.bytes,g=0|t.y.stride,v=0|t.u.stride,y=0|t.v.stride,b=d<<2,T=0,k=0,P=0,w=0,E=0,x=0,A=0,R=0,O=0,S=0,C=0,B=0,D=0,M=0,V=0,I=0,L=0,j=0;if(1==l&&1==h)for(A=0,R=b,j=0,I=0;I>8,u[A+1]=C-D>>8,u[A+2]=C+M>>8,A+=4,C=298*_[k++]|0,u[A]=C+B>>8,u[A+1]=C-D>>8,u[A+2]=C+M>>8,A+=4,C=298*_[P++]|0,u[R]=C+B>>8,u[R+1]=C-D>>8,u[R+2]=C+M>>8,R+=4,C=298*_[P++]|0,u[R]=C+B>>8,u[R+1]=C-D>>8,u[R+2]=C+M>>8,R+=4;A+=b,R+=b,j++}else for(x=0,I=0;I>h)*v|0,E=j*y|0,V=0;V>l)],B=(409*(S=0|m[E+L])|0)-57088|0,D=(100*O|0)+(208*S|0)-34816|0,M=(516*O|0)-70912|0,C=298*_[T++]|0,u[x]=C+B>>8,u[x+1]=C-D>>8,u[x+2]=C+M>>8,x+=4}}}()},877:t=>{!function(){"use strict";t.exports=function depower(t){for(var i=0,u=t>>1;0!=u;)u>>=1,i++;if(t!==1<{!function(){"use strict";var i=u(487),d=u(926),c=u(895),l={FrameSink:i,SoftwareFrameSink:d,WebGLFrameSink:c,attach:function(t,i){return("webGL"in(i=i||{})?i.webGL:c.isAvailable())?new c(t,i):new d(t,i)}};t.exports=l}()}},i={};function __webpack_require__(u){var d=i[u];if(void 0!==d)return d.exports;var c=i[u]={exports:{}};return t[u](c,c.exports,__webpack_require__),c.exports}var u={};return(()=>{"use strict";var t=u,i=__webpack_require__(318);Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"OGVCompat",{enumerable:!0,get:function get(){return c.default}}),Object.defineProperty(t,"OGVLoader",{enumerable:!0,get:function get(){return l.default}}),Object.defineProperty(t,"OGVMediaError",{enumerable:!0,get:function get(){return h.default}}),Object.defineProperty(t,"OGVMediaType",{enumerable:!0,get:function get(){return _.default}}),Object.defineProperty(t,"OGVPlayer",{enumerable:!0,get:function get(){return p.default}}),Object.defineProperty(t,"OGVTimeRanges",{enumerable:!0,get:function get(){return m.default}}),t.OGVVersion=void 0;var d=i(__webpack_require__(8)),c=i(__webpack_require__(523)),l=i(__webpack_require__(964)),h=i(__webpack_require__(759)),_=i(__webpack_require__(278)),p=i(__webpack_require__(869)),m=i(__webpack_require__(168)),g="1.8.6-20220111172545-1f60d9d";t.OGVVersion=g,"object"===("undefined"==typeof window?"undefined":(0,d.default)(window))&&(window.OGVCompat=c.default,window.OGVLoader=l.default,window.OGVMediaError=h.default,window.OGVMediaType=_.default,window.OGVTimeRanges=m.default,window.OGVPlayer=p.default,window.OGVVersion=g)})(),u})()}));
\ No newline at end of file
diff --git a/package.json b/package.json
index a69274015..7d25f7fdf 100644
--- a/package.json
+++ b/package.json
@@ -14,7 +14,6 @@
"fast-sha256": "^1.3.0",
"libsodium": "^0.7.9",
"libsodium-wrappers": "^0.7.9",
- "ogv": "^1.8.6",
"ts-proto": "^1.101.0",
"zstddec": "^0.0.2"
}
diff --git a/src/codec.js b/src/codec.js
index da4f0cbdb..6dc7db92a 100644
--- a/src/codec.js
+++ b/src/codec.js
@@ -1,4 +1,5 @@
// example: https://github.com/rgov/js-theora-decoder/blob/main/index.html
+// https://github.com/brion/ogv.js/releases, yarn add has no simd
// dev: copy decoder files from node/ogv/dist/* to project dir
// dist: .... to dist
/*
@@ -20,8 +21,12 @@
*/
export function loadVp9(callback) {
+ // Multithreading is used only if `options.threading` is true.
+ // This requires browser support for the new `SharedArrayBuffer` and `Atomics` APIs,
+ // currently available in Firefox and Chrome with experimental flags enabled.
+ // 所有主流浏览器均默认于2018年1月5日禁用SharedArrayBuffer
window.OGVLoader.loadClass(
- "OGVDecoderVideoVP9W",
+ "OGVDecoderVideoVP9SIMDW",
(videoCodecClass) => {
window.videoCodecClass = videoCodecClass;
videoCodecClass({ videoFormat: {} }).then((decoder) => {
@@ -30,7 +35,7 @@ export function loadVp9(callback) {
})
})
},
- { worker: true }
+ { worker: true, threading: true }
);
}
diff --git a/src/common.ts b/src/common.ts
index 2f1516042..0355d3607 100644
--- a/src/common.ts
+++ b/src/common.ts
@@ -45,12 +45,11 @@ export function translate(locale: string, text: string): string {
const zCode = "z".charCodeAt(0);
const aCode = "a".charCodeAt(0);
-export function mapKey(name: string) {
+export function mapKey(name: string, isDesktop: Boolean) {
const tmp = KEY_MAP[name];
- if (!tmp) return undefined;
if (tmp.length == 1) {
const chr = tmp.charCodeAt(0);
- if (chr > zCode || chr < aCode)
+ if (!isDesktop && (chr > zCode || chr < aCode))
return KeyEvent.fromPartial({ unicode: chr });
else return KeyEvent.fromPartial({ chr });
}
diff --git a/src/connection.ts b/src/connection.ts
index c0e4138ba..6f75498c0 100644
--- a/src/connection.ts
+++ b/src/connection.ts
@@ -27,12 +27,14 @@ export default class Connection {
_audioDecoder: any;
_password: Uint8Array | undefined;
_options: any;
+ _videoTestSpeed: number[];
constructor() {
this._msgbox = globals.msgbox;
this._draw = globals.draw;
this._msgs = [];
this._id = "";
+ this._videoTestSpeed = [0, 0];
}
async start(id: string) {
@@ -58,7 +60,7 @@ export default class Connection {
this.loadVideoDecoder();
this.loadAudioDecoder();
const uri = getDefaultUri();
- const ws = new Websock(uri);
+ const ws = new Websock(uri, true);
this._ws = ws;
this._id = id;
console.log(
@@ -75,7 +77,7 @@ export default class Connection {
nat_type,
});
ws.sendRendezvous({ punch_hole_request });
- const msg = ws.parseRendezvous(await ws.next());
+ const msg = (await ws.next()) as rendezvous.RendezvousMessage;
ws.close();
console.log(new Date() + ": Got relay response");
const phr = msg.punch_hole_response;
@@ -113,7 +115,7 @@ export default class Connection {
}
const uuid = rr.uuid;
console.log(new Date() + ": Connecting to relay server: " + uri);
- const ws = new Websock(uri);
+ const ws = new Websock(uri, false, this.handleVideoFrame.bind(this));
await ws.open();
console.log(new Date() + ": Connected to relay server");
this._ws = ws;
@@ -149,7 +151,7 @@ export default class Connection {
this._ws?.sendMessage({});
return;
}
- const msg = this._ws?.parseMessage(await this._ws?.next());
+ const msg = (await this._ws?.next()) as message.Message;
let signedId: any = msg?.signed_id;
if (!signedId) {
console.error("Handshake failed: invalid message type");
@@ -198,7 +200,7 @@ export default class Connection {
async msgLoop() {
while (true) {
- const msg = this._ws?.parseMessage(await this._ws?.next());
+ const msg = (await this._ws?.next()) as message.Message;
if (msg?.hash) {
this._hash = msg?.hash;
if (!this._password)
@@ -251,6 +253,7 @@ export default class Connection {
draw(frame: any) {
this._draw?.(frame);
+ globals.draw(frame);
}
close() {
@@ -305,6 +308,7 @@ export default class Connection {
my_name: "web", // to-do
password,
option: this.getOptionMessage(),
+ video_ack_required: true,
});
this._ws?.sendMessage({ login_request });
}
@@ -341,6 +345,11 @@ export default class Connection {
return n > 0 ? msg : undefined;
}
+ sendVideoReceived() {
+ const misc = message.Misc.fromPartial({ video_received: true });
+ this._ws?.sendMessage({ misc });
+ }
+
handleVideoFrame(vf: message.VideoFrame) {
if (!this._firstFrame) {
this.msgbox("", "", "");
@@ -348,11 +357,28 @@ export default class Connection {
}
if (vf.vp9s) {
const dec = this._videoDecoder;
- // dec.sync();
+ var tm = new Date().getTime();
+ var i = 0;
+ const n = vf.vp9s?.frames.length;
vf.vp9s.frames.forEach((f) => {
dec.processFrame(f.data.slice(0).buffer, (ok: any) => {
- if (ok && dec.frameBuffer) {
+ i++;
+ if (i == n) this.sendVideoReceived();
+ if (ok && dec.frameBuffer && n == i) {
this.draw(dec.frameBuffer);
+ const now = new Date().getTime();
+ var elapsed = now - tm;
+ this._videoTestSpeed[1] += elapsed;
+ this._videoTestSpeed[0] += 1;
+ if (this._videoTestSpeed[0] >= 30) {
+ console.log(
+ "video decoder: " +
+ parseInt(
+ "" + this._videoTestSpeed[1] / this._videoTestSpeed[0]
+ )
+ );
+ this._videoTestSpeed = [0, 0];
+ }
}
});
});
@@ -398,6 +424,8 @@ export default class Connection {
handleMisc(misc: message.Misc) {
if (misc.audio_format) {
//
+ } else if (misc.chat_message) {
+ globals.pushEvent("chat", misc.chat_message.text);
} else if (misc.permission_info) {
const p = misc.permission_info;
console.info("Change permission " + p.permission + " -> " + p.enabled);
@@ -457,18 +485,18 @@ export default class Connection {
shift: Boolean,
command: Boolean
) {
- const key_event = mapKey(name);
+ const key_event = mapKey(name, globals.isDesktop());
if (!key_event) return;
- if (alt && name == 'VK_MENU') {
+ if (alt && name == "VK_MENU") {
alt = false;
}
- if (ctrl && name == 'VK_CONTROL') {
+ if (ctrl && name == "VK_CONTROL") {
ctrl = false;
}
- if (shift && name == 'VK_SHIFT') {
+ if (shift && name == "VK_SHIFT") {
shift = false;
}
- if (command && name == 'Meta') {
+ if (command && name == "Meta") {
command = false;
}
key_event.down = down;
@@ -581,9 +609,9 @@ export default class Connection {
const misc = message.Misc.fromPartial({ option });
this._ws?.sendMessage({ misc });
}
-
+
getImageQuality() {
- return this.getOption('image-quality');
+ return this.getOption("image-quality");
}
getImageQualityEnum(
@@ -631,7 +659,7 @@ export default class Connection {
// @ts-ignore
async function testDelay() {
- const ws = new Websock(getDefaultUri(false));
+ const ws = new Websock(getDefaultUri(false), true);
await ws.open();
console.log(ws.latency());
}
diff --git a/src/gen_js_from_hbb.ts b/src/gen_js_from_hbb.ts
index 1a53133bc..eab602cca 100644
--- a/src/gen_js_from_hbb.ts
+++ b/src/gen_js_from_hbb.ts
@@ -684,12 +684,12 @@ export const KEY_MAP: any = {
"VK_RBRACKET": "]",
"VK_BACKSLASH": "\\",
"VK_MINUS": "-",
- "VK_PLUS": "= // it is =, but sciter return VK_PLUS",
- "VK_DIVIDE": "Divide // numpad",
- "VK_MULTIPLY": "Multiply // numpad",
- "VK_SUBTRACT": "Subtract // numpad",
- "VK_ADD": "Add // numpad",
- "VK_DECIMAL": "Decimal // numpad",
+ "VK_PLUS": "=",
+ "VK_DIVIDE": "Divide",
+ "VK_MULTIPLY": "Multiply",
+ "VK_SUBTRACT": "Subtract",
+ "VK_ADD": "Add",
+ "VK_DECIMAL": "Decimal",
"VK_F1": "F1",
"VK_F2": "F2",
"VK_F3": "F3",
diff --git a/src/globals.js b/src/globals.js
index f67703cd1..78f029043 100644
--- a/src/globals.js
+++ b/src/globals.js
@@ -14,12 +14,15 @@ window.getRgba = () => {
currentFrame = undefined;
return tmp || null;
}
-window.getLanguage = () => navigator.language;
window.isMobile = () => {
return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)
|| /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0, 4));
}
+export function isDesktop() {
+ return !isMobile;
+}
+
export function msgbox(type, title, text) {
if (!events) return;
if (!type || (type == 'error' && !text)) return;
@@ -297,4 +300,4 @@ export function getPeers() {
} catch (e) {
return {};
}
-}
\ No newline at end of file
+}
diff --git a/src/message.ts b/src/message.ts
index 6f338f12e..22b3198fd 100644
--- a/src/message.ts
+++ b/src/message.ts
@@ -642,6 +642,7 @@ export interface LoginRequest {
option: OptionMessage | undefined;
file_transfer: FileTransfer | undefined;
port_forward: PortForward | undefined;
+ video_ack_required: boolean;
}
export interface ChatMessage {
@@ -944,6 +945,7 @@ export interface Misc {
close_reason: string | undefined;
refresh_video: boolean | undefined;
option_response: OptionResponse | undefined;
+ video_received: boolean | undefined;
}
export interface Message {
@@ -1521,6 +1523,7 @@ function createBaseLoginRequest(): LoginRequest {
option: undefined,
file_transfer: undefined,
port_forward: undefined,
+ video_ack_required: false,
};
}
@@ -1556,6 +1559,9 @@ export const LoginRequest = {
writer.uint32(66).fork()
).ldelim();
}
+ if (message.video_ack_required === true) {
+ writer.uint32(72).bool(message.video_ack_required);
+ }
return writer;
},
@@ -1587,6 +1593,9 @@ export const LoginRequest = {
case 8:
message.port_forward = PortForward.decode(reader, reader.uint32());
break;
+ case 9:
+ message.video_ack_required = reader.bool();
+ break;
default:
reader.skipType(tag & 7);
break;
@@ -1612,6 +1621,9 @@ export const LoginRequest = {
port_forward: isSet(object.port_forward)
? PortForward.fromJSON(object.port_forward)
: undefined,
+ video_ack_required: isSet(object.video_ack_required)
+ ? Boolean(object.video_ack_required)
+ : false,
};
},
@@ -1636,6 +1648,8 @@ export const LoginRequest = {
(obj.port_forward = message.port_forward
? PortForward.toJSON(message.port_forward)
: undefined);
+ message.video_ack_required !== undefined &&
+ (obj.video_ack_required = message.video_ack_required);
return obj;
},
@@ -1659,6 +1673,7 @@ export const LoginRequest = {
object.port_forward !== undefined && object.port_forward !== null
? PortForward.fromPartial(object.port_forward)
: undefined;
+ message.video_ack_required = object.video_ack_required ?? false;
return message;
},
};
@@ -4466,6 +4481,7 @@ function createBaseMisc(): Misc {
close_reason: undefined,
refresh_video: undefined,
option_response: undefined,
+ video_received: undefined,
};
}
@@ -4510,6 +4526,9 @@ export const Misc = {
writer.uint32(90).fork()
).ldelim();
}
+ if (message.video_received !== undefined) {
+ writer.uint32(96).bool(message.video_received);
+ }
return writer;
},
@@ -4553,6 +4572,9 @@ export const Misc = {
reader.uint32()
);
break;
+ case 12:
+ message.video_received = reader.bool();
+ break;
default:
reader.skipType(tag & 7);
break;
@@ -4587,6 +4609,9 @@ export const Misc = {
option_response: isSet(object.option_response)
? OptionResponse.fromJSON(object.option_response)
: undefined,
+ video_received: isSet(object.video_received)
+ ? Boolean(object.video_received)
+ : undefined,
};
},
@@ -4620,6 +4645,8 @@ export const Misc = {
(obj.option_response = message.option_response
? OptionResponse.toJSON(message.option_response)
: undefined);
+ message.video_received !== undefined &&
+ (obj.video_received = message.video_received);
return obj;
},
@@ -4651,6 +4678,7 @@ export const Misc = {
object.option_response !== undefined && object.option_response !== null
? OptionResponse.fromPartial(object.option_response)
: undefined;
+ message.video_received = object.video_received ?? undefined;
return message;
},
};
diff --git a/src/ui.js b/src/ui.js
index 4402d7400..b76824ba6 100644
--- a/src/ui.js
+++ b/src/ui.js
@@ -51,6 +51,7 @@ if (app) {
const conn = globals.newConn();
conn.setMsgbox(msgbox);
conn.setDraw((f) => {
+ globals.draw(f);
player.drawFrame(f);
});
document.querySelector('div#status').style.display = 'block';
diff --git a/src/websock.ts b/src/websock.ts
index 71b84fba4..d5652895d 100644
--- a/src/websock.ts
+++ b/src/websock.ts
@@ -7,13 +7,19 @@ type Keys = "message" | "open" | "close" | "error";
export default class Websock {
_websocket: WebSocket;
_eventHandlers: { [key in Keys]: Function };
- _buf: Uint8Array[];
+ _buf: (rendezvous.RendezvousMessage | message.Message)[];
_status: any;
_latency: number;
_secretKey: [Uint8Array, number, number] | undefined;
_uri: string;
+ _isRendezvous: boolean;
+ _videoCallback: ((v: message.VideoFrame) => void) | undefined;
- constructor(uri: string) {
+ constructor(
+ uri: string,
+ isRendezvous: boolean = true,
+ fn: ((v: message.VideoFrame) => void) | undefined = undefined
+ ) {
this._eventHandlers = {
message: (_: any) => {},
open: () => {},
@@ -27,6 +33,8 @@ export default class Websock {
this._websocket.onmessage = this._recv_message.bind(this);
this._websocket.binaryType = "arraybuffer";
this._latency = new Date().getTime();
+ this._isRendezvous = isRendezvous;
+ this._videoCallback = fn;
}
latency(): number {
@@ -98,7 +106,7 @@ export default class Websock {
this._websocket.onclose = (e) => {
if (this._status == "open") {
// e.code 1000 means that the connection was closed normally.
- reject('Reset by the peer');
+ reject("Reset by the peer");
}
this._status = e;
console.error("WebSock.onclose: " + e);
@@ -112,14 +120,16 @@ export default class Websock {
this._status = e;
console.error("WebSock.onerror: " + e);
this._eventHandlers.error(e);
- reject(e['data']);
+ reject(e["data"]);
};
});
}
- async next(timeout = 12000): Promise {
+ async next(
+ timeout = 12000
+ ): Promise {
const func = (
- resolve: (value: Uint8Array) => void,
+ resolve: (value: rendezvous.RendezvousMessage | message.Message) => void,
reject: (reason: any) => void,
tm0: number
) => {
@@ -166,7 +176,16 @@ export default class Websock {
k[2] += 1;
bytes = globals.decrypt(bytes, k[2], k[0]);
}
- this._buf.push(bytes);
+ if (this._isRendezvous) {
+ this._buf.push(this.parseRendezvous(bytes));
+ } else {
+ const m = this.parseMessage(bytes);
+ if (this._videoCallback && m.video_frame) {
+ this._videoCallback(m.video_frame);
+ } else {
+ this._buf.push(m);
+ }
+ }
}
this._eventHandlers.message(e.data);
}
diff --git a/yarn.lock b/yarn.lock
index c8e30b076..27da14f94 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2,13 +2,6 @@
# yarn lockfile v1
-"@babel/runtime@^7.16.7":
- version "7.16.7"
- resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.16.7.tgz#03ff99f64106588c9c403c6ecb8c3bafbbdff1fa"
- integrity sha512-9E9FJowqAsytyOY6LG+1KuueckRL+aQW+mKvXRXnuFGyRAyepJPmEo9vgMfXUA6O9u3IeEdv9MAkppFcaQwogQ==
- dependencies:
- regenerator-runtime "^0.13.4"
-
"@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf"
@@ -251,13 +244,6 @@ object-hash@^1.3.1:
resolved "https://registry.yarnpkg.com/object-hash/-/object-hash-1.3.1.tgz#fde452098a951cb145f039bb7d455449ddc126df"
integrity sha512-OSuu/pU4ENM9kmREg0BdNrUDIl1heYa4mBZacJc+vVWz4GtAwu7jO8s4AIt2aGRUTqxykpWzI3Oqnsm13tTMDA==
-ogv@^1.8.6:
- version "1.8.6"
- resolved "https://registry.yarnpkg.com/ogv/-/ogv-1.8.6.tgz#0e6fa1c166802e3a405b1b318d8eb27d2544cce9"
- integrity sha512-YuvO37U7Hc0mIm/TyAbyn3qVDKgg+4b+ViU73qEGzEKVX8bdxEVH08SoYrGLTJ2b8Z1/IEx8Vdy0hO4CWhRMOA==
- dependencies:
- "@babel/runtime" "^7.16.7"
-
path-parse@^1.0.7:
version "1.0.7"
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735"
@@ -301,11 +287,6 @@ protobufjs@^6.8.8:
"@types/node" ">=13.7.0"
long "^4.0.0"
-regenerator-runtime@^0.13.4:
- version "0.13.9"
- resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52"
- integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==
-
resolve@^1.20.0:
version "1.21.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.21.0.tgz#b51adc97f3472e6a5cf4444d34bc9d6b9037591f"
diff --git a/yuv.js b/yuv.js
index 65199f3a8..35feb485e 100644
--- a/yuv.js
+++ b/yuv.js
@@ -11,7 +11,6 @@ var yPtr, yPtrLen, uPtr, uPtrLen, vPtr, vPtrLen, outPtr, outPtrLen;
let testSpeed = [0, 0];
function I420ToARGB(yb) {
if (!wasmExports) return;
- testSpeed[0] += 1;
var tm0 = new Date().getTime();
var { malloc, free, memory } = wasmExports;
var HEAPU8 = new Uint8Array(memory.buffer);
@@ -50,8 +49,9 @@ function I420ToARGB(yb) {
var res = wasmExports.yuv420_rgb24_std(w, h, yPtr, uPtr, vPtr, yb.y.stride, yb.v.stride, outPtr, w * 4, 1);
var out = HEAPU8.slice(outPtr, outPtr + n);
testSpeed[1] += new Date().getTime() - tm0;
+ testSpeed[0] += 1;
if (testSpeed[0] > 30) {
- console.log(testSpeed[1] / testSpeed[0]);
+ console.log('yuv: ' + parseInt('' + testSpeed[1] / testSpeed[0]));
testSpeed = [0, 0];
}
return out;
diff --git a/yuv_rgb.c b/yuv_rgb.c
index 9ac3b4bae..fb4a703d1 100644
--- a/yuv_rgb.c
+++ b/yuv_rgb.c
@@ -7,6 +7,9 @@
//
#include
+typedef __i64x2 __m128i;
+#define _mm_load_si128 wasm_v128_load
+
#include