/*!
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"),s=require("../../events.js"),o=require("../../plugin/hooksDescriptor.js"),n=require("../../plugin/plugin.js"),a=require("../../state.js"),r=require("./touch.js"),c=require("../assets/seekicon.js");var u="auto",l="seeking",h="playbackrate",d=["videoClick","videoDbClick"],p=function(n){e.inherits(g,n);var p=e.createSuper(g);function g(i){var s;return e.classCallCheck(this,g),s=p.call(this,i),e.defineProperty(e.assertThisInitialized(s),"onTouchStart",function(i){var o=e.assertThisInitialized(s),n=o.player,a=o.config,r=o.pos,c=o.playerConfig,u=s.getTouche(i);if(u&&!a.disableGesture&&s.duration>0&&!n.ended){r.isStart=!0,s.timer&&clearTimeout(s.timer),t.default.checkIsFunction(c.disableSwipeHandler)&&c.disableSwipeHandler(),s.find(".xg-dur").innerHTML=t.default.format(s.duration);var l=s.root.getBoundingClientRect();90===n.rotateDeg?(r.top=l.left,r.left=l.top,r.width=l.height,r.height=l.width):(r.top=l.top,r.left=l.left,r.width=l.width,r.height=l.height);var h=parseInt(u.pageX-r.left,10),d=parseInt(u.pageY-r.top,10);r.x=90===n.rotateDeg?d:h,r.y=90===n.rotateDeg?h:d,r.scopeL=a.scopeL*r.width,r.scopeR=(1-a.scopeR)*r.width,r.scopeM1=r.width*(1-a.scopeM)/2,r.scopeM2=r.width-r.scopeM1}}),e.defineProperty(e.assertThisInitialized(s),"onTouchMove",function(t){var i=s.getTouche(t),o=e.assertThisInitialized(s),n=o.pos,a=o.config,r=o.player;if(i&&!a.disableGesture&&s.duration&&n.isStart){var c=a.miniMoveStep,u=a.hideControlsActive,l=parseInt(i.pageX-n.left,10),h=parseInt(i.pageY-n.top,10),d=90===r.rotateDeg?h:l,p=90===r.rotateDeg?l:h;if(Math.abs(d-n.x)>c||Math.abs(p-n.y)>c){var g=d-n.x,f=p-n.y,v=n.scope;if(-1===v&&(0===(v=s.checkScope(d,p,g,f,n))&&(u?r.blur():r.focus({autoHide:!1}),!n.time&&(n.time=parseInt(1e3*r.currentTime,10)+1e3*s.timeOffset)),n.scope=v),-1===v||v>0&&!a.gestureY||0===v&&!a.gestureX)return;s.executeMove(g,f,v,n.width,n.height),n.x=d,n.y=p}}}),e.defineProperty(e.assertThisInitialized(s),"onTouchEnd",function(i){var o=e.assertThisInitialized(s),n=o.player,a=o.pos,r=o.playerConfig;if(setTimeout(function(){n.getPlugin("progress")&&n.getPlugin("progress").resetSeekState()},10),a.isStart){a.scope>-1&&i.cancelable&&i.preventDefault();var c=s.config,l=c.disableGesture,h=c.gestureX;!l&&h?s.endLastMove(a.scope):a.time=0,a.scope=-1,s.resetPos(),t.default.checkIsFunction(r.enableSwipeHandler)&&r.enableSwipeHandler(),s.changeAction(u)}}),e.defineProperty(e.assertThisInitialized(s),"onRootTouchMove",function(e){!s.config.disableGesture&&s.config.gestureX&&s.checkIsRootTarget(e)&&(e.stopPropagation(),s.pos.isStart?s.onTouchMove(e):s.onTouchStart(e))}),e.defineProperty(e.assertThisInitialized(s),"onRootTouchEnd",function(e){s.pos.scope>-1&&s.onTouchEnd(e)}),s.pos={isStart:!1,x:0,y:0,time:0,volume:0,rate:1,light:0,width:0,height:0,scopeL:0,scopeR:0,scopeM1:0,scopeM2:0,scope:-1},s.timer=null,s}return e.createClass(g,[{key:"duration",get:function(){return this.playerConfig.customDuration||this.player.duration}},{key:"timeOffset",get:function(){return this.playerConfig.timeOffset||0}},{key:"registerIcons",value:function(){return{seekTipIcon:{icon:c.default,class:"xg-seek-pre"}}}},{key:"afterCreate",value:function(){var e=this;d.map(function(t){e.__hooks[t]=null});var i=this.playerConfig,o=this.config,n=this.player;!0===i.closeVideoDblclick&&(o.closedbClick=!0),this.resetPos(),t.default.isUndefined(i.disableGesture)||(o.disableGesture=!!i.disableGesture),this.appendChild(".xg-seek-icon",this.icons.seekTipIcon),this.xgMask=t.default.createDom("xg-mask","",{},"xgmask"),n.root.appendChild(this.xgMask),this.initCustomStyle(),this.registerThumbnail();var a="mouse"===this.domEventType?"mouse":"touch";this.touch=new r.default(this.root,{eventType:a,needPreventDefault:!this.config.disableGesture}),this.root.addEventListener("contextmenu",function(e){e.preventDefault()}),n.root.addEventListener("touchmove",this.onRootTouchMove,!0),n.root.addEventListener("touchend",this.onRootTouchEnd,!0),n.root.addEventListener("touchcancel",this.onRootTouchEnd,!0);var c=this.player.controls;c&&c.center&&(c.center.addEventListener("touchmove",this.onRootTouchMove,!0),c.center.addEventListener("touchend",this.onRootTouchEnd,!0),c.center.addEventListener("touchcancel",this.onRootTouchEnd,!0)),this.on(s.DURATION_CHANGE,function(){var t=e.player,i=e.config;t.duration>0&&1e3*t.duration<i.moveDuration&&(i.moveDuration=1e3*t.duration)}),this.on([s.CANPLAY,s.ENDED],function(){var t=e.pos,i=t.time;!t.isStart&&i>0&&(e.pos.time=0)});var l={touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",press:"onPress",pressend:"onPressEnd",click:"onClick",doubleclick:"onDbClick"};if(Object.keys(l).map(function(t){e.touch.on(t,function(i){e[l[t]](i)})}),!o.disableActive){var h=n.plugins.progress;h&&(h.addCallBack("dragmove",function(t){e.activeSeekNote(t.currentTime,t.forward)}),["dragend","click"].forEach(function(t){h.addCallBack(t,function(){e.changeAction(u)})}))}}},{key:"registerThumbnail",value:function(){var e=this.player.plugins.thumbnail;if(e&&e.usable){this.thumbnail=e.createThumbnail(null,"mobile-thumbnail");var t=this.find(".time-preview");t.insertBefore(this.thumbnail,t.children[0])}}},{key:"initCustomStyle",value:function(){var e=(this.playerConfig||{}).commonStyle,i=e.playedColor,s=e.progressColor,o=e.timePreviewStyle,n=e.curTimeColor,a=e.durationColor;if(i&&(this.find(".xg-curbar").style.backgroundColor=i),s&&(this.find(".xg-bar").style.backgroundColor=s),o){var r=this.find(".time-preview");Object.keys(o).forEach(function(e){r.style[e]=o[e]})}var c=n||i,u=a;c&&(this.find(".xg-cur").style.color=c),u&&(this.find(".xg-dur").style.color=u),this.config.disableTimeProgress&&t.default.addClass(this.find(".xg-timebar"),"hide")}},{key:"resetPos",value:function(){var e=this;this.pos?(this.pos.isStart=!1,this.pos.scope=-1,["x","y","width","height","scopeL","scopeR","scopeM1","scopeM2"].map(function(t){e.pos[t]=0})):this.pos={isStart:!1,x:0,y:0,volume:0,rate:1,light:0,width:0,height:0,scopeL:0,scopeR:0,scopeM1:0,scopeM2:0,scope:-1,time:0}}},{key:"changeAction",value:function(e){var t=this.player;this.root.setAttribute("data-xg-action",e);var i=t.plugins.start;i&&i.recover()}},{key:"getTouche",value:function(e){this.player.rotateDeg;var t=e.touches&&e.touches.length>0?e.touches[e.touches.length-1]:e;return{pageX:t.pageX,pageY:t.pageY}}},{key:"checkScope",value:function(e,t,i,s,o){var n=o.width,a=-1;if(e<0||e>n)return a;var r=0===s?Math.abs(i):Math.abs(i/s);return Math.abs(i)>0&&r>=1.73&&e>o.scopeM1&&e<o.scopeM2?a=0:(0===Math.abs(i)||r<=.57)&&(a=e<o.scopeL?1:e>o.scopeR?2:3),a}},{key:"executeMove",value:function(e,t,s,o,n){switch(s){case 0:this.updateTime(e/o*this.config.scopeM);break;case 1:this.updateBrightness(t/n);break;case 2:i.default.os.isIos||this.updateVolume(t/n)}}},{key:"endLastMove",value:function(e){var t=this,i=this.pos,s=this.player,o=this.config,n=(i.time-this.timeOffset)/1e3;if(0===e)s.seek(Number(n).toFixed(1)),o.hideControlsEnd?s.blur():s.focus(),this.timer=setTimeout(function(){t.pos.time=0},500);this.changeAction(u)}},{key:"checkIsRootTarget",value:function(e){var t=this.player.plugins||{};return(!t.progress||!t.progress.root.contains(e.target))&&(t.start&&t.start.root.contains(e.target)||t.controls&&t.controls.root.contains(e.target))}},{key:"sendUseAction",value:function(e){var t=this.player.paused;this.emitUserAction(e,"switch_play_pause",{prop:"paused",from:t,to:!t})}},{key:"clickHandler",value:function(e){var i=this.player,s=this.config,o=this.playerConfig;i.state<a.STATES.RUNNING?o.closeVideoClick||(this.sendUseAction(t.default.createEvent("click")),i.play()):!s.closedbClick||o.closeVideoClick?i.isActive?i.blur():i.focus():o.closeVideoClick||((i.isActive||s.focusVideoClick)&&(this.sendUseAction(t.default.createEvent("click")),this.switchPlayPause()),i.focus())}},{key:"dbClickHandler",value:function(e){var i=this.config,s=this.player;!i.closedbClick&&s.state>=a.STATES.RUNNING&&(this.sendUseAction(t.default.createEvent("dblclick")),this.switchPlayPause())}},{key:"onClick",value:function(e){var t=this,i=this.player;o.runHooks(this,d[0],function(e,i){t.clickHandler(i.e)},{e:e,paused:i.paused})}},{key:"onDbClick",value:function(e){var t=this,i=this.player;o.runHooks(this,d[1],function(e,i){t.dbClickHandler(i.e)},{e:e,paused:i.paused})}},{key:"onPress",value:function(e){var t=this.pos,i=this.config,s=this.player;i.disablePress||(t.rate=this.player.playbackRate,this.emitUserAction("press","change_rate",{prop:"playbackRate",from:s.playbackRate,to:i.pressRate}),s.playbackRate=i.pressRate,this.changeAction(h))}},{key:"onPressEnd",value:function(e){var t=this.pos,i=this.config,s=this.player;i.disablePress||(this.emitUserAction("pressend","change_rate",{prop:"playbackRate",from:s.playbackRate,to:t.rate}),s.playbackRate=t.rate,t.rate=1,this.changeAction(u))}},{key:"updateTime",value:function(e){var t=this.player,i=this.config,s=this.player.duration;e=Number(e.toFixed(4));var o=parseInt(e*i.moveDuration,10)+this.timeOffset;o=(o+=this.pos.time)<0?0:o>1e3*s?1e3*s-200:o,t.getPlugin("time")&&t.getPlugin("time").updateTime(o/1e3),t.getPlugin("progress")&&t.getPlugin("progress").updatePercent(o/1e3/this.duration,!0),this.activeSeekNote(o/1e3,e>0),i.isTouchingSeek&&t.seek(Number((o-this.timeOffset)/1e3).toFixed(1)),this.pos.time=o}},{key:"updateVolume",value:function(e){this.player.rotateDeg&&(e=-e);var t=this.player,i=this.pos;if(e=parseInt(100*e,10),i.volume+=e,!(Math.abs(i.volume)<10)){var s=parseInt(10*t.volume,10)-parseInt(i.volume/10,10);s=s>10?10:s<1?0:s,t.volume=s/10,i.volume=0}}},{key:"updateBrightness",value:function(e){var t=this.pos,i=this.config,s=this.xgMask;if(i.darkness){this.player.rotateDeg&&(e=-e);var o=t.light+.8*e;o=o>i.maxDarkness?i.maxDarkness:o<0?0:o,s&&(s.style.backgroundColor="rgba(0,0,0,".concat(o,")")),t.light=o}}},{key:"activeSeekNote",value:function(e){var i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],s=this.player,o=this.config,n=!(this.duration!==1/0&&this.duration>0);if(e&&"number"==typeof e&&!n&&!o.disableActive){e<0?e=0:e>s.duration&&(e=s.duration-.2),this.changeAction(l);var a=s.plugins.start;a&&a.focusHide(),this.find(".xg-dur").innerHTML=t.default.format(this.duration),this.find(".xg-cur").innerHTML=t.default.format(e),this.find(".xg-curbar").style.width="".concat(e/this.duration*100,"%"),i?t.default.removeClass(this.find(".xg-seek-show"),"xg-back"):t.default.addClass(this.find(".xg-seek-show"),"xg-back"),this.updateThumbnails(e)}}},{key:"updateThumbnails",value:function(e){var t=this.player.plugins.thumbnail;t&&t.usable&&this.thumbnail&&t.update(this.thumbnail,e,160,90)}},{key:"switchPlayPause",value:function(){var e=this.player;if(e.state<a.STATES.ATTACHED)return!1;e.ended||(e.paused?e.play():e.pause())}},{key:"disableGesture",value:function(){this.config.disableGesture=!0}},{key:"enableGesture",value:function(){this.config.disableGesture=!1}},{key:"destroy",value:function(){var e=this.player;this.timer&&clearTimeout(this.timer),this.thumbnail=null,e.root.removeChild(this.xgMask),this.xgMask=null,this.touch&&this.touch.destroy(),this.touch=null,e.root.removeEventListener("touchmove",this.onRootTouchMove,!0),e.root.removeEventListener("touchend",this.onRootTouchEnd,!0),e.root.removeEventListener("touchcancel",this.onRootTouchEnd,!0);var t=this.player.controls;t&&t.center&&(t.center.removeEventListener("touchmove",this.onRootTouchMove,!0),t.center.removeEventListener("touchend",this.onRootTouchEnd,!0),t.center.removeEventListener("touchcancel",this.onRootTouchEnd,!0))}},{key:"render",value:function(){var e="normal"!==this.config.gradient?"gradient ".concat(this.config.gradient):"gradient";return'\n     <xg-trigger class="trigger">\n     <div class="'.concat(e,'"></div>\n        <div class="time-preview">\n            <div class="xg-seek-show ').concat(this.config.disableSeekIcon?" hide-seek-icon":"",'">\n              <i class="xg-seek-icon"></i>\n              <span class="xg-cur">00:00</span>\n              <span class="xg-separator">/</span>\n              <span class="xg-dur">00:00</span>\n            </div>\n              <div class="xg-bar xg-timebar">\n                <div class="xg-curbar"></div>\n              </div>\n        </div>\n        <div class="xg-playbackrate xg-top-note">\n            <span><i>').concat(this.config.pressRate,"X</i>").concat(this.i18n.FORWARD,"</span>\n        </div>\n     </xg-trigger>\n    ")}}],[{key:"pluginName",get:function(){return"mobile"}},{key:"defaultConfig",get:function(){return{index:0,disableGesture:!1,gestureX:!0,gestureY:!0,gradient:"normal",isTouchingSeek:!1,miniMoveStep:5,miniYPer:5,scopeL:.25,scopeR:.25,scopeM:.9,pressRate:2,darkness:!0,maxDarkness:.8,disableActive:!1,disableTimeProgress:!1,hideControlsActive:!1,hideControlsEnd:!1,moveDuration:36e4,closedbClick:!1,disablePress:!0,disableSeekIcon:!1,focusVideoClick:!1}}}]),g}(n.default);exports.default=p;