/*!
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 e,createClass as n,objectSpread2 as o,get as r,getPrototypeOf as s}from"../../_virtual/_rollupPluginBabelHelpers.js";import a from"../../utils/util.js";import{DEFINITION_CHANGE as f}from"../../events.js";import{POSITIONS as l}from"../../plugin/plugin.js";import c from"../common/optionsIcon.js";var u=/* @__PURE__ */function(){i(h,c);var u=t(h);function h(i){var t;return e(this,h),(t=u.call(this,i)).curTime=0,t.isPaused=!0,t}return n(h,[{key:"beforeCreate",value:function(i){var t=i.config.list;Array.isArray(t)&&t.length>0&&(i.config.list=t.map(function(i){return!i.text&&i.name&&(i.text=i.name),i.text||(i.text=i.definition),i}))}},{key:"afterCreate",value:function(){var i=this;r(s(h.prototype),"afterCreate",this).call(this),this.on("resourceReady",function(t){i.changeDefinitionList(t)}),this.on(f,function(t){i.renderItemList(i.config.list,t.to)}),this.player.definitionList.length<2&&this.hide()}},{key:"show",value:function(i){!this.config.list||this.config.list.length<2||a.addClass(this.root,"show")}},{key:"initDefinition",value:function(){var i=this.config,t=i.list,e=i.defaultDefinition;if(t.length>0){var n=null;t.map(function(i){i.definition===e&&(n=i)}),n||(n=t[0]),this.changeDefinition(n)}}},{key:"renderItemList",value:function(){var i=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.config.list||[],e=arguments.length>1?arguments[1]:void 0,n=e&&e.definition?e.definition:this.config.defaultDefinition;e&&t.forEach(function(i){i.selected=!1});var a=0,f=t.map(function(t,e){var r=o(o({},t),{},{showText:i.getTextByLang(t)||t.definition,selected:!1});return(t.selected||t.definition&&t.definition==n)&&(r.selected=!0,a=e),r});r(s(h.prototype),"renderItemList",this).call(this,f,a)}},{key:"changeDefinitionList",value:function(i){Array.isArray(i)&&(this.config.list=i.map(function(i){return!i.text&&i.name&&(i.text=i.name),i.text||(i.text=i.definition),i}),this.renderItemList(),this.config.list.length<2?this.hide():this.show())}},{key:"changeDefinition",value:function(i,t){this.player.changeDefinition(i,t)}},{key:"onItemClick",value:function(i,t){var e=this.player.definitionList;r(s(h.prototype),"onItemClick",this).apply(this,arguments),this.emitUserAction(i,"change_definition",{from:t.from,to:t.to});for(var n=0;n<e.length;n++)t.to&&e[n].definition===t.to.definition&&(t.to.url=e[n].url),t.from&&e[n].definition===t.from.definition&&(t.from.url=e[n].url);this.player.changeDefinition(t.to,t.from)}}],[{key:"pluginName",get:function(){return"definition"}},{key:"defaultConfig",get:function(){return o(o({},c.defaultConfig),{},{position:l.CONTROLS_RIGHT,index:3,list:[],defaultDefinition:"",disable:!1,hidePortrait:!1,className:"xgplayer-definition",isShowIcon:!0})}}]),h}();export{u as default};