Files
EasyPlayerJs/html-demo/js/easyplayer-pro-multi.js
2024-08-01 16:32:01 +08:00

2 lines
1.5 MiB
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";class t{on(e,t,i){const r=this.e||(this.e={});return(r[e]||(r[e]=[])).push({fn:t,ctx:i}),this}once(e,t,i){const r=this;function s(...a){r.off(e,s),t.apply(i,a)}return s._=t,this.on(e,s,i)}emit(e,...t){const i=((this.e||(this.e={}))[e]||[]).slice();for(let e=0;e<i.length;e+=1)i[e].fn.apply(i[e].ctx,t);return this}off(e,t){const i=this.e||(this.e={});if(!e)return Object.keys(i).forEach((e=>{delete i[e]})),void delete this.e;const r=i[e],s=[];if(r&&t)for(let e=0,i=r.length;e<i;e+=1)r[e].fn!==t&&r[e].fn._!==t&&s.push(r[e]);return s.length?i[e]=s:delete i[e],this}}const i=1,r=2,s=3,a=4,n=5,o=6,l=9,d=["","websocket","fetch","hls","webrtc","webTransport","aliyunRtc","ts"],h="fetch",c="hls",u="websocket",p="webrtc",f="webTransport",y="worker",m="aliyunRtc",g="wsRtc",A="player",v="playerAudio",b="playbackTF",_="mp4",w="mp4",E="flv",S="mov",T="flv",k="m7s",C="hls",D="webrtc",R="webTransport",x="nakedFlow",L="fmp4",I="mpeg4",P="aliyunRtc",B="ts",M="wsRtc",U={flv:"FLV",m7s:"M7S",hls:"HLS",fmp4:"FMP4",mpeg4:"MPEG4",webrtc:"Webrtc",webTransport:"WebTransport",nakedFlow:"裸流",aliyunRtc:"AliyunRtc",ts:"TS"},F="mse",O="wcs",N="offscreen",G="wasm",z="simd",W="mt",V="webrtc",H="hls",$="wsRtc",j="aliyunRtc",K="canvas",q="video",Y="debug",Q="warn",X="click",J="mouseDownAndUp",Z={normal:"normal",simple:"simple"},ee=36e5,te="/crypto/",ie="jbprov",re=1e4,se={url:"",playbackConfig:{},fullscreenWatermarkConfig:{},playType:A,playbackForwardMaxRateDecodeIFrame:4,playOptions:{},isLive:!0,isMulti:!0,isM7sCrypto:!1,supportHls265:!0,playFailedUseLastFrameShow:!0,playFailedAndPausedShowMessage:!1,pauseAndNextPlayUseLastFrameShow:!1,widthOrHeightChangeReplayDelayTime:0,isUseNewFullscreenWatermark:!1},ae={playType:A,container:"",videoBuffer:1e3,videoBufferDelay:1e3,networkDelay:1e4,isResize:!0,isFullResize:!1,isFlv:!1,isHls:!1,isFmp4:!1,isFmp4Private:!1,isWebrtc:!1,isWebrtcForZLM:!1,isWebrtcForSRS:!1,isWebrtcForOthers:!0,isNakedFlow:!1,isMpeg4:!1,isAliyunRtc:!1,isTs:!1,debug:!1,debugLevel:Q,debugUuid:"",isMulti:!0,multiIndex:-1,hotKey:!1,loadingTimeout:10,heartTimeout:10,timeout:10,pageVisibilityHiddenTimeout:300,loadingTimeoutReplay:!0,heartTimeoutReplay:!0,loadingTimeoutReplayTimes:3,heartTimeoutReplayTimes:3,heartTimeoutReplayUseLastFrameShow:!0,replayUseLastFrameShow:!0,replayShowLoadingIcon:!1,supportDblclickFullscreen:!1,showBandwidth:!1,showPerformance:!1,mseCorrectTimeDuration:20,keepScreenOn:!0,isNotMute:!1,hasAudio:!0,hasVideo:!0,operateBtns:{fullscreen:!1,screenshot:!1,play:!1,audio:!1,record:!1,ptz:!1,quality:!1,zoom:!1,close:!1,scale:!1,performance:!1,logSave:!1,aiFace:!1,aiObject:!1,aiOcclusion:!1,fullscreenFn:null,fullscreenExitFn:null,screenshotFn:null,playFn:null,pauseFn:null,recordFn:null,recordStopFn:null},extendOperateBtns:[],contextmenuBtns:[],watermarkConfig:{},controlAutoHide:!1,hasControl:!1,loadingIcon:!0,loadingIconStyle:{},loadingText:"",background:"",backgroundLoadingShow:!0,loadingBackground:"",loadingBackgroundWidth:0,loadingBackgroundHeight:0,decoder:"decoder-pro.js",decoderAudio:"decoder-pro-audio.js",decoderHard:"decoder-pro-hard.js",decoderHardNotWasm:"decoder-pro-hard-not-wasm.js",wasmMp4RecorderDecoder:"easyplayer-pro-mp4-recorder-decoder.js",decoderWASM:"",isDecoderUseCDN:!1,url:"",rotate:0,mirrorRotate:"none",aspectRatio:"default",playbackConfig:{playList:[],fps:"",showControl:!0,controlType:Z.normal,duration:0,startTime:"",showRateBtn:!1,rateConfig:[],showPrecision:"",showPrecisionBtn:!0,isCacheBeforeDecodeForFpsRender:!1,uiUsePlaybackPause:!1,isPlaybackPauseClearCache:!0,isUseFpsRender:!1,isUseLocalCalculateTime:!1,localOneFrameTimestamp:40,supportWheel:!1,useWCS:!1,useMSE:!1},qualityConfig:[],defaultStreamQuality:"",scaleConfig:["拉伸","缩放","正常"],forceNoOffscreen:!0,hiddenAutoPause:!1,protocol:r,demuxType:T,useWasm:!1,useMSE:!1,useWCS:!1,useSIMD:!0,useMThreading:!1,wcsUseVideoRender:!0,wcsUseWebgl2Render:!0,wasmUseVideoRender:!0,mseUseCanvasRender:!1,hlsUseCanvasRender:!1,webrtcUseCanvasRender:!1,useOffscreen:!1,useWebGPU:!1,mseDecodeErrorReplay:!0,wcsDecodeErrorReplay:!0,wasmDecodeErrorReplay:!0,simdDecodeErrorReplay:!0,simdDecodeErrorReplayType:G,autoWasm:!0,decoderErrorAutoWasm:!0,hardDecodingNotSupportAutoWasm:!0,webglAlignmentErrorReplay:!0,webglContextLostErrorReplay:!0,openWebglAlignment:!1,syncAudioAndVideo:!1,syncAudioAndVideoDiff:500,playbackDelayTime:1e3,playbackFps:25,playbackForwardMaxRateDecodeIFrame:4,playbackCurrentTimeMove:!0,useVideoRender:!0,useCanvasRender:!1,networkDelayTimeoutReplay:!1,recordType:_,checkFirstIFrame:!0,nakedFlowFps:25,audioEngine:null,isShowRecordingUI:!0,isShowZoomingUI:!0,useFaceDetector:!1,useObjectDetector:!1,useImageDetector:!1,useOcclusionDetector:!1,ptzClickType:X,ptzStopEmitDelay:.3,ptzZoomShow:!1,ptzApertureShow:!1,ptzFocusShow:!1,ptzMoreArrowShow:!1,weiXinInAndroidAudioBufferSize:4800,isM7sCrypto:!1,m7sCryptoAudio:!1,isSm4Crypto:!1,isXorCrypto:!1,sm4CryptoKey:"",m7sCryptoKey:"",xorCryptoKey:"",cryptoKey:"",cryptoIV:"",cryptoKeyUrl:"",autoResize:!1,useWebFullScreen:!1,ptsMaxDiff:3600,aiFaceDetectLevel:2,aiFaceDetectWidth:240,aiFaceDetectShowRect:!0,aiFaceDetectInterval:1e3,aiFaceDetectRectConfig:{},aiObjectDetectLevel:2,aiObjectDetectWidth:240,aiObjectDetectShowRect:!0,aiObjectDetectInterval:1e3,aiObjectDetectRectConfig:{},aiOcclusionDetectInterval:1e3,aiImageDetectDrop:!1,aiImageDetectActive:!1,videoRenderSupportScale:!0,mediaSourceTsIsMaxDiffReplay:!0,controlHtml:"",isH265:!1,isWebrtcH265:!1,supportLockScreenPlayAudio:!0,supportHls265:!0,isEmitSEI:!1,pauseAndNextPlayUseLastFrameShow:!1,demuxUseWorker:!1,playFailedAndReplay:!0,showMessageConfig:{webglAlignmentError:"Webgl 渲染失败",webglContextLostError:"webgl 上下文丢失",mediaSourceH265NotSupport:"不支持硬解码H265",mediaSourceFull:"缓冲区已满",mediaSourceAppendBufferError:"初始化解码器失败",mseSourceBufferError:"解码失败",mseAddSourceBufferError:"初始化解码器失败",mediaSourceDecoderConfigurationError:"初始化解码器失败",mediaSourceTsIsMaxDiff:"流异常",mseWidthOrHeightChange:"流异常",mediaSourceAudioG711NotSupport:"硬解码不支持G711a/u音频格式",mediaSourceUseCanvasRenderPlayFailed:"MediaSource解码使用canvas渲染失败",webcodecsH265NotSupport:"不支持硬解码H265",webcodecsUnsupportedConfigurationError:"初始化解码器失败",webcodecsDecodeConfigureError:"初始化解码器失败",webcodecsDecodeError:"解码失败",wcsWidthOrHeightChange:"解码失败",wasmDecodeError:"解码失败",simdDecodeError:"解码失败",wasmWidthOrHeightChange:"流异常",wasmUseVideoRenderError:"video自动渲染失败",videoElementPlayingFailed:"video自动渲染失败",simdH264DecodeVideoWidthIsTooLarge:"不支持该分辨率的视频",networkDelayTimeout:"网络超时重播失败",fetchError:"请求失败",streamEnd:"请求结束",websocketError:"请求失败",webrtcError:"请求失败",hlsError:"请求失败",decoderWorkerInitError:"初始化worker失败",videoElementPlayingFailedForWebrtc:"video自动渲染失败",videoInfoError:"解析视频分辨率失败",webrtcStreamH265:"webrtc不支持H265",delayTimeout:"播放超时重播失败",loadingTimeout:"加载超时重播失败",loadingTimeoutRetryEnd:"加载超时重播失败",delayTimeoutRetryEnd:"播放超时重播失败"},videoElementPlayingFailedReplay:!0,mp4RecordUseWasm:!0,mseAutoCleanupSourceBuffer:!0,mseAutoCleanupMaxBackwardDuration:30,mseAutoCleanupMinBackwardDuration:10,widthOrHeightChangeReplay:!0,simdH264DecodeVideoWidthIsTooLargeReplay:!0,mediaSourceAudioG711NotSupportReplay:!0,mediaSourceAudioInitTimeoutReplay:!0,mediaSourceUseCanvasRenderPlayFailedReplay:!0,mediaSourceUseCanvasRenderPlayFailedReplayType:q,widthOrHeightChangeReplayDelayTime:0,ghostWatermarkConfig:{on:5,off:5,content:"",fontSize:12,color:"white",opacity:.15,speed:.2},dynamicWatermarkConfig:{content:"",speed:.2,fontSize:12,color:"white",opacity:.15},isDropSameTimestampGop:!1,mseDecodeAudio:!1,nakedFlowH265DemuxUseNew:!0,extendDomConfig:{html:"",showBeforePlay:!1,showAfterLoading:!0},disableContextmenu:!1,websocket1006ErrorReplay:!1,websocket1006ErrorReplayDelayTime:0,mseDecoderUseWorker:!1},ne="init",oe="initVideo",le="render",de="playAudio",he="initAudio",ce="audioCode",ue="audioNalu",pe="audioAACSequenceHeader",fe="videoCode",ye="videoCodec",me="videoNalu",ge="videoPayload",Ae="audioPayload",ve="wasmError",be="workerFetch",_e="iframeIntervalTs",we="isDropping",Ee="workerEnd",Se="playbackStreamVideoFps",Te="wasmDecodeVideoNoResponseError",ke="wasmWidthOrHeightChange",Ce="simdDecodeError",De="simdH264DecodeVideoWidthIsTooLarge",Re="closeEnd",xe="tempStream",Le="videoSEI",Ie="flvScriptData",Pe="aacSequenceHeader",Be="videoSequenceHeader",Me="flvBufferData",Ue="checkFirstIFrame",Fe="Invalid NAL unit size",Oe=1,Ne=2,Ge=8,ze=9,We=18,Ve="init",He="decode",$e="audioDecode",je="videoDecode",Ke="close",qe="updateConfig",Ye="clearBuffer",Qe="fetchStream",Xe="sendWsMessage",Je="fetch",Ze="destroy",et="buffer",tt="fetchError",it="fetchClose",rt="fetchSuccess",st={fullscreen:"fullscreen$2",webFullscreen:"webFullscreen",decoderWorkerInit:"decoderWorkerInit",play:"play",playing:"playing",pause:"pause",mute:"mute",load:"load",screenshot:"screenshot",screenshots:"screenshots",loading:"loading",zooming:"zooming",videoInfo:"videoInfo",timeUpdate:"timeUpdate",audioInfo:"audioInfo",log:"log",error:"error",kBps:"kBps",timeout:"timeout",delayTimeout:"delayTimeout",delayTimeoutRetryEnd:"delayTimeoutRetryEnd",loadingTimeout:"loadingTimeout",loadingTimeoutRetryEnd:"loadingTimeoutRetryEnd",stats:"stats",performance:"performance",videoSmooth:"videoSmooth",faceDetectActive:"faceDetectActive",objectDetectActive:"objectDetectActive",occlusionDetectActive:"occlusionDetectActive",imageDetectActive:"imageDetectActive",record:"record",recording:"recording",recordingTimestamp:"recordingTimestamp",recordStart:"recordStart",recordEnd:"recordEnd",recordCreateError:"recordCreateError",recordBlob:"recordBlob",buffer:"buffer",videoFrame:"videoFrame",videoSEI:"videoSEI",start:"start",metadata:"metadata",resize:"resize",volumechange:"volumechange",destroy:"destroy",beforeDestroy:"beforeDestroy",streamEnd:"streamEnd",streamRate:"streamRate",streamAbps:"streamAbps",streamVbps:"streamVbps",streamDts:"streamDts",streamSuccess:"streamSuccess",streamMessage:"streamMessage",streamError:"streamError",streamStats:"streamStats",mseSourceOpen:"mseSourceOpen",mseSourceClose:"mseSourceClose",mseSourceended:"mseSourceended",mseSourceBufferError:"mseSourceBufferError",mseAddSourceBufferError:"mseAddSourceBufferError",mseSourceBufferBusy:"mseSourceBufferBusy",mseSourceBufferFull:"mseSourceBufferFull",videoWaiting:"videoWaiting",videoTimeUpdate:"videoTimeUpdate",videoSyncAudio:"videoSyncAudio",playToRenderTimes:"playToRenderTimes",playbackTime:"playbackTime",playbackTimestamp:"playbackTimestamp",playbackTimeScroll:"playbackTimeScroll",playbackPrecision:"playbackPrecision",playbackShowPrecisionChange:"playbackShowPrecisionChange",playbackJustTime:"playbackJustTime",playbackStats:"playbackStats",playbackSeek:"playbackSeek",playbackPause:"playbackPause",playbackPauseOrResume:"playbackPauseOrResume",playbackRateChange:"playbackRateChange",playbackPreRateChange:"playbackPreRateChange",ptz:"ptz",streamQualityChange:"streamQualityChange",visibilityChange:"visibilityChange",netBuf:"netBuf",close:"close",networkDelayTimeout:"networkDelayTimeout",togglePerformancePanel:"togglePerformancePanel",viewResizeChange:"viewResizeChange",flvDemuxBufferSizeTooLarge:"flvDemuxBufferSizeTooLarge",talkGetUserMediaSuccess:"talkGetUserMediaSuccess",talkGetUserMediaFail:"talkGetUserMediaFail",talkGetUserMediaTimeout:"talkGetUserMediaTimeout",talkStreamStart:"talkStreamStart",talkStreamOpen:"talkStreamOpen",talkStreamMessage:"talkStreamMessage",talkStreamClose:"talkStreamClose",talkStreamError:"talkStreamError",talkStreamInactive:"talkStreamInactive",webrtcDisconnect:"webrtcDisconnect",webrtcFailed:"webrtcFailed",webrtcClosed:"webrtcClosed",webrtcOnConnectionStateChange:"webrtcOnConnectionStateChange",webrtcOnIceConnectionStateChange:"webrtcOnIceConnectionStateChange",crashLog:"crashLog",focus:"focus",blur:"blur",visibilityHiddenTimeout:"visibilityHiddenTimeout",websocketOpen:"websocketOpen",websocketClose:"websocketClose",websocketError:"websocketError",websocketMessage:"websocketMessage",aiObjectDetectorInfo:"aiObjectDetectorInfo",aiFaceDetectorInfo:"aiFaceDetectorInfo",aiOcclusionDetectResult:"aiOcclusionDetectResult",aiImageDetectResult:"aiImageDetectResult",playFailedAndPaused:"playFailedAndPaused",audioResumeState:"audioResumeState",webrtcStreamH265:"webrtcStreamH265",rtcConnetMessage:"rtcConnetMessage",flvMetaData:"flvMetaData",talkFailedAndStop:"talkFailedAndStop",removeLoadingBgImage:"removeLoadingBgImage",memoryLog:"memoryLog",downloadMemoryLog:"downloadMemoryLog",pressureObserverCpu:"pressureObserverCpu",currentPts:"currentPts"},at={load:st.load,timeUpdate:st.timeUpdate,videoInfo:st.videoInfo,audioInfo:st.audioInfo,error:st.error,kBps:st.kBps,start:st.start,timeout:st.timeout,loadingTimeout:st.loadingTimeout,loadingTimeoutRetryEnd:st.loadingTimeoutRetryEnd,delayTimeout:st.delayTimeout,delayTimeoutRetryEnd:st.delayTimeoutRetryEnd,fullscreen:"fullscreen",webFullscreen:st.webFullscreen,play:st.play,pause:st.pause,mute:st.mute,stats:st.stats,performance:st.performance,recordingTimestamp:st.recordingTimestamp,recordStart:st.recordStart,recordCreateError:st.recordCreateError,recordEnd:st.recordEnd,recordBlob:st.recordBlob,playToRenderTimes:st.playToRenderTimes,playbackSeek:st.playbackSeek,playbackStats:st.playbackStats,playbackTimestamp:st.playbackTimestamp,playbackPauseOrResume:st.playbackPauseOrResume,playbackPreRateChange:st.playbackPreRateChange,playbackRateChange:st.playbackRateChange,playbackShowPrecisionChange:st.playbackShowPrecisionChange,ptz:st.ptz,streamQualityChange:st.streamQualityChange,zooming:st.zooming,crashLog:st.crashLog,focus:st.focus,blur:st.blur,visibilityHiddenTimeout:st.visibilityHiddenTimeout,visibilityChange:st.visibilityChange,websocketOpen:st.websocketOpen,websocketClose:st.websocketClose,networkDelayTimeout:st.networkDelayTimeout,aiObjectDetectorInfo:st.aiObjectDetectorInfo,aiFaceDetectorInfo:st.aiFaceDetectorInfo,aiOcclusionDetectResult:st.aiOcclusionDetectResult,aiImageDetectResult:st.aiImageDetectResult,playFailedAndPaused:st.playFailedAndPaused,streamEnd:st.streamEnd,audioResumeState:st.audioResumeState,videoSEI:st.videoSEI,flvMetaData:st.flvMetaData,webrtcOnConnectionStateChange:st.webrtcOnConnectionStateChange,webrtcOnIceConnectionStateChange:st.webrtcOnIceConnectionStateChange,rtcConnetMessage:st.rtcConnetMessage,currentPts:st.currentPts,videoSmooth:st.videoSmooth},nt={talkStreamClose:st.talkStreamClose,talkStreamError:st.talkStreamError,talkStreamMessage:st.talkStreamMessage,talkStreamInactive:st.talkStreamInactive,talkGetUserMediaTimeout:st.talkGetUserMediaTimeout,talkFailedAndStop:st.talkFailedAndStop},ot={talkStreamError:st.talkStreamError,talkStreamClose:st.talkStreamClose},lt={playError:"playIsNotPauseOrUrlIsNull",fetchError:"fetchError",websocketError:"websocketError",webcodecsH265NotSupport:"webcodecsH265NotSupport",webcodecsDecodeError:"webcodecsDecodeError",webcodecsUnsupportedConfigurationError:"webcodecsUnsupportedConfigurationError",webcodecsDecodeConfigureError:"webcodecsDecodeConfigureError",mediaSourceH265NotSupport:"mediaSourceH265NotSupport",mediaSourceAudioG711NotSupport:"mediaSourceAudioG711NotSupport",mediaSourceAudioInitTimeout:"mediaSourceAudioInitTimeout",mediaSourceDecoderConfigurationError:"mediaSourceDecoderConfigurationError",mediaSourceFull:st.mseSourceBufferFull,mseSourceBufferError:st.mseSourceBufferError,mseAddSourceBufferError:st.mseAddSourceBufferError,mediaSourceAppendBufferError:"mediaSourceAppendBufferError",mediaSourceTsIsMaxDiff:"mediaSourceTsIsMaxDiff",mediaSourceUseCanvasRenderPlayFailed:"mediaSourceUseCanvasRenderPlayFailed",mediaSourceBufferedIsZeroError:"mediaSourceBufferedIsZeroError",wasmDecodeError:"wasmDecodeError",wasmUseVideoRenderError:"wasmUseVideoRenderError",hlsError:"hlsError",webrtcError:"webrtcError",webrtcClosed:st.webrtcClosed,webrtcIceCandidateError:"webrtcIceCandidateError",webglAlignmentError:"webglAlignmentError",wasmWidthOrHeightChange:"wasmWidthOrHeightChange",mseWidthOrHeightChange:"mseWidthOrHeightChange",wcsWidthOrHeightChange:"wcsWidthOrHeightChange",widthOrHeightChange:"widthOrHeightChange",tallWebsocketClosedByError:"tallWebsocketClosedByError",flvDemuxBufferSizeTooLarge:st.flvDemuxBufferSizeTooLarge,wasmDecodeVideoNoResponseError:"wasmDecodeVideoNoResponseError",audioChannelError:"audioChannelError",simdH264DecodeVideoWidthIsTooLarge:"simdH264DecodeVideoWidthIsTooLarge",simdDecodeError:"simdDecodeError",webglContextLostError:"webglContextLostError",videoElementPlayingFailed:"videoElementPlayingFailed",videoElementPlayingFailedForWebrtc:"videoElementPlayingFailedForWebrtc",decoderWorkerInitError:"decoderWorkerInitError",videoInfoError:"videoInfoError",videoCodecIdError:"videoCodecIdError",streamEnd:st.streamEnd,delayTimeout:st.delayTimeout,loadingTimeout:st.loadingTimeout,networkDelayTimeout:st.networkDelayTimeout,aliyunRtcError:"aliyunRtcError",...ot},dt="notConnect",ht="open",ct="close",ut="error",pt={download:"download",base64:"base64",blob:"blob"},ft="download",yt="blob",mt={7:"H264(AVC)",12:"H265(HEVC)",99:"MPEG4"},gt=7,At=12,vt="H264(AVC)",bt="H265(HEVC)",_t={AAC:10,ALAW:7,MULAW:8,MP3:2},wt={AAC:"AAC",ALAW:"ALAW(g711a)",MULAW:"MULAW(g711u)",MP3:"MP3"},Et={10:"AAC",7:"ALAW",8:"MULAW",2:"MP3"},St={sps:7,pps:8,iFrame:5,kUnspecified:0,kSliceNonIDR:1,kSliceDPA:2,kSliceDPB:3,kSliceDPC:4,kSliceIDR:5,kSliceSEI:6,kSliceSPS:7,kSlicePPS:8,kSliceAUD:9,kEndOfSequence:10,kEndOfStream:11,kFiller:12,kSPSExt:13,kReserved0:14},Tt=19,kt=20,Ct=32,Dt=33,Rt=34,xt=39,Lt=39,It=40,Pt=48,Bt=0,Mt=1,Ut=2,Ft="webcodecs",Ot="webgl",Nt="webgl2",Gt="webgpu",zt="offscreen",Wt="mse",Vt="hls",Ht="webrtc",$t="key",jt="delta",Kt='video/mp4; codecs="avc1.64002A"',qt='video/mp4; codecs="hev1.1.6.L123.b0"',Yt="ended",Qt="open",Xt="closed",Jt=2e3,Zt=27,ei=38,ti=40,ii="oneHour",ri="halfHour",si="tenMin",ai="fiveMin",ni={oneHour:"one-hour",halfHour:"half-hour",tenMin:"ten-min",fiveMin:"five-min"},oi=["oneHour","halfHour","tenMin","fiveMin"],li=["up","right","down","left","left-up","right-up","left-down","right-down"],di="stop",hi="fiStop",ci="zoomExpand",ui="zoomNarrow",pi="apertureFar",fi="apertureNear",yi="focusFar",mi="focusNear",gi="g711a",Ai="g711u",vi="pcm",bi="opus",_i={png:"image/png",jpeg:"image/jpeg",webp:"image/webp"},wi={sourceClose:"sourceclose",sourceOpen:"sourceopen",sourceended:"sourceended"},Ei="canplay",Si="waiting",Ti="timeupdate",ki="ratechange",Ci="hevc",Di="A key frame is required after configure() or flush()",Ri="Cannot call 'decode' on a closed codec",xi="Unsupported configuration",Li="Decoder failure",Ii="Decoding error",Pi="Decoder error",Bi="HEVC decoding is not supported",Mi="loading",Ui="playing",Fi="paused",Oi="destroy",Ni=0,Gi=1,zi=8,Wi=0,Vi=98,Hi="empty",$i="rtp",ji="tcp",Ki="open",qi="close",Yi="error",Qi="message",Xi="worklet",Ji="script",Zi={encType:gi,packetType:$i,packetTcpSendType:ji,rtpSsrc:"0000000000",numberChannels:1,sampleRate:8e3,sampleBitsWidth:16,sendInterval:20,debug:!1,debugLevel:Q,testMicrophone:!1,saveRtpToFile:!1,audioBufferLength:160,engine:Xi,checkGetUserMediaTimeout:!1,getUserMediaTimeout:1e4,audioConstraints:{latency:!0,noiseSuppression:!0,autoGainControl:!0,echoCancellation:!0,sampleRate:48e3,channelCount:1}},er="worklet",tr="script",ir="active",rr={name:"",index:0,icon:"",iconHover:"",iconTitle:"",activeIcon:"",activeIconHover:"",activeIconTitle:"",click:null,activeClick:null},sr={content:"",click:null,index:0},ar={container:"",maxSplit:4,split:1,draggable:!1,showSelectedBorder:!0,supportDblclickContainerFullscreen:!1,supportMousemoveEvent:!1,style:{border:"#343434",borderSelect:"#FFCC00",background:"#000"}},nr={multiFullscreen:"multiFullscreen",dblSelected:"multiDblSelected",selected:"multiSelected",mouseover:"multiMouseover",mouseout:"multiMouseout",mouseup:"multiMouseup",mousedown:"multiMousedown",mousemove:"multiMousemove",dragstart:"multiDragstart",dragenter:"multiDragenter",dragleave:"multiDragleave",drop:"multiDrop"},or="3-1",lr="4-1",dr=1,hr="subtitle-segments",cr="hls-manifest-loaded",ur="hls-level-loaded",pr="demuxed-track",fr="flv-script-data",yr="metadata-parsed",mr="ttfb",gr="load-retry",Ar="load-start",vr="speed",br="load-complete",_r="load-response-headers",wr="sei",Er="sei-in-time",Sr="switch-url-failed",Tr="switch-url-success",kr="subtitle-playlist",Cr="stream-parsed",Dr="error",Rr=[0,160,240,320,480,640],xr=[0,160,240,320,480,640],Lr=["轻松","正常","较高","高"],Ir={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"},Pr="video decoder initialization failed",Br=1,Mr=2,Ur=0,Fr=1,Or=3,Nr=16,Gr="candidate-pair",zr="inbound-rtp",Wr="local-candidate",Vr="remote-candidate",Hr="track",$r="ulaw",jr="alaw",Kr="mp3",qr=9e4,Yr=45e4,Qr=9e4;class Xr{constructor(e){this.log=(t,...i)=>{if(e._opt.debug&&e._opt.debugLevel==Y){const r=e._opt.debugUuid?`[${e._opt.debugUuid}]`:"";console.log(`EasyPro${r}[✅✅✅][${t}]`,...i)}},this.warn=(t,...i)=>{if(e._opt.debug&&(e._opt.debugLevel==Y||e._opt.debugLevel==Q)){const r=e._opt.debugUuid?`[${e._opt.debugUuid}]`:"";console.log(`EasyPro${r}[❗❗❗][${t}]`,...i)}},this.error=(t,...i)=>{const r=e._opt.debugUuid?`[${e._opt.debugUuid}]`:"";console.error(`EasyPro${r}[❌❌❌][${t}]`,...i)}}}var Jr="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Zr(e,t){return e(t={exports:{}},t.exports),t.exports}var es=Zr((function(e){!function(){var t="undefined"!=typeof window&&void 0!==window.document?window.document:{},i=e.exports,r=function(){for(var e,i=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],r=0,s=i.length,a={};r<s;r++)if((e=i[r])&&e[1]in t){for(r=0;r<e.length;r++)a[i[0][r]]=e[r];return a}return!1}(),s={change:r.fullscreenchange,error:r.fullscreenerror},a={request:function(e,i){return new Promise(function(s,a){var n=function(){this.off("change",n),s()}.bind(this);this.on("change",n);var o=(e=e||t.documentElement)[r.requestFullscreen](i);o instanceof Promise&&o.then(n).catch(a)}.bind(this))},exit:function(){return new Promise(function(e,i){if(this.isFullscreen){var s=function(){this.off("change",s),e()}.bind(this);this.on("change",s);var a=t[r.exitFullscreen]();a instanceof Promise&&a.then(s).catch(i)}else e()}.bind(this))},toggle:function(e,t){return this.isFullscreen?this.exit():this.request(e,t)},onchange:function(e){this.on("change",e)},onerror:function(e){this.on("error",e)},on:function(e,i){var r=s[e];r&&t.addEventListener(r,i,!1)},off:function(e,i){var r=s[e];r&&t.removeEventListener(r,i,!1)},raw:r};r?(Object.defineProperties(a,{isFullscreen:{get:function(){return Boolean(t[r.fullscreenElement])}},element:{enumerable:!0,get:function(){return t[r.fullscreenElement]}},isEnabled:{enumerable:!0,get:function(){return Boolean(t[r.fullscreenEnabled])}}}),i?e.exports=a:window.screenfull=a):i?e.exports={isEnabled:!1}:window.screenfull={isEnabled:!1}}()}));function ts({profile:e,sampleRate:t,channel:i}){return new Uint8Array([175,0,e<<3|(14&t)>>1,(1&t)<<7|i<<3])}function is(e){return rs(e)&&e[1]===Ni}function rs(e){return e[0]>>4===_t.AAC}es.isEnabled;const ss=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],as=ss;function ns(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)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]);if(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])}}function os(e,t=9e4){return 1024*t/e}const ls=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];function ds(e){let t=new Uint8Array(e),i=null,r=0,s=0,a=0,n=null;if(r=s=t[0]>>>3,a=(7&t[0])<<1|t[1]>>>7,a<0||a>=ls.length)return void console.error("Flv: AAC invalid sampling frequency index!");let o=ls[a],l=(120&t[1])>>>3;if(l<0||l>=8)return void console.log("Flv: AAC invalid channel configuration");5===r&&(n=(7&t[1])<<1|t[2]>>>7,t[2]);let d=self.navigator.userAgent.toLowerCase();return-1!==d.indexOf("firefox")?a>=6?(r=5,i=new Array(4),n=a-3):(r=2,i=new Array(2),n=a):-1!==d.indexOf("android")?(r=2,i=new Array(2),n=a):(r=5,n=a,i=new Array(4),a>=6?n=a-3:1===l&&(r=2,i=new Array(2),n=a)),i[0]=r<<3,i[0]|=(15&a)>>>1,i[1]=(15&a)<<7,i[1]|=(15&l)<<3,5===r&&(i[1]|=(15&n)>>>1,i[2]=(1&n)<<7,i[2]|=8,i[3]=0),{audioType:"aac",config:i,sampleRate:o,channelCount:l,objectType:r,codec:"mp4a.40."+r,originalCodec:"mp4a.40."+s}}class hs{constructor(e){this.buffer=e,this.buflen=e.length,this.bufpos=0,this.bufoff=0,this.iserro=!1}read(e){let t=0,i=0;for(;e;){if(e<0||this.bufpos>=this.buflen)return this.iserro=!0,0;this.iserro=!1,i=this.bufoff+e>8?8-this.bufoff:e,t<<=i,t+=this.buffer[this.bufpos]>>8-this.bufoff-i&255>>8-i,this.bufoff+=i,e-=i,8==this.bufoff&&(this.bufpos++,this.bufoff=0)}return t}look(e){let t=this.bufpos,i=this.bufoff,r=this.read(e);return this.bufpos=t,this.bufoff=i,r}read_golomb(){let e;for(e=0;0==this.read(1)&&!this.iserro;e++);return(1<<e)+this.read(e)-1}}function cs(e){let t=e.read(5);return 31===t&&(t=e.read(6)+32),t}function us(e,t){return t.sampling_index=e.read(4),15==t.sampling_index?e.read(24):ps[t.sampling_index]}const ps=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350,0,0,0],fs=[0,1,2,3,4,5,6,8];function ys(){}function ms(e){let t=null;const i=["webgl","experimental-webgl","moz-webgl","webkit-3d"];let r=0;for(;!t&&r<i.length;){const s=i[r];try{let i={preserveDrawingBuffer:!0};t=e.getContext(s,i)}catch(e){console.error(e),t=null}t&&"function"==typeof t.getParameter||(t=null),++r}return t}function gs(e){let t=null;return t=e.getContext("webgl2"),t}function As(e=""){const t=e.split(","),i=atob(t[1]),r=t[0].replace("data:","").replace(";base64","");let s=i.length,a=new Uint8Array(s);for(;s--;)a[s]=i.charCodeAt(s);return new File([a],"file",{type:r})}function vs(){return(new Date).getTime()}function bs(e,t,i){return Math.max(Math.min(e,Math.max(t,i)),Math.min(t,i))}function _s(e,t,i){if(e)return"object"==typeof t&&Object.keys(t).forEach((i=>{_s(e,i,t[i])})),e.style[t]=i,e}function ws(e,t,i=!0){if(!e)return 0;const r=getComputedStyle(e,null).getPropertyValue(t);return i?parseFloat(r):r}function Es(){return performance&&"function"==typeof performance.now?performance.now():Date.now()}function Ss(e){let t=0,i=Es();return r=>{if(!Ns(r))return;t+=r;const s=Es(),a=s-i;a>=1e3&&(e(t/a*1e3),i=s,t=0)}}(()=>{try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){const e=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(e instanceof WebAssembly.Module)return new WebAssembly.Instance(e)instanceof WebAssembly.Instance}}catch(e){}})();const Ts='"2024-7-26"';function ks(){return/iphone|ipod|android.*mobile|windows.*phone|blackberry.*mobile/i.test(window.navigator.userAgent.toLowerCase())}function Cs(){return!(ks()||/ipad|android(?!.*mobile)|tablet|kindle|silk/i.test(window.navigator.userAgent.toLowerCase()))}function Ds(){const e=window.navigator.userAgent.toLowerCase();return/android/i.test(e)}function Rs(){const e=window.navigator.userAgent.toLowerCase();return/firefox/i.test(e)}function xs(){const e=window.navigator.userAgent.toLowerCase()||"",t={type:"",version:""},i={IE:window.ActiveXObject||"ActiveXObject"in window,Chrome:e.indexOf("chrome")>-1&&e.indexOf("safari")>-1,Firefox:e.indexOf("firefox")>-1,Opera:e.indexOf("opera")>-1,Safari:e.indexOf("safari")>-1&&-1==e.indexOf("chrome"),Edge:e.indexOf("edge")>-1,QQBrowser:/qqbrowser/.test(e),WeixinBrowser:/MicroMessenger/i.test(e)};for(let r in i)if(i[r]){let i="";if("IE"===r){const t=e.match(/(msie\s|trident.*rv:)([\w.]+)/);t&&t.length>2&&(i=e.match(/(msie\s|trident.*rv:)([\w.]+)/)[2])}else if("Chrome"===r){for(let e in navigator.mimeTypes)"application/360softmgrplugin"===navigator.mimeTypes[e].type&&(r="360");const t=e.match(/chrome\/([\d.]+)/);t&&t.length>1&&(i=t[1])}else if("Firefox"===r){const t=e.match(/firefox\/([\d.]+)/);t&&t.length>1&&(i=t[1])}else if("Opera"===r){const t=e.match(/opera\/([\d.]+)/);t&&t.length>1&&(i=t[1])}else if("Safari"===r){const t=e.match(/version\/([\d.]+)/);t&&t.length>1&&(i=t[1])}else if("Edge"===r){const t=e.match(/edge\/([\d.]+)/);t&&t.length>1&&(i=t[1])}else if("QQBrowser"===r){const t=e.match(/qqbrowser\/([\d.]+)/);t&&t.length>1&&(i=t[1])}t.type=r,t.version=parseInt(i)}return t}function Ls(){const e=window.navigator.userAgent.toLowerCase();return e&&/iphone|ipad|ipod|ios/.test(e)}function Is(){const e=window.navigator.userAgent;return!e.match(/Chrome/gi)&&!!e.match(/Safari/gi)}function Ps(e,t){if(0===arguments.length)return null;var i,r=t||"{y}-{m}-{d} {h}:{i}:{s}";"object"==typeof e?i=e:(10===(""+e).length&&(e=1e3*parseInt(e)),e=+e,i=new Date(e));var s={y:i.getFullYear(),m:i.getMonth()+1,d:i.getDate(),h:i.getHours(),i:i.getMinutes(),s:i.getSeconds(),a:i.getDay()};return r.replace(/{(y|m|d|h|i|s|a)+}/g,((e,t)=>{var i=s[t];return"a"===t?["一","二","三","四","五","六","日"][i-1]:(e.length>0&&i<10&&(i="0"+i),i||0)}))}function Bs(){return"VideoFrame"in window}function Ms(e){if("string"!=typeof e)return e;var t=Number(e);return isNaN(t)?e:t}function Us(){return"xxxxxxxxxxxx4xxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))}function Fs(e,t){let i,r,s=!1;return function a(...n){if(s)return i=n,void(r=this);s=!0,e.apply(this,n),setTimeout((()=>{s=!1,i&&(a.apply(r,i),i=null,r=null)}),t)}}function Os(e){if(null==e||""==e)return"0 Bytes";const t=new Array("Bytes","KB","MB","GB","TB","PB","EB","ZB","YB");let i=0;const r=parseFloat(e);i=Math.floor(Math.log(r)/Math.log(1024));var s=r/Math.pow(1024,i);return(s=s.toFixed(2))+t[i]}function Ns(e){return"[object Number]"===Object.prototype.toString.call(e)}function Gs(){let e=!1;return"MediaSource"in self&&self.MediaSource.isTypeSupported(qt)&&(e=!0),e}function zs(){const e=xs();return"chrome"===e.type.toLowerCase()&&e.version>=107}function Ws(){let e=!1;return"MediaStreamTrackGenerator"in window&&(e=!0),e}function Vs(){let e=!1;return"MediaStream"in window&&(e=!0),e}function Hs(e,t){let i=window.URL.createObjectURL(t),r=window.document.createElement("a");r.download=e,r.href=i;let s=window.document.createEvent("MouseEvents");s.initEvent("click",!0,!0),r.dispatchEvent(s),setTimeout((()=>{window.URL.revokeObjectURL(i)}),Ls()?1e3:0)}function $s(e){return null==e}function js(e){return!0===e||!1===e}function Ks(e){return!$s(e)}function qs(e){let t={left:"",right:"",top:"",bottom:"",opacity:1,backgroundColor:"",image:{src:"",width:"100",height:"60"},text:{content:"",fontSize:"14",color:"#000",width:"",height:""},rect:{color:"green",lineWidth:2,width:"",height:"",fill:"",fillOpacity:.2},line:{x1:"",y1:"",x2:"",y2:"",color:"green",lineWidth:2},polygon:{color:"green",lineWidth:2,list:[],fill:"",fillOpacity:.2},html:""};const i=Object.assign(t.image,e.image||{}),r=Object.assign(t.text,e.text||{}),s=Object.assign(t.rect,e.rect||{}),a=Object.assign(t.line,e.line||{});return t=Object.assign(t,e,{image:i,text:r,rect:s,line:a}),t}function Ys(e,t){let i={container:e||"",text:"",opacity:"",angle:"",color:"",fontSize:"",fontFamily:""};return i=Object.assign(i,t),{watermark_parent_node:i.container,watermark_alpha:i.opacity,watermark_angle:i.angle,watermark_fontsize:i.fontSize,watermark_color:i.color,watermark_font:i.fontFamily,watermark_txt:i.text}}function Qs(e,t){return new Promise(((i,r)=>{let s=qs(t);if(!s.image.src&&!s.text.content)return i(e);let a=document.createElement("canvas");a.width=t.width,a.height=t.height;let n=a.getContext("2d");Ns(s.left)?s.left:Ns(s.right)&&(a.width,s.right),Ns(s.top)?s.top:Ns(s.bottom)&&(a.height,s.bottom);const o=new Image;o.src=e,o.onload=()=>{if(n.drawImage(o,0,0,a.width,a.height),s.image&&s.image.src){const e=new Image;e.src=s.image.src,e.setAttribute("crossOrigin","Anonymous"),e.onload=()=>{let e=a.width/2,r=a.height/2;n.translate(e,r),n.rotate(-Math.PI/4),n.font=s.text.fontSize+"px 宋体",n.fillStyle=s.text.color,n.textAlign="center",n.fillText(s.text.content,0,0),n.rotate(Math.PI/4),n.translate(-e,-r),i(a.toDataURL(t.format,t.quality))},e.onerror=e=>{r(e)}}else if(s.text&&s.text.content){n.font=s.text.fontSize+"px 宋体",n.fillStyle=s.text.color,n.textAlign="center",n.textBaseline="middle";const e=n.measureText(s.text.content).width,r=s.text.fontSize;for(let t=0;t<a.height;t+=5*r)for(let i=0;i<a.width;i+=2*e)n.save(),n.translate(i,t),n.rotate(-Math.PI/6),n.fillText(s.text.content,0,0),n.restore();i(a.toDataURL(t.format,t.quality))}},o.onerror=e=>{r(e)}}))}function Xs(e){var t;if(e>-1){var i=Math.floor(e/3600),r=Math.floor(e/60)%60,s=e%60;t=i<10?"0"+i+":":i+":",r<10&&(t+="0"),t+=r+":",(s=Math.round(s))<10&&(t+="0"),t+=s.toFixed(0)}return t}function Js(e,t){let i="";if(e>-1){const r=Math.floor(e/60)%60;let s=e%60;s=Math.round(s),i=r<10?"0"+r+":":r+":",s<10&&(i+="0"),i+=s,$s(t)||(t<10&&(t="0"+t),i+=":"+t)}return i}function Zs(e){let t="";if(e>-1){const i=Math.floor(e/60/60)%60;let r=Math.floor(e/60)%60,s=e%60;r=Math.round(r),t=i<10?"0"+i+":":i+":",r<10&&(t+="0"),t+=r+":",s<10&&(t+="0"),t+=s}return t}function ea(e,t){const i=Math.floor(t/60)%60,r=Math.floor(t%60);return new Date(e).setHours(i,r,0,0)}function ta(e,t){const i=Math.floor(t/60/60)%60,r=Math.floor(t/60)%60,s=t%60;return new Date(e).setHours(i,r,s,0)}function ia(e){return(""+e).length}function ra(e){return e&&0===Object.keys(e).length}function sa(e){return!ra(e)}function aa(e){return"string"==typeof e}const na=()=>{const e=window.navigator.userAgent;return/MicroMessenger/i.test(e)},oa=()=>{const e=window.navigator.userAgent;return/Chrome/i.test(e)};function la(e){const t=e||window.event;return t.target||t.srcElement}function da(){return Rs()&&function(){const e=navigator.userAgent.toLowerCase();return/macintosh|mac os x/i.test(e)}()}function ha(e){return"function"==typeof e}function ca(e){if(ks()){let t=0,i=0;if(1===e.touches.length){let r=e.touches[0];t=r.clientX,i=r.clientY}return{posX:t,posY:i}}let t=0,i=0;const r=e||window.event;return r.pageX||r.pageY?(t=r.pageX,i=r.pageY):(r.clientX||r.clientY)&&(t=e.clientX+document.documentElement.scrollLeft+document.body.scrollLeft,i=e.clientY+document.documentElement.scrollTop+document.body.scrollTop),{posX:t,posY:i}}function ua(){let e=document.createElement("video"),t=e.canPlayType("application/vnd.apple.mpegurl");return e=null,t}function pa(e){let t=ka(e.hasAudio)&&(e.useMSE||e.useWCS&&!e.useOffscreen)&&ka(e.demuxUseWorker);return!!(ka(t)&&e.useMSE&&e.mseDecodeAudio&&ka(e.demuxUseWorker))||t}function fa(e){const t=e.toString().trim().match(/^function\s*\w*\s*\([\w\s,]*\)\s*{([\w\W]*?)}$/)[1];console.log(">>>funcStr >>>",t);const i=new Blob([t],{type:"application/javascript"});return URL.createObjectURL(i)}function ya(e){e.close()}function ma(){return"https:"===window.location.protocol||"localhost"===window.location.hostname}function ga(e){const t=Object.prototype.toString;return function(e){switch(t.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:try{return e instanceof Error}catch(e){return!1}}}(e)?e.message:null==e?"":"object"==typeof e?JSON.stringify(e,null,2):String(e)}function Aa(e,t){t&&(e=e.filter((e=>e.type&&e.type===t)));let i=e[0],r=null,s=1;if(e.length>0){let t=e[1];t&&t.ts-i.ts>1e5&&(i=t,s=2)}if(i)for(let a=s;a<e.length;a++){let s=e[a];if(t&&s.type&&s.type!==t&&(s=null),s){if(s.ts-i.ts>=1e3){e[a-1].ts-i.ts<1e3&&(r=a+1)}}}return r}function va(e){for(var t=(e+"=".repeat((4-e.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),i=window.atob(t),r=new Uint8Array(i.length),s=0;s<i.length;++s)r[s]=i.charCodeAt(s);return r}function ba(e){const t=/(msie|trident)/i.test(navigator.userAgent),i=document.createElement("a");let r=e;return t&&(i.setAttribute("href",r),r=i.href),i.setAttribute("href",r),{origin:i.origin,href:i.href,protocol:i.protocol?i.protocol.replace(/:$/,""):"",host:i.host,search:i.search?i.search.replace(/^\?/,""):"",hash:i.hash?i.hash.replace(/^#/,""):"",hostname:i.hostname,port:i.port,pathname:"/"===i.pathname.charAt(0)?i.pathname:"/"+i.pathname}}function _a(e){let t="";if("object"==typeof e)try{t=JSON.stringify(e),t=JSON.parse(t)}catch(i){t=e}else t=e;return t}function wa(){return _a(se)}function Ea(){return _a(ae)}function Sa(e){return e[0]>>4===Gi&&e[1]===Ni}function Ta(e){return!0===e||"true"===e}function ka(e){return!0!==e&&"true"!==e}function Ca(e,t,i){e&&(e.dataset?e.dataset[t]=i:e.setAttribute("data-"+t,i))}function Da(e,t){return e?e.dataset?e.dataset[t]:e.getAttribute("data-"+t):""}function Ra(e){return e.replace(/-([a-z])/g,(function(e,t){return t.toUpperCase()}))}function xa(){return/iphone/i.test(navigator.userAgent)}function La(){try{var e=document.createElement("canvas");return!(!window.WebGL2RenderingContext||!e.getContext("webgl2"))}catch(e){return!1}}function Ia(e){return e.trim().match(/^function\s*\w*\s*\([\w\s,]*\)\s*{([\w\W]*?)}$/)[1]}function Pa(){let e=!1;return"requestVideoFrameCallback"in HTMLVideoElement.prototype&&(e=!0),e}function Ba(){let e=!1;return"PressureObserver"in window&&(e=!0),e}class Ma{constructor(e){this.destroys=[],this.proxy=this.proxy.bind(this),this.master=e}proxy(e,t,i,r={}){if(!e)return;if(Array.isArray(t))return t.map((t=>this.proxy(e,t,i,r)));e.addEventListener(t,i,r);const s=()=>{ha(e.removeEventListener)&&e.removeEventListener(t,i,r)};return this.destroys.push(s),s}destroy(){this.master.debug&&this.master.debug.log("Events","destroy"),this.destroys.forEach((e=>e())),this.destroys=[]}}var Ua=1e-6,Fa="undefined"!=typeof Float32Array?Float32Array:Array;function Oa(){var e=new Fa(16);return Fa!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function Na(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var Ga,za=function(e,t,i,r,s,a,n){var o=1/(t-i),l=1/(r-s),d=1/(a-n);return e[0]=-2*o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*d,e[11]=0,e[12]=(t+i)*o,e[13]=(s+r)*l,e[14]=(n+a)*d,e[15]=1,e};function Wa(e,t,i){var r=new Fa(3);return r[0]=e,r[1]=t,r[2]=i,r}Ga=new Fa(3),Fa!=Float32Array&&(Ga[0]=0,Ga[1]=0,Ga[2]=0);class Va{constructor(e,t){this.gl=e,t&&this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1);const i=this._initShaderProgram();this._programInfo={program:i,attribLocations:{vertexPosition:e.getAttribLocation(i,"aVertexPosition"),texturePosition:e.getAttribLocation(i,"aTexturePosition")},uniformLocations:{projectionMatrix:e.getUniformLocation(i,"uProjectionMatrix"),modelMatrix:e.getUniformLocation(i,"uModelMatrix"),viewMatrix:e.getUniformLocation(i,"uViewMatrix"),rgbatexture:e.getUniformLocation(i,"rgbaTexture"),ytexture:e.getUniformLocation(i,"yTexture"),utexture:e.getUniformLocation(i,"uTexture"),vtexture:e.getUniformLocation(i,"vTexture"),isyuv:e.getUniformLocation(i,"isyuv")}},this._buffers=this._initBuffers(),this._rgbatexture=this._createTexture(),this._ytexture=this._createTexture(),this._utexture=this._createTexture(),this._vtexture=this._createTexture()}destroy(){this.gl.deleteProgram(this._programInfo.program),this.gl.deleteBuffer(this._buffers.position),this.gl.deleteBuffer(this._buffers.texPosition),this.gl.deleteBuffer(this._buffers.indices),this.gl.deleteTexture(this._rgbatexture),this.gl.deleteTexture(this._ytexture),this.gl.deleteTexture(this._utexture),this.gl.deleteTexture(this._vtexture),this._programInfo=null,this._buffers=null,this._rgbatexture=null,this._ytexture=null,this._utexture=null,this._vtexture=null}_initShaderProgram(){const e=this._loadShader(this.gl.VERTEX_SHADER,"\n attribute vec4 aVertexPosition;\n attribute vec2 aTexturePosition;\n varying lowp vec2 vTexturePosition;\n void main(void) {\n gl_Position = aVertexPosition;\n vTexturePosition = aTexturePosition;\n }\n "),t=this._loadShader(this.gl.FRAGMENT_SHADER,"\n precision highp float;\n varying highp vec2 vTexturePosition;\n uniform int isyuv;\n uniform sampler2D rgbaTexture;\n uniform sampler2D yTexture;\n uniform sampler2D uTexture;\n uniform sampler2D vTexture;\n\n const mat4 YUV2RGB = mat4( 1.1643828125, 0, 1.59602734375, -.87078515625,\n 1.1643828125, -.39176171875, -.81296875, .52959375,\n 1.1643828125, 2.017234375, 0, -1.081390625,\n 0, 0, 0, 1);\n\n\n void main(void) {\n\n if (isyuv>0) {\n\n highp float y = texture2D(yTexture, vTexturePosition).r;\n highp float u = texture2D(uTexture, vTexturePosition).r;\n highp float v = texture2D(vTexture, vTexturePosition).r;\n gl_FragColor = vec4(y, u, v, 1) * YUV2RGB;\n\n } else {\n gl_FragColor = texture2D(rgbaTexture, vTexturePosition);\n }\n }\n "),i=this.gl.createProgram();return this.gl.attachShader(i,e),this.gl.attachShader(i,t),this.gl.linkProgram(i),this.gl.getProgramParameter(i,this.gl.LINK_STATUS)?i:(console.log("Unable to initialize the shader program: "+this.gl.getProgramInfoLog(i)),null)}_loadShader(e,t){const i=this.gl,r=i.createShader(e);return i.shaderSource(r,t),i.compileShader(r),i.getShaderParameter(r,i.COMPILE_STATUS)?r:(console.log("An error occurred compiling the shaders: "+i.getShaderInfoLog(r)),i.deleteShader(r),null)}_initBuffers(){const e=this.gl,t=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,t);const i=[-1,-1,1,-1,1,1,-1,1];e.bufferData(e.ARRAY_BUFFER,new Float32Array(i),e.STATIC_DRAW);var r=[];r=r.concat([0,1],[1,1],[1,0],[0,0]);const s=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,s),e.bufferData(e.ARRAY_BUFFER,new Float32Array(r),e.STATIC_DRAW);const a=e.createBuffer();e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,a);return e.bufferData(e.ELEMENT_ARRAY_BUFFER,new Uint16Array([0,1,2,0,2,3]),e.STATIC_DRAW),{positions:i,position:t,texPosition:s,indices:a}}_createTexture(){let e=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),e}_drawScene(e,t,i){this.gl.viewport(0,0,e,t),this.gl.enable(this.gl.BLEND),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._buffers.position),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(this._buffers.positions),this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this._programInfo.attribLocations.vertexPosition,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this._programInfo.attribLocations.vertexPosition),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._buffers.texPosition),this.gl.vertexAttribPointer(this._programInfo.attribLocations.texturePosition,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this._programInfo.attribLocations.texturePosition),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this._buffers.indices);i?(this.gl.activeTexture(this.gl.TEXTURE0+3),this.gl.bindTexture(this.gl.TEXTURE_2D,this._ytexture),this.gl.activeTexture(this.gl.TEXTURE0+4),this.gl.bindTexture(this.gl.TEXTURE_2D,this._utexture),this.gl.activeTexture(this.gl.TEXTURE0+5),this.gl.bindTexture(this.gl.TEXTURE_2D,this._vtexture)):(this.gl.activeTexture(this.gl.TEXTURE0+2),this.gl.bindTexture(this.gl.TEXTURE_2D,this._rgbatexture)),this.gl.useProgram(this._programInfo.program),this.gl.uniform1i(this._programInfo.uniformLocations.rgbatexture,2),this.gl.uniform1i(this._programInfo.uniformLocations.ytexture,3),this.gl.uniform1i(this._programInfo.uniformLocations.utexture,4),this.gl.uniform1i(this._programInfo.uniformLocations.vtexture,5),this.gl.uniform1i(this._programInfo.uniformLocations.isyuv,i?1:0),this.gl.drawElements(this.gl.TRIANGLES,6,this.gl.UNSIGNED_SHORT,0)}_calRect(e,t,i,r,s,a){let n=2*e/s-1,o=2*(a-t-r)/a-1,l=2*(e+i)/s-1,d=2*(a-t)/a-1;return[n,o,l,o,l,d,n,d]}_clear(){this.gl.clearColor(0,0,0,1),this.gl.clearDepth(1),this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT)}render(e,t,i,r,s){const a=this.gl;this._clear(),a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,this._ytexture),a.texImage2D(a.TEXTURE_2D,0,a.LUMINANCE,e,t,0,a.LUMINANCE,a.UNSIGNED_BYTE,i),a.activeTexture(a.TEXTURE1),a.bindTexture(a.TEXTURE_2D,this._utexture),a.texImage2D(a.TEXTURE_2D,0,a.LUMINANCE,e/2,t/2,0,a.LUMINANCE,a.UNSIGNED_BYTE,r),a.activeTexture(a.TEXTURE2),a.bindTexture(a.TEXTURE_2D,this._vtexture),a.texImage2D(a.TEXTURE_2D,0,a.LUMINANCE,e/2,t/2,0,a.LUMINANCE,a.UNSIGNED_BYTE,s),this._buffers.positions=[-1,-1,1,-1,1,1,-1,1],this._drawScene(e,t,!0)}renderYUV(e,t,i){let r=i.slice(0,e*t),s=i.slice(e*t,e*t*5/4),a=i.slice(e*t*5/4,e*t*3/2);const n=this.gl;this._clear(),n.activeTexture(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,this._ytexture),n.texImage2D(n.TEXTURE_2D,0,n.LUMINANCE,e,t,0,n.LUMINANCE,n.UNSIGNED_BYTE,r),n.activeTexture(n.TEXTURE1),n.bindTexture(n.TEXTURE_2D,this._utexture),n.texImage2D(n.TEXTURE_2D,0,n.LUMINANCE,e/2,t/2,0,n.LUMINANCE,n.UNSIGNED_BYTE,s),n.activeTexture(n.TEXTURE2),n.bindTexture(n.TEXTURE_2D,this._vtexture),n.texImage2D(n.TEXTURE_2D,0,n.LUMINANCE,e/2,t/2,0,n.LUMINANCE,n.UNSIGNED_BYTE,a),this._buffers.positions=[-1,-1,1,-1,1,1,-1,1],this._drawScene(e,t,!0)}drawDom(e,t,i,r,s){const a=this.gl;a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,this._rgbatexture),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,s),this._buffers.positions=this._calRect(i,r,s.width,s.height,e,t),this._drawScene(e,t,!1)}}class Ha{constructor(e){this.gpu=e,this.pipeline=null,this.matrixGroupInfo=null,this.depthTexture=null,this.textureGroupInfo=null,this.hasInited=!1,this.buffers=this._initBuffer(),this._initPipeline().then((e=>{this.pipeline=e,this.matrixGroupInfo=this._initMatrixGroupInfo(),this.hasInited=!0}))}destroy(){this.gpu&&(this.gpu.device.destroy(),this.gpu=null),this.hasInited=!1,this.pipeline=null,this.matrixGroupInfo=null,this.depthTexture=null,this.textureGroupInfo=null}_initBuffer(){const e=this.gpu.device,t=new Float32Array([-1,-1,-1,1,-1,-1,1,1,-1,-1,1,-1]),i=e.createBuffer({size:t.byteLength,usage:window.GPUBufferUsage.VERTEX|window.GPUBufferUsage.COPY_DST});e.queue.writeBuffer(i,0,t);const r=new Float32Array([0,1,1,1,1,0,0,0]),s=e.createBuffer({size:r.byteLength,usage:window.GPUBufferUsage.VERTEX|window.GPUBufferUsage.COPY_DST});e.queue.writeBuffer(s,0,r);const a=new Uint16Array([0,1,2,0,2,3]),n=e.createBuffer({size:a.byteLength,usage:window.GPUBufferUsage.INDEX|window.GPUBufferUsage.COPY_DST});return e.queue.writeBuffer(n,0,a),{positionBuffer:i,texpositionBuffer:s,indexBuffer:n}}_initPipeline(){return new Promise(((e,t)=>{const i=this.gpu.device,r=this.gpu.format,s={layout:"auto",vertex:{module:i.createShaderModule({code:"\n\n @binding(0) @group(0) var<uniform> uModelMatrix : mat4x4<f32>;\n @binding(1) @group(0) var<uniform> uViewMatrix : mat4x4<f32>;\n @binding(2) @group(0) var<uniform> uProjectionMatrix : mat4x4<f32>;\n\n struct VertexOutput {\n @builtin(position) Position : vec4<f32>,\n @location(0) vTexturePosition : vec2<f32>,\n }\n\n @vertex\n fn main(\n @location(0) aVertexPosition : vec4<f32>,\n @location(1) aTexturePosition : vec2<f32>\n ) -> VertexOutput {\n var output : VertexOutput;\n var tmppos : vec4<f32> = uProjectionMatrix * uViewMatrix * uModelMatrix * aVertexPosition;\n output.Position = vec4<f32>(tmppos.x, tmppos.y, (tmppos.z+1.)/2., tmppos.w); // webgl z [-1, 1], webgpu z [0, 1], 这里z做下调整 z-webgpu = (z-webgl+1)/2\n output.vTexturePosition = aTexturePosition;\n return output;\n }\n\n "}),entryPoint:"main",buffers:[{arrayStride:12,attributes:[{shaderLocation:0,offset:0,format:"float32x3"}]},{arrayStride:8,attributes:[{shaderLocation:1,offset:0,format:"float32x2"}]}]},primitive:{topology:"triangle-list"},fragment:{module:i.createShaderModule({code:"\n @group(1) @binding(0) var mySampler: sampler;\n @group(1) @binding(1) var yTexture: texture_2d<f32>;\n @group(1) @binding(2) var uTexture: texture_2d<f32>;\n @group(1) @binding(3) var vTexture: texture_2d<f32>;\n\n const YUV2RGB : mat4x4<f32> = mat4x4<f32>( 1.1643828125, 0, 1.59602734375, -.87078515625,\n 1.1643828125, -.39176171875, -.81296875, .52959375,\n 1.1643828125, 2.017234375, 0, -1.081390625,\n 0, 0, 0, 1);\n\n @fragment\n fn main(\n @location(0) vTexturePosition: vec2<f32>\n ) -> @location(0) vec4<f32> {\n\n var y : f32= textureSample(yTexture, mySampler, vTexturePosition).r;\n var u : f32 = textureSample(uTexture, mySampler, vTexturePosition).r;\n var v : f32 = textureSample(vTexture, mySampler, vTexturePosition).r;\n\n return vec4<f32>(y, u, v, 1.0)*YUV2RGB;\n }\n\n "}),entryPoint:"main",targets:[{format:r}]},depthStencil:{depthWriteEnabled:!0,depthCompare:"less",format:"depth24plus"}};i.createRenderPipelineAsync(s).then((t=>{e(t)})).catch((e=>{t(e)}))}))}_initMatrixGroupInfo(){const e=this.gpu.device,t=this.pipeline,i=Oa();za(i,-1,1,-1,1,.1,100);const r=Oa();Na(r);const s=Oa();!function(e,t,i,r){var s,a,n,o,l,d,h,c,u,p,f=t[0],y=t[1],m=t[2],g=r[0],A=r[1],v=r[2],b=i[0],_=i[1],w=i[2];Math.abs(f-b)<Ua&&Math.abs(y-_)<Ua&&Math.abs(m-w)<Ua?Na(e):(h=f-b,c=y-_,u=m-w,s=A*(u*=p=1/Math.hypot(h,c,u))-v*(c*=p),a=v*(h*=p)-g*u,n=g*c-A*h,(p=Math.hypot(s,a,n))?(s*=p=1/p,a*=p,n*=p):(s=0,a=0,n=0),o=c*n-u*a,l=u*s-h*n,d=h*a-c*s,(p=Math.hypot(o,l,d))?(o*=p=1/p,l*=p,d*=p):(o=0,l=0,d=0),e[0]=s,e[1]=o,e[2]=h,e[3]=0,e[4]=a,e[5]=l,e[6]=c,e[7]=0,e[8]=n,e[9]=d,e[10]=u,e[11]=0,e[12]=-(s*f+a*y+n*m),e[13]=-(o*f+l*y+d*m),e[14]=-(h*f+c*y+u*m),e[15]=1)}(s,Wa(0,0,0),Wa(0,0,-1),Wa(0,1,0));const a=e.createBuffer({size:64,usage:window.GPUBufferUsage.UNIFORM|window.GPUBufferUsage.COPY_DST});e.queue.writeBuffer(a,0,r);const n=e.createBuffer({size:64,usage:window.GPUBufferUsage.UNIFORM|window.GPUBufferUsage.COPY_DST});e.queue.writeBuffer(n,0,s);const o=e.createBuffer({size:64,usage:window.GPUBufferUsage.UNIFORM|window.GPUBufferUsage.COPY_DST});e.queue.writeBuffer(o,0,i);return{modelMatrixBuffer:a,viewMatrixBuffer:n,projectMatrixBuffer:o,group:e.createBindGroup({label:"group0",layout:t.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:a}},{binding:1,resource:{buffer:n}},{binding:2,resource:{buffer:o}}]})}}_initTextureGroupInfo(e,t){const i=this.gpu.device,r=this.pipeline,s=i.createTexture({size:[e,t],format:"r8unorm",usage:window.GPUTextureUsage.TEXTURE_BINDING|window.GPUTextureUsage.COPY_DST|window.GPUTextureUsage.RENDER_ATTACHMENT}),a=i.createTexture({size:[e/2,t/2],format:"r8unorm",usage:window.GPUTextureUsage.TEXTURE_BINDING|window.GPUTextureUsage.COPY_DST|window.GPUTextureUsage.RENDER_ATTACHMENT}),n=i.createTexture({size:[e/2,t/2],format:"r8unorm",usage:window.GPUTextureUsage.TEXTURE_BINDING|window.GPUTextureUsage.COPY_DST|window.GPUTextureUsage.RENDER_ATTACHMENT}),o=i.createSampler({magFilter:"linear",minFilter:"linear"}),l=i.createBindGroup({label:"group1",layout:r.getBindGroupLayout(1),entries:[{binding:0,resource:o},{binding:1,resource:s.createView()},{binding:2,resource:a.createView()},{binding:3,resource:n.createView()}]});return{yTexture:s,uTexture:a,vTexture:n,group:l}}_drawScene(){const e=this.gpu.device,t=this.gpu.context,i=e.createCommandEncoder(),r={colorAttachments:[{view:t.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:0},loadOp:"clear",storeOp:"store"}],depthStencilAttachment:{view:this.depthTexture.createView(),depthClearValue:1,depthLoadOp:"clear",depthStoreOp:"store"}},s=i.beginRenderPass(r);s.setPipeline(this.pipeline),s.setBindGroup(0,this.matrixGroupInfo.group),s.setBindGroup(1,this.textureGroupInfo.group),s.setVertexBuffer(0,this.buffers.positionBuffer),s.setVertexBuffer(1,this.buffers.texpositionBuffer),s.setIndexBuffer(this.buffers.indexBuffer,"uint16"),s.drawIndexed(6),s.end(),e.queue.submit([i.finish()])}renderYUV(e,t,i){if(!this.hasInited)return;let r=i.slice(0,e*t),s=i.slice(e*t,e*t*5/4),a=i.slice(e*t*5/4,e*t*3/2);const n=this.gpu.device;this.depthTexture||(this.depthTexture=this.gpu.device.createTexture({size:[e,t],format:"depth24plus",usage:window.GPUTextureUsage.RENDER_ATTACHMENT})),this.textureGroupInfo||(this.textureGroupInfo=this._initTextureGroupInfo(e,t)),n.queue.writeTexture({texture:this.textureGroupInfo.yTexture},r,{bytesPerRow:e,rowsPerImage:t},[e,t]),n.queue.writeTexture({texture:this.textureGroupInfo.uTexture},s,{bytesPerRow:e/2,rowsPerImage:t/2},[e/2,t/2]),n.queue.writeTexture({texture:this.textureGroupInfo.vTexture},a,{bytesPerRow:e/2,rowsPerImage:t/2},[e/2,t/2]),this._drawScene()}clear(){}}class $a{constructor(e){this.player=e,this.TAG_NAME="SingleWatermark",this.configList=[],this.shadowRoot=null,this.shadowRootRealDom=null,this.shadowRootInnerDom=null,this.scale=1,this.isDynamic=!1,this._initDom(),this.player.debug.log(this.TAG_NAME,"int")}destroy(){this.configList=[],this.shadowRootInnerDom=null,this.isDynamic=!1,this.scale=1,this.shadowRoot&&(this.player.$container.removeChild(this.shadowRootRealDom),this.shadowRoot=null,this.shadowRootRealDom=null),this.player.debug.log(this.TAG_NAME,"destroy")}resize(){this.player.debug.log(this.TAG_NAME,"resize()"),"default"===this.player._opt.aspectRatio||ks()?this.player.getRenderType()===K?this._resizeDomForCanvas():this.player.getRenderType()===q&&this._resizeDomForVideo():this._resizeDomRatio()}_initDom(){const e=this.player.$container;let t=null;const i=document.createElement("div");i.setAttribute("style","pointer-events: none !important;display: block !important;"),t="function"==typeof i.attachShadow?i.attachShadow({mode:"open"}):i.shadowRoot?i.shadowRoot:i;const r=document.createElement("div");r.setAttribute("style","position: absolute; top: 0; left: 0; width: 0; height: 0;display: none;"),t.appendChild(r);const s=e.children,a=Math.floor(Math.random()*(s.length-1))+1;s[a]?e.insertBefore(i,s[a]):e.appendChild(i),this.shadowRootInnerDom=r,this.shadowRootRealDom=i,this.shadowRoot=t}update(e){this._removeDom();let t=[];Array.isArray(e)?t=e:sa(e)&&t.push(e);let i=t.map((e=>qs(e)));this.configList=i,this._updateDom()}_resizeDomForVideo(){const e=this.player.width,t=this.player.height,i=this.player.getVideoInfo();if(!(i&&i.height>0&&i.width>0))return;let r=i.width,s=i.height;const a=this.player._opt;let n=t,o=e;if(a.hasControl&&!a.controlAutoHide){const e=a.playType===b?Pt:0;ks()&&this.player.fullscreen&&a.useWebFullScreen?o-=e:n-=e}const l=a.rotate;let d=(o-r)/2,h=(n-s)/2;270!==l&&90!==l||(r=i.height,s=i.width);const c=o/r,u=n/s;let p=c>u?u:c;a.isResize||c!==u&&(p=c+","+u),a.isFullResize&&(p=c>u?c:u);let f="scale("+p+")";"none"===a.mirrorRotate&&l&&(f+=" rotate("+l+"deg)"),"level"===a.mirrorRotate?f+=" rotateY(180deg)":"vertical"===a.mirrorRotate&&(f+=" rotateX(180deg)"),this.scale=-1!==(""+p).indexOf(",")?c:p,this.shadowRootInnerDom.style.transform=f,this.shadowRootInnerDom.style.left=d+"px",this.shadowRootInnerDom.style.top=h+"px",this.shadowRootInnerDom.style.width=i.width+"px",this.shadowRootInnerDom.style.height=i.height+"px",this.shadowRootInnerDom.style.display="block"}_resizeDomForCanvas(){const e=this.player.getVideoInfo();if(!(e&&e.height>0&&e.width>0))return;const t=this.player._opt;let i=this.player.width,r=this.player.height;if(t.hasControl&&!t.controlAutoHide){const e=t.playType===b?Pt:0;ks()&&this.player.fullscreen&&t.useWebFullScreen?i-=e:r-=e}let s=e.width,a=e.height;const n=t.rotate;let o=(i-s)/2,l=(r-a)/2;270!==n&&90!==n||(s=e.height,a=e.width);const d=i/s,h=r/a;let c=d>h?h:d;t.isResize||d!==h&&(c=d+","+h),t.isFullResize&&(c=d>h?d:h);let u="scale("+c+")";"none"===t.mirrorRotate&&n&&(u+=" rotate("+n+"deg)"),"level"===t.mirrorRotate?u+=" rotateY(180deg)":"vertical"===t.mirrorRotate&&(u+=" rotateX(180deg)"),this.shadowRootInnerDom.style.height=e.height+"px",this.shadowRootInnerDom.style.width=e.width+"px",this.shadowRootInnerDom.style.padding="0",this.shadowRootInnerDom.style.transform=u,this.shadowRootInnerDom.style.left=o+"px",this.shadowRootInnerDom.style.top=l+"px",this.shadowRootInnerDom.style.display="block"}_resizeDomRatio(){const e=this.player.getVideoInfo();if(!(e&&e.height>0&&e.width>0))return;const t=this.player._opt.aspectRatio.split(":").map(Number);let i=this.player.width,r=this.player.height;const s=this.player._opt;let a=0;s.hasControl&&!s.controlAutoHide&&(a=s.playType===b?Pt:0,r-=a);const n=e.width/e.height,o=t[0]/t[1];if(n>o){const t=o*e.height/e.width;this.shadowRootInnerDom.style.width=100*t+"%",this.shadowRootInnerDom.style.height=`calc(100% - ${a}px)`,this.shadowRootInnerDom.style.padding=`0 ${(i-i*t)/2}px`}else{const t=e.width/o/e.height;this.shadowRootInnerDom.style.width="100%",this.shadowRootInnerDom.style.height=`calc(${100*t}% - ${a}px)`,this.shadowRootInnerDom.style.padding=(r-r*t)/2+"px 0"}this.shadowRootInnerDom.style.display="block"}_updateDom(){this.shadowRoot&&this.configList.forEach((e=>{const t=document.createElement("div");let i=null;if(e.image&&e.image.src?(i=document.createElement("img"),i.style.height="100%",i.style.width="100%",i.style.objectFit="contain",i.src=e.image.src):e.text&&e.text.content?i=document.createTextNode(e.text.content):(e.rect&&e.rect.color&&e.rect.width||e.html||e.line&&e.line.x1&&e.line.y1&&e.line.x2&&e.line.y2||e.polygon&&e.polygon.list&&e.polygon.list.length>=3)&&(i=document.createElement("div")),i){if(t.appendChild(i),t.style.visibility="",t.style.position="absolute",t.style.display="block",t.style["-ms-user-select"]="none",t.style["-moz-user-select"]="none",t.style["-webkit-user-select"]="none",t.style["-o-user-select"]="none",t.style["user-select"]="none",t.style["-webkit-touch-callout"]="none",t.style["-webkit-tap-highlight-color"]="rgba(0,0,0,0)",t.style["-webkit-text-size-adjust"]="none",t.style["-webkit-touch-callout"]="none",t.style.opacity=e.opacity,Ns(e.left)&&(t.style.left=e.left+"px"),Ns(e.right)&&(t.style.right=e.right+"px"),Ns(e.top)&&(t.style.top=e.top+"px"),Ns(e.bottom)&&(t.style.bottom=e.bottom+"px"),e.backgroundColor&&(t.style.backgroundColor=e.backgroundColor),t.style.overflow="hidden",t.style.zIndex="9999999",e.image&&e.image.src)t.style.width=e.image.width+"px",t.style.height=e.image.height+"px";else if(e.text&&e.text.content)t.style.fontSize=e.text.fontSize+"px",t.style.color=e.text.color,e.text.width&&(t.style.width=e.text.width+"px"),e.text.height&&(t.style.height=e.text.height+"px");else if(e.rect&&e.rect.color&&e.rect.width){if(t.style.width=e.rect.width+"px",t.style.height=e.rect.height+"px",t.style.borderWidth=e.rect.lineWidth+"px",t.style.borderStyle="solid",t.style.borderColor=e.rect.color,e.rect.fill){const i=document.createElement("div");i.style.position="absolute",i.style.width="100%",i.style.height="100%",i.style.backgroundColor=e.rect.fill,e.rect.fillOpacity&&(i.style.opacity=e.rect.fillOpacity),t.appendChild(i)}}else if(e.html)t.style.width="100%",t.style.height="100%",t.innerHTML=e.html;else if(e.line&&e.line.x1&&e.line.y1&&e.line.x2&&e.line.y2)this.settingLine(t,e.line);else if(e.polygon&&e.polygon.list&&e.polygon.list.length>=3){t.style.width="100%",t.style.height="100%";let i=e.polygon.list;const r=e.polygon.color,s=e.polygon.lineWidth;if(i=i.sort(((e,t)=>(e.index||0)-(t.index||0))),e.polygon.fill){const r=document.createElement("div");r.style.position="absolute",r.style.width="100%",r.style.height="100%";const s="polygon("+i.map((e=>`${e.x}px ${e.y}px`)).join(", ")+")";r.style.clipPath=s,r.style.backgroundColor=e.polygon.fill,e.polygon.fillOpacity&&(r.style.opacity=e.polygon.fillOpacity),t.appendChild(r)}i.forEach(((e,a)=>{const n=document.createElement("div");if(a===i.length-1){const a=i[0],o={x1:e.x,y1:e.y,x2:a.x,y2:a.y,color:r,lineWidth:s};return this.settingLine(n,o),void t.appendChild(n)}const o=i[a+1],l={x1:e.x,y1:e.y,x2:o.x,y2:o.y,color:r,lineWidth:s};this.settingLine(n,l),t.appendChild(n)}))}this.isDynamic&&(this.shadowRootDynamicDom=t),this.shadowRootInnerDom.appendChild(t)}}))}settingLine(e,t){const i=t.x1,r=t.y1,s=t.x2,a=t.y2;var n=Math.sqrt((i-s)**2+(r-a)**2),o=180*Math.atan2(a-r,s-i)/Math.PI;e.style.backgroundColor=t.color,e.style.width=n+"px",e.style.height=t.lineWidth+"px",e.style.position="absolute",e.style.top=r+"px",e.style.left=i+"px",e.style.transform="rotate("+o+"deg)",e.style.transformOrigin="0 0"}remove(){this._removeDom()}_removeDom(){this.shadowRootInnerDom&&(this.shadowRootInnerDom.innerHTML="")}}class ja extends t{constructor(){super(),this.videoInfo={width:null,height:null,encType:null,encTypeCode:null},this.init=!1,this.prevAiFaceDetectTime=null,this.prevAiObjectDetectTime=null,this.prevOcclusionDetectTime=null,this.contentWatermark=null,this.aiContentWatermark=null,this.tempContentList=[],this.tempAiContentList=[],this.streamFps=0}destroy(){this.resetInit(),this.contentWatermark&&(this.contentWatermark.destroy(),this.contentWatermark=null),this.tempContentList=[],this.aiContentWatermark&&(this.aiContentWatermark.destroy(),this.aiContentWatermark=null),this.tempAiContentList=[],this.prevAiFaceDetectTime=null,this.prevAiObjectDetectTime=null,this.streamFps=0,this.off()}resetInit(){this.videoInfo={width:null,height:null,encType:null,encTypeCode:null},this.init=!1}getHasInit(){return this.init}updateVideoInfo(e){Ks(e.encTypeCode)&&(this.videoInfo.encType=mt[e.encTypeCode],this.videoInfo.encTypeCode=e.encTypeCode),Ks(e.encType)&&(this.videoInfo.encType=e.encType),Ks(e.width)&&(this.videoInfo.width=e.width),Ks(e.height)&&(this.videoInfo.height=e.height),Ks(this.videoInfo.encType)&&Ks(this.videoInfo.height)&&Ks(this.videoInfo.width)&&!this.init&&(this.player.emit(st.videoInfo,this.videoInfo),this.init=!0)}getVideoInfo(){return this.videoInfo}clearView(){this.tempContentList=[],this.tempAiContentList=[]}resize(){if(this.player.debug.log("CommonVideo","resize()"),"default"===this.player._opt.aspectRatio||ks()?this._resize():this._resizeRatio(),this.contentWatermark&&this.contentWatermark.resize(),this.aiContentWatermark&&this.aiContentWatermark.resize(),this.player.singleWatermark&&this.player.singleWatermark.resize(),this.player.ghostWatermark&&this.player.ghostWatermark.resize(),this.player.dynamicWatermark&&this.player.dynamicWatermark.resize(),this.player.zoom&&this.player.zooming){const e=this._getStyleScale();this.player.zoom.updatePrevVideoElementStyleScale(e),this.player.zoom.updateVideoElementScale()}}_resizeRatio(){this.player.debug.log("CommonVideo","_resizeRatio()");const e=this.player._opt.aspectRatio.split(":").map(Number);let t=this.player.width,i=this.player.height;const r=this.player._opt;let s=0;r.hasControl&&!r.controlAutoHide&&(s=r.playType===b?Pt:0,i-=s);const a=this.videoInfo,n=a.width/a.height,o=e[0]/e[1];if(this.getType()===K&&(this.$videoElement.style.left="0",this.$videoElement.style.top="0",this.$videoElement.style.transform="none"),this.getType()===q&&this.player._opt.videoRenderSupportScale&&(this.$videoElement.style.objectFit="fill"),n>o){const e=o*a.height/a.width;this.$videoElement.style.width=100*e+"%",this.$videoElement.style.height=`calc(100% - ${s}px)`,this.$videoElement.style.padding=`0 ${(t-t*e)/2}px`}else{const e=a.width/o/a.height;this.$videoElement.style.width="100%",this.$videoElement.style.height=`calc(${100*e}% - ${s}px)`,this.$videoElement.style.padding=(i-i*e)/2+"px 0"}}play(){}pause(){}setRate(e){}getType(){return""}getCanvasType(){return""}getCurrentTime(){return 0}getStreamFps(){return this.streamFps}isPlaying(){return!0}getPlaybackQuality(){return null}setStreamFps(e){this.player.debug.log("CommonVideo","setStreamFps",e),this.streamFps=e}addContentToCanvas(e=[]){this.tempContentList=e}addAiContentToCanvas(e=[]){this.tempAiContentList=e}doAddContentToWatermark(){if(this.tempContentList.length>0){this.contentWatermark||(this.contentWatermark=new $a(this.player),this.contentWatermark.resize());const e=[];this.tempContentList.forEach((t=>{let i={left:t.x||0,top:t.y||0};"text"===t.type?i.text={content:t.text,fontSize:t.fontSize||"14",color:t.color||"#000"}:"rect"===t.type?i.rect={width:t.width,height:t.height,color:t.color||"green",lineWidth:t.lineWidth||2,fill:t.fill||"",fillOpacity:t.fillOpacity||.2}:"polygon"===t.type?i.polygon={list:t.list,color:t.color||"green",lineWidth:t.lineWidth||2,fill:t.fill,fillOpacity:t.fillOpacity||.2}:"line"===t.type&&(i.line={color:t.color||"green",lineWidth:t.lineWidth||2,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2}),e.push(i)})),this.contentWatermark.update(e)}else this.contentWatermark&&this.contentWatermark.remove()}doAddAiContentToWatermark(){if(this.tempAiContentList.length>0){this.aiContentWatermark||(this.aiContentWatermark=new $a(this.player),this.aiContentWatermark.resize());const e=this.tempAiContentList.map((e=>{let t={left:e.x,top:e.y};return"text"===e.type?t.text={content:e.text,fontSize:e.fontSize,color:e.color}:"rect"===e.type&&(t.rect={width:e.width,height:e.height,color:e.color,lineWidth:e.lineWidth}),t}));this.aiContentWatermark.update(e)}else this.aiContentWatermark&&this.aiContentWatermark.remove()}_getStyleScale(){let e=this.$videoElement.style.transform.match(/scale\([0-9., ]*\)/g),t="";if(e&&e[0]){t=e[0].replace("scale(","").replace(")","").split(",")}return t}}var Ka="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof global&&global.global===global?global:void 0;function qa(e,t,i){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){Ja(r.response,t,i)},r.onerror=function(){console.error("could not download file")},r.send()}function Ya(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return t.status>=200&&t.status<=299}function Qa(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(i){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var Xa=Ka.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),Ja="object"!=typeof window||window!==Ka?function(){}:"download"in HTMLAnchorElement.prototype&&!Xa?function(e,t,i){var r=Ka.URL||Ka.webkitURL,s=document.createElementNS("http://www.w3.org/1999/xhtml","a");t=t||e.name||"download",s.download=t,s.rel="noopener","string"==typeof e?(s.href=e,s.origin!==location.origin?Ya(s.href)?qa(e,t,i):Qa(s,s.target="_blank"):Qa(s)):(s.href=r.createObjectURL(e),setTimeout((function(){r.revokeObjectURL(s.href)}),4e4),setTimeout((function(){Qa(s)}),0))}:"msSaveOrOpenBlob"in navigator?function(e,t,i){if(t=t||e.name||"download","string"==typeof e)if(Ya(e))qa(e,t,i);else{var r=document.createElement("a");r.href=e,r.target="_blank",setTimeout((function(){Qa(r)}))}else navigator.msSaveOrOpenBlob(function(e,t){return void 0===t?t={autoBom:!1}:"object"!=typeof t&&(console.warn("Deprecated: Expected third argument to be a object"),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob([String.fromCharCode(65279),e],{type:e.type}):e}(e,i),t)}:function(e,t,i,r){if((r=r||open("","_blank"))&&(r.document.title=r.document.body.innerText="downloading..."),"string"==typeof e)return qa(e,t,i);var s="application/octet-stream"===e.type,a=/constructor/i.test(Ka.HTMLElement)||Ka.safari,n=/CriOS\/[\d]+/.test(navigator.userAgent);if((n||s&&a||Xa)&&"undefined"!=typeof FileReader){var o=new FileReader;o.onloadend=function(){var e=o.result;e=n?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),r?r.location.href=e:location=e,r=null},o.readAsDataURL(e)}else{var l=Ka.URL||Ka.webkitURL,d=l.createObjectURL(e);r?r.location=d:location.href=d,r=null,setTimeout((function(){l.revokeObjectURL(d)}),4e4)}};class Za{constructor(e,t){this.canvas=e,this.gl=t;const i=t.createShader(t.VERTEX_SHADER);if(t.shaderSource(i,"\n attribute vec2 xy;\n varying highp vec2 uv;\n void main(void) {\n gl_Position = vec4(xy, 0.0, 1.0);\n // Map vertex coordinates (-1 to +1) to UV coordinates (0 to 1).\n // UV coordinates are Y-flipped relative to vertex coordinates.\n uv = vec2((1.0 + xy.x) / 2.0, (1.0 - xy.y) / 2.0);\n }\n "),t.compileShader(i),!t.getShaderParameter(i,t.COMPILE_STATUS))throw t.getShaderInfoLog(i);const r=t.createShader(t.FRAGMENT_SHADER);if(t.shaderSource(r,"\n varying highp vec2 uv;\n uniform sampler2D texture;\n void main(void) {\n gl_FragColor = texture2D(texture, uv);\n }\n "),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw t.getShaderInfoLog(r);const s=t.createProgram();if(t.attachShader(s,i),t.attachShader(s,r),t.linkProgram(s),!t.getProgramParameter(s,t.LINK_STATUS))throw t.getProgramInfoLog(s);t.useProgram(s);const a=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,a),t.bufferData(t.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),t.STATIC_DRAW);const n=t.getAttribLocation(s,"xy");t.vertexAttribPointer(n,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(n);const o=t.createTexture();t.bindTexture(t.TEXTURE_2D,o),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),this.program=s,this.buffer=a,this.vertexShader=i,this.fragmentShader=r,this.texture=o}destroy(){this.gl.deleteProgram(this.program),this.gl.deleteBuffer(this.buffer),this.gl.deleteTexture(this.texture),this.gl.deleteShader(this.vertexShader),this.gl.deleteShader(this.fragmentShader),this.program=null,this.buffer=null,this.vertexShader=null,this.fragmentShader=null,this.texture=null}render(e){this.canvas.width=e.displayWidth,this.canvas.height=e.displayHeight;const t=this.gl;t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),t.viewport(0,0,t.drawingBufferWidth,t.drawingBufferHeight),t.clearColor(1,0,0,1),t.clear(t.COLOR_BUFFER_BIT),t.drawArrays(t.TRIANGLE_FAN,0,4)}}class en extends ja{constructor(e){super(),this.player=e;const t=document.createElement("canvas");t.style.position="absolute",t.style.top=0,t.style.left=0,this.$videoElement=t,e.$container.appendChild(this.$videoElement),this.context2D=null,this.contextGl=null,this.webglRender=null,this.webglRectRender=null,this.webGPURender=null,this.isWebglContextLost=!1,this.isWcsWebgl2=!1,this.bitmaprenderer=null,this.renderType=null,this.controlHeight=0,this.proxyDestroyList=[],this._initCanvasRender()}destroy(){super.destroy(),this.proxyDestroyList.length>0&&(this.proxyDestroyList.forEach((e=>{e&&e()})),this.proxyDestroyList=[]),this.contextGl&&(this.contextGl=null),this.context2D&&(this.context2D=null),this.webglRender&&(this.webglRender.destroy(),this.webglRender=null),this.webglRectRender&&(this.webglRectRender.destroy(),this.webglRectRender=null),this.webGPURender&&(this.webGPURender.destroy(),this.webGPURender=null),this.bitmaprenderer&&(this.bitmaprenderer=null),this.renderType=null,this.isWebglContextLost=!1,this.videoInfo={width:"",height:"",encType:""},this.player.$container.removeChild(this.$videoElement),this.init=!1,this.off()}_initContext2D(e={}){this.context2D=this.$videoElement.getContext("2d",e)}_initContextGl(){this.player.events,this.contextGl=ms(this.$videoElement),this.contextGl?(this._bindContextGlEvents(),this.webglRender=new Va(this.contextGl,this.player._opt.openWebglAlignment)):this.player.debug.error("CommonCanvasLoader","_initContextGl() createContextGL error")}_initContextGl2(){if(this.contextGl=gs(this.$videoElement),this.contextGl){this._bindContextGlEvents(2);try{this.webglRender=new Za(this.$videoElement,this.contextGl)}catch(e){this.player.debug.error("CommonCanvasLoader",`create webgl2Render error is ${e} and next use context2d.draw render`),this.contextGl=null,this.webglRender=null,this._initContext2D()}}else this.player.debug.error("CommonCanvasLoader","_initContextGl2() createContextGL2 error")}_bindContextGlEvents(e=1){const{proxy:t}=this.player.events,i=t(this.$videoElement,"webglcontextlost",(t=>{t.preventDefault(),this.player.debug.error("canvasVideo","webglcontextlost error",t),this.isWebglContextLost=!0,this.webglRender&&(this.player.debug.log("CommonCanvasLoader","webglcontextlost error and destroy webglRender"),this.webglRender.destroy(),this.webglRender=null),this.webglRectRender&&(this.player.debug.log("CommonCanvasLoader","webglcontextlost error and destroy webglRectRender"),this.webglRectRender.destroy(),this.webglRectRender=null),this.contextGl=null,setTimeout((()=>{if(this.player.debug.log("CommonCanvasLoader",`createContextGL() version ${e}`),1===e?this.contextGl=ms(this.$videoElement):2===e&&(this.contextGl=gs(this.$videoElement)),this.player.debug.log("CommonCanvasLoader","createContextGL success"),this.contextGl&&this.contextGl.getContextAttributes){const t=this.contextGl.getContextAttributes();t&&t.stencil?(1===e?this.webglRender=new Va(this.contextGl,this.player._opt.openWebglAlignment):2===e&&(this.webglRender=new Za(this.$videoElement,this.contextGl)),this.isWebglContextLost=!1,this.player.debug.log("CommonCanvasLoader","webglcontextlost error reset and getContextAttributes().stencil is true")):(this.player.debug.error("CommonCanvasLoader","webglcontextlost error, getContextAttributes().stencil is false"),this.player.emitError(lt.webglContextLostError))}else this.player.debug.error("CommonCanvasLoader","webglcontextlost error, getContextAttributes().stencil is false"),this.player.emitError(lt.webglContextLostError)}),500)})),r=t(this.$videoElement,"webglcontextrestored",(e=>{e.preventDefault(),this.player.debug.log("CommonCanvasLoader","webglcontextrestored ",e)}));this.proxyDestroyList.push(i,r)}_initContextGPU(){var t;(t=this.$videoElement,new Promise(((e,i)=>{navigator.gpu?navigator.gpu.requestAdapter().then((r=>{r?r.requestDevice().then((s=>{if(s){const a=t.getContext("webgpu");if(a){const t=navigator.gpu.getPreferredCanvasFormat();a.configure({device:s,format:t,alphaMode:"opaque"}),e({adapter:r,device:s,context:a,format:t})}else i('WebGPU "context" create fail')}else i('WebGPU "device" request fail')})).catch((e=>{i('WebGPU "adapter.requestDevice()" fail')})):i('WebGPU "adapter" request fail is empty')})).catch((e=>{i('WebGPU "navigator.gpu.requestAdapter()" fail')})):i("WebGPU not support!!")}))).then((t=>{t?(this.webGPURender=new Ha(t),this.player.debug.log("CommonCanvasLoader","webGPURender init success")):(this.player.debug.warn("CommonCanvasLoader",`createWebGPUContext error is ${e} and next use webgl render`),this.renderType=Ot,this._initContextGl())})).catch((e=>{this.player.debug.warn("CommonCanvasLoader",`createWebGPUContext error is ${e} and next use webgl render`),this.renderType=Ot,this._initContextGl()}))}initCanvasViewSize(){this.$videoElement.width=this.videoInfo.width,this.$videoElement.height=this.videoInfo.height,this.resize()}screenshot(e,t,i,r){e=e||vs(),r=r||pt.download;let s=.92;!_i[t]&&pt[t]&&(r=t,t="png",i=void 0),"string"==typeof i&&(r=i,i=void 0),void 0!==i&&(s=Number(i));const a=_i[t]||_i.png,n=this.$videoElement.toDataURL(a,s);if(r===pt.base64)return n;{const t=As(n);if(r===pt.blob)return t;if(r===pt.download){const i=a.split("/")[1];Ja(t,e+"."+i)}}}screenshotWatermark(e){return new Promise(((t,i)=>{aa(e)&&(e={filename:e}),(e=e||{}).width=this.videoInfo.width,e.height=this.videoInfo.height,e.filename=e.filename||vs(),e.format=e.format?_i[e.format]:_i.png,e.quality=Number(e.quality)||.92,e.type=e.type||pt.download;const r=this.$videoElement.toDataURL(e.format,e.quality);Qs(r,e).then((i=>{if(e.type===pt.base64)t(r);else{const r=As(i);if(e.type===pt.blob)t(r);else if(e.type===pt.download){t();const i=e.format.split("/")[1];Ja(r,e.filename+"."+i)}}})).catch((e=>{i(e)}))}))}render(){}clearView(){super.clearView()}play(){}pause(){}_resize(){this.player.debug.log("canvasVideo","_resize()");const e=this.player._opt;let t=this.player.width,i=this.player.height;if(e.hasControl&&!e.controlAutoHide){const r=this.controlHeight;ks()&&this.player.fullscreen&&e.useWebFullScreen?t-=r:i-=r}let r=this.$videoElement.width,s=this.$videoElement.height;const a=e.rotate;let n=(t-r)/2,o=(i-s)/2;270!==a&&90!==a||(r=this.$videoElement.height,s=this.$videoElement.width);const l=t/r,d=i/s;let h=l>d?d:l;ka(e.isResize)&&l!==d&&(h=l+","+d),e.isFullResize&&(h=l>d?l:d);let c="scale("+h+")";"none"===e.mirrorRotate&&a&&(c+=" rotate("+a+"deg)"),"level"===e.mirrorRotate?c+=" rotateY(180deg)":"vertical"===e.mirrorRotate&&(c+=" rotateX(180deg)"),this.$videoElement.style.height=this.videoInfo.height+"px",this.$videoElement.style.width=this.videoInfo.width+"px",this.$videoElement.style.padding="0",this.$videoElement.style.transform=c,this.$videoElement.style.left=n+"px",this.$videoElement.style.top=o+"px"}initFps(){}setStreamFps(e){}getStreamFps(){return 25}getType(){return K}getCanvasType(){let e=this.renderType===Gt?Gt:Ot;return this.isWcsWebgl2&&(e=Nt),e}}class tn extends en{constructor(e){super(e),this.yuvList=[],this.controlHeight=0,this.tempTextCanvas=null,this.tempTextCanvasCtx=null,this.player.debug.log("CanvasVideo","init")}destroy(){super.destroy(),this.yuvList=[],this.tempTextCanvas&&(this.tempTextCanvasCtx.clearRect(0,0,this.tempTextCanvas.width,this.tempTextCanvas.height),this.tempTextCanvas.width=0,this.tempTextCanvas.height=0,this.tempTextCanvas=null),this.player.debug.log("CanvasVideoLoader","destroy")}_initCanvasRender(){this.player._opt.useWCS&&!this._supportOffscreen()?(this.renderType=Ft,La()&&this.player._opt.wcsUseWebgl2Render?(this._initContextGl2(),this.webglRender&&(this.isWcsWebgl2=!0)):this._initContext2D()):this.player._opt.useMSE&&this.player._opt.mseUseCanvasRender?(this.renderType=Wt,this._initContext2D()):this.player.isOldHls()&&this.player._opt.useCanvasRender?(this.renderType=Vt,this._initContext2D()):this.player.isWebrtcH264()&&this.player._opt.webrtcUseCanvasRender?(this.renderType=Ht,this._initContext2D()):this._supportOffscreen()?(this.renderType=zt,this._bindOffscreen()):this.player._opt.useWebGPU?(this.renderType=Gt,this._initContextGPU()):(this.renderType=Ot,this._initContextGl())}_supportOffscreen(){return"function"==typeof this.$videoElement.transferControlToOffscreen&&this.player._opt.useOffscreen}_bindOffscreen(){this.bitmaprenderer=this.$videoElement.getContext("bitmaprenderer")}render(e){this.yuvList.push(e),this.startRender()}startRender(){for(;!(this.yuvList.length<=0);){const e=this.yuvList.shift();this.doRender(e)}}doRender(e){if(this.renderType!==Wt){const t={ts:e.ts||0,fps:!0};this.player.updateStats(t)}switch(this.renderType){case zt:this.bitmaprenderer.transferFromImageBitmap(e.buffer);break;case Ot:case Gt:if(this.isWebglContextLost)return void this.player.debug.warn("CanvasVideoLoader","doRender() and webgl context is lost");let t=e.output;if(this.player.faceDetectActive&&this.player.ai&&this.player.ai.faceDetector){null===this.prevAiFaceDetectTime&&(this.prevAiFaceDetectTime=vs());const i=vs();i-this.prevAiFaceDetectTime>=this.player._opt.aiFaceDetectInterval&&(t=this.player.ai.faceDetector.detect({width:this.$videoElement.width,height:this.$videoElement.height,data:e.output,ts:e.ts||0}),this.prevAiFaceDetectTime=i)}if(this.player.objectDetectActive&&this.player.ai&&this.player.ai.objectDetector){null===this.prevAiObjectDetectTime&&(this.prevAiObjectDetectTime=vs());const i=vs();i-this.prevAiObjectDetectTime>=this.player._opt.aiObjectDetectInterval&&(t=this.player.ai.objectDetector.detect({width:this.$videoElement.width,height:this.$videoElement.height,data:e.output,ts:e.ts||0}),this.prevAiObjectDetectTime=i)}if(this.player.occlusionDetectActive&&this.player.ai&&this.player.ai.occlusionDetector){null===this.prevAiOcclusionDetectTime&&(this.prevAiOcclusionDetectTime=vs());const t=vs();if(t-this.prevAiOcclusionDetectTime>=this.player._opt.aiOcclusionDetectInterval){const i=this.player.ai.occlusionDetector.check({width:this.$videoElement.width,height:this.$videoElement.height,data:e.output});this.prevAiOcclusionDetectTime=t,i&&this.player.emit(st.aiOcclusionDetectResult,{ts:e.ts||0})}}if(this.player.imageDetectActive&&this.player.ai&&this.player.ai.imageDetector){const t=this.player.ai.imageDetector.check({width:this.$videoElement.width,height:this.$videoElement.height,data:e.output});if(t&&t.data&&(this.player.emit(st.aiOcclusionDetectResult,{type:t.type,ts:e.ts||0}),this.player._opt.aiImageDetectDrop))return void this.player.debug.log("CanvasVideoLoader",`doRender() and ai image detect result type is ${t.type} and drop`)}if(this.renderType===Gt)try{if(!this.webGPURender)return void this.player.debug.warn("CanvasVideoLoader","doRender webgpu render is not init");this.webGPURender.renderYUV(this.$videoElement.width,this.$videoElement.height,t)}catch(e){this.player.debug.error("CanvasVideoLoader",`doRender webgpu render and error: ${e.toString()}`)}else if(this.renderType===Ot)try{this.webglRender.renderYUV(this.$videoElement.width,this.$videoElement.height,t)}catch(e){this.player.debug.error("CanvasVideoLoader",`doRender webgl render context is lost ${this.contextGl&&this.contextGl.isContextLost()} and error: ${e.toString()}`)}break;case Ft:if(this.webglRender)this.webglRender.render(e.videoFrame),ya(e.videoFrame);else if(this.context2D)if(ha(e.videoFrame.createImageBitmap))try{e.videoFrame.createImageBitmap().then((t=>{this.context2D.drawImage(t,0,0,this.$videoElement.width,this.$videoElement.height),ya(e.videoFrame)}))}catch(e){}else this.context2D.drawImage(e.videoFrame,0,0,this.$videoElement.width,this.$videoElement.height),ya(e.videoFrame);else this.player.debug.warn("CanvasVideoLoader","doRender() and webcodecs context is lost");break;case Wt:case Vt:case Ht:this.context2D.drawImage(e.$video,0,0,this.$videoElement.width,this.$videoElement.height)}let t=e.ts||0;this.renderType===Wt&&(t=parseInt(1e3*e.$video.currentTime,10)+(this.player.mseDecoder.firstRenderTime||0)),this.player.updateCurrentPts(t),this.doAddContentToWatermark(),this.doAddAiContentToWatermark()}clearView(){switch(super.clearView(),this.renderType){case zt:(function(e,t){const i=document.createElement("canvas");i.width=e,i.height=t;const r=window.createImageBitmap(i,0,0,e,t);return i.width=0,i.height=0,r})(this.$videoElement.width,this.$videoElement.height).then((e=>{this.bitmaprenderer.transferFromImageBitmap(e)}));break;case Ot:this.contextGl.clear(this.contextGl.COLOR_BUFFER_BIT);break;case Gt:this.webGPURender.clear();break;case Ft:this.contextGl?this.contextGl.clear(this.contextGl.COLOR_BUFFER_BIT):this.context2D&&this.context2D.clearRect(0,0,this.$videoElement.width,this.$videoElement.height);break;case Wt:case Vt:case Ht:this.context2D.clearRect(0,0,this.$videoElement.width,this.$videoElement.height)}}_initTempTextCanvas(){this.tempTextCanvas=document.createElement("canvas"),this.tempTextCanvasCtx=this.tempTextCanvas.getContext("2d"),this.tempTextCanvas.width=600,this.tempTextCanvas.height=20}doAddContentToCanvas(){this.tempContentList.length>0&&this.context2D&&function({ctx:e,list:t}){e.save(),(t||[]).forEach((t=>{"text"===t.type?(e.font=`${t.fontSize||12}px Arial`,e.fillStyle=t.color||"green",e.fillText(t.text,t.x,t.y)):"rect"===t.type&&(e.strokeStyle=t.color||"green",e.lineWidth=t.lineWidth||2,e.strokeRect(t.x,t.y,t.width,t.height))})),e.restore()}({ctx:this.context2D,list:this.tempContentList})}doAddContentToWebGlCanvas(){this.tempContentList.length>0&&this.contextGl&&this.webglRectRender&&this.tempContentList.forEach((e=>{const t=e.x,i=e.y;if("rect"===e.type){const s=e.width,a=e.height,n=(r=e.color||"#008000",[parseInt(r.substring(1,3),16)/255,parseInt(r.substring(3,5),16)/255,parseInt(r.substring(5,7),16)/255,1]),o=e.lineWidth||4;if(!s||!a)return;this.webglRectRender.drawBox({x:t,y:i,width:s,height:a,lineColor:n,lineWidth:o,canvasWidth:this.$videoElement.width,canvasHeight:this.$videoElement.height})}else if("text"===e.type){const r=e.text||"";if(!r)return;const s=e.fontSize||20,a=e.color||"#008000";this.tempTextCanvas||this._initTempTextCanvas(),this.tempTextCanvasCtx.clearRect(0,0,this.tempTextCanvas.width,this.tempTextCanvas.height),this.tempTextCanvasCtx.font=`${s}px Arial`,this.tempTextCanvasCtx.fillStyle=a,this.tempTextCanvasCtx.textBaseline="top",this.tempTextCanvasCtx.fillText(r,0,0),this.webglRender.drawDom(this.$videoElement.width,this.$videoElement.height,t,i,this.tempTextCanvas)}var r}))}}class rn extends ja{constructor(e){super(),this.player=e,this.TAG_NAME="Video";const t=document.createElement("video"),i=document.createElement("canvas");t.muted=!0,t.style.position="absolute",t.style.top=0,t.style.left=0,this._delayPlay=!1,e.$container.appendChild(t),this.$videoElement=t,this.$canvasElement=i,this.canvasContext=i.getContext("2d"),this.mediaStream=null,this.vwriter=null,e.canVideoTrackWritter()&&Ws()&&Vs()&&(this.trackGenerator=new MediaStreamTrackGenerator({kind:"video"}),this.mediaStream=new MediaStream([this.trackGenerator]),t.srcObject=this.mediaStream,this.vwriter=this.trackGenerator.writable.getWriter()),this.fixChromeVideoFlashBug(),this.fixMobileAutoFullscreen(),this.resize(),this.eventListenList=[],this.isRenderRetryPlaying=!1,this.isRenderRetryPlayingTimes=0,this.isRetryPlaying=!1,this.isRetryPlayingTimes=0,this.checkVideoCanplayTimeout=null;const r=Pa();this.supportVideoFrameCallbackHandle=null;const{proxy:s}=this.player.events,a=s(this.$videoElement,"canplay",(()=>{this.player.debug.log("Video","canplay"),this.player.isDestroyedOrClosed()||this._delayPlay&&(this.clearCheckVideoCanplayTimeout(),this._play(),Pa()?this.supportVideoFrameCallbackHandle||(this.supportVideoFrameCallbackHandle=this.$videoElement.requestVideoFrameCallback(this.videoFrameCallback.bind(this))):this.player.debug.warn("Video","not support requestVideoFrameCallback and use timeupdate event to update stats"))})),n=s(this.$videoElement,"waiting",(()=>{this.player.debug.log("Video","waiting")})),o=s(this.$videoElement,"loadedmetadata",(()=>{this.player.debug.log("Video","loadedmetadata")})),l=s(this.$videoElement,"timeupdate",(t=>{if(!this.player.isDestroyedOrClosed()){if(ka(r)){const t=parseInt(1e3*this.getCurrentTime(),10);(e.isWebrtcH264()||this.player.isOldHls()||this.player.isAliyunRtc())&&(this.player.emit(st.timeUpdate,t),e.handleRender(),e.updateStats({fps:!0,ts:t,dts:t}))}this.player.isMseDecoderUseWorker()&&(this.player.decoderWorker.updateVideoTimestamp(this.getCurrentTime()),this._handleUpdatePlaybackRate())}})),d=s(this.$videoElement,"error",(()=>{this.player.debug.error("Video","Error Code "+this.$videoElement.error.code+" "+Ir[this.$videoElement.error.code]+"; Details: "+this.$videoElement.error.message),this.player.isUseMSE()&&4===this.$videoElement.error.code&&-1!==this.$videoElement.error.message.indexOf(Pr)&&(this.player.isMSEVideoDecoderInitializationFailedNotSupportHevc=!0),this.player.isHlsCanVideoPlay()}));if(this.eventListenList.push(a,n,l,d,o),this.player.isMseDecoderUseWorker()){const e=s(this.$videoElement,ki,(()=>{this.player.debug.log(this.TAG_NAME,"video playback Rate change",this.$videoElement&&this.$videoElement.playbackRate),this.$videoElement&&this.$videoElement.paused&&(this.player.debug.log(this.TAG_NAME,"video is paused and next try to replay"),this.$videoElement.play())}));this.eventListenList.push(e)}this.player.debug.log("Video","init")}destroy(){if(super.destroy(),this.clearCheckVideoCanplayTimeout(),this._cancelVideoFrameCallback(),this.eventListenList&&(this.eventListenList.forEach((e=>{e()})),this.eventListenList=[]),this.isRenderRetryPlaying=!1,this.isRenderRetryPlayingTimes=0,this.isRetryPlaying=!1,this.isRetryPlayingTimes=0,this.player._opt.videoRenderSupportScale&&this._isNeedAddBackDropFilter()){const e=this.player.$container;e.style.backdropFilter="none",e.style.transform="none"}if(this.$canvasElement.height=0,this.$canvasElement.width=0,this.$canvasElement=null,this.canvasContext=null,this.$videoElement){this.$videoElement.pause(),this.$videoElement.currentTime=0,this.$videoElement.srcObject&&(this.$videoElement.srcObject=null,this.$videoElement.removeAttribute("srcObject")),this.$videoElement.src&&(this.$videoElement.src="",this.$videoElement.removeAttribute("src"));try{this.$videoElement.load()}catch(e){}this.player.$container.removeChild(this.$videoElement),this.$videoElement=null}this.trackGenerator&&(this.trackGenerator.stop(),this.trackGenerator=null),this.vwriter&&(this.vwriter.close(),this.vwriter=null),this._delayPlay=!1,this.mediaStream&&(this.mediaStream.getTracks().forEach((e=>e.stop())),this.mediaStream=null),this.off(),this.player.debug.log("Video","destroy")}videoFrameCallback(e,t={}){if(this.player.isDestroyedOrClosed())return void this.player.debug.log("Video","videoFrameCallback() and isDestroyedOrClosed and return");this.player.handleRender();const i=parseInt(1e3*Math.max(t.mediaTime,this.getCurrentTime()),10)||0;if(this.player.isUseHls265UseMse())this.player.updateStats({fps:!0,ts:i});else if(this.player.isMseDecoderUseWorker()){this.player._times.videoStart||(this.player._times.videoStart=vs(),this.player.handlePlayToRenderTimes());const e=i+(this.player._mseWorkerData.firstRenderTime||0);if(this.player.updateStats({fps:!0,dfps:!0,ts:e,mseTs:i}),this.player.emit(st.timeUpdate,e),ka(this.getHasInit())&&t.width&&t.height){const e={width:t.width,height:t.height};this.updateVideoInfo(e),this.initCanvasViewSize()}}if(this.player.isWebrtcH264()||this.player.isOldHls()||this.player.isAliyunRtc()){if(this.player.emit(st.timeUpdate,i),ka(this.getHasInit())&&t.width&&t.height){const e={width:t.width,height:t.height};this.videoInfo.encTypeCode||this.player.isOldHls()||(e.encTypeCode=gt),this.updateVideoInfo(e)}this.player.updateStats({fps:!0,ts:i,dts:i}),this.player.updateCurrentPts(i),this.doAddContentToWatermark()}else if(Ta(this.player._opt.useMSE)&&ka(this.player._opt.mseUseCanvasRender)){if(this.player.mseDecoder){let e=parseInt(1e3*Math.max(t.mediaTime,this.getCurrentTime()),10)+(this.player.mseDecoder.firstRenderTime||0);this.player.updateCurrentPts(e)}else if(this.player._opt.mseDecoderUseWorker){let e=parseInt(1e3*Math.max(t.mediaTime,this.getCurrentTime()),10)+(this.player._mseWorkerData.firstRenderTime||0);this.player.updateCurrentPts(e)}this.doAddContentToWatermark()}this.supportVideoFrameCallbackHandle=this.$videoElement.requestVideoFrameCallback(this.videoFrameCallback.bind(this))}fixChromeVideoFlashBug(){if(this.player._opt.videoRenderSupportScale&&this._isNeedAddBackDropFilter()){const e=this.player.$container;e.style.backdropFilter="blur(0px)",e.style.transform="translateZ(0)"}}fixMobileAutoFullscreen(){const e=Ls(),t=Ds();(e||t)&&(this.player.debug.log("Video",`fixMobileAutoFullscreen and isIOS ${e} and isAndroid ${t}`),this.$videoElement.setAttribute("webkit-playsinline","true"),this.$videoElement.setAttribute("playsinline","true"),this.$videoElement.setAttribute("x5-video-player-type","h5-page"))}_isNeedAddBackDropFilter(){const e=xs().type.toLowerCase();return"chrome"===e||"edge"===e}isPaused(){let e=!0;return this.$videoElement&&(e=this.$videoElement.paused),e}isPause(){return this.isPaused()}_getVideoReadyState(){let e=0;return this.$videoElement&&(e=this.$videoElement.readyState),e}_getVideoCurrentTime(){let e=0;return this.$videoElement&&(e=this.$videoElement.currentTime),e}play(){if(this.$videoElement){const e=this._getVideoReadyState();if(this.player.debug.log("Video",`play and readyState: ${e}`),0===e)return this.player.debug.log("Video","readyState is 0 and set _delayPlay to true and listen canplay event to play"),this._delayPlay=!0,void(null===this.checkVideoCanplayTimeout&&(this.checkVideoCanplayTimeout=setTimeout((()=>{if(this.clearCheckVideoCanplayTimeout(),!this.player.isDestroyedOrClosed()&&ka(this.isPlaying())){const e=this._getBufferStore();this.player.debug.warn("Video",`checkVideoCanplayTimeout and video is not playing and buffer store is ${e} and retry play`),this.$videoElement.currentTime=e,this._replay()}}),1e3)));this._play()}}_play(){this.$videoElement&&this.$videoElement.play().then((()=>{this._delayPlay=!1,this.player.debug.log("Video","_play success"),this.isPlaying()?(this.player.emit(st.removeLoadingBgImage),this.isRetryPlayingTimes=0,this.isRetryPlaying=!1):setTimeout((()=>{this._replay()}),100)})).catch((e=>{this.player.isDestroyedOrClosed()?this.player.debug.log("Video","_play error and player is isDestroyedOrClosed and return"):(this.player.debug.error("Video","_play error",e),this.isRetryPlaying=!1,setTimeout((()=>{this._replay()}),100))}))}_replay(){if(!this.isPlaying()&&ka(this.player.isDestroyedOrClosed())&&ka(this.isRetryPlaying)){if(this.isRetryPlaying=!0,this.isRetryPlayingTimes>=3)return void(this.player.isWebrtcH264()?(this.player.debug.error("Video",`_replay(webrtc H264) then but not playing and retry play times is ${this.isRetryPlayingTimes} and emit error`),this.player.emitError(lt.videoElementPlayingFailedForWebrtc)):(this.player.debug.error("Video",`_replay then but not playing and retry play times is ${this.isRetryPlayingTimes} and emit error to use canvas render`),this.player.emitError(lt.videoElementPlayingFailed)));this.player.debug.warn("Video",`_play then but not playing and retry play and isRetryPlayingTimes is ${this.isRetryPlayingTimes}`),this._play(),this.isRetryPlayingTimes++}else this.player.debug.log("Video",`_replay() and isPlaying is ${this.isPlaying()} and isRetryPlaying is ${this.isRetryPlaying} and isDestroyedOrClosed is ${this.player.isDestroyedOrClosed()} and return;`)}pause(e){this.player.debug.log(this.TAG_NAME,"pause and isNow is "+e),this.isPlaying()&&(e?(this.$videoElement&&this.$videoElement.pause(),this._cancelVideoFrameCallback()):setTimeout((()=>{this.$videoElement&&this.$videoElement.pause(),this._cancelVideoFrameCallback()}),100))}clearView(){super.clearView(),this.$videoElement&&(this.$videoElement.pause(),this.$videoElement.currentTime=0,this.$videoElement.src&&(this.$videoElement.src="",this.$videoElement.removeAttribute("src")),this.$videoElement.srcObject&&(this.$videoElement.srcObject=null,this.$videoElement.removeAttribute("srcObject")))}screenshot(e,t,i,r){if(!this._canScreenshot())return this.player.debug.warn("Video","screenshot failed, video is not ready"),null;e=e||vs(),r=r||pt.download;let s=.92;!_i[t]&&pt[t]&&(r=t,t="png",i=void 0),"string"==typeof i&&(r=i,i=void 0),void 0!==i&&(s=Number(i));const a=this.$videoElement;let n=this.$canvasElement;n.width=a.videoWidth,n.height=a.videoHeight,this.canvasContext.drawImage(a,0,0,n.width,n.height);const o=_i[t]||_i.png,l=n.toDataURL(o,s);if(this.canvasContext.clearRect(0,0,n.width,n.height),n.width=0,n.height=0,r===pt.base64)return l;{const t=As(l);if(r===pt.blob)return t;if(r===pt.download){const i=o.split("/")[1];Ja(t,e+"."+i)}}}screenshotWatermark(e){return new Promise(((t,i)=>{if(aa(e)&&(e={filename:e}),!this._canScreenshot())return this.player.debug.warn("Video","screenshot failed, video is not ready"),i("screenshot failed, video is not ready");const r=this.$videoElement;(e=e||{}).width=r.videoWidth,e.height=r.videoHeight,e.filename=e.filename||vs(),e.format=e.format?_i[e.format]:_i.png,e.quality=Number(e.quality)||.92,e.type=e.type||pt.download;let s=this.$canvasElement;s.width=r.videoWidth,s.height=r.videoHeight,this.canvasContext.drawImage(r,0,0,s.width,s.height);const a=s.toDataURL(e.format,e.quality);this.canvasContext.clearRect(0,0,s.width,s.height),s.width=0,s.height=0,Qs(a,e).then((i=>{if(e.type===pt.base64)t(a);else{const r=As(i);if(e.type===pt.blob)t(r);else if(e.type===pt.download){t();const i=e.format.split("/")[1];Ja(r,e.filename+"."+i)}}})).catch((e=>{i(e)}))}))}initCanvasViewSize(){this.resize()}clear(){const e=this.$videoElement,t=e.buffered,i=t.length?t.end(t.length-1):0;e.currentTime=i}render(e){if(this.vwriter){if(this.$videoElement.srcObject||(this.$videoElement.srcObject=this.mediaStream),this.isPaused()){const e=this._getVideoReadyState();if(this.player.debug.warn("Video","render() error, video is paused and readyState is "+e),4===e&&ka(this.isRenderRetryPlaying)){if(this.isRenderRetryPlaying=!0,this.isRenderRetryPlayingTimes>3)return this.player.debug.error("Video","render() error, video is paused and readyState is "+e+", retry times is "+this.isRenderRetryPlayingTimes+", emit error and use canvas render"),void this.player.emitError(lt.videoElementPlayingFailed);this.$videoElement.play().then((()=>{this.isRenderRetryPlayingTimes=0,this.isRenderRetryPlaying=!1,this.player.debug.log("Video","render() video is paused and replay success")})).catch((e=>{this.isRenderRetryPlaying=!1,this.isRenderRetryPlayingTimes++,this.player.debug.warn("Video","render() error, video is paused and replay error ",e)}))}}if(this.player.updateStats({fps:!0,ts:e.ts||0}),e.videoFrame)this.vwriter.write(e.videoFrame),ya(e.videoFrame);else if(e.output){let r=e.output;if(this.player.faceDetectActive&&this.player.ai&&this.player.ai.faceDetector){null===this.prevAiFaceDetectTime&&(this.prevAiFaceDetectTime=vs());const t=vs();t-this.prevAiFaceDetectTime>this.player._opt.aiFaceDetectInterval&&(r=this.player.ai.faceDetector.detect({width:this.videoInfo.width,height:this.videoInfo.height,data:e.output,ts:e.ts||0}),this.prevAiFaceDetectTime=t)}if(this.player.objectDetectActive&&this.player.ai&&this.player.ai.objectDetector){null===this.prevAiObjectDetectTime&&(this.prevAiObjectDetectTime=vs());const t=vs();t-this.prevAiObjectDetectTime>this.player._opt.aiObjectDetectInterval&&(r=this.player.ai.objectDetector.detect({width:this.videoInfo.width,height:this.videoInfo.height,data:e.output,ts:e.ts||0}),this.prevAiObjectDetectTime=t)}if(this.player.occlusionDetectActive&&this.player.ai&&this.player.ai.occlusionDetector){null===this.prevAiOcclusionDetectTime&&(this.prevAiOcclusionDetectTime=vs());const t=vs();if(t-this.prevAiOcclusionDetectTime>=this.player._opt.aiOcclusionDetectInterval){const i=this.player.ai.occlusionDetector.check({width:this.videoInfo.width,height:this.videoInfo.height,data:e.output,ts:e.ts||0});this.prevAiOcclusionDetectTime=t,i&&(this.player.debug.log("Video","render() and ai occlusion detect result is true"),this.player.emit(st.aiOcclusionDetectResult,{ts:e.ts||0}))}}if(this.player.imageDetectActive&&this.player.ai&&this.player.ai.imageDetector){const t=this.player.ai.imageDetector.check({width:this.videoInfo.width,height:this.videoInfo.height,data:e.output,ts:e.ts||0});if(t&&t.data&&(this.player.emit(st.aiOcclusionDetectResult,{type:t.type,ts:e.ts||0}),this.player._opt.aiImageDetectDrop))return void this.player.debug.log("Video",`render() and ai image detect result type is ${t.type} and drop`)}try{const s=(t=r,i={format:"I420",codedWidth:this.videoInfo.width,codedHeight:this.videoInfo.height,timestamp:e.ts},new VideoFrame(t,i));this.vwriter.write(s),ya(s)}catch(e){this.player.debug.error("Video","render error",e),this.player.emitError(lt.wasmUseVideoRenderError,e)}}this.player.updateCurrentPts(e.ts||0),this.doAddContentToWatermark(),this.doAddAiContentToWatermark()}else this.player.debug.warn("Video","render and this.vwriter is null");var t,i}_resize(){this.player.debug.log("Video","_resize()");let e=this.player.width,t=this.player.height;const i=this.player._opt,r=i.rotate;if(i.hasControl&&!i.controlAutoHide){const r=i.playType===b?Pt:0;ks()&&this.player.fullscreen&&i.useWebFullScreen?e-=r:t-=r}this.$videoElement.width=e,this.$videoElement.height=t,this.$videoElement.style.width=e+"px",this.$videoElement.style.height=t+"px",270!==r&&90!==r||(this.$videoElement.width=t,this.$videoElement.height=e,this.$videoElement.style.width=t+"px",this.$videoElement.style.height=e+"px");let s=(e-this.$videoElement.width)/2,a=(t-this.$videoElement.height)/2,n="contain";ka(i.isResize)&&(n="fill"),i.isFullResize&&(n="none");let o="";"none"===i.mirrorRotate&&r&&(o+=" rotate("+r+"deg)"),"level"===i.mirrorRotate?o+=" rotateY(180deg)":"vertical"===i.mirrorRotate&&(o+=" rotateX(180deg)"),this.player._opt.videoRenderSupportScale&&(this.$videoElement.style.objectFit=n),this.$videoElement.style.transform=o,this.$videoElement.style.padding="0",this.$videoElement.style.left=s+"px",this.$videoElement.style.top=a+"px"}getType(){return q}getCurrentTime(){return this.$videoElement.currentTime}isPlaying(){return this.$videoElement&&ka(this.$videoElement.paused)&&ka(this.$videoElement.ended)&&0!==this.$videoElement.playbackRate&&0!==this.$videoElement.readyState}_canScreenshot(){return this.$videoElement&&this.$videoElement.readyState>=2}getPlaybackQuality(){let e=null;if(this.$videoElement){if(ha(this.$videoElement.getVideoPlaybackQuality)){const t=this.$videoElement.getVideoPlaybackQuality();e={droppedVideoFrames:t.droppedVideoFrames||t.corruptedVideoFrames,totalVideoFrames:t.totalVideoFrames,creationTime:t.creationTime}}else e={droppedVideoFrames:this.$videoElement.webkitDroppedFrameCount,totalVideoFrames:this.$videoElement.webkitDecodedFrameCount,creationTime:vs()};e&&(e.renderedVideoFrames=e.totalVideoFrames-e.droppedVideoFrames)}return e}setRate(e){this.$videoElement&&(this.$videoElement.playbackRate=e)}get rate(){let e=1;return this.$videoElement&&(e=this.$videoElement.playbackRate),e}clearCheckVideoCanplayTimeout(){this.checkVideoCanplayTimeout&&(clearTimeout(this.checkVideoCanplayTimeout),this.checkVideoCanplayTimeout=null)}_cancelVideoFrameCallback(){this.supportVideoFrameCallbackHandle&&this.$videoElement&&(this.$videoElement.cancelVideoFrameCallback(this.supportVideoFrameCallbackHandle),this.supportVideoFrameCallbackHandle=null)}_getBufferStore(){const e=this.$videoElement;let t=0;return e.buffered.length>0&&(t=e.buffered.start(0)),t}_handleUpdatePlaybackRate(){const e=this.$videoElement;let t=(this.player._opt.videoBuffer+this.player._opt.videoBufferDelay)/1e3;const i=e.buffered;i.length&&i.start(0);const r=i.length?i.end(i.length-1):0;let s=e.currentTime;const a=r-s,n=Math.max(5,t+3);if(this.player.updateStats({mseVideoBufferDelayTime:a}),a>n)this.player.debug.log(this.TAG_NAME,`handleUpdatePlaybackRate and buffered is ${r} and current is ${s} , delay buffer is more than ${n} is ${a} and new time is ${r}`),e.currentTime=r,s=e.currentTime;else if(a<0){if(this.player.debug.warn(this.TAG_NAME,`handleUpdatePlaybackRate and delay buffer is ${r} - current is ${s} = ${a} < 0 and check video is paused : ${e.paused} `),0===r)return void this.player.emit(lt.mediaSourceBufferedIsZeroError,"video.buffered is empty");e.paused&&e.play()}const o=this._getPlaybackRate(r-s);e.playbackRate!==o&&(this.player.debug.log(this.TAG_NAME,`handleUpdatePlaybackRate and buffered is ${r} and current time is ${s} and delay is ${r-s} set playbackRate is ${o} `),e.playbackRate=o)}_getPlaybackRate(e){const t=this.$videoElement;let i=this.player._opt.videoBufferDelay+this.player._opt.videoBuffer;const r=Math.max(i,1e3),s=r/2;return e*=1e3,1===t.playbackRate?e>r?1.2:1:e<=s?1:t.playbackRate}getVideoCurrentTime(){let e=0;return this.$videoElement&&(e=this.$videoElement.currentTime),e}getVideoBufferLastTime(){const e=this.$videoElement;let t=0;if(e){const i=e.buffered;i.length&&i.start(0);t=i.length?i.end(i.length-1):0}return t}getVideoBufferDelayTime(){const e=this.$videoElement;const t=this.getVideoBufferLastTime()-e.currentTime;return t>0?t:0}checkSourceBufferDelay(){const e=this.$videoElement;let t=0;return e.buffered.length>0&&(t=e.buffered.end(e.buffered.length-1)-e.currentTime),t<0&&(this.player.debug.warn(this.TAG_NAME,`checkSourceBufferDelay end(0) is ${e.buffered.end(0)} - currentTime is ${e.currentTime} and result < 0 and result is ${t}`),t=0),t}checkSourceBufferStore(){const e=this.$videoElement;let t=0;return e.buffered.length>0&&(t=e.currentTime-e.buffered.start(0)),t}getDecodePlaybackRate(){let e=0;const t=this.$videoElement;return t&&(e=t.playbackRate),e}}class sn extends en{constructor(e){super(e),this.controlHeight=Pt,this.bufferList=[],this.playing=!1,this.playInterval=null,this.fps=1,this.preFps=1,this.streamFps=0,this.playbackRate=1,this._firstTimestamp=null,this._renderFps=0,this._startfpsTime=null,this._startFpsTimestamp=null,this._hasCalcFps=!1,this.player.on(st.playbackPause,(e=>{e?(this.pause(),this.player.playback.isPlaybackPauseClearCache&&this.clear()):this.resume()})),this.player.debug.log("CanvasPlaybackLoader","init")}destroy(){this._stopSync(),this._firstTimestamp=null,this.playing=!1,this.playbackRate=1,this.fps=1,this.preFps=1,this.bufferList=[],this._renderFps=0,this._startfpsTime=null,this._startFpsTimestamp=null,this._hasCalcFps=!1,super.destroy(),this.player.debug.log("CanvasPlaybackLoader","destroy")}_initCanvasRender(){this.player._opt.useWCS?(this.renderType=Ft,La()&&this.player._opt.wcsUseWebgl2Render?(this._initContextGl2(),this.webglRender&&(this.isWcsWebgl2=!0)):this._initContext2D()):this.player._opt.useWebGPU?(this.renderType=Gt,this._initContextGPU()):(this.renderType=Ot,this._initContextGl())}_sync(){this._stopSync(),this._doPlay(),this.playInterval=setInterval((()=>{this._doPlay()}),this.fragDuration)}_doPlay(){if(this.bufferList.length>0&&!this.player.seeking){const e=this.bufferList.shift();e&&e.buffer&&(this._doRender(e.buffer),this.player.handleRender(),this.player.playback.updateStats({ts:e.ts,tfTs:e.tfTs}))}}_stopSync(){this.playInterval&&(clearInterval(this.playInterval),this.playInterval=null)}_doRender(e){if(this.player._opt.useWCS)if(this.webglRender)this.webglRender.render(e),ya(e);else if(ha(e.createImageBitmap))try{e.createImageBitmap().then((t=>{this.context2D.drawImage(t,0,0,this.$videoElement.width,this.$videoElement.height),ya(e)}))}catch(e){}else this.context2D.drawImage(e,0,0,this.$videoElement.width,this.$videoElement.height),ya(e);else if(this.getCanvasType()===Ot)try{this.webglRender.renderYUV(this.$videoElement.width,this.$videoElement.height,e)}catch(e){this.player.debug.error("CanvasPlaybackLoader",`doRender webgl render context is lost ${this.contextGl&&this.contextGl.isContextLost()} and error: ${e.toString()}`)}else if(this.getCanvasType()===Gt)try{if(!this.webGPURender)return void this.player.debug.warn("CanvasVideoLoader","doRender webgpu render is not init");this.webGPURender.renderYUV(this.$videoElement.width,this.$videoElement.height,e)}catch(e){this.player.debug.error("CanvasPlaybackLoader",`doRender webgpu render and error: ${e.toString()}`)}}get rate(){return this.playbackRate}get fragDuration(){return Math.ceil(1e3/(this.fps*this.playbackRate))}get bufferSize(){return this.bufferList.length}getStreamFps(){return this.streamFps}initFps(){this._hasCalcFps?this.player.debug.log("CanvasPlaybackLoader","initFps, has calc fps"):(this.preFps=bs(this.player.playback.fps,1,100),this.fps=this.preFps)}setFps(e){e!==this.fps?(e>100&&this.player.debug.warn("CanvasPlaybackLoader","setFps max",e),e<0&&this.player.debug.warn("CanvasPlaybackLoader","setFps min",e),this.fps=bs(e,1,100),this.player.debug.log("CanvasPlaybackLoader",`setFps ${this.preFps} -> ${this.fps}`),this.player.playback.isUseFpsRender&&this._sync()):this.player.debug.log("CanvasPlaybackLoader",`setFps, same fps ${e}`)}setStreamFps(e){this.player.debug.log("CanvasPlaybackLoader","setStreamFps",e),this._hasCalcFps=!0,this.streamFps=e,this.preFps=e,this.setFps(e)}setRate(e){e!==this.playbackRate&&(this.playbackRate=e,this.player.playback.isUseFpsRender&&this._sync())}render$2(e){null===this._firstTimestamp&&(this._firstTimestamp=e.ts);const t={tfTs:e.ts-this._firstTimestamp,ts:e.ts};e.videoFrame?t.buffer=e.videoFrame:t.buffer=e.output,this.bufferList.push(t),this.startRender(),this.player.handleRender(),this.player.playback.updateStats({ts:e.ts,tfTs:t.tfTs})}startRender(){for(;!(this.bufferList.length<=0);){const e=this.bufferList.shift();this._doRender(e.buffer)}}pushData(e){null===this._firstTimestamp&&(this._firstTimestamp=e.ts);const t={tfTs:e.ts-this._firstTimestamp,ts:e.ts};e.videoFrame?t.buffer=e.videoFrame:t.buffer=e.output;const i=this.player._opt.playbackConfig.isCacheBeforeDecodeForFpsRender;if(i||this.bufferSize>this.fps*this.playbackRate*2&&(this.player.debug.warn("CanvasPlaybackLoader",`buffer size is ${this.bufferSize}`),this._doPlay()),this.bufferList.push(t),!this._hasCalcFps){const e=Aa(this.bufferList);null!==e&&e!==this.preFps&&(this.player.debug.log("CanvasPlaybackLoader",`calc fps is ${e} pre fps is ${this.preFps} and updatePreFps`),this.setStreamFps(e))}if(!i){const e=this.bufferList.length,t=e/(this.fps*this.playbackRate);this.player.debug.log("CanvasPlaybackLoader","rate is",t),t<=1?this.setFps(this.preFps):(this.setFps(this.fps+Math.floor(t*this.playbackRate)),this.player.debug.warn("CanvasPlaybackLoader","rate is",t,"fps is",this.fps,"bufferListLength is",e))}}initVideo(){this.player.playback&&this.player.playback.isUseFpsRender&&this._sync(),this.playing=!0}initVideoDelay(){const e=this.player._opt.playbackDelayTime;e>0?this.delayTimeout=setTimeout((()=>{this.initVideo()}),e):this.initVideo()}clearView(){super.clearView(),this.contextGl.clear(this.contextGl.COLOR_BUFFER_BIT)}clear(){this.player._opt.useWCS&&this.bufferList.forEach((e=>{e.buffer&&ya(e.buffer)})),this.bufferList=[]}resume(){this.player.playback.isUseFpsRender&&this._sync(),this.playing=!0}pause(){this.player.playback.isUseFpsRender&&this._stopSync(),this.playing=!1}}class an{constructor(e){return new(an.getLoaderFactory(e._opt))(e)}static getLoaderFactory(e){return e.isWsRtc?rn:e.useMSE?e.mseUseCanvasRender?tn:rn:e.isHls&&ka(e.supportHls265)||e.isWebrtc&&ka(e.isWebrtcH265)?e.useCanvasRender?tn:rn:e.isAliyunRtc?rn:e.useWCS?e.playType===b?sn:!e.useOffscreen&&e.wcsUseVideoRender?rn:tn:e.playType===b?sn:e.wasmUseVideoRender&&!e.useOffscreen?rn:tn}}class nn extends t{constructor(e){super(),this.bufferList=[],this.player=e,this.$audio=null,this.scriptNode=null,this.workletProcessorNode=null,this.hasInitScriptNode=!1,this.audioContext=new(window.AudioContext||window.webkitAudioContext)({sampleRate:48e3}),this.gainNode=this.audioContext.createGain();const t=this.audioContext.createBufferSource();t.buffer=this.audioContext.createBuffer(1,1,22050),t.connect(this.audioContext.destination),t.noteOn?t.noteOn(0):t.start(0),this.audioBufferSourceNode=t,this.mediaStreamAudioDestinationNode=this.audioContext.createMediaStreamDestination(),this.gainNode.gain.value=0,this.playing=!1,this.audioInfo={encType:"",channels:"",sampleRate:"",depth:""},this.init=!1,this.hasAudio=!1,this.audioResumeStateTimeout=null}destroy(){this.closeAudio(),this.resetInit(),this.audioContext&&(this.audioContext.close(),this.audioContext=null),this.gainNode=null,this.hasAudio=!1,this.playing=!1,this.scriptNode&&(this.scriptNode.onaudioprocess=ys,this.scriptNode=null),this.workletProcessorNode&&(this.workletProcessorNode.port.onmessage=ys,this.workletProcessorNode=null),this.clearAudioResumeStateTimeout(),this.audioBufferSourceNode=null,this.mediaStreamAudioDestinationNode=null,this.hasInitScriptNode=!1,this.off()}resetInit(){this.audioInfo={encType:"",channels:"",sampleRate:"",depth:""},this.init=!1}getAudioInfo(){return this.audioInfo}updateAudioInfo(e){e.encTypeCode&&(this.audioInfo.encTypeCode=e.encTypeCode,this.audioInfo.encType=Et[e.encTypeCode]),e.channels&&(this.audioInfo.channels=e.channels),e.sampleRate&&(this.audioInfo.sampleRate=e.sampleRate),e.depth&&(this.audioInfo.depth=e.depth),this.audioInfo.sampleRate&&this.audioInfo.channels&&this.audioInfo.encType&&!this.init&&(this.player.emit(st.audioInfo,this.audioInfo),this.init=!0)}get isPlaying(){return this.playing}get isMute(){return 0===this.gainNode.gain.value}get volume(){return this.gainNode.gain.value}get bufferSize(){return this.bufferList.length}get audioContextState(){let e=null;return this.audioContext&&(e=this.audioContext.state),e}initScriptNode(){}initMobileScriptNode(){}initWorkletScriptNode(){}getEngineType(){return""}mute(e){this.player.emit(st.mute,e),e?(this.setVolume(0),this.clear()):this.setVolume(this.player.lastVolume||.5)}setVolume(e){e=parseFloat(e).toFixed(2),isNaN(e)||(this.audioEnabled(!0),e=bs(e,0,1),this.gainNode.gain.value=e,this.player.emit(st.volumechange,this.player.volume))}closeAudio(){this.hasInitScriptNode&&(this.scriptNode&&this.scriptNode.disconnect(this.gainNode),this.workletProcessorNode&&this.workletProcessorNode.disconnect(this.gainNode),this.gainNode&&(this.gainNode.disconnect(this.mediaStreamAudioDestinationNode),this.$audio||this.gainNode.disconnect(this.audioContext.destination))),this.clear()}audioEnabled(e){e?this.isStateSuspended()&&(this.audioContext.resume().then((()=>{this.player.emit(st.audioResumeState,{state:this.audioContextState,isRunning:this.isStateRunning()})})),this.audioResumeStateTimeout=setTimeout((()=>{this.clearAudioResumeStateTimeout(),this.isStateSuspended()&&this.player.emit(st.audioResumeState,{state:this.audioContextState,isRunning:this.isStateRunning()})}),1e3)):this.isStateRunning()&&this.audioContext.suspend()}isStateRunning(){return"running"===this.audioContextState}isStateSuspended(){return"suspended"===this.audioContextState}clearAudioResumeStateTimeout(){this.audioResumeStateTimeout&&(clearTimeout(this.audioResumeStateTimeout),this.audioResumeStateTimeout=null)}clear(){this.bufferList=[]}play(e,t){}pause(){this.playing=!1}resume(){this.playing=!0}setRate(e){}getAudioBufferSize(){return 0}}class on{constructor(e,t,i,r){this.player=e,this.audio=t,this.channel=i,this.bufferSize=r}extract(e,t){let i=this.provide(t);for(let t=0;t<i.size;t++)e[2*t]=i.left[t],e[2*t+1]=i.right[t];return this.audio.tempAudioTimestamp=i.ts,i.size}provide(e){let t=new Float32Array(e),i=new Float32Array(e),r=0,s=0,a=0,n=e/this.bufferSize;const o=this.audio.bufferList;if(n&&o.length>=n){try{for(let e=0;e<n;e++){const e=o.shift();2===this.channel?(t.set(e.buffer[0],a),i.set(e.buffer[1],a)):(t.set(e.buffer[0],a),i.set(e.buffer[0],a)),a+=this.bufferSize,s=e.ts}}catch(e){this.player.debug.warn("Processor","provide()",e),t=new Float32Array(0),i=new Float32Array(0)}r=t.length}return{size:r,ts:s,left:t,right:i}}destroy(){this.buffer=null,this.channel=null}}class ln{constructor(){this._vector=new Float32Array,this._position=0,this._frameCount=0}get vector(){return this._vector}get position(){return this._position}get startIndex(){return 2*this._position}get frameCount(){return this._frameCount}get endIndex(){return 2*(this._position+this._frameCount)}clear(){this.receive(this._frameCount),this.rewind()}put(e){this._frameCount+=e}putSamples(e,t,i=0){const r=2*(t=t||0);i>=0||(i=(e.length-r)/2);const s=2*i;this.ensureCapacity(i+this._frameCount);const a=this.endIndex;this.vector.set(e.subarray(r,r+s),a),this._frameCount+=i}putBuffer(e,t,i=0){t=t||0,i>=0||(i=e.frameCount-t),this.putSamples(e.vector,e.position+t,i)}receive(e){e>=0&&!(e>this._frameCount)||(e=this.frameCount),this._frameCount-=e,this._position+=e}receiveSamples(e,t=0){const i=2*t,r=this.startIndex;e.set(this._vector.subarray(r,r+i)),this.receive(t)}extract(e,t=0,i=0){const r=this.startIndex+2*t,s=2*i;e.set(this._vector.subarray(r,r+s))}ensureCapacity(e=0){const t=parseInt(2*e);if(this._vector.length<t){const e=new Float32Array(t);e.set(this._vector.subarray(this.startIndex,this.endIndex)),this._vector=e,this._position=0}else this.rewind()}ensureAdditionalCapacity(e=0){this.ensureCapacity(this._frameCount+e)}rewind(){this._position>0&&(this._vector.set(this._vector.subarray(this.startIndex,this.endIndex)),this._position=0)}}class dn{constructor(e){e?(this._inputBuffer=new ln,this._outputBuffer=new ln):this._inputBuffer=this._outputBuffer=null}get inputBuffer(){return this._inputBuffer}set inputBuffer(e){this._inputBuffer=e}get outputBuffer(){return this._outputBuffer}set outputBuffer(e){this._outputBuffer=e}clear(){this._inputBuffer.clear(),this._outputBuffer.clear()}}class hn extends dn{constructor(e){super(e),this.reset(),this._rate=1}set rate(e){this._rate=e}reset(){this.slopeCount=0,this.prevSampleL=0,this.prevSampleR=0}clone(){const e=new hn;return e.rate=this._rate,e}process(){const e=this._inputBuffer.frameCount;this._outputBuffer.ensureAdditionalCapacity(e/this._rate+1);const t=this.transpose(e);this._inputBuffer.receive(),this._outputBuffer.put(t)}transpose(e=0){if(0===e)return 0;const t=this._inputBuffer.vector,i=this._inputBuffer.startIndex,r=this._outputBuffer.vector,s=this._outputBuffer.endIndex;let a=0,n=0;for(;this.slopeCount<1;)r[s+2*n]=(1-this.slopeCount)*this.prevSampleL+this.slopeCount*t[i],r[s+2*n+1]=(1-this.slopeCount)*this.prevSampleR+this.slopeCount*t[i+1],n+=1,this.slopeCount+=this._rate;if(this.slopeCount-=1,1!==e)e:for(;;){for(;this.slopeCount>1;)if(this.slopeCount-=1,a+=1,a>=e-1)break e;const o=i+2*a;r[s+2*n]=(1-this.slopeCount)*t[o]+this.slopeCount*t[o+2],r[s+2*n+1]=(1-this.slopeCount)*t[o+1]+this.slopeCount*t[o+3],n+=1,this.slopeCount+=this._rate}return this.prevSampleL=t[i+2*e-2],this.prevSampleR=t[i+2*e-1],n}}class cn{constructor(e){this._pipe=e}get pipe(){return this._pipe}get inputBuffer(){return this._pipe.inputBuffer}get outputBuffer(){return this._pipe.outputBuffer}fillInputBuffer(){throw new Error("fillInputBuffer() not overridden")}fillOutputBuffer(e=0){for(;this.outputBuffer.frameCount<e;){const e=16384-this.inputBuffer.frameCount;if(this.fillInputBuffer(e),this.inputBuffer.frameCount<16384)break;this._pipe.process()}}clear(){this._pipe.clear()}}const un=function(){};class pn extends cn{constructor(e,t,i=un){super(t),this.callback=i,this.sourceSound=e,this.historyBufferSize=22050,this._sourcePosition=0,this.outputBufferPosition=0,this._position=0}get position(){return this._position}set position(e){if(e>this._position)throw new RangeError("New position may not be greater than current position");const t=this.outputBufferPosition-(this._position-e);if(t<0)throw new RangeError("New position falls outside of history buffer");this.outputBufferPosition=t,this._position=e}get sourcePosition(){return this._sourcePosition}set sourcePosition(e){this.clear(),this._sourcePosition=e}onEnd(){this.callback()}fillInputBuffer(e=0){const t=new Float32Array(2*e),i=this.sourceSound.extract(t,e,this._sourcePosition);this._sourcePosition+=i,this.inputBuffer.putSamples(t,0,i)}extract(e,t=0){this.fillOutputBuffer(this.outputBufferPosition+t);const i=Math.min(t,this.outputBuffer.frameCount-this.outputBufferPosition);this.outputBuffer.extract(e,this.outputBufferPosition,i);const r=this.outputBufferPosition+i;return this.outputBufferPosition=Math.min(this.historyBufferSize,r),this.outputBuffer.receive(Math.max(r-this.historyBufferSize,0)),this._position+=i,i}handleSampleData(e){this.extract(e.data,4096)}clear(){super.clear(),this.outputBufferPosition=0}}const fn=[[124,186,248,310,372,434,496,558,620,682,744,806,868,930,992,1054,1116,1178,1240,1302,1364,1426,1488,0],[-100,-75,-50,-25,25,50,75,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[-20,-15,-10,-5,5,10,15,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[-4,-3,-2,-1,1,2,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],yn=-10/1.5;class mn extends dn{constructor(e){super(e),this._quickSeek=!0,this.midBufferDirty=!1,this.midBuffer=null,this.overlapLength=0,this.autoSeqSetting=!0,this.autoSeekSetting=!0,this._tempo=1,this.setParameters(44100,0,0,8)}clear(){super.clear(),this.clearMidBuffer()}clearMidBuffer(){this.midBufferDirty&&(this.midBufferDirty=!1,this.midBuffer=null)}setParameters(e,t,i,r){e>0&&(this.sampleRate=e),r>0&&(this.overlapMs=r),t>0?(this.sequenceMs=t,this.autoSeqSetting=!1):this.autoSeqSetting=!0,i>0?(this.seekWindowMs=i,this.autoSeekSetting=!1):this.autoSeekSetting=!0,this.calculateSequenceParameters(),this.calculateOverlapLength(this.overlapMs),this.tempo=this._tempo}set tempo(e){let t;this._tempo=e,this.calculateSequenceParameters(),this.nominalSkip=this._tempo*(this.seekWindowLength-this.overlapLength),this.skipFract=0,t=Math.floor(this.nominalSkip+.5),this.sampleReq=Math.max(t+this.overlapLength,this.seekWindowLength)+this.seekLength}get tempo(){return this._tempo}get inputChunkSize(){return this.sampleReq}get outputChunkSize(){return this.overlapLength+Math.max(0,this.seekWindowLength-2*this.overlapLength)}calculateOverlapLength(e=0){let t;t=this.sampleRate*e/1e3,t=t<16?16:t,t-=t%8,this.overlapLength=t,this.refMidBuffer=new Float32Array(2*this.overlapLength),this.midBuffer=new Float32Array(2*this.overlapLength)}checkLimits(e,t,i){return e<t?t:e>i?i:e}calculateSequenceParameters(){let e,t;this.autoSeqSetting&&(e=150+-50*this._tempo,e=this.checkLimits(e,50,125),this.sequenceMs=Math.floor(e+.5)),this.autoSeekSetting&&(t=28.333333333333332+yn*this._tempo,t=this.checkLimits(t,15,25),this.seekWindowMs=Math.floor(t+.5)),this.seekWindowLength=Math.floor(this.sampleRate*this.sequenceMs/1e3),this.seekLength=Math.floor(this.sampleRate*this.seekWindowMs/1e3)}set quickSeek(e){this._quickSeek=e}clone(){const e=new mn;return e.tempo=this._tempo,e.setParameters(this.sampleRate,this.sequenceMs,this.seekWindowMs,this.overlapMs),e}seekBestOverlapPosition(){return this._quickSeek?this.seekBestOverlapPositionStereoQuick():this.seekBestOverlapPositionStereo()}seekBestOverlapPositionStereo(){let e,t,i,r=0;for(this.preCalculateCorrelationReferenceStereo(),e=0,t=Number.MIN_VALUE;r<this.seekLength;r+=1)i=this.calculateCrossCorrelationStereo(2*r,this.refMidBuffer),i>t&&(t=i,e=r);return e}seekBestOverlapPositionStereoQuick(){let e,t,i,r,s,a=0;for(this.preCalculateCorrelationReferenceStereo(),t=Number.MIN_VALUE,e=0,r=0,s=0;a<4;a+=1){let n=0;for(;fn[a][n]&&(s=r+fn[a][n],!(s>=this.seekLength));)i=this.calculateCrossCorrelationStereo(2*s,this.refMidBuffer),i>t&&(t=i,e=s),n+=1;r=e}return e}preCalculateCorrelationReferenceStereo(){let e,t,i=0;for(;i<this.overlapLength;i+=1)t=i*(this.overlapLength-i),e=2*i,this.refMidBuffer[e]=this.midBuffer[e]*t,this.refMidBuffer[e+1]=this.midBuffer[e+1]*t}calculateCrossCorrelationStereo(e,t){const i=this._inputBuffer.vector;e+=this._inputBuffer.startIndex;let r=0,s=2;const a=2*this.overlapLength;let n;for(;s<a;s+=2)n=s+e,r+=i[n]*t[s]+i[n+1]*t[s+1];return r}overlap(e){this.overlapStereo(2*e)}overlapStereo(e){const t=this._inputBuffer.vector;e+=this._inputBuffer.startIndex;const i=this._outputBuffer.vector,r=this._outputBuffer.endIndex;let s,a,n=0;const o=1/this.overlapLength;let l,d,h;for(;n<this.overlapLength;n+=1)a=(this.overlapLength-n)*o,l=n*o,s=2*n,d=s+e,h=s+r,i[h+0]=t[d+0]*l+this.midBuffer[s+0]*a,i[h+1]=t[d+1]*l+this.midBuffer[s+1]*a}process(){let e,t,i;if(null===this.midBuffer){if(this._inputBuffer.frameCount<this.overlapLength)return;this.midBuffer=new Float32Array(2*this.overlapLength),this._inputBuffer.receiveSamples(this.midBuffer,this.overlapLength)}for(;this._inputBuffer.frameCount>=this.sampleReq;){e=this.seekBestOverlapPosition(),this._outputBuffer.ensureAdditionalCapacity(this.overlapLength),this.overlap(Math.floor(e)),this._outputBuffer.put(this.overlapLength),t=this.seekWindowLength-2*this.overlapLength,t>0&&this._outputBuffer.putBuffer(this._inputBuffer,e+this.overlapLength,t);const r=this._inputBuffer.startIndex+2*(e+this.seekWindowLength-this.overlapLength);this.midBuffer.set(this._inputBuffer.vector.subarray(r,r+2*this.overlapLength)),this.skipFract+=this.nominalSkip,i=Math.floor(this.skipFract),this.skipFract-=i,this._inputBuffer.receive(i)}}}const gn=function(e,t){return(e>t?e-t:t-e)>1e-10};class An{constructor(){this.transposer=new hn(!1),this.stretch=new mn(!1),this._inputBuffer=new ln,this._intermediateBuffer=new ln,this._outputBuffer=new ln,this._rate=0,this._tempo=0,this.virtualPitch=1,this.virtualRate=1,this.virtualTempo=1,this.calculateEffectiveRateAndTempo()}clear(){this.transposer.clear(),this.stretch.clear()}clone(){const e=new An;return e.rate=this.rate,e.tempo=this.tempo,e}get rate(){return this._rate}set rate(e){this.virtualRate=e,this.calculateEffectiveRateAndTempo()}set rateChange(e){this._rate=1+.01*e}get tempo(){return this._tempo}set tempo(e){this.virtualTempo=e,this.calculateEffectiveRateAndTempo()}set tempoChange(e){this.tempo=1+.01*e}set pitch(e){this.virtualPitch=e,this.calculateEffectiveRateAndTempo()}set pitchOctaves(e){this.pitch=Math.exp(.69314718056*e),this.calculateEffectiveRateAndTempo()}set pitchSemitones(e){this.pitchOctaves=e/12}get inputBuffer(){return this._inputBuffer}get outputBuffer(){return this._outputBuffer}calculateEffectiveRateAndTempo(){const e=this._tempo,t=this._rate;this._tempo=this.virtualTempo/this.virtualPitch,this._rate=this.virtualRate*this.virtualPitch,gn(this._tempo,e)&&(this.stretch.tempo=this._tempo),gn(this._rate,t)&&(this.transposer.rate=this._rate),this._rate>1?this._outputBuffer!=this.transposer.outputBuffer&&(this.stretch.inputBuffer=this._inputBuffer,this.stretch.outputBuffer=this._intermediateBuffer,this.transposer.inputBuffer=this._intermediateBuffer,this.transposer.outputBuffer=this._outputBuffer):this._outputBuffer!=this.stretch.outputBuffer&&(this.transposer.inputBuffer=this._inputBuffer,this.transposer.outputBuffer=this._intermediateBuffer,this.stretch.inputBuffer=this._intermediateBuffer,this.stretch.outputBuffer=this._outputBuffer)}process(){this._rate>1?(this.stretch.process(),this.transposer.process()):(this.transposer.process(),this.stretch.process())}}class vn{constructor(e,t,i){this.player=e,this.audio=t,this.soundTouch=new An,this.soundTouch.tempo=1,this.soundTouch.rate=1,this.filter=new pn(i,this.soundTouch)}setRate(e){e!==this.soundTouch.rate&&(this.soundTouch.tempo=e)}provide(e){let t=new Float32Array(2*e),i=this.filter.extract(t,e),r=new Float32Array(i),s=new Float32Array(i);for(let e=0;e<i;e++)r[e]=t[2*e],s[e]=t[2*e+1];return{size:i,left:r,right:s,ts:this.audio.tempAudioTimestamp||0}}destroy(){this.soundTouch&&(this.soundTouch.clear(),this.soundTouch=null),this.filter&&(this.filter=null)}}class bn extends nn{constructor(e){super(e),this.defaultPlaybackRate=1,this.playbackRate=1,this.rateProcessor=null,this.processor=null,this.scriptNodeInterval=null,this.engineType=this.getAutoAudioEngineType(),this.audioBufferSize=this.getAudioBufferSizeByType(),this.$audio=null,this._delayPlay=!1,this.eventListenList=[],this.workletUrl=null,this.clearWorkletUrlTimeout=null,this.player._opt.supportLockScreenPlayAudio&&Ls()&&(this.$audio=document.createElement("audio"),Object.assign(this.$audio.style,{position:"absolute",left:"-100%",top:"-100%"}),e.$container?e.$container.appendChild(this.$audio):document.body.appendChild(this.$audio),this._bindAudioProxy(),this.player.debug.log("AudioContext","create audio element")),this.scriptStartTime=0,this.player.debug.log("AudioContext","init",`engineType: ${this.engineType}, audioBufferSize: ${this.audioBufferSize}`)}destroy(){super.destroy(),this.workletUrl&&(URL.revokeObjectURL(this.workletUrl),this.workletUrl=null),this.clearWorkletUrlTimeout&&(clearTimeout(this.clearWorkletUrlTimeout),this.clearWorkletUrlTimeout=null),this.eventListenList&&(this.eventListenList.forEach((e=>{e()})),this.eventListenList=[]),this.$audio&&(this.$audio.pause(),this.$audio.srcObject=null,this.$audio.parentNode&&this.$audio.parentNode.removeChild(this.$audio),this.$audio=null),this.processor&&(this.processor.destroy(),this.processor=null),this.rateProcessor&&(this.rateProcessor.destroy(),this.rateProcessor=null),this.scriptNodeInterval&&(clearInterval(this.scriptNodeInterval),this.scriptNodeInterval=null),this.defaultPlaybackRate=1,this.playbackRate=1,this.scriptStartTime=0,this.audioBufferSize=0,this.engineType=tr,this.player.debug.log("AudioContext","destroy")}isAudioPlaying(){return this.$audio&&ka(this.$audio.paused)&&ka(this.$audio.ended)&&0!==this.$audio.playbackRate&&0!==this.$audio.readyState}_bindAudioProxy(){const{proxy:e}=this.player.events,t=e(this.$audio,"canplay",(()=>{this.player.debug.log("AudioContext","canplay"),this._delayPlay&&this._audioElementPlay()}));this.eventListenList.push(t)}_getAudioElementReadyState(){let e=0;return this.$audio&&(e=this.$audio.readyState),e}audioElementPlay(){if(this.$audio){const e=this._getAudioElementReadyState();if(this.player.debug.log("AudioContext",`play and readyState: ${e}`),!(0!==e||na()&&Ls()))return this.player.debug.warn("AudioContext","readyState is 0 and set _delayPlay to true"),void(this._delayPlay=!0);this._audioElementPlay()}}_audioElementPlay(){this.$audio&&this.$audio.play().then((()=>{this._delayPlay=!1,this.player.debug.log("AudioContext","_audioElementPlay success"),setTimeout((()=>{this.isAudioPlaying()||(this.player.debug.warn("AudioContext","play failed and retry play"),this._audioElementPlay())}),100),this.isAudioPlaying()&&(this.player.debug.log("AudioContext","play success and remove document click event listener"),document.removeEventListener("click",this._audioElementPlay.bind(this)))})).catch((e=>{this.player.debug.error("AudioContext","_audioElementPlay error",e),document.addEventListener("click",this._audioElementPlay.bind(this))}))}getAudioBufferSize(){return this.audioBufferSize}get oneBufferDuration(){return this.audioBufferSize/this.audioContext.sampleRate*1e3}get isActiveEngineType(){return this.engineType===ir}initProcessor(){this.processor=new on(this.player,this,this.audioInfo.channels,this.audioBufferSize),this.rateProcessor=new vn(this.player,this,this.processor)}getAutoAudioEngineType(){let e=this.player._opt.audioEngine||tr;const t=()=>{e=na()&&Ds()?ir:Ls()&&this.player._opt.supportLockScreenPlayAudio?tr:ma()&&this.supportAudioWorklet()?er:tr};return this.player._opt.audioEngine?this.player._opt.audioEngine===er&&ma()?e=er:this.player._opt.audioEngine===ir?e=ir:this.player._opt.audioEngine===tr?e=tr:t():t(),e}getAudioBufferSizeByType(){const e=this.engineType;this.player._opt.hasVideo;const t=this.player._opt.weiXinInAndroidAudioBufferSize;return e===er?1024:e===ir?t||4800:1024}supportAudioWorklet(){return this.audioContext&&this.audioContext.audioWorklet}initScriptNode(){this.playing=!0,this.hasInitScriptNode||(this.initProcessor(),this.engineType===er?this.initWorkletScriptNode():this.engineType===ir?this.initIntervalScriptNode():this.engineType===tr&&this.initProcessScriptNode(),this.audioElementPlay())}getEngineType(){return this.engineType}isPlaybackRateSpeed(){return this.playbackRate>this.defaultPlaybackRate}initProcessScriptNode(){const e=this.audioContext.createScriptProcessor(this.audioBufferSize,0,this.audioInfo.channels);e.onaudioprocess=e=>{const t=e.outputBuffer;this.handleScriptNodeCallback(t)},e.connect(this.gainNode),this.scriptNode=e,this.gainNode.connect(this.mediaStreamAudioDestinationNode),this.$audio?this.$audio.srcObject=this.mediaStreamAudioDestinationNode.stream:this.gainNode.connect(this.audioContext.destination),this.hasInitScriptNode=!0}initIntervalScriptNode(){this.scriptStartTime=0;const e=1e3*this.audioBufferSize/this.audioContext.sampleRate;this.scriptNodeInterval=setInterval((()=>{if(0===this.bufferList.length||ka(this.playing)||this.isMute)return void(this.playing&&ka(this.isMute)&&this.player.debug.log("AudioContext",`interval script node and bufferList is ${this.bufferList.length} or playing is ${this.playing}`));const e=this.audioContext.createBufferSource(),t=this.audioContext.createBuffer(this.audioInfo.channels,this.audioBufferSize,this.audioContext.sampleRate);this.handleScriptNodeCallback(t,(()=>{this.scriptStartTime<this.audioContext.currentTime&&(this.player.debug.log("AudioContext",`script start time ${this.scriptStartTime} is less than current time ${this.audioContext.currentTime}`),this.scriptStartTime=this.audioContext.currentTime),e.buffer=t,e.connect(this.gainNode),e.start(this.scriptStartTime),this.scriptStartTime+=t.duration}))}),e),this.gainNode.connect(this.mediaStreamAudioDestinationNode),this.$audio?this.$audio.srcObject=this.mediaStreamAudioDestinationNode.stream:this.gainNode.connect(this.audioContext.destination),this.hasInitScriptNode=!0}initWorkletScriptNode(){let e=fa((function(){class e extends AudioWorkletProcessor{constructor(){super(),this.audioBufferSize=1024,this.start=!1,this.channels=1,this.samplesArray=[],this.offset=0,this.state=0,this.port.onmessage=e=>{"init"===e.data.message?(this.audioBufferSize=e.data.audioBufferSize,this.start=e.data.start,this.channels=e.data.channels,this.state=0,this.offset=0,this.samplesArray=[]):"stop"===e.data.message?(this.state=0,this.start=!1,this.offset=0,this.samplesArray=[]):"data"===e.data.message?this.samplesArray.push(e.data.buffer):"zero"===e.data.message&&this.samplesArray.push({left:new Float32Array(this.audioBufferSize).fill(0),right:new Float32Array(this.audioBufferSize).fill(0)})}}process(e,t,i){const r=t[0][0],s=t[0][1];if(0===this.offset&&this.port.postMessage({message:"beep"}),0===this.state)this.state=1;else if(1===this.state&&this.samplesArray.length>=4)this.state=2;else if(2===this.state){const e=this.samplesArray[0];for(let t=0;t<r.length;t++)1===this.channels?r[t]=e.left[t+this.offset]:2===this.channels&&(r[t]=e.left[t+this.offset],s&&(s[t]=e.right[t+this.offset]))}else 1===this.channels?r.fill(0):2===this.channels&&(r.fill(0),s&&s.fill(0));return this.offset+=128,this.offset===this.audioBufferSize&&(this.offset=0,2===this.state&&this.samplesArray.shift(),0===this.samplesArray.length&&(this.state=0)),this.start}}registerProcessor("worklet-processor",e)}));this.workletUrl=e,this.audioContext.audioWorklet.addModule(e).then((()=>{if(this.player.isDestroyedOrClosed())return void this.player.debug.log("AudioContext","initWorkletScriptNode() player is destroyed");if(!this.audioContext)return void this.player.debug.warn("AudioContext","initWorkletScriptNode audioContext is null");let e=[1];2===this.audioInfo.channels&&(e=[1,1]);try{this.workletProcessorNode=new AudioWorkletNode(this.audioContext,"worklet-processor",{numberOfOutputs:this.audioInfo.channels,outputChannelCount:e})}catch(e){this.player.debug.error("AudioContext","initWorkletScriptNode error",e),this.workletProcessorNode=null,this.tierDownToProcessScript()}this.workletProcessorNode&&(this.workletProcessorNode.connect(this.gainNode),this.gainNode.connect(this.mediaStreamAudioDestinationNode),this.$audio?this.$audio.srcObject=this.mediaStreamAudioDestinationNode.stream:this.gainNode.connect(this.audioContext.destination),this.hasInitScriptNode=!0,this.workletProcessorNode.port.postMessage({message:"init",audioBufferSize:this.audioBufferSize,start:!0,channels:this.audioInfo.channels}),this.workletProcessorNode.port.onmessage=e=>{this.workletProcessorNode?this.audioContext?this.handleScriptNodeCallback(this.workletProcessorNode,null,!0):this.workletProcessorNode.port.postMessage({message:"zero"}):this.player.debug.error("AudioContext","workletProcessorNode is null")})})),this.clearWorkletUrlTimeout=setTimeout((()=>{URL.revokeObjectURL(this.workletUrl),this.workletUrl=null,this.clearWorkletUrlTimeout=null}),re)}tierDownToProcessScript(){this.player.debug.log("AudioContext","tierDownToProcessScript"),this.engineType=tr,this.audioBufferSize=this.getAudioBufferSizeByType(),this.initProcessScriptNode(),this.audioElementPlay()}handleScriptNodeCallback(e,t,i=!1){let r;t=t||ys;let s=e.length;i&&(r=e,s=this.audioBufferSize);const a=this.audioInfo.channels;if(this.bufferList.length&&this.playing){if(this.player._opt,this.player.openSyncAudioAndVideo()&&Ta(this.player.visibility)){this.calcPlaybackRateBySync();const s=this.player.getAudioSyncVideoDiff();if(s>this.player._opt.syncAudioAndVideoDiff)return this.player.debug.warn("AudioContext",`audioSyncVideoOption more than diff :${s}, waiting and bufferList is ${this.bufferList.length}`),i?r.port.postMessage({message:"zero"}):this.fillScriptNodeOutputBuffer(e,a),void t()}let n=this._provide(s);if(0===n.size)return this.player.debug.warn("AudioContext",`bufferList size is ${this.bufferList.length} outputBufferLength is ${s},and bufferItem.size is 0`),i?r.port.postMessage({message:"zero"}):this.fillScriptNodeOutputBuffer(e,a),void t();n&&n.ts&&(this.player.audioTimestamp=n.ts),i?r.port.postMessage({message:"data",buffer:n}):this.fillScriptNodeOutputBuffer(e,a,n),t()}else 0===this.bufferList.length&&this.playing&&ka(this.isMute)&&this.player.debug.warn("AudioContext",`bufferList size is 0 and outputBufferLength is ${s}`),i?r.port.postMessage({message:"zero"}):this.fillScriptNodeOutputBuffer(e,a),t()}fillScriptNodeOutputBuffer(e,t,i){if(1===t){const t=e.getChannelData(0);i?0===i.size?t.fill(0):t.set(i.left):t.fill(0)}else if(2===t){const t=e.getChannelData(0),r=e.getChannelData(1);i?0===i.size?(t.fill(0),r.fill(0)):(t.set(i.left),r.set(i.right)):(t.fill(0),r.fill(0))}}play(e,t){this.isMute||(this.hasInitScriptNode?(this.hasAudio=!0,this.player.latestAudioTimestamp=t,this.bufferList.push({buffer:e,ts:t}),ka(this.player.openSyncAudioAndVideo())&&this.calcPlaybackRateByBuffer()):this.player.debug.warn("AudioContext","play has not init script node"))}calcPlaybackRateBySync(){if(this.isMute)return;if(!this.playing)return;const e=Math.floor(2e3/this.oneBufferDuration);if(this.bufferList.length>e)return this.player.debug.warn("AudioContext",`bufferList length ${this.bufferList.length} more than ${e}, and drop`),void this.clear();const t=this.player.getAudioSyncVideoDiff();if(this.getEngineType()===ir){if(t<-this.player._opt.syncAudioAndVideoDiff){this.player.debug.warn("AudioContext",`engine active , audioSyncVideoOption ${-this.player._opt.syncAudioAndVideoDiff} less than diff :${t},\n and bufferlist is ${this.bufferList.length}`);const e=this.player.getRenderCurrentPts();for(;this.bufferList.length>0;){const t=this.bufferList[0],i=t.ts-e;if(i>-this.player._opt.syncAudioAndVideoDiff/2){this.player.audioTimestamp=t.ts,this.player.debug.log("AudioContext",`engine active , audioSyncVideoOption\n item.ts is ${t.ts} and currentVideoTimestamp is ${e}, diff is ${i} > -${this.player._opt.syncAudioAndVideoDiff/2} and end`);break}this.bufferList.shift(),this.player.audioTimestamp=t.ts}}}else{let e=this.playbackRate;t<-this.player._opt.syncAudioAndVideoDiff?e===this.defaultPlaybackRate&&(this.player.debug.log("AudioContext",`audioSyncVideoOption ${-this.player._opt.syncAudioAndVideoDiff} less than diff :${t},\n speed up, playbackRate is ${e},\n and bufferList is ${this.bufferList.length}`),e=this.defaultPlaybackRate+.2):t>-this.player._opt.syncAudioAndVideoDiff/2&&e!==this.defaultPlaybackRate&&(this.player.debug.log("AudioContext",`diff is ${t} > -${this.player._opt.syncAudioAndVideoDiff/2} and speed to 1`),e=this.defaultPlaybackRate),this.updatePlaybackRate(e)}}calcPlaybackRateByBuffer(){if(this.isMute)return;if(!this.playing)return;let e=this.playbackRate,t=1e3,i=5e3;this.isAudioPlayer&&(t=this.player._opt.videoBufferDelay,i=this.player._opt.videoBufferMax);const r=Math.floor(t/this.oneBufferDuration),s=Math.floor(i/this.oneBufferDuration);if(this.bufferList.length>s)return this.player.debug.warn("AudioContext",`bufferList length ${this.bufferList.length} more than ${s}, and drop`),void this.clear();this.getEngineType()!==ir&&(this.bufferList.length>r?(e=this.defaultPlaybackRate+.2,this.player.debug.log("AudioContext",`bufferList length ${this.bufferList.length} more than ${r}, speed up, playbackRate is ${e}`)):this.bufferList.length<r/2&&(e=this.defaultPlaybackRate),this.updatePlaybackRate(e))}updatePlaybackRate(e){this.rateProcessor&&(this.playbackRate=e,this.rateProcessor.setRate(this.playbackRate))}_provide(e){return(1===this.playbackRate?this.processor:this.rateProcessor).provide(e)}}class _n extends t{constructor(e){super(),this.player=e,this.$video=e.video.$videoElement,this.init=!1,this.player._opt.hlsUseCanvasRender&&(this.$video=this.player.hlsDecoder.$videoElement),this.player._opt.webrtcUseCanvasRender&&(this.$video=this.player.webrtc.$videoElement),this.player.wsRtcDecoder&&(this.$video=this.player.wsRtcDecoder.$videoElement),this.audioInfo={encType:"",channels:"",sampleRate:""},this.player.debug.log("Audio","init")}destroy(){this.resetInit(),this.off(),this.player.debug.log("Audio","destroy")}resetInit(){this.init=!1,this.audioInfo={encType:"",channels:"",sampleRate:""}}getAudioInfo(){return this.audioInfo}updateAudioInfo(e){Ks(e.encTypeCode)&&(this.audioInfo.encType=Et[e.encTypeCode]),Ks(e.encType)&&(this.audioInfo.encType=e.encType),Ks(e.channels)&&(this.audioInfo.channels=e.channels),Ks(e.sampleRate)&&(this.audioInfo.sampleRate=e.sampleRate),Ks(this.audioInfo.sampleRate)&&Ks(this.audioInfo.channels)&&Ks(this.audioInfo.encType)&&!this.init&&(this.player.debug.log("Audio","audioInfo",JSON.stringify(this.audioInfo)),this.player.emit(st.audioInfo,this.audioInfo),this.init=!0)}get isPlaying(){return!0}get volume(){return Ta(this.$video.muted)?0:this.$video.volume}get isMute(){return 0===this.$video.volume||Ta(this.$video.muted)}mute(e){this.setVolume(e?0:this.player.lastVolume||.5)}setVolume(e){e=parseFloat(e),isNaN(e)||(e=bs(e,0,1),this.$video.muted&&(this.$video.muted=!1),Ls()&&(this.$video.muted=0===e),this.player.isAliyunRtc()&&this.player.aliyunRtcDecoder&&this.player.aliyunRtcDecoder.aliyunRtcRemoteStream&&(this.player.aliyunRtcDecoder.aliyunRtcRemoteStream.muted=0===e),this.$video.volume=e,this.player.emit(st.volumechange,this.player.volume))}clear(){}play(){}pause(){}resume(){}getEngineType(){return"audio"}isPlaybackRateSpeed(){return!1}getAudioBufferSize(){return 0}setRate(){}}class wn extends bn{constructor(e){super(e),this.delayTimeout=null,this.player.on(st.playbackPause,(e=>{this.listenPlaybackPause(e)})),this.player.debug.log("AudioPlaybackContext","init")}destroy(){this.delayTimeout&&(clearTimeout(this.delayTimeout),this.delayTimeout=null),super.destroy(),this.player.debug.log("AudioPlaybackLoader","destroy")}listenPlaybackPause(e){e?(this.pause(),this.player.playback.isPlaybackPauseClearCache&&this.clear()):this.resume()}initScriptNodeDelay(){const e=this.player._opt.playbackDelayTime;e>0?this.delayTimeout=setTimeout((()=>{this.initScriptNode()}),e):this.initScriptNode()}setRate(e){e!==this.defaultPlaybackRate&&this.rateProcessor&&(this.player.debug.log("AudioPlaybackContext","setRate",e),this.defaultPlaybackRate=e,this.updatePlaybackRate(e))}}class En extends bn{constructor(e){super(e),this.TAG_NAME="AudioPlayerLoader",this.isAudioPlayer=!0,this.player.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this.player.debug.log(this.TAG_NAME,"destroy")}play(e,t){ka(this.playing)||super.play(e,t)}pause(){this.player.debug.log(this.TAG_NAME,"pause"),this.playing=!1,this.clear()}resume(){this.player.debug.log(this.TAG_NAME,"resume"),this.playing=!0}}class Sn{constructor(e){return new(Sn.getLoaderFactory(e._opt))(e)}static getLoaderFactory(e){return e.playType===b?e.useMSE&&e.mseDecodeAudio?_n:wn:e.playType===v?En:e.isHls&&ka(e.supportHls265)||e.isWebrtc&&ka(e.isWebrtcH265)||e.useMSE&&e.mseDecodeAudio||e.isAliyunRtc?_n:bn}}class Tn extends t{constructor(e){super(),this.TAG_NAME="FetchWorkerLoader",this.player=e,this.playing=!1,this.fetchWorker=null,this.workerClearTimeout=null,this.workerUrl=null,this.abortController=new AbortController,this.streamRate=Ss((t=>{e.emit(st.kBps,(t/1024).toFixed(2))})),this.streamRateInterval=null,this._initFetchWorker(),e.debug.log(this.TAG_NAME,"init")}destroy(){this.off(),this.workerUrl&&(window.URL.revokeObjectURL(this.workerUrl),this.workerUrl=null),this.workerClearTimeout&&(clearTimeout(this.workerClearTimeout),this.workerClearTimeout=null),this.fetchWorker&&(this.fetchWorker.postMessage({cmd:Ze}),this.fetchWorker.terminate(),this.fetchWorker=null),this._stopStreamRateInterval(),this.streamRate=null,this.player.debug.log(this.TAG_NAME,"destroy")}_initFetchWorker(){const e=Ia(function(){function e(e){return!0===e||"true"===e}function t(e){return!1===e||"false"===e}const i="The user aborted a request",r="AbortError",s="AbortError",a="fetch",n="destroy",o="buffer",l="fetchError",d="fetchClose",h="fetchSuccess",c="idle",u="buffering",p="complete";let f=new class{constructor(){this._requestAbort=!1,this._status=c,this.writableStream=null,this.isChrome=!1,this.abortController=new AbortController}destroy(){this.abort(),this.writableStream&&t(this.writableStream.locked)&&this.writableStream.close().catch((e=>{})),this.writableStream=null,this._status=c}fetchStream(t,a={}){const n=Object.assign({signal:this.abortController.signal},{headers:a.headers||{}});fetch(t,n).then((t=>{if(this._requestAbort)return this._status=c,void t.body.cancel();if(!function(e){return e.ok&&e.status>=200&&e.status<=299}(t))return this.abort(),void postMessage({cmd:l,message:`fetch response status is ${t.status} and ok is ${t.ok}`});if(postMessage({cmd:h}),"undefined"!=typeof WritableStream)this.writableStream=new WritableStream({write:t=>{this.abortController&&this.abortController.signal&&this.abortController.signal.aborted||e(this._requestAbort)?this._status=p:(this._status=u,postMessage({cmd:o,buffer:t},[t.buffer]))},close:()=>{this._status=p,postMessage({cmd:d})},abort:e=>{if(this.abortController&&this.abortController.signal&&this.abortController.signal.aborted)return void(this._status=p);const t=e.toString();-1===t.indexOf(i)&&-1===t.indexOf(r)&&e.name!==s&&(this.abort(),postMessage({cmd:l,message:e.toString()}))}}),t.body.pipeTo(this.writableStream);else{const a=t.body.getReader(),n=()=>{a.read().then((({done:t,value:i})=>{if(t)return this._status=p,void postMessage({cmd:d});this.abortController&&this.abortController.signal&&this.abortController.signal.aborted||e(this._requestAbort)?this._status=p:(this._status=u,postMessage({cmd:o,buffer:i},[i.buffer]),n())})).catch((e=>{if(this.abortController&&this.abortController.signal&&this.abortController.signal.aborted)return void(this._status=p);const t=e.toString();-1===t.indexOf(i)&&-1===t.indexOf(r)&&e.name!==s&&(this.abort(),postMessage({cmd:l,message:e.toString()}))}))};n()}})).catch((e=>{this.abortController&&this.abortController.signal&&this.abortController.signal.aborted||"AbortError"!==e.name&&(this.abort(),postMessage({cmd:l,message:e.toString()}))}))}abort(){if(this._requestAbort=!0,this._status!==u||t(f.isChrome)){if(this.abortController){try{this.abortController.abort()}catch(e){}this.abortController=null}}else this.abortController=null}};self.onmessage=t=>{const i=t.data;switch(i.cmd){case a:f.isChrome=e(i.isChrome),f.fetchStream(i.url,JSON.parse(i.options));break;case n:f.destroy(),f=null}}}.toString()),t=new Blob([e],{type:"text/javascript"});let i=URL.createObjectURL(t);const r=new Worker(i);this.workerUrl=i,this.workerClearTimeout=setTimeout((()=>{window.URL.revokeObjectURL(this.workerUrl),this.workerUrl=null,this.workerClearTimeout=null}),re),r.onmessage=e=>{const{demux:t}=this.player,i=e.data;switch(i.cmd){case et:this.streamRate&&this.streamRate(i.buffer.byteLength),t.dispatch(i.buffer);break;case rt:this.emit(st.streamSuccess),this._startStreamRateInterval();break;case it:t.close(),this.emit(st.streamEnd,"fetch done");break;case tt:t.close(),this.emit(lt.fetchError,i.message)}},this.fetchWorker=r}_startStreamRateInterval(){this._stopStreamRateInterval(),this.streamRateInterval=setInterval((()=>{this.streamRate&&this.streamRate(0)}),1e3)}_stopStreamRateInterval(){this.streamRateInterval&&(clearInterval(this.streamRateInterval),this.streamRateInterval=null)}fetchStream(e,t={}){this.player._times.streamStart=vs(),this.fetchWorker.postMessage({cmd:Je,url:e,isChrome:oa(),options:JSON.stringify(t)})}getStreamType(){return h}}class kn extends t{constructor(e){super(),this.player=e,this.socket=null,this.socketStatus=dt,this.wsUrl=null,this.requestAbort=!1,this.socketDestroyFnList=[],this.streamRate=Ss((t=>{e.emit(st.kBps,(t/1024).toFixed(2))})),this.streamRateInterval=null,e.debug.log("WebsocketStream","init")}destroy(){this._closeWebSocket(),this.stopStreamRateInterval(),this.wsUrl=null,this.off(),this.player.debug.log("WebsocketStream","destroy")}startStreamRateInterval(){this.stopStreamRateInterval(),this.streamRateInterval=setInterval((()=>{this.streamRate&&this.streamRate(0)}),1e3)}stopStreamRateInterval(){this.streamRateInterval&&(clearInterval(this.streamRateInterval),this.streamRateInterval=null)}_createWebSocket(){const e=this.player,{debug:t,events:{proxy:i},demux:r}=e;this.socket=new WebSocket(this.wsUrl),this.socket.binaryType="arraybuffer";const s=i(this.socket,"open",(()=>{t.log("WebsocketStream","socket open"),this.socketStatus=ht,this.emit(st.streamSuccess),this.player.emit(st.websocketOpen),this.startStreamRateInterval()})),a=i(this.socket,"message",(e=>{this.streamRate&&this.streamRate(e.data.byteLength),this._handleMessage(e.data)})),n=i(this.socket,"close",(e=>{if(t.log("WebsocketStream",`socket close and code is ${e.code}`),1006===e.code&&t.error("WebsocketStream",`socket close abnormally and code is ${e.code}`),Ta(this.requestAbort))return this.requestAbort=!1,void t.log("WebsocketStream","socket close and requestAbort is true");r.close(),this.socketStatus=ct,this.player.emit(st.websocketClose,e.code),this.emit(st.streamEnd,e.code)})),o=i(this.socket,"error",(e=>{t.error("WebsocketStream","socket error",e),this.socketStatus=ut,this.emit(lt.websocketError,e),r.close(),t.log("WebsocketStream","socket error:",e.isTrusted?"websocket user aborted":"websocket error")}));this.socketDestroyFnList.push(s,a,n,o)}_closeWebSocket(){this.socketDestroyFnList.forEach((e=>e())),!this.socket||0!==this.socket.readyState&&1!==this.socket.readyState?this.socket&&this.player.debug.log("WebsocketStream",`_closeWebSocket() socket is null or socket status is ${this.socket&&this.socket.readyState}`):(this.requestAbort=!0,this.socket.close(1e3,"Client disconnecting")),this.socket=null,this.socketStatus=dt,this.streamRate=null}_handleMessage(e){const{demux:t}=this.player;t?t.dispatch(e):this.player.debug.warn("WebsocketStream","websocket handle message demux is null")}fetchStream(e,t){this.player._times.streamStart=vs(),this.wsUrl=e,this._createWebSocket()}sendMessage(e){this.socket?this.socketStatus===ht?this.socket.send(e):this.player.debug.error("WebsocketStream",`websocket send message error and socket status is ${this.socketStatus}`):this.player.debug.error("WebsocketStream","websocket send message socket is null")}resetFetchStream(){this._closeWebSocket(),this._createWebSocket()}getStreamType(){return u}}class Cn extends t{constructor(e){super(),this.player=e,e.debug.log("HlsStream","init")}destroy(){this.off(),this.player.debug.log("HlsStream","destroy")}fetchStream(e){const{hlsDecoder:t,debug:i}=this.player;this.player._times.streamStart=vs(),t.loadSource(e).then((()=>{this.player.debug.log("HlsStream","loadSource success"),this.emit(st.streamSuccess)})).catch((e=>{this.emit(lt.hlsError,e)}))}getStreamType(){return c}}class Dn extends t{constructor(e){super(),this.player=e,this.webrctUrl=null,e.debug.log("WebrtcStream","init")}destroy(){this.webrctUrl=null,this.off(),this.player.debug.log("WebrtcStream","destroy")}fetchStream(e){const{webrtc:t,debug:i}=this.player;this.player._times.streamStart=vs(),this.webrctUrl=e.replace("webrtc:",window.location.protocol),t.loadSource(this.webrctUrl).then((()=>{this.player.debug.log("WebrtcStream","loadSource success"),this.emit(st.streamSuccess)})).catch((e=>{this.player.debug.error("WebrtcStream","loadSource error",e),this.emit(lt.webrtcError,e)}))}getStreamType(){return p}}class Rn extends t{constructor(e){super(),this.player=e,e.debug.log("wsRtcStream","init")}destroy(){this.off(),this.player.debug.log("wsRtcStream","destroy")}fetchStream(e){const{wsRtcDecoder:t,debug:i}=this.player;this.player._times.streamStart=vs(),t.loadSource(e).then((()=>{this.player.debug.log("wsRtcStream","loadSource success"),this.emit(st.streamSuccess)})).catch((e=>{this.emit(lt.webrtcError,e)}))}getStreamType(){return g}}class xn extends t{constructor(e){super(),this.player=e,this.transport=null,this.wtUrl=null,this.streamRate=Ss((t=>{e.emit(st.kBps,(t/1024).toFixed(2))})),this.streamRateInterval=null,e.debug.log("WebTransportLoader","init")}destroy(){this.abort(),this.off(),this.player.debug.log("WebTransportLoader","destroy")}startStreamRateInterval(){this.stopStreamRateInterval(),this.streamRateInterval=setInterval((()=>{this.streamRate&&this.streamRate(0)}),1e3)}stopStreamRateInterval(){this.streamRateInterval&&(clearInterval(this.streamRateInterval),this.streamRateInterval=null)}_createWebTransport(){const e=this.player,{debug:t,events:{proxy:i},demux:r}=e;try{this.transport=new WebTransport(this.wtUrl),this.transport.ready.then((()=>{this.emit(st.streamSuccess),this.startStreamRateInterval(),this.transport.createBidirectionalStream().then((e=>{e.readable.pipeTo(new WritableStream(r.input))}))})).catch((e=>{this.player.debug.warn("WebTransportLoader","_createWebTransport-ready",e)}))}catch(e){this.player.debug.warn("WebTransportLoader","_createWebTransport",e)}}fetchStream(e){this.player._times.streamStart=vs(),this.wtUrl=e.replace(/^wt:/,"https:"),this._createWebTransport()}abort(){if(this.transport)try{this.transport.close(),this.transport=null}catch(e){this.transport=null}}getStreamType(){return f}}class Ln extends t{constructor(e){super(),this.player=e,this.workUrl=null,e.debug.log("WorkerStream","init")}destroy(){this.workUrl=null,this.off(),this.player.debug.log("WorkerStream","destroy")}sendMessage(e){this.player.decoderWorker.workerSendMessage(e)}fetchStream(e,t={}){this.workUrl=e,this.player._times.streamStart=vs(),this.player.decoderWorker.workerFetchStream(e)}getStreamType(){const e=this.player._opt.protocol;return y+" "+(e===r?h:u)}}class In extends t{constructor(e){super(),this.TAG_NAME="AliyunRtcLoader",this.player=e,e.debug.log(this.TAG_NAME,"init")}destroy(){this.off(),this.player.debug.log(this.TAG_NAME,"destroy")}fetchStream(e){const{aliyunRtcDecoder:t}=this.player;this.player._times.streamStart=vs(),t.loadSource(e).then((()=>{this.player.debug.log(this.TAG_NAME,"loadSource success"),this.emit(st.streamSuccess)})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource error",e),this.emit(lt.aliyunRtcError,e)}))}getStreamType(){return m}}class Pn{constructor(e){return new(Pn.getLoaderFactory(e._opt))(e)}static getLoaderFactory(e){const{protocol:t,useWasm:d,playType:h,useWCS:c,useMSE:u,demuxUseWorker:p}=e;return t===r?h===v?Ln:h===A?d&&!pa(e)||p?Ln:Tn:c||u?p?Ln:Tn:Ln:t===i?h===v?Ln:h===A?d&&!pa(e)||p?Ln:kn:c||u?p?Ln:kn:Ln:t===l?Rn:t===s?Cn:t===a?Dn:t===n?xn:t===o?In:void 0}}var Bn=Zr((function(e){function t(e,s){if(!e)throw"First parameter is required.";s=new i(e,s=s||{type:"video"});var a=this;function n(t){t&&(s.initCallback=function(){t(),t=s.initCallback=null});var i=new r(e,s);(p=new i(e,s)).record(),u("recording"),s.disableLogs||console.log("Initialized recorderType:",p.constructor.name,"for output-type:",s.type)}function o(e){if(e=e||function(){},p){if("paused"===a.state)return a.resumeRecording(),void setTimeout((function(){o(e)}),1);"recording"===a.state||s.disableLogs||console.warn('Recording state should be: "recording", however current state is: ',a.state),s.disableLogs||console.log("Stopped recording "+s.type+" stream."),"gif"!==s.type?p.stop(t):(p.stop(),t()),u("stopped")}else y();function t(t){if(p){Object.keys(p).forEach((function(e){"function"!=typeof p[e]&&(a[e]=p[e])}));var i=p.blob;if(!i){if(!t)throw"Recording failed.";p.blob=i=t}if(i&&!s.disableLogs&&console.log(i.type,"->",g(i.size)),e){var r;try{r=h.createObjectURL(i)}catch(e){}"function"==typeof e.call?e.call(a,r):e(r)}s.autoWriteToDisk&&d((function(e){var t={};t[s.type+"Blob"]=e,R.Store(t)}))}else"function"==typeof e.call?e.call(a,""):e("")}}function l(e){postMessage((new FileReaderSync).readAsDataURL(e))}function d(e,t){if(!e)throw"Pass a callback function over getDataURL.";var i=t?t.blob:(p||{}).blob;if(!i)return s.disableLogs||console.warn("Blob encoder did not finish its job yet."),void setTimeout((function(){d(e,t)}),1e3);if("undefined"==typeof Worker||navigator.mozGetUserMedia){var r=new FileReader;r.readAsDataURL(i),r.onload=function(t){e(t.target.result)}}else{var a=function(e){try{var t=h.createObjectURL(new Blob([e.toString(),"this.onmessage = function (eee) {"+e.name+"(eee.data);}"],{type:"application/javascript"})),i=new Worker(t);return h.revokeObjectURL(t),i}catch(e){}}(l);a.onmessage=function(t){e(t.data)},a.postMessage(i)}}function c(e){e=e||0,"paused"!==a.state?"stopped"!==a.state&&(e>=a.recordingDuration?o(a.onRecordingStopped):(e+=1e3,setTimeout((function(){c(e)}),1e3))):setTimeout((function(){c(e)}),1e3)}function u(e){a&&(a.state=e,"function"==typeof a.onStateChanged.call?a.onStateChanged.call(a,e):a.onStateChanged(e))}var p,f='It seems that recorder is destroyed or "startRecording" is not invoked for '+s.type+" recorder.";function y(){!0!==s.disableLogs&&console.warn(f)}var m={startRecording:function(t){return s.disableLogs||console.log("RecordRTC version: ",a.version),t&&(s=new i(e,t)),s.disableLogs||console.log("started recording "+s.type+" stream."),p?(p.clearRecordedData(),p.record(),u("recording"),a.recordingDuration&&c(),a):(n((function(){a.recordingDuration&&c()})),a)},stopRecording:o,pauseRecording:function(){p?"recording"===a.state?(u("paused"),p.pause(),s.disableLogs||console.log("Paused recording.")):s.disableLogs||console.warn("Unable to pause the recording. Recording state: ",a.state):y()},resumeRecording:function(){p?"paused"===a.state?(u("recording"),p.resume(),s.disableLogs||console.log("Resumed recording.")):s.disableLogs||console.warn("Unable to resume the recording. Recording state: ",a.state):y()},initRecorder:n,setRecordingDuration:function(e,t){if(void 0===e)throw"recordingDuration is required.";if("number"!=typeof e)throw"recordingDuration must be a number.";return a.recordingDuration=e,a.onRecordingStopped=t||function(){},{onRecordingStopped:function(e){a.onRecordingStopped=e}}},clearRecordedData:function(){p?(p.clearRecordedData(),s.disableLogs||console.log("Cleared old recorded data.")):y()},getBlob:function(){if(p)return p.blob;y()},getDataURL:d,toURL:function(){if(p)return h.createObjectURL(p.blob);y()},getInternalRecorder:function(){return p},save:function(e){p?A(p.blob,e):y()},getFromDisk:function(e){p?t.getFromDisk(s.type,e):y()},setAdvertisementArray:function(e){s.advertisement=[];for(var t=e.length,i=0;i<t;i++)s.advertisement.push({duration:i,image:e[i]})},blob:null,bufferSize:0,sampleRate:0,buffer:null,reset:function(){"recording"!==a.state||s.disableLogs||console.warn("Stop an active recorder."),p&&"function"==typeof p.clearRecordedData&&p.clearRecordedData(),p=null,u("inactive"),a.blob=null},onStateChanged:function(e){s.disableLogs||console.log("Recorder state changed:",e)},state:"inactive",getState:function(){return a.state},destroy:function(){var e=s.disableLogs;s={disableLogs:!0},a.reset(),u("destroyed"),m=a=null,w.AudioContextConstructor&&(w.AudioContextConstructor.close(),w.AudioContextConstructor=null),s.disableLogs=e,s.disableLogs||console.log("RecordRTC is destroyed.")},version:"5.6.2"};if(!this)return a=m,m;for(var v in m)this[v]=m[v];return a=this,m}function i(e,t){return t.recorderType||t.type||(t.audio&&t.video?t.type="video":t.audio&&!t.video&&(t.type="audio")),t.recorderType&&!t.type&&(t.recorderType===C||t.recorderType===k||void 0!==P&&t.recorderType===P?t.type="video":t.recorderType===x?t.type="gif":t.recorderType===T?t.type="audio":t.recorderType===S&&(b(e,"audio").length&&b(e,"video").length||!b(e,"audio").length&&b(e,"video").length?t.type="video":b(e,"audio").length&&!b(e,"video").length&&(t.type="audio"))),void 0!==S&&"undefined"!=typeof MediaRecorder&&"requestData"in MediaRecorder.prototype&&(t.mimeType||(t.mimeType="video/webm"),t.type||(t.type=t.mimeType.split("/")[0]),t.bitsPerSecond),t.type||(t.mimeType&&(t.type=t.mimeType.split("/")[0]),t.type||(t.type="audio")),t}function r(e,t){var i;return(f||c||u)&&(i=T),"undefined"!=typeof MediaRecorder&&"requestData"in MediaRecorder.prototype&&!f&&(i=S),"video"===t.type&&(f||u)&&(i=C,void 0!==P&&"undefined"!=typeof ReadableStream&&(i=P)),"gif"===t.type&&(i=x),"canvas"===t.type&&(i=k),E()&&i!==k&&i!==x&&"undefined"!=typeof MediaRecorder&&"requestData"in MediaRecorder.prototype&&(b(e,"video").length||b(e,"audio").length)&&("audio"===t.type?"function"==typeof MediaRecorder.isTypeSupported&&MediaRecorder.isTypeSupported("audio/webm")&&(i=S):"function"==typeof MediaRecorder.isTypeSupported&&MediaRecorder.isTypeSupported("video/webm")&&(i=S)),e instanceof Array&&e.length&&(i=I),t.recorderType&&(i=t.recorderType),!t.disableLogs&&i&&i.name&&console.log("Using recorderType:",i.name||i.constructor.name),!i&&y&&(i=S),i}function s(e){this.addStream=function(t){t&&(e=t)},this.mediaType={audio:!0,video:!0},this.startRecording=function(){var i,r=this.mediaType,s=this.mimeType||{audio:null,video:null,gif:null};if("function"!=typeof r.audio&&E()&&!b(e,"audio").length&&(r.audio=!1),"function"!=typeof r.video&&E()&&!b(e,"video").length&&(r.video=!1),"function"!=typeof r.gif&&E()&&!b(e,"video").length&&(r.gif=!1),!r.audio&&!r.video&&!r.gif)throw"MediaStream must have either audio or video tracks.";if(r.audio&&(i=null,"function"==typeof r.audio&&(i=r.audio),this.audioRecorder=new t(e,{type:"audio",bufferSize:this.bufferSize,sampleRate:this.sampleRate,numberOfAudioChannels:this.numberOfAudioChannels||2,disableLogs:this.disableLogs,recorderType:i,mimeType:s.audio,timeSlice:this.timeSlice,onTimeStamp:this.onTimeStamp}),r.video||this.audioRecorder.startRecording()),r.video){i=null,"function"==typeof r.video&&(i=r.video);var a=e;if(E()&&r.audio&&"function"==typeof r.audio){var n=b(e,"video")[0];p?((a=new m).addTrack(n),i&&i===C&&(i=S)):(a=new m).addTrack(n)}this.videoRecorder=new t(a,{type:"video",video:this.video,canvas:this.canvas,frameInterval:this.frameInterval||10,disableLogs:this.disableLogs,recorderType:i,mimeType:s.video,timeSlice:this.timeSlice,onTimeStamp:this.onTimeStamp,workerPath:this.workerPath,webAssemblyPath:this.webAssemblyPath,frameRate:this.frameRate,bitrate:this.bitrate}),r.audio||this.videoRecorder.startRecording()}if(r.audio&&r.video){var o=this,l=!0===E();(r.audio instanceof T&&r.video||!0!==r.audio&&!0!==r.video&&r.audio!==r.video)&&(l=!1),!0===l?(o.audioRecorder=null,o.videoRecorder.startRecording()):o.videoRecorder.initRecorder((function(){o.audioRecorder.initRecorder((function(){o.videoRecorder.startRecording(),o.audioRecorder.startRecording()}))}))}r.gif&&(i=null,"function"==typeof r.gif&&(i=r.gif),this.gifRecorder=new t(e,{type:"gif",frameRate:this.frameRate||200,quality:this.quality||10,disableLogs:this.disableLogs,recorderType:i,mimeType:s.gif}),this.gifRecorder.startRecording())},this.stopRecording=function(e){e=e||function(){},this.audioRecorder&&this.audioRecorder.stopRecording((function(t){e(t,"audio")})),this.videoRecorder&&this.videoRecorder.stopRecording((function(t){e(t,"video")})),this.gifRecorder&&this.gifRecorder.stopRecording((function(t){e(t,"gif")}))},this.pauseRecording=function(){this.audioRecorder&&this.audioRecorder.pauseRecording(),this.videoRecorder&&this.videoRecorder.pauseRecording(),this.gifRecorder&&this.gifRecorder.pauseRecording()},this.resumeRecording=function(){this.audioRecorder&&this.audioRecorder.resumeRecording(),this.videoRecorder&&this.videoRecorder.resumeRecording(),this.gifRecorder&&this.gifRecorder.resumeRecording()},this.getBlob=function(e){var t={};return this.audioRecorder&&(t.audio=this.audioRecorder.getBlob()),this.videoRecorder&&(t.video=this.videoRecorder.getBlob()),this.gifRecorder&&(t.gif=this.gifRecorder.getBlob()),e&&e(t),t},this.destroy=function(){this.audioRecorder&&(this.audioRecorder.destroy(),this.audioRecorder=null),this.videoRecorder&&(this.videoRecorder.destroy(),this.videoRecorder=null),this.gifRecorder&&(this.gifRecorder.destroy(),this.gifRecorder=null)},this.getDataURL=function(e){function t(e,t){if("undefined"!=typeof Worker){var i=function(e){var t,i=h.createObjectURL(new Blob([e.toString(),"this.onmessage = function (eee) {"+e.name+"(eee.data);}"],{type:"application/javascript"})),r=new Worker(i);if(void 0!==h)t=h;else{if("undefined"==typeof webkitURL)throw"Neither URL nor webkitURL detected.";t=webkitURL}return t.revokeObjectURL(i),r}((function(e){postMessage((new FileReaderSync).readAsDataURL(e))}));i.onmessage=function(e){t(e.data)},i.postMessage(e)}else{var r=new FileReader;r.readAsDataURL(e),r.onload=function(e){t(e.target.result)}}}this.getBlob((function(i){i.audio&&i.video?t(i.audio,(function(r){t(i.video,(function(t){e({audio:r,video:t})}))})):i.audio?t(i.audio,(function(t){e({audio:t})})):i.video&&t(i.video,(function(t){e({video:t})}))}))},this.writeToDisk=function(){t.writeToDisk({audio:this.audioRecorder,video:this.videoRecorder,gif:this.gifRecorder})},this.save=function(e){(e=e||{audio:!0,video:!0,gif:!0}).audio&&this.audioRecorder&&this.audioRecorder.save("string"==typeof e.audio?e.audio:""),e.video&&this.videoRecorder&&this.videoRecorder.save("string"==typeof e.video?e.video:""),e.gif&&this.gifRecorder&&this.gifRecorder.save("string"==typeof e.gif?e.gif:"")}}t.version="5.6.2",e.exports=t,t.getFromDisk=function(e,t){if(!t)throw"callback is mandatory.";console.log("Getting recorded "+("all"===e?"blobs":e+" blob ")+" from disk!"),R.Fetch((function(i,r){"all"!==e&&r===e+"Blob"&&t&&t(i),"all"===e&&t&&t(i,r.replace("Blob",""))}))},t.writeToDisk=function(e){console.log("Writing recorded blob(s) to disk!"),(e=e||{}).audio&&e.video&&e.gif?e.audio.getDataURL((function(t){e.video.getDataURL((function(i){e.gif.getDataURL((function(e){R.Store({audioBlob:t,videoBlob:i,gifBlob:e})}))}))})):e.audio&&e.video?e.audio.getDataURL((function(t){e.video.getDataURL((function(e){R.Store({audioBlob:t,videoBlob:e})}))})):e.audio&&e.gif?e.audio.getDataURL((function(t){e.gif.getDataURL((function(e){R.Store({audioBlob:t,gifBlob:e})}))})):e.video&&e.gif?e.video.getDataURL((function(t){e.gif.getDataURL((function(e){R.Store({videoBlob:t,gifBlob:e})}))})):e.audio?e.audio.getDataURL((function(e){R.Store({audioBlob:e})})):e.video?e.video.getDataURL((function(e){R.Store({videoBlob:e})})):e.gif&&e.gif.getDataURL((function(e){R.Store({gifBlob:e})}))},s.getFromDisk=t.getFromDisk,s.writeToDisk=t.writeToDisk,void 0!==t&&(t.MRecordRTC=s);var a;(a=void 0!==Jr?Jr:null)&&"undefined"==typeof window&&void 0!==Jr&&(Jr.navigator={userAgent:"Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45",getUserMedia:function(){}},Jr.console||(Jr.console={}),void 0!==Jr.console.log&&void 0!==Jr.console.error||(Jr.console.error=Jr.console.log=Jr.console.log||function(){console.log(arguments)}),"undefined"==typeof document&&(a.document={documentElement:{appendChild:function(){return""}}},document.createElement=document.captureStream=document.mozCaptureStream=function(){var e={getContext:function(){return e},play:function(){},pause:function(){},drawImage:function(){},toDataURL:function(){return""},style:{}};return e},a.HTMLVideoElement=function(){}),"undefined"==typeof location&&(a.location={protocol:"file:",href:"",hash:""}),"undefined"==typeof screen&&(a.screen={width:0,height:0}),void 0===h&&(a.URL={createObjectURL:function(){return""},revokeObjectURL:function(){return""}}),a.window=Jr);var n=window.requestAnimationFrame;if(void 0===n)if("undefined"!=typeof webkitRequestAnimationFrame)n=webkitRequestAnimationFrame;else if("undefined"!=typeof mozRequestAnimationFrame)n=mozRequestAnimationFrame;else if("undefined"!=typeof msRequestAnimationFrame)n=msRequestAnimationFrame;else if(void 0===n){var o=0;n=function(e,t){var i=(new Date).getTime(),r=Math.max(0,16-(i-o)),s=setTimeout((function(){e(i+r)}),r);return o=i+r,s}}var l=window.cancelAnimationFrame;void 0===l&&("undefined"!=typeof webkitCancelAnimationFrame?l=webkitCancelAnimationFrame:"undefined"!=typeof mozCancelAnimationFrame?l=mozCancelAnimationFrame:"undefined"!=typeof msCancelAnimationFrame?l=msCancelAnimationFrame:void 0===l&&(l=function(e){clearTimeout(e)}));var d=window.AudioContext;void 0===d&&("undefined"!=typeof webkitAudioContext&&(d=webkitAudioContext),"undefined"!=typeof mozAudioContext&&(d=mozAudioContext));var h=window.URL;void 0===h&&"undefined"!=typeof webkitURL&&(h=webkitURL),"undefined"!=typeof navigator&&void 0===navigator.getUserMedia&&(void 0!==navigator.webkitGetUserMedia&&(navigator.getUserMedia=navigator.webkitGetUserMedia),void 0!==navigator.mozGetUserMedia&&(navigator.getUserMedia=navigator.mozGetUserMedia));var c=!(-1===navigator.userAgent.indexOf("Edge")||!navigator.msSaveBlob&&!navigator.msSaveOrOpenBlob),u=!!window.opera||-1!==navigator.userAgent.indexOf("OPR/"),p=navigator.userAgent.toLowerCase().indexOf("firefox")>-1&&"netscape"in window&&/ rv:/.test(navigator.userAgent),f=!u&&!c&&!!navigator.webkitGetUserMedia||v()||-1!==navigator.userAgent.toLowerCase().indexOf("chrome/"),y=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);y&&!f&&-1!==navigator.userAgent.indexOf("CriOS")&&(y=!1,f=!0);var m=window.MediaStream;function g(e){if(0===e)return"0 Bytes";var t=parseInt(Math.floor(Math.log(e)/Math.log(1e3)),10);return(e/Math.pow(1e3,t)).toPrecision(3)+" "+["Bytes","KB","MB","GB","TB"][t]}function A(e,t){if(!e)throw"Blob object is required.";if(!e.type)try{e.type="video/webm"}catch(e){}var i=(e.type||"video/webm").split("/")[1];if(-1!==i.indexOf(";")&&(i=i.split(";")[0]),t&&-1!==t.indexOf(".")){var r=t.split(".");t=r[0],i=r[1]}var s=(t||Math.round(9999999999*Math.random())+888888888)+"."+i;if(void 0!==navigator.msSaveOrOpenBlob)return navigator.msSaveOrOpenBlob(e,s);if(void 0!==navigator.msSaveBlob)return navigator.msSaveBlob(e,s);var a=document.createElement("a");a.href=h.createObjectURL(e),a.download=s,a.style="display:none;opacity:0;color:transparent;",(document.body||document.documentElement).appendChild(a),"function"==typeof a.click?a.click():(a.target="_blank",a.dispatchEvent(new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0}))),h.revokeObjectURL(a.href)}function v(){return"undefined"!=typeof window&&"object"==typeof window.process&&"renderer"===window.process.type||(!("undefined"==typeof process||"object"!=typeof process.versions||!process.versions.electron)||"object"==typeof navigator&&"string"==typeof navigator.userAgent&&navigator.userAgent.indexOf("Electron")>=0)}function b(e,t){return e&&e.getTracks?e.getTracks().filter((function(e){return e.kind===(t||"audio")})):[]}function _(e,t){"srcObject"in t?t.srcObject=e:"mozSrcObject"in t?t.mozSrcObject=e:t.srcObject=e}void 0===m&&"undefined"!=typeof webkitMediaStream&&(m=webkitMediaStream),void 0!==m&&void 0===m.prototype.stop&&(m.prototype.stop=function(){this.getTracks().forEach((function(e){e.stop()}))}),void 0!==t&&(t.invokeSaveAsDialog=A,t.getTracks=b,t.getSeekableBlob=function(e,t){if("undefined"==typeof EBML)throw new Error("Please link: https://www.webrtc-experiment.com/EBML.js");var i=new EBML.Reader,r=new EBML.Decoder,s=EBML.tools,a=new FileReader;a.onload=function(e){r.decode(this.result).forEach((function(e){i.read(e)})),i.stop();var a=s.makeMetadataSeekable(i.metadatas,i.duration,i.cues),n=this.result.slice(i.metadataSize),o=new Blob([a,n],{type:"video/webm"});t(o)},a.readAsArrayBuffer(e)},t.bytesToSize=g,t.isElectron=v);var w={};function E(){if(p||y||c)return!0;var e,t,i=navigator.userAgent,r=""+parseFloat(navigator.appVersion),s=parseInt(navigator.appVersion,10);return(f||u)&&(e=i.indexOf("Chrome"),r=i.substring(e+7)),-1!==(t=r.indexOf(";"))&&(r=r.substring(0,t)),-1!==(t=r.indexOf(" "))&&(r=r.substring(0,t)),s=parseInt(""+r,10),isNaN(s)&&(r=""+parseFloat(navigator.appVersion),s=parseInt(navigator.appVersion,10)),s>=49}function S(e,t){var i=this;if(void 0===e)throw'First argument "MediaStream" is required.';if("undefined"==typeof MediaRecorder)throw"Your browser does not support the Media Recorder API. Please try other modules e.g. WhammyRecorder or StereoAudioRecorder.";if("audio"===(t=t||{mimeType:"video/webm"}).type){var r;if(b(e,"video").length&&b(e,"audio").length)navigator.mozGetUserMedia?(r=new m).addTrack(b(e,"audio")[0]):r=new m(b(e,"audio")),e=r;t.mimeType&&-1!==t.mimeType.toString().toLowerCase().indexOf("audio")||(t.mimeType=f?"audio/webm":"audio/ogg"),t.mimeType&&"audio/ogg"!==t.mimeType.toString().toLowerCase()&&navigator.mozGetUserMedia&&(t.mimeType="audio/ogg")}var s,a=[];function n(){i.timestamps.push((new Date).getTime()),"function"==typeof t.onTimeStamp&&t.onTimeStamp(i.timestamps[i.timestamps.length-1],i.timestamps)}function o(e){return s&&s.mimeType?s.mimeType:e.mimeType||"video/webm"}function l(){a=[],s=null,i.timestamps=[]}this.getArrayOfBlobs=function(){return a},this.record=function(){i.blob=null,i.clearRecordedData(),i.timestamps=[],d=[],a=[];var r=t;t.disableLogs||console.log("Passing following config over MediaRecorder API.",r),s&&(s=null),f&&!E()&&(r="video/vp8"),"function"==typeof MediaRecorder.isTypeSupported&&r.mimeType&&(MediaRecorder.isTypeSupported(r.mimeType)||(t.disableLogs||console.warn("MediaRecorder API seems unable to record mimeType:",r.mimeType),r.mimeType="audio"===t.type?"audio/webm":"video/webm"));try{s=new MediaRecorder(e,r),t.mimeType=r.mimeType}catch(t){s=new MediaRecorder(e)}r.mimeType&&!MediaRecorder.isTypeSupported&&"canRecordMimeType"in s&&!1===s.canRecordMimeType(r.mimeType)&&(t.disableLogs||console.warn("MediaRecorder API seems unable to record mimeType:",r.mimeType)),s.ondataavailable=function(e){if(e.data&&d.push("ondataavailable: "+g(e.data.size)),"number"!=typeof t.timeSlice)!e.data||!e.data.size||e.data.size<100||i.blob?i.recordingCallback&&(i.recordingCallback(new Blob([],{type:o(r)})),i.recordingCallback=null):(i.blob=t.getNativeBlob?e.data:new Blob([e.data],{type:o(r)}),i.recordingCallback&&(i.recordingCallback(i.blob),i.recordingCallback=null));else if(e.data&&e.data.size&&(a.push(e.data),n(),"function"==typeof t.ondataavailable)){var s=t.getNativeBlob?e.data:new Blob([e.data],{type:o(r)});t.ondataavailable(s)}},s.onstart=function(){d.push("started")},s.onpause=function(){d.push("paused")},s.onresume=function(){d.push("resumed")},s.onstop=function(){d.push("stopped")},s.onerror=function(e){e&&(e.name||(e.name="UnknownError"),d.push("error: "+e),t.disableLogs||(-1!==e.name.toString().toLowerCase().indexOf("invalidstate")?console.error("The MediaRecorder is not in a state in which the proposed operation is allowed to be executed.",e):-1!==e.name.toString().toLowerCase().indexOf("notsupported")?console.error("MIME type (",r.mimeType,") is not supported.",e):-1!==e.name.toString().toLowerCase().indexOf("security")?console.error("MediaRecorder security error",e):"OutOfMemory"===e.name?console.error("The UA has exhaused the available memory. User agents SHOULD provide as much additional information as possible in the message attribute.",e):"IllegalStreamModification"===e.name?console.error("A modification to the stream has occurred that makes it impossible to continue recording. An example would be the addition of a Track while recording is occurring. User agents SHOULD provide as much additional information as possible in the message attribute.",e):"OtherRecordingError"===e.name?console.error("Used for an fatal error other than those listed above. User agents SHOULD provide as much additional information as possible in the message attribute.",e):"GenericError"===e.name?console.error("The UA cannot provide the codec or recording option that has been requested.",e):console.error("MediaRecorder Error",e)),function(e){if(!i.manuallyStopped&&s&&"inactive"===s.state)return delete t.timeslice,void s.start(6e5);setTimeout(void 0,1e3)}(),"inactive"!==s.state&&"stopped"!==s.state&&s.stop())},"number"==typeof t.timeSlice?(n(),s.start(t.timeSlice)):s.start(36e5),t.initCallback&&t.initCallback()},this.timestamps=[],this.stop=function(e){e=e||function(){},i.manuallyStopped=!0,s&&(this.recordingCallback=e,"recording"===s.state&&s.stop(),"number"==typeof t.timeSlice&&setTimeout((function(){i.blob=new Blob(a,{type:o(t)}),i.recordingCallback(i.blob)}),100))},this.pause=function(){s&&"recording"===s.state&&s.pause()},this.resume=function(){s&&"paused"===s.state&&s.resume()},this.clearRecordedData=function(){s&&"recording"===s.state&&i.stop(l),l()},this.getInternalRecorder=function(){return s},this.blob=null,this.getState=function(){return s&&s.state||"inactive"};var d=[];this.getAllStates=function(){return d},void 0===t.checkForInactiveTracks&&(t.checkForInactiveTracks=!1);i=this;!function r(){if(s&&!1!==t.checkForInactiveTracks)return!1===function(){if("active"in e){if(!e.active)return!1}else if("ended"in e&&e.ended)return!1;return!0}()?(t.disableLogs||console.log("MediaStream seems stopped."),void i.stop()):void setTimeout(r,1e3)}(),this.name="MediaStreamRecorder",this.toString=function(){return this.name}}function T(e,i){if(!b(e,"audio").length)throw"Your stream has no audio tracks.";var r,s=this,a=[],n=[],o=!1,l=0,d=2,c=(i=i||{}).desiredSampRate;function u(){if(!1===i.checkForInactiveTracks)return!0;if("active"in e){if(!e.active)return!1}else if("ended"in e&&e.ended)return!1;return!0}function p(e,t){function i(e,t){var i,r=e.numberOfAudioChannels,s=e.leftBuffers.slice(0),a=e.rightBuffers.slice(0),n=e.sampleRate,o=e.internalInterleavedLength,l=e.desiredSampRate;function d(e,t,i){var r=Math.round(e.length*(t/i)),s=[],a=Number((e.length-1)/(r-1));s[0]=e[0];for(var n=1;n<r-1;n++){var o=n*a,l=Number(Math.floor(o)).toFixed(),d=Number(Math.ceil(o)).toFixed(),c=o-l;s[n]=h(e[l],e[d],c)}return s[r-1]=e[e.length-1],s}function h(e,t,i){return e+(t-e)*i}function c(e,t){for(var i=new Float64Array(t),r=0,s=e.length,a=0;a<s;a++){var n=e[a];i.set(n,r),r+=n.length}return i}function u(e,t,i){for(var r=i.length,s=0;s<r;s++)e.setUint8(t+s,i.charCodeAt(s))}2===r&&(s=c(s,o),a=c(a,o),l&&(s=d(s,l,n),a=d(a,l,n))),1===r&&(s=c(s,o),l&&(s=d(s,l,n))),l&&(n=l),2===r&&(i=function(e,t){for(var i=e.length+t.length,r=new Float64Array(i),s=0,a=0;a<i;)r[a++]=e[s],r[a++]=t[s],s++;return r}(s,a)),1===r&&(i=s);var p=i.length,f=new ArrayBuffer(44+2*p),y=new DataView(f);u(y,0,"RIFF"),y.setUint32(4,36+2*p,!0),u(y,8,"WAVE"),u(y,12,"fmt "),y.setUint32(16,16,!0),y.setUint16(20,1,!0),y.setUint16(22,r,!0),y.setUint32(24,n,!0),y.setUint32(28,n*r*2,!0),y.setUint16(32,2*r,!0),y.setUint16(34,16,!0),u(y,36,"data"),y.setUint32(40,2*p,!0);for(var m=p,g=44,A=0;A<m;A++)y.setInt16(g,32767*i[A],!0),g+=2;if(t)return t({buffer:f,view:y});postMessage({buffer:f,view:y})}if(e.noWorker)i(e,(function(e){t(e.buffer,e.view)}));else{var r,s,a,n=(r=i,s=h.createObjectURL(new Blob([r.toString(),";this.onmessage = function (eee) {"+r.name+"(eee.data);}"],{type:"application/javascript"})),(a=new Worker(s)).workerURL=s,a);n.onmessage=function(e){t(e.data.buffer,e.data.view),h.revokeObjectURL(n.workerURL),n.terminate()},n.postMessage(e)}}!0===i.leftChannel&&(d=1),1===i.numberOfAudioChannels&&(d=1),(!d||d<1)&&(d=2),i.disableLogs||console.log("StereoAudioRecorder is set to record number of channels: "+d),void 0===i.checkForInactiveTracks&&(i.checkForInactiveTracks=!0),this.record=function(){if(!1===u())throw"Please make sure MediaStream is active.";_(),E=v=!1,o=!0,void 0!==i.timeSlice&&T()},this.stop=function(e){e=e||function(){},o=!1,p({desiredSampRate:c,sampleRate:A,numberOfAudioChannels:d,internalInterleavedLength:l,leftBuffers:a,rightBuffers:1===d?[]:n,noWorker:i.noWorker},(function(t,i){s.blob=new Blob([i],{type:"audio/wav"}),s.buffer=new ArrayBuffer(i.buffer.byteLength),s.view=i,s.sampleRate=c||A,s.bufferSize=g,s.length=l,E=!1,e&&e(s.blob)}))},void 0===t.Storage&&(t.Storage={AudioContextConstructor:null,AudioContext:window.AudioContext||window.webkitAudioContext}),t.Storage.AudioContextConstructor&&"closed"!==t.Storage.AudioContextConstructor.state||(t.Storage.AudioContextConstructor=new t.Storage.AudioContext);var f=t.Storage.AudioContextConstructor,y=f.createMediaStreamSource(e),m=[0,256,512,1024,2048,4096,8192,16384],g=void 0===i.bufferSize?4096:i.bufferSize;if(-1===m.indexOf(g)&&(i.disableLogs||console.log("Legal values for buffer-size are "+JSON.stringify(m,null,"\t"))),f.createJavaScriptNode)r=f.createJavaScriptNode(g,d,d);else{if(!f.createScriptProcessor)throw"WebAudio API has no support on this browser.";r=f.createScriptProcessor(g,d,d)}y.connect(r),i.bufferSize||(g=r.bufferSize);var A=void 0!==i.sampleRate?i.sampleRate:f.sampleRate||44100;(A<22050||A>96e3)&&(i.disableLogs||console.log("sample-rate must be under range 22050 and 96000.")),i.disableLogs||i.desiredSampRate&&console.log("Desired sample-rate: "+i.desiredSampRate);var v=!1;function _(){a=[],n=[],l=0,E=!1,o=!1,v=!1,f=null,s.leftchannel=a,s.rightchannel=n,s.numberOfAudioChannels=d,s.desiredSampRate=c,s.sampleRate=A,s.recordingLength=l,S={left:[],right:[],recordingLength:0}}function w(){r&&(r.onaudioprocess=null,r.disconnect(),r=null),y&&(y.disconnect(),y=null),_()}this.pause=function(){v=!0},this.resume=function(){if(!1===u())throw"Please make sure MediaStream is active.";if(!o)return i.disableLogs||console.log("Seems recording has been restarted."),void this.record();v=!1},this.clearRecordedData=function(){i.checkForInactiveTracks=!1,o&&this.stop(w),w()},this.name="StereoAudioRecorder",this.toString=function(){return this.name};var E=!1;r.onaudioprocess=function(e){if(!v)if(!1===u()&&(i.disableLogs||console.log("MediaStream seems stopped."),r.disconnect(),o=!1),o){E||(E=!0,i.onAudioProcessStarted&&i.onAudioProcessStarted(),i.initCallback&&i.initCallback());var t=e.inputBuffer.getChannelData(0),h=new Float32Array(t);if(a.push(h),2===d){var c=e.inputBuffer.getChannelData(1),p=new Float32Array(c);n.push(p)}l+=g,s.recordingLength=l,void 0!==i.timeSlice&&(S.recordingLength+=g,S.left.push(h),2===d&&S.right.push(p))}else y&&(y.disconnect(),y=null)},f.createMediaStreamDestination?r.connect(f.createMediaStreamDestination()):r.connect(f.destination),this.leftchannel=a,this.rightchannel=n,this.numberOfAudioChannels=d,this.desiredSampRate=c,this.sampleRate=A,s.recordingLength=l;var S={left:[],right:[],recordingLength:0};function T(){o&&"function"==typeof i.ondataavailable&&void 0!==i.timeSlice&&(S.left.length?(p({desiredSampRate:c,sampleRate:A,numberOfAudioChannels:d,internalInterleavedLength:S.recordingLength,leftBuffers:S.left,rightBuffers:1===d?[]:S.right},(function(e,t){var r=new Blob([t],{type:"audio/wav"});i.ondataavailable(r),setTimeout(T,i.timeSlice)})),S={left:[],right:[],recordingLength:0}):setTimeout(T,i.timeSlice))}}function k(e,t){if("undefined"==typeof html2canvas)throw"Please link: https://www.webrtc-experiment.com/screenshot.js";(t=t||{}).frameInterval||(t.frameInterval=10);var i=!1;["captureStream","mozCaptureStream","webkitCaptureStream"].forEach((function(e){e in document.createElement("canvas")&&(i=!0)}));var r,s,a,n=!(!window.webkitRTCPeerConnection&&!window.webkitGetUserMedia||!window.chrome),o=50,l=navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);if(n&&l&&l[2]&&(o=parseInt(l[2],10)),n&&o<52&&(i=!1),t.useWhammyRecorder&&(i=!1),i)if(t.disableLogs||console.log("Your browser supports both MediRecorder API and canvas.captureStream!"),e instanceof HTMLCanvasElement)r=e;else{if(!(e instanceof CanvasRenderingContext2D))throw"Please pass either HTMLCanvasElement or CanvasRenderingContext2D.";r=e.canvas}else navigator.mozGetUserMedia&&(t.disableLogs||console.error("Canvas recording is NOT supported in Firefox."));this.record=function(){if(a=!0,i&&!t.useWhammyRecorder){var e;"captureStream"in r?e=r.captureStream(25):"mozCaptureStream"in r?e=r.mozCaptureStream(25):"webkitCaptureStream"in r&&(e=r.webkitCaptureStream(25));try{var n=new m;n.addTrack(b(e,"video")[0]),e=n}catch(e){}if(!e)throw"captureStream API are NOT available.";(s=new S(e,{mimeType:t.mimeType||"video/webm"})).record()}else p.frames=[],u=(new Date).getTime(),c();t.initCallback&&t.initCallback()},this.getWebPImages=function(i){if("canvas"===e.nodeName.toLowerCase()){var r=p.frames.length;p.frames.forEach((function(e,i){var s=r-i;t.disableLogs||console.log(s+"/"+r+" frames remaining"),t.onEncodingCallback&&t.onEncodingCallback(s,r);var a=e.image.toDataURL("image/webp",1);p.frames[i].image=a})),t.disableLogs||console.log("Generating WebM"),i()}else i()},this.stop=function(e){a=!1;var r=this;i&&s?s.stop(e):this.getWebPImages((function(){p.compile((function(i){t.disableLogs||console.log("Recording finished!"),r.blob=i,r.blob.forEach&&(r.blob=new Blob([],{type:"video/webm"})),e&&e(r.blob),p.frames=[]}))}))};var d=!1;function h(){p.frames=[],a=!1,d=!1}function c(){if(d)return u=(new Date).getTime(),setTimeout(c,500);if("canvas"===e.nodeName.toLowerCase()){var i=(new Date).getTime()-u;return u=(new Date).getTime(),p.frames.push({image:(r=document.createElement("canvas"),s=r.getContext("2d"),r.width=e.width,r.height=e.height,s.drawImage(e,0,0),r),duration:i}),void(a&&setTimeout(c,t.frameInterval))}var r,s;html2canvas(e,{grabMouse:void 0===t.showMousePointer||t.showMousePointer,onrendered:function(e){var i=(new Date).getTime()-u;if(!i)return setTimeout(c,t.frameInterval);u=(new Date).getTime(),p.frames.push({image:e.toDataURL("image/webp",1),duration:i}),a&&setTimeout(c,t.frameInterval)}})}this.pause=function(){d=!0,s instanceof S&&s.pause()},this.resume=function(){d=!1,s instanceof S?s.resume():a||this.record()},this.clearRecordedData=function(){a&&this.stop(h),h()},this.name="CanvasRecorder",this.toString=function(){return this.name};var u=(new Date).getTime(),p=new D.Video(100)}function C(e,t){function i(e){e=void 0!==e?e:10;var t=(new Date).getTime()-l;return t?a?(l=(new Date).getTime(),setTimeout(i,100)):(l=(new Date).getTime(),o.paused&&o.play(),c.drawImage(o,0,0,h.width,h.height),d.frames.push({duration:t,image:h.toDataURL("image/webp")}),void(s||setTimeout(i,e,e))):setTimeout(i,e,e)}function r(e,t,i,r,s){var a=document.createElement("canvas");a.width=h.width,a.height=h.height;var n,o,l,d=a.getContext("2d"),c=[],u=-1===t,p=t&&t>0&&t<=e.length?t:e.length,f=0,y=0,m=0,g=Math.sqrt(Math.pow(255,2)+Math.pow(255,2)+Math.pow(255,2)),A=i&&i>=0&&i<=1?i:0,v=r&&r>=0&&r<=1?r:0,b=!1;o=-1,l=(n={length:p,functionToLoop:function(t,i){var r,s,a,n=function(){!b&&a-r<=a*v||(u&&(b=!0),c.push(e[i])),t()};if(b)n();else{var o=new Image;o.onload=function(){d.drawImage(o,0,0,h.width,h.height);var e=d.getImageData(0,0,h.width,h.height);r=0,s=e.data.length,a=e.data.length/4;for(var t=0;t<s;t+=4){var i={r:e.data[t],g:e.data[t+1],b:e.data[t+2]};Math.sqrt(Math.pow(i.r-f,2)+Math.pow(i.g-y,2)+Math.pow(i.b-m,2))<=g*A&&r++}n()},o.src=e[i].image}},callback:function(){(c=c.concat(e.slice(p))).length<=0&&c.push(e[e.length-1]),s(c)}}).length,function e(){++o!==l?setTimeout((function(){n.functionToLoop(e,o)}),1):n.callback()}()}(t=t||{}).frameInterval||(t.frameInterval=10),t.disableLogs||console.log("Using frames-interval:",t.frameInterval),this.record=function(){t.width||(t.width=320),t.height||(t.height=240),t.video||(t.video={width:t.width,height:t.height}),t.canvas||(t.canvas={width:t.width,height:t.height}),h.width=t.canvas.width||320,h.height=t.canvas.height||240,c=h.getContext("2d"),t.video&&t.video instanceof HTMLVideoElement?(o=t.video.cloneNode(),t.initCallback&&t.initCallback()):(o=document.createElement("video"),_(e,o),o.onloadedmetadata=function(){t.initCallback&&t.initCallback()},o.width=t.video.width,o.height=t.video.height),o.muted=!0,o.play(),l=(new Date).getTime(),d=new D.Video,t.disableLogs||(console.log("canvas resolutions",h.width,"*",h.height),console.log("video width/height",o.width||h.width,"*",o.height||h.height)),i(t.frameInterval)};var s=!1;this.stop=function(e){e=e||function(){},s=!0;var i=this;setTimeout((function(){r(d.frames,-1,null,null,(function(r){d.frames=r,t.advertisement&&t.advertisement.length&&(d.frames=t.advertisement.concat(d.frames)),d.compile((function(t){i.blob=t,i.blob.forEach&&(i.blob=new Blob([],{type:"video/webm"})),e&&e(i.blob)}))}))}),10)};var a=!1;function n(){d.frames=[],s=!0,a=!1}this.pause=function(){a=!0},this.resume=function(){a=!1,s&&this.record()},this.clearRecordedData=function(){s||this.stop(n),n()},this.name="WhammyRecorder",this.toString=function(){return this.name};var o,l,d,h=document.createElement("canvas"),c=h.getContext("2d")}void 0!==d?w.AudioContext=d:"undefined"!=typeof webkitAudioContext&&(w.AudioContext=webkitAudioContext),void 0!==t&&(t.Storage=w),void 0!==t&&(t.MediaStreamRecorder=S),void 0!==t&&(t.StereoAudioRecorder=T),void 0!==t&&(t.CanvasRecorder=k),void 0!==t&&(t.WhammyRecorder=C);var D=function(){function e(e){this.frames=[],this.duration=e||1,this.quality=.8}function t(e){function t(e,t,i){return[{data:e,id:231}].concat(i.map((function(e){var i=function(e){var t=0;e.keyframe&&(t|=128);e.invisible&&(t|=8);e.lacing&&(t|=e.lacing<<1);e.discardable&&(t|=1);if(e.trackNum>127)throw"TrackNumber > 127 not supported";var i=[128|e.trackNum,e.timecode>>8,255&e.timecode,t].map((function(e){return String.fromCharCode(e)})).join("")+e.frame;return i}({discardable:0,frame:e.data.slice(4),invisible:0,keyframe:1,lacing:0,trackNum:1,timecode:Math.round(t)});return t+=e.duration,{data:i,id:163}})))}function i(e){for(var t=[];e>0;)t.push(255&e),e>>=8;return new Uint8Array(t.reverse())}function r(e){var t=[];e=(e.length%8?new Array(9-e.length%8).join("0"):"")+e;for(var i=0;i<e.length;i+=8)t.push(parseInt(e.substr(i,8),2));return new Uint8Array(t)}function s(e){for(var t=[],a=0;a<e.length;a++){var n=e[a].data;"object"==typeof n&&(n=s(n)),"number"==typeof n&&(n=r(n.toString(2))),"string"==typeof n&&(n=new Uint8Array(n.split("").map((function(e){return e.charCodeAt(0)}))));var o=n.size||n.byteLength||n.length,l=Math.ceil(Math.ceil(Math.log(o)/Math.log(2))/8),d=o.toString(2),h=new Array(7*l+7+1-d.length).join("0")+d,c=new Array(l).join("0")+"1"+h;t.push(i(e[a].id)),t.push(r(c)),t.push(n)}return new Blob(t,{type:"video/webm"})}function a(e,t){return parseInt(e.substr(t+4,4).split("").map((function(e){var t=e.charCodeAt(0).toString(2);return new Array(8-t.length+1).join("0")+t})).join(""),2)}function n(e){for(var t=0,i={};t<e.length;){var r=e.substr(t,4),s=a(e,t),o=e.substr(t+4+4,s);t+=8+s,i[r]=i[r]||[],"RIFF"===r||"LIST"===r?i[r].push(n(o)):i[r].push(o)}return i}var o=new function(e){var i=function(e){if(!e[0])return void postMessage({error:"Something went wrong. Maybe WebP format is not supported in the current browser."});for(var t=e[0].width,i=e[0].height,r=e[0].duration,s=1;s<e.length;s++)r+=e[s].duration;return{duration:r,width:t,height:i}}(e);if(!i)return[];for(var r,a=[{id:440786851,data:[{data:1,id:17030},{data:1,id:17143},{data:4,id:17138},{data:8,id:17139},{data:"webm",id:17026},{data:2,id:17031},{data:2,id:17029}]},{id:408125543,data:[{id:357149030,data:[{data:1e6,id:2807729},{data:"whammy",id:19840},{data:"whammy",id:22337},{data:(r=i.duration,[].slice.call(new Uint8Array(new Float64Array([r]).buffer),0).map((function(e){return String.fromCharCode(e)})).reverse().join("")),id:17545}]},{id:374648427,data:[{id:174,data:[{data:1,id:215},{data:1,id:29637},{data:0,id:156},{data:"und",id:2274716},{data:"V_VP8",id:134},{data:"VP8",id:2459272},{data:1,id:131},{id:224,data:[{data:i.width,id:176},{data:i.height,id:186}]}]}]}]}],n=0,o=0;n<e.length;){var l=[],d=0;do{l.push(e[n]),d+=e[n].duration,n++}while(n<e.length&&d<3e4);var h={id:524531317,data:t(o,0,l)};a[1].data.push(h),o+=d}return s(a)}(e.map((function(e){var t=function(e){for(var t=e.RIFF[0].WEBP[0],i=t.indexOf("*"),r=0,s=[];r<4;r++)s[r]=t.charCodeAt(i+3+r);return{width:16383&(s[1]<<8|s[0]),height:16383&(s[3]<<8|s[2]),data:t,riff:e}}(n(atob(e.image.slice(23))));return t.duration=e.duration,t})));postMessage(o)}return e.prototype.add=function(e,t){if("canvas"in e&&(e=e.canvas),"toDataURL"in e&&(e=e.toDataURL("image/webp",this.quality)),!/^data:image\/webp;base64,/gi.test(e))throw"Input must be formatted properly as a base64 encoded DataURI of type image/webp";this.frames.push({image:e,duration:t||this.duration})},e.prototype.compile=function(e){var i,r,s,a=(i=t,r=h.createObjectURL(new Blob([i.toString(),"this.onmessage = function (eee) {"+i.name+"(eee.data);}"],{type:"application/javascript"})),s=new Worker(r),h.revokeObjectURL(r),s);a.onmessage=function(t){t.data.error?console.error(t.data.error):e(t.data)},a.postMessage(this.frames)},{Video:e}}();void 0!==t&&(t.Whammy=D);var R={init:function(){var e=this;if("undefined"!=typeof indexedDB&&void 0!==indexedDB.open){var t,i=this.dbName||location.href.replace(/\/|:|#|%|\.|\[|\]/g,""),r=indexedDB.open(i,1);r.onerror=e.onError,r.onsuccess=function(){((t=r.result).onerror=e.onError,t.setVersion)?1!==t.version?t.setVersion(1).onsuccess=function(){s(t),a()}:a():a()},r.onupgradeneeded=function(e){s(e.target.result)}}else console.error("IndexedDB API are not available in this browser.");function s(t){t.createObjectStore(e.dataStoreName)}function a(){var i=t.transaction([e.dataStoreName],"readwrite");function r(t){i.objectStore(e.dataStoreName).get(t).onsuccess=function(i){e.callback&&e.callback(i.target.result,t)}}e.videoBlob&&i.objectStore(e.dataStoreName).put(e.videoBlob,"videoBlob"),e.gifBlob&&i.objectStore(e.dataStoreName).put(e.gifBlob,"gifBlob"),e.audioBlob&&i.objectStore(e.dataStoreName).put(e.audioBlob,"audioBlob"),r("audioBlob"),r("videoBlob"),r("gifBlob")}},Fetch:function(e){return this.callback=e,this.init(),this},Store:function(e){return this.audioBlob=e.audioBlob,this.videoBlob=e.videoBlob,this.gifBlob=e.gifBlob,this.init(),this},onError:function(e){console.error(JSON.stringify(e,null,"\t"))},dataStoreName:"recordRTC",dbName:null};function x(e,t){if("undefined"==typeof GIFEncoder){var i=document.createElement("script");i.src="https://www.webrtc-experiment.com/gif-recorder.js",(document.body||document.documentElement).appendChild(i)}t=t||{};var r=e instanceof CanvasRenderingContext2D||e instanceof HTMLCanvasElement;this.record=function(){"undefined"!=typeof GIFEncoder&&d?(r||(t.width||(t.width=h.offsetWidth||320),t.height||(t.height=h.offsetHeight||240),t.video||(t.video={width:t.width,height:t.height}),t.canvas||(t.canvas={width:t.width,height:t.height}),a.width=t.canvas.width||320,a.height=t.canvas.height||240,h.width=t.video.width||320,h.height=t.video.height||240),(u=new GIFEncoder).setRepeat(0),u.setDelay(t.frameRate||200),u.setQuality(t.quality||10),u.start(),"function"==typeof t.onGifRecordingStarted&&t.onGifRecordingStarted(),p=n((function e(i){if(!0!==f.clearedRecordedData){if(s)return setTimeout((function(){e(i)}),100);p=n(e),void 0===typeof c&&(c=i),i-c<90||(!r&&h.paused&&h.play(),r||o.drawImage(h,0,0,a.width,a.height),t.onGifPreview&&t.onGifPreview(a.toDataURL("image/png")),u.addFrame(o),c=i)}})),t.initCallback&&t.initCallback()):setTimeout(f.record,1e3)},this.stop=function(e){e=e||function(){},p&&l(p),this.blob=new Blob([new Uint8Array(u.stream().bin)],{type:"image/gif"}),e(this.blob),u.stream().bin=[]};var s=!1;this.pause=function(){s=!0},this.resume=function(){s=!1},this.clearRecordedData=function(){f.clearedRecordedData=!0,u&&(u.stream().bin=[])},this.name="GifRecorder",this.toString=function(){return this.name};var a=document.createElement("canvas"),o=a.getContext("2d");r&&(e instanceof CanvasRenderingContext2D?a=(o=e).canvas:e instanceof HTMLCanvasElement&&(o=e.getContext("2d"),a=e));var d=!0;if(!r){var h=document.createElement("video");h.muted=!0,h.autoplay=!0,h.playsInline=!0,d=!1,h.onloadedmetadata=function(){d=!0},_(e,h),h.play()}var c,u,p=null,f=this}function L(e,i){!function(e){void 0===t&&e&&"undefined"==typeof window&&void 0!==Jr&&(Jr.navigator={userAgent:"Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45",getUserMedia:function(){}},Jr.console||(Jr.console={}),void 0!==Jr.console.log&&void 0!==Jr.console.error||(Jr.console.error=Jr.console.log=Jr.console.log||function(){console.log(arguments)}),"undefined"==typeof document&&(e.document={documentElement:{appendChild:function(){return""}}},document.createElement=document.captureStream=document.mozCaptureStream=function(){var e={getContext:function(){return e},play:function(){},pause:function(){},drawImage:function(){},toDataURL:function(){return""},style:{}};return e},e.HTMLVideoElement=function(){}),"undefined"==typeof location&&(e.location={protocol:"file:",href:"",hash:""}),"undefined"==typeof screen&&(e.screen={width:0,height:0}),void 0===d&&(e.URL={createObjectURL:function(){return""},revokeObjectURL:function(){return""}}),e.window=Jr)}(void 0!==Jr?Jr:null),i=i||"multi-streams-mixer";var r=[],s=!1,a=document.createElement("canvas"),n=a.getContext("2d");a.style.opacity=0,a.style.position="absolute",a.style.zIndex=-1,a.style.top="-1000em",a.style.left="-1000em",a.className=i,(document.body||document.documentElement).appendChild(a),this.disableLogs=!1,this.frameInterval=10,this.width=360,this.height=240,this.useGainNode=!0;var o=this,l=window.AudioContext;void 0===l&&("undefined"!=typeof webkitAudioContext&&(l=webkitAudioContext),"undefined"!=typeof mozAudioContext&&(l=mozAudioContext));var d=window.URL;void 0===d&&"undefined"!=typeof webkitURL&&(d=webkitURL),"undefined"!=typeof navigator&&void 0===navigator.getUserMedia&&(void 0!==navigator.webkitGetUserMedia&&(navigator.getUserMedia=navigator.webkitGetUserMedia),void 0!==navigator.mozGetUserMedia&&(navigator.getUserMedia=navigator.mozGetUserMedia));var h=window.MediaStream;void 0===h&&"undefined"!=typeof webkitMediaStream&&(h=webkitMediaStream),void 0!==h&&void 0===h.prototype.stop&&(h.prototype.stop=function(){this.getTracks().forEach((function(e){e.stop()}))});var c={};function u(){if(!s){var e=r.length,t=!1,i=[];if(r.forEach((function(e){e.stream||(e.stream={}),e.stream.fullcanvas?t=e:i.push(e)})),t)a.width=t.stream.width,a.height=t.stream.height;else if(i.length){a.width=e>1?2*i[0].width:i[0].width;var n=1;3!==e&&4!==e||(n=2),5!==e&&6!==e||(n=3),7!==e&&8!==e||(n=4),9!==e&&10!==e||(n=5),a.height=i[0].height*n}else a.width=o.width||360,a.height=o.height||240;t&&t instanceof HTMLVideoElement&&p(t),i.forEach((function(e,t){p(e,t)})),setTimeout(u,o.frameInterval)}}function p(e,t){if(!s){var i=0,r=0,a=e.width,o=e.height;1===t&&(i=e.width),2===t&&(r=e.height),3===t&&(i=e.width,r=e.height),4===t&&(r=2*e.height),5===t&&(i=e.width,r=2*e.height),6===t&&(r=3*e.height),7===t&&(i=e.width,r=3*e.height),void 0!==e.stream.left&&(i=e.stream.left),void 0!==e.stream.top&&(r=e.stream.top),void 0!==e.stream.width&&(a=e.stream.width),void 0!==e.stream.height&&(o=e.stream.height),n.drawImage(e,i,r,a,o),"function"==typeof e.stream.onRender&&e.stream.onRender(n,i,r,a,o,t)}}function f(e){var t=document.createElement("video");return function(e,t){"srcObject"in t?t.srcObject=e:"mozSrcObject"in t?t.mozSrcObject=e:t.srcObject=e}(e,t),t.className=i,t.muted=!0,t.volume=0,t.width=e.width||o.width||360,t.height=e.height||o.height||240,t.play(),t}function y(t){r=[],(t=t||e).forEach((function(e){if(e.getTracks().filter((function(e){return"video"===e.kind})).length){var t=f(e);t.stream=e,r.push(t)}}))}void 0!==l?c.AudioContext=l:"undefined"!=typeof webkitAudioContext&&(c.AudioContext=webkitAudioContext),this.startDrawingFrames=function(){u()},this.appendStreams=function(t){if(!t)throw"First parameter is required.";t instanceof Array||(t=[t]),t.forEach((function(t){var i=new h;if(t.getTracks().filter((function(e){return"video"===e.kind})).length){var s=f(t);s.stream=t,r.push(s),i.addTrack(t.getTracks().filter((function(e){return"video"===e.kind}))[0])}if(t.getTracks().filter((function(e){return"audio"===e.kind})).length){var a=o.audioContext.createMediaStreamSource(t);o.audioDestination=o.audioContext.createMediaStreamDestination(),a.connect(o.audioDestination),i.addTrack(o.audioDestination.stream.getTracks().filter((function(e){return"audio"===e.kind}))[0])}e.push(i)}))},this.releaseStreams=function(){r=[],s=!0,o.gainNode&&(o.gainNode.disconnect(),o.gainNode=null),o.audioSources.length&&(o.audioSources.forEach((function(e){e.disconnect()})),o.audioSources=[]),o.audioDestination&&(o.audioDestination.disconnect(),o.audioDestination=null),o.audioContext&&o.audioContext.close(),o.audioContext=null,n.clearRect(0,0,a.width,a.height),a.stream&&(a.stream.stop(),a.stream=null)},this.resetVideoStreams=function(e){!e||e instanceof Array||(e=[e]),y(e)},this.name="MultiStreamsMixer",this.toString=function(){return this.name},this.getMixedStream=function(){s=!1;var t=function(){var e;y(),"captureStream"in a?e=a.captureStream():"mozCaptureStream"in a?e=a.mozCaptureStream():o.disableLogs||console.error("Upgrade to latest Chrome or otherwise enable this flag: chrome://flags/#enable-experimental-web-platform-features");var t=new h;return e.getTracks().filter((function(e){return"video"===e.kind})).forEach((function(e){t.addTrack(e)})),a.stream=t,t}(),i=function(){c.AudioContextConstructor||(c.AudioContextConstructor=new c.AudioContext);o.audioContext=c.AudioContextConstructor,o.audioSources=[],!0===o.useGainNode&&(o.gainNode=o.audioContext.createGain(),o.gainNode.connect(o.audioContext.destination),o.gainNode.gain.value=0);var t=0;if(e.forEach((function(e){if(e.getTracks().filter((function(e){return"audio"===e.kind})).length){t++;var i=o.audioContext.createMediaStreamSource(e);!0===o.useGainNode&&i.connect(o.gainNode),o.audioSources.push(i)}})),!t)return;return o.audioDestination=o.audioContext.createMediaStreamDestination(),o.audioSources.forEach((function(e){e.connect(o.audioDestination)})),o.audioDestination.stream}();return i&&i.getTracks().filter((function(e){return"audio"===e.kind})).forEach((function(e){t.addTrack(e)})),e.forEach((function(e){e.fullcanvas})),t}}function I(e,t){e=e||[];var i,r,s=this;(t=t||{elementClass:"multi-streams-mixer",mimeType:"video/webm",video:{width:360,height:240}}).frameInterval||(t.frameInterval=10),t.video||(t.video={}),t.video.width||(t.video.width=360),t.video.height||(t.video.height=240),this.record=function(){var s;i=new L(e,t.elementClass||"multi-streams-mixer"),(s=[],e.forEach((function(e){b(e,"video").forEach((function(e){s.push(e)}))})),s).length&&(i.frameInterval=t.frameInterval||10,i.width=t.video.width||360,i.height=t.video.height||240,i.startDrawingFrames()),t.previewStream&&"function"==typeof t.previewStream&&t.previewStream(i.getMixedStream()),(r=new S(i.getMixedStream(),t)).record()},this.stop=function(e){r&&r.stop((function(t){s.blob=t,e(t),s.clearRecordedData()}))},this.pause=function(){r&&r.pause()},this.resume=function(){r&&r.resume()},this.clearRecordedData=function(){r&&(r.clearRecordedData(),r=null),i&&(i.releaseStreams(),i=null)},this.addStreams=function(s){if(!s)throw"First parameter is required.";s instanceof Array||(s=[s]),e.concat(s),r&&i&&(i.appendStreams(s),t.previewStream&&"function"==typeof t.previewStream&&t.previewStream(i.getMixedStream()))},this.resetVideoStreams=function(e){i&&(!e||e instanceof Array||(e=[e]),i.resetVideoStreams(e))},this.getMixer=function(){return i},this.name="MultiStreamRecorder",this.toString=function(){return this.name}}function P(e,t){var i,r,s;function a(){return new ReadableStream({start:function(r){var s=document.createElement("canvas"),a=document.createElement("video"),n=!0;a.srcObject=e,a.muted=!0,a.height=t.height,a.width=t.width,a.volume=0,a.onplaying=function(){s.width=t.width,s.height=t.height;var e=s.getContext("2d"),o=1e3/t.frameRate,l=setInterval((function(){if(i&&(clearInterval(l),r.close()),n&&(n=!1,t.onVideoProcessStarted&&t.onVideoProcessStarted()),e.drawImage(a,0,0),"closed"!==r._controlledReadableStream.state)try{r.enqueue(e.getImageData(0,0,t.width,t.height))}catch(e){}}),o)},a.play()}})}function n(e,l){if(!t.workerPath&&!l)return i=!1,void fetch("https://unpkg.com/webm-wasm@latest/dist/webm-worker.js").then((function(t){t.arrayBuffer().then((function(t){n(e,t)}))}));if(!t.workerPath&&l instanceof ArrayBuffer){var d=new Blob([l],{type:"text/javascript"});t.workerPath=h.createObjectURL(d)}t.workerPath||console.error("workerPath parameter is missing."),(r=new Worker(t.workerPath)).postMessage(t.webAssemblyPath||"https://unpkg.com/webm-wasm@latest/dist/webm-wasm.wasm"),r.addEventListener("message",(function(e){"READY"===e.data?(r.postMessage({width:t.width,height:t.height,bitrate:t.bitrate||1200,timebaseDen:t.frameRate||30,realtime:t.realtime}),a().pipeTo(new WritableStream({write:function(e){i?console.error("Got image, but recorder is finished!"):r.postMessage(e.data.buffer,[e.data.buffer])}}))):e.data&&(s||o.push(e.data))}))}"undefined"!=typeof ReadableStream&&"undefined"!=typeof WritableStream||console.error("Following polyfill is strongly recommended: https://unpkg.com/@mattiasbuelens/web-streams-polyfill/dist/polyfill.min.js"),(t=t||{}).width=t.width||640,t.height=t.height||480,t.frameRate=t.frameRate||30,t.bitrate=t.bitrate||1200,t.realtime=t.realtime||!0,this.record=function(){o=[],s=!1,this.blob=null,n(e),"function"==typeof t.initCallback&&t.initCallback()},this.pause=function(){s=!0},this.resume=function(){s=!1};var o=[];this.stop=function(e){i=!0;var t=this;!function(e){r?(r.addEventListener("message",(function(t){null===t.data&&(r.terminate(),r=null,e&&e())})),r.postMessage(null)):e&&e()}((function(){t.blob=new Blob(o,{type:"video/webm"}),e(t.blob)}))},this.name="WebAssemblyRecorder",this.toString=function(){return this.name},this.clearRecordedData=function(){o=[],s=!1,this.blob=null},this.blob=null}void 0!==t&&(t.DiskStorage=R),void 0!==t&&(t.GifRecorder=x),void 0===t&&(e.exports=L),void 0!==t&&(t.MultiStreamRecorder=I),void 0!==t&&(t.RecordRTCPromisesHandler=function(e,i){if(!this)throw'Use "new RecordRTCPromisesHandler()"';if(void 0===e)throw'First argument "MediaStream" is required.';var r=this;r.recordRTC=new t(e,i),this.startRecording=function(){return new Promise((function(e,t){try{r.recordRTC.startRecording(),e()}catch(e){t(e)}}))},this.stopRecording=function(){return new Promise((function(e,t){try{r.recordRTC.stopRecording((function(i){r.blob=r.recordRTC.getBlob(),r.blob&&r.blob.size?e(i):t("Empty blob.",r.blob)}))}catch(e){t(e)}}))},this.pauseRecording=function(){return new Promise((function(e,t){try{r.recordRTC.pauseRecording(),e()}catch(e){t(e)}}))},this.resumeRecording=function(){return new Promise((function(e,t){try{r.recordRTC.resumeRecording(),e()}catch(e){t(e)}}))},this.getDataURL=function(e){return new Promise((function(e,t){try{r.recordRTC.getDataURL((function(t){e(t)}))}catch(e){t(e)}}))},this.getBlob=function(){return new Promise((function(e,t){try{e(r.recordRTC.getBlob())}catch(e){t(e)}}))},this.getInternalRecorder=function(){return new Promise((function(e,t){try{e(r.recordRTC.getInternalRecorder())}catch(e){t(e)}}))},this.reset=function(){return new Promise((function(e,t){try{e(r.recordRTC.reset())}catch(e){t(e)}}))},this.destroy=function(){return new Promise((function(e,t){try{e(r.recordRTC.destroy())}catch(e){t(e)}}))},this.getState=function(){return new Promise((function(e,t){try{e(r.recordRTC.getState())}catch(e){t(e)}}))},this.blob=null,this.version="5.6.2"}),void 0!==t&&(t.WebAssemblyRecorder=P)}));class Mn{constructor(e){this._buffer=e,this._buffer_index=0,this._total_bytes=e.byteLength,this._total_bits=8*e.byteLength,this._current_word=0,this._current_word_bits_left=0}destroy(){this._buffer=null}_fillCurrentWord(){let e=this._total_bytes-this._buffer_index;if(e<=0)return void console.error("ExpGolomb: _fillCurrentWord() but no bytes available",this._total_bytes,this._buffer_index);let t=Math.min(4,e),i=new Uint8Array(4);i.set(this._buffer.subarray(this._buffer_index,this._buffer_index+t)),this._current_word=new DataView(i.buffer).getUint32(0,!1),this._buffer_index+=t,this._current_word_bits_left=8*t}readBits(e){if(e>32&&console.error("ExpGolomb: readBits() bits exceeded max 32bits!"),e<=this._current_word_bits_left){let t=this._current_word>>>32-e;return this._current_word<<=e,this._current_word_bits_left-=e,t}let t=this._current_word_bits_left?this._current_word:0;t>>>=32-this._current_word_bits_left;let i=e-this._current_word_bits_left;this._fillCurrentWord();let r=Math.min(i,this._current_word_bits_left),s=this._current_word>>>32-r;return this._current_word<<=r,this._current_word_bits_left-=r,t=t<<r|s,t}readBool(){return 1===this.readBits(1)}readByte(){return this.readBits(8)}_skipLeadingZero(){let e;for(e=0;e<this._current_word_bits_left;e++)if(this._current_word&2147483648>>>e)return this._current_word<<=e,this._current_word_bits_left-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()}readUEG(){let e=this._skipLeadingZero();return this.readBits(e+1)-1}readSEG(){let e=this.readUEG();return 1&e?e+1>>>1:-1*(e>>>1)}}class Un{static _ebsp2rbsp(e){let t=e,i=t.byteLength,r=new Uint8Array(i),s=0;for(let e=0;e<i;e++)e>=2&&3===t[e]&&0===t[e-1]&&0===t[e-2]||(r[s]=t[e],s++);return new Uint8Array(r.buffer,0,s)}static parseSPS(e){let t=Un._ebsp2rbsp(e),i=new Mn(t);i.readByte();let r=i.readByte();i.readByte();let s=i.readByte();i.readUEG();let a=Un.getProfileString(r),n=Un.getLevelString(s),o=1,l=420,d=[0,420,422,444],h=8;if((100===r||110===r||122===r||244===r||44===r||83===r||86===r||118===r||128===r||138===r||144===r)&&(o=i.readUEG(),3===o&&i.readBits(1),o<=3&&(l=d[o]),h=i.readUEG()+8,i.readUEG(),i.readBits(1),i.readBool())){let e=3!==o?8:12;for(let t=0;t<e;t++)i.readBool()&&(t<6?Un._skipScalingList(i,16):Un._skipScalingList(i,64))}i.readUEG();let c=i.readUEG();if(0===c)i.readUEG();else if(1===c){i.readBits(1),i.readSEG(),i.readSEG();let e=i.readUEG();for(let t=0;t<e;t++)i.readSEG()}let u=i.readUEG();i.readBits(1);let p=i.readUEG(),f=i.readUEG(),y=i.readBits(1);0===y&&i.readBits(1),i.readBits(1);let m=0,g=0,A=0,v=0;i.readBool()&&(m=i.readUEG(),g=i.readUEG(),A=i.readUEG(),v=i.readUEG());let b=1,_=1,w=0,E=!0,S=0,T=0;if(i.readBool()){if(i.readBool()){let e=i.readByte();e>0&&e<16?(b=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][e-1],_=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][e-1]):255===e&&(b=i.readByte()<<8|i.readByte(),_=i.readByte()<<8|i.readByte())}if(i.readBool()&&i.readBool(),i.readBool()&&(i.readBits(4),i.readBool()&&i.readBits(24)),i.readBool()&&(i.readUEG(),i.readUEG()),i.readBool()){let e=i.readBits(32),t=i.readBits(32);E=i.readBool(),S=t,T=2*e,w=S/T}}let k=1;1===b&&1===_||(k=b/_);let C=0,D=0;if(0===o)C=1,D=2-y;else{C=3===o?1:2,D=(1===o?2:1)*(2-y)}let R=16*(p+1),x=16*(f+1)*(2-y);R-=(m+g)*C,x-=(A+v)*D;let L=Math.ceil(R*k);return i.destroy(),i=null,{profile_string:a,level_string:n,bit_depth:h,ref_frames:u,chroma_format:l,chroma_format_string:Un.getChromaFormatString(l),frame_rate:{fixed:E,fps:w,fps_den:T,fps_num:S},sar_ratio:{width:b,height:_},codec_size:{width:R,height:x},present_size:{width:L,height:x}}}static parseSPS$2(e){let t=e.subarray(1,4),i="avc1.";for(let e=0;e<3;e++){let r=t[e].toString(16);r.length<2&&(r="0"+r),i+=r}let r=Un._ebsp2rbsp(e),s=new Mn(r);s.readByte();let a=s.readByte();s.readByte();let n=s.readByte();s.readUEG();let o=Un.getProfileString(a),l=Un.getLevelString(n),d=1,h=420,c=[0,420,422,444],u=8,p=8;if((100===a||110===a||122===a||244===a||44===a||83===a||86===a||118===a||128===a||138===a||144===a)&&(d=s.readUEG(),3===d&&s.readBits(1),d<=3&&(h=c[d]),u=s.readUEG()+8,p=s.readUEG()+8,s.readBits(1),s.readBool())){let e=3!==d?8:12;for(let t=0;t<e;t++)s.readBool()&&(t<6?Un._skipScalingList(s,16):Un._skipScalingList(s,64))}s.readUEG();let f=s.readUEG();if(0===f)s.readUEG();else if(1===f){s.readBits(1),s.readSEG(),s.readSEG();let e=s.readUEG();for(let t=0;t<e;t++)s.readSEG()}let y=s.readUEG();s.readBits(1);let m=s.readUEG(),g=s.readUEG(),A=s.readBits(1);0===A&&s.readBits(1),s.readBits(1);let v=0,b=0,_=0,w=0;s.readBool()&&(v=s.readUEG(),b=s.readUEG(),_=s.readUEG(),w=s.readUEG());let E=1,S=1,T=0,k=!0,C=0,D=0;if(s.readBool()){if(s.readBool()){let e=s.readByte();e>0&&e<16?(E=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][e-1],S=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][e-1]):255===e&&(E=s.readByte()<<8|s.readByte(),S=s.readByte()<<8|s.readByte())}if(s.readBool()&&s.readBool(),s.readBool()&&(s.readBits(4),s.readBool()&&s.readBits(24)),s.readBool()&&(s.readUEG(),s.readUEG()),s.readBool()){let e=s.readBits(32),t=s.readBits(32);k=s.readBool(),C=t,D=2*e,T=C/D}}let R=1;1===E&&1===S||(R=E/S);let x=0,L=0;if(0===d)x=1,L=2-A;else{x=3===d?1:2,L=(1===d?2:1)*(2-A)}let I=16*(m+1),P=16*(g+1)*(2-A);I-=(v+b)*x,P-=(_+w)*L;let B=Math.ceil(I*R);return s.destroy(),s=null,{codec_mimetype:i,profile_idc:a,level_idc:n,profile_string:o,level_string:l,chroma_format_idc:d,bit_depth:u,bit_depth_luma:u,bit_depth_chroma:p,ref_frames:y,chroma_format:h,chroma_format_string:Un.getChromaFormatString(h),frame_rate:{fixed:k,fps:T,fps_den:D,fps_num:C},sar_ratio:{width:E,height:S},codec_size:{width:I,height:P},present_size:{width:B,height:P}}}static _skipScalingList(e,t){let i=8,r=8,s=0;for(let a=0;a<t;a++)0!==r&&(s=e.readSEG(),r=(i+s+256)%256),i=0===r?i:r}static getProfileString(e){switch(e){case 66:return"Baseline";case 77:return"Main";case 88:return"Extended";case 100:return"High";case 110:return"High10";case 122:return"High422";case 244:return"High444";default:return"Unknown"}}static getLevelString(e){return(e/10).toFixed(1)}static getChromaFormatString(e){switch(e){case 420:return"4:2:0";case 422:return"4:2:2";case 444:return"4:4:4";default:return"Unknown"}}}class Fn{constructor(e){this.buffer=e,this.buflen=e.length,this.bufpos=0,this.bufoff=0,this.iserro=!1}read(e){let t=0,i=0;for(;e;){if(e<0||this.bufpos>=this.buflen)return this.iserro=!0,0;this.iserro=!1,i=this.bufoff+e>8?8-this.bufoff:e,t<<=i,t+=this.buffer[this.bufpos]>>8-this.bufoff-i&255>>8-i,this.bufoff+=i,e-=i,8==this.bufoff&&(this.bufpos++,this.bufoff=0)}return t}look(e){let t=this.bufpos,i=this.bufoff,r=this.read(e);return this.bufpos=t,this.bufoff=i,r}read_golomb(){let e;for(e=0;0===this.read(1)&&!this.iserro;e++);return(1<<e)+this.read(e)-1}}function On(e){const t={},i=new DataView(e.buffer);let r=i.getUint8(0),s=i.getUint8(1);if(i.getUint8(2),i.getUint8(3),1!==r||0===s)return{};const a=1+(3&i.getUint8(4));if(3!==a&&4!==a)return{};let n=31&i.getUint8(5);if(0===n)return{};let o=6;for(let r=0;r<n;r++){let s=i.getUint16(o,!1);if(o+=2,0===s)continue;let a=new Uint8Array(e.buffer,o,s);o+=s;let n=Un.parseSPS(a);if(0!==r)continue;t.sps=a,t.timescale=1e3,t.codecWidth=n.codec_size.width,t.codecHeight=n.codec_size.height,t.presentWidth=n.present_size.width,t.presentHeight=n.present_size.height,t.profile=n.profile_string,t.level=n.level_string,t.bitDepth=n.bit_depth,t.chromaFormat=n.chroma_format,t.sarRatio=n.sar_ratio,t.frameRate=n.frame_rate,!1!==n.frame_rate.fixed&&0!==n.frame_rate.fps_num&&0!==n.frame_rate.fps_den||(t.frameRate={fixed:!0,fps:25,fps_num:25e3,fps_den:1e3});let l=t.frameRate.fps_den,d=t.frameRate.fps_num;t.refSampleDuration=t.timescale*(l/d);let h=a.subarray(1,4),c="avc1.";for(let e=0;e<3;e++){let t=h[e].toString(16);t.length<2&&(t="0"+t),c+=t}t.codec=c}let l=i.getUint8(o);if(0===l)return{};o++;for(let r=0;r<l;r++){let r=i.getUint16(o,!1);if(o+=2,0===r)continue;let s=new Uint8Array(e.buffer,o,r);o+=r,t.pps=s}if(t.videoType="avc",t.sps){const e=t.sps.byteLength,i=new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e]),r=new Uint8Array(e+4);r.set(i,0),r.set(t.sps,4),t.sps=r}if(t.pps){const e=t.pps.byteLength,i=new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e]),r=new Uint8Array(e+4);r.set(i,0),r.set(t.pps,4),t.pps=r}return t}function Nn({sps:e,pps:t}){let i=8+e.byteLength+1+2+t.byteLength,r=!1;const s=Un.parseSPS$2(e);66!==e[3]&&77!==e[3]&&88!==e[3]&&(r=!0,i+=4);let a=new Uint8Array(i);a[0]=1,a[1]=e[1],a[2]=e[2],a[3]=e[3],a[4]=255,a[5]=225;let n=e.byteLength;a[6]=n>>>8,a[7]=255&n;let o=8;a.set(e,8),o+=n,a[o]=1;let l=t.byteLength;a[o+1]=l>>>8,a[o+2]=255&l,a.set(t,o+3),o+=3+l,r&&(a[o]=252|s.chroma_format_idc,a[o+1]=248|s.bit_depth_luma-8,a[o+2]=248|s.bit_depth_chroma-8,a[o+3]=0,o+=4);const d=[23,0,0,0,0],h=new Uint8Array(d.length+a.byteLength);return h.set(d,0),h.set(a,d.length),h}function Gn(e,t){let i=[];i[0]=t?23:39,i[1]=1,i[2]=0,i[3]=0,i[4]=0;const r=new Uint8Array(i.length+e.byteLength);return r.set(i,0),r.set(e,i.length),r}function zn(e){return 31&e[0]}function Wn(e){return e===St.kSliceSEI}function Vn(e){return!function(e){return e===St.sps||e===St.pps}(e)&&!Wn(e)}function Hn(e){return e===St.iFrame}const $n=e=>{let t=e,i=t.byteLength,r=new Uint8Array(i),s=0;for(let e=0;e<i;e++)e>=2&&3===t[e]&&0===t[e-1]&&0===t[e-2]||(r[s]=t[e],s++);return new Uint8Array(r.buffer,0,s)},jn=e=>{switch(e){case 0:return"4:0:0";case 1:return"4:2:0";case 2:return"4:2:2";case 3:return"4:4:4";default:return"Unknown"}};function Kn(e,t=0){return(e[t]<<24>>>0)+(e[t+1]<<16)+(e[t+2]<<8)+(e[t+3]||0)}function qn(e,t=4){if(e.length<4)return;const i=e.length,r=[];let s,a=0;for(;a+t<i;)if(s=Kn(e,a),3===t&&(s>>>=8),a+=t,s){if(a+s>i)break;r.push(e.subarray(a,a+s)),a+=s}return r}function Yn(e){const t=e.byteLength,i=new Uint8Array(4);i[0]=t>>>24&255,i[1]=t>>>16&255,i[2]=t>>>8&255,i[3]=255&t;const r=new Uint8Array(t+4);return r.set(i,0),r.set(e,4),r}class Qn{static _ebsp2rbsp(e){let t=e,i=t.byteLength,r=new Uint8Array(i),s=0;for(let e=0;e<i;e++)e>=2&&3===t[e]&&0===t[e-1]&&0===t[e-2]||(r[s]=t[e],s++);return new Uint8Array(r.buffer,0,s)}static parseVPS(e){let t=Qn._ebsp2rbsp(e),i=new Mn(t);return i.readByte(),i.readByte(),i.readBits(4),i.readBits(2),i.readBits(6),{num_temporal_layers:i.readBits(3)+1,temporal_id_nested:i.readBool()}}static parseSPS(e){let t=Qn._ebsp2rbsp(e),i=new Mn(t);i.readByte(),i.readByte();let r=0,s=0,a=0,n=0;i.readBits(4);let o=i.readBits(3);i.readBool();let l=i.readBits(2),d=i.readBool(),h=i.readBits(5),c=i.readByte(),u=i.readByte(),p=i.readByte(),f=i.readByte(),y=i.readByte(),m=i.readByte(),g=i.readByte(),A=i.readByte(),v=i.readByte(),b=i.readByte(),_=i.readByte(),w=[],E=[];for(let e=0;e<o;e++)w.push(i.readBool()),E.push(i.readBool());if(o>0)for(let e=o;e<8;e++)i.readBits(2);for(let e=0;e<o;e++)w[e]&&(i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte()),E[e]&&i.readByte();i.readUEG();let S=i.readUEG();3==S&&i.readBits(1);let T=i.readUEG(),k=i.readUEG();i.readBool()&&(r+=i.readUEG(),s+=i.readUEG(),a+=i.readUEG(),n+=i.readUEG());let C=i.readUEG(),D=i.readUEG(),R=i.readUEG();for(let e=i.readBool()?0:o;e<=o;e++)i.readUEG(),i.readUEG(),i.readUEG();if(i.readUEG(),i.readUEG(),i.readUEG(),i.readUEG(),i.readUEG(),i.readUEG(),i.readBool()){if(i.readBool())for(let e=0;e<4;e++)for(let t=0;t<(3===e?2:6);t++){if(i.readBool()){let t=Math.min(64,1<<4+(e<<1));e>1&&i.readSEG();for(let e=0;e<t;e++)i.readSEG()}else i.readUEG()}}i.readBool(),i.readBool(),i.readBool()&&(i.readByte(),i.readUEG(),i.readUEG(),i.readBool());let x=i.readUEG(),L=0;for(let e=0;e<x;e++){let t=!1;if(0!==e&&(t=i.readBool()),t){e===x&&i.readUEG(),i.readBool(),i.readUEG();let t=0;for(let e=0;e<=L;e++){let e=i.readBool(),r=!1;e||(r=i.readBool()),(e||r)&&t++}L=t}else{let e=i.readUEG(),t=i.readUEG();L=e+t;for(let t=0;t<e;t++)i.readUEG(),i.readBool();for(let e=0;e<t;e++)i.readUEG(),i.readBool()}}if(i.readBool()){let e=i.readUEG();for(let t=0;t<e;t++){for(let e=0;e<R+4;e++)i.readBits(1);i.readBits(1)}}let I=!1,P=0,B=1,M=1,U=!1,F=1,O=1;if(i.readBool(),i.readBool(),i.readBool()){if(i.readBool()){let e=i.readByte();e>0&&e<=16?(B=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][e-1],M=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][e-1]):255===e&&(B=i.readBits(16),M=i.readBits(16))}if(i.readBool()&&i.readBool(),i.readBool()){i.readBits(3),i.readBool(),i.readBool()&&(i.readByte(),i.readByte(),i.readByte())}if(i.readBool()&&(i.readUEG(),i.readUEG()),i.readBool(),i.readBool(),i.readBool(),I=i.readBool(),I&&(i.readUEG(),i.readUEG(),i.readUEG(),i.readUEG()),i.readBool()){if(F=i.readBits(32),O=i.readBits(32),i.readBool()&&i.readUEG(),i.readBool()){let e=!1,t=!1,r=!1;e=i.readBool(),t=i.readBool(),(e||t)&&(r=i.readBool(),r&&(i.readByte(),i.readBits(5),i.readBool(),i.readBits(5)),i.readBits(4),i.readBits(4),r&&i.readBits(4),i.readBits(5),i.readBits(5),i.readBits(5));for(let s=0;s<=o;s++){let s=i.readBool();U=s;let a=!0,n=1;s||(a=i.readBool());let o=!1;if(a?i.readUEG():o=i.readBool(),o||(n=i.readUEG()+1),e){for(let e=0;e<n;e++)i.readUEG(),i.readUEG(),r&&(i.readUEG(),i.readUEG());i.readBool()}if(t){for(let e=0;e<n;e++)i.readUEG(),i.readUEG(),r&&(i.readUEG(),i.readUEG());i.readBool()}}}}i.readBool()&&(i.readBool(),i.readBool(),i.readBool(),P=i.readUEG(),i.readUEG(),i.readUEG(),i.readUEG(),i.readUEG())}i.readBool();let N=`hvc1.${h}.1.L${_}.B0`,G=T-(r+s)*(1===S||2===S?2:1),z=k-(a+n)*(1===S?2:1),W=1;return 1!==B&&1!==M&&(W=B/M),i.destroy(),i=null,{codec_mimetype:N,profile_string:Qn.getProfileString(h),level_string:Qn.getLevelString(_),profile_idc:h,bit_depth:C+8,ref_frames:1,chroma_format:S,chroma_format_string:Qn.getChromaFormatString(S),general_level_idc:_,general_profile_space:l,general_tier_flag:d,general_profile_idc:h,general_profile_compatibility_flags_1:c,general_profile_compatibility_flags_2:u,general_profile_compatibility_flags_3:p,general_profile_compatibility_flags_4:f,general_constraint_indicator_flags_1:y,general_constraint_indicator_flags_2:m,general_constraint_indicator_flags_3:g,general_constraint_indicator_flags_4:A,general_constraint_indicator_flags_5:v,general_constraint_indicator_flags_6:b,min_spatial_segmentation_idc:P,constant_frame_rate:0,chroma_format_idc:S,bit_depth_luma_minus8:C,bit_depth_chroma_minus8:D,frame_rate:{fixed:U,fps:O/F,fps_den:F,fps_num:O},sar_ratio:{width:B,height:M},codec_size:{width:G,height:z},present_size:{width:G*W,height:z}}}static parsePPS(e){let t=Qn._ebsp2rbsp(e),i=new Mn(t);i.readByte(),i.readByte(),i.readUEG(),i.readUEG(),i.readBool(),i.readBool(),i.readBits(3),i.readBool(),i.readBool(),i.readUEG(),i.readUEG(),i.readSEG(),i.readBool(),i.readBool(),i.readBool()&&i.readUEG(),i.readSEG(),i.readSEG(),i.readBool(),i.readBool(),i.readBool(),i.readBool();let r=i.readBool(),s=i.readBool(),a=1;return s&&r?a=0:s?a=3:r&&(a=2),{parallelismType:a}}static getChromaFormatString(e){switch(e){case 0:return"4:0:0";case 1:return"4:2:0";case 2:return"4:2:2";case 3:return"4:4:4";default:return"Unknown"}}static getProfileString(e){switch(e){case 1:return"Main";case 2:return"Main10";case 3:return"MainSP";case 4:return"Rext";case 9:return"SCC";default:return"Unknown"}}static getLevelString(e){return(e/30).toFixed(1)}}function Xn(e){let t={codecWidth:0,codecHeight:0,videoType:Ci,width:0,height:0,profile:0,level:0};e=e.slice(5);do{let i={};if(e.length<23){console.warn("parseHEVCDecoderConfigurationRecord$2",`arrayBuffer.length ${e.length} < 23`);break}if(i.configurationVersion=e[0],1!=i.configurationVersion)break;i.general_profile_space=e[1]>>6&3,i.general_tier_flag=e[1]>>5&1,i.general_profile_idc=31&e[1],i.general_profile_compatibility_flags=e[2]<<24|e[3]<<16|e[4]<<8|e[5],i.general_constraint_indicator_flags=e[6]<<24|e[7]<<16|e[8]<<8|e[9],i.general_constraint_indicator_flags=i.general_constraint_indicator_flags<<16|e[10]<<8|e[11],i.general_level_idc=e[12],i.min_spatial_segmentation_idc=(15&e[13])<<8|e[14],i.parallelismType=3&e[15],i.chromaFormat=3&e[16],i.bitDepthLumaMinus8=7&e[17],i.bitDepthChromaMinus8=7&e[18],i.avgFrameRate=e[19]<<8|e[20],i.constantFrameRate=e[21]>>6&3,i.numTemporalLayers=e[21]>>3&7,i.temporalIdNested=e[21]>>2&1,i.lengthSizeMinusOne=3&e[21];let r=e[22],s=e.slice(23);for(let e=0;e<r&&!(s.length<3);e++){let e=63&s[0],r=s[1]<<8|s[2];s=s.slice(3);for(let a=0;a<r&&!(s.length<2);a++){let r=s[0]<<8|s[1];if(s.length<2+r)break;if(s=s.slice(2),33==e){let e=new Uint8Array(r);e.set(s.slice(0,r),0),i.psps=Jn(e,i),t.profile=i.general_profile_idc,t.level=i.general_level_idc/30,t.width=i.psps.pic_width_in_luma_samples-(i.psps.conf_win_left_offset+i.psps.conf_win_right_offset),t.height=i.psps.pic_height_in_luma_samples-(i.psps.conf_win_top_offset+i.psps.conf_win_bottom_offset)}s=s.slice(r)}}}while(0);return t.codecWidth=t.width||1920,t.codecHeight=t.height||1080,t.presentHeight=t.codecHeight,t.presentWidth=t.codecWidth,t.timescale=1e3,t.refSampleDuration=1e3/23976*1e3,t}function Jn(e,t){let i={},r=e.length,s=[],a=new Fn(e);a.read(1),a.read(6),a.read(6),a.read(3);for(let e=2;e<r;e++)e+2<r&&3==a.look(24)?(s.push(a.read(8)),s.push(a.read(8)),e+=2,a.read(8)):s.push(a.read(8));let n=new Uint8Array(s),o=new Fn(n);if(i.sps_video_parameter_set_id=o.read(4),i.sps_max_sub_layers_minus1=o.read(3),i.sps_temporal_id_nesting_flag=o.read(1),i.profile_tier_level=function(e,t,i){let r={};r.profile_space=e.read(2),r.tier_flag=e.read(1),r.profile_idc=e.read(5),r.profile_compatibility_flags=e.read(32),r.general_progressive_source_flag=e.read(1),r.general_interlaced_source_flag=e.read(1),r.general_non_packed_constraint_flag=e.read(1),r.general_frame_only_constraint_flag=e.read(1),e.read(32),e.read(12),r.level_idc=e.read(8),r.sub_layer_profile_present_flag=[],r.sub_layer_level_present_flag=[];for(let t=0;t<i;t++)r.sub_layer_profile_present_flag[t]=e.read(1),r.sub_layer_level_present_flag[t]=e.read(1);if(i>0)for(let t=i;t<8;t++)e.read(2);r.sub_layer_profile_space=[],r.sub_layer_tier_flag=[],r.sub_layer_profile_idc=[],r.sub_layer_profile_compatibility_flag=[],r.sub_layer_progressive_source_flag=[],r.sub_layer_interlaced_source_flag=[],r.sub_layer_non_packed_constraint_flag=[],r.sub_layer_frame_only_constraint_flag=[],r.sub_layer_level_idc=[];for(let t=0;t<i;t++)r.sub_layer_profile_present_flag[t]&&(r.sub_layer_profile_space[t]=e.read(2),r.sub_layer_tier_flag[t]=e.read(1),r.sub_layer_profile_idc[t]=e.read(5),r.sub_layer_profile_compatibility_flag[t]=e.read(32),r.sub_layer_progressive_source_flag[t]=e.read(1),r.sub_layer_interlaced_source_flag[t]=e.read(1),r.sub_layer_non_packed_constraint_flag[t]=e.read(1),r.sub_layer_frame_only_constraint_flag[t]=e.read(1),e.read(32),e.read(12)),r.sub_layer_level_present_flag[t]?r.sub_layer_level_idc[t]=e.read(8):r.sub_layer_level_idc[t]=1;return r}(o,0,i.sps_max_sub_layers_minus1),i.sps_seq_parameter_set_id=o.read_golomb(),i.chroma_format_idc=o.read_golomb(),3==i.chroma_format_idc?i.separate_colour_plane_flag=o.read(1):i.separate_colour_plane_flag=0,i.pic_width_in_luma_samples=o.read_golomb(),i.pic_height_in_luma_samples=o.read_golomb(),i.conformance_window_flag=o.read(1),i.conformance_window_flag){let e=1+(i.chroma_format_idc<2),t=1+(i.chroma_format_idc<3);i.conf_win_left_offset=o.read_golomb()*t,i.conf_win_right_offset=o.read_golomb()*t,i.conf_win_top_offset=o.read_golomb()*e,i.conf_win_bottom_offset=o.read_golomb()*e}else i.conf_win_left_offset=0,i.conf_win_right_offset=0,i.conf_win_top_offset=0,i.conf_win_bottom_offset=0;return i}function Zn({vps:e,pps:t,sps:i}){let r={configurationVersion:1};const s=(e=>{let t=$n(e),i=new Mn(t);return i.readByte(),i.readByte(),i.readBits(4),i.readBits(2),i.readBits(6),{num_temporal_layers:i.readBits(3)+1,temporal_id_nested:i.readBool()}})(e),a=(e=>{let t=$n(e),i=new Mn(t);i.readByte(),i.readByte();let r=0,s=0,a=0,n=0;i.readBits(4);let o=i.readBits(3);i.readBool();let l=i.readBits(2),d=i.readBool(),h=i.readBits(5),c=i.readByte(),u=i.readByte(),p=i.readByte(),f=i.readByte(),y=i.readByte(),m=i.readByte(),g=i.readByte(),A=i.readByte(),v=i.readByte(),b=i.readByte(),_=i.readByte(),w=[],E=[];for(let e=0;e<o;e++)w.push(i.readBool()),E.push(i.readBool());if(o>0)for(let e=o;e<8;e++)i.readBits(2);for(let e=0;e<o;e++)w[e]&&(i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte()),w[e]&&i.readByte();i.readUEG();let S=i.readUEG();3==S&&i.readBits(1);let T=i.readUEG(),k=i.readUEG();i.readBool()&&(r+=i.readUEG(),s+=i.readUEG(),a+=i.readUEG(),n+=i.readUEG());let C=i.readUEG(),D=i.readUEG(),R=i.readUEG();for(let e=i.readBool()?0:o;e<=o;e++)i.readUEG(),i.readUEG(),i.readUEG();if(i.readUEG(),i.readUEG(),i.readUEG(),i.readUEG(),i.readUEG(),i.readUEG(),i.readBool()&&i.readBool())for(let e=0;e<4;e++)for(let t=0;t<(3===e?2:6);t++)if(i.readBool()){let t=Math.min(64,1<<4+(e<<1));e>1&&i.readSEG();for(let e=0;e<t;e++)i.readSEG()}else i.readUEG();i.readBool(),i.readBool(),i.readBool()&&(i.readByte(),i.readUEG(),i.readUEG(),i.readBool());let x=i.readUEG(),L=0;for(let e=0;e<x;e++){let t=!1;if(0!==e&&(t=i.readBool()),t){e===x&&i.readUEG(),i.readBool(),i.readUEG();let t=0;for(let e=0;e<=L;e++){let e=i.readBool(),r=!1;e||(r=i.readBool()),(e||r)&&t++}L=t}else{let e=i.readUEG(),t=i.readUEG();L=e+t;for(let t=0;t<e;t++)i.readUEG(),i.readBool();for(let e=0;e<t;e++)i.readUEG(),i.readBool()}}if(i.readBool()){let e=i.readUEG();for(let t=0;t<e;t++){for(let e=0;e<R+4;e++)i.readBits(1);i.readBits(1)}}let I=!1,P=0,B=1,M=1,U=!1,F=1,O=1;if(i.readBool(),i.readBool(),i.readBool()){if(i.readBool()){let e=i.readByte();e>0&&e<16?(B=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][e-1],M=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][e-1]):255===e&&(B=i.readBits(16),M=i.readBits(16))}if(i.readBool()&&i.readBool(),i.readBool()&&(i.readBits(3),i.readBool(),i.readBool()&&(i.readByte(),i.readByte(),i.readByte())),i.readBool()&&(i.readUEG(),i.readUEG()),i.readBool(),i.readBool(),i.readBool(),I=i.readBool(),I&&(r+=i.readUEG(),s+=i.readUEG(),a+=i.readUEG(),n+=i.readUEG()),i.readBool()&&(F=i.readBits(32),O=i.readBits(32),i.readBool()&&(i.readUEG(),i.readBool()))){let e=!1,t=!1,r=!1;e=i.readBool(),t=i.readBool(),(e||t)&&(r=i.readBool(),r&&(i.readByte(),i.readBits(5),i.readBool(),i.readBits(5)),i.readBits(4),i.readBits(4),r&&i.readBits(4),i.readBits(5),i.readBits(5),i.readBits(5));for(let s=0;s<=o;s++){let s=i.readBool();U=s;let a=!1,n=1;s||(a=i.readBool());let o=!1;if(a?i.readSEG():o=i.readBool(),o||(cpbcnt=i.readUEG()+1),e)for(let e=0;e<n;e++)i.readUEG(),i.readUEG(),r&&(i.readUEG(),i.readUEG());if(t)for(let e=0;e<n;e++)i.readUEG(),i.readUEG(),r&&(i.readUEG(),i.readUEG())}}i.readBool()&&(i.readBool(),i.readBool(),i.readBool(),P=i.readUEG(),i.readUEG(),i.readUEG(),i.readUEG(),i.readUEG())}i.readBool();let N=`hvc1.${h}.1.L${_}.B0`,G=T,z=k,W=1;return 1!==B&&1!==M&&(W=B/M),i.destroy(),i=null,{codec_mimetype:N,level_string:(V=_,(V/30).toFixed(1)),profile_idc:h,bit_depth:C+8,ref_frames:1,chroma_format:S,chroma_format_string:jn(S),general_level_idc:_,general_profile_space:l,general_tier_flag:d,general_profile_idc:h,general_profile_compatibility_flags_1:c,general_profile_compatibility_flags_2:u,general_profile_compatibility_flags_3:p,general_profile_compatibility_flags_4:f,general_constraint_indicator_flags_1:y,general_constraint_indicator_flags_2:m,general_constraint_indicator_flags_3:g,general_constraint_indicator_flags_4:A,general_constraint_indicator_flags_5:v,general_constraint_indicator_flags_6:b,min_spatial_segmentation_idc:P,constant_frame_rate:0,chroma_format_idc:S,bit_depth_luma_minus8:C,bit_depth_chroma_minus8:D,frame_rate:{fixed:U,fps:O/F,fps_den:F,fps_num:O},sar_ratio:{width:B,height:M},codec_size:{width:G,height:z},present_size:{width:G*W,height:z}};var V})(i),n=(e=>{let t=$n(e),i=new Mn(t);i.readByte(),i.readByte(),i.readUEG(),i.readUEG(),i.readBool(),i.readBool(),i.readBits(3),i.readBool(),i.readBool(),i.readUEG(),i.readUEG(),i.readSEG(),i.readBool(),i.readBool(),i.readBool()&&i.readUEG(),i.readSEG(),i.readSEG(),i.readBool(),i.readBool(),i.readBool(),i.readBool();let r=i.readBool(),s=i.readBool(),a=1;return s&&r?a=0:s?a=3:r&&(a=2),{parallelismType:a}})(t);r=Object.assign(r,s,a,n);let o=23+(5+e.byteLength)+(5+i.byteLength)+(5+t.byteLength),l=new Uint8Array(o);l[0]=1,l[1]=(3&r.general_profile_space)<<6|(r.general_tier_flag?1:0)<<5|31&r.general_profile_idc,l[2]=r.general_profile_compatibility_flags_1||0,l[3]=r.general_profile_compatibility_flags_2||0,l[4]=r.general_profile_compatibility_flags_3||0,l[5]=r.general_profile_compatibility_flags_4||0,l[6]=r.general_constraint_indicator_flags_1||0,l[7]=r.general_constraint_indicator_flags_2||0,l[8]=r.general_constraint_indicator_flags_3||0,l[9]=r.general_constraint_indicator_flags_4||0,l[10]=r.general_constraint_indicator_flags_5||0,l[11]=r.general_constraint_indicator_flags_6||0,l[12]=60,l[13]=240|(3840&r.min_spatial_segmentation_idc)>>8,l[14]=255&r.min_spatial_segmentation_idc,l[15]=252|3&r.parallelismType,l[16]=252|3&r.chroma_format_idc,l[17]=248|7&r.bit_depth_luma_minus8,l[18]=248|7&r.bit_depth_chroma_minus8,l[19]=0,l[20]=0,l[21]=(3&r.constant_frame_rate)<<6|(7&r.num_temporal_layers)<<3|(r.temporal_id_nested?1:0)<<2|3,l[22]=3,l[23]=128|Ct,l[24]=0,l[25]=1,l[26]=(65280&e.byteLength)>>8,l[27]=255&e.byteLength,l.set(e,28),l[23+(5+e.byteLength)+0]=128|Dt,l[23+(5+e.byteLength)+1]=0,l[23+(5+e.byteLength)+2]=1,l[23+(5+e.byteLength)+3]=(65280&i.byteLength)>>8,l[23+(5+e.byteLength)+4]=255&i.byteLength,l.set(i,23+(5+e.byteLength)+5),l[23+(5+e.byteLength+5+i.byteLength)+0]=128|Rt,l[23+(5+e.byteLength+5+i.byteLength)+1]=0,l[23+(5+e.byteLength+5+i.byteLength)+2]=1,l[23+(5+e.byteLength+5+i.byteLength)+3]=(65280&t.byteLength)>>8,l[23+(5+e.byteLength+5+i.byteLength)+4]=255&t.byteLength,l.set(t,23+(5+e.byteLength+5+i.byteLength)+5);const d=[28,0,0,0,0],h=new Uint8Array(d.length+l.byteLength);return h.set(d,0),h.set(l,d.length),h}function eo(e,t){let i=[];i[0]=t?28:44,i[1]=1,i[2]=0,i[3]=0,i[4]=0;const r=new Uint8Array(i.length+e.byteLength);return r.set(i,0),r.set(e,i.length),r}function to(e){return(126&e[0])>>1}function io(e){return!function(e){return e>=32&&e<=40}(e)}function ro(e){return e>=16&&e<=21}class so extends t{constructor(e){super(),this.TAG_NAME="recorderCommon",this.player=e,this.fileName="",this._isRecording=!1,this._recordingTimestamp=0,this.recordingInterval=null,this.sps=null,this.pps=null,this.vps=null,this.codecId=null,this.audioCodeId=null,this.metaInfo={codecWidth:0,codecHeight:0,presentWidth:0,presentHeight:0,refSampleDuration:0,timescale:1e3,avcc:null,videoType:""},this.audioMetaInfo={timescale:1e3,sampleRate:0,refSampleDuration:0,channelCount:0,codec:"",originalCodec:"",audioType:"",extraData:new Uint8Array(0)}}destroy(){this._reset(),this.sps=null,this.pps=null,this.vps=null,this.codecId=null,this.audioCodeId=null,this.metaInfo=null,this.audioMetaInfo=null}get isH264(){return this.codecId===gt}get isH265(){return this.codecId===At}setFileName(e){this.fileName=e}get isRecording(){return this._isRecording}get recording(){return this._isRecording}get recordTime(){return this._recordingTimestamp}startRecord(){}handleAddNaluTrack(e,t,i,r){}handleAddAudioTrack(e,t){}handleAddTrack(e){}stopRecordAndSave(){}startRecordingInterval(){}isWasmMp4(){return!1}stopRecordingInterval(){this.recordingInterval&&clearInterval(this.recordingInterval),this.recordingInterval=null}getToTalByteLength(){return 0}_reset(){this.fileName="",this._isRecording=!1,this._recordingTimestamp=0,this.stopRecordingInterval()}initMetaData(e,t){let i;const r=e.slice(5);if(this.codecId=t,this.metaInfo.avcc=r,t===gt)i=On(r);else if(t===At){i=function(e){let t=23;const i=e[t];if((63&i)!==Ct)return console.warn(`parseHEVCDecoderVPSAndSPSAndPPS and vpsTag is ${i}`),{};t+=2,t+=1;const r=e[t+1]|e[t]<<8;t+=2;const s=e.slice(t,t+r);t+=r;const a=e[t];if((63&a)!==Dt)return console.warn(`parseHEVCDecoderVPSAndSPSAndPPS and sps tag is ${a}`),{};t+=2,t+=1;const n=e[t+1]|e[t]<<8;t+=2;const o=e.slice(t,t+n);t+=n;const l=e[t];if((63&l)!==Rt)return console.warn(`parseHEVCDecoderVPSAndSPSAndPPS and pps tag is ${l}`),{};t+=2,t+=1;const d=e[t+1]|e[t]<<8;t+=2;const h=e.slice(t,t+d),c=new Uint8Array([n>>>24&255,n>>>16&255,n>>>8&255,255&n]),u=new Uint8Array([d>>>24&255,d>>>16&255,d>>>8&255,255&d]),p=new Uint8Array([r>>>24&255,r>>>16&255,r>>>8&255,255&r]),f=new Uint8Array(n+4);f.set(c,0),f.set(o,4);const y=new Uint8Array(d+4);y.set(u,0),y.set(h,4);const m=new Uint8Array(r+4);return m.set(p,0),m.set(s,4),{sps:f,pps:y,vps:m}}(r);const t=Xn(e);i=Object.assign(i,t)}i&&(i.vps&&(this.vps=i.vps),i.pps&&(this.pps=i.pps),i.sps&&(this.sps=i.sps),i.presentWidth&&(this.metaInfo.presentWidth=i.presentWidth),i.presentHeight&&(this.metaInfo.presentHeight=i.presentHeight),i.codecWidth&&(this.metaInfo.codecWidth=i.codecWidth),i.codecHeight&&(this.metaInfo.codecHeight=i.codecHeight),i.timescale&&(this.metaInfo.timescale=i.timescale),i.refSampleDuration&&(this.metaInfo.refSampleDuration=i.refSampleDuration),i.videoType&&(this.metaInfo.videoType=i.videoType))}initAudioMetaData(e,t){this.audioCodeId=t;const i=e[0]>>1&1;let r=null;t===_t.AAC?(r=function(e){let t={},i=new hs(e);return i.read(16),t.object_type=cs(i),t.sample_rate=us(i,t),t.chan_config=i.read(4),t.chan_config<fs.length&&(t.channels=fs[t.chan_config]),t.sbr=-1,t.ps=-1,5!=t.object_type&&29!=t.object_type||(29==t.object_type&&(t.ps=1),t.ext_object_type=5,t.sbr=1,t.sample_rate=us(i,t),t.object_type=cs(i)),{...t,channelCount:t.channels,sampleRate:t.sample_rate}}(e),r&&(r.channelCount&&(this.audioMetaInfo.channelCount=r.channelCount),r.codec&&(this.audioMetaInfo.codec=r.codec),r.originalCodec&&(this.audioMetaInfo.originalCodec=r.originalCodec),r.config&&(this.audioMetaInfo.config=r.config),r.sampleRate&&(this.audioMetaInfo.sampleRate=r.sampleRate),this.audioMetaInfo.sampleRate&&this.audioMetaInfo.timescale&&(this.audioMetaInfo.refSampleDuration=1024/this.audioMetaInfo.sampleRate*this.audioMetaInfo.timescale)),this.audioMetaInfo.depth=i?16:8,this.audioMetaInfo.extraData=e.slice(2)):this.audioMetaInfo.depth=0===i?8:16}initAudioAacExtraData(e){this.audioMetaInfo.extraData=new Uint8Array(e)}}class ao extends so{constructor(e){super(e),this.totalByteLength=0,this._startRecordingTimestamp=null,e.debug.log("RecorderRTC","init")}_reset(){super._reset(),this.totalByteLength=0,this._startRecordingTimestamp=null,this.recorder&&(this.recorder.destroy(),this.recorder=null)}destroy(){super.destroy(),this._reset(),this.player.debug.log("RecorderRTC","destroy")}getSeekableBlob(e){const t=new EBML.Reader,i=new EBML.Decoder,r=EBML.tools,s=new FileReader;return new Promise(((a,n)=>{s.onload=function(e){i.decode(this.result).forEach((function(e){t.read(e)})),t.stop();const s=r.makeMetadataSeekable(t.metadatas,t.duration,t.cues),n=this.result.slice(t.metadataSize),o=new Blob([s,n],{type:"video/mp4"});a(o)},s.readAsArrayBuffer(e)}))}startRecord(){const e=this.player.debug,t={type:"video",mimeType:"video/webm;codecs=h264",timeSlice:1e3,onTimeStamp:t=>{e.log("RecorderRTC","record timestamp :"+t),null===this._startRecordingTimestamp&&(this._startRecordingTimestamp=t),this._recordingTimestamp=(t-this._startRecordingTimestamp)/1e3},ondataavailable:t=>{this.totalByteLength+=t.size,e.log("RecorderRTC","ondataavailable",t.size)},disableLogs:!this.player._opt.debug};try{let i=null;if(this.player.getRenderType()===K?i=this.player.video.$videoElement.captureStream(25):this.player.video.mediaStream?i=this.player.video.mediaStream:this.player.isOldHls()||this.player._opt.useMSE||this.player._opt.useWCS?i=this.player.video.$videoElement.captureStream(25):this.player.isWebrtcH264()?i=this.player.webrtc.videoStream:this.player.isAliyunRtc()&&(i=this.player.video.$videoElement.captureStream(25)),!i)return e.error("RecorderRTC","startRecord error and can not create stream"),void this.player.emitError(st.recordCreateError,"can not create stream");if(this.player.audio&&this.player.audio.mediaStreamAudioDestinationNode&&this.player.audio.mediaStreamAudioDestinationNode.stream&&!this.player.audio.isStateSuspended()&&this.player.audio.hasAudio&&this.player._opt.hasAudio){const e=this.player.audio.mediaStreamAudioDestinationNode.stream;if(e.getAudioTracks().length>0){const t=e.getAudioTracks()[0];t&&t.enabled&&i.addTrack(t)}}this.recorder=Bn(i,t)}catch(t){return e.error("RecorderRTC","startRecord error",t),void this.player.emitError(st.recordCreateError,t)}this.recorder&&(this._isRecording=!0,this.player.emit(st.recording,!0),this.recorder.startRecording(),e.log("RecorderRTC","start recording"),this.player.emit(st.recordStart),this.startRecordingInterval())}startRecordingInterval(){this.stopRecordingInterval(),this.recordingInterval=window.setInterval((()=>{this.player.emit(st.recordingTimestamp,this._recordingTimestamp)}),1e3)}stopRecordAndSave(e=ft,t){return new Promise(((i,r)=>{this.recorder&&this._isRecording||r("recorder is not ready"),t&&this.setFileName(t),this.recorder.stopRecording((()=>{this.player.debug.log("RecorderRTC","stop recording");const t=(this.fileName||vs())+"."+w;if(this.recorder.getBlob(),e===yt){const e=this.recorder.getBlob();i(e),this.player.emit(st.recordBlob,e)}else i(),this.recorder.save(t);this.player.emit(st.recordEnd),this._reset(),this.player.emit(st.recording,!1)}))}))}getToTalByteLength(){return this.totalByteLength}getTotalDuration(){return this.recordTime}getType(){return w}initMetaData(){}}class no{static init(){no.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[],".mp3":[],free:[],edts:[],elst:[],stss:[]};for(let e in no.types)no.types.hasOwnProperty(e)&&(no.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let e=no.constants={};e.FTYP=new Uint8Array([105,115,111,109,0,0,2,0,105,115,111,109,105,115,111,50,97,118,99,49,109,112,52,49,0,0,0,0]),e.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),e.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSC=e.STCO=e.STTS,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.HDLR_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]),e.HDLR_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]),e.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}static box(e){let t=8,i=null,r=Array.prototype.slice.call(arguments,1),s=r.length;for(let e=0;e<s;e++)t+=r[e].byteLength;i=new Uint8Array(t),i[0]=t>>>24&255,i[1]=t>>>16&255,i[2]=t>>>8&255,i[3]=255&t,i.set(e,4);let a=8;for(let e=0;e<s;e++)i.set(r[e],a),a+=r[e].byteLength;return i}static generateInitSegment(e,t,i){let r=no.box(no.types.ftyp,no.constants.FTYP),s=no.box(no.types.free),a=8,n=new Uint8Array;i+a>=Math.pow(2,32)-1?(a=16,n=new Uint8Array(i+a),n.set(new Uint8Array([0,0,0,1]),0),n.set(no.types.mdat,4),n.set(new Uint8Array([i+8>>>56&255,i+8>>>48&255,i+8>>>40&255,i+8>>>32&255,i+8>>>24&255,i+8>>>16&255,i+8>>>8&255,i+8&255]),8)):(n=new Uint8Array(i+a),n[0]=i+8>>>24&255,n[1]=i+8>>>16&255,n[2]=i+8>>>8&255,n[3]=i+8&255,n.set(no.types.mdat,4));for(let e=0;e<t.length;e++){let i=t[e];i.duration=i.refSampleDuration*i.sequenceNumber;for(let e=0;e<i.sequenceNumber;e++){let t=i.samples[e];t.chunkOffset=r.byteLength+s.byteLength+a;let o=t.data;n.set(o,a),a+=o.byteLength}}let o=no.moov(e,t),l=new Uint8Array(r.byteLength+o.byteLength+n.byteLength+s.byteLength);return l.set(r,0),l.set(s,r.byteLength),l.set(n,r.byteLength+s.byteLength),l.set(o,r.byteLength+n.byteLength+s.byteLength),l}static moov(e,t){let i=e.timescale,r=e.duration,s=t.length,a=no.mvhd(i,r),n=new Uint8Array;for(let e=0;e<s;e++){let i=no.trak(t[e]),r=new Uint8Array(i.byteLength+n.byteLength);r.set(n,0),r.set(i,n.byteLength),n=new Uint8Array(r.byteLength),n.set(r,0)}return no.box(no.types.moov,a,n)}static mvhd(e,t){return no.box(no.types.mvhd,new Uint8Array([0,0,0,0,206,186,253,168,206,186,253,168,e>>>24&255,e>>>16&255,e>>>8&255,255&e,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,0,0,0,3]))}static trak(e){return no.box(no.types.trak,no.tkhd(e),no.mdia(e))}static tkhd(e){let t=e.id,i=e.duration,r=e.presentWidth,s=e.presentHeight;return no.box(no.types.tkhd,new Uint8Array([0,0,0,15,206,186,253,168,206,186,253,168,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,0,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,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>>8&255,255&r,0,0,s>>>8&255,255&s,0,0]))}static edts(e,t){return no.box(no.types.edts,no.elst(e,t))}static elst(e,t){let i=0;for(let r=0;r<t;r++)"video"===e[r].type&&(i+=e[r].duration);let r=e[t].duration;return 0===i&&(i=e[t].refSampleDuration),no.box(no.types.elst,new Uint8Array([0,0,0,0,0,0,0,2,i>>>24&255,i>>>16&255,i>>>8&255,255&i,255,255,255,255,0,1,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r,0,0,0,0,0,1,0,0]))}static mdia(e){return no.box(no.types.mdia,no.mdhd(e),no.hdlr(e),no.minf(e))}static mdhd(e){let t=e.timescale/e.refSampleDuration,i=t*e.duration/e.timescale;return no.box(no.types.mdhd,new Uint8Array([0,0,0,0,206,186,253,168,206,186,253,168,t>>>24&255,t>>>16&255,t>>>8&255,255&t,i>>>24&255,i>>>16&255,i>>>8&255,255&i,85,196,0,0]))}static hdlr(e){let t=null;return t=no.constants.HDLR_VIDEO,no.box(no.types.hdlr,t)}static minf(e){let t=null;return t=no.box(no.types.vmhd,no.constants.VMHD),no.box(no.types.minf,t,no.dinf(),no.stbl(e))}static dinf(){return no.box(no.types.dinf,no.box(no.types.dref,no.constants.DREF))}static stbl(e){let t=e.samples,i=[{No:1,num:0,sampleDelte:1,chunkNo:1,duration:t[0].duration}],r=[t[0].duration],s=t.length;for(let e=0;e<s;e++)for(let s=0;s<i.length;s++)t[e].duration===i[s].duration?i[s].num++:r.indexOf(t[e].duration)<0&&(r.push(t[e].duration),i.push({No:2,num:0,sampleDelte:1,chunkNo:e+1,duration:t[e].duration}));return no.box(no.types.stbl,no.stsd(e),no.stts(i),no.stss(t),no.stsc(i),no.stsz(t),no.stco(i,t))}static stts(e){let t=e.length,i=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t]),r=i.byteLength,s=new Uint8Array(r+8*t);s.set(i,0);for(let i=0;i<t;i++)s.set(new Uint8Array([e[i].num>>>24&255,e[i].num>>>16&255,e[i].num>>>8&255,255&e[i].num,e[i].sampleDelte>>>24&255,e[i].sampleDelte>>>16&255,e[i].sampleDelte>>>8&255,255&e[i].sampleDelte]),r),r+=8;return no.box(no.types.stts,s)}static stss(e){let t=[],i=e.length;for(let r=0;r<i;r++)!0===e[r].isKeyframe&&t.push(r+1);let r=t.length,s=new Uint8Array([0,0,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r]),a=s.byteLength,n=new Uint8Array(a+4*r);n.set(s,0);for(let e=0;e<r;e++)n.set(new Uint8Array([t[e]>>>24&255,t[e]>>>16&255,t[e]>>>8&255,255&t[e]]),a),a+=4;return no.box(no.types.stss,n)}static stsc(e){let t=e.length,i=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t]),r=i.byteLength,s=new Uint8Array(r+12*t);s.set(i,0);for(let i=0;i<t;i++){let t=e[i].chunkNo,a=e[i].num,n=e[i].sampleDelte;s.set(new Uint8Array([t>>>24&255,t>>>16&255,t>>>8&255,255&t,a>>>24&255,a>>>16&255,a>>>8&255,255&a,n>>>24&255,n>>>16&255,n>>>8&255,255&n]),r),r+=12}return no.box(no.types.stsc,s)}static stsz(e){let t=e.length,i=new Uint8Array([0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t]),r=i.byteLength,s=new Uint8Array(r+4*t);s.set(i,0);for(let i=0;i<t;i++){let t=e[i].data.byteLength;s.set(new Uint8Array([t>>>24&255,t>>>16&255,t>>>8&255,255&t]),r),r+=4}return no.box(no.types.stsz,s)}static stco(e,t){let i=t[0].chunkOffset;return no.box(no.types.stco,new Uint8Array([0,0,0,0,0,0,0,1,i>>>24&255,i>>>16&255,i>>>8&255,255&i]))}static stsd(e){return"audio"===e.type?"mp3"===e.codec?no.box(no.types.stsd,no.constants.STSD_PREFIX,no.mp3(e)):no.box(no.types.stsd,no.constants.STSD_PREFIX,no.mp4a(e)):"avc"===e.videoType?no.box(no.types.stsd,no.constants.STSD_PREFIX,no.avc1(e)):no.box(no.types.stsd,no.constants.STSD_PREFIX,no.hvc1(e))}static mp3(e){let t=e.channelCount,i=e.sampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,i>>>8&255,255&i,0,0]);return no.box(no.types[".mp3"],r)}static mp4a(e){let t=e.channelCount,i=e.sampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,i>>>8&255,255&i,0,0]);return no.box(no.types.mp4a,r,no.esds(e))}static esds(e){let t=e.config||[],i=t.length,r=new Uint8Array([0,0,0,0,3,23+i,0,1,0,4,15+i,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([i]).concat(t).concat([6,1,2]));return no.box(no.types.esds,r)}static avc1(e){let t=e.avcc,i=e.codecWidth,r=e.codecHeight,s=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,i>>>8&255,255&i,r>>>8&255,255&r,0,72,0,0,0,72,0,0,0,0,0,0,0,1,13,106,101,115,115,105,98,117,99,97,45,112,114,111,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return no.box(no.types.avc1,s,no.box(no.types.avcC,t))}static hvc1(e){let t=e.avcc;const i=e.codecWidth,r=e.codecHeight;let s=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,i>>>8&255,255&i,r>>>8&255,255&r,0,72,0,0,0,72,0,0,0,0,0,0,0,1,13,106,101,115,115,105,98,117,99,97,45,112,114,111,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return no.box(no.types.hvc1,s,no.box(no.types.hvcC,t))}static mvex(e){return no.box(no.types.mvex,no.trex(e))}static trex(e){let t=e.id,i=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return no.box(no.types.trex,i)}static moof(e,t){return no.box(no.types.moof,no.mfhd(e.sequenceNumber),no.traf(e,t))}static mfhd(e){let t=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e]);return no.box(no.types.mfhd,t)}static traf(e,t){let i=e.id,r=no.box(no.types.tfhd,new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i])),s=no.box(no.types.tfdt,new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t])),a=no.sdtp(e),n=no.trun(e,a.byteLength+16+16+8+16+8+8);return no.box(no.types.traf,r,s,n,a)}static sdtp(e){let t=e.samples||[],i=t.length,r=new Uint8Array(4+i);for(let e=0;e<i;e++){let i=t[e].flags;r[e+4]=i.isLeading<<6|i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy}return no.box(no.types.sdtp,r)}static trun(e,t){let i=e.samples||[],r=i.length,s=12+16*r,a=new Uint8Array(s);t+=8+s,a.set([0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,255&r,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0);for(let e=0;e<r;e++){let t=i[e].duration,r=i[e].size,s=i[e].flags,n=i[e].cts;a.set([t>>>24&255,t>>>16&255,t>>>8&255,255&t,r>>>24&255,r>>>16&255,r>>>8&255,255&r,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.isNonSync,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n],12+16*e)}return no.box(no.types.trun,a)}static mdat(e){return no.box(no.types.mdat,e)}}no.init();class oo extends so{constructor(e){super(e),this.TAG_NAME="recorderMP4",this._reset(),e.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this._reset(),this.player.debug.log(this.TAG_NAME,"destroy")}_reset(){super._reset(),this.totalDuration=0,this.totalAudioDuration=0,this.totalByteLength=0,this.totalAudioByteLength=0,this.bufferList=[],this.audioBufferList=[],this.cacheTrack={},this.audioCacheTrack={},this.sequenceNumber=0,this.audioSequenceNumber=0}startRecord(){const e=this.player.debug;this._isRecording=!0,this.player.emit(st.recording,!0),e.log(this.TAG_NAME,"start recording"),this.player.emit(st.recordStart),this.startRecordingInterval()}startRecordingInterval(){this.stopRecordingInterval(),this.recordingInterval=window.setInterval((()=>{this.player.emit(st.recordingTimestamp,this.getTotalDuration())}),1e3)}formatFmp4Track(e,t,i,r){return{id:1,sequenceNumber:++this.sequenceNumber,size:e.byteLength,dts:i,cts:r,isKeyframe:t,data:e,duration:0,flags:{isLeading:0,dependsOn:t?2:1,isDependedOn:t?1:0,hasRedundancy:0,isNonSync:t?0:1}}}formatAudioFmp4Track(e,t){return{id:2,sequenceNumber:++this.audioSequenceNumber,size:e.byteLength,dts:t,pts:t,cts:0,data:new Uint8Array(e),duration:0,originalDts:t,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}}handleAddNaluTrack(e,t,i,r){this.cacheTrack.id&&i>=this.cacheTrack.dts?(this.cacheTrack.duration=i-this.cacheTrack.dts,this.handleAddFmp4Track(this.cacheTrack)):this.cacheTrack={},this.cacheTrack=this.formatFmp4Track(e,t,i,r)}handleAddAudioTrack(e,t){}handleAddFmp4Track(e){if(!this.isRecording)return void this.player.debug.error(this.TAG_NAME,"handleAddFmp4Track, isRecording is false ");if((null===this.sps||null===this.pps)&&this.isH264)return void this.player.debug.error(this.TAG_NAME,"handleAddFmp4Track, is h264 and this.sps or this.pps is null ");if((null===this.sps||null===this.pps||null===this.vps)&&this.isH265)return void this.player.debug.error(this.TAG_NAME,"handleAddFmp4Track, is h265 and this.sps or this.pps or this.vps is null ");const t=Object.assign({},e);t.pts=t.dts+t.cts;const i=t.data;if(t.isKeyframe)if(this.isH264){const e=new Uint8Array(this.sps.byteLength+this.pps.byteLength);e.set(this.sps,0),e.set(this.pps,this.sps.byteLength);const r=new Uint8Array(e.byteLength+i.byteLength);r.set(e,0),r.set(i,e.byteLength),t.data=r}else if(this.isH265){const e=new Uint8Array(this.sps.byteLength+this.pps.byteLength+this.vps.byteLength);e.set(this.vps,0),e.set(this.sps,this.vps.byteLength),e.set(this.pps,this.vps.byteLength+this.sps.byteLength);const r=new Uint8Array(e.byteLength+i.byteLength);r.set(e,0),r.set(i,e.byteLength),t.data=r}t.size=t.data.byteLength,this.totalDuration+=t.duration,this.totalByteLength+=t.data.byteLength,t.duration=0,t.originalDts=t.dts,delete t.id,delete t.sequenceNumber,this.bufferList.push(t)}handleAddFmp4AudioTrack(e){const t=Object.assign({},e);t.pts=t.dts+t.cts,t.size=t.data.byteLength,this.totalAudioDuration+=t.duration,this.totalAudioByteLength+=t.data.byteLength,t.duration=0,t.originalDts=t.dts,delete t.id,delete t.sequenceNumber,this.audioBufferList.push(t)}getTotalDuration(){return this.totalDuration/1e3}getType(){return _}getToTalByteLength(){return this.totalByteLength+this.totalAudioByteLength}stopRecordAndSave(e=ft,t){return new Promise(((i,r)=>{if(!this.isRecording)return this.player.debug.error(this.TAG_NAME,"stop recording fail, isRecording is false "),r("stop recording fail, isRecording is false ");if(0===this.bufferList.length)return this.player.debug.error(this.TAG_NAME,"stop recording fail, this.bufferList.length is 0 "),r("stop recording fail, this.bufferList.length is 0 ");t&&this.setFileName(t);const s={id:1,type:"video",sps:this.sps,pps:this.pps,samples:this.bufferList,sequenceNumber:this.bufferList.length,length:0,addSampleNum:1,duration:0,...this.metaInfo},a={id:2,type:"audio",sequenceNumber:this.audioBufferList.length,samples:this.audioBufferList,...this.audioMetaInfo},n=[s];a.samples.length>0&&n.push(a),this.player.debug.log(this.TAG_NAME,`trackList length is ${n.length}`);const o=no.generateInitSegment({timescale:1e3,duration:this.totalDuration},n,this.totalByteLength+this.totalAudioByteLength);this.player.debug.log(this.TAG_NAME,"stop recording");const l=new Blob([o],{type:"application/octet-stream"});if(e===yt)i(l),this.player.emit(st.recordBlob,l);else{i();Hs((this.fileName||vs())+"."+_,l)}this.player.emit(st.recordEnd),this._reset(),this.player.emit(st.recording,!1)}))}}class lo extends so{constructor(e){super(e),this.TAG_NAME="FlvRecorderLoader",this.player=e,this._init(),this.player.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this._init(),this.player.debug.log(this.TAG_NAME,"destroy")}_init(){this.hasAudio=!1,this.hasVideo=!1,this.startTime=null,this.currentTime=0,this.prevTimestamp=0,this.totalByteLength=0,this.totalDuration=0,this.flvMetaData=null,this.aacSequenceHeader=null,this.videoSequenceHeader=null,this.bufferList=[]}_reset(){super._reset(),this._init()}startRecord(){const e=this.player.debug;this._isRecording=!0,this.player.emit(st.recording,!0),e.log(this.TAG_NAME,"start recording"),this.player.emit(st.recordStart),this.startRecordingInterval()}startRecordingInterval(){this.stopRecordingInterval(),this.recordingInterval=window.setInterval((()=>{this.player.emit(st.recordingTimestamp,this.getTotalDuration())}),1e3)}addMetaData(e){this.flvMetaData=e}addAACSequenceHeader(e){this.aacSequenceHeader=e}addVideoSequenceHeader(e){this.videoSequenceHeader=e}addVideo(e,t){this._setStartTime(t);const i=this._getBufferTs(t);this.hasVideo=!0,this._createBufferItem(e,ze,i)}addAudio(e,t){this._setStartTime(t);const i=this._getBufferTs(t);this.hasAudio=!0,this._createBufferItem(e,Ge,i)}_setStartTime(e){null===this.startTime&&this._isRecording&&(this.startTime=e,this.player.debug.log(this.TAG_NAME,`_setStartTime is ${e}`))}_getBufferTs(e){e>this.currentTime&&(this.currentTime=e);let t=0;return this.startTime&&e>=this.startTime&&(t=e-this.startTime),t>this.prevTimestamp?this.prevTimestamp=t:t=this.prevTimestamp,t}_createBufferItem(e,t,i){const r=this._createFlvPacket(e,t,i),s=this._createFlvTag(r);this.totalByteLength+=s.byteLength,this.bufferList.push(s)}_createFlvTag(e){let t=11+e.header.length,i=new Uint8Array(t+4);i[0]=e.header.type;let r=new DataView(i.buffer);return i[1]=e.header.length>>16&255,i[2]=e.header.length>>8&255,i[3]=255&e.header.length,i[4]=e.header.timestamp>>16&255,i[5]=e.header.timestamp>>8&255,i[6]=255&e.header.timestamp,i[7]=e.header.timestamp>>24&255,i[8]=0,i[9]=0,i[10]=0,r.setUint32(t,t),i.set(e.payload.subarray(0,e.header.length),11),i}_createFlvPacket(e=null,t=0,i=0){return{header:{length:e?e.length:0,timestamp:i,type:t},payload:e}}stopRecordAndSave(e=ft,t){return new Promise(((i,r)=>{if(!this.isRecording)return this.player.debug.error(this.TAG_NAME,"stop recording fail, isRecording is false "),r("stop recording fail, isRecording is false ");if(0===this.bufferList.length)return this.player.debug.error(this.TAG_NAME,"stop recording fail, this.bufferList.length is 0 "),r("stop recording fail, this.bufferList.length is 0 ");t&&this.setFileName(t);const s=new Uint8Array([70,76,86,1,0,0,0,0,9,0,0,0,0]);this.hasVideo&&(s[4]|=1),this.hasAudio&&(s[4]|=4);let a=[s];if(this.flvMetaData){const e=this._createFlvPacket(this.flvMetaData,We),t=this._createFlvTag(e);a.push(t)}if(this.videoSequenceHeader){const e=this._createFlvPacket(this.videoSequenceHeader,ze),t=this._createFlvTag(e);a.push(t)}if(this.aacSequenceHeader){const e=this._createFlvPacket(this.aacSequenceHeader,Ge),t=this._createFlvTag(e);a.push(t)}const n=function(e){const t=e[0].constructor;return e.reduce(((e,i)=>{const r=new t((0|e.byteLength)+(0|i.byteLength));return r.set(e,0),r.set(i,0|e.byteLength),r}),new t)}(a.concat(this.bufferList));this.player.debug.log(this.TAG_NAME,"stop recording");const o=new Blob([n],{type:"application/octet-stream"});if(e===yt)i(o),this.player.emit(st.recordBlob,o);else{i();Hs((this.fileName||vs())+"."+E,o)}this.player.emit(st.recordEnd),this._reset(),this.player.emit(st.recording,!1)}))}getTotalDuration(){let e=0;return null!==this.startTime&&null!==this.currentTime&&(e=this.currentTime-this.startTime),Math.round(e/1e3)}getType(){return E}getToTalByteLength(){return this.totalByteLength}}const ho={init:0,findFirstStartCode:1,findSecondStartCode:2};class co extends t{constructor(e){super(),this.player=e,this.isDestroyed=!1,this.reset()}destroy(){this.isDestroyed=!1,this.off(),this.reset()}reset(){this.stats=ho.init,this.tempBuffer=new Uint8Array(0),this.parsedOffset=0,this.versionLayer=0}dispatch(e,t){let i=new Uint8Array(this.tempBuffer.length+e.length);for(i.set(this.tempBuffer,0),i.set(e,this.tempBuffer.length),this.tempBuffer=i;!this.isDestroyed;){if(this.state==ho.Init){let e=!1;for(;this.tempBuffer.length-this.parsedOffset>=2&&!this.isDestroyed;)if(255==this.tempBuffer[this.parsedOffset]){if(!(!1&this.tempBuffer[this.parsedOffset+1])){this.versionLayer=this.tempBuffer[this.parsedOffset+1],this.state=ho.findFirstStartCode,this.fisrtStartCodeOffset=this.parsedOffset,this.parsedOffset+=2,e=!0;break}this.parsedOffset++}else this.parsedOffset++;if(e)continue;break}if(this.state==ho.findFirstStartCode){let e=!1;for(;this.tempBuffer.length-this.parsedOffset>=2&&!this.isDestroyed;)if(255==this.tempBuffer[this.parsedOffset]){if(this.tempBuffer[this.parsedOffset+1]==this.versionLayer){this.state=ho.findSecondStartCode,this.secondStartCodeOffset=this.parsedOffset,this.parsedOffset+=2,e=!0;break}this.parsedOffset++}else this.parsedOffset++;if(e)continue;break}if(this.state==ho.findSecondStartCode){let e=this.tempBuffer.slice(this.fisrtStartCodeOffset,this.secondStartCodeOffset);this.emit("data",e,t),this.tempBuffer=this.tempBuffer.slice(this.secondStartCodeOffset),this.fisrtStartCodeOffset=0,this.parsedOffset=2,this.state=ho.findFirstStartCode}}}}class uo extends so{constructor(e){super(e),this.TAG_NAME="recorderWasmMP4",this._reset(),this.wasmMp4Recorder=new window.EasyPlayerProMp4Recorder({debug:e._opt.debug,debugLevel:e._opt.debugLevel,debugUuid:e._opt.debugUuid,decoder:e._opt.wasmMp4RecorderDecoder}),this.mp3Demuxer=null,this.isG711=!1,e.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this.mp3Demuxer&&(this.mp3Demuxer.destroy(),this.mp3Demuxer=null),this.isG711=!1,this._reset(),this.player.debug.log(this.TAG_NAME,"destroy")}_reset(){super._reset(),this.cacheTrack={},this.audioCacheTrack={},this.totalDuration=0,this.totalAudioDuration=0,this.totalByteLength=0,this.totalAudioByteLength=0,this.hasAudio=!1,this.hasVideo=!1}getType(){return _}isWasmMp4(){return!0}getTotalDuration(){return this.totalDuration/1e3}getToTalByteLength(){return this.totalByteLength+this.totalAudioByteLength}startRecord(){const e=this.player.debug,t=this.player.getAudioInfo(),i=this.player.getVideoInfo(),r={};if(this.codecId){const e={type:this.codecId,width:i.width,height:i.height,extraData:this.metaInfo.avcc};r.video=e,this.hasVideo=!0}if(t.encTypeCode){this.isG711=t.encTypeCode===_t.ALAW||t.encTypeCode===_t.MULAW;const e={type:t.encTypeCode,sampleRate:t.sampleRate,channels:t.channels,extraData:this.audioMetaInfo.extraData,depth:t.depth};this.audioCodeId=t.encTypeCode,r.audio=e,this.hasAudio=!0}this.wasmMp4Recorder.startRecord(r).then((()=>{this._isRecording=!0,this.player.emit(st.recording,!0),e.log(this.TAG_NAME,"start recording"),this.player.emit(st.recordStart),this.startRecordingInterval()})).catch((t=>{e.error(this.TAG_NAME,"startRecord error",t),this.player.emitError(st.recordCreateError,t)}))}startRecordingInterval(){this.stopRecordingInterval(),this.recordingInterval=window.setInterval((()=>{this.player.emit(st.recordingTimestamp,this.getTotalDuration())}),1e3)}stopRecordAndSave(e=ft,t){return new Promise(((i,r)=>this.isRecording?0===this.totalDuration?(this.player.debug.error(this.TAG_NAME,"stop recording fail, totalDuration is 0 "),r("stop recording fail, totalDuration is 0 ")):(t&&this.setFileName(t),void this.wasmMp4Recorder.stopRecord().then((t=>{if(e===yt)i(t),this.player.emit(st.recordBlob,t);else{i();const e=this.isG711?S:_;Hs((this.fileName||vs())+"."+e,t)}})).catch((e=>{this.player.debug.error(this.TAG_NAME,"stopRecord error",e),r(e)})).finally((()=>{this.player.emit(st.recordEnd),this._reset(),this.player.emit(st.recording,!1)}))):(this.player.debug.error(this.TAG_NAME,"stop recording fail, isRecording is false "),r("stop recording fail, isRecording is false "))))}handleAddAudioTrack(e,t){this.audioCodeId===_t.MP3?(this.mp3Demuxer||(this.mp3Demuxer=new co(this.player),this.mp3Demuxer.on("data",((e,t)=>{this._handleAddAudioTrack(e,t)}))),this.mp3Demuxer.dispatch(e,t)):this._handleAddAudioTrack(e,t)}_handleAddAudioTrack(e,t){ka(this.hasAudio)||(this.audioCacheTrack.id&&t>=this.audioCacheTrack.dts?(this.audioCacheTrack.duration=t-this.audioCacheTrack.dts,this.totalAudioDuration+=this.audioCacheTrack.duration,this.totalAudioByteLength+=this.audioCacheTrack.payload.byteLength,this.wasmMp4Recorder.sendAudioFrame(this.audioCacheTrack.payload,this.audioCacheTrack.dts)):this.audioCacheTrack={},this.audioCacheTrack={id:2,payload:e,dts:t})}handleAddNaluTrack(e,t,i,r){ka(this.hasVideo)||(this.cacheTrack.id&&i>=this.cacheTrack.dts?(this.cacheTrack.duration=i-this.cacheTrack.dts,this.totalDuration+=this.cacheTrack.duration,this.totalByteLength+=this.cacheTrack.payload.byteLength,this.wasmMp4Recorder.sendVideoFrame(this.cacheTrack.payload,this.cacheTrack.isIFrame,this.cacheTrack.dts,this.cacheTrack.cts)):this.cacheTrack={},this.cacheTrack={id:1,payload:e,isIFrame:t,dts:i,cts:r})}}class po{constructor(e){return new(po.getLoaderFactory(e._opt))(e)}static getLoaderFactory(e){if(e.recordType===_){if(e.useWasm||e.useMSE||e.useWCS)return window.EasyPlayerProMp4Recorder&&e.mp4RecordUseWasm?uo:oo}else if(e.recordType===E)return lo;return ao}}function fo(e,t,i){let r=e;if(t+i<r.length){for(;i--;)if(128!=(192&r[++t]))return!1;return!0}return!1}function yo(e){let t=[],i=e,r=0,s=e.length;for(;r<s;)if(i[r]<128)t.push(String.fromCharCode(i[r])),++r;else{if(i[r]<192);else if(i[r]<224){if(fo(i,r,1)){let e=(31&i[r])<<6|63&i[r+1];if(e>=128){t.push(String.fromCharCode(65535&e)),r+=2;continue}}}else if(i[r]<240){if(fo(i,r,2)){let e=(15&i[r])<<12|(63&i[r+1])<<6|63&i[r+2];if(e>=2048&&55296!=(63488&e)){t.push(String.fromCharCode(65535&e)),r+=3;continue}}}else if(i[r]<248&&fo(i,r,3)){let e=(7&i[r])<<18|(63&i[r+1])<<12|(63&i[r+2])<<6|63&i[r+3];if(e>65536&&e<1114112){e-=65536,t.push(String.fromCharCode(e>>>10|55296)),t.push(String.fromCharCode(1023&e|56320)),r+=4;continue}}t.push(String.fromCharCode(65533)),++r}return t.join("")}let mo=function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}();class go{static parseScriptData(e,t,i){let r={};try{let s=go.parseValue(e,t,i),a=go.parseValue(e,t+s.size,i-s.size);r[s.data]=a.data}catch(e){console.error("AMF",e.toString())}return r}static parseObject(e,t,i){let r=go.parseString(e,t,i),s=go.parseValue(e,t+r.size,i-r.size),a=s.objectEnd;return{data:{name:r.data,value:s.data},size:r.size+s.size,objectEnd:a}}static parseVariable(e,t,i){return go.parseObject(e,t,i)}static parseString(e,t,i){let r,s=new DataView(e,t,i).getUint16(0,!mo);return r=s>0?yo(new Uint8Array(e,t+2,s)):"",{data:r,size:2+s}}static parseLongString(e,t,i){let r,s=new DataView(e,t,i).getUint32(0,!mo);return r=s>0?yo(new Uint8Array(e,t+4,s)):"",{data:r,size:4+s}}static parseDate(e,t,i){let r=new DataView(e,t,i),s=r.getFloat64(0,!mo);return s+=60*r.getInt16(8,!mo)*1e3,{data:new Date(s),size:10}}static parseValue(e,t,i){let r,s=new DataView(e,t,i),a=1,n=s.getUint8(0),o=!1;try{switch(n){case 0:r=s.getFloat64(1,!mo),a+=8;break;case 1:r=!!s.getUint8(1),a+=1;break;case 2:{let s=go.parseString(e,t+1,i-1);r=s.data,a+=s.size;break}case 3:{r={};let n=0;for(9==(16777215&s.getUint32(i-4,!mo))&&(n=3);a<i-4;){let s=go.parseObject(e,t+a,i-a-n);if(s.objectEnd)break;r[s.data.name]=s.data.value,a+=s.size}if(a<=i-3){9===(16777215&s.getUint32(a-1,!mo))&&(a+=3)}break}case 8:{r={},a+=4;let n=0;for(9==(16777215&s.getUint32(i-4,!mo))&&(n=3);a<i-8;){let s=go.parseVariable(e,t+a,i-a-n);if(s.objectEnd)break;r[s.data.name]=s.data.value,a+=s.size}if(a<=i-3){9===(16777215&s.getUint32(a-1,!mo))&&(a+=3)}break}case 9:r=void 0,a=1,o=!0;break;case 10:{r=[];let n=s.getUint32(1,!mo);a+=4;for(let s=0;s<n;s++){let s=go.parseValue(e,t+a,i-a);r.push(s.data),a+=s.size}break}case 11:{let s=go.parseDate(e,t+1,i-1);r=s.data,a+=s.size;break}case 12:{let s=go.parseString(e,t+1,i-1);r=s.data,a+=s.size;break}default:a=i,console.warn("AMF","Unsupported AMF value type "+n)}}catch(e){console.error("AMF",e.toString())}return{data:r,size:a,objectEnd:o}}}function Ao(e){return go.parseScriptData(e.buffer,e.byteOffset,e.byteLength)}class vo{constructor(e){this.player=e,this.destroyResolve=null,this.workerClearTimeout=null,this.workerUrl=null;let t=e._opt.decoder;if(this.decoderWorkerCloseTimeout=null,ka(this.player._opt.useWasm)&&(t=this.player._opt.demuxUseWorker?e._opt.decoderHard:e._opt.decoderAudio),0===t.indexOf("http")&&this.player._opt.isDecoderUseCDN){const e=new Blob([`importScripts("${t}")`],{type:"application/javascript"});t=window.URL.createObjectURL(e),this.workerUrl=t,this.workerClearTimeout=setTimeout((()=>{window.URL.revokeObjectURL(this.workerUrl),this.workerUrl=null,this.workerClearTimeout=null}),re)}this.decoderWorker=new Worker(t),this._initDecoderWorker(),e.debug.log("decoderWorker",`init and decoder url is ${t}`),e.on(st.visibilityChange,(()=>{this.updateWorkConfig({key:"visibility",value:e.visibility})}))}destroy(){return new Promise(((e,t)=>{this.player.loaded?(this.player.debug.log("decoderWorker","has loaded and post message to destroy"),this.decoderWorker?(this.decoderWorker.postMessage({cmd:Ke}),this.destroyResolve=e,this.decoderWorkerCloseTimeout=setTimeout((()=>{this.player.debug.warn("decoderWorker","send close but not response and destroy directly"),this.decoderWorkerCloseTimeout&&(clearTimeout(this.decoderWorkerCloseTimeout),this.decoderWorkerCloseTimeout=null),this._destroy(),setTimeout((()=>{e()}),0)}),2e3)):(this.player.debug.warn("decoderWorker","has loaded but decoderWorker is null and destroy directly"),this._destroy(),setTimeout((()=>{e()}),0))):(this.player.debug.log("decoderWorker","has not loaded and destroy directly"),this._destroy(),setTimeout((()=>{e()}),0))}))}_destroy(){this.decoderWorkerCloseTimeout&&(clearTimeout(this.decoderWorkerCloseTimeout),this.decoderWorkerCloseTimeout=null),this.workerUrl&&(window.URL.revokeObjectURL(this.workerUrl),this.workerUrl=null),this.workerClearTimeout&&(clearTimeout(this.workerClearTimeout),this.workerClearTimeout=null),this.decoderWorker&&(this.decoderWorker.terminate(),this.decoderWorker.onerror=null,this.decoderWorker.onmessageerror=null,this.decoderWorker.onmessage=null,this.decoderWorker=null),this.player.debug.log("decoderWorker","destroy"),this.destroyResolve&&(this.destroyResolve(),this.destroyResolve=null)}_initDecoderWorker(){const{debug:e,events:{proxy:t}}=this.player;this.decoderWorker.onerror=e=>{this.player.debug.error("decoderWorker","onerror",e),this.player.emitError(lt.decoderWorkerInitError,e)},this.decoderWorker.onmessageerror=e=>{this.player.debug.error("decoderWorker","onmessageerror",e)},this.decoderWorker.onmessage=t=>{const i=t.data;switch(i.cmd){case ne:e.log("decoderWorker","onmessage:",ne),this.decoderWorker&&this._initWork(),this.player.loaded||this.player.emit(st.load),this.player.emit(st.decoderWorkerInit);break;case fe:e.log("decoderWorker","onmessage:",fe,i.code),this.player._times.decodeStart||(this.player._times.decodeStart=vs()),this.player.video.updateVideoInfo({encTypeCode:i.code});break;case ye:e.log("decoderWorker","onmessage:",ye,i.codecId),this.player.recorder&&this.player.recorder.initMetaData(i.buffer,i.codecId),this.player.video.updateVideoInfo({encTypeCode:i.codecId});break;case ce:e.log("decoderWorker","onmessage:",ce,i.code),this.player.audio&&this.player.audio.updateAudioInfo({encTypeCode:i.code});break;case pe:e.log("decoderWorker","onmessage:",pe),this.player.recorder&&this.player.recorder.initAudioAacExtraData(i.buffer);break;case oe:if(e.log("decoderWorker","onmessage:",oe,`width:${i.w},height:${i.h}`),$s(i.w)||$s(i.h))return void this.player.emitError(lt.videoInfoError,`video width ${i.w} or height ${i.h} is empty`);if(this.player.video.updateVideoInfo({width:i.w,height:i.h}),!this.player._opt.openWebglAlignment&&i.w/2%4!=0&&this.player.getRenderType()===K)return void this.player.emitError(lt.webglAlignmentError);this.player.video.initCanvasViewSize(),this.player._opt.playType===b&&(this.player.video.initFps(),this.player.video.initVideoDelay());break;case he:if(e.log("decoderWorker","onmessage:",he,`channels:${i.channels},sampleRate:${i.sampleRate}`),i.channels>2)return void this.player.emitError(lt.audioChannelError,`audio channel is ${i.channels}, max is 2`);this.player.audio&&(this.player.audio.updateAudioInfo(i),this.player._opt.playType===A?this.player.audio.initScriptNode():this.player._opt.playType===b&&this.player.audio.initScriptNodeDelay());break;case le:if(!this.player.video)return void e.warn("decoderWorker","onmessage render but video is null");if(this.player.isPlayer()){if(ka(this.player.video.getHasInit()))return void e.warn("decoderWorker","onmessage render but video has not init");this.player.video.render(i),this.player.handleRender(),this.player.emit(st.timeUpdate,i.ts),this.player.updateStats({dfps:!0,buf:i.delay}),this.player._times.videoStart||(this.player._times.videoStart=vs(),this.player.handlePlayToRenderTimes())}else this.player.isPlayback()&&(this.player.updateStats({dfps:!0}),ka(this.player.playbackPause)?(this.player.playback.isUseLocalCalculateTime&&this.player.playback.increaseLocalTimestamp(),this.player.playback.isUseFpsRender?this.player.video.pushData(i):this.player.video.render$2(i)):!this.player.playback.isPlaybackPauseClearCache&&this.player.playback.isCacheBeforeDecodeForFpsRender&&this.player.playback.isUseFpsRender&&this.player.video.pushData(i));break;case me:this.player.recorder&&this.player.recorder.isRecording&&this.player._opt.recordType===_&&this.player.recorder.handleAddNaluTrack(i.buffer,i.isIFrame,i.ts,i.cts);break;case ue:this.player.recorder&&this.player.recorder.isRecording&&this.player._opt.recordType===_&&this.player.recorder.isWasmMp4()&&this.player.recorder.handleAddAudioTrack(i.buffer,i.ts);break;case ge:const{webcodecsDecoder:t,mseDecoder:r}=this.player;this.player.updateStats({buf:i.delay});const s=new Uint8Array(i.payload);this.player._opt.useWCS&&!this.player._opt.useOffscreen?t.decodeVideo(s,i.ts,i.isIFrame,i.cts):this.player._opt.useMSE&&r.decodeVideo(s,i.ts,i.isIFrame,i.cts);break;case Ae:if(this.player._opt.useMSE){const e=new Uint8Array(i.payload);this.player.mseDecoder.decodeAudio(e,i.ts,i.cts)}break;case de:if(!this.player.audio)return void e.warn("decoderWorker","onmessage playAudio but audio is null");(this.player.playing&&this.player.audio||!this.player.video)&&(this.player._opt.hasVideo||this.player.handleRender(),(this.player._opt.playType===A||this.player._opt.playType===b&&(ka(this.player.playbackPause)||!this.player.playback.isPlaybackPauseClearCache&&this.player.playback.isCacheBeforeDecodeForFpsRender&&this.player.playback.isUseFpsRender))&&this.player.audio.play(i.buffer,i.ts));break;case be:if(i.type===st.streamSuccess)this.player.stream?this.player.stream.emit(st.streamSuccess):e.warn("decoderWorker","onmessage and workerFetch response stream success but stream is null");else if(i.type===st.streamRate)this.player.emit(st.kBps,(i.value/1024).toFixed(2));else if(i.type===st.streamEnd)this.player?(i.value===u&&this.player.emit(st.websocketClose,i.msg),this.player.stream?this.player.stream.emit(st.streamEnd,i.msg):e&&e.warn("decoderWorker","onmessage and workerFetch response stream end but player.stream is null")):e&&e.warn("decoderWorker","onmessage and workerFetch response stream end but player is null");else if(i.type===lt.websocketError)this.player&&this.player.stream?this.player.stream.emit(lt.websocketError,i.value):e&&e.warn("decoderWorker","onmessage and workerFetch response websocket error but stream is null");else if(i.type===lt.fetchError)this.player&&this.player.stream?this.player.stream.emit(lt.fetchError,i.value):e&&e.warn("decoderWorker","onmessage and workerFetch response fetch error but stream is null");else if(i.type===st.streamAbps)this.player.updateStats({abps:i.value});else if(i.type===st.streamVbps)this.player._times.demuxStart||(this.player._times.demuxStart=vs()),this.player.updateStats({vbps:i.value});else if(i.type===st.streamDts)this.player.updateStats({dts:i.value});else if(i.type===st.netBuf)this.player.updateStats({netBuf:i.value});else if(i.type===st.networkDelayTimeout)this.player.emit(st.networkDelayTimeout,i.value);else if(i.type===st.streamStats){const e=JSON.parse(i.value);this.player.updateStats({workerStats:e})}else i.type===st.websocketOpen&&this.player.emit(st.websocketOpen);break;case _e:this.player&&(this.player.videoIframeIntervalTs=i.value);break;case we:this.player&&this.player.updateStats({isDropping:!0});break;case Ue:this.player.decoderCheckFirstIFrame();break;case Se:this.player&&this.player.video&&this.player.video.setStreamFps(i.value);break;case ve:i.message&&-1!==i.message.indexOf(Fe)&&this.player.emitError(lt.wasmDecodeError,"");break;case Te:this.player.emitError(lt.wasmDecodeVideoNoResponseError);break;case De:this.player.emitError(lt.simdH264DecodeVideoWidthIsTooLarge);break;case ke:this.player.emitError(lt.wasmWidthOrHeightChange);break;case Ce:this.player.emitError(lt.simdDecodeError);break;case Ee:e.log("decoderWorker","onmessage:",Ee);break;case Re:e.log("decoderWorker","onmessage:",Re),this._destroy();break;case xe:this.player&&this.player.pushTempStream(i.buffer);break;case Le:this.player&&this.player.emit(st.videoSEI,{ts:i.ts,data:new Uint8Array(i.buffer)});break;case Ie:if(this.player){if(this.player.isRecordTypeFlv()){const e=new Uint8Array(i.buffer);this.player.recorder.addMetaData(e)}const e=Ao(new Uint8Array(i.buffer));e&&e.onMetaData&&this.player.updateMetaData(e.onMetaData)}break;case Pe:if(this.player&&this.player.isRecordTypeFlv()){const e=new Uint8Array(i.buffer);this.player.recorder.addAACSequenceHeader(e,i.ts)}break;case Be:if(this.player&&this.player.isRecordTypeFlv()){const e=new Uint8Array(i.buffer);this.player.recorder.addVideoSequenceHeader(e,i.ts)}break;case Me:if(this.player&&this.player.isRecordTypeFlv()&&this.player.recording){const e=new Uint8Array(i.buffer);i.type===Ne?this.player.recorder.addVideo(e,i.ts):i.type===Oe&&this.player.recorder.addAudio(e,i.ts)}break;default:this.player[i.cmd]&&this.player[i.cmd](i)}}}_initWork(){const e={debug:this.player._opt.debug,debugLevel:this.player._opt.debugLevel,debugUuid:this.player._opt.debugUuid,useOffscreen:this.player._opt.useOffscreen,useWCS:this.player._opt.useWCS,useMSE:this.player._opt.useMSE,videoBuffer:this.player._opt.videoBuffer,videoBufferDelay:this.player._opt.videoBufferDelay,openWebglAlignment:this.player._opt.openWebglAlignment,playType:this.player._opt.playType,hasAudio:this.player._opt.hasAudio,hasVideo:this.player._opt.hasVideo,playbackRate:1,playbackForwardMaxRateDecodeIFrame:this.player._opt.playbackForwardMaxRateDecodeIFrame,playbackIsCacheBeforeDecodeForFpsRender:this.player._opt.playbackConfig.isCacheBeforeDecodeForFpsRender,sampleRate:this.player.audio&&this.player.audio.audioContext&&this.player.audio.audioContext.sampleRate||0,audioBufferSize:this.player.audio&&this.player.audio.getAudioBufferSize()||1024,networkDelay:this.player._opt.networkDelay,visibility:this.player.visibility,useSIMD:this.player._opt.useSIMD,recordType:this.player._opt.recordType,checkFirstIFrame:this.player._opt.checkFirstIFrame,isM7sCrypto:this.player._opt.isM7sCrypto,isXorCrypto:this.player._opt.isXorCrypto,isSm4Crypto:this.player._opt.isSm4Crypto,sm4CryptoKey:this.player._opt.sm4CryptoKey,m7sCryptoAudio:this.player._opt.m7sCryptoAudio,isFlv:this.player._opt.isFlv,isFmp4:this.player._opt.isFmp4,isMpeg4:this.player._opt.isMpeg4,isTs:this.player._opt.isTs,isNakedFlow:this.player._opt.isNakedFlow,isHls265:this.player.isUseHls265(),isFmp4Private:this.player._opt.isFmp4Private,isEmitSEI:this.player._opt.isEmitSEI,isRecordTypeFlv:this.player.isRecordTypeFlv(),isWasmMp4:this.player.recorder&&this.player.recorder.isWasmMp4()||!1,isChrome:oa(),isDropSameTimestampGop:this.player._opt.isDropSameTimestampGop,mseDecodeAudio:this.player._opt.mseDecodeAudio,nakedFlowH265DemuxUseNew:this.player._opt.nakedFlowH265DemuxUseNew};this.decoderWorker.postMessage({cmd:Ve,opt:JSON.stringify(e)}),this.player._opt.isM7sCrypto&&(this.updateWorkConfig({key:"cryptoKey",value:this.player._opt.cryptoKey}),this.updateWorkConfig({key:"cryptoIV",value:this.player._opt.cryptoIV}))}decodeVideo(e,t,i){this.player._opt.playType===A?this.player.isUseHls265()?this._decodeVideoNoDelay(e,t,i):this._decodeVideo(e,t,i):this.player._opt.playType===b&&(this.player.video.rate>=this.player._opt.playbackForwardMaxRateDecodeIFrame?i&&(this.player.debug.log("decoderWorker",`current rate is ${this.player.video.rate},only decode i frame`),this._decodeVideoNoDelay(e,t,i)):1===this.player.video.rate?this._decodeVideo(e,t,i):this._decodeVideoNoDelay(e,t,i))}_decodeVideo(e,t,i){const r={type:Ne,ts:Math.max(t,0),isIFrame:i};this.decoderWorker.postMessage({cmd:He,buffer:e,options:r},[e.buffer])}_decodeVideoNoDelay(e,t,i){this.decoderWorker.postMessage({cmd:je,buffer:e,ts:Math.max(t,0),isIFrame:i},[e.buffer])}decodeAudio(e,t){this.player._opt.playType===A?this.player._opt.useWCS||this.player._opt.useMSE||this.player.isUseHls265()?this._decodeAudioNoDelay(e,t):this._decodeAudio(e,t):this.player._opt.playType===b&&(1===this.player.video.rate?this._decodeAudio(e,t):this._decodeAudioNoDelay(e,t))}_decodeAudio(e,t){const i={type:Oe,ts:Math.max(t,0)};this.decoderWorker.postMessage({cmd:He,buffer:e,options:i},[e.buffer])}_decodeAudioNoDelay(e,t){this.decoderWorker.postMessage({cmd:$e,buffer:e,ts:Math.max(t,0)},[e.buffer])}updateWorkConfig(e){this.decoderWorker&&this.decoderWorker.postMessage({cmd:qe,key:e.key,value:e.value})}workerFetchStream(e){const{_opt:t}=this.player,i={protocol:t.protocol,isFlv:t.isFlv,isFmp4:t.isFmp4,isMpeg4:t.isMpeg4,isNakedFlow:t.isNakedFlow,isTs:t.isTs};this.decoderWorker.postMessage({cmd:Qe,url:e,opt:JSON.stringify(i)})}clearWorkBuffer(e=!1){this.decoderWorker.postMessage({cmd:Ye,needClear:e})}workerSendMessage(e){this.decoderWorker.postMessage({cmd:Xe,message:e})}}var bo,_o="application/json, text/javascript",wo="text/html",Eo=/^(?:text|application)\/xml/i,So=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,To=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,ko=/^\s*$/,Co={},Do={},Ro="",xo={type:"GET",beforeSend:Lo,success:Lo,error:Lo,complete:Lo,context:null,xhr:function(){return new window.XMLHttpRequest},accepts:{json:_o,xml:"application/xml, text/xml",html:wo,text:"text/plain","*":"*/".concat("*")},crossDomain:!1,timeout:0,username:null,password:null,processData:!0,promise:Lo,contentType:"application/x-www-form-urlencoded; charset=UTF-8"};function Lo(){}var Io=function(e,t){"object"==typeof e&&(t=e,e=void 0);var i=Go({},t=t||{});for(var r in xo)void 0===i[r]&&(i[r]=xo[r]);try{var s={},a=new Promise((function(e,t){s.resolve=e,s.reject=t}));a.resolve=s.resolve,a.reject=s.reject,i.promise=a}catch(e){i.promise={resolve:Lo,reject:Lo}}var n=To.exec(window.location.href.toLowerCase())||[];i.url=((e||i.url||window.location.href)+"").replace(/#.*$/,"").replace(/^\/\//,n[1]+"//");var o=i.url;i.crossDomain||(i.crossDomain=/^([\w-]+:)?\/\/([^\/]+)/.test(i.url)&&RegExp.$2!==window.location.href);var l=i.dataType;if("jsonp"===l){if(!/=\?/.test(i.url)){var d=(i.jsonp||"callback")+"=?";i.url=Fo(i.url,d)}return function(e){var t,i=e.jsonpCallback||"jsonp"+Vo(),r=window.document.createElement("script"),s={abort:function(){i in window&&(window[i]=Lo)}},a=window.document.getElementsByTagName("head")[0]||window.document.documentElement;function n(i){window.clearTimeout(t),s.abort(),Mo(i.type,s,i.type,e),o()}r.onerror=function(e){n(e)},window[i]=function(i){window.clearTimeout(t),Po(i,s,e),o()},Oo(e),r.src=e.url.replace(/=\?/,"="+i),r.src=Fo(r.src,"_="+(new Date).getTime()),r.async=!0,e.scriptCharset&&(r.charset=e.scriptCharset);a.insertBefore(r,a.firstChild),e.timeout>0&&(t=window.setTimeout((function(){s.abort(),Mo("timeout",s,"timeout",e),o()}),e.timeout));function o(){r.clearAttributes?r.clearAttributes():r.onload=r.onreadystatechange=r.onerror=null,r.parentNode&&r.parentNode.removeChild(r),r=null,delete window[i]}return e.promise.abort=function(){s.abort()},e.promise.xhr=s,e.promise}(i)}Oo(i);var h=i.accepts[l]||i.accepts["*"],c={};/^([\w-]+:)\/\//.test(i.url)?RegExp.$1:window.location.protocol;var u,p=xo.xhr();i.crossDomain||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest"),i.ifModified&&(Co[o]&&(c["If-Modified-Since"]=Co[o]),Do[o]&&(c["If-None-Match"]=Do[o])),h&&(c.Accept=h,h.indexOf(",")>-1&&(h=h.split(",",2)[0]),p.overrideMimeType&&p.overrideMimeType(h));var f=!/^(?:GET|HEAD)$/.test(i.type.toUpperCase());if((i.data&&f&&!1!==i.contentType||t.contentType)&&(c["Content-Type"]=i.contentType),!1===i.cache&&!f){var y=/([?&])_=[^&]*/;i.url=y.test(o)?o.replace(y,"$1_="+Vo()):o+(/\?/.test(o)?"&":"?")+"_="+Vo()}i.headers=Go(c,i.headers||{}),p.onreadystatechange=function(){if(4===p.readyState){var e;clearTimeout(u);var t=!1;if(p.status>=200&&p.status<300||304===p.status){if(Ro=p.getAllResponseHeaders(),i.ifModified){var r=Uo("Last-Modified");r&&(Co[o]=r),(r=Uo("etag"))&&(Do[o]=r)}l=l||function(e){return e&&(e===wo?"html":e===_o?"json":Eo.test(e)&&"xml")||"text"}(p.getResponseHeader("content-type")),e=p.responseText;try{"xml"===l?e=p.responseXML:"json"===l&&(e=ko.test(e)?null:JSON.parse(e))}catch(e){t=e}t?Mo(t,"parseerror",p,i):Po(e,p,i)}else Mo(null,"error",p,i)}};var m=!("async"in i)||i.async;if(p.open(i.type,i.url,m,i.username,i.password),i.xhrFields)for(var g in i.xhrFields)p[g]=i.xhrFields[g];for(var g in i.mimeType&&p.overrideMimeType&&p.overrideMimeType(i.mimeType),i.headers)void 0!==i.headers[g]&&p.setRequestHeader(g,i.headers[g]+"");return!1===function(e,t){var i=t.context;if(!1===t.beforeSend.call(i,e,t))return!1}(p,i)?(p.abort(),!1):(i.timeout>0&&(u=window.setTimeout((function(){p.onreadystatechange=Lo,p.abort(),Mo(null,"timeout",p,i)}),i.timeout)),p.send(i.data?i.data:null),i.promise.abort=function(){p.abort()},i.promise)};function Po(e,t,i){var r=i.context,s="success";i.success.call(r,e,s,t),i.promise.resolve(e,s,t),Bo(s,t,i)}function Bo(e,t,i){var r=i.context;i.complete.call(r,t,e)}function Mo(e,t,i,r){var s=r.context;r.error.call(s,i,t,e),r.promise.reject(i,t,e),Bo(t,i,r)}function Uo(e){var t;if(!bo){for(bo={};t=So.exec(Ro);)bo[t[1].toLowerCase()]=t[2];t=bo[e.toLowerCase()]}return null===t?null:t}function Fo(e,t){return(e+"&"+t).replace(/[&?]{1,2}/,"?")}function Oo(e){!zo(e)||e.data instanceof FormData||!e.processData||(e.data=function(e,t){var i=[];return i.add=function(e,t){this.push(encodeURIComponent(e)+"="+encodeURIComponent(t))},No(i,e,t),i.join("&").replace("%20","+")}(e.data)),!e.data||e.type&&"GET"!==e.type.toUpperCase()||(e.url=Fo(e.url,e.data))}function No(e,t,i,r){var s=function(e){return"[object Array]"===Object.prototype.toString.call(e)}(t);for(var a in t){var n=t[a];r&&(a=i?r:r+"["+(s?"":a)+"]"),!r&&s?e.add(n.name,n.value):(i?s(n):zo(n))?No(e,n,i,a):e.add(a,n)}}function Go(e){for(var t=Array.prototype.slice.call(arguments,1),i=0,r=t.length;i<r;i++){var s=t[i]||{};for(var a in s)s.hasOwnProperty(a)&&void 0!==s[a]&&(e[a]=s[a])}return e}function zo(e){var t=typeof e;return"function"===t||"object"===t&&!!e}function Wo(e){return"function"==typeof e}function Vo(){return(new Date).getTime()}function Ho(e){return parseInt(e)===e}function $o(e){if(!Ho(e.length))return!1;for(var t=0;t<e.length;t++)if(!Ho(e[t])||e[t]<0||e[t]>255)return!1;return!0}function jo(e,t){if(e.buffer&&"Uint8Array"===e.name)return t&&(e=e.slice?e.slice():Array.prototype.slice.call(e)),e;if(Array.isArray(e)){if(!$o(e))throw new Error("Array contains invalid value: "+e);return new Uint8Array(e)}if(Ho(e.length)&&$o(e))return new Uint8Array(e);throw new Error("unsupported array-like object")}function Ko(e){return new Uint8Array(e)}function qo(e,t,i,r,s){null==r&&null==s||(e=e.slice?e.slice(r,s):Array.prototype.slice.call(e,r,s)),t.set(e,i)}Io.get=function(e,t,i,r){return Wo(t)&&(r=r||i,i=t,t=void 0),Io({url:e,data:t,success:i,dataType:r})},Io.post=function(e,t,i,r){return Wo(t)&&(r=r||i,i=t,t=void 0),Io({type:"POST",url:e,data:t,success:i,dataType:r})},Io.getJSON=function(e,t,i){return Wo(t)&&(i=t,t=void 0),Io({url:e,data:t,success:i,dataType:"json"})},Io.ajaxSetup=function(e,t){return t?Go(Go(e,xo),t):Go(xo,e)};var Yo,Qo={toBytes:function(e){var t=[],i=0;for(e=encodeURI(e);i<e.length;){var r=e.charCodeAt(i++);37===r?(t.push(parseInt(e.substr(i,2),16)),i+=2):t.push(r)}return jo(t)},fromBytes:function(e){for(var t=[],i=0;i<e.length;){var r=e[i];r<128?(t.push(String.fromCharCode(r)),i++):r>191&&r<224?(t.push(String.fromCharCode((31&r)<<6|63&e[i+1])),i+=2):(t.push(String.fromCharCode((15&r)<<12|(63&e[i+1])<<6|63&e[i+2])),i+=3)}return t.join("")}},Xo=(Yo="0123456789abcdef",{toBytes:function(e){for(var t=[],i=0;i<e.length;i+=2)t.push(parseInt(e.substr(i,2),16));return t},fromBytes:function(e){for(var t=[],i=0;i<e.length;i++){var r=e[i];t.push(Yo[(240&r)>>4]+Yo[15&r])}return t.join("")}}),Jo={16:10,24:12,32:14},Zo=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],el=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],tl=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],il=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],rl=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],sl=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],al=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],nl=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],ol=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],ll=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],dl=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],hl=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],cl=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],ul=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],pl=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function fl(e){for(var t=[],i=0;i<e.length;i+=4)t.push(e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3]);return t}var yl=function(e){if(!(this instanceof yl))throw Error("AES must be instanitated with `new`");Object.defineProperty(this,"key",{value:jo(e,!0)}),this._prepare()};yl.prototype._prepare=function(){var e=Jo[this.key.length];if(null==e)throw new Error("invalid key size (must be 16, 24 or 32 bytes)");this._Ke=[],this._Kd=[];for(var t=0;t<=e;t++)this._Ke.push([0,0,0,0]),this._Kd.push([0,0,0,0]);var i,r=4*(e+1),s=this.key.length/4,a=fl(this.key);for(t=0;t<s;t++)i=t>>2,this._Ke[i][t%4]=a[t],this._Kd[e-i][t%4]=a[t];for(var n,o=0,l=s;l<r;){if(n=a[s-1],a[0]^=el[n>>16&255]<<24^el[n>>8&255]<<16^el[255&n]<<8^el[n>>24&255]^Zo[o]<<24,o+=1,8!=s)for(t=1;t<s;t++)a[t]^=a[t-1];else{for(t=1;t<s/2;t++)a[t]^=a[t-1];n=a[s/2-1],a[s/2]^=el[255&n]^el[n>>8&255]<<8^el[n>>16&255]<<16^el[n>>24&255]<<24;for(t=s/2+1;t<s;t++)a[t]^=a[t-1]}for(t=0;t<s&&l<r;)d=l>>2,h=l%4,this._Ke[d][h]=a[t],this._Kd[e-d][h]=a[t++],l++}for(var d=1;d<e;d++)for(var h=0;h<4;h++)n=this._Kd[d][h],this._Kd[d][h]=hl[n>>24&255]^cl[n>>16&255]^ul[n>>8&255]^pl[255&n]},yl.prototype.encrypt=function(e){if(16!=e.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var t=this._Ke.length-1,i=[0,0,0,0],r=fl(e),s=0;s<4;s++)r[s]^=this._Ke[0][s];for(var a=1;a<t;a++){for(s=0;s<4;s++)i[s]=il[r[s]>>24&255]^rl[r[(s+1)%4]>>16&255]^sl[r[(s+2)%4]>>8&255]^al[255&r[(s+3)%4]]^this._Ke[a][s];r=i.slice()}var n,o=Ko(16);for(s=0;s<4;s++)n=this._Ke[t][s],o[4*s]=255&(el[r[s]>>24&255]^n>>24),o[4*s+1]=255&(el[r[(s+1)%4]>>16&255]^n>>16),o[4*s+2]=255&(el[r[(s+2)%4]>>8&255]^n>>8),o[4*s+3]=255&(el[255&r[(s+3)%4]]^n);return o},yl.prototype.decrypt=function(e){if(16!=e.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var t=this._Kd.length-1,i=[0,0,0,0],r=fl(e),s=0;s<4;s++)r[s]^=this._Kd[0][s];for(var a=1;a<t;a++){for(s=0;s<4;s++)i[s]=nl[r[s]>>24&255]^ol[r[(s+3)%4]>>16&255]^ll[r[(s+2)%4]>>8&255]^dl[255&r[(s+1)%4]]^this._Kd[a][s];r=i.slice()}var n,o=Ko(16);for(s=0;s<4;s++)n=this._Kd[t][s],o[4*s]=255&(tl[r[s]>>24&255]^n>>24),o[4*s+1]=255&(tl[r[(s+3)%4]>>16&255]^n>>16),o[4*s+2]=255&(tl[r[(s+2)%4]>>8&255]^n>>8),o[4*s+3]=255&(tl[255&r[(s+1)%4]]^n);return o};var ml=function(e){if(!(this instanceof ml))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new yl(e)};ml.prototype.encrypt=function(e){if((e=jo(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=Ko(e.length),i=Ko(16),r=0;r<e.length;r+=16)qo(e,i,0,r,r+16),qo(i=this._aes.encrypt(i),t,r);return t},ml.prototype.decrypt=function(e){if((e=jo(e)).length%16!=0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var t=Ko(e.length),i=Ko(16),r=0;r<e.length;r+=16)qo(e,i,0,r,r+16),qo(i=this._aes.decrypt(i),t,r);return t};var gl=function(e,t){if(!(this instanceof gl))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Block Chaining",this.name="cbc",t){if(16!=t.length)throw new Error("invalid initialation vector size (must be 16 bytes)")}else t=Ko(16);this._lastCipherblock=jo(t,!0),this._aes=new yl(e)};gl.prototype.encrypt=function(e){if((e=jo(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=Ko(e.length),i=Ko(16),r=0;r<e.length;r+=16){qo(e,i,0,r,r+16);for(var s=0;s<16;s++)i[s]^=this._lastCipherblock[s];this._lastCipherblock=this._aes.encrypt(i),qo(this._lastCipherblock,t,r)}return t},gl.prototype.decrypt=function(e){if((e=jo(e)).length%16!=0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var t=Ko(e.length),i=Ko(16),r=0;r<e.length;r+=16){qo(e,i,0,r,r+16),i=this._aes.decrypt(i);for(var s=0;s<16;s++)t[r+s]=i[s]^this._lastCipherblock[s];qo(e,this._lastCipherblock,0,r,r+16)}return t};var Al=function(e,t,i){if(!(this instanceof Al))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Feedback",this.name="cfb",t){if(16!=t.length)throw new Error("invalid initialation vector size (must be 16 size)")}else t=Ko(16);i||(i=1),this.segmentSize=i,this._shiftRegister=jo(t,!0),this._aes=new yl(e)};Al.prototype.encrypt=function(e){if(e.length%this.segmentSize!=0)throw new Error("invalid plaintext size (must be segmentSize bytes)");for(var t,i=jo(e,!0),r=0;r<i.length;r+=this.segmentSize){t=this._aes.encrypt(this._shiftRegister);for(var s=0;s<this.segmentSize;s++)i[r+s]^=t[s];qo(this._shiftRegister,this._shiftRegister,0,this.segmentSize),qo(i,this._shiftRegister,16-this.segmentSize,r,r+this.segmentSize)}return i},Al.prototype.decrypt=function(e){if(e.length%this.segmentSize!=0)throw new Error("invalid ciphertext size (must be segmentSize bytes)");for(var t,i=jo(e,!0),r=0;r<i.length;r+=this.segmentSize){t=this._aes.encrypt(this._shiftRegister);for(var s=0;s<this.segmentSize;s++)i[r+s]^=t[s];qo(this._shiftRegister,this._shiftRegister,0,this.segmentSize),qo(e,this._shiftRegister,16-this.segmentSize,r,r+this.segmentSize)}return i};var vl=function(e,t){if(!(this instanceof vl))throw Error("AES must be instanitated with `new`");if(this.description="Output Feedback",this.name="ofb",t){if(16!=t.length)throw new Error("invalid initialation vector size (must be 16 bytes)")}else t=Ko(16);this._lastPrecipher=jo(t,!0),this._lastPrecipherIndex=16,this._aes=new yl(e)};vl.prototype.encrypt=function(e){for(var t=jo(e,!0),i=0;i<t.length;i++)16===this._lastPrecipherIndex&&(this._lastPrecipher=this._aes.encrypt(this._lastPrecipher),this._lastPrecipherIndex=0),t[i]^=this._lastPrecipher[this._lastPrecipherIndex++];return t},vl.prototype.decrypt=vl.prototype.encrypt;var bl=function(e){if(!(this instanceof bl))throw Error("Counter must be instanitated with `new`");0===e||e||(e=1),"number"==typeof e?(this._counter=Ko(16),this.setValue(e)):this.setBytes(e)};bl.prototype.setValue=function(e){if("number"!=typeof e||parseInt(e)!=e)throw new Error("invalid counter value (must be an integer)");if(e>Number.MAX_SAFE_INTEGER)throw new Error("integer value out of safe range");for(var t=15;t>=0;--t)this._counter[t]=e%256,e=parseInt(e/256)},bl.prototype.setBytes=function(e){if(16!=(e=jo(e,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=e},bl.prototype.increment=function(){for(var e=15;e>=0;e--){if(255!==this._counter[e]){this._counter[e]++;break}this._counter[e]=0}};var _l=function(e,t){if(!(this instanceof _l))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",t instanceof bl||(t=new bl(t)),this._counter=t,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new yl(e)};_l.prototype.encrypt=function(e){for(var t=jo(e,!0),i=0;i<t.length;i++)16===this._remainingCounterIndex&&(this._remainingCounter=this._aes.encrypt(this._counter._counter),this._remainingCounterIndex=0,this._counter.increment()),t[i]^=this._remainingCounter[this._remainingCounterIndex++];return t},_l.prototype.decrypt=_l.prototype.encrypt;const wl={AES:yl,Counter:bl,ModeOfOperation:{ecb:ml,cbc:gl,cfb:Al,ofb:vl,ctr:_l},utils:{hex:Xo,utf8:Qo},padding:{pkcs7:{pad:function(e){var t=16-(e=jo(e,!0)).length%16,i=Ko(e.length+t);qo(e,i);for(var r=e.length;r<i.length;r++)i[r]=t;return i},strip:function(e){if((e=jo(e,!0)).length<16)throw new Error("PKCS#7 invalid length");var t=e[e.length-1];if(t>16)throw new Error("PKCS#7 padding byte out of range");for(var i=e.length-t,r=0;r<t;r++)if(e[i+r]!==t)throw new Error("PKCS#7 invalid padding byte");var s=Ko(i);return qo(e,s,0,0,i),s}}},_arrayTest:{coerceArray:jo,createArray:Ko,copyArray:qo}};const El=0,Sl=32,Tl=16,kl=[214,144,233,254,204,225,61,183,22,182,20,194,40,251,44,5,43,103,154,118,42,190,4,195,170,68,19,38,73,134,6,153,156,66,80,244,145,239,152,122,51,84,11,67,237,207,172,98,228,179,28,169,201,8,232,149,128,223,148,250,117,143,63,166,71,7,167,252,243,115,23,186,131,89,60,25,230,133,79,168,104,107,129,178,113,100,218,139,248,235,15,75,112,86,157,53,30,36,14,94,99,88,209,162,37,34,124,59,1,33,120,135,212,0,70,87,159,211,39,82,76,54,2,231,160,196,200,158,234,191,138,210,64,199,56,181,163,247,242,206,249,97,21,161,224,174,93,164,155,52,26,85,173,147,50,48,245,140,177,227,29,246,226,46,130,102,202,96,192,41,35,171,13,83,78,111,213,219,55,69,222,253,142,47,3,255,106,114,109,108,91,81,141,27,175,146,187,221,188,127,17,217,92,65,31,16,90,216,10,193,49,136,165,205,123,189,45,116,208,18,184,229,180,176,137,105,151,74,12,150,119,126,101,185,241,9,197,110,198,132,24,240,125,236,58,220,77,32,121,238,95,62,215,203,57,72],Cl=[462357,472066609,943670861,1415275113,1886879365,2358483617,2830087869,3301692121,3773296373,4228057617,404694573,876298825,1347903077,1819507329,2291111581,2762715833,3234320085,3705924337,4177462797,337322537,808926789,1280531041,1752135293,2223739545,2695343797,3166948049,3638552301,4110090761,269950501,741554753,1213159005,1684763257];function Dl(e){const t=[];for(let i=0,r=e.length;i<r;i+=2)t.push(parseInt(e.substr(i,2),16));return t}function Rl(e,t){const i=31&t;return e<<i|e>>>32-i}function xl(e){return(255&kl[e>>>24&255])<<24|(255&kl[e>>>16&255])<<16|(255&kl[e>>>8&255])<<8|255&kl[255&e]}function Ll(e){return e^Rl(e,2)^Rl(e,10)^Rl(e,18)^Rl(e,24)}function Il(e){return e^Rl(e,13)^Rl(e,23)}function Pl(e,t,i){const r=new Array(4),s=new Array(4);for(let t=0;t<4;t++)s[0]=255&e[4*t],s[1]=255&e[4*t+1],s[2]=255&e[4*t+2],s[3]=255&e[4*t+3],r[t]=s[0]<<24|s[1]<<16|s[2]<<8|s[3];for(let e,t=0;t<32;t+=4)e=r[1]^r[2]^r[3]^i[t+0],r[0]^=Ll(xl(e)),e=r[2]^r[3]^r[0]^i[t+1],r[1]^=Ll(xl(e)),e=r[3]^r[0]^r[1]^i[t+2],r[2]^=Ll(xl(e)),e=r[0]^r[1]^r[2]^i[t+3],r[3]^=Ll(xl(e));for(let e=0;e<16;e+=4)t[e]=r[3-e/4]>>>24&255,t[e+1]=r[3-e/4]>>>16&255,t[e+2]=r[3-e/4]>>>8&255,t[e+3]=255&r[3-e/4]}function Bl(e,t,i,{padding:r="pkcs#7",mode:s,iv:a=[],output:n="string"}={}){if("cbc"===s&&("string"==typeof a&&(a=Dl(a)),16!==a.length))throw new Error("iv is invalid");if("string"==typeof t&&(t=Dl(t)),16!==t.length)throw new Error("key is invalid");if(e="string"==typeof e?i!==El?function(e){const t=[];for(let i=0,r=e.length;i<r;i++){const r=e.codePointAt(i);if(r<=127)t.push(r);else if(r<=2047)t.push(192|r>>>6),t.push(128|63&r);else if(r<=55295||r>=57344&&r<=65535)t.push(224|r>>>12),t.push(128|r>>>6&63),t.push(128|63&r);else{if(!(r>=65536&&r<=1114111))throw t.push(r),new Error("input is not supported");i++,t.push(240|r>>>18&28),t.push(128|r>>>12&63),t.push(128|r>>>6&63),t.push(128|63&r)}}return t}(e):Dl(e):[...e],("pkcs#5"===r||"pkcs#7"===r)&&i!==El){const t=Tl-e.length%Tl;for(let i=0;i<t;i++)e.push(t)}const o=new Array(Sl);!function(e,t,i){const r=new Array(4),s=new Array(4);for(let t=0;t<4;t++)s[0]=255&e[0+4*t],s[1]=255&e[1+4*t],s[2]=255&e[2+4*t],s[3]=255&e[3+4*t],r[t]=s[0]<<24|s[1]<<16|s[2]<<8|s[3];r[0]^=2746333894,r[1]^=1453994832,r[2]^=1736282519,r[3]^=2993693404;for(let e,i=0;i<32;i+=4)e=r[1]^r[2]^r[3]^Cl[i+0],t[i+0]=r[0]^=Il(xl(e)),e=r[2]^r[3]^r[0]^Cl[i+1],t[i+1]=r[1]^=Il(xl(e)),e=r[3]^r[0]^r[1]^Cl[i+2],t[i+2]=r[2]^=Il(xl(e)),e=r[0]^r[1]^r[2]^Cl[i+3],t[i+3]=r[3]^=Il(xl(e));if(i===El)for(let e,i=0;i<16;i++)e=t[i],t[i]=t[31-i],t[31-i]=e}(t,o,i);const l=[];let d=a,h=e.length,c=0;for(;h>=Tl;){const t=e.slice(c,c+16),r=new Array(16);if("cbc"===s)for(let e=0;e<Tl;e++)i!==El&&(t[e]^=d[e]);Pl(t,r,o);for(let e=0;e<Tl;e++)"cbc"===s&&i===El&&(r[e]^=d[e]),l[c+e]=r[e];"cbc"===s&&(d=i!==El?r:t),h-=Tl,c+=Tl}if(("pkcs#5"===r||"pkcs#7"===r)&&i===El){const e=l.length,t=l[e-1];for(let i=1;i<=t;i++)if(l[e-i]!==t)throw new Error("padding is invalid");l.splice(e-t,t)}return"array"!==n?i!==El?l.map((e=>1===(e=e.toString(16)).length?"0"+e:e)).join(""):function(e){const t=[];for(let i=0,r=e.length;i<r;i++)e[i]>=240&&e[i]<=247?(t.push(String.fromCodePoint(((7&e[i])<<18)+((63&e[i+1])<<12)+((63&e[i+2])<<6)+(63&e[i+3]))),i+=3):e[i]>=224&&e[i]<=239?(t.push(String.fromCodePoint(((15&e[i])<<12)+((63&e[i+1])<<6)+(63&e[i+2]))),i+=2):e[i]>=192&&e[i]<=223?(t.push(String.fromCodePoint(((31&e[i])<<6)+(63&e[i+1]))),i++):t.push(String.fromCodePoint(e[i]));return t.join("")}(l):l}function Ml(e,t,i){for(let r=2;r<e.length;++r){const s=r-2,a=t[s%t.length],n=i[s%i.length];e[r]=e[r]^a^n}return e}class Ul extends t{constructor(e){super(),this.TAG_NAME="CommonDemux",this.player=e,this.stopId=null,this.firstTimestamp=null,this.startTimestamp=null,this.preDelayTimestamp=null,this.preLoopTimestamp=null,this.bufferStartDts=null,this.bufferStartLocalTs=null,this.preIframeTs=null,this.preFrameTs=null,this.preTimestamp=null,this.preTimestampDuration=0,this.prevPayloadBufferSize=0,this.isStreamTsMoreThanLocal=!1,this.delay=-1,this.pushLatestDelay=-1,this.bufferList=[],this.historyIntervalDiffTimeList=[],this.playbackStreamFps=null,this.playbackStreamAudioFps=null,this.playbackStreamVideoFps=null,this.dropping=!1,this.isPushDropping=!1,this.nalUnitSize=null,this.initInterval(),this.player.debug.log("CommonDemux","init")}destroy(){this.bufferList=[],this.historyIntervalDiffTimeList=[],this.playbackStreamFps=null,this.playbackStreamAudioFps=null,this.playbackStreamVideoFps=null,this.clearStopInterval(),this.firstTimestamp=null,this.startTimestamp=null,this.bufferStartDts=null,this.bufferStartLocalTs=null,this.preDelayTimestamp=null,this.preLoopTimestamp=null,this.preIframeTs=null,this.preTimestamp=null,this.preTimestampDuration=0,this.prevPayloadBufferSize=0,this.isStreamTsMoreThanLocal=!1,this.delay=-1,this.pushLatestDelay=-1,this.dropping=!1,this.isPushDropping=!1,this.nalUnitSize=null,this.off(),this.player.debug.log("CommonDemux","destroy")}isDropping(){return this.dropping||this.isPushDropping}getDelay(e,t){if(!e||!this.player.isDemuxDecodeFirstIIframeInit())return-1;if(t===Oe)return this.delay;if(this.preDelayTimestamp&&this.preDelayTimestamp>e)return this.preDelayTimestamp-e>1e3&&this.player.debug.warn("CommonDemux",`getDelay() and preDelayTimestamp is ${this.preDelayTimestamp} > timestamp is ${e} more than ${this.preDelayTimestamp-e}ms and return ${this.delay}`),this.preDelayTimestamp=e,this.delay;if(this.firstTimestamp){if(e){const t=Date.now()-this.startTimestamp,i=e-this.firstTimestamp;t>=i?(this.isStreamTsMoreThanLocal=!1,this.delay=t-i):(this.isStreamTsMoreThanLocal=!0,this.delay=i-t)}}else this.firstTimestamp=e,this.startTimestamp=Date.now(),this.delay=-1;return this.preDelayTimestamp=e,this.delay}getDelayNotUpdateDelay(e,t){if(!e||!this.player.isDemuxDecodeFirstIIframeInit())return-1;if(t===Oe)return this.pushLatestDelay;if(this.preDelayTimestamp&&this.preDelayTimestamp-e>1e3)return this.player.debug.warn("CommonDemux",`getDelayNotUpdateDelay() and preDelayTimestamp is ${this.preDelayTimestamp} > timestamp is ${e} more than ${this.preDelayTimestamp-e}ms and return -1`),-1;if(this.firstTimestamp){let t=-1;if(e){const i=Date.now()-this.startTimestamp,r=e-this.firstTimestamp;t=i>=r?i-r:r-i}return t}return-1}resetDelay(){this.firstTimestamp=null,this.startTimestamp=null,this.delay=-1,this.dropping=!1}resetAllDelay(){this.resetDelay(),this.preDelayTimestamp=null}initInterval(){this.player.isUseHls265()?this.player.debug.log("CommonDemux","initInterval() and is hls and support hls265 so return"):-1===this.player.getStreamType().indexOf(y)?this.player.isPlaybackCacheBeforeDecodeForFpsRender()?this.player.debug.log("CommonDemux","initInterval() and playback and playbackIsCacheBeforeDecodeForFpsRender is true so return"):(this.player.debug.log("CommonDemux","setInterval()"),this._loop(),this.stopId=setInterval((()=>{let e=(new Date).getTime();this.preLoopTimestamp||(this.preLoopTimestamp=e);const t=e-this.preLoopTimestamp;this.updateHistoryIntervalDiffTimeList(t),t>100&&this.player.debug.warn("CommonDemux",`loop demux diff time is ${t}`),this._loop(),this.preLoopTimestamp=(new Date).getTime()}),20)):this.player.debug.log("CommonDemux","initInterval() and is worker stream so return")}clearStopInterval(){this.stopId&&(clearInterval(this.stopId),this.stopId=null)}updateHistoryIntervalDiffTimeList(e){this.historyIntervalDiffTimeList.length>5&&this.historyIntervalDiffTimeList.shift(),this.historyIntervalDiffTimeList.push(e)}isHistoryIntervalDiffTimeAllLarge(){if(this.historyIntervalDiffTimeList.length<5)return!1;for(let e=0;e<this.historyIntervalDiffTimeList.length;e++)if(this.historyIntervalDiffTimeList[e]<900)return!1;return!0}initPlaybackCacheLoop(){this.clearStopInterval();const e=()=>{let e=null;this.bufferList.length&&(e=this.bufferList.shift(),this._doDecoderDecode(e))};e();const t=Math.ceil(1e3/(this.playbackStreamFps*this.player.getPlaybackRate()));this.player.debug.log("CommonDemux",`initPlaybackCacheLoop() and fragDuration is ${t}, playbackStreamFps is ${this.playbackStreamFps}, playbackRate is ${this.player.getPlaybackRate()}`),this.stopId=setInterval(e,t)}_loop(){let e;const t=this.player._opt.videoBuffer,i=this.player._opt.videoBufferDelay,r=this.player._opt.playType===A;if(this.bufferList.length){if(this.isPushDropping)return void this.player.debug.warn("CommonDemux",`_loop isPushDropping is true and bufferList length is ${this.bufferList.length}`);if(this.dropping){for(e=this.bufferList.shift(),this.player.debug.warn("CommonDemux",`_loop is dropping and data.ts is ${e.ts}, data.type is ${e.type}, data.isIFrame is ${e.isIFrame}, delay is ${this.delay} ,buffer list is ${this.bufferList.length}`);!e.isIFrame&&this.bufferList.length;)e=this.bufferList.shift();const t=this.getDelayNotUpdateDelay(e.ts,e.type);e.isIFrame&&t<=this.getNotDroppingDelayTs()&&(this.player.debug.log("CommonDemux",`_loop data isIFrame is true and delay is ${this.delay}`),this.dropping=!1,this._doDecoderDecode(e),this._decodeNext(e))}else if(this.player.isPlayback()||this.player.isPlayUseMSE()||0===t)for(;this.bufferList.length;)e=this.bufferList.shift(),this._doDecoderDecode(e);else if(e=this.bufferList[0],-1===this.getDelay(e.ts,e.type))this.player.debug.log("CommonDemux",`delay is -1 and data.ts is ${e.ts} data.type is ${e.type}`),this.bufferList.shift(),this._doDecoderDecode(e),this._decodeNext(e);else if(this.delay>i+t&&r)this.hasIframeInBufferList()?(this.player.debug.warn("CommonDemux",`_loop delay is ${this.delay}, set dropping is true`),this.resetAllDelay(),this.dropping=!0,this.player.updateStats({isDropping:!0})):(this.bufferList.shift(),this._doDecoderDecode(e),this._decodeNext(e));else for(;this.bufferList.length;){if(e=this.bufferList[0],!(this.getDelay(e.ts,e.type)>t)){this.delay<0&&this.player.debug.warn("CommonDemux",`_loop delay is ${this.delay} bufferList is ${this.bufferList}`);break}this.bufferList.shift(),this._doDecoderDecode(e)}}else-1!==this.delay&&this.player.debug.log("CommonDemux","loop() bufferList is empty and reset delay"),this.resetAllDelay()}_doDecode(e,t,i,r,s=0){const a=this.player;let n={ts:i,cts:s,type:t,isIFrame:!1};this.player.isPlayer()?(t===Ne&&a._opt.playType===A&&this.calcNetworkDelay(i),a._opt.useWCS&&!a._opt.useOffscreen||a._opt.useMSE?(t===Ne&&(n.isIFrame=r),this.pushBuffer(e,n)):t===Ne?a.decoderWorker&&a.decoderWorker.decodeVideo(e,i,r):t===Oe&&a._opt.hasAudio&&a.decoderWorker&&a.decoderWorker.decodeAudio(e,i)):this.player.isPlayback()&&(t===Ne&&(n.isIFrame=r),this.player.isPlaybackOnlyDecodeIFrame()?t===Ne&&r&&this.pushBuffer(e,n):this.player.isPlaybackCacheBeforeDecodeForFpsRender()||1===this.player.getPlaybackRate()?this.pushBuffer(e,n):this.pushBuffer(e,n,!1))}_doDecodeByHls(e,t,i,r,s=0){let a=!1;if(t===Oe&&is(e)&&(this.player.debug.log("CommonDemux",`hls pushBuffer audio ts is ${i}, isAacCodecPacket is true`),a=!0,this.player.isRecordTypeFlv())){const t=new Uint8Array(e);this.player.recorder.addAACSequenceHeader(t,i)}let n=!1;if(t===Ne&&r&&Sa(e)&&(this.player.debug.log("CommonDemux",`hls pushBuffer video ts is ${i}, isVideoSequenceHeader is true`),n=!0,this.player.isRecordTypeFlv())){const t=new Uint8Array(e);this.player.recorder.addVideoSequenceHeader(t,i)}this.player.recording&&ka(n)&&ka(a)&&this.handleRecording(e,t,i,r,s),t===Ne?this._doDecoderDecode({ts:i,cts:s,payload:e,type:Ne,isIFrame:r}):t===Oe&&this._doDecoderDecode({ts:i,payload:e,type:Oe})}_doDecodeByFmp4(e,t,i,r,s=0){this._doDecode(e,t,i,r,s)}_doDecodeByTs(e,t,i,r,s=0){this._doDecode(e,t,i,r,s)}_decodeNext(e){const t=e.ts;if(0===this.bufferList.length)return;let i=this.bufferList[0];const r=i.ts-t,s=e.type===Ne&&i.type===Oe,a=e.type===Ne&&Sa(e.payload);(r<=20||s||a)&&(this.player.debug.log("CommonDemux",`decode data type is ${e.type} and\n ts is ${t} next data type is ${i.type} ts is ${i.ts}\n diff is ${r} and isVideoAndNextAudio is ${s} and isVideoSqeHeader is ${a}`),this.bufferList.shift(),this._doDecoderDecode(i))}_doDecoderDecode(e){const t=this.player,{webcodecsDecoder:i,mseDecoder:r}=t;this.player.isPlayer()&&this.player.updateStats({buf:this.delay}),e.type===Oe?t._opt.hasAudio&&(t._opt.useMSE&&t._opt.mseDecodeAudio?r.decodeAudio(e.payload,e.ts):t.decoderWorker&&t.decoderWorker.decodeAudio(e.payload,e.ts)):e.type===Ne&&(t._opt.isEmitSEI&&this.findSei(e.payload,e.ts),t._opt.useWCS&&!t._opt.useOffscreen?i.decodeVideo(e.payload,e.ts,e.isIFrame,e.cts):t._opt.useMSE?r.decodeVideo(e.payload,e.ts,e.isIFrame,e.cts):t.decoderWorker&&t.decoderWorker.decodeVideo(e.payload,e.ts,e.isIFrame))}pushBuffer(e,t,i=!0){const r=this.player._opt.videoBuffer,s=this.player._opt.videoBufferDelay,a=this.player.isPlayer();if(t.type===Oe&&is(e)){if(this.player.debug.log("CommonDemux",`pushBuffer() audio ts is ${t.ts}, isAacCodecPacket is true`),this.player.isRecordTypeFlv()){const i=new Uint8Array(e);this.player.recorder.addAACSequenceHeader(i,t.ts)}this._doDecoderDecode({ts:t.ts,payload:e,type:Oe})}else if(t.type===Ne&&t.isIFrame&&Sa(e)){if(this.player.debug.log("CommonDemux",`pushBuffer() video ts is ${t.ts}, isVideoSequenceHeader is true`),this.player.isRecordTypeFlv()){const i=new Uint8Array(e);this.player.recorder.addVideoSequenceHeader(i,t.ts)}this._doDecoderDecode({ts:t.ts,payload:e,type:Ne,isIFrame:t.isIFrame,cts:t.cts})}else{if(this.player.recording&&this.handleRecording(e,t.type,t.ts,t.isIFrame,t.cts),a){if(this.preTimestampDuration>0&&this.preTimestamp>0&&t.type===Ne){const e=t.ts-this.preTimestamp,i=this.preTimestampDuration+this.preTimestampDuration/2;e>=i&&this.player.debug.log("CommonDemux",`pushBuffer() video\n ts is ${t.ts}, preTimestamp is ${this.preTimestamp},\n diff is ${e} and preTimestampDuration is ${this.preTimestampDuration} and maxDiff is ${i}\n maybe trigger black screen or flower screen`)}if(this.preTimestamp>0&&t.ts<this.preTimestamp&&t.type===Ne&&this.preTimestamp-t.ts>ee&&(this.player.debug.warn("CommonDemux",`pushBuffer() video\n ts is ${t.ts}, preTimestamp is ${this.preTimestamp},\n diff is ${this.preTimestamp-t.ts} more than 3600000\n and resetAllDelay()`),this.resetAllDelay()),t.ts<=this.preTimestamp&&this.preTimestamp>0&&t.type===Ne&&(this.player.debug.warn("CommonDemux",`pushBuffer() video\n ts is ${t.ts} less than (or equal) preTimestamp is ${this.preTimestamp} and\n payloadBufferSize is ${e.byteLength} and prevPayloadBufferSize is ${this.prevPayloadBufferSize}`),this.player._opt.isDropSameTimestampGop&&this.player.isDemuxDecodeFirstIIframeInit())){const e=this.hasIframeInBufferList(),t=ka(this.isPushDropping);return this.player.debug.log("CommonDemux",`pushBuffer(), isDropSameTimestampGop is true and\n hasIframe is ${e} and isNotPushDropping is ${t} and next drop buffer`),void(e&&t?this.dropBuffer$2():this.clearBuffer(!0))}if(this.player.isDemuxDecodeFirstIIframeInit()){let e=this.getDelayNotUpdateDelay(t.ts,t.type);this.pushLatestDelay=e;const i=s+r;this.player._opt.useMSE?e>i&&this.delay<i&&this.delay>0&&this.hasIframeInBufferList()&&!1===this.isPushDropping&&(this.player.debug.warn("CommonDemux",`useMSE, pushLatestDelay is ${e} > ${s+r}, bufferList is ${this.bufferList.length}, delay is ${this.delay} and dropBuffer$2()`),this.dropBuffer$2()):e>i&&this.delay<i&&this.delay>0&&this.hasIframeInBufferList()&&!1===this.isPushDropping&&(this.player.debug.warn("CommonDemux",`useWCS, pushLatestDelay is ${e} > ${s+r},bufferList is ${this.bufferList.length}, delay is ${this.delay} and dropBuffer$2()`),this.dropBuffer$2()),this.isHistoryIntervalDiffTimeAllLarge()&&ka(this.player.visibility)&&(this.player._opt.useMSE?this.hasIframeInBufferList()&&!1===this.isPushDropping&&(this.player.debug.warn("CommonDemux",`useMSE, page visibility is false and\n history interval diff is ${this.historyIntervalDiffTimeList.join(",")} and\n bufferList is ${this.bufferList.length},\n delay is ${this.delay} and dropBuffer$2()`),this.dropBuffer$2()):this.hasIframeInBufferList()&&!1===this.isPushDropping&&(this.player.debug.warn("CommonDemux",`useWCS, page visibility is false and\n history interval diff is ${this.historyIntervalDiffTimeList.join(",")} and\n bufferList is ${this.bufferList.length},\n delay is ${this.delay} and dropBuffer$2()`),this.dropBuffer$2()))}t.type===Ne&&(this.preTimestamp>0&&(this.preTimestampDuration=t.ts-this.preTimestamp),this.prevPayloadBufferSize=e.byteLength,this.preTimestamp=t.ts)}if(i?t.type===Oe?this.bufferList.push({ts:t.ts,payload:e,type:Oe}):t.type===Ne&&this.bufferList.push({ts:t.ts,cts:t.cts,payload:e,type:Ne,isIFrame:t.isIFrame}):t.type===Ne?this._doDecoderDecode({ts:t.ts,cts:t.cts,payload:e,type:Ne,isIFrame:t.isIFrame}):t.type===Oe&&this._doDecoderDecode({ts:t.ts,payload:e,type:Oe}),this.player.isPlaybackCacheBeforeDecodeForFpsRender()&&($s(this.playbackStreamVideoFps)||$s(this.playbackStreamAudioFps))){let e=this.playbackStreamVideoFps,t=this.playbackStreamAudioFps;if($s(this.playbackStreamVideoFps)&&(e=Aa(this.bufferList,Ne),e>0&&(this.playbackStreamVideoFps=e,this.player.video&&this.player.video.setStreamFps(this.playbackStreamVideoFps),this.playbackStreamFps=t?e+t:e,ka(this.player._opt.hasAudio)&&(this.player.debug.log(this.TAG_NAME,"playbackCacheBeforeDecodeForFpsRender,_opt.hasAudio is false and set streamAudioFps is 0"),this.playbackStreamAudioFps=0),this.initPlaybackCacheLoop())),$s(this.playbackStreamAudioFps)&&(t=Aa(this.bufferList,Oe),t>0&&(this.playbackStreamAudioFps=t,this.playbackStreamFps=e?e+t:t,this.initPlaybackCacheLoop())),$s(this.playbackStreamVideoFps)&&$s(this.playbackStreamAudioFps)){const i=this.bufferList.map((e=>({type:e.type,ts:e.ts})));this.player.debug.log("CommonDemux",`playbackCacheBeforeDecodeForFpsRender, calc streamAudioFps is ${t}, streamVideoFps is ${e}, bufferListLength is ${this.bufferList.length} and ts list is ${JSON.stringify(i)}`)}const i=this.getAudioBufferLength()>0,r=i?60:40;this.bufferList.length>=r&&(this.debug.warn("CommonDemux",`playbackCacheBeforeDecodeForFpsRender, bufferListLength is ${this.bufferList.length} more than ${r}, and hasAudio is ${i} an set streamFps is 25`),this.playbackStreamVideoFps=e,this.player.video&&this.player.video.setStreamFps(this.playbackStreamVideoFps),i?(this.playbackStreamAudioFps=25,this.playbackStreamFps=this.playbackStreamVideoFps+this.playbackStreamAudioFps):this.playbackStreamFps=this.playbackStreamVideoFps,this.initPlaybackCacheLoop())}}}dropBuffer$2(){if(this.bufferList.length>0){let e=this.bufferList.findIndex((e=>Ta(e.isIFrame)&&e.type===Ne));if(this.isAllIframeInBufferList())for(let t=0;t<this.bufferList.length;t++){const i=this.bufferList[t],r=this.getDelayNotUpdateDelay(i.ts,i.type);if(r>=this.getNotDroppingDelayTs()){this.player.debug.log("CommonDemux",`dropBuffer$2() isAllIframeInBufferList() is true, and index is ${t} and tempDelay is ${r} and notDroppingDelayTs is ${this.getNotDroppingDelayTs()}`),e=t;break}}if(e>=0){this.isPushDropping=!0,this.player.updateStats({isDropping:!0});const t=this.bufferList.length;this.bufferList=this.bufferList.slice(e);const i=this.bufferList.shift();this.resetAllDelay(),this.getDelay(i.ts,i.type),this._doDecoderDecode(i),this.isPushDropping=!1,this.player.debug.log("CommonDemux",`dropBuffer$2() iFrameIndex is ${e},and old bufferList length is ${t} ,and new bufferList length is ${this.bufferList.length} and new delay is ${this.delay} `)}else this.isPushDropping=!1}0===this.bufferList.length&&(this.isPushDropping=!1)}clearBuffer(e=!1){this.player.debug.log("CommonDemux",`clearBuffer,buffer length is ${this.bufferList.length}, need clear is ${e} and _opt.checkFirstIFrame is ${this.player._opt.checkFirstIFrame}`),e&&(this.bufferList=[]),this.player.isPlayer()&&(this.resetAllDelay(),Ta(this.player._opt.checkFirstIFrame)&&(this.dropping=!0,this.player.updateStats({isDropping:!0}))),this.player.decoderCheckFirstIFrame()}calcNetworkDelay(e){if(!(this.player.isDemuxDecodeFirstIIframeInit()&&e>0))return;null===this.bufferStartDts?(this.bufferStartDts=e,this.bufferStartLocalTs=vs()):e<this.bufferStartDts&&(this.player.debug.warn("CommonDemux",`calcNetworkDelay dts is ${e} and bufferStartDts is ${this.bufferStartDts}`),this.bufferStartDts=e,this.bufferStartLocalTs=vs());let t=e-this.bufferStartDts,i=vs()-this.bufferStartLocalTs,r=i>t?i-t:0;r>this.player._opt.networkDelay&&this.player._opt.playType===A&&(this.player.debug.warn("CommonDemux",`delay is more than networkDelay and now dts:${e},start dts is ${this.bufferStartDts}, vs start is ${t},local diff is ${i} ,delay is ${r}, _opt.networkDelay is ${this.player._opt.networkDelay}`),this.player.emit(st.networkDelayTimeout,r)),this.player.updateStats({netBuf:r})}calcIframeIntervalTimestamp(e){if(null===this.preIframeTs)this.preIframeTs=e;else if(this.preIframeTs<e){const t=e-this.preIframeTs;this.player&&(this.player.videoIframeIntervalTs=t),this.preIframeTs=e}}calcBufferFps(e){}getNotDroppingDelayTs(){return this.player._opt.videoBuffer+this.player._opt.videoBufferDelay/2}getMaxDelayTs(){return this.player._opt.videoBuffer+this.player._opt.videoBufferDelay}getPushLatestDelay(){return this.pushLatestDelay}getVideoBufferLength(){let e=0;return this.bufferList.forEach((t=>{t.type===Ne&&(e+=1)})),e}getAudioBufferLength(){let e=0;return this.bufferList.forEach((t=>{t.type===Oe&&(e+=1)})),e}hasIframeInBufferList(){return this.bufferList.some((e=>e.type===Ne&&e.isIFrame))}isAllIframeInBufferList(){const e=this.getVideoBufferLength();let t=0;return this.bufferList.forEach((e=>{e.type===Ne&&e.isIFrame&&(t+=1)})),e===t}getInputByteLength(){return 0}getIsStreamTsMoreThanLocal(){return this.isStreamTsMoreThanLocal}close(){}reset(){}findSei(e,t,i=!1){let r=4;Ks(this.nalUnitSize)&&(r=this.nalUnitSize);const s=qn(e.slice(5),r);if(ka(i)){const e=this.player.getVideoInfo();e&&e.encType&&(i=e.encType===bt)}s.forEach((e=>{const r=i?e[0]>>>1&63:31&e[0];(i&&(r===It||r===Lt)||ka(i)&&r===St.kSliceSEI)&&this.player.emit(st.videoSEI,{ts:t,data:e})}))}handleRecording(e,t,i,r,s){if(this.player.isRecordTypeFlv()){const r=new Uint8Array(e);t===Ne?this.player.recorder.addVideo(r,i):t===Oe&&this.player.recorder.addAudio(r,i)}else if(this.player.isRecordTypeMp4()){const a=new Uint8Array(e);if(this.player.recorder.isWasmMp4()){if(t===Ne)this.player.recorder.handleAddNaluTrack(a.slice(5),r,i,s);else if(t===Oe){const t=new Uint8Array(e);this.player.recorder.handleAddAudioTrack(rs(t)?t.slice(2):t.slice(1),i)}}else t===Ne&&this.player.recorder.handleAddNaluTrack(a.slice(5),r,i,s)}}updateNalUnitSize(e){const t=15&e[0];this.player.video.updateVideoInfo({encTypeCode:t});const i=t===At;this.nalUnitSize=function(e,t){let i=null;return t?e.length>=28&&(i=1+(3&e[26])):e.length>=12&&(i=1+(3&e[9])),i}(e,i),this.player.debug.log(this.TAG_NAME,`demux() isVideoSequenceHeader is true and isHevc is ${i} and nalUnitSize is ${this.nalUnitSize}`)}cryptoPayload(e,t){let i=e,r=this.player;if(r._opt.isM7sCrypto)if(r._opt.cryptoKey&&r._opt.cryptoKey.byteLength>0&&r._opt.cryptoIV&&r._opt.cryptoIV.byteLength>0){const t=this.player.video.getVideoInfo();t.encTypeCode?i=function(e,t,i,r=!1){t=new Uint8Array(t),i=new Uint8Array(i);const s=e.byteLength;let a=5;for(;a<s;){let o=(n=e.slice(a,a+4))[3]|n[2]<<8|n[1]<<16|n[0]<<24;if(o>s)break;let l=e[a+4],d=!1;if(r?(l=l>>>1&63,d=[0,1,2,3,4,5,6,7,8,9,16,17,18,19,20,21].includes(l)):(l&=31,d=1===l||5===l),d){const r=e.slice(a+4+2,a+4+o);let s=new wl.ModeOfOperation.ctr(t,new wl.Counter(i));const n=s.decrypt(r);s=null,e.set(n,a+4+2)}a=a+4+o}var n;return e}(e,r._opt.cryptoKey,r._opt.cryptoIV,t.encTypeCode===At):r.debug.warn(this.TAG_NAME,`videoInfo.encTypeCode is ${t.encTypeCode}`)}else r.debug.error(this.TAG_NAME,`isM7sCrypto cryptoKey.length is ${r._opt.cryptoKey&&r._opt.cryptoKey.byteLength} or cryptoIV.length is ${r._opt.cryptoIV&&r._opt.cryptoIV.byteLength} null`);else if(r._opt.isSm4Crypto)r._opt.sm4CryptoKey&&t?i=function(e,t,i=!1){const r=e.byteLength;let s=5;for(;s<r;){let n=(a=e.slice(s,s+4))[3]|a[2]<<8|a[1]<<16|a[0]<<24;if(n>r)break;let o=e[s+4],l=!1;if(i?(o=o>>>1&63,l=[0,1,2,3,4,5,6,7,8,9,16,17,18,19,20,21].includes(o)):(o&=31,l=1===o||5===o),l){const i=Bl(e.slice(s+4+2,s+4+n),t,0,{padding:"none",output:"array"});e.set(i,s+4+2)}s=s+4+n}var a;return e}(e,r._opt.sm4CryptoKey):r._opt.sm4CryptoKey||r.debug.error(this.TAG_NAME,"isSm4Crypto opt.sm4CryptoKey is null");else if(r._opt.isXorCrypto)if(r._opt.cryptoKey&&r._opt.cryptoKey.byteLength>0&&r._opt.cryptoIV&&r._opt.cryptoIV.byteLength>0){const t=this.player.video.getVideoInfo();i=function(e,t,i,r=!1){const s=e.byteLength;let a=5;for(;a<s;){let o=(n=e.slice(a,a+4))[3]|n[2]<<8|n[1]<<16|n[0]<<24;if(o>s)break;let l=e[a+4],d=!1;if(r?(l=l>>>1&63,d=[0,1,2,3,4,5,6,7,8,9,16,17,18,19,20,21].includes(l)):(l&=31,d=1===l||5===l),d){const r=Ml(e.slice(a+4,a+4+o),t,i);e.set(r,a+4)}a=a+4+o}var n;return e}(e,r._opt.cryptoKey,r._opt.cryptoIV,t.encTypeCode===At)}else r.debug.error(this.TAG_NAME,"isXorCrypto opt.xorCryptoKey is null");return i}cryptoPayloadAudio(e){let t=e,i=this.player;if(i._opt.isM7sCrypto)if(i._opt.cryptoKey&&i._opt.cryptoKey.byteLength>0&&i._opt.cryptoIV&&i._opt.cryptoIV.byteLength>0){e[0]>>4===_t.AAC&&(t=function(e,t,i){if(e.byteLength<=30)return e;const r=e.slice(32);let s=new wl.ModeOfOperation.ctr(t,new wl.Counter(i));const a=s.decrypt(r);return s=null,e.set(a,32),e}(e,i._opt.cryptoKey,i._opt.cryptoIV))}else i.debug.error(this.TAG_NAME,`isM7sCrypto cryptoKey.length is ${i._opt.cryptoKey&&i._opt.cryptoKey.byteLength} or cryptoIV.length is ${i._opt.cryptoIV&&i._opt.cryptoIV.byteLength} null`);return t}_decodeEnhancedH265Video(e,t){const i=e[0],r=48&i,s=15&i,a=e.slice(1,5),n=new ArrayBuffer(4),o=new Uint32Array(n),l="a"==String.fromCharCode(a[0]);if(s===Ur){if(r===Nr){const t=e.slice(5);if(l);else{const e=new Uint8Array(5+t.length);e.set([28,0,0,0,0],0),e.set(t,5),this.updateNalUnitSize(e),this.player.debug.log(this.TAG_NAME,`demux() isVideoSequenceHeader(enhancedH265) is true and nalUnitSize is ${this.nalUnitSize}`),this._doDecode(e,Ne,0,!0,0)}}}else if(s===Fr){let i=e,s=0;const a=r===Nr;if(a&&this.calcIframeIntervalTimestamp(t),l);else{o[0]=e[4],o[1]=e[3],o[2]=e[2],o[3]=0,s=o[0];i=eo(e.slice(8),a),i=this.cryptoPayload(i,a),this._doDecode(i,Ne,t,a,s)}}else if(s===Or){const i=r===Nr,s=e.slice(5);i&&this.calcIframeIntervalTimestamp(t);let a=eo(s,i);a=this.cryptoPayload(a,i),this._doDecode(a,Ne,t,i,0)}}_isEnhancedH265Header(e){return!(128&~e)}}var Fl=function(e,t,i,r){return new(i||(i=Promise))((function(s,a){function n(e){try{l(r.next(e))}catch(e){a(e)}}function o(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(n,o)}l((r=r.apply(e,t||[])).next())}))};const Ol=Symbol(32),Nl=Symbol(16),Gl=Symbol(8);class zl{constructor(e){this.g=e,this.consumed=0,e&&(this.need=e.next().value)}setG(e){this.g=e,this.demand(e.next().value,!0)}consume(){this.buffer&&this.consumed&&(this.buffer.copyWithin(0,this.consumed),this.buffer=this.buffer.subarray(0,this.buffer.length-this.consumed),this.consumed=0)}demand(e,t){return t&&this.consume(),this.need=e,this.flush()}read(e){return Fl(this,void 0,void 0,(function*(){return this.lastReadPromise&&(yield this.lastReadPromise),this.lastReadPromise=new Promise(((t,i)=>{var r;this.reject=i,this.resolve=e=>{delete this.lastReadPromise,delete this.resolve,delete this.need,t(e)};this.demand(e,!0)||null===(r=this.pull)||void 0===r||r.call(this,e)}))}))}readU32(){return this.read(Ol)}readU16(){return this.read(Nl)}readU8(){return this.read(Gl)}close(){var e;this.g&&this.g.return(),this.buffer&&this.buffer.subarray(0,0),null===(e=this.reject)||void 0===e||e.call(this,new Error("EOF")),delete this.lastReadPromise}flush(){if(!this.buffer||!this.need)return;let e=null;const t=this.buffer.subarray(this.consumed);let i=0;const r=e=>t.length<(i=e);if("number"==typeof this.need){if(r(this.need))return;e=t.subarray(0,i)}else if(this.need===Ol){if(r(4))return;e=t[0]<<24|t[1]<<16|t[2]<<8|t[3]}else if(this.need===Nl){if(r(2))return;e=t[0]<<8|t[1]}else if(this.need===Gl){if(r(1))return;e=t[0]}else if("buffer"in this.need){if("byteOffset"in this.need){if(r(this.need.byteLength-this.need.byteOffset))return;new Uint8Array(this.need.buffer,this.need.byteOffset).set(t.subarray(0,i)),e=this.need}else if(this.g)return void this.g.throw(new Error("Unsupported type"))}else{if(r(this.need.byteLength))return;new Uint8Array(this.need).set(t.subarray(0,i)),e=this.need}return this.consumed+=i,this.g?this.demand(this.g.next(e).value,!0):this.resolve&&this.resolve(e),e}write(e){if(e instanceof Uint8Array?this.malloc(e.length).set(e):"buffer"in e?this.malloc(e.byteLength).set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):this.malloc(e.byteLength).set(new Uint8Array(e)),!this.g&&!this.resolve)return new Promise((e=>this.pull=e));this.flush()}writeU32(e){this.malloc(4).set([e>>24&255,e>>16&255,e>>8&255,255&e]),this.flush()}writeU16(e){this.malloc(2).set([e>>8&255,255&e]),this.flush()}writeU8(e){this.malloc(1)[0]=e,this.flush()}malloc(e){if(this.buffer){const t=this.buffer.length,i=t+e;if(i<=this.buffer.buffer.byteLength-this.buffer.byteOffset)this.buffer=new Uint8Array(this.buffer.buffer,this.buffer.byteOffset,i);else{const e=new Uint8Array(i);e.set(this.buffer),this.buffer=e}return this.buffer.subarray(t,i)}return this.buffer=new Uint8Array(e),this.buffer}}zl.U32=Ol,zl.U16=Nl,zl.U8=Gl;class Wl extends Ul{constructor(e){super(e),this.TAG_NAME="FlvDemux",this.input=new zl(this.demux()),e.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this.input=null,this.player.debug.log(this.TAG_NAME,"destroy")}dispatch(e){this.input?this.input.write(e):this.player&&this.player.debug.warn(this.TAG_NAME,"dispatch() this.input is null")}*demux(){yield 9;const e=new ArrayBuffer(4),t=new Uint8Array(e),i=new Uint32Array(e),r=this.player;for(;;){if(!this.input)return;t[3]=0;const e=yield 15,s=e[4];t[0]=e[7],t[1]=e[6],t[2]=e[5];const a=i[0];t[0]=e[10],t[1]=e[9],t[2]=e[8],t[3]=e[11];let n=i[0];const o=(yield a).slice();if(!r)return;switch(s){case Ge:if(r._opt.hasAudio&&(r.updateStats({abps:o.byteLength}),o.byteLength>0)){let e=o;Ta(this.player._opt.m7sCryptoAudio)&&(e=this.cryptoPayloadAudio(o)),this._doDecode(e,Oe,n)}break;case ze:if(r._opt.hasVideo&&o.length>=6){let e=n;r.updateStats({vbps:o.byteLength,dts:e}),r._times.demuxStart||(r._times.demuxStart=vs());const t=o[0];if(this._isEnhancedH265Header(t))this._decodeEnhancedH265Video(o,e);else{const e=15&t,r=(t>>4&15)===dr;if(ka(e===At||e===gt))return void this.player.debug.warn(this.TAG_NAME,`demux() codecId is ${e} and ignore`);r&&(this.calcIframeIntervalTimestamp(n),null===this.nalUnitSize&&Sa(o)&&this.updateNalUnitSize(o)),i[0]=o[4],i[1]=o[3],i[2]=o[2],i[3]=0;let s=i[0],a=this.cryptoPayload(o,r);this._doDecode(a,Ne,n,r,s)}}else o.length<6&&r.debug.warn(this.TAG_NAME,`payload.length is ${o.length} less than 6 and ignore`);break;case We:if(this.player.isRecordTypeFlv()){const e=new Uint8Array(o);this.player.recorder.addMetaData(e)}const e=Ao(o);e&&e.onMetaData&&r.updateMetaData(e.onMetaData);break;default:r.debug.log(this.TAG_NAME,`demux() type is ${s}`)}}}close(){this.input=null}getInputByteLength(){let e=0;return this.input&&this.input.buffer&&(e=this.input.buffer.byteLength),e}hasUnitTypeIDR(e,t){const i=qn(e.slice(5));let r=!1;return i.forEach((e=>{const i=t?e[0]>>>1&63:31&e[0];(t&&(i===Tt||i===kt)||ka(t)&&i===St.iFrame)&&(r=!0)})),r}}class Vl extends Ul{constructor(e){super(e),this.TAG_NAME="M7sDemux",e.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this.player.debug.log(this.TAG_NAME,"destroy")}dispatch(e){const t=this.player,i=new DataView(e),r=i.getUint8(0),s=i.getUint32(1,!1),a=new ArrayBuffer(4),n=new Uint32Array(a);switch(r){case Oe:if(t._opt.hasAudio){const i=new Uint8Array(e,5);t.updateStats({abps:i.byteLength}),i.byteLength>0&&this._doDecode(i,r,s)}break;case Ne:if(t._opt.hasVideo)if(t._times.demuxStart||(t._times.demuxStart=vs()),i.byteLength>=11){const a=new Uint8Array(e,5);let o=s;t.updateStats({vbps:a.byteLength,dts:o});const l=a[0];if(this._isEnhancedH265Header(l))this._decodeEnhancedH265Video(a,s);else{const e=i.getUint8(5)>>4==1;e&&this.calcIframeIntervalTimestamp(s),n[0]=a[4],n[1]=a[3],n[2]=a[2],n[3]=0;let t=n[0],o=this.cryptoPayload(a,e);this._doDecode(o,r,s,e,t)}}else this.player.debug.warn(this.TAG_NAME,"dispatch","dv byteLength is",i.byteLength,"and return")}}}class Hl extends Wl{constructor(e){super(e),e.debug.log("WebTransportDemux","init")}destroy(){this.player.debug.log("WebTransportDemux","destroy"),super.destroy()}}class $l extends Ul{TAG_NAME="NakedFlowDemux";constructor(e){super(e),this.lastBuf=null,this.vps=null,this.sps=null,this.pps=null,this.streamVideoType=null,this.streamAudioType=null,this.tempNaluBufferList=new Uint8Array(0),this.localDts=0,this.isSendSeqHeader=!1,this.isSendAACSeqHeader=!1,e.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this.lastBuf=null,this.vps=null,this.sps=null,this.pps=null,this.streamVideoType=null,this.streamAudioType=null,this.tempNaluBufferList=new Uint8Array(0),this.localDts=0,this.localAudioDts=0,this.isSendSeqHeader=!1,this.isSendAACSeqHeader=!1,this.player.debug.log(this.TAG_NAME,"destroy")}dispatch(e){this.player;const t=new Uint8Array(e);this.extractNALu$2(t)}addNaluToBuffer(e){const t=e.byteLength+this.tempNaluBufferList.byteLength,i=new Uint8Array(t);i.set(this.tempNaluBufferList,0),i.set(e,this.tempNaluBufferList.byteLength),this.tempNaluBufferList=i}downloadNakedFlowFile(){const e=new Blob([this.tempNaluBufferList]);try{const t=document.createElement("a");t.href=window.URL.createObjectURL(e),t.download=Date.now()+".h264",t.click(),window.URL.revokeObjectURL(t.href)}catch(e){console.error("downloadTempNalu",e)}}getNaluDts(){const e=this.player._opt.nakedFlowFps;return this.localDts=this.localDts+parseInt(1e3/e),this.localDts}getNaluAudioDts(){const e=this.player.audio.audioContext.sampleRate,t=this.player.audio.audioBufferSize;return this.localDts+parseInt(t/e*1e3)}extractNALu(e){let t,i,r=0,s=e.byteLength,a=0,n=[];for(;r<s;)switch(t=e[r++],a){case 0:0===t&&(a=1);break;case 1:a=0===t?2:0;break;case 2:case 3:0===t?a=3:1===t&&r<s?(e[r],i&&n.push(e.subarray(i,r-a-1)),i=r,a=0):a=0}return i&&n.push(e.subarray(i,s)),n}extractNALu$2(e){let t=null;if(!e||e.byteLength<1)return;this.lastBuf?(t=new Uint8Array(e.byteLength+this.lastBuf.length),t.set(this.lastBuf),t.set(new Uint8Array(e),this.lastBuf.length)):t=new Uint8Array(e);let i=0,r=-1,s=-2;const a=new Array;for(let e=0;e<t.length;e+=2){const i=t[e],n=t[e+1];0==r&&0==i&&0==n?a.push(e-1):1==n&&0==i&&0==r&&0==s&&a.push(e-2),s=i,r=n}if(a.length>1)for(let e=0;e<a.length-1;++e){const r=t.subarray(a[e],a[e+1]+1);this.handleNALu(r),i=a[e+1]}else i=a[0];if(0!=i&&i<t.length)this.lastBuf=t.subarray(i);else{this.lastBuf||(this.lastBuf=t);const i=new Uint8Array(this.lastBuf.length+e.byteLength);i.set(this.lastBuf),i.set(new Uint8Array(e),this.lastBuf.length),this.lastBuf=i}}handleNALu(e){e.byteLength<4?this.player.debug.warn(this.TAG_NAME,`handleNALu nalu byteLength is ${e.byteLength} <= 4`):(e=e.slice(4),this.handleVideoNalu(e))}handleVideoNalu(e){const t=new Uint8Array(e);if(this.streamVideoType||(this.streamVideoType=function(e){let t=null,i=31&e[0];return i!==St.sps&&i!==St.pps||(t=vt),t||(i=(126&e[0])>>1,i!==Ct&&i!==Dt&&i!==Rt||(t=bt)),t}(t)),this.streamVideoType===vt){const e=this.handleAddNaluStartCode(t),i=this.extractNALu(e);if(0===i.length)return void this.player.debug.warn(this.TAG_NAME,"handleVideoNalu","naluList.length === 0");const r=[];if(i.forEach((e=>{const t=zn(e);t===St.pps||t===St.sps?this.handleVideoH264Nalu(e):Vn(t)&&r.push(e)})),1===r.length)this.handleVideoH264Nalu(r[0]);else{const e=function(e){if(0===e.length)return!1;const t=zn(e[0]);for(let i=1;i<e.length;i++)if(t!==zn(e[i]))return!1;return!0}(r);if(e){const e=zn(r[0]),t=Hn(e);this.handleVideoH264NaluList(r,t,e)}else r.forEach((e=>{this.handleVideoH264Nalu(e)}))}}else if(this.streamVideoType===bt)if(this.player._opt.nakedFlowH265DemuxUseNew){const e=this.handleAddNaluStartCode(t),i=this.extractNALu(e);if(0===i.length)return void this.player.debug.warn(this.TAG_NAME,"handleVideoNalu","h265 naluList.length === 0");const r=[];if(i.forEach((e=>{const t=to(e);t===Rt||t===Dt||t===Ct?this.handleVideoH265Nalu(e):io(t)&&r.push(e)})),1===r.length)this.handleVideoH265Nalu(r[0]);else{const e=function(e){if(0===e.length)return!1;const t=to(e[0]);for(let i=1;i<e.length;i++)if(t!==to(e[i]))return!1;return!0}(r);if(e){const e=to(r[0]),t=ro(e);this.handleVideoH265NaluList(r,t,e)}else r.forEach((e=>{this.handleVideoH265Nalu(e)}))}}else{to(t)===Rt?this.extractH265PPS(t):this.handleVideoH265Nalu(t)}else this.player.debug.error(this.TAG_NAME," this.streamVideoType is null")}extractH264PPS(e){const t=this.handleAddNaluStartCode(e);this.extractNALu(t).forEach((e=>{Wn(zn(e))?this.extractH264SEI(e):this.handleVideoH264Nalu(e)}))}extractH265PPS(e){const t=this.handleAddNaluStartCode(e);this.extractNALu(t).forEach((e=>{const t=to(e);t===xt?this.extractH265SEI(e):this.handleVideoH265Nalu(e)}))}extractH264SEI(e){const t=this.handleAddNaluStartCode(e);this.extractNALu(t).forEach((e=>{this.handleVideoH264Nalu(e)}))}extractH265SEI(e){const t=this.handleAddNaluStartCode(e);this.extractNALu(t).forEach((e=>{this.handleVideoH265Nalu(e)}))}handleAddNaluStartCode(e){const t=[0,0,0,1],i=new Uint8Array(e.length+t.length);return i.set(t),i.set(e,t.length),i}handleAudioAACNalu(e){if(!e||e.byteLength<1)return;this.streamAudioType||(this.streamAudioType=wt.AAC);let t=new Uint8Array(e);const i=t.slice(0,7);if(t=t.slice(7),!this.isSendAACSeqHeader){const e=(192&i[2])>>6,t=(60&i[2])>>2,r=(1&i[2])<<2|(192&i[3])>>6,s=new Uint8Array([175,0,e<<3|(14&t)>>1,(1&t)<<7|r<<3]);this.isSendAACSeqHeader=!0,this._doDecode(s,Oe,0,!1,0)}const r=this.getNaluAudioDts(),s=new Uint8Array(t.length+2);s.set([175,1],0),s.set(t,2),this._doDecode(s,Oe,r,!1,0)}handleAudioG711ANalu(e){if(!e||e.byteLength<1)return;this.streamAudioType||(this.streamAudioType=wt.ALAW);let t=new Uint8Array(e);const i=this.getNaluAudioDts(),r=new Uint8Array(t.length+1);r.set([114],0),r.set(t,1),this._doDecode(r,Oe,i,!1,0)}handleAudioG711UNalu(e){if(!e||e.byteLength<1)return;this.streamAudioType||(this.streamAudioType=wt.MULAW);let t=new Uint8Array(e);const i=this.getNaluAudioDts(),r=new Uint8Array(t.length+1);r.set([130],0),r.set(t,1),this._doDecode(r,Oe,i,!1,0)}handleVideoH264Nalu(e){const t=zn(e);switch(t){case St.sps:this.sps=e;break;case St.pps:this.pps=e}if(this.isSendSeqHeader){if(this.sps&&this.pps){const e=Nn({sps:this.sps,pps:this.pps}),t=this.getNaluDts();this._doDecode(e,Ne,t,!0,0),this.sps=null,this.pps=null}if(Vn(t)){this.player._times.demuxStart||(this.player._times.demuxStart=vs());const i=Hn(t),r=this.getNaluDts(),s=function(e,t){let i=[];i[0]=t?23:39,i[1]=1,i[2]=0,i[3]=0,i[4]=0,i[5]=e.byteLength>>24&255,i[6]=e.byteLength>>16&255,i[7]=e.byteLength>>8&255,i[8]=255&e.byteLength;const r=new Uint8Array(i.length+e.byteLength);return r.set(i,0),r.set(e,i.length),r}(e,i);this._preDoDecode(s,Ne,r,i,0)}else this.player.debug.warn(this.TAG_NAME,`handleVideoH264Nalu is avc seq head nalType is ${t}`)}else if(this.sps&&this.pps){this.isSendSeqHeader=!0;const e=Nn({sps:this.sps,pps:this.pps});this._doDecode(e,Ne,0,!0,0),this.sps=null,this.pps=null}}handleVideoH264NaluList(e,t,i){if(this.isSendSeqHeader){this.player._times.demuxStart||(this.player._times.demuxStart=vs());const i=this.getNaluDts(),r=Gn(e.reduce(((e,t)=>{const i=Yn(e),r=Yn(t),s=new Uint8Array(i.byteLength+r.byteLength);return s.set(i,0),s.set(r,i.byteLength),s})),t);this._preDoDecode(r,Ne,i,t,0)}else this.player.debug.warn(this.TAG_NAME,"handleVideoH264NaluList isSendSeqHeader is false")}handleVideoH265Nalu(e){const t=to(e);switch(t){case Ct:this.vps=e;break;case Dt:this.sps=e;break;case Rt:this.pps=e}if(this.isSendSeqHeader){if(this.vps&&this.sps&&this.pps){const e=Zn({vps:this.vps,sps:this.sps,pps:this.pps}),t=this.getNaluDts();this._doDecode(e,Ne,t,!0,0),this.vps=null,this.sps=null,this.pps=null}if(io(t)){this.player._times.demuxStart||(this.player._times.demuxStart=vs());const i=ro(t),r=this.getNaluDts(),s=function(e,t){let i=[];i[0]=t?28:44,i[1]=1,i[2]=0,i[3]=0,i[4]=0,i[5]=e.byteLength>>24&255,i[6]=e.byteLength>>16&255,i[7]=e.byteLength>>8&255,i[8]=255&e.byteLength;const r=new Uint8Array(i.length+e.byteLength);return r.set(i,0),r.set(e,i.length),r}(e,i);this._preDoDecode(s,Ne,r,i,0)}}else if(this.vps&&this.sps&&this.pps){this.isSendSeqHeader=!0;const e=Zn({vps:this.vps,sps:this.sps,pps:this.pps});this._doDecode(e,Ne,0,!0,0),this.vps=null,this.sps=null,this.pps=null}}handleVideoH265NaluList(e,t,i){if(this.isSendSeqHeader){this.player._times.demuxStart||(this.player._times.demuxStart=vs());const i=this.getNaluDts(),r=eo(e.reduce(((e,t)=>{const i=Yn(e),r=Yn(t),s=new Uint8Array(i.byteLength+r.byteLength);return s.set(i,0),s.set(r,i.byteLength),s})),t);this._preDoDecode(r,Ne,i,t,0)}else this.player.debug.warn(this.TAG_NAME,"handleVideoH265NaluList isSendSeqHeader is false")}_preDoDecode(e,t,i,r,s){this.player.updateStats({vbps:e.byteLength,dts:i}),r&&this.calcIframeIntervalTimestamp(i),this._doDecode(e,Ne,i,r,s)}getInputByteLength(){let e=0;return this.lastBuf&&(e=this.lastBuf.byteLength),e}}class jl extends Ul{constructor(e){super(e),this.player=e,e.debug.log("EmptyDemux","init")}destroy(){super.destroy(),this.player.debug.log("EmptyDemux","destroy")}}var Kl=Zr((function(e,t){var i,r,s,a=(i=new Date,r=4,s={setLogLevel:function(e){r=e==this.debug?1:e==this.info?2:e==this.warn?3:(this.error,4)},debug:function(e,t){void 0===console.debug&&(console.debug=console.log),1>=r&&console.debug("["+a.getDurationString(new Date-i,1e3)+"]","["+e+"]",t)},log:function(e,t){this.debug(e.msg)},info:function(e,t){2>=r&&console.info("["+a.getDurationString(new Date-i,1e3)+"]","["+e+"]",t)},warn:function(e,t){3>=r&&console.warn("["+a.getDurationString(new Date-i,1e3)+"]","["+e+"]",t)},error:function(e,t){4>=r&&console.error("["+a.getDurationString(new Date-i,1e3)+"]","["+e+"]",t)}},s);a.getDurationString=function(e,t){var i;function r(e,t){for(var i=(""+e).split(".");i[0].length<t;)i[0]="0"+i[0];return i.join(".")}e<0?(i=!0,e=-e):i=!1;var s=e/(t||1),a=Math.floor(s/3600);s-=3600*a;var n=Math.floor(s/60),o=1e3*(s-=60*n);return o-=1e3*(s=Math.floor(s)),o=Math.floor(o),(i?"-":"")+a+":"+r(n,2)+":"+r(s,2)+"."+r(o,3)},a.printRanges=function(e){var t=e.length;if(t>0){for(var i="",r=0;r<t;r++)r>0&&(i+=","),i+="["+a.getDurationString(e.start(r))+","+a.getDurationString(e.end(r))+"]";return i}return"(empty)"},t.Log=a;var n=function(e){if(!(e instanceof ArrayBuffer))throw"Needs an array buffer";this.buffer=e,this.dataview=new DataView(e),this.position=0};n.prototype.getPosition=function(){return this.position},n.prototype.getEndPosition=function(){return this.buffer.byteLength},n.prototype.getLength=function(){return this.buffer.byteLength},n.prototype.seek=function(e){var t=Math.max(0,Math.min(this.buffer.byteLength,e));return this.position=isNaN(t)||!isFinite(t)?0:t,!0},n.prototype.isEos=function(){return this.getPosition()>=this.getEndPosition()},n.prototype.readAnyInt=function(e,t){var i=0;if(this.position+e<=this.buffer.byteLength){switch(e){case 1:i=t?this.dataview.getInt8(this.position):this.dataview.getUint8(this.position);break;case 2:i=t?this.dataview.getInt16(this.position):this.dataview.getUint16(this.position);break;case 3:if(t)throw"No method for reading signed 24 bits values";i=this.dataview.getUint8(this.position)<<16,i|=this.dataview.getUint8(this.position+1)<<8,i|=this.dataview.getUint8(this.position+2);break;case 4:i=t?this.dataview.getInt32(this.position):this.dataview.getUint32(this.position);break;case 8:if(t)throw"No method for reading signed 64 bits values";i=this.dataview.getUint32(this.position)<<32,i|=this.dataview.getUint32(this.position+4);break;default:throw"readInt method not implemented for size: "+e}return this.position+=e,i}throw"Not enough bytes in buffer"},n.prototype.readUint8=function(){return this.readAnyInt(1,!1)},n.prototype.readUint16=function(){return this.readAnyInt(2,!1)},n.prototype.readUint24=function(){return this.readAnyInt(3,!1)},n.prototype.readUint32=function(){return this.readAnyInt(4,!1)},n.prototype.readUint64=function(){return this.readAnyInt(8,!1)},n.prototype.readString=function(e){if(this.position+e<=this.buffer.byteLength){for(var t="",i=0;i<e;i++)t+=String.fromCharCode(this.readUint8());return t}throw"Not enough bytes in buffer"},n.prototype.readCString=function(){for(var e=[];;){var t=this.readUint8();if(0===t)break;e.push(t)}return String.fromCharCode.apply(null,e)},n.prototype.readInt8=function(){return this.readAnyInt(1,!0)},n.prototype.readInt16=function(){return this.readAnyInt(2,!0)},n.prototype.readInt32=function(){return this.readAnyInt(4,!0)},n.prototype.readInt64=function(){return this.readAnyInt(8,!1)},n.prototype.readUint8Array=function(e){for(var t=new Uint8Array(e),i=0;i<e;i++)t[i]=this.readUint8();return t},n.prototype.readInt16Array=function(e){for(var t=new Int16Array(e),i=0;i<e;i++)t[i]=this.readInt16();return t},n.prototype.readUint16Array=function(e){for(var t=new Int16Array(e),i=0;i<e;i++)t[i]=this.readUint16();return t},n.prototype.readUint32Array=function(e){for(var t=new Uint32Array(e),i=0;i<e;i++)t[i]=this.readUint32();return t},n.prototype.readInt32Array=function(e){for(var t=new Int32Array(e),i=0;i<e;i++)t[i]=this.readInt32();return t},t.MP4BoxStream=n;var o=function(e,t,i){this._byteOffset=t||0,e instanceof ArrayBuffer?this.buffer=e:"object"==typeof e?(this.dataView=e,t&&(this._byteOffset+=t)):this.buffer=new ArrayBuffer(e||0),this.position=0,this.endianness=null==i?o.LITTLE_ENDIAN:i};o.prototype={},o.prototype.getPosition=function(){return this.position},o.prototype._realloc=function(e){if(this._dynamicSize){var t=this._byteOffset+this.position+e,i=this._buffer.byteLength;if(t<=i)t>this._byteLength&&(this._byteLength=t);else{for(i<1&&(i=1);t>i;)i*=2;var r=new ArrayBuffer(i),s=new Uint8Array(this._buffer);new Uint8Array(r,0,s.length).set(s),this.buffer=r,this._byteLength=t}}},o.prototype._trimAlloc=function(){if(this._byteLength!=this._buffer.byteLength){var e=new ArrayBuffer(this._byteLength),t=new Uint8Array(e),i=new Uint8Array(this._buffer,0,t.length);t.set(i),this.buffer=e}},o.BIG_ENDIAN=!1,o.LITTLE_ENDIAN=!0,o.prototype._byteLength=0,Object.defineProperty(o.prototype,"byteLength",{get:function(){return this._byteLength-this._byteOffset}}),Object.defineProperty(o.prototype,"buffer",{get:function(){return this._trimAlloc(),this._buffer},set:function(e){this._buffer=e,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._buffer.byteLength}}),Object.defineProperty(o.prototype,"byteOffset",{get:function(){return this._byteOffset},set:function(e){this._byteOffset=e,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._buffer.byteLength}}),Object.defineProperty(o.prototype,"dataView",{get:function(){return this._dataView},set:function(e){this._byteOffset=e.byteOffset,this._buffer=e.buffer,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._byteOffset+e.byteLength}}),o.prototype.seek=function(e){var t=Math.max(0,Math.min(this.byteLength,e));this.position=isNaN(t)||!isFinite(t)?0:t},o.prototype.isEof=function(){return this.position>=this._byteLength},o.prototype.mapUint8Array=function(e){this._realloc(1*e);var t=new Uint8Array(this._buffer,this.byteOffset+this.position,e);return this.position+=1*e,t},o.prototype.readInt32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var i=new Int32Array(e);return o.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),o.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},o.prototype.readInt16Array=function(e,t){e=null==e?this.byteLength-this.position/2:e;var i=new Int16Array(e);return o.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),o.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},o.prototype.readInt8Array=function(e){e=null==e?this.byteLength-this.position:e;var t=new Int8Array(e);return o.memcpy(t.buffer,0,this.buffer,this.byteOffset+this.position,e*t.BYTES_PER_ELEMENT),this.position+=t.byteLength,t},o.prototype.readUint32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var i=new Uint32Array(e);return o.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),o.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},o.prototype.readUint16Array=function(e,t){e=null==e?this.byteLength-this.position/2:e;var i=new Uint16Array(e);return o.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),o.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},o.prototype.readUint8Array=function(e){e=null==e?this.byteLength-this.position:e;var t=new Uint8Array(e);return o.memcpy(t.buffer,0,this.buffer,this.byteOffset+this.position,e*t.BYTES_PER_ELEMENT),this.position+=t.byteLength,t},o.prototype.readFloat64Array=function(e,t){e=null==e?this.byteLength-this.position/8:e;var i=new Float64Array(e);return o.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),o.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},o.prototype.readFloat32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var i=new Float32Array(e);return o.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),o.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},o.prototype.readInt32=function(e){var t=this._dataView.getInt32(this.position,null==e?this.endianness:e);return this.position+=4,t},o.prototype.readInt16=function(e){var t=this._dataView.getInt16(this.position,null==e?this.endianness:e);return this.position+=2,t},o.prototype.readInt8=function(){var e=this._dataView.getInt8(this.position);return this.position+=1,e},o.prototype.readUint32=function(e){var t=this._dataView.getUint32(this.position,null==e?this.endianness:e);return this.position+=4,t},o.prototype.readUint16=function(e){var t=this._dataView.getUint16(this.position,null==e?this.endianness:e);return this.position+=2,t},o.prototype.readUint8=function(){var e=this._dataView.getUint8(this.position);return this.position+=1,e},o.prototype.readFloat32=function(e){var t=this._dataView.getFloat32(this.position,null==e?this.endianness:e);return this.position+=4,t},o.prototype.readFloat64=function(e){var t=this._dataView.getFloat64(this.position,null==e?this.endianness:e);return this.position+=8,t},o.endianness=new Int8Array(new Int16Array([1]).buffer)[0]>0,o.memcpy=function(e,t,i,r,s){var a=new Uint8Array(e,t,s),n=new Uint8Array(i,r,s);a.set(n)},o.arrayToNative=function(e,t){return t==this.endianness?e:this.flipArrayEndianness(e)},o.nativeToEndian=function(e,t){return this.endianness==t?e:this.flipArrayEndianness(e)},o.flipArrayEndianness=function(e){for(var t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),i=0;i<e.byteLength;i+=e.BYTES_PER_ELEMENT)for(var r=i+e.BYTES_PER_ELEMENT-1,s=i;r>s;r--,s++){var a=t[s];t[s]=t[r],t[r]=a}return e},o.prototype.failurePosition=0,String.fromCharCodeUint8=function(e){for(var t=[],i=0;i<e.length;i++)t[i]=e[i];return String.fromCharCode.apply(null,t)},o.prototype.readString=function(e,t){return null==t||"ASCII"==t?String.fromCharCodeUint8.apply(null,[this.mapUint8Array(null==e?this.byteLength-this.position:e)]):new TextDecoder(t).decode(this.mapUint8Array(e))},o.prototype.readCString=function(e){var t=this.byteLength-this.position,i=new Uint8Array(this._buffer,this._byteOffset+this.position),r=t;null!=e&&(r=Math.min(e,t));for(var s=0;s<r&&0!==i[s];s++);var a=String.fromCharCodeUint8.apply(null,[this.mapUint8Array(s)]);return null!=e?this.position+=r-s:s!=t&&(this.position+=1),a};var l=Math.pow(2,32);o.prototype.readInt64=function(){return this.readInt32()*l+this.readUint32()},o.prototype.readUint64=function(){return this.readUint32()*l+this.readUint32()},o.prototype.readInt64=function(){return this.readUint32()*l+this.readUint32()},o.prototype.readUint24=function(){return(this.readUint8()<<16)+(this.readUint8()<<8)+this.readUint8()},t.DataStream=o,o.prototype.save=function(e){var t=new Blob([this.buffer]);if(!window.URL||!URL.createObjectURL)throw"DataStream.save: Can't create object URL.";var i=window.URL.createObjectURL(t),r=document.createElement("a");document.body.appendChild(r),r.setAttribute("href",i),r.setAttribute("download",e),r.setAttribute("target","_self"),r.click(),window.URL.revokeObjectURL(i)},o.prototype._dynamicSize=!0,Object.defineProperty(o.prototype,"dynamicSize",{get:function(){return this._dynamicSize},set:function(e){e||this._trimAlloc(),this._dynamicSize=e}}),o.prototype.shift=function(e){var t=new ArrayBuffer(this._byteLength-e),i=new Uint8Array(t),r=new Uint8Array(this._buffer,e,i.length);i.set(r),this.buffer=t,this.position-=e},o.prototype.writeInt32Array=function(e,t){if(this._realloc(4*e.length),e instanceof Int32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)o.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapInt32Array(e.length,t);else for(var i=0;i<e.length;i++)this.writeInt32(e[i],t)},o.prototype.writeInt16Array=function(e,t){if(this._realloc(2*e.length),e instanceof Int16Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)o.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapInt16Array(e.length,t);else for(var i=0;i<e.length;i++)this.writeInt16(e[i],t)},o.prototype.writeInt8Array=function(e){if(this._realloc(1*e.length),e instanceof Int8Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)o.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapInt8Array(e.length);else for(var t=0;t<e.length;t++)this.writeInt8(e[t])},o.prototype.writeUint32Array=function(e,t){if(this._realloc(4*e.length),e instanceof Uint32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)o.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapUint32Array(e.length,t);else for(var i=0;i<e.length;i++)this.writeUint32(e[i],t)},o.prototype.writeUint16Array=function(e,t){if(this._realloc(2*e.length),e instanceof Uint16Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)o.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapUint16Array(e.length,t);else for(var i=0;i<e.length;i++)this.writeUint16(e[i],t)},o.prototype.writeUint8Array=function(e){if(this._realloc(1*e.length),e instanceof Uint8Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)o.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapUint8Array(e.length);else for(var t=0;t<e.length;t++)this.writeUint8(e[t])},o.prototype.writeFloat64Array=function(e,t){if(this._realloc(8*e.length),e instanceof Float64Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)o.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapFloat64Array(e.length,t);else for(var i=0;i<e.length;i++)this.writeFloat64(e[i],t)},o.prototype.writeFloat32Array=function(e,t){if(this._realloc(4*e.length),e instanceof Float32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)o.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapFloat32Array(e.length,t);else for(var i=0;i<e.length;i++)this.writeFloat32(e[i],t)},o.prototype.writeInt32=function(e,t){this._realloc(4),this._dataView.setInt32(this.position,e,null==t?this.endianness:t),this.position+=4},o.prototype.writeInt16=function(e,t){this._realloc(2),this._dataView.setInt16(this.position,e,null==t?this.endianness:t),this.position+=2},o.prototype.writeInt8=function(e){this._realloc(1),this._dataView.setInt8(this.position,e),this.position+=1},o.prototype.writeUint32=function(e,t){this._realloc(4),this._dataView.setUint32(this.position,e,null==t?this.endianness:t),this.position+=4},o.prototype.writeUint16=function(e,t){this._realloc(2),this._dataView.setUint16(this.position,e,null==t?this.endianness:t),this.position+=2},o.prototype.writeUint8=function(e){this._realloc(1),this._dataView.setUint8(this.position,e),this.position+=1},o.prototype.writeFloat32=function(e,t){this._realloc(4),this._dataView.setFloat32(this.position,e,null==t?this.endianness:t),this.position+=4},o.prototype.writeFloat64=function(e,t){this._realloc(8),this._dataView.setFloat64(this.position,e,null==t?this.endianness:t),this.position+=8},o.prototype.writeUCS2String=function(e,t,i){null==i&&(i=e.length);for(var r=0;r<e.length&&r<i;r++)this.writeUint16(e.charCodeAt(r),t);for(;r<i;r++)this.writeUint16(0)},o.prototype.writeString=function(e,t,i){var r=0;if(null==t||"ASCII"==t)if(null!=i){var s=Math.min(e.length,i);for(r=0;r<s;r++)this.writeUint8(e.charCodeAt(r));for(;r<i;r++)this.writeUint8(0)}else for(r=0;r<e.length;r++)this.writeUint8(e.charCodeAt(r));else this.writeUint8Array(new TextEncoder(t).encode(e.substring(0,i)))},o.prototype.writeCString=function(e,t){var i=0;if(null!=t){var r=Math.min(e.length,t);for(i=0;i<r;i++)this.writeUint8(e.charCodeAt(i));for(;i<t;i++)this.writeUint8(0)}else{for(i=0;i<e.length;i++)this.writeUint8(e.charCodeAt(i));this.writeUint8(0)}},o.prototype.writeStruct=function(e,t){for(var i=0;i<e.length;i+=2){var r=e[i+1];this.writeType(r,t[e[i]],t)}},o.prototype.writeType=function(e,t,i){var r;if("function"==typeof e)return e(this,t);if("object"==typeof e&&!(e instanceof Array))return e.set(this,t,i);var s=null,a="ASCII",n=this.position;switch("string"==typeof e&&/:/.test(e)&&(r=e.split(":"),e=r[0],s=parseInt(r[1])),"string"==typeof e&&/,/.test(e)&&(r=e.split(","),e=r[0],a=parseInt(r[1])),e){case"uint8":this.writeUint8(t);break;case"int8":this.writeInt8(t);break;case"uint16":this.writeUint16(t,this.endianness);break;case"int16":this.writeInt16(t,this.endianness);break;case"uint32":this.writeUint32(t,this.endianness);break;case"int32":this.writeInt32(t,this.endianness);break;case"float32":this.writeFloat32(t,this.endianness);break;case"float64":this.writeFloat64(t,this.endianness);break;case"uint16be":this.writeUint16(t,o.BIG_ENDIAN);break;case"int16be":this.writeInt16(t,o.BIG_ENDIAN);break;case"uint32be":this.writeUint32(t,o.BIG_ENDIAN);break;case"int32be":this.writeInt32(t,o.BIG_ENDIAN);break;case"float32be":this.writeFloat32(t,o.BIG_ENDIAN);break;case"float64be":this.writeFloat64(t,o.BIG_ENDIAN);break;case"uint16le":this.writeUint16(t,o.LITTLE_ENDIAN);break;case"int16le":this.writeInt16(t,o.LITTLE_ENDIAN);break;case"uint32le":this.writeUint32(t,o.LITTLE_ENDIAN);break;case"int32le":this.writeInt32(t,o.LITTLE_ENDIAN);break;case"float32le":this.writeFloat32(t,o.LITTLE_ENDIAN);break;case"float64le":this.writeFloat64(t,o.LITTLE_ENDIAN);break;case"cstring":this.writeCString(t,s);break;case"string":this.writeString(t,a,s);break;case"u16string":this.writeUCS2String(t,this.endianness,s);break;case"u16stringle":this.writeUCS2String(t,o.LITTLE_ENDIAN,s);break;case"u16stringbe":this.writeUCS2String(t,o.BIG_ENDIAN,s);break;default:if(3==e.length){for(var l=e[1],d=0;d<t.length;d++)this.writeType(l,t[d]);break}this.writeStruct(e,t)}null!=s&&(this.position=n,this._realloc(s),this.position=n+s)},o.prototype.writeUint64=function(e){var t=Math.floor(e/l);this.writeUint32(t),this.writeUint32(4294967295&e)},o.prototype.writeUint24=function(e){this.writeUint8((16711680&e)>>16),this.writeUint8((65280&e)>>8),this.writeUint8(255&e)},o.prototype.adjustUint32=function(e,t){var i=this.position;this.seek(e),this.writeUint32(t),this.seek(i)},o.prototype.mapInt32Array=function(e,t){this._realloc(4*e);var i=new Int32Array(this._buffer,this.byteOffset+this.position,e);return o.arrayToNative(i,null==t?this.endianness:t),this.position+=4*e,i},o.prototype.mapInt16Array=function(e,t){this._realloc(2*e);var i=new Int16Array(this._buffer,this.byteOffset+this.position,e);return o.arrayToNative(i,null==t?this.endianness:t),this.position+=2*e,i},o.prototype.mapInt8Array=function(e){this._realloc(1*e);var t=new Int8Array(this._buffer,this.byteOffset+this.position,e);return this.position+=1*e,t},o.prototype.mapUint32Array=function(e,t){this._realloc(4*e);var i=new Uint32Array(this._buffer,this.byteOffset+this.position,e);return o.arrayToNative(i,null==t?this.endianness:t),this.position+=4*e,i},o.prototype.mapUint16Array=function(e,t){this._realloc(2*e);var i=new Uint16Array(this._buffer,this.byteOffset+this.position,e);return o.arrayToNative(i,null==t?this.endianness:t),this.position+=2*e,i},o.prototype.mapFloat64Array=function(e,t){this._realloc(8*e);var i=new Float64Array(this._buffer,this.byteOffset+this.position,e);return o.arrayToNative(i,null==t?this.endianness:t),this.position+=8*e,i},o.prototype.mapFloat32Array=function(e,t){this._realloc(4*e);var i=new Float32Array(this._buffer,this.byteOffset+this.position,e);return o.arrayToNative(i,null==t?this.endianness:t),this.position+=4*e,i};var d=function(e){this.buffers=[],this.bufferIndex=-1,e&&(this.insertBuffer(e),this.bufferIndex=0)};(d.prototype=new o(new ArrayBuffer,0,o.BIG_ENDIAN)).initialized=function(){var e;return this.bufferIndex>-1||(this.buffers.length>0?0===(e=this.buffers[0]).fileStart?(this.buffer=e,this.bufferIndex=0,a.debug("MultiBufferStream","Stream ready for parsing"),!0):(a.warn("MultiBufferStream","The first buffer should have a fileStart of 0"),this.logBufferLevel(),!1):(a.warn("MultiBufferStream","No buffer to start parsing from"),this.logBufferLevel(),!1))},ArrayBuffer.concat=function(e,t){a.debug("ArrayBuffer","Trying to create a new buffer of size: "+(e.byteLength+t.byteLength));var i=new Uint8Array(e.byteLength+t.byteLength);return i.set(new Uint8Array(e),0),i.set(new Uint8Array(t),e.byteLength),i.buffer},d.prototype.reduceBuffer=function(e,t,i){var r;return(r=new Uint8Array(i)).set(new Uint8Array(e,t,i)),r.buffer.fileStart=e.fileStart+t,r.buffer.usedBytes=0,r.buffer},d.prototype.insertBuffer=function(e){for(var t=!0,i=0;i<this.buffers.length;i++){var r=this.buffers[i];if(e.fileStart<=r.fileStart){if(e.fileStart===r.fileStart){if(e.byteLength>r.byteLength){this.buffers.splice(i,1),i--;continue}a.warn("MultiBufferStream","Buffer (fileStart: "+e.fileStart+" - Length: "+e.byteLength+") already appended, ignoring")}else e.fileStart+e.byteLength<=r.fileStart||(e=this.reduceBuffer(e,0,r.fileStart-e.fileStart)),a.debug("MultiBufferStream","Appending new buffer (fileStart: "+e.fileStart+" - Length: "+e.byteLength+")"),this.buffers.splice(i,0,e),0===i&&(this.buffer=e);t=!1;break}if(e.fileStart<r.fileStart+r.byteLength){var s=r.fileStart+r.byteLength-e.fileStart,n=e.byteLength-s;if(!(n>0)){t=!1;break}e=this.reduceBuffer(e,s,n)}}t&&(a.debug("MultiBufferStream","Appending new buffer (fileStart: "+e.fileStart+" - Length: "+e.byteLength+")"),this.buffers.push(e),0===i&&(this.buffer=e))},d.prototype.logBufferLevel=function(e){var t,i,r,s,n,o=[],l="";for(r=0,s=0,t=0;t<this.buffers.length;t++)i=this.buffers[t],0===t?(n={},o.push(n),n.start=i.fileStart,n.end=i.fileStart+i.byteLength,l+="["+n.start+"-"):n.end===i.fileStart?n.end=i.fileStart+i.byteLength:((n={}).start=i.fileStart,l+=o[o.length-1].end-1+"], ["+n.start+"-",n.end=i.fileStart+i.byteLength,o.push(n)),r+=i.usedBytes,s+=i.byteLength;o.length>0&&(l+=n.end-1+"]");var d=e?a.info:a.debug;0===this.buffers.length?d("MultiBufferStream","No more buffer in memory"):d("MultiBufferStream",this.buffers.length+" stored buffer(s) ("+r+"/"+s+" bytes), continuous ranges: "+l)},d.prototype.cleanBuffers=function(){var e,t;for(e=0;e<this.buffers.length;e++)(t=this.buffers[e]).usedBytes===t.byteLength&&(a.debug("MultiBufferStream","Removing buffer #"+e),this.buffers.splice(e,1),e--)},d.prototype.mergeNextBuffer=function(){var e;if(this.bufferIndex+1<this.buffers.length){if((e=this.buffers[this.bufferIndex+1]).fileStart===this.buffer.fileStart+this.buffer.byteLength){var t=this.buffer.byteLength,i=this.buffer.usedBytes,r=this.buffer.fileStart;return this.buffers[this.bufferIndex]=ArrayBuffer.concat(this.buffer,e),this.buffer=this.buffers[this.bufferIndex],this.buffers.splice(this.bufferIndex+1,1),this.buffer.usedBytes=i,this.buffer.fileStart=r,a.debug("ISOFile","Concatenating buffer for box parsing (length: "+t+"->"+this.buffer.byteLength+")"),!0}return!1}return!1},d.prototype.findPosition=function(e,t,i){var r,s=null,n=-1;for(r=!0===e?0:this.bufferIndex;r<this.buffers.length&&(s=this.buffers[r]).fileStart<=t;)n=r,i&&(s.fileStart+s.byteLength<=t?s.usedBytes=s.byteLength:s.usedBytes=t-s.fileStart,this.logBufferLevel()),r++;return-1!==n&&(s=this.buffers[n]).fileStart+s.byteLength>=t?(a.debug("MultiBufferStream","Found position in existing buffer #"+n),n):-1},d.prototype.findEndContiguousBuf=function(e){var t,i,r,s=void 0!==e?e:this.bufferIndex;if(i=this.buffers[s],this.buffers.length>s+1)for(t=s+1;t<this.buffers.length&&(r=this.buffers[t]).fileStart===i.fileStart+i.byteLength;t++)i=r;return i.fileStart+i.byteLength},d.prototype.getEndFilePositionAfter=function(e){var t=this.findPosition(!0,e,!1);return-1!==t?this.findEndContiguousBuf(t):e},d.prototype.addUsedBytes=function(e){this.buffer.usedBytes+=e,this.logBufferLevel()},d.prototype.setAllUsedBytes=function(){this.buffer.usedBytes=this.buffer.byteLength,this.logBufferLevel()},d.prototype.seek=function(e,t,i){var r;return-1!==(r=this.findPosition(t,e,i))?(this.buffer=this.buffers[r],this.bufferIndex=r,this.position=e-this.buffer.fileStart,a.debug("MultiBufferStream","Repositioning parser at buffer position: "+this.position),!0):(a.debug("MultiBufferStream","Position "+e+" not found in buffered data"),!1)},d.prototype.getPosition=function(){if(-1===this.bufferIndex||null===this.buffers[this.bufferIndex])throw"Error accessing position in the MultiBufferStream";return this.buffers[this.bufferIndex].fileStart+this.position},d.prototype.getLength=function(){return this.byteLength},d.prototype.getEndPosition=function(){if(-1===this.bufferIndex||null===this.buffers[this.bufferIndex])throw"Error accessing position in the MultiBufferStream";return this.buffers[this.bufferIndex].fileStart+this.byteLength},t.MultiBufferStream=d;var h=function(){var e=[];e[3]="ES_Descriptor",e[4]="DecoderConfigDescriptor",e[5]="DecoderSpecificInfo",e[6]="SLConfigDescriptor",this.getDescriptorName=function(t){return e[t]};var t=this,i={};return this.parseOneDescriptor=function(t){var r,s,n,o=0;for(r=t.readUint8(),n=t.readUint8();128&n;)o=(127&n)<<7,n=t.readUint8();return o+=127&n,a.debug("MPEG4DescriptorParser","Found "+(e[r]||"Descriptor "+r)+", size "+o+" at position "+t.getPosition()),(s=e[r]?new i[e[r]](o):new i.Descriptor(o)).parse(t),s},i.Descriptor=function(e,t){this.tag=e,this.size=t,this.descs=[]},i.Descriptor.prototype.parse=function(e){this.data=e.readUint8Array(this.size)},i.Descriptor.prototype.findDescriptor=function(e){for(var t=0;t<this.descs.length;t++)if(this.descs[t].tag==e)return this.descs[t];return null},i.Descriptor.prototype.parseRemainingDescriptors=function(e){for(var i=e.position;e.position<i+this.size;){var r=t.parseOneDescriptor(e);this.descs.push(r)}},i.ES_Descriptor=function(e){i.Descriptor.call(this,3,e)},i.ES_Descriptor.prototype=new i.Descriptor,i.ES_Descriptor.prototype.parse=function(e){if(this.ES_ID=e.readUint16(),this.flags=e.readUint8(),this.size-=3,128&this.flags?(this.dependsOn_ES_ID=e.readUint16(),this.size-=2):this.dependsOn_ES_ID=0,64&this.flags){var t=e.readUint8();this.URL=e.readString(t),this.size-=t+1}else this.URL="";32&this.flags?(this.OCR_ES_ID=e.readUint16(),this.size-=2):this.OCR_ES_ID=0,this.parseRemainingDescriptors(e)},i.ES_Descriptor.prototype.getOTI=function(e){var t=this.findDescriptor(4);return t?t.oti:0},i.ES_Descriptor.prototype.getAudioConfig=function(e){var t=this.findDescriptor(4);if(!t)return null;var i=t.findDescriptor(5);if(i&&i.data){var r=(248&i.data[0])>>3;return 31===r&&i.data.length>=2&&(r=32+((7&i.data[0])<<3)+((224&i.data[1])>>5)),r}return null},i.DecoderConfigDescriptor=function(e){i.Descriptor.call(this,4,e)},i.DecoderConfigDescriptor.prototype=new i.Descriptor,i.DecoderConfigDescriptor.prototype.parse=function(e){this.oti=e.readUint8(),this.streamType=e.readUint8(),this.bufferSize=e.readUint24(),this.maxBitrate=e.readUint32(),this.avgBitrate=e.readUint32(),this.size-=13,this.parseRemainingDescriptors(e)},i.DecoderSpecificInfo=function(e){i.Descriptor.call(this,5,e)},i.DecoderSpecificInfo.prototype=new i.Descriptor,i.SLConfigDescriptor=function(e){i.Descriptor.call(this,6,e)},i.SLConfigDescriptor.prototype=new i.Descriptor,this};t.MPEG4DescriptorParser=h;var c={ERR_INVALID_DATA:-1,ERR_NOT_ENOUGH_DATA:0,OK:1,BASIC_BOXES:["mdat","idat","free","skip","meco","strk"],FULL_BOXES:["hmhd","nmhd","iods","xml ","bxml","ipro","mere"],CONTAINER_BOXES:[["moov",["trak","pssh"]],["trak"],["edts"],["mdia"],["minf"],["dinf"],["stbl",["sgpd","sbgp"]],["mvex",["trex"]],["moof",["traf"]],["traf",["trun","sgpd","sbgp"]],["vttc"],["tref"],["iref"],["mfra",["tfra"]],["meco"],["hnti"],["hinf"],["strk"],["strd"],["sinf"],["rinf"],["schi"],["trgr"],["udta",["kind"]],["iprp",["ipma"]],["ipco"]],boxCodes:[],fullBoxCodes:[],containerBoxCodes:[],sampleEntryCodes:{},sampleGroupEntryCodes:[],trackGroupTypes:[],UUIDBoxes:{},UUIDs:[],initialize:function(){c.FullBox.prototype=new c.Box,c.ContainerBox.prototype=new c.Box,c.SampleEntry.prototype=new c.Box,c.TrackGroupTypeBox.prototype=new c.FullBox,c.BASIC_BOXES.forEach((function(e){c.createBoxCtor(e)})),c.FULL_BOXES.forEach((function(e){c.createFullBoxCtor(e)})),c.CONTAINER_BOXES.forEach((function(e){c.createContainerBoxCtor(e[0],null,e[1])}))},Box:function(e,t,i){this.type=e,this.size=t,this.uuid=i},FullBox:function(e,t,i){c.Box.call(this,e,t,i),this.flags=0,this.version=0},ContainerBox:function(e,t,i){c.Box.call(this,e,t,i),this.boxes=[]},SampleEntry:function(e,t,i,r){c.ContainerBox.call(this,e,t),this.hdr_size=i,this.start=r},SampleGroupEntry:function(e){this.grouping_type=e},TrackGroupTypeBox:function(e,t){c.FullBox.call(this,e,t)},createBoxCtor:function(e,t){c.boxCodes.push(e),c[e+"Box"]=function(t){c.Box.call(this,e,t)},c[e+"Box"].prototype=new c.Box,t&&(c[e+"Box"].prototype.parse=t)},createFullBoxCtor:function(e,t){c[e+"Box"]=function(t){c.FullBox.call(this,e,t)},c[e+"Box"].prototype=new c.FullBox,c[e+"Box"].prototype.parse=function(e){this.parseFullHeader(e),t&&t.call(this,e)}},addSubBoxArrays:function(e){if(e){this.subBoxNames=e;for(var t=e.length,i=0;i<t;i++)this[e[i]+"s"]=[]}},createContainerBoxCtor:function(e,t,i){c[e+"Box"]=function(t){c.ContainerBox.call(this,e,t),c.addSubBoxArrays.call(this,i)},c[e+"Box"].prototype=new c.ContainerBox,t&&(c[e+"Box"].prototype.parse=t)},createMediaSampleEntryCtor:function(e,t,i){c.sampleEntryCodes[e]=[],c[e+"SampleEntry"]=function(e,t){c.SampleEntry.call(this,e,t),c.addSubBoxArrays.call(this,i)},c[e+"SampleEntry"].prototype=new c.SampleEntry,t&&(c[e+"SampleEntry"].prototype.parse=t)},createSampleEntryCtor:function(e,t,i,r){c.sampleEntryCodes[e].push(t),c[t+"SampleEntry"]=function(i){c[e+"SampleEntry"].call(this,t,i),c.addSubBoxArrays.call(this,r)},c[t+"SampleEntry"].prototype=new c[e+"SampleEntry"],i&&(c[t+"SampleEntry"].prototype.parse=i)},createEncryptedSampleEntryCtor:function(e,t,i){c.createSampleEntryCtor.call(this,e,t,i,["sinf"])},createSampleGroupCtor:function(e,t){c[e+"SampleGroupEntry"]=function(t){c.SampleGroupEntry.call(this,e,t)},c[e+"SampleGroupEntry"].prototype=new c.SampleGroupEntry,t&&(c[e+"SampleGroupEntry"].prototype.parse=t)},createTrackGroupCtor:function(e,t){c[e+"TrackGroupTypeBox"]=function(t){c.TrackGroupTypeBox.call(this,e,t)},c[e+"TrackGroupTypeBox"].prototype=new c.TrackGroupTypeBox,t&&(c[e+"TrackGroupTypeBox"].prototype.parse=t)},createUUIDBox:function(e,t,i,r){c.UUIDs.push(e),c.UUIDBoxes[e]=function(r){t?c.FullBox.call(this,"uuid",r,e):i?c.ContainerBox.call(this,"uuid",r,e):c.Box.call(this,"uuid",r,e)},c.UUIDBoxes[e].prototype=t?new c.FullBox:i?new c.ContainerBox:new c.Box,r&&(c.UUIDBoxes[e].prototype.parse=t?function(e){this.parseFullHeader(e),r&&r.call(this,e)}:r)}};c.initialize(),c.TKHD_FLAG_ENABLED=1,c.TKHD_FLAG_IN_MOVIE=2,c.TKHD_FLAG_IN_PREVIEW=4,c.TFHD_FLAG_BASE_DATA_OFFSET=1,c.TFHD_FLAG_SAMPLE_DESC=2,c.TFHD_FLAG_SAMPLE_DUR=8,c.TFHD_FLAG_SAMPLE_SIZE=16,c.TFHD_FLAG_SAMPLE_FLAGS=32,c.TFHD_FLAG_DUR_EMPTY=65536,c.TFHD_FLAG_DEFAULT_BASE_IS_MOOF=131072,c.TRUN_FLAGS_DATA_OFFSET=1,c.TRUN_FLAGS_FIRST_FLAG=4,c.TRUN_FLAGS_DURATION=256,c.TRUN_FLAGS_SIZE=512,c.TRUN_FLAGS_FLAGS=1024,c.TRUN_FLAGS_CTS_OFFSET=2048,c.Box.prototype.add=function(e){return this.addBox(new c[e+"Box"])},c.Box.prototype.addBox=function(e){return this.boxes.push(e),this[e.type+"s"]?this[e.type+"s"].push(e):this[e.type]=e,e},c.Box.prototype.set=function(e,t){return this[e]=t,this},c.Box.prototype.addEntry=function(e,t){var i=t||"entries";return this[i]||(this[i]=[]),this[i].push(e),this},t.BoxParser=c,c.parseUUID=function(e){return c.parseHex16(e)},c.parseHex16=function(e){for(var t="",i=0;i<16;i++){var r=e.readUint8().toString(16);t+=1===r.length?"0"+r:r}return t},c.parseOneBox=function(e,t,i){var r,s,n,o=e.getPosition(),l=0;if(e.getEndPosition()-o<8)return a.debug("BoxParser","Not enough data in stream to parse the type and size of the box"),{code:c.ERR_NOT_ENOUGH_DATA};if(i&&i<8)return a.debug("BoxParser","Not enough bytes left in the parent box to parse a new box"),{code:c.ERR_NOT_ENOUGH_DATA};var d=e.readUint32(),h=e.readString(4),u=h;if(a.debug("BoxParser","Found box of type '"+h+"' and size "+d+" at position "+o),l=8,"uuid"==h){if(e.getEndPosition()-e.getPosition()<16||i-l<16)return e.seek(o),a.debug("BoxParser","Not enough bytes left in the parent box to parse a UUID box"),{code:c.ERR_NOT_ENOUGH_DATA};l+=16,u=n=c.parseUUID(e)}if(1==d){if(e.getEndPosition()-e.getPosition()<8||i&&i-l<8)return e.seek(o),a.warn("BoxParser",'Not enough data in stream to parse the extended size of the "'+h+'" box'),{code:c.ERR_NOT_ENOUGH_DATA};d=e.readUint64(),l+=8}else if(0===d)if(i)d=i;else if("mdat"!==h)return a.error("BoxParser","Unlimited box size not supported for type: '"+h+"'"),r=new c.Box(h,d),{code:c.OK,box:r,size:r.size};return 0!==d&&d<l?(a.error("BoxParser","Box of type "+h+" has an invalid size "+d+" (too small to be a box)"),{code:c.ERR_NOT_ENOUGH_DATA,type:h,size:d,hdr_size:l,start:o}):0!==d&&i&&d>i?(a.error("BoxParser","Box of type '"+h+"' has a size "+d+" greater than its container size "+i),{code:c.ERR_NOT_ENOUGH_DATA,type:h,size:d,hdr_size:l,start:o}):0!==d&&o+d>e.getEndPosition()?(e.seek(o),a.info("BoxParser","Not enough data in stream to parse the entire '"+h+"' box"),{code:c.ERR_NOT_ENOUGH_DATA,type:h,size:d,hdr_size:l,start:o}):t?{code:c.OK,type:h,size:d,hdr_size:l,start:o}:(c[h+"Box"]?r=new c[h+"Box"](d):"uuid"!==h?(a.warn("BoxParser","Unknown box type: '"+h+"'"),(r=new c.Box(h,d)).has_unparsed_data=!0):c.UUIDBoxes[n]?r=new c.UUIDBoxes[n](d):(a.warn("BoxParser","Unknown uuid type: '"+n+"'"),(r=new c.Box(h,d)).uuid=n,r.has_unparsed_data=!0),r.hdr_size=l,r.start=o,r.write===c.Box.prototype.write&&"mdat"!==r.type&&(a.info("BoxParser","'"+u+"' box writing not yet implemented, keeping unparsed data in memory for later write"),r.parseDataAndRewind(e)),r.parse(e),(s=e.getPosition()-(r.start+r.size))<0?(a.warn("BoxParser","Parsing of box '"+u+"' did not read the entire indicated box data size (missing "+-s+" bytes), seeking forward"),e.seek(r.start+r.size)):s>0&&(a.error("BoxParser","Parsing of box '"+u+"' read "+s+" more bytes than the indicated box data size, seeking backwards"),0!==r.size&&e.seek(r.start+r.size)),{code:c.OK,box:r,size:r.size})},c.Box.prototype.parse=function(e){"mdat"!=this.type?this.data=e.readUint8Array(this.size-this.hdr_size):0===this.size?e.seek(e.getEndPosition()):e.seek(this.start+this.size)},c.Box.prototype.parseDataAndRewind=function(e){this.data=e.readUint8Array(this.size-this.hdr_size),e.position-=this.size-this.hdr_size},c.FullBox.prototype.parseDataAndRewind=function(e){this.parseFullHeader(e),this.data=e.readUint8Array(this.size-this.hdr_size),this.hdr_size-=4,e.position-=this.size-this.hdr_size},c.FullBox.prototype.parseFullHeader=function(e){this.version=e.readUint8(),this.flags=e.readUint24(),this.hdr_size+=4},c.FullBox.prototype.parse=function(e){this.parseFullHeader(e),this.data=e.readUint8Array(this.size-this.hdr_size)},c.ContainerBox.prototype.parse=function(e){for(var t,i;e.getPosition()<this.start+this.size;){if((t=c.parseOneBox(e,!1,this.size-(e.getPosition()-this.start))).code!==c.OK)return;if(i=t.box,this.boxes.push(i),this.subBoxNames&&-1!=this.subBoxNames.indexOf(i.type))this[this.subBoxNames[this.subBoxNames.indexOf(i.type)]+"s"].push(i);else{var r="uuid"!==i.type?i.type:i.uuid;this[r]?a.warn("Box of type "+r+" already stored in field of this type"):this[r]=i}}},c.Box.prototype.parseLanguage=function(e){this.language=e.readUint16();var t=[];t[0]=this.language>>10&31,t[1]=this.language>>5&31,t[2]=31&this.language,this.languageString=String.fromCharCode(t[0]+96,t[1]+96,t[2]+96)},c.SAMPLE_ENTRY_TYPE_VISUAL="Visual",c.SAMPLE_ENTRY_TYPE_AUDIO="Audio",c.SAMPLE_ENTRY_TYPE_HINT="Hint",c.SAMPLE_ENTRY_TYPE_METADATA="Metadata",c.SAMPLE_ENTRY_TYPE_SUBTITLE="Subtitle",c.SAMPLE_ENTRY_TYPE_SYSTEM="System",c.SAMPLE_ENTRY_TYPE_TEXT="Text",c.SampleEntry.prototype.parseHeader=function(e){e.readUint8Array(6),this.data_reference_index=e.readUint16(),this.hdr_size+=8},c.SampleEntry.prototype.parse=function(e){this.parseHeader(e),this.data=e.readUint8Array(this.size-this.hdr_size)},c.SampleEntry.prototype.parseDataAndRewind=function(e){this.parseHeader(e),this.data=e.readUint8Array(this.size-this.hdr_size),this.hdr_size-=8,e.position-=this.size-this.hdr_size},c.SampleEntry.prototype.parseFooter=function(e){c.ContainerBox.prototype.parse.call(this,e)},c.createMediaSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_HINT),c.createMediaSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_METADATA),c.createMediaSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_SUBTITLE),c.createMediaSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_SYSTEM),c.createMediaSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_TEXT),c.createMediaSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,(function(e){var t;this.parseHeader(e),e.readUint16(),e.readUint16(),e.readUint32Array(3),this.width=e.readUint16(),this.height=e.readUint16(),this.horizresolution=e.readUint32(),this.vertresolution=e.readUint32(),e.readUint32(),this.frame_count=e.readUint16(),t=Math.min(31,e.readUint8()),this.compressorname=e.readString(t),t<31&&e.readString(31-t),this.depth=e.readUint16(),e.readUint16(),this.parseFooter(e)})),c.createMediaSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO,(function(e){this.parseHeader(e),e.readUint32Array(2),this.channel_count=e.readUint16(),this.samplesize=e.readUint16(),e.readUint16(),e.readUint16(),this.samplerate=e.readUint32()/65536,this.parseFooter(e)})),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"avc1"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"avc2"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"avc3"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"avc4"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"av01"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"hvc1"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"hev1"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"vvc1"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"vvi1"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"vvs1"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"vvcN"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"vp08"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"vp09"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO,"mp4a"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO,"ac-3"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO,"ec-3"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO,"Opus"),c.createEncryptedSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"encv"),c.createEncryptedSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO,"enca"),c.createEncryptedSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_SUBTITLE,"encu"),c.createEncryptedSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_SYSTEM,"encs"),c.createEncryptedSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_TEXT,"enct"),c.createEncryptedSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_METADATA,"encm"),c.createBoxCtor("a1lx",(function(e){var t=16*(1+(1&(1&e.readUint8())));this.layer_size=[];for(var i=0;i<3;i++)this.layer_size[i]=16==t?e.readUint16():e.readUint32()})),c.createBoxCtor("a1op",(function(e){this.op_index=e.readUint8()})),c.createFullBoxCtor("auxC",(function(e){this.aux_type=e.readCString();var t=this.size-this.hdr_size-(this.aux_type.length+1);this.aux_subtype=e.readUint8Array(t)})),c.createBoxCtor("av1C",(function(e){var t=e.readUint8();if(t>>7&!1)a.error("av1C marker problem");else if(this.version=127&t,1===this.version)if(t=e.readUint8(),this.seq_profile=t>>5&7,this.seq_level_idx_0=31&t,t=e.readUint8(),this.seq_tier_0=t>>7&1,this.high_bitdepth=t>>6&1,this.twelve_bit=t>>5&1,this.monochrome=t>>4&1,this.chroma_subsampling_x=t>>3&1,this.chroma_subsampling_y=t>>2&1,this.chroma_sample_position=3&t,t=e.readUint8(),this.reserved_1=t>>5&7,0===this.reserved_1){if(this.initial_presentation_delay_present=t>>4&1,1===this.initial_presentation_delay_present)this.initial_presentation_delay_minus_one=15&t;else if(this.reserved_2=15&t,0!==this.reserved_2)return void a.error("av1C reserved_2 parsing problem");var i=this.size-this.hdr_size-4;this.configOBUs=e.readUint8Array(i)}else a.error("av1C reserved_1 parsing problem");else a.error("av1C version "+this.version+" not supported")})),c.createBoxCtor("avcC",(function(e){var t,i;for(this.configurationVersion=e.readUint8(),this.AVCProfileIndication=e.readUint8(),this.profile_compatibility=e.readUint8(),this.AVCLevelIndication=e.readUint8(),this.lengthSizeMinusOne=3&e.readUint8(),this.nb_SPS_nalus=31&e.readUint8(),i=this.size-this.hdr_size-6,this.SPS=[],t=0;t<this.nb_SPS_nalus;t++)this.SPS[t]={},this.SPS[t].length=e.readUint16(),this.SPS[t].nalu=e.readUint8Array(this.SPS[t].length),i-=2+this.SPS[t].length;for(this.nb_PPS_nalus=e.readUint8(),i--,this.PPS=[],t=0;t<this.nb_PPS_nalus;t++)this.PPS[t]={},this.PPS[t].length=e.readUint16(),this.PPS[t].nalu=e.readUint8Array(this.PPS[t].length),i-=2+this.PPS[t].length;i>0&&(this.ext=e.readUint8Array(i))})),c.createBoxCtor("btrt",(function(e){this.bufferSizeDB=e.readUint32(),this.maxBitrate=e.readUint32(),this.avgBitrate=e.readUint32()})),c.createBoxCtor("clap",(function(e){this.cleanApertureWidthN=e.readUint32(),this.cleanApertureWidthD=e.readUint32(),this.cleanApertureHeightN=e.readUint32(),this.cleanApertureHeightD=e.readUint32(),this.horizOffN=e.readUint32(),this.horizOffD=e.readUint32(),this.vertOffN=e.readUint32(),this.vertOffD=e.readUint32()})),c.createBoxCtor("clli",(function(e){this.max_content_light_level=e.readUint16(),this.max_pic_average_light_level=e.readUint16()})),c.createFullBoxCtor("co64",(function(e){var t,i;if(t=e.readUint32(),this.chunk_offsets=[],0===this.version)for(i=0;i<t;i++)this.chunk_offsets.push(e.readUint64())})),c.createFullBoxCtor("CoLL",(function(e){this.maxCLL=e.readUint16(),this.maxFALL=e.readUint16()})),c.createBoxCtor("colr",(function(e){if(this.colour_type=e.readString(4),"nclx"===this.colour_type){this.colour_primaries=e.readUint16(),this.transfer_characteristics=e.readUint16(),this.matrix_coefficients=e.readUint16();var t=e.readUint8();this.full_range_flag=t>>7}else("rICC"===this.colour_type||"prof"===this.colour_type)&&(this.ICC_profile=e.readUint8Array(this.size-4))})),c.createFullBoxCtor("cprt",(function(e){this.parseLanguage(e),this.notice=e.readCString()})),c.createFullBoxCtor("cslg",(function(e){0===this.version&&(this.compositionToDTSShift=e.readInt32(),this.leastDecodeToDisplayDelta=e.readInt32(),this.greatestDecodeToDisplayDelta=e.readInt32(),this.compositionStartTime=e.readInt32(),this.compositionEndTime=e.readInt32())})),c.createFullBoxCtor("ctts",(function(e){var t,i;if(t=e.readUint32(),this.sample_counts=[],this.sample_offsets=[],0===this.version)for(i=0;i<t;i++){this.sample_counts.push(e.readUint32());var r=e.readInt32();r<0&&a.warn("BoxParser","ctts box uses negative values without using version 1"),this.sample_offsets.push(r)}else if(1==this.version)for(i=0;i<t;i++)this.sample_counts.push(e.readUint32()),this.sample_offsets.push(e.readInt32())})),c.createBoxCtor("dac3",(function(e){var t=e.readUint8(),i=e.readUint8(),r=e.readUint8();this.fscod=t>>6,this.bsid=t>>1&31,this.bsmod=(1&t)<<2|i>>6&3,this.acmod=i>>3&7,this.lfeon=i>>2&1,this.bit_rate_code=3&i|r>>5&7})),c.createBoxCtor("dec3",(function(e){var t=e.readUint16();this.data_rate=t>>3,this.num_ind_sub=7&t,this.ind_subs=[];for(var i=0;i<this.num_ind_sub+1;i++){var r={};this.ind_subs.push(r);var s=e.readUint8(),a=e.readUint8(),n=e.readUint8();r.fscod=s>>6,r.bsid=s>>1&31,r.bsmod=(1&s)<<4|a>>4&15,r.acmod=a>>1&7,r.lfeon=1&a,r.num_dep_sub=n>>1&15,r.num_dep_sub>0&&(r.chan_loc=(1&n)<<8|e.readUint8())}})),c.createFullBoxCtor("dfLa",(function(e){var t=[],i=["STREAMINFO","PADDING","APPLICATION","SEEKTABLE","VORBIS_COMMENT","CUESHEET","PICTURE","RESERVED"];for(this.parseFullHeader(e);;){var r=e.readUint8(),s=Math.min(127&r,i.length-1);if(s?e.readUint8Array(e.readUint24()):(e.readUint8Array(13),this.samplerate=e.readUint32()>>12,e.readUint8Array(20)),t.push(i[s]),128&r)break}this.numMetadataBlocks=t.length+" ("+t.join(", ")+")"})),c.createBoxCtor("dimm",(function(e){this.bytessent=e.readUint64()})),c.createBoxCtor("dmax",(function(e){this.time=e.readUint32()})),c.createBoxCtor("dmed",(function(e){this.bytessent=e.readUint64()})),c.createBoxCtor("dOps",(function(e){if(this.Version=e.readUint8(),this.OutputChannelCount=e.readUint8(),this.PreSkip=e.readUint16(),this.InputSampleRate=e.readUint32(),this.OutputGain=e.readInt16(),this.ChannelMappingFamily=e.readUint8(),0!==this.ChannelMappingFamily){this.StreamCount=e.readUint8(),this.CoupledCount=e.readUint8(),this.ChannelMapping=[];for(var t=0;t<this.OutputChannelCount;t++)this.ChannelMapping[t]=e.readUint8()}})),c.createFullBoxCtor("dref",(function(e){var t,i;this.entries=[];for(var r=e.readUint32(),s=0;s<r;s++){if((t=c.parseOneBox(e,!1,this.size-(e.getPosition()-this.start))).code!==c.OK)return;i=t.box,this.entries.push(i)}})),c.createBoxCtor("drep",(function(e){this.bytessent=e.readUint64()})),c.createFullBoxCtor("elng",(function(e){this.extended_language=e.readString(this.size-this.hdr_size)})),c.createFullBoxCtor("elst",(function(e){this.entries=[];for(var t=e.readUint32(),i=0;i<t;i++){var r={};this.entries.push(r),1===this.version?(r.segment_duration=e.readUint64(),r.media_time=e.readInt64()):(r.segment_duration=e.readUint32(),r.media_time=e.readInt32()),r.media_rate_integer=e.readInt16(),r.media_rate_fraction=e.readInt16()}})),c.createFullBoxCtor("emsg",(function(e){1==this.version?(this.timescale=e.readUint32(),this.presentation_time=e.readUint64(),this.event_duration=e.readUint32(),this.id=e.readUint32(),this.scheme_id_uri=e.readCString(),this.value=e.readCString()):(this.scheme_id_uri=e.readCString(),this.value=e.readCString(),this.timescale=e.readUint32(),this.presentation_time_delta=e.readUint32(),this.event_duration=e.readUint32(),this.id=e.readUint32());var t=this.size-this.hdr_size-(16+(this.scheme_id_uri.length+1)+(this.value.length+1));1==this.version&&(t-=4),this.message_data=e.readUint8Array(t)})),c.createFullBoxCtor("esds",(function(e){var t=e.readUint8Array(this.size-this.hdr_size);if(void 0!==h){var i=new h;this.esd=i.parseOneDescriptor(new o(t.buffer,0,o.BIG_ENDIAN))}})),c.createBoxCtor("fiel",(function(e){this.fieldCount=e.readUint8(),this.fieldOrdering=e.readUint8()})),c.createBoxCtor("frma",(function(e){this.data_format=e.readString(4)})),c.createBoxCtor("ftyp",(function(e){var t=this.size-this.hdr_size;this.major_brand=e.readString(4),this.minor_version=e.readUint32(),t-=8,this.compatible_brands=[];for(var i=0;t>=4;)this.compatible_brands[i]=e.readString(4),t-=4,i++})),c.createFullBoxCtor("hdlr",(function(e){0===this.version&&(e.readUint32(),this.handler=e.readString(4),e.readUint32Array(3),this.name=e.readString(this.size-this.hdr_size-20),"\0"===this.name[this.name.length-1]&&(this.name=this.name.slice(0,-1)))})),c.createBoxCtor("hvcC",(function(e){var t,i,r,s;this.configurationVersion=e.readUint8(),s=e.readUint8(),this.general_profile_space=s>>6,this.general_tier_flag=(32&s)>>5,this.general_profile_idc=31&s,this.general_profile_compatibility=e.readUint32(),this.general_constraint_indicator=e.readUint8Array(6),this.general_level_idc=e.readUint8(),this.min_spatial_segmentation_idc=4095&e.readUint16(),this.parallelismType=3&e.readUint8(),this.chroma_format_idc=3&e.readUint8(),this.bit_depth_luma_minus8=7&e.readUint8(),this.bit_depth_chroma_minus8=7&e.readUint8(),this.avgFrameRate=e.readUint16(),s=e.readUint8(),this.constantFrameRate=s>>6,this.numTemporalLayers=(13&s)>>3,this.temporalIdNested=(4&s)>>2,this.lengthSizeMinusOne=3&s,this.nalu_arrays=[];var a=e.readUint8();for(t=0;t<a;t++){var n=[];this.nalu_arrays.push(n),s=e.readUint8(),n.completeness=(128&s)>>7,n.nalu_type=63&s;var o=e.readUint16();for(i=0;i<o;i++){var l={};n.push(l),r=e.readUint16(),l.data=e.readUint8Array(r)}}})),c.createFullBoxCtor("iinf",(function(e){var t;0===this.version?this.entry_count=e.readUint16():this.entry_count=e.readUint32(),this.item_infos=[];for(var i=0;i<this.entry_count;i++){if((t=c.parseOneBox(e,!1,this.size-(e.getPosition()-this.start))).code!==c.OK)return;"infe"!==t.box.type&&a.error("BoxParser","Expected 'infe' box, got "+t.box.type),this.item_infos[i]=t.box}})),c.createFullBoxCtor("iloc",(function(e){var t;t=e.readUint8(),this.offset_size=t>>4&15,this.length_size=15&t,t=e.readUint8(),this.base_offset_size=t>>4&15,1===this.version||2===this.version?this.index_size=15&t:this.index_size=0,this.items=[];var i=0;if(this.version<2)i=e.readUint16();else{if(2!==this.version)throw"version of iloc box not supported";i=e.readUint32()}for(var r=0;r<i;r++){var s={};if(this.items.push(s),this.version<2)s.item_ID=e.readUint16();else{if(2!==this.version)throw"version of iloc box not supported";s.item_ID=e.readUint16()}switch(1===this.version||2===this.version?s.construction_method=15&e.readUint16():s.construction_method=0,s.data_reference_index=e.readUint16(),this.base_offset_size){case 0:s.base_offset=0;break;case 4:s.base_offset=e.readUint32();break;case 8:s.base_offset=e.readUint64();break;default:throw"Error reading base offset size"}var a=e.readUint16();s.extents=[];for(var n=0;n<a;n++){var o={};if(s.extents.push(o),1===this.version||2===this.version)switch(this.index_size){case 0:o.extent_index=0;break;case 4:o.extent_index=e.readUint32();break;case 8:o.extent_index=e.readUint64();break;default:throw"Error reading extent index"}switch(this.offset_size){case 0:o.extent_offset=0;break;case 4:o.extent_offset=e.readUint32();break;case 8:o.extent_offset=e.readUint64();break;default:throw"Error reading extent index"}switch(this.length_size){case 0:o.extent_length=0;break;case 4:o.extent_length=e.readUint32();break;case 8:o.extent_length=e.readUint64();break;default:throw"Error reading extent index"}}}})),c.createBoxCtor("imir",(function(e){var t=e.readUint8();this.reserved=t>>7,this.axis=1&t})),c.createFullBoxCtor("infe",(function(e){if(0!==this.version&&1!==this.version||(this.item_ID=e.readUint16(),this.item_protection_index=e.readUint16(),this.item_name=e.readCString(),this.content_type=e.readCString(),this.content_encoding=e.readCString()),1===this.version)return this.extension_type=e.readString(4),a.warn("BoxParser","Cannot parse extension type"),void e.seek(this.start+this.size);this.version>=2&&(2===this.version?this.item_ID=e.readUint16():3===this.version&&(this.item_ID=e.readUint32()),this.item_protection_index=e.readUint16(),this.item_type=e.readString(4),this.item_name=e.readCString(),"mime"===this.item_type?(this.content_type=e.readCString(),this.content_encoding=e.readCString()):"uri "===this.item_type&&(this.item_uri_type=e.readCString()))})),c.createFullBoxCtor("ipma",(function(e){var t,i;for(entry_count=e.readUint32(),this.associations=[],t=0;t<entry_count;t++){var r={};this.associations.push(r),this.version<1?r.id=e.readUint16():r.id=e.readUint32();var s=e.readUint8();for(r.props=[],i=0;i<s;i++){var a=e.readUint8(),n={};r.props.push(n),n.essential=(128&a)>>7==1,1&this.flags?n.property_index=(127&a)<<8|e.readUint8():n.property_index=127&a}}})),c.createFullBoxCtor("iref",(function(e){var t,i;for(this.references=[];e.getPosition()<this.start+this.size;){if((t=c.parseOneBox(e,!0,this.size-(e.getPosition()-this.start))).code!==c.OK)return;(i=0===this.version?new c.SingleItemTypeReferenceBox(t.type,t.size,t.hdr_size,t.start):new c.SingleItemTypeReferenceBoxLarge(t.type,t.size,t.hdr_size,t.start)).write===c.Box.prototype.write&&"mdat"!==i.type&&(a.warn("BoxParser",i.type+" box writing not yet implemented, keeping unparsed data in memory for later write"),i.parseDataAndRewind(e)),i.parse(e),this.references.push(i)}})),c.createBoxCtor("irot",(function(e){this.angle=3&e.readUint8()})),c.createFullBoxCtor("ispe",(function(e){this.image_width=e.readUint32(),this.image_height=e.readUint32()})),c.createFullBoxCtor("kind",(function(e){this.schemeURI=e.readCString(),this.value=e.readCString()})),c.createFullBoxCtor("leva",(function(e){var t=e.readUint8();this.levels=[];for(var i=0;i<t;i++){var r={};this.levels[i]=r,r.track_ID=e.readUint32();var s=e.readUint8();switch(r.padding_flag=s>>7,r.assignment_type=127&s,r.assignment_type){case 0:r.grouping_type=e.readString(4);break;case 1:r.grouping_type=e.readString(4),r.grouping_type_parameter=e.readUint32();break;case 2:case 3:break;case 4:r.sub_track_id=e.readUint32();break;default:a.warn("BoxParser","Unknown leva assignement type")}}})),c.createBoxCtor("lsel",(function(e){this.layer_id=e.readUint16()})),c.createBoxCtor("maxr",(function(e){this.period=e.readUint32(),this.bytes=e.readUint32()})),c.createBoxCtor("mdcv",(function(e){this.display_primaries=[],this.display_primaries[0]={},this.display_primaries[0].x=e.readUint16(),this.display_primaries[0].y=e.readUint16(),this.display_primaries[1]={},this.display_primaries[1].x=e.readUint16(),this.display_primaries[1].y=e.readUint16(),this.display_primaries[2]={},this.display_primaries[2].x=e.readUint16(),this.display_primaries[2].y=e.readUint16(),this.white_point={},this.white_point.x=e.readUint16(),this.white_point.y=e.readUint16(),this.max_display_mastering_luminance=e.readUint32(),this.min_display_mastering_luminance=e.readUint32()})),c.createFullBoxCtor("mdhd",(function(e){1==this.version?(this.creation_time=e.readUint64(),this.modification_time=e.readUint64(),this.timescale=e.readUint32(),this.duration=e.readUint64()):(this.creation_time=e.readUint32(),this.modification_time=e.readUint32(),this.timescale=e.readUint32(),this.duration=e.readUint32()),this.parseLanguage(e),e.readUint16()})),c.createFullBoxCtor("mehd",(function(e){1&this.flags&&(a.warn("BoxParser","mehd box incorrectly uses flags set to 1, converting version to 1"),this.version=1),1==this.version?this.fragment_duration=e.readUint64():this.fragment_duration=e.readUint32()})),c.createFullBoxCtor("meta",(function(e){this.boxes=[],c.ContainerBox.prototype.parse.call(this,e)})),c.createFullBoxCtor("mfhd",(function(e){this.sequence_number=e.readUint32()})),c.createFullBoxCtor("mfro",(function(e){this._size=e.readUint32()})),c.createFullBoxCtor("mvhd",(function(e){1==this.version?(this.creation_time=e.readUint64(),this.modification_time=e.readUint64(),this.timescale=e.readUint32(),this.duration=e.readUint64()):(this.creation_time=e.readUint32(),this.modification_time=e.readUint32(),this.timescale=e.readUint32(),this.duration=e.readUint32()),this.rate=e.readUint32(),this.volume=e.readUint16()>>8,e.readUint16(),e.readUint32Array(2),this.matrix=e.readUint32Array(9),e.readUint32Array(6),this.next_track_id=e.readUint32()})),c.createBoxCtor("npck",(function(e){this.packetssent=e.readUint32()})),c.createBoxCtor("nump",(function(e){this.packetssent=e.readUint64()})),c.createFullBoxCtor("padb",(function(e){var t=e.readUint32();this.padbits=[];for(var i=0;i<Math.floor((t+1)/2);i++)this.padbits=e.readUint8()})),c.createBoxCtor("pasp",(function(e){this.hSpacing=e.readUint32(),this.vSpacing=e.readUint32()})),c.createBoxCtor("payl",(function(e){this.text=e.readString(this.size-this.hdr_size)})),c.createBoxCtor("payt",(function(e){this.payloadID=e.readUint32();var t=e.readUint8();this.rtpmap_string=e.readString(t)})),c.createFullBoxCtor("pdin",(function(e){var t=(this.size-this.hdr_size)/8;this.rate=[],this.initial_delay=[];for(var i=0;i<t;i++)this.rate[i]=e.readUint32(),this.initial_delay[i]=e.readUint32()})),c.createFullBoxCtor("pitm",(function(e){0===this.version?this.item_id=e.readUint16():this.item_id=e.readUint32()})),c.createFullBoxCtor("pixi",(function(e){var t;for(this.num_channels=e.readUint8(),this.bits_per_channels=[],t=0;t<this.num_channels;t++)this.bits_per_channels[t]=e.readUint8()})),c.createBoxCtor("pmax",(function(e){this.bytes=e.readUint32()})),c.createFullBoxCtor("prft",(function(e){this.ref_track_id=e.readUint32(),this.ntp_timestamp=e.readUint64(),0===this.version?this.media_time=e.readUint32():this.media_time=e.readUint64()})),c.createFullBoxCtor("pssh",(function(e){if(this.system_id=c.parseHex16(e),this.version>0){var t=e.readUint32();this.kid=[];for(var i=0;i<t;i++)this.kid[i]=c.parseHex16(e)}var r=e.readUint32();r>0&&(this.data=e.readUint8Array(r))})),c.createFullBoxCtor("clef",(function(e){this.width=e.readUint32(),this.height=e.readUint32()})),c.createFullBoxCtor("enof",(function(e){this.width=e.readUint32(),this.height=e.readUint32()})),c.createFullBoxCtor("prof",(function(e){this.width=e.readUint32(),this.height=e.readUint32()})),c.createContainerBoxCtor("tapt",null,["clef","prof","enof"]),c.createBoxCtor("rtp ",(function(e){this.descriptionformat=e.readString(4),this.sdptext=e.readString(this.size-this.hdr_size-4)})),c.createFullBoxCtor("saio",(function(e){1&this.flags&&(this.aux_info_type=e.readUint32(),this.aux_info_type_parameter=e.readUint32());var t=e.readUint32();this.offset=[];for(var i=0;i<t;i++)0===this.version?this.offset[i]=e.readUint32():this.offset[i]=e.readUint64()})),c.createFullBoxCtor("saiz",(function(e){1&this.flags&&(this.aux_info_type=e.readUint32(),this.aux_info_type_parameter=e.readUint32()),this.default_sample_info_size=e.readUint8();var t=e.readUint32();if(this.sample_info_size=[],0===this.default_sample_info_size)for(var i=0;i<t;i++)this.sample_info_size[i]=e.readUint8()})),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_METADATA,"mett",(function(e){this.parseHeader(e),this.content_encoding=e.readCString(),this.mime_format=e.readCString(),this.parseFooter(e)})),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_METADATA,"metx",(function(e){this.parseHeader(e),this.content_encoding=e.readCString(),this.namespace=e.readCString(),this.schema_location=e.readCString(),this.parseFooter(e)})),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_SUBTITLE,"sbtt",(function(e){this.parseHeader(e),this.content_encoding=e.readCString(),this.mime_format=e.readCString(),this.parseFooter(e)})),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_SUBTITLE,"stpp",(function(e){this.parseHeader(e),this.namespace=e.readCString(),this.schema_location=e.readCString(),this.auxiliary_mime_types=e.readCString(),this.parseFooter(e)})),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_SUBTITLE,"stxt",(function(e){this.parseHeader(e),this.content_encoding=e.readCString(),this.mime_format=e.readCString(),this.parseFooter(e)})),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_SUBTITLE,"tx3g",(function(e){this.parseHeader(e),this.displayFlags=e.readUint32(),this.horizontal_justification=e.readInt8(),this.vertical_justification=e.readInt8(),this.bg_color_rgba=e.readUint8Array(4),this.box_record=e.readInt16Array(4),this.style_record=e.readUint8Array(12),this.parseFooter(e)})),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_METADATA,"wvtt",(function(e){this.parseHeader(e),this.parseFooter(e)})),c.createSampleGroupCtor("alst",(function(e){var t,i=e.readUint16();for(this.first_output_sample=e.readUint16(),this.sample_offset=[],t=0;t<i;t++)this.sample_offset[t]=e.readUint32();var r=this.description_length-4-4*i;for(this.num_output_samples=[],this.num_total_samples=[],t=0;t<r/4;t++)this.num_output_samples[t]=e.readUint16(),this.num_total_samples[t]=e.readUint16()})),c.createSampleGroupCtor("avll",(function(e){this.layerNumber=e.readUint8(),this.accurateStatisticsFlag=e.readUint8(),this.avgBitRate=e.readUint16(),this.avgFrameRate=e.readUint16()})),c.createSampleGroupCtor("avss",(function(e){this.subSequenceIdentifier=e.readUint16(),this.layerNumber=e.readUint8();var t=e.readUint8();this.durationFlag=t>>7,this.avgRateFlag=t>>6&1,this.durationFlag&&(this.duration=e.readUint32()),this.avgRateFlag&&(this.accurateStatisticsFlag=e.readUint8(),this.avgBitRate=e.readUint16(),this.avgFrameRate=e.readUint16()),this.dependency=[];for(var i=e.readUint8(),r=0;r<i;r++){var s={};this.dependency.push(s),s.subSeqDirectionFlag=e.readUint8(),s.layerNumber=e.readUint8(),s.subSequenceIdentifier=e.readUint16()}})),c.createSampleGroupCtor("dtrt",(function(e){a.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),c.createSampleGroupCtor("mvif",(function(e){a.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),c.createSampleGroupCtor("prol",(function(e){this.roll_distance=e.readInt16()})),c.createSampleGroupCtor("rap ",(function(e){var t=e.readUint8();this.num_leading_samples_known=t>>7,this.num_leading_samples=127&t})),c.createSampleGroupCtor("rash",(function(e){if(this.operation_point_count=e.readUint16(),this.description_length!==2+(1===this.operation_point_count?2:6*this.operation_point_count)+9)a.warn("BoxParser","Mismatch in "+this.grouping_type+" sample group length"),this.data=e.readUint8Array(this.description_length-2);else{if(1===this.operation_point_count)this.target_rate_share=e.readUint16();else{this.target_rate_share=[],this.available_bitrate=[];for(var t=0;t<this.operation_point_count;t++)this.available_bitrate[t]=e.readUint32(),this.target_rate_share[t]=e.readUint16()}this.maximum_bitrate=e.readUint32(),this.minimum_bitrate=e.readUint32(),this.discard_priority=e.readUint8()}})),c.createSampleGroupCtor("roll",(function(e){this.roll_distance=e.readInt16()})),c.SampleGroupEntry.prototype.parse=function(e){a.warn("BoxParser","Unknown Sample Group type: "+this.grouping_type),this.data=e.readUint8Array(this.description_length)},c.createSampleGroupCtor("scif",(function(e){a.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),c.createSampleGroupCtor("scnm",(function(e){a.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),c.createSampleGroupCtor("seig",(function(e){this.reserved=e.readUint8();var t=e.readUint8();this.crypt_byte_block=t>>4,this.skip_byte_block=15&t,this.isProtected=e.readUint8(),this.Per_Sample_IV_Size=e.readUint8(),this.KID=c.parseHex16(e),this.constant_IV_size=0,this.constant_IV=0,1===this.isProtected&&0===this.Per_Sample_IV_Size&&(this.constant_IV_size=e.readUint8(),this.constant_IV=e.readUint8Array(this.constant_IV_size))})),c.createSampleGroupCtor("stsa",(function(e){a.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),c.createSampleGroupCtor("sync",(function(e){var t=e.readUint8();this.NAL_unit_type=63&t})),c.createSampleGroupCtor("tele",(function(e){var t=e.readUint8();this.level_independently_decodable=t>>7})),c.createSampleGroupCtor("tsas",(function(e){a.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),c.createSampleGroupCtor("tscl",(function(e){a.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),c.createSampleGroupCtor("vipr",(function(e){a.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),c.createFullBoxCtor("sbgp",(function(e){this.grouping_type=e.readString(4),1===this.version?this.grouping_type_parameter=e.readUint32():this.grouping_type_parameter=0,this.entries=[];for(var t=e.readUint32(),i=0;i<t;i++){var r={};this.entries.push(r),r.sample_count=e.readInt32(),r.group_description_index=e.readInt32()}})),c.createFullBoxCtor("schm",(function(e){this.scheme_type=e.readString(4),this.scheme_version=e.readUint32(),1&this.flags&&(this.scheme_uri=e.readString(this.size-this.hdr_size-8))})),c.createBoxCtor("sdp ",(function(e){this.sdptext=e.readString(this.size-this.hdr_size)})),c.createFullBoxCtor("sdtp",(function(e){var t,i=this.size-this.hdr_size;this.is_leading=[],this.sample_depends_on=[],this.sample_is_depended_on=[],this.sample_has_redundancy=[];for(var r=0;r<i;r++)t=e.readUint8(),this.is_leading[r]=t>>6,this.sample_depends_on[r]=t>>4&3,this.sample_is_depended_on[r]=t>>2&3,this.sample_has_redundancy[r]=3&t})),c.createFullBoxCtor("senc"),c.createFullBoxCtor("sgpd",(function(e){this.grouping_type=e.readString(4),a.debug("BoxParser","Found Sample Groups of type "+this.grouping_type),1===this.version?this.default_length=e.readUint32():this.default_length=0,this.version>=2&&(this.default_group_description_index=e.readUint32()),this.entries=[];for(var t=e.readUint32(),i=0;i<t;i++){var r;r=c[this.grouping_type+"SampleGroupEntry"]?new c[this.grouping_type+"SampleGroupEntry"](this.grouping_type):new c.SampleGroupEntry(this.grouping_type),this.entries.push(r),1===this.version&&0===this.default_length?r.description_length=e.readUint32():r.description_length=this.default_length,r.write===c.SampleGroupEntry.prototype.write&&(a.info("BoxParser","SampleGroup for type "+this.grouping_type+" writing not yet implemented, keeping unparsed data in memory for later write"),r.data=e.readUint8Array(r.description_length),e.position-=r.description_length),r.parse(e)}})),c.createFullBoxCtor("sidx",(function(e){this.reference_ID=e.readUint32(),this.timescale=e.readUint32(),0===this.version?(this.earliest_presentation_time=e.readUint32(),this.first_offset=e.readUint32()):(this.earliest_presentation_time=e.readUint64(),this.first_offset=e.readUint64()),e.readUint16(),this.references=[];for(var t=e.readUint16(),i=0;i<t;i++){var r={};this.references.push(r);var s=e.readUint32();r.reference_type=s>>31&1,r.referenced_size=2147483647&s,r.subsegment_duration=e.readUint32(),s=e.readUint32(),r.starts_with_SAP=s>>31&1,r.SAP_type=s>>28&7,r.SAP_delta_time=268435455&s}})),c.SingleItemTypeReferenceBox=function(e,t,i,r){c.Box.call(this,e,t),this.hdr_size=i,this.start=r},c.SingleItemTypeReferenceBox.prototype=new c.Box,c.SingleItemTypeReferenceBox.prototype.parse=function(e){this.from_item_ID=e.readUint16();var t=e.readUint16();this.references=[];for(var i=0;i<t;i++)this.references[i]=e.readUint16()},c.SingleItemTypeReferenceBoxLarge=function(e,t,i,r){c.Box.call(this,e,t),this.hdr_size=i,this.start=r},c.SingleItemTypeReferenceBoxLarge.prototype=new c.Box,c.SingleItemTypeReferenceBoxLarge.prototype.parse=function(e){this.from_item_ID=e.readUint32();var t=e.readUint16();this.references=[];for(var i=0;i<t;i++)this.references[i]=e.readUint32()},c.createFullBoxCtor("SmDm",(function(e){this.primaryRChromaticity_x=e.readUint16(),this.primaryRChromaticity_y=e.readUint16(),this.primaryGChromaticity_x=e.readUint16(),this.primaryGChromaticity_y=e.readUint16(),this.primaryBChromaticity_x=e.readUint16(),this.primaryBChromaticity_y=e.readUint16(),this.whitePointChromaticity_x=e.readUint16(),this.whitePointChromaticity_y=e.readUint16(),this.luminanceMax=e.readUint32(),this.luminanceMin=e.readUint32()})),c.createFullBoxCtor("smhd",(function(e){this.balance=e.readUint16(),e.readUint16()})),c.createFullBoxCtor("ssix",(function(e){this.subsegments=[];for(var t=e.readUint32(),i=0;i<t;i++){var r={};this.subsegments.push(r),r.ranges=[];for(var s=e.readUint32(),a=0;a<s;a++){var n={};r.ranges.push(n),n.level=e.readUint8(),n.range_size=e.readUint24()}}})),c.createFullBoxCtor("stco",(function(e){var t;if(t=e.readUint32(),this.chunk_offsets=[],0===this.version)for(var i=0;i<t;i++)this.chunk_offsets.push(e.readUint32())})),c.createFullBoxCtor("stdp",(function(e){var t=(this.size-this.hdr_size)/2;this.priority=[];for(var i=0;i<t;i++)this.priority[i]=e.readUint16()})),c.createFullBoxCtor("sthd"),c.createFullBoxCtor("stri",(function(e){this.switch_group=e.readUint16(),this.alternate_group=e.readUint16(),this.sub_track_id=e.readUint32();var t=(this.size-this.hdr_size-8)/4;this.attribute_list=[];for(var i=0;i<t;i++)this.attribute_list[i]=e.readUint32()})),c.createFullBoxCtor("stsc",(function(e){var t,i;if(t=e.readUint32(),this.first_chunk=[],this.samples_per_chunk=[],this.sample_description_index=[],0===this.version)for(i=0;i<t;i++)this.first_chunk.push(e.readUint32()),this.samples_per_chunk.push(e.readUint32()),this.sample_description_index.push(e.readUint32())})),c.createFullBoxCtor("stsd",(function(e){var t,i,r,s;for(this.entries=[],r=e.readUint32(),t=1;t<=r;t++){if((i=c.parseOneBox(e,!0,this.size-(e.getPosition()-this.start))).code!==c.OK)return;c[i.type+"SampleEntry"]?((s=new c[i.type+"SampleEntry"](i.size)).hdr_size=i.hdr_size,s.start=i.start):(a.warn("BoxParser","Unknown sample entry type: "+i.type),s=new c.SampleEntry(i.type,i.size,i.hdr_size,i.start)),s.write===c.SampleEntry.prototype.write&&(a.info("BoxParser","SampleEntry "+s.type+" box writing not yet implemented, keeping unparsed data in memory for later write"),s.parseDataAndRewind(e)),s.parse(e),this.entries.push(s)}})),c.createFullBoxCtor("stsg",(function(e){this.grouping_type=e.readUint32();var t=e.readUint16();this.group_description_index=[];for(var i=0;i<t;i++)this.group_description_index[i]=e.readUint32()})),c.createFullBoxCtor("stsh",(function(e){var t,i;if(t=e.readUint32(),this.shadowed_sample_numbers=[],this.sync_sample_numbers=[],0===this.version)for(i=0;i<t;i++)this.shadowed_sample_numbers.push(e.readUint32()),this.sync_sample_numbers.push(e.readUint32())})),c.createFullBoxCtor("stss",(function(e){var t,i;if(i=e.readUint32(),0===this.version)for(this.sample_numbers=[],t=0;t<i;t++)this.sample_numbers.push(e.readUint32())})),c.createFullBoxCtor("stsz",(function(e){var t;if(this.sample_sizes=[],0===this.version)for(this.sample_size=e.readUint32(),this.sample_count=e.readUint32(),t=0;t<this.sample_count;t++)0===this.sample_size?this.sample_sizes.push(e.readUint32()):this.sample_sizes[t]=this.sample_size})),c.createFullBoxCtor("stts",(function(e){var t,i,r;if(t=e.readUint32(),this.sample_counts=[],this.sample_deltas=[],0===this.version)for(i=0;i<t;i++)this.sample_counts.push(e.readUint32()),(r=e.readInt32())<0&&(a.warn("BoxParser","File uses negative stts sample delta, using value 1 instead, sync may be lost!"),r=1),this.sample_deltas.push(r)})),c.createFullBoxCtor("stvi",(function(e){var t=e.readUint32();this.single_view_allowed=3&t,this.stereo_scheme=e.readUint32();var i,r,s=e.readUint32();for(this.stereo_indication_type=e.readString(s),this.boxes=[];e.getPosition()<this.start+this.size;){if((i=c.parseOneBox(e,!1,this.size-(e.getPosition()-this.start))).code!==c.OK)return;r=i.box,this.boxes.push(r),this[r.type]=r}})),c.createBoxCtor("styp",(function(e){c.ftypBox.prototype.parse.call(this,e)})),c.createFullBoxCtor("stz2",(function(e){var t,i;if(this.sample_sizes=[],0===this.version)if(this.reserved=e.readUint24(),this.field_size=e.readUint8(),i=e.readUint32(),4===this.field_size)for(t=0;t<i;t+=2){var r=e.readUint8();this.sample_sizes[t]=r>>4&15,this.sample_sizes[t+1]=15&r}else if(8===this.field_size)for(t=0;t<i;t++)this.sample_sizes[t]=e.readUint8();else if(16===this.field_size)for(t=0;t<i;t++)this.sample_sizes[t]=e.readUint16();else a.error("BoxParser","Error in length field in stz2 box")})),c.createFullBoxCtor("subs",(function(e){var t,i,r,s;for(r=e.readUint32(),this.entries=[],t=0;t<r;t++){var a={};if(this.entries[t]=a,a.sample_delta=e.readUint32(),a.subsamples=[],(s=e.readUint16())>0)for(i=0;i<s;i++){var n={};a.subsamples.push(n),1==this.version?n.size=e.readUint32():n.size=e.readUint16(),n.priority=e.readUint8(),n.discardable=e.readUint8(),n.codec_specific_parameters=e.readUint32()}}})),c.createFullBoxCtor("tenc",(function(e){if(e.readUint8(),0===this.version)e.readUint8();else{var t=e.readUint8();this.default_crypt_byte_block=t>>4&15,this.default_skip_byte_block=15&t}this.default_isProtected=e.readUint8(),this.default_Per_Sample_IV_Size=e.readUint8(),this.default_KID=c.parseHex16(e),1===this.default_isProtected&&0===this.default_Per_Sample_IV_Size&&(this.default_constant_IV_size=e.readUint8(),this.default_constant_IV=e.readUint8Array(this.default_constant_IV_size))})),c.createFullBoxCtor("tfdt",(function(e){1==this.version?this.baseMediaDecodeTime=e.readUint64():this.baseMediaDecodeTime=e.readUint32()})),c.createFullBoxCtor("tfhd",(function(e){var t=0;this.track_id=e.readUint32(),this.size-this.hdr_size>t&&this.flags&c.TFHD_FLAG_BASE_DATA_OFFSET?(this.base_data_offset=e.readUint64(),t+=8):this.base_data_offset=0,this.size-this.hdr_size>t&&this.flags&c.TFHD_FLAG_SAMPLE_DESC?(this.default_sample_description_index=e.readUint32(),t+=4):this.default_sample_description_index=0,this.size-this.hdr_size>t&&this.flags&c.TFHD_FLAG_SAMPLE_DUR?(this.default_sample_duration=e.readUint32(),t+=4):this.default_sample_duration=0,this.size-this.hdr_size>t&&this.flags&c.TFHD_FLAG_SAMPLE_SIZE?(this.default_sample_size=e.readUint32(),t+=4):this.default_sample_size=0,this.size-this.hdr_size>t&&this.flags&c.TFHD_FLAG_SAMPLE_FLAGS?(this.default_sample_flags=e.readUint32(),t+=4):this.default_sample_flags=0})),c.createFullBoxCtor("tfra",(function(e){this.track_ID=e.readUint32(),e.readUint24();var t=e.readUint8();this.length_size_of_traf_num=t>>4&3,this.length_size_of_trun_num=t>>2&3,this.length_size_of_sample_num=3&t,this.entries=[];for(var i=e.readUint32(),r=0;r<i;r++)1===this.version?(this.time=e.readUint64(),this.moof_offset=e.readUint64()):(this.time=e.readUint32(),this.moof_offset=e.readUint32()),this.traf_number=e["readUint"+8*(this.length_size_of_traf_num+1)](),this.trun_number=e["readUint"+8*(this.length_size_of_trun_num+1)](),this.sample_number=e["readUint"+8*(this.length_size_of_sample_num+1)]()})),c.createFullBoxCtor("tkhd",(function(e){1==this.version?(this.creation_time=e.readUint64(),this.modification_time=e.readUint64(),this.track_id=e.readUint32(),e.readUint32(),this.duration=e.readUint64()):(this.creation_time=e.readUint32(),this.modification_time=e.readUint32(),this.track_id=e.readUint32(),e.readUint32(),this.duration=e.readUint32()),e.readUint32Array(2),this.layer=e.readInt16(),this.alternate_group=e.readInt16(),this.volume=e.readInt16()>>8,e.readUint16(),this.matrix=e.readInt32Array(9),this.width=e.readUint32(),this.height=e.readUint32()})),c.createBoxCtor("tmax",(function(e){this.time=e.readUint32()})),c.createBoxCtor("tmin",(function(e){this.time=e.readUint32()})),c.createBoxCtor("totl",(function(e){this.bytessent=e.readUint32()})),c.createBoxCtor("tpay",(function(e){this.bytessent=e.readUint32()})),c.createBoxCtor("tpyl",(function(e){this.bytessent=e.readUint64()})),c.TrackGroupTypeBox.prototype.parse=function(e){this.parseFullHeader(e),this.track_group_id=e.readUint32()},c.createTrackGroupCtor("msrc"),c.TrackReferenceTypeBox=function(e,t,i,r){c.Box.call(this,e,t),this.hdr_size=i,this.start=r},c.TrackReferenceTypeBox.prototype=new c.Box,c.TrackReferenceTypeBox.prototype.parse=function(e){this.track_ids=e.readUint32Array((this.size-this.hdr_size)/4)},c.trefBox.prototype.parse=function(e){for(var t,i;e.getPosition()<this.start+this.size;){if((t=c.parseOneBox(e,!0,this.size-(e.getPosition()-this.start))).code!==c.OK)return;(i=new c.TrackReferenceTypeBox(t.type,t.size,t.hdr_size,t.start)).write===c.Box.prototype.write&&"mdat"!==i.type&&(a.info("BoxParser","TrackReference "+i.type+" box writing not yet implemented, keeping unparsed data in memory for later write"),i.parseDataAndRewind(e)),i.parse(e),this.boxes.push(i)}},c.createFullBoxCtor("trep",(function(e){for(this.track_ID=e.readUint32(),this.boxes=[];e.getPosition()<this.start+this.size;){if(ret=c.parseOneBox(e,!1,this.size-(e.getPosition()-this.start)),ret.code!==c.OK)return;box=ret.box,this.boxes.push(box)}})),c.createFullBoxCtor("trex",(function(e){this.track_id=e.readUint32(),this.default_sample_description_index=e.readUint32(),this.default_sample_duration=e.readUint32(),this.default_sample_size=e.readUint32(),this.default_sample_flags=e.readUint32()})),c.createBoxCtor("trpy",(function(e){this.bytessent=e.readUint64()})),c.createFullBoxCtor("trun",(function(e){var t=0;if(this.sample_count=e.readUint32(),t+=4,this.size-this.hdr_size>t&&this.flags&c.TRUN_FLAGS_DATA_OFFSET?(this.data_offset=e.readInt32(),t+=4):this.data_offset=0,this.size-this.hdr_size>t&&this.flags&c.TRUN_FLAGS_FIRST_FLAG?(this.first_sample_flags=e.readUint32(),t+=4):this.first_sample_flags=0,this.sample_duration=[],this.sample_size=[],this.sample_flags=[],this.sample_composition_time_offset=[],this.size-this.hdr_size>t)for(var i=0;i<this.sample_count;i++)this.flags&c.TRUN_FLAGS_DURATION&&(this.sample_duration[i]=e.readUint32()),this.flags&c.TRUN_FLAGS_SIZE&&(this.sample_size[i]=e.readUint32()),this.flags&c.TRUN_FLAGS_FLAGS&&(this.sample_flags[i]=e.readUint32()),this.flags&c.TRUN_FLAGS_CTS_OFFSET&&(0===this.version?this.sample_composition_time_offset[i]=e.readUint32():this.sample_composition_time_offset[i]=e.readInt32())})),c.createFullBoxCtor("tsel",(function(e){this.switch_group=e.readUint32();var t=(this.size-this.hdr_size-4)/4;this.attribute_list=[];for(var i=0;i<t;i++)this.attribute_list[i]=e.readUint32()})),c.createFullBoxCtor("txtC",(function(e){this.config=e.readCString()})),c.createFullBoxCtor("url ",(function(e){1!==this.flags&&(this.location=e.readCString())})),c.createFullBoxCtor("urn ",(function(e){this.name=e.readCString(),this.size-this.hdr_size-this.name.length-1>0&&(this.location=e.readCString())})),c.createUUIDBox("a5d40b30e81411ddba2f0800200c9a66",!0,!1,(function(e){this.LiveServerManifest=e.readString(this.size-this.hdr_size).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")})),c.createUUIDBox("d08a4f1810f34a82b6c832d8aba183d3",!0,!1,(function(e){this.system_id=c.parseHex16(e);var t=e.readUint32();t>0&&(this.data=e.readUint8Array(t))})),c.createUUIDBox("a2394f525a9b4f14a2446c427c648df4",!0,!1),c.createUUIDBox("8974dbce7be74c5184f97148f9882554",!0,!1,(function(e){this.default_AlgorithmID=e.readUint24(),this.default_IV_size=e.readUint8(),this.default_KID=c.parseHex16(e)})),c.createUUIDBox("d4807ef2ca3946958e5426cb9e46a79f",!0,!1,(function(e){this.fragment_count=e.readUint8(),this.entries=[];for(var t=0;t<this.fragment_count;t++){var i={},r=0,s=0;1===this.version?(r=e.readUint64(),s=e.readUint64()):(r=e.readUint32(),s=e.readUint32()),i.absolute_time=r,i.absolute_duration=s,this.entries.push(i)}})),c.createUUIDBox("6d1d9b0542d544e680e2141daff757b2",!0,!1,(function(e){1===this.version?(this.absolute_time=e.readUint64(),this.duration=e.readUint64()):(this.absolute_time=e.readUint32(),this.duration=e.readUint32())})),c.createFullBoxCtor("vmhd",(function(e){this.graphicsmode=e.readUint16(),this.opcolor=e.readUint16Array(3)})),c.createFullBoxCtor("vpcC",(function(e){var t;1===this.version?(this.profile=e.readUint8(),this.level=e.readUint8(),t=e.readUint8(),this.bitDepth=t>>4,this.chromaSubsampling=t>>1&7,this.videoFullRangeFlag=1&t,this.colourPrimaries=e.readUint8(),this.transferCharacteristics=e.readUint8(),this.matrixCoefficients=e.readUint8(),this.codecIntializationDataSize=e.readUint16(),this.codecIntializationData=e.readUint8Array(this.codecIntializationDataSize)):(this.profile=e.readUint8(),this.level=e.readUint8(),t=e.readUint8(),this.bitDepth=t>>4&15,this.colorSpace=15&t,t=e.readUint8(),this.chromaSubsampling=t>>4&15,this.transferFunction=t>>1&7,this.videoFullRangeFlag=1&t,this.codecIntializationDataSize=e.readUint16(),this.codecIntializationData=e.readUint8Array(this.codecIntializationDataSize))})),c.createBoxCtor("vttC",(function(e){this.text=e.readString(this.size-this.hdr_size)})),c.createFullBoxCtor("vvcC",(function(e){var t,i,r={held_bits:void 0,num_held_bits:0,stream_read_1_bytes:function(e){this.held_bits=e.readUint8(),this.num_held_bits=8},stream_read_2_bytes:function(e){this.held_bits=e.readUint16(),this.num_held_bits=16},extract_bits:function(e){var t=this.held_bits>>this.num_held_bits-e&(1<<e)-1;return this.num_held_bits-=e,t}};if(r.stream_read_1_bytes(e),r.extract_bits(5),this.lengthSizeMinusOne=r.extract_bits(2),this.ptl_present_flag=r.extract_bits(1),this.ptl_present_flag){if(r.stream_read_2_bytes(e),this.ols_idx=r.extract_bits(9),this.num_sublayers=r.extract_bits(3),this.constant_frame_rate=r.extract_bits(2),this.chroma_format_idc=r.extract_bits(2),r.stream_read_1_bytes(e),this.bit_depth_minus8=r.extract_bits(3),r.extract_bits(5),r.stream_read_2_bytes(e),r.extract_bits(2),this.num_bytes_constraint_info=r.extract_bits(6),this.general_profile_idc=r.extract_bits(7),this.general_tier_flag=r.extract_bits(1),this.general_level_idc=e.readUint8(),r.stream_read_1_bytes(e),this.ptl_frame_only_constraint_flag=r.extract_bits(1),this.ptl_multilayer_enabled_flag=r.extract_bits(1),this.general_constraint_info=new Uint8Array(this.num_bytes_constraint_info),this.num_bytes_constraint_info){for(t=0;t<this.num_bytes_constraint_info-1;t++){var s=r.extract_bits(6);r.stream_read_1_bytes(e);var a=r.extract_bits(2);this.general_constraint_info[t]=s<<2|a}this.general_constraint_info[this.num_bytes_constraint_info-1]=r.extract_bits(6)}else r.extract_bits(6);for(r.stream_read_1_bytes(e),this.ptl_sublayer_present_mask=0,i=this.num_sublayers-2;i>=0;--i){var n=r.extract_bits(1);this.ptl_sublayer_present_mask|=n<<i}for(i=this.num_sublayers;i<=8&&this.num_sublayers>1;++i)r.extract_bits(1);for(i=this.num_sublayers-2;i>=0;--i)this.ptl_sublayer_present_mask&1<<i&&(this.sublayer_level_idc[i]=e.readUint8());if(this.ptl_num_sub_profiles=e.readUint8(),this.general_sub_profile_idc=[],this.ptl_num_sub_profiles)for(t=0;t<this.ptl_num_sub_profiles;t++)this.general_sub_profile_idc.push(e.readUint32());this.max_picture_width=e.readUint16(),this.max_picture_height=e.readUint16(),this.avg_frame_rate=e.readUint16()}this.nalu_arrays=[];var o=e.readUint8();for(t=0;t<o;t++){var l=[];this.nalu_arrays.push(l),r.stream_read_1_bytes(e),l.completeness=r.extract_bits(1),r.extract_bits(2),l.nalu_type=r.extract_bits(5);var d=1;for(13!=l.nalu_type&&12!=l.nalu_type&&(d=e.readUint16()),i=0;i<d;i++){var h=e.readUint16();l.push({data:e.readUint8Array(h),length:h})}}})),c.createFullBoxCtor("vvnC",(function(e){var t=strm.readUint8();this.lengthSizeMinusOne=3&t})),c.SampleEntry.prototype.isVideo=function(){return!1},c.SampleEntry.prototype.isAudio=function(){return!1},c.SampleEntry.prototype.isSubtitle=function(){return!1},c.SampleEntry.prototype.isMetadata=function(){return!1},c.SampleEntry.prototype.isHint=function(){return!1},c.SampleEntry.prototype.getCodec=function(){return this.type.replace(".","")},c.SampleEntry.prototype.getWidth=function(){return""},c.SampleEntry.prototype.getHeight=function(){return""},c.SampleEntry.prototype.getChannelCount=function(){return""},c.SampleEntry.prototype.getSampleRate=function(){return""},c.SampleEntry.prototype.getSampleSize=function(){return""},c.VisualSampleEntry.prototype.isVideo=function(){return!0},c.VisualSampleEntry.prototype.getWidth=function(){return this.width},c.VisualSampleEntry.prototype.getHeight=function(){return this.height},c.AudioSampleEntry.prototype.isAudio=function(){return!0},c.AudioSampleEntry.prototype.getChannelCount=function(){return this.channel_count},c.AudioSampleEntry.prototype.getSampleRate=function(){return this.samplerate},c.AudioSampleEntry.prototype.getSampleSize=function(){return this.samplesize},c.SubtitleSampleEntry.prototype.isSubtitle=function(){return!0},c.MetadataSampleEntry.prototype.isMetadata=function(){return!0},c.decimalToHex=function(e,t){var i=Number(e).toString(16);for(t=null==t?t=2:t;i.length<t;)i="0"+i;return i},c.avc1SampleEntry.prototype.getCodec=c.avc2SampleEntry.prototype.getCodec=c.avc3SampleEntry.prototype.getCodec=c.avc4SampleEntry.prototype.getCodec=function(){var e=c.SampleEntry.prototype.getCodec.call(this);return this.avcC?e+"."+c.decimalToHex(this.avcC.AVCProfileIndication)+c.decimalToHex(this.avcC.profile_compatibility)+c.decimalToHex(this.avcC.AVCLevelIndication):e},c.hev1SampleEntry.prototype.getCodec=c.hvc1SampleEntry.prototype.getCodec=function(){var e,t=c.SampleEntry.prototype.getCodec.call(this);if(this.hvcC){switch(t+=".",this.hvcC.general_profile_space){case 0:t+="";break;case 1:t+="A";break;case 2:t+="B";break;case 3:t+="C"}t+=this.hvcC.general_profile_idc,t+=".";var i=this.hvcC.general_profile_compatibility,r=0;for(e=0;e<32&&(r|=1&i,31!=e);e++)r<<=1,i>>=1;t+=c.decimalToHex(r,0),t+=".",0===this.hvcC.general_tier_flag?t+="L":t+="H",t+=this.hvcC.general_level_idc;var s=!1,a="";for(e=5;e>=0;e--)(this.hvcC.general_constraint_indicator[e]||s)&&(a="."+c.decimalToHex(this.hvcC.general_constraint_indicator[e],0)+a,s=!0);t+=a}return t},c.vvc1SampleEntry.prototype.getCodec=c.vvi1SampleEntry.prototype.getCodec=function(){var e,t=c.SampleEntry.prototype.getCodec.call(this);if(this.vvcC){t+="."+this.vvcC.general_profile_idc,this.vvcC.general_tier_flag?t+=".H":t+=".L",t+=this.vvcC.general_level_idc;var i="";if(this.vvcC.general_constraint_info){var r,s=[],a=0;for(a|=this.vvcC.ptl_frame_only_constraint<<7,a|=this.vvcC.ptl_multilayer_enabled<<6,e=0;e<this.vvcC.general_constraint_info.length;++e)a|=this.vvcC.general_constraint_info[e]>>2&63,s.push(a),a&&(r=e),a=this.vvcC.general_constraint_info[e]>>2&3;if(void 0===r)i=".CA";else{i=".C";var n="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",o=0,l=0;for(e=0;e<=r;++e)for(o=o<<8|s[e],l+=8;l>=5;){i+=n[o>>l-5&31],o&=(1<<(l-=5))-1}l&&(i+=n[31&(o<<=5-l)])}}t+=i}return t},c.mp4aSampleEntry.prototype.getCodec=function(){var e=c.SampleEntry.prototype.getCodec.call(this);if(this.esds&&this.esds.esd){var t=this.esds.esd.getOTI(),i=this.esds.esd.getAudioConfig();return e+"."+c.decimalToHex(t)+(i?"."+i:"")}return e},c.stxtSampleEntry.prototype.getCodec=function(){var e=c.SampleEntry.prototype.getCodec.call(this);return this.mime_format?e+"."+this.mime_format:e},c.vp08SampleEntry.prototype.getCodec=c.vp09SampleEntry.prototype.getCodec=function(){var e=c.SampleEntry.prototype.getCodec.call(this),t=this.vpcC.level;0==t&&(t="00");var i=this.vpcC.bitDepth;return 8==i&&(i="08"),e+".0"+this.vpcC.profile+"."+t+"."+i},c.av01SampleEntry.prototype.getCodec=function(){var e,t=c.SampleEntry.prototype.getCodec.call(this),i=this.av1C.seq_level_idx_0;return i<10&&(i="0"+i),2===this.av1C.seq_profile&&1===this.av1C.high_bitdepth?e=1===this.av1C.twelve_bit?"12":"10":this.av1C.seq_profile<=2&&(e=1===this.av1C.high_bitdepth?"10":"08"),t+"."+this.av1C.seq_profile+"."+i+(this.av1C.seq_tier_0?"H":"M")+"."+e},c.Box.prototype.writeHeader=function(e,t){this.size+=8,this.size>l&&(this.size+=8),"uuid"===this.type&&(this.size+=16),a.debug("BoxWriter","Writing box "+this.type+" of size: "+this.size+" at position "+e.getPosition()+(t||"")),this.size>l?e.writeUint32(1):(this.sizePosition=e.getPosition(),e.writeUint32(this.size)),e.writeString(this.type,null,4),"uuid"===this.type&&e.writeUint8Array(this.uuid),this.size>l&&e.writeUint64(this.size)},c.FullBox.prototype.writeHeader=function(e){this.size+=4,c.Box.prototype.writeHeader.call(this,e," v="+this.version+" f="+this.flags),e.writeUint8(this.version),e.writeUint24(this.flags)},c.Box.prototype.write=function(e){"mdat"===this.type?this.data&&(this.size=this.data.length,this.writeHeader(e),e.writeUint8Array(this.data)):(this.size=this.data?this.data.length:0,this.writeHeader(e),this.data&&e.writeUint8Array(this.data))},c.ContainerBox.prototype.write=function(e){this.size=0,this.writeHeader(e);for(var t=0;t<this.boxes.length;t++)this.boxes[t]&&(this.boxes[t].write(e),this.size+=this.boxes[t].size);a.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),e.adjustUint32(this.sizePosition,this.size)},c.TrackReferenceTypeBox.prototype.write=function(e){this.size=4*this.track_ids.length,this.writeHeader(e),e.writeUint32Array(this.track_ids)},c.avcCBox.prototype.write=function(e){var t;for(this.size=7,t=0;t<this.SPS.length;t++)this.size+=2+this.SPS[t].length;for(t=0;t<this.PPS.length;t++)this.size+=2+this.PPS[t].length;for(this.ext&&(this.size+=this.ext.length),this.writeHeader(e),e.writeUint8(this.configurationVersion),e.writeUint8(this.AVCProfileIndication),e.writeUint8(this.profile_compatibility),e.writeUint8(this.AVCLevelIndication),e.writeUint8(this.lengthSizeMinusOne+252),e.writeUint8(this.SPS.length+224),t=0;t<this.SPS.length;t++)e.writeUint16(this.SPS[t].length),e.writeUint8Array(this.SPS[t].nalu);for(e.writeUint8(this.PPS.length),t=0;t<this.PPS.length;t++)e.writeUint16(this.PPS[t].length),e.writeUint8Array(this.PPS[t].nalu);this.ext&&e.writeUint8Array(this.ext)},c.co64Box.prototype.write=function(e){var t;for(this.version=0,this.flags=0,this.size=4+8*this.chunk_offsets.length,this.writeHeader(e),e.writeUint32(this.chunk_offsets.length),t=0;t<this.chunk_offsets.length;t++)e.writeUint64(this.chunk_offsets[t])},c.cslgBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=20,this.writeHeader(e),e.writeInt32(this.compositionToDTSShift),e.writeInt32(this.leastDecodeToDisplayDelta),e.writeInt32(this.greatestDecodeToDisplayDelta),e.writeInt32(this.compositionStartTime),e.writeInt32(this.compositionEndTime)},c.cttsBox.prototype.write=function(e){var t;for(this.version=0,this.flags=0,this.size=4+8*this.sample_counts.length,this.writeHeader(e),e.writeUint32(this.sample_counts.length),t=0;t<this.sample_counts.length;t++)e.writeUint32(this.sample_counts[t]),1===this.version?e.writeInt32(this.sample_offsets[t]):e.writeUint32(this.sample_offsets[t])},c.drefBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=4,this.writeHeader(e),e.writeUint32(this.entries.length);for(var t=0;t<this.entries.length;t++)this.entries[t].write(e),this.size+=this.entries[t].size;a.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),e.adjustUint32(this.sizePosition,this.size)},c.elngBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=this.extended_language.length,this.writeHeader(e),e.writeString(this.extended_language)},c.elstBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=4+12*this.entries.length,this.writeHeader(e),e.writeUint32(this.entries.length);for(var t=0;t<this.entries.length;t++){var i=this.entries[t];e.writeUint32(i.segment_duration),e.writeInt32(i.media_time),e.writeInt16(i.media_rate_integer),e.writeInt16(i.media_rate_fraction)}},c.emsgBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=16+this.message_data.length+(this.scheme_id_uri.length+1)+(this.value.length+1),this.writeHeader(e),e.writeCString(this.scheme_id_uri),e.writeCString(this.value),e.writeUint32(this.timescale),e.writeUint32(this.presentation_time_delta),e.writeUint32(this.event_duration),e.writeUint32(this.id),e.writeUint8Array(this.message_data)},c.ftypBox.prototype.write=function(e){this.size=8+4*this.compatible_brands.length,this.writeHeader(e),e.writeString(this.major_brand,null,4),e.writeUint32(this.minor_version);for(var t=0;t<this.compatible_brands.length;t++)e.writeString(this.compatible_brands[t],null,4)},c.hdlrBox.prototype.write=function(e){this.size=20+this.name.length+1,this.version=0,this.flags=0,this.writeHeader(e),e.writeUint32(0),e.writeString(this.handler,null,4),e.writeUint32(0),e.writeUint32(0),e.writeUint32(0),e.writeCString(this.name)},c.kindBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=this.schemeURI.length+1+(this.value.length+1),this.writeHeader(e),e.writeCString(this.schemeURI),e.writeCString(this.value)},c.mdhdBox.prototype.write=function(e){this.size=20,this.flags=0,this.version=0,this.writeHeader(e),e.writeUint32(this.creation_time),e.writeUint32(this.modification_time),e.writeUint32(this.timescale),e.writeUint32(this.duration),e.writeUint16(this.language),e.writeUint16(0)},c.mehdBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=4,this.writeHeader(e),e.writeUint32(this.fragment_duration)},c.mfhdBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=4,this.writeHeader(e),e.writeUint32(this.sequence_number)},c.mvhdBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=96,this.writeHeader(e),e.writeUint32(this.creation_time),e.writeUint32(this.modification_time),e.writeUint32(this.timescale),e.writeUint32(this.duration),e.writeUint32(this.rate),e.writeUint16(this.volume<<8),e.writeUint16(0),e.writeUint32(0),e.writeUint32(0),e.writeUint32Array(this.matrix),e.writeUint32(0),e.writeUint32(0),e.writeUint32(0),e.writeUint32(0),e.writeUint32(0),e.writeUint32(0),e.writeUint32(this.next_track_id)},c.SampleEntry.prototype.writeHeader=function(e){this.size=8,c.Box.prototype.writeHeader.call(this,e),e.writeUint8(0),e.writeUint8(0),e.writeUint8(0),e.writeUint8(0),e.writeUint8(0),e.writeUint8(0),e.writeUint16(this.data_reference_index)},c.SampleEntry.prototype.writeFooter=function(e){for(var t=0;t<this.boxes.length;t++)this.boxes[t].write(e),this.size+=this.boxes[t].size;a.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),e.adjustUint32(this.sizePosition,this.size)},c.SampleEntry.prototype.write=function(e){this.writeHeader(e),e.writeUint8Array(this.data),this.size+=this.data.length,a.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),e.adjustUint32(this.sizePosition,this.size)},c.VisualSampleEntry.prototype.write=function(e){this.writeHeader(e),this.size+=70,e.writeUint16(0),e.writeUint16(0),e.writeUint32(0),e.writeUint32(0),e.writeUint32(0),e.writeUint16(this.width),e.writeUint16(this.height),e.writeUint32(this.horizresolution),e.writeUint32(this.vertresolution),e.writeUint32(0),e.writeUint16(this.frame_count),e.writeUint8(Math.min(31,this.compressorname.length)),e.writeString(this.compressorname,null,31),e.writeUint16(this.depth),e.writeInt16(-1),this.writeFooter(e)},c.AudioSampleEntry.prototype.write=function(e){this.writeHeader(e),this.size+=20,e.writeUint32(0),e.writeUint32(0),e.writeUint16(this.channel_count),e.writeUint16(this.samplesize),e.writeUint16(0),e.writeUint16(0),e.writeUint32(this.samplerate<<16),this.writeFooter(e)},c.stppSampleEntry.prototype.write=function(e){this.writeHeader(e),this.size+=this.namespace.length+1+this.schema_location.length+1+this.auxiliary_mime_types.length+1,e.writeCString(this.namespace),e.writeCString(this.schema_location),e.writeCString(this.auxiliary_mime_types),this.writeFooter(e)},c.SampleGroupEntry.prototype.write=function(e){e.writeUint8Array(this.data)},c.sbgpBox.prototype.write=function(e){this.version=1,this.flags=0,this.size=12+8*this.entries.length,this.writeHeader(e),e.writeString(this.grouping_type,null,4),e.writeUint32(this.grouping_type_parameter),e.writeUint32(this.entries.length);for(var t=0;t<this.entries.length;t++){var i=this.entries[t];e.writeInt32(i.sample_count),e.writeInt32(i.group_description_index)}},c.sgpdBox.prototype.write=function(e){var t,i;for(this.flags=0,this.size=12,t=0;t<this.entries.length;t++)i=this.entries[t],1===this.version&&(0===this.default_length&&(this.size+=4),this.size+=i.data.length);for(this.writeHeader(e),e.writeString(this.grouping_type,null,4),1===this.version&&e.writeUint32(this.default_length),this.version>=2&&e.writeUint32(this.default_sample_description_index),e.writeUint32(this.entries.length),t=0;t<this.entries.length;t++)i=this.entries[t],1===this.version&&0===this.default_length&&e.writeUint32(i.description_length),i.write(e)},c.sidxBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=20+12*this.references.length,this.writeHeader(e),e.writeUint32(this.reference_ID),e.writeUint32(this.timescale),e.writeUint32(this.earliest_presentation_time),e.writeUint32(this.first_offset),e.writeUint16(0),e.writeUint16(this.references.length);for(var t=0;t<this.references.length;t++){var i=this.references[t];e.writeUint32(i.reference_type<<31|i.referenced_size),e.writeUint32(i.subsegment_duration),e.writeUint32(i.starts_with_SAP<<31|i.SAP_type<<28|i.SAP_delta_time)}},c.smhdBox.prototype.write=function(e){this.version=0,this.flags=1,this.size=4,this.writeHeader(e),e.writeUint16(this.balance),e.writeUint16(0)},c.stcoBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=4+4*this.chunk_offsets.length,this.writeHeader(e),e.writeUint32(this.chunk_offsets.length),e.writeUint32Array(this.chunk_offsets)},c.stscBox.prototype.write=function(e){var t;for(this.version=0,this.flags=0,this.size=4+12*this.first_chunk.length,this.writeHeader(e),e.writeUint32(this.first_chunk.length),t=0;t<this.first_chunk.length;t++)e.writeUint32(this.first_chunk[t]),e.writeUint32(this.samples_per_chunk[t]),e.writeUint32(this.sample_description_index[t])},c.stsdBox.prototype.write=function(e){var t;for(this.version=0,this.flags=0,this.size=0,this.writeHeader(e),e.writeUint32(this.entries.length),this.size+=4,t=0;t<this.entries.length;t++)this.entries[t].write(e),this.size+=this.entries[t].size;a.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),e.adjustUint32(this.sizePosition,this.size)},c.stshBox.prototype.write=function(e){var t;for(this.version=0,this.flags=0,this.size=4+8*this.shadowed_sample_numbers.length,this.writeHeader(e),e.writeUint32(this.shadowed_sample_numbers.length),t=0;t<this.shadowed_sample_numbers.length;t++)e.writeUint32(this.shadowed_sample_numbers[t]),e.writeUint32(this.sync_sample_numbers[t])},c.stssBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=4+4*this.sample_numbers.length,this.writeHeader(e),e.writeUint32(this.sample_numbers.length),e.writeUint32Array(this.sample_numbers)},c.stszBox.prototype.write=function(e){var t,i=!0;if(this.version=0,this.flags=0,this.sample_sizes.length>0)for(t=0;t+1<this.sample_sizes.length;){if(this.sample_sizes[t+1]!==this.sample_sizes[0]){i=!1;break}t++}else i=!1;this.size=8,i||(this.size+=4*this.sample_sizes.length),this.writeHeader(e),i?e.writeUint32(this.sample_sizes[0]):e.writeUint32(0),e.writeUint32(this.sample_sizes.length),i||e.writeUint32Array(this.sample_sizes)},c.sttsBox.prototype.write=function(e){var t;for(this.version=0,this.flags=0,this.size=4+8*this.sample_counts.length,this.writeHeader(e),e.writeUint32(this.sample_counts.length),t=0;t<this.sample_counts.length;t++)e.writeUint32(this.sample_counts[t]),e.writeUint32(this.sample_deltas[t])},c.tfdtBox.prototype.write=function(e){var t=Math.pow(2,32)-1;this.version=this.baseMediaDecodeTime>t?1:0,this.flags=0,this.size=4,1===this.version&&(this.size+=4),this.writeHeader(e),1===this.version?e.writeUint64(this.baseMediaDecodeTime):e.writeUint32(this.baseMediaDecodeTime)},c.tfhdBox.prototype.write=function(e){this.version=0,this.size=4,this.flags&c.TFHD_FLAG_BASE_DATA_OFFSET&&(this.size+=8),this.flags&c.TFHD_FLAG_SAMPLE_DESC&&(this.size+=4),this.flags&c.TFHD_FLAG_SAMPLE_DUR&&(this.size+=4),this.flags&c.TFHD_FLAG_SAMPLE_SIZE&&(this.size+=4),this.flags&c.TFHD_FLAG_SAMPLE_FLAGS&&(this.size+=4),this.writeHeader(e),e.writeUint32(this.track_id),this.flags&c.TFHD_FLAG_BASE_DATA_OFFSET&&e.writeUint64(this.base_data_offset),this.flags&c.TFHD_FLAG_SAMPLE_DESC&&e.writeUint32(this.default_sample_description_index),this.flags&c.TFHD_FLAG_SAMPLE_DUR&&e.writeUint32(this.default_sample_duration),this.flags&c.TFHD_FLAG_SAMPLE_SIZE&&e.writeUint32(this.default_sample_size),this.flags&c.TFHD_FLAG_SAMPLE_FLAGS&&e.writeUint32(this.default_sample_flags)},c.tkhdBox.prototype.write=function(e){this.version=0,this.size=80,this.writeHeader(e),e.writeUint32(this.creation_time),e.writeUint32(this.modification_time),e.writeUint32(this.track_id),e.writeUint32(0),e.writeUint32(this.duration),e.writeUint32(0),e.writeUint32(0),e.writeInt16(this.layer),e.writeInt16(this.alternate_group),e.writeInt16(this.volume<<8),e.writeUint16(0),e.writeInt32Array(this.matrix),e.writeUint32(this.width),e.writeUint32(this.height)},c.trexBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=20,this.writeHeader(e),e.writeUint32(this.track_id),e.writeUint32(this.default_sample_description_index),e.writeUint32(this.default_sample_duration),e.writeUint32(this.default_sample_size),e.writeUint32(this.default_sample_flags)},c.trunBox.prototype.write=function(e){this.version=0,this.size=4,this.flags&c.TRUN_FLAGS_DATA_OFFSET&&(this.size+=4),this.flags&c.TRUN_FLAGS_FIRST_FLAG&&(this.size+=4),this.flags&c.TRUN_FLAGS_DURATION&&(this.size+=4*this.sample_duration.length),this.flags&c.TRUN_FLAGS_SIZE&&(this.size+=4*this.sample_size.length),this.flags&c.TRUN_FLAGS_FLAGS&&(this.size+=4*this.sample_flags.length),this.flags&c.TRUN_FLAGS_CTS_OFFSET&&(this.size+=4*this.sample_composition_time_offset.length),this.writeHeader(e),e.writeUint32(this.sample_count),this.flags&c.TRUN_FLAGS_DATA_OFFSET&&(this.data_offset_position=e.getPosition(),e.writeInt32(this.data_offset)),this.flags&c.TRUN_FLAGS_FIRST_FLAG&&e.writeUint32(this.first_sample_flags);for(var t=0;t<this.sample_count;t++)this.flags&c.TRUN_FLAGS_DURATION&&e.writeUint32(this.sample_duration[t]),this.flags&c.TRUN_FLAGS_SIZE&&e.writeUint32(this.sample_size[t]),this.flags&c.TRUN_FLAGS_FLAGS&&e.writeUint32(this.sample_flags[t]),this.flags&c.TRUN_FLAGS_CTS_OFFSET&&(0===this.version?e.writeUint32(this.sample_composition_time_offset[t]):e.writeInt32(this.sample_composition_time_offset[t]))},c["url Box"].prototype.write=function(e){this.version=0,this.location?(this.flags=0,this.size=this.location.length+1):(this.flags=1,this.size=0),this.writeHeader(e),this.location&&e.writeCString(this.location)},c["urn Box"].prototype.write=function(e){this.version=0,this.flags=0,this.size=this.name.length+1+(this.location?this.location.length+1:0),this.writeHeader(e),e.writeCString(this.name),this.location&&e.writeCString(this.location)},c.vmhdBox.prototype.write=function(e){this.version=0,this.flags=1,this.size=8,this.writeHeader(e),e.writeUint16(this.graphicsmode),e.writeUint16Array(this.opcolor)},c.cttsBox.prototype.unpack=function(e){var t,i,r;for(r=0,t=0;t<this.sample_counts.length;t++)for(i=0;i<this.sample_counts[t];i++)e[r].pts=e[r].dts+this.sample_offsets[t],r++},c.sttsBox.prototype.unpack=function(e){var t,i,r;for(r=0,t=0;t<this.sample_counts.length;t++)for(i=0;i<this.sample_counts[t];i++)e[r].dts=0===r?0:e[r-1].dts+this.sample_deltas[t],r++},c.stcoBox.prototype.unpack=function(e){var t;for(t=0;t<this.chunk_offsets.length;t++)e[t].offset=this.chunk_offsets[t]},c.stscBox.prototype.unpack=function(e){var t,i,r,s,a;for(s=0,a=0,t=0;t<this.first_chunk.length;t++)for(i=0;i<(t+1<this.first_chunk.length?this.first_chunk[t+1]:1/0);i++)for(a++,r=0;r<this.samples_per_chunk[t];r++){if(!e[s])return;e[s].description_index=this.sample_description_index[t],e[s].chunk_index=a,s++}},c.stszBox.prototype.unpack=function(e){var t;for(t=0;t<this.sample_sizes.length;t++)e[t].size=this.sample_sizes[t]},c.DIFF_BOXES_PROP_NAMES=["boxes","entries","references","subsamples","items","item_infos","extents","associations","subsegments","ranges","seekLists","seekPoints","esd","levels"],c.DIFF_PRIMITIVE_ARRAY_PROP_NAMES=["compatible_brands","matrix","opcolor","sample_counts","sample_counts","sample_deltas","first_chunk","samples_per_chunk","sample_sizes","chunk_offsets","sample_offsets","sample_description_index","sample_duration"],c.boxEqualFields=function(e,t){if(e&&!t)return!1;var i;for(i in e)if(!(c.DIFF_BOXES_PROP_NAMES.indexOf(i)>-1||e[i]instanceof c.Box||t[i]instanceof c.Box||void 0===e[i]||void 0===t[i]||"function"==typeof e[i]||"function"==typeof t[i]||e.subBoxNames&&e.subBoxNames.indexOf(i.slice(0,4))>-1||t.subBoxNames&&t.subBoxNames.indexOf(i.slice(0,4))>-1||"data"===i||"start"===i||"size"===i||"creation_time"===i||"modification_time"===i||c.DIFF_PRIMITIVE_ARRAY_PROP_NAMES.indexOf(i)>-1||e[i]===t[i]))return!1;return!0},c.boxEqual=function(e,t){if(!c.boxEqualFields(e,t))return!1;for(var i=0;i<c.DIFF_BOXES_PROP_NAMES.length;i++){var r=c.DIFF_BOXES_PROP_NAMES[i];if(e[r]&&t[r]&&!c.boxEqual(e[r],t[r]))return!1}return!0};var u=function(){};u.prototype.parseSample=function(e){var t,i={};i.resources=[];var r=new n(e.data.buffer);if(e.subsamples&&0!==e.subsamples.length){if(i.documentString=r.readString(e.subsamples[0].size),e.subsamples.length>1)for(t=1;t<e.subsamples.length;t++)i.resources[t]=r.readUint8Array(e.subsamples[t].size)}else i.documentString=r.readString(e.data.length);return"undefined"!=typeof DOMParser&&(i.document=(new DOMParser).parseFromString(i.documentString,"application/xml")),i};var p=function(){};p.prototype.parseSample=function(e){return new n(e.data.buffer).readString(e.data.length)},p.prototype.parseConfig=function(e){var t=new n(e.buffer);return t.readUint32(),t.readCString()},t.XMLSubtitlein4Parser=u,t.Textin4Parser=p;var f=function(e){this.stream=e||new d,this.boxes=[],this.mdats=[],this.moofs=[],this.isProgressive=!1,this.moovStartFound=!1,this.onMoovStart=null,this.moovStartSent=!1,this.onReady=null,this.readySent=!1,this.onSegment=null,this.onSamples=null,this.onError=null,this.sampleListBuilt=!1,this.fragmentedTracks=[],this.extractedTracks=[],this.isFragmentationInitialized=!1,this.sampleProcessingStarted=!1,this.nextMoofNumber=0,this.itemListBuilt=!1,this.onSidx=null,this.sidxSent=!1};f.prototype.setSegmentOptions=function(e,t,i){var r=this.getTrackById(e);if(r){var s={};this.fragmentedTracks.push(s),s.id=e,s.user=t,s.trak=r,r.nextSample=0,s.segmentStream=null,s.nb_samples=1e3,s.rapAlignement=!0,i&&(i.nbSamples&&(s.nb_samples=i.nbSamples),i.rapAlignement&&(s.rapAlignement=i.rapAlignement))}},f.prototype.unsetSegmentOptions=function(e){for(var t=-1,i=0;i<this.fragmentedTracks.length;i++){this.fragmentedTracks[i].id==e&&(t=i)}t>-1&&this.fragmentedTracks.splice(t,1)},f.prototype.setExtractionOptions=function(e,t,i){var r=this.getTrackById(e);if(r){var s={};this.extractedTracks.push(s),s.id=e,s.user=t,s.trak=r,r.nextSample=0,s.nb_samples=1e3,s.samples=[],i&&i.nbSamples&&(s.nb_samples=i.nbSamples)}},f.prototype.unsetExtractionOptions=function(e){for(var t=-1,i=0;i<this.extractedTracks.length;i++){this.extractedTracks[i].id==e&&(t=i)}t>-1&&this.extractedTracks.splice(t,1)},f.prototype.parse=function(){var e,t;if(!this.restoreParsePosition||this.restoreParsePosition())for(;;){if(this.hasIncompleteMdat&&this.hasIncompleteMdat()){if(this.processIncompleteMdat())continue;return}if(this.saveParsePosition&&this.saveParsePosition(),(e=c.parseOneBox(this.stream,false)).code===c.ERR_NOT_ENOUGH_DATA){if(this.processIncompleteBox){if(this.processIncompleteBox(e))continue;return}return}var i;switch(i="uuid"!==(t=e.box).type?t.type:t.uuid,this.boxes.push(t),i){case"mdat":this.mdats.push(t);break;case"moof":this.moofs.push(t);break;case"moov":this.moovStartFound=!0,0===this.mdats.length&&(this.isProgressive=!0);default:void 0!==this[i]&&a.warn("ISOFile","Duplicate Box of type: "+i+", overriding previous occurrence"),this[i]=t}this.updateUsedBytes&&this.updateUsedBytes(t,e)}},f.prototype.checkBuffer=function(e){if(null==e)throw"Buffer must be defined and non empty";if(void 0===e.fileStart)throw"Buffer must have a fileStart property";return 0===e.byteLength?(a.warn("ISOFile","Ignoring empty buffer (fileStart: "+e.fileStart+")"),this.stream.logBufferLevel(),!1):(a.info("ISOFile","Processing buffer (fileStart: "+e.fileStart+")"),e.usedBytes=0,this.stream.insertBuffer(e),this.stream.logBufferLevel(),!!this.stream.initialized()||(a.warn("ISOFile","Not ready to start parsing"),!1))},f.prototype.appendBuffer=function(e,t){var i;if(this.checkBuffer(e))return this.parse(),this.moovStartFound&&!this.moovStartSent&&(this.moovStartSent=!0,this.onMoovStart&&this.onMoovStart()),this.moov?(this.sampleListBuilt||(this.buildSampleLists(),this.sampleListBuilt=!0),this.updateSampleLists(),this.onReady&&!this.readySent&&(this.readySent=!0,this.onReady(this.getInfo())),this.processSamples(t),this.nextSeekPosition?(i=this.nextSeekPosition,this.nextSeekPosition=void 0):i=this.nextParsePosition,this.stream.getEndFilePositionAfter&&(i=this.stream.getEndFilePositionAfter(i))):i=this.nextParsePosition?this.nextParsePosition:0,this.sidx&&this.onSidx&&!this.sidxSent&&(this.onSidx(this.sidx),this.sidxSent=!0),this.meta&&(this.flattenItemInfo&&!this.itemListBuilt&&(this.flattenItemInfo(),this.itemListBuilt=!0),this.processItems&&this.processItems(this.onItem)),this.stream.cleanBuffers&&(a.info("ISOFile","Done processing buffer (fileStart: "+e.fileStart+") - next buffer to fetch should have a fileStart position of "+i),this.stream.logBufferLevel(),this.stream.cleanBuffers(),this.stream.logBufferLevel(!0),a.info("ISOFile","Sample data size in memory: "+this.getAllocatedSampleDataSize())),i},f.prototype.getInfo=function(){var e,t,i,r,s,a,n={},o=new Date("1904-01-01T00:00:00Z").getTime();if(this.moov)for(n.hasMoov=!0,n.duration=this.moov.mvhd.duration,n.timescale=this.moov.mvhd.timescale,n.isFragmented=null!=this.moov.mvex,n.isFragmented&&this.moov.mvex.mehd&&(n.fragment_duration=this.moov.mvex.mehd.fragment_duration),n.isProgressive=this.isProgressive,n.hasIOD=null!=this.moov.iods,n.brands=[],n.brands.push(this.ftyp.major_brand),n.brands=n.brands.concat(this.ftyp.compatible_brands),n.created=new Date(o+1e3*this.moov.mvhd.creation_time),n.modified=new Date(o+1e3*this.moov.mvhd.modification_time),n.tracks=[],n.audioTracks=[],n.videoTracks=[],n.subtitleTracks=[],n.metadataTracks=[],n.hintTracks=[],n.otherTracks=[],e=0;e<this.moov.traks.length;e++){if(a=(i=this.moov.traks[e]).mdia.minf.stbl.stsd.entries[0],r={},n.tracks.push(r),r.id=i.tkhd.track_id,r.name=i.mdia.hdlr.name,r.references=[],i.tref)for(t=0;t<i.tref.boxes.length;t++)s={},r.references.push(s),s.type=i.tref.boxes[t].type,s.track_ids=i.tref.boxes[t].track_ids;i.edts&&(r.edits=i.edts.elst.entries),r.created=new Date(o+1e3*i.tkhd.creation_time),r.modified=new Date(o+1e3*i.tkhd.modification_time),r.movie_duration=i.tkhd.duration,r.movie_timescale=n.timescale,r.layer=i.tkhd.layer,r.alternate_group=i.tkhd.alternate_group,r.volume=i.tkhd.volume,r.matrix=i.tkhd.matrix,r.track_width=i.tkhd.width/65536,r.track_height=i.tkhd.height/65536,r.timescale=i.mdia.mdhd.timescale,r.cts_shift=i.mdia.minf.stbl.cslg,r.duration=i.mdia.mdhd.duration,r.samples_duration=i.samples_duration,r.codec=a.getCodec(),r.kind=i.udta&&i.udta.kinds.length?i.udta.kinds[0]:{schemeURI:"",value:""},r.language=i.mdia.elng?i.mdia.elng.extended_language:i.mdia.mdhd.languageString,r.nb_samples=i.samples.length,r.size=i.samples_size,r.bitrate=8*r.size*r.timescale/r.samples_duration,a.isAudio()?(r.type="audio",n.audioTracks.push(r),r.audio={},r.audio.sample_rate=a.getSampleRate(),r.audio.channel_count=a.getChannelCount(),r.audio.sample_size=a.getSampleSize()):a.isVideo()?(r.type="video",n.videoTracks.push(r),r.video={},r.video.width=a.getWidth(),r.video.height=a.getHeight()):a.isSubtitle()?(r.type="subtitles",n.subtitleTracks.push(r)):a.isHint()?(r.type="metadata",n.hintTracks.push(r)):a.isMetadata()?(r.type="metadata",n.metadataTracks.push(r)):(r.type="metadata",n.otherTracks.push(r))}else n.hasMoov=!1;if(n.mime="",n.hasMoov&&n.tracks){for(n.videoTracks&&n.videoTracks.length>0?n.mime+='video/mp4; codecs="':n.audioTracks&&n.audioTracks.length>0?n.mime+='audio/mp4; codecs="':n.mime+='application/mp4; codecs="',e=0;e<n.tracks.length;e++)0!==e&&(n.mime+=","),n.mime+=n.tracks[e].codec;n.mime+='"; profiles="',n.mime+=this.ftyp.compatible_brands.join(),n.mime+='"'}return n},f.prototype.processSamples=function(e){var t,i;if(this.sampleProcessingStarted){if(this.isFragmentationInitialized&&null!==this.onSegment)for(t=0;t<this.fragmentedTracks.length;t++){var r=this.fragmentedTracks[t];for(i=r.trak;i.nextSample<i.samples.length&&this.sampleProcessingStarted;){a.debug("ISOFile","Creating media fragment on track #"+r.id+" for sample "+i.nextSample);var s=this.createFragment(r.id,i.nextSample,r.segmentStream);if(!s)break;if(r.segmentStream=s,i.nextSample++,(i.nextSample%r.nb_samples==0||e||i.nextSample>=i.samples.length)&&(a.info("ISOFile","Sending fragmented data on track #"+r.id+" for samples ["+Math.max(0,i.nextSample-r.nb_samples)+","+(i.nextSample-1)+"]"),a.info("ISOFile","Sample data size in memory: "+this.getAllocatedSampleDataSize()),this.onSegment&&this.onSegment(r.id,r.user,r.segmentStream.buffer,i.nextSample,e||i.nextSample>=i.samples.length),r.segmentStream=null,r!==this.fragmentedTracks[t]))break}}if(null!==this.onSamples)for(t=0;t<this.extractedTracks.length;t++){var n=this.extractedTracks[t];for(i=n.trak;i.nextSample<i.samples.length&&this.sampleProcessingStarted;){a.debug("ISOFile","Exporting on track #"+n.id+" sample #"+i.nextSample);var o=this.getSample(i,i.nextSample);if(!o)break;if(i.nextSample++,n.samples.push(o),(i.nextSample%n.nb_samples==0||i.nextSample>=i.samples.length)&&(a.debug("ISOFile","Sending samples on track #"+n.id+" for sample "+i.nextSample),this.onSamples&&this.onSamples(n.id,n.user,n.samples),n.samples=[],n!==this.extractedTracks[t]))break}}}},f.prototype.getBox=function(e){var t=this.getBoxes(e,!0);return t.length?t[0]:null},f.prototype.getBoxes=function(e,t){var i=[];return f._sweep.call(this,e,i,t),i},f._sweep=function(e,t,i){for(var r in this.type&&this.type==e&&t.push(this),this.boxes){if(t.length&&i)return;f._sweep.call(this.boxes[r],e,t,i)}},f.prototype.getTrackSamplesInfo=function(e){var t=this.getTrackById(e);return t?t.samples:void 0},f.prototype.getTrackSample=function(e,t){var i=this.getTrackById(e);return this.getSample(i,t)},f.prototype.releaseUsedSamples=function(e,t){var i=0,r=this.getTrackById(e);r.lastValidSample||(r.lastValidSample=0);for(var s=r.lastValidSample;s<t;s++)i+=this.releaseSample(r,s);a.info("ISOFile","Track #"+e+" released samples up to "+t+" (released size: "+i+", remaining: "+this.samplesDataSize+")"),r.lastValidSample=t},f.prototype.start=function(){this.sampleProcessingStarted=!0,this.processSamples(!1)},f.prototype.stop=function(){this.sampleProcessingStarted=!1},f.prototype.flush=function(){a.info("ISOFile","Flushing remaining samples"),this.updateSampleLists(),this.processSamples(!0),this.stream.cleanBuffers(),this.stream.logBufferLevel(!0)},f.prototype.seekTrack=function(e,t,i){var r,s,n,o,l=0,d=0;if(0===i.samples.length)return a.info("ISOFile","No sample in track, cannot seek! Using time "+a.getDurationString(0,1)+" and offset: 0"),{offset:0,time:0};for(r=0;r<i.samples.length;r++){if(s=i.samples[r],0===r)d=0,o=s.timescale;else if(s.cts>e*s.timescale){d=r-1;break}t&&s.is_sync&&(l=r)}for(t&&(d=l),e=i.samples[d].cts,i.nextSample=d;i.samples[d].alreadyRead===i.samples[d].size&&i.samples[d+1];)d++;return n=i.samples[d].offset+i.samples[d].alreadyRead,a.info("ISOFile","Seeking to "+(t?"RAP":"")+" sample #"+i.nextSample+" on track "+i.tkhd.track_id+", time "+a.getDurationString(e,o)+" and offset: "+n),{offset:n,time:e/o}},f.prototype.seek=function(e,t){var i,r,s,n=this.moov,o={offset:1/0,time:1/0};if(this.moov){for(s=0;s<n.traks.length;s++)i=n.traks[s],(r=this.seekTrack(e,t,i)).offset<o.offset&&(o.offset=r.offset),r.time<o.time&&(o.time=r.time);return a.info("ISOFile","Seeking at time "+a.getDurationString(o.time,1)+" needs a buffer with a fileStart position of "+o.offset),o.offset===1/0?o={offset:this.nextParsePosition,time:0}:o.offset=this.stream.getEndFilePositionAfter(o.offset),a.info("ISOFile","Adjusted seek position (after checking data already in buffer): "+o.offset),o}throw"Cannot seek: moov not received!"},f.prototype.equal=function(e){for(var t=0;t<this.boxes.length&&t<e.boxes.length;){var i=this.boxes[t],r=e.boxes[t];if(!c.boxEqual(i,r))return!1;t++}return!0},t.ISOFile=f,f.prototype.lastBoxStartPosition=0,f.prototype.parsingMdat=null,f.prototype.nextParsePosition=0,f.prototype.discardMdatData=!1,f.prototype.processIncompleteBox=function(e){var t;return"mdat"===e.type?(t=new c[e.type+"Box"](e.size),this.parsingMdat=t,this.boxes.push(t),this.mdats.push(t),t.start=e.start,t.hdr_size=e.hdr_size,this.stream.addUsedBytes(t.hdr_size),this.lastBoxStartPosition=t.start+t.size,this.stream.seek(t.start+t.size,!1,this.discardMdatData)?(this.parsingMdat=null,!0):(this.moovStartFound?this.nextParsePosition=this.stream.findEndContiguousBuf():this.nextParsePosition=t.start+t.size,!1)):("moov"===e.type&&(this.moovStartFound=!0,0===this.mdats.length&&(this.isProgressive=!0)),!!this.stream.mergeNextBuffer&&this.stream.mergeNextBuffer()?(this.nextParsePosition=this.stream.getEndPosition(),!0):(e.type?this.moovStartFound?this.nextParsePosition=this.stream.getEndPosition():this.nextParsePosition=this.stream.getPosition()+e.size:this.nextParsePosition=this.stream.getEndPosition(),!1))},f.prototype.hasIncompleteMdat=function(){return null!==this.parsingMdat},f.prototype.processIncompleteMdat=function(){var e;return e=this.parsingMdat,this.stream.seek(e.start+e.size,!1,this.discardMdatData)?(a.debug("ISOFile","Found 'mdat' end in buffered data"),this.parsingMdat=null,!0):(this.nextParsePosition=this.stream.findEndContiguousBuf(),!1)},f.prototype.restoreParsePosition=function(){return this.stream.seek(this.lastBoxStartPosition,!0,this.discardMdatData)},f.prototype.saveParsePosition=function(){this.lastBoxStartPosition=this.stream.getPosition()},f.prototype.updateUsedBytes=function(e,t){this.stream.addUsedBytes&&("mdat"===e.type?(this.stream.addUsedBytes(e.hdr_size),this.discardMdatData&&this.stream.addUsedBytes(e.size-e.hdr_size)):this.stream.addUsedBytes(e.size))},f.prototype.add=c.Box.prototype.add,f.prototype.addBox=c.Box.prototype.addBox,f.prototype.init=function(e){var t=e||{};this.add("ftyp").set("major_brand",t.brands&&t.brands[0]||"iso4").set("minor_version",0).set("compatible_brands",t.brands||["iso4"]);var i=this.add("moov");return i.add("mvhd").set("timescale",t.timescale||600).set("rate",t.rate||65536).set("creation_time",0).set("modification_time",0).set("duration",t.duration||0).set("volume",t.width?0:256).set("matrix",[65536,0,0,0,65536,0,0,0,1073741824]).set("next_track_id",1),i.add("mvex"),this},f.prototype.addTrack=function(e){this.moov||this.init(e);var t=e||{};t.width=t.width||320,t.height=t.height||320,t.id=t.id||this.moov.mvhd.next_track_id,t.type=t.type||"avc1";var i=this.moov.add("trak");this.moov.mvhd.next_track_id=t.id+1,i.add("tkhd").set("flags",c.TKHD_FLAG_ENABLED|c.TKHD_FLAG_IN_MOVIE|c.TKHD_FLAG_IN_PREVIEW).set("creation_time",0).set("modification_time",0).set("track_id",t.id).set("duration",t.duration||0).set("layer",t.layer||0).set("alternate_group",0).set("volume",1).set("matrix",[0,0,0,0,0,0,0,0,0]).set("width",t.width<<16).set("height",t.height<<16);var r=i.add("mdia");r.add("mdhd").set("creation_time",0).set("modification_time",0).set("timescale",t.timescale||1).set("duration",t.media_duration||0).set("language",t.language||"und"),r.add("hdlr").set("handler",t.hdlr||"vide").set("name",t.name||"Track created with MP4Box.js"),r.add("elng").set("extended_language",t.language||"fr-FR");var s=r.add("minf");if(void 0!==c[t.type+"SampleEntry"]){var a=new c[t.type+"SampleEntry"];a.data_reference_index=1;var o="";for(var l in c.sampleEntryCodes)for(var d=c.sampleEntryCodes[l],h=0;h<d.length;h++)if(d.indexOf(t.type)>-1){o=l;break}switch(o){case"Visual":if(s.add("vmhd").set("graphicsmode",0).set("opcolor",[0,0,0]),a.set("width",t.width).set("height",t.height).set("horizresolution",72<<16).set("vertresolution",72<<16).set("frame_count",1).set("compressorname",t.type+" Compressor").set("depth",24),t.avcDecoderConfigRecord){var u=new c.avcCBox,p=new n(t.avcDecoderConfigRecord);u.parse(p),a.addBox(u)}break;case"Audio":s.add("smhd").set("balance",t.balance||0),a.set("channel_count",t.channel_count||2).set("samplesize",t.samplesize||16).set("samplerate",t.samplerate||65536);break;case"Hint":s.add("hmhd");break;case"Subtitle":if(s.add("sthd"),"stpp"===t.type)a.set("namespace",t.namespace||"nonamespace").set("schema_location",t.schema_location||"").set("auxiliary_mime_types",t.auxiliary_mime_types||"");break;default:s.add("nmhd")}t.description&&a.addBox(t.description),t.description_boxes&&t.description_boxes.forEach((function(e){a.addBox(e)})),s.add("dinf").add("dref").addEntry((new c["url Box"]).set("flags",1));var f=s.add("stbl");return f.add("stsd").addEntry(a),f.add("stts").set("sample_counts",[]).set("sample_deltas",[]),f.add("stsc").set("first_chunk",[]).set("samples_per_chunk",[]).set("sample_description_index",[]),f.add("stco").set("chunk_offsets",[]),f.add("stsz").set("sample_sizes",[]),this.moov.mvex.add("trex").set("track_id",t.id).set("default_sample_description_index",t.default_sample_description_index||1).set("default_sample_duration",t.default_sample_duration||0).set("default_sample_size",t.default_sample_size||0).set("default_sample_flags",t.default_sample_flags||0),this.buildTrakSampleLists(i),t.id}},c.Box.prototype.computeSize=function(e){var t=e||new o;t.endianness=o.BIG_ENDIAN,this.write(t)},f.prototype.addSample=function(e,t,i){var r=i||{},s={},a=this.getTrackById(e);if(null!==a){s.number=a.samples.length,s.track_id=a.tkhd.track_id,s.timescale=a.mdia.mdhd.timescale,s.description_index=r.sample_description_index?r.sample_description_index-1:0,s.description=a.mdia.minf.stbl.stsd.entries[s.description_index],s.data=t,s.size=t.byteLength,s.alreadyRead=s.size,s.duration=r.duration||1,s.cts=r.cts||0,s.dts=r.dts||0,s.is_sync=r.is_sync||!1,s.is_leading=r.is_leading||0,s.depends_on=r.depends_on||0,s.is_depended_on=r.is_depended_on||0,s.has_redundancy=r.has_redundancy||0,s.degradation_priority=r.degradation_priority||0,s.offset=0,s.subsamples=r.subsamples,a.samples.push(s),a.samples_size+=s.size,a.samples_duration+=s.duration,a.first_dts||(a.first_dts=r.dts),this.processSamples();var n=this.createSingleSampleMoof(s);return this.addBox(n),n.computeSize(),n.trafs[0].truns[0].data_offset=n.size+8,this.add("mdat").data=new Uint8Array(t),s}},f.prototype.createSingleSampleMoof=function(e){var t=0;t=e.is_sync?1<<25:65536;var i=new c.moofBox;i.add("mfhd").set("sequence_number",this.nextMoofNumber),this.nextMoofNumber++;var r=i.add("traf"),s=this.getTrackById(e.track_id);return r.add("tfhd").set("track_id",e.track_id).set("flags",c.TFHD_FLAG_DEFAULT_BASE_IS_MOOF),r.add("tfdt").set("baseMediaDecodeTime",e.dts-(s.first_dts||0)),r.add("trun").set("flags",c.TRUN_FLAGS_DATA_OFFSET|c.TRUN_FLAGS_DURATION|c.TRUN_FLAGS_SIZE|c.TRUN_FLAGS_FLAGS|c.TRUN_FLAGS_CTS_OFFSET).set("data_offset",0).set("first_sample_flags",0).set("sample_count",1).set("sample_duration",[e.duration]).set("sample_size",[e.size]).set("sample_flags",[t]).set("sample_composition_time_offset",[e.cts-e.dts]),i},f.prototype.lastMoofIndex=0,f.prototype.samplesDataSize=0,f.prototype.resetTables=function(){var e,t,i,r,s,a;for(this.initial_duration=this.moov.mvhd.duration,this.moov.mvhd.duration=0,e=0;e<this.moov.traks.length;e++){(t=this.moov.traks[e]).tkhd.duration=0,t.mdia.mdhd.duration=0,(t.mdia.minf.stbl.stco||t.mdia.minf.stbl.co64).chunk_offsets=[],(i=t.mdia.minf.stbl.stsc).first_chunk=[],i.samples_per_chunk=[],i.sample_description_index=[],(t.mdia.minf.stbl.stsz||t.mdia.minf.stbl.stz2).sample_sizes=[],(r=t.mdia.minf.stbl.stts).sample_counts=[],r.sample_deltas=[],(s=t.mdia.minf.stbl.ctts)&&(s.sample_counts=[],s.sample_offsets=[]),a=t.mdia.minf.stbl.stss;var n=t.mdia.minf.stbl.boxes.indexOf(a);-1!=n&&(t.mdia.minf.stbl.boxes[n]=null)}},f.initSampleGroups=function(e,t,i,r,s){var a,n,o,l;function d(e,t,i){this.grouping_type=e,this.grouping_type_parameter=t,this.sbgp=i,this.last_sample_in_run=-1,this.entry_index=-1}for(t&&(t.sample_groups_info=[]),e.sample_groups_info||(e.sample_groups_info=[]),n=0;n<i.length;n++){for(l=i[n].grouping_type+"/"+i[n].grouping_type_parameter,o=new d(i[n].grouping_type,i[n].grouping_type_parameter,i[n]),t&&(t.sample_groups_info[l]=o),e.sample_groups_info[l]||(e.sample_groups_info[l]=o),a=0;a<r.length;a++)r[a].grouping_type===i[n].grouping_type&&(o.description=r[a],o.description.used=!0);if(s)for(a=0;a<s.length;a++)s[a].grouping_type===i[n].grouping_type&&(o.fragment_description=s[a],o.fragment_description.used=!0,o.is_fragment=!0)}if(t){if(s)for(n=0;n<s.length;n++)!s[n].used&&s[n].version>=2&&(l=s[n].grouping_type+"/0",(o=new d(s[n].grouping_type,0)).is_fragment=!0,t.sample_groups_info[l]||(t.sample_groups_info[l]=o))}else for(n=0;n<r.length;n++)!r[n].used&&r[n].version>=2&&(l=r[n].grouping_type+"/0",o=new d(r[n].grouping_type,0),e.sample_groups_info[l]||(e.sample_groups_info[l]=o))},f.setSampleGroupProperties=function(e,t,i,r){var s,a;for(s in t.sample_groups=[],r){var n;if(t.sample_groups[s]={},t.sample_groups[s].grouping_type=r[s].grouping_type,t.sample_groups[s].grouping_type_parameter=r[s].grouping_type_parameter,i>=r[s].last_sample_in_run&&(r[s].last_sample_in_run<0&&(r[s].last_sample_in_run=0),r[s].entry_index++,r[s].entry_index<=r[s].sbgp.entries.length-1&&(r[s].last_sample_in_run+=r[s].sbgp.entries[r[s].entry_index].sample_count)),r[s].entry_index<=r[s].sbgp.entries.length-1?t.sample_groups[s].group_description_index=r[s].sbgp.entries[r[s].entry_index].group_description_index:t.sample_groups[s].group_description_index=-1,0!==t.sample_groups[s].group_description_index)n=r[s].fragment_description?r[s].fragment_description:r[s].description,t.sample_groups[s].group_description_index>0?(a=t.sample_groups[s].group_description_index>65535?(t.sample_groups[s].group_description_index>>16)-1:t.sample_groups[s].group_description_index-1,n&&a>=0&&(t.sample_groups[s].description=n.entries[a])):n&&n.version>=2&&n.default_group_description_index>0&&(t.sample_groups[s].description=n.entries[n.default_group_description_index-1])}},f.process_sdtp=function(e,t,i){t&&(e?(t.is_leading=e.is_leading[i],t.depends_on=e.sample_depends_on[i],t.is_depended_on=e.sample_is_depended_on[i],t.has_redundancy=e.sample_has_redundancy[i]):(t.is_leading=0,t.depends_on=0,t.is_depended_on=0,t.has_redundancy=0))},f.prototype.buildSampleLists=function(){var e,t;for(e=0;e<this.moov.traks.length;e++)t=this.moov.traks[e],this.buildTrakSampleLists(t)},f.prototype.buildTrakSampleLists=function(e){var t,i,r,s,a,n,o,l,d,h,c,u,p,y,m,g,A,v,b,_,w,E,S,T;if(e.samples=[],e.samples_duration=0,e.samples_size=0,i=e.mdia.minf.stbl.stco||e.mdia.minf.stbl.co64,r=e.mdia.minf.stbl.stsc,s=e.mdia.minf.stbl.stsz||e.mdia.minf.stbl.stz2,a=e.mdia.minf.stbl.stts,n=e.mdia.minf.stbl.ctts,o=e.mdia.minf.stbl.stss,l=e.mdia.minf.stbl.stsd,d=e.mdia.minf.stbl.subs,u=e.mdia.minf.stbl.stdp,h=e.mdia.minf.stbl.sbgps,c=e.mdia.minf.stbl.sgpds,v=-1,b=-1,_=-1,w=-1,E=0,S=0,T=0,f.initSampleGroups(e,null,h,c),void 0!==s){for(t=0;t<s.sample_sizes.length;t++){var k={};k.number=t,k.track_id=e.tkhd.track_id,k.timescale=e.mdia.mdhd.timescale,k.alreadyRead=0,e.samples[t]=k,k.size=s.sample_sizes[t],e.samples_size+=k.size,0===t?(y=1,p=0,k.chunk_index=y,k.chunk_run_index=p,A=r.samples_per_chunk[p],g=0,m=p+1<r.first_chunk.length?r.first_chunk[p+1]-1:1/0):t<A?(k.chunk_index=y,k.chunk_run_index=p):(y++,k.chunk_index=y,g=0,y<=m||(m=++p+1<r.first_chunk.length?r.first_chunk[p+1]-1:1/0),k.chunk_run_index=p,A+=r.samples_per_chunk[p]),k.description_index=r.sample_description_index[k.chunk_run_index]-1,k.description=l.entries[k.description_index],k.offset=i.chunk_offsets[k.chunk_index-1]+g,g+=k.size,t>v&&(b++,v<0&&(v=0),v+=a.sample_counts[b]),t>0?(e.samples[t-1].duration=a.sample_deltas[b],e.samples_duration+=e.samples[t-1].duration,k.dts=e.samples[t-1].dts+e.samples[t-1].duration):k.dts=0,n?(t>=_&&(w++,_<0&&(_=0),_+=n.sample_counts[w]),k.cts=e.samples[t].dts+n.sample_offsets[w]):k.cts=k.dts,o?(t==o.sample_numbers[E]-1?(k.is_sync=!0,E++):(k.is_sync=!1,k.degradation_priority=0),d&&d.entries[S].sample_delta+T==t+1&&(k.subsamples=d.entries[S].subsamples,T+=d.entries[S].sample_delta,S++)):k.is_sync=!0,f.process_sdtp(e.mdia.minf.stbl.sdtp,k,k.number),k.degradation_priority=u?u.priority[t]:0,d&&d.entries[S].sample_delta+T==t&&(k.subsamples=d.entries[S].subsamples,T+=d.entries[S].sample_delta),(h.length>0||c.length>0)&&f.setSampleGroupProperties(e,k,t,e.sample_groups_info)}t>0&&(e.samples[t-1].duration=Math.max(e.mdia.mdhd.duration-e.samples[t-1].dts,0),e.samples_duration+=e.samples[t-1].duration)}},f.prototype.updateSampleLists=function(){var e,t,i,r,s,a,n,o,l,d,h,u,p,y,m;if(void 0!==this.moov)for(;this.lastMoofIndex<this.moofs.length;)if(l=this.moofs[this.lastMoofIndex],this.lastMoofIndex++,"moof"==l.type)for(d=l,e=0;e<d.trafs.length;e++){for(h=d.trafs[e],u=this.getTrackById(h.tfhd.track_id),p=this.getTrexById(h.tfhd.track_id),r=h.tfhd.flags&c.TFHD_FLAG_SAMPLE_DESC?h.tfhd.default_sample_description_index:p?p.default_sample_description_index:1,s=h.tfhd.flags&c.TFHD_FLAG_SAMPLE_DUR?h.tfhd.default_sample_duration:p?p.default_sample_duration:0,a=h.tfhd.flags&c.TFHD_FLAG_SAMPLE_SIZE?h.tfhd.default_sample_size:p?p.default_sample_size:0,n=h.tfhd.flags&c.TFHD_FLAG_SAMPLE_FLAGS?h.tfhd.default_sample_flags:p?p.default_sample_flags:0,h.sample_number=0,h.sbgps.length>0&&f.initSampleGroups(u,h,h.sbgps,u.mdia.minf.stbl.sgpds,h.sgpds),t=0;t<h.truns.length;t++){var g=h.truns[t];for(i=0;i<g.sample_count;i++){(y={}).moof_number=this.lastMoofIndex,y.number_in_traf=h.sample_number,h.sample_number++,y.number=u.samples.length,h.first_sample_index=u.samples.length,u.samples.push(y),y.track_id=u.tkhd.track_id,y.timescale=u.mdia.mdhd.timescale,y.description_index=r-1,y.description=u.mdia.minf.stbl.stsd.entries[y.description_index],y.size=a,g.flags&c.TRUN_FLAGS_SIZE&&(y.size=g.sample_size[i]),u.samples_size+=y.size,y.duration=s,g.flags&c.TRUN_FLAGS_DURATION&&(y.duration=g.sample_duration[i]),u.samples_duration+=y.duration,u.first_traf_merged||i>0?y.dts=u.samples[u.samples.length-2].dts+u.samples[u.samples.length-2].duration:(h.tfdt?y.dts=h.tfdt.baseMediaDecodeTime:y.dts=0,u.first_traf_merged=!0),y.cts=y.dts,g.flags&c.TRUN_FLAGS_CTS_OFFSET&&(y.cts=y.dts+g.sample_composition_time_offset[i]),m=n,g.flags&c.TRUN_FLAGS_FLAGS?m=g.sample_flags[i]:0===i&&g.flags&c.TRUN_FLAGS_FIRST_FLAG&&(m=g.first_sample_flags),y.is_sync=!(m>>16&1),y.is_leading=m>>26&3,y.depends_on=m>>24&3,y.is_depended_on=m>>22&3,y.has_redundancy=m>>20&3,y.degradation_priority=65535&m;var A=!!(h.tfhd.flags&c.TFHD_FLAG_BASE_DATA_OFFSET),v=!!(h.tfhd.flags&c.TFHD_FLAG_DEFAULT_BASE_IS_MOOF),b=!!(g.flags&c.TRUN_FLAGS_DATA_OFFSET),_=0;_=A?h.tfhd.base_data_offset:v||0===t?d.start:o,y.offset=0===t&&0===i?b?_+g.data_offset:_:o,o=y.offset+y.size,(h.sbgps.length>0||h.sgpds.length>0||u.mdia.minf.stbl.sbgps.length>0||u.mdia.minf.stbl.sgpds.length>0)&&f.setSampleGroupProperties(u,y,y.number_in_traf,h.sample_groups_info)}}if(h.subs){u.has_fragment_subsamples=!0;var w=h.first_sample_index;for(t=0;t<h.subs.entries.length;t++)w+=h.subs.entries[t].sample_delta,(y=u.samples[w-1]).subsamples=h.subs.entries[t].subsamples}}},f.prototype.getSample=function(e,t){var i,r=e.samples[t];if(!this.moov)return null;if(r.data){if(r.alreadyRead==r.size)return r}else r.data=new Uint8Array(r.size),r.alreadyRead=0,this.samplesDataSize+=r.size,a.debug("ISOFile","Allocating sample #"+t+" on track #"+e.tkhd.track_id+" of size "+r.size+" (total: "+this.samplesDataSize+")");for(;;){var s=this.stream.findPosition(!0,r.offset+r.alreadyRead,!1);if(!(s>-1))return null;var n=(i=this.stream.buffers[s]).byteLength-(r.offset+r.alreadyRead-i.fileStart);if(r.size-r.alreadyRead<=n)return a.debug("ISOFile","Getting sample #"+t+" data (alreadyRead: "+r.alreadyRead+" offset: "+(r.offset+r.alreadyRead-i.fileStart)+" read size: "+(r.size-r.alreadyRead)+" full size: "+r.size+")"),o.memcpy(r.data.buffer,r.alreadyRead,i,r.offset+r.alreadyRead-i.fileStart,r.size-r.alreadyRead),i.usedBytes+=r.size-r.alreadyRead,this.stream.logBufferLevel(),r.alreadyRead=r.size,r;if(0===n)return null;a.debug("ISOFile","Getting sample #"+t+" partial data (alreadyRead: "+r.alreadyRead+" offset: "+(r.offset+r.alreadyRead-i.fileStart)+" read size: "+n+" full size: "+r.size+")"),o.memcpy(r.data.buffer,r.alreadyRead,i,r.offset+r.alreadyRead-i.fileStart,n),r.alreadyRead+=n,i.usedBytes+=n,this.stream.logBufferLevel()}},f.prototype.releaseSample=function(e,t){var i=e.samples[t];return i.data?(this.samplesDataSize-=i.size,i.data=null,i.alreadyRead=0,i.size):0},f.prototype.getAllocatedSampleDataSize=function(){return this.samplesDataSize},f.prototype.getCodecs=function(){var e,t="";for(e=0;e<this.moov.traks.length;e++){e>0&&(t+=","),t+=this.moov.traks[e].mdia.minf.stbl.stsd.entries[0].getCodec()}return t},f.prototype.getTrexById=function(e){var t;if(!this.moov||!this.moov.mvex)return null;for(t=0;t<this.moov.mvex.trexs.length;t++){var i=this.moov.mvex.trexs[t];if(i.track_id==e)return i}return null},f.prototype.getTrackById=function(e){if(void 0===this.moov)return null;for(var t=0;t<this.moov.traks.length;t++){var i=this.moov.traks[t];if(i.tkhd.track_id==e)return i}return null},f.prototype.items=[],f.prototype.itemsDataSize=0,f.prototype.flattenItemInfo=function(){var e,t,i,r=this.items,s=this.meta;if(null!=s&&void 0!==s.hdlr&&void 0!==s.iinf){for(e=0;e<s.iinf.item_infos.length;e++)(i={}).id=s.iinf.item_infos[e].item_ID,r[i.id]=i,i.ref_to=[],i.name=s.iinf.item_infos[e].item_name,s.iinf.item_infos[e].protection_index>0&&(i.protection=s.ipro.protections[s.iinf.item_infos[e].protection_index-1]),s.iinf.item_infos[e].item_type?i.type=s.iinf.item_infos[e].item_type:i.type="mime",i.content_type=s.iinf.item_infos[e].content_type,i.content_encoding=s.iinf.item_infos[e].content_encoding;if(s.iloc)for(e=0;e<s.iloc.items.length;e++){var n=s.iloc.items[e];switch(i=r[n.item_ID],0!==n.data_reference_index&&(a.warn("Item storage with reference to other files: not supported"),i.source=s.dinf.boxes[n.data_reference_index-1]),n.construction_method){case 0:break;case 1:case 2:a.warn("Item storage with construction_method : not supported")}for(i.extents=[],i.size=0,t=0;t<n.extents.length;t++)i.extents[t]={},i.extents[t].offset=n.extents[t].extent_offset+n.base_offset,i.extents[t].length=n.extents[t].extent_length,i.extents[t].alreadyRead=0,i.size+=i.extents[t].length}if(s.pitm&&(r[s.pitm.item_id].primary=!0),s.iref)for(e=0;e<s.iref.references.length;e++){var o=s.iref.references[e];for(t=0;t<o.references.length;t++)r[o.from_item_ID].ref_to.push({type:o.type,id:o.references[t]})}if(s.iprp)for(var l=0;l<s.iprp.ipmas.length;l++){var d=s.iprp.ipmas[l];for(e=0;e<d.associations.length;e++){var h=d.associations[e];for(void 0===(i=r[h.id]).properties&&(i.properties={},i.properties.boxes=[]),t=0;t<h.props.length;t++){var c=h.props[t];if(c.property_index>0&&c.property_index-1<s.iprp.ipco.boxes.length){var u=s.iprp.ipco.boxes[c.property_index-1];i.properties[u.type]=u,i.properties.boxes.push(u)}}}}}},f.prototype.getItem=function(e){var t,i;if(!this.meta)return null;if(!(i=this.items[e]).data&&i.size)i.data=new Uint8Array(i.size),i.alreadyRead=0,this.itemsDataSize+=i.size,a.debug("ISOFile","Allocating item #"+e+" of size "+i.size+" (total: "+this.itemsDataSize+")");else if(i.alreadyRead===i.size)return i;for(var r=0;r<i.extents.length;r++){var s=i.extents[r];if(s.alreadyRead!==s.length){var n=this.stream.findPosition(!0,s.offset+s.alreadyRead,!1);if(!(n>-1))return null;var l=(t=this.stream.buffers[n]).byteLength-(s.offset+s.alreadyRead-t.fileStart);if(!(s.length-s.alreadyRead<=l))return a.debug("ISOFile","Getting item #"+e+" extent #"+r+" partial data (alreadyRead: "+s.alreadyRead+" offset: "+(s.offset+s.alreadyRead-t.fileStart)+" read size: "+l+" full extent size: "+s.length+" full item size: "+i.size+")"),o.memcpy(i.data.buffer,i.alreadyRead,t,s.offset+s.alreadyRead-t.fileStart,l),s.alreadyRead+=l,i.alreadyRead+=l,t.usedBytes+=l,this.stream.logBufferLevel(),null;a.debug("ISOFile","Getting item #"+e+" extent #"+r+" data (alreadyRead: "+s.alreadyRead+" offset: "+(s.offset+s.alreadyRead-t.fileStart)+" read size: "+(s.length-s.alreadyRead)+" full extent size: "+s.length+" full item size: "+i.size+")"),o.memcpy(i.data.buffer,i.alreadyRead,t,s.offset+s.alreadyRead-t.fileStart,s.length-s.alreadyRead),t.usedBytes+=s.length-s.alreadyRead,this.stream.logBufferLevel(),i.alreadyRead+=s.length-s.alreadyRead,s.alreadyRead=s.length}}return i.alreadyRead===i.size?i:null},f.prototype.releaseItem=function(e){var t=this.items[e];if(t.data){this.itemsDataSize-=t.size,t.data=null,t.alreadyRead=0;for(var i=0;i<t.extents.length;i++){t.extents[i].alreadyRead=0}return t.size}return 0},f.prototype.processItems=function(e){for(var t in this.items){var i=this.items[t];this.getItem(i.id),e&&!i.sent&&(e(i),i.sent=!0,i.data=null)}},f.prototype.hasItem=function(e){for(var t in this.items){var i=this.items[t];if(i.name===e)return i.id}return-1},f.prototype.getMetaHandler=function(){return this.meta?this.meta.hdlr.handler:null},f.prototype.getPrimaryItem=function(){return this.meta&&this.meta.pitm?this.getItem(this.meta.pitm.item_id):null},f.prototype.itemToFragmentedTrackFile=function(e){var t=e||{},i=null;if(null==(i=t.itemId?this.getItem(t.itemId):this.getPrimaryItem()))return null;var r=new f;r.discardMdatData=!1;var s={type:i.type,description_boxes:i.properties.boxes};i.properties.ispe&&(s.width=i.properties.ispe.image_width,s.height=i.properties.ispe.image_height);var a=r.addTrack(s);return a?(r.addSample(a,i.data),r):null},f.prototype.write=function(e){for(var t=0;t<this.boxes.length;t++)this.boxes[t].write(e)},f.prototype.createFragment=function(e,t,i){var r=this.getTrackById(e),s=this.getSample(r,t);if(null==s)return s=r.samples[t],this.nextSeekPosition?this.nextSeekPosition=Math.min(s.offset+s.alreadyRead,this.nextSeekPosition):this.nextSeekPosition=r.samples[t].offset+s.alreadyRead,null;var n=i||new o;n.endianness=o.BIG_ENDIAN;var l=this.createSingleSampleMoof(s);l.write(n),l.trafs[0].truns[0].data_offset=l.size+8,a.debug("MP4Box","Adjusting data_offset with new value "+l.trafs[0].truns[0].data_offset),n.adjustUint32(l.trafs[0].truns[0].data_offset_position,l.trafs[0].truns[0].data_offset);var d=new c.mdatBox;return d.data=s.data,d.write(n),n},f.writeInitializationSegment=function(e,t,i,r){var s;a.debug("ISOFile","Generating initialization segment");var n=new o;n.endianness=o.BIG_ENDIAN,e.write(n);var l=t.add("mvex");for(i&&l.add("mehd").set("fragment_duration",i),s=0;s<t.traks.length;s++)l.add("trex").set("track_id",t.traks[s].tkhd.track_id).set("default_sample_description_index",1).set("default_sample_duration",r).set("default_sample_size",0).set("default_sample_flags",65536);return t.write(n),n.buffer},f.prototype.save=function(e){var t=new o;t.endianness=o.BIG_ENDIAN,this.write(t),t.save(e)},f.prototype.getBuffer=function(){var e=new o;return e.endianness=o.BIG_ENDIAN,this.write(e),e.buffer},f.prototype.initializeSegmentation=function(){var e,t,i,r;for(null===this.onSegment&&a.warn("MP4Box","No segmentation callback set!"),this.isFragmentationInitialized||(this.isFragmentationInitialized=!0,this.nextMoofNumber=0,this.resetTables()),t=[],e=0;e<this.fragmentedTracks.length;e++){var s=new c.moovBox;s.mvhd=this.moov.mvhd,s.boxes.push(s.mvhd),i=this.getTrackById(this.fragmentedTracks[e].id),s.boxes.push(i),s.traks.push(i),(r={}).id=i.tkhd.track_id,r.user=this.fragmentedTracks[e].user,r.buffer=f.writeInitializationSegment(this.ftyp,s,this.moov.mvex&&this.moov.mvex.mehd?this.moov.mvex.mehd.fragment_duration:void 0,this.moov.traks[e].samples.length>0?this.moov.traks[e].samples[0].duration:0),t.push(r)}return t},c.Box.prototype.printHeader=function(e){this.size+=8,this.size>l&&(this.size+=8),"uuid"===this.type&&(this.size+=16),e.log(e.indent+"size:"+this.size),e.log(e.indent+"type:"+this.type)},c.FullBox.prototype.printHeader=function(e){this.size+=4,c.Box.prototype.printHeader.call(this,e),e.log(e.indent+"version:"+this.version),e.log(e.indent+"flags:"+this.flags)},c.Box.prototype.print=function(e){this.printHeader(e)},c.ContainerBox.prototype.print=function(e){this.printHeader(e);for(var t=0;t<this.boxes.length;t++)if(this.boxes[t]){var i=e.indent;e.indent+=" ",this.boxes[t].print(e),e.indent=i}},f.prototype.print=function(e){e.indent="";for(var t=0;t<this.boxes.length;t++)this.boxes[t]&&this.boxes[t].print(e)},c.mvhdBox.prototype.print=function(e){c.FullBox.prototype.printHeader.call(this,e),e.log(e.indent+"creation_time: "+this.creation_time),e.log(e.indent+"modification_time: "+this.modification_time),e.log(e.indent+"timescale: "+this.timescale),e.log(e.indent+"duration: "+this.duration),e.log(e.indent+"rate: "+this.rate),e.log(e.indent+"volume: "+(this.volume>>8)),e.log(e.indent+"matrix: "+this.matrix.join(", ")),e.log(e.indent+"next_track_id: "+this.next_track_id)},c.tkhdBox.prototype.print=function(e){c.FullBox.prototype.printHeader.call(this,e),e.log(e.indent+"creation_time: "+this.creation_time),e.log(e.indent+"modification_time: "+this.modification_time),e.log(e.indent+"track_id: "+this.track_id),e.log(e.indent+"duration: "+this.duration),e.log(e.indent+"volume: "+(this.volume>>8)),e.log(e.indent+"matrix: "+this.matrix.join(", ")),e.log(e.indent+"layer: "+this.layer),e.log(e.indent+"alternate_group: "+this.alternate_group),e.log(e.indent+"width: "+this.width),e.log(e.indent+"height: "+this.height)};var y={createFile:function(e,t){var i=void 0===e||e,r=new f(t);return r.discardMdatData=!i,r}};t.createFile=y.createFile}));function ql(e){return e.reduce(((e,t)=>256*e+t))}function Yl(e){const t=[101,103,119,99],i=e.length-28,r=e.slice(i,i+t.length);return t.every(((e,t)=>e===r[t]))}Kl.Log,Kl.MP4BoxStream,Kl.DataStream,Kl.MultiBufferStream,Kl.MPEG4DescriptorParser,Kl.BoxParser,Kl.XMLSubtitlein4Parser,Kl.Textin4Parser,Kl.ISOFile,Kl.createFile;class Ql{constructor(){this.s=null,this.a=null,this.l=0,this.c=0,this.u=1/0,this.A=!1,this.d=!1,this.r=4194304,this.n=new Uint8Array([30,158,90,33,244,57,83,165,2,70,35,87,215,231,226,108]),this.t=this.n.slice().reverse()}destroy(){this.s=null,this.a=null,this.l=0,this.c=0,this.u=1/0,this.A=!1,this.d=!1,this.r=4194304,this.n=null,this.t=null}transport(e){if(!this.s&&this.l>50)return e;if(this.l++,this.d)return e;const t=new Uint8Array(e);if(this.A){if(!(this.c<this.u))return this.a&&this.s?(this.a.set(t,this.r),this.s.parse(null,this.r,t.byteLength),this.a.slice(this.r,this.r+t.byteLength)):(console.error("video_error_2"),this.d=!0,e);Yl(t)&&this.c++}else{const i=function(e,t){const i=function(e,t){for(let i=0;i<e.byteLength-t.length;i++)for(let r=0;r<t.length&&e[i+r]===t[r];r++)if(r===t.length-1)return i;return null}(e,t);if(i){const t=ql(e.slice(i+16,i+16+8));return[t,ql(e.slice(i+24,i+24+8)),function(e){return e.map((e=>~e))}(e.slice(i+32,i+32+t))]}return null}(t,this.t);if(!i)return e;const r=function(e){try{if("object"!=typeof WebAssembly||"function"!=typeof WebAssembly.instantiate)throw null;{const e=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(!(e instanceof WebAssembly.Module&&new WebAssembly.Instance(e)instanceof WebAssembly.Instance))throw null}}catch(e){return new Error("video_error_4")}let t;try{t={env:{__handle_stack_overflow:()=>e(new Error("video_error_1")),memory:new WebAssembly.Memory({initial:256,maximum:256})}}}catch(e){return new Error("video_error_5")}return t}(e);if(r instanceof Error)return console.error(r.message),this.d=!0,e;this.A=!0,this.u=i[1],Yl(t)&&this.c++,WebAssembly.instantiate(i[2],r).then((e=>{if(!function(e){return"function"==typeof e.parse&&"object"==typeof e.memory}(e.instance.exports))return this.d=!0,void console.error("video_error_3");this.s=e.instance.exports,this.a=new Uint8Array(this.s.memory.buffer)})).catch((e=>{this.d=!0,console.error("video_error_6")}))}return e}}class Xl extends Ul{constructor(e){super(e),this.TAG_NAME="Fmp4Loader",this.player=e,this.mp4Box=Kl.createFile(),this.tempFmp4List=[],this.offset=0,this.videoTrackId=null,this.audioTrackId=null,this.isHevc=!1,this.transportDescarmber=null,this.player._opt.isFmp4Private&&(this.transportDescarmber=new Ql),this._listenMp4Box(),e.debug.log(this.TAG_NAME,"init")}destroy(){this.mp4Box&&(this.mp4Box.flush(),this.mp4Box=null),this.transportDescarmber&&(this.transportDescarmber.destroy(),this.transportDescarmber=null),this.tempFmp4List=[],this.offset=0,this.videoTrackId=null,this.audioTrackId=null,this.isHevc=!1,this.player.debug.log(this.TAG_NAME,"destroy")}_listenMp4Box(){this.mp4Box.onReady=this.onReady.bind(this),this.mp4Box.onError=this.onError.bind(this),this.mp4Box.onSamples=this.onSamples.bind(this)}onReady(e){this.player.debug.log(this.TAG_NAME,"onReady",e);const t=e.videoTracks[0],i=e.audioTracks[0];if(t){this.videoTrackId=t.id;const e=this.getSeqHeader(t);e&&(this.player.debug.log(this.TAG_NAME,"seqHeader",e),this._doDecodeByFmp4(e,Ne,0,!0,0)),this.mp4Box.setExtractionOptions(t.id)}if(i&&this.player._opt.hasAudio){this.audioTrackId=i.id;const e=i.audio||{},t=as.indexOf(e.sample_rate),r=i.codec.replace("mp4a.40.","");this.mp4Box.setExtractionOptions(i.id);const s={profile:parseInt(r,10),sampleRate:t,channel:e.channel_count},a=ts(s);this.player.debug.log(this.TAG_NAME,"aacADTSHeader",a,"config",s),this._doDecodeByFmp4(a,Oe,0,!1,0)}this.mp4Box.start()}onError(e){this.player.debug.error(this.TAG_NAME,"mp4Box onError",e)}onSamples(e,t,i){if(e===this.videoTrackId)for(const e of i){const t=e.data,i=e.is_sync,r=1e3*e.cts/e.timescale;e.duration,e.timescale,this.player.updateStats({vbps:t.byteLength,dts:r}),i&&this.calcIframeIntervalTimestamp(r);let s=null;s=this.isHevc?eo(t,i):Gn(t,i),this._doDecodeByFmp4(s,Ne,r,i,0)}else if(e===this.audioTrackId){if(this.player._opt.hasAudio)for(const e of i){const t=e.data;this.player.updateStats({abps:t.byteLength});const i=1e3*e.cts/e.timescale;e.duration,e.timescale;const r=new Uint8Array(t.byteLength+2);r.set([175,1],0),r.set(t,2),this._doDecodeByFmp4(r,Oe,i,!1,0)}}else this.player.debug.warn(this.TAG_NAME,"onSamples() trackId error",e)}getSeqHeader(e){const t=this.mp4Box.getTrackById(e.id);for(const e of t.mdia.minf.stbl.stsd.entries)if(e.avcC||e.hvcC){const t=new Kl.DataStream(void 0,0,Kl.DataStream.BIG_ENDIAN);let i=[];e.avcC?(e.avcC.write(t),i=[23,0,0,0,0]):(this.isHevc=!0,e.hvcC.write(t),i=[28,0,0,0,0]);const r=new Uint8Array(t.buffer,8),s=new Uint8Array(i.length+r.length);return s.set(i,0),s.set(r,i.length),s}return null}dispatch(e){let t=new Uint8Array(e);"string"!=typeof e?"object"==typeof e?(this.transportDescarmber&&(t=this.transportDescarmber.transport(t)),t.buffer.fileStart=this.offset,this.offset+=t.byteLength,this.mp4Box.appendBuffer(t.buffer)):this.player.debug.warn(this.TAG_NAME,"dispatch()","data is not object",e):this.player.debug.warn(this.TAG_NAME,"dispatch()","data is string",e)}downloadFmp4File(){const e=new Blob(this.tempFmp4List,{type:'video/mp4; codecs="avc1.640028,mp4a.40.2"'}),t=URL.createObjectURL(e),i=document.createElement("a");i.href=t,i.download=vs()+".fmp4",i.click(),URL.revokeObjectURL(t)}}class Jl extends Ul{LOG_NAME="Mpeg4Loader";constructor(e){super(e),this.player=e,this.player.debug.log(this.LOG_NAME,"init")}destroy(){super.destroy(),this.player.debug.log(this.LOG_NAME,"destroy")}}function Zl(...e){if((e=e.filter(Boolean)).length<2)return e[0];const t=new Uint8Array(e.reduce(((e,t)=>e+t.byteLength),0));let i=0;return e.forEach((e=>{t.set(e,i),i+=e.byteLength})),t}class ed extends Ul{constructor(e){super(e),this.player=e,this._pmtId=-1,this._remainingPacketData=null,this._videoPesData=[],this._audioPesData=[],this._gopId=0,this._videoPid=-1,this._audioPid=-1,this._codecType=gt,this._audioCodecType=_t.AAC,this._vps=null,this._sps=null,this._pps=null,this.TAG_NAME="HlsTsLoader",this._isForHls=!0,this.videoTrack=ed.initVideoTrack(),this.audioTrack=ed.initAudioTrack(),this._baseDts=-1,this._baseDtsInited=!1,this._basefps=25,this._baseFpsInterval=null,this._tempSampleTsList=[],this._hasAudio=!1,this._hasVideo=!1,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=!1,this._videoTimestampBreak=!1,this._lastAudioExceptionGapDot=0,this._lastAudioExceptionOverlapDot=0,this._lastAudioExceptionLargeGapDot=0,this._isSendAACSeqHeader=!1,this.workerClearTimeout=null,this.workerUrl=null,this.loopWorker=null,this.tempSampleListInfo={},this._isUseWorker()&&this._initLoopWorker(),this.player.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this.workerUrl&&(URL.revokeObjectURL(this.workerUrl),this.workerUrl=null),this.workerClearTimeout&&(clearTimeout(this.workerClearTimeout),this.workerClearTimeout=null),this.loopWorker&&(this.loopWorker.postMessage({cmd:"destroy"}),this.loopWorker.terminate(),this.loopWorker=null),this._stopDecodeLoopInterval(),this.videoTrack=null,this.audioTrack=null,this.tempSampleListInfo={},this._baseDts=-1,this._baseDtsInited=!1,this._basefps=50,this._hasCalcFps=!1,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=!1,this._videoTimestampBreak=!1,this._lastAudioExceptionGapDot=0,this._lastAudioExceptionOverlapDot=0,this._lastAudioExceptionLargeGapDot=0,this._isForHls=!0,this._isSendAACSeqHeader=!1,this.player.debug.log(this.TAG_NAME,"destroy")}static initVideoTrack(){return{samples:[]}}static initAudioTrack(){return{samples:[]}}static probe(e){return!!e.length&&(71===e[0]&&71===e[188]&&71===e[376])}static _parsePES(e){const t=e[8];if(null==t||e.length<t+9)return;if(1!==(e[0]<<16|e[1]<<8|e[2]))return;const i=(e[4]<<8)+e[5];if(i&&i>e.length-6)return;let r,s;const a=e[7];return 192&a&&(r=536870912*(14&e[9])+4194304*(255&e[10])+16384*(254&e[11])+128*(255&e[12])+(254&e[13])/2,64&a?(s=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2,r-s>54e5&&(r=s)):s=r),{data:e.subarray(9+t),pts:r,dts:s,originalPts:r,originalDts:s}}_demux(e,t=!1,i=!0){t&&(this._pmtId=-1,this.videoTrack=ed.initVideoTrack(),this.audioTrack=ed.initAudioTrack()),!i||t?(this._remainingPacketData=null,this._videoPesData=[],this._audioPesData=[]):(this.videoTrack.samples=[],this.audioTrack.samples=[],this._remainingPacketData&&(e=Zl(this._remainingPacketData,e),this._remainingPacketData=null));let r=e.length;const s=r%188;s&&(this._remainingPacketData=e.subarray(r-s),r-=s);for(let t=0;t<r;t+=188){if(71!==e[t])throw new Error("TS packet did not start with 0x47");const i=!!(64&e[t+1]),r=((31&e[t+1])<<8)+e[t+2];let s;if((48&e[t+3])>>4>1){if(s=t+5+e[t+4],s===t+188)continue}else s=t+4;switch(r){case 0:i&&(s+=e[s]+1),this._pmtId=(31&e[s+10])<<8|e[s+11];break;case this._pmtId:{i&&(s+=e[s]+1);const t=s+3+((15&e[s+1])<<8|e[s+2])-4;for(s+=12+((15&e[s+10])<<8|e[s+11]);s<t;){const t=(31&e[s+1])<<8|e[s+2];switch(e[s]){case 15:this._audioPid=t,this._audioCodecType=_t.AAC;break;case 27:this._videoPid=t,this._codecType=gt;break;case 36:this._videoPid=t,this._codecType=At;break;default:this.player.debug.warn(this.TAG_NAME,`Unsupported stream. type: ${e[s]}, pid: ${t}`)}s+=5+((15&e[s+3])<<8|e[s+4])}}break;case this._videoPid:i&&this._videoPesData.length&&this._parseVideoData(),this._videoPesData.push(e.subarray(s,t+188));break;case this._audioPid:i&&this._audioPesData.length&&this._parseAudioData(),this._audioPesData.push(e.subarray(s,t+188));break;case 17:case 8191:break;default:this.player.debug.warn(this.TAG_NAME,`Unknown pid: ${r}`)}}this._parseVideoData(),this._parseAudioData(),this.audioTrack.formatTimescale=this.videoTrack.formatTimescale=this.videoTrack.timescale=9e4,this.audioTrack.timescale=this.audioTrack.sampleRate||0}demuxAndFix(e,t,i,r){this.player._times.demuxStart||(this.player._times.demuxStart=vs()),this._demux(e,t,i),this._fix(r,t,i)}_parseVideoData(){if(!this._videoPesData.length)return void this.player.debug.log(this.TAG_NAME,"_parseVideoData","no video pes data");const e=ed._parsePES(Zl(...this._videoPesData));if(!e)return void this.player.debug.warn(this.TAG_NAME,"Cannot parse video pes data length",this._videoPesData.length);const t=function(e){const t=e.length;let i=2,r=0;for(;null!==e[i]&&void 0!==e[i]&&1!==e[i];)i++;if(i++,r=i+2,r>=t)return[];const s=[];for(;r<t;)switch(e[r]){case 0:if(0!==e[r-1]){r+=2;break}if(0!==e[r-2]){r++;break}i!==r-2&&s.push(e.subarray(i,r-2));do{r++}while(1!==e[r]&&r<t);i=r+1,r=i+2;break;case 1:if(0!==e[r-1]||0!==e[r-2]){r+=3;break}i!==r-2&&s.push(e.subarray(i,r-2)),i=r+1,r=i+2;break;default:r+=3}return i<t&&s.push(e.subarray(i)),s}(e.data);t?this._createVideoSample(t,e.pts,e.dts):this.player.debug.warn(this.TAG_NAME,"Cannot parse avc units",e),this._videoPesData=[]}_createVideoSample(e,t,i){if(!e.length)return;const r=this._codecType===At,s={isIFrame:!1,type:Ne,isHevc:r,vps:null,sps:null,pps:null,pts:t,dts:i,payload:null};e.forEach((e=>{const t=r?e[0]>>>1&63:31&e[0];switch(t){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!r&&5!==t||r&&5===t)break;s.isIFrame=!0,this._gopId++;break;case 6:case 39:case 40:if(!r&&6!==t||r&&6===t)break;return void function(e,t){const i=e.length;let r=t?2:1,s=0,a=0,n="";for(;255===e[r];)s+=255,r++;for(s+=e[r++];255===e[r];)a+=255,r++;if(a+=e[r++],5===s&&i>r+16)for(let t=0;t<16;t++)n+=e[r].toString(16),r++;e.subarray(r)}(function(e){const t=e.byteLength,i=[];let r=1;for(;r<t-2;)0===e[r]&&0===e[r+1]&&3===e[r+2]?(i.push(r+2),r+=2):r++;if(!i.length)return e;const s=t-i.length,a=new Uint8Array(s);let n=0;for(r=0;r<s;n++,r++)n===i[0]&&(n++,i.shift()),a[r]=e[n];return a}(e),r);case 32:if(!r)break;s.vps||(s.vps=e);break;case 7:case 33:if(!r&&7!==t||r&&7===t)break;s.sps||(s.sps=e);break;case 8:case 34:if(!r&&8!==t||r&&8===t)break;s.pps||(s.pps=e)}if(r&&io(t)||!r&&Vn(t)){const t=Yn(e);if(s.payload){const e=new Uint8Array(s.payload.byteLength+t.byteLength);e.set(s.payload,0),e.set(t,s.payload.byteLength),s.payload=e}else s.payload=t}}));let a=null;r?s.sps&&s.vps&&s.pps&&(a=Zn({vps:s.vps,sps:s.sps,pps:s.pps})):s.sps&&s.pps&&(a=Nn({sps:s.sps,pps:s.pps})),a&&(this.player.debug.log(this.TAG_NAME,"_createVideoSample","seqHeader"),this._doDecodeByHls(a,Ne,Math.round(s.pts/90),!0,0)),s.isIFrame&&this.calcIframeIntervalTimestamp(Math.round(s.dts/90)),this.videoTrack.samples=this.videoTrack.samples.concat(s)}_parseAudioData(){if(!this._audioPesData.length)return;const e=ed._parsePES(Zl(...this._audioPesData));if(e){if(this.player._opt.hasAudio){if(this._audioCodecType===_t.AAC){const t=function(e,t){const i=e.length;let r=0;for(;r+2<i&&(255!==e[r]||240!=(246&e[r+1]));)r++;if(r>=i)return;const s=r,a=[],n=(60&e[r+2])>>>2,o=ss[n];if(!o)throw new Error(`Invalid sampling index: ${n}`);const l=1+((192&e[r+2])>>>6),d=(1&e[r+2])<<2|(192&e[r+3])>>>6;let h,c,u=0;const p=os(o);for(;r+7<i;)if(255===e[r]&&240==(246&e[r+1])){if(c=(3&e[r+3])<<11|e[r+4]<<3|(224&e[r+5])>>5,i-r<c)break;h=2*(1&~e[r+1]),a.push({pts:t+u*p,data:e.subarray(r+7+h,r+c)}),u++,r+=c}else r++;return{skip:s,remaining:r>=i?void 0:e.subarray(r),frames:a,samplingFrequencyIndex:n,sampleRate:o,objectType:l,channelCount:d,originCodec:`mp4a.40.${l}`}}(e.data,e.originalPts);if(t){if(this.audioTrack.codec=t.codec,this.audioTrack.sampleRate=t.sampleRate,this.audioTrack.channelCount=t.channelCount,!this._isSendAACSeqHeader){const e=ts({profile:t.objectType,sampleRate:t.samplingFrequencyIndex,channel:t.channelCount});this._isSendAACSeqHeader=!0,this.player.debug.log(this.TAG_NAME,"aac seq header",`profile: ${t.objectType}, sampleRate:${t.sampleRate},sampleRateIndex: ${t.samplingFrequencyIndex}, channel: ${t.channelCount}`),this._doDecodeByHls(e,Oe,0,!1,0)}if(this._isSendAACSeqHeader){const e=[];t.frames.forEach((t=>{const i=t.pts,r=new Uint8Array(t.data.length+2);r.set([175,1],0),r.set(t.data,2);const s={type:Oe,pts:i,dts:i,payload:r};e.push(s)})),this.audioTrack.samples=this.audioTrack.samples.concat(e)}else this.player.debug.warn(this.TAG_NAME,"aac seq header not send")}else this.player.debug.warn(this.TAG_NAME,"aac parseADTS error")}this._audioPesData=[]}}else this.player.debug.warn(this.TAG_NAME,"Cannot parse audio pes",this._audioPesData)}_fix(e=0,t=!1,i=!0){e=Math.round(9e4*e);const r=this.videoTrack,s=this.audioTrack,a=r.samples,n=s.samples;if(!a.length&&!n.length)return;const o=a[0],l=n[0];let d=0;if(a.length&&n.length&&(d=o.dts-l.pts),this._baseDtsInited||this._calculateBaseDts(),t&&(this._calculateBaseDts(),this._baseDts-=e),!i){this._videoNextDts=d>0?e+d:e,this._audioNextPts=d>0?e:e-d;const t=o?o.dts-this._baseDts-this._videoNextDts:0,i=l?l.pts-this._baseDts-this._audioNextPts:0;Math.abs(t||i)>Qr&&(this._calculateBaseDts(this.audioTrack,this.videoTrack),this._baseDts-=e)}this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(s),this._fixVideo(r);let h=r.samples.concat(s.samples);h=h.map((e=>(e.dts=Math.round(e.dts/90),e.pts=Math.round(e.pts/90),e.cts=e.pts-e.dts,e))).sort(((e,t)=>e.dts-t.dts)),h.forEach((e=>{const t=new Uint8Array(e.payload);delete e.payload,this._isUseWorker()?this.loopWorker.postMessage({...e,payload:t,cmd:"sample"},[t.buffer]):e.type===Ne?this._doDecodeVideo({...e,payload:t}):e.type===Oe&&this._doDecodeAudio({...e,payload:t})})),ka(this._hasCalcFps)&&this._isUseWorker()&&(this._hasCalcFps=!0,this._calcDecodeFps(h))}_isUseWorker(){return!this.player.isUseMSE()&&this.isForHls()}_calculateBaseDts(){const e=this.audioTrack,t=this.videoTrack,i=e.samples,r=t.samples;if(!i.length&&!r.length)return!1;let s=1/0,a=1/0;i.length&&(e.baseDts=s=i[0].pts),r.length&&(t.baseDts=a=r[0].dts),this._baseDts=Math.min(s,a);const n=a-s;return Number.isFinite(n)&&Math.abs(n)>45e3&&this.player.debug.warn(this.TAG_NAME,`large av first frame gap,\n video pts: ${a},\n audio pts: ${s},\n base dts: ${this._baseDts},\n detect is: ${n}`),this._baseDtsInited=!0,!0}_resetBaseDtsWhenStreamBreaked(){if(this._baseDtsInited&&this._videoTimestampBreak&&this._audioTimestampBreak){if(!this._calculateBaseDts(this.audioTrack,this.videoTrack))return;this._baseDts-=Math.min(this._audioNextPts,this._videoNextDts),this._audioLastSample=null,this._videoLastSample=null,this._videoTimestampBreak=!1,this._audioTimestampBreak=!1}}_fixAudio(e){const t=e.samples;t.length&&(t.forEach((e=>{e.pts-=this._baseDts,e.dts=e.pts})),this._doFixAudioInternal(e,t,9e4))}_fixVideo(e){const t=e.samples;if(!t.length)return;if(t.forEach((e=>{e.dts-=this._baseDts,e.pts-=this._baseDts})),void 0===this._videoNextDts){const e=t[0];this._videoNextDts=e.dts}const i=t.length;let r=0;const s=t[0],a=t[1],n=this._videoNextDts-s.dts;let o;Math.abs(n)>45e3&&(s.dts+=n,s.pts+=n,this.player.debug.warn(this.TAG_NAME,`large video gap between chunk,\n next dts is ${this._videoNextDts},\n first dts is ${s.dts},\n next dts is ${a.dts},\n duration is ${n}`),a&&Math.abs(a.dts-s.dts)>Qr&&(this._videoTimestampBreak=!0,t.forEach(((e,t)=>{0!==t&&(e.dts+=n,e.pts+=n)}))));const l=e.samples[0],d=e.samples[i-1];o=1===i?9e3:Math.floor((d.dts-l.dts)/(i-1));for(let s=0;s<i;s++){const a=t[s].dts,n=t[s+1];if(r=s<i-1?n.dts-a:t[s-1]?Math.min(a-t[s-1].dts,o):o,r>Qr||r<0){this._videoTimestampBreak=!0,r=this._audioTimestampBreak?o:Math.max(r,2700);const i=this._audioNextPts||0;n&&n.dts>i&&(r=o),this.player.debug.warn(this.TAG_NAME,`large video gap between frames,\n time is ${a/e.timescale},\n dts is ${a},\n origin dts is ${t[s].originalDts},\n next dts is ${this._videoNextDts},\n sample Duration is ${r} ,\n ref Sample DurationInt is ${o}`)}t[s].duration=r,this._videoNextDts+=r}}_doFixAudioInternal(e,t,i){e.sampleDuration||(e.sampleDuration=os(e.timescale,i));const r=e.sampleDuration;if(void 0===this._audioNextPts){const e=t[0];this._audioNextPts=e.pts}for(let i=0;i<t.length;i++){const s=this._audioNextPts,a=t[i],n=a.pts-s;if(!this._audioTimestampBreak&&n>=3*r&&n<=qr&&!Is()){ns(e.codec,e.channelCount)||t[0].data.subarray();const o=Math.floor(n/r);Math.abs(a.pts-this._lastAudioExceptionGapDot)>Yr&&(this._lastAudioExceptionGapDot=a.pts),this.player.debug.warn(this.TAG_NAME,`audio gap detected,\n pts is ${t.pts},\n originPts is ${t.originalPts},\n count is ${o},\n nextPts is ${s},\n ref sample duration is ${r}`);for(let e=0;e<o;e++)this._audioNextPts+=r,i++;i--}else n<=-3*r&&n>=-9e4?(Math.abs(a.pts-this._lastAudioExceptionOverlapDot)>Yr&&(this._lastAudioExceptionOverlapDot=a.pts,this.player.debug.warn(this.TAG_NAME,`audio overlap detected,\n pts is ${a.pts},\n originPts is ${a.originalPts},\n nextPts is ${s},\n ref sample duration is ${r}`)),t.splice(i,1),i--):(Math.abs(n)>=qr&&(this._audioTimestampBreak=!0,Math.abs(a.pts-this._lastAudioExceptionLargeGapDot)>Yr&&(this._lastAudioExceptionLargeGapDot=a.pts,this.player.debug.warn(this.TAG_NAME,`large audio gap detected,\n time is ${a.pts/1e3}\n pts is ${a.pts},\n originPts is ${a.originalPts},\n nextPts is ${s},\n sample duration is ${n}\n ref sample duration is ${r}`))),a.dts=a.pts=s,this._audioNextPts+=r)}}_calcDecodeFps(e){const t=Aa(e.map((e=>({ts:e.dts||e.pts,type:e.type}))),Ne);t&&(this._basefps=t,this._postMessageToLoopWorker("updateBaseFps",{baseFps:this._basefps}),this.player.debug.log(this.TAG_NAME,`_calcDecodeFps() video fps is ${t}, update base fps is ${this._basefps}`))}_initLoopWorker(){this.player.debug.log(this.TAG_NAME,"_initLoopWorker()");const e=Ia(function(){const e=1,t=2;let i=new class{constructor(){this.baseFps=0,this.fpsInterval=null,this.preLoopTimestamp=null,this.startBpsTime=null,this.allSampleList=[]}destroy(){this._clearInterval(),this.baseFps=0,this.allSampleList=[],this.preLoopTimestamp=null,this.startBpsTime=null}updateBaseFps(e){this.baseFps=e,this._clearInterval(),this._startInterval()}pushSample(e){delete e.cmd,this.allSampleList.push(e)}_startInterval(){const e=Math.ceil(1e3/this.baseFps);this.fpsInterval=setInterval((()=>{let t=(new Date).getTime();this.preLoopTimestamp||(this.preLoopTimestamp=t),this.startBpsTime||(this.startBpsTime=t);const i=t-this.preLoopTimestamp;if(i>2*e&&console.warn(`EasyPro:[TsLoader LoopWorker] loop interval is ${i}ms, more than ${e} * 2ms`),this._loop(),this.preLoopTimestamp=(new Date).getTime(),this.startBpsTime){t-this.startBpsTime>=1e3&&(this._calcSampleList(),this.startBpsTime=t)}}),e)}_clearInterval(){this.fpsInterval&&(clearInterval(this.fpsInterval),this.fpsInterval=null)}_calcSampleList(){const i={buferredDuration:0,allListLength:this.allSampleList.length,audioListLength:0,videoListLength:0};this.allSampleList.forEach((r=>{r.type===t?(i.videoListLength++,r.duration&&(i.buferredDuration+=Math.round(r.duration/90))):r.type===e&&i.audioListLength++})),postMessage({cmd:"sampleListInfo",...i})}_loop(){let i=null;if(this.allSampleList.length)if(i=this.allSampleList.shift(),i.type===t){postMessage({cmd:"decodeVideo",...i},[i.payload.buffer]);let t=this.allSampleList[0];for(;t&&t.type===e;)i=this.allSampleList.shift(),postMessage({cmd:"decodeAudio",...i},[i.payload.buffer]),t=this.allSampleList[0]}else i.type===e&&(postMessage({cmd:"decodeAudio",...i},[i.payload.buffer]),this.allSampleList.length&&this.allSampleList[0].type===t&&(i=this.allSampleList.shift(),postMessage({cmd:"decodeVideo",...i},[i.payload.buffer])))}};self.onmessage=e=>{const t=e.data;switch(t.cmd){case"updateBaseFps":i.updateBaseFps(t.baseFps);break;case"sample":i.pushSample(t);break;case"destroy":i.destroy(),i=null}}}.toString()),t=new Blob([e],{type:"text/javascript"}),i=URL.createObjectURL(t);let r=new Worker(i);this.workerUrl=i,this.workerClearTimeout=setTimeout((()=>{window.URL.revokeObjectURL(this.workerUrl),this.workerUrl=null,this.workerClearTimeout=null}),re),r.onmessage=e=>{const t=e.data;switch(t.cmd){case"decodeVideo":this._doDecodeVideo(t);break;case"decodeAudio":this._doDecodeAudio(t);break;case"sampleListInfo":this.tempSampleListInfo=t}},this.loopWorker=r}_postMessageToLoopWorker(e,t){this._isUseWorker()&&(this.loopWorker?this.loopWorker.postMessage({cmd:e,...t}):this.player.debug.warn(this.TAG_NAME,"loop worker is not init, can not post message"))}_doDecodeAudio(e){const t=new Uint8Array(e.payload);this.player.updateStats({abps:t.byteLength});let i=t;Ta(this.player._opt.m7sCryptoAudio)&&(i=this.cryptoPayloadAudio(t)),this.isForHls()?this._doDecodeByHls(i,Oe,e.dts,!1,0):this._doDecodeByTs(i,Oe,e.dts,!1,0)}_doDecodeVideo(e){const t=new Uint8Array(e.payload);let i=null;i=e.isHevc?eo(t,e.isIFrame):Gn(t,e.isIFrame),this.player.updateStats({dts:e.dts,vbps:i.byteLength});const r=e.pts-e.dts;let s=this.cryptoPayload(i,e.isIFrame);this.isForHls()?this._doDecodeByHls(s,Ne,e.dts,e.isIFrame,r):this._doDecodeByTs(s,Ne,e.dts,e.isIFrame,r)}_stopDecodeLoopInterval(){this._baseFpsInterval&&(clearInterval(this._baseFpsInterval),this._baseFpsInterval=null)}getBuferredDuration(){return this.tempSampleListInfo.buferredDuration||0}getSampleListLength(){return this.tempSampleListInfo.allListLength||0}getSampleAudioListLength(){return this.tempSampleListInfo.audioListLength||0}getSampleVideoListLength(){return this.tempSampleListInfo.videoListLength||0}isForHls(){return this._isForHls}}class td extends ed{constructor(e){super(e),this.player=e,this.TAG_NAME="TsLoader",this.isFirstDispatch=!0,this._isForHls=!1,this.player.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this.isFirstDispatch=!0,this._isForHls=!1}dispatch(e){this.demuxAndFix(e,this.isFirstDispatch,!0,0),this.isFirstDispatch&&(this.isFirstDispatch=!1)}}class id{constructor(e){return new(id.getLoaderFactory(e))(e)}static getLoaderFactory(e){const t=e._opt.demuxType;return t===k?Vl:t===T||e.isWebrtcH265()?Wl:t===R?Hl:t===x?$l:t===L?Xl:t===I?Jl:t===B?td:jl}}const rd=[44100,48e3,32e3,0],sd=[22050,24e3,16e3,0],ad=[11025,12e3,8e3,0],nd=[0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1],od=[0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1],ld=[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1];function dd(e){if(e.length<4)return void console.error("Invalid MP3 packet, header missing!");let t=new Uint8Array(e.buffer),i=null;if(255!==t[0])return void console.error("Invalid MP3 packet, first byte != 0xFF ");let r=t[1]>>>3&3,s=(6&t[1])>>1,a=(240&t[2])>>>4,n=(12&t[2])>>>2,o=3!==(t[3]>>>6&3)?2:1,l=0,d=0;switch(r){case 0:l=ad[n];break;case 2:l=sd[n];break;case 3:l=rd[n]}switch(s){case 1:a<ld.length&&(d=ld[a]);break;case 2:a<od.length&&(d=od[a]);break;case 3:a<nd.length&&(d=nd[a])}return i={bitRate:d,samplingRate:l,channelCount:o,codec:"mp3",originalCodec:"mp3",audioType:"mp3"},i}class hd extends t{constructor(e){super(),this.player=e,this.TAG_NAME="Webcodecs",this.hasInit=!1,this.hasAudioInit=!1,this.isDecodeFirstIIframe=!!ka(e._opt.checkFirstIFrame),this.isInitInfo=!1,this.isAudioInitInfo=!1,this.prevTimestamp=null,this.decodeDiffTimestamp=null,this.prevDts=null,this.decoder=null,this.decoderAudio=null,this.isAAC=!1,this.isWidthOrHeightChanged=!1,this.audioSourceBufferCheckTimeout=null,this.audioSourceNoDataCheckTimeout=null,this.initDecoder(),this.needInitAudio()&&this.initDecoderAudio(),e.debug.log(this.TAG_NAME,"init")}destroy(){this._clearAudioNoDataCheckTimeout(),this._clearAudioSourceBufferCheckTimeout(),this.decoder&&(ka(this.isDecodeStateClosed())&&this.decoder.close(),this.decoder=null),this.decoderAudio&&(ka(this.isAudioDecodeStateClosed())&&this.decoderAudio.close(),this.decoderAudio=null),this.prevTimestamp=null,this.decodeDiffTimestamp=null,this.prevDts=null,this.hasInit=!1,this.isInitInfo=!1,this.isAAC=!1,this.isDecodeFirstIIframe=!1,this.isWidthOrHeightChanged=!1,this.off(),this.player.debug.log(this.TAG_NAME,"destroy")}initDecoder(){const e=this;this.decoder=new VideoDecoder({output(t){e.handleDecode(t)},error(t){e.handleError(t)}})}initDecoderAudio(){const e=this;this.decoderAudio=new AudioDecoder({output(t){e.handleDecodeAudio(t)},error(t){e.handleErrorAudio(t)}})}needInitAudio(){return this.player._opt.hasAudio&&this.player._opt.wcsDecodeAudio}handleDecode(e){this.player.isDestroyedOrClosed()||(this.needInitAudio()&&ka(this.hasAudioInit)?null===this.audioSourceBufferCheckTimeout&&(this.audioSourceBufferCheckTimeout=setTimeout((()=>{this._clearAudioSourceBufferCheckTimeout(),this.player.emit(lt.webcodecsAudioInitTimeout)}),1e3)):this.player.isPlayer()?(this.player.updateStats({dfps:!0}),this.player._times.videoStart||(this.player._times.videoStart=vs(),this.player.handlePlayToRenderTimes()),this.player.video.render({videoFrame:e,ts:e.timestamp}),this.player.handleRender()):this.player.isPlayback()&&(this.player.updateStats({dfps:!0}),ka(this.player.playbackPause)?(this.player.playback.isUseLocalCalculateTime&&this.player.playback.increaseLocalTimestamp(),this.player.playback.isUseFpsRender?this.player.video.pushData({videoFrame:e,ts:e.timestamp}):this.player.video.render$2({videoFrame:e,ts:e.timestamp})):ka(this.player.playback.isPlaybackPauseClearCache)&&this.player.playback.isCacheBeforeDecodeForFpsRender&&this.player.playback.isUseFpsRender&&this.player.video.pushData({videoFrame:e,ts:e.timestamp})))}handleError(e){this.player.debug.error(this.TAG_NAME,"VideoDecoder handleError",e.code,e);const t=e.toString();-1!==t.indexOf(xi)?this.player.emitError(lt.webcodecsUnsupportedConfigurationError,t):-1!==t.indexOf(Li)||-1!==t.indexOf(Ii)||-1!==t.indexOf(Pi)?this.player.emitError(lt.webcodecsDecodeError,t):-1!==t.indexOf(Bi)&&this.player.emitError(lt.webcodecsH265NotSupport,t)}handleDecodeAudio(e){this.player.isPlayer()?this.player.audio.play(e,e.timestamp):this.player.isPlayback()}handleErrorAudio(e){this.player.debug.error(this.TAG_NAME,"AudioDecoder handleError",e.code,e)}decodeVideo(e,t,i,r){if(this.player)if(this.player.isDestroyedOrClosed())this.player.debug&&this.player.debug.warn(this.TAG_NAME,"decodeVideo() player is destroyed");else if(this.hasInit)if(!this.isDecodeFirstIIframe&&i&&(this.isDecodeFirstIIframe=!0),this.isDecodeFirstIIframe){if(this.isDecodeStateClosed())return void this.player.debug.warn(this.TAG_NAME,"VideoDecoder isDecodeStateClosed true");if(i&&0===e[1]){const t=15&e[0];let i={};if(t===gt){i=On(e.slice(5))}else t===At&&(i=Xn(e));const r=this.player.video.videoInfo;r&&r.width&&r.height&&i&&i.codecWidth&&i.codecHeight&&(i.codecWidth!==r.width||i.codecHeight!==r.height)&&(this.player.debug.warn(this.TAG_NAME,`decodeVideo: video width or height is changed,\n old width is ${r.width}, old height is ${r.height},\n new width is ${i.codecWidth}, new height is ${i.codecHeight},\n and emit change event`),this.isWidthOrHeightChanged=!0,this.player.emitError(lt.wcsWidthOrHeightChange,`width ${r.width}->${r.height} height ${i.codecWidth}->${i.codecHeight}`))}if(this.isWidthOrHeightChanged)return void this.player.debug.warn(this.TAG_NAME,"decodeVideo: video width or height is changed, and return");if(Sa(e))return void this.player.debug.log(this.TAG_NAME,"decodeVideo and payload is video sequence header so drop this frame");if(e.byteLength<12)return void this.player.debug.warn(this.TAG_NAME,`decodeVideo and payload is too small , payload length is ${e.byteLength}`);let r=!1,s=(new Date).getTime();this.prevTimestamp||(this.prevTimestamp=s,r=!0);const a=s-this.prevTimestamp;this.decodeDiffTimestamp=a,a>500&&!r&&this.player.isPlayer()&&this.player.debug.warn(this.TAG_NAME,"decodeVideo diff time is ",a);const n=e.slice(5),o=new EncodedVideoChunk({data:n,timestamp:t,type:i?$t:jt});this.player.emit(st.timeUpdate,t);try{this.decoder.decode(o)}catch(e){this.player.debug.error(this.TAG_NAME,"VideoDecoder",e);const t=e.toString();(-1!==t.indexOf(Di)||-1!==t.indexOf(Ri))&&this.player.emitError(lt.webcodecsDecodeError,t)}this.prevTimestamp=(new Date).getTime()}else this.player.debug.log(this.TAG_NAME,"VideoDecoder first frame is not iFrame");else if(i&&e[1]===Ni){const t=15&e[0];if(this.player.video.updateVideoInfo({encTypeCode:t}),t===At&&!zs()){const e=xs();return this.player.debug.warn(this.TAG_NAME,"WebcodecsDecoder not support hevc decode",e.type,e.version),void this.player.emitError(lt.webcodecsH265NotSupport)}this.player._times.decodeStart||(this.player._times.decodeStart=vs());let i=null,r=null;const s=e.slice(5);if(t===gt?(r=On(s),i={codec:r.codec,description:s}):t===At&&(r=parseHEVCDecoderConfigurationRecord$4(s),i={codec:r.codec,description:s}),!i||i&&!i.codec||r&&0===r.codecWidth&&0===r.codecHeight)return this.player.debug.warn(this.TAG_NAME,"decodeVideo and webcodecs configure is",JSON.stringify(i)),void this.player.emitError(lt.webcodecsDecodeConfigureError,"configure or configure.code is null");i.codedHeight=r.codecHeight,i.codedWidth=r.codecWidth,this.isInitInfo||(this.player.debug.log(this.TAG_NAME,`updateVideoInfo: ${r.codecWidth},${r.codecHeight}`),this.player.video.updateVideoInfo({width:r.codecWidth,height:r.codecHeight}),this.player.video.initCanvasViewSize(),this.isInitInfo=!0),this.player.recorder&&this.player._opt.recordType===_&&this.player.recorder.initMetaData(e,t),this.player.debug.log(this.TAG_NAME,`decoder.configure() and codec is ${i.codec}`);try{this.decoder.configure(i),this.hasInit=!0}catch(e){this.player.debug.error(this.TAG_NAME,"configure error",e.code,e);const t=e.toString();-1!==t.indexOf(Bi)?this.player.emitError(lt.webcodecsH265NotSupport,t):this.player.emitError(lt.webcodecsDecodeConfigureError,t)}}else this.player.debug.warn(this.TAG_NAME,`decodeVideo has not init , isIframe is ${i} , payload is ${e[1]} so drop this frame`)}decodeAudio(e,t){if(this.player)if(this.player.isDestroyedOrClosed())this.player.debug&&this.player.debug.warn(this.TAG_NAME,"decodeAudio() player is destroyed");else if(this.hasAudioInit){if(is(e))return void this.player.debug.log(this.TAG_NAME,"decodeAudio and has already initialized and payload is aac codec packet so drop this frame");if(this._clearAudioNoDataCheckTimeout(),this.isDecodeFirstIIframe){if(this.isAudioDecodeStateClosed())return void this.player.debug.warn(this.TAG_NAME,"AudioDecoder isDecodeStateClosed true");const i=this.isAAC?e.slice(2):e.slice(1),r=i.length/this.player.audio.audioInfo.sampleRate*1e3,s=new EncodedAudioChunk({type:"key",data:i,timestamp:t,duration:parseInt(r,10)});try{this.decoderAudio.decode(s)}catch(e){this.player.debug.error(this.TAG_NAME,"AudioDecoder",e),e.toString()}}}else{const t=e[0]>>4,i=e[0]>>1&1,r=t===_t.MP3,s=t===_t.AAC,a=t===_t.ALAW;let n="";n=s?i?16:8:0===i?8:16;const o={codec:"",numberOfChannels:"",sampleRate:""};let l=null;if(s||r){let t=null;if(is(e)){const i=e.slice(2);t=ds(i),t&&(o.codec=t.originalCodec,o.numberOfChannels=t.channelCount,o.sampleRate=t.sampleRate),l=i,this.isAAC=s}else r&&(t=dd(e),t&&(o.codec=Kr,o.numberOfChannels=t.channelCount,o.sampleRate=t.samplingRate))}else o.codec=a?jr:$r,o.numberOfChannels=1,o.sampleRate=8e3;if(o.codec&&o.numberOfChannels&&o.sampleRate){this.isAudioInitInfo||(this.player.audio.updateAudioInfo({encTypeCode:t,channels:o.numberOfChannels,sampleRate:o.sampleRate,depth:n}),this.isAudioInitInfo=!0),this.player.recorder&&this.player._opt.recordType===_&&l&&this.player.recorder.initAudioAacExtraData(l),this.player.debug.log(this.TAG_NAME,`decoderAudio.configure() and codec is ${o.codec}`);try{this.decoderAudio.configure(o),this._clearAudioSourceBufferCheckTimeout(),this.hasAudioInit=!0,null===this.audioSourceNoDataCheckTimeout&&(this.audioSourceNoDataCheckTimeout=setTimeout((()=>{this._clearAudioNoDataCheckTimeout(),this.player.emit(lt.webcodecsAudioNoDataTimeout)}),1e3))}catch(e){this.player.debug.error(this.TAG_NAME,"configure audio error",e.code,e),e.toString()}}}}_clearAudioSourceBufferCheckTimeout(){this.audioSourceBufferCheckTimeout&&(clearTimeout(this.audioSourceBufferCheckTimeout),this.audioSourceBufferCheckTimeout=null)}_clearAudioNoDataCheckTimeout(){this.audioSourceNoDataCheckTimeout&&(clearTimeout(this.audioSourceNoDataCheckTimeout),this.audioSourceNoDataCheckTimeout=null)}getDecodeDiffTimes(){return this.decodeDiffTimestamp}isDecodeStateClosed(){return"closed"===this.decoder.state}isDecodeStateConfigured(){return"configured"===this.decoder.state}isDecodeStateUnConfigured(){return"unconfigured"===this.decoder.state}isAudioDecodeStateClosed(){return"closed"===this.decoderAudio.state}isAudioDecodeStateConfigured(){return"configured"===this.decoderAudio.state}isAudioDecodeStateUnConfigured(){return"unconfigured"===this.decoderAudio.state}}const cd={play:"播放",pause:"暂停",audio:"",mute:"",screenshot:"截图",loading:"",fullscreen:"全屏",fullscreenExit:"退出全屏",record:"录制",recordStop:"停止录制",narrow:"缩小",expand:"放大",ptz:"操作盘",ptzActive:"操作盘激活",zoom:"电子放大",zoomStop:"关闭电子放大",close:"关闭",performance:"性能面板",performanceActive:"性能面板激活",face:"人脸识别",faceActive:"人脸识别激活",object:"物品识别",objectActive:"物品识别激活",occlusion:"遮挡物检查",occlusionActive:"遮挡物检查激活",logSave:"保存日志"};var ud=Object.keys(cd).reduce(((e,t)=>(e[t]=`\n <i class="easyplayer-icon easyplayer-icon-${t}"></i>\n ${cd[t]?`<span class="icon-title-tips"><span class="icon-title">${cd[t]}</span></span>`:""}\n`,e)),{});function pd(e,t){let i=!1;return e.forEach((e=>{i||e.startTimestamp<=t&&e.endTimestamp>t&&(i=!0)})),i}function fd(e=[],t=[],i){const r=e.length,s=t.length,a=Math.max(r,s),n=Jt,o=Math.ceil(a/n);let l=0,d=0;!function s(){let a="",h="";for(let i=0;i<n;i++){const i=e[d];i&&(a+=`\n <div class="easyplayer-playback-time-minute-one${i.hasRecord?" active":""}${i.isStart?" start":""}" data-has-record="${i.hasRecord}"\n data-time="${i.timestamp}" data-type="${i.dataType}">\n <span class="easyplayer-playback-time-title-tips ${d>r-60?"easyplayer-playback-time-title-tips-left":""}"><span class="easyplayer-playback-time-title">${i.title}</span></span>\n </div>\n `);const s=t[d];s&&(h+=`\n <div class="easyplayer-playback-time-hour" data-hour="${s.hour}" data-min="${s.min}" data-second="${s.second}"><span class="easyplayer-playback-time-hour-text">${s.title}</span></div>\n `),d+=1}a&&i.$playbackTimeListOne.insertAdjacentHTML("beforeend",a),h&&i.$playbackTimeListSecond.insertAdjacentHTML("beforeend",h),l+=1,l<o&&(i.rafId=window.requestAnimationFrame(s))}()}function yd(e,t){const i=function(e=[]){let t=[];const i=(e[0]||{}).startTimestamp;for(let r=0;r<1440;r++){const s=r%60==0;let a=!1;i&&(a=pd(e,ea(i,r))),t.push({title:Js(r),timestamp:r,dataType:"min",hasRecord:a,isStart:s})}return t}(e);fd(i,function(){let e=[];for(let t=0;t<24;t++){let i=t+":00";t<10&&(i="0"+i),e.push({title:i,hour:t,min:0,second:0})}return e}(),t)}function md(e,t){const i=function(e=[]){let t=[];const i=(e[0]||{}).startTimestamp;for(let r=0;r<1440;r++){let s=60*r,a=s%1800==0,n=!1;i&&(n=pd(e,ta(i,s))),t.push({title:Zs(s),timestamp:s,dataType:"second",hasRecord:n,isStart:a});let o=60*r+30;a=o%1800==0,i&&(n=pd(e,ta(i,o))),t.push({title:Zs(o),timestamp:o,dataType:"second",hasRecord:n,isStart:a})}return t}(e);fd(i,function(){let e=[];for(let t=0;t<24;t++){let i=t+":00",r=t+":30";t<10&&(i="0"+i,r="0"+r),e.push({title:i,hour:t,min:0,second:0}),e.push({title:r,hour:t,min:30,second:0})}return e}(),t)}function gd(e,t){const i=function(e=[]){let t=[];const i=(e[0]||{}).startTimestamp;for(let r=0;r<144;r++)for(let s=0;s<60;s++){let a=10*s+600*r,n=a%600==0,o=!1;i&&(o=pd(e,ta(i,a))),t.push({title:Zs(a),timestamp:a,dataType:"second",isStart:n,hasRecord:o})}return t}(e);fd(i,function(){let e=[];for(let t=0;t<24;t++){let i=t+":00";t<10&&(i="0"+i),e.push({title:i,hour:t,min:0,second:0});for(let r=1;r<6;r++){let s=r+"0";e.push({title:i.replace(":00",":"+s),hour:t,min:10*r,second:0})}}return e}(),t)}function Ad(e,t){const i=function(e=[]){let t=[];const i=(e[0]||{}).startTimestamp;for(let r=0;r<288;r++)for(let s=0;s<60;s++){let a=5*s+300*r,n=a%300==0,o=!1;i&&(o=pd(e,ta(i,a))),t.push({title:Zs(a),timestamp:a,dataType:"second",isStart:n,hasRecord:o})}return t}(e);fd(i,function(){let e=[];for(let t=0;t<24;t++){let i=t+":00";t<10&&(i="0"+i),e.push({title:i,hour:t,min:0,second:0}),e.push({title:i.replace(":00",":05"),hour:t,min:5,second:0});for(let r=1;r<6;r++){let s=r+"0",a=r+"5";e.push({title:i.replace(":00",":"+s),hour:t,min:10*r,second:0}),e.push({title:i.replace(":00",":"+a),hour:t,min:10*r+5,second:0})}}return e}(),t)}function vd(e){const t=Math.floor(e/3600),i=Math.floor((e-3600*t)/60),r=Math.floor(e-3600*t-60*i);return(t>0?[t,i,r]:[i,r]).map((e=>e<10?`0${e}`:String(e))).join(":")}function bd(e,t,i){const r=e.$playbackProgress,{left:s}=r.getBoundingClientRect(),a=bs((ks()?i.touches[0].clientX:i.pageX)-s,0,r.clientWidth),n=parseInt(a/r.clientWidth*t,10);return{second:n,time:vd(n),width:a,percentage:bs(a/r.clientWidth,0,1)}}function _d(e,t){return t instanceof Element?e.appendChild(t):e.insertAdjacentHTML("beforeend",String(t)),e.lastElementChild||e.lastChild}function wd(e,t,i){return e&&e.style&&Ks(t)&&(e.style[t]=i),e}function Ed(e,t){return e.composedPath&&e.composedPath().indexOf(t)>-1}function Sd(e){let t=!1;return e&&e.parentNode&&(e.parentNode.removeChild(e),t=!0),t}var Td=(e,t)=>{const{events:{proxy:i}}=e,r=document.createElement("object");r.setAttribute("aria-hidden","true"),r.setAttribute("tabindex",-1),r.type="text/html",r.data="about:blank",_s(r,{display:"block",position:"absolute",top:"0",left:"0",height:"100%",width:"100%",overflow:"hidden",pointerEvents:"none",zIndex:"-1"});let s=e.width,a=e.height;const n=Fs((()=>{e.width===s&&e.height===a||(s=e.width,a=e.height,e.emit(st.resize),c())}),500);i(r,"load",(()=>{i(r.contentDocument.defaultView,"resize",(()=>{n()}))})),e.$container.appendChild(r),e.on(st.destroy,(()=>{e.$container.removeChild(r)})),e.on(st.volumechange,(()=>{!function(e){if(0===e)_s(t.$volumeOn,"display","none"),_s(t.$volumeOff,"display","flex"),_s(t.$volumeHandle,"top","48px");else if(t.$volumeHandle&&t.$volumePanel){const i=ws(t.$volumePanel,"height")||60,r=ws(t.$volumeHandle,"height"),s=i-(i-r)*e-r;_s(t.$volumeHandle,"top",`${s}px`),_s(t.$volumeOn,"display","flex"),_s(t.$volumeOff,"display","none")}t.$volumePanelText&&(t.$volumePanelText.innerHTML=parseInt(100*e))}(e.volume)})),e.on(st.loading,(i=>{_s(t.$loading,"display",i?"flex":"none"),(ka(e._opt.backgroundLoadingShow)&&Ta(i)||ka(i))&&_s(t.$poster,"display","none"),i&&(_s(t.$playBig,"display","none"),_s(t.$tipsMessage,"display","none")),i||e._opt.extendDomConfig.showAfterLoading&&t.$extendDom&&_s(t.$extendDom,"display","block"),ks()||i||e.getRenderType()===K&&ka(e._opt.useMSE)&&o()})),e.on(st.removeLoadingBgImage,(()=>{ks()||o()}));const o=()=>{t.$loadingBgImage&&t.$loadingBg&&t.$loadingBgImage.src&&(e.debug&&e.debug.log("Control","remove loading bg image"),t.$loadingBgImage.width=0,t.$loadingBgImage.height=0,t.$loadingBgImage.src="",_s(t.$loadingBg,"display","none"))},l=t=>{e.fullscreen?la(t)===e.$container&&d():d()},d=i=>{let r=js(i)?i:e.fullscreen;_s(t.$fullscreenExit,"display",r?"flex":"none"),_s(t.$fullscreen,"display",r?"none":"flex")},h=()=>e._opt.playType===b&&e._opt.playbackConfig.showControl,c=i=>{ks()&&t.$controls&&e._opt.useWebFullScreen&&setTimeout((()=>{if(e.fullscreen){const i=h()?Pt:0;let r=e.height/2-e.width+i/2,s=e.height/2-i/2;if(t.$controls.style.transform=`translateX(${-r}px) translateY(-${s}px) rotate(-90deg)`,t.$zoomControls){const i=156,r=30,s=e.width/2+i/2-r/2;t.$zoomControls.style.transform=`translateX(${-s}px) translateY(${e.height/2}px) rotate(-90deg)`}if(t.$recording){const i=101,r=20,s=e.width/2+i/2-r/2;t.$recording.style.transform=`translateX(${-s}px) translateY(${e.height/2}px) rotate(-90deg)`}}else t.$controls.style.transform="translateX(0) translateY(0) rotate(0)",t.$zoomControls&&(t.$zoomControls.style.transform="translateX(-50%) translateY(0) rotate(0)"),t.$recording&&(t.$recording.style.transform="translateX(-50%) translateY(0) rotate(0)");i&&i()}),10)};try{es.on("change",l),e.events.destroys.push((()=>{es.off("change",l)}))}catch(e){}e.on(st.webFullscreen,(e=>{ks()&&(d(e),c((()=>{p()})))})),e.on(st.recording,(()=>{e.playing&&(_s(t.$record,"display",e.recording?"none":"flex"),_s(t.$recordStop,"display",e.recording?"flex":"none"),(e._opt.hasControl||e._opt.isShowRecordingUI)&&(_s(t.$recording,"display",e.recording?"flex":"none"),ka(e.recording)&&t.$recordingTime&&(t.$recordingTime.innerHTML=Xs(0))))})),e.on(st.recordingTimestamp,(e=>{t.$recordingTime&&(t.$recordingTime.innerHTML=Xs(e))})),e.on(st.zooming,(()=>{e.playing&&(_s(t.$zoom,"display",e.zooming?"none":"flex"),_s(t.$zoomStop,"display",e.zooming?"flex":"none"),(e._opt.hasControl||e._opt.isShowZoomingUI)&&_s(t.$zoomControls,"display",e.zooming?"flex":"none"))})),e.on(st.playing,(e=>{u(e)}));const u=i=>{_s(t.$play,"display",i?"none":"flex"),_s(t.$playBig,"display",i?"none":"block"),_s(t.$pause,"display",i?"flex":"none"),_s(t.$screenshot,"display",i?"flex":"none"),_s(t.$record,"display",i?"flex":"none"),_s(t.$qualityMenu,"display",i?"flex":"none"),_s(t.$volume,"display",i?"flex":"none"),_s(t.$ptz,"display",i?"flex":"none"),_s(t.$zoom,"display",i?"flex":"none"),_s(t.$scaleMenu,"display",i?"flex":"none"),_s(t.$faceDetect,"display",i?"flex":"none"),_s(t.$objectDetect,"display",i?"flex":"none"),_s(t.$occlusionDetect,"display",i?"flex":"none"),_s(t.$controlHtml,"display",i?"flex":"none"),e.isPlayback()&&_s(t.$speedMenu,"display",i?"flex":"none"),d(),t.extendBtnList.forEach((e=>{e.$iconWrap&&_s(e.$iconWrap,"display",i?"flex":"none"),e.$activeIconWrap&&_s(e.$activeIconWrap,"display","none")})),e._opt.showPerformance?_s(t.$performanceActive,"display",i?"flex":"none"):(_s(t.$performance,"display",i?"flex":"none"),_s(t.$performanceActive,"display","none")),_s(t.$poster,"display","none"),_s(t.$ptzActive,"display","none"),_s(t.$recordStop,"display","none"),_s(t.$zoomStop,"display","none"),_s(t.$faceDetectActive,"display","none"),_s(t.$objectDetectActive,"display","none"),i||(t.$speed&&(t.$speed.innerHTML=function(e){if(null==e||""===e)return"0 KB/s";let t=parseFloat(e);return t=t.toFixed(2),t+"KB/s"}("")),_s(t.$zoomControls,"display","none"),_s(t.$recording,"display","none"),t.$ptzControl&&t.$ptzControl.classList.remove("easyplayer-ptz-controls-show")),p(),i&&f()};e.on(st.playbackPause,(e=>{u(!e)})),e.on(st.kBps,(i=>{const r=function(e){if(null==e||""===e||0===parseFloat(e)||"NaN"===e)return"0 KB/s";const t=["KB/s","MB/s","GB/s","TB/s","PB/s","EB/s","ZB/s","YB/s"];let i=0;const r=parseFloat(e);i=Math.floor(Math.log(r)/Math.log(1024));let s=r/Math.pow(1024,i);return s=s.toFixed(2),s+(t[i]||t[0])}(i);t.kbpsShow=r,e._opt.showBandwidth&&(t.$speed&&(t.$speed.innerHTML=r),p())}));const p=()=>{if(h()&&e._opt.playbackConfig.controlType===Z.normal){let i=t.controlsInnerRect.width-t.controlsLeftRect.width-t.controlsRightRect.width-t.controlsPlaybackBtnsRect.width;ks()&&e.webFullscreen&&(i=t.controlsInnerRect.height-t.controlsLeftRect.height-t.controlsRightRect.height-t.controlsPlaybackBtnsRect.height),t.$playbackTimeInner.style.width=i+"px"}},f=()=>{if(!h()||e._opt.playbackConfig.controlType!==Z.normal)return;const i=t.$playbackCurrentTime.style.left;let r=parseInt(i,10);const s=t.controlsPlaybackTimeInner.width;r=r-s/2>0?parseInt(r-s/2,10):0,t.$playbackTimeInner.scrollLeft=r};if(h()){const i=()=>{if(h()){let i=0;const r=e.playback&&e.playback.playingTimestamp;if(r){const s=new Date(r),a=s.getHours(),n=s.getMinutes(),o=s.getSeconds();e.playback.is60Min?i=60*a+n:e.playback.is30Min?i=2*(60*a+n)+parseInt(o/30,10):e.playback.is10Min?i=6*(60*a+n)+parseInt(o/10,10):e.playback.is5Min?i=12*(60*a+n)+parseInt(o/5,10):e.playback.is1Min&&(i=60*(60*a+n)+parseInt(o,10)),t.$playbackCurrentTime.style.left=i+"px"}}},r=e=>{t.$playbackNarrow.classList.remove("disabled"),t.$playbackExpand.classList.remove("disabled"),e===ii&&t.$playbackNarrow.classList.add("disabled"),e===ai&&t.$playbackExpand.classList.add("disabled")};e.on(st.playbackTime,(r=>{if(e._opt.playbackConfig.controlType===Z.normal)t.$playbackCurrentTimeText&&(t.$playbackCurrentTimeText.innerText=Ps(r,"{h}:{i}:{s}")),i();else if(e._opt.playbackConfig.controlType===Z.simple){const i=(s=r,a=e.playback.totalDuration,bs(s/a,0,1));t.$playbackProgressPlayed.style.width=100*i+"%",t.$playbackProgressIndicator.style.left=`calc(${100*i}% - 7px)`,t.$playbackProgressTime.innerText=`${vd(r)} / ${vd(e.playback.totalDuration)}`}var s,a})),e.on(st.playbackPrecision,((s,a)=>{h()&&e._opt.playbackConfig.controlType===Z.normal&&(t.$playbackTimeScroll.classList.remove(ni.oneHour,ni.halfHour,ni.fiveMin,ni.tenMin),t.$playbackTimeScroll.classList.add(ni[s]),t.rafId&&(window.cancelAnimationFrame(t.rafId),t.rafId=null),t.changePercisitionInterval&&(clearTimeout(t.changePercisitionInterval),t.changePercisitionInterval=null),t.$playbackTimeListOne.innerHTML="",t.$playbackTimeListSecond.innerHTML="",t.changePercisitionInterval=setTimeout((()=>{switch(t.$playbackTimeListOne.innerHTML="",t.$playbackTimeListSecond.innerHTML="",s){case ii:yd(a,t);break;case ri:md(a,t);break;case si:gd(a,t);break;case ai:Ad(a,t)}i(),e._opt.playbackConfig.showPrecisionBtn&&r(s),f()}),16))})),e.on(st.resize,(()=>{p()})),e.on(st.playbackTimeScroll,(()=>{f()})),p()}if(e._opt.operateBtns.quality&&e._opt.qualityConfig.length>0){e.on(st.streamQualityChange,(e=>{i(e)}));const i=e=>{t.$qualityText.innerText=e,t.$qualityMenuItems.forEach((t=>{const i=t.dataset.quality;t.classList.remove("easyplayer-quality-menu-item-active"),i===e&&t.classList.add("easyplayer-quality-menu-item-active")}))};(()=>{const i=e._opt.qualityConfig||[];let r="";i.forEach((e=>{r+=`\n <div class="easyplayer-quality-menu-item" data-quality="${e}">${e}</div>\n `})),r&&(t.$qualityMenuList.insertAdjacentHTML("beforeend",r),Object.defineProperty(t,"$qualityMenuItems",{value:e.$container.querySelectorAll(".easyplayer-quality-menu-item")}))})(),e.streamQuality&&i(e.streamQuality)}if(e._opt.operateBtns.scale&&e._opt.scaleConfig.length>0){e.on(st.viewResizeChange,(e=>{i(e)}));const i=i=>{const r=e._opt.scaleConfig[i];t.$scaleText.innerText=r,t.$scaleMenuItems.forEach((e=>{const t=e.dataset.scale;e.classList.remove("easyplayer-scale-menu-item-active"),Ms(t)===Ms(i)&&e.classList.add("easyplayer-scale-menu-item-active")}))};(()=>{const i=e._opt.scaleConfig||[];let r="";i.forEach(((e,t)=>{r+=`\n <div class="easyplayer-scale-menu-item" data-scale="${t}">${e}</div>\n `})),r&&(t.$scaleMenuList.insertAdjacentHTML("beforeend",r),Object.defineProperty(t,"$scaleMenuItems",{value:e.$container.querySelectorAll(".easyplayer-scale-menu-item")}))})(),i(e.scaleType)}if(e.isPlayback()&&e._opt.playbackConfig.showRateBtn&&e._opt.playbackConfig.rateConfig.length>0){e.on(st.playbackRateChange,(e=>{i(e)}));const i=i=>{const r=e._opt.playbackConfig.rateConfig.find((e=>Ms(e.value)===Ms(i)));r&&(t.$speedText.innerText=r.label,t.$speedMenuItems.forEach((e=>{const t=e.dataset.speed;e.classList.remove("easyplayer-speed-menu-item-active"),Ms(t)===Ms(i)&&e.classList.add("easyplayer-speed-menu-item-active")})))};(()=>{const i=e._opt.playbackConfig.rateConfig;let r="";i.forEach(((e,t)=>{r+=`\n <div class="easyplayer-speed-menu-item" data-speed="${e.value}">${e.label}</div>\n `})),r&&(t.$speedMenuList.insertAdjacentHTML("beforeend",r),Object.defineProperty(t,"$speedMenuItems",{value:e.$container.querySelectorAll(".easyplayer-speed-menu-item")}))})();const r=e.playback?e.playback.playbackRate:1;i(r)}e.on(st.stats,((i={})=>{if(e._opt.showPerformance){_s(t.$performancePanel,"display","block"),t.$performancePanel.innerHTML="";const r=Ts,s=window.performance&&window.performance.memory?window.performance.memory:null,a=e.getCpuLevel(),n=Ks(a)&&-1!==a?`${Lr[a]}`:"",o=e.video&&e.video.videoInfo||{},l=e.audio&&e.audio.audioInfo||{},d=e._times||{},h=e.getRenderType(),c=e.getCanvasRenderType(),u=e.getDecodeType(),p=e.getDemuxType(),f=e.getStreamType(),y=e.getAudioEngineType();let m=e.getRecordingDuration(),g=e.getRecordingByteLength();const A=e.isAudioPlaybackRateSpeed(),v=e.videoIframeIntervalTs;m=Xs(m),g=Os(g);const b=e.isPlayback()?"录播":"直播";let _=i.isDropping;const w=e._opt.useMSE&&e._opt.mseDecodeAudio,E=e.control?e.control.kbpsShow:"0 KB/s",S=e.getVideoPlaybackQuality(),T=`\n <div class="easyplayer-performance-item">\n <span>版本 ${r}</span>\n </div>\n ${e._opt.isMulti?`\n <div class="easyplayer-performance-item">\n <span>UUid ${e._opt.debugUuid}</span>\n </div>\n `:""}\n ${e.isInMulti()?`\n <div class="easyplayer-performance-item">\n <span>窗口下标 ${e._opt.multiIndex}</span>\n </div>\n `:""}\n ${s?`\n <div class="easyplayer-performance-item">\n <span>内存大小限制 ${Os(s.jsHeapSizeLimit)}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>可使用的内存 ${Os(s.totalJSHeapSize)}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>已使用的内存 ${Os(s.usedJSHeapSize)}</span>\n </div>\n `:""}\n ${n?`\n <div class="easyplayer-performance-item">\n <span>CPU压力情况 ${n}</span>\n </div>\n `:""}\n\n ${s&&s.usedJSHeapSize>s.totalJSHeapSize?'\n <div class="easyplayer-performance-item">\n <span>可能内存泄漏 是}</span>\n </div>\n ':""}\n <div class="easyplayer-performance-item">\n <span>播放模式 ${b}</span>\n </div>\n ${e.isPlayback()?`\n <div class="easyplayer-performance-item">\n <span>播放倍率 ${e.playback.rate}倍</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>播放模式 ${e.playback.isUseFpsRender?"固定FPS":"动态FPS"}</span>\n </div>\n ${e.playback.isUseFpsRender?`\n <div class="easyplayer-performance-item">\n <span>固定FPS ${e.video.getStreamFps()}</span>\n </div>\n `:""}\n `:""}\n <div class="easyplayer-performance-item">\n <span>解封装模式 ${U[p]}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>解码模式 ${u}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>渲染组件 ${h}</span>\n </div>\n ${h===K?`\n <div class="easyplayer-performance-item">\n <span>渲染引擎 ${c}</span>\n </div>\n `:""}\n <div class="easyplayer-performance-item">\n <span>网络请求组件 ${f}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>视频格式 ${o.encType||"-"}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>视频(宽x高) ${o.width||"-"}x${o.height||"-"}</span>\n </div>\n ${e.isPlayer()?`\n <div class="easyplayer-performance-item">\n <span>视频GOP(ms) ${v||"-"}</span>\n </div>\n `:""}\n <div class="easyplayer-performance-item">\n <span>音频格式 ${wt[l.encType]||"-"}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>音频引擎 ${y||"-"}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>音频通道 ${l.channels||"-"}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>音频采样率 ${l.sampleRate||"-"}</span>\n </div>\n ${e.isPlayer()?`\n <div class="easyplayer-performance-item">\n <span>播放器初始化(ms) ${d.playTimestamp}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>开始请求地址(ms) ${d.streamTimestamp}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>请求响应(ms) ${d.streamResponseTimestamp}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>解封装(ms) ${d.demuxTimestamp}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>解码(ms) ${d.decodeTimestamp}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>页面开始渲染(ms) ${d.videoTimestamp}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>初始化到页面渲染(ms) ${d.allTimestamp}</span>\n </div>\n ${e.recording?`\n <div class="easyplayer-performance-item">\n <span>视频录制时间 ${m}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>视频录制大小 ${g}</span>\n </div>\n `:""}\n `:""}\n <div class="easyplayer-performance-item">\n <span>音频码率(bit) ${i.abps}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>视频码率(bit) ${i.vbps}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>视频帧率(fps) ${i.fps}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>视频峰值帧率(fps) ${i.maxFps}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>解码帧率(fps) ${i.dfps}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>音频缓冲帧 ${i.audioBuffer}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>音频缓冲时长(ms) ${i.audioBufferDelayTs}</span>\n </div>\n ${e.isPlayer()?`\n <div class="easyplayer-performance-item">\n <span>视频待解码帧 ${i.demuxBuffer}</span>\n </div>\n `:`\n <div class="easyplayer-performance-item">\n <span>缓存时长(ms) ${i.playbackCacheDataDuration}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>视频待渲染帧 ${i.playbackVideoBuffer}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>视频待解码帧 ${i.demuxBuffer}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>音频待解码帧 ${i.audioDemuxBuffer}</span>\n </div>\n `}\n <div class="easyplayer-performance-item">\n <span>待解封装数据(byte) ${i.flvBuffer}</span>\n </div>\n ${e._opt.useMSE?`\n <div class="easyplayer-performance-item">\n <span>MSE缓冲时长(ms) ${i.mseDelay}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>MSE待解码帧 ${i.msePendingBuffer}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>MSE缓存时长(s) ${i.mseStore}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>MSE解码间隔(ms) ${i.mseDecodeDiffTimes}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>MSE解码时间(ms) ${i.mseTs}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>MSE播放模式 ${i.mseDecodePlaybackRate>1?"加速":"正常"}</span>\n </div>\n `:""}\n ${e._opt.useWCS?`\n <div class="easyplayer-performance-item">\n <span>WCS解码间隔(ms) ${i.wcsDecodeDiffTimes}</span>\n </div>\n `:""}\n ${e.isOldHls()?`<div class="easyplayer-performance-item">\n <span>HLS缓冲时长(ms) ${i.hlsDelay}</span>\n </div>\n `:""}\n ${e.isUseHls265()?`<div class="easyplayer-performance-item">\n <span>HLS缓冲时长(ms) ${i.hlsDelay}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>HLS待解码帧 ${i.hlsDemuxLength}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>HLS待解码视频帧 ${i.hlsDemuxVideoLength}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>HLS待解码音频帧 ${i.hlsDemuxAudioLength}</span>\n </div>\n `:""}\n ${e.isPlayer()&&S?`\n <div class="easyplayer-performance-item">\n <span>Video已渲染帧 ${S.renderedVideoFrames}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>Video已丢弃帧 ${S.droppedVideoFrames}</span>\n </div>\n `:""}\n ${e.isPlayer()?`\n <div class="easyplayer-performance-item">\n <span>网络延迟(ms) ${i.netBuf}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>缓冲时长(ms) ${i.buf}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>最新缓冲时长(ms) ${i.pushLatestDelay}</span>\n </div>\n `:""}\n ${e._opt.useMSE||e.isWebrtcH264()||e.isAliyunRtc()?`\n <div class="easyplayer-performance-item">\n <span>video显示时间(s) ${i.videoCurrentTime}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>video间隔时间(s) ${i.videoCurrentTimeDiff}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>videoBuffer缓存时间(ms) ${i.mseVideoBufferDelayTime}</span>\n </div>\n `:""}\n <div class="easyplayer-performance-item">\n <span>视频显示时间(ms) ${i.currentPts||i.ts}</span>\n </div>\n ${e._opt.hasAudio&&e.isAudioNotMute()&&ka(w)?`\n <div class="easyplayer-performance-item">\n <span>音频显示时间(ms) ${i.audioTs}</span>\n </div>\n ${e._opt.hasVideo?`\n <div class="easyplayer-performance-item">\n <span>音视频同步时间戳(ms) ${i.audioSyncVideo}</span>\n </div>\n `:""}\n <div class="easyplayer-performance-item">\n <span>音频播放模式 ${A?"加速":"正常"}</span>\n </div>\n `:""}\n <div class="easyplayer-performance-item">\n <span>视频解码时间(ms) ${i.dts}</span>\n </div>\n ${e.isPlayer()?`\n <div class="easyplayer-performance-item">\n <span>解码前-解码后延迟(ms) ${i.delayTs}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>总延迟(网络+解码)(ms) ${i.totalDelayTs}</span>\n </div>\n `:""}\n ${e.isPlayer()&&i.isStreamTsMoreThanLocal?'<div class="easyplayer-performance-item">\n <span>是否超过一倍率推流 是</span>\n </div>\n ':""}\n ${e.isPlayer()?`\n <div class="easyplayer-performance-item">\n <span>是否播放流畅 ${i.videoSmooth}</span>\n </div>\n `:""}\n ${e.isPlayer()?`\n <div class="easyplayer-performance-item">\n <span>是否在丢帧 ${_}</span>\n </div>\n `:""}\n <div class="easyplayer-performance-item">\n <span>网速 ${E}</span>\n </div>\n <div class="easyplayer-performance-item">\n <span>播放时长(s) ${Xs(i.pTs)}</span>\n </div>\n <div class="easyplayer-performance-item-block"></div>\n `;t.$performancePanel.insertAdjacentHTML("beforeend",T)}else t.$performancePanel.innerHTML="",_s(t.$performancePanel,"display","none")})),e.on(st.togglePerformancePanel,(e=>{_s(t.$performance,"display",e?"none":"flex"),_s(t.$performanceActive,"display",e?"flex":"none")})),e.on(st.faceDetectActive,(e=>{_s(t.$faceDetect,"display",e?"none":"flex"),_s(t.$faceDetectActive,"display",e?"flex":"none")})),e.on(st.objectDetectActive,(e=>{_s(t.$objectDetect,"display",e?"none":"flex"),_s(t.$objectDetectActive,"display",e?"flex":"none")})),e.on(st.occlusionDetectActive,(e=>{_s(t.$occlusionDetect,"display",e?"none":"flex"),_s(t.$occlusionDetectActive,"display",e?"flex":"none")}))};function kd(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===i&&r.firstChild?r.insertBefore(s,r.firstChild):r.appendChild(s),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(document.createTextNode(e))}}kd('@keyframes rotation{0%{-webkit-transform:rotate(0deg)}to{-webkit-transform:rotate(1turn)}}@keyframes magentaPulse{0%{background-color:#630030;-webkit-box-shadow:0 0 9px #333}50%{background-color:#a9014b;-webkit-box-shadow:0 0 18px #a9014b}to{background-color:#630030;-webkit-box-shadow:0 0 9px #333}}.easyplayer-container video::-webkit-media-controls{display:none!important}.easyplayer-container .easyplayer-icon{cursor:pointer;width:16px;height:16px;display:inline-block}.easyplayer-container .easyplayer-ptz-controls{position:absolute;width:156px;height:156px;visibility:hidden;opacity:0;border-radius:78px;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATgAAAE4BAMAAAA9UfJZAAAAMFBMVEUAAABHcEy0tLRZWVmysrKoqKi1tbWvr6+2traBgYG1tbWWlpa1tbW1tbVUVFS1tbVGCHqkAAAAD3RSTlMzAO9U3LSWySp3aZcVRDUDw823AAAJYUlEQVR42u3d32sbVxYH8EPHxgg/lBsa7SBkukmpSbwLI2KbEPpgZ5MQtwmM0wRMmgdhP6RgEuwlSVnYlmGMYaEvMU1KKX4QNq0pocVmm7CYfRBaQguFpbgPKRSC/4V2LGliO+bulWKrkvVrftyZ+WbxeTRG+nDnnnNmRjP3EpMR6tMH18du/0Xj1tGz5+9cf/DUlPKx5PsTkr8s3eZ1cX7ym1zkuI/f1wTFunNt9fP+FIno7/98/tFY+Y8ffBUlLrmkl2Cr96guTv27BMxP5iLCqUvi68+tpqhJKPNXBH3SjACnfimm/7Wmsl3fI/FP75lh457oPH+1Da3M+1T8481QcT0T7UetevR618LDPdH4hTlyHLGH3LoZEk6d4PlvyVW8pfNeMwzcDwa/kCKXoTzk9tfB455o1mXyEIOa+0PrFvcFt+fIU8QM/k6guOQifzNFHkN5l/flgsOJVHibfMR9l2nhBqem+VXyFZ/xghkMTp3il8lnDPKiGQROhs2lzjEuKcVW1uWk4ybk2Eq63pxk3CK/RZLiJO+Ti/vZXw3ZX1E+kon7jv+JJMY/+Q15uIRWIKmRthZk4VTDTsnFKYZtSsItWiskObq1Pjm4f8gqIrUF5W8ycAl+nAKIT/iCf1zSKFAgkW4/7drifrLmgsHF2k87alvhblFAcbJttWuDU/VtCiyyedMXbjGfCg6n6H1+cHE+TQFGFx/3jksa2xRoZO2cZ9xsUJn6e8aOeMX1aGco4Biw1jzilm0KPNJb3nBxvhI8rrtVTlCLK5ptCiEyBS+474POhr2c+NA9Lqm/QaHEiXzONW42yN5Q2ydG3OLU4MvI7+XEdImbCWvgSkN3zB1O1YYptOhoNnRNcDM2hRjGMTc4VZsOE9fVZOioyYyjUKPJrKPGNW44XFxX41rXEPc4vFTdS9iLTnFJ4wyFHAO2U1zcSoWNU7RLDnFTb1DocaLoDJfgc+HjYo3uTjTArW9TBJHdcYJTtdEocJ0NCnE97nGBIon0RQc4YzgaXIfdHhdBHdmrJuNtceubFFFkdtrhVG0lKlx3XUrsxz22KbIwLrbBTQ1Hhxsotsb18FR0OIWvtcT9Z5sijOyfW+KM6ShxXXYrXMJKRYlTtIUWuLubFGlknrXAGaPR4jrt5riERRFH7XGtwc1sRo3LHGuKi/qo7j+uhJOr9flKMBW4QR2uxk1NR4/rKjbGRdpXG/bXKtxrAEdVHNfTDXHLf0TAvbLVCJfU5hBwMSvXABfPE0To4w1wP25i4DLPG+CmRjFwncV6nIpQSF4UE7MOd7hAIJG+VIe7u4GCG3pWh0uPouA6C/txMFOuetIR3JSrmnQEN+WqJh2BVbmaSreLS+JMudKky9Xg4jYBRXq8BndoEwmXOVKDWx5GwnVs1eD0OSRcLF+N67EIKrS1Klx8GwuXHa/C/biBhRt6XoVbnsbCdW1V4bDyoZIRZZwKlg8iI8wKLl5Aw73oEWXcoQ003NCRCm59GA3XsVPBTa2g4bqLFZyWQsMp1h6uJ09woa/t4tCaV6WBEWSy7qYrQSbrbroS2MVNzUUOAXbWSnel0sU+AUbpsl/gEjYizlgo4w5vI+Kyl8o4xEryopYI3N1hRFzHszJueRQR17lVxqXnEHGxQhmHd06yd15CgBcQlcsIYokCJi69IHDxbUycOGki9toGJm7otMC9/ism7tXfBA6zBperMIHW4HIVJsDrwsrVIYE2CNEibIHDbBDlFkFJ0AYhWkSOemxUnLFGqN2r1L8ItXuV+hfFN1FxmXH6wwYqbuivdAgXd4RQ+36p8xNq3y91flqfRsV17dD6KCquc4eWcXFbtLyCiusu0hQ0bg4VFytSGhdXICOFilNs0nFx+QOcZ5xGsGEd4DzjOC6OH+A847QD3P9jtuJ2CGjcQeP3gYM+2YQ+TYe+wMG+NETGQd+OgL6RA30LDPrm4eu/ouJe/Q37hjX0rX7oH0mgf16C/mEO+idN6B+DoX9Gx34AAfrRDeiHXqAfF0Lt/OUHrVAfUcucRn+4D/qxSOgHSqEfxcV+iBn68W/EV3AqD85Dv3IA/bIG9GsumC8IaSb+q1XYL6VBv84H/SIk9Cuk0C/fQr+2jP3CN/Sr8tCLDEAvzwC9sAX0kiDYi6lAL0MDvYAP9NJH0ItGYS+3Bb1QGVaP2LfEG/TieNDLCmIvyAi9lCX0IqDQy6diLzwLvWQv9GLH0MtER76rRqWxPgdemtwYf9kWdYdeDh97IwHoLRigN6/A3vYDesMU6K1msDfpgd7eiOmjSEf1ZdpSC3ozMuht3LA3wIPeOjDSTRdfKb7M21VCb/QJvUUq9uay0NvyYm9oHFFKdDvaChp6E23s7cehN25nh5G3vE8aZ8LGDdjMIY49zoc9dPpFx7ikHnIh7sjnHOPYTMj36oxjzDlO1UI9Xe9oUICb49iMDTBwzXCqFuKsG2gycM1wYtaFlrCK3mTgmuJU7UzkA9cUx2bDGjpFH2FucUk9pA57onGNa4lj31uhnJzEtA+ZexxLh3KpkykwL7g4D+GUuJuPe8Kx5RCuJtJbzBuuJ/hyMmCtecSx2aBzIqaNMK+4pBHwtU7WznnGiZwI9Oykq1U2tMWxxSD7hKL3MT84VQ/wwGbzpi8c+47fCsp2kt9g/nDsp6AyNqb1Mb+4pBFQKU7bpm8cS/DjQdg+aXT/wTWOzfLL8m2DfITJwLFFS/oZQHf7CecQpxq25GqnGO0nnEMcS2iSq13WWmCycKLaHZebDDeYPBz7mb8tz3aff8Rk4tiivJQd5H1MLo5NyNIN8t6cbJw6ZV2WYys6tTnHCZ2MsRM2k8nHSdG5srnBMTXNr/qzfcYLLmyucEyd8FdR7vNeNzZ3OJZc5G967mTKu7wvx4LDMfYFtz2efMYM/o7LL3OLY080byVlULNusqBx7AeDX3B9aJWH3P6aBY8rpUX+W3e2t3SXqeAZVzq0/JyLmRe7wt0fUs849t8Jzv/u8Ngq/+K8d42FhxODp/P8VQc85VPxjzc9folXHFO/1Lh1rc3BjT0S//SeycLGCd6Sxvm51abDp8xf4dyaNL1/gw+caBhLuvj6O6v36mWn5scEPe+H5hMn4uP3hUEAr63e6y+PYX//qflHY+U/fvCVzw/3ixPD98vSbV4X5ye/yfn+aP+4MvDpg+tjZ4+K8bKOnr1z/cFTU8rH/g92biFxn2S73AAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%;transition:visibility .3s,opacity .3s;right:43px;bottom:135px}.easyplayer-container .easyplayer-ptz-controls.easyplayer-ptz-controls-show{visibility:visible;opacity:1}.easyplayer-container .easyplayer-ptz-bg-active{visibility:hidden;opacity:0;width:156px;height:156px;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATgAAAE4CAMAAAD4oR9YAAAAM1BMVEX///////////////////////////9HcEz///////////////////////////////////85yRS0AAAAEXRSTlO5DCgVgZBxAK2fQDRkBR5XTPLKM/gAABnnSURBVHja7F0Jkqs6DGQPO9z/tD8Jq6WWbCCvIjKfzAGmulrW3ooedr6ui+M4TdP++SXPr1l/SdL3aRrHhv7ZyA5qb9xe0L3Am+DrkzeCL/BeX908MezTuPsfOArdgl3KsZuhq99fk/Tx3waum+ByAHua5QbYilkzY1aP728YhrH5InrfBa57OLAtVjpRbYaumex04dq4APeC7vnVSfo/45bXLe33jGscMx3f0A1vyg3t69e2dRL/NeA6wrgdcCvjyPM2U25mXDt9xVD3f/qN0yi3Mm6P20S54vlXtGPS/R3GPSbYOsC4ZAvmJtiaGiL3Zlzx/Ht+Y/KXTJXbqmaqe9za1VYn3N7YpX/OVGev2qduOLIiB7xqOzGuWCiXFVmWtU3368A5lkqeOJI21I5XXaORxVRnxmUTdNnY/4U3riNvHMJts9XRtdXVUttipdzrK/4x7UyY6sK4Gbo+nU21T1zKcd9AGJetlMvyLKvj3zXVfeqQElMljINx3MK4xVQ3xj2Ry7N/6CiMOIfYyVUXWxUyBx7HuZRbcHt9bf/Lb9zsHlzKzabauJaK47iVcC7jJujS33/joKkmxDnM4QiJ4xDjZuT+DXQW3jgxV012qcPuiePhCGfchlv1/P0D6Czmqmuq2gPGkbIS8Q4ZsNU3dGP3Y2+cW1RyKpkrbAnwqhi3iXHFHrU3bFVV5c3vBsCsOALjkXErAW85F3rjFvBm5Kos+TngCOXYG7fA1ojFER7GPUHbmer0tfGPANeROM6pjvDMQSkrsWQ1d564Fbr61964TvSqDa6O0ELmAtvGuc2rrpQrn/aa/qCpYq+6mSpOVhnjWBy38u2JXFl9yL8acg6CV3Ur5yxVZfW4AsRxG+XKssz6n3njVMYR4Eg8sj1yi3tgtroxrpyhG38gc+h8PYddPQ551dVQW5jju2/cG7kXdB946Uy9cbDnQOpxuCCHcq5dHDcht8D2/K67VxPNGtLJd7qDTcgb1zLGbXEcY9z0Fd39GReTzIH1B/2lcxrGTYxjXnXyqxNyef8zpipVlfDsyCCmDkuumhGvWq6W+vyisqxvDJwwOxJQO6fNmjaQcRt0ZdR2dwWOFZViuculNWtgBZjk+DNq1cq45y+Lf5NxE25B3oEyLueFJWqtT+Ciqr8r48jsCAyAG+2Na53MAdQxX16VhHEL4Z7Ilc2dGad28pskaULiEdDlyijjdqa6gBeNtwSu63AnP3V6NUnAG9cu1RHOuL2hVi5qr6+9Za4qV0dCGcfCEfDIufWRFbsZvKy7KeNgW7XHvRqxWfOGLhO6XCrjoiiPb/rGdZ75uGRfj9u3B1sWAEtdLuxVF/Cq9HaMe4A4TptkZYwLqI44rmGDbUe5E8hZcg54zquRbHXu5NN6HKuO7N84YqwbdGV/Q8YF5arUN7CJTNLkgplD5T5xG+OOI2ehAhxv00ocOlpWwhHwljns5uNg6bxCb9wbueSupip6VTnj2jGudSvnOeqrVo6h7vl2nHM2K8AkV1WyfDYDvHUcWF+1VBl3EDlLKdc2dQ6aNbhXw2eAt14Nf+MqFse5rDuS8tucHUmhqaJppYF6B8440h7E8cjhqMTiLtcaAL+ga9jWZb35hpbHceyNI9WRSmHcE7n4jqbqTp2D2nnzgm154mB1hJQy1cwBIpd3twCOrjnEoDsoTZ2jepybb2VKrhpx3zB92Z29Khpl1ZN8MHWzJV1CdYQHJEeqTMbqcfEMW+obLBwES83w7AgvY0YlMNT3N96GcXEHGQdxG2t3CQ5kDkoFeO8esHd4fc193jinAtxvXhUN3Ywz5VAFGM3cENfgVM4x5YICYRumqu5yIVMdJuhaLXMAFWBKOIhbWFBiO44Dg4Usxx/cCrDyxqESMIYuu4lX1fYcGnVaaVmtKXZxHOzW5Bvfqtk3iLAFuVaLew4HluDUzIH1VYMZF+AgLMZxcAYY1uNYBTgrwPDIaqxOQ1p540IchBFTJW9c2ofNAO99Q+sYaugbJ35Vd4sKsPbGqVM33KsWmdpXLeXqufsVNwhH8FyhOh8n74foKb5WVDr0zFky1Rgt+iaJZyJTWErKMynpqsqgVy4q0xv0VTvZq0pJPq5jzn41zzzVET0aCYjmTO05OLaaBEwWqhvSenUkKtVw5P0N96mOpNr2YCPuh4AJCGEAoioDver7628Sx8WAcU2i1eM259AWhZBzuQEJieN07JR6sCHgXoSLnepI7yo9NqgCLE5A6K4hjHGKsVqK49JYEGyBg4XIq2b7FREUx5Xu2LkXOtmz2pJBW5sOqdjJF3sOjHG5fz7OT7n8DtURwjjPtBKtx7VLOa6Q4zh5Wkn8xhvU4xbG9al/s2bAbxwYkJO7XCGME43VIuMc56Dnqi7hpPE4cVopBLnibozTp5X4DHAQ49iwfsCX3IhxYFoJB8C0y7Xr1iwBSZXDulIUjF11G6+qr5aPALlCmTrfyWfQzCEK49xoPMnnjFMaq3QlX9tzQPuq0QFbLeNbMU6cHRn3Sb60HwJ6NXAhKQi61nzpPAbtQaY8jUUgQnRHSodxZSjjoig161W7HePIRGZDJzJHQXiEzE4DpRtSjotCHzkUkhj2qqJi4V54T1S6cWwVp/nhjAP1JQuDhbs4TtFW0spKTgW4UHJVFv4GQpcZA64jkt1xDNS8lDEv9Y3z5KpRGY4biIINMC7e2lxKNFJDqUfQquGZA2yrHoINUM7G6ZX1iVM2RKDUI08dssVUfduDRyI5QDkbFWCnscrWVWV1/RZ2uaRc9UyKL1LO0r7q1qwBm761WsmEUjdge9ApAB9iHHWslq4kMalHTbHQieO0zXKljHmIc4XdOE695yCpsg7eOE7t5B/4Uqv1uDSGKhDYq0r6yQWYj5NnRw5BNxjOHJAKRJB+nJqr4jcuOki4qOzs5qrgulSDJzJHUcyrCNMdOc44ty5nel815KDZ4HTypeoILAEfZJxbCjYkSpVKgZx/IpOfXgnarDkKXWIrHAm7kiTqxw1er+oQzg2Bj32FTcYJ2kpCIx9PK2XMq1ZCz+EM46LYZK4qaCsdmo+TqiOV5FWPITdYLZ2jOqYa/6LN8kJSZT1dxkSTJEYKmZ2/OuI5aIYYh+UzKn3TN9A9mLjL1cl6LexKkqof575xVJWVx3HRefdgUbGQNGs2U2Ul4HYQ60o+HeBzjCtt9VXVqXMpc3DEzh2NzEJSnr7OuG35wUTpPGjqXN3lQgdE0AWRA2sOHls1eO2yh/uqWM1LbUgvQzeatOhR5NZM39QIBNyQbviBVajYItbOYa56knCbrRrUj0vxTn5QVQlOnUtdrjKKztuqpbMEJ27WtCG3BzX9uMPfYqsmlW7SPnRfFeSqwTrAp9641VZtXi1PlX1VN44THzlvPe4k45aZLys9h+7cvuqsAqEpBAm6I9HJN24pZ9oIRzp5XzVUsVCZOnd0Ry4zbu52GdMBDn7j+NVyYXaEneW6+sbNrQcjtwdJCTh4WmlrSLcF3axRZ4AvMC6zxjj9annty1X9M8BoefBMQGKudB5UjnMnMltQV1JuD5JK5jnGTUU52zeke+4cfMJ7ygxwSZuDJ6EbzDEuZF+VNLnczCETlPdkdf3Tj5yhAHhNVdV9VXgJGV9JyqWjjRdS1fWRs6vmRctK1KuiLD/b22q2KyvlWJT1HOPeo3IWqyNwlwtrxJNrlwW69ZNr0qKnoBsfNrWVcH+w9gzIFXxDeisr5cxSrzCusFVWkpVukH7coF/0zQRt0a2QGZ1HLrfAuIfDOL/uiLOTz9UMMiTmtXMOVXmxW/P+OqM6wPBKEmLcbuiGMw4lq9cmIPbewa5iIb3LdYxxKHMouYDcSeRqcxd9+dS5VFWCGZd3e9DtR5+21dbYRd/1EAaagUC6IzDLV7YHj4pSKbmDkZRLnmRNcHeQ3azZdvLJ9qCUOVyhXGVmQUSpx9GWAzNW6Y0DmYMzrbTeHjzxxTeI41zktugXtQezAsRxon7caUt9VZZMMQ7pAPMnjnTyB5lxJHPgU+enGTeajONUHWB46wfW41jmAE79nHerNiYyFeXpBu/keycyM8983CWv+sxWLe2rsgpwH7qRxPuqb7pl6IKe61RPYpcbvefQy3e58LSSbwY4B071CuNKk31VtswlTyuJ+6oZuss1h3HVCTEDluZb7Ks6prqrjijlOLTLxRlXUhng85RLo+77por7qp5c1fUN8I1Tbw9eqce9ArkvA6eqxOOr5UQGgrdVC1l5GszHnYSuNsC4OKgeF6au73S5Mt983IU3bvwqcN3jAe9y9VgkvvHPskp7DuI9h7PfYOGNw3EcH7rx91XRPbNPT2TOEbCNNw7uJOGhG+naD8+5PG/cJcI9gYu/CxuYVuqd+6reHbgBWqrvavlV5LLvAqfdc6AFYElcyW1IS0eScqg7ch65/MvABXW5ElWvZXDiOL2Tz3VHzn7Vt4F7iNuDobMjwp7DUh3hfKs+EQCbAs43O9KgG9KDrK6vMe5qIPdd4NS7XFLi4NxzADf0eEPa8aqX1lV35REjb5zac1geuYVwtfjGbTmXsJH0qf7g14Hz9xzE9iD0qigewTv5F71qaeKNwz0HXI+jb5zLODABQWaAP+MbXA2SbxdH9KlzMjw9jvAUMr72o6363hQ4VyQ+lU+vkH70ALVFM2cnP8f1uOojhLPgVZnWI7y9Enjtcr+TT/qDJdj0LW9tqlgFQtUdYQfNQupxnHE3dw5aripmDgOcOt90gHOpOvKRF85EOCJKPSrVEa/y9D9QLDQEXKco3UiqVPtdrjZIIxNuSEeX+qomc9U+3S/WUIUgvD2o7nJ9UnfECnAPWQUiSOu8HYKERz6oO2IDuE7THcHOATIO9xzQhnT1IcblVhjnagRp8QjZVw1gHOFb9ZnSuY1OvutVe3/86w4Be7XOc6GvetsuF47jAq5dElFWn9a5oJF5YUDOBHCdds9BzRw2xrWy1jl946qrC6tfb0i7uWoKZ0eaoJs1e8LR+6pQPy66GMiNhqaV4ljbc/DqjrTC1fL8n/RVa0ummiI1r0a/yyUPT2dcXBR08s9Cl9gVpdKvEvgO00LB7qta585g4eP7jIuDxEXdaSV87TID91WdiUx67uf011lkHBTea/R6HN1XhTdr0AmROw9Pd1h5euurJvxKEh2e9uyrfnYn38q4vnp7cLchXXuVbtxdLoFx1UVtpWnv0uLNGudquTCROXj2HHI6riRK791zJakjIxDKRGatMI5fu8z81y4vzU5bE2yJmYLyFsc1jaythPcc+CW4j2grGVi71GTQgnLV1tFrQduDUj3uWvwb27p2Sefjel/PAXXy+QywoFh4IZKrTF67lC6I1H6NTHEGOBeWB88LoVm6dimoGaxO1a+RiafOpX3V8r7yGayOuZfPgGsOQhy3V4Fgew7wSlJ5hXG1aY1Msj2IK8B0BAK8cYIIxBXG9bZuD6ZUlCqk5zC0x/Yczh9YtSVK9ZA3pAN6Dqq6vnAo9ANx3Ndl0LazXPK0kq/n4J06F+45XMkc7Ajv0Sy/VzZrpAsiLUnyhZ38fQX4vOqIOXX9o9cutRlgfZfrSuZgTVxU9KrKPQdQOgd3CZB7OO9VzcnZ4pYDHddnkoVSrprlAXe5ynN5gxF1/Vi7ocenp7XdcueJyxSt8wtjhRYku2EcB3Hb1LxqHMb9192VJTmuw7DxSsfxdv/Tvn7TSceiAEpylqYnH/lWsWBRXABMVLHQ8B4cjvWUfN1xTYU6wJEqqy7y1ynBEIGt8ycqBxe2BGh3JEt3hO3HtXjm0KFJ/kHIOTDCmEUM2RFMH9ygn8N+WoNmDpcLZEgfFuz2pQPMKof7eHBME0RsxAVX3OFS1Y/Zj77jtGQ34nLRWjVeHtFF/pOIc2EvRdf1m/2UKy11s+8qtXzmAKQMhiNNTDefqiWtFIlkQqEbNJFuO7g6oqr84p8PC710IxN0R0bK5VIFV2svTx9CnCPTxspm1iiGiBKeptmh26tAYOXpp+y3HSGuqUwnONzIZN7bRAdYp4bDZpee5qq5OsAKcdTQISjykUjmM/aq3lRZK3rH6a5SOMmPZw5BQ47yQ05rvm3NVVXhkLCs0YqF2EN60A4iw8Ev1dtcNXvmsGK+qukh/QIRtEHE06cK1fXtKRfLqoTLRadcw8Ev1ZkTXBXzVdkdt5k1PvtQo/24I604520lvq0EFAvxXLXlytPHpjUXcRU4tTuiJvkx4EbugxHojrRJTn4p5jY3gcspucLQKW0lVnNhFQhF5ir+VhsvgZsN/Tji9cOcVybD6wcOuQ5MuXpxirhyt0tTea9NTPKLEVf7CdzMaZdZbpd0Pw6LZ1wiN7PhWGpwk1Uz/BzQDsSEnOB6vXT+cLscntoB3sQZ4qiaV/qOixjSJYgrBNwwu0OcSYKzzbe1ExwYrF6InFdpVp3EG+IIJSlsnWv9uEQ/DrMH497IcOgt4hNxC9vXv2b5ElhU32fuuF78IQ4r3XyreV3NST5V86K16uG6YRF3iIt1gJscxRbgE9oG88E2oa5fdMu14h9x5pZX2I9DuaGn+nGXmOdw6PHrvh+X9OWagGdNbzCkI5uk7NhpwHliSDf2sIY4wQHl6ZysWvoaqcUz4hLyGUrsfF85QIZIvASsh1zZsYsA54qTDyuHSAViM7wH+x6NarDWeRHiFpHT3HE1g5zldsk6wEDOdiiwJejFJeKYvaqtWEhFqShfFSkWHikaPHZH0qJUxEOvnK9a4CE9ibvACVQsbMLKwWTWGP6qMeKOAW6o3AWOXHHZ/TiD55BGXHZW3UScfqqPVdbGMjSLa1VVcRG+KmRI53fOOxGnn2piedpgSK9GB5h0MssBVzsM3AwdfXPuuFh3ZGLaonBUk3/J9eIfcXDmcC1RLEwotgTvuDzIDY3LwM1z0kMam/1gjcyWjQePq7VscjrE2YuFxNHMLFWB1vlwKDO4rlX1tj7ROidZNc1XzZJPZh/q73O5BPBVo90R5PaTyKqYPVhcdK3iGXHxJB8RRLT14KZYl1FW7RJa5zkf6uw2cJJ8x5kbmcDsx+yO6NglQreInO+Oy9oBNry348qh2M5hFTkH4sysihA3WXNVvAIciQSVtH2d745kdZUYQ9pa1o8QNxzLqO4m+eFcNRk6BLmWiHZ3gK+a+FZH8Y444q9qbuuTmcMLlad7Ee+Iq9gOcNJ7cFqZDjCXOs98AV9m8Y84OFitI7fLK0VcwHPoqZ+Dks+wPtRhEf+IS4kZ1ElqOZrW3CBH+ar2O24U34GT8rmqntWsif24jjFrrCtuEjkD4qC2kpqrjrQ9cpDLZXlIt+I+cEl/VernsB7Zj9PTQZIYKjkX4iCz5go7mYpZY2qdI77qH+M9MtRyGsQZXC5rrzBWnt77OQCNzKB2YIi7ipwDcZXJ5YJS54p32UM/h84WAmZZdZMTBE435LLt3sm2foajbyqtTnKCwCkVCFMlHnKSpkhev4UdYHDHke5IK2cIXKACYbuWm7UqVp7uzDsOI66bzxE4ogKBZg5ZtWqCIR2+4wDiLtl2s84m+VW8ra+YNXZ3BHaA4VwVvn8vjcipEJezr8/UDOgOMDeYYv24ZGXvtzuS0Y9jO8AT3QHmnPzhz9G4OZs5QKIvFgJW40FYqraAWRP4OQSRK4qbM55Dxpeqd4B/uiNTmj1oVg5ZhZbvKZdi1mBHMyIuanPydXdk97GW4U28GZqFSjdL8h2nkgN+x7E7bo+40rj50AHOkTq3NYIQ4tpolRXKi36/Q0rj5m2uWkV81ZS6/hRvK/XRyIHRHIby95v/d1y9WEk1lmW1uVx4XekWua4SOSHiKuZnZu3HYXV9yh6EPIc74NojBuQe9uMqUz+ujp4jI+2dt6w7Qp3ghuw+krNaNctBrwYqaNB7MHgAdyk/h5K+pdfx4GzusoafKujHRR3gDu/HhfpxfxF3lTMGbrZtCdB+XIi4KDegmQPagbh1zsufIY4QV2ltJcVXDTn5EeKKuFyqcmgrOWng9g05pZG5RFvnd8SNtDuiPKRbw9H3/ztumkVOjrg5ra2kEIe7IxBx4e7IA3DjMwf3eMfhh9xovH/73dZ5n9cBHrpFzhs4hbhgB5iqeaH5IGDWtCazZuhnOXHg5jmdVX9mDte0u9TjAQz9HB6Iu4zPHt2v7kgNe+cb3FbqeVa9qBfw39C1jZw9cMBDmr7jwqHDylzL+5Sfw2V9wcn9Iy5qZFoTaZRV9b7+k1nB55Sr2gEOaysFiFO+tCSrhqsj2yzyjyAu3lYCHnojyap85gAdfV9wu3l+x2V0R36INSvWAUbvuMvzydRprWogTmfVO+AI4uB+XF/JvxK4UHekMZRucHdkQhsQvdqPuwGurV95cl+LhUR3hPfjTN5lkFa78bUH97StdEdcOJC277h0bvgO24ty6RkQV5OtG5Pn0GIy19S8/OCeKofojlu47gjVT+4/EjZvdu9grnq1uVxAB1il1beEzRtBJJQICv1VMeKU93a0OzItbzq5k90RgLhl+XGCqy3ERdYrO0fftXnb2T3VqjfE5aigMbf3YANirN54co93XMjJT20rhWteP5Hrr/NbT+7xjoPMctOzJkqq6/Luk3u84+7vuGUBSzeBweoE3yPTm8Hm444LiA5gyMXuuJU56G3NR07uAXHVwwo5fgBTf1Xo2rjVnzq7r6yK1LwSr5HHHTdt9fy5k5/R7XLcJdX7FbeOy2dP7trPweQ57FRZx7r6+Mndq3ldEzrAY938ysl9uiQ1cJNVa2SO16X6tZP/dj8uDqJW2VfM/O/ftf7FmPkK3OMZ3MAu8G3T6ytiTTU7OK8jxMlfuN1idg/X91/9VUZ81WOVo8P+Bw+0DogP6NDPAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-ptz-bg-active.easyplayer-ptz-bg-active-up{transform:rotate(-90deg)}.easyplayer-container .easyplayer-ptz-bg-active.easyplayer-ptz-bg-active-left{transform:rotate(180deg)}.easyplayer-container .easyplayer-ptz-bg-active.easyplayer-ptz-bg-active-down{transform:rotate(90deg)}.easyplayer-container .easyplayer-ptz-bg-active.easyplayer-ptz-bg-active-left-up{transform:rotate(-135deg)}.easyplayer-container .easyplayer-ptz-bg-active.easyplayer-ptz-bg-active-right-up{transform:rotate(-45deg)}.easyplayer-container .easyplayer-ptz-bg-active.easyplayer-ptz-bg-active-left-down{transform:rotate(135deg)}.easyplayer-container .easyplayer-ptz-bg-active.easyplayer-ptz-bg-active-right-down{transform:rotate(45deg)}.easyplayer-container .easyplayer-ptz-bg-active.easyplayer-ptz-bg-active-show{visibility:visible;opacity:1}.easyplayer-container .easyplayer-ptz-control{position:absolute;left:53px;top:53px;width:50px;height:50px;background:#fff;border-radius:50%;transition:left .3s,top .3s}.easyplayer-container .easyplayer-ptz-control.easyplayer-ptz-control-left{left:33px}.easyplayer-container .easyplayer-ptz-control.easyplayer-ptz-control-up{top:33px}.easyplayer-container .easyplayer-ptz-control.easyplayer-ptz-control-right{left:73px}.easyplayer-container .easyplayer-ptz-control.easyplayer-ptz-control-down{top:73px}.easyplayer-container .easyplayer-ptz-control.easyplayer-ptz-control-left-up{top:39px;left:39px}.easyplayer-container .easyplayer-ptz-control.easyplayer-ptz-control-left-down{left:39px;top:67px}.easyplayer-container .easyplayer-ptz-control.easyplayer-ptz-control-right-up{top:39px;left:67px}.easyplayer-container .easyplayer-ptz-control.easyplayer-ptz-control-right-down{top:67px;left:67px}.easyplayer-container .easyplayer-ptz-icon{position:relative}.easyplayer-container .easyplayer-ptz-icon:hover .icon-title-tips{visibility:visible;opacity:1}.easyplayer-container .easyplayer-ptz-btns{display:block;position:absolute;left:0;top:156px;width:156px;box-sizing:border-box;padding:0 30px}.easyplayer-container .easyplayer-ptz-btns .easyplayer-ptz-btn{display:flex;justify-content:space-between}.easyplayer-container .easyplayer-ptz-expand .easyplayer-ptz-expand-icon{display:inline-block;width:28px;height:28px;cursor:pointer;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAMAAABF0y+mAAAANlBMVEVfX19fX19fX19fX19fX19fX19fX19HcExfX19fX19fX1/////Pz8+oqKjCwsKhoaHn5+eWlpaOqTaDAAAAC3RSTlP/3CaKxwJiAELtp4ri/s4AAACuSURBVCjPfZPREoUgCERXBdPRyv7/Z6/Z1aQp9oWJMyYLiKUrOIpAJBdGCldgbzBkPM/QEoTI3jBEPBRDhwEvChe08Q1Ge0ImvIq4Qj8ljrLdH77CyQPWlCdHC0Q1e9rmmuC+oQN9Q4LwcQg40L6eyqm0uEpXSUqe3fKpkkqL+Y/o+07SrahNEO0T0LBsvOitf4xsLqiNTB32wtqaVKosGLO2mhUrS93+PZ4D99wPqzMJVcbEyA8AAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-ptz-expand:hover .easyplayer-ptz-expand-icon{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAMAAABF0y+mAAAAM1BMVEVHcEyZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZn////i4uLZ2dnIyMjExMS8vLy+iXNeAAAACnRSTlMAYomLxwEm9+NCLo6DKwAAALNJREFUKM99k9kWgyAMRIMmEMLm/39tKaVKFJkXl3sYJ4sAXeQ3ZOcYd0+gRYblFBuFLYoS2ot5lpvYn8zJQ65TO2GVNmdCmQq/qczw4gjpejD14BgmhziEIvCjVRlPioftHW6A7xBB1a8CCUMvsuSqEkPM7eZX6h8GrQ67bYpNIbRL6rb4/k2EfVXKsgmqfQrW9qnGq96a28jGQG1ky2HXpVysyYyeDIhWq7le6ua9P36HD6+2GRi8iBZBAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-ptz-narrow .easyplayer-ptz-narrow-icon{display:inline-block;width:28px;height:28px;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAMAAABF0y+mAAAAM1BMVEVHcExfX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX1/9/f2/v7/y8vLUObqxAAAADXRSTlMA3IrE6SZi9wI+y0gNXAn3CgAAAI5JREFUKM+Fk1kOwyAMBQ04bJHT3P+0JVUMNMWv8zvSk1cipfjAKXHwhR7k6KTjYp7dVuWLug1XWB5wz96T/JD2O3Phmv0k5ypL6lVVFIPYpLOka5WKSSFvS0/BloHYlkza5HkMzrvVLo8ZlRr7mtFYWBBsBQ4BjC//GTxcGVw2PpOVHQ6fJj7qS4936OoN2K4e5yE6N1UAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%;cursor:pointer}.easyplayer-container .easyplayer-ptz-narrow:hover .easyplayer-ptz-narrow-icon{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcBAMAAACAI8KnAAAAJ1BMVEVHcEyZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZn+/v7X19ckk9ihAAAACnRSTlMA9+NCAsuKJsRiPv/2GwAAAJlJREFUGNNjYAAC5gxFoTYDBijw1FoFBIumQHjsUavAYGkBmGu0CgqUwRqlYNyFIO2Fq+BAnIGBJQrBXerAwLkKCUxgYELmKjBYIXMXM2Qhc5cxdCFzVzBoIXMXMYAcsRsMdgEdgs4FKT4DBqdAitGMQrMIzRkojlRB9wKaB9G8z+CMGjgshjCuMCjoWNxRAxYt2KGRYgJiAQAnZcjElaB/xwAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-ptz-aperture-far .easyplayer-ptz-aperture-icon{display:inline-block;width:28px;height:28px;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAMAAABF0y+mAAAASFBMVEVHcExfX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX1////9fX1+kpKRzc3ODg4PFxcW1tbXW1tbk5OT29vaVlZVmZmZ8vCMFAAAADHRSTlMAxGJ5Mssm9+NCiYtiH91SAAABAklEQVQoz41T7Q6DIAyEJQooUL55/zddhVazzZjdHyqXXo8DhWCYTWqltNyN+MZLuxP69UGti/vAsl6c0e4L+tQ2yv1AEbvecMhO5cXdYhk+6aO3WGrNAMwentlMz/ZAKIlNoRsqY2wtFWu9t8wasc0iYVN0LkQfrG1zbxNyrIBcntOQrH1Ukkb60QcxYF1xMA2dh8zWj6ZDsLCsIrL4Ds5Hm9FMbCEROWUB0COaLXEIZJKV7CKybGO7UuxjxY2C/TkMbxboKBQCxgMN6MCJQ6Ch/QjOZg/B13LGx8FDTe3IFvl+Bc9XBi3UWoex68qeL/vxmdyxyvz3NJ8f9dDef36HN7koIK2LjxB0AAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%;cursor:pointer}.easyplayer-container .easyplayer-ptz-aperture-far:hover .easyplayer-ptz-aperture-icon{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAMAAABF0y+mAAAAOVBMVEVHcEyZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZn+/v6cnJzr6+u/v7+xsbGlpaXNzc3b29vqh7uRAAAAC3RSTlMAyRjKA59J/3PzPhe1wxwAAAD2SURBVCjPjZPrssMgCIR1mkYtisD7P+zBCyZpM5mzv5hs0M8VnZvaok9BlXzc3FXbO5z0vtifFC5Kn8OL4UfxwVvuHm61d5Z0b6ZGZZwZpQAUosWsjVZntVS1sH3ZFo1IRVYfGXgx+VGwNkkIVbhq9/jm3cAhaNv1Uk3IA8mNn7D3kbQeWK3TLH2jCthrDFcTMwUWaKiClc9mJtJWhS3SF5BpJqMQW1b3xwnkDahMoHYomkeJRgSENA/MFsKML7fgoCBVbGvM+Cx4JcKWbWHKK/h1ZYS1Jy/nK3u8bB3KhzG5deMxtfv3aO7/Heq+9ms8h9fxHP4AHzAWU9zlWNgAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-ptz-aperture-near .easyplayer-ptz-aperture-icon{display:inline-block;width:28px;height:28px;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAMAAABF0y+mAAAAQlBMVEVHcExfX19fX19fX19fX19fX19fX19fX19fX19fX19fX1////9fX1+FhYWbm5vz8/Nzc3OwsLDi4uLDw8PW1tZmZmYgm6a+AAAAC3RSTlMAYmOLx4kn9+NCIVJiPGAAAAD+SURBVCjPjVPttoMgDMOJAqOU8uH7v+qKFN2c597lF5LTJg1VqQG3aGuM1bNTV0wWDtjpg3pq+IB+npyzcIE9ejsDXzDCrjccs+tOariF3n2OLyw5xko0vh9MDjNb9Q0hp2GK3cixlIApe4/JD9appR8SFxWAUFLg6n63iB1irnY1Jv0mlrok7nUdcZRa1YeshxBA9iijChlxI6iZEaBgSEL2tkRcymPGGJpqlbZ6uDg0WR/F0DwuMpxDkYwiIXA8hO2uMJdGCCK6teB8RQoY8xGfevQjxYQt25qoRwDT25MRBjZ7GtP/P/afa3LHmrflXa+ruf661Hvv+et3eAF6Fh3v+sSUGgAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%;cursor:pointer}.easyplayer-container .easyplayer-ptz-aperture-near:hover .easyplayer-ptz-aperture-icon{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAMAAABF0y+mAAAAM1BMVEWZmZmZmZmZmZmZmZmZmZmZmZmZmZlHcEyZmZmZmZn///+qqqq9vb3z8/PMzMzo6Oja2tpXGg+mAAAACnRSTlP/JomLxwJiAONCr+rW2wAAAOtJREFUKM99U9sWhCAInEpLBS///7WLEWy7p9O8qEzCMBIOQ15DAlLYsoegS9yFMKQ93skl4Adh+ZI54Q8pG5nxgKzkgkcsk4zhmQxRyN1OPHqtncjOu5AuppcJ6s1EHTA1YzC3Wgq3YmzGqpsmlwZAo7F8oLEVKoeE6+TbSxK0JJ/3FLOwFnUxzXuoltYDDMLoAlmYXLAWIrkqbdZKs+q4KBfkNV1uwGaBim9TdLWS3R7iGRvCNTPB7JvGlc5EXK8cKbrxooint73RzXh7Msl6Oj/uT/b62O9j8sj6gMXX0Xwf6jP3Zr9DtNAHTYMMXrXSK0YAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-ptz-focus-far .easyplayer-ptz-focus-icon{display:inline-block;width:28px;height:28px;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAMAAABF0y+mAAAAPFBMVEVHcExfX19fX19fX19fX19fX19fX19fX19fX19fX19fX1////92dnbs7OyFhYWjo6Pe3t7Ly8uxsbG8vLyG+Q0EAAAAC3RSTlMAiWJjx9wm/0Lti7mfpe0AAADaSURBVCjPfVMJDoQgDERFC/bg8P9/XUSO6CqTqA0TptNDpSrMpC2A1btRT8wrNKzzjdo03KC3zhkLD9imbeAFhd3sG2kvZQ2v0NknfGBJZKkhBM9MxOxDKBV1N4iHi0TRHYjN01Qi7/kK2PtyNDU7DAEJgDAAN0u1jsQEFEkcVVmrqjeXrkWRmC67eqbgG7bJyvkQSQkvUvec7szpek6t9ubWJSK/uJVSm+APzHKCh++DWWuH4plQKNYOpfappcjy2VvJn9744cjGwx6uyXjBxqs5Xuqsvf/9Dj8rLhRg+bQ5VAAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%;cursor:pointer}.easyplayer-container .easyplayer-ptz-focus-far:hover .easyplayer-ptz-focus-icon{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAMAAABF0y+mAAAAOVBMVEWZmZmZmZmZmZmZmZmZmZmZmZmZmZlHcEyZmZmZmZmZmZn///+xsbGoqKjt7e309PTExMTQ0NDe3t774OlGAAAAC3RSTlP/itxixwImAELtp8B2gZgAAADmSURBVCjPjZMLjsUgCEVpq60G8Lf/xQ62gvNeOmZuUiWeKHC1cKnC5iJAdFuwJXgmf+xg2g//G54OPuTOCUOEL8WgMMCLwgPP+Abj2aF38CrnBR7whw6Bo4fWUk7MMrQ2OrpAq0GspTLLgKg1wTailNITZA0EaTkZGjIAY5NwlATah5CGRMJYj50tFtlWiapsLvAPRdtL/WOmET7QzZyl5ywzp7NWsjBJ1odsragJqeJ9HGFNZoLaJw71hMTm0O7NeDE1Z6YsU5rGL69sedmXXz0ToW8PzA/oV09T8OJR32fb7+B17Qe3WwtC9PVbHAAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-ptz-focus-near .easyplayer-ptz-focus-icon{display:inline-block;width:28px;height:28px;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAMAAABF0y+mAAAARVBMVEVHcExfX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX1/////t7e2dnZ3W1tbGxsa3t7eDg4Oqqqri4uKTk5NImu/5AAAADXRSTlMAYieJ3MvE/0Lti4oh87zNagAAAOtJREFUKM+NU1sOwyAMY30FtoWS8Lj/UZe2gWpVh2aJH1wcO0mNqbDj4gDc8rLmiscEDdPji3rP8IX5fXLWwQWuaVu4gbKDuyPdsJMz3GLefcIPbJ6PDCEAFDlUAJiORM3NigQFAXAFlqOeRhWJyFFIHxNGvRrN0mp470U++3axGM2RAmXcXqKnkDSN0a9WIk5Sa01MpDXBQAdVtrA8lBhFnnKpsmoo5VBrhszV0KuJ5N2tP92O50iQjpzcctravoihdoi0Q1NrfN56m0VWzFBoje+OrD/s7pr0F0yUr6s5/LvUu/bz+B2ep+IHdMIV2SUZfCsAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%;cursor:pointer}.easyplayer-container .easyplayer-ptz-focus-near:hover .easyplayer-ptz-focus-icon{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAMAAABF0y+mAAAAQlBMVEVHcEyZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZn////c3Nz09PTp6enR0dHFxcW7u7uwsLAUKT0cAAAADXRSTlMA3IrE6WIm9wI+y0gNQZpqdwAAAOdJREFUKM99U9GShCAMQ8BF3Cmlpfz/r15dAe88l8zwQiQkoRrTEa3zIXhno7lhWxcYWNbtN/fa4Q/218VFDzf4of0O8A/h3TQfOGU/ytsOj9gPVyt8warkmYEQQAgABYDxTKROz88koS6AVIB1fRCNbSI1cVUy15Jq27LGjTtyzipPeWw40/IXQkrHyZSRmqw3LaQgctFNKYzYyGACfEXossLMojFEj7J0WfdwJ3dD9uY2X25tL0Hj45mTR87Y66u9IQFsDS1bL57o7JbUDNIofvpk08eej8kTe3Hz0ZwP9UFfv8OgfgBUByCEUZhYtAAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-ptz-arrow{cursor:pointer;position:absolute;width:0;height:0}.easyplayer-container .easyplayer-ptz-arrow-up{left:71px;top:15px;border:7px solid transparent;border-bottom:10px solid #fff}.easyplayer-container .easyplayer-ptz-arrow-right{top:71px;right:15px;border:7px solid transparent;border-left:10px solid #fff}.easyplayer-container .easyplayer-ptz-arrow-left{left:15px;top:71px;border:7px solid transparent;border-right:10px solid #fff}.easyplayer-container .easyplayer-ptz-arrow-down{left:71px;bottom:15px;border:7px solid transparent;border-top:10px solid #fff}.easyplayer-container .easyplayer-ptz-arrow-left-up{transform:rotate(45deg);left:32px;top:33px;border:7px solid transparent;border-right:10px solid #fff}.easyplayer-container .easyplayer-ptz-arrow-right-up{transform:rotate(-45deg);right:32px;top:33px;border:7px solid transparent;border-left:10px solid #fff}.easyplayer-container .easyplayer-ptz-arrow-left-down{transform:rotate(45deg);left:32px;bottom:33px;border:7px solid transparent;border-top:10px solid #fff}.easyplayer-container .easyplayer-ptz-arrow-right-down{transform:rotate(-45deg);right:32px;bottom:33px;border:7px solid transparent;border-top:10px solid #fff}.easyplayer-container .easyplayer-loading-bg{display:none}.easyplayer-container .easyplayer-loading-bg,.easyplayer-container .easyplayer-poster{position:absolute;z-index:10;left:0;top:0;right:0;bottom:0;height:100%;width:100%;background-position:50%;background-repeat:no-repeat;background-size:contain;pointer-events:none}.easyplayer-container .easyplayer-play-big{position:absolute;display:none;height:100%;width:100%;z-index:1;background:rgba(0,0,0,.4)}.easyplayer-container .easyplayer-play-big:after{cursor:pointer;content:"";position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);display:block;width:48px;height:48px;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAIVBMVEVHcEzMzMzMzMzNzc3MzMzPz8/Nzc3MzMzMzMzMzMzMzMzLVn6fAAAACnRSTlMA+duduRUwSGSD8toSsAAAAI9JREFUOMvV07ENgzAQhWG3lLSp6MwCViYIRSpG8AiM4FWMaPymDBKESMF/cQ0S136F353vnLuo3gp1kOYEoCXW4LFKIZAnqAXYICeASoAdzgG+cApwgF4EfwF+oDkCqIwA6gnyAKA8AaizQhsBAjzuqUHofInGIQbjRxXjMrTJuHDestR4Bng4eGrN0929PqNfzC6h06weAAAAAElFTkSuQmCC");background-repeat:no-repeat;background-position:50%}.easyplayer-container .easyplayer-play-big:hover:after{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJFBMVEVHcEz///////////////////////////////////////////8Uel1nAAAAC3RSTlMA+rbVFUecgC7rYhEEz+4AAACbSURBVDjL1dMhDsJAEIXhdeiGpKYWQVKDWc8ReojFc4ReAlPFFQazad7lIGkb0jK/WEPSsZ+YN5mZEP5UrZIP0vgE0Kv3oPlIJlAk8AJM4ASYwAkww2+ABfQg0ImgugPYsfNBVl99kA0AsjOArAPQpRTGHiBB8whxM0y+3skXNltsvMYriIWrpWPA80mFJ5qL3gAfB1/tcAt7rzdiV+HEgs1oBgAAAABJRU5ErkJggg==")}.easyplayer-container .easyplayer-recording{display:none;position:absolute;box-sizing:border-box;left:50%;top:0;padding:0 3px;transform:translateX(-50%);justify-content:space-around;align-items:center;width:101px;height:20px;background:#000;opacity:1;border-radius:0 0 8px 8px;z-index:1}.easyplayer-container .easyplayer-recording .easyplayer-recording-red-point{width:8px;height:8px;background:#ff1f1f;border-radius:50%;animation:magentaPulse 1s linear infinite}.easyplayer-container .easyplayer-recording .easyplayer-recording-time{font-size:14px;font-weight:500;color:#ddd}.easyplayer-container .easyplayer-recording .easyplayer-recording-stop{height:100%}.easyplayer-container .easyplayer-recording .easyplayer-icon-recordStop{width:16px;height:16px;cursor:pointer}.easyplayer-container .easyplayer-zoom-controls{display:none;position:absolute;box-sizing:border-box;left:50%;top:0;padding:0 3px;transform:translateX(-50%);justify-content:space-around;align-items:center;width:156px;height:30px;background:#000;opacity:1;border-radius:0 0 8px 8px;z-index:1}.easyplayer-container .easyplayer-zoom-controls .easyplayer-icon{vertical-align:top}.easyplayer-container .easyplayer-zoom-controls .easyplayer-zoom-narrow{width:16px;height:16px;cursor:pointer}.easyplayer-container .easyplayer-zoom-controls .easyplayer-zoom-tips{font-size:14px;font-weight:500;color:#ddd}.easyplayer-container .easyplayer-zoom-controls .easyplayer-zoom-expand,.easyplayer-container .easyplayer-zoom-controls .easyplayer-zoom-stop2{width:16px;height:16px;cursor:pointer}.easyplayer-container .easyplayer-loading{display:none;flex-direction:column;justify-content:center;align-items:center;position:absolute;z-index:20;left:0;top:0;right:0;bottom:0;width:100%;height:100%;pointer-events:none}.easyplayer-container .easyplayer-loading-text{line-height:20px;font-size:13px;color:#fff;margin-top:10px}.easyplayer-container .easyplayer-controls{background-image:linear-gradient(180deg,transparent,rgba(0,0,0,.37),rgba(0,0,0,.75),rgba(0,0,0,.75));box-sizing:border-box;display:flex;flex-direction:column;justify-content:flex-end;position:absolute;z-index:40;left:0;right:0;bottom:0;height:48px;width:100%;padding-left:13px;padding-right:13px;font-size:14px;color:#fff;opacity:0;visibility:hidden;transition:all .2s ease-in-out;-webkit-user-select:none;-moz-user-select:none;user-select:none;transition:width .5s ease-in}.easyplayer-container .easyplayer-controls .easyplayer-controls-item{position:relative;display:flex;justify-content:center;padding:0 8px}.easyplayer-container .easyplayer-controls .easyplayer-controls-item:hover .icon-title-tips{visibility:visible;opacity:1}.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-face,.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-face-active,.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-fullscreen,.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-fullscreen-exit,.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-icon-audio,.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-microphone-close,.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-object,.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-object-active,.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-occlusion,.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-occlusion-active,.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-pause,.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-performance,.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-performance-active,.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-play,.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-ptz,.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-ptz-active,.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-quality-menu,.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-record,.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-record-stop,.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-scale-menu,.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-screenshot,.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-speed-menu,.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-template-menu,.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-volume,.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-zoom,.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-zoom-stop{display:none}.easyplayer-container .easyplayer-controls .easyplayer-controls-item.easyplayer-speed{padding:0}.easyplayer-container .easyplayer-controls .easyplayer-controls-item-html{position:relative;display:none;justify-content:center}.easyplayer-container .easyplayer-controls .easyplayer-playback-control-time{position:relative;justify-content:center;padding:0 8px}.easyplayer-container .easyplayer-controls .easyplayer-icon-audio,.easyplayer-container .easyplayer-controls .easyplayer-icon-mute{z-index:1}.easyplayer-container .easyplayer-controls .easyplayer-controls-bottom{display:flex;justify-content:space-between;height:100%}.easyplayer-container .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-left,.easyplayer-container .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-right{display:flex;align-items:center}.easyplayer-container.easyplayer-controls-show .easyplayer-controls{opacity:1;visibility:visible}.easyplayer-container.easyplayer-controls-show-auto-hide .easyplayer-controls{opacity:.8;visibility:visible;display:none}.easyplayer-container.easyplayer-hide-cursor *{cursor:none!important}.easyplayer-container .easyplayer-icon-loading{width:50px;height:50px;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAIVBMVEVHcEx4eHh4eHh4eHh4eHh3d3d4eHh4eHh4eHh4eHh4eHiqaCaRAAAACnRSTlMAikwX3CxpwZ7zIGi5xgAAAZ9JREFUOMt9lb9Lw0AUx2Njqm4iGEqmEnBxslKUdhJctFMVcW5wKZ0CLpJJQRw6iVqQbg3FtPdX+l5+XHJ3796bQj557773fe8ujtOI+6jz5p84dHjTkYD4+RhT9CIRZWRPJr1bChnbY532GhT4oUpbI6HEuqvgIH9544dh9J4/rpr0Ms8oV3zMNT7X1MXSmaznzfHjM4n72moe5n8ryYrW9rKRvgf0S93JA7yKa9lbzUg3keJb8OVCtwkrFmoO4MnsAuj5rGqnZg+GZXUXkl9NjEui9n3YA9XgpMgakLXz6ujMTIgrCkPVv0Jil8KgKQN/wRN69hLcb1vrbR2nQkxwiZTGQ5Teb7TO8PUaS8Q03sE+zkjP8qbjzgJtEhRbV4gnlkOFeM7hDYNdxPbiYFvKSHN6L2NmY5WzMYPtplZdTxncRvn2sI+DHIoug22jWMaA12Y7BrXzrG8BX32XPMDKWVzw1bdMOnH1KNqNi8toqn7JGumZnStXLi0e4tcP6R3I635Nc/mzsMxl9aux9b78UVmn2pve8u6eR50j9c0/ywzyVl5+z84AAAAASUVORK5CYII=");background-position:50%;background-repeat:no-repeat;background-size:100% 100%;animation-name:rotation;animation-duration:1s;animation-timing-function:linear;animation-iteration-count:infinite}.easyplayer-container .easyplayer-icon-screenshot{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJFBMVEVHcEzMzMzMzMzMzMzMzMzNzc3MzMzMzMzNzc3Nzc3MzMzMzMwv5ahDAAAAC3RSTlMAW+8S2UGVwyyZnOTRhEMAAAEfSURBVDjLzZKxbsJADIYdBQpsSCyVMlXAdEuQYGKpWFk6dWHJgsQ7sMDSpUv3PgITAQT0f7ly57ucQ45KXRAZot+/89k+X4ju9KzL4XOhlm3pR0enYrWViSRPXQIQSASkRSkIJEFRimYCuQAHSW89IOv6SH5TCsuAj68Ab1wDzqkAzqoC7AUAPtgsABgkBBgkCJiNHehGok//KRVsHqd+3Dj1/vukt3AH/Jj05s5/AmyZhFVWXDls44iVvfQWkCvgxU6g9ZdJfCLvjJbYaT3GvjOY4mQSG3SJGjhr/Y1Xohp+TGKqqzexZ/1GVGdNCitt6R8zVvb9d+JmKdl8o5sPWbtxT6zFuJcDQtk92MNmYiXHquYlZlVt1j4P6cd7fgHFW7Nhqu29TwAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-screenshot:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAALVBMVEVHcEz////////////////////////////////////////////////////////NXt0CAAAADnRSTlMAWe+X2TINXUYZvctoYyuS2NgAAAEVSURBVDjLzZKhDsJADIZLCAsEg8WgEGCWGSwCgZxB4MgEAonB8wQEXoBH4BEWXgPJgEBG0mdgR3u77raRYAgnlq+9+/t3TQF+dKbZcJXSYSnzlViT457lRScKmBqILSFA3GoO8S4E+Ex5JiSJ4CbVdyOQdZNomX9D4dl+ko3NC8vFFmhPy8FIsi0ZlwLBW/LY5BxYYreUSgoFAEmhB5Rc9OCbUoXmTmDadQKTn4y6A/XTaoSKdb6KyGU6RJ7eHgpb3ABinAoil303xB6vQnRahNhXvMdre+fzOgxVrokX4jHAnBh8PALU8Eq8BqgTg/vePF8tpuPy9/NFaalSc273RizarYqfkswjifNMQ/TyTGMv4v87L+ks5gqDbc9OAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-play{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAIVBMVEVHcEzMzMzMzMzNzc3MzMzPz8/Nzc3MzMzMzMzMzMzMzMzLVn6fAAAACnRSTlMA+duduRUwSGSD8toSsAAAAI9JREFUOMvV07ENgzAQhWG3lLSp6MwCViYIRSpG8AiM4FWMaPymDBKESMF/cQ0S136F353vnLuo3gp1kOYEoCXW4LFKIZAnqAXYICeASoAdzgG+cApwgF4EfwF+oDkCqIwA6gnyAKA8AaizQhsBAjzuqUHofInGIQbjRxXjMrTJuHDestR4Bng4eGrN0929PqNfzC6h06weAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-play:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJFBMVEVHcEz///////////////////////////////////////////8Uel1nAAAAC3RSTlMA+rbVFUecgC7rYhEEz+4AAACbSURBVDjL1dMhDsJAEIXhdeiGpKYWQVKDWc8ReojFc4ReAlPFFQazad7lIGkb0jK/WEPSsZ+YN5mZEP5UrZIP0vgE0Kv3oPlIJlAk8AJM4ASYwAkww2+ABfQg0ImgugPYsfNBVl99kA0AsjOArAPQpRTGHiBB8whxM0y+3skXNltsvMYriIWrpWPA80mFJ5qL3gAfB1/tcAt7rzdiV+HEgs1oBgAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-pause{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAFVBMVEVHcEzMzMzHx8fMzMzMzMzOzs7MzMz4IlKVAAAABnRSTlMA6xIU1hVqIuOVAAAAMUlEQVQ4y2NgGFYgLS3RAEQziQFZoxKjEqMSaBJpEAkgIw1ZQlBQRAEs4QhkDeIMDgAWx1gMHyIL4wAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-pause:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAFVBMVEVHcEz///////////////////////+3ygHaAAAABnRSTlMA7OgSFBXMmAA4AAAAM0lEQVQ4y2NgGFYgLS3JAUQzi6WlJY5KjEqMSqBJpEEkgIw0ZAklJSUDsISikpLQIM7gAJjhWp6XcaOxAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-record{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAHlBMVEVHcEzGxsbMzMzMzMzLy8vMzMzMzMzNzc3MzMzMzMxEZ/aQAAAACXRSTlMADPKKKeBxlV6neZ4mAAAArUlEQVQ4y2NgGDZgJhpowCURAJeYpIQENJEkCgWRgCeShAGyjfgl2EqwS7BFToZJiLg4ICTEImdOh0pwRM6cDJcIjpw5E6aDFeh8B5gECBCUYAkKCoMbNXNSOlyCgUEQ4apJJmxIEkjOVWFgxi4RgEsikGQJnEYp4pLA6VxUDyJLIAUJcRLIwY7qXKSIQvOHWCQODzKIleBPPjgTHM4kijNR48oGkajiYUMykwMAAfmZhUjBISQAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-record:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJ1BMVEVHcEz///////////////////////////////////////////////8NopmKAAAADHRSTlMA8gyMLeRw1x2DBpWGN2QDAAAAt0lEQVQ4y2NgGDbgDBpIwCVRAJc4KIgEZM4EwCU2KSEBHySJCcg29iBJGCBLgHUs24FdYlnNYZiESksDXKJALebMaagES8yZw3CJypgzZ2A6WIHOd4BJgABMgh2XBEtpaBjcqDMHs+ESDFyLEK46aMGGkEB2rgQDJ3aJAFwSUSRL4DQKp+VHcTkXxYMoEkhBQpwEcrCjSCBHFJo/1GIO408MOJMPzgSHM4niTNS4skENqnjYkMzkAEgzyFpeX6L3AAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-recordStop{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAOVBMVEVHcEz///////////////////////////////////////////////////////////////////////99PJZNAAAAEnRSTlMAMPndsnZj1CSYPcmL6wsdoU80pOJLAAABu0lEQVRIx5VV26KEIAhMA++p9f8fezatFDPr8LSrjMxwiWlqzRuMYKW0ENH46c3WuGyVLXEduuO83UyK59fl1jX5EEUXD9DOaSh43XEP5zUIdZ4pAecTofVnWSt3ip4rx7N61vjnY1D30CpH4QQR8vsP+RA5Rs3KpjfMU/pMim/LgbvH7DF2F8sU0owqapKLqgnhuGWwImUagn2zhUX6WQQoYkXG9WxSAJd700/ygsCpAoliaDsPiG48GM1X5Ft/06sfp8DrDE+3DpekWjxM6366fgEcnklC+AIIWYQmPEeAaUmjFOnhCLDfxZRH+w1gU5b/DYjfNcyJ0p7dxX8B+FwxQVtvAGB5ig0d5gFA5KbzS91hI8CenvlHflfN/XvzJQnxbBEko1gbvVnPii+FadSVRUEaYylQfJtpLB+aRG4LY/80yKdUbCraM0lozGR4ewZ0Wtnj1iC7hjWKNnjYmR62W15cLlL3+2pyMR09jccyuyUrHKsvthc5xsY1iWJ0Xk3t+2XP7AnWwrAQmBH6asXubmL1Z5Lz6o992jWiu9lnMSiQsK27FS9NxhCumZgB2fTBPFsFolhZr5B/D3o9sJAI6skAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-recordStop:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAMFBMVEVHcEwimP0imPwimP8imPwimP0imPsimP0imfsimPwimP0imPwimf8imPwimPwimPxLmg1rAAAAD3RSTlMA15sisGUvdz3szYwMT8H+hDJEAAABx0lEQVQ4y3WUO08CQRCADxBQchBiMDE24KswFlw0Wtig/oHzUWglJBZWio3GDjUxlhhrEzT+ABMrO2iptLLVRluDggI+xtmdXW73LkxxNzvfzuzszNwZhhDzdOxqaPGgYrgkOgFczh90ezAJQmpL2v6OHYnqk2aWxOTtAnu/O/Y5XNZXmTZjo3ot7aESwLdFeqAM0MoJkMf9ltwVQJ9PcQN0UFIJogvdJgLQVFMsAlxyBaPmVBDCE8W7qd+2SDsx0q4OwhSrCG134W54jDfKLjDNxaL8/9AAMM/solptRnoALBbwEPWYrOEzLnrZsTGoMW+fBHG2SiLPUNI6KMOH8QS/XsCMBYQekIEv7NGZF/Rht2yqmA4i3UG9O0iTqgMfhirDhRdU8XJZqqEO8tDAqje8IIt1r+I5HmBjfD9AxQ1MgJQRpc6GJRALHOAS1WRlhMs4VaSFzwIWzCUF3op71kdNsNs/FDCuA58YqCQl7IhN3WbDnlLtfjnuON515WM17c7w41QPOuBIzDT5wqi0T4ESGV3gjtTjkuPATwHoX9+cPRlmmvJ57YAir2qKy459QL/UhrS/uAu3xf8KiX3DI+b22t6jc9F/qfaum9E1pJ4AAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-fullscreen{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAALVBMVEVHcEzMzMzOzs7Pz8/MzMzMzMzNzc3MzMzMzMzMzMzMzMzMzMzNzc3MzMzMzMxdHBitAAAADnRSTlMA8AwGYt0aUcg+til5kgmZywUAAAGWSURBVDjL1VM9SwNBEB12IcGkMagxNktQSZFCYimIJAqKpZ3Vco3YBYs0NkKQgBg4ECtLFSFVCGgQrERBsLayPE0Ip7n5De73BdKLTrE3ezPvze6+GYDfsAQKy/Rz0i/OZJjY9XREuohTKulS+ZFGiADfyZXU5uHktI44VH5apDx554aXwJqloiIwiEsStAjCAsRNF1jCmGqa4Vc+BvS4JkjwzyPE6xiwzsxxeTbZxqjkANSWZFkoIj5bQBl4aBDfkPDNpeRRialB+SRAFz8UU1sAaEUjSCDoJ7iukZJ1V+c01bFczM1pWaa+a0Rp7MHn4V8Z1R9vLLCv9WjKdVFfk77JP+bZdz35YAfKXx6KhKp93abUYVbrj49g9aAYSuFCLbPUwzdCsYEWTloXgw1oGwQbENeuKwxzXhxwAADRMFd+zzRc6AAASY6RH8VjUHaXTrlOpDgCUP3gelc01e2d+f16cWbnQ46BGCRNVsWAWQJVw2xGfUXVv2k1OsLfazXqblzS99u1FwKFvBJioXBY2+r82U75Ab7O0ypVV0wKAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-fullscreen:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAANlBMVEVHcEz///////////////////////////////////////////////////////////////////+GUsxbAAAAEXRSTlMA3clDHfdfDQbsVG00u4Cqkr04dRsAAAGaSURBVEjH7VXLdsQgCPUBAROdjP//s1UTDUxsz3TRTc+wC94bHsLVmP9hkE8LIdvgupt2tFhcpy2CMZyVxNePEoqDp4hwEGz5PTqWoZNzLrmD9riltBEYzzpZQ8bweXy56Qy6Tivsp5JQYtawuMH3eJlSxIJtdSSa4xer4lMB89pK23mKrwjZVpsRzLq35vEE3+r26h6w5EKppcp3fP2lIpTPWJvoXoobeNI1sM3haHvx56tu2sdElJ54GbnPQ7RZ1sCpl8qPEMXBNQ8vN82jNbzLCPzGSDOZj/2Bqd19R1rELIEbDFrUJfKYdlALbDuDMko/hz7t8DqtCfr8h1Vt4rn7eh/6Ph37ch20aW8McsfGCOXzcr+GOlQG1rJ2HSHUDO/4Mu01qVAqTCpCJfgZ3phTS2pKm5aZOMUbs7Q6nk6L8UzRh6W78jH+gD/VRxHokPuNgUGTaPPR+zDR1mrlvcGgwkAVacSbeoN4Z0rb5/6XLrW/2GTLk2NhXHRKzrqAt9cD4rr4ddvae0NAYgOICdZyvPj4UYRf2BdfbB8iWvnTUwAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-fullscreenExit{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAG1BMVEVHcEzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMxi4XDRAAAACHRSTlMAf3WqJmy+7azWNnMAAADNSURBVDjLxZQ9E4IwDIaLfMzCOTDSOz07OjLir5CR0dmJFVHIzzZtnMzbOzcyZHnuaXpJWmO2ji4GhpAzzZeQzw8FKCj1pMHss9OgpwsGOS0YGOcVUMPsfBVkmJoVCBJW0FFB6SFIaMKAlRGDnEiDkuM00lP3SmL6H5QSh+iIr9ZWVWntUV9Z4qWbHAWrhcUYNLC4Wwm3xb1r2mOQYoVn2EKFAVb81KHiQQq6L3vSUoMBUmSzgCKbVeiL3eTp3Odf8H1sxRAZZNZt/Vt8AHcPQbiQQVF+AAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-fullscreenExit:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJ1BMVEVHcEz///////////////////////////////////////////////8NopmKAAAADHRSTlMAe4Fzh7MZbKPtN8gpX19xAAAA3klEQVQ4y8XUIQ7CQBAF0CWhKQHDGtQKQFcURUgqEARBED0Aoqp3IKnoATAEW8MNOACmhQYKcyi6uyjmr+aLqXj56bSbVoh/J3HBxcw0ZfA2c3FiQLGeQcWh1lOVDDJTAeCbCgAR6QqCDj0xCEU5Bl2BIALKMwhdKjGILRUYfCIOEynlvABANk64M5jabJxHfJY2I76yzYu/ZCc0s1WbNYAQ3jxqwMoGHoqWGHpUQajEgcYYcKWFtjLE4FGJQewoxODRDQOqKPPcHl9sfzSXa/0L349tEDsOsp/8+2/xAY+BZBY9KhM5AAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-audio{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAIVBMVEVHcEzKysrMzMzMzMzMzMzMzMzMzMzMzMzMzMzNzc3MzMz8gU00AAAACnRSTlMAL0jMZKt96hGJsSKv1QAAAJ9JREFUOMvN078KQFAYBfCbJEw2q6SUyWxTnsJT2JTJ6D38Gb6n5PpT6BwbuaNfTnz3fEp9fZwAP7czD0MsGCzBYJcEYsGwBEHQQRB0EII1CMAWdAOzyJUvJ4jyDVyZVHKGpj9guEI2IuhaDFadYnCkIm9I+kPgn8t+kI7kOsT72HcwQnJR9Gofy8DrwwtHK8pLzdeALg5fNb6cdJ1fOjOGYrl5CLFcggAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-audio:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJ1BMVEVHcEz///////////////////////////////////////////////8NopmKAAAADHRSTlMAL0TQf2frEaZYt8E+idL4AAAAnUlEQVQ4y2NgoDdgUcAuzr4Hh4TaGQHsBp3BLsG+BoeE2hnsEkCDsEqADMIqATIImwTYICwSEIPQJFhnBjKInUGSUA2CSPCcOcIwB1ki5xRM4iiDDrKEzQlsEuUF2CVY0jbgkDhjMLQkEkj0IM4gQQ1EHMHOOXMiakRpTiQQtXgTA+7kgzvB4UyiuBM17myAM+Pgzmq4MyfO7EwjAAAEf+BAxqI/agAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-mute{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAMFBMVEVHcEzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMztXryaAAAAD3RSTlMAHd4P7ztyiy1OnKhdx7uY2gyAAAAB8ElEQVQ4y72Uu0vDQBzHE45C3SJFaSGjUEiRpJRCBifXokkpSv0DfOBrEKxUUSoFH9ClFAUfU7c4OARRCs5WjThIsJuDlLo4ldvPe8SYxGyCt1zgw+dev+8vHPcvYybvfCR2OgUv2CoLdI62bUn3gq5UJxOomZofXPUNrIChJRklfcDSiKK2bYQ6PiCaREk0EQoYPFYa3F73F+DGsBJLmAjBAMBKakG15KAxqIhd2KuK5reRccBDNbqGJhfSlnNc/kBh4OY+vaoR5QrRC0afKgxMrKdXNKI8yxRENpyd+i0VA6wMm5IOBmORCwfAFjGwolofevbuPrvpGhRgpVaqiJflrLuUQQFRToS9l894EMDe7q6yL7/G5wMATc5mQCiAvQo3HAbwLtyYHQZgTxhohgGUa/CP12EA16W2/Ou4ZEj1dNG9oPMkZGiwJWQ8j+huPoJy9Z/XHTfUFSbAURveCtE5px5vs7hQDKS25FSDn2KR5Up1/lRmIHne7BvKd82LMRJbSjr5M40lmaYZ5/PRpiCpizjJyk+CwOGOzACLpSdz02QxkiuRhd8dNOwkV7zl2YX1mcySKJrQiPkXY9klSt6rkJPRwIlmzrcWSGyzHuTb11V/N0y/S6SdwdCR4m/47OIN7XOQCfwJwHGp8IcfyRdBLEZK4Uxp6wAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-mute:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAP1BMVEVHcEz///////////////////////////////////////////////////////////////////////////////9KjZoYAAAAFHRSTlMAbk2o8o0P5TsGnVojFi/XHcV9urLaq0oAAAIQSURBVEjH3ZZZkqswDEXxLM8T+1/rkw0BuwM0f131+IvDyZVk6SrL8p88QCHp8UAnWmoWoG8AwQRN4/vOiqwUuwWqiob646MMhEW+KnMLMIXffgiZoODBusb7kCzjByF7OOszkOyp4amJ7fWVPwCN6BpyWRypvANPCvi7u4aTXe13YI+KkYA5bMRTSMlLnSyGwisSH40B0FJOrKVB6iAw2U7sGgPgQ/DTPQjitCOZT4Q6gWCtGwGFbSM34ENUNSpAKTACmC31rnRgJwjDdkFAJpfkAsZcAJvCSVQB2FaWWKdB/ATMAHwIUYL21lRBZRDiC5AnsBHBUqxEyaraFMoz0AnvHNa6xDWS34FGgNf6PYAEZoCt+BroUWFVbeb5HbCqSvB2cToyca+Adjlycdawt0C/HeyScl1W/w3gsU3aAd7JF8AuAN6isr7NAogXAFeq59Ec7ifAm49hF8wCMWfVNXAeCAkjEGuBr6R5ZGJzBrl4gGniBME+w8aMMyCsNZtfaemnmYaAQ6I3Rz0fnDhHJxc93Vrr7sHWjP3XRtTba2L3EkdFVaPC6YmXxKI9DGF1YPLdiwfD2r37cL5nDVw+uKzU5K27hsXCXPtyC2uyyl0D0p2TY7VaIvFYWU0Dm8TdOXmrVp52HG4lU4K/N38PpS/Kw70dbmb/sC0WCcQwNNzzjrzUj7veUyIIyL/4m/EP8V829O8zh5EAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-ptz{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAM1BMVEVHcEzMzMzMzMzMzMzMzMzMzMzNzc3MzMzNzc3MzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMxDm1AzAAAAEXRSTlMAHqw+E8It/gjxc03jhGDTlgAjE2kAAAI6SURBVEjHpVbZkoQgDBwg3Of/f+12gtfMbK1Yy4NampCju4Ov1y8ruNyyo9fyCibVlNW6vUu29GpWQwTVdPTernqwffHex0WP4Nro3k+PrMKCvew/PcZ95aoNsY9yua+cGxTZsnf2K7ch4CAdGnWwYx/5LgKZCgxGdrhH3BeqNmnwviFXPZbQJmcM25HJ5n7/Pczr2QqksMJfO7BJOHLKLWFdMiL1QXYRwFagMklb4GB1zS7s8Le3fqH7Q28tVLkKdIzeaOJB2OKtY8KfTQCUa4++dNsLbrqpTR7xguHGt8hfg8P+seuaEkNdBjahzOD7g1cHP21SL2LtMNBKMdTRJjffTX1wVgrsEb1ITJU6QknwYJAcQky2cE02NbzPp70KyKggtpu9xM7Ik+CBIqY+8FrYyRUkrs+MEm1TG6tG9LZxNDNFGDue63TYGgIHqUUcuNhvhyZtn5LnlDq3Juxa4noCuX0scErOpNMDCrVcHPCS5rFGuQR9KZpxnB6CQ0ZO+AIBcTPk3UdbTx1L7jLEEHsMW7ZYm8NlIFyxn8+xdL7MURYEhzd5k2N2TabxIAORwC2r00QQfNSgrnqTJfh7cDmDu9ggtV0EZFr7kGu4KAxtNDln406TLwF9iZCIwn9EfjPuncRHYm5x3NfK3cFAS5kWxljSnTFlPHBAUFg5HsCCVOd9cdwXq+027un2QJlMjqISJutCDceRtTTuT4+1Q3HWHR8cu0fh9sGvADTYH9iLah/9nPz5+/MDJnQfoIVoAnQAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-ptz:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAQlBMVEVHcEz////////////////////////////////////////////////////////////////////////////////////1bZCPAAAAFXRSTlMAeVoYDS1pBiPv4/g6lkzO2qSxvoixscijAAACi0lEQVRIx51W2ZLcIAwcLnPf+P9/NS2wp5xkq0ziF3ZRC3R0i/l8fvi04oxx89n+RBi1sqB38TKw7lw7lNzDa3U0e57bHhJ4d567HlqGC08eLAj9Gv8XD4/OwtsdhlfCW2s9LfWtuNrMhG1uLWP17Xh14LF4m8dx1OJ9jkm85YCYch5JzDVy81on3MFYkpTNYGmHHloYI+aqlNhlh5ZSvmH1AyBUwPcMX+u/clW3XYvA2YgRGXyZIZX6PXv0l3GlV9Jp9FKcK7mytJIg8xEeBdaBtV4P8tAixexnp73tY7ZBkrk9WEL8t7ZUDqtIA3jXa8sODSeUVqw5aztT+g4QeNAgM0PGTA0+EmfVeUvU0CEW4hX+lt/zseE7jJKDSmi0EUKBhr7EAMKPvNjOA9Fz4Yk/CFgcGRSdkYOHCLRxQfzKRN5SB/b5Ot8SzzQiKqcb6ipFdCfi1JI84OBdxzarhJ8RkpxHOQszl7bpn0GpmnXq6R4OfTkwwlyUWzeQg7rSLNhNUzEUEqJF3DMHeeXgqRIaYwHimLKipK8hMZOYVfJ5oKtIFSgXk5z4KcNx3GOIPGYfPigh9YGHBNQKVKbZhxMnqq+OHfWBHARZfWm1dnfSXfJuXInplse8wy39zkisdQ5kuLY+Bpc5hwGiH8Mx1rE24DFaLqXkfrNVkjk+8JPTPF0bUw+R9MCVuA8ks/xDyF/9orMqpBQeiob5RbIbmv7/TxvoX1Oqa914TsYg7QUWx8Y7R89JQY8mY6Dat1G5GARuMOgYHY9cbL1vNvc++fk67olLk4nrQSl7457OPqdeKn+vEwm4LPzW87DyXvqIyei9znHS+cZz9SxV+Qf8nNbjn37NkDx4+PmCXzHOLUMtjgmUAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-ptzActive{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAANlBMVEVHcEwgmv8imPwimPwhmP8imP8imPwimPwmmf8imPwimPwhmP0imPwimPwimPwimPsimP0imPoLqfILAAAAEnRSTlMADprCJBnU/gXwh3LiUKxAXjJ/ELXKAAACbklEQVRIx5VW2bbjIAwLa1jM9v8/O7Iht+09MwPlpS2VwLZkJ9f1lxVG1joPdZ0u1ZIxurhv8DH6dMpQI5t439GAEc7xYPgTRnAtV7plReRhd5kDP8+fd+wzt70yPhIJzWT7/6DCJCAYLReZPMIuJC4pClSktHqbNpJO1aTmmAme3cvtWs9NSfq52CPhnJNjlbVHwgmWSWGHeQHcKFjj7fygwidf2fa4mbVOuladcnsoDn9/CKKAWf6HEtpANiJvUp9Fgr0SvocPP/sqjOCK9ktpyCAo4Kt/d4n4/6baseNKAt5XrauPN1A4ZLAd30RUI4kNfELVx+yd3lrXYIg1Bp/B/dGs5N8mPsJoVyiwkofQSlm+K9aiwmoQMDoI4wefoK/rhkESrSuV+BR2i6HZH9juLzxCtBmn6rFmB66gNJQwBOSxncT/N3FAlxAoLQfJDy2+6rMLI3aznl9fhOcGSdZzoNhex2K3TXJEVe3M4Zb6QhHuJc5BWakYIqqietcPw6FK+EHofUHRqtLEQ5X8dKVENXXgEpLOpcjwkFI30YFVHE8fyx2ShZJ/ydTKlZwZ4BCOv/af9uMi0DILe4kieynScgPbhai+DRDckTT6N6zJpI3HMghM3BMg+q9pHmwrbR0Q0D5wc0JHPy0E5Ur7Nf3Rk68LnR0NHfO28/T5P4cNr+uLFR7eEdiNxvMRbd5Onlqsis4iIVdme4di3akWOz+3T0aUnFWHa8QZrO51NO69MeLPafrNuBenxel/3d21j8k/jyxf+75OQabFxOtuT94G3Lpjzb0zBn2Dl0ep/waPidQ/p/XB60Dp7e8F/QO7WSJg4zEzdwAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-ptzActive:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAANlBMVEVHcExru/9ru/9qu/9ru/9ru/9ru/9ru/9svP9ruv9ru/9ru/9ru/9ru/9ru/9ru/9ru/9ru/+3uxEqAAAAEnRSTlMA5q0cR/PC/ggSKtN5OIhaa5izIOiAAAACV0lEQVRIx5VW2ZLjMAiMToNu/f/PboNsJ5PaKWv8kKRkWkDTQF6v/zyUfO+JX9sP1dKKd/v2acQcm992kbo1R4il7iHIif0BRNtCUOozH4cikAdt2YfjRLTnzN15/8I85wFCI2xDzlnyMLO7R0aFoTzbFGB+jIkYLkyePvmW8d2fs2ZfZuv8It9s6zvV5uSr2LmKb9oVh37QvpjYOcf8fcO3Cb1jGqOU0SvTTd6X2KUBLgKdLzaiDtE2n+isTh8/+AX7E6/Vh/NNSyfVm10RXIe1nxXRapmsDQB7SMnkmE0IxgqvUn0jteEf1T2CHXgr0gjZllGk1HoJL7lD7fRpD20CgJcwQ6EdSh3lLK0zVfuqz2WvPlPJh7HqnCQ4MysxoAYQE0vHub/toRuqzRy5pEUvbg62MzlJQn1MHBe1x7WSAddpNDSN1c9wRMhKfi2jrICwAIsQvHkD7Al41bOrBNC1Y7QdmSg15LDokGETJB/imxYJKfmFMDqI3FjUkDS3NSEDjBaxknRYSb+4nj4kC43W2OKrkqGB8jV2Fq03YiWbhHQTpUV1mMHXWYf8HlNX7ZUQRC6iwBAIK0r0ILr1UxqKsPattAkhwSIiMl76bT/Ft/TbTy2jHQoM7Cz9isHVMb6GILl0H4DGivbw7xNc8rAtiJn3O/qvD6JT/wgs7Y370ZSdWmbZWEKiG1lXImldW7Q1jGMbZW9tUVKZmGjjGvf+EXAqzWiX5OfFSHVp/zjbfGPc3whdcbTF67V2N1e79qYMru2/AnzVYFsdWFt/+nOypv8vQvoHou4gOtSrG5EAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-performance{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAnUExURUdwTM7OzszMzM3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3NzW8hQDoAAAAMdFJOUwC/gO8ra6tUQNmVEKtAA1gAAAE4SURBVDjLzZMhT8RAEIWnpS3tXcWdQ6wgOJIKfFdUICv6AyruB5w4EuSJCwRXgUBWkGArLsEi6JVuaZkfxawguSWz/p7azLdtdt97C3ASagp+PpeXPDjHVx7McMWDCBc8qPCZB4m44YFIeOBh+ckCf9z+sCCYqi8WvA/5Nwu26cfA+JRBs4h7WmX/tr9AXcQHAPdgzEPZh5idTQBOZ3zyiModISKQGxZ7dd85E0SKfMGjM7vXeI/5AE5LvrwpcK9IOrQYB5BlCsFIvjzgrkaSjsBZbmC9XsGsAxfn8gKXpL9sSlnQFBwFTTuaKWXgI5Ar+sfHTrW6DUDO+2jEEtCNQ9wL6gNujMvvdFS3eugxGT51fBXxTvF1wLLngbT0BGphKalAy0MQ3Z4Ha2V7UoMFJKkFVAWcvH4B0OJfd9YsTl0AAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-performance:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAzUExURUdwTP///////////////////////////////////////////////////////////////8/RimEAAAAQdFJOUwD2qdfrViyAwW2XORBGtSCsD6SyAAABN0lEQVRIx+2VzQ7DIAyDYfxToH7/p10CbQ+T2s33Rb1MijM3/qDG/EurolD9zSNRggBU0hFelMABmenfADhGkJDhGUFGgiX6I1AAQlDgZK/td8ELtQORiTmIq42I2bYdCD8NjzPmYQxO+rbn2S5qzEUF6YjkgcJude56X3s0SoL7LRAeylyaVPiFq0Jyx230mpeXmXVOHssRbhackhCq25Sny++xcBW1n6Snqw6BTgrqRP6kzfDcgmRLGonDWSf2OecwB491dOrEVZpNsxiyiHzWJ0Z+BbBwzaoWVb49HrqVfSkxHen7WNznLhzl8xpQlT3E9oHUtYaufB+7NY9g9ctbjFfj/h1DwXUrzDltMn1Ql9M814EQWPLmEBg4R7JSzpFQxTmSBMkLvJKOhFHfKEEnv3L/+qw3DuMPzAFH9pIAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-performanceActive{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAtUExURUdwTBGW2xKV2hKW3BKW2xGW3BKW2xGW3BGW2xKW2xKV3RGW2xGW2xGW3BKW2+P2IvgAAAAOdFJOUwC/gCvzq1RAleURc9VmrA9rXAAAAT9JREFUOMvNkzFLw1AUhU+SxtTahnZyC+IsIeAenDuE/oJQcS/FTYTi6hKcHYpDZ/EXBME95BeURpM0Me39Db4Mgk/u23umcL8kvHfOucBBKEr5eW95xoMjeuBBlyY86NOQBwt654HrPPHAca/YuUHrDQsG9eybBWa1+GLBqvS3LJiNX0vGJw/R0N6LJ+/f6x9I3uwG0D+luRU0FnmdCtBy6ZM7KvQdjgXwJYuNZVNrFfqF8IX+nFm/oBvyS2iZ8OWxgH4u1IZmU4kgfoa5E77c0jwhoTYCbTRFGE7QrXFCveCURkK/2cRBCp2gFYiyWk7Jw4AgXOmQZMAqa9uAeCP+JsViihtb9OKIPtBUuvy8jeqyHRpMhvc5X0W6Lvg60HrPg0DREySOoqQJKRbByRWbExaqlSoVwB0rwCLFwesHquttxhcsa64AAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-performanceActive:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAnUExURUdwTH3G63zE6n3G7H3F633G7H3F633G633F7H3F7HvG7H3G7H3F6xOzy+EAAAAMdFJOUwC/hKbvK0BT2XURZct0z00AAAE3SURBVDjLzZMhU8NAEIX3LiSUNqI1qBMMChFRgYxAd07E4CI6HQwzEUXgKjC4CH5ABAKJyA+oaHqBJO3+KPaYYSZh9nyfyuyXu7l77x3ASSgu+flYX/HgHOc8kC4wwikPMnzhQaTueKAiHvi43bFg0m4OLPBM9sWCjyb9ZsHm8NkwPiUQT8MjfSX/fn+F/C3syJf9YB7oLsDkjIaiHix5QCNbGBmAFPve+3lXi/0viLB3ZnmDz5g2ICry5daAvCbZhSE2oIsFeC35ssJljiQbgZitIY7nIGu4wLG+xBnpL5tClxQhCANR1Q5TSmCCQK7YjftOVbYNUOxot0EsHl0uwHdFfcD14PJLG9W9HfpMho81X0V8MnwdcHvkgS4cBcqVo6QKHQ9B1a6XY1zAcSiIFg6QlXDy+gEd714RcAqEowAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-face{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAeUExURUdwTL+/v76+vsDAwL+/v7+/v7+/v8DAwL+/v7+/v96T4QgAAAAJdFJOUwBAgSCbs9hZap+hQJoAAADvSURBVDjLY2AYRkAJCAygbEZBQUEBKJtpJhDAOJpA9kSYxESgKphuIaBuhASqyYzESjC2hDRilQBZ64BFgm2qMLPYNCwSkQpAwlMBWYIRzJsKYrKCxZSRncKSDFYzBSNY2MD2MqRhSFgqgClPAwwJBxwSbAk4jGKZDCKZp2JIsEOcOx0ztjQDYL5ENwsYJKrTsMSvGSgepzVg2pE5qSikPRPT8sopBuDod0ATZ54JsbZyBrJgAVAp1Ax2oPXMykjxYQaLA2CMoERUZQDMrgBUCc8CKIdzAvHJhyQJpLQLSu0TCaV2lPwBSu0KQy+LAwBuJj5UbruNggAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-face:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAnUExURUdwTP///////////////////////////////////////////////w2imYoAAAAMdFJOUwBAgBvfrFmcw4wrbtGliFoAAAD2SURBVDjLY2AYRkAJCAygbEZBQUEBKJvpDBDAODpA9kGYxEGgKphuIaBuhASqyYzESjBu79yIVWIP0NoCLBIsR4WZJY5gkYiZACRqFJAlGMG8EyAmK1hMGdkp7M4gkus4RrCwBIApFwwJmwlgqsYAQ6IAIrEAwygHHEaxngJbfhRDgg0sxHoMM7Z0AmC+RAPsJ4S5NE5gid8VoHg8sgHTDh/PzM60HkzLc44bgKMf3RKuMwoQ+dNIgswJDAycUDPYjhgwMCsjxYcJLA6AMYISUTkBMLsaUCVqEqAcngPEJx+SJJDSLii1HySU2lHyByi1Kwy9LA4AqflRBKNSA88AAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-faceActive{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAhUExURUdwTBCT2xKV2hGY2hKW2xGW2xGW2xGW2xKX3BGX3BKW23povfoAAAAKdFJOUwBAgRybs9hZLG6hrV9tAAAA80lEQVQ4y2NgGEZACQgMoGxGQUFBASibaRUQwDhaQPZCmMRCoCqYbiGgboQEqsmMxEowTgmZiFViFtBaBywSbEuFmcWWYZGIUgASXgrIEoxg3lIQkxUspozsFJZkEMmxBCNY2MD2MqRhSFgpgCkvAwwJBxwSbAk4jGJZAbZ8KYYEO8S5yzFjSysA5kt0s5YKc6guwxK/baB4XDYB045Vi4pCyrMwLa9aYgCOfgc0cY5VEGurViIJMhcAlULNYF9mwMCsjBQfZrA4AMYISkRVBcDsCkCV8CqAcrgWEJ98SJJASrug1L6QUGpHyR+g1K4w9LI4ALk0RHtSETFcAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-faceActive:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAhUExURUdwTHzD63zE6n7H7H3F7H3F633G63zF7H3G7H3F7H3F68TinBIAAAAKdFJOUwBAgR+Z31ipwW4yAjb9AAAA+UlEQVQ4y2NgGEZACQgMoGxGQUFBASibaRUQwDhaQPZCmMRCoCqYbiGgboQEqsmMxEowTmmZiFViFtBaBywSrMuFmSWWYpGoUgASXgrIEowgHtsKEJMDLKaM7BSWYLCaJRjBwloAploxJKwUwJSXAYYE2KUMVRgSrAFgKhTDKPbFIJJ5OYYEG1iIfRlmbGkVwHyJBlhWCDNrrMASvxageFw6AdOOqKCklrQuTMuzlhiAo98BTZx5FcTarJXIgglApVBr2ZYaMDArI8WHKSwOgDGCElFZBTC7GlAlvBKgHK4FxCcfkiSQ0i4otS8klNpR8gcotSsMvSwOAIs+RIlIrewIAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-object{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAA51JREFUaEPtmT1oFEEUx9/bnRALGxE70btkZjcR7QMiRisRbCzEQvxCLGyEhCDRBC/RoNaWFgYLFUSwUBAUDKKFFqIQ3OzNJpfCyspS8HaejNyG87J7t7N3l03gttydefP/vbcz8+YNwhZ/cIvrhx5A3hFMjEAQBDwMwzOmAi3LWhBCLDTr5/t+ycSubdtLnPOncX1iAfQAlmXdNBmkru2RVgBSSspg+5kQ4lRjv1iAIAgqRFTIMIju0i2AWNvrAKSUowDwLqP4tACm9rWmbABCiFxXKimlhu0BtPFHtdc19wj4vn/Wtu3XnPOfWVByA5BSngCAuwCwryb8Hud8EhGNltANB/B9/5BlWXcA4GCMx/8g4jjn/H7aaGwYgOd5BxhjcwCgPd/0QcRVAJhM2l3rO3cdQEq5GxFvEdH5VsLX7aKIH8MwLLmu+zapb9cAFhcXt/f3988AwJip8Jj2L2zbLg0MDHxr/NY1gCAIpohIJ2V2BwC0iUd9fX2lQqFQ6cQvtJbICSGOxHhlVOdKjuPMl8vlqzrxI6IdWUAQ8Um1Wp0ZGhryiYghYrUtgDQionxJT0al1IwGkVJeBAANvieNDQB4joglzvmilHIXAIwrpX67rmuUamfKcxoTvnoQ3/dP27Z9g4j2J4C81KBCiC9LS0suY2yMiC7rttoZuQBEQhsiopfT6wAwUvv+hjE2XSwWP0kpRxBxgohO1kPmDhAHEgTBUaVU1XGc98vLy8eVUhoqbpPLPwIx6/wqEV2ovX8AALzZ/Ng0EWgQGa1iLQ8xPYCUyx8YHjt7EWjm2I7sAy0it7ERqNWEDkeiklIJg8pFWwC1ZC6SM9NYc1oXgcaiVlxVYmVlZW8YhlMAcCnFvOkEQPqqRBqASLTneTsZY3pjapZSpwF4Y1nW7ODg4Ie202kTgGiwSqWyrVqtXgOA6Zj0OhGAiF4R0azrup87dqDJAlA/eLlcnkDESQCI0us4gOdEdNtxnK+tfkHjA027AJEgKeUVANBROVd7p3fixwAwJ4T43kp4nR2zylynAOoE/JuAiPiDcx6kFb5pAEwF5zKJ2xXZrH9uc6BTUD0AAGh639Xo6bjUI+G/NglS+p3Y87wCY+y/2ozJSGkuRDLekQFjbEexWPxVryfpjuxhllKhNtwtAESc55xHx9M1hsR0WlcOlFLHTLyv26Ypi5hesyql5oeHh3VBeN2T6TxgCtXN9j2Abno3je0tH4G/KbtRT7VUKs8AAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-object:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAwdJREFUaEPtmTuIFTEUhv8fLSxsFrET3UIQRHtBRNdKBBsLsRBfiIWNoIisD1xfqLWlhYuFCiJYKAgKLqKFFqIgoiBoYWVlKbjwy4HMJXs3M5Nk7tzZCzfdvZPk/F9OHicnxIgXjrh+jAG69mCpByStB3AgQ+AcybmqdpJmEvv9SvJhqE0QwBm4lGikqD4VAaCMvh+R3NffrgzgB4DJDCPWpC2AYN+LACTtAPAqU3wsQGr/pikPgGSnO5Ukgx0DNJhRzZp27gFJBwE8J/k7B6UzAEl7ANwEsNEJvwVgmmTSFjp0AEnbANwAsDUw4v8AnCZ5O9YbQwOQtBnAdQA28nXlp/NG8HT1G7cOIGkNgKsADtepDnx/C2CG5Muytq0BSFoJ4DKAUxnC+5s8cSCf+j+0CXDBjAJYNgAA6+Keg7AwpldyAXqBHMmpwKjYyThJclbSSQBWfyIT5IF5kuQ3SctJzjcCiBHhxUu2GM24gRx1IGtj+gDw2I34Z0mrbXcC8JdkUqidFecEAj4fZD+A8wA2lYA8NVCSHyRtcGvouKtrg9EJQKHVB7Ht9ByALe7jCwAXSb6TZP+dAbC3D7JzgBDITgDzJF9L2u2gQoectV0yAD7IEffjDgC7plaVJQdgYotdLOYSMwaI2gETr51jD1SN6qDOgSobw/WAywltLxRVhBIxi7LxInaxUCHHFvmCpFkorWInoR8LheqsA2DB3LGIRdPIAznBXC1AIVrSKncwVYXUMQB2Sl8h+SYQOCanVaIBPJAVAM5aqBAIr6sAnjnh78s82aoHQkYlWYwz7YXXIQCLRK+R/Fg3BYcO4HnlhPPKIfefTYX7dm8m+aVOuNdP+1OoSow79KzKL5LfY4UvGYBUwZ0s4qYiazzY7RRqCtfZIm4qfGBrAEDle1e/0FDoUTKvUxiT3gfsaWlBbibFUsyDiKSkBK9nf4LkH19P2RvZ3cxUIVoEmCVZXE97DFXPrJY52JUy+lY3Ji2S8cxq4i3jsahk3QdSodqsPwZoc3Rj+h55D/wH5CHfQHNA9EUAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-objectActive{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAA9JJREFUaEPtmU+IE1ccx7+/N7O0BwUn24UeRKOd7LalvS+I6HoSwYsH8SCtLf1jEqWoyLJVMfEP6nlNIgi6eFChCB4UChaU0h7aQ1GQrnFSdw9e/JNs9LTFzPvJZI27m8xk5k02m13I3sK+33vfz/u9N+/7fo+wzP9ometHF6DTGfTMQF+mYNqwd6sKlFLcK++P3WsWF8nkUyr9stAeTcXN624xrgDVAUgcVxmk1lbaGPIFyFocou9fSonYzvo4d4BsYQLgaIhB0EYA174bAFaNWpuFhrthxDsxQQCMrKXUPwGbvfr2BSglYh39UjmwXYCwy2kh4jqegd5M/itdaL8+i5vPwwB1DMDIWNuJcBbA545wAs4V4+YIiJQ+oYsOYGTzGwniDIANLjP+hkCHiglzNGg2Fg3AGB3/Ugj9NBO2+4ujSSaMeJ2uc+PbDhC5aK1GhU6CeY+/8IZz9E+CnSomBn7zim0bQF/m4QqbPkgDOKgufH4EAzdZaKny3vUP6vtqG0BvtnCUwY4p01oFcOIZuCJ7elKvvo9OtLyESMN7IzeViA3VC3TshiY4Wkz2j0Uyj3+aMX5shAIhuia4kn6Z+DSPu6xjiCotAQQRMeuXaJJYpqsgOetbcBV8TZA+ANxgotRU3Hz48SWr7800DjHL6VJyQMlqh/I5jYZvFsTI5XcRa0cA/sLDv98iieMv98X++Sj7aEBCPwjwD9W2LNMdAqhJnQMyc5D9DGBwRhzukK4fK/647q9I1hoE6DDAO+ZBdh6gEaQ3V9hi27JS3tf/u3Hhv20kpQPldsgthQw0fOcnpc3fVK2EhosEmE33x9LJwKxM54Lj/Ap0SeoCBPz+qVw7uxnwmdQFOge8R1n0DDg1ISaxqSbJy0oE2pTvqhStbOK5FQy2ka6vOTVkoL6o5VaVWHX+yVoh7KMAvvPbNq1mQNmNBgGoiV55fry3R+jOweRpqQMBMO4wxImp5Cd/tGynVQBqg0UvT3z4eroyDMaxenvdHIBvE/GJYnzgb69MtjUDboMa2ceHCTQCoGqvPQBuSOZT5WT/fb8luOgANUFGxkoQYVja+Lq2iQm4ygKnS3tj//oJf9+PamUuzBJqJsY59Jz/9wh6+iJpFoIKXzIAqoI7solbFdksvmN7YKGgugAMNH3vqp9pN+vhtq5VMqT2PpAbjwrW59VmVAYL8iASCfdGBvm/bpQPrCvP1eP+RpYrXA5XKgTaBkA0Voqb1eupL4DToFo5YLlVZfadtkHKIqrPrFLIsXL8s0k3LaHuA6pQ7WzfBWjn7Abpe9ln4C11Qo9Pmb2aMgAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-objectActive:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAA8hJREFUaEPtmU1oU1kUx//nvthx4cJqX3RgGLsQBNG1tq8Z7axkwM0sxIX4hbhwIygibfPMeyapunY5iymzGAURZjEDAwoVm8SPhSiIKAjtQtAmiooLiyb3yEtNm76+5L37kjQp5C2Te879/+65H+eeS1jlH61y/egCtDuCNSOQyH3cWirNHVIXKO6kYvqdenbxqVlLxS8J8Txp6Ne9bDwBnA5IiIRKJ5W2LDHsB2BmC6zqmxk3UkP6AbedJ4CZfTsNcL9qJ077VgHU8r0MID5V2EsCk2HEBwbIFdT8M/aGBkgaelt3KtOB7QKEnU9NsGt7BMyp2cOa4P8tY3M+DE/bAC7cK+xnxmUwtjvCCXzFHtRHiEhpC11xADOTjwG4BCLDY8S/MvhsyoheDRqNFQMwc292QmppEPb7i6MZgEdqna7V9i0HSNx/95MscRLgo/7CXS0IWS6VrFRs8+1ati0DSEzm18kesgGcURa+3OAfSGklY5ueuP9qGYCZzceZySKC1gQAgPkvXtNjpXatn258CmlYSOSSg/qwW+B8usH9SSM6Ec/lTxM7iR/3hgEh4Jpk2Kkh/UVikiP2MBUbAggiYjFfchajtB0QM/fuOFg64D8H8QHQTQ3CsowNT8cffdLnPn8+KyXPpWKb1FLtYJ0tbbU84asCyRYOEmiMwTtq+P63JJAYH9AfxTOFbUTlNXRyPlmTdpsAKlIXQZyDDJJGGbx7/l++BSHM5EDfg7HMm91CRM6B+fdqyA4AWA5iZd/++hWymDaid+OZ/G8EGgXB65DrhAi4Jw3NsORj5VRC4A8AW+tN2Q6KwKJM54b2HcD3EtMFCLojqVw7uxHwGdVQ992OjkC5JqSJPRXw2qlEsMpFo1OonMx9/7gE211z8iirLC1qeVUlxrLvtwgU4wBO+K2bpgCoVSX8ASqiRx682hgp/jBaL6UOBsC3pMTFdCyaaUI6HRyg0llicnptqWfdeTBMd3pdH4D/kyQupgf7HtaKZIj7gDpAdefxzOw5IjECoJxeewEQ6CZBpmwj+thvCq44QEWQmZ09BYjzLHFk4SQm/C2KIm3/svGZn/AFP+qVucYi4BbmbLnOb5rGr+zB6MugwjsGQFVwWxZxoyLr2bdtDTQLqgsAQt33LvdIe6UenvNaJUQqJ3Hi3ut+KSNLajMqfQV5EAnzRuZoEF8ivfZw74dqPbXeyP4MVSoE0DoAmkgafeXrqS+A08CpHBDTPpXRd9oGKYuoPrNqETlhD/w446Ul1H1AFaqV7bsArRzdIL5XfQS+AaeCtE+rbksUAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-occlusion{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAACCVJREFUaEO9Wn2MXFUVP+e96X5oa9UoYpUszrzzZlqLKDYhgAFaaKU2+M2W9Q8TNUQSQEsiRUjFVaHGNmoBMTUmaPwD2iIhqKR8WEBFGkLFUjbtzDtvpjYrVhpCXAtm1867x5zxvnXm9c28mR13b7LpdO65557fveeez0GYp1Gr1d4VRdF7lL3rui/n8/lX5mMr/H8wDcPwIgC4QkQuAwAVWv9eA4BJy/8sAHg7ALysf4i4DwAe9Tzvj/3uP2cA5XL5CsdxNiLi5QBwUkQeQcRHrNB/JaKZZuGYeRAA3gsAZ4nIBkTcAABLROS3xpjdpVLp0bmA6RlApVI5FxE3OY4zGkXRdkTc6/v+c3PZPAiC80Vkveu6Nxlj9ojIjmKx+GIvvLoGcODAgTctXbp0CwBsEpGHEXEbEf25l83a0TLzh0RkMyJ+AgB2TE1N3b5q1ap/dcO7KwC6AQDsRMQhAPiu53m7umHeK00YhlcDwC0iMg0A13ZzQJkAlKmI3A8ADyDi9Z7nnehVsF7owzA8Q0R+BABXIeJY1mF1BMDM3wSAcRHZ5Pv+nb0I0i9tEARfRcQdxphvFYvF8Xb82gJg5gsA4FkiyrylfoQVEScIgttyudxLhULhwSQvZhYAuJCI9qftkyrckSNHzs7lckdFZJ3v+0/0I2CntRMTEwNDQ0P3i8inAeCUPmLP8/Y2rwmCYC0iPl6v19+3fPnyvyT5nQZAmQ4ODv5aRF70fX/zfAk/OTk5PD09rcbg4/EeiPgPEfkUET2dALENEc+dmZm5cuXKlf9unjsNADNvBYD1AHAJEf1zPgCUy+UljuPsQsSPpfD/m95Is29h5rcAwO8AYC8R3doWgDopx3H2I+IXs17/XIEdOnTobcPDw3ry6zrwCKMo+kypVDoU01hreK8x5oJmZ9dyA0EQ/AwAhnzfH5urgJ3WVSqVd7iuu8vGTB23SLM+QRCoOZ/2ff8Ls2oXf9DYJpfLPSgiH+nGgfQKcGJi4szBwUE9+Uuy1orIQREZKxaL5WZadaiI+Ey9XtfbacROszfAzL8wxtQ62dysjdvNM7MGcSq8Rq1ZY/+pU6fGVqxYcSyNsFKpjDuOkyeizycBHBeRjb7v/z5rh17ma7XaSBRFuwHg/C7WPYWIV3fy9kEQXIyIu4no3bMAqtXqZcaYnUREXWzSNQkzFwBAhf9wF4v2RlG0sVQqncyiZWZ2HOfaQqGwr6FCYRhuE5E3E9F1WYuT83qluVzu74VCYWfzXLlcLuqDBYAPZvEUkYeIaBQR61m0Os/M9yDiG57nbW4AYOZnAeDWpAPJYsbMNwLAD5TOdd2L8/n8Hyy/FfbkV2bxaKgB4s89z5u1LFlrmPlSANhKRBfGAPTBrCGiatbieN7GSpoaDut3IvLa4sWLi8uWLXvVbvBUFi+NchFR00/V6+16ollr7AGpaj5JRCMxAL06VaGWNLATM2ZW4dc00yDinZ7nbdLvrLXQaDZ1iMi9vu9/ySb/BwHgTAC4kYh2ZIGw6ekbRJRDy+AlIjoja2E8X6vVilEUtdhoOzdBROdY4fcYY0Ydx0kDcQ8RXd90m+qVH9P/qwPTf9WcK5+YJmnemfmE67rnIDOfBwA/JaJuLEWDHzNrAPZwGmCNGnO53HYAWA4Aoykgvk9EX0uuDcPwBhG5KwahAjOzqqHqewNYMwhm/hMAXDMnAEEQaP76vTY39v4oiiZd1/0VALyzGYSI3OH7vubVqYOZ9fE3NEENin1LDdqkgZkFMBcVqlarG4wxv0mR4nUiWqLfHz58eGTRokXfdl33tnw+n+pVu1XZNLpZFbIq0fKIm6yIOhX10K8g4t1E9IDSa84wMDBwHBG1WNU8NIObDReY+RYA0EqDhhJqbQ4SkRYI+hotj9gCaDGj1Wp1lTHm+ZRdvk5EDdVh5h9qiaWZBhHXe57XCLKYWVXoygSPk0SksX1fw3r4FjPa4shsVqanP5DcyRhzebFY3Hf06NG31ut1fWQNT4uIWzzPu0M/d3gjTxPR6r6k/+/htDqyMAy/Y4zRPOCmmLn1zprYJ8eriLja87yJSqXyScdxHtKSi4YCVvgxRLyvjZCpFqhXQEEQbHccZ9rzvG/EsdBFIqKmVK1AYzQJl8Z/NH4PzHxV/NkCuAsRb0hb1C4x7xUAMx9GxGu0ONycD0yKyGcTuegLAJD26K4joh+nbczMe7QolZwTkZt939/Wq7BJeq2nIuIviUgr3v9LaDSdFJFjKR7vtMcYOxXVRWPMpY7jCBE1PGiz84k3F5G7fd//Sr/CW80YR8SROK2cvYFOKSUzr0PED2hGZYw5ISLHrafUx9QI2uICmFY1RORsx3FmEPE5EXne8zz1mn2Pjiml1d+ekvrmqHO+K3hWvvZJvb2ensoqCwmgq7KK1eGttnuyNqsSvVAAtGINAE9oF6hjYUsB2EaG6vWx2La3U96FAmAt28jU1NTqZOMjtbhrGxovZJXVFwJAXGYHgPPS6lVtS+dxY6PT41wIAFpe79To6Fj7j9PCdmX2TvF6vzYzLqtrgyX2MWk8M5sXcaNDRLQjeft8Vaxj4bQSLSJbEFHjsraNjZg+E4AS2obHTzRb0kxsvirXVm1vBoAT9Xr9y2kNjeQtdAVAF9kQW5PseW+zzszMjCcbGe1UsmsAMYOURveTc62nap1TRNYsSKM7eQIaO7mu+zkAWAsArwPA45oXdPNTAxutaillsTqoKIruW7CfGqRdpRaHReSj2lvo8scezyDiY1qc7dda9axC3W64UD+3+Q/fZENVhTDr2gAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-occlusion:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAABphJREFUaEO9WmnIVVUUXSuiuahopOLLIqTBBgtCC01Ty8JmS/sRVESBNgiVJVZaaag0WBlGYNEPrSyiQdTKskEjpNKSCBqlzAqJSAsbYMV67vt13/3uffe+93pvw+Mb7rn77HXOPntY5xEdEkkHAjgk1G8k+VMnpuL/oVTSaQDOBnBmGG3DfwHwXeg/DMC+ADbGZwWAZSRXtTt/ywAk2eDLAIwAsAXAkvjY6O9J/pk2TtLOAA4FYDDnxmdPAG8AeJbkslbANA1A0gkAbgJwKYA5AJaS/KCVySWdCmA0gFsAPAfgIZLrmtFVGYCk3QBMDeNfAjCb5MfNTFY0VtJJAG4FcL5BALiX5B9VdFcCEBPMB7ALgPtIPlNFebNjJI0DcDuAbQCuq7JApQBC6SIAiwFMJPlzs4Y1M17SAQAeBTAWwPiyxWoIQNJdAKbZbUjObcaQdsdKujHcaTpJ25ArhQAkDQKwmmTpLrVjrKQdANwJ4FOSL2R1SRKAwSTfz5sn1zhJhwP4BsAokq+3Y2CjdyXtBMDueRGAv32ISS7NhN+RAF4D0I/kt1l9fQCE0lcArCPpyNARkbQrAAeD81IT/ArgQpIrMyBmA3D4HkPyr/SzPAAzIzYPJflbJ6yX5ARm48/J0f+DdySdWyTtBeDtyDlTCgFEkrKvXVV2+lsFJmmfMH5UAx1fAriY5CfJmIiGCwAMSie7uh2Q9KRjPcnxrRpY4vP7hfGumcqkT/SR5POyjeSVycu9AKK2cRQ4vUoCKZs9J5ocFMYPrfDu2sgBn2fOgjP2e7E7tdopDeBpAF83irkVJs4dIslFnH3eVWuZ2IWdwDbkDZTknHAEySuyADa5uiT5TtkMzTyX1ONqE4ALtzJ5C8C4Rtle0pCoXg/uBSDJPjmf5FFlMzTzXNKRYfzJFd5z/PcCujRvKJK+iFppRc2FJDnO7k5yQtnLOb7tLf2RpIu9XpHUP9zmxAo6X3R5TvKfCmNt7zwAvztPJQBWA5iSTSBlyiRNAvBAjBtC8t1YkGNi5Y8r0xHPn0pHlrJ3JJ0BYCbJwQkAH5jhJL8qezl5HrWSW0NnVItbyP4kN8cE9ucycVh0+2m/nlM184drvkmyJwHgrbML1bWBjWaXZOOHZ8bMJeluzdts13I1WyQLSF4dzb/DpsPsJJJuaBpKtKd2oR0ZClwJug6vJOHfdTE6XlxPckAY7xbRbWceiHkkJ6Z201l5efw93T8dzkNP7d/Z8C7JfckAAxgI4AmSVSJFTZkkF2BuK/OkX/TKRweALIj7Sd6cfVHS9QAeTkAEALuh/d1Sl5klfQjgmlYBuEqdVQDg2KBTXgawfwbEDJLuq3NFkg9/zRMcUOIsJTuQrVB7AZiAataFTIu8mmPFVpKuNL1LTmB3u1kpyqqV/LUY7HYXisnqDnEqijipOEObVXuEpPtiG+dGxP83WZUWd3C95YIkN+hmGlxKONqsJel6pi2pO8RhUF0YlXQKgDU5s9xGsuY6kh4MiiU9bHRCUEmyC43J6NhC0rV9W5IXRusSWaywV98rnZURJFdI2huAD1mSaaeSnBHgis7ISpLD2rJ+++L1SWT3RB9ghqwmkgzKjX1WNgMYRnK9pAsAuAxYTNLRxu+5l1hYYGRuBGoWkCQzgu4L7kjOgP3WodRRIAGQGJen33VLch7GJr8HAIdCh8Q8yW3MWwDwWS2EkqvS/YBJ2UsyvehHAPIO3QSSj+VNLMkJzKRUViaTdNHYlgSf+jxJk8R1DY3byQ05GS/vMNaSSvii/VEkaxlUUjr5JMY6gt3QluX/eYZLlJ6k+KvUUkpyqj8+OirH300pALWiLSHAJJnVMK/kusqs9RqSTjptS3C0+S1lrF5TTX266uw0gxf2FTf1McDkUWVapZsAKtEqAcIu4FJhZBkT3S0AwVib4lxCspjYCgC+yLBf+0DXYnuRdBGAI5trK+efuouPInLXodMhtCGt3g0AKZp9YB5f1Yhe923JokaHs0sATK8XXnSUXXAkbWEuzd6oXm83ZkpKaPVpSY7J01l6eZFcdESX5cu3jjDWiXHBRLvpcV1WeLGRjC8FEAfbienx6JZmdZC5tttOBuBkeW3ehUZ2FyoBCBAurWv3ZdEPd/Ka1W5Td5FR5JKVAaS2OHvRbX6mJT41eE5TM52/6M6uQNDxlzvhAdga91gusat81cDVquurPQA4QS3s2lcN8rYyyOGzfLdQ8cseLsiWu7NrN1o17UJVJ+zW123+BfogD+TkdLQFAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-occlusionActive{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAACItJREFUaEO9Wn+MVNUV/s59+wOqyM7bFaxAsDBvFqnWak0MYhBQUEqUVssi/aNJawg7bxaKScFqqKyt0gip4sK8XUKqjX/IL43RlqBSxLZWYqwWdWNh3oIlFClkebMUaXfZefc0983MMjv7Zt7MLrvvn93MPec753v33HPuPfcRhukZt+3YeCndCQpeCO3kmWVTTg+HKbocoKHWjpnEuBfMd4GgnJ7ADAcCJzx8iUlE0AGcBOMkiPYz4c1kNPzXodofNAE9fvheQCyBoLvBOA/wHunSHq7CiXM9+BdWGj39nGuxq8dWYyJdxCSh8UKAFoIwBpL/CMidTmzam4MhUzaBmpYjNwmNVoFEA9jdSEx7zzZFPhiM8dotiduYeAFIWw2Wu6TLm7pW1n9SDlbJBK7d+rev/c8du5aAVQC/Lok2dEWNv5djrJBsTat9s2BeA9AiBjaN1s499eXyW/9bCnZJBNIG0AbQKCb8OhkN7ygFvFyZUGvHQ8R4DOBuSWgs5QUFEkiD8nYAuyuJmk5Hw2fKdawc+fGtHeN6mbcAWMxES4NeVlECequ9DoxmMK9yYpHny3FkqLJ6PPFTEG0CyyedWH1zIbyCBPQ2ewYk3ndMI3CWhuTsOhb6uMQTEBWfOdGpr+Zj6ZbNELjdaTQO+tnxda6m9R/XCa74AoLnO42RfUNysJjyuvYqffyo7QA/AKCXQYuSZnhvrorelpgHSW9LSn2jK3r9P/PhBhLY1V6ld1b/HuBPHDOyZricn/jsidEXRnXvIOD+SzaoS7r8/a4Vxrv9SFiJDQDd5NT13IeGGy7mjg0gELLs9QQsQAp3OiuN/wwHgbrfHh4ju8UOEH3XB/9LkvxAbm3RW+yrUIE/MbA3aRqPFyTgFakKcZCJfhK0+gdLbKz1aUjDaJWG5xfCYKADcB9MmtM+zcpksuELMiVn5Ba7fjOgxxMvgjDKMSNLB+tgMb0xW4/UVUpth7dnCnp8so9uJbaD0e3EIj/OqvcR8PY2VPGqJL6jlAISZD9//Op4+zWSqncwcGewLh8il5eeXVF/OFc2XVDpPXDqwezeqY9AyLJfIpbHiuXcYMP+EnqLPREVUGEzMxCDcFC6vUu7mqYf95PV40eamcSUpGn8SI1fmgHLPiUFL+lqjPw50EgZAjVbjk0Wwt0J4LYgNQYOVBE9VKza17QlZglJOx3T+Hofgdq2o3dJKduSpmEEGSlnfOxWe6pwsZOA75Sgt1dUu0s6H552Pkg2ZNm2EKLxbOPU/d4M6FbHBma+IhkzYkHK+ePpKa34d9Kc2pY7VmcdrpfQVNh8OxCT+TVnutGAOZQKlAUQittxIrrgmOE1aQJx+30p8Xh+AQkC01vtR8B4VskxtFlJc8pfPLw2ezokVNjcEIThjRP9zomG+zJLkE7NZnu2EFjvxIzbMzNgH3c1zD233DgapJwd17fYM0DYD8Lo9G/s9GpX1p9ffm2nZ0DDgUAstcsVNAGMWQBtVG80UAeACk3NxTuOaUzOEkg5KVwx4BhYBE237P0A5vYTIXreiYZXpWf1SDNIrCsIwfyCE4s8rA7/qV73EIBrADzimMamQBItdrVegQuOaVSQAui96H6WjBnjAhUzAnXWsXoJt1+Ozgy1O6Zxo+e8JnbBlQ1+JBiIJ02jqW824/Z8EN5KT6R8Uv1R6dzDyTz56T0Ut89UVmk3Ut1W+xZXYlsyapSSKTy4Osu+XwKv+xFWu0aBio1gXA+BhgEkGL9xYsbP8nVrrY4VDG7JklAOhyz7AAGzc3/L6oVa7Y80gWWDIhCKJ9YQ0TO+MybwTVHpnnB7tDcIuDqXBDM/nYxF1haaabX4ZS+8SFAJRa2lrGx+gukjMJgQCllHFxLkH3wc+coxjTHq95otn08mUflLltoTXU1TfKtqqSHrJ9cXQt6Cs+x+izgni6iicgrg0wBtdkxjtwfmHUSqTgGkmlW5jzrB9W0Xai37MQYWAZioml0ADjmmcfNQHPd0cxdxhkC/NFrXdvRWKeWH+YYY+HnSNLzQ0S37OXgtlpyHaYETC3sNqlrLfoOB+/IwzjumcdVQCQxMo/mFzHvD1ertV+UbIynvPttUv7/muS9qRHVK5Xqv0hLT2rOx8NPq/0JrhIF3k6YxZ6gEfApZx68Aqc4Bq7PgqjqDMMPHWCcTzUlGw+211pHvMcRrquXimEZDxvmlRPSyr5MFMlC5hHQrsREQ3Y4Z/oVXyNLNWd7mmMb0LFiOc374Ddn1oFv24r61obCsRAuBVvgpFTqYl0/A/pyJlqnm8KXtdKt9glz+Qe5ZtNayP2ZgwKJjRiwZMyw/w7pl71JNqQHrh/nRZCyyoVxn8+W9fqpGrzhRY5IXupdCJvEiwMfzK57vYswc99KxKGdDCHaihldB+xWfDDiDNyfNyMqhOu8lD6860+TssbKkI6WuSj3oW0yYSZBnwHxKEc3dtGUbYF5Xg/k6CNHDTB9o4A87zfBHl8P5okfKNLvyDvV+BC6Ho4Uwih7qlVK5bZWRJFBSWyUTw+sJtLCSMC+oEz1SBNIda+xj8J6ijS1FQF1kdLtjVYE6ns3thaZ0pAhkMtvkUdq5OfkXHwWau96FxsdBbfWRIJBts0vCLX79qoKt8+zFRrH2+ogQsGwudtFR/IIjeyws0GYvtl8fajbKttVBaM7WGD/MwMuL7EUHwBuRoqeGq2PdV1C9TjSvBWh1sYuNrHwgAS+9pi88tgIYx0TPDFfnOhO2jwI4Iym13O9CI38WSiLgKe1qrwp1VjePxDVrsq6nOf8io1BIlk4gg5B/0S01emew/VSvz+ny3BG56M5/A6odz6T9kIB5DHwFxtsssbuUTw1IYDEI8wm4koF9xO7LI/apgd9UquYwS74HzHeU+LHHeyToLdWcHWq2KjuESjU4Up/b/B9u0kgtWdqPkwAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-occlusionActive:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAACJpJREFUaEO9WntsW9UZ/33HaZJCX7S5TmhalQ1NaAzGYJUgvk7pe5QKusGa0v0xaZvQkKBbK60BWl/b8XWKaLWtUJg6IcG0P+hrCMHWlcdK2OLrFPFYGdU0ac+q9BHfFPoC2sQ+33SufVPXvfa1kyaWolg+3+t3zznfd87vu4Qx+nQfONc8yF+0KvP1NPHoxjsm9Y+FK7oSRo2+fh0I3AUpFwHUyoxWIv6EiI4o+8w8m5mmE+EowEchxH4g95rZ1myN1v+IAUR6M3eRwCqAFgM4C8ZeZuyFmHDk9OmpH2+7my4UB7fmj9wwderpWZBDs4mwHOoPmAzwn1hiV7I9+NpIwNQMwOjtvwWC1gLUwVJuIfA+s73lnZE4N3pP3M6gZSTEeoB3Q/JWs735w1psVQ0g/t6xq+T5uogkrCXQKyDebIaCf63FWTlZI525FUydDF4hGFtFYzYZnzvz82psVwVAOSCI7QA3MuMJU9d2VmO8VhnDsh8gwuMAnWfIh6p5QL4AlFEAO5ixp45yj8T1lkytgdUiH7dOBLMceIYIKwGs9ntYFQFELDtGQJyJ1yZDwadqCWS0spF05qfEtJWl7Eq2N8fL2SsLwLBOtgEybeqa7yyNJthYjEVucSYqRN1HCX3GS6W2DMtmQIRMfUaflx/P4GJ9x6+Tsu6/xGJpIjzjzdEEWEk3tvtQvZzVsgPM9zEwJJhXJMLBfcU60dTJJUzyDSGyX+pqu/Z/pfYuAxA7xPXytP17YvowEdY6xyr4dekjEydxo0oG9170QadY8neS7drbl4KwNzPxLWKqdk/XTTRYPHYZgGgqs0kSLQsExJ1dd8w4MxYAOlP25AaCCv5uD/vHIHP3FdeW2IGTU3I5+WfBvC8RDm4oC0AVKRbUR6Af+u3+kQJ7rPfwNXVi4k4CLS1vg/+Vy/H9m+Y1/82VUdmQwc+T5LbiYnfJDBhW5gWAGk1dWz3SACvpxd8705QbHNwJ5kV+9r2yj2HZOwA+b+rBH7j6wwDyZxt6CcThagqIXwCl47GeTIusJ7Vs7vTTZfDBHGVXPxGa+Y9i2ULFTrHk+92z00UAlv1bSPmfSjnXz3G58c6ej2c1TGjYCYLub4P6JAZXd+szD3vJRnr74xDiy0ld+74aHwZgpOzjknhVtx78i7+T6iU2Wp/OEZzdBcLtVWj1BJB7oFK132hl5gmmXWZYu3YYQDQ9sIiZt5u69pUqnFQtErH6rycWKvhv+ioR9l2QWLU5rJ31kzUs+59E9FAi1LTfmYFo2t7MzFebevBhP+XScTWlVCdOmG3a9uKxSMq+QRB2MvANX5vML4shraNrAWV9ZQEYVuZZIvosEdI6HQCGlUmzpA2lBcTPWLTPXscSv3DkmOeZ4WCv+ho7cPLGXC63i0A3+dnIj9NvTL1pOLP46UR67fkkeJOpB0MFAPZhxoSFSX3av/2U3XHD6m9j0H4CTSz89kmgoeGG+NwpA3kH6PGzxcAOAbQyMI8IW9QT9dNR4xHr1PWEobdMXZvjAIik7OzpM01Xl14DKxkzLHs/gIXFMgR6KqE3rXVsqqUlRKy8DX7e1IM/2nCgvzmQFQdBaAFjnRnWtvqBcK6nUwY+S4a1OlLswfnc5x+ZejDop+iOq/VNhEtytLOKwIeSevBmFXxgQt3u3FC2wwsEMT+bCAcfGbZn9S8liNcdG1J2qf8qnTsps/ApTe+Glck0Bq66mWJ99m3MeC4R0vwzRcFYpM++lyRe8QKsTo1STtgC4KsiQB2lIAj4eULXflaqG7UG1jD4aReECthI2z1gzC/+zdWLpu33ifDgiAAYVn8nIJ70BBAQX/siK480CLwKJq0YBIG7E3owUm6mnc0/JJ2VoBKK2ksXZ6DkhOoCGMkSilr2cgb+4BHIOVPXJqvfN1rH5giqT0gORLv1azyrarVL1ktueAl5beKiLKL4nuMg9BPxtkQouEfJOxeR1ubjAKaXbOJ0Qm8aPi5E0gOPE7ACzLMAtBJwMKFrt44mcKV7ySZWPxjWpWk0lrLnSsK7pY4Y9FhSb3KWjpG2fwmGk3HcD5NYlgzNcAgqI22/CsY9JTbOmro2ZbQALkujpYWs8IRVSa8vdUa53OLEvJb9sZ5Pp3F9tsettAyKJPWm7vwDKbNHCG+bIW3BqAFcVsj6BkzkuNEMa+td4woUQG0ezgYCCCyI69MPRdL93yYWLyvKJRnWOpy1n7ZXC8aLXkGWy0C1AjJS9hYE6LzZ1mTkK7EiZ6V4ztS1G11jbnCegRB3uPshms6sdL87+8nKPE2gNV565S7mNQOw7L9DyAcVOXzxOG3ZRyBz3y2+ixqW/QEAj01HD5t606+8HEdS9u4CKVUyLB819ebNtQZbKq/4VIjA70xdm63GigBkXmDJhy+reB6b0b3u5fO0nA8hOKlrTgUtLj7Dmxu8LakHfzLa4J0Zdo4oNMe9VlZ1pYyoUk/i62DSAc6wlMfzpf7ioc0lwAqsxnUEugDB7yCLd8127f0rEXzFK2U+e9R2qfcCcCUCLWej4qXeAVAjrTKeAKqiVRQItQQgaLng3BI/Jnq8ACjGWlLgTUjeW5HYUgCcRsZgfY9UG7qQ28tN6XgBUJlNCJoj6gcXlDY+PMndwmb5wI9WHw8ALs0O4tu8+KoK9Hq+sVGJXh8PAHl6vXyjo3KDo3AtLEezVzqvjzYbubQ6A3G3xpQ5nlR25TY6iLGF6kRyrBhrNwrFRHNWRpiwvlJjw5WvqvuSb3gEfs2gIAFPjhVznU+VeJTAGSFyP/ZqaJQ+7qoAKCXV+OBTdnw82qw0TYuXNjLKrZOqAbgGShvdLOitkfKpiuckyQvHpdFd+gQUHQ9B3yPGEhDOAfwGS9pT1asGgldCNTgYk5igCtSL4/aqgddUKnIY4G8xc7ialz2IKAXQ64qcHW22qnkJVetwvF63+T9nAHfjRfzL0gAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-logSave{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAA1RJREFUaEPtmT1oFEEUx9/bFLFKJzG2WiknZObFxlO8RtFC8SuFWlrYGBtRRNCghV9YmFQWgoVaaAS1ULRRRKvbmYBBQezVYBOIGFMkT0ZuYXPufOxdspuDO7jibmfe/H/z3sy8eYvQ4R/scP3QBSjbg8EemJyc3La4uHgUETcx82YAWNum+N8A8IWZrxLR41ZtBQForUeY+Xarg/j6MfMVIrroa5f13AuglOJWDLfQ56aU8mzefk4ApdR9ADiW12ir7RFxXAgxkqe/FUBrvYeZXzQbY+bh3t7ed5VKZTrPQM2eNHYQ8VGGjTtSypOhtq0AcRyPIeKptCEppTfkbAM3AxhbcRwfyYJg5nEiCvKEVZBS6hUA7EoEIeJ+IcTz0JlpbpcFYNrYIBDxlhDijG88lwd+IGJ/YoCZ1xPRd5/BUA/Mzc31VavVWRcEM18jovOuMV0eWLL7tBM+RoBS6isAbEzERFFUHRwc/JD8dnjishDikg2iSIAJADiU8uhdIjqRFuZYEweI6Gmuc8AWs6EhVK/XR3t6eg4zMyKiEQ/MvOSwQsS3iHhhZmbmY61W++UIp/dSyu2FAmit3zDzTjMoItaFEFuVUt8AYCB0ElLtZqWUfYUCZHlQKXUQAJ60AAC2Nbhia8AWglprAoB7jYQwmGXVACSKzRqJomgLAJjvBh/JqgPwCQ7dRAoPIZ/w5HkXIHQGQlOHvCd56PjdEOpoD6TShT/MfD19OXeFQCPnOYeIaxYWFiaGhoZGQ9Pv5nZthVA6XWjkOsMJRGj+b/IhIURtVQCkIUJvYKUCONLf/+67tjuw+T+rLlTYLmSDCDmwbOIbF6CgC1Vba8B3m3JBuMQXDuC4iGQy+MSXAhAKESK+NAAfRKj4UgFsEHnElw5gBGit9wFAUqy9kbco1vY2Gsfxsha2QrbV1K42gIimAPDvw8zTRLQuy0ZhpcU8AMZ7zPws1ee1lHJ3LoDlLu7mAcioZFuLvYWV130AU1NT/fPz8zuyqtWIuFcI8TKXBxo7QaEvOCyQD6SUx20T4K33F/iKKVOj7yrqBWhsiSv6ki8zNBBPCyHGfKEXBGCMrMBr1mZtPxHxEzN/jqLoYbr07oIIBvDNRFnPuwBlzXwybsd74C95KWhPrxIhsgAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-logSave:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAthJREFUaEPtmTuMTUEYx3//TrWdeLRUJCrReISGUBCvLVAqNGiEiASh8IoClUKyBQqPBAWhsREqnYRE9NgoV0T3yci5m9mzc2bmnHvvOXuTO8ktbs7MN//ffPP45hsx4kUjrp8xQNcezPaAmW0EDgFrgLXA0j7F/wG+AlckPW5qKwvAzE4At5p2ktHusqTzGfUWVEkCmJk1MdygzQ1Jp+u2iwKY2X3gcF2jfdS/I8l5O7tUApjZTuBlwNIk8E7STHYvQMCTzs6jgI27ko7l2o4B3AaO+4YkJadcVcdlAGfLzA5WQGR7IgbwGtjuCdoj6UXuyJTrhQBcnQjETUmnUv3FAH4CyzwDKyX9SBnM9QAwIWk2AXFV0tlYnzGAebtPP9OnEPkNWO2J2STpQ+9/xBOXJF2ogmgT4Amw3xNyT9JRX1gEYq+kZyGIoQGY2UXgAPyPt5x4V8qH1TRwDvgk6XdkOr2XtLltgLfA1qLTj5I2mNl3YEWDdTQraaJtgAVryMz2AU8bAFC1Boc5hYKbgJmtB6aKgDCbZdEAeLuOWyPrit+qFMmiA0gJrjr4yu1an0Ip4Z6Hss6hMUBu6FD3JB9PodwRGGkPeOHCX+CafzmPDUAR85wBlrgwQ5LbUueV3AHsaxGbmR8uOAGTPYga8f+0pG2LBWAOosYNrFOAqith6L5bdQee81optG7nHIjE8DlnVlB8EVa3AxCJ4VMAleJbB2gAERXfCUANiKT4zgAyILLEdwoQgcgW3zlAIWA30EvWXq+bFBvESTzQxFZqSyqdAe7i7xIAvTIjaXnIRmupxZoAznvPvTZvJO2oCzDQ5G5NgPKbRGWyt7X0egrAzFwedktFtnqXpFe1PFAsxLYfOEIaH0g6UjUAyXx/i09MQY2pq2gSoPDEsB/5QuJPSnLrMFqyAAqIQT+zloX9Aj4DX4CHfuo9RpANkBqJrr6PAboa+V6/I++Bf0in3kCazcMZAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-zoom{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAkUExURUdwTMDAwL+/v7+/v7+/v76+vr+/v7+/v7+/v7+/v7+/v7+/vxtcv/AAAAALdFJOUwBVdZCpGdZE7C3B0wnY6AAAAV9JREFUOMt1lDtPwzAQx20ghGwVsHVJhQRDlsywWKqEULsw8FhRJ2iWiglGGJvFCw8xIVVCSEwkKU25L4ftpOHs2Cclsu7v370smxCLecRh+xOH8Ja5kGEs/6dtYf1XONcWZurbwwRCQjYZ9l7uHAPAOBHpI1QC/QSY9g84ldmnAn7Z3htwsfZnvSe54eJd5hlcC7gccxTwSETZEr5+714vLRdfkFraVNtetXLpR7ha+mkHCV1Y/q8ZOW8AgDkecsIaAEIcGbIGyLUq4KcBYl0o7QAB4FZACBMrQKpaJOCZQqyAIhgayYEpgD1DZghXCvBTNJFKmCvgzmhcCEsBwMjSRx6BslYftRX0JLYKrAsLqzDC54EFMwvy58QhMM8hFNq0UpwET+sLC9/4BmEBTytyRCIbDoAEiR1Qp1dbRxfoyv9g3ogaKVuXhVZZbtqX6Ez6H23PxG4CM259QDwt/h8ABfK8nDqSAAAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-zoom:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAzUExURUdwTP///////////////////////////////////////////////////////////////8/RimEAAAAQdFJOUwCCyreU7KZVRCDaZnETLwj6WaYVAAABUUlEQVRIx5WV2Q6EIAxFoVBWxf7/184AOnGUsvTBqDmXrqRCzNou1kwGtyZIQNuiD0P6evWTURFUMtIoPO+iVoGIZPkMqkdKA0jZgoJ6suQc2EoiGBldOoQ9HSDk5+GTs1Fqo9IlcEpvNv3qv0MBhSalIFSv3+MCJCY8fUaCxasycrMu9dp5VTUhubXZ6CqsAvn66ZAsx+e8fON37oT3bZ4aiRU0kDlavGSrQI95HPBZACt8FuCL16IruBVkzBeBW+CLYHvyfiDQd96IpHpOMqP++fAq9VMQ7rwrM5+6gjwG/3y/D/m8ylPYpvpAeqO7DfvwMPO9D6jnBabG56YFZx77fEjD+9AyLdYEhp8nxoNh5wmJtfY8AS+wzIZZrJNcC4h3wV8IH1p87Iyfnc6XVaAd7ICHAsebw97zgDSxZ/yvViiPuYUfTe650knM2+7Ywz9yOCklzohLOwAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-zoomStop{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAzUExURUdwTP///////////////////////////////////////////////////////////////8/RimEAAAAQdFJOUwDjmTC6Y0KBVakX8s8iC3JYR1wyAAABVUlEQVRIx62V2baFIAiGcwJRS97/aU/Zbtht0VzrcJOuvl/AAabpXy1RF0F/m2h2PX5mzucEuO9gMon1MY7KlG8w4LImC1XFQmxDGVkm1DYpXi0qS1gXTEGzKoqNS1ajAxPqJDikFLcFS+aukYJffRfXnAj9kYUXFVi86wzzPjuCFRXBwS3KaC/Pt02Ww7uf1jz3BVYtX/OsyDQFDn7yswPXb+Ovs39eJJWwxrOXV4thgC+//QBf/uMAXwAa4AuRBvgdWR58CB2B+eaRG5e8QO7Jn2sIAvzhbdsDnXzev8q0BengGXv8EciH3y1CY5++yI/BRNx82g/La7lc7b0Am/tUC6n3HoZ4SbDyy5BgzSNivV6wbPXeIPOpHlOU+CjkTQKvQOpXdRdJvn+5xttWQa4EZUOzluonT6+q72X6Zb0+T/lNhQd7hg9vm8LWUhW5gT4iN7c/0ZUo8Q3AttYAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-zoomStop:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAqUExURUdwTBKV2hGW2xKW2xKW2xKW2xGV3BGW2xGW3BGX2xKW3BKW2xCX2xKW2yDN61kAAAANdFJOUwCAVKxm3T/DmhrxKw97YQBGAAABaklEQVQ4y2NgIA6wGqCLMCqAqV4HdIm9F0Ek22UMM9hiG4AkVzQDA+cmx+YyJJnDlw8wMNQaNpfevbu0QgxJgrN3JQPD3VvhjU57kESnOZqvvXuJgcEXxVFMEkDt1w11gZYwoVgue3d5SzaQSgCydZG1TMkBU8vBuq9guBcqNBNDgj0GQrMEb0CVYEmA2ViANRQZ795tQPZduADciXcVUNSthGu4hGrAJawagBIXsWoAClzGqgEocRWrBqDIrQNQDTPRXZ8A0cB41wBNQgGiQfbubTQJAagGDB0GIA0OsnevbkCTCADiu4J374ahW34JqAEIbiXMRJOAgkvMKJYgJBx6717AKiF4F4eOu+jxgQCXGHBIKPDgkBC8JYCURJDtQHYWN4oEcvpZiyR+C9lZtkgSKKG1CyGOGrxItleixjrcLFBWRAYcMIkG9NQMiY67N7AlcxAQwMwA6SBxM2xZQ3jtVRPsRQ83sg8ACMIUxzzE8wsAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-close{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAeUExURUdwTM3Nzc7Ozs7Ozs3Nzc3NzcrKys3Nzc3Nzc3NzePZJxkAAAAJdFJOUwCtKdPBGAmNTt3jdDcAAADfSURBVDjL1dOxDoIwEADQgwR07GTCZtI/IGHgAzBhM9EPkMTB0Y3V0ZXIcn/rtRR6pefgSKeSu3ellyvA9lZ/5F9p/3K7PZY8oPG5BD6MpPUSgIITzdIStifAshjRQV1PCFT8TxaicTzzwEwINOEdHVmDmcTAkRhMhMAp7iQRjcMtDhCp8SA1v0ARGIIK/gnkv0p1OBTS4QRUIpE7DiYYXTBrzcld3JIrAarXrps4AVNwRSZgExoJmIyAaAdsShUMn/JF2fh4YEkpAcgvnuwYCIb6EbbbP4PsDfLD2dD6Av1qTvAQlzUTAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-close:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAeUExURUdwTP///////////////////////////////////8kBMKEAAAAJdFJOUwCt0igUwJdJePGbgLgAAADcSURBVDjL1ZMxEoIwFESTCaOWFDapqeicnAALTiANnaWlnVewDTMW/7b+aCAb8jkAVIHN2/lsNkrt73lf8M08nnF1pAYFR/dFmAAx7SIoi4iDbRrWDMAuQFzmmxAGbjjJgjj6dCjMCAND/o8RWQMzUgIRKYE/wsC5TJIRR74rBUZaqqXwLZEXT0WTDGwLW1aavJWQir9qadw++NgykWoMNtcykh8Q5EECgr5C+jjpGjHjPGhPU5eVzyfPJitfnUyhPg6ywMKZ7BygcYcsPCj1Kc8uXYPqpeSLs6PnC4w8S+8OJ9MLAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-narrow{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAABm1JREFUaEPVWWuIVVUUXmvfYRosHzUZUUqKjkSXSe5Z+5qJhfawLELCR5ohPhKjjB4EWgkpkopRSWEPS1Mqy7Gkd0iPGaKy6ey9Z3z0opwEQytSMiS5NZ4Ve7j3dubMOfecO96buf/cx17rW+vba52919oH4RQfeIr7DxUjoLW+BhHHAsAAZh5gPwGghpl/TKVSHZ7n7T9+/Ph+ANg/atQo+1mRcUIEtNYzAWAiM09ExLPK8KgNADYw8wYp5Z9l6PUQ7RWBvON3AMClJ2Kcmb9DxAKR33qDVRYBrfUNzLwQESf0xliUDjPvR8T1RLSsXNzEBIwxc5l5fYSBnxGxxfO8bQCwN5VKHc7lcofr6+tzR44cGcTMg4UQgxDRfp8IAJdH4KwlooXlkEhEQGv9EAAsDQF+GwDWEdE75Rg1xlwFADcx83QAOCOg29SvX79ZDQ0NuSSYsQS01h8BwBUBsF45HnTIGHMBM9uFmR2Ya0bEWxzHORBHoiQBY8xmZp4RAFlNRIvigMuZN8asYOb7Azq7hBCTMpnMvlJYkQSMMUuYeblf2fO8ZdlsNiyVyvE3VNZ13XFCiGb/JCK+6DjOrLIJ2N0GAN4KKG4hIpuzVRtKqf6I+HvAwAIiWhdlNDQCSqntga3yUyK6rGqe+4Db2tqu8zzv3cJfiPiLfQYdx/k6zH4PAvlD6iWf8B7P8yZls9mO/4KAtaG1fhgAHvCReN1xnClJCXweOGFLhrAapJqamlLDhg372H9eMPNMKeXmoL1uEVBKTUXEJp+QJiJZDSfjMIOZgIibHMcJbrfdq1Gt9WMAcI8P/D9f/YJtpVQfW7n6isSDRHReyQhorXcCwMV5oWN1dXWD0un04bjVqta81to+i7bi7RpCiAmZTOYDv71iCu3cuXNQZ2env07fRkSTq+VcEtyQ7XwNEfkz5N8Ucl13khDiDR/b+ZlM5vkkhqopo5Q65Euj74loRGgElFJ3IuIThUnP8xqz2eyeajqXBFtrvR0AiuU7EXXbeIo/tNaPAMB9BVBmrpVS/l3KiDFmBjNPKbMbK0A+6zjOq3EktNavAUAxlUsR2AIA0ywgM3dIKYfFgRtjmph5apxc2Dwz/ySlHBynq7V+wV+tliLwPgBcmwdsJaLRceDGmD3MnI6Ti5j/g4j6x+lqrZ8EgGKTE0nAGPM0M9+Wj8BhKWV9HLjrukuFEPMBoMf+HKdrm3oimhcnFyy1IwkopRYj4soCYF1dXf3JPAMKfiilNiFisaSOJOC67nQhxCu+h3i0lLI1boWqPW+M6WDmoXk7+4io8L3rr+IuZIwZycztPocWEdHqajtYCl8pdSEifuOT2UhEc/w63fZUrfWvADCwixlii+M4408mAa31AgB4xufDHCLaGElAKbUZEf09cAMR/XCySGit7TXO3IJ9IcTQYI8cLKfvQsQ1BYVq9sBxi9La2jqipqbmMwA4Oy8bWtoHCTiIaBua0/JKB5hZSikPxhms9LxSah0i2i26MHoUct0eYt+2tRIRF5/MKGit7YFqD9auYU9tRBwfls49emJjzEBm3gEAxVKCmadJKbdWepWj8LTWHwLAlb75hUS0Nkw+6lbidkTspoCI6aibgUoSU0otR8QlBUxE3Oo4TleNlpiAFQwWUfa/XC7XZ8yYMccq6bAfS2v9OADcHUidqUT0RdkE8iS+BIBsQHkkEe2qNAml1HOIeGsA914isqQiR5LL3aMAcHoAYTIR2av0Ex7t7e3ne563mplvDoIh4le2xC+VurEE8pGwh1m3/sBec3ie96iUcndvWLS3t4/o7OycK4SYw8znRKZIDIlEBPIk7IrfGDB01JIAgJZsNtuShIjruplUKmWdtidsMLK2lFmFiPP8fUapSCQmYJ2L6cDsNfh7iLiXme1VjG3GOwFguOd5DYg4HAAa7O/Q3QTRXiavchxnhzHmIgCw3V6xWYoiURYBa9h13atTqdTssJxNEoEImQeJaIV/LimJsgkUjCilLrGXToho33mFrmoMod2I+LLneW9KKb8Nk01CotcE/AaVUmOFENcz8zgAGAIA54Y4dAgADiCifejtjcQnSSIWRgIAniIi+5q3cm/q/c40NzfX9e3bd4gQ4kxEPFhbW3sgnU7/lcThJJHwV8kViUBvHStHz0aCme2qe7W1tasbGxu7rkFPGQKR50Q5q/B/lP0HjgOoT/ydvaYAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-narrow:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAABS1JREFUaEPVmgmoVVUUhr+fosKC5ogGSsqIpKQwMqjIBpsICdMGQ7ISo4wGApugJCoxLClssElpNEuaI5okKjOI5onKhEQrSiKiaKA/Vu3zOu+8c88593qvj7fgcO99e6/h33udtdda+4khThri9tM1ALaPAQ4Btso9GwNfAyuBb7JHUnzvCq0XANuTgePSs00bFr0L3BuPpF/b4BswtSMAyfDzgYPXRznweQ7ID53IaguA7ROBGcC4TpRV8IRL3SNpVrtyGwOwfVYoaaHgW2AZsBT4CliXnt+BXYBd02d8D5c7rIWc+ZJigRpTIwC2rwauKZH6NLBA0jONNQK2jwJOAU4FtijwPgpMkRTga6kWgO2XgSMKkjoyvGiN7d3SwpxZGHsVOEPSmjoElQBsPwScVhAyR9LMOsHtjNu+Hri8wPMBMF7SqipZLQHYvgq4tsA8S1KZK7Vjb+lc24cDsfJ5ul/SlLYBpGjzVIFxsaTw2Z6R7S2BnwoKpkta0Epp6Q7YfqEQKl+XdGjPLM8Jtn088GzuT9/FOyjpkzL9AwCkQ+qB3OSPki9GOrBByPZ1wBU5ZY9LOrkpgDcLJ2zlFvYCke2NgFcK58VkSRFU+lG/HbA9EYg4nNE7kkb3wsg6mSWesEhSMdz2z0Zt3wRcnBO+wVc/0217WMpesyRxraSd6nbgfWC/NOm3OP4lRVowKGQ73sXIeDMaJ+nFvDF9LmQ78pR8nr5U0oRBsTwpLQnn8yTlPeR/F7I9HngiZ/A0SXcPJoDQbftHIHOjLyTt1WoHLgBuyQ3uKylC6KBS8UyS1C/w5F3oRuDSnLWbSPqzynrbkSdFfG6nGstE3inpkbrVsf0Y0OfKVQAWA5OSwJWS9mggPEJuhN5OaLWkqBMqyfZ9QF/4rALwPHBskrZC0pgGwsPFRtbNazH+s6TIfeoA3JqqwH/nVQG4HTg3SVsnadsGwiMznQYMiM91vKmgP7tuXjHVrgJwGXBDTuC2g3kGZHbYXhQVWva7CkCkyg/nAIyRtKJuhXo9bjuSyOFJzypJ2ff/XCqHdBTwXs6gmZLm9NrAKvm29wY+zc1ZKGlqnqeYzH0PbJ8mLJM0dpABTAfuyNkwVdLCKgDFGniEpC8HC4TtaONEOyej4cUaubgDFwLzcgw9q4HrFsV2pAxvANuluaWpfRHAAUAUNJsmpmhrjJa0tk5ht8dtRx0cITqjAYlcv5c49zJHKI2QmtEG3wXbcaDGwZrRamBsmTuX1cTxEi8H8qnEJElLur3KreTZfgk4Mjc+Q9L8svmtuhLnAUWGka06A90EZjt6UdGTymiJpCxHG6CqqrHVL4lKnMMkRaXWE7J9M3BRwXUmSnqrlcK61uLbwIEF5lGSou3XVbJ9F3BOQeglkgJUS2rS3P0F2LwgYYKkaKWvN9neGYgT//QSYR9Hil/lurUAQqjtOMyK9UEkWXMlfdgJihTn45CK1GCHChmVIBoBSCBixU8qKIrdmRuXG5LigqOWbO+fjA7jizsbqcxsINLsfJ3REkRjAAlEVQUWbfDncjc0UYz/BewJjCh8lgGNZvJsSctt75MabLUg2gKQQBydSrwyn63dgRYTrpQUdwR91BRE2wAyDbYPSk2nuPOKVW6X4t15EHhS0mdlzE1AdAygsFpxwX0CEJcUuwM7lhgULhW5VRgeHYnXmiBuAeI2SXHN272b+gKgzRKQrYFIBNdI+qOJwQ13oi8/68oOdGpYO3xpJ2LV/45zI/t3hSEDoBXYIQ/gH99H3EBePlczAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-expand{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAABvJJREFUaEPVWWmIXEUQrnqzZseYxGM9QBNF4hrJEDfzqieuAY/gFRXPyMYbzUHwQBQUzx+KeBAJKhrRqEhEQWMU75AYXREPlunu3bjxIDGraIwiuJpFkL26pMK84eXtm3lvZieGFAzsTtf1VVd3V9Ug7OOE+7j/0BAAnZ2d2UmTJl2cyWTaAOBA+TDzgYjYDAB/y4eZ5fNjc3Pze7NmzfqlUYEbFwBr7TUAcAEzXwAA2bROIeKnzrkNALBeKWXTysXx1QXAGHMVANwEACePxzgzjyLi057nrczn81vr0VUTAGOMRPtmRDy7HmOVZBDxL+fcyr6+vgc7OjqGatGdGoC19hZmfrKC8t9LafEWAGzLZDL9g4OD/S0tLYM7d+6cyszTPM+biojy97kAcGoFPV8ODw8vbG9v354WRCoAxpiXAUDyPUrvAcAqIno/rUHhs9aeCQALmflyAJgUlkXEf5xzp6U9G4kAjDHcKMejeqy1xzDz/QBwXYyNViL6ISkwVQEYY74AgLkRJcuJ6M4kxbWsW2sfZua7ozJNTU1HtLW1/VFNV0UAxpjlAHBHWNg590ChUJCINZyKxeLpnud1RhSvmzJlyiWtra2DFS+AuAW5bQDg3cja60QkObvHSGstj588fGVi5heVUktqAqC1Xh+5Kj8nolP2mOchxd3d3ec55z6I2JpPROvj7I9JodIj9UqIebNz7qJCodD3fwAQG8aYhwDgnpC99UQ0Py2ALyMv7DIiWvV/OS921qxZk5k+ffon4fcCEZf4vv9i1I/ddkBrfSUivhpiMkSkanXeWnsFAFwCADNHR0fX1nPwYzJhAxGdkwTgJUQM38l1Rd8Y8yYAXFoytoOIjqo1CFrriQDwCyIeEsh6nndsPp//KayrvANbt25tHhgY+AsA9i8x/JvNZqfmcrn+Wo1bazuZ+fRAjogSH8w4G8YYOYtSOAZ0GxE9EQvAGCMRk8gF9BYRLajVeeFvIIDdrnOpt3zfnxcLwFr7CDPfFdqupfl8/oW9CUBsa63/DKXRz0R0TCUAzzDzDcGic25WoVDYvLcBGGPk/i+X7wMDA/vNmzdvJPCrnJvW2leZ+cpggZknKKWGqwGw1l7IzOcg4swoX/gMyNbH6HnO9/3XkgJkjFkLAOVUzmQyM2bPnr1lDABjjJTE58sCM/cppaanUK4BgJL44taZebtSalqSrDHmpXC1ysynKKU+j9uBj5hZ6nShLiJqT1Jurd3MzLkkvgrrfxPRwUmyxpinAODmSqkdTqE3mPmy0g70K6VakpQXi8X7Pc9bCgBHJvHGrEsjtCxJLlpqDw8PTwt3bGEAzzNzuerLZrMt9bwB4lCjrtHSLbQaEa8NgGaz2cm5XO6fuDPwGADcHjrE7UqprqQIxa03EoC1to+Zjy3ZGZN25R3QWt+IiCtDDt1JRNLU1EyNAqC1PgERvws58DYRSY1VpjKA3t7eaUNDQz+Xtybm1UuLpFEAjDFyRp4N2a1cSsTlLgCkaqyjwBoIQMrnRYH+0dHR/Jw5c3pid6B0YO5GxIdDV1ZdPbC19nLn3GOIOAUA1hLR4rS7F/B1dXUd39TUJEOFQ+U7RNzo+/5ZUT3RfsBHRGloZCgrtIOZlVLqt1odGC+/1noVIsoVHdAiIpJHbTcaU+ZqrR9BxHJRtycnEZVAGmOkfVwXOo9bJk+efGLcdGIMAGvtYcz8FQCUSwlm7lBKvTHeqKaVN8ZsBIAz0qRybKMRc6VKDuZ83/82rRP18mmtH0TE+0LyHxNRUOKMUVuxU7LWlkuLQGpwcHDi3Llz/63XuSQ5Y8zjAHBrwMfM/cy8oFAoxFWzu9iSRou/xtQ5bUT0dZIzta5rrZ+XyUNYDhFv931/RTVdVQF0d3e3OufKtXdI0QIiklH6uKmnp+co59zycC8SOrzfAEBHtdRNbLaLxeIMz/O+H3N9Ia52zq1QSvXWg6Knp+f4kZGRRZ7nXc/Mh1fSgYhVQSQCEMW9vb1HDA0NyS0UHS/KLF+2+NNqeRp2rlgs5jOZjDgtL+wBEcdlEv0oIi4O9xnVQKQCIEZkTuN53uqgZ4iJmMxrPkTEbXL4AECaceldj3POtSLicVKayP9x0UZEGSY/6vv+V9ZaaVHXpAGRGkBgtFgsnpXJZK6Ly9l6Uqkkcy8RlUsY+S4tiJoBBE5qrU9CxKvlZ1YA2G3UkRJIr4wxnXPvKKXGnLG0IOoGEHZSnn5EvIiZTwKAowEgrh39U2orRJRDLxOJz9IAjdsJAHiGiORn3sb8Uh91ZNOmTQeMjIwcjYgHIeJvEyZM2JHL5Wr6+TSsMwoCEVf4vr+re2zIDqSJ5Hh5BAQzS9R/IiJpf3fRPgOg4jsx3sjsbfn/AH37LF5g3/BiAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-icon-expand:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAABYZJREFUaEPVmXmoVVUUxn8f0WRzVkJlIWVGUmIJWWADTVaUldFclCnSQBQYNv1RSCWGVFRSlkRh0GBS2YBmJWGJUBHNNJiYWQSZfwTRxBfrce5jv/3Ovefc++4z3oKLD/fea61v7bXXdMQQJw1x/ekKANs7AOcA44Ddkt/2wJbk9z2wTNIP3TLcgADYvhw4q/gFiLq0ClgBLJf0Ud1DZfs6AmD7UuA64JiBCAf+BR4GHpH0TSe82gJgO6x9PXBqJ8JanPktQABzJP3VDu/aAGzfADzYhPnPQLjFUuA7YHPx+xPYHxhZ/Bt/nw4c14TP+8CFkjbWBVELgO2ngfD3nJYBCyW9Wldg7LN9cigKXATsnJ39HTi+7tuoBGDb3VI852P7QOBO4MoSGaMlfVtlmJYAbL8HHJsxmSdpdhXjdtZt3wPcWnJmhKRfWvFqCsD2PODm7PBdksJiXSfbJwDvZIzfAM6VFG+plEoBFNHmlezEc5LCZweNbEcSjMSX0iJJ09sFsDwLlaslTRo0zRPGts8AXstkTZYUOvWjfjdQJKnFyc7PgCmS1m0NACHD9t3AbYm8yNiT6wKIWJxm2JmSFm4t5QsA2wBvZ/liuqRFuR59bsD2JcAzyaYPJU1oV3nbF8fjAw4DlnTy8Es8YYWk06oAPJnF5I6sb/tF4LxC2CZJ+3VghGFAVK17JmdHSVqf8uq9AdtR+kZNsmOx4Y9I/5KiLGiLbEc4jLDYQ5IqE2aZANvxFqNwbNBNkh5oBiAsFpZr0FJJU9vSvNjcRQBRPKbhfJWkE5sBuBe4JVmcIemJ/xNAyLb9a+JGGyRF+dFLqQstAK5J1g6XFCG0berWDRQA8py0raR/et2z8YftiD4RhRq0naS/W2lv+2wgIkNEm5x630BRaufrj0l6tso6tpcAqSuPkfR1GYAoic8sFtZJOqgG8w+Ao6r2NVnfKCn6hJZkO4+MkyStLgPwJhB1etBaSRNrMA8XG1u1r8n6Fkl7VJ21/VDRBTa29nHt9A28AJxf7NosaXgN5lGZzgD2rdpbsh6N0MyqcyWl9si0Y0sBPA6kVd/wTnJAKNTlR/wUcEUCdBdJ0bX1UArgPmBWsnGipLVVFipb7zKAKCJHFXL6uV0K4NpiMtDQabakaGrapm4BsH0o8GWiwEuSosbqpRRARIQNyVq/rFcXSRcBxBt5NJHbvJQo812gVmOdA+sigCifpyX8x0v6uPQGCgDRWEeD3aCOemDb0XrGm9q1KKevrnt7jX22DwFiqLBX8X8rJZ2S88n7gSOBaGiiMg3aBEyQ9FO7Cgx0v+1ooiJEN2iapEhqfaispcyLuo5uYSAAbEf7GBOJBkXpcETZdKIMwN7AGiAtJS6QFIluq5DtlcBJdVy52VglD6nBa6ykLwYbge05wB2JnLckNUqcfuJbDbbS0qJxcJik6NQGhWzfD9yYMI9ucKqkGByXUtVo8ceSOmecpE+6jcB2XsqEiFmS5reSVQVgNNBbeyeMwioxSh8w2Y6GPzJ+2os0+H4OxPtr6rqVzbbtMcBXJZpGkTVf0qedoCjifCSpq4B9WvBoCaISQDC2PQKIN5GPF6MqjCuOsqOpn6bK2R5fKB3K75QpHpPouUAkvrTPaAqiFoACRMxpwuqNniE3WsxrXk++0EQzHr3rwVGSZP+WGTymD3MlrbEdLerzdUDUBtCQaDvSeXyQKPPZTrwpztwuKS1h4tZrgWgbQALkaOCy4hNrn1FHTRTxdmKQ8LKksjdWC0THADK/jtQ/BQhQBwBl7Wi4VNRWoXhMJN6tA7TJTSyQFJ95u/OlPlfEdjzOALI7EIVgzEfb+nyaGSh3p4h+Pd1jV26gjiUHuqe4ibD6eklRqvfQkAHQzABDHsB/7aMVT352GH8AAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.easyplayer-container .easyplayer-menu-icon-text,.easyplayer-container .easyplayer-quality-icon-text,.easyplayer-container .easyplayer-scale-icon-text,.easyplayer-container .easyplayer-speed-icon-text{font-size:14px;min-width:30px;height:20px;line-height:20px;cursor:pointer;text-align:center}.easyplayer-container .easyplayer-speed{box-sizing:border-box;text-align:center;font-size:14px;color:#fff;width:90px}.easyplayer-container .easyplayer-menu-list,.easyplayer-container .easyplayer-quality-menu-list,.easyplayer-container .easyplayer-scale-menu-list,.easyplayer-container .easyplayer-speed-menu-list{position:absolute;left:50%;bottom:100%;visibility:hidden;opacity:0;transform:translateX(-50%);transition:visibility .3s,opacity .3s;border-radius:4px;overflow:hidden;width:-moz-max-content;width:max-content}.easyplayer-container .easyplayer-menu-list.easyplayer-menu-shown,.easyplayer-container .easyplayer-menu-list.easyplayer-quality-menu-shown,.easyplayer-container .easyplayer-menu-list.easyplayer-scale-menu-shown,.easyplayer-container .easyplayer-menu-list.easyplayer-speed-menu-shown,.easyplayer-container .easyplayer-quality-menu-list.easyplayer-menu-shown,.easyplayer-container .easyplayer-quality-menu-list.easyplayer-quality-menu-shown,.easyplayer-container .easyplayer-quality-menu-list.easyplayer-scale-menu-shown,.easyplayer-container .easyplayer-quality-menu-list.easyplayer-speed-menu-shown,.easyplayer-container .easyplayer-scale-menu-list.easyplayer-menu-shown,.easyplayer-container .easyplayer-scale-menu-list.easyplayer-quality-menu-shown,.easyplayer-container .easyplayer-scale-menu-list.easyplayer-scale-menu-shown,.easyplayer-container .easyplayer-scale-menu-list.easyplayer-speed-menu-shown,.easyplayer-container .easyplayer-speed-menu-list.easyplayer-menu-shown,.easyplayer-container .easyplayer-speed-menu-list.easyplayer-quality-menu-shown,.easyplayer-container .easyplayer-speed-menu-list.easyplayer-scale-menu-shown,.easyplayer-container .easyplayer-speed-menu-list.easyplayer-speed-menu-shown{visibility:visible;opacity:1}.easyplayer-container .icon-title-tips{pointer-events:none;position:absolute;left:50%;bottom:100%;visibility:hidden;opacity:0;transform:translateX(-50%);transition:visibility .3s ease 0s,opacity .3s ease 0s;background-color:rgba(0,0,0,.5);border-radius:4px}.easyplayer-container .icon-title{display:inline-block;padding:5px 10px;font-size:12px;white-space:nowrap;color:#fff}.easyplayer-container .easyplayer-quality-menu{padding:8px 0}.easyplayer-container .easyplayer-menu-item,.easyplayer-container .easyplayer-quality-menu-item,.easyplayer-container .easyplayer-scale-menu-item,.easyplayer-container .easyplayer-speed-menu-item{display:block;height:25px;line-height:25px;margin:0;padding:0 10px;cursor:pointer;font-size:14px;text-align:center;width:50px;color:hsla(0,0%,100%,.5);transition:color .3s,background-color .3s}.easyplayer-container .easyplayer-menu-item:hover,.easyplayer-container .easyplayer-quality-menu-item:hover,.easyplayer-container .easyplayer-scale-menu-item:hover,.easyplayer-container .easyplayer-speed-menu-item:hover{background-color:hsla(0,0%,100%,.2)}.easyplayer-container .easyplayer-menu-item:focus,.easyplayer-container .easyplayer-quality-menu-item:focus,.easyplayer-container .easyplayer-scale-menu-item:focus,.easyplayer-container .easyplayer-speed-menu-item:focus{outline:none}.easyplayer-container .easyplayer-menu-item.easyplayer-menu-item-active,.easyplayer-container .easyplayer-menu-item.easyplayer-quality-menu-item-active,.easyplayer-container .easyplayer-menu-item.easyplayer-scale-menu-item-active,.easyplayer-container .easyplayer-menu-item.easyplayer-speed-menu-item-active,.easyplayer-container .easyplayer-quality-menu-item.easyplayer-menu-item-active,.easyplayer-container .easyplayer-quality-menu-item.easyplayer-quality-menu-item-active,.easyplayer-container .easyplayer-quality-menu-item.easyplayer-scale-menu-item-active,.easyplayer-container .easyplayer-quality-menu-item.easyplayer-speed-menu-item-active,.easyplayer-container .easyplayer-scale-menu-item.easyplayer-menu-item-active,.easyplayer-container .easyplayer-scale-menu-item.easyplayer-quality-menu-item-active,.easyplayer-container .easyplayer-scale-menu-item.easyplayer-scale-menu-item-active,.easyplayer-container .easyplayer-scale-menu-item.easyplayer-speed-menu-item-active,.easyplayer-container .easyplayer-speed-menu-item.easyplayer-menu-item-active,.easyplayer-container .easyplayer-speed-menu-item.easyplayer-quality-menu-item-active,.easyplayer-container .easyplayer-speed-menu-item.easyplayer-scale-menu-item-active,.easyplayer-container .easyplayer-speed-menu-item.easyplayer-speed-menu-item-active{color:#2298fc}.easyplayer-container .easyplayer-volume-panel-wrap{position:absolute;left:50%;bottom:100%;visibility:hidden;opacity:0;transform:translateX(-50%) translateY(22%);transition:visibility .3s,opacity .3s;background-color:rgba(0,0,0,.5);border-radius:4px;height:120px;width:50px;overflow:hidden}.easyplayer-container .easyplayer-volume-panel-wrap.easyplayer-volume-panel-wrap-show{visibility:visible;opacity:1}.easyplayer-container .easyplayer-volume-panel{cursor:pointer;position:absolute;top:21px;height:60px;width:50px;overflow:hidden}.easyplayer-container .easyplayer-volume-panel-text{position:absolute;left:0;top:0;width:50px;height:20px;line-height:20px;text-align:center;color:#fff;font-size:12px}.easyplayer-container .easyplayer-volume-panel-handle{position:absolute;top:48px;left:50%;width:12px;height:12px;border-radius:12px;margin-left:-6px;background:#fff}.easyplayer-container .easyplayer-volume-panel-handle:before{bottom:-54px;background:#fff}.easyplayer-container .easyplayer-volume-panel-handle:after{bottom:6px;background:hsla(0,0%,100%,.2)}.easyplayer-container .easyplayer-volume-panel-handle:after,.easyplayer-container .easyplayer-volume-panel-handle:before{content:"";position:absolute;display:block;left:50%;width:3px;margin-left:-1px;height:60px}.easyplayer-container.easyplayer-fullscreen-web .easyplayer-controls{width:100vh}.easyplayer-container.easyplayer-fullscreen-web .easyplayer-play-big:after{transform:translate(-50%,-50%) rotate(270deg)}.easyplayer-container.easyplayer-fullscreen-web .easyplayer-loading{flex-direction:row}.easyplayer-container.easyplayer-fullscreen-web .easyplayer-loading-text{transform:rotate(270deg)}.easyplayer-container .easyplayer-contextmenus{display:none;flex-direction:column;position:absolute;z-index:120;left:10px;top:10px;min-width:200px;padding:5px 0;background-color:rgba(0,0,0,.9);border-radius:3px}.easyplayer-container .easyplayer-contextmenus .easyplayer-contextmenu{cursor:pointer;font-size:12px;display:block;color:#fff;padding:10px 15px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-shadow:0 0 2px rgba(0,0,0,.5);border-bottom:1px solid hsla(0,0%,100%,.1)}.easyplayer-container .easyplayer-contextmenus .easyplayer-contextmenu a{color:#fff;text-decoration:none}.easyplayer-container .easyplayer-contextmenus .easyplayer-contextmenu span{display:inline-block;padding:0 7px}.easyplayer-container .easyplayer-contextmenus .easyplayer-contextmenu span.art-current,.easyplayer-container .easyplayer-contextmenus .easyplayer-contextmenu span:hover{color:var(--theme)}.easyplayer-container .easyplayer-contextmenus .easyplayer-contextmenu:hover{background-color:hsla(0,0%,100%,.1)}.easyplayer-container .easyplayer-contextmenus .easyplayer-contextmenu:last-child{border-bottom:none}.easyplayer-container.easyplayer-contextmenus-show .easyplayer-contextmenus{display:flex}.easyplayer-container .easyplayer-extend-dom{display:block;position:relative;width:100%;height:100%;display:none}.easyplayer-container-playback .easyplayer-controls{height:48px}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center{flex:1;display:flex;box-sizing:border-box;justify-content:space-between;font-size:12px}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-controls-playback-time{box-sizing:border-box;flex:1;position:relative;height:100%}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-controls-playback-time-inner{width:300px;height:100%;overflow-y:hidden;overflow-x:auto}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-controls-playback-current-time{position:absolute;left:0;top:0;height:15px;width:1px;background-color:red;text-align:center;z-index:1}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-controls-playback-current-time-text{position:absolute;box-sizing:border-box;padding:0 5px;width:60px;left:-25px;top:15px;border:1px solid red;height:15px;line-height:15px;cursor:move;background-color:#fff;color:#000;-webkit-user-select:none;-moz-user-select:none;user-select:none}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-controls-playback-time-scroll{position:relative;width:1440px;margin:0 auto}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-controls-playback-time-scroll.one-hour{width:1440px}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-controls-playback-time-scroll.half-hour{width:2880px}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-controls-playback-time-scroll.ten-min{width:8640px}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-controls-playback-time-scroll.five-min{width:17280px}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-controls-playback-time-scroll.one-min{width:86400px}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-controls-playback-time-list{position:relative;background-color:#ccc;height:48px}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-playback-time-day{height:100%;overflow:hidden}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-playback-time-one-wrap{height:8px;z-index:1}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-playback-time-second-wrap{height:25px}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-controls-playback-btns{display:flex;align-items:center}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-playback-time-minute-one,.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-playback-time-second-one{float:left;width:1px;height:8px;margin:0;cursor:default;position:relative;z-index:1}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-playback-time-minute-one.active,.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-playback-time-second-one.active{background-color:orange;cursor:pointer}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-playback-time-minute-one.start,.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-playback-time-second-one.start{background-color:#999}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-playback-time-minute-one:hover .easyplayer-playback-time-title-tips,.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-playback-time-second-one:hover .easyplayer-playback-time-title-tips{visibility:visible;opacity:1}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-playback-time-title-tips{pointer-events:none;position:absolute;left:0;top:100%;visibility:hidden;opacity:0;transform:translateX(13%);transition:visibility .3s ease 0s,opacity .3s ease 0s;background-color:#000;border-radius:4px;z-index:1}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-playback-time-title-tips.easyplayer-playback-time-title-tips-left{transform:translateX(-100%)}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-playback-time-title-tips .easyplayer-playback-time-title{display:inline-block;padding:2px 5px;font-size:12px;white-space:nowrap;color:#fff}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-playback-time-hour,.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-playback-time-minute{float:left;position:relative;width:60px;box-sizing:border-box;border-top:1px solid #999;-webkit-user-select:none;-moz-user-select:none;user-select:none;text-align:left;height:25px;line-height:25px}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-playback-time-hour:first-child,.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-playback-time-minute:first-child{border-left:0}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-playback-time-hour:first-child .easyplayer-playback-time-hour-text,.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-playback-time-minute:first-child .easyplayer-playback-time-hour-text{left:0}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-playback-time-hour:after,.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-playback-time-minute:after{content:"";position:absolute;left:0;top:-8px;width:1px;height:14px;background-color:#999}.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-playback-time-hour-text,.easyplayer-container-playback .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-center .easyplayer-playback-time-minute-text{position:absolute;left:-13px}.easyplayer-container-playback .easyplayer-playback-expand.disabled .easyplayer-icon-expand,.easyplayer-container-playback .easyplayer-playback-narrow.disabled .easyplayer-icon-narrow{cursor:no-drop}.easyplayer-container-playback .easyplayer-control-progress-simple{position:absolute;box-sizing:border-box;left:0;top:-2px;width:100%;display:flex;flex-direction:row;align-items:center;height:8px;cursor:pointer}.easyplayer-container-playback .easyplayer-control-progress-simple:hover{top:0;align-items:flex-start}.easyplayer-container-playback .easyplayer-control-progress-simple:hover .easyplayer-control-progress-inner{height:100%}.easyplayer-container-playback .easyplayer-control-progress-simple:hover .easyplayer-control-progress-inner .easyplayer-progress-indicator{transform:scale(1);visibility:visible}.easyplayer-container-playback .easyplayer-control-progress-inner{display:flex;align-items:center;position:relative;height:50%;width:100%;transition:all .2s ease;background:hsla(0,0%,100%,.5)}.easyplayer-container-playback .easyplayer-progress-hover{display:none;width:0}.easyplayer-container-playback .easyplayer-progress-played{position:absolute;left:0;top:0;right:0;bottom:0;height:100%;width:0;background-color:orange}.easyplayer-container-playback .easyplayer-progress-indicator{visibility:hidden;align-items:center;justify-content:center;position:absolute;z-index:40;border-radius:50%;transform:scale(.1);transition:transform .1s ease-in-out}.easyplayer-container-playback .easyplayer-progress-indicator .easyplayer-icon{width:100%;height:100%;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.easyplayer-container-playback .easyplayer-progress-indicator:hover{transform:scale(1.2)!important}.easyplayer-container-playback .easyplayer-progress-tip{display:none;position:absolute;z-index:50;top:-25px;left:0;height:20px;padding:0 5px;line-height:20px;color:#fff;font-size:12px;text-align:center;background:rgba(0,0,0,.7);border-radius:3px;font-weight:700;white-space:nowrap}.easyplayer-container-playback.easyplayer-fullscreen-web .easyplayer-controls .easyplayer-controls-bottom .easyplayer-controls-playback-time-inner{overflow-y:auto}.easyplayer-zoom-control{cursor:grab}.easyplayer-performance-panel{position:absolute;box-sizing:border-box;z-index:10000;left:0;top:0;padding:5px;font-size:10px;background:rgba(0,0,0,.2);color:#fff;max-height:100%;overflow-y:auto;display:none}.easyplayer-performance-panel .easyplayer-performance-item{display:flex;align-items:center;margin-top:3px;color:#fff}.easyplayer-performance-panel .easyplayer-performance-item-block{height:10px}.easyplayer-tips-message{position:absolute;top:0;left:0;width:100%;height:100%;background:linear-gradient(180deg,rgba(0,0,0,.8),hsla(0,0%,100%,0));overflow:auto;box-sizing:content-box;display:none}.easyplayer-tips-message:before{color:hsla(0,0%,100%,.3);content:"X";font-family:Arial,Helvetica,sans-serif;font-size:40px;left:0;line-height:1;margin-top:-20px;position:absolute;text-shadow:2em 2em 4em #000;text-align:center;top:50%;vertical-align:middle;width:100%}.easyplayer-tips-message .easyplayer-tips-message-close{position:absolute;z-index:99999;right:0;top:0;width:40px;height:40px;display:flex;align-items:center;justify-content:center}.easyplayer-tips-message .easyplayer-tips-message-close .easyplayer-tips-message-close-icon{width:20px;height:20px;border-radius:10px;cursor:pointer;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAeUExURUdwTM3Nzc7Ozs7Ozs3Nzc3NzcrKys3Nzc3Nzc3NzePZJxkAAAAJdFJOUwCtKdPBGAmNTt3jdDcAAADfSURBVDjL1dOxDoIwEADQgwR07GTCZtI/IGHgAzBhM9EPkMTB0Y3V0ZXIcn/rtRR6pefgSKeSu3ellyvA9lZ/5F9p/3K7PZY8oPG5BD6MpPUSgIITzdIStifAshjRQV1PCFT8TxaicTzzwEwINOEdHVmDmcTAkRhMhMAp7iQRjcMtDhCp8SA1v0ARGIIK/gnkv0p1OBTS4QRUIpE7DiYYXTBrzcld3JIrAarXrps4AVNwRSZgExoJmIyAaAdsShUMn/JF2fh4YEkpAcgvnuwYCIb6EbbbP4PsDfLD2dD6Av1qTvAQlzUTAAAAAElFTkSuQmCC") no-repeat 50%;background-color:#fff;background-size:100% 100%}.easyplayer-tips-message .easyplayer-tips-message-content{overflow:auto;padding:35px;box-sizing:border-box;width:100%;height:100%}.easyplayer-tips-message .easyplayer-tips-message-content .easyplayer-tips-message-content-item{font-size:14px;color:#fff;text-align:center;line-height:1.5}');class Cd{constructor(e){var t;this.player=e,this.TAG_NAME="Control",this.extendBtnList=[],((e,t)=>{e._opt.hasControl&&e._opt.controlAutoHide?e.$container.classList.add("easyplayer-controls-show-auto-hide"):e.$container.classList.add("easyplayer-controls-show");const i=e._opt,r=i.operateBtns,s=`\n <div class="easyplayer-controls-center">\n <div class="easyplayer-controls-playback-time">\n <div class="easyplayer-controls-playback-time-inner">\n <div class="easyplayer-controls-playback-time-scroll">\n <div class="easyplayer-controls-playback-time-list">\n <div class="easyplayer-playback-time-day">\n <div class="easyplayer-playback-time-one-wrap"></div>\n <div class="easyplayer-playback-time-second-wrap"></div>\n </div>\n </div>\n <div class="easyplayer-controls-playback-current-time">\n <div class="easyplayer-controls-playback-current-time-text">00:00:00</div>\n </div>\n </div>\n </div>\n </div>\n ${i.playbackConfig.showPrecisionBtn?`\n <div class="easyplayer-controls-playback-btns">\n <div class="easyplayer-controls-item easyplayer-playback-narrow">${ud.narrow}</div>\n <div class="easyplayer-controls-item easyplayer-playback-expand">${ud.expand}</div>\n </div>\n `:""}\n </div>\n `;e.$container.insertAdjacentHTML("beforeend",`\n ${i.background?`<div class="easyplayer-poster" style="background-image: url(${i.background})"></div>`:""}\n <div class="easyplayer-loading-bg">\n <img class="easyplayer-loading-bg-image" src="" alt="">\n </div>\n ${i.loadingIcon?`\n <div class="easyplayer-loading">\n ${ud.loading}\n <div class="easyplayer-loading-text">${i.loadingText}</div>\n </div>\n `:""}\n ${i.hasControl&&r.play?'<div class="easyplayer-play-big"></div>':""}\n ${i.hasControl&&r.ptz?`\n <div class="easyplayer-ptz-controls">\n <div class="easyplayer-ptz-bg-active"></div>\n <div class="easyplayer-ptz-arrow easyplayer-ptz-arrow-up" data-arrow="up"></div>\n <div class="easyplayer-ptz-arrow easyplayer-ptz-arrow-right" data-arrow="right"></div>\n <div class="easyplayer-ptz-arrow easyplayer-ptz-arrow-down" data-arrow="down"></div>\n <div class="easyplayer-ptz-arrow easyplayer-ptz-arrow-left" data-arrow="left"></div>\n ${i.ptzMoreArrowShow?'\n <div class="easyplayer-ptz-arrow easyplayer-ptz-arrow-left-up" data-arrow="left-up"></div>\n <div class="easyplayer-ptz-arrow easyplayer-ptz-arrow-right-up" data-arrow="right-up"></div>\n <div class="easyplayer-ptz-arrow easyplayer-ptz-arrow-left-down" data-arrow="left-down"></div>\n <div class="easyplayer-ptz-arrow easyplayer-ptz-arrow-right-down" data-arrow="right-down"></div>\n ':""}\n <div class="easyplayer-ptz-control"></div>\n <div class="easyplayer-ptz-btns">\n ${i.ptzZoomShow?'\n <div class="easyplayer-ptz-btn">\n <div class="easyplayer-ptz-expand easyplayer-ptz-icon">\n <i class="easyplayer-ptz-expand-icon"></i>\n <span class="icon-title-tips">\n <span class="icon-title">缩放+</span>\n </span>\n </div>\n <div class="easyplayer-ptz-narrow easyplayer-ptz-icon">\n <i class="easyplayer-ptz-narrow-icon"></i>\n <span class="icon-title-tips">\n <span class="icon-title">缩放-</span>\n </span>\n </div>\n </div>\n ':""}\n ${i.ptzApertureShow?'\n <div class="easyplayer-ptz-btn">\n <div class="easyplayer-ptz-aperture-far easyplayer-ptz-icon">\n <i class="easyplayer-ptz-aperture-icon"></i>\n <span class="icon-title-tips">\n <span class="icon-title">光圈+</span>\n </span>\n </div>\n <div class="easyplayer-ptz-aperture-near easyplayer-ptz-icon">\n <i class="easyplayer-ptz-aperture-icon"></i>\n <span class="icon-title-tips">\n <span class="icon-title">光圈-</span>\n </span>\n </div>\n </div>\n ':""}\n ${i.ptzFocusShow?'\n <div class="easyplayer-ptz-btn">\n <div class="easyplayer-ptz-focus-far easyplayer-ptz-icon">\n <i class="easyplayer-ptz-focus-icon"></i>\n <span class="icon-title-tips">\n <span class="icon-title">聚焦+</span>\n </span>\n </div>\n <div class="easyplayer-ptz-focus-near easyplayer-ptz-icon">\n <i class="easyplayer-ptz-focus-icon"></i>\n <span class="icon-title-tips">\n <span class="icon-title">聚焦-</span>\n </span>\n </div>\n </div>\n ':""}\n </div>\n </div>\n `:""}\n ${i.hasVideo?`\n <div class="easyplayer-zoom-controls">\n <div class="easyplayer-zoom-narrow">${ud.narrow}</div>\n <div class="easyplayer-zoom-tips">电子放大</div>\n <div class="easyplayer-zoom-expand">${ud.expand}</div>\n <div class="easyplayer-zoom-stop2">${ud.zoomStop}</div>\n </div>\n <div class="easyplayer-recording">\n <div class="easyplayer-recording-red-point"></div>\n <div class="easyplayer-recording-time">00:00:00</div>\n <div class="easyplayer-recording-stop">${ud.recordStop}</div>\n </div>\n `:""}\n\n ${i.hasControl?`\n <div class="easyplayer-controls">\n <div class="easyplayer-controls-bottom">\n <div class="easyplayer-controls-left">\n ${i.showBandwidth?'<div class="easyplayer-controls-item easyplayer-speed"></div>':""}\n <div class="easyplayer-playback-control-time"></div>\n <div class="easyplayer-controls-item-html">${i.controlHtml}</div>\n </div>\n ${i.playType===b&&i.playbackConfig.showControl&&i.playbackConfig.controlType===Z.normal?s:""}\n ${i.playType===b&&i.playbackConfig.showControl&&i.playbackConfig.controlType===Z.simple?'\n <div class="easyplayer-control-progress-simple">\n <div class="easyplayer-control-progress-inner">\n <div class="easyplayer-progress-hover"></div>\n <div class="easyplayer-progress-played"></div>\n <div class="easyplayer-progress-indicator"></div>\n <div class="easyplayer-progress-tip">00:00</div>\n </div>\n </div>\n ':""}\n <div class="easyplayer-controls-right">\n ${i.playType===b&&i.playbackConfig.showRateBtn?'\n <div class="easyplayer-controls-item-wrap">\n <div class="easyplayer-controls-item easyplayer-speed-menu">\n <div class="easyplayer-speed-icon-text"></div>\n <div class="easyplayer-speed-menu-list"></div>\n </div>\n </div>\n ':""}\n ${r.close?`<div class="easyplayer-controls-item-wrap"><div class="easyplayer-controls-item easyplayer-close">${ud.close}</div></div>`:""}\n ${r.logSave?`<div class="easyplayer-controls-item-wrap"><div class="easyplayer-controls-item easyplayer-logSave">${ud.logSave}</div></div>`:""}\n ${r.performance?`<div class="easyplayer-controls-item-wrap"><div class="easyplayer-controls-item easyplayer-performance">${ud.performance}</div><div class="easyplayer-controls-item easyplayer-performance-active">${ud.performanceActive}</div></div>`:""}\n ${r.aiFace?`<div class="easyplayer-controls-item-wrap"><div class="easyplayer-controls-item easyplayer-face">${ud.face}</div><div class="easyplayer-controls-item easyplayer-face-active">${ud.faceActive}</div></div>`:""}\n ${r.aiObject?`<div class="easyplayer-controls-item-wrap"><div class="easyplayer-controls-item easyplayer-object">${ud.object}</div><div class="easyplayer-controls-item easyplayer-object-active">${ud.objectActive}</div></div>`:""}\n ${r.aiOcclusion?`<div class="easyplayer-controls-item-wrap"><div class="easyplayer-controls-item easyplayer-occlusion">${ud.occlusion}</div><div class="easyplayer-controls-item easyplayer-occlusion-active">${ud.occlusionActive}</div></div>`:""}\n ${r.quality?'\n <div class="easyplayer-controls-item-wrap">\n <div class="easyplayer-controls-item easyplayer-quality-menu">\n <div class="easyplayer-quality-icon-text"></div>\n <div class="easyplayer-quality-menu-list"></div>\n </div>\n </div>\n ':""}\n ${r.scale?'\n <div class="easyplayer-controls-item-wrap">\n <div class="easyplayer-controls-item easyplayer-scale-menu">\n <div class="easyplayer-scale-icon-text"></div>\n <div class="easyplayer-scale-menu-list"></div>\n </div>\n </div>\n ':""}\n ${r.audio?`\n <div class="easyplayer-controls-item-wrap">\n <div class="easyplayer-controls-item easyplayer-volume">\n ${ud.audio}\n ${ud.mute}\n <div class="easyplayer-volume-panel-wrap">\n <div class="easyplayer-volume-panel">\n <div class="easyplayer-volume-panel-handle"></div>\n </div>\n <div class="easyplayer-volume-panel-text"></div>\n </div>\n </div>\n </div>\n `:""}\n ${r.play?`<div class="easyplayer-controls-item-wrap"><div class="easyplayer-controls-item easyplayer-play">${ud.play}</div><div class="easyplayer-controls-item easyplayer-pause">${ud.pause}</div></div>`:""}\n ${r.screenshot?`<div class="easyplayer-controls-item-wrap"><div class="easyplayer-controls-item easyplayer-screenshot">${ud.screenshot}</div></div>`:""}\n ${r.record?` <div class="easyplayer-controls-item-wrap"><div class="easyplayer-controls-item easyplayer-record">${ud.record}</div><div class="easyplayer-controls-item easyplayer-record-stop">${ud.recordStop}</div></div>`:""}\n ${r.ptz?` <div class="easyplayer-controls-item-wrap"><div class="easyplayer-controls-item easyplayer-ptz">${ud.ptz}</div><div class="easyplayer-controls-item easyplayer-ptz-active">${ud.ptzActive}</div></div>`:""}\n ${r.zoom?` <div class="easyplayer-controls-item-wrap"><div class="easyplayer-controls-item easyplayer-zoom">${ud.zoom}</div><div class="easyplayer-controls-item easyplayer-zoom-stop">${ud.zoomStop}</div></div>`:""}\n ${r.fullscreen?`<div class="easyplayer-controls-item-wrap"><div class="easyplayer-controls-item easyplayer-fullscreen">${ud.fullscreen}</div><div class="easyplayer-controls-item easyplayer-fullscreen-exit">${ud.fullscreenExit}</div></div>`:""}\n </div>\n </div>\n </div>\n `:""}\n <div class="easyplayer-performance-panel"></div>\n <div class="easyplayer-contextmenus"></div>\n <div class="easyplayer-tips-message">\n <div class="easyplayer-tips-message-close">\n <div class="easyplayer-tips-message-close-icon"></div>\n </div>\n <div class="easyplayer-tips-message-content"></div>\n </div>\n `),Object.defineProperty(t,"$poster",{value:e.$container.querySelector(".easyplayer-poster")}),Object.defineProperty(t,"$loadingBg",{value:e.$container.querySelector(".easyplayer-loading-bg")}),Object.defineProperty(t,"$loadingBgImage",{value:e.$container.querySelector(".easyplayer-loading-bg-image")}),Object.defineProperty(t,"$loading",{value:e.$container.querySelector(".easyplayer-loading")}),Object.defineProperty(t,"$loadingText",{value:e.$container.querySelector(".easyplayer-loading-text")}),Object.defineProperty(t,"$play",{value:e.$container.querySelector(".easyplayer-play")}),Object.defineProperty(t,"$playBig",{value:e.$container.querySelector(".easyplayer-play-big")}),Object.defineProperty(t,"$recording",{value:e.$container.querySelector(".easyplayer-recording")}),Object.defineProperty(t,"$recordingTime",{value:e.$container.querySelector(".easyplayer-recording-time")}),Object.defineProperty(t,"$recordingStop",{value:e.$container.querySelector(".easyplayer-recording-stop")}),Object.defineProperty(t,"$pause",{value:e.$container.querySelector(".easyplayer-pause")}),Object.defineProperty(t,"$controls",{value:e.$container.querySelector(".easyplayer-controls")}),Object.defineProperty(t,"$controlsInner",{value:e.$container.querySelector(".easyplayer-controls-bottom")}),Object.defineProperty(t,"$controlsLeft",{value:e.$container.querySelector(".easyplayer-controls-left")}),Object.defineProperty(t,"$controlsRight",{value:e.$container.querySelector(".easyplayer-controls-right")}),Object.defineProperty(t,"$volume",{value:e.$container.querySelector(".easyplayer-volume")}),Object.defineProperty(t,"$volumePanelWrap",{value:e.$container.querySelector(".easyplayer-volume-panel-wrap")}),Object.defineProperty(t,"$volumePanelText",{value:e.$container.querySelector(".easyplayer-volume-panel-text")}),Object.defineProperty(t,"$volumePanel",{value:e.$container.querySelector(".easyplayer-volume-panel")}),Object.defineProperty(t,"$volumeHandle",{value:e.$container.querySelector(".easyplayer-volume-panel-handle")}),Object.defineProperty(t,"$volumeOn",{value:e.$container.querySelector(".easyplayer-icon-audio")}),Object.defineProperty(t,"$volumeOff",{value:e.$container.querySelector(".easyplayer-icon-mute")}),Object.defineProperty(t,"$fullscreen",{value:e.$container.querySelector(".easyplayer-fullscreen")}),Object.defineProperty(t,"$fullscreenExit",{value:e.$container.querySelector(".easyplayer-fullscreen-exit")}),Object.defineProperty(t,"$record",{value:e.$container.querySelector(".easyplayer-record")}),Object.defineProperty(t,"$recordStop",{value:e.$container.querySelector(".easyplayer-record-stop")}),Object.defineProperty(t,"$screenshot",{value:e.$container.querySelector(".easyplayer-screenshot")}),Object.defineProperty(t,"$speed",{value:e.$container.querySelector(".easyplayer-speed")}),Object.defineProperty(t,"$controlHtml",{value:e.$container.querySelector(".easyplayer-controls-item-html")}),Object.defineProperty(t,"$playbackTime",{value:e.$container.querySelector(".easyplayer-controls-playback-time")}),Object.defineProperty(t,"$playbackTimeInner",{value:e.$container.querySelector(".easyplayer-controls-playback-time-inner")}),Object.defineProperty(t,"$playbackTimeScroll",{value:e.$container.querySelector(".easyplayer-controls-playback-time-scroll")}),Object.defineProperty(t,"$playbackTimeList",{value:e.$container.querySelector(".easyplayer-controls-playback-time-list")}),Object.defineProperty(t,"$playbackTimeListOne",{value:e.$container.querySelector(".easyplayer-playback-time-one-wrap")}),Object.defineProperty(t,"$playbackTimeListSecond",{value:e.$container.querySelector(".easyplayer-playback-time-second-wrap")}),Object.defineProperty(t,"$playbackCurrentTime",{value:e.$container.querySelector(".easyplayer-controls-playback-current-time")}),Object.defineProperty(t,"$playbackCurrentTimeText",{value:e.$container.querySelector(".easyplayer-controls-playback-current-time-text")}),Object.defineProperty(t,"$controlsPlaybackBtns",{value:e.$container.querySelector(".easyplayer-controls-playback-btns")}),Object.defineProperty(t,"$playbackNarrow",{value:e.$container.querySelector(".easyplayer-playback-narrow")}),Object.defineProperty(t,"$playbackExpand",{value:e.$container.querySelector(".easyplayer-playback-expand")}),Object.defineProperty(t,"$ptz",{value:e.$container.querySelector(".easyplayer-ptz")}),Object.defineProperty(t,"$ptzActive",{value:e.$container.querySelector(".easyplayer-ptz-active")}),Object.defineProperty(t,"$ptzControl",{value:e.$container.querySelector(".easyplayer-ptz-controls")}),Object.defineProperty(t,"$ptzBgActive",{value:e.$container.querySelector(".easyplayer-ptz-bg-active")}),Object.defineProperty(t,"$ptzControlCircular",{value:e.$container.querySelector(".easyplayer-ptz-control")}),Object.defineProperty(t,"$ptzArrows",{value:e.$container.querySelectorAll(".easyplayer-ptz-arrow")}),Object.defineProperty(t,"$ptzExpand",{value:e.$container.querySelector(".easyplayer-ptz-expand")}),Object.defineProperty(t,"$ptzNarrow",{value:e.$container.querySelector(".easyplayer-ptz-narrow")}),Object.defineProperty(t,"$ptzApertureFar",{value:e.$container.querySelector(".easyplayer-ptz-aperture-far")}),Object.defineProperty(t,"$ptzApertureNear",{value:e.$container.querySelector(".easyplayer-ptz-aperture-near")}),Object.defineProperty(t,"$ptzFocusFar",{value:e.$container.querySelector(".easyplayer-ptz-focus-far")}),Object.defineProperty(t,"$ptzFocusNear",{value:e.$container.querySelector(".easyplayer-ptz-focus-near")}),Object.defineProperty(t,"$qualityText",{value:e.$container.querySelector(".easyplayer-quality-icon-text")}),Object.defineProperty(t,"$qualityMenu",{value:e.$container.querySelector(".easyplayer-quality-menu")}),Object.defineProperty(t,"$qualityMenuList",{value:e.$container.querySelector(".easyplayer-quality-menu-list")}),Object.defineProperty(t,"$scaleText",{value:e.$container.querySelector(".easyplayer-scale-icon-text")}),Object.defineProperty(t,"$scaleMenu",{value:e.$container.querySelector(".easyplayer-scale-menu")}),Object.defineProperty(t,"$scaleMenuList",{value:e.$container.querySelector(".easyplayer-scale-menu-list")}),Object.defineProperty(t,"$zoom",{value:e.$container.querySelector(".easyplayer-zoom")}),Object.defineProperty(t,"$zoomStop",{value:e.$container.querySelector(".easyplayer-zoom-stop")}),Object.defineProperty(t,"$zoomNarrow",{value:e.$container.querySelector(".easyplayer-zoom-narrow")}),Object.defineProperty(t,"$zoomExpand",{value:e.$container.querySelector(".easyplayer-zoom-expand")}),Object.defineProperty(t,"$zoomStop2",{value:e.$container.querySelector(".easyplayer-zoom-stop2")}),Object.defineProperty(t,"$close",{value:e.$container.querySelector(".easyplayer-close")}),Object.defineProperty(t,"$zoomControls",{value:e.$container.querySelector(".easyplayer-zoom-controls")}),Object.defineProperty(t,"$performancePanel",{value:e.$container.querySelector(".easyplayer-performance-panel")}),Object.defineProperty(t,"$performance",{value:e.$container.querySelector(".easyplayer-performance")}),Object.defineProperty(t,"$performanceActive",{value:e.$container.querySelector(".easyplayer-performance-active")}),Object.defineProperty(t,"$faceDetect",{value:e.$container.querySelector(".easyplayer-face")}),Object.defineProperty(t,"$faceDetectActive",{value:e.$container.querySelector(".easyplayer-face-active")}),Object.defineProperty(t,"$objectDetect",{value:e.$container.querySelector(".easyplayer-object")}),Object.defineProperty(t,"$objectDetectActive",{value:e.$container.querySelector(".easyplayer-object-active")}),Object.defineProperty(t,"$occlusionDetect",{value:e.$container.querySelector(".easyplayer-occlusion")}),Object.defineProperty(t,"$occlusionDetectActive",{value:e.$container.querySelector(".easyplayer-occlusion-active")}),Object.defineProperty(t,"$contextmenus",{value:e.$container.querySelector(".easyplayer-contextmenus")}),Object.defineProperty(t,"$speedText",{value:e.$container.querySelector(".easyplayer-speed-icon-text")}),Object.defineProperty(t,"$speedMenu",{value:e.$container.querySelector(".easyplayer-speed-menu")}),Object.defineProperty(t,"$speedMenuList",{value:e.$container.querySelector(".easyplayer-speed-menu-list")}),Object.defineProperty(t,"$logSave",{value:e.$container.querySelector(".easyplayer-logSave")}),Object.defineProperty(t,"$playbackProgress",{value:e.$container.querySelector(".easyplayer-control-progress-simple")}),Object.defineProperty(t,"$playbackProgressTip",{value:e.$container.querySelector(".easyplayer-progress-tip")}),Object.defineProperty(t,"$playbackProgressHover",{value:e.$container.querySelector(".easyplayer-progress-hover")}),Object.defineProperty(t,"$playbackProgressPlayed",{value:e.$container.querySelector(".easyplayer-progress-played")}),Object.defineProperty(t,"$playbackProgressIndicator",{value:e.$container.querySelector(".easyplayer-progress-indicator")}),Object.defineProperty(t,"$playbackProgressTime",{value:e.$container.querySelector(".easyplayer-playback-control-time")}),Object.defineProperty(t,"$tipsMessage",{value:e.$container.querySelector(".easyplayer-tips-message")}),Object.defineProperty(t,"$tipsMessageClose",{value:e.$container.querySelector(".easyplayer-tips-message-close")}),Object.defineProperty(t,"$tipsMessageContent",{value:e.$container.querySelector(".easyplayer-tips-message-content")})})(e,this),e._opt.extendOperateBtns.length>0&&e._opt.extendOperateBtns.forEach((e=>{this.addExtendBtn(e)})),e._opt.extendDomConfig&&e._opt.extendDomConfig.html&&this.addExtendDom(e._opt.extendDomConfig),t=this,Object.defineProperty(t,"controlsRect",{get:()=>t.$controls.getBoundingClientRect()}),Object.defineProperty(t,"controlsInnerRect",{get:()=>t.$controlsInner.getBoundingClientRect()}),Object.defineProperty(t,"controlsLeftRect",{get:()=>t.$controlsLeft.getBoundingClientRect()}),Object.defineProperty(t,"controlsRightRect",{get:()=>t.$controlsRight.getBoundingClientRect()}),Object.defineProperty(t,"controlsPlaybackTimeInner",{get:()=>t.$playbackTimeInner&&t.$playbackTimeInner.getBoundingClientRect()||{}}),Object.defineProperty(t,"controlsPlaybackBtnsRect",{get:()=>t.$controlsPlaybackBtns&&t.$controlsPlaybackBtns.getBoundingClientRect()||{width:0}}),Td(e,this),((e,t)=>{const{events:{proxy:i},debug:r}=e,s=e._opt,a=s.operateBtns;function n(e){const{bottom:i,height:r}=t.$volumePanel.getBoundingClientRect(),{height:s}=t.$volumeHandle.getBoundingClientRect();return bs(i-e.y-s/2,0,r-s/2)/(r-s)}if(Cs()&&i(window,["click","contextmenu"],(i=>{i.composedPath().indexOf(e.$container)>-1?t.isFocus=!0:t.isFocus=!1})),i(t.$controls,"click",(e=>{e.stopPropagation()})),a.play&&(i(t.$pause,"click",(t=>{s.playType===b&&s.playbackConfig.uiUsePlaybackPause?e.playbackPause=!0:ha(a.pauseFn)?a.pauseFn():e.pauseForControl()})),i(t.$play,"click",(t=>{s.playType===b&&e.playbackPause?e.playbackPause=!1:ha(a.playFn)?a.playFn():e.playForControl().then((()=>{e.resumeAudioAfterPause()}))}))),i(t.$playBig,"click",(t=>{s.playType===b&&e.playbackPause?e.playbackPause=!1:ha(a.playFn)?a.playFn():e.playForControl().then((()=>{e.resumeAudioAfterPause()}))})),a.screenshot&&i(t.$screenshot,"click",(t=>{e.emit(st.screenshot,!0),t.stopPropagation(),ha(a.screenshotFn)?a.screenshotFn():e.video.screenshot()})),a.audio&&(Cs()&&(i(t.$volume,"mouseover",(()=>{t.$volumePanelWrap.classList.add("easyplayer-volume-panel-wrap-show")})),i(t.$volume,"mouseout",(()=>{t.$volumePanelWrap.classList.remove("easyplayer-volume-panel-wrap-show")})),i(t.$volumePanel,"click",(t=>{e.emit(st.mute,e.volume>0),t.stopPropagation(),e.volume=n(t)})),i(t.$volumeHandle,"mousedown",(e=>{e.stopPropagation(),t.isVolumeDroging=!0})),i(t.$volumeHandle,"mousemove",(i=>{t.isVolumeDroging&&(e.volume=n(i))})),i(document,"mouseup",(()=>{t.isVolumeDroging&&(t.isVolumeDroging=!1)}))),i(t.$volumeOn,"click",(i=>{i.stopPropagation(),_s(t.$volumeOn,"display","none"),_s(t.$volumeOff,"display","block");const r=e.volume;e.volume=0,e._lastVolume=Cs()?r:1})),i(t.$volumeOff,"click",(i=>{i.stopPropagation(),_s(t.$volumeOn,"display","block"),_s(t.$volumeOff,"display","none"),e.volume=Cs()?e.lastVolume||.5:1}))),a.record&&(i(t.$record,"click",(t=>{t.stopPropagation(),ha(a.recordFn)?a.recordFn():e.recording=!0})),i(t.$recordStop,"click",(t=>{t.stopPropagation(),ha(a.recordStopFn)?a.recordStopFn():e.recording=!1}))),i(t.$recordingStop,"click",(t=>{t.stopPropagation(),ha(a.recordStopFn)?a.recordStopFn():e.recording=!1})),a.fullscreen&&(i(t.$fullscreen,"click",(t=>{t.stopPropagation(),ha(a.fullscreenFn)?a.fullscreenFn():e.fullscreen=!0})),i(t.$fullscreenExit,"click",(t=>{t.stopPropagation(),ha(a.fullscreenExitFn)?a.fullscreenExitFn():e.fullscreen=!1}))),a.ptz){if(i(t.$ptz,"click",(e=>{e.stopPropagation(),_s(t.$ptzActive,"display","flex"),_s(t.$ptz,"display","none"),t.$ptzControl.classList.add("easyplayer-ptz-controls-show")})),i(t.$ptzActive,"click",(e=>{e.stopPropagation(),_s(t.$ptz,"display","flex"),_s(t.$ptzActive,"display","none"),t.$ptzControl.classList.remove("easyplayer-ptz-controls-show")})),t.$ptzArrows.forEach((r=>{if(s.ptzClickType===X)i(r,"click",(i=>{i.stopPropagation();const r=i.currentTarget.dataset.arrow;t.$ptzBgActive.classList.add("easyplayer-ptz-bg-active-show"),t.$ptzBgActive.classList.add(`easyplayer-ptz-bg-active-${r}`),t.$ptzControlCircular.classList.add(`easyplayer-ptz-control-${r}`),e.emit(st.ptz,Ra(r)),setTimeout((()=>{t.$ptzBgActive.classList.remove("easyplayer-ptz-bg-active-show"),li.forEach((e=>{t.$ptzBgActive.classList.remove(`easyplayer-ptz-bg-active-${e}`),t.$ptzControlCircular.classList.remove(`easyplayer-ptz-control-${e}`)})),e.emit(st.ptz,di)}),1e3*s.ptzStopEmitDelay)}));else if(s.ptzClickType===J){let s=!1;i(r,"mousedown",(i=>{i.stopPropagation(),s=!0;const r=i.currentTarget.dataset.arrow;t.$ptzBgActive.classList.add("easyplayer-ptz-bg-active-show"),t.$ptzBgActive.classList.add(`easyplayer-ptz-bg-active-${r}`),t.$ptzControlCircular.classList.add(`easyplayer-ptz-control-${r}`),e.emit(st.ptz,Ra(r))}));const a=()=>{s=!1,t.$ptzBgActive.classList.remove("easyplayer-ptz-bg-active-show"),li.forEach((e=>{t.$ptzBgActive.classList.remove(`easyplayer-ptz-bg-active-${e}`),t.$ptzControlCircular.classList.remove(`easyplayer-ptz-control-${e}`)})),e.emit(st.ptz,di)};i(r,"mouseup",(e=>{e.stopPropagation(),s&&a()})),i(window,"mouseup",(e=>{e.stopPropagation(),s&&a()}))}})),s.ptzZoomShow)if(s.ptzClickType===X)i(t.$ptzExpand,"click",(t=>{t.stopPropagation(),e.emit(st.ptz,ci),setTimeout((()=>{e.emit(st.ptz,di)}),1e3*s.ptzStopEmitDelay)})),i(t.$ptzNarrow,"click",(t=>{t.stopPropagation(),e.emit(st.ptz,ui),setTimeout((()=>{e.emit(st.ptz,di)}),1e3*s.ptzStopEmitDelay)}));else if(s.ptzClickType===J){let r=!1,s=!1;i(t.$ptzExpand,"mousedown",(t=>{t.stopPropagation(),r=!0,e.emit(st.ptz,ci)})),i(t.$ptzNarrow,"mousedown",(t=>{t.stopPropagation(),s=!0,e.emit(st.ptz,ui)}));const a=()=>{r=!1,s=!1,e.emit(st.ptz,di)};i(t.$ptzExpand,"mouseup",(e=>{e.stopPropagation(),r&&a()})),i(t.$ptzNarrow,"mouseup",(e=>{e.stopPropagation(),s&&a()})),i(window,"mouseup",(e=>{e.stopPropagation(),(r||s)&&a()}))}if(s.ptzApertureShow)if(s.ptzClickType===X)i(t.$ptzApertureFar,"click",(t=>{t.stopPropagation(),e.emit(st.ptz,pi),setTimeout((()=>{e.emit(st.ptz,hi)}),1e3*s.ptzStopEmitDelay)})),i(t.$ptzApertureNear,"click",(t=>{t.stopPropagation(),e.emit(st.ptz,fi),setTimeout((()=>{e.emit(st.ptz,hi)}),1e3*s.ptzStopEmitDelay)}));else if(s.ptzClickType===J){let r=!1,s=!1;i(t.$ptzApertureFar,"mousedown",(t=>{t.stopPropagation(),r=!0,e.emit(st.ptz,pi)})),i(t.$ptzApertureNear,"mousedown",(t=>{t.stopPropagation(),s=!0,e.emit(st.ptz,fi)}));const a=()=>{r=!1,s=!1,e.emit(st.ptz,hi)};i(t.$ptzApertureFar,"mouseup",(e=>{e.stopPropagation(),r&&a()})),i(t.$ptzApertureNear,"mouseup",(e=>{e.stopPropagation(),s&&a()})),i(window,"mouseup",(e=>{e.stopPropagation(),(r||s)&&a()}))}if(s.ptzFocusShow)if(s.ptzClickType===X)i(t.$ptzFocusFar,"click",(t=>{t.stopPropagation(),e.emit(st.ptz,yi),setTimeout((()=>{e.emit(st.ptz,hi)}),1e3*s.ptzStopEmitDelay)})),i(t.$ptzFocusNear,"click",(t=>{t.stopPropagation(),e.emit(st.ptz,mi),setTimeout((()=>{e.emit(st.ptz,hi)}),1e3*s.ptzStopEmitDelay)}));else if(s.ptzClickType===J){let r=!1,s=!1;i(t.$ptzFocusFar,"mousedown",(t=>{t.stopPropagation(),r=!0,e.emit(st.ptz,yi)})),i(t.$ptzFocusNear,"mousedown",(t=>{t.stopPropagation(),s=!0,e.emit(st.ptz,mi)}));const a=()=>{r=!1,s=!1,e.emit(st.ptz,hi)};i(t.$ptzFocusFar,"mouseup",(e=>{e.stopPropagation(),r&&a()})),i(t.$ptzFocusNear,"mouseup",(e=>{e.stopPropagation(),s&&a()})),i(window,"mouseup",(e=>{e.stopPropagation(),(r||s)&&a()}))}}if(a.performance&&(i(t.$performance,"click",(t=>{t.stopPropagation(),e.togglePerformancePanel(!0)})),i(t.$performanceActive,"click",(t=>{t.stopPropagation(),e.togglePerformancePanel(!1)}))),a.logSave&&i(t.$logSave,"click",(t=>{t.stopPropagation(),e.downloadMemoryLog()})),a.aiFace&&(i(t.$faceDetect,"click",(t=>{t.stopPropagation(),e.faceDetect(!0)})),i(t.$faceDetectActive,"click",(t=>{t.stopPropagation(),e.faceDetect(!1)}))),a.aiObject&&(i(t.$objectDetect,"click",(t=>{t.stopPropagation(),e.objectDetect(!0)})),i(t.$objectDetectActive,"click",(t=>{t.stopPropagation(),e.objectDetect(!1)}))),a.aiOcclusion&&(i(t.$occlusionDetect,"click",(t=>{t.stopPropagation(),e.occlusionDetect(!0)})),i(t.$occlusionDetectActive,"click",(t=>{t.stopPropagation(),e.occlusionDetect(!1)}))),e._opt.hasControl&&e._opt.controlAutoHide){i(e.$container,"mouseover",(()=>{e.fullscreen||(_s(t.$controls,"display","block"),s())})),i(e.$container,"mousemove",(()=>{e.$container&&t.$controls&&(e.fullscreen,"none"===t.$controls.style.display&&(_s(t.$controls,"display","block"),s()))})),i(e.$container,"mouseout",(()=>{a(),_s(t.$controls,"display","none")}));let r=null;const s=()=>{a(),r=setTimeout((()=>{_s(t.$controls,"display","none")}),5e3)},a=()=>{r&&(clearTimeout(r),r=null)}}if(e._opt.playType===b){let r=e._opt.playbackConfig.controlType;e._opt.playbackConfig.showRateBtn&&(i(t.$speedMenu,"mouseover",(()=>{t.$speedMenuList.classList.add("easyplayer-speed-menu-shown")})),i(t.$speedMenu,"mouseout",(()=>{t.$speedMenuList.classList.remove("easyplayer-speed-menu-shown")})),i(t.$speedMenuList,"click",(t=>{const i=la(t);if(i.matches("div.easyplayer-speed-menu-item")){const t=i.dataset;e.emit(st.playbackPreRateChange,t.speed)}}))),r===Z.normal?(i(t.$playbackNarrow,"click",(t=>{t.stopPropagation(),e.playback&&e.playback.narrowPrecision()})),i(t.$playbackExpand,"click",(t=>{t.stopPropagation(),e.playback&&e.playback.expandPrecision()})),i(t.$playbackTimeList,"click",(t=>{const i=la(t);i.matches("div.easyplayer-playback-time-minute-one")&&e.playback&&e.playback.seek(i.dataset)})),e._opt.playbackConfig.supportWheel&&i(t.$playbackTimeInner,"wheel",(t=>{t.preventDefault(),(t.wheelDelta?t.wheelDelta/120:-(t.detail||0)/3)>0?e.playback&&e.playback.expandPrecision():e.playback&&e.playback.narrowPrecision()}))):r===Z.simple&&(t.isDroging=!1,i(t.$playbackProgress,"click",(i=>{if(i.target!==t.$playbackProgressIndicator){let r=0,s=0;if(e.isInWebFullscreen())r=i.touches[0].clientY/e.height,s=r*e.playback.totalDuration;else{const a=bd(t,e.playback.totalDuration,i);r=a.percentage,s=a.second}e.playback&&e.playback.seek({time:s})}})),i(t.$playbackProgress,"mousemove",(i=>{_s(t.$playbackProgressTip,"display","block");const{width:r,time:s}=bd(t,e.playback.totalDuration,i);t.$playbackProgressTip.innerHTML=s;const a=t.$playbackProgressTip.clientWidth;r<=a/2?_s(t.$playbackProgressTip,"left",0):r>t.$playbackProgress.clientWidth-a/2?_s(t.$playbackProgressTip,"left",t.$playbackProgress-a+"px"):_s(t.$playbackProgressTip,"left",r-a/2+"px")})),i(t.$playbackProgress,"mouseout",(()=>{_s(t.$playbackProgressTip,"display","none")})),i(t.$playbackProgressIndicator,"mousedown",(e=>{t.isDroging=!0})),i(t.$playbackProgress,"mousemove",(i=>{if(t.isDroging){const{second:r,percentage:s}=bd(t,e.playback.totalDuration,i);e.playback&&e.playback.seek({time:r})}})),i(t.$playbackProgress,"mouseup",(e=>{t.isDroging&&(t.isDroging=!1)})))}a.quality&&(i(t.$qualityMenu,"mouseover",(()=>{t.$qualityMenuList.classList.add("easyplayer-quality-menu-shown")})),i(t.$qualityMenu,"mouseout",(()=>{t.$qualityMenuList.classList.remove("easyplayer-quality-menu-shown")})),i(t.$qualityMenuList,"click",(t=>{const i=la(t);if(i.matches("div.easyplayer-quality-menu-item")){const t=i.dataset;e.streamQuality=t.quality}}))),a.scale&&(i(t.$scaleMenu,"mouseover",(()=>{t.$scaleMenuList.classList.add("easyplayer-scale-menu-shown")})),i(t.$scaleMenu,"mouseout",(()=>{t.$scaleMenuList.classList.remove("easyplayer-scale-menu-shown")})),i(t.$scaleMenuList,"click",(t=>{const i=la(t);if(i.matches("div.easyplayer-scale-menu-item")){const t=i.dataset;e.setScaleMode(t.scale)}}))),a.zoom&&(i(t.$zoom,"click",(t=>{t.stopPropagation(),e.zooming=!0})),i(t.$zoomStop,"click",(t=>{t.stopPropagation(),e.zooming=!1}))),i(t.$zoomExpand,"click",(t=>{t.stopPropagation(),e.zoom&&e.zoom.expandPrecision()})),i(t.$zoomNarrow,"click",(t=>{t.stopPropagation(),e.zoom&&e.zoom.narrowPrecision()})),i(t.$zoomStop2,"click",(t=>{t.stopPropagation(),e.zooming=!1})),a.close&&i(t.$close,"click",(t=>{t.stopPropagation(),e.doDestroy()})),i(t.$tipsMessageClose,"click",(e=>{e.stopPropagation(),t.$tipsMessageContent.innerHTML="",_s(t.$tipsMessage,"display","none")}))})(e,this),e._opt.hotKey&&((e,t)=>{const{events:{proxy:i}}=e,r={};function s(e,t){r[e]?r[e].push(t):r[e]=[t]}s(Zt,(()=>{e.fullscreen&&(e.fullscreen=!1)})),s(ei,(()=>{e.volume+=.05})),s(ti,(()=>{e.volume-=.05})),i(window,"keydown",(e=>{if(t.isFocus){const t=document.activeElement.tagName.toUpperCase(),i=document.activeElement.getAttribute("contenteditable");if("INPUT"!==t&&"TEXTAREA"!==t&&""!==i&&"true"!==i){const t=r[e.keyCode];t&&(e.preventDefault(),t.forEach((e=>e())))}}}))})(e,this),this.btnIndex=0,this.initLoadingBackground(),sa(e._opt.loadingIconStyle)&&this.initLoadingIconStyle(e._opt.loadingIconStyle),this.kbpsShow="0 KB/s",this.player.debug.log("Control","init")}destroy(){if(this.$performancePanel){this.$performancePanel.innerHTML="";if(!Sd(this.$performancePanel)){const e=this.player.$container.querySelector(".easyplayer-performance-panel");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$poster){if(!Sd(this.$poster)){const e=this.player.$container.querySelector(".easyplayer-poster");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$loading){if(!Sd(this.$loading)){const e=this.player.$container.querySelector(".easyplayer-loading");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$loadingBg){if(!Sd(this.$loadingBg)){const e=this.player.$container.querySelector(".easyplayer-loading-bg");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$controls){if(!Sd(this.$controls)){const e=this.player.$container.querySelector(".easyplayer-controls");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$playBig){if(!Sd(this.$playBig)){const e=this.player.$container.querySelector(".easyplayer-play-big");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$recording){if(!Sd(this.$recording)){const e=this.player.$container.querySelector(".easyplayer-recording");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$ptzControl){if(!Sd(this.$ptzControl)){const e=this.player.$container.querySelector(".easyplayer-ptz-controls");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$zoomControls){if(!Sd(this.$zoomControls)){const e=this.player.$container.querySelector(".easyplayer-zoom-controls");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$contextmenus){this.$contextmenus.innerHTML="";if(!Sd(this.$contextmenus)){const e=this.player.$container.querySelector(".easyplayer-contextmenus");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$tipsMessage){if(!Sd(this.$tipsMessage)){const e=this.player.$container.querySelector(".easyplayer-tips-message");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$extendDom){if(!Sd(this.$extendDom)){const e=this.player.$container.querySelector(".easyplayer-extend-dom");e&&this.player.$container&&this.player.$container.removeChild(e)}}this.btnIndex=0,this.extendBtnList=[],this.kbpsShow="0 KB/s",this.player.$container&&(this.player.$container.classList.remove("easyplayer-controls-show-auto-hide"),this.player.$container.classList.remove("easyplayer-controls-show")),this.player.debug.log("Control","destroy")}getBtnIndex(){return this.btnIndex++}autoSize(){const e=this.player;e.$container.style.padding="0 0";const t=e.width,i=e.height,r=t/i,s=e.video.$videoElement.width/e.video.$videoElement.height;if(r>s){const r=(t-i*s)/2;e.$container.style.padding=`0 ${r}px`}else{const r=(i-t/s)/2;e.$container.style.padding=`${r}px 0`}}initLoadingBackground(){const e=this.player;e._opt.loadingBackground&&e._opt.loadingBackgroundWidth&&e._opt.loadingBackgroundHeight&&(e.debug.log("Control","initLoadingBackground()"),"default"===this.player._opt.aspectRatio||ks()?(e.getRenderType()===K||e.getRenderType()===q)&&this._initLoadingBackground():this._initLoadingBackgroundForRatio(),wd(this.$loadingBg,"display","block"),e._opt.loadingBackground="",e._opt.loadingBackgroundWidth=0,e._opt.loadingBackgroundHeight=0)}initLoadingIconStyle(e){const t=this.player.$container.querySelector(".easyplayer-icon-loading");t&&(e.width&&wd(t,"width",`${e.width}px`),e.height&&wd(t,"height",`${e.height}px`),e.background&&wd(t,"backgroundImage",`url("${e.background}")`),!1===e.hasAnimation&&(wd(t,"animationName","none"),wd(t,"animationDuration",0),wd(t,"animationTimingFunction","ease"),wd(t,"animationIterationCount",1)))}_initLoadingBackgroundForRatio(){const e=this.player._opt.aspectRatio.split(":").map(Number);let t=this.player.width,i=this.player.height;const r=this.player._opt;let s=0;r.hasControl&&!r.controlAutoHide&&(s=r.playType===b?Pt:0,i-=s);const a=this.player._opt.loadingBackgroundWidth,n=this.player._opt.loadingBackgroundHeight,o=a/n,l=e[0]/e[1];if(this.$loadingBgImage.src=this.player._opt.loadingBackground,o>l){const e=l*n/a;this.$loadingBgImage.style.width=100*e+"%",this.$loadingBgImage.style.height=`calc(100% - ${s}px)`,this.$loadingBgImage.style.padding=`0 ${(t-t*e)/2}px`}else{const e=a/l/n;this.$loadingBgImage.style.width="100%",this.$loadingBgImage.style.height=`calc(${100*e}% - ${s}px)`,this.$loadingBgImage.style.padding=(i-i*e)/2+"px 0"}}_initLoadingBackground(){const e=this.player;let t=e.height;const i=e._opt;if(i.hasControl&&!i.controlAutoHide){t-=i.playType===b?Pt:0}let r=e.width,s=t;const a=i.rotate;270!==a&&90!==a||(r=t,s=e.width),this.$loadingBgImage.width=r,this.$loadingBgImage.height=s,this.$loadingBgImage.src=e._opt.loadingBackground;let n=(e.width-r)/2,o=(t-s)/2,l="contain";i.isResize||(l="fill"),i.isFullResize&&(l="none");let d="";"none"===i.mirrorRotate&&a&&(d+=" rotate("+a+"deg)"),"level"===i.mirrorRotate?d+=" rotateY(180deg)":"vertical"===i.mirrorRotate&&(d+=" rotateX(180deg)"),this.player._opt.videoRenderSupportScale&&(this.$loadingBgImage.style.objectFit=l),this.$loadingBgImage.style.transform=d,this.$loadingBgImage.style.padding="0",this.$loadingBgImage.style.left=n+"px",this.$loadingBgImage.style.top=o+"px"}_validateExtendBtn(e){let t=!0;if(e.name||(this.player.debug.warn("Control","extend button name is required"),t=!1),t){-1!==this.extendBtnList.findIndex((t=>t.name===e.name))&&(this.player.debug.warn("Control",`extend button name: ${e.name} is already exist`),t=!1)}return t&&(e.icon||(this.player.debug.warn("Control","extend button icon is required"),t=!1)),t}addExtendBtn(e={}){const t=_a(rr);if(e=Object.assign({},t,e),!this._validateExtendBtn(e))return;const i=e.name||"",r=this.$controlsRight,s=e.activeIcon&&e.activeClick,a=`\n <div class="easyplayer-controls-item-wrap easyplayer-controls-item-wrap-${i}">\n ${e.icon?`<div class="easyplayer-controls-item easyplayer-control-extend-${i}">\n <i class="easyplayer-icon easyplayer-icon-extend-${i}"></i>\n ${e.iconTitle?`\n <span class="icon-title-tips"><span class="icon-title">${e.iconTitle}</span></span>\n `:""}\n </div>`:""}\n ${e.activeIcon?`<div class="easyplayer-controls-item easyplayer-control-extend-${i}-active">\n <i class="easyplayer-icon easyplayer-icon-extend-${i}-active"></i>\n ${e.activeIconTitle?`\n <span class="icon-title-tips"><span class="icon-title">${e.activeIconTitle}</span></span>\n `:""}\n </div>`:""}\n </div>\n `,n=Array.from(r.children)[e.index];n?n.insertAdjacentHTML("beforebegin",a):_d(r,a);const o=r.querySelector(`.easyplayer-controls-item-wrap-${i}`),l=e.icon?r.querySelector(`.easyplayer-icon-extend-${i}`):null,d=e.icon?r.querySelector(`.easyplayer-control-extend-${i}`):null,h=e.activeIcon?r.querySelector(`.easyplayer-icon-extend-${i}-active`):null,c=e.activeIcon?r.querySelector(`.easyplayer-control-extend-${i}-active`):null,{events:{proxy:u},debug:p}=this.player;e.icon&&(wd(l,"background",`url(${e.icon}) no-repeat center`),wd(l,"background-size","100% 100%"),wd(d,"display","none"),e.iconHover&&(u(l,"mouseover",(()=>{wd(l,"background",`url(${e.iconHover}) no-repeat center`),wd(l,"background-size","100% 100%")})),u(l,"mouseout",(()=>{wd(l,"background",`url(${e.icon}) no-repeat center`),wd(l,"background-size","100% 100%")})))),e.activeIcon&&(wd(h,"background",`url(${e.activeIcon}) no-repeat center`),wd(h,"background-size","100% 100%"),wd(c,"display","none"),e.activeIconHover&&(u(h,"mouseover",(()=>{wd(h,"background",`url(${e.activeIconHover}) no-repeat center`),wd(h,"background-size","100% 100%")})),u(h,"mouseout",(()=>{wd(h,"background",`url(${e.activeIcon}) no-repeat center`),wd(h,"background-size","100% 100%")})))),e.click&&l&&u(l,"click",(t=>{t.preventDefault(),s&&(wd(d,"display","none"),wd(c,"display","flex")),this.player.isInMulti()?e.click.call(this.player,t,this.player._opt.multiIndex):e.click.call(this.player,t)})),e.activeClick&&h&&u(h,"click",(t=>{t.preventDefault(),wd(d,"display","flex"),wd(c,"display","none"),this.player.isInMulti()?e.activeClick.call(this.player,t,this.player._opt.multiIndex):e.activeClick.call(this.player,t)})),this.extendBtnList.push({name:i,$iconContainer:o,$iconWrap:d,$activeIconWrap:c})}addExtendDom(e){if(this.player.debug.log(this.TAG_NAME,"addExtendDom"),e.html){const t=`\n <div class="easyplayer-extend-dom">\n ${e.html}\n </div>\n `;this.player.$container.insertAdjacentHTML("beforeend",t),Object.defineProperty(this,"$extendDom",{value:this.player.$container.querySelector(".easyplayer-extend-dom")}),e.showBeforePlay&&wd(this.$extendDom,"display","block")}}toggleExtendDom(e){this.$extendDom&&(js(e)||(e="none"===this.$extendDom.style.display),wd(this.$extendDom,"display",e?"block":"none"))}updateExtendDom(e){this.player.debug.log(this.TAG_NAME,"updateExtendDom"),this.$extendDom&&(this.$extendDom.innerHTML=e)}removeExtendDom(){this.player.debug.log(this.TAG_NAME,"removeExtendDom"),this.$extendDom&&(this.$extendDom.innerHTML="")}updateLoadingText(e){this.$loadingText&&(this.$loadingText.innerText=e)}getExtendBtnList(){return this.extendBtnList}showTipsMessage(e,t){const i=this.$tipsMessage,r=this.$tipsMessageContent;if(i){const s=`\n <div class="easyplayer-tips-message-content-item">${e}</div>\n ${t?`<div class="easyplayer-tips-message-content-item">Error Type:${t}</div>`:""}\n `;r.innerHTML=s,wd(i,"display","block")}}hideTipsMessage(){const e=this.$tipsMessage;e&&($tipsMessageContent.innerHTML="",wd(e,"display","none"))}}kd(".easyplayer-container{position:relative;width:100%;height:100%;overflow:hidden}.easyplayer-container.easyplayer-fullscreen-web{position:fixed;z-index:9999;left:0;top:0;right:0;bottom:0;width:100vw!important;height:100vh!important;background:#000}");class Dd{static init(){Dd.types={avc1:[],avcC:[],hvc1:[],hvcC:[],av01:[],av1C:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[],".mp3":[],Opus:[],dOps:[],"ac-3":[],dac3:[],"ec-3":[],dec3:[]};for(let e in Dd.types)Dd.types.hasOwnProperty(e)&&(Dd.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let e=Dd.constants={};e.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),e.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),e.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSC=e.STCO=e.STTS,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.HDLR_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]),e.HDLR_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]),e.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}static box(e){let t=8,i=null,r=Array.prototype.slice.call(arguments,1),s=r.length;for(let e=0;e<s;e++)t+=r[e].byteLength;i=new Uint8Array(t),i[0]=t>>>24&255,i[1]=t>>>16&255,i[2]=t>>>8&255,i[3]=255&t,i.set(e,4);let a=8;for(let e=0;e<s;e++)i.set(r[e],a),a+=r[e].byteLength;return i}static generateInitSegment(e){let t=Dd.box(Dd.types.ftyp,Dd.constants.FTYP),i=Dd.moov(e),r=new Uint8Array(t.byteLength+i.byteLength);return r.set(t,0),r.set(i,t.byteLength),r}static moov(e){let t=Dd.mvhd(e.timescale,e.duration),i=Dd.trak(e),r=Dd.mvex(e);return Dd.box(Dd.types.moov,t,i,r)}static mvhd(e,t){return Dd.box(Dd.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e,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]))}static trak(e){return Dd.box(Dd.types.trak,Dd.tkhd(e),Dd.mdia(e))}static tkhd(e){let t=e.id,i=e.duration,r=e.presentWidth,s=e.presentHeight;return Dd.box(Dd.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,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,0,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,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>>8&255,255&r,0,0,s>>>8&255,255&s,0,0]))}static mdia(e){return Dd.box(Dd.types.mdia,Dd.mdhd(e),Dd.hdlr(e),Dd.minf(e))}static mdhd(e){let t=e.timescale,i=e.duration;return Dd.box(Dd.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,i>>>24&255,i>>>16&255,i>>>8&255,255&i,85,196,0,0]))}static hdlr(e){let t=null;return t="audio"===e.type?Dd.constants.HDLR_AUDIO:Dd.constants.HDLR_VIDEO,Dd.box(Dd.types.hdlr,t)}static minf(e){let t=null;return t="audio"===e.type?Dd.box(Dd.types.smhd,Dd.constants.SMHD):Dd.box(Dd.types.vmhd,Dd.constants.VMHD),Dd.box(Dd.types.minf,t,Dd.dinf(),Dd.stbl(e))}static dinf(){return Dd.box(Dd.types.dinf,Dd.box(Dd.types.dref,Dd.constants.DREF))}static stbl(e){return Dd.box(Dd.types.stbl,Dd.stsd(e),Dd.box(Dd.types.stts,Dd.constants.STTS),Dd.box(Dd.types.stsc,Dd.constants.STSC),Dd.box(Dd.types.stsz,Dd.constants.STSZ),Dd.box(Dd.types.stco,Dd.constants.STCO))}static stsd(e){return"audio"===e.type?"mp3"===e.audioType?Dd.box(Dd.types.stsd,Dd.constants.STSD_PREFIX,Dd.mp3(e)):Dd.box(Dd.types.stsd,Dd.constants.STSD_PREFIX,Dd.mp4a(e)):"avc"===e.videoType?Dd.box(Dd.types.stsd,Dd.constants.STSD_PREFIX,Dd.avc1(e)):Dd.box(Dd.types.stsd,Dd.constants.STSD_PREFIX,Dd.hvc1(e))}static mp3(e){let t=e.channelCount,i=e.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,i>>>8&255,255&i,0,0]);return Dd.box(Dd.types[".mp3"],r)}static mp4a(e){let t=e.channelCount,i=e.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,i>>>8&255,255&i,0,0]);return Dd.box(Dd.types.mp4a,r,Dd.esds(e))}static esds(e){let t=e.config||[],i=t.length,r=new Uint8Array([0,0,0,0,3,23+i,0,1,0,4,15+i,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([i]).concat(t).concat([6,1,2]));return Dd.box(Dd.types.esds,r)}static avc1(e){let t=e.avcc;const i=e.codecWidth,r=e.codecHeight;let s=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,i>>>8&255,255&i,r>>>8&255,255&r,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,255,255]);return Dd.box(Dd.types.avc1,s,Dd.box(Dd.types.avcC,t))}static hvc1(e){let t=e.avcc;const i=e.codecWidth,r=e.codecHeight;let s=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,i>>>8&255,255&i,r>>>8&255,255&r,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,255,255]);return Dd.box(Dd.types.hvc1,s,Dd.box(Dd.types.hvcC,t))}static mvex(e){return Dd.box(Dd.types.mvex,Dd.trex(e))}static trex(e){let t=e.id,i=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return Dd.box(Dd.types.trex,i)}static moof(e,t){return Dd.box(Dd.types.moof,Dd.mfhd(e.sequenceNumber),Dd.traf(e,t))}static mfhd(e){let t=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e]);return Dd.box(Dd.types.mfhd,t)}static traf(e,t){let i=e.id,r=Dd.box(Dd.types.tfhd,new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i])),s=Dd.box(Dd.types.tfdt,new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t])),a=Dd.sdtp(e),n=Dd.trun(e,a.byteLength+16+16+8+16+8+8);return Dd.box(Dd.types.traf,r,s,n,a)}static sdtp(e){let t=new Uint8Array(5),i=e.flags;return t[4]=i.isLeading<<6|i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy,Dd.box(Dd.types.sdtp,t)}static trun(e,t){let i=new Uint8Array(28);t+=36,i.set([0,0,15,1,0,0,0,1,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0);let r=e.duration,s=e.size,a=e.flags,n=e.cts;return i.set([r>>>24&255,r>>>16&255,r>>>8&255,255&r,s>>>24&255,s>>>16&255,s>>>8&255,255&s,a.isLeading<<2|a.dependsOn,a.isDependedOn<<6|a.hasRedundancy<<4|a.isNonSync,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n],12),Dd.box(Dd.types.trun,i)}static mdat(e){return Dd.box(Dd.types.mdat,e)}}Dd.init();class Rd extends t{constructor(e){super(),this.TAG_NAME="MediaSource",this.player=e,this._resetInIt(),this._useManagedMediaSource="ManagedMediaSource"in self&&!("MediaSource"in self),this.mediaSource=this._useManagedMediaSource?new self.ManagedMediaSource:new self.MediaSource,this.isDecodeFirstIIframe=!!ka(e._opt.checkFirstIFrame),this.mediaSourceObjectURL=null,this._useManagedMediaSource||(this.mediaSourceObjectURL=window.URL.createObjectURL(this.mediaSource)),this.isSupportVideoFrameCallback=Pa(),this.canvasRenderInterval=null,e._opt.mseUseCanvasRender?(this.$videoElement=document.createElement("video"),this._useManagedMediaSource?(this.$videoElement.disableRemotePlayback=!0,this.$videoElement.srcObject=this.mediaSource):this.$videoElement.src=this.mediaSourceObjectURL,this.initVideoEvents()):(this._useManagedMediaSource?(this.player.video.$videoElement.disableRemotePlayback=!0,this.player.video.$videoElement.srcObject=this.mediaSource):this.player.video.$videoElement.src=this.mediaSourceObjectURL,this.$videoElement=this.player.video.$videoElement),this._bindMediaSourceEvents(),this.audioSourceBufferCheckTimeout=null,this.audioSourceNoDataCheckTimeout=null,this.player.isPlayback()&&this.player.on(st.playbackPause,(t=>{ka(t)?(Ta(e._opt.checkFirstIFrame)&&(this.player.debug.log(this.TAG_NAME,"playbackPause is false and _opt.checkFirstIFrame is true so set isDecodeFirstIIframe = false"),this.isDecodeFirstIIframe=!1),this.clearUpAllSourceBuffer(),this.$videoElement.play()):(this.$videoElement.pause(),this.cacheTrack={})})),this.player.on(st.visibilityChange,(e=>{e&&setTimeout((()=>{if(this.player.isPlaying()&&this.$videoElement){const e=this.getVideoBufferLastTime();e>this.$videoElement.currentTime&&(this.player.debug.log(this.TAG_NAME,`visibilityChange is true and lastTime is ${e} and currentTime is ${this.$videoElement.currentTime} so set currentTime to lastTime`),this.$videoElement.currentTime=e)}}),300)})),this._useManagedMediaSource?this.player.debug.log(this.TAG_NAME,"init and using ManagedMediaSource"):this.player.debug.log(this.TAG_NAME,"init")}destroy(){this.stop(),this._clearAudioSourceBufferCheckTimeout(),this._clearAudioNoDataCheckTimeout(),this._stopCanvasRender(),this.eventListenList.length&&(this.eventListenList.forEach((e=>e())),this.eventListenList=[]),this.supportVideoFrameCallbackHandle&&this.$videoElement&&(this.$videoElement.cancelVideoFrameCallback(this.supportVideoFrameCallbackHandle),this.supportVideoFrameCallbackHandle=null),this.$videoElement&&(this.player._opt.mseUseCanvasRender&&this.$videoElement.src&&(this.$videoElement.src="",this.$videoElement.removeAttribute("src")),this.$videoElement=null),this.mediaSourceObjectURL&&(window.URL.revokeObjectURL(this.mediaSourceObjectURL),this.mediaSourceObjectURL=null),this._resetInIt(),this.off(),this.player.debug.log(this.TAG_NAME,"destroy")}needInitAudio(){return this.player._opt.hasAudio&&this.player._opt.mseDecodeAudio}_resetInIt(){this.isAvc=null,this.isAAC=null,this.videoMeta={},this.audioMeta={},this.sourceBuffer=null,this.audioSourceBuffer=null,this.hasInit=!1,this.hasAudioInit=!1,this.isInitInfo=!1,this.isAudioInitInfo=!1,this.audioMimeType="",this.videoMimeType="",this.cacheTrack={},this.cacheAudioTrack={},this.timeInit=!1,this.sequenceNumber=0,this.audioSequenceNumber=0,this.firstRenderTime=null,this.firstAudioTime=null,this.$videoElement=null,this.mediaSourceAppendBufferFull=!1,this.mediaSourceAppendBufferError=!1,this.mediaSourceAddSourceBufferError=!1,this.mediaSourceBufferError=!1,this.mediaSourceError=!1,this.prevTimestamp=null,this.decodeDiffTimestamp=null,this.prevDts=null,this.prevAudioDts=null,this.prevPayloadBufferSize=0,this.isWidthOrHeightChanged=!1,this.prevTs=null,this.prevAudioTs=null,this.eventListenList=[],this.pendingRemoveRanges=[],this.pendingSegments=[],this.pendingAudioRemoveRanges=[],this.pendingAudioSegments=[],this.supportVideoFrameCallbackHandle=null}get state(){return this.mediaSource&&this.mediaSource.readyState}get isStateOpen(){return this.state===Qt}get isStateClosed(){return this.state===Xt}get isStateEnded(){return this.state===Yt}get duration(){return this.mediaSource&&this.mediaSource.duration||-1}set duration(e){this.mediaSource.duration=e}_bindMediaSourceEvents(){const{debug:e,events:{proxy:t}}=this.player,i=t(this.mediaSource,wi.sourceOpen,(()=>{this.player.debug.log(this.TAG_NAME,"sourceOpen"),this._onMediaSourceSourceOpen(),this.player.emit(st.mseSourceOpen)})),r=t(this.mediaSource,wi.sourceClose,(()=>{this.player.debug.log(this.TAG_NAME,"sourceClose"),this.player.emit(st.mseSourceClose)})),s=t(this.mediaSource,wi.sourceended,(()=>{this.player.debug.log(this.TAG_NAME,"sourceended"),this.player.emit(st.mseSourceended)}));this.eventListenList.push(i,r,s);const a=t(this.$videoElement,Ti,(e=>{if(ka(this.isSupportVideoFrameCallback))if(this.player.checkIsInRender())this.player.handleRender();else{const t=parseInt(e.timeStamp,10);this.player.debug.log(this.TAG_NAME,`mseUseCanvasRender is ${this.player._opt.mseUseCanvasRender} and\n $videoElement ts is ${t}, but not in render and vbps is ${this.player._stats.vbps} and fps is ${this.player._stats.fps}`)}})),n=t(this.$videoElement,ki,(()=>{this.player.debug.log(this.TAG_NAME,"video playback Rate change",this.$videoElement&&this.$videoElement.playbackRate),this.$videoElement&&this.$videoElement.paused&&(this.player.debug.warn(this.TAG_NAME,"video is paused and sent isMSEPlaybackRateChangePause true"),this.player.isMSEPlaybackRateChangePause=!0)}));if(this.eventListenList.push(a,n),this._useManagedMediaSource){const e=t(this.mediaSource,wi.startstreaming,(()=>{this.player.debug.log(this.TAG_NAME,"ManagedMediaSource startstreaming"),this.player.emit(st.mseSourceStartStreaming)})),i=t(this.mediaSource,wi.endstreaming,(()=>{this.player.debug.log(this.TAG_NAME,"ManagedMediaSource endstreaming"),this.player.emit(st.mseSourceEndStreaming)})),r=t(this.mediaSource,wi.qualitychange,(()=>{this.player.debug.log(this.TAG_NAME,"ManagedMediaSource qualitychange")}));this.eventListenList.push(e,i,r)}}_onMediaSourceSourceOpen(){this.sourceBuffer||(this.player.debug.log("MediaSource","onMediaSourceSourceOpen() sourceBuffer is null and next init"),this._initSourceBuffer()),this.audioSourceBuffer||(this.player.debug.log("MediaSource","onMediaSourceSourceOpen() audioSourceBuffer is null and next init"),this._initAudioSourceBuffer()),this._hasPendingSegments()&&this._doAppendSegments()}initVideoEvents(){const{proxy:e}=this.player.events,t=e(this.$videoElement,Ei,(()=>{this.player.debug.log(this.TAG_NAME,"video canplay"),this.$videoElement.play().then((()=>{this.player.emit(st.removeLoadingBgImage),Pa()?this.supportVideoFrameCallbackHandle=this.$videoElement.requestVideoFrameCallback(this.videoFrameCallback.bind(this)):this.player.isUseHls265()&&(this._stopCanvasRender(),this.canvasRenderInterval=setInterval((()=>{this.player.video.render({$video:this.$videoElement,ts:parseInt(1e3*this.$videoElement.currentTime,10)||0})}),40)),this.player.debug.log(this.TAG_NAME,"video play")})).catch((e=>{this.player.debug.error(this.TAG_NAME,"video play error ",e),this.player.emitError(lt.mediaSourceUseCanvasRenderPlayFailed,e)}))})),i=e(this.$videoElement,Si,(()=>{this.player.debug.log(this.TAG_NAME,"video waiting")})),r=e(this.$videoElement,Ti,(e=>{parseInt(e.timeStamp,10),this.$videoElement.paused&&(this.player.debug.warn(this.TAG_NAME,"video is paused and next try to replay"),this.$videoElement.play().then((()=>{this.player.debug.log(this.TAG_NAME,"video is paused and replay success")})).catch((e=>{this.player.debug.warn(this.TAG_NAME,"video is paused and replay error ",e)})))}));this.eventListenList.push(t,i,r)}videoFrameCallback(e,t={}){if(this.player.isDestroyedOrClosed())return void this.player.debug.log(this.TAG_NAME,"videoFrameCallback() player is destroyed");const i=parseInt(1e3*Math.max(t.mediaTime,this.$videoElement.currentTime),10)||0;this.player.handleRender(),this.player.video.render({$video:this.$videoElement,ts:i}),this.player.isUseHls265()&&this.player.updateStats({fps:!0,ts:i}),this.supportVideoFrameCallbackHandle=this.$videoElement.requestVideoFrameCallback(this.videoFrameCallback.bind(this))}decodeVideo(e,t,i,r){const s=this.player;if(s)if(this.player.isDestroyedOrClosed())this.player.debug.warn(this.TAG_NAME,"decodeVideo() player is destroyed");else if(this.hasInit)if(!this.isDecodeFirstIIframe&&i&&(this.isDecodeFirstIIframe=!0),this.isDecodeFirstIIframe){if(i&&0===e[1]){const t=15&e[0];let i={};if(t===gt){i=On(e.slice(5))}else t===At&&(i=Xn(e));const r=this.player.video.videoInfo;r&&r.width&&r.height&&i&&i.codecWidth&&i.codecHeight&&(i.codecWidth!==r.width||i.codecHeight!==r.height)&&(this.player.debug.warn(this.TAG_NAME,`\n decodeVideo: video width or height is changed,\n old width is ${r.width}, old height is ${r.height},\n new width is ${i.codecWidth}, new height is ${i.codecHeight},\n and emit change event`),this.isWidthOrHeightChanged=!0,this.player.emitError(lt.mseWidthOrHeightChange))}if(this.isWidthOrHeightChanged)return void this.player.debug.warn(this.TAG_NAME,"decodeVideo: video width or height is changed, and return");if(Sa(e))return void this.player.debug.warn(this.TAG_NAME,"decodeVideo and payload is video sequence header so drop this frame");if(e.byteLength<12)return void this.player.debug.warn(this.TAG_NAME,`decodeVideo and payload is too small , payload length is ${e.byteLength}`);let s=t;if(this.player.isPlayer()){if(null===this.firstRenderTime&&(this.firstRenderTime=t),s=t-this.firstRenderTime,s<0&&(this.player.debug.warn(this.TAG_NAME,`decodeVideo\n local dts is < 0 , ts is ${t} and prevTs is ${this.prevTs},\n firstRenderTime is ${this.firstRenderTime} and mseCorrectTimeDuration is ${this.player._opt.mseCorrectTimeDuration}`),s=null===this.prevDts?0:this.prevDts+this.player._opt.mseCorrectTimeDuration,this._checkTsIsMaxDiff(t)))return this.player.debug.warn(this.TAG_NAME,`decodeVideo is max diff , ts is ${t} and prevTs is ${this.prevTs}, diff is ${this.prevTs-t} and emit replay`),void this.player.emitError(lt.mediaSourceTsIsMaxDiff,`decodeVideo is max diff, prevTs is ${this.prevTs} and ts is ${t}`);if(null!==this.prevDts&&s<=this.prevDts){if(this.player.debug.warn(this.TAG_NAME,`\n decodeVideo dts is less than(or equal) prev dts ,\n dts is ${s} and prev dts is ${this.prevDts} \n and now ts is ${t} and prev ts is ${this.prevTs} \n and diff is ${t-this.prevTs} and firstRenderTime is ${this.firstRenderTime} and isIframe is ${i}\n and mseCorrectTimeDuration is ${this.player._opt.mseCorrectTimeDuration},\n and prevPayloadBufferSize is ${this.prevPayloadBufferSize} and payload size is ${e.byteLength}`),s===this.prevDts&&this.prevPayloadBufferSize===e.byteLength)return void this.player.debug.warn(this.TAG_NAME,"decodeVideo dts is equal to prev dts and payload size is equal to prev payload size so drop this frame");if(s=this.prevDts+this.player._opt.mseCorrectTimeDuration,this._checkTsIsMaxDiff(t))return this.player.debug.warn(this.TAG_NAME,`decodeVideo is max diff , ts is ${t} and prevTs is ${this.prevTs}, diff is ${this.prevTs-t} and emit replay`),void this.emit(lt.mediaSourceTsIsMaxDiff,`decodeVideo is max diff, prevTs is ${this.prevTs} and ts is ${t}`)}}this.player.isPlayer()?this._decodeVideo(e,s,i,r,t):this.player.isPlayback()&&ka(this.player.playbackPause)&&(this.player.playback.isUseLocalCalculateTime&&this.player.playback.increaseLocalTimestamp(),this._decodeVideo(e,s,i,r,t)),this.prevDts=s,this.prevPayloadBufferSize=e.byteLength,this.prevTs=t}else this.player.debug.log(this.TAG_NAME,"decodeVideo first frame is not iFrame");else if(i&&e[1]===Ni){const r=15&e[0];if(s.video.updateVideoInfo({encTypeCode:r}),r===At&&ka(Gs()))return void this.player.emitError(lt.mediaSourceH265NotSupport);s._times.decodeStart||(s._times.decodeStart=vs()),this.hasInit=this._decodeConfigurationRecord(e,t,i,r)}else this.player.debug.warn(this.TAG_NAME,`decodeVideo has not init , isIframe is ${i} , payload is ${e[1]}`)}decodeAudio(e,t){if(this.player)if(this.player.isDestroyedOrClosed())this.player.debug.warn(this.TAG_NAME,"decodeAudio() player is destroyed");else if(ka(this.hasAudioInit))this.hasAudioInit=this._decodeAudioConfigurationRecord(e,t);else{let i=t;if(is(e))return void this.player.debug.log(this.TAG_NAME,"decodeAudio and has already initialized and payload is aac codec packet so drop this frame");if(this._clearAudioNoDataCheckTimeout(),this.player.isPlayer()){if(null===this.firstAudioTime&&(this.firstAudioTime=t,null!==this.firstRenderTime&&null!==this.prevTs)){const e=Math.abs(this.firstRenderTime-this.prevTs);e>300&&(this.firstAudioTime-=e,this.player.debug.warn(this.TAG_NAME,`video\n firstAudioTime is ${this.firstRenderTime} and current time is ${this.prevTs}\n play time is ${e} and firstAudioTime ${t} - ${e} = ${this.firstAudioTime}`))}if(i=t-this.firstAudioTime,i<0&&(this.player.debug.warn(this.TAG_NAME,`decodeAudio\n local dts is < 0 , ts is ${t} and prevTs is ${this.prevAudioTs},\n firstAudioTime is ${this.firstAudioTime}`),i=null===this.prevAudioDts?0:this.prevAudioDts+this.player._opt.mseCorrectAudioTimeDuration,this._checkAudioTsIsMaxDiff(t)))return this.player.debug.warn(this.TAG_NAME,`decodeAudio is max diff , ts is ${t} and prevTs is ${this.prevAudioDts}, diff is ${this.prevAudioDts-t} and emit replay`),void this.player.emitError(lt.mediaSourceTsIsMaxDiff,`decodeAudio is max diff, prevTs is ${this.prevAudioDts} and ts is ${t}`);null!==this.prevAudioTs&&i<=this.prevAudioDts&&(this.player.debug.warn(this.TAG_NAME,`\n decodeAudio dts is less than(or equal) prev dts ,\n dts is ${i} and prev dts is ${this.prevAudioDts} \n and now ts is ${t} and prev ts is ${this.prevAudioTs} \n and diff is ${t-this.prevAudioTs}`),i=this.prevAudioDts+this.player._opt.mseCorrectAudioTimeDuration)}(this.player.isPlayer()||this.player.isPlayback()&&ka(this.player.playbackPause))&&this._decodeAudio(e,i,t),this.prevAudioTs=t,this.prevAudioDts=i}}_checkTsIsMaxDiff(e){return this.prevTs>0&&e<this.prevTs&&this.prevTs-e>ee}_checkAudioTsIsMaxDiff(e){return this.prevAudioTs>0&&e<this.prevAudioTs&&this.prevAudioTs-e>ee}_decodeConfigurationRecord(e,t,i,r){let s=e.slice(5),a={};if(r===gt?a=On(s):r===At&&(a=function(e){const t=e;if(t.length<22)return console.error(`Invalid HEVCDecoderConfigurationRecord, lack of data! ${t.length} < 22`),{};let i={codecWidth:0,codecHeight:0,videoType:Ci},r=function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}(),s=new DataView(t.buffer),a=s.getUint8(0),n=31&s.getUint8(1);if(1!==a||0===n)return console.error(`Invalid HEVCDecoderConfigurationRecord,version is ${a}, hevcProfile is ${n}`),{};let o=1+(3&s.getUint8(21));if(3!==o&&4!==o)return console.error("Invalid HEVCDecoderConfigurationRecord, Strange NaluLengthSizeMinusOne: "+(o-1)),{};let l=s.getUint8(22);for(let e=0,a=23;e<l;e++){let e=63&s.getUint8(a+0),n=s.getUint16(a+1,!r);a+=3;for(let o=0;o<n;o++){let n=s.getUint16(a+0,!r);if(0===o)if(33===e){a+=2;let e=new Uint8Array(t.buffer,a,n),r=Qn.parseSPS(e);i.codecWidth=r.codec_size.width,i.codecHeight=r.codec_size.height,i.presentWidth=r.present_size.width,i.presentHeight=r.present_size.height,i.profile=r.profile_string,i.level=r.level_string,i.bitDepth=r.bit_depth,i.chromaFormat=r.chroma_format,i.sarRatio=r.sar_ratio,i.frameRate=r.frame_rate,!1!==r.frame_rate.fixed&&0!==r.frame_rate.fps_num&&0!==r.frame_rate.fps_den||(i.frameRate={fixed:!0,fps:23.976,fps_num:23976,fps_den:1e3}),i.frameRate.fps_den,i.frameRate.fps_num,i.codec=r.codec_mimetype,a+=n}else a+=2+n;else a+=2+n}}return i.hvcc=new Uint8Array(t),i}(s)),ra(a)||0===a.codecWidth&&0===a.codecHeight)return this.player.debug.warn(this.TAG_NAME,"_decodeConfigurationRecord",a),this.player.emitError(lt.mediaSourceDecoderConfigurationError),!1;this.player.recorder&&this.player._opt.recordType===_&&this.player.recorder.initMetaData(e,r);const n={id:Br,type:"video",timescale:1e3,duration:0,avcc:s,codecWidth:a.codecWidth,codecHeight:a.codecHeight,videoType:a.videoType},o=Dd.generateInitSegment(n);this.isAvc=r===gt;let l=a.codec;return this.videoMimeType=l?`video/mp4; codecs="${a.codec}"`:this.isAvc?Kt:qt,this._initSourceBuffer(),this.appendBuffer(o.buffer),this.sequenceNumber=0,this.cacheTrack={},this.timeInit=!1,!0}_decodeAudioConfigurationRecord(e,t){const i=e[0]>>4,r=i===_t.MP3,s=i===_t.AAC;if(ka(s||r))return this.player.debug.warn(this.TAG_NAME,`_decodeAudioConfigurationRecord audio codec is not support , codecId is ${i} ant auto wasm decode`),this.player.emit(lt.mediaSourceAudioG711NotSupport),!1;const a={id:Mr,type:"audio",timescale:1e3};let n={};if(is(e)){if(n=ds(e.slice(2)),!n)return!1;a.audioSampleRate=n.sampleRate,a.channelCount=n.channelCount,a.config=n.config,a.refSampleDuration=1024/a.audioSampleRate*a.timescale}else{if(!r)return!1;if(n=dd(e),!n)return!1;a.audioSampleRate=n.samplingRate,a.channelCount=n.channelCount,a.refSampleDuration=1152/a.audioSampleRate*a.timescale}a.codec=n.codec,a.duration=0;let o="mp4",l=n.codec,d=null;r&&ka(Rs())?(o="mpeg",l="",d=new Uint8Array):d=Dd.generateInitSegment(a);let h=`${a.type}/${o}`;return l&&l.length>0&&(h+=`;codecs=${l}`),ka(this.isAudioInitInfo)&&(this.player.audio.updateAudioInfo({encTypeCode:i,channels:a.channelCount,sampleRate:a.audioSampleRate}),this.isAudioInitInfo=!0),this.audioMimeType=h,this.isAAC=s,this._initAudioSourceBuffer(),this.appendAudioBuffer(d.buffer),!0}_initSourceBuffer(){const{debug:e,events:{proxy:t}}=this.player;if(null===this.sourceBuffer&&null!==this.mediaSource&&this.isStateOpen&&this.videoMimeType){try{this.sourceBuffer=this.mediaSource.addSourceBuffer(this.videoMimeType),e.log(this.TAG_NAME,"_initSourceBuffer() this.mediaSource.addSourceBuffer()",this.videoMimeType)}catch(t){return e.error(this.TAG_NAME,"appendBuffer() this.mediaSource.addSourceBuffer()",t.code,t),this.player.emitError(lt.mseAddSourceBufferError,t),void(this.mediaSourceAddSourceBufferError=!0)}if(this.sourceBuffer){const i=t(this.sourceBuffer,"error",(t=>{this.mediaSourceBufferError=!0,e.error(this.TAG_NAME,"mseSourceBufferError this.sourceBuffer",t),this.player.emitError(lt.mseSourceBufferError,t)})),r=t(this.sourceBuffer,"updateend",(()=>{this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()&&this._doAppendSegments()}));this.eventListenList.push(i,r)}}else e.log(this.TAG_NAME,`_initSourceBuffer and this.isStateOpen is ${this.isStateOpen} and this.isAvc === null is ${null===this.isAvc}`)}_initAudioSourceBuffer(){const{debug:e,events:{proxy:t}}=this.player;if(null===this.audioSourceBuffer&&null!==this.mediaSource&&this.isStateOpen&&this.audioMimeType){try{this.audioSourceBuffer=this.mediaSource.addSourceBuffer(this.audioMimeType),this._clearAudioSourceBufferCheckTimeout(),e.log(this.TAG_NAME,"_initAudioSourceBuffer() this.mediaSource.addSourceBuffer()",this.audioMimeType)}catch(t){return e.error(this.TAG_NAME,"appendAudioBuffer() this.mediaSource.addSourceBuffer()",t.code,t),this.player.emitError(lt.mseAddSourceBufferError,t),void(this.mediaSourceAddSourceBufferError=!0)}if(this.audioSourceBuffer){const i=t(this.audioSourceBuffer,"error",(t=>{this.mediaSourceBufferError=!0,e.error(this.TAG_NAME,"mseSourceBufferError this.audioSourceBuffer",t),this.player.emitError(lt.mseSourceBufferError,t)})),r=t(this.audioSourceBuffer,"updateend",(()=>{this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()&&this._doAppendSegments()}));this.eventListenList.push(i,r),null===this.audioSourceNoDataCheckTimeout&&(this.audioSourceNoDataCheckTimeout=setTimeout((()=>{this._clearAudioNoDataCheckTimeout(),this.player.emit(lt.mediaSourceAudioNoDataTimeout)}),1e3))}}else e.log(this.TAG_NAME,`_initAudioSourceBuffer and this.isStateOpen is ${this.isStateOpen} and this.audioMimeType is ${this.audioMimeType}`)}_decodeVideo(e,t,i,r,s){const a=this.player;let n=e.slice(5),o=n.byteLength;if(0===o)return void a.debug.warn(this.TAG_NAME,"_decodeVideo payload bytes is 0 and return");let l=(new Date).getTime(),d=!1;this.prevTimestamp||(this.prevTimestamp=l,d=!0);const h=l-this.prevTimestamp;this.decodeDiffTimestamp=h,h>500&&!d&&this.player.isPlayer()&&a.debug.warn(this.TAG_NAME,`_decodeVideo now time is ${l} and prev time is ${this.prevTimestamp}, diff time is ${h} ms`);const c=this.$videoElement;if(this.cacheTrack.id&&t>=this.cacheTrack.dts){let e=8+this.cacheTrack.size,i=new Uint8Array(e);i[0]=e>>>24&255,i[1]=e>>>16&255,i[2]=e>>>8&255,i[3]=255&e,i.set(Dd.types.mdat,4),i.set(this.cacheTrack.data,8),this.cacheTrack.duration=t-this.cacheTrack.dts;let r=Dd.moof(this.cacheTrack,this.cacheTrack.dts);this.cacheTrack={};let n=new Uint8Array(r.byteLength+i.byteLength);n.set(r,0),n.set(i,r.byteLength),this.appendBuffer(n.buffer),a.emit(st.timeUpdate,s),a.isPlayer()?a.isUseHls265()?a.updateStats({dfps:!0,mseTs:t}):a.updateStats({fps:!0,dfps:!0,ts:s,mseTs:t}):a.isPlayback()&&a.playback.updateStats({ts:s}),a._times.videoStart||(a._times.videoStart=vs(),a.handlePlayToRenderTimes())}else a.debug.log(this.TAG_NAME,`timeInit set false , cacheTrack = {} now dts is ${t}, and ts is ${s} cacheTrack dts is ${this.cacheTrack&&this.cacheTrack.dts}`),this.timeInit=!1,this.cacheTrack={};this.cacheTrack||(this.cacheTrack={}),this.cacheTrack.id=Br,this.cacheTrack.sequenceNumber=++this.sequenceNumber,this.cacheTrack.size=o,this.cacheTrack.dts=t,this.cacheTrack.cts=r,this.cacheTrack.isKeyframe=i,this.cacheTrack.data=n,this.cacheTrack.flags={isLeading:0,dependsOn:i?2:1,isDependedOn:i?1:0,hasRedundancy:0,isNonSync:i?0:1},!this.isInitInfo&&c.videoWidth>0&&c.videoHeight>0&&(a.debug.log(this.TAG_NAME,`updateVideoInfo: ${c.videoWidth},${c.videoHeight}`),a.video.updateVideoInfo({width:c.videoWidth,height:c.videoHeight}),a.video.initCanvasViewSize(),this.isInitInfo=!0),a._opt.mseUseCanvasRender&&ka(this.isSupportVideoFrameCallback)&&ka(a.isUseHls265())&&a.video.render({$video:c,ts:t}),this.prevTimestamp=(new Date).getTime()}_stopCanvasRender(){this.canvasRenderInterval&&(clearInterval(this.canvasRenderInterval),this.canvasRenderInterval=null)}_decodeAudio(e,t,i){this.player;let r=this.isAAC?e.slice(2):e.slice(1),s=r.byteLength;if(this.cacheAudioTrack.id&&t>=this.cacheAudioTrack.dts){let e=8+this.cacheAudioTrack.size,i=new Uint8Array(e);i[0]=e>>>24&255,i[1]=e>>>16&255,i[2]=e>>>8&255,i[3]=255&e,i.set(Dd.types.mdat,4),i.set(this.cacheAudioTrack.data,8),this.cacheAudioTrack.duration=t-this.cacheAudioTrack.dts;let r=Dd.moof(this.cacheAudioTrack,this.cacheAudioTrack.dts);this.cacheAudioTrack={};let s=new Uint8Array(r.byteLength+i.byteLength);s.set(r,0),s.set(i,r.byteLength),this.appendAudioBuffer(s.buffer)}else this.cacheAudioTrack={};this.cacheAudioTrack||(this.cacheAudioTrack={}),this.cacheAudioTrack.id=Mr,this.cacheAudioTrack.sequenceNumber=++this.audioSequenceNumber,this.cacheAudioTrack.size=s,this.cacheAudioTrack.dts=t,this.cacheAudioTrack.cts=0,this.cacheAudioTrack.data=r,this.cacheAudioTrack.flags={isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}appendBuffer(e){if(this.player.isDestroyedOrClosed())return void this.player.debug.warn(this.TAG_NAME,"appendBuffer() player is destroyed");const{debug:t,events:{proxy:i}}=this.player;this.mediaSourceAddSourceBufferError?t.warn(this.TAG_NAME,"appendBuffer() this.mediaSourceAddSourceBufferError is true"):this.mediaSourceAppendBufferFull?t.warn(this.TAG_NAME,"appendBuffer() this.mediaSourceAppendBufferFull is true"):this.mediaSourceAppendBufferError?t.warn(this.TAG_NAME,"appendBuffer() this.mediaSourceAppendBufferError is true"):this.mediaSourceBufferError?t.warn(this.TAG_NAME,"appendBuffer() this.mediaSourceBufferError is true"):(this.pendingSegments.push(e),this.sourceBuffer&&(this.player.isPlayer()&&this._handleUpdatePlaybackRate(),this.player.isPlayback()&&this._handleUpdateBufferDelayTime(),this.player._opt.mseAutoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanUpSourceBuffer(),ka(this.getSourceBufferUpdating())&&this.isStateOpen&&ka(this._hasPendingRemoveRanges()))?this._doAppendSegments():this.isStateClosed?(this.mediaSourceBufferError=!0,this.player.emitError(lt.mseSourceBufferError,"mediaSource is not attached to video or mediaSource is closed")):this.isStateEnded?(this.mediaSourceBufferError=!0,this.player.emitError(lt.mseSourceBufferError,"mediaSource is end")):this._hasPendingRemoveRanges()&&t.log(this.TAG_NAME,`video has pending remove ranges and video length is ${this.pendingRemoveRanges.length}, audio length is ${this.pendingAudioRemoveRanges.length}`))}appendAudioBuffer(e){if(this.player.isDestroyedOrClosed())return void this.player.debug.warn(this.TAG_NAME,"appendAudioBuffer() player is destroyed");const{debug:t,events:{proxy:i}}=this.player;this.mediaSourceAddSourceBufferError?t.warn(this.TAG_NAME,"appendAudioBuffer() this.mediaSourceAddSourceBufferError is true"):this.mediaSourceAppendBufferFull?t.warn(this.TAG_NAME,"appendAudioBuffer() this.mediaSourceAppendBufferFull is true"):this.mediaSourceAppendBufferError?t.warn(this.TAG_NAME,"appendAudioBuffer() this.mediaSourceAppendBufferError is true"):this.mediaSourceBufferError?t.warn(this.TAG_NAME,"appendAudioBuffer() this.mediaSourceBufferError is true"):(this.pendingAudioSegments.push(e),this.audioSourceBuffer&&(this.player.isPlayer()&&this._handleUpdatePlaybackRate(),this.player.isPlayback()&&this._handleUpdateBufferDelayTime(),this.player._opt.mseAutoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanUpSourceBuffer(),ka(this.getAudioSourceBufferUpdating())&&this.isStateOpen&&ka(this._hasPendingRemoveRanges()))?this._doAppendSegments():this.isStateClosed?(this.mediaSourceBufferError=!0,this.player.emitError(lt.mseSourceBufferError,"mediaSource is not attached to video or mediaSource is closed")):this.isStateEnded?(this.mediaSourceBufferError=!0,this.player.emitError(lt.mseSourceBufferError,"mediaSource is end")):this._hasPendingRemoveRanges()&&t.log(this.TAG_NAME,`audio has pending remove ranges and video length is ${this.pendingRemoveRanges.length}, audio length is ${this.pendingAudioRemoveRanges.length}`))}getSourceBufferUpdating(){return this.sourceBuffer&&this.sourceBuffer.updating}getAudioSourceBufferUpdating(){return this.audioSourceBuffer&&this.audioSourceBuffer.updating}stop(){this.removeSourceBuffer(),this.endOfStream(),this.abortSourceBuffer()}checkSourceBufferDelay(){const e=this.$videoElement;let t=0,i=0;return e.buffered.length>0&&(i=e.buffered.end(e.buffered.length-1),t=i-e.currentTime),t<0&&(this.player.debug.warn(this.TAG_NAME,`checkMSESourceBufferDelay ${t} < 0, and buffered is ${i} ,currentTime is ${e.currentTime} , try to seek ${e.currentTime} to ${i}`),e.currentTime=i,t=0),t}checkSourceBufferStore(){const e=this.$videoElement;let t=0;return e.buffered.length>0&&(t=e.currentTime-e.buffered.start(0)),t}getDecodeDiffTimes(){return this.decodeDiffTimestamp}removeBuffer(e,t){const i=da();if(this.player.debug.log(this.TAG_NAME,`removeBuffer() start is ${e} and end is ${t} and _isMacOsFirefox is ${i}`),this.isStateOpen&&ka(i)){if(ka(this.getSourceBufferUpdating()))try{this.sourceBuffer.remove(e,t)}catch(e){this.player.debug.warn(this.TAG_NAME,"removeBuffer() sourceBuffer error",e)}if(ka(this.getAudioSourceBufferUpdating()))try{this.audioSourceBuffer.remove(e,t)}catch(e){this.player.debug.warn(this.TAG_NAME,"removeBuffer() audioSourceBuffer error",e)}}}clearUpAllSourceBuffer(){if(this.sourceBuffer){const e=this.sourceBuffer.buffered;for(let t=0;t<e.length;t++){let i=e.start(t),r=e.end(t);this.pendingRemoveRanges.push({start:i,end:r})}ka(this.getSourceBufferUpdating())&&this._doRemoveRanges()}if(this.audioSourceBuffer){const e=this.audioSourceBuffer.buffered;for(let t=0;t<e.length;t++){let i=e.start(t),r=e.end(t);this.pendingAudioRemoveRanges.push({start:i,end:r})}ka(this.getAudioSourceBufferUpdating())&&this._doRemoveRanges()}}endOfStream(){if(this.isStateOpen&&this.$videoElement&&this.$videoElement.readyState>=1)try{this.player.debug.log(this.TAG_NAME,"endOfStream()"),this.mediaSource.endOfStream()}catch(e){this.player.debug.warn(this.TAG_NAME,"endOfStream() error",e)}}abortSourceBuffer(){if(this.isStateOpen){if(this.sourceBuffer)try{this.player.debug.log(this.TAG_NAME,"abortSourceBuffer() abort sourceBuffer"),this.sourceBuffer.abort()}catch(e){}if(this.audioSourceBuffer)try{this.player.debug.log(this.TAG_NAME,"abortSourceBuffer() abort audioSourceBuffer"),this.audioSourceBuffer.abort()}catch(e){}}this.sourceBuffer=null,this.audioSourceBuffer=null}removeSourceBuffer(){if(!this.isStateClosed&&this.mediaSource){if(this.sourceBuffer)try{this.player.debug.log(this.TAG_NAME,"removeSourceBuffer() sourceBuffer"),this.mediaSource.removeSourceBuffer(this.sourceBuffer)}catch(e){this.player.debug.warn(this.TAG_NAME,"removeSourceBuffer() sourceBuffer error",e)}if(this.audioSourceBuffer)try{this.player.debug.log(this.TAG_NAME,"removeSourceBuffer() audioSourceBuffer"),this.mediaSource.removeSourceBuffer(this.audioSourceBuffer)}catch(e){this.player.debug.warn(this.TAG_NAME,"removeSourceBuffer() audioSourceBuffer error",e)}}}_hasPendingSegments(){return this.pendingSegments.length>0||this.pendingAudioSegments.length>0}getPendingSegmentsLength(){return this.pendingSegments.length}_handleUpdatePlaybackRate(){if(!this.$videoElement)return;const e=this.$videoElement;let t=(this.player._opt.videoBuffer+this.player._opt.videoBufferDelay)/1e3;const i=e.buffered;i.length&&i.start(0);const r=i.length?i.end(i.length-1):0;let s=e.currentTime;const a=r-s,n=Math.max(5,t+3);if(this.player.updateStats({mseVideoBufferDelayTime:a}),a>n)this.player.debug.log(this.TAG_NAME,`handleUpdatePlaybackRate and buffered is ${r} and current is ${s} , delay buffer is more than ${n} is ${a} and new time is ${r}`),e.currentTime=r,s=e.currentTime;else if(a<0){if(this.player.debug.warn(this.TAG_NAME,`handleUpdatePlaybackRate and delay buffer is ${r} - current is ${s} = ${a} < 0 and check video is paused : ${e.paused} `),0===r)return void this.player.emit(lt.mediaSourceBufferedIsZeroError,"video.buffered is empty");e.paused&&e.play()}const o=this._getPlaybackRate(r-s);e.playbackRate!==o&&(this.player.debug.log(this.TAG_NAME,`handleUpdatePlaybackRate and buffered is ${r} and current time is ${s} and delay is ${r-s} set playbackRate is ${o} `),e.playbackRate=o)}_handleUpdateBufferDelayTime(){const e=this.getVideoBufferDelayTime();this.player.updateStats({mseVideoBufferDelayTime:e})}_doAppendSegments(){if(this.isStateClosed||this.isStateEnded)this.player.debug.log(this.TAG_NAME,"_doAppendSegments() mediaSource is closed or ended and return");else if(null!==this.sourceBuffer){if(this.needInitAudio()&&null===this.audioSourceBuffer)return this.player.debug.log(this.TAG_NAME,"_doAppendSegments() audioSourceBuffer is null and need init audio source buffer"),void(null===this.audioSourceBufferCheckTimeout&&(this.audioSourceBufferCheckTimeout=setTimeout((()=>{this._clearAudioSourceBufferCheckTimeout(),this.player.emit(lt.mediaSourceAudioInitTimeout)}),1e3)));if(ka(this.getSourceBufferUpdating())&&this.pendingSegments.length>0){const e=this.pendingSegments.shift();try{this.sourceBuffer.appendBuffer(e)}catch(e){this.player.debug.error(this.TAG_NAME,"this.sourceBuffer.appendBuffer()",e.code,e),22===e.code?(this.stop(),this.mediaSourceAppendBufferFull=!0,this.player.emitError(lt.mediaSourceFull)):11===e.code?(this.stop(),this.mediaSourceAppendBufferError=!0,this.player.emitError(lt.mediaSourceAppendBufferError)):(this.stop(),this.mediaSourceBufferError=!0,this.player.emitError(st.mseSourceBufferError,e))}}if(ka(this.getAudioSourceBufferUpdating())&&this.pendingAudioSegments.length>0){const e=this.pendingAudioSegments.shift();try{this.audioSourceBuffer.appendBuffer(e)}catch(e){this.player.debug.error(this.TAG_NAME,"this.audioSourceBuffer.appendBuffer()",e.code,e),22===e.code?(this.stop(),this.mediaSourceAppendBufferFull=!0,this.player.emitError(lt.mediaSourceFull)):11===e.code?(this.stop(),this.mediaSourceAppendBufferError=!0,this.player.emitError(lt.mediaSourceAppendBufferError)):(this.stop(),this.mediaSourceBufferError=!0,this.player.emitError(st.mseSourceBufferError,e))}}}else this.player.debug.log(this.TAG_NAME,"_doAppendSegments() sourceBuffer is null and wait init and return")}_doCleanUpSourceBuffer(){if(!this.$videoElement)return;const e=this.$videoElement.currentTime;if(this.sourceBuffer){const t=this.sourceBuffer.buffered;let i=!1;for(let r=0;r<t.length;r++){let s=t.start(r),a=t.end(r);if(s<=e&&e<a+3){if(e-s>=this.player._opt.mseAutoCleanupMaxBackwardDuration){i=!0;let t=e-this.player._opt.mseAutoCleanupMinBackwardDuration;this.pendingRemoveRanges.push({start:s,end:t})}}else a<e&&(i=!0,this.pendingRemoveRanges.push({start:s,end:a}))}i&&ka(this.getSourceBufferUpdating())&&this._doRemoveRanges()}if(this.audioSourceBuffer){const t=this.audioSourceBuffer.buffered;let i=!1;for(let r=0;r<t.length;r++){let s=t.start(r),a=t.end(r);if(s<=e&&e<a+3){if(e-s>=this.player._opt.mseAutoCleanupMaxBackwardDuration){i=!0;let t=e-this.player._opt.mseAutoCleanupMinBackwardDuration;this.pendingAudioRemoveRanges.push({start:s,end:t})}}else a<e&&(i=!0,this.pendingAudioRemoveRanges.push({start:s,end:a}))}i&&ka(this.getAudioSourceBufferUpdating())&&this._doRemoveRanges()}}_hasPendingRemoveRanges(){return this.pendingRemoveRanges.length>0||this.pendingAudioRemoveRanges.length>0}_doRemoveRanges(){if(this.sourceBuffer&&ka(this.getSourceBufferUpdating())){let e=this.pendingRemoveRanges;for(;e.length&&ka(this.getSourceBufferUpdating());){let t=e.shift();try{this.sourceBuffer.remove(t.start,t.end)}catch(e){this.player.debug.warn(this.TAG_NAME,"_doRemoveRanges() sourceBuffer error",e)}}}if(this.audioSourceBuffer&&ka(this.getAudioSourceBufferUpdating())){let e=this.pendingAudioRemoveRanges;for(;e.length&&ka(this.getAudioSourceBufferUpdating());){let t=e.shift();try{this.audioSourceBuffer.remove(t.start,t.end)}catch(e){this.player.debug.warn(this.TAG_NAME,"_doRemoveRanges() audioSourceBuffer error",e)}}}}getDecodePlaybackRate(){let e=0;const t=this.$videoElement;return t&&(e=t.playbackRate),e}_getPlaybackRate(e){const t=this.$videoElement;let i=this.player._opt.videoBufferDelay+this.player._opt.videoBuffer;const r=Math.max(i,1e3),s=r/2;return e*=1e3,1===t.playbackRate?e>r?1.2:1:e<=s?1:t.playbackRate}_needCleanupSourceBuffer(){if(ka(this.player._opt.mseAutoCleanupSourceBuffer)||!this.$videoElement)return!1;const e=this.$videoElement,t=e.buffered,i=e.currentTime;return t.length>=1&&i-t.start(0)>=this.player._opt.mseAutoCleanupMaxBackwardDuration}getVideoCurrentTime(){let e=0;return this.$videoElement&&(e=this.$videoElement.currentTime),e}getVideoBufferLastTime(){const e=this.$videoElement;let t=0;if(e){const i=e.buffered;i.length&&i.start(0);t=i.length?i.end(i.length-1):0}return t}getVideoBufferDelayTime(){const e=this.$videoElement;const t=this.getVideoBufferLastTime()-e.currentTime;return t>0?t:0}_clearAudioSourceBufferCheckTimeout(){this.audioSourceBufferCheckTimeout&&(clearTimeout(this.audioSourceBufferCheckTimeout),this.audioSourceBufferCheckTimeout=null)}_clearAudioNoDataCheckTimeout(){this.audioSourceNoDataCheckTimeout&&(clearTimeout(this.audioSourceNoDataCheckTimeout),this.audioSourceNoDataCheckTimeout=null)}}const xd=()=>"wakeLock"in navigator&&-1===window.navigator.userAgent.indexOf("Samsung")&&ka(Ls());class Ld{constructor(e){this.player=e,this.enabled=!1,xd()?(this.player.debug.log("NoSleep","Native Wake Lock API supported."),this._wakeLock=null,this.handleVisibilityChange=()=>{null!==this._wakeLock&&"visible"===document.visibilityState&&this.enable()},document.addEventListener("visibilitychange",this.handleVisibilityChange),document.addEventListener("fullscreenchange",this.handleVisibilityChange)):(this.player.debug.log("NoSleep","Native Wake Lock API not supported. so use video element."),this.noSleepVideo=document.createElement("video"),this.noSleepVideo.setAttribute("title","No Sleep"),this.noSleepVideo.setAttribute("playsinline",""),this._addSourceToVideo(this.noSleepVideo,"webm","data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQRChYECGFOAZwEAAAAAABLfEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHYTbuMU6uEElTDZ1OsggGXTbuMU6uEHFO7a1OsghLJ7AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmsirXsYMPQkBNgI1MYXZmNTguNDUuMTAwV0GNTGF2ZjU4LjQ1LjEwMESJiECzmgAAAAAAFlSua0C5rgEAAAAAAABO14EBc8WI9UhIq9EDJPCcgQAitZyDdW5khoVWX1ZQOIOBASPjg4QF9eEA4AEAAAAAAAAbsIIBQLqB8FSwggElVLqB8FWwiFW3gQFVuIECrgEAAAAAAABZ14ECc8WIUEWPA9J/iJ6cgQAitZyDdW5khoZBX09QVVNWqoNjLqBWu4QExLQAg4EC4ZGfgQG1iEDncAAAAAAAYmSBIGOik09wdXNIZWFkAQE4AYC7AAAAAAASVMNnQcJzcwEAAAAAAACXY8CAZ8gBAAAAAAAAFUWji01BSk9SX0JSQU5ERIeEaXNvbWfIAQAAAAAAABZFo41NSU5PUl9WRVJTSU9ORIeDNTEyZ8gBAAAAAAAAJ0WjkUNPTVBBVElCTEVfQlJBTkRTRIeQaXNvbWlzbzJhdmMxbXA0MWfIAQAAAAAAABpFo4dFTkNPREVSRIeNTGF2ZjU4LjQ1LjEwMHNzAQAAAAAAAIZjwItjxYj1SEir0QMk8GfIAQAAAAAAAB5Fo4xIQU5ETEVSX05BTUVEh4xWaWRlb0hhbmRsZXJnyAEAAAAAAAAhRaOHRU5DT0RFUkSHlExhdmM1OC45MS4xMDAgbGlidnB4Z8iiRaOIRFVSQVRJT05Eh5QwMDowMDowNS4wMDcwMDAwMDAAAHNzAQAAAAAAAIdjwItjxYhQRY8D0n+InmfIAQAAAAAAAB5Fo4xIQU5ETEVSX05BTUVEh4xTb3VuZEhhbmRsZXJnyAEAAAAAAAAiRaOHRU5DT0RFUkSHlUxhdmM1OC45MS4xMDAgbGlib3B1c2fIokWjiERVUkFUSU9ORIeUMDA6MDA6MDUuMDE4MDAwMDAwAAAfQ7Z1T2TngQCjh4IAAID4//6jQKSBAAeAMBIAnQEqQAHwAABHCIWFiIWEiAICAAYWBPcGgWSfa9ubJzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh69AD+/6tQgKOHggAVgPj//qOHggApgPj//qOHggA9gPj//qOHggBRgPj//qOHggBlgPj//qOegQBrANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCAHmA+P/+o4eCAI2A+P/+o4eCAKGA+P/+o4eCALWA+P/+o4eCAMmA+P/+o56BAM8A0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4IA3YD4//6jh4IA8YD4//6jh4IBBYD4//6jh4IBGYD4//6jh4IBLYD4//6jnoEBMwDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHggFBgPj//qOHggFVgPj//qOHggFpgPj//qOHggF9gPj//qOHggGRgPj//qOegQGXANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCAaWA+P/+o4eCAbmA+P/+o4eCAc2A+P/+o4eCAeGA+P/+o4eCAfWA+P/+o56BAfsA0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4ICCYD4//6jh4ICHYD4//6jh4ICMYD4//6jh4ICRYD4//6jh4ICWYD4//6jnoECXwDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHggJtgPj//qOHggKBgPj//qOHggKVgPj//qOHggKpgPj//qOHggK9gPj//qOegQLDANECAAUQEBRgAGFgv9AAIgAQzX61yT5xzAAAo4eCAtGA+P/+o4eCAuWA+P/+o4eCAvmA+P/+o4eCAw2A+P/+o4eCAyGA+P/+o56BAycA0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4IDNYD4//6jh4IDSYD4//6jh4IDXYD4//6jh4IDcYD4//6jh4IDhYD4//6jnoEDiwDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHggOZgPj//qOHggOtgPj//qOHggPBgPj//qOHggPVgPj//qOHggPpgPj//qOegQPvANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCA/2A+P/+o4eCBBGA+P/+o4eCBCWA+P/+o4eCBDmA+P/+o4eCBE2A+P/+o56BBFMA0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4IEiID4//6jh4IEnID4//6jh4IEsID4//6jnoEEtwDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHggTEgPj//qOHggTYgPj//qOHggTsgPj//qOHggUAgPj//qOHggUUgPj//qOegQUbANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCBSiA+P/+o4eCBTyA+P/+o4eCBVCA+P/+o4eCBWSA+P/+o4eCBXiA+P/+o56BBX8A0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4IFjID4//6jh4IFoID4//6jh4IFtID4//6jh4IFyID4//6jh4IF3ID4//6jnoEF4wDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHggXwgPj//qOHggYEgPj//qOHggYYgPj//qOHggYsgPj//qOHggZAgPj//qOegQZHANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCBlSA+P/+o4eCBmiA+P/+o4eCBnyA+P/+o4eCBpCA+P/+o4eCBqSA+P/+o56BBqsA0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4IGuID4//6jh4IGzID4//6jh4IG4ID4//6jh4IG9ID4//6jh4IHCID4//6jnoEHDwDRAgAFEBAUYABhYL/QACIAEM1+tck+ccwAAKOHggccgPj//qOHggcwgPj//qOHggdEgPj//qOHggdYgPj//qOHggdsgPj//qOegQdzANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCB4CA+P/+o4eCB5SA+P/+o4eCB6iA+P/+o4eCB7yA+P/+o4eCB9CA+P/+o56BB9cA0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4IH5ID4//6jh4IH+ID4//6jh4IIDID4//6jh4IIIID4//6jh4IINID4//6jnoEIOwDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHgghIgPj//qOHgghcgPj//qOHgghwgPj//qOHggiEgPj//qOegQifANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCCMCA+P/+o4eCCNSA+P/+o4eCCOiA+P/+o4eCCPyA+P/+o56BCQMA0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4IJEID4//6jh4IJJID4//6jh4IJOID4//6jh4IJTID4//6jh4IJYID4//6jnoEJZwDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHggl0gPj//qOHggmIgPj//qOHggmcgPj//qOHggmwgPj//qOHggnEgPj//qOegQnLANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCCdiA+P/+o4eCCeyA+P/+o4eCCgCA+P/+o4eCChSA+P/+o4eCCiiA+P/+o56BCi8A0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4IKPID4//6jh4IKUID4//6jh4IKZID4//6jh4IKeID4//6jh4IKjID4//6jnoEKkwDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHggqggPj//qOHggq0gPj//qOHggrIgPj//qOHggrcgPj//qOHggrwgPj//qOegQr3ANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCCwSA+P/+o4eCCxiA+P/+o4eCCyyA+P/+o4eCC0CA+P/+o4eCC1SA+P/+o56BC1sA0QIABRAQFGAAYWC/0AAiABDNfrXJPnHMAACjh4ILaID4//6jh4ILfID4//6jh4ILkID4//6jh4ILpID4//6jh4ILuID4//6jnoELvwDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHggvMgPj//qOHggvggPj//qOHggv0gPj//qOHggwIgPj//qOHggwcgPj//qOegQwjANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCDDCA+P/+o4eCDESA+P/+o4eCDFiA+P/+o4eCDGyA+P/+o4eCDICA+P/+o56BDIcA0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4IMlID4//6jh4IMqID4//6jh4IMvID4//6jh4IM0ID4//6jnoEM6wDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHgg0MgPj//qOHgg0ggPj//qOHgg00gPj//qOHgg1IgPj//qOegQ1PANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCDVyA+P/+o4eCDXCA+P/+o4eCDYSA+P/+o4eCDZiA+P/+o4eCDayA+P/+o56BDbMA0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4INwID4//6jh4IN1ID4//6jh4IN6ID4//6jh4IN/ID4//6jh4IOEID4//6jnoEOFwDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHgg4kgPj//qOHgg44gPj//qOHgg5MgPj//qOHgg5ggPj//qOHgg50gPj//qOegQ57ANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCDoiA+P/+o4eCDpyA+P/+o4eCDrCA+P/+o4eCDsSA+P/+o4eCDtiA+P/+o56BDt8A0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4IO7ID4//6jh4IPAID4//6jh4IPFID4//6jh4IPKID4//6jh4IPPID4//6jnoEPQwDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHgg9QgPj//qOHgg9kgPj//qOHgg94gPj//qOHgg+MgPj//qOHgg+ggPj//qOegQ+nANECAAUQEBRgAGFgv9AAIgAQzX61yT5xzAAAo4eCD7SA+P/+o4eCD8iA+P/+o4eCD9yA+P/+o4eCD/CA+P/+o4eCEASA+P/+o56BEAsA0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4IQGID4//6jh4IQLID4//6jh4IQQID4//6jh4IQVID4//6jh4IQaID4//6jnoEQbwDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHghB8gPj//qOHghCQgPj//qOHghCkgPj//qOHghC4gPj//qOHghDMgPj//qOegRDTANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCEOCA+P/+o4eCEPSA+P/+o4eCEQiA+P/+o56BETcA0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4IRQ4D4//6jh4IRV4D4//6jh4IRa4D4//6jh4IRf4D4//6jh4IRk4D4//6jnoERmwDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHghGngPj//qOHghG7gPj//qOHghHPgPj//qOHghHjgPj//qOHghH3gPj//qOegRH/ANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCEguA+P/+o4eCEh+A+P/+o4eCEjOA+P/+o4eCEkeA+P/+o4eCEluA+P/+o56BEmMA0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4ISb4D4//6jh4ISg4D4//6jh4ISl4D4//6jh4ISq4D4//6jh4ISv4D4//6jnoESxwDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHghLTgPj//qOHghLngPj//qOHghL7gPj//qOHghMPgPj//qOHghMjgPj//qOegRMrANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCEzeA+P/+o4eCE0uA+P/+o4eCE1+A+P/+o4eCE3OA+P/+oAEAAAAAAAAPoYeCE4cA+P/+daKDB/KBHFO7a5G7j7OBB7eK94EB8YIDX/CBDA=="),this._addSourceToVideo(this.noSleepVideo,"mp4","data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAACORtZGF03gIATGF2YzU4LjM1LjEwMAACMEAOAAACcQYF//9t3EXpvebZSLeWLNgg2SPu73gyNjQgLSBjb3JlIDE2MSByMzAyNyA0MTIxMjc3IC0gSC4yNjQvTVBFRy00IEFWQyBjb2RlYyAtIENvcHlsZWZ0IDIwMDMtMjAyMCAtIGh0dHA6Ly93d3cudmlkZW9sYW4ub3JnL3gyNjQuaHRtbCAtIG9wdGlvbnM6IGNhYmFjPTAgcmVmPTMgZGVibG9jaz0xOjA6MCBhbmFseXNlPTB4MToweDExMSBtZT1oZXggc3VibWU9NyBwc3k9MSBwc3lfcmQ9MS4wMDowLjAwIG1peGVkX3JlZj0xIG1lX3JhbmdlPTE2IGNocm9tYV9tZT0xIHRyZWxsaXM9MSA4eDhkY3Q9MCBjcW09MCBkZWFkem9uZT0yMSwxMSBmYXN0X3Bza2lwPTEgY2hyb21hX3FwX29mZnNldD0tMiB0aHJlYWRzPTcgbG9va2FoZWFkX3RocmVhZHM9MSBzbGljZWRfdGhyZWFkcz0wIG5yPTAgZGVjaW1hdGU9MSBpbnRlcmxhY2VkPTAgYmx1cmF5X2NvbXBhdD0wIGNvbnN0cmFpbmVkX2ludHJhPTAgYmZyYW1lcz0wIHdlaWdodHA9MCBrZXlpbnQ9MjUwIGtleWludF9taW49MTAgc2NlbmVjdXQ9NDAgaW50cmFfcmVmcmVzaD0wIHJjX2xvb2thaGVhZD00MCByYz1jcmYgbWJ0cmVlPTEgY3JmPTIzLjAgcWNvbXA9MC42MCBxcG1pbj0wIHFwbWF4PTY5IHFwc3RlcD00IGlwX3JhdGlvPTEuNDAgYXE9MToxLjAwAIAAAADvZYiED/JigADD7JycnJycnJycnJycnJycnJycnJ11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111114BGCAHARggBwEYIAcBGCAHARggBwAAAAdBmjgf4BLYARggBwEYIAcBGCAHARggBwAAAAdBmlQH+AS2ARggBwEYIAcBGCAHARggBwAAAAdBmmA/wCWwARggBwEYIAcBGCAHARggBwEYIAcAAAAHQZqAP8AlsAEYIAcBGCAHARggBwEYIAcAAAAHQZqgP8AlsAEYIAcBGCAHARggBwEYIAcAAAAHQZrAP8AlsAEYIAcBGCAHARggBwEYIAcBGCAHAAAAB0Ga4D/AJbABGCAHARggBwEYIAcBGCAHAAAAB0GbAD/AJbABGCAHARggBwEYIAcBGCAHAAAAB0GbID/AJbABGCAHARggBwEYIAcBGCAHARggBwAAAAdBm0A/wCWwARggBwEYIAcBGCAHAAAAB0GbYD/AJbABGCAHARggBwEYIAcAAAAHQZuAP8AlsAEYIAcBGCAHARggBwEYIAcBGCAHAAAAB0GboD/AJbABGCAHARggBwEYIAcBGCAHAAAAB0GbwD/AJbABGCAHARggBwEYIAcBGCAHAAAAB0Gb4D/AJbABGCAHARggBwEYIAcBGCAHARggBwAAAAdBmgA/wCWwARggBwEYIAcBGCAHARggBwAAAAdBmiA/wCWwARggBwEYIAcBGCAHARggBwAAAAdBmkA/wCWwARggBwEYIAcBGCAHARggBwEYIAcAAAAHQZpgP8AlsAEYIAcBGCAHARggBwEYIAcAAAAHQZqAP8AlsAEYIAcBGCAHARggBwEYIAcAAAAHQZqgP8AlsAEYIAcBGCAHARggBwAAAAdBmsA/wCWwARggBwEYIAcBGCAHARggBwAAAAdBmuA/wCWwARggBwEYIAcBGCAHARggBwAAAAdBmwA/wCWwARggBwEYIAcBGCAHARggBwEYIAcAAAAHQZsgP8AlsAEYIAcBGCAHARggBwEYIAcAAAAHQZtAP8AlsAEYIAcBGCAHARggBwEYIAcAAAAHQZtgP8AlsAEYIAcBGCAHARggBwEYIAcBGCAHAAAAB0GbgD/AJbABGCAHARggBwEYIAcBGCAHAAAAB0GboD/AJbABGCAHARggBwEYIAcBGCAHAAAAB0GbwD/AJbABGCAHARggBwEYIAcBGCAHARggBwAAAAdBm+A/wCWwARggBwEYIAcBGCAHARggBwAAAAdBmgA/wCWwARggBwEYIAcAAAAHQZogP8AlsAEYIAcBGCAHARggBwEYIAcBGCAHAAAAB0GaQD/AJbABGCAHARggBwEYIAcBGCAHAAAAB0GaYD/AJbABGCAHARggBwEYIAcBGCAHAAAAB0GagD/AJbABGCAHARggBwEYIAcBGCAHARggBwAAAAdBmqA/wCWwARggBwEYIAcBGCAHARggBwAAAAdBmsA/wCWwARggBwEYIAcBGCAHARggBwAAAAdBmuA/wCWwARggBwEYIAcBGCAHARggBwEYIAcAAAAHQZsAP8AlsAEYIAcBGCAHARggBwEYIAcAAAAHQZsgP8AlsAEYIAcBGCAHARggBwEYIAcAAAAHQZtAP8AlsAEYIAcBGCAHARggBwEYIAcBGCAHAAAAB0GbYD/AJbABGCAHARggBwAAAAdBm4A/wCWwARggBwEYIAcBGCAHARggBwAAAAdBm6A/wCWwARggBwEYIAcBGCAHARggBwEYIAcAAAAHQZvAP8AlsAEYIAcBGCAHARggBwEYIAcAAAAHQZvgP8AlsAEYIAcBGCAHARggBwEYIAcAAAAHQZoAO8AlsAEYIAcBGCAHARggBwEYIAcBGCAHAAAAB0GaIDfAJbABGCAHARggBwEYIAcBGCAHAAAMxm1vb3YAAABsbXZoZAAAAAAAAAAAAAAAAAAAA+gAABOgAAEAAAEAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAPLdHJhawAAAFx0a2hkAAAAAwAAAAAAAAAAAAAAAQAAAAAAABOIAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAElVVUA8AAAAAAAJGVkdHMAAAAcZWxzdAAAAAAAAAABAAATiAAAAAAAAQAAAAADQ21kaWEAAAAgbWRoZAAAAAAAAAAAAAAAAAAAKAAAAMgAVcQAAAAAAC1oZGxyAAAAAAAAAAB2aWRlAAAAAAAAAAAAAAAAVmlkZW9IYW5kbGVyAAAAAu5taW5mAAAAFHZtaGQAAAABAAAAAAAAAAAAAAAkZGluZgAAABxkcmVmAAAAAAAAAAEAAAAMdXJsIAAAAAEAAAKuc3RibAAAAKpzdHNkAAAAAAAAAAEAAACaYXZjMQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAFAAPAASAAAAEgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABj//wAAADRhdmNDAULAC//hABxnQsAL2QFB+/8ACwAMEAAAAwAQAAADAUDxQqSAAQAFaMuDyyAAAAAQcGFzcAAAAAsAAAAMAAAAGHN0dHMAAAAAAAAAAQAAADIAAAQAAAAAFHN0c3MAAAAAAAAAAQAAAAEAAAAcc3RzYwAAAAAAAAABAAAAAQAAAAEAAAABAAAA3HN0c3oAAAAAAAAAAAAAADIAAANoAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAANhzdGNvAAAAAAAAADIAAABFAAADwQAAA9wAAAP3AAAEFgAABDEAAARMAAAEawAABIYAAAShAAAEwAAABNcAAATuAAAFDQAABSgAAAVDAAAFYgAABX0AAAWYAAAFtwAABdIAAAXtAAAGBAAABh8AAAY6AAAGWQAABnQAAAaPAAAGrgAABskAAAbkAAAHAwAABx4AAAcxAAAHUAAAB2sAAAeGAAAHpQAAB8AAAAfbAAAH+gAACBUAAAgwAAAITwAACGIAAAh9AAAInAAACLcAAAjSAAAI8QAACCV0cmFrAAAAXHRraGQAAAADAAAAAAAAAAAAAAACAAAAAAAAE6AAAAAAAAAAAAAAAAEBAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAkZWR0cwAAABxlbHN0AAAAAAAAAAEAABOIAAAEAAABAAAAAAedbWRpYQAAACBtZGhkAAAAAAAAAAAAAAAAAACsRAADYVRVxAAAAAAALWhkbHIAAAAAAAAAAHNvdW4AAAAAAAAAAAAAAABTb3VuZEhhbmRsZXIAAAAHSG1pbmYAAAAQc21oZAAAAAAAAAAAAAAAJGRpbmYAAAAcZHJlZgAAAAAAAAABAAAADHVybCAAAAABAAAHDHN0YmwAAABqc3RzZAAAAAAAAAABAAAAWm1wNGEAAAAAAAAAAQAAAAAAAAAAAAIAEAAAAACsRAAAAAAANmVzZHMAAAAAA4CAgCUAAgAEgICAF0AVAAAAAAENiAAABVQFgICABRIIVuUABoCAgAECAAAAYHN0dHMAAAAAAAAACgAAAC8AAAQAAAAAAQAACtUAAAAsAAAEAAAAAAEAAArWAAAALAAABAAAAAABAAAK1QAAACwAAAQAAAAAAQAACtUAAAAaAAAEAAAAAAEAAAH/AAABzHN0c2MAAAAAAAAAJQAAAAEAAAABAAAAAQAAAAIAAAAFAAAAAQAAAAMAAAAEAAAAAQAAAAUAAAAFAAAAAQAAAAYAAAAEAAAAAQAAAAgAAAAFAAAAAQAAAAkAAAAEAAAAAQAAAAsAAAAFAAAAAQAAAAwAAAADAAAAAQAAAA4AAAAFAAAAAQAAAA8AAAAEAAAAAQAAABEAAAAFAAAAAQAAABIAAAAEAAAAAQAAABQAAAAFAAAAAQAAABUAAAAEAAAAAQAAABcAAAADAAAAAQAAABgAAAAEAAAAAQAAABoAAAAFAAAAAQAAABsAAAAEAAAAAQAAAB0AAAAFAAAAAQAAAB4AAAAEAAAAAQAAACAAAAAFAAAAAQAAACEAAAAEAAAAAQAAACIAAAACAAAAAQAAACMAAAAFAAAAAQAAACQAAAAEAAAAAQAAACYAAAAFAAAAAQAAACcAAAAEAAAAAQAAACkAAAAFAAAAAQAAACoAAAAEAAAAAQAAACwAAAAFAAAAAQAAAC0AAAACAAAAAQAAAC4AAAAEAAAAAQAAAC8AAAAFAAAAAQAAADAAAAAEAAAAAQAAADIAAAAFAAAAAQAAADMAAAAEAAAAAQAAA1xzdHN6AAAAAAAAAAAAAADSAAAAFQAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAA3HN0Y28AAAAAAAAAMwAAADAAAAOtAAADzAAAA+cAAAQCAAAEIQAABDwAAARXAAAEdgAABJEAAASsAAAEywAABOIAAAT5AAAFGAAABTMAAAVOAAAFbQAABYgAAAWjAAAFwgAABd0AAAX4AAAGDwAABioAAAZFAAAGZAAABn8AAAaaAAAGuQAABtQAAAbvAAAHDgAABykAAAc8AAAHWwAAB3YAAAeRAAAHsAAAB8sAAAfmAAAIBQAACCAAAAg7AAAIWgAACG0AAAiIAAAIpwAACMIAAAjdAAAI/AAAABpzZ3BkAQAAAHJvbGwAAAACAAAAAf//AAAAHHNiZ3AAAAAAcm9sbAAAAAEAAADSAAAAAQAAAGJ1ZHRhAAAAWm1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAALWlsc3QAAAAlqXRvbwAAAB1kYXRhAAAAAQAAAABMYXZmNTguMjAuMTAw"),Object.assign(this.noSleepVideo.style,{position:"absolute",left:"-100%",top:"-100%"}),document.querySelector("body").append(this.noSleepVideo),this.handleNoSleepVideoTimeUpdate=()=>{this.noSleepVideo&&this.noSleepVideo.currentTime>4&&(this.noSleepVideo.currentTime=1)},this.noSleepVideo.addEventListener("timeupdate",this.handleNoSleepVideoTimeUpdate))}destroy(){if(this._wakeLock&&(this._wakeLock.release(),this._wakeLock=null),this.noSleepVideo){this.handleNoSleepVideoTimeUpdate&&this.noSleepVideo.removeEventListener("timeupdate",this.handleNoSleepVideoTimeUpdate);try{this.noSleepVideo.parentNode&&this.noSleepVideo.parentNode.removeChild(this.noSleepVideo)}catch(e){this.player.debug.warn("NoSleep","Failed to remove noSleepVideo element.")}this.noSleepVideo=null}this.handleVisibilityChange&&(document.removeEventListener("visibilitychange",this.handleVisibilityChange),document.removeEventListener("fullscreenchange",this.handleVisibilityChange))}_addSourceToVideo(e,t,i){var r=document.createElement("source");r.src=i,r.type=`video/${t}`,e.appendChild(r)}get isEnabled(){return this.enabled}enable(){const e=this.player.debug;if(xd())return navigator.wakeLock.request("screen").then((t=>{this._wakeLock=t,this.enabled=!0,e.log("wakeLock","Wake Lock active."),this._wakeLock.addEventListener("release",(()=>{e.log("wakeLock","Wake Lock released.")}))})).catch((t=>{throw this.enabled=!1,e.warn("wakeLock",`${t.name}, ${t.message}`),t}));return this.noSleepVideo.play().then((t=>(e.log("wakeLock","noSleepVideo Wake Lock active."),this.enabled=!0,t))).catch((t=>{throw e.warn("wakeLock",`noSleepVideo ${t.name}, ${t.message}`),this.enabled=!1,t}))}disable(){xd()?(this._wakeLock&&this._wakeLock.release(),this._wakeLock=null):this.noSleepVideo&&this.noSleepVideo.pause(),this.enabled=!1,this.player.debug.log("wakeLock","Disabling wake lock.")}}var Id,Pd=Zr((function(e,t){!function t(i){e.exports=function(){function e(e,t,i){if(r())return Reflect.construct.apply(null,arguments);var s=[null];s.push.apply(s,t);var a=new(e.bind.apply(e,s));return i&&f(a,i.prototype),a}function r(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(r=function(){return!!e})()}function s(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}function a(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?s(Object(i),!0).forEach((function(t){h(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):s(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function n(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function o(e){var t=n(e,"string");return"symbol"==typeof t?t:t+""}function l(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,o(r.key),r)}}function d(e,t,i){return t&&l(e.prototype,t),i&&l(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function h(e,t,i){return(t=o(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},c.apply(this,arguments)}function u(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,f(e,t)}function p(e){return p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},p(e)}function f(e,t){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},f(e,t)}function y(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}function m(t){var i="function"==typeof Map?new Map:void 0;return m=function(t){if(null===t||!y(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==i){if(i.has(t))return i.get(t);i.set(t,r)}function r(){return e(t,arguments,p(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),f(r,t)},m(t)}function g(e,t){if(e){if("string"==typeof e)return A(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?A(e,t):void 0}}function A(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=new Array(t);i<t;i++)r[i]=e[i];return r}function v(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=g(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function b(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var _={exports:{}};!function(e,t){var i,r,s,a,n;i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,s=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,n={buildAbsoluteURL:function(e,t,i){if(i=i||{},e=e.trim(),!(t=t.trim())){if(!i.alwaysNormalize)return e;var s=n.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");return s.path=n.normalizePath(s.path),n.buildURLFromParts(s)}var a=n.parseURL(t);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return i.alwaysNormalize?(a.path=n.normalizePath(a.path),n.buildURLFromParts(a)):t;var o=n.parseURL(e);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=r.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var d={scheme:o.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(d.netLoc=o.netLoc,"/"!==a.path[0]))if(a.path){var h=o.path,c=h.substring(0,h.lastIndexOf("/")+1)+a.path;d.path=n.normalizePath(c)}else d.path=o.path,a.params||(d.params=o.params,a.query||(d.query=o.query));return null===d.path&&(d.path=i.alwaysNormalize?n.normalizePath(a.path):a.path),n.buildURLFromParts(d)},parseURL:function(e){var t=i.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(s,"");e.length!==(e=e.replace(a,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},e.exports=n}(_);var w=_.exports,E=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},S=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=T},T=Number.MAX_SAFE_INTEGER||9007199254740991,k=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.MEDIA_ENDED="hlsMediaEnded",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached",e.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",e}({}),C=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),D=function(e){return e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_PARSING_ERROR="levelParsingError",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.FRAG_GAP="fragGap",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.UNKNOWN="unknown",e}({}),R=/^(\d+)x(\d+)$/,x=/(.+?)=(".*?"|.*?)(?:,|$)/g,L=function(){function e(t){"string"==typeof t&&(t=e.parseAttrList(t)),c(this,t)}var t=e.prototype;return t.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var i=new Uint8Array(t.length/2),r=0;r<t.length/2;r++)i[r]=parseInt(t.slice(2*r,2*r+2),16);return i}return null},t.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.decimalFloatingPoint=function(e){return parseFloat(this[e])},t.optionalFloat=function(e,t){var i=this[e];return i?parseFloat(i):t},t.enumeratedString=function(e){return this[e]},t.bool=function(e){return"YES"===this[e]},t.decimalResolution=function(e){var t=R.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},e.parseAttrList=function(e){var t,i={},r='"';for(x.lastIndex=0;null!==(t=x.exec(e));){var s=t[2];0===s.indexOf(r)&&s.lastIndexOf(r)===s.length-1&&(s=s.slice(1,-1)),i[t[1].trim()]=s}return i},d(e,[{key:"clientAttrs",get:function(){return Object.keys(this).filter((function(e){return"X-"===e.substring(0,2)}))}}])}(),I=function(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;var i="["+e+"]:";this.trace=P,this.debug=t.debug.bind(null,i),this.log=t.log.bind(null,i),this.warn=t.warn.bind(null,i),this.info=t.info.bind(null,i),this.error=t.error.bind(null,i)},P=function(){},B={trace:P,debug:P,log:P,warn:P,info:P,error:P};function M(){return c({},B)}function U(e,t){var i=self.console[e];return i?i.bind(self.console,(t?"["+t+"] ":"")+"["+e+"] >"):P}function F(e,t,i){return t[e]?t[e].bind(t):U(e,i)}var O=M();function N(e,t,i){var r=M();if("object"==typeof console&&!0===e||"object"==typeof e){var s=["debug","log","info","warn","error"];s.forEach((function(t){r[t]=F(t,e,i)}));try{r.log('Debug logs enabled for "'+t+'" in hls.js version '+void 0)}catch(e){return M()}s.forEach((function(t){O[t]=F(t,e)}))}else c(O,r);return r}var G=O;function z(e){return"ID"!==e&&"CLASS"!==e&&"START-DATE"!==e&&"DURATION"!==e&&"END-DATE"!==e&&"END-ON-NEXT"!==e}function W(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e}var V=function(){function e(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){var i=t.attr;for(var r in i)if(Object.prototype.hasOwnProperty.call(e,r)&&e[r]!==i[r]){G.warn('DATERANGE tag attribute: "'+r+'" does not match for tags with ID: "'+e.ID+'"'),this._badValueForSameId=r;break}e=c(new L({}),i,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){var s=new Date(this.attr["END-DATE"]);E(s.getTime())&&(this._endDate=s)}}return d(e,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var e=this.duration;return null!==e?new Date(this._startDate.getTime()+1e3*e):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var e=this.attr.decimalFloatingPoint("DURATION");if(E(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&E(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}])}(),H=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}},$={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},j=function(){function e(e){var t;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((t={})[$.AUDIO]=null,t[$.VIDEO]=null,t[$.AUDIOVIDEO]=null,t),this.baseurl=e}return e.prototype.setByteRange=function(e,t){var i,r=e.split("@",2);i=1===r.length?(null==t?void 0:t.byteRangeEndOffset)||0:parseInt(r[1]),this._byteRange=[i,parseInt(r[0])+i]},d(e,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=w.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}}])}(),K=function(e){function t(t,i){var r;return(r=e.call(this,i)||this)._decryptdata=null,r.rawProgramDateTime=null,r.programDateTime=null,r.tagList=[],r.duration=0,r.sn=0,r.levelkeys=void 0,r.type=void 0,r.loader=null,r.keyLoader=null,r.level=-1,r.cc=0,r.startPTS=void 0,r.endPTS=void 0,r.startDTS=void 0,r.endDTS=void 0,r.start=0,r.deltaPTS=void 0,r.maxStartPTS=void 0,r.minEndPTS=void 0,r.stats=new H,r.data=void 0,r.bitrateTest=!1,r.title=null,r.initSegment=null,r.endList=void 0,r.gap=void 0,r.urlId=0,r.type=t,r}u(t,e);var i=t.prototype;return i.setKeyFormat=function(e){if(this.levelkeys){var t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}},i.abortRequests=function(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()},i.setElementaryStreamInfo=function(e,t,i,r,s,a){void 0===a&&(a=!1);var n=this.elementaryStreams,o=n[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,i),o.startDTS=Math.min(o.startDTS,r),o.endDTS=Math.max(o.endDTS,s)):n[e]={startPTS:t,endPTS:i,startDTS:r,endDTS:s,partial:a}},i.clearElementaryStreamInfo=function(){var e=this.elementaryStreams;e[$.AUDIO]=null,e[$.VIDEO]=null,e[$.AUDIOVIDEO]=null},d(t,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{var t=Object.keys(this.levelkeys);if(1===t.length)return this._decryptdata=this.levelkeys[t[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!E(this.programDateTime))return null;var e=E(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var t=Object.keys(this.levelkeys),i=t.length;if(i>1||1===i&&this.levelkeys[t[0]].encrypted)return!0}return!1}}])}(j),q=function(e){function t(t,i,r,s,a){var n;(n=e.call(this,r)||this).fragOffset=0,n.duration=0,n.gap=!1,n.independent=!1,n.relurl=void 0,n.fragment=void 0,n.index=void 0,n.stats=new H,n.duration=t.decimalFloatingPoint("DURATION"),n.gap=t.bool("GAP"),n.independent=t.bool("INDEPENDENT"),n.relurl=t.enumeratedString("URI"),n.fragment=i,n.index=s;var o=t.enumeratedString("BYTERANGE");return o&&n.setByteRange(o,a),a&&(n.fragOffset=a.fragOffset+a.duration),n}return u(t,e),d(t,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}])}(j),Y=10,Q=function(){function e(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}return e.prototype.reloaded=function(e){if(!e)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&i>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay},d(e,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&E(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||Y}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}])}();function X(e){return Uint8Array.from(atob(e),(function(e){return e.charCodeAt(0)}))}function J(e){return Uint8Array.from(unescape(encodeURIComponent(e)),(function(e){return e.charCodeAt(0)}))}function Z(e){var t=J(e).subarray(0,16),i=new Uint8Array(16);return i.set(t,16-t.length),i}function ee(e){var t=function(e,t,i){var r=e[t];e[t]=e[i],e[i]=r};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}function te(e){var t=e.split(":"),i=null;if("data"===t[0]&&2===t.length){var r=t[1].split(";"),s=r[r.length-1].split(",");if(2===s.length){var a="base64"===s[0],n=s[1];a?(r.splice(-1,1),i=X(n)):i=Z(n)}}return i}var ie={cbc:0,ctr:1};function re(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function se(e){switch(e){case"AES-128":case"AES-256":return ie.cbc;case"AES-256-CTR":return ie.ctr;default:throw new Error("invalid full segment method "+e)}}var ae="undefined"!=typeof self?self:void 0,ne={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},oe={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function le(e){switch(e){case oe.FAIRPLAY:return ne.FAIRPLAY;case oe.PLAYREADY:return ne.PLAYREADY;case oe.WIDEVINE:return ne.WIDEVINE;case oe.CLEARKEY:return ne.CLEARKEY}}var de={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function he(e){if(e===de.WIDEVINE)return ne.WIDEVINE}function ce(e){switch(e){case ne.FAIRPLAY:return oe.FAIRPLAY;case ne.PLAYREADY:return oe.PLAYREADY;case ne.WIDEVINE:return oe.WIDEVINE;case ne.CLEARKEY:return oe.CLEARKEY}}function ue(e){var t=e.drmSystems,i=e.widevineLicenseUrl,r=t?[ne.FAIRPLAY,ne.WIDEVINE,ne.PLAYREADY,ne.CLEARKEY].filter((function(e){return!!t[e]})):[];return!r[ne.WIDEVINE]&&i&&r.push(ne.WIDEVINE),r}var pe,fe=null!=ae&&null!=(pe=ae.navigator)&&pe.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function ye(e,t,i,r){var s;switch(e){case ne.FAIRPLAY:s=["cenc","sinf"];break;case ne.WIDEVINE:case ne.PLAYREADY:s=["cenc"];break;case ne.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+e)}return me(s,t,i,r)}function me(e,t,i,r){return[{initDataTypes:e,persistentState:r.persistentState||"optional",distinctiveIdentifier:r.distinctiveIdentifier||"optional",sessionTypes:r.sessionTypes||[r.sessionType||"temporary"],audioCapabilities:t.map((function(e){return{contentType:'audio/mp4; codecs="'+e+'"',robustness:r.audioRobustness||"",encryptionScheme:r.audioEncryptionScheme||null}})),videoCapabilities:i.map((function(e){return{contentType:'video/mp4; codecs="'+e+'"',robustness:r.videoRobustness||"",encryptionScheme:r.videoEncryptionScheme||null}}))}]}function ge(e,t,i){return Uint8Array.prototype.slice?e.slice(t,i):new Uint8Array(Array.prototype.slice.call(e,t,i))}function Ae(e,t){if(void 0===t&&(t=!1),"undefined"!=typeof TextDecoder){var i=new TextDecoder("utf-8").decode(e);if(t){var r=i.indexOf("\0");return-1!==r?i.substring(0,r):i}return i.replace(/\0/g,"")}for(var s,a,n,o=e.length,l="",d=0;d<o;){if(0===(s=e[d++])&&t)return l;if(0!==s&&3!==s)switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:l+=String.fromCharCode(s);break;case 12:case 13:a=e[d++],l+=String.fromCharCode((31&s)<<6|63&a);break;case 14:a=e[d++],n=e[d++],l+=String.fromCharCode((15&s)<<12|(63&a)<<6|63&n)}}return l}var ve={hexDump:function(e){for(var t="",i=0;i<e.length;i++){var r=e[i].toString(16);r.length<2&&(r="0"+r),t+=r}return t}},be=Math.pow(2,32)-1,_e=[].push,we={video:1,audio:2,id3:3,text:4};function Ee(e){return String.fromCharCode.apply(null,e)}function Se(e,t){var i=e[t]<<8|e[t+1];return i<0?65536+i:i}function Te(e,t){var i=Ce(e,t);return i<0?4294967296+i:i}function ke(e,t){var i=Te(e,t);return i*=Math.pow(2,32),i+=Te(e,t+4)}function Ce(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function De(e,t,i){e[t]=i>>24,e[t+1]=i>>16&255,e[t+2]=i>>8&255,e[t+3]=255&i}function Re(e){for(var t=e.byteLength,i=0;i<t;){var r=Te(e,i);if(r>8&&109===e[i+4]&&111===e[i+5]&&111===e[i+6]&&102===e[i+7])return!0;i=r>1?i+r:t}return!1}function xe(e,t){var i=[];if(!t.length)return i;for(var r=e.byteLength,s=0;s<r;){var a=Te(e,s),n=a>1?s+a:r;if(Ee(e.subarray(s+4,s+8))===t[0])if(1===t.length)i.push(e.subarray(s+8,n));else{var o=xe(e.subarray(s+8,n),t.slice(1));o.length&&_e.apply(i,o)}s=n}return i}function Le(e){var t=[],i=e[0],r=8,s=Te(e,r);r+=4;var a=0,n=0;0===i?(a=Te(e,r),n=Te(e,r+4),r+=8):(a=ke(e,r),n=ke(e,r+8),r+=16),r+=2;var o=e.length+n,l=Se(e,r);r+=2;for(var d=0;d<l;d++){var h=r,c=Te(e,h);h+=4;var u=2147483647&c;if(1==(2147483648&c)>>>31)return G.warn("SIDX has hierarchical references (not supported)"),null;var p=Te(e,h);h+=4,t.push({referenceSize:u,subsegmentDuration:p,info:{duration:p/s,start:o,end:o+u-1}}),o+=u,r=h+=4}return{earliestPresentationTime:a,timescale:s,version:i,referencesCount:l,references:t}}function Ie(e){for(var t=[],i=xe(e,["moov","trak"]),r=0;r<i.length;r++){var s=i[r],n=xe(s,["tkhd"])[0];if(n){var o=n[0],l=Te(n,0===o?12:20),d=xe(s,["mdia","mdhd"])[0];if(d){var h=Te(d,0===(o=d[0])?12:20),c=xe(s,["mdia","hdlr"])[0];if(c){var u=Ee(c.subarray(8,12)),p={soun:$.AUDIO,vide:$.VIDEO}[u];if(p){var f=Pe(xe(s,["mdia","minf","stbl","stsd"])[0]);t[l]={timescale:h,type:p},t[p]=a({timescale:h,id:l},f)}}}}}return xe(e,["moov","mvex","trex"]).forEach((function(e){var i=Te(e,4),r=t[i];r&&(r.default={duration:Te(e,12),flags:Te(e,20)})})),t}function Pe(e){var t=e.subarray(8),i=t.subarray(86),r=Ee(t.subarray(4,8)),s=r,a="enca"===r||"encv"===r;if(a){var n=xe(t,[r])[0];xe(n.subarray("enca"===r?28:78),["sinf"]).forEach((function(e){var t=xe(e,["schm"])[0];if(t){var i=Ee(t.subarray(4,8));if("cbcs"===i||"cenc"===i){var r=xe(e,["frma"])[0];r&&(s=Ee(r))}}}))}switch(s){case"avc1":case"avc2":case"avc3":case"avc4":var o=xe(i,["avcC"])[0];s+="."+Me(o[1])+Me(o[2])+Me(o[3]);break;case"mp4a":var l=xe(t,[r])[0],d=xe(l.subarray(28),["esds"])[0];if(d&&d.length>7){var h=4;if(3!==d[h++])break;h=Be(d,h),h+=2;var c=d[h++];if(128&c&&(h+=2),64&c&&(h+=d[h++]),4!==d[h++])break;h=Be(d,h);var u=d[h++];if(64!==u)break;if(s+="."+Me(u),h+=12,5!==d[h++])break;h=Be(d,h);var p=d[h++],f=(248&p)>>3;31===f&&(f+=1+((7&p)<<3)+((224&d[h])>>5)),s+="."+f}break;case"hvc1":case"hev1":var y=xe(i,["hvcC"])[0],m=y[1],g=["","A","B","C"][m>>6],A=31&m,v=Te(y,2),b=(32&m)>>5?"H":"L",_=y[12],w=y.subarray(6,12);s+="."+g+A,s+="."+v.toString(16).toUpperCase(),s+="."+b+_;for(var E="",S=w.length;S--;){var T=w[S];(T||E)&&(E="."+T.toString(16).toUpperCase()+E)}s+=E;break;case"dvh1":case"dvhe":var k=xe(i,["dvcC"])[0],C=k[2]>>1&127,D=k[2]<<5&32|k[3]>>3&31;s+="."+Ue(C)+"."+Ue(D);break;case"vp09":var R=xe(i,["vpcC"])[0],x=R[4],L=R[5],I=R[6]>>4&15;s+="."+Ue(x)+"."+Ue(L)+"."+Ue(I);break;case"av01":var P=xe(i,["av1C"])[0],B=P[1]>>>5,M=31&P[1],U=P[2]>>>7?"H":"M",F=(64&P[2])>>6,O=(32&P[2])>>5,N=2===B&&F?O?12:10:F?10:8,G=(16&P[2])>>4,z=(8&P[2])>>3,W=(4&P[2])>>2,V=3&P[2],H=1,$=1,j=1,K=0;s+="."+B+"."+Ue(M)+U+"."+Ue(N)+"."+G+"."+z+W+V+"."+Ue(H)+"."+Ue($)+"."+Ue(j)+"."+K}return{codec:s,encrypted:a}}function Be(e,t){for(var i=t+5;128&e[t++]&&t<i;);return t}function Me(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function Ue(e){return(e<10?"0":"")+e}function Fe(e,t){if(!e||!t)return e;var i=t.keyId;return i&&t.isCommonEncryption&&xe(e,["moov","trak"]).forEach((function(e){var t=xe(e,["mdia","minf","stbl","stsd"])[0].subarray(8),r=xe(t,["enca"]),s=r.length>0;s||(r=xe(t,["encv"])),r.forEach((function(e){xe(s?e.subarray(28):e.subarray(78),["sinf"]).forEach((function(e){var t=Oe(e);if(t){var r=t.subarray(8,24);r.some((function(e){return 0!==e}))||(G.log("[eme] Patching keyId in 'enc"+(s?"a":"v")+">sinf>>tenc' box: "+ve.hexDump(r)+" -> "+ve.hexDump(i)),t.set(i,8))}}))}))})),e}function Oe(e){var t=xe(e,["schm"])[0];if(t){var i=Ee(t.subarray(4,8));if("cbcs"===i||"cenc"===i)return xe(e,["schi","tenc"])[0]}return G.error("[eme] missing 'schm' box"),null}function Ne(e,t){return xe(t,["moof","traf"]).reduce((function(t,i){var r=xe(i,["tfdt"])[0],s=r[0],a=xe(i,["tfhd"]).reduce((function(t,i){var a=Te(i,4),n=e[a];if(n){var o=Te(r,4);if(1===s){if(o===be)return G.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),t;o*=be+1,o+=Te(r,8)}var l=o/(n.timescale||9e4);if(E(l)&&(null===t||l<t))return l}return t}),null);return null!==a&&E(a)&&(null===t||a<t)?a:t}),null)}function Ge(e,t){for(var i=0,r=0,s=0,a=xe(e,["moof","traf"]),n=0;n<a.length;n++){var o=a[n],l=xe(o,["tfhd"])[0],d=t[Te(l,4)];if(d){var h=d.default,c=Te(l,0)|(null==h?void 0:h.flags),u=null==h?void 0:h.duration;8&c&&(u=Te(l,2&c?12:8));for(var p=d.timescale||9e4,f=xe(o,["trun"]),y=0;y<f.length;y++)!(i=ze(f[y]))&&u&&(i=u*Te(f[y],4)),d.type===$.VIDEO?r+=i/p:d.type===$.AUDIO&&(s+=i/p)}}if(0===r&&0===s){for(var m=1/0,g=0,A=0,v=xe(e,["sidx"]),b=0;b<v.length;b++){var _=Le(v[b]);if(null!=_&&_.references){m=Math.min(m,_.earliestPresentationTime/_.timescale);var w=_.references.reduce((function(e,t){return e+t.info.duration||0}),0);A=(g=Math.max(g,w+_.earliestPresentationTime/_.timescale))-m}}if(A&&E(A))return A}return r||s}function ze(e){var t=Te(e,0),i=8;1&t&&(i+=4),4&t&&(i+=4);for(var r=0,s=Te(e,4),a=0;a<s;a++)256&t&&(r+=Te(e,i),i+=4),512&t&&(i+=4),1024&t&&(i+=4),2048&t&&(i+=4);return r}function We(e,t,i){xe(t,["moof","traf"]).forEach((function(t){xe(t,["tfhd"]).forEach((function(r){var s=Te(r,4),a=e[s];if(a){var n=a.timescale||9e4;xe(t,["tfdt"]).forEach((function(e){var t=e[0],r=i*n;if(r){var s=Te(e,4);if(0===t)s-=r,De(e,4,s=Math.max(s,0));else{s*=Math.pow(2,32),s+=Te(e,8),s-=r,s=Math.max(s,0);var a=Math.floor(s/(be+1)),o=Math.floor(s%(be+1));De(e,4,a),De(e,8,o)}}}))}}))}))}function Ve(e){var t={valid:null,remainder:null},i=xe(e,["moof"]);if(i.length<2)return t.remainder=e,t;var r=i[i.length-1];return t.valid=ge(e,0,r.byteOffset-8),t.remainder=ge(e,r.byteOffset-8),t}function He(e,t){var i=new Uint8Array(e.length+t.length);return i.set(e),i.set(t,e.length),i}function $e(e,t){var i=[],r=t.samples,s=t.timescale,a=t.id,n=!1;return xe(r,["moof"]).map((function(o){var l=o.byteOffset-8;xe(o,["traf"]).map((function(o){var d=xe(o,["tfdt"]).map((function(e){var t=e[0],i=Te(e,4);return 1===t&&(i*=Math.pow(2,32),i+=Te(e,8)),i/s}))[0];return void 0!==d&&(e=d),xe(o,["tfhd"]).map((function(d){var h=Te(d,4),c=16777215&Te(d,0),u=0,p=!!(16&c),f=0,y=!!(32&c),m=8;h===a&&(!!(1&c)&&(m+=8),!!(2&c)&&(m+=4),!!(8&c)&&(u=Te(d,m),m+=4),p&&(f=Te(d,m),m+=4),y&&(m+=4),"video"===t.type&&(n=je(t.codec)),xe(o,["trun"]).map((function(a){var o=a[0],d=16777215&Te(a,0),h=!!(1&d),c=0,p=!!(4&d),y=!!(256&d),m=0,g=!!(512&d),A=0,v=!!(1024&d),b=!!(2048&d),_=0,w=Te(a,4),E=8;h&&(c=Te(a,E),E+=4),p&&(E+=4);for(var S=c+l,T=0;T<w;T++){if(y?(m=Te(a,E),E+=4):m=u,g?(A=Te(a,E),E+=4):A=f,v&&(E+=4),b&&(_=0===o?Te(a,E):Ce(a,E),E+=4),t.type===$.VIDEO)for(var k=0;k<A;){var C=Te(r,S);Ke(n,r[S+=4])&&qe(r.subarray(S,S+C),n?2:1,e+_/s,i),S+=C,k+=C+4}e+=m/s}})))}))}))})),i}function je(e){if(!e)return!1;var t=e.indexOf("."),i=t<0?e:e.substring(0,t);return"hvc1"===i||"hev1"===i||"dvh1"===i||"dvhe"===i}function Ke(e,t){if(e){var i=t>>1&63;return 39===i||40===i}return 6==(31&t)}function qe(e,t,i,r){var s=Ye(e),a=0;a+=t;for(var n=0,o=0,l=0;a<s.length;){n=0;do{if(a>=s.length)break;n+=l=s[a++]}while(255===l);o=0;do{if(a>=s.length)break;o+=l=s[a++]}while(255===l);var d=s.length-a,h=a;if(o<d)a+=o;else if(o>d){G.error("Malformed SEI payload. "+o+" is too small, only "+d+" bytes left to parse.");break}if(4===n){if(181===s[h++]){var c=Se(s,h);if(h+=2,49===c){var u=Te(s,h);if(h+=4,1195456820===u){var p=s[h++];if(3===p){var f=s[h++],y=64&f,m=y?2+3*(31&f):0,g=new Uint8Array(m);if(y){g[0]=f;for(var A=1;A<m;A++)g[A]=s[h++]}r.push({type:p,payloadType:n,pts:i,bytes:g})}}}}}else if(5===n&&o>16){for(var v=[],b=0;b<16;b++){var _=s[h++].toString(16);v.push(1==_.length?"0"+_:_),3!==b&&5!==b&&7!==b&&9!==b||v.push("-")}for(var w=o-16,E=new Uint8Array(w),S=0;S<w;S++)E[S]=s[h++];r.push({payloadType:n,pts:i,uuid:v.join(""),userData:Ae(E),userDataBytes:E})}}}function Ye(e){for(var t=e.byteLength,i=[],r=1;r<t-2;)0===e[r]&&0===e[r+1]&&3===e[r+2]?(i.push(r+2),r+=2):r++;if(0===i.length)return e;var s=t-i.length,a=new Uint8Array(s),n=0;for(r=0;r<s;n++,r++)n===i[0]&&(n++,i.shift()),a[r]=e[n];return a}function Qe(e){var t=e[0],i="",r="",s=0,a=0,n=0,o=0,l=0,d=0;if(0===t){for(;"\0"!==Ee(e.subarray(d,d+1));)i+=Ee(e.subarray(d,d+1)),d+=1;for(i+=Ee(e.subarray(d,d+1)),d+=1;"\0"!==Ee(e.subarray(d,d+1));)r+=Ee(e.subarray(d,d+1)),d+=1;r+=Ee(e.subarray(d,d+1)),d+=1,s=Te(e,12),a=Te(e,16),o=Te(e,20),l=Te(e,24),d=28}else if(1===t){s=Te(e,d+=4);var h=Te(e,d+=4),c=Te(e,d+=4);for(d+=4,n=Math.pow(2,32)*h+c,S(n)||(n=Number.MAX_SAFE_INTEGER,G.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=Te(e,d),l=Te(e,d+=4),d+=4;"\0"!==Ee(e.subarray(d,d+1));)i+=Ee(e.subarray(d,d+1)),d+=1;for(i+=Ee(e.subarray(d,d+1)),d+=1;"\0"!==Ee(e.subarray(d,d+1));)r+=Ee(e.subarray(d,d+1)),d+=1;r+=Ee(e.subarray(d,d+1)),d+=1}return{schemeIdUri:i,value:r,timeScale:s,presentationTime:n,presentationTimeDelta:a,eventDuration:o,id:l,payload:e.subarray(d,e.byteLength)}}function Xe(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];for(var s=i.length,a=8,n=s;n--;)a+=i[n].byteLength;var o=new Uint8Array(a);for(o[0]=a>>24&255,o[1]=a>>16&255,o[2]=a>>8&255,o[3]=255&a,o.set(e,4),n=0,a=8;n<s;n++)o.set(i[n],a),a+=i[n].byteLength;return o}function Je(e,t,i){if(16!==e.byteLength)throw new RangeError("Invalid system id");var r,s,a;if(t){r=1,s=new Uint8Array(16*t.length);for(var n=0;n<t.length;n++){var o=t[n];if(16!==o.byteLength)throw new RangeError("Invalid key");s.set(o,16*n)}}else r=0,s=new Uint8Array;r>0?(a=new Uint8Array(4),t.length>0&&new DataView(a.buffer).setUint32(0,t.length,!1)):a=new Uint8Array;var l=new Uint8Array(4);return i&&i.byteLength>0&&new DataView(l.buffer).setUint32(0,i.byteLength,!1),Xe([112,115,115,104],new Uint8Array([r,0,0,0]),e,a,s,l,i||new Uint8Array)}function Ze(e){if(!(e instanceof ArrayBuffer)||e.byteLength<32)return null;var t={version:0,systemId:"",kids:null,data:null},i=new DataView(e),r=i.getUint32(0);if(e.byteLength!==r&&r>44)return null;if(1886614376!==i.getUint32(4))return null;if(t.version=i.getUint32(8)>>>24,t.version>1)return null;t.systemId=ve.hexDump(new Uint8Array(e,12,16));var s=i.getUint32(28);if(0===t.version){if(r-32<s)return null;t.data=new Uint8Array(e,32,s)}else if(1===t.version){t.kids=[];for(var a=0;a<s;a++)t.kids.push(new Uint8Array(e,32+16*a,16))}return t}var et={},tt=function(){function e(e,t,i,r,s){void 0===r&&(r=[1]),void 0===s&&(s=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=i,this.keyFormatVersions=r,this.iv=s,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&!re(e)}e.clearKeyUriToKeyIdMap=function(){et={}};var t=e.prototype;return t.isSupported=function(){if(this.method){if(re(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case oe.FAIRPLAY:case oe.WIDEVINE:case oe.PLAYREADY:case oe.CLEARKEY:return-1!==["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1},t.getDecryptData=function(t){if(!this.encrypted||!this.uri)return null;if(re(this.method)&&this.uri&&!this.iv){"number"!=typeof t&&(G.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),t=0);var i=it(t);return new e(this.method,this.uri,"identity",this.keyFormatVersions,i)}var r=te(this.uri);if(r)switch(this.keyFormat){case oe.WIDEVINE:this.pssh=r,r.length>=22&&(this.keyId=r.subarray(r.length-22,r.length-6));break;case oe.PLAYREADY:var s=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Je(s,null,r);var a=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2),n=String.fromCharCode.apply(null,Array.from(a)),o=n.substring(n.indexOf("<"),n.length),l=(new DOMParser).parseFromString(o,"text/xml").getElementsByTagName("KID")[0];if(l){var d=l.childNodes[0]?l.childNodes[0].nodeValue:l.getAttribute("VALUE");if(d){var h=X(d).subarray(0,16);ee(h),this.keyId=h}}break;default:var c=r.subarray(0,16);if(16!==c.length){var u=new Uint8Array(16);u.set(c,16-c.length),c=u}this.keyId=c}if(!this.keyId||16!==this.keyId.byteLength){var p=et[this.uri];if(!p){var f=Object.keys(et).length%Number.MAX_SAFE_INTEGER;p=new Uint8Array(16),new DataView(p.buffer,12,4).setUint32(0,f),et[this.uri]=p}this.keyId=p}return this},e}();function it(e){for(var t=new Uint8Array(16),i=12;i<16;i++)t[i]=e>>8*(15-i)&255;return t}var rt=/\{\$([a-zA-Z0-9-_]+)\}/g;function st(e){return rt.test(e)}function at(e,t,i){if(null!==e.variableList||e.hasVariableRefs)for(var r=i.length;r--;){var s=i[r],a=t[s];a&&(t[s]=nt(e,a))}}function nt(e,t){if(null!==e.variableList||e.hasVariableRefs){var i=e.variableList;return t.replace(rt,(function(t){var r=t.substring(2,t.length-1),s=null==i?void 0:i[r];return void 0===s?(e.playlistParsingError||(e.playlistParsingError=new Error('Missing preceding EXT-X-DEFINE tag for Variable Reference: "'+r+'"')),t):s}))}return t}function ot(e,t,i){var r,s,a=e.variableList;if(a||(e.variableList=a={}),"QUERYPARAM"in t){r=t.QUERYPARAM;try{var n=new self.URL(i).searchParams;if(!n.has(r))throw new Error('"'+r+'" does not match any query parameter in URI: "'+i+'"');s=n.get(r)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: "+t.message))}}else r=t.NAME,s=t.VALUE;r in a?e.playlistParsingError||(e.playlistParsingError=new Error('EXT-X-DEFINE duplicate Variable Name declarations: "'+r+'"')):a[r]=s||""}function lt(e,t,i){var r=t.IMPORT;if(i&&r in i){var s=e.variableList;s||(e.variableList=s={}),s[r]=i[r]}else e.playlistParsingError||(e.playlistParsingError=new Error('EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "'+r+'"'))}function dt(e){if(void 0===e&&(e=!0),"undefined"!=typeof self)return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}var ht={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function ct(e,t){var i=ht[t];return!!i&&!!i[e.slice(0,4)]}function ut(e,t,i){return void 0===i&&(i=!0),!e.split(",").some((function(e){return!pt(e,t,i)}))}function pt(e,t,i){var r;void 0===i&&(i=!0);var s=dt(i);return null!=(r=null==s?void 0:s.isTypeSupported(ft(e,t)))&&r}function ft(e,t){return t+'/mp4;codecs="'+e+'"'}function yt(e){if(e){var t=e.substring(0,4);return ht.video[t]}return 2}function mt(e){return e.split(",").reduce((function(e,t){var i=ht.video[t];return i?(2*i+e)/(e?3:2):(ht.audio[t]+e)/(e?2:1)}),0)}var gt={};function At(e,t){if(void 0===t&&(t=!0),gt[e])return gt[e];for(var i={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[e],r=0;r<i.length;r++){var s;if(pt(i[r],"audio",t))return gt[e]=i[r],i[r];if("mp3"===i[r]&&null!=(s=dt(t))&&s.isTypeSupported("audio/mpeg"))return""}return e}var vt=/flac|opus|mp4a\.40\.34/i;function bt(e,t){return void 0===t&&(t=!0),e.replace(vt,(function(e){return At(e.toLowerCase(),t)}))}function _t(e,t){return e&&"mp4a"!==e?e:t}function wt(e){var t=e.split(".");if(t.length>2){var i=t.shift()+".";return i+=parseInt(t.shift()).toString(16),i+=("000"+parseInt(t.shift()).toString(16)).slice(-4)}return e}function Et(e){var t=dt(e)||{isTypeSupported:function(){return!1}};return{mpeg:t.isTypeSupported("audio/mpeg"),mp3:t.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:t.isTypeSupported('audio/mp4; codecs="ac-3"')}}var St=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,Tt=/#EXT-X-MEDIA:(.*)/g,kt=/^#EXT(?:INF|-X-TARGETDURATION):/m,Ct=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Dt=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),Rt=function(){function e(){}return e.findGroup=function(e,t){for(var i=0;i<e.length;i++){var r=e[i];if(r.id===t)return r}},e.resolve=function(e,t){return w.buildAbsoluteURL(t,e,{alwaysNormalize:!0})},e.isMediaPlaylist=function(e){return kt.test(e)},e.parseMasterPlaylist=function(t,i){var r,s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:st(t)},a=[];for(St.lastIndex=0;null!=(r=St.exec(t));)if(r[1]){var n,o=new L(r[1]);at(s,o,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);var l=nt(s,r[2]),d={attrs:o,bitrate:o.decimalInteger("BANDWIDTH")||o.decimalInteger("AVERAGE-BANDWIDTH"),name:o.NAME,url:e.resolve(l,i)},h=o.decimalResolution("RESOLUTION");h&&(d.width=h.width,d.height=h.height),It(o.CODECS,d),null!=(n=d.unknownCodecs)&&n.length||a.push(d),s.levels.push(d)}else if(r[3]){var c=r[3],u=r[4];switch(c){case"SESSION-DATA":var p=new L(u);at(s,p,["DATA-ID","LANGUAGE","VALUE","URI"]);var f=p["DATA-ID"];f&&(null===s.sessionData&&(s.sessionData={}),s.sessionData[f]=p);break;case"SESSION-KEY":var y=xt(u,i,s);y.encrypted&&y.isSupported()?(null===s.sessionKeys&&(s.sessionKeys=[]),s.sessionKeys.push(y)):G.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+u+'"');break;case"DEFINE":var m=new L(u);at(s,m,["NAME","VALUE","QUERYPARAM"]),ot(s,m,i);break;case"CONTENT-STEERING":var g=new L(u);at(s,g,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:e.resolve(g["SERVER-URI"],i),pathwayId:g["PATHWAY-ID"]||"."};break;case"START":s.startTimeOffset=Lt(u)}}var A=a.length>0&&a.length<s.levels.length;return s.levels=A?a:s.levels,0===s.levels.length&&(s.playlistParsingError=new Error("no levels found in manifest")),s},e.parseMasterPlaylistMedia=function(t,i,r){var s,a={},n=r.levels,o={AUDIO:n.map((function(e){return{id:e.attrs.AUDIO,audioCodec:e.audioCodec}})),SUBTITLES:n.map((function(e){return{id:e.attrs.SUBTITLES,textCodec:e.textCodec}})),"CLOSED-CAPTIONS":[]},l=0;for(Tt.lastIndex=0;null!==(s=Tt.exec(t));){var d=new L(s[1]),h=d.TYPE;if(h){var c=o[h],u=a[h]||[];a[h]=u,at(r,d,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);var p=d.LANGUAGE,f=d["ASSOC-LANGUAGE"],y=d.CHANNELS,m=d.CHARACTERISTICS,g=d["INSTREAM-ID"],A={attrs:d,bitrate:0,id:l++,groupId:d["GROUP-ID"]||"",name:d.NAME||p||"",type:h,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:p,url:d.URI?e.resolve(d.URI,i):""};if(f&&(A.assocLang=f),y&&(A.channels=y),m&&(A.characteristics=m),g&&(A.instreamId=g),null!=c&&c.length){var v=e.findGroup(c,A.groupId)||c[0];Pt(A,v,"audioCodec"),Pt(A,v,"textCodec")}u.push(A)}}return a},e.parseLevelPlaylist=function(e,t,i,r,s,a){var n,o,l,d=new Q(t),h=d.fragments,u=null,p=0,f=0,y=0,m=0,g=null,A=new K(r,t),v=-1,b=!1,_=null;for(Ct.lastIndex=0,d.m3u8=e,d.hasVariableRefs=st(e);null!==(n=Ct.exec(e));){b&&(b=!1,(A=new K(r,t)).start=y,A.sn=p,A.cc=m,A.level=i,u&&(A.initSegment=u,A.rawProgramDateTime=u.rawProgramDateTime,u.rawProgramDateTime=null,_&&(A.setByteRange(_),_=null)));var w=n[1];if(w){A.duration=parseFloat(w);var S=(" "+n[2]).slice(1);A.title=S||null,A.tagList.push(S?["INF",w,S]:["INF",w])}else if(n[3]){if(E(A.duration)){A.start=y,l&&Ft(A,l,d),A.sn=p,A.level=i,A.cc=m,h.push(A);var T=(" "+n[3]).slice(1);A.relurl=nt(d,T),Mt(A,g),g=A,y+=A.duration,p++,f=0,b=!0}}else if(n[4]){var k=(" "+n[4]).slice(1);g?A.setByteRange(k,g):A.setByteRange(k)}else if(n[5])A.rawProgramDateTime=(" "+n[5]).slice(1),A.tagList.push(["PROGRAM-DATE-TIME",A.rawProgramDateTime]),-1===v&&(v=h.length);else{if(!(n=n[0].match(Dt))){G.warn("No matches on slow regex match for level playlist!");continue}for(o=1;o<n.length&&void 0===n[o];o++);var C=(" "+n[o]).slice(1),D=(" "+n[o+1]).slice(1),R=n[o+2]?(" "+n[o+2]).slice(1):"";switch(C){case"PLAYLIST-TYPE":d.type=D.toUpperCase();break;case"MEDIA-SEQUENCE":p=d.startSN=parseInt(D);break;case"SKIP":var x=new L(D);at(d,x,["RECENTLY-REMOVED-DATERANGES"]);var I=x.decimalInteger("SKIPPED-SEGMENTS");if(E(I)){d.skippedSegments=I;for(var P=I;P--;)h.unshift(null);p+=I}var B=x.enumeratedString("RECENTLY-REMOVED-DATERANGES");B&&(d.recentlyRemovedDateranges=B.split("\t"));break;case"TARGETDURATION":d.targetduration=Math.max(parseInt(D),1);break;case"VERSION":d.version=parseInt(D);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":d.live=!1;break;case"#":(D||R)&&A.tagList.push(R?[D,R]:[D]);break;case"DISCONTINUITY":m++,A.tagList.push(["DIS"]);break;case"GAP":A.gap=!0,A.tagList.push([C]);break;case"BITRATE":A.tagList.push([C,D]);break;case"DATERANGE":var M=new L(D);at(d,M,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),at(d,M,M.clientAttrs);var U=new V(M,d.dateRanges[M.ID]);U.isValid||d.skippedSegments?d.dateRanges[U.id]=U:G.warn('Ignoring invalid DATERANGE tag: "'+D+'"'),A.tagList.push(["EXT-X-DATERANGE",D]);break;case"DEFINE":var F=new L(D);at(d,F,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in F?lt(d,F,a):ot(d,F,t);break;case"DISCONTINUITY-SEQUENCE":m=parseInt(D);break;case"KEY":var O=xt(D,t,d);if(O.isSupported()){if("NONE"===O.method){l=void 0;break}l||(l={}),l[O.keyFormat]&&(l=c({},l)),l[O.keyFormat]=O}else G.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+D+'"');break;case"START":d.startTimeOffset=Lt(D);break;case"MAP":var N=new L(D);if(at(d,N,["BYTERANGE","URI"]),A.duration){var z=new K(r,t);Ut(z,N,i,l),u=z,A.initSegment=u,u.rawProgramDateTime&&!A.rawProgramDateTime&&(A.rawProgramDateTime=u.rawProgramDateTime)}else{var W=A.byteRangeEndOffset;if(W){var H=A.byteRangeStartOffset;_=W-H+"@"+H}else _=null;Ut(A,N,i,l),u=A,b=!0}break;case"SERVER-CONTROL":var $=new L(D);d.canBlockReload=$.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=$.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&$.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=$.optionalFloat("PART-HOLD-BACK",0),d.holdBack=$.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var j=new L(D);d.partTarget=j.decimalFloatingPoint("PART-TARGET");break;case"PART":var Y=d.partList;Y||(Y=d.partList=[]);var X=f>0?Y[Y.length-1]:void 0,J=f++,Z=new L(D);at(d,Z,["BYTERANGE","URI"]);var ee=new q(Z,A,t,J,X);Y.push(ee),A.duration+=ee.duration;break;case"PRELOAD-HINT":var te=new L(D);at(d,te,["URI"]),d.preloadHint=te;break;case"RENDITION-REPORT":var ie=new L(D);at(d,ie,["URI"]),d.renditionReports=d.renditionReports||[],d.renditionReports.push(ie);break;default:G.warn("line parsed but not handled: "+n)}}}g&&!g.relurl?(h.pop(),y-=g.duration,d.partList&&(d.fragmentHint=g)):d.partList&&(Mt(A,g),A.cc=m,d.fragmentHint=A,l&&Ft(A,l,d));var re=h.length,se=h[0],ae=h[re-1];if((y+=d.skippedSegments*d.targetduration)>0&&re&&ae){d.averagetargetduration=y/re;var ne=ae.sn;d.endSN="initSegment"!==ne?ne:0,d.live||(ae.endList=!0),se&&(d.startCC=se.cc)}else d.endSN=0,d.startCC=0;return d.fragmentHint&&(y+=d.fragmentHint.duration),d.totalduration=y,d.endCC=m,v>0&&Bt(h,v),d},e}();function xt(e,t,i){var r,s,a=new L(e);at(i,a,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);var n=null!=(r=a.METHOD)?r:"",o=a.URI,l=a.hexadecimalInteger("IV"),d=a.KEYFORMATVERSIONS,h=null!=(s=a.KEYFORMAT)?s:"identity";o&&a.IV&&!l&&G.error("Invalid IV: "+a.IV);var c=o?Rt.resolve(o,t):"",u=(d||"1").split("/").map(Number).filter(Number.isFinite);return new tt(n,c,h,u,l)}function Lt(e){var t=new L(e).decimalFloatingPoint("TIME-OFFSET");return E(t)?t:null}function It(e,t){var i=(e||"").split(/[ ,]+/).filter((function(e){return e}));["video","audio","text"].forEach((function(e){var r=i.filter((function(t){return ct(t,e)}));r.length&&(t[e+"Codec"]=r.join(","),i=i.filter((function(e){return-1===r.indexOf(e)})))})),t.unknownCodecs=i}function Pt(e,t,i){var r=t[i];r&&(e[i]=r)}function Bt(e,t){for(var i=e[t],r=t;r--;){var s=e[r];if(!s)return;s.programDateTime=i.programDateTime-1e3*s.duration,i=s}}function Mt(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),E(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}function Ut(e,t,i,r){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=i,e.sn="initSegment",r&&(e.levelkeys=r),e.initSegment=null}function Ft(e,t,i){e.levelkeys=t;var r=i.encryptedFragments;r.length&&r[r.length-1].levelkeys===t||!Object.keys(t).some((function(e){return t[e].isCommonEncryption}))||r.push(e)}var Ot={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},Nt={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function Gt(e){switch(e.type){case Ot.AUDIO_TRACK:return Nt.AUDIO;case Ot.SUBTITLE_TRACK:return Nt.SUBTITLE;default:return Nt.MAIN}}function zt(e,t){var i=e.url;return void 0!==i&&0!==i.indexOf("data:")||(i=t.url),i}var Wt=function(){function e(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}var t=e.prototype;return t.startLoad=function(e){},t.stopLoad=function(){this.destroyInternalLoaders()},t.registerListeners=function(){var e=this.hls;e.on(k.MANIFEST_LOADING,this.onManifestLoading,this),e.on(k.LEVEL_LOADING,this.onLevelLoading,this),e.on(k.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(k.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.unregisterListeners=function(){var e=this.hls;e.off(k.MANIFEST_LOADING,this.onManifestLoading,this),e.off(k.LEVEL_LOADING,this.onLevelLoading,this),e.off(k.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(k.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.createInternalLoader=function(e){var t=this.hls.config,i=t.pLoader,r=t.loader,s=new(i||r)(t);return this.loaders[e.type]=s,s},t.getInternalLoader=function(e){return this.loaders[e.type]},t.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},t.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},t.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},t.onManifestLoading=function(e,t){var i=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Ot.MANIFEST,url:i,deliveryDirectives:null})},t.onLevelLoading=function(e,t){var i=t.id,r=t.level,s=t.pathwayId,a=t.url,n=t.deliveryDirectives;this.load({id:i,level:r,pathwayId:s,responseType:"text",type:Ot.LEVEL,url:a,deliveryDirectives:n})},t.onAudioTrackLoading=function(e,t){var i=t.id,r=t.groupId,s=t.url,a=t.deliveryDirectives;this.load({id:i,groupId:r,level:null,responseType:"text",type:Ot.AUDIO_TRACK,url:s,deliveryDirectives:a})},t.onSubtitleTrackLoading=function(e,t){var i=t.id,r=t.groupId,s=t.url,a=t.deliveryDirectives;this.load({id:i,groupId:r,level:null,responseType:"text",type:Ot.SUBTITLE_TRACK,url:s,deliveryDirectives:a})},t.load=function(e){var t,i,r,s=this,a=this.hls.config,n=this.getInternalLoader(e);if(n){var o=n.context;if(o&&o.url===e.url&&o.level===e.level)return void this.hls.logger.trace("[playlist-loader]: playlist request ongoing");this.hls.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),n.abort()}if(i=e.type===Ot.MANIFEST?a.manifestLoadPolicy.default:c({},a.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),n=this.createInternalLoader(e),E(null==(t=e.deliveryDirectives)?void 0:t.part)&&(e.type===Ot.LEVEL&&null!==e.level?r=this.hls.levels[e.level].details:e.type===Ot.AUDIO_TRACK&&null!==e.id?r=this.hls.audioTracks[e.id].details:e.type===Ot.SUBTITLE_TRACK&&null!==e.id&&(r=this.hls.subtitleTracks[e.id].details),r)){var l=r.partTarget,d=r.targetduration;if(l&&d){var h=1e3*Math.max(3*l,.8*d);i=c({},i,{maxTimeToFirstByteMs:Math.min(h,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,i.maxTimeToFirstByteMs)})}}var u=i.errorRetry||i.timeoutRetry||{},p={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:u.maxNumRetry||0,retryDelay:u.retryDelayMs||0,maxRetryDelay:u.maxRetryDelayMs||0},f={onSuccess:function(e,t,i,r){var a=s.getInternalLoader(i);s.resetInternalLoader(i.type);var n=e.data;0===n.indexOf("#EXTM3U")?(t.parsing.start=performance.now(),Rt.isMediaPlaylist(n)?s.handleTrackOrLevelPlaylist(e,t,i,r||null,a):s.handleMasterPlaylist(e,t,i,r)):s.handleManifestParsingError(e,i,new Error("no EXTM3U delimiter"),r||null,t)},onError:function(e,t,i,r){s.handleNetworkError(t,i,!1,e,r)},onTimeout:function(e,t,i){s.handleNetworkError(t,i,!0,void 0,e)}};n.load(e,p,f)},t.handleMasterPlaylist=function(e,t,i,r){var s=this.hls,a=e.data,n=zt(e,i),o=Rt.parseMasterPlaylist(a,n);if(o.playlistParsingError)this.handleManifestParsingError(e,i,o.playlistParsingError,r,t);else{var l=o.contentSteering,d=o.levels,h=o.sessionData,c=o.sessionKeys,u=o.startTimeOffset,p=o.variableList;this.variableList=p;var f=Rt.parseMasterPlaylistMedia(a,n,o),y=f.AUDIO,m=void 0===y?[]:y,g=f.SUBTITLES,A=f["CLOSED-CAPTIONS"];m.length&&(m.some((function(e){return!e.url}))||!d[0].audioCodec||d[0].attrs.AUDIO||(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),m.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new L({}),bitrate:0,url:""}))),s.trigger(k.MANIFEST_LOADED,{levels:d,audioTracks:m,subtitles:g,captions:A,contentSteering:l,url:n,stats:t,networkDetails:r,sessionData:h,sessionKeys:c,startTimeOffset:u,variableList:p})}},t.handleTrackOrLevelPlaylist=function(e,t,i,r,s){var a=this.hls,n=i.id,o=i.level,l=i.type,d=zt(e,i),h=0,c=E(o)?o:E(n)?n:0,u=Gt(i),p=Rt.parseLevelPlaylist(e.data,d,c,u,h,this.variableList);if(l===Ot.MANIFEST){var f={attrs:new L({}),bitrate:0,details:p,name:"",url:d};a.trigger(k.MANIFEST_LOADED,{levels:[f],audioTracks:[],url:d,stats:t,networkDetails:r,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),i.levelDetails=p,this.handlePlaylistLoaded(p,e,t,i,r,s)},t.handleManifestParsingError=function(e,t,i,r,s){this.hls.trigger(k.ERROR,{type:C.NETWORK_ERROR,details:D.MANIFEST_PARSING_ERROR,fatal:t.type===Ot.MANIFEST,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:r,stats:s})},t.handleNetworkError=function(e,t,i,r,s){void 0===i&&(i=!1);var n="A network "+(i?"timeout":"error"+(r?" (status "+r.code+")":""))+" occurred while loading "+e.type;e.type===Ot.LEVEL?n+=": "+e.level+" id: "+e.id:e.type!==Ot.AUDIO_TRACK&&e.type!==Ot.SUBTITLE_TRACK||(n+=" id: "+e.id+' group-id: "'+e.groupId+'"');var o=new Error(n);this.hls.logger.warn("[playlist-loader]: "+n);var l=D.UNKNOWN,d=!1,h=this.getInternalLoader(e);switch(e.type){case Ot.MANIFEST:l=i?D.MANIFEST_LOAD_TIMEOUT:D.MANIFEST_LOAD_ERROR,d=!0;break;case Ot.LEVEL:l=i?D.LEVEL_LOAD_TIMEOUT:D.LEVEL_LOAD_ERROR,d=!1;break;case Ot.AUDIO_TRACK:l=i?D.AUDIO_TRACK_LOAD_TIMEOUT:D.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case Ot.SUBTITLE_TRACK:l=i?D.SUBTITLE_TRACK_LOAD_TIMEOUT:D.SUBTITLE_LOAD_ERROR,d=!1}h&&this.resetInternalLoader(e.type);var c={type:C.NETWORK_ERROR,details:l,fatal:d,url:e.url,loader:h,context:e,error:o,networkDetails:t,stats:s};if(r){var u=(null==t?void 0:t.url)||e.url;c.response=a({url:u,data:void 0},r)}this.hls.trigger(k.ERROR,c)},t.handlePlaylistLoaded=function(e,t,i,r,s,a){var n=this.hls,o=r.type,l=r.level,d=r.id,h=r.groupId,c=r.deliveryDirectives,u=zt(t,r),p=Gt(r),f="number"==typeof r.level&&p===Nt.MAIN?l:void 0;if(e.fragments.length){e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var y=e.playlistParsingError;if(y)n.trigger(k.ERROR,{type:C.NETWORK_ERROR,details:D.LEVEL_PARSING_ERROR,fatal:!1,url:u,error:y,reason:y.message,response:t,context:r,level:f,parent:p,networkDetails:s,stats:i});else switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),a.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),o){case Ot.MANIFEST:case Ot.LEVEL:n.trigger(k.LEVEL_LOADED,{details:e,level:f||0,id:d||0,stats:i,networkDetails:s,deliveryDirectives:c});break;case Ot.AUDIO_TRACK:n.trigger(k.AUDIO_TRACK_LOADED,{details:e,id:d||0,groupId:h||"",stats:i,networkDetails:s,deliveryDirectives:c});break;case Ot.SUBTITLE_TRACK:n.trigger(k.SUBTITLE_TRACK_LOADED,{details:e,id:d||0,groupId:h||"",stats:i,networkDetails:s,deliveryDirectives:c})}}else{var m=new Error("No Segments found in Playlist");n.trigger(k.ERROR,{type:C.NETWORK_ERROR,details:D.LEVEL_EMPTY_ERROR,fatal:!1,url:u,error:m,reason:m.message,response:t,context:r,level:f,parent:p,networkDetails:s,stats:i})}},e}();function Vt(e,t){var i;try{i=new Event("addtrack")}catch(e){(i=document.createEvent("Event")).initEvent("addtrack",!1,!1)}i.track=e,t.dispatchEvent(i)}function Ht(e,t){var i=e.mode;if("disabled"===i&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error("addCue is failed for: "+t)}catch(i){G.debug("[texttrack-utils]: "+i);try{var r=new self.TextTrackCue(t.startTime,t.endTime,t.text);r.id=t.id,e.addCue(r)}catch(e){G.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: "+e)}}"disabled"===i&&(e.mode=i)}function $t(e){var t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues)for(var i=e.cues.length;i--;)e.removeCue(e.cues[i]);"disabled"===t&&(e.mode=t)}function jt(e,t,i,r){var s=e.mode;if("disabled"===s&&(e.mode="hidden"),e.cues&&e.cues.length>0)for(var a=qt(e.cues,t,i),n=0;n<a.length;n++)r&&!r(a[n])||e.removeCue(a[n]);"disabled"===s&&(e.mode=s)}function Kt(e,t){if(t<e[0].startTime)return 0;var i=e.length-1;if(t>e[i].endTime)return-1;for(var r=0,s=i;r<=s;){var a=Math.floor((s+r)/2);if(t<e[a].startTime)s=a-1;else{if(!(t>e[a].startTime&&r<i))return a;r=a+1}}return e[r].startTime-t<t-e[s].startTime?r:s}function qt(e,t,i){var r=[],s=Kt(e,t);if(s>-1)for(var a=s,n=e.length;a<n;a++){var o=e[a];if(o.startTime>=t&&o.endTime<=i)r.push(o);else if(o.startTime>i)return r}return r}function Yt(e){for(var t=[],i=0;i<e.length;i++){var r=e[i];"subtitles"!==r.kind&&"captions"!==r.kind||!r.label||t.push(e[i])}return t}var Qt={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};function Xt(e){if(!(e.size<2)){var t=Ae(e.data,!0),i=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:i.buffer}}}function Jt(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,i=Ae(e.data.subarray(t),!0);t+=i.length+1;var r=Ae(e.data.subarray(t));return{key:e.type,info:i,data:r}}var s=Ae(e.data.subarray(1));return{key:e.type,info:"",data:s}}}function Zt(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,i=Ae(e.data.subarray(t),!0);t+=i.length+1;var r=Ae(e.data.subarray(t));return{key:e.type,info:i,data:r}}var s=Ae(e.data);return{key:e.type,info:"",data:s}}function ei(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=1/0),ti(e,t,i,Uint8Array)}function ti(e,t,i,r){var s=ii(e),a=1;"BYTES_PER_ELEMENT"in r&&(a=r.BYTES_PER_ELEMENT);var n=ri(e)?e.byteOffset:0,o=(n+e.byteLength)/a,l=(n+t)/a,d=Math.floor(Math.max(0,Math.min(l,o)));return new r(s,d,Math.floor(Math.min(d+Math.max(i,0),o))-d)}function ii(e){return e instanceof ArrayBuffer?e:e.buffer}function ri(e){return e&&e.buffer instanceof ArrayBuffer&&void 0!==e.byteLength&&void 0!==e.byteOffset}function si(e){return e instanceof ArrayBuffer?e:0==e.byteOffset&&e.byteLength==e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}function ai(e){return btoa(String.fromCharCode.apply(String,e))}function ni(e,t){if(e<0)return-ni(-e,t);var i=Math.pow(10,t);if(Math.abs(e*i%1-.5)<Number.EPSILON){var r=Math.floor(e*i);return(r%2==0?r:r+1)/i}return Math.round(e*i)/i}function oi(e,t){var i=new URL(e),r=new URL(t);if(i.origin!==r.origin)return e;for(var s=i.pathname.split("/").slice(1),a=r.pathname.split("/").slice(1,-1);s[0]===a[0];)s.shift(),a.shift();for(;a.length;)a.shift(),s.unshift("..");return s.join("/")}function li(){try{return crypto.randomUUID()}catch(r){try{var e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch(e){var i=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=(i+16*Math.random())%16|0;return i=Math.floor(i/16),("x"==e?t:3&t|8).toString(16)}))}}}function di(e){var t={key:e.type,description:"",data:"",mimeType:null,pictureType:null},i=3;if(!(e.size<2))if(e.data[0]===i){var r=e.data.subarray(1).indexOf(0);if(-1!==r){var s=Ae(ei(e.data,1,r)),a=e.data[2+r],n=e.data.subarray(3+r).indexOf(0);if(-1!==n){var o,l=Ae(ei(e.data,3+r,n));return o="--\x3e"===s?Ae(ei(e.data,4+r+n)):si(e.data.subarray(4+r+n)),t.mimeType=s,t.pictureType=a,t.description=l,t.data=o,t}}}else console.log("Ignore frame with unrecognized character encoding")}function hi(e){return"PRIV"===e.type?Xt(e):"W"===e.type[0]?Zt(e):"APIC"===e.type?di(e):Jt(e)}function ci(e,t){var i=0;return i=(127&e[t])<<21,i|=(127&e[t+1])<<14,i|=(127&e[t+2])<<7,i|=127&e[t+3]}function ui(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),i=ci(e,4),r=10;return{type:t,size:i,data:e.subarray(r,r+i)}}function pi(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function fi(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}var yi=10,mi=10;function gi(e){for(var t=0,i=[];fi(e,t);){var r=ci(e,t+6);e[t+5]>>6&1&&(t+=yi);for(var s=(t+=yi)+r;t+mi<s;){var a=ui(e.subarray(t)),n=hi(a);n&&i.push(n),t+=a.size+yi}pi(e,t)&&(t+=yi)}return i}function Ai(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}var vi=.25;function bi(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function _i(e,t,i,r,s){var n=new e(t,i,"");try{n.value=r,s&&(n.type=s)}catch(o){n=new e(t,i,JSON.stringify(s?a({type:s},r):r))}return n}var wi=function(){var e=bi();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function Ei(e,t){return e.getTime()/1e3-t}function Si(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var Ti=function(){function e(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}var t=e.prototype;return t.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},t._registerListeners=function(){var e=this.hls;e.on(k.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(k.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(k.MANIFEST_LOADING,this.onManifestLoading,this),e.on(k.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(k.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(k.LEVEL_UPDATED,this.onLevelUpdated,this)},t._unregisterListeners=function(){var e=this.hls;e.off(k.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(k.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(k.MANIFEST_LOADING,this.onManifestLoading,this),e.off(k.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(k.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(k.LEVEL_UPDATED,this.onLevelUpdated,this)},t.onMediaAttached=function(e,t){this.media=t.media},t.onMediaDetaching=function(){this.id3Track&&($t(this.id3Track),this.id3Track=null),this.media=null,this.dateRangeCuesAppended={}},t.onManifestLoading=function(){this.dateRangeCuesAppended={}},t.createTrack=function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t},t.getID3Track=function(e){if(this.media){for(var t=0;t<e.length;t++){var i=e[t];if("metadata"===i.kind&&"id3"===i.label)return Vt(i,this.media),i}return this.media.addTextTrack("metadata","id3")}},t.onFragParsingMetadata=function(e,t){if(this.media){var i=this.hls.config,r=i.enableEmsgMetadataCues,s=i.enableID3MetadataCues;if(r||s){var a=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var n=bi();if(n)for(var o=0;o<a.length;o++){var l=a[o].type;if((l!==Qt.emsg||r)&&s){var d=gi(a[o].data);if(d){var h=a[o].pts,c=h+a[o].duration;c>wi&&(c=wi),c-h<=0&&(c=h+vi);for(var u=0;u<d.length;u++){var p=d[u];if(!Ai(p)){this.updateId3CueEnds(h,l);var f=_i(n,h,c,p,l);f&&this.id3Track.addCue(f)}}}}}}}},t.updateId3CueEnds=function(e,t){var i,r=null==(i=this.id3Track)?void 0:i.cues;if(r)for(var s=r.length;s--;){var a=r[s];a.type===t&&a.startTime<e&&a.endTime===wi&&(a.endTime=e)}},t.onBufferFlushing=function(e,t){var i=t.startOffset,r=t.endOffset,s=t.type,a=this.id3Track,n=this.hls;if(n){var o=n.config,l=o.enableEmsgMetadataCues,d=o.enableID3MetadataCues;a&&(l||d)&&jt(a,i,r,"audio"===s?function(e){return e.type===Qt.audioId3&&d}:"video"===s?function(e){return e.type===Qt.emsg&&l}:function(e){return e.type===Qt.audioId3&&d||e.type===Qt.emsg&&l})}},t.onLevelUpdated=function(e,t){var i=this,r=t.details;if(this.media&&r.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var s=this.dateRangeCuesAppended,a=this.id3Track,n=r.dateRanges,o=Object.keys(n);if(a)for(var l=Object.keys(s).filter((function(e){return!o.includes(e)})),d=function(){var e=l[h];Object.keys(s[e].cues).forEach((function(t){a.removeCue(s[e].cues[t])})),delete s[e]},h=l.length;h--;)d();var c=r.fragments[r.fragments.length-1];if(0!==o.length&&E(null==c?void 0:c.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var u=c.programDateTime/1e3-c.start,p=bi(),f=function(){var e=o[y],t=n[e],r=Ei(t.startDate,u),a=s[e],l=(null==a?void 0:a.cues)||{},d=(null==a?void 0:a.durationKnown)||!1,h=wi,c=t.endDate;if(c)h=Ei(c,u),d=!0;else if(t.endOnNext&&!d){var f=o.reduce((function(e,i){if(i!==t.id){var r=n[i];if(r.class===t.class&&r.startDate>t.startDate&&(!e||t.startDate<e.startDate))return r}return e}),null);f&&(h=Ei(f.startDate,u),d=!0)}for(var m=Object.keys(t.attr),g=0;g<m.length;g++){var A=m[g];if(z(A)){var v=l[A];if(v)d&&!a.durationKnown&&(v.endTime=h);else if(p){var b=t.attr[A];W(A)&&(b=Si(b));var _=_i(p,r,h,{key:A,data:b},Qt.dateRange);_&&(_.id=e,i.id3Track.addCue(_),l[A]=_)}}}s[e]={cues:l,dateRange:t,durationKnown:d}},y=0;y<o.length;y++)f()}}},e}(),ki=function(){function e(e){var t=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.onTimeupdate=function(){var e=t.media,i=t.levelDetails;if(e&&i){t.currentTime=e.currentTime;var r=t.computeLatency();if(null!==r){t._latency=r;var s=t.config,a=s.lowLatencyMode,n=s.maxLiveSyncPlaybackRate;if(a&&1!==n&&i.live){var o=t.targetLatency;if(null!==o){var l=r-o;if(l<Math.min(t.maxLatency,o+i.targetduration)&&l>.05&&t.forwardBufferLength>1){var d=Math.min(2,Math.max(1,n)),h=Math.round(2/(1+Math.exp(-.75*l-t.edgeStalled))*20)/20;e.playbackRate=Math.min(d,Math.max(1,h))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}}}}},this.hls=e,this.config=e.config,this.registerListeners()}var t=e.prototype;return t.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=null},t.registerListeners=function(){this.hls.on(k.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(k.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(k.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(k.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(k.ERROR,this.onError,this)},t.unregisterListeners=function(){this.hls.off(k.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(k.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(k.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(k.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(k.ERROR,this.onError,this)},t.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)},t.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)},t.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},t.onLevelUpdated=function(e,t){var i=t.details;this.levelDetails=i,i.advanced&&this.onTimeupdate(),!i.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)},t.onError=function(e,t){var i;t.details===D.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(i=this.levelDetails)&&i.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))},t.estimateLiveEdge=function(){var e=this.levelDetails;return null===e?null:e.edge+e.age},t.computeLatency=function(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime},d(e,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config,t=this.levelDetails;return void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(null===e)return null;var t=e.holdBack,i=e.partHoldBack,r=e.targetduration,s=this.config,a=s.liveSyncDuration,n=s.liveSyncDurationCount,o=s.lowLatencyMode,l=this.hls.userConfig,d=o&&i||t;(l.liveSyncDuration||l.liveSyncDurationCount||0===d)&&(d=void 0!==a?a:n*r);var h=r,c=1;return d+Math.min(this.stallCount*c,h)}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency,i=this.levelDetails;if(null===e||null===t||null===i)return null;var r=i.edge,s=e-t-this.edgeStalled,a=r-i.totalduration,n=r-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(a,s),n)}},{key:"drift",get:function(){var e=this.levelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(null===e)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}}])}(),Ci=["NONE","TYPE-0","TYPE-1",null];function Di(e){return Ci.indexOf(e)>-1}var Ri=["SDR","PQ","HLG"];function xi(e){return!!e&&Ri.indexOf(e)>-1}var Li={No:"",Yes:"YES",v2:"v2"};function Ii(e){var t=e.canSkipUntil,i=e.canSkipDateRanges,r=e.age;return t&&r<t/2?i?Li.v2:Li.Yes:Li.No}var Pi=function(){function e(e,t,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=i}return e.prototype.addDirectives=function(e){var t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href},e}(),Bi=function(){function e(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter((function(e){return!!e})).map((function(e){return e.substring(0,4)})).join(","),this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}var t=e.prototype;return t.hasAudioGroup=function(e){return Mi(this._audioGroups,e)},t.hasSubtitleGroup=function(e){return Mi(this._subtitleGroups,e)},t.addGroupId=function(e,t){if(t)if("audio"===e){var i=this._audioGroups;i||(i=this._audioGroups=[]),-1===i.indexOf(t)&&i.push(t)}else if("text"===e){var r=this._subtitleGroups;r||(r=this._subtitleGroups=[]),-1===r.indexOf(t)&&r.push(t)}},t.addFallback=function(){},d(e,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function(){return this._attrs[0]}},{key:"codecs",get:function(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function(){return this.url[0]||""}},{key:"audioGroups",get:function(){return this._audioGroups}},{key:"subtitleGroups",get:function(){return this._subtitleGroups}},{key:"urlId",get:function(){return 0},set:function(e){}},{key:"audioGroupIds",get:function(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function(){var e;return null==(e=this.audioGroups)?void 0:e[0]}},{key:"textGroupId",get:function(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}}])}();function Mi(e,t){return!(!t||!e)&&-1!==e.indexOf(t)}function Ui(e,t){var i=t.startPTS;if(E(i)){var r,s=0;t.sn>e.sn?(s=i-e.start,r=e):(s=e.start-i,r=t),r.duration!==s&&(r.duration=s)}else t.sn>e.sn?e.cc===t.cc&&e.minEndPTS?t.start=e.start+(e.minEndPTS-e.start):t.start=e.start+e.duration:t.start=Math.max(e.start-t.duration,0)}function Fi(e,t,i,r,s,a){r-i<=0&&(G.warn("Fragment should have a positive duration",t),r=i+t.duration,a=s+t.duration);var n=i,o=r,l=t.startPTS,d=t.endPTS;if(E(l)){var h=Math.abs(l-i);E(t.deltaPTS)?t.deltaPTS=Math.max(h,t.deltaPTS):t.deltaPTS=h,n=Math.max(i,l),i=Math.min(i,l),s=Math.min(s,t.startDTS),o=Math.min(r,d),r=Math.max(r,d),a=Math.max(a,t.endDTS)}var c=i-t.start;0!==t.start&&(t.start=i),t.duration=r-t.start,t.startPTS=i,t.maxStartPTS=n,t.startDTS=s,t.endPTS=r,t.minEndPTS=o,t.endDTS=a;var u,p=t.sn;if(!e||p<e.startSN||p>e.endSN)return 0;var f=p-e.startSN,y=e.fragments;for(y[f]=t,u=f;u>0;u--)Ui(y[u],y[u-1]);for(u=f;u<y.length-1;u++)Ui(y[u],y[u+1]);return e.fragmentHint&&Ui(y[y.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,c}function Oi(e,t){for(var i=null,r=e.fragments,s=r.length-1;s>=0;s--){var a=r[s].initSegment;if(a){i=a;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;var n,o=0;if(zi(e,t,(function(e,r){e.relurl&&(o=e.cc-r.cc),E(e.startPTS)&&E(e.endPTS)&&(r.start=r.startPTS=e.startPTS,r.startDTS=e.startDTS,r.maxStartPTS=e.maxStartPTS,r.endPTS=e.endPTS,r.endDTS=e.endDTS,r.minEndPTS=e.minEndPTS,r.duration=e.endPTS-e.startPTS,r.duration&&(n=r),t.PTSKnown=t.alignedSliding=!0),r.elementaryStreams=e.elementaryStreams,r.loader=e.loader,r.stats=e.stats,e.initSegment&&(r.initSegment=e.initSegment,i=e.initSegment)})),i&&(t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments).forEach((function(e){var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=i)?void 0:t.relurl)||(e.initSegment=i)})),t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some((function(e){return!e})),t.deltaUpdateFailed){G.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var l=t.skippedSegments;l--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=Ni(e.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));var d=t.fragments;if(o){G.warn("discontinuity sliding from playlist, take drift into account");for(var h=0;h<d.length;h++)d[h].cc+=o}t.skippedSegments&&(t.startCC=t.fragments[0].cc),Gi(e.partList,t.partList,(function(e,t){t.elementaryStreams=e.elementaryStreams,t.stats=e.stats})),n?Fi(t,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS):Wi(e,t),d.length&&(t.totalduration=t.edge-d[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;var c=t.advancedDateTime;if(t.advanced&&c){var u=t.edge;t.driftStart||(t.driftStartTime=c,t.driftStart=u),t.driftEndTime=c,t.driftEnd=u}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime}function Ni(e,t,i){var r=c({},e);return i&&i.forEach((function(e){delete r[e]})),Object.keys(t).forEach((function(e){var i=new V(t[e].attr,r[e]);i.isValid?r[e]=i:G.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(t[e].attr)+'"')})),r}function Gi(e,t,i){if(e&&t)for(var r=0,s=0,a=e.length;s<=a;s++){var n=e[s],o=t[s+r];n&&o&&n.index===o.index&&n.fragment.sn===o.fragment.sn?i(n,o):r--}}function zi(e,t,i){for(var r=t.skippedSegments,s=Math.max(e.startSN,t.startSN)-t.startSN,a=(e.fragmentHint?1:0)+(r?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,n=t.startSN-e.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,d=s;d<=a;d++){var h=l[n+d],c=o[d];r&&!c&&d<r&&(c=t.fragments[d]=h),h&&c&&i(h,c)}}function Wi(e,t){var i=t.startSN+t.skippedSegments-e.startSN,r=e.fragments;i<0||i>=r.length||Vi(t,r[i].start)}function Vi(e,t){if(t){for(var i=e.fragments,r=e.skippedSegments;r<i.length;r++)i[r].start+=t;e.fragmentHint&&(e.fragmentHint.start+=t)}}function Hi(e,t){void 0===t&&(t=1/0);var i=1e3*e.targetduration;if(e.updated){var r=e.fragments,s=4;if(r.length&&i*s>t){var a=1e3*r[r.length-1].duration;a<i&&(i=a)}}else i/=2;return Math.round(i)}function $i(e,t,i){if(null==e||!e.details)return null;var r=e.details,s=r.fragments[t-r.startSN];return s||((s=r.fragmentHint)&&s.sn===t?s:t<r.startSN&&i&&i.sn===t?i:null)}function ji(e,t,i){var r;return null!=e&&e.details?Ki(null==(r=e.details)?void 0:r.partList,t,i):null}function Ki(e,t,i){if(e)for(var r=e.length;r--;){var s=e[r];if(s.index===i&&s.fragment.sn===t)return s}return null}function qi(e){e.forEach((function(e,t){var i=e.details;null!=i&&i.fragments&&i.fragments.forEach((function(e){e.level=t}))}))}function Yi(e){switch(e.details){case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_TIMEOUT:case D.LEVEL_LOAD_TIMEOUT:case D.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Qi(e,t){var i=Yi(t);return e.default[(i?"timeout":"error")+"Retry"]}function Xi(e,t){var i="linear"===e.backoff?1:Math.pow(2,t);return Math.min(i*e.retryDelayMs,e.maxRetryDelayMs)}function Ji(e){return a(a({},e),{errorRetry:null,timeoutRetry:null})}function Zi(e,t,i,r){if(!e)return!1;var s=null==r?void 0:r.code,a=t<e.maxNumRetry&&(er(s)||!!i);return e.shouldRetry?e.shouldRetry(e,t,i,r,a):a}function er(e){return 0===e&&!1===navigator.onLine||!!e&&(e<400||e>499)}var tr={search:function(e,t){for(var i=0,r=e.length-1,s=null,a=null;i<=r;){var n=t(a=e[s=(i+r)/2|0]);if(n>0)i=s+1;else{if(!(n<0))return a;r=s-1}}return null}};function ir(e,t,i){if(null===t||!Array.isArray(e)||!e.length||!E(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;i=i||0;for(var r=0;r<e.length;++r){var s=e[r];if(ar(t,i,s))return s}return null}function rr(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=0);var s=null;if(e){s=t[e.sn-t[0].sn+1]||null;var a=e.endDTS-i;a>0&&a<15e-7&&(i+=15e-7)}else 0===i&&0===t[0].start&&(s=t[0]);if(s&&(!e||e.level===s.level)&&0===sr(i,r,s))return s;var n=tr.search(t,sr.bind(null,i,r));return!n||n===e&&s?s:n}function sr(e,t,i){if(void 0===e&&(e=0),void 0===t&&(t=0),i.start<=e&&i.start+i.duration>e)return 0;var r=Math.min(t,i.duration+(i.deltaPTS?i.deltaPTS:0));return i.start+i.duration-r<=e?1:i.start-r>e&&i.start?-1:0}function ar(e,t,i){var r=1e3*Math.min(t,i.duration+(i.deltaPTS?i.deltaPTS:0));return(i.endProgramDateTime||0)-r>e}function nr(e,t){return tr.search(e,(function(e){return e.cc<t?1:e.cc>t?-1:0}))}var or={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},lr={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4},dr=function(e){function t(t){var i;return(i=e.call(this,"error-controller",t.logger)||this).hls=void 0,i.playlistError=0,i.penalizedRenditions={},i.hls=t,i.registerListeners(),i}u(t,e);var i=t.prototype;return i.registerListeners=function(){var e=this.hls;e.on(k.ERROR,this.onError,this),e.on(k.MANIFEST_LOADING,this.onManifestLoading,this),e.on(k.LEVEL_UPDATED,this.onLevelUpdated,this)},i.unregisterListeners=function(){var e=this.hls;e&&(e.off(k.ERROR,this.onError,this),e.off(k.ERROR,this.onErrorOut,this),e.off(k.MANIFEST_LOADING,this.onManifestLoading,this),e.off(k.LEVEL_UPDATED,this.onLevelUpdated,this))},i.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},i.startLoad=function(e){},i.stopLoad=function(){this.playlistError=0},i.getVariantLevelIndex=function(e){return(null==e?void 0:e.type)===Nt.MAIN?e.level:this.hls.loadLevel},i.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},i.onLevelUpdated=function(){this.playlistError=0},i.onError=function(e,t){var i,r;if(!t.fatal){var s=this.hls,a=t.context;switch(t.details){case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case D.FRAG_PARSING_ERROR:if(null!=(i=t.frag)&&i.gap)return void(t.errorAction={action:or.DoNothing,flags:lr.None});case D.FRAG_GAP:case D.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=or.SendAlternateToPenaltyBox);case D.LEVEL_EMPTY_ERROR:case D.LEVEL_PARSING_ERROR:var n,o,l=t.parent===Nt.MAIN?t.level:s.loadLevel;return void(t.details===D.LEVEL_EMPTY_ERROR&&null!=(n=t.context)&&null!=(o=n.levelDetails)&&o.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,l):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,l)));case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==a?void 0:a.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level)));case D.AUDIO_TRACK_LOAD_ERROR:case D.AUDIO_TRACK_LOAD_TIMEOUT:case D.SUBTITLE_LOAD_ERROR:case D.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){var d=s.levels[s.loadLevel];if(d&&(a.type===Ot.AUDIO_TRACK&&d.hasAudioGroup(a.groupId)||a.type===Ot.SUBTITLE_TRACK&&d.hasSubtitleGroup(a.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,s.loadLevel),t.errorAction.action=or.SendAlternateToPenaltyBox,void(t.errorAction.flags=lr.MoveAllAlternatesMatchingHost)}return;case D.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var h=s.levels[s.loadLevel],c=null==h?void 0:h.attrs["HDCP-LEVEL"];return void(c?t.errorAction={action:or.SendAlternateToPenaltyBox,flags:lr.MoveAllAlternatesMatchingHDCP,hdcpLevel:c}:this.keySystemError(t));case D.BUFFER_ADD_CODEC_ERROR:case D.REMUX_ALLOC_ERROR:case D.BUFFER_APPEND_ERROR:return void(t.errorAction=this.getLevelSwitchAction(t,null!=(r=t.level)?r:s.loadLevel));case D.INTERNAL_EXCEPTION:case D.BUFFER_APPENDING_ERROR:case D.BUFFER_FULL_ERROR:case D.LEVEL_SWITCH_ERROR:case D.BUFFER_STALLED_ERROR:case D.BUFFER_SEEK_OVER_HOLE:case D.BUFFER_NUDGE_ON_STALL:return void(t.errorAction={action:or.DoNothing,flags:lr.None})}t.type===C.KEY_SYSTEM_ERROR&&this.keySystemError(t)}},i.keySystemError=function(e){var t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)},i.getPlaylistRetryOrSwitchAction=function(e,t){var i=Qi(this.hls.config.playlistLoadPolicy,e),r=this.playlistError++;if(Zi(i,r,Yi(e),e.response))return{action:or.RetryRequest,flags:lr.None,retryConfig:i,retryCount:r};var s=this.getLevelSwitchAction(e,t);return i&&(s.retryConfig=i,s.retryCount=r),s},i.getFragRetryOrSwitchAction=function(e){var t=this.hls,i=this.getVariantLevelIndex(e.frag),r=t.levels[i],s=t.config,a=s.fragLoadPolicy,n=s.keyLoadPolicy,o=Qi(e.details.startsWith("key")?n:a,e),l=t.levels.reduce((function(e,t){return e+t.fragmentError}),0);if(r&&(e.details!==D.FRAG_GAP&&r.fragmentError++,Zi(o,l,Yi(e),e.response)))return{action:or.RetryRequest,flags:lr.None,retryConfig:o,retryCount:l};var d=this.getLevelSwitchAction(e,i);return o&&(d.retryConfig=o,d.retryCount=l),d},i.getLevelSwitchAction=function(e,t){var i=this.hls;null==t&&(t=i.loadLevel);var r=this.hls.levels[t];if(r){var s,a,n=e.details;r.loadError++,n===D.BUFFER_APPEND_ERROR&&r.fragmentError++;var o=-1,l=i.levels,d=i.loadLevel,h=i.minAutoLevel,c=i.maxAutoLevel;i.autoLevelEnabled||(i.loadLevel=-1);for(var u,p=null==(s=e.frag)?void 0:s.type,f=(p===Nt.AUDIO&&n===D.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(n===D.BUFFER_ADD_CODEC_ERROR||n===D.BUFFER_APPEND_ERROR))&&l.some((function(e){var t=e.audioCodec;return r.audioCodec!==t})),y="video"===e.sourceBufferName&&(n===D.BUFFER_ADD_CODEC_ERROR||n===D.BUFFER_APPEND_ERROR)&&l.some((function(e){var t=e.codecSet,i=e.audioCodec;return r.codecSet!==t&&r.audioCodec===i})),m=null!=(a=e.context)?a:{},g=m.type,A=m.groupId,v=function(){var t=(b+d)%l.length;if(t!==d&&t>=h&&t<=c&&0===l[t].loadError){var i,s,a=l[t];if(n===D.FRAG_GAP&&e.frag){var u=l[t].details;if(u){var m=rr(e.frag,u.fragments,e.frag.start);if(null!=m&&m.gap)return 0}}else{if(g===Ot.AUDIO_TRACK&&a.hasAudioGroup(A)||g===Ot.SUBTITLE_TRACK&&a.hasSubtitleGroup(A))return 0;if(p===Nt.AUDIO&&null!=(i=r.audioGroups)&&i.some((function(e){return a.hasAudioGroup(e)}))||p===Nt.SUBTITLE&&null!=(s=r.subtitleGroups)&&s.some((function(e){return a.hasSubtitleGroup(e)}))||f&&r.audioCodec===a.audioCodec||!f&&r.audioCodec!==a.audioCodec||y&&r.codecSet===a.codecSet)return 0}return o=t,1}},b=l.length;b--&&(0===(u=v())||1!==u););if(o>-1&&i.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:or.SendAlternateToPenaltyBox,flags:lr.None,nextAutoLevel:o}}return{action:or.SendAlternateToPenaltyBox,flags:lr.MoveAllAlternatesMatchingHost}},i.onErrorOut=function(e,t){var i;switch(null==(i=t.errorAction)?void 0:i.action){case or.DoNothing:break;case or.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===D.FRAG_GAP?/MediaSource readyState: ended/.test(t.error.message)&&(this.warn('MediaSource ended after "'+t.sourceBufferName+'" sourceBuffer append error. Attempting to recover from media error.'),this.hls.recoverMediaError()):t.fatal=!0}t.fatal&&this.hls.stopLoad()},i.sendAlternateToPenaltyBox=function(e){var t=this.hls,i=e.errorAction;if(i){var r=i.flags,s=i.hdcpLevel,a=i.nextAutoLevel;switch(r){case lr.None:this.switchLevel(e,a);break;case lr.MoveAllAlternatesMatchingHDCP:s&&(t.maxHdcpLevel=Ci[Ci.indexOf(s)-1],i.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+t.maxHdcpLevel+'" or lower')}i.resolved||this.switchLevel(e,a)}},i.switchLevel=function(e,t){void 0!==t&&e.errorAction&&(this.warn("switching to level "+t+" after "+e.details),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)},t}(I),hr=function(e){function t(t,i){var r;return(r=e.call(this,i,t.logger)||this).hls=void 0,r.timer=-1,r.requestScheduled=-1,r.canLoad=!1,r.hls=t,r}u(t,e);var i=t.prototype;return i.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},i.clearTimer=function(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)},i.startLoad=function(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()},i.stopLoad=function(){this.canLoad=!1,this.clearTimer()},i.switchParams=function(e,t,i){var r=null==t?void 0:t.renditionReports;if(r){for(var s=-1,a=0;a<r.length;a++){var n=r[a],o=void 0;try{o=new self.URL(n.URI,t.url).href}catch(e){this.warn("Could not construct new URL for Rendition Report: "+e),o=n.URI||""}if(o===e){s=a;break}o===e.substring(0,o.length)&&(s=a)}if(-1!==s){var l=r[s],d=parseInt(l["LAST-MSN"])||(null==t?void 0:t.lastPartSn),h=parseInt(l["LAST-PART"])||(null==t?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){var c=Math.min(t.age-t.partTarget,t.targetduration);h>=0&&c>t.partTarget&&(h+=1)}var u=i&&Ii(i);return new Pi(d,h>=0?h:void 0,u)}}},i.loadPlaylist=function(e){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())},i.shouldLoadPlaylist=function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)},i.shouldReloadPlaylist=function(e){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(e)},i.playlistLoaded=function(e,t,i){var r=this,s=t.details,a=t.stats,n=self.performance.now(),o=a.loading.first?Math.max(0,n-a.loading.first):0;if(s.advancedDateTime=Date.now()-o,s.live||null!=i&&i.live){if(s.reloaded(i),i&&this.log("live playlist "+e+" "+(s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED")),i&&s.fragments.length>0&&Oi(i,s),!this.canLoad||!s.live)return;var l,d=void 0,h=void 0;if(s.canBlockReload&&s.endSN&&s.advanced){var c=this.hls.config.lowLatencyMode,u=s.lastPartSn,p=s.endSN,f=s.lastPartIndex,y=u===p;-1!==f?(d=y?p+1:u,h=y?c?0:f:f+1):d=p+1;var m=s.age,g=m+s.ageHeader,A=Math.min(g-s.partTarget,1.5*s.targetduration);if(A>0){if(g>3*s.targetduration)this.log("Playlist last advanced "+m.toFixed(2)+"s ago. Omitting segment and part directives."),d=void 0,h=void 0;else if(null!=i&&i.tuneInGoal&&g-s.partTarget>i.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+i.tuneInGoal+" to: "+A+" with playlist age: "+s.age),A=0;else{var v=Math.floor(A/s.targetduration);d+=v,void 0!==h&&(h+=Math.round(A%s.targetduration/s.partTarget)),this.log("CDN Tune-in age: "+s.ageHeader+"s last advanced "+m.toFixed(2)+"s goal: "+A+" skip sn "+v+" to part "+h)}s.tuneInGoal=A}if(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,h),c||!y)return void this.loadPlaylist(l)}else(s.canBlockReload||s.canSkipUntil)&&(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,h));var b=this.hls.mainForwardBufferInfo,_=b?b.end-b.len:0,w=Hi(s,1e3*(s.edge-_));s.updated&&n>this.requestScheduled+w&&(this.requestScheduled=a.loading.start),void 0!==d&&s.canBlockReload?this.requestScheduled=a.loading.first+w-(1e3*s.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+w<n?this.requestScheduled=n:this.requestScheduled-n<=0&&(this.requestScheduled+=w);var E=this.requestScheduled-n;E=Math.max(0,E),this.log("reload live playlist "+e+" in "+Math.round(E)+" ms"),this.timer=self.setTimeout((function(){return r.loadPlaylist(l)}),E)}else this.clearTimer()},i.getDeliveryDirectives=function(e,t,i,r){var s=Ii(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,r=t.part,s=Li.No),new Pi(i,r,s)},i.checkRetry=function(e){var t=this,i=e.details,r=Yi(e),s=e.errorAction,a=s||{},n=a.action,o=a.retryCount,l=void 0===o?0:o,d=a.retryConfig,h=!!s&&!!d&&(n===or.RetryRequest||!s.resolved&&n===or.SendAlternateToPenaltyBox);if(h){var c;if(this.requestScheduled=-1,l>=d.maxNumRetry)return!1;if(r&&null!=(c=e.context)&&c.deliveryDirectives)this.warn("Retrying playlist loading "+(l+1)+"/"+d.maxNumRetry+' after "'+i+'" without delivery-directives'),this.loadPlaylist();else{var u=Xi(d,l);this.timer=self.setTimeout((function(){return t.loadPlaylist()}),u),this.warn("Retrying playlist loading "+(l+1)+"/"+d.maxNumRetry+' after "'+i+'" in '+u+"ms")}e.levelRetry=!0,s.resolved=!0}return h},t}(I),cr=function(){function e(e,t,i){void 0===t&&(t=0),void 0===i&&(i=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=i}var t=e.prototype;return t.sample=function(e,t){var i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e},t.getTotalWeight=function(){return this.totalWeight_},t.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},e}(),ur=function(){function e(e,t,i,r){void 0===r&&(r=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new cr(e),this.fast_=new cr(t),this.defaultTTFB_=r,this.ttfb_=new cr(e)}var t=e.prototype;return t.update=function(e,t){var i=this.slow_,r=this.fast_,s=this.ttfb_;i.halfLife!==e&&(this.slow_=new cr(e,i.getEstimate(),i.getTotalWeight())),r.halfLife!==t&&(this.fast_=new cr(t,r.getEstimate(),r.getTotalWeight())),s.halfLife!==e&&(this.ttfb_=new cr(e,s.getEstimate(),s.getTotalWeight()))},t.sample=function(e,t){var i=(e=Math.max(e,this.minDelayMs_))/1e3,r=8*t/i;this.fast_.sample(i,r),this.slow_.sample(i,r)},t.sampleTTFB=function(e){var t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,Math.max(e,5))},t.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},t.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},t.destroy=function(){},e}(),pr={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},fr={};function yr(e,t,i,r,s,a){var n=e.audioCodec?e.audioGroups:null,o=null==a?void 0:a.audioCodec,l=null==a?void 0:a.channels,d=l?parseInt(l):o?1/0:2,h=null;if(null!=n&&n.length)try{h=1===n.length&&n[0]?t.groups[n[0]].channels:n.reduce((function(e,i){if(i){var r=t.groups[i];if(!r)throw new Error("Audio track group "+i+" not found");Object.keys(r.channels).forEach((function(t){e[t]=(e[t]||0)+r.channels[t]}))}return e}),{2:0})}catch(e){return!0}return void 0!==e.videoCodec&&(e.width>1920&&e.height>1088||e.height>1920&&e.width>1088||e.frameRate>Math.max(r,30)||"SDR"!==e.videoRange&&e.videoRange!==i||e.bitrate>Math.max(s,8e6))||!!h&&E(d)&&Object.keys(h).some((function(e){return parseInt(e)>d}))}function mr(e,t,i){var r=e.videoCodec,s=e.audioCodec;if(!r||!s||!i)return Promise.resolve(pr);var n={width:e.width,height:e.height,bitrate:Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)),framerate:e.frameRate||30},o=e.videoRange;"SDR"!==o&&(n.transferFunction=o.toLowerCase());var l=r.split(",").map((function(e){return{type:"media-source",video:a(a({},n),{},{contentType:ft(e,"video")})}}));return s&&e.audioGroups&&e.audioGroups.forEach((function(e){var i;e&&(null==(i=t.groups[e])||i.tracks.forEach((function(t){if(t.groupId===e){var i=t.channels||"",r=parseFloat(i);E(r)&&r>2&&l.push.apply(l,s.split(",").map((function(e){return{type:"media-source",audio:{contentType:ft(e,"audio"),channels:""+r}}})))}})))})),Promise.all(l.map((function(e){var t=gr(e);return fr[t]||(fr[t]=i.decodingInfo(e))}))).then((function(e){return{supported:!e.some((function(e){return!e.supported})),configurations:l,decodingInfoResults:e}})).catch((function(e){return{supported:!1,configurations:l,decodingInfoResults:[],error:e}}))}function gr(e){var t=e.audio,i=e.video,r=i||t;if(r){var s=r.contentType.split('"')[1];if(i)return"r"+i.height+"x"+i.width+"f"+Math.ceil(i.framerate)+(i.transferFunction||"sd")+"_"+s+"_"+Math.ceil(i.bitrate/1e5);if(t)return"c"+t.channels+(t.spatialRendering?"s":"n")+"_"+s}return""}function Ar(){if("function"==typeof matchMedia){var e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}function vr(e,t){var i=!1,r=[];return e&&(i="SDR"!==e,r=[e]),t&&(r=t.allowedVideoRanges||Ri.slice(0),r=(i=void 0!==t.preferHDR?t.preferHDR:Ar())?r.filter((function(e){return"SDR"!==e})):["SDR"]),{preferHDR:i,allowedVideoRanges:r}}function br(e,t,i,r,s){for(var a=Object.keys(e),n=null==r?void 0:r.channels,o=null==r?void 0:r.audioCodec,l=n&&2===parseInt(n),d=!0,h=!1,c=1/0,u=1/0,p=1/0,f=0,y=[],m=vr(t,s),g=m.preferHDR,A=m.allowedVideoRanges,v=function(){var t=e[a[b]];d=t.channels[2]>0,c=Math.min(c,t.minHeight),u=Math.min(u,t.minFramerate),p=Math.min(p,t.minBitrate);var i=A.filter((function(e){return t.videoRanges[e]>0}));i.length>0&&(h=!0,y=i)},b=a.length;b--;)v();c=E(c)?c:0,u=E(u)?u:0;var _=Math.max(1080,c),w=Math.max(30,u);p=E(p)?p:i,i=Math.max(p,i),h||(t=void 0,y=[]);var S=a.reduce((function(t,r){var s=e[r];if(r===t)return t;if(s.minBitrate>i)return _r(r,"min bitrate of "+s.minBitrate+" > current estimate of "+i),t;if(!s.hasDefaultAudio)return _r(r,"no renditions with default or auto-select sound found"),t;if(o&&r.indexOf(o.substring(0,4))%5!=0)return _r(r,'audio codec preference "'+o+'" not found'),t;if(n&&!l){if(!s.channels[n])return _r(r,"no renditions with "+n+" channel sound found (channels options: "+Object.keys(s.channels)+")"),t}else if((!o||l)&&d&&0===s.channels[2])return _r(r,"no renditions with stereo sound found"),t;return s.minHeight>_?(_r(r,"min resolution of "+s.minHeight+" > maximum of "+_),t):s.minFramerate>w?(_r(r,"min framerate of "+s.minFramerate+" > maximum of "+w),t):y.some((function(e){return s.videoRanges[e]>0}))?s.maxScore<f?(_r(r,"max score of "+s.maxScore+" < selected max of "+f),t):t&&(mt(r)>=mt(t)||s.fragmentError>e[t].fragmentError)?t:(f=s.maxScore,r):(_r(r,"no variants with VIDEO-RANGE of "+JSON.stringify(y)+" found"),t)}),void 0);return{codecSet:S,videoRanges:y,preferHDR:g,minFramerate:u,minBitrate:p}}function _r(e,t){G.log('[abr] start candidates with "'+e+'" ignored because '+t)}function wr(e){return e.reduce((function(e,t){var i=e.groups[t.groupId];i||(i=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),i.tracks.push(t);var r=t.channels||"2";return i.channels[r]=(i.channels[r]||0)+1,i.hasDefault=i.hasDefault||t.default,i.hasAutoSelect=i.hasAutoSelect||t.autoselect,i.hasDefault&&(e.hasDefaultAudio=!0),i.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e}),{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function Er(e,t,i,r){return e.slice(i,r+1).reduce((function(e,i){if(!i.codecSet)return e;var r=i.audioGroups,s=e[i.codecSet];s||(e[i.codecSet]=s={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!r,fragmentError:0}),s.minBitrate=Math.min(s.minBitrate,i.bitrate);var a=Math.min(i.height,i.width);return s.minHeight=Math.min(s.minHeight,a),s.minFramerate=Math.min(s.minFramerate,i.frameRate),s.maxScore=Math.max(s.maxScore,i.score),s.fragmentError+=i.fragmentError,s.videoRanges[i.videoRange]=(s.videoRanges[i.videoRange]||0)+1,r&&r.forEach((function(e){if(e){var i=t.groups[e];s.hasDefaultAudio=s.hasDefaultAudio||t.hasDefaultAudio?i.hasDefault:i.hasAutoSelect||!t.hasDefaultAudio&&!t.hasAutoSelectAudio,Object.keys(i.channels).forEach((function(e){s.channels[e]=(s.channels[e]||0)+i.channels[e]}))}})),e}),{})}function Sr(e,t,i){if("attrs"in e){var r=t.indexOf(e);if(-1!==r)return r}for(var s=0;s<t.length;s++)if(Tr(e,t[s],i))return s;return-1}function Tr(e,t,i){var r=e.groupId,s=e.name,a=e.lang,n=e.assocLang,o=e.characteristics,l=e.default,d=e.forced;return(void 0===r||t.groupId===r)&&(void 0===s||t.name===s)&&(void 0===a||t.lang===a)&&(void 0===a||t.assocLang===n)&&(void 0===l||t.default===l)&&(void 0===d||t.forced===d)&&(void 0===o||kr(o,t.characteristics))&&(void 0===i||i(e,t))}function kr(e,t){void 0===t&&(t="");var i=e.split(","),r=t.split(",");return i.length===r.length&&!i.some((function(e){return-1===r.indexOf(e)}))}function Cr(e,t){var i=e.audioCodec,r=e.channels;return!(void 0!==i&&(t.audioCodec||"").substring(0,4)!==i.substring(0,4)||void 0!==r&&r!==(t.channels||"2"))}function Dr(e,t,i,r,s){var a=t[r],n=t.reduce((function(e,t,i){var r=t.uri;return(e[r]||(e[r]=[])).push(i),e}),{})[a.uri];n.length>1&&(r=Math.max.apply(Math,n));var o=a.videoRange,l=a.frameRate,d=a.codecSet.substring(0,4),h=Rr(t,r,(function(t){if(t.videoRange!==o||t.frameRate!==l||t.codecSet.substring(0,4)!==d)return!1;var r=t.audioGroups,a=i.filter((function(e){return!r||-1!==r.indexOf(e.groupId)}));return Sr(e,a,s)>-1}));return h>-1?h:Rr(t,r,(function(t){var r=t.audioGroups,a=i.filter((function(e){return!r||-1!==r.indexOf(e.groupId)}));return Sr(e,a,s)>-1}))}function Rr(e,t,i){for(var r=t;r;r--)if(i(e[r]))return r;for(var s=t+1;s<e.length;s++)if(i(e[s]))return s;return-1}var xr=function(e){function t(t){var i;return(i=e.call(this,"abr",t.logger)||this).hls=void 0,i.lastLevelLoadSec=0,i.lastLoadedFragLevel=-1,i.firstSelection=-1,i._nextAutoLevel=-1,i.nextAutoLevelKey="",i.audioTracksByGroup=null,i.codecTiers=null,i.timer=-1,i.fragCurrent=null,i.partCurrent=null,i.bitrateTestDelay=0,i.bwEstimator=void 0,i._abandonRulesCheck=function(){var e=i,t=e.fragCurrent,r=e.partCurrent,s=e.hls,a=s.autoLevelEnabled,n=s.media;if(t&&n){var o=performance.now(),l=r?r.stats:t.stats,d=r?r.duration:t.duration,h=o-l.loading.start,c=s.minAutoLevel;if(l.aborted||l.loaded&&l.loaded===l.total||t.level<=c)return i.clearTimer(),void(i._nextAutoLevel=-1);if(a&&!n.paused&&n.playbackRate&&n.readyState){var u=s.mainForwardBufferInfo;if(null!==u){var p=i.bwEstimator.getEstimateTTFB(),f=Math.abs(n.playbackRate);if(!(h<=Math.max(p,d/(2*f)*1e3))){var y=u.len/f,m=l.loading.first?l.loading.first-l.loading.start:-1,g=l.loaded&&m>-1,A=i.getBwEstimate(),v=s.levels,b=v[t.level],_=l.total||Math.max(l.loaded,Math.round(d*b.averageBitrate/8)),w=g?h-m:h;w<1&&g&&(w=Math.min(h,8*l.loaded/A));var S=g?1e3*l.loaded/w:0,T=S?(_-l.loaded)/S:8*_/A+p/1e3;if(!(T<=y)){var C,D=S?8*S:A,R=Number.POSITIVE_INFINITY;for(C=t.level-1;C>c;C--){var x=v[C].maxBitrate;if((R=i.getTimeToLoadFrag(p/1e3,D,d*x,!v[C].details))<y)break}if(!(R>=T||R>10*d)){s.nextLoadLevel=s.nextAutoLevel=C,g?i.bwEstimator.sample(h-Math.min(p,m),l.loaded):i.bwEstimator.sampleTTFB(h);var L=v[C].maxBitrate;i.getBwEstimate()*i.hls.config.abrBandWidthUpFactor>L&&i.resetEstimator(L),i.clearTimer(),i.warn("Fragment "+t.sn+(r?" part "+r.index:"")+" of level "+t.level+" is loading too slowly;\n Time to underbuffer: "+y.toFixed(3)+" s\n Estimated load time for current fragment: "+T.toFixed(3)+" s\n Estimated load time for down switch fragment: "+R.toFixed(3)+" s\n TTFB estimate: "+(0|m)+" ms\n Current BW estimate: "+(E(A)?0|A:"Unknown")+" bps\n New BW estimate: "+(0|i.getBwEstimate())+" bps\n Switching to level "+C+" @ "+(0|L)+" bps"),s.trigger(k.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:r,stats:l})}}}}}}},i.hls=t,i.bwEstimator=i.initEstimator(),i.registerListeners(),i}u(t,e);var i=t.prototype;return i.resetEstimator=function(e){e&&(this.log("setting initial bwe to "+e),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()},i.initEstimator=function(){var e=this.hls.config;return new ur(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)},i.registerListeners=function(){var e=this.hls;e.on(k.MANIFEST_LOADING,this.onManifestLoading,this),e.on(k.FRAG_LOADING,this.onFragLoading,this),e.on(k.FRAG_LOADED,this.onFragLoaded,this),e.on(k.FRAG_BUFFERED,this.onFragBuffered,this),e.on(k.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(k.LEVEL_LOADED,this.onLevelLoaded,this),e.on(k.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(k.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(k.ERROR,this.onError,this)},i.unregisterListeners=function(){var e=this.hls;e&&(e.off(k.MANIFEST_LOADING,this.onManifestLoading,this),e.off(k.FRAG_LOADING,this.onFragLoading,this),e.off(k.FRAG_LOADED,this.onFragLoaded,this),e.off(k.FRAG_BUFFERED,this.onFragBuffered,this),e.off(k.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(k.LEVEL_LOADED,this.onLevelLoaded,this),e.off(k.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(k.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(k.ERROR,this.onError,this))},i.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null},i.onManifestLoading=function(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()},i.onLevelsUpdated=function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null},i.onMaxAutoLevelUpdated=function(){this.firstSelection=-1,this.nextAutoLevelKey=""},i.onFragLoading=function(e,t){var i,r=t.frag;this.ignoreFragment(r)||(r.bitrateTest||(this.fragCurrent=r,this.partCurrent=null!=(i=t.part)?i:null),this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100))},i.onLevelSwitching=function(e,t){this.clearTimer()},i.onError=function(e,t){if(!t.fatal)switch(t.details){case D.BUFFER_ADD_CODEC_ERROR:case D.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case D.FRAG_LOAD_TIMEOUT:var i=t.frag,r=this.fragCurrent,s=this.partCurrent;if(i&&r&&i.sn===r.sn&&i.level===r.level){var a=performance.now(),n=s?s.stats:i.stats,o=a-n.loading.start,l=n.loading.first?n.loading.first-n.loading.start:-1;if(n.loaded&&l>-1){var d=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(o-Math.min(d,l),n.loaded)}else this.bwEstimator.sampleTTFB(o)}}},i.getTimeToLoadFrag=function(e,t,i,r){return e+i/t+(r?this.lastLevelLoadSec:0)},i.onLevelLoaded=function(e,t){var i=this.hls.config,r=t.stats.loading,s=r.end-r.start;E(s)&&(this.lastLevelLoadSec=s/1e3),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD)},i.onFragLoaded=function(e,t){var i=t.frag,r=t.part,s=r?r.stats:i.stats;if(i.type===Nt.MAIN&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),!this.ignoreFragment(i)){if(this.clearTimer(),i.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var a=r?r.duration:i.duration,n=this.hls.levels[i.level],o=(n.loaded?n.loaded.bytes:0)+s.loaded,l=(n.loaded?n.loaded.duration:0)+a;n.loaded={bytes:o,duration:l},n.realBitrate=Math.round(8*o/l)}if(i.bitrateTest){var d={stats:s,frag:i,part:r,id:i.type};this.onFragBuffered(k.FRAG_BUFFERED,d),i.bitrateTest=!1}else this.lastLoadedFragLevel=i.level}},i.onFragBuffered=function(e,t){var i=t.frag,r=t.part,s=null!=r&&r.stats.loaded?r.stats:i.stats;if(!s.aborted&&!this.ignoreFragment(i)){var a=s.parsing.end-s.loading.start-Math.min(s.loading.first-s.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,s.loaded),s.bwEstimate=this.getBwEstimate(),i.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}},i.ignoreFragment=function(e){return e.type!==Nt.MAIN||"initSegment"===e.sn},i.clearTimer=function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)},i.getAutoLevelKey=function(){return this.getBwEstimate()+"_"+this.getStarvationDelay().toFixed(2)},i.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,i=this.hls;if(i.levels.length<=1)return i.loadLevel;var r=i.maxAutoLevel,s=i.config,a=i.minAutoLevel,n=t?t.duration:e?e.duration:0,o=this.getBwEstimate(),l=this.getStarvationDelay(),d=s.abrBandWidthFactor,h=s.abrBandWidthUpFactor;if(l){var c=this.findBestLevel(o,a,r,l,0,d,h);if(c>=0)return c}var u=n?Math.min(n,s.maxStarvationDelay):s.maxStarvationDelay;if(!l){var p=this.bitrateTestDelay;p&&(u=(n?Math.min(n,s.maxLoadingDelay):s.maxLoadingDelay)-p,this.info("bitrate test took "+Math.round(1e3*p)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*u)+" ms"),d=h=1)}var f=this.findBestLevel(o,a,r,l,u,d,h);if(this.info((l?"rebuffering expected":"buffer is empty")+", optimal quality level "+f),f>-1)return f;var y=i.levels[a],m=i.levels[i.loadLevel];return(null==y?void 0:y.bitrate)<(null==m?void 0:m.bitrate)?a:i.loadLevel},i.getStarvationDelay=function(){var e=this.hls,t=e.media;if(!t)return 1/0;var i=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,r=e.mainForwardBufferInfo;return(r?r.len:0)/i},i.getBwEstimate=function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate},i.findBestLevel=function(e,t,i,r,s,a,n){var o,l=this,d=r+s,h=this.lastLoadedFragLevel,c=-1===h?this.hls.firstLevel:h,u=this.fragCurrent,p=this.partCurrent,f=this.hls,y=f.levels,m=f.allAudioTracks,g=f.loadLevel,A=f.config;if(1===y.length)return 0;var v,b=y[c],_=!(null==b||null==(o=b.details)||!o.live),w=-1===g||-1===h,S="SDR",T=(null==b?void 0:b.frameRate)||0,k=A.audioPreference,C=A.videoPreference,D=this.audioTracksByGroup||(this.audioTracksByGroup=wr(m));if(w){if(-1!==this.firstSelection)return this.firstSelection;var R=br(this.codecTiers||(this.codecTiers=Er(y,D,t,i)),S,e,k,C),x=R.codecSet,L=R.videoRanges,I=R.minFramerate,P=R.minBitrate,B=R.preferHDR;v=x,S=B?L[L.length-1]:L[0],T=I,e=Math.max(e,P),this.log("picked start tier "+JSON.stringify(R))}else v=null==b?void 0:b.codecSet,S=null==b?void 0:b.videoRange;for(var M,U=p?p.duration:u?u.duration:0,F=this.bwEstimator.getEstimateTTFB()/1e3,O=[],N=function(){var t,o=y[G],u=G>c;if(!o)return 0;if(A.useMediaCapabilities&&!o.supportedResult&&!o.supportedPromise){var f=navigator.mediaCapabilities;"function"==typeof(null==f?void 0:f.decodingInfo)&&yr(o,D,S,T,e,k)?(o.supportedPromise=mr(o,D,f),o.supportedPromise.then((function(e){if(l.hls){o.supportedResult=e;var t=l.hls.levels,i=t.indexOf(o);e.error?l.warn('MediaCapabilities decodingInfo error: "'+e.error+'" for level '+i+" "+JSON.stringify(e)):e.supported||(l.warn("Unsupported MediaCapabilities decodingInfo result for level "+i+" "+JSON.stringify(e)),i>-1&&t.length>1&&(l.log("Removing unsupported level "+i),l.hls.removeLevel(i)))}}))):o.supportedResult=pr}if(v&&o.codecSet!==v||S&&o.videoRange!==S||u&&T>o.frameRate||!u&&T>0&&T<o.frameRate||o.supportedResult&&(null==(t=o.supportedResult.decodingInfoResults)||!t[0].smooth))return O.push(G),0;var m,C=o.details,R=(p?null==C?void 0:C.partTarget:null==C?void 0:C.averagetargetduration)||U;m=u?n*e:a*e;var x=U&&r>=2*U&&0===s?y[G].averageBitrate:y[G].maxBitrate,L=l.getTimeToLoadFrag(F,m,x*R,void 0===C);if(m>=x&&(G===h||0===o.loadError&&0===o.fragmentError)&&(L<=F||!E(L)||_&&!l.bitrateTestDelay||L<d)){var I=l.forcedAutoLevel;return G===g||-1!==I&&I===g||(O.length&&l.trace("Skipped level(s) "+O.join(",")+" of "+i+' max with CODECS and VIDEO-RANGE:"'+y[O[0]].codecs+'" '+y[O[0]].videoRange+'; not compatible with "'+b.codecs+'" '+S),l.info("switch candidate:"+c+"->"+G+" adjustedbw("+Math.round(m)+")-bitrate="+Math.round(m-x)+" ttfb:"+F.toFixed(1)+" avgDuration:"+R.toFixed(1)+" maxFetchDuration:"+d.toFixed(1)+" fetchDuration:"+L.toFixed(1)+" firstSelection:"+w+" codecSet:"+v+" videoRange:"+S+" hls.loadLevel:"+g)),w&&(l.firstSelection=G),{v:G}}},G=i;G>=t;G--)if(0!==(M=N())&&M)return M.v;return-1},d(t,[{key:"firstAutoLevel",get:function(){var e=this.hls,t=e.maxAutoLevel,i=e.minAutoLevel,r=this.getBwEstimate(),s=this.hls.config.maxStarvationDelay,a=this.findBestLevel(r,i,t,0,s,1,1);if(a>-1)return a;var n=this.hls.firstLevel,o=Math.min(Math.max(n,i),t);return this.warn("Could not find best starting auto level. Defaulting to first in playlist "+n+" clamped to "+o),o}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),i=this.lastLoadedFragLevel>-1;if(!(-1===e||t&&i&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return e;var r=t&&i?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){var s=this.hls.levels;if(s.length>Math.max(e,r)&&s[e].loadError<=s[r].loadError)return e}return this._nextAutoLevel=r,this.nextAutoLevelKey=this.getAutoLevelKey(),r},set:function(e){var t=this.hls,i=t.maxAutoLevel,r=t.minAutoLevel,s=Math.min(Math.max(e,r),i);this._nextAutoLevel!==s&&(this.nextAutoLevelKey="",this._nextAutoLevel=s)}}])}(I),Lr=function(e){function t(t,i){var r;return(r=e.call(this,t,i)||this)._boundTick=void 0,r._tickTimer=null,r._tickInterval=null,r._tickCallCount=0,r._boundTick=r.tick.bind(r),r}u(t,e);var i=t.prototype;return i.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},i.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},i.onHandlerDestroyed=function(){},i.hasInterval=function(){return!!this._tickInterval},i.hasNextTick=function(){return!!this._tickTimer},i.setInterval=function(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)},i.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},i.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},i.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},i.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},i.doTick=function(){},t}(I),Ir={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},Pr=function(){function e(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}var t=e.prototype;return t._registerListeners=function(){var e=this.hls;e.on(k.BUFFER_APPENDED,this.onBufferAppended,this),e.on(k.FRAG_BUFFERED,this.onFragBuffered,this),e.on(k.FRAG_LOADED,this.onFragLoaded,this)},t._unregisterListeners=function(){var e=this.hls;e.off(k.BUFFER_APPENDED,this.onBufferAppended,this),e.off(k.FRAG_BUFFERED,this.onFragBuffered,this),e.off(k.FRAG_LOADED,this.onFragLoaded,this)},t.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},t.getAppendedFrag=function(e,t){var i=this.activePartLists[t];if(i)for(var r=i.length;r--;){var s=i[r];if(!s)break;var a=s.end;if(s.start<=e&&null!==a&&e<=a)return s}return this.getBufferedFrag(e,t)},t.getBufferedFrag=function(e,t){return this.getFragAtPos(e,t,!0)},t.getFragAtPos=function(e,t,i){for(var r=this.fragments,s=Object.keys(r),a=s.length;a--;){var n=r[s[a]];if((null==n?void 0:n.body.type)===t&&(!i||n.buffered)){var o=n.body;if(o.start<=e&&e<=o.end)return o}}return null},t.detectEvictedFragments=function(e,t,i,r){var s=this;this.timeRanges&&(this.timeRanges[e]=t);var a=(null==r?void 0:r.fragment.sn)||-1;Object.keys(this.fragments).forEach((function(r){var n=s.fragments[r];if(n&&!(a>=n.body.sn))if(n.buffered||n.loaded){var o=n.range[e];o&&o.time.some((function(e){var i=!s.isTimeBuffered(e.startPTS,e.endPTS,t);return i&&s.removeFragment(n.body),i}))}else n.body.type===i&&s.removeFragment(n.body)}))},t.detectPartialFragments=function(e){var t=this,i=this.timeRanges,r=e.frag,s=e.part;if(i&&"initSegment"!==r.sn){var a=Mr(r),n=this.fragments[a];if(!(!n||n.buffered&&r.gap)){var o=!r.relurl;Object.keys(i).forEach((function(e){var a=r.elementaryStreams[e];if(a){var l=i[e],d=o||!0===a.partial;n.range[e]=t.getBufferedTimes(r,s,d,l)}})),n.loaded=null,Object.keys(n.range).length?(n.buffered=!0,(n.body.endList=r.endList||n.body.endList)&&(this.endListFragments[n.body.type]=n),Br(n)||this.removeParts(r.sn-1,r.type)):this.removeFragment(n.body)}}},t.removeParts=function(e,t){var i=this.activePartLists[t];i&&(this.activePartLists[t]=i.filter((function(t){return t.fragment.sn>=e})))},t.fragBuffered=function(e,t){var i=Mr(e),r=this.fragments[i];!r&&t&&(r=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),r&&(r.loaded=null,r.buffered=!0)},t.getBufferedTimes=function(e,t,i,r){for(var s={time:[],partial:i},a=e.start,n=e.end,o=e.minEndPTS||n,l=e.maxStartPTS||a,d=0;d<r.length;d++){var h=r.start(d)-this.bufferPadding,c=r.end(d)+this.bufferPadding;if(l>=h&&o<=c){s.time.push({startPTS:Math.max(a,r.start(d)),endPTS:Math.min(n,r.end(d))});break}if(a<c&&n>h){var u=Math.max(a,r.start(d)),p=Math.min(n,r.end(d));p>u&&(s.partial=!0,s.time.push({startPTS:u,endPTS:p}))}else if(n<=h)break}return s},t.getPartialFragment=function(e){var t,i,r,s=null,a=0,n=this.bufferPadding,o=this.fragments;return Object.keys(o).forEach((function(l){var d=o[l];d&&Br(d)&&(i=d.body.start-n,r=d.body.end+n,e>=i&&e<=r&&(t=Math.min(e-i,r-e),a<=t&&(s=d.body,a=t)))})),s},t.isEndListAppended=function(e){var t=this.endListFragments[e];return void 0!==t&&(t.buffered||Br(t))},t.getState=function(e){var t=Mr(e),i=this.fragments[t];return i?i.buffered?Br(i)?Ir.PARTIAL:Ir.OK:Ir.APPENDING:Ir.NOT_LOADED},t.isTimeBuffered=function(e,t,i){for(var r,s,a=0;a<i.length;a++){if(r=i.start(a)-this.bufferPadding,s=i.end(a)+this.bufferPadding,e>=r&&t<=s)return!0;if(t<=r)return!1}return!1},t.onFragLoaded=function(e,t){var i=t.frag,r=t.part;if("initSegment"!==i.sn&&!i.bitrateTest){var s=r?null:t,a=Mr(i);this.fragments[a]={body:i,appendedPTS:null,loaded:s,buffered:!1,range:Object.create(null)}}},t.onBufferAppended=function(e,t){var i=t.frag,r=t.part,s=t.timeRanges,a=t.type;if("initSegment"!==i.sn){var n=i.type;if(r){var o=this.activePartLists[n];o||(this.activePartLists[n]=o=[]),o.push(r)}this.timeRanges=s;var l=s[a];this.detectEvictedFragments(a,l,n,r)}},t.onFragBuffered=function(e,t){this.detectPartialFragments(t)},t.hasFragment=function(e){var t=Mr(e);return!!this.fragments[t]},t.hasParts=function(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)},t.removeFragmentsInRange=function(e,t,i,r,s){var a=this;r&&!this.hasGaps||Object.keys(this.fragments).forEach((function(n){var o=a.fragments[n];if(o){var l=o.body;l.type!==i||r&&!l.gap||l.start<t&&l.end>e&&(o.buffered||s)&&a.removeFragment(l)}}))},t.removeFragment=function(e){var t=Mr(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var i=this.activePartLists[e.type];if(i){var r=e.sn;this.activePartLists[e.type]=i.filter((function(e){return e.fragment.sn!==r}))}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},t.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},e}();function Br(e){var t,i,r;return e.buffered&&(e.body.gap||(null==(t=e.range.video)?void 0:t.partial)||(null==(i=e.range.audio)?void 0:i.partial)||(null==(r=e.range.audiovideo)?void 0:r.partial))}function Mr(e){return e.type+"_"+e.level+"_"+e.sn}var Ur={length:0,start:function(){return 0},end:function(){return 0}},Fr=function(){function e(){}return e.isBuffered=function(t,i){if(t)for(var r=e.getBuffered(t),s=r.length;s--;)if(i>=r.start(s)&&i<=r.end(s))return!0;return!1},e.bufferInfo=function(t,i,r){if(t){var s=e.getBuffered(t);if(s.length){for(var a=[],n=0;n<s.length;n++)a.push({start:s.start(n),end:s.end(n)});return e.bufferedInfo(a,i,r)}}return{len:0,start:i,end:i,nextStart:void 0}},e.bufferedInfo=function(e,t,i){t=Math.max(0,t),e.sort((function(e,t){return e.start-t.start||t.end-e.end}));var r=[];if(i)for(var s=0;s<e.length;s++){var a=r.length;if(a){var n=r[a-1].end;e[s].start-n<i?e[s].end>n&&(r[a-1].end=e[s].end):r.push(e[s])}else r.push(e[s])}else r=e;for(var o,l=0,d=t,h=t,c=0;c<r.length;c++){var u=r[c].start,p=r[c].end;if(t+i>=u&&t<p)d=u,l=(h=p)-t;else if(t+i<u){o=u;break}}return{len:l,start:d||0,end:h||0,nextStart:o}},e.getBuffered=function(e){try{return e.buffered||Ur}catch(e){return G.log("failed to get media.buffered",e),Ur}},e}(),Or=function(e,t,i,r,s,a){void 0===r&&(r=0),void 0===s&&(s=-1),void 0===a&&(a=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=Nr(),this.buffering={audio:Nr(),video:Nr(),audiovideo:Nr()},this.level=e,this.sn=t,this.id=i,this.size=r,this.part=s,this.partial=a};function Nr(){return{start:0,executeStart:0,executeEnd:0,end:0}}function Gr(e,t){for(var i=0,r=e.length;i<r;i++){var s;if((null==(s=e[i])?void 0:s.cc)===t)return e[i]}return null}function zr(e,t,i){return!(!t||!(i.endCC>i.startCC||e&&e.cc<i.startCC))}function Wr(e,t){var i=e.fragments,r=t.fragments;if(r.length&&i.length){var s=Gr(i,r[0].cc);if(s&&(!s||s.startPTS))return s;G.log("No frag in previous level to align on")}else G.log("No fragments to align")}function Vr(e,t){if(e){var i=e.start+t;e.start=e.startPTS=i,e.endPTS=i+e.duration}}function Hr(e,t){for(var i=t.fragments,r=0,s=i.length;r<s;r++)Vr(i[r],e);t.fragmentHint&&Vr(t.fragmentHint,e),t.alignedSliding=!0}function $r(e,t,i){t&&(jr(e,i,t),!i.alignedSliding&&t&&Kr(i,t),i.alignedSliding||!t||i.skippedSegments||Wi(t,i))}function jr(e,t,i){if(zr(e,i,t)){var r=Wr(i,t);r&&E(r.start)&&(G.log("Adjusting PTS using last level due to CC increase within current level "+t.url),Hr(r.start,t))}}function Kr(e,t){if(e.hasProgramDateTime&&t.hasProgramDateTime){var i=e.fragments,r=t.fragments;if(i.length&&r.length){var s,a,n=Math.min(t.endCC,e.endCC);t.startCC<n&&e.startCC<n&&(s=Gr(r,n),a=Gr(i,n)),s&&a||(a=Gr(i,(s=r[Math.floor(r.length/2)]).cc)||i[Math.floor(i.length/2)]);var o=s.programDateTime,l=a.programDateTime;o&&l&&Hr((l-o)/1e3-(a.start-s.start),e)}}}var qr=Math.pow(2,17),Yr=function(){function e(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var t=e.prototype;return t.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},t.abort=function(){this.loader&&this.loader.abort()},t.load=function(e,t){var i=this,r=e.url;if(!r)return Promise.reject(new Zr({type:C.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(r?"part list":"url")),networkDetails:null}));this.abort();var s=this.config,n=s.fLoader,o=s.loader;return new Promise((function(l,d){if(i.loader&&i.loader.destroy(),e.gap){if(e.tagList.some((function(e){return"GAP"===e[0]})))return void d(Xr(e));e.gap=!1}var h=i.loader=e.loader=n?new n(s):new o(s),c=Qr(e),u=Ji(s.fragLoadPolicy.default),p={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:qr};e.stats=h.stats,h.load(c,p,{onSuccess:function(t,r,s,a){i.resetLoader(e,h);var n=t.data;s.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(n.slice(0,16)),n=n.slice(16)),l({frag:e,part:null,payload:n,networkDetails:a})},onError:function(t,s,n,o){i.resetLoader(e,h),d(new Zr({type:C.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:a({url:r,data:void 0},t),error:new Error("HTTP Error "+t.code+" "+t.text),networkDetails:n,stats:o}))},onAbort:function(t,r,s){i.resetLoader(e,h),d(new Zr({type:C.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:s,stats:t}))},onTimeout:function(t,r,s){i.resetLoader(e,h),d(new Zr({type:C.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after "+p.timeout+"ms"),networkDetails:s,stats:t}))},onProgress:function(i,r,s,a){t&&t({frag:e,part:null,payload:s,networkDetails:a})}})}))},t.loadPart=function(e,t,i){var r=this;this.abort();var s=this.config,n=s.fLoader,o=s.loader;return new Promise((function(l,d){if(r.loader&&r.loader.destroy(),e.gap||t.gap)d(Xr(e,t));else{var h=r.loader=e.loader=n?new n(s):new o(s),c=Qr(e,t),u=Ji(s.fragLoadPolicy.default),p={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:qr};t.stats=h.stats,h.load(c,p,{onSuccess:function(s,a,n,o){r.resetLoader(e,h),r.updateStatsFromPart(e,t);var d={frag:e,part:t,payload:s.data,networkDetails:o};i(d),l(d)},onError:function(i,s,n,o){r.resetLoader(e,h),d(new Zr({type:C.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:a({url:c.url,data:void 0},i),error:new Error("HTTP Error "+i.code+" "+i.text),networkDetails:n,stats:o}))},onAbort:function(i,s,a){e.stats.aborted=t.stats.aborted,r.resetLoader(e,h),d(new Zr({type:C.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:a,stats:i}))},onTimeout:function(i,s,a){r.resetLoader(e,h),d(new Zr({type:C.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after "+p.timeout+"ms"),networkDetails:a,stats:i}))}})}}))},t.updateStatsFromPart=function(e,t){var i=e.stats,r=t.stats,s=r.total;if(i.loaded+=r.loaded,s){var a=Math.round(e.duration/t.duration),n=Math.min(Math.round(i.loaded/s),a),o=(a-n)*Math.round(i.loaded/n);i.total=i.loaded+o}else i.total=Math.max(i.loaded,i.total);var l=i.loading,d=r.loading;l.start?l.first+=d.first-d.start:(l.start=d.start,l.first=d.first),l.end=d.end},t.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},e}();function Qr(e,t){void 0===t&&(t=null);var i=t||e,r={frag:e,part:t,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},s=i.byteRangeStartOffset,a=i.byteRangeEndOffset;if(E(s)&&E(a)){var n,o=s,l=a;if("initSegment"===e.sn&&Jr(null==(n=e.decryptdata)?void 0:n.method)){var d=a-s;d%16&&(l=a+(16-d%16)),0!==s&&(r.resetIV=!0,o=s-16)}r.rangeStart=o,r.rangeEnd=l}return r}function Xr(e,t){var i=new Error("GAP "+(e.gap?"tag":"attribute")+" found"),r={type:C.MEDIA_ERROR,details:D.FRAG_GAP,fatal:!1,frag:e,error:i,networkDetails:null};return t&&(r.part=t),(t||e).stats.aborted=!0,new Zr(r)}function Jr(e){return"AES-128"===e||"AES-256"===e}var Zr=function(e){function t(t){var i;return(i=e.call(this,t.error.message)||this).data=void 0,i.data=t,i}return u(t,e),t}(m(Error)),es=function(){function e(e,t,i){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=i}return e.prototype.decrypt=function(e,t){switch(this.aesMode){case ie.cbc:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case ie.ctr:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error("[AESCrypto] invalid aes mode "+this.aesMode)}},e}(),ts=function(){function e(e,t,i){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=e,this.key=t,this.aesMode=i}return e.prototype.expandKey=function(){var e=is(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])},e}();function is(e){switch(e){case ie.cbc:return"AES-CBC";case ie.ctr:return"AES-CTR";default:throw new Error("[FastAESKey] invalid aes mode "+e)}}function rs(e){var t=e.byteLength,i=t&&new DataView(e.buffer).getUint8(t-1);return i?ge(e,0,t-i):e}var ss=function(){function e(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var t=e.prototype;return t.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),i=new Uint32Array(4),r=0;r<4;r++)i[r]=t.getUint32(4*r);return i},t.initTable=function(){var e=this.sBox,t=this.invSBox,i=this.subMix,r=i[0],s=i[1],a=i[2],n=i[3],o=this.invSubMix,l=o[0],d=o[1],h=o[2],c=o[3],u=new Uint32Array(256),p=0,f=0,y=0;for(y=0;y<256;y++)u[y]=y<128?y<<1:y<<1^283;for(y=0;y<256;y++){var m=f^f<<1^f<<2^f<<3^f<<4;m=m>>>8^255&m^99,e[p]=m,t[m]=p;var g=u[p],A=u[g],v=u[A],b=257*u[m]^16843008*m;r[p]=b<<24|b>>>8,s[p]=b<<16|b>>>16,a[p]=b<<8|b>>>24,n[p]=b,b=16843009*v^65537*A^257*g^16843008*p,l[m]=b<<24|b>>>8,d[m]=b<<16|b>>>16,h[m]=b<<8|b>>>24,c[m]=b,p?(p=g^u[u[u[v^g]]],f^=u[u[f]]):p=f=1}},t.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),i=!0,r=0;r<t.length&&i;)i=t[r]===this.key[r],r++;if(!i){this.key=t;var s=this.keySize=t.length;if(4!==s&&6!==s&&8!==s)throw new Error("Invalid aes key size="+s);var a,n,o,l,d=this.ksRows=4*(s+6+1),h=this.keySchedule=new Uint32Array(d),c=this.invKeySchedule=new Uint32Array(d),u=this.sBox,p=this.rcon,f=this.invSubMix,y=f[0],m=f[1],g=f[2],A=f[3];for(a=0;a<d;a++)a<s?o=h[a]=t[a]:(l=o,a%s==0?(l=u[(l=l<<8|l>>>24)>>>24]<<24|u[l>>>16&255]<<16|u[l>>>8&255]<<8|u[255&l],l^=p[a/s|0]<<24):s>6&&a%s==4&&(l=u[l>>>24]<<24|u[l>>>16&255]<<16|u[l>>>8&255]<<8|u[255&l]),h[a]=o=(h[a-s]^l)>>>0);for(n=0;n<d;n++)a=d-n,l=3&n?h[a]:h[a-4],c[n]=n<4||a<=4?l:y[u[l>>>24]]^m[u[l>>>16&255]]^g[u[l>>>8&255]]^A[u[255&l]],c[n]=c[n]>>>0}},t.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},t.decrypt=function(e,t,i){for(var r,s,a,n,o,l,d,h,c,u,p,f,y,m,g=this.keySize+6,A=this.invKeySchedule,v=this.invSBox,b=this.invSubMix,_=b[0],w=b[1],E=b[2],S=b[3],T=this.uint8ArrayToUint32Array_(i),k=T[0],C=T[1],D=T[2],R=T[3],x=new Int32Array(e),L=new Int32Array(x.length),I=this.networkToHostOrderSwap;t<x.length;){for(c=I(x[t]),u=I(x[t+1]),p=I(x[t+2]),f=I(x[t+3]),o=c^A[0],l=f^A[1],d=p^A[2],h=u^A[3],y=4,m=1;m<g;m++)r=_[o>>>24]^w[l>>16&255]^E[d>>8&255]^S[255&h]^A[y],s=_[l>>>24]^w[d>>16&255]^E[h>>8&255]^S[255&o]^A[y+1],a=_[d>>>24]^w[h>>16&255]^E[o>>8&255]^S[255&l]^A[y+2],n=_[h>>>24]^w[o>>16&255]^E[l>>8&255]^S[255&d]^A[y+3],o=r,l=s,d=a,h=n,y+=4;r=v[o>>>24]<<24^v[l>>16&255]<<16^v[d>>8&255]<<8^v[255&h]^A[y],s=v[l>>>24]<<24^v[d>>16&255]<<16^v[h>>8&255]<<8^v[255&o]^A[y+1],a=v[d>>>24]<<24^v[h>>16&255]<<16^v[o>>8&255]<<8^v[255&l]^A[y+2],n=v[h>>>24]<<24^v[o>>16&255]<<16^v[l>>8&255]<<8^v[255&d]^A[y+3],L[t]=I(r^k),L[t+1]=I(n^C),L[t+2]=I(a^D),L[t+3]=I(s^R),k=c,C=u,D=p,R=f,t+=4}return L.buffer},e}(),as=16,ns=function(){function e(e,t){var i=(void 0===t?{}:t).removePKCS7Padding,r=void 0===i||i;if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=e.enableSoftwareAES,this.removePKCS7Padding=r,r)try{var s=self.crypto;s&&(this.subtle=s.subtle||s.webkitSubtle)}catch(e){}this.useSoftware=null===this.subtle}var t=e.prototype;return t.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},t.isSync=function(){return this.useSoftware},t.flush=function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var i=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?rs(i):i},t.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},t.decrypt=function(e,t,i,r){var s=this;return this.useSoftware?new Promise((function(a,n){s.softwareDecrypt(new Uint8Array(e),t,i,r);var o=s.flush();o?a(o.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(e),t,i,r)},t.softwareDecrypt=function(e,t,i,r){var s=this.currentIV,a=this.currentResult,n=this.remainderData;if(r!==ie.cbc||16!==t.byteLength)return G.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),n&&(e=He(n,e),this.remainderData=null);var o=this.getValidChunk(e);if(!o.length)return null;s&&(i=s);var l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new ss),l.expandKey(t);var d=a;return this.currentResult=l.decrypt(o.buffer,0,i),this.currentIV=ge(o,-16).buffer,d||null},t.webCryptoDecrypt=function(e,t,i,r){var s=this,a=this.subtle;return this.key===t&&this.fastAesKey||(this.key=t,this.fastAesKey=new ts(a,t,r)),this.fastAesKey.expandKey().then((function(t){return a?(s.logOnce("WebCrypto AES decrypt"),new es(a,new Uint8Array(i),r).decrypt(e.buffer,t)):Promise.reject(new Error("web crypto not initialized"))})).catch((function(a){return G.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+a.name+": "+a.message),s.onWebCryptoError(e,t,i,r)}))},t.onWebCryptoError=function(e,t,i,r){var s=this.enableSoftwareAES;if(s){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i,r);var a=this.flush();if(a)return a.buffer}throw new Error("WebCrypto"+(s?" and softwareDecrypt":"")+": failed to decrypt data")},t.getValidChunk=function(e){var t=e,i=e.length-e.length%as;return i!==e.length&&(t=ge(e,0,i),this.remainderData=ge(e,i)),t},t.logOnce=function(e){this.logEnabled&&(G.log("[decrypter]: "+e),this.logEnabled=!1)},e}(),os={toString:function(e){for(var t="",i=e.length,r=0;r<i;r++)t+="["+e.start(r).toFixed(3)+"-"+e.end(r).toFixed(3)+"]";return t}},ls={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},ds=function(e){function t(t,i,r,s,a){var n;return(n=e.call(this,s,t.logger)||this).hls=void 0,n.fragPrevious=null,n.fragCurrent=null,n.fragmentTracker=void 0,n.transmuxer=null,n._state=ls.STOPPED,n.playlistType=void 0,n.media=null,n.mediaBuffer=null,n.config=void 0,n.bitrateTest=!1,n.lastCurrentTime=0,n.nextLoadPosition=0,n.startPosition=0,n.startTimeOffset=null,n.loadedmetadata=!1,n.retryDate=0,n.levels=null,n.fragmentLoader=void 0,n.keyLoader=void 0,n.levelLastLoaded=null,n.startFragRequested=!1,n.decrypter=void 0,n.initPTS=[],n.buffering=!0,n.loadingParts=!1,n.onMediaSeeking=function(){var e=n,t=e.config,i=e.fragCurrent,r=e.media,s=e.mediaBuffer,a=e.state,o=r?r.currentTime:0,l=Fr.bufferInfo(s||r,o,t.maxBufferHole);if(n.log("media seeking to "+(E(o)?o.toFixed(3):o)+", state: "+a),n.state===ls.ENDED)n.resetLoadingState();else if(i){var d=t.maxFragLookUpTolerance,h=i.start-d,c=i.start+i.duration+d;if(!l.len||c<l.start||h>l.end){var u=o>c;(o<h||u)&&(u&&i.loader&&(n.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),i.abortRequests(),n.resetLoadingState()),n.fragPrevious=null)}}if(r&&(n.fragmentTracker.removeFragmentsInRange(o,1/0,n.playlistType,!0),n.lastCurrentTime=o,!n.loadingParts)){var p=Math.max(l.end,o),f=n.shouldLoadParts(n.getLevelDetails(),p);f&&(n.log("LL-Part loading ON after seeking to "+o.toFixed(2)+" with buffer @"+p.toFixed(2)),n.loadingParts=f)}n.loadedmetadata||l.len||(n.nextLoadPosition=n.startPosition=o),n.tickImmediate()},n.onMediaEnded=function(){n.startPosition=n.lastCurrentTime=0,n.playlistType===Nt.MAIN&&n.hls.trigger(k.MEDIA_ENDED,{stalled:!1})},n.playlistType=a,n.hls=t,n.fragmentLoader=new Yr(t.config),n.keyLoader=r,n.fragmentTracker=i,n.config=t.config,n.decrypter=new ns(t.config),n}u(t,e);var i=t.prototype;return i.registerListeners=function(){var e=this.hls;e.on(k.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(k.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(k.MANIFEST_LOADING,this.onManifestLoading,this),e.on(k.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(k.ERROR,this.onError,this)},i.unregisterListeners=function(){var e=this.hls;e.off(k.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(k.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(k.MANIFEST_LOADING,this.onManifestLoading,this),e.off(k.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(k.ERROR,this.onError,this)},i.doTick=function(){this.onTickEnd()},i.onTickEnd=function(){},i.startLoad=function(e){},i.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=ls.STOPPED},i.pauseBuffering=function(){this.buffering=!1},i.resumeBuffering=function(){this.buffering=!0},i._streamEnded=function(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;var i=t.partList;if(null!=i&&i.length){var r=i[i.length-1];return Fr.isBuffered(this.media,r.start+r.duration/2)}var s=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(s)},i.getLevelDetails=function(){var e;if(this.levels&&null!==this.levelLastLoaded)return null==(e=this.levelLastLoaded)?void 0:e.details},i.onMediaAttached=function(e,t){var i=this.media=this.mediaBuffer=t.media;i.addEventListener("seeking",this.onMediaSeeking),i.addEventListener("ended",this.onMediaEnded);var r=this.config;this.levels&&r.autoStartLoad&&this.state===ls.STOPPED&&this.startLoad(r.startPosition)},i.onMediaDetaching=function(){var e=this.media;null!=e&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&(e.removeEventListener("seeking",this.onMediaSeeking),e.removeEventListener("ended",this.onMediaEnded)),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},i.onManifestLoading=function(){},i.onError=function(e,t){},i.onManifestLoaded=function(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]},i.onHandlerDestroying=function(){this.stopLoad(),e.prototype.onHandlerDestroying.call(this),this.hls=this.onMediaSeeking=this.onMediaEnded=null},i.onHandlerDestroyed=function(){this.state=ls.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,e.prototype.onHandlerDestroyed.call(this)},i.loadFragment=function(e,t,i){this._loadFragForPlayback(e,t,i)},i._loadFragForPlayback=function(e,t,i){var r=this,s=function(t){if(r.fragContextChanged(e))return r.warn("Fragment "+e.sn+(t.part?" p: "+t.part.index:"")+" of level "+e.level+" was dropped during download."),void r.fragmentTracker.removeFragment(e);e.stats.chunkCount++,r._handleFragmentLoadProgress(t)};this._doFragLoad(e,t,i,s).then((function(t){if(t){var i=r.state;r.fragContextChanged(e)?(i===ls.FRAG_LOADING||!r.fragCurrent&&i===ls.PARSING)&&(r.fragmentTracker.removeFragment(e),r.state=ls.IDLE):("payload"in t&&(r.log("Loaded fragment "+e.sn+" of level "+e.level),r.hls.trigger(k.FRAG_LOADED,t)),r._handleFragmentLoadComplete(t))}})).catch((function(t){r.state!==ls.STOPPED&&r.state!==ls.ERROR&&(r.warn(t),r.resetFragmentLoading(e))}))},i.clearTrackerIfNeeded=function(e){var t,i=this.fragmentTracker;if(i.getState(e)===Ir.APPENDING){var r=e.type,s=this.getFwdBufferInfo(this.mediaBuffer,r),a=Math.max(e.duration,s?s.len:this.config.maxBufferLength);this.reduceMaxBufferLength(a)&&i.removeFragment(e)}else 0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===Ir.PARTIAL&&i.removeFragment(e))},i.checkLiveUpdate=function(e){if(e.updated&&!e.live){var t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)},i.flushMainBuffer=function(e,t,i){if(void 0===i&&(i=null),e-t){var r={startOffset:e,endOffset:t,type:i};this.hls.trigger(k.BUFFER_FLUSHING,r)}},i._loadInitSegment=function(e,t){var i=this;this._doFragLoad(e,t).then((function(t){if(!t||i.fragContextChanged(e)||!i.levels)throw new Error("init load aborted");return t})).then((function(t){var r=i.hls,s=t.payload,a=e.decryptdata;if(s&&s.byteLength>0&&null!=a&&a.key&&a.iv&&re(a.method)){var n=self.performance.now();return i.decrypter.decrypt(new Uint8Array(s),a.key.buffer,a.iv.buffer,se(a.method)).catch((function(t){throw r.trigger(k.ERROR,{type:C.MEDIA_ERROR,details:D.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:e}),t})).then((function(s){var a=self.performance.now();return r.trigger(k.FRAG_DECRYPTED,{frag:e,payload:s,stats:{tstart:n,tdecrypt:a}}),t.payload=s,i.completeInitSegmentLoad(t)}))}return i.completeInitSegmentLoad(t)})).catch((function(t){i.state!==ls.STOPPED&&i.state!==ls.ERROR&&(i.warn(t),i.resetFragmentLoading(e))}))},i.completeInitSegmentLoad=function(e){if(!this.levels)throw new Error("init load aborted, missing levels");var t=e.frag.stats;this.state!==ls.STOPPED&&(this.state=ls.IDLE),e.frag.data=new Uint8Array(e.payload),t.parsing.start=t.buffering.start=self.performance.now(),t.parsing.end=t.buffering.end=self.performance.now(),this.tick()},i.fragContextChanged=function(e){var t=this.fragCurrent;return!e||!t||e.sn!==t.sn||e.level!==t.level},i.fragBufferedComplete=function(e,t){var i,r,s,a,n=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered "+e.type+" sn: "+e.sn+(t?" part: "+t.index:"")+" of "+(this.playlistType===Nt.MAIN?"level":"track")+" "+e.level+" (frag:["+(null!=(i=e.startPTS)?i:NaN).toFixed(3)+"-"+(null!=(r=e.endPTS)?r:NaN).toFixed(3)+"] > buffer:"+(n?os.toString(Fr.getBuffered(n)):"(detached)")+")"),"initSegment"!==e.sn){var o;if(e.type!==Nt.SUBTITLE){var l=e.elementaryStreams;if(!Object.keys(l).some((function(e){return!!l[e]})))return void(this.state=ls.IDLE)}var d=null==(o=this.levels)?void 0:o[e.level];null!=d&&d.fragmentError&&(this.log("Resetting level fragment error count of "+d.fragmentError+" on frag buffered"),d.fragmentError=0)}this.state=ls.IDLE,n&&(!this.loadedmetadata&&e.type==Nt.MAIN&&n.buffered.length&&(null==(s=this.fragCurrent)?void 0:s.sn)===(null==(a=this.fragPrevious)?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},i.seekToStartPos=function(){},i._handleFragmentLoadComplete=function(e){var t=this.transmuxer;if(t){var i=e.frag,r=e.part,s=e.partsLoaded,a=!s||0===s.length||s.some((function(e){return!e})),n=new Or(i.level,i.sn,i.stats.chunkCount+1,0,r?r.index:-1,!a);t.flush(n)}},i._handleFragmentLoadProgress=function(e){},i._doFragLoad=function(e,t,i,r){var s,a=this;void 0===i&&(i=null);var n=null==t?void 0:t.details;if(!this.levels||!n)throw new Error("frag load aborted, missing level"+(n?"":" detail")+"s");var o=null;!e.encrypted||null!=(s=e.decryptdata)&&s.key?!e.encrypted&&n.encryptedFragments.length&&this.keyLoader.loadClear(e,n.encryptedFragments):(this.log("Loading key for "+e.sn+" of ["+n.startSN+"-"+n.endSN+"], "+(this.playlistType===Nt.MAIN?"level":"track")+" "+e.level),this.state=ls.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then((function(e){if(!a.fragContextChanged(e.frag))return a.hls.trigger(k.KEY_LOADED,e),a.state===ls.KEY_LOADING&&(a.state=ls.IDLE),e})),this.hls.trigger(k.KEY_LOADING,{frag:e}),null===this.fragCurrent&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING"))));var l=this.fragPrevious;if("initSegment"!==e.sn&&(!l||e.sn!==l.sn)){var d=this.shouldLoadParts(t.details,e.end);d!==this.loadingParts&&(this.log("LL-Part loading "+(d?"ON":"OFF")+" loading sn "+(null==l?void 0:l.sn)+"->"+e.sn),this.loadingParts=d)}if(i=Math.max(e.start,i||0),this.loadingParts&&"initSegment"!==e.sn){var h=n.partList;if(h&&r){i>e.end&&n.fragmentHint&&(e=n.fragmentHint);var c=this.getNextPart(h,e,i);if(c>-1){var u,p=h[c];return this.log("Loading part sn: "+e.sn+" p: "+p.index+" cc: "+e.cc+" of playlist ["+n.startSN+"-"+n.endSN+"] parts [0-"+c+"-"+(h.length-1)+"] "+(this.playlistType===Nt.MAIN?"level":"track")+": "+e.level+", target: "+parseFloat(i.toFixed(3))),this.nextLoadPosition=p.start+p.duration,this.state=ls.FRAG_LOADING,u=o?o.then((function(i){return!i||a.fragContextChanged(i.frag)?null:a.doFragPartsLoad(e,p,t,r)})).catch((function(e){return a.handleFragLoadError(e)})):this.doFragPartsLoad(e,p,t,r).catch((function(e){return a.handleFragLoadError(e)})),this.hls.trigger(k.FRAG_LOADING,{frag:e,part:p,targetBufferTime:i}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):u}if(!e.url||this.loadedEndOfParts(h,i))return Promise.resolve(null)}}if("initSegment"!==e.sn&&this.loadingParts)this.log("LL-Part loading OFF after next part miss @"+i.toFixed(2)),this.loadingParts=!1;else if(!e.url)return Promise.resolve(null);this.log("Loading fragment "+e.sn+" cc: "+e.cc+" "+(n?"of ["+n.startSN+"-"+n.endSN+"] ":"")+(this.playlistType===Nt.MAIN?"level":"track")+": "+e.level+", target: "+parseFloat(i.toFixed(3))),E(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=ls.FRAG_LOADING;var f,y=this.config.progressive;return f=y&&o?o.then((function(t){return!t||a.fragContextChanged(null==t?void 0:t.frag)?null:a.fragmentLoader.load(e,r)})).catch((function(e){return a.handleFragLoadError(e)})):Promise.all([this.fragmentLoader.load(e,y?r:void 0),o]).then((function(e){var t=e[0];return!y&&t&&r&&r(t),t})).catch((function(e){return a.handleFragLoadError(e)})),this.hls.trigger(k.FRAG_LOADING,{frag:e,targetBufferTime:i}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):f},i.doFragPartsLoad=function(e,t,i,r){var s=this;return new Promise((function(a,n){var o,l=[],d=null==(o=i.details)?void 0:o.partList;!function t(o){s.fragmentLoader.loadPart(e,o,r).then((function(r){l[o.index]=r;var n=r.part;s.hls.trigger(k.FRAG_LOADED,r);var h=ji(i,e.sn,o.index+1)||Ki(d,e.sn,o.index+1);if(!h)return a({frag:e,part:n,partsLoaded:l});t(h)})).catch(n)}(t)}))},i.handleFragLoadError=function(e){if("data"in e){var t=e.data;e.data&&t.details===D.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(k.ERROR,t)}else this.hls.trigger(k.ERROR,{type:C.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null},i._handleTransmuxerFlush=function(e){var t=this.getCurrentContext(e);if(t&&this.state===ls.PARSING){var i=t.frag,r=t.part,s=t.level,a=self.performance.now();if(i.stats.parsing.end=a,r&&(r.stats.parsing.end=a),"initSegment"!==i.sn){var n=this.getLevelDetails(),o=n&&i.sn>n.endSN||this.shouldLoadParts(n,i.end);o!==this.loadingParts&&(this.log("LL-Part loading "+(o?"ON":"OFF")+" after parsing segment ending @"+i.end.toFixed(2)),this.loadingParts=o)}this.updateLevelTiming(i,r,s,e.partial)}else this.fragCurrent||this.state===ls.STOPPED||this.state===ls.ERROR||(this.state=ls.IDLE)},i.shouldLoadParts=function(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(null!=e&&e.partList){var i,r=e.partList[0];if(t>=r.end+((null==(i=e.fragmentHint)?void 0:i.duration)||0)&&this.lastCurrentTime>r.start-r.fragment.duration)return!0}}return!1},i.getCurrentContext=function(e){var t=this.levels,i=this.fragCurrent,r=e.level,s=e.sn,a=e.part;if(null==t||!t[r])return this.warn("Levels object was unset while buffering fragment "+s+" of level "+r+". The current chunk will not be buffered."),null;var n=t[r],o=a>-1?ji(n,s,a):null,l=o?o.fragment:$i(n,s,i);return l?(i&&i!==l&&(l.stats=i.stats),{frag:l,part:o,level:n}):null},i.bufferFragmentData=function(e,t,i,r,s){var a;if(e&&this.state===ls.PARSING){var n=e.data1,o=e.data2,l=n;if(n&&o&&(l=He(n,o)),null!=(a=l)&&a.length){var d={type:e.type,frag:t,part:i,chunkMeta:r,parent:t.type,data:l};if(this.hls.trigger(k.BUFFER_APPENDING,d),e.dropped&&e.independent&&!i){if(s)return;this.flushBufferGap(t)}}}},i.flushBufferGap=function(e){var t=this.media;if(t)if(Fr.isBuffered(t,t.currentTime)){var i=t.currentTime,r=Fr.bufferInfo(t,i,0),s=e.duration,a=Math.min(2*this.config.maxFragLookUpTolerance,.25*s),n=Math.max(Math.min(e.start-a,r.end-a),i+a);e.start-n>a&&this.flushMainBuffer(n,e.start)}else this.flushMainBuffer(0,e.start)},i.getFwdBufferInfo=function(e,t){var i=this.getLoadPosition();return E(i)?this.getFwdBufferInfoAtPos(e,i,t):null},i.getFwdBufferInfoAtPos=function(e,t,i){var r=this.config.maxBufferHole,s=Fr.bufferInfo(e,t,r);if(0===s.len&&void 0!==s.nextStart){var a=this.fragmentTracker.getBufferedFrag(t,i);if(a&&(s.nextStart<=a.end||a.gap))return Fr.bufferInfo(e,t,Math.max(s.nextStart,r))}return s},i.getMaxBufferLength=function(e){var t,i=this.config;return t=e?Math.max(8*i.maxBufferSize/e,i.maxBufferLength):i.maxBufferLength,Math.min(t,i.maxMaxBufferLength)},i.reduceMaxBufferLength=function(e){var t=this.config,i=e||t.maxBufferLength;return t.maxMaxBufferLength>=i&&(t.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+t.maxMaxBufferLength+"s"),!0)},i.getAppendedFrag=function(e,t){var i=this.fragmentTracker.getAppendedFrag(e,Nt.MAIN);return i&&"fragment"in i?i.fragment:i},i.getNextFragment=function(e,t){var i=t.fragments,r=i.length;if(!r)return null;var s=this.config,a=i[0].start,n=s.lowLatencyMode&&!!t.partList,o=null;if(t.live){var l=s.initialLiveManifestSize;if(r<l)return this.warn("Not enough fragments to start playback (have: "+r+", need: "+l+")"),null;(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<a)&&(n&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),o=this.getInitialLiveFragment(t,i),this.startPosition=this.nextLoadPosition=o?this.hls.liveSyncPosition||o.start:e)}else e<=a&&(o=i[0]);if(!o){var d=this.loadingParts?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,d,t)}return this.mapToInitFragWhenRequired(o)},i.isLoopLoading=function(e,t){var i=this.fragmentTracker.getState(e);return(i===Ir.OK||i===Ir.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t},i.getNextFragmentLoopLoading=function(e,t,i,r,s){var a=e.gap,n=this.getNextFragment(this.nextLoadPosition,t);if(null===n)return n;if(e=n,a&&e&&!e.gap&&i.nextStart){var o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,r);if(null!==o&&i.len+o.len>=s)return this.log('buffer full after gaps in "'+r+'" playlist starting at sn: '+e.sn),null}return e},i.mapToInitFragWhenRequired=function(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment},i.getNextPart=function(e,t,i){for(var r=-1,s=!1,a=!0,n=0,o=e.length;n<o;n++){var l=e[n];if(a=a&&!l.independent,r>-1&&i<l.start)break;var d=l.loaded;d?r=-1:(s||l.independent||a)&&l.fragment===t&&(r=n),s=d}return r},i.loadedEndOfParts=function(e,t){var i=e[e.length-1];return i&&t>i.start&&i.loaded},i.getInitialLiveFragment=function(e,t){var i=this.fragPrevious,r=null;if(i){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+i.programDateTime),r=ir(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!r){var s=i.sn+1;if(s>=e.startSN&&s<=e.endSN){var a=t[s-e.startSN];i.cc===a.cc&&(r=a,this.log("Live playlist, switching playlist, load frag with next SN: "+r.sn))}r||(r=nr(t,i.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+r.sn)}}else{var n=this.hls.liveSyncPosition;null!==n&&(r=this.getFragmentAtPosition(n,this.bitrateTest?e.fragmentEnd:e.edge,e))}return r},i.getFragmentAtPosition=function(e,t,i){var r,s=this.config,a=this.fragPrevious,n=i.fragments,o=i.endSN,l=i.fragmentHint,d=s.maxFragLookUpTolerance,h=i.partList,c=!!(this.loadingParts&&null!=h&&h.length&&l);if(c&&l&&!this.bitrateTest&&(n=n.concat(l),o=l.sn),r=e<t?rr(a,n,e,e>t-d?0:d):n[n.length-1]){var u=r.sn-i.startSN,p=this.fragmentTracker.getState(r);if((p===Ir.OK||p===Ir.PARTIAL&&r.gap)&&(a=r),a&&r.sn===a.sn&&(!c||h[0].fragment.sn>r.sn)&&a&&r.level===a.level){var f=n[u+1];r=r.sn<o&&this.fragmentTracker.getState(f)!==Ir.OK?f:null}}return r},i.synchronizeToLiveEdge=function(e){var t=this.config,i=this.media;if(i){var r=this.hls.liveSyncPosition,s=i.currentTime,a=e.fragments[0].start,n=e.edge,o=s>=a-t.maxFragLookUpTolerance&&s<=n;if(null!==r&&i.duration>r&&(s<r||!o)){var l=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!o&&i.readyState<4||s<n-l)&&(this.loadedmetadata||(this.nextLoadPosition=r),i.readyState&&(this.warn("Playback: "+s.toFixed(3)+" is located too far from the end of live sliding playlist: "+n+", reset currentTime to : "+r.toFixed(3)),i.currentTime=r))}}},i.alignPlaylists=function(e,t,i){var r=e.fragments.length;if(!r)return this.warn("No fragments in live playlist"),0;var s=e.fragments[0].start,a=!t,n=e.alignedSliding&&E(s);if(a||!n&&!s){var o=this.fragPrevious;$r(o,i,e);var l=e.fragments[0].start;return this.log("Live playlist sliding: "+l.toFixed(2)+" start-sn: "+(t?t.startSN:"na")+"->"+e.startSN+" prev-sn: "+(o?o.sn:"na")+" fragments: "+r),l}return s},i.waitForCdnTuneIn=function(e){var t=3;return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*t)},i.setStartPosition=function(e,t){var i=this.startPosition;if(i<t&&(i=-1),-1===i||-1===this.lastCurrentTime){var r=null!==this.startTimeOffset,s=r?this.startTimeOffset:e.startTimeOffset;null!==s&&E(s)?(i=t+s,s<0&&(i+=e.totalduration),i=Math.min(Math.max(t,i),t+e.totalduration),this.log("Start time offset "+s+" found in "+(r?"multivariant":"media")+" playlist, adjust startPosition to "+i),this.startPosition=i):e.live?i=this.hls.liveSyncPosition||t:this.startPosition=i=0,this.lastCurrentTime=i}this.nextLoadPosition=i},i.getLoadPosition=function(){var e=this.media,t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t},i.handleFragLoadAborted=function(e,t){this.transmuxer&&"initSegment"!==e.sn&&e.stats.aborted&&(this.warn("Fragment "+e.sn+(t?" part "+t.index:"")+" of level "+e.level+" was aborted"),this.resetFragmentLoading(e))},i.resetFragmentLoading=function(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===ls.FRAG_LOADING_WAITING_RETRY)||(this.state=ls.IDLE)},i.onFragmentOrKeyLoadError=function(e,t){if(t.chunkMeta&&!t.frag){var i=this.getCurrentContext(t.chunkMeta);i&&(t.frag=i.frag)}var r=t.frag;if(r&&r.type===e&&this.levels)if(this.fragContextChanged(r)){var s;this.warn("Frag load error must match current frag to retry "+r.url+" > "+(null==(s=this.fragCurrent)?void 0:s.url))}else{var a=t.details===D.FRAG_GAP;a&&this.fragmentTracker.fragBuffered(r,!0);var n=t.errorAction,o=n||{},l=o.action,d=o.retryCount,h=void 0===d?0:d,c=o.retryConfig;if(n&&l===or.RetryRequest&&c){this.resetStartWhenNotLoaded(this.levelLastLoaded);var u=Xi(c,h);this.warn("Fragment "+r.sn+" of "+e+" "+r.level+" errored with "+t.details+", retrying loading "+(h+1)+"/"+c.maxNumRetry+" in "+u+"ms"),n.resolved=!0,this.retryDate=self.performance.now()+u,this.state=ls.FRAG_LOADING_WAITING_RETRY}else if(c&&n){if(this.resetFragmentErrors(e),!(h<c.maxNumRetry))return void this.warn(t.details+" reached or exceeded max retry ("+h+")");a||l===or.RemoveAlternatePermanently||(n.resolved=!0)}else(null==n?void 0:n.action)===or.SendAlternateToPenaltyBox?this.state=ls.WAITING_LEVEL:this.state=ls.ERROR;this.tickImmediate()}},i.reduceLengthAndFlushBuffer=function(e){if(this.state===ls.PARSING||this.state===ls.PARSED){var t=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,t),r=i&&i.len>.5;r&&this.reduceMaxBufferLength(i.len);var s=!r;return s&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+t+" buffer"),e.frag&&(this.fragmentTracker.removeFragment(e.frag),this.nextLoadPosition=e.frag.start),this.resetLoadingState(),s}return!1},i.resetFragmentErrors=function(e){e===Nt.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==ls.STOPPED&&(this.state=ls.IDLE)},i.afterBufferFlushed=function(e,t,i){if(e){var r=Fr.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,r,i),this.state===ls.ENDED&&this.resetLoadingState()}},i.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==ls.STOPPED&&(this.state=ls.IDLE)},i.resetStartWhenNotLoaded=function(e){if(!this.loadedmetadata){this.startFragRequested=!1;var t=e?e.details:null;null!=t&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},i.resetWhenMissingContext=function(e){this.warn("The loading context changed while buffering fragment "+e.sn+" of level "+e.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()},i.removeUnbufferedFrags=function(e){void 0===e&&(e=0),this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)},i.updateLevelTiming=function(e,t,i,r){var s,a=this,n=i.details;if(n){if(!Object.keys(e.elementaryStreams).reduce((function(t,s){var o=e.elementaryStreams[s];if(o){var l=o.endPTS-o.startPTS;if(l<=0)return a.warn("Could not parse fragment "+e.sn+" "+s+" duration reliably ("+l+")"),t||!1;var d=r?0:Fi(n,e,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return a.hls.trigger(k.LEVEL_PTS_UPDATED,{details:n,level:i,drift:d,type:s,frag:e,start:o.startPTS,end:o.endPTS}),!0}return t}),!1)&&null===(null==(s=this.transmuxer)?void 0:s.error)){var o=new Error("Found no media in fragment "+e.sn+" of level "+e.level+" resetting transmuxer to fallback to playlist timing");if(0===i.fragmentError&&(i.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(o.message),this.hls.trigger(k.ERROR,{type:C.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:o,frag:e,reason:"Found no media in msn "+e.sn+' of level "'+i.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=ls.PARSED,this.hls.trigger(k.FRAG_PARSED,{frag:e,part:t})}else this.warn("level.details undefined")},i.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},i.recoverWorkerError=function(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())},d(t,[{key:"state",get:function(){return this._state},set:function(e){var t=this._state;t!==e&&(this._state=e,this.log(t+"->"+e))}}])}(Lr),hs=function(){function e(){this.chunks=[],this.dataLength=0}var t=e.prototype;return t.push=function(e){this.chunks.push(e),this.dataLength+=e.length},t.flush=function(){var e,t=this.chunks,i=this.dataLength;return t.length?(e=1===t.length?t[0]:cs(t,i),this.reset(),e):new Uint8Array(0)},t.reset=function(){this.chunks.length=0,this.dataLength=0},e}();function cs(e,t){for(var i=new Uint8Array(t),r=0,s=0;s<e.length;s++){var a=e[s];i.set(a,r),r+=a.length}return i}function us(e,t){return void 0===e&&(e=""),void 0===t&&(t=9e4),{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}function ps(e,t){for(var i=t,r=0;fi(e,t);)r+=10,r+=ci(e,t+6),pi(e,t+10)&&(r+=10),t+=r;if(r>0)return e.subarray(i,i+r)}function fs(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),i=1&t[3],r=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return r/=45,i&&(r+=47721858.84),Math.round(r)}}function ys(e){for(var t=gi(e),i=0;i<t.length;i++){var r=t[i];if(Ai(r))return fs(r)}}function ms(e,t){return fi(e,t)&&ci(e,t+6)+10<=e.length-t}var gs=function(){function e(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var t=e.prototype;return t.resetInitSegment=function(e,t,i,r){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},t.resetTimeStamp=function(e){this.initPTS=e,this.resetContiguity()},t.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},t.canParse=function(e,t){return!1},t.appendFrame=function(e,t,i){},t.demux=function(e,t){this.cachedData&&(e=He(this.cachedData,e),this.cachedData=null);var i,r=ps(e,0),s=r?r.length:0,a=this._audioTrack,n=this._id3Track,o=r?ys(r):void 0,l=e.length;for((null===this.basePTS||0===this.frameIndex&&E(o))&&(this.basePTS=As(o,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),r&&r.length>0&&n.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Qt.audioId3,duration:Number.POSITIVE_INFINITY});s<l;){if(this.canParse(e,s)){var d=this.appendFrame(a,e,s);d?(this.frameIndex++,this.lastPTS=d.sample.pts,i=s+=d.length):s=l}else ms(e,s)?(r=ps(e,s),n.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Qt.audioId3,duration:Number.POSITIVE_INFINITY}),i=s+=r.length):s++;if(s===l&&i!==l){var h=ge(e,i);this.cachedData?this.cachedData=He(this.cachedData,h):this.cachedData=h}}return{audioTrack:a,videoTrack:us(),id3Track:n,textTrack:us()}},t.demuxSampleAes=function(e,t,i){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},t.flush=function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:us(),id3Track:this._id3Track,textTrack:us()}},t.destroy=function(){},e}(),As=function(e,t,i){return E(e)?90*e:9e4*t+(i?9e4*i.baseTime/i.timescale:0)};function vs(e,t,i,r){var s,a,n,o,l,d=navigator.userAgent.toLowerCase(),h=r,c=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=a=1+((192&t[i+2])>>>6);var u=(60&t[i+2])>>>2;if(!(u>c.length-1))return o=(1&t[i+2])<<2,o|=(192&t[i+3])>>>6,G.log("manifest codec:"+r+", ADTS type:"+s+", samplingIndex:"+u),/firefox|palemoon/i.test(d)?u>=6?(s=5,l=new Array(4),n=u-3):(s=2,l=new Array(2),n=u):-1!==d.indexOf("android")?(s=2,l=new Array(2),n=u):(s=5,l=new Array(4),r&&(-1!==r.indexOf("mp4a.40.29")||-1!==r.indexOf("mp4a.40.5"))||!r&&u>=6?n=u-3:((r&&-1!==r.indexOf("mp4a.40.2")&&(u>=6&&1===o||/vivaldi/i.test(d))||!r&&1===o)&&(s=2,l=new Array(2)),n=u)),l[0]=s<<3,l[0]|=(14&u)>>1,l[1]|=(1&u)<<7,l[1]|=o<<3,5===s&&(l[1]|=(14&n)>>1,l[2]=(1&n)<<7,l[2]|=8,l[3]=0),{config:l,samplerate:c[u],channelCount:o,codec:"mp4a.40."+s,parsedCodec:"mp4a.40."+a,manifestCodec:h};var p=new Error("invalid ADTS sampling index:"+u);e.emit(k.ERROR,k.ERROR,{type:C.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!0,error:p,reason:p.message})}function bs(e,t){return 255===e[t]&&240==(246&e[t+1])}function _s(e,t){return 1&e[t+1]?7:9}function ws(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function Es(e,t){return t+5<e.length}function Ss(e,t){return t+1<e.length&&bs(e,t)}function Ts(e,t){return Es(e,t)&&bs(e,t)&&ws(e,t)<=e.length-t}function ks(e,t){if(Ss(e,t)){var i=_s(e,t);if(t+i>=e.length)return!1;var r=ws(e,t);if(r<=i)return!1;var s=t+r;return s===e.length||Ss(e,s)}return!1}function Cs(e,t,i,r,s){if(!e.samplerate){var a=vs(t,i,r,s);if(!a)return;e.config=a.config,e.samplerate=a.samplerate,e.channelCount=a.channelCount,e.codec=a.codec,e.manifestCodec=a.manifestCodec,e.parsedCodec=a.parsedCodec,G.log("parsed codec:"+e.parsedCodec+", codec:"+e.codec+", rate:"+a.samplerate+", channels:"+a.channelCount)}}function Ds(e){return 9216e4/e}function Rs(e,t){var i=_s(e,t);if(t+i<=e.length){var r=ws(e,t)-i;if(r>0)return{headerLength:i,frameLength:r}}}function xs(e,t,i,r,s){var a,n=r+s*Ds(e.samplerate),o=Rs(t,i);if(o){var l=o.frameLength,d=o.headerLength,h=d+l,c=Math.max(0,i+h-t.length);c?(a=new Uint8Array(h-d)).set(t.subarray(i+d,t.length),0):a=t.subarray(i+d,i+h);var u={unit:a,pts:n};return c||e.samples.push(u),{sample:u,length:h,missing:c}}var p=t.length-i;return(a=new Uint8Array(p)).set(t.subarray(i,t.length),0),{sample:{unit:a,pts:n},length:p,missing:-1}}var Ls=null,Is=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],Ps=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Bs=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Ms=[0,1,1,4];function Us(e,t,i,r,s){if(!(i+24>t.length)){var a=Fs(t,i);if(a&&i+a.frameLength<=t.length){var n=r+s*(9e4*a.samplesPerFrame/a.sampleRate),o={unit:t.subarray(i,i+a.frameLength),pts:n,dts:n};return e.config=[],e.channelCount=a.channelCount,e.samplerate=a.sampleRate,e.samples.push(o),{sample:o,length:a.frameLength,missing:0}}}}function Fs(e,t){var i=e[t+1]>>3&3,r=e[t+1]>>1&3,s=e[t+2]>>4&15,a=e[t+2]>>2&3;if(1!==i&&0!==s&&15!==s&&3!==a){var n=e[t+2]>>1&1,o=e[t+3]>>6,l=1e3*Is[14*(3===i?3-r:3===r?3:4)+s-1],d=Ps[3*(3===i?0:2===i?1:2)+a],h=3===o?1:2,c=Bs[i][r],u=Ms[r],p=8*c*u,f=Math.floor(c*l/d+n)*u;if(null===Ls){var y=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Ls=y?parseInt(y[1]):0}return!!Ls&&Ls<=87&&2===r&&l>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:d,channelCount:h,frameLength:f,samplesPerFrame:p}}}function Os(e,t){return!(255!==e[t]||224&~e[t+1]||!(6&e[t+1]))}function Ns(e,t){return t+1<e.length&&Os(e,t)}function Gs(e,t){var i=4;return Os(e,t)&&i<=e.length-t}function zs(e,t){if(t+1<e.length&&Os(e,t)){var i=4,r=Fs(e,t),s=i;null!=r&&r.frameLength&&(s=r.frameLength);var a=t+s;return a===e.length||Ns(e,a)}return!1}var Ws=function(e){function t(t,i){var r;return(r=e.call(this)||this).observer=void 0,r.config=void 0,r.observer=t,r.config=i,r}u(t,e);var i=t.prototype;return i.resetInitSegment=function(t,i,r,s){e.prototype.resetInitSegment.call(this,t,i,r,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:i,duration:s,inputTimeScale:9e4,dropped:0}},t.probe=function(e){if(!e)return!1;var t=ps(e,0),i=(null==t?void 0:t.length)||0;if(zs(e,i))return!1;for(var r=e.length;i<r;i++)if(ks(e,i))return G.log("ADTS sync word found !"),!0;return!1},i.canParse=function(e,t){return Ts(e,t)},i.appendFrame=function(e,t,i){Cs(e,this.observer,t,i,e.manifestCodec);var r=xs(e,t,i,this.basePTS,this.frameIndex);if(r&&0===r.missing)return r},t}(gs),Vs=/\/emsg[-/]ID3/i,Hs=function(){function e(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}var t=e.prototype;return t.resetTimeStamp=function(){},t.resetInitSegment=function(e,t,i,r){var s=this.videoTrack=us("video",1),a=this.audioTrack=us("audio",1),n=this.txtTrack=us("text",1);if(this.id3Track=us("id3",1),this.timeOffset=0,null!=e&&e.byteLength){var o=Ie(e);if(o.video){var l=o.video,d=l.id,h=l.timescale,c=l.codec;s.id=d,s.timescale=n.timescale=h,s.codec=c}if(o.audio){var u=o.audio,p=u.id,f=u.timescale,y=u.codec;a.id=p,a.timescale=f,a.codec=y}n.id=we.text,s.sampleDuration=0,s.duration=a.duration=r}},t.resetContiguity=function(){this.remainderData=null},e.probe=function(e){return Re(e)},t.demux=function(e,t){this.timeOffset=t;var i=e,r=this.videoTrack,s=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=He(this.remainderData,e));var a=Ve(i);this.remainderData=a.remainder,r.samples=a.valid||new Uint8Array}else r.samples=i;var n=this.extractID3Track(r,t);return s.samples=$e(t,r),{videoTrack:r,audioTrack:this.audioTrack,id3Track:n,textTrack:this.txtTrack}},t.flush=function(){var e=this.timeOffset,t=this.videoTrack,i=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var r=this.extractID3Track(t,this.timeOffset);return i.samples=$e(e,t),{videoTrack:t,audioTrack:us(),id3Track:r,textTrack:us()}},t.extractID3Track=function(e,t){var i=this.id3Track;if(e.samples.length){var r=xe(e.samples,["emsg"]);r&&r.forEach((function(e){var r=Qe(e);if(Vs.test(r.schemeIdUri)){var s=E(r.presentationTime)?r.presentationTime/r.timeScale:t+r.presentationTimeDelta/r.timeScale,a=4294967295===r.eventDuration?Number.POSITIVE_INFINITY:r.eventDuration/r.timeScale;a<=.001&&(a=Number.POSITIVE_INFINITY);var n=r.payload;i.samples.push({data:n,len:n.byteLength,dts:s,pts:s,type:Qt.emsg,duration:a})}}))}return i},t.demuxSampleAes=function(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},t.destroy=function(){},e}(),$s=function(e,t){var i=0,r=5;t+=r;for(var s=new Uint32Array(1),a=new Uint32Array(1),n=new Uint8Array(1);r>0;){n[0]=e[t];var o=Math.min(r,8),l=8-o;a[0]=4278190080>>>24+l<<l,s[0]=(n[0]&a[0])>>l,i=i?i<<o|s[0]:s[0],t+=1,r-=o}return i},js=function(e){function t(t){var i;return(i=e.call(this)||this).observer=void 0,i.observer=t,i}u(t,e);var i=t.prototype;return i.resetInitSegment=function(t,i,r,s){e.prototype.resetInitSegment.call(this,t,i,r,s),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:i,duration:s,inputTimeScale:9e4,dropped:0}},i.canParse=function(e,t){return t+64<e.length},i.appendFrame=function(e,t,i){var r=Ks(e,t,i,this.basePTS,this.frameIndex);if(-1!==r)return{sample:e.samples[e.samples.length-1],length:r,missing:0}},t.probe=function(e){if(!e)return!1;var t=ps(e,0);if(!t)return!1;var i=t.length;return 11===e[i]&&119===e[i+1]&&void 0!==ys(t)&&$s(e,i)<16},t}(gs);function Ks(e,t,i,r,s){if(i+8>t.length)return-1;if(11!==t[i]||119!==t[i+1])return-1;var a=t[i+4]>>6;if(a>=3)return-1;var n=[48e3,44100,32e3][a],o=63&t[i+4],l=2*[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][3*o+a];if(i+l>t.length)return-1;var d=t[i+6]>>5,h=0;2===d?h+=2:(1&d&&1!==d&&(h+=2),4&d&&(h+=2));var c=(t[i+6]<<8|t[i+7])>>12-h&1,u=[2,1,2,3,3,4,4,5][d]+c,p=t[i+5]>>3,f=7&t[i+5],y=new Uint8Array([a<<6|p<<1|f>>2,(3&f)<<6|d<<3|c<<2|o>>4,o<<4&224]),m=r+s*(1536/n*9e4),g=t.subarray(i,i+l);return e.config=y,e.channelCount=u,e.samplerate=n,e.samples.push({unit:g,pts:m}),l}var qs=function(){function e(){this.VideoSample=null}var t=e.prototype;return t.createVideoSample=function(e,t,i,r){return{key:e,frame:!1,pts:t,dts:i,units:[],debug:r,length:0}},t.getLastNalUnit=function(e){var t,i,r=this.VideoSample;if(r&&0!==r.units.length||(r=e[e.length-1]),null!=(t=r)&&t.units){var s=r.units;i=s[s.length-1]}return i},t.pushAccessUnit=function(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var i=t.samples,r=i.length;if(!r)return void t.dropped++;var s=i[r-1];e.pts=s.pts,e.dts=s.dts}t.samples.push(e)}e.debug.length&&G.log(e.pts+"/"+e.dts+":"+e.debug)},t.parseNALu=function(e,t){var i,r,s=t.byteLength,a=e.naluState||0,n=a,o=[],l=0,d=-1,h=0;for(-1===a&&(d=0,h=this.getNALuType(t,0),a=0,l=1);l<s;)if(i=t[l++],a)if(1!==a)if(i)if(1===i){if(r=l-a-1,d>=0){var c={data:t.subarray(d,r),type:h};o.push(c)}else{var u=this.getLastNalUnit(e.samples);u&&(n&&l<=4-n&&u.state&&(u.data=u.data.subarray(0,u.data.byteLength-n)),r>0&&(u.data=He(u.data,t.subarray(0,r)),u.state=0))}l<s?(d=l,h=this.getNALuType(t,l),a=0):a=-1}else a=0;else a=3;else a=i?0:2;else a=i?0:1;if(d>=0&&a>=0){var p={data:t.subarray(d,s),type:h,state:a};o.push(p)}if(0===o.length){var f=this.getLastNalUnit(e.samples);f&&(f.data=He(f.data,t))}return e.naluState=a,o},e}(),Ys=function(){function e(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}var t=e.prototype;return t.loadWord=function(){var e=this.data,t=this.bytesAvailable,i=e.byteLength-t,r=new Uint8Array(4),s=Math.min(4,t);if(0===s)throw new Error("no bytes available");r.set(e.subarray(i,i+s)),this.word=new DataView(r.buffer).getUint32(0),this.bitsAvailable=8*s,this.bytesAvailable-=s},t.skipBits=function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},t.readBits=function(e){var t=Math.min(this.bitsAvailable,e),i=this.word>>>32-t;if(e>32&&G.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?i<<t|this.readBits(t):i},t.skipLZ=function(){var e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},t.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.skipEG=function(){this.skipBits(1+this.skipLZ())},t.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},t.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},t.readBoolean=function(){return 1===this.readBits(1)},t.readUByte=function(){return this.readBits(8)},t.readUShort=function(){return this.readBits(16)},t.readUInt=function(){return this.readBits(32)},e}(),Qs=function(e){function t(){return e.apply(this,arguments)||this}u(t,e);var i=t.prototype;return i.parsePES=function(e,t,i,r,s){var a,n=this,o=this.parseNALu(e,i.data),l=this.VideoSample,d=!1;i.data=null,l&&o.length&&!e.audFound&&(this.pushAccessUnit(l,e),l=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts,"")),o.forEach((function(r){var o;switch(r.type){case 1:var h=!1;a=!0;var c,u=r.data;if(d&&u.length>4){var p=n.readSliceType(u);2!==p&&4!==p&&7!==p&&9!==p||(h=!0)}h&&null!=(c=l)&&c.frame&&!l.key&&(n.pushAccessUnit(l,e),l=n.VideoSample=null),l||(l=n.VideoSample=n.createVideoSample(!0,i.pts,i.dts,"")),l.frame=!0,l.key=h;break;case 5:a=!0,null!=(o=l)&&o.frame&&!l.key&&(n.pushAccessUnit(l,e),l=n.VideoSample=null),l||(l=n.VideoSample=n.createVideoSample(!0,i.pts,i.dts,"")),l.key=!0,l.frame=!0;break;case 6:a=!0,qe(r.data,1,i.pts,t.samples);break;case 7:var f,y;a=!0,d=!0;var m=r.data,g=n.readSPS(m);if(!e.sps||e.width!==g.width||e.height!==g.height||(null==(f=e.pixelRatio)?void 0:f[0])!==g.pixelRatio[0]||(null==(y=e.pixelRatio)?void 0:y[1])!==g.pixelRatio[1]){e.width=g.width,e.height=g.height,e.pixelRatio=g.pixelRatio,e.sps=[m],e.duration=s;for(var A=m.subarray(1,4),v="avc1.",b=0;b<3;b++){var _=A[b].toString(16);_.length<2&&(_="0"+_),v+=_}e.codec=v}break;case 8:a=!0,e.pps=[r.data];break;case 9:a=!0,e.audFound=!0,l&&n.pushAccessUnit(l,e),l=n.VideoSample=n.createVideoSample(!1,i.pts,i.dts,"");break;case 12:a=!0;break;default:a=!1,l&&(l.debug+="unknown NAL "+r.type+" ")}l&&a&&l.units.push(r)})),r&&l&&(this.pushAccessUnit(l,e),this.VideoSample=null)},i.getNALuType=function(e,t){return 31&e[t]},i.readSliceType=function(e){var t=new Ys(e);return t.readUByte(),t.readUEG(),t.readUEG()},i.skipScalingList=function(e,t){for(var i=8,r=8,s=0;s<e;s++)0!==r&&(r=(i+t.readEG()+256)%256),i=0===r?i:r},i.readSPS=function(e){var t,i,r,s=new Ys(e),a=0,n=0,o=0,l=0,d=s.readUByte.bind(s),h=s.readBits.bind(s),c=s.readUEG.bind(s),u=s.readBoolean.bind(s),p=s.skipBits.bind(s),f=s.skipEG.bind(s),y=s.skipUEG.bind(s),m=this.skipScalingList.bind(this);d();var g=d();if(h(5),p(3),d(),y(),100===g||110===g||122===g||244===g||44===g||83===g||86===g||118===g||128===g){var A=c();if(3===A&&p(1),y(),y(),p(1),u())for(i=3!==A?8:12,r=0;r<i;r++)u()&&m(r<6?16:64,s)}y();var v=c();if(0===v)c();else if(1===v)for(p(1),f(),f(),t=c(),r=0;r<t;r++)f();y(),p(1);var b=c(),_=c(),w=h(1);0===w&&p(1),p(1),u()&&(a=c(),n=c(),o=c(),l=c());var E=[1,1];if(u()&&u())switch(d()){case 1:E=[1,1];break;case 2:E=[12,11];break;case 3:E=[10,11];break;case 4:E=[16,11];break;case 5:E=[40,33];break;case 6:E=[24,11];break;case 7:E=[20,11];break;case 8:E=[32,11];break;case 9:E=[80,33];break;case 10:E=[18,11];break;case 11:E=[15,11];break;case 12:E=[64,33];break;case 13:E=[160,99];break;case 14:E=[4,3];break;case 15:E=[3,2];break;case 16:E=[2,1];break;case 255:E=[d()<<8|d(),d()<<8|d()]}return{width:Math.ceil(16*(b+1)-2*a-2*n),height:(2-w)*(_+1)*16-(w?2:4)*(o+l),pixelRatio:E}},t}(qs),Xs=function(e){function t(){for(var t,i=arguments.length,r=new Array(i),s=0;s<i;s++)r[s]=arguments[s];return(t=e.call.apply(e,[this].concat(r))||this).initVPS=null,t}u(t,e);var i=t.prototype;return i.parsePES=function(e,t,i,r,s){var n,o=this,l=this.parseNALu(e,i.data),d=this.VideoSample,h=!1;i.data=null,d&&l.length&&!e.audFound&&(this.pushAccessUnit(d,e),d=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts,"")),l.forEach((function(r){var l;switch(r.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:d||(d=o.VideoSample=o.createVideoSample(!1,i.pts,i.dts,"")),d.frame=!0,n=!0;break;case 16:case 17:case 18:case 21:var c;n=!0,h&&null!=(c=d)&&c.frame&&!d.key&&(o.pushAccessUnit(d,e),d=o.VideoSample=null),d||(d=o.VideoSample=o.createVideoSample(!0,i.pts,i.dts,"")),d.key=!0,d.frame=!0;break;case 19:case 20:n=!0,null!=(l=d)&&l.frame&&!d.key&&(o.pushAccessUnit(d,e),d=o.VideoSample=null),d||(d=o.VideoSample=o.createVideoSample(!0,i.pts,i.dts,"")),d.key=!0,d.frame=!0;break;case 39:n=!0,qe(r.data,2,i.pts,t.samples);break;case 32:if(n=!0,!e.vps){var u=o.readVPS(r.data);e.params=a({},u),o.initVPS=r.data}e.vps=[r.data];break;case 33:if(n=!0,h=!0,"object"==typeof e.params){if(void 0===e.vps||e.vps[0]===o.initVPS||void 0===e.sps||o.matchSPS(e.sps[0],r.data)||(o.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){var p=o.readSPS(r.data);for(var f in e.width=p.width,e.height=p.height,e.pixelRatio=p.pixelRatio,e.duration=s,e.codec=p.codecString,e.sps=[],p.params)e.params[f]=p.params[f]}void 0!==e.vps&&e.vps[0]===o.initVPS&&e.sps.push(r.data)}d||(d=o.VideoSample=o.createVideoSample(!0,i.pts,i.dts,"")),d.key=!0;break;case 34:if(n=!0,"object"==typeof e.params){if(!e.pps){e.pps=[];var y=o.readPPS(r.data);for(var m in y)e.params[m]=y[m]}null===o.initVPS&&0!==e.pps.length||e.pps.push(r.data)}break;case 35:n=!0,e.audFound=!0,d&&o.pushAccessUnit(d,e),d=o.VideoSample=o.createVideoSample(!1,i.pts,i.dts,"");break;default:n=!1,d&&(d.debug+="unknown or irrelevant NAL "+r.type+" ")}d&&n&&d.units.push(r)})),r&&d&&(this.pushAccessUnit(d,e),this.VideoSample=null)},i.getNALuType=function(e,t){return(126&e[t])>>>1},i.ebsp2rbsp=function(e){for(var t=new Uint8Array(e.byteLength),i=0,r=0;r<e.byteLength;r++)r>=2&&3===e[r]&&0===e[r-1]&&0===e[r-2]||(t[i]=e[r],i++);return new Uint8Array(t.buffer,0,i)},i.readVPS=function(e){var t=new Ys(e);return t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6),{numTemporalLayers:t.readBits(3)+1,temporalIdNested:t.readBoolean()}},i.readSPS=function(e){var t=new Ys(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);var i=t.readBits(3);t.readBoolean();for(var r=t.readBits(2),s=t.readBoolean(),a=t.readBits(5),n=t.readUByte(),o=t.readUByte(),l=t.readUByte(),d=t.readUByte(),h=t.readUByte(),c=t.readUByte(),u=t.readUByte(),p=t.readUByte(),f=t.readUByte(),y=t.readUByte(),m=t.readUByte(),g=[],A=[],v=0;v<i;v++)g.push(t.readBoolean()),A.push(t.readBoolean());if(i>0)for(var b=i;b<8;b++)t.readBits(2);for(var _=0;_<i;_++)g[_]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),A[_]&&t.readUByte();t.readUEG();var w=t.readUEG();3==w&&t.skipBits(1);var E=t.readUEG(),S=t.readUEG(),T=t.readBoolean(),k=0,C=0,D=0,R=0;T&&(k+=t.readUEG(),C+=t.readUEG(),D+=t.readUEG(),R+=t.readUEG());for(var x=t.readUEG(),L=t.readUEG(),I=t.readUEG(),P=t.readBoolean()?0:i;P<=i;P++)t.skipUEG(),t.skipUEG(),t.skipUEG();if(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.readBoolean()&&t.readBoolean())for(var B=0;B<4;B++)for(var M=0;M<(3===B?2:6);M++)if(t.readBoolean()){var U=Math.min(64,1<<4+(B<<1));B>1&&t.readEG();for(var F=0;F<U;F++)t.readEG()}else t.readUEG();t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());for(var O=t.readUEG(),N=0,G=0;G<O;G++){var z=!1;if(0!==G&&(z=t.readBoolean()),z){G===O&&t.readUEG(),t.readBoolean(),t.readUEG();for(var W=0,V=0;V<=N;V++){var H=t.readBoolean(),$=!1;H||($=t.readBoolean()),(H||$)&&W++}N=W}else{var j=t.readUEG(),K=t.readUEG();N=j+K;for(var q=0;q<j;q++)t.readUEG(),t.readBoolean();for(var Y=0;Y<K;Y++)t.readUEG(),t.readBoolean()}}if(t.readBoolean())for(var Q=t.readUEG(),X=0;X<Q;X++){for(var J=0;J<I+4;J++)t.readBits(1);t.readBits(1)}var Z=0,ee=1,te=1,ie=!0,re=1,se=0;t.readBoolean(),t.readBoolean();var ae=!1;if(t.readBoolean()){if(t.readBoolean()){var ne=t.readUByte();ne>0&&ne<16?(ee=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][ne-1],te=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][ne-1]):255===ne&&(ee=t.readBits(16),te=t.readBits(16))}if(t.readBoolean()&&t.readBoolean(),t.readBoolean()&&(t.readBits(3),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte())),t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),(ae=t.readBoolean())&&(k+=t.readUEG(),C+=t.readUEG(),D+=t.readUEG(),R+=t.readUEG()),t.readBoolean()&&(re=t.readBits(32),se=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean())){var oe=t.readBoolean(),le=t.readBoolean(),de=!1;(oe||le)&&((de=t.readBoolean())&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),de&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(var he=0;he<=i;he++){var ce=!1;(ie=t.readBoolean())||t.readBoolean()?t.readEG():ce=t.readBoolean();var ue=ce?1:t.readUEG()+1;if(oe)for(var pe=0;pe<ue;pe++)t.readUEG(),t.readUEG(),de&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(le)for(var fe=0;fe<ue;fe++)t.readUEG(),t.readUEG(),de&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),Z=t.readUEG())}var ye=E,me=S;if(T||ae){var ge=1,Ae=1;1===w?ge=Ae=2:2==w&&(ge=2),ye=E-ge*C-ge*k,me=S-Ae*R-Ae*D}for(var ve=r?["A","B","C"][r]:"",be=n<<24|o<<16|l<<8|d,_e=0,we=0;we<32;we++)_e=(_e|(be>>we&1)<<31-we)>>>0;var Ee=_e.toString(16);return 1===a&&"2"===Ee&&(Ee="6"),{codecString:"hvc1."+ve+a+"."+Ee+"."+(s?"H":"L")+m+".B0",params:{general_tier_flag:s,general_profile_idc:a,general_profile_space:r,general_profile_compatibility_flags:[n,o,l,d],general_constraint_indicator_flags:[h,c,u,p,f,y],general_level_idc:m,bit_depth:x+8,bit_depth_luma_minus8:x,bit_depth_chroma_minus8:L,min_spatial_segmentation_idc:Z,chroma_format_idc:w,frame_rate:{fixed:ie,fps:se/re}},width:ye,height:me,pixelRatio:[ee,te]}},i.readPPS=function(e){var t=new Ys(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);var i=t.readBoolean(),r=t.readBoolean(),s=1;return r&&i?s=0:r?s=3:i&&(s=2),{parallelismType:s}},i.matchSPS=function(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)},t}(qs),Js=function(){function e(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new ns(t,{removePKCS7Padding:!1})}var t=e.prototype;return t.decryptBuffer=function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,ie.cbc)},t.decryptAacSample=function(e,t,i){var r=this,s=e[t].unit;if(!(s.length<=16)){var a=s.subarray(16,s.length-s.length%16),n=a.buffer.slice(a.byteOffset,a.byteOffset+a.length);this.decryptBuffer(n).then((function(a){var n=new Uint8Array(a);s.set(n,16),r.decrypter.isSync()||r.decryptAacSamples(e,t+1,i)}))}},t.decryptAacSamples=function(e,t,i){for(;;t++){if(t>=e.length)return void i();if(!(e[t].unit.length<32||(this.decryptAacSample(e,t,i),this.decrypter.isSync())))return}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,i=new Int8Array(t),r=0,s=32;s<e.length-16;s+=160,r+=16)i.set(e.subarray(s,s+16),r);return i},t.getAvcDecryptedUnit=function(e,t){for(var i=new Uint8Array(t),r=0,s=32;s<e.length-16;s+=160,r+=16)e.set(i.subarray(r,r+16),s);return e},t.decryptAvcSample=function(e,t,i,r,s){var a=this,n=Ye(s.data),o=this.getAvcEncryptedData(n);this.decryptBuffer(o.buffer).then((function(o){s.data=a.getAvcDecryptedUnit(n,o),a.decrypter.isSync()||a.decryptAvcSamples(e,t,i+1,r)}))},t.decryptAvcSamples=function(e,t,i,r){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length)return void r();for(var s=e[t].units;!(i>=s.length);i++){var a=s[i];if(!(a.data.length<=48||1!==a.type&&5!==a.type||(this.decryptAvcSample(e,t,i,r,a),this.decrypter.isSync())))return}}},e}(),Zs=188,ea=function(){function e(e,t,i){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.videoParser=null}e.probe=function(t){var i=e.syncOffset(t);return i>0&&G.warn("MPEG2-TS detected but first sync word found @ offset "+i),-1!==i},e.syncOffset=function(e){for(var t=e.length,i=Math.min(5*Zs,t-Zs)+1,r=0;r<i;){for(var s=!1,a=-1,n=0,o=r;o<t;o+=Zs){if(71!==e[o]||t-o!==Zs&&71!==e[o+Zs]){if(n)return-1;break}if(n++,-1===a&&0!==(a=o)&&(i=Math.min(a+99*Zs,e.length-Zs)+1),s||(s=0===ta(e,o)),s&&n>1&&(0===a&&n>2||o+Zs>i))return a}r++}return-1},e.createTrack=function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:we[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}};var t=e.prototype;return t.resetInitSegment=function(t,i,r,s){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=e.createTrack("video"),this._audioTrack=e.createTrack("audio",s),this._id3Track=e.createTrack("id3"),this._txtTrack=e.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=i,this.videoCodec=r,this._duration=s},t.resetTimeStamp=function(){},t.resetContiguity=function(){var e=this._audioTrack,t=this._videoTrack,i=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.remainderData=null},t.demux=function(t,i,r,s){var a;void 0===r&&(r=!1),void 0===s&&(s=!1),r||(this.sampleAes=null);var n=this._videoTrack,o=this._audioTrack,l=this._id3Track,d=this._txtTrack,h=n.pid,c=n.pesData,u=o.pid,p=l.pid,f=o.pesData,y=l.pesData,m=null,g=this.pmtParsed,A=this._pmtId,v=t.length;if(this.remainderData&&(v=(t=He(this.remainderData,t)).length,this.remainderData=null),v<Zs&&!s)return this.remainderData=t,{audioTrack:o,videoTrack:n,id3Track:l,textTrack:d};var b=Math.max(0,e.syncOffset(t));(v-=(v-b)%Zs)<t.byteLength&&!s&&(this.remainderData=new Uint8Array(t.buffer,v,t.buffer.byteLength-v));for(var _=0,w=b;w<v;w+=Zs)if(71===t[w]){var E=!!(64&t[w+1]),S=ta(t,w),T=void 0;if((48&t[w+3])>>4>1){if((T=w+5+t[w+4])===w+Zs)continue}else T=w+4;switch(S){case h:if(E){if(c&&(a=aa(c))){if(null===this.videoParser)switch(n.segmentCodec){case"avc":this.videoParser=new Qs;break;case"hevc":this.videoParser=new Xs}null!==this.videoParser&&this.videoParser.parsePES(n,d,a,!1,this._duration)}c={data:[],size:0}}c&&(c.data.push(t.subarray(T,w+Zs)),c.size+=w+Zs-T);break;case u:if(E){if(f&&(a=aa(f)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,a);break;case"mp3":this.parseMPEGPES(o,a);break;case"ac3":this.parseAC3PES(o,a)}f={data:[],size:0}}f&&(f.data.push(t.subarray(T,w+Zs)),f.size+=w+Zs-T);break;case p:E&&(y&&(a=aa(y))&&this.parseID3PES(l,a),y={data:[],size:0}),y&&(y.data.push(t.subarray(T,w+Zs)),y.size+=w+Zs-T);break;case 0:E&&(T+=t[T]+1),A=this._pmtId=ia(t,T);break;case A:E&&(T+=t[T]+1);var R=ra(t,T,this.typeSupported,r);(h=R.videoPid)>0&&(n.pid=h,n.segmentCodec=R.segmentVideoCodec),(u=R.audioPid)>0&&(o.pid=u,o.segmentCodec=R.segmentAudioCodec),(p=R.id3Pid)>0&&(l.pid=p),null===m||g||(G.warn("MPEG-TS PMT found at "+w+" after unknown PID '"+m+"'. Backtracking to sync byte @"+b+" to parse all TS packets."),m=null,w=b-188),g=this.pmtParsed=!0;break;case 17:case 8191:break;default:m=S}}else _++;if(_>0){var x=new Error("Found "+_+" TS packet/s that do not start with 0x47");this.observer.emit(k.ERROR,k.ERROR,{type:C.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:x,reason:x.message})}n.pesData=c,o.pesData=f,l.pesData=y;var L={audioTrack:o,videoTrack:n,id3Track:l,textTrack:d};return s&&this.extractRemainingSamples(L),L},t.flush=function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e},t.extractRemainingSamples=function(e){var t,i=e.audioTrack,r=e.videoTrack,s=e.id3Track,a=e.textTrack,n=r.pesData,o=i.pesData,l=s.pesData;if(n&&(t=aa(n))){if(null===this.videoParser)switch(r.segmentCodec){case"avc":this.videoParser=new Qs;break;case"hevc":this.videoParser=new Xs}null!==this.videoParser&&(this.videoParser.parsePES(r,a,t,!0,this._duration),r.pesData=null)}else r.pesData=n;if(o&&(t=aa(o))){switch(i.segmentCodec){case"aac":this.parseAACPES(i,t);break;case"mp3":this.parseMPEGPES(i,t);break;case"ac3":this.parseAC3PES(i,t)}i.pesData=null}else null!=o&&o.size&&G.log("last AAC PES packet truncated,might overlap between fragments"),i.pesData=o;l&&(t=aa(l))?(this.parseID3PES(s,t),s.pesData=null):s.pesData=l},t.demuxSampleAes=function(e,t,i){var r=this.demux(e,i,!0,!this.config.progressive),s=this.sampleAes=new Js(this.observer,this.config,t);return this.decrypt(r,s)},t.decrypt=function(e,t){return new Promise((function(i){var r=e.audioTrack,s=e.videoTrack;r.samples&&"aac"===r.segmentCodec?t.decryptAacSamples(r.samples,0,(function(){s.samples?t.decryptAvcSamples(s.samples,0,0,(function(){i(e)})):i(e)})):s.samples&&t.decryptAvcSamples(s.samples,0,0,(function(){i(e)}))}))},t.destroy=function(){this._duration=0},t.parseAACPES=function(e,t){var i,r,s,a=0,n=this.aacOverFlow,o=t.data;if(n){this.aacOverFlow=null;var l=n.missing,d=n.sample.unit.byteLength;if(-1===l)o=He(n.sample.unit,o);else{var h=d-l;n.sample.unit.set(o.subarray(0,l),h),e.samples.push(n.sample),a=n.missing}}for(i=a,r=o.length;i<r-1&&!Ss(o,i);i++);if(i!==a){var c,u=i<r-1;c=u?"AAC PES did not start with ADTS header,offset:"+i:"No ADTS header found in AAC PES";var p=new Error(c);if(G.warn("parsing error: "+c),this.observer.emit(k.ERROR,k.ERROR,{type:C.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,levelRetry:u,error:p,reason:c}),!u)return}if(Cs(e,this.observer,o,i,this.audioCodec),void 0!==t.pts)s=t.pts;else{if(!n)return void G.warn("[tsdemuxer]: AAC PES unknown PTS");var f=Ds(e.samplerate);s=n.sample.pts+f}for(var y,m=0;i<r;){if(i+=(y=xs(e,o,i,s,m)).length,y.missing){this.aacOverFlow=y;break}for(m++;i<r-1&&!Ss(o,i);i++);}},t.parseMPEGPES=function(e,t){var i=t.data,r=i.length,s=0,a=0,n=t.pts;if(void 0!==n)for(;a<r;)if(Ns(i,a)){var o=Us(e,i,a,n,s);if(!o)break;a+=o.length,s++}else a++;else G.warn("[tsdemuxer]: MPEG PES unknown PTS")},t.parseAC3PES=function(e,t){var i=t.data,r=t.pts;if(void 0!==r)for(var s,a=i.length,n=0,o=0;o<a&&(s=Ks(e,i,o,r,n++))>0;)o+=s;else G.warn("[tsdemuxer]: AC3 PES unknown PTS")},t.parseID3PES=function(e,t){if(void 0!==t.pts){var i=c({},t,{type:this._videoTrack?Qt.emsg:Qt.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}else G.warn("[tsdemuxer]: ID3 PES unknown PTS")},e}();function ta(e,t){return((31&e[t+1])<<8)+e[t+2]}function ia(e,t){return(31&e[t+10])<<8|e[t+11]}function ra(e,t,i,r){var s={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},a=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<a;){var n=ta(e,t),o=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!r){sa("ADTS AAC");break}case 15:-1===s.audioPid&&(s.audioPid=n);break;case 21:-1===s.id3Pid&&(s.id3Pid=n);break;case 219:if(!r){sa("H.264");break}case 27:-1===s.videoPid&&(s.videoPid=n,s.segmentVideoCodec="avc");break;case 3:case 4:i.mpeg||i.mp3?-1===s.audioPid&&(s.audioPid=n,s.segmentAudioCodec="mp3"):G.log("MPEG audio found, not supported in this browser");break;case 193:if(!r){sa("AC-3");break}case 129:i.ac3?-1===s.audioPid&&(s.audioPid=n,s.segmentAudioCodec="ac3"):G.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===s.audioPid&&o>0)for(var l=t+5,d=o;d>2;){106===e[l]&&(!0!==i.ac3?G.log("AC-3 audio found, not supported in this browser for now"):(s.audioPid=n,s.segmentAudioCodec="ac3"));var h=e[l+1]+2;l+=h,d-=h}break;case 194:case 135:G.warn("Unsupported EC-3 in M2TS found");break;case 36:-1===s.videoPid&&(s.videoPid=n,s.segmentVideoCodec="hevc",G.log("HEVC in M2TS found"))}t+=o+5}return s}function sa(e){G.log(e+" with AES-128-CBC encryption found in unencrypted stream")}function aa(e){var t,i,r,s,a,n=0,o=e.data;if(!e||0===e.size)return null;for(;o[0].length<19&&o.length>1;)o[0]=He(o[0],o[1]),o.splice(1,1);if(1===((t=o[0])[0]<<16)+(t[1]<<8)+t[2]){if((i=(t[4]<<8)+t[5])&&i>e.size-6)return null;var l=t[7];192&l&&(s=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,64&l?s-(a=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2)>54e5&&(G.warn(Math.round((s-a)/9e4)+"s delta between PTS and DTS, align them"),s=a):a=s);var d=(r=t[8])+9;if(e.size<=d)return null;e.size-=d;for(var h=new Uint8Array(e.size),c=0,u=o.length;c<u;c++){var p=(t=o[c]).byteLength;if(d){if(d>p){d-=p;continue}t=t.subarray(d),p-=d,d=0}h.set(t,n),n+=p}return i&&(i-=r+3),{data:h,pts:s,dts:a,len:i}}return null}var na=function(e){function t(){return e.apply(this,arguments)||this}u(t,e);var i=t.prototype;return i.resetInitSegment=function(t,i,r,s){e.prototype.resetInitSegment.call(this,t,i,r,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:i,duration:s,inputTimeScale:9e4,dropped:0}},t.probe=function(e){if(!e)return!1;var t=ps(e,0),i=(null==t?void 0:t.length)||0;if(t&&11===e[i]&&119===e[i+1]&&void 0!==ys(t)&&$s(e,i)<=16)return!1;for(var r=e.length;i<r;i++)if(zs(e,i))return G.log("MPEG Audio sync word found !"),!0;return!1},i.canParse=function(e,t){return Gs(e,t)},i.appendFrame=function(e,t,i){if(null!==this.basePTS)return Us(e,t,i,this.basePTS,this.frameIndex)},t}(gs),oa=function(){function e(){}return e.getSilentFrame=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)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]);if(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}(),la=Math.pow(2,32)-1,da=function(){function e(){}return e.init=function(){var t;for(t in e.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var i=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]),r=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]);e.HDLR_TYPES={video:i,audio:r};var s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),a=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=a,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var n=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,n,l,n,o),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,s))},e.box=function(e){for(var t=8,i=arguments.length,r=new Array(i>1?i-1:0),s=1;s<i;s++)r[s-1]=arguments[s];for(var a=r.length,n=a;a--;)t+=r[a].byteLength;var o=new Uint8Array(t);for(o[0]=t>>24&255,o[1]=t>>16&255,o[2]=t>>8&255,o[3]=255&t,o.set(e,4),a=0,t=8;a<n;a++)o.set(r[a],t),t+=r[a].byteLength;return o},e.hdlr=function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])},e.mdat=function(t){return e.box(e.types.mdat,t)},e.mdhd=function(t,i){i*=t;var r=Math.floor(i/(la+1)),s=Math.floor(i%(la+1));return e.box(e.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,s>>24,s>>16&255,s>>8&255,255&s,85,196,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))},e.mfhd=function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))},e.minf=function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))},e.moof=function(t,i,r){return e.box(e.types.moof,e.mfhd(t),e.traf(r,i))},e.moov=function(t){for(var i=t.length,r=[];i--;)r[i]=e.trak(t[i]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)].concat(r).concat(e.mvex(t)))},e.mvex=function(t){for(var i=t.length,r=[];i--;)r[i]=e.trex(t[i]);return e.box.apply(null,[e.types.mvex].concat(r))},e.mvhd=function(t,i){i*=t;var r=Math.floor(i/(la+1)),s=Math.floor(i%(la+1)),a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,s>>24,s>>16&255,s>>8&255,255&s,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]);return e.box(e.types.mvhd,a)},e.sdtp=function(t){var i,r,s=t.samples||[],a=new Uint8Array(4+s.length);for(i=0;i<s.length;i++)r=s[i].flags,a[i+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return e.box(e.types.sdtp,a)},e.stbl=function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))},e.avc1=function(t){var i,r,s,a=[],n=[];for(i=0;i<t.sps.length;i++)s=(r=t.sps[i]).byteLength,a.push(s>>>8&255),a.push(255&s),a=a.concat(Array.prototype.slice.call(r));for(i=0;i<t.pps.length;i++)s=(r=t.pps[i]).byteLength,n.push(s>>>8&255),n.push(255&s),n=n.concat(Array.prototype.slice.call(r));var o=e.box(e.types.avcC,new Uint8Array([1,a[3],a[4],a[5],255,224|t.sps.length].concat(a).concat([t.pps.length]).concat(n))),l=t.width,d=t.height,h=t.pixelRatio[0],c=t.pixelRatio[1];return e.box(e.types.avc1,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,l>>8&255,255&l,d>>8&255,255&d,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]),o,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,255&h,c>>24,c>>16&255,c>>8&255,255&c])))},e.esds=function(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))},e.audioStsd=function(e){var t=e.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0])},e.mp4a=function(t){return e.box(e.types.mp4a,e.audioStsd(t),e.box(e.types.esds,e.esds(t)))},e.mp3=function(t){return e.box(e.types[".mp3"],e.audioStsd(t))},e.ac3=function(t){return e.box(e.types["ac-3"],e.audioStsd(t),e.box(e.types.dac3,t.config))},e.stsd=function(t){return"audio"===t.type?"mp3"===t.segmentCodec&&"mp3"===t.codec?e.box(e.types.stsd,e.STSD,e.mp3(t)):"ac3"===t.segmentCodec?e.box(e.types.stsd,e.STSD,e.ac3(t)):e.box(e.types.stsd,e.STSD,e.mp4a(t)):"avc"===t.segmentCodec?e.box(e.types.stsd,e.STSD,e.avc1(t)):e.box(e.types.stsd,e.STSD,e.hvc1(t))},e.tkhd=function(t){var i=t.id,r=t.duration*t.timescale,s=t.width,a=t.height,n=Math.floor(r/(la+1)),o=Math.floor(r%(la+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,255&i,0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,o>>24,o>>16&255,o>>8&255,255&o,0,0,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,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,s>>8&255,255&s,0,0,a>>8&255,255&a,0,0]))},e.traf=function(t,i){var r=e.sdtp(t),s=t.id,a=Math.floor(i/(la+1)),n=Math.floor(i%(la+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,n>>24,n>>16&255,n>>8&255,255&n])),e.trun(t,r.length+16+20+8+16+8+8),r)},e.trak=function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.trex=function(t){var i=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},e.trun=function(t,i){var r,s,a,n,o,l,d=t.samples||[],h=d.length,c=12+16*h,u=new Uint8Array(c);for(i+=8+c,u.set(["video"===t.type?1:0,0,15,1,h>>>24&255,h>>>16&255,h>>>8&255,255&h,i>>>24&255,i>>>16&255,i>>>8&255,255&i],0),r=0;r<h;r++)a=(s=d[r]).duration,n=s.size,o=s.flags,l=s.cts,u.set([a>>>24&255,a>>>16&255,a>>>8&255,255&a,n>>>24&255,n>>>16&255,n>>>8&255,255&n,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*r);return e.box(e.types.trun,u)},e.initSegment=function(t){e.types||e.init();var i=e.moov(t);return He(e.FTYP,i)},e.hvc1=function(t){for(var i=t.params,r=[t.vps,t.sps,t.pps],s=4,a=new Uint8Array([1,i.general_profile_space<<6|(i.general_tier_flag?32:0)|i.general_profile_idc,i.general_profile_compatibility_flags[0],i.general_profile_compatibility_flags[1],i.general_profile_compatibility_flags[2],i.general_profile_compatibility_flags[3],i.general_constraint_indicator_flags[0],i.general_constraint_indicator_flags[1],i.general_constraint_indicator_flags[2],i.general_constraint_indicator_flags[3],i.general_constraint_indicator_flags[4],i.general_constraint_indicator_flags[5],i.general_level_idc,240|i.min_spatial_segmentation_idc>>8,255&i.min_spatial_segmentation_idc,252|i.parallelismType,252|i.chroma_format_idc,248|i.bit_depth_luma_minus8,248|i.bit_depth_chroma_minus8,0,parseInt(i.frame_rate.fps),s-1|i.temporal_id_nested<<2|i.num_temporal_layers<<3|(i.frame_rate.fixed?64:0),r.length]),n=a.length,o=0;o<r.length;o+=1){n+=3;for(var l=0;l<r[o].length;l+=1)n+=2+r[o][l].length}var d=new Uint8Array(n);d.set(a,0),n=a.length;for(var h=r.length-1,c=0;c<r.length;c+=1){d.set(new Uint8Array([32+c|(c===h?128:0),0,r[c].length]),n),n+=3;for(var u=0;u<r[c].length;u+=1)d.set(new Uint8Array([r[c][u].length>>8,255&r[c][u].length]),n),n+=2,d.set(r[c][u],n),n+=r[c][u].length}var p=e.box(e.types.hvcC,d),f=t.width,y=t.height,m=t.pixelRatio[0],g=t.pixelRatio[1];return e.box(e.types.hvc1,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,f>>8&255,255&f,y>>8&255,255&y,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]),p,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([m>>24,m>>16&255,m>>8&255,255&m,g>>24,g>>16&255,g>>8&255,255&g])))},e}();da.types=void 0,da.HDLR_TYPES=void 0,da.STTS=void 0,da.STSC=void 0,da.STCO=void 0,da.STSZ=void 0,da.VMHD=void 0,da.SMHD=void 0,da.STSD=void 0,da.FTYP=void 0,da.DINF=void 0;var ha=9e4;function ca(e,t,i,r){void 0===i&&(i=1),void 0===r&&(r=!1);var s=e*t*i;return r?Math.round(s):s}function ua(e,t,i,r){return void 0===i&&(i=1),void 0===r&&(r=!1),ca(e,t,1/i,r)}function pa(e,t){return void 0===t&&(t=!1),ca(e,1e3,1/ha,t)}function fa(e,t){return void 0===t&&(t=1),ca(e,ha,1/t)}var ya=1e4,ma=1024,ga=1152,Aa=1536,va=null,ba=null,_a=function(){function e(e,t,i,r){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.ISGenerated=!1,null===va){var s=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);va=s?parseInt(s[1]):0}if(null===ba){var a=navigator.userAgent.match(/Safari\/(\d+)/i);ba=a?parseInt(a[1]):0}}var t=e.prototype;return t.destroy=function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null},t.resetTimeStamp=function(e){G.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},t.resetNextTimestamp=function(){G.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},t.resetInitSegment=function(){G.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0},t.getVideoStartPts=function(e){var t=!1,i=e.reduce((function(e,i){var r=i.pts-e;return r<-4294967296?(t=!0,wa(e,i.pts)):r>0?e:i.pts}),e[0].pts);return t&&G.debug("PTS rollover detected"),i},t.remux=function(e,t,i,r,s,a,n,o){var l,d,h,c,u,p,f=s,y=s,m=e.pid>-1,g=t.pid>-1,A=t.samples.length,v=e.samples.length>0,b=n&&A>0||A>1;if((!m||v)&&(!g||b)||this.ISGenerated||n){if(this.ISGenerated){var _,w,E,S,T=this.videoTrackConfig;!T||t.width===T.width&&t.height===T.height&&(null==(_=t.pixelRatio)?void 0:_[0])===(null==(w=T.pixelRatio)?void 0:w[0])&&(null==(E=t.pixelRatio)?void 0:E[1])===(null==(S=T.pixelRatio)?void 0:S[1])||this.resetInitSegment()}else h=this.generateIS(e,t,s,a);var k,C=this.isVideoContiguous,D=-1;if(b&&(D=Ea(t.samples),!C&&this.config.forceKeyFrameOnDiscontinuity))if(p=!0,D>0){G.warn("[mp4-remuxer]: Dropped "+D+" out of "+A+" video samples due to a missing keyframe");var R=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(D),t.dropped+=D,k=y+=(t.samples[0].pts-R)/t.inputTimeScale}else-1===D&&(G.warn("[mp4-remuxer]: No keyframe found out of "+A+" video samples"),p=!1);if(this.ISGenerated){if(v&&b){var x=this.getVideoStartPts(t.samples),L=(wa(e.samples[0].pts,x)-x)/t.inputTimeScale;f+=Math.max(0,L),y+=Math.max(0,-L)}if(v){if(e.samplerate||(G.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),h=this.generateIS(e,t,s,a)),d=this.remuxAudio(e,f,this.isAudioContiguous,a,g||b||o===Nt.AUDIO?y:void 0),b){var I=d?d.endPTS-d.startPTS:0;t.inputTimeScale||(G.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),h=this.generateIS(e,t,s,a)),l=this.remuxVideo(t,y,C,I)}}else b&&(l=this.remuxVideo(t,y,C,0));l&&(l.firstKeyFrame=D,l.independent=-1!==D,l.firstKeyFramePTS=k)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(u=Sa(i,s,this._initPTS,this._initDTS)),r.samples.length&&(c=Ta(r,s,this._initPTS))),{audio:d,video:l,initSegment:h,independent:p,text:c,id3:u}},t.generateIS=function(e,t,i,r){var s,a,n,o=e.samples,l=t.samples,d=this.typeSupported,h={},c=this._initPTS,u=!c||r,p="audio/mp4";if(u&&(s=a=1/0),e.config&&o.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":d.mpeg?(p="audio/mpeg",e.codec=""):d.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}h.audio={id:"audio",container:p,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&d.mpeg?new Uint8Array(0):da.initSegment([e]),metadata:{channelCount:e.channelCount}},u&&(n=e.inputTimeScale,c&&n===c.timescale?u=!1:s=a=o[0].pts-Math.round(n*i))}if(t.sps&&t.pps&&l.length){if(t.timescale=t.inputTimeScale,h.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:da.initSegment([t]),metadata:{width:t.width,height:t.height}},u)if(n=t.inputTimeScale,c&&n===c.timescale)u=!1;else{var f=this.getVideoStartPts(l),y=Math.round(n*i);a=Math.min(a,wa(l[0].dts,f)-y),s=Math.min(s,f-y)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(h).length)return this.ISGenerated=!0,u?(this._initPTS={baseTime:s,timescale:n},this._initDTS={baseTime:a,timescale:n}):s=n=void 0,{tracks:h,initPTS:s,timescale:n}},t.remuxVideo=function(e,t,i,r){var s,a,n=e.inputTimeScale,o=e.samples,l=[],d=o.length,h=this._initPTS,u=this.nextAvcDts,p=8,f=this.videoSampleDuration,y=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY,g=!1;if(!i||null===u){var A=t*n,v=o[0].pts-wa(o[0].dts,o[0].pts);va&&null!==u&&Math.abs(A-v-u)<15e3?i=!0:u=A-v}for(var b=h.baseTime*n/h.timescale,_=0;_<d;_++){var w=o[_];w.pts=wa(w.pts-b,u),w.dts=wa(w.dts-b,u),w.dts<o[_>0?_-1:_].dts&&(g=!0)}g&&o.sort((function(e,t){var i=e.dts-t.dts,r=e.pts-t.pts;return i||r})),s=o[0].dts;var E=(a=o[o.length-1].dts)-s,S=E?Math.round(E/(d-1)):f||e.inputTimeScale/30;if(i){var T=s-u,R=T>S,x=T<-1;if((R||x)&&(R?G.warn((e.segmentCodec||"").toUpperCase()+": "+pa(T,!0)+" ms ("+T+"dts) hole between fragments detected at "+t.toFixed(3)):G.warn((e.segmentCodec||"").toUpperCase()+": "+pa(-T,!0)+" ms ("+T+"dts) overlapping between fragments detected at "+t.toFixed(3)),!x||u>=o[0].pts||va)){s=u;var L=o[0].pts-T;if(R)o[0].dts=s,o[0].pts=L;else for(var I=!0,P=0;P<o.length&&!(o[P].dts>L&&I);P++){var B=o[P].pts;if(o[P].dts-=T,o[P].pts-=T,P<o.length-1){var M=o[P+1].pts;I=M<=o[P].pts==M<=B}}G.log("Video: Initial PTS/DTS adjusted: "+pa(L,!0)+"/"+pa(s,!0)+", delta: "+pa(T,!0)+" ms")}}for(var U=0,F=0,O=s=Math.max(0,s),N=0;N<d;N++){for(var z=o[N],W=z.units,V=W.length,H=0,$=0;$<V;$++)H+=W[$].data.length;F+=H,U+=V,z.length=H,z.dts<O?(z.dts=O,O+=S/4|0||1):O=z.dts,y=Math.min(z.pts,y),m=Math.max(z.pts,m)}a=o[d-1].dts;var j,K=F+4*U+8;try{j=new Uint8Array(K)}catch(e){return void this.observer.emit(k.ERROR,k.ERROR,{type:C.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:K,reason:"fail allocating video mdat "+K})}var q=new DataView(j.buffer);q.setUint32(0,K),j.set(da.types.mdat,4);for(var Y=!1,Q=Number.POSITIVE_INFINITY,X=Number.POSITIVE_INFINITY,J=Number.NEGATIVE_INFINITY,Z=Number.NEGATIVE_INFINITY,ee=0;ee<d;ee++){for(var te=o[ee],ie=te.units,re=0,se=0,ae=ie.length;se<ae;se++){var ne=ie[se],oe=ne.data,le=ne.data.byteLength;q.setUint32(p,le),p+=4,j.set(oe,p),p+=le,re+=4+le}var de=void 0;if(ee<d-1)f=o[ee+1].dts-te.dts,de=o[ee+1].pts-te.pts;else{var he=this.config,ce=ee>0?te.dts-o[ee-1].dts:S;if(de=ee>0?te.pts-o[ee-1].pts:S,he.stretchShortVideoTrack&&null!==this.nextAudioPts){var ue=Math.floor(he.maxBufferHole*n),pe=(r?y+r*n:this.nextAudioPts)-te.pts;pe>ue?((f=pe-ce)<0?f=ce:Y=!0,G.log("[mp4-remuxer]: It is approximately "+pe/90+" ms to the next segment; using duration "+f/90+" ms for the last video frame.")):f=ce}else f=ce}var fe=Math.round(te.pts-te.dts);Q=Math.min(Q,f),J=Math.max(J,f),X=Math.min(X,de),Z=Math.max(Z,de),l.push(new Ca(te.key,f,re,fe))}if(l.length)if(va){if(va<70){var ye=l[0].flags;ye.dependsOn=2,ye.isNonSync=0}}else if(ba&&Z-X<J-Q&&S/J<.025&&0===l[0].cts){G.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var me=s,ge=0,Ae=l.length;ge<Ae;ge++){var ve=me+l[ge].duration,be=me+l[ge].cts;if(ge<Ae-1){var _e=ve+l[ge+1].cts;l[ge].duration=_e-be}else l[ge].duration=ge?l[ge-1].duration:S;l[ge].cts=0,me=ve}}f=Y||!f?S:f,this.nextAvcDts=u=a+f,this.videoSampleDuration=f,this.isVideoContiguous=!0;var we={data1:da.moof(e.sequenceNumber++,s,c({},e,{samples:l})),data2:j,startPTS:y/n,endPTS:(m+f)/n,startDTS:s/n,endDTS:u/n,type:"video",hasAudio:!1,hasVideo:!0,nb:l.length,dropped:e.dropped};return e.samples=[],e.dropped=0,we},t.getSamplesPerFrame=function(e){switch(e.segmentCodec){case"mp3":return ga;case"ac3":return Aa;default:return ma}},t.remuxAudio=function(e,t,i,r,s){var a=e.inputTimeScale,n=a/(e.samplerate?e.samplerate:a),o=this.getSamplesPerFrame(e),l=o*n,d=this._initPTS,h="mp3"===e.segmentCodec&&this.typeSupported.mpeg,u=[],p=void 0!==s,f=e.samples,y=h?0:8,m=this.nextAudioPts||-1,g=t*a,A=d.baseTime*a/d.timescale;if(this.isAudioContiguous=i=i||f.length&&m>0&&(r&&Math.abs(g-m)<9e3||Math.abs(wa(f[0].pts-A,g)-m)<20*l),f.forEach((function(e){e.pts=wa(e.pts-A,g)})),!i||m<0){if(f=f.filter((function(e){return e.pts>=0})),!f.length)return;m=0===s?0:r&&!p?Math.max(0,g):f[0].pts}if("aac"===e.segmentCodec)for(var v=this.config.maxAudioFramesDrift,b=0,_=m;b<f.length;b++){var w=f[b],E=w.pts,S=E-_,T=Math.abs(1e3*S/a);if(S<=-v*l&&p)0===b&&(G.warn("Audio frame @ "+(E/a).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*S/a)+" ms."),this.nextAudioPts=m=_=E);else if(S>=v*l&&T<ya&&p){var R=Math.round(S/l);(_=E-R*l)<0&&(R--,_+=l),0===b&&(this.nextAudioPts=m=_),G.warn("[mp4-remuxer]: Injecting "+R+" audio frame @ "+(_/a).toFixed(3)+"s due to "+Math.round(1e3*S/a)+" ms gap.");for(var x=0;x<R;x++){var L=Math.max(_,0),I=oa.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);I||(G.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),I=w.unit.subarray()),f.splice(b,0,{unit:I,pts:L}),_+=l,b++}}w.pts=_,_+=l}for(var P,B=null,M=null,U=0,F=f.length;F--;)U+=f[F].unit.byteLength;for(var O=0,N=f.length;O<N;O++){var z=f[O],W=z.unit,V=z.pts;if(null!==M)u[O-1].duration=Math.round((V-M)/n);else{if(i&&"aac"===e.segmentCodec&&(V=m),B=V,!(U>0))return;U+=y;try{P=new Uint8Array(U)}catch(e){return void this.observer.emit(k.ERROR,k.ERROR,{type:C.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:U,reason:"fail allocating audio mdat "+U})}h||(new DataView(P.buffer).setUint32(0,U),P.set(da.types.mdat,4))}P.set(W,y);var H=W.byteLength;y+=H,u.push(new Ca(!0,o,H,0)),M=V}var $=u.length;if($){var j=u[u.length-1];this.nextAudioPts=m=M+n*j.duration;var K=h?new Uint8Array(0):da.moof(e.sequenceNumber++,B/n,c({},e,{samples:u}));e.samples=[];var q=B/a,Y=m/a,Q={data1:K,data2:P,startPTS:q,endPTS:Y,startDTS:q,endDTS:Y,type:"audio",hasAudio:!0,hasVideo:!1,nb:$};return this.isAudioContiguous=!0,Q}},t.remuxEmptyAudio=function(e,t,i,r){var s=e.inputTimeScale,a=s/(e.samplerate?e.samplerate:s),n=this.nextAudioPts,o=this._initDTS,l=9e4*o.baseTime/o.timescale,d=(null!==n?n:r.startDTS*s)+l,h=r.endDTS*s+l,c=a*ma,u=Math.ceil((h-d)/c),p=oa.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);if(G.warn("[mp4-remuxer]: remux empty Audio"),p){for(var f=[],y=0;y<u;y++){var m=d+y*c;f.push({unit:p,pts:m,dts:m})}return e.samples=f,this.remuxAudio(e,t,i,!1)}G.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},e}();function wa(e,t){var i;if(null===t)return e;for(i=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=i;return e}function Ea(e){for(var t=0;t<e.length;t++)if(e[t].key)return t;return-1}function Sa(e,t,i,r){var s=e.samples.length;if(s){for(var a=e.inputTimeScale,n=0;n<s;n++){var o=e.samples[n];o.pts=wa(o.pts-i.baseTime*a/i.timescale,t*a)/a,o.dts=wa(o.dts-r.baseTime*a/r.timescale,t*a)/a}var l=e.samples;return e.samples=[],{samples:l}}}function Ta(e,t,i){var r=e.samples.length;if(r){for(var s=e.inputTimeScale,a=0;a<r;a++){var n=e.samples[a];n.pts=wa(n.pts-i.baseTime*s/i.timescale,t*s)/s}e.samples.sort((function(e,t){return e.pts-t.pts}));var o=e.samples;return e.samples=[],{samples:o}}}var ka,Ca=function(e,t,i,r){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=i,this.cts=r,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}},Da=function(){function e(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}var t=e.prototype;return t.destroy=function(){},t.resetTimeStamp=function(e){this.initPTS=e,this.lastEndTime=null},t.resetNextTimestamp=function(){this.lastEndTime=null},t.resetInitSegment=function(e,t,i,r){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(Fe(e,r)),this.emitInitSegment=!0},t.generateInitSegment=function(e){var t=this.audioCodec,i=this.videoCodec;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var r=this.initData=Ie(e);r.audio&&(t=xa(r.audio,$.AUDIO)),r.video&&(i=xa(r.video,$.VIDEO));var s={};r.audio&&r.video?s.audiovideo={container:"video/mp4",codec:t+","+i,initSegment:e,id:"main"}:r.audio?s.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:r.video?s.video={container:"video/mp4",codec:i,initSegment:e,id:"main"}:G.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=s},t.remux=function(e,t,i,r,s,a){var n,o,l=this.initPTS,d=this.lastEndTime,h={audio:void 0,video:void 0,text:r,id3:i,initSegment:void 0};E(d)||(d=this.lastEndTime=s||0);var c=t.samples;if(null==c||!c.length)return h;var u={initPTS:void 0,timescale:1},p=this.initData;if(null!=(n=p)&&n.length||(this.generateInitSegment(c),p=this.initData),null==(o=p)||!o.length)return G.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),h;this.emitInitSegment&&(u.tracks=this.initTracks,this.emitInitSegment=!1);var f=Ge(c,p),y=Ne(p,c),m=null===y?s:y;(Ra(l,m,s,f)||u.timescale!==l.timescale&&a)&&(u.initPTS=m-s,l&&1===l.timescale&&G.warn("Adjusting initPTS by "+(u.initPTS-l.baseTime)),this.initPTS=l={baseTime:u.initPTS,timescale:1});var g=e?m-l.baseTime/l.timescale:d,A=g+f;We(p,c,l.baseTime/l.timescale),f>0?this.lastEndTime=A:(G.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var v=!!p.audio,b=!!p.video,_="";v&&(_+="audio"),b&&(_+="video");var w={data1:c,startPTS:g,startDTS:g,endPTS:A,endDTS:A,type:_,hasAudio:v,hasVideo:b,nb:1,dropped:0};return h.audio="audio"===w.type?w:void 0,h.video="audio"!==w.type?w:void 0,h.initSegment=u,h.id3=Sa(i,s,l,l),r.samples.length&&(h.text=Ta(r,s,l)),h},e}();function Ra(e,t,i,r){if(null===e)return!0;var s=Math.max(r,1),a=t-e.baseTime/e.timescale;return Math.abs(a-i)>s}function xa(e,t){var i=null==e?void 0:e.codec;if(i&&i.length>4)return i;if(t===$.AUDIO){if("ec-3"===i||"ac-3"===i||"alac"===i)return i;if("fLaC"===i||"Opus"===i)return bt(i,!1);var r="mp4a.40.5";return G.info('Parsed audio codec "'+i+'" or audio object type not handled. Using "'+r+'"'),r}return G.warn('Unhandled video codec "'+i+'"'),"hvc1"===i||"hev1"===i?"hvc1.1.6.L120.90":"av01"===i?"av01.0.04M.08":"avc1.42e01e"}try{ka=self.performance.now.bind(self.performance)}catch(e){G.debug("Unable to use Performance API on this environment"),ka=null==ae?void 0:ae.Date.now}var La=[{demux:Hs,remux:Da},{demux:ea,remux:_a},{demux:Ws,remux:_a},{demux:na,remux:_a}];La.splice(2,0,{demux:js,remux:_a});var Ia=function(){function e(e,t,i,r,s){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=i,this.vendor=r,this.id=s}var t=e.prototype;return t.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},t.push=function(e,t,i,r){var s=this,a=i.transmuxing;a.executeStart=ka();var n=new Uint8Array(e),o=this.currentTransmuxState,l=this.transmuxConfig;r&&(this.currentTransmuxState=r);var d=r||o,h=d.contiguous,c=d.discontinuity,u=d.trackSwitch,p=d.accurateTimeOffset,f=d.timeOffset,y=d.initSegmentChange,m=l.audioCodec,g=l.videoCodec,A=l.defaultInitPts,v=l.duration,b=l.initSegmentData,_=Pa(n,t);if(_&&re(_.method)){var w=this.getDecrypter(),E=se(_.method);if(!w.isSync())return this.decryptionPromise=w.webCryptoDecrypt(n,_.key.buffer,_.iv.buffer,E).then((function(e){var t=s.push(e,null,i);return s.decryptionPromise=null,t})),this.decryptionPromise;var S=w.softwareDecrypt(n,_.key.buffer,_.iv.buffer,E);if(i.part>-1&&(S=w.flush()),!S)return a.executeEnd=ka(),Ba(i);n=new Uint8Array(S)}var T=this.needsProbing(c,u);if(T){var R=this.configureTransmuxer(n);if(R)return G.warn("[transmuxer] "+R.message),this.observer.emit(k.ERROR,k.ERROR,{type:C.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:R,reason:R.message}),a.executeEnd=ka(),Ba(i)}(c||u||y||T)&&this.resetInitSegment(b,m,g,v,t),(c||y||T)&&this.resetInitialTimestamp(A),h||this.resetContiguity();var x=this.transmux(n,_,f,p,i),L=this.currentTransmuxState;return L.contiguous=!0,L.discontinuity=!1,L.trackSwitch=!1,a.executeEnd=ka(),x},t.flush=function(e){var t=this,i=e.transmuxing;i.executeStart=ka();var r=this.decrypter,s=this.currentTransmuxState,a=this.decryptionPromise;if(a)return a.then((function(){return t.flush(e)}));var n=[],o=s.timeOffset;if(r){var l=r.flush();l&&n.push(this.push(l,null,e))}var d=this.demuxer,h=this.remuxer;if(!d||!h)return i.executeEnd=ka(),[Ba(e)];var c=d.flush(o);return Ma(c)?c.then((function(i){return t.flushRemux(n,i,e),n})):(this.flushRemux(n,c,e),n)},t.flushRemux=function(e,t,i){var r=t.audioTrack,s=t.videoTrack,a=t.id3Track,n=t.textTrack,o=this.currentTransmuxState,l=o.accurateTimeOffset,d=o.timeOffset;G.log("[transmuxer.ts]: Flushed fragment "+i.sn+(i.part>-1?" p: "+i.part:"")+" of level "+i.level);var h=this.remuxer.remux(r,s,a,n,d,l,!0,this.id);e.push({remuxResult:h,chunkMeta:i}),i.transmuxing.executeEnd=ka()},t.resetInitialTimestamp=function(e){var t=this.demuxer,i=this.remuxer;t&&i&&(t.resetTimeStamp(e),i.resetTimeStamp(e))},t.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())},t.resetInitSegment=function(e,t,i,r,s){var a=this.demuxer,n=this.remuxer;a&&n&&(a.resetInitSegment(e,t,i,r),n.resetInitSegment(e,t,i,s))},t.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},t.transmux=function(e,t,i,r,s){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,i,r,s):this.transmuxUnencrypted(e,i,r,s)},t.transmuxUnencrypted=function(e,t,i,r){var s=this.demuxer.demux(e,t,!1,!this.config.progressive),a=s.audioTrack,n=s.videoTrack,o=s.id3Track,l=s.textTrack;return{remuxResult:this.remuxer.remux(a,n,o,l,t,i,!1,this.id),chunkMeta:r}},t.transmuxSampleAes=function(e,t,i,r,s){var a=this;return this.demuxer.demuxSampleAes(e,t,i).then((function(e){return{remuxResult:a.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,i,r,!1,a.id),chunkMeta:s}}))},t.configureTransmuxer=function(e){for(var t,i=this.config,r=this.observer,s=this.typeSupported,a=this.vendor,n=0,o=La.length;n<o;n++){var l;if(null!=(l=La[n].demux)&&l.probe(e)){t=La[n];break}}if(!t)return new Error("Failed to find demuxer by probing fragment data");var d=this.demuxer,h=this.remuxer,c=t.remux,u=t.demux;h&&h instanceof c||(this.remuxer=new c(r,i,s,a)),d&&d instanceof u||(this.demuxer=new u(r,i,s),this.probe=u.probe)},t.needsProbing=function(e,t){return!this.demuxer||!this.remuxer||e||t},t.getDecrypter=function(){var e=this.decrypter;return e||(e=this.decrypter=new ns(this.config)),e},e}();function Pa(e,t){var i=null;return e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(i=t),i}var Ba=function(e){return{remuxResult:{},chunkMeta:e}};function Ma(e){return"then"in e&&e.then instanceof Function}var Ua=function(e,t,i,r,s){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=i,this.duration=r,this.defaultInitPts=s||null},Fa=function(e,t,i,r,s,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=i,this.trackSwitch=r,this.timeOffset=s,this.initSegmentChange=a},Oa={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,i="~";function r(){}function s(e,t,i){this.fn=e,this.context=t,this.once=i||!1}function a(e,t,r,a,n){if("function"!=typeof r)throw new TypeError("The listener must be a function");var o=new s(r,a||e,n),l=i?i+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],o]:e._events[l].push(o):(e._events[l]=o,e._eventsCount++),e}function n(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function o(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(i=!1)),o.prototype.eventNames=function(){var e,r,s=[];if(0===this._eventsCount)return s;for(r in e=this._events)t.call(e,r)&&s.push(i?r.slice(1):r);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(e)):s},o.prototype.listeners=function(e){var t=i?i+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var s=0,a=r.length,n=new Array(a);s<a;s++)n[s]=r[s].fn;return n},o.prototype.listenerCount=function(e){var t=i?i+e:e,r=this._events[t];return r?r.fn?1:r.length:0},o.prototype.emit=function(e,t,r,s,a,n){var o=i?i+e:e;if(!this._events[o])return!1;var l,d,h=this._events[o],c=arguments.length;if(h.fn){switch(h.once&&this.removeListener(e,h.fn,void 0,!0),c){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,t),!0;case 3:return h.fn.call(h.context,t,r),!0;case 4:return h.fn.call(h.context,t,r,s),!0;case 5:return h.fn.call(h.context,t,r,s,a),!0;case 6:return h.fn.call(h.context,t,r,s,a,n),!0}for(d=1,l=new Array(c-1);d<c;d++)l[d-1]=arguments[d];h.fn.apply(h.context,l)}else{var u,p=h.length;for(d=0;d<p;d++)switch(h[d].once&&this.removeListener(e,h[d].fn,void 0,!0),c){case 1:h[d].fn.call(h[d].context);break;case 2:h[d].fn.call(h[d].context,t);break;case 3:h[d].fn.call(h[d].context,t,r);break;case 4:h[d].fn.call(h[d].context,t,r,s);break;default:if(!l)for(u=1,l=new Array(c-1);u<c;u++)l[u-1]=arguments[u];h[d].fn.apply(h[d].context,l)}}return!0},o.prototype.on=function(e,t,i){return a(this,e,t,i,!1)},o.prototype.once=function(e,t,i){return a(this,e,t,i,!0)},o.prototype.removeListener=function(e,t,r,s){var a=i?i+e:e;if(!this._events[a])return this;if(!t)return n(this,a),this;var o=this._events[a];if(o.fn)o.fn!==t||s&&!o.once||r&&o.context!==r||n(this,a);else{for(var l=0,d=[],h=o.length;l<h;l++)(o[l].fn!==t||s&&!o[l].once||r&&o[l].context!==r)&&d.push(o[l]);d.length?this._events[a]=1===d.length?d[0]:d:n(this,a)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&n(this,t)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=i,o.EventEmitter=o,e.exports=o}(Oa);var Na=b(Oa.exports);function Ga(e){var t=new Na,i=function(t,i){e.postMessage({event:t,data:i})};t.on(k.FRAG_DECRYPTED,i),t.on(k.ERROR,i);var r=function(e){var t=function(t){var r=function(e){i("workerLog",{logType:t,message:e})};e[t]=r};for(var r in e)t(r)};e.addEventListener("message",(function(s){var a=s.data;switch(a.cmd){case"init":var n=JSON.parse(a.config);e.transmuxer=new Ia(t,a.typeSupported,n,a.vendor,a.id);var o=N(n.debug,a.id);r(o),i("init",null);break;case"configure":e.transmuxer.configure(a.config);break;case"demux":var l=e.transmuxer.push(a.data,a.decryptdata,a.chunkMeta,a.state);Ma(l)?(e.transmuxer.async=!0,l.then((function(t){za(e,t)})).catch((function(e){i(k.ERROR,{type:C.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:a.chunkMeta,fatal:!1,error:e,err:e,reason:"transmuxer-worker push error"})}))):(e.transmuxer.async=!1,za(e,l));break;case"flush":var d=a.chunkMeta,h=e.transmuxer.flush(d);Ma(h)||e.transmuxer.async?(Ma(h)||(h=Promise.resolve(h)),h.then((function(t){Va(e,t,d)})).catch((function(e){i(k.ERROR,{type:C.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:a.chunkMeta,fatal:!1,error:e,err:e,reason:"transmuxer-worker flush error"})}))):Va(e,h,d)}}))}function za(e,t){if(Ha(t.remuxResult))return!1;var i=[],r=t.remuxResult,s=r.audio,a=r.video;return s&&Wa(i,s),a&&Wa(i,a),e.postMessage({event:"transmuxComplete",data:t},i),!0}function Wa(e,t){t.data1&&e.push(t.data1.buffer),t.data2&&e.push(t.data2.buffer)}function Va(e,t,i){t.reduce((function(t,i){return za(e,i)||t}),!1)||e.postMessage({event:"transmuxComplete",data:t[0]}),e.postMessage({event:"flush",data:i})}function Ha(e){return!(e.audio||e.video||e.text||e.id3||e.initSegment)}function $a(){return!0}function ja(){var e=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+t.toString()+")(true);"],{type:"text/javascript"}),i=self.URL.createObjectURL(e);return{worker:new self.Worker(i),objectURL:i}}function Ka(e){var t=new self.URL(e,self.location.href).href;return{worker:new self.Worker(t),scriptURL:t}}void 0!==i&&i&&Ga(self);var qa=function(){function e(e,t,i,r){var s=this;this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;var a=e.config;this.hls=e,this.id=t,this.useWorker=!!a.enableWorker,this.onTransmuxComplete=i,this.onFlush=r;var n=function(e,t){(t=t||{}).frag=s.frag,t.id=s.id,e===k.ERROR&&(s.error=t.error),s.hls.trigger(e,t)};this.observer=new Na,this.observer.on(k.FRAG_DECRYPTED,n),this.observer.on(k.ERROR,n);var o=Et(a.preferManagedMediaSource),l=navigator.vendor;if(this.useWorker&&"undefined"!=typeof Worker&&(a.workerPath||$a()))try{a.workerPath?(G.log("loading Web Worker "+a.workerPath+' for "'+t+'"'),this.workerContext=Ka(a.workerPath)):(G.log('injecting Web Worker for "'+t+'"'),this.workerContext=ja()),this.onwmsg=function(e){return s.onWorkerMessage(e)};var d=this.workerContext.worker;d.addEventListener("message",this.onwmsg),d.onerror=function(e){var i=new Error(e.message+" ("+e.filename+":"+e.lineno+")");a.enableWorker=!1,G.warn('Error in "'+t+'" Web Worker, fallback to inline'),s.hls.trigger(k.ERROR,{type:C.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:i})},d.postMessage({cmd:"init",typeSupported:o,vendor:l,id:t,config:JSON.stringify(a)})}catch(e){G.warn('Error setting up "'+t+'" Web Worker, fallback to inline',e),this.resetWorker(),this.error=null,this.transmuxer=new Ia(this.observer,o,a,l,t)}else this.transmuxer=new Ia(this.observer,o,a,l,t)}var t=e.prototype;return t.resetWorker=function(){if(this.workerContext){var e=this.workerContext,t=e.worker,i=e.objectURL;i&&self.URL.revokeObjectURL(i),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}},t.destroy=function(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},t.push=function(e,t,i,r,s,a,n,o,l,d){var h,c,u=this;l.transmuxing.start=self.performance.now();var p=this.transmuxer,f=a?a.start:s.start,y=s.decryptdata,m=this.frag,g=!(m&&s.cc===m.cc),A=!(m&&l.level===m.level),v=m?l.sn-m.sn:-1,b=this.part?l.part-this.part.index:-1,_=0===v&&l.id>1&&l.id===(null==m?void 0:m.stats.chunkCount),w=!A&&(1===v||0===v&&(1===b||_&&b<=0)),E=self.performance.now();(A||v||0===s.stats.parsing.start)&&(s.stats.parsing.start=E),!a||!b&&w||(a.stats.parsing.start=E);var S=!(m&&(null==(h=s.initSegment)?void 0:h.url)===(null==(c=m.initSegment)?void 0:c.url)),T=new Fa(g,w,o,A,f,S);if(!w||g||S){G.log("[transmuxer-interface, "+s.type+"]: Starting new transmux session for sn: "+l.sn+" p: "+l.part+" level: "+l.level+" id: "+l.id+"\n discontinuity: "+g+"\n trackSwitch: "+A+"\n contiguous: "+w+"\n accurateTimeOffset: "+o+"\n timeOffset: "+f+"\n initSegmentChange: "+S);var k=new Ua(i,r,t,n,d);this.configureTransmuxer(k)}if(this.frag=s,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:y,chunkMeta:l,state:T},e instanceof ArrayBuffer?[e]:[]);else if(p){var C=p.push(e,y,l,T);Ma(C)?(p.async=!0,C.then((function(e){u.handleTransmuxComplete(e)})).catch((function(e){u.transmuxerError(e,l,"transmuxer-interface push error")}))):(p.async=!1,this.handleTransmuxComplete(C))}},t.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var i=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(i){var r=i.flush(e);Ma(r)||i.async?(Ma(r)||(r=Promise.resolve(r)),r.then((function(i){t.handleFlushResult(i,e)})).catch((function(i){t.transmuxerError(i,e,"transmuxer-interface flush error")}))):this.handleFlushResult(r,e)}},t.transmuxerError=function(e,t,i){this.hls&&(this.error=e,this.hls.trigger(k.ERROR,{type:C.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:i}))},t.handleFlushResult=function(e,t){var i=this;e.forEach((function(e){i.handleTransmuxComplete(e)})),this.onFlush(t)},t.onWorkerMessage=function(e){var t=e.data,i=this.hls;switch(t.event){case"init":var r,s=null==(r=this.workerContext)?void 0:r.objectURL;s&&self.URL.revokeObjectURL(s);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":G[t.data.logType]&&G[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,i.trigger(t.event,t.data)}},t.configureTransmuxer=function(e){var t=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)},t.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},e}();function Ya(e,t){if(e.length!==t.length)return!1;for(var i=0;i<e.length;i++)if(!Qa(e[i].attrs,t[i].attrs))return!1;return!0}function Qa(e,t,i){var r=e["STABLE-RENDITION-ID"];return r&&!i?r===t["STABLE-RENDITION-ID"]:!(i||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some((function(i){return e[i]!==t[i]}))}function Xa(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}var Ja=100,Za=function(e){function t(t,i,r){var s;return(s=e.call(this,t,i,r,"audio-stream-controller",Nt.AUDIO)||this).videoBuffer=null,s.videoTrackCC=-1,s.waitingVideoCC=-1,s.bufferedTrack=null,s.switchingTrack=null,s.trackId=-1,s.waitingData=null,s.mainDetails=null,s.flushing=!1,s.bufferFlushed=!1,s.cachedTrackLoadedData=null,s.registerListeners(),s}u(t,e);var i=t.prototype;return i.onHandlerDestroying=function(){this.unregisterListeners(),e.prototype.onHandlerDestroying.call(this),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null},i.registerListeners=function(){e.prototype.registerListeners.call(this);var t=this.hls;t.on(k.LEVEL_LOADED,this.onLevelLoaded,this),t.on(k.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(k.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(k.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(k.BUFFER_RESET,this.onBufferReset,this),t.on(k.BUFFER_CREATED,this.onBufferCreated,this),t.on(k.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(k.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(k.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(k.FRAG_BUFFERED,this.onFragBuffered,this)},i.unregisterListeners=function(){var t=this.hls;t&&(e.prototype.unregisterListeners.call(this),t.off(k.LEVEL_LOADED,this.onLevelLoaded,this),t.off(k.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(k.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(k.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(k.BUFFER_RESET,this.onBufferReset,this),t.off(k.BUFFER_CREATED,this.onBufferCreated,this),t.off(k.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(k.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(k.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(k.FRAG_BUFFERED,this.onFragBuffered,this))},i.onInitPtsFound=function(e,t){var i=t.frag,r=t.id,s=t.initPTS,a=t.timescale;if("main"===r){var n=i.cc;this.initPTS[i.cc]={baseTime:s,timescale:a},this.log("InitPTS for cc: "+n+" found from main: "+s),this.videoTrackCC=n,this.state===ls.WAITING_INIT_PTS&&this.tick()}},i.startLoad=function(e){if(!this.levels)return this.startPosition=e,void(this.state=ls.STOPPED);var t=this.lastCurrentTime;this.stopLoad(),this.setInterval(Ja),t>0&&-1===e?(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t,this.state=ls.IDLE):(this.loadedmetadata=!1,this.state=ls.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()},i.doTick=function(){switch(this.state){case ls.IDLE:this.doTickIdle();break;case ls.WAITING_TRACK:var t,i=this.levels,r=this.trackId,s=null==i||null==(t=i[r])?void 0:t.details;if(s){if(this.waitForCdnTuneIn(s))break;this.state=ls.WAITING_INIT_PTS}break;case ls.FRAG_LOADING_WAITING_RETRY:var a,n=performance.now(),o=this.retryDate;if(!o||n>=o||null!=(a=this.media)&&a.seeking){var l=this.levels,d=this.trackId;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((null==l?void 0:l[d])||null),this.state=ls.IDLE}break;case ls.WAITING_INIT_PTS:var h=this.waitingData;if(h){var c=h.frag,u=h.part,p=h.cache,f=h.complete;if(void 0!==this.initPTS[c.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=ls.FRAG_LOADING;var y={frag:c,part:u,payload:p.flush(),networkDetails:null};this._handleFragmentLoadProgress(y),f&&e.prototype._handleFragmentLoadComplete.call(this,y)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+c.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var m=this.getLoadPosition(),g=Fr.bufferInfo(this.mediaBuffer,m,this.config.maxBufferHole);sr(g.end,this.config.maxFragLookUpTolerance,c)<0&&(this.log("Waiting fragment cc ("+c.cc+") @ "+c.start+" cancelled because another fragment at "+g.end+" is needed"),this.clearWaitingFragment())}}else this.state=ls.IDLE}this.onTickEnd()},i.clearWaitingFragment=function(){var e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state!==ls.STOPPED&&(this.state=ls.IDLE))},i.resetLoadingState=function(){this.clearWaitingFragment(),e.prototype.resetLoadingState.call(this)},i.onTickEnd=function(){var e=this.media;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)},i.doTickIdle=function(){var e=this.hls,t=this.levels,i=this.media,r=this.trackId,s=e.config;if(this.buffering&&(i||!this.startFragRequested&&s.startFragPrefetch)&&null!=t&&t[r]){var a=t[r],n=a.details;if(!n||n.live&&this.levelLastLoaded!==a||this.waitForCdnTuneIn(n))this.state=ls.WAITING_TRACK;else{var o=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&o&&(this.bufferFlushed=!1,this.afterBufferFlushed(o,$.AUDIO,Nt.AUDIO));var l=this.getFwdBufferInfo(o,Nt.AUDIO);if(null!==l){var d=this.bufferedTrack,h=this.switchingTrack;if(!h&&this._streamEnded(l,n))return e.trigger(k.BUFFER_EOS,{type:"audio"}),void(this.state=ls.ENDED);var c=l.len,u=e.maxBufferLength,p=n.fragments,f=p[0].start,y=this.flushing?this.getLoadPosition():l.end;if(h&&i){var m=this.getLoadPosition();d&&!Qa(h.attrs,d.attrs)&&(y=m),n.PTSKnown&&m<f&&(l.end>f||l.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=f+.05)}if(!(c>=u&&!h&&y<p[p.length-1].start)){var g=this.getNextFragment(y,n),A=!1;if(g&&this.isLoopLoading(g,y)&&(A=!!g.gap,g=this.getNextFragmentLoopLoading(g,n,l,Nt.MAIN,u)),g){if(!n.live||y<this.hls.liveSyncPosition){var v=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,Nt.MAIN);if(v&&g.start>v.end+g.duration){var b=this.fragmentTracker.getFragAtPos(g.start,Nt.MAIN);if(null===b)return;if(A||(A=!!b.gap||0===v.len),!A||l.nextStart&&l.nextStart<b.end)return}}this.loadFragment(g,a,y)}else this.bufferFlushed=!0}}}}},i.onMediaDetaching=function(){this.videoBuffer=null,this.bufferFlushed=this.flushing=!1,e.prototype.onMediaDetaching.call(this)},i.onAudioTracksUpdated=function(e,t){var i=t.audioTracks;this.resetTransmuxer(),this.levels=i.map((function(e){return new Bi(e)}))},i.onAudioTrackSwitching=function(e,t){var i=!!t.url;this.trackId=t.id;var r=this.fragCurrent;r&&(r.abortRequests(),this.removeUnbufferedFrags(r.start)),this.resetLoadingState(),i?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==ls.STOPPED&&(this.setInterval(Ja),this.state=ls.IDLE,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())},i.onManifestLoading=function(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=this.flushing=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1},i.onLevelLoaded=function(e,t){this.mainDetails=t.details,null!==this.cachedTrackLoadedData&&(this.hls.trigger(k.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},i.onAudioTrackLoaded=function(e,t){var i;if(null!=this.mainDetails){var r=this.levels,s=t.details,a=t.id;if(r){this.log("Audio track "+a+" loaded ["+s.startSN+","+s.endSN+"]"+(s.lastPartSn?"[part-"+s.lastPartSn+"-"+s.lastPartIndex+"]":"")+",duration:"+s.totalduration);var n=r[a],o=0;if(s.live||null!=(i=n.details)&&i.live){this.checkLiveUpdate(s);var l,d=this.mainDetails;if(s.deltaUpdateFailed||!d)return;!n.details&&s.hasProgramDateTime&&d.hasProgramDateTime?(Kr(s,d),o=s.fragments[0].start):o=this.alignPlaylists(s,n.details,null==(l=this.levelLastLoaded)?void 0:l.details)}n.details=s,this.levelLastLoaded=n,this.startFragRequested||!this.mainDetails&&s.live||this.setStartPosition(this.mainDetails||s,o),this.state!==ls.WAITING_TRACK||this.waitForCdnTuneIn(s)||(this.state=ls.IDLE),this.tick()}else this.warn("Audio tracks were reset while loading level "+a)}else this.cachedTrackLoadedData=t},i._handleFragmentLoadProgress=function(e){var t,i=e.frag,r=e.part,s=e.payload,a=this.config,n=this.trackId,o=this.levels;if(o){var l=o[n];if(l){var d=l.details;if(!d)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(i.start);var h=a.defaultAudioCodec||l.audioCodec||"mp4a.40.2",c=this.transmuxer;c||(c=this.transmuxer=new qa(this.hls,Nt.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var u=this.initPTS[i.cc],p=null==(t=i.initSegment)?void 0:t.data;if(void 0!==u){var f=!1,y=r?r.index:-1,m=-1!==y,g=new Or(i.level,i.sn,i.stats.chunkCount,s.byteLength,y,m);c.push(s,p,h,"",i,r,d.totalduration,f,g,u)}else this.log("Unknown video PTS for cc "+i.cc+", waiting for video PTS before demuxing audio frag "+i.sn+" of ["+d.startSN+" ,"+d.endSN+"],track "+n),(this.waitingData=this.waitingData||{frag:i,part:r,cache:new hs,complete:!1}).cache.push(new Uint8Array(s)),this.waitingVideoCC=this.videoTrackCC,this.state=ls.WAITING_INIT_PTS}else this.warn("Audio track is undefined on fragment load progress")}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+i.sn+" of level "+i.level+" will not be buffered")},i._handleFragmentLoadComplete=function(t){this.waitingData?this.waitingData.complete=!0:e.prototype._handleFragmentLoadComplete.call(this,t)},i.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},i.onBufferCreated=function(e,t){var i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)},i.onFragBuffered=function(e,t){var i=t.frag,r=t.part;if(i.type===Nt.AUDIO)if(this.fragContextChanged(i))this.warn("Fragment "+i.sn+(r?" p: "+r.index:"")+" of level "+i.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+(this.switchingTrack?this.switchingTrack.name:"false"));else{if("initSegment"!==i.sn){this.fragPrevious=i;var s=this.switchingTrack;s&&(this.bufferedTrack=s,this.switchingTrack=null,this.hls.trigger(k.AUDIO_TRACK_SWITCHED,a({},s)))}this.fragBufferedComplete(i,r)}else if(!this.loadedmetadata&&i.type===Nt.MAIN){var n=this.videoBuffer||this.media;n&&Fr.getBuffered(n).length&&(this.loadedmetadata=!0)}},i.onError=function(t,i){var r;if(i.fatal)this.state=ls.ERROR;else switch(i.details){case D.FRAG_GAP:case D.FRAG_PARSING_ERROR:case D.FRAG_DECRYPT_ERROR:case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Nt.AUDIO,i);break;case D.AUDIO_TRACK_LOAD_ERROR:case D.AUDIO_TRACK_LOAD_TIMEOUT:case D.LEVEL_PARSING_ERROR:i.levelRetry||this.state!==ls.WAITING_TRACK||(null==(r=i.context)?void 0:r.type)!==Ot.AUDIO_TRACK||(this.state=ls.IDLE);break;case D.BUFFER_APPEND_ERROR:case D.BUFFER_FULL_ERROR:if(!i.parent||"audio"!==i.parent)return;if(i.details===D.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(i)&&(this.bufferedTrack=null,e.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio"));break;case D.INTERNAL_EXCEPTION:this.recoverWorkerError(i)}},i.onBufferFlushing=function(e,t){t.type!==$.VIDEO&&(this.flushing=!0)},i.onBufferFlushed=function(e,t){var i=t.type;if(i!==$.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===ls.ENDED&&(this.state=ls.IDLE);var r=this.mediaBuffer||this.media;r&&(this.afterBufferFlushed(r,i,Nt.AUDIO),this.tick())}},i._handleTransmuxComplete=function(e){var t,i="audio",r=this.hls,s=e.remuxResult,a=e.chunkMeta,n=this.getCurrentContext(a);if(n){var o=n.frag,l=n.part,d=n.level,h=d.details,u=s.audio,p=s.text,f=s.id3,y=s.initSegment;if(!this.fragContextChanged(o)&&h){if(this.state=ls.PARSING,this.switchingTrack&&u&&this.completeAudioSwitch(this.switchingTrack),null!=y&&y.tracks){var m=o.initSegment||o;this._bufferInitSegment(d,y.tracks,m,a),r.trigger(k.FRAG_PARSING_INIT_SEGMENT,{frag:m,id:i,tracks:y.tracks})}if(u){var g=u.startPTS,A=u.endPTS,v=u.startDTS,b=u.endDTS;l&&(l.elementaryStreams[$.AUDIO]={startPTS:g,endPTS:A,startDTS:v,endDTS:b}),o.setElementaryStreamInfo($.AUDIO,g,A,v,b),this.bufferFragmentData(u,o,l,a)}if(null!=f&&null!=(t=f.samples)&&t.length){var _=c({id:i,frag:o,details:h},f);r.trigger(k.FRAG_PARSING_METADATA,_)}if(p){var w=c({id:i,frag:o,details:h},p);r.trigger(k.FRAG_PARSING_USERDATA,w)}}else this.fragmentTracker.removeFragment(o)}else this.resetWhenMissingContext(a)},i._bufferInitSegment=function(e,t,i,r){if(this.state===ls.PARSING){t.video&&delete t.video;var s=t.audio;if(s){s.id="audio";var a=e.audioCodec;this.log("Init audio buffer, container:"+s.container+", codecs[level/parsed]=["+a+"/"+s.codec+"]"),a&&1===a.split(",").length&&(s.levelCodec=a),this.hls.trigger(k.BUFFER_CODECS,t);var n=s.initSegment;if(null!=n&&n.byteLength){var o={type:"audio",frag:i,part:null,chunkMeta:r,parent:i.type,data:n};this.hls.trigger(k.BUFFER_APPENDING,o)}this.tickImmediate()}}},i.loadFragment=function(t,i,r){var s,a=this.fragmentTracker.getState(t);if(this.fragCurrent=t,this.switchingTrack||a===Ir.NOT_LOADED||a===Ir.PARTIAL)if("initSegment"===t.sn)this._loadInitSegment(t,i);else if(null!=(s=i.details)&&s.live&&!this.initPTS[t.cc]){this.log("Waiting for video PTS in continuity counter "+t.cc+" of live stream before loading audio fragment "+t.sn+" of level "+this.trackId),this.state=ls.WAITING_INIT_PTS;var n=this.mainDetails;n&&n.fragments[0].start!==i.details.fragments[0].start&&Kr(i.details,n)}else this.startFragRequested=!0,e.prototype.loadFragment.call(this,t,i,r);else this.clearTrackerIfNeeded(t)},i.flushAudioIfNeeded=function(t){var i=this.media,r=this.bufferedTrack,s=null==r?void 0:r.attrs,a=t.attrs;i&&s&&(s.CHANNELS!==a.CHANNELS||r.name!==t.name||r.lang!==t.lang)&&(this.log("Switching audio track : flushing all audio"),e.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null)},i.completeAudioSwitch=function(e){var t=this.hls;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(k.AUDIO_TRACK_SWITCHED,a({},e))},t}(ds),en=function(e){function t(t){var i;return(i=e.call(this,t,"audio-track-controller")||this).tracks=[],i.groupIds=null,i.tracksInGroup=[],i.trackId=-1,i.currentTrack=null,i.selectDefaultTrack=!0,i.registerListeners(),i}u(t,e);var i=t.prototype;return i.registerListeners=function(){var e=this.hls;e.on(k.MANIFEST_LOADING,this.onManifestLoading,this),e.on(k.MANIFEST_PARSED,this.onManifestParsed,this),e.on(k.LEVEL_LOADING,this.onLevelLoading,this),e.on(k.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(k.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(k.ERROR,this.onError,this)},i.unregisterListeners=function(){var e=this.hls;e.off(k.MANIFEST_LOADING,this.onManifestLoading,this),e.off(k.MANIFEST_PARSED,this.onManifestParsed,this),e.off(k.LEVEL_LOADING,this.onLevelLoading,this),e.off(k.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(k.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(k.ERROR,this.onError,this)},i.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,e.prototype.destroy.call(this)},i.onManifestLoading=function(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0},i.onManifestParsed=function(e,t){this.tracks=t.audioTracks||[]},i.onAudioTrackLoaded=function(e,t){var i=t.id,r=t.groupId,s=t.details,a=this.tracksInGroup[i];if(a&&a.groupId===r){var n=a.details;a.details=t.details,this.log("Audio track "+i+' "'+a.name+'" lang:'+a.lang+" group:"+r+" loaded ["+s.startSN+"-"+s.endSN+"]"),i===this.trackId&&this.playlistLoaded(i,t,n)}else this.warn("Audio track with id:"+i+" and group:"+r+" not found in active group "+(null==a?void 0:a.groupId))},i.onLevelLoading=function(e,t){this.switchLevel(t.level)},i.onLevelSwitching=function(e,t){this.switchLevel(t.level)},i.switchLevel=function(e){var t=this.hls.levels[e];if(t){var i=t.audioGroups||null,r=this.groupIds,s=this.currentTrack;if(!i||(null==r?void 0:r.length)!==(null==i?void 0:i.length)||null!=i&&i.some((function(e){return-1===(null==r?void 0:r.indexOf(e))}))){this.groupIds=i,this.trackId=-1,this.currentTrack=null;var a=this.tracks.filter((function(e){return!i||-1!==i.indexOf(e.groupId)}));if(a.length)this.selectDefaultTrack&&!a.some((function(e){return e.default}))&&(this.selectDefaultTrack=!1),a.forEach((function(e,t){e.id=t}));else if(!s&&!this.tracksInGroup.length)return;this.tracksInGroup=a;var n=this.hls.config.audioPreference;if(!s&&n){var o=Sr(n,a,Cr);if(o>-1)s=a[o];else{var l=Sr(n,this.tracks);s=this.tracks[l]}}var d=this.findTrackId(s);-1===d&&s&&(d=this.findTrackId(null));var h={audioTracks:a};this.log("Updating audio tracks, "+a.length+" track(s) found in group(s): "+(null==i?void 0:i.join(","))),this.hls.trigger(k.AUDIO_TRACKS_UPDATED,h);var c=this.trackId;if(-1!==d&&-1===c)this.setAudioTrack(d);else if(a.length&&-1===c){var u,p=new Error("No audio track selected for current audio group-ID(s): "+(null==(u=this.groupIds)?void 0:u.join(","))+" track count: "+a.length);this.warn(p.message),this.hls.trigger(k.ERROR,{type:C.MEDIA_ERROR,details:D.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:p})}}else this.shouldReloadPlaylist(s)&&this.setAudioTrack(this.trackId)}},i.onError=function(e,t){!t.fatal&&t.context&&(t.context.type!==Ot.AUDIO_TRACK||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||(this.requestScheduled=-1,this.checkRetry(t)))},i.setAudioOption=function(e){var t=this.hls;if(t.config.audioPreference=e,e){var i=this.allAudioTracks;if(this.selectDefaultTrack=!1,i.length){var r=this.currentTrack;if(r&&Tr(e,r,Cr))return r;var s=Sr(e,this.tracksInGroup,Cr);if(s>-1){var a=this.tracksInGroup[s];return this.setAudioTrack(s),a}if(r){var n=t.loadLevel;-1===n&&(n=t.firstAutoLevel);var o=Dr(e,t.levels,i,n,Cr);if(-1===o)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){var l=Sr(e,i);if(l>-1)return i[l]}}}return null},i.setAudioTrack=function(e){var t=this.tracksInGroup;if(e<0||e>=t.length)this.warn("Invalid audio track id: "+e);else{this.clearTimer(),this.selectDefaultTrack=!1;var i=this.currentTrack,r=t[e],s=r.details&&!r.details.live;if(!(e===this.trackId&&r===i&&s||(this.log("Switching to audio-track "+e+' "'+r.name+'" lang:'+r.lang+" group:"+r.groupId+" channels:"+r.channels),this.trackId=e,this.currentTrack=r,this.hls.trigger(k.AUDIO_TRACK_SWITCHING,a({},r)),s))){var n=this.switchParams(r.url,null==i?void 0:i.details,r.details);this.loadPlaylist(n)}}},i.findTrackId=function(e){for(var t=this.tracksInGroup,i=0;i<t.length;i++){var r=t[i];if((!this.selectDefaultTrack||r.default)&&(!e||Tr(e,r,Cr)))return i}if(e){for(var s=e.name,a=e.lang,n=e.assocLang,o=e.characteristics,l=e.audioCodec,d=e.channels,h=0;h<t.length;h++)if(Tr({name:s,lang:a,assocLang:n,characteristics:o,audioCodec:l,channels:d},t[h],Cr))return h;for(var c=0;c<t.length;c++){var u=t[c];if(Qa(e.attrs,u.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return c}for(var p=0;p<t.length;p++){var f=t[p];if(Qa(e.attrs,f.attrs,["LANGUAGE"]))return p}}return-1},i.loadPlaylist=function(t){var i=this.currentTrack;if(this.shouldLoadPlaylist(i)&&i){e.prototype.loadPlaylist.call(this);var r=i.id,s=i.groupId,a=i.url;if(t)try{a=t.addDirectives(a)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}this.log("loading audio-track playlist "+r+' "'+i.name+'" lang:'+i.lang+" group:"+s),this.clearTimer(),this.hls.trigger(k.AUDIO_TRACK_LOADING,{url:a,id:r,groupId:s,deliveryDirectives:t||null})}},d(t,[{key:"allAudioTracks",get:function(){return this.tracks}},{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}}])}(hr),tn=500,rn=function(e){function t(t,i,r){var s;return(s=e.call(this,t,i,r,"subtitle-stream-controller",Nt.SUBTITLE)||this).currentTrackId=-1,s.tracksBuffered=[],s.mainDetails=null,s.registerListeners(),s}u(t,e);var i=t.prototype;return i.onHandlerDestroying=function(){this.unregisterListeners(),e.prototype.onHandlerDestroying.call(this),this.mainDetails=null},i.registerListeners=function(){e.prototype.registerListeners.call(this);var t=this.hls;t.on(k.LEVEL_LOADED,this.onLevelLoaded,this),t.on(k.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(k.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(k.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(k.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(k.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(k.FRAG_BUFFERED,this.onFragBuffered,this)},i.unregisterListeners=function(){e.prototype.unregisterListeners.call(this);var t=this.hls;t.off(k.LEVEL_LOADED,this.onLevelLoaded,this),t.off(k.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(k.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(k.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(k.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(k.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(k.FRAG_BUFFERED,this.onFragBuffered,this)},i.startLoad=function(e){this.stopLoad(),this.state=ls.IDLE,this.setInterval(tn),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()},i.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},i.onMediaDetaching=function(){this.tracksBuffered=[],e.prototype.onMediaDetaching.call(this)},i.onLevelLoaded=function(e,t){this.mainDetails=t.details},i.onSubtitleFragProcessed=function(e,t){var i=t.frag,r=t.success;if(this.fragPrevious=i,this.state=ls.IDLE,r){var s=this.tracksBuffered[this.currentTrackId];if(s){for(var a,n=i.start,o=0;o<s.length;o++)if(n>=s[o].start&&n<=s[o].end){a=s[o];break}var l=i.start+i.duration;a?a.end=l:(a={start:n,end:l},s.push(a)),this.fragmentTracker.fragBuffered(i),this.fragBufferedComplete(i,null)}}},i.onBufferFlushing=function(e,t){var i=t.startOffset,r=t.endOffset;if(0===i&&r!==Number.POSITIVE_INFINITY){var s=r-1;if(s<=0)return;t.endOffsetSubtitles=Math.max(0,s),this.tracksBuffered.forEach((function(e){for(var t=0;t<e.length;)if(e[t].end<=s)e.shift();else{if(!(e[t].start<s))break;e[t].start=s,t++}})),this.fragmentTracker.removeFragmentsInRange(i,s,Nt.SUBTITLE)}},i.onFragBuffered=function(e,t){var i;this.loadedmetadata||t.frag.type!==Nt.MAIN||null!=(i=this.media)&&i.buffered.length&&(this.loadedmetadata=!0)},i.onError=function(e,t){var i=t.frag;(null==i?void 0:i.type)===Nt.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==ls.STOPPED&&(this.state=ls.IDLE))},i.onSubtitleTracksUpdated=function(e,t){var i=this,r=t.subtitleTracks;this.levels&&Ya(this.levels,r)?this.levels=r.map((function(e){return new Bi(e)})):(this.tracksBuffered=[],this.levels=r.map((function(e){var t=new Bi(e);return i.tracksBuffered[t.id]=[],t})),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Nt.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null)},i.onSubtitleTrackSwitch=function(e,t){var i;if(this.currentTrackId=t.id,null!=(i=this.levels)&&i.length&&-1!==this.currentTrackId){var r=this.levels[this.currentTrackId];null!=r&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.state!==ls.STOPPED&&this.setInterval(tn)}else this.clearInterval()},i.onSubtitleTrackLoaded=function(e,t){var i,r=this.currentTrackId,s=this.levels,a=t.details,n=t.id;if(s){var o=s[r];if(!(n>=s.length||n!==r)&&o){this.log("Subtitle track "+n+" loaded ["+a.startSN+","+a.endSN+"]"+(a.lastPartSn?"[part-"+a.lastPartSn+"-"+a.lastPartIndex+"]":"")+",duration:"+a.totalduration),this.mediaBuffer=this.mediaBufferTimeRanges;var l=0;if(a.live||null!=(i=o.details)&&i.live){var d=this.mainDetails;if(a.deltaUpdateFailed||!d)return;var h,c=d.fragments[0];o.details?0===(l=this.alignPlaylists(a,o.details,null==(h=this.levelLastLoaded)?void 0:h.details))&&c&&Vi(a,l=c.start):a.hasProgramDateTime&&d.hasProgramDateTime?(Kr(a,d),l=a.fragments[0].start):c&&Vi(a,l=c.start)}o.details=a,this.levelLastLoaded=o,this.startFragRequested||!this.mainDetails&&a.live||this.setStartPosition(this.mainDetails||a,l),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===ls.IDLE&&(rr(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),o.details=void 0))}}else this.warn("Subtitle tracks were reset while loading level "+n)},i._handleFragmentLoadComplete=function(e){var t=this,i=e.frag,r=e.payload,s=i.decryptdata,a=this.hls;if(!this.fragContextChanged(i)&&r&&r.byteLength>0&&null!=s&&s.key&&s.iv&&re(s.method)){var n=performance.now();this.decrypter.decrypt(new Uint8Array(r),s.key.buffer,s.iv.buffer,se(s.method)).catch((function(e){throw a.trigger(k.ERROR,{type:C.MEDIA_ERROR,details:D.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:i}),e})).then((function(e){var t=performance.now();a.trigger(k.FRAG_DECRYPTED,{frag:i,payload:e,stats:{tstart:n,tdecrypt:t}})})).catch((function(e){t.warn(e.name+": "+e.message),t.state=ls.IDLE}))}},i.doTick=function(){if(this.media){if(this.state===ls.IDLE){var e=this.currentTrackId,t=this.levels,i=null==t?void 0:t[e];if(!i||!t.length||!i.details)return;var r=this.config,s=this.getLoadPosition(),a=Fr.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],s,r.maxBufferHole),n=a.end,o=a.len,l=i.details;if(o>this.hls.maxBufferLength+l.levelTargetDuration)return;var d=l.fragments,h=d.length,c=l.edge,u=null,p=this.fragPrevious;if(n<c){var f=r.maxFragLookUpTolerance,y=n>c-f?0:f;!(u=rr(p,d,Math.max(d[0].start,n),y))&&p&&p.start<d[0].start&&(u=d[0])}else u=d[h-1];if(!u)return;if("initSegment"!==(u=this.mapToInitFragWhenRequired(u)).sn){var m=d[u.sn-l.startSN-1];m&&m.cc===u.cc&&this.fragmentTracker.getState(m)===Ir.NOT_LOADED&&(u=m)}this.fragmentTracker.getState(u)===Ir.NOT_LOADED&&this.loadFragment(u,i,n)}}else this.state=ls.IDLE},i.loadFragment=function(t,i,r){this.fragCurrent=t,"initSegment"===t.sn?this._loadInitSegment(t,i):(this.startFragRequested=!0,e.prototype.loadFragment.call(this,t,i,r))},d(t,[{key:"mediaBufferTimeRanges",get:function(){return new sn(this.tracksBuffered[this.currentTrackId]||[])}}])}(ds),sn=function(e){this.buffered=void 0;var t=function(t,i,r){if((i>>>=0)>r-1)throw new DOMException("Failed to execute '"+t+"' on 'TimeRanges': The index provided ("+i+") is greater than the maximum bound ("+r+")");return e[i][t]};this.buffered={get length(){return e.length},end:function(i){return t("end",i,e.length)},start:function(i){return t("start",i,e.length)}}},an=function(e){function t(t){var i;return(i=e.call(this,t,"subtitle-track-controller")||this).media=null,i.tracks=[],i.groupIds=null,i.tracksInGroup=[],i.trackId=-1,i.currentTrack=null,i.selectDefaultTrack=!0,i.queuedDefaultTrack=-1,i.useTextTrackPolling=!1,i.subtitlePollingInterval=-1,i._subtitleDisplay=!0,i.asyncPollTrackChange=function(){return i.pollTrackChange(0)},i.onTextTracksChanged=function(){if(i.useTextTrackPolling||self.clearInterval(i.subtitlePollingInterval),i.media&&i.hls.config.renderTextTracksNatively){for(var e=null,t=Yt(i.media.textTracks),r=0;r<t.length;r++)if("hidden"===t[r].mode)e=t[r];else if("showing"===t[r].mode){e=t[r];break}var s=i.findTrackForTextTrack(e);i.subtitleTrack!==s&&i.setSubtitleTrack(s)}},i.registerListeners(),i}u(t,e);var i=t.prototype;return i.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,e.prototype.destroy.call(this)},i.registerListeners=function(){var e=this.hls;e.on(k.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(k.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(k.MANIFEST_LOADING,this.onManifestLoading,this),e.on(k.MANIFEST_PARSED,this.onManifestParsed,this),e.on(k.LEVEL_LOADING,this.onLevelLoading,this),e.on(k.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(k.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(k.ERROR,this.onError,this)},i.unregisterListeners=function(){var e=this.hls;e.off(k.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(k.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(k.MANIFEST_LOADING,this.onManifestLoading,this),e.off(k.MANIFEST_PARSED,this.onManifestParsed,this),e.off(k.LEVEL_LOADING,this.onLevelLoading,this),e.off(k.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(k.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(k.ERROR,this.onError,this)},i.onMediaAttached=function(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},i.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)},i.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),Yt(this.media.textTracks).forEach((function(e){$t(e)})),this.subtitleTrack=-1,this.media=null)},i.onManifestLoading=function(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0},i.onManifestParsed=function(e,t){this.tracks=t.subtitleTracks},i.onSubtitleTrackLoaded=function(e,t){var i=t.id,r=t.groupId,s=t.details,a=this.tracksInGroup[i];if(a&&a.groupId===r){var n=a.details;a.details=t.details,this.log("Subtitle track "+i+' "'+a.name+'" lang:'+a.lang+" group:"+r+" loaded ["+s.startSN+"-"+s.endSN+"]"),i===this.trackId&&this.playlistLoaded(i,t,n)}else this.warn("Subtitle track with id:"+i+" and group:"+r+" not found in active group "+(null==a?void 0:a.groupId))},i.onLevelLoading=function(e,t){this.switchLevel(t.level)},i.onLevelSwitching=function(e,t){this.switchLevel(t.level)},i.switchLevel=function(e){var t=this.hls.levels[e];if(t){var i=t.subtitleGroups||null,r=this.groupIds,s=this.currentTrack;if(!i||(null==r?void 0:r.length)!==(null==i?void 0:i.length)||null!=i&&i.some((function(e){return-1===(null==r?void 0:r.indexOf(e))}))){this.groupIds=i,this.trackId=-1,this.currentTrack=null;var a=this.tracks.filter((function(e){return!i||-1!==i.indexOf(e.groupId)}));if(a.length)this.selectDefaultTrack&&!a.some((function(e){return e.default}))&&(this.selectDefaultTrack=!1),a.forEach((function(e,t){e.id=t}));else if(!s&&!this.tracksInGroup.length)return;this.tracksInGroup=a;var n=this.hls.config.subtitlePreference;if(!s&&n){this.selectDefaultTrack=!1;var o=Sr(n,a);if(o>-1)s=a[o];else{var l=Sr(n,this.tracks);s=this.tracks[l]}}var d=this.findTrackId(s);-1===d&&s&&(d=this.findTrackId(null));var h={subtitleTracks:a};this.log("Updating subtitle tracks, "+a.length+' track(s) found in "'+(null==i?void 0:i.join(","))+'" group-id'),this.hls.trigger(k.SUBTITLE_TRACKS_UPDATED,h),-1!==d&&-1===this.trackId&&this.setSubtitleTrack(d)}else this.shouldReloadPlaylist(s)&&this.setSubtitleTrack(this.trackId)}},i.findTrackId=function(e){for(var t=this.tracksInGroup,i=this.selectDefaultTrack,r=0;r<t.length;r++){var s=t[r];if((!i||s.default)&&(i||e)&&(!e||Tr(s,e)))return r}if(e){for(var a=0;a<t.length;a++){var n=t[a];if(Qa(e.attrs,n.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return a}for(var o=0;o<t.length;o++){var l=t[o];if(Qa(e.attrs,l.attrs,["LANGUAGE"]))return o}}return-1},i.findTrackForTextTrack=function(e){if(e)for(var t=this.tracksInGroup,i=0;i<t.length;i++)if(Xa(t[i],e))return i;return-1},i.onError=function(e,t){!t.fatal&&t.context&&(t.context.type!==Ot.SUBTITLE_TRACK||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))},i.setSubtitleOption=function(e){if(this.hls.config.subtitlePreference=e,e){var t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){var i=this.currentTrack;if(i&&Tr(e,i))return i;var r=Sr(e,this.tracksInGroup);if(r>-1){var s=this.tracksInGroup[r];return this.setSubtitleTrack(r),s}if(i)return null;var a=Sr(e,t);if(a>-1)return t[a]}}return null},i.loadPlaylist=function(t){e.prototype.loadPlaylist.call(this);var i=this.currentTrack;if(this.shouldLoadPlaylist(i)&&i){var r=i.id,s=i.groupId,a=i.url;if(t)try{a=t.addDirectives(a)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}this.log("Loading subtitle playlist for id "+r),this.hls.trigger(k.SUBTITLE_TRACK_LOADING,{url:a,id:r,groupId:s,deliveryDirectives:t||null})}},i.toggleTrackModes=function(){var e=this.media;if(e){var t,i=Yt(e.textTracks),r=this.currentTrack;if(r&&((t=i.filter((function(e){return Xa(r,e)}))[0])||this.warn('Unable to find subtitle TextTrack with name "'+r.name+'" and language "'+r.lang+'"')),[].slice.call(i).forEach((function(e){"disabled"!==e.mode&&e!==t&&(e.mode="disabled")})),t){var s=this.subtitleDisplay?"showing":"hidden";t.mode!==s&&(t.mode=s)}}},i.setSubtitleTrack=function(e){var t=this.tracksInGroup;if(this.media)if(e<-1||e>=t.length||!E(e))this.warn("Invalid subtitle track id: "+e);else{this.clearTimer(),this.selectDefaultTrack=!1;var i=this.currentTrack,r=t[e]||null;if(this.trackId=e,this.currentTrack=r,this.toggleTrackModes(),r){var s=!!r.details&&!r.details.live;if(e!==this.trackId||r!==i||!s){this.log("Switching to subtitle-track "+e+(r?' "'+r.name+'" lang:'+r.lang+" group:"+r.groupId:""));var a=r.id,n=r.groupId,o=void 0===n?"":n,l=r.name,d=r.type,h=r.url;this.hls.trigger(k.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:l,type:d,url:h});var c=this.switchParams(r.url,null==i?void 0:i.details,r.details);this.loadPlaylist(c)}}else this.hls.trigger(k.SUBTITLE_TRACK_SWITCH,{id:e})}else this.queuedDefaultTrack=e},d(t,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}},{key:"allSubtitleTracks",get:function(){return this.tracks}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}}])}(hr),nn=function(){function e(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}var t=e.prototype;return t.append=function(e,t,i){var r=this.queues[t];r.push(e),1!==r.length||i||this.executeNext(t)},t.appendBlocker=function(e){var t=this;return new Promise((function(i){var r={execute:i,onStart:function(){},onComplete:function(){},onError:function(){}};t.append(r,e)}))},t.unblockAudio=function(e){this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio")},t.executeNext=function(e){var t=this.queues[e];if(t.length){var i=t[0];try{i.execute()}catch(t){G.warn('[buffer-operation-queue]: Exception executing "'+e+'" SourceBuffer operation: '+t),i.onError(t);var r=this.buffers[e];null!=r&&r.updating||this.shiftAndExecuteNext(e)}}},t.shiftAndExecuteNext=function(e){this.queues[e].shift(),this.executeNext(e)},t.current=function(e){return this.queues[e][0]},e}(),on=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,ln=function(e){function t(t,i){var r;return(r=e.call(this,"buffer-controller",t.logger)||this).details=null,r._objectUrl=null,r.operationQueue=void 0,r.listeners=void 0,r.hls=void 0,r.fragmentTracker=void 0,r.bufferCodecEventsExpected=0,r._bufferCodecEventsTotal=0,r.media=null,r.mediaSource=null,r.lastMpegAudioChunk=null,r.blockedAudioAppend=null,r.lastVideoAppendEnd=0,r.appendSource=void 0,r.appendErrors={audio:0,video:0,audiovideo:0},r.tracks={},r.pendingTracks={},r.sourceBuffer=void 0,r._onEndStreaming=function(e){r.hls&&r.hls.pauseBuffering()},r._onStartStreaming=function(e){r.hls&&r.hls.resumeBuffering()},r._onMediaSourceOpen=function(){var e=r,t=e.media,i=e.mediaSource;if(r.log("Media source opened"),t){t.removeEventListener("emptied",r._onMediaEmptied);var s=r.getDurationAndRange();s&&r.updateMediaSource(s),r.hls.trigger(k.MEDIA_ATTACHED,{media:t,mediaSource:i})}i&&i.removeEventListener("sourceopen",r._onMediaSourceOpen),r.checkPendingTracks()},r._onMediaSourceClose=function(){r.log("Media source closed")},r._onMediaSourceEnded=function(){r.log("Media source ended")},r._onMediaEmptied=function(){var e=r,t=e.mediaSrc,i=e._objectUrl;t!==i&&r.error("Media element src was set while attaching MediaSource ("+i+" > "+t+")")},r.hls=t,r.fragmentTracker=i,r.appendSource=t.config.preferManagedMediaSource&&"undefined"!=typeof self&&self.ManagedMediaSource,r._initSourceBuffer(),r.registerListeners(),r}u(t,e);var i=t.prototype;return i.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},i.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null},i.registerListeners=function(){var e=this.hls;e.on(k.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(k.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(k.MANIFEST_LOADING,this.onManifestLoading,this),e.on(k.MANIFEST_PARSED,this.onManifestParsed,this),e.on(k.BUFFER_RESET,this.onBufferReset,this),e.on(k.BUFFER_APPENDING,this.onBufferAppending,this),e.on(k.BUFFER_CODECS,this.onBufferCodecs,this),e.on(k.BUFFER_EOS,this.onBufferEos,this),e.on(k.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(k.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(k.FRAG_PARSED,this.onFragParsed,this),e.on(k.FRAG_CHANGED,this.onFragChanged,this)},i.unregisterListeners=function(){var e=this.hls;e.off(k.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(k.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(k.MANIFEST_LOADING,this.onManifestLoading,this),e.off(k.MANIFEST_PARSED,this.onManifestParsed,this),e.off(k.BUFFER_RESET,this.onBufferReset,this),e.off(k.BUFFER_APPENDING,this.onBufferAppending,this),e.off(k.BUFFER_CODECS,this.onBufferCodecs,this),e.off(k.BUFFER_EOS,this.onBufferEos,this),e.off(k.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(k.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(k.FRAG_PARSED,this.onFragParsed,this),e.off(k.FRAG_CHANGED,this.onFragChanged,this)},i._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new nn(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null,this.blockedAudioAppend=null,this.lastVideoAppendEnd=0},i.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},i.onManifestParsed=function(e,t){var i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,this.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},i.onMediaAttaching=function(e,t){var i=this.media=t.media,r=dt(this.appendSource);if(i&&r){var s,a=this.mediaSource=new r;this.log("created media source: "+(null==(s=a.constructor)?void 0:s.name)),a.addEventListener("sourceopen",this._onMediaSourceOpen),a.addEventListener("sourceended",this._onMediaSourceEnded),a.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(a.addEventListener("startstreaming",this._onStartStreaming),a.addEventListener("endstreaming",this._onEndStreaming));var n=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{i.removeAttribute("src");var o=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||o&&a instanceof o,dn(i),hn(i,n),i.load()}catch(e){i.src=n}else i.src=n;i.addEventListener("emptied",this._onMediaEmptied)}},i.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,i=this._objectUrl;if(t){if(this.log("media source detaching"),"open"===t.readyState)try{t.endOfStream()}catch(e){this.warn("onMediaDetaching: "+e.message+" while calling endOfStream")}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}e&&(e.removeEventListener("emptied",this._onMediaEmptied),i&&self.URL.revokeObjectURL(i),this.mediaSrc===i?(e.removeAttribute("src"),this.appendSource&&dn(e),e.load()):this.warn("media|source.src was changed by a third party - skip cleanup"),this.media=null),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={},this.hls.trigger(k.MEDIA_DETACHED,void 0)},i.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach((function(t){e.resetBuffer(t)})),this._initSourceBuffer(),this.hls.resumeBuffering()},i.resetBuffer=function(e){var t=this.sourceBuffer[e];try{var i;t&&(this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,null!=(i=this.mediaSource)&&i.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t))}catch(t){this.warn("onBufferReset "+e,t)}},i.onBufferCodecs=function(e,t){var i=this,r=this.getSourceBufferTypes().length,s=Object.keys(t);if(s.forEach((function(e){if(r){var s,a=i.tracks[e];if(a&&"function"==typeof(null==(s=a.buffer)?void 0:s.changeType)){var n,o=t[e],l=o.id,d=o.codec,h=o.levelCodec,c=o.container,u=o.metadata,p=_t(a.codec,a.levelCodec),f=null==p?void 0:p.replace(on,"$1"),y=_t(d,h),m=null==(n=y)?void 0:n.replace(on,"$1");if(y&&f!==m){"audio"===e.slice(0,5)&&(y=bt(y,i.appendSource));var g=c+";codecs="+y;i.appendChangeType(e,g),i.log("switching codec "+p+" to "+y),i.tracks[e]={buffer:a.buffer,codec:d,container:c,levelCodec:h,metadata:u,id:l}}}}else i.pendingTracks[e]=t[e]})),!r){var a=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==a&&(this.log(a+" bufferCodec event(s) expected "+s.join(",")),this.bufferCodecEventsExpected=a),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks()}},i.appendChangeType=function(e,t){var i=this,r=this.operationQueue,s={execute:function(){var s=i.sourceBuffer[e];s&&(i.log("changing "+e+" sourceBuffer type to "+t),s.changeType(t)),r.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(t){i.warn("Failed to change "+e+" SourceBuffer type",t)}};r.append(s,e,!!this.pendingTracks[e])},i.blockAudio=function(e){var t,i=this,r=e.start,s=r+.05*e.duration;if(!0!==(null==(t=this.fragmentTracker.getAppendedFrag(r,Nt.MAIN))?void 0:t.gap)){var a={execute:function(){var e;(i.lastVideoAppendEnd>s||i.sourceBuffer.video&&Fr.isBuffered(i.sourceBuffer.video,s)||!0===(null==(e=i.fragmentTracker.getAppendedFrag(s,Nt.MAIN))?void 0:e.gap))&&(i.blockedAudioAppend=null,i.operationQueue.shiftAndExecuteNext("audio"))},onStart:function(){},onComplete:function(){},onError:function(){}};this.blockedAudioAppend={op:a,frag:e},this.operationQueue.append(a,"audio",!0)}},i.unblockAudio=function(){var e=this.blockedAudioAppend;e&&(this.blockedAudioAppend=null,this.operationQueue.unblockAudio(e.op))},i.onBufferAppending=function(e,t){var i=this,r=this.operationQueue,s=this.tracks,a=t.data,n=t.type,o=t.parent,l=t.frag,d=t.part,h=t.chunkMeta,c=h.buffering[n],u=l.sn,p=self.performance.now();c.start=p;var f=l.stats.buffering,y=d?d.stats.buffering:null;0===f.start&&(f.start=p),y&&0===y.start&&(y.start=p);var m=s.audio,g=!1;"audio"===n&&"audio/mpeg"===(null==m?void 0:m.container)&&(g=!this.lastMpegAudioChunk||1===h.id||this.lastMpegAudioChunk.sn!==h.sn,this.lastMpegAudioChunk=h);var A=this.sourceBuffer.video;if(A&&"initSegment"!==u){var v=d||l,b=this.blockedAudioAppend;if("audio"!==n||"main"===o||this.blockedAudioAppend){if("video"===n){var _=v.end;if(b){var w=b.frag.start;(_>w||_<this.lastVideoAppendEnd||Fr.isBuffered(A,w))&&this.unblockAudio()}this.lastVideoAppendEnd=_}}else{var E=v.start+.05*v.duration,S=A.buffered,T=this.operationQueue.current("video");S.length||T?!T&&!Fr.isBuffered(A,E)&&this.lastVideoAppendEnd<E&&this.blockAudio(v):this.blockAudio(v)}}var R=(d||l).start,x={execute:function(){if(c.executeStart=self.performance.now(),g){var e=i.sourceBuffer[n];if(e){var t=R-e.timestampOffset;Math.abs(t)>=.1&&(i.log("Updating audio SourceBuffer timestampOffset to "+R+" (delta: "+t+") sn: "+u+")"),e.timestampOffset=R)}}i.appendExecutor(a,n)},onStart:function(){},onComplete:function(){var e=self.performance.now();c.executeEnd=c.end=e,0===f.first&&(f.first=e),y&&0===y.first&&(y.first=e);var t=i.sourceBuffer,r={};for(var s in t)r[s]=Fr.getBuffered(t[s]);i.appendErrors[n]=0,"audio"===n||"video"===n?i.appendErrors.audiovideo=0:(i.appendErrors.audio=0,i.appendErrors.video=0),i.hls.trigger(k.BUFFER_APPENDED,{type:n,frag:l,part:d,chunkMeta:h,parent:l.type,timeRanges:r})},onError:function(e){var t={type:C.MEDIA_ERROR,parent:l.type,details:D.BUFFER_APPEND_ERROR,sourceBufferName:n,frag:l,part:d,chunkMeta:h,error:e,err:e,fatal:!1};if(e.code===DOMException.QUOTA_EXCEEDED_ERR)t.details=D.BUFFER_FULL_ERROR;else{var r=++i.appendErrors[n];t.details=D.BUFFER_APPEND_ERROR,i.warn("Failed "+r+"/"+i.hls.config.appendErrorMaxRetry+' times to append segment in "'+n+'" sourceBuffer'),r>=i.hls.config.appendErrorMaxRetry&&(t.fatal=!0)}i.hls.trigger(k.ERROR,t)}};r.append(x,n,!!this.pendingTracks[n])},i.getFlushOp=function(e,t,i){var r=this;return{execute:function(){r.removeExecutor(e,t,i)},onStart:function(){},onComplete:function(){r.hls.trigger(k.BUFFER_FLUSHED,{type:e})},onError:function(t){r.warn("Failed to remove from "+e+" SourceBuffer",t)}}},i.onBufferFlushing=function(e,t){var i=this,r=this.operationQueue,s=t.type,a=t.startOffset,n=t.endOffset;s?r.append(this.getFlushOp(s,a,n),s):this.getSourceBufferTypes().forEach((function(e){r.append(i.getFlushOp(e,a,n),e)}))},i.onFragParsed=function(e,t){var i=this,r=t.frag,s=t.part,a=[],n=s?s.elementaryStreams:r.elementaryStreams;n[$.AUDIOVIDEO]?a.push("audiovideo"):(n[$.AUDIO]&&a.push("audio"),n[$.VIDEO]&&a.push("video"));var o=function(){var e=self.performance.now();r.stats.buffering.end=e,s&&(s.stats.buffering.end=e);var t=s?s.stats:r.stats;i.hls.trigger(k.FRAG_BUFFERED,{frag:r,part:s,stats:t,id:r.type})};0===a.length&&this.warn("Fragments must have at least one ElementaryStreamType set. type: "+r.type+" level: "+r.level+" sn: "+r.sn),this.blockBuffers(o,a)},i.onFragChanged=function(e,t){this.trimBuffers()},i.onBufferEos=function(e,t){var i=this;"video"===t.type&&this.unblockAudio(),this.getSourceBufferTypes().reduce((function(e,r){var s=i.sourceBuffer[r];return!s||t.type&&t.type!==r||(s.ending=!0,s.ended||(s.ended=!0,i.log(r+" sourceBuffer now EOS"))),e&&!(s&&!s.ended)}),!0)&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers((function(){i.getSourceBufferTypes().forEach((function(e){var t=i.sourceBuffer[e];t&&(t.ending=!1)}));var e=i.mediaSource;e&&"open"===e.readyState?(i.log("Calling mediaSource.endOfStream()"),e.endOfStream()):e&&i.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: "+e.readyState)})))},i.onLevelUpdated=function(e,t){var i=this,r=t.details;if(r.fragments.length){this.details=r;var s=this.getDurationAndRange();s&&(this.getSourceBufferTypes().length?this.blockBuffers((function(){return i.updateMediaSource(s)})):this.updateMediaSource(s))}},i.trimBuffers=function(){var e=this.hls,t=this.details,i=this.media;if(i&&null!==t&&this.getSourceBufferTypes().length){var r=e.config,s=i.currentTime,a=t.levelTargetDuration,n=t.live&&null!==r.liveBackBufferLength?r.liveBackBufferLength:r.backBufferLength;if(E(n)&&n>0){var o=Math.max(n,a),l=Math.floor(s/a)*a-o;this.flushBackBuffer(s,a,l)}if(E(r.frontBufferFlushThreshold)&&r.frontBufferFlushThreshold>0){var d=Math.max(r.maxBufferLength,r.frontBufferFlushThreshold),h=Math.max(d,a),c=Math.floor(s/a)*a+h;this.flushFrontBuffer(s,a,c)}}},i.flushBackBuffer=function(e,t,i){var r=this,s=this.details,a=this.sourceBuffer;this.getSourceBufferTypes().forEach((function(n){var o=a[n];if(o){var l=Fr.getBuffered(o);if(l.length>0&&i>l.start(0)){if(r.hls.trigger(k.BACK_BUFFER_REACHED,{bufferEnd:i}),null!=s&&s.live)r.hls.trigger(k.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(o.ended&&l.end(l.length-1)-e<2*t)return void r.log("Cannot flush "+n+" back buffer while SourceBuffer is in ended state");r.hls.trigger(k.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:n})}}}))},i.flushFrontBuffer=function(e,t,i){var r=this,s=this.sourceBuffer;this.getSourceBufferTypes().forEach((function(a){var n=s[a];if(n){var o=Fr.getBuffered(n),l=o.length;if(l<2)return;var d=o.start(l-1),h=o.end(l-1);if(i>d||e>=d&&e<=h)return;if(n.ended&&e-h<2*t)return void r.log("Cannot flush "+a+" front buffer while SourceBuffer is in ended state");r.hls.trigger(k.BUFFER_FLUSHING,{startOffset:d,endOffset:1/0,type:a})}}))},i.getDurationAndRange=function(){if(!this.details||!this.media||!this.mediaSource||"open"!==this.mediaSource.readyState)return null;var e=this.details,t=this.hls,i=this.media,r=this.mediaSource,s=e.fragments[0].start+e.totalduration,a=i.duration,n=E(r.duration)?r.duration:0;if(e.live&&t.config.liveDurationInfinity){if(r.duration=1/0,e.fragments.length&&e.live&&r.setLiveSeekableRange){var o=Math.max(0,e.fragments[0].start);return{duration:1/0,start:o,end:Math.max(o,o+e.totalduration)}}return{duration:1/0}}return s>n&&s>a||!E(a)?{duration:s}:null},i.updateMediaSource=function(e){var t=e.duration,i=e.start,r=e.end;this.media&&this.mediaSource&&"open"===this.mediaSource.readyState&&(E(t)&&this.log("Updating Media Source duration to "+t.toFixed(3)),this.mediaSource.duration=t,void 0!==i&&void 0!==r&&(this.log("Media Source duration is set to "+this.mediaSource.duration+". Setting seekable range to "+i+"-"+r+"."),this.mediaSource.setLiveSeekableRange(i,r)))},i.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,i=this.pendingTracks,r=Object.keys(i).length;if(r&&(!e||2===r||"audiovideo"in i)){this.createSourceBuffers(i),this.pendingTracks={};var s=this.getSourceBufferTypes();if(s.length)this.hls.trigger(k.BUFFER_CREATED,{tracks:this.tracks}),s.forEach((function(e){t.executeNext(e)}));else{var a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(k.ERROR,{type:C.MEDIA_ERROR,details:D.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}},i.createSourceBuffers=function(e){var t=this,i=this.sourceBuffer,r=this.mediaSource;if(!r)throw Error("createSourceBuffers called when mediaSource was null");var s=function(s){if(!i[s]){var a=e[s];if(!a)throw Error("source buffer exists for track "+s+", however track does not");var n=a.levelCodec||a.codec;n&&"audio"===s.slice(0,5)&&(n=bt(n,t.appendSource));var o=a.container+";codecs="+n;t.log("creating sourceBuffer("+o+")");try{var l=i[s]=r.addSourceBuffer(o),d=s;t.addBufferListener(d,"updatestart",t._onSBUpdateStart),t.addBufferListener(d,"updateend",t._onSBUpdateEnd),t.addBufferListener(d,"error",t._onSBUpdateError),t.appendSource&&t.addBufferListener(d,"bufferedchange",(function(e,i){var r=i.removedRanges;null!=r&&r.length&&t.hls.trigger(k.BUFFER_FLUSHED,{type:s})})),t.tracks[s]={buffer:l,codec:n,container:a.container,levelCodec:a.levelCodec,metadata:a.metadata,id:a.id}}catch(e){t.error("error while trying to add sourceBuffer: "+e.message),t.hls.trigger(k.ERROR,{type:C.MEDIA_ERROR,details:D.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:s,mimeType:o})}}};for(var a in e)s(a)},i._onSBUpdateStart=function(e){this.operationQueue.current(e).onStart()},i._onSBUpdateEnd=function(e){var t;if("closed"!==(null==(t=this.mediaSource)?void 0:t.readyState)){var i=this.operationQueue;i.current(e).onComplete(),i.shiftAndExecuteNext(e)}else this.resetBuffer(e)},i._onSBUpdateError=function(e,t){var i,r=new Error(e+" SourceBuffer error. MediaSource readyState: "+(null==(i=this.mediaSource)?void 0:i.readyState));this.error(""+r,t),this.hls.trigger(k.ERROR,{type:C.MEDIA_ERROR,details:D.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:r,fatal:!1});var s=this.operationQueue.current(e);s&&s.onError(r)},i.removeExecutor=function(e,t,i){var r=this.media,s=this.mediaSource,a=this.operationQueue,n=this.sourceBuffer[e];if(!r||!s||!n)return this.warn("Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void a.shiftAndExecuteNext(e);var o=E(r.duration)?r.duration:1/0,l=E(s.duration)?s.duration:1/0,d=Math.max(0,t),h=Math.min(i,o,l);h>d&&(!n.ending||n.ended)?(n.ended=!1,this.log("Removing ["+d+","+h+"] from the "+e+" SourceBuffer"),n.remove(d,h)):a.shiftAndExecuteNext(e)},i.appendExecutor=function(e,t){var i=this.sourceBuffer[t];if(i)i.ending=!1,i.ended=!1,i.appendBuffer(e);else if(!this.pendingTracks[t])throw new Error("Attempting to append to the "+t+" SourceBuffer, but it does not exist")},i.blockBuffers=function(e,t){var i=this;if(void 0===t&&(t=this.getSourceBufferTypes()),!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(e);var r=this.operationQueue,s=t.map((function(e){return r.appendBlocker(e)}));t.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),Promise.all(s).then((function(s){e(),t.forEach((function(e,t){var s=i.sourceBuffer[e];null!=s&&s.updating||r.shiftAndExecuteNext(e)}))}))},i.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},i.addBufferListener=function(e,t,i){var r=this.sourceBuffer[e];if(r){var s=i.bind(this,e);this.listeners[e].push({event:t,listener:s}),r.addEventListener(t,s)}},i.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach((function(e){t.removeEventListener(e.event,e.listener)}))},d(t,[{key:"mediaSrc",get:function(){var e,t=(null==(e=this.media)?void 0:e.firstChild)||this.media;return null==t?void 0:t.src}}])}(I);function dn(e){var t=e.querySelectorAll("source");[].slice.call(t).forEach((function(t){e.removeChild(t)}))}function hn(e,t){var i=self.document.createElement("source");i.type="video/mp4",i.src=t,e.appendChild(i)}var cn={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},un=function(e){var t=e;return cn.hasOwnProperty(e)&&(t=cn[e]),String.fromCharCode(t)},pn=15,fn=100,yn={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},mn={17:2,18:4,21:6,22:8,23:10,19:13,20:15},gn={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},An={25:2,26:4,29:6,30:8,31:10,27:13,28:15},vn=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],bn=function(){function e(){this.time=null,this.verboseLevel=0}return e.prototype.log=function(e,t){if(this.verboseLevel>=e){var i="function"==typeof t?t():t;G.log(this.time+" ["+e+"] "+i)}},e}(),_n=function(e){for(var t=[],i=0;i<e.length;i++)t.push(e[i].toString(16));return t},wn=function(){function e(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}var t=e.prototype;return t.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},t.setStyles=function(e){for(var t=["foreground","underline","italics","background","flash"],i=0;i<t.length;i++){var r=t[i];e.hasOwnProperty(r)&&(this[r]=e[r])}},t.isDefault=function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash},t.equals=function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash},t.copy=function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash},t.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},e}(),En=function(){function e(){this.uchar=" ",this.penState=new wn}var t=e.prototype;return t.reset=function(){this.uchar=" ",this.penState.reset()},t.setChar=function(e,t){this.uchar=e,this.penState.copy(t)},t.setPenState=function(e){this.penState.copy(e)},t.equals=function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)},t.copy=function(e){this.uchar=e.uchar,this.penState.copy(e.penState)},t.isEmpty=function(){return" "===this.uchar&&this.penState.isDefault()},e}(),Sn=function(){function e(e){this.chars=[],this.pos=0,this.currPenState=new wn,this.cueStartTime=null,this.logger=void 0;for(var t=0;t<fn;t++)this.chars.push(new En);this.logger=e}var t=e.prototype;return t.equals=function(e){for(var t=0;t<fn;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0},t.copy=function(e){for(var t=0;t<fn;t++)this.chars[t].copy(e.chars[t])},t.isEmpty=function(){for(var e=!0,t=0;t<fn;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e},t.setCursor=function(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>fn&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=fn)},t.moveCursor=function(e){var t=this.pos+e;if(e>1)for(var i=this.pos+1;i<t+1;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(t)},t.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},t.insertChar=function(e){var t=this;e>=144&&this.backSpace();var i=un(e);this.pos>=fn?this.logger.log(0,(function(){return"Cannot insert "+e.toString(16)+" ("+i+") at position "+t.pos+". Skipping it!"})):(this.chars[this.pos].setChar(i,this.currPenState),this.moveCursor(1))},t.clearFromPos=function(e){var t;for(t=e;t<fn;t++)this.chars[t].reset()},t.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},t.clearToEndOfRow=function(){this.clearFromPos(this.pos)},t.getTextString=function(){for(var e=[],t=!0,i=0;i<fn;i++){var r=this.chars[i].uchar;" "!==r&&(t=!1),e.push(r)}return t?"":e.join("")},t.setPenStyles=function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)},e}(),Tn=function(){function e(e){this.rows=[],this.currRow=pn-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(var t=0;t<pn;t++)this.rows.push(new Sn(e));this.logger=e}var t=e.prototype;return t.reset=function(){for(var e=0;e<pn;e++)this.rows[e].clear();this.currRow=pn-1},t.equals=function(e){for(var t=!0,i=0;i<pn;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t},t.copy=function(e){for(var t=0;t<pn;t++)this.rows[t].copy(e.rows[t])},t.isEmpty=function(){for(var e=!0,t=0;t<pn;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e},t.backSpace=function(){this.rows[this.currRow].backSpace()},t.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},t.insertChar=function(e){this.rows[this.currRow].insertChar(e)},t.setPen=function(e){this.rows[this.currRow].setPenStyles(e)},t.moveCursor=function(e){this.rows[this.currRow].moveCursor(e)},t.setCursor=function(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)},t.setPAC=function(e){this.logger.log(2,(function(){return"pacData = "+JSON.stringify(e)}));var t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(var i=0;i<pn;i++)this.rows[i].clear();var r=this.currRow+1-this.nrRollUpRows,s=this.lastOutputScreen;if(s){var a=s.rows[r].cueStartTime,n=this.logger.time;if(null!==a&&null!==n&&a<n)for(var o=0;o<this.nrRollUpRows;o++)this.rows[t-this.nrRollUpRows+o+1].copy(s.rows[r+o])}}this.currRow=t;var l=this.rows[this.currRow];if(null!==e.indent){var d=e.indent,h=Math.max(d-1,0);l.setCursor(e.indent),e.color=l.chars[h].penState.foreground}var c={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(c)},t.setBkgData=function(e){this.logger.log(2,(function(){return"bkgData = "+JSON.stringify(e)})),this.backSpace(),this.setPen(e),this.insertChar(32)},t.setRollUpRows=function(e){this.nrRollUpRows=e},t.rollUp=function(){var e=this;if(null!==this.nrRollUpRows){this.logger.log(1,(function(){return e.getDisplayText()}));var t=this.currRow+1-this.nrRollUpRows,i=this.rows.splice(t,1)[0];i.clear(),this.rows.splice(this.currRow,0,i),this.logger.log(2,"Rolling up")}else this.logger.log(3,"roll_up but nrRollUpRows not set yet")},t.getDisplayText=function(e){e=e||!1;for(var t=[],i="",r=-1,s=0;s<pn;s++){var a=this.rows[s].getTextString();a&&(r=s+1,e?t.push("Row "+r+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(i=e?"["+t.join(" | ")+"]":t.join("\n")),i},t.getTextAndFormat=function(){return this.rows},e}(),kn=function(){function e(e,t,i){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new Tn(i),this.nonDisplayedMemory=new Tn(i),this.lastOutputScreen=new Tn(i),this.currRollUpRow=this.displayedMemory.rows[pn-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}var t=e.prototype;return t.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[pn-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},t.getHandler=function(){return this.outputFilter},t.setHandler=function(e){this.outputFilter=e},t.setPAC=function(e){this.writeScreen.setPAC(e)},t.setBkgData=function(e){this.writeScreen.setBkgData(e)},t.setMode=function(e){e!==this.mode&&(this.mode=e,this.logger.log(2,(function(){return"MODE="+e})),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)},t.insertChars=function(e){for(var t=this,i=0;i<e.length;i++)this.writeScreen.insertChar(e[i]);var r=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,(function(){return r+": "+t.writeScreen.getDisplayText(!0)})),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(1,(function(){return"DISPLAYED: "+t.displayedMemory.getDisplayText(!0)})),this.outputDataUpdate())},t.ccRCL=function(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},t.ccBS=function(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},t.ccAOF=function(){},t.ccAON=function(){},t.ccDER=function(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},t.ccRU=function(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)},t.ccFON=function(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},t.ccRDC=function(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},t.ccTR=function(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")},t.ccRTD=function(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")},t.ccEDM=function(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},t.ccCR=function(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},t.ccENM=function(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},t.ccEOC=function(){var e=this;if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,(function(){return"DISP: "+e.displayedMemory.getDisplayText()}))}this.outputDataUpdate(!0)},t.ccTO=function(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)},t.ccMIDROW=function(e){var t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{var i=Math.floor(e/2)-16,r=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=r[i]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)},t.outputDataUpdate=function(e){void 0===e&&(e=!1);var t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))},t.cueSplitAtTime=function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))},e}(),Cn=function(){function e(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=xn(),this.logger=void 0;var r=this.logger=new bn;this.channels=[null,new kn(e,t,r),new kn(e+1,i,r)]}var t=e.prototype;return t.getHandler=function(e){return this.channels[e].getHandler()},t.setHandler=function(e,t){this.channels[e].setHandler(t)},t.addData=function(e,t){var i,r,s,a=!1;this.logger.time=e;for(var n=0;n<t.length;n+=2)if(r=127&t[n],s=127&t[n+1],0!==r||0!==s){if(this.logger.log(3,"["+_n([t[n],t[n+1]])+"] -> ("+_n([r,s])+")"),(i=this.parseCmd(r,s))||(i=this.parseMidrow(r,s)),i||(i=this.parsePAC(r,s)),i||(i=this.parseBackgroundAttributes(r,s)),!i&&(a=this.parseChars(r,s))){var o=this.currentChannel;o&&o>0?this.channels[o].insertChars(a):this.logger.log(2,"No channel found yet. TEXT-MODE?")}i||a||this.logger.log(2,"Couldn't parse cleaned data "+_n([r,s])+" orig: "+_n([t[n],t[n+1]]))}},t.parseCmd=function(e,t){var i=this.cmdHistory;if(!((20===e||28===e||21===e||29===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=33&&t<=35))return!1;if(Rn(e,t,i))return Dn(null,null,i),this.logger.log(3,"Repeated command ("+_n([e,t])+") is dropped"),!0;var r=20===e||21===e||23===e?1:2,s=this.channels[r];return 20===e||21===e||28===e||29===e?32===t?s.ccRCL():33===t?s.ccBS():34===t?s.ccAOF():35===t?s.ccAON():36===t?s.ccDER():37===t?s.ccRU(2):38===t?s.ccRU(3):39===t?s.ccRU(4):40===t?s.ccFON():41===t?s.ccRDC():42===t?s.ccTR():43===t?s.ccRTD():44===t?s.ccEDM():45===t?s.ccCR():46===t?s.ccENM():47===t&&s.ccEOC():s.ccTO(t-32),Dn(e,t,i),this.currentChannel=r,!0},t.parseMidrow=function(e,t){var i=0;if((17===e||25===e)&&t>=32&&t<=47){if((i=17===e?1:2)!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;var r=this.channels[i];return!!r&&(r.ccMIDROW(t),this.logger.log(3,"MIDROW ("+_n([e,t])+")"),!0)}return!1},t.parsePAC=function(e,t){var i,r=this.cmdHistory;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127||(16===e||24===e)&&t>=64&&t<=95))return!1;if(Rn(e,t,r))return Dn(null,null,r),!0;var s=e<=23?1:2;i=t>=64&&t<=95?1===s?yn[e]:gn[e]:1===s?mn[e]:An[e];var a=this.channels[s];return!!a&&(a.setPAC(this.interpretPAC(i,t)),Dn(e,t,r),this.currentChannel=s,!0)},t.interpretPAC=function(e,t){var i,r={color:null,italics:!1,indent:null,underline:!1,row:e};return i=t>95?t-96:t-64,r.underline=!(1&~i),i<=13?r.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(r.italics=!0,r.color="white"):r.indent=4*Math.floor((i-16)/2),r},t.parseChars=function(e,t){var i,r,s=null,a=null;if(e>=25?(i=2,a=e-8):(i=1,a=e),a>=17&&a<=19?(r=17===a?t+80:18===a?t+112:t+144,this.logger.log(2,"Special char '"+un(r)+"' in channel "+i),s=[r]):e>=32&&e<=127&&(s=0===t?[e]:[e,t]),s){var n=_n(s);this.logger.log(3,"Char codes = "+n.join(",")),Dn(e,t,this.cmdHistory)}return s},t.parseBackgroundAttributes=function(e,t){var i;if(!((16===e||24===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=45&&t<=47))return!1;var r={};16===e||24===e?(i=Math.floor((t-32)/2),r.background=vn[i],t%2==1&&(r.background=r.background+"_semi")):45===t?r.background="transparent":(r.foreground="black",47===t&&(r.underline=!0));var s=e<=23?1:2;return this.channels[s].setBkgData(r),Dn(e,t,this.cmdHistory),!0},t.reset=function(){for(var e=0;e<Object.keys(this.channels).length;e++){var t=this.channels[e];t&&t.reset()}this.cmdHistory=xn()},t.cueSplitAtTime=function(e){for(var t=0;t<this.channels.length;t++){var i=this.channels[t];i&&i.cueSplitAtTime(e)}},e}();function Dn(e,t,i){i.a=e,i.b=t}function Rn(e,t,i){return i.a===e&&i.b===t}function xn(){return{a:null,b:null}}var Ln=function(){function e(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}var t=e.prototype;return t.dispatchCue=function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},t.newCue=function(e,t,i){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)},t.reset=function(){this.cueRanges=[],this.startTime=null},e}(),In=function(){if(null!=ae&&ae.VTTCue)return self.VTTCue;var e=["","lr","rl"],t=["start","middle","end","left","right"];function i(e,t){if("string"!=typeof t)return!1;if(!Array.isArray(e))return!1;var i=t.toLowerCase();return!!~e.indexOf(i)&&i}function r(t){return i(e,t)}function s(e){return i(t,e)}function a(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];for(var s=1;s<arguments.length;s++){var a=arguments[s];for(var n in a)e[n]=a[n]}return e}function n(e,t,i){var n=this,o={enumerable:!0};n.hasBeenReset=!1;var l="",d=!1,h=e,c=t,u=i,p=null,f="",y=!0,m="auto",g="start",A=50,v="middle",b=50,_="middle";Object.defineProperty(n,"id",a({},o,{get:function(){return l},set:function(e){l=""+e}})),Object.defineProperty(n,"pauseOnExit",a({},o,{get:function(){return d},set:function(e){d=!!e}})),Object.defineProperty(n,"startTime",a({},o,{get:function(){return h},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");h=e,this.hasBeenReset=!0}})),Object.defineProperty(n,"endTime",a({},o,{get:function(){return c},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");c=e,this.hasBeenReset=!0}})),Object.defineProperty(n,"text",a({},o,{get:function(){return u},set:function(e){u=""+e,this.hasBeenReset=!0}})),Object.defineProperty(n,"region",a({},o,{get:function(){return p},set:function(e){p=e,this.hasBeenReset=!0}})),Object.defineProperty(n,"vertical",a({},o,{get:function(){return f},set:function(e){var t=r(e);if(!1===t)throw new SyntaxError("An invalid or illegal string was specified.");f=t,this.hasBeenReset=!0}})),Object.defineProperty(n,"snapToLines",a({},o,{get:function(){return y},set:function(e){y=!!e,this.hasBeenReset=!0}})),Object.defineProperty(n,"line",a({},o,{get:function(){return m},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");m=e,this.hasBeenReset=!0}})),Object.defineProperty(n,"lineAlign",a({},o,{get:function(){return g},set:function(e){var t=s(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");g=t,this.hasBeenReset=!0}})),Object.defineProperty(n,"position",a({},o,{get:function(){return A},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");A=e,this.hasBeenReset=!0}})),Object.defineProperty(n,"positionAlign",a({},o,{get:function(){return v},set:function(e){var t=s(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");v=t,this.hasBeenReset=!0}})),Object.defineProperty(n,"size",a({},o,{get:function(){return b},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");b=e,this.hasBeenReset=!0}})),Object.defineProperty(n,"align",a({},o,{get:function(){return _},set:function(e){var t=s(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");_=t,this.hasBeenReset=!0}})),n.displayState=void 0}return n.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},n}(),Pn=function(){function e(){}return e.prototype.decode=function(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))},e}();function Bn(e){function t(e,t,i,r){return 3600*(0|e)+60*(0|t)+(0|i)+parseFloat(r||0)}var i=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return i?parseFloat(i[2])>59?t(i[2],i[3],0,i[4]):t(i[1],i[2],i[3],i[4]):null}var Mn=function(){function e(){this.values=Object.create(null)}var t=e.prototype;return t.set=function(e,t){this.get(e)||""===t||(this.values[e]=t)},t.get=function(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t},t.has=function(e){return e in this.values},t.alt=function(e,t,i){for(var r=0;r<i.length;++r)if(t===i[r]){this.set(e,t);break}},t.integer=function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))},t.percent=function(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),!0}return!1},e}();function Un(e,t,i,r){var s=r?e.split(r):[e];for(var a in s)if("string"==typeof s[a]){var n=s[a].split(i);2===n.length&&t(n[0],n[1])}}var Fn=new In(0,0,""),On="middle"===Fn.align?"middle":"center";function Nn(e,t,i){var r=e;function s(){var t=Bn(e);if(null===t)throw new Error("Malformed timestamp: "+r);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function a(e,t){var r=new Mn;Un(e,(function(e,t){var s;switch(e){case"region":for(var a=i.length-1;a>=0;a--)if(i[a].id===t){r.set(e,i[a].region);break}break;case"vertical":r.alt(e,t,["rl","lr"]);break;case"line":s=t.split(","),r.integer(e,s[0]),r.percent(e,s[0])&&r.set("snapToLines",!1),r.alt(e,s[0],["auto"]),2===s.length&&r.alt("lineAlign",s[1],["start",On,"end"]);break;case"position":s=t.split(","),r.percent(e,s[0]),2===s.length&&r.alt("positionAlign",s[1],["start",On,"end","line-left","line-right","auto"]);break;case"size":r.percent(e,t);break;case"align":r.alt(e,t,["start",On,"end","left","right"])}}),/:/,/\s/),t.region=r.get("region",null),t.vertical=r.get("vertical","");var s=r.get("line","auto");"auto"===s&&-1===Fn.line&&(s=-1),t.line=s,t.lineAlign=r.get("lineAlign","start"),t.snapToLines=r.get("snapToLines",!0),t.size=r.get("size",100),t.align=r.get("align",On);var a=r.get("position","auto");"auto"===a&&50===Fn.position&&(a="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=a}function n(){e=e.replace(/^\s+/,"")}if(n(),t.startTime=s(),n(),"--\x3e"!==e.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+r);e=e.slice(3),n(),t.endTime=s(),n(),a(e,t)}function Gn(e){return e.replace(/<br(?: \/)?>/gi,"\n")}var zn=function(){function e(){this.state="INITIAL",this.buffer="",this.decoder=new Pn,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var t=e.prototype;return t.parse=function(e){var t=this;function i(){var e=t.buffer,i=0;for(e=Gn(e);i<e.length&&"\r"!==e[i]&&"\n"!==e[i];)++i;var r=e.slice(0,i);return"\r"===e[i]&&++i,"\n"===e[i]&&++i,t.buffer=e.slice(i),r}function r(e){Un(e,(function(e,t){}),/:/)}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var s="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;var a=(s=i()).match(/^()?WEBVTT([ \t].*)?$/);if(null==a||!a[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var n=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(n?n=!1:s=i(),t.state){case"HEADER":/:/.test(s)?r(s):s||(t.state="ID");continue;case"NOTE":s||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(s)){t.state="NOTE";break}if(!s)continue;if(t.cue=new In(0,0,""),t.state="CUE",-1===s.indexOf("--\x3e")){t.cue.id=s;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{Nn(s,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var o=-1!==s.indexOf("--\x3e");if(!s||o&&(n=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(null===t.cue)continue;t.cue.text&&(t.cue.text+="\n"),t.cue.text+=s;continue;case"BADCUE":s||(t.state="ID")}}}catch(e){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this},t.flush=function(){var e=this;try{if((e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state||"BADWEBVTT"===e.state)throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this},e}(),Wn=/\r\n|\n\r|\n|\r/g,Vn=function(e,t,i){return void 0===i&&(i=0),e.slice(i,i+t.length)===t},Hn=function(e){var t=parseInt(e.slice(-3)),i=parseInt(e.slice(-6,-4)),r=parseInt(e.slice(-9,-7)),s=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!(E(t)&&E(i)&&E(r)&&E(s)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+e);return t+=1e3*i,t+=6e4*r,t+=36e5*s},$n=function(e){for(var t=5381,i=e.length;i;)t=33*t^e.charCodeAt(--i);return(t>>>0).toString()};function jn(e,t,i){return $n(e.toString())+$n(t.toString())+$n(i)}var Kn=function(e,t,i){var r=e[t],s=e[r.prevCC];if(!s||!s.new&&r.new)return e.ccOffset=e.presentationOffset=r.start,void(r.new=!1);for(;null!=(a=s)&&a.new;){var a;e.ccOffset+=r.start-s.start,r.new=!1,s=e[(r=s).prevCC]}e.presentationOffset=i};function qn(e,t,i,r,s,a,n){var o,l=new zn,d=Ae(new Uint8Array(e)).trim().replace(Wn,"\n").split("\n"),h=[],c=t?fa(t.baseTime,t.timescale):0,u="00:00.000",p=0,f=0,y=!0;l.oncue=function(e){var a=i[r],n=i.ccOffset,l=(p-c)/9e4;if(null!=a&&a.new&&(void 0!==f?n=i.ccOffset=a.start:Kn(i,r,l)),l){if(!t)return void(o=new Error("Missing initPTS for VTT MPEGTS"));n=l-i.presentationOffset}var d=e.endTime-e.startTime,u=wa(9e4*(e.startTime+n-f),9e4*s)/9e4;e.startTime=Math.max(u,0),e.endTime=Math.max(u+d,0);var y=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(y)),e.id||(e.id=jn(e.startTime,e.endTime,y)),e.endTime>0&&h.push(e)},l.onparsingerror=function(e){o=e},l.onflush=function(){o?n(o):a(h)},d.forEach((function(e){if(y){if(Vn(e,"X-TIMESTAMP-MAP=")){y=!1,e.slice(16).split(",").forEach((function(e){Vn(e,"LOCAL:")?u=e.slice(6):Vn(e,"MPEGTS:")&&(p=parseInt(e.slice(7)))}));try{f=Hn(u)/1e3}catch(e){o=e}return}""===e&&(y=!1)}l.parse(e+"\n")})),l.flush()}var Yn="stpp.ttml.im1t",Qn=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Xn=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Jn={left:"start",center:"center",right:"end",start:"start",end:"end"};function Zn(e,t,i,r){var s=xe(new Uint8Array(e),["mdat"]);if(0!==s.length){var a=s.map((function(e){return Ae(e)})),n=ua(t.baseTime,1,t.timescale);try{a.forEach((function(e){return i(eo(e,n))}))}catch(e){r(e)}}else r(new Error("Could not parse IMSC1 mdat"))}function eo(e,t){var i=(new DOMParser).parseFromString(e,"text/xml").getElementsByTagName("tt")[0];if(!i)throw new Error("Invalid ttml");var r={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},s=Object.keys(r).reduce((function(e,t){return e[t]=i.getAttribute("ttp:"+t)||r[t],e}),{}),a="preserve"!==i.getAttribute("xml:space"),n=io(to(i,"styling","style")),o=io(to(i,"layout","region")),l=to(i,"body","[begin]");return[].map.call(l,(function(e){var i=ro(e,a);if(!i||!e.hasAttribute("begin"))return null;var r=oo(e.getAttribute("begin"),s),l=oo(e.getAttribute("dur"),s),d=oo(e.getAttribute("end"),s);if(null===r)throw no(e);if(null===d){if(null===l)throw no(e);d=r+l}var h=new In(r-t,d-t,i);h.id=jn(h.startTime,h.endTime,h.text);var u=so(o[e.getAttribute("region")],n[e.getAttribute("style")],n),p=u.textAlign;if(p){var f=Jn[p];f&&(h.lineAlign=f),h.align=p}return c(h,u),h})).filter((function(e){return null!==e}))}function to(e,t,i){var r=e.getElementsByTagName(t)[0];return r?[].slice.call(r.querySelectorAll(i)):[]}function io(e){return e.reduce((function(e,t){var i=t.getAttribute("xml:id");return i&&(e[i]=t),e}),{})}function ro(e,t){return[].slice.call(e.childNodes).reduce((function(e,i,r){var s;return"br"===i.nodeName&&r?e+"\n":null!=(s=i.childNodes)&&s.length?ro(i,t):t?e+i.textContent.trim().replace(/\s+/g," "):e+i.textContent}),"")}function so(e,t,i){var r="http://www.w3.org/ns/ttml#styling",s=null,a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],n=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;return n&&i.hasOwnProperty(n)&&(s=i[n]),a.reduce((function(i,a){var n=ao(t,r,a)||ao(e,r,a)||ao(s,r,a);return n&&(i[a]=n),i}),{})}function ao(e,t,i){return e&&e.hasAttributeNS(t,i)?e.getAttributeNS(t,i):null}function no(e){return new Error("Could not parse ttml timestamp "+e)}function oo(e,t){if(!e)return null;var i=Bn(e);return null===i&&(Qn.test(e)?i=lo(e,t):Xn.test(e)&&(i=ho(e,t))),i}function lo(e,t){var i=Qn.exec(e),r=(0|i[4])+(0|i[5])/t.subFrameRate;return 3600*(0|i[1])+60*(0|i[2])+(0|i[3])+r/t.frameRate}function ho(e,t){var i=Xn.exec(e),r=Number(i[1]);switch(i[2]){case"h":return 3600*r;case"m":return 60*r;case"ms":return 1e3*r;case"f":return r/t.frameRate;case"t":return r/t.tickRate}return r}var co=function(){function e(e){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=yo(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},e.on(k.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(k.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(k.MANIFEST_LOADING,this.onManifestLoading,this),e.on(k.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(k.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(k.FRAG_LOADING,this.onFragLoading,this),e.on(k.FRAG_LOADED,this.onFragLoaded,this),e.on(k.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(k.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(k.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(k.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(k.BUFFER_FLUSHING,this.onBufferFlushing,this)}var t=e.prototype;return t.destroy=function(){var e=this.hls;e.off(k.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(k.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(k.MANIFEST_LOADING,this.onManifestLoading,this),e.off(k.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(k.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(k.FRAG_LOADING,this.onFragLoading,this),e.off(k.FRAG_LOADED,this.onFragLoaded,this),e.off(k.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(k.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(k.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(k.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(k.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0},t.initCea608Parsers=function(){var e=new Ln(this,"textTrack1"),t=new Ln(this,"textTrack2"),i=new Ln(this,"textTrack3"),r=new Ln(this,"textTrack4");this.cea608Parser1=new Cn(1,e,t),this.cea608Parser2=new Cn(3,i,r)},t.addCues=function(e,t,i,r,s){for(var a=!1,n=s.length;n--;){var o=s[n],l=fo(o[0],o[1],t,i);if(l>=0&&(o[0]=Math.min(o[0],t),o[1]=Math.max(o[1],i),a=!0,l/(i-t)>.5))return}if(a||s.push([t,i]),this.config.renderTextTracksNatively){var d=this.captionsTracks[e];this.Cues.newCue(d,t,i,r)}else{var h=this.Cues.newCue(null,t,i,r);this.hls.trigger(k.CUES_PARSED,{type:"captions",cues:h,track:e})}},t.onInitPtsFound=function(e,t){var i=this,r=t.frag,s=t.id,a=t.initPTS,n=t.timescale,o=this.unparsedVttFrags;"main"===s&&(this.initPTS[r.cc]={baseTime:a,timescale:n}),o.length&&(this.unparsedVttFrags=[],o.forEach((function(e){i.onFragLoaded(k.FRAG_LOADED,e)})))},t.getExistingTrack=function(e,t){var i=this.media;if(i)for(var r=0;r<i.textTracks.length;r++){var s=i.textTracks[r];if(po(s,{name:e,lang:t,attrs:{}}))return s}return null},t.createCaptionsTrack=function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)},t.createNativeTrack=function(e){if(!this.captionsTracks[e]){var t=this.captionsProperties,i=this.captionsTracks,r=this.media,s=t[e],a=s.label,n=s.languageCode,o=this.getExistingTrack(a,n);if(o)i[e]=o,$t(i[e]),Vt(i[e],r);else{var l=this.createTextTrack("captions",a,n);l&&(l[e]=!0,i[e]=l)}}},t.createNonNativeTrack=function(e){if(!this.nonNativeCaptionsTracks[e]){var t=this.captionsProperties[e];if(t){var i={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=i,this.hls.trigger(k.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[i]})}}},t.createTextTrack=function(e,t,i){var r=this.media;if(r)return r.addTextTrack(e,t,i)},t.onMediaAttaching=function(e,t){this.media=t.media,this._cleanTracks()},t.onMediaDetaching=function(){var e=this.captionsTracks;Object.keys(e).forEach((function(t){$t(e[t]),delete e[t]})),this.nonNativeCaptionsTracks={},this.media=null},t.onManifestLoading=function(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=yo(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},t._cleanTracks=function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var i=0;i<t.length;i++)$t(t[i])}},t.onSubtitleTracksUpdated=function(e,t){var i=this,r=t.subtitleTracks||[],s=r.some((function(e){return e.textCodec===Yn}));if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(Ya(this.tracks,r))return void(this.tracks=r);if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){var a=this.media,n=a?Yt(a.textTracks):null;if(this.tracks.forEach((function(e,t){var r;if(n){for(var s=null,a=0;a<n.length;a++)if(n[a]&&po(n[a],e)){s=n[a],n[a]=null;break}s&&(r=s)}if(r)$t(r);else{var o=uo(e);(r=i.createTextTrack(o,e.name,e.lang))&&(r.mode="disabled")}r&&i.textTracks.push(r)})),null!=n&&n.length){var o=n.filter((function(e){return null!==e})).map((function(e){return e.label}));o.length&&this.hls.logger.warn("Media element contains unused subtitle tracks: "+o.join(", ")+". Replace media element for each source to clear TextTracks and captions menu.")}}else if(this.tracks.length){var l=this.tracks.map((function(e){return{label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}}));this.hls.trigger(k.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:l})}}},t.onManifestLoaded=function(e,t){var i=this;this.config.enableCEA708Captions&&t.captions&&t.captions.forEach((function(e){var t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(t){var r="textTrack"+t[1],s=i.captionsProperties[r];s&&(s.label=e.name,e.lang&&(s.languageCode=e.lang),s.media=e)}}))},t.closedCaptionsForLevel=function(e){var t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]},t.onFragLoading=function(e,t){if(this.enabled&&t.frag.type===Nt.MAIN){var i,r,s=this.cea608Parser1,a=this.cea608Parser2,n=this.lastSn;if(!s||!a)return;var o=t.frag,l=o.cc,d=o.sn,h=null!=(i=null==(r=t.part)?void 0:r.index)?i:-1;d===n+1||d===n&&h===this.lastPartIndex+1||l===this.lastCc||(s.reset(),a.reset()),this.lastCc=l,this.lastSn=d,this.lastPartIndex=h}},t.onFragLoaded=function(e,t){var i=t.frag,r=t.payload;if(i.type===Nt.SUBTITLE)if(r.byteLength){var s=i.decryptdata,a="stats"in t;if(null==s||!s.encrypted||a){var n=this.tracks[i.level],o=this.vttCCs;o[i.cc]||(o[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),n&&n.textCodec===Yn?this._parseIMSC1(i,r):this._parseVTTs(t)}}else this.hls.trigger(k.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})},t._parseIMSC1=function(e,t){var i=this,r=this.hls;Zn(t,this.initPTS[e.cc],(function(t){i._appendCues(t,e.level),r.trigger(k.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})}),(function(t){r.logger.log("Failed to parse IMSC1: "+t),r.trigger(k.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})}))},t._parseVTTs=function(e){var t,i=this,r=e.frag,s=e.payload,a=this.initPTS,n=this.unparsedVttFrags,o=a.length-1;if(a[r.cc]||-1!==o){var l=this.hls;qn(null!=(t=r.initSegment)&&t.data?He(r.initSegment.data,new Uint8Array(s)):s,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,(function(e){i._appendCues(e,r.level),l.trigger(k.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})}),(function(t){var a="Missing initPTS for VTT MPEGTS"===t.message;a?n.push(e):i._fallbackToIMSC1(r,s),l.logger.log("Failed to parse VTT cue: "+t),a&&o>r.cc||l.trigger(k.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:t})}))}else n.push(e)},t._fallbackToIMSC1=function(e,t){var i=this,r=this.tracks[e.level];r.textCodec||Zn(t,this.initPTS[e.cc],(function(){r.textCodec=Yn,i._parseIMSC1(e,t)}),(function(){r.textCodec="wvtt"}))},t._appendCues=function(e,t){var i=this.hls;if(this.config.renderTextTracksNatively){var r=this.textTracks[t];if(!r||"disabled"===r.mode)return;e.forEach((function(e){return Ht(r,e)}))}else{var s=this.tracks[t];if(!s)return;var a=s.default?"default":"subtitles"+t;i.trigger(k.CUES_PARSED,{type:"subtitles",cues:e,track:a})}},t.onFragDecrypted=function(e,t){t.frag.type===Nt.SUBTITLE&&this.onFragLoaded(k.FRAG_LOADED,t)},t.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},t.onFragParsingUserdata=function(e,t){if(this.enabled&&this.config.enableCEA708Captions){var i=t.frag,r=t.samples;if(i.type!==Nt.MAIN||"NONE"!==this.closedCaptionsForLevel(i))for(var s=0;s<r.length;s++){var a=r[s].bytes;if(a){this.cea608Parser1||this.initCea608Parsers();var n=this.extractCea608Data(a);this.cea608Parser1.addData(r[s].pts,n[0]),this.cea608Parser2.addData(r[s].pts,n[1])}}}},t.onBufferFlushing=function(e,t){var i=t.startOffset,r=t.endOffset,s=t.endOffsetSubtitles,a=t.type,n=this.media;if(n&&!(n.currentTime<r)){if(!a||"video"===a){var o=this.captionsTracks;Object.keys(o).forEach((function(e){return jt(o[e],i,r)}))}if(this.config.renderTextTracksNatively&&0===i&&void 0!==s){var l=this.textTracks;Object.keys(l).forEach((function(e){return jt(l[e],i,s)}))}}},t.extractCea608Data=function(e){for(var t=[[],[]],i=31&e[0],r=2,s=0;s<i;s++){var a=e[r++],n=127&e[r++],o=127&e[r++];if((0!==n||0!==o)&&4&a){var l=3&a;0!==l&&1!==l||(t[l].push(n),t[l].push(o))}}return t},e}();function uo(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function po(e,t){return!!e&&e.kind===uo(t)&&Xa(t,e)}function fo(e,t,i,r){return Math.min(t,r)-Math.max(e,i)}function yo(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}var mo=function(){function e(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var t=e.prototype;return t.setStreamController=function(e){this.streamController=e},t.destroy=function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},t.registerListeners=function(){var e=this.hls;e.on(k.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(k.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(k.MANIFEST_PARSED,this.onManifestParsed,this),e.on(k.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(k.BUFFER_CODECS,this.onBufferCodecs,this),e.on(k.MEDIA_DETACHING,this.onMediaDetaching,this)},t.unregisterListener=function(){var e=this.hls;e.off(k.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(k.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(k.MANIFEST_PARSED,this.onManifestParsed,this),e.off(k.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(k.BUFFER_CODECS,this.onBufferCodecs,this),e.off(k.MEDIA_DETACHING,this.onMediaDetaching,this)},t.onFpsDropLevelCapping=function(e,t){var i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})},t.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()},t.onManifestParsed=function(e,t){var i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.config.capLevelToPlayerSize&&t.video&&this.startCapping()},t.onLevelsUpdated=function(e,t){this.timer&&E(this.autoLevelCapping)&&this.detectPlayerSize()},t.onBufferCodecs=function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()},t.onMediaDetaching=function(){this.stopCapping(),this.media=null},t.detectPlayerSize=function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);var e=this.hls.levels;if(e.length){var t=this.hls,i=this.getMaxLevel(e.length-1);i!==this.autoLevelCapping&&t.logger.log("Setting autoLevelCapping to "+i+": "+e[i].height+"p@"+e[i].bitrate+" for media "+this.mediaWidth+"x"+this.mediaHeight),t.autoLevelCapping=i,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},t.getMaxLevel=function(t){var i=this,r=this.hls.levels;if(!r.length)return-1;var s=r.filter((function(e,r){return i.isLevelAllowed(e)&&r<=t}));return this.clientRect=null,e.getMaxLevelByMediaSize(s,this.mediaWidth,this.mediaHeight)},t.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},t.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},t.getDimensions=function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,t.width||t.height||(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.top||e.height||0)}return this.clientRect=t,t},t.isLevelAllowed=function(e){return!this.restrictedLevels.some((function(t){return e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height}))},e.getMaxLevelByMediaSize=function(e,t,i){if(null==e||!e.length)return-1;for(var r=function(e,t){return!t||e.width!==t.width||e.height!==t.height},s=e.length-1,a=Math.max(t,i),n=0;n<e.length;n+=1){var o=e[n];if((o.width>=a||o.height>=a)&&r(o,e[n+1])){s=n;break}}return s},d(e,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return e}}])}(),go=function(){function e(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}var t=e.prototype;return t.setStreamController=function(e){this.streamController=e},t.registerListeners=function(){this.hls.on(k.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(k.MEDIA_DETACHING,this.onMediaDetaching,this)},t.unregisterListeners=function(){this.hls.off(k.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(k.MEDIA_DETACHING,this.onMediaDetaching,this)},t.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},t.onMediaAttaching=function(e,t){var i=this.hls.config;if(i.capLevelOnFPSDrop){var r=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=r,r&&"function"==typeof r.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}},t.onMediaDetaching=function(){this.media=null},t.checkFPS=function(e,t,i){var r=performance.now();if(t){if(this.lastTime){var s=r-this.lastTime,a=i-this.lastDroppedFrames,n=t-this.lastDecodedFrames,o=1e3*a/s,l=this.hls;if(l.trigger(k.FPS_DROP,{currentDropped:a,currentDecoded:n,totalDroppedFrames:i}),o>0&&a>l.config.fpsDroppedMonitoringThreshold*n){var d=l.currentLevel;l.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+d),d>0&&(-1===l.autoLevelCapping||l.autoLevelCapping>=d)&&(d-=1,l.trigger(k.FPS_DROP_LEVEL_CAPPING,{level:d,droppedLevel:l.currentLevel}),l.autoLevelCapping=d,this.streamController.nextLevelSwitch())}}this.lastTime=r,this.lastDroppedFrames=i,this.lastDecodedFrames=t}},t.checkFPSInterval=function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},e}(),Ao=function(e){function t(i){var r;return(r=e.call(this,"eme",i.logger)||this).hls=void 0,r.config=void 0,r.media=null,r.keyFormatPromise=null,r.keySystemAccessPromises={},r._requestLicenseFailureCount=0,r.mediaKeySessions=[],r.keyIdToKeySessionPromise={},r.setMediaKeysQueue=t.CDMCleanupPromise?[t.CDMCleanupPromise]:[],r.onMediaEncrypted=function(e){var t=e.initDataType,i=e.initData;if(r.debug('"'+e.type+'" event: init data type: "'+t+'"'),null!==i){var s,a;if("sinf"===t&&r.config.drmSystems[ne.FAIRPLAY]){var n=Ee(new Uint8Array(i));try{var o=X(JSON.parse(n).sinf),l=Oe(new Uint8Array(o));if(!l)return;s=l.subarray(8,24),a=ne.FAIRPLAY}catch(e){return void r.warn('Failed to parse sinf "encrypted" event message initData')}}else{var d=Ze(i);if(null===d)return;0===d.version&&d.systemId===de.WIDEVINE&&d.data&&(s=d.data.subarray(8,24)),a=he(d.systemId)}if(a&&s){for(var h,c=ve.hexDump(s),u=r,p=u.keyIdToKeySessionPromise,f=u.mediaKeySessions,y=p[c],m=function(){var e=f[g],a=e.decryptdata;if(a.pssh||!a.keyId)return 0;var n=ve.hexDump(a.keyId);return c===n||-1!==a.uri.replace(/-/g,"").indexOf(c)?(y=p[n],delete p[n],a.pssh=new Uint8Array(i),a.keyId=s,y=p[c]=y.then((function(){return r.generateRequestWithPreferredKeySession(e,t,i,"encrypted-event-key-match")})),1):void 0},g=0;g<f.length&&(0===(h=m())||1!==h);g++);y||(y=p[c]=r.getKeySystemSelectionPromise([a]).then((function(e){var a,n=e.keySystem,o=e.mediaKeys;r.throwIfDestroyed();var l=new tt("ISO-23001-7",c,null!=(a=ce(n))?a:"");return l.pssh=new Uint8Array(i),l.keyId=s,r.attemptSetMediaKeys(n,o).then((function(){r.throwIfDestroyed();var e=r.createMediaKeySessionContext({decryptdata:l,keySystem:n,mediaKeys:o});return r.generateRequestWithPreferredKeySession(e,t,i,"encrypted-event-no-match")}))}))),y.catch((function(e){return r.handleError(e)}))}}},r.onWaitingForKey=function(e){r.log('"'+e.type+'" event')},r.hls=i,r.config=i.config,r.registerListeners(),r}u(t,e);var i=t.prototype;return i.destroy=function(){this.unregisterListeners(),this.onMediaDetached();var e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null},i.registerListeners=function(){this.hls.on(k.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(k.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(k.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(k.MANIFEST_LOADED,this.onManifestLoaded,this)},i.unregisterListeners=function(){this.hls.off(k.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(k.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(k.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(k.MANIFEST_LOADED,this.onManifestLoaded,this)},i.getLicenseServerUrl=function(e){var t=this.config,i=t.drmSystems,r=t.widevineLicenseUrl,s=i[e];if(s)return s.licenseUrl;if(e===ne.WIDEVINE&&r)return r;throw new Error('no license server URL configured for key-system "'+e+'"')},i.getServerCertificateUrl=function(e){var t=this.config.drmSystems[e];if(t)return t.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+e+'"]')},i.attemptKeySystemAccess=function(e){var t=this,i=this.hls.levels,r=function(e,t,i){return!!e&&i.indexOf(e)===t},s=i.map((function(e){return e.audioCodec})).filter(r),a=i.map((function(e){return e.videoCodec})).filter(r);return s.length+a.length===0&&a.push("avc1.42e01e"),new Promise((function(i,r){!function e(n){var o=n.shift();t.getMediaKeysPromise(o,s,a).then((function(e){return i({keySystem:o,mediaKeys:e})})).catch((function(t){n.length?e(n):r(t instanceof Eo?t:new Eo({type:C.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))}))}(e)}))},i.requestMediaKeySystemAccess=function(e,t){var i=this.config.requestMediaKeySystemAccessFunc;if("function"!=typeof i){var r="Configured requestMediaKeySystemAccess is not a function "+i;return null===fe&&"http:"===self.location.protocol&&(r="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(r))}return i(e,t)},i.getMediaKeysPromise=function(e,t,i){var r=this,s=ye(e,t,i,this.config.drmSystemOptions),a=this.keySystemAccessPromises[e],n=null==a?void 0:a.keySystemAccess;if(!n){this.log('Requesting encrypted media "'+e+'" key-system access with config: '+JSON.stringify(s)),n=this.requestMediaKeySystemAccess(e,s);var o=this.keySystemAccessPromises[e]={keySystemAccess:n};return n.catch((function(t){r.log('Failed to obtain access to key-system "'+e+'": '+t)})),n.then((function(t){r.log('Access for key-system "'+t.keySystem+'" obtained');var i=r.fetchServerCertificate(e);return r.log('Create media-keys for "'+e+'"'),o.mediaKeys=t.createMediaKeys().then((function(t){return r.log('Media-keys created for "'+e+'"'),i.then((function(i){return i?r.setMediaKeysServerCertificate(t,e,i):t}))})),o.mediaKeys.catch((function(t){r.error('Failed to create media-keys for "'+e+'"}: '+t)})),o.mediaKeys}))}return n.then((function(){return a.mediaKeys}))},i.createMediaKeySessionContext=function(e){var t=e.decryptdata,i=e.keySystem,r=e.mediaKeys;this.log('Creating key-system session "'+i+'" keyId: '+ve.hexDump(t.keyId||[]));var s=r.createSession(),a={decryptdata:t,keySystem:i,mediaKeys:r,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(a),a},i.renewKeySession=function(e){var t=e.decryptdata;if(t.pssh){var i=this.createMediaKeySessionContext(e),r=this.getKeyIdString(t),s="cenc";this.keyIdToKeySessionPromise[r]=this.generateRequestWithPreferredKeySession(i,s,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)},i.getKeyIdString=function(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return ve.hexDump(e.keyId)},i.updateKeySession=function(e,t){var i,r=e.mediaKeysSession;return this.log('Updating key-session "'+r.sessionId+'" for keyID '+ve.hexDump((null==(i=e.decryptdata)?void 0:i.keyId)||[])+"\n } (data length: "+(t?t.byteLength:t)+")"),r.update(t)},i.selectKeySystemFormat=function(e){var t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log("Selecting key-system from fragment (sn: "+e.sn+" "+e.type+": "+e.level+") key formats "+t.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise},i.getKeyFormatPromise=function(e){var t=this;return new Promise((function(i,r){var s=ue(t.config),a=e.map(le).filter((function(e){return!!e&&-1!==s.indexOf(e)}));return t.getKeySystemSelectionPromise(a).then((function(e){var t=e.keySystem,s=ce(t);s?i(s):r(new Error('Unable to find format for key-system "'+t+'"'))})).catch(r)}))},i.loadKey=function(e){var t=this,i=e.keyInfo.decryptdata,r=this.getKeyIdString(i),s="(keyId: "+r+' format: "'+i.keyFormat+'" method: '+i.method+" uri: "+i.uri+")";this.log("Starting session for key "+s);var a=this.keyIdToKeySessionPromise[r];return a||(a=this.keyIdToKeySessionPromise[r]=this.getKeySystemForKeyPromise(i).then((function(r){var a=r.keySystem,n=r.mediaKeys;return t.throwIfDestroyed(),t.log("Handle encrypted media sn: "+e.frag.sn+" "+e.frag.type+": "+e.frag.level+" using key "+s),t.attemptSetMediaKeys(a,n).then((function(){t.throwIfDestroyed();var e=t.createMediaKeySessionContext({keySystem:a,mediaKeys:n,decryptdata:i}),r="cenc";return t.generateRequestWithPreferredKeySession(e,r,i.pssh,"playlist-key")}))}))).catch((function(e){return t.handleError(e)})),a},i.throwIfDestroyed=function(e){if(!this.hls)throw new Error("invalid state")},i.handleError=function(e){this.hls&&(this.error(e.message),e instanceof Eo?this.hls.trigger(k.ERROR,e.data):this.hls.trigger(k.ERROR,{type:C.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))},i.getKeySystemForKeyPromise=function(e){var t=this.getKeyIdString(e),i=this.keyIdToKeySessionPromise[t];if(!i){var r=le(e.keyFormat),s=r?[r]:ue(this.config);return this.attemptKeySystemAccess(s)}return i},i.getKeySystemSelectionPromise=function(e){if(e.length||(e=ue(this.config)),0===e.length)throw new Eo({type:C.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(e)},i.attemptSetMediaKeys=function(e,t){var i=this,r=this.setMediaKeysQueue.slice();this.log('Setting media-keys for "'+e+'"');var s=Promise.all(r).then((function(){if(!i.media)throw new Error("Attempted to set mediaKeys without media element attached");return i.media.setMediaKeys(t)}));return this.setMediaKeysQueue.push(s),s.then((function(){i.log('Media-keys set for "'+e+'"'),r.push(s),i.setMediaKeysQueue=i.setMediaKeysQueue.filter((function(e){return-1===r.indexOf(e)}))}))},i.generateRequestWithPreferredKeySession=function(e,t,i,r){var s,a,n=this,o=null==(s=this.config.drmSystems)||null==(a=s[e.keySystem])?void 0:a.generateRequest;if(o)try{var l=o.call(this.hls,t,i,e);if(!l)throw new Error("Invalid response from configured generateRequest filter");t=l.initDataType,i=e.decryptdata.pssh=l.initData?new Uint8Array(l.initData):null}catch(e){var d;if(this.warn(e.message),null!=(d=this.hls)&&d.config.debug)throw e}if(null===i)return this.log('Skipping key-session request for "'+r+'" (no initData)'),Promise.resolve(e);var h=this.getKeyIdString(e.decryptdata);this.log('Generating key-session request for "'+r+'": '+h+" (init data type: "+t+" length: "+(i?i.byteLength:null)+")");var c=new Na,u=e._onmessage=function(t){var i=e.mediaKeysSession;if(i){var r=t.messageType,s=t.message;n.log('"'+r+'" message event for session "'+i.sessionId+'" message size: '+s.byteLength),"license-request"===r||"license-renewal"===r?n.renewLicense(e,s).catch((function(e){n.handleError(e),c.emit("error",e)})):"license-release"===r?e.keySystem===ne.FAIRPLAY&&(n.updateKeySession(e,J("acknowledged")),n.removeSession(e)):n.warn('unhandled media key message type "'+r+'"')}else c.emit("error",new Error("invalid state"))},p=e._onkeystatuseschange=function(t){if(e.mediaKeysSession){n.onKeyStatusChange(e);var i=e.keyStatus;c.emit("keyStatus",i),"expired"===i&&(n.warn(e.keySystem+" expired for key "+h),n.renewKeySession(e))}else c.emit("error",new Error("invalid state"))};e.mediaKeysSession.addEventListener("message",u),e.mediaKeysSession.addEventListener("keystatuseschange",p);var f=new Promise((function(e,t){c.on("error",t),c.on("keyStatus",(function(i){i.startsWith("usable")?e():"output-restricted"===i?t(new Eo({type:C.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===i?t(new Eo({type:C.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'+i+'"')):"expired"===i?t(new Error("key expired while generating request")):n.warn('unhandled key status change "'+i+'"')}))}));return e.mediaKeysSession.generateRequest(t,i).then((function(){var t;n.log('Request generated for key-session "'+(null==(t=e.mediaKeysSession)?void 0:t.sessionId)+'" keyId: '+h)})).catch((function(e){throw new Eo({type:C.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_SESSION,error:e,fatal:!1},"Error generating key-session request: "+e)})).then((function(){return f})).catch((function(t){throw c.removeAllListeners(),n.removeSession(e),t})).then((function(){return c.removeAllListeners(),e}))},i.onKeyStatusChange=function(e){var t=this;e.mediaKeysSession.keyStatuses.forEach((function(i,r){t.log('key status change "'+i+'" for keyStatuses keyId: '+ve.hexDump("buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r))+" session keyId: "+ve.hexDump(new Uint8Array(e.decryptdata.keyId||[]))+" uri: "+e.decryptdata.uri),e.keyStatus=i}))},i.fetchServerCertificate=function(e){var t=this.config,i=new(0,t.loader)(t),r=this.getServerCertificateUrl(e);return r?(this.log('Fetching server certificate for "'+e+'"'),new Promise((function(s,n){var o={responseType:"arraybuffer",url:r},l=t.certLoadPolicy.default,d={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:function(e,t,i,r){s(e.data)},onError:function(t,i,s,l){n(new Eo({type:C.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:s,response:a({url:o.url,data:void 0},t)},'"'+e+'" certificate request failed ('+r+"). Status: "+t.code+" ("+t.text+")"))},onTimeout:function(t,i,s){n(new Eo({type:C.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:s,response:{url:o.url,data:void 0}},'"'+e+'" certificate request timed out ('+r+")"))},onAbort:function(e,t,i){n(new Error("aborted"))}};i.load(o,d,h)}))):Promise.resolve()},i.setMediaKeysServerCertificate=function(e,t,i){var r=this;return new Promise((function(s,a){e.setServerCertificate(i).then((function(a){r.log("setServerCertificate "+(a?"success":"not supported by CDM")+" ("+(null==i?void 0:i.byteLength)+') on "'+t+'"'),s(e)})).catch((function(e){a(new Eo({type:C.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:!0},e.message))}))}))},i.renewLicense=function(e,t){var i=this;return this.requestLicense(e,new Uint8Array(t)).then((function(t){return i.updateKeySession(e,new Uint8Array(t)).catch((function(e){throw new Eo({type:C.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:e,fatal:!0},e.message)}))}))},i.unpackPlayReadyKeyMessage=function(e,t){var i=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!i.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;var r=(new DOMParser).parseFromString(i,"application/xml"),s=r.querySelectorAll("HttpHeader");if(s.length>0)for(var a,n=0,o=s.length;n<o;n++){var l,d,h=null==(l=(a=s[n]).querySelector("name"))?void 0:l.textContent,c=null==(d=a.querySelector("value"))?void 0:d.textContent;h&&c&&e.setRequestHeader(h,c)}var u=r.querySelector("Challenge"),p=null==u?void 0:u.textContent;if(!p)throw new Error("Cannot find <Challenge> in key message");return J(atob(p))},i.setupLicenseXHR=function(e,t,i,r){var s=this,a=this.config.licenseXhrSetup;return a?Promise.resolve().then((function(){if(!i.decryptdata)throw new Error("Key removed");return a.call(s.hls,e,t,i,r)})).catch((function(n){if(!i.decryptdata)throw n;return e.open("POST",t,!0),a.call(s.hls,e,t,i,r)})).then((function(i){return e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:i||r}})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:r}))},i.requestLicense=function(e,t){var i=this,r=this.config.keyLoadPolicy.default;return new Promise((function(s,a){var n=i.getLicenseServerUrl(e.keySystem);i.log("Sending license request to URL: "+n);var o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=function(){if(!i.hls||!e.mediaKeysSession)return a(new Error("invalid state"));if(4===o.readyState)if(200===o.status){i._requestLicenseFailureCount=0;var l=o.response;i.log("License received "+(l instanceof ArrayBuffer?l.byteLength:l));var d=i.config.licenseResponseCallback;if(d)try{l=d.call(i.hls,o,n,e)}catch(e){i.error(e)}s(l)}else{var h=r.errorRetry,c=h?h.maxNumRetry:0;if(i._requestLicenseFailureCount++,i._requestLicenseFailureCount>c||o.status>=400&&o.status<500)a(new Eo({type:C.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:n,data:void 0,code:o.status,text:o.statusText}},"License Request XHR failed ("+n+"). Status: "+o.status+" ("+o.statusText+")"));else{var u=c-i._requestLicenseFailureCount+1;i.warn("Retrying license request, "+u+" attempts left"),i.requestLicense(e,t).then(s,a)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,i.setupLicenseXHR(o,n,e,t).then((function(t){var r=t.xhr,s=t.licenseChallenge;e.keySystem==ne.PLAYREADY&&(s=i.unpackPlayReadyKeyMessage(r,s)),r.send(s)}))}))},i.onMediaAttached=function(e,t){if(this.config.emeEnabled){var i=t.media;this.media=i,i.addEventListener("encrypted",this.onMediaEncrypted),i.addEventListener("waitingforkey",this.onWaitingForKey)}},i.onMediaDetached=function(){var e=this,i=this.media,r=this.mediaKeySessions;i&&(i.removeEventListener("encrypted",this.onMediaEncrypted),i.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},tt.clearKeyUriToKeyIdMap();var s=r.length;t.CDMCleanupPromise=Promise.all(r.map((function(t){return e.removeSession(t)})).concat(null==i?void 0:i.setMediaKeys(null).catch((function(t){e.log("Could not clear media keys: "+t)})))).then((function(){s&&(e.log("finished closing key sessions and clearing media keys"),r.length=0)})).catch((function(t){e.log("Could not close sessions and clear media keys: "+t)}))},i.onManifestLoading=function(){this.keyFormatPromise=null},i.onManifestLoaded=function(e,t){var i=t.sessionKeys;if(i&&this.config.emeEnabled&&!this.keyFormatPromise){var r=i.reduce((function(e,t){return-1===e.indexOf(t.keyFormat)&&e.push(t.keyFormat),e}),[]);this.log("Selecting key-system from session-keys "+r.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(r)}},i.removeSession=function(e){var t=this,i=e.mediaKeysSession,r=e.licenseXhr;if(i){this.log("Remove licenses and keys and close session "+i.sessionId),e._onmessage&&(i.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(i.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var s=this.mediaKeySessions.indexOf(e);return s>-1&&this.mediaKeySessions.splice(s,1),i.remove().catch((function(e){t.log("Could not remove session: "+e)})).then((function(){return i.close()})).catch((function(e){t.log("Could not close session: "+e)}))}},t}(I);Ao.CDMCleanupPromise=void 0;var vo,bo,_o,wo,Eo=function(e){function t(t,i){var r;return(r=e.call(this,i)||this).data=void 0,t.error||(t.error=new Error(i)),r.data=t,t.err=t.error,r}return u(t,e),t}(m(Error));(function(e){e.MANIFEST="m",e.AUDIO="a",e.VIDEO="v",e.MUXED="av",e.INIT="i",e.CAPTION="c",e.TIMED_TEXT="tt",e.KEY="k",e.OTHER="o"})(vo||(vo={})),function(e){e.DASH="d",e.HLS="h",e.SMOOTH="s",e.OTHER="o"}(bo||(bo={})),function(e){e.OBJECT="CMCD-Object",e.REQUEST="CMCD-Request",e.SESSION="CMCD-Session",e.STATUS="CMCD-Status"}(_o||(_o={}));var So=((wo={})[_o.OBJECT]=["br","d","ot","tb"],wo[_o.REQUEST]=["bl","dl","mtp","nor","nrr","su"],wo[_o.SESSION]=["cid","pr","sf","sid","st","v"],wo[_o.STATUS]=["bs","rtp"],wo),To=function e(t,i){Array.isArray(t)&&(t=t.map((function(t){return t instanceof e?t:new e(t)}))),this.value=t,this.params=i},ko="Dict";function Co(e){return Array.isArray(e)?JSON.stringify(e):e instanceof Map?"Map{}":e instanceof Set?"Set{}":"object"==typeof e?JSON.stringify(e):String(e)}function Do(e,t,i,r){return new Error("failed to "+e+' "'+Co(t)+'" as '+i,{cause:r})}function Ro(e,t,i){return Do("serialize",e,t,i)}var xo=function(e){this.description=e},Lo="Bare Item",Io="Boolean";function Po(e){if("boolean"!=typeof e)throw Ro(e,Io);return e?"?1":"?0"}var Bo="Byte Sequence";function Mo(e){if(!1===ArrayBuffer.isView(e))throw Ro(e,Bo);return":"+ai(e)+":"}var Uo="Integer";function Fo(e){return e<-999999999999999||999999999999999<e}function Oo(e){if(Fo(e))throw Ro(e,Uo);return e.toString()}function No(e){return"@"+Oo(e.getTime()/1e3)}var Go="Decimal";function zo(e){var t=ni(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw Ro(e,Go);var i=t.toString();return i.includes(".")?i:i+".0"}var Wo="String",Vo=/[\x00-\x1f\x7f]+/;function Ho(e){if(Vo.test(e))throw Ro(e,Wo);return'"'+e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'}function $o(e){return e.description||e.toString().slice(7,-1)}var jo="Token";function Ko(e){var t=$o(e);if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(t))throw Ro(t,jo);return t}function qo(e){switch(typeof e){case"number":if(!E(e))throw Ro(e,Lo);return Number.isInteger(e)?Oo(e):zo(e);case"string":return Ho(e);case"symbol":return Ko(e);case"boolean":return Po(e);case"object":if(e instanceof Date)return No(e);if(e instanceof Uint8Array)return Mo(e);if(e instanceof xo)return Ko(e);default:throw Ro(e,Lo)}}var Yo="Key";function Qo(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw Ro(e,Yo);return e}function Xo(e){return null==e?"":Object.entries(e).map((function(e){var t=e[0],i=e[1];return!0===i?";"+Qo(t):";"+Qo(t)+"="+qo(i)})).join("")}function Jo(e){return e instanceof To?""+qo(e.value)+Xo(e.params):qo(e)}function Zo(e){return"("+e.value.map(Jo).join(" ")+")"+Xo(e.params)}function el(e,t){if(void 0===t&&(t={whitespace:!0}),"object"!=typeof e)throw Ro(e,ko);var i=e instanceof Map?e.entries():Object.entries(e),r=(null==t?void 0:t.whitespace)?" ":"";return Array.from(i).map((function(e){var t=e[0],i=e[1];i instanceof To==0&&(i=new To(i));var r=Qo(t);return!0===i.value?r+=Xo(i.params):(r+="=",Array.isArray(i.value)?r+=Zo(i):r+=Jo(i)),r})).join(","+r)}function tl(e,t){return el(e,t)}var il=function(e){return"ot"===e||"sf"===e||"st"===e},rl=function(e){return"number"==typeof e?E(e):null!=e&&""!==e&&!1!==e},sl=function(e){return Math.round(e)},al=function(e){return 100*sl(e/100)},nl={br:sl,d:sl,bl:al,dl:al,mtp:al,nor:function(e,t){return(null==t?void 0:t.baseUrl)&&(e=oi(e,t.baseUrl)),encodeURIComponent(e)},rtp:al,tb:sl};function ol(e,t){var i={};if(null==e||"object"!=typeof e)return i;var r=Object.keys(e).sort(),s=c({},nl,null==t?void 0:t.formatters),a=null==t?void 0:t.filter;return r.forEach((function(r){if(!(null==a?void 0:a(r))){var n=e[r],o=s[r];o&&(n=o(n,t)),"v"===r&&1===n||"pr"==r&&1===n||rl(n)&&(il(r)&&"string"==typeof n&&(n=new xo(n)),i[r]=n)}})),i}function ll(e,t){return void 0===t&&(t={}),e?tl(ol(e,t),c({whitespace:!1},t)):""}function dl(e,t){if(void 0===t&&(t={}),!e)return{};var i=Object.entries(e),r=Object.entries(So).concat(Object.entries((null==t?void 0:t.customHeaderMap)||{})),s=i.reduce((function(e,t){var i,s,a=t[0],n=t[1],o=(null===(i=r.find((function(e){return e[1].includes(a)})))||void 0===i?void 0:i[0])||_o.REQUEST;return null!==(s=e[o])&&void 0!==s||(e[o]={}),e[o][a]=n,e}),{});return Object.entries(s).reduce((function(e,i){var r=i[0],s=i[1];return e[r]=ll(s,t),e}),{})}function hl(e,t,i){return c(e,dl(t,i))}var cl="CMCD";function ul(e,t){if(void 0===t&&(t={}),!e)return"";var i=ll(e,t);return cl+"="+encodeURIComponent(i)}var pl=/CMCD=[^&#]+/;function fl(e,t,i){var r=ul(t,i);if(!r)return e;if(pl.test(e))return e.replace(pl,r);var s=e.includes("?")?"&":"?";return""+e+s+r}var yl=function(){function e(e){var t=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){t.initialized&&(t.starved=!0),t.buffering=!0},this.onPlaying=function(){t.initialized||(t.initialized=!0),t.buffering=!1},this.applyPlaylistData=function(e){try{t.apply(e,{ot:vo.MANIFEST,su:!t.initialized})}catch(e){t.hls.logger.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=function(e){try{var i=e.frag,r=t.hls.levels[i.level],s=t.getObjectType(i),a={d:1e3*i.duration,ot:s};s!==vo.VIDEO&&s!==vo.AUDIO&&s!=vo.MUXED||(a.br=r.bitrate/1e3,a.tb=t.getTopBandwidth(s)/1e3,a.bl=t.getBufferLength(s));var n=t.getNextFrag(i);n&&n.url&&n.url!==i.url&&(a.nor=n.url),t.apply(e,a)}catch(e){t.hls.logger.warn("Could not generate segment CMCD data.",e)}},this.hls=e;var i=this.config=e.config,r=i.cmcd;null!=r&&(i.pLoader=this.createPlaylistLoader(),i.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||li(),this.cid=r.contentId,this.useHeaders=!0===r.useHeaders,this.includeKeys=r.includeKeys,this.registerListeners())}var t=e.prototype;return t.registerListeners=function(){var e=this.hls;e.on(k.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(k.MEDIA_DETACHED,this.onMediaDetached,this),e.on(k.BUFFER_CREATED,this.onBufferCreated,this)},t.unregisterListeners=function(){var e=this.hls;e.off(k.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(k.MEDIA_DETACHED,this.onMediaDetached,this),e.off(k.BUFFER_CREATED,this.onBufferCreated,this)},t.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=null},t.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},t.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},t.onBufferCreated=function(e,t){var i,r;this.audioBuffer=null==(i=t.tracks.audio)?void 0:i.buffer,this.videoBuffer=null==(r=t.tracks.video)?void 0:r.buffer},t.createData=function(){var e;return{v:1,sf:bo.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},t.apply=function(e,t){void 0===t&&(t={}),c(t,this.createData());var i=t.ot===vo.INIT||t.ot===vo.VIDEO||t.ot===vo.MUXED;this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);var r=this.includeKeys;r&&(t=Object.keys(t).reduce((function(e,i){return r.includes(i)&&(e[i]=t[i]),e}),{}));var s={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),hl(e.headers,t,s)):e.url=fl(e.url,t,s)},t.getNextFrag=function(e){var t,i=null==(t=this.hls.levels[e.level])?void 0:t.details;if(i){var r=e.sn-i.startSN;return i.fragments[r+1]}},t.getObjectType=function(e){var t=e.type;return"subtitle"===t?vo.TIMED_TEXT:"initSegment"===e.sn?vo.INIT:"audio"===t?vo.AUDIO:"main"===t?this.hls.audioTracks.length?vo.VIDEO:vo.MUXED:void 0},t.getTopBandwidth=function(e){var t,i=0,r=this.hls;if(e===vo.AUDIO)t=r.audioTracks;else{var s=r.maxAutoLevel,a=s>-1?s+1:r.levels.length;t=r.levels.slice(0,a)}for(var n,o=v(t);!(n=o()).done;){var l=n.value;l.bitrate>i&&(i=l.bitrate)}return i>0?i:NaN},t.getBufferLength=function(e){var t=this.media,i=e===vo.AUDIO?this.audioBuffer:this.videoBuffer;return i&&t?1e3*Fr.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len:NaN},t.createPlaylistLoader=function(){var e=this.config.pLoader,t=this.applyPlaylistData,i=e||this.config.loader;return function(){function e(e){this.loader=void 0,this.loader=new i(e)}var r=e.prototype;return r.destroy=function(){this.loader.destroy()},r.abort=function(){this.loader.abort()},r.load=function(e,i,r){t(e),this.loader.load(e,i,r)},d(e,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}])}()},t.createFragmentLoader=function(){var e=this.config.fLoader,t=this.applyFragmentData,i=e||this.config.loader;return function(){function e(e){this.loader=void 0,this.loader=new i(e)}var r=e.prototype;return r.destroy=function(){this.loader.destroy()},r.abort=function(){this.loader.abort()},r.load=function(e,i,r){t(e),this.loader.load(e,i,r)},d(e,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}])}()},e}(),ml=3e5,gl=function(e){function t(t){var i;return(i=e.call(this,"content-steering",t.logger)||this).hls=void 0,i.loader=null,i.uri=null,i.pathwayId=".",i.pathwayPriority=null,i.timeToLoad=300,i.reloadTimer=-1,i.updated=0,i.started=!1,i.enabled=!0,i.levels=null,i.audioTracks=null,i.subtitleTracks=null,i.penalizedPathways={},i.hls=t,i.registerListeners(),i}u(t,e);var i=t.prototype;return i.registerListeners=function(){var e=this.hls;e.on(k.MANIFEST_LOADING,this.onManifestLoading,this),e.on(k.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(k.MANIFEST_PARSED,this.onManifestParsed,this),e.on(k.ERROR,this.onError,this)},i.unregisterListeners=function(){var e=this.hls;e&&(e.off(k.MANIFEST_LOADING,this.onManifestLoading,this),e.off(k.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(k.MANIFEST_PARSED,this.onManifestParsed,this),e.off(k.ERROR,this.onError,this))},i.startLoad=function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}},i.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()},i.clearTimeout=function(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)},i.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},i.removeLevel=function(e){var t=this.levels;t&&(this.levels=t.filter((function(t){return t!==e})))},i.onManifestLoading=function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null},i.onManifestLoaded=function(e,t){var i=t.contentSteering;null!==i&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())},i.onManifestParsed=function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks},i.onError=function(e,t){var i=t.errorAction;if((null==i?void 0:i.action)===or.SendAlternateToPenaltyBox&&i.flags===lr.MoveAllAlternatesMatchingHost){var r=this.levels,s=this.pathwayPriority,a=this.pathwayId;if(t.context){var n=t.context,o=n.groupId,l=n.pathwayId,d=n.type;o&&r?a=this.getPathwayForGroupId(o,d,a):l&&(a=l)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!s&&r&&(s=r.reduce((function(e,t){return-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e}),[])),s&&s.length>1&&(this.updatePathwayPriority(s),i.resolved=this.pathwayId!==a),i.resolved||this.warn("Could not resolve "+t.details+' ("'+t.error.message+'") with content-steering for Pathway: '+a+" levels: "+(r?r.length:r)+" priorities: "+JSON.stringify(s)+" penalized: "+JSON.stringify(this.penalizedPathways))}},i.filterParsedLevels=function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){var i=e[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+i+'"'),t=this.getLevelsForPathway(i),this.pathwayId=i}return t.length!==e.length?(this.log("Found "+t.length+"/"+e.length+' levels in Pathway "'+this.pathwayId+'"'),t):e},i.getLevelsForPathway=function(e){return null===this.levels?[]:this.levels.filter((function(t){return e===t.pathwayId}))},i.updatePathwayPriority=function(e){var t;this.pathwayPriority=e;var i=this.penalizedPathways,r=performance.now();Object.keys(i).forEach((function(e){r-i[e]>ml&&delete i[e]}));for(var s=0;s<e.length;s++){var a=e[s];if(!(a in i)){if(a===this.pathwayId)return;var n=this.hls.nextLoadLevel,o=this.hls.levels[n];if((t=this.getLevelsForPathway(a)).length>0){this.log('Setting Pathway to "'+a+'"'),this.pathwayId=a,qi(t),this.hls.trigger(k.LEVELS_UPDATED,{levels:t});var l=this.hls.levels[n];o&&l&&this.levels&&(l.attrs["STABLE-VARIANT-ID"]!==o.attrs["STABLE-VARIANT-ID"]&&l.bitrate!==o.bitrate&&this.log("Unstable Pathways change from bitrate "+o.bitrate+" to "+l.bitrate),this.hls.nextLoadLevel=n);break}}}},i.getPathwayForGroupId=function(e,t,i){for(var r=this.getLevelsForPathway(i).concat(this.levels||[]),s=0;s<r.length;s++)if(t===Ot.AUDIO_TRACK&&r[s].hasAudioGroup(e)||t===Ot.SUBTITLE_TRACK&&r[s].hasSubtitleGroup(e))return r[s].pathwayId;return i},i.clonePathways=function(e){var t=this,i=this.levels;if(i){var r={},s={};e.forEach((function(e){var a=e.ID,n=e["BASE-ID"],o=e["URI-REPLACEMENT"];if(!i.some((function(e){return e.pathwayId===a}))){var l=t.getLevelsForPathway(n).map((function(e){var t=new L(e.attrs);t["PATHWAY-ID"]=a;var i=t.AUDIO&&t.AUDIO+"_clone_"+a,n=t.SUBTITLES&&t.SUBTITLES+"_clone_"+a;i&&(r[t.AUDIO]=i,t.AUDIO=i),n&&(s[t.SUBTITLES]=n,t.SUBTITLES=n);var l=vl(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",o),d=new Bi({attrs:t,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:l,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(var h=1;h<e.audioGroups.length;h++)d.addGroupId("audio",e.audioGroups[h]+"_clone_"+a);if(e.subtitleGroups)for(var c=1;c<e.subtitleGroups.length;c++)d.addGroupId("text",e.subtitleGroups[c]+"_clone_"+a);return d}));i.push.apply(i,l),Al(t.audioTracks,r,o,a),Al(t.subtitleTracks,s,o,a)}}))}},i.loadSteeringManifest=function(e){var t,i=this,r=this.hls.config,s=r.loader;this.loader&&this.loader.destroy(),this.loader=new s(r);try{t=new self.URL(e)}catch(t){return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: "+e)}if("data:"!==t.protocol){var a=0|(this.hls.bandwidthEstimate||r.abrEwmaDefaultEstimate);t.searchParams.set("_HLS_pathway",this.pathwayId),t.searchParams.set("_HLS_throughput",""+a)}var n={responseType:"json",url:t.href},o=r.steeringManifestLoadPolicy.default,l=o.errorRetry||o.timeoutRetry||{},d={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:l.maxNumRetry||0,retryDelay:l.retryDelayMs||0,maxRetryDelay:l.maxRetryDelayMs||0},h={onSuccess:function(e,r,s,a){i.log('Loaded steering manifest: "'+t+'"');var n=e.data;if(1===(null==n?void 0:n.VERSION)){i.updated=performance.now(),i.timeToLoad=n.TTL;var o=n["RELOAD-URI"],l=n["PATHWAY-CLONES"],d=n["PATHWAY-PRIORITY"];if(o)try{i.uri=new self.URL(o,t).href}catch(e){return i.enabled=!1,void i.log("Failed to parse Steering Manifest RELOAD-URI: "+o)}i.scheduleRefresh(i.uri||s.url),l&&i.clonePathways(l);var h={steeringManifest:n,url:t.toString()};i.hls.trigger(k.STEERING_MANIFEST_LOADED,h),d&&i.updatePathwayPriority(d)}else i.log("Steering VERSION "+n.VERSION+" not supported!")},onError:function(e,t,r,s){if(i.log("Error loading steering manifest: "+e.code+" "+e.text+" ("+t.url+")"),i.stopLoad(),410===e.code)return i.enabled=!1,void i.log("Steering manifest "+t.url+" no longer available");var a=1e3*i.timeToLoad;if(429!==e.code)i.scheduleRefresh(i.uri||t.url,a);else{var n=i.loader;if("function"==typeof(null==n?void 0:n.getResponseHeader)){var o=n.getResponseHeader("Retry-After");o&&(a=1e3*parseFloat(o))}i.log("Steering manifest "+t.url+" rate limited")}},onTimeout:function(e,t,r){i.log("Timeout loading steering manifest ("+t.url+")"),i.scheduleRefresh(i.uri||t.url)}};this.log("Requesting steering manifest: "+t),this.loader.load(n,d,h)},i.scheduleRefresh=function(e,t){var i=this;void 0===t&&(t=1e3*this.timeToLoad),this.clearTimeout(),this.reloadTimer=self.setTimeout((function(){var t,r=null==(t=i.hls)?void 0:t.media;!r||r.ended?i.scheduleRefresh(e,1e3*i.timeToLoad):i.loadSteeringManifest(e)}),t)},t}(I);function Al(e,t,i,r){e&&Object.keys(t).forEach((function(s){var a=e.filter((function(e){return e.groupId===s})).map((function(e){var a=c({},e);return a.details=void 0,a.attrs=new L(a.attrs),a.url=a.attrs.URI=vl(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",i),a.groupId=a.attrs["GROUP-ID"]=t[s],a.attrs["PATHWAY-ID"]=r,a}));e.push.apply(e,a)}))}function vl(e,t,i,r){var s,a=r.HOST,n=r.PARAMS,o=r[i];t&&(s=null==o?void 0:o[t])&&(e=s);var l=new self.URL(e);return a&&!s&&(l.host=a),n&&Object.keys(n).sort().forEach((function(e){e&&l.searchParams.set(e,n[e])})),l.href}var bl=/^age:\s*[\d.]+\s*$/im,_l=function(){function e(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new H,this.retryDelay=0}var t=e.prototype;return t.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null,this.stats=null},t.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))},t.abort=function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},t.load=function(e,t,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=i,this.loadInternal()},t.loadInternal=function(){var e=this,t=this.config,i=this.context;if(t&&i){var r=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;var a=this.xhrSetup;a?Promise.resolve().then((function(){if(!e.stats.aborted)return a(r,i.url)})).catch((function(e){return r.open("GET",i.url,!0),a(r,i.url)})).then((function(){e.stats.aborted||e.openAndSendXhr(r,i,t)})).catch((function(t){e.callbacks.onError({code:r.status,text:t.message},i,r,s)})):this.openAndSendXhr(r,i,t)}},t.openAndSendXhr=function(e,t,i){e.readyState||e.open("GET",t.url,!0);var r=t.headers,s=i.loadPolicy,a=s.maxTimeToFirstByteMs,n=s.maxLoadTimeMs;if(r)for(var o in r)e.setRequestHeader(o,r[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),i.timeout=a&&E(a)?a:n,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()},t.readystatechange=function(){var e=this.context,t=this.loader,i=this.stats;if(e&&t){var r=t.readyState,s=this.config;if(!i.aborted&&r>=2&&(0===i.loading.first&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),s.timeout!==s.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),s.timeout=s.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),4===r)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var a=t.status,n="text"!==t.responseType;if(a>=200&&a<300&&(n&&t.response||null!==t.responseText)){i.loading.end=Math.max(self.performance.now(),i.loading.first);var o=n?t.response:t.responseText,l="arraybuffer"===t.responseType?o.byteLength:o.length;if(i.loaded=i.total=l,i.bwEstimate=8e3*i.total/(i.loading.end-i.loading.first),!this.callbacks)return;var d=this.callbacks.onProgress;if(d&&d(i,e,o,t),!this.callbacks)return;var h={url:t.responseURL,data:o,code:a};this.callbacks.onSuccess(h,i,e,t)}else{var c=s.loadPolicy.errorRetry;Zi(c,i.retry,!1,{url:e.url,data:void 0,code:a})?this.retry(c):(G.error(a+" while loading "+e.url),this.callbacks.onError({code:a,text:t.statusText},e,t,i))}}}},t.loadtimeout=function(){var e,t=null==(e=this.config)?void 0:e.loadPolicy.timeoutRetry;if(Zi(t,this.stats.retry,!0))this.retry(t);else{var i;G.warn("timeout while loading "+(null==(i=this.context)?void 0:i.url));var r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}},t.retry=function(e){var t=this.context,i=this.stats;this.retryDelay=Xi(e,i.retry),i.retry++,G.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+(null==t?void 0:t.url)+", retrying "+i.retry+"/"+e.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},t.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},t.getCacheAge=function(){var e=null;if(this.loader&&bl.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},t.getResponseHeader=function(e){return this.loader&&new RegExp("^"+e+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null},e}();function wl(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}var El=/(\d+)-(\d+)\/(\d+)/,Sl=function(){function e(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||Dl,this.controller=new self.AbortController,this.stats=new H}var t=e.prototype;return t.destroy=function(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null},t.abortInternal=function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())},t.abort=function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},t.load=function(e,t,i){var r=this,s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();var a=Tl(e,this.controller.signal),n=i.onProgress,o="arraybuffer"===e.responseType,l=o?"byteLength":"length",d=t.loadPolicy,h=d.maxTimeToFirstByteMs,c=d.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,a),self.clearTimeout(this.requestTimeout),t.timeout=h&&E(h)?h:c,this.requestTimeout=self.setTimeout((function(){r.abortInternal(),i.onTimeout(s,e,r.response)}),t.timeout),self.fetch(this.request).then((function(a){r.response=r.loader=a;var l=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(r.requestTimeout),t.timeout=c,r.requestTimeout=self.setTimeout((function(){r.abortInternal(),i.onTimeout(s,e,r.response)}),c-(l-s.loading.start)),!a.ok){var d=a.status,h=a.statusText;throw new Rl(h||"fetch, bad network response",d,a)}return s.loading.first=l,s.total=Cl(a.headers)||s.total,n&&E(t.highWaterMark)?r.loadProgressively(a,s,e,t.highWaterMark,n):o?a.arrayBuffer():"json"===e.responseType?a.json():a.text()})).then((function(a){var o=r.response;if(!o)throw new Error("loader destroyed");self.clearTimeout(r.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);var d=a[l];d&&(s.loaded=s.total=d);var h={url:o.url,data:a,code:o.status};n&&!E(t.highWaterMark)&&n(s,e,a,o),i.onSuccess(h,s,e,o)})).catch((function(t){if(self.clearTimeout(r.requestTimeout),!s.aborted){var a=t&&t.code||0,n=t?t.message:null;i.onError({code:a,text:n},e,t?t.details:null,s)}}))},t.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},t.getResponseHeader=function(e){return this.response?this.response.headers.get(e):null},t.loadProgressively=function(e,t,i,r,s){void 0===r&&(r=0);var a=new hs,n=e.body.getReader();return function o(){return n.read().then((function(n){if(n.done)return a.dataLength&&s(t,i,a.flush(),e),Promise.resolve(new ArrayBuffer(0));var l=n.value,d=l.length;return t.loaded+=d,d<r||a.dataLength?(a.push(l),a.dataLength>=r&&s(t,i,a.flush(),e)):s(t,i,l,e),o()})).catch((function(){return Promise.reject()}))}()},e}();function Tl(e,t){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(c({},e.headers))};return e.rangeEnd&&i.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1)),i}function kl(e){var t=El.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}function Cl(e){var t=e.get("Content-Range");if(t){var i=kl(t);if(E(i))return i}var r=e.get("Content-Length");if(r)return parseInt(r)}function Dl(e,t){return new self.Request(e.url,t)}var Rl=function(e){function t(t,i,r){var s;return(s=e.call(this,t)||this).code=void 0,s.details=void 0,s.code=i,s.details=r,s}return u(t,e),t}(m(Error)),xl=/\s/,Ll={newCue:function(e,t,i,r){for(var s,a,n,o,l,d=[],h=self.VTTCue||self.TextTrackCue,c=0;c<r.rows.length;c++)if(n=!0,o=0,l="",!(s=r.rows[c]).isEmpty()){for(var u,p=0;p<s.chars.length;p++)xl.test(s.chars[p].uchar)&&n?o++:(l+=s.chars[p].uchar,n=!1);s.cueStartTime=t,t===i&&(i+=1e-4),o>=16?o--:o++;var f=Gn(l.trim()),y=jn(t,i,f);null!=e&&null!=(u=e.cues)&&u.getCueById(y)||((a=new h(t,i,f)).id=y,a.line=c+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*o/32)),d.push(a))}return e&&d.length&&(d.sort((function(e,t){return"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line})),d.forEach((function(t){return Ht(e,t)}))),d}},Il=a(a({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:_l,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:xr,bufferController:ln,capLevelController:mo,errorController:dr,fpsController:go,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:fe,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!0,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},Pl()),{},{subtitleStreamController:rn,subtitleTrackController:an,timelineController:co,audioStreamController:Za,audioTrackController:en,emeController:Ao,cmcdController:yl,contentSteeringController:gl});function Pl(){return{cueHandler:Ll,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function Bl(e,t,i){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var r=Ml(e),s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach((function(e){var a=("level"===e?"playlist":e)+"LoadPolicy",n=void 0===t[a],o=[];s.forEach((function(i){var s=e+"Loading"+i,l=t[s];if(void 0!==l&&n){o.push(s);var d=r[a].default;switch(t[a]={default:d},i){case"TimeOut":d.maxLoadTimeMs=l,d.maxTimeToFirstByteMs=l;break;case"MaxRetry":d.errorRetry.maxNumRetry=l,d.timeoutRetry.maxNumRetry=l;break;case"RetryDelay":d.errorRetry.retryDelayMs=l,d.timeoutRetry.retryDelayMs=l;break;case"MaxRetryTimeout":d.errorRetry.maxRetryDelayMs=l,d.timeoutRetry.maxRetryDelayMs=l}}})),o.length&&i.warn('hls.js config: "'+o.join('", "')+'" setting(s) are deprecated, use "'+a+'": '+JSON.stringify(t[a]))})),a(a({},r),t)}function Ml(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(Ml):Object.keys(e).reduce((function(t,i){return t[i]=Ml(e[i]),t}),{}):e}function Ul(e,t){var i=e.loader;i!==Sl&&i!==_l?(t.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):wl()&&(e.loader=Sl,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}var Fl=function(e){function t(t,i){var r;return(r=e.call(this,t,"level-controller")||this)._levels=[],r._firstLevel=-1,r._maxAutoLevel=-1,r._startLevel=void 0,r.currentLevel=null,r.currentLevelIndex=-1,r.manualLevelIndex=-1,r.steering=void 0,r.onParsedComplete=void 0,r.steering=i,r._registerListeners(),r}u(t,e);var i=t.prototype;return i._registerListeners=function(){var e=this.hls;e.on(k.MANIFEST_LOADING,this.onManifestLoading,this),e.on(k.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(k.LEVEL_LOADED,this.onLevelLoaded,this),e.on(k.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(k.FRAG_BUFFERED,this.onFragBuffered,this),e.on(k.ERROR,this.onError,this)},i._unregisterListeners=function(){var e=this.hls;e.off(k.MANIFEST_LOADING,this.onManifestLoading,this),e.off(k.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(k.LEVEL_LOADED,this.onLevelLoaded,this),e.off(k.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(k.FRAG_BUFFERED,this.onFragBuffered,this),e.off(k.ERROR,this.onError,this)},i.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),e.prototype.destroy.call(this)},i.stopLoad=function(){this._levels.forEach((function(e){e.loadError=0,e.fragmentError=0})),e.prototype.stopLoad.call(this)},i.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1},i.onManifestLoading=function(e,t){this.resetLevels()},i.onManifestLoaded=function(e,t){var i=this.hls.config.preferManagedMediaSource,r=[],s={},a={},n=!1,o=!1,l=!1;t.levels.forEach((function(e){var t,d=e.attrs,h=e.audioCodec,c=e.videoCodec;h&&(e.audioCodec=h=bt(h,i)||void 0),0===(null==(t=c)?void 0:t.indexOf("avc1"))&&(c=e.videoCodec=wt(c));var u=e.width,p=e.height,f=e.unknownCodecs;if(n||(n=!(!u||!p)),o||(o=!!c),l||(l=!!h),!(null!=f&&f.length||h&&!ut(h,"audio",i)||c&&!ut(c,"video",i))){var y=d.CODECS,m=d["FRAME-RATE"],g=d["HDCP-LEVEL"],A=d["PATHWAY-ID"],v=d.RESOLUTION,b=d["VIDEO-RANGE"],_=(A||".")+"-"+e.bitrate+"-"+v+"-"+m+"-"+y+"-"+b+"-"+g;if(s[_])if(s[_].uri===e.url||e.attrs["PATHWAY-ID"])s[_].addGroupId("audio",d.AUDIO),s[_].addGroupId("text",d.SUBTITLES);else{var w=a[_]+=1;e.attrs["PATHWAY-ID"]=new Array(w+1).join(".");var E=new Bi(e);s[_]=E,r.push(E)}else{var S=new Bi(e);s[_]=S,a[_]=1,r.push(S)}}})),this.filterAndSortMediaOptions(r,t,n,o,l)},i.filterAndSortMediaOptions=function(e,t,i,r,s){var a=this,n=[],o=[],l=e;if((i||r)&&s&&(l=l.filter((function(e){var t=e.videoCodec,i=e.videoRange,r=e.width,s=e.height;return(!!t||!(!r||!s))&&xi(i)}))),0!==l.length){if(t.audioTracks){var d=this.hls.config.preferManagedMediaSource;Ol(n=t.audioTracks.filter((function(e){return!e.audioCodec||ut(e.audioCodec,"audio",d)})))}t.subtitles&&Ol(o=t.subtitles);var h=l.slice(0);l.sort((function(e,t){if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return Ri.indexOf(e.videoRange)-Ri.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){var r=yt(e.videoCodec),s=yt(t.videoCodec);if(r!==s)return s-r}if(e.uri===t.uri&&e.codecSet!==t.codecSet){var a=mt(e.codecSet),n=mt(t.codecSet);if(a!==n)return n-a}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0}));var c=h[0];if(this.steering&&(l=this.steering.filterParsedLevels(l)).length!==h.length)for(var u=0;u<h.length;u++)if(h[u].pathwayId===l[0].pathwayId){c=h[u];break}this._levels=l;for(var p=0;p<l.length;p++)if(l[p]===c){var f;this._firstLevel=p;var y=c.bitrate,m=this.hls.bandwidthEstimate;if(this.log("manifest loaded, "+l.length+" level(s) found, first bitrate: "+y),void 0===(null==(f=this.hls.userConfig)?void 0:f.abrEwmaDefaultEstimate)){var g=Math.min(y,this.hls.config.abrEwmaDefaultEstimateMax);g>m&&m===Il.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=g)}break}var A=s&&!r,v={levels:l,audioTracks:n,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:s,video:r,altAudio:!A&&n.some((function(e){return!!e.url}))};this.hls.trigger(k.MANIFEST_PARSED,v),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else Promise.resolve().then((function(){if(a.hls){t.levels.length&&a.warn("One or more CODECS in variant not supported: "+JSON.stringify(t.levels[0].attrs));var e=new Error("no level with compatible codecs found in manifest");a.hls.trigger(k.ERROR,{type:C.MEDIA_ERROR,details:D.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:e,reason:e.message})}}))},i.onError=function(e,t){!t.fatal&&t.context&&t.context.type===Ot.LEVEL&&t.context.level===this.level&&this.checkRetry(t)},i.onFragBuffered=function(e,t){var i=t.frag;if(void 0!==i&&i.type===Nt.MAIN){var r=i.elementaryStreams;if(!Object.keys(r).some((function(e){return!!r[e]})))return;var s=this._levels[i.level];null!=s&&s.loadError&&(this.log("Resetting level error count of "+s.loadError+" on frag buffered"),s.loadError=0)}},i.onLevelLoaded=function(e,t){var i,r,s=t.level,a=t.details,n=this._levels[s];if(!n)return this.warn("Invalid level index "+s),void(null!=(r=t.deliveryDirectives)&&r.skip&&(a.deltaUpdateFailed=!0));if(s===this.currentLevelIndex){0===n.fragmentError&&(n.loadError=0);var o=n.details;o===t.details&&o.advanced&&(o=void 0),this.playlistLoaded(s,t,o)}else null!=(i=t.deliveryDirectives)&&i.skip&&(a.deltaUpdateFailed=!0)},i.loadPlaylist=function(t){e.prototype.loadPlaylist.call(this);var i=this.currentLevelIndex,r=this.currentLevel;if(r&&this.shouldLoadPlaylist(r)){var s=r.uri;if(t)try{s=t.addDirectives(s)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}var a=r.attrs["PATHWAY-ID"];this.log("Loading level index "+i+(void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:"")+" with"+(a?" Pathway "+a:"")+" "+s),this.clearTimer(),this.hls.trigger(k.LEVEL_LOADING,{url:s,level:i,pathwayId:r.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}},i.removeLevel=function(e){var t,i=this,r=this._levels.filter((function(t,r){return r!==e||(i.steering&&i.steering.removeLevel(t),t===i.currentLevel&&(i.currentLevel=null,i.currentLevelIndex=-1,t.details&&t.details.fragments.forEach((function(e){return e.level=-1}))),!1)}));qi(r),this._levels=r,this.currentLevelIndex>-1&&null!=(t=this.currentLevel)&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(k.LEVELS_UPDATED,{levels:r})},i.onLevelsUpdated=function(e,t){var i=t.levels;this._levels=i},i.checkMaxAutoUpdated=function(){var e=this.hls,t=e.autoLevelCapping,i=e.maxAutoLevel,r=e.maxHdcpLevel;this._maxAutoLevel!==i&&(this._maxAutoLevel=i,this.hls.trigger(k.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:i,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:r}))},d(t,[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t=this._levels;if(0!==t.length){if(e<0||e>=t.length){var i=new Error("invalid level idx"),r=e<0;if(this.hls.trigger(k.ERROR,{type:C.OTHER_ERROR,details:D.LEVEL_SWITCH_ERROR,level:e,fatal:r,error:i,reason:i.message}),r)return;e=Math.min(e,t.length-1)}var s=this.currentLevelIndex,a=this.currentLevel,n=a?a.attrs["PATHWAY-ID"]:void 0,o=t[e],l=o.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=o,s!==e||!o.details||!a||n!==l){this.log("Switching to level "+e+" ("+(o.height?o.height+"p ":"")+(o.videoRange?o.videoRange+" ":"")+(o.codecSet?o.codecSet+" ":"")+"@"+o.bitrate+")"+(l?" with Pathway "+l:"")+" from level "+s+(n?" with Pathway "+n:""));var d={level:e,attrs:o.attrs,details:o.details,bitrate:o.bitrate,averageBitrate:o.averageBitrate,maxBitrate:o.maxBitrate,realBitrate:o.realBitrate,width:o.width,height:o.height,codecSet:o.codecSet,audioCodec:o.audioCodec,videoCodec:o.videoCodec,audioGroups:o.audioGroups,subtitleGroups:o.subtitleGroups,loaded:o.loaded,loadError:o.loadError,fragmentError:o.fragmentError,name:o.name,id:o.id,uri:o.uri,url:o.url,urlId:0,audioGroupIds:o.audioGroupIds,textGroupIds:o.textGroupIds};this.hls.trigger(k.LEVEL_SWITCHING,d);var h=o.details;if(!h||h.live){var c=this.switchParams(o.uri,null==a?void 0:a.details,h);this.loadPlaylist(c)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}}])}(hr);function Ol(e){var t={};e.forEach((function(e){var i=e.groupId||"";e.id=t[i]=t[i]||0,t[i]++}))}var Nl=function(){function e(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}var t=e.prototype;return t.abort=function(e){for(var t in this.keyUriToKeyInfo){var i=this.keyUriToKeyInfo[t].loader;if(i){var r;if(e&&e!==(null==(r=i.context)?void 0:r.frag.type))return;i.abort()}}},t.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},t.destroy=function(){for(var e in this.detach(),this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}},t.createKeyLoadError=function(e,t,i,r,s){return void 0===t&&(t=D.KEY_LOAD_ERROR),new Zr({type:C.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:s,error:i,networkDetails:r})},t.loadClear=function(e,t){var i=this;if(this.emeController&&this.config.emeEnabled)for(var r=e.sn,s=e.cc,a=function(){var e=t[n];if(s<=e.cc&&("initSegment"===r||"initSegment"===e.sn||r<e.sn))return i.emeController.selectKeySystemFormat(e).then((function(t){e.setKeyFormat(t)})),1},n=0;n<t.length&&!a();n++);},t.load=function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then((function(i){return t.loadInternal(e,i)})):this.loadInternal(e)},t.loadInternal=function(e,t){var i,r;t&&e.setKeyFormat(t);var s=e.decryptdata;if(!s){var a=new Error(t?"Expected frag.decryptdata to be defined after setting format "+t:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,a))}var n=s.uri;if(!n)return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+n+'"')));var o,l=this.keyUriToKeyInfo[n];if(null!=(i=l)&&i.decryptdata.key)return s.key=l.decryptdata.key,Promise.resolve({frag:e,keyInfo:l});if(null!=(r=l)&&r.keyLoadPromise)switch(null==(o=l.mediaKeySessionContext)?void 0:o.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return l.keyLoadPromise.then((function(t){return s.key=t.keyInfo.decryptdata.key,{frag:e,keyInfo:l}}))}switch(l=this.keyUriToKeyInfo[n]={decryptdata:s,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},s.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===s.keyFormat?this.loadKeyHTTP(l,e):this.loadKeyEME(l,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(l,e);default:return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+s.method+'"')))}},t.loadKeyEME=function(e,t){var i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var r=this.emeController.loadKey(i);if(r)return(e.keyLoadPromise=r.then((function(t){return e.mediaKeySessionContext=t,i}))).catch((function(t){throw e.keyLoadPromise=null,t}))}return Promise.resolve(i)},t.loadKeyHTTP=function(e,t){var i=this,r=this.config,s=new(0,r.loader)(r);return t.keyLoader=e.loader=s,e.keyLoadPromise=new Promise((function(n,o){var l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},d=r.keyLoadPolicy.default,h={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:function(e,t,r,s){var a=r.frag,l=r.keyInfo,d=r.url;if(!a.decryptdata||l!==i.keyUriToKeyInfo[d])return o(i.createKeyLoadError(a,D.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),s));l.decryptdata.key=a.decryptdata.key=new Uint8Array(e.data),a.keyLoader=null,l.loader=null,n({frag:a,keyInfo:l})},onError:function(e,r,s,n){i.resetLoader(r),o(i.createKeyLoadError(t,D.KEY_LOAD_ERROR,new Error("HTTP Error "+e.code+" loading key "+e.text),s,a({url:l.url,data:void 0},e)))},onTimeout:function(e,r,s){i.resetLoader(r),o(i.createKeyLoadError(t,D.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),s))},onAbort:function(e,r,s){i.resetLoader(r),o(i.createKeyLoadError(t,D.INTERNAL_ABORTED,new Error("key loading aborted"),s))}};s.load(l,h,c)}))},t.resetLoader=function(e){var t=e.frag,i=e.keyInfo,r=e.url,s=i.loader;t.keyLoader===s&&(t.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[r],s&&s.destroy()},e}();function Gl(){return self.SourceBuffer||self.WebKitSourceBuffer}function zl(){if(!dt())return!1;var e=Gl();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}function Wl(){if(!zl())return!1;var e=dt();return"function"==typeof(null==e?void 0:e.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some((function(t){return e.isTypeSupported(ft(t,"video"))}))||["mp4a.40.2","fLaC"].some((function(t){return e.isTypeSupported(ft(t,"audio"))})))}function Vl(){var e,t=Gl();return"function"==typeof(null==t||null==(e=t.prototype)?void 0:e.changeType)}var Hl=250,$l=2,jl=.1,Kl=.05,ql=function(e){function t(t,i,r,s){var a;return(a=e.call(this,"gap-controller",s.logger)||this).config=void 0,a.media=null,a.fragmentTracker=void 0,a.hls=void 0,a.nudgeRetry=0,a.stallReported=!1,a.stalled=null,a.moved=!1,a.seeking=!1,a.ended=0,a.config=t,a.media=i,a.fragmentTracker=r,a.hls=s,a}u(t,e);var i=t.prototype;return i.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},i.poll=function(e,t,i,r){var s=this.config,a=this.media,n=this.stalled;if(null!==a){var o=a.currentTime,l=a.seeking,d=this.seeking&&!l,h=!this.seeking&&l;if(this.seeking=l,o===e)if(h||d)this.stalled=null;else if(a.paused&&!l||a.ended||0===a.playbackRate||!Fr.getBuffered(a).length)this.nudgeRetry=0;else{var c=Fr.bufferInfo(a,o,0),u=c.nextStart||0;if(l){var p=c.len>$l,f=!u||t&&t.start<=o||u-o>$l&&!this.fragmentTracker.getPartialFragment(o);if(p||f)return;this.moved=!1}if(!this.moved&&null!==this.stalled){if(!(c.len>0||u))return;var y=Math.max(u,c.start||0)-o,m=null!=i&&i.live?2*i.targetduration:$l,g=this.fragmentTracker.getPartialFragment(o);if(y>0&&(y<=m||g))return void(a.paused||this._trySkipBufferHole(g))}var A=self.performance.now();if(null!==n){var v=A-n;if(!l&&v>=Hl){if(r===ls.ENDED&&(null==i||!i.live)&&Math.abs(o-((null==i?void 0:i.edge)||0))<1){if(v<1e3||this.ended)return;return this.ended=o,void this.hls.trigger(k.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(c),!this.media)return}var b=Fr.bufferInfo(a,o,s.maxBufferHole);this._tryFixBufferStall(b,v)}else this.stalled=A}else if(this.ended=0,this.moved=!0,l||(this.nudgeRetry=0),null!==n){if(this.stallReported){var _=self.performance.now()-n;this.warn("playback not stuck anymore @"+o+", after "+Math.round(_)+"ms"),this.stallReported=!1}this.stalled=null}}},i._tryFixBufferStall=function(e,t){var i=this.config,r=this.fragmentTracker,s=this.media;if(null!==s){var a=s.currentTime,n=r.getPartialFragment(a);if(n&&(this._trySkipBufferHole(n)||!this.media))return;(e.len>i.maxBufferHole||e.nextStart&&e.nextStart-a<i.maxBufferHole)&&t>1e3*i.highBufferWatchdogPeriod&&(this.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},i._reportStall=function(e){var t=this.hls,i=this.media;if(!this.stallReported&&i){this.stallReported=!0;var r=new Error("Playback stalling at @"+i.currentTime+" due to low buffer ("+JSON.stringify(e)+")");this.warn(r.message),t.trigger(k.ERROR,{type:C.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,fatal:!1,error:r,buffer:e.len})}},i._trySkipBufferHole=function(e){var t=this.config,i=this.hls,r=this.media;if(null===r)return 0;var s=r.currentTime,a=Fr.bufferInfo(r,s,0),n=s<a.start?a.start:a.nextStart;if(n){var o=a.len<=t.maxBufferHole,l=a.len>0&&a.len<1&&r.readyState<3,d=n-s;if(d>0&&(o||l)){if(d>t.maxBufferHole){var h=this.fragmentTracker,c=!1;if(0===s){var u=h.getAppendedFrag(0,Nt.MAIN);u&&n<u.end&&(c=!0)}if(!c){var p=e||h.getAppendedFrag(s,Nt.MAIN);if(p){for(var f=!1,y=p.end;y<n;){var m=h.getPartialFragment(y);if(!m){f=!0;break}y+=m.duration}if(f)return 0}}}var g=Math.max(n+Kl,s+jl);if(this.warn("skipping hole, adjusting currentTime from "+s+" to "+g),this.moved=!0,this.stalled=null,r.currentTime=g,e&&!e.gap){var A=new Error("fragment loaded with buffer holes, seeking from "+s+" to "+g);i.trigger(k.ERROR,{type:C.MEDIA_ERROR,details:D.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:A,reason:A.message,frag:e})}return g}}return 0},i._tryNudgeBuffer=function(){var e=this.config,t=this.hls,i=this.media,r=this.nudgeRetry;if(null!==i){var s=i.currentTime;if(this.nudgeRetry++,r<e.nudgeMaxRetry){var a=s+(r+1)*e.nudgeOffset,n=new Error("Nudging 'currentTime' from "+s+" to "+a);this.warn(n.message),i.currentTime=a,t.trigger(k.ERROR,{type:C.MEDIA_ERROR,details:D.BUFFER_NUDGE_ON_STALL,error:n,fatal:!1})}else{var o=new Error("Playhead still not moving while enough data buffered @"+s+" after "+e.nudgeMaxRetry+" nudges");this.error(o.message),t.trigger(k.ERROR,{type:C.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,error:o,fatal:!0})}}},t}(I),Yl=100,Ql=function(e){function t(t,i,r){var s;return(s=e.call(this,t,i,r,"stream-controller",Nt.MAIN)||this).audioCodecSwap=!1,s.gapController=null,s.level=-1,s._forceStartLoad=!1,s.altAudio=!1,s.audioOnly=!1,s.fragPlaying=null,s.fragLastKbps=0,s.couldBacktrack=!1,s.backtrackFragment=null,s.audioCodecSwitch=!1,s.videoBuffer=null,s.onMediaPlaying=function(){s.tick()},s.onMediaSeeked=function(){var e=s.media,t=e?e.currentTime:null;E(t)&&s.log("Media seeked to "+t.toFixed(3));var i=s.getMainFwdBufferInfo();null!==i&&0!==i.len?s.tick():s.warn('Main forward buffer length on "seeked" event '+(i?i.len:"empty")+")")},s.registerListeners(),s}u(t,e);var i=t.prototype;return i.registerListeners=function(){e.prototype.registerListeners.call(this);var t=this.hls;t.on(k.MANIFEST_PARSED,this.onManifestParsed,this),t.on(k.LEVEL_LOADING,this.onLevelLoading,this),t.on(k.LEVEL_LOADED,this.onLevelLoaded,this),t.on(k.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(k.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(k.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(k.BUFFER_CREATED,this.onBufferCreated,this),t.on(k.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(k.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(k.FRAG_BUFFERED,this.onFragBuffered,this)},i.unregisterListeners=function(){e.prototype.unregisterListeners.call(this);var t=this.hls;t.off(k.MANIFEST_PARSED,this.onManifestParsed,this),t.off(k.LEVEL_LOADED,this.onLevelLoaded,this),t.off(k.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(k.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(k.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(k.BUFFER_CREATED,this.onBufferCreated,this),t.off(k.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(k.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(k.FRAG_BUFFERED,this.onFragBuffered,this)},i.onHandlerDestroying=function(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),e.prototype.onHandlerDestroying.call(this)},i.startLoad=function(e){if(this.levels){var t=this.lastCurrentTime,i=this.hls;if(this.stopLoad(),this.setInterval(Yl),this.level=-1,!this.startFragRequested){var r=i.startLevel;-1===r&&(i.config.testBandwidth&&this.levels.length>1?(r=0,this.bitrateTest=!0):r=i.firstAutoLevel),i.nextLoadLevel=r,this.level=i.loadLevel,this.loadedmetadata=!1}t>0&&-1===e&&(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=ls.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=ls.STOPPED},i.stopLoad=function(){this._forceStartLoad=!1,e.prototype.stopLoad.call(this)},i.doTick=function(){switch(this.state){case ls.WAITING_LEVEL:var e=this.levels,t=this.level,i=null==e?void 0:e[t],r=null==i?void 0:i.details;if(r&&(!r.live||this.levelLastLoaded===i)){if(this.waitForCdnTuneIn(r))break;this.state=ls.IDLE;break}if(this.hls.nextLoadLevel!==this.level){this.state=ls.IDLE;break}break;case ls.FRAG_LOADING_WAITING_RETRY:var s,a=self.performance.now(),n=this.retryDate;if(!n||a>=n||null!=(s=this.media)&&s.seeking){var o=this.levels,l=this.level,d=null==o?void 0:o[l];this.resetStartWhenNotLoaded(d||null),this.state=ls.IDLE}}this.state===ls.IDLE&&this.doTickIdle(),this.onTickEnd()},i.onTickEnd=function(){e.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},i.doTickIdle=function(){if(this.buffering){var e=this.hls,t=this.levelLastLoaded,i=this.levels,r=this.media;if(null!==t&&(r||!this.startFragRequested&&e.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)){var s=e.nextLoadLevel;if(null!=i&&i[s]){var a=i[s],n=this.getMainFwdBufferInfo();if(null!==n){var o=this.getLevelDetails();if(o&&this._streamEnded(n,o)){var l={};return this.altAudio&&(l.type="video"),this.hls.trigger(k.BUFFER_EOS,l),void(this.state=ls.ENDED)}e.loadLevel!==s&&-1===e.manualLevel&&this.log("Adapting to level "+s+" from level "+this.level),this.level=e.nextLoadLevel=s;var d=a.details;if(!d||this.state===ls.WAITING_LEVEL||d.live&&this.levelLastLoaded!==a)return this.level=s,void(this.state=ls.WAITING_LEVEL);var h=n.len,c=this.getMaxBufferLength(a.maxBitrate);if(!(h>=c)){this.backtrackFragment&&this.backtrackFragment.start>n.end&&(this.backtrackFragment=null);var u=this.backtrackFragment?this.backtrackFragment.start:n.end,p=this.getNextFragment(u,d);if(this.couldBacktrack&&!this.fragPrevious&&p&&"initSegment"!==p.sn&&this.fragmentTracker.getState(p)!==Ir.OK){var f,y=(null!=(f=this.backtrackFragment)?f:p).sn-d.startSN,m=d.fragments[y-1];m&&p.cc===m.cc&&(p=m,this.fragmentTracker.removeFragment(m))}else this.backtrackFragment&&n.len&&(this.backtrackFragment=null);if(p&&this.isLoopLoading(p,u)){if(!p.gap){var g=this.audioOnly&&!this.altAudio?$.AUDIO:$.VIDEO,A=(g===$.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;A&&this.afterBufferFlushed(A,g,Nt.MAIN)}p=this.getNextFragmentLoopLoading(p,d,n,Nt.MAIN,c)}p&&(!p.initSegment||p.initSegment.data||this.bitrateTest||(p=p.initSegment),this.loadFragment(p,a,u))}}}}}},i.loadFragment=function(t,i,r){var s=this.fragmentTracker.getState(t);this.fragCurrent=t,s===Ir.NOT_LOADED||s===Ir.PARTIAL?"initSegment"===t.sn?this._loadInitSegment(t,i):this.bitrateTest?(this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t,i)):(this.startFragRequested=!0,e.prototype.loadFragment.call(this,t,i,r)):this.clearTrackerIfNeeded(t)},i.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,Nt.MAIN)},i.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},i.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},i.nextLevelSwitch=function(){var e=this.levels,t=this.media;if(null!=t&&t.readyState){var i,r=this.getAppendedFrag(t.currentTime);r&&r.start>1&&this.flushMainBuffer(0,r.start-1);var s=this.getLevelDetails();if(null!=s&&s.live){var a=this.getMainFwdBufferInfo();if(!a||a.len<2*s.targetduration)return}if(!t.paused&&e){var n=e[this.hls.nextLoadLevel],o=this.fragLastKbps;i=o&&this.fragCurrent?this.fragCurrent.duration*n.maxBitrate/(1e3*o)+1:0}else i=0;var l=this.getBufferedFrag(t.currentTime+i);if(l){var d=this.followingBufferedFrag(l);if(d){this.abortCurrentFrag();var h=d.maxStartPTS?d.maxStartPTS:d.start,c=d.duration,u=Math.max(l.end,h+Math.min(Math.max(c-this.config.maxFragLookUpTolerance,c*(this.couldBacktrack?.5:.125)),c*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(u,Number.POSITIVE_INFINITY)}}}},i.abortCurrentFrag=function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case ls.KEY_LOADING:case ls.FRAG_LOADING:case ls.FRAG_LOADING_WAITING_RETRY:case ls.PARSING:case ls.PARSED:this.state=ls.IDLE}this.nextLoadPosition=this.getLoadPosition()},i.flushMainBuffer=function(t,i){e.prototype.flushMainBuffer.call(this,t,i,this.altAudio?"video":null)},i.onMediaAttached=function(t,i){e.prototype.onMediaAttached.call(this,t,i);var r=i.media;r.addEventListener("playing",this.onMediaPlaying),r.addEventListener("seeked",this.onMediaSeeked),this.gapController=new ql(this.config,r,this.fragmentTracker,this.hls)},i.onMediaDetaching=function(){var t=this.media;t&&(t.removeEventListener("playing",this.onMediaPlaying),t.removeEventListener("seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),e.prototype.onMediaDetaching.call(this)},i.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(k.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1},i.onManifestParsed=function(e,t){var i=!1,r=!1;t.levels.forEach((function(e){var t=e.audioCodec;t&&(i=i||-1!==t.indexOf("mp4a.40.2"),r=r||-1!==t.indexOf("mp4a.40.5"))})),this.audioCodecSwitch=i&&r&&!Vl(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1},i.onLevelLoading=function(e,t){var i=this.levels;if(i&&this.state===ls.IDLE){var r=i[t.level];(!r.details||r.details.live&&this.levelLastLoaded!==r||this.waitForCdnTuneIn(r.details))&&(this.state=ls.WAITING_LEVEL)}},i.onLevelLoaded=function(e,t){var i,r=this.levels,s=t.level,a=t.details,n=a.totalduration;if(r){this.log("Level "+s+" loaded ["+a.startSN+","+a.endSN+"]"+(a.lastPartSn?"[part-"+a.lastPartSn+"-"+a.lastPartIndex+"]":"")+", cc ["+a.startCC+", "+a.endCC+"] duration:"+n);var o=r[s],l=this.fragCurrent;!l||this.state!==ls.FRAG_LOADING&&this.state!==ls.FRAG_LOADING_WAITING_RETRY||l.level!==t.level&&l.loader&&this.abortCurrentFrag();var d=0;if(a.live||null!=(i=o.details)&&i.live){var h;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;d=this.alignPlaylists(a,o.details,null==(h=this.levelLastLoaded)?void 0:h.details)}if(o.details=a,this.levelLastLoaded=o,this.hls.trigger(k.LEVEL_UPDATED,{details:a,level:s}),this.state===ls.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=ls.IDLE}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,d),this.tick()}else this.warn("Levels were reset while loading level "+s)},i._handleFragmentLoadProgress=function(e){var t,i=e.frag,r=e.part,s=e.payload,a=this.levels;if(a){var n=a[i.level],o=n.details;if(!o)return this.warn("Dropping fragment "+i.sn+" of level "+i.level+" after level details were reset"),void this.fragmentTracker.removeFragment(i);var l=n.videoCodec,d=o.PTSKnown||!o.live,h=null==(t=i.initSegment)?void 0:t.data,c=this._getAudioCodec(n),u=this.transmuxer=this.transmuxer||new qa(this.hls,Nt.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),p=r?r.index:-1,f=-1!==p,y=new Or(i.level,i.sn,i.stats.chunkCount,s.byteLength,p,f),m=this.initPTS[i.cc];u.push(s,h,c,l,i,r,o.totalduration,d,y,m)}else this.warn("Levels were reset while fragment load was in progress. Fragment "+i.sn+" of level "+i.level+" will not be buffered")},i.onAudioTrackSwitching=function(e,t){var i=this.altAudio;if(!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var r=this.fragCurrent;r&&(this.log("Switching to main audio track, cancel main fragment load"),r.abortRequests(),this.fragmentTracker.removeFragment(r)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var s=this.hls;i&&(s.trigger(k.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),s.trigger(k.AUDIO_TRACK_SWITCHED,t)}},i.onAudioTrackSwitched=function(e,t){var i=t.id,r=!!this.hls.audioTracks[i].url;if(r){var s=this.videoBuffer;s&&this.mediaBuffer!==s&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=s)}this.altAudio=r,this.tick()},i.onBufferCreated=function(e,t){var i,r,s=t.tracks,a=!1;for(var n in s){var o=s[n];if("main"===o.id){if(r=n,i=o,"video"===n){var l=s[n];l&&(this.videoBuffer=l.buffer)}}else a=!0}a&&i?(this.log("Alternate track found, use "+r+".buffered to schedule main fragment loading"),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media},i.onFragBuffered=function(e,t){var i=t.frag,r=t.part;if(!i||i.type===Nt.MAIN){if(this.fragContextChanged(i))return this.warn("Fragment "+i.sn+(r?" p: "+r.index:"")+" of level "+i.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===ls.PARSED&&(this.state=ls.IDLE));var s=r?r.stats:i.stats;this.fragLastKbps=Math.round(8*s.total/(s.buffering.end-s.loading.first)),"initSegment"!==i.sn&&(this.fragPrevious=i),this.fragBufferedComplete(i,r)}},i.onError=function(e,t){var i;if(t.fatal)this.state=ls.ERROR;else switch(t.details){case D.FRAG_GAP:case D.FRAG_PARSING_ERROR:case D.FRAG_DECRYPT_ERROR:case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Nt.MAIN,t);break;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:case D.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==ls.WAITING_LEVEL||(null==(i=t.context)?void 0:i.type)!==Ot.LEVEL||(this.state=ls.IDLE);break;case D.BUFFER_APPEND_ERROR:case D.BUFFER_FULL_ERROR:if(!t.parent||"main"!==t.parent)return;if(t.details===D.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case D.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}},i.checkBuffer=function(){var e=this.media,t=this.gapController;if(e&&t&&e.readyState){if(this.loadedmetadata||!Fr.getBuffered(e).length){var i=this.state,r=i!==ls.IDLE?this.fragCurrent:null,s=this.getLevelDetails();t.poll(this.lastCurrentTime,r,s,i)}this.lastCurrentTime=e.currentTime}},i.onFragLoadEmergencyAborted=function(){this.state=ls.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},i.onBufferFlushed=function(e,t){var i=t.type;if(i!==$.AUDIO||this.audioOnly&&!this.altAudio){var r=(i===$.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(r,i,Nt.MAIN),this.tick()}},i.onLevelsUpdated=function(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=t.levels},i.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},i.seekToStartPos=function(){var e=this.media;if(e){var t=e.currentTime,i=this.startPosition;if(i>=0&&t<i){if(e.seeking)return void this.log("could not seek to "+i+", already seeking at "+t);var r=Fr.getBuffered(e),s=(r.length?r.start(0):0)-i;s>0&&(s<this.config.maxBufferHole||s<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+s+" to match buffer start"),i+=s,this.startPosition=i),this.log("seek to target start position "+i+" from current time "+t),e.currentTime=i}}},i._getAudioCodec=function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t},i._loadBitrateTestFrag=function(e,t){var i=this;e.bitrateTest=!0,this._doFragLoad(e,t).then((function(r){var s=i.hls;if(r&&!i.fragContextChanged(e)){t.fragmentError=0,i.state=ls.IDLE,i.startFragRequested=!1,i.bitrateTest=!1;var a=e.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),s.trigger(k.FRAG_LOADED,r),e.bitrateTest=!1}}))},i._handleTransmuxComplete=function(e){var t,i="main",r=this.hls,s=e.remuxResult,a=e.chunkMeta,n=this.getCurrentContext(a);if(n){var o=n.frag,l=n.part,d=n.level,h=s.video,c=s.text,u=s.id3,p=s.initSegment,f=d.details,y=this.altAudio?void 0:s.audio;if(this.fragContextChanged(o))this.fragmentTracker.removeFragment(o);else{if(this.state=ls.PARSING,p){if(null!=p&&p.tracks){var m=o.initSegment||o;this._bufferInitSegment(d,p.tracks,m,a),r.trigger(k.FRAG_PARSING_INIT_SEGMENT,{frag:m,id:i,tracks:p.tracks})}var g=p.initPTS,A=p.timescale;E(g)&&(this.initPTS[o.cc]={baseTime:g,timescale:A},r.trigger(k.INIT_PTS_FOUND,{frag:o,id:i,initPTS:g,timescale:A}))}if(h&&f&&"initSegment"!==o.sn){var v=f.fragments[o.sn-1-f.startSN],b=o.sn===f.startSN,_=!v||o.cc>v.cc;if(!1!==s.independent){var w=h.startPTS,S=h.endPTS,T=h.startDTS,C=h.endDTS;if(l)l.elementaryStreams[h.type]={startPTS:w,endPTS:S,startDTS:T,endDTS:C};else if(h.firstKeyFrame&&h.independent&&1===a.id&&!_&&(this.couldBacktrack=!0),h.dropped&&h.independent){var D=this.getMainFwdBufferInfo(),R=(D?D.end:this.getLoadPosition())+this.config.maxBufferHole,x=h.firstKeyFramePTS?h.firstKeyFramePTS:w;if(!b&&R<x-this.config.maxBufferHole&&!_)return void this.backtrack(o);_&&(o.gap=!0),o.setElementaryStreamInfo(h.type,o.start,S,o.start,C,!0)}else b&&w>$l&&(o.gap=!0);o.setElementaryStreamInfo(h.type,w,S,T,C),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(h,o,l,a,b||_)}else{if(!b&&!_)return void this.backtrack(o);o.gap=!0}}if(y){var L=y.startPTS,I=y.endPTS,P=y.startDTS,B=y.endDTS;l&&(l.elementaryStreams[$.AUDIO]={startPTS:L,endPTS:I,startDTS:P,endDTS:B}),o.setElementaryStreamInfo($.AUDIO,L,I,P,B),this.bufferFragmentData(y,o,l,a)}if(f&&null!=u&&null!=(t=u.samples)&&t.length){var M={id:i,frag:o,details:f,samples:u.samples};r.trigger(k.FRAG_PARSING_METADATA,M)}if(f&&c){var U={id:i,frag:o,details:f,samples:c.samples};r.trigger(k.FRAG_PARSING_USERDATA,U)}}}else this.resetWhenMissingContext(a)},i._bufferInitSegment=function(e,t,i,r){var s=this;if(this.state===ls.PARSING){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;var a=t.audio,n=t.video,o=t.audiovideo;if(a){var l=e.audioCodec,d=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(l&&(l=-1!==l.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),1!==a.metadata.channelCount&&-1===d.indexOf("firefox")&&(l="mp4a.40.5")),l&&-1!==l.indexOf("mp4a.40.5")&&-1!==d.indexOf("android")&&"audio/mpeg"!==a.container&&(l="mp4a.40.2",this.log("Android: force audio codec to "+l)),e.audioCodec&&e.audioCodec!==l&&this.log('Swapping manifest audio codec "'+e.audioCodec+'" for "'+l+'"'),a.levelCodec=l,a.id="main",this.log("Init audio buffer, container:"+a.container+", codecs[selected/level/parsed]=["+(l||"")+"/"+(e.audioCodec||"")+"/"+a.codec+"]")}n&&(n.levelCodec=e.videoCodec,n.id="main",this.log("Init video buffer, container:"+n.container+", codecs[level/parsed]=["+(e.videoCodec||"")+"/"+n.codec+"]")),o&&this.log("Init audiovideo buffer, container:"+o.container+", codecs[level/parsed]=["+e.codecs+"/"+o.codec+"]"),this.hls.trigger(k.BUFFER_CODECS,t),Object.keys(t).forEach((function(e){var a=t[e].initSegment;null!=a&&a.byteLength&&s.hls.trigger(k.BUFFER_APPENDING,{type:e,data:a,frag:i,part:null,chunkMeta:r,parent:i.type})})),this.tickImmediate()}},i.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,Nt.MAIN)},i.backtrack=function(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=ls.IDLE},i.checkFragmentChanged=function(){var e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){var i=e.currentTime;if(Fr.isBuffered(e,i)?t=this.getAppendedFrag(i):Fr.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;var r=this.fragPlaying,s=t.level;r&&t.sn===r.sn&&r.level===s||(this.fragPlaying=t,this.hls.trigger(k.FRAG_CHANGED,{frag:t}),r&&r.level===s||this.hls.trigger(k.LEVEL_SWITCHED,{level:s}))}}},d(t,[{key:"maxBufferLength",get:function(){var e=this.levels,t=this.level,i=null==e?void 0:e[t];return i?this.getMaxBufferLength(i.maxBitrate):this.config.maxBufferLength}},{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}},{key:"currentProgramDateTime",get:function(){var e=this.media;if(e){var t=e.currentTime,i=this.currentFrag;if(i&&E(t)&&E(i.programDateTime)){var r=i.programDateTime+1e3*(t-i.start);return new Date(r)}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])}(ds),Xl=function(){function e(t){void 0===t&&(t={}),this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Na,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0;var i=this.logger=N(t.debug||!1,"Hls instance"),r=this.config=Bl(e.DefaultConfig,t,i);this.userConfig=t,r.progressive&&Ul(r,i);var s=r.abrController,a=r.bufferController,n=r.capLevelController,o=r.errorController,l=r.fpsController,d=new o(this),h=this.abrController=new s(this),c=new Pr(this),u=this.bufferController=new a(this,c),p=this.capLevelController=new n(this),f=new l(this),y=new Wt(this),m=new Ti(this),g=r.contentSteeringController,A=g?new g(this):null,v=this.levelController=new Fl(this,A),b=new Nl(this.config),_=this.streamController=new Ql(this,c,b);p.setStreamController(_),f.setStreamController(_);var w=[y,v,_];A&&w.splice(1,0,A),this.networkControllers=w;var E=[h,u,p,f,m,c];this.audioTrackController=this.createController(r.audioTrackController,w);var S=r.audioStreamController;S&&w.push(new S(this,c,b)),this.subtitleTrackController=this.createController(r.subtitleTrackController,w);var T=r.subtitleStreamController;T&&w.push(new T(this,c,b)),this.createController(r.timelineController,E),b.emeController=this.emeController=this.createController(r.emeController,E),this.cmcdController=this.createController(r.cmcdController,E),this.latencyController=this.createController(ki,E),this.coreComponents=E,w.push(d);var C=d.onErrorOut;"function"==typeof C&&this.on(k.ERROR,C,d)}e.isMSESupported=function(){return zl()},e.isSupported=function(){return Wl()},e.getMediaSource=function(){return dt()};var t=e.prototype;return t.createController=function(e,t){if(e){var i=new e(this);return t&&t.push(i),i}return null},t.on=function(e,t,i){void 0===i&&(i=this),this._emitter.on(e,t,i)},t.once=function(e,t,i){void 0===i&&(i=this),this._emitter.once(e,t,i)},t.removeAllListeners=function(e){this._emitter.removeAllListeners(e)},t.off=function(e,t,i,r){void 0===i&&(i=this),this._emitter.off(e,t,i,r)},t.listeners=function(e){return this._emitter.listeners(e)},t.emit=function(e,t,i){return this._emitter.emit(e,t,i)},t.trigger=function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),!this.triggeringException){this.triggeringException=!0;var i=e===k.ERROR;this.trigger(k.ERROR,{type:C.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:i,event:e,error:t}),this.triggeringException=!1}}return!1},t.listenerCount=function(e){return this._emitter.listenerCount(e)},t.destroy=function(){this.logger.log("destroy"),this.trigger(k.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((function(e){return e.destroy()})),this.networkControllers.length=0,this.coreComponents.forEach((function(e){return e.destroy()})),this.coreComponents.length=0;var e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null},t.attachMedia=function(e){this.logger.log("attachMedia"),this._media=e,this.trigger(k.MEDIA_ATTACHING,{media:e})},t.detachMedia=function(){this.logger.log("detachMedia"),this.trigger(k.MEDIA_DETACHING,void 0),this._media=null},t.loadSource=function(e){this.stopLoad();var t=this.media,i=this.url,r=this.url=w.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log("loadSource:"+r),t&&i&&(i!==r||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(k.MANIFEST_LOADING,{url:e})},t.startLoad=function(e){void 0===e&&(e=-1),this.logger.log("startLoad("+e+")"),this.networkControllers.forEach((function(t){t.startLoad(e)}))},t.stopLoad=function(){this.logger.log("stopLoad"),this.networkControllers.forEach((function(e){e.stopLoad()}))},t.resumeBuffering=function(){this.networkControllers.forEach((function(e){e.resumeBuffering&&e.resumeBuffering()}))},t.pauseBuffering=function(){this.networkControllers.forEach((function(e){e.pauseBuffering&&e.pauseBuffering()}))},t.swapAudioCodec=function(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},t.recoverMediaError=function(){this.logger.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)},t.removeLevel=function(e){this.levelController.removeLevel(e)},t.setAudioOption=function(e){var t;return null==(t=this.audioTrackController)?void 0:t.setAudioOption(e)},t.setSubtitleOption=function(e){var t;return null==(t=this.subtitleTrackController)||t.setSubtitleOption(e),null},d(e,[{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){this.logger.log("set currentLevel:"+e),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){this.logger.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){this.logger.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){this.logger.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){var e=this.levelController.startLevel;return-1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e},set:function(e){this.logger.log("set startLevel:"+e),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(this.logger.log("set autoLevelCapping:"+e),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN},set:function(e){this.abrController.resetEstimator(e)}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){Di(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var i=e.length,r=0;r<i;r++)if(e[r].maxBitrate>=t)return r;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,i=this.autoLevelCapping,r=this.maxHdcpLevel;if(e=-1===i&&null!=t&&t.length?t.length-1:i,r)for(var s=e;s--;){var a=t[s].attrs["HDCP-LEVEL"];if(a&&a<=r)return s}return e}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(e){this.abrController.nextAutoLevel=e}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"maxBufferLength",get:function(){return this.streamController.maxBufferLength}},{key:"allAudioTracks",get:function(){var e=this.audioTrackController;return e?e.allAudioTracks:[]}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"allSubtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){}},{key:"Events",get:function(){return k}},{key:"ErrorTypes",get:function(){return C}},{key:"ErrorDetails",get:function(){return D}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:Il},set:function(t){e.defaultConfig=t}}])}();return Xl.defaultConfig=void 0,Xl}()}(!1)})),Bd=(Id=Pd)&&Id.__esModule&&Object.prototype.hasOwnProperty.call(Id,"default")?Id.default:Id;class Md extends t{constructor(e){super(),this.player=e,this.TAG_NAME="HlsDecoder",e._opt,this.canVideoPlay=!1,this.$videoElement=null,this.canvasRenderInterval=null,this.bandwidthEstimateInterval=null,this.fpsInterval=null,this.hlsFps=0,this.hlsPrevFrams=0,this.isInitInfo=!1,this.eventsDestroy=[],this.supportVideoFrameCallbackHandle=null,this.player.isHlsCanVideoPlay()?(this.$videoElement=this.player.video.$videoElement,this.canVideoPlay=!0):Bd.isSupported()?(this.$videoElement=this.player.video.$videoElement,this.hls=new Bd({}),this._initHls(),this._bindEvents()):this.player.debug.error(this.TAG_NAME,"init hls error ,not support "),this.player.debug.log(this.TAG_NAME,"init")}destroy(){return new Promise(((e,t)=>{this.supportVideoFrameCallbackHandle&&this.$videoElement&&(this.$videoElement.cancelVideoFrameCallback(this.supportVideoFrameCallbackHandle),this.supportVideoFrameCallbackHandle=null),this.hls&&(this.hls.destroy(),this.hls=null),this.eventsDestroy.length&&(this.eventsDestroy.forEach((e=>e())),this.eventsDestroy=[]),this.isInitInfo=!1,this._stopCanvasRender(),this._stopBandwidthEstimateInterval(),this._stopFpsInterval(),this.$videoElement=null,this.hlsFps=0,this.player.debug.log(this.TAG_NAME,"destroy"),setTimeout((()=>{e()}),0)}))}checkHlsBufferedDelay(){const e=this.$videoElement;let t=0;const i=e.buffered,r=i.length?i.end(i.length-1):0;return t=r-e.currentTime,t<0&&(this.player.debug.warn(this.TAG_NAME,`checkHlsBufferedDelay ${t} < 0, and buffered is ${r} ,currentTime is ${e.currentTime} , try to seek ${e.currentTime} to ${r}`),e.currentTime=r,t=0),t}getFps(){return this.hlsFps}_startCanvasRender(){Pa()?this.supportVideoFrameCallbackHandle=this.$videoElement.requestVideoFrameCallback(this.videoFrameCallback.bind(this)):(this._stopCanvasRender(),this.canvasRenderInterval=setInterval((()=>{this.player.video.render({$video:this.$videoElement,ts:parseInt(1e3*this.$videoElement.currentTime,10)||0})}),40))}_stopCanvasRender(){this.canvasRenderInterval&&(clearInterval(this.canvasRenderInterval),this.canvasRenderInterval=null)}videoFrameCallback(e,t={}){if(this.player.isDestroyedOrClosed())return void this.player.debug.log(this.TAG_NAME,"videoFrameCallback() player is destroyed");const i=parseInt(1e3*Math.max(t.mediaTime,this.$videoElement.currentTime),10)||0;this.player.video.render({$video:this.$videoElement,ts:i}),this.player.handleRender(),this.player.updateStats({dts:i}),this.supportVideoFrameCallbackHandle=this.$videoElement.requestVideoFrameCallback(this.videoFrameCallback.bind(this))}_startBandwidthEstimateInterval(){this._stopBandwidthEstimateInterval(),this.bandwidthEstimateInterval=setInterval((()=>{let e=0;this.hls.bandwidthEstimate&&(e=this.hls.bandwidthEstimate),this.player.emit(st.kBps,(e/1024/8/10).toFixed(2))}),1e3)}_stopBandwidthEstimateInterval(){this.bandwidthEstimateInterval&&(clearInterval(this.bandwidthEstimateInterval),this.bandwidthEstimateInterval=null)}_startFpsInterval(){this._stopCanvasRender(),this.fpsInterval=setInterval((()=>{if(this.$videoElement)if(ha(this.$videoElement.getVideoPlaybackQuality)){const e=this.$videoElement.getVideoPlaybackQuality();this.hlsFps=e.totalVideoFrames-this.hlsPrevFrams,this.hlsPrevFrams=e.totalVideoFrames}else{const e=this.$videoElement.webkitDecodedFrameCount||0;this.hlsFps=e-this.hlsPrevFrams,this.hlsPrevFrams=e}}),1e3)}_stopFpsInterval(){this.fpsInterval&&(clearInterval(this.fpsInterval),this.fpsInterval=null)}_initHls(){this.player._opt.useCanvasRender&&(this.$videoElement=document.createElement("video"),this.$videoElement.muted=!0,Is()&&(this.$videoElement.style.position="absolute"),this.initVideoEvents()),this.hls.attachMedia(this.$videoElement)}_bindEvents(){const e=this.player,{proxy:t}=this.player.events;this.hls;const i=this.$videoElement,r=Pa(),s=t(i,Ti,(t=>{if(this.hls){const i=parseInt(t.timeStamp,10);this.player._opt.useCanvasRender&&ka(r)&&e.updateStats({ts:i,dts:i})}}));this.eventsDestroy.push(s),this._startBandwidthEstimateInterval(),this._startFpsInterval(),this.hls.on(Bd.Events.ERROR,((t,i)=>{if(i.fatal)switch(i.type){case Bd.ErrorTypes.NETWORK_ERROR:this.player.debug.warn(this.TAG_NAME,"fatal network error encountered, try to recover"),this.hls.startLoad();break;case Bd.ErrorTypes.MEDIA_ERROR:this.player.debug.warn(this.TAG_NAME,"fatal media error encountered, try to recover"),this.hls.recoverMediaError()}else if("mediaError"===i.type){if("Unsupported HEVC stream type found 0x24"!==i.reason)return;e.resetPlayerH265()}})),this.hls.on(Bd.Events.MEDIA_ATTACHING,(()=>{})),this.hls.on(Bd.Events.MEDIA_ATTACHED,(()=>{})),this.hls.on(Bd.Events.MEDIA_DETACHING,(()=>{})),this.hls.on(Bd.Events.MEDIA_DETACHED,(()=>{})),this.hls.on(Bd.Events.BUFFER_RESET,(()=>{})),this.hls.on(Bd.Events.BUFFER_CODECS,(()=>{})),this.hls.on(Bd.Events.BUFFER_CREATED,(()=>{})),this.hls.on(Bd.Events.BUFFER_APPENDING,((e,t)=>{})),this.hls.on(Bd.Events.BUFFER_APPENDED,(()=>{})),this.hls.on(Bd.Events.BUFFER_EOS,(()=>{})),this.hls.on(Bd.Events.BUFFER_FLUSHING,(()=>{})),this.hls.on(Bd.Events.BUFFER_FLUSHED,(()=>{})),this.hls.on(Bd.Events.MANIFEST_LOADING,(()=>{})),this.hls.on(Bd.Events.MANIFEST_LOADED,((e,t)=>{})),this.hls.on(Bd.Events.MANIFEST_PARSED,(t=>{e._times.demuxStart||(e._times.demuxStart=vs())})),this.hls.on(Bd.Events.LEVEL_LOADING,(()=>{})),this.hls.on(Bd.Events.LEVEL_LOADED,((e,t)=>{})),this.hls.on(Bd.Events.FRAG_LOADING,(e=>{})),this.hls.on(Bd.Events.FRAG_LOADED,((t,i)=>{e._times.decodeStart||(e._times.decodeStart=vs())})),this.hls.on(Bd.Events.BUFFER_APPENDING,(()=>{e._times.videoStart||(e._times.videoStart=vs(),e.handlePlayToRenderTimes())})),this.hls.on(Bd.Events.FRAG_DECRYPTED,(()=>{})),this.hls.on(Bd.Events.KEY_LOADING,(()=>{})),this.hls.on(Bd.Events.KEY_LOADING,(()=>{})),this.hls.on(Bd.Events.FPS_DROP,(e=>{})),this.hls.on(Bd.Events.FPS_DROP_LEVEL_CAPPING,(e=>{})),this.hls.on(Bd.Events.FRAG_PARSING_INIT_SEGMENT,((e,t)=>{const i=!!(t&&t.tracks&&t.tracks.audio),r=!!(t&&t.tracks&&t.tracks.video);if(i&&t.tracks.audio){let e=t.tracks.audio;const i=e.metadata&&e.metadata.channelCount?e.metadata.channelCount:0,r=e.codec;this.player.audio&&this.player.audio.updateAudioInfo({encType:r,channels:i,sampleRate:44100})}if(r&&t.tracks.video){let e=t.tracks.video;const i={encTypeCode:-1!==e.codec.indexOf("avc")?gt:At};e.metadata&&(i.width=e.metadata.width,i.height=e.metadata.height),this.player.video&&this.player.video.updateVideoInfo(i)}}))}initVideoPlay(e){this.player._opt.useCanvasRender&&(this.$videoElement=document.createElement("video"),this.initVideoEvents()),this.$videoElement.autoplay=!0,this.$videoElement.muted=!0,this.$videoElement.src=e}_initRenderSize(){this.isInitInfo||(this.player.video.updateVideoInfo({width:this.$videoElement.videoWidth,height:this.$videoElement.videoHeight}),this.player.video.initCanvasViewSize(),this.isInitInfo=!0)}initVideoEvents(){const{proxy:e}=this.player.events,t=e(this.$videoElement,Ei,(()=>{this.player.debug.log(this.TAG_NAME,"video canplay"),this.$videoElement.play().then((()=>{this.player.debug.log(this.TAG_NAME,"video play"),this._startCanvasRender(),this._initRenderSize()})).catch((e=>{this.player.debug.warn(this.TAG_NAME,"video play error ",e)}))})),i=e(this.$videoElement,Si,(()=>{this.player.debug.log(this.TAG_NAME,"video waiting")})),r=e(this.$videoElement,Ti,(e=>{const t=parseInt(e.timeStamp,10);this.player.handleRender(),this.player.updateStats({ts:t}),this.$videoElement.paused&&(this.player.debug.warn(this.TAG_NAME,"video is paused and next try to replay"),this.$videoElement.play().then((()=>{this.player.debug.log(this.TAG_NAME,"video is paused and replay success")})).catch((e=>{this.player.debug.warn(this.TAG_NAME,"video is paused and replay error ",e)})))})),s=e(this.$videoElement,ki,(()=>{this.player.debug.log(this.TAG_NAME,"video playback Rate change",this.$videoElement&&this.$videoElement.playbackRate)}));this.eventsDestroy.push(t,i,r,s)}loadSource(e){return new Promise(((t,i)=>{this.canVideoPlay?(this.initVideoPlay(e),t()):this.hls.on(Bd.Events.MEDIA_ATTACHED,(()=>{this.hls.loadSource(e),t()}))}))}}const Ud=2097152,Fd="fetch",Od="xhr",Nd="arraybuffer",Gd="text",zd="json",Wd="real_time_speed",Vd=Object.prototype.toString;function Hd(e){if("[object Object]"!==Vd.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function $d(e){if(!e||null===e[0]||void 0===e[0]||0===e[0]&&(null===e[1]||void 0===e[1]))return;let t="bytes="+e[0]+"-";return e[1]&&(t+=e[1]),t}function jd(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Kd(e,t){if(!e)return;if(!t)return e;let i;const r=Object.keys(t).map((e=>{if(i=t[e],null!=i)return Array.isArray(i)?e+="[]":i=[i],i.map((t=>{var i;return i=t,"[object Date]"===Vd.call(i)?t=t.toISOString():function(e){return null!==e&&"object"==typeof e}(t)&&(t=JSON.stringify(t)),`${jd(e)}=${jd(t)}`})).join("&")})).filter(Boolean).join("&");if(r){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e}function qd(e,t,i,r,s,a,n,o,l,d,h){s=null!=s?parseFloat(s):null,r=parseInt(r||"0",10),Number.isNaN(r)&&(r=0);return{data:e,done:t,option:{range:l,vid:d,index:o,contentLength:r,age:s,startTime:a,firstByteTime:n,endTime:Date.now(),priOptions:h},response:i}}function Yd(e,t){return Math.round(8*e*1e3/t/1024)}class Qd extends Error{retryCount=0;isTimeout=!1;loaderType=Fd;startTime=0;endTime=0;options={};constructor(e,t,i,r){super(r),this.url=e,this.request=t,this.response=i}}class Xd extends t{_abortController=null;_timeoutTimer=null;_reader=null;_response=null;_aborted=!1;_index=-1;_range=null;_receivedLength=0;_running=!1;_logger=null;_vid="";_onProcessMinLen=0;_onCancel=null;_priOptions=null;TAG_NAME="FetchLoader";constructor(e){super(),this.player=e}load({url:e,vid:t,timeout:i,responseType:r,onProgress:s,index:a,onTimeout:n,onCancel:o,range:l,transformResponse:d,request:h,params:c,logger:u,method:p,headers:f,body:y,mode:m,credentials:g,cache:A,redirect:v,referrer:b,referrerPolicy:_,onProcessMinLen:w,priOptions:E}){this._aborted=!1,this._onProcessMinLen=w,this._onCancel=o,this._abortController="undefined"!=typeof AbortController&&new AbortController,this._running=!0,this._index=a,this._range=l||[0,0],this._vid=t||e,this._priOptions=E||{};const S={method:p,headers:f,body:y,mode:m,credentials:g,cache:A,redirect:v,referrer:b,referrerPolicy:_,signal:this._abortController?.signal};let T=!1;clearTimeout(this._timeoutTimer),e=Kd(e,c);const k=$d(l);k&&(f=h?h.headers:S.headers=S.headers||(Headers?new Headers:{}),Headers&&f instanceof Headers?f.append("Range",k):f.Range=k),i&&(this._timeoutTimer=setTimeout((()=>{if(T=!0,this.cancel(),n){const t=new Qd(e,S,null,"timeout");t.isTimeout=!0,n(t,{index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions})}}),i));const C=Date.now();return(Ks(a)||Ks(l))&&this.player.debug.log(this.TAG_NAME,"[fetch load start], index,",a,",range,",l),new Promise(((t,i)=>{fetch(h||e,h?void 0:S).then((async n=>{if(clearTimeout(this._timeoutTimer),this._response=n,this._aborted||!this._running)return;if(d&&(n=d(n,e)||n),!n.ok)throw new Qd(e,S,n,"bad network response");const o=Date.now();let h;if(r===Gd)h=await n.text(),this._running=!1;else if(r===zd)h=await n.json(),this._running=!1;else{if(s)return this.resolve=t,this.reject=i,void this._loadChunk(n,s,C,o);{h=await n.arrayBuffer(),h=new Uint8Array(h),this._running=!1;const e=Date.now()-C,t=Yd(h.byteLength,e);this.emit(Wd,{speed:t,len:h.byteLength,time:e,vid:this._vid,index:this._index,range:this._range,priOptions:this._priOptions})}}(Ks(a)||Ks(l))&&this.player.debug.log(this.TAG_NAME,"[fetch load end], index,",a,",range,",l),t(qd(h,!0,n,n.headers.get("Content-Length"),n.headers.get("age"),C,o,a,l,this._vid,this._priOptions))})).catch((t=>{clearTimeout(this._timeoutTimer),this._running=!1,this._aborted&&!T||((t=t instanceof Qd?t:new Qd(e,S,null,t?.message)).startTime=C,t.endTime=Date.now(),t.isTimeout=T,t.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},i(t))}))}))}async cancel(){if(!this._aborted){if(this._aborted=!0,this._running=!1,this._response){try{this._reader&&await this._reader.cancel()}catch(e){}this._response=this._reader=null}if(this._abortController){try{this._abortController.abort()}catch(e){}this._abortController=null}this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions})}}_loadChunk(e,t,i,r){if(!e.body||!e.body.getReader){this._running=!1;const t=new Qd(e.url,"",e,"onProgress of bad response.body.getReader");return t.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},void this.reject(t)}this._onProcessMinLen>0&&(this._cache=new Uint8Array(Ud),this._writeIdx=0);const s=this._reader=e.body.getReader();let a,n,o;const l=async()=>{n=Date.now();try{a=await s.read(),o=Date.now()}catch(e){return o=Date.now(),void(this._aborted||(this._running=!1,e.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this.reject(e)))}const d=this._range?.length>0?this._range[0]:0,h=d+this._receivedLength;if(this._aborted)return this._running=!1,void t(void 0,!1,{range:[h,h],vid:this._vid,index:this._index,startTime:n,endTime:o,st:i,firstByteTime:r,priOptions:this._priOptions},e);const c=a.value?a.value.byteLength:0;let u;if(this._receivedLength+=c,this.player.debug.log(this.TAG_NAME,"【fetchLoader,onProgress call】,task,",this._range,", start,",h,", end,",d+this._receivedLength,", done,",a.done),this._onProcessMinLen>0){if(this._writeIdx+c>=this._onProcessMinLen||a.done)u=new Uint8Array(this._writeIdx+c),u.set(this._cache.slice(0,this._writeIdx),0),c>0&&u.set(a.value,this._writeIdx),this._writeIdx=0,this.player.debug.log(this.TAG_NAME,"【fetchLoader,onProgress enough】,done,",a.done,",len,",u.byteLength,", writeIdx,",this._writeIdx);else if(c>0&&this._writeIdx+c<Ud)this._cache.set(a.value,this._writeIdx),this._writeIdx+=c,this.player.debug.log(this.TAG_NAME,"【fetchLoader,onProgress cache】,len,",c,", writeIdx,",this._writeIdx);else if(c>0){const e=new Uint8Array(this._writeIdx+c+2048);this.player.debug.log(this.TAG_NAME,"【fetchLoader,onProgress extra start】,size,",this._writeIdx+c+2048,", datalen,",c,", writeIdx,",this._writeIdx),e.set(this._cache.slice(0,this._writeIdx),0),c>0&&e.set(a.value,this._writeIdx),this._writeIdx+=c,delete this._cache,this._cache=e,this.player.debug.log(this.TAG_NAME,"【fetchLoader,onProgress extra end】,len,",c,", writeIdx,",this._writeIdx)}}else u=a.value;if((u&&u.byteLength>0||a.done)&&t(u,a.done,{range:[this._range[0]+this._receivedLength-(u?u.byteLength:0),this._range[0]+this._receivedLength],vid:this._vid,index:this._index,startTime:n,endTime:o,st:i,firstByteTime:r,priOptions:this._priOptions},e),a.done){const t=Date.now()-i,s=Yd(this._receivedLength,t);this.emit(Wd,{speed:s,len:this._receivedLength,time:t,vid:this._vid,index:this._index,range:this._range,priOptions:this._priOptions}),this._running=!1,this.player.debug.log(this.TAG_NAME,"[fetchLoader onProgress end],task,",this._range,",done,",a.done),this.resolve(qd(a,!0,e,e.headers.get("Content-Length"),e.headers.get("age"),i,r,this._index,this._range,this._vid,this._priOptions))}else l()};l()}get receiveLen(){return this._receivedLength}get running(){return this._running}set running(e){this._running=e}static isSupported(){return!("undefined"==typeof fetch)}}class Jd{TAG_NAME="Task";constructor(e,t,i){this.promise=function(){let e,t;const i=new Promise(((i,r)=>{e=i,t=r}));return i.used=!1,i.resolve=(...t)=>(i.used=!0,e(...t)),i.reject=(...e)=>(i.used=!0,t(...e)),i}(),this.alive=!!t.onProgress,this._loaderType=e,this.player=i,this._loader=e===Fd&&window.fetch?new Xd(i):new Zd(i),this._config=t,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=t.retryCheckFunc}exec(){const{retry:e,retryDelay:t,onRetryError:i,transformError:r,...s}=this._config,a=async()=>{try{const e=await this._loader.load(s);this.promise.resolve(e)}catch(n){if(this._loader.running=!1,this.player.debug.log(this.TAG_NAME,"[task request catch err]",n),this._canceled)return;n.loaderType=this._loaderType,n.retryCount=this._retryCount;let o=n;r&&(o=r(o)||o),i&&this._retryCount>0&&i(o,this._retryCount,{index:s.index,vid:s.vid,range:s.range,priOptions:s.priOptions}),this._retryCount++;let l=!0;if(this._retryCheckFunc&&(l=this._retryCheckFunc(n)),l&&this._retryCount<=e)return clearTimeout(this._retryTimer),this.player.debug.log(this.TAG_NAME,"[task request setTimeout],retry",this._retryCount,",retry range,",s.range),void(this._retryTimer=setTimeout(a,t));this.promise.reject(o)}};return a(),this.promise}async cancel(){return clearTimeout(this._retryTimer),this._canceled=!0,this._loader.running=!1,this._loader.cancel()}get running(){return this._loader&&this._loader.running}get loader(){return this._loader}}class Zd extends t{_xhr=null;_aborted=!1;_timeoutTimer=null;_range=null;_receivedLength=0;_url=null;_onProgress=null;_index=-1;_headers=null;_currentChunkSizeKB=384;_timeout=null;_xhr=null;_withCredentials=null;_startTime=-1;_loadCompleteResolve=null;_loadCompleteReject=null;_runing=!1;_logger=!1;_vid="";_responseType;_credentials;_method;_transformResponse;_firstRtt;_onCancel=null;_priOptions=null;TAG_NAME="XhrLoader";constructor(e){super(),this.player=e}load(e){clearTimeout(this._timeoutTimer),this._range=e.range,this._onProgress=e.onProgress,this._index=e.index,this._headers=e.headers,this._withCredentials="include"===e.credentials||"same-origin"===e.credentials,this._body=e.body||null,e.method&&(this._method=e.method),this._timeout=e.timeout||null,this._runing=!0,this._vid=e.vid||e.url,this._responseType=e.responseType,this._firstRtt=-1,this._onTimeout=e.onTimeout,this._onCancel=e.onCancel,this._request=e.request,this._priOptions=e.priOptions||{},this.player.debug.log(this.TAG_NAME,"【xhrLoader task】, range",this._range),this._url=Kd(e.url,e.params);const t=Date.now();return new Promise(((e,t)=>{this._loadCompleteResolve=e,this._loadCompleteReject=t,this._startLoad()})).catch((e=>{if(clearTimeout(this._timeoutTimer),this._runing=!1,!this._aborted)throw(e=e instanceof Qd?e:new Qd(this._url,this._request)).startTime=t,e.endTime=Date.now(),e.options={index:this._index,vid:this._vid,priOptions:this._priOptions},e}))}_startLoad(){let e=null;if(this._responseType===Nd&&this._range&&this._range.length>1)if(this._onProgress){this._firstRtt=-1;const t=1024*this._currentChunkSizeKB,i=this._range[0]+this._receivedLength;let r=this._range[1];t<this._range[1]-i&&(r=i+t),e=[i,r],this.player.debug.log(this.TAG_NAME,"[xhr_loader->],tast :",this._range,", SubRange, ",e)}else e=this._range,this.player.debug.log(this.TAG_NAME,"[xhr_loader->],tast :",this._range,", allRange, ",e);this._internalOpen(e)}_internalOpen(e){try{this._startTime=Date.now();const t=this._xhr=new XMLHttpRequest;t.open(this._method||"GET",this._url,!0),t.responseType=this._responseType,this._timeout&&(t.timeout=this._timeout),t.withCredentials=this._withCredentials,t.onload=this._onLoad.bind(this),t.onreadystatechange=this._onReadyStatechange.bind(this),t.onerror=e=>{this._running=!1;const t=new Qd(this._url,this._request,e?.currentTarget?.response,"xhr.onerror.status:"+e?.currentTarget?.status+",statusText,"+e?.currentTarget?.statusText);t.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(t)},t.ontimeout=e=>{this.cancel();const t=new Qd(this._url,this._request,{status:408},"timeout");this._onTimeout&&(t.isTimeout=!0,this._onTimeout(t,{index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions})),t.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(t)};const i=this._headers||{},r=$d(e);r&&(i.Range=r),i&&Object.keys(i).forEach((e=>{t.setRequestHeader(e,i[e])})),this.player.debug.log(this.TAG_NAME,"[xhr.send->] tast,",this._range,",load sub range, ",e),t.send(this._body)}catch(t){t.options={index:this._index,range:e,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(t)}}_onReadyStatechange(e){2===e.target.readyState&&this._firstRtt<0&&(this._firstRtt=Date.now())}_onLoad(e){const t=e.target.status;if(t<200||t>299){const i=new Qd(this._url,null,{...e.target.response,status:t},"bad response,status:"+t);return i.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(i)}let i,r=null,s=!1;const a=this._range?.length>0?this._range[0]:0;if(this._responseType===Nd){const t=new Uint8Array(e.target.response);if(i=a+this._receivedLength,t&&t.byteLength>0){this._receivedLength+=t.byteLength;const e=Date.now()-this._startTime,r=Yd(this._receivedLength,e);this.emit(Wd,{speed:r,len:this._receivedLength,time:e,vid:this._vid,index:this._index,range:[i,a+this._receivedLength],priOptions:this._priOptions})}r=t,s=!(this._range?.length>1&&this._range[1]&&this._receivedLength<this._range[1]-this._range[0]),this.player.debug.log(this.TAG_NAME,"[xhr load done->], tast :",this._range,", start",i,"end ",a+this._receivedLength,",dataLen,",t?t.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",s)}else s=!0,r=e.target.response;let n={ok:t>=200&&t<300,status:t,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};this._transformResponse&&(n=this._transformResponse(n,this._url)||n),this._onProgress&&this._onProgress(r,s,{index:this._index,vid:this._vid,range:[i,a+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},n),s?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(qd(this._onProgress?null:r,s,n,n.headers["content-length"],n.headers.age,this._startTime,this._firstRtt,this._index,this._range,this._vid,this._priOptions))):this._startLoad()}cancel(){if(!this._aborted)return this._aborted=!0,this._runing=!1,super.removeAllListeners(),this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions}),this._xhr?this._xhr.abort():void 0}static isSupported(){return"undefined"!=typeof XMLHttpRequest}get receiveLen(){return this._receivedLength}get running(){return this._running}set running(e){this._running=e}_getHeaders(e){const t=e.getAllResponseHeaders().trim().split("\r\n"),i={};for(const e of t){const t=e.split(": ");i[t[0].toLowerCase()]=t.slice(1).join(": ")}return i}}class eh extends t{type=Fd;_queue=[];_alive=[];_currentTask=null;_config;constructor(e,t){super(),this.player=t,this._config=function(e){return{loaderType:Fd,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:Gd,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}}(e),this._config.loaderType!==Od&&Xd.isSupported()||(this.type=Od)}destroy(){this._queue=[],this._alive=[],this._currentTask=null}isFetch(){return this.type===Fd}static isFetchSupport(){return Xd.isSupported()}load(e,t={}){"string"!=typeof e&&e?t=e:t.url=e||t.url||this._config.url,(t=Object.assign({},this._config,t)).params&&(t.params=Object.assign({},t.params)),t.headers&&Hd(t.headers)&&(t.headers=Object.assign({},t.headers)),t.body&&Hd(t.body)&&(t.body=Object.assign({},t.body)),t.transformRequest&&(t=t.transformRequest(t)||t);const i=new Jd(this.type,t,this.player);return i.loader.on(Wd,(e=>{this.emit(Wd,e)})),this._queue.push(i),1!==this._queue.length||this._currentTask&&this._currentTask.running||this._processTask(),i.promise}async cancel(){const e=this._queue.map((e=>e.cancel())).concat(this._alive.map((e=>e.cancel())));this._currentTask&&e.push(this._currentTask.cancel()),this._queue=[],this._alive=[],await Promise.all(e),await function(e=0){return new Promise((t=>setTimeout(t,e)))}()}_processTask(){if(this._currentTask=this._queue.shift(),!this._currentTask)return;this._currentTask.alive&&this._alive.push(this._currentTask);const e=this._currentTask.exec().catch((e=>{}));e&&"function"==typeof e.finally&&e.finally((()=>{this._currentTask?.alive&&this._alive?.length>0&&(this._alive=this._alive.filter((e=>e&&e!==this._currentTask))),this._processTask()}))}}const th="network",ih="network_timeout",rh="other",sh="manifest",ah="hls",nh="demux";class oh extends Error{constructor(e,t,i,r,s){super(s||i?.message),this.errorType=e===ih?th:e,this.originError=i,this.ext=r,this.errorMessage=this.message}static create(e,t,i,r,s){return e instanceof oh?e:(e instanceof Error&&(i=e,e=""),e||(e=rh),new oh(e,t,i,r,s))}static network(e){return new oh(e?.isTimeout?ih:th,null,e instanceof Error?e:null,{url:e?.url,response:e?.response,httpCode:e?.response?.status})}}const lh=/^#(EXT[^:]*)(?::(.*))?$/,dh=/([^=]+)=(?:"([^"]*)"|([^",]*))(?:,|$)/g,hh=/^(?:[a-zA-Z0-9+\-.]+:)?\/\//,ch=/^((?:[a-zA-Z0-9+\-.]+:)?\/\/[^/?#]*)?([^?#]*\/)?/;function uh(e){const t=e.match(lh);if(t&&t[1])return[t[1].replace("EXT-X-",""),t[2]]}function ph(e){const t={};let i=dh.exec(e);for(;i;)t[i[1]]=i[2]||i[3],i=dh.exec(e);return t}function fh(e,t){if(!t||!e||hh.test(e))return e;const i=ch.exec(t);return i?"/"===e[0]?i[1]+e:i[1]+i[2]+e:e}const yh={audio:[/^mp4a/,/^vorbis$/,/^opus$/,/^flac$/,/^[ae]c-3$/],video:[/^avc/,/^hev/,/^hvc/,/^vp0?[89]/,/^av1$/],text:[/^vtt$/,/^wvtt/,/^stpp/]};function mh(e,t){const i=yh[e];if(i&&t&&t.length)for(let e=0;e<i.length;e++)for(let r=0;r<t.length;r++)if(i[e].test(t[r]))return t[r]}class gh{constructor(){this.version=0,this.streams=[],this.isMaster=!0}}const Ah="AUDIO",vh="SUBTITLE";class bh{id=0;url="";default=!1;autoSelect=!1;forced=!1;group="";name="";lang="";segments=[];endSN=0}class _h extends bh{mediaType=Ah;channels=0}class wh extends bh{mediaType=vh}class Eh{id=0;bitrate=0;width=0;height=0;name="";url="";audioCodec="";videoCodec="";textCodec="";audioGroup="";audioStreams=[];subtitleStreams=[];closedCaptionsStream=[]}class Sh{version=0;url="";type="";startCC=0;endCC=0;startSN=0;endSN=0;totalDuration=0;targetDuration=0;live=!0;segments=[]}class Th{sn=0;cc=0;url="";title="";start=0;duration=0;key=null;byteRange=null;isInitSegment=!1;initSegment=null;isLast=!1;hasAudio=!1;hasVideo=!1;get end(){return this.start+this.duration}setTrackExist(e,t){this.hasVideo=e,this.hasAudio=t}setByteRange(e,t){this.byteRange=[0];const i=e.split("@");1===i.length&&t&&t.byteRange?(this.byteRange[0]=t.byteRange[1]||0,this.byteRange[0]&&(this.byteRange[0]+=1)):this.byteRange[0]=parseInt(i[1]),this.byteRange[1]=this.byteRange[0]+parseInt(i[0])-1}}class kh{method="";url="";iv=null;keyFormat="";keyFormatVersions="";constructor(e){e instanceof kh&&(this.method=e.method,this.url=e.url,this.keyFormat=e.keyFormat,this.keyFormatVersions=e.keyFormatVersions,e.iv&&(this.iv=new Uint8Array(e.iv)))}clone(e){const t=new kh(this);return null!=e&&t.setIVFromSN(e),t}setIVFromSN(e){if(!this.iv&&"AES-128"===this.method&&"number"==typeof e&&this.url){this.iv=new Uint8Array(16);for(let t=12;t<16;t++)this.iv[t]=e>>8*(15-t)&255}}}class Ch{static parse(e="",t){if(!e.includes("#EXTM3U"))throw new Error("Invalid m3u8 file");const i=function(e){return e.split(/[\r\n]/).map((e=>e.trim())).filter(Boolean)}(e);return Ch.isMediaPlaylist(e)?function(e,t){const i=new Sh;i.url=t;let r,s=new Th,a=null,n=null,o=0,l=0,d=0,h=0,c=!1;for(;(r=e[h++])&&!c;){if("#"!==r[0]){s.sn=l,s.cc=d,s.url=fh(r,t),n&&(s.key=n.clone(l)),a&&(s.initSegment=a),i.segments.push(s),s=new Th,l++;continue}const e=uh(r);if(!e)continue;const[h,u]=e;switch(h){case"VERSION":i.version=parseInt(u);break;case"PLAYLIST-TYPE":i.type=u?.toUpperCase();break;case"TARGETDURATION":i.targetDuration=parseFloat(u);break;case"ENDLIST":{const e=i.segments[i.segments.length-1];e&&(e.isLast=!0),i.live=!1,c=!0}break;case"MEDIA-SEQUENCE":l=i.startSN=parseInt(u);break;case"DISCONTINUITY-SEQUENCE":d=i.startCC=parseInt(u);break;case"DISCONTINUITY":d++;break;case"BYTERANGE":s.setByteRange(u,i.segments[i.segments.length-1]);break;case"EXTINF":{const[e,t]=u.split(",");s.start=o,s.duration=parseFloat(e),o+=s.duration,s.title=t}break;case"KEY":{const e=ph(u);if("NONE"===e.METHOD){n=null;break}if("AES-128"!==e.METHOD)throw new Error(`encrypt ${e.METHOD}/${e.KEYFORMAT} is not supported`);if(n=new kh,n.method=e.METHOD,n.url=/^blob:/.test(e.URI)?e.URI:fh(e.URI,t),n.keyFormat=e.KEYFORMAT||"identity",n.keyFormatVersions=e.KEYFORMATVERSIONS,e.IV){let t=e.IV.slice(2);t=(1&t.length?"0":"")+t,n.iv=new Uint8Array(t.length/2);for(let e=0,i=t.length/2;e<i;e++)n.iv[e]=parseInt(t.slice(2*e,2*e+2),16)}}break;case"MAP":{const e=ph(u);s.url=fh(e.URI,t),e.BYTERANGE&&s.setByteRange(e.BYTERANGE),s.isInitSegment=!0,s.sn=0,n&&(s.key=n.clone(0)),a=s,s=new Th}}}const u=i.segments[i.segments.length-1];return u&&(i.endSN=u.sn),i.totalDuration=o,i.endCC=d,i}(i,t):function(e,t){const i=new gh;let r,s=0;const a=[],n=[];for(;r=e[s++];){const o=uh(r);if(!o)continue;const[l,d]=o;if("VERSION"===l)i.version=parseInt(d);else if("MEDIA"===l&&d){const e=ph(d);let i;switch(e.TYPE){case"AUDIO":i=new _h;break;case"SUBTITLES":i=new wh;break;default:i=new bh}i.url=fh(e.URI,t),i.default="YES"===e.DEFAULT,i.autoSelect="YES"===e.AUTOSELECT,i.group=e["GROUP-ID"],i.name=e.NAME,i.lang=e.LANGUAGE,e.CHANNELS&&(i.channels=Number(e.CHANNELS.split("/")[0]),Number.isNaN(i.channels)&&(i.channels=0)),"AUDIO"===e.TYPE&&e.URI&&a.push(i),"SUBTITLES"===e.TYPE&&n.push(i)}else if("STREAM-INF"===l&&d){const r=new Eh,a=ph(d);if(r.bitrate=parseInt(a["AVERAGE-BANDWIDTH"]||a.BANDWIDTH),r.name=a.NAME,r.url=fh(e[s++],t),a.RESOLUTION){const[e,t]=a.RESOLUTION.split("x");r.width=parseInt(e),r.height=parseInt(t)}if(a.CODECS){const e=a.CODECS.split(/[ ,]+/).filter(Boolean);r.videoCodec=mh("video",e),r.audioCodec=mh("audio",e),r.textCodec=mh("text",e)}r.audioGroup=a.AUDIO,r.subtitleGroup=a.SUBTITLES,i.streams.push(r)}}return i.streams.forEach(((e,t)=>{e.id=t})),a.length&&(a.forEach(((e,t)=>{e.id=t})),i.streams.forEach((e=>{e.audioGroup&&(e.audioStreams=a.filter((t=>t.group===e.audioGroup)))}))),n.length&&(n.forEach(((e,t)=>{e.id=t})),i.streams.forEach((e=>{e.subtitleGroup&&(e.subtitleStreams=n.filter((t=>t.group===e.subtitleGroup)))}))),i}(i,t)}static isMediaPlaylist(e){return e.includes("#EXTINF:")||e.includes("#EXT-X-TARGETDURATION:")}}class Dh{constructor(e){this.hls=e,this.player=e.player,this.TAG_NAME="HlsManifestLoader",this._timer=null;const{retryCount:t,retryDelay:i,loadTimeout:r,fetchOptions:s}=this.hls.config;this._loader=new eh({...s,responseType:"text",retry:t,retryDelay:i,timeout:r,onRetryError:this._onLoaderRetry},this.player),this._audioLoader=new eh({...s,responseType:"text",retry:t,retryDelay:i,timeout:r,onRetryError:this._onLoaderRetry},this.player),this._subtitleLoader=new eh({...s,responseType:"text",retry:t,retryDelay:i,timeout:r,onRetryError:this._onLoaderRetry},this.player)}async destroy(){await this.stopPoll(),this._audioLoader&&(this._audioLoader.destroy(),this._audioLoader=null),this._subtitleLoader&&(this._subtitleLoader.destroy(),this._subtitleLoader=null),this._loader&&(this._loader.destroy(),this._loader=null)}async load(e,t,i){this.player.debug.log(this.TAG_NAME,"load()",e,t,i);const r=[this._loader.load(e)];let s,a,n,o,l,d;t&&r.push(this._audioLoader.load(t)),i&&r.push(this._subtitleLoader.load(i));try{const[e,i,o]=await Promise.all(r);if(!e)return[];s=e.data,t?(a=i?.data,n=o?.data):n=i?.data}catch(e){throw oh.network(e)}try{if(o=Ch.parse(s,e),!1===o?.live&&o.segments&&!o.segments.length)throw new Error("empty segments list");a&&(l=Ch.parse(a,t)),n&&(d=Ch.parse(n,i))}catch(e){throw new oh(sh,ah,e)}return o&&(o.isMaster?this.hls.emit(cr,{playlist:o}):this.hls.emit(ur,{playlist:o})),[o,l,d]}poll(e,t,i,r,s,a){clearTimeout(this._timer),a=a||3e3;let n=this.hls.config.pollRetryCount;const o=async()=>{clearTimeout(this._timer);try{const s=await this.load(e,t,i);if(!s[0])return;n=this.hls.config.pollRetryCount,r(s[0],s[1],s[2])}catch(e){n--,n<=0&&s(e)}this._timer=setTimeout(o,a)};this._timer=setTimeout(o,a)}stopPoll(){return clearTimeout(this._timer),this.cancel()}cancel(){return Promise.all([this._loader.cancel(),this._audioLoader.cancel()])}_onLoaderRetry=(e,t)=>{this.hls.emit(gr,{error:oh.network(e),retryTime:t})}}class Rh{_chunkSpeeds=[];_speeds=[];addRecord(e,t){e&&t&&(this._speeds.push(8e3*e/t),this._speeds=this._speeds.slice(-3))}addChunkRecord(e,t){e&&t&&(this._chunkSpeeds.push(8e3*e/t),this._chunkSpeeds=this._chunkSpeeds.slice(-100))}getAvgSpeed(){return this._chunkSpeeds.length||this._speeds.length?this._speeds.length?this._speeds.reduce(((e,t)=>e+t))/this._speeds.length:this._chunkSpeeds.reduce(((e,t)=>e+t))/this._chunkSpeeds.length:0}getLatestSpeed(){return this._chunkSpeeds.length||this._speeds.length?this._speeds.length?this._speeds[this._speeds.length-1]:this._chunkSpeeds[this._chunkSpeeds.length-1]:0}reset(){this._chunkSpeeds=[],this._speeds=[]}}class xh{constructor(e){this.hls=e,this.player=e.player,this._bandwidthService=new Rh;const{retryCount:t,retryDelay:i,loadTimeout:r,fetchOptions:s}=this.hls.config;this._segmentLoader=new eh({...s,responseType:"arraybuffer",retry:t,retryDelay:i,timeout:r,onRetryError:this._onLoaderRetry},this.player),this._audioSegmentLoader=new eh({...s,responseType:"arraybuffer",retry:t,retryDelay:i,timeout:r,onRetryError:this._onLoaderRetry},this.player),this._keyLoader=new eh({...s,responseType:"arraybuffer",retry:t,retryDelay:i,timeout:r,onRetryError:this._onLoaderRetry},this.player)}destroy(){this.reset(),this._keyLoader&&(this._keyLoader.destroy(),this._keyLoader=null),this._audioSegmentLoader&&(this._audioSegmentLoader.destroy(),this._audioSegmentLoader=null),this._segmentLoader&&(this._segmentLoader.destroy(),this._segmentLoader=null)}speedInfo(){return{speed:this._bandwidthService.getLatestSpeed(),avgSpeed:this._bandwidthService.getAvgSpeed()}}resetBandwidth(){this._bandwidthService.reset()}load(e,t,i,r=i){const s=[];return e&&(s[0]=this.loadVideoSegment(e,i)),t&&(s[1]=this.loadAudioSegment(t,r)),Promise.all(s)}loadVideoSegment(e,t){return this._loadSegment(this._segmentLoader,e,t)}loadAudioSegment(e,t){return this._loadSegment(this._audioSegmentLoader,e,t)}async _loadSegment(e,t,i){let r,s,a,n,o;const l=[];if(this.hls.emit(Ar,{url:t.url}),l[0]=e.load(t.url),i&&t.initSegment){const i=t.initSegment.url;r=this._mapCache[i],r||(this.hls.emit(Ar,{url:i}),l[1]=e.load(i).then((e=>{if(e){Object.keys(this._mapCache)>30&&(this._mapCache={}),r=this._mapCache[i]=e.data,this._emitOnLoaded(e,i)}})));const s=t.initSegment.key?.url;s&&(o=t.initSegment.key.iv,n=this._keyCache[s],n||(this.hls.emit(Ar,{url:s}),l[2]=this._keyLoader.load(s).then((e=>{e&&(n=this._keyCache[s]=e.data,this._emitOnLoaded(e,s))}))))}const d=t.key?.url;d&&(a=t.key.iv,s=this._keyCache[d],s||(this.hls.emit(Ar,{url:d}),l[3]=this._keyLoader.load(d).then((e=>{e&&(s=this._keyCache[d]=e.data,this._emitOnLoaded(e,d))}))));const[h]=await Promise.all(l);if(!h)return;const c=h.data;return this._emitOnLoaded(h,t.url),{data:c,map:r,key:s,mapKey:n,keyIv:a,mapKeyIv:o}}reset(){this.error=null,this._mapCache={},this._keyCache={},this._bandwidthService.reset()}async cancel(){await Promise.all([this._keyLoader.cancel(),this._segmentLoader.cancel(),this._audioSegmentLoader.cancel()])}_emitOnLoaded=(e,t)=>{const{data:i,response:r,option:s}=e,{firstByteTime:a,startTime:n,endTime:o,contentLength:l}=s||{},d=o-n;this._bandwidthService.addRecord(l||i.byteLength,d),this.hls.emit(vr,{time:d,byteLength:l,url:t}),this.hls.emit(br,{url:t,elapsed:d||0}),this.hls.emit(mr,{url:t,responseUrl:r.url,elapsed:a-n}),this.hls.emit(_r,{headers:r.headers})};_onLoaderRetry=(e,t)=>{this.hls.emit(gr,{error:oh.network(e),retryTime:t})}}class Lh{constructor(e,t,i){this.live=void 0,this.id=0,this.bitrate=0,this.width=0,this.height=0,this.name="",this.url="",this.audioCodec="",this.videoCodec="",this.textCodec="",this.startCC=0,this.endCC=0,this.startSN=0,this.endSN=-1,this.totalDuration=0,this.targetDuration=0,this.snDiff=null,this.segments=[],this.audioStreams=[],this.subtitleStreams=[],this.closedCaptions=[],this.currentAudioStream=null,this.currentSubtitleStream=null,this.TAG_NAME="HlsStream",this.update(e,t,i)}get lastSegment(){return this.segments.length?this.segments[this.segments.length-1]:null}get segmentDuration(){return this.targetDuration||this.segments[0]?.duration||0}get liveEdge(){return this.endTime}get endTime(){return this.lastSegment?.end||0}get currentSubtitleEndSn(){return this.currentSubtitleStream?.endSN||0}clearOldSegment(e,t){return this._clearSegments(e,t)}getAudioSegment(e){if(!e||!this.currentAudioStream)return;const t=e.sn-this.snDiff;return this.currentAudioStream.segments.find((e=>e.sn===t))}update(e,t){this.url=e.url,Array.isArray(e.segments)?(null!==this.live&&void 0!==this.live||(this.live=e.live),this._updateSegments(e,this),this.startCC=e.startCC,this.endCC=e.endCC,this.startSN=e.startSN,this.endSN=e.endSN||-1,this.totalDuration=e.totalDuration,this.targetDuration=e.targetDuration,this.live=e.live,t&&this.currentAudioStream&&Array.isArray(t.segments)&&(this._updateSegments(t,this.currentAudioStream),(null===this.snDiff||void 0===this.snDiff)&&e.segments.length&&t.segments.length&&(this.snDiff=e.segments[0].sn-t.segments[0].sn))):(this.id=e.id,this.bitrate=e.bitrate,this.width=e.width,this.height=e.height,this.name=e.name,this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.textCodec=e.textCodec,this.audioStreams=e.audioStreams,this.subtitleStreams=e.subtitleStreams,!this.currentAudioStream&&this.audioStreams.length&&(this.currentAudioStream=this.audioStreams.find((e=>e.default))||this.audioStreams[0]),!this.currentSubtitleStream&&this.subtitleStreams.length&&(this.currentSubtitleStream=this.subtitleStreams.find((e=>e.default))||this.subtitleStreams[0]))}updateSubtitle(e){if(!(e&&this.currentSubtitleStream&&Array.isArray(e.segments)))return;const t=this._updateSegments(e,this.currentSubtitleStream),i=this.currentSubtitleStream.segments;return i.length>100&&(this.currentSubtitleStream.segments=i.slice(100)),t?t.map((e=>({sn:e.sn,url:e.url,duration:e.duration,start:e.start,end:e.end,lang:this.currentSubtitleStream.lang}))):void 0}switchSubtitle(e){const t=this.subtitleStreams.find((t=>t.lang===e)),i=this.currentSubtitleStream;t&&(this.currentSubtitleStream=t,i.segments=[])}_clearSegments(e,t){let i=0;const r=this.segments;for(let t=0,s=r.length;t<s;t++)if(r[t].end>=e){i=t;break}return i>t&&(i=t),i&&(this.segments=this.segments.slice(i),this.currentAudioStream&&(this.currentAudioStream.segments=this.currentAudioStream.segments.slice(i))),t-i}_updateSegments(e,t){const i=t.segments;if(this.live){const r=i[i.length-1],s=r?.sn||-1;if(s<e.endSN&&e.segments.length){const a=e.segments.findIndex((e=>e.sn===s)),n=a<0?e.segments:e.segments.slice(a+1);if(i.length&&n.length){let e=r.end;n.forEach((t=>{t.start=e,e=t.end}));const t=r?.cc||-1;t>n[0].cc&&n.forEach((e=>e.cc+=t))}return t.endSN=e.endSN,t.segments=i.concat(n),n}}else t.segments=e.segments}}class Ih{constructor(e){this.hls=e,this.player=e.player,this.streams=[],this.currentStream=null,this.dvrWindow=0,this._segmentPointer=-1,this.TAG_NAME="HlsPlaylist"}destroy(){this.reset()}get lastSegment(){return this.currentStream?.lastSegment}get currentSegment(){return this.currentSegments?.[this._segmentPointer]}get nextSegment(){return this.currentSegments?.[this._segmentPointer+1]}get currentSegments(){return this.currentStream?.segments}get currentSubtitleEndSn(){return this.currentStream?.currentSubtitleEndSn}get liveEdge(){return this.currentStream?.liveEdge}get totalDuration(){return this.currentStream?.totalDuration||0}get seekRange(){const e=this.currentSegments;if(e&&e.length)return[e[0].start,e[e.length-1].end]}get isEmpty(){return!this.currentSegments?.length}get isLive(){return this.currentStream?.live}get hasSubtitle(){return!!this.currentStream?.currentSubtitleStream}getAudioSegment(e){return this.currentStream?.getAudioSegment(e)}moveSegmentPointer(e){null==e&&(e=this._segmentPointer+1),this._segmentPointer=bs(e,-1,this.currentSegments?.length),this.player.debug.log(this.TAG_NAME,`moveSegmentPointer() and param pos is ${e} and clamp result is ${this._segmentPointer}`)}reset(){this.streams=[],this.currentStream=null,this.dvrWindow=0,this._segmentPointer=-1}getSegmentByIndex(e){return this.currentSegments?.[e]}setNextSegmentByIndex(e=0){this._segmentPointer=e-1,this.player.debug.log(this.TAG_NAME,"setNextSegmentByIndex()",e,this._segmentPointer)}findSegmentIndexByTime(e){const t=this.currentSegments;if(t){for(let i,r=0,s=t.length;r<s;r++)if(i=t[r],e>=i.start&&e<i.end)return r;const i=t[t.length-1];if(Math.abs(e-i?.end)<.2)return t.length-1}}upsertPlaylist(e,t,i){if(!e)return void this.player.debug.warn(this.TAG_NAME,"upsertPlaylist() playlist is null");if(e.isMaster)this.streams.length=e.streams.length,e.streams.filter((e=>e.url)).forEach(((e,t)=>{this.streams[t]?this.streams[t].update(e):this.streams[t]=new Lh(e)})),this.currentStream=this.streams[0];else if(Array.isArray(e.segments)){const r=this.currentStream;if(r){r.update(e,t,i);const s=r.updateSubtitle(i);s&&this.hls.emit(hr,{list:s})}else this.reset(),this.currentStream=this.streams[0]=new Lh(e,t,i)}this.currentStream&&this.hls.isLive&&!this.dvrWindow&&(this.dvrWindow=this.currentSegments.reduce(((e,t)=>e+=t.duration),0))}switchSubtitle(e){this.currentStream?.switchSubtitle(e)}clearOldSegment(e=50){const t=this.currentStream;if(!this.dvrWindow||!t)return;const i=t.endTime-this.dvrWindow;if(i<=0)return void this.player.debug.log(this.TAG_NAME,`clearOldSegment() stream.endTime:${t.endTime}, this.dvrWindow:${this.dvrWindow} startTime <= 0`);const r=t.segments;if(r.length<=e)return void this.player.debug.log(this.TAG_NAME,`clearOldSegment() segments.length:${r.length} <= maxPlaylistSize:${e}`);const s=this._segmentPointer;this._segmentPointer=t.clearOldSegment(i,s),this.player.debug.log(this.TAG_NAME,"clearOldSegment() update _segmentPointer:",s,this._segmentPointer),this.player.debug.log(this.TAG_NAME,"currentSegments",this.currentSegments)}checkSegmentTrackChange(e,t){const i=this.findSegmentIndexByTime(e),r=this.getSegmentByIndex(i);if(!r)return;if(!r.hasAudio&&!r.hasVideo)return;if(2!==t&&r.hasAudio&&r.hasVideo)return r;if(r.end-e>.3)return;const s=this.getSegmentByIndex(i+1);return s&&(s.hasAudio||s.hasVideo)&&(s.hasAudio!==r.hasAudio||s.hasVideo!==r.hasVideo)?s:void 0}}class Ph{constructor(e,t){this.hls=e,this.player=t;const i=window.crypto||window.msCrypto;this.subtle=i&&(i.subtle||i.webkitSubtle),this.externalDecryptor=null}decrypt(e,t){if(!e&&!t)return;const i=[];return e&&(i[0]=this._decryptSegment(e)),t&&(i[1]=this._decryptSegment(t)),Promise.all(i)}async _decryptSegment(e){let t=e.data;return e.key&&(t=await this._decryptData(e.data,e.key,e.keyIv)),e.map?Zl(e.map,t):t}async _decryptData(e,t,i){if(this.externalDecryptor)return await this.externalDecryptor.decrypt(e,t,i);{if(!this.subtle)throw new Error("crypto is not defined");const r=await this.subtle.importKey("raw",t,{name:"AES-CBC"},!1,["encrypt","decrypt"]);return new Uint8Array(await this.subtle.decrypt({name:"AES-CBC",iv:i},r,e))}}}function Bh(e,t=0){return(e[t]<<8)+(e[t+1]||0)}function Mh(e,t=0){return(e[t]<<24>>>0)+(e[t+1]<<16)+(e[t+2]<<8)+(e[t+3]||0)}function Uh(e,t=0){const i=Math.pow(2,32);return Mh(e,t)*i+Mh(e,t+4)}const Fh="aac",Oh="g7110a",Nh="g7110m",Gh="avc",zh="hevc";class Wh{static FREQ=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];static getFrameDuration(e,t=9e4){return 1024*t/e}static getRateIndexByRate(e){return Wh.FREQ.indexOf(e)}}function Vh(e,t,i,r,s,a){const n=[],o=s?.entries,l=t.entries,d=r.entries,h=i.entrySizes,c=a?.entries;let u,p,f;c&&(u={},c.forEach((e=>{u[e-1]=!0}))),o&&(p=[],o.forEach((({count:e,offset:t})=>{for(let i=0;i<e;i++)p.push(t)})));let y=-1,m=0,g=0,A=0,v=0,b=0,_=l[0].samplesPerChunk,w=l[1]?l[1].firstChunk-1:1/0;return e.entries.forEach((({count:e,delta:t})=>{for(let r=0;r<e;r++)f={dts:m,duration:t,size:h[g]||i.sampleSize,offset:d[A]+b,index:g},c&&(f.keyframe=u[g],f.keyframe&&y++,f.gopId=y),p&&g<p.length&&(f.pts=f.dts+p[g]),n.push(f),m+=t,g++,g<_?b+=f.size:(A++,b=0,A>=w&&(v++,w=l[v+1]?l[v+1].firstChunk-1:1/0),_+=l[v].samplesPerChunk)})),n}function Hh(e,t){return e.dataReferenceIndex=Bh(t,6),e.width=Bh(t,24),e.height=Bh(t,26),e.horizresolution=Mh(t,28),e.vertresolution=Mh(t,32),e.frameCount=Bh(t,40),e.depth=Bh(t,74),78}function $h(e,t){return e.dataReferenceIndex=Bh(t,6),e.channelCount=Bh(t,16),e.sampleSize=Bh(t,18),e.sampleRate=Mh(t,24)/65536,28}function jh(e,t,i){if(!e)return;if(e.size!==e.data.length)throw new Error(`box ${e.type} size !== data.length`);const r={start:e.start,size:e.size,headerSize:e.headerSize,type:e.type};return t&&(r.version=e.data[e.headerSize],r.flags=function(e,t=0){return(e[t]<<16)+(e[t+1]<<8)+(e[t+2]||0)}(e.data,e.headerSize+1),r.headerSize+=4),i(r,e.data.subarray(r.headerSize),r.start+r.headerSize),r}const Kh=function(...e){const t=[];return e.forEach((e=>{t.push(function(e,t,i){const r=String(i),s=0|t;let a=Math.ceil(s/r.length);const n=[],o=String(e);for(;a--;)n.push(r);return n.join("").substring(0,s-o.length)+o}(Number(e).toString(16),2,0))})),t[0]};class qh{static probe(e){return!!qh.findBox(e,["ftyp"])}static findBox(e,t,i=0){const r=[];if(!e)return r;let s=0,a="",n=0;for(;e.length>7;){if(s=Mh(e),a=String.fromCharCode.apply(null,e.subarray(4,8)),n=8,1===s?(s=Uh(e,8),n+=8):s||(s=e.length),!t[0]||a===t[0]){const o=e.subarray(0,s);if(!(t.length<2))return qh.findBox(o.subarray(n),t.slice(1),i+n);r.push({start:i,size:s,headerSize:n,type:a,data:o})}i+=s,e=e.subarray(s)}return r}static tfhd(e){return jh(e,!0,((e,t)=>{e.trackId=Mh(t);let i=4;const r=1&e.flags,s=2&e.flags,a=8&e.flags,n=16&e.flags,o=32&e.flags;r&&(i+=4,e.baseDataOffset=Mh(t,i),i+=4),s&&(e.sampleDescriptionIndex=Mh(t,i),i+=4),a&&(e.defaultSampleDuration=Mh(t,i),i+=4),n&&(e.defaultSampleSize=Mh(t,i),i+=4),o&&(e.defaultSampleFlags=Mh(t,i))}))}static sidx(e){return jh(e,!0,((e,t)=>{let i=0;e.reference_ID=Mh(t,i),i+=4,e.timescale=Mh(t,i),i+=4,0===e.version?(e.earliest_presentation_time=Mh(t,i),i+=4,e.first_offset=Mh(t,i),i+=4):(e.earliest_presentation_time=Uh(t,i),i+=8,e.first_offset=Uh(t,i),i+=8),i+=2,e.references=[];const r=Bh(t,i);i+=2;for(let s=0;s<r;s++){const r={};e.references.push(r);let s=Mh(t,i);i+=4,r.reference_type=s>>31&1,r.referenced_size=2147483647&s,r.subsegment_duration=Mh(t,i),i+=4,s=Mh(t,i),i+=4,r.starts_with_SAP=s>>31&1,r.SAP_type=s>>28&7,r.SAP_delta_time=268435455&s}}))}static moov(e){return jh(e,!1,((e,t,i)=>{e.mvhd=qh.mvhd(qh.findBox(t,["mvhd"],i)[0]),e.trak=qh.findBox(t,["trak"],i).map((e=>qh.trak(e))),e.pssh=qh.pssh(qh.findBox(t,["pssh"],i)[0])}))}static mvhd(e){return jh(e,!0,((e,t)=>{let i=0;1===e.version?(e.timescale=Mh(t,16),e.duration=Uh(t,20),i+=28):(e.timescale=Mh(t,8),e.duration=Mh(t,12),i+=16),e.nextTrackId=Mh(t,i+76)}))}static trak(e){return jh(e,!1,((e,t,i)=>{e.tkhd=qh.tkhd(qh.findBox(t,["tkhd"],i)[0]),e.mdia=qh.mdia(qh.findBox(t,["mdia"],i)[0])}))}static tkhd(e){return jh(e,!0,((e,t)=>{let i=0;1===e.version?(e.trackId=Mh(t,16),e.duration=Uh(t,24),i+=32):(e.trackId=Mh(t,8),e.duration=Mh(t,16),i+=20),e.width=Mh(t,i+52),e.height=Mh(t,i+56)}))}static mdia(e){return jh(e,!1,((e,t,i)=>{e.mdhd=qh.mdhd(qh.findBox(t,["mdhd"],i)[0]),e.hdlr=qh.hdlr(qh.findBox(t,["hdlr"],i)[0]),e.minf=qh.minf(qh.findBox(t,["minf"],i)[0])}))}static mdhd(e){return jh(e,!0,((e,t)=>{let i=0;1===e.version?(e.timescale=Mh(t,16),e.duration=Uh(t,20),i+=28):(e.timescale=Mh(t,8),e.duration=Mh(t,12),i+=16);const r=Bh(t,i);e.language=String.fromCharCode(96+(r>>10&31),96+(r>>5&31),96+(31&r))}))}static hdlr(e){return jh(e,!0,((e,t)=>{0===e.version&&(e.handlerType=String.fromCharCode.apply(null,t.subarray(4,8)))}))}static minf(e){return jh(e,!1,((e,t,i)=>{e.vmhd=qh.vmhd(qh.findBox(t,["vmhd"],i)[0]),e.smhd=qh.smhd(qh.findBox(t,["smhd"],i)[0]),e.stbl=qh.stbl(qh.findBox(t,["stbl"],i)[0])}))}static vmhd(e){return jh(e,!0,((e,t)=>{e.graphicsmode=Bh(t),e.opcolor=[Bh(t,2),Bh(t,4),Bh(t,6)]}))}static smhd(e){return jh(e,!0,((e,t)=>{e.balance=Bh(t)}))}static stbl(e){return jh(e,!1,((e,t,i)=>{e.stsd=qh.stsd(qh.findBox(t,["stsd"],i)[0]),e.stts=qh.stts(qh.findBox(t,["stts"],i)[0]),e.ctts=qh.ctts(qh.findBox(t,["ctts"],i)[0]),e.stsc=qh.stsc(qh.findBox(t,["stsc"],i)[0]),e.stsz=qh.stsz(qh.findBox(t,["stsz"],i)[0]),e.stco=qh.stco(qh.findBox(t,["stco"],i)[0]),e.stco||(e.co64=qh.co64(qh.findBox(t,["co64"],i)[0]),e.stco=e.co64);const r=e.stsd.entries[0]?.sinf?.schi?.tenc.default_IV_size;e.stss=qh.stss(qh.findBox(t,["stss"],i)[0]),e.senc=qh.senc(qh.findBox(t,["senc"],i)[0],r)}))}static senc(e,t=8){return jh(e,!0,((e,i)=>{let r=0;const s=Mh(i,r);r+=4,e.samples=[];for(let a=0;a<s;a++){const s={InitializationVector:[]};for(let e=0;e<t;e++)s.InitializationVector[e]=i[r+e];if(r+=t,2&e.flags){s.subsamples=[];const e=Bh(i,r);r+=2;for(let t=0;t<e;t++){const e={};e.BytesOfClearData=Bh(i,r),r+=2,e.BytesOfProtectedData=Mh(i,r),r+=4,s.subsamples.push(e)}}e.samples.push(s)}}))}static pssh(e){return jh(e,!0,((e,t)=>{const i=[],r=[];let s=0;for(let e=0;e<16;e++)r.push(Kh(t[s+e]));if(s+=16,e.version>0){const e=Mh(t,s);s+=4;for(let r=0;r<(""+e).length;r++)for(let e=0;e<16;e++){const e=t[s];s+=1,i.push(Kh(e))}}const a=Mh(t,s);e.data_size=a,s+=4,e.kid=i,e.system_id=r,e.buffer=t}))}static stsd(e){return jh(e,!0,((e,t,i)=>{e.entryCount=Mh(t),e.entries=qh.findBox(t.subarray(4),[],i+4).map((e=>{switch(e.type){case"avc1":case"avc2":case"avc3":case"avc4":return qh.avc1(e);case"hvc1":case"hev1":return qh.hvc1(e);case"mp4a":return qh.mp4a(e);case"alaw":case"ulaw":return qh.alaw(e);case"enca":return jh(e,!1,((e,t,i)=>{e.channelCount=Bh(t,16),e.samplesize=Bh(t,18),e.sampleRate=Mh(t,24)/65536,t=t.subarray(28),e.sinf=qh.sinf(qh.findBox(t,["sinf"],i)[0]),e.esds=qh.esds(qh.findBox(t,["esds"],i)[0])}));case"encv":return jh(e,!1,((e,t,i)=>{e.width=Bh(t,24),e.height=Bh(t,26),e.horizresolution=Mh(t,28),e.vertresolution=Mh(t,32),t=t.subarray(78),e.sinf=qh.sinf(qh.findBox(t,["sinf"],i)[0]),e.avcC=qh.avcC(qh.findBox(t,["avcC"],i)[0]),e.hvcC=qh.hvcC(qh.findBox(t,["hvcC"],i)[0]),e.pasp=qh.pasp(qh.findBox(t,["pasp"],i)[0])}))}})).filter(Boolean)}))}static tenc(e){return jh(e,!1,((e,t)=>{let i=6;e.default_IsEncrypted=t[i],i+=1,e.default_IV_size=t[i],i+=1,e.default_KID=[];for(let r=0;r<16;r++)e.default_KID.push(Kh(t[i])),i+=1}))}static schi(e){return jh(e,!1,((e,t,i)=>{e.tenc=qh.tenc(qh.findBox(t,["tenc"],i)[0])}))}static sinf(e){return jh(e,!1,((e,t,i)=>{e.schi=qh.schi(qh.findBox(t,["schi"],i)[0]),e.frma=qh.frma(qh.findBox(t,["frma"],i)[0])}))}static frma(e){return jh(e,!1,((e,t)=>{e.data_format="";for(let i=0;i<4;i++)e.data_format+=String.fromCharCode(t[i])}))}static avc1(e){return jh(e,!1,((e,t,i)=>{const r=Hh(e,t),s=t.subarray(r);i+=r,e.avcC=qh.avcC(qh.findBox(s,["avcC"],i)[0]),e.pasp=qh.pasp(qh.findBox(s,["pasp"],i)[0])}))}static avcC(e){return jh(e,!1,((e,t)=>{e.configurationVersion=t[0],e.AVCProfileIndication=t[1],e.profileCompatibility=t[2],e.AVCLevelIndication=t[3],e.codec=function(e){let t,i="avc1.";for(let r=0;r<3;r++)t=e[r].toString(16),t.length<2&&(t=`0${t}`),i+=t;return i}([t[1],t[2],t[3]]),e.lengthSizeMinusOne=3&t[4],e.spsLength=31&t[5],e.sps=[];let i=6;for(let r=0;r<e.spsLength;r++){const r=Bh(t,i);i+=2,e.sps.push(t.subarray(i,i+r)),i+=r}e.ppsLength=t[i],i+=1,e.pps=[];for(let r=0;r<e.ppsLength;r++){const r=Bh(t,i);i+=2,e.pps.push(t.subarray(i,i+=r)),i+=r}}))}static hvc1(e){return jh(e,!1,((e,t,i)=>{const r=Hh(e,t),s=t.subarray(r);i+=r,e.hvcC=qh.hvcC(qh.findBox(s,["hvcC"],i)[0]),e.pasp=qh.pasp(qh.findBox(s,["pasp"],i)[0])}))}static hvcC(e){return jh(e,!1,((t,i)=>{t.data=e.data,t.codec="hev1.1.6.L93.B0",t.configurationVersion=i[0];const r=i[1];t.generalProfileSpace=r>>6,t.generalTierFlag=(32&r)>>5,t.generalProfileIdc=31&r,t.generalProfileCompatibility=Mh(i,2),t.generalConstraintIndicatorFlags=i.subarray(6,12),t.generalLevelIdc=i[12],t.avgFrameRate=Bh(i,19),t.numOfArrays=i[22],t.vps=[],t.sps=[],t.pps=[];let s=23,a=0,n=0,o=0;for(let e=0;e<t.numOfArrays;e++){a=63&i[s],n=Bh(i,s+1),s+=3;const e=[];for(let t=0;t<n;t++)o=Bh(i,s),s+=2,e.push(i.subarray(s,s+o)),s+=o;32===a?t.vps.push(...e):33===a?t.sps.push(...e):34===a&&t.pps.push(...e)}}))}static pasp(e){return jh(e,!1,((e,t)=>{e.hSpacing=Mh(t),e.vSpacing=Mh(t,4)}))}static mp4a(e){return jh(e,!1,((e,t,i)=>{const r=$h(e,t);e.esds=qh.esds(qh.findBox(t.subarray(r),["esds"],i+r)[0])}))}static esds(e){return jh(e,!0,((e,t)=>{e.codec="mp4a.";let i=0,r=0,s=0,a=0;for(;t.length;){for(i=0,a=t[i],r=t[i+1],i+=2;128&r;)s=(127&r)<<7,r=t[i],i+=1;if(s+=127&r,3===a)t=t.subarray(i+3);else{if(4!==a){if(5===a){const r=e.config=t.subarray(i,i+s);let a=(248&r[0])>>3;return 31===a&&r.length>=2&&(a=32+((7&r[0])<<3)+((224&r[1])>>5)),e.objectType=a,e.codec+=a.toString(16),void("."===e.codec[e.codec.length-1]&&(e.codec=e.codec.substring(0,e.codec.length-1)))}return void("."===e.codec[e.codec.length-1]&&(e.codec=e.codec.substring(0,e.codec.length-1)))}e.codec+=(t[i].toString(16)+".").padStart(3,"0"),t=t.subarray(i+13)}}}))}static alaw(e){return jh(e,!1,((e,t)=>{$h(e,t)}))}static stts(e){return jh(e,!0,((e,t)=>{const i=Mh(t),r=[];let s=4;for(let e=0;e<i;e++)r.push({count:Mh(t,s),delta:Mh(t,s+4)}),s+=8;e.entryCount=i,e.entries=r}))}static ctts(e){return jh(e,!0,((e,t)=>{const i=Mh(t),r=[];let s=4;if(1===e.version)for(let e=0;e<i;e++)r.push({count:Mh(t,s),offset:Mh(t,s+4)}),s+=8;else for(let e=0;e<i;e++)r.push({count:Mh(t,s),offset:-(1+~Mh(t,s+4))}),s+=8;e.entryCount=i,e.entries=r}))}static stsc(e){return jh(e,!0,((e,t)=>{const i=Mh(t),r=[];let s=4;for(let e=0;e<i;e++)r.push({firstChunk:Mh(t,s),samplesPerChunk:Mh(t,s+4),sampleDescriptionIndex:Mh(t,s+8)}),s+=12;e.entryCount=i,e.entries=r}))}static stsz(e){return jh(e,!0,((e,t)=>{const i=Mh(t),r=Mh(t,4),s=[];if(!i){let e=8;for(let i=0;i<r;i++)s.push(Mh(t,e)),e+=4}e.sampleSize=i,e.sampleCount=r,e.entrySizes=s}))}static stco(e){return jh(e,!0,((e,t)=>{const i=Mh(t),r=[];let s=4;for(let e=0;e<i;e++)r.push(Mh(t,s)),s+=4;e.entryCount=i,e.entries=r}))}static co64(e){return jh(e,!0,((e,t)=>{const i=Mh(t),r=[];let s=4;for(let e=0;e<i;e++)r.push(Uh(t,s)),s+=8;e.entryCount=i,e.entries=r}))}static stss(e){return jh(e,!0,((e,t)=>{const i=Mh(t),r=[];let s=4;for(let e=0;e<i;e++)r.push(Mh(t,s)),s+=4;e.entryCount=i,e.entries=r}))}static moof(e){return jh(e,!1,((e,t,i)=>{e.mfhd=qh.mfhd(qh.findBox(t,["mfhd"],i)[0]),e.traf=qh.findBox(t,["traf"],i).map((e=>qh.traf(e)))}))}static mfhd(e){return jh(e,!0,((e,t)=>{e.sequenceNumber=Mh(t)}))}static traf(e){return jh(e,!1,((e,t,i)=>{e.tfhd=qh.tfhd(qh.findBox(t,["tfhd"],i)[0]),e.tfdt=qh.tfdt(qh.findBox(t,["tfdt"],i)[0]),e.trun=qh.trun(qh.findBox(t,["trun"],i)[0])}))}static trun(e){return jh(e,!0,((e,t)=>{const{version:i,flags:r}=e,s=t.length,a=e.sampleCount=Mh(t);let n=4;if(s>n&&1&r&&(e.dataOffset=-(1+~Mh(t,n)),n+=4),s>n&&4&r&&(e.firstSampleFlags=Mh(t,n),n+=4),e.samples=[],s>n){let s;for(let o=0;o<a;o++)s={},256&r&&(s.duration=Mh(t,n),n+=4),512&r&&(s.size=Mh(t,n),n+=4),1024&r&&(s.flags=Mh(t,n),n+=4),2048&r&&(s.cts=i?-(1+~Mh(t,n+4)):Mh(t,n),n+=4),e.samples.push(s)}}))}static tfdt(e){return jh(e,!0,((e,t)=>{1===e.version?e.baseMediaDecodeTime=Uh(t):e.baseMediaDecodeTime=Mh(t)}))}static probe(e){return!!qh.findBox(e,["ftyp"])}static parseSampleFlags(e){return{isLeading:(12&e[0])>>>2,dependsOn:3&e[0],isDependedOn:(192&e[1])>>>6,hasRedundancy:(48&e[1])>>>4,paddingValue:(14&e[1])>>>1,isNonSyncSample:1&e[1],degradationPriority:e[2]<<8|e[3]}}static moovToTrack(e,t,i){const r=e.trak;if(!r||!r.length)return;const s=r.find((e=>"vide"===e.mdia?.hdlr?.handlerType)),a=r.find((e=>"soun"===e.mdia?.hdlr?.handlerType));if(s&&t){const i=t,r=s.tkhd?.trackId;null!=r&&(i.id=s.tkhd.trackId),i.tkhdDuration=s.tkhd.duration,i.mvhdDurtion=e.mvhd.duration,i.mvhdTimecale=e.mvhd.timescale,i.timescale=i.formatTimescale=s.mdia.mdhd.timescale,i.duration=s.mdia.mdhd.duration||i.mvhdDurtion/i.mvhdTimecale*i.timescale;const a=s.mdia.minf.stbl.stsd.entries[0];if(i.width=a.width,i.height=a.height,a.pasp&&(i.sarRatio=[a.pasp.hSpacing,a.pasp.vSpacing]),a.hvcC)i.codecType=zh,i.codec=a.hvcC.codec,i.vps=a.hvcC.vps,i.sps=a.hvcC.sps,i.pps=a.hvcC.pps,i.hvcC=a.hvcC.data;else{if(!a.avcC)throw new Error("unknown video stsd entry");i.codecType=Gh,i.codec=a.avcC.codec,i.sps=a.avcC.sps,i.pps=a.avcC.pps}i.present=!0,i.ext={},i.ext.stss=s.mdia?.minf?.stbl?.stss,i.ext.ctts=s.mdia?.minf?.stbl?.ctts,a&&"encv"===a.type&&(i.isVideoEncryption=!0,a.default_KID=a.sinf?.schi?.tenc.default_KID,a.default_IsEncrypted=a.sinf?.schi?.tenc.default_IsEncrypted,a.default_IV_size=a.sinf?.schi?.tenc.default_IV_size,i.videoSenc=s.mdia.minf.stbl.senc&&s.mdia.minf.stbl.senc.samples,a.data_format=a.sinf?.frma?.data_format,i.useEME=e.useEME,i.kidValue=e.kidValue,i.pssh=e.pssh,i.encv=a)}if(a&&i){const t=i,r=a.tkhd?.trackId;null!=r&&(t.id=a.tkhd.trackId),t.tkhdDuration=a.tkhd.duration,t.mvhdDurtion=e.mvhd.duration,t.mvhdTimecale=e.mvhd.timescale,t.timescale=t.formatTimescale=a.mdia.mdhd.timescale,t.duration=a.mdia.mdhd.duration||t.mvhdDurtion/t.mvhdTimecale*t.timescale;const s=a.mdia.minf.stbl.stsd.entries[0];switch(t.sampleSize=s.sampleSize,t.sampleRate=s.sampleRate,t.channelCount=s.channelCount,t.present=!0,s.type){case"alaw":t.codecType=t.codec=Oh,t.sampleRate=8e3;break;case"ulaw":t.codecType=t.codec=Nh,t.sampleRate=8e3;break;default:t.codecType=Fh,t.sampleDuration=Wh.getFrameDuration(t.sampleRate,t.timescale),t.sampleRateIndex=Wh.getRateIndexByRate(t.sampleRate),t.objectType=s.esds?.objectType||2,s.esds&&(t.config=Array.from(s.esds.config)),t.codec=s.esds?.codec||"mp4a.40.2"}t.sampleDuration=Wh.getFrameDuration(t.sampleRate,t.timescale),t.objectType=s.esds?.objectType||2,s.esds&&(s.esds.config?t.config=Array.from(s.esds.config):console.warn("esds config is null")),t.codec=s.esds?.codec||"mp4a.40.2",t.sampleRateIndex=Wh.getRateIndexByRate(t.sampleRate),t.ext={},t.ext.stss=a.mdia?.minf?.stbl?.stss,t.ext.ctts=a.mdia?.minf?.stbl?.ctts,t.present=!0,s&&"enca"===s.type&&(t.isAudioEncryption=!0,s.data_format=s.sinf?.frma?.data_format,s.default_KID=s.sinf?.schi?.tenc.default_KID,s.default_IsEncrypted=s.sinf?.schi?.tenc.default_IsEncrypted,s.default_IV_size=s.sinf?.schi?.tenc.default_IV_size,t.audioSenc=a.mdia.minf.stbl.senc&&a.mdia.minf.stbl.senc.samples,t.useEME=e.useEME,t.kidValue=e.kidValue,t.enca=s)}if(i&&(i.isVideoEncryption=!!t&&t.isVideoEncryption),t&&(t.isAudioEncryption=!!i&&i.isAudioEncryption),t?.encv||i?.enca){const e=t?.encv?.default_KID,r=i?.enca?.default_KID,s=e||r?(e||r).join(""):null;t&&(t.kid=s),i&&(i.kid=s)}return t&&(t.flags=3841),i&&(i.flags=1793),{videoTrack:t,audioTrack:i}}static evaluateDefaultDuration(e,t,i){const r=t?.samples?.length;if(!r)return 1024;return 1024*r/t.timescale*e.timescale/i}static moofToSamples(e,t,i){const r={};return e.mfhd&&(t&&(t.sequenceNumber=e.mfhd.sequenceNumber),i&&(i.sequenceNumber=e.mfhd.sequenceNumber)),e.traf.forEach((({tfhd:e,tfdt:s,trun:a})=>{if(!e||!a)return;s&&(t&&t.id===e.trackId&&(t.baseMediaDecodeTime=s.baseMediaDecodeTime),i&&i.id===e.trackId&&(i.baseMediaDecodeTime=s.baseMediaDecodeTime));const n=e.defaultSampleSize||0,o=e.defaultSampleDuration||qh.evaluateDefaultDuration(t,i,a.samples.length||a.sampleCount);let l=a.dataOffset||0,d=0,h=-1;if(!a.samples.length&&a.sampleCount){r[e.trackId]=[];for(let t=0;t<a.sampleCount;t++)r[e.trackId].push({offset:l,dts:d,duration:o,size:n}),d+=o,l+=n}else r[e.trackId]=a.samples.map(((e,t)=>((e={offset:l,dts:d,pts:d+(e.cts||0),duration:e.duration||o,size:e.size||n,gopId:h,keyframe:0===t||null!==e.flags&&void 0!==e.flags&&(65536&e.flags)>>>0!=65536}).keyframe&&(h++,e.gopId=h),d+=e.duration,l+=e.size,e)))})),r}static moovToSamples(e){const t=e.trak;if(!t||!t.length)return;const i=t.find((e=>"vide"===e.mdia?.hdlr?.handlerType)),r=t.find((e=>"soun"===e.mdia?.hdlr?.handlerType));if(!i&&!r)return;let s,a;if(i){const e=i.mdia?.minf?.stbl;if(!e)return;const{stts:t,stsc:r,stsz:a,stco:n,stss:o,ctts:l}=e;if(!(t&&r&&a&&n&&o))return;s=Vh(t,r,a,n,l,o)}if(r){const e=r.mdia?.minf?.stbl;if(!e)return;const t=r.mdia.mdhd?.timescale,{stts:i,stsc:s,stsz:n,stco:o}=e;if(!(t&&i&&s&&n&&o))return;a=Vh(i,s,n,o)}return{videoSamples:s,audioSamples:a}}}class Yh extends Ul{constructor(e){super(e),this.player=e,this.TAG_NAME="HlsFmp4Loader",this.tempSampleListInfo={},this.isInitVideo=!1,this.isInitAudio=!1,this.videoTrack={id:1,samples:[],sps:[],pps:[],vps:[],codec:""},this.audioTrack={id:2,samples:[],sampleRate:0,channelCount:0,codec:"",codecType:""},this.workerClearTimeout=null,this.workerUrl=null,this.loopWorker=null,this._hasCalcFps=!1,this.player.isUseMSE()||this._initLoopWorker(),e.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this.workerUrl&&(URL.revokeObjectURL(this.workerUrl),this.workerUrl=null),this.workerClearTimeout&&(clearTimeout(this.workerClearTimeout),this.workerClearTimeout=null),this.loopWorker&&(this.loopWorker.postMessage({cmd:"destroy"}),this.loopWorker.terminate(),this.loopWorker=null),this._hasCalcFps=!1,this.videoTrack=null,this.audioTrack=null,this.isInitVideo=!1,this.isInitAudio=!1,this.player.debug.log(this.TAG_NAME,"destroy")}demux(e,t){let i=this.audioTrack,r=this.videoTrack;if(this.checkInitAudio(),this.checkInitVideo(),i.samples=[],r.samples=[],t){if(this.player.updateStats({abps:t.byteLength}),ka(this.isInitAudio)){const e=qh.findBox(t,["moov"])[0];if(!e)return void this.player.debug.error(this.TAG_NAME,"cannot found moov box");qh.moovToTrack(qh.moov(e),null,i),this.checkInitAudio()&&(this.player.debug.log(this.TAG_NAME,"audioData audio init success"),this._sendAccADTSHeader(i))}const e=qh.findBox(t,["moof"])[0];if(e){const r=qh.moofToSamples(qh.moof(e),null,i)[i.id],s=i.baseMediaDecodeTime;if(r){const a=e.start;r.map((e=>{e.offset+=a;const r=t.subarray(e.offset,e.offset+e.size),n=e.dts+s,o=new Uint8Array(r.length+2);o.set([175,1],0),o.set(r,2),i.samples.push({type:Oe,pts:n,dts:n,payload:o,duration:e.duration,size:o.byteLength})}))}}}if(e){if(this.player.updateStats({vbps:e.byteLength}),ka(this.isInitVideo)&&ka(this.isInitAudio)){const t=qh.findBox(e,["moov"])[0];if(!t)throw new Error("cannot found moov box");if(qh.moovToTrack(qh.moov(t),r,i),ka(this.isInitAudio)&&this.checkInitAudio()&&(this.player.debug.log(this.TAG_NAME,"videoData audio init success",i),this._sendAccADTSHeader(i)),this.checkInitVideo()){this.player.debug.log(this.TAG_NAME,"video init success");let e=null;r.codecType===Ci?r.sps.length&&r.vps.length&&r.pps.length&&(e=Zn({sps:r.sps[0],pps:r.pps[0],vps:r.vps[0]})):r.sps.length&&r.pps.length&&(e=Nn({sps:r.sps[0],pps:r.pps[0]})),e&&(this.player.debug.log(this.TAG_NAME,"seqHeader"),this._doDecodeByHls(e,Ne,0,!0,0))}}const t=qh.findBox(e,["moof"])[0];if(t){const s=qh.moofToSamples(qh.moof(t),r,i),a=r.baseMediaDecodeTime,n=i.baseMediaDecodeTime,o=t.start;Object.keys(s).forEach((t=>{r.id==t?s[t].map((t=>{t.offset+=o;const i={type:Ne,pts:(t.pts||t.dts)+a,dts:t.dts+a,units:[],payload:null,isIFrame:!1};i.duration=t.duration,i.gopId=t.gopId,t.keyframe&&(i.isIFrame=!0);const s=e.subarray(t.offset,t.offset+t.size);i.payload=s,r.samples.push(i)})):i.id==t&&s[t].map((t=>{t.offset+=o;const r=e.subarray(t.offset,t.offset+t.size),s=t.dts+n,a=new Uint8Array(r.length+2);a.set([175,1],0),a.set(r,2),i.samples.push({type:Oe,pts:s,dts:s,payload:a,duration:t.duration,size:a.byteLength})}))}))}}const s=r.samples.concat(i.samples);s.sort(((e,t)=>e.dts-t.dts)),s.forEach((e=>{const t=new Uint8Array(e.payload);delete e.payload,this.player.isUseMSE()?e.type===Ne?this._doDecodeVideo({...e,payload:t}):e.type===Oe&&this._doDecodeAudio({...e,payload:t}):this.loopWorker.postMessage({...e,payload:t,cmd:"sample"},[t.buffer])})),ka(this._hasCalcFps)&&(this._hasCalcFps=!0,this._calcDecodeFps(s))}checkInitAudio(){return this.isInitAudio=!!(this.audioTrack.sampleRate&&this.audioTrack.channelCount&&this.audioTrack.codec&&"aac"===this.audioTrack.codecType),this.isInitAudio}checkInitVideo(){return this.isInitVideo=!!(this.videoTrack.pps.length&&this.videoTrack.sps.length&&this.videoTrack.codec),this.isInitVideo}_sendAccADTSHeader(e){const t=ts({profile:e.objectType,sampleRate:e.sampleRateIndex,channel:e.channelCount});this._doDecodeByHls(t,Oe,0,!0,0)}_calcDecodeFps(e){const t=Aa(e.map((e=>({ts:e.dts||e.pts,type:e.type}))),Ne);t&&(this._basefps=t,this._postMessageToLoopWorker("updateBaseFps",{baseFps:this._basefps}),this.player.debug.log(this.TAG_NAME,`_calcDecodeFps() video fps is ${t}, update base fps is ${this._basefps}`))}_initLoopWorker(){this.player.debug.log(this.TAG_NAME,"_initLoopWorker()");const e=Ia(function(){const e=1,t=2;let i=new class{constructor(){this.baseFps=0,this.fpsInterval=null,this.preLoopTimestamp=null,this.startBpsTime=null,this.allSampleList=[]}destroy(){this._clearInterval(),this.baseFps=0,this.allSampleList=[],this.preLoopTimestamp=null,this.startBpsTime=null}updateBaseFps(e){this.baseFps=e,this._clearInterval(),this._startInterval()}pushSample(e){delete e.cmd,this.allSampleList.push(e)}_startInterval(){const e=Math.ceil(1e3/this.baseFps);this.fpsInterval=setInterval((()=>{let t=(new Date).getTime();this.preLoopTimestamp||(this.preLoopTimestamp=t),this.startBpsTime||(this.startBpsTime=t);const i=t-this.preLoopTimestamp;if(i>2*e&&console.warn(`EasyPro:[HlsFmp4Loader LoopWorker] loop interval is ${i}ms, more than ${e} * 2ms`),this._loop(),this.preLoopTimestamp=(new Date).getTime(),this.startBpsTime){t-this.startBpsTime>=1e3&&(this._calcSampleList(),this.startBpsTime=t)}}),e)}_clearInterval(){this.fpsInterval&&(clearInterval(this.fpsInterval),this.fpsInterval=null)}_calcSampleList(){const i={buferredDuration:0,allListLength:this.allSampleList.length,audioListLength:0,videoListLength:0};this.allSampleList.forEach((r=>{r.type===t?(i.videoListLength++,r.duration&&(i.buferredDuration+=r.duration)):r.type===e&&i.audioListLength++})),postMessage({cmd:"sampleListInfo",...i})}_loop(){let i=null;if(this.allSampleList.length)if(i=this.allSampleList.shift(),i.type===t){postMessage({cmd:"decodeVideo",...i},[i.payload.buffer]);let t=this.allSampleList[0];for(;t&&t.type===e;)i=this.allSampleList.shift(),postMessage({cmd:"decodeAudio",...i},[i.payload.buffer]),t=this.allSampleList[0]}else i.type===e&&(postMessage({cmd:"decodeAudio",...i},[i.payload.buffer]),this.allSampleList.length&&this.allSampleList[0].type===t&&(i=this.allSampleList.shift(),postMessage({cmd:"decodeVideo",...i},[i.payload.buffer])))}};self.onmessage=e=>{const t=e.data;switch(t.cmd){case"updateBaseFps":i.updateBaseFps(t.baseFps);break;case"sample":i.pushSample(t);break;case"destroy":i.destroy(),i=null}}}.toString()),t=new Blob([e],{type:"text/javascript"}),i=URL.createObjectURL(t);let r=new Worker(i);this.workerUrl=i,this.workerClearTimeout=setTimeout((()=>{window.URL.revokeObjectURL(this.workerUrl),this.workerUrl=null,this.workerClearTimeout=null}),re),r.onmessage=e=>{const t=e.data;switch(t.cmd){case"decodeVideo":this._doDecodeVideo(t);break;case"decodeAudio":this._doDecodeAudio(t);break;case"sampleListInfo":this.tempSampleListInfo=t}},this.loopWorker=r}_postMessageToLoopWorker(e,t){this.player.isUseMSE()||(this.loopWorker?this.loopWorker.postMessage({cmd:e,...t}):this.player.debug.warn(this.TAG_NAME,"loop worker is not init, can not post message"))}_doDecodeAudio(e){const t=new Uint8Array(e.payload);this._doDecodeByHls(t,Oe,e.dts,!1,0)}_doDecodeVideo(e){const t=new Uint8Array(e.payload);let i=null;i=e.isHevc?eo(t,e.isIFrame):Gn(t,e.isIFrame),this.player.updateStats({dts:e.dts});const r=e.pts-e.dts;this._doDecodeByHls(i,Ne,e.dts,e.isIFrame,r)}getBuferredDuration(){return this.tempSampleListInfo.buferredDuration||0}getSampleListLength(){return this.tempSampleListInfo.allListLength||0}getSampleAudioListLength(){return this.tempSampleListInfo.audioListLength||0}getSampleVideoListLength(){return this.tempSampleListInfo.videoListLength||0}}class Qh{constructor(e,t){this.hls=e,this.player=this.hls.player,this.isMP4=t,this._initSegmentId="",this.TAG_NAME="HlsTransmuxer",this._demuxer=t?new Yh(this.hls.player):new ed(this.hls.player),this.player.debug.log(this.TAG_NAME,`init and isMP4 is ${t}`)}destroy(){this._demuxer&&(this._demuxer.destroy(),this._demuxer=null)}transmux(e,t,i,r,s,a){this.player.debug.log(this.TAG_NAME,`transmux videoChunk:${e&&e.byteLength}, audioChunk:${t&&t.byteLength}, discontinuity:${i}, contiguous:${r}, startTime:${s}, needInit:${a}`);const n=this._demuxer;try{this.isMP4?n.demux(e,t):n.demuxAndFix(Zl(e,t),i,r,s)}catch(e){throw new oh(nh,ah,e)}}}class Xh{constructor(e){this.hls=e,this.player=e.player,this._decryptor=new Ph(this.hls,this.player),this._transmuxer=null,this._mse=null,this._softVideo=null,this._sourceCreated=!1,this._needInitSegment=!0,this._directAppend=!1,this.TAG_NAME="HlsBufferService"}async destroy(){this._softVideo=null,this._transmuxer&&(this._transmuxer.destroy(),this._transmuxer=null)}get baseDts(){return this._transmuxer?._demuxer?._baseDts}get nbSb(){return 0}async updateDuration(e){this.player.debug.log(this.TAG_NAME,"updateDuration()",e)}getBuferredDuration(){return this._transmuxer?._demuxer?.getBuferredDuration()}getBufferedSegments(){return this._transmuxer?._demuxer?.getSampleListLength()}getBufferedAudioSegments(){return this._transmuxer?._demuxer?.getSampleAudioListLength()}getBufferedVideoSegments(){return this._transmuxer?._demuxer?.getSampleVideoListLength()}createSource(e,t,i,r){if(this._sourceCreated)return;const s=e||t;s&&(ed.probe(s)?this._transmuxer||(this._transmuxer=new Qh(this.hls,!1)):qh.probe(s)?this._transmuxer||(this._transmuxer=new Qh(this.hls,!0)):this.player.debug.error(this.TAG_NAME,"createSource error: chunk is not ts"))}async appendBuffer(e,t,i,r,s,a,n){if(i?.length||r?.length)return this._needInitSegment,this._transmuxer.transmux(i,r,s,a,n,this._needInitSegment||s),!0}async clearAllBuffer(){this.player.debug.log(this.TAG_NAME,"clearAllBuffer")}decryptBuffer(e,t){return this._decryptor.decrypt(e,t)}async reset(e=!1){this._transmuxer=null,this._needInitSegment=!0,this._directAppend=!1}async endOfStream(){this._softVideo&&this._softVideo.endOfStream()}async setLiveSeekableRange(e,t){}seamlessSwitch(){this._needInitSegment=!0}}class Jh{constructor(e){this.emitter=e,this._seiSet=new Set,e.on(wr,(e=>{e&&this._seiSet.add(e)}))}throw(e){if(null==e||!this._seiSet.size)return;const t=e-.2,i=e+.2,r=[];this._seiSet.forEach((e=>{e.time>=t&&e.time<=i&&r.push(e)})),r.forEach((e=>{this._seiSet.delete(e),this.emitter.emit(Er,e)}))}reset(){this._seiSet.clear()}}class Zh{constructor(e){this._timescale=e,this.encodeType="",this.audioCodec="",this.videoCodec="",this.domain="",this.fps=0,this.bitrate=0,this.width=0,this.height=0,this.samplerate=0,this.channelCount=0,this.gop=0,this._bitsAccumulateSize=0,this._bitsAccumulateDuration=0}getStats(){return{encodeType:this.encodeType,audioCodec:this.audioCodec,videoCodec:this.videoCodec,domain:this.domain,fps:this.fps,bitrate:this.bitrate,width:this.width,height:this.height,samplerate:this.samplerate,channelCount:this.channelCount,gop:this.gop}}setEncodeType(e){this.encodeType=e}setFpsFromScriptData({data:e}){const t=e?.onMetaData?.framerate;t&&t>0&&t<100&&(this.fps=t)}setVideoMeta(e){if(this.width=e.width,this.height=e.height,this.videoCodec=e.codec,this.encodeType=e.codecType,e.fpsNum&&e.fpsDen){const t=e.fpsNum/e.fpsDen;t>0&&t<100&&(this.fps=t)}}setAudioMeta(e){this.audioCodec=e.codec,this.samplerate=e.sampleRate,this.channelCount=e.channelCount}setDomain(e){this.domain=e.split("/").slice(2,3)[0]}updateBitrate(e){if((!this.fps||this.fps>=100)&&e.length){const t=e.reduce(((e,t)=>e+t.duration),0)/e.length;this.fps=Math.round(this._timescale/t)}e.forEach((e=>{1===e.gopId&&this.gop++,this._bitsAccumulateDuration+=e.duration/(this._timescale/1e3),this._bitsAccumulateSize+=e.units.reduce(((e,t)=>e+t.length),0),this._bitsAccumulateDuration>=1e3&&(this.bitrate=8*this._bitsAccumulateSize,this._bitsAccumulateDuration=0,this._bitsAccumulateSize=0)}))}}class ec{_core=null;_samples=[];constructor(e,t=1e3){this._core=e,this._timescale=t,this._stats=new Zh(t),this._bindEvents()}getStats(){const{currentTime:e=0,decodeFps:t=0}=this._core?.media||{};return{...this._stats.getStats(),downloadSpeed:this._core?.speedInfo?.().speed||0,avgSpeed:this._core?.speedInfo?.().avgSpeed||0,currentTime:e,bufferEnd:this._core?.bufferInfo()?.remaining||0,decodeFps:t}}_bindEvents(){this._core.on(pr,(e=>this._stats.updateBitrate(e.samples))),this._core.on(fr,(e=>{this._stats.setFpsFromScriptData(e)})),this._core.on(yr,(e=>{"video"===e.type?this._stats.setVideoMeta(e.track):this._stats.setAudioMeta(e.track)})),this._core.on(mr,(e=>{this._stats.setDomain(e.responseUrl)}))}reset(){this._samples=[],this._stats=new Zh(this._timescale)}}class tc extends t{constructor(e,t={}){super(),this.player=e,this.config=null,this._manifestLoader=null,this._segmentLoader=null,this._playlist=null,this._bufferService=null,this._seiService=null,this._stats=null,this._prevSegSn=null,this._prevSegCc=null,this._tickTimer=null,this._tickInterval=500,this._segmentProcessing=!1,this._reloadOnPlay=!1,this._switchUrlOpts=null,this._disconnectTimer=null,this.TAG_NAME="Hls256",this.canVideoPlay=!1,this.$videoElement=null,this.config=t=function(e){return{isLive:!0,maxPlaylistSize:50,retryCount:3,retryDelay:1e3,pollRetryCount:2,loadTimeout:1e4,preloadTime:30,softDecode:!1,bufferBehind:10,maxJumpDistance:3,startTime:0,targetLatency:10,maxLatency:20,allowedStreamTrackChange:!0,...e}}(t),this._manifestLoader=new Dh(this),this._segmentLoader=new xh(this),this._playlist=new Ih(this),this._bufferService=new Xh(this),this._seiService=new Jh(this),this._stats=new ec(this,9e4),this.player.debug.log(this.TAG_NAME,"init")}async destroy(){this.player.debug.log(this.TAG_NAME,"destroy()"),this._playlist.reset(),this._segmentLoader.reset(),this._seiService.reset(),await Promise.all([this._clear(),this._bufferService.destroy()]),this._manifestLoader&&(await this._manifestLoader.destroy(),this._manifestLoader=null),this._segmentLoader&&(this._segmentLoader.destroy(),this._segmentLoader=null),this._playlist&&(this._playlist.destroy(),this._playlist=null),this.player.debug.log(this.TAG_NAME,"destroy end")}_startTick(){this._stopTick(),this._tickTimer=setTimeout((()=>{this._tick()}),this._tickInterval)}_stopTick(){this._tickTimer&&clearTimeout(this._tickTimer),this._tickTimer=null}_tick(){this.player.isDestroyedOrClosed()?this.player.debug.log(this.TAG_NAME,"_tick() player is destroyed"):(this._startTick(),this._loadSegment())}get isLive(){return this._playlist.isLive}get streams(){return this._playlist.streams}get currentStream(){return this._playlist.currentStream}get hasSubtitle(){return this._playlist.hasSubtitle}get baseDts(){return this._bufferService?.baseDts}speedInfo(){return this._segmentLoader.speedInfo()}resetBandwidth(){this._segmentLoader.resetBandwidth()}getStats(){return this._stats.getStats()}async loadSource(e){return await this._reset(),await this._loadData(e),this._startTick(),!0}async _loadData(e){try{e&&(e=e.trim())}catch(e){}if(!e)throw this._emitError(new oh(rh,rh,null,null,"m3u8 url is missing"));const t=await this._loadM3U8(e),{currentStream:i}=this._playlist;if(this._urlSwitching){0===i.bitrate&&this._switchUrlOpts?.bitrate&&(i.bitrate=this._switchUrlOpts?.bitrate);const e=this._getSeamlessSwitchPoint();this.config.startTime=e;const t=this._playlist.findSegmentIndexByTime(e),r=this._playlist.getSegmentByIndex(t+1);if(r){const e=r.start;this.player.debug.warn(this.TAG_NAME,`clear buffer from ${e}`)}}t&&(this.isLive?(this.player.debug.log(this.TAG_NAME,"is live"),this._bufferService.setLiveSeekableRange(0,4294967295),this.config.targetLatency<this._playlist.totalDuration&&(this.config.targetLatency=this._playlist.totalDuration,this.config.maxLatency=1.5*this.config.targetLatency),t.isMaster||this._pollM3U8(e)):(this.player.debug.log(this.TAG_NAME,`is vod and totalDuration is ${i.totalDuration} s`),await this._bufferService.updateDuration(i.totalDuration))),await this._loadSegment()}async _loadM3U8(e){let t;try{[t]=await this._manifestLoader.load(e)}catch(e){throw this._emitError(oh.create(e))}if(t)return this._playlist.upsertPlaylist(t),t.isMaster?(this._playlist.currentStream.subtitleStreams?.length&&this.emit(kr,{list:this._playlist.currentStream.subtitleStreams}),await this._refreshM3U8()):this.player.debug.warn(this.TAG_NAME,"_loadM3U8() is not master playlist"),this.emit(Cr),t;this.player.debug.warn(this.TAG_NAME,"_loadM3U8() playlist is empty")}_refreshM3U8(){this.player.debug.log(this.TAG_NAME,"_refreshM3U8()");const e=this._playlist.currentStream;if(!e||!e.url)throw this._emitError(oh.create(null,null,new Error("m3u8 url is not defined")));const t=e.url,i=e.currentAudioStream?.url,r=e.currentSubtitleStream?.url;return this._manifestLoader.load(t,i,r).then((([e,s,a])=>{e?(this._playlist.upsertPlaylist(e,s,a),this.isLive&&this._pollM3U8(t,i,r)):this.player.debug.warn(this.TAG_NAME,"_refreshM3U8() mediaPlaylist is empty")})).catch((e=>{throw this._emitError(oh.create(e))}))}_pollM3U8(e,t,i){let r=this._playlist.isEmpty;this._manifestLoader.poll(e,t,i,((e,t,i)=>{this._playlist.upsertPlaylist(e,t,i),this._playlist.clearOldSegment(),e&&r&&!this._playlist.isEmpty&&this._loadSegment(),r&&(r=this._playlist.isEmpty)}),(e=>{this._emitError(oh.create(e))}),1e3*(this._playlist.lastSegment?.duration||0))}_loadSegment=async()=>{if(this._segmentProcessing)return void this.player.debug.warn("_loadSegment()","_segmentProcessing is ture and return");if(!this._playlist)return void this.player.debug.warn("_loadSegment()","this._playlist is null and return");const e=this._playlist.currentSegment,t=this._playlist.nextSegment;if(this.player.debug.log(this.TAG_NAME,"_loadSegment()","curSeg",e&&e.url,"nextSeg",t&&t.url),t)return this._loadSegmentDirect();this.player.debug.log(this.TAG_NAME,"nextSeg is null and return")};async _loadSegmentDirect(){const e=this._playlist.nextSegment;if(!e)return void this.player.debug.log(this.TAG_NAME,"_loadSegmentDirect() !seg");let t=!1,i=null;try{this._segmentProcessing=!0,t=await this._reqAndBufferSegment(e,this._playlist.getAudioSegment(e))}catch(e){i=e}finally{this._segmentProcessing=!1}return i?this._emitError(oh.create(i)):(t?(this._urlSwitching&&(this._urlSwitching=!1,this.emit(Tr,{url:this.config.url})),this._playlist.moveSegmentPointer(),this.player.debug.log(this.TAG_NAME,"_loadSegmentDirect()","seg.isLast",e.isLast),e.isLast?(this.player.debug.log(this.TAG_NAME,"_loadSegmentDirect()","seg.isLast"),this._end()):(this.player.debug.log(this.TAG_NAME,"_loadSegmentDirect()","and next _loadSegment()"),this._loadSegment())):this.player.debug.log(this.TAG_NAME,"_loadSegmentDirect() not appended"),t)}async _reqAndBufferSegment(e,t){this.player.debug.log(this.TAG_NAME,"video seg",e&&e.url,"audio seg",t&&t.url);const i=e?e.cc:t.cc,r=this._prevSegCc!==i;let s=[];try{s=await this._segmentLoader.load(e,t,r)}catch(e){throw e.fatal=!1,this._segmentLoader.error=e,e}if(!s[0])return;const a=await this._bufferService.decryptBuffer(...s);if(!a)return void this.player.debug.log(this.TAG_NAME,"decryptBuffer return null");const n=e?e.sn:t.sn,o=e?e.start:t.start,l=this._playlist.currentStream;return this._bufferService.createSource(a[0],a[1],l?.videoCodec,l?.audioCodec),await this._bufferService.appendBuffer(e,t,a[0],a[1],r,this._prevSegSn===n-1,o),this._prevSegCc=i,this._prevSegSn=n,!0}async _clear(){this.player.debug.log(this.TAG_NAME,"_clear()"),clearTimeout(this._disconnectTimer),this._stopTick(),await Promise.all([this._segmentLoader.cancel(),this._manifestLoader.stopPoll()]),this._segmentProcessing=!1}async _reset(e=!1){return this.player.debug.log(this.TAG_NAME,"_reset()"),this._reloadOnPlay=!1,this._prevSegSn=null,this._prevSegCc=null,this._switchUrlOpts=null,this._playlist.reset(),this._segmentLoader.reset(),this._seiService.reset(),this._stats.reset(),await this._clear(),this._bufferService.reset(e)}_end(){this.player.debug.log(this.TAG_NAME,"_end()"),this._clear()}_emitError(e,t=!1){return!1===e.originError?.fatal?console.warn(e):(console.table(e),console.error(e),console.error(this.media?.error),this._stopTick(),this._urlSwitching&&(this._urlSwitching=!1,this.emit(Sr,e)),t&&this._end(),this._seiService.reset(),this.emit(Dr,e)),e}_getSeamlessSwitchPoint(){const{media:e}=this;let t=e.currentTime;if(!e.paused){const i=this._playlist.findSegmentIndexByTime(e.currentTime),r=this._playlist.getSegmentByIndex(i),s=this._stats?.getStats().downloadSpeed;if(s&&r){t+=r.duration*this._playlist.currentStream.bitrate/s+1}else t+=5}return t}getDemuxBuferredDuration(){return this._bufferService.getBuferredDuration()||0}getDemuxBufferedListLength(){return this._bufferService.getBufferedSegments()||0}getDemuxAudioBufferedListLength(){return this._bufferService.getBufferedAudioSegments()||0}getDemuxVideoBufferedListLength(){return this._bufferService.getBufferedVideoSegments()||0}}class ic extends t{TAG_NAME="Hls256Decoder";constructor(e){super(),this.player=e,this.$videoElement=this.player.video.$videoElement,this.hls=null,this.eventsDestroy=[],this.bandwidthEstimateInterval=null,this.hls=new tc(e),this._bindEvents()}async destroy(){return this._stopBandwidthEstimateInterval(),this.hls&&(await this.hls.destroy(),this.hls=null),this.eventsDestroy.length&&(this.eventsDestroy.forEach((e=>e())),this.eventsDestroy=[]),this.$videoElement=null,this.player.debug.log(this.TAG_NAME,"destroy"),!0}_bindEvents(){this.hls.on(Dr,(e=>{this.player.emitError(lt.hlsError,e)})),this._startBandwidthEstimateInterval()}_startBandwidthEstimateInterval(){this._stopBandwidthEstimateInterval(),this.bandwidthEstimateInterval=setInterval((()=>{const e=this.hls.speedInfo();this.player.emit(st.kBps,(e.avgSpeed/1024/8).toFixed(2)),this.hls.resetBandwidth()}),1e3)}_stopBandwidthEstimateInterval(){this.bandwidthEstimateInterval&&(clearInterval(this.bandwidthEstimateInterval),this.bandwidthEstimateInterval=null)}async loadSource(e){return this.url=e,await this.hls.loadSource(e),!0}checkHlsBufferedDelay(){let e=0;return this.hls&&(e=this.hls.getDemuxBuferredDuration()),e}getDemuxBufferedListLength(){let e=0;return this.hls&&(e=this.hls.getDemuxBufferedListLength()),e}getDemuxAudioBufferedListLength(){let e=0;return this.hls&&(e=this.hls.getDemuxAudioBufferedListLength()),e}getDemuxVideoBufferedListLength(){let e=0;return this.hls&&(e=this.hls.getDemuxVideoBufferedListLength()),e}}class rc extends t{constructor(e){super(),this.player=e,this.wsConnect=null,this.rtcContent=null,this.intervalTime=null,this.localStream=null,e.debug.log("wsRtcDecoder","init"),this.$videoElement=this.player.video.$videoElement,this.player.video.$videoElement.muted=!this.player._opt.isNotMute,this.candidateList=[],this.iceGatheringState=!1,this.interval=null}destroy(){this.intervalTime&&clearInterval(this.intervalTime),this.interval&&clearInterval(this.interval),this.rtcContent&&(this.rtcContent.close(),this.rtcContent=null,this.localStream=null,this.intervalTime=null,this.iceGatheringState=!1,this.candidateList=[]),this.wsConnect&&(this.wsConnect.close(),this.wsConnect=null),this.player.debug.log("wsRtcDecoder","destroy")}loadSource(e){return new Promise(((t,i)=>{this.wsConnect=new WebSocket(e),this.wsConnect.onopen=()=>{this.intervalTime=setInterval((()=>{this.wsConnect.send(JSON.stringify({type:"ping"}))}),4500),this.player.emit(st.rtcConnetMessage,"连接中..."),this.createMedia(),t()},this.wsConnect.onmessage=e=>{const t=JSON.parse(e.data);switch(t.type){case"sdp":this.rtcContent.setRemoteDescription(new RTCSessionDescription({sdp:t.sdp,type:"answer"})),this.player.emit(st.rtcConnetMessage,"接收视频信息...");break;case"candidate":case"pong":case"ErrSDP":case"ErrCandidate":case"Err":break;case"ErrKeepAlive":console.log("🚀 ~ CustomRTC ~ ErrKeepAlive: 服务端保活失败"),this.destroy()}},this.wsConnect.onclose=()=>{this.player.emit(st.rtcConnetMessage,"网络连接中断!"),this.destroy(),i()}}))}async createMedia(){this.localStream=await navigator.mediaDevices.getUserMedia({video:!1,audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),this.createPeer()}createPeer(){if(this.rtcContent=new RTCPeerConnection({bundlePolicy:"balanced",iceTransportPolicy:"relay",iceCandidatePoolSize:10,iceServers:this.player._opt.iceServers}),this.localStream){const e=this.localStream.getAudioTracks()[0];e.enabled=!1,this.rtcContent.addTrack(e,this.localStream)}this.rtcContent.addTransceiver("audio",{direction:"sendrecv"}),this.rtcContent.addTransceiver("video",{direction:"recvonly"}),this.rtcContent.onicecandidate=e=>{"complete"===this.rtcContent?.iceGatheringState?this.iceGatheringState=!0:e.candidate&&this.candidateList.push(JSON.stringify(e.candidate))},this.createOffer(),this.rtcContent.oniceconnectionstatechange=e=>{"checking"===this.rtcContent?.iceConnectionState&&this.player.emit(st.rtcConnetMessage,"正在检查视频源信息..."),"connected"===this.rtcContent?.iceConnectionState?this.player.emit(st.rtcConnetMessage,"[成功]建立视频连接"):"disconnected"===this.rtcContent?.iceConnectionState?this.player.emit(st.rtcConnetMessage,"[失败]视频连接已断开"):"failed"===this.rtcContent?.iceConnectionState&&this.player.emit(st.rtcConnetMessage,"[失败]视频连接失败")},this.rtcContent.ontrack=e=>{this.$videoElement.srcObject=e.streams[0]}}createOffer(){this.rtcContent.createOffer().then((e=>{this.rtcContent.setLocalDescription(e).then((e=>{this.player.emit(st.rtcConnetMessage,"获取客户端信息...");let t=0;this.interval=setInterval((()=>{if(t+=1,t>100||this.iceGatheringState){clearInterval(this.interval);const e=this.rtcContent?.localDescription;this.wsConnect?.send(JSON.stringify({channel_id:this.player._opt.channelId,connect_type:1,sdp:e?.sdp,type:"sdp"}))}}),10)}))}))}startVoice(){if(this.localStream){const e=this.localStream?.getAudioTracks()[0];e.enabled=!0}}pauseVoice(){if(this.localStream){const e=this.localStream?.getAudioTracks()[0];e.enabled=!1}}removeVoice(){this.localStream&&this.localStream.getTracks().forEach((e=>{e.stop()}))}}class sc extends t{constructor(e){super(),this.player=e,this.TAG_NAME="CommonWebrtc",this.rtcPeerConnection=null,this.videoStream=null,this.isDisconnected=!1,this.isH264=this.player.isWebrtcH264(),this.eventsDestroy=[],this.supportVideoFrameCallbackHandle=null,this.isInitInfo=!1,this.$videoElement=this.player.video.$videoElement,this.bandwidthEstimateInterval=null,this.rtcPeerTrackVideoReceiver=null,this.rtcPeerTrackAudioReceiver=null,this.prevWebrtcVideoStats={},this.prevWebrtcAudioStats={},this.currentWebrtcStats={},this.player._opt.webrtcUseCanvasRender&&this.isH264&&(this.$videoElement=document.createElement("video"),Is()&&(this.$videoElement.style.position="absolute"),this._initVideoEvents()),this.$videoElement.muted=!0,this._initRtcPeerConnection()}destroy(){this.isDisconnected=!1,this.isInitInfo=!1,this.prevWebrtcVideoStats={},this.currentWebrtcStats={},this.rtcPeerTrackVideoReceiver=null,this.rtcPeerTrackAudioReceiver=null,this._stopBandwidthEstimateInterval(),this.supportVideoFrameCallbackHandle&&this.$videoElement&&(this.$videoElement.cancelVideoFrameCallback(this.supportVideoFrameCallbackHandle),this.supportVideoFrameCallbackHandle=null),this.eventsDestroy.length&&(this.eventsDestroy.forEach((e=>e())),this.eventsDestroy=[]),this.isH264&&(this.videoStream&&(this.videoStream.getTracks().forEach((e=>e.stop())),this.videoStream=null),this.$videoElement.srcObject=null),this.rtcPeerConnection&&(this.rtcPeerConnection.onicecandidate=ys,this.rtcPeerConnection.ontrack=ys,this.rtcPeerConnection.onconnectionstatechange=ys,this.rtcPeerConnection.ondatachannel=ys,this.rtcPeerConnection.close(),this.rtcPeerConnection=null)}_initVideoEvents(){const{proxy:e}=this.player.events,t=e(this.$videoElement,Ei,(()=>{this.player.debug.log(this.TAG_NAME,"video canplay"),this.$videoElement.play().then((()=>{this.player.debug.log(this.TAG_NAME,"video play"),this._startCanvasRender(),this._initRenderSize()})).catch((e=>{this.player.debug.warn(this.TAG_NAME,"video play error ",e)}))})),i=e(this.$videoElement,Si,(()=>{this.player.debug.log("HlsDecoder","video waiting")})),r=e(this.$videoElement,Ti,(e=>{const t=parseInt(e.timeStamp,10);this.player.handleRender(),this.player.updateStats({ts:t}),this.$videoElement.paused&&(this.player.debug.warn("HlsDecoder","video is paused and next try to replay"),this.$videoElement.play().then((()=>{this.player.debug.log("HlsDecoder","video is paused and replay success")})).catch((e=>{this.player.debug.warn("HlsDecoder","video is paused and replay error ",e)})))})),s=e(this.$videoElement,ki,(()=>{this.player.debug.log("HlsDecoder","video playback Rate change",this.$videoElement&&this.$videoElement.playbackRate)}));this.eventsDestroy.push(t,i,r,s)}_initRtcPeerConnection(){const e=new RTCPeerConnection,t=this.player;e.addTransceiver("video",{direction:"recvonly"}),e.addTransceiver("audio",{direction:"recvonly"}),e.onsignalingstatechange=e=>{this.player.debug.log(this.TAG_NAME,"onsignalingstatechange",e)},e.oniceconnectionstatechange=i=>{this.player.debug.log(this.TAG_NAME,"oniceconnectionstatechange",e.iceConnectionState);const r=e.iceConnectionState;switch(this.player.emit(st.webrtcOnIceConnectionStateChange,r),this.isDisconnected="disconnected"===r,e.iceConnectionState){case"new":case"checking":case"closed":case"connected":case"completed":break;case"failed":t.emit(st.webrtcFailed);break;case"disconnected":t.emit(st.webrtcDisconnect);break;case"closed":t.emit(st.webrtcClosed)}},e.onicecandidate=e=>{this.player.debug.log(this.TAG_NAME,"onicecandidate",e),e.candidate&&this.player.debug.log(this.TAG_NAME,"Remote ICE candidate: ",e.candidate.candidate)},e.ontrack=t=>{if(this.player.debug.log(this.TAG_NAME,"ontrack",t),"video"===t.track.kind){this.player.debug.log(this.TAG_NAME,"ontrack video"),this.rtcPeerTrackVideoReceiver=e.getReceivers().find((function(e){return e.track===t.track})),this.rtcPeerTrackVideoReceiver&&this._startBandwidthEstimateInterval();let i=t.streams[0];this.$videoElement.autoplay=!0,this.$videoElement.srcObject=i,this.videoStream=i}else"audio"===t.track.kind&&(this.player.debug.log(this.TAG_NAME,"ontrack audio"),this.rtcPeerTrackAudioReceiver=e.getReceivers().find((function(e){return e.track===t.track})),this.rtcPeerTrackAudioReceiver&&this._startBandwidthEstimateInterval())},e.onicecandidateerror=e=>{this.player.debug.log(this.TAG_NAME,"onicecandidateerror",e),this.player.emitError(lt.webrtcIceCandidateError,e)},e.onconnectionstatechange=i=>{switch(this.player.debug.log(this.TAG_NAME,"onconnectionstatechange",i),this.player.emit(st.webrtcOnConnectionStateChange,e.connectionState),e.connectionState){case"new":case"connecting":case"connected":case"disconnected":break;case"failed":this.isDisconnected&&t.emit(st.webrtcFailed)}},this.rtcPeerConnection=e}_startBandwidthEstimateInterval(){this.player.debug.log(this.TAG_NAME,"_startBandwidthEstimateInterval"),this._stopBandwidthEstimateInterval(),this.bandwidthEstimateInterval=setInterval((()=>{this.rtcPeerTrackVideoReceiver&&this.rtcPeerTrackVideoReceiver.getStats().then((e=>{let t={},i=0;e.forEach((e=>{if(e)switch(e.type){case Gr:("succeeded"===e.state||e.bytesReceived)&&(this.currentWebrtcStats.timestamp=e.timestamp,this.currentWebrtcStats.rtt=e.currentRoundTripTime||-1,this.currentWebrtcStats.bytesReceived=e.bytesReceived||0,this.currentWebrtcStats.bytesSent=e.bytesSent||0);break;case Vr:this.currentWebrtcStats.remoteCandidate=e||{};break;case Wr:this.currentWebrtcStats.localCandidate=e||{};break;case zr:this.currentWebrtcStats.lastTimeStamp=e.timestamp;const r=((e.timestamp||0)-(this.prevWebrtcVideoStats.timestamp||0))/1e3,s=Number(e.bytesReceived||0)-Number(this.prevWebrtcVideoStats.bytesReceived||0),a=Math.floor(s/r);i+=a,t.vbps=a,this.prevWebrtcVideoStats=e;break;case Hr:e.frameWidth&&e.frameHeight&&(this.currentWebrtcStats.frameWidth=e.frameWidth||0,this.currentWebrtcStats.frameHeight=e.frameHeight||0)}})),this.rtcPeerTrackAudioReceiver?this.rtcPeerTrackAudioReceiver.getStats().then((e=>{e.forEach((e=>{if(e&&e.type===zr){this.currentWebrtcStats.lastTimeStamp=e.timestamp;const r=((e.timestamp||0)-(this.prevWebrtcAudioStats.timestamp||0))/1e3,s=Number(e.bytesReceived||0)-Number(this.prevWebrtcAudioStats.bytesReceived||0),a=Math.floor(s/r);i+=a,t.abps=a,this.prevWebrtcAudioStats=e}})),this.player.updateStats(t),this.player.emit(st.kBps,(i/1024).toFixed(2))})):(this.player.updateStats(t),this.player.emit(st.kBps,(i/1024).toFixed(2)))}))}),1e3)}_stopBandwidthEstimateInterval(){this.player.debug.log(this.TAG_NAME,"_stopBandwidthEstimateInterval"),this.bandwidthEstimateInterval&&(clearInterval(this.bandwidthEstimateInterval),this.bandwidthEstimateInterval=null)}_startCanvasRender(){Pa()?this.supportVideoFrameCallbackHandle=this.$videoElement.requestVideoFrameCallback(this.videoFrameCallback.bind(this)):(this._stopCanvasRender(),this.canvasRenderInterval=setInterval((()=>{this.player.video.render({$video:this.$videoElement,ts:0})}),40))}_stopCanvasRender(){this.canvasRenderInterval&&(clearInterval(this.canvasRenderInterval),this.canvasRenderInterval=null)}videoFrameCallback(e,t={}){this.player.isDestroyedOrClosed()?this.player.debug.log(this.TAG_NAME,"videoFrameCallback() player is destroyed"):(this.player.video.render({$video:this.$videoElement,ts:t.mediaTime||0}),this.player.updateStats({dts:t.mediaTime||0}),this.supportVideoFrameCallbackHandle=this.$videoElement.requestVideoFrameCallback(this.videoFrameCallback.bind(this)))}_initRenderSize(){this.isInitInfo||(this.player.video.updateVideoInfo({width:this.$videoElement.videoWidth,height:this.$videoElement.videoHeight}),this.player.video.initCanvasViewSize(),this.isInitInfo=!0)}getVideoCurrentTime(){let e=0;return this.$videoElement&&(e=this.$videoElement.currentTime),e}}class ac extends sc{constructor(e){super(e),this.rtcPeerConnectionDataChannel=null,this.player.isWebrtcH265()&&(this.streamRate=Ss((t=>{e.emit(st.kBps,(t/1024).toFixed(2))}))),this.TAG_NAME="WebrtcForM7SDecoder",this.player.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this.stopStreamRateInterval(),this.rtcPeerConnectionDataChannel&&(this.rtcPeerConnectionDataChannel.onopen=ys,this.rtcPeerConnectionDataChannel.onclose=ys,this.rtcPeerConnectionDataChannel.onmessage=ys,this.rtcPeerConnectionDataChannel.close(),this.rtcPeerConnectionDataChannel=null,this.rtcPeerConnection&&(this.rtcPeerConnection.close(),this.rtcPeerConnection.getSenders.forEach((e=>{e.track.stop()})),this.rtcPeerConnection.onicecandidate=null,this.rtcPeerConnection.ontrack=null,this.rtcPeerConnection.ondatachannel=null,this.rtcPeerConnection=null)),this.player.debug.log(this.TAG_NAME,"destroy")}_initRtcPeerConnection(){const e=new RTCPeerConnection,t=this.player;e.addTransceiver("video",{direction:"recvonly"}),e.addTransceiver("audio",{direction:"recvonly"}),e.onsignalingstatechange=e=>{this.player.debug.log(this.TAG_NAME,"onsignalingstatechange",e)},e.oniceconnectionstatechange=i=>{this.player.debug.log(this.TAG_NAME,"oniceconnectionstatechange",e.iceConnectionState);const r=e.iceConnectionState;switch(this.player.emit(st.webrtcOnIceConnectionStateChange,r),this.isDisconnected="disconnected"===r,e.iceConnectionState){case"new":case"checking":case"closed":case"connected":case"completed":break;case"failed":t.emit(st.webrtcFailed);break;case"disconnected":t.emit(st.webrtcDisconnect);break;case"closed":t.emit(st.webrtcClosed)}},e.onicecandidate=e=>{this.player.debug.log(this.TAG_NAME,"onicecandidate",e),e.candidate&&this.player.debug.log(this.TAG_NAME,"Remote ICE candidate: ",e.candidate.candidate)},e.ontrack=i=>{this.player.debug.log(this.TAG_NAME,"ontrack",i);const r=t.video.$videoElement;if(t.isWebrtcH264())if("video"===i.track.kind){this.player.debug.log(this.TAG_NAME,"ontrack video"),this.rtcPeerTrackVideoReceiver=e.getReceivers().find((function(e){return e.track===i.track})),this.rtcPeerTrackVideoReceiver&&this._startBandwidthEstimateInterval();let t=i.streams[0];r.autoplay=!0,r.srcObject=t,this.videoStream=t}else"audio"===i.track.kind&&(this.player.debug.log(this.TAG_NAME,"ontrack audio"),this.rtcPeerTrackAudioReceiver=e.getReceivers().find((function(e){return e.track===i.track})),this.rtcPeerTrackAudioReceiver&&this._startBandwidthEstimateInterval())},e.onicecandidateerror=e=>{this.player.debug.log(this.TAG_NAME,"onicecandidateerror",e),this.player.emitError(lt.webrtcIceCandidateError,e)},e.onconnectionstatechange=i=>{switch(t.debug.log(this.TAG_NAME,`sdp connect status ${e.connectionState}`),e.connectionState){case"new":case"connecting":case"connected":case"disconnected":break;case"failed":this.isDisconnected&&t.emit(st.webrtcFailed)}},e.ondatachannel=e=>{const t=e.channel;this.player.debug.log(this.TAG_NAME,"ondatachannel"),t.onopen=()=>{this.player.debug.log(this.TAG_NAME,"ondatachannel and onopen")},t.onmessage=e=>{const t=e.data;if(this.player.isWebrtcH264())return this.player.debug.warn(this.TAG_NAME,"ondatachannel is H265 but decode is h264 so emit webrtcStreamH265 "),void this.player.emit(st.webrtcStreamH265);this.player.isDestroyedOrClosed()?this.player.debug.warn(this.TAG_NAME,"ondatachannel and player is destroyed"):(this.streamRate&&this.streamRate(t.byteLength),this.player.demux&&this.player.demux.dispatch(t))},t.onclose=()=>{this.player.debug.warn(this.TAG_NAME,"ondatachannel and onclose")},this.rtcPeerConnectionDataChannel=t};e.createDataChannel("signal").onmessage=e=>{this.player.debug.log(this.TAG_NAME,"signalChannel,onmessage",e);JSON.parse(e.data).type},this.rtcPeerConnection=e}startStreamRateInterval(){this.stopStreamRateInterval(),this.streamRateInterval=setInterval((()=>{this.streamRate&&this.streamRate(0)}),1e3)}stopStreamRateInterval(){this.streamRateInterval&&(clearInterval(this.streamRateInterval),this.streamRateInterval=null)}loadSource(e,t={}){return new Promise(((t,i)=>{const r=this.rtcPeerConnection;r.createOffer().then((s=>{r.setLocalDescription(s),this.player.debug.log(this.TAG_NAME,"getWebRtcRemoteSdp loadSource"),function(e,t){return fetch(e,{method:"POST",cache:"no-cache",redirect:"follow",referrerPolicy:"no-referrer",headers:{"Content-Type":"application/sdp"},body:t})}(e,s.sdp).then((e=>{e.text().then((e=>{this.player.debug.log(this.TAG_NAME,"getWebRtcRemoteSdp response"),e?r.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:e})).then((()=>{this.player.isWebrtcH265()&&this.startStreamRateInterval(),t()})).catch((e=>{i(e)})):i("sdp is null")})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource response.text() error",e),i(e)}))})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource getWebRtcRemoteSdp response error",e),i(e)}))})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource rtcPeerConnection.createOffer() error",e),i(e)}))}))}}class nc extends sc{constructor(e){super(e),this.TAG_NAME="WebrtcForZLMDecoder",this.player.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this.player.debug.log(this.TAG_NAME,"destroy")}loadSource(e){return new Promise(((t,i)=>{const r=this.rtcPeerConnection;r.createOffer().then((s=>{r.setLocalDescription(s),this.player.debug.log(this.TAG_NAME,"getWebRtcRemoteSdp loadSource"),function(e,t){return Io({url:e,type:"POST",data:t,contentType:"text/plain;charset=utf-8",processData:!1,dataType:"json"})}(e,s.sdp).then((e=>{this.player.debug.log(this.TAG_NAME,`getWebRtcRemoteSdp response and code is ${e.code}`);const s=e;if(s&&0!==s.code)return i(s.msg);s&&s.sdp?r.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:s.sdp})).then((()=>{t()})).catch((e=>{i(e)})):i("sdp is null")})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource getWebRtcRemoteSdp response error",e),i(e)}))})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource rtcPeerConnection.createOffer() error",e),i(e)}))}))}}class oc extends t{constructor(e,t){if(super(),this.player=e,this.player.$container.classList.add("easyplayer-container-playback"),this._showPrecision=null,this._startTime=null,this._playStartTime=null,this._playingTimestamp=null,this._fps=parseInt(t.fps,10)||e._opt.playbackFps,this._isUseFpsRender=!!Ta(t.isUseFpsRender),this._rate=1,this._audioTimestamp=0,this._videoTimestamp=0,this.controlType=t.controlType||Z.normal,t.controlType&&-1===[Z.normal,Z.simple].indexOf(t.controlType)&&(this.player.debug.warn("Playback","constructor()","controlType is not in [normal,simple]",t.controlType),this.controlType=Z.normal),this._currentLocalTimestamp=0,this._localOneFrameTimestamp=t.localOneFrameTimestamp||40,this._localCalculateTimeInterval=null,this._isUseLocalCalculateTime=!!Ta(t.isUseLocalCalculateTime),this._isPlaybackPauseClearCache=!ka(t.isPlaybackPauseClearCache),this._isCacheBeforeDecodeForFpsRender=!!Ta(t.isCacheBeforeDecodeForFpsRender),this._startfpsTime=null,this._startFpsTimestamp=null,this._checkStatsInterval=null,this._playbackTs=0,this._renderFps=0,this._isUseLocalCalculateTime?this._startLocalCalculateTime():this._listen(),this.playbackList=[],this._playbackListStartTimestamp=null,this._totalDuration=0,t.controlType===Z.normal)this.initPlaybackList(t.playList,t.showPrecision,t.startTime);else if(t.controlType===Z.simple){t.duration&&(this._totalDuration=1e3*t.duration);let e=t.startTime||0;e>this.totalDuration&&(e=this.totalDuration),this.setStartTime(e)}this.player.on(st.playbackPause,(e=>{e?this.pause():this.resume()}));const i={fps:this._fps,isUseFpsRender:this._isUseFpsRender,localOneFrameTimestamp:this._localOneFrameTimestamp,isUseLocalCalculateTime:this._isUseLocalCalculateTime,uiUsePlaybackPause:t.uiUsePlaybackPause,showControl:t.showControl};e.debug.log("Playback","init",JSON.stringify(i))}destroy(){this._startTime=null,this._showPrecision=null,this._playStartTime=null,this._playingTimestamp=null,this._totalDuration=0,this._audioTimestamp=0,this._videoTimestamp=0,this._fps=null,this._isUseFpsRender=!1,this._rate=1,this.playbackList=[],this._playbackListStartTimestamp=null,this._localCalculateTimeInterval=null,this._currentLocalTimestamp=0,this._startfpsTime=null,this._startFpsTimestamp=null,this._renderFps=0,this._playbackTs=0,this._stopLocalCalculateTime(),this.clearStatsInterval(),this.player.$container&&this.player.$container.classList.remove("easyplayer-container-playback"),this.off(),this.player.debug.log("Playback","destroy")}_listen(){this.player.on(st.stats,(e=>{const t=e.ts;this._playStartTime||(this._playStartTime=t-1e3);let i=t-this._playStartTime;this.setPlayingTimestamp(i)}))}pause(){this.clearStatsInterval()}resume(){this.startCheckStatsInterval()}updateStats(e={}){this._startFpsTimestamp||(this._startFpsTimestamp=vs()),Ks(e.ts)&&(this.player.updateStats({fps:!0,ts:e.ts}),this._playbackTs=e.ts,this._startfpsTime||(this._startfpsTime=e.ts),this._renderFps+=1);const t=vs(),i=t-this._startFpsTimestamp;if(i<1e3)return;let r=null;this._startfpsTime&&(r=this._playbackTs-this._startfpsTime),this.player.emit(st.playbackStats,{fps:this._renderFps,rate:this.rate,start:this._startfpsTime,end:this._playbackTs,timestamp:i,dataTimestamp:r,audioBufferSize:this.player.audio?this.player.audio.bufferSize:0,videoBufferSize:this.player.video?this.player.video.bufferSize:0,ts:this._playbackTs}),this._renderFps=0,this._startfpsTime=this._playbackTs,this._startFpsTimestamp=t}updateLocalOneFrameTimestamp(e){this._localOneFrameTimestamp=e}_startLocalCalculateTime(){this._stopLocalCalculateTime(),this._localCalculateTimeInterval=setInterval((()=>{const e=this._currentLocalTimestamp;this._playStartTime||(this._playStartTime=e-1e3);let t=e-this._playStartTime;this.setPlayingTimestamp(t)}),1e3)}startCheckStatsInterval(){this.clearStatsInterval(),this._checkStatsInterval=setInterval((()=>{this.updateStats()}),1e3)}_stopLocalCalculateTime(){this._localCalculateTimeInterval&&(clearInterval(this._localCalculateTimeInterval),this._localCalculateTimeInterval=null)}clearStatsInterval(){this._checkStatsInterval&&(clearInterval(this._checkStatsInterval),this._checkStatsInterval=null)}increaseLocalTimestamp(){this._isUseLocalCalculateTime&&(this._currentLocalTimestamp+=this._localOneFrameTimestamp)}initPlaybackList(e,t,i){this.playbackList=e||[];let r=0;if(this.playbackList.forEach(((e,t)=>{10===ia(e.start)&&(e.startTimestamp=1e3*e.start,e.startTime=Ps(e.startTimestamp)),10===ia(e.end)&&(e.endTimestamp=1e3*e.end,e.endTime=Ps(e.endTimestamp)),e.duration=e.end-e.start,r+=e.duration})),this._totalDuration=r,this.player.debug.log("Playback",this.playbackList),this.playbackList.length>0){const e=this.playbackList[0].startTimestamp;this._playbackListStartTimestamp=e;let t=e;i&&(10===ia(i)&&(i*=1e3),this._isTimeInPlaybackList(i)&&(t=i)),this.setStartTime(t)}const s=t||ii;this.setShowPrecision(s)}get totalDuration(){return(this._totalDuration||0)/1e3}get startTime(){return this._startTime||0}setStartTime(e){this._startTime=e,this._playingTimestamp=e,this._playStartTime=null}setRate(e){this._rate=e,this.player.emit(st.playbackRateChange,e)}get fps(){return this._fps}get rate(){return this._rate}get isUseFpsRender(){return this._isUseFpsRender}get isUseLocalCalculateTime(){return this._isUseLocalCalculateTime}get showPrecision(){return this._showPrecision}get is60Min(){return this.showPrecision===ii}get is30Min(){return this.showPrecision===ri}get is10Min(){return this.showPrecision===si}get is5Min(){return this.showPrecision===ai}get is1Min(){return this.showPrecision===ai}get isPlaybackPauseClearCache(){return this._isPlaybackPauseClearCache}get isCacheBeforeDecodeForFpsRender(){return this._isCacheBeforeDecodeForFpsRender}setShowPrecision(e){oi.includes(e)||(this.player.debug.warn("Playback","setShowPrecision()","type is not in PLAYBACK_CONTROL_TIME_PRECISION_ARRAY",e),e=ii),this._showPrecision&&this._showPrecision===e||(this._showPrecision=e,this.player.emit(st.playbackPrecision,this._showPrecision,this.playbackList),this.player.emit(st.playbackShowPrecisionChange,this._showPrecision))}setPlayingTimestamp(e){let t;if(this.controlType===Z.normal){t=this.startTime+e,this._playingTimestamp=t,this.player.emit(st.playbackTime,t);const i=new Date(t);this.player.emit(st.playbackTimestamp,{ts:t,hour:i.getHours(),min:i.getMinutes(),second:i.getSeconds()})}else this.controlType===Z.simple&&(t=this.startTime+Math.round(e/1e3),t>this.totalDuration&&(this.player.debug.log("Playback","setPlayingTimestamp()",`timestamp ${t} > this.totalDuration ${this.totalDuration}`),t=this.totalDuration),console.log(t),this._playingTimestamp=t,this.player.emit(st.playbackTime,t),this.player.emit(st.playbackTimestamp,{ts:t}))}get playingTimestamp(){return this._playingTimestamp}narrowPrecision(){const e=oi.indexOf(this.showPrecision)-1;if(e>=0){const t=oi[e];this.setShowPrecision(t)}}expandPrecision(){const e=oi.indexOf(this.showPrecision)+1;if(e<=oi.length-1){const t=oi[e];this.setShowPrecision(t)}}seek(e){if(this.player.debug.log("Playback","seek()",e),this.controlType===Z.normal){if("true"===e.hasRecord){let t=e.time;"min"===e.type&&(t=60*e.time);let i=function(e){let t={};e>-1&&(t={hour:Math.floor(e/60/60)%60,min:Math.floor(e/60)%60,second:e%60});return t}(t);if(this._playbackListStartTimestamp){const e=new Date(this._playbackListStartTimestamp).setHours(i.hour,i.min,i.second,0);i.timestamp=e;const t=this._findMoreInfoByTimestamp(e);i&&t.more&&(i.more=t.more)}this.player.emit(st.playbackSeek,i)}}else if(this.controlType===Z.simple){let t=e.time;this.player.emit(st.playbackSeek,{ts:t})}}currentTimeScroll(){this.player.emit(st.playbackTimeScroll)}_findMoreInfoByTimestamp(e){let t=null;return this.playbackList.forEach(((i,r)=>{i.startTimestamp<=e&&i.endTimestamp>=e&&(t=i)})),t}_isTimeInPlaybackList(e){let t=!1;return this.playbackList.forEach(((i,r)=>{i.startTimestamp<=e&&i.endTimestamp>=e&&(t=!0)})),t}getControlType(){return this.controlType}isControlTypeNormal(){return this.controlType===Z.normal}isControlTypeSimple(){return this.controlType===Z.simple}}class lc extends t{constructor(e){super(),this.player=e,this.TAG_NAME="zoom",this.bindEvents=[],this.isDragging=!1,this.currentZoom=1,this.prevVideoElementStyleTransform=null,this.prevVideoElementStyleScale=null,this.maxScale=5,this.tempPosition={x:0,y:0},this.videoPosition={left:0,top:0};const{events:{proxy:t},debug:i}=this.player;this.player.on(st.zooming,(e=>{if(e){this.player.$container.classList.add("easyplayer-zoom-control"),this._bindEvents();const e=this.player.video.$videoElement.style.transform;let t=this.player.video.$videoElement.style.left,i=this.player.video.$videoElement.style.top;t=parseFloat(t),i=parseFloat(i),t&&(this.videoPosition.left=t),i&&(this.videoPosition.top=i),this.prevVideoElementStyleTransform=e;let r=e.match(/scale\([0-9., ]*\)/g);if(r&&r[0]){let e=r[0].replace("scale(","").replace(")","");this.prevVideoElementStyleScale=e.split(",")}}else{this.player.$container.classList.remove("easyplayer-zoom-control"),this._unbindEvents(),this._resetVideoPosition(),this.player.$container.style.cursor="auto";let e=this.prevVideoElementStyleTransform;this.player.video.$videoElement.style.transform=e,this.prevVideoElementStyleTransform=null,this.prevVideoElementStyleScale=null,ks()&&this.player._opt.useWebFullScreen&&this.player.resize()}}));const r=t(window,ks()?"touchend":"mouseup",(e=>{this.handleMouseUp(e)}));this.bindEvents.push(r),e.debug.log("zoom","init")}destroy(){this.bindEvents=[],this.isDragging=!1,this.currentZoom=1,this.prevVideoElementStyleTransform=null,this.prevVideoElementStyleScale=null,this.tempPosition={x:0,y:0},this.videoPosition={left:0,top:0},this.off(),this.player.debug.log("zoom","destroy")}_bindEvents(){const{events:{proxy:e},debug:t}=this.player,i=e(this.player.$container,ks()?"touchmove":"mousemove",(e=>{this.handleMouseMove(e)}));this.bindEvents.push(i);const r=e(this.player.$container,ks()?"touchstart":"mousedown",(e=>{this.handleMouseDown(e)}));this.bindEvents.push(r);const s=e(window,ks()?"touchend":"mouseup",(e=>{this.handleMouseUp(e)}));this.bindEvents.push(s)}_unbindEvents(){this.bindEvents.forEach((e=>{e&&e()}))}handleMouseMove(e){if(e.stopPropagation(),this.isDragging&&this.player.zooming){e.preventDefault();const{posX:t,posY:i}=ca(e),r=this.tempPosition.x-t,s=this.tempPosition.y-i;this.videoPosition.left=this.videoPosition.left-r,this.videoPosition.top=this.videoPosition.top-s,this.tempPosition.x=t,this.tempPosition.y=i,this.updateVideoPosition()}}handleMouseDown(e){e.stopPropagation();const t=la(e);if(this.player.zooming&&(t.matches("video")||t.matches("canvas"))){e.preventDefault();const{posX:t,posY:i}=ca(e);this.player.$container.style.cursor="grabbing",this.tempPosition.x=t,this.tempPosition.y=i,this.isDragging=!0,this.player.debug.log("zoom","handleMouseDown is dragging true")}}handleMouseUp(e){e.stopPropagation(),this.isDragging&&this.player.zooming&&(e.preventDefault(),this.tempPosition={x:0,y:0},this.isDragging=!1,this.player.$container.style.cursor="grab",this.player.debug.log("zoom","handleMouseUp is dragging false"))}updateVideoPosition(){const e=this.player.video.$videoElement;e.style.left=this.videoPosition.left+"px",e.style.top=this.videoPosition.top+"px"}_resetVideoPosition(){this.player.resize(),this.tempPosition={x:0,y:0},this.videoPosition={left:0,top:0},this.currentZoom=1,this.isDragging=!1}narrowPrecision(){this.currentZoom<=1||(this.currentZoom-=1,this.updateVideoElementScale())}expandPrecision(){this.currentZoom>=this.maxScale||(this.currentZoom+=1,this.updateVideoElementScale())}updatePrevVideoElementStyleScale(e){this.prevVideoElementStyleScale=e}updateVideoElementScale(){const e=this.player.video.$videoElement;let t=e.style.transform,i=1,r=1;if(this.prevVideoElementStyleScale){const e=this.prevVideoElementStyleScale[0];void 0!==e&&(i=e,r=e);const t=this.prevVideoElementStyleScale[1];void 0!==t&&(r=t)}r=Ms(r),i=Ms(i);const s=.5*i*(this.currentZoom-1)+i,a=.5*r*(this.currentZoom-1)+r;let n;n=-1===t.indexOf("scale(")?t+` scale(${s},${a})`:t.replace(/scale\([0-9., ]*\)/,`scale(${s},${a})`),this.player.debug.log("zoom",`updateVideoElementScale end is ${s}, ${a} style is ${n}`),e.style.transform=n}}class dc extends t{constructor(e){super(),this.player=e,this.faceDetector=null,this.objectDetector=null,this.imageDetector=null,this.occlusionDetector=null,this.initFaceDetector(),this.initObjectDetector(),this.initImageDetector(),this.initOcclusionDetector();let t="init";this.faceDetector&&(t+=" and use faceDetector"),this.objectDetector&&(t+=" and use objectDetector"),this.imageDetector&&(t+=" and use imageDetector"),this.occlusionDetector&&(t+=" and use occlusionDetector"),this.player.debug.log("AiLoader",t)}destroy(){this.off(),this.faceDetector&&(this.faceDetector.destroy(),this.faceDetector=null),this.objectDetector&&(this.objectDetector.destroy(),this.objectDetector=null),this.imageDetector&&(this.imageDetector.destroy(),this.imageDetector=null),this.occlusionDetector&&(this.occlusionDetector.destroy(),this.occlusionDetector=null),this.player.debug.log("AiLoader","destroy")}initFaceDetector(){if(this.player._opt.useFaceDetector&&window.EasyPlayerProFaceDetector){const e=new EasyPlayerProFaceDetector({detectWidth:this.player._opt.aiFaceDetectWidth,showRect:!1,debug:this.player._opt.debug,debugLevel:this.player._opt.debugLevel,debugUuid:this.player._opt.debugUuid});e.load().then((()=>{this.player.debug.log("AiLoader","init face detector success"),this.faceDetector=e,this.faceDetector.on("easyplayer-pro-face-detector-info",(e=>{if(this.player.emit(st.aiFaceDetectorInfo,e),this.player._opt.aiFaceDetectShowRect){const t=this.player._opt.aiFaceDetectRectConfig||{},i=(e.list||[]).map((e=>(e.type="rect",e.color=t.borderColor||"#0000FF",e.lineWidth=t.borderWidth||2,e)));this.player.video&&this.player.video.addAiContentToCanvas(i)}}))}))}}initObjectDetector(){if(this.player._opt.useObjectDetector&&window.EasyPlayerProObjectDetector){const e=new EasyPlayerProObjectDetector({detectWidth:this.player._opt.aiObjectDetectWidth,showRect:!1,debug:this.player._opt.debug,debugLevel:this.player._opt.debugLevel,debugUuid:this.player._opt.debugUuid});e.load().then((()=>{this.player.debug.log("AiLoader","init object detector success"),this.objectDetector=e,this.objectDetector.on("easyplayer-pro-object-detector-info",(e=>{if(this.player.emit(st.aiObjectDetectorInfo,e),this.player._opt.aiObjectDetectShowRect){const t=[],i=this.player._opt.aiObjectDetectRectConfig||{};(e.list||[]).forEach((e=>{const r={type:"rect",color:i.borderColor||"#0000FF",lineWidth:i.borderWidth||2,x:e.rect.x,y:e.rect.y,width:e.rect.width,height:e.rect.height},s={type:"text",color:i.color||"#000",fontSize:i.fontSize||14,text:e.zh,x:e.rect.x,y:e.rect.y-25};t.push(r,s)})),this.player.video&&this.player.video.addAiContentToCanvas(t)}}))}))}}initImageDetector(){if(this.player._opt.useImageDetector&&window.EasyPlayerProImageDetector){const e=new EasyPlayerProImageDetector({debug:this.player._opt.debug,debugLevel:this.player._opt.debugLevel,debugUuid:this.player._opt.debugUuid});e.load().then((()=>{this.player.debug.log("AiLoader","init image detector success"),this.imageDetector=e}))}}initOcclusionDetector(){if(this.player._opt.useOcclusionDetector&&window.EasyPlayerProOcclusionDetector){const e=new EasyPlayerProOcclusionDetector({debug:this.player._opt.debug,debugLevel:this.player._opt.debugLevel,debugUuid:this.player._opt.debugUuid});e.load().then((()=>{this.player.debug.log("AiLoader","init occlusion detector success"),this.occlusionDetector=e}))}}updateFaceDetectorConfig(e={}){this.faceDetector&&this.faceDetector.updateConfig(e)}updateObjectDetectorConfig(e={}){this.objectDetector&&this.objectDetector.updateConfig(e)}updateImageDetectorConfig(e={}){this.imageDetector&&this.imageDetector.updateConfig(e)}updateOcclusionDetectorConfig(e={}){this.occlusionDetector&&this.occlusionDetector.updateConfig(e)}}class hc extends t{constructor(e){super(),this.player=e,this.LOG_NAME="Contextmenu",this.menuList=[],this.$contextmenus=e.control.$contextmenus,ks()?this.player.debug.warn(this.LOG_NAME,"not support mobile"):this.init(),e.debug.log(this.LOG_NAME,"init")}destroy(){this.menuList=[],this.player.debug.log(this.LOG_NAME,"destroy")}get isShow(){return e=this.player.$container,t="easyplayer-contextmenus-show",e.classList.contains(t);var e,t}show(){var e,t;e=this.player.$container,t="easyplayer-contextmenus-show",e.classList.add(t)}hide(){var e,t;e=this.player.$container,t="easyplayer-contextmenus-show",e.classList.remove(t)}init(){const{events:{proxy:e},debug:t}=this.player;this.player._opt.contextmenuBtns.length>0&&this.player._opt.contextmenuBtns.forEach((e=>{this.addMenuItem(e)})),e(this.player.$container,"contextmenu",(e=>{e.preventDefault(),this.show();const t=e.clientX,i=e.clientY,{height:r,width:s,left:a,top:n}=this.player.$container.getBoundingClientRect(),{height:o,width:l}=this.$contextmenus.getBoundingClientRect();let d=t-a,h=i-n;t+l>a+s&&(d=s-l),i+o>n+r&&(h=r-o),_s(this.$contextmenus,{left:`${d}px`,top:`${h}px`})})),e(this.player.$container,"click",(e=>{Ed(e,this.$contextmenus)||this.hide()})),this.player.on(st.blur,(()=>{this.hide()}))}_validateMenuItem(e){let t=!0;return e.content||(this.player.debug.warn(this.LOG_NAME,"content is required"),t=!1),t}addMenuItem(e={}){const t=_a(sr);if(e=Object.assign({},t,e),!this._validateMenuItem(e))return;const{events:{proxy:i},debug:r}=this.player,s=Us(),a=`\n <div class="easyplayer-contextmenu easyplayer-contextmenu-${s}">\n ${e.content}\n </div>\n `,n=Array.from(this.$contextmenus.children)[e.index];n?n.insertAdjacentHTML("beforebegin",a):_d(this.$contextmenus,a);const o=this.$contextmenus.querySelector(`.easyplayer-contextmenu-${s}`);e.click&&i(o,"click",(t=>{t.preventDefault(),e.click.call(this.player,this,t),this.hide()})),this.menuList.push({uuid:s,$menuItem:o})}}class cc extends sc{constructor(e){super(e),this.TAG_NAME="WebrtcForSRSDecoder",this.player.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this.player.debug.log(this.TAG_NAME,"destroy")}loadSource(e){return new Promise(((t,i)=>{const r=this.rtcPeerConnection;r.createOffer().then((s=>{r.setLocalDescription(s),this.player.debug.log(this.TAG_NAME,"getWebRtcRemoteSdp loadSource"),function(e,t){return fetch(e,{method:"POST",cache:"no-cache",redirect:"follow",referrerPolicy:"no-referrer",headers:{"Content-Type":"application/sdp"},body:t})}(e,s.sdp).then((e=>{this.player.debug.log(this.TAG_NAME,`getWebRtcRemoteSdp response and code is ${e.code}`);const s=e;if(s&&0!==s.code)return i(s.msg);s?r.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:s})).then((()=>{t()})).catch((e=>{i(e)})):i("sdp is null")})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource getWebRtcRemoteSdp response error",e),i(e)}))})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource rtcPeerConnection.createOffer() error",e),i(e)}))}))}}class uc extends sc{constructor(e){super(e),this.TAG_NAME="WebrtcForOthersDecoder",this.player.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this.player.debug.log(this.TAG_NAME,"destroy")}loadSource(e){return new Promise(((t,i)=>{const r=this.rtcPeerConnection;r.createOffer().then((s=>{r.setLocalDescription(s),this.player.debug.log(this.TAG_NAME,"getWebRtcRemoteSdp loadSource"),function(e,t){return fetch(e,{method:"POST",cache:"no-cache",redirect:"follow",referrerPolicy:"no-referrer",headers:{"Content-Type":"application/sdp"},body:t})}(e,s.sdp).then((e=>{this.player.debug.log(this.TAG_NAME,`getWebRtcRemoteSdp response and code is ${e.code}`),e.text().then((e=>{this.player.debug.log(this.TAG_NAME,"getWebRtcRemoteSdp response");try{let t=JSON.parse(e);this.player.debug.log(this.TAG_NAME,"this is json sdp response"),0!=t.code&&(this.player.debug.log(this.TAG_NAME,`response json code ${t.code}`),i(new Error(`response sdp json code: ${t.code}`))),e=t.sdp}catch(e){this.player.debug.log(this.TAG_NAME,"this is raw sdp response")}e?r.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:e})).then((()=>{t()})).catch((e=>{i(e)})):i("sdp is null")})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource response.text() error",e),i(e)}))})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource getWebRtcRemoteSdp response error",e),i(e)}))})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource rtcPeerConnection.createOffer() error",e),i(e)}))}))}}class pc extends t{constructor(e){if(super(),this.TAG_NAME="AliyunRtc",this.player=e,!window.AliRTS)throw new Error("AliyunRtc is not defined");this.aliyunRtc=window.AliRTS.createClient(),this.aliyunRtcRemoteStream=null,this.$videoElement=this.player.video.$videoElement,this.listenEvents(),this.player.debug.log(this.TAG_NAME,"init")}destroy(){this.aliyunRtc&&(this.aliyunRtcRemoteStream&&(this.aliyunRtcRemoteStream=null),this.aliyunRtc.unsubscribe(),this.aliyunRtc=null),this.off(),this.player.debug.log(this.TAG_NAME,"destroy")}listenEvents(){this.aliyunRtc.on("onError",(e=>{this.player.debug.log(this.TAG_NAME,`onError and code is ${e.errorCode} and message: ${e.message}`),10400!==e.errorCode&&(this.player.debug.error(this.TAG_NAME,`onError and code is ${e.errorCode} and message: ${e.message}`),this.player.emitError(lt.aliyunRtcError,e))})),this.aliyunRtc.on("reconnect",(e=>{this.player.debug.log(this.TAG_NAME,"reconnect",e)}));const e="canplay",t="waiting",i="playing",r="media";this.aliyunRtc.on("onPlayEvent",(s=>{if(s.event===e)this.player.debug.log(this.TAG_NAME,"onPlayEvent and canplay");else if(s.event===t)this.player.debug.log(this.TAG_NAME,"onPlayEvent and playing - > waiting");else if(s.event===i)this.player.debug.log(this.TAG_NAME,"onPlayEvent and waiting -> playing");else if(s.event===r){const e=s.data;let t={},i=0;if(e.audio){const r=Math.floor(e.audio.bytesReceivedPerSecond);i+=r,t.abps=r}if(e.video){const r=Math.floor(e.video.bytesReceivedPerSecond);i+=r,t.vbps=r}this.player.updateStats(t),this.player.emit(st.kBps,(i/1024).toFixed(2))}}))}loadSource(e){return new Promise(((t,i)=>{this.aliyunRtc.isSupport({isReceiveVideo:!0}).then((()=>{this.aliyunRtc.subscribe(e,{}).then((e=>{this.aliyunRtcRemoteStream=e,e.play(this.$videoElement),t()})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource and subscribe is not success: ",e.message),i(e.message)}))})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource and is not support: ",e.message),i(e.message)}))}))}getVideoCurrentTime(){let e=0;return this.$videoElement&&(e=this.$videoElement.currentTime),e}}class fc{constructor(e){this.player=e,this.TAG_NAME="PressureObserverCpu",this.observer=null,this.latestCpuInfo=null,this.currentLevel=-1,this._init(),this.player.debug.log(this.TAG_NAME,"init")}destroy(){this.observer&&(this.observer.disconnect(),this.observer=null),this.latestCpuInfo=null,this.currentLevel=-1,this.player.debug.log(this.TAG_NAME,"destroy")}getCurrentCpuState(){return this.currentLevel}_init(){ka(Ba())?this.player.debug.log(this.TAG_NAME,"not support PressureObserver"):(this.observer=new PressureObserver((e=>{const t=(e||[]).find((e=>"cpu"===e.source));if(t){switch(this.latestCpuInfo=t,t.state){case"nominal":this.currentLevel=0;break;case"fair":this.currentLevel=1;break;case"serious":this.currentLevel=2;break;case"critical":this.currentLevel=3;break;default:this.currentLevel=-1}this.player.emit(st.pressureObserverCpu,this.currentLevel)}})),this.observer&&this.observer.observe("cpu"))}}class yc extends $a{constructor(e,t={}){super(e),this.TAG_NAME="DynamicWatermark",this.isPauseAnimation=!1,this.isStopAnimation=!1,this.rafID=null,this.speed=t.speed||.2,this.isDynamic=!0,this.shadowRootDynamicDom=null,this.isGhost=!0===t.isGhost,this.ghostConfig={on:t.on||5,off:t.off||5},this.waterMarkWillRemove=!1,this.waterMarkWillAdd=!1,this.player.once(st.start,(()=>{const e=ka(false)?decodeURIComponent("EasyPlayerPro%20%E4%BD%93%E9%AA%8C"):t.content;let i=this.player.getVideoInfo();i||(i={width:200,height:200}),this.update({text:{content:e,fontSize:t.fontSize||18,color:t.color||"white"},left:i.width*Math.random(),top:i.height*Math.random(),opacity:t.opacity||.15}),this.startAnimation()})),this.player.debug.log(this.TAG_NAME,"int")}destroy(){super.destroy(),this.rafID&&(cancelAnimationFrame(this.rafID),this.rafID=null)}startAnimation(){if(!this.rafID){let e=1,t=1,i=Math.random(),r={width:0,height:0};const s=()=>{try{if(ka(this.isPauseAnimation)&&this.shadowRootDynamicDom&&this.shadowRootInnerDom){const a=this.shadowRootInnerDom,n=this.shadowRootDynamicDom,o=a.getBoundingClientRect(),l=n.getBoundingClientRect();if(l.width&&l.height&&(r.width=l.width,r.height=l.height),!this.shadowRootInnerDom.contains(this.shadowRootDynamicDom))return this.isGhost?ka(this.waterMarkWillAdd)&&(this.waterMarkWillAdd=!0,setTimeout((()=>{this._addDom(o,r),this.waterMarkWillAdd=!1}),1e3*this.ghostConfig.off)):this._addDom(o,r),void(0!==this.speed&&requestAnimationFrame(s));const d=Math.min(1,0===this.speed?0:this.speed?this.speed:.2);let h=l.left-o.left,c=l.top-o.top;h+=d*t*i,c+=d*e*(1-i),h+r.width>o.width?(t=-1,i=Math.random()):h<0&&(t=1,i=Math.random()),c+r.height>o.height?(e=-1,i=Math.random()):c<0&&(e=1,i=Math.random()),h=Math.min(o.width-r.width,h),c=Math.min(o.height-r.height,c);const u=h/o.width*100,p=c/o.height*100;this.shadowRootDynamicDom.style.left=`${u}%`,this.shadowRootDynamicDom.style.top=`${p}%`,ka(this.waterMarkWillRemove)&&this.isGhost&&(this.waterMarkWillRemove=!0,setTimeout((()=>{this._removeDom(),this.waterMarkWillRemove=!1}),1e3*this.ghostConfig.on))}}catch(e){}if(this.isStopAnimation)return this.isStopAnimation=!1,cancelAnimationFrame(this.rafID),void(this.rafID=null);0!==this.speed&&requestAnimationFrame(s)};this.rafID=requestAnimationFrame(s)}}_addDom(e,t){if(this.shadowRootInnerDom&&this.shadowRootDynamicDom){this.shadowRootInnerDom.appendChild(this.shadowRootDynamicDom);let i=e.width*Math.random(),r=e.height*Math.random();i=Math.min(e.width-2*t.width,i),r=Math.min(e.height-2*t.height,r),this.shadowRootDynamicDom.style.left=`${i}px`,this.shadowRootDynamicDom.style.top=`${r}px`}}resumeAnimation(){this.isPauseAnimation=!1}pauseAnimation(){this.isPauseAnimation=!0}stopAnimation(){this.isStopAnimation=!0}}class mc extends t{constructor(e,t={}){super(),this._opt={},this.TAG_NAME="Player",this.$container=e;const i=Ea();if(this._opt=Object.assign({},i,t),this.debug=new Xr(this),this.debug.log(this.TAG_NAME,"init"),this._opt.forceNoOffscreen=!0,this._canPlayAppleMpegurl=!1,(Is()||Ls())&&(this._canPlayAppleMpegurl=ua(),this.debug.log(this.TAG_NAME,"isIOS or isSafari and canPlayAppleMpegurl",this._canPlayAppleMpegurl)),ks()&&(this._opt.controlAutoHide=!1),xa()&&(this.debug.log(this.TAG_NAME,"isIphone and set _opt.videoRenderSupportScale false"),this._opt.videoRenderSupportScale=!1,na()&&Ta(this._opt.isHls)&&ka(this._opt.supportHls265)&&(this.debug.log(this.TAG_NAME,"isIphone and is in wechat and is hls so set supportHls265 true"),this._opt.supportHls265=!0)),ka(this._opt.playFailedAndReplay)&&(this.debug.log(this.TAG_NAME,"_opt.playFailedAndReplay is false and set others replay params false"),this._opt.webglAlignmentErrorReplay=!1,this._opt.webglContextLostErrorReplay=!1,this._opt.autoWasm=!1,this._opt.mseDecodeErrorReplay=!1,this._opt.mediaSourceTsIsMaxDiffReplay=!1,this._opt.wcsDecodeErrorReplay=!1,this._opt.wasmDecodeErrorReplay=!1,this._opt.simdDecodeErrorReplay=!1,this._opt.videoElementPlayingFailedReplay=!1,this._opt.networkDelayTimeoutReplay=!1,this._opt.widthOrHeightChangeReplay=!1,this._opt.simdH264DecodeVideoWidthIsTooLargeReplay=!1,this._opt.mediaSourceUseCanvasRenderPlayFailedReplay=!1,this._opt.heartTimeoutReplay=!1,this._opt.loadingTimeoutReplay=!1,this._opt.websocket1006ErrorReplay=!1),this._opt.forceNoOffscreen||("undefined"==typeof OffscreenCanvas?(this._opt.forceNoOffscreen=!0,this._opt.useOffscreen=!1):this._opt.useOffscreen=!0),this._opt.isMpeg4&&(this.debug.log(this.TAG_NAME,"isMpeg4 is true, so set _opt.useWasm true and others params false"),this._opt.useWCS=!1,this._opt.useMSE=!1,this._opt.isNakedFlow=!1,this._opt.useSIMD=!1,this._opt.isFmp4=!1,this._opt.useWasm=!0),this.isPlayback()&&(this._opt.mseDecoderUseWorker=!1),this._opt.mseDecoderUseWorker&&(this._opt.mseDecoderUseWorker=!!(self.Worker&&self.MediaSource&&"canConstructInDedicatedWorker"in self.MediaSource&&!0===self.MediaSource.canConstructInDedicatedWorker),ka(this._opt.mseDecoderUseWorker)&&this.debug.log(this.TAG_NAME,"mseDecoderUseWorker is true but not support so set _opt.mseDecoderUseWorker = false")),(this.isOldHls()||this.isWebrtcH264()||this.isAliyunRtc())&&(this.debug.log(this.TAG_NAME,"isOldHls or isWebrtcH264 or isAliyunRtc is true, so set some params false and _opt.recordType is webm"),this._opt.useWCS=!1,this._opt.useMSE=!1,this._opt.isNakedFlow=!1,this._opt.useSIMD=!1,this._opt.isFmp4=!1,this._opt.useWasm=!1,this._opt.recordType=w),this._opt.isNakedFlow&&(this.debug.log(this.TAG_NAME,"isNakedFlow is true, so set _opt.mseDecodeAudio false"),this._opt.mseDecodeAudio=!1),!this.isOldHls()&&!this.isWebrtcH264()){if(this._opt.useWCS){const e="VideoEncoder"in window,t=zs();this._opt.useWCS=e,this._opt.useWCS&&this._opt.isH265&&(this._opt.useWCS=t),this._opt.useWCS||this.debug.warn(this.TAG_NAME,`\n useWCS is true,\n and supportWCS is ${e}, supportHevcWCS is ${t} , _opt.isH265 is ${this._opt.isH265}\n so set useWCS false`),this._opt.useWCS&&(this._opt.useOffscreen?this._opt.wcsUseVideoRender=!1:this._opt.wcsUseVideoRender&&(this._opt.wcsUseVideoRender=Ws()&&Vs(),this._opt.wcsUseVideoRender||this.debug.warn(this.TAG_NAME,"wcsUseVideoRender is true, but not support so set wcsUseVideoRender false")))}if(this._opt.useMSE){const e=function(){let e=!1;return"MediaSource"in self&&self.MediaSource.isTypeSupported(Kt)&&(e=!0),e}(),t=Gs();this._opt.useMSE=e,this._opt.useMSE&&this._opt.isH265&&(this._opt.useMSE=t),this._opt.useMSE||this.debug.warn(this.TAG_NAME,`\n useMSE is true,\n and supportMSE is ${e}, supportHevcMSE is ${t} , _opt.isH265 is ${this._opt.isH265}\n so set useMSE false`)}}if(ka(this._opt.useMSE)&&(this._opt.mseDecodeAudio=!1),this._opt.useMSE?(this._opt.useWCS&&this.debug.warn(this.TAG_NAME,"useMSE is true and useWCS is true then useWCS set true->false"),this._opt.forceNoOffscreen||this.debug.warn(this.TAG_NAME,"useMSE is true and forceNoOffscreen is false then forceNoOffscreen set false->true"),this._opt.useWCS=!1,this._opt.forceNoOffscreen=!0):this._opt.useWCS,this._opt.isWebrtc&&this._opt.demuxUseWorker&&(this.debug.warn(this.TAG_NAME,"isWebrtc is true and demuxUseWorker is true then demuxUseWorker set true->false"),this._opt.demuxUseWorker=!1),this._opt.isHls&&this._opt.demuxUseWorker&&(this.debug.warn(this.TAG_NAME,"isHls is true and demuxUseWorker is true then demuxUseWorker set true->false"),this._opt.demuxUseWorker=!1),this._opt.isAliyunRtc&&this._opt.demuxUseWorker&&(this.debug.warn(this.TAG_NAME,"isAliyunRtc is true and demuxUseWorker is true then demuxUseWorker set true->false"),this._opt.demuxUseWorker=!1),this.isStreamWebTransport()&&this._opt.demuxUseWorker&&(this.debug.warn(this.TAG_NAME,"is stream use webTransport is true and demuxUseWorker is true then demuxUseWorker set true->false"),this._opt.demuxUseWorker=!1),ka(this._opt.demuxUseWorker)&&(this._opt.mseDecoderUseWorker=!1),this.isPlayback()&&(this._opt.mseDecoderUseWorker=!1),this._opt.useMThreading&&(this._opt.useMThreading="undefined"!=typeof SharedArrayBuffer,this._opt.useMThreading||this.debug.warn(this.TAG_NAME,"useMThreading is true, but not support so set useMThreading false")),this._opt.useSIMD||-1!==this._opt.decoder.indexOf("-simd")){const e=WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),t=xa();this._opt.useSIMD=e&&ka(t),this._opt.useSIMD||this.debug.warn(this.TAG_NAME,`useSIMD is true, but not supportisSupportSimd is ${e} ,isIphone is ${t} so set useSIMD false`)}var r;if(this._opt.useSIMD?-1===this._opt.decoder.indexOf("-simd")?this._opt.useMThreading?this._opt.decoder=this._opt.decoder.replace("decoder-pro.js","decoder-pro-simd-mt.js"):this._opt.decoder=this._opt.decoder.replace("decoder-pro.js","decoder-pro-simd.js"):this._opt.useMThreading&&(this._opt.decoder=this._opt.decoder.replace("decoder-pro-simd.js","decoder-pro-simd-mt.js")):-1!==this._opt.decoder.indexOf("-simd")?this._opt.useMThreading?this._opt.decoder=this._opt.decoder.replace("decoder-pro-simd.js","decoder-pro-mt.js"):this._opt.decoder=this._opt.decoder.replace("decoder-pro-simd.js","decoder-pro.js"):this._opt.useMThreading&&(this._opt.decoder=this._opt.decoder.replace("decoder-pro.js","decoder-pro-mt.js")),-1!==this._opt.decoder.indexOf("-simd")?this._opt.useMThreading?(this._opt.decoderAudio=this._opt.decoder.replace("decoder-pro-simd-mt.js","decoder-pro-audio.js"),this._opt.decoderHard=this._opt.decoder.replace("decoder-pro-simd-mt.js","decoder-pro-hard.js"),this._opt.decoderHardNotWasm=this._opt.decoder.replace("decoder-pro-simd-mt.js","decoder-pro-hard-not-wasm.js")):(this._opt.decoderAudio=this._opt.decoder.replace("decoder-pro-simd.js","decoder-pro-audio.js"),this._opt.decoderHard=this._opt.decoder.replace("decoder-pro-simd.js","decoder-pro-hard.js"),this._opt.decoderHardNotWasm=this._opt.decoder.replace("decoder-pro-simd.js","decoder-pro-hard-not-wasm.js")):this._opt.useMThreading?(this._opt.decoderAudio=this._opt.decoder.replace("decoder-pro-mt.js","decoder-pro-audio.js"),this._opt.decoderHard=this._opt.decoder.replace("decoder-pro-mt.js","decoder-pro-hard.js"),this._opt.decoderHardNotWasm=this._opt.decoder.replace("decoder-pro-mt.js","decoder-pro-hard-not-wasm.js")):(this._opt.decoderAudio=this._opt.decoder.replace("decoder-pro.js","decoder-pro-audio.js"),this._opt.decoderHard=this._opt.decoder.replace("decoder-pro.js","decoder-pro-hard.js"),this._opt.decoderHardNotWasm=this._opt.decoder.replace("decoder-pro.js","decoder-pro-hard-not-wasm.js")),ka(this._opt.hasAudio)&&(this._opt.operateBtns.audio=!1),ka(this._opt.hasVideo)&&(this._opt.operateBtns.fullscreen=!1,this._opt.operateBtns.screenshot=!1,this._opt.operateBtns.record=!1,this._opt.operateBtns.ptz=!1,this._opt.operateBtns.quality=!1,this._opt.operateBtns.zoom=!1),this._opt.qualityConfig&&0===this._opt.qualityConfig.length&&this._opt.operateBtns.quality&&(this._opt.operateBtns.quality=!1,this.debug.warn(this.TAG_NAME,"_opt.qualityConfig is empty, so set operateBtns.quality false")),Ta(this._opt.useWebGPU)&&(this._opt.useWebGPU=function(){let e=!1;return"gpu"in navigator&&(e=!0),e}(),ka(this._opt.useWebGPU)&&this.debug.warn(this.TAG_NAME,"useWebGPU is true, but not support so set useWebGPU false")),this._opt.hasControl=this._hasControl(),this._loading=!1,this._playing=!1,this._playbackPause=!1,this._hasLoaded=!1,this._zooming=!1,this._destroyed=!1,this._closed=!1,this._checkHeartTimeout=null,this._checkLoadingTimeout=null,this._checkStatsInterval=null,this._checkVisibleHiddenTimeout=null,this._startBpsTime=null,this._isPlayingBeforePageHidden=!1,this._stats={buf:0,netBuf:0,fps:0,maxFps:0,dfps:0,abps:0,vbps:0,ts:0,mseTs:0,currentPts:0,pTs:0,dts:0,mseVideoBufferDelayTime:0,isDropping:!1},this._allStatsData={},this._faceDetectActive=!1,this._objectDetectActive=!1,this._occlusionDetectActive=!1,this._imageDetectActive=!1,this._times={playInitStart:"",playStart:"",streamStart:"",streamResponse:"",demuxStart:"",decodeStart:"",videoStart:"",playTimestamp:"",streamTimestamp:"",streamResponseTimestamp:"",demuxTimestamp:"",decodeTimestamp:"",videoTimestamp:"",allTimestamp:""},this._videoTimestamp=0,this._audioTimestamp=0,this._latestAudioTimestamp=0,this._videoIframeIntervalTs=0,this._streamQuality=this._opt.defaultStreamQuality||"",!this._streamQuality&&this._opt.qualityConfig.length>0&&(this._streamQuality=this._opt.qualityConfig[0]||""),this._visibility=!0,this._lastestVisibilityChangeTimestamp=null,this._tempWorkerStats=null,this._historyFpsList=[],this._historyVideoDiffList=[],this._tempStreamList=[],this._tempInnerPlayBgobj=null,this._flvMetaData=null,this._flvMetaDataFps=null,this._mseWorkerData={},ka(this._opt.useMSE)&&ka(this._opt.useWCS)&&!this.isWebrtcH264()&&!this.isOldHls()&&(this._opt.useWasm=!0),(this.isOldHls()||this.isWebrtcH264())&&(this._opt.hasVideo=!0,this._opt.hasAudio=!0),this._opt.hasVideo||(this._opt.useMSE=!1,this._opt.useWCS=!1),this._opt.useWasm&&(this._opt.useOffscreen?this._opt.wasmUseVideoRender=!1:this._opt.wasmUseVideoRender&&(this._opt.wasmUseVideoRender=Bs()&&Ws()&&Vs(),this._opt.wasmUseVideoRender||this.debug.warn(this.TAG_NAME,"use wasm video render, but not support so set wasmUseVideoRender false")),this._opt.useSIMD?this.debug.log(this.TAG_NAME,"use simd wasm"):this.debug.log(this.TAG_NAME,"use wasm")),this._opt.useWasm&&(this._opt.useFaceDetector&&window.EasyPlayerProFaceDetector||this._opt.useObjectDetector&&window.EasyPlayerProObjectDetector||this._opt.useOcclusionDetector&&window.EasyPlayerProOcclusionDetector||this._opt.useImageDetector&&window.EasyPlayerProImageDetector)?(this.ai=new dc(this),this._opt.useFaceDetector&&window.EasyPlayerProFaceDetector||(this._opt.operateBtns.aiFace=!1),this._opt.useObjectDetector&&window.EasyPlayerProObjectDetector||(this._opt.operateBtns.aiObject=!1),this._opt.useOcclusionDetector&&window.EasyPlayerProOcclusionDetector||(this._opt.operateBtns.aiOcclusion=!1),this._opt.useImageDetector&&this._opt.aiImageDetectActive&&window.EasyPlayerProImageDetector&&(this.imageDetectActive=!0)):(this._opt.operateBtns.aiObject=!1,this._opt.operateBtns.aiFace=!1,this._opt.operateBtns.aiOcclusion=!1),this._opt.useFaceDetector&&(this._opt.useWasm&&window.EasyPlayerProFaceDetector||this.debug.warn(this.TAG_NAME,`use face detector, useWasm is ${this._opt.useWasm} and window.EasyPlayerProFaceDetector is null`)),this._opt.useObjectDetector&&(this._opt.useWasm&&window.EasyPlayerProObjectDetector||this.debug.warn(this.TAG_NAME,`use object detector, useWasm is ${this._opt.useWasm} and window.EasyPlayerProObjectDetector is null`)),this._opt.useOcclusionDetector&&(this._opt.useWasm&&window.EasyPlayerProOcclusionDetector||this.debug.warn(this.TAG_NAME,`use occlusion detector, useWasm is ${this._opt.useWasm} and window.EasyPlayerProOcclusionDetector is null`)),this._opt.useImageDetector&&(this._opt.useWasm&&window.EasyPlayerProImageDetector||this.debug.warn(this.TAG_NAME,`use image detector, useWasm is ${this._opt.useWasm} and window.EasyPlayerProImageDetector is null`)),this._opt.useVideoRender&&(this._opt.useWasm&&!this._opt.useOffscreen?(this._opt.wasmUseVideoRender=Bs()&&Ws()&&Vs(),this._opt.wasmUseVideoRender||this.debug.warn(this.TAG_NAME,"use wasm video render, but not support so set wasmUseVideoRender false")):this._opt.useWCS&&!this._opt.useOffscreen&&(this._opt.wcsUseVideoRender=Ws()&&Vs(),this._opt.wcsUseVideoRender||this.debug.warn(this.TAG_NAME,"use wcs video render, but not support so set wcsUseVideoRender false"))),this._opt.useCanvasRender&&(this._opt.useMSE&&ka(this._opt.mseDecoderUseWorker)&&(this._opt.mseUseCanvasRender=!0),this._opt.useWasm&&(this._opt.wasmUseVideoRender=!1),this._opt.useWCS&&(this._opt.wcsUseVideoRender=!1),this.isOldHls()&&!Is()&&(this._opt.hlsUseCanvasRender=!0),this.isWebrtcH264()&&(this._opt.webrtcUseCanvasRender=!0)),this._opt.useVideoRender=!1,this._opt.useCanvasRender=!1,this._opt.useWasm?this._opt.wasmUseVideoRender?this._opt.useVideoRender=!0:this._opt.useCanvasRender=!0:this._opt.useWCS?this._opt.wcsUseVideoRender?this._opt.useVideoRender=!0:this._opt.useCanvasRender=!0:this._opt.useMSE?this._opt.mseUseCanvasRender?this._opt.useCanvasRender=!0:this._opt.useVideoRender=!0:this.isOldHls()?this._opt.hlsUseCanvasRender?this._opt.useCanvasRender=!0:this._opt.useVideoRender=!0:this.isWebrtcH264()&&(this._opt.webrtcUseCanvasRender?this._opt.useCanvasRender=!0:this._opt.useVideoRender=!0),r=this,Object.defineProperty(r,"rect",{get:()=>{let e={};return r.$container&&(e=r.$container.getBoundingClientRect(),e.width=Math.max(e.width,r.$container.clientWidth),e.height=Math.max(e.height,r.$container.clientHeight)),e}}),["bottom","height","left","right","top","width"].forEach((e=>{Object.defineProperty(r,e,{get:()=>r.rect[e]||0})})),this.events=new Ma(this),this._opt.hasVideo&&(this.video=new an(this),this.recorder=new po(this)),this.isWsRtc()?(this.wsRtcDecoder=new rc(this),this.loaded=!0):this.isOldHls()?(this.hlsDecoder=new Md(this),this.loaded=!0):this.isWebrtcH264()?(this._opt.isWebrtcForZLM?this.webrtc=new nc(this):this._opt.isWebrtcForSRS?this.webrtc=new cc(this):this._opt.isWebrtcForOthers?this.webrtc=new uc(this):this.webrtc=new ac(this),this.loaded=!0):this.isAliyunRtc()?(this.aliyunRtcDecoder=new pc(this),this.loaded=!0):(this.isUseHls265()&&(this.hlsDecoder=new ic(this)),this.isWebrtcH265()&&(this.webrtc=new ac(this)),ka(pa(this._opt))?this.decoderWorker=new vo(this):this.loaded=!0),this._opt.hasAudio&&(this.audio=new Sn(this)),this.stream=null,this.demux=null,this._lastVolume=null,this._isInZoom=!1,this._playingStartTimestamp=null,this.isMSEVideoDecoderInitializationFailedNotSupportHevc=!1,this._opt.useWCS&&(this.webcodecsDecoder=new hd(this),!this._opt.hasAudio&&ka(this._opt.demuxUseWorker)&&(this.loaded=!0)),this._opt.useMSE&&ka(this._opt.mseDecoderUseWorker)&&(this.mseDecoder=new Rd(this),!this._opt.hasAudio&&ka(this._opt.demuxUseWorker)&&(this.loaded=!0)),this.control=new Cd(this),this._opt.contextmenuBtns.length>0&&ka(this._opt.disableContextmenu)&&Cs()?this.contextmenu=new hc(this):Ta(this._opt.disableContextmenu)&&this._opt.contextmenuBtns.length>0&&Cs()&&this.debug.warn(this.TAG_NAME,"disableContextmenu is true, but contextmenuBtns is not empty, so Contextmenu can not be createdplease check"),this.isPlayback()&&(this.playback=new oc(this,this._opt.playbackConfig)),this._opt.operateBtns.zoom&&(this.zoom=new lc(this)),/(iphone|ipad|ipod|ios|android)/i.test(window.navigator.userAgent.toLowerCase())&&ka(this._opt.supportLockScreenPlayAudio&&Ls())&&(this.keepScreenOn=new Ld(this)),(e=>{try{const t=t=>{la(t)===e.$container&&(e.emit(at.fullscreen,e.fullscreen),e.fullscreen?e._opt.useMSE&&e.resize():e.resize())};es.on("change",t),e.events.destroys.push((()=>{es.off("change",t)}))}catch(e){}if(e.on(st.decoderWorkerInit,(()=>{e.debug.log("player","listen decoderWorkerInit and set loaded true"),e.loaded=!0})),e.on(st.play,(()=>{e.loading=!1})),e.on(st.screenshot,(t=>{e.emit(st.screenshots,t)})),e.on(st.fullscreen,(t=>{if(t)try{es.request(e.$container).then((()=>{})).catch((t=>{e.debug.error("player","fullscreen request error",t),ks()&&e._opt.useWebFullScreen&&(e.webFullscreen=!0)}))}catch(t){ks()&&e._opt.useWebFullScreen&&(e.webFullscreen=!0)}else try{es.exit().then((()=>{e.webFullscreen&&(e.webFullscreen=!1)})).catch((t=>{e.debug.error("player","fullscreen exit error",t),e.webFullscreen&&(e.webFullscreen=!1)}))}catch(t){e.webFullscreen&&(e.webFullscreen=!1)}})),ks()&&e.on(st.webFullscreen,(t=>{t?e.$container.classList.add("easyplayer-fullscreen-web"):e.$container.classList.remove("easyplayer-fullscreen-web"),e.emit(at.fullscreen,e.fullscreen)})),e.on(st.resize,(()=>{e.video&&e.video.resize()})),e._opt.debug){const t=[st.timeUpdate,st.currentPts,st.videoSEI],i=[st.stats,st.playbackStats,st.playbackTimestamp,st.flvMetaData,st.playToRenderTimes,st.audioInfo,st.videoInfo];Object.keys(st).forEach((r=>{e.on(st[r],((s,...a)=>{t.includes(r)||(i.includes(r)&&(s=JSON.stringify(s)),e.debug.log("player events",st[r],s,...a))}))})),Object.keys(lt).forEach((t=>{e.on(lt[t],((...i)=>{e.debug.warn("player event error",lt[t],...i)}))}))}})(this),(e=>{const{_opt:t,debug:i,events:{proxy:r}}=e;if(t.supportDblclickFullscreen&&r(e.$container,"dblclick",(t=>{const i=la(t).nodeName.toLowerCase();"canvas"!==i&&"video"!==i||(e.fullscreen=!e.fullscreen)})),r(document,"visibilitychange",(()=>{e.visibility="visible"===document.visibilityState,i.log("visibilitychange",document.visibilityState),t.hiddenAutoPause&&(i.log("visibilitychange","hiddenAutoPause is true ",document.visibilityState,e._isPlayingBeforePageHidden),"visible"===document.visibilityState?e._isPlayingBeforePageHidden&&e.play():(e._isPlayingBeforePageHidden=e.playing,e.playing&&e.pause()))})),Cs()&&r(document,["click","contextmenu"],(t=>{Ed(t,e.$container)?(Ta(e._opt.disableContextmenu)&&"contextmenu"===t.type&&t.preventDefault(),e.isInput="INPUT"===t.target.tagName,e.isFocus=!0,e.emit(st.focus)):(e.isInput=!1,e.isFocus=!1,e.emit(st.blur))})),t.autoResize){const t=Fs((()=>{e.resize()}),500);r(window,["resize","orientationchange"],(()=>{t()})),screen&&screen.orientation&&screen.orientation.onchange&&r(screen.orientation,"change",(()=>{t()}))}})(this),this.singleWatermark=new $a(this),this._opt.ghostWatermarkConfig.content){const e=Object.assign({},this._opt.ghostWatermarkConfig,{isGhost:!0});this.ghostWatermark=new yc(this,e)}this._opt.dynamicWatermarkConfig.content&&(this.dynamicWatermark=new yc(this,this._opt.dynamicWatermarkConfig)),this._opt.watermarkConfig&&this.updateWatermark(this._opt.watermarkConfig),Ba()&&(this.pressureObserverCpu=new fc(this)),this._opt.useWCS&&this.debug.log(this.TAG_NAME,"use WCS"),this._opt.useMSE&&(this._opt.mseDecoderUseWorker?this.debug.log(this.TAG_NAME,"use worker MSE"):this.debug.log(this.TAG_NAME,"use MSE")),this._opt.useOffscreen&&this.debug.log(this.TAG_NAME,"use offscreen"),this._opt.isHls&&(this._opt.supportHls265?this.debug.log(this.TAG_NAME,"use hls 265"):this.debug.log(this.TAG_NAME,"use hls")),this._opt.isWebrtc&&(this._opt.isWebrtcH265?this.debug.log(this.TAG_NAME,"use webrtc h265"):this._opt.isWebrtcForZLM?this.debug.log(this.TAG_NAME,"use webrtc for ZLM"):this._opt.isWebrtcForSRS?this.debug.log(this.TAG_NAME,"use webrtc for SRS"):this._opt.isWebrtcForOthers?this.debug.log(this.TAG_NAME,"use webrtc for Others"):this.debug.log(this.TAG_NAME,"use webrtc for M7S")),this.isAliyunRtc()&&this.debug.log(this.TAG_NAME,"use aliyun rtc"),this._opt.isFmp4&&this.debug.log(this.TAG_NAME,"use fmp4"),this._opt.isMpeg4&&this.debug.log(this.TAG_NAME,"use mpeg4"),this.isPlayback()&&this.debug.log(this.TAG_NAME,"use playback"),this._opt.hasVideo&&(0===this.width&&this.debug.warn(this.TAG_NAME,"container width is 0, please check the container width"),0===this.height&&this.debug.warn(this.TAG_NAME,"container height is 0, please check the container height")),this.debug.log("Player options",JSON.stringify(this._opt))}async destroy(){this._destroyed=!0,this.emit("destroy"),this.off(),this.events&&(this.events.destroy(),this.events=null),this.clearCheckLoadingTimeout(),this.clearStatsInterval(),this.clearVisibilityHiddenTimeout(),this.decoderWorker&&(await this.decoderWorker.destroy(),this.decoderWorker=null),await this._destroy()}async _destroy(){this._loading=!1,this._playing=!1,this._playbackPause=!1,this._hasLoaded=!1,this._lastVolume=null,this._zooming=!1,this._faceDetectActive=!1,this._objectDetectActive=!1,this._occlusionDetectActive=!1,this._imageDetectActive=!1,this._times={playInitStart:"",playStart:"",streamStart:"",streamResponse:"",demuxStart:"",decodeStart:"",videoStart:"",playTimestamp:"",streamTimestamp:"",streamResponseTimestamp:"",demuxTimestamp:"",decodeTimestamp:"",videoTimestamp:"",allTimestamp:""},this.singleWatermark&&(this.singleWatermark.destroy(),this.singleWatermark=null),this.ghostWatermark&&(this.ghostWatermark.destroy(),this.ghostWatermark=null),this.dynamicWatermark&&(this.dynamicWatermark.destroy(),this.dynamicWatermark=null),this.pressureObserverCpu&&(this.pressureObserverCpu.destroy(),this.pressureObserverCpu=null),this.stream&&(this.stream.destroy(),this.stream=null),this.hlsDecoder&&(await this.hlsDecoder.destroy(),this.hlsDecoder=null),this.wsRtcDecoder&&(await this.wsRtcDecoder.destroy(),this.wsRtcDecoder=null),this.mseDecoder&&(this.mseDecoder.destroy(),this.mseDecoder=null),this.webrtc&&(this.webrtc.destroy(),this.webrtc=null),this.aliyunRtcDecoder&&(this.aliyunRtcDecoder.destroy(),this.aliyunRtcDecoder=null),this.video&&(this.video.destroy(),this.video=null),this.audio&&(this.audio.destroy(),this.audio=null),this.recorder&&(this.recorder.destroy(),this.recorder=null),this.control&&(this.control.destroy(),this.control=null),this.webcodecsDecoder&&(this.webcodecsDecoder.destroy(),this.webcodecsDecoder=null),this.demux&&(this.demux.destroy(),this.demux=null),this.playback&&(this.playback.destroy(),this.playback=null),this.zoom&&(this.zoom.destroy(),this.zoom=null),this.ai&&(this.ai.destroy(),this.ai=null),this.keepScreenOn&&(this.releaseWakeLock(),this.keepScreenOn.destroy(),this.keepScreenOn=null),this.resetStats(),this._audioTimestamp=0,this._latestAudioTimestamp=0,this._videoTimestamp=0,this._streamQuality="",this._visibility=!0,this._isInZoom=!1,this._playingStartTimestamp=null,this._lastestVisibilityChangeTimestamp=null,this._videoIframeIntervalTs=null,this._tempWorkerStats=null,this._tempStreamList=[],this._tempInnerPlayBgobj={},this._flvMetaData=null,this._flvMetaDataFps=null,this._mseWorkerData={},this.isMSEVideoDecoderInitializationFailedNotSupportHevc=!1,this.debug.log("play","destroy end"),this._opt=Ea(),this.$container=null}set fullscreen(e){ks()&&this._opt.useWebFullScreen?this.webFullscreen=e:this.emit(st.fullscreen,e)}get fullscreen(){return es.isFullscreen||this.webFullscreen}set webFullscreen(e){this.emit(st.webFullscreen,e),setTimeout((()=>{this.updateOption({rotate:e?270:0}),this.resize()}),10)}get webFullscreen(){return this.$container.classList.contains("easyplayer-fullscreen-web")}set loaded(e){this._hasLoaded=e}get loaded(){return this._hasLoaded||this.isOldHls()||this.isWebrtcH264()||this._opt.useMSE&&ka(this._opt.hasAudio)&&ka(this._opt.demuxUseWorker)||this._opt.useWCS&&!this._opt.hasAudio&&ka(this._opt.demuxUseWorker)}set playing(e){this.isClosed()&&e?this.debug.log(this.TAG_NAME,"player is closed, so can not play"):(e&&Ta(this.loading)&&(this.loading=!1),this.playing!==e&&(this._playing=e,this.emit(st.playing,e),this.emit(st.volumechange,this.volume),e?this.emit(st.play):this.emit(st.pause)))}get playing(){return this._playing}get volume(){return this.audio&&this.audio.volume||0}set volume(e){this.emit(st.mute,e>0),this.video&&this.video.$videoElement&&(this.video.$videoElement.muted=!(e>0),this.video.$videoElement.volume=e>1?1:e),e!==this.volume&&(this.audio?(this.audio.setVolume(e),this._lastVolume=this.volume,this.isMute=0===this.volume):this.debug.warn(this.TAG_NAME,"set volume error, audio is null"))}get lastVolume(){return this._lastVolume}set loading(e){this.loading!==e&&(this._loading=e,this.emit(st.loading,this._loading))}get loading(){return this._loading}set zooming(e){this.zooming!==e&&(this.zoom||(this.zoom=new lc(this)),this._zooming=e,this.emit(st.zooming,this.zooming))}get zooming(){return this._zooming}set recording(e){e?this.playing&&!this.recording&&(this.recorder&&this.recorder.startRecord(),this.isDemuxInWorker()&&this.decoderWorker&&this.decoderWorker.updateWorkConfig({key:"isRecording",value:!0})):this.recording&&(this.isDemuxInWorker()&&this.decoderWorker&&this.decoderWorker.updateWorkConfig({key:"isRecording",value:!1}),this.recorder&&this.recorder.stopRecordAndSave().then((()=>{})).catch((e=>{})))}get recording(){return!!this.recorder&&this.recorder.isRecording}set audioTimestamp(e){null!==e&&(this._audioTimestamp=e)}get audioTimestamp(){return this._audioTimestamp}set latestAudioTimestamp(e){null!==e&&(this._latestAudioTimestamp=e)}get latestAudioTimestamp(){return this._latestAudioTimestamp}get videoTimestamp(){return this._stats.currentPts||this._stats.ts}set streamQuality(e){this.streamQuality!==e&&(this._streamQuality=e,this.emit(st.streamQualityChange,e))}get streamQuality(){return this._streamQuality}get isDebug(){return Ta(this._opt.debug)}get scaleType(){const e=this._opt,t=e.isResize,i=e.isFullResize;let r=Bt;return ka(i)&&ka(t)?r=Bt:ka(i)&&Ta(t)?r=Mt:Ta(i)&&Ta(t)&&(r=Ut),r}set visibility(e){this._visibility!==e&&(this._visibility=e,this.emit(st.visibilityChange,e),this._lastestVisibilityChangeTimestamp=vs(),e?this.clearVisibilityHiddenTimeout():this.startVisibilityHiddenTimeout())}get visibility(){return this._visibility}set playbackPause(e){this._playbackPause!==e&&(this._playbackPause=e,this.emit(st.playbackPause,e),this.emit(st.playbackPauseOrResume,e))}get playbackPause(){return this.isPlayback()&&this._playbackPause}set videoIframeIntervalTs(e){this._videoIframeIntervalTs=e}get videoIframeIntervalTs(){return this._videoIframeIntervalTs}set faceDetectActive(e){this._faceDetectActive!==e&&(this._faceDetectActive=e,this.emit(st.faceDetectActive,e))}get faceDetectActive(){return this._faceDetectActive}set objectDetectActive(e){this._objectDetectActive!==e&&(this._objectDetectActive=e,this.emit(st.objectDetectActive,e))}get objectDetectActive(){return this._objectDetectActive}set occlusionDetectActive(e){this._occlusionDetectActive!==e&&(this._occlusionDetectActive=e,this.emit(st.occlusionDetectActive,e))}get occlusionDetectActive(){return this._occlusionDetectActive}set imageDetectActive(e){this._imageDetectActive!==e&&(this._imageDetectActive=e)}get imageDetectActive(){return this._imageDetectActive}get isUseWorkerDemuxAndDecode(){return this.stream&&this.stream.getStreamType()===y}isDestroyed(){return this._destroyed}isClosed(){return this._closed}isDestroyedOrClosed(){return this.isDestroyed()||this.isClosed()}isPlaying(){let e=!1;return this._opt.playType===A?e=this.playing:this._opt.playType===b&&(e=ka(this.playbackPause)&&this.playing),e}updateOption(e,t=!1){this._opt=Object.assign({},this._opt,e),Ta(t)&&this.decoderWorker&&Object.keys(e).forEach((t=>{this.decoderWorker.updateWorkConfig({key:t,value:e[t]})}))}init(){return new Promise(((e,t)=>{this.video||this._opt.hasVideo&&(this.video=new an(this)),this.audio||this._opt.hasAudio&&(this.audio=new Sn(this)),this.stream||(this.stream=new Pn(this)),this.isWsRtc()?(this.wsRtcDecoder||(this.wsRtcDecoder=new rc(this),this.loaded=!0),e()):this.isOldHls()?(this.hlsDecoder||(this.hlsDecoder=new Md(this),this.loaded=!0),e()):this.isWebrtcH264()?(this.webrtc||(this._opt.isWebrtcForZLM?this.webrtc=new nc(this):this._opt.isWebrtcForSRS?this.webrtc=new cc(this):this._opt.isWebrtcForOthers?this.webrtc=new uc(this):this.webrtc=new ac(this),this.loaded=!0),e()):this.isAliyunRtc()?(this.aliyunRtcDecoder||(this.aliyunRtcDecoder=new pc(this),this.loaded=!0),e()):(this.demux||this._opt.hasVideo&&!this.isUseWorkerDemuxAndDecode&&(this.demux=new id(this)),this._opt.useWCS&&(this.webcodecsDecoder||(this.webcodecsDecoder=new hd(this))),this._opt.useMSE&&ka(this._opt.mseDecoderUseWorker)&&(this.mseDecoder||(this.mseDecoder=new Rd(this))),this.isUseHls265()&&(this.hlsDecoder||(this.hlsDecoder=new ic(this))),this.isWebrtcH265()&&(this.webrtc||(this.webrtc=new ac(this))),this.decoderWorker?this.loaded?e():this.once(st.decoderWorkerInit,(()=>{this.isDestroyedOrClosed()?(this.debug.error(this.TAG_NAME,"init() failed and player is destroyed"),t("init() failed and player is destroyed")):(this.loaded=!0,e())})):pa(this._opt)?e():(this.decoderWorker=new vo(this),this.once(st.decoderWorkerInit,(()=>{this.isDestroyedOrClosed()?(this.debug.error(this.TAG_NAME,"init() failed and player is destroyed"),t("init() failed and player is destroyed")):(this.loaded=!0,e())}))))}))}play(e,t={}){return new Promise(((i,r)=>{if(!e&&!this._opt.url)return r("url is empty");this._closed=!1,this.loading=!0,this.playing=!1,this._times.playInitStart=vs(),e||(e=this._opt.url),this._opt.url=e,this.control&&this._opt.loadingBackground&&this.control.initLoadingBackground(),this.init().then((()=>{this.debug.log(this.TAG_NAME,"play() init and next fetch stream"),this._times.playStart=vs(),this._opt.isNotMute&&this.mute(!1),this.enableWakeLock(),this.checkLoadingTimeout(),this.stream?(this.stream.once(lt.fetchError,(e=>{this.emitError(lt.fetchError,e)})),this.stream.once(lt.websocketError,(e=>{this.emitError(lt.websocketError,e)})),this.stream.once(st.streamEnd,(e=>{this.emit(st.streamEnd,e)})),this.stream.once(lt.hlsError,(e=>{this.emitError(lt.hlsError,e)})),this.stream.once(lt.webrtcError,(e=>{this.emitError(lt.webrtcError,e)})),this.stream.once(st.streamSuccess,(()=>{i(),this._times.streamResponse=vs(),this.video&&this.video.play(),this.checkStatsInterval(),this.isPlayback()&&this.playback&&this.playback.startCheckStatsInterval()})),this.stream.fetchStream(e,t)):(this.debug.warn(this.TAG_NAME,`play() this.stream is null and is isDestroyedOrClosed is ${this.isDestroyedOrClosed()}`),r("this.stream is null"))})).catch((e=>{r(e)}))}))}playForControl(){return new Promise(((e,t)=>{this.debug.log(this.TAG_NAME,`playForControl() and pauseAndNextPlayUseLastFrameShow is ${this._opt.pauseAndNextPlayUseLastFrameShow}`),this._opt.pauseAndNextPlayUseLastFrameShow&&this._tempInnerPlayBgobj&&this._tempInnerPlayBgobj.loadingBackground&&this.updateOption({loadingBackground:this._tempInnerPlayBgobj.loadingBackground,loadingBackgroundWidth:this._tempInnerPlayBgobj.loadingBackgroundWidth,loadingBackgroundHeight:this._tempInnerPlayBgobj.loadingBackgroundHeight}),this.play().then((t=>{e(t)})).catch((e=>{t(e)}))}))}close(){return new Promise(((e,t)=>{this._close().then((()=>{this.video&&this.video.clearView(),e()})).catch((e=>{t(e)}))}))}resumeAudioAfterPause(){this.lastVolume&&(this.volume=this.lastVolume)}_close(){return new Promise(((e,t)=>{this._closed=!0,this.video&&(this.video.resetInit(),this.video.pause(!0)),this.loading=!1,this.recording=!1,this.zooming=!1,this.playing=!1,this.clearCheckLoadingTimeout(),this.clearStatsInterval(),this.isPlayback()&&this.playback&&this.playback.clearStatsInterval(),this.releaseWakeLock(),this.resetStats(),this._audioTimestamp=0,this._videoTimestamp=0,this._times={playInitStart:"",playStart:"",streamStart:"",streamResponse:"",demuxStart:"",decodeStart:"",videoStart:"",playTimestamp:"",streamTimestamp:"",streamResponseTimestamp:"",demuxTimestamp:"",decodeTimestamp:"",videoTimestamp:"",allTimestamp:""};const i=()=>{this.stream&&(this.stream.destroy(),this.stream=null),this.demux&&(this.demux.destroy(),this.demux=null),this.webcodecsDecoder&&(this.webcodecsDecoder.destroy(),this.webcodecsDecoder=null),this.mseDecoder&&(this.mseDecoder.destroy(),this.mseDecoder=null),this.hlsDecoder&&(this.hlsDecoder.destroy(),this.hlsDecoder=null),this.webrtc&&(this.webrtc.destroy(),this.webrtc=null),this.aliyunRtcDecoder&&(this.aliyunRtcDecoder.destroy(),this.aliyunRtcDecoder=null),this.audio&&(this.audio.destroy(),this.audio=null)};this.decoderWorker?this.decoderWorker.destroy().then((()=>{this.decoderWorker=null,i(),setTimeout((()=>{e()}),0)})).catch((e=>{this.debug&&this.debug.error(this.TAG_NAME,"close() decoderWorker.destroy() error",e),t()})):(i(),setTimeout((()=>{e()}),0))}))}pause(e=!1){return new Promise(((t,i)=>{e?this.close().then((()=>{t()})).catch((e=>{i(e)})):this._close().then((()=>{t()})).catch((e=>{i(e)}))}))}pauseForControl(){return new Promise(((e,t)=>{if(this.debug.log(this.TAG_NAME,"_pauseInner()"),this._opt.pauseAndNextPlayUseLastFrameShow&&this.video){const e=this.video.screenshot("","png",.92,"base64");if(e){const t=this.getVideoInfo();t?(this.debug.log(this.TAG_NAME,`pauseForControl() and loadingBackground width is ${t.width} and height is ${t.height}`),this._tempInnerPlayBgobj={loadingBackground:e,loadingBackgroundWidth:t.width,loadingBackgroundHeight:t.height}):this.debug.warn(this.TAG_NAME,"pauseForControl() and videoInfo is null")}else this.debug.warn(this.TAG_NAME,"pauseForControl() and loadingBackground is null")}this.pause().then((t=>{e(t)})).catch((e=>{t(e)}))}))}isAudioMute(){let e=!0;return this.audio&&(e=this.audio.isMute),e}isAudioNotMute(){return!this.isAudioMute()}mute(e){this.audio&&this.audio.mute(e)}resize(){this.video&&this.video.resize()}startRecord(e,t){this.recording||(this.recorder.setFileName(e,t),this.recording=!0)}stopRecordAndSave(e,t){return new Promise(((i,r)=>{this.recorder||r("recorder is null"),this.recording?(this._opt.useWasm&&this.decoderWorker&&this.decoderWorker.updateWorkConfig({key:"isRecording",value:!1}),this.recorder.stopRecordAndSave(e,t).then((e=>{i(e)})).catch((e=>{r(e)}))):r("recorder is not recording")}))}_hasControl(){let e=!1,t=!1;return Object.keys(this._opt.operateBtns).forEach((e=>{this._opt.operateBtns[e]&&-1===(""+e).indexOf("Fn")&&(t=!0)})),(this._opt.showBandwidth||t)&&(e=!0),this._opt.extendOperateBtns&&this._opt.extendOperateBtns.length>0&&(e=!0),this.isPlayback()&&this._opt.playbackConfig.showControl&&(e=!0),e}useWasmDecode(){return ka(this._opt.useMSE)&&ka(this._opt.useWCS)}canVideoTrackWritter(){const e=this._opt;return!this.isOldHls()&&!this.isWebrtcH264()&&ka(e.useMSE)&&!this.isAliyunRtc()&&(e.useWCS&&ka(e.useOffscreen)&&e.wcsUseVideoRender||this.useWasmDecode())}checkHeartTimeout$2(){if(ka(this.playbackPause)&&this.playing){if(this.isDestroyedOrClosed())return void(this.debug&&this.debug.warn(this.TAG_NAME,"checkHeartTimeout$2 but player is destroyed"));if(ka(this.isHistoryFpsListAllZero()))return void(this.debug&&this.debug.warn(this.TAG_NAME,"checkHeartTimeout$2 but fps is not all zero"));if(0!==this._stats.fps)return void(this.debug&&this.debug.warn(this.TAG_NAME,`checkHeartTimeout$2 but fps is ${this._stats.fps}`));if(ka(this.visibility)&&0!==this._stats.vbps)return void(this.debug&&this.debug.warn(this.TAG_NAME,`checkHeartTimeout$2 but page is not visibility and vbps is ${this._stats.vbps}`));const e=this._historyFpsList.join(",");this.debug.warn(this.TAG_NAME,`checkHeartTimeout$2 and\n pause and emit delayTimeout event and\n current vbps is ${this._stats.vbps} and\n current fps is ${this._stats.fps} and\n history FpsList is ${e} and\n current visibility is ${this.visibility} and`),this.emit(st.timeout,st.delayTimeout),this.emit(st.delayTimeout)}else this.debug.log(this.TAG_NAME,`checkHeartTimeout$2 playbackPause is ${this.playbackPause}, playing is ${this.playing}`)}checkStatsInterval(){this._checkStatsInterval=setInterval((()=>{this.updateStats()}),1e3)}checkLoadingTimeout(){this._checkLoadingTimeout=setTimeout((()=>{this.playing?this.debug.warn(this.TAG_NAME,`checkLoadingTimeout but loading is ${this.loading} and playing is ${this.playing}`):this.isDestroyedOrClosed()?this.debug&&this.debug.warn(this.TAG_NAME,"checkLoadingTimeout but player is destroyed"):(this.debug.warn(this.TAG_NAME,"checkLoadingTimeout and pause and emit loadingTimeout event"),this.emit(st.timeout,st.loadingTimeout),this.emit(st.loadingTimeout))}),1e3*this._opt.loadingTimeout)}clearCheckLoadingTimeout(){this._checkLoadingTimeout&&(this.debug.log(this.TAG_NAME,"clearCheckLoadingTimeout"),clearTimeout(this._checkLoadingTimeout),this._checkLoadingTimeout=null)}clearStatsInterval(){this._checkStatsInterval&&(clearInterval(this._checkStatsInterval),this._checkStatsInterval=null)}handleRender(){this.isDestroyedOrClosed()?this.debug&&this.debug.warn(this.TAG_NAME,"handleRender but player is destroyed"):(this.loading&&(this.clearCheckLoadingTimeout(),this.loading=!1,this.emit(st.start)),this.playing||(this.playing=!0))}updateStats(e={}){if(this._startBpsTime||(this._startBpsTime=vs()),Ks(e.ts)){const t=parseInt(e.ts,10);this._stats.ts=t,null===this._playingStartTimestamp&&t>0&&(this._playingStartTimestamp=t)}Ks(e.dts)&&(this._stats.dts=parseInt(e.dts,10)),Ks(e.mseTs)&&(this._stats.mseTs=e.mseTs),Ks(e.buf)&&(this._stats.buf=e.buf),Ks(e.netBuf)&&(this._stats.netBuf=e.netBuf),Ks(e.currentPts)&&(this._stats.currentPts=e.currentPts),e.fps&&(this._stats.fps+=1),e.dfps&&(this._stats.dfps+=1),e.abps&&(this._stats.abps+=e.abps),e.vbps&&(this._stats.vbps+=e.vbps),e.workerStats&&(this._tempWorkerStats=e.workerStats),e.isDropping&&(this._stats.isDropping=e.isDropping),e.mseVideoBufferDelayTime&&(this._stats.mseVideoBufferDelayTime=parseInt(1e3*e.mseVideoBufferDelayTime,10));const t=vs();if(t-this._startBpsTime<1e3)return;null!==this._playingStartTimestamp&&this._stats.fps>0&&(this._stats.pTs+=1);let i=0,r=0,s=0,a=0,n=0;this._opt.useMSE&&(this.mseDecoder?(i=this.mseDecoder.checkSourceBufferDelay(),i=parseInt(1e3*i,10),r=this.mseDecoder.checkSourceBufferStore(),r=r.toFixed(2),s=this.mseDecoder.getDecodeDiffTimes(),a=this.mseDecoder.getDecodePlaybackRate(),n=this.mseDecoder.getPendingSegmentsLength()):this.isMseDecoderUseWorker()&&(i=this.video.checkSourceBufferDelay(),i=parseInt(1e3*i,10),r=this.video.checkSourceBufferStore(),r=r.toFixed(2),a=this.video.getDecodePlaybackRate())),this._opt.useWCS&&this.webcodecsDecoder&&(s=this.webcodecsDecoder.getDecodeDiffTimes()),this.isOldHls()&&this.hlsDecoder&&(i=this.hlsDecoder.checkHlsBufferedDelay(),i=parseInt(1e3*i,10)),this.isWsRtc()&&this.wsRtcDecoder;let o=0,l=0,d=0;this.isUseHls265()&&this.hlsDecoder&&(i=this.hlsDecoder.checkHlsBufferedDelay(),i=i.toFixed(2),o=this.hlsDecoder.getDemuxBufferedListLength(),d=this.hlsDecoder.getDemuxVideoBufferedListLength(),l=this.hlsDecoder.getDemuxAudioBufferedListLength());let h=0,c=0,u=0,p=!1,f=0;this._opt.useWasm||this._opt.demuxUseWorker?this._tempWorkerStats&&(c=this._tempWorkerStats.demuxBufferDelay,u=this._tempWorkerStats.audioDemuxBufferDelay,h=this._tempWorkerStats.flvBufferByteLength,this._stats.netBuf=this._tempWorkerStats.netBuf,f=this._tempWorkerStats.pushLatestDelay,p=this._tempWorkerStats.isStreamTsMoreThanLocal,this._stats.buf=this._tempWorkerStats.latestDelay):this.demux&&(h=this.demux.getInputByteLength(),f=this.demux.getPushLatestDelay(),p=this.demux.getIsStreamTsMoreThanLocal(),this.demux.bufferList&&(c=this.demux.bufferList.length));let y=0,m=0;this.audio&&this.audio.bufferList&&(y=this.audio.bufferList.length,m=parseInt(y*this.audio.oneBufferDuration,10));let g=0,A=0;if(this.isPlayback()&&this.video){this._opt.playbackConfig.isUseFpsRender&&(g=this.video.bufferList&&this.video.bufferList.length||0);let e=this.video.getStreamFps();const t=e>0?1e3/e:0;A=parseInt(t*g+t*c,10)}let v=0;this.videoTimestamp>0&&(v=this._stats.dts-this.videoTimestamp);const b=v+this._stats.netBuf;this.isOldHls()&&(this._stats.fps=this.hlsDecoder.getFps()),this._stats.fps>this._stats.maxFps&&(this._stats.maxFps=this._stats.fps);let _=this.getVideoCurrentTime();const w=this._stats.videoCurrentTime;let E=-1;w&&_&&(E=(_-w).toFixed(2),_=_.toFixed(2));let S=0;this.audioTimestamp>0&&(S=this.audioTimestamp-this.getRenderCurrentPts()),this._allStatsData=Object.assign(this._stats,{audioBuffer:y,audioBufferDelayTs:m,audioTs:this.audioTimestamp,latestAudioTs:this.latestAudioTimestamp,playbackVideoBuffer:g,playbackVideoWaitingBuffer:0,playbackAudioWaitingBuffer:0,playbackCacheDataDuration:A,demuxBuffer:c,pushLatestDelay:f,audioDemuxBuffer:u,flvBuffer:h,mseDelay:i,mseStore:r,mseDecodeDiffTimes:s,mseDecodePlaybackRate:a,msePendingBuffer:n,wcsDecodeDiffTimes:s,hlsDelay:i,hlsDemuxLength:o,hlsDemuxAudioLength:l,hlsDemuxVideoLength:d,delayTs:v,totalDelayTs:b,isStreamTsMoreThanLocal:p,videoCurrentTime:_,videoCurrentTimeDiff:E,audioSyncVideo:S});let T=null,k=null,C="";if(this.isPlayer()&&this._opt.hasVideo&&this.playing){T=function(e,t){let i=3;const r=t||25;return e<.33*r?i=0:e<.5*r?i=1:e<.83*r&&(i=2),i}(this._stats.fps,this._flvMetaDataFps),this._allStatsData.performance=T;const e=this.checkVideoSmooth(this._allStatsData);C=e.reason,k=e.result,this._allStatsData.videoSmooth=k}this.emit(st.stats,this._allStatsData),this._allStatsData.flvBuffer>1048576&&this.emit(lt.flvDemuxBufferSizeTooLarge,this._allStatsData.flvBuffer),this._opt.hasVideo?(this.updateHistoryFpsList(this._stats.fps,this._stats.videoCurrentTimeDiff),Ks(T)&&this.emit(st.performance,T),Ks(k)&&this.emit(st.videoSmooth,k,C)):this._opt.hasAudio&&this.updateHistoryFpsList(this._stats.abps,0),this._stats.fps=0,this._stats.dfps=0,this._stats.abps=0,this._stats.vbps=0,this._stats.isDropping=!1,this._startBpsTime=t}resetStats(){this._startBpsTime=null,this._playingStartTimestamp=null,this._historyFpsList=[],this._historyVideoDiffList=[],this._stats={buf:0,netBuf:0,fps:0,maxFps:0,dfps:0,abps:0,vbps:0,ts:0,mseTs:0,currentPts:0,pTs:0,dts:0,mseVideoBufferDelayTime:0,isDropping:!1},this._allStatsData={}}checkVideoSmooth(e){let t=!0,i="";if(this._opt.videoBuffer,this._opt.videoBufferDelay,this.isWebrtcH264()||this.isOldHls())return{result:t,reason:i};if(0===e.vbps&&ka(this._opt.isHls)&&(i="vbpsIsZero",this.debug.log(this.TAG_NAME,`checkVideoSmooth false because ${i}`),t=!1),t&&e.isDropping&&(i="isDroppingIsTrue",this.debug.log(this.TAG_NAME,`checkVideoSmooth false because ${i}`),t=!1),t&&this.visibility&&this._historyFpsList.length>=this._opt.heartTimeout){const r=function(e){const t=Math.max(...e),i=Math.min(...e);return e.filter((e=>e!==t&&e!==i))}(this._historyFpsList),s=r.reduce(((e,t)=>e+t),0)/r.length,a=.83*s;e.fps<a&&(i="fpsIsLow",this.debug.log(this.TAG_NAME,`checkVideoSmooth false because fps is ${e.fps} < min fix is ${a} and avgFps is ${s}`),t=!1)}return t&&this.visibility&&this._opt.useMSE&&(e.videoCurrentTimeDiff>=1.5||e.videoCurrentTimeDiff<=.5)&&-1!==e.videoCurrentTimeDiff&&(i="videoCurrentTimeDiffIsNotNormal",this.debug.log(this.TAG_NAME,`checkVideoSmooth false because videoCurrentTimeDiff is ${e.videoCurrentTimeDiff}`),t=!1),{result:t,reason:i}}enableWakeLock(){this._opt.keepScreenOn&&this.keepScreenOn&&this.keepScreenOn.enable()}releaseWakeLock(){this._opt.keepScreenOn&&this.keepScreenOn&&this.keepScreenOn.disable()}clearBufferDelay(){this._opt.useWasm?this.decoderWorker&&this.decoderWorker.clearWorkBuffer(!0):this.demux&&this.demux.clearBuffer(!0)}doDestroy(){this.emit(st.beforeDestroy)}startVoice(){this.wsRtcDecoder&&this.wsRtcDecoder.startVoice()}pauseVoice(){this.wsRtcDecoder&&this.wsRtcDecoder.pauseVoice()}removeVoice(){this.wsRtcDecoder&&this.wsRtcDecoder.removeVoice()}handlePlayToRenderTimes(){if(this.isDestroyedOrClosed())return void this.debug.log(this.TAG_NAME,"handlePlayToRenderTimes but player is closed or destroyed");const e=this.getPlayToRenderTimes();this.emit(st.playToRenderTimes,e)}getPlayToRenderTimes(){const e=this._times;return e.playTimestamp=e.playStart-e.playInitStart,e.streamTimestamp=e.streamStart-e.playStart,e.streamResponseTimestamp=e.streamResponse-e.streamStart>0?e.streamResponse-e.streamStart:0,e.demuxTimestamp=e.demuxStart-e.streamResponse>0?e.demuxStart-e.streamResponse:0,e.decodeTimestamp=e.decodeStart-e.demuxStart>0?e.decodeStart-e.demuxStart:0,e.videoTimestamp=e.videoStart-e.decodeStart,e.allTimestamp=e.videoStart-e.playInitStart,e}getOption(){return this._opt}getPlayType(){return this._opt.playType}isPlayer(){return this._opt.playType===A}isPlayback(){return this._opt.playType===b}isDemuxSetCodecInit(){let e=!0,t=this._opt;return t.useWCS&&!t.useOffscreen?e=!!this.webcodecsDecoder&&this.webcodecsDecoder.hasInit:t.useMSE&&(e=!!this.mseDecoder&&this.mseDecoder.hasInit),e}isDemuxDecodeFirstIIframeInit(){let e=!0,t=this._opt;return t.useWCS&&!t.useOffscreen?e=!!this.webcodecsDecoder&&this.webcodecsDecoder.isDecodeFirstIIframe:t.useMSE&&(e=!!this.mseDecoder&&this.mseDecoder.isDecodeFirstIIframe),e}isAudioPlaybackRateSpeed(){let e=!1;return this.audio&&(e=this.audio.isPlaybackRateSpeed()),e}getPlayingTimestamp(){return this._stats.pTs}getRecordingType(){let e=null;return this.recorder&&(e=this.recorder.getType()),e}getRecordingByteLength(){let e=0;return this.recording&&(e=this.recorder.getToTalByteLength()),e}getRecordingDuration(){let e=0;return this.recording&&(e=this.recorder.getTotalDuration()),e}getDecodeType(){let e="";const t=this.getOption();return this.isWebrtcH264()?V:this.isAliyunRtc()?j:this.isOldHls()?H:this.isWsRtc()?$:(t.useMSE&&(e+=F+" ",t.mseDecoderUseWorker&&(e+="worker")),t.useWCS&&(e+=O+" "),t.useWasm&&(e+=G+" ",t.useSIMD&&(e+=z+" "),t.useMThreading&&(e+=W+" ")),t.useOffscreen&&(e+=N+" "),e)}getDemuxType(){let e="";return e=this.getOption().demuxType,e}getRenderType(){let e="";return this.video&&(e=this.video.getType()),e}getCanvasRenderType(){let e="";return this.video&&(e=this.video.getCanvasType()),e}getAudioEngineType(){let e="";return this.audio&&(e=this.audio.getEngineType()),e}getStreamType(){let e="";return this.stream&&(e=this.stream.getStreamType()),e}getAllStatsData(){return this._allStatsData}togglePerformancePanel(e){this.updateOption({showPerformance:e}),this.emit(st.togglePerformancePanel,e)}setScaleMode(e){let t={isFullResize:!1,isResize:!1,aspectRatio:"default"};switch(e=Number(e)){case Bt:t.isFullResize=!1,t.isResize=!1;break;case Mt:t.isFullResize=!1,t.isResize=!0;break;case Ut:t.isFullResize=!0,t.isResize=!0}this.updateOption(t),this.resize(),this.emit(st.viewResizeChange,e)}startVisibilityHiddenTimeout(){this.clearVisibilityHiddenTimeout(),this._opt.pageVisibilityHiddenTimeout>0&&(this.visibilityHiddenTimeout=setTimeout((()=>{this.emit(st.visibilityHiddenTimeout)}),1e3*this._opt.pageVisibilityHiddenTimeout))}clearVisibilityHiddenTimeout(){this._checkVisibleHiddenTimeout&&(clearTimeout(this._checkVisibleHiddenTimeout),this._checkVisibleHiddenTimeout=null)}faceDetect(e){this.faceDetectActive=e}objectDetect(e){this.objectDetectActive=e}occlusionDetect(e){this.occlusionDetectActive=e}downloadNakedFlowFile(){this.demux&&this.demux.downloadNakedFlowFile&&this.demux.downloadNakedFlowFile()}downloadFmp4File(){this.demux&&this.demux.downloadFmp4File&&this.demux.downloadFmp4File()}downloadMpeg4File(){const e=new Blob([this._tempStreamList]);try{const t=document.createElement("a");t.href=window.URL.createObjectURL(e),t.download=Date.now()+".mpeg4",t.click(),window.URL.revokeObjectURL(t.href)}catch(e){console.error("downloadMpeg4File",e)}}hasCacheOnGopBuffer(){const e=this.videoIframeIntervalTs,t=this._allStatsData.demuxBuffer,i=this._allStatsData.maxFps;let r=!1;if(e&&t&&i){r=1e3/i*t>e}return r}addContentToCanvas(e=[]){this.video&&this.video.addContentToCanvas(e)}sendWebsocketMessage(e){const t=this.getStreamType();t===u||t===y+" "+u?this.stream.sendMessage(e):this.debug.warn(this.TAG_NAME,`sendWebsocketMessage: stream type is not websocket, current stream type is ${this.getStreamType()}`)}checkIsInRender(){const e=this._stats;return e.vbps>0&&e.fps>0}setControlHtml(e){this.control&&this.control.$controlHtml&&(this.control.$controlHtml.innerHTML=e)}clearControlHtml(){this.control&&this.control.$controlHtml&&(this.control.$controlHtml.innerHTML="")}updateWatermark(e){this.singleWatermark&&this.singleWatermark.update(e)}removeWatermark(){this.singleWatermark&&this.singleWatermark.remove()}getVideoInfo(){let e=null;return this.video&&(e=this.video.getVideoInfo()),e}getAudioInfo(){let e=null;return this.audio&&(e=this.audio.getAudioInfo()),e}getVideoPlaybackQuality(){let e=null;return this.video&&(e=this.video.getPlaybackQuality()),e}emitError(e,t=""){this.emit(st.error,e,t),this.emit(e,t)}updateHistoryFpsList(e,t){this.playbackPause||(this._historyFpsList.length>this._opt.heartTimeout&&(this._historyFpsList.shift(),this._historyVideoDiffList.shift()),this._historyFpsList.push(e),this._historyVideoDiffList.push(t),this.isHistoryFpsListAllZero()&&this.checkHeartTimeout$2())}isHistoryFpsListAllZero(){let e=!0;if(this._historyFpsList.length<this._opt.heartTimeout&&(e=!1),e)for(let t=0;t<this._historyFpsList.length;t++)if(this._historyFpsList[t]>0){e=!1;break}if(e)for(let t=0;t<this._historyVideoDiffList.length;t++)if(this._historyVideoDiffList[t]>0){e=!1;break}return e}isUseHls265(){return Ta(this._opt.isHls)&&Ta(this._opt.supportHls265)}isHls(){return Ta(this._opt.isHls)}isOldHls(){return Ta(this._opt.isHls)&&ka(this._opt.supportHls265)}isWsRtc(){return Ta(this._opt.isWsRtc)}isWebrtcNotH265(){return Ta(this._opt.isWebrtc)&&ka(this._opt.isWebrtcH265)}isWebrtcH264(){return Ta(this._opt.isWebrtc)&&ka(this._opt.isWebrtcH265)}isWebrtcH265(){return Ta(this._opt.isWebrtc)&&Ta(this._opt.isWebrtcH265)}isAliyunRtc(){return Ta(this._opt.isAliyunRtc)}isUseHls265UseMse(){return this.isUseHls265()&&this.isUseMSE()}isStreamWebTransport(){return this.getStreamType()===f}isPlaybackCacheBeforeDecodeForFpsRender(){return this.isPlayback()&&Ta(this._opt.playbackConfig.isCacheBeforeDecodeForFpsRender)&&Ta(this._opt.useWCS)}isPlaybackUseWCS(){return this.isPlayback()&&Ta(this._opt.useWCS)}isPlaybackUseMSE(){return this.isPlayback()&&Ta(this._opt.useMSE)}isPlayUseMSE(){return this.isPlayer()&&Ta(this._opt.useMSE)}isInWebFullscreen(){return this._opt.useWebFullScreen&&ks()&&this.fullscreen}getPlaybackRate(){let e=1;return Ta(this.isPlayback())&&this.playback&&(e=this.playback.rate),e}isPlaybackOnlyDecodeIFrame(){return Ta(this.isPlayback())&&this.getPlaybackRate()>=this._opt.playbackForwardMaxRateDecodeIFrame}pushTempStream(e){const t=new Uint8Array(e);this._tempStreamList.push(t)}updateLoadingText(e){this.loading&&this.control&&this.control.updateLoadingText(e)}getVideoCurrentTime(){let e=0;return this.video&&(this._opt.useMSE?this.mseDecoder?e=this.mseDecoder.getVideoCurrentTime():this.isMseDecoderUseWorker()&&(e=this.video.getVideoCurrentTime()):this.isWebrtcH264()&&this.webrtc?e=this.webrtc.getVideoCurrentTime():this.isAliyunRtc()&&this.aliyunRtcDecoder&&(e=this.aliyunRtcDecoder.getVideoCurrentTime())),e}addMemoryLog(e,...t){this.emit(st.memoryLog,` [${e}] `,...t)}downloadMemoryLog(){this.emit(st.downloadMemoryLog)}isInMulti(){return-1!==this._opt.multiIndex}isWebrtcForM7S(){return ka(this._opt.isWebrtcForZLM)&&ka(this._opt.isWebrtcForSRS)&&ka(this._opt.isWebrtcForOthers)}updateMetaData(e){if(this.debug.log(this.TAG_NAME,"updateMetaData",JSON.stringify(e)),this._flvMetaData=e,this._flvMetaData){const e=this._flvMetaData;if(Ns(e.framerate)){const t=Math.floor(1e3*e.framerate);if(t>0){const e=t/1e3;this._flvMetaDataFps=e}}js(e.hasAudio)&&ka(e.hasAudio)&&(this.debug.log("updateMetaData","hasAudio",e.hasAudio,"and update _opt.hasAudio"),this._opt.hasAudio=e.hasAudio),js(e.hasVideo)&&ka(e.hasVideo)&&(this.debug.log("updateMetaData","hasVideo",e.hasVideo,"and update _opt.hasVideo"),this._opt.hasVideo=e.hasVideo)}this.emit(st.flvMetaData,e)}getMetaData(){return this._flvMetaData}getExtendBtnList(){return this.control.getExtendBtnList().map((e=>({name:e.name,$container:e.$iconContainer,$btn:e.$iconWrap,$activeBtn:e.$activeIconWrap})))}getCpuLevel(){let e=null;return this.pressureObserverCpu&&(e=this.pressureObserverCpu.getCurrentCpuState()),e}isRecordTypeFlv(){return this.recorder&&this._opt.recordType===E}isRecordTypeMp4(){return this.recorder&&this._opt.recordType===_}isRecordTypeWebm(){return this.recorder&&this._opt.recordType===w}isDemuxInWorker(){return this._opt.useWasm||this._opt.demuxUseWorker}isUseMSE(){return Ta(this._opt.useMSE)}isUseWCS(){return Ta(this._opt.useWCS)}isUseWASM(){return Ta(this._opt.useWasm)}isMseDecoderUseWorker(){return this.isUseMSE()&&Ta(this._opt.mseDecoderUseWorker)}getAudioSyncVideoDiff(){return this.audioTimestamp-this.getRenderCurrentPts()}getMseVideoBufferDelayTime(){let e=0;return this._opt.useMSE&&this.mseDecoder&&(this.mseDecoder?e=this.mseDecoder.getVideoBufferDelayTime():this.isMseDecoderUseWorker()&&(e=this.video.getVideoBufferDelayTime()),e=parseInt(1e3*e,10)),e}updateCurrentPts(e){this.updateStats({currentPts:e}),this.emit(st.currentPts,e)}getRenderCurrentPts(){let e=0;return e=this._stats.currentPts?this._stats.currentPts:this.videoTimestamp-this.getMseVideoBufferDelayTime(),e}openSyncAudioAndVideo(){return this._opt.syncAudioAndVideo&&this._opt.hasVideo}showTipsMessageByCode(e){if(this.control){const t=this._opt.showMessageConfig[e]||"未知异常";this.control.showTipsMessage(t,e)}}showTipsMessageByContent(e){this.control&&e&&this.control.showTipsMessage(e)}hideTipsMessage(){this.control&&this.control.hideTipsMessage()}decoderCheckFirstIFrame(){Ta(this._opt.checkFirstIFrame)&&(this.mseDecoder?this.mseDecoder.isDecodeFirstIIframe=!1:this.webcodecsDecoder&&(this.webcodecsDecoder.isDecodeFirstIIframe=!1))}isHlsCanVideoPlay(){return this._canPlayAppleMpegurl&&this.isOldHls()}}class gc{constructor(e){const{fromSampleRate:t,toSampleRate:i,channels:r,inputBufferSize:s}=e;if(!t||!i||!r)throw new Error("Invalid settings specified for the resampler.");this.resampler=null,this.fromSampleRate=t,this.toSampleRate=i,this.channels=r||0,this.inputBufferSize=s,this.initialize()}initialize(){this.fromSampleRate==this.toSampleRate?(this.resampler=e=>e,this.ratioWeight=1):(this.fromSampleRate<this.toSampleRate?(this.linearInterpolation(),this.lastWeight=1):(this.multiTap(),this.tailExists=!1,this.lastWeight=0),this.initializeBuffers(),this.ratioWeight=this.fromSampleRate/this.toSampleRate)}bufferSlice(e){try{return this.outputBuffer.subarray(0,e)}catch(t){try{return this.outputBuffer.length=e,this.outputBuffer}catch(t){return this.outputBuffer.slice(0,e)}}}initializeBuffers(){this.outputBufferSize=Math.ceil(this.inputBufferSize*this.toSampleRate/this.fromSampleRate/this.channels*1.0000004768371582)+this.channels+this.channels;try{this.outputBuffer=new Float32Array(this.outputBufferSize),this.lastOutput=new Float32Array(this.channels)}catch(e){this.outputBuffer=[],this.lastOutput=[]}}linearInterpolation(){this.resampler=e=>{let t,i,r,s,a,n,o,l,d,h=e.length,c=this.channels;if(h%c!=0)throw new Error("Buffer was of incorrect sample length.");if(h<=0)return[];for(t=this.outputBufferSize,i=this.ratioWeight,r=this.lastWeight,s=0,a=0,n=0,o=0,l=this.outputBuffer;r<1;r+=i)for(a=r%1,s=1-a,this.lastWeight=r%1,d=0;d<this.channels;++d)l[o++]=this.lastOutput[d]*s+e[d]*a;for(r-=1,h-=c,n=Math.floor(r)*c;o<t&&n<h;){for(a=r%1,s=1-a,d=0;d<this.channels;++d)l[o++]=e[n+(d>0?d:0)]*s+e[n+(c+d)]*a;r+=i,n=Math.floor(r)*c}for(d=0;d<c;++d)this.lastOutput[d]=e[n++];return this.bufferSlice(o)}}multiTap(){this.resampler=e=>{let t,i,r,s,a,n,o,l,d,h,c,u=e.length,p=this.channels;if(u%p!=0)throw new Error("Buffer was of incorrect sample length.");if(u<=0)return[];for(t=this.outputBufferSize,i=[],r=this.ratioWeight,s=0,n=0,o=0,l=!this.tailExists,this.tailExists=!1,d=this.outputBuffer,h=0,c=0,a=0;a<p;++a)i[a]=0;do{if(l)for(s=r,a=0;a<p;++a)i[a]=0;else{for(s=this.lastWeight,a=0;a<p;++a)i[a]=this.lastOutput[a];l=!0}for(;s>0&&n<u;){if(o=1+n-c,!(s>=o)){for(a=0;a<p;++a)i[a]+=e[n+(a>0?a:0)]*s;c+=s,s=0;break}for(a=0;a<p;++a)i[a]+=e[n++]*o;c=n,s-=o}if(0!==s){for(this.lastWeight=s,a=0;a<p;++a)this.lastOutput[a]=i[a];this.tailExists=!0;break}for(a=0;a<p;++a)d[h++]=i[a]/r}while(n<u&&h<t);return this.bufferSlice(h)}}resample(e){return this.fromSampleRate==this.toSampleRate?this.ratioWeight=1:(this.fromSampleRate<this.toSampleRate?this.lastWeight=1:(this.tailExists=!1,this.lastWeight=0),this.initializeBuffers(),this.ratioWeight=this.fromSampleRate/this.toSampleRate),this.resampler(e)}}const Ac=15,vc=4,bc=132,_c=[255,511,1023,2047,4095,8191,16383,32767];function wc(e,t,i){for(let r=0;r<i;r++)if(e<=t[r])return r;return i}function Ec(e){const t=[];return Array.prototype.slice.call(e).forEach(((e,i)=>{t[i]=function(e){let t,i,r;return e>=0?t=213:(t=85,(e=-e-1)<0&&(e=32767)),i=wc(e,_c,8),i>=8?127^t:(r=i<<vc,r|=i<2?e>>4&Ac:e>>i+3&Ac,r^t)}(e)})),t}function Sc(e){const t=[];return Array.prototype.slice.call(e).forEach(((e,i)=>{t[i]=function(e){let t=0;e<0?(e=bc-e,t=127):(e+=bc,t=255);let i=wc(e,_c,8);return i>=8?127^t:(i<<4|e>>i+3&15)^t}(e)})),t}class Tc extends t{constructor(e,t={}){super(),this._opt={},e&&(this.player=e),this.tag="talk";const i=_a(Zi);this._opt=Object.assign({},i,t),this._opt.sampleRate=parseInt(this._opt.sampleRate,10),this._opt.sampleBitsWidth=parseInt(this._opt.sampleBitsWidth,10),this.audioContext=null,this.gainNode=null,this.recorder=null,this.workletRecorder=null,this.biquadFilter=null,this.userMediaStream=null,this.clearWorkletUrlTimeout=null,this.bufferSize=512,this._opt.audioBufferLength=this.calcAudioBufferLength(),this.audioBufferList=[],this.socket=null,this.socketStatus=dt,this.mediaStreamSource=null,this.heartInterval=null,this.checkGetUserMediaTimeout=null,this.wsUrl=null,this.startTimestamp=0,this.sequenceId=0,this.tempTimestamp=null,this.tempG711BufferList=[],this.tempRtpBufferList=[],this.events=new Ma(this),this._initTalk(),this.player||(this.debug=new Xr(this)),this._opt.encType!==gi&&this._opt.encType!==Ai||8e3===this._opt.sampleRate&&16===this._opt.sampleBitsWidth||this.warn(this.tag,`\n encType is ${this._opt.encType} and sampleBitsWidth is ${this._opt.sampleBitsWidth}, set sampleBitsWidth to ${this._opt.sampleBitsWidth}。\n ${this._opt.encType} only support sampleRate 8000 and sampleBitsWidth 16`),this.log(this.tag,"init",JSON.stringify(this._opt))}destroy(){this.clearWorkletUrlTimeout&&(clearTimeout(this.clearWorkletUrlTimeout),this.clearWorkletUrlTimeout=null),this.userMediaStream&&(this.userMediaStream.getTracks&&this.userMediaStream.getTracks().forEach((e=>{e.stop()})),this.userMediaStream=null),this.mediaStreamSource&&(this.mediaStreamSource.disconnect(),this.mediaStreamSource=null),this.recorder&&(this.recorder.disconnect(),this.recorder.onaudioprocess=null,this.recorder=null),this.biquadFilter&&(this.biquadFilter.disconnect(),this.biquadFilter=null),this.gainNode&&(this.gainNode.disconnect(),this.gainNode=null),this.workletRecorder&&(this.workletRecorder.disconnect(),this.workletRecorder=null),this.socket&&(this.socketStatus===ht&&this._sendClose(),this.socket.close(),this.socket=null),this._stopHeartInterval(),this._stopCheckGetUserMediaTimeout(),this.audioContext=null,this.gainNode=null,this.recorder=null,this.audioBufferList=[],this.sequenceId=0,this.wsUrl=null,this.tempTimestamp=null,this.tempRtpBufferList=[],this.tempG711BufferList=[],this.startTimestamp=0,this.log("talk","destroy")}addRtpToBuffer(e){const t=e.length+this.tempRtpBufferList.length,i=new Uint8Array(t);i.set(this.tempRtpBufferList,0),i.set(e,this.tempRtpBufferList.length),this.tempRtpBufferList=i}addG711ToBuffer(e){const t=e.length+this.tempG711BufferList.length,i=new Uint8Array(t);i.set(this.tempG711BufferList,0),i.set(e,this.tempG711BufferList.length),this.tempG711BufferList=i}downloadRtpFile(){const e=new Blob([this.tempRtpBufferList]);try{const t=document.createElement("a");t.href=window.URL.createObjectURL(e),t.download=Date.now()+".rtp",t.click(),window.URL.revokeObjectURL(t.href)}catch(e){console.error("downloadRtpFile",e)}}downloadG711File(){const e=new Blob([this.tempG711BufferList]);try{const t=document.createElement("a");t.href=window.URL.createObjectURL(e),t.download=Date.now()+"."+this._opt.encType,t.click(),window.URL.revokeObjectURL(t.href)}catch(e){console.error("downloadRtpFile",e)}}calcAudioBufferLength(){const{sampleRate:e,sampleBitsWidth:t}=this._opt;return 8*e*.02/8}get socketStatusOpen(){return this.socketStatus===ht}log(...e){this._log("log",...e)}warn(...e){this._log("warn",...e)}error(...e){this._log("error",...e)}_log(e,...t){this.player?this.player.debug[e](...t):this.debug?this.debug[e](...t):console[e](...t)}_getSequenceId(){return++this.sequenceId}_createWebSocket(){return new Promise(((e,t)=>{const i=this.events.proxy;this.socket=new WebSocket(this.wsUrl),this.socket.binaryType="arraybuffer",this.emit(st.talkStreamStart),i(this.socket,Ki,(()=>{this.socketStatus=ht,this.log(this.tag,"websocket open -> do talk"),this.emit(st.talkStreamOpen),e(),this._doTalk()})),i(this.socket,Qi,(e=>{this.log(this.tag,"websocket message",e.data),this.emit(st.talkStreamMessage,e)})),i(this.socket,qi,(e=>{this.socketStatus=ct,this.warn(this.tag,"websocket close -> reject",e),this.emit(st.talkStreamClose),t(e)})),i(this.socket,Yi,(e=>{this.socketStatus=ut,this.error(this.tag,"websocket error -> reject",e),this.emit(st.talkStreamError,e),t(e)}))}))}_sendClose(){}_initTalk(){this._initMethods(),this._opt.engine===Xi?this._initWorklet():this._opt.engine===Ji&&this._initScriptProcessor(),this.log(this.tag,"audioContext samplerate",this.audioContext.sampleRate)}_initMethods(){this.audioContext=new(window.AudioContext||window.webkitAudioContext)({sampleRate:48e3}),this.gainNode=this.audioContext.createGain(),this.gainNode.gain.value=1,this.biquadFilter=this.audioContext.createBiquadFilter(),this.biquadFilter.type="lowpass",this.biquadFilter.frequency.value=3e3,this.resampler=new gc({fromSampleRate:this.audioContext.sampleRate,toSampleRate:this._opt.sampleRate,channels:this._opt.numberChannels,inputBufferSize:this.bufferSize})}_initScriptProcessor(){const e=this.audioContext.createScriptProcessor||this.audioContext.createJavaScriptNode;this.recorder=e.apply(this.audioContext,[this.bufferSize,this._opt.numberChannels,this._opt.numberChannels]),this.recorder.onaudioprocess=e=>this._onaudioprocess(e)}_initWorklet(){const e=fa((function(){class e extends AudioWorkletProcessor{constructor(e){super(),this._cursor=0,this._bufferSize=e.processorOptions.bufferSize,this._buffer=new Float32Array(this._bufferSize)}process(e,t,i){if(!e.length||!e[0].length)return!0;for(let t=0;t<e[0][0].length;t++)this._cursor+=1,this._cursor===this._bufferSize&&(this._cursor=0,this.port.postMessage({eventType:"data",buffer:this._buffer})),this._buffer[this._cursor]=e[0][0][t];return!0}}registerProcessor("talk-processor",e)}));console.log(">>> workletUrl >>>",e),this.audioContext.audioWorklet&&this.audioContext.audioWorklet.addModule(e).then((()=>{const e=new AudioWorkletNode(this.audioContext,"talk-processor",{processorOptions:{bufferSize:this.bufferSize}});e.connect(this.gainNode),e.port.onmessage=e=>{"data"===e.data.eventType&&this._encodeAudioData(e.data.buffer)},this.workletRecorder=e})),this.clearWorkletUrlTimeout=setTimeout((()=>{URL.revokeObjectURL(e),this.clearWorkletUrlTimeout=null}),re)}_onaudioprocess(e){const t=e.inputBuffer.getChannelData(0);this._encodeAudioData(new Float32Array(t))}_encodeAudioData(e){if(0===e[0]&&0===e[1])return void this.log(this.tag,"empty audio data");const t=this.resampler.resample(e);let i=t;if(16===this._opt.sampleBitsWidth?i=function(e){let t=e.length,i=new Int16Array(t);for(;t--;){let r=Math.max(-1,Math.min(1,e[t]));i[t]=r<0?32768*r:32767*r}return i}(t):8===this._opt.sampleBitsWidth&&(i=function(e){let t=e.length,i=new Int8Array(t);for(;t--;){let r=Math.max(-1,Math.min(1,e[t]));const s=r<0?32768*r:32767*r;i[t]=parseInt(255/(65535/(32768+s)),10)}return i}(t)),null!==i.buffer){let e=null;this._opt.encType===gi?e=Ec(i):this._opt.encType===Ai?e=Sc(i):this._opt.encType===vi&&(e=i);const t=new Uint8Array(e);for(let e=0;e<t.length;e++){let i=this.audioBufferList.length;this.audioBufferList[i++]=t[e],this.audioBufferList.length===this._opt.audioBufferLength&&(this._sendTalkMsg(new Uint8Array(this.audioBufferList)),this.audioBufferList=[])}}}_parseAudioMsg(e){let t=null;return this._opt.packetType!==$i||this._opt.encType!==gi&&this._opt.encType!==Ai?this._opt.packetType===Hi&&(t=e):t=this.rtpPacket(e),t}rtpPacket(e){const t=[];let i=0,r=0,s=0;const a=this._opt.rtpSsrc,n=e.length;this._opt.encType===gi?i=zi:this._opt.encType===Ai?i=Wi:this._opt.encType===bi&&(i=Vi),this.startTimestamp||(this.startTimestamp=vs()),s=vs()-this.startTimestamp,r=this._getSequenceId();let o=0;if(this._opt.packetTcpSendType===ji){const e=n+12;t[o++]=255&e>>8,t[o++]=255&e}t[o++]=128,t[o++]=128+i,t[o++]=r/256,t[o++]=r%256,t[o++]=s/65536/256,t[o++]=s/65536%256,t[o++]=s%65536/256,t[o++]=s%65536%256,t[o++]=a/65536/256,t[o++]=a/65536%256,t[o++]=a%65536/256,t[o++]=a%65536%256;let l=t.concat([...e]),d=new Uint8Array(l.length);for(let e=0;e<l.length;e++)d[e]=l[e];return d}opusPacket(e){return e}_sendTalkMsg(e){null===this.tempTimestamp&&(this.tempTimestamp=vs());const t=vs(),i=t-this.tempTimestamp,r=this._parseAudioMsg(e);this.log(this.tag,`send talk msg and diff is ${i} and byteLength is ${r.byteLength} and length is ${r.length}, and ${this._opt.encType} length is ${e.length}`),Ta(this._opt.saveToTempFile)&&Ta(this._opt.debug)&&(this._opt.packetType===$i?this.addRtpToBuffer(r):this.addG711ToBuffer(r)),r&&(this.socketStatusOpen?this.socket.send(r.buffer):this.emit(lt.tallWebsocketClosedByError)),this.tempTimestamp=t}_doTalk(){this._getUserMedia()}_getUserMedia(){this.log(this.tag,"getUserMedia"),void 0===window.navigator.mediaDevices&&(window.navigator.mediaDevices={}),void 0===window.navigator.mediaDevices.getUserMedia&&(this.log(this.tag,"window.navigator.mediaDevices.getUserMedia is undefined and init function"),window.navigator.mediaDevices.getUserMedia=function(e){var t=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;return t?new Promise((function(i,r){t.call(navigator,e,i,r)})):Promise.reject(new Error("getUserMedia is not implemented in this browser"))}),this._opt.checkGetUserMediaTimeout&&this._startCheckGetUserMediaTimeout(),window.navigator.mediaDevices.getUserMedia({audio:this._opt.audioConstraints,video:!1}).then((e=>{this.log(this.tag,"getUserMedia success"),this.userMediaStream=e,this.mediaStreamSource=this.audioContext.createMediaStreamSource(e),this.mediaStreamSource.connect(this.biquadFilter),this.recorder?(this.biquadFilter.connect(this.recorder),this.recorder.connect(this.gainNode)):this.workletRecorder&&(this.biquadFilter.connect(this.workletRecorder),this.workletRecorder.connect(this.gainNode)),this.gainNode.connect(this.audioContext.destination),this.emit(st.talkGetUserMediaSuccess),null===e.oninactive&&(e.oninactive=e=>{this._handleStreamInactive(e)})})).catch((e=>{this.error(this.tag,"getUserMedia error",e.toString()),this.emit(st.talkGetUserMediaFail,e.toString())})).finally((()=>{this.log(this.tag,"getUserMedia finally"),this._stopCheckGetUserMediaTimeout()}))}_getUserMedia2(){this.log(this.tag,"getUserMedia"),navigator.mediaDevices?navigator.mediaDevices.getUserMedia({audio:!0}).then((e=>{this.log(this.tag,"getUserMedia2 success")})):navigator.getUserMedia({audio:!0},this.log(this.tag,"getUserMedia2 success"),this.log(this.tag,"getUserMedia2 fail"))}async _getUserMedia3(){this.log(this.tag,"getUserMedia3");try{const e=await navigator.mediaDevices.getUserMedia({audio:{latency:!0,noiseSuppression:!0,autoGainControl:!0,echoCancellation:!0,sampleRate:48e3,channelCount:1},video:!1});console.log("getUserMedia() got stream:",e),this.log(this.tag,"getUserMedia3 success")}catch(e){this.log(this.tag,"getUserMedia3 fail")}}_handleStreamInactive(e){this.userMediaStream&&(this.warn(this.tag,"stream oninactive",e),this.emit(st.talkStreamInactive))}_startCheckGetUserMediaTimeout(){this._stopCheckGetUserMediaTimeout(),this.checkGetUserMediaTimeout=setTimeout((()=>{this.log(this.tag,"check getUserMedia timeout"),this.emit(st.talkGetUserMediaTimeout)}),this._opt.getUserMediaTimeout)}_stopCheckGetUserMediaTimeout(){this.checkGetUserMediaTimeout&&(this.log(this.tag,"stop checkGetUserMediaTimeout"),clearTimeout(this.checkGetUserMediaTimeout),this.checkGetUserMediaTimeout=null)}_startHeartInterval(){this.heartInterval=setInterval((()=>{this.log(this.tag,"heart interval");let e=[35,36,0,0,0,0,0,0];e=new Uint8Array(e),this.socket.send(e.buffer)}),15e3)}_stopHeartInterval(){this.heartInterval&&(this.log(this.tag,"stop heart interval"),clearInterval(this.heartInterval),this.heartInterval=null)}startTalk(e){return new Promise(((t,i)=>{if(!function(){let e=!1;const t=window.navigator;return t&&(e=!(!t.mediaDevices||!t.mediaDevices.getUserMedia),e||(e=!!(t.getUserMedia||t.webkitGetUserMedia||t.mozGetUserMedia||t.msGetUserMedia))),e}())return i("not support getUserMedia");if(this.wsUrl=e,this._opt.testMicrophone)this._doTalk();else{if(!this.wsUrl)return i("wsUrl is null");this._createWebSocket().catch((e=>{i(e)}))}this.once(st.talkGetUserMediaFail,(()=>{i("getUserMedia fail")})),this.once(st.talkGetUserMediaSuccess,(()=>{t()}))}))}setVolume(e){e=parseFloat(e).toFixed(2),isNaN(e)||(e=bs(e,0,1),this.gainNode.gain.value=e)}getOption(){return this._opt}get volume(){return this.gainNode?parseFloat(100*this.gainNode.gain.value).toFixed(0):null}}class kc{constructor(e){this.player=e,this.globalSetting=null;const t=Us();this.defaultSettings={watermark_id:`EasyPlayerPro_${t}`,watermark_prefix:`EasyPlayerPro_mask_${t}`,watermark_txt:"EasyPlayerPro 测试水印",watermark_x:0,watermark_y:0,watermark_rows:0,watermark_cols:0,watermark_x_space:0,watermark_y_space:0,watermark_font:"微软雅黑",watermark_color:"black",watermark_fontsize:"18px",watermark_alpha:.15,watermark_width:150,watermark_height:100,watermark_angle:15,watermark_parent_width:0,watermark_parent_height:0,watermark_parent_node:null},this.player.debug.log("Watermark","int")}destroy(){this._removeMark(),this.globalSetting=null,this.defaultSettings={watermark_id:"",watermark_prefix:"",watermark_txt:"EasyPlayerPro 测试水印",watermark_x:0,watermark_y:0,watermark_rows:0,watermark_cols:0,watermark_x_space:0,watermark_y_space:0,watermark_font:"微软雅黑",watermark_color:"black",watermark_fontsize:"18px",watermark_alpha:.15,watermark_width:150,watermark_height:100,watermark_angle:-15,watermark_parent_width:0,watermark_parent_height:0,watermark_parent_node:null},this.player.debug.log("Watermark","destroy")}remove(){this._removeMark()}load(e){this.globalSetting=e,this._loadMark(e)}resize(){this.player.debug.log("Watermark","resize()"),this.globalSetting&&this._loadMark(this.globalSetting)}_loadMark(){let e=this.defaultSettings;if(1===arguments.length&&"object"==typeof arguments[0]){var t=arguments[0]||{};for(let i in t)t[i]&&e[i]&&t[i]===e[i]||(t[i]||0===t[i])&&(e[i]=t[i])}var i=document.getElementById(e.watermark_id);i&&i.parentNode&&i.parentNode.removeChild(i);var r="string"==typeof e.watermark_parent_node?document.getElementById(e.watermark_parent_node):e.watermark_parent_node,s=r||document.body;const a=s.getBoundingClientRect();var n=Math.max(s.scrollWidth,s.clientWidth,a.width),o=Math.max(s.scrollHeight,s.clientHeight,a.height),l=arguments[0]||{},d=s;(l.watermark_parent_width||l.watermark_parent_height)&&d&&(e.watermark_x=e.watermark_x+0,e.watermark_y=e.watermark_y+0);var h=document.getElementById(e.watermark_id),c=null;if(h)h.shadowRoot&&(c=h.shadowRoot);else{(h=document.createElement("div")).id=e.watermark_id,h.setAttribute("style","pointer-events: none !important; display: block !important"),c="function"==typeof h.attachShadow?h.attachShadow({mode:"open"}):h;var u=s.children,p=Math.floor(Math.random()*(u.length-1))+1;u[p]?s.insertBefore(h,u[p]):s.appendChild(h)}e.watermark_cols=parseInt((n-e.watermark_x)/(e.watermark_width+e.watermark_x_space));var f,y=parseInt((n-e.watermark_x-e.watermark_width*e.watermark_cols)/e.watermark_cols);e.watermark_x_space=y?e.watermark_x_space:y,e.watermark_rows=parseInt((o-e.watermark_y)/(e.watermark_height+e.watermark_y_space));var m,g,A,v=parseInt((o-e.watermark_y-e.watermark_height*e.watermark_rows)/e.watermark_rows);e.watermark_y_space=v?e.watermark_y_space:v,r?(f=e.watermark_x+e.watermark_width*e.watermark_cols+e.watermark_x_space*(e.watermark_cols-1),m=e.watermark_y+e.watermark_height*e.watermark_rows+e.watermark_y_space*(e.watermark_rows-1)):(f=0+e.watermark_x+e.watermark_width*e.watermark_cols+e.watermark_x_space*(e.watermark_cols-1),m=0+e.watermark_y+e.watermark_height*e.watermark_rows+e.watermark_y_space*(e.watermark_rows-1));for(var b=0;b<e.watermark_rows;b++){A=r?0+e.watermark_y+(o-m)/2+(e.watermark_y_space+e.watermark_height)*b:e.watermark_y+(o-m)/2+(e.watermark_y_space+e.watermark_height)*b;for(var _=0;_<e.watermark_cols;_++){g=r?0+e.watermark_x+(n-f)/2+(e.watermark_width+e.watermark_x_space)*_:e.watermark_x+(n-f)/2+(e.watermark_width+e.watermark_x_space)*_;var w=document.createElement("div"),E=document.createTextNode(e.watermark_txt);w.appendChild(E),w.id=e.watermark_prefix+b+_,w.style.webkitTransform="rotate("+e.watermark_angle+"deg)",w.style.MozTransform="rotate("+e.watermark_angle+"deg)",w.style.msTransform="rotate("+e.watermark_angle+"deg)",w.style.OTransform="rotate("+e.watermark_angle+"deg)",w.style.transform="rotate("+e.watermark_angle+"deg)",w.style.visibility="",w.style.position="absolute",w.style.left=g+"px",w.style.top=A+"px",w.style.overflow="hidden",w.style.zIndex="9999999",w.style.opacity=e.watermark_alpha,w.style.fontSize=e.watermark_fontsize,w.style.fontFamily=e.watermark_font,w.style.color=e.watermark_color,w.style.textAlign="center",w.style.width=e.watermark_width+"px",w.style.height=e.watermark_height+"px",w.style.display="block",w.style["-ms-user-select"]="none",c.appendChild(w)}}}_removeMark(){const e=this.defaultSettings;var t=document.getElementById(e.watermark_id);if(t){var i=t.parentNode;i&&i.removeChild(t)}}}class Cc{constructor(e){this.player=e,this.globalSetting=null;const t=Us();this.defaultSettings={watermark_id:`EasyPlayerPro_${t}`,watermark_prefix:`EasyPlayerPro_mask_${t}`,watermark_txt:"EasyPlayerPro 测试水印",watermark_x:0,watermark_y:0,watermark_rows:0,watermark_cols:0,watermark_x_space:100,watermark_y_space:100,watermark_font:"微软雅黑",watermark_color:"black",watermark_fontsize:18,watermark_alpha:.15,watermark_width:150,watermark_height:100,watermark_angle:-15,watermark_parent_width:0,watermark_parent_height:0,watermark_parent_node:null},this.player.debug.log("Watermark","int")}destroy(){this._removeMark(),this.globalSetting=null,this.defaultSettings={watermark_id:"",watermark_prefix:"",watermark_txt:"EasyPlayerPro 测试水印",watermark_x:0,watermark_y:0,watermark_rows:0,watermark_cols:0,watermark_x_space:100,watermark_y_space:100,watermark_font:"微软雅黑",watermark_color:"black",watermark_fontsize:18,watermark_alpha:.15,watermark_width:150,watermark_height:100,watermark_angle:-15,watermark_parent_width:0,watermark_parent_height:0,watermark_parent_node:null},this.player.debug.log("Watermark","destroy")}remove(){this._removeMark()}load(e){this.globalSetting=e,this._loadMark(e)}resize(){this.player.debug.log("Watermark","resize()"),this.globalSetting&&this._loadMark(this.globalSetting)}_loadMark(){let e=this.defaultSettings;if(1===arguments.length&&"object"==typeof arguments[0]){var t=arguments[0]||{};for(let i in t)t[i]&&e[i]&&t[i]===e[i]||(t[i]||0===t[i])&&(e[i]=t[i])}var i=document.getElementById(e.watermark_id);i&&i.parentNode&&i.parentNode.removeChild(i);var r="string"==typeof e.watermark_parent_node?document.getElementById(e.watermark_parent_node):e.watermark_parent_node,s=r||document.body;const a=s.getBoundingClientRect();var n=Math.max(s.scrollWidth,s.clientWidth,a.width),o=Math.max(s.scrollHeight,s.clientHeight,a.height),l=arguments[0]||{},d=s;(l.watermark_parent_width||l.watermark_parent_height)&&d&&(e.watermark_x=e.watermark_x+0,e.watermark_y=e.watermark_y+0);var h=document.getElementById(e.watermark_id),c=null;if(h)h.shadowRoot&&(c=h.shadowRoot);else{(h=document.createElement("div")).id=e.watermark_id,h.setAttribute("style","pointer-events: none !important; display: block !important"),c="function"==typeof h.attachShadow?h.attachShadow({mode:"open"}):h;var u=s.children,p=Math.floor(Math.random()*(u.length-1))+1;u[p]?s.insertBefore(h,u[p]):s.appendChild(h)}const f=this._calcTextSize(),y=this.defaultSettings,m=y.watermark_x_space+f.width,g=y.watermark_y_space+f.height,A=2*g,v=m/2,b=`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="none">\n <defs>\n <pattern id="pattern1" x="0" y="0" width="${m}" height="${A}" patternUnits="userSpaceOnUse" patternTransform="rotate(${y.watermark_angle})">\n <text x="0" y="${y.watermark_fontsize}" style="font-family:${y.watermark_font}; font-size:${y.watermark_fontsize}; fill:${y.watermark_color}; fill-opacity:${y.watermark_alpha}">${y.watermark_txt}</text>\n </pattern>\n <pattern id="pattern2" x="${v}" y="${g}" width="${m}" height="${A}" patternUnits="userSpaceOnUse" patternTransform="rotate(${y.watermark_angle})">\n <text x="0" y="${y.watermark_fontsize}" style="font-family:${y.watermark_font}; font-size:${y.watermark_fontsize}; fill:${y.watermark_color}; fill-opacity:${y.watermark_alpha}">${y.watermark_txt}</text>\n </pattern>\n </defs>\n <rect x="0" y="0" width="100%" height="100%" style="fill:url(#pattern1); fill-opacity:1;" />\n <rect x="0" y="0" width="100%" height="100%" style="fill:url(#pattern2); fill-opacity:1;" />\n </svg>`,_=window.btoa(unescape(encodeURIComponent(b)));var w=document.createElement("div");w.style.position="absolute",w.style.left="0px",w.style.top="0px",w.style.overflow="hidden",w.style.zIndex="9999999",w.style.width=n+"px",w.style.height=o+"px",w.style.display="block",w.style["-ms-user-select"]="none",w.style.backgroundImage=`url(data:image/svg+xml;base64,${_})`,c.appendChild(w)}_removeMark(){const e=this.defaultSettings;var t=document.getElementById(e.watermark_id);if(t){var i=t.parentNode;i&&i.removeChild(t)}}_calcTextSize(){const{watermark_txt:e,watermark_font:t,watermark_fontsize:i}=this.globalSetting,r=document.createElement("span");r.innerHTML=e,r.setAttribute("style",`font-family: ${t}; font-size: ${i}px; visibility: hidden; display: inline-block`),document.querySelector("body").appendChild(r);const s={width:r.offsetWidth,height:r.offsetHeight};return r.remove(),s}}const Dc="right",Rc="left",xc="up",Lc="down",Ic="leftUp",Pc="leftDown",Bc="rightUp",Mc="rightDown",Uc="zoomExpand",Fc="zoomNarrow",Oc="apertureFar",Nc="apertureNear",Gc="focusFar",zc="focusNear",Wc="setPos",Vc="calPos",Hc="delPos",$c="wiperOpen",jc="wiperClose",Kc={stop:0,fiStop:0,right:1,left:2,up:8,down:4,leftUp:10,leftDown:6,rightUp:9,rightDown:5,zoomExpand:16,zoomNarrow:32,apertureFar:72,apertureNear:68,focusFar:66,focusNear:65,setPos:129,calPos:130,delPos:131,wiperOpen:140,wiperClose:141},qc=[25,50,75,100,125,150,175,200,225,250],Yc=[1,2,3,4,5,6,7,8,9,16],Qc=[16,48,80,112,144,160,176,192,208,224];function Xc(e){const{type:t,speed:i=5,index:r=0}=e,s=function(e){e=e||5;const t=e-1,i=qc[t]||qc[4];return i}(i);let a,n,o,l;switch(a=Kc[t],t){case xc:case Lc:case Oc:case Nc:o=s;break;case Dc:case Rc:case Gc:case zc:n=s;break;case Ic:case Pc:case Bc:case Mc:n=s,o=s;break;case Uc:case Fc:l=function(e){e=e||5;const t=e-1,i=Qc[t]||Qc[4];return i}(i);break;case Vc:case Hc:case Wc:o=function(e){return Yc[e-1]}(r);break;case jc:case $c:n=1}return function(e,t,i,r){let s=[];s[0]=165,s[1]=15,s[2]=1,s[3]=0,s[4]=0,s[5]=0,s[6]=0,e&&(s[3]=e);t&&(s[4]=t);i&&(s[5]=i);r&&(s[6]=r);return s[7]=(s[0]+s[1]+s[2]+s[3]+s[4]+s[5]+s[6])%256,function(e){let t="";for(let i=0;i<e.length;i++){let r=e[i].toString(16);1===r.length&&(r="0"+r),t+=r.toUpperCase()}return t}(s)}(a,n,o,l)}const Jc=["Boolean","Number","String","Undefined","Null","Date","Object"];function Zc(e){if("object"!=typeof e)return e;const t=Object.prototype.toString.call(e).slice(8,-1);switch(t){case"Array":case"Uint8Array":case"ArrayBuffer":return t+"["+e.length+"]";case"Object":return"{}";default:return t}}function eu(e,t,i){i||(i=1),t||(t=2);const r={};if(!e||"object"!=typeof e)return e;const s=Object.prototype.toString.call(e).slice(8,-1);if(!Jc.includes(s))return s;if(!(i>t)){for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(i===t?r[s]=Zc(e[s]):"object"==typeof e[s]?r[s]=eu(e[s],t,i+1):r[s]=e[s]);return r}}function tu(){return(new Date).toLocaleString()}class iu{constructor(e,t={}){this.player=e,this.logMaxSize=t?.logMaxSize||204800,this.logSize=0,this.logTextArray=[]}destroy(){this.clear()}clear(){this.logSize=0,this.logTextArray=[]}logCache(...e){let t="";try{const i=e.map((e=>eu(e)));t="[EasyPro] "+tu()+JSON.stringify(i)}catch(e){return}if(this.logSize+=t.length,this.logTextArray.push(t),this.logSize>this.logMaxSize){const e=this.logTextArray.shift();this.logSize-=e.length}}download(){const e=this.logTextArray.join("\n");this.clear();const t=new Blob([e],{type:"text/plain"});Ja(t,"EasyPro-"+tu()+".log")}}class ru extends t{constructor(e={}){super(),this._opt={},this.$container=null,Object.keys(e).forEach((t=>{if(void 0===e[t])throw new Error(`EasyPro option "${t}" can not be undefined`)})),(Ls()||Is())&&(e.useMSE=!1,e.useWCS=!1),this.originalOptions=e;const t=wa();let i=Object.assign({},t,e);i.url="",i.isMulti&&(i.debugUuid="xxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))),this.debug=new Xr(this),this.debug.log("EasyPro","init");let r=e.container;if("string"==typeof e.container&&(r=document.querySelector(e.container)),!r)throw this.debug.error("EasyPro","EasyPro need container option and now container is",e.container),new Error("EasyPro need container option");if(i.decoder&&ka(-1!==i.decoder.indexOf("decoder-pro.js")||-1!==i.decoder.indexOf("decoder-pro-simd.js")))throw this.debug.error("EasyPro",`EasyPro decoder ${i.decoder} must be decoder-pro.js or decoder-pro-simd.js`),new Error(`EasyPro decoder ${i.decoder} must be decoder-pro.js or decoder-pro-simd.js`);if("CANVAS"===r.nodeName||"VIDEO"===r.nodeName)throw this.debug.error("EasyPro",`EasyPro container type can not be ${r.nodeName} type`),new Error(`EasyPro container type can not be ${r.nodeName} type`);if(i.videoBuffer>=i.heartTimeout)throw this.debug.error("EasyPro",`EasyPro videoBuffer ${i.videoBuffer}s must be less than heartTimeout ${i.heartTimeout}s`),new Error(`EasyPro videoBuffer ${i.videoBuffer}s must be less than heartTimeout ${i.heartTimeout}s`);if(this._checkHasCreated(r))throw this.debug.error("EasyPro","EasyPro container has been created and can not be created again",r),new Error("EasyPro container has been created and can not be created again",r);if(r.classList.add("easyplayer-container"),Ca(r,ie,Us()),ka(i.isLive)){const e=document.createElement("video");return e.muted=!0,e.setAttribute("controlsList","nodownload"),e.disablePictureInPicture="disablePictureInPicture",e.style.position="absolute",e.style.top=0,e.style.left=0,e.style.height="100%",e.style.width="100%",r.appendChild(e),this.$videoElement=e,this.$container=r,void(this._opt=i)}if(delete i.container,Ks(i.videoBuffer)&&(i.videoBuffer=1e3*Number(i.videoBuffer)),Ks(i.videoBufferDelay)&&(i.videoBufferDelay=1e3*Number(i.videoBufferDelay)),Ks(i.networkDelay)&&(i.networkDelay=1e3*Number(i.networkDelay)),Ks(i.aiFaceDetectInterval)&&(i.aiFaceDetectInterval=1e3*Number(i.aiFaceDetectInterval)),Ks(i.aiObjectDetectInterval)&&(i.aiObjectDetectInterval=1e3*Number(i.aiObjectDetectInterval)),Ks(i.timeout)&&($s(i.loadingTimeout)&&(i.loadingTimeout=i.timeout),$s(i.heartTimeout)&&(i.heartTimeout=i.timeout)),Ks(i.autoWasm)&&($s(i.decoderErrorAutoWasm)&&(i.decoderErrorAutoWasm=i.autoWasm),$s(i.hardDecodingNotSupportAutoWasm)&&(i.hardDecodingNotSupportAutoWasm=i.autoWasm)),Ks(i.aiFaceDetectLevel)&&$s(i.aiFaceDetectWidth)){const e=Rr[i.aiFaceDetectLevel];e&&(i.aiFaceDetectWidth=e)}if(Ks(i.aiObjectDetectLevel)&&$s(i.aiObjectDetectWidth)){const e=xr[i.aiObjectDetectLevel];e&&(i.aiObjectDetectWidth=e)}Ta(i.isCrypto)&&(i.isM7sCrypto=!0),this._opt=i,this._destroyed=!1,this.$container=r,this._tempPlayBgObj={},this._loadingTimeoutReplayTimes=0,this._heartTimeoutReplayTimes=0,this.events=new Ma(this),this._opt.isUseNewFullscreenWatermark?this.watermark=new Cc(this):this.watermark=new kc(this),this.memoryLogger=new iu(this),this._initPlayer(r,i),this._initWatermark(),this.debug.log("EasyPro",`init success and version is ${Ts}`),console.log(`EasyPro Version is ${Ts}`)}destroy(){return new Promise(((e,t)=>{this.debug.log("EasyPro","destroy()"),this._destroyed=!0,this.off(),this.$videoElement&&(this.$videoElement.pause(),this.$videoElement.currentTime=0,this.$videoElement.srcObject&&(this.$videoElement.srcObject=null,this.$videoElement.removeAttribute("srcObject")),this.$videoElement.src&&(this.$videoElement.src="",this.$videoElement.removeAttribute("src")),this.$container&&this.$container.removeChild(this.$videoElement),this.$videoElement=null),this.player?this.player.destroy().then((()=>{this.player=null,this._destroy(),setTimeout((()=>{e()}),0)})).catch((()=>{t()})):(this._destroy(),setTimeout((()=>{e()}),0))}))}_destroy(){var e,t;this.events&&(this.events.destroy(),this.events=null),this.talk&&(this.talk.destroy(),this.talk=null),this.watermark&&(this.watermark.destroy(),this.watermark=null),this.memoryLogger&&(this.memoryLogger.destroy(),this.memoryLogger=null),this.$container&&(this.$container.classList.remove("easyplayer-container"),this.$container.classList.remove("easyplayer-fullscreen-web"),e=this.$container,t=ie,e&&(e.dataset?delete e.dataset[t]:e.removeAttribute("data-"+t)),this.$container=null),this.debug&&this.debug.log("EasyPro","destroy end"),this._resetOpt(),this._tempPlayBgObj=null,this._loadingTimeoutReplayTimes=0,this._heartTimeoutReplayTimes=0}_resetOpt(){this._opt=wa()}_getOriginalOpt(){const e=wa();return Object.assign({},e,this.originalOptions)}_initPlayer(e,t){this.player=new mc(e,t),this._bindEvents()}_initTalk(e={}){this.talk&&(this.talk.destroy(),this.talk=null),this.player&&(e.debug=this.player._opt.debug),this.talk=new Tc(this.player,e),this.debug.log("EasyPro","_initTalk",this.talk.getOption()),this._bindTalkEvents()}_resetPlayer(e={}){return new Promise(((t,i)=>{const r=()=>{this._opt.url="",this._opt.playOptions={},this._opt=Object.assign(this._opt,e),this._initPlayer(this.$container,this._opt)};this.player?this.player.destroy().then((()=>{this.player=null,r(),setTimeout((()=>{t()}),0)})):(r(),setTimeout((()=>{t()}),0))}))}_bindEvents(){Object.keys(at).forEach((e=>{this.player.on(at[e],((...t)=>{this.emit(e,...t)}))})),this._opt.playFailedAndPausedShowMessage&&this.on(st.playFailedAndPaused,(e=>{this.player&&this.player.showTipsMessageByCode(e)})),this.player.once(st.beforeDestroy,(()=>{this.emit(st.close),this.destroy().then((()=>{})).catch((e=>{}))})),this.player.on(st.resize,(()=>{this.watermark&&this.watermark.resize()})),this.player.on(st.screenshots,(()=>{this.emit(st.screenshots,!0)})),this.player.on(st.fullscreen,(()=>{this.watermark&&this.watermark.resize()})),this.player.on(st.videoInfo,(()=>{this.player&&(this.player.singleWatermark&&this.player.singleWatermark.resize(),this.player.ghostWatermark&&this.player.ghostWatermark.resize(),this.player.dynamicWatermark&&this.player.dynamicWatermark.resize())})),this.player.on(st.memoryLog,((...e)=>{this.memoryLogger.logCache(...e)})),this.player.on(st.downloadMemoryLog,(()=>{this.downloadMemoryLog()}))}_bindTalkEvents(){Object.keys(nt).forEach((e=>{this.player.on(nt[e],(t=>{this.emit(e,t)}))}))}_initWatermark(){if(sa(this._opt.fullscreenWatermarkConfig)){const e=Ys(this.$container,this._opt.fullscreenWatermarkConfig);if(!e.watermark_txt)return void this.debug.warn("EasyPro","fullscreenWatermarkConfig text is empty");this.watermark.load(e)}}_checkHasCreated(e){if(!e)return!1;return!!Da(e,ie)}isDestroyed(){return this._destroyed}getOption(){return this.player?this.player.getOption():{}}setDebug(e){this.debug.log("EasyPro",`setDebug() ${e}`),this._opt.debug=!!e,this.player?this.player.updateOption({debug:!!e},!0):this.debug.warn("EasyPro","player is not init")}getIsDebug(){let e=!1;return this.player&&(e=this.player._opt.debug),e}mute(){this.debug.log("EasyPro","mute()"),this.player&&this.player.mute(!0)}cancelMute(){this.debug.log("EasyPro","cancelMute()"),this.player&&this.player.mute(!1)}setVolume(e){this.debug.log("EasyPro",`setVolume() ${e}`),this.player&&(this.player.volume=e)}getVolume(){let e=null;return this.player&&(e=this.player.volume,e=parseFloat(e).toFixed(2)),e}audioResume(){this.debug.log("EasyPro","audioResume()"),this.player&&this.player.audio?this.player.audio.audioEnabled(!0):this.debug.warn("EasyPro","audioResume error")}setTimeout(e){this.debug.log("EasyPro",`setTimeout() ${e}`),e=Number(e),isNaN(e)?this.debug.warn("EasyPro",`setTimeout error: ${e} is not a number`):(this._opt.timeout=e,this._opt.loadingTimeout=e,this._opt.heartTimeout=e,this.player&&this.player.updateOption({timeout:e,loadingTimeout:e,heartTimeout:e}))}setScaleMode(e){this.debug.log("EasyPro",`setScaleMode() ${e}`),this.player?this.player.setScaleMode(e):this.debug.warn("EasyPro","setScaleMode() player is null")}pause(e=!1){return new Promise(((t,i)=>{this.debug.log("EasyPro",`pause() ${e}`),(this._opt.pauseAndNextPlayUseLastFrameShow||this._opt.replayUseLastFrameShow)&&(this._tempPlayBgObj=this._getVideoLastIframeInfo()),this._pause(e).then((e=>{t(e)})).catch((e=>{i(e)}))}))}_pause(e=!1){return new Promise(((t,i)=>{if(this.debug.log("EasyPro",`_pause() ${e}`),this.isDestroyed())return i("EasyPro is destroyed");this.player?this.player.pause(e).then((e=>{t(e)})).catch((e=>{i(e)})):i("player is null")}))}close(){return new Promise(((e,t)=>{this.debug.log("EasyPro","close()"),this._opt.url="",this._loadingTimeoutReplayTimes=0,this._heartTimeoutReplayTimes=0,this.player?this.player.close().then((()=>{e()})).catch((e=>{t(e)})):t("player is null")}))}clearView(){this.debug.log("EasyPro","clearView()"),this.player&&this.player.video?this.getRenderType()===K?this.player.video.clearView():this.debug.warn("EasyPro","clearView","render type is video, not support clearView, please use canvas render type"):this.debug.warn("EasyPro","clearView","player is null")}play(e="",t={}){return new Promise(((i,r)=>{if(this.debug.log("EasyPro",`play() ${e}`,JSON.stringify(t)),!e&&!this._opt.url)return this.emit(st.error,lt.playError),void r("url is null and this._opt.url is null");if(e&&-1===(e=(e=(""+e).trim()).replace("webrtcs:","webrtc:")).indexOf("http:")&&-1===e.indexOf("https:")&&-1===e.indexOf("webrtc:")&&-1===e.indexOf("ws:")&&-1===e.indexOf("wss:")&&-1===e.indexOf("wt:")&&-1===e.indexOf("artc:"))return r(`url ${e} must be "http:" or "https:" or "webrtc:" or "ws:" or "wss" or "wt:" or "artc:" protocol`);if(ka(this._opt.isLive))return this.$videoElement.controls="controls",this.$videoElement.muted=!1,this.$videoElement.src=e,this.$videoElement.play(),void i(this.$videoElement);if(this._opt.isM7sCrypto){let s=t.cryptoKey||this._opt.playOptions.cryptoKey,a=t.cryptoIV||this._opt.playOptions.cryptoIV;if(this._opt.m7sCryptoKey&&(!s||!a)){const e=this._opt.m7sCryptoKey.split(".");s=va(e[0]),a=va(e[1])}if(!s||!a){const s=e||this._opt.url;return void this._cryptoPlay(s).then((({cryptoIV:s,cryptoKey:a})=>{this._opt.playOptions.cryptoKey=a,this._opt.playOptions.cryptoIV=s,t.cryptoIV=s,t.cryptoKey=a,this._playBefore(e,t).then((()=>{i()})).catch((e=>{r(e)}))})).catch((e=>{r(e)}))}this._opt.playOptions.cryptoKey=s,this._opt.playOptions.cryptoIV=a,t.cryptoIV=a,t.cryptoKey=s}else if(this._opt.isXorCrypto){let e=t.cryptoKey||this._opt.playOptions.cryptoKey,i=t.cryptoIV||this._opt.playOptions.cryptoIV;if(this._opt.xorCryptoKey&&(!e||!i)){const t=this._opt.xorCryptoKey.split(".");e=va(t[0]),i=va(t[1])}e&&i&&(this._opt.playOptions.cryptoKey=e,this._opt.playOptions.cryptoIV=i,t.cryptoIV=i,t.cryptoKey=e)}this._playBefore(e,t).then((()=>{i()})).catch((e=>{r(e)}))}))}_playBefore(e,t){return new Promise(((i,r)=>{if(this.player)if(e)if(this._opt.url)if(e===this._opt.url)if(this.player.playing)this.debug.log("EasyPro","_playBefore","playing and resolve()"),i();else{this.debug.log("EasyPro","_playBefore","this._opt.url === url and pause -> play and destroy play");let e=this._getOriginalOpt();(this._opt.pauseAndNextPlayUseLastFrameShow||this._opt.replayUseLastFrameShow)&&this._tempPlayBgObj&&this._tempPlayBgObj.loadingBackground&&(e=Object.assign(e,this._tempPlayBgObj));const t=this.isMute(),s=this._opt.url,a={...this._opt.playOptions,isNotMute:!t};this._resetPlayer(e).then((()=>{this._play(s,a).then((()=>{this.player.resumeAudioAfterPause(),i()})).catch((e=>{this.debug.error("EasyPro","_playBefore this.player.play error",e),this.emit(st.crashLog,this.getCrashLog("this.player.play 1",e)),r(e)}))})).catch((e=>{this.debug.error("EasyPro","_resetPlayer error",e)}))}else{this.debug.log("EasyPro","_playBefore",`\n this._url.url is ${this._opt.url}\n and new url is ${e}\n and destroy and play new url`);const s=this._getOriginalOpt();this._resetPlayer(s).then((()=>{this._play(e,t).then((()=>{i()})).catch((e=>{this.debug.error("EasyPro","_playBefore _play error",e),this.emit(st.crashLog,this.getCrashLog("this.player.play 2",e)),r(e)}))})).catch((e=>{this.debug.error("EasyPro","_resetPlayer error",e)}))}else this._play(e,t).then((()=>{i()})).catch((e=>{this.debug.error("EasyPro","_playBefore _play error",e),this.emit(st.crashLog,this.getCrashLog("this.player.play 3",e)),r(e)}));else{let e=this._getOriginalOpt();(this._opt.pauseAndNextPlayUseLastFrameShow||this._opt.replayUseLastFrameShow)&&this._tempPlayBgObj&&this._tempPlayBgObj.loadingBackground&&(e=Object.assign(e,this._tempPlayBgObj));const t=this._opt.url,s=this._opt.playOptions;this._resetPlayer(e).then((()=>{this._play(t,s).then((()=>{this.player.resumeAudioAfterPause(),i()})).catch((e=>{this.debug.error("EasyPro","_playBefore _play error",e),this.emit(st.crashLog,this.getCrashLog("this.player.play 4",e)),r(e)}))})).catch((e=>{this.debug.error("EasyPro","_resetPlayer error",e)}))}else e?this._play(e,t).then((()=>{i()})).catch((e=>{this.debug.error("EasyPro","_playBefore _play error",e),this.emit(st.crashLog,this.getCrashLog("this.player.play 5",e)),r(e)})):this._play(this._opt.url,this._opt.playOptions).then((()=>{i()})).catch((e=>{this.debug.error("EasyPro","_playBefore _play error",e),this.emit(st.crashLog,this.getCrashLog("this.player.play 6",e)),r(e)}))}))}_cryptoPlay(e){return new Promise(((t,i)=>{const r=function(e){const t=(e||document.location.toString()).split("//"),i=t[1].indexOf("/");let r=t[1].substring(i);return-1!=r.indexOf("?")&&(r=r.split("?")[0]),r}(e);let s=this._opt.cryptoKeyUrl,a="";const n=ba(e);if(s){if(a=s,this._opt.isM7sCrypto&&-1===a.indexOf(`${te}?stream=`)){const e=ba(s);a=e.origin+te+`?stream=${r}`}}else s=n.origin+te,a=s+`?stream=${r}`;var o;this.player.debug.log("EasyPro",`_cryptoPlay() cryptoKeyUrl: ${a} and opt.cryptoKeyUrl: ${this._opt.cryptoKeyUrl}`),(o=a,new Promise(((e,t)=>{Io.get(o).then((t=>{e(t)})).catch((e=>{t(e)}))}))).then((e=>{if(e){const r=e.split("."),s=va(r[0]),a=va(r[1]);a&&s?t({cryptoIV:a,cryptoKey:s}):i("get cryptoIV or cryptoKey error")}else i(`cryptoKeyUrl: getM7SCryptoStreamKey ${a} res is null`)})).catch((e=>{i(e)}))}))}playback(e,t={}){return new Promise(((i,r)=>{if(this.debug.log("EasyPro",`playback() ${e}, options: ${JSON.stringify(t)}`),ka(this._opt.isLive))return r("this._opt.isLive is false, can not playback");const s=Ea(),a=Object.assign({},s.playbackConfig,this._opt.playbackConfig,t);a.isUseFpsRender||a.isCacheBeforeDecodeForFpsRender&&(a.isCacheBeforeDecodeForFpsRender=!1,this.debug.warn("EasyPro","playbackConfig.isUseFpsRender is false, isCacheBeforeDecodeForFpsRender can not be ture, isCacheBeforeDecodeForFpsRender is set to false")),0===a.rateConfig.length&&a.showRateBtn&&(a.showRateBtn=!1,this.debug.warn("EasyPro","playbackConfig.rateConfig.length is 0, showRateBtn can not be ture, showRateBtn is set to false")),a.controlType,Z.simple,this._resetPlayer({videoBuffer:0,playbackConfig:a,playType:b,openWebglAlignment:!0,useMSE:a.useMSE,useWCS:a.useWCS,useSIMD:!0}).then((()=>{this.play(e,t).then((()=>{i()})).catch((e=>{r(e)}))})).catch((e=>{r(e)}))}))}playbackPause(e=!1){return this.debug.log("EasyPro",`playbackPause() ${e}`),this._opt.playType===A?Promise.reject("playType is player, can not call playbackPause method"):new Promise(((t,i)=>{if(!this.player)return i("player is null");Ta(e)?this._pause().then((()=>{t()})).catch((e=>{i(e)})):(this.player.playbackPause=!0,t())}))}playbackResume(){return this.debug.log("EasyPro","playbackResume()"),this._opt.playType===A?Promise.reject("playType is player, can not call playbackResume method"):new Promise(((e,t)=>{if(!this.player)return t("player is null");this.player.playbackPause=!1,e()}))}forward(e){return this.debug.log("EasyPro",`forward() ${e}`),ka(this._opt.isLive)||this._opt.playType===A?Promise.reject("forward() method only just for playback type"):Ns(Number(e))?new Promise(((t,i)=>{this.player?(e=bs(Number(e),.1,32),this.player.decoderWorker&&this.player.decoderWorker.updateWorkConfig({key:"playbackRate",value:e}),this.player.playback.setRate(e),this.player.video&&this.player.video.setRate(e),this.player.audio&&this.player.audio.setRate(e),(this.player.isPlaybackUseWCS()||this.player.isPlaybackUseMSE())&&(this.player.demux.dropBuffer$2(),this.player.isPlaybackCacheBeforeDecodeForFpsRender()&&this.player.demux.initPlaybackCacheLoop()),t()):i("player is not playing")})):Promise.reject(`forward() params "rate": ${e} must be number type`)}playbackForward(e){return this.forward(e)}normal(){return this.forward(1)}playbackNormal(){return this.normal()}updatePlaybackForwardMaxRateDecodeIFrame(e){this.debug.log("EasyPro",`updatePlaybackForwardMaxRateDecodeIFrame() ${e}`),e=Number(e),e=bs(e=parseInt(e,10),1,8),this._opt.playbackForwardMaxRateDecodeIFrame=e,this.player?this.player.updateOption({playbackForwardMaxRateDecodeIFrame:e},!0):this.debug.warn("EasyPro","updatePlaybackForwardMaxRateDecodeIFrame() player is null")}setPlaybackStartTime(e){this.debug.log("EasyPro",`setPlaybackStartTime() ${e}`);const t=ia(e);if(this.player)if(this.player.isPlayback()){if(t<10&&0!==e&&this.player.playback.isControlTypeNormal())this.debug.warn("EasyPro",`setPlaybackStartTime() control type is normal and timestamp: ${e} is not valid`);else if(this.player.playback.isControlTypeSimple()&&e>this.player.playback.totalDuration)this.debug.warn("EasyPro",`setPlaybackStartTime() control type is simple and timestamp: ${e} is more than ${this.player.playback.totalDuration}`);else if(this.player.playing){this.player.playback.isControlTypeNormal()&&10===t&&(e*=1e3),document.getElementsByTagName("video")[0].currentTime=e}}else this.debug.warn("EasyPro","setPlaybackStartTime() playType is not playback");else this.debug.warn("EasyPro","setPlaybackStartTime() player is null")}setPlaybackShowPrecision(e){this.debug.log("EasyPro",`setPlaybackShowPrecision() ${e}`),this.player?this.player.isPlayback()?this.player.playback.isControlTypeNormal()?this.player.playback.setShowPrecision(e):this.debug.warn("EasyPro","control type is not normal , not support!"):this.debug.warn("EasyPro","playType is not playback"):this.debug.warn("EasyPro","player is null")}playbackCurrentTimeScroll(){this.debug.log("EasyPro","playbackCurrentTimeScroll()"),this.player?this.player.isPlayback()?this.player.playback.isControlTypeNormal()?this.player.playback.currentTimeScroll():this.debug.warn("EasyPro","control type is not normal , not support!"):this.debug.warn("EasyPro","playType is not playback"):this.debug.warn("EasyPro","player is null")}playbackClearCacheBuffer(){this.debug.log("EasyPro","playbackClearCacheBuffer()"),this.player?this.player.isPlayback()?(this.player.video&&this.player.video.clear(),this.player.audio&&this.player.audio.clear(),this.clearBufferDelay()):this.debug.warn("EasyPro","playType is not playback"):this.debug.warn("EasyPro","player is null")}getPlaybackCurrentRate(){if(this.player){if(this.player.isPlayback())return this.player.getPlaybackRate();this.debug.warn("EasyPro","playType is not playback")}else this.debug.warn("EasyPro","player is null")}updatePlaybackLocalOneFrameTimestamp(e){this.debug.log("EasyPro",`updatePlaybackLocalOneFrameTimestamp() ${e}`),this.player?this.player.isPlayback()?this.player.playback.updateLocalOneFrameTimestamp(e):this.debug.warn("EasyPro","playType is not playback"):this.debug.warn("EasyPro","player is null")}setStreamQuality(e){if(this.debug.log("EasyPro",`setStreamQuality() ${e}`),!this.player)return void this.debug.warn("EasyPro","player is null");if(!this.player._opt.operateBtns.quality)return void this.debug.warn("EasyPro","player._opt.operateBtns.quality is false");(this.player._opt.qualityConfig||[]).includes(e)?this.player.streamQuality=e:this.debug.warn("EasyPro",`quality: ${e} is not in qualityList`)}_play(t="",h={}){return new Promise(((c,u)=>{if(!this.player)return u("player is null");let p=!1;this._opt.url&&this._opt.url!==t&&(p=!0),this._opt.url=t,this._opt.playOptions=h;const f=t.split("?")[0],y=f.startsWith("http://")||f.startsWith("https://"),m=f.startsWith("webrtc://"),g=f.startsWith("artc://"),A=f.startsWith("wt://"),v=f.startsWith("ws://")||f.startsWith("wss://"),b=y||v,_=v&&f.includes("/api/devices/"),w=y&&f.endsWith(".m3u8"),E=b&&f.endsWith(".flv"),S=b&&(f.endsWith(".fmp4")||f.endsWith(".mp4")),U=b&&f.endsWith(".mpeg4"),F=b&&(f.endsWith(".h264")||f.endsWith(".h265")),O=b&&f.endsWith(".ts");let N=this._opt.isWebrtcForZLM||!1,z=this._opt.isWebrtcForSRS||!1,W=this._opt.isWebrtcForOthers||!1;m&&(-1!==t.indexOf("/index/api/webrtc")?(N=!0,z=!1,W=!1):-1!==t.indexOf("/rtc/v1/play/")&&(z=!0,N=!1,W=!1));let V=null,H=null;if(E&&ka(this._opt.isFlv)&&this._resetDemuxType("isFlv"),S&&ka(this._opt.isFmp4)&&this._resetDemuxType("isFmp4"),U&&ka(this._opt.isMpeg4)&&this._resetDemuxType("isMpeg4"),F&&ka(this._opt.isNakedFlow)&&this._resetDemuxType("isNakedFlow"),O&&ka(this._opt.isTs)&&this._resetDemuxType("isTs"),_&&this._resetDemuxType("isWsRtc"),V=y?w?s:r:A?n:_?l:m?a:g?o:i,this._opt.isNakedFlow?H=x:this._opt.isFmp4?H=L:this._opt.isMpeg4?H=I:this._opt.isFlv?H=T:this._opt.isTs?H=B:_?H=M:w?H=C:m?H=D:g?H=P:A?H=R:v&&(H=k),!V||!H)return this._opt.playFailedAndPausedShowMessage&&this.showErrorMessageTips("url is not support"),u(`play protocol is ${d[V]}, demuxType is ${H}`);this.debug.log("EasyPro",`play protocol is ${d[V]}, demuxType is ${H}`);const $=()=>{this.player.once(lt.webglAlignmentError,(e=>{if(this.isDestroyed())this.debug.log("EasyPro","webglAlignmentError but player is destroyed");else if(this.emit(st.crashLog,this.getCrashLog(lt.webglAlignmentError,e)),this.player&&this.player._opt.webglAlignmentErrorReplay){this.debug.log("EasyPro","webglAlignmentError");const t=this._opt.url,i=this.isMute(),r={...this._opt.playOptions,isNotMute:!i};this._resetPlayer({openWebglAlignment:!0,isNotMute:!i}).then((()=>{this.play(t,r).then((()=>{this.debug.log("EasyPro","webglAlignmentError and play success")})).catch((t=>{this.emit(st.playFailedAndPaused,lt.webglAlignmentError,{},e),this.debug.error("EasyPro","webglAlignmentError and play error",t)}))})).catch((e=>{this.debug.error("EasyPro","webglAlignmentError and _resetPlayer error",e)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this._pause(t).then((()=>{this.emit(st.playFailedAndPaused,lt.webglAlignmentError,{},e),this.debug.log("EasyPro","webglAlignmentError and webglAlignmentErrorReplay is false")})).catch((t=>{this.emit(st.playFailedAndPaused,lt.webglAlignmentError,{},e),this.debug.error("EasyPro","webglAlignmentError and pause error",t)}))}})),this.player.once(lt.webglContextLostError,(e=>{if(this.isDestroyed())return void this.debug.log("EasyPro","webglContextLostError but player is destroyed");this.emit(st.crashLog,this.getCrashLog(lt.webglContextLostError,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.webglContextLostErrorReplay){this.debug.log("EasyPro","webglContextLostError");const i=this._opt.url,r=this.isMute(),s={...this._opt.playOptions,isNotMute:!r};let a={};this.player._opt.replayUseLastFrameShow&&(a=Object.assign({},a,t,{loadingIcon:this.player._opt.replayShowLoadingIcon,isNotMute:!r})),this._resetPlayer(a).then((()=>{this.play(i,s).then((()=>{this.debug.log("EasyPro","webglContextLostError and play success")})).catch((i=>{this.emit(st.playFailedAndPaused,lt.webglContextLostError,t,e),this.debug.error("EasyPro","webglContextLostError and play error",i)}))})).catch((i=>{this.emit(st.playFailedAndPaused,lt.webglContextLostError,t,e),this.debug.error("EasyPro","webglContextLostError and _resetPlayer error",i)}))}else{const i=!1===this._opt.playFailedUseLastFrameShow;this._pause(i).then((()=>{this.emit(st.playFailedAndPaused,lt.webglContextLostError,t,e),this.debug.log("EasyPro","webglContextLostError and webglContextLostErrorReplay is false")})).catch((i=>{this.emit(st.playFailedAndPaused,lt.webglContextLostError,t,e),this.debug.error("EasyPro","webglAlignmentError and pause error",i)}))}})),this.player.once(lt.mediaSourceH265NotSupport,(e=>{if(this.isDestroyed())this.debug.log("EasyPro","mediaSourceH265NotSupport but player is destroyed");else if(this.emit(st.crashLog,this.getCrashLog(lt.mediaSourceH265NotSupport,e)),this.player&&this.player._opt.hardDecodingNotSupportAutoWasm){this.debug.log("EasyPro","mediaSourceH265NotSupport auto wasm [mse-> wasm] reset player and play");const t=this._opt.url,i=this.isMute(),r={...this._opt.playOptions,isNotMute:!i};this._resetPlayer({useMSE:!1,useWCS:!1,isNotMute:!i}).then((()=>{this.play(t,r).then((()=>{this.debug.log("EasyPro","mediaSourceH265NotSupport auto wasm [mse-> wasm] reset player and play success")})).catch((t=>{this.emit(st.playFailedAndPaused,lt.mediaSourceH265NotSupport,e),this.debug.error("EasyPro","mediaSourceH265NotSupport auto wasm [mse-> wasm] reset player and play error",t)}))})).catch((t=>{this.emit(st.playFailedAndPaused,lt.mediaSourceH265NotSupport,{},e),this.debug.error("EasyPro","mediaSourceH265NotSupport auto wasm [mse-> wasm] _resetPlayer error",t)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this._pause(t).then((()=>{this.emit(st.playFailedAndPaused,lt.mediaSourceH265NotSupport,{},e),this.debug.log("EasyPro","mediaSourceH265NotSupport and autoWasm is false")})).catch((t=>{this.emit(st.playFailedAndPaused,lt.mediaSourceH265NotSupport,{},e),this.debug.error("EasyPro","mediaSourceH265NotSupport and pause error",t)}))}})),this.player.once(lt.mediaSourceFull,(e=>{if(this.isDestroyed())return void this.debug.log("EasyPro","mediaSourceFull but player is destroyed");this.emit(st.crashLog,this.getCrashLog(lt.mediaSourceFull,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.mseDecodeErrorReplay){const i=this._opt.url,r=this.isMute(),s={...this._opt.playOptions,isNotMute:!r};let a={};this.player._opt.decoderErrorAutoWasm&&(a={useMSE:!1,useWCS:!1}),this.debug.log("EasyPro",`mediaSourceFull and auto wasm [mse-> ${this.player._opt.decoderErrorAutoWasm?"wasm":"mse"}] reset player and play`),this.player._opt.replayUseLastFrameShow&&(a=Object.assign({},a,t,{loadingIcon:this.player._opt.replayShowLoadingIcon,isNotMute:!r})),this._resetPlayer(a).then((()=>{this.play(i,s).then((()=>{this.debug.log("EasyPro","mediaSourceFull and reset player and play success")})).catch((i=>{this.emit(st.playFailedAndPaused,lt.mediaSourceFull,t,e),this.debug.error("EasyPro","mediaSourceFull and reset player and play error",i)}))})).catch((i=>{this.emit(st.playFailedAndPaused,lt.mediaSourceFull,t,e),this.debug.error("EasyPro","mediaSourceFull and _resetPlayer error",i)}))}else{const i=!1===this._opt.playFailedUseLastFrameShow;this._pause(i).then((()=>{this.emit(st.playFailedAndPaused,lt.mediaSourceFull,t,e),this.debug.log("EasyPro","mediaSourceFull and autoWasm is false")})).catch((i=>{this.emit(st.playFailedAndPaused,lt.mediaSourceFull,t,e),this.debug.error("EasyPro","mediaSourceFull and pause error",i)}))}})),this.player.once(lt.mediaSourceAppendBufferError,(e=>{if(this.isDestroyed())return void this.debug.log("EasyPro","mediaSourceAppendBufferError but player is destroyed");this.emit(st.crashLog,this.getCrashLog(lt.mediaSourceAppendBufferError,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.mseDecodeErrorReplay){const i=this._opt.url,r=this.isMute(),s={...this._opt.playOptions,isNotMute:!r};let a={};this.player._opt.decoderErrorAutoWasm&&(a={useMSE:!1,useWCS:!1}),this.debug.log("EasyPro",`mediaSourceAppendBufferError and auto wasm [mse-> ${this.player._opt.decoderErrorAutoWasm?"wasm":"mse"}] reset player and play`),this.player._opt.replayUseLastFrameShow&&(a=Object.assign({},a,t,{loadingIcon:this.player._opt.replayShowLoadingIcon,isNotMute:!r})),this._resetPlayer(a).then((()=>{this.play(i,s).then((()=>{this.debug.log("EasyPro","mediaSourceAppendBufferError and reset player and play success")})).catch((i=>{this.emit(st.playFailedAndPaused,lt.mediaSourceAppendBufferError,t,e),this.debug.error("EasyPro","mediaSourceAppendBufferError and reset player and play error",i)}))})).catch((i=>{this.emit(st.playFailedAndPaused,lt.mediaSourceAppendBufferError,t,e),this.debug.error("EasyPro","mediaSourceAppendBufferError and _resetPlayer error",i)}))}else{const i=!1===this._opt.playFailedUseLastFrameShow;this._pause(i).then((()=>{this.emit(st.playFailedAndPaused,lt.mediaSourceAppendBufferError,t,e),this.debug.log("EasyPro","mediaSourceAppendBufferError and autoWasm is false")})).catch((i=>{this.emit(st.playFailedAndPaused,lt.mediaSourceAppendBufferError,t,e),this.debug.error("EasyPro","mediaSourceAppendBufferError and pause error",i)}))}})),this.player.once(lt.mseSourceBufferError,(e=>{if(this.isDestroyed())return void this.debug.log("EasyPro","mseSourceBufferError but player is destroyed");this.emit(st.crashLog,this.getCrashLog(lt.mseSourceBufferError,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.mseDecodeErrorReplay){const i=this._opt.url,r=this.isMute(),s={...this._opt.playOptions,isNotMute:!r};let a={};this.player._opt.decoderErrorAutoWasm&&(a={useMSE:!1,useWCS:!1}),this.player.isMSEVideoDecoderInitializationFailedNotSupportHevc&&(this.debug.log("EasyPro","mseSourceBufferError and isMSEVideoDecoderInitializationFailedNotSupportHevc is true so auto wasm"),a={useMSE:!1,useWCS:!1}),this.debug.log("EasyPro",`mseSourceBufferError auto wasm [mse-> ${this.player._opt.decoderErrorAutoWasm?"wasm":"mse"}] reset player and play`),this.player._opt.replayUseLastFrameShow&&(a=Object.assign({},a,t,{loadingIcon:this.player._opt.replayShowLoadingIcon,isNotMute:!r})),this._resetPlayer(a).then((()=>{this.play(i,s).then((()=>{this.debug.log("EasyPro","mseSourceBufferError reset player and play success")})).catch((i=>{this.emit(st.playFailedAndPaused,lt.mseSourceBufferError,t,e),this.debug.error("EasyPro","mseSourceBufferError reset player and play error",i)}))})).catch((i=>{this.emit(st.playFailedAndPaused,lt.mseSourceBufferError,t,e),this.debug.error("EasyPro","mseSourceBufferError _resetPlayer and play error",i)}))}else{const i=!1===this._opt.playFailedUseLastFrameShow;this._pause(i).then((()=>{this.emit(st.playFailedAndPaused,lt.mseSourceBufferError,t,e),this.debug.log("EasyPro","mseSourceBufferError and autoWasm is false")})).catch((i=>{this.emit(st.playFailedAndPaused,lt.mseSourceBufferError,t,e),this.debug.error("EasyPro","mseSourceBufferError and pause error:",i)}))}})),this.player.once(lt.mediaSourceBufferedIsZeroError,(e=>{if(this.isDestroyed())return void this.debug.log("EasyPro","mediaSourceBufferedIsZeroError but player is destroyed");this.emit(st.crashLog,this.getCrashLog(lt.mediaSourceBufferedIsZeroError,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.mseDecodeErrorReplay){const i=this._opt.url,r=this.isMute(),s={...this._opt.playOptions,isNotMute:!r};let a={};this.player._opt.decoderErrorAutoWasm&&(a={useMSE:!1,useWCS:!1}),this.debug.log("EasyPro",`mediaSourceBufferedIsZeroError auto wasm [mse-> ${this.player._opt.decoderErrorAutoWasm?"wasm":"mse"}] reset player and play`),this.player._opt.replayUseLastFrameShow&&(a=Object.assign({},a,t,{loadingIcon:this.player._opt.replayShowLoadingIcon,isNotMute:!r})),this._resetPlayer(a).then((()=>{this.play(i,s).then((()=>{this.debug.log("EasyPro","mediaSourceBufferedIsZeroError reset player and play success")})).catch((i=>{this.emit(st.playFailedAndPaused,lt.mediaSourceBufferedIsZeroError,t,e),this.debug.error("EasyPro","mediaSourceBufferedIsZeroError reset player and play error",i)}))})).catch((i=>{this.emit(st.playFailedAndPaused,lt.mediaSourceBufferedIsZeroError,t,e),this.debug.error("EasyPro","mediaSourceBufferedIsZeroError _resetPlayer and play error",i)}))}else{const i=!1===this._opt.playFailedUseLastFrameShow;this._pause(i).then((()=>{this.emit(st.playFailedAndPaused,lt.mediaSourceBufferedIsZeroError,t,e),this.debug.log("EasyPro","mediaSourceBufferedIsZeroError and autoWasm is false")})).catch((i=>{this.emit(st.playFailedAndPaused,lt.mediaSourceBufferedIsZeroError,t,e),this.debug.error("EasyPro","mediaSourceBufferedIsZeroError and pause error:",i)}))}})),this.player.once(lt.mseAddSourceBufferError,(e=>{if(this.isDestroyed())return void this.debug.log("EasyPro","mseAddSourceBufferError but player is destroyed");this.emit(st.crashLog,this.getCrashLog(lt.mseAddSourceBufferError,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.hardDecodingNotSupportAutoWasm){this.debug.log("EasyPro","mseAddSourceBufferError auto wasm [mse-> wasm] reset player and play");const i=this._opt.url,r=this.isMute(),s={...this._opt.playOptions,isNotMute:!r};let a={useMSE:!1,useWCS:!1};this.player._opt.replayUseLastFrameShow&&(a=Object.assign({},a,t,{loadingIcon:this.player._opt.replayShowLoadingIcon,isNotMute:!r})),this._resetPlayer(a).then((()=>{this.play(i,s).then((()=>{this.debug.log("EasyPro","mseAddSourceBufferError auto wasm [mse-> wasm] reset player and play success")})).catch((i=>{this.emit(st.playFailedAndPaused,lt.mseAddSourceBufferError,t,e),this.debug.error("EasyPro","mseAddSourceBufferError auto wasm [mse-> wasm] reset player and play error",i)}))})).catch((i=>{this.emit(st.playFailedAndPaused,lt.mseAddSourceBufferError,t,e),this.debug.error("EasyPro","mseAddSourceBufferError auto wasm [mse-> wasm] _resetPlayer and play error",i)}))}else{const i=!1===this._opt.playFailedUseLastFrameShow;this._pause(i).then((()=>{this.emit(st.playFailedAndPaused,lt.mseAddSourceBufferError,t,e),this.debug.log("EasyPro","mseAddSourceBufferError and autoWasm is false")})).catch((i=>{this.emit(st.playFailedAndPaused,lt.mseAddSourceBufferError,t,e),this.debug.error("EasyPro","mseAddSourceBufferError and pause error",i)}))}})),this.player.once(lt.mediaSourceDecoderConfigurationError,(e=>{if(this.isDestroyed())this.debug.log("EasyPro","mediaSourceDecoderConfigurationError but player is destroyed");else if(this.emit(st.crashLog,this.getCrashLog(lt.mediaSourceDecoderConfigurationError,e)),this.player&&this.player._opt.hardDecodingNotSupportAutoWasm){this.debug.log("EasyPro","mediaSourceDecoderConfigurationError auto wasm [mse-> wasm] reset player and play");const t=this._opt.url,i=this.isMute(),r={...this._opt.playOptions,isNotMute:!i};let s={useMSE:!1,useWCS:!1,isNotMute:!i};this._resetPlayer(s).then((()=>{this.play(t,r).then((()=>{this.debug.log("EasyPro","mediaSourceDecoderConfigurationError auto wasm [mse-> wasm] reset player and play success")})).catch((t=>{this.emit(st.playFailedAndPaused,lt.mediaSourceDecoderConfigurationError,e),this.debug.error("EasyPro","mediaSourceDecoderConfigurationError auto wasm [mse-> wasm] reset player and play error",t)}))})).catch((t=>{this.emit(st.playFailedAndPaused,lt.mediaSourceDecoderConfigurationError,e),this.debug.error("EasyPro","mediaSourceDecoderConfigurationError auto wasm [mse-> wasm] _resetPlayer and play error",t)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this._pause(t).then((()=>{this.emit(st.playFailedAndPaused,lt.mediaSourceDecoderConfigurationError,e),this.debug.log("EasyPro","mediaSourceDecoderConfigurationError and autoWasm is false")})).catch((t=>{this.emit(st.playFailedAndPaused,lt.mediaSourceDecoderConfigurationError,e),this.debug.error("EasyPro","mediaSourceDecoderConfigurationError and pause error",t)}))}})),this.player.once(lt.mediaSourceTsIsMaxDiff,(e=>{if(this.isDestroyed())return void this.debug.log("EasyPro","mediaSourceTsIsMaxDiff but player is destroyed");this.emit(st.crashLog,this.getCrashLog(lt.mediaSourceTsIsMaxDiff,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.mediaSourceTsIsMaxDiffReplay){this.debug.log("EasyPro","mediaSourceTsIsMaxDiff reset player and play");const i=this._opt.url,r=this.isMute(),s={...this._opt.playOptions,isNotMute:!r};let a={isNotMute:!r};a=Object.assign({},a,t),this._resetPlayer(a).then((()=>{this.play(i,s).then((()=>{this.debug.log("EasyPro","mediaSourceTsIsMaxDiff replay success")})).catch((i=>{this.emit(st.playFailedAndPaused,lt.mediaSourceTsIsMaxDiff,t,e),this.debug.error("EasyPro","mediaSourceTsIsMaxDiff replay error",i)}))})).catch((i=>{this.emit(st.playFailedAndPaused,lt.mediaSourceTsIsMaxDiff,t,e),this.debug.error("EasyPro","mediaSourceTsIsMaxDiff _resetPlayer error",i)}))}else{const i=!1===this._opt.playFailedUseLastFrameShow;this._pause(i).then((()=>{this.emit(st.playFailedAndPaused,lt.mediaSourceTsIsMaxDiff,t,e),this.debug.log("EasyPro","mediaSourceTsIsMaxDiff and replay is false")})).catch((i=>{this.emit(st.playFailedAndPaused,lt.mediaSourceTsIsMaxDiff,t,e),this.debug.error("EasyPro","mediaSourceTsIsMaxDiff and pause error",i)}))}})),this.player.once(lt.mseWidthOrHeightChange,(t=>{if(this.isDestroyed())return void this.debug.log("EasyPro","mseWidthOrHeightChange but player is destroyed");this.emit(st.crashLog,this.getCrashLog(lt.mseWidthOrHeightChange,t));const i=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.widthOrHeightChangeReplay){this.debug.log("EasyPro","mseWidthOrHeightChange and reset player and play");const e=this._opt.url,r=this.isMute(),s={...this._opt.playOptions,isNotMute:!r};let a={isNotMute:!r};a=Object.assign({},a,i),this._resetPlayer(a).then((()=>{this.player._opt.widthOrHeightChangeReplayDelayTime>0?setTimeout((()=>{this.isDestroyed()?this.debug.log("EasyPro","mseWidthOrHeightChange and widthOrHeightChangeReplayDelayTime but player is destroyed"):this.play(e,s).then((()=>{this.debug.log("EasyPro","mseWidthOrHeightChange and reset player and play success")})).catch((e=>{this.emit(st.playFailedAndPaused,lt.mseWidthOrHeightChange,i,t),this.debug.error("EasyPro","mseWidthOrHeightChange and reset player and play error",e)}))}),1e3*this.player._opt.widthOrHeightChangeReplayDelayTime):this.play(e,s).then((()=>{this.debug.log("EasyPro","mseWidthOrHeightChange and reset player and play success")})).catch((e=>{this.emit(st.playFailedAndPaused,lt.mseWidthOrHeightChange,i,t),this.debug.error("EasyPro","mseWidthOrHeightChange and reset player and play error",e)}))})).catch((e=>{this.emit(st.playFailedAndPaused,lt.mseWidthOrHeightChange,i,t),this.debug.error("EasyPro","mseWidthOrHeightChange and _resetPlayer error",e)}))}else{const r=!1===this._opt.playFailedUseLastFrameShow;this._pause(r).then((()=>{this.emit(st.playFailedAndPaused,lt.mseWidthOrHeightChange,i,t),this.debug.error("EasyPro","mseWidthOrHeightChange and _resetPlayer error",e)})).catch((e=>{this.emit(st.playFailedAndPaused,lt.mseWidthOrHeightChange,i,t),this.debug.error("EasyPro","mseWidthOrHeightChange error and pause error",e)}))}})),this.player.once(lt.mediaSourceAudioG711NotSupport,(t=>{if(this.isDestroyed())return void this.debug.log("EasyPro","mediaSourceAudioG711NotSupport but player is destroyed");const i=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.mediaSourceAudioG711NotSupportReplay){this.debug.log("EasyPro","mediaSourceAudioG711NotSupport and reset player and play");const e=this._opt.url,r=this.isMute(),s={...this._opt.playOptions,isNotMute:!r};let a={mseDecodeAudio:!1,isNotMute:!r};a=Object.assign({},a,i),this._resetPlayer(a).then((()=>{this.play(e,s).then((()=>{this.debug.log("EasyPro","mediaSourceAudioG711NotSupport and reset player and play success")})).catch((e=>{this.emit(st.playFailedAndPaused,lt.mediaSourceAudioG711NotSupport,i,t),this.debug.error("EasyPro","mediaSourceAudioG711NotSupport and reset player and play error",e)}))})).catch((e=>{this.emit(st.playFailedAndPaused,lt.mediaSourceAudioG711NotSupport,i,t),this.debug.error("EasyPro","mediaSourceAudioG711NotSupport and _resetPlayer error",e)}))}else{const r=!1===this._opt.playFailedUseLastFrameShow;this._pause(r).then((()=>{this.emit(st.playFailedAndPaused,lt.mediaSourceAudioG711NotSupport,i,t),this.debug.error("EasyPro","mediaSourceAudioG711NotSupport and _resetPlayer error",e)})).catch((e=>{this.emit(st.playFailedAndPaused,lt.mediaSourceAudioG711NotSupport,i,t),this.debug.error("EasyPro","mediaSourceAudioG711NotSupport error and pause error",e)}))}})),this.player.once(lt.mediaSourceAudioInitTimeout,(t=>{if(this.isDestroyed())return void this.debug.log("EasyPro","mediaSourceAudioInitTimeout but player is destroyed");const i=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.mediaSourceAudioInitTimeoutReplay){this.debug.log("EasyPro","mediaSourceAudioInitTimeout and reset player and play");const e=this._opt.url,r=this.isMute(),s={...this._opt.playOptions,isNotMute:!r};let a={mseDecodeAudio:!1,isNotMute:!r};a=Object.assign({},a,i),this._resetPlayer(a).then((()=>{this.play(e,s).then((()=>{this.debug.log("EasyPro","mediaSourceAudioInitTimeout and reset player and play success")})).catch((e=>{this.emit(st.playFailedAndPaused,lt.mediaSourceAudioInitTimeout,i,t),this.debug.error("EasyPro","mediaSourceAudioInitTimeout and reset player and play error",e)}))})).catch((e=>{this.emit(st.playFailedAndPaused,lt.mediaSourceAudioInitTimeout,i,t),this.debug.error("EasyPro","mediaSourceAudioInitTimeout and _resetPlayer error",e)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this._pause(t).then((()=>{this.emit(st.playFailedAndPaused,lt.mediaSourceAudioInitTimeout,i),this.debug.error("EasyPro","mediaSourceAudioInitTimeout and _resetPlayer error",e)})).catch((e=>{this.emit(st.playFailedAndPaused,lt.mediaSourceAudioInitTimeout,i),this.debug.error("EasyPro","mediaSourceAudioInitTimeout error and pause error",e)}))}})),this.player.once(lt.mediaSourceUseCanvasRenderPlayFailed,(e=>{if(this.isDestroyed())this.debug.log("EasyPro","mediaSourceUseCanvasRenderPlayFailed but player is destroyed");else if(this.emit(st.crashLog,this.getCrashLog(lt.mediaSourceUseCanvasRenderPlayFailed,e)),this.player&&this.player._opt.mediaSourceUseCanvasRenderPlayFailedReplay&&this.player._opt.mediaSourceUseCanvasRenderPlayFailedReplayType){this.debug.log("EasyPro",`mediaSourceUseCanvasRenderPlayFailed relayType is ${this.player._opt.mediaSourceUseCanvasRenderPlayFailedReplayType} and reset player and play`);const t=this._opt.url,i=this.isMute(),r={...this._opt.playOptions,isNotMute:!i};let s={};const a=this.player._opt.mediaSourceUseCanvasRenderPlayFailedReplayType;a===K?s={useMSE:!1,useWCS:!1}:a===q&&(s={useVideoRender:!0,useCanvasRender:!1}),this._resetPlayer({...s,isNotMute:!i}).then((()=>{this.play(t,r).then((()=>{this.debug.log("EasyPro","mediaSourceUseCanvasRenderPlayFailed and reset player and play success")})).catch((t=>{this.emit(st.playFailedAndPaused,lt.mediaSourceUseCanvasRenderPlayFailed,e),this.debug.error("EasyPro","mediaSourceUseCanvasRenderPlayFailed and reset player and play error",t)}))})).catch((e=>{this.debug.error("EasyPro","mediaSourceUseCanvasRenderPlayFailed auto and _resetPlayer and play error",e)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this._pause(t).then((()=>{this.debug.log("EasyPro","mediaSourceUseCanvasRenderPlayFailed and pause player success")})).catch((t=>{this.emit(st.playFailedAndPaused,lt.mediaSourceUseCanvasRenderPlayFailed,e),this.debug.error("EasyPro","mediaSourceUseCanvasRenderPlayFailed and pause",t)}))}})),this.player.once(lt.webcodecsH265NotSupport,(e=>{if(this.isDestroyed())this.debug.log("EasyPro","webcodecsH265NotSupport but player is destroyed");else if(this.emit(st.crashLog,this.getCrashLog(lt.webcodecsH265NotSupport,e)),this.player&&this.player._opt.hardDecodingNotSupportAutoWasm){this.debug.log("EasyPro","webcodecsH265NotSupport auto wasm [wcs-> wasm] reset player and play");const t=this._opt.url,i=this.isMute(),r={...this._opt.playOptions,isNotMute:!i};this._resetPlayer({useMSE:!1,useWCS:!1,isNotMute:!i}).then((()=>{this.play(t,r).then((()=>{this.debug.log("EasyPro","webcodecsH265NotSupport auto wasm [wcs-> wasm] reset player and play success")})).catch((t=>{this.emit(st.playFailedAndPaused,lt.webcodecsH265NotSupport,e),this.debug.error("EasyPro","webcodecsH265NotSupport auto wasm [wcs-> wasm] reset player and play error",t)}))})).catch((e=>{this.debug.error("EasyPro","webcodecsH265NotSupport auto wasm [wcs-> wasm] _resetPlayer and play error",e)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this._pause(t).then((()=>{this.emit(st.playFailedAndPaused,lt.webcodecsH265NotSupport,e),this.debug.log("EasyPro","webcodecsH265NotSupport and autoWasm is false")})).catch((t=>{this.emit(st.playFailedAndPaused,lt.webcodecsH265NotSupport,e),this.debug.error("EasyPro","webcodecsH265NotSupport and pause error",t)}))}})),this.player.once(lt.webcodecsUnsupportedConfigurationError,(e=>{if(this.isDestroyed())this.debug.log("EasyPro","webcodecsUnsupportedConfigurationError but player is destroyed");else if(this.emit(st.crashLog,this.getCrashLog(lt.webcodecsUnsupportedConfigurationError,e)),this.player&&this.player._opt.hardDecodingNotSupportAutoWasm){this.debug.log("EasyPro","webcodecsUnsupportedConfigurationError auto wasm [wcs-> wasm] reset player and play");const t=this._opt.url,i=this.isMute(),r={...this._opt.playOptions,isNotMute:!i};this._resetPlayer({useMSE:!1,useWCS:!1,isNotMute:!i}).then((()=>{this.play(t,r).then((()=>{this.debug.log("EasyPro","webcodecsUnsupportedConfigurationError auto wasm [wcs-> wasm] reset player and play success")})).catch((t=>{this.emit(st.playFailedAndPaused,lt.webcodecsUnsupportedConfigurationError,e),this.debug.error("EasyPro","webcodecsUnsupportedConfigurationError auto wasm [wcs-> wasm] reset player and play error",t)}))})).catch((t=>{this.emit(st.playFailedAndPaused,lt.webcodecsUnsupportedConfigurationError,e),this.debug.error("EasyPro","webcodecsUnsupportedConfigurationError auto wasm [wcs-> wasm] _resetPlayer and play error",t)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this._pause(t).then((()=>{this.emit(st.playFailedAndPaused,lt.webcodecsUnsupportedConfigurationError,e),this.debug.log("EasyPro","webcodecsUnsupportedConfigurationError and autoWasm is false")})).catch((t=>{this.emit(st.playFailedAndPaused,lt.webcodecsUnsupportedConfigurationError,e),this.debug.error("EasyPro","webcodecsUnsupportedConfigurationError and pause error",t)}))}})),this.player.once(lt.webcodecsDecodeConfigureError,(e=>{if(this.isDestroyed())this.debug.log("EasyPro","webcodecsDecodeConfigureError but player is destroyed");else if(this.emit(st.crashLog,this.getCrashLog(lt.webcodecsDecodeConfigureError,e)),this.player&&this.player._opt.hardDecodingNotSupportAutoWasm){this.debug.log("EasyPro","webcodecsDecodeConfigureError auto wasm [wcs-> wasm] reset player and play");const t=this._opt.url,i=this.isMute(),r={...this._opt.playOptions,isNotMute:!i};this._resetPlayer({useMSE:!1,useWCS:!1,isNotMute:!i}).then((()=>{this.play(t,r).then((()=>{this.debug.log("EasyPro","webcodecsDecodeConfigureError auto wasm [wcs-> wasm] reset player and play success")})).catch((t=>{this.emit(st.playFailedAndPaused,lt.webcodecsDecodeConfigureError,e),this.debug.error("EasyPro","webcodecsDecodeConfigureError auto wasm [wcs-> wasm] reset player and play error",t)}))})).catch((t=>{this.emit(st.playFailedAndPaused,lt.webcodecsDecodeConfigureError,e),this.debug.error("EasyPro","webcodecsDecodeConfigureError auto wasm [wcs-> wasm] _resetPlayer and play error",t)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this._pause(t).then((()=>{this.emit(st.playFailedAndPaused,lt.webcodecsDecodeConfigureError,e),this.debug.log("EasyPro","webcodecsDecodeConfigureError and autoWasm is false")})).catch((t=>{this.emit(st.playFailedAndPaused,lt.webcodecsDecodeConfigureError,e),this.debug.error("EasyPro","webcodecsDecodeConfigureError and pause error",t)}))}})),this.player.once(lt.webcodecsDecodeError,(e=>{if(this.isDestroyed())return void this.debug.log("EasyPro","webcodecsDecodeError but player is destroyed");this.emit(st.crashLog,this.getCrashLog(lt.webcodecsDecodeError,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.wcsDecodeErrorReplay){const i=this._opt.url,r=this.isMute(),s={...this._opt.playOptions,isNotMute:!r};let a={};this.player._opt.decoderErrorAutoWasm&&(a={useMSE:!1,useWCS:!1}),this.debug.log("EasyPro",`webcodecs decode error autoWasm [wcs-> ${this.player._opt.decoderErrorAutoWasm?"wasm":"wcs"}] reset player and play`),this.player._opt.replayUseLastFrameShow&&(a=Object.assign({},a,t,{loadingIcon:this.player._opt.replayShowLoadingIcon,isNotMute:!r})),this._resetPlayer(a).then((()=>{this.play(i,s).then((()=>{this.debug.log("EasyPro","webcodecs decode error reset player and play success")})).catch((i=>{this.emit(st.playFailedAndPaused,lt.webcodecsDecodeError,t,e),this.debug.error("EasyPro","webcodecs decode error reset player and play error",i)}))})).catch((()=>{this.emit(st.playFailedAndPaused,lt.webcodecsDecodeError,t,e),this.debug.error("EasyPro","webcodecs decode error _resetPlayer error")}))}else{const i=!1===this._opt.playFailedUseLastFrameShow;this._pause(i).then((()=>{this.emit(st.playFailedAndPaused,lt.webcodecsDecodeError,t,e),this.debug.log("EasyPro","webcodecs decode error and autoWasm is false")})).catch((i=>{this.emit(st.playFailedAndPaused,lt.webcodecsDecodeError,t,e),this.debug.error("EasyPro","webcodecs decode error and pause error",i)}))}})),this.player.once(lt.wcsWidthOrHeightChange,(t=>{if(this.isDestroyed())return void this.debug.log("EasyPro","wcsWidthOrHeightChange but player is destroyed");this.emit(st.crashLog,this.getCrashLog(lt.wcsWidthOrHeightChange,t));const i=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.widthOrHeightChangeReplay){this.debug.log("EasyPro","wcsWidthOrHeightChange and reset player and play");const e=this._opt.url,r=this.isMute(),s={...this._opt.playOptions,isNotMute:!r};let a={};a=Object.assign({},a,i),this._resetPlayer(a).then((()=>{this._opt.widthOrHeightChangeReplayDelayTime>0?setTimeout((()=>{this.isDestroyed()?this.debug.log("EasyPro","wcsWidthOrHeightChange and widthOrHeightChangeReplayDelayTime but player is destroyed"):this.play(e,s).then((()=>{this.debug.log("EasyPro","wcsWidthOrHeightChange and reset player and play success")})).catch((e=>{this.emit(st.playFailedAndPaused,lt.wcsWidthOrHeightChange,i,t),this.debug.error("EasyPro","wcsWidthOrHeightChange and reset player and play error",e)}))}),1e3*this._opt.widthOrHeightChangeReplayDelayTime):this.play(e,s).then((()=>{this.debug.log("EasyPro","wcsWidthOrHeightChange and reset player and play success")})).catch((e=>{this.emit(st.playFailedAndPaused,lt.wcsWidthOrHeightChange,i,t),this.debug.error("EasyPro","wcsWidthOrHeightChange and reset player and play error",e)}))})).catch((e=>{this.emit(st.playFailedAndPaused,lt.wcsWidthOrHeightChange,i,t),this.debug.error("EasyPro","wcsWidthOrHeightChange and _resetPlayer error",e)}))}else{const r=!1===this._opt.playFailedUseLastFrameShow;this._pause(r).then((()=>{this.emit(st.playFailedAndPaused,lt.wcsWidthOrHeightChange,i,t),this.debug.error("EasyPro","wcsWidthOrHeightChange and _resetPlayer error",e)})).catch((e=>{this.emit(st.playFailedAndPaused,lt.wcsWidthOrHeightChange,i,t),this.debug.error("EasyPro","wcsWidthOrHeightChange error and pause error",e)}))}})),this.player.once(lt.wasmDecodeError,(e=>{if(this.isDestroyed())return void this.debug.log("EasyPro","wasmDecodeError but player is destroyed");this.emit(st.crashLog,this.getCrashLog(lt.wasmDecodeError,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.wasmDecodeErrorReplay){this.debug.log("EasyPro","wasm decode error and reset player and play");const i=this._opt.url,r=this.isMute(),s={...this._opt.playOptions,isNotMute:!r};let a={};this.player._opt.replayUseLastFrameShow&&(a=Object.assign({},a,t,{loadingIcon:this.player._opt.replayShowLoadingIcon,isNotMute:!r})),this._resetPlayer(a).then((()=>{this.play(i,s).then((()=>{this.debug.log("EasyPro","wasm decode error and reset player and play success")})).catch((i=>{this.emit(st.playFailedAndPaused,lt.wasmDecodeError,t,e),this.debug.error("EasyPro","wasm decode error and reset player and play error",i)}))})).catch((()=>{this.emit(st.playFailedAndPaused,lt.wasmDecodeError,t,e),this.debug.error("EasyPro","wasm decode error and _resetPlayer error")}))}else{const i=!1===this._opt.playFailedUseLastFrameShow;this._pause(i).then((()=>{this.emit(st.playFailedAndPaused,lt.wasmDecodeError,t,e),this.debug.log("EasyPro","wasm decode error and wasmDecodeErrorReplay is false")})).catch((i=>{this.emit(st.playFailedAndPaused,lt.wasmDecodeError,t,e),this.debug.error("EasyPro","wasm decode error and pause error",i)}))}})),this.player.once(lt.simdDecodeError,(e=>{if(this.isDestroyed())return void this.debug.log("EasyPro","simdDecodeError but player is destroyed");this.emit(st.crashLog,this.getCrashLog(lt.simdDecodeError,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.simdDecodeErrorReplay){this.debug.log("EasyPro",`simdDecodeError error simdDecodeErrorReplayType is ${this.player._opt.simdDecodeErrorReplayType} and reset player and play`);const i=this._opt.url,r=this.isMute(),s=this.getPlaybackCurrentRate(),a={...this._opt.playOptions,isNotMute:!r};let n={};this.player._opt.simdDecodeErrorReplayType===G&&(n={useSIMD:!1,isNotMute:!r}),n=Object.assign({},n,t),this._resetPlayer(n).then((()=>{this.play(i,a).then((()=>{s&&this.forward(s),this.debug.log("EasyPro","simdDecodeError and reset player and play success")})).catch((i=>{this.emit(st.playFailedAndPaused,lt.simdDecodeError,t,e),this.debug.error("EasyPro","simdDecodeError and reset player and play error",i)}))})).catch((i=>{this.emit(st.playFailedAndPaused,lt.simdDecodeError,t,e),this.debug.error("EasyPro","simdDecodeError and _resetPlayer error",i)}))}else{const i=!1===this._opt.playFailedUseLastFrameShow;this._pause(i).then((()=>{this.emit(st.playFailedAndPaused,lt.simdDecodeError,t,e),this.debug.error("EasyPro","simdDecodeError and simdDecodeErrorReplay is false")})).catch((i=>{this.emit(st.playFailedAndPaused,lt.simdDecodeError,t,e),this.debug.error("EasyPro","simdDecodeError error and pause error",i)}))}})),this.player.once(lt.wasmWidthOrHeightChange,(t=>{if(this.isDestroyed())return void this.debug.log("EasyPro","wasmWidthOrHeightChange but player is destroyed");this.emit(st.crashLog,this.getCrashLog(lt.wasmWidthOrHeightChange,t));const i=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.widthOrHeightChangeReplay){this.debug.log("EasyPro","wasmWidthOrHeightChange and reset player and play");const e=this._opt.url,r=this.isMute(),s={...this._opt.playOptions,isNotMute:!r};let a={isNotMute:!r};a=Object.assign({},a,i),this._resetPlayer(a).then((()=>{this._opt.widthOrHeightChangeReplayDelayTime>0?setTimeout((()=>{this.isDestroyed()?this.debug.log("EasyPro","wasmWidthOrHeightChange and widthOrHeightChangeReplayDelayTime but player is destroyed"):this.play(e,s).then((()=>{this.debug.log("EasyPro","wasmWidthOrHeightChange and reset player and play success")})).catch((e=>{this.emit(st.playFailedAndPaused,lt.wasmWidthOrHeightChange,i,t),this.debug.error("EasyPro","wasmWidthOrHeightChange and reset player and play error",e)}))}),1e3*this._opt.widthOrHeightChangeReplayDelayTime):this.play(e,s).then((()=>{this.debug.log("EasyPro","wasmWidthOrHeightChange and reset player and play success")})).catch((e=>{this.emit(st.playFailedAndPaused,lt.wasmWidthOrHeightChange,i,t),this.debug.error("EasyPro","wasmWidthOrHeightChange and reset player and play error",e)}))})).catch((e=>{this.emit(st.playFailedAndPaused,lt.wasmWidthOrHeightChange,i,t),this.debug.error("EasyPro","wasmWidthOrHeightChange and _resetPlayer error",e)}))}else{const r=!1===this._opt.playFailedUseLastFrameShow;this._pause(r).then((()=>{this.emit(st.playFailedAndPaused,lt.wasmWidthOrHeightChange,i,t),this.debug.error("EasyPro","wasmWidthOrHeightChange and _resetPlayer error",e)})).catch((e=>{this.emit(st.playFailedAndPaused,lt.wasmWidthOrHeightChange,i),this.debug.error("EasyPro","wasmWidthOrHeightChange error and pause error",e)}))}})),this.player.once(lt.wasmUseVideoRenderError,(e=>{if(this.isDestroyed())return void this.debug.log("EasyPro","wasmUseVideoRenderError but player is destroyed");this.emit(st.crashLog,this.getCrashLog(lt.wasmUseVideoRenderError,e)),this.debug.log("EasyPro","wasmUseVideoRenderError and reset player and play");const t=this._opt.url,i=this.isMute(),r={...this._opt.playOptions,isNotMute:!i};this._resetPlayer({useVideoRender:!1,useCanvasRender:!0,isNotMute:!i}).then((()=>{this.play(t,r).then((()=>{this.debug.log("EasyPro","wasmUseVideoRenderError and reset player and play success")})).catch((t=>{this.emit(st.playFailedAndPaused,lt.wasmUseVideoRenderError,{},e),this.debug.error("EasyPro","wasmUseVideoRenderError and reset player and play error",t)}))})).catch((t=>{this.emit(st.playFailedAndPaused,lt.wasmUseVideoRenderError,{},e),this.debug.error("EasyPro","wasmUseVideoRenderError and _resetPlayer error",t)}))})),this.player.once(lt.videoElementPlayingFailed,(e=>{if(this.isDestroyed())this.debug.log("EasyPro","videoElementPlayingFailed but player is destroyed");else if(this.emit(st.crashLog,this.getCrashLog(lt.videoElementPlayingFailed,e)),this.player&&this.player._opt.videoElementPlayingFailedReplay){this.debug.log("EasyPro",`videoElementPlayingFailed and useMSE is ${this._opt.useMSE} and reset player and play`);const t=this._opt.url,i=this.isMute(),r={...this._opt.playOptions,isNotMute:!i};this._resetPlayer({useMSE:!1,useVideoRender:!1,useCanvasRender:!0,isNotMute:!i}).then((()=>{this.play(t,r).then((()=>{this.debug.log("EasyPro","videoElementPlayingFailed and reset player and play success")})).catch((t=>{this.emit(st.playFailedAndPaused,lt.videoElementPlayingFailed,{},e),this.debug.error("EasyPro","videoElementPlayingFailed and reset player and play error",t)}))})).catch((t=>{this.emit(st.playFailedAndPaused,lt.videoElementPlayingFailed,{},e),this.debug.error("EasyPro","videoElementPlayingFailed and _resetPlayer error",t)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this._pause(t).then((()=>{this.emit(st.playFailedAndPaused,lt.videoElementPlayingFailed,{},e),this.debug.error("EasyPro","videoElementPlayingFailed and videoElementPlayingFailedReplay is false")})).catch((t=>{this.emit(st.playFailedAndPaused,lt.videoElementPlayingFailed,{},e),this.debug.error("EasyPro","videoElementPlayingFailed and _pause error",t)}))}})),this.player.once(lt.simdH264DecodeVideoWidthIsTooLarge,(e=>{if(this.isDestroyed())this.debug.log("EasyPro","simdH264DecodeVideoWidthIsTooLarge but player is destroyed");else if(this.emit(st.crashLog,this.getCrashLog(lt.simdH264DecodeVideoWidthIsTooLarge,e)),this.player&&this.player._opt.simdH264DecodeVideoWidthIsTooLargeReplay){this.debug.log("EasyPro","simdH264DecodeVideoWidthIsTooLarge and reset player and play");const t=this._opt.url,i=this.isMute(),r={...this._opt.playOptions,isNotMute:!i};this._resetPlayer({useSIMD:!1,isNotMute:!i}).then((()=>{this.play(t,r).then((()=>{this.debug.log("EasyPro","simdH264DecodeVideoWidthIsTooLarge and reset player and play success")})).catch((t=>{this.emit(st.playFailedAndPaused,lt.simdH264DecodeVideoWidthIsTooLarge,{},e),this.debug.error("EasyPro","simdH264DecodeVideoWidthIsTooLarge and reset player and play error",t)}))})).catch((t=>{this.emit(st.playFailedAndPaused,lt.simdH264DecodeVideoWidthIsTooLarge,{},e),this.debug.error("EasyPro","simdH264DecodeVideoWidthIsTooLarge and _resetPlayer error",t)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this._pause(t).then((()=>{this.emit(st.playFailedAndPaused,lt.simdH264DecodeVideoWidthIsTooLarge,{},e),this.debug.error("EasyPro","simdH264DecodeVideoWidthIsTooLarge and simdDecodeErrorReplay is false")})).catch((t=>{this.emit(st.playFailedAndPaused,lt.simdH264DecodeVideoWidthIsTooLarge,{},e),this.debug.error("EasyPro","simdH264DecodeVideoWidthIsTooLarge and pause error",t)}))}})),this.player.once(st.networkDelayTimeout,(e=>{if(this.player._opt.networkDelayTimeoutReplay){if(this.isDestroyed())return void this.debug.log("EasyPro","networkDelayTimeout but player is destroyed");this.emit(st.crashLog,this.getCrashLog(st.networkDelayTimeout,e));const t=this._getVideoLastIframeInfo();this.debug.log("EasyPro","network delay time out and reset player and play");const i=this._opt.url,r=this.isMute(),s={...this._opt.playOptions,isNotMute:!r};let a={};this.player&&this.player._opt.replayUseLastFrameShow&&(a=Object.assign({},a,t,{loadingIcon:this.player._opt.replayShowLoadingIcon,isNotMute:!r})),this._resetPlayer(a).then((()=>{this.play(i,s).then((()=>{this.debug.log("EasyPro","wasm decode error and reset player and play success")})).catch((i=>{this.emit(st.playFailedAndPaused,st.networkDelayTimeout,t,e),this.debug.error("EasyPro","wasm decode error and reset player and play error",i)}))})).catch((()=>{this.emit(st.playFailedAndPaused,st.networkDelayTimeout,t,e),this.debug.error("EasyPro","wasm decode error and _resetPlayer error")}))}})),this.player.once(lt.fetchError,(e=>{if(this.isDestroyed())return void this.debug.log("EasyPro","fetchError but player is destroyed");this.emit(st.crashLog,this.getCrashLog(lt.fetchError,e));const t=this._getVideoLastIframeInfo();this.debug.log("EasyPro","fetch error and pause player");const i=!1===this._opt.playFailedUseLastFrameShow;this._pause(i).then((()=>{this.emit(st.playFailedAndPaused,lt.fetchError,t,e)})).catch((i=>{this.emit(st.playFailedAndPaused,lt.fetchError,t,e),this.debug.error("EasyPro","fetch error and pause",i)}))})),this.player.once(st.streamEnd,(e=>{if(this.isDestroyed())return void this.debug.log("EasyPro","streamEnd but player is destroyed and return");this.emit(st.crashLog,this.getCrashLog(st.streamEnd,e));const t=this._getVideoLastIframeInfo();let i={};if(this.player&&this.player._opt.replayUseLastFrameShow&&t.loadingBackgroundHeight&&(i=Object.assign({},i,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),this.player&&this.player._opt.websocket1006ErrorReplay&&""+e=="1006"){this.debug.log("EasyPro","streamEnd and websocket1006ErrorReplay is true and error is 1006 and reset player and play");const t=this.isMute(),r={...this._opt.playOptions,isNotMute:!t},s=this._opt.url;this._resetPlayer(i).then((()=>{setTimeout((()=>{this.isDestroyed()?this.debug.log("EasyPro","streamEnd and 1006 error but player is destroyed and return"):this.play(s,r).then((()=>{this.debug.log("EasyPro","streamEnd and 1006 error and reset player and play success")})).catch((t=>{this.emit(st.playFailedAndPaused,lt.streamEnd,{},e),this.debug.error("EasyPro","streamEnd and 1006 error and reset player and play error",t)}))}),1e3*this._opt.websocket1006ErrorReplayDelayTime)})).catch((t=>{this.emit(st.playFailedAndPaused,lt.streamEnd,{},e),this.debug.error("EasyPro","streamEnd and 1006 and _resetPlayer error",t)}))}else{this.debug.log("EasyPro","streamEnd pause player");const i=!1===this._opt.playFailedUseLastFrameShow;this._pause(i).then((()=>{this.emit(st.playFailedAndPaused,st.streamEnd,t,e)})).catch((i=>{this.emit(st.playFailedAndPaused,st.streamEnd,t,e),this.debug.error("EasyPro","streamEnd pause",i)}))}})),this.player.once(lt.websocketError,(e=>{if(this.isDestroyed())return void this.debug.log("EasyPro","websocketError but player is destroyed");this.emit(st.crashLog,this.getCrashLog(lt.websocketError,e));const t=this._getVideoLastIframeInfo();this.debug.log("EasyPro","websocketError and reset player");const i=!1===this._opt.playFailedUseLastFrameShow;this._pause(i).then((()=>{this.emit(st.playFailedAndPaused,lt.websocketError,t,e)})).catch((i=>{this.emit(st.playFailedAndPaused,lt.websocketError,t,e),this.debug.error("EasyPro","websocketError and pause",i)}))})),this.player.once(lt.webrtcError,(e=>{if(this.isDestroyed())return void this.debug.log("EasyPro","webrtcError but player is destroyed");this.emit(st.crashLog,this.getCrashLog(lt.webrtcError,e));const t=this._getVideoLastIframeInfo();this.debug.log("EasyPro","webrtcError and pause player");const i=!1===this._opt.playFailedUseLastFrameShow;this._pause(i).then((()=>{this.emit(st.playFailedAndPaused,lt.webrtcError,t,e)})).catch((i=>{this.emit(st.playFailedAndPaused,lt.webrtcError,t,e),this.debug.error("EasyPro","webrtcError and pause",i)}))})),this.player.once(lt.hlsError,(e=>{if(this.isDestroyed())return void this.debug.log("EasyPro","hlsError but player is destroyed");this.emit(st.crashLog,this.getCrashLog(lt.hlsError,e));const t=this._getVideoLastIframeInfo();this.debug.log("EasyPro","hlsError and pause player");const i=!1===this._opt.playFailedUseLastFrameShow;this._pause(i).then((()=>{this.emit(st.playFailedAndPaused,lt.hlsError,t,e)})).catch((i=>{this.emit(st.playFailedAndPaused,lt.hlsError,t,e),this.debug.error("EasyPro","hlsError and pause",i)}))})),this.player.once(lt.aliyunRtcError,(e=>{if(this.isDestroyed())return void this.debug.log("EasyPro","aliyunRtcError but player is destroyed");this.emit(st.crashLog,this.getCrashLog(lt.aliyunRtcError,e));const t=this._getVideoLastIframeInfo();this.debug.log("EasyPro","aliyunRtcError and pause player");const i=!1===this._opt.playFailedUseLastFrameShow;this._pause(i).then((()=>{this.emit(st.playFailedAndPaused,lt.aliyunRtcError,t,e)})).catch((i=>{this.emit(st.playFailedAndPaused,lt.aliyunRtcError,t,e),this.debug.error("EasyPro","aliyunRtcError and pause",i)}))})),this.player.once(lt.decoderWorkerInitError,(e=>{if(this.isDestroyed())return void this.debug.log("EasyPro","decoderWorkerInitError but player is destroyed");this.emit(st.crashLog,this.getCrashLog(lt.decoderWorkerInitError,e)),this.debug.log("EasyPro","decoderWorkerInitError and pause player");const t=!1===this._opt.playFailedUseLastFrameShow;this._pause(t).then((()=>{this.emit(st.playFailedAndPaused,lt.decoderWorkerInitError,{},e)})).catch((t=>{this.emit(st.playFailedAndPaused,lt.decoderWorkerInitError,{},e),this.debug.error("EasyPro","decoderWorkerInitError and pause",t)}))})),this.player.once(lt.videoElementPlayingFailedForWebrtc,(e=>{if(this.isDestroyed())return void this.debug.log("EasyPro","videoElementPlayingFailedForWebrtc but player is destroyed");this.emit(st.crashLog,this.getCrashLog(lt.videoElementPlayingFailedForWebrtc,e)),this.debug.log("EasyPro","videoElementPlayingFailedForWebrtc and pause player");const t=!1===this._opt.playFailedUseLastFrameShow;this._pause(t).then((()=>{this.emit(st.playFailedAndPaused,lt.videoElementPlayingFailedForWebrtc,{},e)})).catch((t=>{this.emit(st.playFailedAndPaused,lt.videoElementPlayingFailedForWebrtc,{},e),this.debug.error("EasyPro","videoElementPlayingFailedForWebrtc and pause",t)}))})),this.player.once(lt.videoInfoError,(e=>{if(this.isDestroyed())return void this.debug.log("EasyPro","videoInfoError but player is destroyed");this.emit(st.crashLog,this.getCrashLog(lt.videoInfoError,e)),this.debug.log("EasyPro","videoInfoError and pause player");const t=!1===this._opt.playFailedUseLastFrameShow;this._pause(t).then((()=>{this.emit(st.playFailedAndPaused,lt.videoInfoError,{},e)})).catch((t=>{this.emit(st.playFailedAndPaused,lt.videoInfoError,{},e),this.debug.error("EasyPro","videoInfoError and pause",t)}))})),this.player.once(st.webrtcStreamH265,(e=>{if(this.isDestroyed())return void this.debug.log("EasyPro","webrtcStreamH265 but player is destroyed");this.debug.log("EasyPro","webrtcStreamH265 and reset player and play");const t=this._opt.url,i=this.isMute(),r={...this._opt.playOptions,isNotMute:!i},s={isWebrtcH265:!0,isNotMute:!i};this._resetPlayer(s).then((()=>{this.play(t,r).then((()=>{this.debug.log("EasyPro","webrtcStreamH265 and reset player and play success")})).catch((t=>{this.emit(st.playFailedAndPaused,st.webrtcStreamH265,{},e),this.debug.error("EasyPro","webrtcStreamH265 and reset player and play error",t)}))})).catch((()=>{this.emit(st.playFailedAndPaused,st.webrtcStreamH265,{},e),this.debug.error("EasyPro","webrtcStreamH265 and _resetPlayer error")}))})),this.player.on(st.delayTimeout,(e=>{if(this.isDestroyed())return void this.debug.log("EasyPro","delay timeout but player is destroyed");this.emit(st.crashLog,this.getCrashLog(st.delayTimeout,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.heartTimeoutReplay&&(this._heartTimeoutReplayTimes<this.player._opt.heartTimeoutReplayTimes||-1===this.player._opt.heartTimeoutReplayTimes)){if(this.debug.log("EasyPro",`delay timeout replay time is ${this._heartTimeoutReplayTimes} and heartTimeoutReplayTimes is ${this.player._opt.heartTimeoutReplayTimes}`),this.isDestroyed())return void(this.debug&&this.debug.warn("EasyPro","delay timeout replay but player is destroyed"));this._heartTimeoutReplayTimes+=1;const i=this._opt.url,r=this.isMute(),s=this.getPlaybackCurrentRate(),a={...this._opt.playOptions,isNotMute:!r};let n={};(this.player._opt.heartTimeoutReplayUseLastFrameShow||this.player._opt.replayUseLastFrameShow)&&(n=Object.assign({},n,t,{loadingIcon:this.player._opt.replayShowLoadingIcon,isNotMute:!r})),this._resetPlayer(n).then((()=>{this.play(i,a).then((()=>{console.log("重连成功!",s),s&&this.forward(s)})).catch((i=>{this.emit(st.playFailedAndPaused,st.delayTimeout,t,e),this.debug.error("EasyPro","delay timeout replay error",i)}))})).catch((i=>{this.emit(st.playFailedAndPaused,st.delayTimeout,t,e),this.debug.error("EasyPro","delay timeout _resetPlayer error",i)}))}else{const i=!1===this._opt.playFailedUseLastFrameShow;this._pause(i).then((()=>{this.emit(st.playFailedAndPaused,st.delayTimeout,t,e),this.player&&(this.emit(st.delayTimeoutRetryEnd),this.emit(st.playFailedAndPaused,st.delayTimeoutRetryEnd)),this.debug.warn("EasyPro",`delayTimeoutRetryEnd and\n opt.heartTimeout is ${this.player&&this.player._opt.heartTimeout} and\n opt.heartTimeoutReplay is ${this.player&&this.player._opt.heartTimeoutReplay} and\n opt.heartTimeoutReplayTimes is ${this.player&&this.player._opt.heartTimeoutReplayTimes},and\n local._heartTimeoutReplayTimes is ${this._heartTimeoutReplayTimes}`)})).catch((i=>{this.emit(st.playFailedAndPaused,st.delayTimeout,t,e),this.debug.error("EasyPro","delay timeout and pause error",i)}))}})),this.player.on(st.loadingTimeout,(e=>{if(this.emit(st.crashLog,this.getCrashLog(st.loadingTimeout,e)),this.isDestroyed())this.debug.log("EasyPro","loading timeout but player is destroyed");else if(this.player&&this.player._opt.loadingTimeoutReplay&&(this._loadingTimeoutReplayTimes<this.player._opt.loadingTimeoutReplayTimes||-1===this.player._opt.loadingTimeoutReplayTimes)){if(this.debug.log("EasyPro",`loading timeout and\n replay time is ${this._loadingTimeoutReplayTimes} and\n loadingTimeoutReplayTimes is ${this.player._opt.loadingTimeoutReplayTimes}`),this.isDestroyed())return void(this.debug&&this.debug.warn("EasyPro","delay timeout replay but player is destroyed"));this._loadingTimeoutReplayTimes+=1;const t=this._opt.url,i=this.isMute(),r=this.getPlaybackCurrentRate(),s={...this._opt.playOptions,isNotMute:!i};this._resetPlayer(h).then((()=>{this.play(t,s).then((()=>{r&&this.forward(r)})).catch((t=>{this.emit(st.playFailedAndPaused,st.loadingTimeout,{},e),this.debug.error("EasyPro","loading timeout replay error",t)}))})).catch((t=>{this.emit(st.playFailedAndPaused,st.loadingTimeout,{},e),this.debug.error("EasyPro","loading timeout _resetPlayer error",t)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this._pause(t).then((()=>{this.emit(st.playFailedAndPaused,st.loadingTimeout,{},e),this.player&&(this.emit(st.loadingTimeoutRetryEnd),this.emit(st.playFailedAndPaused,st.loadingTimeoutRetryEnd,{},e)),this.debug.log("EasyPro",`loadingTimeoutRetryEnd and\n opt.loadingTimeout is ${this.player&&this.player._opt.loadingTimeout} and\n opt.loadingTimeoutReplay is ${this.player&&this.player._opt.loadingTimeoutReplay} and\n local._loadingTimeoutReplayTimes time is ${this._loadingTimeoutReplayTimes} and\n opt.loadingTimeoutReplayTimes is ${this.player&&this.player._opt.loadingTimeoutReplayTimes}`)})).catch((t=>{this.emit(st.playFailedAndPaused,st.loadingTimeout,{},e),this.debug.error("EasyPro","loading timeout and pause error",t)}))}})),this._hasLoaded()?this.player.play(t,h).then((()=>{c()})).catch((e=>{this.debug.error("EasyPro","_hasLoaded() and play error",e),this.emit(st.crashLog,this.getCrashLog("_hasLoaded() and play error",e)),this.player&&this.player.pause().then((()=>{u(e)})).catch((e=>{u(e),this.debug.error("EasyPro","_hasLoaded() and play error and next pause error",e)}))})):this.player.once(st.decoderWorkerInit,(()=>{this.player.play(t,h).then((()=>{c()})).catch((e=>{this.debug.error("EasyPro","decoderWorkerInit and play error",e),this.emit(st.crashLog,this.getCrashLog("decoderWorkerInit and play error",e)),this.player&&this.player.pause().then((()=>{u(e)})).catch((e=>{u(e),this.debug.error("EasyPro","decoderWorkerInit and play error and next pause error",e)}))}))}))},j=this.player.getOption(),Y=w&&ka(this._opt.supportHls265),Q=m&&ka(this._opt.isWebrtcH265),X=w&&!!ua(),J=w&&j.demuxUseWorker;if(Y||Q||g||p||U||X||J)this.debug.log("EasyPro",`need reset player and\n isOldHls is ${Y} and isOldWebrtc is ${Q} and\n isAliyunRtc is ${g} and\n needResetPlayer(url change) is ${p} and\n isMpeg4 is ${U} and\n isHlsCanVideoPlay is ${X} and\n isHlsButDemuxUseWorker is ${J}`),this._resetPlayer({protocol:V,demuxType:H,isWsRtc:_,isHls:w,isWebrtc:m,isWebrtcForZLM:N,isWebrtcForSRS:z,isWebrtcForOthers:W,isAliyunRtc:g,cryptoKey:h.cryptoKey||"",cryptoIV:h.cryptoIV||"",url:t}).then((()=>{$()})).catch((e=>{u("reset player error")}));else{const e={protocol:V,demuxType:H,isHls:w,isWsRtc:_,isWebrtc:m,isAliyunRtc:g,isFlv:this._opt.isFlv,isFmp4:this._opt.isFmp4,isMpeg4:this._opt.isMpeg4,isNakedFlow:this._opt.isNakedFlow,isTs:this._opt.isTs,cryptoKey:h.cryptoKey||"",cryptoIV:h.cryptoIV||""};this._opt.isNakedFlow&&(e.mseDecodeAudio=!1),this.player.updateOption(e),h.cryptoKey&&h.cryptoIV&&this.player.decoderWorker&&(this.player.decoderWorker.updateWorkConfig({key:"cryptoKey",value:h.cryptoKey}),this.player.decoderWorker.updateWorkConfig({key:"cryptoIV",value:h.cryptoIV})),$()}}))}_resetDemuxType(e){this._opt.isFlv=!1,this._opt.isFmp4=!1,this._opt.isMpeg4=!1,this._opt.isNakedFlow=!1,this._opt.isHls=!1,this._opt.isWsRtc=!1,this._opt.isWebrtc=!1,this._opt.isWebrtcForZLM=!1,this._opt.isWebrtcForSRS=!1,this._opt.isWebrtcForOthers=!1,this._opt.isAliyunRtc=!1,this._opt.isTs=!1,e&&(this._opt[e]=!0),"isFmp4"!==e&&(this._opt.isFmp4Private=!1)}startVoice(){this.player.startVoice()}pauseVoice(){this.player.pauseVoice()}removeVoice(){this.player.removeVoice()}resize(){this.debug.log("EasyPro","resize()"),this.player&&this.player.resize()}setBufferTime(e){this.debug.log("EasyPro",`setBufferTime() ${e}`),(e=Number(e))>10&&this.debug.warn("EasyPro",`setBufferTime() buffer time is ${e} second, is too large, video will show blank screen until cache ${e} second buffer data`);const t=1e3*e;this._opt.videoBuffer=t,this.player?this.player.updateOption({videoBuffer:t},!0):this.debug.warn("EasyPro","setBufferTime() player is null")}setBufferDelayTime(e){this.debug.log("EasyPro",`setBufferDelayTime() ${e}`),(e=Number(e))<.2&&this.debug.warn("EasyPro",`setBufferDelayTime() buffer time delay is ${e} second, is too small`);const t=1e3*(e=bs(e,.2,100));this._opt.videoBufferDelay=t,this.player?this.player.updateOption({videoBufferDelay:t},!0):this.debug.warn("EasyPro","setBufferDelayTime() player is null")}setRotate(e){this.debug.log("EasyPro",`setRotate() ${e}`),e=parseInt(e,10);this._opt.rotate!==e&&-1!==[0,90,180,270].indexOf(e)?(this._opt.rotate=e,this.player?(this.player.updateOption({rotate:e}),this.resize()):this.debug.warn("EasyPro","setRotate() player is null")):this.debug.warn("EasyPro",`setRotate() rotate is ${e} and this._opt.rotate is ${this._opt.rotate}`)}setMirrorRotate(e){this.debug.log("EasyPro",`setMirrorRotate() ${e}`);e||(e="none"),this._opt.mirrorRotate!==e&&-1!==["none","level","vertical"].indexOf(e)?(this._opt.mirrorRotate=e,this.player?(this.player.updateOption({mirrorRotate:e}),this.resize()):this.debug.warn("EasyPro","setMirrorRotate() player is null")):this.debug.warn("EasyPro",`setMirrorRotate() mirrorRotate is ${e} and this._opt.mirrorRotate is ${this._opt.mirrorRotate}`)}setAspectRatio(e){this.debug.log("EasyPro",`setAspectRatio() ${e}`);e||(e="default"),this._opt.aspectRatio!==e&&-1!==["default","4:3","16:9"].indexOf(e)?(this._opt.aspectRatio=e,this.player?(this.player.updateOption({aspectRatio:e}),this.resize()):this.debug.warn("EasyPro","setAspectRatio() player is null")):this.debug.warn("EasyPro",`setAspectRatio() aspectRatio is ${e} and this._opt.aspectRatio is ${this._opt.mirrorRotate}`)}hasLoaded(){return!0}_hasLoaded(){return this.player&&this.player.loaded||!1}setKeepScreenOn(){this.debug.log("EasyPro","setKeepScreenOn()"),this._opt.keepScreenOn=!0,this.player?this.player.updateOption({keepScreenOn:!0}):this.debug.warn("EasyPro","setKeepScreenOn() player is not ready")}setFullscreen(e){this.debug.log("EasyPro",`setFullscreen() ${e}`);const t=!!e;this.player?this.player.fullscreen!==t?this.player.fullscreen=t:this.debug.warn("EasyPro",`setFullscreen() fullscreen is ${t} and this.player.fullscreen is ${this.player.fullscreen}`):this.debug.warn("EasyPro","setFullscreen() player is not ready")}setWebFullscreen(e){this.debug.log("EasyPro",`setWebFullscreen() ${e}`);const t=!!e;this.player?this.player.webFullscreen=t:this.debug.warn("EasyPro","setWebFullscreen() player is not ready")}screenshot(e,t,i,r){return this.debug.log("EasyPro",`screenshot() ${e} ${t} ${i} ${r}`),this.player&&this.player.video?this.player.video.screenshot(e,t,i,r):(this.debug.warn("EasyPro","screenshot() player is not ready"),console.log("没有player实例"),null)}screenshotWatermark(e){return new Promise(((t,i)=>{this.debug.log("EasyPro","screenshotWatermark()",e),this.player&&this.player.video?this.player.video.screenshotWatermark(e).then((e=>{t(e)})).catch((e=>{i(e)})):(this.debug.warn("EasyPro","screenshotWatermark() player is not ready"),i("player is not ready"))}))}startRecord(e,t){return new Promise(((i,r)=>{if(this.debug.log("EasyPro",`startRecord() ${e} ${t}`),!this.player)return this.debug.warn("EasyPro","startRecord() player is not ready"),r("player is not ready");this.player.playing?(this.player.startRecord(e,t),i()):(this.debug.warn("EasyPro","startRecord() player is not playing"),r("not playing"))}))}stopRecordAndSave(e,t){return new Promise(((i,r)=>{this.debug.log("EasyPro",`stopRecordAndSave() ${e} ${t}`),this.player&&this.player.recording?this.player.stopRecordAndSave(e,t).then((e=>{i(e)})).catch((e=>{r(e)})):r("not recording")}))}isPlaying(){let e=!1;return this.player&&(e=this.player.isPlaying()),e}isLoading(){return!!this.player&&this.player.loading}isPause(){let e=!1;return this._opt.playType===A?e=!this.isPlaying()&&!this.isLoading():this._opt.playType===b&&this.player&&(e=this.player.playbackPause),e}isPaused(){return this.isPause()}isPlaybackPause(){let e=!1;return this._opt.playType===b&&this.player&&(e=this.player.playbackPause),e}isMute(){let e=!0;return this.player&&(e=this.player.isAudioMute()),e}isRecording(){return this.player&&this.player.recorder&&this.player.recorder.recording||!1}isFullscreen(){let e=!1;return this.player&&(e=this.player.fullscreen),e}isWebFullscreen(){let e=!1;return this.player&&(e=this.player.webFullscreen),e}clearBufferDelay(){this.debug.log("EasyPro","clearBufferDelay()"),this.player?this.player.clearBufferDelay():this.debug.warn("EasyPro","clearBufferDelay() player is not init")}setNetworkDelayTime(e){this.debug.log("EasyPro",`setNetworkDelayTime() ${e}`),(e=Number(e))<1&&this.debug.warn("EasyPro",`setNetworkDelayTime() network delay is ${e} second, is too small`);const t=1e3*(e=bs(e,1,100));this._opt.networkDelay=t,this.player?this.player.updateOption({networkDelay:t},!0):this.debug.warn("EasyPro","setNetworkDelayTime() player is null")}getDecodeType(){let e="";return this.player&&(e=this.player.getDecodeType()),e}getRenderType(){let e="";return this.player&&(e=this.player.getRenderType()),e}getAudioEngineType(){let e="";return this.player&&(e=this.player.getAudioEngineType()),e}getPlayingTimestamp(){let e=0;return this.player&&(e=this.player.getPlayingTimestamp()),e}getStatus(){let e=Oi;return this.player&&(e=this.player.loading?Mi:this.player.playing?Ui:Fi),e}getPlayType(){return this.player?this.player._opt.playType:A}togglePerformancePanel(e){this.debug.log("EasyPro",`togglePerformancePanel() ${e}`);const t=this.player._opt.showPerformance;let i=!t;js(e)&&(i=e),i!==t?this.player?this.player.togglePerformancePanel(i):this.debug.warn("EasyPro","togglePerformancePanel() failed, this.player is not init"):this.debug.warn("EasyPro",`togglePerformancePanel() failed, showPerformance is prev: ${t} === now: ${i}`)}openZoom(){this.debug.log("EasyPro","openZoom()"),this.player?this.player.zooming=!0:this.debug.warn("EasyPro","openZoom() failed, this.player is not init")}closeZoom(){this.debug.log("EasyPro","closeZoom()"),this.player?this.player.zooming=!1:this.debug.warn("EasyPro","closeZoom() failed, this.player is not init")}isZoomOpen(){let e=!1;return this.player&&(e=this.player.zooming),e}toggleZoom(e){this.debug.log("EasyPro",`toggleZoom() ${e}`),js(e)||(e=!this.isZoomOpen()),Ta(e)?this.openZoom():ka(!1)&&this.closeZoom()}expandZoom(){this.debug.log("EasyPro","expandZoom()"),this.player&&this.player.zoom&&this.player.zooming?this.player.zoom.expandPrecision():this.debug.warn("EasyPro","expandZoom() failed, zoom is not open or not init")}narrowZoom(){this.debug.log("EasyPro","narrowZoom()"),this.player&&this.player.zoom&&this.player.zooming?this.player.zoom.narrowPrecision():this.debug.warn("EasyPro","narrowZoom failed, zoom is not open or not init")}getCurrentZoomIndex(){let e=1;return this.player&&this.player.zoom&&(e=this.player.zoom.currentZoom),e}startTalk(e,t={}){return new Promise(((i,r)=>{this.debug.log("EasyPro","startTalk()",e,t),this._initTalk(t),this.talk.startTalk(e).then((()=>{i(),this.talk.once(st.talkStreamClose,(()=>{this.debug.warn("EasyPro","talk stream close"),this.stopTalk().catch((e=>{}))})),this.talk.once(st.talkStreamError,(e=>{this.debug.warn("EasyPro","talk stream error",e),this.stopTalk().catch((e=>{}))})),this.talk.once(st.talkStreamInactive,(()=>{this.debug.warn("EasyPro","talk stream inactive"),this.stopTalk().catch((e=>{}))}))})).catch((e=>{r(e)}))}))}stopTalk(){return new Promise(((e,t)=>{if(this.debug.log("EasyPro","stopTalk()"),!this.talk)return t("stopTalk() talk is not init");this.talk.destroy(),e()}))}getTalkVolume(){return new Promise(((e,t)=>{if(!this.talk)return t("getTalkVolume() talk is not init");e(this.talk.volume)}))}setTalkVolume(e){return new Promise(((t,i)=>{if(this.debug.log("EasyPro","setTalkVolume()",e),!this.talk)return i("setTalkVolume() talk is not init");this.talk.setVolume(e/100),t()}))}setNakedFlowFps(e){return new Promise(((t,i)=>{if(this.debug.log("EasyPro","setNakedFlowFps()",e),$s(e))return i("setNakedFlowFps() fps is empty");let r=Number(e);r=bs(r,1,100),this._opt.nakedFlowFps=r,this.player?this.player.updateOption({nakedFlowFps:r}):this.debug.warn("EasyPro","setNakedFlowFps() player is null"),t()}))}getCrashLog(e,t=""){if(!this.player)return;const i=this.player.getAllStatsData(),r=this.player;let s={url:this._opt.url,playType:r.isPlayback()?"playback":"live",demuxType:r.getDemuxType(),decoderType:r.getDecodeType(),renderType:r.getRenderType(),videoInfo:{encType:"",width:"",height:""},audioInfo:{encType:"",sampleRate:"",channels:""},audioEngine:r.getAudioEngineType(),allTimes:i.pTs,timestamp:vs(),type:e,error:ga(t)||e};if(r.video){const e=r.video.videoInfo||{};s.videoInfo={encType:e.encType||"",width:e.width||"",height:e.height||""}}if(r.audio){const e=r.audio.audioInfo||{};s.audioInfo={encType:e.encType||"",sampleRate:e.sampleRate||"",channels:e.channels||""}}return s}updateDebugLevel(e){this.debug.log("EasyPro","updateDebugLevel()",e),e===Y||e===Q?e!==this.player._opt.debugLevel?(this._opt.debugLevel=e,this.player?this.player.updateOption({debugLevel:e},!0):this.debug.warn("EasyPro","updateDebugLevel() player is null")):this.debug.warn("EasyPro",`updateDebugLevel() level is same, level: ${e}`):this.debug.warn("EasyPro",`updateDebugLevel() level is not valid, level: ${e}`)}updateWatermark(e){this.debug.log("EasyPro","updateWatermark()",e),this.player?this.player.updateWatermark(e):this.debug.warn("EasyPro","updateWatermark() player is not init")}removeWatermark(){this.debug.log("EasyPro","removeWatermark()"),this.player?this.player.removeWatermark():this.debug.warn("EasyPro","removeWatermark() player is not init")}updateFullscreenWatermark(e){if(this.debug.log("EasyPro","updateFullscreenWatermark()",e),sa(e)){this._opt.fullscreenWatermarkConfig=e;const t=Ys(this.$container,e);if(!t.watermark_txt)return void this.debug.warn("EasyPro","fullscreenWatermarkConfig text is empty");this.watermark.load(t)}else this.debug.warn("EasyPro",`updateFullscreenWatermark() config is not valid, config: ${e}`)}removeFullscreenWatermark(){this.debug.log("EasyPro","removeFullscreenWatermark()"),this.watermark?this.watermark.remove():this.debug.warn("EasyPro","removeFullscreenWatermark() watermark is not init")}faceDetectOpen(){this.debug.log("EasyPro","faceDetectOpen()"),this.player?this.player.faceDetect(!0):this.debug.warn("EasyPro","faceDetectOpen() player is not init")}faceDetectClose(){this.debug.log("EasyPro","faceDetectClose()"),this.player?this.player.faceDetect(!1):this.debug.warn("EasyPro","faceDetectClose() player is not init")}objectDetectOpen(){this.debug.log("EasyPro","objectDetectOpen()"),this.player?this.player.objectDetect(!0):this.debug.warn("EasyPro","objectDetectOpen() player is not init")}objectDetectClose(){this.debug.log("EasyPro","objectDetectClose()"),this.player?this.player.objectDetect(!1):this.debug.warn("EasyPro","objectDetectClose() player is not init")}sendWebsocketMessage(e){this.debug.log("EasyPro","sendWebsocketMessage()",e),this.player?this.player.sendWebsocketMessage(e):this.debug.warn("EasyPro","sendWebsocketMessage() player is not init")}addContentToCanvas(e){this.debug.log("EasyPro","addContentToCanvas()"),this.player?this.player.addContentToCanvas(e):this.debug.warn("EasyPro","addContentToCanvas() player is not init")}clearContentToCanvas(){this.debug.log("EasyPro","clearContentToCanvas()"),this.player?this.player.addContentToCanvas([]):this.debug.warn("EasyPro","clearContentToCanvas() player is not init")}setControlHtml(e){this.debug.log("EasyPro","setControlHtml()",e),this.player?this.player.setControlHtml(e):this.debug.warn("EasyPro","setControlHtml() player is not init")}clearControlHtml(){this.debug.log("EasyPro","clearControlHtml()"),this.player?this.player.clearControlHtml():this.debug.warn("EasyPro","clearControlHtml() player is not init")}getVideoInfo(){let e=null;return this.player&&(e=this.player.getVideoInfo()),e}getAudioInfo(){let e=null;return this.player&&(e=this.player.getAudioInfo()),e}setSm4CryptoKey(e){this.debug.log("EasyPro","setSm4CryptoKey()",e),32===(e=""+e).length?(this._opt.sm4CryptoKey=e,this.player?this.player.updateOption({sm4CryptoKey:e},!0):this.debug.warn("EasyPro","setSm4CryptoKey() player is null")):this.debug.warn("EasyPro",`setSm4CryptoKey() key is invalid and length is ${e.length} !== 32`)}setM7sCryptoKey(e){this.debug.log("EasyPro","setM7sCryptoKey()",e),e=""+e,this._opt.m7sCryptoKey=e,this.player?this.player.updateOption({m7sCryptoKey:e},!0):this.debug.warn("EasyPro","setM7sCryptoKey() player is null")}setXorCryptoKey(e){this.debug.log("EasyPro","setXorCryptoKey()",e),e=""+e,this._opt.xorCryptoKey=e,this.player?this.player.updateOption({xorCryptoKey:e},!0):this.debug.warn("EasyPro","setXorCryptoKey() player is null")}updateLoadingText(e){this.debug.log("EasyPro","updateLoadingText()",e),this.player?this.player.updateLoadingText(e):this.debug.warn("EasyPro","updateLoadingText() player is null")}updateIsEmitSEI(e){this.debug.log("EasyPro","updateIsEmitSEI()",e),this._opt.isEmitSEI=e,this.player?this.player.updateOption({isEmitSEI:e},!0):this.debug.warn("EasyPro","updateIsEmitSEI() player is null")}getPTZCmd(e,t){if(this.debug.log("EasyPro","getPTZCmd()",e),e)return this.player?Xc({type:e,index:0,speed:t}):void this.debug.warn("EasyPro","getPTZCmd() player is null");this.debug.warn("EasyPro","getPTZCmd() ptz is null")}downloadTempNakedFlowFile(){return new Promise(((e,t)=>{this.player?(this.player.downloadNakedFlowFile(),e()):t("player is not init")}))}downloadTempFmp4File(){return new Promise(((e,t)=>{this.player?(this.player.downloadFmp4File(),e()):t("player is not init")}))}downloadTempMpeg4File(){return new Promise(((e,t)=>{this.player?(this.player.downloadMpeg4File(),e()):t("player is not init")}))}downloadTempRtpFile(){return new Promise(((e,t)=>{this.talk?(this.talk.downloadRtpFile(),e()):t("talk is not init")}))}downloadMemoryLog(){this.memoryLogger&&this.memoryLogger.download()}_getVideoLastIframeInfo(){const e=this.getVideoInfo()||{};return{loadingBackground:this.screenshot("","png",.92,"base64"),loadingBackgroundWidth:e.width||0,loadingBackgroundHeight:e.height||0}}getExtendBtnList(){this.debug.log("EasyPro","getExtendBtnList()");let e=[];return this.player?e=this.player.getExtendBtnList():this.debug.warn("EasyPro","getExtendBtnList() player is null"),e}getFlvMetaData(){this.debug.log("EasyPro","getFlvMetaData()");let e=null;return this.player?e=this.player.getMetaData():this.debug.warn("EasyPro","getFlvMetaData() player is null"),e}updateAiFaceDetectInterval(e){this.debug.log("EasyPro","updateAiFaceDetectInterval()",e);const t=1e3*(e=Number(e));this._opt.aiFaceDetectInterval=t,this.player?this.player.updateOption({aiFaceDetectInterval:t}):this.debug.warn("EasyPro","updateAiFaceDetectInterval() player is null")}updateAiFaceDetectLevel(e){if(this.debug.log("EasyPro","updateAiFaceDetectLevel()",e),!Rr[e])return void this.debug.warn("EasyPro",`'updateAiFaceDetectLevel() level ${e} is invalid'`);const t=Rr[e];this._opt.aiFaceDetectWidth=t,this.player?(this.player.updateOption({aiFaceDetectWidth:t}),this.player.ai&&this.player.ai.updateFaceDetectorConfig({detectWidth:t})):this.debug.warn("EasyPro","updateAiFaceDetectLevel() player is null")}updateAiObjectDetectInterval(e){this.debug.log("EasyPro","updateAiObjectDetectInterval()",e);const t=1e3*(e=Number(e));this._opt.aiObjectDetectInterval=t,this.player?this.player.updateOption({aiObjectDetectInterval:t}):this.debug.warn("EasyPro","updateAiObjectDetectInterval() player is null")}updateAiObjectDetectLevel(e){if(this.debug.log("EasyPro","updateAiObjectDetectLevel()",e),!xr[e])return void this.debug.warn("EasyPro",`'updateAiObjectDetectLevel() level ${e} is invalid'`);const t=xr[e];this._opt.aiObjectDetectWidth=t,this.player?(this.player.updateOption({aiObjectDetectWidth:t}),this.player.ai&&this.player.ai.updateObjectDetectorConfig({detectWidth:t})):this.debug.warn("EasyPro","updateAiObjectDetectLevel() player is null")}setCryptoKeyUrl(e){this.debug.log("EasyPro","setCryptoKeyUrl()",e),e&&(this._opt.cryptoKeyUrl=e)}showErrorMessageTips(e){this.debug.log("EasyPro","showErrorMessageTips()",e),e&&(this.player?this.player.showTipsMessageByContent(e):this.debug.warn("EasyPro","showErrorMessageTips() player is null"))}hideErrorMessageTips(){this.debug.log("EasyPro","hideErrorMessageTips()"),this.player?this.player.hideTipsMessage():this.debug.warn("EasyPro","hideErrorMessageTips() player is null")}}ru.ERROR=lt,ru.EVENTS=at,window.EasyPlayerPro=ru,window.WebPlayerPro=ru;kd('.easyplayer-multi-container .easyplayer-multi-player-container-v2{overflow:hidden;width:100%;height:100%;position:relative;display:grid;grid-template-columns:repeat(var(--split),1fr);grid-template-rows:repeat(var(--split),1fr)}.easyplayer-multi-container .easyplayer-multi-player-container-v2 .easyplayer-multi-player{overflow:hidden;position:relative;width:100%;height:100%}.easyplayer-multi-container .easyplayer-multi-player-container-v2 .easyplayer-multi-player .easyplayer-multi-player-draw-window{position:absolute;z-index:1;width:calc(100% - 2px);height:calc(100% - 2px);color:#fff;transition:all .25s}.easyplayer-multi-container .easyplayer-multi-player-container-v2 .easyplayer-multi-player .easyplayer-multi-player-video-window{position:absolute;left:1px;top:1px;z-index:2;width:calc(100% - 2px);height:calc(100% - 2px)}.easyplayer-multi-container .easyplayer-multi-player[fullscreen="1"]{grid-column-start:1;grid-column-end:9;grid-row-start:1;grid-row-end:9}.easyplayer-multi-container .easyplayer-multi-layout-6 .easyplayer-multi-player[order="0"]{grid-column-start:1;grid-column-end:3;grid-row-start:1;grid-row-end:3}.easyplayer-multi-container .easyplayer-multi-layout-9 .easyplayer-multi-player[order="0"]{grid-column-start:1;grid-column-end:4;grid-row-start:1;grid-row-end:4}');class su extends t{constructor(e={}){super(),this._opt={},Object.keys(e).forEach((t=>{if(void 0===e[t])throw new Error(`easyplayer-pro-multi option "${t}" can not be undefined`)}));const t=_a(ar);this._opt=Object.assign({},t,e),this.LOG_TAG="easyplayerProMulti";let i=e.container;if("string"==typeof e.container&&(i=document.querySelector(e.container)),!i)throw new Error("easyplayer-pro-multi need container option");if("CANVAS"===i.nodeName||"VIDEO"===i.nodeName)throw new Error(`easyplayer-pro-multi container type can not be ${i.nodeName} type`);i.classList.add("easyplayer-multi-container"),this.maxWindowSize=this._opt.maxSplit*this._opt.maxSplit,this.currentWindowIndex=-1,this.currentWindowUuid=null,this.specialLayoutType=null,this.startDragWindowItem=null,this.windowList=[],this.$container=i,this.debug=new Xr(this),this.events=new Ma(this),this._opt.split||(this._opt.split=1),Ta(this._opt.draggable)?this._initWindows$2():this._initWindows(),this._innerArrangeWindow(this._opt.split,!0),this._initEvents(),this._handleWindowSelect(0),this._listenFullscreenChange()}destroy(){return new Promise(((e,t)=>{if(this.debug.log(this.LOG_TAG,"destroy()"),this.off(),this.events&&(this.events.destroy(),this.events=null),this.specialLayoutType=null,this.startDragWindowItem=null,this.currentWindowUuid=null,this.currentWindowIndex=-1,this.$container&&(this.$container.classList.remove("easyplayer-multi-container"),this.$container=null),this.windowList){const i=[];this.windowList.forEach((e=>{e.$playerContainerEvents.forEach((e=>{e()})),e.player&&i.push(e.player.destroy())})),Promise.all(i).then((()=>{this.windowList.forEach((e=>{e.player=null})),this.windowList=[],e()})).catch((e=>{t(e)}))}else e();this.debug&&this.debug.log(this.LOG_TAG,"destroy")}))}_createPlayer(e){const t=this._findWindowItemIndex(e);e.uuid;const i=this._opt;i.supportDblclickContainerFullscreen&&(i.supportDblclickFullscreen=!1);const r=new ru({...i,isMulti:!0,multiIndex:t,container:e.$player});return Object.keys(at).forEach((e=>{r.on(at[e],((...i)=>{this.emit(e,t,...i)}))})),r.on(st.close,(()=>{this.emit(st.close,t),e.player=null})),r}_initWindows(){let e="";for(let t=0;t<this.maxWindowSize;t++)e+=`\n <div class="easyplayer-multi-player" wid="${t}" style='float: left;position:relative;overflow: hidden; background-color:${this._opt.style.background};'>\n <div class="easyplayer-multi-player-draw-window" wid="${t}" style='position:absolute; z-index: 1; border: 1px solid ${this._opt.style.border};'></div>\n <div class="easyplayer-multi-player-video-window" wid="${t}" style='position:absolute;left: 1px;top:1px; z-index: 2;'></div>\n <div class="mutli-text" style='color:#fff;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);' wid="${t}">未选择视频</div>\n </div>\n `;const t=`<div class="easyplayer-multi-player-container" style="overflow: hidden;width:100%; height:100%; position: relative;">${e}</div>`;this.$container.innerHTML=t;const i=this.$container.querySelectorAll(".easyplayer-multi-player");for(let e=0;e<this.maxWindowSize;e++){const t=i[e],r=t.querySelector(".easyplayer-multi-player-draw-window"),s=t.querySelector(".easyplayer-multi-player-video-window"),a=Us();Ca(t,"uuid",a),this.windowList[e]={uuid:a,isContainerFullscreen:!1,$playerContainer:t,$playerBorder:r,$player:s,$playerContainerEvents:[],player:null}}}_initWindows$2(){let e="";const t=this._opt.split;for(let t=0;t<this.maxWindowSize;t++)e+=`\n <div class="easyplayer-multi-player" wid="${t}" order='${t}' style='order:${t};background-color:${this._opt.style.background};'>\n <div class="easyplayer-multi-player-draw-window" wid="${t}"></div>\n <div class="easyplayer-multi-player-video-window" wid="${t}"></div>\n <div class="mutli-text" style='color:#fff;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);' wid="${t}">未选择视频</div>\n </div>\n `;const i=`<div class="easyplayer-multi-player-container-v2" style="--split:${t}">\n ${e}\n </div>`;this.$container.innerHTML=i,this.$multiContainer=this.$container.querySelector(".easyplayer-multi-player-container-v2");const r=this.$container.querySelectorAll(".easyplayer-multi-player");for(let e=0;e<this.maxWindowSize;e++){const t=r[e],i=t.querySelector(".easyplayer-multi-player-draw-window"),s=t.querySelector(".easyplayer-multi-player-video-window"),a=Us();Ca(t,"uuid",a),this.windowList[e]={uuid:a,isContainerFullscreen:!1,$playerContainer:t,$playerBorder:i,$player:s,$playerContainerEvents:[],player:null}}}_initEvents(){const{proxy:e}=this.events;this.windowList.forEach(((t,i)=>{const r=t.$playerContainer,s=e(r,"click",(e=>{const t=Da(r,"uuid"),i=this._findWindowItemIndexByUuid(t);if(this.emit(nr.selected,i,e),this.getSelectedWindowUuid()===t){if(this._getWindowItem(t).isContainerFullscreen)return}1!==this._opt.split&&this._handleWindowSelect(i)})),a=e(r,"dblclick",(e=>{const t=Da(r,"uuid"),i=this._findWindowItemIndexByUuid(t);this.emit(nr.dblSelected,i,e),this._opt.supportDblclickContainerFullscreen&&1!==this._opt.split&&this._handleWindowContainerFullscreen(i)})),n=e(r,"mouseup",(e=>{const t=Da(r,"uuid"),i=this._findWindowItemIndexByUuid(t);this.emit(nr.mouseup,i,e)})),o=e(r,"mouseover",(e=>{const t=Da(r,"uuid"),i=this._findWindowItemIndexByUuid(t);this.emit(nr.mouseover,i,e)})),l=e(r,"mouseout",(e=>{const t=Da(r,"uuid"),i=this._findWindowItemIndexByUuid(t);this.emit(nr.mouseout,i,e)})),d=e(r,"mousedown",(e=>{const t=Da(r,"uuid"),i=this._findWindowItemIndexByUuid(t);this.emit(nr.mousedown,i,e)})),h=e(r,"dragover",(e=>{e.preventDefault()})),c=e(r,"dragenter",(e=>{const t=Da(r,"uuid"),i=this._findWindowItemIndexByUuid(t);this.emit(nr.dragenter,i,e)})),u=e(r,"dragleave",(e=>{const t=Da(r,"uuid"),i=this._findWindowItemIndexByUuid(t);this.emit(nr.dragleave,i,e)})),p=e(r,"drop",(e=>{const t=Da(r,"uuid"),i=this._findWindowItemIndexByUuid(t);if(e.preventDefault(),this._opt.draggable&&this.startDragWindowItem){const e=this.startDragWindowItem.$playerContainer,t=e.style.order;e.style.order=r.style.order,e.setAttribute("order",e.style.order),r.setAttribute("order",t),r.style.order=t,this.debug.log(this.LOG_TAG,`player Drop ${t} -> ${e.style.order}`),this._sortWindows()}this.emit(nr.drop,i,e)}));if(t.$playerContainerEvents=[s,n,o,l,d,a,h,c,u,p],this._opt.draggable){const i=e(r,"dragstart",(e=>{const t=Da(r,"uuid"),i=this._findWindowItemIndexByUuid(t);this._handleWindowSelect(i),this.startDragWindowItem=this._getWindowItem(i),this.emit(nr.dragstart,i,e,r)}));t.$playerContainerEvents.push(i)}if(this._opt.supportMousemoveEvent){const i=e(r,"mousemove",(e=>{const t=Da(r,"uuid"),i=this._findWindowItemIndexByUuid(t);this.emit(nr.mousemove,i,e)}));t.$playerContainerEvents.push(i)}}))}_getContainerRect(){const e=this.$container.getBoundingClientRect();return{width:parseInt(e.width),height:parseInt(e.height)}}_updateWindows(){const e=this._getContainerRect(),t=e.width,i=e.height,r=this._opt.split,s=t%r,a=i%r,n=(t-s-2*r)/r,o=(i-a-2*r)/r,l=(t-s)/r,d=(i-a)/r;let h=this._getCurrentMaxSplit();for(let e=0;e<h;e++){const t=this.windowList[e];t.isContainerFullscreen=!1;const i=t.$playerContainer;i.style.position="relative",i.style.left="auto",i.style.top="auto",i.style.zIndex="auto";const h=t.$playerBorder,c=t.$player,u=n+(e%r==r-1?s:0),p=o+(e+r>=Math.pow(r,2)?a:0),f=l+(e%r==r-1?s:0),y=d+(e+r>=Math.pow(r,2)?a:0);i.style.width=f+"px",i.style.height=y+"px",i.style.display="block",c.style.width=u+"px",c.style.height=p+"px",c.style.display="block",h.style.width=u+"px",h.style.height=p+"px",h.style.display="block",t.player&&t.player.resize()}if(this.specialLayoutType){const e=this.windowList[0],t=e.$playerContainer,i=e.$player,r=e.$playerBorder,s=t.style.width.replace("px",""),a=t.style.height.replace("px",""),n=i.style.width.replace("px",""),o=i.style.height.replace("px","");let l,d,c,u;this.specialLayoutType===or?(l=2*s,d=2*a,c=2*n+2,u=2*o+2):this.specialLayoutType===lr&&(l=3*s,d=3*a,c=3*n+4,u=3*o+4),t.style.width=l+"px",t.style.height=d+"px",i.style.width=c+"px",i.style.height=u+"px",r.style.width=c+"px",r.style.height=u+"px",e.player&&e.player.resize(),h=this._getSpecialMaxSplit()}for(let e=h;e<this.maxWindowSize;e++){const t=this.windowList[e];t.player&&(t.player.destroy(),t.player=null),t.$playerContainer.style.display="none",t.$playerContainer.style.width="0",t.$playerContainer.style.height="0",t.$player.style.display="none",t.$playerBorder.style.display="none"}if(1===this._opt.split){this.windowList[0].$playerBorder.style.display="none"}}_updateWindows$2(){const e=this._opt.split;let t=this._getCurrentMaxSplit();if(this.$multiContainer){const t="easyplayer-multi-layout-6",i="easyplayer-multi-layout-9";this.$multiContainer.classList.remove(t,i),this.specialLayoutType===or?this.$multiContainer.classList.add(t):this.specialLayoutType===lr&&this.$multiContainer.classList.add(i),this.$multiContainer.style.setProperty("--split",`${e}`)}this._sortWindows();for(let e=t;e<this.maxWindowSize;e++){const t=this.windowList[e];t&&t.player&&(t.player.destroy(),t.player=null)}if(1===this._opt.split){this.windowList[0].$playerBorder.style.display="none"}this.windowList.forEach((e=>{e.$playerContainer.draggable=this._opt.split>1}))}_sortWindows(){const e=[];for(let t=0;t<this.maxWindowSize;t++){const i=this.windowList[t];e[i.$playerContainer.style.order]=i}this.windowList=e}_handleWindowSelect(e){const t=this._getWindowItem(e);t?(this.currentWindowIndex=this._findWindowItemIndex(t),this.currentWindowUuid=t.uuid,this.windowList.length>1&&(this.windowList.forEach((e=>{t.$playerBorder.style.display="block",e.$playerBorder.style.border=`1px solid ${this._opt.style.border}`})),this._opt.showSelectedBorder&&(t.$playerBorder.style.border=`1px solid ${this._opt.style.borderSelect}`))):this.debug.warn(this.LOG_TAG,`_handleWindowSelect() ${e} is not exist`),1===this._opt.split&&(t.$playerBorder.style.display="none")}_handleWindowContainerFullscreen(e,t){const i=this._getWindowItem(e);if(i){if(js(t)&&t===i.isContainerFullscreen)return;if(this._opt.draggable)i.isContainerFullscreen?(i.$playerContainer.setAttribute("fullscreen","0"),i.$playerContainer.style.fullscreen="0"):(i.$playerContainer.setAttribute("fullscreen","1"),i.$playerContainer.style.fullscreen="1");else if(i.isContainerFullscreen)i.$playerContainer.style.position="relative",i.$playerContainer.style.left="auto",i.$playerContainer.style.top="auto",i.$playerContainer.style.zIndex="auto",i.$playerContainer.style.width=i.prevInfo.playerContainerWidth,i.$playerContainer.style.height=i.prevInfo.playerContainerHeight,i.$player.style.width=i.prevInfo.playerWidth,i.$player.style.height=i.prevInfo.playerHeight,this.getSelectedWindowUuid()===i.uuid&&(i.$playerBorder.style.display="block");else{const e=this._getContainerRect(),t=e.width,r=e.height;i.prevInfo={playerContainerWidth:i.$playerContainer.style.width,playerContainerHeight:i.$playerContainer.style.height,playerWidth:i.$player.style.width,playerHeight:i.$player.style.height},i.$playerContainer.style.position="absolute",i.$playerContainer.style.top="0",i.$playerContainer.style.left="0",i.$playerContainer.style.zIndex="10",i.$playerContainer.style.width=t+"px",i.$playerContainer.style.height=r+"px",i.$player.style.width=t+"px",i.$player.style.height=r+"px",i.$playerBorder.style.display="none"}i.isContainerFullscreen=!i.isContainerFullscreen,i.player&&i.player.resize()}else this.debug.warn(this.LOG_TAG,`handleWindowContainerFullscreen() ${e} is not exist`)}_handleFullscreenResize(e=5){let t=this._getContainerRect(),i=0;const r=setInterval((()=>{const s=es.isFullscreen,a=this._getContainerRect(),n={width:screen.width,height:screen.height};this.debug.log(this.LOG_TAG,`isInFullscreen ${s} , checkRectInterval times : ${i} nowRect:${JSON.stringify(a)}, prevRect:${JSON.stringify(t)} ,window screen rect:${JSON.stringify(n)}`);const o=a.width===t.width&&a.height===t.height,l=!s||n.width-a.width<10&&n.height-a.height<10;if(o&&l||i>=e)return this.resize(),void clearInterval(r);t=a,i++}),1e3)}_listenFullscreenChange(){try{const e=e=>{la(e)===this.$container&&(this.emit(nr.multiFullscreen,es.isFullscreen),es.isFullscreen||-1!==window.navigator.userAgent.indexOf("Edg")?this._handleFullscreenResize():this.resize())};es.on("change",e),this.events.destroys.push((()=>{es.off("change",e)}))}catch(e){}}play(e,t,i){return new Promise(((r,s)=>{(Ns(t)||aa(t))&&(i=t,t={});const a=this._getWindowItem(i);if(a)if(a.player)a.player.play(e,t).then((()=>{r()})).catch((e=>{s(e)}));else{const i=this._createPlayer(a);a.player=i,i.play(e,t).then((()=>{r()})).catch((e=>{s(e)}))}else s(`play() windowIndex ${selectedWindowIndex} is not exist`)}))}getOption(e){const t=this._getWindowItem(e);return t&&t.player?t.player.getOption():(this.debug.warn(this.LOG_TAG,`getOption() windowIndex ${e} is not exist`),{})}setDebug(e,t){const i=this._getWindowItem(t);i&&i.player?i.player.setDebug(e):this.debug.warn(this.LOG_TAG,`setDebug() windowIndex ${t} is not exist`)}mute(e){const t=this._getWindowItem(e);t&&t.player?t.player.mute():this.debug.warn(this.LOG_TAG,`mute() windowIndex ${e} is not exist`)}cancelMute(e){const t=this._getWindowItem(e);t&&t.player?t.player.cancelMute():this.debug.warn(this.LOG_TAG,`cancelMute() windowIndex ${e} is not exist`)}setVolume(e,t){const i=this._getWindowItem(t);i&&i.player?i.player.setVolume(e):this.debug.warn(this.LOG_TAG,`setVolume() windowIndex ${t} is not exist`)}audioResume(e){const t=this._getWindowItem(e);t&&t.player?t.player.audioResume():this.debug.warn(this.LOG_TAG,`audioResume() windowIndex ${e} is not exist`)}setTimeout(e,t){const i=this._getWindowItem(t);i&&i.player?i.player.setTimeout(e):this.debug.warn(this.LOG_TAG,`setTimeout() windowIndex ${t} is not exist`)}setScaleMode(e,t){const i=this._getWindowItem(t);i&&i.player?i.player.setScaleMode(e):this.debug.warn(this.LOG_TAG,`setScaleMode() windowIndex ${t} is not exist`)}pause(e=!1,t){return new Promise(((i,r)=>{const s=this._getWindowItem(t);s&&s.player?s.player.pause(e).then((()=>{i()})).catch((e=>{r(e)})):r(`pause() windowIndex ${t} is not exist`)}))}close(e){return new Promise(((t,i)=>{const r=this._getWindowItem(e);r&&r.player?r.player.close().then((()=>{t()})).catch((e=>{i(e)})):i(`close() windowIndex ${e} is not exist`)}))}clearView(e){const t=this._getWindowItem(e);t&&t.player?t.player.clearView():this.debug.warn(this.LOG_TAG,`clearView() windowIndex ${e} is not exist`)}setStreamQuality(e,t){const i=this._getWindowItem(t);i&&i.player?i.player.setStreamQuality(e):this.debug.warn(this.LOG_TAG,`setStreamQuality() windowIndex ${t} is not exist`)}resize(){this._opt.draggable?this._updateWindows$2():this._updateWindows()}setBufferTime(e,t){const i=this._getWindowItem(t);i&&i.player?i.player.setBufferTime(e):this.debug.warn(this.LOG_TAG,`setBufferTime() windowIndex ${t} is not exist`)}setBufferDelayTime(e,t){const i=this._getWindowItem(t);i&&i.player?i.player.setBufferDelayTime(e):this.debug.warn(this.LOG_TAG,`setBufferDelayTime() windowIndex ${t} is not exist`)}setRotate(e,t){const i=this._getWindowItem(t);i&&i.player?i.player.setRotate(e):this.debug.warn(this.LOG_TAG,`setRotate() windowIndex ${t} is not exist`)}setMirrorRotate(e,t){const i=this._getWindowItem(t);i&&i.player?i.player.setMirrorRotate(e):this.debug.warn(this.LOG_TAG,`setMirrorRotate() windowIndex ${t} is not exist`)}updateIsEmitSEI(e,t){const i=this._getWindowItem(t);i&&i.player?i.player.updateIsEmitSEI(e):this.debug.warn(this.LOG_TAG,`updateIsEmitSEI() windowIndex ${t} is not exist`)}setAspectRatio(e,t){const i=this._getWindowItem(t);i&&i.player?i.player.setAspectRatio(e):this.debug.warn(this.LOG_TAG,`setAspectRatio() windowIndex ${t} is not exist`)}hasLoaded(e){const t=this._getWindowItem(e);return!(!t||!t.player)&&t.player.hasLoaded()}setKeepScreenOn(e){const t=this._getWindowItem(e);t&&t.player?t.player.setKeepScreenOn():this.debug.warn(this.LOG_TAG,`setKeepScreenOn() windowIndex ${e} is not exist`)}setFullscreen(e,t){const i=this._getWindowItem(t);i&&i.player?i.player.setFullscreen(e):this.debug.warn(this.LOG_TAG,`setFullscreen() windowIndex ${t} is not exist`)}screenshot(e,t){const i=this._getWindowItem(t);return i&&i.player?i.player.screenshot(e.filename,e.format,e.quality,e.type):null}screenshotWatermark(e,t){const i=this._getWindowItem(t);return i&&i.player?i.player.screenshotWatermark(e):null}startRecord(e,t,i){return new Promise(((r,s)=>{const a=this._getWindowItem(i);a&&a.player?a.player.startRecord(e,t).then((()=>{r()})).catch((e=>{s(e)})):(this.debug.warn(this.LOG_TAG,`startRecord() windowIndex ${i} is not exist`),s(`windowIndex ${i} is not exist`))}))}stopRecordAndSave(e,t,i){return new Promise(((r,s)=>{const a=this._getWindowItem(i);a&&a.player?a.player.stopRecordAndSave(e,t).then((e=>{r(e)})).catch((e=>{s(e)})):(this.debug.warn(this.LOG_TAG,`stopRecordAndSave() windowIndex ${i} is not exist`),s(`windowIndex ${i} is not exist`))}))}isPlaying(e){const t=this._getWindowItem(e);return t&&t.player?t.player.isPlaying():(this.debug.warn(this.LOG_TAG,`isPlaying() windowIndex ${e} is not exist`),!1)}isLoading(e){const t=this._getWindowItem(e);return t&&t.player?t.player.isLoading():(this.debug.warn(this.LOG_TAG,`isLoading() windowIndex ${e} is not exist`),!1)}isPaused(e){const t=this._getWindowItem(e);return t&&t.player?t.player.isPaused():(this.debug.warn(this.LOG_TAG,`windowIndex ${e} is not exist`),!1)}isMute(e){const t=this._getWindowItem(e);return t&&t.player?t.player.isMute():(this.debug.warn(this.LOG_TAG,`isMute() windowIndex ${e} is not exist`),!1)}isRecording(e){const t=this._getWindowItem(e);return t&&t.player?t.player.isRecording():(this.debug.warn(this.LOG_TAG,`isRecording() windowIndex ${e} is not exist`),!1)}clearBufferDelay(e){const t=this._getWindowItem(e);t&&t.player?t.player.clearBufferDelay():this.debug.warn(this.LOG_TAG,`clearBufferDelay() windowIndex ${e} is not exist`)}setNetworkDelayTime(e,t){const i=this._getWindowItem(t);i&&i.player?i.player.setNetworkDelayTime(e):this.debug.warn(this.LOG_TAG,`setNetworkDelayTime() windowIndex ${t} is not exist`)}getDecodeType(e){const t=this._getWindowItem(e);return t&&t.player?t.player.getDecodeType():(this.debug.warn(this.LOG_TAG,`getDecodeType() windowIndex ${e} is not exist`),null)}getRenderType(e){const t=this._getWindowItem(e);return t&&t.player?t.player.getRenderType():(this.debug.warn(this.LOG_TAG,`windowIndex ${e} is not exist`),null)}getAudioEngineType(e){const t=this._getWindowItem(e);return t&&t.player?t.player.getAudioEngineType():(this.debug.warn(this.LOG_TAG,`windowIndex ${e} is not exist`),null)}getPlayingTimestamp(e){const t=this._getWindowItem(e);return t&&t.player?t.player.getPlayingTimestamp():(this.debug.warn(this.LOG_TAG,`windowIndex ${e} is not exist`),null)}getStatus(e){const t=this._getWindowItem(e);return t&&t.player?t.player.getStatus():(this.debug.warn(this.LOG_TAG,`getStatus() windowIndex ${e} is not exist`),null)}getPlayType(e){const t=this._getWindowItem(e);return t&&t.player?t.player.getPlayType():(this.debug.warn(this.LOG_TAG,`getPlayType() windowIndex ${e} is not exist`),null)}togglePerformancePanel(e,t){const i=this._getWindowItem(t);i&&i.player?i.player.togglePerformancePanel(e):this.debug.warn(this.LOG_TAG,`togglePerformancePanel() windowIndex ${t} is not exist`)}openZoom(e){const t=this._getWindowItem(e);t&&t.player?t.player.openZoom():this.debug.warn(this.LOG_TAG,`openZoom() windowIndex ${e} is not exist`)}closeZoom(e){const t=this._getWindowItem(e);t&&t.player?t.player.closeZoom():this.debug.warn(this.LOG_TAG,`closeZoom() windowIndex ${e} is not exist`)}isZoomOpen(e){const t=this._getWindowItem(e);return t&&t.player?t.player.isZoomOpen():(this.debug.warn(this.LOG_TAG,`isZoomOpen() windowIndex ${e} is not exist`),!1)}expandZoom(e){const t=this._getWindowItem(e);t&&t.player?t.player.expandZoom():this.debug.warn(this.LOG_TAG,`expandZoom() windowIndex ${e} is not exist`)}narrowZoom(e){const t=this._getWindowItem(e);t&&t.player?t.player.narrowZoom():this.debug.warn(this.LOG_TAG,`narrowZoom() windowIndex ${e} is not exist`)}getCurrentZoomIndex(e){const t=this._getWindowItem(e);return t&&t.player?t.player.getCurrentZoomIndex():(this.debug.warn(this.LOG_TAG,`getCurrentZoomIndex() windowIndex ${e} is not exist`),0)}setNakedFlowFps(e,t){const i=this._getWindowItem(t);i&&i.player?i.player.setNakedFlowFps(e):this.debug.warn(this.LOG_TAG,`setNakedFlowFps() windowIndex ${t} is not exist`)}updateDebugLevel(e,t){const i=this._getWindowItem(t);i&&i.player?i.player.updateDebugLevel(e):this.debug.warn(this.LOG_TAG,`updateDebugLevel() windowIndex ${t} is not exist`)}updateWatermark(e,t){const i=this._getWindowItem(t);i&&i.player?i.player.updateWatermark(e):this.debug.warn(this.LOG_TAG,`updateWatermark() windowIndex ${t} is not exist`)}removeWatermark(e){const t=this._getWindowItem(e);t&&t.player?t.player.removeWatermark():this.debug.warn(this.LOG_TAG,`removeWatermark() windowIndex ${e} is not exist`)}updateFullscreenWatermark(e,t){const i=this._getWindowItem(t);i&&i.player?i.player.updateFullscreenWatermark(e):this.debug.warn(this.LOG_TAG,`updateFullscreenWatermark() windowIndex ${t} is not exist`)}removeFullscreenWatermark(e){const t=this._getWindowItem(e);t&&t.player?t.player.removeFullscreenWatermark():this.debug.warn(this.LOG_TAG,`removeFullscreenWatermark() windowIndex ${e} is not exist`)}faceDetectOpen(e){const t=this._getWindowItem(e);t&&t.player?t.player.faceDetectOpen():this.debug.warn(this.LOG_TAG,`faceDetectOpen() windowIndex ${e} is not exist`)}faceDetectClose(e){const t=this._getWindowItem(e);t&&t.player?t.player.faceDetectClose():this.debug.warn(this.LOG_TAG,`faceDetectClose() windowIndex ${e} is not exist`)}objectDetectOpen(e){const t=this._getWindowItem(e);t&&t.player?t.player.objectDetectOpen():this.debug.warn(this.LOG_TAG,`objectDetectOpen() windowIndex ${e} is not exist`)}objectDetectClose(e){const t=this._getWindowItem(e);t&&t.player?t.player.objectDetectClose():this.debug.warn(this.LOG_TAG,`objectDetectClose() windowIndex ${e} is not exist`)}sendWebsocketMessage(e,t){const i=this._getWindowItem(t);i&&i.player?i.player.sendWebsocketMessage(e):this.debug.warn(this.LOG_TAG,`sendWebsocketMessage() windowIndex ${t} is not exist`)}addContentToCanvas(e,t){const i=this._getWindowItem(t);i&&i.player?i.player.addContentToCanvas(e):this.debug.warn(this.LOG_TAG,`addContentToCanvas() windowIndex ${t} is not exist`)}clearContentToCanvas(e){const t=this._getWindowItem(e);t&&t.player?t.player.clearContentToCanvas():this.debug.warn(this.LOG_TAG,`clearContentToCanvas() windowIndex ${e} is not exist`)}setControlHtml(e,t){const i=this._getWindowItem(t);i&&i.player?i.player.setControlHtml(e):this.debug.warn(this.LOG_TAG,`setControlHtml() windowIndex ${t} is not exist`)}clearControlHtml(e){const t=this._getWindowItem(e);t&&t.player?t.player.clearControlHtml():this.debug.warn(this.LOG_TAG,`clearControlHtml() windowIndex ${e} is not exist`)}getFlvMetaData(e){const t=this._getWindowItem(e);return t&&t.player?t.player.getFlvMetaData():(this.debug.warn(this.LOG_TAG,`getFlvMetaData() windowIndex ${e} is not exist`),null)}getExtendBtnList(e){const t=this._getWindowItem(e);return t&&t.player?t.player.getExtendBtnList():(this.debug.warn(this.LOG_TAG,`getExtendBtnList() windowIndex ${e} is not exist`),null)}updateAiFaceDetectInterval(e,t){const i=this._getWindowItem(t);if(!i||!i.player)return this.debug.warn(this.LOG_TAG,`updateAiFaceDetectInterval() windowIndex ${t} is not exist`),null;i.player.updateAiFaceDetectInterval(e)}updateAiFaceDetectLevel(e,t){const i=this._getWindowItem(t);if(!i||!i.player)return this.debug.warn(this.LOG_TAG,`updateAiFaceDetectLevel() windowIndex ${t} is not exist`),null;i.player.updateAiFaceDetectLevel(e)}updateAiObjectDetectInterval(e,t){const i=this._getWindowItem(t);if(!i||!i.player)return this.debug.warn(this.LOG_TAG,`updateAiObjectDetectInterval() windowIndex ${t} is not exist`),null;i.player.updateAiObjectDetectInterval(e)}updateAiObjectDetectLevel(e,t){const i=this._getWindowItem(t);if(!i||!i.player)return this.debug.warn(this.LOG_TAG,`updateAiObjectDetectLevel() windowIndex ${t} is not exist`),null;i.player.updateAiObjectDetectLevel(e)}setCryptoKeyUrl(e,t){const i=this._getWindowItem(t);if(!i||!i.player)return this.debug.warn(this.LOG_TAG,`setCryptoKeyUrl() windowIndex ${t} is not exist`),null;i.player.setCryptoKeyUrl(e)}showErrorMessageTips(e,t){const i=this._getWindowItem(t);if(!i||!i.player)return this.debug.warn(this.LOG_TAG,`showErrorMessageTips() windowIndex ${t} is not exist`),null;i.player.showErrorMessageTips(e)}hideErrorMessageTips(e){const t=this._getWindowItem(e);if(!t||!t.player)return this.debug.warn(this.LOG_TAG,`hideErrorMessageTips() windowIndex ${e} is not exist`),null;t.player.hideErrorMessageTips()}destroySingle(e){return new Promise(((t,i)=>{const r=this._getWindowItem(e);r?r.player&&r.player.destroy().then((()=>{r.player=null,t()})).catch((e=>{i(e)})):(i("windowIndex is not exist"),this.debug.warn(this.LOG_TAG,`destroySingle() windowIndex ${e} is not exist`))}))}initSingle(e){return new Promise(((t,i)=>{const r=this._getWindowItem(e);if(r)if(r.player)r.player.destroy().then((()=>{r.player=null;const e=this._createPlayer(r);r.player=e,t()})).catch((e=>{i(e)}));else{const e=this._createPlayer(r);r.player=e,t()}else i("windowIndex is not exist"),this.debug.warn(this.LOG_TAG,`destroySingle() windowIndex ${e} is not exist`)}))}setFullscreenMulti(e){return new Promise(((t,i)=>{if(this.debug.log(this.LOG_TAG,"setFullscreenMulti",e),e)try{es.request(this.$container).then((()=>{t()})).catch((e=>{this.debug.error(this.LOG_TAG,"fullscreen request inner error",e),i(e)}))}catch(e){this.debug.error(this.LOG_TAG,"fullscreen request error",e),i(e)}else try{es.exit().then((()=>{t()})).catch((e=>{this.debug.error(this.LOG_TAG,"fullscreen exit inner error",e),i(e)}))}catch(e){this.debug.error(this.LOG_TAG,"fullscreen exit error",e),i(e)}}))}toggleSingleWindowContainerFullscreen(e,t){this.debug.log(this.LOG_TAG,"setSingleWindowContainerFullscreen",t);const i=this._getWindowItem(t);this.windowList.forEach((e=>{e.uuid!==i.uuid&&this._handleWindowContainerFullscreen(e.uuid,!1)})),this._handleWindowContainerFullscreen(i.uuid,e)}selectWindow(e){this.debug.log(this.LOG_TAG,"selectWindow",e),this._handleWindowSelect(e)}arrangeWindow(e){this.debug.log(this.LOG_TAG,"arrangeWindow",e),this._innerArrangeWindow(e)}_innerArrangeWindow(e,t=!1){if(!e)return void this.debug.warn(this.LOG_TAG,`arrangeWindow() split ${e} is not valid`);if([or,lr].includes(e))this._arrangeSpecialWindow(e);else{if(this._opt.split===e&&null===this.specialLayoutType&&ka(t))return void this.debug.warn(this.LOG_TAG,`arrangeWindow() split ${e} is not changed`);this.specialLayoutType=null,this._arrangeWindow(e)}}_arrangeWindow(e){(e=Ms(e))<1||!Ns(e)?this.debug.warn(this.LOG_TAG,`arrangeWindow() split ${e} is not valid`):(e>this._opt.maxSplit&&(e=this._opt.maxSplit),this._opt.split=e,this.currentWindowIndex=0,this._opt.draggable?this._updateWindows$2():this._updateWindows(),this._handleWindowSelect(this.currentWindowIndex))}_arrangeSpecialWindow(e){this._opt.maxSplit<=3&&e===lr||this._opt.maxSplit<=2&&e===or?this.debug.warn(this.LOG_TAG,`_arrangeSpecialWindow() type ${e} is not valid because maxSplit is ${this._opt.maxSplit}`):this.specialLayoutType&&this.specialLayoutType===e?this.debug.warn(this.LOG_TAG,`_arrangeSpecialWindow() type ${e} is not changed`):(this.specialLayoutType=e,e===or?this._arrangeWindow(3):e===lr?this._arrangeWindow(4):this.debug.warn(this.LOG_TAG,`_arrangeSpecialWindow() type ${e} is not valid`))}getCurrentSplit(){return this.specialLayoutType?this.specialLayoutType:this._opt.split}_getCurrentMaxSplit(){if(this.specialLayoutType){let e=0;return this.specialLayoutType===or?e=9:this.specialLayoutType===lr&&(e=16),e}return this._opt.split*this._opt.split}_getSpecialMaxSplit(){let e=0;return this.specialLayoutType===or?e=6:this.specialLayoutType===lr&&(e=8),e}getSelectedWindowIndex(){return this.currentWindowIndex}getSelectedWindowUuid(){return this.currentWindowUuid}getWindowItem(e){let t=this._getWindowItem(e),i=null;return t&&(i={index:e,$player:t.$player,$playerContainer:t.$playerContainer,player:t.player,uuid:t.uuid}),i}getNextWindowItem(e){let t=null,i=this._getWindowItem(e);if(i){const e=this._getWindowUuidList()||[],r=e.findIndex((e=>e===i.uuid));if(r<e.length-1){const i=r+1,s=this._findWindowItemByUuid(e[i]);s&&(t={index:i,$player:s.$player,$playerContainer:s.$playerContainer,player:s.player,uuid:s.uuid})}}return t}getPrevWindowItem(e){let t=null,i=this._getWindowItem(e);if(i){const e=this._getWindowUuidList()||[],r=e.findIndex((e=>e===i.uuid));if(r>0){const i=r-1,s=this._findWindowItemByUuid(e[i]);s&&(t={index:i,$player:s.$player,$playerContainer:s.$playerContainer,player:s.player,uuid:s.uuid})}}return t}isWindowItemHasInitPlayer(e){let t=!1,i=this._getWindowItem(e);return i&&i.player&&(t=!0),t}_getWindowItem(e){let t=null;const i=aa(e)&&16===e.length;return t=i||!Ns(e)?this._findWindowItemByUuid(i?e:this.currentWindowUuid):this.windowList[e],t}_getWindowUuidList(){return this.windowList.filter(((e,t)=>t<this._getCurrentMaxSplit())).map((e=>e.uuid))}_findWindowItemIndex(e){return e&&e.uuid?this._findWindowItemIndexByUuid(e.uuid):null}_findWindowItemIndexByUuid(e){return this.windowList.findIndex((t=>t.uuid===e))}_findWindowItemByUuid(e){return this.windowList.find((t=>t.uuid===e))}}su.MULTI_EVENTS=nr,su.EVENTS={...at,...nr},su.ERROR=lt,window.EasyPlayerProMulti=su,window.WebPlayerProMulti=su}));