import*as UI from"../ui/ui.js";export class AnimationScreenshotPopover extends UI.Widget.VBox{constructor(e){super(!0),console.assert(e.length>0),this.registerRequiredCSS("animation/animationScreenshotPopover.css",{enableLegacyPatching:!1}),this.contentElement.classList.add("animation-screenshot-popover"),this._frames=e;for(const t of e)this.contentElement.appendChild(t),t.style.display="none";this._rafId=0,this._currentFrame=0,this._frames[0].style.display="block",this._progressBar=this.contentElement.createChild("div","animation-progress")}wasShown(){this._rafId=this.contentElement.window().requestAnimationFrame(this._changeFrame.bind(this))}willHide(){this.contentElement.window().cancelAnimationFrame(this._rafId),delete this._endDelay}_changeFrame(){if(this._rafId=this.contentElement.window().requestAnimationFrame(this._changeFrame.bind(this)),this._endDelay)return void this._endDelay--;if(this._showFrame=!this._showFrame,!this._showFrame)return;const e=this._frames.length;this._frames[this._currentFrame%e].style.display="none",this._currentFrame++,this._frames[this._currentFrame%e].style.display="block",this._currentFrame%e===e-1&&(this._endDelay=50),this._progressBar.style.width=(this._currentFrame%e+1)/e*100+"%"}}