/*!
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("./mediaProxy.js"),i=require("./utils/util.js"),s=require("./utils/sniffer.js"),n=require("./utils/database.js"),o=require("./error.js"),r=require("./events.js"),a=require("./constant.js"),l=require("./plugin/plugin.js"),u=require("./plugin/basePlugin.js"),c=require("./plugin/pluginsManager.js"),f=require("./stateClassMap.js"),h=require("./defaultConfig.js"),d=require("./plugin/preset.js"),g=require("./plugin/hooksDescriptor.js"),v=require("./plugins/controls/index.js"),p=require("./utils/debug.js"),y=require("./lang/i18n.js"),m=require("./version.js"),E=require("./state.js"),T=require("./instManager.js");var _=["play","pause","replay","retry"],S=0,A=0,C=null,k=function(t){e.inherits(P,t);var k=e.createSuper(P);function P(t){var o;e.classCallCheck(this,P);var l=i.default.deepMerge(h.default(),t);o=k.call(this,l),e.defineProperty(e.assertThisInitialized(o),"canPlayFunc",function(){if(o.config){var e=o.config,t=e.autoplay,i=e.defaultPlaybackRate;p.default.logInfo("player","canPlayFunc, startTime",o.__startTime),o._seekToStartTime(),o.playbackRate=i,(t||o._useAutoplay)&&o.mediaPlay(),o.off(r.CANPLAY,o.canPlayFunc),o.removeClass(f.default.ENTER)}}),e.defineProperty(e.assertThisInitialized(o),"onFullscreenChange",function(t,s){var n=function(){i.default.setTimeout(e.assertThisInitialized(o),function(){o.resize()},100)},l=i.default.getFullScreenEl();o._fullActionFrom?o._fullActionFrom="":o.emit(r.USER_ACTION,{eventType:"system",action:"switch_fullscreen",pluginName:"player",currentTime:o.currentTime,duration:o.duration,props:[{prop:"fullscreen",from:!0,to:!1}]});var u=i.checkIsCurrentVideo(l,o.playerId,a.PLATER_ID);if(s||l&&(l===o._fullscreenEl||u))n(),!o.config.closeFocusVideoFocus&&o.media.focus(),o.fullscreen=!0,o.changeFullStyle(o.root,l,f.default.FULLSCREEN),o.emit(r.FULLSCREEN_CHANGE,!0,o._fullScreenOffset),o.cssfullscreen&&o.exitCssFullscreen();else if(o.fullscreen){n();var c=e.assertThisInitialized(o),h=c._fullScreenOffset;if(c.config.needFullscreenScroll?(window.scrollTo(h.left,h.top),i.default.setTimeout(e.assertThisInitialized(o),function(){o.fullscreen=!1,o._fullScreenOffset=null},100)):(!o.config.closeFocusVideoFocus&&o.media.focus(),o.fullscreen=!1,o._fullScreenOffset=null),o.cssfullscreen)o.removeClass(f.default.FULLSCREEN);else{var d=o._fullscreenEl;d||!o.root.contains(t.target)&&t.target!==o.root||(d=t.target),o.recoverFullStyle(o.root,d,f.default.FULLSCREEN)}o._fullscreenEl=null,o.emit(r.FULLSCREEN_CHANGE,!1)}}),e.defineProperty(e.assertThisInitialized(o),"_onWebkitbeginfullscreen",function(e){o._fullscreenEl=o.media,o.onFullscreenChange(e,!0)}),e.defineProperty(e.assertThisInitialized(o),"_onWebkitendfullscreen",function(e){o.onFullscreenChange(e,!1)}),g.default(e.assertThisInitialized(o),_),o.config=l,o._pluginInfoId=i.default.generateSessionId(),p.bindDebug(e.assertThisInitialized(o));var u=o.constructor.defaultPreset;if(o.config.presets.length){var d=o.config.presets.indexOf("default");d>=0&&u&&(o.config.presets[d]=u)}else u&&o.config.presets.push(u);if(o.userTimer=null,o.waitTimer=null,o.handleSource=!0,o._state=E.STATES.INITIAL,o.isAd=!1,o.isError=!1,o._hasStart=!1,o.isSeeking=!1,o.isCanplay=!1,o._useAutoplay=!1,o.__startTime=-1,o.rotateDeg=0,o.isActive=!1,o.fullscreen=!1,o.cssfullscreen=!1,o.isRotateFullscreen=!1,o._fullscreenEl=null,o.timeSegments=[],o._cssfullscreenEl=null,o.curDefinition=null,o._orgCss="",o._fullScreenOffset=null,o._videoHeight=0,o._videoWidth=0,o.videoPos={pi:1,scale:0,rotate:-1,x:0,y:0,h:-1,w:-1,vy:0,vx:0},o.sizeInfo={width:0,height:0,left:0,top:0},o._accPlayed={t:0,acc:0,loopAcc:0},o._offsetInfo={currentTime:-1,duration:0},o.innerContainer=null,o.controls=null,o.topBar=null,o.root=null,o.__i18n=y.default.init(o._pluginInfoId),s.default.os.isAndroid&&s.default.osVersion>0&&s.default.osVersion<6&&(o.config.autoplay=!1),o.database=new n.default,o.isUserActive=!1,o._onceSeekCanplay=null,o._isPauseBeforeSeek=0,o.innerStates={isActiveLocked:!1},o.instManager=C,!o._initDOM())return console.error(new Error("can't find the dom which id is ".concat(o.config.id," or this.config.el does not exist"))),e.possibleConstructorReturn(o);var v=o.config,m=v.definition,T=void 0===m?{}:m;if(!v.url&&T.list&&T.list.length>0){var S=T.list.find(function(e){return e.definition&&e.definition===T.defaultDefinition});S||(T.defaultDefinition=T.list[0].definition,S=T.list[0]),o.config.url=S.url,o.curDefinition=S}return o._bindEvents(),o._registerPresets(),o._registerPlugins(),c.default.onPluginsReady(e.assertThisInitialized(o)),o.getInitDefinition(),o.setState(E.STATES.READY),i.default.setTimeout(e.assertThisInitialized(o),function(){o.emit(r.READY)},0),o.onReady&&o.onReady(),(o.config.videoInit||o.config.autoplay)&&(!o.hasStart||o.state<E.STATES.ATTACHED)&&o.start(),o}return e.createClass(P,[{key:"_initDOM",value:function(){var e,t=this;if(this.root=this.config.id?document.getElementById(this.config.id):null,!this.root){var i=this.config.el;if(!i||1!==i.nodeType)return this.emit(r.ERROR,new o.default("use",this.config.vid,{line:32,handle:"Constructor",msg:"container id can't be empty"})),console.error("this.confg.id or this.config.el can't be empty"),!1;this.root=i}var n=T.checkPlayerRoot(this.root);if(n&&(p.default.logWarn("The is an Player instance already exists in this.root, destroy it and reinitialize"),n.destroy()),this.root.setAttribute(a.PLATER_ID,this.playerId),this.media.setAttribute(a.PLATER_ID,this.playerId),null===(e=C)||void 0===e||e.add(this),c.default.init(this),this._initBaseDoms(),this.config.controls){var l=this.config.controls.root||null,u=c.default.register(this,v.default,{root:l});this.controls=u}var h="mobile"===this.config.isMobileSimulateMode?"mobile":s.default.device;if(this.addClass("".concat(f.default.DEFAULT," ").concat(f.default.INACTIVE," xgplayer-").concat(h," ").concat(this.config.controls?"":f.default.NO_CONTROLS)),this.config.autoplay?this.addClass(f.default.ENTER):this.addClass(f.default.NO_START),this.config.fluid){var d=this.config,g=d.width,y=d.height;"number"==typeof g&&"number"==typeof y||(g=600,y=337.5);var m={width:"100%",height:"0","max-width":"100%","padding-top":"".concat(100*y/g,"%")};Object.keys(m).forEach(function(e){t.root.style[e]=m[e]})}else["width","height"].forEach(function(e){t.config[e]&&("number"!=typeof t.config[e]?t.root.style[e]=t.config[e]:t.root.style[e]="".concat(t.config[e],"px"))});var E=this.root.getBoundingClientRect(),_=E.width,S=E.height,A=E.left,k=E.top;return this.sizeInfo.width=_,this.sizeInfo.height=S,this.sizeInfo.left=A,this.sizeInfo.top=k,!0}},{key:"_initBaseDoms",value:function(){this.topBar=null,this.leftBar=null,this.rightBar=null,this.config.marginControls&&(this.innerContainer=i.default.createDom("xg-video-container","",{"data-index":-1},"xg-video-container"),this.root.appendChild(this.innerContainer))}},{key:"_bindEvents",value:function(){var e=this;["focus","blur"].forEach(function(t){e.on(t,e["on"+t.charAt(0).toUpperCase()+t.slice(1)])}),a.FULLSCREEN_EVENTS.forEach(function(t){document&&document.addEventListener(t,e.onFullscreenChange)}),s.default.os.isIos&&(this.media.addEventListener("webkitbeginfullscreen",this._onWebkitbeginfullscreen),this.media.addEventListener("webkitendfullscreen",this._onWebkitendfullscreen)),this.once(r.LOADED_DATA,this.resize),this.playFunc=function(){e.config.closeFocusVideoFocus||e.media.focus()},this.once(r.PLAY,this.playFunc)}},{key:"_unbindEvents",value:function(){var e=this;this.root.removeEventListener("mousemove",this.mousemoveFunc),a.FULLSCREEN_EVENTS.forEach(function(t){document.removeEventListener(t,e.onFullscreenChange)}),this.playFunc&&this.off(r.PLAY,this.playFunc),this.off(r.CANPLAY,this.canPlayFunc),this.media.removeEventListener("webkitbeginfullscreen",this._onWebkitbeginfullscreen),this.media.removeEventListener("webkitendfullscreen",this._onWebkitendfullscreen)}},{key:"_clearUserTimer",value:function(){this.userTimer&&(i.default.clearTimeout(this,this.userTimer),this.userTimer=null)}},{key:"_startInit",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.media&&(e&&""!==e&&("Array"!==i.default.typeOf(e)||0!==e.length)||(e="",this.emit(r.URL_NULL),p.default.logWarn("config.url is null, please get url and run player._startInit(url)"),!this.config.nullUrlStart))){i.default.isNotNull(n.playSessionId)&&(this._playSessionId=n.playSessionId),this.handleSource&&(this._detachSourceEvents(this.media),"Array"===i.default.typeOf(e)&&e.length>0?this._attachSourceEvents(this.media,e):this.media.src&&this.media.src===e?e||this.media.removeAttribute("src"):this.media.src=e),"Number"===i.default.typeOf(this.config.volume)&&(this.volume=this.config.volume);var o=this.innerContainer?this.innerContainer:this.root;this.media instanceof window.Element&&!o.contains(this.media)&&o.insertBefore(this.media,o.firstChild);var a=this.media.readyState;p.default.logInfo("_startInit readyState",a),this.config.autoplay&&(!i.default.isMSE(this.media)&&this.load(),(s.default.os.isIpad||s.default.os.isPhone)&&this.mediaPlay());var l=this.config.startTime;this.__startTime=l>0?l:-1,this.config.startTime=0,a>=2&&this.duration>0?this.canPlayFunc():this.on(r.CANPLAY,this.canPlayFunc),(!this.hasStart||this.state<E.STATES.ATTACHED)&&c.default.afterInit(this),this.hasStart=!0,this.setState(E.STATES.ATTACHED),i.default.setTimeout(this,function(){t.emit(r.COMPLETE)},0)}}},{key:"_registerPlugins",value:function(){var e=this,t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this._loadingPlugins=[];var i=this.config.ignores||[],s=this.config.plugins||[],n=this.config.i18n||[];t&&y.default.extend(n,this.__i18n);var o=i.join("||").toLowerCase().split("||"),r=this.plugins;s.forEach(function(i){try{var s=i.plugin?i.plugin.pluginName:i.pluginName;if(s&&o.indexOf(s.toLowerCase())>-1)return null;if(!t&&r[s.toLowerCase()])return;if(i.lazy&&i.loader){var n=c.default.lazyRegister(e,i);return void(i.forceBeforeInit&&(n.then(function(){e._loadingPlugins.splice(e._loadingPlugins.indexOf(n),1)}).catch(function(t){p.default.logError("_registerPlugins:loadingPlugin",t),e._loadingPlugins.splice(e._loadingPlugins.indexOf(n),1)}),e._loadingPlugins.push(n)))}return e.registerPlugin(i)}catch(a){p.default.logError("_registerPlugins:",a)}})}},{key:"_registerPresets",value:function(){var e=this;this.config.presets.forEach(function(t){d.usePreset(e,t)})}},{key:"_getRootByPosition",value:function(e){var t=null;switch(e){case l.POSITIONS.ROOT_RIGHT:this.rightBar||(this.rightBar=i.default.createPositionBar("xg-right-bar",this.root)),t=this.rightBar;break;case l.POSITIONS.ROOT_LEFT:this.leftBar||(this.leftBar=i.default.createPositionBar("xg-left-bar",this.root)),t=this.leftBar;break;case l.POSITIONS.ROOT_TOP:this.topBar||(this.topBar=i.default.createPositionBar("xg-top-bar",this.root),this.config.topBarAutoHide&&i.default.addClass(this.topBar,f.default.TOP_BAR_AUTOHIDE)),t=this.topBar;break;default:t=this.innerContainer||this.root}return t}},{key:"registerPlugin",value:function(e,t){var i=c.default.formatPluginInfo(e,t),s=i.PLUFGIN,n=i.options,o=this.config.plugins;!c.default.checkPluginIfExits(s.pluginName,o)&&o.push(s);var r=c.default.getRootByConfig(s.pluginName,this.config);r.root&&(n.root=r.root),r.position&&(n.position=r.position);var a,l=n.position?n.position:n.config&&n.config.position||s.defaultConfig&&s.defaultConfig.position;return!n.root&&"string"==typeof l&&l.indexOf("controls")>-1?null===(a=this.controls)||void 0===a?void 0:a.registerPlugin(s,n,s.pluginName):(n.root||(n.root=this._getRootByPosition(l)),c.default.register(this,s,n))}},{key:"deregister",value:function(e){"string"==typeof e?c.default.unRegister(this,e):e instanceof u.default&&c.default.unRegister(this,e.pluginName)}},{key:"unRegisterPlugin",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.deregister(e),t&&this.removePluginFromConfig(e)}},{key:"removePluginFromConfig",value:function(e){var t;if("string"==typeof e?t=e:e instanceof u.default&&(t=e.pluginName),t)for(var i=this.config.plugins.length-1;i>-1;i--){if(this.config.plugins[i].pluginName.toLowerCase()===t.toLowerCase()){this.config.plugins.splice(i,1);break}}}},{key:"plugins",get:function(){return c.default.getPlugins(this)}},{key:"getPlugin",value:function(e){var t=c.default.findPlugin(this,e);return t&&t.pluginName?t:null}},{key:"addClass",value:function(e){this.root&&(i.default.hasClass(this.root,e)||i.default.addClass(this.root,e))}},{key:"removeClass",value:function(e){this.root&&i.default.removeClass(this.root,e)}},{key:"hasClass",value:function(e){if(this.root)return i.default.hasClass(this.root,e)}},{key:"setAttribute",value:function(e,t){this.root&&this.root.setAttribute(e,t)}},{key:"removeAttribute",value:function(e,t){this.root&&this.root.removeAttribute(e,t)}},{key:"start",value:function(e){var t=this;if(!(this.state>E.STATES.ATTACHING)){var s=this._playSessionId;return i.default.isNotNull(s)&&(this._playSessionId=void 0),e||this.config.url||this.getInitDefinition(),this.hasStart=!0,this.setState(E.STATES.ATTACHING),this._registerPlugins(!1),c.default.beforeInit(this).then(function(){if(t.config){e||(e=t.url||t.config.url);var i=t.preProcessUrl(e);return t._startInit(i.url,{playSessionId:s})}}).catch(function(e){throw e.fileName="player",e.lineNumber="236",p.default.logError("start:beforeInit:",e),e})}}},{key:"switchURL",value:function(e,t){var n=this,o=e;"Object"===i.default.typeOf(e)&&(o=e.url),o=this.preProcessUrl(o).url;var r=this.currentTime;this.__startTime=r;var a=this.paused&&!this.isError;return this.src=o,new Promise(function(e,t){var i=function(e){n.off("timeupdate",r),n.off("canplay",r),t(e)},r=function(){n._seekToStartTime(),a&&n.pause(),n.off("error",i),e(!0)};n.once("error",i),o?(s.default.os.isAndroid?n.once("timeupdate",r):n.once("canplay",r),n.play()):n.errorHandler("error",{code:6,message:"empty_src"})})}},{key:"videoPlay",value:function(){this.mediaPlay()}},{key:"mediaPlay",value:function(){var t=this;if(!this.hasStart&&this.state<E.STATES.ATTACHED)return this.removeClass(f.default.NO_START),this.addClass(f.default.ENTER),this.start(),void(this._useAutoplay=!0);this.state<E.STATES.RUNNING&&(this.removeClass(f.default.NO_START),!this.isCanplay&&this.addClass(f.default.ENTER));var s=e.get(e.getPrototypeOf(P.prototype),"play",this).call(this);return void 0!==s&&s&&s.then?s.then(function(){t.removeClass(f.default.NOT_ALLOW_AUTOPLAY),t.addClass(f.default.PLAYING),t.state<E.STATES.RUNNING&&(p.default.logInfo(">>>>playPromise.then"),t.setState(E.STATES.RUNNING),t.emit(r.AUTOPLAY_STARTED))}).catch(function(e){if(p.default.logWarn(">>>>playPromise.catch",e.name),t.media&&t.media.error)return t.onError(),void t.removeClass(f.default.ENTER);"NotAllowedError"===e.name&&(t._errorTimer=i.default.setTimeout(t,function(){t._errorTimer=null,t.emit(r.AUTOPLAY_PREVENTED),t.addClass(f.default.NOT_ALLOW_AUTOPLAY),t.removeClass(f.default.ENTER),t.pause(),t.setState(E.STATES.NOTALLOW)},0))}):(p.default.logWarn("video.play not return promise"),this.state<E.STATES.RUNNING&&(this.setState(E.STATES.RUNNING),this.removeClass(f.default.NOT_ALLOW_AUTOPLAY),this.removeClass(f.default.NO_START),this.removeClass(f.default.ENTER),this.addClass(f.default.PLAYING),this.emit(r.AUTOPLAY_STARTED))),s}},{key:"mediaPause",value:function(){e.get(e.getPrototypeOf(P.prototype),"pause",this).call(this)}},{key:"videoPause",value:function(){e.get(e.getPrototypeOf(P.prototype),"pause",this).call(this)}},{key:"play",value:function(){var e=this;return this.removeClass(f.default.PAUSED),g.runHooks(this,"play",function(){return e.mediaPlay()})}},{key:"pause",value:function(){var t=this;g.runHooks(this,"pause",function(){e.get(e.getPrototypeOf(P.prototype),"pause",t).call(t)})}},{key:"seek",value:function(e,t){var i=this;if(this.media&&!Number.isNaN(Number(e))&&this.hasStart){var s=this.config,n=s.isSeekedPlay,o=s.seekedStatus,a=t||(n?"play":o);e=e<0?0:e>this.duration?parseInt(this.duration,10):e,!this._isPauseBeforeSeek&&(this._isPauseBeforeSeek=this.paused?2:1),this._onceSeekCanplay&&this.off(r.SEEKED,this._onceSeekCanplay),this._onceSeekCanplay=function(){switch(i.removeClass(f.default.ENTER),i.isSeeking=!1,a){case"play":i.play();break;case"pause":i.pause();break;default:i._isPauseBeforeSeek>1||i.paused?i.pause():i.play()}i._isPauseBeforeSeek=0,i._onceSeekCanplay=null},this.once(r.SEEKED,this._onceSeekCanplay),this.state<E.STATES.RUNNING?(this.removeClass(f.default.NO_START),this.currentTime=e,this.play()):this.currentTime=e}}},{key:"getInitDefinition",value:function(){var e=this,t=this.config,i=t.definition;!t.url&&i&&i.list&&i.list.length>0&&i.defaultDefinition&&i.list.map(function(t){t.definition===i.defaultDefinition&&(e.config.url=t.url,e.curDefinition=t)})}},{key:"changeDefinition",value:function(t,i){var s=this,n=this.config.definition;if(Array.isArray(null==n?void 0:n.list)&&n.list.forEach(function(e){(null==t?void 0:t.definition)===e.definition&&(s.curDefinition=e)}),null!=t&&t.bitrate&&"number"!=typeof t.bitrate&&(t.bitrate=parseInt(t.bitrate,10)||0),this.emit(r.DEFINITION_CHANGE,{from:i,to:t}),this.hasStart){var o=this.switchURL(t.url,e.objectSpread2({seamless:!1!==n.seamless&&"undefined"!=typeof MediaSource&&"function"==typeof MediaSource.isTypeSupported},t));o&&o.then?o.then(function(){s.emit(r.AFTER_DEFINITION_CHANGE,{from:i,to:t})}):this.emit(r.AFTER_DEFINITION_CHANGE,{from:i,to:t})}else this.config.url=t.url}},{key:"reload",value:function(){this.load(),this.reloadFunc=function(){this.play()},this.once(r.LOADED_DATA,this.reloadFunc)}},{key:"resetState",value:function(){var e=this,t=[f.default.NOT_ALLOW_AUTOPLAY,f.default.PLAYING,f.default.NO_START,f.default.PAUSED,f.default.REPLAY,f.default.ENTER,f.default.ENDED,f.default.ERROR,f.default.LOADING];this.hasStart=!1,this.isError=!1,this._useAutoplay=!1,this.mediaPause(),this._accPlayed.acc=0,this._accPlayed.t=0,this._accPlayed.loopAcc=0,t.forEach(function(t){e.removeClass(t)}),this.addClass(f.default.NO_START),this.emit(r.RESET)}},{key:"reset",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],i=arguments.length>1?arguments[1]:void 0;if(this.resetState(),this.plugins&&(t.map(function(t){e.deregister(t)}),i)){var s=h.default();Object.keys(this.config).forEach(function(t){"undefined"===e.config[t]||"plugins"!==t&&"presets"!==t&&"el"!==t&&"id"!==t||(e.config[t]=s[t])})}}},{key:"destroy",value:function(){var t,s=this,n=this.innerContainer,o=this.root,l=this.media;if(o&&l){if(this.hasStart=!1,this._useAutoplay=!1,o.removeAttribute(a.PLATER_ID),l.removeAttribute(a.PLATER_ID),this.updateAcc("destroy"),this._unbindEvents(),this._detachSourceEvents(this.media),i.default.clearAllTimers(this),this.emit(r.DESTROY),null===(t=C)||void 0===t||t.remove(this),c.default.destroy(this),g.delHooksDescriptor(this),e.get(e.getPrototypeOf(P.prototype),"destroy",this).call(this),this.fullscreen&&this._fullscreenEl===this.root&&this.exitFullscreen(),n)for(var u=n.children,f=0;f<u.length;f++)n.removeChild(u[f]);!n&&l instanceof window.Node&&o.contains(l)&&!this.config.remainMediaAfterDestroy&&o.removeChild(l),["topBar","leftBar","rightBar","innerContainer"].map(function(e){s[e]&&o.removeChild(s[e]),s[e]=null});var h=o.className.split(" ");h.length>0?o.className=h.filter(function(e){return e.indexOf("xgplayer")<0}).join(" "):o.className="",this.removeAttribute("data-xgfill"),["isSeeking","isCanplay","isActive","cssfullscreen","fullscreen"].forEach(function(e){s[e]=!1})}}},{key:"replay",value:function(){var e=this;this.removeClass(f.default.ENDED),this.currentTime=0,this.isSeeking=!1,g.runHooks(this,"replay",function(){e.once(r.SEEKED,function(){var t=e.mediaPlay();t&&t.catch&&t.catch(function(e){console.log(e)})}),e.emit(r.REPLAY),e.onPlay()})}},{key:"retry",value:function(){var e=this;this.removeClass(f.default.ERROR),this.addClass(f.default.LOADING),g.runHooks(this,"retry",function(){var t=e.currentTime,s=e.config.url,n=i.default.isMSE(e.media)?{url:s}:e.preProcessUrl(s);e.src=n.url,!e.config.isLive&&(e.currentTime=t),e.once(r.CANPLAY,function(){e.mediaPlay()})})}},{key:"changeFullStyle",value:function(e,t,s,n){e&&(n||(n=f.default.PARENT_FULLSCREEN),this._orgCss||(this._orgCss=i.default.filterStyleFromText(e)),i.default.addClass(e,s),t&&t!==e&&!this._orgPCss&&(this._orgPCss=i.default.filterStyleFromText(t),i.default.addClass(t,n),t.setAttribute(a.PLATER_ID,this.playerId)))}},{key:"recoverFullStyle",value:function(e,t,s,n){n||(n=f.default.PARENT_FULLSCREEN),this._orgCss&&(i.default.setStyleFromCsstext(e,this._orgCss),this._orgCss=""),i.default.removeClass(e,s),t&&t!==e&&this._orgPCss&&(i.default.setStyleFromCsstext(t,this._orgPCss),this._orgPCss="",i.default.removeClass(t,n),t.removeAttribute(a.PLATER_ID))}},{key:"getFullscreen",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.config.fullscreenTarget,t=this.root,s=this.media;if("video"!==e&&"media"!==e||(e=this[e]),e||(e=t),this._fullScreenOffset={top:i.default.scrollTop(),left:i.default.scrollLeft()},this._fullscreenEl=e,this._fullActionFrom="get",i.default.getFullScreenEl()===this._fullscreenEl)return this.onFullscreenChange(),Promise.resolve();try{for(var n=0;n<a.GET_FULLSCREEN_API.length;n++){var o=a.GET_FULLSCREEN_API[n];if(e[o]){var r="webkitRequestFullscreen"===o?e.webkitRequestFullscreen(window.Element.ALLOW_KEYBOARD_INPUT):e[o]();return r&&r.then?r:Promise.resolve()}}return s.fullscreenEnabled||s.webkitSupportsFullscreen?(s.webkitEnterFullscreen(),Promise.resolve()):Promise.reject(new Error("call getFullscreen fail"))}catch(l){return Promise.reject(new Error("call getFullscreen fail"))}}},{key:"exitFullscreen",value:function(e){if(this.isRotateFullscreen&&this.exitRotateFullscreen(),this._fullscreenEl||i.default.getFullScreenEl()){this.root;var t=this.media;this._fullActionFrom="exit";try{for(var s=0;s<a.EXIT_FULLSCREEN_API.length;s++){var n=a.EXIT_FULLSCREEN_API[s];if(document[n]){var o=document[n]();return o&&o.then?o:Promise.resolve()}}return t&&t.webkitSupportsFullscreen?(t.webkitExitFullScreen(),Promise.resolve()):Promise.reject(new Error("call exitFullscreen fail"))}catch(r){return Promise.reject(new Error("call exitFullscreen fail"))}}}},{key:"getCssFullscreen",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.config.fullscreenTarget;this.isRotateFullscreen?this.exitRotateFullscreen():this.fullscreen&&this.exitFullscreen();var t=e?"".concat(f.default.INNER_FULLSCREEN," ").concat(f.default.CSS_FULLSCREEN):f.default.CSS_FULLSCREEN;this.changeFullStyle(this.root,e,t);var i=this.config.fullscreen,s=void 0===i?{}:i;(!0===s.useCssFullscreen||"function"==typeof s.useCssFullscreen&&s.useCssFullscreen())&&(this.fullscreen=!0,this.emit(r.FULLSCREEN_CHANGE,!0)),this._cssfullscreenEl=e,this.cssfullscreen=!0,this.emit(r.CSS_FULLSCREEN_CHANGE,!0)}},{key:"exitCssFullscreen",value:function(){var e=this._cssfullscreenEl?"".concat(f.default.INNER_FULLSCREEN," ").concat(f.default.CSS_FULLSCREEN):f.default.CSS_FULLSCREEN;if(this.fullscreen){var t=this.config.fullscreen,i=void 0===t?{}:t;!0===i.useCssFullscreen||"function"==typeof i.useCssFullscreen&&i.useCssFullscreen()?(this.recoverFullStyle(this.root,this._cssfullscreenEl,e),this.fullscreen=!1,this.emit(r.FULLSCREEN_CHANGE,!1)):this.removeClass(e)}else this.recoverFullStyle(this.root,this._cssfullscreenEl,e);this._cssfullscreenEl=null,this.cssfullscreen=!1,this.emit(r.CSS_FULLSCREEN_CHANGE,!1)}},{key:"getRotateFullscreen",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.config.fullscreenTarget;this.cssfullscreen&&this.exitCssFullscreen(e);var t=e?"".concat(f.default.INNER_FULLSCREEN," ").concat(f.default.ROTATE_FULLSCREEN):f.default.ROTATE_FULLSCREEN;this._fullscreenEl=e||this.root,this.changeFullStyle(this.root,e,t,f.default.PARENT_ROTATE_FULLSCREEN),this.isRotateFullscreen=!0,this.fullscreen=!0,this.setRotateDeg(90),this._rootStyle=this.root.getAttribute("style");var i=90===Math.abs(window.orientation)||90===Math.abs(screen.orientation.angle);this.root.style.width="".concat(i?window.innerWidth:window.innerHeight,"px"),this.emit(r.FULLSCREEN_CHANGE,!0)}},{key:"exitRotateFullscreen",value:function(e){var t=this._fullscreenEl!==this.root?"".concat(f.default.INNER_FULLSCREEN," ").concat(f.default.ROTATE_FULLSCREEN):f.default.ROTATE_FULLSCREEN;this.recoverFullStyle(this.root,this._fullscreenEl,t,f.default.PARENT_ROTATE_FULLSCREEN),this.isRotateFullscreen=!1,this.fullscreen=!1,this.setRotateDeg(0),this.emit(r.FULLSCREEN_CHANGE,!1),this._rootStyle&&(this.root.style.style=this._rootStyle,this._rootStyle=!1)}},{key:"setRotateDeg",value:function(e){90===window.orientation||-90===window.orientation?this.rotateDeg=0:this.rotateDeg=e}},{key:"focus",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{autoHide:!this.config.closeDelayBlur,delay:this.config.inactive};this.isActive?this.onFocus(t):this.emit(r.PLAYER_FOCUS,e.objectSpread2({paused:this.paused,ended:this.ended},t))}},{key:"blur",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{ignorePaused:!1};this.isActive?(this._clearUserTimer(),this.emit(r.PLAYER_BLUR,e.objectSpread2({paused:this.paused,ended:this.ended},t))):this.onBlur(t)}},{key:"onFocus",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{autoHide:!0,delay:3e3},s=this.innerStates;if(this.isActive=!0,this.removeClass(f.default.INACTIVE),this._clearUserTimer(),void 0!==t.isLock&&(s.isActiveLocked=t.isLock),!1===t.autoHide||!0===t.isLock||s.isActiveLocked)this._clearUserTimer();else{var n=t&&t.delay?t.delay:this.config.inactive;this.userTimer=i.default.setTimeout(this,function(){e.userTimer=null,e.blur()},n)}}},{key:"onBlur",value:function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).ignorePaused,t=void 0!==e&&e;if(!this.innerStates.isActiveLocked){var i=this.config.closePauseVideoFocus;this.isActive=!1,(t||i||!this.paused&&!this.ended)&&this.addClass(f.default.INACTIVE)}}},{key:"onEmptied",value:function(){this.updateAcc("emptied")}},{key:"onCanplay",value:function(){this.removeClass(f.default.ENTER),this.removeClass(f.default.ERROR),this.removeClass(f.default.LOADING),this.isCanplay=!0,this.waitTimer&&i.default.clearTimeout(this,this.waitTimer)}},{key:"onLoadeddata",value:function(){var e=this;this.isError=!1,this.isSeeking=!1,this.__startTime>0&&(this.duration>0?this._seekToStartTime():this.once(r.DURATION_CHANGE,function(){e._seekToStartTime()}))}},{key:"onLoadstart",value:function(){this.removeClass(f.default.ERROR),this.isCanplay=!1}},{key:"onPlay",value:function(){this.state===E.STATES.ENDED&&this.setState(E.STATES.RUNNING),this.removeClass(f.default.PAUSED),this.ended&&this.removeClass(f.default.ENDED),!this.config.closePlayVideoFocus&&this.focus()}},{key:"onPause",value:function(){this.addClass(f.default.PAUSED),this.updateAcc("pause"),this.config.closePauseVideoFocus||(this._clearUserTimer(),this.focus())}},{key:"onEnded",value:function(){this.updateAcc("ended"),this.addClass(f.default.ENDED),this.setState(E.STATES.ENDED)}},{key:"onError",value:function(){this.isError=!0,this.updateAcc("error"),this.removeClass(f.default.NOT_ALLOW_AUTOPLAY),this.removeClass(f.default.NO_START),this.removeClass(f.default.ENTER),this.removeClass(f.default.LOADING),this.addClass(f.default.ERROR)}},{key:"onSeeking",value:function(){this.isSeeking||this.updateAcc("seeking"),this.isSeeking=!0,this.addClass(f.default.SEEKING)}},{key:"onSeeked",value:function(){this.isSeeking=!1,this.waitTimer&&i.default.clearTimeout(this,this.waitTimer),this.removeClass(f.default.LOADING),this.removeClass(f.default.SEEKING)}},{key:"onWaiting",value:function(){var e=this;this.waitTimer&&i.default.clearTimeout(this,this.waitTimer),this.updateAcc("waiting"),this.waitTimer=i.default.setTimeout(this,function(){e.addClass(f.default.LOADING),e.emit(r.LOADING),i.default.clearTimeout(e,e.waitTimer),e.waitTimer=null},this.config.minWaitDelay)}},{key:"onPlaying",value:function(){var e=this;this.isError=!1,[f.default.NO_START,f.default.PAUSED,f.default.ENDED,f.default.ERROR,f.default.REPLAY,f.default.LOADING].forEach(function(t){e.removeClass(t)}),this._accPlayed.t||this.paused||this.ended||(this._accPlayed.t=(new Date).getTime())}},{key:"onTimeupdate",value:function(){!this._videoHeight&&this.media.videoHeight&&this.resize(),(this.waitTimer||this.hasClass(f.default.LOADING))&&this.media.readyState>2&&(this.removeClass(f.default.LOADING),i.default.clearTimeout(this,this.waitTimer),this.waitTimer=null),!this.paused&&this.state===E.STATES.NOTALLOW&&this.duration&&(this.setState(E.STATES.RUNNING),this.emit(r.AUTOPLAY_STARTED)),this._accPlayed.t||this.paused||this.ended||(this._accPlayed.t=(new Date).getTime())}},{key:"onVolumechange",value:function(){"Number"===i.default.typeOf(this.config.volume)&&(this.config.volume=this.volume)}},{key:"onRatechange",value:function(){this.config.defaultPlaybackRate=this.playbackRate}},{key:"emitUserAction",value:function(t,s,n){if(this.media&&s&&t){var o="String"===i.default.typeOf(t)?t:t.type||"";n.props&&"Array"!==i.default.typeOf(n.props)&&(n.props=[n.props]),this.emit(r.USER_ACTION,e.objectSpread2({eventType:o,action:s,currentTime:this.currentTime,duration:this.duration,ended:this.ended,event:t},n))}}},{key:"updateAcc",value:function(e){if(this._accPlayed.t){var t=(new Date).getTime()-this._accPlayed.t;this._accPlayed.acc+=t,this._accPlayed.t=0,("ended"===e||this.ended)&&(this._accPlayed.loopAcc=this._accPlayed.acc)}}},{key:"checkBuffer",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{startDiff:0,endDiff:0})||{},i=t.startDiff,s=void 0===i?0:i,n=t.endDiff,o=void 0===n?0:n,r=this.media.buffered;if(!r||0===r.length||!this.duration)return!0;for(var a=e||this.media.currentTime||.2,l=r.length,u=0;u<l;u++)if(r.start(u)+s<=a&&r.end(u)-o>a)return!0;return!1}},{key:"resizePosition",value:function(){var e=this,t=this.videoPos,s=t.vy,n=t.vx,o=t.h,r=t.w,a=this.videoPos.rotate;if(!(a<0&&o<0&&r<0)){var l=this.videoPos._pi;if(!l&&this.media.videoHeight&&(l=this.media.videoWidth/this.media.videoHeight*100),l){this.videoPos.pi=l;var u={rotate:a=a<0?0:a},c=0,f=0,h=1,d=Math.abs(a/90),g=this.root,v=this.innerContainer,p=g.offsetWidth,y=v?v.offsetHeight:g.offsetHeight,m={},E=y,T=p;if(d%2==0)h=o>0?100/o:r>0?100/r:1,u.scale=h,c=s>0?(100-o)/2-s:0,u.y=2===d?0-c:c,f=n>0?(100-r)/2-n:0,u.x=2===d?0-f:f,m.width="".concat(T,"px"),m.height="".concat(E,"px"),m.maxWidth="",m.maxHeight="";else if(d%2==1){E=p;var _=y-p;f=-_/2/(T=y)*100,u.x=3===d?f+s/2:f-s/2,c=_/2/E*100,u.y=3===d?c+n/2:c-n/2,u.scale=h,m.width="".concat(T,"px"),m.maxWidth="".concat(T,"px"),m.height="".concat(E,"px"),m.maxHeight="".concat(E,"px")}var S=i.default.getTransformStyle(u,this.media.style.transform||this.media.style.webkitTransform);m.transform=S,m.webkitTransform=S,Object.keys(m).map(function(t){e.media.style[t]=m[t]})}}}},{key:"position",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{h:0,y:0,x:0,w:0};if(this.media&&e&&e.h){var t=this.videoPos;t.h=100*e.h||0,t.w=100*e.w||0,t.vx=100*e.x||0,t.vy=100*e.y||0,this.resizePosition()}}},{key:"setConfig",value:function(e){var t=this;e&&Object.keys(e).map(function(s){if("plugins"!==s){t.config[s]=e[s];var n=t.plugins[s.toLowerCase()];n&&"Function"===i.default.typeOf(n.setConfig)&&n.setConfig(e[s])}})}},{key:"playNext",value:function(e){var t=this;this.resetState(),this.setConfig(e),this._currentTime=0,this._duration=0,g.runHooks(this,"playnext",function(){t.start(),t.emit(r.PLAYNEXT,e)})}},{key:"resize",value:function(){var e=this;if(this.media&&this.root){var t=this.root.getBoundingClientRect();this.sizeInfo.width=t.width,this.sizeInfo.height=t.height,this.sizeInfo.left=t.left,this.sizeInfo.top=t.top;var i=this.media,s=i.videoWidth,n=i.videoHeight,o=this.config,a=o.fitVideoSize,l=o.videoFillMode;if("fill"!==l&&"cover"!==l&&"contain"!==l||this.setAttribute("data-xgfill",l),n&&s){this._videoHeight=n,this._videoWidth=s;var u=this.controls&&this.innerContainer?this.controls.root.getBoundingClientRect().height:0,c=t.width,f=t.height-u,h=parseInt(s/n*1e3,10),d=parseInt(c/f*1e3,10),g=c,v=f,p={};"auto"===a&&d>h||"fixWidth"===a?(v=c/h*1e3,this.config.fluid?p.paddingTop="".concat(100*v/g,"%"):p.height="".concat(v+u,"px")):("auto"===a&&d<h||"fixHeight"===a)&&(g=h*f/1e3,p.width="".concat(g,"px")),this.fullscreen||this.cssfullscreen||Object.keys(p).forEach(function(t){e.root.style[t]=p[t]}),("fillHeight"===l&&d<h||"fillWidth"===l&&d>h)&&this.setAttribute("data-xgfill","cover");var y={videoScale:h,vWidth:g,vHeight:v,cWidth:g,cHeight:v+u};this.resizePosition(),this.emit(r.VIDEO_RESIZE,y)}}}},{key:"updateObjectPosition",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.media.updateObjectPosition?this.media.updateObjectPosition(e,t):this.media.style.objectPosition="".concat(100*e,"% ").concat(100*t,"%")}},{key:"setState",value:function(e){p.default.logInfo("setState","state from:".concat(E.STATE_ARRAY[this.state]," to:").concat(E.STATE_ARRAY[e])),this._state=e}},{key:"preProcessUrl",value:function(e,t){var s=this.config,n=s.preProcessUrl,o=s.preProcessUrlOptions,r=Object.assign({},o,t);return i.default.isBlob(e)||"function"!=typeof n?{url:e}:n(e,r)}},{key:"_seekToStartTime",value:function(){this.__startTime>0&&this.duration>0&&(this.currentTime=this.__startTime>this.duration?this.duration:this.__startTime,this.__startTime=-1)}},{key:"state",get:function(){return this._state}},{key:"isFullscreen",get:function(){return this.fullscreen}},{key:"isCssfullScreen",get:function(){return this.cssfullscreen}},{key:"hasStart",get:function(){return this._hasStart},set:function(e){"boolean"==typeof e&&(this._hasStart=e,!1===e&&this.setState(E.STATES.READY),this.emit("hasstart"))}},{key:"isPlaying",get:function(){return this._state===E.STATES.RUNNING||this._state===E.STATES.ENDED},set:function(e){e?this.setState(E.STATES.RUNNING):this._state>=E.STATES.RUNNING&&this.setState(E.STATES.ATTACHED)}},{key:"definitionList",get:function(){return this.config&&this.config.definition&&this.config.definition.list||[]},set:function(e){var t=this,i=this.config.definition,s=null,n=null;i.list=e,this.emit("resourceReady",e),e.forEach(function(e){var o;(null===(o=t.curDefinition)||void 0===o?void 0:o.definition)===e.definition&&(s=e),i.defaultDefinition===e.definition&&(n=e)}),!n&&e.length>0&&(n=e[0]),s?this.changeDefinition(s):n&&this.changeDefinition(n)}},{key:"videoFrameInfo",get:function(){var e={total:0,dropped:0,corrupted:0,droppedRate:0,droppedDuration:0};if(!this.media||!this.media.getVideoPlaybackQuality)return e;var t=this.media.getVideoPlaybackQuality();return e.dropped=t.droppedVideoFrames||0,e.total=t.totalVideoFrames||0,e.corrupted=t.corruptedVideoFrames||0,e.total>0&&(e.droppedRate=e.dropped/e.total*100,e.droppedDuration=parseInt(this.cumulateTime/e.total*e.dropped,0)),e}},{key:"lang",get:function(){return this.config.lang},set:function(e){0!==y.default.langKeys.filter(function(t){return t===e}).length||"zh"===e?(this.config.lang=e,c.default.setLang(e,this)):console.error("Sorry, set lang fail, because the language [".concat(e,"] is not supported now, list of all supported languages is [").concat(y.default.langKeys.join(),"] "))}},{key:"i18n",get:function(){var e=this.config.lang;return"zh"===e&&(e="zh-cn"),this.__i18n.lang[e]||this.__i18n.lang.en}},{key:"i18nKeys",get:function(){return this.__i18n.textKeys||{}}},{key:"version",get:function(){return m.default}},{key:"playerId",get:function(){return this._pluginInfoId}},{key:"url",get:function(){return this.__url||this.config.url},set:function(e){this.__url=e}},{key:"poster",get:function(){return this.plugins.poster?this.plugins.poster.config.poster:this.config.poster},set:function(e){this.plugins.poster&&this.plugins.poster.update(e)}},{key:"readyState",get:function(){return e.get(e.getPrototypeOf(P.prototype),"readyState",this)}},{key:"error",get:function(){var t=e.get(e.getPrototypeOf(P.prototype),"error",this);return this.i18n[t]||t}},{key:"networkState",get:function(){return e.get(e.getPrototypeOf(P.prototype),"networkState",this)}},{key:"fullscreenChanging",get:function(){return!(null===this._fullScreenOffset)}},{key:"cumulateTime",get:function(){var e=this._accPlayed,t=e.acc,i=e.t;return i?(new Date).getTime()-i+t:t}},{key:"zoom",get:function(){return this.config.zoom},set:function(e){this.config.zoom=e}},{key:"videoRotateDeg",get:function(){return this.videoPos.rotate},set:function(e){(e=i.default.convertDeg(e))%90==0&&e!==this.videoPos.rotate&&(this.videoPos.rotate=e,this.resizePosition())}},{key:"avgSpeed",get:function(){return A},set:function(e){A=e}},{key:"realTimeSpeed",get:function(){return S},set:function(e){S=e}},{key:"offsetCurrentTime",get:function(){return this._offsetInfo.currentTime||0},set:function(e){this._offsetInfo.currentTime=e}},{key:"offsetDuration",get:function(){return this._offsetInfo.duration||0},set:function(e){this._offsetInfo.duration=e||0}},{key:"hook",value:function(e,t){return g.hook.call.apply(g.hook,[this].concat(Array.prototype.slice.call(arguments)))}},{key:"useHooks",value:function(e,t){return g.useHooks.call.apply(g.useHooks,[this].concat(Array.prototype.slice.call(arguments)))}},{key:"removeHooks",value:function(e,t){return g.removeHooks.call.apply(g.removeHooks,[this].concat(Array.prototype.slice.call(arguments)))}},{key:"usePluginHooks",value:function(e,t,i){for(var s=arguments.length,n=new Array(s>3?s-3:0),o=3;o<s;o++)n[o-3]=arguments[o];return g.usePluginHooks.call.apply(g.usePluginHooks,[this].concat(Array.prototype.slice.call(arguments)))}},{key:"removePluginHooks",value:function(e,t,i){for(var s=arguments.length,n=new Array(s>3?s-3:0),o=3;o<s;o++)n[o-3]=arguments[o];return g.removePluginHooks.call.apply(g.removePluginHooks,[this].concat(Array.prototype.slice.call(arguments)))}},{key:"setUserActive",value:function(e,t){var s;"boolean"==typeof t&&t!==this.muted&&(this.addInnerOP("volumechange"),i.default.typeOf(t)===Boolean&&(this.muted=t)),null===(s=C)||void 0===s||s.setActive(this.playerId,e)}}],[{key:"debugger",get:function(){return p.default.config.debug},set:function(e){p.default.config.debug=e}},{key:"instManager",get:function(){return C},set:function(e){C=e}},{key:"getCurrentUserActivePlayerId",value:function(){var e;return null===(e=C)||void 0===e?void 0:e.getActiveId()}},{key:"setCurrentUserActive",value:function(e,t){var i;null===(i=C)||void 0===i||i.setActive(e,t)}},{key:"isHevcSupported",value:function(){return s.default.isHevcSupported()}},{key:"probeConfigSupported",value:function(e){return s.default.probeConfigSupported(e)}},{key:"install",value:function(e,t){P.plugins||(P.plugins={}),P.plugins[e]||(P.plugins[e]=t)}},{key:"use",value:function(e,t){P.plugins||(P.plugins={}),P.plugins[e]=t}}]),P}(t.default);e.defineProperty(k,"defaultPreset",null),e.defineProperty(k,"XgVideoProxy",null),k.instManager=T.InstManager.getInstance(),exports.Util=i.default,exports.Sniffer=s.default,exports.Errors=o.default,exports.Events=r,exports.Plugin=l.default,exports.BasePlugin=u.default,exports.STATE_CLASS=f.default,exports.I18N=y.default,exports.default=k;