/*!
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 t,createSuper as e,classCallCheck as a,createClass as r,objectSpread2 as i,get as n,getPrototypeOf as s}from"../../_virtual/_rollupPluginBabelHelpers.js";import{RATE_CHANGE as o}from"../../events.js";import{POSITIONS as l}from"../../plugin/plugin.js";import c from"../common/optionsIcon.js";var u=/* @__PURE__ */function(){t(p,c);var u=e(p);function p(t){var e;return a(this,p),(e=u.call(this,t)).curRate=1,e}return r(p,[{key:"beforeCreate",value:function(t){var e=t.player.config.playbackRate,a=e?Array.isArray(e)?e:t.config.list:[];Array.isArray(a)&&(t.config.list=a.map(function(t){return"number"==typeof t?t={rate:t,text:"".concat(t,"x")}:!t.text&&t.rate&&(t.text="".concat(t.rate,"x")),t}))}},{key:"afterCreate",value:function(){var t=this;n(s(p.prototype),"afterCreate",this).call(this),this.on(o,function(){t.curValue!==t.player.playbackRate&&t.renderItemList()}),this.renderItemList()}},{key:"show",value:function(t){this.config.list&&0!==this.config.list.length&&n(s(p.prototype),"show",this).call(this)}},{key:"onItemClick",value:function(t,e){n(s(p.prototype),"onItemClick",this).call(this,t,e);var a=t.delegateTarget,r=Number(a.getAttribute("rate"));if(!r||r===this.curValue)return!1;var i={playbackRate:{from:this.player.playbackRate,to:r}};this.emitUserAction(t,"change_rate",{props:i}),this.curValue=r,this.player.playbackRate=r}},{key:"renderItemList",value:function(){var t=this,e=this.player.playbackRate||1;this.curValue=e;var a=-1,r=this.config.list.map(function(r,i){var n={rate:r.rate};return n.rate===e&&(n.selected=!0,a=i),n.showText=t.getTextByLang(r),n});n(s(p.prototype),"renderItemList",this).call(this,r,a)}},{key:"changeCurrentText",value:function(){if(!this.isIcons){var t=this.config.list,e=t[this.curIndex<t.length?this.curIndex:0],a="";a=!e||this.curIndex<0?"".concat(this.player.playbackRate,"x"):this.getTextByLang(e,"iconText"),this.find(".icon-text").innerHTML=a}}},{key:"destroy",value:function(){n(s(p.prototype),"destroy",this).call(this)}}],[{key:"pluginName",get:function(){return"playbackRate"}},{key:"defaultConfig",get:function(){return i(i({},c.defaultConfig),{},{position:l.CONTROLS_RIGHT,index:4,list:[2,1.5,1,.75,.5],className:"xgplayer-playbackrate",isShowIcon:!0,hidePortrait:!1})}}]),p}();export{u as default};