/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../../_virtual/_rollupPluginBabelHelpers.js"),t=require("../../utils/util.js"),i=require("../../utils/sniffer.js"),n=require("../../events.js"),o=require("../../plugin/plugin.js"),s=require("./innerList.js");var r={POINT:"inner-focus-point",HIGHLIGHT:"inner-focus-highlight"},a=function(a){e.inherits(l,a);var u=e.createSuper(l);function l(i){var n;return e.classCallCheck(this,l),n=u.call(this,i),e.defineProperty(e.assertThisInitialized(n),"onMoveOnly",function(i,o){var s=e.assertThisInitialized(n),r=s.pos,a=s.config,u=s.player,l=o;if(i){t.default.event(i);var c=t.default.getEventPos(i,u.zoom),d=90===u.rotateDeg?c.clientY:c.clientX;if(r.moving&&Math.abs(r.x-d)<a.miniMoveStep)return;r.moving=!0,r.x=d,l=n.computeTime(i,d)}n.triggerCallbacks("dragmove",l,i),n._updateInnerFocus(l)}),e.defineProperty(e.assertThisInitialized(n),"onBodyClick",function(e){n.pos.isLocked&&(n.pos.isLocked=!1,e.preventDefault(),e.stopPropagation())}),e.defineProperty(e.assertThisInitialized(n),"_mouseDownHandler",function(e,t){n._state.time=t.currentTime,n.updateWidth(t.currentTime,t.seekTime,t.percent,0),n._updateInnerFocus(t)}),e.defineProperty(e.assertThisInitialized(n),"_mouseUpHandler",function(t,i){e.assertThisInitialized(n).pos.moving&&n.updateWidth(i.currentTime,i.seekTime,i.percent,2)}),e.defineProperty(e.assertThisInitialized(n),"_mouseMoveHandler",function(t,i){var o=e.assertThisInitialized(n),s=o._state,r=o.pos,a=o.config,u=o.player;s.time<i.currentTime?i.forward=!0:i.forward=!1,s.time=i.currentTime,r.isDown&&!r.moving&&(r.moving=!0,a.isPauseMoving&&u.pause(),n.triggerCallbacks("dragstart",i,t),n.emitUserAction("drag","dragstart",i)),n.updateWidth(i.currentTime,i.seekTime,i.percent,1),n.triggerCallbacks("dragmove",i,t),n._updateInnerFocus(i)}),e.defineProperty(e.assertThisInitialized(n),"onMouseDown",function(i){var o=e.assertThisInitialized(n),s=o._state,r=o.player,a=o.pos,u=o.config,l=o.playerConfig,c=t.default.getEventPos(i,r.zoom),d=90===r.rotateDeg?c.clientY:c.clientX;if(!(r.isMini||u.closeMoveSeek||!l.allowSeekAfterEnded&&r.ended)){if(r.duration||r.isPlaying){i.stopPropagation(),n.focus(),t.default.checkIsFunction(l.disableSwipeHandler)&&l.disableSwipeHandler(),t.default.checkIsFunction(u.onMoveStart)&&u.onMoveStart(),t.default.event(i),a.x=d,a.isDown=!0,a.moving=!1,s.prePlayTime=r.currentTime,r.focus({autoHide:!1}),n.isProgressMoving=!0,t.default.addClass(n.progressBtn,"active");var h=n.computeTime(i,d);return h.prePlayTime=s.prePlayTime,n._mouseDownHandlerHook(i,h),"touchstart"===i.type?(n.root.addEventListener("touchmove",n.onMouseMove),n.root.addEventListener("touchend",n.onMouseUp),n.root.addEventListener("touchcancel",n.onMouseUp)):(n.unbind("mousemove",n.onMoveOnly),document.addEventListener("mousemove",n.onMouseMove,!1),document.addEventListener("mouseup",n.onMouseUp,!1)),!0}r.play()}}),e.defineProperty(e.assertThisInitialized(n),"onMouseUp",function(i){var o=e.assertThisInitialized(n),s=o.player,r=o.config,a=o.pos,u=o.playerConfig,l=o._state;if(a){i.stopPropagation(),i.preventDefault(),t.default.checkIsFunction(u.enableSwipeHandler)&&u.enableSwipeHandler(),t.default.checkIsFunction(r.onMoveEnd)&&r.onMoveEnd(),t.default.event(i),t.default.removeClass(n.progressBtn,"active");var c=n.computeTime(i,a.x);c.prePlayTime=l.prePlayTime,a.moving?(n.triggerCallbacks("dragend",c,i),n.emitUserAction("drag","dragend",c)):(n.triggerCallbacks("click",c,i),n.emitUserAction("click","click",c)),n._mouseUpHandlerHook(i,c),a.moving=!1,a.isDown=!1,a.x=0,a.y=0,a.isLocked=!0,l.prePlayTime=0,l.time=0;var d=i.type;"touchend"===d||"touchcancel"===d?(n.root.removeEventListener("touchmove",n.onMouseMove),n.root.removeEventListener("touchend",n.onMouseUp),n.root.removeEventListener("touchcancel",n.onMouseUp),n.blur()):(document.removeEventListener("mousemove",n.onMouseMove,!1),document.removeEventListener("mouseup",n.onMouseUp,!1),a.isEnter?"mobile"!==u.isMobileSimulateMode&&n.bind("mousemove",n.onMoveOnly):n.onMouseLeave(i)),t.default.setTimeout(e.assertThisInitialized(n),function(){n.resetSeekState()},1),s.focus()}}),e.defineProperty(e.assertThisInitialized(n),"onMouseMove",function(i){var o=e.assertThisInitialized(n),s=o._state,r=o.pos,a=o.player,u=o.config;t.default.checkTouchSupport()&&i.preventDefault(),t.default.event(i);var l=t.default.getEventPos(i,a.zoom),c=90===a.rotateDeg?l.clientY:l.clientX,d=Math.abs(r.x-c);if(!(r.moving&&d<u.miniMoveStep||!r.moving&&d<u.miniStartStep)){r.x=c;var h=n.computeTime(i,c);h.prePlayTime=s.prePlayTime,n._mouseMoveHandlerHook(i,h)}}),e.defineProperty(e.assertThisInitialized(n),"onMouseOut",function(e){n.triggerCallbacks("mouseout",null,e)}),e.defineProperty(e.assertThisInitialized(n),"onMouseOver",function(e){n.triggerCallbacks("mouseover",null,e)}),e.defineProperty(e.assertThisInitialized(n),"onMouseEnter",function(i){var o=e.assertThisInitialized(n),s=o.player,r=o.pos;if(!(r.isDown||r.isEnter||s.isMini||!s.config.allowSeekAfterEnded&&s.ended)){r.isEnter=!0,n.bind("mousemove",n.onMoveOnly),n.bind("mouseleave",n.onMouseLeave),t.default.event(i);var a=t.default.getEventPos(i,s.zoom),u=90===s.rotateDeg?a.clientY:a.clientX,l=n.computeTime(i,u);n.triggerCallbacks("mouseenter",l,i),n.focus()}}),e.defineProperty(e.assertThisInitialized(n),"onMouseLeave",function(e){n.triggerCallbacks("mouseleave",null,e),n.unlock(),n._updateInnerFocus(null)}),e.defineProperty(e.assertThisInitialized(n),"onVideoResize",function(){var e=n.pos,t=e.x,i=e.isDown;if(e.isEnter&&!i){var o=n.computeTime(null,t);n.onMoveOnly(null,o)}}),n.useable=!1,n.isProgressMoving=!1,n.__dragCallBacks=[],n._state={now:-1,direc:0,time:0,prePlayTime:-1},n._disableBlur=!1,"boolean"==typeof n.config.isDragingSeek&&(console.warn("[XGPLAYER] 'isDragingSeek' is deprecated, please use 'isDraggingSeek' instead"),n.config.isDraggingSeek=n.config.isDragingSeek),n}return e.createClass(l,[{key:"offsetDuration",get:function(){return this.playerConfig.customDuration||this.player.offsetDuration||this.player.duration}},{key:"duration",get:function(){return this.playerConfig.customDuration||this.player.duration}},{key:"timeOffset",get:function(){return this.playerConfig.timeOffset||0}},{key:"currentTime",get:function(){var e=this.player,t=e.offsetCurrentTime,i=e.currentTime;return t>=0?t:i+this.timeOffset}},{key:"changeState",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.useable=e}},{key:"show",value:function(e){this.root&&(this.root.style.display="flex")}},{key:"_initInner",value:function(){var t=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};i&&0!==i.length||(i=[{percent:1}]);var o=e.objectSpread2(e.objectSpread2({fragments:i},n),{},{actionCallback:function(e){t.emitUserAction("fragment_focus","fragment_focus",e)}});this.innerList?this.innerList.reset(o):(this.innerList=new s.default(o),this.outer.insertBefore(this.innerList.render(),this.outer.children[0]),["findHightLight","unHightLight","setHightLight","findFragment"].map(function(e){t[e]=t.innerList[e].bind(t.innerList)}))}},{key:"_updateInnerFocus",value:function(e){this.innerList&&this.innerList.updateFocus(e)}},{key:"afterCreate",value:function(){if(!this.config.disable&&!this.playerConfig.isLive){this.pos={x:0,y:0,moving:!1,isDown:!1,isEnter:!1,isLocked:!1},this.outer=this.find("xg-outer");var e=this.config,t=e.fragFocusClass,n=e.fragAutoFocus,o=e.fragClass;this._initInner(this.config.fragments,{fragFocusClass:t,fragAutoFocus:n,fragClass:o,style:this.playerConfig.commonStyle||{}}),"mobile"===i.default.device&&(this.config.isDraggingSeek=!1,this.isMobile=!0),this.progressBtn=this.find(".xgplayer-progress-btn"),this.listenEvents(),this.bindDomEvents(),this.initCustomStyle()}}},{key:"listenEvents",value:function(){var e=this;this.on(n.DURATION_CHANGE,function(){e.onMouseLeave()}),this.on(n.TIME_UPDATE,function(){e.onTimeupdate()}),this.on(n.SEEKED,function(){e.onTimeupdate(),e.onCacheUpdate()}),this.on(n.PROGRESS,function(){e.onCacheUpdate()}),this.on(n.ENDED,function(){e.onCacheUpdate(!0),e.onTimeupdate(!0),e._state.now=0}),this.on(n.EMPTIED,function(){e.onReset()}),this.on(n.VIDEO_RESIZE,function(){e.onVideoResize()})}},{key:"setConfig",value:function(e){var t=this,i=null;Object.keys(e).forEach(function(n){t.config[n]=e[n],"fragments"===n&&(i=e[n])}),i&&this._initInner(i,e)}},{key:"initCustomStyle",value:function(){var t=(this.playerConfig||{}).commonStyle.sliderBtnStyle,i=this.progressBtn;t&&("string"==typeof t?i.style.boxShadow=t:"object"===e.typeof(t)&&Object.keys(t).map(function(e){i.style[e]=t[e]}))}},{key:"triggerCallbacks",value:function(e,t,i){this.__dragCallBacks.length>0&&this.__dragCallBacks.map(function(n){if(n&&n.handler&&n.type===e)try{n.handler(t,i)}catch(o){console.error("[XGPLAYER][triggerCallbacks] ".concat(n," error"),o)}})}},{key:"addCallBack",value:function(e,t){t&&"function"==typeof t&&this.__dragCallBacks.push({type:e,handler:t})}},{key:"removeCallBack",value:function(e,t){var i=this.__dragCallBacks,n=-1;i.map(function(i,o){i&&i.type===e&&i.handler===t&&(n=o)}),n>-1&&i.splice(n,1)}},{key:"unlock",value:function(){var e=this.player,t=this.pos;t.isEnter=!1,t.isLocked=!1,e.isMini||(this.unbind("mousemove",this.onMoveOnly),t.isDown?this.unbind("mouseleave",this.onMouseLeave):this.blur())}},{key:"bindDomEvents",value:function(){var e=this.player.config;this._mouseDownHandlerHook=this.hook("dragstart",this._mouseDownHandler),this._mouseUpHandlerHook=this.hook("dragend",this._mouseUpHandler),this._mouseMoveHandlerHook=this.hook("drag",this._mouseMoveHandler),"touch"!==this.domEventType&&"compatible"!==this.domEventType||this.root.addEventListener("touchstart",this.onMouseDown),"mouse"!==this.domEventType&&"compatible"!==this.domEventType||(this.bind("mousedown",this.onMouseDown),"mobile"!==e.isMobileSimulateMode&&this.bind("mouseenter",this.onMouseEnter),this.bind("mouseover",this.onMouseOver),this.bind("mouseout",this.onMouseOut),this.player.root.addEventListener("click",this.onBodyClick,!0))}},{key:"focus",value:function(){this.player.controls.pauseAutoHide(),t.default.addClass(this.root,"active")}},{key:"blur",value:function(){this._disableBlur||(this.player.controls.recoverAutoHide(),t.default.removeClass(this.root,"active"))}},{key:"disableBlur",value:function(){this._disableBlur=!0}},{key:"enableBlur",value:function(){this._disableBlur=!1}},{key:"updateWidth",value:function(e,t,i,n){var o=this.config,s=this.player;if(!o.isCloseClickSeek||0!==n){var r=t=t>=s.duration?s.duration-o.endedDiff:Number(t).toFixed(1);this.updatePercent(i),this.updateTime(e),(1!==n||o.isDraggingSeek&&"audio"!==s.config.mediaType)&&(this._state.now=r,this._state.direc=r>s.currentTime?0:1,s.seek(r))}}},{key:"computeTime",value:function(e,i){var n,o,s=this.player,r=this.root.getBoundingClientRect(),a=r.width,u=r.height,l=r.top,c=r.left,d=i;90===s.rotateDeg?(n=u,o=l):(n=a,o=c);var h=d-o,f=(h=h>n?n:h<0?0:h)/n;f=f<0?0:f>1?1:f,Number.isNaN(f)&&(f=this.player.currentTime/this.offsetDuration);var p=parseInt(f*this.offsetDuration*1e3,10)/1e3;return{percent:f,currentTime:p,seekTime:t.default.getCurrentTimeByOffset(p,s.timeSegments),offset:h,width:n,left:o,e:e}}},{key:"updateTime",value:function(e){var t=this.player,i=this.duration;e>i?e=i:e<0&&(e=0);var n=t.plugins.time;n&&n.updateTime(e)}},{key:"resetSeekState",value:function(){this.isProgressMoving=!1;var e=this.player.plugins.time;e&&e.resetActive()}},{key:"updatePercent",value:function(e,t){if(this.isProgressMoving=!0,!this.config.disable){e=e>1?1:e<0?0:e,this.progressBtn.style.left="".concat(100*e,"%"),this.innerList.update({played:e*this.offsetDuration},this.offsetDuration);var i=this.player.plugins.miniprogress;i&&i.update({played:e*this.offsetDuration},this.offsetDuration)}}},{key:"onTimeupdate",value:function(e){var i=this.player,n=this._state,o=this.offsetDuration;if(!(i.isSeeking&&i.media.seeking||this.isProgressMoving)&&i.hasStart){if(n.now>-1){var s=parseInt(1e3*n.now,10)-parseInt(1e3*i.currentTime,10);if(0===n.direc&&s>300||1===n.direc&&s>-300)return void(n.now=-1);n.now=-1}var r=this.currentTime;r=t.default.adjustTimeByDuration(r,o,e),this.innerList.update({played:r},o),this.progressBtn.style.left="".concat(r/o*100,"%")}}},{key:"onCacheUpdate",value:function(e){var i=this.player,n=this.duration;if(i){var o=i.bufferedPoint.end;o=t.default.adjustTimeByDuration(o,n,e),this.innerList.update({cached:o},n)}}},{key:"onReset",value:function(){this.innerList.update({played:0,cached:0},0),this.progressBtn.style.left="0%"}},{key:"destroy",value:function(){var e=this.player;this.thumbnailPlugin=null,this.innerList.destroy(),this.innerList=null;var t=this.domEventType;"touch"!==t&&"compatible"!==t||(this.root.removeEventListener("touchstart",this.onMouseDown),this.root.removeEventListener("touchmove",this.onMouseMove),this.root.removeEventListener("touchend",this.onMouseUp),this.root.removeEventListener("touchcancel",this.onMouseUp)),"mouse"!==t&&"compatible"!==t||(this.unbind("mousedown",this.onMouseDown),this.unbind("mouseenter",this.onMouseEnter),this.unbind("mousemove",this.onMoveOnly),this.unbind("mouseleave",this.onMouseLeave),document.removeEventListener("mousemove",this.onMouseMove,!1),document.removeEventListener("mouseup",this.onMouseUp,!1),e.root.removeEventListener("click",this.onBodyClick,!0))}},{key:"render",value:function(){if(!this.config.disable&&!this.playerConfig.isLive){var e=this.player.controls?this.player.controls.config.mode:"";return'\n    <xg-progress class="xgplayer-progress '.concat("bottom"===e?"xgplayer-progress-bottom":"",'">\n      <xg-outer class="xgplayer-progress-outer">\n        <xg-progress-btn class="xgplayer-progress-btn"></xg-progress-btn>\n      </xg-outer>\n    </xg-progress>\n    ')}}}],[{key:"pluginName",get:function(){return"progress"}},{key:"defaultConfig",get:function(){return{position:o.POSITIONS.CONTROLS_CENTER,index:0,disable:!1,isDraggingSeek:!0,closeMoveSeek:!1,isPauseMoving:!1,isCloseClickSeek:!1,fragments:[{percent:1}],fragFocusClass:r.POINT,fragClass:"",fragAutoFocus:!1,miniMoveStep:5,miniStartStep:2,onMoveStart:function(){},onMoveEnd:function(){},endedDiff:.2}}},{key:"FRAGMENT_FOCUS_CLASS",get:function(){return r}}]),l}(o.default);exports.default=a;