2 lines
206 KiB
Plaintext
2 lines
206 KiB
Plaintext
/*! For license information please see player-12.27bdc997.js.LICENSE.txt */
|
||
"use strict";!function(e,t){"object"==typeof module&&"object"==typeof module.exports?t():"function"==typeof define&&define.amd?define([],t):(e="undefined"!=typeof globalThis?globalThis:e||self)&&t()}(this,function(){"use strict";"object"==typeof window&&(window.openRedirect={version:"1.2.20",webpackPluginVersion:"3.4.22",reportOnly:!1})}),!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).xss={})}(this,function(e){"use strict";var t=function(){return(t=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function r(e,t,r){if(r||2==arguments.length)for(var n,i=0,a=t.length;i<a;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}var n=/[^a-zA-Z0-9\\_:.-]/gim,i=/</g,a=/>/g,o=/&#([a-zA-Z0-9]*);?/gim,s=/"/g,l=/:?/gim,u=/&newline;?/gim,c=/((j\s*a\s*v\s*a|v\s*b|l\s*i\s*v\s*e)\s*s\s*c\s*r\s*i\s*p\s*t\s*|m\s*o\s*c\s*h\s*a):/gi,d=/u\s*r\s*l\s*\(.*/gi,f=/e\s*x\s*p\s*r\s*e\s*s\s*s\s*i\s*o\s*n\s*\(.*/gi,h=/"/g,p=function(e){return e.replace(i,"<").replace(a,">")},g={indexOf:function(e,t){var r,n;for(r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return -1},forEach:function(e,t,r){var n,i;for(n=0,i=e.length;n<i;n++)t.call(r,e[n],n,e)},some:function(e,t,r){var n,i;for(n=0,i=e.length;n<i;n++)if(t.call(r,e[n],n,e))return!0;return!1},trim:function(e){return e.replace(/(^\s*)|(\s*$)/g,"")},includes:function(e,t){if("string"==typeof e)return -1!==e.indexOf(t);for(var r=0;r<e.length;r++)if(e[r]===t)return!0;return!1},spaceIndex:function(e){var t=/\s|\n|\t/.exec(e);return t?t.index:-1},uniq:function(e){for(var t={},r=[],n=0;n<e.length;n++)t[e[n]]||(r.push(e[n]),t[e[n]]=!0);return r},from:function(e){for(var t=[],r=0;r<e.length;r++)t.push(e[r]);return t},keys:function(e){var t=[];for(var r in e)t.push(r);return t}};function v(e){return null==e}function m(e){var t;return'"'===(t=e)[0]&&'"'===t[t.length-1]||"'"===t[0]&&"'"===t[t.length-1]?e.substr(1,e.length-2):e}function y(e){var t,r,n,i,a,o,s,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",u="",c=0;for(e=function(e){e=e.replace(/rn/g,"n");for(var t="",r=0;r<e.length;r++){var n=e.charCodeAt(r);n<128?t+=String.fromCharCode(n):n>127&&n<2048?t+=String.fromCharCode(n>>6|192)+String.fromCharCode(63&n|128):t+=String.fromCharCode(n>>12|224)+String.fromCharCode(n>>6&63|128)+String.fromCharCode(63&n|128)}return t}(e);c<e.length;)i=(t=e.charCodeAt(c++))>>2,a=(3&t)<<4|(r=e.charCodeAt(c++))>>4,o=(15&r)<<2|(n=e.charCodeAt(c++))>>6,s=63&n,isNaN(r)?o=s=64:isNaN(n)&&(s=64),u=u+l.charAt(i)+l.charAt(a)+l.charAt(o)+l.charAt(s);return u}function _(e){var t,r,n,i,a,o,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="",u=0;for(e=e.replace(/[^A-Za-z0-9+/=]/g,"");u<e.length;)t=s.indexOf(e.charAt(u++))<<2|(i=s.indexOf(e.charAt(u++)))>>4,r=(15&i)<<4|(a=s.indexOf(e.charAt(u++)))>>2,n=(3&a)<<6|(o=s.indexOf(e.charAt(u++))),l+=String.fromCharCode(t),64!==a&&(l+=String.fromCharCode(r)),64!==o&&(l+=String.fromCharCode(n));return function(e){for(var t="",r=0,n=0,i=0,a=0;r<e.length;)(n=e.charCodeAt(r))<128?(t+=String.fromCharCode(n),r++):n>191&&n<224?(t+=String.fromCharCode((31&n)<<6|63&(a=e.charCodeAt(r+1))),r+=2):(a=e.charCodeAt(r+1),t+=String.fromCharCode((15&n)<<12|(63&a)<<6|63&(i=e.charCodeAt(r+2))),r+=3);return t}(l)}function T(e,t,r){var n="",i=0,a=!1,o=!1,s=0,l=e.length,u="",c="";e:for(s=0;s<l;s++){var d=e.charAt(s);if(!1===a){if("<"===d){a=s;continue}}else if(!1===o){if("<"===d){n+=r(e.slice(i,s)),a=s,i=s;continue}if(">"===d||s===l-1){n+=r(e.slice(i,a)),u=function(e){var t,r=g.spaceIndex(e);return t=-1===r?e.slice(1,-1):e.slice(1,r+1),"/"===(t=g.trim(t).toLowerCase()).slice(0,1)&&(t=t.slice(1)),"/"===t.slice(-1)&&(t=t.slice(0,-1)),t}(c=e.slice(a,s+1)),n+=t(a,n.length,u,c,"</"===c.slice(0,2)),i=s+1,a=!1;continue}if('"'===d||"'"===d)for(var f=1,h=e.charAt(s-f);""===h.trim()||"="===h;){if("="===h){o=d;continue e}h=e.charAt(s-++f)}}else if(d===o){o=!1;continue}}return i<l&&(n+=r(e.substr(i))),n}function b(e,t){var r=0,i=0,a=[],o=!1,s=e.length;function l(e,r){if(!((e=(e=g.trim(e)).replace(n,"").toLowerCase()).length<1)){var i=t(e,r||"");i&&a.push(i)}}for(var u=0;u<s;u++){var c=e.charAt(u),d=void 0;if(!1!==o||"="!==c){if(!1===o||u!==i){if(/\s|\n|\t/.test(c)){if(e=e.replace(/\s|\n|\t/g," "),!1===o){if(-1===(d=function(e,t){for(;t<e.length;t++){var r=e[t];if(" "!==r)return"="===r?t:-1}return -1}(e,u))){l(g.trim(e.slice(r,u))),o=!1,r=u+1;continue}u=d-1;continue}if(-1===(d=function(e,t){for(;t>0;t--){var r=e[t];if(" "!==r)return"="===r?t:-1}return -1}(e,u-1))){l(o,m(g.trim(e.slice(r,u)))),o=!1,r=u+1;continue}}}else{if(-1===(d=e.indexOf(c,u+1)))break;l(o,g.trim(e.slice(i+1,d))),o=!1,r=(u=d)+1}}else o=e.slice(r,u),r=u+1,i='"'===e.charAt(r)||"'"===e.charAt(r)?r:function(e,t){for(;t<e.length;t++){var r=e[t];if(" "!==r)return"'"===r||'"'===r?t:-1}return -1}(e,u+1)}return r<e.length&&(!1===o?l(e.slice(r)):l(o,m(g.trim(e.slice(r))))),g.trim(a.join(" "))}function E(e,t,r){if(r=function(e){return e=function(e){for(var t="",r=0,n=e.length;r<n;r++)t+=32>e.charCodeAt(r)?" ":e.charAt(r);return g.trim(t)}(e=(e=(e=e.replace(s,'"')).replace(o,function(e,t){return"x"===t[0]||"X"===t[0]?String.fromCharCode(parseInt(t.substr(1),16)):String.fromCharCode(parseInt(t,10))})).replace(l,":").replace(u," "))}(r),"href"===t||"src"===t){if("#"===(r=g.trim(r)))return"#";if("http://"!==r.substr(0,7)&&"https://"!==r.substr(0,8)&&"mailto:"!==r.substr(0,7)&&"tel:"!==r.substr(0,4)&&"data:image/"!==r.substr(0,11)&&"ftp://"!==r.substr(0,6)&&"./"!==r.substr(0,2)&&"../"!==r.substr(0,3)&&"#"!==r[0]&&"/"!==r[0])return""}else if("background"===t){if(c.lastIndex=0,c.test(r))return""}else if("style"===t&&(f.lastIndex=0,f.test(r)||(d.lastIndex=0,d.test(r)&&(c.lastIndex=0,c.test(r)))))return"";return r=function(e){return e=p(e=e.replace(h,"""))}(r)}var S=function(e){return"string"==typeof e?e.replace(/'/g,'"').replace('=""',"").replace(/\s+/g,"").toLowerCase():""},k=function(){function e(e){var t=function(e){var t={};for(var r in e)t[r]=e[r];return t}(e||{});t.stripIgnoreTag&&(t.onIgnoreTag,t.onIgnoreTag=function(){return""}),t.whiteList={},t.onTag=function(){},t.onTagAttr=function(){},t.onIgnoreTag=function(){},t.onIgnoreTagAttr=function(){},t.safeAttrValue=E,t.escapeHtml=p,this.options=Object.assign(t,e)}return e.prototype.process=function(e){if(!(e=(e=e||"").toString()))return"";var t,r,n,i,a,o,s=this.options,l=s.whiteList,u=s.onTag,c=s.onIgnoreTag,d=s.onTagAttr,f=s.onIgnoreTagAttr,h=s.safeAttrValue,p=s.escapeHtml;s.stripBlankChar&&(e=(t=(t=e.split("")).filter(function(e){var t=e.charCodeAt(0);return!(127===t||t<=31&&10!==t&&13!==t)})).join("")),s.allowCommentTag||(e=function(e){for(var t="",r=0;r<e.length;){var n=e.indexOf("\x3c!--",r);if(-1===n){t+=e.slice(r);break}t+=e.slice(r,n);var i=e.indexOf("--\x3e",n);if(-1===i)break;r=i+3}return t}(e));var v=!1;s.stripIgnoreTagBody&&(r=s.stripIgnoreTagBody,"function"!=typeof(n=c)&&(n=function(){}),i=!Array.isArray(r),a=[],o=!1,c=(v={onIgnoreTag:function(e,t,s){var l;if(l=e,i||-1!==g.indexOf(r,l)){if(s.isClosing){var u="[/removed]",c=s.position+u.length;return a.push([!1!==o?o:s.position,c]),o=!1,u}return o||(o=s.position),"[removed]"}return n(e,t,s)},remove:function(e){var t="",r=0;return g.forEach(a,function(n){t+=e.slice(r,n[0]),r=n[1]}),t+=e.slice(r)}}).onIgnoreTag);var m=T(e,function(e,t,r,n,i){var a={sourcePosition:e,position:t,isClosing:i,isWhite:Object.prototype.hasOwnProperty.call(l,r)},o=u(r,n,a);if(null!=o)return o;if(a.isWhite){if(a.isClosing)return"</".concat(r,">");var s=function(e){var t=g.spaceIndex(e);if(-1===t)return{html:"",closing:"/"===e[e.length-2]};var r="/"===(e=g.trim(e.slice(t+1,-1)))[e.length-1];return r&&(e=g.trim(e.slice(0,-1))),{html:e,closing:r}}(n),v=l[r],m=b(s.html,function(e,t){var n=-1!==g.indexOf(v,e),i=d(r,e,t,n);return null==i?n?(t=h(r,e,t,null))?"".concat(e,'="').concat(t,'"'):e:null==(i=f(r,e,t,n))?void 0:i:i});return n="<".concat(r),m&&(n+=" ".concat(m)),s.closing&&(n+=" /"),n+=">"}return null==(o=c(r,n,a))?p(n):o},p);return v&&(m=v.remove(m)),m},e}(),R=Function("\nvar _checkXSS = function (it) {\n return it && it.Math == Math && it;\n};\nreturn _checkXSS(typeof globalThis === 'object' && globalThis) ||\n_checkXSS(typeof window === 'object' && window) ||\n_checkXSS(typeof self === 'object' && self) ||\n_checkXSS(typeof global === 'object' && global) ||\nFunction('return this')();\n")(),x=new(function(){function e(){var e=this;this.batchData=[],this.uniqKeys=new Set,this.timeout=2e3,this.lock=!1,this.getSlardarBid=function(){var t,r,n="douyin_web";if(!g.includes(n,"bid"))return n;if(e.config&&e.config.bid)return e.config.bid;if(R&&R._xssBid)return R._xssBid;if(R&&R.slardar&&"function"==typeof R.slardar.config){var i=(R.slardar.config()||{}).bid;if(i)return i}if(R&&R.Slardar&&"function"==typeof R.Slardar.config){var a=(R.Slardar.config()||{}).bid;if(a)return a}return(null===(r=null===(t=null==R?void 0:R.Slardar)||void 0===t?void 0:t._baseParams)||void 0===r?void 0:r.bid)||"argus"},this.getConfigRegion=function(){var t;return g.includes("cn","region")?e.config&&e.config.region?e.config.region:((null===(t=null==R?void 0:R.gfdatav1)||void 0===t?void 0:t.region)||"cn").toLowerCase():"cn"},this.gerReportUrl=function(){var t={cn:_("aHR0cHM6Ly9tb24uemlqaWVhcGkuY29tL21vbml0b3JfYnJvd3Nlci9jb2xsZWN0L2JhdGNoL3NlY3VyaXR5Lz9iaWQ9"),boe:_("aHR0cHM6Ly9tb24uemlqaWVhcGkuY29tL21vbml0b3JfYnJvd3Nlci9jb2xsZWN0L2JhdGNoL3NlY3VyaXR5Lz9iaWQ9"),ttp:_("aHR0cHM6Ly9tb24udXMudGlrdG9rdi5jb20vbW9uaXRvcl9icm93c2VyL2NvbGxlY3QvYmF0Y2gvc2VjdXJpdHkvP2JpZD0="),va:_("aHR0cHM6Ly9tb24tdmEuYnl0ZW92ZXJzZWEuY29tL21vbml0b3JfYnJvd3Nlci9jb2xsZWN0L2JhdGNoL3NlY3VyaXR5Lz9iaWQ9"),maliva:_("aHR0cHM6Ly9tb24tdmEuYnl0ZW92ZXJzZWEuY29tL21vbml0b3JfYnJvd3Nlci9jb2xsZWN0L2JhdGNoL3NlY3VyaXR5Lz9iaWQ9"),sg:_("aHR0cHM6Ly9tb24tdmEuYnl0ZW92ZXJzZWEuY29tL21vbml0b3JfYnJvd3Nlci9jb2xsZWN0L2JhdGNoL3NlY3VyaXR5Lz9iaWQ9"),boei18n:_("aHR0cHM6Ly9tb24tdmEuYnl0ZW92ZXJzZWEuY29tL21vbml0b3JfYnJvd3Nlci9jb2xsZWN0L2JhdGNoL3NlY3VyaXR5Lz9iaWQ9")}[e.getConfigRegion()];if(t)return t+e.getSlardarBid()}}return e.prototype.setConfig=function(e){this.config=e},e.prototype.upload=function(){var e=this,t=this.gerReportUrl();!this.lock&&t&&0!==this.batchData.length&&(this.lock=!0,setTimeout(function(){var r=e.batchData.slice(0,100);e.batchData=e.batchData.slice(100),R.fetch(t,{method:"post",body:JSON.stringify(r),headers:{"Content-Type":"application/json"}}).catch(function(e){}),e.lock=!1,e.upload()},this.timeout))},e.prototype.generateKey=function(e){return e.collectKey?[e.collectMode,e.collectKey].join("___"):""},e.prototype.push=function(e){this.batchData.push(e),this.upload()},e.prototype.report=function(e){var t=this.generateKey(e);if(R.fetch&&e.collectKey){var r="object"==typeof window?window.location.href:"SSR";e.documentUrl=r;var n={age:Math.floor(Date.now()),type:"xss",url:r,body:e,"user-agent":""};"enforce"===e.disposition&&"SSR"!==r||(n.url=t),"SSR"===r&&(n.url="SSR___".concat(n.url),n.body.ssr=!0),this.push(n)}},e}()),w=function(e){for(var t=0,r=function(r){Array.isArray(e[r])?0===e[r].length?delete e[r]:(e[r]=g.from(g.uniq(e[r])),t+=e[r].length):0===g.keys(e[r]).length?delete e[r]:g.keys(e[r]).forEach(function(n){e[r][n]=g.from(g.uniq(e[r][n])),t+=e[r][n].length})},n=0,i=g.keys(e);n<i.length;n++)r(i[n]);return{count:t,ret:e}};function L(e,t){return x.setConfig(t),new k(t).process(e)}function D(e){var t,r=(t=/\s|\n|\t/.exec(e))?t.index:-1;if(-1===r)return{html:"",closing:"/"===e[e.length-2]};var n="/"===(e=e.slice(r+1,-1).trim())[e.length-1];return n&&(e=e.slice(0,-1).trim()),{html:e,closing:n}}var C=function(e){return -1===(e=(e=(e=(e=e.replace(/:/gi,":")).replace(/&tab;/gi,"")).replace(/&newline;/gi,"")).replace(/(\t|\n|\r)/g,"")).indexOf("&#")?e.trim().toLowerCase():e.trim().replace(/&#(?:(x)([0-9a-f]+)|([0-9]+));?/gi,function(e,t,r,n){return String.fromCharCode(t?parseInt(r,16):parseInt(n))}).replace(/(\t|\n|\r)/g,"").toLowerCase()};function P(e,t){if(void 0===e&&(e=""),"string"!=typeof e)return!0;if(e=C(e),g.includes(e,"base64")&&!function(e){if(""===e||""===e.trim())return!0;try{return!g.includes(e,"data:text/html;base64")}catch(e){return!0}}(e))return t&&t("data:text/html;base64"),!1;var r=["expression(","behavior:","view-source:"];if(g.some(r,function(t){return -1!==e.indexOf(t)}))return g.forEach(r,function(r){-1!==e.indexOf(r)&&t&&t(r)}),!1;var n=["data:application","data:javascript","data:text/html","data:texthtml"];if(g.some(n,function(t){return -1!==e.indexOf(t)}))return g.forEach(n,function(r){-1!==e.indexOf(r)&&t&&t(r)}),!1;if(e.indexOf("javascript:")>0)return t&&t("javascript:"),!1;if(/^javascript:/i.test(e)){var i=e.slice(11).replace(/\s/g,"").trim();return!!g.some(["void","void(0)","void0","false","undefined",";"],function(e){return e===i})||(t&&t("javascript:"),!1)}return!0}var A=function(e,t){var r,n,i="<%= isSaveValidUrl =>";if("string"!=typeof e||(n=Number("<%= urlLimit =>"),void 0!==r&&(n=r),"NaN"!==e.toString()&&-1!==n&&e.length>=n)||P(e,t))return e;try{if(!0===(i=JSON.parse(i))||"true"===i){var a=new URL(e);return a.origin+a.pathname}}catch(e){}return"#"};function O(e,t,n){if(void 0===e&&(e=""),void 0===t&&(t=[]),"string"!=typeof e)return!0;if(!P(e=C(e)))return!1;var i,a={url:(i=e.match(/^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/)||[])[0],scheme:i[1],slash:i[2],host:i[3],port:i[4],path:i[5],query:i[6],hash:i[7]},o=a.scheme,s=a.host;return n?!!n(e):!(!o||!s)&&(!g.includes(["http","https","file"],o)||("object"==typeof window&&window&&(t=r(r([],t,!0),[location.host],!1)),g.some(t,function(e){return!!(e instanceof RegExp&&e.test(s))||e===s})))}var I={a:["target","title","spellcheck","rel"],canvas:[],abbr:["title"],address:[],area:["shape","coords","alt"],article:[],aside:[],audio:["autoplay","controls","loop","preload"],b:[],bdi:["dir"],bdo:["dir"],big:[],blockquote:["cite"],br:[],caption:[],center:[],cite:[],code:[],col:["align","valign","span","width"],colgroup:["align","valign","span","width"],dd:[],del:["datetime"],details:["open"],div:["dir"],dl:[],dt:[],em:[],font:["color","size","face"],footer:[],h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],header:[],hr:[],i:[],img:["alt","title","width","height","decoding"],ins:["datetime"],li:[],mark:[],nav:[],ol:["start"],p:[],pre:[],s:[],section:[],small:[],span:[],sub:[],sup:[],delete:[],form:[],strong:[],mask:["maskunits","x","y","width","height","fill"],table:["width","border","align","valign"],tbody:["align","valign"],td:["width","rowspan","colspan","align","valign"],tfoot:["align","valign"],th:["width","rowspan","colspan","align","valign"],thead:["align","valign"],tr:["rowspan","align","valign"],tt:[],u:[],ul:[],wbr:[],video:["autoplay","controls","loop","preload","height","width"],svg:["viewBox","version","xmlns","fill","width","height","stroke","stroke-width","style"],path:["d","fill","opacity","stroke","p-id","fill-rule","clip-rule","stroke-width","stroke-linecap","stroke-linejoin","fill-opacity","mask"],rect:["x","y","width","height","fill","stroke","rx"],g:[]},M={collect:null,initCollect:function(){this.collect={whiteList:{},filterProtocol:[]}},removeCollect:function(){var e=w(this.collect),t=e.count,r=e.ret;return this.collect=null,{collectKey:0===t?null:JSON.stringify(r),collectMode:"white"}},onIgnoreTagAttr:function(e,t,n){return e&&g.indexOf(["href","src"],t)>-1?M.domainWhiteList&&Array.isArray(M.domainWhiteList)&&M.domainWhiteList.length>0&&!O(n,r([],M.domainWhiteList,!0))?"":"".concat(t,'="').concat(A(n,function(e){var t;null===(t=M.collect)||void 0===t||t.filterProtocol.push(e)}),'"'):e&&(g.indexOf(["style","class","id"],t)>-1||t.indexOf("data-")>-1)?"".concat(t,'="').concat(n,'"'):(M.collect.whiteList[e]=M.collect.whiteList[e]||[],void M.collect.whiteList[e].push(t))},onIgnoreTag:function(e,t){if("style"===e)return t;T(t,function(e,t,r,n){b(D(n).html.replace("/",""),function(e){M.collect.whiteList[r]=M.collect.whiteList[r]||[],M.collect.whiteList[r].push(e)})},p)},whiteList:I,mergeWhiteList:function(e){for(var t,r={},n=0,i=g.keys(I);n<i.length;n++)r[t=i[n]]=g.from(I[t]);for(var a=0,o=g.keys(e);a<o.length;a++)r[t=o[a]]=t in I?I[t].concat(e[t]):g.from(e[t]);return r},setWhiteList:function(e){for(var t=0,r=g.keys(e);t<r.length;t++){var n=r[t];this.whiteList[n]=n in I?I[n].concat(e[n]):g.from(e[n])}}};try{var N={},B="merge";g.includes(B,"override")&&(M.whiteList=N.whiteList),g.includes(B,"merge")&&M.setWhiteList(N.whiteList)}catch(e){}var U=function(e,t){for(var r={},n=0,i=g.keys(e);n<i.length;n++){var a=i[n];Array.isArray(e[a])?r[a]=g.from(e[a]):r[a]=U({},e[a])}for(var o=0,s=g.keys(t);o<s.length;o++)(a=s[o])in e?Array.isArray(e[a])?r[a]=e[a].concat(t[a]):r[a]=U(e[a],t[a]):Array.isArray(t[a])?r[a]=g.from(t[a]):r[a]=U({},t[a]);return r},F={blackList:{a:["folder"],meta:["content"],iframe:["srcdoc"],input:["pattern"],vmlframe:["xmlns"]},blackTags:["script","xml","embed","isindex","object","base","set","handler","animate","payload","import"],blackAttrs:["charset","ns","namespace","formaction","xlink:href","xmlns:xlink","handler","repeat","repeat-start","repeat-end"],blackAttrRegExps:[/^on/],filterList:{param:["value"],video:["poster"],form:["action"]},filterAttrs:["href","src","background","style","dynsrc","lowsrc","content"]};try{var V={};V.blackAttrRegExps&&(V.blackAttrRegExps=V.blackAttrRegExps.map(function(e){return new RegExp(e.toString().slice(1,e.toString().length-1))}));var G="merge";g.includes(G,"override")&&(F=V),g.includes(G,"merge")&&(F=U(F,V))}catch(e){}var H={mode:"black",whiteList:{},blackConfig:F,collect:null,initCollect:function(){H.collect={blackList:{},blackTags:[],blackAttrs:[],blackAttrRegExps:[],filterAttrs:[],filterList:{},filterProtocol:[]}},removeCollect:function(){var e=w(H.collect),t=e.count,r=e.ret;return H.collect=null,{collectKey:0===t?null:JSON.stringify(r),collectMode:"black"}},onIgnoreTag:function(e,t){var r;if(!g.includes(F.blackTags,e))return T(t,function(e,t,r,n,i){if(-1!==r.indexOf("/"))return p(n);if(i)return"</".concat(r,">");var a=D(n),o=b(a.html,function(e,t){var n,i=0;if(F.blackList[r]&&g.includes(F.blackList[r],e)&&(H.collect.blackList[r]=H.collect.blackList[r]||[],H.collect.blackList[r].push(e),i++),F.blackAttrRegExps.length&&F.blackAttrRegExps.some(function(t){return t.test(e)})&&g.forEach(F.blackAttrRegExps,function(t){t.test(e)&&(H.collect.blackAttrRegExps.push("".concat(t.toString(),"->").concat(e)),i++)}),F.blackAttrs.length&&g.includes(F.blackAttrs,e)&&(F.blackAttrs.push(e),i++),!i){if(F.filterList&&F.filterList[r]&&g.includes(F.filterList[r],e)){var a=A(t,function(e){var t;null===(t=H.collect)||void 0===t||t.filterProtocol.push(e)});return a!==t&&(H.collect.filterList[r]=H.collect.filterList[r]||[],H.collect.filterList[r].push(e)),t?"".concat(e,"='").concat(a,"'"):e}return F.filterAttrs&&g.includes(F.filterAttrs,e)?((a=A(t,function(e){var t;null===(t=H.collect)||void 0===t||t.filterProtocol.push(e)}))!==t&&(null===(n=H.collect)||void 0===n||n.filterAttrs.push(e)),t?"".concat(e,"='").concat(a,"'"):e):t?"".concat(e,"='").concat(t,"'"):e}});return n="<".concat(r),o&&(n+=" ".concat(o)),a.closing&&(n+=" /"),n+=">"},p);null===(r=H.collect)||void 0===r||r.blackTags.push(e)}},j=function(e){var t=e.reportOnly,r=void 0===t||t,n=e.block;return r&&"all"===r?"report":("string"==typeof r&&("true"===r&&(r=!0),"false"===r&&(r=!1)),n?"enforce":r?"report":"enforce")},Z=function(e){return function(r,n,i){if(!r||"string"!=typeof r)return r;var a=n;e===L&&(a=M).initCollect();var o=e(r,a);if(S(o)===S(r))return r;if(!i)return o;var s=i.logType,l=j(i),u=a.removeCollect();return x.report(t(t({type:s,disposition:l},u),{sourceText:y(r),filterText:y(o)})),"enforce"===l?o:r}},Y=Z(function(e,t){return void 0===t&&(t={}),t&&t.whiteList||(t.whiteList={a:["target","href","title"],abbr:["title"],address:[],area:["shape","coords","href","alt"],article:[],aside:[],audio:["autoplay","controls","crossorigin","loop","muted","preload","src"],b:[],bdi:["dir"],bdo:["dir"],big:[],blockquote:["cite"],br:[],caption:[],center:[],cite:[],code:[],col:["align","valign","span","width"],colgroup:["align","valign","span","width"],dd:[],del:["datetime"],details:["open"],div:[],dl:[],dt:[],em:[],figcaption:[],figure:[],font:["color","size","face"],footer:[],h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],header:[],hr:[],i:[],img:["src","alt","title","width","height"],ins:["datetime"],li:[],mark:[],nav:[],ol:[],p:[],pre:[],s:[],section:[],small:[],span:[],sub:[],summary:[],sup:[],strong:[],strike:[],table:["width","border","align","valign"],tbody:["align","valign"],td:["width","rowspan","colspan","align","valign"],tfoot:["align","valign"],th:["width","rowspan","colspan","align","valign"],thead:["align","valign"],tr:["rowspan","align","valign"],tt:[],u:[],ul:[],video:["autoplay","controls","crossorigin","loop","muted","playsinline","poster","preload","src","height","width"]}),new k(t).process(e)}),W=Z(L),z=function(e,t,r){var n=[],i=A(e,function(e){n.push(e)});if(i===e)return e;n=g.from(g.uniq(n));var a=t||r||{};if(!a)return i;var o=a.logType,s=j(r);return x.report({type:o,disposition:s,collectKey:n.join("___"),collectData:JSON.stringify(n),collectMode:"black",sourceText:y(e),filterText:y(i)}),"enforce"===s?i:e},K=R._xssProject||{},q=R.xssNamespace||{},X="3.0.26",J={FilterXSS:k,version:X,webpackPluginVersion:"<%= webpackPluginVersion =>",reportOnly:"<%= reportOnly =>",filterXSS:Y,_filterXSS:W,filterUrl:z,Config:M,BlackConfig:H,project:K,setProjectName:function(e){K[e]=this,R._xssProjectName=e}};q.douyin_web=J,R.xssNamespace=q,R.Math&&!R.Math.xssNamespace&&(R.Math.xssNamespace=q),K[X]=J,R.globalThis=R,R.getFilterXss=function(){return void 0!==this._xssProjectName?this._xssProject[this._xssProjectName]:J},R.xss=J,R.isSafeUrl=O,R.isSafeDomain=O,R.isSafeProtocol=P,R._xssProject=K,R._xssProjectName&&(K[R._xssProjectName]=J);var Q=J.setProjectName.bind(J);e.BlackConfig=H,e.Config=M,e.FilterXSS=k,e._filterXSS=W,e.filterUrl=z,e.filterXSS=Y,e.isSafeDomain=O,e.isSafeProtocol=P,e.isSafeUrl=O,e.project=K,e.setProjectName=Q,e.setXssNamespace=function(e){var t=e.appId,r=e.bid,n=e.region;q[t]=J;M.bid=r,M.region=n,M.enabled=!0},e.xssNamespace=q,Object.defineProperty(e,"__esModule",{value:!0})}),(self.webpackChunkdouyin_web=self.webpackChunkdouyin_web||[]).push([["79122"],{167033:function(e,t,r){r.d(t,{L8:function(){return f},LM:function(){return g},LQ:function(){return S},P9:function(){return l},RB:function(){return w},_P:function(){return o},ab:function(){return x},cM:function(){return c},fC:function(){return E},je:function(){return d},kM:function(){return _},ky:function(){return v},lv:function(){return h},pv:function(){return b},qP:function(){return R},rg:function(){return u},uV:function(){return a},vR:function(){return p},xV:function(){return y},xp:function(){return L},xv:function(){return s},yc:function(){return T}});var n=r(726949);r(346984),r(705574),r(303846),r(802824),r(162093),r(497397),r(232070),r(918016),r(2885),r(248385),r(679308),r(374285),r(759943),r(414931),r(706056),r(240148),r(683656),r(228983),r(499222),r(663030);var i="undefined"!=typeof window&&window.location.href.indexOf("loggerdebug")>-1;function a(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=0,r=0;r<e.length;r++){var n=e[r].end,i=e[r].begin;if(!(Number.isNaN(Number(n))||Number.isNaN(Number(i)))&&!(i<0)&&!(n<0)&&!(n<i))t+=e[r].end-e[r].begin}return t=parseInt(1e3*t,10)}function o(e){if(null==e||""===e||"string"!=typeof e)return"";var t=e.split("/"),r="";return t.length>3&&t[2]&&(r=t[2]),r}function s(e){var t=new Date().getTime();try{e=parseInt(e)}catch(t){e=0}return t+=e,window.performance&&"function"==typeof window.performance.now&&(t+=window.performance.now()),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var r=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"===e?r:3&r|8).toString(16)})}function l(e){return function(t){return Object.prototype.toString.call(t)==="[object ".concat(e,"]")}}function u(e){var t={};if(e instanceof window.XMLHttpRequest)try{e.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(function(e){var r=e.split(": "),n=r.shift(),i=r.join(": ");t[n]=i})}catch(e){}return t}function c(e){for(var t,r=arguments.length,n=Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];i&&(t=console).log.apply(t,["[logger]",e].concat(n))}function d(){try{return Math.round(window.performance.now())}catch(e){return new Date().getTime()}}function f(){return new Date().getTime()}function h(e,t){var r={ext:e.ext||{},data:{}};return Object.keys(e).map(function(n){t[n]?r.data[t[n]]=e[n]:"ext"!==n&&(r.ext[n]=e[n])}),r}function p(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(r,n){try{!e&&n(Error("url is undefined"));var i=d(),a=i,o={},s=new window.XMLHttpRequest;s.open("get",e),s.onreadystatechange=function(){2===s.readyState&&(o.headers=u(s),o.connectTime=d()-a,o.status=s.status,o.statusText=s.statusText,i=d())},s.onload=function(){r(o)},s.onprogress=function(e){var t=d()-i,r=0;r=parseInt(e.loaded/1e3/(t/1e3),10),o.speed=0|r,o.costTime=t},s.onerror=function(){!o.status&&(o.status=-1,o.costTime=d()-i),n(o)},s.ontimeout=function(){!o.status&&(o.status=-2,o.costTime=d()-i),r(o)},s.onabort=function(){r(o)},s.responseType="arraybuffer",s.timeout=t.timeout||1e4,s.setRequestHeader("Range","bytes=".concat(t.range||"0-1048576")),s.send()}catch(e){n(e)}})}function g(e){return!!(!e||window.location.href.indexOf(e)>-1)||!1}function v(e){return!!e&&/^blob:/.test(e)}var m={x_response_sinfo:"x-response-sinfo",x_response_cache:"x-response-cache",x_response_cinfo:"x-response-cinfo"};function y(e){if(!e)return{};var t={};return Object.keys(m).map(function(r){if(e[r]||"string"!=typeof m[r]){if(!e[r]&&m[r]instanceof Array){var n=m[r].filter(function(t){return void 0!==e[t]});n.length>0?t[r]=e[n[0]]:t[r]=""}}else t[r]=e[m[r]]||""}),t}function _(e){return Object.prototype.toString.call(e).match(/([^\s.*]+)(?=]$)/g)[0]}function T(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return Object.keys(t).map(function(n){if("append"===r){var i,a;e[n]=(i=e[n],a=t[n],i?"string"==typeof a||"number"==typeof a?"".concat(i," ").concat(a):a:a)}else e[n]=t[n]}),e}function b(e,t){if(!e||!t)return!1;try{return Array.prototype.some.call(e.classList,function(e){return e===t})}catch(i){var r=e.className&&"object"===(0,n.Ac)(e.className)?e.getAttribute("class"):e.className;return r&&!!r.match(new RegExp("(\\s|^)".concat(t,"(\\s|$)")))}}function E(e){if("String"===_(e))return e.replace("P","p");if(!e)return"";if("Number"===_(e))return"".concat(e)}function S(e){try{return JSON.stringify(e)}catch(e){return""}}var k={UN_KNOW:0,EXPIRED:1,NO_EXPIRED:2};function R(e){if(!e||"String"!==_(e))return 0;var t=0;try{var r=RegExp("(\\?|&)x-tos-expires=([^&]*)(&|$)"),n=e.match(r);if(null!==n)t=parseInt(n[2],10);else{var i=e.split("/");i.length>5&&8===i[4].length&&(t=parseInt(i[4],16))}if(t>0){var a=parseInt(new Date().getTime()/1e3,10);return t<a?k.EXPIRED:k.NO_EXPIRED}return k.UN_KNOW}catch(e){return k.UN_KNOW}}function x(){return"undefined"==typeof document?0:"visible"===document.visibilityState?1:0}function w(e,t){return Math.round(t/e*1e5)}function L(){try{if("undefined"==typeof navigator||!navigator.plugins)return"";for(var e=[],t=navigator.plugins.length,r=["chromium","internal","native client","pdf"],n=0;n<t;n++)!function(){var t=navigator.plugins[n];if(t&&t.name){var i=t.name.trim().toLowerCase();!r.some(function(e){return i.includes(e)})&&-1===e.indexOf(i)&&e.push(i)}}();return e.length>0?JSON.stringify(e):""}catch(e){return""}}},515951:function(e,t,r){r.d(t,{Z:function(){return U}});var n=r(61072);r(346984),r(705574),r(941533),r(451236),r(303846),r(124300),r(802824),r(162093),r(9498),r(117232),r(503e3),r(497397),r(232070),r(932651),r(2885),r(248385),r(679308),r(88856),r(759943),r(414931),r(706056),r(591111),r(663030),r(490629);var i=r(659830),a=r(75740),o=r(924718),s=r(365791),l=r(317153),u=r(755290),c=r(734123),d=r(403826),f=r(938310),h=r(364812),p=r(403177),g=r(576005),v=r(631144),m=r(861504),y=r(392671),_=r(937049),T=r(614184),b=r(374260),E=r(588984),S=r(858985),k=r(107093),R=r(235154),x=r(718828),w=r(441226),L=r(144144),D="DESTROYED",C="xglog_cache",P="degrade",A={UPDATE_URL:"UPDATE_URL"},O=null,I=null,M=null,N=null,B=0,U=function(e){var t,r,u,p,U,F,V,G;function H(e){var t,r,o,s;return(0,n.PA)(this,H),r=(0,n.$w)(this,H,[e]),(0,n._x)(r,"_onChangeConfig",function(e){if(e){var t=e.nextBufferLength===r.config.minBufferLength;if(r.setConfig(e),e.nextBufferLength&&!t)try{r._onTimeUpdate()}catch(e){}}}),(0,n._x)(r,"fpsStuckHandle",function(e){var t=r.player,n=r.config,i=r.mse;if(!r.fpsStuckTime&&(r.fpsStuckTime=e.currentTime,r.log(d._.LOG,"fpsStuckHandle, currentTime,",e.currentTime)),i&&r.fpsStuckTime>0){var a=t.bufferedPoint;i.clearOpQueues(f.d1.VIDEO,!!n.enableMsePatches),r.log(d._.LOG,"fpsStuckHandle, remove: ".concat(a.start,"-").concat(a.end,","),"stuckTime: ".concat(r.fpsStuckTime)),i.remove(f.d1.VIDEO,a.start,a.end).then(function(){t.currentTime=r.fpsStuckTime,r.fpsStuckTime=null}),!r._firstMetFPSStuck&&(r._firstMetFPSStuck=!0,r.log(d._.LOG,"firstMetFPSStuck"),r.emit(C))}}),(0,n._x)(r,"_replayHook",function(e){}),(0,n._x)(r,"_retryHook",function(){var e=r.player,t=r.playerConfig,n=e.paused;r.softDecode?e.vtype=a.l0.MP4_MSE_SOFT:e.vtype=a.l0.MP4_MSE,r._defInited=!1,r._MSEError=!1,e.video.removeEventListener("loadedmetadata",r.__onmetadataHandle);var i=e.currentTime||0;r.log(d._.LOG,"retryHook ",t.vid,r.codecType,i);var o=function(){r.__onmetadataHandle=function(){i&&(e.currentTime=i,r.log(d._.LOG,"retryHook update currentTime",t.vid,r.codecType,i)),n?e.pause():e.play(),e.video.removeEventListener("loadedmetadata",r.__onmetadataHandle),r.__onmetadataHandle=null},e.video.addEventListener("loadedmetadata",r.__onmetadataHandle)};return!r.config.enableMsePatches&&o(),r._destroyMSE(),r._reset(),r.states=[],r.playerStartInit(t.url),r.config.enableMsePatches&&o(),!1}),(0,n._x)(r,"_playHook",function(e){r._usePaused=!1,r._cancelLoading=!1,r.log(d._.LOG,"playHook"),r._startProgress()}),(0,n._x)(r,"_pauseHook",function(e){var t;r._usePaused=!0;for(var n=arguments.length,i=Array(n>1?n-1:0),a=1;a<n;a++)i[a-1]=arguments[a];r.log(d._.LOG,"pauseHook",i[0],null===(t=r.player)||void 0===t?void 0:t.currentTime),0>i.indexOf(null===m.Im||void 0===m.Im?void 0:m.Im.BUFFER_CONTROLS)&&(clearTimeout(r.checkResumePlayTimer),r.checkResumePlayTimer=null,r.log(d._.LOG,"pause hook clear buffer_control state")),r._loadStuckCheck()}),(0,n._x)(r,"abrSwitchURL",(o=(0,n.x)((0,n.l5)().mark(function e(t){var i,a,o,s;return(0,n.l5)().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:i=r.playerConfig.definition.list,a=0,o=0;case 4:if(!(o<i.length)){e.next=11;break}if(t.definition!==i[o].definition){e.next=8;break}return a=o,e.abrupt("break",11);case 8:o++,e.next=4;break;case 11:s=r.player.curDefinition,r.changeDefinition(i[a],s,!0);case 13:case"end":return e.stop()}},e)})),function(e){return o.apply(this,arguments)})),(0,n._x)(r,"timerHandle",function(){r._requestTimer&&r._onTimeUpdate()}),(0,n._x)(r,"changeDefineCanPlay",function(e,t,n,i){var a,o=r.player,s=r._changeDefState?r._changeDefState.currentTime:e;if(r.needStarLoadFirstSegment=!0,o.changeDefinitionSeekState=1,r.log(d._.LOG,"changeDefineCanPlay seek changeBitrate point ".concat(s,", pause: ").concat(null===(a=r._changeDefState)||void 0===a?void 0:a.paused)),o.ended){o.currentTime=0;return}o.currentTime=s,r._changeDefState&&r._changeDefState.paused?o.pause():o.play(),r._changeDefState=null,o.emit(c.Events.AFTER_DEFINITION_CHANGE,{from:n,to:i})}),(0,n._x)(r,"changeDefinition",function(e,t,a){var o,s=r.player,l=r.playerConfig,u=r.mp4,h=r.config;if(!t&&(t=s.curDefinition),r._MSEError=!1,r.useVideoLoad){"__auto__"===e.url&&(e.url=s.config.definition.list[0].url),M.call(r.player,e,t);return}var p=s.definitionList.filter(function(t){return t.definition===e.definition});if(p.length>0&&(e=p[0]),r._handlerUrl(e.url),e._mainURL=h._mainURL,e._backupURL=h._backupURL,r._switchBitRateWay&&!a){r.oldChangeDefinition(e,t);return}var g="自动"===e.definition||"auto"===e.definition;if(a)r.log(d._.LOG,"[switchBitrate:ABR], ready to switch bitRate, ",e.bitrate,e.definition);else{var v=!1;if(g)null===(y=r._abrService)||void 0===y||y.updateCurrentHDRStatus(null===(T=t)||void 0===T?void 0:T.isHDR),null===(b=r._abrService)||void 0===b||b.enable(),v=!0;else{r._abrService&&r._abrService.disable();var m,y,T,b,E,S=null===(E=l.definition)||void 0===E?void 0:E.list;if(S&&(!e.bitrate||!e.uri||!e.size||!e.duration)){for(var R=0;R<S.length;R++)if(e.definition===S[R].definition){e.bitrate=S[R].bitrate,e.uri=S[R].uri||t.uri,e.size=S[R].size||k.Z.getFileSize(e.bitrate,l.duration),e.duration=S[R].duration||r.playerConfig.duration;break}}}null===(m=r.adaptRange)||void 0===m||m.updateBitrate(e.bitrate),s.oldBit=e.bitrate,s.emit(c.Events.DEFINITION_CHANGE,{from:t,to:e}),setTimeout(function(){r._abrService&&r._abrService.updateAutoDefiDesc(s.curDefinition.definition,!g)}),v&&(e=s.curDefinition),r.log(d._.LOG,"[switchBitrate:CBS],switch bitRate, ",e.bitrate,e.definition,s.currentTime)}if(s.curDefinition=e,r.mp4.clearPCDNNodeList(),r.checkPCDN(),!!u){["keyValue","kid","secretKey","drm","getLicenseUrl","drmKeyToken","sessionId"].forEach(function(t){h[t]=e[t]});var x=r.config,w=x.kid,L=x.drmKeyToken,D=x.secretKey,C=x.keyValue,P=x.drm,A=x.reuseSecretKey,O=null;if(w||L||D||C||P)r._secretkey?!A&&r._secretkey.updateConfig(r.config):(r._secretkey=new i.XGSecretKey(r.config),r._secretkey.on(i.EVENT_EME.ERROR,r._errorHandler)),(O=r._secretkey.getLicenseSecret()).then(function(){if(!!r.player&&!!r._secretkey){var e=r.player.video||r.player.media;r._secretkey.setOptions(),r._secretkey.setupEME(e)}});else{var I=Promise.withResolvers(),N=I.promise,B=I.resolve;O=N,B()}O.then((o=(0,n.x)((0,n.l5)().mark(function i(a){var o,c,p,g,v,m,y,_,T,b,E,S,k,R;return(0,n.l5)().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(null!=a&&a.secretKey&&(h.keyValue||(h.secretKey=a.secretKey),h.decryptKey=a.decryptKey),l.url=e.url,c=0,p=!1,g=s.getBufferedRange(),r._abrService&&r._abrService.isCurrentInAbr()?(v=Math.max(g[1],s.currentTime),c=r.getCurGopEndTime(v)):(c=r.getCurGopEndTime(),p=!0),!(c>=u.timeRange[u.timeRange.length-1].startTime)){n.next=9;break}return r.log(d._.LOG,"switch bitrate last segment, so return"),n.abrupt("return");case 9:if(m=null===(o=r._abrService)||void 0===o?void 0:o.isCurrentInAbr(),null==u||u.updateChangeBitRateTime(c),y=u.getFragmentIdx(c),!(g[1]<c)){n.next=16;break}u.fillGopData&&u.fillGopData(s.currentTime),n.next=20;break;case 16:return r.canDownload=!1,n.next=19,u.cancelLoading();case 19:u.metaLoading=!1;case 20:(_=r.getAdaptTimeRangeIdx(y))<0&&(_=r._curLoadSegmentIdx),r.log(d._.LOG,"switchBitrate point: ".concat(_),"currentTime: ".concat(s.currentTime,", timeStart: ").concat(c,", \n buffer: ").concat(g[0]," - ").concat(g[1])),p&&s.emit("definitionSwitchTime",u.adaptTimeRange[_].startTime+1),r._definitionChangePointInfo={changeStartTime:c,changeInfo:{from:t,to:e}},r._removeBuffEndTime=c,(T=s.getBufferedRange(s.buffered))[1]>0&&T[1]>c&&(!r._abrService||!m)&&(r.removeBuffer(f.d1.VIDEO,c,T[1]),r.log(d._.LOG,"switchBitrate: ready to remove buffer, ".concat(c," - ").concat(T[1]))),(b=u.getFragmentIdx(s.currentTime))>0&&(E=s.buffered.start(0),S=u.timeRange[b].startTime-1,r.removeBuffer(f.d1.VIDEO,E,S,function(){r.log(d._.LOG,"switchBitrate: remove old bitrate buffer end",JSON.stringify(s.getBufferedRange(s.buffered)))}),r.log(d._.LOG,"switchBitrate: ready to remove pre buffer, ".concat(E," - ").concat(S))),k=u.getAdaptIdxBySrcIdx(b)+1,r.log(d._.LOG,"switchBitrate: resetFragmentLoadState, ".concat(k,", changeBitRateIdx: ").concat(_)),u.resetFragmentLoadState(k),r._curLoadSegmentIdx=k,r.mp4.readyToChangeBitrate(e),r._setCurrentDefinition(e),r._emitDefinitionChangeDetailEvent(c),r.canDownload=!0,r._onTimeUpdate(),R={width:e.width||e.vwidth,height:e.height||e.vheight},s.emit("RESOLUTION_UPDATE",R);case 41:case"end":return n.stop()}},i)})),function(e){return o.apply(this,arguments)})).catch(function(t){r.log(d._.ERROR,"switchBitrate: GET_LICENSE_ERROR, ".concat(null==t?void 0:t.message));var n=new c.Errors(r.player,{errorType:_.iR.DRM,errorCode:_.O1.custom_drm,errorMessage:(null==t?void 0:t.message)||"GET_LICENSE_ERROR",vid:l.vid});t.errorType="GET_LICENSE_ERROR",r.emit("GET_LICENSE_ERROR",n),r.changeState("LICENSE_ERROR",{d:e.definition})})}}),(0,n._x)(r,"_onVideoError",function(e){var t,n,i=r.player;r.changeState("video_error",{code:e.code||(null==i||null===(t=i.video)||void 0===t||null===(t=t.error)||void 0===t?void 0:t.code),message:e.message||(null==i||null===(n=i.video)||void 0===n||null===(n=n.error)||void 0===n?void 0:n.message),videoType:r.useVideoLoad})}),(0,n._x)(r,"removeBuffer",function(e,t,n,i){var a,o=r.getBufferDur();null===(a=r.mse)||void 0===a||a.remove(e,t,n).then(function(){var e=r.player,t=o-r.getBufferDur();if(t>0){r.emit("removeBuffer",{removeDur:t});for(var n=[],a=0;a<e.buffered.length;a++)n.push([e.buffered.start(a),e.buffered.end(a)]);r.log(d._.LOG,"removeDur end,curBuffer:".concat(JSON.stringify(n),",\n currentTime:").concat(r.player.currentTime))}i&&i()})}),(0,n._x)(r,"_onPlaying",function(){r._waitAdjustTimeCnt>0&&r._waitInBufferTimer&&(r._waitAdjustTimeCnt-=1,r.log(d._.WARN,"[waitInBuffer resume play], waitAdjustTimeCnt,",r._waitAdjustTimeCnt)),clearTimeout(r._waitInBufferTimer),r._waitInBufferTimer=null;var e=r.mp4,t=r.player,n=r.config.resumePlayWaterLevel;if(!e){r.checkResumePlayTimer>0&&(clearTimeout(r.checkResumePlayTimer),r.checkResumePlayTimer=null,t.isBufferControlPaused&&(t.isBufferControlPaused=!1),t.paused&&t.play());return}if(e&&e.meta&&e.meta.duration-t.currentTime<=n)return;if(r.waitLevelStartTime<0&&(r.waitLevelStartTime=t.currentTime),!r.playFlag&&(r.playFlag=!0),void 0!==t.isBufferControlPaused&&!(n<=0)){if(n>0&&t.currentTime-r.waitLevelStartTime>=m.Ef){var i=t.getBufferedRange(t.buffered2);i[1]>0&&i[1]-t.currentTime<n?(!t.paused&&(r.emit(m.of,{type:m.a1.WAITING}),t.pause(null===m.Im||void 0===m.Im?void 0:m.Im.BUFFER_CONTROLS),r.log(d._.LOG,"[!!!!!buffer not rich, pause],currentTime, ",t.currentTime,", bufferEnd,",i[1])),clearTimeout(r.checkResumePlayTimer),r.checkResumePlayTimer=setTimeout(r._onPlaying,n/2*1e3)):t.isBufferControlPaused&&t.paused&&(r.log(d._.LOG,"[!!!!!buffer rich, play],, currentTime, ",t.currentTime,", bufferEnd,",i[1]),clearTimeout(r.checkResumePlayTimer),r.checkResumePlayTimer=null,t.isBufferControlPaused=!1,r.emit(m.of,{type:m.a1.PLAYING}),t.play())}}}),(0,n._x)(r,"_lowDecoder",function(){var e="function"==typeof r.player.video.getStats?r.player.video.getStats():null;r.log(d._.WARN,"H265 lowdecode: ".concat(r.playerConfig.vid," "),e,", h265Degrade, ",r.config.h265Degrade),r.config.h265Degrade&&r._onDegrade()}),(0,n._x)(r,"_onError",function(e){r._onDegrade(e)}),(0,n._x)(r,"_onDegrade",function(e){var t,n,i=r.player,o=r.playerConfig,s=r.config;i.video.removeEventListener("lowdecode",r._onDegrade),i.video.removeEventListener("error",r._onError),null===(t=r.mp4)||void 0===t||t.destroy();var l=i.currentTime;if(r.log(d._.WARN,"[h265 degrade], vid,",o.vid,",currtime,",l),r.emit(P,{errc:null==e?void 0:e.errorCode,err_msg:(null==e?void 0:e.errorMessage)||(null==e?void 0:e.message),CodecTypes:r.codecType,media_type:o.mediaType}),null!=s&&s.H264Config){var u=s.H264Config;["drm","getLicenseUrl","kid","keyValue","secretKey","isEncrypt","useEME"].forEach(function(e){s[e]=u[e]||null})}var c={mp4encryptplayer:s,mediaType:"video",codecType:a.u7.H264};if((null==o||null===(n=o.H264DefinitionList)||void 0===n?void 0:n.length)>0){var f=r._processArrayUrl(o.H264DefinitionList);o.H264DefinitionList=f,i.config.definition.list=f,i.config.url=f[0].url,i.config.defaultBitrate=o.H264DefinitionList[0].bitrate,i.config.defaultDefinition=o.H264DefinitionList[0].definition,r.isH265DegradeH264=!0,i.playNext(c),r.__onmetadataHandle=function(){i.currentTime=l,r.isH265DegradeH264=!1,r.log(d._.LOG,"H265DegradeH264 update currentTime",l),i.video.removeEventListener("loadedmetadata",r.__onmetadataHandle),r.__onmetadataHandle=null},i.video.addEventListener("loadedmetadata",r.__onmetadataHandle)}else i.pause(),r._reset(),r.states=[],r.checkReUseMSE(!1,s.enableMsePatches),r.log(d._.ERROR,"H265 error,degrade h264 but no h264 url"),r.emit("error",e)}),(0,n._x)(r,"_onMp4MetaReady",function(e,t){if(!t||t.hasDestroyed){r.log(d._.LOG,"Mp4MetaReady but return, ".concat(!!t,", ").concat(null==t?void 0:t.hasDestroyed));return}var n=r._checkMetaInfo(e);if(n){r._errorHandler(n);return}var i=e.videoCodec,a=e.audioCodec;r._mediaCodec.videoCodec=i,r._mediaCodec.audioCodec=a;try{r._initEME(e),r.softDecode?(r.log(d._.LOG,"initMseProxy"),r._initMseProxy()):r.player.video instanceof HTMLVideoElement&&(r.log(d._.LOG,"initMse"),r._initMse(e)),r._initPromise&&r._initPromise.resolve()}catch(e){r._errorHandler(new c.Errors(r.player,{errorType:_.iR.MEDIA,errorCode:_.O1.eme_hijack,errorMessage:(null==e?void 0:e.message)||"eme or mse catch err",vid:r.playerConfig.vid}));return}if(null!=t&&t.timeRange){var o=[];t.timeRange.every(function(e){return o.push({startTime:e.startTime,endTime:e.endTime}),!0}),r.emit("KEYFRAMETIME",o)}t===r.mp4&&r._loadData()}),(0,n._x)(r,"_onMp4Error",(s=(0,n.x)((0,n.l5)().mark(function e(t){return(0,n.l5)().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:r._errorHandler(t);case 1:case"end":return e.stop()}},e)})),function(e){return s.apply(this,arguments)})),(0,n._x)(r,"_onMp4Progress",function(e){r.emit("progress_event",e)}),(0,n._x)(r,"_onMp4DataCallBack",function(){r._isMseInit&&r._onTimeUpdate()}),(0,n._x)(r,"_updateDrmConfig",function(e){var t=r.config;r.mp4.updateSecretKey(t.useEME,t.secretKey,t.decryptKey,t.keyValue),r._secretkey&&e.kid&&r._secretkey.updateKid(e.kid)}),(0,n._x)(r,"_updateMSE",function(e){r.player.video instanceof HTMLVideoElement&&(r.log(d._.LOG,"updateMse",e.videoCodec),r._initMse(e))}),(0,n._x)(r,"_onVideoTimeUpdate",function(){var e,t,n,i=r.mse,a=r.player;r.waitLevelStartTime<0&&(r.waitLevelStartTime=a.currentTime),r.checkReStartTimer(),r._isEnded(),a.isSeeking&&(a.isSeeking=!1),!r.useVideoLoad&&i&&r._removeBuffEndTime>0&&a.currentTime>r._removeBuffEndTime+1&&(r.log(d._.LOG,"remove old bitrate buffer,0 - ".concat(r._removeBuffEndTime)),r.removeBuffer(f.d1.VIDEO,0,r._removeBuffEndTime-1),r._removeBuffEndTime=0),a.currentTime>=(null===(e=r._definitionChangePointInfo)||void 0===e?void 0:e.changeStartTime)&&(r.needStarLoadFirstSegment=!0,(0,R.u8)()&&(r.log(d._.LOG,"definitionChangePointInfo update\n changeDefinitionSeekState = 2\n ".concat(a.currentTime)),a.changeDefinitionSeekState=2)),r._definitionChangePointInfo&&a.currentTime>r._definitionChangePointInfo.changeStartTime&&(a.emit(c.Events.AFTER_DEFINITION_CHANGE,r._definitionChangePointInfo.changeInfo),r.log(d._.LOG,c.Events.AFTER_DEFINITION_CHANGE,", currentTime,",a.currentTime,",from ",null===(t=r._definitionChangePointInfo)||void 0===t||null===(t=t.changeInfo)||void 0===t||null===(t=t.from)||void 0===t?void 0:t.definition," to ",null===(n=r._definitionChangePointInfo)||void 0===n||null===(n=n.changeInfo)||void 0===n||null===(n=n.to)||void 0===n?void 0:n.definition),r._definitionChangePointInfo=null),!r.useVideoLoad&&null===r._requestTimer&&(r._offineLine||r._cancelLoading||r._startProgress()),r._lastBufferPoint=a.bufferedPoint}),(0,n._x)(r,"_onBufferedReset",function(){r.mp4&&r.mp4.videoTrak&&r.mp4.resetFragmentLoadState(0)}),(0,n._x)(r,"_onOnlineHandler",function(){r._offineLine=!1;var e=r.playerConfig,t=r.player,n=t.currentTime,i=t.paused;r.log(d._.LOG,"online useVideoLoad:",r.useVideoLoad,r._hasStartProgressBack),r.useVideoLoad?(r.__onmetadataHandle=function(){n&&(t.currentTime=n),r.log(d._.LOG,"onOnlineHandler update currentTime",e.vid,r.codecType,r._currentTime),i?t.pause():t.play(),t.video.removeEventListener("loadedmetadata",r.__onmetadataHandle),r.__onmetadataHandle=null},t.video.addEventListener("loadedmetadata",r.__onmetadataHandle),r._setPlayerSrc(e.url)):(r._hasStartProgressBack&&r._startProgress(),r._hasStartProgressBack=!1)}),(0,n._x)(r,"_onOfflineHandler",function(){r._offineLine=!0,r.log(d._.LOG,"offline, ",r._hasStartProgress),r._hasStartProgress&&(r._stopProgress(),r._hasStartProgressBack=!0)}),(0,n._x)(r,"_loadDataSuccess",function(e){if(!r.isDestroy&&(!!r.mse||!!r.mseProxy)){try{e.initSeg&&(r._appendInitSeg(e.initSeg),(!e.buffer||e.buffer.byteLength<1)&&r._onTimeUpdate());var t=e.buffer,i=e.state,a=e.context,o=e.videoTrack,s=e.audioTrack;try{var l=r.mp4.cachePreloadData(e),u=l.needCache,h=l.preloadData;if(u){var p=r.player.preloader;if(p){var g=r.player.curDefinition,v=r._getPreloadMeta(g);h.codecType=r.codecType,h.definition=g.definition;var m=p.getDataUniqueKey(v);h.cacheKey=m,p.getItem(v,!0).then(function(e){p.setItem(v,Object.assign({},e||{},(0,n._x)({},m,h)),!0)})}}}catch(e){}if(r.debugInfo.loadIndx=a?a.fragIndex:-1,r.mse){if(i&&(!t||(null==t?void 0:t.byteLength)<=0)&&null!==(E=r.mp4)&&void 0!==E&&E.checkIsLoadEnd(null===(S=a.range)||void 0===S?void 0:S[1])){var y=r.player.buffered;r._loadedEnd=!0;var T=0;y&&(null==y?void 0:y.length)>0&&(T=y.end(y.length-1)),r._isEnded(),r.log(d._.LOG,"loaded ended !!!==>>>","range: ".concat(JSON.stringify(a.range)),"fragIndex: ".concat(a.fragIndex),"bufferEndTime: ".concat(T),"meta_duration: ".concat(r.mp4.meta.duration))}if(t&&(null==t?void 0:t.byteLength)>0){r._appendBuffer(f.d1.VIDEO,t,a,i);var b=r.getDataBitRate(a.fragIndex);r.player.emit("addVideoBufferEnd",{start:Math.floor(a.startPts),end:a.endPts,bandwidth:b.bitrate})}}else if(r.mseProxy&&(o&&o.samples.length>0||s&&s.samples.length>0)){if(o.editListApplied){var E,S,k,R=o.editList,x=o.samples,w=0;(null==R||null===(k=R.entries)||void 0===k?void 0:k.length)>0&&(w=R.entries[0].media_time),x.forEach(function(e){e.dts+=w,e.pts+=w,e.originDts+=w,e.originPts+=w}),o.baseMediaDecodeTime+=w}r.log(d._.LOG,"[xgvideo] append","index: ".concat(a.fragIndex),"range: ".concat(JSON.stringify(e.context.range)),"timeRange: ".concat(a.timeRange)),r.mseProxy.appendBuffer(o,s)}}catch(e){r.changeState("APPEND_DATA_ERROR",{errMsg:null==e?void 0:e.message});var L=new c.Errors(r.player,{errorType:_.iR.MEDIA,errorCode:_.O1.mseAppend,vid:r.playerConfig.vid,errorMessage:e.message,mediaError:{code:_.O1.mseAppend,message:e.message}});r._errorHandler(L)}null!=e&&e.state&&r._onTimeUpdate()}}),(0,n._x)(r,"_onResumePlaying",function(){r._resumePlay=!0}),(0,n._x)(r,"_seekOnce",function(e){var t=r.player;if(!!t)t.currentTime=e+.1*Math.pow(2,r._currentSeekTimes||0),r._currentSeekTimes++,r.log(d._.LOG,"当前第".concat(r._currentSeekTimes,"次Seek,currentTime=").concat(null==t?void 0:t.currentTime))}),(0,n._x)(r,"_onWaiting",function(){r.checkReStartTimer(),r._isEnded();var e,t=JSON.stringify(r.getAllBufferRange());r.changeState("waiting",{curtime:r.player.currentTime,buffer:t});var n=r.player,i=r.config,a=r.playerConfig,o=r.mp4;clearTimeout(r._waitInBufferTimer),r._waitInBufferTimer=null;var s=n.currentTime;r.log(d._.LOG,",[onWaiting],curTime, ",s,",buffer,",t,",dur,",null==o||null===(e=o.meta)||void 0===e?void 0:e.duration);var l=n.bufferedPoint;l.end>0&&(l.end-s>=2||r._loadedEnd)?r._waitAdjustTimeCnt<i.waitJampBufferMaxCnt?r._waitInBufferTimer=setTimeout(function(){r._waitAdjustTimeCnt++,r.changeState("waitInBuffer_seek",{waitAdjustTimeCnt:r._waitAdjustTimeCnt,curTime:s}),n.currentTime=n.currentTime+.5},i.waitingInBufferTimeOut):r._errorHandler(new c.Errors(r.player,{errorType:_.iR.RUNTIME,errorCode:_.O1.waitTimeout,errorMessage:"onWaitTimeout_in_buffer",vid:a.vid})):r._loadStuckCheck()}),(0,n._x)(r,"_onEnded",function(){r.log(d._.LOG,"[player.onEnded], stopProgress"),r._stopProgress()}),(0,n._x)(r,"_errorHandler",function(e){r._setPlayerError(e);var t=r.player,i=r.playerConfig,o=r.preLoadData;if(!!t&&!r.useVideoLoad){if(e.errorCode===_.O1["403"]&&r._emitExpireEvent(e)&&r.config.urlExpireDisableErrorEvent){r.log(d._.LOG,"_errorHandler urlExpireDisableErrorEvent",r.config.urlExpireDisableErrorEvent,",errorCode,",e.errorCode),r._stopProgress(),r.emit(C);return}if("object"!==(0,n.Ac)(e)){var s={};s.err=e,e=s}!e.ext&&(e.ext={});var l=t.paused;if(e.ext.vid=i.vid,e.ext.preloadHit=r.hitpreload?1:0,e.ext.preloadCached=o?o.duration:0,e.ext.timerStep=Math.max.apply(Math,(0,n.u)(r.timerStepList)),e.ext.codectype=r.codecType,e.message&&(e.errorMessage=e.message),e=new c.Errors(t,e),r.log(d._.ERROR,"_errorHandle","preState is ".concat(l),null===(u=e)||void 0===u?void 0:u.errorCode,e.errorMessage),e.url||(e.url=t.src),r.player.emit("playCatch",r.player.vtype,e),e.errd&&"object"===(0,n.Ac)(e.errd)&&r.mp4&&(e.errd.url=r.mp4.url,e.url=r.mp4.url),r.emit("DATA_REPORT",e),r.mp4&&r.mp4.cancelLoading(),r._abrService&&r._abrService.disable(),r.canDownload=!1,r.checkIsDegraded(e))r.player.vtype=a.l0.MP4_2,r._initPromise&&r.removeAndRejectInitPromise(e),r._startDegradedPlayback(e,l);else{r.log(d._.ERROR,"final error !!!!, ",i.vid,null===(f=e)||void 0===f?void 0:f.errorCode,null===(h=e)||void 0===h?void 0:h.errorMessage),r.player.pause(),r._reset(),r.states=[];var u,f,h,p,g,v=t.currentTime;r._destroyMSE(),t.currentTime=v,r.emit("error",e),r._setStartTimelines(a.l1.PLAY_ERROR,{message:null===(p=e)||void 0===p?void 0:p.message,httpCode:null===(g=e)||void 0===g?void 0:g.errorCode})}r.emit(C)}}),(0,n._x)(r,"_onSourceError",function(e){if(!r._hasFirstFramed){if(!(null!==(t=e.message)&&void 0!==t&&t.includes("PCDN"))){var t,n,i,o,s="".concat(r.player.vtype,"-host:").concat(null==e?void 0:e.host,"-").concat(null==e?void 0:e.errorCode,"-").concat(null!==(n=null==e||null===(i=e.mediaError)||void 0===i?void 0:i.message)&&void 0!==n?n:null==e?void 0:e.message);r._setStartTimelines(a.l1.HTTP_ERROR,{message:s,httpCode:null==e?void 0:e.errorCode}),null===(o=r._startTimelines)||void 0===o||null===(o=o.httpError)||void 0===o||o.push({message:s,httpCode:null==e?void 0:e.errorCode})}}}),(0,n._x)(r,"_onSeeking",(0,n.x)((0,n.l5)().mark(function e(){var t,i,a,o,s,l,u,c,h,p,g,v,m,y,_;return(0,n.l5)().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!r.useVideoLoad){e.next=2;break}return e.abrupt("return");case 2:if(a=(i=r).player,o=i.mp4,s=i.mse,l=i.config,3!==a.changeDefinitionSeekState){e.next=7;break}return a.changeDefinitionSeekState=void 0,r.log(d._.LOG,"[seeking] changeDefinitionSeekState clear"),e.abrupt("return");case 7:if(u=a.currentTime,c=a.bufferedPoint,r.waitLevelStartTime=u,r.changeState("seeking",{curTime:u,buffered:c,lastBuffered:r._lastBufferPoint}),r.log(d._.LOG,"[seeking], curTime: ".concat(u,", duration: ").concat(null==o||null===(t=o.meta)||void 0===t?void 0:t.duration),"buffer: ".concat(JSON.stringify(r.getAllBufferRange()))),!(!o||!o.meta)){e.next=15;break}return l.enableMsePatches&&o&&!o.meta&&u>=0&&(o.seekTimeAfterMetaReady=u),e.abrupt("return");case 15:if(r._startProgress(),o.bufferUsedPos=0,o.metaLoading=!1,r._loadedEnd=!1,r._definitionChangePointInfo&&(r._definitionChangePointInfo.changeStartTime=u,r.log(d._.LOG,"[seeking update definitionChangePointInfo]",u)),o.changeBitRateTime>0&&(o.updateChangeBitRateTime(u),r.log(d._.LOG,"[seeking update changeBitRateTime]",u)),h=0,!(c.end>0)){e.next=30;break}if(!(r.isSeekingInSameBuffer(u,c)&&(!l.enableMsePatches||o.checkInAdaptTimeRange(c)))){e.next=26;break}return r.log(d._.LOG,"[seeking in buffered], linear buffer, curTime: ".concat(u,", buffered: ").concat(c.start,"-").concat(c.end)),e.abrupt("return");case 26:o.seekTime=c.end,r.log(d._.LOG,"[seeking in buffered], but is not continuous: ".concat(c.start,"-").concat(c.end)),e.next=32;break;case 30:o.seekTime=u,r.log(d._.LOG,"[seeking out buffered], seekTime: ".concat(u));case 32:return p=o.getFragmentIdx(o.seekTime),h=(g=r.getAdaptTimeRangeIdx(p))<0?r._curLoadSegmentIdx:g,o.seekTime===u&&null!=s&&s.isFull()&&(m=(v=r.getAllBufferRange())[v.length-1],r._checkRemovePlayedBuffer([m.start,m.end],u,!0,!0)),r.log(d._.LOG,"[seekTime resetFragmentLoadState], adaptIdx: ".concat(h)),o.resetFragmentLoadState(h),null==s||s.clearOpQueues(f.d1.VIDEO,!!l.enableMsePatches),1===a.changeDefinitionSeekState?null==s||s.remove(f.d1.VIDEO,0,1/0).then(function(){a.changeDefinitionSeekState=2,r.log(d._.LOG,"[seeking], changeDefinitionSeek remove buffer end, changeDefinitionSeekState = 2")}):l.removeBufferAtSeek&&(y=o.seekTime,_=1/0,r.log(d._.LOG,"[seeking mse remove], ".concat(y,"-").concat(_)),null==s||s.remove(f.d1.VIDEO,y,_)),r.canDownload=!1,e.next=43,o.cancelLoading();case 43:r.canDownload=!0,o.fillFirstSegment=!1,r._curLoadSegmentIdx=h,r._onTimeUpdate(),r._isEnded();case 48:case"end":return e.stop()}},e)}))),r.initLog(null===(t=r.player.playerId)||void 0===t||null===(t=t.toString())||void 0===t?void 0:t.slice(-4)),r.log(d._.LOG,"plugin version: ".concat(L.i),"playerId: ".concat(r.playerId),"vid: ".concat(r.playerConfig.vid)),r._pendingPromises=[],r._allInitPromise=new w.Z,r._isInit=!1,r._isEventInit=!1,r.preloader=null,r._useVideoLoad=!1,r.mse=null,r.mp4=null,r.eme=null,r._isMseInit=!1,r._corePromise=null,r._initPromise=null,r._hasStartProgress=!1,r._hasStartProgressBack=!1,r._curLoadSegmentIdx=0,r._abrService=null,r._checkRemoveBufferLastTime=k.Z.nowTime(),r.playFlag=!1,r.config.resumePlayWaterLevel=Math.min(r.config.minBufferLength,r.config.resumePlayWaterLevel),r.checkResumePlayTimer=null,r._MSEError=!1,r._waitAdjustTimeCnt=0,r._waitInBufferTimer=null,r.isActive=!0,r.debugInfo={},r.seekTimeAfterMetaReady=void 0,r._suspendLoading=!1,r.states=[],r.removeVideoList=[],r._lastCheckTime=k.Z.nowTime(),r._lastCheckLagTime=k.Z.nowTime(),r._changeDefState=null,r._defInited=!1,r._removeBuffEndTime=0,r._lastTimeupdateTime2=0,r.waitLevelStartTime=-1,r.preLoadData=null,r.forPreloadTimeCache=null,r._usePaused=!1,r.hitpreload=!1,r.isH265DegradeH264=!1,r.loadstartTimer=null,r.loadedmetadataTimer=null,r.loadeddataTimer=null,r.canplayTimer=null,r.adaptRangeRes=[],r._definitionChangePointInfo=null,r._lastTimeupdateTime2=0,r.waitLevelStartTime=-1,r.timerStepList=[],r._isH265SoftDecoder=!1,r._beforeLoadStartCostTime=0,r._requestTimer=null,r.firstFrameCostTime={},r._mediaCodec={videoCodec:"",audioCodec:""},r._setTimelineData(),r._updatePropsByConfig(),r.player._customExpiryCheck=r.config.enableCusExpiryCheck,r._bindSrcTiming=m.Iv.META_READY,r}return(0,n.XW)(H,e),(0,n.qH)(H,[{key:"_setTimelineData",value:function(){this._startTimelines={startstage:-1,startmessage:"",httpCode:-1,httpError:[],reqtime:-1,downgradetime:-1,fcost:-1,ffcost:-1,startbufferlength:-1,playerError:"",startdelta:-1,loadstarttime:-1,loadeddatatime:-1,loadstarttype:-1,loadeddatatype:-1,playtime:-1,playerstate:-1},this._hasFirstFramed=!1}},{key:"setConfig",value:function(e){this.config=Object.assign(this.config,e),this._updatePropsByConfig()}},{key:"_updatePropsByConfig",value:function(){this._maxBufferLength=this.config.maxBufferLength,this._minBufferLength=this.config.minBufferLength,this._nextBufferLength=this.config.nextBufferLength,this._switchBitRateWay=this.config.switchBitRateWay,this._tickInSeconds=this.config.tickInSeconds||m._X}},{key:"initLog",value:function(e){var t=this.config.logCacheConfig,r=t.logCacheLevel,n=t.logMaxSize;this.logger=new d.Y(H.pluginName+e,{logCacheLevel:r,logMaxSize:n}),x.i5&&d.Y.enable()}},{key:"playerlogger",value:function(e){e?d.Y.enable():d.Y.disable()}},{key:"_setStartTimelines",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this._hasFirstFramed&&this._startTimelines){this._startTimelines.startstage=e,this._startTimelines.startmessage="".concat(a.sm[e]||"","-").concat((null==t?void 0:t.message)||"");var r=this._startTimelines.httpCode;this._startTimelines.httpCode=-1!==r?r:(null==t?void 0:t.httpCode)||-1,e===a.l1.PLAYER_ERROR&&(this._startTimelines.playerError=(null==t?void 0:t.message)||"")}}},{key:"afterCreate",value:function(){var e=this,t=this.playerConfig,r=this.config,i=this.player;if(r.width=t.width||0,r.height=t.height||0,t.vid=t.vid||r.vid,"object"!==(0,n.Ac)(r.reqParams)&&(r.reqParams={}),!f.d1.isSupported('video/mp4; codecs="avc1.64001E, mp4a.40.5"')){this._setStartTimelines(a.l1.NOT_SUPPORTED);return}void 0===r.supportHevc&&null!==c.Sniffer&&void 0!==c.Sniffer&&c.Sniffer.isHevcSupported&&c.Sniffer.isHevcSupported()&&this.player.video instanceof HTMLVideoElement&&(r.supportHevc=!0),void 0===r.supportVvcc&&(r.supportVvcc=(0,R.E0)()),this.softDecode?i.vtype=a.l0.MP4_MSE_SOFT:i.vtype=a.l0.MP4_MSE,(!(0,R.KI)()||this.softDecode)&&(r.useEME=!1),r.useEME=!1!==r.useEME,this.checkConfig(),r.onlyInit&&(t.autoplay=!1,t.videoInit=!1,this._hasStartProgress=!1,this._hasStartProgressBack=!1),t.useWaterLevel&&(t.userGestureEventMiddleware||(t.userGestureEventMiddleware=S.Ru),t.videoEventMiddleware||i.setEventsMiddleware(S.f4)),this._proxyPlayer(),i.useHooks("replay",this._replayHook),i.useHooks("play",this._playHook),i.useHooks("pause",this._pauseHook),i.useHooks("retry",this._retryHook),this.on("source_error",this._onSourceError),this.on("error",this._onSourceError),i.video.addEventListener(m.fD.BUFFERED_RESET,this._onBufferedReset),this._bindNetworkStateChange(),this.on(c.Events.TIME_UPDATE,this._onVideoTimeUpdate),this.on(c.Events.LOADED_DATA,function(){var t;-1===e._startTimelines.loadeddatatime&&(e._startTimelines.loadeddatatime=k.Z.nowTime(),e._startTimelines.loadeddatatype=i.vtype===a.l0.MP4_MSE?1:2),e.loadedDataEventRev=!0,e.changeState("LOADED_DATA"),e.deleteVideo(),e.mp4&&e.mp4.updateLoadedDataDone(),e._onTimeUpdate(),null!==(t=e.config)&&void 0!==t&&t.enableFPSStuckHandle&&e.on(c.Events.FPS_STUCK,e.fpsStuckHandle)}),this.on(c.Events.LOAD_START,function(){e.changeState("LOAD_START"),e._bindSrcTiming===m.Iv.META_READY?e._beforeLoadStartCostTime=new Date().getTime()-e._tm:e._beforeLoadStartCostTime=0,e.log(d._.LOG,"mp4plugin loadstart",e._beforeLoadStartCostTime),-1===e._startTimelines.loadstarttime&&(e._startTimelines.loadstarttime=k.Z.nowTime(),e._startTimelines.loadstarttype=i.vtype===a.l0.MP4_MSE?1:2),e.codecType===a.u7.H265&&!e.config.supportHevc&&(e._isMseInit=!0,e._onTimeUpdate())}),this.on(c.Events.ENDED,function(){e.log(d._.LOG,"mp4plugin receive player video ended event"),e._onEnded()}),this.on(c.Events.PAUSE,function(){e._usePaused=!0}),this.on(c.Events.PLAY,function(){e._usePaused=!1}),this.on(c.Events.AUTOPLAY_STARTED,function(){e._startTimelines&&(e._startTimelines.playtime=k.Z.nowTime())}),this.on("xglog",function(t){if("firstFrame"===t.eventType){var r,n=e.preLoadData&&e.preLoadData.definition?e.preLoadData.definition:-1,i=e.player;e._startTimelines.fcost=k.Z.nowTime()-e._startTimelines.reqtime,e._startTimelines.ffcost=t.fvt,e._hasFirstFramed=!0,e.log(d._.DEBUG,"[xgplayer-encrypt-mp4]>>>>firstFrame ".concat(e.playerConfig.vid,", ").concat(t.fvt,", codecType: ").concat(e.codecType),"hitPreload: ".concat(e.hitpreload,", video: ").concat(e._useVideoLoad,", preloadBitrate: ").concat(n),"curDefinition: ".concat(null===(r=i.curDefinition)||void 0===r?void 0:r.definition))}}),i.mp4MseFlag=!0}},{key:"_startBufferCheck",value:function(){var e=this.player;if(!e.video)return;var t=[];if(!!e.video.buffered){for(var r=0,n=e.video.buffered.length;r<n;r++)t.push([e.video.buffered.start(r),e.video.buffered.end(r)]);t.toString()!==this.lastBuffer&&(this.lastBuffer=t.toString(),this._onBufferReachThreshold())}}},{key:"_onBufferReachThreshold",value:function(){var e=this.player,t=this.config;if(e.video){for(var r=e.video.buffered,n=0,i=0,a=0;a<r.length&&(n=r.start(a),i=r.end(a),!(n<=e.video.currentTime)||!(e.video.currentTime<=i));a++);i-e.video.currentTime>=t.bufferThreshold&&!this._hasTriggerBufferThreshold&&(this._hasTriggerBufferThreshold=!0,e.emit("BUFFER_THRESHOLD",i-e.video.currentTime))}}},{key:"_startUrlExpiredCheck",value:function(){var e,t,r,n=this.player;if(null!==(e=this.expiryCheckPlugin)&&void 0!==e&&null!==(e=e.config)&&void 0!==e&&e.useCdnExpiryTime){null===(t=(r=this.expiryCheckPlugin).handleUrlExpiryCheckByCdnPath)||void 0===t||t.call(r);return}var i=n.config;i.definition&&i.definition.list&&i.definition.list.length>0&&(this.urlExpireTimestamp=i.definition.list[0].url_expire||0,this._handleUrlExpire())}},{key:"cancelLoading",value:(t=(0,n.x)((0,n.l5)().mark(function e(){var t,r;return(0,n.l5)().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.mp4){e.next=2;break}return e.abrupt("return");case 2:return this._cancelLoading=!0,this.log(d._.LOG,"player cancelLoading",this.playerConfig.vid),this._stopProgress(),null===(t=this.preloader)||void 0===t||null===(r=t.cancelLoading)||void 0===r||r.call(t),e.next=8,this.mp4.cancelLoading();case 8:case"end":return e.stop()}},e,this)})),function(){return t.apply(this,arguments)})},{key:"suspendLoading",value:function(){var e,t=this.mp4;if(!!t&&!this._suspendLoading)this._suspendLoading=!0,this.log(d._.LOG,"player suspendLoading",this.playerConfig.vid),this._stopProgress(),null!=t&&null!==(e=t.adaptTimeRange[this._curLoadSegmentIdx])&&void 0!==e&&e.isLoading&&(t.resetFragmentLoadState(this._curLoadSegmentIdx,!0),this.cancelLoading())}},{key:"resumeLoading",value:function(){if(!!this.mp4&&!!this._suspendLoading)this._suspendLoading=!1,this.log(d._.LOG,"player resumeLoading",this.playerConfig.vid),this._startProgress()}},{key:"checkConfig",value:function(){var e=this.playerConfig,t=this.config,r=e.defaultDefinition,n=e.defaultBitrate;if(!r){var i=this.playerConfig.definition;r=i&&i.defaultDefinition?i.defaultDefinition:t.definition}!n&&t.bitrate&&(n=t.bitrate),e.defaultDefinition=r,e.defaultBitrate=n}},{key:"beforePlayerInit",value:function(){var e=this,t=this.player,r=this;!this._isInit&&(c.BasePlugin.defineGetterOrSetter(t,{__url:{get:function(){return r.mse?r.mse.url:t.config.url},configurable:!0},downloadSpeed:{get:function(){return B/8},configurable:!0},playerVersion:{get:function(){return L.i},configurable:!0},menuCodeType:{get:function(){return r.mp4&&r.mp4.meta?r.mp4.meta.videoCodec:r.codecType===a.u7.H264?"avc":"hevc"},configurable:!0},playerType:{get:function(){return"MP4"},configurable:!0},supportMenus:{get:function(){return{speed:null==t?void 0:t.mp4MseFlag,cdn:null==t?void 0:t.mp4MseFlag,resolution:null==t?void 0:t.mp4MseFlag}},configurable:!0},preloadActive:{get:function(){return e.isActive},set:function(t){e.isActive=t,e.isActive&&e._startProgress()},configurable:!0},performance:{get:function(){var t={};return e.states.forEach(function(e){t[e.state.toLowerCase()]=e.t2}),t},configurable:!0},domain:{get:function(){return r.domain},configurable:!0},loadURL:{get:function(){return r.loadURL},configurable:!0},abrInstance:{get:function(){return r.abrInstance},configurable:!0},pcdnReq:{get:function(){var e=o.e.pcdnReqCnt,t=T.Yx.pcdnDownLoadReqCnt;return{pcdn_tracker_request_cnt:e.pcdn_tracker_request_cnt,pcdn_tracker_failed_cnt:e.pcdn_tracker_failed_cnt,pcdn_download_request_cnt:t.pcdn_download_request_cnt,pcdn_download_failed_cnt:t.pcdn_download_failed_cnt}},configurable:!0},retryInfo:{get:function(){return T.Tw},configurable:!0},softDecoder:{get:function(){return e._isH265SoftDecoder},configurable:!0},logCache:{get:function(){if(!!r.logger){var t,n,i,a="";try{a=JSON.stringify(e.config)}catch(e){a="config stringify error"}return r.log(d._.LOG,"timerStepList, ".concat(JSON.stringify(e.timerStepList),",\n currentTime: ").concat(null===(t=r.player)||void 0===t?void 0:t.currentTime,"\n buffer, ").concat(JSON.stringify(r.getAllBufferRange()),",\n state: ").concat(JSON.stringify(r.states),",\n isActive:").concat(r.isActive,",\n preRangeType: ").concat(null===(n=r.player)||void 0===n||null===(n=n.preloader)||void 0===n||null===(n=n._config)||void 0===n?void 0:n.loadRangeType,",\n loadRangeType: ").concat(null===(i=r.config)||void 0===i?void 0:i.loadRangeType,",\n Mp4EncryptPlayer version, ").concat(L.i,",\n Mp4EncryptPlayer config, ").concat(a)),r.logger.getLogCache()}},configurable:!0},pcdnVVStat:{get:function(){var e,t=r.mp4,i=r.pcdn;return t?(0,n.Zj)((0,n.Zj)({},t.pcdnVVStat),{},{trace_id:null===(e=t.pcdnTraceInfo)||void 0===e?void 0:e.trace_id,cancelCnt:(null==t?void 0:t.pSCCancelCnt)||0,is_try_open:i?1:0}):null},configurable:!0},beforeLoadStartCostTime:{get:function(){return e.useVideoLoad?0:e._beforeLoadStartCostTime},configurable:!0},mediaCodec:{get:function(){return e._mediaCodec},configurable:!0},bandwidth:{get:function(){var e,t,i=r.mp4,a=i?i.loadInfo:null;return{vid:null===(e=r.playerConfig)||void 0===e?void 0:e.vid,cdn:{speed:null==a||null===(t=a[T._R.CDN])||void 0===t?void 0:t.loadSpeed,size:a&&a[T._R.CDN]?a[T._R.CDN].loadLen:0},pcdn:(0,n.Zj)({size:a&&a[T._R.PCDN]?a[T._R.PCDN].loadLen:0},null==i?void 0:i.pcdnTraceInfo)}},configurable:!0},ext:{get:function(){var e,t,n,i,a,o,s,l,u=[];if((null===(e=r.player)||void 0===e||null===(e=e.video)||void 0===e||null===(e=e.buffered)||void 0===e?void 0:e.length)>0){for(var c=r.player.video.buffered,d=0,f=(null==c?void 0:c.length)||0;d<f;d++)u.push([c.start(d),c.end(d)])}return{type:"MP4",version:L.i,usevideo:r.useVideoLoad?1:0,curTime:null===(t=r.player)||void 0===t?void 0:t.currentTime,duration:(null===(n=r.mp4)||void 0===n||null===(n=n.meta)||void 0===n?void 0:n.duration)||(null===(i=r.player)||void 0===i?void 0:i.duration),loadIdx:r._curLoadSegmentIdx,curload:null!==(a=r.mp4)&&void 0!==a&&a.adaptTimeRange?r.mp4.adaptTimeRange[r._curLoadSegmentIdx]:{},buffer:u,speed:null===(o=r.debugInfo)||void 0===o?void 0:o.speed,states:null==r?void 0:r.states,loadRangeType:null===(s=r.config)||void 0===s?void 0:s.loadRangeType,preRangeType:null===(l=r.player)||void 0===l||null===(l=l.preloader)||void 0===l||null===(l=l._config)||void 0===l?void 0:l.loadRangeType}},configurable:!0},currentDefinitionFromPlayer:{get:function(){return r.abrInstance&&r.abrInstance.isCurrentInAbr?t._currentDefinitionFromPlayer:t.curDefinition},configurable:!0},currentDefitionFromPlayer:{get:function(){return t.currentDefinitionFromPlayer},configurable:!0},startTimelines:{get:function(){if(e._startTimelines){var r=k.Z.nowTime();e._startTimelines.startuploadtime=r;var n=t.vtype!==a.l0.MP4_MSE?e._startTimelines.downgradetime:e._startTimelines.reqtime;if(e._startTimelines.startdelta=r-n,e._startTimelines.firstframedp=e._hasFirstFramed?1:0,e._startTimelines.playerstate=t.state,!e._hasFirstFramed){var i=t.getBufferedRange();e._startTimelines.startbufferlength=i[1]-i[0],e.emit(C)}}return JSON.parse(JSON.stringify(e._startTimelines))},configurable:!0},encryptedInfo:{get:function(){var t,r=0;return e._secretkey&&(r=null!==(t=e._secretkey.config)&&void 0!==t&&t.useEME?1:2),{encryptedType:r}},configurable:!0}}),this._isInit=!0)}},{key:"destroy",value:function(){var e,t,r=this.player,n=this.config;r.preloader&&r.preloader.removePlayingId(r.playerId),r.removeHooks("replay",this._replayHook),r.removeHooks("play",this._playHook),r.removeHooks("pause",this._pauseHook),r.removeHooks("retry",this._retryHook),null===(e=this._requestTimer)||void 0===e||e.destroy(),this._requestTimer=null,this._reset(),this.states=[],this.checkReUseMSE(!1,n.enableMsePatches),this._secretkey&&(this._secretkey.off(i.EVENT_EME.ERROR,this._errorHandler),this._secretkey.destroy()),this.player.playNext=O,this.player._startInit=I,this.player.changeDefinition=M,this.player.switchURL=N,this._unbindNetworkStateChange(),this._unbindEvents(),r.video&&r.video.removeEventListener(m.fD.BUFFERED_RESET,this._onBufferedReset),this._bufferCheckTimer&&clearInterval(this._bufferCheckTimer),this._removeBufferTimer&&(clearTimeout(this._removeBufferTimer),this._removeBufferTimer=null),(null===(t=this.logger)||void 0===t?void 0:t.reset)&&this.logger.reset(),this.timerStepList=[]}},{key:"_proxyPlayer",value:function(){var e=this;"function"==typeof this.player.playNext&&(O=this.player.playNext),this.player.playNext=function(){e.playNext.apply(e,arguments)},I=this.player._startInit,N=this.player.switchURL,M=this.player.changeDefinition,this.player._startInit=this.playerStartInit.bind(this),this.player.switchURL=this.switchURL.bind(this),this.player.changeDefinition=this.changeDefinition.bind(this)}},{key:"getInitBitrate",value:function(){var e=this.player,t=this.playerConfig,r=null,n=e.definitionList;if(n&&n.length>0){var i={},a=e.preloader;if(a){var o=a.getPreloadMetaByVid(t.vid);if(o){var s=a.getDataUniqueKey(o),l=(0,S.Vh)(o,n);l?(l.cacheKey=s,(r=l).type="preload",r.preLoadMeta=o,i={m:1,t:2,ck:s}):i={m:0,t:1,ck:s}}}else i={t:0};if(this.changeState(m.fp.PRELOAD_CHECK,i),r&&t.userSelectDefinition&&t.focusUserDefinition){var u={m:1,ud:t.userSelectDefinition,d:r.definition};t.userSelectDefinition!==r.definition&&(r=null,u.m=1),this.changeState(m.fp.USER_DEFI_CHECK,u)}!r&&this.bitRateAdapter&&(this.bitRateAdapter.speed=T.Yx.speed,(r=this.getDefinitonFromAdapter(n,t.userSelectDefinition))&&(r.type="bitRateAdapter"))}if(!r||!r.url){var d,f=(null===(d=t.definition)||void 0===d?void 0:d.defaultDefinition)||t.defaultDefinition;if("Array"===c.Util.typeOf(t.url)&&t.url.length>0||"String"===c.Util.typeOf(t.url)&&t.url){var h=this._getDefinitionItem(f),p=t.defaultBitrate||t.bitrate||(null==h?void 0:h.bitrate);r={url:t.url,definition:(null==h?void 0:h.definition)||f||-1,duration:(null==h?void 0:h.duration)||t.duration||this.config.duration||0,bitrate:p,uri:t.uri||(null==h?void 0:h.uri),file_id:null==h?void 0:h.file_id,size:(null==h?void 0:h.size)||t.size,type:"default"}}else r=n[n.length-1]}return this.playerConfig.url=r.url,r.networkSpeed=T.Yx.speed,e.curDefinition=r,r}},{key:"_setPlayerSrc",value:function(e){var t=this.player;this._removeVideoSource();var r="Array"===c.Util.typeOf(e);e=r?this._processArrayUrl(e):this._processUrl(e),r?(t.video.removeAttribute("src"),t._detachSourceEvents||e.forEach(function(e){t.video.appendChild(c.Util.createDom("source","",{src:"".concat(e.src),type:"".concat(e.type||"")}))}),t._attachSourceEvents(t.video,e)):t.video.src=e,t.play(),t.mp4MseFlag=!1,t.emit("playertypechange"),this._startTimelines.downgradetime=k.Z.nowTime()}},{key:"_removeVideoSource",value:function(e){var t=this.player,r=(e=e||t.video).children;if(r.length>0)for(t._detachSourceEvents(e);r.length>0;)e.removeChild(r[0])}},{key:"_getDefinitionItem",value:function(e){var t=this.playerConfig;if(!t.definition||!t.definition.list)return null;for(var r=0;r<t.definition.list.length;r++){var n=t.definition.list[r];if(n.definition===e)return n}return null}},{key:"_initAbrDefinition",value:function(){var e,t=this.player,r=this.playerConfig;if(r.definition.list.length>0&&(!t.curDefinition&&(t.curDefinition=r.definition.list[0]),!t.curDefinition.vwidth&&Object.assign(t.curDefinition,this._getDefinitionItem(t.curDefinition.definition)),this._abrService.updateAbrCacheData()),this._abrService&&this._abrService.isCurrentAutoDefi){var n=r.definition.list.length;t.curDefinition=r.definition.list[n-1]}for(var i=0;i<r.definition.list.length;i++){var a=r.definition.list[i];t.curDefinition.definition===a.definition?a.selected=!0:a.selected=!1}this.player.emit("resourceReady",r.definition.list);var o=null===(e=t.curDefinition)||void 0===e?void 0:e.bitrate;if(!o)for(var s=0;s<r.definition.list.length;s++){var l=r.definition.list[s];l.definition===t.curDefinition.definition&&(o=l.bitrate)}o&&this._abrService.updateBitrate(o)}},{key:"_initAbrService",value:(r=(0,n.x)((0,n.l5)().mark(function e(){var t,r;return(0,n.l5)().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.playerConfig,!(!(r=this.config).autoBitrateOpts||!r.autoBitrateOpts.isOpenAutoDefi)){e.next=3;break}return e.abrupt("return");case 3:return this._abrService=new g.Z(this,this.abrSwitchURL),e.next=6,this._abrService.init({video:t.definition.list.concat()});case 6:this._initAbrDefinition();case 7:case"end":return e.stop()}},e,this)})),function(){return r.apply(this,arguments)})},{key:"_initMp4Kernel",value:function(){var e=this,t=this.playerConfig,r=this.config,n=new w.Z;try{var i=this.player.curDefinition;if(this.log(d._.LOG,"[_initMp4Kernel] ".concat(t.vid," curDefinition"),null==i?void 0:i.definition),!this._handlerUrl(t.url))return this.log(d._.LOG,"emptyUrl"),n.reject(Error("emptyUrl")),n;if(r.forceVideoPlay&&(this.codecType===a.u7.H264||r.supportHevc))return this.useVideoLoad=!0,this.log(d._.LOG,"forceVideoPlay"),n.reject(Error("forceVideoPlay")),n;var o=[];this._secretkey&&o.push(this._secretkey.getLicenseSecret()),o.push(this._checkPreloader()),Promise.all(o).then(function(t){if(e.isDestroy){n.reject(Error("destroy"));return}var o=null;if(t&&t.length>0&&(t.length>1&&(!r.keyValue&&t[0].secretKey&&(r.secretKey=t[0].secretKey),r.decryptKey=t[0].decryptKey),o=t[t.length-1].data),!o&&r.needPreloadCheck&&(e.codecType!==a.u7.H265||r.supportHevc))e.useVideoLoad=!0,e.log(d._.LOG,"no_preload"),n.reject(Error("no_preload"));else if(e.vtype&&"MP3"===e.vtype)e.useVideoLoad=!0,e.log(d._.LOG,"vtype_not_MP4"),n.reject(Error("vtype_not_MP4"));else{var s,l=r._mainURL;e._initMp4(l,o,{fileSize:i?i.size:0}),e.updateLoadInfo(null===(s=o)||void 0===s?void 0:s.cacheKey),e.checkPCDN(),e.initAdaptRange(),e._initAbrService()}}).catch(function(r){e.log(d._.ERROR,"getLicense or checkPreloader reject",null==r?void 0:r.message,null==r?void 0:r.stack);var a,o,s,l=(null==r||null===(a=r.error)||void 0===a?void 0:a.code)||("getLicense"===r.method?_.O1.custom_drm:_.O1.other),u=(null==r?void 0:r.message)||(null==r||null===(o=r.error)||void 0===o?void 0:o.message)||"getLicense or checkPreloader reject";"getLicense"===r.method?(s=new c.Errors(e.player,{errorType:_.iR.DRM,errorCode:l,errorMessage:u,vid:t.vid}),e.emit("GET_LICENSE_ERROR",s),e.changeState("LICENSE_ERROR",{d:i?i.definition:0})):s=new c.Errors(e.player,{errorType:_.iR.OTHER,errorCode:l,errorMessage:u,vid:t.vid}),n.reject(s)})}catch(e){n.reject(e)}return n}},{key:"updateLoadInfo",value:function(e){var t;if(!!e&&!!this.mp4)this.mp4.loadInfo=null===(t=this.preloader)||void 0===t?void 0:t.getLoadInfoAndDelete(e)}},{key:"initAdaptRange",value:function(){var e=this.config,t=this.player,r=this.playerConfig,n=t.curDefinition,i=n.bitrate,a=n.duration;null!=e&&e.adaptRange&&(this.adaptRange=new s.Q(t,i,a||r.duration,e.adaptRange))}},{key:"getPCDNReqId",value:function(){var e=this.player.curDefinition,t=this.playerConfig.vid;return e.uri?e.uri.slice(-20)+e.bitrate:t?t.slice(-20)+e.bitrate:void 0}},{key:"checkPCDN",value:function(){var e,t=this,r=this.config,n=this.player,i=this.mp4,a=n.curDefinition;if(null!==(e=r.pcdnConfig)&&void 0!==e&&e.openPCDN&&a.duration>=r.pcdnConfig.minDuration){r.pcdnConfig.app_id&&(m.tE.app_id=r.pcdnConfig.app_id),r.pcdnConfig.sid&&(m.tE.sid=r.pcdnConfig.sid);var s,l=r._mainURL;if(!a.uri||!a.bitrate||0>=l.indexOf("video/")){this.log(d._.LOG,"uri null or bitrate null or url not contain video cannot use pcdn"),this.pcdn=null;return}!(0,S.Pj)(l)&&(l=document.location.protocol+l);var u={vid:a.uri,sfid:a.file_id,cdn_url:l,file_type:null===(s=this.vtype||"MP4")||void 0===s?void 0:s.toLowerCase(),bitrate:a.bitrate,duration:Math.floor((null==a?void 0:a.duration)||0),size:(null==a?void 0:a.size)||k.Z.getFileSize(a.bitrate,a.duration)};if(this.pcdn)this.pcdn.resetTrackeArgs();else{var c=Object.assign({},{productConfig:m.tE},r.pcdnConfig),f=u.bitrate,h=u.duration;this.pcdn=new o.e(c,n,f,h)}this.pcdn.fetchPCDNNode(null,u,this.getPCDNReqId()).then(function(e){var r,n,a=t.getPCDNReqId();if(null!=e&&e.req_id&&a!==e.req_id){t.log(d._.LOG,",fetchPCDNNode is not match curDefinition reqId",a,", pcdnRet.req_id",e.req_id);return}i&&e&&(t.log(d._.LOG,"".concat(t.playerConfig.vid," get peer end,pcdn node update,"),null==e||null===(r=e.nodes)||void 0===r?void 0:r.length),i.updateNode(null==e?void 0:e.nodes),i.pcdnTraceInfo={uri:e.vid,fid:e.fid,trace_id:null==e?void 0:e.trace_id},i.pcdnVVStat&&(i.pcdnVVStat.try_req_node+=1,i.pcdnVVStat.req_node_succ+=1,i.pcdnVVStat.has_ret_node+=(null==e||null===(n=e.nodes)||void 0===n?void 0:n.length)>0?1:0))}).catch(function(e){(null==i?void 0:i.pcdnVVStat)&&(i.pcdnVVStat.try_req_node+=1),t.checkURLExpired(e,"_fetchPCDNNode")})}else this.pcdn=null}},{key:"initTimer",value:function(){if(!this._requestTimer){var e=this.config.timerInWorker;this._requestTimer=new y.f({frequency:this._tickInSeconds,timerInWorker:e}),this._requestTimer.on(m.sW,this.timerHandle)}}},{key:"playerStartInit",value:(u=(0,n.x)((0,n.l5)().mark(function e(t){var r,o,s,l,u,h,p,g,v,y,T,b,E,S,R,x,w,L,P,A,O,I,M,N,B,U,F,V,G=this;return(0,n.l5)().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.log(d._.LOG,"playerStartInit",this.player.hasStart,this.playerId,t),!this.isDestroy){e.next=4;break}return this._setStartTimelines(a.l1.START_INIT_DESTROY),e.abrupt("return");case 4:if(r=this.playerConfig,o=this.player,s=this.config,this.states=[],this._sTime=k.Z.nowTime(),this._lastBufferPoint=void 0,this._usePaused=!1,this.isActive&&(null==o?void 0:o.currentTime)!==0&&(this.log(d._.LOG,"[playerStartInit] reset current = 0 ,buffer,",JSON.stringify(null==o||null===(l=o.buffered2)||void 0===l?void 0:l.bufferedList)),this.player.currentTime=0),this._isH265SoftDecoder=this.softDecode,s.reUseMSE&&this.mse&&"String"===c.Util.typeOf(t)&&/^blob/.test(t)&&t!==this.mse.url&&(t=r.url,this._destroyMSE()),(!t||"__auto__"===t||"anytext"===t)&&(u=r.definition)&&u.list&&u.list.length>0&&u.defaultDefinition&&(u.list.map(function(e){e.definition===u.defaultDefinition&&(r.url=e.url,G.player.curDefinition=e)}),(!r.url||"__auto__"===t||"anytext"===t)&&(t=(h=u.list[0]).url,r.url=h.url,u.defaultDefinition=h.definition,this.player.curDefinition=h)),this.initTimer(),p=o.oldBit,g=this._defInited?null:this.getInitBitrate(),o.oldBit=null==o||null===(F=o.curDefinition)||void 0===F?void 0:F.bitrate,!(!o.changeDefinitionFlag&&p&&p!==(null==o||null===(V=o.curDefinition)||void 0===V?void 0:V.bitrate))){e.next=23;break}if(!this.mp4){e.next=22;break}return this.canDownload=!1,e.next=22,this.mp4.cancelLoading();case 22:if(this.mse){this.once(c.Events.LOAD_START,function(){G.log(d._.LOG,"playerStartInit changeBtrate changeDefinitionSeekState = 1, currentTime += 0.001"),o.changeDefinitionSeekState=1,G.player.currentTime+=.001});try{this.mse.clearOpQueues(f.d1.VIDEO,!!s.enableMsePatches),this.mseAbort(),this.mse.remove(f.d1.VIDEO,0,1/0).then(function(){G.log(d._.LOG,"playerStartInit remove all buffer end")})}catch(e){this.log(d._.LOG,"playerStartInit mse func err, ".concat(null==e?void 0:e.message))}}case 23:if(o.changeDefinitionFlag=void 0,y=(v=this.config).kid,T=v.drmKeyToken,b=v.secretKey,E=v.keyValue,S=v.drm,y||T||b||E||S?this._secretkey?this._secretkey.updateConfig(this.config):(this._secretkey=new i.XGSecretKey(this.config),this._secretkey.on(i.EVENT_EME.ERROR,this._errorHandler)):this._secretkey=null,this._defInited=!0,this.log(d._.LOG,"[playerStartInit] ".concat(r.vid," curDefinition"),g||this.player.curDefinition),x=(R=this.player).preloader,w=R.playerId,x&&x.addPlayingId(r.vid,w),s.needPreloadCheck&&!this.softDecode&&!this._secretkey&&(L=!1,P="",x&&(A=this.player.curDefinition,O=this._getPreloadMeta(A),I=x.hasItemSameVid(O),P=x.getDataUniqueKey(O),I&&(L=!0)),!L&&(M=x?"no preload data":"no preloader",this.useVideoLoad=!0,this.player.vtype=a.l0.MP4_0,this._setStartTimelines(a.l1.NO_PRELOAD,{message:a.l0.MP4_0}),this.log(d._.LOG,"[playerStartInit] ".concat(r.vid," ").concat(M),!!x),N=new c.Errors(this.player,{errorType:"runtime",errorTypeCode:_.iR.runtime,errorCode:_.O1.other,vid:this.playerConfig.vid,errorMessage:M}),this.changeState(m.fp.PRELOAD_MATCH,{m:0,ck:P}),this.player.emit("playCatch",this.player.vtype,N))),!this.useVideoLoad){e.next=39;break}if(t=this.playerConfig.url,!s.closeDowngrade){e.next=36;break}return this._setStartTimelines(a.l1.CLOSE_DWNGRADE,{message:"isDestroy"}),e.abrupt("return");case 36:return this._playerStartInitCall(t),this._startProgress(),e.abrupt("return");case 39:if(!this.isDestroy){e.next=42;break}return this._setStartTimelines(a.l1.START_INIT_DESTROY,{message:"isDestroy"}),e.abrupt("return");case 42:this.player.mp4MseFlag=!0,this._tm=new Date().getTime(),this._reset(),B=this.playerConfig.vid,this.changeState("PLAYER_START_INIT"),this.mse||s.bindSrcTiming!==m.Iv.INIT?this._bindSrcTiming=m.Iv.META_READY:(this._bindSrcTiming=m.Iv.INIT,this.log(d._.LOG,"playerStartInit new MSE",this._bindSrcTiming),this.mse=new f.d1(this.player.video)),U=this._initMp4Kernel(),this._initPromise=U,this._addPendingPromise(this._initPromise),U.then(function(){if(G.isDestroy){G._setStartTimelines(a.l1.START_INIT_DESTROY,{message:"then destroy"});return}G.mse&&(t=G.mse.url),G.changeState("PLAY_INIT_OK"),G._bindEvents(),G._startProgress()}).catch(function(e){var r,n,i=!!G._initPromise&&G._initPromise.isBreak;if(G.isDestroy||i||e===D){var o="isDestroy:".concat(G.isDestroy,",isBreak:").concat(i,",e:").concat(e);G._setStartTimelines(a.l1.INIT_PROMISE_CATCH,{message:o});return}if(G.log(d._.LOG,"_initMp4Kernel.catch: ".concat(B," isDestroy:").concat(G.isDestroy,",\n errorCode:").concat((null==e?void 0:e.errorCode)||_.O1.other,",errMsg:").concat((null==e?void 0:e.errorMessage)||(null==e?void 0:e.message))),(null==e?void 0:e.errorCode)===_.O1["403"]&&(G._setStartTimelines(a.l1.HTTP_ERROR,{message:"request 403",httpCode:403}),G._emitExpireEvent(e)&&s.urlExpireDisableErrorEvent)){G._initPromise=null,G.log(d._.LOG,"initMp4Kernel urlExpireDisableErrorEvent",s.urlExpireDisableErrorEvent,",errorCode,",e.errorCode),G._stopProgress(),G.emit(C);return}var l=e;!l.errorCode&&((l=new c.Errors(G.player,{errorType:_.iR.RUNTIME,errorCode:(null==e?void 0:e.errorCode)||_.O1.other,vid:G.playerConfig.vid,errorMessage:(null==e?void 0:e.errorMessage)||(null==e?void 0:e.message),mediaError:{code:(null==e?void 0:e.httpCode)||_.O1.other,message:(null==e?void 0:e.errorMessage)||(null==e?void 0:e.message),errorType:null==e?void 0:e.errorType}})).url=t),G._setStartTimelines(a.l1.INIT_PROMISE_CATCH,{message:(null==e?void 0:e.errorMessage)||(null==e?void 0:e.message)}),G.changeState("PLAY_INIT_CATCH",{c:l.errorCode,m:(null==e?void 0:e.errorMessage)||(null==e?void 0:e.message),t:null==e?void 0:e.errorType}),G.useVideoLoad=!0,G.player.vtype=a.l0.MP4_1,G.player.emit("playCatch",G.player.vtype,l);var u=G.checkIsDegraded(l);if(G.log(d._.WARN,"PLAY_INIT_CATCH final error !!!!, ",B,null===(r=l)||void 0===r?void 0:r.errorCode,null===(n=l)||void 0===n?void 0:n.errorMessage,",degrade:",u),G.emit(C),!u){G.player.pause(),G._reset(),G.states=[],G.emit("error",l),G._initPromise=null;return}}).finally(function(){if(!!G._initPromise){var e,r=G._initPromise.isBreak;G._initPromise&&G._removePendingPromise(G._initPromise),G._initPromise=null,G._usePaused&&(G.playerConfig.autoplay=!1),G.softDecode&&"Array"===c.Util.typeOf(t)&&(t=t[0].src),"String"===c.Util.typeOf(t)&&!/^blob/.test(t)&&G._destroyMSE();var n=(null===(e=G.player)||void 0===e?void 0:e.currentSrc)===t;G.changeState("PLAY_INIT_FINALLY",{isDestroy:G.isDestroy,isBreak:r,reUseSrc:n}),G.isDestroy||r||G._playerStartInitCall(t),G._bindSrcTiming===m.Iv.META_READY&&G.reUseMSEEmitEvents(n),G._abrService&&G._abrService.isCurrentInAbr()&&(G._abrService.enable(),G._abrService.execute())}});case 52:case"end":return e.stop()}},e,this)})),function(e){return u.apply(this,arguments)})},{key:"_playerStartInitCall",value:function(e){e="Array"===c.Util.typeOf(e)?this._processArrayUrl(e):this._processUrl(e),I.call(this.player,e),this._startTimelines.downgradetime=k.Z.nowTime()}},{key:"_destroyMSE",value:function(){var e=this;if(!!this.mse)try{this.mse.clearOpQueues(f.d1.VIDEO,!!this.config.enableMsePatches);var t=this.config.enableMsePatches?this.mseAbort():this.mse.abort();if(!t)return;t.then((0,n.x)((0,n.l5)().mark(function t(){var r,i;return(0,n.l5)().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,null===(r=e.mse)||void 0===r?void 0:r.unbindMedia();case 2:e.mse&&e.log(d._.LOG,"destroyMSE ",null===(i=e.playerConfig)||void 0===i?void 0:i.vid),e.mse=null;case 4:case"end":return t.stop()}},t)}))).catch(function(){})}catch(e){}}},{key:"reUseMSEEmitEvents",value:function(e){var t,r=this;e&&/^blob/.test(null===(t=this.player)||void 0===t?void 0:t.currentSrc)&&(clearTimeout(this.loadstartTimer),clearTimeout(this.loadedmetadataTimer),clearTimeout(this.loadeddataTimer),clearTimeout(this.canplayTimer),this.loadstartTimer=setTimeout(function(){clearTimeout(r.loadstartTimer),r.loadstartTimer=null,r.emit(c.Events.LOAD_START),r.log(d._.LOG,"reUseMSE add emit loadstart event")},10),this.loadedmetadataTimer=setTimeout(function(){clearTimeout(r.loadedmetadataTimer),r.loadedmetadataTimer=null,r.emit(c.Events.LOADED_METADATA),r.log(d._.LOG,"reUseMSE add emit loadedmetadata event")},25),this.loadeddataTimer=setTimeout(function(){clearTimeout(r.loadeddataTimer),r.loadeddataTimer=null,r.emit(c.Events.LOADED_DATA),r.log(d._.LOG,"reUseMSE add emit loadeddata event")},50),this.canplayTimer=setTimeout(function(){clearTimeout(r.canplayTimer),r.canplayTimer=null,r.emit(c.Events.CANPLAY),r.log(d._.LOG,"reUseMSE add emit canplay event")},90))}},{key:"playNext",value:function(e){var t=this,r=this.player;this._setTimelineData(),this._defInited=!1,this._hasTriggerBufferThreshold=!1,r.resetState(),r._currentTime=0,r._duration=0,r.isPlaying=!1,this._useVideoLoad=!1,this._MSEError=!1;var n=this.softDecode;r.pause(),this._reset(),this.states=[];["url","vid","kid","playAuthToken","keyToken","startTime","secretKey"].forEach(function(e){delete t.config[e]}),e.vtype&&(this.vtype=e.vtype.toUpperCase()),r.setConfig(e),this.checkReUseMSE(this.config.reUseMSE),this.softDecode?r.vtype=a.l0.MP4_MSE_SOFT:r.vtype=a.l0.MP4_MSE,this.codecType=this.playerConfig.codecType?this.playerConfig.codecType.toLowerCase():a.u7.H264,n!==this.softDecode&&this.h265_h264_switch(this.playerConfig.mediaType||"video"),this.checkConfig(),this.log(d._.LOG,"[Index] playNext",e.vtype,e.vid),r.start(),this.config.reUseMSE&&!this.isH265DegradeH264&&(this.__onmetadataHandle=function(){t.log(d._.LOG,"[Index] playNext metadata update currentTime = 0"),0!==r.currentTime&&(r.currentTime=0),r.video.removeEventListener("loadedmetadata",t.__onmetadataHandle),t.__onmetadataHandle=null},r.video.addEventListener("loadedmetadata",this.__onmetadataHandle)),this.emit("playnext")}},{key:"h265_h264_switch",value:function(e){this.log(d._.LOG,"[Index],h265_switch_h264",e);var t=this.player,r=c.Util.createDom(e,"",this.getVideoConfig(this.playerConfig),"xgplayer-".concat(e,"-img"));this.removeVideoList.push(t.video),r.muted=t.video.muted,r.volume=t.video.volume,t.media?t.media=r:t.video=r,t.attachVideoEvents(t.video)}},{key:"getVideoConfig",value:function(e){var t=Object.assign({},{controls:!1,autoplay:e.autoplay,playsinline:e.playsinline,"x5-playsinline":e.playsinline,"webkit-playsinline":e.playsinline,"x5-video-player-fullscreen":e["x5-video-player-fullscreen"]||e.x5VideoPlayerFullscreen,"x5-video-orientation":e["x5-video-orientation"]||e.x5VideoOrientation,airplay:e.airplay,"webkit-airplay":e.airplay,tabindex:2,mediaType:e.mediaType||"video"},e.videoConfig,e.videoAttributes);return e.loop&&(t.loop="loop"),t}},{key:"next",value:function(e){this.playNext(e)}},{key:"oldChangeDefinition",value:(p=(0,n.x)((0,n.l5)().mark(function e(t,r){var i,a,o,s,l,u,h,p,g,v,m,y,_=this;return(0,n.l5)().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(i=this.config,a=this.player,o=this.playerConfig,a.changeDefinitionFlag=!0,a.emit(c.Events.DEFINITION_CHANGE,{from:r,to:t}),a.emit(c.Events.WAITING),l=(s=a.definitionList).filter(function(e){return e.definition===t.definition||e.definition===Number(t.definition)}),(u=s.filter(function(e){return e.definition===r.definition||e.definition===Number(r.definition)})).length>0&&(u[0].selected=!1),!(l.length>0)){e.next=13;break}(t=l[0]).selected=!0,e.next=14;break;case 13:return e.abrupt("return");case 14:return a.curDefinition=t,this.log(d._.LOG,"[oldChangeDefinition],currentTime,",a.currentTime,",from,",r,",to,",t),h=a.currentTime,(p=a.paused)&&(this.config.autoplayBack=o.autoplay,o.autoplay=!1),this._changeDefState={currentTime:h,paused:p},i.definition=t.definition,["keyValue","kid","secretKey","drm","getLicenseUrl","drmKeyToken","sessionId"].forEach(function(e){i[e]=t[e]}),e.next=24,null===(v=this.mp4)||void 0===v?void 0:v.cancelLoading();case 24:if(null===(m=this.mse)||void 0===m||m.clearOpQueues(f.d1.VIDEO,!!i.enableMsePatches),g=null===(y=this.mse)||void 0===y?void 0:y.abort(f.d1.VIDEO)){e.next=28;break}return e.abrupt("return");case 28:g.then(function(){o.url=t.url,o.userSelectDefinition=t.definition,o.defaultDefinition=t.definition,a.currentTime=0,a.pause(),_._reset(),_.states=[],_.checkReUseMSE(!1,i.enableMsePatches),_._isMseInit=!1,_.eme=null,_._handlerUrl(t.url),_.once(c.Events.CANPLAY_THROUGH,function(){void 0!==_.config.autoplayBack&&_.config.autoplayBack!==o.autoplay&&(o.autoplay=_.config.autoplayBack,_.config.autoplayBack=void 0)}),a.video.removeEventListener("loadedmetadata",_._changeDefineCanPlay),_._changeDefineCanPlay=function(){_.changeDefineCanPlay(h,p,r,t),a.video.removeEventListener("loadedmetadata",_._changeDefineCanPlay)},a.video.addEventListener("loadedmetadata",_._changeDefineCanPlay),a.video.load(),_.playerStartInit(o.url)}).catch(function(){});case 29:case"end":return e.stop()}},e,this)})),function(e,t){return p.apply(this,arguments)})},{key:"_emitDefinitionChangeDetailEvent",value:function(e){var t=this._currDefinition,r=t.bitrate,n=t.definition,i=t.file_id,a=t.width,o=t.vwidth,s=t.height,l=t.vheight;this.player.emit("definitionChangeDetail",{start:e,bitrate:r,definition:n,mediaType:"video",url:this.config._mainURL,fileid:i});this.player.emit("RESOLUTION_UPDATE",{width:a||o,height:s||l})}},{key:"getCurGopEndTime",value:function(e){var t=this.player;if(!t)return 0;var r=this.mp4,n=r.getFragmentIdx(e||t.currentTime);return r.timeRange[n].endTime}},{key:"_setCurrentDefinition",value:function(e){var t=this.player.config;if(t.definition&&t.definition.list){var r=t.definition.list.filter(function(t){return t.bitrate===e.bitrate||t.definition===e.definition});this._currDefinition=r&&r[0]}!this._currDefinition&&(this._currDefinition={})}},{key:"switchURL",value:function(e,t){var r=this;if(t&&"object"===(0,n.Ac)(t)&&t.action===A.UPDATE_URL){this._updateURL({url:null==e?void 0:e.url});return}if(this.useVideoLoad){N.call(this.player,e);return}var i=this.player,a=this.config;i.config.definition.list=[e],i.config.url=e.url,i.config.defaultBitrate=e.bitrate,i.config.defaultDefinition=e.definition;["keyValue","kid","secretKey","drm","getLicenseUrl","drmKeyToken","sessionId"].forEach(function(t){a[t]=e[t]}),this.__onmetadataHandle=function(){i.currentTime=0,i.video.removeEventListener("loadedmetadata",r.__onmetadataHandle),r.__onmetadataHandle=null},i.video.addEventListener("loadedmetadata",this.__onmetadataHandle),this.playNext(a)}},{key:"_updateURL",value:function(e){var t=this.player,r=this.config,n=(e||{}).url;return!!t&&!!n&&((t.config.url=n,t.curDefinition&&(t.curDefinition.url=n),this._handlerUrl(n),!this.useVideoLoad&&this.mp4)?(this.mp4.updateUrl(r._mainURL,r._backupURL),!0):!!this.useVideoLoad&&(N.call(this.player,n),!0))}},{key:"_handlerUrl",value:function(e){var t,r=this.config,n=this.playerConfig;if(!e)return!1;var i=[];if("String"===c.Util.typeOf(e))t=e,n.backupURL&&i.push(n.backupURL);else if("Array"===c.Util.typeOf(e)&&e.length>0&&(t=e[0].src,e.length>1))for(var a=1;a<e.length;a++){var o=this._processUrl(e[a].src);i.push(o)}return(!!t||0!==i.length)&&(r._mainURL=this._processUrl(t),r._backupURL=i,!0)}},{key:"_processUrl",value:function(e){var t=this.config,r=this.playerConfig,i=k.Z.extUrl(e,(0,n.Zj)({__vid:r.vid},t.reqParams));if(r&&"function"==typeof r.preProcessUrl){var a=r.preProcessUrlOptions||{};i=r.preProcessUrl(i,a).url}return i}},{key:"_processArrayUrl",value:function(e){var t=this;return e.map(function(e){return(0,n.Zj)((0,n.Zj)({},e),{},{src:t._processUrl(e.src)})})}},{key:"_bindEvents",value:function(){var e=this;this.log(d._.LOG,"bindEvents,",this._isEventInit);var t=this.config,r=this.player;!this._isEventInit&&(this.on("seeking",this._onSeeking),this.on("waiting",this._onWaiting),this.on("error",this._onVideoError),this.on("playing",this._onPlaying),this.on("detectGap",function(){t.gapDegrade&&t.useEME&&(t.useEME=!1,e._replay())}),this.on(l.J.CHANGE_FLYING_PLUGIN_CONFIG,this._onChangeConfig),r.setEventsMiddleware({error:function(t,n){var i,o,s,l,u,c,f={errorCode:null==t||null===(i=t.error)||void 0===i?void 0:i.code,errorMessage:null==t||null===(o=t.error)||void 0===o?void 0:o.message,videoType:e.useVideoLoad};if(e.changeState("video_error.Middleware",f),e._setPlayerError(f),e.codecType===a.u7.H265&&(null==t||null===(s=t.error)||void 0===s?void 0:s.message.indexOf("video decoder initialization failed"))>=0&&e.emit("DECODER_FAILED",{codecType:e.config.codecType,vid:null===(l=e.playerConfig)||void 0===l?void 0:l.vid,message:null==t||null===(u=t.error)||void 0===u?void 0:u.message}),e.log(d._.ERROR,"error middleware",JSON.stringify(f),", isDegrade,",!e._MSEError&&!e.useVideoLoad,r.currentTime),!e._MSEError&&!e.useVideoLoad){r.vtype=a.l0.MP4_2,e._MSEError=!0,null===(c=e.mp4)||void 0===c||c.cancelLoading(),e._startDegradedPlayback(f,r.paused),e.emit(C);return}e.emit(C),e.useVideoLoad&&n(t.eventName,null==t?void 0:t.error)}})),this._isEventInit=!0}},{key:"getBufferDur",value:function(){if(!(null!==(e=this.player)&&void 0!==e&&e.buffered))return 0;for(var e,t=this.player.buffered,r=0,n=0,i=t.length;n<i;n++)r+=t.end(n)-t.start(n);return r}},{key:"deleteVideo",value:function(){var e;if((null===(e=this.removeVideoList)||void 0===e?void 0:e.length)>0){for(var t=0;t<this.removeVideoList.length;t++){var r=this.removeVideoList[t],n=r.parentNode;n&&n.removeChild(r),this.log(d._.WARN,"[_removeVideoSource]")}this.removeVideoList=[]}}},{key:"_unbindEvents",value:function(){var e,t;this.log(d._.LOG,"unbindEvents,",this._isEventInit),this.off("seeking",this._onSeeking),this.off("waiting",this._onWaiting),this.off("ended",this._onEnded),this.off("error",this._onError),this.off("playing",this._onPlaying),this.off(l.J.CHANGE_FLYING_PLUGIN_CONFIG,this._onChangeConfig),this._isEventInit=!1,null!==(e=this.config)&&void 0!==e&&e.enableFPSStuckHandle&&this.off(c.Events.FPS_STUCK,this.fpsStuckHandle),null!==(t=this.playerConfig)&&void 0!==t&&t.fixOOM&&(this.off("source_error",this._onSourceError),this.off("error",this._onSourceError))}},{key:"changeState",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!this._pTime&&(this._pTime=k.Z.nowTime());var r=k.Z.nowTime()-this._pTime,n=k.Z.nowTime()-this._sTime;this.log(d._.LOG,">>>changeState[".concat(e,"]"),r,n,JSON.stringify(t)),this.states.push({state:e,t1:r,t2:n,data:t}),this._pTime=k.Z.nowTime()}},{key:"_initMseProxy",value:function(){var e,t=this.player.video||this.player.media;t instanceof HTMLVideoElement&&this.h265_h264_switch(this.playerConfig.mediaType),this.softDecode&&t&&(this.mseProxy=t,null===(e=t.setPlayMode)||void 0===e||e.call(t,"VOD"),t.addEventListener("lowdecode",this._lowDecoder),t.addEventListener("error",this._onError),this.player.forceDegradeToVideo=function(){})}},{key:"notSupportError",value:function(e){return this.log(d._.LOG,e,m.eT),new c.Errors(this.player,{errorType:_.iR.MEDIA,errorCode:_.O1.mse,errorMessage:"".concat(e," ").concat(m.eT),vid:this.playerConfig.vid})}},{key:"removeAndRejectInitPromise",value:function(e){this._initPromise&&(this._removePendingPromise(this._initPromise),this._initPromise.reject(e))}},{key:"_initMp4",value:function(e,t){var r,i,a,o,s,l,u,c,f,h=this,p=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},g=this.config,v=this.player,y=this.playerConfig;this.mp4&&(this.mp4.destroy(),this.mp4=null),this._startTimelines.reqtime=k.Z.nowTime(),this.changeState("MP4_NEW",{});var _=0;null!=g&&null!==(o=g.pcdnConfig)&&void 0!==o&&o.openPCDN&&(_=(null==g||null===(i=g.pcdnConfig)||void 0===i?void 0:i.switchPCDNMaxCnt)||2),null!=g&&null!==(s=g.pcdnConfig)&&void 0!==s&&s.adaptPCDNConfig&&null!=g&&null!==(l=g.pcdnConfig)&&void 0!==l&&null!==(l=l.adaptPCDNConfig)&&void 0!==l&&l.PCDNBufferControl&&(_=0),this._setCurrentDefinition(v.curDefinition);var R=b.Z;(null==g?void 0:g.loadRangeType)===m.TJ.SIZE&&(R=E.Z);var w=null===(u=v.curDefinition)||void 0===u||null===(u=u.pktOffsetMap)||void 0===u?void 0:u.find(function(e){return(null==e?void 0:e.time)===((null==g?void 0:g.firstLoadTimePos)||m.he)}),L=g.enableWorker,D=g.useUrlRange,P=g.retryCount,A=g.retryDelay,O=g.timeout,I=g.processMaxGapTime,M=g.onProcessMinLen,N=g.supportHevc,U=g.afterLoadeddataCallBackLen,F=g.firstLoadBuffer,V=g.memoryOpt,G=g.emitMediaListControl,H=g.reqOptions,j=g.audioGroupingStrategy,Z=g.fixEditListOffset,Y=g.fixEditListOffsetThreshold,W=g.isAddRange,z=g.disableRepeatRange,K=g.alwaysStreamingLoad,q=g.loadRangeType,X=g.changeUrlRetry,J=g.dynamicTimeoutIns;this.mp4=new R(e,v.curDefinition.bitrate,{segmentDuration:g.segmentMinDuration,enableWorker:L,softDecode:this.softDecode,codecType:this.codecType,chunkSize:g.preloadSize,firstLoadSize:null==w?void 0:w.offset,duration:y.duration||0,fileSize:p.fileSize||0,playerId:this.playerId,vid:y.vid,useUrlRange:D,retryCount:P,retryDelay:A,timeout:O,processMaxGapTime:I,onProcessMinLen:M,supportHevc:N,afterLoadeddataCallBackLen:U,firstLoadBuffer:F,logger:this.logger,memoryOpt:V,emitMediaListControl:G,enablePreloadCache:g.enablePreloadCache,switchPCDNMaxCnt:_,reqOptions:H,audioGroupingStrategy:j,fixEditListOffset:Z,fixEditListOffsetThreshold:Y,isAddRange:W,disableRepeatRange:z,alwaysStreamingLoad:K,loadRangeType:q,enableMsePatches:g.enableMsePatches,changeUrlRetry:X,dynamicTimeoutIns:J},this.config._backupURL,""),this.mp4.once(T.kL.META_READY,this._onMp4MetaReady),this.mp4.on(T.kL.ERROR,this._onMp4Error),this.mp4.on(T.kL.UPDATE_EME,this._updateDrmConfig),this.mp4.on(T.kL.INIT_MSE,this._updateMSE),this.mp4.on(T.kL.TASK_PROGRESS,this._onMp4Progress),this.mp4.on(T.kL.MOOV_REQ_PROGRESS,this._onMp4DataCallBack),this.mp4.MP4Loader.on("networkError",function(e){var t;null===(t=h.player)||void 0===t||t.emit("networkError",e)}),this.mp4.on(T.kL.LOAD_ERROR,function(e){var t;null===(t=h.player)||void 0===t||t.emit("source_error",e)}),this.mp4.on(T.kL.REMOVE_PCDN_NODE,function(e){h.pcdn&&e&&h.pcdn.removePCDNNode(e.vid,e.bitrate,e.url)}),this.mp4.on(T.kL.CHANGE_URL,function(e){h.player&&(h.player.emit("initialUrl",{url:e}),h.player.emit("changeHost",k.Z.getHostFromUrl(e)))}),this.mp4.on(T.kL.UPDATE_LOAD_IDX,(r=(0,n.x)((0,n.l5)().mark(function e(t){var r;return(0,n.l5)().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(r=h.mp4)||void 0===r?void 0:r.cancelLoading();case 2:h._curLoadSegmentIdx=t,h.log(d._.LOG,"[update curLoadSegmentIdx]",t);case 4:case"end":return e.stop()}},e)})),function(e){return r.apply(this,arguments)})),this.mp4.on(T.kL.CANCEL_LOADED_LEN,function(e){if(!!h.player){var t,r,n=y.vid,i=(null==e?void 0:e.load_type)||T._R.CDN,a=null===(t=h.mp4)||void 0===t?void 0:t.getCurSwitchPCDNCnt(),o=h._currDefinition,s=o.bitrate,l=o.definition,u=o.file_id;i===T._R.CDN?h.player.emit("prf_data_size",{vid:n,task_type:1,cdn_size:e.len,change_cnt:a,definition:l,bitrate:s,fileid:u}):h.player.emit("prf_data_size",{vid:n,task_type:1,pcdn_size:e.len,trace_id:null===(r=h.mp4)||void 0===r||null===(r=r.pcdnTraceInfo)||void 0===r?void 0:r.trace_id,change_cnt:a,definition:l,bitrate:s,fileid:u}),h.mp4&&h.mp4.updateLoadInfo(i,e.len),x.XO}}),this.mp4.MP4Loader.on(m.kW,function(e){B=e.speed,!h.debugInfo.speed&&(h.debugInfo.speed=[]),h.debugInfo.speed.push(B),h.debugInfo.speed.length>10&&h.debugInfo.speed.shift();var t=(null==e||null===(E=e.priOptions)||void 0===E?void 0:E.type)||T._R.CDN;h.emit(m.kW,(0,n.Zj)((0,n.Zj)({},e),{},{type:t}));var r=(null===(k=h.playerConfig)||void 0===k?void 0:k.vid)||(null==e?void 0:e.vid);if((null==e?void 0:e.len)>0){if(!h.player)return;var i=(null==e||null===(R=e.priOptions)||void 0===R?void 0:R.type)||T._R.CDN,a=(0,S.pl)(e.len,e.time),o=(null===(w=h.adaptRangeRes)||void 0===w?void 0:w.length)>0?h.adaptRangeRes.shift():{},s=o.cachedBufferDur,l=o.loadTarDuration,u=o.loadDuration,c=o.forceSetMin;o.idx;var d=o.PCDNInBuffer,f=o.PCDNOutBuffer,p=o.loadSize,g=null===(L=h.mp4)||void 0===L?void 0:L.getCurSwitchPCDNCnt(),v=h._currDefinition,y=v.bitrate,_={vid:r,task_type:1,buffer_dur:s||-1,load_tar_dur:l||-1,load_dur:u||-1,force_set_min:c,in_buf:d||-1,out_buf:f||-1,change_cnt:g,bitrate:y,definition:v.definition,fileid:v.file_id,load_size:p||-1,rtt:(null==e||null===(D=e.priOptions)||void 0===D?void 0:D.rtt)||0};i===T._R.CDN?(_.cdn_size=e.len,_.cdn_speed=a):(_.pcdn_size=e.len,_.pcdn_speed=a),h.player.emit("prf_data_size",_),x.XO;var b=e.index?null===(C=h.mp4)||void 0===C||null===(C=C.adaptTimeRange[e.index])||void 0===C||null===(C=C.timeRangeIdx)||void 0===C?void 0:C[1]:null;if(b&&b>=h.mp4.timeRange.length-1)for(;(null===(P=h.adaptRangeRes)||void 0===P?void 0:P.length)>0;){var E,k,R,w,L,D,C,P,A,O=h.adaptRangeRes.shift(),I=O.cachedBufferDur,M=O.loadTarDuration,N=O.loadDuration,U=O.forceSetMin,F=(O.idx,O.loadSize),V=O.PCDNInBuffer,G=O.PCDNOutBuffer,H=null===(A=h.mp4)||void 0===A?void 0:A.getCurSwitchPCDNCnt();_.buffer_dur=I||-1,_.load_tar_dur=M||-1,_.load_dur=N||-1,_.force_set_min=U||-1,_.in_buf=V||-1,_.out_buf=G||-1,_.load_size=F||-1,_.change_cnt=H,h.player.emit("prf_data_size",_),x.XO}h.mp4&&h.mp4.updateLoadInfo(i,e.len)}}),this.mp4.on(m.fD.MEDIA_LIST,function(e){var t;null===(t=h.player)||void 0===t||t.emit(m.fD.MEDIA_LIST,e)}),this.mp4.on(m.fD.FIRST_MET_MUX_NOT_CONTINUE,function(){h.emit(C)}),null!=g&&null!==(c=g.pcdnConfig)&&void 0!==c&&c.adaptPCDNConfig&&null!=g&&null!==(f=g.pcdnConfig)&&void 0!==f&&null!==(f=f.adaptPCDNConfig)&&void 0!==f&&f.PCDNBufferControl&&(null===(a=this.mp4)||void 0===a||a.setSwitchPCDNCallBack(function(){var e=h.pcdn;if(!e)return -1;var t=e.getPCDNChangeCnt()||-1;return h.log(d._.LOG,"[updateSwitchPCDNMaxCnt]",t),t})),this.changeState("MP4_INIT",{destroy:this.mp4.hasDestroyed}),this.emit("loadstart_mse"),this.mp4.bufferTimeFuncCallBack=function(){return v.bufferedPoint.end-v.currentTime},this.mp4.init(t),this._emitDefinitionChangeDetailEvent(0)}},{key:"_checkPreloader",value:(U=(0,n.x)((0,n.l5)().mark(function e(){var t,r,i,a,o,s,l,u,c,f,h,p,g;return(0,n.l5)().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r=(t=this.player).curDefinition,i=t.preloader,o=(a=Promise.withResolvers()).promise,s=a.resolve,l={method:"checkPreloader",success:0,type:"error",cacheKey:""},i){e.next=9;break}return this.changeState(m.fp.PRELOAD_ERROR,{t:2}),l.success=0,l.error=Error("no_preloader"),s(l),e.abrupt("return",o);case 9:if(u=this._getPreloadMeta(r),c=i.getDataUniqueKey(u),l.cacheKey=c,!c){e.next=46;break}return e.next=15,i.getPreLoadData(u);case 15:if(!(f=e.sent)){e.next=39;break}if(p=f.bitrate,g=f.orgDefinition,delete f.generateBy,!(p&&r.bitrate&&p!==r.bitrate)){e.next=27;break}return this.preLoadData=null,l.success=0,l.error=Error("bitrate_not_match_cut_".concat(r.bitrate,"_cache_").concat(p)),this.changeState(m.fp.PRELOAD_ERROR,{t:1,bitrate:p,ck:c}),s(l),this.log(d._.LOG,">>>check Preloader bitrate_not_match cacheKey".concat(c,"\n curDefinition:").concat(r.bitrate," cache:").concat(p)),e.abrupt("return",o);case 27:r.orgDefinition=g,x.i5,this.preLoadData=f,this.emit("PRELOAD_INFO",this.preLoadData),l.success=1,l.data=f,null===(h=this.preloader)||void 0===h||h.setUsePreloadInfo(c,!0),this.changeState(m.fp.PRELOAD_OK,{t:4,l:this.preLoadData.byteLength,ck:c}),f.mediaSegList&&f.mediaSegList.length>0||f.buffer&&f.buffer.byteLength>0?this.hitpreload=!0:this.hitpreload=!1,s(l),e.next=44;break;case 39:this.preLoadData=null,this.changeState(m.fp.PRELOAD_ERROR,{t:0,ck:c}),l.success=0,l.error=Error("none_preload"),s(l);case 44:e.next=50;break;case 46:this.changeState(m.fp.PRELOAD_ERROR,{t:3,ck:c}),l.success=0,l.error=Error("none_preload"),s(l);case 50:return e.abrupt("return",o);case 51:case"end":return e.stop()}},e,this)})),function(){return U.apply(this,arguments)})},{key:"_initEME",value:function(e){var t,r,n=this.config,a=n.kid,o=n.drmKeyToken,s=n.secretKey,l=n.keyValue,u=n.drm,f=n.useEME;if((a||o||s||l||u)&&f&&!(0,i.checkEMEValid)()){this.log(d._.ERROR,"checkEMEInValid"),this._errorHandler(new c.Errors(this.player,{errorType:_.iR.MEDIA,errorCode:_.O1.eme_hijack,errorMessage:"checkEMEInValid",vid:this.playerConfig.vid}));return}var h=this.player,p=this.config;this._updateDrmConfig(e),this.log(d._.LOG,"useEME: ",p.useEME),null===(t=this._secretkey)||void 0===t||t.setOptions('video/mp4; codecs="avc1.64001E"','audio/mp4; codecs="mp4a.40.2"'),null===(r=this._secretkey)||void 0===r||r.setupEME(h.video)}},{key:"_initMse",value:(F=(0,n.x)((0,n.l5)().mark(function e(t){var r,a=this,o,s,l,u,h,p,g,v,y,T,b,E,S,k,R,x,w,L,D=arguments;return(0,n.l5)().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(o=D.length>1&&void 0!==D[1]&&D[1],l=(s=this.config).kid,u=s.drmKeyToken,h=s.secretKey,p=s.keyValue,g=s.drm,v=s.useEME,!((l||u||h||p||g)&&v&&!(0,i.checkMSEValid)())){e.next=6;break}return this.log(d._.ERROR,"checkMSEInValid "),this._errorHandler(new c.Errors(this.player,{errorType:_.iR.MEDIA,errorCode:_.O1.mse_hijack,errorMessage:"checkMSEInValid",vid:this.playerConfig.vid})),e.abrupt("return");case 6:null===(r=this.player)||void 0===r||r.emit("codecsupdate",t.videoCodec),this.updateMSEDuration(),y=this.mp4&&this.mp4.checkCodecH265(),T=this.mp4&&this.mp4.checkCodecH266(),b=!!t.videoCodec,E=!!t.audioCodec,S=b&&E?y?'video/mp4; codecs="hev1.1.6.L93.B0, mp4a.40.5"':T?'video/mp4; codecs="bvc2.1.6.L93.B0, mp4a.40.5"':'video/mp4; codecs="avc1.64001E, mp4a.40.5"':b?y?'video/mp4; codecs="hev1.1.6.L93.B0"':T?'video/mp4; codecs="bvc2.1.6.L93.B0"':'video/mp4; codecs="avc1.64001E"':'video/mp4; codecs="mp4a.40.5"',k=(0,n._x)({},f.d1.VIDEO,{mimeType:"video/mp4",codec:S}),this.mse?this._bindSrcTiming===m.Iv.INIT?R=this.mse._openPromise:(this.log(d._.LOG,"MSE exist"),w=(x=Promise.withResolvers()).promise,L=x.resolve,R=w,L()):(this.log(d._.LOG,"new MSE",this._bindSrcTiming),this.mse=new f.d1,R=this.mse.bindMedia(this.player.video)),R.then(function(){if(!!a.mse){a.changeState("MSE_OPEN");try{var e=Object.keys(k).map(function(e){return a.mse.createOrChangeSource(e,k[e].codec)});Promise.all(e).then(function(){a.changeState("MSE_OPEN_DONE"),a._isMseInit=!0;var e=a.seekTimeAfterMetaReady;if(a.config.enableMsePatches&&a.player&&"number"==typeof e&&e>=0){var t=a.player.bufferedPoint;a.seekTimeAfterMetaReady=void 0,e>=t.start&&e<=t.end?a._onSeeking():a.player.currentTime=e}else try{a._onTimeUpdate()}catch(e){throw a.log(d._.ERROR,"MSE createOrChangeSource onTimeUpdate catch err: ",null==e?void 0:e.message),e}}).catch(function(){var e=(0,n.x)((0,n.l5)().mark(function e(t){var r;return(0,n.l5)().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return a.config.reUseMSE=!1,a.log(d._.WARN,"MSE createOrChangeSource catch err: ",null==t?void 0:t.message),e.next=4,null===(r=a.mse)||void 0===r?void 0:r.unbindMedia();case 4:a.mse=null,a._isMseInit=!1,o?a.MSEErrorHandle(t):a._initMse(a.mp4.meta,!0);case 7:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}())}catch(e){a.MSEErrorHandle(e)}}}),this.changeState("MSE_INIT");case 17:case"end":return e.stop()}},e,this)})),function(e){return F.apply(this,arguments)})},{key:"MSEErrorHandle",value:function(e){var t=new c.Errors(this.player,{errorType:_.iR.mse,errorCode:_.O1.mse,vid:this.playerConfig.vid,errorMessage:e.message,mediaError:{code:_.O1.mse,message:e.message}});this.log(d._.ERROR,"initMse error: ",null==e?void 0:e.message),this._errorHandler(t)}},{key:"_appendInitSeg",value:function(e){var t=this;if(!!this.mse&&!this._MSEError)this.changeState("MSE_INITSEG"),this.mse.append(f.d1.VIDEO,e,{vid:this.playerConfig.vid,range:null,dataLen:e.byteLength,isinit:!0}).then(function(e){t.changeState("MSE_INITSEG_OK",{costtime:null==e?void 0:e.costtime})}),this.config.useEME&&this._secretkey&&(this._secretkey.emit(i.EVENT_EME.ENCRYPTED),this.player.emit(i.EVENT_EME.ENCRYPTED))}},{key:"_checkMetaInfo",value:function(e){if(!e)return new c.Errors(this.player,{errorType:_.iR.DEMUX,errorCode:_.O1.metaError,errorMessage:"meta is null",vid:this.playerConfig.vid});var t,r=this.player.video||this.player.media,n=this.mp4.checkCodecH265(),i=this.mp4.checkCodecH266();if(this.changeState("MP4_META_READY",{isH265:n,isH266:i}),n&&(this.codecType!==a.u7.H265&&(this.codecType=a.u7.H265,this.log(d._.LOG,"codecType fix ".concat(this.codecType,", ").concat(e.videoCodec))),!this.softDecode&&!this.config.supportHevc)||i&&(this.codecType!==a.u7.H266&&(this.codecType=a.u7.H266,this.log(d._.LOG,"codecType fix ",this.codecType,e.videoCodec)),!(this.softDecode&&(null===(t=r.canPlayType)||void 0===t?void 0:t.call(r,'video/mp4; codecs="'.concat(e.videoCodec,'"')))==="probably")&&!this.config.supportVvcc))return this.notSupportError("".concat(this.codecType," - ").concat(e.videoCodec));var o=this.config,s=o.enableCheckTrackGap,l=o.trackGap;if(e.videoCodec&&e.audioCodec&&s){var u=e.moov.trak,f=e.moov.mvhd.timescale;if(Math.abs(this._getTrakDuration(u[0],f)-this._getTrakDuration(u[1],f))>l)return new c.Errors(this.player,{errorType:_.iR.DEMUX,errorCode:_.O1.metaError,errorMessage:"video track and audio track duration long gap, mse cannot play to end",vid:this.playerConfig.vid})}return null}},{key:"_getTrakDuration",value:function(e,t){return e.tkhd.duration/t}},{key:"_stopProgress",value:function(){this.log(d._.LOG,"stopProgress",this._hasStartProgress),this._hasStartProgress=!1,this._requestTimer&&this._requestTimer.stop(),this._bufferBreakTimer&&(clearTimeout(this._bufferBreakTimer),this._bufferBreakTimer=null,this._bufferBreakFlag=void 0),this._seekResumTimer&&(clearTimeout(this._seekResumTimer),this._seekResumTimer=null)}},{key:"checkReStartTimer",value:function(){var e=k.Z.nowTime()-this._lastTimeupdateTime2;e>2*this._tickInSeconds*1e3&&!this._offineLine&&(this.log(d._.LOG,"checkReStartTimer reStart timer",e,k.Z.nowTime()),this._stopProgress(),this._startProgress(),this._lastTimeupdateTime2=k.Z.nowTime())}},{key:"_bindNetworkStateChange",value:function(){window.addEventListener("online",this._onOnlineHandler),window.addEventListener("offline",this._onOfflineHandler)}},{key:"_unbindNetworkStateChange",value:function(){window.removeEventListener("online",this._onOnlineHandler),window.removeEventListener("offline",this._onOfflineHandler)}},{key:"_onSuperStart",value:function(e){var t=this,r=this.player;(0,x.cM)("_onSuperStart:".concat(e),this.mse),r.video.src=e,this.once("canplay",function(){r.play(),t.on("waiting",t._onWaiting)})}},{key:"_appendBuffer",value:function(e,t,r,n){var i=this,o=this.mse,s=this.playerConfig,l=this.player,u=s.vid;if(r=r||{},this.log(d._.LOG,"appendStart",r.fragIndex,JSON.stringify(r.range)),this._MSEError){this.log(d._.ERROR,"_MSEError, not append return");return}o.append(e,t,{vid:u,state:n,context:JSON.stringify(r)}).then(function(e){2===l.changeDefinitionSeekState&&(l.changeDefinitionSeekState=3,i.log(d._.LOG,"appendEnd changeDefinitionSeekState += 0.001"),l.currentTime+=.001);var t,a,o,s,u=i.getAllBufferRange(),c=null!=e&&null!==(t=e.context)&&void 0!==t&&t.context?JSON.parse(null==e||null===(a=e.context)||void 0===a?void 0:a.context):{};if(i.log(d._.LOG,"appendEnd ",null==c?void 0:c.fragIndex,JSON.stringify(null==c?void 0:c.range),", costTime,",null==e?void 0:e.costtime,", opt,",null==e?void 0:e.name,",buffer,",JSON.stringify(u),l.currentTime),!i.loadedDataEventRev){var f=(null==e?void 0:e.costtime)||0,h=i.states.findIndex(function(e){return"APPEND_DATA_OK"===e.state});h>=0?(i.states[h].data.cnt+=1,i.states[h].data.costtime+=f):i.changeState("APPEND_DATA_OK",{costtime:f,cnt:1})}if(i.mse&&n&&(null!==(o=i.mp4)&&void 0!==o&&o.checkIsLoadEnd(null===(s=r.range)||void 0===s?void 0:s[1])||i._loadedEnd)){var p=i.player.buffered;i._loadedEnd=!0;var g=0;p&&(null==p?void 0:p.length)>0&&(g=p.end(p.length-1)),i._isEnded(),i.log(d._.LOG,"loaded ended !!!===>>>",JSON.stringify(r.range),", fragIndex,",r.fragIndex,", bufferEndTime,",g,",meta_duration,",i.mp4.meta.duration)}}).catch(function(e){var t=i.player,n=i.mse;if(!i._hasFirstFramed&&i._setStartTimelines(a.l1.MSE_ERROR,{message:null==e?void 0:e.message}),!i._MSEError&&!!t){var o=t.media||t.video;if(e&&null!=n&&n.isFull()){i.log(d._.WARN,"[MSE is full]");var s=t.getBufferedRange();i._checkRemovePlayedBuffer(s,t.currentTime,!0)}else{var l,f,h,p,g="".concat(null!=o&&o.error?[o.error.code,o.error.message].join("-"):"MEDIA_EMPTY"),v="".concat((null==e?void 0:e.errorCode)||"","-").concat((null==e?void 0:e.errorMessage)||(null==e?void 0:e.message)||"MSE_EMPTY"),m="".concat(v,"|").concat(g);i._MSEError=!0,i.changeState("_MSEError",{fragIndex:null===(l=r)||void 0===l?void 0:l.fragIndex,range:null===(f=r)||void 0===f?void 0:f.range}),i.log(d._.LOG,"MSE append error",null===(h=r)||void 0===h?void 0:h.fragIndex,JSON.stringify(null===(p=r)||void 0===p?void 0:p.range));var y=new c.Errors(t,{errorType:_.iR.MEDIA,errorCode:_.O1.mseAppend,vid:u,errorMessage:m,mediaError:{code:_.O1.mseAppend,message:m}});i._errorHandler(y)}}})}},{key:"_loadData",value:(V=(0,n.x)((0,n.l5)().mark(function e(){var t,r;return(0,n.l5)().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(!this.mp4||!this._isMseInit&&!this.softDecode)){e.next=2;break}return e.abrupt("return");case 2:if(e.prev=2,t=this.player,r=h.l.info(h.l.get(t.media||t.video),t.currentTime),!(!this.config.alwaysStreamingLoad&&r.remaining>5)){e.next=10;break}return e.next=8,this.mp4.loadAllFragmentData(this._curLoadSegmentIdx,this._loadDataSuccess);case 8:e.next=12;break;case 10:return e.next=12,this.mp4.load(this._curLoadSegmentIdx,this._loadDataSuccess);case 12:e.next=17;break;case 14:e.prev=14,e.t0=e.catch(2),this.log(d._.ERROR,"[Index] _loadData error",this.playerConfig.vid,null===e.t0||void 0===e.t0?void 0:e.t0.message);case 17:case"end":return e.stop()}},e,this,[[2,14]])})),function(){return V.apply(this,arguments)})},{key:"_getPreloadMeta",value:function(e){var t=(0,S.F5)(e);return!t.vid&&(t={vid:this.playerConfig.vid,codecType:this.codecType,vtype:"MP4",bitrate:e.bitrate||0,mediaType:"video",definition:e.definition}),t}},{key:"getDataBitRate",value:function(e){var t=this.mp4,r=this.playerConfig;if(!t)return 0;for(var n=t.getDataBitRate(e),i=r.definition.list,a=0,o=0;i&&o<i.length;o++)if(i[o].bitrate===n){a=i[o];break}return a}},{key:"_loadStuckCheck",value:function(){var e=this,t=this.config,r=this.player;if(!t.disableBufferBreakCheck){if((!this.playerConfig.autoplay||this.softDecode)&&!this.playFlag)return;var n=r.isUserActive;if(r.currentTime-(this._lastCurrentTime||0)>.1||!n&&r.paused||n&&this.playFlag&&r.paused)(1===this._bufferBreakFlag||2===this._bufferBreakFlag)&&(this.log(d._.LOG,"视频没有卡死,重置卡死标记,curtime,",r.currentTime),this._bufferBreakFlag=0,clearTimeout(this._bufferBreakTimer),this._bufferBreakFlag=null);else if(!this._bufferBreakFlag){this._bufferBreakFlag=1;var i=JSON.stringify(this.getAllBufferRange()),a=this.getWaitingTimeOut();this.log(d._.LOG,"卡死计时开始! ".concat(a,"ms后确认卡死,"),r.currentTime,i),this._bufferBreakTimer=setTimeout(function(){if(!e.isDestroy&&!t.disableInactiveWaitingCheck&&(!!n||!r.paused)&&(!n||!e.playFlag||!r.paused)){if(1===e._bufferBreakFlag){var i=r.currentTime,a=r.bufferedPoint;if(a.end>0&&a.end-i>=2){e.retrySeekResum(i);return}}e._bufferBreakFlag=2,e.waitTimeoutDegrade()}},a)}this._lastCurrentTime=r.currentTime}}},{key:"getWaitingTimeOut",value:function(){var e=this.player,t=this.config.waitingTimeOut;if(!this.playFlag){var r,n=null===(r=e.curDefinition)||void 0===r?void 0:r.duration;if(n>0){var i=m.zb.find(function(e){return n>=e.range[0]&&n<e.range[1]});i&&(t=i.time)}}return t}},{key:"waitTimeoutDegrade",value:function(){var e,t=this.player;this.changeState("wait_timeout"),this.log(d._.LOG,"确认卡死!!!,curtime,",t.currentTime,JSON.stringify(this.getAllBufferRange()),",duration,",null===(e=this.mp4)||void 0===e||null===(e=e.meta)||void 0===e?void 0:e.duration),this.emit("waittimeout");var r=document.hidden||"hidden"===document.visibilityState,n=new c.Errors(this.player,{errorType:_.iR.RUNTIME,errorCode:r?_.O1.waitTimeoutWithHidden:_.O1.waitTimeout,errorMessage:"wait_timeout",vid:this.playerConfig.vid});this._errorHandler(n)}},{key:"retrySeekResum",value:(G=(0,n.x)((0,n.l5)().mark(function e(t){var r,i,a,o,s=this;return(0,n.l5)().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.player,i=this.config,this.changeState("retrySeek"),this.log(d._.LOG,"卡死但有超过2s的buffer,seek下!!!"),clearTimeout(this._seekResumTimer),this._resumePlay=!1,!(i.waitingRetrySeekTimes>0&&i.waitingRetryDuration)){e.next=14;break}return a=Math.min(i.waitingRetrySeekTimes,3),this._currentSeekTimes=0,this.off("playing",this._onResumePlaying),this.once("playing",this._onResumePlaying),o=function(){if(!r||s._resumePlay||r.paused){s.log(d._.LOG,"当前播放实例已恢复或处于暂停状态,退出重试 player=".concat(!!r,",_resumePlay=").concat(s._resumePlay,",paused=").concat(null==r?void 0:r.paused));return}if(s._currentSeekTimes<a){s._seekOnce(t),s._seekResumTimer=setTimeout(o,i.waitingRetryDuration);return}s.waitTimeoutDegrade(),s._seekResumTimer=null},this._seekOnce(t),this._seekResumTimer=setTimeout(o,i.waitingRetryDuration),e.abrupt("return");case 14:r.currentTime=t+1,this.once("playing",function(){s._resumePlay=!0}),this._seekResumTimer=setTimeout(function(){!s._resumePlay&&s.waitTimeoutDegrade(),s._seekResumTimer=null},Math.ceil(i.waitingTimeOut/2));case 17:case"end":return e.stop()}},e,this)})),function(e){return G.apply(this,arguments)})},{key:"_isInBuffer",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=!1,n=this.player.video.buffered,i=0;i<n.length;i++){var a=n.start(i)-t,o=n.end(i)+t;if(a<=e.startTime&&e.endTime<=o){r=!0;break}}return r}},{key:"_doubleCheckBuffer",value:function(e){var t=this.player;return!(e.startTime>t.currentTime)||!t.video||!t.video.buffered||1===t.video.buffered.length||this._isInBuffer(e,.2)}},{key:"isOpenPCDN",value:function(e){var t=this;if(this.pcdn&&this.mp4){var r=e-this.player.currentTime,n=this.pcdn,i=this.config,a=this.mp4,o=i.pcdnConfig,s=n.getPCDNInBuffer()||o.enterMinBuffer,l=n.getPCDNOutBuffer()||o.outMaxBuffer;if(r>=s){if(a.updatePCDNState(T.oy.OPEN),a.isUpdateNode){var u=this.player.curDefinition,c=u.uri,f=u.bitrate;this.pcdn.getPCDNNode(c,f,this.getPCDNReqId()).then(function(e){if(!!a){var r,i=t.getPCDNReqId();if(null!=e&&e.req_id&&i!==e.req_id){t.log(d._.LOG,",getPCDNNode is not match curDefinition reqId",i,", pcdnRet.req_id",e.req_id);return}a.updateNode(null==e?void 0:e.nodes),n.updatePCDNBitrate(f),e&&(a.pcdnTraceInfo={uri:e.vid,fid:e.fid,trace_id:null==e?void 0:e.trace_id}),e&&a.pcdnVVStat&&(a.pcdnVVStat.try_req_node+=1,a.pcdnVVStat.req_node_succ+=1,a.pcdnVVStat.has_ret_node+=(null==e||null===(r=e.nodes)||void 0===r?void 0:r.length)>0?1:0)}}).catch(function(e){(null==a?void 0:a.pcdnVVStat)&&(a.pcdnVVStat.try_req_node+=1),t.checkURLExpired(e,"_getPCDNNode")})}}else r<l&&a.updatePCDNState(T.oy.CLOSE)}}},{key:"checkURLExpired",value:function(e,t){var r,n,i,a,o=k.Z.checkUrlIsExpired(this.config._mainURL);1===o&&this.pcdn&&(this.pcdn=null);var s=(null==e||null===(r=e.response)||void 0===r?void 0:r.url)||(null===(n=this.config.pcdnConfig)||void 0===n?void 0:n.trackerUrl);null===(i=this.player)||void 0===i||i.emit("source_error",{host:k.Z.getHostFromUrl(s),src:s,errorCode:null==e||null===(a=e.response)||void 0===a?void 0:a.status,message:"".concat(null==e?void 0:e.message,"-").concat(o).concat(t)})}},{key:"pushTimerStep",value:function(){var e;(null===(e=this.timerStepList)||void 0===e?void 0:e.length)>m.zK&&this.timerStepList.shift(),this._lastTimeupdateTime2>0&&this.timerStepList.push(k.Z.nowTime()-this._lastTimeupdateTime2)}},{key:"_onTimeUpdate",value:function(){this.pushTimerStep(),this._lastTimeupdateTime2=k.Z.nowTime();var e=this.mse,t=this.mp4,r=this.player,n=this.config;if(!r)return;if((0,R.yx)()&&r.paused!==this._usePaused&&(this._usePaused?r.pause():r.play()),this.useVideoLoad||!t){this.useVideoLoad&&null!==(o=this.expiryCheckPlugin)&&void 0!==o&&null!==(o=o.config)&&void 0!==o&&o.enableExpiryCheck&&k.Z.nowTime()-this._lastCheckTime>1e3&&(this._lastCheckTime=k.Z.nowTime(),this._startUrlExpiredCheck());return}var i=r.getBufferedRange();k.Z.nowTime()-this._lastCheckTime>1e3&&(this._lastCheckTime=k.Z.nowTime(),this._loadStuckCheck(),this._startUrlExpiredCheck(),this._checkRemovePlayedBuffer(i,r.currentTime));var a=t.timeRange;if(!!a&&!(a.length<1)){if((e||this.mseProxy)&&this.canDownload&&!this._suspendLoading){var o,s,l,u=this._maxBufferLength,c=!1;(this.playFlag&&r.paused||!this.isActive)&&(c=!0),c?u=r.isInstNext&&this._nextBufferLength>=0?this._nextBufferLength:this._minBufferLength:null!==(l=this.config)&&void 0!==l&&null!==(l=l.adaptRange)&&void 0!==l&&l.targetCacheControl&&(u=this.adaptRange.getAdaptCacheBuffer()),!this.preLoadData&&null!==(s=this.config)&&void 0!==s&&null!==(s=s.adaptRange)&&void 0!==s&&s.targetCacheControl&&(u+=this.config.noPreloadAddBufferLen);var d=r.currentTime+u;i[1]-d<0&&(this.isOpenPCDN(i[1]),(null==n?void 0:n.loadRangeType)===m.TJ.SIZE?this.sizeRangeCheckLoad(c,u,i[1]-r.currentTime):this.gopRangeCheckLoad(c,u)),this.playFlag&&!this._hasTriggerBufferThreshold&&this._startBufferCheck()}}}},{key:"sizeRangeCheckLoad",value:function(e,t,r){var n=this.player,i=this.mp4;this.config;var a=i.adaptTimeRange,o=a.length,s=i.size-1||n.curDefinition.size-1;if(!(null!=a&&a.length)||(null===(u=a[o-1])||void 0===u?void 0:u.range[1])<s||!a[o-1].isLoading||i.changeBitRateTime>0){var l=a.findIndex(function(e){return!e.downloaded});if(!(null!=a&&a.length)||l>=0||a[o-1].downloaded){var u,c,f=this.calculateAdaptRange(e,t),h=f.adaptRangeRes,p=f.loadDuration;if(h.loadDuration=p,l<0?i.changeBitRateTime>0&&(null===(c=a[o-1])||void 0===c?void 0:c.range[1])>=s?(this._curLoadSegmentIdx=a.length-1,this.log(d._.LOG,"changeBitRateTime> 0 and load last adaptTime")):this._curLoadSegmentIdx=i.updateAdaptTimeRange(null,p):this._curLoadSegmentIdx=l,l>0&&i.changeBitRateTime<=0){var g=a[l-1];if(null!=g&&g.downloaded&&r>0&&(null==g?void 0:g.endTime)-n.currentTime>=t)return}var v=a[this._curLoadSegmentIdx];if(this._curLoadSegmentIdx>=0&&this._isInBuffer(v)&&this._removeBuffEndTime<=0&&this._curLoadSegmentIdx>=0&&v.endTime-v.startTime>1){this.log(d._.LOG,"onTimeUpdate, ".concat(this._curLoadSegmentIdx," download segment, has buffer: "),v.startTime,v.endTime,n.currentTime),v.downloaded=!0,v.isLoading=!0,i.seekTime<v.endTime&&(i.seekTime=v.endTime,this.log(d._.LOG,"".concat(this._curLoadSegmentIdx," download segment, has buffer adjust seekTime")));return}h.idx=this._curLoadSegmentIdx,this.adaptRangeResPush(h),(!a[this._curLoadSegmentIdx].isLoading||i.changeBitRateTime>0)&&(this.log(d._.LOG,"[onTimeUpdate],load index==>>>, ",this._curLoadSegmentIdx,JSON.stringify(a[this._curLoadSegmentIdx])),this._loadData())}}}},{key:"adaptRangeResPush",value:function(e){var t;(!this.adaptRangeRes.length||(null===(t=this.adaptRangeRes[e.length-1])||void 0===t?void 0:t.idx)!==this._curLoadSegmentIdx)&&(this.adaptRangeRes.push(e),this.log(d._.LOG,"adaptRangeRes>>>>",e))}},{key:"gopRangeCheckLoad",value:function(e,t){var r=this,n=this.player,i=this.mp4,a=i.timeRange,o=i.adaptTimeRange,s=i.changeBitRateTime;a.every(function(i,a){if(void 0!==i.adaptTimeRangeIdx&&i.adaptTimeRangeIdx>=0&&o&&o[i.adaptTimeRangeIdx].downloaded&&!(s>0&&i.adaptTimeRangeIdx===o.length-1&&o[i.adaptTimeRangeIdx].downloaded))return!0;var l=r.mp4.getAdaptIdxBySrcIdx(a,!0),u=l>=0?o[l]:null,c=l>=0&&r._isInBuffer(u);if(r._removeBuffEndTime<=0&&l>=0&&u.endTime-u.startTime>1&&c)return o[l].downloaded=!0,o[l].isLoading=!0,r.log(d._.LOG,"onTimeUpdate, ".concat(l," download segment, has buffer"),u.startTime,u.endTime,n.currentTime),!0;if(i.startTime-n.currentTime<t){var f,h=r.calculateAdaptRange(e,t),p=h.adaptRangeRes,g=h.loadDuration;r._curLoadSegmentIdx=r.mp4.updateAdaptTimeRange(a,g),p.idx=r._curLoadSegmentIdx,(null===(f=r.config)||void 0===f||null===(f=f.adaptRange)||void 0===f?void 0:f.rangeControl)&&(p.loadDuration=r.mp4.adaptTimeRange[r._curLoadSegmentIdx].duration),r.adaptRangeResPush(p);var v=o[r._curLoadSegmentIdx];if(r._isInBuffer(v))return v.downloaded=!0,v.isLoading=!0,r.log(d._.LOG,"onTimeUpdate_, ".concat(r._curLoadSegmentIdx," download segment, has buffer"),v.startTime,v.endTime,n.currentTime),!0;(!o[r._curLoadSegmentIdx].isLoading||s>0)&&(r.log(d._.LOG,"[onTimeUpdate],load index==>>>, ",r._curLoadSegmentIdx,JSON.stringify(o[r._curLoadSegmentIdx])),r._loadData())}})}},{key:"calculateAdaptRange",value:function(e,t){var r,n,i,a,o,s={forceSetMin:e};return null!==(r=this.pcdn)&&void 0!==r&&r.isOpenAdaptPCDN&&(s.PCDNInBuffer=this.pcdn.curPCDNInBuffer,s.PCDNOutBuffer=this.pcdn.curPCDNOutBuffer),!this.playFlag||e?a=this._minBufferLength:null!==(o=this.config)&&void 0!==o&&null!==(o=o.adaptRange)&&void 0!==o&&o.rangeControl?(a=this.adaptRange.getAdaptLoadDuration(),s.loadTarDuration=a):a=this.config.rangeMaxDuration,(null===(n=this.config)||void 0===n||null===(n=n.adaptRange)||void 0===n?void 0:n.targetCacheControl)&&(s.cachedBufferDur=t),!this.playFlag&&null!==(i=this.config)&&void 0!==i&&null!==(i=i.adaptRange)&&void 0!==i&&i.rangeControl&&(s.loadTarDuration=a),{adaptRangeRes:s,loadDuration:a}}},{key:"checkReUseMSE",value:function(e){var t=this,r=!(arguments.length>1)||void 0===arguments[1]||arguments[1],n=this.mse;if(!!n)if(e||this.config.reUseMSE){n.clearOpQueues(f.d1.VIDEO,r),this.mseAbort();var i,a=null===(i=this.player)||void 0===i?void 0:i.buffered;if((null==a?void 0:a.length)>0){var o=a.end(a.length-1);this.log(d._.LOG,"reUseMSE remove buffer, 0-",o),this._canUpdateDuration=!1,this.removeBuffer(f.d1.VIDEO,0,o,function(){var e;t._canUpdateDuration=!0,(null===(e=t.mp4)||void 0===e||null===(e=e.meta)||void 0===e?void 0:e.duration)&&t.updateMSEDuration()})}}else n.unbindMedia(),this.mse=null,this._unloadVideo()}},{key:"updateMSEDuration",value:function(){var e,t=this.mse,r=this.mp4;this._canUpdateDuration&&null!=r&&null!==(e=r.meta)&&void 0!==e&&e.duration&&r.meta.duration!==t.duration&&(this.log(d._.LOG,"updateMSEDuration ",r.meta.duration,",oldDuration,",t.duration),t.updateDuration(r.meta.duration),this._canUpdateDuration=null)}},{key:"_reset",value:function(){this._bindSrcTiming=m.Iv.META_READY,this._definitionChangePointInfo=null,this.adaptRangeRes=[],this.hitpreload=!1,this._sTime=k.Z.nowTime(),this._removeBuffEndTime=0,this._usePaused=!1,this.useVideoLoad=!1,this._isMseInit=!1,this.loadedDataEventRev=!1,this.needStarLoadFirstSegment=!1,this._curLoadSegmentIdx=0,this.emitExpireTimestamp=null,this.preLoadData=null,this.forPreloadTimeCache=null,this.playFlag=!1,this.waitLevelStartTime=-1,this._waitAdjustTimeCnt=0,this._firstMetFPSStuck=!1,this._initPromise&&"pending"===this._initPromise.state&&this._initPromise.reject(D),this.checkResumePlayTimer&&(clearTimeout(this.checkResumePlayTimer),this.checkResumePlayTimer=null),this._stopProgress(),this.mp4&&(this.mp4.destroy(),this.mp4=null),this.mseProxy&&(this.player.video.removeEventListener("lowdecode",this._onDegrade),this.player.video.removeEventListener("error",this._onError)),this.__onmetadataHandle&&(this.player.video.removeEventListener("loadedmetadata",this.__onmetadataHandle),this.__onmetadataHandle=null),this._unloadVideo(),this._cancelPendingPromises(),this._abrService&&(this._abrService.destroy(),this._abrService=null),this._waitInBufferTimer&&(clearTimeout(this._waitInBufferTimer),this._waitInBufferTimer=null),this.canDownload=!0,this._suspendLoading=!1,this._mediaCodec={videoCodec:"",audioCodec:""}}},{key:"removeErrorUrls",value:function(e,t,r){return e.errorCode===_.O1["403"]&&this._emitExpireEvent(e),r}},{key:"_setPlayerError",value:function(e){if(!this._hasFirstFramed){var t="".concat(this.player.vtype," ").concat(null==e?void 0:e.errorCode,"-").concat(null==e?void 0:e.errorMessage,"-").concat(null==e?void 0:e.rangeStart,"-").concat(null==e?void 0:e.rangeEnd);this._setStartTimelines(a.l1.PLAYER_ERROR,{message:t,httpCode:null==e?void 0:e.errorCode})}}},{key:"checkIsDegraded",value:function(e){var t=this.config,r=t.notDegradeErrorList,n=t.drm,i=t.kid,a=t.drmKeyToken,o=t.keyValue,s=t.secretKey;return!(n||i||a||o||s||e.errorCode>=7e3&&e.errorCode<=7999||(null==r?void 0:r.length)>0&&(e.errorCode===_.O1.timeout&&r.indexOf("timeout")>=0||e.errorCode===_.O1["403"]&&(r.indexOf(403)>=0||r.indexOf("403")>=0)||e.errorCode===_.O1["404"]&&(r.indexOf(404)>=0||r.indexOf("404")>=0)))&&!0}},{key:"_startDegradedPlayback",value:function(e,t){var r=this;this.canDownload=!1;var n=this.player,i=this.playerConfig,o=this.config;if(!n){this._setStartTimelines(a.l1.DESTROY,{message:"-degrade"});return}this.mse&&(this.mse.clearOpQueues(f.d1.VIDEO,!!o.enableMsePatches),this.mseAbort()),this._currentTime=n.currentTime||0,this.player.pause(),this._reset(),this.states=[],this._replay=null;var s=i.H264DefinitionList;if(this.codecType===a.u7.H265&&this.softDecode)this.log(d._.LOG,"h265 softDecode err,degrade use 264 play",i.vid),this._onDegrade(e);else if(this.codecType===a.u7.H264||o.supportHevc||o.supportVvcc||(null==s?void 0:s.length)>0){var l=o.drm,u=o.kid,c=o.drmKeyToken,h=o.keyValue,p=o.secretKey;if(l||u||c||h||p)l&&Object.keys(l).map(function(t){l&&(e[t]=l[t])}),this.log(d._.ERROR,"final error !!!!, ",i.vid,null==e?void 0:e.errorCode,null==e?void 0:e.errorMessage),this.emit("error",e);else{this.log(d._.LOG,this.codecType,"MSE degrade video,",i.vid,n.currentTime),this.emit(P,{errc:null==e?void 0:e.errorCode,err_msg:(null==e?void 0:e.errorMessage)||(null==e?void 0:e.message),CodecTypes:this.codecType,media_type:i.mediaType}),this.useVideoLoad=!0,this.__onmetadataHandle=function(){var e;if(!!r.player)r._currentTime&&(r.player.currentTime=r._currentTime),r.log(d._.LOG,"DegradedPlayback update currentTime",null===(e=r.playerConfig)||void 0===e?void 0:e.vid,r.codecType,r._currentTime),t?r.player.pause():r.player.play(),r.player.video.removeEventListener("loadedmetadata",r.__onmetadataHandle),r.__onmetadataHandle=null},n.video.addEventListener("loadedmetadata",this.__onmetadataHandle);var g,v=i.url;if((null==e||null===(g=e.message)||void 0===g?void 0:g.indexOf(m.eT))>=0&&(null==s?void 0:s.length)>0){var y=s.length,_=this.player.curDefinition.definition,T=_&&s.find(function(e){return e.definition===_});!T&&(i.H264DefinitionList.sort(function(e,t){return e.bitrate-t.bitrate}),T=i.H264DefinitionList[Math.floor(y/2)]),T&&(v=T.url,this.playerConfig.codecType=a.u7.H264,this.codecType=a.u7.H264)}this._setPlayerSrc(v)}}else this.log(d._.ERROR,"degrade player failed"),this.emit("error",e)}},{key:"mseAbort",value:function(){var e;if(null!==(e=this.mse)&&void 0!==e&&e.abort){var t=this.mse.abort(f.d1.VIDEO);if(t)return t.catch(function(){}),t}}},{key:"isSeekingInSameBuffer",value:function(e,t){var r=!1,n=this.mp4,i=this._lastBufferPoint;return n.meta&&n.meta.duration-t.end<.5&&(r=!0),i&&0!==e&&e>=i.start&&e<i.end&&(r=!0),this._lastBufferPoint=t,r}},{key:"getAdaptTimeRangeIdx",value:function(e){var t,r,n=this.config,i=this.adaptRange,a=n.segmentMinDuration;return i&&null!=n&&null!==(t=n.adaptRange)&&void 0!==t&&t.rangeControl&&(a=i.getAdaptLoadDuration()),null===(r=this.mp4)||void 0===r?void 0:r.updateAdaptTimeRange(e,a)}},{key:"_startProgress",value:function(){this.initTimer(),this._requestTimer.start(),this._hasStartProgress=!0}},{key:"_unloadVideo",value:function(){this.log(d._.LOG,"unloadVideo");var e=this.player;try{e.video&&e.video.src&&!/^blob/.test(e.currentSrc)&&!/^blob/.test(e.video.src)&&(this.log(d._.LOG,"unloadVideo src"),e.video.removeAttribute("src"),e.video.load())}catch(e){this.log(d._.ERROR,"unloadVideo error",null==e?void 0:e.message)}}},{key:"_addPendingPromise",value:function(e){this._pendingPromises.push(e)}},{key:"_removePendingPromise",value:function(e){this.log(d._.LOG,"removePendingPromise",null==e?void 0:e.id);var t=this._pendingPromises.indexOf(e);t>-1&&this._pendingPromises.splice(t,1)}},{key:"_cancelPendingPromises",value:function(){this._pendingPromises.length>0&&this._pendingPromises.forEach(function(e){e.reject(D)}),this._pendingPromises=[]}},{key:"_onMediaExpired",value:function(){this.log(d._.LOG,"MediaExpired stopProgress"),this._stopProgress(),this.emit(m.fD.MEDIA_EXPIRED)}},{key:"_isEnded",value:function(){var e,t,r,n,i=this.player,a=this.mp4;if(!i)return!1;var o=i.bufferedPoint,s=o?o.end:0;this.checkStartLoadFirstSegment(s);var l=i.currentTime;l>1&&s>l&&(s-l>=2||i.duration-l<1)&&2===i.video.readyState?k.Z.nowTime()-this._lastCheckLagTime>=3e3&&(this.log(d._.LOG,"[has buffer but waiting,seek 0.2 adjust],curTime,",l,", bufferend,",s,", duration,",null==a||null===(n=a.meta)||void 0===n?void 0:n.duration),i.currentTime=l+.2,this._lastCheckLagTime=k.Z.nowTime()):this._lastCheckLagTime=k.Z.nowTime();var u=(null===(e=i.buffered)||void 0===e?void 0:e.length)||0;if(u<=0||!i.buffered)return!1;var c=(null===(t=i.buffered)||void 0===t?void 0:t.end(u-1))||0;return!!(null!=a&&null!==(r=a.meta)&&void 0!==r&&r.duration&&a.meta.duration-i.currentTime<1&&(this._loadedEnd||1>Math.abs(a.meta.duration-c)))&&(this._stopProgress(),this.log(d._.LOG,"[isEnded],stopProgress and endOfStream,curTime, ",i.currentTime,", bufferend,",c,", duration,",a.meta.duration),this.mse&&this.mse.endOfStream().then(function(){}),!0)}},{key:"checkStartLoadFirstSegment",value:function(e){var t=this.player,r=this.mp4,n=this.config;if(!!t&&!!n.loadFirstGopData&&!!(null!=r&&null!==(i=r.meta)&&void 0!==i&&i.duration)&&!!(null!=t&&null!==(a=t.buffered)&&void 0!==a&&a.length)&&!!this.needStarLoadFirstSegment){if((this._loadedEnd||.5>Math.abs(e-this.mp4.meta.duration))&&t.buffered.start(0)>=r.timeRange[0].endTime){this.log(d._.LOG,"changeBitrate load end, reload loadFirstSegment"),this.needStarLoadFirstSegment=!1,r.resetDemuxSampleIdx(0),r._loadSuccessCallBack=this._loadDataSuccess;var i,a,o,s=(null===(o=r.timeRange[0])||void 0===o?void 0:o.range)||r.calculateRange(0);r.fillFirstSegment=!0,r.startLoad(s,0)}}}},{key:"_clearMediaKeys",value:function(){var e=this.player;e.video&&"function"==typeof e.video.setMediaKeys&&e.video.setMediaKeys(null).catch(function(){})}},{key:"_checkRemovePlayedBuffer",value:function(e,t,r,n){var i=this,a=this.mse,o=this.mp4,s=this.player;if(!a||!o||!s)return;if(r&&(clearTimeout(this._removeBufferTimer),this._removeBufferTimer=null),!e&&(e=s.getBufferedRange()),!t&&(t=s.currentTime),!(!r&&k.Z.nowTime()-this._checkRemoveBufferLastTime<=this.config.removeBufferLen)){if(this._checkRemoveBufferLastTime=k.Z.nowTime(),e&&e[0]>=0&&(t-e[0]>this.config.removeBufferLen||a.isFull())){var l=n?e[1]:t-(a.isFull()?0:15),u=o.getFragmentIdx(l);if(u>0&&(n||o.timeRange[u].startTime<t)){var c=Math.floor(Math.min(o.timeRange[u].startTime,e[1])),h=Math.max(o.timeRange[0].endTime+1,e[0]);h<c?(this.log(d._.LOG,"[checkremoveSourceBuffer], remove range==>>>",h,c,t),this.removeBuffer(f.d1.VIDEO,h,c)):a.isFull()&&!this._removeBufferTimer&&(this._removeBufferTimer=setTimeout(function(){i._checkRemovePlayedBuffer(null,null,!0)},1e4))}}}}},{key:"onMediaUpdate",value:function(e){var t=e.vid,r=e.kid,n=e.url,i=this.player,a=this.config;if(t===this.playerConfig.vid&&r===a.kid&&n){this.playerConfig.url=n,this._handlerUrl(n);var o=a._mainURL;return this.useVideoLoad?i.src=n:this.mp4&&this.mp4.updateUrl(o),!0}return!1}},{key:"enableAutoBuffer",value:function(e){var t=this;if(e){if(!this._allInitPromise){this.log(d._.LOG,"player destroyed!!");return}this._allInitPromise.then(function(){t.log(d._.LOG,"enableAutoBuffer true"),t._startProgress()})}else this._stopProgress(),this.log(d._.LOG,"enableAutoBuffer false")}},{key:"bitRateAdapter",get:function(){return this.player&&this.player.plugins?this.config.needAutoBitrate?this.player.plugins.bitrateselector:null:null}},{key:"getDefinitonFromAdapter",value:function(e,t){if(!this.bitRateAdapter)return null;var r=this.bitRateAdapter;return r.getSuitableBitrate?r.getSuitableBitrate(e,t):r.bitRateAdapter?r.bitRateAdapter.select(e):null}},{key:"log",value:function(e,t){for(var r=(this.playerConfig||{}).vid,n=r?"[Index]".concat(r," ").concat(t):"[Index] ".concat(t),i=arguments.length,a=Array(i>2?i-2:0),o=2;o<i;o++)a[o-2]=arguments[o];x.cM.apply(void 0,[this.logger,e,n].concat(a))}},{key:"_emitInitFail",value:function(e){this.log(d._.ERROR,"initFail, reason:",e),this.emit(m.fD.INIT_FAIL,e)}},{key:"useVideoLoad",get:function(){return this._useVideoLoad},set:function(e){this._useVideoLoad=e}},{key:"ready",get:function(){return this._allInitPromise}},{key:"speed",get:function(){return parseInt(T.Yx.speed,10)}},{key:"version",get:function(){return L.i}},{key:"realTimeSpeed",get:function(){return B}},{key:"opQueueLen",get:function(){var e=this.mse&&this.mse._queue?this.mse._queue[f.d1.VIDEO]:[];return e?e.length:0}},{key:"loadSegmentTimeRange",get:function(){return[0,0,0,0]}},{key:"moovSize",get:function(){return 0}},{key:"isDestroy",get:function(){return!this.player}},{key:"domain",get:function(){return k.Z.getHostFromUrl(this.loadURL)}},{key:"loadURL",get:function(){var e=this.player,t=e.currentSrc;return/^blob/.test(e.currentSrc)&&(t=this.mp4.currentLoadUseUrl()),t}},{key:"abrInstance",get:function(){return this._abrService?this._abrService.abrInstance:null}},{key:"expiryCheckPlugin",get:function(){return this.player&&this.player.plugins?this.player._customExpiryCheck?this.player.plugins.expirycheck:null:null}},{key:"isSuspendLoading",get:function(){return this._suspendLoading}},{key:"_handleUrlExpire",value:function(){var e=this,t=this.config,r=this.player,n=r.paused;new Date().getTime()/1e3>=this.urlExpireTimestamp&&this.urlExpireTimestamp>0&&!n&&t.getServerTime&&(r.serverTimeDiffPromise=r.serverTimeDiffPromise||t.getServerTime().catch(function(){return 0}),r.serverTimeDiffPromise.then(function(t){if(t&&(r.serverTimeDiff=new Date().getTime()/1e3-t),new Date().getTime()/1e3>=e.urlExpireTimestamp+r.serverTimeDiff){e.urlExpireTimestamp=new Date().getTime()/1e3+86400;var n=new _.oO("network",_.O1["403"]);e._emitExpireEvent(n)}}))}},{key:"_emitExpireEvent",value:function(e){var t=this.player,r=new Date().getTime()/1e3;return this.emitExpireTimestamp?!!(r-this.emitExpireTimestamp>300)&&(this.emitExpireTimestamp=r,t.emit("MEDIA_EXPIRED",e),!0):(this.emitExpireTimestamp=r,t.emit("MEDIA_EXPIRED",e),!0)}},{key:"reportBugPostPlayerLog",value:function(){this.log(d._.LOG,"reportBugPostPlayerLog"),this.emit(C)}},{key:"getAllBufferRange",value:function(){var e=[],t=this.player;if(!t||!(null!=t&&t.buffered))return e;var r=t.buffered;if(r)for(var n=0,i=r.length;n<i;n++)e.push([null==r?void 0:r.start(n),null==r?void 0:r.end(n)]);return e}}],[{key:"pluginName",get:function(){return"Mp4EncryptPlayer"}},{key:"defaultConfig",get:function(){return v.g}},{key:"speed",get:function(){return B}},{key:"realTimeSpeed",get:function(){return B}},{key:"version",get:function(){return L.i}}])}(u.q);U.isSupported=R.Gb,U.isEMESupported=R.KI,U.isSupportedWithXgmse=R.pU,U.isMediaSourceSupported=R.Hs,U.isWebAssemblySupported=R.qK,U.CUSTOM_EVENTS=m.fD,U.updateUnionInfo=i.XGSecretKey.updateUnionInfo,U.generateEncryptInfo=i.XGSecretKey.generateEncryptInfo,U.registerPreloader=u.q.registerPreloader,U.getSharedDynamicTimeoutIns=p.wN},538165:function(e,t,r){r.d(t,{P:function(){return i}});var n=r(261825);function i(e,t,r){var i=r.isOpen,s=r.vip_enable_downgrade,l=r.support_2k_down_1080,u=r.support_1080_down_720,c=r.support_720_down_540,d=r.isSupportSr;if(!i)return e;var f=e.isVip;if(!s&&f||!e.gearName||d&&d(e))return e;var h=null,p=function(e){if(e.width&&e.height){var t=Math.min(e.width,e.height);if(t>=2160)return o.Res2160p;if(t>=1440)return o.Res1440p;else if(t>=1080)return o.Res1080p;else if(t>=720)return o.Res720p;else if(t>=540)return o.Res540p;else if(t>=480)return o.Res480p;else if(t>=360)return o.Res360p}var r=e.qualityType;if(r){if(r>=70&&r<=74)return o.Res2160p;if(r>=6&&r<=7)return o.Res1440p;else if(r>=1&&r<=5)return o.Res1080p;else if(r>=10&&r<=19)return o.Res720p;else if(r>=20&&r<=29)return o.Res540p;else if(r>=30&&r<=39)return o.Res480p;else if(r>=40&&r<=49)return o.Res360p}var n=e.gearName;if(n){if(n.includes("2160"))return o.Res2160p;if(n.includes("1440"))return o.Res1440p;else if(n.includes("1080"))return o.Res1080p;else if(n.includes("720"))return o.Res720p;else if(n.includes("540"))return o.Res540p;else if(n.includes("480"))return o.Res480p;else if(n.includes("360"))return o.Res360p}return""}(e);return p===o.Res1440p&&l?h=a(e,"1080",t,d):p===o.Res1080p&&u?h=a(e,"720",t,d):p===o.Res720p&&c&&(h=a(e,"540",t,d)),!h&&(h=e),(0,n.Zj)((0,n.Zj)({},h),{},{type:"overscore",fromType:e.type,orgDefinition:e.definition})}function a(e,t,r,n){for(var i=t.toLowerCase(),a=0;a<r.length;a++){var o=r[a];if(r[a].gearName.toLowerCase().includes(i)&&o._xgOrgBitrate<e._xgOrgBitrate&&n(o))return r[a]}return null}r(303846),r(248385),r(706056),r(663030);var o={Res2160p:"4k",Res1440p:"2k",Res1080p:"1080p",Res720p:"720p",Res540p:"540p",Res480p:"480p",Res360p:"360p"}},832567:function(e,t,r){r.d(t,{Z:function(){return n}});let n=function(){try{if("undefined"!=typeof indexedDB)return indexedDB}catch(e){}}()},949195:function(e,t,r){r.d(t,{_:function(){return i}});var n=r(832641);function i(){return{autoPreload:!1,autoCheck:{enable:!1,interval:1e3},preloadMaxCacheCount:5,preloadCacheType:n.Rr.MEMORY,autoCheckPreload:!0,startPreloadControl:!1,startPreloadMinBuffer:5,startPreloadMinPosTime:5,minBufferLength:5,endPreloadControl:!1,endPreloadTaskStrategy:0}}},737756:function(e,t,r){function n(e,t,r){if(!e)return!1;var n=a(e.buffered,e.currentTime),i=t.startPreloadControl,o=t.startPreloadMinBuffer,s=t.startPreloadMinPosTime,l=t.minBufferLength;if(i){var u=Math.max(n[1]-e.currentTime,0);if("number"==typeof o&&u>o){if("number"==typeof s&&e.currentTime>s||e.currentTime>e.duration/2)return null==r||r("log","[checkIfStartPreload] hit buffer",u,"startPreloadMinBuffer",o),!0}else if(e.currentTime+o+1>e.duration&&e.currentTime+u>e.duration-1)return null==r||r("log","[checkIfStartPreload] hit end"),!0}else{var c="number"==typeof l&&e.duration>l+5?l:e.duration/2,d=Math.min(e.currentTime+l,e.duration),f=n[1]-d;if(e.currentTime>c&&f>-1)return null==r||r("log","[checkIfStartPreload] hit minPos",c,"minCacheTime",d),!0}return!1}function i(e,t,r){var n=t.endPreloadControl,i=t.endPreloadMinBuffer,o=t.startPreloadMinBuffer;if(!e)return!1;if(n){if("number"==typeof o&&e.currentTime+o>=e.duration)return!1;var s=Math.max(a(e.buffered,e.currentTime)[1]-e.currentTime,0);if(s<=i)return null==r||r("log","[checkIfCancelPreload] hit buffer:",s,"endPreloadMinBuffer:",i,"video:","".concat(e.currentTime,"/").concat(e.duration)),!0}return!1}function a(e,t){var r=[0,0];if(e)for(var n=0,i=e.length;n<i&&(r[0]=e.start(n),r[1]=e.end(n),!(r[0]<=t)||!(t<=r[1]));n++);return r[0]-t<=0&&t-r[1]<=0?r:[0,0]}function o(e,t,r){for(var n=0;n<e.length;n++)if(r===e[n][t])return n;return -1}r.d(t,{PK:function(){return o},fQ:function(){return i},lh:function(){return a},xF:function(){return n}}),r(346984)},330124:function(e,t,r){function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}r.d(t,{$w:function(){return o},Ac:function(){return S},Kd:function(){return m},PA:function(){return s},XW:function(){return h},ZQ:function(){return T},Zj:function(){return v},_x:function(){return d},l5:function(){return y},qH:function(){return u},sf:function(){return c},u:function(){return b},x:function(){return a}});function i(e,t,r,n,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void r(e)}s.done?t(l):Promise.resolve(l).then(n,i)}function a(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var o=e.apply(t,r);function s(e){i(o,n,a,s,l,"next",e)}function l(e){i(o,n,a,s,l,"throw",e)}s(void 0)})}}function o(e,t,r){return t=f(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,p()?Reflect.construct(t,r||[],f(e).constructor):t.apply(e,r))}function s(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}function l(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,E(n.key),n)}}function u(e,t,r){return t&&l(e.prototype,t),r&&l(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=k(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function d(e,t,r){return(t=E(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function h(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_(e,t)}function p(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(p=function(){return!!e})()}function g(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function v(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?g(Object(r),!0).forEach(function(t){d(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):g(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function m(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r={};for(var n in e)if(({}).hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],-1===t.indexOf(r)&&({}).propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function y(){y=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function c(t,r,n,a){var o=Object.create((r&&r.prototype instanceof v?r:v).prototype);return i(o,"_invoke",{value:function(t,r,n){var i=f;return function(a,o){if(i===h)throw Error("Generator is already running");if(i===p){if("throw"===a)throw o;return{value:e,done:!0}}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var l=function t(r,n){var i=n.method,a=r.iterator[i];if(a===e)return n.delegate=null,"throw"===i&&r.iterator.return&&(n.method="return",n.arg=e,t(r,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=TypeError("The iterator does not provide a '"+i+"' method")),g;var o=d(a,r.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,g;var s=o.arg;return s?s.done?(n[r.resultName]=s.value,n.next=r.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):s:(n.method="throw",n.arg=TypeError("iterator result is not an object"),n.delegate=null,g)}(s,n);if(l){if(l===g)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===f)throw i=p,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=h;var u=d(t,r,n);if("normal"===u.type){if(i=n.done?p:"suspendedYield",u.arg===g)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=p,n.method="throw",n.arg=u.arg)}}}(t,n,new L(a||[]))}),o}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=c;var f="suspendedStart",h="executing",p="completed",g={};function v(){}function m(){}function _(){}var T={};u(T,o,function(){return this});var b=Object.getPrototypeOf,E=b&&b(b(D([])));E&&E!==r&&n.call(E,o)&&(T=E);var S=_.prototype=v.prototype=Object.create(T);function k(e){["next","throw","return"].forEach(function(t){u(e,t,function(e){return this._invoke(t,e)})})}function R(e,t){var r;i(this,"_invoke",{value:function(i,a){function o(){return new t(function(r,o){!function r(i,a,o,s){var l=d(e[i],e,a);if("throw"!==l.type){var u=l.arg,c=u.value;return c&&"object"==typeof c&&n.call(c,"__await")?t.resolve(c.__await).then(function(e){r("next",e,o,s)},function(e){r("throw",e,o,s)}):t.resolve(c).then(function(e){u.value=e,o(u)},function(e){return r("throw",e,o,s)})}s(l.arg)}(i,a,r,o)})}return r=r?r.then(o,o):o()}})}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function w(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function D(t){if(t||""===t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw TypeError(typeof t+" is not iterable")}return m.prototype=_,i(S,"constructor",{value:_,configurable:!0}),i(_,"constructor",{value:m,configurable:!0}),m.displayName=u(_,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===m||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,_):(e.__proto__=_,u(e,l,"GeneratorFunction")),e.prototype=Object.create(S),e},t.awrap=function(e){return{__await:e}},k(R.prototype),u(R.prototype,s,function(){return this}),t.AsyncIterator=R,t.async=function(e,r,n,i,a){void 0===a&&(a=Promise);var o=new R(c(e,r,n,i),a);return t.isGeneratorFunction(r)?o:o.next().then(function(e){return e.done?e.value:o.next()})},k(S),u(S,l,"Generator"),u(S,o,function(){return this}),u(S,"toString",function(){return"[object Generator]"}),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=D,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(w),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return s.type="throw",s.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var l=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(l&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(l){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,g):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),w(r),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;w(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:D(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),g}},t}function _(e,t){return(_=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function T(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,a,o,s=[],l=!0,u=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=a.call(r)).done)&&(s.push(n.value),s.length!==t);l=!0);}catch(e){u=!0,i=e}finally{try{if(!l&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw i}}return s}}(e,t)||k(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||k(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function E(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function S(e){return(S="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function k(e,t){if(e){if("string"==typeof e)return n(e,t);var r=({}).toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}},613753:function(e,t,r){r.d(t,{N:function(){return i}});var n=r(730210);r(932651);var i=(0,n.qH)(function e(t,r){(0,n.PA)(this,e),this.config=t,this.instManager=r},[{key:"updateConfig",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!!e)t?Object.assign(this.config,e):this.config=e}}])},340343:function(e,t,r){r.d(t,{Q:function(){return a}});var n=r(137263);r(162093),r(2885),r(248385);var i=r(4610),a=(0,n.qH)(function e(t,r,i,a){var o=this;(0,n.PA)(this,e),this.config=e.getDefaultConfig(),this.bitrate=0,this.lastAdaptCacheBuffer=0,a&&Object.keys(a).map(function(e){void 0!==a[e]&&null!==a[e]&&(o.config[e]=a[e])}),this.duration=i,this.player=t,this.updateBitrate(r)},[{key:"updateBitrate",value:function(e){this.bitrate=e,!this.bitrate&&(this.bitrate=this.config.minBandwidth)}},{key:"getAdaptLoadDuration",value:function(){var e=this.player,t=this.config;if(!t.rangeControl)return -1;var r=(null==e?void 0:e.bufferedPoint)||null,n=e&&null!=r&&r.end?r.end-e.currentTime:0;if(t.use_weibull){var a=this.calcToPlayDurationMs(t.cdf_for_playing_media_low)/1e3;a>this.lastAdaptCacheBuffer&&(a=this.lastAdaptCacheBuffer);var o=0;return n<a?o=a-n:n<this.lastAdaptCacheBuffer&&(o=this.lastAdaptCacheBuffer-n),e&&o+n>e.duration&&(o=e.duration-n),(0,i.uZ)(o,t.rangeMinDuration,t.rangeMaxDuration)}return Math.max(t.rangeMaxDuration-n,t.rangeMinDuration)}},{key:"getAdaptCacheBuffer",value:function(){var e=this.player,t=this.config,r=this.bitrate;if(!t.targetCacheControl)return this.lastAdaptCacheBuffer=-1,-1;var n=t.estPlayTime,i=(null==e?void 0:e.currentTime)||0,a=n;t.use_weibull?a=this.calcToPlayDurationMs(t.cdf_for_playing_media_buffer)/1e3:t.estPTcontrol&&(a=Math.min(n,(this.duration||(null==e?void 0:e.duration)||0)-i));var o=t.playbackRateControl&&e?e.playbackRate:1,s=e&&1024*e.avgSpeed/o||0,l=Math.max(t.safeFactor*s,t.minBandwidth);null!=e&&e.avgSpeed&&(l=t.safeFactor*s);var u=r>0?Math.floor((1-l/r)*a):0;return u=t.minDangerThreshold+Math.max(u,0),this.lastAdaptCacheBuffer=Math.min(Math.max(t.cacheSafeFactor*u,t.minTargetCacheDur),t.maxTargetCacheDur),this.lastAdaptCacheBuffer}},{key:"calcToPlayDurationMs",value:function(e){var t,r=this.player,n=this.config,a=null==r||null===(t=r.config)||void 0===t||null===(t=t.mediaInfo)||void 0===t?void 0:t.play_time_prob_dist,o=(0,i.eq)(a,n.default_weibull_param||i.XB),s=1e3*(this.duration||(null==r?void 0:r.duration)||0),l=1e3*((null==r?void 0:r.currentTime)||0),u=(0,i.cF)(o,e,s,l)-l;return u=(0,i.uZ)(u,n.min_to_play_ms,n.max_to_play_ms)}}],[{key:"getDefaultConfig",value:function(){return{rangeMaxDuration:15,rangeMinDuration:5,rangeMinSize:409600,safeFactor:.1,cacheSafeFactor:3,minDangerThreshold:5,estPlayTime:12,minBandwidth:1e6,estPTcontrol:!1,minTargetCacheDur:30,maxTargetCacheDur:60,targetCacheControl:!1,rangeControl:!1,playbackRateControl:!1,use_weibull:!1,default_weibull_param:i.XB,cdf_for_playing_media_buffer:.5,cdf_for_playing_media_low:.25,min_to_play_ms:1e3,max_to_play_ms:5e3}}}])},740651:function(e,t,r){r.d(t,{q:function(){return l}});var n,i=r(137263),a=r(734123),o=r(830571),s=r(373974),l=function(e){function t(e){(0,i.PA)(this,t);var r,a=(r=(0,i.$w)(this,t,[e])).player,o=r.playerConfig;return r.playerId=a.playerId,r.codecType=o.codecType?o.codecType.toLowerCase():s.u7.H264,r.bizType=a.bizType="number"==typeof o.bizType?o.bizType:s.Ye.Normal,o.vtype&&(r.vtype=o.vtype.toUpperCase()),n&&(a.preloader=n),r}return(0,i.XW)(t,e),(0,i.qH)(t,[{key:"softDecode",get:function(){var e;return(null===(e=this.playerConfig)||void 0===e?void 0:e.mediaType)==="xg-video"}}],[{key:"registerPreloader",value:function(e){if(!!e)n=e,o.w.getInstance().findAll(function(e){return!e.config.isLive&&(e.preloader=n),!1})}}])}(a.BasePlugin)},373974:function(e,t,r){r.d(t,{Ye:function(){return l},_R:function(){return d},kW:function(){return c},l0:function(){return s},l1:function(){return f},sm:function(){return h},u7:function(){return u}});var n,i,a,o=r(137263);var s=((n=s||{}).MP4="MP4",n.MP4_MSE_SOFT="MP4_MSE_SOFT",n.MP4_MSE="MP4_MSE",n.MP4_0="MP4_0",n.MP4_1="MP4_1",n.MP4_2="MP4_2",n.DASH="DASH",n.HLS="HLS",n);var l=((i=l||{})[i.Normal=0]="Normal",i[i.Ad=1]="Ad",i);var u=((a=u||{})[a.AVC=0]="AVC",a[a.HEVC=1]="HEVC",a[a.VVC=2]="VVC",a.H264="h264",a.H265="h265",a.H266="h266",a),c="real_time_speed",d={CDN:"cdn",PCDN:"pcdn"},f={BEFEORE_START:0,NOT_SUPPORTED:1,START_INIT_DESTROY:2,NO_PRELOAD:3,CLOSE_DWNGRADE:4,INIT_PROMISE_CATCH:5,PLAYER_ERROR:6,HTTP_ERROR:7,MSE_ERROR:8,DESTROY:9},h=(0,o._x)((0,o._x)((0,o._x)((0,o._x)((0,o._x)((0,o._x)((0,o._x)((0,o._x)((0,o._x)((0,o._x)({},f.BEFEORE_START,"before start"),f.NOT_SUPPORTED,"codec not support"),f.START_INIT_DESTROY,"start init destroy"),f.NO_PRELOAD,"no preload"),f.CLOSE_DWNGRADE,"close downgrade"),f.INIT_PROMISE_CATCH,"init promise catch"),f.PLAYER_ERROR,"player error"),f.HTTP_ERROR,"http error"),f.MSE_ERROR,"mse error"),f.DESTROY,"destroy")},428235:function(e,t,r){r.d(t,{Z:function(){return a}});var n=function(){return i&&!function(){var e="_localstorage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch(e){return!0}}()}();function i(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}let a={length:n?localStorage.length:0,clear:function(e){try{for(var t=localStorage.length-1;t>=0;t--){var r=localStorage.key(t);0===r.indexOf(e)&&localStorage.removeItem(r)}}catch(e){}},getItem:function(e){try{return localStorage.getItem(e)}catch(e){return null}},key:function(e){try{return localStorage.key(e)}catch(e){return null}},setItem:function(e,t){try{localStorage.setItem(e,t)}catch(e){}},removeItem:function(e){try{localStorage.removeItem(e)}catch(e){}},isSupport:n}},510142:function(e,t,r){r.d(t,{l:function(){return i}});var n=r(204885);function i(){(0,n.z)()}},165436:function(e,t,r){r.d(t,{Z:function(){return i}});var n=r(405935);r(248385),r(679308);var i=function(){function e(){(0,n.PA)(this,e);var t,r,i=new Promise(function(e,n){t=e,r=n});return i.resolve=t,i.reject=r,i}return(0,n.qH)(e,[{key:"resolve",value:function(e){}},{key:"reject",value:function(e){}}]),e}()},92956:function(e,t,r){r.d(t,{Z:function(){return i}});var n=r(405935),i=function(){function e(){(0,n.PA)(this,e)}return(0,n.qH)(e,null,[{key:"install",value:function(){if(window.requestAnimationFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame,window.cancelAnimationFrame=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.cancelRequestAnimationFrame||window.webkitCancelRequestAnimationFrame||window.mozCancelRequestAnimationFrame,!window.requestAnimationFrame){var e=Date.now();window.requestAnimationFrame=function(t){var r=Date.now(),n=Math.max(16.7-(r-e),0),i=setTimeout(t,n);return e=r+n,i}}!window.cancelAnimationFrame&&(window.cancelAnimationFrame=function(e){clearTimeout(e)})}}]),e}()},227346:function(e,t,r){r.d(t,{p:function(){return n}});function n(e,t,r){var n;return function(i){var a,o,s,l,u,c,d;return new Worker(n=n||(a=e,o=t,s=r,l=void 0===o?null:o,c=(u=function(e,t){var r=atob(e);if(t){for(var n=new Uint8Array(r.length),i=0,a=r.length;i<a;++i)n[i]=r.charCodeAt(i);return String.fromCharCode.apply(null,new Uint16Array(n.buffer))}return r}(a,void 0!==s&&s)).indexOf("\n",10)+1,d=new Blob([u.substring(c)+(l?"//# sourceMappingURL="+l:"")],{type:"application/javascript"}),URL.createObjectURL(d)),i)}}},773975:function(e,t,r){r.d(t,{Z:function(){return d}});var n=r(315355),i=r(919209),a=r(272787);r(60998),r(162093),r(705574),r(346984);var o=r(155363),s=r(874668),l=r(597931),u={FIRST_DATA:1,AUDIO_MSE_OPEN_START:2,AUDIO_MSE_OPEND:3,AUDIO_FIRSTTIME_APPENDED:4,AUDIO_READY:5,WASM_WORKER_INIT:6,WASM_WORKER_READY:7,FIRST_FRAME_TODECODE:8,VIDEO_READY:9,FIRST_FRAME:10,WAITIGN:11,SEEKING:12,SEEKED:13},c=Object.entries(u),d=function(){function e(){(0,n.Z)(this,e),(0,a.Z)(this,"_dot",[]),(0,a.Z)(this,"_currentLowDecodeCount",0)}return(0,i.Z)(e,[{key:"getBootStats",value:function(){var e,t=(null===(e=this._dot[0])||void 0===e?void 0:e.dot)||0;return this._dot.map(function(e){return{action:c.filter(function(t){return t[1]===e.action})[0][1],dot:parseInt(e.dot-t)}})}},{key:"getStats",value:function(e){var t,r=this.getBootStats(),n=r.length;return{bootStats:r,currentState:n?r[n-1].action:0,bitrate:Math.abs(e.bitrate/1e3),decodeFps:e.decodeFps,fps:e.fps,playbackRate:e.playbackRate,firstframe:null===(t=r.filter(function(e){return 10===e.action})[0])||void 0===t?void 0:t.dot,width:e.videoWidth,height:e.videoHeight,decoderMode:e.decoderMode,vv:(0,o.HQ)(),lowdecodeVV:(0,o.Vw)(),h265FailureRate:Math.floor((0,o.Vw)()/(0,o.HQ)()*100),currentLowDecodeCount:this._currentLowDecodeCount}}},{key:"seekElapses",value:function(){for(var e=this.getBootStats(),t=[],r=0,n=0,i=e.length;n<i;n++){var a=e[n];a.action===u.SEEKING&&(r=a.dot),a.action===u.SEEKED&&t.push(a.dot-r)}return t}},{key:"addFirstData",value:function(){this._dot.push({action:u.FIRST_DATA,dot:this._getTimestap()})}},{key:"addAudioBoundMedia",value:function(){this._dot.push({action:u.AUDIO_BOUND_MEDIA,dot:this._getTimestap()})}},{key:"addAudioMseOpenStart",value:function(){this._dot.push({action:u.AUDIO_MSE_OPEN_START,dot:this._getTimestap()})}},{key:"addAudioMseOpend",value:function(){this._dot.push({action:u.AUDIO_MSE_OPEND,dot:this._getTimestap()})}},{key:"addAudioFirstTimeAppended",value:function(){this._dot.push({action:u.AUDIO_FIRSTTIME_APPENDED,dot:this._getTimestap()})}},{key:"addAudioReady",value:function(){this._dot.push({action:u.AUDIO_READY,dot:this._getTimestap()})}},{key:"addWasmInit",value:function(){this._dot.push({action:u.WASM_WORKER_INIT,dot:this._getTimestap()})}},{key:"addWasmReady",value:function(){this._dot.push({action:u.WASM_WORKER_READY,dot:this._getTimestap()})}},{key:"addFirstFrameToDecode",value:function(){this._dot.push({action:u.FIRST_FRAME_TODECODE,dot:this._getTimestap()})}},{key:"addVideoReady",value:function(){this._dot.push({action:u.VIDEO_READY,dot:this._getTimestap()})}},{key:"addFirstframe",value:function(){this._dot.push({action:u.FIRST_FRAME,dot:this._getTimestap()});var e,t=null===(e=this.getBootStats().filter(function(e){return 10===e.action})[0])||void 0===e?void 0:e.dot;if(t>=1300){(0,o.DO)(1);return}if(t>=1e3){(0,o.DO)(3);return}t>=500&&(0,o.Dd)()}},{key:"addWaiting",value:function(){this._dot.push({action:u.WAITIGN,dot:this._getTimestap()})}},{key:"addSeeking",value:function(){this._dot.push({action:u.SEEKING,dot:this._getTimestap()})}},{key:"addSeeked",value:function(){this._dot.push({action:u.SEEKED,dot:this._getTimestap()})}},{key:"_getTimestap",value:function(){return performance.now()}},{key:"increaseLowDecodeCount",value:function(e){this._currentLowDecodeCount++,this._currentLowDecodeCount>=1&&e<=(0,s.tT)().tempDisabledThreshold&&(l.kg.warn("Analyse","disabled!, fps=".concat(e,", threshold=").concat((0,s.tT)().tempDisabledThreshold)),(0,o.DO)(2))}},{key:"reset",value:function(){this._currentLowDecodeCount=0,this._dot=[]}}]),e}()},685290:function(e,t,r){r.d(t,{Z:function(){return o},s:function(){return a}});var n=r(315355),i=r(919209);function a(e){var t;(null===(t=e.buffer)||void 0===t?void 0:t.close)&&e.buffer.close()}r(9498),r(705574),r(663030);var o=function(){function e(t){(0,n.Z)(this,e),this.TAG="FrameQueue",this._parent=t,this._lastGopId=0,this._frames=[]}return(0,i.Z)(e,[{key:"currentTimeDts",get:function(){return this._parent.preciseVideoDts}},{key:"length",get:function(){return this._frames.length}},{key:"frames",get:function(){return this._frames}},{key:"append",value:function(e){if(!e.info){a(e);return}this._frames.push(e)}},{key:"appendVodFrame",value:function(e){this._frames.push(e)}},{key:"nextFrame",value:function(){var e=this._frames.length;return 1===this._parent.noAudio&&e>3&&(this._frames=this._frames.slice(e-2)),this._frames[0]}},{key:"shift",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=this._frames.shift();return this.deletePassed(e),t}},{key:"deletePassed",value:function(e){this._frames=this._frames.filter(function(t){return!!t.info&&!!(t.info.dts>e)||(a(t),!1)})}},{key:"empty",value:function(){this._frames.forEach(function(e){return a(e)}),this._frames=[]}},{key:"destroy",value:function(){this.empty(),this._lastGopId=0}}]),e}()},830361:function(e,t,r){r.d(t,{Z:function(){return c}});var n=r(264911),i=r(315355),a=r(919209),o=r(272787);r(124300),r(248385),r(591111),r(490629),r(656562);var s=r(597931),l=r(874668),u=[],c=function(){function e(t,r,a){var s=this;(0,i.Z)(this,e),(0,o.Z)(this,"TAG","RenderWorker"),(0,o.Z)(this,"timerWorkerCache",u),(0,o.Z)(this,"_errorOccur",!1),(0,o.Z)(this,"_doTask",function(e){var t,r;if("NEXT_TICK"===e.data.type){null===(t=s._task)||void 0===t||t.call(s);return}if("RENDER_ERR"===e.data.type){s._emitError(e.data.msg);return}"RESIZE_EVENT"===e.data.type&&(null===(r=s._parent)||void 0===r||r.emitResizeEvent())}),(0,o.Z)(this,"_onError",function(e){s._emitError(e.message)}),(0,o.Z)(this,"_emitError",function(e){s._errorOccur=!0,s._worker&&(s._worker._cvs=null,s._worker._offscreen=null),s._cvs&&(s._cvs._worker=null),s._parent._emitError(e,3)}),this._task=t,this._parent=a;var l=this._initCanvasWorkerPair(r),c=(0,n.Z)(l,2),d=c[0],f=c[1];f&&(this._worker=f,this._cvs=d,this._bindEvent())}return(0,a.Z)(e,[{key:"canvas",get:function(){return this._cvs}},{key:"_initCanvasWorkerPair",value:function(e){var t,r=this,n=e.canvas||(null===(t=u.pop())||void 0===t?void 0:t._cvs)||document.createElement("canvas");if(n.style.margin="auto",n.style.position="absolute",n.style.pointerEvents="none",n._worker)return s.kg.log(this.TAG,"init canvas && worker, use cached,",n.width,n.height),[n,n._worker];try{var i=new Blob(["\n class FrameRender {\n constructor (configs) {\n this.TAG = 'FrameRender'\n this.configs = Object.assign({}, configs)\n this.canvas = this.configs.canvas\n this.meta = Object.assign({}, this.configs.meta)\n this._initMeta()\n this._initContextGL()\n if (this.contextGL) {\n this._initProgram()\n this._initBuffers()\n this._initTextures()\n }\n }\n\n _initMeta () {\n this.chroma = this.meta.chromaFormat\n this.height = this.meta.height\n this.width = this.meta.width\n if (this.canvas.width !== this.meta.width || this.canvas.height !== this.meta.height) {\n this.canvas.width = this.meta.width\n this.canvas.height = this.meta.height\n self.postMessage({\n type: 'RESIZE_EVENT'\n })\n }\n this.clear()\n }\n\n _initContextGL () {\n if (this.configs.type === '2d') {\n this.ctx = this.canvas.getContext('2d')\n return\n }\n var canvas = this.canvas\n let gl = null\n\n var validContextNames = ['webgl', 'experimental-webgl', 'moz-webgl', 'webkit-3d']\n let nameIndex = 0\n\n while (!gl && nameIndex < validContextNames.length) {\n var contextName = validContextNames[nameIndex]\n\n try {\n gl = canvas.getContext(contextName, this.configs.glCtxOptions)\n break\n } catch (e) {\n gl = null\n }\n\n if (!gl || typeof gl.getParameter !== 'function') {\n gl = null\n }\n\n ++nameIndex\n }\n\n if(!gl) {\n throw new Error('init webgl context error')\n }\n\n this.contextGL = gl\n }\n\n _initProgram () {\n var gl = this.contextGL\n\n // vertex shader is the same for all types\n var vertexShaderScript\n var fragmentShaderScript\n vertexShaderScript = [\n 'attribute vec4 vertexPos;',\n 'attribute vec4 texturePos;',\n 'attribute vec4 uTexturePos;',\n 'attribute vec4 vTexturePos;',\n 'varying vec2 textureCoord;',\n 'varying vec2 uTextureCoord;',\n 'varying vec2 vTextureCoord;',\n\n 'void main()',\n '{',\n ' gl_Position = vertexPos;',\n ' textureCoord = texturePos.xy;',\n ' uTextureCoord = uTexturePos.xy;',\n ' vTextureCoord = vTexturePos.xy;',\n '}'\n ].join('')\n\n fragmentShaderScript = [\n 'precision highp float;',\n 'varying highp vec2 textureCoord;',\n 'varying highp vec2 uTextureCoord;',\n 'varying highp vec2 vTextureCoord;',\n 'uniform sampler2D ySampler;',\n 'uniform sampler2D uSampler;',\n 'uniform sampler2D vSampler;',\n 'uniform mat4 YUV2RGB;',\n\n 'void main(void) {',\n ' highp float y = texture2D(ySampler, textureCoord).r;',\n ' highp float u = texture2D(uSampler, uTextureCoord).r;',\n ' highp float v = texture2D(vSampler, vTextureCoord).r;',\n ' gl_FragColor = vec4(y, u, v, 1) * YUV2RGB;',\n '}'\n ].join('')\n\n var YUV2RGB = [1.16438, 0.0, 1.59603, -0.87079, 1.16438, -0.39176, -0.81297, 0.52959, 1.16438, 2.01723, 0.0, -1.08139, 0, 0, 0, 1]\n var vertexShader = gl.createShader(gl.VERTEX_SHADER)\n gl.shaderSource(vertexShader, vertexShaderScript)\n gl.compileShader(vertexShader)\n if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {\n console.log('Vertex shader failed to compile: ' + gl.getShaderInfoLog(vertexShader))\n }\n\n var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER)\n gl.shaderSource(fragmentShader, fragmentShaderScript)\n gl.compileShader(fragmentShader)\n if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {\n console.log('Fragment shader failed to compile: ' + gl.getShaderInfoLog(fragmentShader))\n }\n\n var program = gl.createProgram()\n gl.attachShader(program, vertexShader)\n gl.attachShader(program, fragmentShader)\n gl.linkProgram(program)\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n console.log('Program failed to compile: ' + gl.getProgramInfoLog(program))\n }\n\n gl.useProgram(program)\n\n var YUV2RGBRef = gl.getUniformLocation(program, 'YUV2RGB')\n gl.uniformMatrix4fv(YUV2RGBRef, false, YUV2RGB)\n\n this.shaderProgram = program\n }\n\n _initBuffers () {\n var gl = this.contextGL\n const program = this.shaderProgram\n\n var vertexPosBuffer = gl.createBuffer()\n gl.bindBuffer(gl.ARRAY_BUFFER, vertexPosBuffer)\n gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([1, 1, -1, 1, 1, -1, -1, -1]), gl.STATIC_DRAW)\n\n var vertexPosRef = gl.getAttribLocation(program, 'vertexPos')\n gl.enableVertexAttribArray(vertexPosRef)\n gl.vertexAttribPointer(vertexPosRef, 2, gl.FLOAT, false, 0, 0)\n\n var texturePosBuffer = gl.createBuffer()\n gl.bindBuffer(gl.ARRAY_BUFFER, texturePosBuffer)\n gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([1, 0, 0, 0, 1, 1, 0, 1]), gl.STATIC_DRAW)\n\n var texturePosRef = gl.getAttribLocation(program, 'texturePos')\n gl.enableVertexAttribArray(texturePosRef)\n gl.vertexAttribPointer(texturePosRef, 2, gl.FLOAT, false, 0, 0)\n\n this.texturePosBuffer = texturePosBuffer\n\n var uTexturePosBuffer = gl.createBuffer()\n gl.bindBuffer(gl.ARRAY_BUFFER, uTexturePosBuffer)\n gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([1, 0, 0, 0, 1, 1, 0, 1]), gl.STATIC_DRAW)\n\n var uTexturePosRef = gl.getAttribLocation(program, 'uTexturePos')\n gl.enableVertexAttribArray(uTexturePosRef)\n gl.vertexAttribPointer(uTexturePosRef, 2, gl.FLOAT, false, 0, 0)\n\n this.uTexturePosBuffer = uTexturePosBuffer\n\n var vTexturePosBuffer = gl.createBuffer()\n gl.bindBuffer(gl.ARRAY_BUFFER, vTexturePosBuffer)\n gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([1, 0, 0, 0, 1, 1, 0, 1]), gl.STATIC_DRAW)\n\n var vTexturePosRef = gl.getAttribLocation(program, 'vTexturePos')\n gl.enableVertexAttribArray(vTexturePosRef)\n gl.vertexAttribPointer(vTexturePosRef, 2, gl.FLOAT, false, 0, 0)\n\n this.vTexturePosBuffer = vTexturePosBuffer\n }\n\n _initTextures () {\n var gl = this.contextGL\n var program = this.shaderProgram\n var yTextureRef = this._initTexture()\n var ySamplerRef = gl.getUniformLocation(program, 'ySampler')\n gl.uniform1i(ySamplerRef, 0)\n this.yTextureRef = yTextureRef\n\n var uTextureRef = this._initTexture()\n var uSamplerRef = gl.getUniformLocation(program, 'uSampler')\n gl.uniform1i(uSamplerRef, 1)\n this.uTextureRef = uTextureRef\n\n var vTextureRef = this._initTexture()\n var vSamplerRef = gl.getUniformLocation(program, 'vSampler')\n gl.uniform1i(vSamplerRef, 2)\n this.vTextureRef = vTextureRef\n\n // fix WebGL: INVALID_OPERATION: texImage2D: ArrayBufferView not big enough for request\n // texture bound to texture unit 1 is not renderable. It might be non-power-of-2 or have incompatible texture filtering (maybe)\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1)\n }\n\n _initTexture () {\n var gl = this.contextGL\n\n var textureRef = gl.createTexture()\n gl.bindTexture(gl.TEXTURE_2D, textureRef)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE)\n gl.bindTexture(gl.TEXTURE_2D, null)\n\n return textureRef\n }\n\n _drawPictureGL (data, width, height, yLinesize, uvLinesize) {\n var ylen = yLinesize * height\n let uvlen = (uvLinesize * height) / 2\n if (this.chroma === 444 || this.chroma === 422) {\n uvlen *= 2\n }\n data = new Uint8Array(data)\n var renderData = {\n yData: data.subarray(0, ylen),\n uData: data.subarray(ylen, ylen + uvlen),\n vData: data.subarray(ylen + uvlen, ylen + uvlen + uvlen)\n }\n this._drawPictureGL420(renderData, width, height, yLinesize, uvLinesize)\n }\n\n _drawPictureGL420 (data, width, height, yLinesize, uvLinesize) {\n var gl = this.contextGL\n var texturePosBuffer = this.texturePosBuffer\n var uTexturePosBuffer = this.uTexturePosBuffer\n var vTexturePosBuffer = this.vTexturePosBuffer\n\n var yTextureRef = this.yTextureRef\n var uTextureRef = this.uTextureRef\n var vTextureRef = this.vTextureRef\n\n var yData = data.yData\n var uData = data.uData\n var vData = data.vData\n\n var yDataPerRow = yLinesize\n var yRowCnt = height\n\n var uDataPerRow = uvLinesize\n let uRowCnt = height / 2\n\n if (this.chroma === 422 || this.chroma === 444) {\n uRowCnt = height\n }\n\n var vDataPerRow = uvLinesize\n var vRowCnt = uRowCnt\n\n var ratiow = this.canvas.width / this.width\n var ratioh = this.canvas.height / this.height\n let left = 0\n let top = 0\n let w = this.canvas.width\n let h = this.canvas.height\n if (ratiow < ratioh) {\n h = (this.height * this.canvas.width) / this.width\n top = parseInt((this.canvas.height - (this.height * this.canvas.width) / this.width) / 2)\n } else {\n w = (this.width * this.canvas.height) / this.height\n left = parseInt((this.canvas.width - (this.width * this.canvas.height) / this.height) / 2)\n }\n gl.viewport(left, top, w, h)\n\n const texturePosValues = new Float32Array([1, 0, 0, 0, 1, 1, 0, 1])\n gl.bindBuffer(gl.ARRAY_BUFFER, texturePosBuffer)\n gl.bufferData(gl.ARRAY_BUFFER, texturePosValues, gl.DYNAMIC_DRAW)\n\n const uTexturePosValues = new Float32Array([1, 0, 0, 0, 1, 1, 0, 1])\n gl.bindBuffer(gl.ARRAY_BUFFER, uTexturePosBuffer)\n gl.bufferData(gl.ARRAY_BUFFER, uTexturePosValues, gl.DYNAMIC_DRAW)\n\n const vTexturePosValues = new Float32Array([1, 0, 0, 0, 1, 1, 0, 1])\n gl.bindBuffer(gl.ARRAY_BUFFER, vTexturePosBuffer)\n gl.bufferData(gl.ARRAY_BUFFER, vTexturePosValues, gl.DYNAMIC_DRAW)\n\n gl.activeTexture(gl.TEXTURE0)\n gl.bindTexture(gl.TEXTURE_2D, yTextureRef)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, yDataPerRow, yRowCnt, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, yData)\n\n gl.activeTexture(gl.TEXTURE1)\n gl.bindTexture(gl.TEXTURE_2D, uTextureRef)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, uDataPerRow, uRowCnt, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, uData)\n\n gl.activeTexture(gl.TEXTURE2)\n gl.bindTexture(gl.TEXTURE_2D, vTextureRef)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, vDataPerRow, vRowCnt, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, vData)\n\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4)\n }\n\n _drawPicture2d (data) {\n if (!data) {\n return\n }\n if (this.canvas) {\n if (!this.ctx) {\n this.ctx = this.canvas.getContext('2d')\n }\n var width = data.displayWidth || data.width\n var height = data.displayHeight || data.height\n if (this.canvas.height !== height || this.canvas.width !== width) {\n this.canvas.height = height\n this.canvas.width = width\n }\n try {\n this.ctx.drawImage(data.dom || data, 0, 0, width, height)\n } catch (error) {\n // console.error(this.TAG, '_drawPicture2d', data, data.dom, error, error.message)\n }\n }\n }\n\n _resize (width, height) {\n if (this.canvas.width !== width || this.canvas.height !== height) {\n this.width = width\n this.height = height\n this.canvas.width = width\n this.canvas.height = height\n self.postMessage({\n type: 'RESIZE_EVENT'\n })\n }\n }\n\n render (data, width, height, yLinesize, uvLinesize) {\n this._resize(width, height)\n var gl = this.contextGL\n if (gl) {\n this._drawPictureGL(data, width, height, yLinesize, uvLinesize)\n } else {\n this._drawPicture2d(data)\n }\n }\n\n updateMeta (meta) {\n this.meta = Object.assign({}, meta)\n this._initMeta()\n }\n\n clear () {\n if (this.contextGL) {\n this.contextGL.clear(this.contextGL.DEPTH_BUFFER_BIT | this.contextGL.COLOR_BUFFER_BIT)\n }\n }\n }\n\n var timer\n var frameRender\n\n function initTimer (interval) {\n stopTimer()\n clearInterval(timer)\n timer = setInterval(function () {\n self.postMessage({ type: 'NEXT_TICK' })\n }, interval)\n }\n\n function stopTimer () {\n clearInterval(timer)\n }\n\n function initWebgl (canvas, meta, type) {\n try {\n frameRender = new FrameRender({\n canvas,\n meta,\n type\n })\n } catch (e) {\n self.postMessage({\n type: 'RENDER_ERR',\n msg: e && e.message\n })\n }\n }\n\n self.onmessage = function (e) {\n var { type, interval } = e.data\n switch (type) {\n case 'START':\n initTimer(interval)\n break\n case 'DESTROY':\n stopTimer()\n break\n case 'OFFSCREEN_CANVAS':\n if (!frameRender) {\n initWebgl(e.data.canvas, e.data.meta, e.data.ctxType)\n }\n break\n case 'UPDATE_META':\n frameRender && frameRender.updateMeta(e.data.meta)\n break\n case 'RENDER':\n try {\n frameRender && frameRender.render(e.data.data, e.data.width, e.data.height, e.data.yLinesize, e.data.uvLinesize)\n } catch (e) {\n self.postMessage({\n type: 'RENDER_ERR',\n msg: e && e.message\n })\n }\n break\n case 'CLEAR':\n frameRender && frameRender.clear()\n break\n default:\n }\n }\n"],{type:"application/javascript"}),a=new Worker(URL.createObjectURL(i));if((0,l.tT)().offscreenCanvas){var o=n.transferControlToOffscreen();a._offscreen=o,a._cvs=n,n._worker=a}return s.kg.log(this.TAG,"init canvas && worker, new created"),[n,a]}catch(e){setTimeout(function(){r._emitError(e.message)})}return[]}},{key:"_bindEvent",value:function(){this._worker.addEventListener("message",this._doTask),this._worker.addEventListener("error",this._onError)}},{key:"startLoop",value:function(e){var t;(e=parseInt(e))<10?e=10:e>60?e=60:e-=8,null===(t=this._worker)||void 0===t||t.postMessage({type:"START",interval:e})}},{key:"stopLoop",value:function(){this._worker.postMessage({type:"DESTROY"})}},{key:"initRenderContext",value:function(e){var t,r,n,i=e.meta,a=e.type;if(null!==(t=this._worker)&&void 0!==t&&t._offscreen&&(this._worker._offscreen.width=i.width,this._worker._offscreen.height=i.height),null!==(r=this._worker)&&void 0!==r&&null!==(n=r._offscreen)&&void 0!==n&&n.cloned){this._worker.postMessage({type:"UPDATE_META",meta:i});return}this._worker.postMessage({type:"OFFSCREEN_CANVAS",canvas:this._worker._offscreen,meta:i,ctxType:a},[this._worker._offscreen]),this._worker._offscreen.cloned=1}},{key:"render",value:function(e,t,r,n,i){this._worker.postMessage({type:"RENDER",data:e,width:t,height:r,yLinesize:n,uvLinesize:i},[e])}},{key:"destroy",value:function(e){this._worker&&(this._worker.postMessage({type:"DESTROY"}),this._worker.removeEventListener("message",this._doTask),this._worker.removeEventListener("error",this._onError),e&&!this._errorOccur&&(u.push(this._worker),this._worker.postMessage({type:"CLEAR"}),s.kg.log(this.TAG,"cache render worker")),this._worker=null,this._task=null)}}]),e}()},976290:function(e,t,r){r.d(t,{i:function(){return a}});var n=r(182432),i=r(275764);function a(e){return(0,n.Zj)({loaderType:i.t.FETCH,retry:0,retryDelay:0,timeout:0,request:null,onTimeout:void 0,onProgress:void 0,onRetryError:void 0,transformRequest:void 0,transformResponse:void 0,transformError:void 0,responseType:i.U.TEXT,range:void 0,url:"",params:void 0,method:"GET",headers:{},body:void 0,mode:void 0,credentials:void 0,cache:void 0,redirect:void 0,referrer:void 0,referrerPolicy:void 0,integrity:void 0,onProcessMinLen:0},e)}},697946:function(e,t,r){r.d(t,{PA:function(){return a},ZQ:function(){return u},Zj:function(){return i},_x:function(){return l},qH:function(){return s},u:function(){return c}});function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function i(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach(function(t){l(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function a(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,h(n.key),n)}}function s(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(e,t,r){return(t=h(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,a,o,s=[],l=!0,u=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=a.call(r)).done)&&(s.push(n.value),s.length!==t);l=!0);}catch(e){u=!0,i=e}finally{try{if(!l&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw i}}return s}}(e,t)||d(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e){return function(e){if(Array.isArray(e))return f(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||d(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){if(e){if("string"==typeof e)return f(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return f(e,t)}}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function h(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}},834279:function(e,t,r){r.d(t,{b:function(){return u}});var n=r(697946),i=r(745740),a=r(461449),o=r(578548),s=r(532096),l=4294967295,u=function(){function e(){(0,n.PA)(this,e)}return(0,n.qH)(e,null,[{key:"box",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];var i=8+(r=r.filter(Boolean)).reduce(function(e,t){return e+t.byteLength},0),a=new Uint8Array(i);a[0]=i>>24&255,a[1]=i>>16&255,a[2]=i>>8&255,a[3]=255&i,a.set(e,4);var o=8;return r.forEach(function(e){a.set(e,o),o+=e.byteLength}),a}},{key:"type",value:function(t){return!e.types[t]&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]),e.types[t]}},{key:"FullBox",value:function(t,r,n){for(var i=arguments.length,a=Array(i>3?i-3:0),o=3;o<i;o++)a[o-3]=arguments[o];return e.box.apply(e,[t,new Uint8Array([r,n>>16&255,n>>8&255,255&n])].concat(a))}},{key:"ftyp",value:function(t){var r=t.find(function(e){return e.type===i.Vc.VIDEO});if((null==r?void 0:r.codecType)===i._e.HEVC)return e.FTYPHEV1;var n=(0,a.YW)({track:r});return null!=n&&n.buildFtyp?n.buildFtyp({track:r,tracks:t,MP4:e}):e.FTYPAVC1}},{key:"initSegment",value:function(t){if(!t||!t.length)return new Uint8Array;var r=e.ftyp(t);return(0,o.gJ)(r,e.moov(t))}},{key:"pssh",value:function(t){var r=new Uint8Array([1,0,0,0].concat([16,119,239,236,192,178,77,2,172,227,60,30,82,226,251,75],[0,0,0,1],(0,o.Qc)(t.kid),[0,0,0,0]));return e.box(e.types.pssh,r)}},{key:"moov",value:function(t){if(!t[0].useEME||!t[0].encv&&!t[0].enca)return e.box.apply(e,[e.types.moov,e.mvhd(t[0].mvhdDurtion||t[0].duration,t[0].mvhdTimecale||t[0].timescale)].concat((0,n.u)(t.map(function(t){return e.trak(t)})),[e.mvex(t)]));!t[0].pssh&&(t[0].pssh={kid:t[0].kid});var r=this.pssh(t[0].pssh);return e.box.apply(e,[e.types.moov,e.mvhd(t[0].mvhdDurtion||t[0].duration,t[0].mvhdTimecale||t[0].timescale),e.mvex(t)].concat((0,n.u)(t.map(function(t){return e.trak(t)})),[r]))}},{key:"mvhd",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4;return e.box(e.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,t>>24&255,t>>16&255,t>>8&255,255&t,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]))}},{key:"trak",value:function(t){return e.box(e.types.trak,e.tkhd(t.id,t.tkhdDuration||0,t.width,t.height),e.mdia(t))}},{key:"tkhd",value:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return e.box(e.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,n>>8&255,255&n,0,0,i>>8&255,255&i,0,0]))}},{key:"edts",value:function(t){return e.box(e.types.edts,e.elst(t))}},{key:"elst",value:function(t){t.entries;var r=t.entriesData,n=t.version;return e.FullBox(e.types.elst,n,0,r)}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.duration,t.timescale),e.hdlr(t.type),e.minf(t))}},{key:"mdhd",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4;return e.box(e.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,t>>24&255,t>>16&255,t>>8&255,255&t,85,196,0,0]))}},{key:"hdlr",value:function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])}},{key:"minf",value:function(t){return e.box(e.types.minf,t.type===i.Vc.VIDEO?e.VMHD:e.SMHD,e.DINF,e.stbl(t))}},{key:"stbl",value:function(t){return t&&t.ext,e.box(e.types.stbl,e.stsd(t),e.STTS,(0,void 0),e.STSC,e.STSZ,e.STCO)}},{key:"stsd",value:function(t){var r;return r="audio"===t.type?t.useEME&&t.enca?e.enca(t):t.codecType===i.yQ.OPUS?e.opus(t):e.mp4a(t):t.useEME&&t.encv?e.encv(t):t.av1C?e.av01(t):e.avc1hev1vvc1(t),e.box(e.types.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),r)}},{key:"enca",value:function(t){var r=t.enca.channelCount,n=t.enca.sampleRate,i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,r,0,16,0,0,0,0,n>>8&255,255&n,0,0]),a=e.esds(t.config),o=e.sinf(t.enca);return e.box(e.types.enca,i,a,o)}},{key:"encv",value:function(t){var r=t.width,o=t.height,s=t.sarRatio&&t.sarRatio.length>1?t.sarRatio[0]:0,l=t.sarRatio&&t.sarRatio.length>1?t.sarRatio[1]:0,u=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,r>>8&255,255&r,o>>8&255,255&o,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),c=(0,a.YW)({track:t});if(t.codecType===i._e.HEVC)d=e.hvcC(t);else if(null!=c&&c.buildConfigBox)d=c.buildConfigBox({track:t,MP4:e});else{var d,f,h,p=t.sps&&t.sps.length>0?t.sps[0]:[],g=t.pps&&t.pps.length>0?t.pps[0]:[],v=new Uint8Array((f=(h=[1,p[1],p[2],p[3],255,225,p.length>>>8&255,255&p.length]).concat.apply(h,(0,n.u)(p)).concat([1,g.length>>>8&255,255&g.length])).concat.apply(f,(0,n.u)(g)));d=e.box(e.types.avcC,v)}var m=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),y=e.sinf(t.encv),_=[u,d,e.box(e.types.btrt,m),y];if(t.sarRatio&&t.sarRatio.length>1){var T=new Uint8Array([s>>24,s>>16&255,s>>8&255,255&s,l>>24,l>>16&255,l>>8&255,255&l]);_.push(e.box(e.types.pasp,T))}return e.box.apply(e,[e.types.encv].concat(_))}},{key:"schi",value:function(t){var r=new Uint8Array([]),n=e.tenc(t);return e.box(e.types.schi,r,n)}},{key:"tenc",value:function(t){var r=new Uint8Array([0,0,0,0,0,0,255&t.default_IsEncrypted,255&t.default_IV_size].concat((0,o.Qc)(t.default_KID)));return e.box(e.types.tenc,r)}},{key:"sinf",value:function(t){var r=new Uint8Array([]),n=new Uint8Array([t.data_format.charCodeAt(0),t.data_format.charCodeAt(1),t.data_format.charCodeAt(2),t.data_format.charCodeAt(3)]),i=new Uint8Array([0,0,0,0,99,101,110,99,0,1,0,0]),a=e.schi(t);return e.box(e.types.sinf,r,e.box(e.types.frma,n),e.box(e.types.schm,i),a)}},{key:"av01",value:function(t){return e.box(e.types.av01,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,t.width>>8&255,255&t.width,t.height>>8&255,255&t.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),t.av1C,t.colr)}},{key:"avc1hev1vvc1",value:function(t){if(t.codecType===i._e.HEVC)n=e.hvcC(t),o=e.types.hvc1;else if(null!==(r=(0,a.YW)({track:t}))&&void 0!==r&&r.buildConfigBox){var r,n,o,s=(0,a.YW)({track:t});n=s.buildConfigBox({track:t,MP4:e}),o=e.type(s.getSampleEntryType?s.getSampleEntryType({track:t}):s.sampleEntries[0])}else n=e.avcC(t),o=e.types.avc1;var l=[new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,t.width>>8&255,255&t.width,t.height>>8&255,255&t.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),n];return t.codecType===i._e.HEVC?l.push(e.box(e.types.fiel,new Uint8Array([1,0]))):t.sarRatio&&t.sarRatio.length>1&&l.push(e.pasp(t.sarRatio)),e.box.apply(e,[o].concat(l))}},{key:"avcC",value:function(t){var r,i,a,o=[],s=[];return t.sps.forEach(function(e){a=e.byteLength,o.push(a>>>8&255),o.push(255&a),o.push.apply(o,(0,n.u)(e))}),t.pps.forEach(function(e){a=e.byteLength,s.push(a>>>8&255),s.push(255&a),s.push.apply(s,(0,n.u)(e))}),e.box(e.types.avcC,new Uint8Array((r=(i=[1,o[3],o[4],o[5],255,224|t.sps.length]).concat.apply(i,o).concat([t.pps.length])).concat.apply(r,s)))}},{key:"vvcC",value:function(t){var r=(0,a.YW)({track:t});return null!=r&&r.buildConfigBox?r.buildConfigBox({track:t,MP4:e}):e.box(e.types.vvcC,new Uint8Array(t.vvcC))}},{key:"hvcC",value:function(t){var r,i=t.hvcC;if(i instanceof ArrayBuffer||i instanceof Uint8Array)return i;var a=t.vps,o=t.sps,s=t.pps;if(i){var l=i.generalProfileCompatibilityFlags,u=i.generalConstraintIndicatorFlags,c=(a.length&&1)+(o.length&&1)+(s.length&&1);r=[1,i.generalProfileSpace<<6|i.generalTierFlag<<5|i.generalProfileIdc,l>>>24,l>>>16,l>>>8,l,u[0],u[1],u[2],u[3],u[4],u[5],i.generalLevelIdc,240,0,252,252|i.chromaFormatIdc,248|i.bitDepthLumaMinus8,248|i.bitDepthChromaMinus8,0,0,i.numTemporalLayers<<3|i.temporalIdNested<<2|3,c];var d=function(e){var t;r.push(e.length>>8,e.length),(t=r).push.apply(t,(0,n.u)(e))};a.length&&(r.push(160,0,a.length),a.forEach(d)),o.length&&(r.push(161,0,o.length),o.forEach(d)),s.length&&(r.push(162,0,s.length),s.forEach(d))}else r=[1,1,96,0,0,0,144,0,0,0,0,0,93,240,0,252,253,248,248,0,0,15,3,160,0,1,0,24,64,1,12,1,255,255,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,153,152,9,161,0,1,0,45,66,1,1,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,160,2,128,128,45,22,89,153,164,147,43,154,128,128,128,130,0,0,3,0,2,0,0,3,0,50,16,162,0,1,0,7,68,1,193,114,180,98,64];return e.box(e.types.hvcC,new Uint8Array(r))}},{key:"pasp",value:function(t){var r=(0,n.ZQ)(t,2),i=r[0],a=r[1];return e.box(e.types.pasp,new Uint8Array([i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a]))}},{key:"mp4a",value:function(t){return e.box(e.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,t.sampleRate>>8&255,255&t.sampleRate,0,0]),t.config.length?e.esds(t.config):void 0)}},{key:"esds",value:function(t){var r=t.length;return e.box(e.types.esds,new Uint8Array([0,0,0,0,3,23+r,0,0,0,4,15+r,64,21,0,6,0,0,0,218,192,0,0,218,192,5].concat([r]).concat(t).concat([6,1,2])))}},{key:"opus",value:function(t){var r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,t.sampleRate>>8&255,255&t.sampleRate,0,0]),n=t.config.length?e.dOps(t):[];return e.box(e.types.Opus,r,n)}},{key:"dOps",value:function(t){if(t.config)return t.config[4]=t.sampleRate>>>24&255,t.config[5]=t.sampleRate>>>16&255,t.config[6]=t.sampleRate>>>8&255,t.config[7]=255&t.sampleRate,e.box(e.types.dOps,t.config)}},{key:"mvex",value:function(t){return e.box.apply(e,[e.types.mvex].concat((0,n.u)(t.map(function(t){return e.trex(t.id)}))))}},{key:"trex",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trex1",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,2,0,0,0,0,0,0,1,0,0]))}},{key:"trex2",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,4,0,0,0,0,0,2,0,0,0]))}},{key:"moof",value:function(t){return e.box.apply(e,[e.types.moof,e.mfhd(t[0].samples?t[0].samples[0].gopId:0)].concat((0,n.u)(t.map(function(t){return e.traf(t)}))))}},{key:"mfhd",value:function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"traf",value:function(t){var r=e.tfhd(t.id),n=e.tfdt(t.baseMediaDecodeTime),i=0;if(t.isVideo&&t.videoSenc&&t.videoSenc.forEach(function(e){i+=8,e.subsamples&&e.subsamples.length&&(i+=2+6*e.subsamples.length)}),t.videoSencLength=i,t.useEME&&(t.isVideoEncryption||t.isAudioEncryption)){if(t.isVideoEncryption){if(t.isVideo){var a=e.saiz(t),o=e.saio(t),s=e.trun1(t),l=e.senc(t);return e.box(e.types.traf,r,n,a,o,s,l)}if(t.isAudioEncryption){var u=e.sbgp(),c=e.saiz(t),d=e.saio(t),f=e.senc(t),h=e.trun1(t);return e.box(e.types.traf,r,n,u,c,d,f,h)}var p=e.sbgp(),g=e.trun1(t);return e.box(e.types.traf,r,n,p,g)}else{if(t.isVideo){var v=e.trun1(t);return e.box(e.types.traf,r,n,v)}var m=e.sbgp(),y=e.saiz(t),_=e.saio(t),T=e.senc(t),b=e.trun1(t);return e.box(e.types.traf,r,n,m,y,_,T,b)}}var E=e.sdtp(t);return e.box(e.types.traf,r,n,E,e.trun(t.samples,E.byteLength+76))}},{key:"sdtp",value:function(t){var r=new s.Z;return t.samples.forEach(function(e){r.write(new Uint8Array(t.isVideo?[e.keyframe?32:16]:[16]))}),e.box(e.types.sdtp,this.extension(0,0),r.buffer)}},{key:"trun1",value:function(t){var r=new s.Z,n=s.Z.writeUint32(t.samples.length),i=null;if(t.isVideo){var a=t.videoSencLength;i=s.Z.writeUint32(76+16*t.samples.length+a+77),!t.isVideoEncryption&&t.isAudioEncryption&&(i=s.Z.writeUint32(76+16*t.samples.length+20))}else{var o=76+12*t.samples.length+52;t.isAudioEncryption&&(o=76+12*t.samples.length+8*t.audioSenc.length+105),i=s.Z.writeUint32(o)}return t.samples.forEach(function(e){r.write(s.Z.writeUint32(e.duration)),r.write(s.Z.writeUint32(e.size)),r.write(s.Z.writeUint32(e.keyframe?33554432:65536)),t.isVideo&&r.write(s.Z.writeUint32(e.cts?e.cts:0))}),e.box(e.types.trun,this.extension(0,t.flags),n,i,r.buffer)}},{key:"senc",value:function(t){var r=new s.Z,n=t.samples.length,i=t.isVideo?16:8,a=t.isVideo?2:0,o=[],l=0;return t.isVideo?(o=t.videoSenc,l=t.videoSencLength):o=t.audioSenc,l=l||i*n,r.write(s.Z.writeUint32(16+l),e.types.senc,this.extension(0,a)),r.write(s.Z.writeUint32(n)),o.forEach(function(e){for(var t=0;t<e.InitializationVector.length;t++)r.write(new Uint8Array([e.InitializationVector[t]]));e.subsamples&&e.subsamples.length&&(r.write(s.Z.writeUint16(e.subsamples.length)),e.subsamples.forEach(function(e){r.write(s.Z.writeUint16(e.BytesOfClearData)),r.write(s.Z.writeUint32(e.BytesOfProtectedData))}))}),r.buffer}},{key:"saio",value:function(t){var r=12*t.samples.length+141;!t.isVideo&&t.isAudioEncryption&&(r=149);var n=new Uint8Array([1,0,0,0,0,0,0,1,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r]);return e.box(e.types.saio,n)}},{key:"saiz",value:function(t){var r=t.samples.length,n=new Uint8Array([0,0,0,0,16,r>>24&255,r>>16&255,r>>8&255,255&r]);return e.box(e.types.saiz,n)}},{key:"sbgp",value:function(){var t=new Uint8Array([114,111,108,108,0,0,0,1,0,0,1,25,0,0,0,1]);return e.box(e.types.sbgp,this.extension(0,0),t)}},{key:"extension",value:function(e,t){return new Uint8Array([e,t>>16&255,t>>8&255,255&t])}},{key:"tfhd",value:function(t){return e.box(e.types.tfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"tfdt",value:function(t){var r=Math.floor(t/(l+1)),n=Math.floor(t%(l+1));return e.box(e.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,n>>24,n>>16&255,n>>8&255,255&n]))}},{key:"trun",value:function(t,r){var n=t.length,i=12+16*n;r+=8+i;var a=new Uint8Array(i);a.set([0,0,15,1,n>>>24&255,n>>>16&255,n>>>8&255,255&n,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0);for(var o=0;o<n;o++){var s=t[o],l=s.duration,u=s.size,c=s.flag,d=void 0===c?{}:c,f=s.cts,h=void 0===f?0:f;a.set([l>>>24&255,l>>>16&255,l>>>8&255,255&l,u>>>24&255,u>>>16&255,u>>>8&255,255&u,d.isLeading<<2|(null===d.dependsOn||void 0===d.dependsOn?1:d.dependsOn),d.isDependedOn<<6|d.hasRedundancy<<4|d.paddingValue<<1|(null===d.isNonSyncSample||void 0===d.isNonSyncSample?1:d.isNonSyncSample),61440&d.degradationPriority,15&d.degradationPriority,h>>>24&255,h>>>16&255,h>>>8&255,255&h],12+16*o)}return e.box(e.types.trun,a)}},{key:"moovMP4",value:function(t){return e.box.apply(e,[e.types.moov,e.mvhd(t[0].duration,t[0].timescale)].concat((0,n.u)(t.map(function(t){return e.trackMP4(t)}))))}},{key:"trackMP4",value:function(t){return e.box(e.types.trak,e.tkhd(t.id,t.duration,t.width,t.height),e.mdiaMP4(t))}},{key:"mdiaMP4",value:function(t){return e.box(e.types.mdia,e.mdhd(t.duration,t.timescale),e.hdlr(t.type),e.minfMP4(t))}},{key:"minfMP4",value:function(t){return e.box(e.types.minf,t.type===i.Vc.VIDEO?e.VMHD:e.SMHD,e.DINF,e.stblMP4(t))}},{key:"stblMP4",value:function(t){var r=t.ext,n=[e.stsd(t),e.stts(r.stts),e.stsc(r.stsc),e.stsz(r.stsz),e.stco(r.stco)];return r.stss.length&&n.push(e.stss(r.stss)),r.ctts.length&&n.push(e.ctts(r.ctts)),e.box.apply(e,[e.types.stbl].concat(n))}},{key:"stts",value:function(t){var r=t.length,n=new Uint8Array(8*r),i=0;return t.forEach(function(e){var t=e.value,r=e.count;n.set([r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t],i),i+=8}),e.box(e.types.stts,(0,o.gJ)(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"stsc",value:function(t){var r=t.length,n=new Uint8Array(12*r),i=0;return t.forEach(function(e){var t=e.firstChunk,r=e.samplesPerChunk,a=e.sampleDescIndex;n.set([t>>24,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,a>>24,a>>16&255,a>>8&255,255&a],i),i+=12}),e.box(e.types.stsc,(0,o.gJ)(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"stsz",value:function(t){var r=t.length,n=new Uint8Array(4*r),i=0;return t.forEach(function(e){n.set([e>>24,e>>16&255,e>>8&255,255&e],i),i+=4}),e.box(e.types.stsz,(0,o.gJ)(new Uint8Array([0,0,0,0,0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"stco",value:function(t){var r=t.length,n=new Uint8Array(4*r),i=0;return t.forEach(function(e){n.set([e>>24,e>>16&255,e>>8&255,255&e],i),i+=4}),e.box(e.types.stco,(0,o.gJ)(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"stss",value:function(t){var r=t.length,n=new Uint8Array(4*r),i=0;return t.forEach(function(e){n.set([e>>24,e>>16&255,e>>8&255,255&e],i),i+=4}),e.box(e.types.stss,(0,o.gJ)(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"ctts",value:function(t){var r=t.length,n=new Uint8Array(8*r),i=0;return t.forEach(function(e){var t=e.value,r=e.count;n.set([r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t],i),i+=8}),e.box(e.types.ctts,(0,o.gJ)(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"styp",value:function(){return e.box(e.types.styp,new Uint8Array([109,115,100,104,0,0,0,0,109,115,100,104,109,115,105,120]))}},{key:"sidx",value:function(t){var r=t.timescale,n=t.samples[0].duration,i=n*t.samples.length,a=t.samples[0].sampleOffset*n,o=8;t.samples.forEach(function(e){o+=e.size});var s=0;if(t.isVideo){var l,u=0;t.videoSenc&&(l=t.videoSenc),t.isVideo&&l.forEach(function(e){u+=8,e.subsamples&&e.subsamples.length&&(u+=2+6*e.subsamples.length)}),t.videoSencLength=u,s=o+141+16*t.samples.length+u,t.useEME&&t.isAudioEncryption&&!t.isVideoEncryption&&(s=o+16*t.samples.length+84)}else s=o+116+12*t.samples.length,t.useEME&&t.isAudioEncryption&&(s=o+169+12*t.samples.length+8*t.audioSenc.length);var c=new Uint8Array([0,0,0,0,0,0,0,255&t.id,r>>24&255,r>>16&255,r>>8&255,255&r,a>>24&255,a>>16&255,a>>8&255,255&a,0,0,0,0,0,0,0,1,0,s>>16&255,s>>8&255,255&s,i>>24&255,i>>16&255,i>>8&255,255&i,144,0,0,0]);return e.box(e.types.sidx,c)}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}}]),e}();(0,n._x)(u,"types",["Opus","dOps","av01","av1C","avc1","avcC","hvc1","hvcC","dinf","dref","edts","elst","esds","ftyp","hdlr","mdat","mdhd","mdia","mfhd","minf","moof","moov","mp4a","mvex","mvhd","pasp","stbl","stco","stsc","stsd","stsz","stts","tfdt","tfhd","traf","trak","trex","tkhd","vmhd","smhd","ctts","stss","styp","pssh","sidx","sbgp","saiz","saio","senc","trun","encv","enca","sinf","btrt","frma","tenc","schm","schi","mehd","fiel","sdtp","vvc1","vvi1","vvcC"].reduce(function(e,t){return e[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)],e},Object.create(null))),(0,n._x)(u,"HDLR_TYPES",{video:new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),audio:new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0])}),(0,n._x)(u,"FTYPAVC1",u.box(u.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]))),(0,n._x)(u,"FTYPHEV1",u.box(u.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49]))),(0,n._x)(u,"FTYPVVC1",u.box(u.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,118,118,99,49]))),(0,n._x)(u,"DINF",u.box(u.types.dinf,u.box(u.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])))),(0,n._x)(u,"VMHD",u.box(u.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]))),(0,n._x)(u,"SMHD",u.box(u.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0]))),(0,n._x)(u,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0])),(0,n._x)(u,"STTS",u.box(u.types.stts,u.StblTable)),(0,n._x)(u,"STSC",u.box(u.types.stsc,u.StblTable)),(0,n._x)(u,"STSZ",u.box(u.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]))),(0,n._x)(u,"STCO",u.box(u.types.stco,u.StblTable))},365975:function(e,t,r){r.d(t,{W:function(){return a}});var n=r(519357),i=r(146202),a=function(){function e(){(0,n.PA)(this,e)}return(0,n.qH)(e,null,[{key:"getRateIndexByRate",value:function(t){return e.FREQ.indexOf(t)}},{key:"parseADTS",value:function(t,r){for(var n,i,a=t.length,o=0;o+2<a&&(255!==t[o]||(246&t[o+1])!=240);){;o++}if(!(o>=a)){var s=o,l=[],u=(60&t[o+2])>>>2,c=e.FREQ[u];if(!c)throw Error("Invalid sampling index: ".concat(u));for(var d=((192&t[o+2])>>>6)+1,f=(1&t[o+2])<<2|(192&t[o+3])>>>6,h=e._getConfig(u,f,d),p=h.config,g=h.codec,v=0,m=e.getFrameDuration(c);o+7<a;){if(255!==t[o]||(246&t[o+1])!=240){o++;continue}if(i=(3&t[o+3])<<11|t[o+4]<<3|(224&t[o+5])>>5,a-o<i)break;n=(1&~t[o+1])*2,l.push({pts:r+v*m,data:t.subarray(o+7+n,o+i)}),v++,o+=i}return{skip:s,remaining:o>=a?void 0:t.subarray(o),frames:l,samplingFrequencyIndex:u,sampleRate:c,objectType:d,channelCount:f,codec:g,config:p,originCodec:"mp4a.40.".concat(d)}}}},{key:"parseAudioSpecificConfig",value:function(t){if(!!t.length){var r=t[0]>>>3,n=(7&t[0])<<1|t[1]>>>7,i=(120&t[1])>>>3,a=e.FREQ[n];if(a){var o=e._getConfig(n,i,r),s=o.config;return{samplingFrequencyIndex:n,sampleRate:a,objectType:r,channelCount:i,config:s,codec:o.codec,originCodec:"mp4a.40.".concat(r)}}}}},{key:"getFrameDuration",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4;return 1024*t/e}},{key:"_getConfig",value:function(e,t,r){var n,a,o=[];return i.vU?e>=6?(n=5,a=e-3):(n=2,a=e):i.Dt?(n=2,a=e):(n=2===r||5===r?r:5,a=e,e>=6?a=e-3:1===t&&(n=2,a=e)),o[0]=n<<3,o[0]|=(14&e)>>1,o[1]=(1&e)<<7,o[1]|=t<<3,5===n&&(o[1]|=(14&a)>>1,o[2]=(1&a)<<7,o[2]|=8,o[3]=0),{config:o,codec:"mp4a.40.".concat(n)}}},{key:"getSilentFrame",value:function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t||3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}}]),e}();(0,n._x)(a,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350])}}]); |