/*!
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("../../utils/sniffer.js"),s=require("../../events.js"),n=require("../../plugin/plugin.js"),o=require("./optionList.js");var c="side",r="middle",l="default",h="click",a="hover";var u="mobile"===e.default.device,d=function(d){i.inherits(f,d);var g=i.createSuper(f);function f(t){var e;return i.classCallCheck(this,f),e=g.call(this,t),i.defineProperty(i.assertThisInitialized(e),"onEnter",function(i){i.stopPropagation(),e.emit("icon_mouseenter",{pluginName:e.pluginName}),e.switchActiveState(i)}),i.defineProperty(i.assertThisInitialized(e),"switchActiveState",function(i){i.stopPropagation(),e.config.toggleMode===h?e.toggle(!e.isActive):e.toggle(!0)}),i.defineProperty(i.assertThisInitialized(e),"onLeave",function(i){i.stopPropagation(),e.emit("icon_mouseleave",{pluginName:e.pluginName}),e.config.listType!==c&&e.isActive&&e.toggle(!1)}),i.defineProperty(i.assertThisInitialized(e),"onListEnter",function(i){e.enterType=2}),i.defineProperty(i.assertThisInitialized(e),"onListLeave",function(i){e.enterType=0,e.isActive&&e.toggle(!1)}),e.isIcons=!1,e.isActive=!1,e.curValue=null,e.curIndex=0,e}return i.createClass(f,[{key:"updateLang",value:function(i){this.renderItemList(this.config.list,this.curIndex)}},{key:"afterCreate",value:function(){var i=this,n=this.config;this.initIcons(),(u=u||"touch"===this.domEventType)&&"mobile"===e.default.device&&n.listType===l&&(n.listType=c),n.hidePortrait&&t.default.addClass(this.root,"portrait"),this.on([s.VIDEO_RESIZE,s.FULLSCREEN_CHANGE],function(){i._resizeList()}),this.once(s.CANPLAY,function(){n.list&&n.list.length>0&&(i.renderItemList(n.list),i.show())}),u&&this.on(s.PLAYER_FOCUS,function(){i.isActive&&(i.optionsList&&i.optionsList.hide(),i.isActive=!1)}),u?(n.toggleMode=h,this.activeEvent="touchend"):this.activeEvent=n.toggleMode===h?"click":"mouseenter",n.toggleMode===h?this.bind(this.activeEvent,this.switchActiveState):(this.bind(this.activeEvent,this.onEnter),this.bind("mouseleave",this.onLeave)),this.isIcons&&this.bind("click",this.onIconClick)}},{key:"initIcons",value:function(){var i=this,e=this.icons,s=Object.keys(e),n=!1;s.length>0&&(s.forEach(function(t){i.appendChild(".xgplayer-icon",e[t]),!n&&(n=e[t])}),this.isIcons=n),n||(this.appendChild(".xgplayer-icon",t.default.createDom("span","",{},"icon-text")),t.default.addClass(this.find(".xgplayer-icon"),"btn-text"))}},{key:"show",value:function(i){!this.config.list||this.config.list.length<2||t.default.addClass(this.root,"show")}},{key:"hide",value:function(){t.default.removeClass(this.root,"show")}},{key:"getTextByLang",value:function(e,s,n){if(void 0===e)return"";var o=this.config.list;!n&&(n=this.player.lang),s=!s||t.default.isUndefined(e[s])?"text":s,"number"==typeof e&&(e=o[e]);try{return"object"===i.typeof(e[s])?e[s][n]||e[s].en:e[s]}catch(c){return console.warn(c),""}}},{key:"toggle",value:function(i){if(i!==this.isActive&&!this.config.disable){var t=this.player.controls,e=this.config.listType;i?(e===c?t.blur():t.focus(),this.optionsList&&this.optionsList.show()):(e===c?t.focus():t.focusAwhile(),this.optionsList&&this.optionsList.hide()),this.isActive=i}}},{key:"onItemClick",value:function(i,t){i.stopPropagation();var e=this.config,s=e.listType,n=e.list;this.curIndex=t.to.index,this.curItem=n[this.curIndex],this.changeCurrentText(),(this.config.isItemClickHide||u||s===c)&&this.toggle(!1)}},{key:"onIconClick",value:function(i){}},{key:"changeCurrentText",value:function(){if(!this.isIcons){var i=this.config.list,t=i[this.curIndex<i.length?this.curIndex:0];t&&(this.find(".icon-text").innerHTML=this.getTextByLang(t,"iconText"))}}},{key:"renderItemList",value:function(i,t){var e=this,s=this.config,l=this.optionsList,h=this.player;if("number"==typeof t&&(this.curIndex=t,this.curItem=s.list[t]),l)return l.renderItemList(i),void this.changeCurrentText();var a,d,g={config:{data:i||[],className:(a=s.listType,d=s.position,a===c?d===n.POSITIONS.CONTROLS_LEFT?"xg-side-list xg-left-side":"xg-side-list xg-right-side":""),onItemClick:function(i,t){e.onItemClick(i,t)},domEventType:u?"touch":"mouse"},root:s.listType===c?h.innerContainer||h.root:this.root};if(this.config.isShowIcon){var f=this.player.root.getBoundingClientRect().height,p=s.listType===r?f-50:f;p&&s.heightLimit&&(g.config.maxHeight="".concat(p,"px")),this.optionsList=new o.default(g),this.changeCurrentText(),this.show()}this._resizeList()}},{key:"_resizeList",value:function(){if(this.config.heightLimit){var i=this.player.root.getBoundingClientRect().height,t=this.config.listType===r?i-50:i;this.optionsList&&this.optionsList.setStyle({maxHeight:"".concat(t,"px")})}}},{key:"destroy",value:function(){this.config.toggleMode===h?this.unbind(this.activeEvent,this.switchActiveState):(this.unbind(this.activeEvent,this.onEnter),this.unbind("mouseleave",this.onLeave)),this.isIcons&&this.unbind("click",this.onIconClick),this.optionsList&&(this.optionsList.destroy(),this.optionsList=null)}},{key:"render",value:function(){if(this.config.isShowIcon)return'<xg-icon class="xg-options-icon '.concat(this.config.className||"",'">\n    <div class="xgplayer-icon">\n    </div>\n   </xg-icon>')}}],[{key:"pluginName",get:function(){return"optionsIcon"}},{key:"defaultConfig",get:function(){return{position:n.POSITIONS.CONTROLS_RIGHT,index:100,list:[],listType:"default",listStyle:{},hidePortrait:!0,isShowIcon:!1,isItemClickHide:!0,toggleMode:a,heightLimit:!0}}}]),f}(n.default);exports.default=d;