export default function(e){e.on("timeupdate",()=>saveProgress(e)),e.on("ready",()=>resumeProgress(e)),e.on("loadeddata",()=>resumeProgress(e)),e.on("ended",()=>clearProgress(e))}export function getId(e){return e?.config?.blockAttributes?.id}export function saveProgress(e){e?.config?.mutedPreview?.enabled||updateTime(e)}export function clearProgress(e){localStorage.removeItem(`player-progress-${getId(e)}`)}export function resumeProgress(e,r=!1){if(!e?.config?.save_player_position||e?.config?.mutedPreview?.enabled)return;let t=getTime(e);return e.hls&&t>=0&&e.hls.startLoad(t),e.duration&&(t=Math.min(t,e.duration)),!t||t<1?0:(e.currentTime=t,e?.isVimeo&&setTimeout(()=>{e.embed.setCurrentTime(t||0)},0),t)}export function getTime(e){return parseFloat(localStorage.getItem(`player-progress-${getId(e)}`))}export function updateTime(e){0!==e.currentTime&&e?.config?.save_player_position&&localStorage.setItem(`player-progress-${getId(e)}`,e.currentTime)}