ogv
Version:
WebAssembly media player using Ogg/Vorbis/Theora/Opus/WebM libs compiled with Emscripten
2 lines • 115 kB
JavaScript
/*! For license information please see ogv-es2017.js.LICENSE.txt */
!function webpackUniversalModuleDefinition(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ogvjs=t():e.ogvjs=t()}(globalThis,(function(){return(()=>{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},848:e=>{window,e.exports=function(e){var t={};function r(i){if(t[i])return t[i].exports;var s=t[i]={i,l:!1,exports:{}};return e[i].call(s.exports,s,s.exports,r),s.l=!0,s.exports}return r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)r.d(i,s,function(t){return e[t]}.bind(null,s));return i},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(e,t){function r(e,t){if(e<1||e!==Math.round(e))throw"Invalid channel count for BufferQueue";this.channels=e,this.bufferSize=t,this.flush()}r.prototype.flush=function(){this._buffers=[],this._pendingBuffer=this.createBuffer(this.bufferSize),this._pendingPos=0},r.prototype.sampleCount=function(){var e=0;return this._buffers.forEach((function(t){e+=t[0].length})),e},r.prototype.createBuffer=function(e){for(var t=[],i=0;i<this.channels;i++)t[i]=new Float32Array(e);return t},r.prototype.validate=function(e){if(e.length!==this.channels)return!1;for(var t,i=0;i<e.length;i++){var s=e[i];if(!(s instanceof Float32Array))return!1;if(0==i)t=s.length;else if(s.length!==t)return!1}return!0},r.prototype.appendBuffer=function(e){if(!this.validate(e))throw"Invalid audio buffer passed to BufferQueue.appendBuffer";for(var t=e[0].length,i=this.channels,s=this._pendingPos,d=this._pendingBuffer,h=this.bufferSize,u=0;u<t;u++){for(var c=0;c<i;c++)d[c][s]=e[c][u];++s==h&&(this._buffers.push(d),s=this._pendingPos=0,d=this._pendingBuffer=this.createBuffer(h))}this._pendingPos=s},r.prototype.prependBuffer=function(e){if(!this.validate(e))throw"Invalid audio buffer passed to BufferQueue.prependBuffer";var t=this._buffers.slice(0);t.push(this.trimBuffer(this._pendingBuffer,0,this._pendingPos)),this.flush(),this.appendBuffer(e);for(var i=0;i<t.length;i++)this.appendBuffer(t[i])},r.prototype.nextBuffer=function(){if(this._buffers.length)return this._buffers.shift();var e=this.trimBuffer(this._pendingBuffer,0,this._pendingPos);return this._pendingBuffer=this.createBuffer(this.bufferSize),this._pendingPos=0,e},r.prototype.trimBuffer=function(e,t,i){var s=e[0].length,d=t+Math.min(i,s);if(0==t&&d>=s)return e;for(var h=[],u=0;u<this.channels;u++)h[u]=e[u].subarray(t,d);return h},e.exports=r},function(e,t,i){!function(){i(0);var t=i(2),s=i(4);function n(e){this._options=e||{},this._backend=null,this._resampleFractional=0,this._resampleLastSampleData=void 0,this._tempoChanger=null}n.prototype.rate=0,n.prototype.targetRate=0,n.prototype.channels=0,n.prototype.bufferSize=0,Object.defineProperty(n.prototype,"bufferDuration",{get:function(){return this.targetRate?this.bufferSize/this.targetRate:0}}),Object.defineProperty(n.prototype,"bufferThreshold",{get:function(){return this._backend?this._backend.bufferThreshold/this.targetRate:0},set:function(e){if(!this._backend)throw"Invalid state: AudioFeeder cannot set bufferThreshold before init";this._backend.bufferThreshold=Math.round(e*this.targetRate)}}),Object.defineProperty(n.prototype,"playbackPosition",{get:function(){return this._backend?this.getPlaybackState().playbackPosition:0}}),Object.defineProperty(n.prototype,"outputPlaybackPosition",{get:function(){return this._backend?this.getPlaybackState().outputPlaybackPosition:0}}),Object.defineProperty(n.prototype,"durationBuffered",{get:function(){return this._backend?this.getPlaybackState().samplesQueued/this.targetRate:0}}),Object.defineProperty(n.prototype,"muted",{get:function(){if(this._backend)return this._backend.muted;throw"Invalid state: cannot get mute before init"},set:function(e){if(!this._backend)throw"Invalid state: cannot set mute before init";this._backend.muted=e}}),n.prototype.mute=function(){this.muted=!0},n.prototype.unmute=function(){this.muted=!1},Object.defineProperty(n.prototype,"volume",{get:function(){if(this._backend)return this._backend.volume;throw"Invalid state: cannot get volume before init"},set:function(e){if(!this._backend)throw"Invalid state: cannot set volume before init";this._backend.volume=e}}),Object.defineProperty(n.prototype,"tempo",{get:function(){if(this._tempoChanger)return this._tempoChanger.getTempo();throw"Invalid state: cannot get tempo before init"},set:function(e){if(!this._tempoChanger)throw"Invalid state: cannot set tempo before init";this._tempoChanger.setTempo(e)}}),n.prototype.init=function(e,i){if(this.channels=e,this.rate=i,this._options.backendFactory)this._backend=this._options.backendFactory(e,i,this._options);else{if(!t.isSupported())throw"No supported backend";this._backend=new t(e,i,this._options)}this.targetRate=this._backend.rate,this.bufferSize=this._backend.bufferSize,this._tempoChanger=s({sampleRate:this.targetRate,numChannels:e,tempo:1}),this._backend.onstarved=function(){this.onstarved&&this.onstarved()}.bind(this),this._backend.onbufferlow=function(){this.onbufferlow&&this.onbufferlow()}.bind(this)},n.prototype._resample=function(e){var t=this.rate,i=this.channels,s=this._backend.rate,d=this._backend.channels;if(t==s&&i==d)return e;var h,u=[],c=e[0].length,l=this._resampleFractional,f=c*s/t+l,_=Math.floor(f),p=f-_;h=t<s?function(e,i,d,h){for(var a=function(t){return t<0?d&&d.length+t>0?d[d.length+t]:e[0]:e[t]},u=0;u<i.length;u++){var c,f=(u+1-l)*t/s-1,_=Math.floor(f),p=Math.ceil(f);c=_==p?a(_):a(_)*(p-f)+a(p)*(f-_),i[u]=h*c}}:function(e,t,i,s){for(var d=0;d<t.length;d++)t[d]=s*e[d*e.length/t.length|0]};var m=1;d>i&&(m=Math.SQRT1_2);for(var V=0;V<d;V++){var g=V;V>=i&&(g=0);var v=e[g],y=new Float32Array(_);h(v,y,this._resampleLastSampleData?this._resampleLastSampleData[g]:void 0,m),u.push(y)}return this._resampleFractional=p,this._resampleLastSampleData=e,u},n.prototype.bufferData=function(e){if(!this._backend)throw"Invalid state: AudioFeeder cannot bufferData before init";var t=this._resample(e);t=this._tempoChanger.process(t),this._backend.appendBuffer(t)},n.prototype.getPlaybackState=function(){if(this._backend){var e=this._backend.getPlaybackState();return e.outputPlaybackPosition=e.playbackPosition,e.playbackPosition=this._tempoChanger.mapOutputToInputTime(e.outputPlaybackPosition),e}throw"Invalid state: AudioFeeder cannot getPlaybackState before init"},n.prototype.waitUntilReady=function(e){if(!this._backend)throw"Invalid state: AudioFeeder cannot waitUntilReady before init";this._backend.waitUntilReady(e)},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&&t.isSupported()},n.initSharedAudioContext=function(){return t.isSupported()?t.initSharedAudioContext():null},e.exports=n}()},function(e,t,i){!function(){var t=window.AudioContext||window.webkitAudioContext,s=i(0),d=i(3);function o(e,t,i){var d=i.audioContext||o.initSharedAudioContext();if(this._context=d,this.output=i.output||d.destination,this.rate=d.sampleRate,this.channels=2,i.bufferSize&&(this.bufferSize=0|i.bufferSize),this.bufferThreshold=2*this.bufferSize,this._bufferQueue=new s(this.channels,this.bufferSize),this._playbackTimeAtBufferTail=d.currentTime,this._queuedTime=0,this._delayedTime=0,this._dropped=0,this._liveBuffer=this._bufferQueue.createBuffer(this.bufferSize),d.createScriptProcessor)this._node=d.createScriptProcessor(this.bufferSize,0,this.channels);else{if(!d.createJavaScriptNode)throw new Error("Bad version of web audio API?");this._node=d.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(e){this._volume=+e}}),o.prototype._muted=!1,Object.defineProperty(o.prototype,"muted",{get:function(){return this._muted},set:function(e){this._muted=!!e}}),o.prototype._audioProcess=function(e){var t,i,s,h,u;u="number"==typeof e.playbackTime?e.playbackTime:this._context.currentTime+this.bufferSize/this.rate;var c=this._playbackTimeAtBufferTail;if(c<u&&(this._delayedTime+=u-c),this._bufferQueue.sampleCount()<this.bufferSize&&this.onstarved&&this.onstarved(),this._bufferQueue.sampleCount()<this.bufferSize){for(t=0;t<this.channels;t++)for(s=e.outputBuffer.getChannelData(t),h=0;h<this.bufferSize;h++)s[h]=0;this._dropped++}else{var l=this.muted?0:this.volume,f=this._bufferQueue.nextBuffer();if(f[0].length<this.bufferSize)throw"Audio buffer not expected length.";for(t=0;t<this.channels;t++)for(i=f[t],this._liveBuffer[t].set(f[t]),s=e.outputBuffer.getChannelData(t),h=0;h<i.length;h++)s[h]=i[h]*l;this._queuedTime+=this.bufferSize/this.rate,this._playbackTimeAtBufferTail=u+this.bufferSize/this.rate,this._bufferQueue.sampleCount()<Math.max(this.bufferSize,this.bufferThreshold)&&this.onbufferlow&&d(this.onbufferlow.bind(this))}},o.prototype._samplesQueued=function(){return this._bufferQueue.sampleCount()+Math.floor(this._timeAwaitingPlayback()*this.rate)},o.prototype._timeAwaitingPlayback=function(){return Math.max(0,this._playbackTimeAtBufferTail-this._context.currentTime)},o.prototype.getPlaybackState=function(){return{playbackPosition:this._queuedTime-this._timeAwaitingPlayback(),samplesQueued:this._samplesQueued(),dropped:this._dropped,delayed:this._delayedTime}},o.prototype.waitUntilReady=function(e){e()},o.prototype.appendBuffer=function(e){this._bufferQueue.appendBuffer(e)},o.prototype.start=function(){this._node.onaudioprocess=this._audioProcess.bind(this),this._node.connect(this.output),this._playbackTimeAtBufferTail=this._context.currentTime},o.prototype.stop=function(){if(this._node){var e=this._timeAwaitingPlayback();if(e>0){var t=Math.round(e*this.rate),i=this._liveBuffer?this._liveBuffer[0].length:0;t>i?(this._bufferQueue.prependBuffer(this._liveBuffer),this._bufferQueue.prependBuffer(this._bufferQueue.createBuffer(t-i))):this._bufferQueue.prependBuffer(this._bufferQueue.trimBuffer(this._liveBuffer,i-t,t)),this._playbackTimeAtBufferTail-=e}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!!t},o.sharedAudioContext=null,o.initSharedAudioContext=function(){if(!o.sharedAudioContext&&o.isSupported()){var e,i=new t;if(i.createScriptProcessor)e=i.createScriptProcessor(1024,0,2);else{if(!i.createJavaScriptNode)throw new Error("Bad version of web audio API?");e=i.createJavaScriptNode(1024,0,2)}e.connect(i.destination),e.disconnect(),o.sharedAudioContext=i}return o.sharedAudioContext},e.exports=o}()},function(e,t){e.exports=function(){if(void 0!==window.setImmediate)return window.setImmediate;if(window&&window.postMessage){var e=[];return window.addEventListener("message",(function(t){if(t.source===window){var i=t.data;if("object"==typeof i&&i.nextTickBrowserPingMessage){var s=e.pop();s&&s()}}})),function(t){e.push(t),window.postMessage({nextTickBrowserPingMessage:!0},document.location.toString())}}return function(e){setTimeout(e,0)}}()},function(e,t,i){var s;window,s=function(){return function(e){var t={};function r(i){if(t[i])return t[i].exports;var s=t[i]={i,l:!1,exports:{}};return e[i].call(s.exports,s,s.exports,r),s.l=!0,s.exports}return r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)r.d(i,s,function(t){return e[t]}.bind(null,s));return i},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(e,t){var i={float_array:function(e){return new Float32Array(e)},blit:function(e,t,i,s,d){i.set(e.subarray(t,t+d),s)}};e.exports=i},function(e,t,i){var s,d;s=i(0),d=i(2),e.exports=function(e){var t=(e=e||{}).sampleRate||44100,i=e.wsizeLog||11,h=e.tempo||1,u=(e.numChannels,Math.pow(2,50/1200)-1),c=1<<i,l=d(i),f=1<<i-2;f-=f%100;for(var _=s.float_array(c+f+5),p=s.float_array(c+f+5),m=f,V=f,g=s.float_array(c),v=0;v<c;v++)g[v]=.5*(1-Math.cos(2*Math.PI*v/c));var y=1+(c>>1),b=s.float_array(y),T=s.float_array(y),k=s.float_array(y),A=s.float_array(y),w=s.float_array(y),P=s.float_array(y),E=1+(y>>1),x=[0,0],R=[],F=[],O=[],S=[];for(v=0;v<2;v++)R.push(s.float_array(E)),F.push(s.float_array(E)),O.push(s.float_array(E)),S.push(s.float_array(y));var C=s.float_array(E),B=s.float_array(E),D=0,M=0,I=[{in_time:0,out_time:0,tempo:h}],L=0,j=0,W=1,X=0,H=0,N=0,z=0,Q={mapOutputToInputTime:function(e){for(var t=I.length-1;e<I[t].out_time&&t>0;)t--;var i=I[t];return i.in_time+i.tempo*(e-i.out_time)},flush:function(e){X=0,x=[0,0],j=0,z=0,N=0;for(var t=0;t<2;t++)for(var i=0;i<y;i++)S[t][i]=0;for(t=0;t<_.length;t++)_[t]=0;for(t=0;t<p.length;t++)p[t]=0;if(e){M=Math.max(0,M-e),D=Q.mapOutputToInputTime(M);for(var s=I.length-1;M<=I[s].out_time&&s>=0;)I.pop(),s--;I.push({in_time:D,out_time:M,tempo:h})}},getTempo:function(){return h},setTempo:function(e){m=V=f,e>=1?V=Math.round(m/e):m=Math.round(V*e),H=(1/e-1*V/m)*m,W=function(e,t){for(var i=e.length/t|0,s=0,d=0;d<i;d++)s+=e[d*t];return.9/s}(g,V),h=e;var t=I[I.length-1];t.out_time==M?t.tempo=e:I.push({in_time:D,out_time:M,tempo:e})}};Q.flush(0),Q.setTempo(h);var J=function(e,t,i){var s=Math.floor(i),d=s%2==1?-1:1;return Math.atan2(d*(t[s]-t[s+1]),d*(e[s]-e[s+1]))},U=function(e,t,i,s,d){var h=2*Math.PI/c*.5*(s+t)*m;return(function(e){return e-2*Math.PI*Math.round(e/(2*Math.PI))}(e-i-h)+h)*d},q=function(e,t,i,s,d,h){for(var l=e%2,f=1-l,_=S[f],p=x[f],m=R[f],V=F[f],g=O[f],v=S[l],y=1;y<v.length;y++)v[y]=t[y]*t[y]+i[y]*i[y];var b=R[l],T=x[l]=function(e,t){for(var i=0,s=0;s<e.length;s++)e[s]>i&&(i=e[s]);var d=1e-8*i,h=1,c=1;for(t[0]=1,s=2;s<e.length;s++){var l=s*u;if(e[s]>d&&e[s]>e[s-1]&&e[s]>=e[s+1]){var f=s+(e[s-1]-e[s+1])/(2*(e[s-1]-2*e[s]+e[s+1]));f-t[h-1]>l?(t[h++]=f,c=s):e[s]>e[c]&&(t[h-1]=f,c=s)}}return h}(v,b),k=F[l],A=O[l];if(0!=e&&0!=T){var w=0;for(N=0;N<T;N++){for(z=b[N];b[N]>m[w]&&w!=p;)++w;var P=w;w>0&&z-m[w-1]<m[w]-z&&(P=w-1);var E=z*u;if(Math.abs(m[P]-z)<E&&_[Math.round(m[P])]>.1*v[Math.round(z)]){var D=J(t,i,z),M=V[P]+g[P]+U(D,z,V[P],m[P],h)-D;k[N]=D,A[N]=M,C[N]=Math.cos(M),B[N]=Math.sin(M)}else k[N]=J(t,i,z),A[N]=0,C[N]=1,B[N]=0}b[T]=2*c;var I=b[P=0],L=b[P+1],j=C[P],W=B[P];for(y=1;y<t.length-1;y++){y>=I&&y-I>L-y&&(I=b[++P],L=b[P+1],j=C[P],W=B[P]);var X=t[y]*j-i[y]*W,H=t[y]*W+i[y]*j;t[y]=X,i[y]=H}}else for(var N=0;N<T;N++){var z=b[N];V[N]=g[N]=J(t,i,z)}},G=function(){var e=0|(X+=2*H);X-=e;for(var t=0;t<c;t++)l.m_re[t]=g[t]*_[t],l.m_im[t]=g[t]*_[m+t];s.blit(_,2*m,_,0,c-m),l.inplace(!1),l.unpack(b,T,k,A),q(L,b,T,0,0,1*V/m),q(L+1,k,A,0,0,1*(V+e)/m),s.blit(k,0,w,0,y),s.blit(A,0,P,0,y),l.repack(b,T,k,A),l.inplace(!0);var i=p.length;for(s.blit(p,j,p,0,i-j),t=i-j;t<i;t++)p[t]=0;var d=0,h=W;for(t=0;t<V;t++)Math.abs(2*l.m_re[t])>d&&(d=Math.abs(2*l.m_re[t]));for(t=0;t<c-V;t++)Math.abs(l.m_re[t+V+e]+l.m_im[t])>d&&(d=Math.abs(l.m_re[t+V+e]+l.m_im[t]));for(t=c-V;t<c;t++)Math.abs(2*l.m_im[t])>d&&(d=Math.abs(2*l.m_im[t]));var u=1/Math.floor(1*c/(2*V));for(h*d>u&&(h=u/d),t=0;t<c;t++)p[t]+=h*l.m_re[t],p[t+V+e]+=h*l.m_im[t];return L+=2,j=2*V+e};return Q.process=function(e){var i=e[0].length,d=e[0];if(e.length>1){d=s.float_array(e[0].length);for(var u=1/e.length,l=0;l<e.length;l++)for(var f=0;f<i;f++)d[f]+=u*e[l][f]}if(1==h){if(z+N>0){var g=z+N+i,v=[];for(l=0;l<e.length;l++){var y=s.float_array(g);s.blit(p,0,y,0,z),s.blit(_,0,y,z,N),s.blit(e[l],0,y,z+N,i),v.push(y)}Q.flush(0),i=g,e=v}return D+=i/t,M+=i/t,e}var b=N+i-(c-m),T=2*Math.floor(Math.max(0,b)/(2*m)),k=z+V*T+Math.floor(X+H*T);z>k&&(k=z);var A=s.float_array(k);s.blit(p,0,A,0,z);for(var w=0,P=z,E=0,x=0;;){var R=c+m-N;if(w+R>i){s.blit(d,w,_,N,i-w),N+=i-w,w=i;break}R<=0?N-=2*m:(s.blit(d,w,_,N,R),w+=R,N=c-m),x=G(),D+=2*m/t,M+=x/t,(E=P+x-k)<0&&(E=0),s.blit(p,0,A,P,x-E),P+=x}s.blit(p,x-E,p,0,E),z=E;var F=[];for(l=0;l<e.length;l++)F.push(A);return F},Q}},function(e,t,i){"use strict";var s=i(0);e.exports=function(e){for(var t=1<<e,i={m_logN:e,m_N:t,m_invN:1/t,m_re:s.float_array(t),m_im:s.float_array(t),m_revTgt:new Array(t)},d=0;d<t;d++){for(var h=d,u=0,c=0;c<e;c++)u<<=1,u|=1&h,h>>=1;i.m_revTgt[d]=u}i.twiddleRe=s.float_array(i.m_logN),i.twiddleIm=s.float_array(i.m_logN);for(var l=1,f=0;f<i.m_logN;f++){var _=2*l*Math.PI*i.m_invN;i.twiddleRe[f]=Math.cos(_),i.twiddleIm[f]=Math.sin(_),l<<=1}i.inplace=function(e){var t=i.m_re,s=i.m_im,d=i.m_N,h=i.m_logN,u=d>>1,c=d>>1,l=d;if(e)for(var f=1/d,_=0;_<d;_++)t[_]*=f,s[_]*=f;for(var p=0;p<h;p++){var m=i.twiddleRe[p],V=i.twiddleIm[p];e||(V*=-1);for(var g=0;g<d;){for(var v=g,y=g+c,b=1,T=0,k=0;k<u;k++){var A=t[v],w=s[v],P=t[y],E=s[y];t[v]=A+P,s[v]=w+E,P=A-P,E=w-E,t[y]=P*b-E*T,s[y]=P*T+E*b,v++,y++;var x=b;b=b*m-T*V,T=x*V+T*m}g+=l}u>>=1,c>>=1,l>>=1}for(var R,F,O=i.m_revTgt,S=0;S<d;S++)O[S]>S&&(F=t[R=O[S]],t[R]=t[S],t[S]=F,F=s[R],s[R]=s[S],s[S]=F)};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<p;u++)e[u]=(i.m_re[u]+i.m_re[t-u])/2,s[u]=(i.m_im[u]-i.m_im[t-u])/2,d[u]=(i.m_im[u]+i.m_im[t-u])/2,h[u]=(-i.m_re[u]+i.m_re[t-u])/2},i.repack=function(e,s,d,h){i.m_re[0]=e[0],i.m_im[0]=d[0],i.m_re[p]=e[p],i.m_im[p]=d[p];for(var u=1;u<p;u++)i.m_re[u]=e[u]-h[u],i.m_im[u]=s[u]+d[u],i.m_re[t-u]=e[u]+h[u],i.m_im[t-u]=-s[u]+d[u]},i}}])},e.exports=s()}])},893:(e,t)=>{"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.9.0-20240423190513-22f6924",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<i.length;d++)if((e=i[d].getAttribute("src"))&&(t=e.match(s)))return t[1]}loadClass(e,t,i){(i=i||{}).worker?this.workerProxy(e,t):super.loadClass(e,t,i)}loadScript(e,t){if("done"==this.scriptStatus[e])t();else if("loading"==this.scriptStatus[e])this.scriptCallbacks[e].push(t);else{this.scriptStatus[e]="loading",this.scriptCallbacks[e]=[t];var i=document.createElement("script"),done=t=>{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,V,g,v,y,b=!1,T=!1;function completionCheck(){if(1==b&&1==T){var e=g+" "+v+"\nOGVLoader.base = "+JSON.stringify(f.base);try{y=new Blob([e],{type:"application/javascript"})}catch(t){window.BlobBuilder=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder,(y=new BlobBuilder).append(e),y=y.getBlob()}s=new Worker(URL.createObjectURL(y)),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&&(g=m.responseText,b=!0,completionCheck())},m.send(),(V=new XMLHttpRequest).open("GET",_,!0),V.onreadystatechange=function(){4==V.readyState&&200==V.status&&(v=V.responseText,T=!0,completionCheck())},V.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<i;)s.push(null);return s}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=class OGVMediaType{constructor(e){e=String(e),this.major=null,this.minor=null,this.codecs=null;var t=split(e,";");if(t.length){var i=t.shift();if(i){var s=split(i,"/",2);this.major=s[0],this.minor=s[1]}for(var d in t){var h=t[d].match(/^codecs\s*=\s*"(.*?)"$/);if(h){this.codecs=split(h[1],",");break}}}}};t.default=i},869:(e,t,i)=>{"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)),V=s(i(168)),g=s(i(625)),v=s(i(302)),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",A="LOADED",w="PRELOAD",P="READY",E="PLAYING",x="SEEKING",R="ERROR",F="NOT_SEEKING",O="BISECT_TO_TARGET",S="BISECT_TO_KEYPOINT",C="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._crossOrigin=null,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 V.default(e)}},seekable:{get:function getSeekable(){return this.duration<1/0&&this._stream&&this._stream.seekable&&this._codec&&this._codec.seekable?new V.default([[0,this._duration]]):new V.default([])}},currentTime:{get:function getCurrentTime(){return this._state==x?this._seekTargetTime:this._codec?this._state!=E||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==x}},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.crossOrigin=this.crossOrigin,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 this._crossOrigin},set:function setCrossOrigin(e){switch(e){case null:this._crossOrigin=e,this.removeAttribute("crossorigin");break;default:e="anonymous";case"":case"anonymous":case"use-credentials":this._crossOrigin=e,this.setAttribute("crossorigin",e)}this._thumbnail&&(this._thumbnail.crossOrigin=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 V.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(){var e=document.createElement("audio");e.src=v.default,e.play(),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=x,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=x,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=C,this._fireEventAsync("seeking"),this._didSeek?void 0:void this._pingProcessing();this._codec.getKeypointOffset(e,(e=>{e>0?(this._seekState=C,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=P,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._seekTargetTime?void this._codec.decodeAudio((()=>{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/2<this._bisectTargetTime?this._seekBisector.right()||(this._log("close enough (right)"),this._seekState=C,this._pingProcessing()):this._seekState==O&&this._codec.hasVideo&&this._codec.keyframeTimestamp<this._codec.frameTimestamp?(this._log("finding the keypoint now"),this._seekState=S,this._startBisection(this._codec.keyframeTimestamp)):(this._log("straight seeking now"),this._seekState=C,this._pingProcessing())}_setupVideo(){this._videoInfo.fps>0?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==A)this._doProcessLoaded();else if(this._state==w)this._doProcessPreload();else if(this._state==P)this._doProcessReady();else if(this._state==x)this._doProcessSeeking();else if(this._state==E)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=A,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