import{aq as e,ap as t,d as i,r as n,K as o,R as r,ay as s,a,x as l,o as c,c as u,G as h,ad as d,i as f,w as p,f as g,e as v,I as y,dq as m,dr as k,ds as C,dh as _}from"./index-vMt5tOuI.js";function b(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function w(e){for(var t=1;te.length)&&(t=e.length);for(var i=0,n=new Array(t);i-1,W={info:"color: #525252; background-color: #90ee90;",error:"color: #525252; background-color: red;",warn:"color: #525252; background-color: yellow; "},G="%c[xgplayer]",z={config:{debug:V?3:0},logInfo:function(e){for(var t,i=arguments.length,n=new Array(i>1?i-1:0),o=1;o=3&&(t=console).log.apply(t,[G,W.info,e].concat(n))},logWarn:function(e){for(var t,i=arguments.length,n=new Array(i>1?i-1:0),o=1;o=1&&(t=console).warn.apply(t,[G,W.warn,e].concat(n))},logError:function(e){var t;if(!(this.config.debug<1)){for(var i=this.config.debug>=2?"trace":"error",n=arguments.length,o=new Array(n>1?n-1:0),r=1;r=t||i<0||h&&e-c>=r}function y(){var e=Date.now();if(v(e))return m(e);a=g(y,function(e){var i=e-c,n=t-(e-l);return h?Math.min(n,r-i):n}(e))}function m(e){return a=void 0,d&&n?p(e):(n=o=void 0,s)}function k(){for(var e=Date.now(),i=v(e),r=arguments.length,d=new Array(r),f=0;f0&&void 0!==arguments[0]?arguments[0]:"div",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",o=document.createElement(e);return o.className=n,o.innerHTML=t,Object.keys(i).forEach((function(t){var n=t,r=i[t];"video"===e||"audio"===e||"live-video"===e?r&&o.setAttribute(n,r):o.setAttribute(n,r)})),o},Y.createDomFromHtml=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";try{var n=document.createElement("div");n.innerHTML=e;var o=n.children;return n=null,o.length>0?(o=o[0],i&&Y.addClass(o,i),t&&Object.keys(t).forEach((function(e){o.setAttribute(e,t[e])})),o):null}catch(r){return z.logError("util.createDomFromHtml",r),null}},Y.hasClass=function(e,t){if(!e||!t)return!1;try{return Array.prototype.some.call(e.classList,(function(e){return e===t}))}catch(n){var i=e.className&&"object"===T(e.className)?e.getAttribute("class"):e.className;return i&&!!i.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))}},Y.addClass=function(e,t){if(e&&t)try{t.replace(/(^\s+|\s+$)/g,"").split(/\s+/g).forEach((function(t){t&&e.classList.add(t)}))}catch(i){Y.hasClass(e,t)||(e.className&&"object"===T(e.className)?e.setAttribute("class",e.getAttribute("class")+" "+t):e.className+=" "+t)}},Y.removeClass=function(e,t){if(e&&t)try{t.replace(/(^\s+|\s+$)/g,"").split(/\s+/g).forEach((function(t){t&&e.classList.remove(t)}))}catch(i){Y.hasClass(e,t)&&t.split(/\s+/g).forEach((function(t){var i=new RegExp("(\\s|^)"+t+"(\\s|$)");e.className&&"object"===T(e.className)?e.setAttribute("class",e.getAttribute("class").replace(i," ")):e.className=e.className.replace(i," ")}))}},Y.toggleClass=function(e,t){e&&t.split(/\s+/g).forEach((function(t){Y.hasClass(e,t)?Y.removeClass(e,t):Y.addClass(e,t)}))},Y.classNames=function(){for(var e=arguments,t=[],i=function(i){"String"===Y.typeOf(e[i])?t.push(e[i]):"Object"===Y.typeOf(e[i])&&Object.keys(e[i]).map((function(n){e[i][n]&&t.push(n)}))},n=0;n0&&void 0!==arguments[0]?arguments[0]:document,i=arguments.length>1?arguments[1]:void 0;try{e=t.querySelector(i)}catch(n){z.logError("util.findDom",n),0===i.indexOf("#")&&(e=t.getElementById(i.slice(1)))}return e},Y.getCss=function(e,t){return e.currentStyle?e.currentStyle[t]:document.defaultView.getComputedStyle(e,!1)[t]},Y.padStart=function(e,t,i){for(var n=String(i),o=t|0,r=Math.ceil(o/n.length),s=[],a=String(e);r--;)s.push(n);return s.join("").substring(0,o-a.length)+a},Y.format=function(e){if(window.isNaN(e))return"";e=Math.round(e);var t=Y.padStart(Math.floor(e/3600),2,0),i=Y.padStart(Math.floor((e-3600*t)/60),2,0),n=Y.padStart(Math.floor(e-3600*t-60*i),2,0);return("00"===t?[i,n]:[t,i,n]).join(":")},Y.event=function(e){if(e.touches){var t=e.touches[0]||e.changedTouches[0];e.clientX=t.clientX||0,e.clientY=t.clientY||0,e.offsetX=t.pageX-t.target.offsetLeft,e.offsetY=t.pageY-t.target.offsetTop}e._target=e.target||e.srcElement},Y.typeOf=function(e){return Object.prototype.toString.call(e).match(/([^\s.*]+)(?=]$)/g)[0]},Y.deepCopy=function(e,t){if("Object"===Y.typeOf(t)&&"Object"===Y.typeOf(e))return Object.keys(t).forEach((function(i){"Object"!==Y.typeOf(t[i])||t[i]instanceof Node?"Array"===Y.typeOf(t[i])?e[i]="Array"===Y.typeOf(e[i])?e[i].concat(t[i]):t[i]:e[i]=t[i]:void 0===e[i]||void 0===e[i]?e[i]=t[i]:Y.deepCopy(e[i],t[i])})),e},Y.deepMerge=function(e,t){return Object.keys(t).map((function(i){var n;"Array"===Y.typeOf(t[i])&&"Array"===Y.typeOf(e[i])?"Array"===Y.typeOf(e[i])&&(n=e[i]).push.apply(n,N(t[i])):Y.typeOf(e[i])!==Y.typeOf(t[i])||null===e[i]||"Object"!==Y.typeOf(e[i])||t[i]instanceof window.Node?null!==t[i]&&(e[i]=t[i]):Y.deepMerge(e[i],t[i])})),e},Y.getBgImage=function(e){var t=(e.currentStyle||window.getComputedStyle(e,null)).backgroundImage;if(!t||"none"===t)return"";var i=document.createElement("a");return i.href=t.replace(/url\("|"\)/g,""),i.href},Y.copyDom=function(e){if(e&&1===e.nodeType){var t=document.createElement(e.tagName);return Array.prototype.forEach.call(e.attributes,(function(e){t.setAttribute(e.name,e.value)})),e.innerHTML&&(t.innerHTML=e.innerHTML),t}return""},Y.setInterval=function(e,t,i,n){e._interval[t]||(e._interval[t]=window.setInterval(i.bind(e),n))},Y.clearInterval=function(e,t){clearInterval(e._interval[t]),e._interval[t]=null},Y.setTimeout=function(e,t,i){e._timers||(e._timers=[]);var n=setTimeout((function(){t(),Y.clearTimeout(e,n)}),i);return e._timers.push(n),n},Y.clearTimeout=function(e,t){var i=e._timers;if("Array"===Y.typeOf(i)){for(var n=0;n-1&&n.indexOf(e)>-1)||(o=parseFloat(i.slice(0,i.indexOf(e)).trim()),r=parseFloat(n.slice(0,n.indexOf(e)).trim()),s=e,!1)})),a.style.width="".concat(o).concat(s),a.style.height="".concat(r).concat(s),a.style.backgroundSize="".concat(o).concat(s," ").concat(r).concat(s),a.style.margin="start"===e?"-".concat(r/2).concat(s," auto auto -").concat(o/2).concat(s):"auto 5px auto 5px");return a},Y.Hex2RGBA=function(e,t){var i=[];if(/^\#[0-9A-F]{3}$/i.test(e)){var n="#";e.replace(/[0-9A-F]/gi,(function(e){n+=e+e})),e=n}return/^#[0-9A-F]{6}$/i.test(e)?(e.replace(/[0-9A-F]{2}/gi,(function(e){i.push(parseInt(e,16))})),"rgba(".concat(i.join(","),", ").concat(t,")")):"rgba(255, 255, 255, 0.1)"},Y.getFullScreenEl=function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement},Y.checkIsFunction=function(e){return e&&"function"==typeof e},Y.checkIsObject=function(e){return null!==e&&"object"===T(e)},Y.hide=function(e){e.style.display="none"},Y.show=function(e,t){e.style.display=t||"block"},Y.isUndefined=function(e){if(null==e)return!0},Y.isNotNull=function(e){return!(null==e)},Y.setStyleFromCsstext=function(e,t){t&&("String"===Y.typeOf(t)?t.replace(/\s+/g,"").split(";").map((function(t){if(t){var i=t.split(":");i.length>1&&(e.style[i[0]]=i[1])}})):Object.keys(t).map((function(i){e.style[i]=t[i]})))},Y.filterStyleFromText=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["width","height","top","left","bottom","right","position","z-index","padding","margin","transform"],i=e.style.cssText;if(!i)return{};var n=i.replace(/\s+/g,"").split(";"),o={},r={};return n.map((function(e){if(e){var i=e.split(":");i.length>1&&(!function(e,t){for(var i=0,n=t.length;i-1)return!0;return!1}(i[0],t)?r[i[0]]=i[1]:o[i[0]]=i[1])}})),e.setAttribute("style",""),Object.keys(r).map((function(t){e.style[t]=r[t]})),o},Y.getStyleFromCsstext=function(e){var t=e.style.cssText;if(!t)return{};var i=t.replace(/\s+/g,"").split(";"),n={};return i.map((function(e){if(e){var t=e.split(":");t.length>1&&(n[t[0]]=t[1])}})),n},Y.preloadImg=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){};if(e){var n=new window.Image;n.onload=function(e){n=null,t&&t(e)},n.onerror=function(e){n=null,i&&i(e)},n.src=e}},Y.stopPropagation=function(e){e&&e.stopPropagation()},Y.scrollTop=function(){return window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0},Y.scrollLeft=function(){return window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0},Y.checkTouchSupport=function(){return"ontouchstart"in window},Y.getBuffered2=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.5,i=[],n=0;na&&(o[s-1].end=i[r].end):o.push(i[r])}else o.push(i[r])}else o=i;return new K(o)},Y.getEventPos=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return e.touches&&e.touches.length>0&&(e=e.touches[0]),{x:e.x/t,y:e.y/t,clientX:e.clientX/t,clientY:e.clientY/t,offsetX:e.offsetX/t,offsetY:e.offsetY/t,pageX:e.pageX/t,pageY:e.pageY/t}},Y.requestAnimationFrame=function(e){var t=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame;if(t)return t(e)},Y.getHostFromUrl=function(e){if("String"!==Y.typeOf(e))return"";var t=e.split("/"),i="";return t.length>3&&t[2]&&(i=t[2]),i},Y.cancelAnimationFrame=function(e){var t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.cancelRequestAnimationFrame;t&&t(e)},Y.isMSE=function(e){return!!(e&&e instanceof HTMLMediaElement)&&(/^blob/.test(e.currentSrc)||/^blob/.test(e.src))},Y.isBlob=function(e){return"string"==typeof e&&/^blob/.test(e)},Y.generateSessionId=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=(new Date).getTime();try{e=parseInt(e)}catch(i){e=0}return t+=e,window.performance&&"function"==typeof window.performance.now&&(t+=parseInt(window.performance.now())),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var i=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"===e?i:3&i|8).toString(16)}))},Y.createEvent=function(e){var t;return"function"==typeof window.Event?t=new Event(e):(t=document.createEvent("Event")).initEvent(e,!0,!0),t},Y.adjustTimeByDuration=function(e,t,i){return t&&e&&(e>t||i&&e0&&void 0!==arguments[0]?arguments[0]:{x:0,y:0,scale:1,rotate:0},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i={scale:"".concat(e.scale||1),translate:"".concat(e.x||0,"%, ").concat(e.y||0,"%"),rotate:"".concat(e.rotate||0,"deg")};return Object.keys(i).forEach((function(e){var n=new RegExp("".concat(e,"\\([^\\(]+\\)"),"g"),o="".concat(e,"(").concat(i[e],")");n.test(t)?(n.lastIndex=-1,t=t.replace(n,o)):t+="".concat(o," ")})),t},Y.convertDeg=function(e){return Math.abs(e)<=1?360*e:e%360},Y.getIndexByTime=function(e,t){var i=t.length,n=-1;if(i<1)return n;if(e<=t[0].end||i<2)n=0;else if(e>t[i-1].end)n=i-1;else for(var o=1;ot[o-1].end&&e<=t[o].end){n=o;break}return n},Y.getOffsetCurrentTime=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,n=-1;if((n=i>=0&&i=s&&e<=a?e-c:e>a&&n>=o-1?a:-1},Y.getCurrentTimeByOffset=function(e,t){var i=-1;if(!t||t.length<0)return e;for(var n=0;n1,s=r||n&&!/(?:Mobile)/.test(e)||o&&/(?:Tablet)/.test(e),a=/(?:iPhone)/.test(e)&&!s;return{isTablet:s,isPhone:a,isIpad:r,isIos:a||r,isAndroid:n,isPc:!(a||n||i||s),isSymbian:i,isWindowsPhone:t,isFireFox:o}},get osVersion(){if("undefined"==typeof navigator)return 0;var e=navigator.userAgent,t="",i=(t=/(?:iPhone)|(?:iPad|PlayBook)/.test(e)?J:Z)?t.exec(e):[];if(i&&i.length>=3){var n=i[2].split(".");return n.length>0?parseInt(n[0]):0}return 0},get isWeixin(){if("undefined"==typeof navigator)return!1;return!!/(micromessenger)\/([\d.]+)/.exec(navigator.userAgent.toLocaleLowerCase())},isSupportMP4:function(){var e={isSupport:!1,mime:""};if("undefined"==typeof document)return e;if(this.supportResult)return this.supportResult;var t=document.createElement("video");return"function"==typeof t.canPlayType&&$.map((function(i){"probably"===t.canPlayType('video/mp4; codecs="'.concat(i,'"'))&&(e.isSupport=!0,e.mime+="||".concat(i))})),this.supportResult=e,t=null,e},isMSESupport:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"';if("undefined"==typeof MediaSource||!MediaSource)return!1;try{return MediaSource.isTypeSupported(e)}catch(t){return this._logger.error(e,t),!1}},isHevcSupported:function(){return!("undefined"==typeof MediaSource||!MediaSource.isTypeSupported)&&(MediaSource.isTypeSupported('video/mp4;codecs="hev1.1.6.L120.90"')||MediaSource.isTypeSupported('video/mp4;codecs="hev1.2.4.L120.90"')||MediaSource.isTypeSupported('video/mp4;codecs="hev1.3.E.L120.90"')||MediaSource.isTypeSupported('video/mp4;codecs="hev1.4.10.L120.90"'))},probeConfigSupported:function(e){var t={supported:!1,smooth:!1,powerEfficient:!1};if(!e||"undefined"==typeof navigator)return Promise.resolve(t);if(navigator.mediaCapabilities&&navigator.mediaCapabilities.decodingInfo)return navigator.mediaCapabilities.decodingInfo(e);var i=e.video||{},n=e.audio||{};try{var o=MediaSource.isTypeSupported(i.contentType),r=MediaSource.isTypeSupported(n.contentType);return Promise.resolve({supported:o&&r,smooth:!1,powerEfficient:!1})}catch(s){return Promise.resolve(t)}}},ee="3.0.16",te={1:"media",2:"media",3:"media",4:"media",5:"media",6:"media"},ie={1:5101,2:5102,3:5103,4:5104,5:5105,6:5106},ne=E((function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{errorType:"",errorCode:0,errorMessage:"",originError:"",ext:{},mediaError:null};x(this,e);var n=t&&t.i18n?t.i18n.ERROR_TYPES:null;if(t.media){var o=i.mediaError?i.mediaError:t.media.error||{},r=t.duration,s=t.currentTime,a=t.ended,l=t.src,c=t.currentSrc,u=t.media,h=u.readyState,d=u.networkState,f=i.errorCode||o.code;ie[f]&&(f=ie[f]);var p={playerVersion:ee,currentTime:s,duration:r,ended:a,readyState:h,networkState:d,src:l||c,errorType:i.errorType,errorCode:f,message:i.errorMessage||o.message,mediaError:o,originError:i.originError?i.originError.stack:"",host:Y.getHostFromUrl(l||c)};return i.ext&&Object.keys(i.ext).map((function(e){p[e]=i.ext[e]})),p}if(arguments.length>1){for(var g={playerVersion:ee,domain:document.domain},v=["errorType","currentTime","duration","networkState","readyState","src","currentSrc","ended","errd","errorCode","mediaError"],y=0;y0&&void 0!==arguments[0]?arguments[0]:this.media;this._evHandlers||(this._evHandlers=Je.map((function(t){var i="on".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));return"function"==typeof e[i]&&e.on(t,e[i]),P({},t,function(e,t){return function(i,n){var o={player:t,eventName:e,originalEvent:i,detail:i.detail||{},timeStamp:i.timeStamp,currentTime:t.currentTime,duration:t.duration,paused:t.paused,ended:t.ended,isInternalOp:!!t._internalOp[i.type],muted:t.muted,volume:t.volume,host:Y.getHostFromUrl(t.currentSrc),vtype:t.vtype};if(t.removeInnerOP(i.type),"timeupdate"===e&&(t._currentTime=t.media&&t.media.currentTime),"ratechange"===e){var r=t.media?t.media.playbackRate:0;if(r&&t._rate===r)return;t._rate=t.media&&t.media.playbackRate}if("durationchange"===e&&(t._duration=t.media.duration),"volumechange"===e&&(o.isMutedChange=t._lastMuted!==t.muted,t._lastMuted=t.muted),"error"===e&&(o.error=n||t.video.error),t.mediaEventMiddleware[e]){var s=tt.bind(t,e,o);try{t.mediaEventMiddleware[e].call(t,o,s)}catch(a){throw tt.call(t,e,o),a}}else tt.call(t,e,o)}}(t,e))}))),this._evHandlers.forEach((function(e){var i=Object.keys(e)[0];t.addEventListener(i,e[i],!1)}))}},{key:"detachVideoEvents",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.media;this._evHandlers.forEach((function(e){var i=Object.keys(e)[0];t.removeEventListener(i,e[i],!1)})),this._evHandlers.forEach((function(t){var i=Object.keys(t)[0],n="on".concat(i.charAt(0).toUpperCase()).concat(i.slice(1));"function"==typeof e[n]&&e.off(i,e[n])})),this._evHandlers=null}},{key:"_attachSourceEvents",value:function(e,t){var i=this;e.removeAttribute("src"),e.load(),t.forEach((function(e,t){i.media.appendChild(Y.createDom("source","",{src:"".concat(e.src),type:"".concat(e.type||""),"data-index":t+1}))}));var n=e.children;if(n){this._videoSourceCount=n.length,this._videoSourceIndex=n.length,this._vLoadeddata=function(e){i.emit(Ze,{src:e.target.currentSrc,host:Y.getHostFromUrl(e.target.currentSrc)})};for(var o=null,r=0;r=i._videoSourceCount){var n={code:4,message:"sources_load_error"};o?o.error(e,n):i.errorHandler("error",n)}var r=te[4];i.emit(qe,new ne(i,{errorType:r,errorCode:4,errorMessage:"sources_load_error",mediaError:{code:4,message:"sources_load_error"},src:e.target.src}))});for(var s=0;s0;)e.removeChild(t[0]);this._vLoadeddata&&e.removeEventListener("loadeddata",this._vLoadeddata)}}},{key:"errorHandler",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(this.media&&(this.media.error||t)){var i=this.media.error||t,n=i.code?te[i.code]:"other";i.message;this.media.currentSrc||(i={code:6,message:"empty_src"}),this.emit(e,new ne(this,{errorType:n,errorCode:i.code,errorMessage:i.message||"",mediaError:i}))}}},{key:"destroy",value:function(){for(var e in this.media&&(this.media.pause&&(this.media.pause(),this.media.muted=!0),this.media.removeAttribute("src"),this.media.load()),this._currentTime=0,this._duration=0,this.mediaConfig=null,this._interval)Object.prototype.hasOwnProperty.call(this._interval,e)&&(clearInterval(this._interval[e]),this._interval[e]=null);this.detachVideoEvents(),this.media=null,this.mediaEventMiddleware={},this.removeAllListeners()}},{key:"video",get:function(){return this.media},set:function(e){this.media=e}},{key:"play",value:function(){return this.media?this.media.play():null}},{key:"pause",value:function(){this.media&&this.media.pause()}},{key:"load",value:function(){this.media&&this.media.load()}},{key:"canPlayType",value:function(e){return!!this.media&&this.media.canPlayType(e)}},{key:"getBufferedRange",value:function(e){var t=[0,0];if(!this.media)return t;e||(e=this.media.buffered);var i=this.media.currentTime;if(e)for(var n=0,o=e.length;n=this.currentTime)return{start:t.start(i),end:t.end(i)};return e}},{key:"crossOrigin",get:function(){return this.media?this.media.crossOrigin:""},set:function(e){this.media&&(this.media.crossOrigin=e)}},{key:"currentSrc",get:function(){return this.media?this.media.currentSrc:""},set:function(e){this.media&&(this.media.currentSrc=e)}},{key:"currentTime",get:function(){return this.media?void 0!==this.media.currentTime?this.media.currentTime:this._currentTime:0},set:function(e){this.media&&(this.media.currentTime=e)}},{key:"defaultMuted",get:function(){return!!this.media&&this.media.defaultMuted},set:function(e){this.media&&(this.media.defaultMuted=e)}},{key:"duration",get:function(){return this._duration}},{key:"ended",get:function(){return!!this.media&&this.media.ended}},{key:"error",get:function(){return this.media.error}},{key:"errorNote",get:function(){if(!this.media.error)return"";return["MEDIA_ERR_ABORTED","MEDIA_ERR_NETWORK","MEDIA_ERR_DECODE","MEDIA_ERR_SRC_NOT_SUPPORTED"][this.media.error.code-1]}},{key:"loop",get:function(){return!!this.media&&this.media.loop},set:function(e){this.media&&(this.media.loop=e)}},{key:"muted",get:function(){return!!this.media&&this.media.muted},set:function(e){this.media&&this.media.muted!==e&&(this._lastMuted=this.media.muted,this.media.muted=e)}},{key:"networkState",get:function(){return this.media.networkState}},{key:"paused",get:function(){return!this.media||this.media.paused}},{key:"playbackRate",get:function(){return this.media?this.media.playbackRate:0},set:function(e){this.media&&e!==1/0&&(this.media.defaultPlaybackRate=e,this.media.playbackRate=e)}},{key:"played",get:function(){return this.media?this.media.played:null}},{key:"preload",get:function(){return!!this.media&&this.media.preload},set:function(e){this.media&&(this.media.preload=e)}},{key:"readyState",get:function(){return this.media.readyState}},{key:"seekable",get:function(){return!!this.media&&this.media.seekable}},{key:"seeking",get:function(){return!!this.media&&this.media.seeking}},{key:"src",get:function(){return this.media?this.media.src:""},set:function(e){this.media&&(this.emit(Le,e),this.emit(de),this._currentTime=0,this._duration=0,Y.isMSE(this.media)?this.onWaiting():(this._detachSourceEvents(this.media),"Array"===Y.typeOf(e)?this._attachSourceEvents(this.media,e):e?this.media.src=e:this.media.removeAttribute("src"),this.load()))}},{key:"volume",get:function(){return this.media?this.media.volume:0},set:function(e){e!==1/0&&this.media&&(this.media.volume=e)}},{key:"aspectRatio",get:function(){return this.media?this.media.videoWidth/this.media.videoHeight:0}},{key:"addInnerOP",value:function(e){this._internalOp[e]=!0}},{key:"removeInnerOP",value:function(e){delete this._internalOp[e]}},{key:"emit",value:function(e,t){for(var n,o=arguments.length,r=new Array(o>2?o-2:0),s=2;s2?o-2:0),s=2;s2?o-2:0),s=2;s2?o-2:0),s=2;s0&&void 0!==arguments[0]?arguments[0]:{name:"xgplayer",version:1,db:null,ojstore:{name:"xg-m4a",keypath:"vid"}};x(this,e),this.indexedDB=window.indexedDB||window.webkitindexedDB,this.IDBKeyRange=window.IDBKeyRange||window.webkitIDBKeyRange,this.myDB=t}return E(e,[{key:"openDB",value:function(e){var t=this,i=this,n=this.myDB.version||1,o=i.indexedDB.open(i.myDB.name,n);o.onerror=function(e){},o.onsuccess=function(n){t.myDB.db=n.target.result,e.call(i)},o.onupgradeneeded=function(e){var t=e.target.result;e.target.transaction,t.objectStoreNames.contains(i.myDB.ojstore.name)||t.createObjectStore(i.myDB.ojstore.name,{keyPath:i.myDB.ojstore.keypath})}}},{key:"deletedb",value:function(){this.indexedDB.deleteDatabase(this.myDB.name)}},{key:"closeDB",value:function(){this.myDB.db.close()}},{key:"addData",value:function(e,t){for(var i,n=this.myDB.db.transaction(e,"readwrite").objectStore(e),o=0;o3?n-3:0),r=3;r2&&void 0!==arguments[2]?arguments[2]:{pre:null,next:null};return this.__hooks||(this.__hooks={}),!this.__hooks[e]&&(this.__hooks[e]=null),function(){var n=arguments,o=this;if(i.pre)try{var r;(r=i.pre).call.apply(r,[this].concat(Array.prototype.slice.call(arguments)))}catch(l){throw l.message="[pluginName: ".concat(this.pluginName,":").concat(e,":pre error] >> ").concat(l.message),l}if(this.__hooks&&this.__hooks[e])try{var s,a=(s=this.__hooks[e]).call.apply(s,[this,this].concat(Array.prototype.slice.call(arguments)));a?a.then?a.then((function(e){!1!==e&<.apply(void 0,[o,t,i.next].concat(N(n)))})).catch((function(e){throw e})):lt.apply(void 0,[this,t,i.next].concat(Array.prototype.slice.call(arguments))):void 0===a&<.apply(void 0,[this,t,i.next].concat(Array.prototype.slice.call(arguments)))}catch(l){throw l.message="[pluginName: ".concat(this.pluginName,":").concat(e,"] >> ").concat(l.message),l}else lt.apply(void 0,[this,t,i.next].concat(Array.prototype.slice.call(arguments)))}.bind(this)}function ut(e,t){var i=this.__hooks;if(i)return!!i.hasOwnProperty(e)&&(i&&(i[e]=t),!0)}function ht(e,t){var i=this.__hooks;i&&delete i[e]}function dt(e){if(this.plugins&&this.plugins[e.toLowerCase()]){for(var t=this.plugins[e.toLowerCase()],i=arguments.length,n=new Array(i>1?i-1:0),o=1;o1?i-1:0),o=1;o1&&void 0!==arguments[1]?arguments[1]:[];e.__hooks={},t&&t.map((function(t){e.__hooks[t]=null})),Object.defineProperty(e,"hooks",{get:function(){return e.__hooks&&Object.keys(e.__hooks).map((function(t){if(e.__hooks[t])return t}))}})}function gt(e){e.__hooks=null}function vt(e,t,i){for(var n=arguments.length,o=new Array(n>3?n-3:0),r=3;r1?i-1:0),o=1;o2&&void 0!==arguments[2]?arguments[2]:{};if(this.player){var n=w(w({},i),{},{pluginName:this.pluginName});this.player.emitUserAction(e,t,n)}}},{key:"hook",value:function(e,t){return ct.call.apply(ct,[this].concat(Array.prototype.slice.call(arguments)))}},{key:"useHooks",value:function(e,t){for(var i=arguments.length,n=new Array(i>2?i-2:0),o=2;o2?i-2:0),o=2;o1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(this.player)return i&&(t.pluginName=i),this.player.registerPlugin({plugin:e,options:t})}},{key:"getPlugin",value:function(e){return this.player?this.player.getPlugin(e):null}},{key:"__destroy",value:function(){var e=this,t=this.player,i=this.pluginName;this.offAll(),Y.clearAllTimers(this),Y.checkIsFunction(this.destroy)&&this.destroy(),["player","playerConfig","pluginName","logger","__args","__hooks"].map((function(t){e[t]=null})),t.unRegisterPlugin(i),gt(this)}}],[{key:"defineGetterOrSetter",value:function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&Object.defineProperty(e,i,t[i])}},{key:"defaultConfig",get:function(){return{}}},{key:"pluginName",get:function(){return"pluginName"}}]),e}();if("undefined"!=typeof Element&&!Element.prototype.matches){var kt=Element.prototype;kt.matches=kt.matchesSelector||kt.mozMatchesSelector||kt.msMatchesSelector||kt.oMatchesSelector||kt.webkitMatchesSelector}var Ct=function(e,t){for(;e&&9!==e.nodeType;){if("function"==typeof e.matches&&e.matches(t))return e;e=e.parentNode}};function _t(e,t,i,n,o){var r=bt.apply(this,arguments);return e.addEventListener(i,r,o),{destroy:function(){e.removeEventListener(i,r,o)}}}function bt(e,t,i,n){return function(i){i.delegateTarget=Ct(i.target,t),i.delegateTarget&&n.call(e,i)}}const wt=e((function(e,t,i,n,o){return"function"==typeof e.addEventListener?_t.apply(null,arguments):"function"==typeof i?_t.bind(null,document).apply(null,arguments):("string"==typeof e&&(e=document.querySelectorAll(e)),Array.prototype.map.call(e,(function(e){return _t(e,t,i,n,o)})))}));var Tt={CONTROLS:"controls",ROOT:"root"},xt={ROOT:"root",ROOT_LEFT:"rootLeft",ROOT_RIGHT:"rootRight",ROOT_TOP:"rootTop",CONTROLS_LEFT:"controlsLeft",CONTROLS_RIGTH:"controlsRight",CONTROLS_RIGHT:"controlsRight",CONTROLS_CENTER:"controlsCenter",CONTROLS:"controls"};function St(e){return!!e&&(e.indexOf&&/^(?:http|data:|\/)/.test(e))}function Et(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",r=null;if(e instanceof window.Element)return Y.addClass(e,i),Object.keys(n).map((function(t){e.setAttribute(t,n[t])})),e;if(St(e)||St(e.url))return n.src=St(e)?e:e.url||"",r=Y.createDom(e.tag||"img","",n,"xg-img ".concat(i));if("function"==typeof e)try{return(r=e())instanceof window.Element?(Y.addClass(r,i),Object.keys(n).map((function(e){r.setAttribute(e,n[e])})),r):(z.logWarn("warn>>icons.".concat(t," in config of plugin named [").concat(o,"] is a function mast return an Element Object")),null)}catch(s){return z.logError("Plugin named [".concat(o,"]:createIcon"),s),null}return"string"==typeof e?Y.createDomFromHtml(e,n,i):(z.logWarn("warn>>icons.".concat(t," in config of plugin named [").concat(o,"] is invalid")),null)}function Pt(e,t){var i=t.config.icons||t.playerConfig.icons;Object.keys(e).map((function(n){var o=e[n],r=o&&o.class?o.class:"",s=o&&o.attr?o.attr:{},a=null;i&&i[n]&&(r=function(e,t){return"object"===T(e)&&e.class&&"string"==typeof e.class?"".concat(t," ").concat(e.class):t}(i[n],r),s=function(e,t){return"object"===T(e)&&e.attr&&"object"===T(e.attr)&&Object.keys(e.attr).map((function(i){t[i]=e.attr[i]})),t}(i[n],s),a=Et(i[n],n,r,s,t.pluginName)),!a&&o&&(a=Et(o.icon?o.icon:o,s,r,{},t.pluginName)),t.icons[n]=a}))}var It=function(e){I(i,mt);var t=R(i);function i(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return x(this,i),(e=t.call(this,n)).__delegates=[],e}return E(i,[{key:"__init",value:function(e){if(M(L(i.prototype),"__init",this).call(this,e),e.root){var t=e.root,n=null;this.icons={},this.root=null,this.parent=null,Pt(this.registerIcons()||{},this),this.langText={};var o,r,s=this.registerLanguageTexts()||{};o=s,r=this,Object.keys(o).map((function(e){Object.defineProperty(r.langText,e,{get:function(){var t=r.lang,i=r.i18n;return i[e]?i[e]:o[e]&&o[e][t]||""}})}));var a="";try{a=this.render()}catch(u){throw z.logError("Plugin:".concat(this.pluginName,":render"),u),new Error("Plugin:".concat(this.pluginName,":render:").concat(u.message))}if(a)(n=i.insert(a,t,e.index)).setAttribute("data-index",e.index);else{if(!e.tag)return;(n=Y.createDom(e.tag,"",e.attr,e.name)).setAttribute("data-index",e.index),t.appendChild(n)}this.root=n,this.parent=t;var l=this.config.attr||{},c=this.config.style||{};this.setAttr(l),this.setStyle(c),this.config.index&&this.root.setAttribute("data-index",this.config.index),this.__registerChildren()}}},{key:"__registerChildren",value:function(){var e=this;if(this.root){this._children=[];var t=this.children();t&&"object"===T(t)&&Object.keys(t).length>0&&Object.keys(t).map((function(i){var n,o,r=i,s=t[r],a={root:e.root};"function"==typeof s?(n=e.config[r]||{},o=s):"object"===T(s)&&"function"==typeof s.plugin&&(n=s.options?Y.deepCopy(e.config[r]||{},s.options):e.config[r]||{},o=s.plugin),a.config=n,void 0!==n.index&&(a.index=n.index),n.root&&(a.root=n.root),e.registerPlugin(o,a,r)}))}}},{key:"updateLang",value:function(e){e||(e=this.lang);var t=this.root,i=this.i18n,n=this.langText;t&&function e(t,i){for(var n=0;n0?e(t.children[n],i):i(t.children[n])}(t,(function(t){var o=t.getAttribute&&t.getAttribute("lang-key");if(o){var r=i[o.toUpperCase()]||n[o];r&&(t.innerHTML="function"==typeof r?r(e):r)}}))}},{key:"lang",get:function(){return this.player.lang}},{key:"changeLangTextKey",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=this.i18n||{},n=this.langText;e.setAttribute&&e.setAttribute("lang-key",t);var o=i[t]||n[t]||"";o&&(e.innerHTML=o)}},{key:"plugins",value:function(){return this._children}},{key:"children",value:function(){return{}}},{key:"registerPlugin",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";t.root=t.root||this.root;var o=M(L(i.prototype),"registerPlugin",this).call(this,e,t,n);return this._children.push(o),o}},{key:"registerIcons",value:function(){return{}}},{key:"registerLanguageTexts",value:function(){return{}}},{key:"find",value:function(e){if(this.root)return this.root.querySelector(e)}},{key:"bind",value:function(e,t,n){var o=this;if(arguments.length<3&&"function"==typeof t)Array.isArray(e)?e.forEach((function(e){o.bindEL(e,t)})):this.bindEL(e,t);else{var r=i.delegate.call(this,this.root,e,t,n);this.__delegates=this.__delegates.concat(r)}}},{key:"unbind",value:function(e,t){var i=this;if(arguments.length<3&&"function"==typeof t)Array.isArray(e)?e.forEach((function(e){i.unbindEL(e,t)})):this.unbindEL(e,t);else for(var n="".concat(e,"_").concat(t),o=0;o2&&void 0!==arguments[2]&&arguments[2];this.root&&"on".concat(e)in this.root&&"function"==typeof t&&this.root.addEventListener(e,t,i)}},{key:"unbindEL",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.root&&"on".concat(e)in this.root&&"function"==typeof t&&this.root.removeEventListener(e,t,i)}},{key:"show",value:function(e){this.root&&(this.root.style.display=void 0!==e?e:"block","none"===window.getComputedStyle(this.root,null).getPropertyValue("display")&&(this.root.style.display="block"))}},{key:"hide",value:function(){this.root&&(this.root.style.display="none")}},{key:"appendChild",value:function(e,t){if(!this.root)return null;if(arguments.length<2&&arguments[0]instanceof window.Element)return this.root.appendChild(arguments[0]);if(!(t&&t instanceof window.Element))return null;try{return"string"==typeof e?this.find(e).appendChild(t):e.appendChild(t)}catch(i){return z.logError("Plugin:appendChild",i),null}}},{key:"render",value:function(){return""}},{key:"destroy",value:function(){}},{key:"__destroy",value:function(){var e=this,t=this.player;this.__delegates.map((function(e){e.destroy()})),this.__delegates=[],this._children instanceof Array&&(this._children.map((function(e){t.unRegisterPlugin(e.pluginName)})),this._children=null),this.root&&(this.root.hasOwnProperty("remove")?this.root.remove():this.root.parentNode&&this.root.parentNode.removeChild(this.root)),M(L(i.prototype),"__destroy",this).call(this),this.icons={},["root","parent"].map((function(t){e[t]=null}))}}],[{key:"insert",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=t.children.length,o=Number(i),r=e instanceof window.Node;if(n){for(var s=0,a=null,l="";s=o){l="beforebegin";break}c4&&void 0!==arguments[4]&&arguments[4],r=[];if(e instanceof window.Node&&"function"==typeof n)if(Array.isArray(i))i.forEach((function(i){var s=wt(e,t,i,n,o);s.key="".concat(t,"_").concat(i),r.push(s)}));else{var s=wt(e,t,i,n,o);s.key="".concat(t,"_").concat(i),r.push(s)}return r}},{key:"ROOT_TYPES",get:function(){return Tt}},{key:"POSITIONS",get:function(){return xt}}]),i}(),Lt=function(){function e(){var t=this;if(x(this,e),P(this,"__trigger",(function(e){var i=(new Date).getTime();t.timeStamp=i;for(var n=0;n-1?this.__handlers[o].handler=t:this.__handlers.push({target:e,handler:t,playerId:i})}}},{key:"unObserver",value:function(e){var t=-1;this.__handlers.map((function(i,n){e===i.target&&(t=n)}));try{this.observer&&this.observer.unobserve(e)}catch(i){}this.observer&&this.observer.unobserve(e),t>-1&&this.__handlers.splice(t,1)}},{key:"destroyObserver",value:function(){this.observer&&this.observer.disconnect(),this.observer=null,this.__handlers=null}},{key:"__runHandler",value:function(e){for(var t=this.__handlers,i=0;i2&&void 0!==arguments[2]?arguments[2]:{};if(e&&t&&"function"==typeof t&&void 0!==t.prototype){var n=e._pluginInfoId;if(n&&this.pluginGroup[n]){this.pluginGroup[n]._plugins||(this.pluginGroup[n]._plugins={});var o=this.pluginGroup[n]._plugins,r=this.pluginGroup[n]._originalOptions;i.player=e;var s=i.pluginName||t.pluginName;if(!s)throw new Error("The property pluginName is necessary");if(!t.isSupported||t.isSupported(e.config.mediaType,e.config.codecType)){i.config||(i.config={});for(var a=Object.keys(r),l=0;l1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;if(this.root){var o=e.defaultConfig||{};if(!t.root){switch(t.position?t.position:t.config&&t.config.position?t.config.position:o.position){case xt.CONTROLS_LEFT:t.root=this.left;break;case xt.CONTROLS_RIGHT:t.root=this.right;break;case xt.CONTROLS_CENTER:t.root=this.center;break;case xt.CONTROLS:t.root=this.root;break;default:t.root=this.left}return M(L(i.prototype),"registerPlugin",this).call(this,e,t,n)}}}},{key:"destroy",value:function(){"mobile"!==Q.device&&(this.unbind("mouseenter",this.onMouseEnter),this.unbind("mouseleave",this.onMouseLeave))}},{key:"render",value:function(){var e=this.config,t=e.mode,i=e.autoHide,n=e.initShow;if(!e.disable){var o=Y.classNames({"xgplayer-controls":!0},{"flex-controls":"flex"===t},{"bottom-controls":"bottom"===t},P({},Dt.CONTROLS_AUTOHIDE,i),{"xgplayer-controls-initshow":n||!i});return'\n \n \n \n \n \n \n \n ')}}}],[{key:"pluginName",get:function(){return"controls"}},{key:"defaultConfig",get:function(){return{disable:!1,autoHide:!0,mode:"",initShow:!1}}}]),i}(),Nt={lang:{},langKeys:[],textKeys:[]};function Ft(e,t){return Object.keys(t).forEach((function(i){var n,o=Y.typeOf(t[i]),r=Y.typeOf(e[i]);"Array"===o?("Array"!==r&&(e[i]=[]),(n=e[i]).push.apply(n,N(t[i]))):"Object"===o?("Object"!==r&&(e[i]={}),Ft(e[i],t[i])):e[i]=t[i]})),e}function Ht(){Object.keys(Nt.lang.en).map((function(e){Nt.textKeys[e]=e}))}function Bt(e,t){var i=e.LANG;if(t||(t=Nt),t.lang){var n=e.TEXT||{};"zh"===i&&(i="zh-cn"),t.lang[i]?Ft(t.lang[i],n):(t.langKeys.push(i),t.lang[i]=n),Ht()}}Bt({LANG:"en",TEXT:{ERROR_TYPES:{network:{code:1,msg:"video download error"},mse:{code:2,msg:"stream append error"},parse:{code:3,msg:"parsing error"},format:{code:4,msg:"wrong format"},decoder:{code:5,msg:"decoding error"},runtime:{code:6,msg:"grammatical errors"},timeout:{code:7,msg:"play timeout"},other:{code:8,msg:"other errors"}},HAVE_NOTHING:"There is no information on whether audio/video is ready",HAVE_METADATA:"Audio/video metadata is ready ",HAVE_CURRENT_DATA:"Data about the current play location is available, but there is not enough data to play the next frame/millisecond",HAVE_FUTURE_DATA:"Current and at least one frame of data is available",HAVE_ENOUGH_DATA:"The available data is sufficient to start playing",NETWORK_EMPTY:"Audio/video has not been initialized",NETWORK_IDLE:"Audio/video is active and has been selected for resources, but no network is used",NETWORK_LOADING:"The browser is downloading the data",NETWORK_NO_SOURCE:"No audio/video source was found",MEDIA_ERR_ABORTED:"The fetch process is aborted by the user",MEDIA_ERR_NETWORK:"An error occurred while downloading",MEDIA_ERR_DECODE:"An error occurred while decoding",MEDIA_ERR_SRC_NOT_SUPPORTED:"Audio/video is not supported",REPLAY:"Replay",ERROR:"Network is offline",PLAY_TIPS:"Play",PAUSE_TIPS:"Pause",PLAYNEXT_TIPS:"Play next",DOWNLOAD_TIPS:"Download",ROTATE_TIPS:"Rotate",RELOAD_TIPS:"Reload",FULLSCREEN_TIPS:"Fullscreen",EXITFULLSCREEN_TIPS:"Exit fullscreen",CSSFULLSCREEN_TIPS:"Cssfullscreen",EXITCSSFULLSCREEN_TIPS:"Exit cssfullscreen",TEXTTRACK:"Caption",PIP:"PIP",SCREENSHOT:"Screenshot",LIVE:"LIVE",OFF:"Off",OPEN:"Open",MINI_DRAG:"Click and hold to drag",MINISCREEN:"Miniscreen",REFRESH_TIPS:"Please Try",REFRESH:"Refresh",FORWARD:"forward",LIVE_TIP:"Live"}});var Ut={get textKeys(){return Nt.textKeys},get langKeys(){return Nt.langKeys},get lang(){var e={};return Nt.langKeys.map((function(t){e[t]=Nt.lang[t]})),Nt.lang["zh-cn"]&&(e.zh=Nt.lang["zh-cn"]||{}),e},extend:function(e,t){var i=[];if(t||(t=Nt),t.lang){i="Array"!==Y.typeOf(e)?Object.keys(e).map((function(t){return{LANG:"zh"===t?"zh-cn":t,TEXT:e[t]}})):e;var n=t.lang;i.map((function(e){"zh"===e.LANG&&(e.LANG="zh-cn"),n[e.LANG]?Ft(n[e.LANG]||{},e.TEXT||{}):Bt(e,t)})),Ht()}},use:Bt,init:function(e){var t,i={lang:{},langKeys:[],textKeys:{},pId:e};return Ft(i.lang,Nt.lang),(t=i.langKeys).push.apply(t,N(Nt.langKeys)),Ft(i.textKeys,Nt.textKeys),i}},jt=1,Vt=2,Wt=3,Gt=4,zt=5,Kt=6,Yt=7,Xt=["ERROR","INITIAL","READY","ATTACHING","ATTACHED","NOTALLOW","RUNNING","ENDED","DESTROYED"],qt={},Zt=null,Jt=function(e){I(i,U.EventEmitter);var t=R(i);function i(){return x(this,i),t.apply(this,arguments)}return E(i,[{key:"add",value:function(e){e&&(qt[e.playerId]=e,1===Object.keys(qt).length&&this.setActive(e.playerId,!0))}},{key:"remove",value:function(e){e&&(e.isUserActive,delete qt[e.playerId])}},{key:"_iterate",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];for(var i in qt)if(Object.prototype.hasOwnProperty.call(qt,i)){var n=qt[i];if(t){if(e(n))break}else e(n)}}},{key:"forEach",value:function(e){this._iterate(e)}},{key:"find",value:function(e){var t=null;return this._iterate((function(i){var n=e(i);return n&&(t=i),n}),!0),t}},{key:"findAll",value:function(e){var t=[];return this._iterate((function(i){e(i)&&t.push(i)})),t}},{key:"setActive",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(qt[e])return t?this.forEach((function(t){e===t.playerId?(t.isUserActive=!0,t.isInstNext=!1):t.isUserActive=!1})):qt[e].isUserActive=t,e}},{key:"getActiveId",value:function(){for(var e=Object.keys(qt),t=0;t1&&void 0!==arguments[1])||arguments[1];if(qt[e])return t?this.forEach((function(t){e===t.playerId?(t.isUserActive=!1,t.isInstNext=!0):t.isInstNext=!1})):qt[e].isInstNext=t,e}}],[{key:"getInstance",value:function(){return Zt||(Zt=new i),Zt}}]),i}();var $t=["play","pause","replay","retry"],Qt=0,ei=0,ti=null,ii=function(e){I(i,it);var t=R(i);function i(e){var n;x(this,i);var o,r=Y.deepMerge(Rt(),e);P(O(n=t.call(this,r)),"canPlayFunc",(function(){if(n.config){var e=n.config,t=e.autoplay,i=e.defaultPlaybackRate;z.logInfo("player","canPlayFunc, startTime",n.__startTime),n.__startTime>0&&n.duration>0&&(n.currentTime=n.__startTime>n.duration?n.duration:n.__startTime,n.__startTime=-1),n.playbackRate=i,(t||n._useAutoplay)&&n.mediaPlay(),n.off(fe,n.canPlayFunc),n.removeClass(Dt.ENTER)}})),P(O(n),"onFullscreenChange",(function(e,t){var i=function(){Y.setTimeout(O(n),(function(){n.resize()}),100)},o=Y.getFullScreenEl();n._fullActionFrom?n._fullActionFrom="":n.emit(Ye,{eventType:"system",action:"switch_fullscreen",pluginName:"player",currentTime:n.currentTime,duration:n.duration,props:[{prop:"fullscreen",from:!0,to:!1}]});var r=function(e,t,i){if(e){var n=e.getAttribute(i);return!(!n||n!==t||"VIDEO"!==e.tagName&&"AUDIO"!==e.tagName)}}(o,n.playerId,at);if(t||o&&(o===n._fullscreenEl||r))i(),!n.config.closeFocusVideoFocus&&n.media.focus(),n.fullscreen=!0,n.changeFullStyle(n.root,o,Dt.FULLSCREEN),n.emit(Me,!0,n._fullScreenOffset),n.cssfullscreen&&n.exitCssFullscreen();else if(n.fullscreen){i();var s=O(n),a=s._fullScreenOffset;s.config.needFullscreenScroll?(window.scrollTo(a.left,a.top),Y.setTimeout(O(n),(function(){n.fullscreen=!1,n._fullScreenOffset=null}),100)):(!n.config.closeFocusVideoFocus&&n.media.focus(),n.fullscreen=!1,n._fullScreenOffset=null),n.cssfullscreen?n.removeClass(Dt.FULLSCREEN):n.recoverFullStyle(n.root,n._fullscreenEl,Dt.FULLSCREEN),n._fullscreenEl=null,n.emit(Me,!1)}})),P(O(n),"_onWebkitbeginfullscreen",(function(e){n._fullscreenEl=n.media,n.onFullscreenChange(e,!0)})),P(O(n),"_onWebkitendfullscreen",(function(e){n.onFullscreenChange(e,!1)})),pt(O(n),$t),n.config=r,n._pluginInfoId=Y.generateSessionId(),(o=O(n)).logInfo=z.logInfo.bind(o),o.logWarn=z.logWarn.bind(o),o.logError=z.logError.bind(o);var s=n.constructor.defaultPreset;if(n.config.presets.length){var a=n.config.presets.indexOf("default");a>=0&&s&&(n.config.presets[a]=s)}else s&&n.config.presets.push(s);if(n.userTimer=null,n.waitTimer=null,n.handleSource=!0,n._state=jt,n.isError=!1,n._hasStart=!1,n.isSeeking=!1,n.isCanplay=!1,n._useAutoplay=!1,n.__startTime=-1,n.rotateDeg=0,n.isActive=!1,n.fullscreen=!1,n.cssfullscreen=!1,n.isRotateFullscreen=!1,n._fullscreenEl=null,n.timeSegments=[],n._cssfullscreenEl=null,n.curDefinition=null,n._orgCss="",n._fullScreenOffset=null,n._videoHeight=0,n._videoWidth=0,n.videoPos={pi:1,scale:0,rotate:-1,x:0,y:0,h:-1,w:-1,vy:0,vx:0},n.sizeInfo={width:0,height:0,left:0,top:0},n._accPlayed={t:0,acc:0,loopAcc:0},n._offsetInfo={currentTime:-1,duration:0},n.innerContainer=null,n.controls=null,n.topBar=null,n.root=null,n.__i18n=Ut.init(n._pluginInfoId),Q.os.isAndroid&&Q.osVersion>0&&Q.osVersion<6&&(n.config.autoplay=!1),n.database=new nt,n.isUserActive=!1,n._onceSeekCanplay=null,n._isPauseBeforeSeek=0,n.innerStates={isActiveLocked:!1},n.instManager=ti,!n._initDOM())return D(n);var l=n.config,c=l.definition,u=void 0===c?{}:c;if(!l.url&&u.list&&u.list.length>0){var h=u.list.find((function(e){return e.definition&&e.definition===u.defaultDefinition}));h||(u.defaultDefinition=u.list[0].definition,h=u.list[0]),n.config.url=h.url,n.curDefinition=h}return n._bindEvents(),n._registerPresets(),n._registerPlugins(),Ot.onPluginsReady(O(n)),n.getInitDefinition(),n.setState(Vt),Y.setTimeout(O(n),(function(){n.emit(we)}),0),n.onReady&&n.onReady(),(n.config.videoInit||n.config.autoplay)&&(!n.hasStart||n.state0?this._attachSourceEvents(this.media,e):this.media.src&&this.media.src===e?e||this.media.removeAttribute("src"):this.media.src=e),"Number"===Y.typeOf(this.config.volume)&&(this.volume=this.config.volume);var i=this.innerContainer?this.innerContainer:this.root;this.media instanceof window.Element&&!i.contains(this.media)&&i.insertBefore(this.media,i.firstChild);var n=this.media.readyState;z.logInfo("_startInit readyState",n),this.config.autoplay&&(!Y.isMSE(this.media)&&this.load(),(Q.os.isIpad||Q.os.isPhone)&&this.mediaPlay());var o=this.config.startTime;this.__startTime=o>0?o:-1,this.config.startTime=0,n>=2&&this.duration>0?this.canPlayFunc():this.on(fe,this.canPlayFunc),(!this.hasStart||this.state0&&void 0!==arguments[0])||arguments[0];this._loadingPlugins=[];var i=this.config.ignores||[],n=this.config.plugins||[],o=this.config.i18n||[];t&&Ut.extend(o,this.__i18n);var r=i.join("||").toLowerCase().split("||"),s=this.plugins;n.forEach((function(i){try{var n=i.plugin?i.plugin.pluginName:i.pluginName;if(n&&r.indexOf(n.toLowerCase())>-1)return null;if(!t&&s[n.toLowerCase()])return;if(i.lazy&&i.loader){var o=Ot.lazyRegister(e,i);return void(i.forceBeforeInit&&(o.then((function(){e._loadingPlugins.splice(e._loadingPlugins.indexOf(o),1)})).catch((function(t){z.logError("_registerPlugins:loadingPlugin",t),e._loadingPlugins.splice(e._loadingPlugins.indexOf(o),1)})),e._loadingPlugins.push(o)))}return e.registerPlugin(i)}catch(a){z.logError("_registerPlugins:",a)}}))}},{key:"_registerPresets",value:function(){var e=this;this.config.presets.forEach((function(t){!function(e,t){var i,n,o=t.preset&&t.options?new t.preset(t.options,e.config):new t({},e.config),r=o.plugins,s=void 0===r?[]:r,a=o.ignores,l=void 0===a?[]:a,c=o.icons,u=void 0===c?{}:c,h=o.i18n,d=void 0===h?[]:h;e.config.plugins||(e.config.plugins=[]),e.config.ignores||(e.config.ignores=[]),(i=e.config.plugins).push.apply(i,N(s)),(n=e.config.ignores).push.apply(n,N(l)),Object.keys(u).map((function(t){e.config.icons[t]||(e.config.icons[t]=u[t])}));var f=e.config.i18n||[];d.push.apply(d,N(f)),e.config.i18n=d}(e,t)}))}},{key:"_getRootByPosition",value:function(e){var t=null;switch(e){case xt.ROOT_RIGHT:this.rightBar||(this.rightBar=Y.createPositionBar("xg-right-bar",this.root)),t=this.rightBar;break;case xt.ROOT_LEFT:this.leftBar||(this.leftBar=Y.createPositionBar("xg-left-bar",this.root)),t=this.leftBar;break;case xt.ROOT_TOP:this.topBar||(this.topBar=Y.createPositionBar("xg-top-bar",this.root),this.config.topBarAutoHide&&Y.addClass(this.topBar,Dt.TOP_BAR_AUTOHIDE)),t=this.topBar;break;default:t=this.innerContainer||this.root}return t}},{key:"registerPlugin",value:function(e,t){var i=Ot.formatPluginInfo(e,t),n=i.PLUFGIN,o=i.options,r=this.config.plugins;!Ot.checkPluginIfExits(n.pluginName,r)&&r.push(n);var s=Ot.getRootByConfig(n.pluginName,this.config);s.root&&(o.root=s.root),s.position&&(o.position=s.position);var a=o.position?o.position:o.config&&o.config.position||n.defaultConfig&&n.defaultConfig.position;return!o.root&&"string"==typeof a&&a.indexOf("controls")>-1?this.controls&&this.controls.registerPlugin(n,o,n.pluginName):(o.root||(o.root=this._getRootByPosition(a)),Ot.register(this,n,o))}},{key:"deregister",value:function(e){"string"==typeof e?Ot.unRegister(this,e):e instanceof mt&&Ot.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 mt&&(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 Ot.getPlugins(this)}},{key:"getPlugin",value:function(e){var t=Ot.findPlugin(this,e);return t&&t.pluginName?t:null}},{key:"addClass",value:function(e){this.root&&(Y.hasClass(this.root,e)||Y.addClass(this.root,e))}},{key:"removeClass",value:function(e){this.root&&Y.removeClass(this.root,e)}},{key:"hasClass",value:function(e){if(this.root)return Y.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>Wt))return e||this.config.url||this.getInitDefinition(),this.hasStart=!0,this.setState(Wt),this._registerPlugins(!1),Ot.beforeInit(this).then((function(){if(t.config){e||(e=t.url||t.config.url);var i=t._preProcessUrl(e);return t._startInit(i.url)}})).catch((function(e){throw e.fileName="player",e.lineNumber="236",z.logError("start:beforeInit:",e),e}))}},{key:"switchURL",value:function(e,t){var i=this,n=e;"Object"===Y.typeOf(e)&&(n=e.url),n=this._preProcessUrl(n).url;var o=this.currentTime;this.__startTime=o;var r=this.paused&&!this.isError;return this.src=n,new Promise((function(e,t){var o=function(e){i.off("timeupdate",s),i.off("canplay",s),t(e)},s=function(){i.duration>0&&i.__startTime>0&&(i.currentTime=i.__startTime,i.__startTime=-1),r&&i.pause(),i.off("error",o),e(!0)};i.once("error",o),n?(Q.os.isAndroid?i.once("timeupdate",s):i.once("canplay",s),i.play()):i.errorHandler("error",{code:6,message:"empty_src"})}))}},{key:"videoPlay",value:function(){this.mediaPlay()}},{key:"mediaPlay",value:function(){var e=this;if(!this.hasStart&&this.state>>>playPromise.then"),e.setState(Kt),e.emit(xe))})).catch((function(t){if(z.logWarn(">>>>playPromise.catch",t.name),e.media&&e.media.error)return e.onError(),void e.removeClass(Dt.ENTER);"NotAllowedError"===t.name&&(e._errorTimer=Y.setTimeout(e,(function(){e._errorTimer=null,e.emit(Se),e.addClass(Dt.NOT_ALLOW_AUTOPLAY),e.removeClass(Dt.ENTER),e.pause(),e.setState(zt)}),0))})):(z.logWarn("video.play not return promise"),this.statethis.duration?parseInt(this.duration,10):e,!this._isPauseBeforeSeek&&(this._isPauseBeforeSeek=this.paused?2:1),this._onceSeekCanplay&&this.off(ue,this._onceSeekCanplay),this._onceSeekCanplay=function(){switch(i.removeClass(Dt.ENTER),i.isSeeking=!1,s){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(ue,this._onceSeekCanplay),this.state0&&i.defaultDefinition&&i.list.map((function(t){t.definition===i.defaultDefinition&&(e.config.url=t.url,e.curDefinition=t)}))}},{key:"changeDefinition",value:function(e,t){var i=this,n=this.config.definition;if(Array.isArray(null==n?void 0:n.list)&&n.list.forEach((function(t){(null==e?void 0:e.definition)===t.definition&&(i.curDefinition=t)})),null!=e&&e.bitrate&&"number"!=typeof e.bitrate&&(e.bitrate=parseInt(e.bitrate,10)||0),this.emit(He,{from:t,to:e}),this.hasStart){var o=this.switchURL(e.url,w({seamless:!1!==n.seamless&&"undefined"!=typeof MediaSource&&"function"==typeof MediaSource.isTypeSupported},e));o&&o.then?o.then((function(){i.emit(Be,{from:t,to:e})})):this.emit(Be,{from:t,to:e})}else this.config.url=e.url}},{key:"reload",value:function(){this.load(),this.reloadFunc=function(){this.play()},this.once(ve,this.reloadFunc)}},{key:"resetState",value:function(){var e=this,t=[Dt.NOT_ALLOW_AUTOPLAY,Dt.PLAYING,Dt.NO_START,Dt.PAUSED,Dt.REPLAY,Dt.ENTER,Dt.ENDED,Dt.ERROR,Dt.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(Dt.NO_START),this.emit(Xe)}},{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 n=Rt();Object.keys(this.config).keys((function(t){"undefined"===e.config[t]||"plugins"!==t&&"presets"!==t&&"el"!==t&&"id"!==t||(e.config[t]=n[t])}))}}},{key:"destroy",value:function(){var e,t=this,n=this.innerContainer,o=this.root,r=this.media;if(o&&r){if(this.hasStart=!1,this._useAutoplay=!1,o.removeAttribute(at),this.updateAcc("destroy"),this._unbindEvents(),this._detachSourceEvents(this.media),Y.clearAllTimers(this),this.emit(Ie),null===(e=ti)||void 0===e||e.remove(this),Ot.destroy(this),gt(this),M(L(i.prototype),"destroy",this).call(this),this.fullscreen&&this._fullscreenEl===this.root&&this.exitFullscreen(),n)for(var s=n.children,a=0;a0?o.className=l.filter((function(e){return e.indexOf("xgplayer")<0})).join(" "):o.className="",this.removeAttribute("data-xgfill"),["isSeeking","isCanplay","isActive","cssfullscreen","fullscreen"].forEach((function(e){t[e]=!1}))}}},{key:"replay",value:function(){var e=this;this.removeClass(Dt.ENDED),this.currentTime=0,this.isSeeking=!1,vt(this,"replay",(function(){e.once(ue,(function(){var t=e.mediaPlay();t&&t.catch&&t.catch((function(e){}))})),e.emit(Pe),e.onPlay()}))}},{key:"retry",value:function(){var e=this;this.removeClass(Dt.ERROR),this.addClass(Dt.LOADING),vt(this,"retry",(function(){var t=e.currentTime,i=e.config.url,n=Y.isMSE(e.media)?{url:i}:e._preProcessUrl(i);e.src=n.url,!e.config.isLive&&(e.currentTime=t),e.once(fe,(function(){e.mediaPlay()}))}))}},{key:"changeFullStyle",value:function(e,t,i,n){e&&(n||(n=Dt.PARENT_FULLSCREEN),this._orgCss||(this._orgCss=Y.filterStyleFromText(e)),Y.addClass(e,i),t&&t!==e&&!this._orgPCss&&(this._orgPCss=Y.filterStyleFromText(t),Y.addClass(t,n),t.setAttribute(at,this.playerId)))}},{key:"recoverFullStyle",value:function(e,t,i,n){n||(n=Dt.PARENT_FULLSCREEN),this._orgCss&&(Y.setStyleFromCsstext(e,this._orgCss),this._orgCss=""),Y.removeClass(e,i),t&&t!==e&&this._orgPCss&&(Y.setStyleFromCsstext(t,this._orgPCss),this._orgPCss="",Y.removeClass(t,n),t.removeAttribute(at))}},{key:"getFullscreen",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.config.fullscreenTarget,t=this.root,i=this.media;if(e||(e=t),this._fullScreenOffset={top:Y.scrollTop(),left:Y.scrollLeft()},this._fullscreenEl=e,this._fullActionFrom="get",Y.getFullScreenEl()===this._fullscreenEl)return this.onFullscreenChange(),Promise.resolve();try{for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:this.config.fullscreenTarget;this.isRotateFullscreen?this.exitRotateFullscreen():this.fullscreen&&this.exitFullscreen();var t=e?"".concat(Dt.INNER_FULLSCREEN," ").concat(Dt.CSS_FULLSCREEN):Dt.CSS_FULLSCREEN;this.changeFullStyle(this.root,e,t);var i=this.config.fullscreen,n=void 0===i?{}:i;(!0===n.useCssFullscreen||"function"==typeof n.useCssFullscreen&&n.useCssFullscreen())&&(this.fullscreen=!0,this.emit(Me,!0)),this._cssfullscreenEl=e,this.cssfullscreen=!0,this.emit(Ne,!0)}},{key:"exitCssFullscreen",value:function(){var e=this._cssfullscreenEl?"".concat(Dt.INNER_FULLSCREEN," ").concat(Dt.CSS_FULLSCREEN):Dt.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(Me,!1)):this.removeClass(e)}else this.recoverFullStyle(this.root,this._cssfullscreenEl,e);this._cssfullscreenEl=null,this.cssfullscreen=!1,this.emit(Ne,!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(Dt.INNER_FULLSCREEN," ").concat(Dt.ROTATE_FULLSCREEN):Dt.ROTATE_FULLSCREEN;this._fullscreenEl=e||this.root,this.changeFullStyle(this.root,e,t,Dt.PARENT_ROTATE_FULLSCREEN),this.isRotateFullscreen=!0,this.fullscreen=!0,this.setRotateDeg(90),this._rootStyle=this.root.getAttribute("style"),this.root.style.width="".concat(window.innerHeight,"px"),this.emit(Me,!0)}},{key:"exitRotateFullscreen",value:function(e){var t=this._fullscreenEl!==this.root?"".concat(Dt.INNER_FULLSCREEN," ").concat(Dt.ROTATE_FULLSCREEN):Dt.ROTATE_FULLSCREEN;this.recoverFullStyle(this.root,this._fullscreenEl,t,Dt.PARENT_ROTATE_FULLSCREEN),this.isRotateFullscreen=!1,this.fullscreen=!1,this.setRotateDeg(0),this.emit(Me,!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 e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{autoHide:!this.config.closeDelayBlur,delay:this.config.inactive};this.isActive?this.onFocus(e):this.emit(_e,w({paused:this.paused,ended:this.ended},e))}},{key:"blur",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{ignorePaused:!1};this.isActive?this.emit(be,w({paused:this.paused,ended:this.ended},e)):this.onBlur(e)}},{key:"onFocus",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{autoHide:!0,delay:3e3},i=this.innerStates;if(this.isActive=!0,this.removeClass(Dt.INACTIVE),this.userTimer&&(Y.clearTimeout(this,this.userTimer),this.userTimer=null),void 0!==t.isLock&&(i.isActiveLocked=t.isLock),!1===t.autoHide||!0===t.isLock||i.isActiveLocked)this.userTimer&&(Y.clearTimeout(this,this.userTimer),this.userTimer=null);else{var n=t&&t.delay?t.delay:this.config.inactive;this.userTimer=Y.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.isActive&&!this.innerStates.isActiveLocked){var i=this.config.closePauseVideoFocus;this.isActive=!1,(t||i||!this.paused&&!this.ended)&&this.addClass(Dt.INACTIVE)}}},{key:"onEmptied",value:function(){this.updateAcc("emptied")}},{key:"onCanplay",value:function(){this.removeClass(Dt.ENTER),this.removeClass(Dt.ERROR),this.removeClass(Dt.LOADING),this.isCanplay=!0,this.waitTimer&&Y.clearTimeout(this,this.waitTimer)}},{key:"onDurationchange",value:function(){this.__startTime>0&&this.duration>0&&(this.currentTime=this.__startTime,this.__startTime=-1)}},{key:"onLoadeddata",value:function(){this.isError=!1,this.isSeeking=!1}},{key:"onLoadstart",value:function(){this.removeClass(Dt.ERROR),this.isCanplay=!1}},{key:"onPlay",value:function(){this.state===Yt&&this.setState(Kt),this.removeClass(Dt.PAUSED),this.ended&&this.removeClass(Dt.ENDED),!this.config.closePlayVideoFocus&&this.focus()}},{key:"onPause",value:function(){this.addClass(Dt.PAUSED),this.updateAcc("pause"),this.config.closePauseVideoFocus||(this.userTimer&&(Y.clearTimeout(this,this.userTimer),this.userTimer=null),this.focus())}},{key:"onEnded",value:function(){this.updateAcc("ended"),this.addClass(Dt.ENDED),this.setState(Yt)}},{key:"onError",value:function(){this.isError=!0,this.updateAcc("error"),this.removeClass(Dt.NOT_ALLOW_AUTOPLAY),this.removeClass(Dt.NO_START),this.removeClass(Dt.ENTER),this.removeClass(Dt.LOADING),this.addClass(Dt.ERROR)}},{key:"onSeeking",value:function(){this.isSeeking||this.updateAcc("seeking"),this.isSeeking=!0,this.addClass(Dt.SEEKING)}},{key:"onSeeked",value:function(){this.isSeeking=!1,this.waitTimer&&Y.clearTimeout(this,this.waitTimer),this.removeClass(Dt.LOADING),this.removeClass(Dt.SEEKING)}},{key:"onWaiting",value:function(){var e=this;this.waitTimer&&Y.clearTimeout(this,this.waitTimer),this.updateAcc("waiting"),this.waitTimer=Y.setTimeout(this,(function(){e.addClass(Dt.LOADING),e.emit(Re),Y.clearTimeout(e,e.waitTimer),e.waitTimer=null}),this.config.minWaitDelay)}},{key:"onPlaying",value:function(){var e=this;this.isError=!1,[Dt.NO_START,Dt.PAUSED,Dt.ENDED,Dt.ERROR,Dt.REPLAY,Dt.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(Dt.LOADING))&&this.media.readyState>2&&(this.removeClass(Dt.LOADING),Y.clearTimeout(this,this.waitTimer),this.waitTimer=null),!this.paused&&this.statei)return!0;return!1}},{key:"resizePosition",value:function(){var e=this.videoPos,t=e.vy,i=e.vx,n=e.h,o=e.w,r=this.videoPos.rotate;if(!(r<0&&n<0&&o<0)){var s=this.videoPos._pi;if(!s&&this.media.videoHeight&&(s=this.media.videoWidth/this.media.videoHeight*100),s){this.videoPos.pi=s;var a={rotate:r=r<0?0:r},l=0,c=0,u=1,h=Math.abs(r/90),d=this.root,f=this.innerContainer,p=d.offsetWidth,g=f?f.offsetHeight:d.offsetHeight,v=g,y=p;if(h%2==0)u=n>0?100/n:o>0?100/o:1,a.scale=u,l=t>0?(100-n)/2-t:0,a.y=2===h?0-l:l,c=i>0?(100-o)/2-i:0,a.x=2===h?0-c:c,this.media.style.width="".concat(y,"px"),this.media.style.height="".concat(v,"px");else if(h%2==1){v=p;var m=g-p;c=-m/2/(y=g)*100,a.x=3===h?c+t/2:c-t/2,l=m/2/v*100,a.y=3===h?l+i/2:l-i/2,a.scale=u,this.media.style.width="".concat(y,"px"),this.media.style.height="".concat(v,"px")}var k=Y.getTransformStyle(a,this.media.style.transform||this.media.style.webkitTransform);this.media.style.transform=k,this.media.style.webkitTransform=k}}}},{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(i){if("plugins"!==i){t.config[i]=e[i];var n=t.plugins[i.toLowerCase()];n&&"Function"===Y.typeOf(n.setConfig)&&n.setConfig(e[i])}}))}},{key:"playNext",value:function(e){var t=this;this.resetState(),this.setConfig(e),this._currentTime=0,this._duration=0,vt(this,"playnext",(function(){t.start(),t.emit(Ge,e)}))}},{key:"resize",value:function(){var e=this;if(this.media){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,n=i.videoWidth,o=i.videoHeight,r=this.config,s=r.fitVideoSize,a=r.videoFillMode;if("fill"!==a&&"cover"!==a&&"contain"!==a||this.setAttribute("data-xgfill",a),o&&n){this._videoHeight=o,this._videoWidth=n;var l=this.controls&&this.innerContainer?this.controls.root.getBoundingClientRect().height:0,c=t.width,u=t.height-l,h=parseInt(n/o*1e3,10),d=parseInt(c/u*1e3,10),f=c,p=u,g={};"auto"===s&&d>h||"fixWidth"===s?(p=c/h*1e3,this.config.fluid?g.paddingTop="".concat(100*p/f,"%"):g.height="".concat(p+l,"px")):("auto"===s&&dh)&&this.setAttribute("data-xgfill","cover");var v={videoScale:h,vWidth:f,vHeight:p,cWidth:f,cHeight:p+l};this.resizePosition(),this.emit(Ue,v)}}}},{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){z.logInfo("setState","state from:".concat(Xt[this.state]," to:").concat(Xt[e])),this._state=e}},{key:"_preProcessUrl",value:function(e,t){var i=this.config.preProcessUrl;return Y.isBlob(e)||"function"!=typeof i?{url:e}:i(e,t)}},{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(Vt),this.emit("hasstart"))}},{key:"isPlaying",get:function(){return this._state===Kt||this._state===Yt},set:function(e){e?this.setState(Kt):this._state>=Kt&&this.setState(Gt)}},{key:"definitionList",get:function(){return this.config&&this.config.definition&&this.config.definition.list||[]},set:function(e){var t=this,i=this.config.definition,n=null,o=null;i.list=e,this.emit("resourceReady",e),e.forEach((function(e){var r;(null===(r=t.curDefinition)||void 0===r?void 0:r.definition)===e.definition&&(n=e),i.defaultDefinition===e.definition&&(o=e)})),!o&&e.length>0&&(o=e[0]),n?this.changeDefinition(n):o&&this.changeDefinition(o)}},{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===Ut.langKeys.filter((function(t){return t===e})).length&&"zh"!==e||(this.config.lang=e,Ot.setLang(e,this))}},{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 ee}},{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 M(L(i.prototype),"readyState",this)}},{key:"error",get:function(){var e=M(L(i.prototype),"error",this);return this.i18n[e]||e}},{key:"networkState",get:function(){return M(L(i.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=Y.convertDeg(e))%90==0&&e!==this.videoPos.rotate&&(this.videoPos.rotate=e,this.resizePosition())}},{key:"avgSpeed",get:function(){return ei},set:function(e){ei=e}},{key:"realTimeSpeed",get:function(){return Qt},set:function(e){Qt=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 ct.call.apply(ct,[this].concat(Array.prototype.slice.call(arguments)))}},{key:"useHooks",value:function(e,t){return ut.call.apply(ut,[this].concat(Array.prototype.slice.call(arguments)))}},{key:"removeHooks",value:function(e,t){return ht.call.apply(ht,[this].concat(Array.prototype.slice.call(arguments)))}},{key:"usePluginHooks",value:function(e,t,i){for(var n=arguments.length,o=new Array(n>3?n-3:0),r=3;r3?n-3:0),r=3;r0&&i&&!n&&(z.logInfo("[xgLogger]".concat(this.player.playerId," emitLog_firstFrame"),e),this._state.isFFLoading=!1,this._state.isFFSend=!0,this.emitLog(si,{fvt:this.fvt,costTime:this.fvt,vt:this.vt,startCostTime:this.startCostTime,loadedCostTime:this.loadedCostTime}))}},{key:"_startWaitTimeout",value:function(){var e=this;this._waittTimer&&Y.clearTimeout(this,this._waittTimer),this._waittTimer=Y.setTimeout(this,(function(){e.suspendWaitingStatus("timeout"),Y.clearTimeout(e,e._waittTimer),e._waittTimer=null}),this.config.waitTimeout)}},{key:"endState",value:function(e){this.suspendWaitingStatus(e),this.suspendSeekingStatus(e)}},{key:"suspendSeekingStatus",value:function(e){if(this.seekingStart){var t=ni(),i=t-this.seekingStart;this.seekingStart=0,this.emitLog(ui,{end:t,costTime:i,endType:e})}}},{key:"suspendWaitingStatus",value:function(e){if(this._waitTimer&&(Y.clearTimeout(this,this._waitTimer),this._waitTimer=null),this._waittTimer&&(Y.clearTimeout(this,this._waittTimer),this._waittTimer=null),this._isWaiting=!1,this.waitingStart){var t=ni(),i=t-this.waitingStart,n=t-this.fixedWaitingStart,o=this.config.waitTimeout;this._isWaiting=!1,this.waitingStart=0,this.fixedWaitingStart=0,this.emitLog(li,{fixedCostTime:n>o?o:n,costTime:i>o?o:i,type:"loadeddata"===e?1:this._waitType,endType:2===this._waitType?"seek":e})}}},{key:"emitLog",value:function(e,t){var i=this.player;this.emit(Ke,w({t:ni(),host:Y.getHostFromUrl(i.currentSrc),vtype:i.vtype,eventType:e,currentTime:this.player.currentTime,readyState:i.video.readyState,networkState:i.video.networkState},t))}}],[{key:"pluginName",get:function(){return"xgLogger"}},{key:"defaultConfig",get:function(){return{waitTimeout:1e4}}}]),i}();function di(){return(new DOMParser).parseFromString('\n \n\n',"image/svg+xml").firstChild}var fi=function(e){I(i,It);var t=R(i);function i(){return x(this,i),t.apply(this,arguments)}return E(i,[{key:"registerIcons",value:function(){return{replay:di}}},{key:"afterCreate",value:function(){var e=this;It.insert(this.icons.replay,this.root,0),this.__handleReplay=this.hook("replayClick",(function(){e.player.replay()}),{pre:function(e){e.preventDefault(),e.stopPropagation()}}),this.bind(".xgplayer-replay",["click","touchend"],this.__handleReplay),this.on(se,(function(){if(e.playerConfig.loop||Y.addClass(e.player.root,"replay"),!e.config.disable){e.show();var t=e.root.querySelector("path");if(t){var i=window.getComputedStyle(t).getPropertyValue("transform");if("string"==typeof i&&i.indexOf("none")>-1)return null;t.setAttribute("transform",i)}}})),this.on(oe,(function(){e.hide()}))}},{key:"handleReplay",value:function(e){e.preventDefault(),e.stopPropagation(),this.player.replay(),Y.removeClass(this.player.root,"replay")}},{key:"show",value:function(e){this.config.disable||(this.root.style.display="flex")}},{key:"enable",value:function(){this.config.disable=!1}},{key:"disable",value:function(){this.config.disable=!0,this.hide()}},{key:"destroy",value:function(){this.unbind(".xgplayer-replay",["click","touchend"],this.__handleReplay)}},{key:"render",value:function(){return'\n ').concat(this.i18n.REPLAY,"\n ")}}],[{key:"pluginName",get:function(){return"replay"}},{key:"defaultConfig",get:function(){return{disable:!1}}}]),i}(),pi=function(e){I(i,It);var t=R(i);function i(){return x(this,i),t.apply(this,arguments)}return E(i,[{key:"isEndedShow",get:function(){return this.config.isEndedShow},set:function(e){this.config.isEndedShow=e}},{key:"hide",value:function(){Y.addClass(this.root,"hide")}},{key:"show",value:function(e){Y.removeClass(this.root,"hide")}},{key:"beforeCreate",value:function(e){"string"==typeof e.player.config.poster&&(e.config.poster=e.player.config.poster)}},{key:"afterCreate",value:function(){var e=this;this.on(se,(function(){e.isEndedShow&&Y.removeClass(e.root,"hide")})),this.config.hideCanplay?(this.once(he,(function(){e.onTimeUpdate()})),this.on(Le,(function(){Y.removeClass(e.root,"hide"),Y.addClass(e.root,"xg-showplay"),e.once(he,(function(){e.onTimeUpdate()}))}))):this.on(oe,(function(){Y.addClass(e.root,"hide")}))}},{key:"onTimeUpdate",value:function(){var e=this;this.player.currentTime?Y.removeClass(this.root,"xg-showplay"):this.once(he,(function(){e.onTimeUpdate()}))}},{key:"update",value:function(e){e&&(this.config.poster=e,this.root.style.backgroundImage="url(".concat(e,")"))}},{key:"getBgSize",value:function(e){var t="";switch(e){case"cover":t="cover";break;case"contain":t="contain";break;case"fixHeight":t="auto 100%";break;default:t=""}return t?"background-size: ".concat(t,";"):""}},{key:"render",value:function(){var e=this.config,t=e.poster,i=e.hideCanplay,n=e.fillMode,o=e.notHidden,r=this.getBgSize(n),s=t?"background-image:url(".concat(t,");").concat(r):r;return'\n ')}}],[{key:"pluginName",get:function(){return"poster"}},{key:"defaultConfig",get:function(){return{isEndedShow:!0,hideCanplay:!1,notHidden:!1,poster:"",fillMode:"fixWidth"}}}]),i}();function gi(){return(new DOMParser).parseFromString('\n \n\n',"image/svg+xml").firstChild}function vi(){return(new DOMParser).parseFromString('\n \n\n',"image/svg+xml").firstChild}var yi={};function mi(e){e?window.clearTimeout(e):Object.keys(yi).map((function(e){window.clearTimeout(yi[e].id),delete yi[e]}))}var ki=function(e){I(i,It);var t=R(i);function i(e){var n;return x(this,i),P(O(n=t.call(this,e)),"onPlayerReset",(function(){n.autoPlayStart=!1;var e="auto"===n.config.mode?"auto-hide":"hide";n.setAttr("data-state","play"),Y.removeClass(n.root,e),n.show()})),P(O(n),"onAutoplayStart",(function(){if(!n.autoPlayStart){var e="auto"===n.config.mode?"auto-hide":"hide";Y.addClass(n.root,e),n.autoPlayStart=!0,n.onPlayPause("play")}})),n.autoPlayStart=!1,n}return E(i,[{key:"afterCreate",value:function(){var e=this,t=this.player,i=this.playerConfig;this.initIcons(),this.once(we,(function(){i&&(i.lang&&"en"===i.lang?Y.addClass(t.root,"lang-is-en"):"jp"===i.lang&&Y.addClass(t.root,"lang-is-jp"))})),this.on(xe,this.onAutoplayStart),i.autoplay||this.show(),this.on(Se,(function(){var t="auto"===e.config.mode?"auto-hide":"hide";e.setAttr("data-state","play"),Y.removeClass(e.root,t),e.show()})),this.on(oe,(function(){e.onPlayPause("play")})),this.on(ae,(function(){e.onPlayPause("pause")})),this.on(Xe,(function(){e.onPlayerReset()})),this.clickHandler=this.hook("startClick",this.switchPausePlay,{pre:function(t){t.cancelable&&t.preventDefault(),t.stopPropagation();var i=e.player.paused;e.emitUserAction(t,"switch_play_pause",{props:"paused",from:i,to:!i})}}),this.bind(["click","touchend"],this.clickHandler)}},{key:"registerIcons",value:function(){return{startPlay:{icon:gi,class:"xg-icon-play"},startPause:{icon:vi,class:"xg-icon-pause"}}}},{key:"initIcons",value:function(){var e=this.icons;this.appendChild("xg-start-inner",e.startPlay),this.appendChild("xg-start-inner",e.startPause)}},{key:"hide",value:function(){Y.addClass(this.root,"hide")}},{key:"show",value:function(e){Y.removeClass(this.root,"hide")}},{key:"focusHide",value:function(){Y.addClass(this.root,"focus-hide")}},{key:"recover",value:function(){Y.removeClass(this.root,"focus-hide")}},{key:"switchStatus",value:function(e){e?this.setAttr("data-state",this.player.paused?"pause":"play"):this.setAttr("data-state",this.player.paused?"play":"pause")}},{key:"animate",value:function(e){var t=this;this._animateId=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{start:null,end:null};return yi[e]&&window.clearTimeout(yi[e].id),yi[e]={},i.start&&i.start(),yi[e].id=window.setTimeout((function(){i.end&&i.end(),window.clearTimeout(yi[e].id),delete yi[e]}),t),yi[e].id}("pauseplay",400,{start:function(){Y.addClass(t.root,"interact"),t.show(),t.switchStatus(!0)},end:function(){Y.removeClass(t.root,"interact"),!e&&t.hide(),t._animateId=null}})}},{key:"endAnimate",value:function(){Y.removeClass(this.root,"interact"),mi(this._animateId),this._animateId=null}},{key:"switchPausePlay",value:function(e){var t=this.player;(e.cancelable&&e.preventDefault(),e.stopPropagation(),t.state\n \n ')}}],[{key:"pluginName",get:function(){return"start"}},{key:"defaultConfig",get:function(){return{isShowPause:!1,isShowEnd:!1,disableAnimate:!1,mode:"hide"}}}]),i}(),Ci=function(e){I(i,It);var t=R(i);function i(){return x(this,i),t.apply(this,arguments)}return E(i,[{key:"render",value:function(){var e=this.config.innerHtml,t=Y.createDom("xg-enter","",{},"xgplayer-enter");if(e&&e instanceof window.HTMLElement)t.appendChild(e);else if(e&&"string"==typeof e)t.innerHTML=e;else{for(var i="",n=1;n<=12;n++)i+='
');t.innerHTML='
'.concat(i,"
")}return t}}],[{key:"pluginName",get:function(){return"enter"}},{key:"defaultConfig",get:function(){return{innerHtml:"",logo:""}}}]),i}();function _i(e,t,i){try{return'
\n ').concat(e.i18n[t],"\n
")}catch(n){return'
'}}var bi=function(e){I(i,It);var t=R(i);function i(){return x(this,i),t.apply(this,arguments)}return E(i,[{key:"afterCreate",value:function(){this.getMini=this.getMini.bind(this),this.exitMini=this.exitMini.bind(this),this.bind("click",this.getMini)}},{key:"getMini",value:function(){this.config.onClick&&this.config.onClick()}},{key:"exitMini",value:function(){this.config.onClick&&this.config.onClick()}},{key:"destroy",value:function(){this.unbind(["click","touchend"],this.getMini)}},{key:"render",value:function(){var e="MINISCREEN";return'\n \n
').concat(this.i18n[e],"
\n
")}}],[{key:"pluginName",get:function(){return"miniscreenIcon"}},{key:"defaultConfig",get:function(){return{position:xt.CONTROLS_RIGHT,index:10}}}]),i}();function wi(e){var t=parseFloat(e);return-1===e.indexOf("%")&&!Number.isNaN(t)&&t}var Ti=["paddingLeft","paddingRight","paddingTop","paddingBottom","marginLeft","marginRight","marginTop","marginBottom","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"],xi=Ti.length;function Si(e){if("string"==typeof e&&(e=document.querySelector(e)),e&&"object"===T(e)&&e.nodeType){var t=function(e){return window.getComputedStyle(e)}(e);if("none"===t.display)return function(){for(var e={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0},t=0;t1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(n=t.call(this)).isEnabled=!0,n.isDragging=!1,n.isDown=!1,n.position={},n.downPoint={},n.dragPoint={x:0,y:0},n.startPos={x:0,y:0},n._root=e instanceof Element?e:document.querySelector(e),n._handlerDom=o.handle instanceof Element?o.handle:document.querySelector(o.handle),n._root&&n._handlerDom?(n._bindStartEvent(),n):D(n)}return E(i,[{key:"_bindStartEvent",value:function(){var e=this;"ontouchstart"in window?this._startKey="touchstart":this._startKey="mousedown",this["on".concat(this._startKey)]=this["on".concat(this._startKey)].bind(this),this._handlerDom.addEventListener(this._startKey,this["on".concat(this._startKey)]),Ai[this._startKey].map((function(t){e["on".concat(t)]=e["on".concat(t)].bind(e)}))}},{key:"_unbindStartEvent",value:function(){this._handlerDom.removeEventListener(this._startKey,this["on".concat(this._startKey)])}},{key:"_bindPostStartEvents",value:function(e){var t=this;if(e){var i=Ai[this._startKey];i.map((function(e){window.addEventListener(e,t["on".concat(e)])})),this._boundPointerEvents=i}}},{key:"_unbindPostStartEvents",value:function(){var e=this;this._boundPointerEvents&&(this._boundPointerEvents.map((function(t){window.removeEventListener(t,e["on".concat(t)])})),delete this._boundPointerEvents)}},{key:"enable",value:function(){this.isEnabled=!0}},{key:"disable",value:function(){this.isEnabled=!1,this.isDragging&&this.onUp()}},{key:"onDocUp",value:function(e){this.onUp()}},{key:"animate",value:function(){var e=this;this.isDragging&&(this.positionDrag(),window.requestAnimationFrame((function(){e.animate()})))}},{key:"positionDrag",value:function(){var e="translate3d(".concat(this.dragPoint.x,"px, ").concat(this.dragPoint.y,"px, 0)");this._root.style.transform=e,this._root.style.webKitTransform=e}},{key:"setLeftTop",value:function(){this._root.style.left=this.position.x+"px",this._root.style.top=this.position.y+"px"}},{key:"onmousedown",value:function(e){this.dragStart(e,e)}},{key:"onmousemove",value:function(e){this.dragMove(e,e)}},{key:"onmouseup",value:function(e){this.dragEnd(e,e)}},{key:"ontouchstart",value:function(e){var t=e.changedTouches[0];this.dragStart(e,t),this.touchIdentifier=void 0!==t.pointerId?t.pointerId:t.identifier,e.preventDefault()}},{key:"ontouchmove",value:function(e){var t=Ei(e.changedTouches,this.touchIdentifier);t&&this.dragMove(e,t)}},{key:"ontouchend",value:function(e){var t=Ei(e.changedTouches,this.touchIdentifier);t&&this.dragEnd(e,t),e.preventDefault()}},{key:"ontouchcancel",value:function(e){var t=Ei(e.changedTouches,this.touchIdentifier);t&&this.dragCancel(e,t)}},{key:"dragStart",value:function(e,t){if(this._root&&!this.isDown&&this.isEnabled){this.downPoint=t,this.dragPoint.x=0,this.dragPoint.y=0,this._getPosition();var i=Si(this._root);this.startPos.x=this.position.x,this.startPos.y=this.position.y,this.startPos.maxY=window.innerHeight-i.height,this.startPos.maxX=window.innerWidth-i.width,this.setLeftTop(),this.isDown=!0,this._bindPostStartEvents(e)}}},{key:"dragRealStart",value:function(e,t){this.isDragging=!0,this.animate(),this.emit(Pi,this.startPos)}},{key:"dragEnd",value:function(e,t){this._root&&(this._unbindPostStartEvents(),this.isDragging&&(this._root.style.transform="",this.setLeftTop(),this.emit(Li)),this.presetInfo())}},{key:"_dragPointerMove",value:function(e,t){var i={x:t.pageX-this.downPoint.pageX,y:t.pageY-this.downPoint.pageY};return!this.isDragging&&this.hasDragStarted(i)&&this.dragRealStart(e,t),i}},{key:"dragMove",value:function(e,t){if(e=e||window.event,this.isDown){var i=this.startPos,n=i.x,o=i.y,r=this._dragPointerMove(e,t),s=r.x,a=r.y;s=this.checkContain("x",s,n),a=this.checkContain("y",a,o),this.position.x=n+s,this.position.y=o+a,this.dragPoint.x=s,this.dragPoint.y=a,this.emit(Ii,this.position)}}},{key:"dragCancel",value:function(e,t){this.dragEnd(e,t)}},{key:"presetInfo",value:function(){this.isDragging=!1,this.startPos={x:0,y:0},this.dragPoint={x:0,y:0},this.isDown=!1}},{key:"destroy",value:function(){this._unbindStartEvent(),this._unbindPostStartEvents(),this.isDragging&&this.dragEnd(),this.removeAllListeners(),this._handlerDom=null}},{key:"hasDragStarted",value:function(e){return Math.abs(e.x)>3||Math.abs(e.y)>3}},{key:"checkContain",value:function(e,t,i){return t+i<0?0-i:"x"===e&&t+i>this.startPos.maxX?this.startPos.maxX-i:"y"===e&&t+i>this.startPos.maxY?this.startPos.maxY-i:t}},{key:"_getPosition",value:function(){var e=window.getComputedStyle(this._root),t=this._getPositionCoord(e.left,"width"),i=this._getPositionCoord(e.top,"height");this.position.x=Number.isNaN(t)?0:t,this.position.y=Number.isNaN(i)?0:i,this._addTransformPosition(e)}},{key:"_addTransformPosition",value:function(e){var t=e.transform;if(0===t.indexOf("matrix")){var i=t.split(","),n=0===t.indexOf("matrix3d")?12:4,o=parseInt(i[n],10),r=parseInt(i[n+1],10);this.position.x+=o,this.position.y+=r}}},{key:"_getPositionCoord",value:function(e,t){if(-1!==e.indexOf("%")){var i=Si(this._root.parentNode);return i?parseFloat(e)/100*i[t]:0}return parseInt(e,10)}}]),i}(),Di=function(e){I(i,It);var t=R(i);function i(e){var n;x(this,i),P(O(n=t.call(this,e)),"onCancelClick",(function(e){n.exitMini(),n.isClose=!0})),P(O(n),"onCenterClick",(function(e){var t=O(n).player;t.paused?t.play():t.pause()})),P(O(n),"onScroll",(function(e){if(!(!window.scrollY&&0!==window.scrollY||Math.abs(window.scrollY-n.pos.scrollY)<50)){var t=parseInt(Y.getCss(n.player.root,"height"));t+=n.config.scrollTop,n.pos.scrollY=window.scrollY,window.scrollY>t+5?!n.isMini&&!n.isClose&&n.getMini():window.scrollY<=t&&(n.isMini&&n.exitMini(),n.isClose=!1)}})),n.isMini=!1,n.isClose=!1;var o=O(n).config;return n.pos={left:o.left<0?window.innerWidth-o.width-20:o.left,top:o.top<0?window.innerHeight-o.height-20:o.top,height:n.config.height,width:n.config.width,scrollY:window.scrollY||0},n.lastStyle=null,n}return E(i,[{key:"beforeCreate",value:function(e){"boolean"==typeof e.player.config.mini&&(e.config.isShowIcon=e.player.config.mini)}},{key:"afterCreate",value:function(){var e=this;this.initIcons(),this.on(ae,(function(){e.setAttr("data-state","pause")})),this.on(oe,(function(){e.setAttr("data-state","play")}))}},{key:"onPluginsReady",value:function(){var e=this,t=this.player;if(!this.config.disable){if(this.config.isShowIcon){var i={config:{onClick:function(){e.getMini()}}};t.controls.registerPlugin(bi,i,bi.pluginName)}var n=Y.checkTouchSupport()?"touchend":"click";this.bind(".mini-cancel-btn",n,this.onCancelClick),this.bind(".play-icon",n,this.onCenterClick),this.config.disableDrag||(this._draggabilly=new Oi(this.player.root,{handle:this.root})),this.config.isScrollSwitch&&window.addEventListener("scroll",this.onScroll)}}},{key:"registerIcons",value:function(){return{play:{icon:gi,class:"xg-icon-play"},pause:{icon:vi,class:"xg-icon-pause"}}}},{key:"initIcons",value:function(){var e=this.icons;this.appendChild(".play-icon",e.play),this.appendChild(".play-icon",e.pause)}},{key:"getMini",value:function(){var e=this;if(!this.isMini){var t=this.player,i=this.playerConfig,n=this.config.target||this.player.root;this.lastStyle={},Y.addClass(t.root,"xgplayer-mini"),["width","height","top","left"].map((function(t){e.lastStyle[t]=n.style[t],n.style[t]="".concat(e.pos[t],"px")})),i.fluid&&(n.style["padding-top"]=""),this.emit(Fe,!0),t.isMini=this.isMini=!0}}},{key:"exitMini",value:function(){var e=this;if(!this.isMini)return!1;var t=this.player,i=this.playerConfig,n=this.config.target||this.player.root;Y.removeClass(t.root,"xgplayer-mini"),this.lastStyle&&Object.keys(this.lastStyle).map((function(t){n.style[t]=e.lastStyle[t]})),this.lastStyle=null,i.fluid&&(t.root.style.width="100%",t.root.style.height="0",t.root.style["padding-top"]="".concat(100*i.height/i.width,"%")),this.emit(Fe,!1),this.isMini=t.isMini=!1}},{key:"destroy",value:function(){window.removeEventListener("scroll",this.onScroll);var e=Y.checkTouchSupport()?"touchend":"click";this.unbind(".mini-cancel-btn",e,this.onCancelClick),this.unbind(".play-icon",e,this.onCenterClick),this._draggabilly&&this._draggabilly.destroy(),this._draggabilly=null,this.exitMini()}},{key:"render",value:function(){if(!this.config.disable)return'\n \n \n '.concat(_i(this,"MINI_DRAG",this.playerConfig.isHideTips),'\n \n
\n \n \n \n
\n
\n
\n
')}}],[{key:"pluginName",get:function(){return"miniscreen"}},{key:"defaultConfig",get:function(){return{index:10,disable:!1,width:320,height:180,left:-1,top:-1,isShowIcon:!1,isScrollSwitch:!1,scrollTop:0,disableDrag:!1}}}]),i}(),Ri={mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",mousemove:"onMouseMove"},Mi=["videoClick","videoDbClick"],Ni=function(e){I(i,mt);var t=R(i);function i(){var e;x(this,i);for(var n=arguments.length,o=new Array(n),r=0;r0&&t.replay():t.paused?t.play():t.pause()}},{key:"onContextmenu",value:function(e){(e=e||window.event).preventDefault&&e.preventDefault(),e.stopPropagation?e.stopPropagation():(e.returnValue=!1,e.cancelBubble=!0)}},{key:"destroy",value:function(){var e=this,t=this.player,i=t.video,n=t.root;this.clickTimer&&clearTimeout(this.clickTimer),n.removeEventListener("click",this.onVideoClick,!1),n.removeEventListener("dblclick",this.onVideoDblClick,!1),i.removeEventListener("contextmenu",this.onContextmenu,!1),Object.keys(Ri).map((function(t){n.removeEventListener(t,e[Ri[t]],!1)}))}}],[{key:"pluginName",get:function(){return"pc"}},{key:"defaultConfig",get:function(){return{}}}]),i}(),Fi="press",Hi="pressend",Bi="doubleclick",Ui="click",ji="touchmove",Vi="touchstart",Wi="touchend",Gi={start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},zi={start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseleave"};function Ki(e){return e&&e.length>0?e[e.length-1]:null}var Yi=function(){function e(t){var i=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{eventType:"touch"};x(this,e),P(this,"onTouchStart",(function(e){var t=i._pos,n=i.root,o=Ki(e.touches);t.x=o?parseInt(o.pageX,10):e.pageX,t.y=o?parseInt(o.pageX,10):e.pageX,t.start=!0,i.__setPress(e),n.addEventListener(i.events.end,i.onTouchEnd),n.addEventListener(i.events.cancel,i.onTouchCancel),n.addEventListener(i.events.move,i.onTouchMove),i.trigger(Vi,e)})),P(this,"onTouchCancel",(function(e){i.onTouchEnd(e)})),P(this,"onTouchEnd",(function(e){var t=i._pos,n=i.root;i.__clearPress(),n.removeEventListener(i.events.cancel,i.onTouchCancel),n.removeEventListener(i.events.end,i.onTouchEnd),n.removeEventListener(i.events.move,i.onTouchMove),e.moving=t.moving,e.press=t.press,t.press&&i.trigger(Hi,e),i.trigger(Wi,e),!t.press&&!t.moving&&i.__setDb(e),t.press=!1,t.start=!1,t.moving=!1})),P(this,"onTouchMove",(function(e){var t=i._pos,n=i.config,o=Ki(e.touches),r=o?parseInt(o.pageX,10):e.pageX,s=o?parseInt(o.pageY,10):e.pageX,a=r-t.x,l=s-t.y;Math.abs(l)=0&&this.__handlers[e].splice(n,1)}}},{key:"trigger",value:function(e,t){this.__handlers[e]&&this.__handlers[e].map((function(e){try{e(t)}catch(i){}}))}},{key:"destroy",value:function(){var e=this,t={touchend:"onTouchEnd",touchmove:"onTouchMove",touchstart:"onTouchStart"};Object.keys(t).forEach((function(i){e.root.removeEventListener(i,e[t[i]])}))}}]),e}();function Xi(){return(new DOMParser).parseFromString('\n \n \n',"image/svg+xml").firstChild}var qi="auto",Zi="seeking",Ji="playbackrate",$i=["videoClick","videoDbClick"],Qi=function(e){I(i,It);var t=R(i);function i(e){var n;return x(this,i),P(O(n=t.call(this,e)),"onTouchStart",(function(e){var t=O(n),i=t.player,o=t.config,r=t.pos,s=t.playerConfig,a=n.getTouche(e);if(a&&!o.disableGesture&&n.duration>0&&!i.ended){r.isStart=!0,Y.checkIsFunction(s.disableSwipeHandler)&&s.disableSwipeHandler(),n.find(".xg-dur").innerHTML=Y.format(n.duration);var l=n.root.getBoundingClientRect();90===i.rotateDeg?(r.top=l.left,r.left=l.top,r.width=l.height,r.height=l.width):(r.top=l.top,r.left=l.left,r.width=l.width,r.height=l.height);var c=parseInt(a.pageX-r.left,10),u=parseInt(a.pageY-r.top,10);r.x=90===i.rotateDeg?u:c,r.y=90===i.rotateDeg?c:u,r.scopeL=o.scopeL*r.width,r.scopeR=(1-o.scopeR)*r.width,r.scopeM1=r.width*(1-o.scopeM)/2,r.scopeM2=r.width-r.scopeM1}})),P(O(n),"onTouchMove",(function(e){var t=n.getTouche(e),i=O(n),o=i.pos,r=i.config,s=i.player;if(t&&!r.disableGesture&&n.duration&&o.isStart){var a=r.miniMoveStep,l=r.hideControlsActive,c=parseInt(t.pageX-o.left,10),u=parseInt(t.pageY-o.top,10),h=90===s.rotateDeg?u:c,d=90===s.rotateDeg?c:u;if(Math.abs(h-o.x)>a||Math.abs(d-o.y)>a){var f=h-o.x,p=d-o.y,g=o.scope;if(-1===g&&(0===(g=n.checkScope(h,d,f,p,o))&&(l?s.blur():s.focus({autoHide:!1}),!o.time&&(o.time=parseInt(1e3*s.currentTime,10)+1e3*n.timeOffset)),o.scope=g),-1===g||g>0&&!r.gestureY||0===g&&!r.gestureX)return;e.cancelable&&e.preventDefault(),n.executeMove(f,p,g,o.width,o.height),o.x=h,o.y=d}}})),P(O(n),"onTouchEnd",(function(e){var t=O(n),i=t.player,o=t.pos,r=t.playerConfig;if(o.isStart){o.scope>-1&&e.cancelable&&e.preventDefault();var s=n.config,a=s.disableGesture,l=s.gestureX;!a&&l?(n.endLastMove(o.scope),setTimeout((function(){i.getPlugin("progress")&&i.getPlugin("progress").resetSeekState()}),10)):o.time=0,o.scope=-1,n.resetPos(),Y.checkIsFunction(r.enableSwipeHandler)&&r.enableSwipeHandler(),n.changeAction(qi)}})),P(O(n),"onRootTouchMove",(function(e){!n.config.disableGesture&&n.config.gestureX&&n.checkIsRootTarget(e)&&(e.stopPropagation(),n.pos.isStart?n.onTouchMove(e):n.onTouchStart(e))})),P(O(n),"onRootTouchEnd",(function(e){n.pos.isStart&&n.checkIsRootTarget(e)&&(e.stopPropagation(),n.onTouchEnd(e))})),n.pos={isStart:!1,x:0,y:0,time:0,volume:0,rate:1,light:0,width:0,height:0,scopeL:0,scopeR:0,scopeM1:0,scopeM2:0,scope:-1},n.timer=null,n}return E(i,[{key:"duration",get:function(){return this.playerConfig.customDuration||this.player.duration}},{key:"timeOffset",get:function(){return this.playerConfig.timeOffset||0}},{key:"registerIcons",value:function(){return{seekTipIcon:{icon:Xi,class:"xg-seek-pre"}}}},{key:"afterCreate",value:function(){var e=this;$i.map((function(t){e.__hooks[t]=null}));var t=this.playerConfig,i=this.config,n=this.player;!0===t.closeVideoDblclick&&(i.closedbClick=!0),this.resetPos(),Y.isUndefined(t.disableGesture)||(i.disableGesture=!!t.disableGesture),this.appendChild(".xg-seek-icon",this.icons.seekTipIcon),this.xgMask=Y.createDom("xg-mask","",{},"xgmask"),n.root.appendChild(this.xgMask),this.initCustomStyle(),this.registerThumbnail();var o="mouse"===this.domEventType?"mouse":"touch";this.touch=new Yi(this.root,{eventType:o,needPreventDefault:!this.config.disableGesture}),this.root.addEventListener("contextmenu",(function(e){e.preventDefault()})),n.root.addEventListener("touchmove",this.onRootTouchMove,!0),n.root.addEventListener("touchend",this.onRootTouchEnd,!0),this.on(pe,(function(){var t=e.player,i=e.config;1e3*t.duration0&&(e.pos.time=0)}));var r={touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",press:"onPress",pressend:"onPressEnd",click:"onClick",doubleclick:"onDbClick"};if(Object.keys(r).map((function(t){e.touch.on(t,(function(i){e[r[t]](i)}))})),!i.disableActive){var s=n.plugins.progress;s&&(s.addCallBack("dragmove",(function(t){e.activeSeekNote(t.currentTime,t.forward)})),s.addCallBack("dragend",(function(){e.changeAction(qi)})))}}},{key:"registerThumbnail",value:function(){var e=this.player.plugins.thumbnail;if(e&&e.usable){this.thumbnail=e.createThumbnail(null,"mobile-thumbnail");var t=this.find(".time-preview");t.insertBefore(this.thumbnail,t.children[0])}}},{key:"initCustomStyle",value:function(){var e=(this.playerConfig||{}).commonStyle,t=e.playedColor,i=e.progressColor,n=e.timePreviewStyle,o=e.curTimeColor,r=e.durationColor;if(t&&(this.find(".xg-curbar").style.backgroundColor=t),i&&(this.find(".xg-bar").style.backgroundColor=i),n){var s=this.find(".time-preview");Object.keys(n).forEach((function(e){s.style[e]=n[e]}))}var a=o||t,l=r;a&&(this.find(".xg-cur").style.color=a),l&&(this.find(".xg-dur").style.color=l),this.config.disableTimeProgress&&Y.addClass(this.find(".xg-timebar"),"hide")}},{key:"resetPos",value:function(){var e=this;this.pos?(this.pos.isStart=!1,this.pos.scope=-1,["x","y","width","height","scopeL","scopeR","scopeM1","scopeM2"].map((function(t){e.pos[t]=0}))):this.pos={isStart:!1,x:0,y:0,volume:0,rate:1,light:0,width:0,height:0,scopeL:0,scopeR:0,scopeM1:0,scopeM2:0,scope:-1,time:0}}},{key:"changeAction",value:function(e){var t=this.player;this.root.setAttribute("data-xg-action",e);var i=t.plugins.start;i&&i.recover()}},{key:"getTouche",value:function(e){this.player.rotateDeg;var t=e.touches&&e.touches.length>0?e.touches[e.touches.length-1]:e;return{pageX:t.pageX,pageY:t.pageY}}},{key:"checkScope",value:function(e,t,i,n,o){var r=o.width,s=-1;if(e<0||e>r)return s;var a=0===n?Math.abs(i):Math.abs(i/n);return Math.abs(i)>0&&a>=1.73&&e>o.scopeM1&&eo.scopeR?2:3),s}},{key:"executeMove",value:function(e,t,i,n,o){switch(i){case 0:this.updateTime(e/n*this.config.scopeM);break;case 1:this.updateBrightness(t/o);break;case 2:Q.os.isIos||this.updateVolume(t/o)}}},{key:"endLastMove",value:function(e){var t=this,i=this.pos,n=this.player,o=this.config,r=(i.time-this.timeOffset)/1e3;if(0===e)n.seek(Number(r).toFixed(1)),o.hideControlsEnd?n.blur():n.focus(),this.timer=setTimeout((function(){t.pos.time=0}),500);this.changeAction(qi)}},{key:"checkIsRootTarget",value:function(e){var t=this.player.plugins||{};return(!t.progress||!t.progress.root.contains(e.target))&&(t.start&&t.start.root.contains(e.target)||t.controls&&t.controls.root.contains(e.target))}},{key:"sendUseAction",value:function(e){var t=this.player.paused;this.emitUserAction(e,"switch_play_pause",{prop:"paused",from:t,to:!t})}},{key:"clickHandler",value:function(e){var t=this.player,i=this.config,n=this.playerConfig;t.state=Kt&&(this.sendUseAction(Y.createEvent("dblclick")),this.switchPlayPause())}},{key:"onClick",value:function(e){var t=this,i=this.player;vt(this,$i[0],(function(e,i){t.clickHandler(i.e)}),{e:e,paused:i.paused})}},{key:"onDbClick",value:function(e){var t=this,i=this.player;vt(this,$i[1],(function(e,i){t.dbClickHandler(i.e)}),{e:e,paused:i.paused})}},{key:"onPress",value:function(e){var t=this.pos,i=this.config,n=this.player;i.disablePress||(t.rate=this.player.playbackRate,this.emitUserAction("press","change_rate",{prop:"playbackRate",from:n.playbackRate,to:i.pressRate}),n.playbackRate=i.pressRate,this.changeAction(Ji))}},{key:"onPressEnd",value:function(e){var t=this.pos,i=this.config,n=this.player;i.disablePress||(this.emitUserAction("pressend","change_rate",{prop:"playbackRate",from:n.playbackRate,to:t.rate}),n.playbackRate=t.rate,t.rate=1,this.changeAction(qi))}},{key:"updateTime",value:function(e){var t=this.player,i=this.config,n=this.player.duration;e=Number(e.toFixed(4));var o=parseInt(e*i.moveDuration,10)+this.timeOffset;o=(o+=this.pos.time)<0?0:o>1e3*n?1e3*n-200:o,t.getPlugin("time")&&t.getPlugin("time").updateTime(o/1e3),t.getPlugin("progress")&&t.getPlugin("progress").updatePercent(o/1e3/this.duration,!0),this.activeSeekNote(o/1e3,e>0),i.isTouchingSeek&&t.seek(Number((o-this.timeOffset)/1e3).toFixed(1)),this.pos.time=o}},{key:"updateVolume",value:function(e){this.player.rotateDeg&&(e=-e);var t=this.player,i=this.pos;if(e=parseInt(100*e,10),i.volume+=e,!(Math.abs(i.volume)<10)){var n=parseInt(10*t.volume,10)-parseInt(i.volume/10,10);n=n>10?10:n<1?0:n,t.volume=n/10,i.volume=0}}},{key:"updateBrightness",value:function(e){this.player.rotateDeg&&(e=-e);var t=this.pos,i=this.config,n=this.xgMask,o=t.light+.8*e;o=o>i.maxDarkness?i.maxDarkness:o<0?0:o,n&&(n.style.backgroundColor="rgba(0,0,0,".concat(o,")")),t.light=o}},{key:"activeSeekNote",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this.player,n=this.config,o=!(this.duration!==1/0&&this.duration>0);if(e&&"number"==typeof e&&!o&&!n.disableActive){e<0?e=0:e>i.duration&&(e=i.duration-.2),this.changeAction(Zi);var r=i.plugins.start;r&&r.focusHide(),this.find(".xg-dur").innerHTML=Y.format(this.duration),this.find(".xg-cur").innerHTML=Y.format(e),this.find(".xg-curbar").style.width="".concat(e/this.duration*100,"%"),t?Y.removeClass(this.find(".xg-seek-show"),"xg-back"):Y.addClass(this.find(".xg-seek-show"),"xg-back"),this.updateThumbnails(e)}}},{key:"updateThumbnails",value:function(e){var t=this.player.plugins.thumbnail;t&&t.usable&&this.thumbnail&&t.update(this.thumbnail,e,160,90)}},{key:"switchPlayPause",value:function(){var e=this.player;if(e.state\n
\n
\n
\n \n 00:00\n /\n 00:00\n
\n
\n
\n
\n
\n
\n ').concat(this.config.pressRate,"X").concat(this.i18n.FORWARD,"\n
\n \n ")}}],[{key:"pluginName",get:function(){return"mobile"}},{key:"defaultConfig",get:function(){return{index:0,disableGesture:!1,gestureX:!0,gestureY:!0,gradient:"normal",isTouchingSeek:!1,miniMoveStep:5,miniYPer:5,scopeL:.25,scopeR:.25,scopeM:.9,pressRate:2,darkness:!0,maxDarkness:.8,disableActive:!1,disableTimeProgress:!1,hideControlsActive:!1,hideControlsEnd:!1,moveDuration:36e4,closedbClick:!1,disablePress:!0,disableSeekIcon:!1,focusVideoClick:!1}}}]),i}();function en(e){var t=e.tagName;return!("INPUT"!==t&&"TEXTAREA"!==t&&!e.isContentEditable)}var tn=function(e){I(i,mt);var t=R(i);function i(){var e;x(this,i);for(var n=arguments.length,o=new Array(n),r=0;r0&&n-o>.9*t)}},{key:"checkCode",value:function(e,t){var i=this,n=!1;return Object.keys(this.keyCodeMap).map((function(o){i.keyCodeMap[o]&&e===i.keyCodeMap[o].keyCode&&!i.keyCodeMap[o].disable&&(n=!t||t&&!i.keyCodeMap[o].noBodyTarget)})),n}},{key:"downVolume",value:function(e){var t=this.player;if(!(t.volume<=0)){var i=parseFloat((t.volume-.1).toFixed(1)),n={volume:{from:t.volume,to:i}};this.emitUserAction(e,"change_volume",{props:n}),t.volume=i>=0?i:0}}},{key:"upVolume",value:function(e){var t=this.player;if(!(t.volume>=1)){var i=parseFloat((t.volume+.1).toFixed(1)),n={volume:{from:t.volume,to:i}};this.emitUserAction(e,"change_volume",{props:n}),t.volume=i<=1?i:1}}},{key:"seek",value:function(e){var t=this.player,i=t.currentTime,n=t.offsetCurrentTime,o=t.duration,r=t.offsetDuration,s=t.timeSegments,a=n>-1?n:i,l=r||o,c=e.repeat&&this.seekStep>=4?parseInt(this.seekStep/2,10):this.seekStep;a+c<=l?a+=c:a=l;var u=Y.getCurrentTimeByOffset(a,s),h={currentTime:{from:i,to:u}};this.emitUserAction(e,"seek",{props:h}),this.player.currentTime=u}},{key:"seekBack",value:function(e){var t=this.player,i=t.currentTime,n=t.offsetCurrentTime,o=t.timeSegments,r=(n>-1?n:i)-(e.repeat?parseInt(this.seekStep/2,10):this.seekStep);r<0&&(r=0);var s={currentTime:{from:i,to:r=Y.getCurrentTimeByOffset(r,o)}};this.emitUserAction(e,"seek",{props:s}),this.player.currentTime=r}},{key:"changePlaybackRate",value:function(e){var t=this._keyState,i=this.config,n=this.player;0===t.playbackRate&&(t.playbackRate=n.playbackRate,n.playbackRate=i.playbackRate)}},{key:"playPause",value:function(e){var t=this.player;t&&(this.emitUserAction(e,"switch_play_pause"),t.paused?t.play():t.pause())}},{key:"exitFullscreen",value:function(e){var t=this.player,i=t.fullscreen,n=t.cssfullscreen;i&&(this.emitUserAction("keyup","switch_fullscreen",{prop:"fullscreen",from:i,to:!i}),t.exitFullscreen()),n&&(this.emitUserAction("keyup","switch_css_fullscreen",{prop:"cssfullscreen",from:n,to:!n}),t.exitCssFullscreen())}},{key:"handleKeyDown",value:function(e){var t=this._keyState;if(e.repeat){t.isPress=!0;var i=Date.now();if(i-t.tt<200)return;t.tt=i}this.handleKeyCode(e.keyCode,e,t.isPress)}},{key:"handleKeyUp",value:function(e){var t=this._keyState;t.playbackRate>0&&(this.player.playbackRate=t.playbackRate,t.playbackRate=0),t.isKeyDown=!1,t.isPress=!1,t.tt=0}},{key:"handleKeyCode",value:function(e,t,i){for(var n,o=Object.keys(this.keyCodeMap),r=0;r\n \n\n',"image/svg+xml").firstChild}var on=function(e){I(i,It);var t=R(i);function i(){return x(this,i),t.apply(this,arguments)}return E(i,[{key:"registerIcons",value:function(){return{loadingIcon:nn}}},{key:"afterCreate",value:function(){this.appendChild("xg-loading-inner",this.icons.loadingIcon)}},{key:"render",value:function(){return'\n \n \n '}}],[{key:"pluginName",get:function(){return"loading"}},{key:"defaultConfig",get:function(){return{position:xt.ROOT}}}]),i}(),rn=[{tag:"xg-cache",className:"xgplayer-progress-cache",styleKey:"cachedColor"},{tag:"xg-played",className:"xgplayer-progress-played",styleKey:"playedColor"}],sn=function(){function e(t){x(this,e),this.fragments=t.fragments||[],0===this.fragments.length&&this.fragments.push({percent:1}),this._callBack=t.actionCallback,this.fragConfig={fragFocusClass:t.fragFocusClass||"inner-focus-point",fragAutoFocus:!!t.fragAutoFocus,fragClass:t.fragClass||""},this.style=t.style||{playedColor:"",cachedColor:"",progressColor:""},this.duration=0,this.cachedIndex=0,this.playedIndex=0,this.focusIndex=-1}return E(e,[{key:"updateDuration",value:function(e){var t=this;this.duration=e;var i=0,n=this.fragments;this.fragments=n.map((function(e){return e.start=parseInt(i,10),e.end=parseInt(i+e.percent*t.duration,10),e.duration=parseInt(e.percent*t.duration,10),i+=e.percent*t.duration,e}))}},{key:"updateProgress",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"played",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{newIndex:0,curIndex:0,millisecond:0},i=this.progressList,n=this.fragments;if(!(i.length<1)){var o=t.newIndex,r=t.curIndex,s=t.millisecond;o!==r&&i.map((function(t,i){io&&(t[e].style.width=0)}));var a=n[o],l=0===s?0:(s-a.start)/a.duration;i[o][e].style.width=l<0?0:"".concat(100*l,"%")}}},{key:"updateFocus",value:function(e){if(this.fragConfig.fragAutoFocus&&!(this.fragments.length<2))if(e){var t=this.findIndex(1e3*e.currentTime,this.focusIndex);if(t>=0&&t!==this.focusIndex){this.focusIndex>-1&&this.unHightLight(this.focusIndex),this.setHightLight(t);var i={index:t,preIndex:this.focusIndex,fragment:this.fragments[this.focusIndex]};this.focusIndex=t,this._callBack&&this._callBack(i)}}else if(this.focusIndex>-1){this.unHightLight(this.focusIndex);var n={index:-1,preIndex:this.focusIndex,fragment:null};this._callBack&&this._callBack(n),this.focusIndex=-1}}},{key:"update",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{cached:0,played:0},t=arguments.length>1?arguments[1]:void 0;if(!this.duration||parseInt(1e3*t,10)!==this.duration){if(!t&&0!==t)return;this.updateDuration(parseInt(1e3*t,10))}var i=this.playedIndex,n=this.cachedIndex;if("Undefined"!==Y.typeOf(e.played)){var o=this.findIndex(1e3*e.played,i);if(o<0)return;this.updateProgress("played",{newIndex:o,curIndex:i,millisecond:parseInt(1e3*e.played,10)}),this.playedIndex=o}if("Undefined"!==Y.typeOf(e.cached)){var r=this.findIndex(1e3*e.cached,n);if(r<0)return;this.updateProgress("cached",{newIndex:r,curIndex:n,millisecond:parseInt(1e3*e.cached,10)}),this.cachedIndex=r}}},{key:"findIndex",value:function(e,t){var i=this.fragments;if(!i||0===i.length)return-1;if(1===i.length)return 0;if(t>-1&&ti[t].start&&ei[i.length-1].start)return i.length-1;for(var n=0;ni[n].start&&e<=i[n].end){t=n;break}return t}},{key:"findHightLight",value:function(){for(var e=this.root.children,t=0;t=t.length?null:{dom:t[e],pos:t[e].getBoundingClientRect()}}},{key:"unHightLight",value:function(){for(var e=this.root.children,t=0;t0;)this.root.removeChild(i[0]);this.render()}}},{key:"render",value:function(){var e=this,t=this.style.progressColor;if(this.root||(this.root=Y.createDom("xg-inners","",{},"progress-list")),this.fragments){var i=this.fragConfig,n=i.fragClass,o=i.fragFocusClass;this.progressList=this.fragments.map((function(i){var r=Y.createDom("xg-inner","",{style:t?"background:".concat(t,"; flex: ").concat(i.percent):"flex: ".concat(i.percent)},"".concat(i.isFocus?o:""," xgplayer-progress-inner ").concat(n));return e.root.appendChild(r),rn.forEach((function(t){r.appendChild(Y.createDom(t.tag,"",{style:t.styleKey?"background: ".concat(e.style[t.styleKey],"; width:0;"):"width:0;"},t.className))})),{cached:r.children[0],played:r.children[1]}}))}return this.root}}]),e}(),an={POINT:"inner-focus-point",HIGHLIGHT:"inner-focus-highlight"},ln=function(e){I(i,It);var t=R(i);function i(e){var n;return x(this,i),P(O(n=t.call(this,e)),"onMoveOnly",(function(e,t){var i=O(n),o=i.pos,r=i.config,s=i.player,a=t;if(e){Y.event(e);var l=Y.getEventPos(e,s.zoom),c=90===s.rotateDeg?l.clientY:l.clientX;if(o.moving&&Math.abs(o.x-c)=0?t:i+this.timeOffset}},{key:"changeState",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.useable=e}},{key:"show",value:function(e){this.root&&(this.root.style.display="flex")}},{key:"_initInner",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t&&0!==t.length||(t=[{percent:1}]);var n=w(w({fragments:t},i),{},{actionCallback:function(t){e.emitUserAction("fragment_focus","fragment_focus",t)}});this.innerList?this.innerList.reset(n):(this.innerList=new sn(n),this.outer.insertBefore(this.innerList.render(),this.outer.children[0]),["findHightLight","unHightLight","setHightLight","findFragment"].map((function(t){e[t]=e.innerList[t].bind(e.innerList)})))}},{key:"_updateInnerFocus",value:function(e){this.innerList&&this.innerList.updateFocus(e)}},{key:"afterCreate",value:function(){var e=this;if(!this.config.disable&&!this.playerConfig.isLive){this.pos={x:0,y:0,moving:!1,isDown:!1,isEnter:!1,isLocked:!1},this.outer=this.find("xg-outer");var t=this.config,i=t.fragFocusClass,n=t.fragAutoFocus,o=t.fragClass;this._initInner(this.config.fragments,{fragFocusClass:i,fragAutoFocus:n,fragClass:o,style:this.playerConfig.commonStyle||{}}),"mobile"===Q.device&&(this.config.isDragingSeek=!1,this.isMobile=!0),this.progressBtn=this.find(".xgplayer-progress-btn"),this.on(pe,(function(){e.onMouseLeave()})),this.on(he,(function(){e.onTimeupdate()})),this.on(ue,(function(){e.onTimeupdate(),e.onCacheUpdate()})),this.on(me,(function(){e.onCacheUpdate()})),this.on(se,(function(){e.onCacheUpdate(!0),e.onTimeupdate(!0),e._state.now=0})),this.on(Ce,(function(){e.onReset()})),this.on(Ue,(function(){e.onVideoResize()})),this.bindDomEvents(),this.initCustomStyle()}}},{key:"setConfig",value:function(e){var t=this,i=null;Object.keys(e).forEach((function(n){t.config[n]=e[n],"fragments"===n&&(i=e[n])})),i&&this._initInner(i,e)}},{key:"initCustomStyle",value:function(){var e=(this.playerConfig||{}).commonStyle.sliderBtnStyle,t=this.progressBtn;e&&("string"==typeof e?t.style.boxShadow=e:"object"===T(e)&&Object.keys(e).map((function(i){t.style[i]=e[i]})))}},{key:"triggerCallbacks",value:function(e,t,i){this.__dragCallBacks.length>0&&this.__dragCallBacks.map((function(n){if(n&&n.handler&&n.type===e)try{n.handler(t,i)}catch(o){}}))}},{key:"addCallBack",value:function(e,t){t&&"function"==typeof t&&this.__dragCallBacks.push({type:e,handler:t})}},{key:"removeCallBack",value:function(e,t){var i=this.__dragCallBacks,n=-1;i.map((function(i,o){i&&i.type===e&&i.handler===t&&(n=o)})),n>-1&&i.splice(n,1)}},{key:"unlock",value:function(){var e=this.player,t=this.pos;t.isEnter=!1,t.isLocked=!1,e.isMini||(this.unbind("mousemove",this.onMoveOnly),t.isDown?this.unbind("mouseleave",this.onMouseLeave):this.blur())}},{key:"bindDomEvents",value:function(){var e=this.player,t=e.controls,i=e.config;this._mouseDownHandlerHook=this.hook("dragstart",this._mouseDownHandler),this._mouseUpHandlerHook=this.hook("dragend",this._mouseUpHandler),this._mouseMoveHandlerHook=this.hook("drag",this._mouseMoveHandler),"touch"!==this.domEventType&&"compatible"!==this.domEventType||(this.root.addEventListener("touchstart",this.onMouseDown),t&&(t.root&&t.root.addEventListener("touchmove",Y.stopPropagation),t.center&&t.center.addEventListener("touchend",Y.stopPropagation))),"mouse"!==this.domEventType&&"compatible"!==this.domEventType||(this.bind("mousedown",this.onMouseDown),"mobile"!==i.isMobileSimulateMode&&this.bind("mouseenter",this.onMouseEnter),this.bind("mouseover",this.onMouseOver),this.bind("mouseout",this.onMouseOut),this.player.root.addEventListener("click",this.onBodyClick,!0))}},{key:"focus",value:function(){this.player.controls.pauseAutoHide(),Y.addClass(this.root,"active")}},{key:"blur",value:function(){this._disableBlur||(this.player.controls.recoverAutoHide(),Y.removeClass(this.root,"active"))}},{key:"disableBlur",value:function(){this._disableBlur=!0}},{key:"enableBlur",value:function(){this._disableBlur=!1}},{key:"updateWidth",value:function(e,t,i,n){var o=this.config,r=this.player;if(!o.isCloseClickSeek||0!==n){var s=t=t>=r.duration?r.duration-o.endedDiff:Number(t).toFixed(1);this.updatePercent(i),this.updateTime(e),(1!==n||o.isDragingSeek&&"audio"!==r.config.mediaType)&&(this._state.now=s,this._state.direc=s>r.currentTime?0:1,r.seek(s))}}},{key:"computeTime",value:function(e,t){var i,n,o=this.player,r=this.root.getBoundingClientRect(),s=r.width,a=r.height,l=r.top,c=r.left,u=t;90===o.rotateDeg?(i=a,n=l):(i=s,n=c);var h=u-n,d=(h=h>i?i:h<0?0:h)/i;d=d<0?0:d>1?1:d;var f=parseInt(d*this.offsetDuration*1e3,10)/1e3;return{percent:d,currentTime:f,seekTime:Y.getCurrentTimeByOffset(f,o.timeSegments),offset:h,width:i,left:n,e:e}}},{key:"updateTime",value:function(e){var t=this.player,i=this.duration;e>i?e=i:e<0&&(e=0);var n=t.plugins.time;n&&n.updateTime(e)}},{key:"resetSeekState",value:function(){this.isProgressMoving=!1;var e=this.player.plugins.time;e&&e.resetActive()}},{key:"updatePercent",value:function(e,t){if(this.isProgressMoving=!0,!this.config.disable){e=e>1?1:e<0?0:e,this.progressBtn.style.left="".concat(100*e,"%"),this.innerList.update({played:e*this.offsetDuration},this.offsetDuration);var i=this.player.plugins.miniprogress;i&&i.update({played:e*this.offsetDuration},this.offsetDuration)}}},{key:"onTimeupdate",value:function(e){var t=this.player,i=this._state,n=this.offsetDuration;if(!(t.isSeeking&&t.media.seeking||this.isProgressMoving)&&t.hasStart){if(i.now>-1){var o=parseInt(1e3*i.now,10)-parseInt(1e3*t.currentTime,10);if(0===i.direc&&o>300||1===i.direc&&o>-300)return void(i.now=-1);i.now=-1}var r=this.currentTime;r=Y.adjustTimeByDuration(r,n,e),this.innerList.update({played:r},n),this.progressBtn.style.left="".concat(r/n*100,"%")}}},{key:"onCacheUpdate",value:function(e){var t=this.player,i=this.duration;if(t){var n=t.bufferedPoint.end;n=Y.adjustTimeByDuration(n,i,e),this.innerList.update({cached:n},i)}}},{key:"onReset",value:function(){this.innerList.update({played:0,cached:0},0),this.progressBtn.style.left="0%"}},{key:"destroy",value:function(){var e=this.player,t=e.controls;this.thumbnailPlugin=null,this.innerList.destroy(),this.innerList=null;var i=this.domEventType;"touch"!==i&&"compatible"!==i||(this.root.removeEventListener("touchstart",this.onMouseDown),this.root.removeEventListener("touchmove",this.onMouseMove),this.root.removeEventListener("touchend",this.onMouseUp),t&&(t.root&&t.root.removeEventListener("touchmove",Y.stopPropagation),t.center&&t.center.removeEventListener("touchend",Y.stopPropagation))),"mouse"!==i&&"compatible"!==i||(this.unbind("mousedown",this.onMouseDown),this.unbind("mouseenter",this.onMouseEnter),this.unbind("mousemove",this.onMoveOnly),this.unbind("mouseleave",this.onMouseLeave),document.removeEventListener("mousemove",this.onMouseMove,!1),document.removeEventListener("mouseup",this.onMouseUp,!1),e.root.removeEventListener("click",this.onBodyClick,!0))}},{key:"render",value:function(){if(!this.config.disable&&!this.playerConfig.isLive){var e=this.player.controls?this.player.controls.config.mode:"";return'\n \n \n \n \n \n ')}}}],[{key:"pluginName",get:function(){return"progress"}},{key:"defaultConfig",get:function(){return{position:xt.CONTROLS_CENTER,index:0,disable:!1,isDragingSeek:!0,closeMoveSeek:!1,isPauseMoving:!1,isCloseClickSeek:!1,fragments:[{percent:1}],fragFocusClass:an.POINT,fragClass:"",fragAutoFocus:!1,miniMoveStep:5,miniStartStep:2,onMoveStart:function(){},onMoveEnd:function(){},endedDiff:.2}}},{key:"FRAGMENT_FOCUS_CLASS",get:function(){return an}}]),i}(),cn=function(e){I(i,It);var t=R(i);function i(){var e;x(this,i);for(var n=arguments.length,o=new Array(n),r=0;r\n
\n
\n '.concat(_i(this,"PLAY_TIPS",this.playerConfig.isHideTips),"\n ")}}],[{key:"pluginName",get:function(){return"play"}},{key:"defaultConfig",get:function(){return{position:xt.CONTROLS_LEFT,index:0,disable:!1}}}]),i}();function hn(){return(new DOMParser).parseFromString('\n \n \n \n',"image/svg+xml").firstChild}var dn=function(e){I(i,It);var t=R(i);function i(){return x(this,i),t.apply(this,arguments)}return E(i,[{key:"afterCreate",value:function(){var e=this;this.initIcons(),this.onClick=function(t){t.preventDefault(),t.stopPropagation(),e.config.onClick(t)},this.bind(["click","touchend"],this.onClick)}},{key:"registerIcons",value:function(){return{screenBack:{icon:hn,class:"xg-fullscreen-back"}}}},{key:"initIcons",value:function(){var e=this.icons;this.appendChild(this.root,e.screenBack)}},{key:"show",value:function(){Y.addClass(this.root,"show")}},{key:"hide",value:function(){Y.removeClass(this.root,"show")}},{key:"render",value:function(){return'\n '}}],[{key:"pluginName",get:function(){return"topbackicon"}},{key:"defaultConfig",get:function(){return{position:xt.ROOT_TOP,index:0}}}]),i}();function fn(){return(new DOMParser).parseFromString('\n \n\n',"image/svg+xml").firstChild}function pn(){return(new DOMParser).parseFromString('\n \n\n',"image/svg+xml").firstChild}var gn=function(e){I(i,cn);var t=R(i);function i(){var e;x(this,i);for(var n=arguments.length,o=new Array(n),r=0;r1&&this.lockScreen(i.lockOrientationType))}},{key:"animate",value:function(e){e?this.setAttr("data-state","full"):this.setAttr("data-state","normal"),this.topBackIcon&&(e?(this.topBackIcon.show(),this.hide()):(this.topBackIcon.hide(),this.show()))}},{key:"render",value:function(){if(!this.config.disable){return'\n
\n
\n '.concat(_i(this,"FULLSCREEN_TIPS",this.playerConfig.isHideTips),"\n
")}}},{key:"lockScreen",value:function(e){try{screen.orientation.lock(e).catch((function(e){}))}catch(t){}}},{key:"unlockScreen",value:function(){try{screen.orientation.unlock().catch((function(e){}))}catch(e){}}}],[{key:"pluginName",get:function(){return"fullscreen"}},{key:"defaultConfig",get:function(){return{position:xt.CONTROLS_RIGHT,index:0,useCssFullscreen:!1,rotateFullscreen:!1,useScreenOrientation:!1,lockOrientationType:"landscape",switchCallback:null,target:null,disable:!1,needBackIcon:!1}}}]),i}(),vn=function(e){I(i,It);var t=R(i);function i(e){var n;return x(this,i),(n=t.call(this,e)).isActiving=!1,n}return E(i,[{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,t=this.player.controls.config.mode;this.mode="flex"===t?"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.on([pe,ue,he],(function(t){"durationchange"===t.eventName&&(e.isActiving=!1),e.onTimeUpdate()})),this.on(se,(function(){e.onTimeUpdate(!0)})),this.on(Ce,(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 t=this.player,i=this.config,n=this.duration;if(!i.disable&&!this.isActiving&&t.hasStart){var o=this.currentTime+this.timeOffset;o=Y.adjustTimeByDuration(o,n,e),"flex"===this.mode?(this.centerCurDom.innerHTML=this.minWidthTime(Y.format(o)),n!==1/0&&n>0&&(this.centerDurDom.innerHTML=Y.format(n))):(this.timeDom.innerHTML=this.minWidthTime(Y.format(o)),n!==1/0&&n>0&&(this.durationDom.innerHTML=Y.format(n)))}}},{key:"onReset",value:function(){"flex"===this.mode?(this.centerCurDom.innerHTML=this.minWidthTime(Y.format(0)),this.centerDurDom.innerHTML=Y.format(0)):(this.timeDom.innerHTML=this.minWidthTime(Y.format(0)),this.durationDom.innerHTML=Y.format(0))}},{key:"createCenterTime",value:function(){var e=this.player;if(e.controls&&e.controls.center){var t=e.controls.center;this.centerCurDom=Y.createDom("xg-icon","00:00",{},"xgplayer-time xg-time-left"),this.centerDurDom=Y.createDom("xg-icon","00:00",{},"xgplayer-time xg-time-right"),t.children.length>0?t.insertBefore(this.centerCurDom,t.children[0]):t.appendChild(this.centerCurDom),t.appendChild(this.centerDurDom)}}},{key:"afterPlayerInit",value:function(){var e=this.config;this.duration===1/0||this.playerConfig.isLive?(Y.hide(this.durationDom),Y.hide(this.timeDom),Y.hide(this.find(".time-separator")),Y.show(this.find(".time-live-tag"))):Y.hide(this.find(".time-live-tag")),e.hide?this.hide():this.show()}},{key:"changeLiveState",value:function(e){e?(Y.hide(this.durationDom),Y.hide(this.timeDom),Y.hide(this.find(".time-separator")),Y.show(this.find(".time-live-tag"))):(Y.hide(this.find(".time-live-tag")),Y.show(this.find(".time-separator")),Y.show(this.durationDom),Y.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(Y.format(e)):this.centerCurDom.innerHTML=this.minWidthTime(Y.format(e)))}},{key:"minWidthTime",value:function(e){return e.split(":").map((function(e){return''.concat(e,"")})).join(":")}},{key:"resetActive",value:function(){var e=this,t=this.player,i=function(){e.isActiving=!1};this.off(ue,i),t.isSeeking&&t.media.seeking?this.once(ue,i):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'\n 00:00\n /\n 00:00\n '.concat(this.i18n.LIVE_TIP,"\n ")}}],[{key:"pluginName",get:function(){return"time"}},{key:"defaultConfig",get:function(){return{position:xt.CONTROLS_LEFT,index:2,disable:!1}}}]),i}(),yn=function(e){I(i,mt);var t=R(i);function i(){var e;x(this,i);for(var n=arguments.length,o=new Array(n),r=0;r0&&(e.player.currentTime=e.curPos.start)}})),P(O(e),"_onTimeupdate",(function(){var t=e.player,i=t.currentTime,n=t.timeSegments;if(e._checkIfEnabled(n)){var o=n.length;e.lastCurrentTime=i;var r=Y.getIndexByTime(i,n);r!==e.curIndex&&e.changeIndex(r,n);var s=Y.getOffsetCurrentTime(i,n,r);if(e.player.offsetCurrentTime=s,e.curPos){var a=e.curPos,l=a.start,c=a.end;ic&&r>=o-1&&e.player.pause()}}})),P(O(e),"_onSeeking",(function(){var t=e.player,i=t.currentTime,n=t.timeSegments;if(e._checkIfEnabled(n))if(in[n.length-1].end)e.player.currentTime=n[n.length-1].end;else{var o=Y.getIndexByTime(i,n);if(o>=0){var r=e.getSeekTime(i,e.lastCurrentTime,o,n);r>=0&&(e.player.currentTime=r)}}})),P(O(e),"_onPlay",(function(){var t=e.player,i=t.currentTime,n=t.timeSegments;e._checkIfEnabled(n)&&i>=n[n.length-1].end&&(e.player.currentTime=n[0].start)})),e}return E(i,[{key:"afterCreate",value:function(){this.curIndex=-1,this.curPos=null,this.lastCurrentTime=0,this.updateSegments(),this.on(pe,this._onDurationChange),this.on(ve,this._onLoadedData),this.on(he,this._onTimeupdate),this.on(ce,this._onSeeking),this.on(oe,this._onPlay)}},{key:"setConfig",value:function(e){var t=this;if(e){var i=Object.keys(e);i.length<1||(i.forEach((function(i){t.config[i]=e[i]})),this.updateSegments())}}},{key:"updateSegments",value:function(){var e=this.config,t=e.disable,i=e.segments,n=this.player;if(t||!i||0===i.length)n.timeSegments=[],n.offsetDuration=0,n.offsetCurrentTime=-1;else{var o=this.formatTimeSegments(i,n.duration);n.timeSegments=o,n.offsetDuration=o.length>0?o[o.length-1].duration:0}}},{key:"formatTimeSegments",value:function(e,t){var i=[];return e?(e.sort((function(e,t){return e.start-t.start})),e.forEach((function(e,n){var o={};if(o.start=e.start<0?0:e.start,o.end=t>0&&e.end>t?t:e.end,!(t>0&&o.start>t)){i.push(o);var r=o.end-o.start;if(0===n)o.offset=e.start,o.cTime=0,o.segDuration=r,o.duration=r;else{var s=i[n-1];o.offset=s.offset+(o.start-s.end),o.cTime=s.duration+s.cTime,o.segDuration=r,o.duration=s.duration+r}}})),i):[]}},{key:"getSeekTime",value:function(e,t,i,n){var o=-1,r=n[i],s=r.start,a=r.end;if(e>=s&&e<=a)return o;var l=e-t;if(l<0&&es?t-s:0;return o=i-1>=0?n[i-1].end+l+c:0}return-1}},{key:"_checkIfEnabled",value:function(e){return!(!e||e.length<1)}},{key:"changeIndex",value:function(e,t){this.curIndex=e,e>=0&&t.length>0?this.curPos=t[e]:this.curPos=null}}],[{key:"pluginName",get:function(){return"TimeSegmentsControls"}},{key:"defaultConfig",get:function(){return{disable:!0,segments:[]}}}]),i}();function mn(){return(new DOMParser).parseFromString('\n \n \n\n',"image/svg+xml").firstChild}function kn(){return(new DOMParser).parseFromString('\n \n \n\n',"image/svg+xml").firstChild}function Cn(){return(new DOMParser).parseFromString('\n \n \n\n',"image/svg+xml").firstChild}var _n=function(e){I(i,It);var t=R(i);function i(){var e;x(this,i);for(var n=arguments.length,o=new Array(n),r=0;ro.barH||e.updateVolumePos(a,t)}})),P(O(e),"onBarMouseUp",(function(t){Y.event(t),document.removeEventListener("mouseup",e.onBarMouseUp);var i=O(e)._d;i.isStart=!1,i.isMoving=!1})),P(O(e),"onMouseenter",(function(t){e._d.isActive=!0,e.focus(),e.emit("icon_mouseenter",{pluginName:e.pluginName})})),P(O(e),"onMouseleave",(function(t){e._d.isActive=!1,e.unFocus(100,!1,t),e.emit("icon_mouseleave",{pluginName:e.pluginName})})),P(O(e),"onVolumeChange",(function(t){if(e.player){var i=e.player,n=i.muted,o=i.volume;e._d.isMoving||(e.find(".xgplayer-drag").style.height=n||0===o?"4px":"".concat(100*o,"%"),e.config.showValueLabel&&e.updateVolumeValue()),e.animate(n,o)}})),e}return E(i,[{key:"registerIcons",value:function(){return{volumeSmall:{icon:kn,class:"xg-volume-small"},volumeLarge:{icon:mn,class:"xg-volume"},volumeMuted:{icon:Cn,class:"xg-volume-mute"}}}},{key:"afterCreate",value:function(){var e=this;if(this._timerId=null,this._d={isStart:!1,isMoving:!1,isActive:!1},!this.config.disable){this.initIcons();var t=this.playerConfig,i=t.commonStyle,n=t.volume;i.volumeColor&&(this.find(".xgplayer-drag").style.backgroundColor=i.volumeColor),this.changeMutedHandler=this.hook("mutedChange",(function(t){e.changeMuted(t)}),{pre:function(e){e.preventDefault(),e.stopPropagation()}}),this._onMouseenterHandler=this.hook("mouseenter",this.onMouseenter),this._onMouseleaveHandler=this.hook("mouseleave",this.onMouseleave),"mobile"!==Q.device&&"mobile"!==this.playerConfig.isMobileSimulateMode&&(this.bind("mouseenter",this._onMouseenterHandler),this.bind(["blur","mouseleave"],this._onMouseleaveHandler),this.bind(".xgplayer-slider","mousedown",this.onBarMousedown),this.bind(".xgplayer-slider","mousemove",this.onBarMouseMove),this.bind(".xgplayer-slider","mouseup",this.onBarMouseUp)),this.bind(".xgplayer-icon",["touchend","click"],this.changeMutedHandler),this.on(ge,this.onVolumeChange),this.once(ve,this.onVolumeChange),"Number"!==Y.typeOf(n)&&(this.player.volume=this.config.default),this.onVolumeChange()}}},{key:"updateVolumePos",value:function(e,t){var i=this.player,n=this.find(".xgplayer-drag"),o=this.find(".xgplayer-bar");if(o&&n){var r=parseInt(e/o.getBoundingClientRect().height*1e3,10);n.style.height="".concat(e,"px");var s=Math.max(Math.min(r/1e3,1),0),a={volume:{from:i.volume,to:s}};i.muted&&(a.muted={from:!0,to:!1}),this.emitUserAction(t,"change_volume",{muted:i.muted,volume:i.volume,props:a}),i.volume=Math.max(Math.min(r/1e3,1),0),i.muted&&(i.muted=!1),this.config.showValueLabel&&this.updateVolumeValue()}}},{key:"updateVolumeValue",value:function(){var e=this.player,t=e.volume,i=e.muted,n=this.find(".xgplayer-value-label"),o=Math.max(Math.min(t,1),0);n.innerText=i?0:Math.ceil(100*o)}},{key:"focus",value:function(){this.player.focus({autoHide:!1}),this._timerId&&(Y.clearTimeout(this,this._timerId),this._timerId=null),Y.addClass(this.root,"slide-show")}},{key:"unFocus",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100,i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2?arguments[2]:void 0,o=this._d,r=this.player;o.isActive||(this._timerId&&(Y.clearTimeout(this,this._timerId),this._timerId=null),this._timerId=Y.setTimeout(this,(function(){o.isActive||(i?r.blur():r.focus(),Y.removeClass(e.root,"slide-show"),o.isStart&&e.onBarMouseUp(n)),e._timerId=null}),t))}},{key:"changeMuted",value:function(e){e&&e.stopPropagation();var t=this.player;this._d.isStart&&this.onBarMouseUp(e),this.emitUserAction(e,"change_muted",{muted:t.muted,volume:t.volume,props:{muted:{from:t.muted,to:!t.muted}}}),t.volume>0&&(t.muted=!t.muted),t.volume<.01&&(t.volume=this.config.miniVolume)}},{key:"animate",value:function(e,t){e||0===t?this.setAttr("data-state","mute"):t<.5&&this.icons.volumeSmall?this.setAttr("data-state","small"):this.setAttr("data-state","normal")}},{key:"initIcons",value:function(){var e=this.icons;this.appendChild(".xgplayer-icon",e.volumeSmall),this.appendChild(".xgplayer-icon",e.volumeLarge),this.appendChild(".xgplayer-icon",e.volumeMuted)}},{key:"destroy",value:function(){this._timerId&&(Y.clearTimeout(this,this._timerId),this._timerId=null),this.unbind("mouseenter",this.onMouseenter),this.unbind(["blur","mouseleave"],this.onMouseleave),this.unbind(".xgplayer-slider","mousedown",this.onBarMousedown),this.unbind(".xgplayer-slider","mousemove",this.onBarMouseMove),this.unbind(".xgplayer-slider","mouseup",this.onBarMouseUp),document.removeEventListener("mouseup",this.onBarMouseUp),this.unbind(".xgplayer-icon","mobile"===Q.device?"touchend":"click",this.changeMutedHandler)}},{key:"render",value:function(){if(!this.config.disable){var e=this.config.default||this.player.volume,t=this.config.showValueLabel;return'\n \n
\n
\n \n '.concat(t?'
'.concat(100*e,"
"):"",'\n
\n \n
\n
\n
')}}}],[{key:"pluginName",get:function(){return"volume"}},{key:"defaultConfig",get:function(){return{position:xt.CONTROLS_RIGHT,index:1,disable:!1,showValueLabel:!1,default:.6,miniVolume:.2}}}]),i}();function bn(){return(new DOMParser).parseFromString('\n \n \n \n \n \n \n \n \n \n\n',"image/svg+xml").firstChild}var wn=function(e){I(i,cn);var t=R(i);function i(e){var n;return x(this,i),(n=t.call(this,e)).rotateDeg=n.config.rotateDeg||0,n}return E(i,[{key:"afterCreate",value:function(){var e=this;if(!this.config.disable){M(L(i.prototype),"afterCreate",this).call(this),this.appendChild(".xgplayer-icon",this.icons.rotate),this.onBtnClick=this.onBtnClick.bind(this),this.bind(".xgplayer-icon",["click","touchend"],this.onBtnClick),this.on(Ue,(function(){e.rotateDeg&&e.config.innerRotate&&Y.setTimeout(e,(function(){e.updateRotateDeg(e.rotateDeg,e.config.innerRotate)}),100)}));var t=this.player.root;this.rootWidth=t.style.width||t.offsetWidth||t.clientWidth,this.rootHeight=t.style.height||t.offsetHeight||t.clientHeight,this.rotateDeg&&this.updateRotateDeg(this.rotateDeg,this.config.innerRotate)}}},{key:"destroy",value:function(){M(L(i.prototype),"destroy",this).call(this),this.unbind(".xgplayer-icon",["click","touchend"],this.onBtnClick)}},{key:"onBtnClick",value:function(e){e.preventDefault(),e.stopPropagation(),this.emitUserAction(e,"rotate"),this.rotate(this.config.clockwise,this.config.innerRotate,1)}},{key:"updateRotateDeg",value:function(e,t){if(e||(e=0),t)this.player.videoRotateDeg=e;else{var i=this.player,n=this.rootWidth,o=this.rootHeight,r=i.root,s=i.innerContainer,a=i.media,l=r.offsetWidth,c=s&&t?s.offsetHeight:r.offsetHeight,u=n,h=o,d=0,f=0;.75!==e&&.25!==e||(u="".concat(c,"px"),h="".concat(l,"px"),d=-(c-l)/2,f=-(l-c)/2);var p="translate(".concat(d,"px,").concat(f,"px) rotate(").concat(e,"turn)"),g={transformOrigin:"center center",transform:p,webKitTransform:p,height:h,width:u},v=t?a:r,y=t?i.getPlugin("poster"):null;Object.keys(g).map((function(e){v.style[e]=g[e],y&&y.root&&(y.root.style[e]=g[e])}))}}},{key:"rotate",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=this.player;this.rotateDeg||(this.rotateDeg=0);var o=e?1:-1;this.rotateDeg=(this.rotateDeg+1+.25*o*i)%1,this.updateRotateDeg(this.rotateDeg,t),n.emit(Ve,360*this.rotateDeg)}},{key:"registerIcons",value:function(){return{rotate:bn}}},{key:"render",value:function(){if(!this.config.disable)return'\n \n
\n
\n '.concat(_i(this,"ROTATE_TIPS",this.playerConfig.isHideTips),"\n
")}}],[{key:"pluginName",get:function(){return"rotate"}},{key:"defaultConfig",get:function(){return{position:xt.CONTROLS_RIGHT,index:6,innerRotate:!0,clockwise:!1,rotateDeg:0,disable:!1}}}]),i}();function Tn(){return(new DOMParser).parseFromString('\n \n',"image/svg+xml").firstChild}function xn(){return(new DOMParser).parseFromString('\n \n \n',"image/svg+xml").firstChild}var Sn="picture-in-picture",En="inline",Pn="fullscreen",In=function(e){I(i,cn);var t=R(i);function i(){var e;x(this,i);for(var n=arguments.length,o=new Array(n),r=0;r\n
\n
\n '.concat(_i(this,"PIP",this.playerConfig.isHideTips),"\n ")}}],[{key:"pluginName",get:function(){return"pip"}},{key:"defaultConfig",get:function(){return{position:xt.CONTROLS_RIGHT,index:6,showIcon:!1,preferDocument:!1,width:void 0,height:void 0,docPiPNode:void 0,docPiPStyle:void 0}}},{key:"checkWebkitSetPresentationMode",value:function(e){return"function"==typeof e.webkitSetPresentationMode}}]),i}();function Ln(){return(new DOMParser).parseFromString('\n \n\n',"image/svg+xml").firstChild}var An=function(e){I(i,It);var t=R(i);function i(e){var n;return x(this,i),P(O(n=t.call(this,e)),"playNext",(function(e){var t=O(n).player;e.preventDefault(),e.stopPropagation(),n.idx+1\n
\n
\n '.concat(_i(this,"PLAYNEXT_TIPS",this.playerConfig.isHideTips),"\n \n ")}}],[{key:"pluginName",get:function(){return"playNext"}},{key:"defaultConfig",get:function(){return{position:xt.CONTROLS_LEFT,index:1,url:null,urlList:[]}}}]),i}(),On={exports:{}};const Dn=e(On.exports=function e(t,i,n){var o,r,s=window,a="application/octet-stream",l=n||a,c=t,u=!i&&!n&&c,h=document.createElement("a"),d=function(e){return String(e)},f=s.Blob||s.MozBlob||s.WebKitBlob||d,p=i||"download";if(f=f.call?f.bind(s):Blob,"true"===String(this)&&(l=(c=[c,l])[0],c=c[1]),u&&u.length<2048&&(p=u.split("/").pop().split("?")[0],h.href=u,-1!==h.href.indexOf(u))){var g=new XMLHttpRequest;return g.open("GET",u,!0),g.responseType="blob",g.onload=function(t){e(t.target.response,p,a)},setTimeout((function(){g.send()}),0),g}if(/^data:([\w+-]+\/[\w+.-]+)?[,;]/.test(c)){if(!(c.length>2096103.424&&f!==d))return navigator.msSaveBlob?navigator.msSaveBlob(k(c),p):C(c);l=(c=k(c)).type||a}else if(/([\x80-\xff])/.test(c)){for(var v=0,y=new Uint8Array(c.length),m=y.length;v\n \n \n \n \n \n \n \n \n \n \n \n \n\n',"image/svg+xml").firstChild}var Mn=function(e){I(i,cn);var t=R(i);function i(e){var n;return x(this,i),P(O(n=t.call(this,e)),"download",(function(e){if(!n.isLock){n.emitUserAction(e,"download");var t=n.playerConfig.url,i="";"String"===Y.typeOf(t)?i=t:"Array"===Y.typeOf(t)&&t.length>0&&(i=t[0].src);var o=n.getAbsoluteURL(i);Dn(o),n.isLock=!0,n.timer=window.setTimeout((function(){n.isLock=!1,window.clearTimeout(n.timer),n.timer=null}),300)}})),n.timer=null,n.isLock=!1,n}return E(i,[{key:"afterCreate",value:function(){M(L(i.prototype),"afterCreate",this).call(this),this.config.disable||(this.appendChild(".xgplayer-icon",this.icons.download),this._handler=this.hook("click",this.download,{pre:function(e){e.preventDefault(),e.stopPropagation()}}),this.bind(["click","touchend"],this._handler))}},{key:"registerIcons",value:function(){return{download:Rn}}},{key:"getAbsoluteURL",value:function(e){if(!e.match(/^https?:\/\//)){var t=document.createElement("div");t.innerHTML='x'),e=t.firstChild.href}return e}},{key:"destroy",value:function(){M(L(i.prototype),"destroy",this).call(this),this.unbind(["click","touchend"],this.download),window.clearTimeout(this.timer),this.timer=null}},{key:"render",value:function(){if(!this.config.disable)return'\n
\n
\n '.concat(_i(this,"DOWNLOAD_TIPS",this.playerConfig.isHideTips),"\n
")}}],[{key:"pluginName",get:function(){return"download"}},{key:"defaultConfig",get:function(){return{position:xt.CONTROLS_RIGHT,index:3,disable:!0}}}]),i}(),Nn=function(e){I(i,cn);var t=R(i);function i(){return x(this,i),t.apply(this,arguments)}return E(i,[{key:"beforeCreate",value:function(e){"boolean"==typeof e.player.config.screenShot&&(e.config.disable=!e.player.config.screenShot)}},{key:"afterCreate",value:function(){M(L(i.prototype),"afterCreate",this).call(this),this.appendChild(".xgplayer-icon",this.icons.screenshotIcon);var e=this.config;this.initSize=function(t){e.fitVideo&&(e.width=t.vWidth,e.height=t.vHeight)},this.once(Ue,this.initSize)}},{key:"onPluginsReady",value:function(){this.show(),this.onClickBtn=this.onClickBtn.bind(this),this.bind(["click","touchend"],this.onClickBtn)}},{key:"saveScreenShot",value:function(e,t){var i=document.createElement("a");i.href=e,i.download=t;var n=document.createEvent("MouseEvents");n.initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),i.dispatchEvent(n)}},{key:"createCanvas",value:function(e,t){var i=document.createElement("canvas"),n=i.getContext("2d");this.canvasCtx=n,this.canvas=i,i.width=e||this.config.width,i.height=t||this.config.height,n.imageSmoothingEnabled=!0,n.imageSmoothingEnabled&&(n.imageSmoothingQuality="high")}},{key:"onClickBtn",value:function(e){var t=this;e.preventDefault(),e.stopPropagation(),this.emitUserAction(e,"shot");var i=this.config;this.shot(i.width,i.height).then((function(e){t.emit(We,e),i.saveImg&&t.saveScreenShot(e,i.name+i.format)}))}},{key:"shot",value:function(e,t){var i=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{quality:.92,type:"image/png"},o=this.config,r=this.player,s=n.quality||o.quality,a=n.type||o.type;return new Promise((function(n,l){var c,u=null;if(r.media.canvas)u=r.media.canvas;else{i.canvas?(i.canvas.width=e||o.width,i.canvas.height=t||o.height):i.createCanvas(e,t),u=i.canvas,c=i.canvasCtx;var h,d,f,p,g=r.media.videoWidth/r.media.videoHeight,v=u.width/u.height,y=r.media.videoWidth,m=r.media.videoHeight;g>v?(f=u.width,p=u.width/g,h=0,d=Math.round((u.height-p)/2)):g===v?(f=u.width,p=u.height,h=0,d=0):g\n
\n ').concat(this.icons.screenshotIcon?"":'').concat(this.i18n[t],""),"\n
\n ")}}}],[{key:"pluginName",get:function(){return"screenShot"}},{key:"defaultConfig",get:function(){return{position:xt.CONTROLS_RIGHT,index:5,quality:.92,type:"image/png",format:".png",width:600,height:337,saveImg:!0,fitVideo:!0,disable:!1,name:"screenshot"}}}]),i}(),Fn=function(){function e(t){x(this,e),this.config=t.config,this.parent=t.root,this.root=Y.createDom("ul","",{},"xg-options-list xg-list-slide-scroll ".concat(this.config.className)),t.root.appendChild(this.root);var i=this.config.maxHeight;i&&this.setStyle({maxHeight:i}),this.onItemClick=this.onItemClick.bind(this),this.renderItemList();var n="mobile"===Q.device?"touchend":"click";this._delegates=It.delegate.call(this,this.root,"li",n,this.onItemClick)}return E(e,[{key:"renderItemList",value:function(e){var t=this,i=this.config,n=this.root;e?i.data=e:e=i.data,i.style&&Object.keys(i.style).map((function(e){n.style[e]=i[e]})),e.length>0&&(this.attrKeys=Object.keys(e[0])),this.root.innerHTML="",e.map((function(e,i){var n=e.selected?"option-item selected":"option-item";e["data-index"]=i,t.root.appendChild(Y.createDom("li","".concat(e.showText,""),e,n))}))}},{key:"onItemClick",value:function(e){e.delegateTarget||(e.delegateTarget=e.target);var t=e.delegateTarget;if(t&&Y.hasClass(t,"selected"))return!1;var i="function"==typeof this.config.onItemClick?this.config.onItemClick:null,n=this.root.querySelector(".selected");Y.addClass(t,"selected"),n&&Y.removeClass(n,"selected"),i(e,{from:n?this.getAttrObj(n,this.attrKeys):null,to:this.getAttrObj(t,this.attrKeys)})}},{key:"getAttrObj",value:function(e,t){if(!e||!t)return{};var i={};t.map((function(t){i[t]=e.getAttribute(t)}));var n=e.getAttribute("data-index");return n&&(i.index=Number(n)),i}},{key:"show",value:function(){Y.removeClass(this.root,"hide"),Y.addClass(this.root,"active")}},{key:"hide",value:function(){Y.removeClass(this.root,"active"),Y.addClass(this.root,"hide")}},{key:"setStyle",value:function(e){var t=this;Object.keys(e).forEach((function(i){t.root.style[i]=e[i]}))}},{key:"destroy",value:function(){this._delegates&&(this._delegates.map((function(e){e.destroy&&e.destroy()})),this._delegates=null),this.root.innerHTML=null,this.parent.removeChild(this.root),this.root=null}}]),e}(),Hn="side",Bn="middle",Un="click",jn="hover";var Vn="mobile"===Q.device,Wn=function(e){I(i,It);var t=R(i);function i(e){var n;return x(this,i),P(O(n=t.call(this,e)),"onEnter",(function(e){e.stopPropagation(),n.emit("icon_mouseenter",{pluginName:n.pluginName}),n.switchActiveState(e)})),P(O(n),"switchActiveState",(function(e){e.stopPropagation(),n.config.toggleMode===Un?n.toggle(!n.isActive):n.toggle(!0)})),P(O(n),"onLeave",(function(e){e.stopPropagation(),n.emit("icon_mouseleave",{pluginName:n.pluginName}),n.config.listType!==Hn&&n.isActive&&n.toggle(!1)})),P(O(n),"onListEnter",(function(e){n.enterType=2})),P(O(n),"onListLeave",(function(e){n.enterType=0,n.isActive&&n.toggle(!1)})),n.isIcons=!1,n.isActive=!1,n.curValue=null,n.curIndex=0,n}return E(i,[{key:"updateLang",value:function(e){this.renderItemList(this.config.list,this.curIndex)}},{key:"afterCreate",value:function(){var e=this,t=this.config;this.initIcons(),Vn&&t.listType!==Bn&&(t.listType=Hn),t.hidePortrait&&Y.addClass(this.root,"portrait"),this.on([Ue,Me],(function(){e._resizeList()})),this.once(fe,(function(){t.list&&t.list.length>0&&(e.renderItemList(t.list),e.show())})),Vn&&this.on(_e,(function(){e.isActive&&(e.optionsList&&e.optionsList.hide(),e.isActive=!1)})),Vn?(t.toggleMode=Un,this.activeEvent="touchend"):this.activeEvent=t.toggleMode===Un?"click":"mouseenter",t.toggleMode===Un?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 e=this,t=this.icons,i=Object.keys(t),n=!1;i.length>0&&(i.forEach((function(i){e.appendChild(".xgplayer-icon",t[i]),!n&&(n=t[i])})),this.isIcons=n),n||(this.appendChild(".xgplayer-icon",Y.createDom("span","",{},"icon-text")),Y.addClass(this.find(".xgplayer-icon"),"btn-text"))}},{key:"show",value:function(e){!this.config.list||this.config.list.length<2||Y.addClass(this.root,"show")}},{key:"hide",value:function(){Y.removeClass(this.root,"show")}},{key:"getTextByLang",value:function(e,t,i){if(void 0===e)return"";var n=this.config.list;!i&&(i=this.player.lang),t=!t||Y.isUndefined(e[t])?"text":t,"number"==typeof e&&(e=n[e]);try{return"object"===T(e[t])?e[t][i]||e[t].en:e[t]}catch(o){return""}}},{key:"toggle",value:function(e){if(e!==this.isActive){var t=this.player.controls,i=this.config.listType;e?(i===Hn?t.blur():t.focus(),this.optionsList&&this.optionsList.show()):(i===Hn?t.focus():t.focusAwhile(),this.optionsList&&this.optionsList.hide()),this.isActive=e}}},{key:"onItemClick",value:function(e,t){e.stopPropagation();var i=this.config,n=i.listType,o=i.list;this.curIndex=t.to.index,this.curItem=o[this.curIndex],this.changeCurrentText(),(this.config.isItemClickHide||Vn||n===Hn)&&this.toggle(!1)}},{key:"onIconClick",value:function(e){}},{key:"changeCurrentText",value:function(){if(!this.isIcons){var e=this.config.list,t=e[this.curIndex\n
\n
\n ')}}],[{key:"pluginName",get:function(){return"optionsIcon"}},{key:"defaultConfig",get:function(){return{position:xt.CONTROLS_RIGHT,index:100,list:[],listType:"middle",listStyle:{},hidePortrait:!0,isShowIcon:!1,isItemClickHide:!0,toggleMode:jn,heightLimit:!0}}}]),i}(),Gn=function(e){I(i,Wn);var t=R(i);function i(e){var n;return x(this,i),(n=t.call(this,e)).curTime=0,n.isPaused=!0,n}return E(i,[{key:"beforeCreate",value:function(e){var t=e.config.list;Array.isArray(t)&&t.length>0&&(e.config.list=t.map((function(e){return!e.text&&e.name&&(e.text=e.name),e.text||(e.text=e.definition),e})))}},{key:"afterCreate",value:function(){var e=this;M(L(i.prototype),"afterCreate",this).call(this),this.on("resourceReady",(function(t){e.changeDefinitionList(t)})),this.on(He,(function(t){e.renderItemList(e.config.list,t.to)})),this.player.definitionList.length<2&&this.hide()}},{key:"show",value:function(e){!this.config.list||this.config.list.length<2||Y.addClass(this.root,"show")}},{key:"initDefinition",value:function(){var e=this.config,t=e.list,i=e.defaultDefinition;if(t.length>0){var n=null;t.map((function(e){e.definition===i&&(n=e)})),n||(n=t[0]),this.changeDefinition(n)}}},{key:"renderItemList",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.config.list||[],n=arguments.length>1?arguments[1]:void 0,o=n&&n.definition?n.definition:this.config.defaultDefinition;n&&t.forEach((function(e){e.selected=!1}));var r=0,s=t.map((function(t,i){var n=w(w({},t),{},{showText:e.getTextByLang(t)||t.definition,selected:!1});return(t.selected||t.definition&&t.definition==o)&&(n.selected=!0,r=i),n}));M(L(i.prototype),"renderItemList",this).call(this,s,r)}},{key:"changeDefinitionList",value:function(e){Array.isArray(e)&&(this.config.list=e.map((function(e){return!e.text&&e.name&&(e.text=e.name),e.text||(e.text=e.definition),e})),this.renderItemList(),this.config.list.length<2?this.hide():this.show())}},{key:"changeDefinition",value:function(e,t){this.player.changeDefinition(e,t)}},{key:"onItemClick",value:function(e,t){var n=this.player.definitionList;M(L(i.prototype),"onItemClick",this).apply(this,arguments),this.emitUserAction(e,"change_definition",{from:t.from,to:t.to});for(var o=0;o\n \n\n',"image/svg+xml").firstChild}function Yn(){return(new DOMParser).parseFromString('\n \n\n',"image/svg+xml").firstChild}var Xn=function(e){I(i,cn);var t=R(i);function i(){return x(this,i),t.apply(this,arguments)}return E(i,[{key:"beforeCreate",value:function(e){"boolean"==typeof e.player.config.cssFullscreen&&(e.config.disable=!e.player.config.cssFullscreen)}},{key:"afterCreate",value:function(){var e=this;M(L(i.prototype),"afterCreate",this).call(this),this.config.disable||(this.config.target&&(this.playerConfig.fullscreenTarget=this.config.target),this.initIcons(),this.on(Ne,(function(t){e.animate(t)})),this.btnClick=this.btnClick.bind(this),this.handleCssFullscreen=this.hook("cssFullscreen_change",this.btnClick,{pre:function(e){e.preventDefault(),e.stopPropagation()}}),this.bind(["click","touchend"],this.handleCssFullscreen))}},{key:"initIcons",value:function(){var e=this.icons,t=this.find(".xgplayer-icon");t.appendChild(e.cssFullscreen),t.appendChild(e.exitCssFullscreen)}},{key:"btnClick",value:function(e){e.preventDefault(),e.stopPropagation();var t=this.player.isCssfullScreen;this.emitUserAction(e,"switch_cssfullscreen",{cssfullscreen:t}),t?this.player.exitCssFullscreen():this.player.getCssFullscreen()}},{key:"animate",value:function(e){this.root&&(e?this.setAttr("data-state","full"):this.setAttr("data-state","normal"),this.switchTips(e))}},{key:"switchTips",value:function(e){var t=this.i18nKeys,i=this.find(".xg-tips");i&&this.changeLangTextKey(i,e?t.EXITCSSFULLSCREEN_TIPS:t.CSSFULLSCREEN_TIPS)}},{key:"registerIcons",value:function(){return{cssFullscreen:{icon:Kn,class:"xg-get-cssfull"},exitCssFullscreen:{icon:Yn,class:"xg-exit-cssfull"}}}},{key:"destroy",value:function(){M(L(i.prototype),"destroy",this).call(this),this.unbind(["click","touchend"],this.btnClick)}},{key:"render",value:function(){if(!this.config.disable)return"\n
\n
\n ".concat(_i(this,"CSSFULLSCREEN_TIPS",this.playerConfig.isHideTips),"\n
")}}],[{key:"pluginName",get:function(){return"cssFullscreen"}},{key:"defaultConfig",get:function(){return{position:xt.CONTROLS_RIGHT,index:1,disable:!1,target:null}}}]),i}(),qn=function(e){I(i,It);var t=R(i);function i(){return x(this,i),t.apply(this,arguments)}return E(i,[{key:"afterCreate",value:function(){var e=this;this.clickHandler=this.hook("errorRetry",this.errorRetry,{pre:function(e){e.preventDefault(),e.stopPropagation()}}),this.onError=this.hook("showError",this.handleError),this.bind(".xgplayer-error-refresh","click",this.clickHandler),this.on(le,(function(t){e.onError(t)}))}},{key:"errorRetry",value:function(e){this.emitUserAction(e,"error_retry",{}),this.player.retry()}},{key:"handleError",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.player,i=e.errorType,n=t.errorNote?this.i18n[t.errorNote]:"";if(!n)switch(i){case"decoder":n=this.i18n.MEDIA_ERR_DECODE;break;case"network":n=this.i18n.MEDIA_ERR_NETWORK;break;default:n=this.i18n.MEDIA_ERR_SRC_NOT_SUPPORTED}this.find(".xgplayer-error-text").innerHTML=n,this.find(".xgplayer-error-tips").innerHTML="".concat(this.i18n.REFRESH_TIPS,'').concat(this.i18n.REFRESH,"")}},{key:"destroy",value:function(){this.unbind(".xgplayer-error-refresh","click",this.clickHandler)}},{key:"render",value:function(){return'\n
\n \n \n
\n
'}}],[{key:"pluginName",get:function(){return"error"}}]),i}(),Zn=function(e){I(i,It);var t=R(i);function i(){return x(this,i),t.apply(this,arguments)}return E(i,[{key:"afterCreate",value:function(){var e=this;this.intervalId=0,this.customConfig=null,this.bind(".highlight",["click","touchend"],(function(t){(e.config.onClick||e.customOnClick)&&(t.preventDefault(),t.stopPropagation(),e.customOnClick?e.customOnClick(t):e.config.onClick(t))})),this.player.showPrompt=function(){e.showPrompt.apply(e,arguments)},this.player.hidePrompt=function(){e.hide()}}},{key:"setStyle",value:function(e){var t=this;Object.keys(e).map((function(i){t.root.style[i]=e[i]}))}},{key:"showPrompt",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){};if(e){this.customOnClick=n;var o=this.config.interval;if(this.intervalId&&(clearTimeout(this.intervalId),this.intervalId=null),Y.addClass(this.root,"show"),"arrow"===i.mode&&Y.addClass(this.root,"arrow"),this.find(".xgplayer-prompt-detail").innerHTML="string"==typeof e?e:"".concat(e.text||"")+"".concat(e.highlight?''.concat(e.highlight,""):""),i.style&&this.setStyle(i.style),"boolean"==typeof i.autoHide?i.autoHide:this.config.autoHide){var r=i.interval||o;this.intervalId=setTimeout((function(){t.hide()}),r)}}}},{key:"hide",value:function(){Y.removeClass(this.root,"show"),Y.removeClass(this.root,"arrow"),this.root.removeAttribute("style"),this.customOnClick=null}},{key:"render",value:function(){return'\n \n ')}}],[{key:"pluginName",get:function(){return"prompt"}},{key:"defaultConfig",get:function(){return{interval:3e3,style:{},mode:"arrow",autoHide:!0,detail:{text:"",highlight:""},onClick:function(){}}}}]),i}(),Jn={time:0,text:"",id:1,duration:1,color:"#fff",style:{},width:6,height:6};function $n(e){Object.keys(Jn).map((function(t){void 0===e[t]&&(e[t]=Jn[t])}))}var Qn={_updateDotDom:function(e,t){if(t){var i=this.calcuPosition(e.time,e.duration),n=e.style||{};n.left="".concat(i.left,"%"),n.width="".concat(i.width,"%"),t.setAttribute("data-text",e.text),t.setAttribute("data-time",e.time),i.isMini?Y.addClass(t,"mini"):Y.removeClass(t,"mini"),Object.keys(n).map((function(e){t.style[e]=n[e]}))}},initDots:function(){var e=this;this._ispots.map((function(t){e.createDot(t,!1)})),this.ispotsInit=!0},createDot:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this.player.plugins.progress;if(i&&(t&&($n(e),this._ispots.push(e)),this.ispotsInit||!t)){var n=this.calcuPosition(e.time,e.duration),o=e.style||{};o.left="".concat(n.left,"%"),o.width="".concat(n.width,"%");var r="xgspot_".concat(e.id," xgplayer-spot");n.isMini&&(r+=" mini");var s=e.template?'
'.concat(e.template,"
"):"",a=Y.createDom("xg-spot",s,{"data-text":e.text,"data-time":e.time,"data-id":e.id},r);Object.keys(o).map((function(e){a.style[e]=o[e]})),i.outer&&i.outer.appendChild(a),this.positionDot(a,e.id)}},findDot:function(e){if(this.player.plugins.progress){var t=this._ispots.filter((function(t,i){return t.id===e}));return t.length>0?t[0]:null}},updateDot:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=this.player.plugins.progress;if(i){var n=this.findDot(e.id);if(n&&Object.keys(e).map((function(t){n[t]=e[t]})),this.ispotsInit){var o=i.find('xg-spot[data-id="'.concat(e.id,'"]'));o&&(this._updateDotDom(e,o),t&&this.showDot(e.id))}}},deleteDot:function(e){var t=this._ispots,i=this.player.plugins.progress;if(i){for(var n=[],o=0;o=0;r--)if(t.splice(n[r],1),this.ispotsInit){var s=i.find('xg-spot[data-id="'.concat(e,'"]'));s&&s.parentElement.removeChild(s)}}},deleteAllDots:function(){var e=this.player.plugins.progress;if(e)if(this.ispotsInit){for(var t=e.root.getElementsByTagName("xg-spot"),i=t.length-1;i>=0;i--)e.outer.removeChild(t[i]);this._ispots=[]}else this._ispots=[]},updateAllDots:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],i=this.player.plugins.progress;if(i)if(this.ispotsInit){this._ispots=[];var n=i.root.getElementsByTagName("xg-spot"),o=n.length;if(o>t.length)for(var r=o-1;r>t.length-1;r--)i.outer.removeChild(n[r]);t.forEach((function(t,i){i0&&n.hide();var i=n.player.plugins.progress;i&&i.disableBlur(),n._curDot.addEventListener("mouseleave",n.onDotMouseLeave)}})),n._ispots=[],n.videoPreview=null,n.videothumbnail=null,n.thumbnail=null,n.timeStr="",n._state={now:0,f:!1},n}return E(i,[{key:"beforeCreate",value:function(e){var t=e.player.plugins.progress;t&&(e.root=t.root)}},{key:"afterCreate",value:function(){var e=this;this._curDot=null,this.handlerSpotClick=this.hook("spotClick",(function(t,i){i.seekTime&&e.player.seek(i.seekTime)})),this.transformTimeHook=this.hook("transformTime",(function(t){e.setTimeContent(Y.format(t))})),function(e){var t=e.config,i=e.player;Object.keys(Qn).map((function(t){e[t]=Qn[t].bind(e)}));var n=i.config.progressDot||t.ispots||[];e._ispots=n.map((function(e){return $n(e),e})),e.ispotsInit=!1,e.playerSize={left:i.sizeInfo.left,width:i.sizeInfo.width},e.on(pe,(function(){e.ispotsInit?e.updateDuration():e.initDots()})),e.on(Ue,(function(){e.positionDots()}))}(this),this.on(pe,(function(){e.show()})),this.config.disable&&this.disable(),this.extTextRoot=this.find(".xg-spot-ext-text")}},{key:"setConfig",value:function(e){var t=this;e&&Object.keys(e).map((function(i){t.config[i]=e[i]}))}},{key:"onPluginsReady",value:function(){this.player.plugins.progress&&(this.previewLine=this.find(".xg-spot-line"),this.timePoint=this.find(".xgplayer-progress-point"),this.timeText=this.find(".xg-spot-time"),this.tipText=this.find(".spot-inner-text"),this._hasThumnail=!1,this.registerThumbnail(),this.bindEvents())}},{key:"bindEvents",value:function(){var e=this,t=this.player.plugins.progress;if(t&&(Object.keys(eo).map((function(i){e[eo[i]]=e[eo[i]].bind(e),t.addCallBack(i,e[eo[i]])})),"mobile"!==Q.device)){this.bind(".xg-spot-info","mousemove",this.onMousemove),this.bind(".xg-spot-info","mousedown",this.onMousedown),this.bind(".xg-spot-info","mouseup",this.onMouseup);var i=this.hook("previewClick",(function(){}));this.handlerPreviewClick=function(t){t.stopPropagation(),i(parseInt(1e3*e._state.now,10)/1e3,t)},this.bind(".xg-spot-content","mouseup",this.handlerPreviewClick)}}},{key:"onProgressMove",value:function(e,t){!this.config.disable&&this.player.duration&&this.updatePosition(e.offset,e.width,e.currentTime,e.e)}},{key:"onProgressDragStart",value:function(e){!this.config.disable&&this.player.duration&&(this.isDrag=!0,this.videoPreview&&Y.addClass(this.videoPreview,"show"))}},{key:"onProgressDragEnd",value:function(e){!this.config.disable&&this.player.duration&&(this.isDrag=!1,this.videoPreview&&Y.removeClass(this.videoPreview,"show"))}},{key:"onProgressClick",value:function(e,t){this.config.disable||Y.hasClass(t.target,"xgplayer-spot")&&(t.stopPropagation(),t.preventDefault(),["time","id","text"].map((function(i){e[i]=t.target.getAttribute("data-".concat(i))})),e.time&&(e.time=Number(e.time)),this.handlerSpotClick(t,e))}},{key:"updateLinePos",value:function(e,t){var i=this.root,n=this.previewLine,o=this.player,r=this.config,s="flex"===o.controls.mode,a=i.getBoundingClientRect().width;if(a||!this._hasThumnail){var l,c=e-(a=this._hasThumnail&&at-a&&!s?(l=c-(t-a),c=t-a):l=0,void 0!==l&&(n.style.transform="translateX(".concat(l.toFixed(2),"px)")),i.style.transform="translateX(".concat(c.toFixed(2),"px) translateZ(0)")}}},{key:"updateTimeText",value:function(e){var t=this.timeText,i=this.timePoint;t.innerHTML=e,!this.thumbnail&&(i.innerHTML=e)}},{key:"updatePosition",value:function(e,t,i,n){var o=this.root,r=this.config,s=this._state;if(o){s.now=i,this.transformTimeHook(i);var a=this.timeStr;n&&n.target&&Y.hasClass(n.target,"xgplayer-spot")?(this.showTips(n.target.getAttribute("data-text"),!1,a),this.focusDot(n.target),s.f=!0,r.isFocusDots&&s.f&&(s.now=parseInt(n.target.getAttribute("data-time"),10))):r.defaultText?(s.f=!1,this.showTips(r.defaultText,!0,a)):(s.f=!1,this.hideTips("")),this.updateTimeText(a),this.updateThumbnails(s.now),this.updateLinePos(e,t)}}},{key:"setTimeContent",value:function(e){this.timeStr=e}},{key:"updateThumbnails",value:function(e){var t=this.player,i=this.videoPreview,n=this.config,o=t.plugins.thumbnail;if(o&&o.usable){this.thumbnail&&o.update(this.thumbnail,e,n.width,n.height);var r=i&&i.getBoundingClientRect();this.videothumbnail&&o.update(this.videothumbnail,e,r.width,r.height)}}},{key:"registerThumbnail",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if("mobile"!==Q.device){var t=this.player,i=this.config,n=t.getPlugin("thumbnail");if(n&&n.setConfig(e),n&&n.usable&&i.isShowThumbnail){Y.removeClass(this.root,"short-line no-thumbnail"),"short"===i.mode&&Y.addClass(this.root,"short-line"),this._hasThumnail=!0;var o=this.find(".xg-spot-thumbnail");this.thumbnail=n.createThumbnail(o,"progress-thumbnail"),i.isShowCoverPreview&&(this.videoPreview=Y.createDom("xg-video-preview","",{},"xgvideo-preview"),t.root.appendChild(this.videoPreview),this.videothumbnail=n.createThumbnail(this.videoPreview,"xgvideo-thumbnail")),this.updateThumbnails(0)}else Y.addClass(this.root,"short-line no-thumbnail")}}},{key:"calcuPosition",value:function(e,t){var i=this.player.plugins.progress,n=this.player,o=i.root.getBoundingClientRect().width,r=n.duration/o*6;return e+t>n.duration&&(t=n.duration-e),n.duration,n.duration,{left:e/n.duration*100,width:t/n.duration*100,isMini:t2&&void 0!==arguments[2]?arguments[2]:"";Y.addClass(this.root,"no-timepoint"),e&&(Y.addClass(this.find(".xg-spot-content"),"show-text"),t&&"production"===this.config.mode?(Y.addClass(this.root,"product"),this.tipText.textContent=e):(Y.removeClass(this.root,"product"),this.tipText.textContent=this._hasThumnail?e:"".concat(i," ").concat(e)))}},{key:"hideTips",value:function(){Y.removeClass(this.root,"no-timepoint"),this.tipText.textContent="",Y.removeClass(this.find(".xg-spot-content"),"show-text"),Y.removeClass(this.root,"product")}},{key:"hide",value:function(){Y.addClass(this.root,"hide")}},{key:"show",value:function(e){Y.removeClass(this.root,"hide")}},{key:"enable",value:function(){var e=this.config,t=this.playerConfig;this.config.disable=!1,this.show(),!this.thumbnail&&e.isShowThumbnail&&this.registerThumbnail(t.thumbnail||{})}},{key:"disable",value:function(){this.config.disable=!0,this.hide()}},{key:"destroy",value:function(){var e=this,t=this.player.plugins.progress;t&&Object.keys(eo).map((function(i){t.removeCallBack(i,e[eo[i]])})),this.videothumbnail=null,this.thumbnail=null,this.videoPreview&&this.player.root.removeChild(this.videoPreview),this.unbind(".xg-spot-info","mousemove",this.onMousemove),this.unbind(".xg-spot-info","mousedown",this.onMousedown),this.unbind(".xg-spot-info","mouseup",this.onMouseup),this.unbind(".xg-spot-content","mouseup",this.handlerPreviewClick)}},{key:"render",value:function(){return"mobile"===Q.device||"mobile"===this.playerConfig.isMobileSimulateMode?"":'
\n
\n
\n \n
\n
\n
\n
00:00
\n
\n
\n
')}}],[{key:"pluginName",get:function(){return"progresspreview"}},{key:"defaultConfig",get:function(){return{index:1,miniWidth:6,ispots:[],defaultText:"",isFocusDots:!0,isHideThumbnailHover:!0,isShowThumbnail:!0,isShowCoverPreview:!1,mode:"",disable:!1,width:160,height:90}}}]),i}(),io=function(e){I(i,It);var t=R(i);function i(e){var n;return x(this,i),(n=t.call(this,e)).ratio=1,n.interval=null,n._preloadMark={},n}return E(i,[{key:"afterCreate",value:function(){var e=this;this.usable&&this.initThumbnail(),this.on([pe],(function(){var t=e.config,i=t.pic_num,n=t.interval;e.usable&&(e.interval=n>0?n:Math.round(1e3*e.player.duration/i)/1e3)}))}},{key:"setConfig",value:function(e){var t=this;if(e){var i=Object.keys(e);i.length<1||(i.forEach((function(i){t.config[i]=e[i]})),this.usable&&this.initThumbnail())}}},{key:"usable",get:function(){var e=this.config,t=e.urls,i=e.pic_num;return t&&t.length>0&&i>0}},{key:"initThumbnail",value:function(){var e=this.config,t=e.width,i=e.height,n=e.pic_num,o=e.interval;this.ratio=t/i*100,this.interval=o||Math.round(this.player.duration/n),this._preloadMark={}}},{key:"getUrlByIndex",value:function(e){return e>=0&&e0&&o.push(e-1),o.push(e),e>0&&e=0&&e1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=this.config,o=n.pic_num,r=n.row,s=n.col,a=n.width,l=n.height;this.interval=Math.round(this.player.duration/o);var c=Math.ceil(e/this.interval),u=(c=c>o?o:c)0?Math.ceil(h/s)-1:0,f=h>0?h-d*s-1:0,p=0,g=0;t&&i?t/i2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",r=this.config,s=r.pic_num,a=r.urls;if(!(s<=0)&&a&&0!==a.length){var l=this.getPosition(t,i,n);this.preload(l.urlIndex),Object.keys(l.style).map((function(t){e.style[t]=l.style[t]})),Object.keys(o).map((function(t){e.style[t]=o[t]}))}}},{key:"changeConfig",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.setConfig(e)}},{key:"createThumbnail",value:function(e,t){var i=Y.createDom("xg-thumbnail","",{},"thumbnail ".concat(t));return e&&e.appendChild(i),i}}],[{key:"pluginName",get:function(){return"thumbnail"}},{key:"defaultConfig",get:function(){return{isShow:!1,urls:[],pic_num:0,col:0,row:0,height:90,width:160,scale:1,className:"",hidePortrait:!1}}}]),i}();function no(e){return e?"background:".concat(e,";"):""}var oo=function(e){I(i,It);var t=R(i);function i(){var e;x(this,i);for(var n=arguments.length,o=new Array(n),r=0;r=0?t:i}},{key:"afterCreate",value:function(){var e=this;this.root&&(this.on(he,this.onTimeupdate),this.on(Ce,(function(){e.reset()})))}},{key:"reset",value:function(){this.update({played:0,cached:0},0)}},{key:"update",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{cached:0,played:0},t=arguments.length>1?arguments[1]:void 0;t&&this.root&&(e.cached&&(this.find("xg-mini-progress-cache").style.width="".concat(e.cached/t*100,"%")),e.played&&(this.find("xg-mini-progress-played").style.width="".concat(e.played/t*100,"%")))}},{key:"render",value:function(){var e=this.playerConfig,t=e.commonStyle;if(e.miniprogress){var i=this.config,n=i.mode,o=i.height,r={cached:no(t.cachedColor),played:no(t.playedColor),progress:no(t.progressColor),height:o>0&&2!==o?"height: ".concat(o,"px;"):""};return'\n \n \n ')}}}],[{key:"pluginName",get:function(){return"MiniProgress"}},{key:"defaultConfig",get:function(){return{mode:"auto",height:2}}}]),i}(),ro="realtime",so="firstframe",ao="poster";var lo=null,co=function(e){I(i,It);var t=R(i);function i(){var e;x(this,i);for(var n=arguments.length,o=new Array(n),r=0;r0)e.renderOnce(),e._frameCount--;else{e._isLoaded=!0,e.off(he,e.renderOnTimeupdate);var i=e.config.startInterval;!e.player.paused&&e._checkIfCanStart()&&e.start(0,i)}})),P(O(e),"start",(function(t,i){var n=e.player.video,o=function(){try{return parseInt(window.performance.now(),10)}catch(e){return(new Date).getTime()}}(),r=e.checkVideoIsSupport(n);r&&e.canvasCtx&&(i||(i=e.interval),e.stop(),n.videoWidth&&n.videoHeight&&(e.videoPI=n.videoHeight>0?parseInt(n.videoWidth/n.videoHeight*100,10):0,(e.config.mode===ro||o-e.preTime>=i)&&(n&&n.videoWidth&&e.update(r,e.videoPI),e.preTime=o)),e.frameId="timer"===e._loopType?Y.setTimeout(O(e),e.start,i):Y.requestAnimationFrame(e.start))})),P(O(e),"stop",(function(){e.frameId&&("timer"===e._loopType?Y.clearTimeout(O(e),e.frameId):Y.cancelAnimationFrame(e.frameId),e.frameId=null)})),e}return E(i,[{key:"afterCreate",value:function(){var e=this;!0===this.playerConfig.dynamicBg&&(this.config.disable=!1),i.isSupport||(this.config.disable=!0);var t=this.config,n=t.disable,o=t.mode,r=t.frameRate;n||(this._pos={width:0,height:0,rwidth:0,rheight:0,x:0,y:0,pi:0},this.isStart=!1,this._isLoaded=!1,this.videoPI=0,this.preTime=0,this.interval=parseInt(1e3/r,10),this.canvas=null,this.canvasCtx=null,this._frameCount=0,this._loopType=this.config.mode!==ro&&this.interval>=1e3?"timer":"animation",this.once(Ee,(function(){e.player&&(e.init(),e.renderByPoster(),e.player.paused||e.start())})),o!==ao&&(o!==so&&(this.on(Ce,(function(){e.stop()})),this.on(oe,(function(){var t=e.config.startInterval;e._checkIfCanStart()&&e.start(0,t)})),this.on(ae,(function(){e.stop()}))),this.on(ve,this.onLoadedData),this.on(ke,(function(){e._isLoaded=!1,e.stop()})),document.addEventListener("visibilitychange",this.onVisibilitychange)))}},{key:"setConfig",value:function(e){var t=this;Object.keys(e).forEach((function(i){"root"===i&&e[i]!==t.config[i]?t.reRender(e[i]):"frameRate"===i?t.interval=parseInt(1e3/e[i],10):"disable"===i&&e[i]&&t.stop(),t.config[i]=e[i]}))}},{key:"init",value:function(e){var t=this.player,n=this.config;this.canvasFilter=i.supportCanvasFilter();try{var o=e||n.root;o||(o=n.isInnerRender&&t.innerContainer||t.root),o.insertAdjacentHTML("afterbegin",'
\n
')),this.root=o.children[0],this.canvas=this.find("canvas"),this.canvasFilter||(this.canvas.style.filter=n.filter,this.canvas.style.webkitFilter=n.filter),this.mask=this.find("xgmask"),n.addMask&&(this.mask.style.background=n.maskBg),this.canvasCtx=this.canvas.getContext("2d")}catch(r){z.logError("plugin:DynamicBg",r)}}},{key:"reRender",value:function(e){if(this.config.disable||this.root){this.stop();var t=this.root?this.root.parentElement:null;if(t!==e&&t.removeChild(this.root),e){this.init(e),this.renderOnce();var i=this.config.startInterval;this._checkIfCanStart()&&this.start(0,i)}else this.root=null}}},{key:"checkVideoIsSupport",value:function(e){if(!e)return null;var t=e&&e instanceof window.HTMLVideoElement?e:e.canvas?e.canvas:e.flyVideo?e.flyVideo:null;if(t&&("safari"!==Q.browser||!Y.isMSE(t)))return t;var i=t?t.tagName.toLowerCase():"";return"canvas"===i||"img"===i?t:null}},{key:"renderByPoster",value:function(){var e=this.playerConfig.poster;if(e){var t="String"===Y.typeOf(e)?e:"String"===Y.typeOf(e.poster)?e.poster:null;this.updateImg(t)}}},{key:"_checkIfCanStart",value:function(){var e=this.config.mode;return this._isLoaded&&!this.player.paused&&e!==so&&e!==ao}},{key:"renderOnce",value:function(){var e=this.player.video;if(e.videoWidth&&e.videoHeight){this.videoPI=parseInt(e.videoWidth/e.videoHeight*100,10);var t=this.checkVideoIsSupport(e);t&&this.update(t,this.videoPI)}}},{key:"updateImg",value:function(e){var t=this;if(e){var i=this.canvas.getBoundingClientRect(),n=i.width,o=i.height,r=new window.Image;r.onload=function(){if(t.canvas&&!t.frameId&&!t.isStart){t.canvas.height=o,t.canvas.width=n;var e=parseInt(n/o*100,10);t.update(r,e),r=null}},r.src=e}}},{key:"update",value:function(e,t){if(this.canvas&&this.canvasCtx&&t)try{var i=this._pos,n=this.config,o=this.canvas.getBoundingClientRect(),r=o.width,s=o.height;if(r!==i.width||s!==i.height||i.pi!==t){var a=parseInt(r/s*100,10);i.pi=t,i.width!==r&&(i.width=this.canvas.width=r),i.height!==s&&(i.height=this.canvas.height=s);var l=s,c=r;at&&(l=parseInt(100*r/t,10)),i.rwidth=c*n.multiple,i.rheight=l*n.multiple,i.x=(r-i.rwidth)/2,i.y=(s-i.rheight)/2}this.canvasFilter&&(this.canvasCtx.filter=n.filter),this.canvasCtx.drawImage(e,i.x,i.y,i.rwidth,i.rheight)}catch(u){z.logError("plugin:DynamicBg",u)}}},{key:"destroy",value:function(){this.stop(),document.removeEventListener("visibilitychange",this.onVisibilitychange),this.canvasCtx=null,this.canvas=null}},{key:"render",value:function(){return""}}],[{key:"pluginName",get:function(){return"dynamicBg"}},{key:"defaultConfig",get:function(){return{isInnerRender:!1,disable:!0,index:-1,mode:"framerate",frameRate:10,filter:"blur(50px)",startFrameCount:2,startInterval:0,addMask:!0,multiple:1.2,maskBg:"rgba(0,0,0,0.7)"}}},{key:"isSupport",get:function(){return"boolean"==typeof lo?lo:lo=function(){try{return!!document.createElement("canvas").getContext}catch(e){return!1}}()}},{key:"supportCanvasFilter",value:function(){return!("safari"===Q.browser||"firefox"===Q.browser)}}]),i}(),uo="info",ho=$e,fo=function(e){I(i,mt);var t=R(i);function i(){var e;x(this,i);for(var n=arguments.length,o=new Array(n),r=0;rn.media.duration)){var h=u-l,d=h<=s;ht&&(0===r||n[r-1].end-t<=i)){o=r;break}}return o}},{key:"_getBuffered",value:function(e){if(!e)return[];for(var t=[],i=0;it.jumpCntMax||e.timer||!1===t.useWaitingTimeoutJump||(e.timer=setTimeout(e.onJump,1e3*t.waitingTime))})),P(O(e),"onJump",(function(){var t=O(e),i=t.player,n=t.config;if(clearTimeout(e.timer),e.timer=null,!(e.jumpCnt>n.jumpCntMax||!1===n.useWaitingTimeoutJump||i.media.paused&&0!==i.media.currentTime&&e.hasPlayed)){e.jumpSize=n.jumpSize*(e.jumpCnt+1),e.jumpCnt===n.jumpSize&&e.jumpSize<6&&(e.jumpSize=6);var o=i.currentTime+e.jumpSize;o>i.media.duration||(e.jumpCnt++,i.currentTime=o)}})),e}return E(i,[{key:"afterCreate",value:function(){var e=this,t=this.config,i=t.useWaitingTimeoutJump,n=t.jumpSize;!1!==i&&(this.hasPlayed=!1,this.jumpCnt=0,this.timer=null,this.jumpSize=n,this.on(de,this.onWaiting),this.on([re,fe],(function(){clearTimeout(e.timer),e.timer=null,e.jumpSize=e.config.jumpSize})),this.on(oe,(function(){e.hasPlayed=!0})))}}],[{key:"pluginName",get:function(){return"waitingTimeoutJump"}},{key:"defaultConfig",get:function(){return{useWaitingTimeoutJump:!1,waitingTime:15,jumpSize:2,jumpCntMax:4}}}]),i}(),vo="cdn",yo=["cdn"],mo=function(e){I(i,It);var t=R(i);function i(){var e;x(this,i);for(var n=arguments.length,o=new Array(n),r=0;r0&&void 0!==arguments[0]?arguments[0]:vo;if(!e.speedListCache||!e.speedListCache[t])return 0;if(e.speedListCache[t].length<=0)return 0;var i=0;return e.speedListCache[t].map((function(e){i+=e})),Math.floor(i/e.speedListCache[t].length)})),P(O(e),"startTimer",(function(){Y.isMSE(e.player.video)||(e.initSpeedList(),e.cnt=0,e.timer=setTimeout(e.testSpeed,e.config.testTimeStep))})),P(O(e),"initSpeedList",(function(){e.speedListCache={},yo.forEach((function(t){e.speedListCache[t]=[]}))})),P(O(e),"_onRealSpeedChange",(function(t){t.speed&&e.appendList(t.speed,t.type||vo)})),P(O(e),"testSpeed",(function(){if(clearTimeout(e.timer),e.timer=null,e.player&&e.config.openSpeed){var t=e.config,i=t.url,n=t.loadSize,o=t.testCnt,r=t.testTimeStep,s=i+(i.indexOf("?")<0?"?testst=":"&testst=")+Date.now();if(!(e.cnt>=o)){e.cnt++;try{var a=(new Date).getTime(),l=null,c=new XMLHttpRequest;e.xhr=c,c.open("GET",s);var u={},h=Math.floor(10*Math.random());u.Range="bytes="+h+"-"+(n+h),u&&Object.keys(u).forEach((function(e){c.setRequestHeader(e,u[e])})),c.onreadystatechange=function(){if(4===c.readyState){e.xhr=null,l=(new Date).getTime();var t=c.getResponseHeader("Content-Length")/1024*8,i=Math.round(1e3*t/(l-a));e.appendList(i),e.timer=setTimeout(e.testSpeed,r)}},c.send()}catch(d){}}}})),P(O(e),"appendList",(function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:vo;if(e.speedListCache&&e.speedListCache[i]){var n=e.config.saveSpeedMax;e.speedListCache[i].length>=n&&e.speedListCache[i].shift(),e.speedListCache[i].push(t);var o=O(e).player;o&&(i===vo?o.realTimeSpeed=t:o[e.getSpeedName("realTime",i)]=t),e.updateSpeed(i)}})),P(O(e),"updateSpeed",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:vo,i=e.getSpeed(t),n=O(e).player;if(n)if(t===vo)n.avgSpeed&&i===n.avgSpeed||(n.avgSpeed=i,n.emit(Ae,{speed:i,realTimeSpeed:n.realTimeSpeed}));else{var o=e.getSpeedName("avg",t);n[o]&&i===n[o]||(n[o]=i,n.emit(Ae,{speed:i,realTimeSpeed:n.realTimeSpeed}))}})),e}return E(i,[{key:"afterCreate",value:function(){var e=this.config,t=e.openSpeed,i=e.addSpeedTypeList;(null==i?void 0:i.length)>0&&yo.push.apply(yo,N(i)),this.initSpeedList(),this.on("real_time_speed",this._onRealSpeedChange),this.timer=null,this.cnt=0,this.xhr=null,t&&this.on([ve,Pe],this.startTimer)}},{key:"getSpeedName",value:function(e,t){return e+"Speed"+t.toUpperCase()}},{key:"openSpeed",get:function(){return this.config.openSpeed},set:function(e){if(this.config.openSpeed=e,!e&&this.timer)return clearTimeout(this.timer),void(this.timer=null);if(this.config.openSpeed){if(this.timer)return;this.timer=setTimeout(this.testSpeed,this.config.testTimeStep)}}},{key:"destroy",value:function(){var e=this;this.off("real_time_speed",this._onRealSpeedChange),this.off([ve,Pe],this.startTimer),yo.forEach((function(t){e.speedListCache&&e.speedListCache[t]&&(e.speedListCache[t]=[])})),this.speedListCache&&(this.speedListCache={}),clearTimeout(this.timer),this.timer=null,this.xhr&&4!==this.xhr.readyState&&(this.xhr.cancel&&this.xhr.cancel(),this.xhr=null)}}],[{key:"pluginName",get:function(){return"testspeed"}},{key:"defaultConfig",get:function(){return{openSpeed:!1,testCnt:3,loadSize:204800,testTimeStep:3e3,url:"",saveSpeedMax:5,addSpeedTypeList:[]}}}]),i}(),ko=function(e){I(i,It);var t=R(i);function i(){return x(this,i),t.apply(this,arguments)}return E(i,[{key:"afterCreate",value:function(){var e=this,t=this.player,i=this.config,n=t.media||t.video;(this.timer=null,this._lastDecodedFrames=0,this._currentStuckCount=0,this._lastCheckPoint=null,this._payload=[],i.disabled)||n.getVideoPlaybackQuality&&(this.on(oe,(function(){e._startTick()})),this.on(ae,(function(){e._stopTick()})),this.on(se,(function(){e._stopTick()})),this.on(Ce,(function(){e._stopTick()})))}},{key:"_startTick",value:function(){var e=this;this._stopTick(),this._timer=setTimeout((function(){e._checkDecodeFPS(),e._startTick()}),this.config.tick)}},{key:"_stopTick",value:function(){clearTimeout(this._timer),this._timer=null}},{key:"_checkBuffer",value:function(e,t){for(var i=!1,n=[],o=0;o=this.config.stuckCount&&(this.emit(Qe,this._payload),this._reset())):this._reset())}}},{key:"_reset",value:function(){this._payload=[],this._currentStuckCount=0}},{key:"_checkDecodeFPS",value:function(){var e=this.player.media||this.player.video;if(e){var t=e.getVideoPlaybackQuality(),i=t.totalVideoFrames,n=t.droppedVideoFrames,o=performance.now();if(i&&this._lastCheckPoint){var r=i-this._lastDecodedFrames,s=o-this._lastCheckPoint;this._checkStuck(r,i,n,s)}this._lastDecodedFrames=i,this._lastCheckPoint=o}}},{key:"destroy",value:function(){this._stopTick()}}],[{key:"pluginName",get:function(){return"FpsDetect"}},{key:"defaultConfig",get:function(){return{disabled:!1,tick:1e3,stuckCount:3,reportFrame:0}}}]),i}();Ut.use({LANG:"zh-cn",TEXT:{ERROR_TYPES:{network:{code:1,msg:"视频下载错误"},mse:{code:2,msg:"流追加错误"},parse:{code:3,msg:"解析错误"},format:{code:4,msg:"格式错误"},decoder:{code:5,msg:"解码错误"},runtime:{code:6,msg:"语法错误"},timeout:{code:7,msg:"播放超时"},other:{code:8,msg:"其他错误"}},HAVE_NOTHING:"没有关于音频/视频是否就绪的信息",HAVE_METADATA:"音频/视频的元数据已就绪",HAVE_CURRENT_DATA:"关于当前播放位置的数据是可用的,但没有足够的数据来播放下一帧/毫秒",HAVE_FUTURE_DATA:"当前及至少下一帧的数据是可用的",HAVE_ENOUGH_DATA:"可用数据足以开始播放",NETWORK_EMPTY:"音频/视频尚未初始化",NETWORK_IDLE:"音频/视频是活动的且已选取资源,但并未使用网络",NETWORK_LOADING:"浏览器正在下载数据",NETWORK_NO_SOURCE:"未找到音频/视频来源",MEDIA_ERR_ABORTED:"取回过程被用户中止",MEDIA_ERR_NETWORK:"网络错误",MEDIA_ERR_DECODE:"解码错误",MEDIA_ERR_SRC_NOT_SUPPORTED:"不支持的音频/视频格式",REPLAY:"重播",ERROR:"网络连接似乎出现了问题",PLAY_TIPS:"播放",PAUSE_TIPS:"暂停",PLAYNEXT_TIPS:"下一集",DOWNLOAD_TIPS:"下载",ROTATE_TIPS:"旋转",RELOAD_TIPS:"重新载入",FULLSCREEN_TIPS:"进入全屏",EXITFULLSCREEN_TIPS:"退出全屏",CSSFULLSCREEN_TIPS:"进入样式全屏",EXITCSSFULLSCREEN_TIPS:"退出样式全屏",TEXTTRACK:"字幕",PIP:"画中画",SCREENSHOT:"截图",LIVE:"正在直播",OFF:"关闭",OPEN:"开启",MINI_DRAG:"点击按住可拖动视频",MINISCREEN:"小屏幕",REFRESH_TIPS:"请试试",REFRESH:"刷新",FORWARD:"快进中",LIVE_TIP:"直播"}});var Co=E((function e(t,i){var n,o,r;x(this,e);var s=i&&"mobile"===i.isMobileSimulateMode,a=i.isLive,l=[].concat(a?[]:[yn,ln,oo,to,vn],[un,gn,wn,An,Gn,zn,Mn,Nn,_n,In]),c=[fi,pi,ki,on,Ci,qn,Zn,io,Di];this.plugins=[fo,hi].concat(N(l),c,[po,go]);var u=s?"mobile":Q.device;switch(u){case"pc":(n=this.plugins).push.apply(n,[tn,Ni,Xn,mo,ko]);break;case"mobile":(o=this.plugins).push.apply(o,[Qi]);break;default:(r=this.plugins).push.apply(r,[tn,Ni,Xn])}(Q.os.isIpad||"pc"===u)&&this.plugins.push(co),Q.os.isIpad&&this.plugins.push(Ni),this.ignores=[],this.i18n=[]})),_o=function(e){I(i,ii);var t=R(i);function i(){return x(this,i),t.apply(this,arguments)}return E(i)}();P(_o,"defaultPreset",Co),P(_o,"Util",Y),P(_o,"Sniffer",Q),P(_o,"Errors",ne),P(_o,"Events",et),P(_o,"Plugin",It),P(_o,"BasePlugin",mt),P(_o,"I18N",Ut),P(_o,"STATE_CLASS",Dt),P(_o,"InstManager",Jt);const bo=i({__name:"VideoPlayer",props:{url:{type:String,default:"",required:!0},poster:{type:String,default:""}},setup(e,{expose:t}){const i=e,h=n(),d=n();return o((()=>{a(d)&&new _o({autoplay:!1,...i,el:a(d)})})),r((()=>i),(async e=>{var t;await s(),e&&(null==(t=a(h))||t.setConfig(e))}),{deep:!0}),l((()=>{var e;null==(e=a(h))||e.destroy()})),t({playerExpose:()=>a(h)}),(e,t)=>(c(),u("div",{ref_key:"videoEl",ref:d},null,512))}}),wo=i({__name:"VideoPlayerViewer",props:{show:{type:Boolean,default:!1},url:{type:String,default:"",required:!0},poster:{type:String,default:""},id:{type:String,default:""}},setup(e){const t=e,i=n(t.show),o=async()=>{i.value=!1,await s();const e=document.getElementById(t.id);e&&document.body.removeChild(e)};return(t,n)=>h((c(),f(a(m),{onClick:o},{default:p((()=>[g("div",{class:"w-full h-full flex justify-center items-center relative",onClick:o},[g("div",{class:"w-44px h-44px color-[#fff] bg-[var(--el-text-color-regular)] rounded-full border-[#fff] flex justify-center items-center cursor-pointer absolute top-40px right-40px",onClick:o},[v(a(y),{icon:"ep:close",size:24})]),v(a(bo),{url:e.url,poster:e.poster},null,8,["url","poster"])])])),_:1},512)),[[d,i.value]])}});let To=null;function xo(e){if(!k)return;const{url:t,poster:i}=e,n={},o=document.createElement("div"),r=C();o.id=r,n.url=t,n.poster=i,n.show=!0,n.id=r,document.body.appendChild(o),To=v(wo,n),_(To,o)}export{bo as _,xo as c};