/*!
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
*/
import{inherits as i,createSuper as t,classCallCheck as s,defineProperty as n,assertThisInitialized as e,createClass as o}from"../../_virtual/_rollupPluginBabelHelpers.js";import l from"../../utils/util.js";import{PAUSE as a,PLAY as r,MINI_STATE_CHANGE as c}from"../../events.js";import h from"../../plugin/plugin.js";import{xgIconTips as p}from"../common/iconTools.js";import d from"../assets/play.js";import g from"../assets/pause.js";import f from"./miniScreenIcon.js";import u from"../../utils/draggabilly.js";var y=/* @__PURE__ */function(){i(m,h);var y=t(m);function m(i){var t;s(this,m),t=y.call(this,i),n(e(t),"onCancelClick",function(i){t.exitMini(),t.isClose=!0}),n(e(t),"onCenterClick",function(i){var s=e(t).player;s.paused?s.play():s.pause()}),n(e(t),"onScroll",function(i){if(!(!window.scrollY&&0!==window.scrollY||Math.abs(window.scrollY-t.pos.scrollY)<50)){var s=parseInt(l.getCss(t.player.root,"height"));s+=t.config.scrollTop,t.pos.scrollY=window.scrollY,window.scrollY>s+5?!t.isMini&&!t.isClose&&t.getMini():window.scrollY<=s&&(t.isMini&&t.exitMini(),t.isClose=!1)}}),t.isMini=!1,t.isClose=!1;var o=e(t).config;return t.pos={left:o.left<0?window.innerWidth-o.width-20:o.left,top:o.top<0?window.innerHeight-o.height-20:o.top,height:t.config.height,width:t.config.width,scrollY:window.scrollY||0},t.lastStyle=null,t}return o(m,[{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(a,function(){i.setAttr("data-state","pause")}),this.on(r,function(){i.setAttr("data-state","play")})}},{key:"onPluginsReady",value:function(){var i=this,t=this.player;if(!this.config.disable){if(this.config.isShowIcon){var s={config:{onClick:function(){i.getMini()}}};t.controls.registerPlugin(f,s,f.pluginName)}var n=l.checkTouchSupport()?"touchend":"click";this.bind(".mini-cancel-btn",n,this.onCancelClick),this.bind(".play-icon",n,this.onCenterClick),this.config.disableDrag||(this._draggabilly=new u(this.player.root,{handle:this.root})),this.config.isScrollSwitch&&window.addEventListener("scroll",this.onScroll)}}},{key:"registerIcons",value:function(){return{play:{icon:d,class:"xg-icon-play"},pause:{icon:g,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 t=this.player,s=this.playerConfig,n=this.config.target||this.player.root;this.lastStyle={},l.addClass(t.root,"xgplayer-mini"),["width","height","top","left"].map(function(t){i.lastStyle[t]=n.style[t],n.style[t]="".concat(i.pos[t],"px")}),s.fluid&&(n.style["padding-top"]=""),this.emit(c,!0),t.isMini=this.isMini=!0}}},{key:"exitMini",value:function(){var i=this;if(!this.isMini)return!1;var t=this.player,s=this.playerConfig,n=this.config.target||this.player.root;l.removeClass(t.root,"xgplayer-mini"),this.lastStyle&&Object.keys(this.lastStyle).map(function(t){n.style[t]=i.lastStyle[t]}),this.lastStyle=null,s.fluid&&(t.root.style.width="100%",t.root.style.height="0",t.root.style["padding-top"]="".concat(100*s.height/s.width,"%")),this.emit(c,!1),this.isMini=t.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=l.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(p(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}}}]),m}();export{f as MiniScreenIcon,y as default};