import{v as r}from"./DCUV69GJ.chunk.js";const n=r.getPlugin("plugin"),s=10;class a extends n{constructor(t,i){if(super(t),i.startTime===void 0)throw Error("Invalid clip start");if(i.endTime===void 0)throw Error("Invalid clip end");if(i.startTime>i.endTime)throw Error("Clip start cannot be greater than clip end");this._clipStart=parseFloat(i.startTime.toPrecision(4)),this._clipEnd=parseFloat(i.endTime.toPrecision(4)),this.playerEndedFn=this.player.ended.bind(t),this.playerDurationFn=this.player.duration.bind(t),this.playerCurrentTimeFn=this.player.currentTime.bind(t),this.playerbufferedFn=this.player.buffered.bind(t),this.player.ended=this.ended.bind(this),this.player.duration=this.duration.bind(this),this.player.currentTime=this.currentTime.bind(this),this.player.buffered=this.buffered.bind(this),this.initialize(),this.player.ready(()=>{this.player.trigger("durationchange")})}get clipStart(){const t=this.playerDurationFn();return this._clipStart>t?t:this._clipStart}get clipEnd(){const t=this.playerDurationFn();return t<=0?this._clipEnd:this._clipEnd>t?t:this._clipEnd}dispose(){this.player.off("timeupdate",this.onTimeUpdate),this.player.off("play",this.onPlay),this.player.ended=this.playerEndedFn,this.player.duration=this.playerDurationFn,this.player.currentTime=this.playerCurrentTimeFn,this.player.buffered=this.playerbufferedFn,this.player.trigger("durationchange"),super.dispose()}initialize(){this.onTimeUpdate=this.onTimeUpdate.bind(this),this.onPlay=this.onPlay.bind(this),this.player.on("timeupdate",this.onTimeUpdate),this.player.on("play",this.onPlay)}onPlay(){this._isEnded&&this.player.currentTime(0)}onTimeUpdate(){const t=this.getCurrentTime(!1);if(t>this.clipEnd){this._isEnded||(this.player.pause(),this.player.trigger("ended"),this._isEnded=!0);return}this._isEnded=!1,t<this.clipStart-s&&this.playerCurrentTimeFn(this.clipStart,!0)}ended(){return this.getCurrentTime(!1)>this.clipEnd}duration(t){return t&&t>0&&(this.playerDurationFn()?console.info("The duration of the player has already been set. This is a no-op."):this.playerDurationFn(t)),this.clipEnd-this.clipStart}currentTime(t,...i){if(typeof t!="number")return this.getCurrentTime(!0);const e=t+this.clipStart;this.playerCurrentTimeFn(e,i)}getCurrentTime(t){const i=this.playerCurrentTimeFn();let e=0;return i>=this.clipStart&&(e=i-this.clipStart),this.player.getCache().currentTime=e,t?e:i}buffered(){const t=this.playerbufferedFn(),i=[];for(let e=0;e<t.length;e++)i[e]=[Math.max(0,t.start(e)-this.clipStart),Math.min(Math.max(0,t.end(e)-this.clipStart),this.player.duration())];return r.createTimeRanges(i)}}r.registerPlugin("clipPlugin",a);
//# sourceMappingURL=GA2y9Z4q.chunk.js.map
