/*!
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 i=require("../../_virtual/_rollupPluginBabelHelpers.js"),t=require("../../utils/util.js"),e=require("../../events.js"),s=require("../../plugin/plugin.js"),n=require("../common/iconTools.js"),l=require("../assets/play.js"),o=require("../assets/pause.js"),a=require("./miniScreenIcon.js"),r=require("../../utils/draggabilly.js");var c=function(s){i.inherits(h,s);var c=i.createSuper(h);function h(e){var s;i.classCallCheck(this,h),s=c.call(this,e),i.defineProperty(i.assertThisInitialized(s),"onCancelClick",function(i){s.exitMini(),s.isClose=!0}),i.defineProperty(i.assertThisInitialized(s),"onCenterClick",function(t){var e=i.assertThisInitialized(s).player;e.paused?e.play():e.pause()}),i.defineProperty(i.assertThisInitialized(s),"onScroll",function(i){if(!(!window.scrollY&&0!==window.scrollY||Math.abs(window.scrollY-s.pos.scrollY)<50)){var e=parseInt(t.default.getCss(s.player.root,"height"));e+=s.config.scrollTop,s.pos.scrollY=window.scrollY,window.scrollY>e+5?!s.isMini&&!s.isClose&&s.getMini():window.scrollY<=e&&(s.isMini&&s.exitMini(),s.isClose=!1)}}),s.isMini=!1,s.isClose=!1;var n=i.assertThisInitialized(s).config;return s.pos={left:n.left<0?window.innerWidth-n.width-20:n.left,top:n.top<0?window.innerHeight-n.height-20:n.top,height:s.config.height,width:s.config.width,scrollY:window.scrollY||0},s.lastStyle=null,s}return i.createClass(h,[{key:"beforeCreate",value:function(i){"boolean"==typeof i.player.config.mini&&(i.config.isShowIcon=i.player.config.mini)}},{key:"afterCreate",value:function(){var i=this;this.initIcons(),this.on(e.PAUSE,function(){i.setAttr("data-state","pause")}),this.on(e.PLAY,function(){i.setAttr("data-state","play")})}},{key:"onPluginsReady",value:function(){var i=this,e=this.player;if(!this.config.disable){if(this.config.isShowIcon){var s={config:{onClick:function(){i.getMini()}}};e.controls.registerPlugin(a.default,s,a.default.pluginName)}var n=t.default.checkTouchSupport()?"touchend":"click";this.bind(".mini-cancel-btn",n,this.onCancelClick),this.bind(".play-icon",n,this.onCenterClick),this.config.disableDrag||(this._draggabilly=new r.default(this.player.root,{handle:this.root})),this.config.isScrollSwitch&&window.addEventListener("scroll",this.onScroll)}}},{key:"registerIcons",value:function(){return{play:{icon:l.default,class:"xg-icon-play"},pause:{icon:o.default,class:"xg-icon-pause"}}}},{key:"initIcons",value:function(){var i=this.icons;this.appendChild(".play-icon",i.play),this.appendChild(".play-icon",i.pause)}},{key:"getMini",value:function(){var i=this;if(!this.isMini){var s=this.player,n=this.playerConfig,l=this.config.target||this.player.root;this.lastStyle={},t.default.addClass(s.root,"xgplayer-mini"),["width","height","top","left"].map(function(t){i.lastStyle[t]=l.style[t],l.style[t]="".concat(i.pos[t],"px")}),n.fluid&&(l.style["padding-top"]=""),this.emit(e.MINI_STATE_CHANGE,!0),s.isMini=this.isMini=!0}}},{key:"exitMini",value:function(){var i=this;if(!this.isMini)return!1;var s=this.player,n=this.playerConfig,l=this.config.target||this.player.root;t.default.removeClass(s.root,"xgplayer-mini"),this.lastStyle&&Object.keys(this.lastStyle).map(function(t){l.style[t]=i.lastStyle[t]}),this.lastStyle=null,n.fluid&&(s.root.style.width="100%",s.root.style.height="0",s.root.style["padding-top"]="".concat(100*n.height/n.width,"%")),this.emit(e.MINI_STATE_CHANGE,!1),this.isMini=s.isMini=!1}},{key:"updatePos",value:function(i){this.pos=Object.assign(this.pos,i),this.isMini&&(this.player.root.style.left="".concat(this.pos.left,"px"),this.player.root.style.top="".concat(this.pos.top,"px"),this.player.root.style.width="".concat(this.pos.width,"px"),this.player.root.style.height="".concat(this.pos.height,"px"))}},{key:"destroy",value:function(){window.removeEventListener("scroll",this.onScroll);var i=t.default.checkTouchSupport()?"touchend":"click";this.unbind(".mini-cancel-btn",i,this.onCancelClick),this.unbind(".play-icon",i,this.onCenterClick),this._draggabilly&&this._draggabilly.destroy(),this._draggabilly=null,this.exitMini()}},{key:"render",value:function(){if(!this.config.disable)return'\n      <xg-mini-layer class="xg-mini-layer">\n      <xg-mini-header class="xgplayer-mini-header">\n      '.concat(n.xgIconTips(this,"MINI_DRAG",this.playerConfig.isHideTips),'\n      </xg-mini-header>\n      <div class="mini-cancel-btn">\n        <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">\n          <path fill="#fff" fill-rule="evenodd" d="M3.99 3.49a1 1 0 0 1 1.414 0L10 8.085l4.596-4.595a1 1 0 1 1 1.414 1.414L11.414 9.5l4.596 4.596a1 1 0 0 1 .084 1.32l-.084.094a1 1 0 0 1-1.414 0L10 10.914 5.404 15.51a1 1 0 0 1-1.414-1.414L8.585 9.5 3.99 4.904a1 1 0 0 1-.084-1.32z"></path>\n        </svg>\n      </div>\n      <div class="play-icon">\n      </div>\n      </xg-mini-layer>')}}],[{key:"pluginName",get:function(){return"miniscreen"}},{key:"defaultConfig",get:function(){return{index:10,disable:!1,width:320,height:180,left:-1,top:-1,isShowIcon:!1,isScrollSwitch:!1,scrollTop:0,disableDrag:!1}}}]),h}(s.default);exports.MiniScreenIcon=a.default,exports.default=c;