/*!
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 e=require("../../_virtual/_rollupPluginBabelHelpers.js"),t=require("../../utils/util.js"),i=require("../../events.js"),n=require("../../plugin/plugin.js");var r=function(r){e.inherits(o,r);var s=e.createSuper(o);function o(t){var i;return e.classCallCheck(this,o),(i=s.call(this,t)).isActiving=!1,i}return e.createClass(o,[{key:"duration",get:function(){var e=this.player,t=e.offsetDuration,i=e.duration;return this.playerConfig.customDuration||t||i}},{key:"currentTime",get:function(){var e=this.player,t=e.offsetCurrentTime,i=e.currentTime;return t>=0?t:i}},{key:"timeOffset",get:function(){return this.playerConfig.timeOffset||0}},{key:"afterCreate",value:function(){var e=this.player.controls.config.mode;this.mode="flex"===e?"flex":"normal",this.config.disable||("flex"===this.mode&&(this.createCenterTime(),this.root.style.display="none"),this.durationDom=this.find(".time-duration"),this.timeDom=this.find(".time-current"),this.listenEvents())}},{key:"listenEvents",value:function(){var e=this;this.on([i.DURATION_CHANGE,i.SEEKED,i.TIME_UPDATE],function(t){"durationchange"===t.eventName&&(e.isActiving=!1),e.onTimeUpdate()}),this.on(i.ENDED,function(){e.onTimeUpdate(!0)}),this.on(i.EMPTIED,function(){e.onReset()})}},{key:"show",value:function(e){if("flex"===this.mode)return this.centerCurDom&&(this.centerCurDom.style.display="block"),void(this.centerDurDom&&(this.centerDurDom.style.display="block"));this.root.style.display="block"}},{key:"hide",value:function(){if("flex"===this.mode)return this.centerCurDom&&(this.centerCurDom.style.display="none"),void(this.centerDurDom&&(this.centerDurDom.style.display="none"));this.root.style.display="none"}},{key:"onTimeUpdate",value:function(e){var i=this.player,n=this.config,r=this.duration;if(!n.disable&&!this.isActiving&&i.hasStart){var s=this.currentTime+this.timeOffset;s=t.default.adjustTimeByDuration(s,r,e),"flex"===this.mode?(this.centerCurDom.innerHTML=this.minWidthTime(t.default.format(s)),r!==1/0&&r>0&&(this.centerDurDom.innerHTML=t.default.format(r))):(this.timeDom.innerHTML=this.minWidthTime(t.default.format(s)),r!==1/0&&r>0&&(this.durationDom.innerHTML=t.default.format(r)))}}},{key:"onReset",value:function(){"flex"===this.mode?(this.centerCurDom.innerHTML=this.minWidthTime(t.default.format(0)),this.centerDurDom.innerHTML=t.default.format(0)):(this.timeDom.innerHTML=this.minWidthTime(t.default.format(0)),this.durationDom.innerHTML=t.default.format(0))}},{key:"createCenterTime",value:function(){var e=this.player;if(e.controls&&e.controls.center){var i=e.controls.center;this.centerCurDom=t.default.createDom("xg-icon","00:00",{},"xgplayer-time xg-time-left"),this.centerDurDom=t.default.createDom("xg-icon","00:00",{},"xgplayer-time xg-time-right"),i.children.length>0?i.insertBefore(this.centerCurDom,i.children[0]):i.appendChild(this.centerCurDom),i.appendChild(this.centerDurDom),this.extraEls=[this.centerCurDom,this.centerDurDom]}}},{key:"afterPlayerInit",value:function(){var e=this.config;this.duration===1/0||this.playerConfig.isLive?(t.default.hide(this.durationDom),t.default.hide(this.timeDom),t.default.hide(this.find(".time-separator")),t.default.show(this.find(".time-live-tag"))):t.default.hide(this.find(".time-live-tag")),e.hide?this.hide():this.show()}},{key:"changeLiveState",value:function(e){e?(t.default.hide(this.durationDom),t.default.hide(this.timeDom),t.default.hide(this.find(".time-separator")),t.default.show(this.find(".time-live-tag"))):(t.default.hide(this.find(".time-live-tag")),t.default.show(this.find(".time-separator")),t.default.show(this.durationDom),t.default.show(this.timeDom))}},{key:"updateTime",value:function(e){this.isActiving=!0,!e&&0!==e||e>this.duration||("flex"!==this.mode?this.timeDom.innerHTML=this.minWidthTime(t.default.format(e)):this.centerCurDom.innerHTML=this.minWidthTime(t.default.format(e)))}},{key:"minWidthTime",value:function(e){return e.split(":").map(function(e){return'<span class="time-min-width">'.concat(e,"</span>")}).join(":")}},{key:"resetActive",value:function(){var e=this,t=this.player,n=function(){e.isActiving=!1};this.off(i.SEEKED,n),t.isSeeking&&t.media.seeking?this.once(i.SEEKED,n):this.isActiving=!1}},{key:"destroy",value:function(){var e=this.player.controls.center;this.centerCurDom&&e.removeChild(this.centerCurDom),this.centerCurDom=null,this.centerDurDom&&e.removeChild(this.centerDurDom),this.centerDurDom=null}},{key:"render",value:function(){if(!this.config.disable)return'<xg-icon class="xgplayer-time">\n    <span class="time-current">00:00</span>\n    <span class="time-separator">/</span>\n    <span class="time-duration">00:00</span>\n    <span class="time-live-tag">'.concat(this.i18n.LIVE_TIP,"</span>\n    </xg-icon>")}}],[{key:"pluginName",get:function(){return"time"}},{key:"defaultConfig",get:function(){return{position:n.POSITIONS.CONTROLS_LEFT,index:2,disable:!1}}}]),o}(n.default);exports.default=r;