web-player-pro-multi.js 1.4 MB

1
  1. !function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";class t{on(e,t,i){const s=this.e||(this.e={});return(s[e]||(s[e]=[])).push({fn:t,ctx:i}),this}once(e,t,i){const s=this;function r(){s.off(e,r);for(var a=arguments.length,o=new Array(a),n=0;n<a;n++)o[n]=arguments[n];t.apply(i,o)}return r._=t,this.on(e,r,i)}emit(e){const t=((this.e||(this.e={}))[e]||[]).slice();for(var i=arguments.length,s=new Array(i>1?i-1:0),r=1;r<i;r++)s[r-1]=arguments[r];for(let e=0;e<t.length;e+=1)t[e].fn.apply(t[e].ctx,s);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 s=i[e],r=[];if(s&&t)for(let e=0,i=s.length;e<i;e+=1)s[e].fn!==t&&s[e].fn._!==t&&r.push(s[e]);return r.length?i[e]=r:delete i[e],this}}const i=1,s=2,r=3,a=4,o=5,n=6,l=["","websocket","fetch","hls","webrtc","webTransport","aliyunRtc"],h="fetch",d="hls",c="websocket",u="webrtc",p="webTransport",f="worker",m="aliyunRtc",g="player",y="playerAudio",A="playbackTF",b="mp4",v="webm",_="flv",w="mov",S="flv",T="m7s",E="hls",k="webrtc",C="webTransport",x="nakedFlow",R="fmp4",D="mpeg4",L="aliyunRtc",I={flv:"FLV",m7s:"m7s",hls:"HLS",fmp4:"FMP4",mpeg4:"MPEG4",webrtc:"Webrtc",webTransport:"WebTransport",nakedFlow:"裸流",aliyunRtc:"aliyunRtc"},P="mse",B="wcs",M="offscreen",F="wasm",U="simd",O="mt",N="webrtc",j="hls",G="aliyunRtc",z="canvas",$="video",W="debug",H="warn",V="click",J="mouseDownAndUp",K={normal:"normal",simple:"simple"},q=36e5,Y="/crypto/",Q="jbprov",X=1e4,Z={url:"",playbackConfig:{},fullscreenWatermarkConfig:{},playType:g,playbackForwardMaxRateDecodeIFrame:4,playOptions:{},isLive:!0,isMulti:!0,isM7sCrypto:!1,supportHls265:!1,playFailedUseLastFrameShow:!0,playFailedAndPausedShowMessage:!1,pauseAndNextPlayUseLastFrameShow:!1},ee={playType:g,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:!1,isNakedFlow:!1,isMpeg4:!1,isAliyunRtc:!1,debug:!1,debugLevel:H,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:!1,loadingBackground:"",loadingBackgroundWidth:0,loadingBackgroundHeight:0,decoder:"decoder-pro.js",decoderAudio:"decoder-pro-audio.js",decoderHard:"decoder-pro-hard.js",wasmMp4RecorderDecoder:"jessibuca-pro-mp4-recorder-decoder.js",decoderWASM:"",isDecoderUseCDN:!1,url:"",rotate:0,mirrorRotate:"none",aspectRatio:"default",playbackConfig:{playList:[],fps:"",showControl:!0,controlType:K.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:s,demuxType:S,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:F,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:b,checkFirstIFrame:!0,nakedFlowFps:25,audioEngine:null,isShowRecordingUI:!0,isShowZoomingUI:!0,useFaceDetector:!1,useObjectDetector:!1,useImageDetector:!1,useOcclusionDetector:!1,ptzClickType:V,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:!1,isEmitSEI:!1,pauseAndNextPlayUseLastFrameShow:!1,demuxUseWorker:!0,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",hlsV2Mp4NotSupport:"Hls解码器不支持解码",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:$,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},te="init",ie="initVideo",se="render",re="playAudio",ae="initAudio",oe="audioCode",ne="audioNalu",le="audioAACSequenceHeader",he="videoCode",de="videoCodec",ce="videoNalu",ue="videoPayload",pe="audioPayload",fe="wasmError",me="workerFetch",ge="iframeIntervalTs",ye="isDropping",Ae="workerEnd",be="playbackStreamVideoFps",ve="wasmDecodeVideoNoResponseError",_e="wasmWidthOrHeightChange",we="simdDecodeError",Se="simdH264DecodeVideoWidthIsTooLarge",Te="closeEnd",Ee="tempStream",ke="videoSEI",Ce="flvScriptData",xe="aacSequenceHeader",Re="videoSequenceHeader",De="flvBufferData",Le="checkFirstIFrame",Ie="Invalid NAL unit size",Pe=1,Be=2,Me=8,Fe=9,Ue=18,Oe="init",Ne="decode",je="audioDecode",Ge="videoDecode",ze="close",$e="updateConfig",We="clearBuffer",He="fetchStream",Ve="sendWsMessage",Je="fetch",Ke="destroy",qe="buffer",Ye="fetchError",Qe="fetchClose",Xe="fetchSuccess",Ze={fullscreen:"fullscreen$2",webFullscreen:"webFullscreen",decoderWorkerInit:"decoderWorkerInit",play:"play",playing:"playing",pause:"pause",mute:"mute",load:"load",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",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",flvMetaData:"flvMetaData",talkFailedAndStop:"talkFailedAndStop",removeLoadingBgImage:"removeLoadingBgImage",memoryLog:"memoryLog",downloadMemoryLog:"downloadMemoryLog",pressureObserverCpu:"pressureObserverCpu",currentPts:"currentPts"},et={load:Ze.load,timeUpdate:Ze.timeUpdate,videoInfo:Ze.videoInfo,audioInfo:Ze.audioInfo,error:Ze.error,kBps:Ze.kBps,start:Ze.start,timeout:Ze.timeout,loadingTimeout:Ze.loadingTimeout,loadingTimeoutRetryEnd:Ze.loadingTimeoutRetryEnd,delayTimeout:Ze.delayTimeout,delayTimeoutRetryEnd:Ze.delayTimeoutRetryEnd,fullscreen:"fullscreen",multiFullscreen:"multiFullscreen",webFullscreen:Ze.webFullscreen,play:Ze.play,pause:Ze.pause,mute:Ze.mute,stats:Ze.stats,performance:Ze.performance,recordingTimestamp:Ze.recordingTimestamp,recordStart:Ze.recordStart,recordCreateError:Ze.recordCreateError,recordEnd:Ze.recordEnd,recordBlob:Ze.recordBlob,playToRenderTimes:Ze.playToRenderTimes,playbackSeek:Ze.playbackSeek,playbackStats:Ze.playbackStats,playbackTimestamp:Ze.playbackTimestamp,playbackPauseOrResume:Ze.playbackPauseOrResume,playbackPreRateChange:Ze.playbackPreRateChange,playbackRateChange:Ze.playbackRateChange,playbackShowPrecisionChange:Ze.playbackShowPrecisionChange,ptz:Ze.ptz,streamQualityChange:Ze.streamQualityChange,zooming:Ze.zooming,crashLog:Ze.crashLog,focus:Ze.focus,blur:Ze.blur,visibilityHiddenTimeout:Ze.visibilityHiddenTimeout,visibilityChange:Ze.visibilityChange,websocketOpen:Ze.websocketOpen,websocketClose:Ze.websocketClose,networkDelayTimeout:Ze.networkDelayTimeout,aiObjectDetectorInfo:Ze.aiObjectDetectorInfo,aiFaceDetectorInfo:Ze.aiFaceDetectorInfo,aiOcclusionDetectResult:Ze.aiOcclusionDetectResult,aiImageDetectResult:Ze.aiImageDetectResult,playFailedAndPaused:Ze.playFailedAndPaused,streamEnd:Ze.streamEnd,audioResumeState:Ze.audioResumeState,videoSEI:Ze.videoSEI,flvMetaData:Ze.flvMetaData,webrtcOnConnectionStateChange:Ze.webrtcOnConnectionStateChange,webrtcOnIceConnectionStateChange:Ze.webrtcOnIceConnectionStateChange,currentPts:Ze.currentPts,videoSmooth:Ze.videoSmooth},tt={talkStreamClose:Ze.talkStreamClose,talkStreamError:Ze.talkStreamError,talkStreamInactive:Ze.talkStreamInactive,talkGetUserMediaTimeout:Ze.talkGetUserMediaTimeout,talkFailedAndStop:Ze.talkFailedAndStop},it={playError:"playIsNotPauseOrUrlIsNull",fetchError:"fetchError",websocketError:"websocketError",webcodecsH265NotSupport:"webcodecsH265NotSupport",webcodecsDecodeError:"webcodecsDecodeError",webcodecsUnsupportedConfigurationError:"webcodecsUnsupportedConfigurationError",webcodecsDecodeConfigureError:"webcodecsDecodeConfigureError",mediaSourceH265NotSupport:"mediaSourceH265NotSupport",mediaSourceAudioG711NotSupport:"mediaSourceAudioG711NotSupport",mediaSourceAudioInitTimeout:"mediaSourceAudioInitTimeout",mediaSourceDecoderConfigurationError:"mediaSourceDecoderConfigurationError",mediaSourceFull:Ze.mseSourceBufferFull,mseSourceBufferError:Ze.mseSourceBufferError,mseAddSourceBufferError:Ze.mseAddSourceBufferError,mediaSourceAppendBufferError:"mediaSourceAppendBufferError",mediaSourceTsIsMaxDiff:"mediaSourceTsIsMaxDiff",mediaSourceUseCanvasRenderPlayFailed:"mediaSourceUseCanvasRenderPlayFailed",mediaSourceBufferedIsZeroError:"mediaSourceBufferedIsZeroError",wasmDecodeError:"wasmDecodeError",wasmUseVideoRenderError:"wasmUseVideoRenderError",hlsError:"hlsError",hlsV2Mp4NotSupport:"hlsV2Mp4NotSupport",webrtcError:"webrtcError",webrtcClosed:Ze.webrtcClosed,webrtcIceCandidateError:"webrtcIceCandidateError",webglAlignmentError:"webglAlignmentError",wasmWidthOrHeightChange:"wasmWidthOrHeightChange",mseWidthOrHeightChange:"mseWidthOrHeightChange",wcsWidthOrHeightChange:"wcsWidthOrHeightChange",widthOrHeightChange:"widthOrHeightChange",tallWebsocketClosedByError:"tallWebsocketClosedByError",flvDemuxBufferSizeTooLarge:Ze.flvDemuxBufferSizeTooLarge,wasmDecodeVideoNoResponseError:"wasmDecodeVideoNoResponseError",audioChannelError:"audioChannelError",simdH264DecodeVideoWidthIsTooLarge:"simdH264DecodeVideoWidthIsTooLarge",simdDecodeError:"simdDecodeError",webglContextLostError:"webglContextLostError",videoElementPlayingFailed:"videoElementPlayingFailed",videoElementPlayingFailedForWebrtc:"videoElementPlayingFailedForWebrtc",decoderWorkerInitError:"decoderWorkerInitError",videoInfoError:"videoInfoError",videoCodecIdError:"videoCodecIdError",streamEnd:Ze.streamEnd,delayTimeout:Ze.delayTimeout,loadingTimeout:Ze.loadingTimeout,networkDelayTimeout:Ze.networkDelayTimeout,aliyunRtcError:"aliyunRtcError",...{talkStreamError:Ze.talkStreamError,talkStreamClose:Ze.talkStreamClose}},st="notConnect",rt="open",at="close",ot="error",nt={download:"download",base64:"base64",blob:"blob"},lt="download",ht="blob",dt={7:"H264(AVC)",12:"H265(HEVC)",99:"MPEG4"},ct=7,ut=12,pt="H264(AVC)",ft="H265(HEVC)",mt=10,gt=7,yt=8,At=2,bt={AAC:"AAC",ALAW:"ALAW(g711a)",MULAW:"MULAW(g711u)",MP3:"MP3"},vt={10:"AAC",7:"ALAW",8:"MULAW",2:"MP3"},_t=7,wt=8,St=5,Tt=6,Et=19,kt=20,Ct=32,xt=33,Rt=34,Dt=39,Lt=39,It=40,Pt=38,Bt=48,Mt=0,Ft=1,Ut=2,Ot="webcodecs",Nt="webgl",jt="webgl2",Gt="webgpu",zt="offscreen",$t="mse",Wt="hls",Ht="webrtc",Vt="key",Jt="delta",Kt='video/mp4; codecs="avc1.64002A"',qt='video/mp4; codecs="hev1.1.6.L123.b0"',Yt="ended",Qt="open",Xt="closed",Zt=27,ei=38,ti=40,ii="oneHour",si="halfHour",ri="tenMin",ai="fiveMin",oi={oneHour:"one-hour",halfHour:"half-hour",tenMin:"ten-min",fiveMin:"five-min"},ni=["oneHour","halfHour","tenMin","fiveMin"],li=["up","right","down","left","left-up","right-up","left-down","right-down"],hi="stop",di="fiStop",ci="zoomExpand",ui="zoomNarrow",pi="apertureFar",fi="apertureNear",mi="focusFar",gi="focusNear",yi="g711a",Ai="g711u",bi="pcm",vi="opus",_i={png:"image/png",jpeg:"image/jpeg",webp:"image/webp"},wi="sourceclose",Si="sourceopen",Ti="sourceended",Ei="canplay",ki="waiting",Ci="timeupdate",xi="ratechange",Ri="hevc",Di="A key frame is required after configure() or flush()",Li="Cannot call 'decode' on a closed codec",Ii="Unsupported configuration",Pi="Decoder failure",Bi="Decoding error",Mi="Decoder error",Fi="HEVC decoding is not supported",Ui="loading",Oi="playing",Ni="paused",ji="destroy",Gi=0,zi=1,$i=8,Wi=0,Hi=98,Vi="empty",Ji="rtp",Ki="tcp",qi="open",Yi="close",Qi="error",Xi="message",Zi="worklet",es="script",ts={encType:yi,packetType:Ji,packetTcpSendType:Ki,rtpSsrc:"0000000000",numberChannels:1,sampleRate:8e3,sampleBitsWidth:16,sendInterval:20,debug:!1,debugLevel:H,testMicrophone:!1,saveRtpToFile:!1,audioBufferLength:160,engine:Zi,checkGetUserMediaTimeout:!1,getUserMediaTimeout:1e4,audioConstraints:{latency:!0,noiseSuppression:!0,autoGainControl:!0,echoCancellation:!0,sampleRate:48e3,channelCount:1}},is="worklet",ss="script",rs="active",as={name:"",index:0,icon:"",iconHover:"",iconTitle:"",activeIcon:"",activeIconHover:"",activeIconTitle:"",click:null,activeClick:null},os={content:"",click:null,index:0},ns={container:"",maxSplit:4,split:1,draggable:!1,showSelectedBorder:!0,supportDblclickContainerFullscreen:!1,style:{border:"#343434",borderSelect:"#FFCC00",background:"#000"}},ls={multiFullscreen:"multiFullscreen",dblSelected:"multiDblSelected",selected:"multiSelected",mouseover:"multiMouseover",mouseout:"multiMouseout",mouseup:"multiMouseup",dragstart:"multiDragstart",dragenter:"multiDragenter",dragleave:"multiDragleave",drop:"multiDrop"},hs="3-1",ds="4-1",cs=1,us="subtitle-segments",ps="hls-manifest-loaded",fs="hls-level-loaded",ms="demuxed-track",gs="flv-script-data",ys="metadata-parsed",As="ttfb",bs="load-retry",vs="load-start",_s="speed",ws="load-complete",Ss="load-response-headers",Ts="sei",Es="sei-in-time",ks="switch-url-failed",Cs="switch-url-success",xs="subtitle-playlist",Rs="stream-parsed",Ds="error",Ls=[0,160,240,320,480,640],Is=[0,160,240,320,480,640],Ps=["轻松","正常","较高","高"],Bs={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"},Ms=1,Fs=2,Us=0,Os=1,Ns=3,js=16;class Gs{constructor(e){this.log=function(t){if(e._opt.debug&&e._opt.debugLevel==W){const a=e._opt.debugUuid?`[${e._opt.debugUuid}]`:"";for(var i=arguments.length,s=new Array(i>1?i-1:0),r=1;r<i;r++)s[r-1]=arguments[r];console.log(`JbPro${a}[✅✅✅][${t}]`,...s)}},this.warn=function(t){if(e._opt.debug&&(e._opt.debugLevel==W||e._opt.debugLevel==H)){const a=e._opt.debugUuid?`[${e._opt.debugUuid}]`:"";for(var i=arguments.length,s=new Array(i>1?i-1:0),r=1;r<i;r++)s[r-1]=arguments[r];console.log(`JbPro${a}[❗❗❗][${t}]`,...s)}},this.error=function(t){const i=e._opt.debugUuid?`[${e._opt.debugUuid}]`:"";for(var s=arguments.length,r=new Array(s>1?s-1:0),a=1;a<s;a++)r[a-1]=arguments[a];console.error(`JbPro${i}[❌❌❌][${t}]`,...r)}}}var zs="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function $s(e,t){return e(t={exports:{}},t.exports),t.exports}var Ws=$s((function(e){!function(){var t="undefined"!=typeof window&&void 0!==window.document?window.document:{},i=e.exports,s=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"]],s=0,r=i.length,a={};s<r;s++)if((e=i[s])&&e[1]in t){for(s=0;s<e.length;s++)a[i[0][s]]=e[s];return a}return!1}(),r={change:s.fullscreenchange,error:s.fullscreenerror},a={request:function(e,i){return new Promise(function(r,a){var o=function(){this.off("change",o),r()}.bind(this);this.on("change",o);var n=(e=e||t.documentElement)[s.requestFullscreen](i);n instanceof Promise&&n.then(o).catch(a)}.bind(this))},exit:function(){return new Promise(function(e,i){if(this.isFullscreen){var r=function(){this.off("change",r),e()}.bind(this);this.on("change",r);var a=t[s.exitFullscreen]();a instanceof Promise&&a.then(r).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 s=r[e];s&&t.addEventListener(s,i,!1)},off:function(e,i){var s=r[e];s&&t.removeEventListener(s,i,!1)},raw:s};s?(Object.defineProperties(a,{isFullscreen:{get:function(){return Boolean(t[s.fullscreenElement])}},element:{enumerable:!0,get:function(){return t[s.fullscreenElement]}},isEnabled:{enumerable:!0,get:function(){return Boolean(t[s.fullscreenEnabled])}}}),i?e.exports=a:window.screenfull=a):i?e.exports={isEnabled:!1}:window.screenfull={isEnabled:!1}}()}));function Hs(e){let{profile:t,sampleRate:i,channel:s}=e;return new Uint8Array([175,0,t<<3|(14&i)>>1,(1&i)<<7|s<<3])}function Vs(e){return Js(e)&&e[1]===Gi}function Js(e){return e[0]>>4===mt}Ws.isEnabled;const Ks=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],qs=Ks;function Ys(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 Qs(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4;return 1024*t/e}const Xs=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];class Zs{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,s=this.read(e);return this.bufpos=t,this.bufoff=i,s}read_golomb(){let e;for(e=0;0==this.read(1)&&!this.iserro;e++);return(1<<e)+this.read(e)-1}}function er(e){let t=e.read(5);return 31===t&&(t=e.read(6)+32),t}function tr(e,t){return t.sampling_index=e.read(4),15==t.sampling_index?e.read(24):ir[t.sampling_index]}const ir=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350,0,0,0],sr=[0,1,2,3,4,5,6,8];function rr(){}function ar(e){let t=null;const i=["webgl","experimental-webgl","moz-webgl","webkit-3d"];let s=0;for(;!t&&s<i.length;){const r=i[s];try{let i={preserveDrawingBuffer:!0};t=e.getContext(r,i)}catch(e){console.error(e),t=null}t&&"function"==typeof t.getParameter||(t=null),++s}return t}function or(e){let t=null;return t=e.getContext("webgl2"),t}function nr(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const t=e.split(","),i=atob(t[1]),s=t[0].replace("data:","").replace(";base64","");let r=i.length,a=new Uint8Array(r);for(;r--;)a[r]=i.charCodeAt(r);return new File([a],"file",{type:s})}function lr(){return(new Date).getTime()}function hr(e,t,i){return Math.max(Math.min(e,Math.max(t,i)),Math.min(t,i))}function dr(e,t,i){if(e)return"object"==typeof t&&Object.keys(t).forEach((i=>{dr(e,i,t[i])})),e.style[t]=i,e}function cr(e,t){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!e)return 0;const s=getComputedStyle(e,null).getPropertyValue(t);return i?parseFloat(s):s}function ur(){return performance&&"function"==typeof performance.now?performance.now():Date.now()}function pr(e){let t=0,i=ur();return s=>{if(!xr(s))return;t+=s;const r=ur(),a=r-i;a>=1e3&&(e(t/a*1e3),i=r,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 fr='"1-4-2024"';function mr(){return/iphone|ipod|android.*mobile|windows.*phone|blackberry.*mobile/i.test(window.navigator.userAgent.toLowerCase())}function gr(){return!(mr()||/ipad|android(?!.*mobile)|tablet|kindle|silk/i.test(window.navigator.userAgent.toLowerCase()))}function yr(){const e=window.navigator.userAgent.toLowerCase();return/android/i.test(e)}function Ar(){const e=window.navigator.userAgent.toLowerCase();return/firefox/i.test(e)}function br(){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 s in i)if(i[s]){let i="";if("IE"===s){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"===s){for(let e in navigator.mimeTypes)"application/360softmgrplugin"===navigator.mimeTypes[e].type&&(s="360");const t=e.match(/chrome\/([\d.]+)/);t&&t.length>1&&(i=t[1])}else if("Firefox"===s){const t=e.match(/firefox\/([\d.]+)/);t&&t.length>1&&(i=t[1])}else if("Opera"===s){const t=e.match(/opera\/([\d.]+)/);t&&t.length>1&&(i=t[1])}else if("Safari"===s){const t=e.match(/version\/([\d.]+)/);t&&t.length>1&&(i=t[1])}else if("Edge"===s){const t=e.match(/edge\/([\d.]+)/);t&&t.length>1&&(i=t[1])}else if("QQBrowser"===s){const t=e.match(/qqbrowser\/([\d.]+)/);t&&t.length>1&&(i=t[1])}t.type=s,t.version=parseInt(i)}return t}function vr(){const e=window.navigator.userAgent.toLowerCase();return e&&/iphone|ipad|ipod|ios/.test(e)}function _r(){const e=window.navigator.userAgent;return!e.match(/Chrome/gi)&&!!e.match(/Safari/gi)}function wr(e,t){if(0===arguments.length)return null;var i,s=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 r={y:i.getFullYear(),m:i.getMonth()+1,d:i.getDate(),h:i.getHours(),i:i.getMinutes(),s:i.getSeconds(),a:i.getDay()},a=s.replace(/{(y|m|d|h|i|s|a)+}/g,((e,t)=>{var i=r[t];return"a"===t?["一","二","三","四","五","六","日"][i-1]:(e.length>0&&i<10&&(i="0"+i),i||0)}));return a}function Sr(){return"VideoFrame"in window}function Tr(e){if("string"!=typeof e)return e;var t=Number(e);return isNaN(t)?e:t}function Er(){return"xxxxxxxxxxxx4xxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))}function kr(e,t){let i,s,r=!1;return function a(){for(var o=arguments.length,n=new Array(o),l=0;l<o;l++)n[l]=arguments[l];if(r)return i=n,void(s=this);r=!0,e.apply(this,n),setTimeout((()=>{r=!1,i&&(a.apply(s,i),i=null,s=null)}),t)}}function Cr(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 s=parseFloat(e);i=Math.floor(Math.log(s)/Math.log(1024));var r=s/Math.pow(1024,i);return(r=r.toFixed(2))+t[i]}function xr(e){return"[object Number]"===Object.prototype.toString.call(e)}function Rr(){let e=!1;return"MediaSource"in window&&window.MediaSource.isTypeSupported(qt)&&(e=!0),e}function Dr(){const e=br();return"chrome"===e.type.toLowerCase()&&e.version>=107}function Lr(){let e=!1;return"MediaStreamTrackGenerator"in window&&(e=!0),e}function Ir(){let e=!1;return"MediaStream"in window&&(e=!0),e}function Pr(e,t){let i=window.URL.createObjectURL(t),s=window.document.createElement("a");s.download=e,s.href=i;let r=window.document.createEvent("MouseEvents");r.initEvent("click",!0,!0),s.dispatchEvent(r),setTimeout((()=>{window.URL.revokeObjectURL(i)}),vr()?1e3:0)}function Br(e){return null==e}function Mr(e){return!0===e||!1===e}function Fr(e){return!Br(e)}function Ur(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||{}),s=Object.assign(t.text,e.text||{}),r=Object.assign(t.rect,e.rect||{}),a=Object.assign(t.line,e.line||{});return t=Object.assign(t,e,{image:i,text:s,rect:r,line:a}),t}function Or(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 Nr(e,t){return new Promise(((i,s)=>{let r=Ur(t);if(!r.image.src&&!r.text.content)return i(e);let a=document.createElement("canvas");a.width=t.width,a.height=t.height;let o=a.getContext("2d"),n=0,l=0;xr(r.left)?n=r.left:xr(r.right)&&(n=a.width-r.right),xr(r.top)?l=r.top:xr(r.bottom)&&(l=a.height-r.bottom);const h=new Image;h.src=e,h.onload=()=>{if(o.drawImage(h,0,0),r.image&&r.image.src){const e=new Image;e.src=r.image.src,e.setAttribute("crossOrigin","Anonymous"),e.onload=()=>{n-=r.image.width,o.drawImage(e,n,l,r.image.width,r.image.height),i(a.toDataURL(t.format,t.quality))},e.onerror=e=>{s()}}else r.text&&r.text.content&&(o.font=r.text.fontSize+"px 宋体",o.fillStyle=r.text.color,o.textAlign="right",o.fillText(r.text.content,n,l),i(a.toDataURL(t.format,t.quality)))},h.onerror=e=>{s(e)}}))}function jr(e){var t;if(e>-1){var i=Math.floor(e/3600),s=Math.floor(e/60)%60,r=e%60;t=i<10?"0"+i+":":i+":",s<10&&(t+="0"),t+=s+":",(r=Math.round(r))<10&&(t+="0"),t+=r.toFixed(0)}return t}function Gr(e,t){let i="";if(e>-1){const s=Math.floor(e/60)%60;let r=e%60;r=Math.round(r),i=s<10?"0"+s+":":s+":",r<10&&(i+="0"),i+=r,Br(t)||(t<10&&(t="0"+t),i+=":"+t)}return i}function zr(e){let t="";if(e>-1){const i=Math.floor(e/60/60)%60;let s=Math.floor(e/60)%60,r=e%60;s=Math.round(s),t=i<10?"0"+i+":":i+":",s<10&&(t+="0"),t+=s+":",r<10&&(t+="0"),t+=r}return t}function $r(e,t){const i=Math.floor(t/60)%60,s=Math.floor(t%60);return new Date(e).setHours(i,s,0,0)}function Wr(e,t){const i=Math.floor(t/60/60)%60,s=Math.floor(t/60)%60,r=t%60;return new Date(e).setHours(i,s,r,0)}function Hr(e){return(""+e).length}function Vr(e){return!function(e){return e&&0===Object.keys(e).length}(e)}function Jr(e){return"string"==typeof e}const Kr=()=>{const e=window.navigator.userAgent;return/MicroMessenger/i.test(e)},qr=()=>{const e=window.navigator.userAgent;return/Chrome/i.test(e)};function Yr(e){const t=e||window.event;return t.target||t.srcElement}function Qr(){return Ar()&&function(){const e=navigator.userAgent.toLowerCase();return/macintosh|mac os x/i.test(e)}()}function Xr(e){return"function"==typeof e}function Zr(e){if(mr()){let t=0,i=0;if(1===e.touches.length){let s=e.touches[0];t=s.clientX,i=s.clientY}return{posX:t,posY:i}}let t=0,i=0;const s=e||window.event;return s.pageX||s.pageY?(t=s.pageX,i=s.pageY):(s.clientX||s.clientY)&&(t=e.clientX+document.documentElement.scrollLeft+document.body.scrollLeft,i=e.clientY+document.documentElement.scrollTop+document.body.scrollTop),{posX:t,posY:i}}function ea(){let e=document.createElement("video"),t=e.canPlayType("application/vnd.apple.mpegurl");return e=null,t}function ta(e){let t=fa(e.hasAudio)&&(e.useMSE||e.useWCS&&!e.useOffscreen)&&fa(e.demuxUseWorker);return!!(fa(t)&&e.useMSE&&e.mseDecodeAudio&&fa(e.demuxUseWorker))||t}function ia(e){const t=e.toString().trim().match(/^function\s*\w*\s*\([\w\s,]*\)\s*{([\w\W]*?)}$/)[1];const i=new Blob([t],{type:"application/javascript"});return URL.createObjectURL(i)}function sa(e){e.close()}function ra(){return"https:"===window.location.protocol||"localhost"===window.location.hostname}function aa(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 oa(e,t){t&&(e=e.filter((e=>e.type&&e.type===t)));let i=e[0],s=null,r=1;if(e.length>0){let t=e[1];t&&t.ts-i.ts>1e5&&(i=t,r=2)}if(i)for(let a=r;a<e.length;a++){let r=e[a];if(t&&r.type&&r.type!==t&&(r=null),r){if(r.ts-i.ts>=1e3){e[a-1].ts-i.ts<1e3&&(s=a+1)}}}return s}function na(e){for(var t=(e+"=".repeat((4-e.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),i=window.atob(t),s=new Uint8Array(i.length),r=0;r<i.length;++r)s[r]=i.charCodeAt(r);return s}function la(e){const t=/(msie|trident)/i.test(navigator.userAgent),i=document.createElement("a");let s=e;return t&&(i.setAttribute("href",s),s=i.href),i.setAttribute("href",s),{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 ha(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 da(){return ha(Z)}function ca(){return ha(ee)}function ua(e){return e[0]>>4===zi&&e[1]===Gi}function pa(e){return!0===e||"true"===e}function fa(e){return!0!==e&&"true"!==e}function ma(e,t,i){e&&(e.dataset?e.dataset[t]=i:e.setAttribute("data-"+t,i))}function ga(e,t){return e?e.dataset?e.dataset[t]:e.getAttribute("data-"+t):""}function ya(e){return e.replace(/-([a-z])/g,(function(e,t){return t.toUpperCase()}))}function Aa(){return/iphone/i.test(navigator.userAgent)}function ba(){return window.performance&&window.performance.memory?window.performance.memory:null}function va(){try{var e=document.createElement("canvas");return!(!window.WebGL2RenderingContext||!e.getContext("webgl2"))}catch(e){return!1}}function _a(e){return e.trim().match(/^function\s*\w*\s*\([\w\s,]*\)\s*{([\w\W]*?)}$/)[1]}function wa(){let e=!1;return"requestVideoFrameCallback"in HTMLVideoElement.prototype&&(e=!0),e}function Sa(){let e=!1;return"PressureObserver"in window&&(e=!0),e}class Ta{constructor(e){this.destroys=[],this.proxy=this.proxy.bind(this),this.master=e}proxy(e,t,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(!e)return;if(Array.isArray(t))return t.map((t=>this.proxy(e,t,i,s)));e.addEventListener(t,i,s);const r=()=>{Xr(e.removeEventListener)&&e.removeEventListener(t,i,s)};return this.destroys.push(r),r}destroy(){this.master.debug&&this.master.debug.log("Events","destroy"),this.destroys.forEach((e=>e())),this.destroys=[]}}var Ea=1e-6,ka="undefined"!=typeof Float32Array?Float32Array:Array;function Ca(){var e=new ka(16);return ka!=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 xa(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 Ra,Da=function(e,t,i,s,r,a,o){var n=1/(t-i),l=1/(s-r),h=1/(a-o);return e[0]=-2*n,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*h,e[11]=0,e[12]=(t+i)*n,e[13]=(r+s)*l,e[14]=(o+a)*h,e[15]=1,e};function La(e,t,i){var s=new ka(3);return s[0]=e,s[1]=t,s[2]=i,s}Ra=new ka(3),ka!=Float32Array&&(Ra[0]=0,Ra[1]=0,Ra[2]=0);class Ia{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,s=i.createShader(e);return i.shaderSource(s,t),i.compileShader(s),i.getShaderParameter(s,i.COMPILE_STATUS)?s:(console.log("An error occurred compiling the shaders: "+i.getShaderInfoLog(s)),i.deleteShader(s),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 s=[];s=s.concat([0,1],[1,1],[1,0],[0,0]);const r=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,r),e.bufferData(e.ARRAY_BUFFER,new Float32Array(s),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:r,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,s,r,a){let o=2*e/r-1,n=2*(a-t-s)/a-1,l=2*(e+i)/r-1,h=2*(a-t)/a-1;return[o,n,l,n,l,h,o,h]}_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,s,r){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,s),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,r),this._buffers.positions=[-1,-1,1,-1,1,1,-1,1],this._drawScene(e,t,!0)}renderYUV(e,t,i){let s=i.slice(0,e*t),r=i.slice(e*t,e*t*5/4),a=i.slice(e*t*5/4,e*t*3/2);const o=this.gl;this._clear(),o.activeTexture(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,this._ytexture),o.texImage2D(o.TEXTURE_2D,0,o.LUMINANCE,e,t,0,o.LUMINANCE,o.UNSIGNED_BYTE,s),o.activeTexture(o.TEXTURE1),o.bindTexture(o.TEXTURE_2D,this._utexture),o.texImage2D(o.TEXTURE_2D,0,o.LUMINANCE,e/2,t/2,0,o.LUMINANCE,o.UNSIGNED_BYTE,r),o.activeTexture(o.TEXTURE2),o.bindTexture(o.TEXTURE_2D,this._vtexture),o.texImage2D(o.TEXTURE_2D,0,o.LUMINANCE,e/2,t/2,0,o.LUMINANCE,o.UNSIGNED_BYTE,a),this._buffers.positions=[-1,-1,1,-1,1,1,-1,1],this._drawScene(e,t,!0)}drawDom(e,t,i,s,r){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,r),this._buffers.positions=this._calRect(i,s,r.width,r.height,e,t),this._drawScene(e,t,!1)}}class Pa{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 s=new Float32Array([0,1,1,1,1,0,0,0]),r=e.createBuffer({size:s.byteLength,usage:window.GPUBufferUsage.VERTEX|window.GPUBufferUsage.COPY_DST});e.queue.writeBuffer(r,0,s);const a=new Uint16Array([0,1,2,0,2,3]),o=e.createBuffer({size:a.byteLength,usage:window.GPUBufferUsage.INDEX|window.GPUBufferUsage.COPY_DST});return e.queue.writeBuffer(o,0,a),{positionBuffer:i,texpositionBuffer:r,indexBuffer:o}}_initPipeline(){return new Promise(((e,t)=>{const i=this.gpu.device,s=this.gpu.format,r={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:s}]},depthStencil:{depthWriteEnabled:!0,depthCompare:"less",format:"depth24plus"}};i.createRenderPipelineAsync(r).then((t=>{e(t)})).catch((e=>{t(e)}))}))}_initMatrixGroupInfo(){const e=this.gpu.device,t=this.pipeline,i=Ca();Da(i,-1,1,-1,1,.1,100);const s=Ca();xa(s);const r=Ca();!function(e,t,i,s){var r,a,o,n,l,h,d,c,u,p,f=t[0],m=t[1],g=t[2],y=s[0],A=s[1],b=s[2],v=i[0],_=i[1],w=i[2];Math.abs(f-v)<Ea&&Math.abs(m-_)<Ea&&Math.abs(g-w)<Ea?xa(e):(d=f-v,c=m-_,u=g-w,r=A*(u*=p=1/Math.hypot(d,c,u))-b*(c*=p),a=b*(d*=p)-y*u,o=y*c-A*d,(p=Math.hypot(r,a,o))?(r*=p=1/p,a*=p,o*=p):(r=0,a=0,o=0),n=c*o-u*a,l=u*r-d*o,h=d*a-c*r,(p=Math.hypot(n,l,h))?(n*=p=1/p,l*=p,h*=p):(n=0,l=0,h=0),e[0]=r,e[1]=n,e[2]=d,e[3]=0,e[4]=a,e[5]=l,e[6]=c,e[7]=0,e[8]=o,e[9]=h,e[10]=u,e[11]=0,e[12]=-(r*f+a*m+o*g),e[13]=-(n*f+l*m+h*g),e[14]=-(d*f+c*m+u*g),e[15]=1)}(r,La(0,0,0),La(0,0,-1),La(0,1,0));const a=e.createBuffer({size:64,usage:window.GPUBufferUsage.UNIFORM|window.GPUBufferUsage.COPY_DST});e.queue.writeBuffer(a,0,s);const o=e.createBuffer({size:64,usage:window.GPUBufferUsage.UNIFORM|window.GPUBufferUsage.COPY_DST});e.queue.writeBuffer(o,0,r);const n=e.createBuffer({size:64,usage:window.GPUBufferUsage.UNIFORM|window.GPUBufferUsage.COPY_DST});e.queue.writeBuffer(n,0,i);return{modelMatrixBuffer:a,viewMatrixBuffer:o,projectMatrixBuffer:n,group:e.createBindGroup({label:"group0",layout:t.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:a}},{binding:1,resource:{buffer:o}},{binding:2,resource:{buffer:n}}]})}}_initTextureGroupInfo(e,t){const i=this.gpu.device,s=this.pipeline,r=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}),o=i.createTexture({size:[e/2,t/2],format:"r8unorm",usage:window.GPUTextureUsage.TEXTURE_BINDING|window.GPUTextureUsage.COPY_DST|window.GPUTextureUsage.RENDER_ATTACHMENT}),n=i.createSampler({magFilter:"linear",minFilter:"linear"}),l=i.createBindGroup({label:"group1",layout:s.getBindGroupLayout(1),entries:[{binding:0,resource:n},{binding:1,resource:r.createView()},{binding:2,resource:a.createView()},{binding:3,resource:o.createView()}]});return{yTexture:r,uTexture:a,vTexture:o,group:l}}_drawScene(){const e=this.gpu.device,t=this.gpu.context,i=e.createCommandEncoder(),s={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"}},r=i.beginRenderPass(s);r.setPipeline(this.pipeline),r.setBindGroup(0,this.matrixGroupInfo.group),r.setBindGroup(1,this.textureGroupInfo.group),r.setVertexBuffer(0,this.buffers.positionBuffer),r.setVertexBuffer(1,this.buffers.texpositionBuffer),r.setIndexBuffer(this.buffers.indexBuffer,"uint16"),r.drawIndexed(6),r.end(),e.queue.submit([i.finish()])}renderYUV(e,t,i){if(!this.hasInited)return;let s=i.slice(0,e*t),r=i.slice(e*t,e*t*5/4),a=i.slice(e*t*5/4,e*t*3/2);const o=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)),o.queue.writeTexture({texture:this.textureGroupInfo.yTexture},s,{bytesPerRow:e,rowsPerImage:t},[e,t]),o.queue.writeTexture({texture:this.textureGroupInfo.uTexture},r,{bytesPerRow:e/2,rowsPerImage:t/2},[e/2,t/2]),o.queue.writeTexture({texture:this.textureGroupInfo.vTexture},a,{bytesPerRow:e/2,rowsPerImage:t/2},[e/2,t/2]),this._drawScene()}clear(){}}class Ba{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||mr()?this.player.getRenderType()===z?this._resizeDomForCanvas():this.player.getRenderType()===$&&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 s=document.createElement("div");s.setAttribute("style","position: absolute; top: 0; left: 0; width: 0; height: 0;display: none;"),t.appendChild(s);const r=e.children,a=Math.floor(Math.random()*(r.length-1))+1;r[a]?e.insertBefore(i,r[a]):e.appendChild(i),this.shadowRootInnerDom=s,this.shadowRootRealDom=i,this.shadowRoot=t}update(e){this._removeDom();let t=[];Array.isArray(e)?t=e:Vr(e)&&t.push(e);let i=t.map((e=>Ur(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 s=i.width,r=i.height;const a=this.player._opt;let o=t,n=e;if(a.hasControl&&!a.controlAutoHide){const e=a.playType===A?Bt:Pt;mr()&&this.player.fullscreen&&a.useWebFullScreen?n-=e:o-=e}const l=a.rotate;let h=(n-s)/2,d=(o-r)/2;270!==l&&90!==l||(s=i.height,r=i.width);const c=n/s,u=o/r;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=h+"px",this.shadowRootInnerDom.style.top=d+"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,s=this.player.height;if(t.hasControl&&!t.controlAutoHide){const e=t.playType===A?Bt:Pt;mr()&&this.player.fullscreen&&t.useWebFullScreen?i-=e:s-=e}let r=e.width,a=e.height;const o=t.rotate;let n=(i-r)/2,l=(s-a)/2;270!==o&&90!==o||(r=e.height,a=e.width);const h=i/r,d=s/a;let c=h>d?d:h;t.isResize||h!==d&&(c=h+","+d),t.isFullResize&&(c=h>d?h:d);let u="scale("+c+")";"none"===t.mirrorRotate&&o&&(u+=" rotate("+o+"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=n+"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,s=this.player.height;const r=this.player._opt;let a=0;r.hasControl&&!r.controlAutoHide&&(a=r.playType===A?Bt:Pt,s-=a);const o=e.width/e.height,n=t[0]/t[1];if(o>n){const t=n*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/n/e.height;this.shadowRootInnerDom.style.width="100%",this.shadowRootInnerDom.style.height=`calc(${100*t}% - ${a}px)`,this.shadowRootInnerDom.style.padding=(s-s*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,xr(e.left)&&(t.style.left=e.left+"px"),xr(e.right)&&(t.style.right=e.right+"px"),xr(e.top)&&(t.style.top=e.top+"px"),xr(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 s=e.polygon.color,r=e.polygon.lineWidth;if(i=i.sort(((e,t)=>(e.index||0)-(t.index||0))),e.polygon.fill){const s=document.createElement("div");s.style.position="absolute",s.style.width="100%",s.style.height="100%";const r="polygon("+i.map((e=>`${e.x}px ${e.y}px`)).join(", ")+")";s.style.clipPath=r,s.style.backgroundColor=e.polygon.fill,e.polygon.fillOpacity&&(s.style.opacity=e.polygon.fillOpacity),t.appendChild(s)}i.forEach(((e,a)=>{const o=document.createElement("div");if(a===i.length-1){const a=i[0],n={x1:e.x,y1:e.y,x2:a.x,y2:a.y,color:s,lineWidth:r};return this.settingLine(o,n),void t.appendChild(o)}const n=i[a+1],l={x1:e.x,y1:e.y,x2:n.x,y2:n.y,color:s,lineWidth:r};this.settingLine(o,l),t.appendChild(o)}))}this.isDynamic&&(this.shadowRootDynamicDom=t),this.shadowRootInnerDom.appendChild(t)}}))}settingLine(e,t){const i=t.x1,s=t.y1,r=t.x2,a=t.y2;var o=Math.sqrt((i-r)**2+(s-a)**2),n=180*Math.atan2(a-s,r-i)/Math.PI;e.style.backgroundColor=t.color,e.style.width=o+"px",e.style.height=t.lineWidth+"px",e.style.position="absolute",e.style.top=s+"px",e.style.left=i+"px",e.style.transform="rotate("+n+"deg)",e.style.transformOrigin="0 0"}remove(){this._removeDom()}_removeDom(){this.shadowRootInnerDom&&(this.shadowRootInnerDom.innerHTML="")}}class Ma 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,this.isDestroyed=!1}destroy(){this.isDestroyed=!0,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){Fr(e.encTypeCode)&&(this.videoInfo.encType=dt[e.encTypeCode],this.videoInfo.encTypeCode=e.encTypeCode),Fr(e.encType)&&(this.videoInfo.encType=e.encType),Fr(e.width)&&(this.videoInfo.width=e.width),Fr(e.height)&&(this.videoInfo.height=e.height),Fr(this.videoInfo.encType)&&Fr(this.videoInfo.height)&&Fr(this.videoInfo.width)&&!this.init&&(this.player.emit(Ze.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||mr()?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 s=this.player._opt;let r=0;s.hasControl&&!s.controlAutoHide&&(r=s.playType===A?Bt:Pt,i-=r);const a=this.videoInfo,o=a.width/a.height,n=e[0]/e[1];if(this.getType()===z&&(this.$videoElement.style.left="0",this.$videoElement.style.top="0",this.$videoElement.style.transform="none"),this.getType()===$&&this.player._opt.videoRenderSupportScale&&(this.$videoElement.style.objectFit="fill"),o>n){const e=n*a.height/a.width;this.$videoElement.style.width=100*e+"%",this.$videoElement.style.height=`calc(100% - ${r}px)`,this.$videoElement.style.padding=`0 ${(t-t*e)/2}px`}else{const e=a.width/n/a.height;this.$videoElement.style.width="100%",this.$videoElement.style.height=`calc(${100*e}% - ${r}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(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.tempContentList=e}addAiContentToCanvas(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.tempAiContentList=e}doAddContentToWatermark(){if(this.tempContentList.length>0){this.contentWatermark||(this.contentWatermark=new Ba(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 Ba(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 Fa="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof global&&global.global===global?global:void 0;function Ua(e,t,i){var s=new XMLHttpRequest;s.open("GET",e),s.responseType="blob",s.onload=function(){Ga(s.response,t,i)},s.onerror=function(){console.error("could not download file")},s.send()}function Oa(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return t.status>=200&&t.status<=299}function Na(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 ja=Fa.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),Ga="object"!=typeof window||window!==Fa?function(){}:"download"in HTMLAnchorElement.prototype&&!ja?function(e,t,i){var s=Fa.URL||Fa.webkitURL,r=document.createElementNS("http://www.w3.org/1999/xhtml","a");t=t||e.name||"download",r.download=t,r.rel="noopener","string"==typeof e?(r.href=e,r.origin!==location.origin?Oa(r.href)?Ua(e,t,i):Na(r,r.target="_blank"):Na(r)):(r.href=s.createObjectURL(e),setTimeout((function(){s.revokeObjectURL(r.href)}),4e4),setTimeout((function(){Na(r)}),0))}:"msSaveOrOpenBlob"in navigator?function(e,t,i){if(t=t||e.name||"download","string"==typeof e)if(Oa(e))Ua(e,t,i);else{var s=document.createElement("a");s.href=e,s.target="_blank",setTimeout((function(){Na(s)}))}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,s){if((s=s||open("","_blank"))&&(s.document.title=s.document.body.innerText="downloading..."),"string"==typeof e)return Ua(e,t,i);var r="application/octet-stream"===e.type,a=/constructor/i.test(Fa.HTMLElement)||Fa.safari,o=/CriOS\/[\d]+/.test(navigator.userAgent);if((o||r&&a||ja)&&"undefined"!=typeof FileReader){var n=new FileReader;n.onloadend=function(){var e=n.result;e=o?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),s?s.location.href=e:location=e,s=null},n.readAsDataURL(e)}else{var l=Fa.URL||Fa.webkitURL,h=l.createObjectURL(e);s?s.location=h:location.href=h,s=null,setTimeout((function(){l.revokeObjectURL(h)}),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 s=t.createShader(t.FRAGMENT_SHADER);if(t.shaderSource(s,"\n varying highp vec2 uv;\n uniform sampler2D texture;\n void main(void) {\n gl_FragColor = texture2D(texture, uv);\n }\n "),t.compileShader(s),!t.getShaderParameter(s,t.COMPILE_STATUS))throw t.getShaderInfoLog(s);const r=t.createProgram();if(t.attachShader(r,i),t.attachShader(r,s),t.linkProgram(r),!t.getProgramParameter(r,t.LINK_STATUS))throw t.getProgramInfoLog(r);t.useProgram(r);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 o=t.getAttribLocation(r,"xy");t.vertexAttribPointer(o,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(o);const n=t.createTexture();t.bindTexture(t.TEXTURE_2D,n),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=r,this.buffer=a,this.vertexShader=i,this.fragmentShader=s,this.texture=n}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 $a extends Ma{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(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.context2D=this.$videoElement.getContext("2d",e)}_initContextGl(){this.player.events,this.contextGl=ar(this.$videoElement),this.contextGl?(this._bindContextGlEvents(),this.webglRender=new Ia(this.contextGl,this.player._opt.openWebglAlignment)):this.player.debug.error("CommonCanvasLoader","_initContextGl() createContextGL error")}_initContextGl2(){if(this.contextGl=or(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(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]: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=ar(this.$videoElement):2===e&&(this.contextGl=or(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 Ia(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(it.webglContextLostError))}else this.player.debug.error("CommonCanvasLoader","webglcontextlost error, getContextAttributes().stencil is false"),this.player.emitError(it.webglContextLostError)}),500)})),s=t(this.$videoElement,"webglcontextrestored",(e=>{e.preventDefault(),this.player.debug.log("CommonCanvasLoader","webglcontextrestored ",e)}));this.proxyDestroyList.push(i,s)}_initContextGPU(){var t;(t=this.$videoElement,new Promise(((e,i)=>{navigator.gpu?navigator.gpu.requestAdapter().then((s=>{s?s.requestDevice().then((r=>{if(r){const a=t.getContext("webgpu");if(a){const t=navigator.gpu.getPreferredCanvasFormat();a.configure({device:r,format:t,alphaMode:"opaque"}),e({adapter:s,device:r,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 Pa(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=Nt,this._initContextGl())})).catch((e=>{this.player.debug.warn("CommonCanvasLoader",`createWebGPUContext error is ${e} and next use webgl render`),this.renderType=Nt,this._initContextGl()}))}initCanvasViewSize(){this.$videoElement.width=this.videoInfo.width,this.$videoElement.height=this.videoInfo.height,this.resize()}screenshot(e,t,i,s){e=e||lr(),s=s||nt.download;let r=.92;!_i[t]&&nt[t]&&(s=t,t="png",i=void 0),"string"==typeof i&&(s=i,i=void 0),void 0!==i&&(r=Number(i));const a=_i[t]||_i.png,o=this.$videoElement.toDataURL(a,r);if(s===nt.base64)return o;{const t=nr(o);if(s===nt.blob)return t;if(s===nt.download){const i=a.split("/")[1];Ga(t,e+"."+i)}}}screenshotWatermark(e){return new Promise(((t,i)=>{Jr(e)&&(e={filename:e}),(e=e||{}).width=this.videoInfo.width,e.height=this.videoInfo.height,e.filename=e.filename||lr(),e.format=e.format?_i[e.format]:_i.png,e.quality=Number(e.quality)||.92,e.type=e.type||nt.download;const s=this.$videoElement.toDataURL(e.format,e.quality);Nr(s,e).then((i=>{if(e.type===nt.base64)t(s);else{const s=nr(i);if(e.type===nt.blob)t(s);else if(e.type===nt.download){t();const i=e.format.split("/")[1];Ga(s,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 s=this.controlHeight;mr()&&this.player.fullscreen&&e.useWebFullScreen?t-=s:i-=s}let s=this.$videoElement.width,r=this.$videoElement.height;const a=e.rotate;let o=(t-s)/2,n=(i-r)/2;270!==a&&90!==a||(s=this.$videoElement.height,r=this.$videoElement.width);const l=t/s,h=i/r;let d=l>h?h:l;fa(e.isResize)&&l!==h&&(d=l+","+h),e.isFullResize&&(d=l>h?l:h);let c="scale("+d+")";"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=o+"px",this.$videoElement.style.top=n+"px"}initFps(){}setStreamFps(e){}getStreamFps(){return 25}getType(){return z}getCanvasType(){let e=this.renderType===Gt?Gt:Nt;return this.isWcsWebgl2&&(e=jt),e}}class Wa extends $a{constructor(e){super(e),this.yuvList=[],this.controlHeight=Pt,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=Ot,va()&&this.player._opt.wcsUseWebgl2Render?(this._initContextGl2(),this.webglRender&&(this.isWcsWebgl2=!0)):this._initContext2D()):this.player._opt.useMSE&&this.player._opt.mseUseCanvasRender?(this.renderType=$t,this._initContext2D()):this.player.isOldHls()&&this.player._opt.useCanvasRender?(this.renderType=Wt,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=Nt,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!==$t){const t={ts:e.ts||0,fps:!0};this.player.updateStats(t)}switch(this.renderType){case zt:this.bitmaprenderer.transferFromImageBitmap(e.buffer);break;case Nt: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=lr());const i=lr();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=lr());const i=lr();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=lr());const t=lr();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(Ze.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(Ze.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===Nt)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 Ot:if(this.webglRender)this.webglRender.render(e.videoFrame),sa(e.videoFrame);else if(this.context2D)if(Xr(e.videoFrame.createImageBitmap))try{e.videoFrame.createImageBitmap().then((t=>{this.context2D.drawImage(t,0,0,this.$videoElement.width,this.$videoElement.height),sa(e.videoFrame)}))}catch(e){}else this.context2D.drawImage(e.videoFrame,0,0,this.$videoElement.width,this.$videoElement.height),sa(e.videoFrame);else this.player.debug.warn("CanvasVideoLoader","doRender() and webcodecs context is lost");break;case $t:case Wt:case Ht:this.context2D.drawImage(e.$video,0,0,this.$videoElement.width,this.$videoElement.height)}let t=e.ts||0;this.renderType===$t&&(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 s=window.createImageBitmap(i,0,0,e,t);return i.width=0,i.height=0,s})(this.$videoElement.width,this.$videoElement.height).then((e=>{this.bitmaprenderer.transferFromImageBitmap(e)}));break;case Nt:this.contextGl.clear(this.contextGl.COLOR_BUFFER_BIT);break;case Gt:this.webGPURender.clear();break;case Ot: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 $t:case Wt: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(e){let{ctx:t,list:i}=e;t.save(),(i||[]).forEach((e=>{"text"===e.type?(t.font=`${e.fontSize||12}px Arial`,t.fillStyle=e.color||"green",t.fillText(e.text,e.x,e.y)):"rect"===e.type&&(t.strokeStyle=e.color||"green",t.lineWidth=e.lineWidth||2,t.strokeRect(e.x,e.y,e.width,e.height))})),t.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 r=e.width,a=e.height,o=(s=e.color||"#008000",[parseInt(s.substring(1,3),16)/255,parseInt(s.substring(3,5),16)/255,parseInt(s.substring(5,7),16)/255,1]),n=e.lineWidth||4;if(!r||!a)return;this.webglRectRender.drawBox({x:t,y:i,width:r,height:a,lineColor:o,lineWidth:n,canvasWidth:this.$videoElement.width,canvasHeight:this.$videoElement.height})}else if("text"===e.type){const s=e.text||"";if(!s)return;const r=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=`${r}px Arial`,this.tempTextCanvasCtx.fillStyle=a,this.tempTextCanvasCtx.textBaseline="top",this.tempTextCanvasCtx.fillText(s,0,0),this.webglRender.drawDom(this.$videoElement.width,this.$videoElement.height,t,i,this.tempTextCanvas)}var s}))}}class Ha extends Ma{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()&&Lr()&&Ir()&&(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 s=wa();this.supportVideoFrameCallbackHandle=null;const{proxy:r}=this.player.events,a=r(this.$videoElement,"canplay",(()=>{this.player.debug.log("Video","canplay"),this._delayPlay&&(this.clearCheckVideoCanplayTimeout(),this._play())})),o=r(this.$videoElement,"waiting",(()=>{this.player.debug.log("Video","waiting")})),n=r(this.$videoElement,"loadedmetadata",(()=>{this.player.debug.log("Video","loadedmetadata")})),l=r(this.$videoElement,"timeupdate",(t=>{if(fa(s)){const i=parseInt(1e3*t.timeStamp,10);(e.isWebrtcH264()||this.player.isOldHls()||this.player.isAliyunRtc())&&(this.player.emit(Ze.timeUpdate,i),e.handleRender(),e.updateStats({fps:!0,ts:i,dts:i}))}})),h=r(this.$videoElement,"error",(()=>{this.player.debug.error("Video","Error Code "+this.$videoElement.error.code+" "+Bs[this.$videoElement.error.code]+"; Details: "+this.$videoElement.error.message),this.player.isHlsCanVideoPlay()}));this.eventListenList.push(a,o,l,h,n),wa()?this.supportVideoFrameCallbackHandle=this.$videoElement.requestVideoFrameCallback(this.videoFrameCallback.bind(this)):this.player.debug.warn("Video","not support requestVideoFrameCallback and use timeupdate event to update stats"),this.player.debug.log("Video","init")}destroy(){if(super.destroy(),this.clearCheckVideoCanplayTimeout(),this.supportVideoFrameCallbackHandle&&this.$videoElement&&(this.$videoElement.cancelVideoFrameCallback(this.supportVideoFrameCallbackHandle),this.supportVideoFrameCallbackHandle=null),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){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.isDestroyed)this.player.debug.log("Video","videoFrameCallback() and isDestroyed");else{if(this.player.isWebrtcH264()||this.player.isOldHls()||this.player.isAliyunRtc()){this.player.emit(Ze.timeUpdate,t.mediaTime),fa(this.getHasInit())&&t.width&&t.height&&this.updateVideoInfo({width:t.width,height:t.height,encTypeCode:ct}),this.player.handleRender();const e=parseInt(1e3*Math.max(t.mediaTime,this.getCurrentTime()),10)||0;this.player.updateStats({fps:!0,ts:e,dts:e}),this.player.updateCurrentPts(e),this.doAddContentToWatermark()}else if(pa(this.player._opt.useMSE)&&fa(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)}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=vr(),t=yr();(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=br().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(),fa(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(Ze.removeLoadingBgImage),this.isRetryPlayingTimes=0,this.isRetryPlaying=!1):setTimeout((()=>{this._replay()}),100)})).catch((e=>{this.player.debug.error("Video","_play error",e),this.isRetryPlaying=!1,setTimeout((()=>{this._replay()}),100)}))}_replay(){if(!this.isPlaying()&&fa(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(it.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(it.videoElementPlayingFailed)));this.player.debug.warn("Video",`_play then but not playing and retry play and isRetryPlayingTimes is ${this.isRetryPlayingTimes}`),this._play(),this.isRetryPlayingTimes++}}pause(e){this.isPlaying()&&(e?this.$videoElement&&this.$videoElement.pause():setTimeout((()=>{this.$videoElement&&this.$videoElement.pause()}),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,s){if(!this._canScreenshot())return this.player.debug.warn("Video","screenshot failed, video is not ready"),null;e=e||lr(),s=s||nt.download;let r=.92;!_i[t]&&nt[t]&&(s=t,t="png",i=void 0),"string"==typeof i&&(s=i,i=void 0),void 0!==i&&(r=Number(i));const a=this.$videoElement;let o=this.$canvasElement;o.width=a.videoWidth,o.height=a.videoHeight,this.canvasContext.drawImage(a,0,0,o.width,o.height);const n=_i[t]||_i.png,l=o.toDataURL(n,r);if(this.canvasContext.clearRect(0,0,o.width,o.height),o.width=0,o.height=0,s===nt.base64)return l;{const t=nr(l);if(s===nt.blob)return t;if(s===nt.download){const i=n.split("/")[1];Ga(t,e+"."+i)}}}screenshotWatermark(e){return new Promise(((t,i)=>{if(Jr(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 s=this.$videoElement;(e=e||{}).width=s.videoWidth,e.height=s.videoHeight,e.filename=e.filename||lr(),e.format=e.format?_i[e.format]:_i.png,e.quality=Number(e.quality)||.92,e.type=e.type||nt.download;let r=this.$canvasElement;r.width=s.videoWidth,r.height=s.videoHeight,this.canvasContext.drawImage(s,0,0,r.width,r.height);const a=r.toDataURL(e.format,e.quality);this.canvasContext.clearRect(0,0,r.width,r.height),r.width=0,r.height=0,Nr(a,e).then((i=>{if(e.type===nt.base64)t(a);else{const s=nr(i);if(e.type===nt.blob)t(s);else if(e.type===nt.download){t();const i=e.format.split("/")[1];Ga(s,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&&fa(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(it.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),sa(e.videoFrame);else if(e.output){let s=e.output;if(this.player.faceDetectActive&&this.player.ai&&this.player.ai.faceDetector){null===this.prevAiFaceDetectTime&&(this.prevAiFaceDetectTime=lr());const t=lr();t-this.prevAiFaceDetectTime>this.player._opt.aiFaceDetectInterval&&(s=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=lr());const t=lr();t-this.prevAiObjectDetectTime>this.player._opt.aiObjectDetectInterval&&(s=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=lr());const t=lr();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(Ze.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(Ze.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 r=(t=s,i={format:"I420",codedWidth:this.videoInfo.width,codedHeight:this.videoInfo.height,timestamp:e.ts},new VideoFrame(t,i));this.vwriter.write(r),sa(r)}catch(e){this.player.debug.error("Video","render error",e),this.player.emitError(it.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,s=i.rotate;if(i.hasControl&&!i.controlAutoHide){const s=i.playType===A?Bt:Pt;mr()&&this.player.fullscreen&&i.useWebFullScreen?e-=s:t-=s}this.$videoElement.width=e,this.$videoElement.height=t,this.$videoElement.style.width=e+"px",this.$videoElement.style.height=t+"px",270!==s&&90!==s||(this.$videoElement.width=t,this.$videoElement.height=e,this.$videoElement.style.width=t+"px",this.$videoElement.style.height=e+"px");let r=(e-this.$videoElement.width)/2,a=(t-this.$videoElement.height)/2,o="contain";fa(i.isResize)&&(o="fill"),i.isFullResize&&(o="none");let n="";"none"===i.mirrorRotate&&s&&(n+=" rotate("+s+"deg)"),"level"===i.mirrorRotate?n+=" rotateY(180deg)":"vertical"===i.mirrorRotate&&(n+=" rotateX(180deg)"),this.player._opt.videoRenderSupportScale&&(this.$videoElement.style.objectFit=o),this.$videoElement.style.transform=n,this.$videoElement.style.padding="0",this.$videoElement.style.left=r+"px",this.$videoElement.style.top=a+"px"}getType(){return $}getCurrentTime(){return this.$videoElement.currentTime}isPlaying(){return this.$videoElement&&fa(this.$videoElement.paused)&&fa(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(Xr(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:lr()};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)}_getBufferStore(){const e=this.$videoElement;let t=0;return e.buffered.length>0&&(t=e.buffered.start(0)),t}}class Va extends $a{constructor(e){super(e),this.controlHeight=Bt,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(Ze.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=Ot,va()&&this.player._opt.wcsUseWebgl2Render?(this._initContextGl2(),this.webglRender&&(this.isWcsWebgl2=!0)):this._initContext2D()):this.player._opt.useWebGPU?(this.renderType=Gt,this._initContextGPU()):(this.renderType=Nt,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),sa(e);else if(Xr(e.createImageBitmap))try{e.createImageBitmap().then((t=>{this.context2D.drawImage(t,0,0,this.$videoElement.width,this.$videoElement.height),sa(e)}))}catch(e){}else this.context2D.drawImage(e,0,0,this.$videoElement.width,this.$videoElement.height),sa(e);else if(this.getCanvasType()===Nt)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=hr(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=hr(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=oa(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&&sa(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 Ja{constructor(e){return new(Ja.getLoaderFactory(e._opt))(e)}static getLoaderFactory(e){return e.useMSE?e.mseUseCanvasRender?Wa:Ha:e.isHls&&fa(e.supportHls265)||e.isWebrtc&&fa(e.isWebrtcH265)?e.useCanvasRender?Wa:Ha:e.isAliyunRtc?Ha:e.useWCS?e.playType===A?Va:!e.useOffscreen&&e.wcsUseVideoRender?Ha:Wa:e.playType===A?Va:e.wasmUseVideoRender&&!e.useOffscreen?Ha:Wa}}class Ka 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=rr,this.scriptNode=null),this.workletProcessorNode&&(this.workletProcessorNode.port.onmessage=rr,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=vt[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(Ze.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){e?(this.isMute||this.player.emit(Ze.mute,e),this.setVolume(0),this.clear()):(this.isMute&&this.player.emit(Ze.mute,e),this.setVolume(this.player.lastVolume||.5))}setVolume(e){e=parseFloat(e).toFixed(2),isNaN(e)||(this.audioEnabled(!0),e=hr(e,0,1),this.gainNode.gain.value=e,this.player.emit(Ze.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(Ze.audioResumeState,{state:this.audioContextState,isRunning:this.isStateRunning()})})),this.audioResumeStateTimeout=setTimeout((()=>{this.clearAudioResumeStateTimeout(),this.isStateSuspended()&&this.player.emit(Ze.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 qa{constructor(e,t,i,s){this.player=e,this.audio=t,this.channel=i,this.bufferSize=s}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),s=0,r=0,a=0,o=e/this.bufferSize;const n=this.audio.bufferList;if(o&&n.length>=o){try{for(let e=0;e<o;e++){const e=n.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,r=e.ts}}catch(e){this.player.debug.warn("Processor","provide()",e),t=new Float32Array(0),i=new Float32Array(0)}s=t.length}return{size:s,ts:r,left:t,right:i}}destroy(){this.buffer=null,this.channel=null}}class Ya{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){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const s=2*(t=t||0);i>=0||(i=(e.length-s)/2);const r=2*i;this.ensureCapacity(i+this._frameCount);const a=this.endIndex;this.vector.set(e.subarray(s,s+r),a),this._frameCount+=i}putBuffer(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]: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){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const i=2*t,s=this.startIndex;e.set(this._vector.subarray(s,s+i)),this.receive(t)}extract(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const s=this.startIndex+2*t,r=2*i;e.set(this._vector.subarray(s,s+r))}ensureCapacity(){const e=parseInt(2*(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0));if(this._vector.length<e){const t=new Float32Array(e);t.set(this._vector.subarray(this.startIndex,this.endIndex)),this._vector=t,this._position=0}else this.rewind()}ensureAdditionalCapacity(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.ensureCapacity(this._frameCount+e)}rewind(){this._position>0&&(this._vector.set(this._vector.subarray(this.startIndex,this.endIndex)),this._position=0)}}class Qa{constructor(e){e?(this._inputBuffer=new Ya,this._outputBuffer=new Ya):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 Xa extends Qa{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 Xa;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(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(0===e)return 0;const t=this._inputBuffer.vector,i=this._inputBuffer.startIndex,s=this._outputBuffer.vector,r=this._outputBuffer.endIndex;let a=0,o=0;for(;this.slopeCount<1;)s[r+2*o]=(1-this.slopeCount)*this.prevSampleL+this.slopeCount*t[i],s[r+2*o+1]=(1-this.slopeCount)*this.prevSampleR+this.slopeCount*t[i+1],o+=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 n=i+2*a;s[r+2*o]=(1-this.slopeCount)*t[n]+this.slopeCount*t[n+2],s[r+2*o+1]=(1-this.slopeCount)*t[n+1]+this.slopeCount*t[n+3],o+=1,this.slopeCount+=this._rate}return this.prevSampleL=t[i+2*e-2],this.prevSampleR=t[i+2*e-1],o}}class Za{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(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]: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 eo=function(){};class to extends Za{constructor(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:eo;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(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]: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){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.fillOutputBuffer(this.outputBufferPosition+t);const i=Math.min(t,this.outputBuffer.frameCount-this.outputBufferPosition);this.outputBuffer.extract(e,this.outputBufferPosition,i);const s=this.outputBufferPosition+i;return this.outputBufferPosition=Math.min(this.historyBufferSize,s),this.outputBuffer.receive(Math.max(s-this.historyBufferSize,0)),this._position+=i,i}handleSampleData(e){this.extract(e.data,4096)}clear(){super.clear(),this.outputBufferPosition=0}}const io=[[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]],so=-10/1.5;class ro extends Qa{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,s){e>0&&(this.sampleRate=e),s>0&&(this.overlapMs=s),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(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;e=this.sampleRate*t/1e3,e=e<16?16:e,e-=e%8,this.overlapLength=e,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+so*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 ro;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,s=0;for(this.preCalculateCorrelationReferenceStereo(),e=0,t=Number.MIN_VALUE;s<this.seekLength;s+=1)i=this.calculateCrossCorrelationStereo(2*s,this.refMidBuffer),i>t&&(t=i,e=s);return e}seekBestOverlapPositionStereoQuick(){let e,t,i,s,r,a=0;for(this.preCalculateCorrelationReferenceStereo(),t=Number.MIN_VALUE,e=0,s=0,r=0;a<4;a+=1){let o=0;for(;io[a][o]&&(r=s+io[a][o],!(r>=this.seekLength));)i=this.calculateCrossCorrelationStereo(2*r,this.refMidBuffer),i>t&&(t=i,e=r),o+=1;s=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 s=0,r=2;const a=2*this.overlapLength;let o;for(;r<a;r+=2)o=r+e,s+=i[o]*t[r]+i[o+1]*t[r+1];return s}overlap(e){this.overlapStereo(2*e)}overlapStereo(e){const t=this._inputBuffer.vector;e+=this._inputBuffer.startIndex;const i=this._outputBuffer.vector,s=this._outputBuffer.endIndex;let r,a,o=0;const n=1/this.overlapLength;let l,h,d;for(;o<this.overlapLength;o+=1)a=(this.overlapLength-o)*n,l=o*n,r=2*o,h=r+e,d=r+s,i[d+0]=t[h+0]*l+this.midBuffer[r+0]*a,i[d+1]=t[h+1]*l+this.midBuffer[r+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 s=this._inputBuffer.startIndex+2*(e+this.seekWindowLength-this.overlapLength);this.midBuffer.set(this._inputBuffer.vector.subarray(s,s+2*this.overlapLength)),this.skipFract+=this.nominalSkip,i=Math.floor(this.skipFract),this.skipFract-=i,this._inputBuffer.receive(i)}}}const ao=function(e,t){return(e>t?e-t:t-e)>1e-10};class oo{constructor(){this.transposer=new Xa(!1),this.stretch=new ro(!1),this._inputBuffer=new Ya,this._intermediateBuffer=new Ya,this._outputBuffer=new Ya,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 oo;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,ao(this._tempo,e)&&(this.stretch.tempo=this._tempo),ao(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 no{constructor(e,t,i){this.player=e,this.audio=t,this.soundTouch=new oo,this.soundTouch.tempo=1,this.soundTouch.rate=1,this.filter=new to(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),s=new Float32Array(i),r=new Float32Array(i);for(let e=0;e<i;e++)s[e]=t[2*e],r[e]=t[2*e+1];return{size:i,left:s,right:r,ts:this.audio.tempAudioTimestamp||0}}destroy(){this.soundTouch&&(this.soundTouch.clear(),this.soundTouch=null),this.filter&&(this.filter=null)}}class lo extends Ka{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&&vr()&&(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=ss,this.player.debug.log("AudioContext","destroy")}isAudioPlaying(){return this.$audio&&fa(this.$audio.paused)&&fa(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||Kr()&&vr()))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===rs}initProcessor(){this.processor=new qa(this.player,this,this.audioInfo.channels,this.audioBufferSize),this.rateProcessor=new no(this.player,this,this.processor)}getAutoAudioEngineType(){let e=this.player._opt.audioEngine||ss;const t=()=>{e=Kr()&&yr()?rs:vr()&&this.player._opt.supportLockScreenPlayAudio?ss:ra()?is:ss};return this.player._opt.audioEngine?this.player._opt.audioEngine===is&&ra()?e=is:this.player._opt.audioEngine===rs?e=rs:this.player._opt.audioEngine===ss?e=ss:t():t(),e}getAudioBufferSizeByType(){const e=this.engineType;this.player._opt.hasVideo;const t=this.player._opt.weiXinInAndroidAudioBufferSize;return e===is?1024:e===rs?t||4800:1024}initScriptNode(){this.playing=!0,this.hasInitScriptNode||(this.initProcessor(),this.engineType===is?this.initWorkletScriptNode():this.engineType===rs?this.initIntervalScriptNode():this.engineType===ss&&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||fa(this.playing)||this.isMute)return void(this.playing&&fa(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=ia((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 s=t[0][0],r=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<s.length;t++)1===this.channels?s[t]=e.left[t+this.offset]:2===this.channels&&(s[t]=e.left[t+this.offset],r&&(r[t]=e.right[t+this.offset]))}else 1===this.channels?s.fill(0):2===this.channels&&(s.fill(0),r&&r.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&&this.audioContext.audioWorklet.addModule(e).then((()=>{if(this.player.isDestroyed())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}),X)}tierDownToProcessScript(){this.player.debug.log("AudioContext","tierDownToProcessScript"),this.engineType=ss,this.audioBufferSize=this.getAudioBufferSizeByType(),this.initProcessScriptNode(),this.audioElementPlay()}handleScriptNodeCallback(e,t){let i,s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t=t||rr;let r=e.length;s&&(i=e,r=this.audioBufferSize);const a=this.audioInfo.channels;if(this.bufferList.length&&this.playing){if(this.player._opt,this.player.openSyncAudioAndVideo()&&pa(this.player.visibility)){this.calcPlaybackRateBySync();const r=this.player.getAudioSyncVideoDiff();if(r>this.player._opt.syncAudioAndVideoDiff)return this.player.debug.warn("AudioContext",`audioSyncVideoOption more than diff :${r}, waiting and bufferList is ${this.bufferList.length}`),s?i.port.postMessage({message:"zero"}):this.fillScriptNodeOutputBuffer(e,a),void t()}let o=this._provide(r);if(0===o.size)return this.player.debug.warn("AudioContext",`bufferList size is ${this.bufferList.length} outputBufferLength is ${r},and bufferItem.size is 0`),s?i.port.postMessage({message:"zero"}):this.fillScriptNodeOutputBuffer(e,a),void t();o&&o.ts&&(this.player.audioTimestamp=o.ts),s?i.port.postMessage({message:"data",buffer:o}):this.fillScriptNodeOutputBuffer(e,a,o),t()}else 0===this.bufferList.length&&this.playing&&fa(this.isMute)&&this.player.debug.warn("AudioContext",`bufferList size is 0 and outputBufferLength is ${r}`),s?i.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),s=e.getChannelData(1);i?0===i.size?(t.fill(0),s.fill(0)):(t.set(i.left),s.set(i.right)):(t.fill(0),s.fill(0))}}play(e,t){this.isMute||(this.hasInitScriptNode?(this.hasAudio=!0,this.player.latestAudioTimestamp=t,this.bufferList.push({buffer:e,ts:t}),fa(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()===rs){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 s=Math.floor(t/this.oneBufferDuration),r=Math.floor(i/this.oneBufferDuration);if(this.bufferList.length>r)return this.player.debug.warn("AudioContext",`bufferList length ${this.bufferList.length} more than ${r}, and drop`),void this.clear();this.getEngineType()!==rs&&(this.bufferList.length>s?(e=this.defaultPlaybackRate+.2,this.player.debug.log("AudioContext",`bufferList length ${this.bufferList.length} more than ${s}, speed up, playbackRate is ${e}`)):this.bufferList.length<s/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 ho 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.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){Fr(e.encTypeCode)&&(this.audioInfo.encType=vt[e.encTypeCode]),Fr(e.encType)&&(this.audioInfo.encType=e.encType),Fr(e.channels)&&(this.audioInfo.channels=e.channels),Fr(e.sampleRate)&&(this.audioInfo.sampleRate=e.sampleRate),Fr(this.audioInfo.sampleRate)&&Fr(this.audioInfo.channels)&&Fr(this.audioInfo.encType)&&!this.init&&(this.player.debug.log("Audio","audioInfo",JSON.stringify(this.audioInfo)),this.player.emit(Ze.audioInfo,this.audioInfo),this.init=!0)}get isPlaying(){return!0}get volume(){return pa(this.$video.muted)?0:this.$video.volume}get isMute(){return 0===this.$video.volume||pa(this.$video.muted)}mute(e){this.setVolume(e?0:this.player.lastVolume||.5)}setVolume(e){e=parseFloat(e),isNaN(e)||(e=hr(e,0,1),this.$video.muted&&(this.$video.muted=!1),vr()&&(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(Ze.volumechange,this.player.volume))}clear(){}play(){}pause(){}resume(){}getEngineType(){return"audio"}isPlaybackRateSpeed(){return!1}getAudioBufferSize(){return 0}setRate(){}}class co extends lo{constructor(e){super(e),this.delayTimeout=null,this.player.on(Ze.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 uo extends lo{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){fa(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 po{constructor(e){return new(po.getLoaderFactory(e._opt))(e)}static getLoaderFactory(e){return e.playType===A?e.useMSE&&e.mseDecodeAudio?ho:co:e.playType===y?uo:e.isHls&&fa(e.supportHls265)||e.isWebrtc&&fa(e.isWebrtcH265)||e.useMSE&&e.mseDecodeAudio||e.isAliyunRtc?ho:lo}}class fo 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=pr((t=>{e.emit(Ze.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:Ke}),this.fetchWorker.terminate(),this.fetchWorker=null),this._stopStreamRateInterval(),this.streamRate=null,this.player.debug.log(this.TAG_NAME,"destroy")}_initFetchWorker(){const e=_a(function(){function e(e){return!0===e||"true"===e}function t(e){return!1===e||"false"===e}const i="The user aborted a request",s="AbortError",r="AbortError",a="fetch",o="destroy",n="buffer",l="fetchError",h="fetchClose",d="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){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=Object.assign({signal:this.abortController.signal},{headers:a.headers||{}});fetch(t,o).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:d}),"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:n,buffer:t},[t.buffer]))},close:()=>{this._status=p,postMessage({cmd:h})},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(s)&&e.name!==r&&(this.abort(),postMessage({cmd:l,message:e.toString()}))}}),t.body.pipeTo(this.writableStream);else{const a=t.body.getReader(),o=()=>{a.read().then((t=>{let{done:i,value:s}=t;if(i)return this._status=p,void postMessage({cmd:h});this.abortController&&this.abortController.signal&&this.abortController.signal.aborted||e(this._requestAbort)?this._status=p:(this._status=u,postMessage({cmd:n,buffer:s},[s.buffer]),o())})).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(s)&&e.name!==r&&(this.abort(),postMessage({cmd:l,message:e.toString()}))}))};o()}})).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 o:f.destroy(),f=null}}}.toString()),t=new Blob([e],{type:"text/javascript"});let i=URL.createObjectURL(t);const s=new Worker(i);this.workerUrl=i,this.workerClearTimeout=setTimeout((()=>{window.URL.revokeObjectURL(this.workerUrl),this.workerUrl=null,this.workerClearTimeout=null}),X),s.onmessage=e=>{const{demux:t}=this.player,i=e.data;switch(i.cmd){case qe:this.streamRate&&this.streamRate(i.buffer.byteLength),t.dispatch(i.buffer);break;case Xe:this.emit(Ze.streamSuccess),this._startStreamRateInterval();break;case Qe:t.close(),this.emit(Ze.streamEnd);break;case Ye:t.close(),this.emit(it.fetchError,i.message)}},this.fetchWorker=s}_startStreamRateInterval(){this._stopStreamRateInterval(),this.streamRateInterval=setInterval((()=>{this.streamRate&&this.streamRate(0)}),1e3)}_stopStreamRateInterval(){this.streamRateInterval&&(clearInterval(this.streamRateInterval),this.streamRateInterval=null)}fetchStream(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.player._times.streamStart=lr(),this.fetchWorker.postMessage({cmd:Je,url:e,isChrome:qr(),options:JSON.stringify(t)})}getStreamType(){return h}}class mo extends t{constructor(e){super(),this.player=e,this.socket=null,this.socketStatus=st,this.wsUrl=null,this.requestAbort=!1,this.socketDestroyFnList=[],this.streamRate=pr((t=>{e.emit(Ze.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:s}=e;this.socket=new WebSocket(this.wsUrl),this.socket.binaryType="arraybuffer";const r=i(this.socket,"open",(()=>{t.log("WebsocketStream","socket open"),this.socketStatus=rt,this.emit(Ze.streamSuccess),this.player.emit(Ze.websocketOpen),this.startStreamRateInterval()})),a=i(this.socket,"message",(e=>{this.streamRate&&this.streamRate(e.data.byteLength),this._handleMessage(e.data)})),o=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}`),pa(this.requestAbort))return this.requestAbort=!1,void t.log("WebsocketStream","socket close and requestAbort is true");s.close(),this.socketStatus=at,this.player.emit(Ze.websocketClose),this.emit(Ze.streamEnd)})),n=i(this.socket,"error",(e=>{t.error("WebsocketStream","socket error",e),this.socketStatus=ot,this.emit(it.websocketError,e),s.close(),t.log("WebsocketStream","socket error:",e.isTrusted?"websocket user aborted":"websocket error")}));this.socketDestroyFnList.push(r,a,o,n)}_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=st,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=lr(),this.wsUrl=e,this._createWebSocket()}sendMessage(e){this.socket?this.socketStatus===rt?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 c}}class go 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=lr(),t.loadSource(e).then((()=>{this.player.debug.log("HlsStream","loadSource success"),this.emit(Ze.streamSuccess)})).catch((e=>{this.emit(it.hlsError,e)}))}getStreamType(){return d}}class yo 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;if(this.player._times.streamStart=lr(),this.webrctUrl=e.replace("webrtc:",window.location.protocol),-1===this.webrctUrl.indexOf("/webrtc/play")&&this.player.isWebrtcForM7S()){const t=new URL(this.webrctUrl),i="/webrtc/play"+t.pathname;this.webrctUrl=t.origin+i+t.search,this.player.debug.log("WebrtcStream",`original url is ${e}, and new url is: ${this.webrctUrl}`)}t.loadSource(this.webrctUrl).then((()=>{this.player.debug.log("WebrtcStream","loadSource success"),this.emit(Ze.streamSuccess)})).catch((e=>{this.player.debug.error("WebrtcStream","loadSource error",e),this.emit(it.webrtcError,e)}))}getStreamType(){return u}}class Ao extends t{constructor(e){super(),this.player=e,this.transport=null,this.wtUrl=null,this.streamRate=pr((t=>{e.emit(Ze.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:s}=e;try{this.transport=new WebTransport(this.wtUrl),this.transport.ready.then((()=>{this.emit(Ze.streamSuccess),this.startStreamRateInterval(),this.transport.createBidirectionalStream().then((e=>{e.readable.pipeTo(new WritableStream(s.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=lr(),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 p}}class bo 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){this.workUrl=e,this.player._times.streamStart=lr(),this.player.decoderWorker.workerFetchStream(e)}getStreamType(){const e=this.player._opt.protocol;return f+" "+(e===s?h:c)}}class vo 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=lr(),t.loadSource(e).then((()=>{this.player.debug.log(this.TAG_NAME,"loadSource success"),this.emit(Ze.streamSuccess)})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource error",e),this.emit(it.aliyunRtcError,e)}))}getStreamType(){return m}}class _o{constructor(e){return new(_o.getLoaderFactory(e._opt))(e)}static getLoaderFactory(e){const{protocol:t,useWasm:l,playType:h,useWCS:d,useMSE:c,demuxUseWorker:u}=e;return t===s?h===y?bo:h===g?l&&!ta(e)||u?bo:fo:d||c?u?bo:fo:bo:t===i?h===y?bo:h===g?l&&!ta(e)||u?bo:mo:d||c?u?bo:mo:bo:t===r?go:t===a?yo:t===o?Ao:t===n?vo:void 0}}var wo=$s((function(e){function t(e,r){if(!e)throw"First parameter is required.";r=new i(e,r=r||{type:"video"});var a=this;function o(t){t&&(r.initCallback=function(){t(),t=r.initCallback=null});var i=new s(e,r);(p=new i(e,r)).record(),u("recording"),r.disableLogs||console.log("Initialized recorderType:",p.constructor.name,"for output-type:",r.type)}function n(e){if(e=e||function(){},p){if("paused"===a.state)return a.resumeRecording(),void setTimeout((function(){n(e)}),1);"recording"===a.state||r.disableLogs||console.warn('Recording state should be: "recording", however current state is: ',a.state),r.disableLogs||console.log("Stopped recording "+r.type+" stream."),"gif"!==r.type?p.stop(t):(p.stop(),t()),u("stopped")}else m();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&&!r.disableLogs&&console.log(i.type,"->",y(i.size)),e){var s;try{s=d.createObjectURL(i)}catch(e){}"function"==typeof e.call?e.call(a,s):e(s)}r.autoWriteToDisk&&h((function(e){var t={};t[r.type+"Blob"]=e,R.Store(t)}))}else"function"==typeof e.call?e.call(a,""):e("")}}function l(e){postMessage((new FileReaderSync).readAsDataURL(e))}function h(e,t){if(!e)throw"Pass a callback function over getDataURL.";var i=t?t.blob:(p||{}).blob;if(!i)return r.disableLogs||console.warn("Blob encoder did not finish its job yet."),void setTimeout((function(){h(e,t)}),1e3);if("undefined"==typeof Worker||navigator.mozGetUserMedia){var s=new FileReader;s.readAsDataURL(i),s.onload=function(t){e(t.target.result)}}else{var a=function(e){try{var t=d.createObjectURL(new Blob([e.toString(),"this.onmessage = function (eee) {"+e.name+"(eee.data);}"],{type:"application/javascript"})),i=new Worker(t);return d.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?n(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 '+r.type+" recorder.";function m(){!0!==r.disableLogs&&console.warn(f)}var g={startRecording:function(t){return r.disableLogs||console.log("RecordRTC version: ",a.version),t&&(r=new i(e,t)),r.disableLogs||console.log("started recording "+r.type+" stream."),p?(p.clearRecordedData(),p.record(),u("recording"),a.recordingDuration&&c(),a):(o((function(){a.recordingDuration&&c()})),a)},stopRecording:n,pauseRecording:function(){p?"recording"===a.state?(u("paused"),p.pause(),r.disableLogs||console.log("Paused recording.")):r.disableLogs||console.warn("Unable to pause the recording. Recording state: ",a.state):m()},resumeRecording:function(){p?"paused"===a.state?(u("recording"),p.resume(),r.disableLogs||console.log("Resumed recording.")):r.disableLogs||console.warn("Unable to resume the recording. Recording state: ",a.state):m()},initRecorder:o,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(),r.disableLogs||console.log("Cleared old recorded data.")):m()},getBlob:function(){if(p)return p.blob;m()},getDataURL:h,toURL:function(){if(p)return d.createObjectURL(p.blob);m()},getInternalRecorder:function(){return p},save:function(e){p?A(p.blob,e):m()},getFromDisk:function(e){p?t.getFromDisk(r.type,e):m()},setAdvertisementArray:function(e){r.advertisement=[];for(var t=e.length,i=0;i<t;i++)r.advertisement.push({duration:i,image:e[i]})},blob:null,bufferSize:0,sampleRate:0,buffer:null,reset:function(){"recording"!==a.state||r.disableLogs||console.warn("Stop an active recorder."),p&&"function"==typeof p.clearRecordedData&&p.clearRecordedData(),p=null,u("inactive"),a.blob=null},onStateChanged:function(e){r.disableLogs||console.log("Recorder state changed:",e)},state:"inactive",getState:function(){return a.state},destroy:function(){var e=r.disableLogs;r={disableLogs:!0},a.reset(),u("destroyed"),g=a=null,w.AudioContextConstructor&&(w.AudioContextConstructor.close(),w.AudioContextConstructor=null),r.disableLogs=e,r.disableLogs||console.log("RecordRTC is destroyed.")},version:"5.6.2"};if(!this)return a=g,g;for(var b in g)this[b]=g[b];return a=this,g}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||t.recorderType===P?t.type="video":t.recorderType===D?t.type="gif":t.recorderType===E?t.type="audio":t.recorderType===T&&(v(e,"audio").length&&v(e,"video").length||!v(e,"audio").length&&v(e,"video").length?t.type="video":v(e,"audio").length&&!v(e,"video").length&&(t.type="audio"))),"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 s(e,t){var i;return(f||c||u)&&(i=E),"undefined"!=typeof MediaRecorder&&"requestData"in MediaRecorder.prototype&&!f&&(i=T),"video"===t.type&&(f||u)&&(i=C,"undefined"!=typeof ReadableStream&&(i=P)),"gif"===t.type&&(i=D),"canvas"===t.type&&(i=k),S()&&i!==k&&i!==D&&"undefined"!=typeof MediaRecorder&&"requestData"in MediaRecorder.prototype&&(v(e,"video").length||v(e,"audio").length)&&("audio"===t.type?"function"==typeof MediaRecorder.isTypeSupported&&MediaRecorder.isTypeSupported("audio/webm")&&(i=T):"function"==typeof MediaRecorder.isTypeSupported&&MediaRecorder.isTypeSupported("video/webm")&&(i=T)),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&&m&&(i=T),i}function r(e){this.addStream=function(t){t&&(e=t)},this.mediaType={audio:!0,video:!0},this.startRecording=function(){var i,s=this.mediaType,r=this.mimeType||{audio:null,video:null,gif:null};if("function"!=typeof s.audio&&S()&&!v(e,"audio").length&&(s.audio=!1),"function"!=typeof s.video&&S()&&!v(e,"video").length&&(s.video=!1),"function"!=typeof s.gif&&S()&&!v(e,"video").length&&(s.gif=!1),!s.audio&&!s.video&&!s.gif)throw"MediaStream must have either audio or video tracks.";if(s.audio&&(i=null,"function"==typeof s.audio&&(i=s.audio),this.audioRecorder=new t(e,{type:"audio",bufferSize:this.bufferSize,sampleRate:this.sampleRate,numberOfAudioChannels:this.numberOfAudioChannels||2,disableLogs:this.disableLogs,recorderType:i,mimeType:r.audio,timeSlice:this.timeSlice,onTimeStamp:this.onTimeStamp}),s.video||this.audioRecorder.startRecording()),s.video){i=null,"function"==typeof s.video&&(i=s.video);var a=e;if(S()&&s.audio&&"function"==typeof s.audio){var o=v(e,"video")[0];p?((a=new g).addTrack(o),i&&i===C&&(i=T)):(a=new g).addTrack(o)}this.videoRecorder=new t(a,{type:"video",video:this.video,canvas:this.canvas,frameInterval:this.frameInterval||10,disableLogs:this.disableLogs,recorderType:i,mimeType:r.video,timeSlice:this.timeSlice,onTimeStamp:this.onTimeStamp,workerPath:this.workerPath,webAssemblyPath:this.webAssemblyPath,frameRate:this.frameRate,bitrate:this.bitrate}),s.audio||this.videoRecorder.startRecording()}if(s.audio&&s.video){var n=this,l=!0===S();(s.audio instanceof E&&s.video||!0!==s.audio&&!0!==s.video&&s.audio!==s.video)&&(l=!1),!0===l?(n.audioRecorder=null,n.videoRecorder.startRecording()):n.videoRecorder.initRecorder((function(){n.audioRecorder.initRecorder((function(){n.videoRecorder.startRecording(),n.audioRecorder.startRecording()}))}))}s.gif&&(i=null,"function"==typeof s.gif&&(i=s.gif),this.gifRecorder=new t(e,{type:"gif",frameRate:this.frameRate||200,quality:this.quality||10,disableLogs:this.disableLogs,recorderType:i,mimeType:r.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=d.createObjectURL(new Blob([e.toString(),"this.onmessage = function (eee) {"+e.name+"(eee.data);}"],{type:"application/javascript"})),s=new Worker(i);if(void 0!==d)t=d;else{if("undefined"==typeof webkitURL)throw"Neither URL nor webkitURL detected.";t=webkitURL}return t.revokeObjectURL(i),s}((function(e){postMessage((new FileReaderSync).readAsDataURL(e))}));i.onmessage=function(e){t(e.data)},i.postMessage(e)}else{var s=new FileReader;s.readAsDataURL(e),s.onload=function(e){t(e.target.result)}}}this.getBlob((function(i){i.audio&&i.video?t(i.audio,(function(s){t(i.video,(function(t){e({audio:s,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,s){"all"!==e&&s===e+"Blob"&&t&&t(i),"all"===e&&t&&t(i,s.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})}))},r.getFromDisk=t.getFromDisk,r.writeToDisk=t.writeToDisk,t.MRecordRTC=r;var a;(a=void 0!==zs?zs:null)&&"undefined"==typeof window&&void 0!==zs&&(zs.navigator={userAgent:"Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45",getUserMedia:function(){}},zs.console||(zs.console={}),void 0!==zs.console.log&&void 0!==zs.console.error||(zs.console.error=zs.console.log=zs.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===d&&(a.URL={createObjectURL:function(){return""},revokeObjectURL:function(){return""}}),a.window=zs);var o=window.requestAnimationFrame;if(void 0===o)if("undefined"!=typeof webkitRequestAnimationFrame)o=webkitRequestAnimationFrame;else if("undefined"!=typeof mozRequestAnimationFrame)o=mozRequestAnimationFrame;else if("undefined"!=typeof msRequestAnimationFrame)o=msRequestAnimationFrame;else if(void 0===o){var n=0;o=function(e,t){var i=(new Date).getTime(),s=Math.max(0,16-(i-n)),r=setTimeout((function(){e(i+s)}),s);return n=i+s,r}}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 h=window.AudioContext;void 0===h&&("undefined"!=typeof webkitAudioContext&&(h=webkitAudioContext),"undefined"!=typeof mozAudioContext&&(h=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 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||b()||-1!==navigator.userAgent.toLowerCase().indexOf("chrome/"),m=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);m&&!f&&-1!==navigator.userAgent.indexOf("CriOS")&&(m=!1,f=!0);var g=window.MediaStream;function y(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 s=t.split(".");t=s[0],i=s[1]}var r=(t||Math.round(9999999999*Math.random())+888888888)+"."+i;if(void 0!==navigator.msSaveOrOpenBlob)return navigator.msSaveOrOpenBlob(e,r);if(void 0!==navigator.msSaveBlob)return navigator.msSaveBlob(e,r);var a=document.createElement("a");a.href=d.createObjectURL(e),a.download=r,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}))),d.revokeObjectURL(a.href)}function b(){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 v(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===g&&"undefined"!=typeof webkitMediaStream&&(g=webkitMediaStream),void 0!==g&&void 0===g.prototype.stop&&(g.prototype.stop=function(){this.getTracks().forEach((function(e){e.stop()}))}),t.invokeSaveAsDialog=A,t.getTracks=v,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,s=new EBML.Decoder,r=EBML.tools,a=new FileReader;a.onload=function(e){s.decode(this.result).forEach((function(e){i.read(e)})),i.stop();var a=r.makeMetadataSeekable(i.metadatas,i.duration,i.cues),o=this.result.slice(i.metadataSize),n=new Blob([a,o],{type:"video/webm"});t(n)},a.readAsArrayBuffer(e)},t.bytesToSize=y,t.isElectron=b;var w={};function S(){if(p||m||c)return!0;var e,t,i=navigator.userAgent,s=""+parseFloat(navigator.appVersion),r=parseInt(navigator.appVersion,10);return(f||u)&&(e=i.indexOf("Chrome"),s=i.substring(e+7)),-1!==(t=s.indexOf(";"))&&(s=s.substring(0,t)),-1!==(t=s.indexOf(" "))&&(s=s.substring(0,t)),r=parseInt(""+s,10),isNaN(r)&&(s=""+parseFloat(navigator.appVersion),r=parseInt(navigator.appVersion,10)),r>=49}function T(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 s;if(v(e,"video").length&&v(e,"audio").length)navigator.mozGetUserMedia?(s=new g).addTrack(v(e,"audio")[0]):s=new g(v(e,"audio")),e=s;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 r,a=[];function o(){i.timestamps.push((new Date).getTime()),"function"==typeof t.onTimeStamp&&t.onTimeStamp(i.timestamps[i.timestamps.length-1],i.timestamps)}function n(e){return r&&r.mimeType?r.mimeType:e.mimeType||"video/webm"}function l(){a=[],r=null,i.timestamps=[]}this.getArrayOfBlobs=function(){return a},this.record=function(){i.blob=null,i.clearRecordedData(),i.timestamps=[],h=[],a=[];var s=t;t.disableLogs||console.log("Passing following config over MediaRecorder API.",s),r&&(r=null),f&&!S()&&(s="video/vp8"),"function"==typeof MediaRecorder.isTypeSupported&&s.mimeType&&(MediaRecorder.isTypeSupported(s.mimeType)||(t.disableLogs||console.warn("MediaRecorder API seems unable to record mimeType:",s.mimeType),s.mimeType="audio"===t.type?"audio/webm":"video/webm"));try{r=new MediaRecorder(e,s),t.mimeType=s.mimeType}catch(t){r=new MediaRecorder(e)}s.mimeType&&!MediaRecorder.isTypeSupported&&"canRecordMimeType"in r&&!1===r.canRecordMimeType(s.mimeType)&&(t.disableLogs||console.warn("MediaRecorder API seems unable to record mimeType:",s.mimeType)),r.ondataavailable=function(e){if(e.data&&h.push("ondataavailable: "+y(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:n(s)})),i.recordingCallback=null):(i.blob=t.getNativeBlob?e.data:new Blob([e.data],{type:n(s)}),i.recordingCallback&&(i.recordingCallback(i.blob),i.recordingCallback=null));else if(e.data&&e.data.size&&(a.push(e.data),o(),"function"==typeof t.ondataavailable)){var r=t.getNativeBlob?e.data:new Blob([e.data],{type:n(s)});t.ondataavailable(r)}},r.onstart=function(){h.push("started")},r.onpause=function(){h.push("paused")},r.onresume=function(){h.push("resumed")},r.onstop=function(){h.push("stopped")},r.onerror=function(e){e&&(e.name||(e.name="UnknownError"),h.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 (",s.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&&r&&"inactive"===r.state)return delete t.timeslice,void r.start(6e5);setTimeout(void 0,1e3)}(),"inactive"!==r.state&&"stopped"!==r.state&&r.stop())},"number"==typeof t.timeSlice?(o(),r.start(t.timeSlice)):r.start(36e5),t.initCallback&&t.initCallback()},this.timestamps=[],this.stop=function(e){e=e||function(){},i.manuallyStopped=!0,r&&(this.recordingCallback=e,"recording"===r.state&&r.stop(),"number"==typeof t.timeSlice&&setTimeout((function(){i.blob=new Blob(a,{type:n(t)}),i.recordingCallback(i.blob)}),100))},this.pause=function(){r&&"recording"===r.state&&r.pause()},this.resume=function(){r&&"paused"===r.state&&r.resume()},this.clearRecordedData=function(){r&&"recording"===r.state&&i.stop(l),l()},this.getInternalRecorder=function(){return r},this.blob=null,this.getState=function(){return r&&r.state||"inactive"};var h=[];this.getAllStates=function(){return h},void 0===t.checkForInactiveTracks&&(t.checkForInactiveTracks=!1);i=this;!function s(){if(r&&!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(s,1e3)}(),this.name="MediaStreamRecorder",this.toString=function(){return this.name}}function E(e,i){if(!v(e,"audio").length)throw"Your stream has no audio tracks.";var s,r=this,a=[],o=[],n=!1,l=0,h=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,s=e.numberOfAudioChannels,r=e.leftBuffers.slice(0),a=e.rightBuffers.slice(0),o=e.sampleRate,n=e.internalInterleavedLength,l=e.desiredSampRate;function h(e,t,i){var s=Math.round(e.length*(t/i)),r=[],a=Number((e.length-1)/(s-1));r[0]=e[0];for(var o=1;o<s-1;o++){var n=o*a,l=Number(Math.floor(n)).toFixed(),h=Number(Math.ceil(n)).toFixed(),c=n-l;r[o]=d(e[l],e[h],c)}return r[s-1]=e[e.length-1],r}function d(e,t,i){return e+(t-e)*i}function c(e,t){for(var i=new Float64Array(t),s=0,r=e.length,a=0;a<r;a++){var o=e[a];i.set(o,s),s+=o.length}return i}function u(e,t,i){for(var s=i.length,r=0;r<s;r++)e.setUint8(t+r,i.charCodeAt(r))}2===s&&(r=c(r,n),a=c(a,n),l&&(r=h(r,l,o),a=h(a,l,o))),1===s&&(r=c(r,n),l&&(r=h(r,l,o))),l&&(o=l),2===s&&(i=function(e,t){for(var i=e.length+t.length,s=new Float64Array(i),r=0,a=0;a<i;)s[a++]=e[r],s[a++]=t[r],r++;return s}(r,a)),1===s&&(i=r);var p=i.length,f=new ArrayBuffer(44+2*p),m=new DataView(f);u(m,0,"RIFF"),m.setUint32(4,36+2*p,!0),u(m,8,"WAVE"),u(m,12,"fmt "),m.setUint32(16,16,!0),m.setUint16(20,1,!0),m.setUint16(22,s,!0),m.setUint32(24,o,!0),m.setUint32(28,o*s*2,!0),m.setUint16(32,2*s,!0),m.setUint16(34,16,!0),u(m,36,"data"),m.setUint32(40,2*p,!0);for(var g=p,y=44,A=0;A<g;A++)m.setInt16(y,32767*i[A],!0),y+=2;if(t)return t({buffer:f,view:m});postMessage({buffer:f,view:m})}if(e.noWorker)i(e,(function(e){t(e.buffer,e.view)}));else{var s,r,a,o=(s=i,r=d.createObjectURL(new Blob([s.toString(),";this.onmessage = function (eee) {"+s.name+"(eee.data);}"],{type:"application/javascript"})),(a=new Worker(r)).workerURL=r,a);o.onmessage=function(e){t(e.data.buffer,e.data.view),d.revokeObjectURL(o.workerURL),o.terminate()},o.postMessage(e)}}!0===i.leftChannel&&(h=1),1===i.numberOfAudioChannels&&(h=1),(!h||h<1)&&(h=2),i.disableLogs||console.log("StereoAudioRecorder is set to record number of channels: "+h),void 0===i.checkForInactiveTracks&&(i.checkForInactiveTracks=!0),this.record=function(){if(!1===u())throw"Please make sure MediaStream is active.";_(),S=b=!1,n=!0,void 0!==i.timeSlice&&E()},this.stop=function(e){e=e||function(){},n=!1,p({desiredSampRate:c,sampleRate:A,numberOfAudioChannels:h,internalInterleavedLength:l,leftBuffers:a,rightBuffers:1===h?[]:o,noWorker:i.noWorker},(function(t,i){r.blob=new Blob([i],{type:"audio/wav"}),r.buffer=new ArrayBuffer(i.buffer.byteLength),r.view=i,r.sampleRate=c||A,r.bufferSize=y,r.length=l,S=!1,e&&e(r.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,m=f.createMediaStreamSource(e),g=[0,256,512,1024,2048,4096,8192,16384],y=void 0===i.bufferSize?4096:i.bufferSize;if(-1===g.indexOf(y)&&(i.disableLogs||console.log("Legal values for buffer-size are "+JSON.stringify(g,null,"\t"))),f.createJavaScriptNode)s=f.createJavaScriptNode(y,h,h);else{if(!f.createScriptProcessor)throw"WebAudio API has no support on this browser.";s=f.createScriptProcessor(y,h,h)}m.connect(s),i.bufferSize||(y=s.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 b=!1;function _(){a=[],o=[],l=0,S=!1,n=!1,b=!1,f=null,r.leftchannel=a,r.rightchannel=o,r.numberOfAudioChannels=h,r.desiredSampRate=c,r.sampleRate=A,r.recordingLength=l,T={left:[],right:[],recordingLength:0}}function w(){s&&(s.onaudioprocess=null,s.disconnect(),s=null),m&&(m.disconnect(),m=null),_()}this.pause=function(){b=!0},this.resume=function(){if(!1===u())throw"Please make sure MediaStream is active.";if(!n)return i.disableLogs||console.log("Seems recording has been restarted."),void this.record();b=!1},this.clearRecordedData=function(){i.checkForInactiveTracks=!1,n&&this.stop(w),w()},this.name="StereoAudioRecorder",this.toString=function(){return this.name};var S=!1;s.onaudioprocess=function(e){if(!b)if(!1===u()&&(i.disableLogs||console.log("MediaStream seems stopped."),s.disconnect(),n=!1),n){S||(S=!0,i.onAudioProcessStarted&&i.onAudioProcessStarted(),i.initCallback&&i.initCallback());var t=e.inputBuffer.getChannelData(0),d=new Float32Array(t);if(a.push(d),2===h){var c=e.inputBuffer.getChannelData(1),p=new Float32Array(c);o.push(p)}l+=y,r.recordingLength=l,void 0!==i.timeSlice&&(T.recordingLength+=y,T.left.push(d),2===h&&T.right.push(p))}else m&&(m.disconnect(),m=null)},f.createMediaStreamDestination?s.connect(f.createMediaStreamDestination()):s.connect(f.destination),this.leftchannel=a,this.rightchannel=o,this.numberOfAudioChannels=h,this.desiredSampRate=c,this.sampleRate=A,r.recordingLength=l;var T={left:[],right:[],recordingLength:0};function E(){n&&"function"==typeof i.ondataavailable&&void 0!==i.timeSlice&&(T.left.length?(p({desiredSampRate:c,sampleRate:A,numberOfAudioChannels:h,internalInterleavedLength:T.recordingLength,leftBuffers:T.left,rightBuffers:1===h?[]:T.right},(function(e,t){var s=new Blob([t],{type:"audio/wav"});i.ondataavailable(s),setTimeout(E,i.timeSlice)})),T={left:[],right:[],recordingLength:0}):setTimeout(E,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 s,r,a,o=!(!window.webkitRTCPeerConnection&&!window.webkitGetUserMedia||!window.chrome),n=50,l=navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);if(o&&l&&l[2]&&(n=parseInt(l[2],10)),o&&n<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)s=e;else{if(!(e instanceof CanvasRenderingContext2D))throw"Please pass either HTMLCanvasElement or CanvasRenderingContext2D.";s=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 s?e=s.captureStream(25):"mozCaptureStream"in s?e=s.mozCaptureStream(25):"webkitCaptureStream"in s&&(e=s.webkitCaptureStream(25));try{var o=new g;o.addTrack(v(e,"video")[0]),e=o}catch(e){}if(!e)throw"captureStream API are NOT available.";(r=new T(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 s=p.frames.length;p.frames.forEach((function(e,i){var r=s-i;t.disableLogs||console.log(r+"/"+s+" frames remaining"),t.onEncodingCallback&&t.onEncodingCallback(r,s);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 s=this;i&&r?r.stop(e):this.getWebPImages((function(){p.compile((function(i){t.disableLogs||console.log("Recording finished!"),s.blob=i,s.blob.forEach&&(s.blob=new Blob([],{type:"video/webm"})),e&&e(s.blob),p.frames=[]}))}))};var h=!1;function d(){p.frames=[],a=!1,h=!1}function c(){if(h)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:(s=document.createElement("canvas"),r=s.getContext("2d"),s.width=e.width,s.height=e.height,r.drawImage(e,0,0),s),duration:i}),void(a&&setTimeout(c,t.frameInterval))}var s,r;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(){h=!0,r instanceof T&&r.pause()},this.resume=function(){h=!1,r instanceof T?r.resume():a||this.record()},this.clearRecordedData=function(){a&&this.stop(d),d()},this.name="CanvasRecorder",this.toString=function(){return this.name};var u=(new Date).getTime(),p=new x.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(),n.paused&&n.play(),c.drawImage(n,0,0,d.width,d.height),h.frames.push({duration:t,image:d.toDataURL("image/webp")}),void(r||setTimeout(i,e,e))):setTimeout(i,e,e)}function s(e,t,i,s,r){var a=document.createElement("canvas");a.width=d.width,a.height=d.height;var o,n,l,h=a.getContext("2d"),c=[],u=-1===t,p=t&&t>0&&t<=e.length?t:e.length,f=0,m=0,g=0,y=Math.sqrt(Math.pow(255,2)+Math.pow(255,2)+Math.pow(255,2)),A=i&&i>=0&&i<=1?i:0,b=s&&s>=0&&s<=1?s:0,v=!1;n=-1,l=(o={length:p,functionToLoop:function(t,i){var s,r,a,o=function(){!v&&a-s<=a*b||(u&&(v=!0),c.push(e[i])),t()};if(v)o();else{var n=new Image;n.onload=function(){h.drawImage(n,0,0,d.width,d.height);var e=h.getImageData(0,0,d.width,d.height);s=0,r=e.data.length,a=e.data.length/4;for(var t=0;t<r;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-m,2)+Math.pow(i.b-g,2))<=y*A&&s++}o()},n.src=e[i].image}},callback:function(){(c=c.concat(e.slice(p))).length<=0&&c.push(e[e.length-1]),r(c)}}).length,function e(){++n!==l?setTimeout((function(){o.functionToLoop(e,n)}),1):o.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}),d.width=t.canvas.width||320,d.height=t.canvas.height||240,c=d.getContext("2d"),t.video&&t.video instanceof HTMLVideoElement?(n=t.video.cloneNode(),t.initCallback&&t.initCallback()):(n=document.createElement("video"),_(e,n),n.onloadedmetadata=function(){t.initCallback&&t.initCallback()},n.width=t.video.width,n.height=t.video.height),n.muted=!0,n.play(),l=(new Date).getTime(),h=new x.Video,t.disableLogs||(console.log("canvas resolutions",d.width,"*",d.height),console.log("video width/height",n.width||d.width,"*",n.height||d.height)),i(t.frameInterval)};var r=!1;this.stop=function(e){e=e||function(){},r=!0;var i=this;setTimeout((function(){s(h.frames,-1,null,null,(function(s){h.frames=s,t.advertisement&&t.advertisement.length&&(h.frames=t.advertisement.concat(h.frames)),h.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 o(){h.frames=[],r=!0,a=!1}this.pause=function(){a=!0},this.resume=function(){a=!1,r&&this.record()},this.clearRecordedData=function(){r||this.stop(o),o()},this.name="WhammyRecorder",this.toString=function(){return this.name};var n,l,h,d=document.createElement("canvas"),c=d.getContext("2d")}void 0!==h?w.AudioContext=h:"undefined"!=typeof webkitAudioContext&&(w.AudioContext=webkitAudioContext),t.Storage=w,t.MediaStreamRecorder=T,t.StereoAudioRecorder=E,t.CanvasRecorder=k,t.WhammyRecorder=C;var x=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";return[128|e.trackNum,e.timecode>>8,255&e.timecode,t].map((function(e){return String.fromCharCode(e)})).join("")+e.frame}({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 s(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 r(e){for(var t=[],a=0;a<e.length;a++){var o=e[a].data;"object"==typeof o&&(o=r(o)),"number"==typeof o&&(o=s(o.toString(2))),"string"==typeof o&&(o=new Uint8Array(o.split("").map((function(e){return e.charCodeAt(0)}))));var n=o.size||o.byteLength||o.length,l=Math.ceil(Math.ceil(Math.log(n)/Math.log(2))/8),h=n.toString(2),d=new Array(7*l+7+1-h.length).join("0")+h,c=new Array(l).join("0")+"1"+d;t.push(i(e[a].id)),t.push(s(c)),t.push(o)}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 o(e){for(var t=0,i={};t<e.length;){var s=e.substr(t,4),r=a(e,t),n=e.substr(t+4+4,r);t+=8+r,i[s]=i[s]||[],"RIFF"===s||"LIST"===s?i[s].push(o(n)):i[s].push(n)}return i}var n=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,s=e[0].duration,r=1;r<e.length;r++)s+=e[r].duration;return{duration:s,width:t,height:i}}(e);if(!i)return[];for(var s,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:(s=i.duration,[].slice.call(new Uint8Array(new Float64Array([s]).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}]}]}]}]}],o=0,n=0;o<e.length;){var l=[],h=0;do{l.push(e[o]),h+=e[o].duration,o++}while(o<e.length&&h<3e4);var d={id:524531317,data:t(n,0,l)};a[1].data.push(d),n+=h}return r(a)}(e.map((function(e){var t=function(e){for(var t=e.RIFF[0].WEBP[0],i=t.indexOf("*"),s=0,r=[];s<4;s++)r[s]=t.charCodeAt(i+3+s);return{width:16383&(r[1]<<8|r[0]),height:16383&(r[3]<<8|r[2]),data:t,riff:e}}(o(atob(e.image.slice(23))));return t.duration=e.duration,t})));postMessage(n)}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,s,r,a=(i=t,s=d.createObjectURL(new Blob([i.toString(),"this.onmessage = function (eee) {"+i.name+"(eee.data);}"],{type:"application/javascript"})),r=new Worker(s),d.revokeObjectURL(s),r);a.onmessage=function(t){t.data.error?console.error(t.data.error):e(t.data)},a.postMessage(this.frames)},{Video:e}}();t.Whammy=x;var R={init:function(){var e=this;if("undefined"!=typeof indexedDB&&void 0!==indexedDB.open){var t,i=this.dbName||location.href.replace(/\/|:|#|%|\.|\[|\]/g,""),s=indexedDB.open(i,1);s.onerror=e.onError,s.onsuccess=function(){((t=s.result).onerror=e.onError,t.setVersion)?1!==t.version?t.setVersion(1).onsuccess=function(){r(t),a()}:a():a()},s.onupgradeneeded=function(e){r(e.target.result)}}else console.error("IndexedDB API are not available in this browser.");function r(t){t.createObjectStore(e.dataStoreName)}function a(){var i=t.transaction([e.dataStoreName],"readwrite");function s(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"),s("audioBlob"),s("videoBlob"),s("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 D(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 s=e instanceof CanvasRenderingContext2D||e instanceof HTMLCanvasElement;this.record=function(){"undefined"!=typeof GIFEncoder&&h?(s||(t.width||(t.width=d.offsetWidth||320),t.height||(t.height=d.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,d.width=t.video.width||320,d.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=o((function e(i){if(!0!==f.clearedRecordedData){if(r)return setTimeout((function(){e(i)}),100);p=o(e),void 0===typeof c&&(c=i),i-c<90||(!s&&d.paused&&d.play(),s||n.drawImage(d,0,0,a.width,a.height),t.onGifPreview&&t.onGifPreview(a.toDataURL("image/png")),u.addFrame(n),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 r=!1;this.pause=function(){r=!0},this.resume=function(){r=!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"),n=a.getContext("2d");s&&(e instanceof CanvasRenderingContext2D?a=(n=e).canvas:e instanceof HTMLCanvasElement&&(n=e.getContext("2d"),a=e));var h=!0;if(!s){var d=document.createElement("video");d.muted=!0,d.autoplay=!0,d.playsInline=!0,h=!1,d.onloadedmetadata=function(){h=!0},_(e,d),d.play()}var c,u,p=null,f=this}function L(e,t){t=t||"multi-streams-mixer";var i=[],s=!1,r=document.createElement("canvas"),a=r.getContext("2d");r.style.opacity=0,r.style.position="absolute",r.style.zIndex=-1,r.style.top="-1000em",r.style.left="-1000em",r.className=t,(document.body||document.documentElement).appendChild(r),this.disableLogs=!1,this.frameInterval=10,this.width=360,this.height=240,this.useGainNode=!0;var o=this,n=window.AudioContext;void 0===n&&("undefined"!=typeof webkitAudioContext&&(n=webkitAudioContext),"undefined"!=typeof mozAudioContext&&(n=mozAudioContext));var l=window.URL;void 0===l&&"undefined"!=typeof webkitURL&&(l=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 d={};function c(){if(!s){var e=i.length,t=!1,a=[];if(i.forEach((function(e){e.stream||(e.stream={}),e.stream.fullcanvas?t=e:a.push(e)})),t)r.width=t.stream.width,r.height=t.stream.height;else if(a.length){r.width=e>1?2*a[0].width:a[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),r.height=a[0].height*n}else r.width=o.width||360,r.height=o.height||240;t&&t instanceof HTMLVideoElement&&u(t),a.forEach((function(e,t){u(e,t)})),setTimeout(c,o.frameInterval)}}function u(e,t){if(!s){var i=0,r=0,o=e.width,n=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&&(o=e.stream.width),void 0!==e.stream.height&&(n=e.stream.height),a.drawImage(e,i,r,o,n),"function"==typeof e.stream.onRender&&e.stream.onRender(a,i,r,o,n,t)}}function p(e){var i=document.createElement("video");return function(e,t){"srcObject"in t?t.srcObject=e:"mozSrcObject"in t?t.mozSrcObject=e:t.srcObject=e}(e,i),i.className=t,i.muted=!0,i.volume=0,i.width=e.width||o.width||360,i.height=e.height||o.height||240,i.play(),i}function f(t){i=[],(t=t||e).forEach((function(e){if(e.getTracks().filter((function(e){return"video"===e.kind})).length){var t=p(e);t.stream=e,i.push(t)}}))}void 0!==n?d.AudioContext=n:"undefined"!=typeof webkitAudioContext&&(d.AudioContext=webkitAudioContext),this.startDrawingFrames=function(){c()},this.appendStreams=function(t){if(!t)throw"First parameter is required.";t instanceof Array||(t=[t]),t.forEach((function(t){var s=new h;if(t.getTracks().filter((function(e){return"video"===e.kind})).length){var r=p(t);r.stream=t,i.push(r),s.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),s.addTrack(o.audioDestination.stream.getTracks().filter((function(e){return"audio"===e.kind}))[0])}e.push(s)}))},this.releaseStreams=function(){i=[],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,a.clearRect(0,0,r.width,r.height),r.stream&&(r.stream.stop(),r.stream=null)},this.resetVideoStreams=function(e){!e||e instanceof Array||(e=[e]),f(e)},this.name="MultiStreamsMixer",this.toString=function(){return this.name},this.getMixedStream=function(){s=!1;var t=function(){var e;f(),"captureStream"in r?e=r.captureStream():"mozCaptureStream"in r?e=r.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)})),r.stream=t,t}(),i=function(){d.AudioContextConstructor||(d.AudioContextConstructor=new d.AudioContext);o.audioContext=d.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,s,r=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 r;i=new L(e,t.elementClass||"multi-streams-mixer"),(r=[],e.forEach((function(e){v(e,"video").forEach((function(e){r.push(e)}))})),r).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()),(s=new T(i.getMixedStream(),t)).record()},this.stop=function(e){s&&s.stop((function(t){r.blob=t,e(t),r.clearRecordedData()}))},this.pause=function(){s&&s.pause()},this.resume=function(){s&&s.resume()},this.clearRecordedData=function(){s&&(s.clearRecordedData(),s=null),i&&(i.releaseStreams(),i=null)},this.addStreams=function(r){if(!r)throw"First parameter is required.";r instanceof Array||(r=[r]),e.concat(r),s&&i&&(i.appendStreams(r),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,s,r;function a(){return new ReadableStream({start:function(s){var r=document.createElement("canvas"),a=document.createElement("video"),o=!0;a.srcObject=e,a.muted=!0,a.height=t.height,a.width=t.width,a.volume=0,a.onplaying=function(){r.width=t.width,r.height=t.height;var e=r.getContext("2d"),n=1e3/t.frameRate,l=setInterval((function(){if(i&&(clearInterval(l),s.close()),o&&(o=!1,t.onVideoProcessStarted&&t.onVideoProcessStarted()),e.drawImage(a,0,0),"closed"!==s._controlledReadableStream.state)try{s.enqueue(e.getImageData(0,0,t.width,t.height))}catch(e){}}),n)},a.play()}})}function o(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){o(e,t)}))}));if(!t.workerPath&&l instanceof ArrayBuffer){var h=new Blob([l],{type:"text/javascript"});t.workerPath=d.createObjectURL(h)}t.workerPath||console.error("workerPath parameter is missing."),(s=new Worker(t.workerPath)).postMessage(t.webAssemblyPath||"https://unpkg.com/webm-wasm@latest/dist/webm-wasm.wasm"),s.addEventListener("message",(function(e){"READY"===e.data?(s.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!"):s.postMessage(e.data.buffer,[e.data.buffer])}}))):e.data&&(r||n.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(){n=[],r=!1,this.blob=null,o(e),"function"==typeof t.initCallback&&t.initCallback()},this.pause=function(){r=!0},this.resume=function(){r=!1};var n=[];this.stop=function(e){i=!0;var t=this;!function(e){s?(s.addEventListener("message",(function(t){null===t.data&&(s.terminate(),s=null,e&&e())})),s.postMessage(null)):e&&e()}((function(){t.blob=new Blob(n,{type:"video/webm"}),e(t.blob)}))},this.name="WebAssemblyRecorder",this.toString=function(){return this.name},this.clearRecordedData=function(){n=[],r=!1,this.blob=null},this.blob=null}t.DiskStorage=R,t.GifRecorder=D,t.MultiStreamRecorder=I,t.RecordRTCPromisesHandler=function(e,i){if(!this)throw'Use "new RecordRTCPromisesHandler()"';if(void 0===e)throw'First argument "MediaStream" is required.';var s=this;s.recordRTC=new t(e,i),this.startRecording=function(){return new Promise((function(e,t){try{s.recordRTC.startRecording(),e()}catch(e){t(e)}}))},this.stopRecording=function(){return new Promise((function(e,t){try{s.recordRTC.stopRecording((function(i){s.blob=s.recordRTC.getBlob(),s.blob&&s.blob.size?e(i):t("Empty blob.",s.blob)}))}catch(e){t(e)}}))},this.pauseRecording=function(){return new Promise((function(e,t){try{s.recordRTC.pauseRecording(),e()}catch(e){t(e)}}))},this.resumeRecording=function(){return new Promise((function(e,t){try{s.recordRTC.resumeRecording(),e()}catch(e){t(e)}}))},this.getDataURL=function(e){return new Promise((function(e,t){try{s.recordRTC.getDataURL((function(t){e(t)}))}catch(e){t(e)}}))},this.getBlob=function(){return new Promise((function(e,t){try{e(s.recordRTC.getBlob())}catch(e){t(e)}}))},this.getInternalRecorder=function(){return new Promise((function(e,t){try{e(s.recordRTC.getInternalRecorder())}catch(e){t(e)}}))},this.reset=function(){return new Promise((function(e,t){try{e(s.recordRTC.reset())}catch(e){t(e)}}))},this.destroy=function(){return new Promise((function(e,t){try{e(s.recordRTC.destroy())}catch(e){t(e)}}))},this.getState=function(){return new Promise((function(e,t){try{e(s.recordRTC.getState())}catch(e){t(e)}}))},this.blob=null,this.version="5.6.2"},t.WebAssemblyRecorder=P}));class So{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 s=Math.min(i,this._current_word_bits_left),r=this._current_word>>>32-s;return this._current_word<<=s,this._current_word_bits_left-=s,t=t<<s|r,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(0!=(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 To{static _ebsp2rbsp(e){let t=e,i=t.byteLength,s=new Uint8Array(i),r=0;for(let e=0;e<i;e++)e>=2&&3===t[e]&&0===t[e-1]&&0===t[e-2]||(s[r]=t[e],r++);return new Uint8Array(s.buffer,0,r)}static parseSPS(e){let t=To._ebsp2rbsp(e),i=new So(t);i.readByte();let s=i.readByte();i.readByte();let r=i.readByte();i.readUEG();let a=To.getProfileString(s),o=To.getLevelString(r),n=1,l=420,h=[0,420,422,444],d=8;if((100===s||110===s||122===s||244===s||44===s||83===s||86===s||118===s||128===s||138===s||144===s)&&(n=i.readUEG(),3===n&&i.readBits(1),n<=3&&(l=h[n]),d=i.readUEG()+8,i.readUEG(),i.readBits(1),i.readBool())){let e=3!==n?8:12;for(let t=0;t<e;t++)i.readBool()&&(t<6?To._skipScalingList(i,16):To._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(),m=i.readBits(1);0===m&&i.readBits(1),i.readBits(1);let g=0,y=0,A=0,b=0;i.readBool()&&(g=i.readUEG(),y=i.readUEG(),A=i.readUEG(),b=i.readUEG());let v=1,_=1,w=0,S=!0,T=0,E=0;if(i.readBool()){if(i.readBool()){let e=i.readByte(),t=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],s=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];e>0&&e<16?(v=t[e-1],_=s[e-1]):255===e&&(v=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);S=i.readBool(),T=t,E=2*e,w=T/E}}let k=1;1===v&&1===_||(k=v/_);let C=0,x=0;if(0===n)C=1,x=2-m;else{C=3===n?1:2,x=(1===n?2:1)*(2-m)}let R=16*(p+1),D=16*(f+1)*(2-m);R-=(g+y)*C,D-=(A+b)*x;let L=Math.ceil(R*k);return i.destroy(),i=null,{profile_string:a,level_string:o,bit_depth:d,ref_frames:u,chroma_format:l,chroma_format_string:To.getChromaFormatString(l),frame_rate:{fixed:S,fps:w,fps_den:E,fps_num:T},sar_ratio:{width:v,height:_},codec_size:{width:R,height:D},present_size:{width:L,height:D}}}static parseSPS$2(e){let t=e.subarray(1,4),i="avc1.";for(let e=0;e<3;e++){let s=t[e].toString(16);s.length<2&&(s="0"+s),i+=s}let s=To._ebsp2rbsp(e),r=new So(s);r.readByte();let a=r.readByte();r.readByte();let o=r.readByte();r.readUEG();let n=To.getProfileString(a),l=To.getLevelString(o),h=1,d=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)&&(h=r.readUEG(),3===h&&r.readBits(1),h<=3&&(d=c[h]),u=r.readUEG()+8,p=r.readUEG()+8,r.readBits(1),r.readBool())){let e=3!==h?8:12;for(let t=0;t<e;t++)r.readBool()&&(t<6?To._skipScalingList(r,16):To._skipScalingList(r,64))}r.readUEG();let f=r.readUEG();if(0===f)r.readUEG();else if(1===f){r.readBits(1),r.readSEG(),r.readSEG();let e=r.readUEG();for(let t=0;t<e;t++)r.readSEG()}let m=r.readUEG();r.readBits(1);let g=r.readUEG(),y=r.readUEG(),A=r.readBits(1);0===A&&r.readBits(1),r.readBits(1);let b=0,v=0,_=0,w=0;r.readBool()&&(b=r.readUEG(),v=r.readUEG(),_=r.readUEG(),w=r.readUEG());let S=1,T=1,E=0,k=!0,C=0,x=0;if(r.readBool()){if(r.readBool()){let e=r.readByte(),t=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],i=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];e>0&&e<16?(S=t[e-1],T=i[e-1]):255===e&&(S=r.readByte()<<8|r.readByte(),T=r.readByte()<<8|r.readByte())}if(r.readBool()&&r.readBool(),r.readBool()&&(r.readBits(4),r.readBool()&&r.readBits(24)),r.readBool()&&(r.readUEG(),r.readUEG()),r.readBool()){let e=r.readBits(32),t=r.readBits(32);k=r.readBool(),C=t,x=2*e,E=C/x}}let R=1;1===S&&1===T||(R=S/T);let D=0,L=0;if(0===h)D=1,L=2-A;else{D=3===h?1:2,L=(1===h?2:1)*(2-A)}let I=16*(g+1),P=16*(y+1)*(2-A);I-=(b+v)*D,P-=(_+w)*L;let B=Math.ceil(I*R);return r.destroy(),r=null,{codec_mimetype:i,profile_idc:a,level_idc:o,profile_string:n,level_string:l,chroma_format_idc:h,bit_depth:u,bit_depth_luma:u,bit_depth_chroma:p,ref_frames:m,chroma_format:d,chroma_format_string:To.getChromaFormatString(d),frame_rate:{fixed:k,fps:E,fps_den:x,fps_num:C},sar_ratio:{width:S,height:T},codec_size:{width:I,height:P},present_size:{width:B,height:P}}}static _skipScalingList(e,t){let i=8,s=8,r=0;for(let a=0;a<t;a++)0!==s&&(r=e.readSEG(),s=(i+r+256)%256),i=0===s?i:s}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 Eo{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,s=this.read(e);return this.bufpos=t,this.bufoff=i,s}read_golomb(){let e;for(e=0;0===this.read(1)&&!this.iserro;e++);return(1<<e)+this.read(e)-1}}function ko(e){const t={},i=new DataView(e.buffer);let s=i.getUint8(0),r=i.getUint8(1);if(i.getUint8(2),i.getUint8(3),1!==s||0===r)return{};const a=1+(3&i.getUint8(4));if(3!==a&&4!==a)return{};let o=31&i.getUint8(5);if(0===o)return{};let n=6;for(let s=0;s<o;s++){let r=i.getUint16(n,!1);if(n+=2,0===r)continue;let a=new Uint8Array(e.buffer,n,r);n+=r;let o=To.parseSPS(a);if(0!==s)continue;t.sps=a,t.timescale=1e3,t.codecWidth=o.codec_size.width,t.codecHeight=o.codec_size.height,t.presentWidth=o.present_size.width,t.presentHeight=o.present_size.height,t.profile=o.profile_string,t.level=o.level_string,t.bitDepth=o.bit_depth,t.chromaFormat=o.chroma_format,t.sarRatio=o.sar_ratio,t.frameRate=o.frame_rate,!1!==o.frame_rate.fixed&&0!==o.frame_rate.fps_num&&0!==o.frame_rate.fps_den||(t.frameRate={fixed:!0,fps:25,fps_num:25e3,fps_den:1e3});let l=t.frameRate.fps_den,h=t.frameRate.fps_num;t.refSampleDuration=t.timescale*(l/h);let d=a.subarray(1,4),c="avc1.";for(let e=0;e<3;e++){let t=d[e].toString(16);t.length<2&&(t="0"+t),c+=t}t.codec=c}let l=i.getUint8(n);if(0===l)return{};n++;for(let s=0;s<l;s++){let s=i.getUint16(n,!1);if(n+=2,0===s)continue;let r=new Uint8Array(e.buffer,n,s);n+=s,t.pps=r}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]),s=new Uint8Array(e+4);s.set(i,0),s.set(t.sps,4),t.sps=s}if(t.pps){const e=t.pps.byteLength,i=new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e]),s=new Uint8Array(e+4);s.set(i,0),s.set(t.pps,4),t.pps=s}return t}function Co(e){let{sps:t,pps:i}=e,s=8+t.byteLength+1+2+i.byteLength,r=!1;const a=To.parseSPS$2(t);66!==t[3]&&77!==t[3]&&88!==t[3]&&(r=!0,s+=4);let o=new Uint8Array(s);o[0]=1,o[1]=t[1],o[2]=t[2],o[3]=t[3],o[4]=255,o[5]=225;let n=t.byteLength;o[6]=n>>>8,o[7]=255&n;let l=8;o.set(t,8),l+=n,o[l]=1;let h=i.byteLength;o[l+1]=h>>>8,o[l+2]=255&h,o.set(i,l+3),l+=3+h,r&&(o[l]=252|a.chroma_format_idc,o[l+1]=248|a.bit_depth_luma-8,o[l+2]=248|a.bit_depth_chroma-8,o[l+3]=0,l+=4);const d=[23,0,0,0,0],c=new Uint8Array(d.length+o.byteLength);return c.set(d,0),c.set(o,d.length),c}function xo(e,t){let i=[];i[0]=t?23:39,i[1]=1,i[2]=0,i[3]=0,i[4]=0;const s=new Uint8Array(i.length+e.byteLength);return s.set(i,0),s.set(e,i.length),s}function Ro(e){return 31&e[0]}function Do(e){return e===Tt}function Lo(e){return!function(e){return e===_t||e===wt}(e)&&!Do(e)}function Io(e){return e===St}const Po=e=>{let t=e,i=t.byteLength,s=new Uint8Array(i),r=0;for(let e=0;e<i;e++)e>=2&&3===t[e]&&0===t[e-1]&&0===t[e-2]||(s[r]=t[e],r++);return new Uint8Array(s.buffer,0,r)},Bo=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 Mo(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<24>>>0)+(e[t+1]<<16)+(e[t+2]<<8)+(e[t+3]||0)}function Fo(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;if(e.length<4)return;const i=e.length,s=[];let r,a=0;for(;a+t<i;)if(r=Mo(e,a),3===t&&(r>>>=8),a+=t,r){if(a+r>i)break;s.push(e.subarray(a,a+r)),a+=r}return s}function Uo(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 s=new Uint8Array(t+4);return s.set(i,0),s.set(e,4),s}function Oo(e){let t={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 s=e[22],r=e.slice(23);for(let e=0;e<s&&!(r.length<3);e++){let e=63&r[0],s=r[1]<<8|r[2];r=r.slice(3);for(let a=0;a<s&&!(r.length<2);a++){let s=r[0]<<8|r[1];if(r.length<2+s)break;if(r=r.slice(2),33==e){let e=new Uint8Array(s);e.set(r.slice(0,s),0),i.psps=No(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)}r=r.slice(s)}}}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.videoType=Ri,t}function No(e,t){let i={},s=e.length,r=[],a=new Eo(e);a.read(1),a.read(6),a.read(6),a.read(3);for(let e=2;e<s;e++)e+2<s&&3==a.look(24)?(r.push(a.read(8)),r.push(a.read(8)),e+=2,a.read(8)):r.push(a.read(8));let o=new Uint8Array(r),n=new Eo(o);if(i.sps_video_parameter_set_id=n.read(4),i.sps_max_sub_layers_minus1=n.read(3),i.sps_temporal_id_nesting_flag=n.read(1),i.profile_tier_level=function(e,t,i){let s={};s.profile_space=e.read(2),s.tier_flag=e.read(1),s.profile_idc=e.read(5),s.profile_compatibility_flags=e.read(32),s.general_progressive_source_flag=e.read(1),s.general_interlaced_source_flag=e.read(1),s.general_non_packed_constraint_flag=e.read(1),s.general_frame_only_constraint_flag=e.read(1),e.read(32),e.read(12),s.level_idc=e.read(8),s.sub_layer_profile_present_flag=[],s.sub_layer_level_present_flag=[];for(let t=0;t<i;t++)s.sub_layer_profile_present_flag[t]=e.read(1),s.sub_layer_level_present_flag[t]=e.read(1);if(i>0)for(let t=i;t<8;t++)e.read(2);s.sub_layer_profile_space=[],s.sub_layer_tier_flag=[],s.sub_layer_profile_idc=[],s.sub_layer_profile_compatibility_flag=[],s.sub_layer_progressive_source_flag=[],s.sub_layer_interlaced_source_flag=[],s.sub_layer_non_packed_constraint_flag=[],s.sub_layer_frame_only_constraint_flag=[],s.sub_layer_level_idc=[];for(let t=0;t<i;t++)s.sub_layer_profile_present_flag[t]&&(s.sub_layer_profile_space[t]=e.read(2),s.sub_layer_tier_flag[t]=e.read(1),s.sub_layer_profile_idc[t]=e.read(5),s.sub_layer_profile_compatibility_flag[t]=e.read(32),s.sub_layer_progressive_source_flag[t]=e.read(1),s.sub_layer_interlaced_source_flag[t]=e.read(1),s.sub_layer_non_packed_constraint_flag[t]=e.read(1),s.sub_layer_frame_only_constraint_flag[t]=e.read(1),e.read(32),e.read(12)),s.sub_layer_level_present_flag[t]?s.sub_layer_level_idc[t]=e.read(8):s.sub_layer_level_idc[t]=1;return s}(n,0,i.sps_max_sub_layers_minus1),i.sps_seq_parameter_set_id=n.read_golomb(),i.chroma_format_idc=n.read_golomb(),3==i.chroma_format_idc?i.separate_colour_plane_flag=n.read(1):i.separate_colour_plane_flag=0,i.pic_width_in_luma_samples=n.read_golomb(),i.pic_height_in_luma_samples=n.read_golomb(),i.conformance_window_flag=n.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=n.read_golomb()*t,i.conf_win_right_offset=n.read_golomb()*t,i.conf_win_top_offset=n.read_golomb()*e,i.conf_win_bottom_offset=n.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 jo(e){let{vps:t,pps:i,sps:s}=e,r={configurationVersion:1};const a=(e=>{let t=Po(e),i=new So(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()}})(t),o=(e=>{let t=Po(e),i=new So(t);i.readByte(),i.readByte();let s=0,r=0,a=0,o=0;i.readBits(4);let n=i.readBits(3);i.readBool();let l=i.readBits(2),h=i.readBool(),d=i.readBits(5),c=i.readByte(),u=i.readByte(),p=i.readByte(),f=i.readByte(),m=i.readByte(),g=i.readByte(),y=i.readByte(),A=i.readByte(),b=i.readByte(),v=i.readByte(),_=i.readByte(),w=[],S=[];for(let e=0;e<n;e++)w.push(i.readBool()),S.push(i.readBool());if(n>0)for(let e=n;e<8;e++)i.readBits(2);for(let e=0;e<n;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 T=i.readUEG();3==T&&i.readBits(1);let E=i.readUEG(),k=i.readUEG();i.readBool()&&(s+=i.readUEG(),r+=i.readUEG(),a+=i.readUEG(),o+=i.readUEG());let C=i.readUEG(),x=i.readUEG(),R=i.readUEG();for(let e=i.readBool()?0:n;e<=n;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 D=i.readUEG(),L=0;for(let e=0;e<D;e++){let t=!1;if(0!==e&&(t=i.readBool()),t){e===D&&i.readUEG(),i.readBool(),i.readUEG();let t=0;for(let e=0;e<=L;e++){let e=i.readBool(),s=!1;e||(s=i.readBool()),(e||s)&&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,F=!1,U=1,O=1;if(i.readBool(),i.readBool(),i.readBool()){if(i.readBool()){let e=i.readByte(),t=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],s=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];e>0&&e<16?(B=t[e-1],M=s[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&&(s+=i.readUEG(),r+=i.readUEG(),a+=i.readUEG(),o+=i.readUEG()),i.readBool()&&(U=i.readBits(32),O=i.readBits(32),i.readBool()&&(i.readUEG(),i.readBool()))){let e=!1,t=!1,s=!1;e=i.readBool(),t=i.readBool(),(e||t)&&(s=i.readBool(),s&&(i.readByte(),i.readBits(5),i.readBool(),i.readBits(5)),i.readBits(4),i.readBits(4),s&&i.readBits(4),i.readBits(5),i.readBits(5),i.readBits(5));for(let r=0;r<=n;r++){let r=i.readBool();F=r;let a=!1,o=1;r||(a=i.readBool());let n=!1;if(a?i.readSEG():n=i.readBool(),n||(cpbcnt=i.readUEG()+1),e)for(let e=0;e<o;e++)i.readUEG(),i.readUEG(),s&&(i.readUEG(),i.readUEG());if(t)for(let e=0;e<o;e++)i.readUEG(),i.readUEG(),s&&(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.${d}.1.L${_}.B0`,j=E,G=k,z=1;return 1!==B&&1!==M&&(z=B/M),i.destroy(),i=null,{codec_mimetype:N,level_string:($=_,($/30).toFixed(1)),profile_idc:d,bit_depth:C+8,ref_frames:1,chroma_format:T,chroma_format_string:Bo(T),general_level_idc:_,general_profile_space:l,general_tier_flag:h,general_profile_idc:d,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:m,general_constraint_indicator_flags_2:g,general_constraint_indicator_flags_3:y,general_constraint_indicator_flags_4:A,general_constraint_indicator_flags_5:b,general_constraint_indicator_flags_6:v,min_spatial_segmentation_idc:P,constant_frame_rate:0,chroma_format_idc:T,bit_depth_luma_minus8:C,bit_depth_chroma_minus8:x,frame_rate:{fixed:F,fps:O/U,fps_den:U,fps_num:O},sar_ratio:{width:B,height:M},codec_size:{width:j,height:G},present_size:{width:j*z,height:G}};var $})(s),n=(e=>{let t=Po(e),i=new So(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 s=i.readBool(),r=i.readBool(),a=1;return r&&s?a=0:r?a=3:s&&(a=2),{parallelismType:a}})(i);r=Object.assign(r,a,o,n);let l=23+(5+t.byteLength)+(5+s.byteLength)+(5+i.byteLength),h=new Uint8Array(l);h[0]=1,h[1]=(3&r.general_profile_space)<<6|(r.general_tier_flag?1:0)<<5|31&r.general_profile_idc,h[2]=r.general_profile_compatibility_flags_1||0,h[3]=r.general_profile_compatibility_flags_2||0,h[4]=r.general_profile_compatibility_flags_3||0,h[5]=r.general_profile_compatibility_flags_4||0,h[6]=r.general_constraint_indicator_flags_1||0,h[7]=r.general_constraint_indicator_flags_2||0,h[8]=r.general_constraint_indicator_flags_3||0,h[9]=r.general_constraint_indicator_flags_4||0,h[10]=r.general_constraint_indicator_flags_5||0,h[11]=r.general_constraint_indicator_flags_6||0,h[12]=60,h[13]=240|(3840&r.min_spatial_segmentation_idc)>>8,h[14]=255&r.min_spatial_segmentation_idc,h[15]=252|3&r.parallelismType,h[16]=252|3&r.chroma_format_idc,h[17]=248|7&r.bit_depth_luma_minus8,h[18]=248|7&r.bit_depth_chroma_minus8,h[19]=0,h[20]=0,h[21]=(3&r.constant_frame_rate)<<6|(7&r.num_temporal_layers)<<3|(r.temporal_id_nested?1:0)<<2|3,h[22]=3,h[23]=128|Ct,h[24]=0,h[25]=1,h[26]=(65280&t.byteLength)>>8,h[27]=(255&t.byteLength)>>0,h.set(t,28),h[23+(5+t.byteLength)+0]=128|xt,h[23+(5+t.byteLength)+1]=0,h[23+(5+t.byteLength)+2]=1,h[23+(5+t.byteLength)+3]=(65280&s.byteLength)>>8,h[23+(5+t.byteLength)+4]=(255&s.byteLength)>>0,h.set(s,23+(5+t.byteLength)+5),h[23+(5+t.byteLength+5+s.byteLength)+0]=128|Rt,h[23+(5+t.byteLength+5+s.byteLength)+1]=0,h[23+(5+t.byteLength+5+s.byteLength)+2]=1,h[23+(5+t.byteLength+5+s.byteLength)+3]=(65280&i.byteLength)>>8,h[23+(5+t.byteLength+5+s.byteLength)+4]=(255&i.byteLength)>>0,h.set(i,23+(5+t.byteLength+5+s.byteLength)+5);const d=[28,0,0,0,0],c=new Uint8Array(d.length+h.byteLength);return c.set(d,0),c.set(h,d.length),c}function Go(e,t){let i=[];i[0]=t?28:44,i[1]=1,i[2]=0,i[3]=0,i[4]=0;const s=new Uint8Array(i.length+e.byteLength);return s.set(i,0),s.set(e,i.length),s}function zo(e){return(126&e[0])>>1}function $o(e){return!function(e){return e>=32&&e<=40}(e)}function Wo(e){return e>=16&&e<=21}class Ho 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===ct}get isH265(){return this.codecId===ut}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,s){}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 s=e.slice(5);if(this.codecId=t,this.metaInfo.avcc=s,t===ct)i=ko(s);else if(t===ut){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 s=e[t+1]|e[t]<<8;t+=2;const r=e.slice(t,t+s);t+=s;const a=e[t];if((63&a)!==xt)return console.warn(`parseHEVCDecoderVPSAndSPSAndPPS and sps tag is ${a}`),{};t+=2,t+=1;const o=e[t+1]|e[t]<<8;t+=2;const n=e.slice(t,t+o);t+=o;const l=e[t];if((63&l)!==Rt)return console.warn(`parseHEVCDecoderVPSAndSPSAndPPS and pps tag is ${l}`),{};t+=2,t+=1;const h=e[t+1]|e[t]<<8;t+=2;const d=e.slice(t,t+h),c=new Uint8Array([o>>>24&255,o>>>16&255,o>>>8&255,255&o]),u=new Uint8Array([h>>>24&255,h>>>16&255,h>>>8&255,255&h]),p=new Uint8Array([s>>>24&255,s>>>16&255,s>>>8&255,255&s]),f=new Uint8Array(o+4);f.set(c,0),f.set(n,4);const m=new Uint8Array(h+4);m.set(u,0),m.set(d,4);const g=new Uint8Array(s+4);return g.set(p,0),g.set(r,4),{sps:f,pps:m,vps:g}}(s);const t=Oo(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 s=null;t===mt?(s=function(e){let t={},i=new Zs(e);return i.read(16),t.object_type=er(i),t.sample_rate=tr(i,t),t.chan_config=i.read(4),t.chan_config<sr.length&&(t.channels=sr[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=tr(i,t),t.object_type=er(i)),{...t,channelCount:t.channels,sampleRate:t.sample_rate}}(e),s&&(s.channelCount&&(this.audioMetaInfo.channelCount=s.channelCount),s.codec&&(this.audioMetaInfo.codec=s.codec),s.originalCodec&&(this.audioMetaInfo.originalCodec=s.originalCodec),s.config&&(this.audioMetaInfo.config=s.config),s.sampleRate&&(this.audioMetaInfo.sampleRate=s.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 Vo extends Ho{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,s=EBML.tools,r=new FileReader;return new Promise(((a,o)=>{r.onload=function(e){i.decode(this.result).forEach((function(e){t.read(e)})),t.stop();const r=s.makeMetadataSeekable(t.metadatas,t.duration,t.cues),o=this.result.slice(t.metadataSize),n=new Blob([r,o],{type:"video/webm"});a(n)},r.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()===z?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(Ze.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=wo(i,t)}catch(t){return e.error("RecorderRTC","startRecord error",t),void this.player.emitError(Ze.recordCreateError,t)}this.recorder&&(this._isRecording=!0,this.player.emit(Ze.recording,!0),this.recorder.startRecording(),e.log("RecorderRTC","start recording"),this.player.emit(Ze.recordStart),this.startRecordingInterval())}startRecordingInterval(){this.stopRecordingInterval(),this.recordingInterval=window.setInterval((()=>{this.player.emit(Ze.recordingTimestamp,this._recordingTimestamp)}),1e3)}stopRecordAndSave(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:lt,t=arguments.length>1?arguments[1]:void 0;return new Promise(((i,s)=>{this.recorder&&this._isRecording||s("recorder is not ready"),t&&this.setFileName(t),this.recorder.stopRecording((()=>{this.player.debug.log("RecorderRTC","stop recording");const t=(this.fileName||lr())+"."+v;if(this.recorder.getBlob(),e===ht){const e=this.recorder.getBlob();i(e),this.player.emit(Ze.recordBlob,e)}else i(),this.recorder.save(t);this.player.emit(Ze.recordEnd),this._reset(),this.player.emit(Ze.recording,!1)}))}))}getToTalByteLength(){return this.totalByteLength}getTotalDuration(){return this.recordTime}getType(){return v}initMetaData(){}}class Jo{static init(){Jo.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 Jo.types)Jo.types.hasOwnProperty(e)&&(Jo.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let e=Jo.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,s=Array.prototype.slice.call(arguments,1),r=s.length;for(let e=0;e<r;e++)t+=s[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<r;e++)i.set(s[e],a),a+=s[e].byteLength;return i}static generateInitSegment(e,t,i){let s=Jo.box(Jo.types.ftyp,Jo.constants.FTYP),r=Jo.box(Jo.types.free),a=8,o=new Uint8Array;i+a>=Math.pow(2,32)-1?(a=16,o=new Uint8Array(i+a),o.set(new Uint8Array([0,0,0,1]),0),o.set(Jo.types.mdat,4),o.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)):(o=new Uint8Array(i+a),o[0]=i+8>>>24&255,o[1]=i+8>>>16&255,o[2]=i+8>>>8&255,o[3]=i+8&255,o.set(Jo.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=s.byteLength+r.byteLength+a;let n=t.data;o.set(n,a),a+=n.byteLength}}let n=Jo.moov(e,t),l=new Uint8Array(s.byteLength+n.byteLength+o.byteLength+r.byteLength);return l.set(s,0),l.set(r,s.byteLength),l.set(o,s.byteLength+r.byteLength),l.set(n,s.byteLength+o.byteLength+r.byteLength),l}static moov(e,t){let i=e.timescale,s=e.duration,r=t.length,a=Jo.mvhd(i,s),o=new Uint8Array;for(let e=0;e<r;e++){let i=Jo.trak(t[e]),s=new Uint8Array(i.byteLength+o.byteLength);s.set(o,0),s.set(i,o.byteLength),o=new Uint8Array(s.byteLength),o.set(s,0)}return Jo.box(Jo.types.moov,a,o)}static mvhd(e,t){return Jo.box(Jo.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 Jo.box(Jo.types.trak,Jo.tkhd(e),Jo.mdia(e))}static tkhd(e){let t=e.id,i=e.duration,s=e.presentWidth,r=e.presentHeight;return Jo.box(Jo.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,s>>>8&255,255&s,0,0,r>>>8&255,255&r,0,0]))}static edts(e,t){return Jo.box(Jo.types.edts,Jo.elst(e,t))}static elst(e,t){let i=0;for(let s=0;s<t;s++)"video"===e[s].type&&(i+=e[s].duration);let s=e[t].duration;return 0===i&&(i=e[t].refSampleDuration),Jo.box(Jo.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,s>>>24&255,s>>>16&255,s>>>8&255,255&s,0,0,0,0,0,1,0,0]))}static mdia(e){return Jo.box(Jo.types.mdia,Jo.mdhd(e),Jo.hdlr(e),Jo.minf(e))}static mdhd(e){let t=e.timescale/e.refSampleDuration,i=t*e.duration/e.timescale;return Jo.box(Jo.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=Jo.constants.HDLR_VIDEO,Jo.box(Jo.types.hdlr,t)}static minf(e){let t=null;return t=Jo.box(Jo.types.vmhd,Jo.constants.VMHD),Jo.box(Jo.types.minf,t,Jo.dinf(),Jo.stbl(e))}static dinf(){return Jo.box(Jo.types.dinf,Jo.box(Jo.types.dref,Jo.constants.DREF))}static stbl(e){let t=e.samples,i=[{No:1,num:0,sampleDelte:1,chunkNo:1,duration:t[0].duration}],s=[t[0].duration],r=t.length;for(let e=0;e<r;e++)for(let r=0;r<i.length;r++)t[e].duration===i[r].duration?i[r].num++:s.indexOf(t[e].duration)<0&&(s.push(t[e].duration),i.push({No:2,num:0,sampleDelte:1,chunkNo:e+1,duration:t[e].duration}));return Jo.box(Jo.types.stbl,Jo.stsd(e),Jo.stts(i),Jo.stss(t),Jo.stsc(i),Jo.stsz(t),Jo.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]),s=i.byteLength,r=new Uint8Array(s+8*t);r.set(i,0);for(let i=0;i<t;i++)r.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]),s),s+=8;return Jo.box(Jo.types.stts,r)}static stss(e){let t=[],i=e.length;for(let s=0;s<i;s++)!0===e[s].isKeyframe&&t.push(s+1);let s=t.length,r=new Uint8Array([0,0,0,0,s>>>24&255,s>>>16&255,s>>>8&255,255&s]),a=r.byteLength,o=new Uint8Array(a+4*s);o.set(r,0);for(let e=0;e<s;e++)o.set(new Uint8Array([t[e]>>>24&255,t[e]>>>16&255,t[e]>>>8&255,255&t[e]]),a),a+=4;return Jo.box(Jo.types.stss,o)}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]),s=i.byteLength,r=new Uint8Array(s+12*t);r.set(i,0);for(let i=0;i<t;i++){let t=e[i].chunkNo,a=e[i].num,o=e[i].sampleDelte;r.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,o>>>24&255,o>>>16&255,o>>>8&255,255&o]),s),s+=12}return Jo.box(Jo.types.stsc,r)}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]),s=i.byteLength,r=new Uint8Array(s+4*t);r.set(i,0);for(let i=0;i<t;i++){let t=e[i].data.byteLength;r.set(new Uint8Array([t>>>24&255,t>>>16&255,t>>>8&255,255&t]),s),s+=4}return Jo.box(Jo.types.stsz,r)}static stco(e,t){let i=t[0].chunkOffset;return Jo.box(Jo.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?Jo.box(Jo.types.stsd,Jo.constants.STSD_PREFIX,Jo.mp3(e)):Jo.box(Jo.types.stsd,Jo.constants.STSD_PREFIX,Jo.mp4a(e)):"avc"===e.videoType?Jo.box(Jo.types.stsd,Jo.constants.STSD_PREFIX,Jo.avc1(e)):Jo.box(Jo.types.stsd,Jo.constants.STSD_PREFIX,Jo.hvc1(e))}static mp3(e){let t=e.channelCount,i=e.sampleRate,s=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 Jo.box(Jo.types[".mp3"],s)}static mp4a(e){let t=e.channelCount,i=e.sampleRate,s=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 Jo.box(Jo.types.mp4a,s,Jo.esds(e))}static esds(e){let t=e.config||[],i=t.length,s=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 Jo.box(Jo.types.esds,s)}static avc1(e){let t=e.avcc,i=e.codecWidth,s=e.codecHeight,r=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,s>>>8&255,255&s,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 Jo.box(Jo.types.avc1,r,Jo.box(Jo.types.avcC,t))}static hvc1(e){let t=e.avcc;const i=e.codecWidth,s=e.codecHeight;let r=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,s>>>8&255,255&s,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 Jo.box(Jo.types.hvc1,r,Jo.box(Jo.types.hvcC,t))}static mvex(e){return Jo.box(Jo.types.mvex,Jo.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 Jo.box(Jo.types.trex,i)}static moof(e,t){return Jo.box(Jo.types.moof,Jo.mfhd(e.sequenceNumber),Jo.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 Jo.box(Jo.types.mfhd,t)}static traf(e,t){let i=e.id,s=Jo.box(Jo.types.tfhd,new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i])),r=Jo.box(Jo.types.tfdt,new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t])),a=Jo.sdtp(e),o=Jo.trun(e,a.byteLength+16+16+8+16+8+8);return Jo.box(Jo.types.traf,s,r,o,a)}static sdtp(e){let t=e.samples||[],i=t.length,s=new Uint8Array(4+i);for(let e=0;e<i;e++){let i=t[e].flags;s[e+4]=i.isLeading<<6|i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy}return Jo.box(Jo.types.sdtp,s)}static trun(e,t){let i=e.samples||[],s=i.length,r=12+16*s,a=new Uint8Array(r);t+=8+r,a.set([0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,255&s,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0);for(let e=0;e<s;e++){let t=i[e].duration,s=i[e].size,r=i[e].flags,o=i[e].cts;a.set([t>>>24&255,t>>>16&255,t>>>8&255,255&t,s>>>24&255,s>>>16&255,s>>>8&255,255&s,r.isLeading<<2|r.dependsOn,r.isDependedOn<<6|r.hasRedundancy<<4|r.isNonSync,0,0,o>>>24&255,o>>>16&255,o>>>8&255,255&o],12+16*e)}return Jo.box(Jo.types.trun,a)}static mdat(e){return Jo.box(Jo.types.mdat,e)}}Jo.init();class Ko extends Ho{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(Ze.recording,!0),e.log(this.TAG_NAME,"start recording"),this.player.emit(Ze.recordStart),this.startRecordingInterval()}startRecordingInterval(){this.stopRecordingInterval(),this.recordingInterval=window.setInterval((()=>{this.player.emit(Ze.recordingTimestamp,this.getTotalDuration())}),1e3)}formatFmp4Track(e,t,i,s){return{id:1,sequenceNumber:++this.sequenceNumber,size:e.byteLength,dts:i,cts:s,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,s){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,s)}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 s=new Uint8Array(e.byteLength+i.byteLength);s.set(e,0),s.set(i,e.byteLength),t.data=s}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 s=new Uint8Array(e.byteLength+i.byteLength);s.set(e,0),s.set(i,e.byteLength),t.data=s}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 b}getToTalByteLength(){return this.totalByteLength+this.totalAudioByteLength}stopRecordAndSave(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:lt,t=arguments.length>1?arguments[1]:void 0;return new Promise(((i,s)=>{if(!this.isRecording)return this.player.debug.error(this.TAG_NAME,"stop recording fail, isRecording is false "),s("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 "),s("stop recording fail, this.bufferList.length is 0 ");t&&this.setFileName(t);const r={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},o=[r];a.samples.length>0&&o.push(a),this.player.debug.log(this.TAG_NAME,`trackList length is ${o.length}`);const n=Jo.generateInitSegment({timescale:1e3,duration:this.totalDuration},o,this.totalByteLength+this.totalAudioByteLength);this.player.debug.log(this.TAG_NAME,"stop recording");const l=new Blob([n],{type:"application/octet-stream"});if(e===ht)i(l),this.player.emit(Ze.recordBlob,l);else{i();Pr((this.fileName||lr())+"."+b,l)}this._reset(),this.player.emit(Ze.recording,!1)}))}}class qo extends Ho{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(Ze.recording,!0),e.log(this.TAG_NAME,"start recording"),this.player.emit(Ze.recordStart),this.startRecordingInterval()}startRecordingInterval(){this.stopRecordingInterval(),this.recordingInterval=window.setInterval((()=>{this.player.emit(Ze.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,Fe,i)}addAudio(e,t){this._setStartTime(t);const i=this._getBufferTs(t);this.hasAudio=!0,this._createBufferItem(e,Me,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 s=this._createFlvPacket(e,t,i),r=this._createFlvTag(s);this.totalByteLength+=r.byteLength,this.bufferList.push(r)}_createFlvTag(e){let t=11+e.header.length,i=new Uint8Array(t+4);i[0]=e.header.type;let s=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,s.setUint32(t,t),i.set(e.payload.subarray(0,e.header.length),11),i}_createFlvPacket(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return{header:{length:e?e.length:0,timestamp:i,type:t},payload:e}}stopRecordAndSave(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:lt,t=arguments.length>1?arguments[1]:void 0;return new Promise(((i,s)=>{if(!this.isRecording)return this.player.debug.error(this.TAG_NAME,"stop recording fail, isRecording is false "),s("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 "),s("stop recording fail, this.bufferList.length is 0 ");t&&this.setFileName(t);const r=new Uint8Array([70,76,86,1,0,0,0,0,9,0,0,0,0]);this.hasVideo&&(r[4]|=1),this.hasAudio&&(r[4]|=4);let a=[r];if(this.flvMetaData){const e=this._createFlvPacket(this.flvMetaData,Ue),t=this._createFlvTag(e);a.push(t)}if(this.videoSequenceHeader){const e=this._createFlvPacket(this.videoSequenceHeader,Fe),t=this._createFlvTag(e);a.push(t)}if(this.aacSequenceHeader){const e=this._createFlvPacket(this.aacSequenceHeader,Me),t=this._createFlvTag(e);a.push(t)}const o=function(e){const t=e[0].constructor;return e.reduce(((e,i)=>{const s=new t((0|e.byteLength)+(0|i.byteLength));return s.set(e,0),s.set(i,0|e.byteLength),s}),new t)}(a.concat(this.bufferList));this.player.debug.log(this.TAG_NAME,"stop recording");const n=new Blob([o],{type:"application/octet-stream"});if(e===ht)i(n),this.player.emit(Ze.recordBlob,n);else{i();Pr((this.fileName||lr())+"."+_,n)}this._reset(),this.player.emit(Ze.recording,!1)}))}getTotalDuration(){let e=0;return null!==this.startTime&&null!==this.currentTime&&(e=this.currentTime-this.startTime),Math.round(e/1e3)}getType(){return _}getToTalByteLength(){return this.totalByteLength}}const Yo={init:0,findFirstStartCode:1,findSecondStartCode:2};class Qo extends t{constructor(e){super(),this.player=e,this.isDestroyed=!1,this.reset()}destroy(){this.isDestroyed=!1,this.off(),this.reset()}reset(){this.stats=Yo.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==Yo.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=Yo.findFirstStartCode,this.fisrtStartCodeOffset=this.parsedOffset,this.parsedOffset+=2,e=!0;break}this.parsedOffset++}else this.parsedOffset++;if(e)continue;break}if(this.state==Yo.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=Yo.findSecondStartCode,this.secondStartCodeOffset=this.parsedOffset,this.parsedOffset+=2,e=!0;break}this.parsedOffset++}else this.parsedOffset++;if(e)continue;break}if(this.state==Yo.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=Yo.findFirstStartCode}}}}class Xo extends Ho{constructor(e){super(e),this.TAG_NAME="recorderWasmMP4",this._reset(),this.wasmMp4Recorder=new window.JessibucaProMp4Recorder({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 b}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(),s={};if(this.codecId){const e={type:this.codecId,width:i.width,height:i.height,extraData:this.metaInfo.avcc};s.video=e,this.hasVideo=!0}if(t.encTypeCode){this.isG711=t.encTypeCode===gt||t.encTypeCode===yt;const e={type:t.encTypeCode,sampleRate:t.sampleRate,channels:t.channels,extraData:this.audioMetaInfo.extraData,depth:t.depth};this.audioCodeId=t.encTypeCode,s.audio=e,this.hasAudio=!0}this.wasmMp4Recorder.startRecord(s).then((()=>{this._isRecording=!0,this.player.emit(Ze.recording,!0),e.log(this.TAG_NAME,"start recording"),this.player.emit(Ze.recordStart),this.startRecordingInterval()})).catch((t=>{e.error(this.TAG_NAME,"startRecord error",t),this.player.emitError(Ze.recordCreateError,t)}))}startRecordingInterval(){this.stopRecordingInterval(),this.recordingInterval=window.setInterval((()=>{this.player.emit(Ze.recordingTimestamp,this.getTotalDuration())}),1e3)}stopRecordAndSave(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:lt,t=arguments.length>1?arguments[1]:void 0;return new Promise(((i,s)=>this.isRecording?0===this.totalDuration?(this.player.debug.error(this.TAG_NAME,"stop recording fail, totalDuration is 0 "),s("stop recording fail, totalDuration is 0 ")):(t&&this.setFileName(t),void this.wasmMp4Recorder.stopRecord().then((t=>{if(e===ht)i(t),this.player.emit(Ze.recordBlob,t);else{i();const e=this.isG711?w:b;Pr((this.fileName||lr())+"."+e,t)}})).catch((e=>{this.player.debug.error(this.TAG_NAME,"stopRecord error",e),s(e)})).finally((()=>{this._reset(),this.player.emit(Ze.recording,!1)}))):(this.player.debug.error(this.TAG_NAME,"stop recording fail, isRecording is false "),s("stop recording fail, isRecording is false "))))}handleAddAudioTrack(e,t){this.audioCodeId===At?(this.mp3Demuxer||(this.mp3Demuxer=new Qo(this.player),this.mp3Demuxer.on("data",((e,t)=>{this._handleAddAudioTrack(e,t)}))),this.mp3Demuxer.dispatch(e,t)):this._handleAddAudioTrack(e,t)}_handleAddAudioTrack(e,t){fa(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,s){fa(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:s})}}class Zo{constructor(e){return new(Zo.getLoaderFactory(e._opt))(e)}static getLoaderFactory(e){if(e.recordType===b){if(e.useWasm||e.useMSE||e.useWCS)return window.JessibucaProMp4Recorder&&e.mp4RecordUseWasm?Xo:Ko}else if(e.recordType===_)return qo;return Vo}}function en(e,t,i){let s=e;if(t+i<s.length){for(;i--;)if(128!=(192&s[++t]))return!1;return!0}return!1}function tn(e){let t=[],i=e,s=0,r=e.length;for(;s<r;)if(i[s]<128)t.push(String.fromCharCode(i[s])),++s;else{if(i[s]<192);else if(i[s]<224){if(en(i,s,1)){let e=(31&i[s])<<6|63&i[s+1];if(e>=128){t.push(String.fromCharCode(65535&e)),s+=2;continue}}}else if(i[s]<240){if(en(i,s,2)){let e=(15&i[s])<<12|(63&i[s+1])<<6|63&i[s+2];if(e>=2048&&55296!=(63488&e)){t.push(String.fromCharCode(65535&e)),s+=3;continue}}}else if(i[s]<248&&en(i,s,3)){let e=(7&i[s])<<18|(63&i[s+1])<<12|(63&i[s+2])<<6|63&i[s+3];if(e>65536&&e<1114112){e-=65536,t.push(String.fromCharCode(e>>>10|55296)),t.push(String.fromCharCode(1023&e|56320)),s+=4;continue}}t.push(String.fromCharCode(65533)),++s}return t.join("")}let sn=function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}();class rn{static parseScriptData(e,t,i){let s={};try{let r=rn.parseValue(e,t,i),a=rn.parseValue(e,t+r.size,i-r.size);s[r.data]=a.data}catch(e){console.error("AMF",e.toString())}return s}static parseObject(e,t,i){let s=rn.parseString(e,t,i),r=rn.parseValue(e,t+s.size,i-s.size),a=r.objectEnd;return{data:{name:s.data,value:r.data},size:s.size+r.size,objectEnd:a}}static parseVariable(e,t,i){return rn.parseObject(e,t,i)}static parseString(e,t,i){let s,r=new DataView(e,t,i).getUint16(0,!sn);return s=r>0?tn(new Uint8Array(e,t+2,r)):"",{data:s,size:2+r}}static parseLongString(e,t,i){let s,r=new DataView(e,t,i).getUint32(0,!sn);return s=r>0?tn(new Uint8Array(e,t+4,r)):"",{data:s,size:4+r}}static parseDate(e,t,i){let s=new DataView(e,t,i),r=s.getFloat64(0,!sn);return r+=60*s.getInt16(8,!sn)*1e3,{data:new Date(r),size:10}}static parseValue(e,t,i){let s,r=new DataView(e,t,i),a=1,o=r.getUint8(0),n=!1;try{switch(o){case 0:s=r.getFloat64(1,!sn),a+=8;break;case 1:s=!!r.getUint8(1),a+=1;break;case 2:{let r=rn.parseString(e,t+1,i-1);s=r.data,a+=r.size;break}case 3:{s={};let o=0;for(9==(16777215&r.getUint32(i-4,!sn))&&(o=3);a<i-4;){let r=rn.parseObject(e,t+a,i-a-o);if(r.objectEnd)break;s[r.data.name]=r.data.value,a+=r.size}if(a<=i-3){9===(16777215&r.getUint32(a-1,!sn))&&(a+=3)}break}case 8:{s={},a+=4;let o=0;for(9==(16777215&r.getUint32(i-4,!sn))&&(o=3);a<i-8;){let r=rn.parseVariable(e,t+a,i-a-o);if(r.objectEnd)break;s[r.data.name]=r.data.value,a+=r.size}if(a<=i-3){9===(16777215&r.getUint32(a-1,!sn))&&(a+=3)}break}case 9:s=void 0,a=1,n=!0;break;case 10:{s=[];let o=r.getUint32(1,!sn);a+=4;for(let r=0;r<o;r++){let r=rn.parseValue(e,t+a,i-a);s.push(r.data),a+=r.size}break}case 11:{let r=rn.parseDate(e,t+1,i-1);s=r.data,a+=r.size;break}case 12:{let r=rn.parseString(e,t+1,i-1);s=r.data,a+=r.size;break}default:a=i,console.warn("AMF","Unsupported AMF value type "+o)}}catch(e){console.error("AMF",e.toString())}return{data:s,size:a,objectEnd:n}}}function an(e){return rn.parseScriptData(e.buffer,e.byteOffset,e.byteLength)}class on{constructor(e){this.player=e,this.destroyResolve=null,this.workerClearTimeout=null,this.workerUrl=null;let t=e._opt.decoder;if(this.decoderWorkerCloseTimeout=null,fa(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}),X)}this.decoderWorker=new Worker(t),this._initDecoderWorker(),e.debug.log("decoderWorker",`init and decoder url is ${t}`),e.on(Ze.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:ze}),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(it.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 te:e.log("decoderWorker","onmessage:",te),this.decoderWorker&&this._initWork(),this.player.loaded||this.player.emit(Ze.load),this.player.emit(Ze.decoderWorkerInit);break;case he:e.log("decoderWorker","onmessage:",he,i.code),this.player._times.decodeStart||(this.player._times.decodeStart=lr()),this.player.video.updateVideoInfo({encTypeCode:i.code});break;case de:e.log("decoderWorker","onmessage:",de,i.codecId),this.player.recorder&&this.player.recorder.initMetaData(i.buffer,i.codecId);break;case oe:e.log("decoderWorker","onmessage:",oe,i.code),this.player.audio&&this.player.audio.updateAudioInfo({encTypeCode:i.code});break;case le:e.log("decoderWorker","onmessage:",le),this.player.recorder&&this.player.recorder.initAudioAacExtraData(i.buffer);break;case ie:if(e.log("decoderWorker","onmessage:",ie,`width:${i.w},height:${i.h}`),Br(i.w)||Br(i.h))return void this.player.emitError(it.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()===z)return void this.player.emitError(it.webglAlignmentError);this.player.video.initCanvasViewSize(),this.player._opt.playType===A&&(this.player.video.initFps(),this.player.video.initVideoDelay());break;case ae:if(e.log("decoderWorker","onmessage:",ae,`channels:${i.channels},sampleRate:${i.sampleRate}`),i.channels>2)return void this.player.emitError(it.audioChannelError,`audio channel is ${i.channels}, max is 2`);this.player.audio&&(this.player.audio.updateAudioInfo(i),this.player._opt.playType===g?this.player.audio.initScriptNode():this.player._opt.playType===A&&this.player.audio.initScriptNodeDelay());break;case se:if(!this.player.video)return void e.warn("decoderWorker","onmessage render but video is null");if(this.player.isPlayer()){if(fa(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(Ze.timeUpdate,i.ts),this.player.updateStats({dfps:!0,buf:i.delay}),this.player._times.videoStart||(this.player._times.videoStart=lr(),this.player.handlePlayToRenderTimes())}else this.player.isPlayback()&&(this.player.updateStats({dfps:!0}),fa(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 ce:this.player.recorder&&this.player.recorder.isRecording&&this.player._opt.recordType===b&&this.player.recorder.handleAddNaluTrack(i.buffer,i.isIFrame,i.ts,i.cts);break;case ne:this.player.recorder&&this.player.recorder.isRecording&&this.player._opt.recordType===b&&this.player.recorder.isWasmMp4()&&this.player.recorder.handleAddAudioTrack(i.buffer,i.ts);break;case ue:const{webcodecsDecoder:t,mseDecoder:s}=this.player;this.player.updateStats({buf:i.delay});const r=new Uint8Array(i.payload);this.player._opt.useWCS&&!this.player._opt.useOffscreen?t.decodeVideo(r,i.ts,i.isIFrame,i.cts):this.player._opt.useMSE&&s.decodeVideo(r,i.ts,i.isIFrame,i.cts);break;case pe:if(this.player._opt.useMSE){const e=new Uint8Array(i.payload);this.player.mseDecoder.decodeAudio(e,i.ts,i.cts)}break;case re: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===g||this.player._opt.playType===A&&(fa(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 me:if(i.type===Ze.streamSuccess)this.player.stream?this.player.stream.emit(Ze.streamSuccess):e.warn("decoderWorker","onmessage and workerFetch response stream success but stream is null");else if(i.type===Ze.streamRate)this.player.emit(Ze.kBps,(i.value/1024).toFixed(2));else if(i.type===Ze.streamEnd)this.player?(i.value===c&&this.player.emit(Ze.websocketClose),this.player.stream?this.player.stream.emit(Ze.streamEnd):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===it.websocketError)this.player&&this.player.stream?this.player.stream.emit(it.websocketError,i.value):e&&e.warn("decoderWorker","onmessage and workerFetch response websocket error but stream is null");else if(i.type===it.fetchError)this.player&&this.player.stream?this.player.stream.emit(it.fetchError,i.value):e&&e.warn("decoderWorker","onmessage and workerFetch response fetch error but stream is null");else if(i.type===Ze.streamAbps)this.player.updateStats({abps:i.value});else if(i.type===Ze.streamVbps)this.player._times.demuxStart||(this.player._times.demuxStart=lr()),this.player.updateStats({vbps:i.value});else if(i.type===Ze.streamDts)this.player.updateStats({dts:i.value});else if(i.type===Ze.netBuf)this.player.updateStats({netBuf:i.value});else if(i.type===Ze.networkDelayTimeout)this.player.emit(Ze.networkDelayTimeout,i.value);else if(i.type===Ze.streamStats){const e=JSON.parse(i.value);this.player.updateStats({workerStats:e})}else i.type===Ze.websocketOpen&&this.player.emit(Ze.websocketOpen);break;case ge:this.player&&(this.player.videoIframeIntervalTs=i.value);break;case ye:this.player&&this.player.updateStats({isDropping:!0});break;case Le:this.player.decoderCheckFirstIFrame();break;case be:this.player&&this.player.video&&this.player.video.setStreamFps(i.value);break;case fe:i.message&&-1!==i.message.indexOf(Ie)&&this.player.emitError(it.wasmDecodeError,"");break;case ve:this.player.emitError(it.wasmDecodeVideoNoResponseError);break;case Se:this.player.emitError(it.simdH264DecodeVideoWidthIsTooLarge);break;case _e:this.player.emitError(it.wasmWidthOrHeightChange);break;case we:this.player.emitError(it.simdDecodeError);break;case Ae:e.log("decoderWorker","onmessage:",Ae);break;case Te:e.log("decoderWorker","onmessage:",Te),this._destroy();break;case Ee:this.player&&this.player.pushTempStream(i.buffer);break;case ke:this.player&&this.player.emit(Ze.videoSEI,{ts:i.ts,data:new Uint8Array(i.buffer)});break;case Ce:if(this.player){if(this.player.isRecordTypeFlv()){const e=new Uint8Array(i.buffer);this.player.recorder.addMetaData(e)}const e=an(new Uint8Array(i.buffer));e&&e.onMetaData&&this.player.updateMetaData(e.onMetaData)}break;case xe:if(this.player&&this.player.isRecordTypeFlv()){const e=new Uint8Array(i.buffer);this.player.recorder.addAACSequenceHeader(e,i.ts)}break;case Re:if(this.player&&this.player.isRecordTypeFlv()){const e=new Uint8Array(i.buffer);this.player.recorder.addVideoSequenceHeader(e,i.ts)}break;case De:if(this.player&&this.player.isRecordTypeFlv()&&this.player.recording){const e=new Uint8Array(i.buffer);i.type===Be?this.player.recorder.addVideo(e,i.ts):i.type===Pe&&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,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:qr(),isDropSameTimestampGop:this.player._opt.isDropSameTimestampGop,mseDecodeAudio:this.player._opt.mseDecodeAudio,nakedFlowH265DemuxUseNew:this.player._opt.nakedFlowH265DemuxUseNew};this.decoderWorker.postMessage({cmd:Oe,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===g?this.player.isUseHls265()?this._decodeVideoNoDelay(e,t,i):this._decodeVideo(e,t,i):this.player._opt.playType===A&&(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 s={type:Be,ts:Math.max(t,0),isIFrame:i};this.decoderWorker.postMessage({cmd:Ne,buffer:e,options:s},[e.buffer])}_decodeVideoNoDelay(e,t,i){this.decoderWorker.postMessage({cmd:Ge,buffer:e,ts:Math.max(t,0),isIFrame:i},[e.buffer])}decodeAudio(e,t){this.player._opt.playType===g?this.player._opt.useWCS||this.player._opt.useMSE||this.player.isUseHls265()?this._decodeAudioNoDelay(e,t):this._decodeAudio(e,t):this.player._opt.playType===A&&(1===this.player.video.rate?this._decodeAudio(e,t):this._decodeAudioNoDelay(e,t))}_decodeAudio(e,t){const i={type:Pe,ts:Math.max(t,0)};this.decoderWorker.postMessage({cmd:Ne,buffer:e,options:i},[e.buffer])}_decodeAudioNoDelay(e,t){this.decoderWorker.postMessage({cmd:je,buffer:e,ts:Math.max(t,0)},[e.buffer])}updateWorkConfig(e){this.decoderWorker&&this.decoderWorker.postMessage({cmd:$e,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};this.decoderWorker.postMessage({cmd:He,url:e,opt:JSON.stringify(i)})}clearWorkBuffer(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.decoderWorker.postMessage({cmd:We,needClear:e})}workerSendMessage(e){this.decoderWorker.postMessage({cmd:Ve,message:e})}}var nn,ln="application/json, text/javascript",hn="text/html",dn=/^(?:text|application)\/xml/i,cn=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,un=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,pn=/^\s*$/,fn={},mn={},gn="",yn={type:"GET",beforeSend:An,success:An,error:An,complete:An,context:null,xhr:function(){return new window.XMLHttpRequest},accepts:{json:ln,xml:"application/xml, text/xml",html:hn,text:"text/plain","*":"*/".concat("*")},crossDomain:!1,timeout:0,username:null,password:null,processData:!0,promise:An,contentType:"application/x-www-form-urlencoded; charset=UTF-8"};function An(){}var bn=function(e,t){"object"==typeof e&&(t=e,e=void 0);var i=Cn({},t=t||{});for(var s in yn)void 0===i[s]&&(i[s]=yn[s]);try{var r={},a=new Promise((function(e,t){r.resolve=e,r.reject=t}));a.resolve=r.resolve,a.reject=r.reject,i.promise=a}catch(e){i.promise={resolve:An,reject:An}}var o=un.exec(window.location.href.toLowerCase())||[];i.url=((e||i.url||window.location.href)+"").replace(/#.*$/,"").replace(/^\/\//,o[1]+"//");var n=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 h=(i.jsonp||"callback")+"=?";i.url=Tn(i.url,h)}return function(e){var t,i=e.jsonpCallback||"jsonp"+Dn(),s=window.document.createElement("script"),r={abort:function(){i in window&&(window[i]=An)}},a=window.document.getElementsByTagName("head")[0]||window.document.documentElement;function o(i){window.clearTimeout(t),r.abort(),wn(i.type,r,i.type,e),n()}s.onerror=function(e){o(e)},window[i]=function(i){window.clearTimeout(t),vn(i,r,e),n()},En(e),s.src=e.url.replace(/=\?/,"="+i),s.src=Tn(s.src,"_="+(new Date).getTime()),s.async=!0,e.scriptCharset&&(s.charset=e.scriptCharset);a.insertBefore(s,a.firstChild),e.timeout>0&&(t=window.setTimeout((function(){r.abort(),wn("timeout",r,"timeout",e),n()}),e.timeout));function n(){s.clearAttributes?s.clearAttributes():s.onload=s.onreadystatechange=s.onerror=null,s.parentNode&&s.parentNode.removeChild(s),s=null,delete window[i]}return e.promise.abort=function(){r.abort()},e.promise.xhr=r,e.promise}(i)}En(i);var d=i.accepts[l]||i.accepts["*"],c={};/^([\w-]+:)\/\//.test(i.url)?RegExp.$1:window.location.protocol;var u,p=yn.xhr();i.crossDomain||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest"),i.ifModified&&(fn[n]&&(c["If-Modified-Since"]=fn[n]),mn[n]&&(c["If-None-Match"]=mn[n])),d&&(c.Accept=d,d.indexOf(",")>-1&&(d=d.split(",",2)[0]),p.overrideMimeType&&p.overrideMimeType(d));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 m=/([?&])_=[^&]*/;i.url=m.test(n)?n.replace(m,"$1_="+Dn()):n+(/\?/.test(n)?"&":"?")+"_="+Dn()}i.headers=Cn(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(gn=p.getAllResponseHeaders(),i.ifModified){var s=Sn("Last-Modified");s&&(fn[n]=s),(s=Sn("etag"))&&(mn[n]=s)}l=l||function(e){return e&&(e===hn?"html":e===ln?"json":dn.test(e)&&"xml")||"text"}(p.getResponseHeader("content-type")),e=p.responseText;try{"xml"===l?e=p.responseXML:"json"===l&&(e=pn.test(e)?null:JSON.parse(e))}catch(e){t=e}t?wn(t,"parseerror",p,i):vn(e,p,i)}else wn(null,"error",p,i)}};var g=!("async"in i)||i.async;if(p.open(i.type,i.url,g,i.username,i.password),i.xhrFields)for(var y in i.xhrFields)p[y]=i.xhrFields[y];for(var y in i.mimeType&&p.overrideMimeType&&p.overrideMimeType(i.mimeType),i.headers)void 0!==i.headers[y]&&p.setRequestHeader(y,i.headers[y]+"");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=An,p.abort(),wn(null,"timeout",p,i)}),i.timeout)),p.send(i.data?i.data:null),i.promise.abort=function(){p.abort()},i.promise)};function vn(e,t,i){var s=i.context,r="success";i.success.call(s,e,r,t),i.promise.resolve(e,r,t),_n(r,t,i)}function _n(e,t,i){var s=i.context;i.complete.call(s,t,e)}function wn(e,t,i,s){var r=s.context;s.error.call(r,i,t,e),s.promise.reject(i,t,e),_n(t,i,s)}function Sn(e){var t;if(!nn){for(nn={};t=cn.exec(gn);)nn[t[1].toLowerCase()]=t[2];t=nn[e.toLowerCase()]}return null===t?null:t}function Tn(e,t){return(e+"&"+t).replace(/[&?]{1,2}/,"?")}function En(e){!xn(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))},kn(i,e,t),i.join("&").replace("%20","+")}(e.data)),!e.data||e.type&&"GET"!==e.type.toUpperCase()||(e.url=Tn(e.url,e.data))}function kn(e,t,i,s){var r=function(e){return"[object Array]"===Object.prototype.toString.call(e)}(t);for(var a in t){var o=t[a];s&&(a=i?s:s+"["+(r?"":a)+"]"),!s&&r?e.add(o.name,o.value):(i?r(o):xn(o))?kn(e,o,i,a):e.add(a,o)}}function Cn(e){for(var t=Array.prototype.slice,i=t.call(arguments,1),s=0,r=i.length;s<r;s++){var a=i[s]||{};for(var o in a)a.hasOwnProperty(o)&&void 0!==a[o]&&(e[o]=a[o])}return e}function xn(e){var t=typeof e;return"function"===t||"object"===t&&!!e}function Rn(e){return"function"==typeof e}function Dn(){return(new Date).getTime()}function Ln(e){return parseInt(e)===e}function In(e){if(!Ln(e.length))return!1;for(var t=0;t<e.length;t++)if(!Ln(e[t])||e[t]<0||e[t]>255)return!1;return!0}function Pn(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(!In(e))throw new Error("Array contains invalid value: "+e);return new Uint8Array(e)}if(Ln(e.length)&&In(e))return new Uint8Array(e);throw new Error("unsupported array-like object")}function Bn(e){return new Uint8Array(e)}function Mn(e,t,i,s,r){null==s&&null==r||(e=e.slice?e.slice(s,r):Array.prototype.slice.call(e,s,r)),t.set(e,i)}bn.get=function(e,t,i,s){return Rn(t)&&(s=s||i,i=t,t=void 0),bn({url:e,data:t,success:i,dataType:s})},bn.post=function(e,t,i,s){return Rn(t)&&(s=s||i,i=t,t=void 0),bn({type:"POST",url:e,data:t,success:i,dataType:s})},bn.getJSON=function(e,t,i){return Rn(t)&&(i=t,t=void 0),bn({url:e,data:t,success:i,dataType:"json"})},bn.ajaxSetup=function(e,t){return t?Cn(Cn(e,yn),t):Cn(yn,e)};var Fn={toBytes:function(e){var t=[],i=0;for(e=encodeURI(e);i<e.length;){var s=e.charCodeAt(i++);37===s?(t.push(parseInt(e.substr(i,2),16)),i+=2):t.push(s)}return Pn(t)},fromBytes:function(e){for(var t=[],i=0;i<e.length;){var s=e[i];s<128?(t.push(String.fromCharCode(s)),i++):s>191&&s<224?(t.push(String.fromCharCode((31&s)<<6|63&e[i+1])),i+=2):(t.push(String.fromCharCode((15&s)<<12|(63&e[i+1])<<6|63&e[i+2])),i+=3)}return t.join("")}},Un=function(){var e="0123456789abcdef";return{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(t){for(var i=[],s=0;s<t.length;s++){var r=t[s];i.push(e[(240&r)>>4]+e[15&r])}return i.join("")}}}(),On={16:10,24:12,32:14},Nn=[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],jn=[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],Gn=[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],zn=[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],$n=[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],Wn=[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],Hn=[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],Vn=[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],Jn=[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],Kn=[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],qn=[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],Yn=[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],Qn=[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],Xn=[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],Zn=[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 el(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 tl=function(e){if(!(this instanceof tl))throw Error("AES must be instanitated with `new`");Object.defineProperty(this,"key",{value:Pn(e,!0)}),this._prepare()};tl.prototype._prepare=function(){var e=On[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,s=4*(e+1),r=this.key.length/4,a=el(this.key);for(t=0;t<r;t++)i=t>>2,this._Ke[i][t%4]=a[t],this._Kd[e-i][t%4]=a[t];for(var o,n=0,l=r;l<s;){if(o=a[r-1],a[0]^=jn[o>>16&255]<<24^jn[o>>8&255]<<16^jn[255&o]<<8^jn[o>>24&255]^Nn[n]<<24,n+=1,8!=r)for(t=1;t<r;t++)a[t]^=a[t-1];else{for(t=1;t<r/2;t++)a[t]^=a[t-1];o=a[r/2-1],a[r/2]^=jn[255&o]^jn[o>>8&255]<<8^jn[o>>16&255]<<16^jn[o>>24&255]<<24;for(t=r/2+1;t<r;t++)a[t]^=a[t-1]}for(t=0;t<r&&l<s;)h=l>>2,d=l%4,this._Ke[h][d]=a[t],this._Kd[e-h][d]=a[t++],l++}for(var h=1;h<e;h++)for(var d=0;d<4;d++)o=this._Kd[h][d],this._Kd[h][d]=Yn[o>>24&255]^Qn[o>>16&255]^Xn[o>>8&255]^Zn[255&o]},tl.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],s=el(e),r=0;r<4;r++)s[r]^=this._Ke[0][r];for(var a=1;a<t;a++){for(r=0;r<4;r++)i[r]=zn[s[r]>>24&255]^$n[s[(r+1)%4]>>16&255]^Wn[s[(r+2)%4]>>8&255]^Hn[255&s[(r+3)%4]]^this._Ke[a][r];s=i.slice()}var o,n=Bn(16);for(r=0;r<4;r++)o=this._Ke[t][r],n[4*r]=255&(jn[s[r]>>24&255]^o>>24),n[4*r+1]=255&(jn[s[(r+1)%4]>>16&255]^o>>16),n[4*r+2]=255&(jn[s[(r+2)%4]>>8&255]^o>>8),n[4*r+3]=255&(jn[255&s[(r+3)%4]]^o);return n},tl.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],s=el(e),r=0;r<4;r++)s[r]^=this._Kd[0][r];for(var a=1;a<t;a++){for(r=0;r<4;r++)i[r]=Vn[s[r]>>24&255]^Jn[s[(r+3)%4]>>16&255]^Kn[s[(r+2)%4]>>8&255]^qn[255&s[(r+1)%4]]^this._Kd[a][r];s=i.slice()}var o,n=Bn(16);for(r=0;r<4;r++)o=this._Kd[t][r],n[4*r]=255&(Gn[s[r]>>24&255]^o>>24),n[4*r+1]=255&(Gn[s[(r+3)%4]>>16&255]^o>>16),n[4*r+2]=255&(Gn[s[(r+2)%4]>>8&255]^o>>8),n[4*r+3]=255&(Gn[255&s[(r+1)%4]]^o);return n};var il=function(e){if(!(this instanceof il))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new tl(e)};il.prototype.encrypt=function(e){if((e=Pn(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=Bn(e.length),i=Bn(16),s=0;s<e.length;s+=16)Mn(e,i,0,s,s+16),Mn(i=this._aes.encrypt(i),t,s);return t},il.prototype.decrypt=function(e){if((e=Pn(e)).length%16!=0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var t=Bn(e.length),i=Bn(16),s=0;s<e.length;s+=16)Mn(e,i,0,s,s+16),Mn(i=this._aes.decrypt(i),t,s);return t};var sl=function(e,t){if(!(this instanceof sl))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=Bn(16);this._lastCipherblock=Pn(t,!0),this._aes=new tl(e)};sl.prototype.encrypt=function(e){if((e=Pn(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=Bn(e.length),i=Bn(16),s=0;s<e.length;s+=16){Mn(e,i,0,s,s+16);for(var r=0;r<16;r++)i[r]^=this._lastCipherblock[r];this._lastCipherblock=this._aes.encrypt(i),Mn(this._lastCipherblock,t,s)}return t},sl.prototype.decrypt=function(e){if((e=Pn(e)).length%16!=0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var t=Bn(e.length),i=Bn(16),s=0;s<e.length;s+=16){Mn(e,i,0,s,s+16),i=this._aes.decrypt(i);for(var r=0;r<16;r++)t[s+r]=i[r]^this._lastCipherblock[r];Mn(e,this._lastCipherblock,0,s,s+16)}return t};var rl=function(e,t,i){if(!(this instanceof rl))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=Bn(16);i||(i=1),this.segmentSize=i,this._shiftRegister=Pn(t,!0),this._aes=new tl(e)};rl.prototype.encrypt=function(e){if(e.length%this.segmentSize!=0)throw new Error("invalid plaintext size (must be segmentSize bytes)");for(var t,i=Pn(e,!0),s=0;s<i.length;s+=this.segmentSize){t=this._aes.encrypt(this._shiftRegister);for(var r=0;r<this.segmentSize;r++)i[s+r]^=t[r];Mn(this._shiftRegister,this._shiftRegister,0,this.segmentSize),Mn(i,this._shiftRegister,16-this.segmentSize,s,s+this.segmentSize)}return i},rl.prototype.decrypt=function(e){if(e.length%this.segmentSize!=0)throw new Error("invalid ciphertext size (must be segmentSize bytes)");for(var t,i=Pn(e,!0),s=0;s<i.length;s+=this.segmentSize){t=this._aes.encrypt(this._shiftRegister);for(var r=0;r<this.segmentSize;r++)i[s+r]^=t[r];Mn(this._shiftRegister,this._shiftRegister,0,this.segmentSize),Mn(e,this._shiftRegister,16-this.segmentSize,s,s+this.segmentSize)}return i};var al=function(e,t){if(!(this instanceof al))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=Bn(16);this._lastPrecipher=Pn(t,!0),this._lastPrecipherIndex=16,this._aes=new tl(e)};al.prototype.encrypt=function(e){for(var t=Pn(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},al.prototype.decrypt=al.prototype.encrypt;var ol=function(e){if(!(this instanceof ol))throw Error("Counter must be instanitated with `new`");0===e||e||(e=1),"number"==typeof e?(this._counter=Bn(16),this.setValue(e)):this.setBytes(e)};ol.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)},ol.prototype.setBytes=function(e){if(16!=(e=Pn(e,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=e},ol.prototype.increment=function(){for(var e=15;e>=0;e--){if(255!==this._counter[e]){this._counter[e]++;break}this._counter[e]=0}};var nl=function(e,t){if(!(this instanceof nl))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",t instanceof ol||(t=new ol(t)),this._counter=t,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new tl(e)};nl.prototype.encrypt=function(e){for(var t=Pn(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},nl.prototype.decrypt=nl.prototype.encrypt;const ll={AES:tl,Counter:ol,ModeOfOperation:{ecb:il,cbc:sl,cfb:rl,ofb:al,ctr:nl},utils:{hex:Un,utf8:Fn},padding:{pkcs7:{pad:function(e){var t=16-(e=Pn(e,!0)).length%16,i=Bn(e.length+t);Mn(e,i);for(var s=e.length;s<i.length;s++)i[s]=t;return i},strip:function(e){if((e=Pn(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,s=0;s<t;s++)if(e[i+s]!==t)throw new Error("PKCS#7 invalid padding byte");var r=Bn(i);return Mn(e,r,0,0,i),r}}},_arrayTest:{coerceArray:Pn,createArray:Bn,copyArray:Mn}};function hl(e){return e[3]|e[2]<<8|e[1]<<16|e[0]<<24}const dl=16,cl=[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],ul=[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 pl(e){const t=[];for(let i=0,s=e.length;i<s;i+=2)t.push(parseInt(e.substr(i,2),16));return t}function fl(e){return e.map((e=>1===(e=e.toString(16)).length?"0"+e:e)).join("")}function ml(e){const t=[];for(let i=0,s=e.length;i<s;i++){const s=e.codePointAt(i);if(s<=127)t.push(s);else if(s<=2047)t.push(192|s>>>6),t.push(128|63&s);else if(s<=55295||s>=57344&&s<=65535)t.push(224|s>>>12),t.push(128|s>>>6&63),t.push(128|63&s);else{if(!(s>=65536&&s<=1114111))throw t.push(s),new Error("input is not supported");i++,t.push(240|s>>>18&28),t.push(128|s>>>12&63),t.push(128|s>>>6&63),t.push(128|63&s)}}return t}function gl(e){const t=[];for(let i=0,s=e.length;i<s;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("")}function yl(e,t){const i=31&t;return e<<i|e>>>32-i}function Al(e){return(255&cl[e>>>24&255])<<24|(255&cl[e>>>16&255])<<16|(255&cl[e>>>8&255])<<8|255&cl[255&e]}function bl(e){return e^yl(e,2)^yl(e,10)^yl(e,18)^yl(e,24)}function vl(e){return e^yl(e,13)^yl(e,23)}function _l(e,t,i){const s=new Array(4),r=new Array(4);for(let t=0;t<4;t++)r[0]=255&e[4*t],r[1]=255&e[4*t+1],r[2]=255&e[4*t+2],r[3]=255&e[4*t+3],s[t]=r[0]<<24|r[1]<<16|r[2]<<8|r[3];for(let e,t=0;t<32;t+=4)e=s[1]^s[2]^s[3]^i[t+0],s[0]^=bl(Al(e)),e=s[2]^s[3]^s[0]^i[t+1],s[1]^=bl(Al(e)),e=s[3]^s[0]^s[1]^i[t+2],s[2]^=bl(Al(e)),e=s[0]^s[1]^s[2]^i[t+3],s[3]^=bl(Al(e));for(let e=0;e<16;e+=4)t[e]=s[3-e/4]>>>24&255,t[e+1]=s[3-e/4]>>>16&255,t[e+2]=s[3-e/4]>>>8&255,t[e+3]=255&s[3-e/4]}function wl(e,t,i){const s=new Array(4),r=new Array(4);for(let t=0;t<4;t++)r[0]=255&e[0+4*t],r[1]=255&e[1+4*t],r[2]=255&e[2+4*t],r[3]=255&e[3+4*t],s[t]=r[0]<<24|r[1]<<16|r[2]<<8|r[3];s[0]^=2746333894,s[1]^=1453994832,s[2]^=1736282519,s[3]^=2993693404;for(let e,i=0;i<32;i+=4)e=s[1]^s[2]^s[3]^ul[i+0],t[i+0]=s[0]^=vl(Al(e)),e=s[2]^s[3]^s[0]^ul[i+1],t[i+1]=s[1]^=vl(Al(e)),e=s[3]^s[0]^s[1]^ul[i+2],t[i+2]=s[2]^=vl(Al(e)),e=s[0]^s[1]^s[2]^ul[i+3],t[i+3]=s[3]^=vl(Al(e));if(0===i)for(let e,i=0;i<16;i++)e=t[i],t[i]=t[31-i],t[31-i]=e}function Sl(e,t,i){let{padding:s="pkcs#7",mode:r,iv:a=[],output:o="string"}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if("cbc"===r&&("string"==typeof a&&(a=pl(a)),16!==a.length))throw new Error("iv is invalid");if("string"==typeof t&&(t=pl(t)),16!==t.length)throw new Error("key is invalid");if(e="string"==typeof e?0!==i?ml(e):pl(e):[...e],("pkcs#5"===s||"pkcs#7"===s)&&0!==i){const t=dl-e.length%dl;for(let i=0;i<t;i++)e.push(t)}const n=new Array(32);wl(t,n,i);const l=[];let h=a,d=e.length,c=0;for(;d>=dl;){const t=e.slice(c,c+16),s=new Array(16);if("cbc"===r)for(let e=0;e<dl;e++)0!==i&&(t[e]^=h[e]);_l(t,s,n);for(let e=0;e<dl;e++)"cbc"===r&&0===i&&(s[e]^=h[e]),l[c+e]=s[e];"cbc"===r&&(h=0!==i?s:t),d-=dl,c+=dl}if(("pkcs#5"===s||"pkcs#7"===s)&&0===i){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"!==o?0!==i?fl(l):gl(l):l}function Tl(e){return e[3]|e[2]<<8|e[1]<<16|e[0]<<24}function El(e,t,i){for(let s=2;s<e.length;++s){const r=s-2,a=t[r%t.length],o=i[r%i.length];e[s]=e[s]^a^o}return e}function kl(e){return e[3]|e[2]<<8|e[1]<<16|e[0]<<24}class Cl 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===Pe)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===Pe)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,s=e-this.firstTimestamp;t=i>=s?i-s:s-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(f)?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,s=this.player._opt.playType===g;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&&s)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,s){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;const a=this.player;let o={ts:i,cts:r,type:t,isIFrame:!1};this.player.isPlayer()?(t===Be&&a._opt.playType===g&&this.calcNetworkDelay(i),a._opt.useWCS&&!a._opt.useOffscreen||a._opt.useMSE?(t===Be&&(o.isIFrame=s),this.pushBuffer(e,o)):t===Be?a.decoderWorker&&a.decoderWorker.decodeVideo(e,i,s):t===Pe&&a._opt.hasAudio&&a.decoderWorker&&a.decoderWorker.decodeAudio(e,i)):this.player.isPlayback()&&(t===Be&&(o.isIFrame=s),this.player.isPlaybackOnlyDecodeIFrame()?t===Be&&s&&this.pushBuffer(e,o):this.player.isPlaybackCacheBeforeDecodeForFpsRender()||1===this.player.getPlaybackRate()?this.pushBuffer(e,o):this.pushBuffer(e,o,!1))}_doDecodeByHls(e,t,i,s){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=!1;if(t===Pe&&Vs(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 o=!1;if(t===Be&&s&&ua(e)&&(this.player.debug.log("CommonDemux",`hls pushBuffer video ts is ${i}, isVideoSequenceHeader is true`),o=!0,this.player.isRecordTypeFlv())){const t=new Uint8Array(e);this.player.recorder.addVideoSequenceHeader(t,i)}this.player.recording&&fa(o)&&fa(a)&&this.handleRecording(e,t,i,s,r),t===Be?this._doDecoderDecode({ts:i,cts:r,payload:e,type:Be,isIFrame:s}):t===Pe&&this._doDecoderDecode({ts:i,payload:e,type:Pe})}_doDecodeByFmp4(e,t,i,s){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;this._doDecode(e,t,i,s,r)}_decodeNext(e){const t=e.ts;if(0===this.bufferList.length)return;let i=this.bufferList[0];const s=i.ts-t,r=e.type===Be&&i.type===Pe,a=e.type===Be&&ua(e.payload);(s<=20||r||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 ${s} and isVideoAndNextAudio is ${r} and isVideoSqeHeader is ${a}`),this.bufferList.shift(),this._doDecoderDecode(i))}_doDecoderDecode(e){const t=this.player,{webcodecsDecoder:i,mseDecoder:s}=t;this.player.isPlayer()&&this.player.updateStats({buf:this.delay}),e.type===Pe?t._opt.hasAudio&&(t._opt.useMSE&&t._opt.mseDecodeAudio?s.decodeAudio(e.payload,e.ts):t.decoderWorker&&t.decoderWorker.decodeAudio(e.payload,e.ts)):e.type===Be&&(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?s.decodeVideo(e.payload,e.ts,e.isIFrame,e.cts):t.decoderWorker&&t.decoderWorker.decodeVideo(e.payload,e.ts,e.isIFrame))}pushBuffer(e,t){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const s=this.player._opt.videoBuffer,r=this.player._opt.videoBufferDelay,a=this.player.isPlayer();if(t.type===Pe&&Vs(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:Pe})}else if(t.type===Be&&t.isIFrame&&ua(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:Be,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===Be){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===Be&&this.preTimestamp-t.ts>q&&(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===Be&&(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=fa(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=r+s;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} > ${r+s}, 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} > ${r+s},bufferList is ${this.bufferList.length}, delay is ${this.delay} and dropBuffer$2()`),this.dropBuffer$2()),this.isHistoryIntervalDiffTimeAllLarge()&&fa(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===Be&&(this.preTimestamp>0&&(this.preTimestampDuration=t.ts-this.preTimestamp),this.prevPayloadBufferSize=e.byteLength,this.preTimestamp=t.ts)}if(i?t.type===Pe?this.bufferList.push({ts:t.ts,payload:e,type:Pe}):t.type===Be&&this.bufferList.push({ts:t.ts,cts:t.cts,payload:e,type:Be,isIFrame:t.isIFrame}):t.type===Be?this._doDecoderDecode({ts:t.ts,cts:t.cts,payload:e,type:Be,isIFrame:t.isIFrame}):t.type===Pe&&this._doDecoderDecode({ts:t.ts,payload:e,type:Pe}),this.player.isPlaybackCacheBeforeDecodeForFpsRender()&&(Br(this.playbackStreamVideoFps)||Br(this.playbackStreamAudioFps))){let e=this.playbackStreamVideoFps,t=this.playbackStreamAudioFps;if(Br(this.playbackStreamVideoFps)&&(e=oa(this.bufferList,Be),e>0&&(this.playbackStreamVideoFps=e,this.player.video&&this.player.video.setStreamFps(this.playbackStreamVideoFps),this.playbackStreamFps=t?e+t:e,fa(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())),Br(this.playbackStreamAudioFps)&&(t=oa(this.bufferList,Pe),t>0&&(this.playbackStreamAudioFps=t,this.playbackStreamFps=e?e+t:t,this.initPlaybackCacheLoop())),Br(this.playbackStreamVideoFps)&&Br(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,s=i?60:40;this.bufferList.length>=s&&(this.debug.warn("CommonDemux",`playbackCacheBeforeDecodeForFpsRender, bufferListLength is ${this.bufferList.length} more than ${s}, 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=>pa(e.isIFrame)&&e.type===Be));if(this.isAllIframeInBufferList())for(let t=0;t<this.bufferList.length;t++){const i=this.bufferList[t],s=this.getDelayNotUpdateDelay(i.ts,i.type);if(s>=this.getNotDroppingDelayTs()){this.player.debug.log("CommonDemux",`dropBuffer$2() isAllIframeInBufferList() is true, and index is ${t} and tempDelay is ${s} 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(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];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(),pa(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=lr()):e<this.bufferStartDts&&(this.player.debug.warn("CommonDemux",`calcNetworkDelay dts is ${e} and bufferStartDts is ${this.bufferStartDts}`),this.bufferStartDts=e,this.bufferStartLocalTs=lr());let t=e-this.bufferStartDts,i=lr()-this.bufferStartLocalTs,s=i>t?i-t:0;s>this.player._opt.networkDelay&&this.player._opt.playType===g&&(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 ${s}, _opt.networkDelay is ${this.player._opt.networkDelay}`),this.player.emit(Ze.networkDelayTimeout,s)),this.player.updateStats({netBuf:s})}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===Be&&(e+=1)})),e}getAudioBufferLength(){let e=0;return this.bufferList.forEach((t=>{t.type===Pe&&(e+=1)})),e}hasIframeInBufferList(){return this.bufferList.some((e=>e.type===Be&&e.isIFrame))}isAllIframeInBufferList(){const e=this.getVideoBufferLength();let t=0;return this.bufferList.forEach((e=>{e.type===Be&&e.isIFrame&&(t+=1)})),e===t}getInputByteLength(){return 0}getIsStreamTsMoreThanLocal(){return this.isStreamTsMoreThanLocal}close(){}reset(){}findSei(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=4;Fr(this.nalUnitSize)&&(s=this.nalUnitSize);const r=Fo(e.slice(5),s);if(fa(i)){const e=this.player.getVideoInfo();e&&e.encType&&(i=e.encType===ft)}r.forEach((e=>{const s=i?e[0]>>>1&63:31&e[0];(i&&(s===It||s===Lt)||fa(i)&&s===Tt)&&this.player.emit(Ze.videoSEI,{ts:t,data:e})}))}handleRecording(e,t,i,s,r){if(this.player.isRecordTypeFlv()){const s=new Uint8Array(e);t===Be?this.player.recorder.addVideo(s,i):t===Pe&&this.player.recorder.addAudio(s,i)}else if(this.player.isRecordTypeMp4()){const a=new Uint8Array(e);if(this.player.recorder.isWasmMp4()){if(t===Be)this.player.recorder.handleAddNaluTrack(a.slice(5),s,i,r);else if(t===Pe){const t=new Uint8Array(e);this.player.recorder.handleAddAudioTrack(Js(t)?t.slice(2):t.slice(1),i)}}else t===Be&&this.player.recorder.handleAddNaluTrack(a.slice(5),s,i,r)}}updateNalUnitSize(e){const t=15&e[0];this.player.video.updateVideoInfo({encTypeCode:t});const i=t===ut;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,s=this.player;if(s._opt.isM7sCrypto)if(s._opt.cryptoKey&&s._opt.cryptoKey.byteLength>0&&s._opt.cryptoIV&&s._opt.cryptoIV.byteLength>0){const t=this.player.video.getVideoInfo();t.encTypeCode?i=function(e,t,i){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];t=new Uint8Array(t),i=new Uint8Array(i);const r=e.byteLength;let a=5;for(;a<r;){let o=hl(e.slice(a,a+4));if(o>r)break;let n=e[a+4],l=!1;if(s?(n=n>>>1&63,l=[0,1,2,3,4,5,6,7,8,9,16,17,18,19,20,21].includes(n)):(n&=31,l=1===n||5===n),l){const s=e.slice(a+4+2,a+4+o);let r=new ll.ModeOfOperation.ctr(t,new ll.Counter(i));const n=r.decrypt(s);r=null,e.set(n,a+4+2)}a=a+4+o}return e}(e,s._opt.cryptoKey,s._opt.cryptoIV,t.encTypeCode===ut):s.debug.warn(this.TAG_NAME,`videoInfo.encTypeCode is ${t.encTypeCode}`)}else s.debug.error(this.TAG_NAME,`isM7sCrypto cryptoKey.length is ${s._opt.cryptoKey&&s._opt.cryptoKey.byteLength} or cryptoIV.length is ${s._opt.cryptoIV&&s._opt.cryptoIV.byteLength} null`);else if(s._opt.isSm4Crypto)s._opt.sm4CryptoKey&&t?i=function(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const s=e.byteLength;let r=5;for(;r<s;){let a=Tl(e.slice(r,r+4));if(a>s)break;let o=e[r+4],n=!1;if(i?(o=o>>>1&63,n=[0,1,2,3,4,5,6,7,8,9,16,17,18,19,20,21].includes(o)):(o&=31,n=1===o||5===o),n){const i=Sl(e.slice(r+4+2,r+4+a),t,0,{padding:"none",output:"array"});e.set(i,r+4+2)}r=r+4+a}return e}(e,s._opt.sm4CryptoKey):s._opt.sm4CryptoKey||s.debug.error(this.TAG_NAME,"isSm4Crypto opt.sm4CryptoKey is null");else if(s._opt.isXorCrypto)if(s._opt.cryptoKey&&s._opt.cryptoKey.byteLength>0&&s._opt.cryptoIV&&s._opt.cryptoIV.byteLength>0){const t=this.player.video.getVideoInfo();i=function(e,t,i){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const r=e.byteLength;let a=5;for(;a<r;){let o=kl(e.slice(a,a+4));if(o>r)break;let n=e[a+4],l=!1;if(s?(n=n>>>1&63,l=[0,1,2,3,4,5,6,7,8,9,16,17,18,19,20,21].includes(n)):(n&=31,l=1===n||5===n),l){const s=El(e.slice(a+4,a+4+o),t,i);e.set(s,a+4)}a=a+4+o}return e}(e,s._opt.cryptoKey,s._opt.cryptoIV,t.encTypeCode===ut)}else s.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===mt&&(t=function(e,t,i){if(e.byteLength<=30)return e;const s=e.slice(32);let r=new ll.ModeOfOperation.ctr(t,new ll.Counter(i));const a=r.decrypt(s);return r=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],s=48&i,r=15&i,a=e.slice(1,5),o=new ArrayBuffer(4),n=new Uint32Array(o),l="a"==String.fromCharCode(a[0]);if(r===Us){if(s===js){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,Be,0,!0,0)}}}else if(r===Os){let i=e,r=0;const a=s===js;if(a&&this.calcIframeIntervalTimestamp(t),l);else{n[0]=e[4],n[1]=e[3],n[2]=e[2],n[3]=0,r=n[0];i=Go(e.slice(8),a),i=this.cryptoPayload(i,a),this._doDecode(i,Be,t,a,r)}}else if(r===Ns){const i=s===js,r=e.slice(5);i&&this.calcIframeIntervalTimestamp(t);let a=Go(r,i);a=this.cryptoPayload(a,i),this._doDecode(a,Be,t,i,0)}}_isEnhancedH265Header(e){return 128==(128&e)}}var xl=function(e,t,i,s){return new(i||(i=Promise))((function(r,a){function o(e){try{l(s.next(e))}catch(e){a(e)}}function n(e){try{l(s.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,n)}l((s=s.apply(e,t||[])).next())}))};const Rl=Symbol(32),Dl=Symbol(16),Ll=Symbol(8);class Il{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 xl(this,void 0,void 0,(function*(){return this.lastReadPromise&&(yield this.lastReadPromise),this.lastReadPromise=new Promise(((t,i)=>{var s;this.reject=i,this.resolve=e=>{delete this.lastReadPromise,delete this.resolve,delete this.need,t(e)};this.demand(e,!0)||null===(s=this.pull)||void 0===s||s.call(this,e)}))}))}readU32(){return this.read(Rl)}readU16(){return this.read(Dl)}readU8(){return this.read(Ll)}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 s=e=>t.length<(i=e);if("number"==typeof this.need){if(s(this.need))return;e=t.subarray(0,i)}else if(this.need===Rl){if(s(4))return;e=t[0]<<24|t[1]<<16|t[2]<<8|t[3]}else if(this.need===Dl){if(s(2))return;e=t[0]<<8|t[1]}else if(this.need===Ll){if(s(1))return;e=t[0]}else if("buffer"in this.need){if("byteOffset"in this.need){if(s(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(s(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}}Il.U32=Rl,Il.U16=Dl,Il.U8=Ll;class Pl extends Cl{constructor(e){super(e),this.TAG_NAME="FlvDemux",this.input=new Il(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),s=this.player;for(;;){if(!this.input)return;t[3]=0;const e=yield 15,r=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 o=i[0];const n=(yield a).slice();if(!s)return;switch(r){case Me:if(s._opt.hasAudio&&(s.updateStats({abps:n.byteLength}),n.byteLength>0)){let e=n;pa(this.player._opt.m7sCryptoAudio)&&(e=this.cryptoPayloadAudio(n)),this._doDecode(e,Pe,o)}break;case Fe:if(s._opt.hasVideo&&n.length>=6){let e=o;s.updateStats({vbps:n.byteLength,dts:e}),s._times.demuxStart||(s._times.demuxStart=lr());const t=n[0];if(this._isEnhancedH265Header(t))this._decodeEnhancedH265Video(n,e);else{const e=15&t,s=(t>>4&15)===cs;if(fa(e===ut||e===ct))return void this.player.debug.warn(this.TAG_NAME,`demux() codecId is ${e} and ignore`);s&&(this.calcIframeIntervalTimestamp(o),null===this.nalUnitSize&&ua(n)&&this.updateNalUnitSize(n)),i[0]=n[4],i[1]=n[3],i[2]=n[2],i[3]=0;let r=i[0],a=this.cryptoPayload(n,s);this._doDecode(a,Be,o,s,r)}}else n.length<6&&s.debug.warn(this.TAG_NAME,`payload.length is ${n.length} less than 6 and ignore`);break;case Ue:if(this.player.isRecordTypeFlv()){const e=new Uint8Array(n);this.player.recorder.addMetaData(e)}const e=an(n);e&&e.onMetaData&&s.updateMetaData(e.onMetaData);break;default:s.debug.log(this.TAG_NAME,`demux() type is ${r}`)}}}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=Fo(e.slice(5));let s=!1;return i.forEach((e=>{const i=t?e[0]>>>1&63:31&e[0];(t&&(i===Et||i===kt)||fa(t)&&i===St)&&(s=!0)})),s}}class Bl extends Cl{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),s=i.getUint8(0),r=i.getUint32(1,!1),a=new ArrayBuffer(4),o=new Uint32Array(a);switch(s){case Pe:if(t._opt.hasAudio){const i=new Uint8Array(e,5);t.updateStats({abps:i.byteLength}),i.byteLength>0&&this._doDecode(i,s,r)}break;case Be:if(t._opt.hasVideo)if(t._times.demuxStart||(t._times.demuxStart=lr()),i.byteLength>=11){const a=new Uint8Array(e,5);let n=r;t.updateStats({vbps:a.byteLength,dts:n});const l=a[0];if(this._isEnhancedH265Header(l))this._decodeEnhancedH265Video(a,r);else{const e=i.getUint8(5)>>4==1;e&&this.calcIframeIntervalTimestamp(r),o[0]=a[4],o[1]=a[3],o[2]=a[2],o[3]=0;let t=o[0],n=this.cryptoPayload(a,e);this._doDecode(n,s,r,e,t)}}else this.player.debug.warn(this.TAG_NAME,"dispatch","dv byteLength is",i.byteLength,"and return")}}}class Ml extends Pl{constructor(e){super(e),e.debug.log("WebTransportDemux","init")}destroy(){this.player.debug.log("WebTransportDemux","destroy"),super.destroy()}}var Fl,Ul=$s((function(e){e.exports=function(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e},e.exports.__esModule=!0,e.exports.default=e.exports})),Ol=(Fl=Ul)&&Fl.__esModule&&Object.prototype.hasOwnProperty.call(Fl,"default")?Fl.default:Fl;class Nl extends Cl{constructor(e){super(e),Ol(this,"TAG_NAME","NakedFlowDemux"),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,s=0,r=e.byteLength,a=0,o=[];for(;s<r;)switch(t=e[s++],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&&s<r?(e[s],i&&o.push(e.subarray(i,s-a-1)),i=s,a=0):a=0}return i&&o.push(e.subarray(i,r)),o}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,s=-1,r=-2;const a=new Array;for(let e=0;e<t.length;e+=2){const i=t[e],o=t[e+1];0==s&&0==i&&0==o?a.push(e-1):1==o&&0==i&&0==s&&0==r&&a.push(e-2),r=i,s=o}if(a.length>1)for(let e=0;e<a.length-1;++e){const s=t.subarray(a[e],a[e+1]+1);this.handleNALu(s),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!==_t&&i!==wt||(t=pt),t||(i=(126&e[0])>>1,i!==Ct&&i!==xt&&i!==Rt||(t=ft)),t}(t)),this.streamVideoType===pt){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 s=[];if(i.forEach((e=>{const t=Ro(e);t===wt||t===_t?this.handleVideoH264Nalu(e):Lo(t)&&s.push(e)})),1===s.length)this.handleVideoH264Nalu(s[0]);else{const e=function(e){if(0===e.length)return!1;const t=Ro(e[0]);for(let i=1;i<e.length;i++)if(t!==Ro(e[i]))return!1;return!0}(s);if(e){const e=Ro(s[0]),t=Io(e);this.handleVideoH264NaluList(s,t,e)}else s.forEach((e=>{this.handleVideoH264Nalu(e)}))}}else if(this.streamVideoType===ft)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 s=[];if(i.forEach((e=>{const t=zo(e);t===Rt||t===xt||t===Ct?this.handleVideoH265Nalu(e):$o(t)&&s.push(e)})),1===s.length)this.handleVideoH265Nalu(s[0]);else{const e=function(e){if(0===e.length)return!1;const t=zo(e[0]);for(let i=1;i<e.length;i++)if(t!==zo(e[i]))return!1;return!0}(s);if(e){const e=zo(s[0]),t=Wo(e);this.handleVideoH265NaluList(s,t,e)}else s.forEach((e=>{this.handleVideoH265Nalu(e)}))}}else{zo(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=>{Do(Ro(e))?this.extractH264SEI(e):this.handleVideoH264Nalu(e)}))}extractH265PPS(e){const t=this.handleAddNaluStartCode(e);this.extractNALu(t).forEach((e=>{const t=zo(e);t===Dt?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=bt.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,s=(1&i[2])<<2|(192&i[3])>>6,r=new Uint8Array([175,0,e<<3|(14&t)>>1,(1&t)<<7|s<<3]);this.isSendAACSeqHeader=!0,this._doDecode(r,Pe,0,!1,0)}const s=this.getNaluAudioDts(),r=new Uint8Array(t.length+2);r.set([175,1],0),r.set(t,2),this._doDecode(r,Pe,s,!1,0)}handleAudioG711ANalu(e){if(!e||e.byteLength<1)return;this.streamAudioType||(this.streamAudioType=bt.ALAW);let t=new Uint8Array(e);const i=this.getNaluAudioDts(),s=new Uint8Array(t.length+1);s.set([114],0),s.set(t,1),this._doDecode(s,Pe,i,!1,0)}handleAudioG711UNalu(e){if(!e||e.byteLength<1)return;this.streamAudioType||(this.streamAudioType=bt.MULAW);let t=new Uint8Array(e);const i=this.getNaluAudioDts(),s=new Uint8Array(t.length+1);s.set([130],0),s.set(t,1),this._doDecode(s,Pe,i,!1,0)}handleVideoH264Nalu(e){const t=Ro(e);switch(t){case _t:this.sps=e;break;case wt:this.pps=e}if(this.isSendSeqHeader){if(this.sps&&this.pps){const e=Co({sps:this.sps,pps:this.pps}),t=this.getNaluDts();this._doDecode(e,Be,t,!0,0),this.sps=null,this.pps=null}if(Lo(t)){this.player._times.demuxStart||(this.player._times.demuxStart=lr());const i=Io(t),s=this.getNaluDts(),r=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 s=new Uint8Array(i.length+e.byteLength);return s.set(i,0),s.set(e,i.length),s}(e,i);this._preDoDecode(r,Be,s,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=Co({sps:this.sps,pps:this.pps});this._doDecode(e,Be,0,!0,0),this.sps=null,this.pps=null}}handleVideoH264NaluList(e,t,i){if(this.isSendSeqHeader){this.player._times.demuxStart||(this.player._times.demuxStart=lr());const i=this.getNaluDts(),s=xo(e.reduce(((e,t)=>{const i=Uo(e),s=Uo(t),r=new Uint8Array(i.byteLength+s.byteLength);return r.set(i,0),r.set(s,i.byteLength),r})),t);this._preDoDecode(s,Be,i,t,0)}else this.player.debug.warn(this.TAG_NAME,"handleVideoH264NaluList isSendSeqHeader is false")}handleVideoH265Nalu(e){const t=zo(e);switch(t){case Ct:this.vps=e;break;case xt:this.sps=e;break;case Rt:this.pps=e}if(this.isSendSeqHeader){if(this.vps&&this.sps&&this.pps){const e=jo({vps:this.vps,sps:this.sps,pps:this.pps}),t=this.getNaluDts();this._doDecode(e,Be,t,!0,0),this.vps=null,this.sps=null,this.pps=null}if($o(t)){this.player._times.demuxStart||(this.player._times.demuxStart=lr());const i=Wo(t),s=this.getNaluDts(),r=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 s=new Uint8Array(i.length+e.byteLength);return s.set(i,0),s.set(e,i.length),s}(e,i);this._preDoDecode(r,Be,s,i,0)}}else if(this.vps&&this.sps&&this.pps){this.isSendSeqHeader=!0;const e=jo({vps:this.vps,sps:this.sps,pps:this.pps});this._doDecode(e,Be,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=lr());const i=this.getNaluDts(),s=Go(e.reduce(((e,t)=>{const i=Uo(e),s=Uo(t),r=new Uint8Array(i.byteLength+s.byteLength);return r.set(i,0),r.set(s,i.byteLength),r})),t);this._preDoDecode(s,Be,i,t,0)}else this.player.debug.warn(this.TAG_NAME,"handleVideoH265NaluList isSendSeqHeader is false")}_preDoDecode(e,t,i,s,r){this.player.updateStats({vbps:e.byteLength,dts:i}),s&&this.calcIframeIntervalTimestamp(i),this._doDecode(e,Be,i,s,r)}getInputByteLength(){let e=0;return this.lastBuf&&(e=this.lastBuf.byteLength),e}}class jl extends Cl{constructor(e){super(e),this.player=e,e.debug.log("EmptyDemux","init")}destroy(){super.destroy(),this.player.debug.log("EmptyDemux","destroy")}}var Gl=$s((function(e,t){var i,s,r,a=(i=new Date,s=4,r={setLogLevel:function(e){s=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>=s&&console.debug("["+a.getDurationString(new Date-i,1e3)+"]","["+e+"]",t)},log:function(e,t){this.debug(e.msg)},info:function(e,t){2>=s&&console.info("["+a.getDurationString(new Date-i,1e3)+"]","["+e+"]",t)},warn:function(e,t){3>=s&&console.warn("["+a.getDurationString(new Date-i,1e3)+"]","["+e+"]",t)},error:function(e,t){4>=s&&console.error("["+a.getDurationString(new Date-i,1e3)+"]","["+e+"]",t)}},r);a.getDurationString=function(e,t){var i;function s(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 r=e/(t||1),a=Math.floor(r/3600);r-=3600*a;var o=Math.floor(r/60),n=1e3*(r-=60*o);return n-=1e3*(r=Math.floor(r)),n=Math.floor(n),(i?"-":"")+a+":"+s(o,2)+":"+s(r,2)+"."+s(n,3)},a.printRanges=function(e){var t=e.length;if(t>0){for(var i="",s=0;s<t;s++)s>0&&(i+=","),i+="["+a.getDurationString(e.start(s))+","+a.getDurationString(e.end(s))+"]";return i}return"(empty)"},t.Log=a;var o=function(e){if(!(e instanceof ArrayBuffer))throw"Needs an array buffer";this.buffer=e,this.dataview=new DataView(e),this.position=0};o.prototype.getPosition=function(){return this.position},o.prototype.getEndPosition=function(){return this.buffer.byteLength},o.prototype.getLength=function(){return this.buffer.byteLength},o.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},o.prototype.isEos=function(){return this.getPosition()>=this.getEndPosition()},o.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"},o.prototype.readUint8=function(){return this.readAnyInt(1,!1)},o.prototype.readUint16=function(){return this.readAnyInt(2,!1)},o.prototype.readUint24=function(){return this.readAnyInt(3,!1)},o.prototype.readUint32=function(){return this.readAnyInt(4,!1)},o.prototype.readUint64=function(){return this.readAnyInt(8,!1)},o.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"},o.prototype.readCString=function(){for(var e=[];;){var t=this.readUint8();if(0===t)break;e.push(t)}return String.fromCharCode.apply(null,e)},o.prototype.readInt8=function(){return this.readAnyInt(1,!0)},o.prototype.readInt16=function(){return this.readAnyInt(2,!0)},o.prototype.readInt32=function(){return this.readAnyInt(4,!0)},o.prototype.readInt64=function(){return this.readAnyInt(8,!1)},o.prototype.readUint8Array=function(e){for(var t=new Uint8Array(e),i=0;i<e;i++)t[i]=this.readUint8();return t},o.prototype.readInt16Array=function(e){for(var t=new Int16Array(e),i=0;i<e;i++)t[i]=this.readInt16();return t},o.prototype.readUint16Array=function(e){for(var t=new Int16Array(e),i=0;i<e;i++)t[i]=this.readUint16();return t},o.prototype.readUint32Array=function(e){for(var t=new Uint32Array(e),i=0;i<e;i++)t[i]=this.readUint32();return t},o.prototype.readInt32Array=function(e){for(var t=new Int32Array(e),i=0;i<e;i++)t[i]=this.readInt32();return t},t.MP4BoxStream=o;var n=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?n.LITTLE_ENDIAN:i};n.prototype={},n.prototype.getPosition=function(){return this.position},n.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 s=new ArrayBuffer(i),r=new Uint8Array(this._buffer);new Uint8Array(s,0,r.length).set(r),this.buffer=s,this._byteLength=t}}},n.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}},n.BIG_ENDIAN=!1,n.LITTLE_ENDIAN=!0,n.prototype._byteLength=0,Object.defineProperty(n.prototype,"byteLength",{get:function(){return this._byteLength-this._byteOffset}}),Object.defineProperty(n.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(n.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(n.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}}),n.prototype.seek=function(e){var t=Math.max(0,Math.min(this.byteLength,e));this.position=isNaN(t)||!isFinite(t)?0:t},n.prototype.isEof=function(){return this.position>=this._byteLength},n.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},n.prototype.readInt32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var i=new Int32Array(e);return n.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),n.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},n.prototype.readInt16Array=function(e,t){e=null==e?this.byteLength-this.position/2:e;var i=new Int16Array(e);return n.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),n.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},n.prototype.readInt8Array=function(e){e=null==e?this.byteLength-this.position:e;var t=new Int8Array(e);return n.memcpy(t.buffer,0,this.buffer,this.byteOffset+this.position,e*t.BYTES_PER_ELEMENT),this.position+=t.byteLength,t},n.prototype.readUint32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var i=new Uint32Array(e);return n.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),n.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},n.prototype.readUint16Array=function(e,t){e=null==e?this.byteLength-this.position/2:e;var i=new Uint16Array(e);return n.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),n.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},n.prototype.readUint8Array=function(e){e=null==e?this.byteLength-this.position:e;var t=new Uint8Array(e);return n.memcpy(t.buffer,0,this.buffer,this.byteOffset+this.position,e*t.BYTES_PER_ELEMENT),this.position+=t.byteLength,t},n.prototype.readFloat64Array=function(e,t){e=null==e?this.byteLength-this.position/8:e;var i=new Float64Array(e);return n.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),n.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},n.prototype.readFloat32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var i=new Float32Array(e);return n.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),n.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},n.prototype.readInt32=function(e){var t=this._dataView.getInt32(this.position,null==e?this.endianness:e);return this.position+=4,t},n.prototype.readInt16=function(e){var t=this._dataView.getInt16(this.position,null==e?this.endianness:e);return this.position+=2,t},n.prototype.readInt8=function(){var e=this._dataView.getInt8(this.position);return this.position+=1,e},n.prototype.readUint32=function(e){var t=this._dataView.getUint32(this.position,null==e?this.endianness:e);return this.position+=4,t},n.prototype.readUint16=function(e){var t=this._dataView.getUint16(this.position,null==e?this.endianness:e);return this.position+=2,t},n.prototype.readUint8=function(){var e=this._dataView.getUint8(this.position);return this.position+=1,e},n.prototype.readFloat32=function(e){var t=this._dataView.getFloat32(this.position,null==e?this.endianness:e);return this.position+=4,t},n.prototype.readFloat64=function(e){var t=this._dataView.getFloat64(this.position,null==e?this.endianness:e);return this.position+=8,t},n.endianness=new Int8Array(new Int16Array([1]).buffer)[0]>0,n.memcpy=function(e,t,i,s,r){var a=new Uint8Array(e,t,r),o=new Uint8Array(i,s,r);a.set(o)},n.arrayToNative=function(e,t){return t==this.endianness?e:this.flipArrayEndianness(e)},n.nativeToEndian=function(e,t){return this.endianness==t?e:this.flipArrayEndianness(e)},n.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 s=i+e.BYTES_PER_ELEMENT-1,r=i;s>r;s--,r++){var a=t[r];t[r]=t[s],t[s]=a}return e},n.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)},n.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))},n.prototype.readCString=function(e){var t=this.byteLength-this.position,i=new Uint8Array(this._buffer,this._byteOffset+this.position),s=t;null!=e&&(s=Math.min(e,t));for(var r=0;r<s&&0!==i[r];r++);var a=String.fromCharCodeUint8.apply(null,[this.mapUint8Array(r)]);return null!=e?this.position+=s-r:r!=t&&(this.position+=1),a};var l=Math.pow(2,32);n.prototype.readInt64=function(){return this.readInt32()*l+this.readUint32()},n.prototype.readUint64=function(){return this.readUint32()*l+this.readUint32()},n.prototype.readInt64=function(){return this.readUint32()*l+this.readUint32()},n.prototype.readUint24=function(){return(this.readUint8()<<16)+(this.readUint8()<<8)+this.readUint8()},t.DataStream=n,n.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),s=document.createElement("a");document.body.appendChild(s),s.setAttribute("href",i),s.setAttribute("download",e),s.setAttribute("target","_self"),s.click(),window.URL.revokeObjectURL(i)},n.prototype._dynamicSize=!0,Object.defineProperty(n.prototype,"dynamicSize",{get:function(){return this._dynamicSize},set:function(e){e||this._trimAlloc(),this._dynamicSize=e}}),n.prototype.shift=function(e){var t=new ArrayBuffer(this._byteLength-e),i=new Uint8Array(t),s=new Uint8Array(this._buffer,e,i.length);i.set(s),this.buffer=t,this.position-=e},n.prototype.writeInt32Array=function(e,t){if(this._realloc(4*e.length),e instanceof Int32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)n.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)},n.prototype.writeInt16Array=function(e,t){if(this._realloc(2*e.length),e instanceof Int16Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)n.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)},n.prototype.writeInt8Array=function(e){if(this._realloc(1*e.length),e instanceof Int8Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)n.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])},n.prototype.writeUint32Array=function(e,t){if(this._realloc(4*e.length),e instanceof Uint32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)n.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)},n.prototype.writeUint16Array=function(e,t){if(this._realloc(2*e.length),e instanceof Uint16Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)n.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)},n.prototype.writeUint8Array=function(e){if(this._realloc(1*e.length),e instanceof Uint8Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)n.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])},n.prototype.writeFloat64Array=function(e,t){if(this._realloc(8*e.length),e instanceof Float64Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)n.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)},n.prototype.writeFloat32Array=function(e,t){if(this._realloc(4*e.length),e instanceof Float32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)n.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)},n.prototype.writeInt32=function(e,t){this._realloc(4),this._dataView.setInt32(this.position,e,null==t?this.endianness:t),this.position+=4},n.prototype.writeInt16=function(e,t){this._realloc(2),this._dataView.setInt16(this.position,e,null==t?this.endianness:t),this.position+=2},n.prototype.writeInt8=function(e){this._realloc(1),this._dataView.setInt8(this.position,e),this.position+=1},n.prototype.writeUint32=function(e,t){this._realloc(4),this._dataView.setUint32(this.position,e,null==t?this.endianness:t),this.position+=4},n.prototype.writeUint16=function(e,t){this._realloc(2),this._dataView.setUint16(this.position,e,null==t?this.endianness:t),this.position+=2},n.prototype.writeUint8=function(e){this._realloc(1),this._dataView.setUint8(this.position,e),this.position+=1},n.prototype.writeFloat32=function(e,t){this._realloc(4),this._dataView.setFloat32(this.position,e,null==t?this.endianness:t),this.position+=4},n.prototype.writeFloat64=function(e,t){this._realloc(8),this._dataView.setFloat64(this.position,e,null==t?this.endianness:t),this.position+=8},n.prototype.writeUCS2String=function(e,t,i){null==i&&(i=e.length);for(var s=0;s<e.length&&s<i;s++)this.writeUint16(e.charCodeAt(s),t);for(;s<i;s++)this.writeUint16(0)},n.prototype.writeString=function(e,t,i){var s=0;if(null==t||"ASCII"==t)if(null!=i){var r=Math.min(e.length,i);for(s=0;s<r;s++)this.writeUint8(e.charCodeAt(s));for(;s<i;s++)this.writeUint8(0)}else for(s=0;s<e.length;s++)this.writeUint8(e.charCodeAt(s));else this.writeUint8Array(new TextEncoder(t).encode(e.substring(0,i)))},n.prototype.writeCString=function(e,t){var i=0;if(null!=t){var s=Math.min(e.length,t);for(i=0;i<s;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)}},n.prototype.writeStruct=function(e,t){for(var i=0;i<e.length;i+=2){var s=e[i+1];this.writeType(s,t[e[i]],t)}},n.prototype.writeType=function(e,t,i){var s;if("function"==typeof e)return e(this,t);if("object"==typeof e&&!(e instanceof Array))return e.set(this,t,i);var r=null,a="ASCII",o=this.position;switch("string"==typeof e&&/:/.test(e)&&(s=e.split(":"),e=s[0],r=parseInt(s[1])),"string"==typeof e&&/,/.test(e)&&(s=e.split(","),e=s[0],a=parseInt(s[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,n.BIG_ENDIAN);break;case"int16be":this.writeInt16(t,n.BIG_ENDIAN);break;case"uint32be":this.writeUint32(t,n.BIG_ENDIAN);break;case"int32be":this.writeInt32(t,n.BIG_ENDIAN);break;case"float32be":this.writeFloat32(t,n.BIG_ENDIAN);break;case"float64be":this.writeFloat64(t,n.BIG_ENDIAN);break;case"uint16le":this.writeUint16(t,n.LITTLE_ENDIAN);break;case"int16le":this.writeInt16(t,n.LITTLE_ENDIAN);break;case"uint32le":this.writeUint32(t,n.LITTLE_ENDIAN);break;case"int32le":this.writeInt32(t,n.LITTLE_ENDIAN);break;case"float32le":this.writeFloat32(t,n.LITTLE_ENDIAN);break;case"float64le":this.writeFloat64(t,n.LITTLE_ENDIAN);break;case"cstring":this.writeCString(t,r);break;case"string":this.writeString(t,a,r);break;case"u16string":this.writeUCS2String(t,this.endianness,r);break;case"u16stringle":this.writeUCS2String(t,n.LITTLE_ENDIAN,r);break;case"u16stringbe":this.writeUCS2String(t,n.BIG_ENDIAN,r);break;default:if(3==e.length){for(var l=e[1],h=0;h<t.length;h++)this.writeType(l,t[h]);break}this.writeStruct(e,t)}null!=r&&(this.position=o,this._realloc(r),this.position=o+r)},n.prototype.writeUint64=function(e){var t=Math.floor(e/l);this.writeUint32(t),this.writeUint32(4294967295&e)},n.prototype.writeUint24=function(e){this.writeUint8((16711680&e)>>16),this.writeUint8((65280&e)>>8),this.writeUint8(255&e)},n.prototype.adjustUint32=function(e,t){var i=this.position;this.seek(e),this.writeUint32(t),this.seek(i)},n.prototype.mapInt32Array=function(e,t){this._realloc(4*e);var i=new Int32Array(this._buffer,this.byteOffset+this.position,e);return n.arrayToNative(i,null==t?this.endianness:t),this.position+=4*e,i},n.prototype.mapInt16Array=function(e,t){this._realloc(2*e);var i=new Int16Array(this._buffer,this.byteOffset+this.position,e);return n.arrayToNative(i,null==t?this.endianness:t),this.position+=2*e,i},n.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},n.prototype.mapUint32Array=function(e,t){this._realloc(4*e);var i=new Uint32Array(this._buffer,this.byteOffset+this.position,e);return n.arrayToNative(i,null==t?this.endianness:t),this.position+=4*e,i},n.prototype.mapUint16Array=function(e,t){this._realloc(2*e);var i=new Uint16Array(this._buffer,this.byteOffset+this.position,e);return n.arrayToNative(i,null==t?this.endianness:t),this.position+=2*e,i},n.prototype.mapFloat64Array=function(e,t){this._realloc(8*e);var i=new Float64Array(this._buffer,this.byteOffset+this.position,e);return n.arrayToNative(i,null==t?this.endianness:t),this.position+=8*e,i},n.prototype.mapFloat32Array=function(e,t){this._realloc(4*e);var i=new Float32Array(this._buffer,this.byteOffset+this.position,e);return n.arrayToNative(i,null==t?this.endianness:t),this.position+=4*e,i};var h=function(e){this.buffers=[],this.bufferIndex=-1,e&&(this.insertBuffer(e),this.bufferIndex=0)};(h.prototype=new n(new ArrayBuffer,0,n.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},h.prototype.reduceBuffer=function(e,t,i){var s;return(s=new Uint8Array(i)).set(new Uint8Array(e,t,i)),s.buffer.fileStart=e.fileStart+t,s.buffer.usedBytes=0,s.buffer},h.prototype.insertBuffer=function(e){for(var t=!0,i=0;i<this.buffers.length;i++){var s=this.buffers[i];if(e.fileStart<=s.fileStart){if(e.fileStart===s.fileStart){if(e.byteLength>s.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<=s.fileStart||(e=this.reduceBuffer(e,0,s.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<s.fileStart+s.byteLength){var r=s.fileStart+s.byteLength-e.fileStart,o=e.byteLength-r;if(!(o>0)){t=!1;break}e=this.reduceBuffer(e,r,o)}}t&&(a.debug("MultiBufferStream","Appending new buffer (fileStart: "+e.fileStart+" - Length: "+e.byteLength+")"),this.buffers.push(e),0===i&&(this.buffer=e))},h.prototype.logBufferLevel=function(e){var t,i,s,r,o,n=[],l="";for(s=0,r=0,t=0;t<this.buffers.length;t++)i=this.buffers[t],0===t?(o={},n.push(o),o.start=i.fileStart,o.end=i.fileStart+i.byteLength,l+="["+o.start+"-"):o.end===i.fileStart?o.end=i.fileStart+i.byteLength:((o={}).start=i.fileStart,l+=n[n.length-1].end-1+"], ["+o.start+"-",o.end=i.fileStart+i.byteLength,n.push(o)),s+=i.usedBytes,r+=i.byteLength;n.length>0&&(l+=o.end-1+"]");var h=e?a.info:a.debug;0===this.buffers.length?h("MultiBufferStream","No more buffer in memory"):h("MultiBufferStream",this.buffers.length+" stored buffer(s) ("+s+"/"+r+" bytes), continuous ranges: "+l)},h.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--)},h.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,s=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=s,a.debug("ISOFile","Concatenating buffer for box parsing (length: "+t+"->"+this.buffer.byteLength+")"),!0}return!1}return!1},h.prototype.findPosition=function(e,t,i){var s,r=null,o=-1;for(s=!0===e?0:this.bufferIndex;s<this.buffers.length&&(r=this.buffers[s]).fileStart<=t;)o=s,i&&(r.fileStart+r.byteLength<=t?r.usedBytes=r.byteLength:r.usedBytes=t-r.fileStart,this.logBufferLevel()),s++;return-1!==o&&(r=this.buffers[o]).fileStart+r.byteLength>=t?(a.debug("MultiBufferStream","Found position in existing buffer #"+o),o):-1},h.prototype.findEndContiguousBuf=function(e){var t,i,s,r=void 0!==e?e:this.bufferIndex;if(i=this.buffers[r],this.buffers.length>r+1)for(t=r+1;t<this.buffers.length&&(s=this.buffers[t]).fileStart===i.fileStart+i.byteLength;t++)i=s;return i.fileStart+i.byteLength},h.prototype.getEndFilePositionAfter=function(e){var t=this.findPosition(!0,e,!1);return-1!==t?this.findEndContiguousBuf(t):e},h.prototype.addUsedBytes=function(e){this.buffer.usedBytes+=e,this.logBufferLevel()},h.prototype.setAllUsedBytes=function(){this.buffer.usedBytes=this.buffer.byteLength,this.logBufferLevel()},h.prototype.seek=function(e,t,i){var s;return-1!==(s=this.findPosition(t,e,i))?(this.buffer=this.buffers[s],this.bufferIndex=s,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)},h.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},h.prototype.getLength=function(){return this.byteLength},h.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=h;var d=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 s,r,o,n=0;for(s=t.readUint8(),o=t.readUint8();128&o;)n=(127&o)<<7,o=t.readUint8();return n+=127&o,a.debug("MPEG4DescriptorParser","Found "+(e[s]||"Descriptor "+s)+", size "+n+" at position "+t.getPosition()),(r=e[s]?new i[e[s]](n):new i.Descriptor(n)).parse(t),r},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 s=t.parseOneDescriptor(e);this.descs.push(s)}},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 s=(248&i.data[0])>>3;return 31===s&&i.data.length>=2&&(s=32+((7&i.data[0])<<3)+((224&i.data[1])>>5)),s}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=d;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,s){c.ContainerBox.call(this,e,t),this.hdr_size=i,this.start=s},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,s){c.sampleEntryCodes[e].push(t),c[t+"SampleEntry"]=function(i){c[e+"SampleEntry"].call(this,t,i),c.addSubBoxArrays.call(this,s)},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,s){c.UUIDs.push(e),c.UUIDBoxes[e]=function(s){t?c.FullBox.call(this,"uuid",s,e):i?c.ContainerBox.call(this,"uuid",s,e):c.Box.call(this,"uuid",s,e)},c.UUIDBoxes[e].prototype=t?new c.FullBox:i?new c.ContainerBox:new c.Box,s&&(c.UUIDBoxes[e].prototype.parse=t?function(e){this.parseFullHeader(e),s&&s.call(this,e)}:s)}};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 s=e.readUint8().toString(16);t+=1===s.length?"0"+s:s}return t},c.parseOneBox=function(e,t,i){var s,r,o,n=e.getPosition(),l=0;if(e.getEndPosition()-n<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 h=e.readUint32(),d=e.readString(4),u=d;if(a.debug("BoxParser","Found box of type '"+d+"' and size "+h+" at position "+n),l=8,"uuid"==d){if(e.getEndPosition()-e.getPosition()<16||i-l<16)return e.seek(n),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=o=c.parseUUID(e)}if(1==h){if(e.getEndPosition()-e.getPosition()<8||i&&i-l<8)return e.seek(n),a.warn("BoxParser",'Not enough data in stream to parse the extended size of the "'+d+'" box'),{code:c.ERR_NOT_ENOUGH_DATA};h=e.readUint64(),l+=8}else if(0===h)if(i)h=i;else if("mdat"!==d)return a.error("BoxParser","Unlimited box size not supported for type: '"+d+"'"),s=new c.Box(d,h),{code:c.OK,box:s,size:s.size};return 0!==h&&h<l?(a.error("BoxParser","Box of type "+d+" has an invalid size "+h+" (too small to be a box)"),{code:c.ERR_NOT_ENOUGH_DATA,type:d,size:h,hdr_size:l,start:n}):0!==h&&i&&h>i?(a.error("BoxParser","Box of type '"+d+"' has a size "+h+" greater than its container size "+i),{code:c.ERR_NOT_ENOUGH_DATA,type:d,size:h,hdr_size:l,start:n}):0!==h&&n+h>e.getEndPosition()?(e.seek(n),a.info("BoxParser","Not enough data in stream to parse the entire '"+d+"' box"),{code:c.ERR_NOT_ENOUGH_DATA,type:d,size:h,hdr_size:l,start:n}):t?{code:c.OK,type:d,size:h,hdr_size:l,start:n}:(c[d+"Box"]?s=new c[d+"Box"](h):"uuid"!==d?(a.warn("BoxParser","Unknown box type: '"+d+"'"),(s=new c.Box(d,h)).has_unparsed_data=!0):c.UUIDBoxes[o]?s=new c.UUIDBoxes[o](h):(a.warn("BoxParser","Unknown uuid type: '"+o+"'"),(s=new c.Box(d,h)).uuid=o,s.has_unparsed_data=!0),s.hdr_size=l,s.start=n,s.write===c.Box.prototype.write&&"mdat"!==s.type&&(a.info("BoxParser","'"+u+"' box writing not yet implemented, keeping unparsed data in memory for later write"),s.parseDataAndRewind(e)),s.parse(e),(r=e.getPosition()-(s.start+s.size))<0?(a.warn("BoxParser","Parsing of box '"+u+"' did not read the entire indicated box data size (missing "+-r+" bytes), seeking forward"),e.seek(s.start+s.size)):r>0&&(a.error("BoxParser","Parsing of box '"+u+"' read "+r+" more bytes than the indicated box data size, seeking backwards"),0!==s.size&&e.seek(s.start+s.size)),{code:c.OK,box:s,size:s.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 s="uuid"!==i.type?i.type:i.uuid;this[s]?a.warn("Box of type "+s+" already stored in field of this type"):this[s]=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 s=e.readInt32();s<0&&a.warn("BoxParser","ctts box uses negative values without using version 1"),this.sample_offsets.push(s)}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(),s=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|s>>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 s={};this.ind_subs.push(s);var r=e.readUint8(),a=e.readUint8(),o=e.readUint8();s.fscod=r>>6,s.bsid=r>>1&31,s.bsmod=(1&r)<<4|a>>4&15,s.acmod=a>>1&7,s.lfeon=1&a,s.num_dep_sub=o>>1&15,s.num_dep_sub>0&&(s.chan_loc=(1&o)<<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 s=e.readUint8(),r=Math.min(127&s,i.length-1);if(r?e.readUint8Array(e.readUint24()):(e.readUint8Array(13),this.samplerate=e.readUint32()>>12,e.readUint8Array(20)),t.push(i[r]),128&s)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 s=e.readUint32(),r=0;r<s;r++){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 s={};this.entries.push(s),1===this.version?(s.segment_duration=e.readUint64(),s.media_time=e.readInt64()):(s.segment_duration=e.readUint32(),s.media_time=e.readInt32()),s.media_rate_integer=e.readInt16(),s.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),i=new d;this.esd=i.parseOneDescriptor(new n(t.buffer,0,n.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,s,r;this.configurationVersion=e.readUint8(),r=e.readUint8(),this.general_profile_space=r>>6,this.general_tier_flag=(32&r)>>5,this.general_profile_idc=31&r,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(),r=e.readUint8(),this.constantFrameRate=r>>6,this.numTemporalLayers=(13&r)>>3,this.temporalIdNested=(4&r)>>2,this.lengthSizeMinusOne=3&r,this.nalu_arrays=[];var a=e.readUint8();for(t=0;t<a;t++){var o=[];this.nalu_arrays.push(o),r=e.readUint8(),o.completeness=(128&r)>>7,o.nalu_type=63&r;var n=e.readUint16();for(i=0;i<n;i++){var l={};o.push(l),s=e.readUint16(),l.data=e.readUint8Array(s)}}})),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 s=0;s<i;s++){var r={};if(this.items.push(r),this.version<2)r.item_ID=e.readUint16();else{if(2!==this.version)throw"version of iloc box not supported";r.item_ID=e.readUint16()}switch(1===this.version||2===this.version?r.construction_method=15&e.readUint16():r.construction_method=0,r.data_reference_index=e.readUint16(),this.base_offset_size){case 0:r.base_offset=0;break;case 4:r.base_offset=e.readUint32();break;case 8:r.base_offset=e.readUint64();break;default:throw"Error reading base offset size"}var a=e.readUint16();r.extents=[];for(var o=0;o<a;o++){var n={};if(r.extents.push(n),1===this.version||2===this.version)switch(this.index_size){case 0:n.extent_index=0;break;case 4:n.extent_index=e.readUint32();break;case 8:n.extent_index=e.readUint64();break;default:throw"Error reading extent index"}switch(this.offset_size){case 0:n.extent_offset=0;break;case 4:n.extent_offset=e.readUint32();break;case 8:n.extent_offset=e.readUint64();break;default:throw"Error reading extent index"}switch(this.length_size){case 0:n.extent_length=0;break;case 4:n.extent_length=e.readUint32();break;case 8:n.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 s={};this.associations.push(s),this.version<1?s.id=e.readUint16():s.id=e.readUint32();var r=e.readUint8();for(s.props=[],i=0;i<r;i++){var a=e.readUint8(),o={};s.props.push(o),o.essential=(128&a)>>7==1,1&this.flags?o.property_index=(127&a)<<8|e.readUint8():o.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 s={};this.levels[i]=s,s.track_ID=e.readUint32();var r=e.readUint8();switch(s.padding_flag=r>>7,s.assignment_type=127&r,s.assignment_type){case 0:s.grouping_type=e.readString(4);break;case 1:s.grouping_type=e.readString(4),s.grouping_type_parameter=e.readUint32();break;case 2:case 3:break;case 4:s.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 s=e.readUint32();s>0&&(this.data=e.readUint8Array(s))})),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 s=this.description_length-4-4*i;for(this.num_output_samples=[],this.num_total_samples=[],t=0;t<s/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(),s=0;s<i;s++){var r={};this.dependency.push(r),r.subSeqDirectionFlag=e.readUint8(),r.layerNumber=e.readUint8(),r.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 s={};this.entries.push(s),s.sample_count=e.readInt32(),s.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 s=0;s<i;s++)t=e.readUint8(),this.is_leading[s]=t>>6,this.sample_depends_on[s]=t>>4&3,this.sample_is_depended_on[s]=t>>2&3,this.sample_has_redundancy[s]=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 s;s=c[this.grouping_type+"SampleGroupEntry"]?new c[this.grouping_type+"SampleGroupEntry"](this.grouping_type):new c.SampleGroupEntry(this.grouping_type),this.entries.push(s),1===this.version&&0===this.default_length?s.description_length=e.readUint32():s.description_length=this.default_length,s.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"),s.data=e.readUint8Array(s.description_length),e.position-=s.description_length),s.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 s={};this.references.push(s);var r=e.readUint32();s.reference_type=r>>31&1,s.referenced_size=2147483647&r,s.subsegment_duration=e.readUint32(),r=e.readUint32(),s.starts_with_SAP=r>>31&1,s.SAP_type=r>>28&7,s.SAP_delta_time=268435455&r}})),c.SingleItemTypeReferenceBox=function(e,t,i,s){c.Box.call(this,e,t),this.hdr_size=i,this.start=s},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,s){c.Box.call(this,e,t),this.hdr_size=i,this.start=s},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 s={};this.subsegments.push(s),s.ranges=[];for(var r=e.readUint32(),a=0;a<r;a++){var o={};s.ranges.push(o),o.level=e.readUint8(),o.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,s,r;for(this.entries=[],s=e.readUint32(),t=1;t<=s;t++){if((i=c.parseOneBox(e,!0,this.size-(e.getPosition()-this.start))).code!==c.OK)return;c[i.type+"SampleEntry"]?((r=new c[i.type+"SampleEntry"](i.size)).hdr_size=i.hdr_size,r.start=i.start):(a.warn("BoxParser","Unknown sample entry type: "+i.type),r=new c.SampleEntry(i.type,i.size,i.hdr_size,i.start)),r.write===c.SampleEntry.prototype.write&&(a.info("BoxParser","SampleEntry "+r.type+" box writing not yet implemented, keeping unparsed data in memory for later write"),r.parseDataAndRewind(e)),r.parse(e),this.entries.push(r)}})),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,s;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()),(s=e.readInt32())<0&&(a.warn("BoxParser","File uses negative stts sample delta, using value 1 instead, sync may be lost!"),s=1),this.sample_deltas.push(s)})),c.createFullBoxCtor("stvi",(function(e){var t=e.readUint32();this.single_view_allowed=3&t,this.stereo_scheme=e.readUint32();var i,s,r=e.readUint32();for(this.stereo_indication_type=e.readString(r),this.boxes=[];e.getPosition()<this.start+this.size;){if((i=c.parseOneBox(e,!1,this.size-(e.getPosition()-this.start))).code!==c.OK)return;s=i.box,this.boxes.push(s),this[s.type]=s}})),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 s=e.readUint8();this.sample_sizes[t]=s>>4&15,this.sample_sizes[t+1]=15&s}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,s,r;for(s=e.readUint32(),this.entries=[],t=0;t<s;t++){var a={};if(this.entries[t]=a,a.sample_delta=e.readUint32(),a.subsamples=[],(r=e.readUint16())>0)for(i=0;i<r;i++){var o={};a.subsamples.push(o),1==this.version?o.size=e.readUint32():o.size=e.readUint16(),o.priority=e.readUint8(),o.discardable=e.readUint8(),o.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(),s=0;s<i;s++)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,s){c.Box.call(this,e,t),this.hdr_size=i,this.start=s},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={},s=0,r=0;1===this.version?(s=e.readUint64(),r=e.readUint64()):(s=e.readUint32(),r=e.readUint32()),i.absolute_time=s,i.absolute_duration=r,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,s={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(s.stream_read_1_bytes(e),s.extract_bits(5),this.lengthSizeMinusOne=s.extract_bits(2),this.ptl_present_flag=s.extract_bits(1),this.ptl_present_flag){if(s.stream_read_2_bytes(e),this.ols_idx=s.extract_bits(9),this.num_sublayers=s.extract_bits(3),this.constant_frame_rate=s.extract_bits(2),this.chroma_format_idc=s.extract_bits(2),s.stream_read_1_bytes(e),this.bit_depth_minus8=s.extract_bits(3),s.extract_bits(5),s.stream_read_2_bytes(e),s.extract_bits(2),this.num_bytes_constraint_info=s.extract_bits(6),this.general_profile_idc=s.extract_bits(7),this.general_tier_flag=s.extract_bits(1),this.general_level_idc=e.readUint8(),s.stream_read_1_bytes(e),this.ptl_frame_only_constraint_flag=s.extract_bits(1),this.ptl_multilayer_enabled_flag=s.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 r=s.extract_bits(6);s.stream_read_1_bytes(e);var a=s.extract_bits(2);this.general_constraint_info[t]=r<<2|a}this.general_constraint_info[this.num_bytes_constraint_info-1]=s.extract_bits(6)}else s.extract_bits(6);for(s.stream_read_1_bytes(e),this.ptl_sublayer_present_mask=0,i=this.num_sublayers-2;i>=0;--i){var o=s.extract_bits(1);this.ptl_sublayer_present_mask|=o<<i}for(i=this.num_sublayers;i<=8&&this.num_sublayers>1;++i)s.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 n=e.readUint8();for(t=0;t<n;t++){var l=[];this.nalu_arrays.push(l),s.stream_read_1_bytes(e),l.completeness=s.extract_bits(1),s.extract_bits(2),l.nalu_type=s.extract_bits(5);var h=1;for(13!=l.nalu_type&&12!=l.nalu_type&&(h=e.readUint16()),i=0;i<h;i++){var d=e.readUint16();l.push({data:e.readUint8Array(d),length:d})}}})),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,s=0;for(e=0;e<32&&(s|=1&i,31!=e);e++)s<<=1,i>>=1;t+=c.decimalToHex(s,0),t+=".",0===this.hvcC.general_tier_flag?t+="L":t+="H",t+=this.hvcC.general_level_idc;var r=!1,a="";for(e=5;e>=0;e--)(this.hvcC.general_constraint_indicator[e]||r)&&(a="."+c.decimalToHex(this.hvcC.general_constraint_indicator[e],0)+a,r=!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 s,r=[],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,r.push(a),a&&(s=e),a=this.vvcC.general_constraint_info[e]>>2&3;if(void 0===s)i=".CA";else{i=".C";var o="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",n=0,l=0;for(e=0;e<=s;++e)for(n=n<<8|r[e],l+=8;l>=5;){i+=o[n>>l-5&31],n&=(1<<(l-=5))-1}l&&(i+=o[31&(n<<=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,s;for(s=0,t=0;t<this.sample_counts.length;t++)for(i=0;i<this.sample_counts[t];i++)e[s].pts=e[s].dts+this.sample_offsets[t],s++},c.sttsBox.prototype.unpack=function(e){var t,i,s;for(s=0,t=0;t<this.sample_counts.length;t++)for(i=0;i<this.sample_counts[t];i++)e[s].dts=0===s?0:e[s-1].dts+this.sample_deltas[t],s++},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,s,r,a;for(r=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++,s=0;s<this.samples_per_chunk[t];s++){if(!e[r])return;e[r].description_index=this.sample_description_index[t],e[r].chunk_index=a,r++}},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 s=c.DIFF_BOXES_PROP_NAMES[i];if(e[s]&&t[s]&&!c.boxEqual(e[s],t[s]))return!1}return!0};var u=function(){};u.prototype.parseSample=function(e){var t,i={};i.resources=[];var s=new o(e.data.buffer);if(e.subsamples&&0!==e.subsamples.length){if(i.documentString=s.readString(e.subsamples[0].size),e.subsamples.length>1)for(t=1;t<e.subsamples.length;t++)i.resources[t]=s.readUint8Array(e.subsamples[t].size)}else i.documentString=s.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 o(e.data.buffer).readString(e.data.length)},p.prototype.parseConfig=function(e){var t=new o(e.buffer);return t.readUint32(),t.readCString()},t.XMLSubtitlein4Parser=u,t.Textin4Parser=p;var f=function(e){this.stream=e||new h,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 s=this.getTrackById(e);if(s){var r={};this.fragmentedTracks.push(r),r.id=e,r.user=t,r.trak=s,s.nextSample=0,r.segmentStream=null,r.nb_samples=1e3,r.rapAlignement=!0,i&&(i.nbSamples&&(r.nb_samples=i.nbSamples),i.rapAlignement&&(r.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 s=this.getTrackById(e);if(s){var r={};this.extractedTracks.push(r),r.id=e,r.user=t,r.trak=s,s.nextSample=0,r.nb_samples=1e3,r.samples=[],i&&i.nbSamples&&(r.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,s,r,a,o={},n=new Date("1904-01-01T00:00:00Z").getTime();if(this.moov)for(o.hasMoov=!0,o.duration=this.moov.mvhd.duration,o.timescale=this.moov.mvhd.timescale,o.isFragmented=null!=this.moov.mvex,o.isFragmented&&this.moov.mvex.mehd&&(o.fragment_duration=this.moov.mvex.mehd.fragment_duration),o.isProgressive=this.isProgressive,o.hasIOD=null!=this.moov.iods,o.brands=[],o.brands.push(this.ftyp.major_brand),o.brands=o.brands.concat(this.ftyp.compatible_brands),o.created=new Date(n+1e3*this.moov.mvhd.creation_time),o.modified=new Date(n+1e3*this.moov.mvhd.modification_time),o.tracks=[],o.audioTracks=[],o.videoTracks=[],o.subtitleTracks=[],o.metadataTracks=[],o.hintTracks=[],o.otherTracks=[],e=0;e<this.moov.traks.length;e++){if(a=(i=this.moov.traks[e]).mdia.minf.stbl.stsd.entries[0],s={},o.tracks.push(s),s.id=i.tkhd.track_id,s.name=i.mdia.hdlr.name,s.references=[],i.tref)for(t=0;t<i.tref.boxes.length;t++)r={},s.references.push(r),r.type=i.tref.boxes[t].type,r.track_ids=i.tref.boxes[t].track_ids;i.edts&&(s.edits=i.edts.elst.entries),s.created=new Date(n+1e3*i.tkhd.creation_time),s.modified=new Date(n+1e3*i.tkhd.modification_time),s.movie_duration=i.tkhd.duration,s.movie_timescale=o.timescale,s.layer=i.tkhd.layer,s.alternate_group=i.tkhd.alternate_group,s.volume=i.tkhd.volume,s.matrix=i.tkhd.matrix,s.track_width=i.tkhd.width/65536,s.track_height=i.tkhd.height/65536,s.timescale=i.mdia.mdhd.timescale,s.cts_shift=i.mdia.minf.stbl.cslg,s.duration=i.mdia.mdhd.duration,s.samples_duration=i.samples_duration,s.codec=a.getCodec(),s.kind=i.udta&&i.udta.kinds.length?i.udta.kinds[0]:{schemeURI:"",value:""},s.language=i.mdia.elng?i.mdia.elng.extended_language:i.mdia.mdhd.languageString,s.nb_samples=i.samples.length,s.size=i.samples_size,s.bitrate=8*s.size*s.timescale/s.samples_duration,a.isAudio()?(s.type="audio",o.audioTracks.push(s),s.audio={},s.audio.sample_rate=a.getSampleRate(),s.audio.channel_count=a.getChannelCount(),s.audio.sample_size=a.getSampleSize()):a.isVideo()?(s.type="video",o.videoTracks.push(s),s.video={},s.video.width=a.getWidth(),s.video.height=a.getHeight()):a.isSubtitle()?(s.type="subtitles",o.subtitleTracks.push(s)):a.isHint()?(s.type="metadata",o.hintTracks.push(s)):a.isMetadata()?(s.type="metadata",o.metadataTracks.push(s)):(s.type="metadata",o.otherTracks.push(s))}else o.hasMoov=!1;if(o.mime="",o.hasMoov&&o.tracks){for(o.videoTracks&&o.videoTracks.length>0?o.mime+='video/mp4; codecs="':o.audioTracks&&o.audioTracks.length>0?o.mime+='audio/mp4; codecs="':o.mime+='application/mp4; codecs="',e=0;e<o.tracks.length;e++)0!==e&&(o.mime+=","),o.mime+=o.tracks[e].codec;o.mime+='"; profiles="',o.mime+=this.ftyp.compatible_brands.join(),o.mime+='"'}return o},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 s=this.fragmentedTracks[t];for(i=s.trak;i.nextSample<i.samples.length&&this.sampleProcessingStarted;){a.debug("ISOFile","Creating media fragment on track #"+s.id+" for sample "+i.nextSample);var r=this.createFragment(s.id,i.nextSample,s.segmentStream);if(!r)break;if(s.segmentStream=r,i.nextSample++,(i.nextSample%s.nb_samples==0||e||i.nextSample>=i.samples.length)&&(a.info("ISOFile","Sending fragmented data on track #"+s.id+" for samples ["+Math.max(0,i.nextSample-s.nb_samples)+","+(i.nextSample-1)+"]"),a.info("ISOFile","Sample data size in memory: "+this.getAllocatedSampleDataSize()),this.onSegment&&this.onSegment(s.id,s.user,s.segmentStream.buffer,i.nextSample,e||i.nextSample>=i.samples.length),s.segmentStream=null,s!==this.fragmentedTracks[t]))break}}if(null!==this.onSamples)for(t=0;t<this.extractedTracks.length;t++){var o=this.extractedTracks[t];for(i=o.trak;i.nextSample<i.samples.length&&this.sampleProcessingStarted;){a.debug("ISOFile","Exporting on track #"+o.id+" sample #"+i.nextSample);var n=this.getSample(i,i.nextSample);if(!n)break;if(i.nextSample++,o.samples.push(n),(i.nextSample%o.nb_samples==0||i.nextSample>=i.samples.length)&&(a.debug("ISOFile","Sending samples on track #"+o.id+" for sample "+i.nextSample),this.onSamples&&this.onSamples(o.id,o.user,o.samples),o.samples=[],o!==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 s in this.type&&this.type==e&&t.push(this),this.boxes){if(t.length&&i)return;f._sweep.call(this.boxes[s],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,s=this.getTrackById(e);s.lastValidSample||(s.lastValidSample=0);for(var r=s.lastValidSample;r<t;r++)i+=this.releaseSample(s,r);a.info("ISOFile","Track #"+e+" released samples up to "+t+" (released size: "+i+", remaining: "+this.samplesDataSize+")"),s.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 s,r,o,n,l=0,h=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(s=0;s<i.samples.length;s++){if(r=i.samples[s],0===s)h=0,n=r.timescale;else if(r.cts>e*r.timescale){h=s-1;break}t&&r.is_sync&&(l=s)}for(t&&(h=l),e=i.samples[h].cts,i.nextSample=h;i.samples[h].alreadyRead===i.samples[h].size&&i.samples[h+1];)h++;return o=i.samples[h].offset+i.samples[h].alreadyRead,a.info("ISOFile","Seeking to "+(t?"RAP":"")+" sample #"+i.nextSample+" on track "+i.tkhd.track_id+", time "+a.getDurationString(e,n)+" and offset: "+o),{offset:o,time:e/n}},f.prototype.seek=function(e,t){var i,s,r,o=this.moov,n={offset:1/0,time:1/0};if(this.moov){for(r=0;r<o.traks.length;r++)i=o.traks[r],(s=this.seekTrack(e,t,i)).offset<n.offset&&(n.offset=s.offset),s.time<n.time&&(n.time=s.time);return a.info("ISOFile","Seeking at time "+a.getDurationString(n.time,1)+" needs a buffer with a fileStart position of "+n.offset),n.offset===1/0?n={offset:this.nextParsePosition,time:0}:n.offset=this.stream.getEndFilePositionAfter(n.offset),a.info("ISOFile","Adjusted seek position (after checking data already in buffer): "+n.offset),n}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],s=e.boxes[t];if(!c.boxEqual(i,s))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 s=i.add("mdia");s.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"),s.add("hdlr").set("handler",t.hdlr||"vide").set("name",t.name||"Track created with MP4Box.js"),s.add("elng").set("extended_language",t.language||"fr-FR");var r=s.add("minf");if(void 0!==c[t.type+"SampleEntry"]){var a=new c[t.type+"SampleEntry"];a.data_reference_index=1;var n="";for(var l in c.sampleEntryCodes)for(var h=c.sampleEntryCodes[l],d=0;d<h.length;d++)if(h.indexOf(t.type)>-1){n=l;break}switch(n){case"Visual":if(r.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 o(t.avcDecoderConfigRecord);u.parse(p),a.addBox(u)}break;case"Audio":r.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":r.add("hmhd");break;case"Subtitle":if(r.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:r.add("nmhd")}t.description&&a.addBox(t.description),t.description_boxes&&t.description_boxes.forEach((function(e){a.addBox(e)})),r.add("dinf").add("dref").addEntry((new c["url Box"]).set("flags",1));var f=r.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 n;t.endianness=n.BIG_ENDIAN,this.write(t)},f.prototype.addSample=function(e,t,i){var s=i||{},r={},a=this.getTrackById(e);if(null!==a){r.number=a.samples.length,r.track_id=a.tkhd.track_id,r.timescale=a.mdia.mdhd.timescale,r.description_index=s.sample_description_index?s.sample_description_index-1:0,r.description=a.mdia.minf.stbl.stsd.entries[r.description_index],r.data=t,r.size=t.byteLength,r.alreadyRead=r.size,r.duration=s.duration||1,r.cts=s.cts||0,r.dts=s.dts||0,r.is_sync=s.is_sync||!1,r.is_leading=s.is_leading||0,r.depends_on=s.depends_on||0,r.is_depended_on=s.is_depended_on||0,r.has_redundancy=s.has_redundancy||0,r.degradation_priority=s.degradation_priority||0,r.offset=0,r.subsamples=s.subsamples,a.samples.push(r),a.samples_size+=r.size,a.samples_duration+=r.duration,a.first_dts||(a.first_dts=s.dts),this.processSamples();var o=this.createSingleSampleMoof(r);return this.addBox(o),o.computeSize(),o.trafs[0].truns[0].data_offset=o.size+8,this.add("mdat").data=new Uint8Array(t),r}},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 s=i.add("traf"),r=this.getTrackById(e.track_id);return s.add("tfhd").set("track_id",e.track_id).set("flags",c.TFHD_FLAG_DEFAULT_BASE_IS_MOOF),s.add("tfdt").set("baseMediaDecodeTime",e.dts-(r.first_dts||0)),s.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,s,r,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=[],(s=t.mdia.minf.stbl.stts).sample_counts=[],s.sample_deltas=[],(r=t.mdia.minf.stbl.ctts)&&(r.sample_counts=[],r.sample_offsets=[]),a=t.mdia.minf.stbl.stss;var o=t.mdia.minf.stbl.boxes.indexOf(a);-1!=o&&(t.mdia.minf.stbl.boxes[o]=null)}},f.initSampleGroups=function(e,t,i,s,r){var a,o,n,l;function h(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=[]),o=0;o<i.length;o++){for(l=i[o].grouping_type+"/"+i[o].grouping_type_parameter,n=new h(i[o].grouping_type,i[o].grouping_type_parameter,i[o]),t&&(t.sample_groups_info[l]=n),e.sample_groups_info[l]||(e.sample_groups_info[l]=n),a=0;a<s.length;a++)s[a].grouping_type===i[o].grouping_type&&(n.description=s[a],n.description.used=!0);if(r)for(a=0;a<r.length;a++)r[a].grouping_type===i[o].grouping_type&&(n.fragment_description=r[a],n.fragment_description.used=!0,n.is_fragment=!0)}if(t){if(r)for(o=0;o<r.length;o++)!r[o].used&&r[o].version>=2&&(l=r[o].grouping_type+"/0",(n=new h(r[o].grouping_type,0)).is_fragment=!0,t.sample_groups_info[l]||(t.sample_groups_info[l]=n))}else for(o=0;o<s.length;o++)!s[o].used&&s[o].version>=2&&(l=s[o].grouping_type+"/0",n=new h(s[o].grouping_type,0),e.sample_groups_info[l]||(e.sample_groups_info[l]=n))},f.setSampleGroupProperties=function(e,t,i,s){var r,a;for(r in t.sample_groups=[],s){var o;if(t.sample_groups[r]={},t.sample_groups[r].grouping_type=s[r].grouping_type,t.sample_groups[r].grouping_type_parameter=s[r].grouping_type_parameter,i>=s[r].last_sample_in_run&&(s[r].last_sample_in_run<0&&(s[r].last_sample_in_run=0),s[r].entry_index++,s[r].entry_index<=s[r].sbgp.entries.length-1&&(s[r].last_sample_in_run+=s[r].sbgp.entries[s[r].entry_index].sample_count)),s[r].entry_index<=s[r].sbgp.entries.length-1?t.sample_groups[r].group_description_index=s[r].sbgp.entries[s[r].entry_index].group_description_index:t.sample_groups[r].group_description_index=-1,0!==t.sample_groups[r].group_description_index)o=s[r].fragment_description?s[r].fragment_description:s[r].description,t.sample_groups[r].group_description_index>0?(a=t.sample_groups[r].group_description_index>65535?(t.sample_groups[r].group_description_index>>16)-1:t.sample_groups[r].group_description_index-1,o&&a>=0&&(t.sample_groups[r].description=o.entries[a])):o&&o.version>=2&&o.default_group_description_index>0&&(t.sample_groups[r].description=o.entries[o.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,s,r,a,o,n,l,h,d,c,u,p,m,g,y,A,b,v,_,w,S,T,E;if(e.samples=[],e.samples_duration=0,e.samples_size=0,i=e.mdia.minf.stbl.stco||e.mdia.minf.stbl.co64,s=e.mdia.minf.stbl.stsc,r=e.mdia.minf.stbl.stsz||e.mdia.minf.stbl.stz2,a=e.mdia.minf.stbl.stts,o=e.mdia.minf.stbl.ctts,n=e.mdia.minf.stbl.stss,l=e.mdia.minf.stbl.stsd,h=e.mdia.minf.stbl.subs,u=e.mdia.minf.stbl.stdp,d=e.mdia.minf.stbl.sbgps,c=e.mdia.minf.stbl.sgpds,b=-1,v=-1,_=-1,w=-1,S=0,T=0,E=0,f.initSampleGroups(e,null,d,c),void 0!==r){for(t=0;t<r.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=r.sample_sizes[t],e.samples_size+=k.size,0===t?(m=1,p=0,k.chunk_index=m,k.chunk_run_index=p,A=s.samples_per_chunk[p],y=0,g=p+1<s.first_chunk.length?s.first_chunk[p+1]-1:1/0):t<A?(k.chunk_index=m,k.chunk_run_index=p):(m++,k.chunk_index=m,y=0,m<=g||(g=++p+1<s.first_chunk.length?s.first_chunk[p+1]-1:1/0),k.chunk_run_index=p,A+=s.samples_per_chunk[p]),k.description_index=s.sample_description_index[k.chunk_run_index]-1,k.description=l.entries[k.description_index],k.offset=i.chunk_offsets[k.chunk_index-1]+y,y+=k.size,t>b&&(v++,b<0&&(b=0),b+=a.sample_counts[v]),t>0?(e.samples[t-1].duration=a.sample_deltas[v],e.samples_duration+=e.samples[t-1].duration,k.dts=e.samples[t-1].dts+e.samples[t-1].duration):k.dts=0,o?(t>=_&&(w++,_<0&&(_=0),_+=o.sample_counts[w]),k.cts=e.samples[t].dts+o.sample_offsets[w]):k.cts=k.dts,n?(t==n.sample_numbers[S]-1?(k.is_sync=!0,S++):(k.is_sync=!1,k.degradation_priority=0),h&&h.entries[T].sample_delta+E==t+1&&(k.subsamples=h.entries[T].subsamples,E+=h.entries[T].sample_delta,T++)):k.is_sync=!0,f.process_sdtp(e.mdia.minf.stbl.sdtp,k,k.number),k.degradation_priority=u?u.priority[t]:0,h&&h.entries[T].sample_delta+E==t&&(k.subsamples=h.entries[T].subsamples,E+=h.entries[T].sample_delta),(d.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,s,r,a,o,n,l,h,d,u,p,m,g;if(void 0!==this.moov)for(;this.lastMoofIndex<this.moofs.length;)if(l=this.moofs[this.lastMoofIndex],this.lastMoofIndex++,"moof"==l.type)for(h=l,e=0;e<h.trafs.length;e++){for(d=h.trafs[e],u=this.getTrackById(d.tfhd.track_id),p=this.getTrexById(d.tfhd.track_id),s=d.tfhd.flags&c.TFHD_FLAG_SAMPLE_DESC?d.tfhd.default_sample_description_index:p?p.default_sample_description_index:1,r=d.tfhd.flags&c.TFHD_FLAG_SAMPLE_DUR?d.tfhd.default_sample_duration:p?p.default_sample_duration:0,a=d.tfhd.flags&c.TFHD_FLAG_SAMPLE_SIZE?d.tfhd.default_sample_size:p?p.default_sample_size:0,o=d.tfhd.flags&c.TFHD_FLAG_SAMPLE_FLAGS?d.tfhd.default_sample_flags:p?p.default_sample_flags:0,d.sample_number=0,d.sbgps.length>0&&f.initSampleGroups(u,d,d.sbgps,u.mdia.minf.stbl.sgpds,d.sgpds),t=0;t<d.truns.length;t++){var y=d.truns[t];for(i=0;i<y.sample_count;i++){(m={}).moof_number=this.lastMoofIndex,m.number_in_traf=d.sample_number,d.sample_number++,m.number=u.samples.length,d.first_sample_index=u.samples.length,u.samples.push(m),m.track_id=u.tkhd.track_id,m.timescale=u.mdia.mdhd.timescale,m.description_index=s-1,m.description=u.mdia.minf.stbl.stsd.entries[m.description_index],m.size=a,y.flags&c.TRUN_FLAGS_SIZE&&(m.size=y.sample_size[i]),u.samples_size+=m.size,m.duration=r,y.flags&c.TRUN_FLAGS_DURATION&&(m.duration=y.sample_duration[i]),u.samples_duration+=m.duration,u.first_traf_merged||i>0?m.dts=u.samples[u.samples.length-2].dts+u.samples[u.samples.length-2].duration:(d.tfdt?m.dts=d.tfdt.baseMediaDecodeTime:m.dts=0,u.first_traf_merged=!0),m.cts=m.dts,y.flags&c.TRUN_FLAGS_CTS_OFFSET&&(m.cts=m.dts+y.sample_composition_time_offset[i]),g=o,y.flags&c.TRUN_FLAGS_FLAGS?g=y.sample_flags[i]:0===i&&y.flags&c.TRUN_FLAGS_FIRST_FLAG&&(g=y.first_sample_flags),m.is_sync=!(g>>16&1),m.is_leading=g>>26&3,m.depends_on=g>>24&3,m.is_depended_on=g>>22&3,m.has_redundancy=g>>20&3,m.degradation_priority=65535&g;var A=!!(d.tfhd.flags&c.TFHD_FLAG_BASE_DATA_OFFSET),b=!!(d.tfhd.flags&c.TFHD_FLAG_DEFAULT_BASE_IS_MOOF),v=!!(y.flags&c.TRUN_FLAGS_DATA_OFFSET),_=0;_=A?d.tfhd.base_data_offset:b||0===t?h.start:n,m.offset=0===t&&0===i?v?_+y.data_offset:_:n,n=m.offset+m.size,(d.sbgps.length>0||d.sgpds.length>0||u.mdia.minf.stbl.sbgps.length>0||u.mdia.minf.stbl.sgpds.length>0)&&f.setSampleGroupProperties(u,m,m.number_in_traf,d.sample_groups_info)}}if(d.subs){u.has_fragment_subsamples=!0;var w=d.first_sample_index;for(t=0;t<d.subs.entries.length;t++)w+=d.subs.entries[t].sample_delta,(m=u.samples[w-1]).subsamples=d.subs.entries[t].subsamples}}},f.prototype.getSample=function(e,t){var i,s=e.samples[t];if(!this.moov)return null;if(s.data){if(s.alreadyRead==s.size)return s}else s.data=new Uint8Array(s.size),s.alreadyRead=0,this.samplesDataSize+=s.size,a.debug("ISOFile","Allocating sample #"+t+" on track #"+e.tkhd.track_id+" of size "+s.size+" (total: "+this.samplesDataSize+")");for(;;){var r=this.stream.findPosition(!0,s.offset+s.alreadyRead,!1);if(!(r>-1))return null;var o=(i=this.stream.buffers[r]).byteLength-(s.offset+s.alreadyRead-i.fileStart);if(s.size-s.alreadyRead<=o)return a.debug("ISOFile","Getting sample #"+t+" data (alreadyRead: "+s.alreadyRead+" offset: "+(s.offset+s.alreadyRead-i.fileStart)+" read size: "+(s.size-s.alreadyRead)+" full size: "+s.size+")"),n.memcpy(s.data.buffer,s.alreadyRead,i,s.offset+s.alreadyRead-i.fileStart,s.size-s.alreadyRead),i.usedBytes+=s.size-s.alreadyRead,this.stream.logBufferLevel(),s.alreadyRead=s.size,s;if(0===o)return null;a.debug("ISOFile","Getting sample #"+t+" partial data (alreadyRead: "+s.alreadyRead+" offset: "+(s.offset+s.alreadyRead-i.fileStart)+" read size: "+o+" full size: "+s.size+")"),n.memcpy(s.data.buffer,s.alreadyRead,i,s.offset+s.alreadyRead-i.fileStart,o),s.alreadyRead+=o,i.usedBytes+=o,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,s=this.items,r=this.meta;if(null!=r&&void 0!==r.hdlr&&void 0!==r.iinf){for(e=0;e<r.iinf.item_infos.length;e++)(i={}).id=r.iinf.item_infos[e].item_ID,s[i.id]=i,i.ref_to=[],i.name=r.iinf.item_infos[e].item_name,r.iinf.item_infos[e].protection_index>0&&(i.protection=r.ipro.protections[r.iinf.item_infos[e].protection_index-1]),r.iinf.item_infos[e].item_type?i.type=r.iinf.item_infos[e].item_type:i.type="mime",i.content_type=r.iinf.item_infos[e].content_type,i.content_encoding=r.iinf.item_infos[e].content_encoding;if(r.iloc)for(e=0;e<r.iloc.items.length;e++){var o=r.iloc.items[e];switch(i=s[o.item_ID],0!==o.data_reference_index&&(a.warn("Item storage with reference to other files: not supported"),i.source=r.dinf.boxes[o.data_reference_index-1]),o.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<o.extents.length;t++)i.extents[t]={},i.extents[t].offset=o.extents[t].extent_offset+o.base_offset,i.extents[t].length=o.extents[t].extent_length,i.extents[t].alreadyRead=0,i.size+=i.extents[t].length}if(r.pitm&&(s[r.pitm.item_id].primary=!0),r.iref)for(e=0;e<r.iref.references.length;e++){var n=r.iref.references[e];for(t=0;t<n.references.length;t++)s[n.from_item_ID].ref_to.push({type:n.type,id:n.references[t]})}if(r.iprp)for(var l=0;l<r.iprp.ipmas.length;l++){var h=r.iprp.ipmas[l];for(e=0;e<h.associations.length;e++){var d=h.associations[e];for(void 0===(i=s[d.id]).properties&&(i.properties={},i.properties.boxes=[]),t=0;t<d.props.length;t++){var c=d.props[t];if(c.property_index>0&&c.property_index-1<r.iprp.ipco.boxes.length){var u=r.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 s=0;s<i.extents.length;s++){var r=i.extents[s];if(r.alreadyRead!==r.length){var o=this.stream.findPosition(!0,r.offset+r.alreadyRead,!1);if(!(o>-1))return null;var l=(t=this.stream.buffers[o]).byteLength-(r.offset+r.alreadyRead-t.fileStart);if(!(r.length-r.alreadyRead<=l))return a.debug("ISOFile","Getting item #"+e+" extent #"+s+" partial data (alreadyRead: "+r.alreadyRead+" offset: "+(r.offset+r.alreadyRead-t.fileStart)+" read size: "+l+" full extent size: "+r.length+" full item size: "+i.size+")"),n.memcpy(i.data.buffer,i.alreadyRead,t,r.offset+r.alreadyRead-t.fileStart,l),r.alreadyRead+=l,i.alreadyRead+=l,t.usedBytes+=l,this.stream.logBufferLevel(),null;a.debug("ISOFile","Getting item #"+e+" extent #"+s+" data (alreadyRead: "+r.alreadyRead+" offset: "+(r.offset+r.alreadyRead-t.fileStart)+" read size: "+(r.length-r.alreadyRead)+" full extent size: "+r.length+" full item size: "+i.size+")"),n.memcpy(i.data.buffer,i.alreadyRead,t,r.offset+r.alreadyRead-t.fileStart,r.length-r.alreadyRead),t.usedBytes+=r.length-r.alreadyRead,this.stream.logBufferLevel(),i.alreadyRead+=r.length-r.alreadyRead,r.alreadyRead=r.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 s=new f;s.discardMdatData=!1;var r={type:i.type,description_boxes:i.properties.boxes};i.properties.ispe&&(r.width=i.properties.ispe.image_width,r.height=i.properties.ispe.image_height);var a=s.addTrack(r);return a?(s.addSample(a,i.data),s):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 s=this.getTrackById(e),r=this.getSample(s,t);if(null==r)return r=s.samples[t],this.nextSeekPosition?this.nextSeekPosition=Math.min(r.offset+r.alreadyRead,this.nextSeekPosition):this.nextSeekPosition=s.samples[t].offset+r.alreadyRead,null;var o=i||new n;o.endianness=n.BIG_ENDIAN;var l=this.createSingleSampleMoof(r);l.write(o),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),o.adjustUint32(l.trafs[0].truns[0].data_offset_position,l.trafs[0].truns[0].data_offset);var h=new c.mdatBox;return h.data=r.data,h.write(o),o},f.writeInitializationSegment=function(e,t,i,s){var r;a.debug("ISOFile","Generating initialization segment");var o=new n;o.endianness=n.BIG_ENDIAN,e.write(o);var l=t.add("mvex");for(i&&l.add("mehd").set("fragment_duration",i),r=0;r<t.traks.length;r++)l.add("trex").set("track_id",t.traks[r].tkhd.track_id).set("default_sample_description_index",1).set("default_sample_duration",s).set("default_sample_size",0).set("default_sample_flags",65536);return t.write(o),o.buffer},f.prototype.save=function(e){var t=new n;t.endianness=n.BIG_ENDIAN,this.write(t),t.save(e)},f.prototype.getBuffer=function(){var e=new n;return e.endianness=n.BIG_ENDIAN,this.write(e),e.buffer},f.prototype.initializeSegmentation=function(){var e,t,i,s;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 r=new c.moovBox;r.mvhd=this.moov.mvhd,r.boxes.push(r.mvhd),i=this.getTrackById(this.fragmentedTracks[e].id),r.boxes.push(i),r.traks.push(i),(s={}).id=i.tkhd.track_id,s.user=this.fragmentedTracks[e].user,s.buffer=f.writeInitializationSegment(this.ftyp,r,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(s)}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 m={createFile:function(e,t){var i=void 0===e||e,s=new f(t);return s.discardMdatData=!i,s}};t.createFile=m.createFile}));function zl(e){return e.reduce(((e,t)=>256*e+t))}function $l(e){const t=[101,103,119,99],i=e.length-28,s=e.slice(i,i+t.length);return t.every(((e,t)=>e===s[t]))}Gl.Log,Gl.MP4BoxStream,Gl.DataStream,Gl.MultiBufferStream,Gl.MPEG4DescriptorParser,Gl.BoxParser,Gl.XMLSubtitlein4Parser,Gl.Textin4Parser,Gl.ISOFile,Gl.createFile;class Wl{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);$l(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 s=0;s<t.length&&e[i+s]===t[s];s++)if(s===t.length-1)return i;return null}(e,t);if(i){const t=zl(e.slice(i+16,i+16+8));return[t,zl(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 s=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(s instanceof Error)return console.error(s.message),this.d=!0,e;this.A=!0,this.u=i[1],$l(t)&&this.c++,WebAssembly.instantiate(i[2],s).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 Hl extends Cl{constructor(e){super(e),this.TAG_NAME="Fmp4Loader",this.player=e,this.mp4Box=Gl.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 Wl),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,Be,0,!0,0)),this.mp4Box.setExtractionOptions(t.id)}if(i&&this.player._opt.hasAudio){this.audioTrackId=i.id;const e=i.audio||{},t=qs.indexOf(e.sample_rate),s=i.codec.replace("mp4a.40.","");this.mp4Box.setExtractionOptions(i.id);const r={profile:parseInt(s,10),sampleRate:t,channel:e.channel_count},a=Hs(r);this.player.debug.log(this.TAG_NAME,"aacADTSHeader",a,"config",r),this._doDecodeByFmp4(a,Pe,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,s=1e3*e.cts/e.timescale;e.duration,e.timescale,this.player.updateStats({vbps:t.byteLength,dts:s}),i&&this.calcIframeIntervalTimestamp(s);let r=null;r=this.isHevc?Go(t,i):xo(t,i),this._doDecodeByFmp4(r,Be,s,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 s=new Uint8Array(t.byteLength+2);s.set([175,1],0),s.set(t,2),this._doDecodeByFmp4(s,Pe,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 Gl.DataStream(void 0,0,Gl.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 s=new Uint8Array(t.buffer,8),r=new Uint8Array(i.length+s.length);return r.set(i,0),r.set(s,i.length),r}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=lr()+".fmp4",i.click(),URL.revokeObjectURL(t)}}class Vl extends Cl{constructor(e){super(e),Ol(this,"LOG_NAME","Mpeg4Loader"),this.player=e,this.player.debug.log(this.LOG_NAME,"init")}destroy(){super.destroy(),this.player.debug.log(this.LOG_NAME,"destroy")}}class Jl{constructor(e){return new(Jl.getLoaderFactory(e))(e)}static getLoaderFactory(e){const t=e._opt.demuxType;return t===T?Bl:t===S||e.isWebrtcH265()?Pl:t===C?Ml:t===x?Nl:t===R?Hl:t===D?Vl:jl}}class Kl extends t{constructor(e){super(),this.player=e,this.hasInit=!1,this.isDecodeFirstIIframe=!!fa(e._opt.checkFirstIFrame),this.isInitInfo=!1,this.prevTimestamp=null,this.decodeDiffTimestamp=null,this.prevDts=null,this.decoder=null,this.isWidthOrHeightChanged=!1,this.initDecoder(),e.debug.log("Webcodecs","init")}destroy(){this.decoder&&(fa(this.isDecodeStateClosed())&&this.decoder.close(),this.decoder=null),this.prevTimestamp=null,this.decodeDiffTimestamp=null,this.prevDts=null,this.hasInit=!1,this.isInitInfo=!1,this.isDecodeFirstIIframe=!1,this.isWidthOrHeightChanged=!1,this.off(),this.player.debug.log("Webcodecs","destroy")}initDecoder(){const e=this;this.decoder=new VideoDecoder({output(t){e.handleDecode(t)},error(t){e.handleError(t)}})}handleDecode(e){this.isInitInfo||(this.player.video.updateVideoInfo({width:e.codedWidth,height:e.codedHeight}),this.player.video.initCanvasViewSize(),this.isInitInfo=!0),this.player.isPlayer()?(this.player.updateStats({dfps:!0}),this.player._times.videoStart||(this.player._times.videoStart=lr(),this.player.handlePlayToRenderTimes()),this.player.video.render({videoFrame:e,ts:e.timestamp}),this.player.handleRender()):this.player.isPlayback()&&(this.player.updateStats({dfps:!0}),fa(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})):fa(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("Webcodecs","VideoDecoder handleError:",e.code,e);const t=e.toString();-1!==t.indexOf(Ii)?this.player.emitError(it.webcodecsUnsupportedConfigurationError,t):(-1!==t.indexOf(Pi)||-1!==t.indexOf(Bi)||-1!==t.indexOf(Mi))&&this.player.emitError(it.webcodecsDecodeError,t)}decodeVideo(e,t,i,s){var r;if(this.player)if(this.player.isDestroyed())this.player.debug.warn("Webcodecs","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("Webcodecs","VideoDecoder isDecodeStateClosed true");if(i&&0===e[1]){const t=15&e[0];let i={};if(t===ct){i=ko(e.slice(5))}else t===ut&&(i=Oo(e));const s=this.player.video.videoInfo;s&&s.width&&s.height&&i&&i.codecWidth&&i.codecHeight&&(i.codecWidth!==s.width||i.codecHeight!==s.height)&&(this.player.debug.warn("Webcodecs",`decodeVideo: video width or height is changed,\n old width is ${s.width}, old height is ${s.height},\n new width is ${i.codecWidth}, new height is ${i.codecHeight},\n and emit change event`),this.isWidthOrHeightChanged=!0,this.player.emitError(it.wcsWidthOrHeightChange))}if(this.isWidthOrHeightChanged)return void this.player.debug.warn("Webcodecs","decodeVideo: video width or height is changed, and return");if(ua(e))return void this.player.debug.warn("Webcodecs","decodeVideo and payload is video sequence header so drop this frame");if(e.byteLength<12)return void this.player.debug.warn("Webcodecs",`decodeVideo and payload is too small , payload length is ${e.byteLength}`);let s=!1,r=(new Date).getTime();this.prevTimestamp||(this.prevTimestamp=r,s=!0);const a=r-this.prevTimestamp;this.decodeDiffTimestamp=a,a>500&&!s&&this.player.isPlayer()&&this.player.debug.warn("Webcodecs","decodeVideo diff time is ",a);const o=e.slice(5),n=new EncodedVideoChunk({data:o,timestamp:t,type:i?Vt:Jt});this.player.emit(Ze.timeUpdate,t);try{this.decoder.decode(n)}catch(e){this.player.debug.error("Webcodecs","VideoDecoder",e);const t=e.toString();(-1!==t.indexOf(Di)||-1!==t.indexOf(Li))&&this.player.emitError(it.webcodecsDecodeError)}this.prevTimestamp=(new Date).getTime()}else this.player.debug.log("Webcodecs","VideoDecoder first frame is not iFrame");else if(i&&e[1]===Gi){const t=15&e[0];if(this.player.video.updateVideoInfo({encTypeCode:t}),t===ut&&!Dr()){const e=br();return this.player.debug.warn("Webcodecs","WebcodecsDecoder not support hevc decode",e.type,e.version),void this.player.emitError(it.webcodecsH265NotSupport)}this.player._times.decodeStart||(this.player._times.decodeStart=lr());let i=null,s=null;const a=e.slice(5);t===ct?(i=function(e){let t=e.subarray(1,4),i="avc1.";for(let e=0;e<3;e++){let s=t[e].toString(16);s.length<2&&(s="0"+s),i+=s}return{codec:i,description:e}}(a),s=ko(a)):t===ut&&((r=a).subarray(1,4),i={codec:"hev1.1.6.L120.90",description:r},s=Oo(e)),s&&s.codecWidth&&s.codecHeight&&(i.codedHeight=s.codecHeight,i.codedWidth=s.codecWidth),this.player.recorder&&this.player._opt.recordType===b&&this.player.recorder.initMetaData(e,t);try{this.decoder.configure(i),this.hasInit=!0}catch(e){this.player.debug.log("Webcodecs","configure error",e.code,e);-1!==e.toString().indexOf(Fi)?this.emit(it.webcodecsH265NotSupport):this.player.emitError(it.webcodecsDecodeConfigureError)}}}getDecodeDiffTimes(){return this.decodeDiffTimestamp}isDecodeStateClosed(){return"closed"===this.decoder.state}isDecodeStateConfigured(){return"configured"===this.decoder.state}isDecodeStateUnConfigured(){return"unconfigured"===this.decoder.state}}const ql={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 Yl=Object.keys(ql).reduce(((e,t)=>(e[t]=`\n <i class="jessibuca-icon jessibuca-icon-${t}"></i>\n ${ql[t]?`<span class="icon-title-tips"><span class="icon-title">${ql[t]}</span></span>`:""}\n`,e)),{});function Ql(e,t){let i=!1;return e.forEach((e=>{i||e.startTimestamp<=t&&e.endTimestamp>t&&(i=!0)})),i}function Xl(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2?arguments[2]:void 0;const s=e.length,r=t.length,a=Math.max(s,r),o=2e3,n=Math.ceil(a/o);let l=0,h=0;function d(){let r="",a="";for(let i=0;i<o;i++){const i=e[h];i&&(r+=`\n <div class="jessibuca-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="jessibuca-playback-time-title-tips ${h>s-60?"jessibuca-playback-time-title-tips-left":""}"><span class="jessibuca-playback-time-title">${i.title}</span></span>\n </div>\n `);const o=t[h];o&&(a+=`\n <div class="jessibuca-playback-time-hour" data-hour="${o.hour}" data-min="${o.min}" data-second="${o.second}"><span class="jessibuca-playback-time-hour-text">${o.title}</span></div>\n `),h+=1}r&&i.$playbackTimeListOne.insertAdjacentHTML("beforeend",r),a&&i.$playbackTimeListSecond.insertAdjacentHTML("beforeend",a),l+=1,l<n&&(i.rafId=window.requestAnimationFrame(d))}d()}function Zl(e,t){const i=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=[];const i=(e[0]||{}).startTimestamp;for(let s=0;s<1440;s++){const r=s%60==0;let a=!1;i&&(a=Ql(e,$r(i,s))),t.push({title:Gr(s),timestamp:s,dataType:"min",hasRecord:a,isStart:r})}return t}(e);Xl(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 eh(e,t){const i=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=[];const i=(e[0]||{}).startTimestamp;for(let s=0;s<1440;s++){let r=60*s,a=r%1800==0,o=!1;i&&(o=Ql(e,Wr(i,r))),t.push({title:zr(r),timestamp:r,dataType:"second",hasRecord:o,isStart:a});let n=60*s+30;a=n%1800==0,i&&(o=Ql(e,Wr(i,n))),t.push({title:zr(n),timestamp:n,dataType:"second",hasRecord:o,isStart:a})}return t}(e);Xl(i,function(){let e=[];for(let t=0;t<24;t++){let i=t+":00",s=t+":30";t<10&&(i="0"+i,s="0"+s),e.push({title:i,hour:t,min:0,second:0}),e.push({title:s,hour:t,min:30,second:0})}return e}(),t)}function th(e,t){const i=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=[];const i=(e[0]||{}).startTimestamp;for(let s=0;s<144;s++)for(let r=0;r<60;r++){let a=10*r+600*s,o=a%600==0,n=!1;i&&(n=Ql(e,Wr(i,a))),t.push({title:zr(a),timestamp:a,dataType:"second",isStart:o,hasRecord:n})}return t}(e);Xl(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 s=1;s<6;s++){let r=s+"0";e.push({title:i.replace(":00",":"+r),hour:t,min:10*s,second:0})}}return e}(),t)}function ih(e,t){const i=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=[];const i=(e[0]||{}).startTimestamp;for(let s=0;s<288;s++)for(let r=0;r<60;r++){let a=5*r+300*s,o=a%300==0,n=!1;i&&(n=Ql(e,Wr(i,a))),t.push({title:zr(a),timestamp:a,dataType:"second",isStart:o,hasRecord:n})}return t}(e);Xl(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 s=1;s<6;s++){let r=s+"0",a=s+"5";e.push({title:i.replace(":00",":"+r),hour:t,min:10*s,second:0}),e.push({title:i.replace(":00",":"+a),hour:t,min:10*s+5,second:0})}}return e}(),t)}function sh(e){const t=Math.floor(e/3600),i=Math.floor((e-3600*t)/60),s=Math.floor(e-3600*t-60*i);return(t>0?[t,i,s]:[i,s]).map((e=>e<10?`0${e}`:String(e))).join(":")}function rh(e,t,i){const s=e.$playbackProgress,{left:r}=s.getBoundingClientRect(),a=hr((mr()?i.touches[0].clientX:i.pageX)-r,0,s.clientWidth),o=parseInt(a/s.clientWidth*t,10);return{second:o,time:sh(o),width:a,percentage:hr(a/s.clientWidth,0,1)}}function ah(e,t){return t instanceof Element?e.appendChild(t):e.insertAdjacentHTML("beforeend",String(t)),e.lastElementChild||e.lastChild}function oh(e,t,i){return e&&e.style&&Fr(t)&&(e.style[t]=i),e}function nh(e,t){return e.composedPath&&e.composedPath().indexOf(t)>-1}function lh(e){let t=!1;return e&&e.parentNode&&(e.parentNode.removeChild(e),t=!0),t}var hh=(e,t)=>{const{events:{proxy:i}}=e,s=document.createElement("object");s.setAttribute("aria-hidden","true"),s.setAttribute("tabindex",-1),s.type="text/html",s.data="about:blank",dr(s,{display:"block",position:"absolute",top:"0",left:"0",height:"100%",width:"100%",overflow:"hidden",pointerEvents:"none",zIndex:"-1"});let r=e.width,a=e.height;const o=kr((()=>{e.width===r&&e.height===a||(r=e.width,a=e.height,e.emit(Ze.resize),c())}),500);i(s,"load",(()=>{i(s.contentDocument.defaultView,"resize",(()=>{o()}))})),e.$container.appendChild(s),e.on(Ze.destroy,(()=>{e.$container.removeChild(s)})),e.on(Ze.volumechange,(()=>{!function(e){if(0===e)dr(t.$volumeOn,"display","none"),dr(t.$volumeOff,"display","flex"),dr(t.$volumeHandle,"top","48px");else if(t.$volumeHandle&&t.$volumePanel){const i=cr(t.$volumePanel,"height")||60,s=cr(t.$volumeHandle,"height"),r=i-(i-s)*e-s;dr(t.$volumeHandle,"top",`${r}px`),dr(t.$volumeOn,"display","flex"),dr(t.$volumeOff,"display","none")}t.$volumePanelText&&(t.$volumePanelText.innerHTML=parseInt(100*e))}(e.volume)})),e.on(Ze.loading,(i=>{dr(t.$loading,"display",i?"flex":"none"),(fa(e._opt.backgroundLoadingShow)&&pa(i)||fa(i))&&dr(t.$poster,"display","none"),i&&(dr(t.$playBig,"display","none"),dr(t.$tipsMessage,"display","none")),mr()||i||e.getRenderType()===z&&fa(e._opt.useMSE)&&n()})),e.on(Ze.removeLoadingBgImage,(()=>{mr()||n()}));const n=()=>{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="",dr(t.$loadingBg,"display","none"))},l=t=>{e.fullscreen?Yr(t)===e.$container&&h():h()},h=i=>{let s=Mr(i)?i:e.fullscreen;dr(t.$fullscreenExit,"display",s?"flex":"none"),dr(t.$fullscreen,"display",s?"none":"flex")},d=()=>e._opt.playType===A&&e._opt.playbackConfig.showControl,c=i=>{mr()&&t.$controls&&e._opt.useWebFullScreen&&setTimeout((()=>{if(e.fullscreen){const i=d()?Bt:Pt;let s=e.height/2-e.width+i/2,r=e.height/2-i/2;if(t.$controls.style.transform=`translateX(${-s}px) translateY(-${r}px) rotate(-90deg)`,t.$zoomControls){const i=156,s=30,r=e.width/2+i/2-s/2;t.$zoomControls.style.transform=`translateX(${-r}px) translateY(${e.height/2}px) rotate(-90deg)`}if(t.$recording){const i=101,s=20,r=e.width/2+i/2-s/2;t.$recording.style.transform=`translateX(${-r}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{Ws.on("change",l),e.events.destroys.push((()=>{Ws.off("change",l)}))}catch(e){}e.on(Ze.webFullscreen,(e=>{mr()&&(h(e),c((()=>{p()})))})),e.on(Ze.recording,(()=>{e.playing&&(dr(t.$record,"display",e.recording?"none":"flex"),dr(t.$recordStop,"display",e.recording?"flex":"none"),(e._opt.hasControl||e._opt.isShowRecordingUI)&&(dr(t.$recording,"display",e.recording?"flex":"none"),fa(e.recording)&&t.$recordingTime&&(t.$recordingTime.innerHTML=jr(0))))})),e.on(Ze.recordingTimestamp,(e=>{t.$recordingTime&&(t.$recordingTime.innerHTML=jr(e))})),e.on(Ze.zooming,(()=>{e.playing&&(dr(t.$zoom,"display",e.zooming?"none":"flex"),dr(t.$zoomStop,"display",e.zooming?"flex":"none"),(e._opt.hasControl||e._opt.isShowZoomingUI)&&dr(t.$zoomControls,"display",e.zooming?"flex":"none"))})),e.on(Ze.playing,(e=>{u(e)}));const u=i=>{dr(t.$play,"display",i?"none":"flex"),dr(t.$playBig,"display",i?"none":"block"),dr(t.$pause,"display",i?"flex":"none"),dr(t.$screenshot,"display",i?"flex":"none"),dr(t.$record,"display",i?"flex":"none"),dr(t.$qualityMenu,"display",i?"flex":"none"),dr(t.$volume,"display",i?"flex":"none"),dr(t.$ptz,"display",i?"flex":"none"),dr(t.$zoom,"display",i?"flex":"none"),dr(t.$scaleMenu,"display",i?"flex":"none"),dr(t.$faceDetect,"display",i?"flex":"none"),dr(t.$objectDetect,"display",i?"flex":"none"),dr(t.$occlusionDetect,"display",i?"flex":"none"),dr(t.$controlHtml,"display",i?"flex":"none"),e.isPlayback()&&dr(t.$speedMenu,"display",i?"flex":"none"),h(),t.extendBtnList.forEach((e=>{e.$iconWrap&&dr(e.$iconWrap,"display",i?"flex":"none"),e.$activeIconWrap&&dr(e.$activeIconWrap,"display","none")})),e._opt.showPerformance?dr(t.$performanceActive,"display",i?"flex":"none"):(dr(t.$performance,"display",i?"flex":"none"),dr(t.$performanceActive,"display","none")),dr(t.$poster,"display","none"),dr(t.$ptzActive,"display","none"),dr(t.$recordStop,"display","none"),dr(t.$zoomStop,"display","none"),dr(t.$faceDetectActive,"display","none"),dr(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"}("")),dr(t.$zoomControls,"display","none"),dr(t.$recording,"display","none"),t.$ptzControl&&t.$ptzControl.classList.remove("jessibuca-ptz-controls-show")),p(),i&&f()};e.on(Ze.playbackPause,(e=>{u(!e)})),e.on(Ze.kBps,(i=>{const s=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 s=parseFloat(e);i=Math.floor(Math.log(s)/Math.log(1024));let r=s/Math.pow(1024,i);return r=r.toFixed(2),r+(t[i]||t[0])}(i);t.kbpsShow=s,e._opt.showBandwidth&&(t.$speed&&(t.$speed.innerHTML=s),p())}));const p=()=>{if(d()&&e._opt.playbackConfig.controlType===K.normal){let i=t.controlsInnerRect.width-t.controlsLeftRect.width-t.controlsRightRect.width-t.controlsPlaybackBtnsRect.width;mr()&&e.webFullscreen&&(i=t.controlsInnerRect.height-t.controlsLeftRect.height-t.controlsRightRect.height-t.controlsPlaybackBtnsRect.height),t.$playbackTimeInner.style.width=i+"px"}},f=()=>{if(!d()||e._opt.playbackConfig.controlType!==K.normal)return;const i=t.$playbackCurrentTime.style.left;let s=parseInt(i,10);const r=t.controlsPlaybackTimeInner.width;s=s-r/2>0?parseInt(s-r/2,10):0,t.$playbackTimeInner.scrollLeft=s};if(d()){const i=()=>{if(d()){let i=0;const s=e.playback&&e.playback.playingTimestamp;if(s){const r=new Date(s),a=r.getHours(),o=r.getMinutes(),n=r.getSeconds();e.playback.is60Min?i=60*a+o:e.playback.is30Min?i=2*(60*a+o)+parseInt(n/30,10):e.playback.is10Min?i=6*(60*a+o)+parseInt(n/10,10):e.playback.is5Min?i=12*(60*a+o)+parseInt(n/5,10):e.playback.is1Min&&(i=60*(60*a+o)+parseInt(n,10)),t.$playbackCurrentTime.style.left=i+"px"}}},s=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(Ze.playbackTime,(s=>{if(e._opt.playbackConfig.controlType===K.normal)t.$playbackCurrentTimeText&&(t.$playbackCurrentTimeText.innerText=wr(s,"{h}:{i}:{s}")),i();else if(e._opt.playbackConfig.controlType===K.simple){const i=(r=s,a=e.playback.totalDuration,hr(r/a,0,1));t.$playbackProgressPlayed.style.width=100*i+"%",t.$playbackProgressIndicator.style.left=`calc(${100*i}% - 7px)`,t.$playbackProgressTime.innerText=`${sh(s)} / ${sh(e.playback.totalDuration)}`}var r,a})),e.on(Ze.playbackPrecision,((r,a)=>{d()&&e._opt.playbackConfig.controlType===K.normal&&(t.$playbackTimeScroll.classList.remove(oi.oneHour,oi.halfHour,oi.fiveMin,oi.tenMin),t.$playbackTimeScroll.classList.add(oi[r]),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="",r){case ii:Zl(a,t);break;case si:eh(a,t);break;case ri:th(a,t);break;case ai:ih(a,t)}i(),e._opt.playbackConfig.showPrecisionBtn&&s(r),f()}),16))})),e.on(Ze.resize,(()=>{p()})),e.on(Ze.playbackTimeScroll,(()=>{f()})),p()}if(e._opt.operateBtns.quality&&e._opt.qualityConfig.length>0){e.on(Ze.streamQualityChange,(e=>{i(e)}));const i=e=>{t.$qualityText.innerText=e,t.$qualityMenuItems.forEach((t=>{const i=t.dataset.quality;t.classList.remove("jessibuca-quality-menu-item-active"),i===e&&t.classList.add("jessibuca-quality-menu-item-active")}))};(()=>{const i=e._opt.qualityConfig||[];let s="";i.forEach((e=>{s+=`\n <div class="jessibuca-quality-menu-item" data-quality="${e}">${e}</div>\n `})),s&&(t.$qualityMenuList.insertAdjacentHTML("beforeend",s),Object.defineProperty(t,"$qualityMenuItems",{value:e.$container.querySelectorAll(".jessibuca-quality-menu-item")}),setTimeout((()=>{const t=i[0];e.streamQuality=t}),0))})(),e.streamQuality&&i(e.streamQuality)}if(e._opt.operateBtns.scale&&e._opt.scaleConfig.length>0){e.on(Ze.viewResizeChange,(e=>{i(e)}));const i=i=>{const s=e._opt.scaleConfig[i];t.$scaleText.innerText=s,t.$scaleMenuItems.forEach((e=>{const t=e.dataset.scale;e.classList.remove("jessibuca-scale-menu-item-active"),Tr(t)===Tr(i)&&e.classList.add("jessibuca-scale-menu-item-active")}))};(()=>{const i=e._opt.scaleConfig||[];let s="";i.forEach(((e,t)=>{s+=`\n <div class="jessibuca-scale-menu-item" data-scale="${t}">${e}</div>\n `})),s&&(t.$scaleMenuList.insertAdjacentHTML("beforeend",s),Object.defineProperty(t,"$scaleMenuItems",{value:e.$container.querySelectorAll(".jessibuca-scale-menu-item")}))})(),i(e.scaleType)}if(e.isPlayback()&&e._opt.playbackConfig.showRateBtn&&e._opt.playbackConfig.rateConfig.length>0){e.on(Ze.playbackRateChange,(e=>{i(e)}));const i=i=>{const s=e._opt.playbackConfig.rateConfig.find((e=>Tr(e.value)===Tr(i)));s&&(t.$speedText.innerText=s.label,t.$speedMenuItems.forEach((e=>{const t=e.dataset.speed;e.classList.remove("jessibuca-speed-menu-item-active"),Tr(t)===Tr(i)&&e.classList.add("jessibuca-speed-menu-item-active")})))};(()=>{const i=e._opt.playbackConfig.rateConfig;let s="";i.forEach(((e,t)=>{s+=`\n <div class="jessibuca-speed-menu-item" data-speed="${e.value}">${e.label}</div>\n `})),s&&(t.$speedMenuList.insertAdjacentHTML("beforeend",s),Object.defineProperty(t,"$speedMenuItems",{value:e.$container.querySelectorAll(".jessibuca-speed-menu-item")}))})();const s=e.playback?e.playback.playbackRate:1;i(s)}e.on(Ze.stats,(function(){let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(e._opt.showPerformance){dr(t.$performancePanel,"display","block"),t.$performancePanel.innerHTML="";const s=fr,r=ba(),a=e.getCpuLevel(),o=Fr(a)&&-1!==a?`${Ps[a]}`:"",n=e.video&&e.video.videoInfo||{},l=e.audio&&e.audio.audioInfo||{},h=e._times||{},d=e.getRenderType(),c=e.getCanvasRenderType(),u=e.getDecodeType(),p=e.getDemuxType(),f=e.getStreamType(),m=e.getAudioEngineType();let g=e.getRecordingDuration(),y=e.getRecordingByteLength();const A=e.isAudioPlaybackRateSpeed(),b=e.videoIframeIntervalTs;g=jr(g),y=Cr(y);const v=e.isPlayback()?"录播":"直播";let _=i.isDropping;const w=e._opt.useMSE&&e._opt.mseDecodeAudio,S=e.control?e.control.kbpsShow:"0 KB/s",T=e.getVideoPlaybackQuality(),E=`\n <div class="jessibuca-performance-item">\n <span>版本 ${s}</span>\n </div>\n ${e._opt.isMulti?`\n <div class="jessibuca-performance-item">\n <span>UUid ${e._opt.debugUuid}</span>\n </div>\n `:""}\n ${e.isInMulti()?`\n <div class="jessibuca-performance-item">\n <span>窗口下标 ${e._opt.multiIndex}</span>\n </div>\n `:""}\n ${r?`\n <div class="jessibuca-performance-item">\n <span>内存大小限制 ${Cr(r.jsHeapSizeLimit)}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>可使用的内存 ${Cr(r.totalJSHeapSize)}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>已使用的内存 ${Cr(r.usedJSHeapSize)}</span>\n </div>\n `:""}\n ${o?`\n <div class="jessibuca-performance-item">\n <span>CPU压力情况 ${o}</span>\n </div>\n `:""}\n\n ${r&&r.usedJSHeapSize>r.totalJSHeapSize?'\n <div class="jessibuca-performance-item">\n <span>可能内存泄漏 是}</span>\n </div>\n ':""}\n <div class="jessibuca-performance-item">\n <span>播放模式 ${v}</span>\n </div>\n ${e.isPlayback()?`\n <div class="jessibuca-performance-item">\n <span>播放倍率 ${e.playback.rate}倍</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>播放模式 ${e.playback.isUseFpsRender?"固定FPS":"动态FPS"}</span>\n </div>\n ${e.playback.isUseFpsRender?`\n <div class="jessibuca-performance-item">\n <span>固定FPS ${e.video.getStreamFps()}</span>\n </div>\n `:""}\n `:""}\n <div class="jessibuca-performance-item">\n <span>解封装模式 ${I[p]}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>解码模式 ${u}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>渲染组件 ${d}</span>\n </div>\n ${d===z?`\n <div class="jessibuca-performance-item">\n <span>渲染引擎 ${c}</span>\n </div>\n `:""}\n <div class="jessibuca-performance-item">\n <span>网络请求组件 ${f}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>视频格式 ${n.encType||"-"}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>视频(宽x高) ${n.width||"-"}x${n.height||"-"}</span>\n </div>\n ${e.isPlayer()?`\n <div class="jessibuca-performance-item">\n <span>视频GOP(ms) ${b||"-"}</span>\n </div>\n `:""}\n <div class="jessibuca-performance-item">\n <span>音频格式 ${bt[l.encType]||"-"}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>音频引擎 ${m||"-"}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>音频通道 ${l.channels||"-"}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>音频采样率 ${l.sampleRate||"-"}</span>\n </div>\n ${e.isPlayer()?`\n <div class="jessibuca-performance-item">\n <span>播放器初始化(ms) ${h.playTimestamp}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>开始请求地址(ms) ${h.streamTimestamp}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>请求响应(ms) ${h.streamResponseTimestamp}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>解封装(ms) ${h.demuxTimestamp}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>解码(ms) ${h.decodeTimestamp}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>页面开始渲染(ms) ${h.videoTimestamp}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>初始化到页面渲染(ms) ${h.allTimestamp}</span>\n </div>\n ${e.recording?`\n <div class="jessibuca-performance-item">\n <span>视频录制时间 ${g}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>视频录制大小 ${y}</span>\n </div>\n `:""}\n `:""}\n <div class="jessibuca-performance-item">\n <span>音频码率(bit) ${i.abps}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>视频码率(bit) ${i.vbps}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>视频帧率(fps) ${i.fps}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>视频峰值帧率(fps) ${i.maxFps}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>解码帧率(fps) ${i.dfps}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>音频缓冲帧 ${i.audioBuffer}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>音频缓冲时长(ms) ${i.audioBufferDelayTs}</span>\n </div>\n ${e.isPlayer()?`\n <div class="jessibuca-performance-item">\n <span>视频待解码帧 ${i.demuxBuffer}</span>\n </div>\n `:`\n <div class="jessibuca-performance-item">\n <span>缓存时长(ms) ${i.playbackCacheDataDuration}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>视频待渲染帧 ${i.playbackVideoBuffer}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>视频待解码帧 ${i.demuxBuffer}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>音频待解码帧 ${i.audioDemuxBuffer}</span>\n </div>\n `}\n <div class="jessibuca-performance-item">\n <span>待解封装数据(byte) ${i.flvBuffer}</span>\n </div>\n ${e._opt.useMSE?`\n <div class="jessibuca-performance-item">\n <span>MSE缓冲时长(ms) ${i.mseDelay}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>MSE缓存时长(s) ${i.mseStore}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>MSE解码间隔(ms) ${i.mseDecodeDiffTimes}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>MSE解码时间(ms) ${i.mseTs}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>MSE播放模式 ${i.mseDecodePlaybackRate>1?"加速":"正常"}</span>\n </div>\n `:""}\n ${e._opt.useWCS?`\n <div class="jessibuca-performance-item">\n <span>WCS解码间隔(ms) ${i.wcsDecodeDiffTimes}</span>\n </div>\n `:""}\n ${e.isOldHls()?`<div class="jessibuca-performance-item">\n <span>HLS缓冲时长(ms) ${i.hlsDelay}</span>\n </div>\n `:""}\n ${e.isUseHls265()?`<div class="jessibuca-performance-item">\n <span>HLS缓冲时长(ms) ${i.hlsDelay}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>HLS待解码帧 ${i.hlsDemuxLength}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>HLS待解码视频帧 ${i.hlsDemuxVideoLength}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>HLS待解码音频帧 ${i.hlsDemuxAudioLength}</span>\n </div>\n `:""}\n ${e.isPlayer()&&T?`\n <div class="jessibuca-performance-item">\n <span>已渲染帧 ${T.renderedVideoFrames}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>已丢弃帧 ${T.droppedVideoFrames}</span>\n </div>\n `:""}\n ${e.isPlayer()?`\n <div class="jessibuca-performance-item">\n <span>网络延迟(ms) ${i.netBuf}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>缓冲时长(ms) ${i.buf}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>最新缓冲时长(ms) ${i.pushLatestDelay}</span>\n </div>\n `:""}\n ${e._opt.useMSE||e.isWebrtcH264()||e.isAliyunRtc()?`\n <div class="jessibuca-performance-item">\n <span>video显示时间(s) ${i.videoCurrentTime}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>video间隔时间(s) ${i.videoCurrentTimeDiff}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>videoBuffer缓存时间(ms) ${i.mseVideoBufferDelayTime}</span>\n </div>\n `:""}\n <div class="jessibuca-performance-item">\n <span>视频显示时间(ms) ${i.currentPts||i.ts}</span>\n </div>\n ${e._opt.hasAudio&&e.isAudioNotMute()&&fa(w)?`\n <div class="jessibuca-performance-item">\n <span>音频显示时间(ms) ${i.audioTs}</span>\n </div>\n ${e._opt.hasVideo?`\n <div class="jessibuca-performance-item">\n <span>音视频同步时间戳(ms) ${i.audioSyncVideo}</span>\n </div>\n `:""}\n <div class="jessibuca-performance-item">\n <span>音频播放模式 ${A?"加速":"正常"}</span>\n </div>\n `:""}\n <div class="jessibuca-performance-item">\n <span>视频解码时间(ms) ${i.dts}</span>\n </div>\n ${e.isPlayer()?`\n <div class="jessibuca-performance-item">\n <span>解码前-解码后延迟(ms) ${i.delayTs}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>总延迟(网络+解码)(ms) ${i.totalDelayTs}</span>\n </div>\n `:""}\n ${e.isPlayer()&&i.isStreamTsMoreThanLocal?'<div class="jessibuca-performance-item">\n <span>是否超过一倍率推流 是</span>\n </div>\n ':""}\n ${e.isPlayer()?`\n <div class="jessibuca-performance-item">\n <span>是否播放流畅 ${i.videoSmooth}</span>\n </div>\n `:""}\n ${e.isPlayer()?`\n <div class="jessibuca-performance-item">\n <span>是否在丢帧 ${_}</span>\n </div>\n `:""}\n <div class="jessibuca-performance-item">\n <span>网速 ${S}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>播放时长(s) ${jr(i.pTs)}</span>\n </div>\n <div class="jessibuca-performance-item-block"></div>\n `;t.$performancePanel.insertAdjacentHTML("beforeend",E)}else t.$performancePanel.innerHTML="",dr(t.$performancePanel,"display","none")})),e.on(Ze.togglePerformancePanel,(e=>{dr(t.$performance,"display",e?"none":"flex"),dr(t.$performanceActive,"display",e?"flex":"none")})),e.on(Ze.faceDetectActive,(e=>{dr(t.$faceDetect,"display",e?"none":"flex"),dr(t.$faceDetectActive,"display",e?"flex":"none")})),e.on(Ze.objectDetectActive,(e=>{dr(t.$objectDetect,"display",e?"none":"flex"),dr(t.$objectDetectActive,"display",e?"flex":"none")})),e.on(Ze.occlusionDetectActive,(e=>{dr(t.$occlusionDetect,"display",e?"none":"flex"),dr(t.$occlusionDetectActive,"display",e?"flex":"none")}))};function dh(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var s=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===i&&s.firstChild?s.insertBefore(r,s.firstChild):s.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}dh('@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}}.jessibuca-container .jessibuca-icon{cursor:pointer;width:16px;height:16px;display:inline-block}.jessibuca-container .jessibuca-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}.jessibuca-container .jessibuca-ptz-controls.jessibuca-ptz-controls-show{visibility:visible;opacity:1}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-ptz-bg-active.jessibuca-ptz-bg-active-up{transform:rotate(-90deg)}.jessibuca-container .jessibuca-ptz-bg-active.jessibuca-ptz-bg-active-left{transform:rotate(180deg)}.jessibuca-container .jessibuca-ptz-bg-active.jessibuca-ptz-bg-active-down{transform:rotate(90deg)}.jessibuca-container .jessibuca-ptz-bg-active.jessibuca-ptz-bg-active-left-up{transform:rotate(-135deg)}.jessibuca-container .jessibuca-ptz-bg-active.jessibuca-ptz-bg-active-right-up{transform:rotate(-45deg)}.jessibuca-container .jessibuca-ptz-bg-active.jessibuca-ptz-bg-active-left-down{transform:rotate(135deg)}.jessibuca-container .jessibuca-ptz-bg-active.jessibuca-ptz-bg-active-right-down{transform:rotate(45deg)}.jessibuca-container .jessibuca-ptz-bg-active.jessibuca-ptz-bg-active-show{visibility:visible;opacity:1}.jessibuca-container .jessibuca-ptz-control{position:absolute;left:53px;top:53px;width:50px;height:50px;background:#fff;border-radius:50%;transition:left .3s,top .3s}.jessibuca-container .jessibuca-ptz-control.jessibuca-ptz-control-left{left:33px}.jessibuca-container .jessibuca-ptz-control.jessibuca-ptz-control-up{top:33px}.jessibuca-container .jessibuca-ptz-control.jessibuca-ptz-control-right{left:73px}.jessibuca-container .jessibuca-ptz-control.jessibuca-ptz-control-down{top:73px}.jessibuca-container .jessibuca-ptz-control.jessibuca-ptz-control-left-up{top:39px;left:39px}.jessibuca-container .jessibuca-ptz-control.jessibuca-ptz-control-left-down{left:39px;top:67px}.jessibuca-container .jessibuca-ptz-control.jessibuca-ptz-control-right-up{top:39px;left:67px}.jessibuca-container .jessibuca-ptz-control.jessibuca-ptz-control-right-down{top:67px;left:67px}.jessibuca-container .jessibuca-ptz-icon{position:relative}.jessibuca-container .jessibuca-ptz-icon:hover .icon-title-tips{visibility:visible;opacity:1}.jessibuca-container .jessibuca-ptz-btns{display:block;position:absolute;left:0;top:156px;width:156px;box-sizing:border-box;padding:0 30px}.jessibuca-container .jessibuca-ptz-btns .jessibuca-ptz-btn{display:flex;justify-content:space-between}.jessibuca-container .jessibuca-ptz-expand .jessibuca-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%}.jessibuca-container .jessibuca-ptz-expand:hover .jessibuca-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%}.jessibuca-container .jessibuca-ptz-narrow .jessibuca-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}.jessibuca-container .jessibuca-ptz-narrow:hover .jessibuca-ptz-narrow-icon{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcBAMAAACAI8KnAAAAJ1BMVEVHcEyZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZn+/v7X19ckk9ihAAAACnRSTlMA9+NCAsuKJsRiPv/2GwAAAJlJREFUGNNjYAAC5gxFoTYDBijw1FoFBIumQHjsUavAYGkBmGu0CgqUwRqlYNyFIO2Fq+BAnIGBJQrBXerAwLkKCUxgYELmKjBYIXMXM2Qhc5cxdCFzVzBoIXMXMYAcsRsMdgEdgs4FKT4DBqdAitGMQrMIzRkojlRB9wKaB9G8z+CMGjgshjCuMCjoWNxRAxYt2KGRYgJiAQAnZcjElaB/xwAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-ptz-aperture-far .jessibuca-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}.jessibuca-container .jessibuca-ptz-aperture-far:hover .jessibuca-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%}.jessibuca-container .jessibuca-ptz-aperture-near .jessibuca-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}.jessibuca-container .jessibuca-ptz-aperture-near:hover .jessibuca-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%}.jessibuca-container .jessibuca-ptz-focus-far .jessibuca-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}.jessibuca-container .jessibuca-ptz-focus-far:hover .jessibuca-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%}.jessibuca-container .jessibuca-ptz-focus-near .jessibuca-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}.jessibuca-container .jessibuca-ptz-focus-near:hover .jessibuca-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%}.jessibuca-container .jessibuca-ptz-arrow{cursor:pointer;position:absolute;width:0;height:0}.jessibuca-container .jessibuca-ptz-arrow-up{left:71px;top:15px;border:7px solid transparent;border-bottom:10px solid #fff}.jessibuca-container .jessibuca-ptz-arrow-right{top:71px;right:15px;border:7px solid transparent;border-left:10px solid #fff}.jessibuca-container .jessibuca-ptz-arrow-left{left:15px;top:71px;border:7px solid transparent;border-right:10px solid #fff}.jessibuca-container .jessibuca-ptz-arrow-down{left:71px;bottom:15px;border:7px solid transparent;border-top:10px solid #fff}.jessibuca-container .jessibuca-ptz-arrow-left-up{transform:rotate(45deg);left:32px;top:33px;border:7px solid transparent;border-right:10px solid #fff}.jessibuca-container .jessibuca-ptz-arrow-right-up{transform:rotate(-45deg);right:32px;top:33px;border:7px solid transparent;border-left:10px solid #fff}.jessibuca-container .jessibuca-ptz-arrow-left-down{transform:rotate(45deg);left:32px;bottom:33px;border:7px solid transparent;border-top:10px solid #fff}.jessibuca-container .jessibuca-ptz-arrow-right-down{transform:rotate(-45deg);right:32px;bottom:33px;border:7px solid transparent;border-top:10px solid #fff}.jessibuca-container .jessibuca-loading-bg{display:none}.jessibuca-container .jessibuca-loading-bg,.jessibuca-container .jessibuca-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}.jessibuca-container .jessibuca-play-big{position:absolute;display:none;height:100%;width:100%;background:rgba(0,0,0,.4)}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-play-big:hover:after{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJFBMVEVHcEz///////////////////////////////////////////8Uel1nAAAAC3RSTlMA+rbVFUecgC7rYhEEz+4AAACbSURBVDjL1dMhDsJAEIXhdeiGpKYWQVKDWc8ReojFc4ReAlPFFQazad7lIGkb0jK/WEPSsZ+YN5mZEP5UrZIP0vgE0Kv3oPlIJlAk8AJM4ASYwAkww2+ABfQg0ImgugPYsfNBVl99kA0AsjOArAPQpRTGHiBB8whxM0y+3skXNltsvMYriIWrpWPA80mFJ5qL3gAfB1/tcAt7rzdiV+HEgs1oBgAAAABJRU5ErkJggg==")}.jessibuca-container .jessibuca-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}.jessibuca-container .jessibuca-recording .jessibuca-recording-red-point{width:8px;height:8px;background:#ff1f1f;border-radius:50%;animation:magentaPulse 1s linear infinite}.jessibuca-container .jessibuca-recording .jessibuca-recording-time{font-size:14px;font-weight:500;color:#ddd}.jessibuca-container .jessibuca-recording .jessibuca-recording-stop{height:100%}.jessibuca-container .jessibuca-recording .jessibuca-icon-recordStop{width:16px;height:16px;cursor:pointer}.jessibuca-container .jessibuca-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}.jessibuca-container .jessibuca-zoom-controls .jessibuca-icon{vertical-align:top}.jessibuca-container .jessibuca-zoom-controls .jessibuca-zoom-narrow{width:16px;height:16px;cursor:pointer}.jessibuca-container .jessibuca-zoom-controls .jessibuca-zoom-tips{font-size:14px;font-weight:500;color:#ddd}.jessibuca-container .jessibuca-zoom-controls .jessibuca-zoom-expand,.jessibuca-container .jessibuca-zoom-controls .jessibuca-zoom-stop2{width:16px;height:16px;cursor:pointer}.jessibuca-container .jessibuca-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}.jessibuca-container .jessibuca-loading-text{line-height:20px;font-size:13px;color:#fff;margin-top:10px}.jessibuca-container .jessibuca-controls{background-color:#161616;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:38px;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}.jessibuca-container .jessibuca-controls .jessibuca-controls-item{position:relative;display:flex;justify-content:center;padding:0 8px}.jessibuca-container .jessibuca-controls .jessibuca-controls-item:hover .icon-title-tips{visibility:visible;opacity:1}.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-face,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-face-active,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-fullscreen,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-fullscreen-exit,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-icon-audio,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-microphone-close,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-object,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-object-active,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-occlusion,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-occlusion-active,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-pause,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-performance,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-performance-active,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-play,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-ptz,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-ptz-active,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-quality-menu,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-record,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-record-stop,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-scale-menu,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-screenshot,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-speed-menu,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-template-menu,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-volume,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-zoom,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-zoom-stop{display:none}.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-speed{padding:0}.jessibuca-container .jessibuca-controls .jessibuca-controls-item-html{position:relative;display:none;justify-content:center}.jessibuca-container .jessibuca-controls .jessibuca-playback-control-time{position:relative;justify-content:center;padding:0 8px}.jessibuca-container .jessibuca-controls .jessibuca-icon-audio,.jessibuca-container .jessibuca-controls .jessibuca-icon-mute{z-index:1}.jessibuca-container .jessibuca-controls .jessibuca-controls-bottom{display:flex;justify-content:space-between;height:100%}.jessibuca-container .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-left,.jessibuca-container .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-right{display:flex;align-items:center}.jessibuca-container.jessibuca-controls-show .jessibuca-controls{opacity:1;visibility:visible}.jessibuca-container.jessibuca-controls-show-auto-hide .jessibuca-controls{opacity:.8;visibility:visible;display:none}.jessibuca-container.jessibuca-hide-cursor *{cursor:none!important}.jessibuca-container .jessibuca-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}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-icon-play{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAIVBMVEVHcEzMzMzMzMzNzc3MzMzPz8/Nzc3MzMzMzMzMzMzMzMzLVn6fAAAACnRSTlMA+duduRUwSGSD8toSsAAAAI9JREFUOMvV07ENgzAQhWG3lLSp6MwCViYIRSpG8AiM4FWMaPymDBKESMF/cQ0S136F353vnLuo3gp1kOYEoCXW4LFKIZAnqAXYICeASoAdzgG+cApwgF4EfwF+oDkCqIwA6gnyAKA8AaizQhsBAjzuqUHofInGIQbjRxXjMrTJuHDestR4Bng4eGrN0929PqNfzC6h06weAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-icon-pause{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAFVBMVEVHcEzMzMzHx8fMzMzMzMzOzs7MzMz4IlKVAAAABnRSTlMA6xIU1hVqIuOVAAAAMUlEQVQ4y2NgGFYgLS3RAEQziQFZoxKjEqMSaBJpEAkgIw1ZQlBQRAEs4QhkDeIMDgAWx1gMHyIL4wAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-pause:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAFVBMVEVHcEz///////////////////////+3ygHaAAAABnRSTlMA7OgSFBXMmAA4AAAAM0lEQVQ4y2NgGFYgLS3JAUQzi6WlJY5KjEqMSqBJpEEkgIw0ZAklJSUDsISikpLQIM7gAJjhWp6XcaOxAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-record{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAHlBMVEVHcEzGxsbMzMzMzMzLy8vMzMzMzMzNzc3MzMzMzMxEZ/aQAAAACXRSTlMADPKKKeBxlV6neZ4mAAAArUlEQVQ4y2NgGDZgJhpowCURAJeYpIQENJEkCgWRgCeShAGyjfgl2EqwS7BFToZJiLg4ICTEImdOh0pwRM6cDJcIjpw5E6aDFeh8B5gECBCUYAkKCoMbNXNSOlyCgUEQ4apJJmxIEkjOVWFgxi4RgEsikGQJnEYp4pLA6VxUDyJLIAUJcRLIwY7qXKSIQvOHWCQODzKIleBPPjgTHM4kijNR48oGkajiYUMykwMAAfmZhUjBISQAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-record:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJ1BMVEVHcEz///////////////////////////////////////////////8NopmKAAAADHRSTlMA8gyMLeRw1x2DBpWGN2QDAAAAt0lEQVQ4y2NgGDbgDBpIwCVRAJc4KIgEZM4EwCU2KSEBHySJCcg29iBJGCBLgHUs24FdYlnNYZiESksDXKJALebMaagES8yZw3CJypgzZ2A6WIHOd4BJgABMgh2XBEtpaBjcqDMHs+ESDFyLEK46aMGGkEB2rgQDJ3aJAFwSUSRL4DQKp+VHcTkXxYMoEkhBQpwEcrCjSCBHFJo/1GIO408MOJMPzgSHM4niTNS4skENqnjYkMzkAEgzyFpeX6L3AAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-icon-fullscreenExit{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAG1BMVEVHcEzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMxi4XDRAAAACHRSTlMAf3WqJmy+7azWNnMAAADNSURBVDjLxZQ9E4IwDIaLfMzCOTDSOz07OjLir5CR0dmJFVHIzzZtnMzbOzcyZHnuaXpJWmO2ji4GhpAzzZeQzw8FKCj1pMHss9OgpwsGOS0YGOcVUMPsfBVkmJoVCBJW0FFB6SFIaMKAlRGDnEiDkuM00lP3SmL6H5QSh+iIr9ZWVWntUV9Z4qWbHAWrhcUYNLC4Wwm3xb1r2mOQYoVn2EKFAVb81KHiQQq6L3vSUoMBUmSzgCKbVeiL3eTp3Odf8H1sxRAZZNZt/Vt8AHcPQbiQQVF+AAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-icon-audio{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAIVBMVEVHcEzKysrMzMzMzMzMzMzMzMzMzMzMzMzMzMzNzc3MzMz8gU00AAAACnRSTlMAL0jMZKt96hGJsSKv1QAAAJ9JREFUOMvN078KQFAYBfCbJEw2q6SUyWxTnsJT2JTJ6D38Gb6n5PpT6BwbuaNfTnz3fEp9fZwAP7czD0MsGCzBYJcEYsGwBEHQQRB0EII1CMAWdAOzyJUvJ4jyDVyZVHKGpj9guEI2IuhaDFadYnCkIm9I+kPgn8t+kI7kOsT72HcwQnJR9Gofy8DrwwtHK8pLzdeALg5fNb6cdJ1fOjOGYrl5CLFcggAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-audio:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJ1BMVEVHcEz///////////////////////////////////////////////8NopmKAAAADHRSTlMAL0TQf2frEaZYt8E+idL4AAAAnUlEQVQ4y2NgoDdgUcAuzr4Hh4TaGQHsBp3BLsG+BoeE2hnsEkCDsEqADMIqATIImwTYICwSEIPQJFhnBjKInUGSUA2CSPCcOcIwB1ki5xRM4iiDDrKEzQlsEuUF2CVY0jbgkDhjMLQkEkj0IM4gQQ1EHMHOOXMiakRpTiQQtXgTA+7kgzvB4UyiuBM17myAM+Pgzmq4MyfO7EwjAAAEf+BAxqI/agAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-icon-face:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAnUExURUdwTP///////////////////////////////////////////////w2imYoAAAAMdFJOUwBAgBvfrFmcw4wrbtGliFoAAAD2SURBVDjLY2AYRkAJCAygbEZBQUEBKJvpDBDAODpA9kGYxEGgKphuIaBuhASqyYzESjBu79yIVWIP0NoCLBIsR4WZJY5gkYiZACRqFJAlGMG8EyAmK1hMGdkp7M4gkus4RrCwBIApFwwJmwlgqsYAQ6IAIrEAwygHHEaxngJbfhRDgg0sxHoMM7Z0AmC+RAPsJ4S5NE5gid8VoHg8sgHTDh/PzM60HkzLc44bgKMf3RKuMwoQ+dNIgswJDAycUDPYjhgwMCsjxYcJLA6AMYISUTkBMLsaUCVqEqAcngPEJx+SJJDSLii1HySU2lHyByi1Kwy9LA4AqflRBKNSA88AAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-faceActive{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAhUExURUdwTBCT2xKV2hGY2hKW2xGW2xGW2xGW2xKX3BGX3BKW23povfoAAAAKdFJOUwBAgRybs9hZLG6hrV9tAAAA80lEQVQ4y2NgGEZACQgMoGxGQUFBASibaRUQwDhaQPZCmMRCoCqYbiGgboQEqsmMxEowTgmZiFViFtBaBywSbEuFmcWWYZGIUgASXgrIEoxg3lIQkxUspozsFJZkEMmxBCNY2MD2MqRhSFgpgCkvAwwJBxwSbAk4jGJZAbZ8KYYEO8S5yzFjSysA5kt0s5YKc6guwxK/baB4XDYB045Vi4pCyrMwLa9aYgCOfgc0cY5VEGurViIJMhcAlULNYF9mwMCsjBQfZrA4AMYISkRVBcDsCkCV8CqAcrgWEJ98SJJASrug1L6QUGpHyR+g1K4w9LI4ALk0RHtSETFcAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-faceActive:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAhUExURUdwTHzD63zE6n7H7H3F7H3F633G63zF7H3G7H3F7H3F68TinBIAAAAKdFJOUwBAgR+Z31ipwW4yAjb9AAAA+UlEQVQ4y2NgGEZACQgMoGxGQUFBASibaRUQwDhaQPZCmMRCoCqYbiGgboQEqsmMxEowTmmZiFViFtBaBywSrMuFmSWWYpGoUgASXgrIEowgHtsKEJMDLKaM7BSWYLCaJRjBwloAploxJKwUwJSXAYYE2KUMVRgSrAFgKhTDKPbFIJJ5OYYEG1iIfRlmbGkVwHyJBlhWCDNrrMASvxageFw6AdOOqKCklrQuTMuzlhiAo98BTZx5FcTarJXIgglApVBr2ZYaMDArI8WHKSwOgDGCElFZBTC7GlAlvBKgHK4FxCcfkiSQ0i4otS8klNpR8gcotSsMvSwOAIs+RIlIrewIAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-icon-zoomStop:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAqUExURUdwTBKV2hGW2xKW2xKW2xKW2xGV3BGW2xGW3BGX2xKW3BKW2xCX2xKW2yDN61kAAAANdFJOUwCAVKxm3T/DmhrxKw97YQBGAAABaklEQVQ4y2NgIA6wGqCLMCqAqV4HdIm9F0Ek22UMM9hiG4AkVzQDA+cmx+YyJJnDlw8wMNQaNpfevbu0QgxJgrN3JQPD3VvhjU57kESnOZqvvXuJgcEXxVFMEkDt1w11gZYwoVgue3d5SzaQSgCydZG1TMkBU8vBuq9guBcqNBNDgj0GQrMEb0CVYEmA2ViANRQZ795tQPZduADciXcVUNSthGu4hGrAJawagBIXsWoAClzGqgEocRWrBqDIrQNQDTPRXZ8A0cB41wBNQgGiQfbubTQJAagGDB0GIA0OsnevbkCTCADiu4J374ahW34JqAEIbiXMRJOAgkvMKJYgJBx6717AKiF4F4eOu+jxgQCXGHBIKPDgkBC8JYCURJDtQHYWN4oEcvpZiyR+C9lZtkgSKKG1CyGOGrxItleixjrcLFBWRAYcMIkG9NQMiY67N7AlcxAQwMwA6SBxM2xZQ3jtVRPsRQ83sg8ACMIUxzzE8wsAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-close{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAeUExURUdwTM3Nzc7Ozs7Ozs3Nzc3NzcrKys3Nzc3Nzc3NzePZJxkAAAAJdFJOUwCtKdPBGAmNTt3jdDcAAADfSURBVDjL1dOxDoIwEADQgwR07GTCZtI/IGHgAzBhM9EPkMTB0Y3V0ZXIcn/rtRR6pefgSKeSu3ellyvA9lZ/5F9p/3K7PZY8oPG5BD6MpPUSgIITzdIStifAshjRQV1PCFT8TxaicTzzwEwINOEdHVmDmcTAkRhMhMAp7iQRjcMtDhCp8SA1v0ARGIIK/gnkv0p1OBTS4QRUIpE7DiYYXTBrzcld3JIrAarXrps4AVNwRSZgExoJmIyAaAdsShUMn/JF2fh4YEkpAcgvnuwYCIb6EbbbP4PsDfLD2dD6Av1qTvAQlzUTAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-menu-icon-text,.jessibuca-container .jessibuca-quality-icon-text,.jessibuca-container .jessibuca-scale-icon-text,.jessibuca-container .jessibuca-speed-icon-text{font-size:14px;min-width:30px;height:20px;line-height:20px;cursor:pointer;text-align:center}.jessibuca-container .jessibuca-speed{box-sizing:border-box;text-align:center;font-size:14px;color:#fff;width:90px}.jessibuca-container .jessibuca-menu-list,.jessibuca-container .jessibuca-quality-menu-list,.jessibuca-container .jessibuca-scale-menu-list,.jessibuca-container .jessibuca-speed-menu-list{position:absolute;left:50%;bottom:100%;visibility:hidden;opacity:0;transform:translateX(-50%);transition:visibility .3s,opacity .3s;background-color:rgba(0,0,0,.5);border-radius:4px;overflow:hidden;width:-moz-max-content;width:max-content}.jessibuca-container .jessibuca-menu-list.jessibuca-menu-shown,.jessibuca-container .jessibuca-menu-list.jessibuca-quality-menu-shown,.jessibuca-container .jessibuca-menu-list.jessibuca-scale-menu-shown,.jessibuca-container .jessibuca-menu-list.jessibuca-speed-menu-shown,.jessibuca-container .jessibuca-quality-menu-list.jessibuca-menu-shown,.jessibuca-container .jessibuca-quality-menu-list.jessibuca-quality-menu-shown,.jessibuca-container .jessibuca-quality-menu-list.jessibuca-scale-menu-shown,.jessibuca-container .jessibuca-quality-menu-list.jessibuca-speed-menu-shown,.jessibuca-container .jessibuca-scale-menu-list.jessibuca-menu-shown,.jessibuca-container .jessibuca-scale-menu-list.jessibuca-quality-menu-shown,.jessibuca-container .jessibuca-scale-menu-list.jessibuca-scale-menu-shown,.jessibuca-container .jessibuca-scale-menu-list.jessibuca-speed-menu-shown,.jessibuca-container .jessibuca-speed-menu-list.jessibuca-menu-shown,.jessibuca-container .jessibuca-speed-menu-list.jessibuca-quality-menu-shown,.jessibuca-container .jessibuca-speed-menu-list.jessibuca-scale-menu-shown,.jessibuca-container .jessibuca-speed-menu-list.jessibuca-speed-menu-shown{visibility:visible;opacity:1}.jessibuca-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}.jessibuca-container .icon-title{display:inline-block;padding:5px 10px;font-size:12px;white-space:nowrap;color:#fff}.jessibuca-container .jessibuca-quality-menu{padding:8px 0}.jessibuca-container .jessibuca-menu-item,.jessibuca-container .jessibuca-quality-menu-item,.jessibuca-container .jessibuca-scale-menu-item,.jessibuca-container .jessibuca-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}.jessibuca-container .jessibuca-menu-item:hover,.jessibuca-container .jessibuca-quality-menu-item:hover,.jessibuca-container .jessibuca-scale-menu-item:hover,.jessibuca-container .jessibuca-speed-menu-item:hover{background-color:hsla(0,0%,100%,.2)}.jessibuca-container .jessibuca-menu-item:focus,.jessibuca-container .jessibuca-quality-menu-item:focus,.jessibuca-container .jessibuca-scale-menu-item:focus,.jessibuca-container .jessibuca-speed-menu-item:focus{outline:none}.jessibuca-container .jessibuca-menu-item.jessibuca-menu-item-active,.jessibuca-container .jessibuca-menu-item.jessibuca-quality-menu-item-active,.jessibuca-container .jessibuca-menu-item.jessibuca-scale-menu-item-active,.jessibuca-container .jessibuca-menu-item.jessibuca-speed-menu-item-active,.jessibuca-container .jessibuca-quality-menu-item.jessibuca-menu-item-active,.jessibuca-container .jessibuca-quality-menu-item.jessibuca-quality-menu-item-active,.jessibuca-container .jessibuca-quality-menu-item.jessibuca-scale-menu-item-active,.jessibuca-container .jessibuca-quality-menu-item.jessibuca-speed-menu-item-active,.jessibuca-container .jessibuca-scale-menu-item.jessibuca-menu-item-active,.jessibuca-container .jessibuca-scale-menu-item.jessibuca-quality-menu-item-active,.jessibuca-container .jessibuca-scale-menu-item.jessibuca-scale-menu-item-active,.jessibuca-container .jessibuca-scale-menu-item.jessibuca-speed-menu-item-active,.jessibuca-container .jessibuca-speed-menu-item.jessibuca-menu-item-active,.jessibuca-container .jessibuca-speed-menu-item.jessibuca-quality-menu-item-active,.jessibuca-container .jessibuca-speed-menu-item.jessibuca-scale-menu-item-active,.jessibuca-container .jessibuca-speed-menu-item.jessibuca-speed-menu-item-active{color:#2298fc}.jessibuca-container .jessibuca-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}.jessibuca-container .jessibuca-volume-panel-wrap.jessibuca-volume-panel-wrap-show{visibility:visible;opacity:1}.jessibuca-container .jessibuca-volume-panel{cursor:pointer;position:absolute;top:21px;height:60px;width:50px;overflow:hidden}.jessibuca-container .jessibuca-volume-panel-text{position:absolute;left:0;top:0;width:50px;height:20px;line-height:20px;text-align:center;color:#fff;font-size:12px}.jessibuca-container .jessibuca-volume-panel-handle{position:absolute;top:48px;left:50%;width:12px;height:12px;border-radius:12px;margin-left:-6px;background:#fff}.jessibuca-container .jessibuca-volume-panel-handle:before{bottom:-54px;background:#fff}.jessibuca-container .jessibuca-volume-panel-handle:after{bottom:6px;background:hsla(0,0%,100%,.2)}.jessibuca-container .jessibuca-volume-panel-handle:after,.jessibuca-container .jessibuca-volume-panel-handle:before{content:"";position:absolute;display:block;left:50%;width:3px;margin-left:-1px;height:60px}.jessibuca-container.jessibuca-fullscreen-web .jessibuca-controls{width:100vh}.jessibuca-container.jessibuca-fullscreen-web .jessibuca-play-big:after{transform:translate(-50%,-50%) rotate(270deg)}.jessibuca-container.jessibuca-fullscreen-web .jessibuca-loading{flex-direction:row}.jessibuca-container.jessibuca-fullscreen-web .jessibuca-loading-text{transform:rotate(270deg)}.jessibuca-container .jessibuca-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}.jessibuca-container .jessibuca-contextmenus .jessibuca-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)}.jessibuca-container .jessibuca-contextmenus .jessibuca-contextmenu a{color:#fff;text-decoration:none}.jessibuca-container .jessibuca-contextmenus .jessibuca-contextmenu span{display:inline-block;padding:0 7px}.jessibuca-container .jessibuca-contextmenus .jessibuca-contextmenu span.art-current,.jessibuca-container .jessibuca-contextmenus .jessibuca-contextmenu span:hover{color:var(--theme)}.jessibuca-container .jessibuca-contextmenus .jessibuca-contextmenu:hover{background-color:hsla(0,0%,100%,.1)}.jessibuca-container .jessibuca-contextmenus .jessibuca-contextmenu:last-child{border-bottom:none}.jessibuca-container.jessibuca-contextmenus-show .jessibuca-contextmenus{display:flex}.jessibuca-container-playback .jessibuca-controls{height:48px}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center{flex:1;display:flex;box-sizing:border-box;justify-content:space-between;font-size:12px}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-controls-playback-time{box-sizing:border-box;flex:1;position:relative;height:100%}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-controls-playback-time-inner{width:300px;height:100%;overflow-y:hidden;overflow-x:auto}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-controls-playback-current-time{position:absolute;left:0;top:0;height:15px;width:1px;background-color:red;text-align:center;z-index:1}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-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}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-controls-playback-time-scroll{position:relative;width:1440px;margin:0 auto}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-controls-playback-time-scroll.one-hour{width:1440px}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-controls-playback-time-scroll.half-hour{width:2880px}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-controls-playback-time-scroll.ten-min{width:8640px}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-controls-playback-time-scroll.five-min{width:17280px}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-controls-playback-time-scroll.one-min{width:86400px}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-controls-playback-time-list{position:relative;background-color:#ccc;height:48px}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-day{height:100%;overflow:hidden}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-one-wrap{height:8px;z-index:1}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-second-wrap{height:25px}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-controls-playback-btns{display:flex;align-items:center}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-minute-one,.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-second-one{float:left;width:1px;height:8px;margin:0;cursor:default;position:relative;z-index:1}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-minute-one.active,.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-second-one.active{background-color:orange;cursor:pointer}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-minute-one.start,.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-second-one.start{background-color:#999}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-minute-one:hover .jessibuca-playback-time-title-tips,.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-second-one:hover .jessibuca-playback-time-title-tips{visibility:visible;opacity:1}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-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}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-title-tips.jessibuca-playback-time-title-tips-left{transform:translateX(-100%)}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-title-tips .jessibuca-playback-time-title{display:inline-block;padding:2px 5px;font-size:12px;white-space:nowrap;color:#fff}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-hour,.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-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}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-hour:first-child,.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-minute:first-child{border-left:0}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-hour:first-child .jessibuca-playback-time-hour-text,.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-minute:first-child .jessibuca-playback-time-hour-text{left:0}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-hour:after,.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-minute:after{content:"";position:absolute;left:0;top:-8px;width:1px;height:14px;background-color:#999}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-hour-text,.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-minute-text{position:absolute;left:-13px}.jessibuca-container-playback .jessibuca-playback-expand.disabled .jessibuca-icon-expand,.jessibuca-container-playback .jessibuca-playback-narrow.disabled .jessibuca-icon-narrow{cursor:no-drop}.jessibuca-container-playback .jessibuca-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}.jessibuca-container-playback .jessibuca-control-progress-simple:hover{top:0;align-items:flex-start}.jessibuca-container-playback .jessibuca-control-progress-simple:hover .jessibuca-control-progress-inner{height:100%}.jessibuca-container-playback .jessibuca-control-progress-simple:hover .jessibuca-control-progress-inner .jessibuca-progress-indicator{transform:scale(1);visibility:visible}.jessibuca-container-playback .jessibuca-control-progress-inner{display:flex;align-items:center;position:relative;height:50%;width:100%;transition:all .2s ease;background:hsla(0,0%,100%,.5)}.jessibuca-container-playback .jessibuca-progress-hover{display:none;width:0}.jessibuca-container-playback .jessibuca-progress-played{position:absolute;left:0;top:0;right:0;bottom:0;height:100%;width:0;background-color:orange}.jessibuca-container-playback .jessibuca-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}.jessibuca-container-playback .jessibuca-progress-indicator .jessibuca-icon{width:100%;height:100%;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.jessibuca-container-playback .jessibuca-progress-indicator:hover{transform:scale(1.2)!important}.jessibuca-container-playback .jessibuca-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}.jessibuca-container-playback.jessibuca-fullscreen-web .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-playback-time-inner{overflow-y:auto}.jessibuca-zoom-control{cursor:grab}.jessibuca-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}.jessibuca-performance-panel .jessibuca-performance-item{display:flex;align-items:center;margin-top:3px;color:#fff}.jessibuca-performance-panel .jessibuca-performance-item-block{height:10px}.jessibuca-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}.jessibuca-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%}.jessibuca-tips-message .jessibuca-tips-message-close{position:absolute;z-index:99999;right:0;top:0;width:40px;height:40px;display:flex;align-items:center;justify-content:center}.jessibuca-tips-message .jessibuca-tips-message-close .jessibuca-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%}.jessibuca-tips-message .jessibuca-tips-message-content{overflow:auto;padding:35px;box-sizing:border-box;width:100%;height:100%}.jessibuca-tips-message .jessibuca-tips-message-content .jessibuca-tips-message-content-item{font-size:14px;color:#fff;text-align:center;line-height:1.5}');class ch{constructor(e){var t;this.player=e,this.extendBtnList=[],((e,t)=>{e._opt.hasControl&&e._opt.controlAutoHide?e.$container.classList.add("jessibuca-controls-show-auto-hide"):e.$container.classList.add("jessibuca-controls-show");const i=e._opt,s=i.operateBtns,r=`\n <div class="jessibuca-controls-center">\n <div class="jessibuca-controls-playback-time">\n <div class="jessibuca-controls-playback-time-inner">\n <div class="jessibuca-controls-playback-time-scroll">\n <div class="jessibuca-controls-playback-time-list">\n <div class="jessibuca-playback-time-day">\n <div class="jessibuca-playback-time-one-wrap"></div>\n <div class="jessibuca-playback-time-second-wrap"></div>\n </div>\n </div>\n <div class="jessibuca-controls-playback-current-time">\n <div class="jessibuca-controls-playback-current-time-text">00:00:00</div>\n </div>\n </div>\n </div>\n </div>\n ${i.playbackConfig.showPrecisionBtn?`\n <div class="jessibuca-controls-playback-btns">\n <div class="jessibuca-controls-item jessibuca-playback-narrow">${Yl.narrow}</div>\n <div class="jessibuca-controls-item jessibuca-playback-expand">${Yl.expand}</div>\n </div>\n `:""}\n </div>\n `;e.$container.insertAdjacentHTML("beforeend",`\n ${i.background?`<div class="jessibuca-poster" style="background-image: url(${i.background})"></div>`:""}\n <div class="jessibuca-loading-bg">\n <img class="jessibuca-loading-bg-image" src="" alt="">\n </div>\n ${i.loadingIcon?`\n <div class="jessibuca-loading">\n ${Yl.loading}\n <div class="jessibuca-loading-text">${i.loadingText}</div>\n </div>\n `:""}\n ${i.hasControl&&s.play?'<div class="jessibuca-play-big"></div>':""}\n ${i.hasControl&&s.ptz?`\n <div class="jessibuca-ptz-controls">\n <div class="jessibuca-ptz-bg-active"></div>\n <div class="jessibuca-ptz-arrow jessibuca-ptz-arrow-up" data-arrow="up"></div>\n <div class="jessibuca-ptz-arrow jessibuca-ptz-arrow-right" data-arrow="right"></div>\n <div class="jessibuca-ptz-arrow jessibuca-ptz-arrow-down" data-arrow="down"></div>\n <div class="jessibuca-ptz-arrow jessibuca-ptz-arrow-left" data-arrow="left"></div>\n ${i.ptzMoreArrowShow?'\n <div class="jessibuca-ptz-arrow jessibuca-ptz-arrow-left-up" data-arrow="left-up"></div>\n <div class="jessibuca-ptz-arrow jessibuca-ptz-arrow-right-up" data-arrow="right-up"></div>\n <div class="jessibuca-ptz-arrow jessibuca-ptz-arrow-left-down" data-arrow="left-down"></div>\n <div class="jessibuca-ptz-arrow jessibuca-ptz-arrow-right-down" data-arrow="right-down"></div>\n ':""}\n <div class="jessibuca-ptz-control"></div>\n <div class="jessibuca-ptz-btns">\n ${i.ptzZoomShow?'\n <div class="jessibuca-ptz-btn">\n <div class="jessibuca-ptz-expand jessibuca-ptz-icon">\n <i class="jessibuca-ptz-expand-icon"></i>\n <span class="icon-title-tips">\n <span class="icon-title">缩放+</span>\n </span>\n </div>\n <div class="jessibuca-ptz-narrow jessibuca-ptz-icon">\n <i class="jessibuca-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="jessibuca-ptz-btn">\n <div class="jessibuca-ptz-aperture-far jessibuca-ptz-icon">\n <i class="jessibuca-ptz-aperture-icon"></i>\n <span class="icon-title-tips">\n <span class="icon-title">光圈+</span>\n </span>\n </div>\n <div class="jessibuca-ptz-aperture-near jessibuca-ptz-icon">\n <i class="jessibuca-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="jessibuca-ptz-btn">\n <div class="jessibuca-ptz-focus-far jessibuca-ptz-icon">\n <i class="jessibuca-ptz-focus-icon"></i>\n <span class="icon-title-tips">\n <span class="icon-title">聚焦+</span>\n </span>\n </div>\n <div class="jessibuca-ptz-focus-near jessibuca-ptz-icon">\n <i class="jessibuca-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="jessibuca-zoom-controls">\n <div class="jessibuca-zoom-narrow">${Yl.narrow}</div>\n <div class="jessibuca-zoom-tips">电子放大</div>\n <div class="jessibuca-zoom-expand">${Yl.expand}</div>\n <div class="jessibuca-zoom-stop2">${Yl.zoomStop}</div>\n </div>\n <div class="jessibuca-recording">\n <div class="jessibuca-recording-red-point"></div>\n <div class="jessibuca-recording-time">00:00:00</div>\n <div class="jessibuca-recording-stop">${Yl.recordStop}</div>\n </div>\n `:""}\n\n ${i.hasControl?`\n <div class="jessibuca-controls">\n <div class="jessibuca-controls-bottom">\n <div class="jessibuca-controls-left">\n ${i.showBandwidth?'<div class="jessibuca-controls-item jessibuca-speed"></div>':""}\n <div class="jessibuca-playback-control-time"></div>\n <div class="jessibuca-controls-item-html">${i.controlHtml}</div>\n </div>\n ${i.playType===A&&i.playbackConfig.showControl&&i.playbackConfig.controlType===K.normal?r:""}\n ${i.playType===A&&i.playbackConfig.showControl&&i.playbackConfig.controlType===K.simple?'\n <div class="jessibuca-control-progress-simple">\n <div class="jessibuca-control-progress-inner">\n <div class="jessibuca-progress-hover"></div>\n <div class="jessibuca-progress-played"></div>\n <div class="jessibuca-progress-indicator"></div>\n <div class="jessibuca-progress-tip">00:00</div>\n </div>\n </div>\n ':""}\n <div class="jessibuca-controls-right">\n ${i.playType===A&&i.playbackConfig.showRateBtn?'\n <div class="jessibuca-controls-item-wrap">\n <div class="jessibuca-controls-item jessibuca-speed-menu">\n <div class="jessibuca-speed-icon-text"></div>\n <div class="jessibuca-speed-menu-list"></div>\n </div>\n </div>\n ':""}\n ${s.close?`<div class="jessibuca-controls-item-wrap"><div class="jessibuca-controls-item jessibuca-close">${Yl.close}</div></div>`:""}\n ${s.logSave?`<div class="jessibuca-controls-item-wrap"><div class="jessibuca-controls-item jessibuca-logSave">${Yl.logSave}</div></div>`:""}\n ${s.performance?`<div class="jessibuca-controls-item-wrap"><div class="jessibuca-controls-item jessibuca-performance">${Yl.performance}</div><div class="jessibuca-controls-item jessibuca-performance-active">${Yl.performanceActive}</div></div>`:""}\n ${s.aiFace?`<div class="jessibuca-controls-item-wrap"><div class="jessibuca-controls-item jessibuca-face">${Yl.face}</div><div class="jessibuca-controls-item jessibuca-face-active">${Yl.faceActive}</div></div>`:""}\n ${s.aiObject?`<div class="jessibuca-controls-item-wrap"><div class="jessibuca-controls-item jessibuca-object">${Yl.object}</div><div class="jessibuca-controls-item jessibuca-object-active">${Yl.objectActive}</div></div>`:""}\n ${s.aiOcclusion?`<div class="jessibuca-controls-item-wrap"><div class="jessibuca-controls-item jessibuca-occlusion">${Yl.occlusion}</div><div class="jessibuca-controls-item jessibuca-occlusion-active">${Yl.occlusionActive}</div></div>`:""}\n ${s.quality?'\n <div class="jessibuca-controls-item-wrap">\n <div class="jessibuca-controls-item jessibuca-quality-menu">\n <div class="jessibuca-quality-icon-text"></div>\n <div class="jessibuca-quality-menu-list"></div>\n </div>\n </div>\n ':""}\n ${s.scale?'\n <div class="jessibuca-controls-item-wrap">\n <div class="jessibuca-controls-item jessibuca-scale-menu">\n <div class="jessibuca-scale-icon-text"></div>\n <div class="jessibuca-scale-menu-list"></div>\n </div>\n </div>\n ':""}\n ${s.audio?`\n <div class="jessibuca-controls-item-wrap">\n <div class="jessibuca-controls-item jessibuca-volume">\n ${Yl.audio}\n ${Yl.mute}\n <div class="jessibuca-volume-panel-wrap">\n <div class="jessibuca-volume-panel">\n <div class="jessibuca-volume-panel-handle"></div>\n </div>\n <div class="jessibuca-volume-panel-text"></div>\n </div>\n </div>\n </div>\n `:""}\n ${s.play?`<div class="jessibuca-controls-item-wrap"><div class="jessibuca-controls-item jessibuca-play">${Yl.play}</div><div class="jessibuca-controls-item jessibuca-pause">${Yl.pause}</div></div>`:""}\n ${s.screenshot?`<div class="jessibuca-controls-item-wrap"><div class="jessibuca-controls-item jessibuca-screenshot">${Yl.screenshot}</div></div>`:""}\n ${s.record?` <div class="jessibuca-controls-item-wrap"><div class="jessibuca-controls-item jessibuca-record">${Yl.record}</div><div class="jessibuca-controls-item jessibuca-record-stop">${Yl.recordStop}</div></div>`:""}\n ${s.ptz?` <div class="jessibuca-controls-item-wrap"><div class="jessibuca-controls-item jessibuca-ptz">${Yl.ptz}</div><div class="jessibuca-controls-item jessibuca-ptz-active">${Yl.ptzActive}</div></div>`:""}\n ${s.zoom?` <div class="jessibuca-controls-item-wrap"><div class="jessibuca-controls-item jessibuca-zoom">${Yl.zoom}</div><div class="jessibuca-controls-item jessibuca-zoom-stop">${Yl.zoomStop}</div></div>`:""}\n ${s.fullscreen?`<div class="jessibuca-controls-item-wrap"><div class="jessibuca-controls-item jessibuca-fullscreen">${Yl.fullscreen}</div><div class="jessibuca-controls-item jessibuca-fullscreen-exit">${Yl.fullscreenExit}</div></div>`:""}\n </div>\n </div>\n </div>\n `:""}\n <div class="jessibuca-performance-panel"></div>\n <div class="jessibuca-contextmenus"></div>\n <div class="jessibuca-tips-message">\n <div class="jessibuca-tips-message-close">\n <div class="jessibuca-tips-message-close-icon"></div>\n </div>\n <div class="jessibuca-tips-message-content"></div>\n </div>\n `),Object.defineProperty(t,"$poster",{value:e.$container.querySelector(".jessibuca-poster")}),Object.defineProperty(t,"$loadingBg",{value:e.$container.querySelector(".jessibuca-loading-bg")}),Object.defineProperty(t,"$loadingBgImage",{value:e.$container.querySelector(".jessibuca-loading-bg-image")}),Object.defineProperty(t,"$loading",{value:e.$container.querySelector(".jessibuca-loading")}),Object.defineProperty(t,"$loadingText",{value:e.$container.querySelector(".jessibuca-loading-text")}),Object.defineProperty(t,"$play",{value:e.$container.querySelector(".jessibuca-play")}),Object.defineProperty(t,"$playBig",{value:e.$container.querySelector(".jessibuca-play-big")}),Object.defineProperty(t,"$recording",{value:e.$container.querySelector(".jessibuca-recording")}),Object.defineProperty(t,"$recordingTime",{value:e.$container.querySelector(".jessibuca-recording-time")}),Object.defineProperty(t,"$recordingStop",{value:e.$container.querySelector(".jessibuca-recording-stop")}),Object.defineProperty(t,"$pause",{value:e.$container.querySelector(".jessibuca-pause")}),Object.defineProperty(t,"$controls",{value:e.$container.querySelector(".jessibuca-controls")}),Object.defineProperty(t,"$controlsInner",{value:e.$container.querySelector(".jessibuca-controls-bottom")}),Object.defineProperty(t,"$controlsLeft",{value:e.$container.querySelector(".jessibuca-controls-left")}),Object.defineProperty(t,"$controlsRight",{value:e.$container.querySelector(".jessibuca-controls-right")}),Object.defineProperty(t,"$volume",{value:e.$container.querySelector(".jessibuca-volume")}),Object.defineProperty(t,"$volumePanelWrap",{value:e.$container.querySelector(".jessibuca-volume-panel-wrap")}),Object.defineProperty(t,"$volumePanelText",{value:e.$container.querySelector(".jessibuca-volume-panel-text")}),Object.defineProperty(t,"$volumePanel",{value:e.$container.querySelector(".jessibuca-volume-panel")}),Object.defineProperty(t,"$volumeHandle",{value:e.$container.querySelector(".jessibuca-volume-panel-handle")}),Object.defineProperty(t,"$volumeOn",{value:e.$container.querySelector(".jessibuca-icon-audio")}),Object.defineProperty(t,"$volumeOff",{value:e.$container.querySelector(".jessibuca-icon-mute")}),Object.defineProperty(t,"$fullscreen",{value:e.$container.querySelector(".jessibuca-fullscreen")}),Object.defineProperty(t,"$fullscreenExit",{value:e.$container.querySelector(".jessibuca-fullscreen-exit")}),Object.defineProperty(t,"$record",{value:e.$container.querySelector(".jessibuca-record")}),Object.defineProperty(t,"$recordStop",{value:e.$container.querySelector(".jessibuca-record-stop")}),Object.defineProperty(t,"$screenshot",{value:e.$container.querySelector(".jessibuca-screenshot")}),Object.defineProperty(t,"$speed",{value:e.$container.querySelector(".jessibuca-speed")}),Object.defineProperty(t,"$controlHtml",{value:e.$container.querySelector(".jessibuca-controls-item-html")}),Object.defineProperty(t,"$playbackTime",{value:e.$container.querySelector(".jessibuca-controls-playback-time")}),Object.defineProperty(t,"$playbackTimeInner",{value:e.$container.querySelector(".jessibuca-controls-playback-time-inner")}),Object.defineProperty(t,"$playbackTimeScroll",{value:e.$container.querySelector(".jessibuca-controls-playback-time-scroll")}),Object.defineProperty(t,"$playbackTimeList",{value:e.$container.querySelector(".jessibuca-controls-playback-time-list")}),Object.defineProperty(t,"$playbackTimeListOne",{value:e.$container.querySelector(".jessibuca-playback-time-one-wrap")}),Object.defineProperty(t,"$playbackTimeListSecond",{value:e.$container.querySelector(".jessibuca-playback-time-second-wrap")}),Object.defineProperty(t,"$playbackCurrentTime",{value:e.$container.querySelector(".jessibuca-controls-playback-current-time")}),Object.defineProperty(t,"$playbackCurrentTimeText",{value:e.$container.querySelector(".jessibuca-controls-playback-current-time-text")}),Object.defineProperty(t,"$controlsPlaybackBtns",{value:e.$container.querySelector(".jessibuca-controls-playback-btns")}),Object.defineProperty(t,"$playbackNarrow",{value:e.$container.querySelector(".jessibuca-playback-narrow")}),Object.defineProperty(t,"$playbackExpand",{value:e.$container.querySelector(".jessibuca-playback-expand")}),Object.defineProperty(t,"$ptz",{value:e.$container.querySelector(".jessibuca-ptz")}),Object.defineProperty(t,"$ptzActive",{value:e.$container.querySelector(".jessibuca-ptz-active")}),Object.defineProperty(t,"$ptzControl",{value:e.$container.querySelector(".jessibuca-ptz-controls")}),Object.defineProperty(t,"$ptzBgActive",{value:e.$container.querySelector(".jessibuca-ptz-bg-active")}),Object.defineProperty(t,"$ptzControlCircular",{value:e.$container.querySelector(".jessibuca-ptz-control")}),Object.defineProperty(t,"$ptzArrows",{value:e.$container.querySelectorAll(".jessibuca-ptz-arrow")}),Object.defineProperty(t,"$ptzExpand",{value:e.$container.querySelector(".jessibuca-ptz-expand")}),Object.defineProperty(t,"$ptzNarrow",{value:e.$container.querySelector(".jessibuca-ptz-narrow")}),Object.defineProperty(t,"$ptzApertureFar",{value:e.$container.querySelector(".jessibuca-ptz-aperture-far")}),Object.defineProperty(t,"$ptzApertureNear",{value:e.$container.querySelector(".jessibuca-ptz-aperture-near")}),Object.defineProperty(t,"$ptzFocusFar",{value:e.$container.querySelector(".jessibuca-ptz-focus-far")}),Object.defineProperty(t,"$ptzFocusNear",{value:e.$container.querySelector(".jessibuca-ptz-focus-near")}),Object.defineProperty(t,"$qualityText",{value:e.$container.querySelector(".jessibuca-quality-icon-text")}),Object.defineProperty(t,"$qualityMenu",{value:e.$container.querySelector(".jessibuca-quality-menu")}),Object.defineProperty(t,"$qualityMenuList",{value:e.$container.querySelector(".jessibuca-quality-menu-list")}),Object.defineProperty(t,"$scaleText",{value:e.$container.querySelector(".jessibuca-scale-icon-text")}),Object.defineProperty(t,"$scaleMenu",{value:e.$container.querySelector(".jessibuca-scale-menu")}),Object.defineProperty(t,"$scaleMenuList",{value:e.$container.querySelector(".jessibuca-scale-menu-list")}),Object.defineProperty(t,"$zoom",{value:e.$container.querySelector(".jessibuca-zoom")}),Object.defineProperty(t,"$zoomStop",{value:e.$container.querySelector(".jessibuca-zoom-stop")}),Object.defineProperty(t,"$zoomNarrow",{value:e.$container.querySelector(".jessibuca-zoom-narrow")}),Object.defineProperty(t,"$zoomExpand",{value:e.$container.querySelector(".jessibuca-zoom-expand")}),Object.defineProperty(t,"$zoomStop2",{value:e.$container.querySelector(".jessibuca-zoom-stop2")}),Object.defineProperty(t,"$close",{value:e.$container.querySelector(".jessibuca-close")}),Object.defineProperty(t,"$zoomControls",{value:e.$container.querySelector(".jessibuca-zoom-controls")}),Object.defineProperty(t,"$performancePanel",{value:e.$container.querySelector(".jessibuca-performance-panel")}),Object.defineProperty(t,"$performance",{value:e.$container.querySelector(".jessibuca-performance")}),Object.defineProperty(t,"$performanceActive",{value:e.$container.querySelector(".jessibuca-performance-active")}),Object.defineProperty(t,"$faceDetect",{value:e.$container.querySelector(".jessibuca-face")}),Object.defineProperty(t,"$faceDetectActive",{value:e.$container.querySelector(".jessibuca-face-active")}),Object.defineProperty(t,"$objectDetect",{value:e.$container.querySelector(".jessibuca-object")}),Object.defineProperty(t,"$objectDetectActive",{value:e.$container.querySelector(".jessibuca-object-active")}),Object.defineProperty(t,"$occlusionDetect",{value:e.$container.querySelector(".jessibuca-occlusion")}),Object.defineProperty(t,"$occlusionDetectActive",{value:e.$container.querySelector(".jessibuca-occlusion-active")}),Object.defineProperty(t,"$contextmenus",{value:e.$container.querySelector(".jessibuca-contextmenus")}),Object.defineProperty(t,"$speedText",{value:e.$container.querySelector(".jessibuca-speed-icon-text")}),Object.defineProperty(t,"$speedMenu",{value:e.$container.querySelector(".jessibuca-speed-menu")}),Object.defineProperty(t,"$speedMenuList",{value:e.$container.querySelector(".jessibuca-speed-menu-list")}),Object.defineProperty(t,"$logSave",{value:e.$container.querySelector(".jessibuca-logSave")}),Object.defineProperty(t,"$playbackProgress",{value:e.$container.querySelector(".jessibuca-control-progress-simple")}),Object.defineProperty(t,"$playbackProgressTip",{value:e.$container.querySelector(".jessibuca-progress-tip")}),Object.defineProperty(t,"$playbackProgressHover",{value:e.$container.querySelector(".jessibuca-progress-hover")}),Object.defineProperty(t,"$playbackProgressPlayed",{value:e.$container.querySelector(".jessibuca-progress-played")}),Object.defineProperty(t,"$playbackProgressIndicator",{value:e.$container.querySelector(".jessibuca-progress-indicator")}),Object.defineProperty(t,"$playbackProgressTime",{value:e.$container.querySelector(".jessibuca-playback-control-time")}),Object.defineProperty(t,"$tipsMessage",{value:e.$container.querySelector(".jessibuca-tips-message")}),Object.defineProperty(t,"$tipsMessageClose",{value:e.$container.querySelector(".jessibuca-tips-message-close")}),Object.defineProperty(t,"$tipsMessageContent",{value:e.$container.querySelector(".jessibuca-tips-message-content")})})(e,this),e._opt.extendOperateBtns.length>0&&e._opt.extendOperateBtns.forEach((e=>{this.addExtendBtn(e)})),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}}),hh(e,this),((e,t)=>{const{events:{proxy:i},debug:s}=e,r=e._opt,a=r.operateBtns;function o(e){const{bottom:i,height:s}=t.$volumePanel.getBoundingClientRect(),{height:r}=t.$volumeHandle.getBoundingClientRect();return hr(i-e.y-r/2,0,s-r/2)/(s-r)}if(gr()&&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=>{r.playType===A&&r.playbackConfig.uiUsePlaybackPause?e.playbackPause=!0:Xr(a.pauseFn)?a.pauseFn():e.pauseForControl()})),i(t.$play,"click",(t=>{r.playType===A&&e.playbackPause?e.playbackPause=!1:Xr(a.playFn)?a.playFn():e.playForControl().then((()=>{e.resumeAudioAfterPause()}))}))),i(t.$playBig,"click",(t=>{r.playType===A&&e.playbackPause?e.playbackPause=!1:Xr(a.playFn)?a.playFn():e.playForControl().then((()=>{e.resumeAudioAfterPause()}))})),a.screenshot&&i(t.$screenshot,"click",(t=>{t.stopPropagation(),Xr(a.screenshotFn)?a.screenshotFn():e.video.screenshot()})),a.audio&&(gr()&&(i(t.$volume,"mouseover",(()=>{t.$volumePanelWrap.classList.add("jessibuca-volume-panel-wrap-show")})),i(t.$volume,"mouseout",(()=>{t.$volumePanelWrap.classList.remove("jessibuca-volume-panel-wrap-show")})),i(t.$volumePanel,"click",(t=>{t.stopPropagation(),e.volume=o(t)})),i(t.$volumeHandle,"mousedown",(()=>{t.isVolumeDroging=!0})),i(t.$volumeHandle,"mousemove",(i=>{t.isVolumeDroging&&(e.volume=o(i))})),i(document,"mouseup",(()=>{t.isVolumeDroging&&(t.isVolumeDroging=!1)}))),i(t.$volumeOn,"click",(i=>{i.stopPropagation(),dr(t.$volumeOn,"display","none"),dr(t.$volumeOff,"display","block");const s=e.volume;e.volume=0,e._lastVolume=gr()?s:1})),i(t.$volumeOff,"click",(i=>{i.stopPropagation(),dr(t.$volumeOn,"display","block"),dr(t.$volumeOff,"display","none"),e.volume=gr()?e.lastVolume||.5:1}))),a.record&&(i(t.$record,"click",(t=>{t.stopPropagation(),Xr(a.recordFn)?a.recordFn():e.recording=!0})),i(t.$recordStop,"click",(t=>{t.stopPropagation(),Xr(a.recordStopFn)?a.recordStopFn():e.recording=!1}))),i(t.$recordingStop,"click",(t=>{t.stopPropagation(),Xr(a.recordStopFn)?a.recordStopFn():e.recording=!1})),a.fullscreen&&(i(t.$fullscreen,"click",(t=>{t.stopPropagation(),Xr(a.fullscreenFn)?a.fullscreenFn():e.fullscreen=!0})),i(t.$fullscreenExit,"click",(t=>{t.stopPropagation(),Xr(a.fullscreenExitFn)?a.fullscreenExitFn():e.fullscreen=!1}))),a.ptz){if(i(t.$ptz,"click",(e=>{e.stopPropagation(),dr(t.$ptzActive,"display","flex"),dr(t.$ptz,"display","none"),t.$ptzControl.classList.add("jessibuca-ptz-controls-show")})),i(t.$ptzActive,"click",(e=>{e.stopPropagation(),dr(t.$ptz,"display","flex"),dr(t.$ptzActive,"display","none"),t.$ptzControl.classList.remove("jessibuca-ptz-controls-show")})),t.$ptzArrows.forEach((s=>{if(r.ptzClickType===V)i(s,"click",(i=>{i.stopPropagation();const s=i.currentTarget.dataset.arrow;t.$ptzBgActive.classList.add("jessibuca-ptz-bg-active-show"),t.$ptzBgActive.classList.add(`jessibuca-ptz-bg-active-${s}`),t.$ptzControlCircular.classList.add(`jessibuca-ptz-control-${s}`),e.emit(Ze.ptz,ya(s)),setTimeout((()=>{t.$ptzBgActive.classList.remove("jessibuca-ptz-bg-active-show"),li.forEach((e=>{t.$ptzBgActive.classList.remove(`jessibuca-ptz-bg-active-${e}`),t.$ptzControlCircular.classList.remove(`jessibuca-ptz-control-${e}`)})),e.emit(Ze.ptz,hi)}),1e3*r.ptzStopEmitDelay)}));else if(r.ptzClickType===J){let r=!1;i(s,"mousedown",(i=>{i.stopPropagation(),r=!0;const s=i.currentTarget.dataset.arrow;t.$ptzBgActive.classList.add("jessibuca-ptz-bg-active-show"),t.$ptzBgActive.classList.add(`jessibuca-ptz-bg-active-${s}`),t.$ptzControlCircular.classList.add(`jessibuca-ptz-control-${s}`),e.emit(Ze.ptz,ya(s))}));const a=()=>{r=!1,t.$ptzBgActive.classList.remove("jessibuca-ptz-bg-active-show"),li.forEach((e=>{t.$ptzBgActive.classList.remove(`jessibuca-ptz-bg-active-${e}`),t.$ptzControlCircular.classList.remove(`jessibuca-ptz-control-${e}`)})),e.emit(Ze.ptz,hi)};i(s,"mouseup",(e=>{e.stopPropagation(),r&&a()})),i(window,"mouseup",(e=>{e.stopPropagation(),r&&a()}))}})),r.ptzZoomShow)if(r.ptzClickType===V)i(t.$ptzExpand,"click",(t=>{t.stopPropagation(),e.emit(Ze.ptz,ci),setTimeout((()=>{e.emit(Ze.ptz,hi)}),1e3*r.ptzStopEmitDelay)})),i(t.$ptzNarrow,"click",(t=>{t.stopPropagation(),e.emit(Ze.ptz,ui),setTimeout((()=>{e.emit(Ze.ptz,hi)}),1e3*r.ptzStopEmitDelay)}));else if(r.ptzClickType===J){let s=!1,r=!1;i(t.$ptzExpand,"mousedown",(t=>{t.stopPropagation(),s=!0,e.emit(Ze.ptz,ci)})),i(t.$ptzNarrow,"mousedown",(t=>{t.stopPropagation(),r=!0,e.emit(Ze.ptz,ui)}));const a=()=>{s=!1,r=!1,e.emit(Ze.ptz,hi)};i(t.$ptzExpand,"mouseup",(e=>{e.stopPropagation(),s&&a()})),i(t.$ptzNarrow,"mouseup",(e=>{e.stopPropagation(),r&&a()})),i(window,"mouseup",(e=>{e.stopPropagation(),(s||r)&&a()}))}if(r.ptzApertureShow)if(r.ptzClickType===V)i(t.$ptzApertureFar,"click",(t=>{t.stopPropagation(),e.emit(Ze.ptz,pi),setTimeout((()=>{e.emit(Ze.ptz,di)}),1e3*r.ptzStopEmitDelay)})),i(t.$ptzApertureNear,"click",(t=>{t.stopPropagation(),e.emit(Ze.ptz,fi),setTimeout((()=>{e.emit(Ze.ptz,di)}),1e3*r.ptzStopEmitDelay)}));else if(r.ptzClickType===J){let s=!1,r=!1;i(t.$ptzApertureFar,"mousedown",(t=>{t.stopPropagation(),s=!0,e.emit(Ze.ptz,pi)})),i(t.$ptzApertureNear,"mousedown",(t=>{t.stopPropagation(),r=!0,e.emit(Ze.ptz,fi)}));const a=()=>{s=!1,r=!1,e.emit(Ze.ptz,di)};i(t.$ptzApertureFar,"mouseup",(e=>{e.stopPropagation(),s&&a()})),i(t.$ptzApertureNear,"mouseup",(e=>{e.stopPropagation(),r&&a()})),i(window,"mouseup",(e=>{e.stopPropagation(),(s||r)&&a()}))}if(r.ptzFocusShow)if(r.ptzClickType===V)i(t.$ptzFocusFar,"click",(t=>{t.stopPropagation(),e.emit(Ze.ptz,mi),setTimeout((()=>{e.emit(Ze.ptz,di)}),1e3*r.ptzStopEmitDelay)})),i(t.$ptzFocusNear,"click",(t=>{t.stopPropagation(),e.emit(Ze.ptz,gi),setTimeout((()=>{e.emit(Ze.ptz,di)}),1e3*r.ptzStopEmitDelay)}));else if(r.ptzClickType===J){let s=!1,r=!1;i(t.$ptzFocusFar,"mousedown",(t=>{t.stopPropagation(),s=!0,e.emit(Ze.ptz,mi)})),i(t.$ptzFocusNear,"mousedown",(t=>{t.stopPropagation(),r=!0,e.emit(Ze.ptz,gi)}));const a=()=>{s=!1,r=!1,e.emit(Ze.ptz,di)};i(t.$ptzFocusFar,"mouseup",(e=>{e.stopPropagation(),s&&a()})),i(t.$ptzFocusNear,"mouseup",(e=>{e.stopPropagation(),r&&a()})),i(window,"mouseup",(e=>{e.stopPropagation(),(s||r)&&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||(dr(t.$controls,"display","block"),r())})),i(e.$container,"mousemove",(()=>{e.$container&&t.$controls&&(e.fullscreen,"none"===t.$controls.style.display&&(dr(t.$controls,"display","block"),r()))})),i(e.$container,"mouseout",(()=>{a(),dr(t.$controls,"display","none")}));let s=null;const r=()=>{a(),s=setTimeout((()=>{dr(t.$controls,"display","none")}),5e3)},a=()=>{s&&(clearTimeout(s),s=null)}}if(e._opt.playType===A){let s=e._opt.playbackConfig.controlType;e._opt.playbackConfig.showRateBtn&&(i(t.$speedMenu,"mouseover",(()=>{t.$speedMenuList.classList.add("jessibuca-speed-menu-shown")})),i(t.$speedMenu,"mouseout",(()=>{t.$speedMenuList.classList.remove("jessibuca-speed-menu-shown")})),i(t.$speedMenuList,"click",(t=>{const i=Yr(t);if(i.matches("div.jessibuca-speed-menu-item")){const t=i.dataset;e.emit(Ze.playbackPreRateChange,t.speed)}}))),s===K.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=Yr(t);i.matches("div.jessibuca-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()}))):s===K.simple&&(t.isDroging=!1,i(t.$playbackProgress,"click",(i=>{if(i.target!==t.$playbackProgressIndicator){let s=0,r=0;if(e.isInWebFullscreen())s=i.touches[0].clientY/e.height,r=s*e.playback.totalDuration;else{const a=rh(t,e.playback.totalDuration,i);s=a.percentage,r=a.second}e.playback&&e.playback.seek({time:r})}})),i(t.$playbackProgress,"mousemove",(i=>{dr(t.$playbackProgressTip,"display","block");const{width:s,time:r}=rh(t,e.playback.totalDuration,i);t.$playbackProgressTip.innerHTML=r;const a=t.$playbackProgressTip.clientWidth;s<=a/2?dr(t.$playbackProgressTip,"left",0):s>t.$playbackProgress.clientWidth-a/2?dr(t.$playbackProgressTip,"left",t.$playbackProgress-a+"px"):dr(t.$playbackProgressTip,"left",s-a/2+"px")})),i(t.$playbackProgress,"mouseout",(()=>{dr(t.$playbackProgressTip,"display","none")})),i(t.$playbackProgressIndicator,"mousedown",(e=>{t.isDroging=!0})),i(t.$playbackProgress,"mousemove",(i=>{if(t.isDroging){const{second:s,percentage:r}=rh(t,e.playback.totalDuration,i);e.playback&&e.playback.seek({time:s})}})),i(t.$playbackProgress,"mouseup",(e=>{t.isDroging&&(t.isDroging=!1)})))}a.quality&&(i(t.$qualityMenu,"mouseover",(()=>{t.$qualityMenuList.classList.add("jessibuca-quality-menu-shown")})),i(t.$qualityMenu,"mouseout",(()=>{t.$qualityMenuList.classList.remove("jessibuca-quality-menu-shown")})),i(t.$qualityMenuList,"click",(t=>{const i=Yr(t);if(i.matches("div.jessibuca-quality-menu-item")){const t=i.dataset;e.streamQuality=t.quality}}))),a.scale&&(i(t.$scaleMenu,"mouseover",(()=>{t.$scaleMenuList.classList.add("jessibuca-scale-menu-shown")})),i(t.$scaleMenu,"mouseout",(()=>{t.$scaleMenuList.classList.remove("jessibuca-scale-menu-shown")})),i(t.$scaleMenuList,"click",(t=>{const i=Yr(t);if(i.matches("div.jessibuca-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="",dr(t.$tipsMessage,"display","none")}))})(e,this),e._opt.hotKey&&((e,t)=>{const{events:{proxy:i}}=e,s={};function r(e,t){s[e]?s[e].push(t):s[e]=[t]}r(Zt,(()=>{e.fullscreen&&(e.fullscreen=!1)})),r(ei,(()=>{e.volume+=.05})),r(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=s[e.keyCode];t&&(e.preventDefault(),t.forEach((e=>e())))}}}))})(e,this),this.btnIndex=0,this.initLoadingBackground(),Vr(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(!lh(this.$performancePanel)){const e=this.player.$container.querySelector(".jessibuca-performance-panel");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$poster){if(!lh(this.$poster)){const e=this.player.$container.querySelector(".jessibuca-poster");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$loading){if(!lh(this.$loading)){const e=this.player.$container.querySelector(".jessibuca-loading");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$loadingBg){if(!lh(this.$loadingBg)){const e=this.player.$container.querySelector(".jessibuca-loading-bg");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$controls){if(!lh(this.$controls)){const e=this.player.$container.querySelector(".jessibuca-controls");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$playBig){if(!lh(this.$playBig)){const e=this.player.$container.querySelector(".jessibuca-play-big");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$recording){if(!lh(this.$recording)){const e=this.player.$container.querySelector(".jessibuca-recording");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$ptzControl){if(!lh(this.$ptzControl)){const e=this.player.$container.querySelector(".jessibuca-ptz-controls");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$zoomControls){if(!lh(this.$zoomControls)){const e=this.player.$container.querySelector(".jessibuca-zoom-controls");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$contextmenus){this.$contextmenus.innerHTML="";if(!lh(this.$contextmenus)){const e=this.player.$container.querySelector(".jessibuca-contextmenus");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$tipsMessage){if(!lh(this.$tipsMessage)){const e=this.player.$container.querySelector(".jessibuca-tips-message");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("jessibuca-controls-show-auto-hide"),this.player.$container.classList.remove("jessibuca-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,s=t/i,r=e.video.$videoElement.width/e.video.$videoElement.height;if(s>r){const s=(t-i*r)/2;e.$container.style.padding=`0 ${s}px`}else{const s=(i-t/r)/2;e.$container.style.padding=`${s}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||mr()?(e.getRenderType()===z||e.getRenderType()===$)&&this._initLoadingBackground():this._initLoadingBackgroundForRatio(),oh(this.$loadingBg,"display","block"),e._opt.loadingBackground="",e._opt.loadingBackgroundWidth=0,e._opt.loadingBackgroundHeight=0)}initLoadingIconStyle(e){const t=this.player.$container.querySelector(".jessibuca-icon-loading");t&&(e.width&&oh(t,"width",`${e.width}px`),e.height&&oh(t,"height",`${e.height}px`),e.background&&oh(t,"backgroundImage",`url("${e.background}")`),!1===e.hasAnimation&&(oh(t,"animationName","none"),oh(t,"animationDuration",0),oh(t,"animationTimingFunction","ease"),oh(t,"animationIterationCount",1)))}_initLoadingBackgroundForRatio(){const e=this.player._opt.aspectRatio.split(":").map(Number);let t=this.player.width,i=this.player.height;const s=this.player._opt;let r=0;s.hasControl&&!s.controlAutoHide&&(r=s.playType===A?Bt:Pt,i-=r);const a=this.player._opt.loadingBackgroundWidth,o=this.player._opt.loadingBackgroundHeight,n=a/o,l=e[0]/e[1];if(this.$loadingBgImage.src=this.player._opt.loadingBackground,n>l){const e=l*o/a;this.$loadingBgImage.style.width=100*e+"%",this.$loadingBgImage.style.height=`calc(100% - ${r}px)`,this.$loadingBgImage.style.padding=`0 ${(t-t*e)/2}px`}else{const e=a/l/o;this.$loadingBgImage.style.width="100%",this.$loadingBgImage.style.height=`calc(${100*e}% - ${r}px)`,this.$loadingBgImage.style.padding=(i-i*e)/2+"px 0"}}_initLoadingBackgroundForCanvas(){const e=this.player._opt;let t=this.player.width,i=this.player.height;if(e.hasControl&&!e.controlAutoHide){const s=e.playType===A?Bt:Pt;mr()&&this.player.fullscreen&&e.useWebFullScreen?t-=s:i-=s}let s={width:this.player._opt.loadingBackgroundWidth,height:this.player._opt.loadingBackgroundHeight},r=s.width,a=s.height;const o=e.rotate;let n=(t-r)/2,l=(i-a)/2;270!==o&&90!==o||(r=s.height,a=s.width);const h=t/r,d=i/a;let c=h>d?d:h;e.isResize||h!==d&&(c=h+","+d),e.isFullResize&&(c=h>d?h:d);let u="scale("+c+")";"none"===e.mirrorRotate&&o&&(u+=" rotate("+o+"deg)"),"level"===e.mirrorRotate?u+=" rotateY(180deg)":"vertical"===e.mirrorRotate&&(u+=" rotateX(180deg)"),this.$loadingBgImage.src=this.player._opt.loadingBackground,this.$loadingBgImage.style.height=s.height+"px",this.$loadingBgImage.style.width=s.width+"px",this.$loadingBgImage.style.padding="0",this.$loadingBgImage.style.transform=u,this.$loadingBgImage.style.left=n+"px",this.$loadingBgImage.style.top=l+"px",this.$loadingBgImage.style.display="block"}_initLoadingBackground(){const e=this.player;let t=e.height;const i=e._opt;if(i.hasControl&&!i.controlAutoHide){t-=i.playType===A?Bt:Pt}let s=e.width,r=t;const a=i.rotate;270!==a&&90!==a||(s=t,r=e.width),this.$loadingBgImage.width=s,this.$loadingBgImage.height=r,this.$loadingBgImage.src=e._opt.loadingBackground;let o=(e.width-s)/2,n=(t-r)/2,l="contain";i.isResize||(l="fill"),i.isFullResize&&(l="none");let h="";"none"===i.mirrorRotate&&a&&(h+=" rotate("+a+"deg)"),"level"===i.mirrorRotate?h+=" rotateY(180deg)":"vertical"===i.mirrorRotate&&(h+=" rotateX(180deg)"),this.player._opt.videoRenderSupportScale&&(this.$loadingBgImage.style.objectFit=l),this.$loadingBgImage.style.transform=h,this.$loadingBgImage.style.padding="0",this.$loadingBgImage.style.left=o+"px",this.$loadingBgImage.style.top=n+"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(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=ha(as);if(e=Object.assign({},t,e),!this._validateExtendBtn(e))return;const i=e.name||"",s=this.$controlsRight,r=e.activeIcon&&e.activeClick,a=`\n <div class="jessibuca-controls-item-wrap jessibuca-controls-item-wrap-${i}">\n ${e.icon?`<div class="jessibuca-controls-item jessibuca-control-extend-${i}">\n <i class="jessibuca-icon jessibuca-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="jessibuca-controls-item jessibuca-control-extend-${i}-active">\n <i class="jessibuca-icon jessibuca-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 `,o=Array.from(s.children)[e.index];o?o.insertAdjacentHTML("beforebegin",a):ah(s,a);const n=s.querySelector(`.jessibuca-controls-item-wrap-${i}`),l=e.icon?s.querySelector(`.jessibuca-icon-extend-${i}`):null,h=e.icon?s.querySelector(`.jessibuca-control-extend-${i}`):null,d=e.activeIcon?s.querySelector(`.jessibuca-icon-extend-${i}-active`):null,c=e.activeIcon?s.querySelector(`.jessibuca-control-extend-${i}-active`):null,{events:{proxy:u},debug:p}=this.player;e.icon&&(oh(l,"background",`url(${e.icon}) no-repeat center`),oh(l,"background-size","100% 100%"),oh(h,"display","none"),e.iconHover&&(u(l,"mouseover",(()=>{oh(l,"background",`url(${e.iconHover}) no-repeat center`),oh(l,"background-size","100% 100%")})),u(l,"mouseout",(()=>{oh(l,"background",`url(${e.icon}) no-repeat center`),oh(l,"background-size","100% 100%")})))),e.activeIcon&&(oh(d,"background",`url(${e.activeIcon}) no-repeat center`),oh(d,"background-size","100% 100%"),oh(c,"display","none"),e.activeIconHover&&(u(d,"mouseover",(()=>{oh(d,"background",`url(${e.activeIconHover}) no-repeat center`),oh(d,"background-size","100% 100%")})),u(d,"mouseout",(()=>{oh(d,"background",`url(${e.activeIcon}) no-repeat center`),oh(d,"background-size","100% 100%")})))),e.click&&l&&u(l,"click",(t=>{t.preventDefault(),r&&(oh(h,"display","none"),oh(c,"display","flex")),this.player.isInMulti()?e.click.call(this.player,t,this.player._opt.multiIndex):e.click.call(this.player,t)})),e.activeClick&&d&&u(d,"click",(t=>{t.preventDefault(),oh(h,"display","flex"),oh(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:n,$iconWrap:h,$activeIconWrap:c})}updateLoadingText(e){this.$loadingText&&(this.$loadingText.innerText=e)}getExtendBtnList(){return this.extendBtnList}showTipsMessage(e,t){const i=this.$tipsMessage,s=this.$tipsMessageContent;if(i){const r=`\n <div class="jessibuca-tips-message-content-item">${e}</div>\n ${t?`<div class="jessibuca-tips-message-content-item">Error Type:${t}</div>`:""}\n `;s.innerHTML=r,oh(i,"display","block")}}hideTipsMessage(){const e=this.$tipsMessage;e&&($tipsMessageContent.innerHTML="",oh(e,"display","none"))}}dh(".jessibuca-container{position:relative;width:100%;height:100%;overflow:hidden}.jessibuca-container.jessibuca-fullscreen-web{position:fixed;z-index:9999;left:0;top:0;right:0;bottom:0;width:100vw!important;height:100vh!important;background:#000}");class uh{static init(){uh.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 uh.types)uh.types.hasOwnProperty(e)&&(uh.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let e=uh.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,s=Array.prototype.slice.call(arguments,1),r=s.length;for(let e=0;e<r;e++)t+=s[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<r;e++)i.set(s[e],a),a+=s[e].byteLength;return i}static generateInitSegment(e){let t=uh.box(uh.types.ftyp,uh.constants.FTYP),i=uh.moov(e),s=new Uint8Array(t.byteLength+i.byteLength);return s.set(t,0),s.set(i,t.byteLength),s}static moov(e){let t=uh.mvhd(e.timescale,e.duration),i=uh.trak(e),s=uh.mvex(e);return uh.box(uh.types.moov,t,i,s)}static mvhd(e,t){return uh.box(uh.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 uh.box(uh.types.trak,uh.tkhd(e),uh.mdia(e))}static tkhd(e){let t=e.id,i=e.duration,s=e.presentWidth,r=e.presentHeight;return uh.box(uh.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,s>>>8&255,255&s,0,0,r>>>8&255,255&r,0,0]))}static mdia(e){return uh.box(uh.types.mdia,uh.mdhd(e),uh.hdlr(e),uh.minf(e))}static mdhd(e){let t=e.timescale,i=e.duration;return uh.box(uh.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?uh.constants.HDLR_AUDIO:uh.constants.HDLR_VIDEO,uh.box(uh.types.hdlr,t)}static minf(e){let t=null;return t="audio"===e.type?uh.box(uh.types.smhd,uh.constants.SMHD):uh.box(uh.types.vmhd,uh.constants.VMHD),uh.box(uh.types.minf,t,uh.dinf(),uh.stbl(e))}static dinf(){return uh.box(uh.types.dinf,uh.box(uh.types.dref,uh.constants.DREF))}static stbl(e){return uh.box(uh.types.stbl,uh.stsd(e),uh.box(uh.types.stts,uh.constants.STTS),uh.box(uh.types.stsc,uh.constants.STSC),uh.box(uh.types.stsz,uh.constants.STSZ),uh.box(uh.types.stco,uh.constants.STCO))}static stsd(e){return"audio"===e.type?"mp3"===e.audioType?uh.box(uh.types.stsd,uh.constants.STSD_PREFIX,uh.mp3(e)):uh.box(uh.types.stsd,uh.constants.STSD_PREFIX,uh.mp4a(e)):"avc"===e.videoType?uh.box(uh.types.stsd,uh.constants.STSD_PREFIX,uh.avc1(e)):uh.box(uh.types.stsd,uh.constants.STSD_PREFIX,uh.hvc1(e))}static mp3(e){let t=e.channelCount,i=e.audioSampleRate,s=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 uh.box(uh.types[".mp3"],s)}static mp4a(e){let t=e.channelCount,i=e.audioSampleRate,s=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 uh.box(uh.types.mp4a,s,uh.esds(e))}static esds(e){let t=e.config||[],i=t.length,s=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 uh.box(uh.types.esds,s)}static avc1(e){let t=e.avcc;const i=e.codecWidth,s=e.codecHeight;let r=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,s>>>8&255,255&s,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 uh.box(uh.types.avc1,r,uh.box(uh.types.avcC,t))}static hvc1(e){let t=e.avcc;const i=e.codecWidth,s=e.codecHeight;let r=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,s>>>8&255,255&s,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 uh.box(uh.types.hvc1,r,uh.box(uh.types.hvcC,t))}static mvex(e){return uh.box(uh.types.mvex,uh.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 uh.box(uh.types.trex,i)}static moof(e,t){return uh.box(uh.types.moof,uh.mfhd(e.sequenceNumber),uh.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 uh.box(uh.types.mfhd,t)}static traf(e,t){let i=e.id,s=uh.box(uh.types.tfhd,new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i])),r=uh.box(uh.types.tfdt,new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t])),a=uh.sdtp(e),o=uh.trun(e,a.byteLength+16+16+8+16+8+8);return uh.box(uh.types.traf,s,r,o,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,uh.box(uh.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 s=e.duration,r=e.size,a=e.flags,o=e.cts;return i.set([s>>>24&255,s>>>16&255,s>>>8&255,255&s,r>>>24&255,r>>>16&255,r>>>8&255,255&r,a.isLeading<<2|a.dependsOn,a.isDependedOn<<6|a.hasRedundancy<<4|a.isNonSync,0,0,o>>>24&255,o>>>16&255,o>>>8&255,255&o],12),uh.box(uh.types.trun,i)}static mdat(e){return uh.box(uh.types.mdat,e)}}uh.init();const ph=[44100,48e3,32e3,0],fh=[22050,24e3,16e3,0],mh=[11025,12e3,8e3,0],gh=[0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1],yh=[0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1],Ah=[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1];class bh extends t{constructor(e){super(),this.TAG_NAME="MediaSource",this.player=e,this._resetInIt(),this.mediaSource=new window.MediaSource,this.isDecodeFirstIIframe=!!fa(e._opt.checkFirstIFrame),this.mediaSourceObjectURL=window.URL.createObjectURL(this.mediaSource),this.isSupportVideoFrameCallback=wa(),e._opt.mseUseCanvasRender?(this.$videoElement=document.createElement("video"),this.$videoElement.src=this.mediaSourceObjectURL,this.initVideoEvents()):(this.player.video.$videoElement.src=this.mediaSourceObjectURL,this.$videoElement=this.player.video.$videoElement),this._bindMediaSourceEvents(),this.audioSourceBufferCheckTimeout=null,this.player.isPlayback()&&this.player.on(Ze.playbackPause,(t=>{fa(t)?(pa(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(Ze.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)}))}destroy(){this.stop(),this._clearAudioSourceBufferCheckTimeout(),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()}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.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.tempFmp4List=[],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,Si,(()=>{this.player.debug.log(this.TAG_NAME,"sourceOpen"),this._onMediaSourceSourceOpen(),this.player&&this.player.emit(Ze.mseSourceOpen)})),s=t(this.mediaSource,wi,(()=>{this.player.debug.log(this.TAG_NAME,"sourceClose"),this.player&&this.player.emit(Ze.mseSourceClose)})),r=t(this.mediaSource,Ti,(()=>{this.player.debug.log(this.TAG_NAME,"sourceended"),this.player&&this.player.emit(Ze.mseSourceended)}));this.eventListenList.push(i,s,r);const a=t(this.$videoElement,Ci,(e=>{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}`)}})),o=t(this.$videoElement,xi,(()=>{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(a,o)}_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(Ze.removeLoadingBgImage),wa()&&(this.supportVideoFrameCallbackHandle=this.$videoElement.requestVideoFrameCallback(this.videoFrameCallback.bind(this))),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(it.mediaSourceUseCanvasRenderPlayFailed,e)}))})),i=e(this.$videoElement,ki,(()=>{this.player.debug.log(this.TAG_NAME,"video waiting")})),s=e(this.$videoElement,Ci,(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,s)}videoFrameCallback(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.player.isDestroyed()?this.player.debug.log(this.TAG_NAME,"videoFrameCallback() player is destroyed"):(this.player.video.render({$video:this.$videoElement,ts:t.mediaTime||0}),this.supportVideoFrameCallbackHandle=this.$videoElement.requestVideoFrameCallback(this.videoFrameCallback.bind(this)))}decodeVideo(e,t,i,s){const r=this.player;if(r)if(this.player.isDestroyed())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===ct){i=ko(e.slice(5))}else t===ut&&(i=Oo(e));const s=this.player.video.videoInfo;s&&s.width&&s.height&&i&&i.codecWidth&&i.codecHeight&&(i.codecWidth!==s.width||i.codecHeight!==s.height)&&(this.player.debug.warn(this.TAG_NAME,`\n decodeVideo: video width or height is changed,\n old width is ${s.width}, old height is ${s.height},\n new width is ${i.codecWidth}, new height is ${i.codecHeight},\n and emit change event`),this.isWidthOrHeightChanged=!0,this.player.emitError(it.mseWidthOrHeightChange))}if(this.isWidthOrHeightChanged)return void this.player.debug.warn(this.TAG_NAME,"decodeVideo: video width or height is changed, and return");if(ua(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 r=t;if(this.player.isPlayer()){if(null===this.firstRenderTime&&(this.firstRenderTime=t),r=t-this.firstRenderTime,r<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}`),r=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}`),void this.player.emitError(it.mediaSourceTsIsMaxDiff);if(null!==this.prevDts&&r<=this.prevDts){if(this.player.debug.warn(this.TAG_NAME,`\n decodeVideo dts is less than(or equal) prev dts ,\n dts is ${r} 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}`),r===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(r=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(it.mediaSourceTsIsMaxDiff)}}this.player.isPlayer()?this._decodeVideo(e,r,i,s,t):this.player.isPlayback()&&fa(this.player.playbackPause)&&(this.player.playback.isUseLocalCalculateTime&&this.player.playback.increaseLocalTimestamp(),this._decodeVideo(e,r,i,s,t)),this.prevDts=r,this.prevPayloadBufferSize=e.byteLength,this.prevTs=t,this.player.getRenderType()===$&&this.player.video&&this.player.video.doAddContentToWatermark()}else this.player.debug.log(this.TAG_NAME,"decodeVideo first frame is not iFrame");else if(i&&e[1]===Gi){const s=15&e[0];if(r.video.updateVideoInfo({encTypeCode:s}),s===ut&&fa(Rr()))return void this.player.emitError(it.mediaSourceH265NotSupport);r._times.decodeStart||(r._times.decodeStart=lr()),this.hasInit=this._decodeConfigurationRecord(e,t,i,s)}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.isDestroyed())this.player.debug.warn(this.TAG_NAME,"decodeAudio() player is destroyed");else if(fa(this.hasAudioInit))this.hasAudioInit=this._decodeAudioConfigurationRecord(e,t);else{let i=t;if(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)return void 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}`);if(null!==this.prevAudioTs&&i<=this.prevAudioDts)return void 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}`)}(this.player.isPlayer()||this.player.isPlayback()&&fa(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>q}_decodeConfigurationRecord(e,t,i,s){let r=e.slice(5),a={};if(s===ct?a=ko(r):s===ut&&(a=Oo(e)),this.player.recorder&&this.player._opt.recordType===b&&this.player.recorder.initMetaData(e,s),0===a.codecWidth&&0===a.codecHeight)return this.player.debug.warn(this.TAG_NAME,"_decodeConfigurationRecord",a),this.player.emitError(it.mediaSourceDecoderConfigurationError),!1;const o={id:Ms,type:"video",timescale:1e3,duration:0,avcc:r,codecWidth:a.codecWidth,codecHeight:a.codecHeight,videoType:a.videoType},n=uh.generateInitSegment(o);return this.isAvc=s===ct,this.player.debug.log(this.TAG_NAME,`_decodeConfigurationRecord mimeType is ${this.isAvc?Kt:qt} and isAvc is ${this.isAvc}`),this._initSourceBuffer(),this.appendBuffer(n.buffer),this.sequenceNumber=0,this.cacheTrack={},this.timeInit=!1,!0}_decodeAudioConfigurationRecord(e,t){const i=e[0]>>4,s=i===At,r=i===mt;if(fa(r||s))return this.player.debug.warn(this.TAG_NAME,`_decodeAudioConfigurationRecord audio codec is not support , codecId is ${i} ant auto wasm decode`),this.player.emit(it.mediaSourceAudioG711NotSupport),!1;const a={id:Fs,type:"audio",timescale:1e3};let o={};if(Vs(e)){o=function(e){let t=new Uint8Array(e),i=null,s=0,r=0,a=0,o=null;if(s=r=t[0]>>>3,a=(7&t[0])<<1|t[1]>>>7,a<0||a>=Xs.length)return void console.error("Flv: AAC invalid sampling frequency index!");let n=Xs[a],l=(120&t[1])>>>3;if(l<0||l>=8)return void console.log("Flv: AAC invalid channel configuration");5===s&&(o=(7&t[1])<<1|t[2]>>>7,t[2]);let h=self.navigator.userAgent.toLowerCase();return-1!==h.indexOf("firefox")?a>=6?(s=5,i=new Array(4),o=a-3):(s=2,i=new Array(2),o=a):-1!==h.indexOf("android")?(s=2,i=new Array(2),o=a):(s=5,o=a,i=new Array(4),a>=6?o=a-3:1===l&&(s=2,i=new Array(2),o=a)),i[0]=s<<3,i[0]|=(15&a)>>>1,i[1]=(15&a)<<7,i[1]|=(15&l)<<3,5===s&&(i[1]|=(15&o)>>>1,i[2]=(1&o)<<7,i[2]|=8,i[3]=0),{audioType:"aac",config:i,sampleRate:n,channelCount:l,objectType:s,codec:"mp4a.40."+s,originalCodec:"mp4a.40."+r}}(e.slice(2)),a.audioSampleRate=o.sampleRate,a.channelCount=o.channelCount,a.config=o.config,a.refSampleDuration=1024/a.audioSampleRate*a.timescale}else o=function(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 s=t[1]>>>3&3,r=(6&t[1])>>1,a=(240&t[2])>>>4,o=(12&t[2])>>>2,n=3!=(t[3]>>>6&3)?2:1,l=0,h=0;switch(s){case 0:l=mh[o];break;case 2:l=fh[o];break;case 3:l=ph[o]}switch(r){case 1:a<Ah.length&&(h=Ah[a]);break;case 2:a<yh.length&&(h=yh[a]);break;case 3:a<gh.length&&(h=gh[a])}return i={bitRate:h,samplingRate:l,channelCount:n,codec:"mp3",originalCodec:"mp3",audioType:"mp3"},i}(e),a.audioSampleRate=o.samplingRate,a.channelCount=o.channelCount,a.refSampleDuration=1152/a.audioSampleRate*a.timescale;a.codec=o.codec,a.duration=0;let n="mp4",l=o.codec,h=null;s&&fa(Ar())?(n="mpeg",l="",h=new Uint8Array):h=uh.generateInitSegment(a);let d=`${a.type}/${n}`;return l&&l.length>0&&(d+=`;codecs=${l}`),fa(this.isAudioInitInfo)&&(this.player.audio.updateAudioInfo({encTypeCode:i,channels:a.channelCount,sampleRate:a.audioSampleRate}),this.isAudioInitInfo=!0),this.audioMimeType=d,this.isAAC=r,this.player.debug.log(this.TAG_NAME,`_decodeAudioConfigurationRecord mimeType is ${d} and isAAC is ${r}`),this._initAudioSourceBuffer(),this.appendAudioBuffer(h.buffer),!0}_initSourceBuffer(){const{debug:e,events:{proxy:t}}=this.player;if(null===this.sourceBuffer&&null!==this.mediaSource&&this.isStateOpen&&null!==this.isAvc){let i=this.isAvc?Kt:qt;try{this.sourceBuffer=this.mediaSource.addSourceBuffer(i),e.log(this.TAG_NAME,"_initSourceBuffer() this.mediaSource.addSourceBuffer()",i)}catch(t){return e.error(this.TAG_NAME,"appendBuffer() this.mediaSource.addSourceBuffer()",t.code,t),this.player.emitError(it.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(it.mseSourceBufferError,t)})),s=t(this.sourceBuffer,"updateend",(()=>{this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()&&this._doAppendSegments()}));this.eventListenList.push(i,s)}}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(it.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(it.mseSourceBufferError,t)})),s=t(this.audioSourceBuffer,"updateend",(()=>{this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()&&this._doAppendSegments()}));this.eventListenList.push(i,s)}}else e.log(this.TAG_NAME,`_initAudioSourceBuffer and this.isStateOpen is ${this.isStateOpen} and this.audioMimeType is ${this.audioMimeType}`)}_decodeVideo(e,t,i,s,r){const a=this.player;let o=e.slice(5),n=o.byteLength;if(0===n)return void a.debug.warn(this.TAG_NAME,"_decodeVideo payload bytes is 0 and return");let l=(new Date).getTime(),h=!1;this.prevTimestamp||(this.prevTimestamp=l,h=!0);const d=l-this.prevTimestamp;this.decodeDiffTimestamp=d,d>500&&!h&&this.player.isPlayer()&&a.debug.warn(this.TAG_NAME,`_decodeVideo now time is ${l} and prev time is ${this.prevTimestamp}, diff time is ${d} 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(uh.types.mdat,4),i.set(this.cacheTrack.data,8),this.cacheTrack.duration=t-this.cacheTrack.dts;let s=uh.moof(this.cacheTrack,this.cacheTrack.dts);this.cacheTrack={};let o=new Uint8Array(s.byteLength+i.byteLength);o.set(s,0),o.set(i,s.byteLength),this.appendBuffer(o.buffer),a.emit(Ze.timeUpdate,r),a.isPlayer()?a.updateStats({fps:!0,dfps:!0,ts:r,mseTs:t}):a.isPlayback()&&a.playback.updateStats({ts:r}),a._times.videoStart||(a._times.videoStart=lr(),a.handlePlayToRenderTimes())}else a.debug.log(this.TAG_NAME,`timeInit set false , cacheTrack = {} now dts is ${t}, and ts is ${r} cacheTrack dts is ${this.cacheTrack&&this.cacheTrack.dts}`),this.timeInit=!1,this.cacheTrack={};this.cacheTrack||(this.cacheTrack={}),this.cacheTrack.id=Ms,this.cacheTrack.sequenceNumber=++this.sequenceNumber,this.cacheTrack.size=n,this.cacheTrack.dts=t,this.cacheTrack.cts=s,this.cacheTrack.isKeyframe=i,this.cacheTrack.data=o,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&&fa(this.isSupportVideoFrameCallback)&&a.video.render({$video:c,ts:t}),this.prevTimestamp=(new Date).getTime()}_decodeAudio(e,t,i){this.player;let s=this.isAAC?e.slice(2):e.slice(1),r=s.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(uh.types.mdat,4),i.set(this.cacheAudioTrack.data,8),this.cacheAudioTrack.duration=t-this.cacheAudioTrack.dts;let s=uh.moof(this.cacheAudioTrack,this.cacheAudioTrack.dts);this.cacheAudioTrack={};let r=new Uint8Array(s.byteLength+i.byteLength);r.set(s,0),r.set(i,s.byteLength),this.appendAudioBuffer(r.buffer)}else this.cacheAudioTrack={};this.cacheAudioTrack||(this.cacheAudioTrack={}),this.cacheAudioTrack.id=Fs,this.cacheAudioTrack.sequenceNumber=++this.audioSequenceNumber,this.cacheAudioTrack.size=r,this.cacheAudioTrack.dts=t,this.cacheAudioTrack.cts=0,this.cacheAudioTrack.data=s,this.cacheAudioTrack.flags={isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}appendBuffer(e){if(this.player.isDestroyed())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,"this.mediaSourceAddSourceBufferError is true"):this.mediaSourceAppendBufferFull?t.warn(this.TAG_NAME,"this.mediaSourceAppendBufferFull is true"):this.mediaSourceAppendBufferError?t.warn(this.TAG_NAME,"this.mediaSourceAppendBufferError is true"):this.mediaSourceBufferError?t.warn(this.TAG_NAME,"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(),fa(this.getSourceBufferUpdating())&&this.isStateOpen&&fa(this._hasPendingRemoveRanges()))?this._doAppendSegments():this.isStateClosed?(this.mediaSourceBufferError=!0,this.player.emitError(it.mseSourceBufferError,"mediaSource is not attached to video or mediaSource is closed")):this.isStateEnded?(this.mediaSourceBufferError=!0,this.player.emitError(it.mseSourceBufferError,"mediaSource is end")):this._hasPendingRemoveRanges()&&t.log(this.TAG_NAME,"video has pending remove ranges"))}appendAudioBuffer(e){if(this.player.isDestroyed())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,"this.mediaSourceAddSourceBufferError is true"):this.mediaSourceAppendBufferFull?t.warn(this.TAG_NAME,"this.mediaSourceAppendBufferFull is true"):this.mediaSourceAppendBufferError?t.warn(this.TAG_NAME,"this.mediaSourceAppendBufferError is true"):this.mediaSourceBufferError?t.warn(this.TAG_NAME,"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(),fa(this.getAudioSourceBufferUpdating())&&this.isStateOpen&&fa(this._hasPendingRemoveRanges()))?this._doAppendSegments():this.isStateClosed?(this.mediaSourceBufferError=!0,this.player.emitError(it.mseSourceBufferError,"mediaSource is not attached to video or mediaSource is closed")):this.isStateEnded?(this.mediaSourceBufferError=!0,this.player.emitError(it.mseSourceBufferError,"mediaSource is end")):this._hasPendingRemoveRanges()&&t.log(this.TAG_NAME,"audio has pending remove ranges"))}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;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}getDecodeDiffTimes(){return this.decodeDiffTimestamp}removeBuffer(e,t){const i=Qr();if(this.player.debug.log(this.TAG_NAME,`removeBuffer() start is ${e} and end is ${t} and _isMacOsFirefox is ${i}`),this.isStateOpen&&fa(i)){if(fa(this.getSourceBufferUpdating()))try{this.sourceBuffer.remove(e,t)}catch(e){this.player.debug.warn(this.TAG_NAME,"removeBuffer() sourceBuffer error",e)}if(fa(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),s=e.end(t);this.pendingRemoveRanges.push({start:i,end:s})}fa(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),s=e.end(t);this.pendingAudioRemoveRanges.push({start:i,end:s})}fa(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}_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 s=i.length?i.end(i.length-1):0;let r=e.currentTime;const a=s-r,o=Math.max(5,t+3);if(this.player.updateStats({mseVideoBufferDelayTime:a}),a>o)this.player.debug.log(this.TAG_NAME,`handleUpdatePlaybackRate and buffered is ${s} and current is ${r} , delay buffer is more than ${o} is ${a} and new time is ${s}`),e.currentTime=s,r=e.currentTime;else if(a<0){if(this.player.debug.warn(this.TAG_NAME,`handleUpdatePlaybackRate and delay buffer is ${s} - current is ${r} = ${a} < 0 and check video is paused : ${e.paused} `),0===s)return void this.player.emit(it.mediaSourceBufferedIsZeroError,"video.buffered is empty");e.paused&&e.play()}const n=this._getPlaybackRate(s-r);e.playbackRate!==n&&(this.player.debug.log(this.TAG_NAME,`handleUpdatePlaybackRate and buffered is ${s} and current time is ${r} and delay is ${s-r} set playbackRate is ${n} `),e.playbackRate=n)}_handleUpdateBufferDelayTime(){const e=this.getVideoBufferDelayTime();this.player.updateStats({mseVideoBufferDelayTime:e})}_doAppendSegments(){if(!this.isStateClosed&&!this.isStateEnded){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(it.mediaSourceAudioInitTimeout)}),1e3)));if(fa(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(it.mediaSourceFull)):11===e.code?(this.stop(),this.mediaSourceAppendBufferError=!0,this.player.emitError(it.mediaSourceAppendBufferError)):(this.stop(),this.mediaSourceBufferError=!0,this.player.debug.error(this.TAG_NAME,"appendBuffer error",e),this.player.emitError(Ze.mseSourceBufferError,e))}}if(fa(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(it.mediaSourceFull)):11===e.code?(this.stop(),this.mediaSourceAppendBufferError=!0,this.player.emitError(it.mediaSourceAppendBufferError)):(this.stop(),this.mediaSourceBufferError=!0,this.player.debug.error(this.TAG_NAME,"appendBuffer error",e),this.player.emitError(Ze.mseSourceBufferError,e))}}}}_doCleanUpSourceBuffer(){if(!this.$videoElement)return;const e=this.$videoElement.currentTime;if(this.sourceBuffer){const t=this.sourceBuffer.buffered;let i=!1;for(let s=0;s<t.length;s++){let r=t.start(s),a=t.end(s);if(r<=e&&e<a+3){if(e-r>=this.player._opt.mseAutoCleanupMaxBackwardDuration){i=!0;let t=e-this.player._opt.mseAutoCleanupMinBackwardDuration;this.pendingRemoveRanges.push({start:r,end:t})}}else a<e&&(i=!0,this.pendingRemoveRanges.push({start:r,end:a}))}i&&fa(this.getSourceBufferUpdating())&&this._doRemoveRanges()}if(this.audioSourceBuffer){const t=this.audioSourceBuffer.buffered;let i=!1;for(let s=0;s<t.length;s++){let r=t.start(s),a=t.end(s);if(r<=e&&e<a+3){if(e-r>=this.player._opt.mseAutoCleanupMaxBackwardDuration){i=!0;let t=e-this.player._opt.mseAutoCleanupMinBackwardDuration;this.pendingAudioRemoveRanges.push({start:r,end:t})}}else a<e&&(i=!0,this.pendingAudioRemoveRanges.push({start:r,end:a}))}i&&fa(this.getAudioSourceBufferUpdating())&&this._doRemoveRanges()}}_hasPendingRemoveRanges(){return this.pendingRemoveRanges.length>0||this.pendingAudioRemoveRanges.length>0}_doRemoveRanges(){if(this.sourceBuffer&&fa(this.getSourceBufferUpdating())){let e=this.pendingRemoveRanges;for(;e.length&&fa(this.getSourceBufferUpdating());){let t=e.shift();try{this.sourceBuffer.remove(t.start,t.end)}catch(e){this.player.debug.warn(this.TAG_NAME,"removeBuffer() sourceBuffer error",e)}}}if(this.audioSourceBuffer&&fa(this.getAudioSourceBufferUpdating())){let e=this.pendingAudioRemoveRanges;for(;e.length&&fa(this.getAudioSourceBufferUpdating());){let t=e.shift();try{this.audioSourceBuffer.remove(t.start,t.end)}catch(e){this.player.debug.warn(this.TAG_NAME,"removeBuffer() 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;const s=Math.max(i,1e3),r=s/2;return e*=1e3,1===t.playbackRate?e>s?1.2:1:e<=r?1:t.playbackRate}_needCleanupSourceBuffer(){if(fa(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)}}const vh=()=>"wakeLock"in navigator&&-1===window.navigator.userAgent.indexOf("Samsung")&&fa(vr());class _h{constructor(e){this.player=e,this.enabled=!1,vh()?(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 s=document.createElement("source");s.src=i,s.type=`video/${t}`,e.appendChild(s)}get isEnabled(){return this.enabled}enable(){const e=this.player.debug;if(vh())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(){vh()?(this._wakeLock&&this._wakeLock.release(),this._wakeLock=null):this.noSleepVideo&&this.noSleepVideo.pause(),this.enabled=!1,this.player.debug.log("wakeLock","Disabling wake lock.")}}function wh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Sh,Th,Eh,kh,Ch,xh={exports:{}};Sh=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,Th=/^(?=([^\/?#]*))\1([^]*)$/,Eh=/(?:\/|^)\.(?=\/)/g,kh=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,xh.exports=Ch={buildAbsoluteURL:function(e,t,i){if(i=i||{},e=e.trim(),!(t=t.trim())){if(!i.alwaysNormalize)return e;var s=Ch.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");return s.path=Ch.normalizePath(s.path),Ch.buildURLFromParts(s)}var r=Ch.parseURL(t);if(!r)throw new Error("Error trying to parse relative URL.");if(r.scheme)return i.alwaysNormalize?(r.path=Ch.normalizePath(r.path),Ch.buildURLFromParts(r)):t;var a=Ch.parseURL(e);if(!a)throw new Error("Error trying to parse base URL.");if(!a.netLoc&&a.path&&"/"!==a.path[0]){var o=Th.exec(a.path);a.netLoc=o[1],a.path=o[2]}a.netLoc&&!a.path&&(a.path="/");var n={scheme:a.scheme,netLoc:r.netLoc,path:null,params:r.params,query:r.query,fragment:r.fragment};if(!r.netLoc&&(n.netLoc=a.netLoc,"/"!==r.path[0]))if(r.path){var l=a.path,h=l.substring(0,l.lastIndexOf("/")+1)+r.path;n.path=Ch.normalizePath(h)}else n.path=a.path,r.params||(n.params=a.params,r.query||(n.query=a.query));return null===n.path&&(n.path=i.alwaysNormalize?Ch.normalizePath(r.path):r.path),Ch.buildURLFromParts(n)},parseURL:function(e){var t=Sh.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(Eh,"");e.length!==(e=e.replace(kh,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};var Rh=xh.exports;function Dh(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,s)}return i}function Lh(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Dh(Object(i),!0).forEach((function(t){Ih(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Dh(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function Ih(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var s=i.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Ph(){return Ph=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(e[s]=i[s])}return e},Ph.apply(this,arguments)}const Bh=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)};let Mh=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",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.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}({}),Fh=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}({}),Uh=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}({});const Oh=function(){},Nh={trace:Oh,debug:Oh,log:Oh,warn:Oh,info:Oh,error:Oh};let jh=Nh;function Gh(e,...t){t.forEach((function(t){jh[t]=e[t]?e[t].bind(e):function(e){const t=self.console[e];return t?t.bind(self.console,`[${e}] >`):Oh}(t)}))}const zh=jh,$h=/^(\d+)x(\d+)$/,Wh=/(.+?)=(".*?"|.*?)(?:,|$)/g;class Hh{constructor(e){"string"==typeof e&&(e=Hh.parseAttrList(e));for(const t in e)e.hasOwnProperty(t)&&("X-"===t.substring(0,2)&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(t)),this[t]=e[t])}decimalInteger(e){const t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;const i=new Uint8Array(t.length/2);for(let e=0;e<t.length/2;e++)i[e]=parseInt(t.slice(2*e,2*e+2),16);return i}return null}hexadecimalIntegerAsNumber(e){const t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){const i=this[e];return i?parseFloat(i):t}enumeratedString(e){return this[e]}bool(e){return"YES"===this[e]}decimalResolution(e){const t=$h.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t;const i={};for(Wh.lastIndex=0;null!==(t=Wh.exec(e));){let e=t[2];0===e.indexOf('"')&&e.lastIndexOf('"')===e.length-1&&(e=e.slice(1,-1));i[t[1].trim()]=e}return i}}function Vh(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e}class Jh{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){const i=t.attr;for(const t in i)if(Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==i[t]){zh.warn(`DATERANGE tag attribute: "${t}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=t;break}e=Ph(new Hh({}),i,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const e=new Date(this.attr["END-DATE"]);Bh(e.getTime())&&(this._endDate=e)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;const e=this.duration;return null!==e?new Date(this._startDate.getTime()+1e3*e):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(Bh(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&Bh(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class Kh{constructor(){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}}}var qh="audio",Yh="video",Qh="audiovideo";class Xh{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[qh]:null,[Yh]:null,[Qh]:null},this.baseurl=e}setByteRange(e,t){const i=e.split("@",2),s=[];1===i.length?s[0]=t?t.byteRangeEndOffset:0:s[0]=parseInt(i[1]),s[1]=parseInt(i[0])+s[0],this._byteRange=s}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Rh.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}}class Zh extends Xh{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new Kh,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.type=e}get decryptdata(){const{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{const e=Object.keys(this.levelkeys);if(1===e.length)return this._decryptdata=this.levelkeys[e[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(null===this.programDateTime)return null;if(!Bh(this.programDateTime))return null;const e=Bh(this.duration)?this.duration:0;return this.programDateTime+1e3*e}get encrypted(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){const e=Object.keys(this.levelkeys),t=e.length;if(t>1||1===t&&this.levelkeys[e[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){const t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()}setElementaryStreamInfo(e,t,i,s,r,a=!1){const{elementaryStreams:o}=this,n=o[e];n?(n.startPTS=Math.min(n.startPTS,t),n.endPTS=Math.max(n.endPTS,i),n.startDTS=Math.min(n.startDTS,s),n.endDTS=Math.max(n.endDTS,r)):o[e]={startPTS:t,endPTS:i,startDTS:s,endDTS:r,partial:a}}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[qh]=null,e[Yh]=null,e[Qh]=null}}class ed extends Xh{constructor(e,t,i,s,r){super(i),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new Kh,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=s;const a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,r),r&&(this.fragOffset=r.fragOffset+r.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}class td{constructor(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}reloaded(e){if(!e)return this.advanced=!0,void(this.updated=!0);const 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}get hasProgramDateTime(){return!!this.fragments.length&&Bh(this.fragments[this.fragments.length-1].programDateTime)}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||10}get drift(){const e=this.driftEndTime-this.driftStartTime;if(e>0){return 1e3*(this.driftEnd-this.driftStart)/e}return 1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function id(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0)))}function sd(e){const t=e.split(":");let i=null;if("data"===t[0]&&2===t.length){const e=t[1].split(";"),s=e[e.length-1].split(",");if(2===s.length){const t="base64"===s[0],r=s[1];t?(e.splice(-1,1),i=id(r)):i=function(e){const t=rd(e).subarray(0,16),i=new Uint8Array(16);return i.set(t,16-t.length),i}(r)}}return i}function rd(e){return Uint8Array.from(unescape(encodeURIComponent(e)),(e=>e.charCodeAt(0)))}var ad={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},od="org.w3.clearkey",nd="com.apple.streamingkeydelivery",ld="com.microsoft.playready",hd="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function dd(e){switch(e){case nd:return ad.FAIRPLAY;case ld:return ad.PLAYREADY;case hd:return ad.WIDEVINE;case od:return ad.CLEARKEY}}var cd="edef8ba979d64acea3c827dcd51d21ed";function ud(e){switch(e){case ad.FAIRPLAY:return nd;case ad.PLAYREADY:return ld;case ad.WIDEVINE:return hd;case ad.CLEARKEY:return od}}function pd(e){const{drmSystems:t,widevineLicenseUrl:i}=e,s=t?[ad.FAIRPLAY,ad.WIDEVINE,ad.PLAYREADY,ad.CLEARKEY].filter((e=>!!t[e])):[];return!s[ad.WIDEVINE]&&i&&s.push(ad.WIDEVINE),s}const fd="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function md(e,t,i){return Uint8Array.prototype.slice?e.slice(t,i):new Uint8Array(Array.prototype.slice.call(e,t,i))}const gd=(e,t)=>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,yd=(e,t)=>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,Ad=(e,t)=>{const i=t;let s=0;for(;gd(e,t);){s+=10;s+=bd(e,t+6),yd(e,t+10)&&(s+=10),t+=s}if(s>0)return e.subarray(i,i+s)},bd=(e,t)=>{let 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],i},vd=(e,t)=>gd(e,t)&&bd(e,t+6)+10<=e.length-t,_d=e=>e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info,wd=e=>{const t=String.fromCharCode(e[0],e[1],e[2],e[3]),i=bd(e,4);return{type:t,size:i,data:e.subarray(10,10+i)}},Sd=e=>{let t=0;const i=[];for(;gd(e,t);){const s=bd(e,t+6);t+=10;const r=t+s;for(;t+8<r;){const s=wd(e.subarray(t)),r=Td(s);r&&i.push(r),t+=s.size+10}yd(e,t)&&(t+=10)}return i},Td=e=>"PRIV"===e.type?Ed(e):"W"===e.type[0]?Cd(e):kd(e),Ed=e=>{if(e.size<2)return;const t=Rd(e.data,!0),i=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:i.buffer}},kd=e=>{if(e.size<2)return;if("TXXX"===e.type){let t=1;const i=Rd(e.data.subarray(t),!0);t+=i.length+1;const s=Rd(e.data.subarray(t));return{key:e.type,info:i,data:s}}const t=Rd(e.data.subarray(1));return{key:e.type,data:t}},Cd=e=>{if("WXXX"===e.type){if(e.size<2)return;let t=1;const i=Rd(e.data.subarray(t),!0);t+=i.length+1;const s=Rd(e.data.subarray(t));return{key:e.type,info:i,data:s}}const t=Rd(e.data);return{key:e.type,data:t}},xd=e=>{if(8===e.data.byteLength){const t=new Uint8Array(e.data),i=1&t[3];let s=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return s/=45,i&&(s+=47721858.84),Math.round(s)}},Rd=(e,t=!1)=>{const i=Ld();if(i){const s=i.decode(e);if(t){const e=s.indexOf("\0");return-1!==e?s.substring(0,e):s}return s.replace(/\0/g,"")}const s=e.length;let r,a,o,n="",l=0;for(;l<s;){if(r=e[l++],0===r&&t)return n;if(0!==r&&3!==r)switch(r>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:n+=String.fromCharCode(r);break;case 12:case 13:a=e[l++],n+=String.fromCharCode((31&r)<<6|63&a);break;case 14:a=e[l++],o=e[l++],n+=String.fromCharCode((15&r)<<12|(63&a)<<6|(63&o)<<0)}}return n};let Dd;function Ld(){return Dd||void 0===self.TextDecoder||(Dd=new self.TextDecoder("utf-8")),Dd}const Id=function(e){let t="";for(let i=0;i<e.length;i++){let s=e[i].toString(16);s.length<2&&(s="0"+s),t+=s}return t},Pd=Math.pow(2,32)-1,Bd=[].push,Md={video:1,audio:2,id3:3,text:4};function Fd(e){return String.fromCharCode.apply(null,e)}function Ud(e,t){const i=e[t]<<8|e[t+1];return i<0?65536+i:i}function Od(e,t){const i=Nd(e,t);return i<0?4294967296+i:i}function Nd(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function jd(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 Gd(e,t){const i=[];if(!t.length)return i;const s=e.byteLength;for(let r=0;r<s;){const a=Od(e,r),o=a>1?r+a:s;if(Fd(e.subarray(r+4,r+8))===t[0])if(1===t.length)i.push(e.subarray(r+8,o));else{const s=Gd(e.subarray(r+8,o),t.slice(1));s.length&&Bd.apply(i,s)}r=o}return i}function zd(e){const t=[],i=e[0];let s=8;const r=Od(e,s);s+=4;s+=0===i?8:16,s+=2;let a=e.length+0;const o=Ud(e,s);s+=2;for(let i=0;i<o;i++){let i=s;const o=Od(e,i);i+=4;const n=2147483647&o;if(1===(2147483648&o)>>>31)return zh.warn("SIDX has hierarchical references (not supported)"),null;const l=Od(e,i);i+=4,t.push({referenceSize:n,subsegmentDuration:l,info:{duration:l/r,start:a,end:a+n-1}}),a+=n,i+=4,s=i}return{earliestPresentationTime:0,timescale:r,version:i,referencesCount:o,references:t}}function $d(e){const t=[],i=Gd(e,["moov","trak"]);for(let e=0;e<i.length;e++){const s=i[e],r=Gd(s,["tkhd"])[0];if(r){let e=r[0],i=0===e?12:20;const a=Od(r,i),o=Gd(s,["mdia","mdhd"])[0];if(o){e=o[0],i=0===e?12:20;const r=Od(o,i),n=Gd(s,["mdia","hdlr"])[0];if(n){const e=Fd(n.subarray(8,12)),i={soun:qh,vide:Yh}[e];if(i){const e=Gd(s,["mdia","minf","stbl","stsd"])[0];let o;e&&(o=Fd(e.subarray(12,16))),t[a]={timescale:r,type:i},t[i]={timescale:r,id:a,codec:o}}}}}}return Gd(e,["moov","mvex","trex"]).forEach((e=>{const i=Od(e,4),s=t[i];s&&(s.default={duration:Od(e,12),flags:Od(e,20)})})),t}function Wd(e){const t=Gd(e,["schm"])[0];if(t){const i=Fd(t.subarray(4,8));if("cbcs"===i||"cenc"===i)return Gd(e,["schi","tenc"])[0]}return zh.error("[eme] missing 'schm' box"),null}function Hd(e){const t=Od(e,0);let i=8;1&t&&(i+=4),4&t&&(i+=4);let s=0;const r=Od(e,4);for(let a=0;a<r;a++){if(256&t){s+=Od(e,i),i+=4}512&t&&(i+=4),1024&t&&(i+=4),2048&t&&(i+=4)}return s}function Vd(e,t){const i=new Uint8Array(e.length+t.length);return i.set(e),i.set(t,e.length),i}function Jd(e,t){const i=[],s=t.samples,r=t.timescale,a=t.id;let o=!1;return Gd(s,["moof"]).map((n=>{const l=n.byteOffset-8;Gd(n,["traf"]).map((n=>{const h=Gd(n,["tfdt"]).map((e=>{const t=e[0];let i=Od(e,4);return 1===t&&(i*=Math.pow(2,32),i+=Od(e,8)),i/r}))[0];return void 0!==h&&(e=h),Gd(n,["tfhd"]).map((h=>{const d=Od(h,4),c=16777215&Od(h,0);let u=0;const p=0!=(16&c);let f=0;const m=0!=(32&c);let g=8;d===a&&(0!=(1&c)&&(g+=8),0!=(2&c)&&(g+=4),0!=(8&c)&&(u=Od(h,g),g+=4),p&&(f=Od(h,g),g+=4),m&&(g+=4),"video"===t.type&&(o=function(e){if(!e)return!1;const t=e.indexOf("."),i=t<0?e:e.substring(0,t);return"hvc1"===i||"hev1"===i||"dvh1"===i||"dvhe"===i}(t.codec)),Gd(n,["trun"]).map((a=>{const n=a[0],h=16777215&Od(a,0),d=0!=(1&h);let c=0;const p=0!=(4&h),m=0!=(256&h);let g=0;const y=0!=(512&h);let A=0;const b=0!=(1024&h),v=0!=(2048&h);let _=0;const w=Od(a,4);let S=8;d&&(c=Od(a,S),S+=4),p&&(S+=4);let T=c+l;for(let l=0;l<w;l++){if(m?(g=Od(a,S),S+=4):g=u,y?(A=Od(a,S),S+=4):A=f,b&&(S+=4),v&&(_=0===n?Od(a,S):Nd(a,S),S+=4),t.type===Yh){let t=0;for(;t<A;){const a=Od(s,T);if(T+=4,Kd(o,s[T])){qd(s.subarray(T,T+a),o?2:1,e+_/r,i)}T+=a,t+=a+4}}e+=g/r}})))}))}))})),i}function Kd(e,t){if(e){const e=t>>1&63;return 39===e||40===e}return 6===(31&t)}function qd(e,t,i,s){const r=Yd(e);let a=0;a+=t;let o=0,n=0,l=!1,h=0;for(;a<r.length;){o=0;do{if(a>=r.length)break;h=r[a++],o+=h}while(255===h);n=0;do{if(a>=r.length)break;h=r[a++],n+=h}while(255===h);const e=r.length-a;if(!l&&4===o&&a<r.length){l=!0;if(181===r[a++]){const e=Ud(r,a);if(a+=2,49===e){const e=Od(r,a);if(a+=4,1195456820===e){const e=r[a++];if(3===e){const t=r[a++],n=31&t,l=64&t,h=l?2+3*n:0,d=new Uint8Array(h);if(l){d[0]=t;for(let e=1;e<h;e++)d[e]=r[a++]}s.push({type:e,payloadType:o,pts:i,bytes:d})}}}}}else if(5===o&&n<e){if(l=!0,n>16){const e=[];for(let t=0;t<16;t++){const i=r[a++].toString(16);e.push(1==i.length?"0"+i:i),3!==t&&5!==t&&7!==t&&9!==t||e.push("-")}const t=n-16,l=new Uint8Array(t);for(let e=0;e<t;e++)l[e]=r[a++];s.push({payloadType:o,pts:i,uuid:e.join(""),userData:Rd(l),userDataBytes:l})}}else if(n<e)a+=n;else if(n>e)break}}function Yd(e){const t=e.byteLength,i=[];let s=1;for(;s<t-2;)0===e[s]&&0===e[s+1]&&3===e[s+2]?(i.push(s+2),s+=2):s++;if(0===i.length)return e;const r=t-i.length,a=new Uint8Array(r);let o=0;for(s=0;s<r;o++,s++)o===i[0]&&(o++,i.shift()),a[s]=e[o];return a}function Qd(e,t,i){if(16!==e.byteLength)throw new RangeError("Invalid system id");let s,r,a;if(t){s=1,r=new Uint8Array(16*t.length);for(let e=0;e<t.length;e++){const i=t[e];if(16!==i.byteLength)throw new RangeError("Invalid key");r.set(i,16*e)}}else s=0,r=new Uint8Array;s>0?(a=new Uint8Array(4),t.length>0&&new DataView(a.buffer).setUint32(0,t.length,!1)):a=new Uint8Array;const o=new Uint8Array(4);return i&&i.byteLength>0&&new DataView(o.buffer).setUint32(0,i.byteLength,!1),function(e,...t){const i=t.length;let s=8,r=i;for(;r--;)s+=t[r].byteLength;const a=new Uint8Array(s);for(a[0]=s>>24&255,a[1]=s>>16&255,a[2]=s>>8&255,a[3]=255&s,a.set(e,4),r=0,s=8;r<i;r++)a.set(t[r],s),s+=t[r].byteLength;return a}([112,115,115,104],new Uint8Array([s,0,0,0]),e,a,r,o,i||new Uint8Array)}let Xd={};class Zd{static clearKeyUriToKeyIdMap(){Xd={}}constructor(e,t,i,s=[1],r=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=s,this.iv=r,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&"AES-128"!==e}isSupported(){if(this.method){if("AES-128"===this.method||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case nd:case hd:case ld:case od:return-1!==["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if("AES-128"===this.method&&this.uri&&!this.iv){"number"!=typeof e&&("AES-128"!==this.method||this.iv||zh.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);const t=function(e){const t=new Uint8Array(16);for(let i=12;i<16;i++)t[i]=e>>8*(15-i)&255;return t}(e);return new Zd(this.method,this.uri,"identity",this.keyFormatVersions,t)}const t=sd(this.uri);if(t)switch(this.keyFormat){case hd:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case ld:{const e=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Qd(e,null,t);const i=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),s=String.fromCharCode.apply(null,Array.from(i)),r=s.substring(s.indexOf("<"),s.length),a=(new DOMParser).parseFromString(r,"text/xml").getElementsByTagName("KID")[0];if(a){const e=a.childNodes[0]?a.childNodes[0].nodeValue:a.getAttribute("VALUE");if(e){const t=id(e).subarray(0,16);!function(e){const t=function(e,t,i){const s=e[t];e[t]=e[i],e[i]=s};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}(t),this.keyId=t}}break}default:{let e=t.subarray(0,16);if(16!==e.length){const t=new Uint8Array(16);t.set(e,16-e.length),e=t}this.keyId=e;break}}if(!this.keyId||16!==this.keyId.byteLength){let e=Xd[this.uri];if(!e){const t=Object.keys(Xd).length%Number.MAX_SAFE_INTEGER;e=new Uint8Array(16);new DataView(e.buffer,12,4).setUint32(0,t),Xd[this.uri]=e}this.keyId=e}return this}}const ec=/\{\$([a-zA-Z0-9-_]+)\}/g;function tc(e){return ec.test(e)}function ic(e,t,i){if(null!==e.variableList||e.hasVariableRefs)for(let s=i.length;s--;){const r=i[s],a=t[r];a&&(t[r]=sc(e,a))}}function sc(e,t){if(null!==e.variableList||e.hasVariableRefs){const i=e.variableList;return t.replace(ec,(t=>{const s=t.substring(2,t.length-1),r=null==i?void 0:i[s];return void 0===r?(e.playlistParsingError||(e.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),t):r}))}return t}function rc(e,t,i){let s,r,a=e.variableList;if(a||(e.variableList=a={}),"QUERYPARAM"in t){s=t.QUERYPARAM;try{const e=new self.URL(i).searchParams;if(!e.has(s))throw new Error(`"${s}" does not match any query parameter in URI: "${i}"`);r=e.get(s)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${t.message}`))}}else s=t.NAME,r=t.VALUE;s in a?e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):a[s]=r||""}function ac(e,t,i){const s=t.IMPORT;if(i&&s in i){let t=e.variableList;t||(e.variableList=t={}),t[s]=i[s]}else e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${s}"`))}function oc(){if("undefined"!=typeof self)return self.MediaSource||self.WebKitMediaSource}const nc={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}},lc=oc();function hc(e,t){var i;return null!=(i=null==lc?void 0:lc.isTypeSupported(`${t||"video"}/mp4;codecs="${e}"`))&&i}const dc=/#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,cc=/#EXT-X-MEDIA:(.*)/g,uc=/^#EXT(?:INF|-X-TARGETDURATION):/m,pc=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),fc=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)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class mc{static findGroup(e,t){for(let i=0;i<e.length;i++){const s=e[i];if(s.id===t)return s}}static convertAVC1ToAVCOTI(e){const t=e.split(".");if(t.length>2){let e=t.shift()+".";return e+=parseInt(t.shift()).toString(16),e+=("000"+parseInt(t.shift()).toString(16)).slice(-4),e}return e}static resolve(e,t){return Rh.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return uc.test(e)}static parseMasterPlaylist(e,t){const i={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:tc(e)},s=[];let r;for(dc.lastIndex=0;null!=(r=dc.exec(e));)if(r[1]){var a;const e=new Hh(r[1]);ic(i,e,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const o=sc(i,r[2]),n={attrs:e,bitrate:e.decimalInteger("AVERAGE-BANDWIDTH")||e.decimalInteger("BANDWIDTH"),name:e.NAME,url:mc.resolve(o,t)},l=e.decimalResolution("RESOLUTION");l&&(n.width=l.width,n.height=l.height),Ac((e.CODECS||"").split(/[ ,]+/).filter((e=>e)),n),n.videoCodec&&-1!==n.videoCodec.indexOf("avc1")&&(n.videoCodec=mc.convertAVC1ToAVCOTI(n.videoCodec)),null!=(a=n.unknownCodecs)&&a.length||s.push(n),i.levels.push(n)}else if(r[3]){const e=r[3],s=r[4];switch(e){case"SESSION-DATA":{const e=new Hh(s);ic(i,e,["DATA-ID","LANGUAGE","VALUE","URI"]);const t=e["DATA-ID"];t&&(null===i.sessionData&&(i.sessionData={}),i.sessionData[t]=e);break}case"SESSION-KEY":{const e=gc(s,t,i);e.encrypted&&e.isSupported()?(null===i.sessionKeys&&(i.sessionKeys=[]),i.sessionKeys.push(e)):zh.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${s}"`);break}case"DEFINE":{const e=new Hh(s);ic(i,e,["NAME","VALUE","QUERYPARAM"]),rc(i,e,t)}break;case"CONTENT-STEERING":{const e=new Hh(s);ic(i,e,["SERVER-URI","PATHWAY-ID"]),i.contentSteering={uri:mc.resolve(e["SERVER-URI"],t),pathwayId:e["PATHWAY-ID"]||"."};break}case"START":i.startTimeOffset=yc(s)}}const o=s.length>0&&s.length<i.levels.length;return i.levels=o?s:i.levels,0===i.levels.length&&(i.playlistParsingError=new Error("no levels found in manifest")),i}static parseMasterPlaylistMedia(e,t,i){let s;const r={},a=i.levels,o={AUDIO:a.map((e=>({id:e.attrs.AUDIO,audioCodec:e.audioCodec}))),SUBTITLES:a.map((e=>({id:e.attrs.SUBTITLES,textCodec:e.textCodec}))),"CLOSED-CAPTIONS":[]};let n=0;for(cc.lastIndex=0;null!==(s=cc.exec(e));){const e=new Hh(s[1]),a=e.TYPE;if(a){const s=o[a],l=r[a]||[];r[a]=l,ic(i,e,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const h={attrs:e,bitrate:0,id:n++,groupId:e["GROUP-ID"]||"",instreamId:e["INSTREAM-ID"],name:e.NAME||e.LANGUAGE||"",type:a,default:e.bool("DEFAULT"),autoselect:e.bool("AUTOSELECT"),forced:e.bool("FORCED"),lang:e.LANGUAGE,url:e.URI?mc.resolve(e.URI,t):""};if(null!=s&&s.length){const e=mc.findGroup(s,h.groupId)||s[0];bc(h,e,"audioCodec"),bc(h,e,"textCodec")}l.push(h)}}return r}static parseLevelPlaylist(e,t,i,s,r,a){const o=new td(t),n=o.fragments;let l,h,d,c=null,u=0,p=0,f=0,m=0,g=null,y=new Zh(s,t),A=-1,b=!1;for(pc.lastIndex=0,o.m3u8=e,o.hasVariableRefs=tc(e);null!==(l=pc.exec(e));){b&&(b=!1,y=new Zh(s,t),y.start=f,y.sn=u,y.cc=m,y.level=i,c&&(y.initSegment=c,y.rawProgramDateTime=c.rawProgramDateTime,c.rawProgramDateTime=null));const e=l[1];if(e){y.duration=parseFloat(e);const t=(" "+l[2]).slice(1);y.title=t||null,y.tagList.push(t?["INF",e,t]:["INF",e])}else if(l[3]){if(Bh(y.duration)){y.start=f,d&&wc(y,d,o),y.sn=u,y.level=i,y.cc=m,y.urlId=r,n.push(y);const e=(" "+l[3]).slice(1);y.relurl=sc(o,e),vc(y,g),g=y,f+=y.duration,u++,p=0,b=!0}}else if(l[4]){const e=(" "+l[4]).slice(1);g?y.setByteRange(e,g):y.setByteRange(e)}else if(l[5])y.rawProgramDateTime=(" "+l[5]).slice(1),y.tagList.push(["PROGRAM-DATE-TIME",y.rawProgramDateTime]),-1===A&&(A=n.length);else{if(l=l[0].match(fc),!l){zh.warn("No matches on slow regex match for level playlist!");continue}for(h=1;h<l.length&&void 0===l[h];h++);const e=(" "+l[h]).slice(1),r=(" "+l[h+1]).slice(1),f=l[h+2]?(" "+l[h+2]).slice(1):"";switch(e){case"PLAYLIST-TYPE":o.type=r.toUpperCase();break;case"MEDIA-SEQUENCE":u=o.startSN=parseInt(r);break;case"SKIP":{const e=new Hh(r);ic(o,e,["RECENTLY-REMOVED-DATERANGES"]);const t=e.decimalInteger("SKIPPED-SEGMENTS");if(Bh(t)){o.skippedSegments=t;for(let e=t;e--;)n.unshift(null);u+=t}const i=e.enumeratedString("RECENTLY-REMOVED-DATERANGES");i&&(o.recentlyRemovedDateranges=i.split("\t"));break}case"TARGETDURATION":o.targetduration=Math.max(parseInt(r),1);break;case"VERSION":o.version=parseInt(r);break;case"EXTM3U":break;case"ENDLIST":o.live=!1;break;case"#":(r||f)&&y.tagList.push(f?[r,f]:[r]);break;case"DISCONTINUITY":m++,y.tagList.push(["DIS"]);break;case"GAP":y.gap=!0,y.tagList.push([e]);break;case"BITRATE":y.tagList.push([e,r]);break;case"DATERANGE":{const e=new Hh(r);ic(o,e,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),ic(o,e,e.clientAttrs);const t=new Jh(e,o.dateRanges[e.ID]);t.isValid||o.skippedSegments?o.dateRanges[t.id]=t:zh.warn(`Ignoring invalid DATERANGE tag: "${r}"`),y.tagList.push(["EXT-X-DATERANGE",r]);break}case"DEFINE":{const e=new Hh(r);ic(o,e,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in e?ac(o,e,a):rc(o,e,t)}break;case"DISCONTINUITY-SEQUENCE":m=parseInt(r);break;case"KEY":{const e=gc(r,t,o);if(e.isSupported()){if("NONE"===e.method){d=void 0;break}d||(d={}),d[e.keyFormat]&&(d=Ph({},d)),d[e.keyFormat]=e}else zh.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${r}"`);break}case"START":o.startTimeOffset=yc(r);break;case"MAP":{const e=new Hh(r);if(ic(o,e,["BYTERANGE","URI"]),y.duration){const r=new Zh(s,t);_c(r,e,i,d),c=r,y.initSegment=c,c.rawProgramDateTime&&!y.rawProgramDateTime&&(y.rawProgramDateTime=c.rawProgramDateTime)}else _c(y,e,i,d),c=y,b=!0;break}case"SERVER-CONTROL":{const e=new Hh(r);o.canBlockReload=e.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=e.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=o.canSkipUntil>0&&e.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=e.optionalFloat("PART-HOLD-BACK",0),o.holdBack=e.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const e=new Hh(r);o.partTarget=e.decimalFloatingPoint("PART-TARGET");break}case"PART":{let e=o.partList;e||(e=o.partList=[]);const i=p>0?e[e.length-1]:void 0,s=p++,a=new Hh(r);ic(o,a,["BYTERANGE","URI"]);const n=new ed(a,y,t,s,i);e.push(n),y.duration+=n.duration;break}case"PRELOAD-HINT":{const e=new Hh(r);ic(o,e,["URI"]),o.preloadHint=e;break}case"RENDITION-REPORT":{const e=new Hh(r);ic(o,e,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(e);break}default:zh.warn(`line parsed but not handled: ${l}`)}}}g&&!g.relurl?(n.pop(),f-=g.duration,o.partList&&(o.fragmentHint=g)):o.partList&&(vc(y,g),y.cc=m,o.fragmentHint=y,d&&wc(y,d,o));const v=n.length,_=n[0],w=n[v-1];if(f+=o.skippedSegments*o.targetduration,f>0&&v&&w){o.averagetargetduration=f/v;const e=w.sn;o.endSN="initSegment"!==e?e:0,o.live||(w.endList=!0),_&&(o.startCC=_.cc)}else o.endSN=0,o.startCC=0;return o.fragmentHint&&(f+=o.fragmentHint.duration),o.totalduration=f,o.endCC=m,A>0&&function(e,t){let i=e[t];for(let s=t;s--;){const t=e[s];if(!t)return;t.programDateTime=i.programDateTime-1e3*t.duration,i=t}}(n,A),o}}function gc(e,t,i){var s,r;const a=new Hh(e);ic(i,a,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const o=null!=(s=a.METHOD)?s:"",n=a.URI,l=a.hexadecimalInteger("IV"),h=a.KEYFORMATVERSIONS,d=null!=(r=a.KEYFORMAT)?r:"identity";n&&a.IV&&!l&&zh.error(`Invalid IV: ${a.IV}`);const c=n?mc.resolve(n,t):"",u=(h||"1").split("/").map(Number).filter(Number.isFinite);return new Zd(o,c,d,u,l)}function yc(e){const t=new Hh(e).decimalFloatingPoint("TIME-OFFSET");return Bh(t)?t:null}function Ac(e,t){["video","audio","text"].forEach((i=>{const s=e.filter((e=>function(e,t){const i=nc[t];return!!i&&!0===i[e.slice(0,4)]}(e,i)));if(s.length){const r=s.filter((e=>0===e.lastIndexOf("avc1",0)||0===e.lastIndexOf("mp4a",0)));t[`${i}Codec`]=r.length>0?r[0]:s[0],e=e.filter((e=>-1===s.indexOf(e)))}})),t.unknownCodecs=e}function bc(e,t,i){const s=t[i];s&&(e[i]=s)}function vc(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),Bh(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}function _c(e,t,i,s){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=i,e.sn="initSegment",s&&(e.levelkeys=s),e.initSegment=null}function wc(e,t,i){e.levelkeys=t;const{encryptedFragments:s}=i;s.length&&s[s.length-1].levelkeys===t||!Object.keys(t).some((e=>t[e].isCommonEncryption))||s.push(e)}var Sc="manifest",Tc="level",Ec="audioTrack",kc="subtitleTrack",Cc="main",xc="audio",Rc="subtitle";function Dc(e){const{type:t}=e;switch(t){case Ec:return xc;case kc:return Rc;default:return Cc}}function Lc(e,t){let i=e.url;return void 0!==i&&0!==i.indexOf("data:")||(i=t.url),i}class Ic{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(Mh.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Mh.LEVEL_LOADING,this.onLevelLoading,this),e.on(Mh.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(Mh.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:e}=this;e.off(Mh.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Mh.LEVEL_LOADING,this.onLevelLoading,this),e.off(Mh.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(Mh.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){const t=this.hls.config,i=t.pLoader,s=t.loader,r=new(i||s)(t);return this.loaders[e.type]=r,r}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){const{url:i}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Sc,url:i,deliveryDirectives:null})}onLevelLoading(e,t){const{id:i,level:s,url:r,deliveryDirectives:a}=t;this.load({id:i,level:s,responseType:"text",type:Tc,url:r,deliveryDirectives:a})}onAudioTrackLoading(e,t){const{id:i,groupId:s,url:r,deliveryDirectives:a}=t;this.load({id:i,groupId:s,level:null,responseType:"text",type:Ec,url:r,deliveryDirectives:a})}onSubtitleTrackLoading(e,t){const{id:i,groupId:s,url:r,deliveryDirectives:a}=t;this.load({id:i,groupId:s,level:null,responseType:"text",type:kc,url:r,deliveryDirectives:a})}load(e){var t;const i=this.hls.config;let s,r=this.getInternalLoader(e);if(r){const t=r.context;if(t&&t.url===e.url)return void zh.trace("[playlist-loader]: playlist request ongoing");zh.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),r.abort()}if(s=e.type===Sc?i.manifestLoadPolicy.default:Ph({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(e),null!=(t=e.deliveryDirectives)&&t.part){let t;if(e.type===Tc&&null!==e.level?t=this.hls.levels[e.level].details:e.type===Ec&&null!==e.id?t=this.hls.audioTracks[e.id].details:e.type===kc&&null!==e.id&&(t=this.hls.subtitleTracks[e.id].details),t){const e=t.partTarget,i=t.targetduration;if(e&&i){const t=1e3*Math.max(3*e,.8*i);s=Ph({},s,{maxTimeToFirstByteMs:Math.min(t,s.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(t,s.maxTimeToFirstByteMs)})}}}const a=s.errorRetry||s.timeoutRetry||{},o={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},n={onSuccess:(e,t,i,s)=>{const r=this.getInternalLoader(i);this.resetInternalLoader(i.type);const a=e.data;0===a.indexOf("#EXTM3U")?(t.parsing.start=performance.now(),mc.isMediaPlaylist(a)?this.handleTrackOrLevelPlaylist(e,t,i,s||null,r):this.handleMasterPlaylist(e,t,i,s)):this.handleManifestParsingError(e,i,new Error("no EXTM3U delimiter"),s||null,t)},onError:(e,t,i,s)=>{this.handleNetworkError(t,i,!1,e,s)},onTimeout:(e,t,i)=>{this.handleNetworkError(t,i,!0,void 0,e)}};r.load(e,o,n)}handleMasterPlaylist(e,t,i,s){const r=this.hls,a=e.data,o=Lc(e,i),n=mc.parseMasterPlaylist(a,o);if(n.playlistParsingError)return void this.handleManifestParsingError(e,i,n.playlistParsingError,s,t);const{contentSteering:l,levels:h,sessionData:d,sessionKeys:c,startTimeOffset:u,variableList:p}=n;this.variableList=p;const{AUDIO:f=[],SUBTITLES:m,"CLOSED-CAPTIONS":g}=mc.parseMasterPlaylistMedia(a,o,n);if(f.length){f.some((e=>!e.url))||!h[0].audioCodec||h[0].attrs.AUDIO||(zh.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),f.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Hh({}),bitrate:0,url:""}))}r.trigger(Mh.MANIFEST_LOADED,{levels:h,audioTracks:f,subtitles:m,captions:g,contentSteering:l,url:o,stats:t,networkDetails:s,sessionData:d,sessionKeys:c,startTimeOffset:u,variableList:p})}handleTrackOrLevelPlaylist(e,t,i,s,r){const a=this.hls,{id:o,level:n,type:l}=i,h=Lc(e,i),d=Bh(o)?o:0,c=Bh(n)?n:d,u=Dc(i),p=mc.parseLevelPlaylist(e.data,h,c,u,d,this.variableList);if(l===Sc){const e={attrs:new Hh({}),bitrate:0,details:p,name:"",url:h};a.trigger(Mh.MANIFEST_LOADED,{levels:[e],audioTracks:[],url:h,stats:t,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),i.levelDetails=p,this.handlePlaylistLoaded(p,e,t,i,s,r)}handleManifestParsingError(e,t,i,s,r){this.hls.trigger(Mh.ERROR,{type:Fh.NETWORK_ERROR,details:Uh.MANIFEST_PARSING_ERROR,fatal:t.type===Sc,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:s,stats:r})}handleNetworkError(e,t,i=!1,s,r){let a=`A network ${i?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${e.type}`;e.type===Tc?a+=`: ${e.level} id: ${e.id}`:e.type!==Ec&&e.type!==kc||(a+=` id: ${e.id} group-id: "${e.groupId}"`);const o=new Error(a);zh.warn(`[playlist-loader]: ${a}`);let n=Uh.UNKNOWN,l=!1;const h=this.getInternalLoader(e);switch(e.type){case Sc:n=i?Uh.MANIFEST_LOAD_TIMEOUT:Uh.MANIFEST_LOAD_ERROR,l=!0;break;case Tc:n=i?Uh.LEVEL_LOAD_TIMEOUT:Uh.LEVEL_LOAD_ERROR,l=!1;break;case Ec:n=i?Uh.AUDIO_TRACK_LOAD_TIMEOUT:Uh.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case kc:n=i?Uh.SUBTITLE_TRACK_LOAD_TIMEOUT:Uh.SUBTITLE_LOAD_ERROR,l=!1}h&&this.resetInternalLoader(e.type);const d={type:Fh.NETWORK_ERROR,details:n,fatal:l,url:e.url,loader:h,context:e,error:o,networkDetails:t,stats:r};if(s){const i=(null==t?void 0:t.url)||e.url;d.response=Lh({url:i,data:void 0},s)}this.hls.trigger(Mh.ERROR,d)}handlePlaylistLoaded(e,t,i,s,r,a){const o=this.hls,{type:n,level:l,id:h,groupId:d,deliveryDirectives:c}=s,u=Lc(t,s),p=Dc(s),f="number"==typeof s.level&&p===Cc?l:void 0;if(!e.fragments.length){const e=new Error("No Segments found in Playlist");return void o.trigger(Mh.ERROR,{type:Fh.NETWORK_ERROR,details:Uh.LEVEL_EMPTY_ERROR,fatal:!1,url:u,error:e,reason:e.message,response:t,context:s,level:f,parent:p,networkDetails:r,stats:i})}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));const m=e.playlistParsingError;if(m)o.trigger(Mh.ERROR,{type:Fh.NETWORK_ERROR,details:Uh.LEVEL_PARSING_ERROR,fatal:!1,url:u,error:m,reason:m.message,response:t,context:s,level:f,parent:p,networkDetails:r,stats:i});else switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),a.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),n){case Sc:case Tc:o.trigger(Mh.LEVEL_LOADED,{details:e,level:f||0,id:h||0,stats:i,networkDetails:r,deliveryDirectives:c});break;case Ec:o.trigger(Mh.AUDIO_TRACK_LOADED,{details:e,id:h||0,groupId:d||"",stats:i,networkDetails:r,deliveryDirectives:c});break;case kc:o.trigger(Mh.SUBTITLE_TRACK_LOADED,{details:e,id:h||0,groupId:d||"",stats:i,networkDetails:r,deliveryDirectives:c})}}}function Pc(e,t){let i;try{i=new Event("addtrack")}catch(e){i=document.createEvent("Event"),i.initEvent("addtrack",!1,!1)}i.track=e,t.dispatchEvent(i)}function Bc(e,t){const 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){zh.debug(`[texttrack-utils]: ${i}`);try{const i=new self.TextTrackCue(t.startTime,t.endTime,t.text);i.id=t.id,e.addCue(i)}catch(e){zh.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${e}`)}}"disabled"===i&&(e.mode=i)}function Mc(e){const t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues)for(let t=e.cues.length;t--;)e.removeCue(e.cues[t]);"disabled"===t&&(e.mode=t)}function Fc(e,t,i,s){const r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues&&e.cues.length>0){const r=function(e,t,i){const s=[],r=function(e,t){if(t<e[0].startTime)return 0;const i=e.length-1;if(t>e[i].endTime)return-1;let s=0,r=i;for(;s<=r;){const a=Math.floor((r+s)/2);if(t<e[a].startTime)r=a-1;else{if(!(t>e[a].startTime&&s<i))return a;s=a+1}}return e[s].startTime-t<t-e[r].startTime?s:r}(e,t);if(r>-1)for(let a=r,o=e.length;a<o;a++){const r=e[a];if(r.startTime>=t&&r.endTime<=i)s.push(r);else if(r.startTime>i)return s}return s}(e.cues,t,i);for(let t=0;t<r.length;t++)s&&!s(r[t])||e.removeCue(r[t])}"disabled"===r&&(e.mode=r)}var Uc="org.id3",Oc="com.apple.quicktime.HLS",Nc="https://aomedia.org/emsg/ID3";function jc(){if("undefined"!=typeof self)return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}const Gc=(()=>{const e=jc();try{new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function zc(e,t){return e.getTime()/1e3-t}class $c{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:e}=this;e.on(Mh.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Mh.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Mh.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Mh.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(Mh.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Mh.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:e}=this;e.off(Mh.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Mh.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Mh.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Mh.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(Mh.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Mh.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(Mc(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){const i=e[t];if("metadata"===i.kind&&"id3"===i.label)return Pc(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:i,enableID3MetadataCues:s}}}=this;if(!i&&!s)return;const{samples:r}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const a=jc();for(let e=0;e<r.length;e++){const t=r[e].type;if(t===Nc&&!i||!s)continue;const o=Sd(r[e].data);if(o){const i=r[e].pts;let s=i+r[e].duration;s>Gc&&(s=Gc);s-i<=0&&(s=i+.25);for(let e=0;e<o.length;e++){const r=o[e];if(!_d(r)){this.updateId3CueEnds(i,t);const e=new a(i,s,"");e.value=r,t&&(e.type=t),this.id3Track.addCue(e)}}}}}updateId3CueEnds(e,t){var i;const s=null==(i=this.id3Track)?void 0:i.cues;if(s)for(let i=s.length;i--;){const r=s[i];r.type===t&&r.startTime<e&&r.endTime===Gc&&(r.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:i,type:s}){const{id3Track:r,hls:a}=this;if(!a)return;const{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:n}}=a;if(r&&(o||n)){let e;e="audio"===s?e=>e.type===Uc&&n:"video"===s?e=>e.type===Nc&&o:e=>e.type===Uc&&n||e.type===Nc&&o,Fc(r,t,i,e)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:i,id3Track:s}=this,{dateRanges:r}=t,a=Object.keys(r);if(s){const e=Object.keys(i).filter((e=>!a.includes(e)));for(let t=e.length;t--;){const r=e[t];Object.keys(i[r].cues).forEach((e=>{s.removeCue(i[r].cues[e])})),delete i[r]}}const o=t.fragments[t.fragments.length-1];if(0===a.length||!Bh(null==o?void 0:o.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const n=o.programDateTime/1e3-o.start,l=jc();for(let e=0;e<a.length;e++){const t=a[e],s=r[t],o=i[t],c=(null==o?void 0:o.cues)||{};let u=(null==o?void 0:o.durationKnown)||!1;const p=zc(s.startDate,n);let f=Gc;const m=s.endDate;if(m)f=zc(m,n),u=!0;else if(s.endOnNext&&!u){const e=a.reduce(((e,t)=>{const i=r[t];return i.class===s.class&&i.id!==t&&i.startDate>s.startDate&&e.push(i),e}),[]).sort(((e,t)=>e.startDate.getTime()-t.startDate.getTime()))[0];e&&(f=zc(e.startDate,n),u=!0)}const g=Object.keys(s.attr);for(let e=0;e<g.length;e++){const i=g[e];if("ID"===(d=i)||"CLASS"===d||"START-DATE"===d||"DURATION"===d||"END-DATE"===d||"END-ON-NEXT"===d)continue;let r=c[i];if(r)u&&!o.durationKnown&&(r.endTime=f);else{let e=s.attr[i];r=new l(p,f,""),Vh(i)&&(h=e,e=Uint8Array.from(h.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),r.value={key:i,data:e},r.type=Oc,r.id=t,this.id3Track.addCue(r),c[i]=r}}i[t]={cues:c,dateRange:s,durationKnown:u}}var h,d}}class Wc{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:e,levelDetails:t}=this;return void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const{levelDetails:e}=this;if(null===e)return null;const{holdBack:t,partHoldBack:i,targetduration:s}=e,{liveSyncDuration:r,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,n=this.hls.userConfig;let l=o&&i||t;(n.liveSyncDuration||n.liveSyncDurationCount||0===l)&&(l=void 0!==r?r:a*s);const h=s;return l+Math.min(1*this.stallCount,h)}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency,i=this.levelDetails;if(null===e||null===t||null===i)return null;const s=i.edge,r=e-t-this.edgeStalled,a=s-i.totalduration,o=s-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(a,r),o)}get drift(){const{levelDetails:e}=this;return null===e?1:e.drift}get edgeStalled(){const{levelDetails:e}=this;if(null===e)return 0;const t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e,levelDetails:t}=this;if(!e||!t)return 0;const i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(Mh.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(Mh.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(Mh.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(Mh.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(Mh.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(Mh.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(Mh.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(Mh.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(Mh.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(Mh.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var i;t.details===Uh.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(i=this.levelDetails)&&i.live&&zh.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;const i=this.computeLatency();if(null===i)return;this._latency=i;const{lowLatencyMode:s,maxLiveSyncPlaybackRate:r}=this.config;if(!s||1===r)return;const a=this.targetLatency;if(null===a)return;const o=i-a,n=o<Math.min(this.maxLatency,a+t.targetduration);if(t.live&&n&&o>.05&&this.forwardBufferLength>1){const t=Math.min(2,Math.max(1,r)),i=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(t,Math.max(1,i))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}estimateLiveEdge(){const{levelDetails:e}=this;return null===e?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return null===e?null:e-this.currentTime}}const Hc=["NONE","TYPE-0","TYPE-1",null];var Vc="",Jc="YES",Kc="v2";class qc{constructor(e,t,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=i}addDirectives(e){const 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}}class Yc{constructor(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=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.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.unknownCodecs=e.unknownCodecs,this.codecSet=[e.videoCodec,e.audioCodec].filter((e=>e)).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(e){const t=e%this.url.length;this._urlId!==t&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=t)}get audioGroupId(){var e;return null==(e=this.audioGroupIds)?void 0:e[this.urlId]}get textGroupId(){var e;return null==(e=this.textGroupIds)?void 0:e[this.urlId]}addFallback(e){this.url.push(e.url),this._attrs.push(e.attrs)}}function Qc(e,t){const i=t.startPTS;if(Bh(i)){let s,r=0;t.sn>e.sn?(r=i-e.start,s=e):(r=e.start-i,s=t),s.duration!==r&&(s.duration=r)}else if(t.sn>e.sn){e.cc===t.cc&&e.minEndPTS?t.start=e.start+(e.minEndPTS-e.start):t.start=e.start+e.duration}else t.start=Math.max(e.start-t.duration,0)}function Xc(e,t,i,s,r,a){s-i<=0&&(zh.warn("Fragment should have a positive duration",t),s=i+t.duration,a=r+t.duration);let o=i,n=s;const l=t.startPTS,h=t.endPTS;if(Bh(l)){const e=Math.abs(l-i);Bh(t.deltaPTS)?t.deltaPTS=Math.max(e,t.deltaPTS):t.deltaPTS=e,o=Math.max(i,l),i=Math.min(i,l),r=Math.min(r,t.startDTS),n=Math.min(s,h),s=Math.max(s,h),a=Math.max(a,t.endDTS)}const d=i-t.start;0!==t.start&&(t.start=i),t.duration=s-t.start,t.startPTS=i,t.maxStartPTS=o,t.startDTS=r,t.endPTS=s,t.minEndPTS=n,t.endDTS=a;const c=t.sn;if(!e||c<e.startSN||c>e.endSN)return 0;let u;const p=c-e.startSN,f=e.fragments;for(f[p]=t,u=p;u>0;u--)Qc(f[u],f[u-1]);for(u=p;u<f.length-1;u++)Qc(f[u],f[u+1]);return e.fragmentHint&&Qc(f[f.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,d}function Zc(e,t){let i=null;const s=e.fragments;for(let e=s.length-1;e>=0;e--){const t=s[e].initSegment;if(t){i=t;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;let r,a=0;if(function(e,t,i){const s=t.skippedSegments,r=Math.max(e.startSN,t.startSN)-t.startSN,a=(e.fragmentHint?1:0)+(s?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,o=t.startSN-e.startSN,n=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments;for(let e=r;e<=a;e++){const r=l[o+e];let a=n[e];s&&!a&&e<s&&(a=t.fragments[e]=r),r&&a&&i(r,a)}}(e,t,((e,s)=>{e.relurl&&(a=e.cc-s.cc),Bh(e.startPTS)&&Bh(e.endPTS)&&(s.start=s.startPTS=e.startPTS,s.startDTS=e.startDTS,s.maxStartPTS=e.maxStartPTS,s.endPTS=e.endPTS,s.endDTS=e.endDTS,s.minEndPTS=e.minEndPTS,s.duration=e.endPTS-e.startPTS,s.duration&&(r=s),t.PTSKnown=t.alignedSliding=!0),s.elementaryStreams=e.elementaryStreams,s.loader=e.loader,s.stats=e.stats,s.urlId=e.urlId,e.initSegment&&(s.initSegment=e.initSegment,i=e.initSegment)})),i){(t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments).forEach((e=>{var t;e.initSegment&&e.initSegment.relurl!==(null==(t=i)?void 0:t.relurl)||(e.initSegment=i)}))}if(t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some((e=>!e)),t.deltaUpdateFailed){zh.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let e=t.skippedSegments;e--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=function(e,t,i){const s=Ph({},e);i&&i.forEach((e=>{delete s[e]}));return Object.keys(t).forEach((e=>{const i=new Jh(t[e].attr,s[e]);i.isValid?s[e]=i:zh.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(t[e].attr)}"`)})),s}(e.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));const o=t.fragments;if(a){zh.warn("discontinuity sliding from playlist, take drift into account");for(let e=0;e<o.length;e++)o[e].cc+=a}t.skippedSegments&&(t.startCC=t.fragments[0].cc),function(e,t,i){if(e&&t){let s=0;for(let r=0,a=e.length;r<=a;r++){const a=e[r],o=t[r+s];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?i(a,o):s--}}}(e.partList,t.partList,((e,t)=>{t.elementaryStreams=e.elementaryStreams,t.stats=e.stats})),r?Xc(t,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS):eu(e,t),o.length&&(t.totalduration=t.edge-o[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;const n=t.advancedDateTime;if(t.advanced&&n){const e=t.edge;t.driftStart||(t.driftStartTime=n,t.driftStart=e),t.driftEndTime=n,t.driftEnd=e}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime}function eu(e,t){const i=t.startSN+t.skippedSegments-e.startSN,s=e.fragments;i<0||i>=s.length||tu(t,s[i].start)}function tu(e,t){if(t){const i=e.fragments;for(let s=e.skippedSegments;s<i.length;s++)i[s].start+=t;e.fragmentHint&&(e.fragmentHint.start+=t)}}function iu(e,t,i){var s;return null!=e&&e.details?su(null==(s=e.details)?void 0:s.partList,t,i):null}function su(e,t,i){if(e)for(let s=e.length;s--;){const r=e[s];if(r.index===i&&r.fragment.sn===t)return r}return null}function ru(e){switch(e.details){case Uh.FRAG_LOAD_TIMEOUT:case Uh.KEY_LOAD_TIMEOUT:case Uh.LEVEL_LOAD_TIMEOUT:case Uh.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function au(e,t){const i=ru(t);return e.default[(i?"timeout":"error")+"Retry"]}function ou(e,t){const i="linear"===e.backoff?1:Math.pow(2,t);return Math.min(i*e.retryDelayMs,e.maxRetryDelayMs)}function nu(e){return Lh(Lh({},e),{errorRetry:null,timeoutRetry:null})}function lu(e,t,i,s){return!!e&&t<e.maxNumRetry&&(function(e){return 0===e&&!1===navigator.onLine||!!e&&(e<400||e>499)}(s)||!!i)}const hu=function(e,t){let i=0,s=e.length-1,r=null,a=null;for(;i<=s;){r=(i+s)/2|0,a=e[r];const o=t(a);if(o>0)i=r+1;else{if(!(o<0))return a;s=r-1}}return null};function du(e,t,i=0,s=0){let r=null;if(e?r=t[e.sn-t[0].sn+1]||null:0===i&&0===t[0].start&&(r=t[0]),r&&0===cu(i,s,r))return r;const a=hu(t,cu.bind(null,i,s));return!a||a===e&&r?r:a}function cu(e=0,t=0,i){if(i.start<=e&&i.start+i.duration>e)return 0;const s=Math.min(t,i.duration+(i.deltaPTS?i.deltaPTS:0));return i.start+i.duration-s<=e?1:i.start-s>e&&i.start?-1:0}function uu(e,t,i){const s=1e3*Math.min(t,i.duration+(i.deltaPTS?i.deltaPTS:0));return(i.endProgramDateTime||0)-s>e}var pu=0,fu=2,mu=5,gu=0,yu=1,Au=2;function bu(e,t,i){if(performance.now()-e.lastErrorPerfMs>3e5)return!0;const s=e.details;if(t.details===Uh.FRAG_GAP&&s&&t.frag){const e=t.frag.start,i=du(null,s.fragments,e);if(i&&!i.gap)return!0}if(i&&e.errors.length<i.errors.length){const i=e.errors[e.errors.length-1];if(s&&i.frag&&t.frag&&Math.abs(i.frag.start-t.frag.start)>3*s.targetduration)return!0}return!1}class vu{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=zh.log.bind(zh,`${t}:`),this.warn=zh.warn.bind(zh,`${t}:`),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t){const i=null==t?void 0:t.renditionReports;if(i){let s=-1;for(let r=0;r<i.length;r++){const a=i[r];let o;try{o=new self.URL(a.URI,t.url).href}catch(e){zh.warn(`Could not construct new URL for Rendition Report: ${e}`),o=a.URI||""}if(o===e){s=r;break}o===e.substring(0,o.length)&&(s=r)}if(-1!==s){const e=i[s],r=parseInt(e["LAST-MSN"])||(null==t?void 0:t.lastPartSn);let a=parseInt(e["LAST-PART"])||(null==t?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){const e=Math.min(t.age-t.partTarget,t.targetduration);a>=0&&e>t.partTarget&&(a+=1)}return new qc(r,a>=0?a:void 0,Vc)}}}loadPlaylist(e){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,i){const{details:s,stats:r}=t,a=self.performance.now(),o=r.loading.first?Math.max(0,a-r.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&&Zc(i,s),!this.canLoad||!s.live)return;let o,n,l;if(s.canBlockReload&&s.endSN&&s.advanced){const e=this.hls.config.lowLatencyMode,r=s.lastPartSn,a=s.endSN,h=s.lastPartIndex,d=r===a,c=e?0:h;-1!==h?(n=d?a+1:r,l=d?c:h+1):n=a+1;const u=s.age,p=u+s.ageHeader;let f=Math.min(p-s.partTarget,1.5*s.targetduration);if(f>0){if(i&&f>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${f} with playlist age: ${s.age}`),f=0;else{const e=Math.floor(f/s.targetduration);if(n+=e,void 0!==l){l+=Math.round(f%s.targetduration/s.partTarget)}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${u.toFixed(2)}s goal: ${f} skip sn ${e} to part ${l}`)}s.tuneInGoal=f}if(o=this.getDeliveryDirectives(s,t.deliveryDirectives,n,l),e||!d)return void this.loadPlaylist(o)}else(s.canBlockReload||s.canSkipUntil)&&(o=this.getDeliveryDirectives(s,t.deliveryDirectives,n,l));const h=this.hls.mainForwardBufferInfo,d=h?h.end-h.len:0,c=function(e,t=1/0){let i=1e3*e.targetduration;if(e.updated){const s=e.fragments,r=4;if(s.length&&i*r>t){const e=1e3*s[s.length-1].duration;e<i&&(i=e)}}else i/=2;return Math.round(i)}(s,1e3*(s.edge-d));s.updated&&a>this.requestScheduled+c&&(this.requestScheduled=r.loading.start),void 0!==n&&s.canBlockReload?this.requestScheduled=r.loading.first+c-(1e3*s.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+c<a?this.requestScheduled=a:this.requestScheduled-a<=0&&(this.requestScheduled+=c);let u=this.requestScheduled-a;u=Math.max(0,u),this.log(`reload live playlist ${e} in ${Math.round(u)} ms`),this.timer=self.setTimeout((()=>this.loadPlaylist(o)),u)}else this.clearTimer()}getDeliveryDirectives(e,t,i,s){let r=function(e,t){const{canSkipUntil:i,canSkipDateRanges:s,endSN:r}=e;return i&&(void 0!==t?t-r:0)<i?s?Kc:Jc:Vc}(e,i);return null!=t&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,s=t.part,r=Vc),new qc(i,s,r)}checkRetry(e){const t=e.details,i=ru(e),s=e.errorAction,{action:r,retryCount:a=0,retryConfig:o}=s||{},n=!!s&&!!o&&(r===mu||!s.resolved&&r===fu);if(n){var l;if(this.requestScheduled=-1,a>=o.maxNumRetry)return!1;if(i&&null!=(l=e.context)&&l.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const e=ou(o,a);this.timer=self.setTimeout((()=>this.loadPlaylist()),e),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" in ${e}ms`)}e.levelRetry=!0,s.resolved=!0}return n}}let _u;class wu extends vu{constructor(e,t){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(Mh.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Mh.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Mh.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Mh.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Mh.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(Mh.FRAG_LOADED,this.onFragLoaded,this),e.on(Mh.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(Mh.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Mh.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Mh.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Mh.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Mh.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(Mh.FRAG_LOADED,this.onFragLoaded,this),e.off(Mh.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}startLoad(){this._levels.forEach((e=>{e.loadError=0,e.fragmentError=0})),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const i=[],s={};let r;t.levels.forEach((e=>{var t;const a=e.attrs;-1!==(null==(t=e.audioCodec)?void 0:t.indexOf("mp4a.40.34"))&&(_u||(_u=/chrome|firefox/i.test(navigator.userAgent)),_u&&(e.audioCodec=void 0));const{AUDIO:o,CODECS:n,"FRAME-RATE":l,"PATHWAY-ID":h,RESOLUTION:d,SUBTITLES:c}=a,u=`${`${h||"."}-`}${e.bitrate}-${d}-${l}-${n}`;r=s[u],r?r.addFallback(e):(r=new Yc(e),s[u]=r,i.push(r)),Su(r,"audio",o),Su(r,"text",c)})),this.filterAndSortMediaOptions(i,t)}filterAndSortMediaOptions(e,t){let i=[],s=[],r=!1,a=!1,o=!1,n=e.filter((({audioCodec:e,videoCodec:t,width:i,height:s,unknownCodecs:n})=>(r||(r=!(!i||!s)),a||(a=!!t),o||(o=!!e),!(null!=n&&n.length)&&(!e||hc(e,"audio"))&&(!t||hc(t,"video")))));if((r||a)&&o&&(n=n.filter((({videoCodec:e,width:t,height:i})=>!!e||!(!t||!i)))),0===n.length)return void Promise.resolve().then((()=>{if(this.hls){const e=new Error("no level with compatible codecs found in manifest");this.hls.trigger(Mh.ERROR,{type:Fh.MEDIA_ERROR,details:Uh.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:e,reason:e.message})}}));t.audioTracks&&(i=t.audioTracks.filter((e=>!e.audioCodec||hc(e.audioCodec,"audio"))),Tu(i)),t.subtitles&&(s=t.subtitles,Tu(s));const l=n.slice(0);n.sort(((e,t)=>e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"]?(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1:e.bitrate!==t.bitrate?e.bitrate-t.bitrate:e.attrs["FRAME-RATE"]!==t.attrs["FRAME-RATE"]?e.attrs.decimalFloatingPoint("FRAME-RATE")-t.attrs.decimalFloatingPoint("FRAME-RATE"):e.attrs.SCORE!==t.attrs.SCORE?e.attrs.decimalFloatingPoint("SCORE")-t.attrs.decimalFloatingPoint("SCORE"):r&&e.height!==t.height?e.height-t.height:0));let h=l[0];if(this.steering&&(n=this.steering.filterParsedLevels(n),n.length!==l.length))for(let e=0;e<l.length;e++)if(l[e].pathwayId===n[0].pathwayId){h=l[e];break}this._levels=n;for(let e=0;e<n.length;e++)if(n[e]===h){this._firstLevel=e,this.log(`manifest loaded, ${n.length} level(s) found, first bitrate: ${h.bitrate}`);break}const d=o&&!a,c={levels:n,audioTracks:i,subtitleTracks:s,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:o,video:a,altAudio:!d&&i.some((e=>!!e.url))};this.hls.trigger(Mh.MANIFEST_PARSED,c),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return 0===this._levels.length?null:this._levels}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(0===t.length)return;if(e<0||e>=t.length){const i=new Error("invalid level idx"),s=e<0;if(this.hls.trigger(Mh.ERROR,{type:Fh.OTHER_ERROR,details:Uh.LEVEL_SWITCH_ERROR,level:e,fatal:s,error:i,reason:i.message}),s)return;e=Math.min(e,t.length-1)}const i=this.currentLevelIndex,s=this.currentLevel,r=s?s.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,i===e&&a.details&&s&&r===o)return;this.log(`Switching to level ${e}${o?" with Pathway "+o:""} from level ${i}${r?" with Pathway "+r:""}`);const n=Ph({},a,{level:e,maxBitrate:a.maxBitrate,attrs:a.attrs,uri:a.uri,urlId:a.urlId});delete n._attrs,delete n._urlId,this.hls.trigger(Mh.LEVEL_SWITCHING,n);const l=a.details;if(!l||l.live){const e=this.switchParams(a.uri,null==s?void 0:s.details);this.loadPlaylist(e)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(void 0===this._startLevel){const e=this.hls.config.startLevel;return void 0!==e?e:this._firstLevel}return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){!t.fatal&&t.context&&t.context.type===Tc&&t.context.level===this.level&&this.checkRetry(t)}onFragLoaded(e,{frag:t}){if(void 0!==t&&t.type===Cc){const e=this._levels[t.level];void 0!==e&&(e.loadError=0)}}onLevelLoaded(e,t){var i;const{level:s,details:r}=t,a=this._levels[s];var o;if(!a)return this.warn(`Invalid level index ${s}`),void(null!=(o=t.deliveryDirectives)&&o.skip&&(r.deltaUpdateFailed=!0));s===this.currentLevelIndex?(0===a.fragmentError&&(a.loadError=0),this.playlistLoaded(s,t,a.details)):null!=(i=t.deliveryDirectives)&&i.skip&&(r.deltaUpdateFailed=!0)}onAudioTrackSwitched(e,t){const i=this.currentLevel;if(!i)return;const s=this.hls.audioTracks[t.id].groupId;if(i.audioGroupIds&&i.audioGroupId!==s){let e=-1;for(let t=0;t<i.audioGroupIds.length;t++)if(i.audioGroupIds[t]===s){e=t;break}-1!==e&&e!==i.urlId&&(i.urlId=e,this.canLoad&&this.startLoad())}}loadPlaylist(e){super.loadPlaylist();const t=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){const s=i.urlId;let r=i.uri;if(e)try{r=e.addDirectives(r)}catch(e){this.warn(`Could not construct new URL with HLS Delivery Directives: ${e}`)}const a=i.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${void 0!==(null==e?void 0:e.msn)?" at sn "+e.msn+" part "+e.part:""} with${a?" Pathway "+a:""} URI ${s+1}/${i.url.length} ${r}`),this.clearTimer(),this.hls.trigger(Mh.LEVEL_LOADING,{url:r,level:t,id:s,deliveryDirectives:e||null})}}get nextLoadLevel(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}removeLevel(e,t){const i=(e,i)=>i!==t,s=this._levels.filter(((s,r)=>r!==e||(s.url.length>1&&void 0!==t?(s.url=s.url.filter(i),s.audioGroupIds&&(s.audioGroupIds=s.audioGroupIds.filter(i)),s.textGroupIds&&(s.textGroupIds=s.textGroupIds.filter(i)),s.urlId=0,!0):(this.steering&&this.steering.removeLevel(s),!1))));this.hls.trigger(Mh.LEVELS_UPDATED,{levels:s})}onLevelsUpdated(e,{levels:t}){t.forEach(((e,t)=>{const{details:i}=e;null!=i&&i.fragments&&i.fragments.forEach((e=>{e.level=t}))})),this._levels=t}}function Su(e,t,i){i&&("audio"===t?(e.audioGroupIds||(e.audioGroupIds=[]),e.audioGroupIds[e.url.length-1]=i):"text"===t&&(e.textGroupIds||(e.textGroupIds=[]),e.textGroupIds[e.url.length-1]=i))}function Tu(e){const t={};e.forEach((e=>{const i=e.groupId||"";e.id=t[i]=t[i]||0,t[i]++}))}var Eu="NOT_LOADED",ku="APPENDING",Cu="PARTIAL",xu="OK";class Ru{constructor(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()}_registerListeners(){const{hls:e}=this;e.on(Mh.BUFFER_APPENDED,this.onBufferAppended,this),e.on(Mh.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Mh.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:e}=this;e.off(Mh.BUFFER_APPENDED,this.onBufferAppended,this),e.off(Mh.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Mh.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const i=this.activePartLists[t];if(i)for(let t=i.length;t--;){const s=i[t];if(!s)break;const r=s.end;if(s.start<=e&&null!==r&&e<=r)return s}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){const{fragments:i}=this,s=Object.keys(i);for(let r=s.length;r--;){const a=i[s[r]];if((null==a?void 0:a.body.type)===t&&a.buffered){const t=a.body;if(t.start<=e&&e<=t.end)return t}}return null}detectEvictedFragments(e,t,i,s){this.timeRanges&&(this.timeRanges[e]=t);const r=(null==s?void 0:s.fragment.sn)||-1;Object.keys(this.fragments).forEach((s=>{const a=this.fragments[s];if(!a)return;if(r>=a.body.sn)return;if(!a.buffered&&!a.loaded)return void(a.body.type===i&&this.removeFragment(a.body));const o=a.range[e];o&&o.time.some((e=>{const i=!this.isTimeBuffered(e.startPTS,e.endPTS,t);return i&&this.removeFragment(a.body),i}))}))}detectPartialFragments(e){const t=this.timeRanges,{frag:i,part:s}=e;if(!t||"initSegment"===i.sn)return;const r=Lu(i),a=this.fragments[r];if(!a||a.buffered&&i.gap)return;const o=!i.relurl;if(Object.keys(t).forEach((e=>{const r=i.elementaryStreams[e];if(!r)return;const n=t[e],l=o||!0===r.partial;a.range[e]=this.getBufferedTimes(i,s,l,n)})),a.loaded=null,Object.keys(a.range).length){a.buffered=!0;(a.body.endList=i.endList||a.body.endList)&&(this.endListFragments[a.body.type]=a),Du(a)||this.removeParts(i.sn-1,i.type)}else this.removeFragment(a.body)}removeParts(e,t){const i=this.activePartLists[t];i&&(this.activePartLists[t]=i.filter((t=>t.fragment.sn>=e)))}fragBuffered(e,t){const i=Lu(e);let s=this.fragments[i];!s&&t&&(s=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)}getBufferedTimes(e,t,i,s){const r={time:[],partial:i},a=e.start,o=e.end,n=e.minEndPTS||o,l=e.maxStartPTS||a;for(let e=0;e<s.length;e++){const t=s.start(e)-this.bufferPadding,i=s.end(e)+this.bufferPadding;if(l>=t&&n<=i){r.time.push({startPTS:Math.max(a,s.start(e)),endPTS:Math.min(o,s.end(e))});break}if(a<i&&o>t)r.partial=!0,r.time.push({startPTS:Math.max(a,s.start(e)),endPTS:Math.min(o,s.end(e))});else if(o<=t)break}return r}getPartialFragment(e){let t,i,s,r=null,a=0;const{bufferPadding:o,fragments:n}=this;return Object.keys(n).forEach((l=>{const h=n[l];h&&Du(h)&&(i=h.body.start-o,s=h.body.end+o,e>=i&&e<=s&&(t=Math.min(e-i,s-e),a<=t&&(r=h.body,a=t)))})),r}isEndListAppended(e){const t=this.endListFragments[e];return void 0!==t&&(t.buffered||Du(t))}getState(e){const t=Lu(e),i=this.fragments[t];return i?i.buffered?Du(i)?Cu:xu:ku:Eu}isTimeBuffered(e,t,i){let s,r;for(let a=0;a<i.length;a++){if(s=i.start(a)-this.bufferPadding,r=i.end(a)+this.bufferPadding,e>=s&&t<=r)return!0;if(t<=s)return!1}return!1}onFragLoaded(e,t){const{frag:i,part:s}=t;if("initSegment"===i.sn||i.bitrateTest)return;const r=s?null:t,a=Lu(i);this.fragments[a]={body:i,appendedPTS:null,loaded:r,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:i,part:s,timeRanges:r}=t;if("initSegment"===i.sn)return;const a=i.type;if(s){let e=this.activePartLists[a];e||(this.activePartLists[a]=e=[]),e.push(s)}this.timeRanges=r,Object.keys(r).forEach((e=>{const t=r[e];this.detectEvictedFragments(e,t,a,s)}))}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=Lu(e);return!!this.fragments[t]}hasParts(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)}removeFragmentsInRange(e,t,i,s,r){s&&!this.hasGaps||Object.keys(this.fragments).forEach((a=>{const o=this.fragments[a];if(!o)return;const n=o.body;n.type!==i||s&&!n.gap||n.start<t&&n.end>e&&(o.buffered||r)&&this.removeFragment(n)}))}removeFragment(e){const t=Lu(e);e.stats.loaded=0,e.clearElementaryStreamInfo();const i=this.activePartLists[e.type];if(i){const t=e.sn;this.activePartLists[e.type]=i.filter((e=>e.fragment.sn!==t))}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function Du(e){var t,i,s;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==(s=e.range.audiovideo)?void 0:s.partial))}function Lu(e){return`${e.type}_${e.level}_${e.urlId}_${e.sn}`}const Iu=Math.pow(2,17);class Pu{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){const i=e.url;if(!i)return Promise.reject(new Fu({type:Fh.NETWORK_ERROR,details:Uh.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(i?"part list":"url")),networkDetails:null}));this.abort();const s=this.config,r=s.fLoader,a=s.loader;return new Promise(((o,n)=>{if(this.loader&&this.loader.destroy(),e.gap){if(e.tagList.some((e=>"GAP"===e[0])))return void n(Mu(e));e.gap=!1}const l=this.loader=e.loader=r?new r(s):new a(s),h=Bu(e),d=nu(s.fragLoadPolicy.default),c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:Iu};e.stats=l.stats,l.load(h,c,{onSuccess:(t,i,s,r)=>{this.resetLoader(e,l);let a=t.data;s.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(a.slice(0,16)),a=a.slice(16)),o({frag:e,part:null,payload:a,networkDetails:r})},onError:(t,s,r,a)=>{this.resetLoader(e,l),n(new Fu({type:Fh.NETWORK_ERROR,details:Uh.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Lh({url:i,data:void 0},t),error:new Error(`HTTP Error ${t.code} ${t.text}`),networkDetails:r,stats:a}))},onAbort:(t,i,s)=>{this.resetLoader(e,l),n(new Fu({type:Fh.NETWORK_ERROR,details:Uh.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:s,stats:t}))},onTimeout:(t,i,s)=>{this.resetLoader(e,l),n(new Fu({type:Fh.NETWORK_ERROR,details:Uh.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${c.timeout}ms`),networkDetails:s,stats:t}))},onProgress:(i,s,r,a)=>{t&&t({frag:e,part:null,payload:r,networkDetails:a})}})}))}loadPart(e,t,i){this.abort();const s=this.config,r=s.fLoader,a=s.loader;return new Promise(((o,n)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap)return void n(Mu(e,t));const l=this.loader=e.loader=r?new r(s):new a(s),h=Bu(e,t),d=nu(s.fragLoadPolicy.default),c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Iu};t.stats=l.stats,l.load(h,c,{onSuccess:(s,r,a,n)=>{this.resetLoader(e,l),this.updateStatsFromPart(e,t);const h={frag:e,part:t,payload:s.data,networkDetails:n};i(h),o(h)},onError:(i,s,r,a)=>{this.resetLoader(e,l),n(new Fu({type:Fh.NETWORK_ERROR,details:Uh.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:Lh({url:h.url,data:void 0},i),error:new Error(`HTTP Error ${i.code} ${i.text}`),networkDetails:r,stats:a}))},onAbort:(i,s,r)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,l),n(new Fu({type:Fh.NETWORK_ERROR,details:Uh.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:r,stats:i}))},onTimeout:(i,s,r)=>{this.resetLoader(e,l),n(new Fu({type:Fh.NETWORK_ERROR,details:Uh.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${c.timeout}ms`),networkDetails:r,stats:i}))}})}))}updateStatsFromPart(e,t){const i=e.stats,s=t.stats,r=s.total;if(i.loaded+=s.loaded,r){const s=Math.round(e.duration/t.duration),a=Math.min(Math.round(i.loaded/r),s),o=(s-a)*Math.round(i.loaded/a);i.total=i.loaded+o}else i.total=Math.max(i.loaded,i.total);const a=i.loading,o=s.loading;a.start?a.first+=o.first-o.start:(a.start=o.start,a.first=o.first),a.end=o.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function Bu(e,t=null){const i=t||e,s={frag:e,part:t,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},r=i.byteRangeStartOffset,a=i.byteRangeEndOffset;if(Bh(r)&&Bh(a)){var o;let t=r,i=a;if("initSegment"===e.sn&&"AES-128"===(null==(o=e.decryptdata)?void 0:o.method)){const e=a-r;e%16&&(i=a+(16-e%16)),0!==r&&(s.resetIV=!0,t=r-16)}s.rangeStart=t,s.rangeEnd=i}return s}function Mu(e,t){const i=new Error(`GAP ${e.gap?"tag":"attribute"} found`),s={type:Fh.MEDIA_ERROR,details:Uh.FRAG_GAP,fatal:!1,frag:e,error:i,networkDetails:null};return t&&(s.part=t),(t||e).stats.aborted=!0,new Fu(s)}class Fu extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class Uu{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const t in this.keyUriToKeyInfo){const i=this.keyUriToKeyInfo[t].loader;if(i){if(e&&e!==i.context.frag.type)return;i.abort()}}}detach(){for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=Uh.KEY_LOAD_ERROR,i,s,r){return new Fu({type:Fh.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:r,error:i,networkDetails:s})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){const{sn:i,cc:s}=e;for(let e=0;e<t.length;e++){const r=t[e];if(s<=r.cc&&("initSegment"===i||"initSegment"===r.sn||i<r.sn)){this.emeController.selectKeySystemFormat(r).then((e=>{r.setKeyFormat(e)}));break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then((t=>this.loadInternal(e,t))):this.loadInternal(e)}loadInternal(e,t){var i,s;t&&e.setKeyFormat(t);const r=e.decryptdata;if(!r){const i=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,Uh.KEY_LOAD_ERROR,i))}const a=r.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,Uh.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=this.keyUriToKeyInfo[a];if(null!=(i=o)&&i.decryptdata.key)return r.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});var n;if(null!=(s=o)&&s.keyLoadPromise)switch(null==(n=o.mediaKeySessionContext)?void 0:n.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then((t=>(r.key=t.keyInfo.decryptdata.key,{frag:e,keyInfo:o})))}switch(o=this.keyUriToKeyInfo[a]={decryptdata:r,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},r.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===r.keyFormat?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,Uh.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${r.method}"`)))}}loadKeyEME(e,t){const i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){const t=this.emeController.loadKey(i);if(t)return(e.keyLoadPromise=t.then((t=>(e.mediaKeySessionContext=t,i)))).catch((t=>{throw e.keyLoadPromise=null,t}))}return Promise.resolve(i)}loadKeyHTTP(e,t){const i=this.config,s=new(0,i.loader)(i);return t.keyLoader=e.loader=s,e.keyLoadPromise=new Promise(((r,a)=>{const o={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},n=i.keyLoadPolicy.default,l={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:(e,t,i,s)=>{const{frag:o,keyInfo:n,url:l}=i;if(!o.decryptdata||n!==this.keyUriToKeyInfo[l])return a(this.createKeyLoadError(o,Uh.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),s));n.decryptdata.key=o.decryptdata.key=new Uint8Array(e.data),o.keyLoader=null,n.loader=null,r({frag:o,keyInfo:n})},onError:(e,i,s,r)=>{this.resetLoader(i),a(this.createKeyLoadError(t,Uh.KEY_LOAD_ERROR,new Error(`HTTP Error ${e.code} loading key ${e.text}`),s,Lh({url:o.url,data:void 0},e)))},onTimeout:(e,i,s)=>{this.resetLoader(i),a(this.createKeyLoadError(t,Uh.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),s))},onAbort:(e,i,s)=>{this.resetLoader(i),a(this.createKeyLoadError(t,Uh.INTERNAL_ABORTED,new Error("key loading aborted"),s))}};s.load(o,l,h)}))}resetLoader(e){const{frag:t,keyInfo:i,url:s}=e,r=i.loader;t.keyLoader===r&&(t.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[s],r&&r.destroy()}}class Ou{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}clearNextTick(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}tick(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}const Nu={length:0,start:()=>0,end:()=>0};class ju{static isBuffered(e,t){try{if(e){const i=ju.getBuffered(e);for(let e=0;e<i.length;e++)if(t>=i.start(e)&&t<=i.end(e))return!0}}catch(e){}return!1}static bufferInfo(e,t,i){try{if(e){const s=ju.getBuffered(e),r=[];let a;for(a=0;a<s.length;a++)r.push({start:s.start(a),end:s.end(a)});return this.bufferedInfo(r,t,i)}}catch(e){}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,i){t=Math.max(0,t),e.sort((function(e,t){const i=e.start-t.start;return i||t.end-e.end}));let s=[];if(i)for(let t=0;t<e.length;t++){const r=s.length;if(r){const a=s[r-1].end;e[t].start-a<i?e[t].end>a&&(s[r-1].end=e[t].end):s.push(e[t])}else s.push(e[t])}else s=e;let r,a=0,o=t,n=t;for(let e=0;e<s.length;e++){const l=s[e].start,h=s[e].end;if(t+i>=l&&t<h)o=l,n=h,a=n-t;else if(t+i<l){r=l;break}}return{len:a,start:o||0,end:n||0,nextStart:r}}static getBuffered(e){try{return e.buffered}catch(e){return zh.log("failed to get media.buffered",e),Nu}}}class Gu{constructor(e,t,i,s=0,r=-1,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={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=e,this.sn=t,this.id=i,this.size=s,this.part=r,this.partial=a}}function zu(e,t){let i=null;for(let s=0,r=e.length;s<r;s++){const r=e[s];if(r&&r.cc===t){i=r;break}}return i}function $u(e,t){if(e){const i=e.start+t;e.start=e.startPTS=i,e.endPTS=i+e.duration}}function Wu(e,t){const i=t.fragments;for(let t=0,s=i.length;t<s;t++)$u(i[t],e);t.fragmentHint&&$u(t.fragmentHint,e),t.alignedSliding=!0}function Hu(e,t,i){t&&(!function(e,t,i){if(function(e,t,i){return!(!t.details||!(i.endCC>i.startCC||e&&e.cc<i.startCC))}(e,i,t)){const e=function(e,t,i=0){const s=e.fragments,r=t.fragments;if(!r.length||!s.length)return void zh.log("No fragments to align");const a=zu(s,r[0].cc);if(a&&(!a||a.startPTS))return a;zh.log("No frag in previous level to align on")}(i.details,t);e&&Bh(e.start)&&(zh.log(`Adjusting PTS using last level due to CC increase within current level ${t.url}`),Wu(e.start,t))}}(e,i,t),!i.alignedSliding&&t.details&&function(e,t){if(!t.fragments.length||!e.hasProgramDateTime||!t.hasProgramDateTime)return;const i=t.fragments[0].programDateTime,s=e.fragments[0].programDateTime,r=(s-i)/1e3+t.fragments[0].start;r&&Bh(r)&&(zh.log(`Adjusting PTS using programDateTime delta ${s-i}ms, sliding:${r.toFixed(3)} ${e.url} `),Wu(r,e))}(i,t.details),i.alignedSliding||!t.details||i.skippedSegments||eu(t.details,i))}function Vu(e,t){if(!e.hasProgramDateTime||!t.hasProgramDateTime)return;const i=e.fragments,s=t.fragments;if(!i.length||!s.length)return;const r=s[Math.round(s.length/2)-1],a=zu(i,r.cc)||i[Math.round(i.length/2)-1],o=r.programDateTime,n=a.programDateTime;if(null===o||null===n)return;Wu((n-o)/1e3-(a.start-r.start),e)}class Ju{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}}class Ku{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}class qu{constructor(){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()}uint8ArrayToUint32Array_(e){const t=new DataView(e),i=new Uint32Array(4);for(let e=0;e<4;e++)i[e]=t.getUint32(4*e);return i}initTable(){const e=this.sBox,t=this.invSBox,i=this.subMix,s=i[0],r=i[1],a=i[2],o=i[3],n=this.invSubMix,l=n[0],h=n[1],d=n[2],c=n[3],u=new Uint32Array(256);let p=0,f=0,m=0;for(m=0;m<256;m++)u[m]=m<128?m<<1:m<<1^283;for(m=0;m<256;m++){let i=f^f<<1^f<<2^f<<3^f<<4;i=i>>>8^255&i^99,e[p]=i,t[i]=p;const n=u[p],m=u[n],g=u[m];let y=257*u[i]^16843008*i;s[p]=y<<24|y>>>8,r[p]=y<<16|y>>>16,a[p]=y<<8|y>>>24,o[p]=y,y=16843009*g^65537*m^257*n^16843008*p,l[i]=y<<24|y>>>8,h[i]=y<<16|y>>>16,d[i]=y<<8|y>>>24,c[i]=y,p?(p=n^u[u[u[g^n]]],f^=u[u[f]]):p=f=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let i=!0,s=0;for(;s<t.length&&i;)i=t[s]===this.key[s],s++;if(i)return;this.key=t;const r=this.keySize=t.length;if(4!==r&&6!==r&&8!==r)throw new Error("Invalid aes key size="+r);const a=this.ksRows=4*(r+6+1);let o,n;const l=this.keySchedule=new Uint32Array(a),h=this.invKeySchedule=new Uint32Array(a),d=this.sBox,c=this.rcon,u=this.invSubMix,p=u[0],f=u[1],m=u[2],g=u[3];let y,A;for(o=0;o<a;o++)o<r?y=l[o]=t[o]:(A=y,o%r==0?(A=A<<8|A>>>24,A=d[A>>>24]<<24|d[A>>>16&255]<<16|d[A>>>8&255]<<8|d[255&A],A^=c[o/r|0]<<24):r>6&&o%r==4&&(A=d[A>>>24]<<24|d[A>>>16&255]<<16|d[A>>>8&255]<<8|d[255&A]),l[o]=y=(l[o-r]^A)>>>0);for(n=0;n<a;n++)o=a-n,A=3&n?l[o]:l[o-4],h[n]=n<4||o<=4?A:p[d[A>>>24]]^f[d[A>>>16&255]]^m[d[A>>>8&255]]^g[d[255&A]],h[n]=h[n]>>>0}networkToHostOrderSwap(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}decrypt(e,t,i){const s=this.keySize+6,r=this.invKeySchedule,a=this.invSBox,o=this.invSubMix,n=o[0],l=o[1],h=o[2],d=o[3],c=this.uint8ArrayToUint32Array_(i);let u=c[0],p=c[1],f=c[2],m=c[3];const g=new Int32Array(e),y=new Int32Array(g.length);let A,b,v,_,w,S,T,E,k,C,x,R,D,L;const I=this.networkToHostOrderSwap;for(;t<g.length;){for(k=I(g[t]),C=I(g[t+1]),x=I(g[t+2]),R=I(g[t+3]),w=k^r[0],S=R^r[1],T=x^r[2],E=C^r[3],D=4,L=1;L<s;L++)A=n[w>>>24]^l[S>>16&255]^h[T>>8&255]^d[255&E]^r[D],b=n[S>>>24]^l[T>>16&255]^h[E>>8&255]^d[255&w]^r[D+1],v=n[T>>>24]^l[E>>16&255]^h[w>>8&255]^d[255&S]^r[D+2],_=n[E>>>24]^l[w>>16&255]^h[S>>8&255]^d[255&T]^r[D+3],w=A,S=b,T=v,E=_,D+=4;A=a[w>>>24]<<24^a[S>>16&255]<<16^a[T>>8&255]<<8^a[255&E]^r[D],b=a[S>>>24]<<24^a[T>>16&255]<<16^a[E>>8&255]<<8^a[255&w]^r[D+1],v=a[T>>>24]<<24^a[E>>16&255]<<16^a[w>>8&255]<<8^a[255&S]^r[D+2],_=a[E>>>24]<<24^a[w>>16&255]<<16^a[S>>8&255]<<8^a[255&T]^r[D+3],y[t]=I(A^u),y[t+1]=I(_^p),y[t+2]=I(v^f),y[t+3]=I(b^m),u=k,p=C,f=x,m=R,t+=4}return y.buffer}}class Yu{constructor(e,{removePKCS7Padding:t=!0}={}){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.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const e=self.crypto;e&&(this.subtle=e.subtle||e.webkitSubtle)}catch(e){}null===this.subtle&&(this.useSoftware=!0)}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;const i=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?function(e){const t=e.byteLength,i=t&&new DataView(e.buffer).getUint8(t-1);return i?md(e,0,t-i):e}(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,i){return this.useSoftware?new Promise(((s,r)=>{this.softwareDecrypt(new Uint8Array(e),t,i);const a=this.flush();a?s(a.buffer):r(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(e),t,i)}softwareDecrypt(e,t,i){const{currentIV:s,currentResult:r,remainderData:a}=this;this.logOnce("JS AES decrypt"),a&&(e=Vd(a,e),this.remainderData=null);const o=this.getValidChunk(e);if(!o.length)return null;s&&(i=s);let n=this.softwareDecrypter;n||(n=this.softwareDecrypter=new qu),n.expandKey(t);const l=r;return this.currentResult=n.decrypt(o.buffer,0,i),this.currentIV=md(o,-16).buffer,l||null}webCryptoDecrypt(e,t,i){const s=this.subtle;return this.key===t&&this.fastAesKey||(this.key=t,this.fastAesKey=new Ku(s,t)),this.fastAesKey.expandKey().then((t=>{if(!s)return Promise.reject(new Error("web crypto not initialized"));this.logOnce("WebCrypto AES decrypt");return new Ju(s,new Uint8Array(i)).decrypt(e.buffer,t)})).catch((s=>(zh.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${s.name}: ${s.message}`),this.onWebCryptoError(e,t,i))))}onWebCryptoError(e,t,i){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i);const s=this.flush();if(s)return s.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e;const i=e.length-e.length%16;return i!==e.length&&(t=md(e,0,i),this.remainderData=md(e,i)),t}logOnce(e){this.logEnabled&&(zh.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const Qu=function(e){let t="";const i=e.length;for(let s=0;s<i;s++)t+=`[${e.start(s).toFixed(3)}-${e.end(s).toFixed(3)}]`;return t},Xu="STOPPED",Zu="IDLE",ep="KEY_LOADING",tp="FRAG_LOADING",ip="FRAG_LOADING_WAITING_RETRY",sp="WAITING_TRACK",rp="PARSING",ap="PARSED",op="ENDED",np="ERROR",lp="WAITING_INIT_PTS",hp="WAITING_LEVEL";class dp extends Ou{constructor(e,t,i,s,r){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=Xu,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=r,this.logPrefix=s,this.log=zh.log.bind(zh,`${s}:`),this.warn=zh.warn.bind(zh,`${s}:`),this.hls=e,this.fragmentLoader=new Pu(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Yu(e.config),e.on(Mh.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const 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=Xu}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;const i=t.partList;if(null!=i&&i.length){const e=i[i.length-1];return ju.isBuffered(this.media,e.start+e.duration/2)}const s=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(s)}getLevelDetails(){var e;if(this.levels&&null!==this.levelLastLoaded)return null==(e=this.levels[this.levelLastLoaded])?void 0:e.details}onMediaAttached(e,t){const i=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),i.addEventListener("seeking",this.onvseeking),i.addEventListener("ended",this.onvended);const s=this.config;this.levels&&s.autoStartLoad&&this.state===Xu&&this.startLoad(s.startPosition)}onMediaDetaching(){const e=this.media;null!=e&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:e,fragCurrent:t,media:i,mediaBuffer:s,state:r}=this,a=i?i.currentTime:0,o=ju.bufferInfo(s||i,a,e.maxBufferHole);if(this.log(`media seeking to ${Bh(a)?a.toFixed(3):a}, state: ${r}`),this.state===op)this.resetLoadingState();else if(t){const i=e.maxFragLookUpTolerance,s=t.start-i,r=t.start+t.duration+i;if(!o.len||r<o.start||s>o.end){const e=a>r;(a<s||e)&&(e&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}i&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),this.lastCurrentTime=a),this.loadedmetadata||o.len||(this.nextLoadPosition=this.startPosition=a),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.stopLoad(),super.onHandlerDestroying()}onHandlerDestroyed(){this.state=Xu,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,super.onHandlerDestroyed()}loadFragment(e,t,i){this._loadFragForPlayback(e,t,i)}_loadFragForPlayback(e,t,i){this._doFragLoad(e,t,i,(t=>{if(this.fragContextChanged(e))return this.warn(`Fragment ${e.sn}${t.part?" p: "+t.part.index:""} of level ${e.level} was dropped during download.`),void this.fragmentTracker.removeFragment(e);e.stats.chunkCount++,this._handleFragmentLoadProgress(t)})).then((t=>{if(!t)return;const i=this.state;this.fragContextChanged(e)?(i===tp||!this.fragCurrent&&i===rp)&&(this.fragmentTracker.removeFragment(e),this.state=Zu):("payload"in t&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(Mh.FRAG_LOADED,t)),this._handleFragmentLoadComplete(t))})).catch((t=>{this.state!==Xu&&this.state!==np&&(this.warn(t),this.resetFragmentLoading(e))}))}clearTrackerIfNeeded(e){var t;const{fragmentTracker:i}=this;if(i.getState(e)===ku){const t=e.type,s=this.getFwdBufferInfo(this.mediaBuffer,t),r=Math.max(e.duration,s?s.len:this.config.maxBufferLength);this.reduceMaxBufferLength(r)&&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)===Cu&&i.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const 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)}flushMainBuffer(e,t,i=null){if(!(e-t))return;const s={startOffset:e,endOffset:t,type:i};this.hls.trigger(Mh.BUFFER_FLUSHING,s)}_loadInitSegment(e,t){this._doFragLoad(e,t).then((t=>{if(!t||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return t})).then((t=>{const{hls:i}=this,{payload:s}=t,r=e.decryptdata;if(s&&s.byteLength>0&&r&&r.key&&r.iv&&"AES-128"===r.method){const a=self.performance.now();return this.decrypter.decrypt(new Uint8Array(s),r.key.buffer,r.iv.buffer).catch((t=>{throw i.trigger(Mh.ERROR,{type:Fh.MEDIA_ERROR,details:Uh.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:e}),t})).then((s=>{const r=self.performance.now();return i.trigger(Mh.FRAG_DECRYPTED,{frag:e,payload:s,stats:{tstart:a,tdecrypt:r}}),t.payload=s,t}))}return t})).then((i=>{const{fragCurrent:s,hls:r,levels:a}=this;if(!a)throw new Error("init load aborted, missing levels");const o=e.stats;this.state=Zu,t.fragmentError=0,e.data=new Uint8Array(i.payload),o.parsing.start=o.buffering.start=self.performance.now(),o.parsing.end=o.buffering.end=self.performance.now(),i.frag===s&&r.trigger(Mh.FRAG_BUFFERED,{stats:o,frag:s,part:null,id:e.type}),this.tick()})).catch((t=>{this.state!==Xu&&this.state!==np&&(this.warn(t),this.resetFragmentLoading(e))}))}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.level!==t.level||e.sn!==t.sn||e.urlId!==t.urlId}fragBufferedComplete(e,t){var i,s,r,a;const o=this.mediaBuffer?this.mediaBuffer:this.media;this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===Cc?"level":"track"} ${e.level} (frag:[${(null!=(i=e.startPTS)?i:NaN).toFixed(3)}-${(null!=(s=e.endPTS)?s:NaN).toFixed(3)}] > buffer:${o?Qu(ju.getBuffered(o)):"(detached)"})`),this.state=Zu,o&&(!this.loadedmetadata&&e.type==Cc&&o.buffered.length&&(null==(r=this.fragCurrent)?void 0:r.sn)===(null==(a=this.fragPrevious)?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:i,part:s,partsLoaded:r}=e,a=!r||0===r.length||r.some((e=>!e)),o=new Gu(i.level,i.sn,i.stats.chunkCount+1,0,s?s.index:-1,!a);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,i=null,s){var r;const a=null==t?void 0:t.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(!e.encrypted||null!=(r=e.decryptdata)&&r.key?!e.encrypted&&a.encryptedFragments.length&&this.keyLoader.loadClear(e,a.encryptedFragments):(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${"[stream-controller]"===this.logPrefix?"level":"track"} ${e.level}`),this.state=ep,this.fragCurrent=e,o=this.keyLoader.load(e).then((e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger(Mh.KEY_LOADED,e),this.state===ep&&(this.state=Zu),e})),this.hls.trigger(Mh.KEY_LOADING,{frag:e}),null===this.fragCurrent&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),i=Math.max(e.start,i||0),this.config.lowLatencyMode&&"initSegment"!==e.sn){const r=a.partList;if(r&&s){i>e.end&&a.fragmentHint&&(e=a.fragmentHint);const n=this.getNextPart(r,e,i);if(n>-1){const l=r[n];let h;return this.log(`Loading part sn: ${e.sn} p: ${l.index} cc: ${e.cc} of playlist [${a.startSN}-${a.endSN}] parts [0-${n}-${r.length-1}] ${"[stream-controller]"===this.logPrefix?"level":"track"}: ${e.level}, target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=l.start+l.duration,this.state=tp,h=o?o.then((i=>!i||this.fragContextChanged(i.frag)?null:this.doFragPartsLoad(e,l,t,s))).catch((e=>this.handleFragLoadError(e))):this.doFragPartsLoad(e,l,t,s).catch((e=>this.handleFragLoadError(e))),this.hls.trigger(Mh.FRAG_LOADING,{frag:e,part:l,targetBufferTime:i}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):h}if(!e.url||this.loadedEndOfParts(r,i))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${a?"of ["+a.startSN+"-"+a.endSN+"] ":""}${"[stream-controller]"===this.logPrefix?"level":"track"}: ${e.level}, target: ${parseFloat(i.toFixed(3))}`),Bh(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=tp;const n=this.config.progressive;let l;return l=n&&o?o.then((t=>!t||this.fragContextChanged(null==t?void 0:t.frag)?null:this.fragmentLoader.load(e,s))).catch((e=>this.handleFragLoadError(e))):Promise.all([this.fragmentLoader.load(e,n?s:void 0),o]).then((([e])=>(!n&&e&&s&&s(e),e))).catch((e=>this.handleFragLoadError(e))),this.hls.trigger(Mh.FRAG_LOADING,{frag:e,targetBufferTime:i}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):l}doFragPartsLoad(e,t,i,s){return new Promise(((r,a)=>{var o;const n=[],l=null==(o=i.details)?void 0:o.partList,h=t=>{this.fragmentLoader.loadPart(e,t,s).then((s=>{n[t.index]=s;const a=s.part;this.hls.trigger(Mh.FRAG_LOADED,s);const o=iu(i,e.sn,t.index+1)||su(l,e.sn,t.index+1);if(!o)return r({frag:e,part:a,partsLoaded:n});h(o)})).catch(a)};h(t)}))}handleFragLoadError(e){if("data"in e){const t=e.data;e.data&&t.details===Uh.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(Mh.ERROR,t)}else this.hls.trigger(Mh.ERROR,{type:Fh.OTHER_ERROR,details:Uh.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==rp)return void(this.fragCurrent||this.state===Xu||this.state===np||(this.state=Zu));const{frag:i,part:s,level:r}=t,a=self.performance.now();i.stats.parsing.end=a,s&&(s.stats.parsing.end=a),this.updateLevelTiming(i,s,r,e.partial)}getCurrentContext(e){const{levels:t,fragCurrent:i}=this,{level:s,sn:r,part:a}=e;if(null==t||!t[s])return this.warn(`Levels object was unset while buffering fragment ${r} of level ${s}. The current chunk will not be buffered.`),null;const o=t[s],n=a>-1?iu(o,r,a):null,l=n?n.fragment:function(e,t,i){if(null==e||!e.details)return null;const s=e.details;let r=s.fragments[t-s.startSN];return r||(r=s.fragmentHint,r&&r.sn===t?r:t<s.startSN&&i&&i.sn===t?i:null)}(o,r,i);return l?(i&&i!==l&&(l.stats=i.stats),{frag:l,part:n,level:o}):null}bufferFragmentData(e,t,i,s,r){var a;if(!e||this.state!==rp)return;const{data1:o,data2:n}=e;let l=o;if(o&&n&&(l=Vd(o,n)),null==(a=l)||!a.length)return;const h={type:e.type,frag:t,part:i,chunkMeta:s,parent:t.type,data:l};if(this.hls.trigger(Mh.BUFFER_APPENDING,h),e.dropped&&e.independent&&!i){if(r)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!ju.isBuffered(t,t.currentTime))return void this.flushMainBuffer(0,e.start);const i=t.currentTime,s=ju.bufferInfo(t,i,0),r=e.duration,a=Math.min(2*this.config.maxFragLookUpTolerance,.25*r),o=Math.max(Math.min(e.start-a,s.end-a),i+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){const i=this.getLoadPosition();return Bh(i)?this.getFwdBufferInfoAtPos(e,i,t):null}getFwdBufferInfoAtPos(e,t,i){const{config:{maxBufferHole:s}}=this,r=ju.bufferInfo(e,t,s);if(0===r.len&&void 0!==r.nextStart){const a=this.fragmentTracker.getBufferedFrag(t,i);if(a&&r.nextStart<a.end)return ju.bufferInfo(e,t,Math.max(r.nextStart,s))}return r}getMaxBufferLength(e){const{config:t}=this;let i;return i=e?Math.max(8*t.maxBufferSize/e,t.maxBufferLength):t.maxBufferLength,Math.min(i,t.maxMaxBufferLength)}reduceMaxBufferLength(e){const 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)}getAppendedFrag(e,t=Cc){const i=this.fragmentTracker.getAppendedFrag(e,Cc);return i&&"fragment"in i?i.fragment:i}getNextFragment(e,t){const i=t.fragments,s=i.length;if(!s)return null;const{config:r}=this,a=i[0].start;let o;if(t.live){const a=r.initialLiveManifestSize;if(s<a)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${a})`),null;t.PTSKnown||this.startFragRequested||-1!==this.startPosition||(o=this.getInitialLiveFragment(t,i),this.startPosition=o?this.hls.liveSyncPosition||o.start:e)}else e<=a&&(o=i[0]);if(!o){const i=r.lowLatencyMode?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,i,t)}return this.mapToInitFragWhenRequired(o)}isLoopLoading(e,t){const i=this.fragmentTracker.getState(e);return(i===xu||i===Cu&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,i,s,r){const a=e.gap,o=this.getNextFragment(this.nextLoadPosition,t);if(null===o)return o;if(e=o,a&&e&&!e.gap&&i.nextStart){const t=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,s);if(null!==t&&i.len+t.len>=r)return this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment}getNextPart(e,t,i){let s=-1,r=!1,a=!0;for(let o=0,n=e.length;o<n;o++){const n=e[o];if(a=a&&!n.independent,s>-1&&i<n.start)break;const l=n.loaded;l?s=-1:(r||n.independent||a)&&n.fragment===t&&(s=o),r=l}return s}loadedEndOfParts(e,t){const i=e[e.length-1];return i&&t>i.start&&i.loaded}getInitialLiveFragment(e,t){const i=this.fragPrevious;let s=null;if(i){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),s=function(e,t,i){if(null===t||!Array.isArray(e)||!e.length||!Bh(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(let s=0;s<e.length;++s){const r=e[s];if(uu(t,i,r))return r}return null}(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){const r=i.sn+1;if(r>=e.startSN&&r<=e.endSN){const a=t[r-e.startSN];i.cc===a.cc&&(s=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=function(e,t){return hu(e,(e=>e.cc<t?1:e.cc>t?-1:0))}(t,i.cc),s&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`))}}else{const t=this.hls.liveSyncPosition;null!==t&&(s=this.getFragmentAtPosition(t,this.bitrateTest?e.fragmentEnd:e.edge,e))}return s}getFragmentAtPosition(e,t,i){const{config:s}=this;let{fragPrevious:r}=this,{fragments:a,endSN:o}=i;const{fragmentHint:n}=i,l=s.maxFragLookUpTolerance,h=i.partList,d=!!(s.lowLatencyMode&&null!=h&&h.length&&n);let c;if(d&&n&&!this.bitrateTest&&(a=a.concat(n),o=n.sn),e<t){c=du(r,a,e,e>t-l?0:l)}else c=a[a.length-1];if(c){const e=c.sn-i.startSN,t=this.fragmentTracker.getState(c);if((t===xu||t===Cu&&c.gap)&&(r=c),r&&c.sn===r.sn&&(!d||h[0].fragment.sn>c.sn)){if(r&&c.level===r.level){const t=a[e+1];c=c.sn<o&&this.fragmentTracker.getState(t)!==xu?t:null}}}return c}synchronizeToLiveEdge(e){const{config:t,media:i}=this;if(!i)return;const s=this.hls.liveSyncPosition,r=i.currentTime,a=e.fragments[0].start,o=e.edge,n=r>=a-t.maxFragLookUpTolerance&&r<=o;if(null!==s&&i.duration>s&&(r<s||!n)){const a=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!n&&i.readyState<4||r<o-a)&&(this.loadedmetadata||(this.nextLoadPosition=s),i.readyState&&(this.warn(`Playback: ${r.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${s.toFixed(3)}`),i.currentTime=s))}}alignPlaylists(e,t){const{levels:i,levelLastLoaded:s,fragPrevious:r}=this,a=null!==s?i[s]:null,o=e.fragments.length;if(!o)return this.warn("No fragments in live playlist"),0;const n=e.fragments[0].start,l=!t,h=e.alignedSliding&&Bh(n);if(l||!h&&!n){Hu(r,a,e);const i=e.fragments[0].start;return this.log(`Live playlist sliding: ${i.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${r?r.sn:"na"} fragments: ${o}`),i}return n}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)}setStartPosition(e,t){let i=this.startPosition;if(i<t&&(i=-1),-1===i||-1===this.lastCurrentTime){const s=null!==this.startTimeOffset,r=s?this.startTimeOffset:e.startTimeOffset;null!==r&&Bh(r)?(i=t+r,r<0&&(i+=e.totalduration),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Start time offset ${r} found in ${s?"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}getLoadPosition(){const{media:e}=this;let t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(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))}resetFragmentLoading(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===ip)||(this.state=Zu)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){const e=this.getCurrentContext(t.chunkMeta);e&&(t.frag=e.frag)}const i=t.frag;if(!i||i.type!==e||!this.levels)return;var s;if(this.fragContextChanged(i))return void this.warn(`Frag load error must match current frag to retry ${i.url} > ${null==(s=this.fragCurrent)?void 0:s.url}`);const r=t.details===Uh.FRAG_GAP;r&&this.fragmentTracker.fragBuffered(i,!0);const a=t.errorAction,{action:o,retryCount:n=0,retryConfig:l}=a||{};if(a&&o===mu&&l){var h;this.resetStartWhenNotLoaded(null!=(h=this.levelLastLoaded)?h:i.level);const s=ou(l,n);this.warn(`Fragment ${i.sn} of ${e} ${i.level} errored with ${t.details}, retrying loading ${n+1}/${l.maxNumRetry} in ${s}ms`),a.resolved=!0,this.retryDate=self.performance.now()+s,this.state=ip}else l&&a?(this.resetFragmentErrors(e),n<l.maxNumRetry?r||(a.resolved=!0):zh.warn(`${t.details} reached or exceeded max retry (${n})`)):(null==a?void 0:a.action)===fu?this.state=hp:this.state=np;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===rp||this.state===ap){const t=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,t),s=i&&i.len>.5;s&&this.reduceMaxBufferLength(i.len);const r=!s;return r&&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(),r}return!1}resetFragmentErrors(e){e===xc&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Xu&&(this.state=Zu)}afterBufferFlushed(e,t,i){if(!e)return;const s=ju.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,s,i),this.state===op&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=Zu}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;const t=this.levels?this.levels[e].details:null;null!=t&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){var t;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(null!=(t=this.levelLastLoaded)?t:e.level),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,i,s){var r;const a=i.details;if(!a)return void this.warn("level.details undefined");if(Object.keys(e.elementaryStreams).reduce(((t,r)=>{const o=e.elementaryStreams[r];if(o){const n=o.endPTS-o.startPTS;if(n<=0)return this.warn(`Could not parse fragment ${e.sn} ${r} duration reliably (${n})`),t||!1;const l=s?0:Xc(a,e,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return this.hls.trigger(Mh.LEVEL_PTS_UPDATED,{details:a,level:i,drift:l,type:r,frag:e,start:o.startPTS,end:o.endPTS}),!0}return t}),!1))i.fragmentError=0;else if(null===(null==(r=this.transmuxer)?void 0:r.error)){const t=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(t.message),this.hls.trigger(Mh.ERROR,{type:Fh.MEDIA_ERROR,details:Uh.FRAG_PARSING_ERROR,fatal:!1,error:t,frag:e,reason:`Found no media in msn ${e.sn} of level "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=ap,this.hls.trigger(Mh.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){var t,i,s;"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(null!=(t=null!=(i=this.levelLastLoaded)?i:null==(s=this.fragCurrent)?void 0:s.level)?t:0),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}function cp(){return self.SourceBuffer||self.WebKitSourceBuffer}function up(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class pp{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,i,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,i){}demux(e,t){this.cachedData&&(e=Vd(this.cachedData,e),this.cachedData=null);let i,s=Ad(e,0),r=s?s.length:0;const a=this._audioTrack,o=this._id3Track,n=s?(e=>{const t=Sd(e);for(let e=0;e<t.length;e++){const i=t[e];if(_d(i))return xd(i)}})(s):void 0,l=e.length;for((null===this.basePTS||0===this.frameIndex&&Bh(n))&&(this.basePTS=fp(n,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),s&&s.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:s,type:Uc,duration:Number.POSITIVE_INFINITY});r<l;){if(this.canParse(e,r)){const t=this.appendFrame(a,e,r);t?(this.frameIndex++,this.lastPTS=t.sample.pts,r+=t.length,i=r):r=l}else vd(e,r)?(s=Ad(e,r),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:s,type:Uc,duration:Number.POSITIVE_INFINITY}),r+=s.length,i=r):r++;if(r===l&&i!==l){const t=md(e,i);this.cachedData?this.cachedData=Vd(this.cachedData,t):this.cachedData=t}}return{audioTrack:a,videoTrack:up(),id3Track:o,textTrack:up()}}demuxSampleAes(e,t,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){const t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:up(),id3Track:this._id3Track,textTrack:up()}}destroy(){}}const fp=(e,t,i)=>{if(Bh(e))return 90*e;return 9e4*t+(i?9e4*i.baseTime/i.timescale:0)};function mp(e,t){return 255===e[t]&&240==(246&e[t+1])}function gp(e,t){return 1&e[t+1]?7:9}function yp(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function Ap(e,t){return t+1<e.length&&mp(e,t)}function bp(e,t){if(Ap(e,t)){const i=gp(e,t);if(t+i>=e.length)return!1;const s=yp(e,t);if(s<=i)return!1;const r=t+s;return r===e.length||Ap(e,r)}return!1}function vp(e,t,i,s,r){if(!e.samplerate){const a=function(e,t,i,s){let r,a,o,n;const l=navigator.userAgent.toLowerCase(),h=s,d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];r=1+((192&t[i+2])>>>6);const c=(60&t[i+2])>>>2;if(!(c>d.length-1))return o=(1&t[i+2])<<2,o|=(192&t[i+3])>>>6,zh.log(`manifest codec:${s}, ADTS type:${r}, samplingIndex:${c}`),/firefox/i.test(l)?c>=6?(r=5,n=new Array(4),a=c-3):(r=2,n=new Array(2),a=c):-1!==l.indexOf("android")?(r=2,n=new Array(2),a=c):(r=5,n=new Array(4),s&&(-1!==s.indexOf("mp4a.40.29")||-1!==s.indexOf("mp4a.40.5"))||!s&&c>=6?a=c-3:((s&&-1!==s.indexOf("mp4a.40.2")&&(c>=6&&1===o||/vivaldi/i.test(l))||!s&&1===o)&&(r=2,n=new Array(2)),a=c)),n[0]=r<<3,n[0]|=(14&c)>>1,n[1]|=(1&c)<<7,n[1]|=o<<3,5===r&&(n[1]|=(14&a)>>1,n[2]=(1&a)<<7,n[2]|=8,n[3]=0),{config:n,samplerate:d[c],channelCount:o,codec:"mp4a.40."+r,manifestCodec:h};e.trigger(Mh.ERROR,{type:Fh.MEDIA_ERROR,details:Uh.FRAG_PARSING_ERROR,fatal:!0,reason:`invalid ADTS sampling index:${c}`})}(t,i,s,r);if(!a)return;e.config=a.config,e.samplerate=a.samplerate,e.channelCount=a.channelCount,e.codec=a.codec,e.manifestCodec=a.manifestCodec,zh.log(`parsed codec:${e.codec}, rate:${a.samplerate}, channels:${a.channelCount}`)}}function _p(e){return 9216e4/e}function wp(e,t,i,s,r){const a=s+r*_p(e.samplerate),o=function(e,t){const i=gp(e,t);if(t+i<=e.length){const s=yp(e,t)-i;if(s>0)return{headerLength:i,frameLength:s}}}(t,i);let n;if(o){const{frameLength:s,headerLength:r}=o,l=r+s,h=Math.max(0,i+l-t.length);h?(n=new Uint8Array(l-r),n.set(t.subarray(i+r,t.length),0)):n=t.subarray(i+r,i+l);const d={unit:n,pts:a};return h||e.samples.push(d),{sample:d,length:l,missing:h}}const l=t.length-i;n=new Uint8Array(l),n.set(t.subarray(i,t.length),0);return{sample:{unit:n,pts:a},length:l,missing:-1}}const Sp=/\/emsg[-/]ID3/i;let Tp=null;const Ep=[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],kp=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Cp=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],xp=[0,1,1,4];function Rp(e,t,i,s,r){if(i+24>t.length)return;const a=Dp(t,i);if(a&&i+a.frameLength<=t.length){const o=s+r*(9e4*a.samplesPerFrame/a.sampleRate),n={unit:t.subarray(i,i+a.frameLength),pts:o,dts:o};return e.config=[],e.channelCount=a.channelCount,e.samplerate=a.sampleRate,e.samples.push(n),{sample:n,length:a.frameLength,missing:0}}}function Dp(e,t){const i=e[t+1]>>3&3,s=e[t+1]>>1&3,r=e[t+2]>>4&15,a=e[t+2]>>2&3;if(1!==i&&0!==r&&15!==r&&3!==a){const o=e[t+2]>>1&1,n=e[t+3]>>6,l=1e3*Ep[14*(3===i?3-s:3===s?3:4)+r-1],h=kp[3*(3===i?0:2===i?1:2)+a],d=3===n?1:2,c=Cp[i][s],u=xp[s],p=8*c*u,f=Math.floor(c*l/h+o)*u;if(null===Tp){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Tp=e?parseInt(e[1]):0}return!!Tp&&Tp<=87&&2===s&&l>=224e3&&0===n&&(e[t+3]=128|e[t+3]),{sampleRate:h,channelCount:d,frameLength:f,samplesPerFrame:p}}}function Lp(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}function Ip(e,t){return t+1<e.length&&Lp(e,t)}function Pp(e,t){if(t+1<e.length&&Lp(e,t)){const i=4,s=Dp(e,t);let r=i;null!=s&&s.frameLength&&(r=s.frameLength);const a=t+r;return a===e.length||Ip(e,a)}return!1}class Bp{constructor(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}loadWord(){const e=this.data,t=this.bytesAvailable,i=e.byteLength-t,s=new Uint8Array(4),r=Math.min(4,t);if(0===r)throw new Error("no bytes available");s.set(e.subarray(i,i+r)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=8*r,this.bytesAvailable-=r}skipBits(e){let t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(t=(e-=this.bitsAvailable)>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e);const i=this.word>>>32-t;if(e>32&&zh.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,t>0&&this.bitsAvailable?i<<t|this.readBits(t):i}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(0!=(this.word&2147483648>>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const e=this.skipLZ();return this.readBits(e+1)-1}readEG(){const e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return 1===this.readBits(1)}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let t,i=8,s=8;for(let r=0;r<e;r++)0!==s&&(t=this.readEG(),s=(i+t+256)%256),i=0===s?i:s}readSPS(){let e,t,i,s=0,r=0,a=0,o=0;const n=this.readUByte.bind(this),l=this.readBits.bind(this),h=this.readUEG.bind(this),d=this.readBoolean.bind(this),c=this.skipBits.bind(this),u=this.skipEG.bind(this),p=this.skipUEG.bind(this),f=this.skipScalingList.bind(this);n();const m=n();if(l(5),c(3),n(),p(),100===m||110===m||122===m||244===m||44===m||83===m||86===m||118===m||128===m){const e=h();if(3===e&&c(1),p(),p(),c(1),d())for(t=3!==e?8:12,i=0;i<t;i++)d()&&f(i<6?16:64)}p();const g=h();if(0===g)h();else if(1===g)for(c(1),u(),u(),e=h(),i=0;i<e;i++)u();p(),c(1);const y=h(),A=h(),b=l(1);0===b&&c(1),c(1),d()&&(s=h(),r=h(),a=h(),o=h());let v=[1,1];if(d()&&d()){switch(n()){case 1:v=[1,1];break;case 2:v=[12,11];break;case 3:v=[10,11];break;case 4:v=[16,11];break;case 5:v=[40,33];break;case 6:v=[24,11];break;case 7:v=[20,11];break;case 8:v=[32,11];break;case 9:v=[80,33];break;case 10:v=[18,11];break;case 11:v=[15,11];break;case 12:v=[64,33];break;case 13:v=[160,99];break;case 14:v=[4,3];break;case 15:v=[3,2];break;case 16:v=[2,1];break;case 255:v=[n()<<8|n(),n()<<8|n()]}}return{width:Math.ceil(16*(y+1)-2*s-2*r),height:(2-b)*(A+1)*16-(b?2:4)*(a+o),pixelRatio:v}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class Mp{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new Yu(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,i){const s=e[t].unit;if(s.length<=16)return;const r=s.subarray(16,s.length-s.length%16),a=r.buffer.slice(r.byteOffset,r.byteOffset+r.length);this.decryptBuffer(a).then((r=>{const a=new Uint8Array(r);s.set(a,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,i)}))}decryptAacSamples(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}}getAvcEncryptedData(e){const t=16*Math.floor((e.length-48)/160)+16,i=new Int8Array(t);let s=0;for(let t=32;t<e.length-16;t+=160,s+=16)i.set(e.subarray(t,t+16),s);return i}getAvcDecryptedUnit(e,t){const i=new Uint8Array(t);let s=0;for(let t=32;t<e.length-16;t+=160,s+=16)e.set(i.subarray(s,s+16),t);return e}decryptAvcSample(e,t,i,s,r){const a=Yd(r.data),o=this.getAvcEncryptedData(a);this.decryptBuffer(o.buffer).then((o=>{r.data=this.getAvcDecryptedUnit(a,o),this.decrypter.isSync()||this.decryptAvcSamples(e,t,i+1,s)}))}decryptAvcSamples(e,t,i,s){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length)return void s();const r=e[t].units;for(;!(i>=r.length);i++){const a=r[i];if(!(a.data.length<=48||1!==a.type&&5!==a.type||(this.decryptAvcSample(e,t,i,s,a),this.decrypter.isSync())))return}}}}const Fp=188;class Up{constructor(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._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=e,this.config=t,this.typeSupported=i}static probe(e){const t=Up.syncOffset(e);return t>0&&zh.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),-1!==t}static syncOffset(e){const t=e.length;let i=Math.min(940,e.length-Fp)+1,s=0;for(;s<i;){let r=!1,a=-1,o=0;for(let n=s;n<t;n+=Fp){if(71!==e[n]){if(o)return-1;break}if(o++,-1===a&&(a=n,0!==a&&(i=Math.min(a+18612,e.length-Fp)+1)),r||(r=0===Np(e,n)),r&&o>1&&(0===a&&o>2||n+Fp>i))return a}s++}return-1}static createTrack(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:Md[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}resetInitSegment(e,t,i,s){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=Up.createTrack("video"),this._audioTrack=Up.createTrack("audio",s),this._id3Track=Up.createTrack("id3"),this._txtTrack=Up.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i,this._duration=s}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_avcTrack:t,_id3Track:i}=this;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(e,t,i=!1,s=!1){let r;i||(this.sampleAes=null);const a=this._avcTrack,o=this._audioTrack,n=this._id3Track,l=this._txtTrack;let h=a.pid,d=a.pesData,c=o.pid,u=n.pid,p=o.pesData,f=n.pesData,m=null,g=this.pmtParsed,y=this._pmtId,A=e.length;if(this.remainderData&&(A=(e=Vd(this.remainderData,e)).length,this.remainderData=null),A<Fp&&!s)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:n,textTrack:l};const b=Math.max(0,Up.syncOffset(e));A-=(A-b)%Fp,A<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,A,e.buffer.byteLength-A));let v=0;for(let t=b;t<A;t+=Fp)if(71===e[t]){const s=!!(64&e[t+1]),A=Np(e,t);let v;if((48&e[t+3])>>4>1){if(v=t+5+e[t+4],v===t+Fp)continue}else v=t+4;switch(A){case h:s&&(d&&(r=zp(d))&&this.parseAVCPES(a,l,r,!1),d={data:[],size:0}),d&&(d.data.push(e.subarray(v,t+Fp)),d.size+=t+Fp-v);break;case c:if(s){if(p&&(r=zp(p)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,r);break;case"mp3":this.parseMPEGPES(o,r)}p={data:[],size:0}}p&&(p.data.push(e.subarray(v,t+Fp)),p.size+=t+Fp-v);break;case u:s&&(f&&(r=zp(f))&&this.parseID3PES(n,r),f={data:[],size:0}),f&&(f.data.push(e.subarray(v,t+Fp)),f.size+=t+Fp-v);break;case 0:s&&(v+=e[v]+1),y=this._pmtId=jp(e,v);break;case y:{s&&(v+=e[v]+1);const r=Gp(e,v,this.typeSupported,i);h=r.avc,h>0&&(a.pid=h),c=r.audio,c>0&&(o.pid=c,o.segmentCodec=r.segmentCodec),u=r.id3,u>0&&(n.pid=u),null===m||g||(zh.warn(`MPEG-TS PMT found at ${t} after unknown PID '${m}'. Backtracking to sync byte @${b} to parse all TS packets.`),m=null,t=b-188),g=this.pmtParsed=!0;break}case 17:case 8191:break;default:m=A}}else v++;if(v>0){const e=new Error(`Found ${v} TS packet/s that do not start with 0x47`);this.observer.emit(Mh.ERROR,Mh.ERROR,{type:Fh.MEDIA_ERROR,details:Uh.FRAG_PARSING_ERROR,fatal:!1,error:e,reason:e.message})}a.pesData=d,o.pesData=p,n.pesData=f;const _={audioTrack:o,videoTrack:a,id3Track:n,textTrack:l};return s&&this.extractRemainingSamples(_),_}flush(){const{remainderData:e}=this;let t;return this.remainderData=null,t=e?this.demux(e,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){const{audioTrack:t,videoTrack:i,id3Track:s,textTrack:r}=e,a=i.pesData,o=t.pesData,n=s.pesData;let l;if(a&&(l=zp(a))?(this.parseAVCPES(i,r,l,!0),i.pesData=null):i.pesData=a,o&&(l=zp(o))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,l);break;case"mp3":this.parseMPEGPES(t,l)}t.pesData=null}else null!=o&&o.size&&zh.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;n&&(l=zp(n))?(this.parseID3PES(s,l),s.pesData=null):s.pesData=n}demuxSampleAes(e,t,i){const s=this.demux(e,i,!0,!this.config.progressive),r=this.sampleAes=new Mp(this.observer,this.config,t);return this.decrypt(s,r)}decrypt(e,t){return new Promise((i=>{const{audioTrack:s,videoTrack:r}=e;s.samples&&"aac"===s.segmentCodec?t.decryptAacSamples(s.samples,0,(()=>{r.samples?t.decryptAvcSamples(r.samples,0,0,(()=>{i(e)})):i(e)})):r.samples&&t.decryptAvcSamples(r.samples,0,0,(()=>{i(e)}))}))}destroy(){this._duration=0}parseAVCPES(e,t,i,s){const r=this.parseAVCNALu(e,i.data);let a,o=this.avcSample,n=!1;i.data=null,o&&r.length&&!e.audFound&&($p(o,e),o=this.avcSample=Op(!1,i.pts,i.dts,"")),r.forEach((s=>{var r;switch(s.type){case 1:{let t=!1;a=!0;const r=s.data;if(n&&r.length>4){const e=new Bp(r).readSliceType();2!==e&&4!==e&&7!==e&&9!==e||(t=!0)}var l;if(t)null!=(l=o)&&l.frame&&!o.key&&($p(o,e),o=this.avcSample=null);o||(o=this.avcSample=Op(!0,i.pts,i.dts,"")),o.frame=!0,o.key=t;break}case 5:a=!0,null!=(r=o)&&r.frame&&!o.key&&($p(o,e),o=this.avcSample=null),o||(o=this.avcSample=Op(!0,i.pts,i.dts,"")),o.key=!0,o.frame=!0;break;case 6:a=!0,qd(s.data,1,i.pts,t.samples);break;case 7:if(a=!0,n=!0,!e.sps){const t=s.data,i=new Bp(t).readSPS();e.width=i.width,e.height=i.height,e.pixelRatio=i.pixelRatio,e.sps=[t],e.duration=this._duration;const r=t.subarray(1,4);let a="avc1.";for(let e=0;e<3;e++){let t=r[e].toString(16);t.length<2&&(t="0"+t),a+=t}e.codec=a}break;case 8:a=!0,e.pps||(e.pps=[s.data]);break;case 9:a=!1,e.audFound=!0,o&&$p(o,e),o=this.avcSample=Op(!1,i.pts,i.dts,"");break;case 12:a=!0;break;default:a=!1,o&&(o.debug+="unknown NAL "+s.type+" ")}if(o&&a){o.units.push(s)}})),s&&o&&($p(o,e),this.avcSample=null)}getLastNalUnit(e){var t;let i,s=this.avcSample;if(s&&0!==s.units.length||(s=e[e.length-1]),null!=(t=s)&&t.units){const e=s.units;i=e[e.length-1]}return i}parseAVCNALu(e,t){const i=t.byteLength;let s=e.naluState||0;const r=s,a=[];let o,n,l,h=0,d=-1,c=0;for(-1===s&&(d=0,c=31&t[0],s=0,h=1);h<i;)if(o=t[h++],s)if(1!==s)if(o)if(1===o){if(d>=0){const e={data:t.subarray(d,h-s-1),type:c};a.push(e)}else{const i=this.getLastNalUnit(e.samples);if(i&&(r&&h<=4-r&&i.state&&(i.data=i.data.subarray(0,i.data.byteLength-r)),n=h-s-1,n>0)){const e=new Uint8Array(i.data.byteLength+n);e.set(i.data,0),e.set(t.subarray(0,n),i.data.byteLength),i.data=e,i.state=0}}h<i?(l=31&t[h],d=h,c=l,s=0):s=-1}else s=0;else s=3;else s=o?0:2;else s=o?0:1;if(d>=0&&s>=0){const e={data:t.subarray(d,i),type:c,state:s};a.push(e)}if(0===a.length){const i=this.getLastNalUnit(e.samples);if(i){const e=new Uint8Array(i.data.byteLength+t.byteLength);e.set(i.data,0),e.set(t,i.data.byteLength),i.data=e}}return e.naluState=s,a}parseAACPES(e,t){let i=0;const s=this.aacOverFlow;let r,a,o,n=t.data;if(s){this.aacOverFlow=null;const t=s.missing,r=s.sample.unit.byteLength;if(-1===t){const e=new Uint8Array(r+n.byteLength);e.set(s.sample.unit,0),e.set(n,r),n=e}else{const a=r-t;s.sample.unit.set(n.subarray(0,t),a),e.samples.push(s.sample),i=s.missing}}for(r=i,a=n.length;r<a-1&&!Ap(n,r);r++);if(r!==i){let e;const t=r<a-1;e=t?`AAC PES did not start with ADTS header,offset:${r}`:"No ADTS header found in AAC PES";const i=new Error(e);if(zh.warn(`parsing error: ${e}`),this.observer.emit(Mh.ERROR,Mh.ERROR,{type:Fh.MEDIA_ERROR,details:Uh.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:i,reason:e}),!t)return}if(vp(e,this.observer,n,r,this.audioCodec),void 0!==t.pts)o=t.pts;else{if(!s)return void zh.warn("[tsdemuxer]: AAC PES unknown PTS");{const t=_p(e.samplerate);o=s.sample.pts+t}}let l,h=0;for(;r<a;){if(l=wp(e,n,r,o,h),r+=l.length,l.missing){this.aacOverFlow=l;break}for(h++;r<a-1&&!Ap(n,r);r++);}}parseMPEGPES(e,t){const i=t.data,s=i.length;let r=0,a=0;const o=t.pts;if(void 0!==o)for(;a<s;)if(Ip(i,a)){const t=Rp(e,i,a,o,r);if(!t)break;a+=t.length,r++}else a++;else zh.warn("[tsdemuxer]: MPEG PES unknown PTS")}parseID3PES(e,t){if(void 0===t.pts)return void zh.warn("[tsdemuxer]: ID3 PES unknown PTS");const i=Ph({},t,{type:this._avcTrack?Nc:Uc,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}}function Op(e,t,i,s){return{key:e,frame:!1,pts:t,dts:i,units:[],debug:s,length:0}}function Np(e,t){return((31&e[t+1])<<8)+e[t+2]}function jp(e,t){return(31&e[t+10])<<8|e[t+11]}function Gp(e,t,i,s){const r={audio:-1,avc:-1,id3:-1,segmentCodec:"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;){const a=Np(e,t);switch(e[t]){case 207:if(!s){zh.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:-1===r.audio&&(r.audio=a);break;case 21:-1===r.id3&&(r.id3=a);break;case 219:if(!s){zh.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:-1===r.avc&&(r.avc=a);break;case 3:case 4:!0!==i.mpeg&&!0!==i.mp3?zh.log("MPEG audio found, not supported in this browser"):-1===r.audio&&(r.audio=a,r.segmentCodec="mp3");break;case 36:zh.warn("Unsupported HEVC stream type found")}t+=5+((15&e[t+3])<<8|e[t+4])}return r}function zp(e){let t,i,s,r,a,o=0;const n=e.data;if(!e||0===e.size)return null;for(;n[0].length<19&&n.length>1;){const e=new Uint8Array(n[0].length+n[1].length);e.set(n[0]),e.set(n[1],n[0].length),n[0]=e,n.splice(1,1)}t=n[0];if(1===(t[0]<<16)+(t[1]<<8)+t[2]){if(i=(t[4]<<8)+t[5],i&&i>e.size-6)return null;const l=t[7];192&l&&(r=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,64&l?(a=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2,r-a>54e5&&(zh.warn(`${Math.round((r-a)/9e4)}s delta between PTS and DTS, align them`),r=a)):a=r),s=t[8];let h=s+9;if(e.size<=h)return null;e.size-=h;const d=new Uint8Array(e.size);for(let e=0,i=n.length;e<i;e++){t=n[e];let i=t.byteLength;if(h){if(h>i){h-=i;continue}t=t.subarray(h),i-=h,h=0}d.set(t,o),o+=i}return i&&(i-=s+3),{data:d,pts:r,dts:a,len:i}}return null}function $p(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){const i=t.samples,s=i.length;if(!s)return void t.dropped++;{const t=i[s-1];e.pts=t.pts,e.dts=t.dts}}t.samples.push(e)}e.debug.length&&zh.log(e.pts+"/"+e.dts+":"+e.debug)}class Wp{static getSilentFrame(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])}}}const Hp=Math.pow(2,32)-1;class Vp{static init(){let e;for(e in Vp.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},Vp.types)Vp.types.hasOwnProperty(e)&&(Vp.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);const t=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]),i=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]);Vp.HDLR_TYPES={video:t,audio:i};const s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),r=new Uint8Array([0,0,0,0,0,0,0,0]);Vp.STTS=Vp.STSC=Vp.STCO=r,Vp.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),Vp.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),Vp.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),Vp.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),n=new Uint8Array([0,0,0,1]);Vp.FTYP=Vp.box(Vp.types.ftyp,a,n,a,o),Vp.DINF=Vp.box(Vp.types.dinf,Vp.box(Vp.types.dref,s))}static box(e,...t){let i=8,s=t.length;const r=s;for(;s--;)i+=t[s].byteLength;const a=new Uint8Array(i);for(a[0]=i>>24&255,a[1]=i>>16&255,a[2]=i>>8&255,a[3]=255&i,a.set(e,4),s=0,i=8;s<r;s++)a.set(t[s],i),i+=t[s].byteLength;return a}static hdlr(e){return Vp.box(Vp.types.hdlr,Vp.HDLR_TYPES[e])}static mdat(e){return Vp.box(Vp.types.mdat,e)}static mdhd(e,t){t*=e;const i=Math.floor(t/(Hp+1)),s=Math.floor(t%(Hp+1));return Vp.box(Vp.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,s>>24,s>>16&255,s>>8&255,255&s,85,196,0,0]))}static mdia(e){return Vp.box(Vp.types.mdia,Vp.mdhd(e.timescale,e.duration),Vp.hdlr(e.type),Vp.minf(e))}static mfhd(e){return Vp.box(Vp.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))}static minf(e){return"audio"===e.type?Vp.box(Vp.types.minf,Vp.box(Vp.types.smhd,Vp.SMHD),Vp.DINF,Vp.stbl(e)):Vp.box(Vp.types.minf,Vp.box(Vp.types.vmhd,Vp.VMHD),Vp.DINF,Vp.stbl(e))}static moof(e,t,i){return Vp.box(Vp.types.moof,Vp.mfhd(e),Vp.traf(i,t))}static moov(e){let t=e.length;const i=[];for(;t--;)i[t]=Vp.trak(e[t]);return Vp.box.apply(null,[Vp.types.moov,Vp.mvhd(e[0].timescale,e[0].duration)].concat(i).concat(Vp.mvex(e)))}static mvex(e){let t=e.length;const i=[];for(;t--;)i[t]=Vp.trex(e[t]);return Vp.box.apply(null,[Vp.types.mvex,...i])}static mvhd(e,t){t*=e;const i=Math.floor(t/(Hp+1)),s=Math.floor(t%(Hp+1)),r=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,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 Vp.box(Vp.types.mvhd,r)}static sdtp(e){const t=e.samples||[],i=new Uint8Array(4+t.length);let s,r;for(s=0;s<t.length;s++)r=t[s].flags,i[s+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return Vp.box(Vp.types.sdtp,i)}static stbl(e){return Vp.box(Vp.types.stbl,Vp.stsd(e),Vp.box(Vp.types.stts,Vp.STTS),Vp.box(Vp.types.stsc,Vp.STSC),Vp.box(Vp.types.stsz,Vp.STSZ),Vp.box(Vp.types.stco,Vp.STCO))}static avc1(e){let t,i,s,r=[],a=[];for(t=0;t<e.sps.length;t++)i=e.sps[t],s=i.byteLength,r.push(s>>>8&255),r.push(255&s),r=r.concat(Array.prototype.slice.call(i));for(t=0;t<e.pps.length;t++)i=e.pps[t],s=i.byteLength,a.push(s>>>8&255),a.push(255&s),a=a.concat(Array.prototype.slice.call(i));const o=Vp.box(Vp.types.avcC,new Uint8Array([1,r[3],r[4],r[5],255,224|e.sps.length].concat(r).concat([e.pps.length]).concat(a))),n=e.width,l=e.height,h=e.pixelRatio[0],d=e.pixelRatio[1];return Vp.box(Vp.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,n>>8&255,255&n,l>>8&255,255&l,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,Vp.box(Vp.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),Vp.box(Vp.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,255&h,d>>24,d>>16&255,d>>8&255,255&d])))}static esds(e){const 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]))}static mp4a(e){const t=e.samplerate;return Vp.box(Vp.types.mp4a,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]),Vp.box(Vp.types.esds,Vp.esds(e)))}static mp3(e){const t=e.samplerate;return Vp.box(Vp.types[".mp3"],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]))}static stsd(e){return"audio"===e.type?"mp3"===e.segmentCodec&&"mp3"===e.codec?Vp.box(Vp.types.stsd,Vp.STSD,Vp.mp3(e)):Vp.box(Vp.types.stsd,Vp.STSD,Vp.mp4a(e)):Vp.box(Vp.types.stsd,Vp.STSD,Vp.avc1(e))}static tkhd(e){const t=e.id,i=e.duration*e.timescale,s=e.width,r=e.height,a=Math.floor(i/(Hp+1)),o=Math.floor(i%(Hp+1));return Vp.box(Vp.types.tkhd,new Uint8Array([1,0,0,7,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,0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,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,r>>8&255,255&r,0,0]))}static traf(e,t){const i=Vp.sdtp(e),s=e.id,r=Math.floor(t/(Hp+1)),a=Math.floor(t%(Hp+1));return Vp.box(Vp.types.traf,Vp.box(Vp.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s])),Vp.box(Vp.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,a>>24,a>>16&255,a>>8&255,255&a])),Vp.trun(e,i.length+16+20+8+16+8+8),i)}static trak(e){return e.duration=e.duration||4294967295,Vp.box(Vp.types.trak,Vp.tkhd(e),Vp.mdia(e))}static trex(e){const t=e.id;return Vp.box(Vp.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){const i=e.samples||[],s=i.length,r=12+16*s,a=new Uint8Array(r);let o,n,l,h,d,c;for(t+=8+r,a.set(["video"===e.type?1:0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,255&s,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0),o=0;o<s;o++)n=i[o],l=n.duration,h=n.size,d=n.flags,c=n.cts,a.set([l>>>24&255,l>>>16&255,l>>>8&255,255&l,h>>>24&255,h>>>16&255,h>>>8&255,255&h,d.isLeading<<2|d.dependsOn,d.isDependedOn<<6|d.hasRedundancy<<4|d.paddingValue<<1|d.isNonSync,61440&d.degradPrio,15&d.degradPrio,c>>>24&255,c>>>16&255,c>>>8&255,255&c],12+16*o);return Vp.box(Vp.types.trun,a)}static initSegment(e){Vp.types||Vp.init();const t=Vp.moov(e),i=new Uint8Array(Vp.FTYP.byteLength+t.byteLength);return i.set(Vp.FTYP),i.set(t,Vp.FTYP.byteLength),i}}Vp.types=void 0,Vp.HDLR_TYPES=void 0,Vp.STTS=void 0,Vp.STSC=void 0,Vp.STCO=void 0,Vp.STSZ=void 0,Vp.VMHD=void 0,Vp.SMHD=void 0,Vp.STSD=void 0,Vp.FTYP=void 0,Vp.DINF=void 0;function Jp(e,t,i=1,s=!1){const r=e*t*i;return s?Math.round(r):r}function Kp(e,t=!1){return Jp(e,1e3,1/9e4,t)}let qp,Yp=null,Qp=null;class Xp{constructor(e,t,i,s=""){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.observer=e,this.config=t,this.typeSupported=i,this.ISGenerated=!1,null===Yp){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Yp=e?parseInt(e[1]):0}if(null===Qp){const e=navigator.userAgent.match(/Safari\/(\d+)/i);Qp=e?parseInt(e[1]):0}}destroy(){}resetTimeStamp(e){zh.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){zh.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){zh.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(e){let t=!1;const i=e.reduce(((e,i)=>{const s=i.pts-e;return s<-4294967296?(t=!0,Zp(e,i.pts)):s>0?e:i.pts}),e[0].pts);return t&&zh.debug("PTS rollover detected"),i}remux(e,t,i,s,r,a,o,n){let l,h,d,c,u,p,f=r,m=r;const g=e.pid>-1,y=t.pid>-1,A=t.samples.length,b=e.samples.length>0,v=o&&A>0||A>1;if((!g||b)&&(!y||v)||this.ISGenerated||o){this.ISGenerated||(d=this.generateIS(e,t,r,a));const i=this.isVideoContiguous;let s,o=-1;if(v&&(o=function(e){for(let t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!i&&this.config.forceKeyFrameOnDiscontinuity))if(p=!0,o>0){zh.warn(`[mp4-remuxer]: Dropped ${o} out of ${A} video samples due to a missing keyframe`);const e=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(o),t.dropped+=o,m+=(t.samples[0].pts-e)/t.inputTimeScale,s=m}else-1===o&&(zh.warn(`[mp4-remuxer]: No keyframe found out of ${A} video samples`),p=!1);if(this.ISGenerated){if(b&&v){const i=this.getVideoStartPts(t.samples),s=(Zp(e.samples[0].pts,i)-i)/t.inputTimeScale;f+=Math.max(0,s),m+=Math.max(0,-s)}if(b){if(e.samplerate||(zh.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),d=this.generateIS(e,t,r,a)),h=this.remuxAudio(e,f,this.isAudioContiguous,a,y||v||n===xc?m:void 0),v){const s=h?h.endPTS-h.startPTS:0;t.inputTimeScale||(zh.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),d=this.generateIS(e,t,r,a)),l=this.remuxVideo(t,m,i,s)}}else v&&(l=this.remuxVideo(t,m,i,0));l&&(l.firstKeyFrame=o,l.independent=-1!==o,l.firstKeyFramePTS=s)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(u=ef(i,r,this._initPTS,this._initDTS)),s.samples.length&&(c=tf(s,r,this._initPTS))),{audio:h,video:l,initSegment:d,independent:p,text:c,id3:u}}generateIS(e,t,i,s){const r=e.samples,a=t.samples,o=this.typeSupported,n={},l=this._initPTS;let h,d,c,u=!l||s,p="audio/mp4";if(u&&(h=d=1/0),e.config&&r.length){if(e.timescale=e.samplerate,"mp3"===e.segmentCodec)o.mpeg?(p="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");n.audio={id:"audio",container:p,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&o.mpeg?new Uint8Array(0):Vp.initSegment([e]),metadata:{channelCount:e.channelCount}},u&&(c=e.inputTimeScale,l&&c===l.timescale?u=!1:h=d=r[0].pts-Math.round(c*i))}if(t.sps&&t.pps&&a.length&&(t.timescale=t.inputTimeScale,n.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:Vp.initSegment([t]),metadata:{width:t.width,height:t.height}},u))if(c=t.inputTimeScale,l&&c===l.timescale)u=!1;else{const e=this.getVideoStartPts(a),t=Math.round(c*i);d=Math.min(d,Zp(a[0].dts,e)-t),h=Math.min(h,e-t)}if(Object.keys(n).length)return this.ISGenerated=!0,u?(this._initPTS={baseTime:h,timescale:c},this._initDTS={baseTime:d,timescale:c}):h=c=void 0,{tracks:n,initPTS:h,timescale:c}}remuxVideo(e,t,i,s){const r=e.inputTimeScale,a=e.samples,o=[],n=a.length,l=this._initPTS;let h,d,c=this.nextAvcDts,u=8,p=this.videoSampleDuration,f=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY,g=!1;if(!i||null===c){c=t*r-(a[0].pts-Zp(a[0].dts,a[0].pts))}const y=l.baseTime*r/l.timescale;for(let e=0;e<n;e++){const t=a[e];t.pts=Zp(t.pts-y,c),t.dts=Zp(t.dts-y,c),t.dts<a[e>0?e-1:e].dts&&(g=!0)}g&&a.sort((function(e,t){const i=e.dts-t.dts,s=e.pts-t.pts;return i||s})),h=a[0].dts,d=a[a.length-1].dts;const A=d-h,b=A?Math.round(A/(n-1)):p||e.inputTimeScale/30;if(i){const e=h-c,t=e>b,i=e<-1;if((t||i)&&(t?zh.warn(`AVC: ${Kp(e,!0)} ms (${e}dts) hole between fragments detected, filling it`):zh.warn(`AVC: ${Kp(-e,!0)} ms (${e}dts) overlapping between fragments detected`),!i||c>=a[0].pts)){h=c;const t=a[0].pts-e;a[0].dts=h,a[0].pts=t,zh.log(`Video: First PTS/DTS adjusted: ${Kp(t,!0)}/${Kp(h,!0)}, delta: ${Kp(e,!0)} ms`)}}h=Math.max(0,h);let v=0,_=0;for(let e=0;e<n;e++){const t=a[e],i=t.units,s=i.length;let r=0;for(let e=0;e<s;e++)r+=i[e].data.length;_+=r,v+=s,t.length=r,t.dts=Math.max(t.dts,h),f=Math.min(t.pts,f),m=Math.max(t.pts,m)}d=a[n-1].dts;const w=_+4*v+8;let S;try{S=new Uint8Array(w)}catch(e){return void this.observer.emit(Mh.ERROR,Mh.ERROR,{type:Fh.MUX_ERROR,details:Uh.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:w,reason:`fail allocating video mdat ${w}`})}const T=new DataView(S.buffer);T.setUint32(0,w),S.set(Vp.types.mdat,4);let E=!1,k=Number.POSITIVE_INFINITY,C=Number.POSITIVE_INFINITY,x=Number.NEGATIVE_INFINITY,R=Number.NEGATIVE_INFINITY;for(let e=0;e<n;e++){const t=a[e],i=t.units;let l,h=0;for(let e=0,t=i.length;e<t;e++){const t=i[e],s=t.data,r=t.data.byteLength;T.setUint32(u,r),u+=4,S.set(s,u),u+=r,h+=4+r}if(e<n-1)p=a[e+1].dts-t.dts,l=a[e+1].pts-t.pts;else{const i=this.config,o=e>0?t.dts-a[e-1].dts:b;if(l=e>0?t.pts-a[e-1].pts:b,i.stretchShortVideoTrack&&null!==this.nextAudioPts){const e=Math.floor(i.maxBufferHole*r),a=(s?f+s*r:this.nextAudioPts)-t.pts;a>e?(p=a-o,p<0?p=o:E=!0,zh.log(`[mp4-remuxer]: It is approximately ${a/90} ms to the next segment; using duration ${p/90} ms for the last video frame.`)):p=o}else p=o}const d=Math.round(t.pts-t.dts);k=Math.min(k,p),x=Math.max(x,p),C=Math.min(C,l),R=Math.max(R,l),o.push(new sf(t.key,p,h,d))}if(o.length)if(Yp){if(Yp<70){const e=o[0].flags;e.dependsOn=2,e.isNonSync=0}}else if(Qp&&R-C<x-k&&b/x<.025&&0===o[0].cts){zh.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let e=h;for(let t=0,i=o.length;t<i;t++){const s=e+o[t].duration,r=e+o[t].cts;if(t<i-1){const e=s+o[t+1].cts;o[t].duration=e-r}else o[t].duration=t?o[t-1].duration:b;o[t].cts=0,e=s}}p=E||!p?b:p,this.nextAvcDts=c=d+p,this.videoSampleDuration=p,this.isVideoContiguous=!0;const D={data1:Vp.moof(e.sequenceNumber++,h,Ph({},e,{samples:o})),data2:S,startPTS:f/r,endPTS:(m+p)/r,startDTS:h/r,endDTS:c/r,type:"video",hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,D}remuxAudio(e,t,i,s,r){const a=e.inputTimeScale,o=a/(e.samplerate?e.samplerate:a),n="aac"===e.segmentCodec?1024:1152,l=n*o,h=this._initPTS,d="mp3"===e.segmentCodec&&this.typeSupported.mpeg,c=[],u=void 0!==r;let p=e.samples,f=d?0:8,m=this.nextAudioPts||-1;const g=t*a,y=h.baseTime*a/h.timescale;if(this.isAudioContiguous=i=i||p.length&&m>0&&(s&&Math.abs(g-m)<9e3||Math.abs(Zp(p[0].pts-y,g)-m)<20*l),p.forEach((function(e){e.pts=Zp(e.pts-y,g)})),!i||m<0){if(p=p.filter((e=>e.pts>=0)),!p.length)return;m=0===r?0:s&&!u?Math.max(0,g):p[0].pts}if("aac"===e.segmentCodec){const t=this.config.maxAudioFramesDrift;for(let i=0,s=m;i<p.length;i++){const r=p[i],o=r.pts,n=o-s,h=Math.abs(1e3*n/a);if(n<=-t*l&&u)0===i&&(zh.warn(`Audio frame @ ${(o/a).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*n/a)} ms.`),this.nextAudioPts=m=s=o);else if(n>=t*l&&h<1e4&&u){let t=Math.round(n/l);s=o-t*l,s<0&&(t--,s+=l),0===i&&(this.nextAudioPts=m=s),zh.warn(`[mp4-remuxer]: Injecting ${t} audio frame @ ${(s/a).toFixed(3)}s due to ${Math.round(1e3*n/a)} ms gap.`);for(let a=0;a<t;a++){const t=Math.max(s,0);let a=Wp.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);a||(zh.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),a=r.unit.subarray()),p.splice(i,0,{unit:a,pts:t}),s+=l,i++}}r.pts=s,s+=l}}let A,b=null,v=null,_=0,w=p.length;for(;w--;)_+=p[w].unit.byteLength;for(let t=0,s=p.length;t<s;t++){const s=p[t],r=s.unit;let a=s.pts;if(null!==v){c[t-1].duration=Math.round((a-v)/o)}else{if(i&&"aac"===e.segmentCodec&&(a=m),b=a,!(_>0))return;_+=f;try{A=new Uint8Array(_)}catch(e){return void this.observer.emit(Mh.ERROR,Mh.ERROR,{type:Fh.MUX_ERROR,details:Uh.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:_,reason:`fail allocating audio mdat ${_}`})}if(!d){new DataView(A.buffer).setUint32(0,_),A.set(Vp.types.mdat,4)}}A.set(r,f);const l=r.byteLength;f+=l,c.push(new sf(!0,n,l,0)),v=a}const S=c.length;if(!S)return;const T=c[c.length-1];this.nextAudioPts=m=v+o*T.duration;const E=d?new Uint8Array(0):Vp.moof(e.sequenceNumber++,b/o,Ph({},e,{samples:c}));e.samples=[];const k=b/a,C=m/a,x={data1:E,data2:A,startPTS:k,endPTS:C,startDTS:k,endDTS:C,type:"audio",hasAudio:!0,hasVideo:!1,nb:S};return this.isAudioContiguous=!0,x}remuxEmptyAudio(e,t,i,s){const r=e.inputTimeScale,a=r/(e.samplerate?e.samplerate:r),o=this.nextAudioPts,n=this._initDTS,l=9e4*n.baseTime/n.timescale,h=(null!==o?o:s.startDTS*r)+l,d=s.endDTS*r+l,c=1024*a,u=Math.ceil((d-h)/c),p=Wp.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(zh.warn("[mp4-remuxer]: remux empty Audio"),!p)return void zh.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");const f=[];for(let e=0;e<u;e++){const t=h+e*c;f.push({unit:p,pts:t,dts:t})}return e.samples=f,this.remuxAudio(e,t,i,!1)}}function Zp(e,t){let i;if(null===t)return e;for(i=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=i;return e}function ef(e,t,i,s){const r=e.samples.length;if(!r)return;const a=e.inputTimeScale;for(let o=0;o<r;o++){const r=e.samples[o];r.pts=Zp(r.pts-i.baseTime*a/i.timescale,t*a)/a,r.dts=Zp(r.dts-s.baseTime*a/s.timescale,t*a)/a}const o=e.samples;return e.samples=[],{samples:o}}function tf(e,t,i){const s=e.samples.length;if(!s)return;const r=e.inputTimeScale;for(let a=0;a<s;a++){const s=e.samples[a];s.pts=Zp(s.pts-i.baseTime*r/i.timescale,t*r)/r}e.samples.sort(((e,t)=>e.pts-t.pts));const a=e.samples;return e.samples=[],{samples:a}}class sf{constructor(e,t,i,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=i,this.cts=s,this.flags=new rf(e)}}class rf{constructor(e){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=e?2:1,this.isNonSync=e?0:1}}function af(e,t){const i=null==e?void 0:e.codec;return i&&i.length>4?i:"hvc1"===i||"hev1"===i?"hvc1.1.6.L120.90":"av01"===i?"av01.0.04M.08":"avc1"===i||t===Yh?"avc1.42e01e":"mp4a.40.5"}try{qp=self.performance.now.bind(self.performance)}catch(e){zh.debug("Unable to use Performance API on this environment"),qp="undefined"!=typeof self&&self.Date.now}const of=[{demux:class{constructor(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}resetTimeStamp(){}resetInitSegment(e,t,i,s){const r=this.videoTrack=up("video",1),a=this.audioTrack=up("audio",1),o=this.txtTrack=up("text",1);if(this.id3Track=up("id3",1),this.timeOffset=0,null==e||!e.byteLength)return;const n=$d(e);if(n.video){const{id:e,timescale:t,codec:i}=n.video;r.id=e,r.timescale=o.timescale=t,r.codec=i}if(n.audio){const{id:e,timescale:t,codec:i}=n.audio;a.id=e,a.timescale=t,a.codec=i}o.id=Md.text,r.sampleDuration=0,r.duration=a.duration=s}resetContiguity(){this.remainderData=null}static probe(e){return Gd(e=e.length>16384?e.subarray(0,16384):e,["moof"]).length>0}demux(e,t){this.timeOffset=t;let i=e;const s=this.videoTrack,r=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=Vd(this.remainderData,e));const t=function(e){const t={valid:null,remainder:null},i=Gd(e,["moof"]);if(!i)return t;if(i.length<2)return t.remainder=e,t;const s=i[i.length-1];return t.valid=md(e,0,s.byteOffset-8),t.remainder=md(e,s.byteOffset-8),t}(i);this.remainderData=t.remainder,s.samples=t.valid||new Uint8Array}else s.samples=i;const a=this.extractID3Track(s,t);return r.samples=Jd(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,i=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const s=this.extractID3Track(t,this.timeOffset);return i.samples=Jd(e,t),{videoTrack:t,audioTrack:up(),id3Track:s,textTrack:up()}}extractID3Track(e,t){const i=this.id3Track;if(e.samples.length){const s=Gd(e.samples,["emsg"]);s&&s.forEach((e=>{const s=function(e){const t=e[0];let i="",s="",r=0,a=0,o=0,n=0,l=0,h=0;if(0===t){for(;"\0"!==Fd(e.subarray(h,h+1));)i+=Fd(e.subarray(h,h+1)),h+=1;for(i+=Fd(e.subarray(h,h+1)),h+=1;"\0"!==Fd(e.subarray(h,h+1));)s+=Fd(e.subarray(h,h+1)),h+=1;s+=Fd(e.subarray(h,h+1)),h+=1,r=Od(e,12),a=Od(e,16),n=Od(e,20),l=Od(e,24),h=28}else if(1===t){h+=4,r=Od(e,h),h+=4;const t=Od(e,h);h+=4;const a=Od(e,h);for(h+=4,o=2**32*t+a,Number.isSafeInteger(o)||(o=Number.MAX_SAFE_INTEGER,zh.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),n=Od(e,h),h+=4,l=Od(e,h),h+=4;"\0"!==Fd(e.subarray(h,h+1));)i+=Fd(e.subarray(h,h+1)),h+=1;for(i+=Fd(e.subarray(h,h+1)),h+=1;"\0"!==Fd(e.subarray(h,h+1));)s+=Fd(e.subarray(h,h+1)),h+=1;s+=Fd(e.subarray(h,h+1)),h+=1}return{schemeIdUri:i,value:s,timeScale:r,presentationTime:o,presentationTimeDelta:a,eventDuration:n,id:l,payload:e.subarray(h,e.byteLength)}}(e);if(Sp.test(s.schemeIdUri)){const e=Bh(s.presentationTime)?s.presentationTime/s.timeScale:t+s.presentationTimeDelta/s.timeScale;let r=4294967295===s.eventDuration?Number.POSITIVE_INFINITY:s.eventDuration/s.timeScale;r<=.001&&(r=Number.POSITIVE_INFINITY);const a=s.payload;i.samples.push({data:a,len:a.byteLength,dts:e,pts:e,type:Nc,duration:r})}}))}return i}demuxSampleAes(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},remux:class{constructor(){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}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,i,s){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(function(e,t){if(!e||!t)return e;const i=t.keyId;i&&t.isCommonEncryption&&Gd(e,["moov","trak"]).forEach((e=>{const t=Gd(e,["mdia","minf","stbl","stsd"])[0].subarray(8);let s=Gd(t,["enca"]);const r=s.length>0;r||(s=Gd(t,["encv"])),s.forEach((e=>{Gd(r?e.subarray(28):e.subarray(78),["sinf"]).forEach((e=>{const t=Wd(e);if(t){const e=t.subarray(8,24);e.some((e=>0!==e))||(zh.log(`[eme] Patching keyId in 'enc${r?"a":"v"}>sinf>>tenc' box: ${Id(e)} -> ${Id(i)}`),t.set(i,8))}}))}))}));return e}(e,s)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:i}=this;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);const s=this.initData=$d(e);t||(t=af(s.audio,qh)),i||(i=af(s.video,Yh));const r={};s.audio&&s.video?r.audiovideo={container:"video/mp4",codec:t+","+i,initSegment:e,id:"main"}:s.audio?r.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:s.video?r.video={container:"video/mp4",codec:i,initSegment:e,id:"main"}:zh.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=r}remux(e,t,i,s,r,a){var o,n;let{initPTS:l,lastEndTime:h}=this;const d={audio:void 0,video:void 0,text:s,id3:i,initSegment:void 0};Bh(h)||(h=this.lastEndTime=r||0);const c=t.samples;if(null==c||!c.length)return d;const u={initPTS:void 0,timescale:1};let p=this.initData;if(null!=(o=p)&&o.length||(this.generateInitSegment(c),p=this.initData),null==(n=p)||!n.length)return zh.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),d;this.emitInitSegment&&(u.tracks=this.initTracks,this.emitInitSegment=!1);const f=function(e,t){let i=0,s=0,r=0;const a=Gd(e,["moof","traf"]);for(let e=0;e<a.length;e++){const o=a[e],n=Gd(o,["tfhd"])[0],l=t[Od(n,4)];if(!l)continue;const h=l.default,d=Od(n,0)|(null==h?void 0:h.flags);let c=null==h?void 0:h.duration;8&d&&(c=Od(n,2&d?12:8));const u=l.timescale||9e4,p=Gd(o,["trun"]);for(let e=0;e<p.length;e++)i=Hd(p[e]),!i&&c&&(i=c*Od(p[e],4)),l.type===Yh?s+=i/u:l.type===qh&&(r+=i/u)}if(0===s&&0===r){let t=0;const i=Gd(e,["sidx"]);for(let e=0;e<i.length;e++){const s=zd(i[e]);null!=s&&s.references&&(t+=s.references.reduce(((e,t)=>e+t.info.duration||0),0))}return t}return s||r}(c,p),m=function(e,t){return Gd(t,["moof","traf"]).reduce(((t,i)=>{const s=Gd(i,["tfdt"])[0],r=s[0],a=Gd(i,["tfhd"]).reduce(((t,i)=>{const a=Od(i,4),o=e[a];if(o){let e=Od(s,4);if(1===r){if(e===Pd)return zh.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),t;e*=Pd+1,e+=Od(s,8)}const i=e/(o.timescale||9e4);if(isFinite(i)&&(null===t||i<t))return i}return t}),null);return null!==a&&isFinite(a)&&(null===t||a<t)?a:t}),null)}(p,c),g=null===m?r:m;(function(e,t,i,s){if(null===e)return!0;const r=Math.max(s,1),a=t-e.baseTime/e.timescale;return Math.abs(a-i)>r}(l,g,r,f)||u.timescale!==l.timescale&&a)&&(u.initPTS=g-r,l&&1===l.timescale&&zh.warn("Adjusting initPTS by "+(u.initPTS-l.baseTime)),this.initPTS=l={baseTime:u.initPTS,timescale:1});const y=e?g-l.baseTime/l.timescale:h,A=y+f;!function(e,t,i){Gd(t,["moof","traf"]).forEach((t=>{Gd(t,["tfhd"]).forEach((s=>{const r=Od(s,4),a=e[r];if(!a)return;const o=a.timescale||9e4;Gd(t,["tfdt"]).forEach((e=>{const t=e[0];let s=Od(e,4);if(0===t)s-=i*o,s=Math.max(s,0),jd(e,4,s);else{s*=Math.pow(2,32),s+=Od(e,8),s-=i*o,s=Math.max(s,0);const t=Math.floor(s/(Pd+1)),r=Math.floor(s%(Pd+1));jd(e,4,t),jd(e,8,r)}}))}))}))}(p,c,l.baseTime/l.timescale),f>0?this.lastEndTime=A:(zh.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const b=!!p.audio,v=!!p.video;let _="";b&&(_+="audio"),v&&(_+="video");const w={data1:c,startPTS:y,startDTS:y,endPTS:A,endDTS:A,type:_,hasAudio:b,hasVideo:v,nb:1,dropped:0};return d.audio="audio"===w.type?w:void 0,d.video="audio"!==w.type?w:void 0,d.initSegment=u,d.id3=ef(i,r,l,l),s.samples.length&&(d.text=tf(s,r,l)),d}}},{demux:Up,remux:Xp},{demux:class extends pp{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,i,s){super.resetInitSegment(e,t,i,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let t=(Ad(e,0)||[]).length;for(let i=e.length;t<i;t++)if(bp(e,t))return zh.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return function(e,t){return function(e,t){return t+5<e.length}(e,t)&&mp(e,t)&&yp(e,t)<=e.length-t}(e,t)}appendFrame(e,t,i){vp(e,this.observer,t,i,e.manifestCodec);const s=wp(e,t,i,this.basePTS,this.frameIndex);if(s&&0===s.missing)return s}},remux:Xp},{demux:class extends pp{resetInitSegment(e,t,i,s){super.resetInitSegment(e,t,i,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let t=(Ad(e,0)||[]).length;for(let i=e.length;t<i;t++)if(Pp(e,t))return zh.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return function(e,t){return Lp(e,t)&&4<=e.length-t}(e,t)}appendFrame(e,t,i){if(null!==this.basePTS)return Rp(e,t,i,this.basePTS,this.frameIndex)}},remux:Xp}];class nf{constructor(e,t,i,s,r){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=s,this.id=r}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,i,s){const r=i.transmuxing;r.executeStart=qp();let a=new Uint8Array(e);const{currentTransmuxState:o,transmuxConfig:n}=this;s&&(this.currentTransmuxState=s);const{contiguous:l,discontinuity:h,trackSwitch:d,accurateTimeOffset:c,timeOffset:u,initSegmentChange:p}=s||o,{audioCodec:f,videoCodec:m,defaultInitPts:g,duration:y,initSegmentData:A}=n,b=function(e,t){let i=null;e.byteLength>0&&null!=t&&null!=t.key&&null!==t.iv&&null!=t.method&&(i=t);return i}(a,t);if(b&&"AES-128"===b.method){const e=this.getDecrypter();if(!e.isSync())return this.decryptionPromise=e.webCryptoDecrypt(a,b.key.buffer,b.iv.buffer).then((e=>{const t=this.push(e,null,i);return this.decryptionPromise=null,t})),this.decryptionPromise;{let t=e.softwareDecrypt(a,b.key.buffer,b.iv.buffer);if(i.part>-1&&(t=e.flush()),!t)return r.executeEnd=qp(),lf(i);a=new Uint8Array(t)}}const v=this.needsProbing(h,d);if(v){const e=this.configureTransmuxer(a);if(e)return zh.warn(`[transmuxer] ${e.message}`),this.observer.emit(Mh.ERROR,Mh.ERROR,{type:Fh.MEDIA_ERROR,details:Uh.FRAG_PARSING_ERROR,fatal:!1,error:e,reason:e.message}),r.executeEnd=qp(),lf(i)}(h||d||p||v)&&this.resetInitSegment(A,f,m,y,t),(h||p||v)&&this.resetInitialTimestamp(g),l||this.resetContiguity();const _=this.transmux(a,b,u,c,i),w=this.currentTransmuxState;return w.contiguous=!0,w.discontinuity=!1,w.trackSwitch=!1,r.executeEnd=qp(),_}flush(e){const t=e.transmuxing;t.executeStart=qp();const{decrypter:i,currentTransmuxState:s,decryptionPromise:r}=this;if(r)return r.then((()=>this.flush(e)));const a=[],{timeOffset:o}=s;if(i){const t=i.flush();t&&a.push(this.push(t,null,e))}const{demuxer:n,remuxer:l}=this;if(!n||!l)return t.executeEnd=qp(),[lf(e)];const h=n.flush(o);return hf(h)?h.then((t=>(this.flushRemux(a,t,e),a))):(this.flushRemux(a,h,e),a)}flushRemux(e,t,i){const{audioTrack:s,videoTrack:r,id3Track:a,textTrack:o}=t,{accurateTimeOffset:n,timeOffset:l}=this.currentTransmuxState;zh.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${i.part>-1?" p: "+i.part:""} of level ${i.level}`);const h=this.remuxer.remux(s,r,a,o,l,n,!0,this.id);e.push({remuxResult:h,chunkMeta:i}),i.transmuxing.executeEnd=qp()}resetInitialTimestamp(e){const{demuxer:t,remuxer:i}=this;t&&i&&(t.resetTimeStamp(e),i.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,i,s,r){const{demuxer:a,remuxer:o}=this;a&&o&&(a.resetInitSegment(e,t,i,s),o.resetInitSegment(e,t,i,r))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,i,s,r){let a;return a=t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,i,s,r):this.transmuxUnencrypted(e,i,s,r),a}transmuxUnencrypted(e,t,i,s){const{audioTrack:r,videoTrack:a,id3Track:o,textTrack:n}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(r,a,o,n,t,i,!1,this.id),chunkMeta:s}}transmuxSampleAes(e,t,i,s,r){return this.demuxer.demuxSampleAes(e,t,i).then((e=>({remuxResult:this.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,i,s,!1,this.id),chunkMeta:r})))}configureTransmuxer(e){const{config:t,observer:i,typeSupported:s,vendor:r}=this;let a;for(let t=0,i=of.length;t<i;t++)if(of[t].demux.probe(e)){a=of[t];break}if(!a)return new Error("Failed to find demuxer by probing fragment data");const o=this.demuxer,n=this.remuxer,l=a.remux,h=a.demux;n&&n instanceof l||(this.remuxer=new l(i,t,s,r)),o&&o instanceof h||(this.demuxer=new h(i,t,s),this.probe=h.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Yu(this.config)),e}}const lf=e=>({remuxResult:{},chunkMeta:e});function hf(e){return"then"in e&&e.then instanceof Function}class df{constructor(e,t,i,s,r){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=s,this.defaultInitPts=r||null}}class cf{constructor(e,t,i,s,r,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=s,this.timeOffset=r,this.initSegmentChange=a}}var uf={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,i="~";function s(){}function r(e,t,i){this.fn=e,this.context=t,this.once=i||!1}function a(e,t,s,a,o){if("function"!=typeof s)throw new TypeError("The listener must be a function");var n=new r(s,a||e,o),l=i?i+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],n]:e._events[l].push(n):(e._events[l]=n,e._eventsCount++),e}function o(e,t){0==--e._eventsCount?e._events=new s:delete e._events[t]}function n(){this._events=new s,this._eventsCount=0}Object.create&&(s.prototype=Object.create(null),(new s).__proto__||(i=!1)),n.prototype.eventNames=function(){var e,s,r=[];if(0===this._eventsCount)return r;for(s in e=this._events)t.call(e,s)&&r.push(i?s.slice(1):s);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},n.prototype.listeners=function(e){var t=i?i+e:e,s=this._events[t];if(!s)return[];if(s.fn)return[s.fn];for(var r=0,a=s.length,o=new Array(a);r<a;r++)o[r]=s[r].fn;return o},n.prototype.listenerCount=function(e){var t=i?i+e:e,s=this._events[t];return s?s.fn?1:s.length:0},n.prototype.emit=function(e,t,s,r,a,o){var n=i?i+e:e;if(!this._events[n])return!1;var l,h,d=this._events[n],c=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),c){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,s),!0;case 4:return d.fn.call(d.context,t,s,r),!0;case 5:return d.fn.call(d.context,t,s,r,a),!0;case 6:return d.fn.call(d.context,t,s,r,a,o),!0}for(h=1,l=new Array(c-1);h<c;h++)l[h-1]=arguments[h];d.fn.apply(d.context,l)}else{var u,p=d.length;for(h=0;h<p;h++)switch(d[h].once&&this.removeListener(e,d[h].fn,void 0,!0),c){case 1:d[h].fn.call(d[h].context);break;case 2:d[h].fn.call(d[h].context,t);break;case 3:d[h].fn.call(d[h].context,t,s);break;case 4:d[h].fn.call(d[h].context,t,s,r);break;default:if(!l)for(u=1,l=new Array(c-1);u<c;u++)l[u-1]=arguments[u];d[h].fn.apply(d[h].context,l)}}return!0},n.prototype.on=function(e,t,i){return a(this,e,t,i,!1)},n.prototype.once=function(e,t,i){return a(this,e,t,i,!0)},n.prototype.removeListener=function(e,t,s,r){var a=i?i+e:e;if(!this._events[a])return this;if(!t)return o(this,a),this;var n=this._events[a];if(n.fn)n.fn!==t||r&&!n.once||s&&n.context!==s||o(this,a);else{for(var l=0,h=[],d=n.length;l<d;l++)(n[l].fn!==t||r&&!n[l].once||s&&n[l].context!==s)&&h.push(n[l]);h.length?this._events[a]=1===h.length?h[0]:h:o(this,a)}return this},n.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&o(this,t)):(this._events=new s,this._eventsCount=0),this},n.prototype.off=n.prototype.removeListener,n.prototype.addListener=n.prototype.on,n.prefixed=i,n.EventEmitter=n,e.exports=n}(uf);var pf=wh(uf.exports);const ff=oc()||{isTypeSupported:()=>!1};class mf{constructor(e,t,i,s){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;const r=e.config;this.hls=e,this.id=t,this.useWorker=!!r.enableWorker,this.onTransmuxComplete=i,this.onFlush=s;const a=(e,t)=>{(t=t||{}).frag=this.frag,t.id=this.id,e===Mh.ERROR&&(this.error=t.error),this.hls.trigger(e,t)};this.observer=new pf,this.observer.on(Mh.FRAG_DECRYPTED,a),this.observer.on(Mh.ERROR,a);const o={mp4:ff.isTypeSupported("video/mp4"),mpeg:ff.isTypeSupported("audio/mpeg"),mp3:ff.isTypeSupported('audio/mp4; codecs="mp3"')},n=navigator.vendor;if(this.useWorker&&"undefined"!=typeof Worker){if(r.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{r.workerPath?(zh.log(`loading Web Worker ${r.workerPath} for "${t}"`),this.workerContext=function(e){const t=new self.URL(e,self.location.href).href;return{worker:new self.Worker(t),scriptURL:t}}(r.workerPath)):(zh.log(`injecting Web Worker for "${t}"`),this.workerContext=function(){const e=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),t=self.URL.createObjectURL(e);return{worker:new self.Worker(t),objectURL:t}}()),this.onwmsg=e=>this.onWorkerMessage(e);const{worker:e}=this.workerContext;e.addEventListener("message",this.onwmsg),e.onerror=e=>{const i=new Error(`${e.message} (${e.filename}:${e.lineno})`);r.enableWorker=!1,zh.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(Mh.ERROR,{type:Fh.OTHER_ERROR,details:Uh.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:i})},e.postMessage({cmd:"init",typeSupported:o,vendor:n,id:t,config:JSON.stringify(r)})}catch(e){zh.warn(`Error setting up "${t}" Web Worker, fallback to inline`,e),this.resetWorker(),this.error=null,this.transmuxer=new nf(this.observer,o,r,n,t)}return}}this.transmuxer=new nf(this.observer,o,r,n,t)}resetWorker(){if(this.workerContext){const{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,i,s,r,a,o,n,l,h){var d,c;l.transmuxing.start=self.performance.now();const{transmuxer:u}=this,p=a?a.start:r.start,f=r.decryptdata,m=this.frag,g=!(m&&r.cc===m.cc),y=!(m&&l.level===m.level),A=m?l.sn-m.sn:-1,b=this.part?l.part-this.part.index:-1,v=0===A&&l.id>1&&l.id===(null==m?void 0:m.stats.chunkCount),_=!y&&(1===A||0===A&&(1===b||v&&b<=0)),w=self.performance.now();(y||A||0===r.stats.parsing.start)&&(r.stats.parsing.start=w),!a||!b&&_||(a.stats.parsing.start=w);const S=!(m&&(null==(d=r.initSegment)?void 0:d.url)===(null==(c=m.initSegment)?void 0:c.url)),T=new cf(g,_,n,y,p,S);if(!_||g||S){zh.log(`[transmuxer-interface, ${r.type}]: Starting new transmux session for sn: ${l.sn} p: ${l.part} level: ${l.level} id: ${l.id}\n discontinuity: ${g}\n trackSwitch: ${y}\n contiguous: ${_}\n accurateTimeOffset: ${n}\n timeOffset: ${p}\n initSegmentChange: ${S}`);const e=new df(i,s,t,o,h);this.configureTransmuxer(e)}if(this.frag=r,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:f,chunkMeta:l,state:T},e instanceof ArrayBuffer?[e]:[]);else if(u){const t=u.push(e,f,l,T);hf(t)?(u.async=!0,t.then((e=>{this.handleTransmuxComplete(e)})).catch((e=>{this.transmuxerError(e,l,"transmuxer-interface push error")}))):(u.async=!1,this.handleTransmuxComplete(t))}}flush(e){e.transmuxing.start=self.performance.now();const{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let i=t.flush(e);hf(i)||t.async?(hf(i)||(i=Promise.resolve(i)),i.then((t=>{this.handleFlushResult(t,e)})).catch((t=>{this.transmuxerError(t,e,"transmuxer-interface flush error")}))):this.handleFlushResult(i,e)}}transmuxerError(e,t,i){this.hls&&(this.error=e,this.hls.trigger(Mh.ERROR,{type:Fh.MEDIA_ERROR,details:Uh.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:i}))}handleFlushResult(e,t){e.forEach((e=>{this.handleTransmuxComplete(e)})),this.onFlush(t)}onWorkerMessage(e){const t=e.data,i=this.hls;switch(t.event){case"init":{var s;const e=null==(s=this.workerContext)?void 0:s.objectURL;e&&self.URL.revokeObjectURL(e);break}case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":zh[t.data.logType]&&zh[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)}}configureTransmuxer(e){const{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}class gf{constructor(e,t,i,s){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=i,this.hls=s}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){const{config:i,media:s,stalled:r}=this;if(null===s)return;const{currentTime:a,seeking:o}=s,n=this.seeking&&!o,l=!this.seeking&&o;if(this.seeking=o,a!==e){if(this.moved=!0,null!==r){if(this.stallReported){const e=self.performance.now()-r;zh.warn(`playback not stuck anymore @${a}, after ${Math.round(e)}ms`),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if(l||n)return void(this.stalled=null);if(s.paused&&!o||s.ended||0===s.playbackRate||!ju.getBuffered(s).length)return;const h=ju.bufferInfo(s,a,0),d=h.len>0,c=h.nextStart||0;if(!d&&!c)return;if(o){const e=h.len>2,i=!c||t&&t.start<=a||c-a>2&&!this.fragmentTracker.getPartialFragment(a);if(e||i)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var u;const e=Math.max(c,h.start||0)-a,t=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,i=(null==t||null==(u=t.details)?void 0:u.live)?2*t.details.targetduration:2,s=this.fragmentTracker.getPartialFragment(a);if(e>0&&(e<=i||s))return void this._trySkipBufferHole(s)}const p=self.performance.now();if(null===r)return void(this.stalled=p);const f=p-r;if(!o&&f>=250&&(this._reportStall(h),!this.media))return;const m=ju.bufferInfo(s,a,i.maxBufferHole);this._tryFixBufferStall(m,f)}_tryFixBufferStall(e,t){const{config:i,fragmentTracker:s,media:r}=this;if(null===r)return;const a=r.currentTime,o=s.getPartialFragment(a);if(o){if(this._trySkipBufferHole(o)||!this.media)return}(e.len>i.maxBufferHole||e.nextStart&&e.nextStart-a<i.maxBufferHole)&&t>1e3*i.highBufferWatchdogPeriod&&(zh.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){const{hls:t,media:i,stallReported:s}=this;if(!s&&i){this.stallReported=!0;const s=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${JSON.stringify(e)})`);zh.warn(s.message),t.trigger(Mh.ERROR,{type:Fh.MEDIA_ERROR,details:Uh.BUFFER_STALLED_ERROR,fatal:!1,error:s,buffer:e.len})}}_trySkipBufferHole(e){const{config:t,hls:i,media:s}=this;if(null===s)return 0;const r=s.currentTime,a=ju.bufferInfo(s,r,0),o=r<a.start?a.start:a.nextStart;if(o){const n=a.len<=t.maxBufferHole,l=a.len>0&&a.len<1&&s.readyState<3,h=o-r;if(h>0&&(n||l)){if(h>t.maxBufferHole){const{fragmentTracker:t}=this;let i=!1;if(0===r){const e=t.getAppendedFrag(0,Cc);e&&o<e.end&&(i=!0)}if(!i){const i=e||t.getAppendedFrag(r,Cc);if(i){let e=!1,s=i.end;for(;s<o;){const i=t.getPartialFragment(s);if(!i){e=!0;break}s+=i.duration}if(e)return 0}}}const a=Math.max(o+.05,r+.1);if(zh.warn(`skipping hole, adjusting currentTime from ${r} to ${a}`),this.moved=!0,this.stalled=null,s.currentTime=a,e&&!e.gap){const t=new Error(`fragment loaded with buffer holes, seeking from ${r} to ${a}`);i.trigger(Mh.ERROR,{type:Fh.MEDIA_ERROR,details:Uh.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:t,reason:t.message,frag:e})}return a}}return 0}_tryNudgeBuffer(){const{config:e,hls:t,media:i,nudgeRetry:s}=this;if(null===i)return;const r=i.currentTime;if(this.nudgeRetry++,s<e.nudgeMaxRetry){const a=r+(s+1)*e.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${r} to ${a}`);zh.warn(o.message),i.currentTime=a,t.trigger(Mh.ERROR,{type:Fh.MEDIA_ERROR,details:Uh.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{const i=new Error(`Playhead still not moving while enough data buffered @${r} after ${e.nudgeMaxRetry} nudges`);zh.error(i.message),t.trigger(Mh.ERROR,{type:Fh.MEDIA_ERROR,details:Uh.BUFFER_STALLED_ERROR,error:i,fatal:!0})}}}class yf extends dp{constructor(e,t,i){super(e,t,i,"[stream-controller]",Cc),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(Mh.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Mh.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Mh.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Mh.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Mh.LEVEL_LOADING,this.onLevelLoading,this),e.on(Mh.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Mh.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(Mh.ERROR,this.onError,this),e.on(Mh.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(Mh.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(Mh.BUFFER_CREATED,this.onBufferCreated,this),e.on(Mh.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(Mh.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Mh.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(Mh.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Mh.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Mh.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Mh.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Mh.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Mh.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(Mh.ERROR,this.onError,this),e.off(Mh.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(Mh.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(Mh.BUFFER_CREATED,this.onBufferCreated,this),e.off(Mh.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(Mh.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Mh.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),this.onMediaDetaching()}startLoad(e){if(this.levels){const{lastCurrentTime:t,hls:i}=this;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){let e=i.startLevel;-1===e&&(i.config.testBandwidth&&this.levels.length>1?(e=0,this.bitrateTest=!0):e=i.nextAutoLevel),this.level=i.nextLoadLevel=e,this.loadedmetadata=!1}t>0&&-1===e&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=Zu,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=Xu}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case hp:{var e;const{levels:t,level:i}=this,s=null==t||null==(e=t[i])?void 0:e.details;if(s&&(!s.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(s))break;this.state=Zu;break}if(this.hls.nextLoadLevel!==this.level){this.state=Zu;break}break}case ip:{var t;const e=self.performance.now(),i=this.retryDate;(!i||e>=i||null!=(t=this.media)&&t.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=Zu)}}this.state===Zu&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:i,media:s}=this,{config:r,nextLoadLevel:a}=e;if(null===t||!s&&(this.startFragRequested||!r.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(null==i||!i[a])return;const o=i[a],n=this.getMainFwdBufferInfo();if(null===n)return;const l=this.getLevelDetails();if(l&&this._streamEnded(n,l)){const e={};return this.altAudio&&(e.type="video"),this.hls.trigger(Mh.BUFFER_EOS,e),void(this.state=op)}e.loadLevel!==a&&-1===e.manualLevel&&this.log(`Adapting to level ${a} from level ${this.level}`),this.level=e.nextLoadLevel=a;const h=o.details;if(!h||this.state===hp||h.live&&this.levelLastLoaded!==a)return this.level=a,void(this.state=hp);const d=n.len,c=this.getMaxBufferLength(o.maxBitrate);if(d>=c)return;this.backtrackFragment&&this.backtrackFragment.start>n.end&&(this.backtrackFragment=null);const u=this.backtrackFragment?this.backtrackFragment.start:n.end;let p=this.getNextFragment(u,h);if(this.couldBacktrack&&!this.fragPrevious&&p&&"initSegment"!==p.sn&&this.fragmentTracker.getState(p)!==xu){var f;const e=(null!=(f=this.backtrackFragment)?f:p).sn-h.startSN,t=h.fragments[e-1];t&&p.cc===t.cc&&(p=t,this.fragmentTracker.removeFragment(t))}else this.backtrackFragment&&n.len&&(this.backtrackFragment=null);if(p&&this.isLoopLoading(p,u)){if(!p.gap){const e=this.audioOnly&&!this.altAudio?qh:Yh,t=(e===Yh?this.videoBuffer:this.mediaBuffer)||this.media;t&&this.afterBufferFlushed(t,e,Cc)}p=this.getNextFragmentLoopLoading(p,h,n,Cc,c)}p&&(!p.initSegment||p.initSegment.data||this.bitrateTest||(p=p.initSegment),this.loadFragment(p,o,u))}loadFragment(e,t,i){const s=this.fragmentTracker.getState(e);this.fragCurrent=e,s===Eu||s===Cu?"initSegment"===e.sn?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,i)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,Cc)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(null!=t&&t.readyState){let i;const s=this.getAppendedFrag(t.currentTime);s&&s.start>1&&this.flushMainBuffer(0,s.start-1);const r=this.getLevelDetails();if(null!=r&&r.live){const e=this.getMainFwdBufferInfo();if(!e||e.len<2*r.targetduration)return}if(!t.paused&&e){const t=e[this.hls.nextLoadLevel],s=this.fragLastKbps;i=s&&this.fragCurrent?this.fragCurrent.duration*t.maxBitrate/(1e3*s)+1:0}else i=0;const a=this.getBufferedFrag(t.currentTime+i);if(a){const e=this.followingBufferedFrag(a);if(e){this.abortCurrentFrag();const t=e.maxStartPTS?e.maxStartPTS:e.start,i=e.duration,s=Math.max(a.end,t+Math.min(Math.max(i-this.config.maxFragLookUpTolerance,.5*i),.75*i));this.flushMainBuffer(s,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case ep:case tp:case ip:case rp:case ap:this.state=Zu}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const i=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new gf(this.config,i,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const e=this.media,t=e?e.currentTime:null;Bh(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);const i=this.getMainFwdBufferInfo();null!==i&&0!==i.len?this.tick():this.warn(`Main forward buffer length on "seeked" event ${i?i.len:"empty"})`)}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(Mh.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1}onManifestParsed(e,t){let i,s=!1,r=!1;t.levels.forEach((e=>{i=e.audioCodec,i&&(-1!==i.indexOf("mp4a.40.2")&&(s=!0),-1!==i.indexOf("mp4a.40.5")&&(r=!0))})),this.audioCodecSwitch=s&&r&&!function(){var e;const t=cp();return"function"==typeof(null==t||null==(e=t.prototype)?void 0:e.changeType)}(),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}onLevelLoading(e,t){const{levels:i}=this;if(!i||this.state!==Zu)return;const s=i[t.level];(!s.details||s.details.live&&this.levelLastLoaded!==t.level||this.waitForCdnTuneIn(s.details))&&(this.state=hp)}onLevelLoaded(e,t){var i;const{levels:s}=this,r=t.level,a=t.details,o=a.totalduration;if(!s)return void this.warn(`Levels were reset while loading level ${r}`);this.log(`Level ${r} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);const n=s[r],l=this.fragCurrent;!l||this.state!==tp&&this.state!==ip||l.level===t.level&&l.urlId===n.urlId||!l.loader||this.abortCurrentFrag();let h=0;if(a.live||null!=(i=n.details)&&i.live){if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;h=this.alignPlaylists(a,n.details)}if(n.details=a,this.levelLastLoaded=r,this.hls.trigger(Mh.LEVEL_UPDATED,{details:a,level:r}),this.state===hp){if(this.waitForCdnTuneIn(a))return;this.state=Zu}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,h),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:i,part:s,payload:r}=e,{levels:a}=this;if(!a)return void this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);const o=a[i.level],n=o.details;if(!n)return this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),void this.fragmentTracker.removeFragment(i);const l=o.videoCodec,h=n.PTSKnown||!n.live,d=null==(t=i.initSegment)?void 0:t.data,c=this._getAudioCodec(o),u=this.transmuxer=this.transmuxer||new mf(this.hls,Cc,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),p=s?s.index:-1,f=-1!==p,m=new Gu(i.level,i.sn,i.stats.chunkCount,r.byteLength,p,f),g=this.initPTS[i.cc];u.push(r,d,c,l,i,s,n.totalduration,h,m,g)}onAudioTrackSwitching(e,t){const 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;const e=this.fragCurrent;e&&(this.log("Switching to main audio track, cancel main fragment load"),e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const e=this.hls;i&&(e.trigger(Mh.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),e.trigger(Mh.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const i=t.id,s=!!this.hls.audioTracks[i].url;if(s){const e=this.videoBuffer;e&&this.mediaBuffer!==e&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=e)}this.altAudio=s,this.tick()}onBufferCreated(e,t){const i=t.tracks;let s,r,a=!1;for(const e in i){const t=i[e];if("main"===t.id){if(r=e,s=t,"video"===e){const t=i[e];t&&(this.videoBuffer=t.buffer)}}else a=!0}a&&s?(this.log(`Alternate track found, use ${r}.buffered to schedule main fragment loading`),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:i,part:s}=t;if(i&&i.type!==Cc)return;if(this.fragContextChanged(i))return this.warn(`Fragment ${i.sn}${s?" p: "+s.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),void(this.state===ap&&(this.state=Zu));const r=s?s.stats:i.stats;this.fragLastKbps=Math.round(8*r.total/(r.buffering.end-r.loading.first)),"initSegment"!==i.sn&&(this.fragPrevious=i),this.fragBufferedComplete(i,s)}onError(e,t){var i;if(t.fatal)this.state=np;else switch(t.details){case Uh.FRAG_GAP:case Uh.FRAG_PARSING_ERROR:case Uh.FRAG_DECRYPT_ERROR:case Uh.FRAG_LOAD_ERROR:case Uh.FRAG_LOAD_TIMEOUT:case Uh.KEY_LOAD_ERROR:case Uh.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Cc,t);break;case Uh.LEVEL_LOAD_ERROR:case Uh.LEVEL_LOAD_TIMEOUT:case Uh.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==hp||(null==(i=t.context)?void 0:i.type)!==Tc||(this.state=Zu);break;case Uh.BUFFER_FULL_ERROR:if(!t.parent||"main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case Uh.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}checkBuffer(){const{media:e,gapController:t}=this;if(e&&t&&e.readyState){if(this.loadedmetadata||!ju.getBuffered(e).length){const e=this.state!==Zu?this.fragCurrent:null;t.poll(this.lastCurrentTime,e)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=Zu,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==qh||this.audioOnly&&!this.altAudio){const e=(t===Yh?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(e,t,Cc)}}onLevelsUpdated(e,t){this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let i=this.startPosition;if(i>=0&&t<i){if(e.seeking)return void this.log(`could not seek to ${i}, already seeking at ${t}`);const s=ju.getBuffered(e),r=(s.length?s.start(0):0)-i;r>0&&(r<this.config.maxBufferHole||r<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${r} to match buffer start`),i+=r,this.startPosition=i),this.log(`seek to target start position ${i} from current time ${t}`),e.currentTime=i}}_getAudioCodec(e){let 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}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then((i=>{const{hls:s}=this;if(!i||this.fragContextChanged(e))return;t.fragmentError=0,this.state=Zu,this.startFragRequested=!1,this.bitrateTest=!1;const r=e.stats;r.parsing.start=r.parsing.end=r.buffering.start=r.buffering.end=self.performance.now(),s.trigger(Mh.FRAG_LOADED,i),e.bitrateTest=!1}))}_handleTransmuxComplete(e){var t;const i="main",{hls:s}=this,{remuxResult:r,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o)return void this.resetWhenMissingContext(a);const{frag:n,part:l,level:h}=o,{video:d,text:c,id3:u,initSegment:p}=r,{details:f}=h,m=this.altAudio?void 0:r.audio;if(this.fragContextChanged(n))this.fragmentTracker.removeFragment(n);else{if(this.state=rp,p){if(null!=p&&p.tracks){const e=n.initSegment||n;this._bufferInitSegment(h,p.tracks,e,a),s.trigger(Mh.FRAG_PARSING_INIT_SEGMENT,{frag:e,id:i,tracks:p.tracks})}const e=p.initPTS,t=p.timescale;Bh(e)&&(this.initPTS[n.cc]={baseTime:e,timescale:t},s.trigger(Mh.INIT_PTS_FOUND,{frag:n,id:i,initPTS:e,timescale:t}))}if(d&&f&&"initSegment"!==n.sn){const e=f.fragments[n.sn-1-f.startSN],t=n.sn===f.startSN,i=!e||n.cc>e.cc;if(!1!==r.independent){const{startPTS:e,endPTS:s,startDTS:r,endDTS:o}=d;if(l)l.elementaryStreams[d.type]={startPTS:e,endPTS:s,startDTS:r,endDTS:o};else if(d.firstKeyFrame&&d.independent&&1===a.id&&!i&&(this.couldBacktrack=!0),d.dropped&&d.independent){const r=this.getMainFwdBufferInfo(),a=(r?r.end:this.getLoadPosition())+this.config.maxBufferHole,l=d.firstKeyFramePTS?d.firstKeyFramePTS:e;if(!t&&a<l-this.config.maxBufferHole&&!i)return void this.backtrack(n);i&&(n.gap=!0),n.setElementaryStreamInfo(d.type,n.start,s,n.start,o,!0)}n.setElementaryStreamInfo(d.type,e,s,r,o),this.backtrackFragment&&(this.backtrackFragment=n),this.bufferFragmentData(d,n,l,a,t||i)}else{if(!t&&!i)return void this.backtrack(n);n.gap=!0}}if(m){const{startPTS:e,endPTS:t,startDTS:i,endDTS:s}=m;l&&(l.elementaryStreams[qh]={startPTS:e,endPTS:t,startDTS:i,endDTS:s}),n.setElementaryStreamInfo(qh,e,t,i,s),this.bufferFragmentData(m,n,l,a)}if(f&&null!=u&&null!=(t=u.samples)&&t.length){const e={id:i,frag:n,details:f,samples:u.samples};s.trigger(Mh.FRAG_PARSING_METADATA,e)}if(f&&c){const e={id:i,frag:n,details:f,samples:c.samples};s.trigger(Mh.FRAG_PARSING_USERDATA,e)}}}_bufferInitSegment(e,t,i,s){if(this.state!==rp)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;const{audio:r,video:a,audiovideo:o}=t;if(r){let t=e.audioCodec;const i=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(t&&(t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),1!==r.metadata.channelCount&&-1===i.indexOf("firefox")&&(t="mp4a.40.5")),-1!==i.indexOf("android")&&"audio/mpeg"!==r.container&&(t="mp4a.40.2",this.log(`Android: force audio codec to ${t}`)),e.audioCodec&&e.audioCodec!==t&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${t}"`),r.levelCodec=t,r.id="main",this.log(`Init audio buffer, container:${r.container}, codecs[selected/level/parsed]=[${t||""}/${e.audioCodec||""}/${r.codec}]`)}a&&(a.levelCodec=e.videoCodec,a.id="main",this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${a.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.attrs.CODECS||""}/${o.codec}]`),this.hls.trigger(Mh.BUFFER_CODECS,t),Object.keys(t).forEach((e=>{const r=t[e].initSegment;null!=r&&r.byteLength&&this.hls.trigger(Mh.BUFFER_APPENDING,{type:e,data:r,frag:i,part:null,chunkMeta:s,parent:i.type})})),this.tick()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,Cc)}backtrack(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=Zu}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&!1===e.seeking){const i=e.currentTime;if(ju.isBuffered(e,i)?t=this.getAppendedFrag(i):ju.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;const e=this.fragPlaying,i=t.level;e&&t.sn===e.sn&&e.level===i&&t.urlId===e.urlId||(this.fragPlaying=t,this.hls.trigger(Mh.FRAG_CHANGED,{frag:t}),e&&e.level===i||this.hls.trigger(Mh.LEVEL_SWITCHED,{level:i}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){const e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){const e=this.media;if(e){const t=e.currentTime,i=this.currentFrag;if(i&&Bh(t)&&Bh(i.programDateTime)){const e=i.programDateTime+1e3*(t-i.start);return new Date(e)}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class Af{constructor(e,t=0,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}sample(e,t){const i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class bf{constructor(e,t,i,s=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 Af(e),this.fast_=new Af(t),this.defaultTTFB_=s,this.ttfb_=new Af(e)}update(e,t){const{slow_:i,fast_:s,ttfb_:r}=this;i.halfLife!==e&&(this.slow_=new Af(e,i.getEstimate(),i.getTotalWeight())),s.halfLife!==t&&(this.fast_=new Af(t,s.getEstimate(),s.getTotalWeight())),r.halfLife!==e&&(this.ttfb_=new Af(e,r.getEstimate(),r.getTotalWeight()))}sample(e,t){const i=(e=Math.max(e,this.minDelayMs_))/1e3,s=8*t/i;this.fast_.sample(i,s),this.slow_.sample(i,s)}sampleTTFB(e){const t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}}class vf{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let i;return e.length?(i=1===e.length?e[0]:function(e,t){const i=new Uint8Array(t);let s=0;for(let t=0;t<e.length;t++){const r=e[t];i.set(r,s),s+=r.length}return i}(e,t),this.reset(),i):new Uint8Array(0)}reset(){this.chunks.length=0,this.dataLength=0}}function _f(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!wf(e[i].attrs,t[i].attrs))return!1;return!0}function wf(e,t){const i=e["STABLE-RENDITION-ID"];return i?i===t["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some((i=>e[i]!==t[i]))}class Sf{constructor(e){this.buffered=void 0;const t=(t,i,s)=>{if((i>>>=0)>s-1)throw new DOMException(`Failed to execute '${t}' on 'TimeRanges': The index provided (${i}) is greater than the maximum bound (${s})`);return e[i][t]};this.buffered={get length(){return e.length},end:i=>t("end",i,e.length),start:i=>t("start",i,e.length)}}}function Tf(e){const t=[];for(let i=0;i<e.length;i++){const s=e[i];"subtitles"!==s.kind&&"captions"!==s.kind||!s.label||t.push(e[i])}return t}class Ef{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t){const i=this.queues[t];i.push(e),1===i.length&&this.buffers[t]&&this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t;const i=new Promise((e=>{t=e})),s={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(s,e),i}executeNext(e){const{buffers:t,queues:i}=this,s=t[e],r=i[e];if(r.length){const t=r[0];try{t.execute()}catch(i){zh.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),t.onError(i),null!=s&&s.updating||(r.shift(),this.executeNext(e))}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}}const kf=oc(),Cf=/([ha]vc.)(?:\.[^.,]+)+/;const xf={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},Rf=function(e){let t=e;return xf.hasOwnProperty(e)&&(t=xf[e]),String.fromCharCode(t)},Df=15,Lf=100,If={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Pf={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Bf={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Mf={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Ff=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class Uf{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const i="function"==typeof t?t():t;zh.log(`${this.time} [${e}] ${i}`)}}}const Of=function(e){const t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t};class Nf{constructor(e,t,i,s,r){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=e||"white",this.underline=t||!1,this.italics=i||!1,this.background=s||"black",this.flash=r||!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){const t=["foreground","underline","italics","background","flash"];for(let i=0;i<t.length;i++){const s=t[i];e.hasOwnProperty(s)&&(this[s]=e[s])}}isDefault(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class jf{constructor(e,t,i,s,r,a){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new Nf(t,i,s,r,a)}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return" "===this.uchar&&this.penState.isDefault()}}class Gf{constructor(e){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(let e=0;e<Lf;e++)this.chars.push(new jf);this.logger=e,this.pos=0,this.currPenState=new Nf}equals(e){let t=!0;for(let i=0;i<Lf;i++)if(!this.chars[i].equals(e.chars[i])){t=!1;break}return t}copy(e){for(let t=0;t<Lf;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<Lf;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>Lf&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Lf)}moveCursor(e){const t=this.pos+e;if(e>1)for(let e=this.pos+1;e<t+1;e++)this.chars[e].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();const t=Rf(e);this.pos>=Lf?this.logger.log(0,(()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!")):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))}clearFromPos(e){let t;for(t=e;t<Lf;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const e=[];let t=!0;for(let i=0;i<Lf;i++){const s=this.chars[i].uchar;" "!==s&&(t=!1),e.push(s)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e);this.chars[this.pos].setPenState(this.currPenState)}}class zf{constructor(e){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(let t=0;t<Df;t++)this.rows.push(new Gf(e));this.logger=e,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let e=0;e<Df;e++)this.rows[e].clear();this.currRow=14}equals(e){let t=!0;for(let i=0;i<Df;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}copy(e){for(let t=0;t<Df;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<Df;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e);this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,(()=>"pacData = "+JSON.stringify(e)));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let e=0;e<Df;e++)this.rows[e].clear();const e=this.currRow+1-this.nrRollUpRows,i=this.lastOutputScreen;if(i){const s=i.rows[e].cueStartTime,r=this.logger.time;if(s&&null!==r&&s<r)for(let s=0;s<this.nrRollUpRows;s++)this.rows[t-this.nrRollUpRows+s+1].copy(i.rows[e+s])}}this.currRow=t;const i=this.rows[this.currRow];if(null!==e.indent){const t=e.indent,s=Math.max(t-1,0);i.setCursor(e.indent),e.color=i.chars[s].penState.foreground}const s={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(s)}setBkgData(e){this.logger.log(2,(()=>"bkgData = "+JSON.stringify(e))),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(null===this.nrRollUpRows)return void this.logger.log(3,"roll_up but nrRollUpRows not set yet");this.logger.log(1,(()=>this.getDisplayText()));const e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;const t=[];let i="",s=-1;for(let i=0;i<Df;i++){const r=this.rows[i].getTextString();r&&(s=i+1,e?t.push("Row "+s+": '"+r+"'"):t.push(r.trim()))}return t.length>0&&(i=e?"["+t.join(" | ")+"]":t.join("\n")),i}getTextAndFormat(){return this.rows}}class $f{constructor(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 zf(i),this.nonDisplayedMemory=new zf(i),this.lastOutputScreen=new zf(i),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,(()=>"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)}insertChars(e){for(let t=0;t<e.length;t++)this.writeScreen.insertChar(e[t]);const t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,(()=>t+": "+this.writeScreen.getDisplayText(!0))),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(1,(()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0))),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){const e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,(()=>"DISP: "+this.displayedMemory.getDisplayText()))}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){const t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{const i=Math.floor(e/2)-16,s=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=s[i]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){const 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))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}class Wf{constructor(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;const s=new Uf;this.channels=[null,new $f(e,t,s),new $f(e+1,i,s)],this.cmdHistory={a:null,b:null},this.logger=s}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){let i,s,r,a=!1;this.logger.time=e;for(let e=0;e<t.length;e+=2)if(s=127&t[e],r=127&t[e+1],0!==s||0!==r){if(this.logger.log(3,"["+Of([t[e],t[e+1]])+"] -> ("+Of([s,r])+")"),i=this.parseCmd(s,r),i||(i=this.parseMidrow(s,r)),i||(i=this.parsePAC(s,r)),i||(i=this.parseBackgroundAttributes(s,r)),!i&&(a=this.parseChars(s,r),a)){const e=this.currentChannel;if(e&&e>0){this.channels[e].insertChars(a)}else this.logger.log(2,"No channel found yet. TEXT-MODE?")}i||a||this.logger.log(2,"Couldn't parse cleaned data "+Of([s,r])+" orig: "+Of([t[e],t[e+1]]))}}parseCmd(e,t){const{cmdHistory:i}=this;if(!((20===e||28===e||21===e||29===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=33&&t<=35))return!1;if(Vf(e,t,i))return Hf(null,null,i),this.logger.log(3,"Repeated command ("+Of([e,t])+") is dropped"),!0;const s=20===e||21===e||23===e?1:2,r=this.channels[s];return 20===e||21===e||28===e||29===e?32===t?r.ccRCL():33===t?r.ccBS():34===t?r.ccAOF():35===t?r.ccAON():36===t?r.ccDER():37===t?r.ccRU(2):38===t?r.ccRU(3):39===t?r.ccRU(4):40===t?r.ccFON():41===t?r.ccRDC():42===t?r.ccTR():43===t?r.ccRTD():44===t?r.ccEDM():45===t?r.ccCR():46===t?r.ccENM():47===t&&r.ccEOC():r.ccTO(t-32),Hf(e,t,i),this.currentChannel=s,!0}parseMidrow(e,t){let i=0;if((17===e||25===e)&&t>=32&&t<=47){if(i=17===e?1:2,i!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const s=this.channels[i];return!!s&&(s.ccMIDROW(t),this.logger.log(3,"MIDROW ("+Of([e,t])+")"),!0)}return!1}parsePAC(e,t){let i;const s=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(Vf(e,t,s))return Hf(null,null,s),!0;const r=e<=23?1:2;i=t>=64&&t<=95?1===r?If[e]:Bf[e]:1===r?Pf[e]:Mf[e];const a=this.channels[r];return!!a&&(a.setPAC(this.interpretPAC(i,t)),Hf(e,t,s),this.currentChannel=r,!0)}interpretPAC(e,t){let i;const s={color:null,italics:!1,indent:null,underline:!1,row:e};return i=t>95?t-96:t-64,s.underline=1==(1&i),i<=13?s.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(s.italics=!0,s.color="white"):s.indent=4*Math.floor((i-16)/2),s}parseChars(e,t){let i,s=null,r=null;if(e>=25?(i=2,r=e-8):(i=1,r=e),r>=17&&r<=19){let e;e=17===r?t+80:18===r?t+112:t+144,this.logger.log(2,"Special char '"+Rf(e)+"' in channel "+i),s=[e]}else e>=32&&e<=127&&(s=0===t?[e]:[e,t]);if(s){const i=Of(s);this.logger.log(3,"Char codes = "+i.join(",")),Hf(e,t,this.cmdHistory)}return s}parseBackgroundAttributes(e,t){if(!((16===e||24===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=45&&t<=47))return!1;let i;const s={};16===e||24===e?(i=Math.floor((t-32)/2),s.background=Ff[i],t%2==1&&(s.background=s.background+"_semi")):45===t?s.background="transparent":(s.foreground="black",47===t&&(s.underline=!0));const r=e<=23?1:2;return this.channels[r].setBkgData(s),Hf(e,t,this.cmdHistory),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}this.cmdHistory={a:null,b:null}}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const i=this.channels[t];i&&i.cueSplitAtTime(e)}}}function Hf(e,t,i){i.a=e,i.b=t}function Vf(e,t,i){return i.a===e&&i.b===t}class Jf{constructor(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}dispatchCue(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,i){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var Kf=function(){if("undefined"!=typeof self&&self.VTTCue)return self.VTTCue;const 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;const i=t.toLowerCase();return!!~e.indexOf(i)&&i}function s(e){return i(t,e)}function r(e,...t){let i=1;for(;i<arguments.length;i++){const t=arguments[i];for(const i in t)e[i]=t[i]}return e}function a(t,a,o){const n=this,l={enumerable:!0};n.hasBeenReset=!1;let h="",d=!1,c=t,u=a,p=o,f=null,m="",g=!0,y="auto",A="start",b=50,v="middle",_=50,w="middle";Object.defineProperty(n,"id",r({},l,{get:function(){return h},set:function(e){h=""+e}})),Object.defineProperty(n,"pauseOnExit",r({},l,{get:function(){return d},set:function(e){d=!!e}})),Object.defineProperty(n,"startTime",r({},l,{get:function(){return c},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");c=e,this.hasBeenReset=!0}})),Object.defineProperty(n,"endTime",r({},l,{get:function(){return u},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");u=e,this.hasBeenReset=!0}})),Object.defineProperty(n,"text",r({},l,{get:function(){return p},set:function(e){p=""+e,this.hasBeenReset=!0}})),Object.defineProperty(n,"region",r({},l,{get:function(){return f},set:function(e){f=e,this.hasBeenReset=!0}})),Object.defineProperty(n,"vertical",r({},l,{get:function(){return m},set:function(t){const s=function(t){return i(e,t)}(t);if(!1===s)throw new SyntaxError("An invalid or illegal string was specified.");m=s,this.hasBeenReset=!0}})),Object.defineProperty(n,"snapToLines",r({},l,{get:function(){return g},set:function(e){g=!!e,this.hasBeenReset=!0}})),Object.defineProperty(n,"line",r({},l,{get:function(){return y},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");y=e,this.hasBeenReset=!0}})),Object.defineProperty(n,"lineAlign",r({},l,{get:function(){return A},set:function(e){const t=s(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");A=t,this.hasBeenReset=!0}})),Object.defineProperty(n,"position",r({},l,{get:function(){return b},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");b=e,this.hasBeenReset=!0}})),Object.defineProperty(n,"positionAlign",r({},l,{get:function(){return v},set:function(e){const t=s(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");v=t,this.hasBeenReset=!0}})),Object.defineProperty(n,"size",r({},l,{get:function(){return _},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");_=e,this.hasBeenReset=!0}})),Object.defineProperty(n,"align",r({},l,{get:function(){return w},set:function(e){const t=s(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");w=t,this.hasBeenReset=!0}})),n.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}();class qf{decode(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function Yf(e){function t(e,t,i,s){return 3600*(0|e)+60*(0|t)+(0|i)+parseFloat(s||0)}const 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}class Qf{constructor(){this.values=Object.create(null)}set(e,t){this.get(e)||""===t||(this.values[e]=t)}get(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,i){for(let s=0;s<i.length;++s)if(t===i[s]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){const i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),!0}return!1}}function Xf(e,t,i,s){const r=s?e.split(s):[e];for(const e in r){if("string"!=typeof r[e])continue;const s=r[e].split(i);if(2!==s.length)continue;t(s[0],s[1])}}const Zf=new Kf(0,0,""),em="middle"===Zf.align?"middle":"center";function tm(e,t,i){const s=e;function r(){const t=Yf(e);if(null===t)throw new Error("Malformed timestamp: "+s);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function a(){e=e.replace(/^\s+/,"")}if(a(),t.startTime=r(),a(),"--\x3e"!==e.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+s);e=e.slice(3),a(),t.endTime=r(),a(),function(e,t){const s=new Qf;Xf(e,(function(e,t){let r;switch(e){case"region":for(let r=i.length-1;r>=0;r--)if(i[r].id===t){s.set(e,i[r].region);break}break;case"vertical":s.alt(e,t,["rl","lr"]);break;case"line":r=t.split(","),s.integer(e,r[0]),s.percent(e,r[0])&&s.set("snapToLines",!1),s.alt(e,r[0],["auto"]),2===r.length&&s.alt("lineAlign",r[1],["start",em,"end"]);break;case"position":r=t.split(","),s.percent(e,r[0]),2===r.length&&s.alt("positionAlign",r[1],["start",em,"end","line-left","line-right","auto"]);break;case"size":s.percent(e,t);break;case"align":s.alt(e,t,["start",em,"end","left","right"])}}),/:/,/\s/),t.region=s.get("region",null),t.vertical=s.get("vertical","");let r=s.get("line","auto");"auto"===r&&-1===Zf.line&&(r=-1),t.line=r,t.lineAlign=s.get("lineAlign","start"),t.snapToLines=s.get("snapToLines",!0),t.size=s.get("size",100),t.align=s.get("align",em);let a=s.get("position","auto");"auto"===a&&50===Zf.position&&(a="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=a}(e,t)}function im(e){return e.replace(/<br(?: \/)?>/gi,"\n")}class sm{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new qf,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;function i(){let e=t.buffer,i=0;for(e=im(e);i<e.length&&"\r"!==e[i]&&"\n"!==e[i];)++i;const s=e.slice(0,i);return"\r"===e[i]&&++i,"\n"===e[i]&&++i,t.buffer=e.slice(i),s}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{let e="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;e=i();const s=e.match(/^()?WEBVTT([ \t].*)?$/);if(null==s||!s[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let s=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(s?s=!1:e=i(),t.state){case"HEADER":/:/.test(e)?Xf(e,(function(e,t){}),/:/):e||(t.state="ID");continue;case"NOTE":e||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(e)){t.state="NOTE";break}if(!e)continue;if(t.cue=new Kf(0,0,""),t.state="CUE",-1===e.indexOf("--\x3e")){t.cue.id=e;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{tm(e,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const i=-1!==e.indexOf("--\x3e");if(!e||i&&(s=!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+=e}continue;case"BADCUE":e||(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}flush(){const 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}}const rm=/\r\n|\n\r|\n|\r/g,am=function(e,t,i=0){return e.slice(i,i+t.length)===t},om=function(e){let t=5381,i=e.length;for(;i;)t=33*t^e.charCodeAt(--i);return(t>>>0).toString()};function nm(e,t,i){return om(e.toString())+om(t.toString())+om(i)}function lm(e,t,i,s,r,a,o){const n=new sm,l=Rd(new Uint8Array(e)).trim().replace(rm,"\n").split("\n"),h=[],d=t?function(e,t=1){return Jp(e,9e4,1/t)}(t.baseTime,t.timescale):0;let c,u="00:00.000",p=0,f=0,m=!0;n.oncue=function(e){const a=i[s];let o=i.ccOffset;const n=(p-d)/9e4;if(null!=a&&a.new&&(void 0!==f?o=i.ccOffset=a.start:function(e,t,i){let s=e[t],r=e[s.prevCC];if(!r||!r.new&&s.new)return e.ccOffset=e.presentationOffset=s.start,void(s.new=!1);for(;null!=(a=r)&&a.new;){var a;e.ccOffset+=s.start-r.start,s.new=!1,s=r,r=e[s.prevCC]}e.presentationOffset=i}(i,s,n)),n){if(!t)return void(c=new Error("Missing initPTS for VTT MPEGTS"));o=n-i.presentationOffset}const l=e.endTime-e.startTime,u=Zp(9e4*(e.startTime+o-f),9e4*r)/9e4;e.startTime=Math.max(u,0),e.endTime=Math.max(u+l,0);const m=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(m)),e.id||(e.id=nm(e.startTime,e.endTime,m)),e.endTime>0&&h.push(e)},n.onparsingerror=function(e){c=e},n.onflush=function(){c?o(c):a(h)},l.forEach((e=>{if(m){if(am(e,"X-TIMESTAMP-MAP=")){m=!1,e.slice(16).split(",").forEach((e=>{am(e,"LOCAL:")?u=e.slice(6):am(e,"MPEGTS:")&&(p=parseInt(e.slice(7)))}));try{f=function(e){let t=parseInt(e.slice(-3));const i=parseInt(e.slice(-6,-4)),s=parseInt(e.slice(-9,-7)),r=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!(Bh(t)&&Bh(i)&&Bh(s)&&Bh(r)))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=6e4*s,t+=36e5*r,t}(u)/1e3}catch(e){c=e}return}""===e&&(m=!1)}n.parse(e+"\n")})),n.flush()}const hm="stpp.ttml.im1t",dm=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,cm=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,um={left:"start",center:"center",right:"end",start:"start",end:"end"};function pm(e,t,i,s){const r=Gd(new Uint8Array(e),["mdat"]);if(0===r.length)return void s(new Error("Could not parse IMSC1 mdat"));const a=r.map((e=>Rd(e))),o=function(e,t,i=1,s=!1){return Jp(e,t,1/i,s)}(t.baseTime,1,t.timescale);try{a.forEach((e=>i(function(e,t){const i=new DOMParser,s=i.parseFromString(e,"text/xml").getElementsByTagName("tt")[0];if(!s)throw new Error("Invalid ttml");const r={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(r).reduce(((e,t)=>(e[t]=s.getAttribute(`ttp:${t}`)||r[t],e)),{}),o="preserve"!==s.getAttribute("xml:space"),n=mm(fm(s,"styling","style")),l=mm(fm(s,"layout","region")),h=fm(s,"body","[begin]");return[].map.call(h,(e=>{const i=gm(e,o);if(!i||!e.hasAttribute("begin"))return null;const s=bm(e.getAttribute("begin"),a),r=bm(e.getAttribute("dur"),a);let h=bm(e.getAttribute("end"),a);if(null===s)throw Am(e);if(null===h){if(null===r)throw Am(e);h=s+r}const d=new Kf(s-t,h-t,i);d.id=nm(d.startTime,d.endTime,d.text);const c=function(e,t,i){const s="http://www.w3.org/ns/ttml#styling";let r=null;const a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],o=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;o&&i.hasOwnProperty(o)&&(r=i[o]);return a.reduce(((i,a)=>{const o=ym(t,s,a)||ym(e,s,a)||ym(r,s,a);return o&&(i[a]=o),i}),{})}(l[e.getAttribute("region")],n[e.getAttribute("style")],n),{textAlign:u}=c;if(u){const e=um[u];e&&(d.lineAlign=e),d.align=u}return Ph(d,c),d})).filter((e=>null!==e))}(e,o))))}catch(e){s(e)}}function fm(e,t,i){const s=e.getElementsByTagName(t)[0];return s?[].slice.call(s.querySelectorAll(i)):[]}function mm(e){return e.reduce(((e,t)=>{const i=t.getAttribute("xml:id");return i&&(e[i]=t),e}),{})}function gm(e,t){return[].slice.call(e.childNodes).reduce(((e,i,s)=>{var r;return"br"===i.nodeName&&s?e+"\n":null!=(r=i.childNodes)&&r.length?gm(i,t):t?e+i.textContent.trim().replace(/\s+/g," "):e+i.textContent}),"")}function ym(e,t,i){return e&&e.hasAttributeNS(t,i)?e.getAttributeNS(t,i):null}function Am(e){return new Error(`Could not parse ttml timestamp ${e}`)}function bm(e,t){if(!e)return null;let i=Yf(e);return null===i&&(dm.test(e)?i=function(e,t){const i=dm.exec(e),s=(0|i[4])+(0|i[5])/t.subFrameRate;return 3600*(0|i[1])+60*(0|i[2])+(0|i[3])+s/t.frameRate}(e,t):cm.test(e)&&(i=function(e,t){const i=cm.exec(e),s=Number(i[1]);switch(i[2]){case"h":return 3600*s;case"m":return 60*s;case"ms":return 1e3*s;case"f":return s/t.frameRate;case"t":return s/t.tickRate}return s}(e,t))),i}function vm(e,t){return!!e&&e.label===t.name&&!(e.textTrack1||e.textTrack2)}class _m{constructor(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()}setStreamController(e){this.streamController=e}destroy(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(Mh.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(Mh.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Mh.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Mh.BUFFER_CODECS,this.onBufferCodecs,this),e.on(Mh.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(Mh.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(Mh.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Mh.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Mh.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Mh.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null}onManifestParsed(e,t){const i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){const e=this.hls.levels;if(e.length){const t=this.hls;t.autoLevelCapping=this.getMaxLevel(e.length-1),t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){const t=this.hls.levels;if(!t.length)return-1;const i=t.filter(((t,i)=>this.isLevelAllowed(t)&&i<=e));return this.clientRect=null,_m.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const e=this.media,t={width:0,height:0};if(e){const 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}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return e}isLevelAllowed(e){return!this.restrictedLevels.some((t=>e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height))}static getMaxLevelByMediaSize(e,t,i){if(null==e||!e.length)return-1;let s=e.length-1;for(let o=0;o<e.length;o+=1){const n=e[o];if((n.width>=t||n.height>=i)&&(r=n,!(a=e[o+1])||r.width!==a.width||r.height!==a.height)){s=o;break}}var r,a;return s}}const wm="[eme]";class Sm{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=Sm.CDMCleanupPromise?[Sm.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=zh.debug.bind(zh,wm),this.log=zh.log.bind(zh,wm),this.warn=zh.warn.bind(zh,wm),this.error=zh.error.bind(zh,wm),this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(Mh.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(Mh.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(Mh.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(Mh.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(Mh.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(Mh.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(Mh.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(Mh.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:i}=this.config,s=t[e];if(s)return s.licenseUrl;if(e===ad.WIDEVINE&&i)return i;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){const{drmSystems:t}=this.config,i=t[e];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,i=(e,t,i)=>!!e&&i.indexOf(e)===t,s=t.map((e=>e.audioCodec)).filter(i),r=t.map((e=>e.videoCodec)).filter(i);return s.length+r.length===0&&r.push("avc1.42e01e"),new Promise(((t,i)=>{const a=e=>{const o=e.shift();this.getMediaKeysPromise(o,s,r).then((e=>t({keySystem:o,mediaKeys:e}))).catch((t=>{e.length?a(e):i(t instanceof Tm?t:new Tm({type:Fh.KEY_SYSTEM_ERROR,details:Uh.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))}))};a(e)}))}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:i}=this.config;if("function"!=typeof i){let e=`Configured requestMediaKeySystemAccess is not a function ${i}`;return null===fd&&"http:"===self.location.protocol&&(e=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(e))}return i(e,t)}getMediaKeysPromise(e,t,i){const s=function(e,t,i,s){let r;switch(e){case ad.FAIRPLAY:r=["cenc","sinf"];break;case ad.WIDEVINE:case ad.PLAYREADY:r=["cenc"];break;case ad.CLEARKEY:r=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${e}`)}return function(e,t,i,s){return[{initDataTypes:e,persistentState:s.persistentState||"not-allowed",distinctiveIdentifier:s.distinctiveIdentifier||"not-allowed",sessionTypes:s.sessionTypes||[s.sessionType||"temporary"],audioCapabilities:t.map((e=>({contentType:`audio/mp4; codecs="${e}"`,robustness:s.audioRobustness||"",encryptionScheme:s.audioEncryptionScheme||null}))),videoCapabilities:i.map((e=>({contentType:`video/mp4; codecs="${e}"`,robustness:s.videoRobustness||"",encryptionScheme:s.videoEncryptionScheme||null})))}]}(r,t,i,s)}(e,t,i,this.config.drmSystemOptions),r=this.keySystemAccessPromises[e];let a=null==r?void 0:r.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(s)}`),a=this.requestMediaKeySystemAccess(e,s);const t=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch((t=>{this.log(`Failed to obtain access to key-system "${e}": ${t}`)})),a.then((i=>{this.log(`Access for key-system "${i.keySystem}" obtained`);const s=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),t.mediaKeys=i.createMediaKeys().then((t=>(this.log(`Media-keys created for "${e}"`),s.then((i=>i?this.setMediaKeysServerCertificate(t,e,i):t))))),t.mediaKeys.catch((t=>{this.error(`Failed to create media-keys for "${e}"}: ${t}`)})),t.mediaKeys}))}return a.then((()=>r.mediaKeys))}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: ${Id(e.keyId||[])}`);const s=i.createSession(),r={decryptdata:e,keySystem:t,mediaKeys:i,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(r),r}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const i=this.createMediaKeySessionContext(e),s=this.getKeyIdString(t),r="cenc";this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(i,r,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return Id(e.keyId)}updateKeySession(e,t){var i;const s=e.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${Id((null==(i=e.decryptdata)?void 0:i.keyId)||[])}\n } (data length: ${t?t.byteLength:t})`),s.update(t)}selectKeySystemFormat(e){const 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}getKeyFormatPromise(e){return new Promise(((t,i)=>{const s=pd(this.config),r=e.map(dd).filter((e=>!!e&&-1!==s.indexOf(e)));return this.getKeySystemSelectionPromise(r).then((({keySystem:e})=>{const s=ud(e);s?t(s):i(new Error(`Unable to find format for key-system "${e}"`))})).catch(i)}))}loadKey(e){const t=e.keyInfo.decryptdata,i=this.getKeyIdString(t),s=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${s}`);let r=this.keyIdToKeySessionPromise[i];return r||(r=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(t).then((({keySystem:i,mediaKeys:r})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${s}`),this.attemptSetMediaKeys(i,r).then((()=>{this.throwIfDestroyed();const e=this.createMediaKeySessionContext({keySystem:i,mediaKeys:r,decryptdata:t});return this.generateRequestWithPreferredKeySession(e,"cenc",t.pssh,"playlist-key")}))))),r.catch((e=>this.handleError(e)))),r}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof Tm?this.hls.trigger(Mh.ERROR,e.data):this.hls.trigger(Mh.ERROR,{type:Fh.KEY_SYSTEM_ERROR,details:Uh.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){const t=this.getKeyIdString(e),i=this.keyIdToKeySessionPromise[t];if(!i){const t=dd(e.keyFormat),i=t?[t]:pd(this.config);return this.attemptKeySystemAccess(i)}return i}getKeySystemSelectionPromise(e){if(e.length||(e=pd(this.config)),0===e.length)throw new Tm({type:Fh.KEY_SYSTEM_ERROR,details:Uh.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}_onMediaEncrypted(e){const{initDataType:t,initData:i}=e;if(this.debug(`"${e.type}" event: init data type: "${t}"`),null===i)return;let s,r;if("sinf"===t&&this.config.drmSystems[ad.FAIRPLAY]){const e=Fd(new Uint8Array(i));try{const t=id(JSON.parse(e).sinf),i=Wd(new Uint8Array(t));if(!i)return;s=i.subarray(8,24),r=ad.FAIRPLAY}catch(e){return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{const e=function(e){if(!(e instanceof ArrayBuffer)||e.byteLength<32)return null;const t={version:0,systemId:"",kids:null,data:null},i=new DataView(e),s=i.getUint32(0);if(e.byteLength!==s&&s>44)return null;if(1886614376!==i.getUint32(4))return null;if(t.version=i.getUint32(8)>>>24,t.version>1)return null;t.systemId=Id(new Uint8Array(e,12,16));const r=i.getUint32(28);if(0===t.version){if(s-32<r)return null;t.data=new Uint8Array(e,32,r)}else if(1===t.version){t.kids=[];for(let i=0;i<r;i++)t.kids.push(new Uint8Array(e,32+16*i,16))}return t}(i);if(null===e)return;0===e.version&&e.systemId===cd&&e.data&&(s=e.data.subarray(8,24)),r=function(e){if(e===cd)return ad.WIDEVINE}(e.systemId)}if(!r||!s)return;const a=Id(s),{keyIdToKeySessionPromise:o,mediaKeySessions:n}=this;let l=o[a];for(let e=0;e<n.length;e++){const r=n[e],h=r.decryptdata;if(h.pssh||!h.keyId)continue;const d=Id(h.keyId);if(a===d||-1!==h.uri.replace(/-/g,"").indexOf(a)){l=o[d],delete o[d],h.pssh=new Uint8Array(i),h.keyId=s,l=o[a]=l.then((()=>this.generateRequestWithPreferredKeySession(r,t,i,"encrypted-event-key-match")));break}}l||(l=o[a]=this.getKeySystemSelectionPromise([r]).then((({keySystem:e,mediaKeys:r})=>{var o;this.throwIfDestroyed();const n=new Zd("ISO-23001-7",a,null!=(o=ud(e))?o:"");return n.pssh=new Uint8Array(i),n.keyId=s,this.attemptSetMediaKeys(e,r).then((()=>{this.throwIfDestroyed();const s=this.createMediaKeySessionContext({decryptdata:n,keySystem:e,mediaKeys:r});return this.generateRequestWithPreferredKeySession(s,t,i,"encrypted-event-no-match")}))}))),l.catch((e=>this.handleError(e)))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){const i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const s=Promise.all(i).then((()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)}));return this.setMediaKeysQueue.push(s),s.then((()=>{this.log(`Media-keys set for "${e}"`),i.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter((e=>-1===i.indexOf(e)))}))}generateRequestWithPreferredKeySession(e,t,i,s){var r,a;const o=null==(r=this.config.drmSystems)||null==(a=r[e.keySystem])?void 0:a.generateRequest;if(o)try{const s=o.call(this.hls,t,i,e);if(!s)throw new Error("Invalid response from configured generateRequest filter");t=s.initDataType,i=e.decryptdata.pssh=s.initData?new Uint8Array(s.initData):null}catch(e){var n;if(this.warn(e.message),null!=(n=this.hls)&&n.config.debug)throw e}if(null===i)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(e);const l=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${s}": ${l} (init data type: ${t} length: ${i?i.byteLength:null})`);const h=new pf;e.mediaKeysSession.onmessage=t=>{const i=e.mediaKeysSession;if(!i)return void h.emit("error",new Error("invalid state"));const{messageType:s,message:r}=t;this.log(`"${s}" message event for session "${i.sessionId}" message size: ${r.byteLength}`),"license-request"===s||"license-renewal"===s?this.renewLicense(e,r).catch((e=>{this.handleError(e),h.emit("error",e)})):"license-release"===s?e.keySystem===ad.FAIRPLAY&&(this.updateKeySession(e,rd("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${s}"`)},e.mediaKeysSession.onkeystatuseschange=t=>{if(!e.mediaKeysSession)return void h.emit("error",new Error("invalid state"));this.onKeyStatusChange(e);const i=e.keyStatus;h.emit("keyStatus",i),"expired"===i&&(this.warn(`${e.keySystem} expired for key ${l}`),this.renewKeySession(e))};const d=new Promise(((e,t)=>{h.on("error",t),h.on("keyStatus",(i=>{i.startsWith("usable")?e():"output-restricted"===i?t(new Tm({type:Fh.KEY_SYSTEM_ERROR,details:Uh.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===i?t(new Tm({type:Fh.KEY_SYSTEM_ERROR,details:Uh.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${i}"`)):"expired"===i?t(new Error("key expired while generating request")):this.warn(`unhandled key status change "${i}"`)}))}));return e.mediaKeysSession.generateRequest(t,i).then((()=>{var t;this.log(`Request generated for key-session "${null==(t=e.mediaKeysSession)?void 0:t.sessionId}" keyId: ${l}`)})).catch((e=>{throw new Tm({type:Fh.KEY_SYSTEM_ERROR,details:Uh.KEY_SYSTEM_NO_SESSION,error:e,fatal:!1},`Error generating key-session request: ${e}`)})).then((()=>d)).catch((t=>{throw h.removeAllListeners(),this.removeSession(e),t})).then((()=>(h.removeAllListeners(),e)))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach(((t,i)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${Id("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${Id(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t}))}fetchServerCertificate(e){const t=this.config,i=new(0,t.loader)(t),s=this.getServerCertificateUrl(e);return s?(this.log(`Fetching serverCertificate for "${e}"`),new Promise(((r,a)=>{const o={responseType:"arraybuffer",url:s},n=t.certLoadPolicy.default,l={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:(e,t,i,s)=>{r(e.data)},onError:(t,i,r,n)=>{a(new Tm({type:Fh.KEY_SYSTEM_ERROR,details:Uh.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:r,response:Lh({url:o.url,data:void 0},t)},`"${e}" certificate request failed (${s}). Status: ${t.code} (${t.text})`))},onTimeout:(t,i,r)=>{a(new Tm({type:Fh.KEY_SYSTEM_ERROR,details:Uh.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:r,response:{url:o.url,data:void 0}},`"${e}" certificate request timed out (${s})`))},onAbort:(e,t,i)=>{a(new Error("aborted"))}};i.load(o,l,h)}))):Promise.resolve()}setMediaKeysServerCertificate(e,t,i){return new Promise(((s,r)=>{e.setServerCertificate(i).then((r=>{this.log(`setServerCertificate ${r?"success":"not supported by CDM"} (${null==i?void 0:i.byteLength}) on "${t}"`),s(e)})).catch((e=>{r(new Tm({type:Fh.KEY_SYSTEM_ERROR,details:Uh.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:!0},e.message))}))}))}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then((t=>this.updateKeySession(e,new Uint8Array(t)).catch((e=>{throw new Tm({type:Fh.KEY_SYSTEM_ERROR,details:Uh.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:e,fatal:!0},e.message)}))))}setupLicenseXHR(e,t,i,s){const r=this.config.licenseXhrSetup;return r?Promise.resolve().then((()=>{if(!i.decryptdata)throw new Error("Key removed");return r.call(this.hls,e,t,i,s)})).catch((a=>{if(!i.decryptdata)throw a;return e.open("POST",t,!0),r.call(this.hls,e,t,i,s)})).then((i=>{e.readyState||e.open("POST",t,!0);return{xhr:e,licenseChallenge:i||s}})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:s}))}requestLicense(e,t){const i=this.config.keyLoadPolicy.default;return new Promise(((s,r)=>{const a=this.getLicenseServerUrl(e.keySystem);this.log(`Sending license request to URL: ${a}`);const o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return r(new Error("invalid state"));if(4===o.readyState)if(200===o.status){this._requestLicenseFailureCount=0;let t=o.response;this.log(`License received ${t instanceof ArrayBuffer?t.byteLength:t}`);const i=this.config.licenseResponseCallback;if(i)try{t=i.call(this.hls,o,a,e)}catch(e){this.error(e)}s(t)}else{const n=i.errorRetry,l=n?n.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>l||o.status>=400&&o.status<500)r(new Tm({type:Fh.KEY_SYSTEM_ERROR,details:Uh.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:a,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${a}). Status: ${o.status} (${o.statusText})`));else{const i=l-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${i} attempts left`),this.requestLicense(e,t).then(s,r)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,a,e,t).then((({xhr:e,licenseChallenge:t})=>{e.send(t)}))}))}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const i=t.media;this.media=i,i.addEventListener("encrypted",this.onMediaEncrypted),i.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Zd.clearKeyUriToKeyIdMap();const i=t.length;Sm.CDMCleanupPromise=Promise.all(t.map((e=>this.removeSession(e))).concat(null==e?void 0:e.setMediaKeys(null).catch((t=>{this.log(`Could not clear media keys: ${t}. media.src: ${null==e?void 0:e.src}`)})))).then((()=>{i&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)})).catch((t=>{this.log(`Could not close sessions and clear media keys: ${t}. media.src: ${null==e?void 0:e.src}`)}))}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(t&&this.config.emeEnabled&&!this.keyFormatPromise){const e=t.reduce(((e,t)=>(-1===e.indexOf(t.keyFormat)&&e.push(t.keyFormat),e)),[]);this.log(`Selecting key-system from session-keys ${e.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(e)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:i}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),t.onmessage=null,t.onkeystatuseschange=null,i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const s=this.mediaKeySessions.indexOf(e);return s>-1&&this.mediaKeySessions.splice(s,1),t.remove().catch((e=>{this.log(`Could not remove session: ${e}`)})).then((()=>t.close())).catch((e=>{this.log(`Could not close session: ${e}`)}))}}}Sm.CDMCleanupPromise=void 0;class Tm extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}}var Em="m",km="a",Cm="v",xm="av",Rm="i",Dm="tt";class Lm{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=e=>{try{this.apply(e,{ot:Em,su:!this.initialized})}catch(e){zh.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=e=>{try{const t=e.frag,i=this.hls.levels[t.level],s=this.getObjectType(t),r={d:1e3*t.duration,ot:s};s!==Cm&&s!==km&&s!=xm||(r.br=i.bitrate/1e3,r.tb=this.getTopBandwidth(s)/1e3,r.bl=this.getBufferLength(s)),this.apply(e,r)}catch(e){zh.warn("Could not generate segment CMCD data.",e)}},this.hls=e;const t=this.config=e.config,{cmcd:i}=t;null!=i&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||Lm.uuid(),this.cid=i.contentId,this.useHeaders=!0===i.useHeaders,this.registerListeners())}registerListeners(){const e=this.hls;e.on(Mh.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Mh.MEDIA_DETACHED,this.onMediaDetached,this),e.on(Mh.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(Mh.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Mh.MEDIA_DETACHED,this.onMediaDetached,this),e.off(Mh.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var i,s;this.audioBuffer=null==(i=t.tracks.audio)?void 0:i.buffer,this.videoBuffer=null==(s=t.tracks.video)?void 0:s.buffer}createData(){var e;return{v:1,sf:"h",sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){Ph(t,this.createData());const i=t.ot===Rm||t.ot===Cm||t.ot===xm;if(this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering),this.useHeaders){const i=Lm.toHeaders(t);if(!Object.keys(i).length)return;e.headers||(e.headers={}),Ph(e.headers,i)}else{const i=Lm.toQuery(t);if(!i)return;e.url=Lm.appendQueryToUri(e.url,i)}}getObjectType(e){const{type:t}=e;return"subtitle"===t?Dm:"initSegment"===e.sn?Rm:"audio"===t?km:"main"===t?this.hls.audioTracks.length?Cm:xm:void 0}getTopBandwidth(e){let t,i=0;const s=this.hls;if(e===km)t=s.audioTracks;else{const e=s.maxAutoLevel,i=e>-1?e+1:s.levels.length;t=s.levels.slice(0,i)}for(const e of t)e.bitrate>i&&(i=e.bitrate);return i>0?i:NaN}getBufferLength(e){const t=this.hls.media,i=e===km?this.audioBuffer:this.videoBuffer;if(!i||!t)return NaN;return 1e3*ju.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,i=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new i(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,i,s){t(e),this.loader.load(e,i,s)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,i=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new i(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,i,s){t(e),this.loader.load(e,i,s)}}}static uuid(){const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}static serialize(e){const t=[],i=e=>!Number.isNaN(e)&&null!=e&&""!==e&&!1!==e,s=e=>Math.round(e),r=e=>100*s(e/100),a={br:s,d:s,bl:r,dl:r,mtp:r,nor:e=>encodeURIComponent(e),rtp:r,tb:s},o=Object.keys(e||{}).sort();for(const s of o){let r=e[s];if(!i(r))continue;if("v"===s&&1===r)continue;if("pr"==s&&1===r)continue;const o=a[s];o&&(r=o(r));const n=typeof r;let l;l="ot"===s||"sf"===s||"st"===s?`${s}=${r}`:"boolean"===n?s:"number"===n?`${s}=${r}`:`${s}=${JSON.stringify(r)}`,t.push(l)}return t.join(",")}static toHeaders(e){const t=Object.keys(e),i={},s=["Object","Request","Session","Status"],r=[{},{},{},{}],a={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3};for(const i of t){r[null!=a[i]?a[i]:1][i]=e[i]}for(let e=0;e<r.length;e++){const t=Lm.serialize(r[e]);t&&(i[`CMCD-${s[e]}`]=t)}return i}static toQuery(e){return`CMCD=${encodeURIComponent(Lm.serialize(e))}`}static appendQueryToUri(e,t){if(!t)return e;const i=e.includes("?")?"&":"?";return`${e}${i}${t}`}}function Im(e,t,i,s){e&&Object.keys(t).forEach((r=>{const a=e.filter((e=>e.groupId===r)).map((e=>{const a=Ph({},e);return a.details=void 0,a.attrs=new Hh(a.attrs),a.url=a.attrs.URI=Pm(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",i),a.groupId=a.attrs["GROUP-ID"]=t[r],a.attrs["PATHWAY-ID"]=s,a}));e.push(...a)}))}function Pm(e,t,i,s){const{HOST:r,PARAMS:a,[i]:o}=s;let n;t&&(n=null==o?void 0:o[t],n&&(e=n));const l=new self.URL(e);return r&&!n&&(l.host=r),a&&Object.keys(a).sort().forEach((e=>{e&&l.searchParams.set(e,a[e])})),l.href}const Bm=/^age:\s*[\d.]+\s*$/im;class Mm{constructor(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=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new Kh,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null}abortInternal(){const 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()))}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(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()}loadInternal(){const{config:e,context:t}=this;if(!e)return;const i=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;const r=this.xhrSetup;r?Promise.resolve().then((()=>{if(!this.stats.aborted)return r(i,t.url)})).catch((e=>(i.open("GET",t.url,!0),r(i,t.url)))).then((()=>{this.stats.aborted||this.openAndSendXhr(i,t,e)})).catch((e=>{this.callbacks.onError({code:i.status,text:e.message},t,i,s)})):this.openAndSendXhr(i,t,e)}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,!0);const s=this.context.headers,{maxTimeToFirstByteMs:r,maxLoadTimeMs:a}=i.loadPolicy;if(s)for(const t in s)e.setRequestHeader(t,s[t]);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=r&&Bh(r)?r:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:i}=this;if(!e||!t)return;const s=t.readyState,r=this.config;if(!i.aborted&&s>=2&&(0===i.loading.first&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),r.timeout!==r.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),r.timeout=r.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),4===s)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const s=t.status,a="text"!==t.responseType;if(s>=200&&s<300&&(a&&t.response||null!==t.responseText)){i.loading.end=Math.max(self.performance.now(),i.loading.first);const r=a?t.response:t.responseText,o="arraybuffer"===t.responseType?r.byteLength:r.length;if(i.loaded=i.total=o,i.bwEstimate=8e3*i.total/(i.loading.end-i.loading.first),!this.callbacks)return;const n=this.callbacks.onProgress;if(n&&n(i,e,r,t),!this.callbacks)return;const l={url:t.responseURL,data:r,code:s};this.callbacks.onSuccess(l,i,e,t)}else{const a=r.loadPolicy.errorRetry;lu(a,i.retry,!1,s)?this.retry(a):(zh.error(`${s} while loading ${e.url}`),this.callbacks.onError({code:s,text:t.statusText},e,t,i))}}}loadtimeout(){var e;const t=null==(e=this.config)?void 0:e.loadPolicy.timeoutRetry;if(lu(t,this.stats.retry,!0))this.retry(t);else{zh.warn(`timeout while loading ${this.context.url}`);const e=this.callbacks;e&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:i}=this;this.retryDelay=ou(e,i.retry),i.retry++,zh.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${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)}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&Bm.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}const Fm=/(\d+)-(\d+)\/(\d+)/;class Um{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||Om,this.controller=new self.AbortController,this.stats=new Kh}destroy(){this.loader=this.callbacks=null,this.abortInternal()}abortInternal(){const e=this.response;null!=e&&e.ok||(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,i){const s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();const r=function(e,t){const i={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(Ph({},e.headers))};e.rangeEnd&&i.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1));return i}(e,this.controller.signal),a=i.onProgress,o="arraybuffer"===e.responseType,n=o?"byteLength":"length",{maxTimeToFirstByteMs:l,maxLoadTimeMs:h}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,r),self.clearTimeout(this.requestTimeout),t.timeout=l&&Bh(l)?l:h,this.requestTimeout=self.setTimeout((()=>{this.abortInternal(),i.onTimeout(s,e,this.response)}),t.timeout),self.fetch(this.request).then((r=>{this.response=this.loader=r;const n=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=h,this.requestTimeout=self.setTimeout((()=>{this.abortInternal(),i.onTimeout(s,e,this.response)}),h-(n-s.loading.start)),!r.ok){const{status:e,statusText:t}=r;throw new Nm(t||"fetch, bad network response",e,r)}return s.loading.first=n,s.total=function(e){const t=e.get("Content-Range");if(t){const e=function(e){const t=Fm.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(Bh(e))return e}const i=e.get("Content-Length");if(i)return parseInt(i)}(r.headers)||s.total,a&&Bh(t.highWaterMark)?this.loadProgressively(r,s,e,t.highWaterMark,a):o?r.arrayBuffer():"json"===e.responseType?r.json():r.text()})).then((r=>{const{response:o}=this;self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);const l=r[n];l&&(s.loaded=s.total=l);const h={url:o.url,data:r,code:o.status};a&&!Bh(t.highWaterMark)&&a(s,e,r,o),i.onSuccess(h,s,e,o)})).catch((t=>{if(self.clearTimeout(this.requestTimeout),s.aborted)return;const r=t&&t.code||0,a=t?t.message:null;i.onError({code:r,text:a},e,t?t.details:null,s)}))}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,i,s=0,r){const a=new vf,o=e.body.getReader(),n=()=>o.read().then((o=>{if(o.done)return a.dataLength&&r(t,i,a.flush(),e),Promise.resolve(new ArrayBuffer(0));const l=o.value,h=l.length;return t.loaded+=h,h<s||a.dataLength?(a.push(l),a.dataLength>=s&&r(t,i,a.flush(),e)):r(t,i,l,e),n()})).catch((()=>Promise.reject()));return n()}}function Om(e,t){return new self.Request(e.url,t)}class Nm extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i}}const jm=/\s/,Gm={newCue(e,t,i,s){const r=[];let a,o,n,l,h;const d=self.VTTCue||self.TextTrackCue;for(let u=0;u<s.rows.length;u++)if(a=s.rows[u],n=!0,l=0,h="",!a.isEmpty()){var c;for(let e=0;e<a.chars.length;e++)jm.test(a.chars[e].uchar)&&n?l++:(h+=a.chars[e].uchar,n=!1);a.cueStartTime=t,t===i&&(i+=1e-4),l>=16?l--:l++;const s=im(h.trim()),p=nm(t,i,s);null!=e&&null!=(c=e.cues)&&c.getCueById(p)||(o=new d(t,i,s),o.id=p,o.line=u+1,o.align="left",o.position=10+Math.min(80,10*Math.floor(8*l/32)),r.push(o))}return e&&r.length&&(r.sort(((e,t)=>"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line)),r.forEach((t=>Bc(e,t)))),r}},zm=Lh(Lh({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength: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:Mm,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:class{constructor(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=e;const t=e.config;this.bwEstimator=new bf(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(Mh.FRAG_LOADING,this.onFragLoading,this),e.on(Mh.FRAG_LOADED,this.onFragLoaded,this),e.on(Mh.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Mh.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Mh.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){const{hls:e}=this;e.off(Mh.FRAG_LOADING,this.onFragLoading,this),e.off(Mh.FRAG_LOADED,this.onFragLoaded,this),e.off(Mh.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Mh.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Mh.LEVEL_LOADED,this.onLevelLoaded,this)}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null}onFragLoading(e,t){var i;const s=t.frag;this.ignoreFragment(s)||(this.fragCurrent=s,this.partCurrent=null!=(i=t.part)?i:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))}onLevelSwitching(e,t){this.clearTimer()}getTimeToLoadFrag(e,t,i,s){return e+i/t+(s?this.lastLevelLoadSec:0)}onLevelLoaded(e,t){const i=this.hls.config,{total:s,bwEstimate:r}=t.stats;Bh(s)&&Bh(r)&&(this.lastLevelLoadSec=8*s/r),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD)}_abandonRulesCheck(){const{fragCurrent:e,partCurrent:t,hls:i}=this,{autoLevelEnabled:s,media:r}=i;if(!e||!r)return;const a=performance.now(),o=t?t.stats:e.stats,n=t?t.duration:e.duration,l=a-o.loading.start;if(o.aborted||o.loaded&&o.loaded===o.total||0===e.level)return this.clearTimer(),void(this._nextAutoLevel=-1);if(!s||r.paused||!r.playbackRate||!r.readyState)return;const h=i.mainForwardBufferInfo;if(null===h)return;const d=this.bwEstimator.getEstimateTTFB(),c=Math.abs(r.playbackRate);if(l<=Math.max(d,n/(2*c)*1e3))return;const u=h.len/c;if(u>=2*n/c)return;const p=o.loading.first?o.loading.first-o.loading.start:-1,f=o.loaded&&p>-1,m=this.bwEstimator.getEstimate(),{levels:g,minAutoLevel:y}=i,A=g[e.level],b=o.total||Math.max(o.loaded,Math.round(n*A.maxBitrate/8));let v=l-p;v<1&&f&&(v=Math.min(l,8*o.loaded/m));const _=f?1e3*o.loaded/v:0,w=_?(b-o.loaded)/_:8*b/m+d/1e3;if(w<=u)return;const S=_?8*_:m;let T,E=Number.POSITIVE_INFINITY;for(T=e.level-1;T>y;T--){const e=g[T].maxBitrate;if(E=this.getTimeToLoadFrag(d/1e3,S,n*e,!g[T].details),E<u)break}E>=w||E>10*n||(i.nextLoadLevel=T,f?this.bwEstimator.sample(l-Math.min(d,p),o.loaded):this.bwEstimator.sampleTTFB(l),this.clearTimer(),zh.warn(`[abr] Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} is loading too slowly;\n Time to underbuffer: ${u.toFixed(3)} s\n Estimated load time for current fragment: ${w.toFixed(3)} s\n Estimated load time for down switch fragment: ${E.toFixed(3)} s\n TTFB estimate: ${p}\n Current BW estimate: ${Bh(m)?(m/1024).toFixed(3):"Unknown"} Kb/s\n New BW estimate: ${(this.bwEstimator.getEstimate()/1024).toFixed(3)} Kb/s\n Aborting and switching to level ${T}`),e.loader&&(this.fragCurrent=this.partCurrent=null,e.abortRequests()),i.trigger(Mh.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:o}))}onFragLoaded(e,{frag:t,part:i}){const s=i?i.stats:t.stats;if(t.type===Cc&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),this.lastLoadedFragLevel=t.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){const e=i?i.duration:t.duration,r=this.hls.levels[t.level],a=(r.loaded?r.loaded.bytes:0)+s.loaded,o=(r.loaded?r.loaded.duration:0)+e;r.loaded={bytes:a,duration:o},r.realBitrate=Math.round(8*a/o)}if(t.bitrateTest){const e={stats:s,frag:t,part:i,id:t.type};this.onFragBuffered(Mh.FRAG_BUFFERED,e),t.bitrateTest=!1}}}onFragBuffered(e,t){const{frag:i,part:s}=t,r=null!=s&&s.stats.loaded?s.stats:i.stats;if(r.aborted)return;if(this.ignoreFragment(i))return;const a=r.parsing.end-r.loading.start-Math.min(r.loading.first-r.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,r.loaded),r.bwEstimate=this.bwEstimator.getEstimate(),i.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==Cc||"initSegment"===e.sn}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){const e=this._nextAutoLevel,t=this.bwEstimator;if(-1!==e&&!t.canEstimate())return e;let i=this.getNextABRAutoLevel();if(-1!==e){const t=this.hls.levels;if(t.length>Math.max(e,i)&&t[e].loadError<=t[i].loadError)return e}return-1!==e&&(i=Math.min(e,i)),i}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:i}=this,{maxAutoLevel:s,config:r,minAutoLevel:a,media:o}=i,n=t?t.duration:e?e.duration:0,l=o&&0!==o.playbackRate?Math.abs(o.playbackRate):1,h=this.bwEstimator?this.bwEstimator.getEstimate():r.abrEwmaDefaultEstimate,d=i.mainForwardBufferInfo,c=(d?d.len:0)/l;let u=this.findBestLevel(h,a,s,c,r.abrBandWidthFactor,r.abrBandWidthUpFactor);if(u>=0)return u;zh.trace(`[abr] ${c?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let p=n?Math.min(n,r.maxStarvationDelay):r.maxStarvationDelay,f=r.abrBandWidthFactor,m=r.abrBandWidthUpFactor;if(!c){const e=this.bitrateTestDelay;if(e){p=(n?Math.min(n,r.maxLoadingDelay):r.maxLoadingDelay)-e,zh.trace(`[abr] bitrate test took ${Math.round(1e3*e)}ms, set first fragment max fetchDuration to ${Math.round(1e3*p)} ms`),f=m=1}}return u=this.findBestLevel(h,a,s,c+p,f,m),Math.max(u,0)}findBestLevel(e,t,i,s,r,a){var o;const{fragCurrent:n,partCurrent:l,lastLoadedFragLevel:h}=this,{levels:d}=this.hls,c=d[h],u=!(null==c||null==(o=c.details)||!o.live),p=null==c?void 0:c.codecSet,f=l?l.duration:n?n.duration:0,m=this.bwEstimator.getEstimateTTFB()/1e3;let g=t,y=-1;for(let o=i;o>=t;o--){const t=d[o];if(!t||p&&t.codecSet!==p){t&&(g=Math.min(o,g),y=Math.max(o,y));continue}-1!==y&&zh.trace(`[abr] Skipped level(s) ${g}-${y} with CODECS:"${d[y].attrs.CODECS}"; not compatible with "${c.attrs.CODECS}"`);const i=t.details,n=(l?null==i?void 0:i.partTarget:null==i?void 0:i.averagetargetduration)||f;let A;A=o<=h?r*e:a*e;const b=d[o].maxBitrate,v=this.getTimeToLoadFrag(m,A,b*n,void 0===i);if(zh.trace(`[abr] level:${o} adjustedbw-bitrate:${Math.round(A-b)} avgDuration:${n.toFixed(1)} maxFetchDuration:${s.toFixed(1)} fetchDuration:${v.toFixed(1)}`),A>b&&(0===v||!Bh(v)||u&&!this.bitrateTestDelay||v<s))return o}return-1}set nextAutoLevel(e){this._nextAutoLevel=e}},bufferController:class{constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=()=>{const{media:e,mediaSource:t}=this;zh.log("[buffer-controller]: Media source opened"),e&&(e.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(Mh.MEDIA_ATTACHED,{media:e})),t&&t.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{zh.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{zh.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{const{media:e,_objectUrl:t}=this;e&&e.src!==t&&zh.error(`Media element src was set while attaching MediaSource (${t} > ${e.src})`)},this.hls=e,this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null}registerListeners(){const{hls:e}=this;e.on(Mh.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Mh.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Mh.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Mh.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Mh.BUFFER_RESET,this.onBufferReset,this),e.on(Mh.BUFFER_APPENDING,this.onBufferAppending,this),e.on(Mh.BUFFER_CODECS,this.onBufferCodecs,this),e.on(Mh.BUFFER_EOS,this.onBufferEos,this),e.on(Mh.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Mh.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Mh.FRAG_PARSED,this.onFragParsed,this),e.on(Mh.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:e}=this;e.off(Mh.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Mh.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Mh.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Mh.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Mh.BUFFER_RESET,this.onBufferReset,this),e.off(Mh.BUFFER_APPENDING,this.onBufferAppending,this),e.off(Mh.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Mh.BUFFER_EOS,this.onBufferEos,this),e.off(Mh.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Mh.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Mh.FRAG_PARSED,this.onFragParsed,this),e.off(Mh.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new Ef(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,zh.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){const i=this.media=t.media;if(i&&kf){const e=this.mediaSource=new kf;e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),i.src=self.URL.createObjectURL(e),this._objectUrl=i.src,i.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:e,mediaSource:t,_objectUrl:i}=this;if(t){if(zh.log("[buffer-controller]: media source detaching"),"open"===t.readyState)try{t.endOfStream()}catch(e){zh.warn(`[buffer-controller]: onMediaDetaching: ${e.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(e.removeEventListener("emptied",this._onMediaEmptied),i&&self.URL.revokeObjectURL(i),e.src===i?(e.removeAttribute("src"),e.load()):zh.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(Mh.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach((e=>{const t=this.sourceBuffer[e];try{t&&(this.removeBufferListeners(e),this.mediaSource&&this.mediaSource.removeSourceBuffer(t),this.sourceBuffer[e]=void 0)}catch(t){zh.warn(`[buffer-controller]: Failed to reset the ${e} buffer`,t)}})),this._initSourceBuffer()}onBufferCodecs(e,t){const i=this.getSourceBufferTypes().length;Object.keys(t).forEach((e=>{if(i){const i=this.tracks[e];if(i&&"function"==typeof i.buffer.changeType){const{id:s,codec:r,levelCodec:a,container:o,metadata:n}=t[e],l=(i.levelCodec||i.codec).replace(Cf,"$1"),h=(a||r).replace(Cf,"$1");if(l!==h){const t=`${o};codecs=${a||r}`;this.appendChangeType(e,t),zh.log(`[buffer-controller]: switching codec ${l} to ${h}`),this.tracks[e]={buffer:i.buffer,codec:r,container:o,levelCodec:a,metadata:n,id:s}}}}else this.pendingTracks[e]=t[e]})),i||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())}appendChangeType(e,t){const{operationQueue:i}=this,s={execute:()=>{const s=this.sourceBuffer[e];s&&(zh.log(`[buffer-controller]: changing ${e} sourceBuffer type to ${t}`),s.changeType(t)),i.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:t=>{zh.warn(`[buffer-controller]: Failed to change ${e} SourceBuffer type`,t)}};i.append(s,e)}onBufferAppending(e,t){const{hls:i,operationQueue:s,tracks:r}=this,{data:a,type:o,frag:n,part:l,chunkMeta:h}=t,d=h.buffering[o],c=self.performance.now();d.start=c;const u=n.stats.buffering,p=l?l.stats.buffering:null;0===u.start&&(u.start=c),p&&0===p.start&&(p.start=c);const f=r.audio;let m=!1;"audio"===o&&"audio/mpeg"===(null==f?void 0:f.container)&&(m=!this.lastMpegAudioChunk||1===h.id||this.lastMpegAudioChunk.sn!==h.sn,this.lastMpegAudioChunk=h);const g=n.start,y={execute:()=>{if(d.executeStart=self.performance.now(),m){const e=this.sourceBuffer[o];if(e){const t=g-e.timestampOffset;Math.abs(t)>=.1&&(zh.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${g} (delta: ${t}) sn: ${n.sn})`),e.timestampOffset=g)}}this.appendExecutor(a,o)},onStart:()=>{},onComplete:()=>{const e=self.performance.now();d.executeEnd=d.end=e,0===u.first&&(u.first=e),p&&0===p.first&&(p.first=e);const{sourceBuffer:t}=this,i={};for(const e in t)i[e]=ju.getBuffered(t[e]);this.appendError=0,this.hls.trigger(Mh.BUFFER_APPENDED,{type:o,frag:n,part:l,chunkMeta:h,parent:n.type,timeRanges:i})},onError:e=>{zh.error(`[buffer-controller]: Error encountered while trying to append to the ${o} SourceBuffer`,e);const t={type:Fh.MEDIA_ERROR,parent:n.type,details:Uh.BUFFER_APPEND_ERROR,frag:n,part:l,chunkMeta:h,error:e,err:e,fatal:!1};e.code===DOMException.QUOTA_EXCEEDED_ERR?t.details=Uh.BUFFER_FULL_ERROR:(this.appendError++,t.details=Uh.BUFFER_APPEND_ERROR,this.appendError>i.config.appendErrorMaxRetry&&(zh.error(`[buffer-controller]: Failed ${i.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),t.fatal=!0)),i.trigger(Mh.ERROR,t)}};s.append(y,o)}onBufferFlushing(e,t){const{operationQueue:i}=this,s=e=>({execute:this.removeExecutor.bind(this,e,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(Mh.BUFFER_FLUSHED,{type:e})},onError:t=>{zh.warn(`[buffer-controller]: Failed to remove from ${e} SourceBuffer`,t)}});t.type?i.append(s(t.type),t.type):this.getSourceBufferTypes().forEach((e=>{i.append(s(e),e)}))}onFragParsed(e,t){const{frag:i,part:s}=t,r=[],a=s?s.elementaryStreams:i.elementaryStreams;a[Qh]?r.push("audiovideo"):(a[qh]&&r.push("audio"),a[Yh]&&r.push("video"));0===r.length&&zh.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers((()=>{const e=self.performance.now();i.stats.buffering.end=e,s&&(s.stats.buffering.end=e);const t=s?s.stats:i.stats;this.hls.trigger(Mh.FRAG_BUFFERED,{frag:i,part:s,stats:t,id:i.type})}),r)}onFragChanged(e,t){this.flushBackBuffer()}onBufferEos(e,t){this.getSourceBufferTypes().reduce(((e,i)=>{const s=this.sourceBuffer[i];return!s||t.type&&t.type!==i||(s.ending=!0,s.ended||(s.ended=!0,zh.log(`[buffer-controller]: ${i} sourceBuffer now EOS`))),e&&!(s&&!s.ended)}),!0)&&(zh.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers((()=>{this.getSourceBufferTypes().forEach((e=>{const t=this.sourceBuffer[e];t&&(t.ending=!1)}));const{mediaSource:e}=this;e&&"open"===e.readyState?(zh.log("[buffer-controller]: Calling mediaSource.endOfStream()"),e.endOfStream()):e&&zh.info(`[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ${e.readyState}`)})))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){const{hls:e,details:t,media:i,sourceBuffer:s}=this;if(!i||null===t)return;const r=this.getSourceBufferTypes();if(!r.length)return;const a=t.live&&null!==e.config.liveBackBufferLength?e.config.liveBackBufferLength:e.config.backBufferLength;if(!Bh(a)||a<0)return;const o=i.currentTime,n=t.levelTargetDuration,l=Math.max(a,n),h=Math.floor(o/n)*n-l;r.forEach((i=>{const r=s[i];if(r){const s=ju.getBuffered(r);if(s.length>0&&h>s.start(0)){if(e.trigger(Mh.BACK_BUFFER_REACHED,{bufferEnd:h}),t.live)e.trigger(Mh.LIVE_BACK_BUFFER_REACHED,{bufferEnd:h});else if(r.ended&&s.end(s.length-1)-o<2*n)return void zh.info(`[buffer-controller]: Cannot flush ${i} back buffer while SourceBuffer is in ended state`);e.trigger(Mh.BUFFER_FLUSHING,{startOffset:0,endOffset:h,type:i})}}}))}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||"open"!==this.mediaSource.readyState)return;const{details:e,hls:t,media:i,mediaSource:s}=this,r=e.fragments[0].start+e.totalduration,a=i.duration,o=Bh(s.duration)?s.duration:0;e.live&&t.config.liveDurationInfinity?(zh.log("[buffer-controller]: Media Source duration is set to Infinity"),s.duration=1/0,this.updateSeekableRange(e)):(r>o&&r>a||!Bh(a))&&(zh.log(`[buffer-controller]: Updating Media Source duration to ${r.toFixed(3)}`),s.duration=r)}updateSeekableRange(e){const t=this.mediaSource,i=e.fragments;if(i.length&&e.live&&null!=t&&t.setLiveSeekableRange){const s=Math.max(0,i[0].start),r=Math.max(s,s+e.totalduration);t.setLiveSeekableRange(s,r)}}checkPendingTracks(){const{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:i}=this,s=Object.keys(i).length;if(s&&!e||2===s){this.createSourceBuffers(i),this.pendingTracks={};const e=this.getSourceBufferTypes();if(e.length)this.hls.trigger(Mh.BUFFER_CREATED,{tracks:this.tracks}),e.forEach((e=>{t.executeNext(e)}));else{const e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(Mh.ERROR,{type:Fh.MEDIA_ERROR,details:Uh.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}}createSourceBuffers(e){const{sourceBuffer:t,mediaSource:i}=this;if(!i)throw Error("createSourceBuffers called when mediaSource was null");for(const s in e)if(!t[s]){const r=e[s];if(!r)throw Error(`source buffer exists for track ${s}, however track does not`);const a=r.levelCodec||r.codec,o=`${r.container};codecs=${a}`;zh.log(`[buffer-controller]: creating sourceBuffer(${o})`);try{const e=t[s]=i.addSourceBuffer(o),n=s;this.addBufferListener(n,"updatestart",this._onSBUpdateStart),this.addBufferListener(n,"updateend",this._onSBUpdateEnd),this.addBufferListener(n,"error",this._onSBUpdateError),this.tracks[s]={buffer:e,codec:a,container:r.container,levelCodec:r.levelCodec,metadata:r.metadata,id:r.id}}catch(e){zh.error(`[buffer-controller]: error while trying to add sourceBuffer: ${e.message}`),this.hls.trigger(Mh.ERROR,{type:Fh.MEDIA_ERROR,details:Uh.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,mimeType:o})}}}_onSBUpdateStart(e){const{operationQueue:t}=this;t.current(e).onStart()}_onSBUpdateEnd(e){const{operationQueue:t}=this;t.current(e).onComplete(),t.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){const i=new Error(`${e} SourceBuffer error`);zh.error(`[buffer-controller]: ${i}`,t),this.hls.trigger(Mh.ERROR,{type:Fh.MEDIA_ERROR,details:Uh.BUFFER_APPENDING_ERROR,error:i,fatal:!1});const s=this.operationQueue.current(e);s&&s.onError(t)}removeExecutor(e,t,i){const{media:s,mediaSource:r,operationQueue:a,sourceBuffer:o}=this,n=o[e];if(!s||!r||!n)return zh.warn(`[buffer-controller]: Attempting to remove from the ${e} SourceBuffer, but it does not exist`),void a.shiftAndExecuteNext(e);const l=Bh(s.duration)?s.duration:1/0,h=Bh(r.duration)?r.duration:1/0,d=Math.max(0,t),c=Math.min(i,l,h);c>d&&!n.ending?(n.ended=!1,zh.log(`[buffer-controller]: Removing [${d},${c}] from the ${e} SourceBuffer`),n.remove(d,c)):a.shiftAndExecuteNext(e)}appendExecutor(e,t){const{operationQueue:i,sourceBuffer:s}=this,r=s[t];if(!r)return zh.warn(`[buffer-controller]: Attempting to append to the ${t} SourceBuffer, but it does not exist`),void i.shiftAndExecuteNext(t);r.ended=!1,r.appendBuffer(e)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length)return zh.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(e);const{operationQueue:i}=this,s=t.map((e=>i.appendBlocker(e)));Promise.all(s).then((()=>{e(),t.forEach((e=>{const t=this.sourceBuffer[e];null!=t&&t.updating||i.shiftAndExecuteNext(e)}))}))}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,i){const s=this.sourceBuffer[e];if(!s)return;const r=i.bind(this,e);this.listeners[e].push({event:t,listener:r}),s.addEventListener(t,r)}removeBufferListeners(e){const t=this.sourceBuffer[e];t&&this.listeners[e].forEach((e=>{t.removeEventListener(e.event,e.listener)}))}},capLevelController:_m,errorController:class{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=zh.log.bind(zh,"[info]:"),this.warn=zh.warn.bind(zh,"[warning]:"),this.error=zh.error.bind(zh,"[error]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(Mh.ERROR,this.onError,this),e.on(Mh.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Mh.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(Mh.ERROR,this.onError,this),e.off(Mh.ERROR,this.onErrorOut,this),e.off(Mh.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Mh.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){this.playlistError=0}stopLoad(){}getVariantLevelIndex(e){return(null==e?void 0:e.type)===Cc?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var i,s;if(t.fatal)return;const r=this.hls,a=t.context;switch(t.details){case Uh.FRAG_LOAD_ERROR:case Uh.FRAG_LOAD_TIMEOUT:case Uh.KEY_LOAD_ERROR:case Uh.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case Uh.FRAG_PARSING_ERROR:if(null!=(i=t.frag)&&i.gap)return void(t.errorAction={action:pu,flags:gu});case Uh.FRAG_GAP:case Uh.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=fu);case Uh.LEVEL_EMPTY_ERROR:case Uh.LEVEL_PARSING_ERROR:{var o,n;const e=t.parent===Cc?t.level:r.loadLevel;t.details===Uh.LEVEL_EMPTY_ERROR&&null!=(o=t.context)&&null!=(n=o.levelDetails)&&n.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,e):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,e))}return;case Uh.LEVEL_LOAD_ERROR:case Uh.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==a?void 0:a.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level)));case Uh.AUDIO_TRACK_LOAD_ERROR:case Uh.AUDIO_TRACK_LOAD_TIMEOUT:case Uh.SUBTITLE_LOAD_ERROR:case Uh.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){const e=r.levels[r.loadLevel];if(e&&(a.type===Ec&&a.groupId===e.audioGroupId||a.type===kc&&a.groupId===e.textGroupId))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,r.loadLevel),t.errorAction.action=fu,void(t.errorAction.flags=yu)}return;case Uh.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const e=r.levels[r.loadLevel],i=null==e?void 0:e.attrs["HDCP-LEVEL"];i&&(t.errorAction={action:fu,flags:Au,hdcpLevel:i})}return;case Uh.BUFFER_ADD_CODEC_ERROR:case Uh.REMUX_ALLOC_ERROR:return void(t.errorAction=this.getLevelSwitchAction(t,null!=(s=t.level)?s:r.loadLevel));case Uh.INTERNAL_EXCEPTION:case Uh.BUFFER_APPENDING_ERROR:case Uh.BUFFER_APPEND_ERROR:case Uh.BUFFER_FULL_ERROR:case Uh.LEVEL_SWITCH_ERROR:case Uh.BUFFER_STALLED_ERROR:case Uh.BUFFER_SEEK_OVER_HOLE:case Uh.BUFFER_NUDGE_ON_STALL:return void(t.errorAction={action:pu,flags:gu})}if(t.type===Fh.KEY_SYSTEM_ERROR){const e=this.getVariantLevelIndex(t.frag);return t.levelRetry=!1,void(t.errorAction=this.getLevelSwitchAction(t,e))}}getPlaylistRetryOrSwitchAction(e,t){var i;const s=au(this.hls.config.playlistLoadPolicy,e),r=this.playlistError++,a=null==(i=e.response)?void 0:i.code;if(lu(s,r,ru(e),a))return{action:mu,flags:gu,retryConfig:s,retryCount:r};const o=this.getLevelSwitchAction(e,t);return s&&(o.retryConfig=s,o.retryCount=r),o}getFragRetryOrSwitchAction(e){const t=this.hls,i=this.getVariantLevelIndex(e.frag),s=t.levels[i],{fragLoadPolicy:r,keyLoadPolicy:a}=t.config,o=au(e.details.startsWith("key")?a:r,e),n=t.levels.reduce(((e,t)=>e+t.fragmentError),0);if(s){var l;e.details!==Uh.FRAG_GAP&&s.fragmentError++;const t=null==(l=e.response)?void 0:l.code;if(lu(o,n,ru(e),t))return{action:mu,flags:gu,retryConfig:o,retryCount:n}}const h=this.getLevelSwitchAction(e,i);return o&&(h.retryConfig=o,h.retryCount=n),h}getLevelSwitchAction(e,t){const i=this.hls;null==t&&(t=i.loadLevel);const s=this.hls.levels[t];if(s&&(s.loadError++,i.autoLevelEnabled)){var r,a;let t=-1;const{levels:o,loadLevel:n,minAutoLevel:l,maxAutoLevel:h}=i,d=null==(r=e.frag)?void 0:r.type,{type:c,groupId:u}=null!=(a=e.context)?a:{};for(let i=o.length;i--;){const r=(i+n)%o.length;if(r!==n&&r>=l&&r<=h&&0===o[r].loadError){const i=o[r];if(e.details===Uh.FRAG_GAP&&e.frag){const t=o[r].details;if(t){const i=du(e.frag,t.fragments,e.frag.start);if(null!=i&&i.gap)continue}}else{if(c===Ec&&u===i.audioGroupId||c===kc&&u===i.textGroupId)continue;if(d===xc&&s.audioGroupId===i.audioGroupId||d===Rc&&s.textGroupId===i.textGroupId)continue}t=r;break}}if(t>-1&&i.loadLevel!==t)return e.levelRetry=!0,this.playlistError=0,{action:fu,flags:gu,nextAutoLevel:t}}return{action:fu,flags:yu}}onErrorOut(e,t){var i;switch(null==(i=t.errorAction)?void 0:i.action){case pu:break;case fu:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===Uh.FRAG_GAP||(t.fatal=!0)}t.fatal&&this.hls.stopLoad()}sendAlternateToPenaltyBox(e){const t=this.hls,i=e.errorAction;if(!i)return;const{flags:s,hdcpLevel:r,nextAutoLevel:a}=i;switch(s){case gu:this.switchLevel(e,a);break;case yu:i.resolved||(i.resolved=this.redundantFailover(e));break;case Au:r&&(t.maxHdcpLevel=Hc[Hc.indexOf(r)-1],i.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`)}i.resolved||this.switchLevel(e,a)}switchLevel(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)}redundantFailover(e){const{hls:t,penalizedRenditions:i}=this,s=e.parent===Cc?e.level:t.loadLevel,r=t.levels[s],a=r.url.length,o=e.frag?e.frag.urlId:r.urlId;r.urlId!==o||e.frag&&!r.details||this.penalizeRendition(r,e);for(let n=1;n<a;n++){const l=(o+n)%a,h=i[l];if(!h||bu(h,e,i[o]))return this.warn(`Switching to Redundant Stream ${l+1}/${a}: "${r.url[l]}" after ${e.details}`),this.playlistError=0,t.levels.forEach((e=>{e.urlId=l})),t.nextLoadLevel=s,!0}return!1}penalizeRendition(e,t){const{penalizedRenditions:i}=this,s=i[e.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};s.lastErrorPerfMs=performance.now(),s.errors.push(t),s.details=e.details,i[e.urlId]=s}},fpsController:class{constructor(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()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(Mh.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(Mh.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const i=this.hls.config;if(i.capLevelOnFPSDrop){const e=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=e,e&&"function"==typeof e.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,i){const s=performance.now();if(t){if(this.lastTime){const e=s-this.lastTime,r=i-this.lastDroppedFrames,a=t-this.lastDecodedFrames,o=1e3*r/e,n=this.hls;if(n.trigger(Mh.FPS_DROP,{currentDropped:r,currentDecoded:a,totalDroppedFrames:i}),o>0&&r>n.config.fpsDroppedMonitoringThreshold*a){let e=n.currentLevel;zh.warn("drop FPS ratio greater than max allowed value for currentLevel: "+e),e>0&&(-1===n.autoLevelCapping||n.autoLevelCapping>=e)&&(e-=1,n.trigger(Mh.FPS_DROP_LEVEL_CAPPING,{level:e,droppedLevel:n.currentLevel}),n.autoLevelCapping=e,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=i,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}},stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:fd,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!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},{cueHandler:Gm,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:class extends dp{constructor(e,t,i){super(e,t,i,"[subtitle-stream-controller]",Rc),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null}_registerListeners(){const{hls:e}=this;e.on(Mh.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Mh.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Mh.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Mh.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Mh.ERROR,this.onError,this),e.on(Mh.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(Mh.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(Mh.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(Mh.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(Mh.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Mh.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(Mh.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Mh.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Mh.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Mh.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Mh.ERROR,this.onError,this),e.off(Mh.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(Mh.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(Mh.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(Mh.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(Mh.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Mh.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=Zu,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:i,success:s}=t;if(this.fragPrevious=i,this.state=Zu,!s)return;const r=this.tracksBuffered[this.currentTrackId];if(!r)return;let a;const o=i.start;for(let e=0;e<r.length;e++)if(o>=r[e].start&&o<=r[e].end){a=r[e];break}const n=i.start+i.duration;a?a.end=n:(a={start:o,end:n},r.push(a)),this.fragmentTracker.fragBuffered(i)}onBufferFlushing(e,t){const{startOffset:i,endOffset:s}=t;if(0===i&&s!==Number.POSITIVE_INFINITY){const e=s-1;if(e<=0)return;t.endOffsetSubtitles=Math.max(0,e),this.tracksBuffered.forEach((t=>{for(let i=0;i<t.length;)if(t[i].end<=e)t.shift();else{if(!(t[i].start<e))break;t[i].start=e,i++}})),this.fragmentTracker.removeFragmentsInRange(i,e,Rc)}}onFragBuffered(e,t){var i;this.loadedmetadata||t.frag.type!==Cc||null!=(i=this.media)&&i.buffered.length&&(this.loadedmetadata=!0)}onError(e,t){const i=t.frag;(null==i?void 0:i.type)===Rc&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==Xu&&(this.state=Zu))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){_f(this.levels,t)?this.levels=t.map((e=>new Yc(e))):(this.tracksBuffered=[],this.levels=t.map((e=>{const t=new Yc(e);return this.tracksBuffered[t.id]=[],t})),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Rc),this.fragPrevious=null,this.mediaBuffer=null)}onSubtitleTrackSwitch(e,t){if(this.currentTrackId=t.id,!this.levels.length||-1===this.currentTrackId)return void this.clearInterval();const i=this.levels[this.currentTrackId];null!=i&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.setInterval(500)}onSubtitleTrackLoaded(e,t){var i;const{details:s,id:r}=t,{currentTrackId:a,levels:o}=this;if(!o.length)return;const n=o[a];if(r>=o.length||r!==a||!n)return;this.mediaBuffer=this.mediaBufferTimeRanges;let l=0;if(s.live||null!=(i=n.details)&&i.live){const e=this.mainDetails;if(s.deltaUpdateFailed||!e)return;const t=e.fragments[0];n.details?(l=this.alignPlaylists(s,n.details),0===l&&t&&(l=t.start,tu(s,l))):s.hasProgramDateTime&&e.hasProgramDateTime?(Vu(s,e),l=s.fragments[0].start):t&&(l=t.start,tu(s,l))}if(n.details=s,this.levelLastLoaded=r,this.startFragRequested||!this.mainDetails&&s.live||this.setStartPosition(n.details,l),this.tick(),s.live&&!this.fragCurrent&&this.media&&this.state===Zu){du(null,s.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),n.details=void 0)}}_handleFragmentLoadComplete(e){const{frag:t,payload:i}=e,s=t.decryptdata,r=this.hls;if(!this.fragContextChanged(t)&&i&&i.byteLength>0&&s&&s.key&&s.iv&&"AES-128"===s.method){const e=performance.now();this.decrypter.decrypt(new Uint8Array(i),s.key.buffer,s.iv.buffer).catch((e=>{throw r.trigger(Mh.ERROR,{type:Fh.MEDIA_ERROR,details:Uh.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e})).then((i=>{const s=performance.now();r.trigger(Mh.FRAG_DECRYPTED,{frag:t,payload:i,stats:{tstart:e,tdecrypt:s}})})).catch((e=>{this.warn(`${e.name}: ${e.message}`),this.state=Zu}))}}doTick(){if(this.media){if(this.state===Zu){const{currentTrackId:e,levels:t}=this,i=t[e];if(!t.length||!i||!i.details)return;const{config:s}=this,r=this.getLoadPosition(),a=ju.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],r,s.maxBufferHole),{end:o,len:n}=a,l=this.getFwdBufferInfo(this.media,Cc),h=i.details;if(n>this.getMaxBufferLength(null==l?void 0:l.len)+h.levelTargetDuration)return;const d=h.fragments,c=d.length,u=h.edge;let p=null;const f=this.fragPrevious;if(o<u){const e=s.maxFragLookUpTolerance,t=o>u-e?0:e;p=du(f,d,Math.max(d[0].start,o),t),!p&&f&&f.start<d[0].start&&(p=d[0])}else p=d[c-1];if(!p)return;if(p=this.mapToInitFragWhenRequired(p),"initSegment"!==p.sn){const e=d[p.sn-h.startSN-1];e&&e.cc===p.cc&&this.fragmentTracker.getState(e)===Eu&&(p=e)}this.fragmentTracker.getState(p)===Eu&&this.loadFragment(p,i,o)}}else this.state=Zu}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,i){this.fragCurrent=e,"initSegment"===e.sn?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,i))}get mediaBufferTimeRanges(){return new Sf(this.tracksBuffered[this.currentTrackId]||[])}},subtitleTrackController:class extends vu{constructor(e){super(e,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.trackChangeListener=()=>this.onTextTracksChanged(),this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes(this.trackId)}registerListeners(){const{hls:e}=this;e.on(Mh.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Mh.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Mh.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Mh.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Mh.LEVEL_LOADING,this.onLevelLoading,this),e.on(Mh.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Mh.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(Mh.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(Mh.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Mh.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Mh.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Mh.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Mh.LEVEL_LOADING,this.onLevelLoading,this),e.off(Mh.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Mh.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(Mh.ERROR,this.onError,this)}onMediaAttached(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))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)}onMediaDetaching(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);Tf(this.media.textTracks).forEach((e=>{Mc(e)})),this.subtitleTrack=-1,this.media=null}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){const{id:i,details:s}=t,{trackId:r}=this,a=this.tracksInGroup[r];if(!a)return void this.warn(`Invalid subtitle track id ${i}`);const o=a.details;a.details=t.details,this.log(`subtitle track ${i} loaded [${s.startSN}-${s.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(null==t||!t.textGroupIds)return;const i=t.textGroupIds[t.urlId],s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==i){const e=this.tracks.filter((e=>!i||e.groupId===i));this.tracksInGroup=e;const t=this.findTrackId(null==s?void 0:s.name)||this.findTrackId();this.groupId=i||null;const r={subtitleTracks:e};this.log(`Updating subtitle tracks, ${e.length} track(s) found in "${i}" group-id`),this.hls.trigger(Mh.SUBTITLE_TRACKS_UPDATED,r),-1!==t&&this.setSubtitleTrack(t,s)}else this.shouldReloadPlaylist(s)&&this.setSubtitleTrack(this.trackId,s)}findTrackId(e){const t=this.tracksInGroup;for(let i=0;i<t.length;i++){const s=t[i];if((!this.selectDefaultTrack||s.default)&&(!e||e===s.name))return s.id}return-1}onError(e,t){!t.fatal&&t.context&&t.context.type===kc&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&this.checkRetry(t)}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1;const t=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,t)}loadPlaylist(e){super.loadPlaylist();const t=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(t)){const i=t.id,s=t.groupId;let r=t.url;if(e)try{r=e.addDirectives(r)}catch(e){this.warn(`Could not construct new URL with HLS Delivery Directives: ${e}`)}this.log(`Loading subtitle playlist for id ${i}`),this.hls.trigger(Mh.SUBTITLE_TRACK_LOADING,{url:r,id:i,groupId:s,deliveryDirectives:e||null})}}toggleTrackModes(e){const{media:t,trackId:i}=this;if(!t)return;const s=Tf(t.textTracks),r=s.filter((e=>e.groupId===this.groupId));if(-1===e)[].slice.call(s).forEach((e=>{e.mode="disabled"}));else{const e=r[i];e&&(e.mode="disabled")}const a=r[e];a&&(a.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(e,t){var i;const s=this.tracksInGroup;if(!this.media)return void(this.queuedDefaultTrack=e);if(this.trackId!==e&&this.toggleTrackModes(e),this.trackId===e&&(-1===e||null!=(i=s[e])&&i.details)||e<-1||e>=s.length)return;this.clearTimer();const r=s[e];if(this.log(`Switching to subtitle-track ${e}`+(r?` "${r.name}" lang:${r.lang} group:${r.groupId}`:"")),this.trackId=e,r){const{id:e,groupId:i="",name:s,type:a,url:o}=r;this.hls.trigger(Mh.SUBTITLE_TRACK_SWITCH,{id:e,groupId:i,name:s,type:a,url:o});const n=this.switchParams(r.url,null==t?void 0:t.details);this.loadPlaylist(n)}else this.hls.trigger(Mh.SUBTITLE_TRACK_SWITCH,{id:e})}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let e=-1;const t=Tf(this.media.textTracks);for(let i=0;i<t.length;i++)if("hidden"===t[i].mode)e=i;else if("showing"===t[i].mode){e=i;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}},timelineController:class{constructor(e){if(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.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},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}},this.config.enableCEA708Captions){const e=new Jf(this,"textTrack1"),t=new Jf(this,"textTrack2"),i=new Jf(this,"textTrack3"),s=new Jf(this,"textTrack4");this.cea608Parser1=new Wf(1,e,t),this.cea608Parser2=new Wf(3,i,s)}e.on(Mh.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Mh.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Mh.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Mh.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Mh.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(Mh.FRAG_LOADING,this.onFragLoading,this),e.on(Mh.FRAG_LOADED,this.onFragLoaded,this),e.on(Mh.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(Mh.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(Mh.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(Mh.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(Mh.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(Mh.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Mh.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Mh.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Mh.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Mh.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(Mh.FRAG_LOADING,this.onFragLoading,this),e.off(Mh.FRAG_LOADED,this.onFragLoaded,this),e.off(Mh.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(Mh.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(Mh.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(Mh.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(Mh.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null}addCues(e,t,i,s,r){let a=!1;for(let e=r.length;e--;){const s=r[e],d=(o=s[0],n=s[1],l=t,h=i,Math.min(n,h)-Math.max(o,l));if(d>=0&&(s[0]=Math.min(s[0],t),s[1]=Math.max(s[1],i),a=!0,d/(i-t)>.5))return}var o,n,l,h;if(a||r.push([t,i]),this.config.renderTextTracksNatively){const r=this.captionsTracks[e];this.Cues.newCue(r,t,i,s)}else{const r=this.Cues.newCue(null,t,i,s);this.hls.trigger(Mh.CUES_PARSED,{type:"captions",cues:r,track:e})}}onInitPtsFound(e,{frag:t,id:i,initPTS:s,timescale:r}){const{unparsedVttFrags:a}=this;"main"===i&&(this.initPTS[t.cc]={baseTime:s,timescale:r}),a.length&&(this.unparsedVttFrags=[],a.forEach((e=>{this.onFragLoaded(Mh.FRAG_LOADED,e)})))}getExistingTrack(e){const{media:t}=this;if(t)for(let i=0;i<t.textTracks.length;i++){const s=t.textTracks[i];if(s[e])return s}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:i,media:s}=this,{label:r,languageCode:a}=t[e],o=this.getExistingTrack(e);if(o)i[e]=o,Mc(i[e]),Pc(i[e],s);else{const t=this.createTextTrack("captions",r,a);t&&(t[e]=!0,i[e]=t)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const i={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=i,this.hls.trigger(Mh.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[i]})}createTextTrack(e,t,i){const s=this.media;if(s)return s.addTextTrack(e,t,i)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:e}=this;Object.keys(e).forEach((t=>{Mc(e[t]),delete e[t]})),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:e}=this;if(!e)return;const t=e.textTracks;if(t)for(let e=0;e<t.length;e++)Mc(t[e])}onSubtitleTracksUpdated(e,t){const i=t.subtitleTracks||[],s=i.some((e=>e.textCodec===hm));if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(_f(this.tracks,i))return void(this.tracks=i);if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){const e=this.media?this.media.textTracks:null;this.tracks.forEach(((t,i)=>{let s;if(e&&i<e.length){let i=null;for(let s=0;s<e.length;s++)if(vm(e[s],t)){i=e[s];break}i&&(s=i)}if(s)Mc(s);else{const e=this._captionsOrSubtitlesFromCharacteristics(t);s=this.createTextTrack(e,t.name,t.lang),s&&(s.mode="disabled")}s&&(s.groupId=t.groupId,this.textTracks.push(s))}))}else if(this.tracks.length){const e=this.tracks.map((e=>({label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e})));this.hls.trigger(Mh.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:e})}}}_captionsOrSubtitlesFromCharacteristics(e){if(e.attrs.CHARACTERISTICS){const t=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS),i=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(t&&i)return"captions"}return"subtitles"}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach((e=>{const t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(!t)return;const i=`textTrack${t[1]}`,s=this.captionsProperties[i];s&&(s.label=e.name,e.lang&&(s.languageCode=e.lang),s.media=e)}))}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){const{cea608Parser1:i,cea608Parser2:s,lastSn:r,lastPartIndex:a}=this;if(this.enabled&&i&&s&&t.frag.type===Cc){var o,n;const e=t.frag.sn,l=null!=(o=null==t||null==(n=t.part)?void 0:n.index)?o:-1;e===r+1||e===r&&l===a+1||(i.reset(),s.reset()),this.lastSn=e,this.lastPartIndex=l}}onFragLoaded(e,t){const{frag:i,payload:s}=t;if(i.type===Rc)if(s.byteLength){const e=i.decryptdata,r="stats"in t;if(null==e||!e.encrypted||r){const e=this.tracks[i.level],r=this.vttCCs;r[i.cc]||(r[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),e&&e.textCodec===hm?this._parseIMSC1(i,s):this._parseVTTs(t)}}else this.hls.trigger(Mh.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const i=this.hls;pm(t,this.initPTS[e.cc],(t=>{this._appendCues(t,e.level),i.trigger(Mh.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})}),(t=>{zh.log(`Failed to parse IMSC1: ${t}`),i.trigger(Mh.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})}))}_parseVTTs(e){var t;const{frag:i,payload:s}=e,{initPTS:r,unparsedVttFrags:a}=this,o=r.length-1;if(!r[i.cc]&&-1===o)return void a.push(e);const n=this.hls;lm(null!=(t=i.initSegment)&&t.data?Vd(i.initSegment.data,new Uint8Array(s)):s,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,(e=>{this._appendCues(e,i.level),n.trigger(Mh.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})}),(t=>{const r="Missing initPTS for VTT MPEGTS"===t.message;r?a.push(e):this._fallbackToIMSC1(i,s),zh.log(`Failed to parse VTT cue: ${t}`),r&&o>i.cc||n.trigger(Mh.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:t})}))}_fallbackToIMSC1(e,t){const i=this.tracks[e.level];i.textCodec||pm(t,this.initPTS[e.cc],(()=>{i.textCodec=hm,this._parseIMSC1(e,t)}),(()=>{i.textCodec="wvtt"}))}_appendCues(e,t){const i=this.hls;if(this.config.renderTextTracksNatively){const i=this.textTracks[t];if(!i||"disabled"===i.mode)return;e.forEach((e=>Bc(i,e)))}else{const s=this.tracks[t];if(!s)return;const r=s.default?"default":"subtitles"+t;i.trigger(Mh.CUES_PARSED,{type:"subtitles",cues:e,track:r})}}onFragDecrypted(e,t){const{frag:i}=t;i.type===Rc&&this.onFragLoaded(Mh.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){const{cea608Parser1:i,cea608Parser2:s}=this;if(!this.enabled||!i||!s)return;const{frag:r,samples:a}=t;if(r.type!==Cc||"NONE"!==this.closedCaptionsForLevel(r))for(let e=0;e<a.length;e++){const t=a[e].bytes;if(t){const r=this.extractCea608Data(t);i.addData(a[e].pts,r[0]),s.addData(a[e].pts,r[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:i,endOffsetSubtitles:s,type:r}){const{media:a}=this;if(a&&!(a.currentTime<i)){if(!r||"video"===r){const{captionsTracks:e}=this;Object.keys(e).forEach((s=>Fc(e[s],t,i)))}if(this.config.renderTextTracksNatively&&0===t&&void 0!==s){const{textTracks:e}=this;Object.keys(e).forEach((i=>Fc(e[i],t,s)))}}}extractCea608Data(e){const t=[[],[]],i=31&e[0];let s=2;for(let r=0;r<i;r++){const i=e[s++],r=127&e[s++],a=127&e[s++];if(0===r&&0===a)continue;if(0!=(4&i)){const e=3&i;0!==e&&1!==e||(t[e].push(r),t[e].push(a))}}return t}},audioStreamController:class extends dp{constructor(e,t,i){super(e,t,i,"[audio-stream-controller]",xc),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){const{hls:e}=this;e.on(Mh.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Mh.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Mh.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Mh.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Mh.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(Mh.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(Mh.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(Mh.ERROR,this.onError,this),e.on(Mh.BUFFER_RESET,this.onBufferReset,this),e.on(Mh.BUFFER_CREATED,this.onBufferCreated,this),e.on(Mh.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(Mh.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(Mh.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(Mh.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Mh.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Mh.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Mh.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Mh.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(Mh.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(Mh.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(Mh.ERROR,this.onError,this),e.off(Mh.BUFFER_RESET,this.onBufferReset,this),e.off(Mh.BUFFER_CREATED,this.onBufferCreated,this),e.off(Mh.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(Mh.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(Mh.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:i,initPTS:s,timescale:r}){if("main"===i){const e=t.cc;this.initPTS[t.cc]={baseTime:s,timescale:r},this.log(`InitPTS for cc: ${e} found from main: ${s}`),this.videoTrackCC=e,this.state===lp&&this.tick()}}startLoad(e){if(!this.levels)return this.startPosition=e,void(this.state=Xu);const t=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),t>0&&-1===e?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=Zu):(this.loadedmetadata=!1,this.state=sp),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case Zu:this.doTickIdle();break;case sp:{var e;const{levels:t,trackId:i}=this,s=null==t||null==(e=t[i])?void 0:e.details;if(s){if(this.waitForCdnTuneIn(s))break;this.state=lp}break}case ip:{var t;const e=performance.now(),i=this.retryDate;(!i||e>=i||null!=(t=this.media)&&t.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=Zu);break}case lp:{const e=this.waitingData;if(e){const{frag:t,part:i,cache:s,complete:r}=e;if(void 0!==this.initPTS[t.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=tp;const e={frag:t,part:i,payload:s.flush(),networkDetails:null};this._handleFragmentLoadProgress(e),r&&super._handleFragmentLoadComplete(e)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${t.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{const e=this.getLoadPosition(),i=ju.bufferInfo(this.mediaBuffer,e,this.config.maxBufferHole);cu(i.end,this.config.maxFragLookUpTolerance,t)<0&&(this.log(`Waiting fragment cc (${t.cc}) @ ${t.start} cancelled because another fragment at ${i.end} is needed`),this.clearWaitingFragment())}}else this.state=Zu}}this.onTickEnd()}clearWaitingFragment(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=Zu)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){const{media:e}=this;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){const{hls:e,levels:t,media:i,trackId:s}=this,r=e.config;if(null==t||!t[s])return;if(!i&&(this.startFragRequested||!r.startFragPrefetch))return;const a=t[s],o=a.details;if(!o||o.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(o))return void(this.state=sp);const n=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&n&&(this.bufferFlushed=!1,this.afterBufferFlushed(n,qh,xc));const l=this.getFwdBufferInfo(n,xc);if(null===l)return;const{bufferedTrack:h,switchingTrack:d}=this;if(!d&&this._streamEnded(l,o))return e.trigger(Mh.BUFFER_EOS,{type:"audio"}),void(this.state=op);const c=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,Cc),u=l.len,p=this.getMaxBufferLength(null==c?void 0:c.len);if(u>=p&&!d)return;const f=o.fragments[0].start;let m=l.end;if(d&&i){const e=this.getLoadPosition();h&&d.attrs!==h.attrs&&(m=e),o.PTSKnown&&e<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)}let g=this.getNextFragment(m,o),y=!1;if(g&&this.isLoopLoading(g,m)&&(y=!!g.gap,g=this.getNextFragmentLoopLoading(g,o,l,Cc,p)),!g)return void(this.bufferFlushed=!0);const A=c&&g.start>c.end+o.targetduration;if(A||(null==c||!c.len)&&l.len){const e=this.getAppendedFrag(g.start,Cc);if(null===e)return;if(y||(y=!!e.gap||!!A&&0===c.len),A&&!y||y&&l.nextStart&&l.nextStart<e.end)return}this.loadFragment(g,a,m)}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map((e=>new Yc(e)))}onAudioTrackSwitching(e,t){const i=!!t.url;this.trackId=t.id;const{fragCurrent:s}=this;s&&(s.abortRequests(),this.removeUnbufferedFrags(s.start)),this.resetLoadingState(),i?this.setInterval(100):this.resetTransmuxer(),i?(this.switchingTrack=t,this.state=Zu):(this.switchingTrack=null,this.bufferedTrack=t,this.state=Xu),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,t){this.mainDetails=t.details,null!==this.cachedTrackLoadedData&&(this.hls.trigger(Mh.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var i;if(null==this.mainDetails)return void(this.cachedTrackLoadedData=t);const{levels:s}=this,{details:r,id:a}=t;if(!s)return void this.warn(`Audio tracks were reset while loading level ${a}`);this.log(`Track ${a} loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""},duration:${r.totalduration}`);const o=s[a];let n=0;if(r.live||null!=(i=o.details)&&i.live){this.checkLiveUpdate(r);const e=this.mainDetails;if(r.deltaUpdateFailed||!e)return;!o.details&&r.hasProgramDateTime&&e.hasProgramDateTime?(Vu(r,e),n=r.fragments[0].start):n=this.alignPlaylists(r,o.details)}o.details=r,this.levelLastLoaded=a,this.startFragRequested||!this.mainDetails&&r.live||this.setStartPosition(o.details,n),this.state!==sp||this.waitForCdnTuneIn(r)||(this.state=Zu),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:i,part:s,payload:r}=e,{config:a,trackId:o,levels:n}=this;if(!n)return void this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);const l=n[o];if(!l)return void this.warn("Audio track is undefined on fragment load progress");const h=l.details;if(!h)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(i.start);const d=a.defaultAudioCodec||l.audioCodec||"mp4a.40.2";let c=this.transmuxer;c||(c=this.transmuxer=new mf(this.hls,xc,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const u=this.initPTS[i.cc],p=null==(t=i.initSegment)?void 0:t.data;if(void 0!==u){const e=!1,t=s?s.index:-1,a=-1!==t,o=new Gu(i.level,i.sn,i.stats.chunkCount,r.byteLength,t,a);c.push(r,p,d,"",i,s,h.totalduration,e,o,u)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${h.startSN} ,${h.endSN}],track ${o}`);const{cache:e}=this.waitingData=this.waitingData||{frag:i,part:s,cache:new vf,complete:!1};e.push(new Uint8Array(r)),this.waitingVideoCC=this.videoTrackCC,this.state=lp}}_handleFragmentLoadComplete(e){this.waitingData?this.waitingData.complete=!0:super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){const i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){const{frag:i,part:s}=t;if(i.type===xc)if(this.fragContextChanged(i))this.warn(`Fragment ${i.sn}${s?" p: "+s.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;const e=this.switchingTrack;e&&(this.bufferedTrack=e,this.switchingTrack=null,this.hls.trigger(Mh.AUDIO_TRACK_SWITCHED,Lh({},e)))}this.fragBufferedComplete(i,s)}else if(!this.loadedmetadata&&i.type===Cc){const e=this.videoBuffer||this.media;if(e){ju.getBuffered(e).length&&(this.loadedmetadata=!0)}}}onError(e,t){var i;if(t.fatal)this.state=np;else switch(t.details){case Uh.FRAG_GAP:case Uh.FRAG_PARSING_ERROR:case Uh.FRAG_DECRYPT_ERROR:case Uh.FRAG_LOAD_ERROR:case Uh.FRAG_LOAD_TIMEOUT:case Uh.KEY_LOAD_ERROR:case Uh.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(xc,t);break;case Uh.AUDIO_TRACK_LOAD_ERROR:case Uh.AUDIO_TRACK_LOAD_TIMEOUT:case Uh.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==sp||(null==(i=t.context)?void 0:i.type)!==Ec||(this.state=Zu);break;case Uh.BUFFER_FULL_ERROR:if(!t.parent||"audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case Uh.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onBufferFlushed(e,{type:t}){t===qh&&(this.bufferFlushed=!0,this.state===op&&(this.state=Zu))}_handleTransmuxComplete(e){var t;const i="audio",{hls:s}=this,{remuxResult:r,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o)return void this.resetWhenMissingContext(a);const{frag:n,part:l,level:h}=o,{details:d}=h,{audio:c,text:u,id3:p,initSegment:f}=r;if(!this.fragContextChanged(n)&&d){if(this.state=rp,this.switchingTrack&&c&&this.completeAudioSwitch(this.switchingTrack),null!=f&&f.tracks){const e=n.initSegment||n;this._bufferInitSegment(f.tracks,e,a),s.trigger(Mh.FRAG_PARSING_INIT_SEGMENT,{frag:e,id:i,tracks:f.tracks})}if(c){const{startPTS:e,endPTS:t,startDTS:i,endDTS:s}=c;l&&(l.elementaryStreams[qh]={startPTS:e,endPTS:t,startDTS:i,endDTS:s}),n.setElementaryStreamInfo(qh,e,t,i,s),this.bufferFragmentData(c,n,l,a)}if(null!=p&&null!=(t=p.samples)&&t.length){const e=Ph({id:i,frag:n,details:d},p);s.trigger(Mh.FRAG_PARSING_METADATA,e)}if(u){const e=Ph({id:i,frag:n,details:d},u);s.trigger(Mh.FRAG_PARSING_USERDATA,e)}}else this.fragmentTracker.removeFragment(n)}_bufferInitSegment(e,t,i){if(this.state!==rp)return;e.video&&delete e.video;const s=e.audio;if(!s)return;s.levelCodec=s.codec,s.id="audio",this.log(`Init audio buffer, container:${s.container}, codecs[parsed]=[${s.codec}]`),this.hls.trigger(Mh.BUFFER_CODECS,e);const r=s.initSegment;if(null!=r&&r.byteLength){const e={type:"audio",frag:t,part:null,chunkMeta:i,parent:t.type,data:r};this.hls.trigger(Mh.BUFFER_APPENDING,e)}this.tick()}loadFragment(e,t,i){const s=this.fragmentTracker.getState(e);var r;(this.fragCurrent=e,this.switchingTrack||s===Eu||s===Cu)?"initSegment"===e.sn?this._loadInitSegment(e,t):null!=(r=t.details)&&r.live&&!this.initPTS[e.cc]?(this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=lp):(this.startFragRequested=!0,super.loadFragment(e,t,i)):this.clearTrackerIfNeeded(e)}completeAudioSwitch(e){const{hls:t,media:i,bufferedTrack:s}=this,r=null==s?void 0:s.attrs,a=e.attrs;i&&r&&(r.CHANNELS!==a.CHANNELS||r.NAME!==a.NAME||r.LANGUAGE!==a.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(Mh.AUDIO_TRACK_SWITCHED,Lh({},e))}},audioTrackController:class extends vu{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(Mh.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Mh.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Mh.LEVEL_LOADING,this.onLevelLoading,this),e.on(Mh.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Mh.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(Mh.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(Mh.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Mh.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Mh.LEVEL_LOADING,this.onLevelLoading,this),e.off(Mh.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Mh.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(Mh.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){const{id:i,groupId:s,details:r}=t,a=this.tracksInGroup[i];if(!a||a.groupId!==s)return void this.warn(`Track with id:${i} and group:${s} not found in active group ${a.groupId}`);const o=a.details;a.details=t.details,this.log(`audio-track ${i} "${a.name}" lang:${a.lang} group:${s} loaded [${r.startSN}-${r.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(null==t||!t.audioGroupIds)return;const i=t.audioGroupIds[t.urlId];if(this.groupId!==i){this.groupId=i||null;const e=this.tracks.filter((e=>!i||e.groupId===i));this.selectDefaultTrack&&!e.some((e=>e.default))&&(this.selectDefaultTrack=!1),this.tracksInGroup=e;const t={audioTracks:e};this.log(`Updating audio tracks, ${e.length} track(s) found in group:${i}`),this.hls.trigger(Mh.AUDIO_TRACKS_UPDATED,t),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}onError(e,t){!t.fatal&&t.context&&t.context.type===Ec&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(t))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length)return void this.warn("Invalid id passed to audio-track controller");this.clearTimer();const i=this.currentTrack;t[this.trackId];const s=t[e],{groupId:r,name:a}=s;if(this.log(`Switching to audio-track ${e} "${a}" lang:${s.lang} group:${r}`),this.trackId=e,this.currentTrack=s,this.selectDefaultTrack=!1,this.hls.trigger(Mh.AUDIO_TRACK_SWITCHING,Lh({},s)),s.details&&!s.details.live)return;const o=this.switchParams(s.url,null==i?void 0:i.details);this.loadPlaylist(o)}selectInitialTrack(){const e=this.tracksInGroup,t=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(-1!==t)this.setAudioTrack(t);else{const t=new Error(`No track found for running audio group-ID: ${this.groupId} track count: ${e.length}`);this.warn(t.message),this.hls.trigger(Mh.ERROR,{type:Fh.MEDIA_ERROR,details:Uh.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:t})}}findTrackId(e){const t=this.tracksInGroup;for(let i=0;i<t.length;i++){const s=t[i];if(!this.selectDefaultTrack||s.default){if(!e||void 0!==e.attrs["STABLE-RENDITION-ID"]&&e.attrs["STABLE-RENDITION-ID"]===s.attrs["STABLE-RENDITION-ID"])return s.id;if(e.name===s.name&&e.lang===s.lang)return s.id}}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(t)){const i=t.id,s=t.groupId;let r=t.url;if(e)try{r=e.addDirectives(r)}catch(e){this.warn(`Could not construct new URL with HLS Delivery Directives: ${e}`)}this.log(`loading audio-track playlist ${i} "${t.name}" lang:${t.lang} group:${s}`),this.clearTimer(),this.hls.trigger(Mh.AUDIO_TRACK_LOADING,{url:r,id:i,groupId:s,deliveryDirectives:e||null})}}},emeController:Sm,cmcdController:Lm,contentSteeringController:class{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=zh.log.bind(zh,"[content-steering]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(Mh.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Mh.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Mh.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Mh.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(Mh.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Mh.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Mh.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Mh.ERROR,this.onError,this))}startLoad(){if(this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri)if(this.updated){const e=Math.max(1e3*this.timeToLoad-(performance.now()-this.updated),0);this.scheduleRefresh(this.uri,e)}else this.loadSteeringManifest(this.uri)}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const t=this.levels;t&&(this.levels=t.filter((t=>t!==e)))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){const{contentSteering:i}=t;null!==i&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:i}=t;if((null==i?void 0:i.action)===fu&&i.flags===yu){let e=this.pathwayPriority;const t=this.pathwayId;this.penalizedPathways[t]||(this.penalizedPathways[t]=performance.now()),!e&&this.levels&&(e=this.levels.reduce(((e,t)=>(-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e)),[])),e&&e.length>1&&(this.updatePathwayPriority(e),i.resolved=this.pathwayId!==t)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){const 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}getLevelsForPathway(e){return null===this.levels?[]:this.levels.filter((t=>e===t.pathwayId))}updatePathwayPriority(e){let t;this.pathwayPriority=e;const i=this.penalizedPathways,s=performance.now();Object.keys(i).forEach((e=>{s-i[e]>3e5&&delete i[e]}));for(let s=0;s<e.length;s++){const r=e[s];if(i[r])continue;if(r===this.pathwayId)return;const a=this.hls.nextLoadLevel,o=this.hls.levels[a];if(t=this.getLevelsForPathway(r),t.length>0){this.log(`Setting Pathway to "${r}"`),this.pathwayId=r,this.hls.trigger(Mh.LEVELS_UPDATED,{levels:t});const e=this.hls.levels[a];o&&e&&this.levels&&(e.attrs["STABLE-VARIANT-ID"]!==o.attrs["STABLE-VARIANT-ID"]&&e.bitrate!==o.bitrate&&this.log(`Unstable Pathways change from bitrate ${o.bitrate} to ${e.bitrate}`),this.hls.nextLoadLevel=a);break}}}clonePathways(e){const t=this.levels;if(!t)return;const i={},s={};e.forEach((e=>{const{ID:r,"BASE-ID":a,"URI-REPLACEMENT":o}=e;if(t.some((e=>e.pathwayId===r)))return;const n=this.getLevelsForPathway(a).map((e=>{const t=Ph({},e);t.details=void 0,t.url=Pm(e.uri,e.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",o);const a=new Hh(e.attrs);a["PATHWAY-ID"]=r;const n=a.AUDIO&&`${a.AUDIO}_clone_${r}`,l=a.SUBTITLES&&`${a.SUBTITLES}_clone_${r}`;n&&(i[a.AUDIO]=n,a.AUDIO=n),l&&(s[a.SUBTITLES]=l,a.SUBTITLES=l),t.attrs=a;const h=new Yc(t);return Su(h,"audio",n),Su(h,"text",l),h}));t.push(...n),Im(this.audioTracks,i,o,r),Im(this.subtitleTracks,s,o,r)}))}loadSteeringManifest(e){const t=this.hls.config,i=t.loader;let s;this.loader&&this.loader.destroy(),this.loader=new i(t);try{s=new self.URL(e)}catch(t){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest URI: ${e}`)}if("data:"!==s.protocol){const e=0|(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate);s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+e)}const r={responseType:"json",url:s.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},n={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},l={onSuccess:(e,t,i,r)=>{this.log(`Loaded steering manifest: "${s}"`);const a=e.data;if(1!==a.VERSION)return void this.log(`Steering VERSION ${a.VERSION} not supported!`);this.updated=performance.now(),this.timeToLoad=a.TTL;const{"RELOAD-URI":o,"PATHWAY-CLONES":n,"PATHWAY-PRIORITY":l}=a;if(o)try{this.uri=new self.URL(o,s).href}catch(e){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest RELOAD-URI: ${o}`)}this.scheduleRefresh(this.uri||i.url),n&&this.clonePathways(n),l&&this.updatePathwayPriority(l)},onError:(e,t,i,s)=>{if(this.log(`Error loading steering manifest: ${e.code} ${e.text} (${t.url})`),this.stopLoad(),410===e.code)return this.enabled=!1,void this.log(`Steering manifest ${t.url} no longer available`);let r=1e3*this.timeToLoad;if(429!==e.code)this.scheduleRefresh(this.uri||t.url,r);else{const e=this.loader;if("function"==typeof(null==e?void 0:e.getResponseHeader)){const t=e.getResponseHeader("Retry-After");t&&(r=1e3*parseFloat(t))}this.log(`Steering manifest ${t.url} rate limited`)}},onTimeout:(e,t,i)=>{this.log(`Timeout loading steering manifest (${t.url})`),this.scheduleRefresh(this.uri||t.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(r,n,l)}scheduleRefresh(e,t=1e3*this.timeToLoad){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout((()=>{this.loadSteeringManifest(e)}),t)}}});function $m(e){return e&&"object"==typeof e?Array.isArray(e)?e.map($m):Object.keys(e).reduce(((t,i)=>(t[i]=$m(e[i]),t)),{}):e}function Wm(e){const t=e.loader;if(t!==Um&&t!==Mm)zh.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1;else{(function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1})()&&(e.loader=Um,e.progressive=!0,e.enableSoftwareAES=!0,zh.log("[config]: Progressive streaming enabled, using FetchLoader"))}}class Hm{static get version(){return"1.4.12"}static isSupported(){return function(){const e=oc();if(!e)return!1;const t=cp(),i=e&&"function"==typeof e.isTypeSupported&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),s=!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove;return!!i&&!!s}()}static get Events(){return Mh}static get ErrorTypes(){return Fh}static get ErrorDetails(){return Uh}static get DefaultConfig(){return Hm.defaultConfig?Hm.defaultConfig:zm}static set DefaultConfig(e){Hm.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new pf,this._autoLevelCapping=void 0,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,function(e,t){if(self.console&&!0===e||"object"==typeof e){Gh(e,"debug","log","info","warn","error");try{jh.log(`Debug logs enabled for "${t}" in hls.js version 1.4.12`)}catch(e){jh=Nh}}else jh=Nh}(e.debug||!1,"Hls instance");const t=this.config=function(e,t){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"');const i=$m(e),s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach((e=>{const r=`${"level"===e?"playlist":e}LoadPolicy`,a=void 0===t[r],o=[];s.forEach((s=>{const n=`${e}Loading${s}`,l=t[n];if(void 0!==l&&a){o.push(n);const e=i[r].default;switch(t[r]={default:e},s){case"TimeOut":e.maxLoadTimeMs=l,e.maxTimeToFirstByteMs=l;break;case"MaxRetry":e.errorRetry.maxNumRetry=l,e.timeoutRetry.maxNumRetry=l;break;case"RetryDelay":e.errorRetry.retryDelayMs=l,e.timeoutRetry.retryDelayMs=l;break;case"MaxRetryTimeout":e.errorRetry.maxRetryDelayMs=l,e.timeoutRetry.maxRetryDelayMs=l}}})),o.length&&zh.warn(`hls.js config: "${o.join('", "')}" setting(s) are deprecated, use "${r}": ${JSON.stringify(t[r])}`)})),Lh(Lh({},i),t)}(Hm.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,t.progressive&&Wm(t);const{abrController:i,bufferController:s,capLevelController:r,errorController:a,fpsController:o}=t,n=new a(this),l=this.abrController=new i(this),h=this.bufferController=new s(this),d=this.capLevelController=new r(this),c=new o(this),u=new Ic(this),p=new $c(this),f=t.contentSteeringController,m=f?new f(this):null,g=this.levelController=new wu(this,m),y=new Ru(this),A=new Uu(this.config),b=this.streamController=new yf(this,y,A);d.setStreamController(b),c.setStreamController(b);const v=[u,g,b];m&&v.splice(1,0,m),this.networkControllers=v;const _=[l,h,d,c,p,y];this.audioTrackController=this.createController(t.audioTrackController,v);const w=t.audioStreamController;w&&v.push(new w(this,y,A)),this.subtitleTrackController=this.createController(t.subtitleTrackController,v);const S=t.subtitleStreamController;S&&v.push(new S(this,y,A)),this.createController(t.timelineController,_),A.emeController=this.emeController=this.createController(t.emeController,_),this.cmcdController=this.createController(t.cmcdController,_),this.latencyController=this.createController(Wc,_),this.coreComponents=_,v.push(n);const T=n.onErrorOut;"function"==typeof T&&this.on(Mh.ERROR,T,n)}createController(e,t){if(e){const i=new e(this);return t&&t.push(i),i}return null}on(e,t,i=this){this._emitter.on(e,t,i)}once(e,t,i=this){this._emitter.once(e,t,i)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,i=this,s){this._emitter.off(e,t,i,s)}listeners(e){return this._emitter.listeners(e)}emit(e,t,i){return this._emitter.emit(e,t,i)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){zh.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),this.trigger(Mh.ERROR,{type:Fh.OTHER_ERROR,details:Uh.INTERNAL_EXCEPTION,fatal:!1,event:e,error:t})}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){zh.log("destroy"),this.trigger(Mh.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((e=>e.destroy())),this.networkControllers.length=0,this.coreComponents.forEach((e=>e.destroy())),this.coreComponents.length=0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){zh.log("attachMedia"),this._media=e,this.trigger(Mh.MEDIA_ATTACHING,{media:e})}detachMedia(){zh.log("detachMedia"),this.trigger(Mh.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();const t=this.media,i=this.url,s=this.url=Rh.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});zh.log(`loadSource:${s}`),t&&i&&(i!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(Mh.MANIFEST_LOADING,{url:e})}startLoad(e=-1){zh.log(`startLoad(${e})`),this.networkControllers.forEach((t=>{t.startLoad(e)}))}stopLoad(){zh.log("stopLoad"),this.networkControllers.forEach((e=>{e.stopLoad()}))}swapAudioCodec(){zh.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){zh.log("recoverMediaError");const e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e,t=0){this.levelController.removeLevel(e,t)}get levels(){const e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){zh.log(`set currentLevel:${e}`),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){zh.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){zh.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){zh.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){return this.levelController.startLevel}set startLevel(e){zh.log(`set startLevel:${e}`),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(zh.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){Hc.indexOf(e)>-1&&(this._maxHdcpLevel=e)}get autoLevelEnabled(){return-1===this.levelController.manualLevel}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const i=e.length;for(let s=0;s<i;s++)if(e[s].maxBitrate>=t)return s;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:i}=this;let s;if(s=-1===t&&e&&e.length?e.length-1:t,i)for(let t=s;t--;){const s=e[t].attrs["HDCP-LEVEL"];if(s&&s<=i)return t}return s}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return!!e&&e.subtitleDisplay}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}Hm.defaultConfig=void 0;class Vm extends t{constructor(e){super(),this.player=e,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):Hm.isSupported()?(this.$videoElement=this.player.video.$videoElement,this.hls=new Hm({}),this._initHls(),this._bindEvents()):this.player.debug.error("HlsDecoder","init hls error ,not support "),this.player.debug.log("HlsDecoder","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("HlsDecoder","destroy"),setTimeout((()=>{e()}),0)}))}checkHlsBufferedDelay(){const e=this.$videoElement;let t=0;const i=e.buffered,s=i.length?i.end(i.length-1):0;return t=s-e.currentTime,t<0&&(this.player.debug.warn("HlsDecoder","checkHlsBufferedDelay result < 0",t,s,e.currentTime),t=0),t}getFps(){return this.hlsFps}_startCanvasRender(){wa()?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){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.player.isDestroyed()?this.player.debug.log("HlsDecoder","videoFrameCallback() player is destroyed"):(this.player.video.render({$video:this.$videoElement,ts:t.mediaTime||0}),this.player.handleRender(),this.player.updateStats({dts:t.mediaTime||0}),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(Ze.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(Xr(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,_r()&&(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,s=wa(),r=t(i,Ci,(t=>{if(this.hls){const i=parseInt(t.timeStamp,10);this.player._opt.useCanvasRender&&fa(s)&&e.updateStats({ts:i,dts:i})}}));this.eventsDestroy.push(r),this._startBandwidthEstimateInterval(),this._startFpsInterval(),this.hls.on(Hm.Events.ERROR,((e,t)=>{if(t.fatal)switch(t.type){case Hm.ErrorTypes.NETWORK_ERROR:this.player.debug.warn("HlsDecoder","fatal network error encountered, try to recover"),this.hls.startLoad();break;case Hm.ErrorTypes.MEDIA_ERROR:this.player.debug.warn("HlsDecoder","fatal media error encountered, try to recover"),this.hls.recoverMediaError()}})),this.hls.on(Hm.Events.MEDIA_ATTACHING,(()=>{})),this.hls.on(Hm.Events.MEDIA_ATTACHED,(()=>{})),this.hls.on(Hm.Events.MEDIA_DETACHING,(()=>{})),this.hls.on(Hm.Events.MEDIA_DETACHED,(()=>{})),this.hls.on(Hm.Events.BUFFER_RESET,(()=>{})),this.hls.on(Hm.Events.BUFFER_CODECS,(()=>{})),this.hls.on(Hm.Events.BUFFER_CREATED,(()=>{})),this.hls.on(Hm.Events.BUFFER_APPENDING,((e,t)=>{this.player.debug.log("HlsDecoder","BUFFER_APPENDING",t.type)})),this.hls.on(Hm.Events.BUFFER_APPENDED,(()=>{})),this.hls.on(Hm.Events.BUFFER_EOS,(()=>{})),this.hls.on(Hm.Events.BUFFER_FLUSHING,(()=>{})),this.hls.on(Hm.Events.BUFFER_FLUSHED,(()=>{})),this.hls.on(Hm.Events.MANIFEST_LOADING,(()=>{this.player.debug.log("HlsDecoder","MANIFEST_LOADING 开始加载playlist m3u8资源")})),this.hls.on(Hm.Events.MANIFEST_LOADED,((e,t)=>{this.player.debug.log("HlsDecoder","MANIFEST_LOADED playlist m3u8文件加载完成",t.url)})),this.hls.on(Hm.Events.MANIFEST_PARSED,(()=>{this.player.debug.log("HlsDecoder","MANIFEST_PARSED playlist m3u8解析完成"),e._times.demuxStart||(e._times.demuxStart=lr())})),this.hls.on(Hm.Events.LEVEL_LOADING,(()=>{})),this.hls.on(Hm.Events.LEVEL_LOADED,((e,t)=>{})),this.hls.on(Hm.Events.FRAG_LOADING,(()=>{})),this.hls.on(Hm.Events.FRAG_LOADED,((t,i)=>{e._times.decodeStart||(e._times.decodeStart=lr())})),this.hls.on(Hm.Events.BUFFER_APPENDING,(()=>{e._times.videoStart||(e._times.videoStart=lr(),e.handlePlayToRenderTimes())})),this.hls.on(Hm.Events.FRAG_DECRYPTED,(()=>{})),this.hls.on(Hm.Events.KEY_LOADING,(()=>{})),this.hls.on(Hm.Events.KEY_LOADING,(()=>{})),this.hls.on(Hm.Events.FPS_DROP,(e=>{})),this.hls.on(Hm.Events.FPS_DROP_LEVEL_CAPPING,(e=>{})),this.hls.on(Hm.Events.FRAG_PARSING_INIT_SEGMENT,((e,t)=>{this.player.debug.log("HlsDecoder","FRAG_PARSING_INIT_SEGMENT",t);const i=!!(t&&t.tracks&&t.tracks.audio),s=!!(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,s=e.codec;this.player.audio&&this.player.audio.updateAudioInfo({encType:s,channels:i,sampleRate:44100})}if(s&&t.tracks.video){let e=t.tracks.video,i=e.codec,s=e.metadata&&e.metadata.width?e.metadata.width:0,r=e.metadata&&e.metadata.height?e.metadata.height:0;this.player.video&&this.player.video.updateVideoInfo({encTypeCode:-1!==i.indexOf("avc")?ct:ut,width:s,height:r})}}))}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("HlsDecoder","video canplay"),this.$videoElement.play().then((()=>{this.player.debug.log("HlsDecoder","video play"),this._startCanvasRender(),this._initRenderSize()})).catch((e=>{this.player.debug.warn("HlsDecoder","video play error ",e)}))})),i=e(this.$videoElement,ki,(()=>{this.player.debug.log("HlsDecoder","video waiting")})),s=e(this.$videoElement,Ci,(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)})))})),r=e(this.$videoElement,xi,(()=>{this.player.debug.log("HlsDecoder","video playback Rate change",this.$videoElement&&this.$videoElement.playbackRate)}));this.eventsDestroy.push(t,i,s,r)}loadSource(e){return new Promise(((t,i)=>{this.canVideoPlay?(this.initVideoPlay(e),t()):this.hls.on(Hm.Events.MEDIA_ATTACHED,(()=>{this.hls.loadSource(e),t()}))}))}}const Jm=2097152,Km="fetch",qm="xhr",Ym="arraybuffer",Qm="text",Xm="json",Zm="real_time_speed",eg=Object.prototype.toString;function tg(e){if("[object Object]"!==eg.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function ig(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 sg(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function rg(e,t){if(!e)return;if(!t)return e;let i;const s=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]"===eg.call(i)?t=t.toISOString():function(e){return null!==e&&"object"==typeof e}(t)&&(t=JSON.stringify(t)),`${sg(e)}=${sg(t)}`})).join("&")})).filter(Boolean).join("&");if(s){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+s}return e}function ag(e,t,i,s,r,a,o,n,l,h,d){r=null!=r?parseFloat(r):null,s=parseInt(s||"0",10),Number.isNaN(s)&&(s=0);return{data:e,done:t,option:{range:l,vid:h,index:n,contentLength:s,age:r,startTime:a,firstByteTime:o,endTime:Date.now(),priOptions:d},response:i}}function og(e,t){return Math.round(8*e*1e3/t/1024)}class ng extends Error{constructor(e,t,i,s){super(s),Ol(this,"retryCount",0),Ol(this,"isTimeout",!1),Ol(this,"loaderType",Km),Ol(this,"startTime",0),Ol(this,"endTime",0),Ol(this,"options",{}),this.url=e,this.request=t,this.response=i}}class lg extends t{constructor(e){super(),Ol(this,"_abortController",null),Ol(this,"_timeoutTimer",null),Ol(this,"_reader",null),Ol(this,"_response",null),Ol(this,"_aborted",!1),Ol(this,"_index",-1),Ol(this,"_range",null),Ol(this,"_receivedLength",0),Ol(this,"_running",!1),Ol(this,"_logger",null),Ol(this,"_vid",""),Ol(this,"_onProcessMinLen",0),Ol(this,"_onCancel",null),Ol(this,"_priOptions",null),Ol(this,"TAG_NAME","FetchLoader"),this.player=e}load(e){var t;let{url:i,vid:s,timeout:r,responseType:a,onProgress:o,index:n,onTimeout:l,onCancel:h,range:d,transformResponse:c,request:u,params:p,logger:f,method:m,headers:g,body:y,mode:A,credentials:b,cache:v,redirect:_,referrer:w,referrerPolicy:S,onProcessMinLen:T,priOptions:E}=e;this._aborted=!1,this._onProcessMinLen=T,this._onCancel=h,this._abortController="undefined"!=typeof AbortController&&new AbortController,this._running=!0,this._index=n,this._range=d||[0,0],this._vid=s||i,this._priOptions=E||{};const k={method:m,headers:g,body:y,mode:A,credentials:b,cache:v,redirect:_,referrer:w,referrerPolicy:S,signal:null===(t=this._abortController)||void 0===t?void 0:t.signal};let C=!1;clearTimeout(this._timeoutTimer),i=rg(i,p);const x=ig(d);x&&(g=u?u.headers:k.headers=k.headers||(Headers?new Headers:{}),Headers&&g instanceof Headers?g.append("Range",x):g.Range=x),r&&(this._timeoutTimer=setTimeout((()=>{if(C=!0,this.cancel(),l){const e=new ng(i,k,null,"timeout");e.isTimeout=!0,l(e,{index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions})}}),r));const R=Date.now();return(Fr(n)||Fr(d))&&this.player.debug.log(this.TAG_NAME,"[fetch load start], index,",n,",range,",d),new Promise(((e,t)=>{fetch(u||i,u?void 0:k).then((async s=>{if(clearTimeout(this._timeoutTimer),this._response=s,this._aborted||!this._running)return;if(c&&(s=c(s,i)||s),!s.ok)throw new ng(i,k,s,"bad network response");const r=Date.now();let l;if(a===Qm)l=await s.text(),this._running=!1;else if(a===Xm)l=await s.json(),this._running=!1;else{if(o)return this.resolve=e,this.reject=t,void this._loadChunk(s,o,R,r);{l=await s.arrayBuffer(),l=new Uint8Array(l),this._running=!1;const e=Date.now()-R,t=og(l.byteLength,e);this.emit(Zm,{speed:t,len:l.byteLength,time:e,vid:this._vid,index:this._index,range:this._range,priOptions:this._priOptions})}}(Fr(n)||Fr(d))&&this.player.debug.log(this.TAG_NAME,"[fetch load end], index,",n,",range,",d),e(ag(l,!0,s,s.headers.get("Content-Length"),s.headers.get("age"),R,r,n,d,this._vid,this._priOptions))})).catch((e=>{var s;clearTimeout(this._timeoutTimer),this._running=!1,this._aborted&&!C||((e=e instanceof ng?e:new ng(i,k,null,null===(s=e)||void 0===s?void 0:s.message)).startTime=R,e.endTime=Date.now(),e.isTimeout=C,e.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},t(e))}))}))}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,s){if(!e.body||!e.body.getReader){this._running=!1;const t=new ng(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(Jm),this._writeIdx=0);const r=this._reader=e.body.getReader();let a,o,n;const l=async()=>{var h;o=Date.now();try{a=await r.read(),n=Date.now()}catch(e){return n=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=(null===(h=this._range)||void 0===h?void 0:h.length)>0?this._range[0]:0,c=d+this._receivedLength;if(this._aborted)return this._running=!1,void t(void 0,!1,{range:[c,c],vid:this._vid,index:this._index,startTime:o,endTime:n,st:i,firstByteTime:s,priOptions:this._priOptions},e);const u=a.value?a.value.byteLength:0;let p;if(this._receivedLength+=u,this.player.debug.log(this.TAG_NAME,"【fetchLoader,onProgress call】,task,",this._range,", start,",c,", end,",d+this._receivedLength,", done,",a.done),this._onProcessMinLen>0){if(this._writeIdx+u>=this._onProcessMinLen||a.done)p=new Uint8Array(this._writeIdx+u),p.set(this._cache.slice(0,this._writeIdx),0),u>0&&p.set(a.value,this._writeIdx),this._writeIdx=0,this.player.debug.log(this.TAG_NAME,"【fetchLoader,onProgress enough】,done,",a.done,",len,",p.byteLength,", writeIdx,",this._writeIdx);else if(u>0&&this._writeIdx+u<Jm)this._cache.set(a.value,this._writeIdx),this._writeIdx+=u,this.player.debug.log(this.TAG_NAME,"【fetchLoader,onProgress cache】,len,",u,", writeIdx,",this._writeIdx);else if(u>0){const e=new Uint8Array(this._writeIdx+u+2048);this.player.debug.log(this.TAG_NAME,"【fetchLoader,onProgress extra start】,size,",this._writeIdx+u+2048,", datalen,",u,", writeIdx,",this._writeIdx),e.set(this._cache.slice(0,this._writeIdx),0),u>0&&e.set(a.value,this._writeIdx),this._writeIdx+=u,delete this._cache,this._cache=e,this.player.debug.log(this.TAG_NAME,"【fetchLoader,onProgress extra end】,len,",u,", writeIdx,",this._writeIdx)}}else p=a.value;if((p&&p.byteLength>0||a.done)&&t(p,a.done,{range:[this._range[0]+this._receivedLength-(p?p.byteLength:0),this._range[0]+this._receivedLength],vid:this._vid,index:this._index,startTime:o,endTime:n,st:i,firstByteTime:s,priOptions:this._priOptions},e),a.done){const t=Date.now()-i,r=og(this._receivedLength,t);this.emit(Zm,{speed:r,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(ag(a,!0,e,e.headers.get("Content-Length"),e.headers.get("age"),i,s,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 hg{constructor(e,t,i){Ol(this,"TAG_NAME","Task"),this.promise=function(){let e,t;const i=new Promise(((i,s)=>{e=i,t=s}));return i.used=!1,i.resolve=function(){return i.used=!0,e(...arguments)},i.reject=function(){return i.used=!0,t(...arguments)},i}(),this.alive=!!t.onProgress,this._loaderType=e,this.player=i,this._loader=e===Km&&window.fetch?new lg(i):new dg(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:s,...r}=this._config,a=async()=>{try{const e=await this._loader.load(r);this.promise.resolve(e)}catch(o){if(this._loader.running=!1,this.player.debug.log(this.TAG_NAME,"[task request catch err]",o),this._canceled)return;o.loaderType=this._loaderType,o.retryCount=this._retryCount;let n=o;s&&(n=s(n)||n),i&&this._retryCount>0&&i(n,this._retryCount,{index:r.index,vid:r.vid,range:r.range,priOptions:r.priOptions}),this._retryCount++;let l=!0;if(this._retryCheckFunc&&(l=this._retryCheckFunc(o)),l&&this._retryCount<=e)return clearTimeout(this._retryTimer),this.player.debug.log(this.TAG_NAME,"[task request setTimeout],retry",this._retryCount,",retry range,",r.range),void(this._retryTimer=setTimeout(a,t));this.promise.reject(n)}};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 dg extends t{constructor(e){super(),Ol(this,"_xhr",null),Ol(this,"_aborted",!1),Ol(this,"_timeoutTimer",null),Ol(this,"_range",null),Ol(this,"_receivedLength",0),Ol(this,"_url",null),Ol(this,"_onProgress",null),Ol(this,"_index",-1),Ol(this,"_headers",null),Ol(this,"_currentChunkSizeKB",384),Ol(this,"_timeout",null),Ol(this,"_xhr",null),Ol(this,"_withCredentials",null),Ol(this,"_startTime",-1),Ol(this,"_loadCompleteResolve",null),Ol(this,"_loadCompleteReject",null),Ol(this,"_runing",!1),Ol(this,"_logger",!1),Ol(this,"_vid",""),Ol(this,"_responseType",void 0),Ol(this,"_credentials",void 0),Ol(this,"_method",void 0),Ol(this,"_transformResponse",void 0),Ol(this,"_firstRtt",void 0),Ol(this,"_onCancel",null),Ol(this,"_priOptions",null),Ol(this,"TAG_NAME","XhrLoader"),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=rg(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 ng?e:new ng(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===Ym&&this._range&&this._range.length>1)if(this._onProgress){this._firstRtt=-1;const t=1024*this._currentChunkSizeKB,i=this._range[0]+this._receivedLength;let s=this._range[1];t<this._range[1]-i&&(s=i+t),e=[i,s],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=>{var t,i,s;this._running=!1;const r=new ng(this._url,this._request,null==e||null===(t=e.currentTarget)||void 0===t?void 0:t.response,"xhr.onerror.status:"+(null==e||null===(i=e.currentTarget)||void 0===i?void 0:i.status)+",statusText,"+(null==e||null===(s=e.currentTarget)||void 0===s?void 0:s.statusText));r.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(r)},t.ontimeout=e=>{this.cancel();const t=new ng(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||{},s=ig(e);s&&(i.Range=s),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){var t;const i=e.target.status;if(i<200||i>299){const t=new ng(this._url,null,{...e.target.response,status:i},"bad response,status:"+i);return t.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(t)}let s,r=null,a=!1;const o=(null===(t=this._range)||void 0===t?void 0:t.length)>0?this._range[0]:0;if(this._responseType===Ym){var n;const t=new Uint8Array(e.target.response);if(s=o+this._receivedLength,t&&t.byteLength>0){this._receivedLength+=t.byteLength;const e=Date.now()-this._startTime,i=og(this._receivedLength,e);this.emit(Zm,{speed:i,len:this._receivedLength,time:e,vid:this._vid,index:this._index,range:[s,o+this._receivedLength],priOptions:this._priOptions})}r=t,a=!((null===(n=this._range)||void 0===n?void 0:n.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",s,"end ",o+this._receivedLength,",dataLen,",t?t.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",a)}else a=!0,r=e.target.response;let l={ok:i>=200&&i<300,status:i,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};this._transformResponse&&(l=this._transformResponse(l,this._url)||l),this._onProgress&&this._onProgress(r,a,{index:this._index,vid:this._vid,range:[s,o+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},l),a?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(ag(this._onProgress?null:r,a,l,l.headers["content-length"],l.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 cg extends t{constructor(e,t){super(),Ol(this,"type",Km),Ol(this,"_queue",[]),Ol(this,"_alive",[]),Ol(this,"_currentTask",null),Ol(this,"_config",void 0),this.player=t,this._config=function(e){return{loaderType:Km,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:Qm,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!==qm&&lg.isSupported()||(this.type=qm)}destroy(){this._queue=[],this._alive=[],this._currentTask=null}isFetch(){return this.type===Km}static isFetchSupport(){return lg.isSupported()}load(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"string"!=typeof e&&e?t=e:t.url=e||t.url||this._config.url,t=Object.assign({},this._config,t),t.params&&(t.params=Object.assign({},t.params)),t.headers&&tg(t.headers)&&(t.headers=Object.assign({},t.headers)),t.body&&tg(t.body)&&(t.body=Object.assign({},t.body)),t.transformRequest&&(t=t.transformRequest(t)||t);const i=new hg(this.type,t,this.player);return i.loader.on(Zm,(e=>{this.emit(Zm,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(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]: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((()=>{var e,t;null!==(e=this._currentTask)&&void 0!==e&&e.alive&&(null===(t=this._alive)||void 0===t?void 0:t.length)>0&&(this._alive=this._alive.filter((e=>e&&e!==this._currentTask))),this._processTask()}))}}const ug="network",pg="network_timeout",fg="other",mg="manifest",gg="hls",yg="demux";class Ag extends Error{constructor(e,t,i,s,r){super(r||(null==i?void 0:i.message)),this.errorType=e===pg?ug:e,this.originError=i,this.ext=s,this.errorMessage=this.message}static create(e,t,i,s,r){return e instanceof Ag?e:(e instanceof Error&&(i=e,e=""),e||(e=fg),new Ag(e,t,i,s,r))}static network(e){var t;return new Ag(null!=e&&e.isTimeout?pg:ug,null,e instanceof Error?e:null,{url:null==e?void 0:e.url,response:null==e?void 0:e.response,httpCode:null==e||null===(t=e.response)||void 0===t?void 0:t.status})}}const bg=/^#(EXT[^:]*)(?::(.*))?$/,vg=/([^=]+)=(?:"([^"]*)"|([^",]*))(?:,|$)/g,_g=/^(?:[a-zA-Z0-9+\-.]+:)?\/\//,wg=/^((?:[a-zA-Z0-9+\-.]+:)?\/\/[^/?#]*)?([^?#]*\/)?/;function Sg(e){const t=e.match(bg);if(t&&t[1])return[t[1].replace("EXT-X-",""),t[2]]}function Tg(e){const t={};let i=vg.exec(e);for(;i;)t[i[1]]=i[2]||i[3],i=vg.exec(e);return t}function Eg(e,t){if(!t||!e||_g.test(e))return e;const i=wg.exec(t);return i?"/"===e[0]?i[1]+e:i[1]+i[2]+e:e}const kg={audio:[/^mp4a/,/^vorbis$/,/^opus$/,/^flac$/,/^[ae]c-3$/],video:[/^avc/,/^hev/,/^hvc/,/^vp0?[89]/,/^av1$/],text:[/^vtt$/,/^wvtt/,/^stpp/]};function Cg(e,t){const i=kg[e];if(i&&t&&t.length)for(let e=0;e<i.length;e++)for(let s=0;s<t.length;s++)if(i[e].test(t[s]))return t[s]}class xg{constructor(){this.version=0,this.streams=[],this.isMaster=!0}}const Rg="AUDIO",Dg="SUBTITLE";class Lg{constructor(){Ol(this,"id",0),Ol(this,"url",""),Ol(this,"default",!1),Ol(this,"autoSelect",!1),Ol(this,"forced",!1),Ol(this,"group",""),Ol(this,"name",""),Ol(this,"lang",""),Ol(this,"segments",[]),Ol(this,"endSN",0)}}class Ig extends Lg{constructor(){super(...arguments),Ol(this,"mediaType",Rg),Ol(this,"channels",0)}}class Pg extends Lg{constructor(){super(...arguments),Ol(this,"mediaType",Dg)}}class Bg{constructor(){Ol(this,"id",0),Ol(this,"bitrate",0),Ol(this,"width",0),Ol(this,"height",0),Ol(this,"name",""),Ol(this,"url",""),Ol(this,"audioCodec",""),Ol(this,"videoCodec",""),Ol(this,"textCodec",""),Ol(this,"audioGroup",""),Ol(this,"audioStreams",[]),Ol(this,"subtitleStreams",[]),Ol(this,"closedCaptionsStream",[])}}class Mg{constructor(){Ol(this,"version",0),Ol(this,"url",""),Ol(this,"type",""),Ol(this,"startCC",0),Ol(this,"endCC",0),Ol(this,"startSN",0),Ol(this,"endSN",0),Ol(this,"totalDuration",0),Ol(this,"targetDuration",0),Ol(this,"live",!0),Ol(this,"segments",[])}}class Fg{constructor(){Ol(this,"sn",0),Ol(this,"cc",0),Ol(this,"url",""),Ol(this,"title",""),Ol(this,"start",0),Ol(this,"duration",0),Ol(this,"key",null),Ol(this,"byteRange",null),Ol(this,"isInitSegment",!1),Ol(this,"initSegment",null),Ol(this,"isLast",!1),Ol(this,"hasAudio",!1),Ol(this,"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 Ug{constructor(e){Ol(this,"method",""),Ol(this,"url",""),Ol(this,"iv",null),Ol(this,"keyFormat",""),Ol(this,"keyFormatVersions",""),e instanceof Ug&&(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 Ug(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 Og{static parse(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;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 Og.isMediaPlaylist(e)?function(e,t){const i=new Mg;i.url=t;let s,r=new Fg,a=null,o=null,n=0,l=0,h=0,d=0,c=!1;for(;(s=e[d++])&&!c;){if("#"!==s[0]){r.sn=l,r.cc=h,r.url=Eg(s,t),o&&(r.key=o.clone(l)),a&&(r.initSegment=a),i.segments.push(r),r=new Fg,l++;continue}const e=Sg(s);if(!e)continue;const[d,u]=e;switch(d){case"VERSION":i.version=parseInt(u);break;case"PLAYLIST-TYPE":i.type=null==u?void 0: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":h=i.startCC=parseInt(u);break;case"DISCONTINUITY":h++;break;case"BYTERANGE":r.setByteRange(u,i.segments[i.segments.length-1]);break;case"EXTINF":{const[e,t]=u.split(",");r.start=n,r.duration=parseFloat(e),n+=r.duration,r.title=t}break;case"KEY":{const e=Tg(u);if("NONE"===e.METHOD){o=null;break}if("AES-128"!==e.METHOD)throw new Error(`encrypt ${e.METHOD}/${e.KEYFORMAT} is not supported`);if(o=new Ug,o.method=e.METHOD,o.url=/^blob:/.test(e.URI)?e.URI:Eg(e.URI,t),o.keyFormat=e.KEYFORMAT||"identity",o.keyFormatVersions=e.KEYFORMATVERSIONS,e.IV){let t=e.IV.slice(2);t=(1&t.length?"0":"")+t,o.iv=new Uint8Array(t.length/2);for(let e=0,i=t.length/2;e<i;e++)o.iv[e]=parseInt(t.slice(2*e,2*e+2),16)}}break;case"MAP":{const e=Tg(u);r.url=Eg(e.URI,t),e.BYTERANGE&&r.setByteRange(e.BYTERANGE),r.isInitSegment=!0,r.sn=0,o&&(r.key=o.clone(0)),a=r,r=new Fg}}}const u=i.segments[i.segments.length-1];return u&&(i.endSN=u.sn),i.totalDuration=n,i.endCC=h,i}(i,t):function(e,t){const i=new xg;let s,r=0;const a=[],o=[];for(;s=e[r++];){const n=Sg(s);if(!n)continue;const[l,h]=n;if("VERSION"===l)i.version=parseInt(h);else if("MEDIA"===l&&h){const e=Tg(h);let i;switch(e.TYPE){case"AUDIO":i=new Ig;break;case"SUBTITLES":i=new Pg;break;default:i=new Lg}i.url=Eg(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&&o.push(i)}else if("STREAM-INF"===l&&h){const s=new Bg,a=Tg(h);if(s.bitrate=parseInt(a["AVERAGE-BANDWIDTH"]||a.BANDWIDTH),s.name=a.NAME,s.url=Eg(e[r++],t),a.RESOLUTION){const[e,t]=a.RESOLUTION.split("x");s.width=parseInt(e),s.height=parseInt(t)}if(a.CODECS){const e=a.CODECS.split(/[ ,]+/).filter(Boolean);s.videoCodec=Cg("video",e),s.audioCodec=Cg("audio",e),s.textCodec=Cg("text",e)}s.audioGroup=a.AUDIO,s.subtitleGroup=a.SUBTITLES,i.streams.push(s)}}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)))}))),o.length&&(o.forEach(((e,t)=>{e.id=t})),i.streams.forEach((e=>{e.subtitleGroup&&(e.subtitleStreams=o.filter((t=>t.group===e.subtitleGroup)))}))),i}(i,t)}static isMediaPlaylist(e){return e.includes("#EXTINF:")||e.includes("#EXT-X-TARGETDURATION:")}}class Ng{constructor(e){Ol(this,"_onLoaderRetry",((e,t)=>{this.hls.emit(bs,{error:Ag.network(e),retryTime:t})})),this.hls=e,this.player=e.player,this.TAG_NAME="HlsManifestLoader",this._timer=null;const{retryCount:t,retryDelay:i,loadTimeout:s,fetchOptions:r}=this.hls.config;this._loader=new cg({...r,responseType:"text",retry:t,retryDelay:i,timeout:s,onRetryError:this._onLoaderRetry},this.player),this._audioLoader=new cg({...r,responseType:"text",retry:t,retryDelay:i,timeout:s,onRetryError:this._onLoaderRetry},this.player),this._subtitleLoader=new cg({...r,responseType:"text",retry:t,retryDelay:i,timeout:s,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 s=[this._loader.load(e)];let r,a,o,n,l,h;t&&s.push(this._audioLoader.load(t)),i&&s.push(this._subtitleLoader.load(i));try{const[e,i,n]=await Promise.all(s);if(!e)return[];r=e.data,t?(a=null==i?void 0:i.data,o=null==n?void 0:n.data):o=null==i?void 0:i.data}catch(e){throw Ag.network(e)}try{var d;if(n=Og.parse(r,e),!1===(null===(d=n)||void 0===d?void 0:d.live)&&n.segments&&!n.segments.length)throw new Error("empty segments list");a&&(l=Og.parse(a,t)),o&&(h=Og.parse(o,i))}catch(e){throw new Ag(mg,gg,e)}return n&&(n.isMaster?this.hls.emit(ps,{playlist:n}):this.hls.emit(fs,{playlist:n})),[n,l,h]}poll(e,t,i,s,r,a){clearTimeout(this._timer),a=a||3e3;let o=this.hls.config.pollRetryCount;const n=async()=>{clearTimeout(this._timer);try{const r=await this.load(e,t,i);if(!r[0])return;o=this.hls.config.pollRetryCount,s(r[0],r[1],r[2])}catch(e){o--,o<=0&&r(e)}this._timer=setTimeout(n,a)};this._timer=setTimeout(n,a)}stopPoll(){return clearTimeout(this._timer),this.cancel()}cancel(){return Promise.all([this._loader.cancel(),this._audioLoader.cancel()])}}class jg{constructor(){Ol(this,"_chunkSpeeds",[]),Ol(this,"_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 Gg{constructor(e){Ol(this,"_emitOnLoaded",((e,t)=>{const{data:i,response:s,option:r}=e,{firstByteTime:a,startTime:o,endTime:n,contentLength:l}=r||{},h=n-o;this._bandwidthService.addRecord(l||i.byteLength,h),this.hls.emit(_s,{time:h,byteLength:l,url:t}),this.hls.emit(ws,{url:t,elapsed:h||0}),this.hls.emit(As,{url:t,responseUrl:s.url,elapsed:a-o}),this.hls.emit(Ss,{headers:s.headers})})),Ol(this,"_onLoaderRetry",((e,t)=>{this.hls.emit(bs,{error:Ag.network(e),retryTime:t})})),this.hls=e,this.player=e.player,this._bandwidthService=new jg;const{retryCount:t,retryDelay:i,loadTimeout:s,fetchOptions:r}=this.hls.config;this._segmentLoader=new cg({...r,responseType:"arraybuffer",retry:t,retryDelay:i,timeout:s,onRetryError:this._onLoaderRetry},this.player),this._audioSegmentLoader=new cg({...r,responseType:"arraybuffer",retry:t,retryDelay:i,timeout:s,onRetryError:this._onLoaderRetry},this.player),this._keyLoader=new cg({...r,responseType:"arraybuffer",retry:t,retryDelay:i,timeout:s,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()}}load(e,t,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:i;const r=[];return e&&(r[0]=this.loadVideoSegment(e,i)),t&&(r[1]=this.loadAudioSegment(t,s)),Promise.all(r)}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){var s;let r,a,o,n,l;const h=[];if(this.hls.emit(vs,{url:t.url}),h[0]=e.load(t.url),i&&t.initSegment){var d;const i=t.initSegment.url;r=this._mapCache[i],r||(this.hls.emit(vs,{url:i}),h[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=null===(d=t.initSegment.key)||void 0===d?void 0:d.url;s&&(l=t.initSegment.key.iv,n=this._keyCache[s],n||(this.hls.emit(vs,{url:s}),h[2]=this._keyLoader.load(s).then((e=>{e&&(n=this._keyCache[s]=e.data,this._emitOnLoaded(e,s))}))))}const c=null===(s=t.key)||void 0===s?void 0:s.url;c&&(o=t.key.iv,a=this._keyCache[c],a||(this.hls.emit(vs,{url:c}),h[3]=this._keyLoader.load(c).then((e=>{e&&(a=this._keyCache[c]=e.data,this._emitOnLoaded(e,c))}))));const[u]=await Promise.all(h);if(!u)return;const p=u.data;return this._emitOnLoaded(u,t.url),{data:p,map:r,key:a,mapKey:n,keyIv:o,mapKeyIv:l}}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()])}}class zg{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(){var e;return this.targetDuration||(null===(e=this.segments[0])||void 0===e?void 0:e.duration)||0}get liveEdge(){return this.endTime}get endTime(){var e;return(null===(e=this.lastSegment)||void 0===e?void 0:e.end)||0}get currentSubtitleEndSn(){var e;return(null===(e=this.currentSubtitleStream)||void 0===e?void 0:e.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 s=this.segments;for(let t=0,r=s.length;t<r;t++)if(s[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 s=i[i.length-1],r=(null==s?void 0:s.sn)||-1;if(r<e.endSN&&e.segments.length){const a=e.segments.findIndex((e=>e.sn===r)),o=a<0?e.segments:e.segments.slice(a+1);if(i.length&&o.length){let e=s.end;o.forEach((t=>{t.start=e,e=t.end}));const t=(null==s?void 0:s.cc)||-1;t>o[0].cc&&o.forEach((e=>e.cc+=t))}return t.endSN=e.endSN,t.segments=i.concat(o),o}}else t.segments=e.segments}}class $g{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(){var e;return null===(e=this.currentStream)||void 0===e?void 0:e.lastSegment}get currentSegment(){var e;return null===(e=this.currentSegments)||void 0===e?void 0:e[this._segmentPointer]}get nextSegment(){var e;return null===(e=this.currentSegments)||void 0===e?void 0:e[this._segmentPointer+1]}get currentSegments(){var e;return null===(e=this.currentStream)||void 0===e?void 0:e.segments}get currentSubtitleEndSn(){var e;return null===(e=this.currentStream)||void 0===e?void 0:e.currentSubtitleEndSn}get liveEdge(){var e;return null===(e=this.currentStream)||void 0===e?void 0:e.liveEdge}get totalDuration(){var e;return(null===(e=this.currentStream)||void 0===e?void 0:e.totalDuration)||0}get seekRange(){const e=this.currentSegments;if(e&&e.length)return[e[0].start,e[e.length-1].end]}get isEmpty(){var e;return!(null!==(e=this.currentSegments)&&void 0!==e&&e.length)}get isLive(){var e;return null===(e=this.currentStream)||void 0===e?void 0:e.live}get hasSubtitle(){var e;return!(null===(e=this.currentStream)||void 0===e||!e.currentSubtitleStream)}getAudioSegment(e){var t;return null===(t=this.currentStream)||void 0===t?void 0:t.getAudioSegment(e)}moveSegmentPointer(e){var t;null==e&&(e=this._segmentPointer+1),this._segmentPointer=hr(e,-1,null===(t=this.currentSegments)||void 0===t?void 0:t.length),this.player.debug.log(this.TAG_NAME,"moveSegmentPointer()",e,this._segmentPointer)}reset(){this.streams=[],this.currentStream=null,this.dvrWindow=0,this._segmentPointer=-1}getSegmentByIndex(e){var t;return null===(t=this.currentSegments)||void 0===t?void 0:t[e]}setNextSegmentByIndex(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]: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,s=0,r=t.length;s<r;s++)if(i=t[s],e>=i.start&&e<i.end)return s;const i=t[t.length-1];if(Math.abs(e-(null==i?void 0: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 zg(e)})),this.currentStream=this.streams[0];else if(Array.isArray(e.segments)){const s=this.currentStream;if(s){s.update(e,t,i);const r=s.updateSubtitle(i);r&&this.hls.emit(us,{list:r})}else this.reset(),this.currentStream=this.streams[0]=new zg(e,t,i)}this.currentStream&&this.hls.isLive&&!this.dvrWindow&&(this.dvrWindow=this.currentSegments.reduce(((e,t)=>e+=t.duration),0))}switchSubtitle(e){var t;null===(t=this.currentStream)||void 0===t||t.switchSubtitle(e)}clearOldSegment(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]: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 s=t.segments;if(s.length<=e)return void this.player.debug.log(this.TAG_NAME,`clearOldSegment() segments.length:${s.length} <= maxPlaylistSize:${e}`);const r=this._segmentPointer;this._segmentPointer=t.clearOldSegment(i,r),this.player.debug.log(this.TAG_NAME,"clearOldSegment() update _segmentPointer:",r,this._segmentPointer),this.player.debug.log(this.TAG_NAME,"currentSegments",this.currentSegments)}checkSegmentTrackChange(e,t){const i=this.findSegmentIndexByTime(e),s=this.getSegmentByIndex(i);if(!s)return;if(!s.hasAudio&&!s.hasVideo)return;if(2!==t&&s.hasAudio&&s.hasVideo)return s;if(s.end-e>.3)return;const r=this.getSegmentByIndex(i+1);return r&&(r.hasAudio||r.hasVideo)&&(r.hasAudio!==s.hasAudio||r.hasVideo!==s.hasVideo)?r:void 0}}function Wg(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];if((t=t.filter(Boolean)).length<2)return t[0];const s=new Uint8Array(t.reduce(((e,t)=>e+t.byteLength),0));let r=0;return t.forEach((e=>{s.set(e,r),r+=e.byteLength})),s}class Hg{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?Wg(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 s=await this.subtle.importKey("raw",t,{name:"AES-CBC"},!1,["encrypt","decrypt"]);return new Uint8Array(await this.subtle.decrypt({name:"AES-CBC",iv:i},s,e))}}}const Vg=9e4,Jg=45e4,Kg=9e4;class qg extends Cl{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=ct,this._audioCodecType=mt,this._vps=null,this._sps=null,this._pps=null,this.TAG_NAME="TsLoader",this.videoTrack=qg.initVideoTrack(),this.audioTrack=qg.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._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._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 s,r;const a=e[7];return 192&a&&(s=536870912*(14&e[9])+4194304*(255&e[10])+16384*(254&e[11])+128*(255&e[12])+(254&e[13])/2,64&a?(r=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2,s-r>54e5&&(s=r)):r=s),{data:e.subarray(9+t),pts:s,dts:r,originalPts:s,originalDts:r}}_demux(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];t&&(this._pmtId=-1,this.videoTrack=qg.initVideoTrack(),this.audioTrack=qg.initAudioTrack()),!i||t?(this._remainingPacketData=null,this._videoPesData=[],this._audioPesData=[]):(this.videoTrack.samples=[],this.audioTrack.samples=[],this._remainingPacketData&&(e=Wg(this._remainingPacketData,e),this._remainingPacketData=null));let s=e.length;const r=s%188;r&&(this._remainingPacketData=e.subarray(s-r),s-=r);for(let t=0;t<s;t+=188){if(71!==e[t])throw new Error("TS packet did not start with 0x47");const i=!!(64&e[t+1]),s=((31&e[t+1])<<8)+e[t+2];let r;if((48&e[t+3])>>4>1){if(r=t+5+e[t+4],r===t+188)continue}else r=t+4;switch(s){case 0:i&&(r+=e[r]+1),this._pmtId=(31&e[r+10])<<8|e[r+11];break;case this._pmtId:{i&&(r+=e[r]+1);const t=r+3+((15&e[r+1])<<8|e[r+2])-4;for(r+=12+((15&e[r+10])<<8|e[r+11]);r<t;){const t=(31&e[r+1])<<8|e[r+2];switch(e[r]){case 15:this._audioPid=t,this._audioCodecType=mt;break;case 27:this._videoPid=t,this._codecType=ct;break;case 36:this._videoPid=t,this._codecType=ut;break;default:this.player.debug.warn(this.TAG_NAME,`Unsupported stream. type: ${e[r]}, pid: ${t}`)}r+=5+((15&e[r+3])<<8|e[r+4])}}break;case this._videoPid:i&&this._videoPesData.length&&this._parseVideoData(),this._videoPesData.push(e.subarray(r,t+188));break;case this._audioPid:i&&this._audioPesData.length&&this._parseAudioData(),this._audioPesData.push(e.subarray(r,t+188));break;case 17:case 8191:break;default:this.player.debug.warn(this.TAG_NAME,`Unknown pid: ${s}`)}}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,s){this.player._times.demuxStart||(this.player._times.demuxStart=lr()),this._demux(e,t,i,s),this._fix(s,t,i)}_parseVideoData(){if(!this._videoPesData.length)return void this.player.debug.log(this.TAG_NAME,"_parseVideoData","no video pes data");const e=qg._parsePES(Wg(...this._videoPesData));if(!e)return void this.player.debug.warn(this.TAG_NAME,"Cannot parse video pes",this._videoPesData);const t=function(e){const t=e.length;let i=2,s=0;for(;null!==e[i]&&void 0!==e[i]&&1!==e[i];)i++;if(i++,s=i+2,s>=t)return[];const r=[];for(;s<t;)switch(e[s]){case 0:if(0!==e[s-1]){s+=2;break}if(0!==e[s-2]){s++;break}i!==s-2&&r.push(e.subarray(i,s-2));do{s++}while(1!==e[s]&&s<t);i=s+1,s=i+2;break;case 1:if(0!==e[s-1]||0!==e[s-2]){s+=3;break}i!==s-2&&r.push(e.subarray(i,s-2)),i=s+1,s=i+2;break;default:s+=3}return i<t&&r.push(e.subarray(i)),r}(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 s=this._codecType===ut,r={isIFrame:!1,type:Be,isHevc:s,vps:null,sps:null,pps:null,pts:t,dts:i,payload:null};e.forEach((e=>{const t=s?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(!s&&5!==t||s&&5===t)break;r.isIFrame=!0,this._gopId++;break;case 6:case 39:case 40:if(!s&&6!==t||s&&6===t)break;return void function(e,t){const i=e.length;let s=t?2:1,r=0,a=0,o="";for(;255===e[s];)r+=255,s++;for(r+=e[s++];255===e[s];)a+=255,s++;if(a+=e[s++],5===r&&i>s+16)for(let t=0;t<16;t++)o+=e[s].toString(16),s++;e.subarray(s)}(function(e){const t=e.byteLength,i=[];let s=1;for(;s<t-2;)0===e[s]&&0===e[s+1]&&3===e[s+2]?(i.push(s+2),s+=2):s++;if(!i.length)return e;const r=t-i.length,a=new Uint8Array(r);let o=0;for(s=0;s<r;o++,s++)o===i[0]&&(o++,i.shift()),a[s]=e[o];return a}(e),s);case 32:if(!s)break;r.vps||(r.vps=e);break;case 7:case 33:if(!s&&7!==t||s&&7===t)break;r.sps||(r.sps=e);break;case 8:case 34:if(!s&&8!==t||s&&8===t)break;r.pps||(r.pps=e)}if(s&&$o(t)||!s&&Lo(t)){const t=Uo(e);if(r.payload){const e=new Uint8Array(r.payload.byteLength+t.byteLength);e.set(r.payload,0),e.set(t,r.payload.byteLength),r.payload=e}else r.payload=t}}));let a=null;s?r.sps&&r.vps&&r.pps&&(a=jo({vps:r.vps,sps:r.sps,pps:r.pps})):r.sps&&r.pps&&(a=Co({sps:r.sps,pps:r.pps})),a&&(this.player.debug.log(this.TAG_NAME,"_createVideoSample","seqHeader"),this._doDecodeByHls(a,Be,r.pts,!0,0)),r.isIFrame&&this.calcIframeIntervalTimestamp(r.dts/90),this.videoTrack.samples=this.videoTrack.samples.concat(r)}_parseAudioData(){if(!this._audioPesData.length)return;const e=qg._parsePES(Wg(...this._audioPesData));if(e){if(this.player._opt.hasAudio){if(this._audioCodecType===mt){const t=function(e,t){const i=e.length;let s=0;for(;s+2<i&&(255!==e[s]||240!=(246&e[s+1]));)s++;if(s>=i)return;const r=s,a=[],o=(60&e[s+2])>>>2,n=Ks[o];if(!n)throw new Error(`Invalid sampling index: ${o}`);const l=1+((192&e[s+2])>>>6),h=(1&e[s+2])<<2|(192&e[s+3])>>>6;let d,c,u=0;const p=Qs(n);for(;s+7<i;)if(255===e[s]&&240==(246&e[s+1])){if(c=(3&e[s+3])<<11|e[s+4]<<3|(224&e[s+5])>>5,i-s<c)break;d=2*(1&~e[s+1]),a.push({pts:t+u*p,data:e.subarray(s+7+d,s+c)}),u++,s+=c}else s++;return{skip:r,remaining:s>=i?void 0:e.subarray(s),frames:a,samplingFrequencyIndex:o,sampleRate:n,objectType:l,channelCount:h,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=Hs({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,Pe,0,!1,0)}if(this._isSendAACSeqHeader){const e=[];t.frames.forEach((t=>{const i=t.pts,s=new Uint8Array(t.data.length+2);s.set([175,1],0),s.set(t.data,2);const r={type:Pe,pts:i,dts:i,payload:s};e.push(r)})),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(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];e=Math.round(9e4*e);const s=this.videoTrack,r=this.audioTrack,a=s.samples,o=r.samples;if(!a.length&&!o.length)return;const n=a[0],l=o[0];let h=0;if(a.length&&o.length&&(h=n.dts-l.pts),this._baseDtsInited||this._calculateBaseDts(),t&&(this._calculateBaseDts(),this._baseDts-=e),!i){this._videoNextDts=h>0?e+h:e,this._audioNextPts=h>0?e:e-h;const t=n?n.dts-this._baseDts-this._videoNextDts:0,i=l?l.pts-this._baseDts-this._audioNextPts:0;Math.abs(t||i)>Kg&&(this._calculateBaseDts(this.audioTrack,this.videoTrack),this._baseDts-=e)}this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(r),this._fixVideo(s);let d=s.samples.concat(r.samples);d=d.map((e=>(e.dts=e.dts/90,e.pts=e.pts/90,e.cts=e.pts-e.dts,e))).sort(((e,t)=>e.dts-t.dts)),d.forEach((e=>{const t=new Uint8Array(e.payload);delete e.payload,this.loopWorker.postMessage({...e,payload:t,cmd:"sample"},[t.buffer])})),fa(this._hasCalcFps)&&(this._hasCalcFps=!0,this._calcDecodeFps(d))}_calculateBaseDts(){const e=this.audioTrack,t=this.videoTrack,i=e.samples,s=t.samples;if(!i.length&&!s.length)return!1;let r=1/0,a=1/0;i.length&&(e.baseDts=r=i[0].pts),s.length&&(t.baseDts=a=s[0].dts),this._baseDts=Math.min(r,a);const o=a-r;return Number.isFinite(o)&&Math.abs(o)>45e3&&this.player.debug.warn(this.TAG_NAME,`large av first frame gap,\n video pts: ${a},\n audio pts: ${r},\n base dts: ${this._baseDts},\n detect is: ${o}`),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 s=0;const r=t[0],a=t[1],o=this._videoNextDts-r.dts;let n;Math.abs(o)>45e3&&(r.dts+=o,r.pts+=o,this.player.debug.warn(this.TAG_NAME,`large video gap between chunk,\n next dts is ${this._videoNextDts},\n first dts is ${r.dts},\n next dts is ${a.dts},\n duration is ${o}`),a&&Math.abs(a.dts-r.dts)>Kg&&(this._videoTimestampBreak=!0,t.forEach(((e,t)=>{0!==t&&(e.dts+=o,e.pts+=o)}))));const l=e.samples[0],h=e.samples[i-1];n=1===i?9e3:Math.floor((h.dts-l.dts)/(i-1));for(let r=0;r<i;r++){const a=t[r].dts,o=t[r+1];if(s=r<i-1?o.dts-a:t[r-1]?Math.min(a-t[r-1].dts,n):n,s>Kg||s<0){this._videoTimestampBreak=!0,s=this._audioTimestampBreak?n:Math.max(s,2700);const i=this._audioNextPts||0;o&&o.dts>i&&(s=n),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[r].originalDts},\n next dts is ${this._videoNextDts},\n sample Duration is ${s} ,\n ref Sample DurationInt is ${n}`)}t[r].duration=s,this._videoNextDts+=s}}_doFixAudioInternal(e,t,i){e.sampleDuration||(e.sampleDuration=Qs(e.timescale,i));const s=e.sampleDuration;if(void 0===this._audioNextPts){const e=t[0];this._audioNextPts=e.pts}for(let i=0;i<t.length;i++){const r=this._audioNextPts,a=t[i],o=a.pts-r;if(!this._audioTimestampBreak&&o>=3*s&&o<=Vg&&!_r()){Ys(e.codec,e.channelCount)||t[0].data.subarray();const n=Math.floor(o/s);Math.abs(a.pts-this._lastAudioExceptionGapDot)>Jg&&(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 ${n},\n nextPts is ${r},\n ref sample duration is ${s}`);for(let e=0;e<n;e++)this._audioNextPts+=s,i++;i--}else o<=-3*s&&o>=-9e4?(Math.abs(a.pts-this._lastAudioExceptionOverlapDot)>Jg&&(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 ${r},\n ref sample duration is ${s}`)),t.splice(i,1),i--):(Math.abs(o)>=Vg&&(this._audioTimestampBreak=!0,Math.abs(a.pts-this._lastAudioExceptionLargeGapDot)>Jg&&(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 ${r},\n sample duration is ${o}\n ref sample duration is ${s}`))),a.dts=a.pts=r,this._audioNextPts+=s)}}_calcDecodeFps(e){const t=oa(e.map((e=>({ts:e.dts||e.pts,type:e.type}))),Be);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(){const e=_a(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(`JbPro:[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((s=>{s.type===t?(i.videoListLength++,s.duration&&(i.buferredDuration+=s.duration/90)):s.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 s=new Worker(i);this.workerUrl=i,this.workerClearTimeout=setTimeout((()=>{window.URL.revokeObjectURL(this.workerUrl),this.workerUrl=null,this.workerClearTimeout=null}),X),s.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=s}_postMessageToLoopWorker(e,t){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;pa(this.player._opt.m7sCryptoAudio)&&(i=this.cryptoPayloadAudio(t)),this._doDecodeByHls(i,Pe,e.dts,!1,0)}_doDecodeVideo(e){const t=new Uint8Array(e.payload);let i=null;i=e.isHevc?Go(t,e.isIFrame):xo(t,e.isIFrame),this.player.updateStats({dts:e.dts,vbps:i.byteLength});const s=e.pts-e.dts;let r=this.cryptoPayload(i,e.isIFrame);this._doDecodeByHls(r,Be,e.dts,e.isIFrame,s)}_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}}function Yg(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<8)+(e[t+1]||0)}function Qg(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<24>>>0)+(e[t+1]<<16)+(e[t+2]<<8)+(e[t+3]||0)}function Xg(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const i=Math.pow(2,32);return Qg(e,t)*i+Qg(e,t+4)}const Zg="aac",ey="g7110a",ty="g7110m",iy="avc",sy="hevc";class ry{static getFrameDuration(e){return 1024*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4)/e}static getRateIndexByRate(e){return ry.FREQ.indexOf(e)}}function ay(e,t,i,s,r,a){const o=[],n=null==r?void 0:r.entries,l=t.entries,h=s.entries,d=i.entrySizes,c=null==a?void 0:a.entries;let u,p,f;c&&(u={},c.forEach((e=>{u[e-1]=!0}))),n&&(p=[],n.forEach((e=>{let{count:t,offset:i}=e;for(let e=0;e<t;e++)p.push(i)})));let m=-1,g=0,y=0,A=0,b=0,v=0,_=l[0].samplesPerChunk,w=l[1]?l[1].firstChunk-1:1/0;return e.entries.forEach((e=>{let{count:t,delta:s}=e;for(let e=0;e<t;e++)f={dts:g,duration:s,size:d[y]||i.sampleSize,offset:h[A]+v,index:y},c&&(f.keyframe=u[y],f.keyframe&&m++,f.gopId=m),p&&y<p.length&&(f.pts=f.dts+p[y]),o.push(f),g+=s,y++,y<_?v+=f.size:(A++,v=0,A>=w&&(b++,w=l[b+1]?l[b+1].firstChunk-1:1/0),_+=l[b].samplesPerChunk)})),o}function oy(e,t){return e.dataReferenceIndex=Yg(t,6),e.width=Yg(t,24),e.height=Yg(t,26),e.horizresolution=Qg(t,28),e.vertresolution=Qg(t,32),e.frameCount=Yg(t,40),e.depth=Yg(t,74),78}function ny(e,t){return e.dataReferenceIndex=Yg(t,6),e.channelCount=Yg(t,16),e.sampleSize=Yg(t,18),e.sampleRate=Qg(t,24)/65536,28}function ly(e,t,i){if(!e)return;if(e.size!==e.data.length)throw new Error(`box ${e.type} size !== data.length`);const s={start:e.start,size:e.size,headerSize:e.headerSize,type:e.type};return t&&(s.version=e.data[e.headerSize],s.flags=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<16)+(e[t+1]<<8)+(e[t+2]||0)}(e.data,e.headerSize+1),s.headerSize+=4),i(s,e.data.subarray(s.headerSize),s.start+s.headerSize),s}Ol(ry,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]);const hy=function(e,t,i){const s=String(i),r=t>>0;let a=Math.ceil(r/s.length);const o=[],n=String(e);for(;a--;)o.push(s);return o.join("").substring(0,r-n.length)+n},dy=function(){const e=[];for(var t=arguments.length,i=new Array(t),s=0;s<t;s++)i[s]=arguments[s];return i.forEach((t=>{e.push(hy(Number(t).toString(16),2,0))})),e[0]};class cy{static probe(e){return!!cy.findBox(e,["ftyp"])}static findBox(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const s=[];if(!e)return s;let r=0,a="",o=0;for(;e.length>7;){if(r=Qg(e),a=String.fromCharCode.apply(null,e.subarray(4,8)),o=8,1===r?(r=Xg(e,8),o+=8):r||(r=e.length),!t[0]||a===t[0]){const n=e.subarray(0,r);if(!(t.length<2))return cy.findBox(n.subarray(o),t.slice(1),i+o);s.push({start:i,size:r,headerSize:o,type:a,data:n})}i+=r,e=e.subarray(r)}return s}static tfhd(e){return ly(e,!0,((e,t)=>{e.trackId=Qg(t);let i=4;const s=1&e.flags,r=2&e.flags,a=8&e.flags,o=16&e.flags,n=32&e.flags;s&&(i+=4,e.baseDataOffset=Qg(t,i),i+=4),r&&(e.sampleDescriptionIndex=Qg(t,i),i+=4),a&&(e.defaultSampleDuration=Qg(t,i),i+=4),o&&(e.defaultSampleSize=Qg(t,i),i+=4),n&&(e.defaultSampleFlags=Qg(t,i))}))}static sidx(e){return ly(e,!0,((e,t)=>{let i=0;e.reference_ID=Qg(t,i),i+=4,e.timescale=Qg(t,i),i+=4,0===e.version?(e.earliest_presentation_time=Qg(t,i),i+=4,e.first_offset=Qg(t,i),i+=4):(e.earliest_presentation_time=Xg(t,i),i+=8,e.first_offset=Xg(t,i),i+=8),i+=2,e.references=[];const s=Yg(t,i);i+=2;for(let r=0;r<s;r++){const s={};e.references.push(s);let r=Qg(t,i);i+=4,s.reference_type=r>>31&1,s.referenced_size=2147483647&r,s.subsegment_duration=Qg(t,i),i+=4,r=Qg(t,i),i+=4,s.starts_with_SAP=r>>31&1,s.SAP_type=r>>28&7,s.SAP_delta_time=268435455&r}}))}static moov(e){return ly(e,!1,((e,t,i)=>{e.mvhd=cy.mvhd(cy.findBox(t,["mvhd"],i)[0]),e.trak=cy.findBox(t,["trak"],i).map((e=>cy.trak(e))),e.pssh=cy.pssh(cy.findBox(t,["pssh"],i)[0])}))}static mvhd(e){return ly(e,!0,((e,t)=>{let i=0;1===e.version?(e.timescale=Qg(t,16),e.duration=Xg(t,20),i+=28):(e.timescale=Qg(t,8),e.duration=Qg(t,12),i+=16),e.nextTrackId=Qg(t,i+76)}))}static trak(e){return ly(e,!1,((e,t,i)=>{e.tkhd=cy.tkhd(cy.findBox(t,["tkhd"],i)[0]),e.mdia=cy.mdia(cy.findBox(t,["mdia"],i)[0])}))}static tkhd(e){return ly(e,!0,((e,t)=>{let i=0;1===e.version?(e.trackId=Qg(t,16),e.duration=Xg(t,24),i+=32):(e.trackId=Qg(t,8),e.duration=Qg(t,16),i+=20),e.width=Qg(t,i+52),e.height=Qg(t,i+56)}))}static mdia(e){return ly(e,!1,((e,t,i)=>{e.mdhd=cy.mdhd(cy.findBox(t,["mdhd"],i)[0]),e.hdlr=cy.hdlr(cy.findBox(t,["hdlr"],i)[0]),e.minf=cy.minf(cy.findBox(t,["minf"],i)[0])}))}static mdhd(e){return ly(e,!0,((e,t)=>{let i=0;1===e.version?(e.timescale=Qg(t,16),e.duration=Xg(t,20),i+=28):(e.timescale=Qg(t,8),e.duration=Qg(t,12),i+=16);const s=Yg(t,i);e.language=String.fromCharCode(96+(s>>10&31),96+(s>>5&31),96+(31&s))}))}static hdlr(e){return ly(e,!0,((e,t)=>{0===e.version&&(e.handlerType=String.fromCharCode.apply(null,t.subarray(4,8)))}))}static minf(e){return ly(e,!1,((e,t,i)=>{e.vmhd=cy.vmhd(cy.findBox(t,["vmhd"],i)[0]),e.smhd=cy.smhd(cy.findBox(t,["smhd"],i)[0]),e.stbl=cy.stbl(cy.findBox(t,["stbl"],i)[0])}))}static vmhd(e){return ly(e,!0,((e,t)=>{e.graphicsmode=Yg(t),e.opcolor=[Yg(t,2),Yg(t,4),Yg(t,6)]}))}static smhd(e){return ly(e,!0,((e,t)=>{e.balance=Yg(t)}))}static stbl(e){return ly(e,!1,((e,t,i)=>{var s,r,a;e.stsd=cy.stsd(cy.findBox(t,["stsd"],i)[0]),e.stts=cy.stts(cy.findBox(t,["stts"],i)[0]),e.ctts=cy.ctts(cy.findBox(t,["ctts"],i)[0]),e.stsc=cy.stsc(cy.findBox(t,["stsc"],i)[0]),e.stsz=cy.stsz(cy.findBox(t,["stsz"],i)[0]),e.stco=cy.stco(cy.findBox(t,["stco"],i)[0]),e.stco||(e.co64=cy.co64(cy.findBox(t,["co64"],i)[0]),e.stco=e.co64);const o=null===(s=e.stsd.entries[0])||void 0===s||null===(r=s.sinf)||void 0===r||null===(a=r.schi)||void 0===a?void 0:a.tenc.default_IV_size;e.stss=cy.stss(cy.findBox(t,["stss"],i)[0]),e.senc=cy.senc(cy.findBox(t,["senc"],i)[0],o)}))}static senc(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;return ly(e,!0,((e,i)=>{let s=0;const r=Qg(i,s);s+=4,e.samples=[];for(let a=0;a<r;a++){const r={InitializationVector:[]};for(let e=0;e<t;e++)r.InitializationVector[e]=i[s+e];if(s+=t,2&e.flags){r.subsamples=[];const e=Yg(i,s);s+=2;for(let t=0;t<e;t++){const e={};e.BytesOfClearData=Yg(i,s),s+=2,e.BytesOfProtectedData=Qg(i,s),s+=4,r.subsamples.push(e)}}e.samples.push(r)}}))}static pssh(e){return ly(e,!0,((e,t)=>{const i=[],s=[];let r=0;for(let e=0;e<16;e++)s.push(dy(t[r+e]));if(r+=16,e.version>0){const e=Qg(t,r);r+=4;for(let s=0;s<(""+e).length;s++)for(let e=0;e<16;e++){const e=t[r];r+=1,i.push(dy(e))}}const a=Qg(t,r);e.data_size=a,r+=4,e.kid=i,e.system_id=s,e.buffer=t}))}static stsd(e){return ly(e,!0,((e,t,i)=>{e.entryCount=Qg(t),e.entries=cy.findBox(t.subarray(4),[],i+4).map((e=>{switch(e.type){case"avc1":case"avc2":case"avc3":case"avc4":return cy.avc1(e);case"hvc1":case"hev1":return cy.hvc1(e);case"mp4a":return cy.mp4a(e);case"alaw":case"ulaw":return cy.alaw(e);case"enca":return ly(e,!1,((e,t,i)=>{e.channelCount=Yg(t,16),e.samplesize=Yg(t,18),e.sampleRate=Qg(t,24)/65536,t=t.subarray(28),e.sinf=cy.sinf(cy.findBox(t,["sinf"],i)[0]),e.esds=cy.esds(cy.findBox(t,["esds"],i)[0])}));case"encv":return ly(e,!1,((e,t,i)=>{e.width=Yg(t,24),e.height=Yg(t,26),e.horizresolution=Qg(t,28),e.vertresolution=Qg(t,32),t=t.subarray(78),e.sinf=cy.sinf(cy.findBox(t,["sinf"],i)[0]),e.avcC=cy.avcC(cy.findBox(t,["avcC"],i)[0]),e.hvcC=cy.hvcC(cy.findBox(t,["hvcC"],i)[0]),e.pasp=cy.pasp(cy.findBox(t,["pasp"],i)[0])}))}})).filter(Boolean)}))}static tenc(e){return ly(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 s=0;s<16;s++)e.default_KID.push(dy(t[i])),i+=1}))}static schi(e){return ly(e,!1,((e,t,i)=>{e.tenc=cy.tenc(cy.findBox(t,["tenc"],i)[0])}))}static sinf(e){return ly(e,!1,((e,t,i)=>{e.schi=cy.schi(cy.findBox(t,["schi"],i)[0]),e.frma=cy.frma(cy.findBox(t,["frma"],i)[0])}))}static frma(e){return ly(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 ly(e,!1,((e,t,i)=>{const s=oy(e,t),r=t.subarray(s);i+=s,e.avcC=cy.avcC(cy.findBox(r,["avcC"],i)[0]),e.pasp=cy.pasp(cy.findBox(r,["pasp"],i)[0])}))}static avcC(e){return ly(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 s=0;s<3;s++)t=e[s].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 s=0;s<e.spsLength;s++){const s=Yg(t,i);i+=2,e.sps.push(t.subarray(i,i+s)),i+=s}e.ppsLength=t[i],i+=1,e.pps=[];for(let s=0;s<e.ppsLength;s++){const s=Yg(t,i);i+=2,e.pps.push(t.subarray(i,i+=s)),i+=s}}))}static hvc1(e){return ly(e,!1,((e,t,i)=>{const s=oy(e,t),r=t.subarray(s);i+=s,e.hvcC=cy.hvcC(cy.findBox(r,["hvcC"],i)[0]),e.pasp=cy.pasp(cy.findBox(r,["pasp"],i)[0])}))}static hvcC(e){return ly(e,!1,((t,i)=>{t.data=e.data,t.codec="hev1.1.6.L93.B0",t.configurationVersion=i[0];const s=i[1];t.generalProfileSpace=s>>6,t.generalTierFlag=(32&s)>>5,t.generalProfileIdc=31&s,t.generalProfileCompatibility=Qg(i,2),t.generalConstraintIndicatorFlags=i.subarray(6,12),t.generalLevelIdc=i[12],t.avgFrameRate=Yg(i,19),t.numOfArrays=i[22],t.vps=[],t.sps=[],t.pps=[];let r=23,a=0,o=0,n=0;for(let e=0;e<t.numOfArrays;e++){a=63&i[r],o=Yg(i,r+1),r+=3;const e=[];for(let t=0;t<o;t++)n=Yg(i,r),r+=2,e.push(i.subarray(r,r+n)),r+=n;32===a?t.vps.push(...e):33===a?t.sps.push(...e):34===a&&t.pps.push(...e)}}))}static pasp(e){return ly(e,!1,((e,t)=>{e.hSpacing=Qg(t),e.vSpacing=Qg(t,4)}))}static mp4a(e){return ly(e,!1,((e,t,i)=>{const s=ny(e,t);e.esds=cy.esds(cy.findBox(t.subarray(s),["esds"],i+s)[0])}))}static esds(e){return ly(e,!0,((e,t)=>{e.codec="mp4a.";let i=0,s=0,r=0,a=0;for(;t.length;){for(i=0,a=t[i],s=t[i+1],i+=2;128&s;)r=(127&s)<<7,s=t[i],i+=1;if(r+=127&s,3===a)t=t.subarray(i+3);else{if(4!==a){if(5===a){const s=e.config=t.subarray(i,i+r);let a=(248&s[0])>>3;return 31===a&&s.length>=2&&(a=32+((7&s[0])<<3)+((224&s[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 ly(e,!1,((e,t)=>{ny(e,t)}))}static stts(e){return ly(e,!0,((e,t)=>{const i=Qg(t),s=[];let r=4;for(let e=0;e<i;e++)s.push({count:Qg(t,r),delta:Qg(t,r+4)}),r+=8;e.entryCount=i,e.entries=s}))}static ctts(e){return ly(e,!0,((e,t)=>{const i=Qg(t),s=[];let r=4;if(1===e.version)for(let e=0;e<i;e++)s.push({count:Qg(t,r),offset:Qg(t,r+4)}),r+=8;else for(let e=0;e<i;e++)s.push({count:Qg(t,r),offset:-(1+~Qg(t,r+4))}),r+=8;e.entryCount=i,e.entries=s}))}static stsc(e){return ly(e,!0,((e,t)=>{const i=Qg(t),s=[];let r=4;for(let e=0;e<i;e++)s.push({firstChunk:Qg(t,r),samplesPerChunk:Qg(t,r+4),sampleDescriptionIndex:Qg(t,r+8)}),r+=12;e.entryCount=i,e.entries=s}))}static stsz(e){return ly(e,!0,((e,t)=>{const i=Qg(t),s=Qg(t,4),r=[];if(!i){let e=8;for(let i=0;i<s;i++)r.push(Qg(t,e)),e+=4}e.sampleSize=i,e.sampleCount=s,e.entrySizes=r}))}static stco(e){return ly(e,!0,((e,t)=>{const i=Qg(t),s=[];let r=4;for(let e=0;e<i;e++)s.push(Qg(t,r)),r+=4;e.entryCount=i,e.entries=s}))}static co64(e){return ly(e,!0,((e,t)=>{const i=Qg(t),s=[];let r=4;for(let e=0;e<i;e++)s.push(Xg(t,r)),r+=8;e.entryCount=i,e.entries=s}))}static stss(e){return ly(e,!0,((e,t)=>{const i=Qg(t),s=[];let r=4;for(let e=0;e<i;e++)s.push(Qg(t,r)),r+=4;e.entryCount=i,e.entries=s}))}static moof(e){return ly(e,!1,((e,t,i)=>{e.mfhd=cy.mfhd(cy.findBox(t,["mfhd"],i)[0]),e.traf=cy.findBox(t,["traf"],i).map((e=>cy.traf(e)))}))}static mfhd(e){return ly(e,!0,((e,t)=>{e.sequenceNumber=Qg(t)}))}static traf(e){return ly(e,!1,((e,t,i)=>{e.tfhd=cy.tfhd(cy.findBox(t,["tfhd"],i)[0]),e.tfdt=cy.tfdt(cy.findBox(t,["tfdt"],i)[0]),e.trun=cy.trun(cy.findBox(t,["trun"],i)[0])}))}static trun(e){return ly(e,!0,((e,t)=>{const{version:i,flags:s}=e,r=t.length,a=e.sampleCount=Qg(t);let o=4;if(r>o&&1&s&&(e.dataOffset=-(1+~Qg(t,o)),o+=4),r>o&&4&s&&(e.firstSampleFlags=Qg(t,o),o+=4),e.samples=[],r>o){let r;for(let n=0;n<a;n++)r={},256&s&&(r.duration=Qg(t,o),o+=4),512&s&&(r.size=Qg(t,o),o+=4),1024&s&&(r.flags=Qg(t,o),o+=4),2048&s&&(r.cts=i?-(1+~Qg(t,o+4)):Qg(t,o),o+=4),e.samples.push(r)}}))}static tfdt(e){return ly(e,!0,((e,t)=>{1===e.version?e.baseMediaDecodeTime=Xg(t):e.baseMediaDecodeTime=Qg(t)}))}static probe(e){return!!cy.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){var s,r;const a=e.trak;if(!a||!a.length)return;const o=a.find((e=>{var t,i;return"vide"===(null===(t=e.mdia)||void 0===t||null===(i=t.hdlr)||void 0===i?void 0:i.handlerType)})),n=a.find((e=>{var t,i;return"soun"===(null===(t=e.mdia)||void 0===t||null===(i=t.hdlr)||void 0===i?void 0:i.handlerType)}));if(o&&t){var l,h,d,c,u,p,f;const i=t,s=null===(l=o.tkhd)||void 0===l?void 0:l.trackId;null!=s&&(i.id=o.tkhd.trackId),i.tkhdDuration=o.tkhd.duration,i.mvhdDurtion=e.mvhd.duration,i.mvhdTimecale=e.mvhd.timescale,i.timescale=i.formatTimescale=o.mdia.mdhd.timescale,i.duration=o.mdia.mdhd.duration||i.mvhdDurtion/i.mvhdTimecale*i.timescale;const r=o.mdia.minf.stbl.stsd.entries[0];if(i.width=r.width,i.height=r.height,r.pasp&&(i.sarRatio=[r.pasp.hSpacing,r.pasp.vSpacing]),r.hvcC)i.codecType=sy,i.codec=r.hvcC.codec,i.vps=r.hvcC.vps,i.sps=r.hvcC.sps,i.pps=r.hvcC.pps,i.hvcC=r.hvcC.data;else{if(!r.avcC)throw new Error("unknown video stsd entry");i.codecType=iy,i.codec=r.avcC.codec,i.sps=r.avcC.sps,i.pps=r.avcC.pps}var m,g,y,A,b,v,_,w;if(i.present=!0,i.ext={},i.ext.stss=null===(h=o.mdia)||void 0===h||null===(d=h.minf)||void 0===d||null===(c=d.stbl)||void 0===c?void 0:c.stss,i.ext.ctts=null===(u=o.mdia)||void 0===u||null===(p=u.minf)||void 0===p||null===(f=p.stbl)||void 0===f?void 0:f.ctts,r&&"encv"===r.type)i.isVideoEncryption=!0,r.default_KID=null===(m=r.sinf)||void 0===m||null===(g=m.schi)||void 0===g?void 0:g.tenc.default_KID,r.default_IsEncrypted=null===(y=r.sinf)||void 0===y||null===(A=y.schi)||void 0===A?void 0:A.tenc.default_IsEncrypted,r.default_IV_size=null===(b=r.sinf)||void 0===b||null===(v=b.schi)||void 0===v?void 0:v.tenc.default_IV_size,i.videoSenc=o.mdia.minf.stbl.senc&&o.mdia.minf.stbl.senc.samples,r.data_format=null===(_=r.sinf)||void 0===_||null===(w=_.frma)||void 0===w?void 0:w.data_format,i.useEME=e.useEME,i.kidValue=e.kidValue,i.pssh=e.pssh,i.encv=r}if(n&&i){var S,T,E,k,C,x,R,D,L;const t=i,a=null===(S=n.tkhd)||void 0===S?void 0:S.trackId;null!=a&&(t.id=n.tkhd.trackId),t.tkhdDuration=n.tkhd.duration,t.mvhdDurtion=e.mvhd.duration,t.mvhdTimecale=e.mvhd.timescale,t.timescale=t.formatTimescale=n.mdia.mdhd.timescale,t.duration=n.mdia.mdhd.duration||t.mvhdDurtion/t.mvhdTimecale*t.timescale;const o=n.mdia.minf.stbl.stsd.entries[0];switch(t.sampleSize=o.sampleSize,t.sampleRate=o.sampleRate,t.channelCount=o.channelCount,t.present=!0,o.type){case"alaw":t.codecType=t.codec=ey,t.sampleRate=8e3;break;case"ulaw":t.codecType=t.codec=ty,t.sampleRate=8e3;break;default:t.codecType=Zg,t.sampleDuration=ry.getFrameDuration(t.sampleRate,t.timescale),t.sampleRateIndex=ry.getRateIndexByRate(t.sampleRate),t.objectType=(null===(s=o.esds)||void 0===s?void 0:s.objectType)||2,o.esds&&(t.config=Array.from(o.esds.config)),t.codec=(null===(r=o.esds)||void 0===r?void 0:r.codec)||"mp4a.40.2"}var I,P,B,M,F,U,O,N;if(t.sampleDuration=ry.getFrameDuration(t.sampleRate,t.timescale),t.objectType=(null===(T=o.esds)||void 0===T?void 0:T.objectType)||2,o.esds&&(o.esds.config?t.config=Array.from(o.esds.config):console.warn("esds config is null")),t.codec=(null===(E=o.esds)||void 0===E?void 0:E.codec)||"mp4a.40.2",t.sampleRateIndex=ry.getRateIndexByRate(t.sampleRate),t.ext={},t.ext.stss=null===(k=n.mdia)||void 0===k||null===(C=k.minf)||void 0===C||null===(x=C.stbl)||void 0===x?void 0:x.stss,t.ext.ctts=null===(R=n.mdia)||void 0===R||null===(D=R.minf)||void 0===D||null===(L=D.stbl)||void 0===L?void 0:L.ctts,t.present=!0,o&&"enca"===o.type)t.isAudioEncryption=!0,o.data_format=null===(I=o.sinf)||void 0===I||null===(P=I.frma)||void 0===P?void 0:P.data_format,o.default_KID=null===(B=o.sinf)||void 0===B||null===(M=B.schi)||void 0===M?void 0:M.tenc.default_KID,o.default_IsEncrypted=null===(F=o.sinf)||void 0===F||null===(U=F.schi)||void 0===U?void 0:U.tenc.default_IsEncrypted,o.default_IV_size=null===(O=o.sinf)||void 0===O||null===(N=O.schi)||void 0===N?void 0:N.tenc.default_IV_size,t.audioSenc=n.mdia.minf.stbl.senc&&n.mdia.minf.stbl.senc.samples,t.useEME=e.useEME,t.kidValue=e.kidValue,t.enca=o}if(i&&(i.isVideoEncryption=!!t&&t.isVideoEncryption),t&&(t.isAudioEncryption=!!i&&i.isAudioEncryption),null!=t&&t.encv||null!=i&&i.enca){var j,G;const e=null==t||null===(j=t.encv)||void 0===j?void 0:j.default_KID,s=null==i||null===(G=i.enca)||void 0===G?void 0:G.default_KID,r=e||s?(e||s).join(""):null;t&&(t.kid=r),i&&(i.kid=r)}return t&&(t.flags=3841),i&&(i.flags=1793),{videoTrack:t,audioTrack:i}}static evaluateDefaultDuration(e,t,i){var s;const r=null==t||null===(s=t.samples)||void 0===s?void 0:s.length;if(!r)return 1024;return 1024*r/t.timescale*e.timescale/i}static moofToSamples(e,t,i){const s={};return e.mfhd&&(t&&(t.sequenceNumber=e.mfhd.sequenceNumber),i&&(i.sequenceNumber=e.mfhd.sequenceNumber)),e.traf.forEach((e=>{let{tfhd:r,tfdt:a,trun:o}=e;if(!r||!o)return;a&&(t&&t.id===r.trackId&&(t.baseMediaDecodeTime=a.baseMediaDecodeTime),i&&i.id===r.trackId&&(i.baseMediaDecodeTime=a.baseMediaDecodeTime));const n=r.defaultSampleSize||0,l=r.defaultSampleDuration||cy.evaluateDefaultDuration(t,i,o.samples.length||o.sampleCount);let h=o.dataOffset||0,d=0,c=-1;if(!o.samples.length&&o.sampleCount){s[r.trackId]=[];for(let e=0;e<o.sampleCount;e++)s[r.trackId].push({offset:h,dts:d,duration:l,size:n}),d+=l,h+=n}else s[r.trackId]=o.samples.map(((e,t)=>((e={offset:h,dts:d,pts:d+(e.cts||0),duration:e.duration||l,size:e.size||n,gopId:c,keyframe:0===t||null!==e.flags&&void 0!==e.flags&&(65536&e.flags)>>>0!=65536}).keyframe&&(c++,e.gopId=c),d+=e.duration,h+=e.size,e)))})),s}static moovToSamples(e){const t=e.trak;if(!t||!t.length)return;const i=t.find((e=>{var t,i;return"vide"===(null===(t=e.mdia)||void 0===t||null===(i=t.hdlr)||void 0===i?void 0:i.handlerType)})),s=t.find((e=>{var t,i;return"soun"===(null===(t=e.mdia)||void 0===t||null===(i=t.hdlr)||void 0===i?void 0:i.handlerType)}));if(!i&&!s)return;let r,a;if(i){var o,n;const e=null===(o=i.mdia)||void 0===o||null===(n=o.minf)||void 0===n?void 0:n.stbl;if(!e)return;const{stts:t,stsc:s,stsz:a,stco:l,stss:h,ctts:d}=e;if(!(t&&s&&a&&l&&h))return;r=ay(t,s,a,l,d,h)}if(s){var l,h,d;const e=null===(l=s.mdia)||void 0===l||null===(h=l.minf)||void 0===h?void 0:h.stbl;if(!e)return;const t=null===(d=s.mdia.mdhd)||void 0===d?void 0:d.timescale,{stts:i,stsc:r,stsz:o,stco:n}=e;if(!(t&&i&&r&&o&&n))return;a=ay(i,r,o,n)}return{videoSamples:r,audioSamples:a}}}class uy extends Cl{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._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,s=this.videoTrack;if(this.checkInitAudio(),this.checkInitVideo(),i.samples=[],s.samples=[],t){if(this.player.updateStats({abps:t.byteLength}),fa(this.isInitAudio)){const e=cy.findBox(t,["moov"])[0];if(!e)return void this.player.debug.error(this.TAG_NAME,"cannot found moov box");cy.moovToTrack(cy.moov(e),null,i),this.checkInitAudio()&&(this.player.debug.log(this.TAG_NAME,"audioData audio init success"),this._sendAccADTSHeader(i))}const e=cy.findBox(t,["moof"])[0];if(e){const s=cy.moofToSamples(cy.moof(e),null,i)[i.id],r=i.baseMediaDecodeTime;if(s){const a=e.start;s.map((e=>{e.offset+=a;const s=t.subarray(e.offset,e.offset+e.size),o=e.dts+r,n=new Uint8Array(s.length+2);n.set([175,1],0),n.set(s,2),i.samples.push({type:Pe,pts:o,dts:o,payload:n,duration:e.duration,size:n.byteLength})}))}}}if(e){if(this.player.updateStats({vbps:e.byteLength}),fa(this.isInitVideo)&&fa(this.isInitAudio)){const t=cy.findBox(e,["moov"])[0];if(!t)throw new Error("cannot found moov box");if(cy.moovToTrack(cy.moov(t),s,i),fa(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;s.codecType===Ri?s.sps.length&&s.vps.length&&s.pps.length&&(e=jo({sps:s.sps[0],pps:s.pps[0],vps:s.vps[0]})):s.sps.length&&s.pps.length&&(e=Co({sps:s.sps[0],pps:s.pps[0]})),e&&(this.player.debug.log(this.TAG_NAME,"seqHeader"),this._doDecodeByHls(e,Be,0,!0,0))}}const t=cy.findBox(e,["moof"])[0];if(t){const r=cy.moofToSamples(cy.moof(t),s,i),a=s.baseMediaDecodeTime,o=i.baseMediaDecodeTime,n=t.start;Object.keys(r).forEach((t=>{s.id==t?r[t].map((t=>{t.offset+=n;const i={type:Be,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 r=e.subarray(t.offset,t.offset+t.size);i.payload=r,s.samples.push(i)})):i.id==t&&r[t].map((t=>{t.offset+=n;const s=e.subarray(t.offset,t.offset+t.size),r=t.dts+o,a=new Uint8Array(s.length+2);a.set([175,1],0),a.set(s,2),i.samples.push({type:Pe,pts:r,dts:r,payload:a,duration:t.duration,size:a.byteLength})}))}))}}const r=s.samples.concat(i.samples);r.sort(((e,t)=>e.dts-t.dts)),r.forEach((e=>{const t=new Uint8Array(e.payload);delete e.payload,this.loopWorker.postMessage({...e,payload:t,cmd:"sample"},[t.buffer])})),fa(this._hasCalcFps)&&(this._hasCalcFps=!0,this._calcDecodeFps(r))}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=Hs({profile:e.objectType,sampleRate:e.sampleRateIndex,channel:e.channelCount});this._doDecodeByHls(t,Pe,0,!0,0)}_calcDecodeFps(e){const t=oa(e.map((e=>({ts:e.dts||e.pts,type:e.type}))),Be);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(){const e=_a(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(`JbPro:[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((s=>{s.type===t?(i.videoListLength++,s.duration&&(i.buferredDuration+=s.duration)):s.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 s=new Worker(i);this.workerUrl=i,this.workerClearTimeout=setTimeout((()=>{window.URL.revokeObjectURL(this.workerUrl),this.workerUrl=null,this.workerClearTimeout=null}),X),s.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=s}_postMessageToLoopWorker(e,t){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,Pe,e.dts,!1,0)}_doDecodeVideo(e){const t=new Uint8Array(e.payload);let i=null;i=e.isHevc?Go(t,e.isIFrame):xo(t,e.isIFrame),this.player.updateStats({dts:e.dts});const s=e.pts-e.dts;this._doDecodeByHls(i,Be,e.dts,e.isIFrame,s)}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 py{constructor(e,t){this.hls=e,this.player=this.hls.player,this.isMP4=t,this._initSegmentId="",this.TAG_NAME="HlsTransmuxer",this.hlsV2Mp4NotSupport=!1,this._demuxer=t?new uy(this.hls.player):new qg(this.hls.player),this.player.debug.log(this.TAG_NAME,`init and isMP4 is ${t}`)}destroy(){this.hlsV2Mp4NotSupport=!1,this._demuxer&&(this._demuxer.destroy(),this._demuxer=null)}transmux(e,t,i,s,r,a){this.player.debug.log(this.TAG_NAME,`transmux videoChunk:${e&&e.byteLength}, audioChunk:${t&&t.byteLength}, discontinuity:${i}, contiguous:${s}, startTime:${r}, needInit:${a}`);const o=this._demuxer;try{this.isMP4?o.demux(e,t):o.demuxAndFix(Wg(e,t),i,s,r)}catch(e){throw new Ag(yg,gg,e)}}}class fy{constructor(e){this.hls=e,this.player=e.player,this._decryptor=new Hg(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(){var e,t;return null===(e=this._transmuxer)||void 0===e||null===(t=e._demuxer)||void 0===t?void 0:t._baseDts}get nbSb(){return 0}async updateDuration(e){this.player.debug.log(this.TAG_NAME,"updateDuration()",e)}getBuferredDuration(){var e,t;return null===(e=this._transmuxer)||void 0===e||null===(t=e._demuxer)||void 0===t?void 0:t.getBuferredDuration()}getBufferedSegments(){var e,t;return null===(e=this._transmuxer)||void 0===e||null===(t=e._demuxer)||void 0===t?void 0:t.getSampleListLength()}getBufferedAudioSegments(){var e,t;return null===(e=this._transmuxer)||void 0===e||null===(t=e._demuxer)||void 0===t?void 0:t.getSampleAudioListLength()}getBufferedVideoSegments(){var e,t;return null===(e=this._transmuxer)||void 0===e||null===(t=e._demuxer)||void 0===t?void 0:t.getSampleVideoListLength()}createSource(e,t,i,s){if(this._sourceCreated)return;const r=e||t;r&&(qg.probe(r)?this._transmuxer||(this._transmuxer=new py(this.hls,!1)):cy.probe(r)?this._transmuxer||(this._transmuxer=new py(this.hls,!0)):this.player.debug.error(this.TAG_NAME,"createSource error: chunk is not ts"))}async appendBuffer(e,t,i,s,r,a,o){if(null!=i&&i.length||null!=s&&s.length)return this._needInitSegment,this._transmuxer.transmux(i,s,r,a,o,this._needInitSegment||r),!0}async clearAllBuffer(){this.player.debug.log(this.TAG_NAME,"clearAllBuffer")}decryptBuffer(e,t){return this._decryptor.decrypt(e,t)}async reset(){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 my{constructor(e){this.emitter=e,this._seiSet=new Set,e.on(Ts,(e=>{e&&this._seiSet.add(e)}))}throw(e){if(null==e||!this._seiSet.size)return;const t=e-.2,i=e+.2,s=[];this._seiSet.forEach((e=>{e.time>=t&&e.time<=i&&s.push(e)})),s.forEach((e=>{this._seiSet.delete(e),this.emitter.emit(Es,e)}))}reset(){this._seiSet.clear()}}class gy{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(e){var t;let{data:i}=e;const s=null==i||null===(t=i.onMetaData)||void 0===t?void 0:t.framerate;s&&s>0&&s<100&&(this.fps=s)}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 yy{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;Ol(this,"_core",null),Ol(this,"_samples",[]),this._core=e,this._timescale=t,this._stats=new gy(t),this._bindEvents()}getStats(){var e,t,i,s,r,a,o;const{currentTime:n=0,decodeFps:l=0}=(null===(e=this._core)||void 0===e?void 0:e.media)||{};return{...this._stats.getStats(),downloadSpeed:(null===(t=this._core)||void 0===t||null===(i=t.speedInfo)||void 0===i?void 0:i.call(t).speed)||0,avgSpeed:(null===(s=this._core)||void 0===s||null===(r=s.speedInfo)||void 0===r?void 0:r.call(s).avgSpeed)||0,currentTime:n,bufferEnd:(null===(a=this._core)||void 0===a||null===(o=a.bufferInfo())||void 0===o?void 0:o.remaining)||0,decodeFps:l}}_bindEvents(){this._core.on(ms,(e=>this._stats.updateBitrate(e.samples))),this._core.on(gs,(e=>{this._stats.setFpsFromScriptData(e)})),this._core.on(ys,(e=>{"video"===e.type?this._stats.setVideoMeta(e.track):this._stats.setAudioMeta(e.track)})),this._core.on(As,(e=>{this._stats.setDomain(e.responseUrl)}))}reset(){this._samples=[],this._stats=new gy(this._timescale)}}class Ay extends t{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),Ol(this,"_loadSegment",(async()=>{if(this.player.debug.log(this.TAG_NAME,"_loadSegment()","_segmentProcessing",this._segmentProcessing),this._segmentProcessing)return void this.player.debug.warn("_loadSegment()","_segmentProcessing is ture and return");const e=this._playlist.currentSegment,t=this._playlist.nextSegment;if(this.player.debug.log(this.TAG_NAME,"_loadSegment()","curSeg",e,"nextSeg",t),t)return this._loadSegmentDirect();this.player.debug.log(this.TAG_NAME,"nextSeg is null and return")})),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 Ng(this),this._segmentLoader=new Gg(this),this._playlist=new $g(this),this._bufferService=new fy(this),this._seiService=new my(this),this._stats=new yy(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._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(){var e;return null===(e=this._bufferService)||void 0===e?void 0:e.baseDts}speedInfo(){return this._segmentLoader.speedInfo()}getStats(){return this._stats.getStats()}async loadSource(e){return this.player.debug.log(this.TAG_NAME,`loadSource() ${e}`),await this._reset(),await this._loadData(e),this._startTick(),!0}async _loadData(e){this.player.debug.log(this.TAG_NAME,`_loadData() ${e}`);try{e&&(e=e.trim())}catch(e){}if(!e)throw this._emitError(new Ag(fg,fg,null,null,"m3u8 url is missing"));const t=await this._loadM3U8(e),{currentStream:i}=this._playlist;if(this._urlSwitching){var s,r;if(0===i.bitrate&&null!==(s=this._switchUrlOpts)&&void 0!==s&&s.bitrate)i.bitrate=null===(r=this._switchUrlOpts)||void 0===r?void 0:r.bitrate;const e=this._getSeamlessSwitchPoint();this.config.startTime=e;const t=this._playlist.findSegmentIndexByTime(e),a=this._playlist.getSegmentByIndex(t+1);if(a){const e=a.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;this.player.debug.log(this.TAG_NAME,`load m3u8: ${e}`);try{[t]=await this._manifestLoader.load(e)}catch(e){throw this._emitError(Ag.create(e))}if(t){var i;if(this._playlist.upsertPlaylist(t),t.isMaster)null!==(i=this._playlist.currentStream.subtitleStreams)&&void 0!==i&&i.length&&this.emit(xs,{list:this._playlist.currentStream.subtitleStreams}),await this._refreshM3U8();else this.player.debug.warn(this.TAG_NAME,"_loadM3U8() is not master playlist");return this.emit(Rs),t}this.player.debug.warn(this.TAG_NAME,"_loadM3U8() playlist is empty")}_refreshM3U8(){var e,t;this.player.debug.log(this.TAG_NAME,"_refreshM3U8()");const i=this._playlist.currentStream;if(!i||!i.url)throw this._emitError(Ag.create(null,null,new Error("m3u8 url is not defined")));const s=i.url,r=null===(e=i.currentAudioStream)||void 0===e?void 0:e.url,a=null===(t=i.currentSubtitleStream)||void 0===t?void 0:t.url;return this._manifestLoader.load(s,r,a).then((e=>{let[t,i,o]=e;t?(this._playlist.upsertPlaylist(t,i,o),this.isLive&&this._pollM3U8(s,r,a)):this.player.debug.warn(this.TAG_NAME,"_refreshM3U8() mediaPlaylist is empty")})).catch((e=>{throw this._emitError(Ag.create(e))}))}_pollM3U8(e,t,i){var s;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(Ag.create(e))}),1e3*((null===(s=this._playlist.lastSegment)||void 0===s?void 0:s.duration)||0))}async _loadSegmentDirect(){this.player.debug.log(this.TAG_NAME,"_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(Ag.create(i)):(t?(this._urlSwitching&&(this._urlSwitching=!1,this.emit(Cs,{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,s=this._prevSegCc!==i;let r=[];try{r=await this._segmentLoader.load(e,t,s)}catch(e){throw e.fatal=!1,this._segmentLoader.error=e,e}if(!r[0])return;const a=await this._bufferService.decryptBuffer(...r);if(!a)return void this.player.debug.log(this.TAG_NAME,"decryptBuffer return null");const o=e?e.sn:t.sn,n=e?e.start:t.start,l=this._playlist.currentStream;return this._bufferService.createSource(a[0],a[1],null==l?void 0:l.videoCodec,null==l?void 0:l.audioCodec),await this._bufferService.appendBuffer(e,t,a[0],a[1],s,this._prevSegSn===o-1,n),this._prevSegCc=i,this._prevSegSn=o,!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(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];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){var t;let i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var s;!1===(null===(t=e.originError)||void 0===t?void 0:t.fatal)?console.warn(e):(console.table(e),console.error(e),console.error(null===(s=this.media)||void 0===s?void 0:s.error),this._stopTick(),this._urlSwitching&&(this._urlSwitching=!1,this.emit(ks,e)),i&&this._end(),this._seiService.reset(),this.emit(Ds,e));return e}_getSeamlessSwitchPoint(){const{media:e}=this;let t=e.currentTime;if(!e.paused){var i;const s=this._playlist.findSegmentIndexByTime(e.currentTime),r=this._playlist.getSegmentByIndex(s),a=null===(i=this._stats)||void 0===i?void 0:i.getStats().downloadSpeed;if(a&&r){t+=r.duration*this._playlist.currentStream.bitrate/a+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 by extends t{constructor(e){super(),Ol(this,"TAG_NAME","Hls256Decoder"),this.player=e,this.$videoElement=this.player.video.$videoElement,this.hls=null,this.eventsDestroy=[],this.bandwidthEstimateInterval=null,this.hls=new Ay(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(Ds,(e=>{this.player.emitError(it.hlsError,e)})),this._startBandwidthEstimateInterval()}_startBandwidthEstimateInterval(){this._stopBandwidthEstimateInterval(),this.bandwidthEstimateInterval=setInterval((()=>{const e=this.hls.speedInfo();this.player.emit(Ze.kBps,(e.avgSpeed/1024/8).toFixed(2))}),1e3)}_stopBandwidthEstimateInterval(){this.bandwidthEstimateInterval&&(clearInterval(this.bandwidthEstimateInterval),this.bandwidthEstimateInterval=null)}async loadSource(e){return this.player.debug.log(this.TAG_NAME,`loadSource() ${e}`),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 vy 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.player._opt.webrtcUseCanvasRender&&this.isH264&&(this.$videoElement=document.createElement("video"),_r()&&(this.$videoElement.style.position="absolute"),this._initVideoEvents()),this.$videoElement.muted=!0,this._initRtcPeerConnection()}destroy(){this.isDisconnected=!1,this.isInitInfo=!1,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=rr,this.rtcPeerConnection.ontrack=rr,this.rtcPeerConnection.onconnectionstatechange=rr,this.rtcPeerConnection.ondatachannel=rr,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,ki,(()=>{this.player.debug.log("HlsDecoder","video waiting")})),s=e(this.$videoElement,Ci,(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)})))})),r=e(this.$videoElement,xi,(()=>{this.player.debug.log("HlsDecoder","video playback Rate change",this.$videoElement&&this.$videoElement.playbackRate)}));this.eventsDestroy.push(t,i,s,r)}_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 s=e.iceConnectionState;switch(this.player.emit(Ze.webrtcOnIceConnectionStateChange,s),this.isDisconnected="disconnected"===s,e.iceConnectionState){case"new":case"checking":case"closed":case"connected":case"completed":break;case"failed":t.emit(Ze.webrtcFailed);break;case"disconnected":t.emit(Ze.webrtcDisconnect);break;case"closed":t.emit(Ze.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=e=>{if(this.player.debug.log(this.TAG_NAME,"ontrack",e),"video"===e.track.kind){this.player.debug.log(this.TAG_NAME,"ontrack audio");let t=e.streams[0];this.$videoElement.autoplay=!0,this.$videoElement.srcObject=t,this.videoStream=t}},e.onicecandidateerror=e=>{this.player.debug.log(this.TAG_NAME,"onicecandidateerror",e),this.player.emitError(it.webrtcIceCandidateError,e)},e.onconnectionstatechange=i=>{switch(this.player.debug.log(this.TAG_NAME,"onconnectionstatechange",i),this.player.emit(Ze.webrtcOnConnectionStateChange,e.connectionState),e.connectionState){case"new":case"connecting":case"connected":case"disconnected":break;case"failed":this.isDisconnected&&t.emit(Ze.webrtcFailed)}},this.rtcPeerConnection=e}_startCanvasRender(){wa()?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){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.player.isDestroyed()?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 _y extends vy{constructor(e){super(e),this.rtcPeerConnectionDataChannel=null,this.player.isWebrtcH265()&&(this.streamRate=pr((t=>{e.emit(Ze.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=rr,this.rtcPeerConnectionDataChannel.onclose=rr,this.rtcPeerConnectionDataChannel.onmessage=rr,this.rtcPeerConnectionDataChannel.close(),this.rtcPeerConnectionDataChannel=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 s=e.iceConnectionState;switch(this.player.emit(Ze.webrtcOnIceConnectionStateChange,s),this.isDisconnected="disconnected"===s,e.iceConnectionState){case"new":case"checking":case"closed":case"connected":case"completed":break;case"failed":t.emit(Ze.webrtcFailed);break;case"disconnected":t.emit(Ze.webrtcDisconnect);break;case"closed":t.emit(Ze.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=e=>{this.player.debug.log(this.TAG_NAME,"ontrack",e);const i=t.video.$videoElement;if("video"===e.track.kind&&t.isWebrtcH264()){let t=e.streams[0];i.autoplay=!0,i.srcObject=t,this.videoStream=t}},e.onicecandidateerror=e=>{this.player.debug.log(this.TAG_NAME,"onicecandidateerror",e),this.player.emitError(it.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(Ze.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(Ze.webrtcStreamH265);this.player.isDestroyed()?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){return new Promise(((t,i)=>{const s=this.rtcPeerConnection;s.createOffer().then((r=>{s.setLocalDescription(r),this.player.debug.log(this.TAG_NAME,"getWebRtcRemoteSdp loadSource"),function(e,t){return fetch(e,{method:"POST",mode:"cors",cache:"no-cache",credentials:"include",redirect:"follow",referrerPolicy:"no-referrer",headers:{"Content-Type":"application/sdp"},body:t})}(e,r.sdp).then((e=>{e.text().then((e=>{this.player.debug.log(this.TAG_NAME,"getWebRtcRemoteSdp response"),s.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:e})).then((()=>{this.player.isWebrtcH265()&&this.startStreamRateInterval(),t()})).catch((e=>{i(e)}))})).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 wy extends vy{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 s=this.rtcPeerConnection;s.createOffer().then((r=>{s.setLocalDescription(r),this.player.debug.log(this.TAG_NAME,"getWebRtcRemoteSdp loadSource"),function(e,t){return bn({url:e,type:"POST",data:t,contentType:"text/plain;charset=utf-8",processData:!1,dataType:"json"})}(e,r.sdp).then((e=>{this.player.debug.log(this.TAG_NAME,`getWebRtcRemoteSdp response and code is ${e.code}`);const r=e;if(0!==r.code)return i(r.msg);s.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:r.sdp})).then((()=>{t()})).catch((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 Sy extends t{constructor(e,t){if(super(),this.player=e,this.player.$container.classList.add("jessibuca-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=!!pa(t.isUseFpsRender),this._rate=1,this._audioTimestamp=0,this._videoTimestamp=0,this.controlType=t.controlType||K.normal,t.controlType&&-1===[K.normal,K.simple].indexOf(t.controlType)&&(this.player.debug.warn("Playback","constructor()","controlType is not in [normal,simple]",t.controlType),this.controlType=K.normal),this._currentLocalTimestamp=0,this._localOneFrameTimestamp=t.localOneFrameTimestamp||40,this._localCalculateTimeInterval=null,this._isUseLocalCalculateTime=!!pa(t.isUseLocalCalculateTime),this._isPlaybackPauseClearCache=!fa(t.isPlaybackPauseClearCache),this._isCacheBeforeDecodeForFpsRender=!!pa(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===K.normal)this.initPlaybackList(t.playList,t.showPrecision,t.startTime);else if(t.controlType===K.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(Ze.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("jessibuca-container-playback"),this.off(),this.player.debug.log("Playback","destroy")}_listen(){this.player.on(Ze.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(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._startFpsTimestamp||(this._startFpsTimestamp=lr()),Fr(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=lr(),i=t-this._startFpsTimestamp;if(i<1e3)return;let s=null;this._startfpsTime&&(s=this._playbackTs-this._startfpsTime),this.player.emit(Ze.playbackStats,{fps:this._renderFps,rate:this.rate,start:this._startfpsTime,end:this._playbackTs,timestamp:i,dataTimestamp:s,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 s=0;if(this.playbackList.forEach(((e,t)=>{10===Hr(e.start)&&(e.startTimestamp=1e3*e.start,e.startTime=wr(e.startTimestamp)),10===Hr(e.end)&&(e.endTimestamp=1e3*e.end,e.endTime=wr(e.endTimestamp)),e.duration=e.end-e.start,s+=e.duration})),this._totalDuration=s,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===Hr(i)&&(i*=1e3),this._isTimeInPlaybackList(i)&&(t=i)),this.setStartTime(t)}const r=t||ii;this.setShowPrecision(r)}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(Ze.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===si}get is10Min(){return this.showPrecision===ri}get is5Min(){return this.showPrecision===ai}get is1Min(){return this.showPrecision===ai}get isPlaybackPauseClearCache(){return this._isPlaybackPauseClearCache}get isCacheBeforeDecodeForFpsRender(){return this._isCacheBeforeDecodeForFpsRender}setShowPrecision(e){ni.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(Ze.playbackPrecision,this._showPrecision,this.playbackList),this.player.emit(Ze.playbackShowPrecisionChange,this._showPrecision))}setPlayingTimestamp(e){let t;if(this.controlType===K.normal){t=this.startTime+e,this._playingTimestamp=t,this.player.emit(Ze.playbackTime,t);const i=new Date(t);this.player.emit(Ze.playbackTimestamp,{ts:t,hour:i.getHours(),min:i.getMinutes(),second:i.getSeconds()})}else this.controlType===K.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),this._playingTimestamp=t,this.player.emit(Ze.playbackTime,t),this.player.emit(Ze.playbackTimestamp,{ts:t}))}get playingTimestamp(){return this._playingTimestamp}narrowPrecision(){const e=ni.indexOf(this.showPrecision)-1;if(e>=0){const t=ni[e];this.setShowPrecision(t)}}expandPrecision(){const e=ni.indexOf(this.showPrecision)+1;if(e<=ni.length-1){const t=ni[e];this.setShowPrecision(t)}}seek(e){if(this.player.debug.log("Playback","seek()",e),this.controlType===K.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(Ze.playbackSeek,i)}}else if(this.controlType===K.simple){let t=e.time;this.player.emit(Ze.playbackSeek,{ts:t})}}currentTimeScroll(){this.player.emit(Ze.playbackTimeScroll)}_findMoreInfoByTimestamp(e){let t=null;return this.playbackList.forEach(((i,s)=>{i.startTimestamp<=e&&i.endTimestamp>=e&&(t=i)})),t}_isTimeInPlaybackList(e){let t=!1;return this.playbackList.forEach(((i,s)=>{i.startTimestamp<=e&&i.endTimestamp>=e&&(t=!0)})),t}getControlType(){return this.controlType}isControlTypeNormal(){return this.controlType===K.normal}isControlTypeSimple(){return this.controlType===K.simple}}class Ty 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(Ze.zooming,(e=>{if(e){this.player.$container.classList.add("jessibuca-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 s=e.match(/scale\([0-9., ]*\)/g);if(s&&s[0]){let e=s[0].replace("scale(","").replace(")","");this.prevVideoElementStyleScale=e.split(",")}}else{this.player.$container.classList.remove("jessibuca-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,mr()&&this.player._opt.useWebFullScreen&&this.player.resize()}}));const s=t(window,mr()?"touchend":"mouseup",(e=>{this.handleMouseUp(e)}));this.bindEvents.push(s),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,mr()?"touchmove":"mousemove",(e=>{this.handleMouseMove(e)}));this.bindEvents.push(i);const s=e(this.player.$container,mr()?"touchstart":"mousedown",(e=>{this.handleMouseDown(e)}));this.bindEvents.push(s);const r=e(window,mr()?"touchend":"mouseup",(e=>{this.handleMouseUp(e)}));this.bindEvents.push(r)}_unbindEvents(){this.bindEvents.forEach((e=>{e&&e()}))}handleMouseMove(e){if(e.stopPropagation(),this.isDragging&&this.player.zooming){e.preventDefault();const{posX:t,posY:i}=Zr(e),s=this.tempPosition.x-t,r=this.tempPosition.y-i;this.videoPosition.left=this.videoPosition.left-s,this.videoPosition.top=this.videoPosition.top-r,this.tempPosition.x=t,this.tempPosition.y=i,this.updateVideoPosition()}}handleMouseDown(e){e.stopPropagation();const t=Yr(e);if(this.player.zooming&&(t.matches("video")||t.matches("canvas"))){e.preventDefault();const{posX:t,posY:i}=Zr(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,s=1;if(this.prevVideoElementStyleScale){const e=this.prevVideoElementStyleScale[0];void 0!==e&&(i=e,s=e);const t=this.prevVideoElementStyleScale[1];void 0!==t&&(s=t)}s=Tr(s),i=Tr(i);const r=.5*i*(this.currentZoom-1)+i,a=.5*s*(this.currentZoom-1)+s;let o;o=-1===t.indexOf("scale(")?t+` scale(${r},${a})`:t.replace(/scale\([0-9., ]*\)/,`scale(${r},${a})`),this.player.debug.log("zoom",`updateVideoElementScale end is ${r}, ${a} style is ${o}`),e.style.transform=o}}class Ey 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.JessibucaProFaceDetector){const e=new JessibucaProFaceDetector({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("jessibuca-pro-face-detector-info",(e=>{if(this.player.emit(Ze.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.JessibucaProObjectDetector){const e=new JessibucaProObjectDetector({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("jessibuca-pro-object-detector-info",(e=>{if(this.player.emit(Ze.aiObjectDetectorInfo,e),this.player._opt.aiObjectDetectShowRect){const t=[],i=this.player._opt.aiObjectDetectRectConfig||{};(e.list||[]).forEach((e=>{const s={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},r={type:"text",color:i.color||"#000",fontSize:i.fontSize||14,text:e.zh,x:e.rect.x,y:e.rect.y-25};t.push(s,r)})),this.player.video&&this.player.video.addAiContentToCanvas(t)}}))}))}}initImageDetector(){if(this.player._opt.useImageDetector&&window.JessibucaProImageDetector){const e=new JessibucaProImageDetector({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.JessibucaProOcclusionDetector){const e=new JessibucaProOcclusionDetector({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(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.faceDetector&&this.faceDetector.updateConfig(e)}updateObjectDetectorConfig(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.objectDetector&&this.objectDetector.updateConfig(e)}updateImageDetectorConfig(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.imageDetector&&this.imageDetector.updateConfig(e)}updateOcclusionDetectorConfig(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.occlusionDetector&&this.occlusionDetector.updateConfig(e)}}class ky extends t{constructor(e){super(),this.player=e,this.LOG_NAME="Contextmenu",this.menuList=[],this.$contextmenus=e.control.$contextmenus,mr()?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="jessibuca-contextmenus-show",e.classList.contains(t);var e,t}show(){var e,t;e=this.player.$container,t="jessibuca-contextmenus-show",e.classList.add(t)}hide(){var e,t;e=this.player.$container,t="jessibuca-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:s,width:r,left:a,top:o}=this.player.$container.getBoundingClientRect(),{height:n,width:l}=this.$contextmenus.getBoundingClientRect();let h=t-a,d=i-o;t+l>a+r&&(h=r-l),i+n>o+s&&(d=s-n),dr(this.$contextmenus,{left:`${h}px`,top:`${d}px`})})),e(this.player.$container,"click",(e=>{nh(e,this.$contextmenus)||this.hide()})),this.player.on(Ze.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(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=ha(os);if(e=Object.assign({},t,e),!this._validateMenuItem(e))return;const{events:{proxy:i},debug:s}=this.player,r=Er(),a=`\n <div class="jessibuca-contextmenu jessibuca-contextmenu-${r}">\n ${e.content}\n </div>\n `,o=Array.from(this.$contextmenus.children)[e.index];o?o.insertAdjacentHTML("beforebegin",a):ah(this.$contextmenus,a);const n=this.$contextmenus.querySelector(`.jessibuca-contextmenu-${r}`);e.click&&i(n,"click",(t=>{t.preventDefault(),e.click.call(this.player,this,t),this.hide()})),this.menuList.push({uuid:r,$menuItem:n})}}class Cy extends vy{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 s=this.rtcPeerConnection;s.createOffer().then((r=>{s.setLocalDescription(r),this.player.debug.log(this.TAG_NAME,"getWebRtcRemoteSdp loadSource"),function(e,t){return fetch(e,{method:"POST",mode:"cors",cache:"no-cache",credentials:"include",redirect:"follow",referrerPolicy:"no-referrer",headers:{"Content-Type":"application/sdp"},body:t})}(e,r.sdp).then((e=>{this.player.debug.log(this.TAG_NAME,`getWebRtcRemoteSdp response and code is ${e.code}`);const r=e;if(0!==r.code)return i(r.msg);s.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:r})).then((()=>{t()})).catch((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 xy extends vy{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 s=this.rtcPeerConnection;s.createOffer().then((r=>{s.setLocalDescription(r),this.player.debug.log(this.TAG_NAME,"getWebRtcRemoteSdp loadSource"),function(e,t){return fetch(e,{method:"POST",mode:"cors",cache:"no-cache",credentials:"include",redirect:"follow",referrerPolicy:"no-referrer",headers:{"Content-Type":"application/sdp"},body:t})}(e,r.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"),s.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:e})).then((()=>{t()})).catch((e=>{i(e)}))})).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 Ry 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=>{if(this.player.debug.error(this.TAG_NAME,`onError and code is ${e.errorCode} and message: ${e.message}`),10410===e.errorCode)this.player.debug.log(this.TAG_NAME,"onError and code is 10410 and message: ",e.message,"and emit aliyunRtcError"),this.player.emit(it.aliyunRtcError,e)})),this.aliyunRtc.on("reconnect",(e=>{this.player.debug.log(this.TAG_NAME,"reconnect",e)}));const e="canplay",t="waiting",i="playing",s="media";this.aliyunRtc.on("onPlayEvent",(r=>{if(r.event===e)this.player.debug.log(this.TAG_NAME,"onPlayEvent and canplay");else if(r.event===t)this.player.debug.log(this.TAG_NAME,"onPlayEvent and playing - > waiting");else if(r.event===i)this.player.debug.log(this.TAG_NAME,"onPlayEvent and waiting -> playing");else if(r.event===s){const e=r.data;let t={},i=0;if(e.audio){const s=parseInt(e.audio.bytesReceivedPerSecond,10);i+=s,t.abps=s}if(e.video){const s=parseInt(e.video.bytesReceivedPerSecond,10);i+=s,t.vbps=s}this.player.updateStats(t),this.player.emit(Ze.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 Dy{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(){fa(Sa())?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(Ze.pressureObserverCpu,this.currentLevel)}})),this.observer&&this.observer.observe("cpu"))}}class Ly extends Ba{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};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(Ze.start,(()=>{const e=fa(false)?decodeURIComponent("JessibucaPro%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(),s={width:0,height:0};const r=()=>{try{if(fa(this.isPauseAnimation)&&this.shadowRootDynamicDom&&this.shadowRootInnerDom){const a=this.shadowRootInnerDom,o=this.shadowRootDynamicDom,n=a.getBoundingClientRect(),l=o.getBoundingClientRect();if(l.width&&l.height&&(s.width=l.width,s.height=l.height),!this.shadowRootInnerDom.contains(this.shadowRootDynamicDom))return this.isGhost?fa(this.waterMarkWillAdd)&&(this.waterMarkWillAdd=!0,setTimeout((()=>{this._addDom(n,s),this.waterMarkWillAdd=!1}),1e3*this.ghostConfig.off)):this._addDom(n,s),void(0!==this.speed&&requestAnimationFrame(r));const h=Math.min(1,0===this.speed?0:this.speed?this.speed:.2);let d=l.left-n.left,c=l.top-n.top;d+=h*t*i,c+=h*e*(1-i),d+s.width>n.width?(t=-1,i=Math.random()):d<0&&(t=1,i=Math.random()),c+s.height>n.height?(e=-1,i=Math.random()):c<0&&(e=1,i=Math.random()),d=Math.min(n.width-s.width,d),c=Math.min(n.height-s.height,c);const u=d/n.width*100,p=c/n.height*100;this.shadowRootDynamicDom.style.left=`${u}%`,this.shadowRootDynamicDom.style.top=`${p}%`,fa(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(r)};this.rafID=requestAnimationFrame(r)}}_addDom(e,t){if(this.shadowRootInnerDom&&this.shadowRootDynamicDom){this.shadowRootInnerDom.appendChild(this.shadowRootDynamicDom);let i=e.width*Math.random(),s=e.height*Math.random();i=Math.min(e.width-2*t.width,i),s=Math.min(e.height-2*t.height,s),this.shadowRootDynamicDom.style.left=`${i}px`,this.shadowRootDynamicDom.style.top=`${s}px`}}resumeAnimation(){this.isPauseAnimation=!1}pauseAnimation(){this.isPauseAnimation=!0}stopAnimation(){this.isStopAnimation=!0}}class Iy extends t{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),this._opt={},this.TAG_NAME="Player",this.$container=e;const i=ca();if(this._opt=Object.assign({},i,t),this.debug=new Gs(this),this._opt.forceNoOffscreen=!0,this._canPlayAppleMpegurl=!1,(_r()||vr())&&(this._canPlayAppleMpegurl=ea(),this.debug.log(this.TAG_NAME,"isIOS or isSafari and canPlayAppleMpegurl",this._canPlayAppleMpegurl)),mr()&&(this._opt.controlAutoHide=!1),Aa()&&(this.debug.log(this.TAG_NAME,"isIphone and set _opt.videoRenderSupportScale false"),this._opt.videoRenderSupportScale=!1),fa(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.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.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=v),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=Dr();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=Lr()&&Ir(),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 window&&window.MediaSource.isTypeSupported(Kt)&&(e=!0),e}(),t=Rr();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(fa(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),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=Aa();this._opt.useSIMD=e&&fa(t),this._opt.useSIMD||this.debug.warn(this.TAG_NAME,`useSIMD is true, but not support(isSupportSimd is ${e} ,isIphone is ${t}) so set useSIMD false`)}var s;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.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.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.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")),fa(this._opt.hasAudio)&&(this._opt.operateBtns.audio=!1),fa(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")),pa(this._opt.useWebGPU)&&(this._opt.useWebGPU=function(){let e=!1;return"gpu"in navigator&&(e=!0),e}(),fa(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._visibility=!0,this._lastestVisibilityChangeTimestamp=null,this._tempWorkerStats=null,this._historyFpsList=[],this._tempStreamList=[],this._tempInnerPlayBgobj=null,this._flvMetaData=null,this._flvMetaDataFps=null,fa(this._opt.useMSE)&&fa(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=Sr()&&Lr()&&Ir(),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.JessibucaProFaceDetector||this._opt.useObjectDetector&&window.JessibucaProObjectDetector||this._opt.useOcclusionDetector&&window.JessibucaProOcclusionDetector||this._opt.useImageDetector&&window.JessibucaProImageDetector)?(this.ai=new Ey(this),this._opt.useFaceDetector&&window.JessibucaProFaceDetector||(this._opt.operateBtns.aiFace=!1),this._opt.useObjectDetector&&window.JessibucaProObjectDetector||(this._opt.operateBtns.aiObject=!1),this._opt.useOcclusionDetector&&window.JessibucaProOcclusionDetector||(this._opt.operateBtns.aiOcclusion=!1),this._opt.useImageDetector&&this._opt.aiImageDetectActive&&window.JessibucaProImageDetector&&(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.JessibucaProFaceDetector||this.debug.warn(this.TAG_NAME,`use face detector, useWasm is ${this._opt.useWasm} and window.JessibucaProFaceDetector is null`)),this._opt.useObjectDetector&&(this._opt.useWasm&&window.JessibucaProObjectDetector||this.debug.warn(this.TAG_NAME,`use object detector, useWasm is ${this._opt.useWasm} and window.JessibucaProObjectDetector is null`)),this._opt.useOcclusionDetector&&(this._opt.useWasm&&window.JessibucaProOcclusionDetector||this.debug.warn(this.TAG_NAME,`use occlusion detector, useWasm is ${this._opt.useWasm} and window.JessibucaProOcclusionDetector is null`)),this._opt.useImageDetector&&(this._opt.useWasm&&window.JessibucaProImageDetector||this.debug.warn(this.TAG_NAME,`use image detector, useWasm is ${this._opt.useWasm} and window.JessibucaProImageDetector is null`)),this._opt.useVideoRender&&(this._opt.useWasm&&!this._opt.useOffscreen?(this._opt.wasmUseVideoRender=Sr()&&Lr()&&Ir(),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=Lr()&&Ir(),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&&(this._opt.mseUseCanvasRender=!0),this._opt.useWasm&&(this._opt.wasmUseVideoRender=!1),this._opt.useWCS&&(this._opt.wcsUseVideoRender=!1),this.isOldHls()&&!_r()&&(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),s=this,Object.defineProperty(s,"rect",{get:()=>{let e={};return s.$container&&(e=s.$container.getBoundingClientRect(),e.width=Math.max(e.width,s.$container.clientWidth),e.height=Math.max(e.height,s.$container.clientHeight)),e}}),["bottom","height","left","right","top","width"].forEach((e=>{Object.defineProperty(s,e,{get:()=>s.rect[e]||0})})),this.events=new Ta(this),this._opt.hasVideo&&(this.video=new Ja(this),this.recorder=new Zo(this)),this.isOldHls()?(this.hlsDecoder=new Vm(this),this.loaded=!0):this.isWebrtcH264()?(this._opt.isWebrtcForZLM?this.webrtc=new wy(this):this._opt.isWebrtcForSRS?this.webrtc=new Cy(this):this._opt.isWebrtcForOthers?this.webrtc=new xy(this):this.webrtc=new _y(this),this.loaded=!0):this.isAliyunRtc()?(this.aliyunRtcDecoder=new Ry(this),this.loaded=!0):(this.isUseHls265()&&(this.hlsDecoder=new by(this)),this.isWebrtcH265()&&(this.webrtc=new _y(this)),fa(ta(this._opt))?this.decoderWorker=new on(this):this.loaded=!0),this._opt.hasAudio&&(this.audio=new po(this)),this.stream=null,this.demux=null,this._lastVolume=null,this._isInZoom=!1,this._playingStartTimestamp=null,this._opt.useWCS&&(this.webcodecsDecoder=new Kl(this),!this._opt.hasAudio&&fa(this._opt.demuxUseWorker)&&(this.loaded=!0)),this._opt.useMSE&&(this.mseDecoder=new bh(this),!this._opt.hasAudio&&fa(this._opt.demuxUseWorker)&&(this.loaded=!0)),this.control=new ch(this),this._opt.contextmenuBtns.length>0&&gr()&&(this.contextmenu=new ky(this)),this.isPlayback()&&(this.playback=new Sy(this,this._opt.playbackConfig)),this._opt.operateBtns.zoom&&(this.zoom=new Ty(this)),/(iphone|ipad|ipod|ios|android)/i.test(window.navigator.userAgent.toLowerCase())&&fa(this._opt.supportLockScreenPlayAudio&&vr())&&(this.keepScreenOn=new _h(this)),(e=>{try{const t=t=>{Yr(t)===e.$container&&(e.emit(et.fullscreen,e.fullscreen),e.fullscreen?e._opt.useMSE&&e.resize():e.resize())};Ws.on("change",t),e.events.destroys.push((()=>{Ws.off("change",t)}))}catch(e){}if(e.on(Ze.decoderWorkerInit,(()=>{e.debug.log("player","listen decoderWorkerInit and set loaded true"),e.loaded=!0})),e.on(Ze.play,(()=>{e.loading=!1})),e.on(Ze.fullscreen,(t=>{if(t)try{Ws.request(e.$container).then((()=>{})).catch((t=>{e.debug.error("player","fullscreen request error",t),mr()&&e._opt.useWebFullScreen&&(e.webFullscreen=!0)}))}catch(t){mr()&&e._opt.useWebFullScreen&&(e.webFullscreen=!0)}else try{Ws.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)}})),mr()&&e.on(Ze.webFullscreen,(t=>{t?e.$container.classList.add("jessibuca-fullscreen-web"):e.$container.classList.remove("jessibuca-fullscreen-web"),e.emit(et.fullscreen,e.fullscreen)})),e.on(Ze.resize,(()=>{e.video&&e.video.resize()})),e._opt.debug){const t=[Ze.timeUpdate,Ze.currentPts,Ze.videoSEI],i=[Ze.stats,Ze.playbackStats,Ze.playbackTimestamp,Ze.flvMetaData,Ze.playToRenderTimes,Ze.audioInfo,Ze.videoInfo];Object.keys(Ze).forEach((s=>{e.on(Ze[s],(function(r){if(!t.includes(s)){i.includes(s)&&(r=JSON.stringify(r));for(var a=arguments.length,o=new Array(a>1?a-1:0),n=1;n<a;n++)o[n-1]=arguments[n];e.debug.log("player events",Ze[s],r,...o)}}))})),Object.keys(it).forEach((t=>{e.on(it[t],(function(){for(var i=arguments.length,s=new Array(i),r=0;r<i;r++)s[r]=arguments[r];e.debug.warn("player event error",it[t],...s)}))}))}})(this),(e=>{const{_opt:t,debug:i,events:{proxy:s}}=e;if(t.supportDblclickFullscreen&&s(e.$container,"dblclick",(t=>{const i=Yr(t).nodeName.toLowerCase();"canvas"!==i&&"video"!==i||(e.fullscreen=!e.fullscreen)})),s(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()))})),gr()&&s(document,["click","contextmenu"],(t=>{nh(t,e.$container)?(e.isInput="INPUT"===t.target.tagName,e.isFocus=!0,e.emit(Ze.focus)):(e.isInput=!1,e.isFocus=!1,e.emit(Ze.blur))})),t.autoResize){const t=kr((()=>{e.resize()}),500);s(window,["resize","orientationchange"],(()=>{t()})),screen&&screen.orientation&&screen.orientation.onchange&&s(screen.orientation,"change",(()=>{t()}))}})(this),this.singleWatermark=new Ba(this),this._opt.ghostWatermarkConfig.content){const e=Object.assign({},this._opt.ghostWatermarkConfig,{isGhost:!0});this.ghostWatermark=new Ly(this,e)}this._opt.dynamicWatermarkConfig.content&&(this.dynamicWatermark=new Ly(this,this._opt.dynamicWatermarkConfig)),this._opt.watermarkConfig&&this.updateWatermark(this._opt.watermarkConfig),Sa()&&(this.pressureObserverCpu=new Dy(this)),this._opt.useWCS&&this.debug.log(this.TAG_NAME,"use WCS"),this._opt.useMSE&&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.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.debug.log("play","destroy end"),this._opt=ca(),this.$container=null}set fullscreen(e){mr()&&this._opt.useWebFullScreen?this.webFullscreen=e:this.emit(Ze.fullscreen,e)}get fullscreen(){return Ws.isFullscreen||this.webFullscreen}set webFullscreen(e){this.emit(Ze.webFullscreen,e),setTimeout((()=>{this.updateOption({rotate:e?270:0}),this.resize()}),10)}get webFullscreen(){return this.$container.classList.contains("jessibuca-fullscreen-web")}set loaded(e){this._hasLoaded=e}get loaded(){return this._hasLoaded||this.isOldHls()||this.isWebrtcH264()||this._opt.useMSE&&fa(this._opt.hasAudio)&&fa(this._opt.demuxUseWorker)||this._opt.useWCS&&!this._opt.hasAudio&&fa(this._opt.demuxUseWorker)}set playing(e){this.isClosed()&&e?this.debug.log(this.TAG_NAME,"player is closed, so can not play"):(e&&pa(this.loading)&&(this.loading=!1),this.playing!==e&&(this._playing=e,this.emit(Ze.playing,e),this.emit(Ze.volumechange,this.volume),e?this.emit(Ze.play):this.emit(Ze.pause)))}get playing(){return this._playing}get volume(){return this.audio&&this.audio.volume||0}set volume(e){e!==this.volume&&(this.audio?(this.audio.setVolume(e),this._lastVolume=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(Ze.loading,this._loading))}get loading(){return this._loading}set zooming(e){this.zooming!==e&&(this.zoom||(this.zoom=new Ty(this)),this._zooming=e,this.emit(Ze.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(Ze.streamQualityChange,e))}get streamQuality(){return this._streamQuality}get isDebug(){return pa(this._opt.debug)}get scaleType(){const e=this._opt,t=e.isResize,i=e.isFullResize;let s=Mt;return fa(i)&&fa(t)?s=Mt:fa(i)&&pa(t)?s=Ft:pa(i)&&pa(t)&&(s=Ut),s}set visibility(e){this._visibility!==e&&(this._visibility=e,this.emit(Ze.visibilityChange,e),this._lastestVisibilityChangeTimestamp=lr(),e?this.clearVisibilityHiddenTimeout():this.startVisibilityHiddenTimeout())}get visibility(){return this._visibility}set playbackPause(e){this._playbackPause!==e&&(this._playbackPause=e,this.emit(Ze.playbackPause,e),this.emit(Ze.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(Ze.faceDetectActive,e))}get faceDetectActive(){return this._faceDetectActive}set objectDetectActive(e){this._objectDetectActive!==e&&(this._objectDetectActive=e,this.emit(Ze.objectDetectActive,e))}get objectDetectActive(){return this._objectDetectActive}set occlusionDetectActive(e){this._occlusionDetectActive!==e&&(this._occlusionDetectActive=e,this.emit(Ze.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()===f}isDestroyed(){return this._destroyed}isClosed(){return this._closed}isPlaying(){let e=!1;return this._opt.playType===g?e=this.playing:this._opt.playType===A&&(e=fa(this.playbackPause)&&this.playing),e}updateOption(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._opt=Object.assign({},this._opt,e),pa(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 Ja(this)),this.audio||this._opt.hasAudio&&(this.audio=new po(this)),this.stream||(this.stream=new _o(this)),this.isOldHls()?(this.hlsDecoder||(this.hlsDecoder=new Vm(this),this.loaded=!0),e()):this.isWebrtcH264()?(this.webrtc||(this._opt.isWebrtcForZLM?this.webrtc=new wy(this):this._opt.isWebrtcForSRS?this.webrtc=new Cy(this):this._opt.isWebrtcForOthers?this.webrtc=new xy(this):this.webrtc=new _y(this),this.loaded=!0),e()):this.isAliyunRtc()?(this.aliyunRtcDecoder||(this.aliyunRtcDecoder=new Ry(this),this.loaded=!0),e()):(this.demux||this._opt.hasVideo&&!this.isUseWorkerDemuxAndDecode&&(this.demux=new Jl(this)),this._opt.useWCS&&(this.webcodecsDecoder||(this.webcodecsDecoder=new Kl(this))),this._opt.useMSE&&(this.mseDecoder||(this.mseDecoder=new bh(this))),this.isUseHls265()&&(this.hlsDecoder||(this.hlsDecoder=new by(this))),this.isWebrtcH265()&&(this.webrtc||(this.webrtc=new _y(this))),this.decoderWorker?this.loaded?e():this.once(Ze.decoderWorkerInit,(()=>{this.isDestroyed()?(this.debug.error(this.TAG_NAME,"init() failed and player is destroyed"),t("init() failed and player is destroyed")):(this.loaded=!0,e())})):ta(this._opt)?e():(this.decoderWorker=new on(this),this.once(Ze.decoderWorkerInit,(()=>{this.isDestroyed()?(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){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(((i,s)=>{if(!e&&!this._opt.url)return s("url is empty");this._closed=!1,this.loading=!0,this.playing=!1,this._times.playInitStart=lr(),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=lr(),this._opt.isNotMute&&this.mute(!1),this.enableWakeLock(),this.checkLoadingTimeout(),this.stream?(this.stream.once(it.fetchError,(e=>{this.emitError(it.fetchError,e)})),this.stream.once(it.websocketError,(e=>{this.emitError(it.websocketError,e)})),this.stream.once(Ze.streamEnd,(()=>{this.emit(Ze.streamEnd)})),this.stream.once(it.hlsError,(e=>{this.emitError(it.hlsError,e)})),this.stream.once(it.webrtcError,(e=>{this.emitError(it.webrtcError,e)})),this.stream.once(Ze.streamSuccess,(()=>{i(),this._times.streamResponse=lr(),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 destroy is ${this.isDestroyed()}`),s("this.stream is null"))})).catch((e=>{s(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.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(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];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,s)=>{this.recorder||s("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=>{s(e)}))):s("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.isPlayback()&&this._opt.playbackConfig.showControl&&(e=!0),e}useWasmDecode(){return fa(this._opt.useMSE)&&fa(this._opt.useWCS)}canVideoTrackWritter(){const e=this._opt;return!this.isOldHls()&&!this.isWebrtcH264()&&fa(e.useMSE)&&!this.isAliyunRtc()&&(e.useWCS&&fa(e.useOffscreen)&&e.wcsUseVideoRender||this.useWasmDecode())}checkHeartTimeout$2(){if(fa(this.playbackPause)&&this.playing){if(this.isDestroyed())return void(this.debug&&this.debug.warn(this.TAG_NAME,"checkHeartTimeout$2 but player is destroyed"));if(fa(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(fa(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(Ze.timeout,Ze.delayTimeout),this.emit(Ze.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.isDestroyed()?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(Ze.timeout,Ze.loadingTimeout),this.emit(Ze.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.isDestroyed()?this.debug&&this.debug.warn(this.TAG_NAME,"handleRender but player is destroyed"):(this.loading&&(this.clearCheckLoadingTimeout(),this.loading=!1,this.emit(Ze.start)),this.playing||(this.playing=!0))}updateStats(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this._startBpsTime||(this._startBpsTime=lr()),Fr(e.ts)){const t=parseInt(e.ts,10);this._stats.ts=t,null===this._playingStartTimestamp&&t>0&&(this._playingStartTimestamp=t)}Fr(e.dts)&&(this._stats.dts=parseInt(e.dts,10)),Fr(e.mseTs)&&(this._stats.mseTs=e.mseTs),Fr(e.buf)&&(this._stats.buf=e.buf),Fr(e.netBuf)&&(this._stats.netBuf=e.netBuf),Fr(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=lr();if(t-this._startBpsTime<1e3)return;null!==this._playingStartTimestamp&&this._stats.fps>0&&(this._stats.pTs+=1);let i=0,s=0,r=0,a=0;this._opt.useMSE&&this.mseDecoder&&(i=this.mseDecoder.checkSourceBufferDelay(),i=parseInt(1e3*i,10),s=this.mseDecoder.checkSourceBufferStore(),s=s.toFixed(2),r=this.mseDecoder.getDecodeDiffTimes(),a=this.mseDecoder.getDecodePlaybackRate()),this._opt.useWCS&&this.webcodecsDecoder&&(r=this.webcodecsDecoder.getDecodeDiffTimes()),this.isOldHls()&&this.hlsDecoder&&(i=this.hlsDecoder.checkHlsBufferedDelay(),i=parseInt(1e3*i,10));let o=0,n=0,l=0;this.isUseHls265()&&this.hlsDecoder&&(i=this.hlsDecoder.checkHlsBufferedDelay(),i=i.toFixed(2),o=this.hlsDecoder.getDemuxBufferedListLength(),l=this.hlsDecoder.getDemuxVideoBufferedListLength(),n=this.hlsDecoder.getDemuxAudioBufferedListLength());let h=0,d=0,c=0,u=!1,p=0;this._opt.useWasm||this._opt.demuxUseWorker?this._tempWorkerStats&&(d=this._tempWorkerStats.demuxBufferDelay,c=this._tempWorkerStats.audioDemuxBufferDelay,h=this._tempWorkerStats.flvBufferByteLength,this._stats.netBuf=this._tempWorkerStats.netBuf,p=this._tempWorkerStats.pushLatestDelay,u=this._tempWorkerStats.isStreamTsMoreThanLocal,this._stats.buf=this._tempWorkerStats.latestDelay):this.demux&&(h=this.demux.getInputByteLength(),p=this.demux.getPushLatestDelay(),u=this.demux.getIsStreamTsMoreThanLocal(),this.demux.bufferList&&(d=this.demux.bufferList.length));let f=0,m=0;this.audio&&this.audio.bufferList&&(f=this.audio.bufferList.length,m=parseInt(f*this.audio.oneBufferDuration,10));let g=0,y=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;y=parseInt(t*g+t*d,10)}const A=this._stats.dts-this.videoTimestamp,b=A+this._stats.netBuf;this.isOldHls()&&(this._stats.fps=this.hlsDecoder.getFps()),this._stats.fps>this._stats.maxFps&&(this._stats.maxFps=this._stats.fps);let v=this.getVideoCurrentTime();const _=this._stats.videoCurrentTime;let w=-1;_&&v&&(w=(v-_).toFixed(2),v=v.toFixed(2));let S=0;this.audioTimestamp>0&&(S=this.audioTimestamp-this.getRenderCurrentPts()),this._allStatsData=Object.assign(this._stats,{audioBuffer:f,audioBufferDelayTs:m,audioTs:this.audioTimestamp,latestAudioTs:this.latestAudioTimestamp,playbackVideoBuffer:g,playbackVideoWaitingBuffer:0,playbackAudioWaitingBuffer:0,playbackCacheDataDuration:y,demuxBuffer:d,pushLatestDelay:p,audioDemuxBuffer:c,flvBuffer:h,mseDelay:i,mseStore:s,mseDecodeDiffTimes:r,mseDecodePlaybackRate:a,wcsDecodeDiffTimes:r,hlsDelay:i,hlsDemuxLength:o,hlsDemuxAudioLength:n,hlsDemuxVideoLength:l,delayTs:A,totalDelayTs:b,isStreamTsMoreThanLocal:u,videoCurrentTime:v,videoCurrentTimeDiff:w,audioSyncVideo:S});let T=null,E=null,k="";if(this.isPlayer()&&this._opt.hasVideo&&this.playing){T=function(e,t){let i=3;const s=t||25;return e<.33*s?i=0:e<.5*s?i=1:e<.83*s&&(i=2),i}(this._stats.fps,this._flvMetaDataFps),this._allStatsData.performance=T;const e=this.checkVideoSmooth(this._allStatsData);k=e.reason,E=e.result,this._allStatsData.videoSmooth=E}this.emit(Ze.stats,this._allStatsData),this._allStatsData.flvBuffer>1048576&&this.emit(it.flvDemuxBufferSizeTooLarge,this._allStatsData.flvBuffer),this._opt.hasVideo?(this.updateHistoryFpsList(this._stats.fps),Fr(T)&&this.emit(Ze.performance,T),Fr(E)&&this.emit(Ze.videoSmooth,E,k)):this._opt.hasAudio&&this.updateHistoryFpsList(this._stats.abps),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._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&&(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 s=function(e){const t=Math.max(...e),i=Math.min(...e);return e.filter((e=>e!==t&&e!==i))}(this._historyFpsList),r=s.reduce(((e,t)=>e+t),0)/s.length,a=.83*r;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 ${r}`),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(Ze.beforeDestroy)}handlePlayToRenderTimes(){const e=this.getPlayToRenderTimes();this.emit(Ze.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,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===g}isPlayback(){return this._opt.playType===A}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()?N:this.isAliyunRtc()?G:this.isOldHls()?j:(t.useMSE&&(e+=P+" "),t.useWCS&&(e+=B+" "),t.useWasm&&(e+=F+" ",t.useSIMD&&(e+=U+" "),t.useMThreading&&(e+=O+" ")),t.useOffscreen&&(e+=M+" "),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(Ze.togglePerformancePanel,e)}setScaleMode(e){let t={isFullResize:!1,isResize:!1,aspectRatio:"default"};switch(e=Number(e)){case Mt:t.isFullResize=!1,t.isResize=!1;break;case Ft:t.isFullResize=!1,t.isResize=!0;break;case Ut:t.isFullResize=!0,t.isResize=!0}this.updateOption(t),this.resize(),this.emit(Ze.viewResizeChange,e)}startVisibilityHiddenTimeout(){this.clearVisibilityHiddenTimeout(),this._opt.pageVisibilityHiddenTimeout>0&&(this.visibilityHiddenTimeout=setTimeout((()=>{this.emit(Ze.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 s=!1;if(e&&t&&i){s=1e3/i*t>e}return s}addContentToCanvas(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.video&&this.video.addContentToCanvas(e)}sendWebsocketMessage(e){const t=this.getStreamType();t===c||t===f+" "+c?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){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";this.emit(Ze.error,e,t),this.emit(e,t)}updateHistoryFpsList(e){this.playbackPause||(this._historyFpsList.length>this._opt.heartTimeout&&this._historyFpsList.shift(),this._historyFpsList.push(e),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}return e}isUseHls265(){return pa(this._opt.isHls)&&pa(this._opt.supportHls265)}isOldHls(){return pa(this._opt.isHls)&&fa(this._opt.supportHls265)}isWebrtcNotH265(){return pa(this._opt.isWebrtc)&&fa(this._opt.isWebrtcH265)}isWebrtcH264(){return pa(this._opt.isWebrtc)&&fa(this._opt.isWebrtcH265)}isWebrtcH265(){return pa(this._opt.isWebrtc)&&pa(this._opt.isWebrtcH265)}isAliyunRtc(){return pa(this._opt.isAliyunRtc)}isStreamWebTransport(){return this.getStreamType()===p}isPlaybackCacheBeforeDecodeForFpsRender(){return this.isPlayback()&&pa(this._opt.playbackConfig.isCacheBeforeDecodeForFpsRender)&&pa(this._opt.useWCS)}isPlaybackUseWCS(){return this.isPlayback()&&pa(this._opt.useWCS)}isPlaybackUseMSE(){return this.isPlayback()&&pa(this._opt.useMSE)}isPlayUseMSE(){return this.isPlayer()&&pa(this._opt.useMSE)}isInWebFullscreen(){return this._opt.useWebFullScreen&&mr()&&this.fullscreen}getPlaybackRate(){let e=1;return pa(this.isPlayback())&&this.playback&&(e=this.playback.rate),e}isPlaybackOnlyDecodeIFrame(){return pa(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.isWebrtcH264()&&this.webrtc?e=this.webrtc.getVideoCurrentTime():this.isAliyunRtc()&&this.aliyunRtcDecoder&&(e=this.aliyunRtcDecoder.getVideoCurrentTime())),e}addMemoryLog(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];this.emit(Ze.memoryLog,` [${e}] `,...i)}downloadMemoryLog(){this.emit(Ze.downloadMemoryLog)}isInMulti(){return-1!==this._opt.multiIndex}isWebrtcForM7S(){return fa(this._opt.isWebrtcForZLM)&&fa(this._opt.isWebrtcForSRS)&&fa(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(xr(e.framerate)){const t=Math.floor(1e3*e.framerate);if(t>0){const e=t/1e3;this._flvMetaDataFps=e}}Mr(e.hasAudio)&&fa(e.hasAudio)&&(this.debug.log("updateMetaData","hasAudio",e.hasAudio,"and update _opt.hasAudio"),this._opt.hasAudio=e.hasAudio),Mr(e.hasVideo)&&fa(e.hasVideo)&&(this.debug.log("updateMetaData","hasVideo",e.hasVideo,"and update _opt.hasVideo"),this._opt.hasVideo=e.hasVideo)}this.emit(Ze.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===_}isRecordTypeMp4(){return this.recorder&&this._opt.recordType===b}isRecordTypeWebm(){return this.recorder&&this._opt.recordType===v}isDemuxInWorker(){return this._opt.useWasm||this._opt.demuxUseWorker}getAudioSyncVideoDiff(){return this.audioTimestamp-this.getRenderCurrentPts()}getMseVideoBufferDelayTime(){let e=0;return this._opt.useMSE&&this.mseDecoder&&(e=this.mseDecoder.getVideoBufferDelayTime(),e=parseInt(1e3*e,10)),e}updateCurrentPts(e){this.updateStats({currentPts:e}),this.emit(Ze.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(){pa(this._opt.checkFirstIFrame)&&(this.mseDecoder?this.mseDecoder.isDecodeFirstIIframe=!1:this.webcodecsDecoder&&(this.webcodecsDecoder.isDecodeFirstIIframe=!1))}isHlsCanVideoPlay(){return this._canPlayAppleMpegurl&&this.isOldHls()}}class Py{constructor(e){const{fromSampleRate:t,toSampleRate:i,channels:s,inputBufferSize:r}=e;if(!t||!i||!s)throw new Error("Invalid settings specified for the resampler.");this.resampler=null,this.fromSampleRate=t,this.toSampleRate=i,this.channels=s||0,this.inputBufferSize=r,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,s,r,a,o,n,l,h,d=e.length,c=this.channels;if(d%c!=0)throw new Error("Buffer was of incorrect sample length.");if(d<=0)return[];for(t=this.outputBufferSize,i=this.ratioWeight,s=this.lastWeight,r=0,a=0,o=0,n=0,l=this.outputBuffer;s<1;s+=i)for(a=s%1,r=1-a,this.lastWeight=s%1,h=0;h<this.channels;++h)l[n++]=this.lastOutput[h]*r+e[h]*a;for(s-=1,d-=c,o=Math.floor(s)*c;n<t&&o<d;){for(a=s%1,r=1-a,h=0;h<this.channels;++h)l[n++]=e[o+(h>0?h:0)]*r+e[o+(c+h)]*a;s+=i,o=Math.floor(s)*c}for(h=0;h<c;++h)this.lastOutput[h]=e[o++];return this.bufferSlice(n)}}multiTap(){this.resampler=e=>{let t,i,s,r,a,o,n,l,h,d,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=[],s=this.ratioWeight,r=0,o=0,n=0,l=!this.tailExists,this.tailExists=!1,h=this.outputBuffer,d=0,c=0,a=0;a<p;++a)i[a]=0;do{if(l)for(r=s,a=0;a<p;++a)i[a]=0;else{for(r=this.lastWeight,a=0;a<p;++a)i[a]=this.lastOutput[a];l=!0}for(;r>0&&o<u;){if(n=1+o-c,!(r>=n)){for(a=0;a<p;++a)i[a]+=e[o+(a>0?a:0)]*r;c+=r,r=0;break}for(a=0;a<p;++a)i[a]+=e[o++]*n;c=o,r-=n}if(0!==r){for(this.lastWeight=r,a=0;a<p;++a)this.lastOutput[a]=i[a];this.tailExists=!0;break}for(a=0;a<p;++a)h[d++]=i[a]/s}while(o<u&&d<t);return this.bufferSlice(d)}}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 By=[255,511,1023,2047,4095,8191,16383,32767];function My(e,t,i){for(let s=0;s<i;s++)if(e<=t[s])return s;return i}function Fy(e){const t=[];return Array.prototype.slice.call(e).forEach(((e,i)=>{t[i]=function(e){let t,i,s;return e>=0?t=213:(t=85,(e=-e-1)<0&&(e=32767)),i=My(e,By,8),i>=8?127^t:(s=i<<4,s|=i<2?e>>4&15:e>>i+3&15,s^t)}(e)})),t}function Uy(e){const t=[];return Array.prototype.slice.call(e).forEach(((e,i)=>{t[i]=function(e){let t=0;e<0?(e=132-e,t=127):(e+=132,t=255);let i=My(e,By,8);return i>=8?127^t:(i<<4|e>>i+3&15)^t}(e)})),t}class Oy extends t{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),this._opt={},e&&(this.player=e),this.tag="talk";const i=ha(ts);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=st,this.mediaStreamSource=null,this.heartInterval=null,this.checkGetUserMediaTimeout=null,this.wsUrl=null,this.startTimestamp=0,this.sequenceId=0,this.tempTimestamp=null,this.tempRtpBufferList=[],this.events=new Ta(this),this._initTalk(),this.player||(this.debug=new Gs(this)),this._opt.encType!==yi&&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===rt&&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.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}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)}}calcAudioBufferLength(){const{sampleRate:e,sampleBitsWidth:t}=this._opt;return 8*e*.02/8}get socketStatusOpen(){return this.socketStatus===rt}log(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this._log("log",...t)}warn(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this._log("warn",...t)}error(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this._log("error",...t)}_log(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];this.player?this.player.debug[e](...i):this.debug?this.debug[e](...i):console[e](...i)}_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(Ze.talkStreamStart),i(this.socket,qi,(()=>{this.socketStatus=rt,this.log(this.tag,"websocket open -> do talk"),this.emit(Ze.talkStreamOpen),e(),this._doTalk()})),i(this.socket,Xi,(e=>{this.log(this.tag,"websocket message",e.data)})),i(this.socket,Yi,(e=>{this.socketStatus=at,this.warn(this.tag,"websocket close -> reject",e),this.emit(Ze.talkStreamClose),t(e)})),i(this.socket,Qi,(e=>{this.socketStatus=ot,this.error(this.tag,"websocket error -> reject",e),this.emit(Ze.talkStreamError,e),t(e)}))}))}_sendClose(){}_initTalk(){this._initMethods(),this._opt.engine===Zi?this._initWorklet():this._opt.engine===es&&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 Py({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=ia((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)}));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}),X)}_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 s=Math.max(-1,Math.min(1,e[t]));i[t]=s<0?32768*s:32767*s}return i}(t):8===this._opt.sampleBitsWidth&&(i=function(e){let t=e.length,i=new Int8Array(t);for(;t--;){let s=Math.max(-1,Math.min(1,e[t]));const r=s<0?32768*s:32767*s;i[t]=parseInt(255/(65535/(32768+r)),10)}return i}(t)),null!==i.buffer){let e=null;this._opt.encType===yi?e=Fy(i):this._opt.encType===Ai?e=Uy(i):this._opt.encType===bi&&(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!==Ji||this._opt.encType!==yi&&this._opt.encType!==Ai?this._opt.packetType===Vi&&(t=e):t=this.rtpPacket(e),t}rtpPacket(e){const t=[];let i=0,s=0,r=0;const a=this._opt.rtpSsrc,o=e.length;this._opt.encType===yi?i=$i:this._opt.encType===Ai?i=Wi:this._opt.encType===vi&&(i=Hi),this.startTimestamp||(this.startTimestamp=lr()),r=lr()-this.startTimestamp,s=this._getSequenceId();let n=0;if(this._opt.packetTcpSendType===Ki){const e=o+12;t[n++]=255&e>>8,t[n++]=255&e>>0}t[n++]=128,t[n++]=128+i,t[n++]=s/256,t[n++]=s%256,t[n++]=r/65536/256,t[n++]=r/65536%256,t[n++]=r%65536/256,t[n++]=r%65536%256,t[n++]=a/65536/256,t[n++]=a/65536%256,t[n++]=a%65536/256,t[n++]=a%65536%256;let l=t.concat([...e]),h=new Uint8Array(l.length);for(let e=0;e<l.length;e++)h[e]=l[e];return h}opusPacket(e){return e}_sendTalkMsg(e){null===this.tempTimestamp&&(this.tempTimestamp=lr());const t=lr(),i=t-this.tempTimestamp,s=this._parseAudioMsg(e);this.log(this.tag,`'send talk msg and diff is ${i} and byteLength is ${s.byteLength} and length is ${s.length}, and g711 length is ${e.length}`),pa(this._opt.saveRtpToFile)&&this._opt.packetType===Ji&&this.addRtpToBuffer(s),s&&(this.socketStatusOpen?this.socket.send(s.buffer):this.emit(it.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,s){t.call(navigator,e,i,s)})):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(Ze.talkGetUserMediaSuccess),null===e.oninactive&&(e.oninactive=e=>{this._handleStreamInactive(e)})})).catch((e=>{this.error(this.tag,"getUserMedia error",e.toString()),this.emit(Ze.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(Ze.talkStreamInactive))}_startCheckGetUserMediaTimeout(){this._stopCheckGetUserMediaTimeout(),this.checkGetUserMediaTimeout=setTimeout((()=>{this.log(this.tag,"check getUserMedia timeout"),this.emit(Ze.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(Ze.talkGetUserMediaFail,(()=>{i("getUserMedia fail")})),this.once(Ze.talkGetUserMediaSuccess,(()=>{t()}))}))}setVolume(e){e=parseFloat(e).toFixed(2),isNaN(e)||(e=hr(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 Ny{constructor(e){this.player=e,this.globalSetting=null;const t=Er();this.defaultSettings={watermark_id:`JessibucaPro_${t}`,watermark_prefix:`JessibucaPro_mask_${t}`,watermark_txt:"JessibucaPro 测试水印",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:"JessibucaPro 测试水印",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 s="string"==typeof e.watermark_parent_node?document.getElementById(e.watermark_parent_node):e.watermark_parent_node,r=s||document.body;const a=r.getBoundingClientRect();var o=Math.max(r.scrollWidth,r.clientWidth,a.width),n=Math.max(r.scrollHeight,r.clientHeight,a.height),l=arguments[0]||{},h=r;(l.watermark_parent_width||l.watermark_parent_height)&&h&&(e.watermark_x=e.watermark_x+0,e.watermark_y=e.watermark_y+0);var d=document.getElementById(e.watermark_id),c=null;if(d)d.shadowRoot&&(c=d.shadowRoot);else{(d=document.createElement("div")).id=e.watermark_id,d.setAttribute("style","pointer-events: none !important; display: block !important"),c="function"==typeof d.attachShadow?d.attachShadow({mode:"open"}):d;var u=r.children,p=Math.floor(Math.random()*(u.length-1))+1;u[p]?r.insertBefore(d,u[p]):r.appendChild(d)}e.watermark_cols=parseInt((o-e.watermark_x)/(e.watermark_width+e.watermark_x_space));var f,m=parseInt((o-e.watermark_x-e.watermark_width*e.watermark_cols)/e.watermark_cols);e.watermark_x_space=m?e.watermark_x_space:m,e.watermark_rows=parseInt((n-e.watermark_y)/(e.watermark_height+e.watermark_y_space));var g,y,A,b=parseInt((n-e.watermark_y-e.watermark_height*e.watermark_rows)/e.watermark_rows);e.watermark_y_space=b?e.watermark_y_space:b,s?(f=e.watermark_x+e.watermark_width*e.watermark_cols+e.watermark_x_space*(e.watermark_cols-1),g=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),g=0+e.watermark_y+e.watermark_height*e.watermark_rows+e.watermark_y_space*(e.watermark_rows-1));for(var v=0;v<e.watermark_rows;v++){A=s?0+e.watermark_y+(n-g)/2+(e.watermark_y_space+e.watermark_height)*v:e.watermark_y+(n-g)/2+(e.watermark_y_space+e.watermark_height)*v;for(var _=0;_<e.watermark_cols;_++){y=s?0+e.watermark_x+(o-f)/2+(e.watermark_width+e.watermark_x_space)*_:e.watermark_x+(o-f)/2+(e.watermark_width+e.watermark_x_space)*_;var w=document.createElement("div"),S=document.createTextNode(e.watermark_txt);w.appendChild(S),w.id=e.watermark_prefix+v+_,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=y+"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)}}}const jy="right",Gy="left",zy="up",$y="down",Wy="leftUp",Hy="leftDown",Vy="rightUp",Jy="rightDown",Ky="zoomExpand",qy="zoomNarrow",Yy="apertureFar",Qy="apertureNear",Xy="focusFar",Zy="focusNear",eA="setPos",tA="calPos",iA="delPos",sA="wiperOpen",rA="wiperClose",aA={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},oA=[25,50,75,100,125,150,175,200,225,250],nA=[1,2,3,4,5,6,7,8,9,16],lA=[16,48,80,112,144,160,176,192,208,224];function hA(e){const{type:t,speed:i=5,index:s=0}=e,r=function(e){return oA[(e=e||5)-1]||oA[4]}(i);let a,o,n,l;switch(a=aA[t],t){case zy:case $y:case Yy:case Qy:n=r;break;case jy:case Gy:case Xy:case Zy:o=r;break;case Wy:case Hy:case Vy:case Jy:o=r,n=r;break;case Ky:case qy:l=function(e){return lA[(e=e||5)-1]||lA[4]}(i);break;case tA:case iA:case eA:n=function(e){return nA[e-1]}(s);break;case rA:case sA:o=1}return function(e,t,i,s){let r=[];r[0]=165,r[1]=15,r[2]=1,r[3]=0,r[4]=0,r[5]=0,r[6]=0,e&&(r[3]=e);t&&(r[4]=t);i&&(r[5]=i);s&&(r[6]=s);return r[7]=(r[0]+r[1]+r[2]+r[3]+r[4]+r[5]+r[6])%256,function(e){let t="";for(let i=0;i<e.length;i++){let s=e[i].toString(16);1===s.length&&(s="0"+s),t+=s.toUpperCase()}return t}(r)}(a,o,n,l)}const dA=["Boolean","Number","String","Undefined","Null","Date","Object"];function cA(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 uA(e,t,i){i||(i=1),t||(t=2);const s={};if(!e||"object"!=typeof e)return e;const r=Object.prototype.toString.call(e).slice(8,-1);if(!dA.includes(r))return r;if(!(i>t)){for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i===t?s[r]=cA(e[r]):"object"==typeof e[r]?s[r]=uA(e[r],t,i+1):s[r]=e[r]);return s}}function pA(){return(new Date).toLocaleString()}class fA{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.player=e,this.logMaxSize=(null==t?void 0:t.logMaxSize)||204800,this.logSize=0,this.logTextArray=[]}destroy(){this.clear()}clear(){this.logSize=0,this.logTextArray=[]}logCache(){let e="";try{for(var t=arguments.length,i=new Array(t),s=0;s<t;s++)i[s]=arguments[s];const r=i.map((e=>uA(e)));e="[JbPro] "+pA()+JSON.stringify(r)}catch(e){return}if(this.logSize+=e.length,this.logTextArray.push(e),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"});Ga(t,"JbPro-"+pA()+".log")}}class mA extends t{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),this._opt={},this.$container=null,Object.keys(e).forEach((t=>{if(void 0===e[t])throw new Error(`JbPro option "${t}" can not be undefined`)})),this.originalOptions=e;const t=da();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 Gs(this);let s=e.container;if("string"==typeof e.container&&(s=document.querySelector(e.container)),!s)throw this.debug.error("JbPro","JbPro need container option and now container is",e.container),new Error("JbPro need container option");if(i.decoder&&fa(-1!==i.decoder.indexOf("decoder-pro.js")||-1!==i.decoder.indexOf("decoder-pro-simd.js")))throw this.debug.error("JbPro",`JbPro decoder ${i.decoder} must be decoder-pro.js or decoder-pro-simd.js`),new Error(`JbPro decoder ${i.decoder} must be decoder-pro.js or decoder-pro-simd.js`);if("CANVAS"===s.nodeName||"VIDEO"===s.nodeName)throw this.debug.error("JbPro",`JbPro container type can not be ${s.nodeName} type`),new Error(`JbPro container type can not be ${s.nodeName} type`);if(i.videoBuffer>=i.heartTimeout)throw this.debug.error("JbPro",`JbPro videoBuffer ${i.videoBuffer}s must be less than heartTimeout ${i.heartTimeout}s`),new Error(`JbPro videoBuffer ${i.videoBuffer}s must be less than heartTimeout ${i.heartTimeout}s`);if(this._checkHasCreated(s))throw this.debug.error("JbPro","JbPro container has been created and can not be created again",s),new Error("JbPro container has been created and can not be created again",s);if(s.classList.add("jessibuca-container"),ma(s,Q,Er()),fa(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%",s.appendChild(e),this.$videoElement=e,this.$container=s,void(this._opt=i)}if(delete i.container,Fr(i.videoBuffer)&&(i.videoBuffer=1e3*Number(i.videoBuffer)),Fr(i.videoBufferDelay)&&(i.videoBufferDelay=1e3*Number(i.videoBufferDelay)),Fr(i.networkDelay)&&(i.networkDelay=1e3*Number(i.networkDelay)),Fr(i.aiFaceDetectInterval)&&(i.aiFaceDetectInterval=1e3*Number(i.aiFaceDetectInterval)),Fr(i.aiObjectDetectInterval)&&(i.aiObjectDetectInterval=1e3*Number(i.aiObjectDetectInterval)),Fr(i.timeout)&&(Br(i.loadingTimeout)&&(i.loadingTimeout=i.timeout),Br(i.heartTimeout)&&(i.heartTimeout=i.timeout)),Fr(i.autoWasm)&&(Br(i.decoderErrorAutoWasm)&&(i.decoderErrorAutoWasm=i.autoWasm),Br(i.hardDecodingNotSupportAutoWasm)&&(i.hardDecodingNotSupportAutoWasm=i.autoWasm)),Fr(i.aiFaceDetectLevel)&&Br(i.aiFaceDetectWidth)){const e=Ls[i.aiFaceDetectLevel];e&&(i.aiFaceDetectWidth=e)}if(Fr(i.aiObjectDetectLevel)&&Br(i.aiObjectDetectWidth)){const e=Is[i.aiObjectDetectLevel];e&&(i.aiObjectDetectWidth=e)}pa(i.isCrypto)&&(i.isM7sCrypto=!0),this._opt=i,this._destroyed=!1,this.$container=s,this._tempPlayBgObj={},this._loadingTimeoutReplayTimes=0,this._heartTimeoutReplayTimes=0,this.events=new Ta(this),this.watermark=new Ny(this),this.memoryLogger=new fA(this),this._initPlayer(s,i),this._initWatermark(),this.debug.log("JbPro",'init success and version is "1-4-2024"'),console.log('JbPro Version is "1-4-2024"')}destroy(){return new Promise(((e,t)=>{this.debug.log("JbPro","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("jessibuca-container"),this.$container.classList.remove("jessibuca-fullscreen-web"),e=this.$container,t=Q,e&&(e.dataset?delete e.dataset[t]:e.removeAttribute("data-"+t)),this.$container=null),this.debug&&this.debug.log("JbPro","destroy end"),this._resetOpt(),this._tempPlayBgObj=null,this._loadingTimeoutReplayTimes=0,this._heartTimeoutReplayTimes=0}_resetOpt(){this._opt=da()}_getOriginalOpt(){const e=da();return Object.assign({},e,this.originalOptions)}_initPlayer(e,t){this.player=new Iy(e,t),this._bindEvents()}_initTalk(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.talk&&(this.talk.destroy(),this.talk=null),this.player&&(e.debug=this.player._opt.debug),this.talk=new Oy(this.player,e),this.debug.log("JbPro","_initTalk",this.talk.getOption()),this._bindTalkEvents()}_resetPlayer(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Promise(((t,i)=>{const s=()=>{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,s(),setTimeout((()=>{t()}),0)})):(s(),setTimeout((()=>{t()}),0))}))}_bindEvents(){var e=this;Object.keys(et).forEach((t=>{this.player.on(et[t],(function(){for(var i=arguments.length,s=new Array(i),r=0;r<i;r++)s[r]=arguments[r];e.emit(t,...s)}))})),this._opt.playFailedAndPausedShowMessage&&this.on(Ze.playFailedAndPaused,(e=>{this.player&&this.player.showTipsMessageByCode(e)})),this.player.once(Ze.beforeDestroy,(()=>{this.emit(Ze.close),this.destroy().then((()=>{})).catch((e=>{}))})),this.player.on(Ze.resize,(()=>{this.watermark&&this.watermark.resize()})),this.player.on(Ze.fullscreen,(()=>{this.watermark&&this.watermark.resize()})),this.player.on(Ze.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(Ze.memoryLog,(function(){e.memoryLogger.logCache(...arguments)})),this.player.on(Ze.downloadMemoryLog,(()=>{this.downloadMemoryLog()}))}_bindTalkEvents(){Object.keys(tt).forEach((e=>{this.player.on(tt[e],(t=>{this.emit(e,t)}))}))}_initWatermark(){if(Vr(this._opt.fullscreenWatermarkConfig)){const e=Or(this.$container,this._opt.fullscreenWatermarkConfig);if(!e.watermark_txt)return void this.debug.warn("JbPro","fullscreenWatermarkConfig text is empty");this.watermark.load(e)}}_checkHasCreated(e){if(!e)return!1;return!!ga(e,Q)}isDestroyed(){return this._destroyed}getOption(){return this.player?this.player.getOption():{}}setDebug(e){this.debug.log("JbPro",`setDebug() ${e}`),this._opt.debug=!!e,this.player?this.player.updateOption({debug:!!e},!0):this.debug.warn("JbPro","player is not init")}getIsDebug(){let e=!1;return this.player&&(e=this.player._opt.debug),e}mute(){this.debug.log("JbPro","mute()"),this.player&&this.player.mute(!0)}cancelMute(){this.debug.log("JbPro","cancelMute()"),this.player&&this.player.mute(!1)}setVolume(e){this.debug.log("JbPro",`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("JbPro","audioResume()"),this.player&&this.player.audio?this.player.audio.audioEnabled(!0):this.debug.warn("JbPro","audioResume error")}setTimeout(e){this.debug.log("JbPro",`setTimeout() ${e}`),e=Number(e),isNaN(e)?this.debug.warn("JbPro",`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("JbPro",`setScaleMode() ${e}`),this.player?this.player.setScaleMode(e):this.debug.warn("JbPro","setScaleMode() player is null")}pause(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return new Promise(((t,i)=>{this.debug.log("JbPro",`pause() ${e}`),this._opt.pauseAndNextPlayUseLastFrameShow&&(this._tempPlayBgObj=this._getVideoLastIframeInfo()),this._pause(e).then((e=>{t(e)})).catch((e=>{i(e)}))}))}_pause(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return new Promise(((t,i)=>{if(this.debug.log("JbPro",`_pause() ${e}`),this.isDestroyed())return i("JbPro 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("JbPro","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("JbPro","clearView()"),this.player&&this.player.video?this.getRenderType()===z?this.player.video.clearView():this.debug.warn("JbPro","clearView","render type is video, not support clearView, please use canvas render type"):this.debug.warn("JbPro","clearView","player is null")}play(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(((i,s)=>{if(this.debug.log("JbPro",`play() ${e}`,JSON.stringify(t)),!e&&!this._opt.url)return this.emit(Ze.error,it.playError),void s("url is null and this._opt.url is null");if(e&&(e=(""+e).trim(),-1===e.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 s(`url ${e} must be "http:" or "https:" or "webrtc:" or "ws:" or "wss:" or "wt:" or "artc:" protocol`);if(fa(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 r=t.cryptoKey||this._opt.playOptions.cryptoKey,a=t.cryptoIV||this._opt.playOptions.cryptoIV;if(this._opt.m7sCryptoKey&&(!r||!a)){const e=this._opt.m7sCryptoKey.split(".");r=na(e[0]),a=na(e[1])}if(!r||!a){const r=e||this._opt.url;return void this._cryptoPlay(r).then((r=>{let{cryptoIV:a,cryptoKey:o}=r;this._opt.playOptions.cryptoKey=o,this._opt.playOptions.cryptoIV=a,t.cryptoIV=a,t.cryptoKey=o,this._playBefore(e,t).then((()=>{i()})).catch((e=>{s(e)}))})).catch((e=>{s(e)}))}this._opt.playOptions.cryptoKey=r,this._opt.playOptions.cryptoIV=a,t.cryptoIV=a,t.cryptoKey=r}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=na(t[0]),i=na(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=>{s(e)}))}))}_playBefore(e,t){return new Promise(((i,s)=>{if(this.player)if(e)if(this._opt.url)if(e===this._opt.url)if(this.player.playing)this.debug.log("JbPro","_playBefore","playing and resolve()"),i();else{this.debug.log("JbPro","_playBefore","this._opt.url === url and pause -> play and destroy play");let e=this._getOriginalOpt();this._opt.pauseAndNextPlayUseLastFrameShow&&this._tempPlayBgObj&&this._tempPlayBgObj.loadingBackground&&(e=Object.assign(e,this._tempPlayBgObj));const t=this._opt.url,r=this._opt.playOptions;this._resetPlayer(e).then((()=>{this._play(t,r).then((()=>{this.player.resumeAudioAfterPause(),i()})).catch((e=>{this.debug.error("JbPro","_playBefore this.player.play error",e),this.emit(Ze.crashLog,this.getCrashLog("this.player.play 1",e)),s(e)}))})).catch((e=>{this.debug.error("JbPro","_resetPlayer error",e)}))}else{this.debug.log("JbPro","_playBefore",`\n this._url.url is ${this._opt.url}\n and new url is ${e}\n and destroy and play new url`);const r=this._getOriginalOpt();this._resetPlayer(r).then((()=>{this._play(e,t).then((()=>{i()})).catch((e=>{this.debug.error("JbPro","_playBefore _play error",e),this.emit(Ze.crashLog,this.getCrashLog("this.player.play 2",e)),s(e)}))})).catch((e=>{this.debug.error("JbPro","_resetPlayer error",e)}))}else this._play(e,t).then((()=>{i()})).catch((e=>{this.debug.error("JbPro","_playBefore _play error",e),this.emit(Ze.crashLog,this.getCrashLog("this.player.play 3",e)),s(e)}));else{let e=this._getOriginalOpt();this._opt.pauseAndNextPlayUseLastFrameShow&&this._tempPlayBgObj&&this._tempPlayBgObj.loadingBackground&&(e=Object.assign(e,this._tempPlayBgObj));const t=this._opt.url,r=this._opt.playOptions;this._resetPlayer(e).then((()=>{this._play(t,r).then((()=>{this.player.resumeAudioAfterPause(),i()})).catch((e=>{this.debug.error("JbPro","_playBefore _play error",e),this.emit(Ze.crashLog,this.getCrashLog("this.player.play 4",e)),s(e)}))})).catch((e=>{this.debug.error("JbPro","_resetPlayer error",e)}))}else e?this._play(e,t).then((()=>{i()})).catch((e=>{this.debug.error("JbPro","_playBefore _play error",e),this.emit(Ze.crashLog,this.getCrashLog("this.player.play 5",e)),s(e)})):this._play(this._opt.url,this._opt.playOptions).then((()=>{i()})).catch((e=>{this.debug.error("JbPro","_playBefore _play error",e),this.emit(Ze.crashLog,this.getCrashLog("this.player.play 6",e)),s(e)}))}))}_cryptoPlay(e){return new Promise(((t,i)=>{const s=function(e){const t=(e||document.location.toString()).split("//"),i=t[1].indexOf("/");let s=t[1].substring(i);return-1!=s.indexOf("?")&&(s=s.split("?")[0]),s}(e);let r=this._opt.cryptoKeyUrl,a="";const o=la(e);if(r){if(a=r,this._opt.isM7sCrypto&&-1===a.indexOf("/crypto/?stream=")){const e=la(r);a=e.origin+Y+`?stream=${s}`}}else r=o.origin+Y,a=r+`?stream=${s}`;var n;this.player.debug.log("JbPro",`_cryptoPlay() cryptoKeyUrl: ${a} and opt.cryptoKeyUrl: ${this._opt.cryptoKeyUrl}`),(n=a,new Promise(((e,t)=>{bn.get(n).then((t=>{e(t)})).catch((e=>{t(e)}))}))).then((e=>{if(e){const s=e.split("."),r=na(s[0]),a=na(s[1]);a&&r?t({cryptoIV:a,cryptoKey:r}):i("get cryptoIV or cryptoKey error")}else i(`cryptoKeyUrl: getM7SCryptoStreamKey ${a} res is null`)})).catch((e=>{i(e)}))}))}playback(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(((i,s)=>{if(this.debug.log("JbPro",`playback() ${e}, options: ${JSON.stringify(t)}`),fa(this._opt.isLive))return s("this._opt.isLive is false, can not playback");const r=ca(),a=Object.assign({},r.playbackConfig,this._opt.playbackConfig,t);a.isUseFpsRender||a.isCacheBeforeDecodeForFpsRender&&(a.isCacheBeforeDecodeForFpsRender=!1,this.debug.warn("JbPro","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("JbPro","playbackConfig.rateConfig.length is 0, showRateBtn can not be ture, showRateBtn is set to false")),a.controlType,K.simple,this._resetPlayer({videoBuffer:0,playbackConfig:a,playType:A,openWebglAlignment:!0,useMSE:a.useMSE,useWCS:a.useWCS,useSIMD:!0}).then((()=>{this.play(e,t).then((()=>{i()})).catch((e=>{s(e)}))})).catch((e=>{s(e)}))}))}playbackPause(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.debug.log("JbPro",`playbackPause() ${e}`),this._opt.playType===g?Promise.reject("playType is player, can not call playbackPause method"):new Promise(((t,i)=>{if(!this.player)return i("player is null");pa(e)?this._pause().then((()=>{t()})).catch((e=>{i(e)})):(this.player.playbackPause=!0,t())}))}playbackResume(){return this.debug.log("JbPro","playbackResume()"),this._opt.playType===g?Promise.reject("playType is player, can not call playbackResume method"):new Promise(((e,t)=>{if(!this.player)return t();this.player.playbackPause=!1,e()}))}forward(e){return this.debug.log("JbPro",`forward() ${e}`),fa(this._opt.isLive)||this._opt.playType===g?Promise.reject("forward() method only just for playback type"):xr(Number(e))?new Promise(((t,i)=>{this.player?(e=hr(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("JbPro",`updatePlaybackForwardMaxRateDecodeIFrame() ${e}`),e=Number(e),e=hr(e=parseInt(e,10),1,8),this._opt.playbackForwardMaxRateDecodeIFrame=e,this.player?this.player.updateOption({playbackForwardMaxRateDecodeIFrame:e},!0):this.debug.warn("JbPro","updatePlaybackForwardMaxRateDecodeIFrame() player is null")}setPlaybackStartTime(e){this.debug.log("JbPro",`setPlaybackStartTime() ${e}`);const t=Hr(e);this.player?this.player.isPlayback()?t<10&&0!==e&&this.player.playback.isControlTypeNormal()?this.debug.warn("JbPro",`setPlaybackStartTime() control type is normal and timestamp: ${e} is not valid`):this.player.playback.isControlTypeSimple()&&e>this.player.playback.totalDuration?this.debug.warn("JbPro",`setPlaybackStartTime() control type is simple and timestamp: ${e} is more than ${this.player.playback.totalDuration}`):this.player.playing&&(this.player.playback.isControlTypeNormal()&&10===t&&(e*=1e3),this.player.playback.setStartTime(e),this.playbackClearCacheBuffer()):this.debug.warn("JbPro","setPlaybackStartTime() playType is not playback"):this.debug.warn("JbPro","setPlaybackStartTime() player is null")}setPlaybackShowPrecision(e){this.debug.log("JbPro",`setPlaybackShowPrecision() ${e}`),this.player?this.player.isPlayback()?this.player.playback.isControlTypeNormal()?this.player.playback.setShowPrecision(e):this.debug.warn("JbPro","control type is not normal , not support!"):this.debug.warn("JbPro","playType is not playback"):this.debug.warn("JbPro","player is null")}playbackCurrentTimeScroll(){this.debug.log("JbPro","playbackCurrentTimeScroll()"),this.player?this.player.isPlayback()?this.player.playback.isControlTypeNormal()?this.player.playback.currentTimeScroll():this.debug.warn("JbPro","control type is not normal , not support!"):this.debug.warn("JbPro","playType is not playback"):this.debug.warn("JbPro","player is null")}playbackClearCacheBuffer(){this.debug.log("JbPro","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("JbPro","playType is not playback"):this.debug.warn("JbPro","player is null")}getPlaybackCurrentRate(){if(this.player){if(this.player.isPlayback())return this.player.getPlaybackRate();this.debug.warn("JbPro","playType is not playback")}else this.debug.warn("JbPro","player is null")}updatePlaybackLocalOneFrameTimestamp(e){this.debug.log("JbPro",`updatePlaybackLocalOneFrameTimestamp() ${e}`),this.player?this.player.isPlayback()?this.player.playback.updateLocalOneFrameTimestamp(e):this.debug.warn("JbPro","playType is not playback"):this.debug.warn("JbPro","player is null")}setStreamQuality(e){if(this.debug.log("JbPro",`setStreamQuality() ${e}`),!this.player)return void this.debug.warn("JbPro","player is null");if(!this.player._opt.operateBtns.quality)return void this.debug.warn("JbPro","player._opt.operateBtns.quality is false");(this.player._opt.qualityConfig||[]).includes(e)?this.player.streamQuality=e:this.debug.warn("JbPro",`quality: ${e} is not in qualityList`)}_play(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",h=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(((d,c)=>{if(!this.player)return c("player is null");let u=!1;this._opt.url&&this._opt.url!==t&&(u=!0),this._opt.url=t,this._opt.playOptions=h;const p=t.split("?")[0],f=p.startsWith("http://")||p.startsWith("https://"),m=p.startsWith("webrtc://"),g=p.startsWith("artc://"),y=p.startsWith("wt://"),A=p.startsWith("ws://")||p.startsWith("wss://"),b=f||A,v=f&&p.endsWith(".m3u8"),_=b&&p.endsWith(".flv"),w=b&&(p.endsWith(".fmp4")||p.endsWith(".mp4")),I=b&&p.endsWith(".mpeg4"),P=b&&(p.endsWith(".h264")||p.endsWith(".h265"));let B=this._opt.isWebrtcForZLM||!1,M=this._opt.isWebrtcForSRS||!1,U=this._opt.isWebrtcForOthers||!1;m&&(-1!==t.indexOf("/index/api/webrtc")?(B=!0,M=!1,U=!1):-1!==t.indexOf("/rtc/v1/play/")&&(M=!0,B=!1,U=!1));let O=null,N=null;if(_&&!this._opt.isFlv&&this._resetDemuxType("isFlv"),w&&!this._opt.isFmp4&&this._resetDemuxType("isFmp4"),I&&!this._opt.isMpeg4&&this._resetDemuxType("isMpeg4"),P&&!this._opt.isNakedFlow&&this._resetDemuxType("isNakedFlow"),O=f?v?r:s:y?o:m?a:g?n:i,N=this._opt.isNakedFlow?x:this._opt.isFmp4?R:this._opt.isMpeg4?D:f&&!v||_||this._opt.isFlv?S:v?E:m?k:g?L:y?C:T,!O||!N)return c(`play protocol is ${O}, demuxType is ${N}`);this.debug.log("JbPro",`play protocol is ${l[O]}, demuxType is ${N}`);const j=()=>{this.player.once(it.webglAlignmentError,(e=>{if(this.isDestroyed())this.debug.log("JbPro","webglAlignmentError but player is destroyed");else if(this.emit(Ze.crashLog,this.getCrashLog(it.webglAlignmentError,e)),this.player&&this.player._opt.webglAlignmentErrorReplay){this.debug.log("JbPro","webglAlignmentError");const e=this._opt.url,t=this._opt.playOptions;this._resetPlayer({openWebglAlignment:!0}).then((()=>{this.play(e,t).then((()=>{this.debug.log("JbPro","webglAlignmentError and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.webglAlignmentError),this.debug.error("JbPro","webglAlignmentError and play error",e)}))})).catch((e=>{this.debug.error("JbPro","webglAlignmentError and _resetPlayer error",e)}))}else{const e=!1===this._opt.playFailedUseLastFrameShow;this._pause(e).then((()=>{this.emit(Ze.playFailedAndPaused,it.webglAlignmentError),this.debug.log("JbPro","webglAlignmentError and webglAlignmentErrorReplay is false")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.webglAlignmentError),this.debug.error("JbPro","webglAlignmentError and pause error",e)}))}})),this.player.once(it.webglContextLostError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","webglContextLostError but player is destroyed");this.emit(Ze.crashLog,this.getCrashLog(it.webglContextLostError,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.webglContextLostErrorReplay){this.debug.log("JbPro","webglContextLostError");const e=this._opt.url,i=this._opt.playOptions;let s={};this.player._opt.replayUseLastFrameShow&&(s=Object.assign({},s,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),this._resetPlayer(s).then((()=>{this.play(e,i).then((()=>{this.debug.log("JbPro","webglContextLostError and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.webglContextLostError,t),this.debug.error("JbPro","webglContextLostError and play error",e)}))})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.webglContextLostError,t),this.debug.error("JbPro","webglContextLostError and _resetPlayer error",e)}))}else{const e=!1===this._opt.playFailedUseLastFrameShow;this._pause(e).then((()=>{this.emit(Ze.playFailedAndPaused,it.webglContextLostError,t),this.debug.log("JbPro","webglContextLostError and webglContextLostErrorReplay is false")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.webglContextLostError,t),this.debug.error("JbPro","webglAlignmentError and pause error",e)}))}})),this.player.once(it.mediaSourceH265NotSupport,(e=>{if(this.isDestroyed())this.debug.log("JbPro","mediaSourceH265NotSupport but player is destroyed");else if(this.emit(Ze.crashLog,this.getCrashLog(it.mediaSourceH265NotSupport,e)),this.player&&this.player._opt.hardDecodingNotSupportAutoWasm){this.debug.log("JbPro","mediaSourceH265NotSupport auto wasm [mse-> wasm] reset player and play");const e=this._opt.url,t=this._opt.playOptions;this._resetPlayer({useMSE:!1,useWCS:!1}).then((()=>{this.play(e,t).then((()=>{this.debug.log("JbPro","mediaSourceH265NotSupport auto wasm [mse-> wasm] reset player and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceH265NotSupport),this.debug.error("JbPro","mediaSourceH265NotSupport auto wasm [mse-> wasm] reset player and play error",e)}))})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceH265NotSupport),this.debug.error("JbPro","mediaSourceH265NotSupport auto wasm [mse-> wasm] _resetPlayer error",e)}))}else{const e=!1===this._opt.playFailedUseLastFrameShow;this._pause(e).then((()=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceH265NotSupport),this.debug.log("JbPro","mediaSourceH265NotSupport and autoWasm is false")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceH265NotSupport),this.debug.error("JbPro","mediaSourceH265NotSupport and pause error",e)}))}})),this.player.once(it.mediaSourceFull,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","mediaSourceFull but player is destroyed");this.emit(Ze.crashLog,this.getCrashLog(it.mediaSourceFull,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.mseDecodeErrorReplay){const e=this._opt.url,i=this._opt.playOptions;let s={};this.player._opt.decoderErrorAutoWasm&&(s={useMSE:!1,useWCS:!1}),this.debug.log("JbPro",`mediaSourceFull and auto wasm [mse-> ${this.player._opt.decoderErrorAutoWasm?"wasm":"mse"}] reset player and play`),this.player._opt.replayUseLastFrameShow&&(s=Object.assign({},s,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),this._resetPlayer(s).then((()=>{this.play(e,i).then((()=>{this.debug.log("JbPro","mediaSourceFull and reset player and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceFull,t),this.debug.error("JbPro","mediaSourceFull and reset player and play error",e)}))})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceFull,t),this.debug.error("JbPro","mediaSourceFull and _resetPlayer error",e)}))}else{const e=!1===this._opt.playFailedUseLastFrameShow;this._pause(e).then((()=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceFull,t),this.debug.log("JbPro","mediaSourceFull and autoWasm is false")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceFull,t),this.debug.error("JbPro","mediaSourceFull and pause error",e)}))}})),this.player.once(it.mediaSourceAppendBufferError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","mediaSourceAppendBufferError but player is destroyed");this.emit(Ze.crashLog,this.getCrashLog(it.mediaSourceAppendBufferError,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.mseDecodeErrorReplay){const e=this._opt.url,i=this._opt.playOptions;let s={};this.player._opt.decoderErrorAutoWasm&&(s={useMSE:!1,useWCS:!1}),this.debug.log("JbPro",`mediaSourceAppendBufferError and auto wasm [mse-> ${this.player._opt.decoderErrorAutoWasm?"wasm":"mse"}] reset player and play`),this.player._opt.replayUseLastFrameShow&&(s=Object.assign({},s,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),this._resetPlayer(s).then((()=>{this.play(e,i).then((()=>{this.debug.log("JbPro","mediaSourceAppendBufferError and reset player and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceAppendBufferError,t),this.debug.error("JbPro","mediaSourceAppendBufferError and reset player and play error",e)}))})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceAppendBufferError,t),this.debug.error("JbPro","mediaSourceAppendBufferError and _resetPlayer error",e)}))}else{const e=!1===this._opt.playFailedUseLastFrameShow;this._pause(e).then((()=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceAppendBufferError,t),this.debug.log("JbPro","mediaSourceAppendBufferError and autoWasm is false")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceAppendBufferError,t),this.debug.error("JbPro","mediaSourceAppendBufferError and pause error",e)}))}})),this.player.once(it.mseSourceBufferError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","mseSourceBufferError but player is destroyed");this.emit(Ze.crashLog,this.getCrashLog(it.mseSourceBufferError,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.mseDecodeErrorReplay){const e=this._opt.url,i=this._opt.playOptions;let s={};this.player._opt.decoderErrorAutoWasm&&(s={useMSE:!1,useWCS:!1}),this.debug.log("JbPro",`mseSourceBufferError auto wasm [mse-> ${this.player._opt.decoderErrorAutoWasm?"wasm":"mse"}] reset player and play`),this.player._opt.replayUseLastFrameShow&&(s=Object.assign({},s,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),this._resetPlayer(s).then((()=>{this.play(e,i).then((()=>{this.debug.log("JbPro","mseSourceBufferError reset player and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mseSourceBufferError,t),this.debug.error("JbPro","mseSourceBufferError reset player and play error",e)}))})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mseSourceBufferError,t),this.debug.error("JbPro","mseSourceBufferError _resetPlayer and play error",e)}))}else{const e=!1===this._opt.playFailedUseLastFrameShow;this._pause(e).then((()=>{this.emit(Ze.playFailedAndPaused,it.mseSourceBufferError,t),this.debug.log("JbPro","mseSourceBufferError and autoWasm is false")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mseSourceBufferError,t),this.debug.error("JbPro","mseSourceBufferError and pause error:",e)}))}})),this.player.once(it.mediaSourceBufferedIsZeroError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","mediaSourceBufferedIsZeroError but player is destroyed");this.emit(Ze.crashLog,this.getCrashLog(it.mediaSourceBufferedIsZeroError,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.mseDecodeErrorReplay){const e=this._opt.url,i=this._opt.playOptions;let s={};this.player._opt.decoderErrorAutoWasm&&(s={useMSE:!1,useWCS:!1}),this.debug.log("JbPro",`mediaSourceBufferedIsZeroError auto wasm [mse-> ${this.player._opt.decoderErrorAutoWasm?"wasm":"mse"}] reset player and play`),this.player._opt.replayUseLastFrameShow&&(s=Object.assign({},s,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),this._resetPlayer(s).then((()=>{this.play(e,i).then((()=>{this.debug.log("JbPro","mediaSourceBufferedIsZeroError reset player and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceBufferedIsZeroError,t),this.debug.error("JbPro","mediaSourceBufferedIsZeroError reset player and play error",e)}))})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceBufferedIsZeroError,t),this.debug.error("JbPro","mediaSourceBufferedIsZeroError _resetPlayer and play error",e)}))}else{const e=!1===this._opt.playFailedUseLastFrameShow;this._pause(e).then((()=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceBufferedIsZeroError,t),this.debug.log("JbPro","mediaSourceBufferedIsZeroError and autoWasm is false")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceBufferedIsZeroError,t),this.debug.error("JbPro","mediaSourceBufferedIsZeroError and pause error:",e)}))}})),this.player.once(it.mseAddSourceBufferError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","mseAddSourceBufferError but player is destroyed");this.emit(Ze.crashLog,this.getCrashLog(it.mseAddSourceBufferError,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.hardDecodingNotSupportAutoWasm){this.debug.log("JbPro","mseAddSourceBufferError auto wasm [mse-> wasm] reset player and play");const e=this._opt.url,i=this._opt.playOptions;let s={useMSE:!1,useWCS:!1};this.player._opt.replayUseLastFrameShow&&(s=Object.assign({},s,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),this._resetPlayer(s).then((()=>{this.play(e,i).then((()=>{this.debug.log("JbPro","mseAddSourceBufferError auto wasm [mse-> wasm] reset player and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mseAddSourceBufferError,t),this.debug.error("JbPro","mseAddSourceBufferError auto wasm [mse-> wasm] reset player and play error",e)}))})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mseAddSourceBufferError,t),this.debug.error("JbPro","mseAddSourceBufferError auto wasm [mse-> wasm] _resetPlayer and play error",e)}))}else{const e=!1===this._opt.playFailedUseLastFrameShow;this._pause(e).then((()=>{this.emit(Ze.playFailedAndPaused,it.mseAddSourceBufferError,t),this.debug.log("JbPro","mseAddSourceBufferError and autoWasm is false")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mseAddSourceBufferError,t),this.debug.error("JbPro","mseAddSourceBufferError and pause error",e)}))}})),this.player.once(it.mediaSourceDecoderConfigurationError,(e=>{if(this.isDestroyed())this.debug.log("JbPro","mediaSourceDecoderConfigurationError but player is destroyed");else if(this.emit(Ze.crashLog,this.getCrashLog(it.mediaSourceDecoderConfigurationError,e)),this.player&&this.player._opt.hardDecodingNotSupportAutoWasm){this.debug.log("JbPro","mediaSourceDecoderConfigurationError auto wasm [mse-> wasm] reset player and play");const e=this._opt.url,t=this._opt.playOptions;let i={useMSE:!1,useWCS:!1};this._resetPlayer(i).then((()=>{this.play(e,t).then((()=>{this.debug.log("JbPro","mediaSourceDecoderConfigurationError auto wasm [mse-> wasm] reset player and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceDecoderConfigurationError),this.debug.error("JbPro","mediaSourceDecoderConfigurationError auto wasm [mse-> wasm] reset player and play error",e)}))})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceDecoderConfigurationError),this.debug.error("JbPro","mediaSourceDecoderConfigurationError auto wasm [mse-> wasm] _resetPlayer and play error",e)}))}else{const e=!1===this._opt.playFailedUseLastFrameShow;this._pause(e).then((()=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceDecoderConfigurationError),this.debug.log("JbPro","mediaSourceDecoderConfigurationError and autoWasm is false")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceDecoderConfigurationError),this.debug.error("JbPro","mediaSourceDecoderConfigurationError and pause error",e)}))}})),this.player.once(it.mediaSourceTsIsMaxDiff,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","mediaSourceTsIsMaxDiff but player is destroyed");this.emit(Ze.crashLog,this.getCrashLog(it.mediaSourceTsIsMaxDiff,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.mediaSourceTsIsMaxDiffReplay){this.debug.log("JbPro","mediaSourceTsIsMaxDiff reset player and play");const e=this._opt.url,i=this._opt.playOptions;let s={};s=Object.assign({},s,t),this._resetPlayer(s).then((()=>{this.play(e,i).then((()=>{this.debug.log("JbPro","mediaSourceTsIsMaxDiff replay success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceTsIsMaxDiff,t),this.debug.error("JbPro","mediaSourceTsIsMaxDiff replay error",e)}))})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceTsIsMaxDiff,t),this.debug.error("JbPro","mediaSourceTsIsMaxDiff _resetPlayer error",e)}))}else{const e=!1===this._opt.playFailedUseLastFrameShow;this._pause(e).then((()=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceTsIsMaxDiff,t),this.debug.log("JbPro","mediaSourceTsIsMaxDiff and replay is false")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceTsIsMaxDiff,t),this.debug.error("JbPro","mediaSourceTsIsMaxDiff and pause error",e)}))}})),this.player.once(it.mseWidthOrHeightChange,(t=>{if(this.isDestroyed())return void this.debug.log("JbPro","mseWidthOrHeightChange but player is destroyed");this.emit(Ze.crashLog,this.getCrashLog(it.mseWidthOrHeightChange,t));const i=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.widthOrHeightChangeReplay){this.debug.log("JbPro","mseWidthOrHeightChange and reset player and play");const e=this._opt.url,t=this._opt.playOptions;let s={};s=Object.assign({},s,i),this._resetPlayer(s).then((()=>{this.play(e,t).then((()=>{this.debug.log("JbPro","mseWidthOrHeightChange and reset player and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mseWidthOrHeightChange,i),this.debug.error("JbPro","mseWidthOrHeightChange and reset player and play error",e)}))})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mseWidthOrHeightChange,i),this.debug.error("JbPro","mseWidthOrHeightChange and _resetPlayer error",e)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this._pause(t).then((()=>{this.emit(Ze.playFailedAndPaused,it.mseWidthOrHeightChange,i),this.debug.error("JbPro","mseWidthOrHeightChange and _resetPlayer error",e)})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mseWidthOrHeightChange,i),this.debug.error("JbPro","mseWidthOrHeightChange error and pause error",e)}))}})),this.player.once(it.mediaSourceAudioG711NotSupport,(t=>{if(this.isDestroyed())return void this.debug.log("JbPro","mediaSourceAudioG711NotSupport but player is destroyed");const i=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.mediaSourceAudioG711NotSupportReplay){this.debug.log("JbPro","mediaSourceAudioG711NotSupport and reset player and play");const e=this._opt.url,t=this._opt.playOptions;let s={mseDecodeAudio:!1};s=Object.assign({},s,i),this._resetPlayer(s).then((()=>{this.play(e,t).then((()=>{this.debug.log("JbPro","mediaSourceAudioG711NotSupport and reset player and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceAudioG711NotSupport,i),this.debug.error("JbPro","mediaSourceAudioG711NotSupport and reset player and play error",e)}))})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceAudioG711NotSupport,i),this.debug.error("JbPro","mediaSourceAudioG711NotSupport and _resetPlayer error",e)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this._pause(t).then((()=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceAudioG711NotSupport,i),this.debug.error("JbPro","mediaSourceAudioG711NotSupport and _resetPlayer error",e)})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceAudioG711NotSupport,i),this.debug.error("JbPro","mediaSourceAudioG711NotSupport error and pause error",e)}))}})),this.player.once(it.mediaSourceAudioInitTimeout,(t=>{if(this.isDestroyed())return void this.debug.log("JbPro","mediaSourceAudioInitTimeout but player is destroyed");const i=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.mediaSourceAudioInitTimeoutReplay){this.debug.log("JbPro","mediaSourceAudioInitTimeout and reset player and play");const e=this._opt.url,t=this._opt.playOptions;let s={mseDecodeAudio:!1};s=Object.assign({},s,i),this._resetPlayer(s).then((()=>{this.play(e,t).then((()=>{this.debug.log("JbPro","mediaSourceAudioInitTimeout and reset player and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceAudioInitTimeout,i),this.debug.error("JbPro","mediaSourceAudioInitTimeout and reset player and play error",e)}))})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceAudioInitTimeout,i),this.debug.error("JbPro","mediaSourceAudioInitTimeout and _resetPlayer error",e)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this._pause(t).then((()=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceAudioInitTimeout,i),this.debug.error("JbPro","mediaSourceAudioInitTimeout and _resetPlayer error",e)})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceAudioInitTimeout,i),this.debug.error("JbPro","mediaSourceAudioInitTimeout error and pause error",e)}))}})),this.player.once(it.mediaSourceUseCanvasRenderPlayFailed,(e=>{if(this.isDestroyed())this.debug.log("JbPro","mediaSourceUseCanvasRenderPlayFailed but player is destroyed");else if(this.emit(Ze.crashLog,this.getCrashLog(it.mediaSourceUseCanvasRenderPlayFailed,e)),this.player&&this.player._opt.mediaSourceUseCanvasRenderPlayFailedReplay&&this.player._opt.mediaSourceUseCanvasRenderPlayFailedReplayType){this.debug.log("JbPro",`mediaSourceUseCanvasRenderPlayFailed relayType is ${this.player._opt.mediaSourceUseCanvasRenderPlayFailedReplayType} and reset player and play`);const e=this._opt.url,t=this._opt.playOptions;let i={};const s=this.player._opt.mediaSourceUseCanvasRenderPlayFailedReplayType;s===z?i={useMSE:!1,useWCS:!1}:s===$&&(i={useVideoRender:!0,useCanvasRender:!1}),this._resetPlayer(i).then((()=>{this.play(e,t).then((()=>{this.debug.log("JbPro","mediaSourceUseCanvasRenderPlayFailed and reset player and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceUseCanvasRenderPlayFailed),this.debug.error("JbPro","mediaSourceUseCanvasRenderPlayFailed and reset player and play error",e)}))})).catch((e=>{this.debug.error("JbPro","mediaSourceUseCanvasRenderPlayFailed auto and _resetPlayer and play error",e)}))}else{const e=!1===this._opt.playFailedUseLastFrameShow;this._pause(e).then((()=>{this.debug.log("JbPro","mediaSourceUseCanvasRenderPlayFailed and pause player success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.mediaSourceUseCanvasRenderPlayFailed),this.debug.error("JbPro","mediaSourceUseCanvasRenderPlayFailed and pause",e)}))}})),this.player.once(it.webcodecsH265NotSupport,(e=>{if(this.isDestroyed())this.debug.log("JbPro","webcodecsH265NotSupport but player is destroyed");else if(this.emit(Ze.crashLog,this.getCrashLog(it.webcodecsH265NotSupport,e)),this.player&&this.player._opt.hardDecodingNotSupportAutoWasm){this.debug.log("JbPro","webcodecsH265NotSupport auto wasm [wcs-> wasm] reset player and play");const e=this._opt.url,t=this._opt.playOptions;this._resetPlayer({useMSE:!1,useWCS:!1}).then((()=>{this.play(e,t).then((()=>{this.debug.log("JbPro","webcodecsH265NotSupport auto wasm [wcs-> wasm] reset player and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.webcodecsH265NotSupport),this.debug.error("JbPro","webcodecsH265NotSupport auto wasm [wcs-> wasm] reset player and play error",e)}))})).catch((e=>{this.debug.error("JbPro","webcodecsH265NotSupport auto wasm [wcs-> wasm] _resetPlayer and play error",e)}))}else{const e=!1===this._opt.playFailedUseLastFrameShow;this._pause(e).then((()=>{this.emit(Ze.playFailedAndPaused,it.webcodecsH265NotSupport),this.debug.log("JbPro","webcodecsH265NotSupport and autoWasm is false")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.webcodecsH265NotSupport),this.debug.error("JbPro","webcodecsH265NotSupport and pause error",e)}))}})),this.player.once(it.webcodecsUnsupportedConfigurationError,(e=>{if(this.isDestroyed())this.debug.log("JbPro","webcodecsUnsupportedConfigurationError but player is destroyed");else if(this.emit(Ze.crashLog,this.getCrashLog(it.webcodecsUnsupportedConfigurationError,e)),this.player&&this.player._opt.hardDecodingNotSupportAutoWasm){this.debug.log("JbPro","webcodecsUnsupportedConfigurationError auto wasm [wcs-> wasm] reset player and play");const e=this._opt.url,t=this._opt.playOptions;this._resetPlayer({useMSE:!1,useWCS:!1}).then((()=>{this.play(e,t).then((()=>{this.debug.log("JbPro","webcodecsUnsupportedConfigurationError auto wasm [wcs-> wasm] reset player and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.webcodecsUnsupportedConfigurationError),this.debug.error("JbPro","webcodecsUnsupportedConfigurationError auto wasm [wcs-> wasm] reset player and play error",e)}))})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.webcodecsUnsupportedConfigurationError),this.debug.error("JbPro","webcodecsUnsupportedConfigurationError auto wasm [wcs-> wasm] _resetPlayer and play error",e)}))}else{const e=!1===this._opt.playFailedUseLastFrameShow;this._pause(e).then((()=>{this.emit(Ze.playFailedAndPaused,it.webcodecsUnsupportedConfigurationError),this.debug.log("JbPro","webcodecsUnsupportedConfigurationError and autoWasm is false")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.webcodecsUnsupportedConfigurationError),this.debug.error("JbPro","webcodecsUnsupportedConfigurationError and pause error",e)}))}})),this.player.once(it.webcodecsDecodeConfigureError,(e=>{if(this.isDestroyed())this.debug.log("JbPro","webcodecsDecodeConfigureError but player is destroyed");else if(this.emit(Ze.crashLog,this.getCrashLog(it.webcodecsDecodeConfigureError,e)),this.player&&this.player._opt.hardDecodingNotSupportAutoWasm){this.debug.log("JbPro","webcodecsDecodeConfigureError auto wasm [wcs-> wasm] reset player and play");const e=this._opt.url,t=this._opt.playOptions;this._resetPlayer({useMSE:!1,useWCS:!1}).then((()=>{this.play(e,t).then((()=>{this.debug.log("JbPro","webcodecsDecodeConfigureError auto wasm [wcs-> wasm] reset player and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.webcodecsDecodeConfigureError),this.debug.error("JbPro","webcodecsDecodeConfigureError auto wasm [wcs-> wasm] reset player and play error",e)}))})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.webcodecsDecodeConfigureError),this.debug.error("JbPro","webcodecsDecodeConfigureError auto wasm [wcs-> wasm] _resetPlayer and play error",e)}))}else{const e=!1===this._opt.playFailedUseLastFrameShow;this._pause(e).then((()=>{this.emit(Ze.playFailedAndPaused,it.webcodecsDecodeConfigureError),this.debug.log("JbPro","webcodecsDecodeConfigureError and autoWasm is false")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.webcodecsDecodeConfigureError),this.debug.error("JbPro","webcodecsDecodeConfigureError and pause error",e)}))}})),this.player.once(it.webcodecsDecodeError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","webcodecsDecodeError but player is destroyed");this.emit(Ze.crashLog,this.getCrashLog(it.webcodecsDecodeError,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.wcsDecodeErrorReplay){const e=this._opt.url,i=this._opt.playOptions;let s={};this.player._opt.decoderErrorAutoWasm&&(s={useMSE:!1,useWCS:!1}),this.debug.log("JbPro",`webcodecs decode error autoWasm [wcs-> ${this.player._opt.decoderErrorAutoWasm?"wasm":"wcs"}] reset player and play`),this.player._opt.replayUseLastFrameShow&&(s=Object.assign({},s,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),this._resetPlayer(s).then((()=>{this.play(e,i).then((()=>{this.debug.log("JbPro","webcodecs decode error reset player and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.webcodecsDecodeError,t),this.debug.error("JbPro","webcodecs decode error reset player and play error",e)}))})).catch((()=>{this.emit(Ze.playFailedAndPaused,it.webcodecsDecodeError,t),this.debug.error("JbPro","webcodecs decode error _resetPlayer error")}))}else{const e=!1===this._opt.playFailedUseLastFrameShow;this._pause(e).then((()=>{this.emit(Ze.playFailedAndPaused,it.webcodecsDecodeError,t),this.debug.log("JbPro","webcodecs decode error and autoWasm is false")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.webcodecsDecodeError,t),this.debug.error("JbPro","webcodecs decode error and pause error",e)}))}})),this.player.once(it.wcsWidthOrHeightChange,(t=>{if(this.isDestroyed())return void this.debug.log("JbPro","wcsWidthOrHeightChange but player is destroyed");this.emit(Ze.crashLog,this.getCrashLog(it.wcsWidthOrHeightChange,t));const i=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.widthOrHeightChangeReplay){this.debug.log("JbPro","wcsWidthOrHeightChange and reset player and play");const e=this._opt.url,t=this._opt.playOptions;let s={};s=Object.assign({},s,i),this._resetPlayer(s).then((()=>{this.play(e,t).then((()=>{this.debug.log("JbPro","wcsWidthOrHeightChange and reset player and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.wcsWidthOrHeightChange,i),this.debug.error("JbPro","wcsWidthOrHeightChange and reset player and play error",e)}))})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.wcsWidthOrHeightChange,i),this.debug.error("JbPro","wcsWidthOrHeightChange and _resetPlayer error",e)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this._pause(t).then((()=>{this.emit(Ze.playFailedAndPaused,it.wcsWidthOrHeightChange,i),this.debug.error("JbPro","wcsWidthOrHeightChange and _resetPlayer error",e)})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.wcsWidthOrHeightChange,i),this.debug.error("JbPro","wcsWidthOrHeightChange error and pause error",e)}))}})),this.player.once(it.wasmDecodeError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","wasmDecodeError but player is destroyed");this.emit(Ze.crashLog,this.getCrashLog(it.wasmDecodeError,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.wasmDecodeErrorReplay){this.debug.log("JbPro","wasm decode error and reset player and play");const e=this._opt.url,i=this._opt.playOptions;let s={};this.player._opt.replayUseLastFrameShow&&(s=Object.assign({},s,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),this._resetPlayer(s).then((()=>{this.play(e,i).then((()=>{this.debug.log("JbPro","wasm decode error and reset player and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.wasmDecodeError,t),this.debug.error("JbPro","wasm decode error and reset player and play error",e)}))})).catch((()=>{this.emit(Ze.playFailedAndPaused,it.wasmDecodeError,t),this.debug.error("JbPro","wasm decode error and _resetPlayer error")}))}else{const e=!1===this._opt.playFailedUseLastFrameShow;this._pause(e).then((()=>{this.emit(Ze.playFailedAndPaused,it.wasmDecodeError,t),this.debug.log("JbPro","wasm decode error and wasmDecodeErrorReplay is false")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.wasmDecodeError,t),this.debug.error("JbPro","wasm decode error and pause error",e)}))}})),this.player.once(it.simdDecodeError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","simdDecodeError but player is destroyed");this.emit(Ze.crashLog,this.getCrashLog(it.simdDecodeError,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.simdDecodeErrorReplay){this.debug.log("JbPro",`simdDecodeError error simdDecodeErrorReplayType is ${this.player._opt.simdDecodeErrorReplayType} and reset player and play`);const e=this._opt.url,i=this._opt.playOptions;let s={};this.player._opt.simdDecodeErrorReplayType===F&&(s={useSIMD:!1}),s=Object.assign({},s,t),this._resetPlayer(s).then((()=>{this.play(e,i).then((()=>{this.debug.log("JbPro","simdDecodeError and reset player and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.simdDecodeError,t),this.debug.error("JbPro","simdDecodeError and reset player and play error",e)}))})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.simdDecodeError,t),this.debug.error("JbPro","simdDecodeError and _resetPlayer error",e)}))}else{const e=!1===this._opt.playFailedUseLastFrameShow;this._pause(e).then((()=>{this.emit(Ze.playFailedAndPaused,it.simdDecodeError,t),this.debug.error("JbPro","simdDecodeError and simdDecodeErrorReplay is false")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.simdDecodeError,t),this.debug.error("JbPro","simdDecodeError error and pause error",e)}))}})),this.player.once(it.wasmWidthOrHeightChange,(t=>{if(this.isDestroyed())return void this.debug.log("JbPro","wasmWidthOrHeightChange but player is destroyed");this.emit(Ze.crashLog,this.getCrashLog(it.wasmWidthOrHeightChange,t));const i=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.widthOrHeightChangeReplay){this.debug.log("JbPro","wasmWidthOrHeightChange and reset player and play");const e=this._opt.url,t=this._opt.playOptions;let s={};s=Object.assign({},s,i),this._resetPlayer(s).then((()=>{this.play(e,t).then((()=>{this.debug.log("JbPro","wasmWidthOrHeightChange and reset player and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.wasmWidthOrHeightChange,i),this.debug.error("JbPro","wasmWidthOrHeightChange and reset player and play error",e)}))})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.wasmWidthOrHeightChange,i),this.debug.error("JbPro","wasmWidthOrHeightChange and _resetPlayer error",e)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this._pause(t).then((()=>{this.emit(Ze.playFailedAndPaused,it.wasmWidthOrHeightChange,i),this.debug.error("JbPro","wasmWidthOrHeightChange and _resetPlayer error",e)})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.wasmWidthOrHeightChange,i),this.debug.error("JbPro","wasmWidthOrHeightChange error and pause error",e)}))}})),this.player.once(it.wasmUseVideoRenderError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","wasmUseVideoRenderError but player is destroyed");this.emit(Ze.crashLog,this.getCrashLog(it.wasmUseVideoRenderError,e)),this.debug.log("JbPro","wasmUseVideoRenderError and reset player and play");const t=this._opt.url,i=this._opt.playOptions;this._resetPlayer({useVideoRender:!1,useCanvasRender:!0}).then((()=>{this.play(t,i).then((()=>{this.debug.log("JbPro","wasmUseVideoRenderError and reset player and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.wasmUseVideoRenderError),this.debug.error("JbPro","wasmUseVideoRenderError and reset player and play error",e)}))})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.wasmUseVideoRenderError),this.debug.error("JbPro","wasmUseVideoRenderError and _resetPlayer error",e)}))})),this.player.once(it.videoElementPlayingFailed,(e=>{if(this.isDestroyed())this.debug.log("JbPro","videoElementPlayingFailed but player is destroyed");else if(this.emit(Ze.crashLog,this.getCrashLog(it.videoElementPlayingFailed,e)),this.player&&this.player._opt.videoElementPlayingFailedReplay){this.debug.log("JbPro",`videoElementPlayingFailed and useMSE is ${this._opt.useMSE} and reset player and play`);const e=this._opt.url,t=this._opt.playOptions;this._resetPlayer({useMSE:!1,useVideoRender:!1,useCanvasRender:!0}).then((()=>{this.play(e,t).then((()=>{this.debug.log("JbPro","videoElementPlayingFailed and reset player and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.videoElementPlayingFailed),this.debug.error("JbPro","videoElementPlayingFailed and reset player and play error",e)}))})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.videoElementPlayingFailed),this.debug.error("JbPro","videoElementPlayingFailed and _resetPlayer error",e)}))}else{const e=!1===this._opt.playFailedUseLastFrameShow;this._pause(e).then((()=>{this.emit(Ze.playFailedAndPaused,it.videoElementPlayingFailed),this.debug.error("JbPro","videoElementPlayingFailed and videoElementPlayingFailedReplay is false")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.videoElementPlayingFailed),this.debug.error("JbPro","videoElementPlayingFailed and _pause error",e)}))}})),this.player.once(it.simdH264DecodeVideoWidthIsTooLarge,(e=>{if(this.isDestroyed())this.debug.log("JbPro","simdH264DecodeVideoWidthIsTooLarge but player is destroyed");else if(this.emit(Ze.crashLog,this.getCrashLog(it.simdH264DecodeVideoWidthIsTooLarge,e)),this.player&&this.player._opt.simdH264DecodeVideoWidthIsTooLargeReplay){this.debug.log("JbPro","simdH264DecodeVideoWidthIsTooLarge and reset player and play");const e=this._opt.url,t=this._opt.playOptions;this._resetPlayer({useSIMD:!1}).then((()=>{this.play(e,t).then((()=>{this.debug.log("JbPro","simdH264DecodeVideoWidthIsTooLarge and reset player and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.simdH264DecodeVideoWidthIsTooLarge),this.debug.error("JbPro","simdH264DecodeVideoWidthIsTooLarge and reset player and play error",e)}))})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.simdH264DecodeVideoWidthIsTooLarge),this.debug.error("JbPro","simdH264DecodeVideoWidthIsTooLarge and _resetPlayer error",e)}))}else{const e=!1===this._opt.playFailedUseLastFrameShow;this._pause(e).then((()=>{this.emit(Ze.playFailedAndPaused,it.simdH264DecodeVideoWidthIsTooLarge,lastFrameInfo),this.debug.error("JbPro","simdH264DecodeVideoWidthIsTooLarge and simdDecodeErrorReplay is false")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.simdH264DecodeVideoWidthIsTooLarge,lastFrameInfo),this.debug.error("JbPro","simdH264DecodeVideoWidthIsTooLarge and pause error",e)}))}})),this.player.once(Ze.networkDelayTimeout,(e=>{if(this.player._opt.networkDelayTimeoutReplay){if(this.isDestroyed())return void this.debug.log("JbPro","networkDelayTimeout but player is destroyed");this.emit(Ze.crashLog,this.getCrashLog(Ze.networkDelayTimeout,e));const t=this._getVideoLastIframeInfo();this.debug.log("JbPro","network delay time out and reset player and play");const i=this._opt.url,s=this._opt.playOptions;let r={};this.player&&this.player._opt.replayUseLastFrameShow&&(r=Object.assign({},r,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),this._resetPlayer(r).then((()=>{this.play(i,s).then((()=>{this.debug.log("JbPro","wasm decode error and reset player and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,Ze.networkDelayTimeout,t),this.debug.error("JbPro","wasm decode error and reset player and play error",e)}))})).catch((()=>{this.emit(Ze.playFailedAndPaused,Ze.networkDelayTimeout,t),this.debug.error("JbPro","wasm decode error and _resetPlayer error")}))}})),this.player.once(it.fetchError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","fetchError but player is destroyed");this.emit(Ze.crashLog,this.getCrashLog(it.fetchError,e));const t=this._getVideoLastIframeInfo();this.debug.log("JbPro","fetch error and pause player");const i=!1===this._opt.playFailedUseLastFrameShow;this._pause(i).then((()=>{this.emit(Ze.playFailedAndPaused,it.fetchError,t)})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.fetchError,t),this.debug.error("JbPro","fetch error and pause",e)}))})),this.player.once(Ze.streamEnd,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","streamEnd but player is destroyed");this.emit(Ze.crashLog,this.getCrashLog(Ze.streamEnd,e));const t=this._getVideoLastIframeInfo();this.debug.log("JbPro","streamEnd pause player");const i=!1===this._opt.playFailedUseLastFrameShow;this._pause(i).then((()=>{this.emit(Ze.playFailedAndPaused,Ze.streamEnd,t)})).catch((e=>{this.emit(Ze.playFailedAndPaused,Ze.streamEnd,t),this.debug.error("JbPro","streamEnd pause",e)}))})),this.player.once(it.websocketError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","websocketError but player is destroyed");this.emit(Ze.crashLog,this.getCrashLog(it.websocketError,e));const t=this._getVideoLastIframeInfo();this.debug.log("JbPro","websocketError and reset player");const i=!1===this._opt.playFailedUseLastFrameShow;this._pause(i).then((()=>{this.emit(Ze.playFailedAndPaused,it.websocketError,t)})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.websocketError,t),this.debug.error("JbPro","websocketError and pause",e)}))})),this.player.once(it.webrtcError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","webrtcError but player is destroyed");this.emit(Ze.crashLog,this.getCrashLog(it.webrtcError,e));const t=this._getVideoLastIframeInfo();this.debug.log("JbPro","webrtcError and pause player");const i=!1===this._opt.playFailedUseLastFrameShow;this._pause(i).then((()=>{this.emit(Ze.playFailedAndPaused,it.webrtcError,t)})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.webrtcError,t),this.debug.error("JbPro","webrtcError and pause",e)}))})),this.player.once(it.hlsError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","hlsError but player is destroyed");this.emit(Ze.crashLog,this.getCrashLog(it.hlsError,e));const t=this._getVideoLastIframeInfo();this.debug.log("JbPro","hlsError and pause player");const i=!1===this._opt.playFailedUseLastFrameShow;this._pause(i).then((()=>{this.emit(Ze.playFailedAndPaused,it.hlsError,t)})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.hlsError,t),this.debug.error("JbPro","hlsError and pause",e)}))})),this.player.once(it.aliyunRtcError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","aliyunRtcError but player is destroyed");this.emit(Ze.crashLog,this.getCrashLog(it.aliyunRtcError,e));const t=this._getVideoLastIframeInfo();this.debug.log("JbPro","aliyunRtcError and pause player");const i=!1===this._opt.playFailedUseLastFrameShow;this._pause(i).then((()=>{this.emit(Ze.playFailedAndPaused,it.aliyunRtcError,t)})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.aliyunRtcError,t),this.debug.error("JbPro","aliyunRtcError and pause",e)}))})),this.player.once(it.decoderWorkerInitError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","decoderWorkerInitError but player is destroyed");this.emit(Ze.crashLog,this.getCrashLog(it.decoderWorkerInitError,e)),this.debug.log("JbPro","decoderWorkerInitError and pause player");const t=!1===this._opt.playFailedUseLastFrameShow;this._pause(t).then((()=>{this.emit(Ze.playFailedAndPaused,it.decoderWorkerInitError)})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.decoderWorkerInitError),this.debug.error("JbPro","decoderWorkerInitError and pause",e)}))})),this.player.once(it.videoElementPlayingFailedForWebrtc,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","videoElementPlayingFailedForWebrtc but player is destroyed");this.emit(Ze.crashLog,this.getCrashLog(it.videoElementPlayingFailedForWebrtc,e)),this.debug.log("JbPro","videoElementPlayingFailedForWebrtc and pause player");const t=!1===this._opt.playFailedUseLastFrameShow;this._pause(t).then((()=>{this.emit(Ze.playFailedAndPaused,it.videoElementPlayingFailedForWebrtc)})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.videoElementPlayingFailedForWebrtc),this.debug.error("JbPro","videoElementPlayingFailedForWebrtc and pause",e)}))})),this.player.once(it.videoInfoError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","videoInfoError but player is destroyed");this.emit(Ze.crashLog,this.getCrashLog(it.videoInfoError,e)),this.debug.log("JbPro","videoInfoError and pause player");const t=!1===this._opt.playFailedUseLastFrameShow;this._pause(t).then((()=>{this.emit(Ze.playFailedAndPaused,it.videoInfoError)})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.videoInfoError),this.debug.error("JbPro","videoInfoError and pause",e)}))})),this.player.once(Ze.webrtcStreamH265,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","webrtcStreamH265 but player is destroyed");this.debug.log("JbPro","webrtcStreamH265 and reset player and play");const t=this._opt.url,i=this._opt.playOptions;this._resetPlayer({isWebrtcH265:!0}).then((()=>{this.play(t,i).then((()=>{this.debug.log("JbPro","webrtcStreamH265 and reset player and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,Ze.webrtcStreamH265),this.debug.error("JbPro","webrtcStreamH265 and reset player and play error",e)}))})).catch((()=>{this.emit(Ze.playFailedAndPaused,Ze.webrtcStreamH265),this.debug.error("JbPro","webrtcStreamH265 and _resetPlayer error")}))})),this.player.once(it.hlsV2Mp4NotSupport,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","hlsV2Mp4NotSupport but player is destroyed");this.debug.log("JbPro","hlsV2Mp4NotSupport and reset player and play");const t=this._opt.url,i=this._opt.playOptions;this._resetPlayer({supportHls265:!1}).then((()=>{this.play(t,i).then((()=>{this.debug.log("JbPro","hlsV2Mp4NotSupport and reset player and play success")})).catch((e=>{this.emit(Ze.playFailedAndPaused,it.hlsV2Mp4NotSupport),this.debug.error("JbPro","hlsV2Mp4NotSupport and reset player and play error",e)}))})).catch((()=>{this.emit(Ze.playFailedAndPaused,it.hlsV2Mp4NotSupport),this.debug.error("JbPro","hlsV2Mp4NotSupport and _resetPlayer error")}))})),this.player.on(Ze.delayTimeout,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","delay timeout but player is destroyed");this.emit(Ze.crashLog,this.getCrashLog(Ze.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("JbPro",`delay timeout replay time is ${this._heartTimeoutReplayTimes} and heartTimeoutReplayTimes is ${this.player._opt.heartTimeoutReplayTimes}`),this.isDestroyed())return void(this.debug&&this.debug.warn("JbPro","delay timeout replay but player is destroyed"));this._heartTimeoutReplayTimes+=1;const e=this._opt.url,i=this._opt.playOptions;let s={};(this.player._opt.heartTimeoutReplayUseLastFrameShow||this.player._opt.replayUseLastFrameShow)&&(s=Object.assign({},s,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),this._resetPlayer(s).then((()=>{this.play(e,i).then((()=>{})).catch((e=>{this.emit(Ze.playFailedAndPaused,Ze.delayTimeout,t),this.debug.error("JbPro","delay timeout replay error",e)}))})).catch((e=>{this.emit(Ze.playFailedAndPaused,Ze.delayTimeout,t),this.debug.error("JbPro","delay timeout _resetPlayer error",e)}))}else{const e=!1===this._opt.playFailedUseLastFrameShow;this._pause(e).then((()=>{this.emit(Ze.playFailedAndPaused,Ze.delayTimeout,t),this.player&&(this.emit(Ze.delayTimeoutRetryEnd),this.emit(Ze.playFailedAndPaused,Ze.delayTimeoutRetryEnd)),this.debug.warn("JbPro",`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((e=>{this.emit(Ze.playFailedAndPaused,Ze.delayTimeout,t),this.debug.error("JbPro","delay timeout and pause error",e)}))}})),this.player.on(Ze.loadingTimeout,(e=>{if(this.emit(Ze.crashLog,this.getCrashLog(Ze.loadingTimeout,e)),this.isDestroyed())this.debug.log("JbPro","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("JbPro",`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("JbPro","delay timeout replay but player is destroyed"));this._loadingTimeoutReplayTimes+=1;const e=this._opt.url,t=this._opt.playOptions;this._resetPlayer().then((()=>{this.play(e,t).then((()=>{})).catch((e=>{this.emit(Ze.playFailedAndPaused,Ze.loadingTimeout),this.debug.error("JbPro","loading timeout replay error",e)}))})).catch((e=>{this.emit(Ze.playFailedAndPaused,Ze.loadingTimeout),this.debug.error("JbPro","loading timeout _resetPlayer error",e)}))}else{const e=!1===this._opt.playFailedUseLastFrameShow;this._pause(e).then((()=>{this.emit(Ze.playFailedAndPaused,Ze.loadingTimeout),this.player&&(this.emit(Ze.loadingTimeoutRetryEnd),this.emit(Ze.playFailedAndPaused,Ze.loadingTimeoutRetryEnd)),this.debug.log("JbPro",`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((e=>{this.emit(Ze.playFailedAndPaused,Ze.loadingTimeout),this.debug.error("JbPro","loading timeout and pause error",e)}))}})),this._hasLoaded()?this.player.play(t,h).then((()=>{d()})).catch((e=>{this.debug.error("JbPro","_hasLoaded() and play error",e),this.emit(Ze.crashLog,this.getCrashLog("_hasLoaded() and play error",e)),this.player&&this.player.pause().then((()=>{c(e)})).catch((e=>{c(e),this.debug.error("JbPro","_hasLoaded() and play error and next pause error",e)}))})):this.player.once(Ze.decoderWorkerInit,(()=>{this.player.play(t,h).then((()=>{d()})).catch((e=>{this.debug.error("JbPro","decoderWorkerInit and play error",e),this.emit(Ze.crashLog,this.getCrashLog("decoderWorkerInit and play error",e)),this.player&&this.player.pause().then((()=>{c(e)})).catch((e=>{c(e),this.debug.error("JbPro","decoderWorkerInit and play error and next pause error",e)}))}))}))},G=v&&fa(this._opt.supportHls265),W=m&&fa(this._opt.isWebrtcH265),H=v&&!!ea();if(G||W||g||u||I||H)this.debug.log("JbPro",`need reset player and\n isOldHls is ${G} and isOldWebrtc is ${W} and isAliyunRtc is ${g} and needResetPlayer(url change) is ${u} and isMpeg4 is ${I} and isHlsCanVideoPlay is ${H}`),this._resetPlayer({protocol:O,demuxType:N,isHls:v,isWebrtc:m,isWebrtcForZLM:B,isWebrtcForSRS:M,isWebrtcForOthers:U,isAliyunRtc:g,cryptoKey:h.cryptoKey||"",cryptoIV:h.cryptoIV||"",url:t}).then((()=>{j()})).catch((e=>{c("reset player error")}));else{const e={protocol:O,demuxType:N,isHls:v,isWebrtc:m,isAliyunRtc:g,isFlv:this._opt.isFlv,isFmp4:this._opt.isFmp4,isMpeg4:this._opt.isMpeg4,isNakedFlow:this._opt.isNakedFlow,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})),j()}}))}_resetDemuxType(e){this._opt.isFlv=!1,this._opt.isFmp4=!1,this._opt.isMpeg4=!1,this._opt.isNakedFlow=!1,this._opt.isHls=!1,this._opt.isWebrtc=!1,this._opt.isWebrtcForZLM=!1,this._opt.isWebrtcForSRS=!1,this._opt.isWebrtcForOthers=!1,this._opt.isAliyunRtc=!1,e&&(this._opt[e]=!0),"isFmp4"!==e&&(this._opt.isFmp4Private=!1)}resize(){this.debug.log("JbPro","resize()"),this.player&&this.player.resize()}setBufferTime(e){this.debug.log("JbPro",`setBufferTime() ${e}`),(e=Number(e))>10&&this.debug.warn("JbPro",`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("JbPro","setBufferTime() player is null")}setBufferDelayTime(e){this.debug.log("JbPro",`setBufferDelayTime() ${e}`),(e=Number(e))<.2&&this.debug.warn("JbPro",`setBufferDelayTime() buffer time delay is ${e} second, is too small`);const t=1e3*(e=hr(e,.2,100));this._opt.videoBufferDelay=t,this.player?this.player.updateOption({videoBufferDelay:t},!0):this.debug.warn("JbPro","setBufferDelayTime() player is null")}setRotate(e){this.debug.log("JbPro",`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("JbPro","setRotate() player is null")):this.debug.warn("JbPro",`setRotate() rotate is ${e} and this._opt.rotate is ${this._opt.rotate}`)}setMirrorRotate(e){this.debug.log("JbPro",`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("JbPro","setMirrorRotate() player is null")):this.debug.warn("JbPro",`setMirrorRotate() mirrorRotate is ${e} and this._opt.mirrorRotate is ${this._opt.mirrorRotate}`)}setAspectRatio(e){this.debug.log("JbPro",`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("JbPro","setAspectRatio() player is null")):this.debug.warn("JbPro",`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("JbPro","setKeepScreenOn()"),this._opt.keepScreenOn=!0,this.player?this.player.updateOption({keepScreenOn:!0}):this.debug.warn("JbPro","setKeepScreenOn() player is not ready")}setFullscreen(e){this.debug.log("JbPro",`setFullscreen() ${e}`);const t=!!e;this.player?this.player.fullscreen!==t?this.player.fullscreen=t:this.debug.warn("JbPro",`setFullscreen() fullscreen is ${t} and this.player.fullscreen is ${this.player.fullscreen}`):this.debug.warn("JbPro","setFullscreen() player is not ready")}setWebFullscreen(e){this.debug.log("JbPro",`setWebFullscreen() ${e}`);const t=!!e;this.player?this.player.webFullscreen=t:this.debug.warn("JbPro","setWebFullscreen() player is not ready")}screenshot(e,t,i,s){return this.debug.log("JbPro",`screenshot() ${e} ${t} ${i} ${s}`),this.player&&this.player.video?this.player.video.screenshot(e,t,i,s):(this.debug.warn("JbPro","screenshot() player is not ready"),null)}screenshotWatermark(e){return new Promise(((t,i)=>{this.debug.log("JbPro","screenshotWatermark()",e),this.player&&this.player.video?this.player.video.screenshotWatermark(e).then((e=>{t(e)})).catch((e=>{i(e)})):(this.debug.warn("JbPro","screenshotWatermark() player is not ready"),i("player is not ready"))}))}startRecord(e,t){return new Promise(((i,s)=>{if(this.debug.log("JbPro",`startRecord() ${e} ${t}`),!this.player)return this.debug.warn("JbPro","startRecord() player is not ready"),s("player is not ready");this.player.playing?(this.player.startRecord(e,t),i()):(this.debug.warn("JbPro","startRecord() player is not playing"),s("not playing"))}))}stopRecordAndSave(e,t){return new Promise(((i,s)=>{this.debug.log("JbPro",`stopRecordAndSave() ${e} ${t}`),this.player&&this.player.recording?this.player.stopRecordAndSave(e,t).then((e=>{i(e)})).catch((e=>{s(e)})):s("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===g?e=!this.isPlaying()&&!this.isLoading():this._opt.playType===A&&this.player&&(e=this.player.playbackPause),e}isPaused(){return this.isPause()}isPlaybackPause(){let e=!1;return this._opt.playType===A&&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("JbPro","clearBufferDelay()"),this.player?this.player.clearBufferDelay():this.debug.warn("JbPro","clearBufferDelay() player is not init")}setNetworkDelayTime(e){this.debug.log("JbPro",`setNetworkDelayTime() ${e}`),(e=Number(e))<1&&this.debug.warn("JbPro",`setNetworkDelayTime() network delay is ${e} second, is too small`);const t=1e3*(e=hr(e,1,100));this._opt.networkDelay=t,this.player?this.player.updateOption({networkDelay:t},!0):this.debug.warn("JbPro","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=ji;return this.player&&(e=this.player.loading?Ui:this.player.playing?Oi:Ni),e}getPlayType(){return this.player?this.player._opt.playType:g}togglePerformancePanel(e){this.debug.log("JbPro",`togglePerformancePanel() ${e}`);const t=this.player._opt.showPerformance;let i=!t;Mr(e)&&(i=e),i!==t?this.player?this.player.togglePerformancePanel(i):this.debug.warn("JbPro","togglePerformancePanel() failed, this.player is not init"):this.debug.warn("JbPro",`togglePerformancePanel() failed, showPerformance is prev: ${t} === now: ${i}`)}openZoom(){this.debug.log("JbPro","openZoom()"),this.player?this.player.zooming=!0:this.debug.warn("JbPro","openZoom() failed, this.player is not init")}closeZoom(){this.debug.log("JbPro","closeZoom()"),this.player?this.player.zooming=!1:this.debug.warn("JbPro","closeZoom() failed, this.player is not init")}isZoomOpen(){let e=!1;return this.player&&(e=this.player.zooming),e}expandZoom(){this.debug.log("JbPro","expandZoom()"),this.player&&this.player.zoom&&this.player.zooming?this.player.zoom.expandPrecision():this.debug.warn("JbPro","expandZoom() failed, zoom is not open or not init")}narrowZoom(){this.debug.log("JbPro","narrowZoom()"),this.player&&this.player.zoom&&this.player.zooming?this.player.zoom.narrowPrecision():this.debug.warn("JbPro","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){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(((i,s)=>{this.debug.log("JbPro","startTalk()",e,t),this._initTalk(t),this.talk.startTalk(e).then((()=>{i(),this.talk.once(Ze.talkStreamClose,(()=>{this.debug.warn("JbPro","talk stream close"),this.stopTalk().catch((e=>{}))})),this.talk.once(Ze.talkStreamError,(e=>{this.debug.warn("JbPro","talk stream error",e),this.stopTalk().catch((e=>{}))})),this.talk.once(Ze.talkStreamInactive,(()=>{this.debug.warn("JbPro","talk stream inactive"),this.stopTalk().catch((e=>{}))}))})).catch((e=>{s(e)}))}))}stopTalk(){return new Promise(((e,t)=>{if(this.debug.log("JbPro","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("JbPro","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("JbPro","setNakedFlowFps()",e),Br(e))return i("setNakedFlowFps() fps is empty");let s=Number(e);s=hr(s,1,100),this._opt.nakedFlowFps=s,this.player?this.player.updateOption({nakedFlowFps:s}):this.debug.warn("JbPro","setNakedFlowFps() player is null"),t()}))}getCrashLog(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(!this.player)return;const i=this.player.getAllStatsData(),s=this.player;let r={url:this._opt.url,playType:s.isPlayback()?"playback":"live",demuxType:s.getDemuxType(),decoderType:s.getDecodeType(),renderType:s.getRenderType(),videoInfo:{encType:"",width:"",height:""},audioInfo:{encType:"",sampleRate:"",channels:""},audioEngine:s.getAudioEngineType(),allTimes:i.pTs,timestamp:lr(),type:e,error:aa(t)||e};if(s.video){const e=s.video.videoInfo||{};r.videoInfo={encType:e.encType||"",width:e.width||"",height:e.height||""}}if(s.audio){const e=s.audio.audioInfo||{};r.audioInfo={encType:e.encType||"",sampleRate:e.sampleRate||"",channels:e.channels||""}}return r}updateDebugLevel(e){this.debug.log("JbPro","updateDebugLevel()",e),e===W||e===H?e!==this.player._opt.debugLevel?(this._opt.debugLevel=e,this.player?this.player.updateOption({debugLevel:e},!0):this.debug.warn("JbPro","updateDebugLevel() player is null")):this.debug.warn("JbPro",`updateDebugLevel() level is same, level: ${e}`):this.debug.warn("JbPro",`updateDebugLevel() level is not valid, level: ${e}`)}updateWatermark(e){this.debug.log("JbPro","updateWatermark()",e),this.player?this.player.updateWatermark(e):this.debug.warn("JbPro","updateWatermark() player is not init")}removeWatermark(){this.debug.log("JbPro","removeWatermark()"),this.player?this.player.removeWatermark():this.debug.warn("JbPro","removeWatermark() player is not init")}updateFullscreenWatermark(e){if(this.debug.log("JbPro","updateFullscreenWatermark()",e),Vr(e)){this._opt.fullscreenWatermarkConfig=e;const t=Or(this.$container,e);if(!t.watermark_txt)return void this.debug.warn("JbPro","fullscreenWatermarkConfig text is empty");this.watermark.load(t)}else this.debug.warn("JbPro",`updateFullscreenWatermark() config is not valid, config: ${e}`)}removeFullscreenWatermark(){this.debug.log("JbPro","removeFullscreenWatermark()"),this.watermark?this.watermark.remove():this.debug.warn("JbPro","removeFullscreenWatermark() watermark is not init")}faceDetectOpen(){this.debug.log("JbPro","faceDetectOpen()"),this.player?this.player.faceDetect(!0):this.debug.warn("JbPro","faceDetectOpen() player is not init")}faceDetectClose(){this.debug.log("JbPro","faceDetectClose()"),this.player?this.player.faceDetect(!1):this.debug.warn("JbPro","faceDetectClose() player is not init")}objectDetectOpen(){this.debug.log("JbPro","objectDetectOpen()"),this.player?this.player.objectDetect(!0):this.debug.warn("JbPro","objectDetectOpen() player is not init")}objectDetectClose(){this.debug.log("JbPro","objectDetectClose()"),this.player?this.player.objectDetect(!1):this.debug.warn("JbPro","objectDetectClose() player is not init")}sendWebsocketMessage(e){this.debug.log("JbPro","sendWebsocketMessage()",e),this.player?this.player.sendWebsocketMessage(e):this.debug.warn("JbPro","sendWebsocketMessage() player is not init")}addContentToCanvas(e){this.debug.log("JbPro","addContentToCanvas()"),this.player?this.player.addContentToCanvas(e):this.debug.warn("JbPro","addContentToCanvas() player is not init")}clearContentToCanvas(){this.debug.log("JbPro","clearContentToCanvas()"),this.player?this.player.addContentToCanvas([]):this.debug.warn("JbPro","clearContentToCanvas() player is not init")}setControlHtml(e){this.debug.log("JbPro","setControlHtml()",e),this.player?this.player.setControlHtml(e):this.debug.warn("JbPro","setControlHtml() player is not init")}clearControlHtml(){this.debug.log("JbPro","clearControlHtml()"),this.player?this.player.clearControlHtml():this.debug.warn("JbPro","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("JbPro","setSm4CryptoKey()",e),32===(e=""+e).length?(this._opt.sm4CryptoKey=e,this.player?this.player.updateOption({sm4CryptoKey:e},!0):this.debug.warn("JbPro","setSm4CryptoKey() player is null")):this.debug.warn("JbPro",`setSm4CryptoKey() key is invalid and length is ${e.length} !== 32`)}setM7sCryptoKey(e){this.debug.log("JbPro","setM7sCryptoKey()",e),e=""+e,this._opt.m7sCryptoKey=e,this.player?this.player.updateOption({m7sCryptoKey:e},!0):this.debug.warn("JbPro","setM7sCryptoKey() player is null")}setXorCryptoKey(e){this.debug.log("JbPro","setXorCryptoKey()",e),e=""+e,this._opt.xorCryptoKey=e,this.player?this.player.updateOption({xorCryptoKey:e},!0):this.debug.warn("JbPro","setXorCryptoKey() player is null")}updateLoadingText(e){this.debug.log("JbPro","updateLoadingText()",e),this.player?this.player.updateLoadingText(e):this.debug.warn("JbPro","updateLoadingText() player is null")}updateIsEmitSEI(e){this.debug.log("JbPro","updateIsEmitSEI()",e),this._opt.isEmitSEI=e,this.player?this.player.updateOption({isEmitSEI:e},!0):this.debug.warn("JbPro","updateIsEmitSEI() player is null")}getPTZCmd(e,t){if(this.debug.log("JbPro","getPTZCmd()",e),e)return this.player?hA({type:e,index:0,speed:t}):void this.debug.warn("JbPro","getPTZCmd() player is null");this.debug.warn("JbPro","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("JbPro","getExtendBtnList()");let e=[];return this.player?e=this.player.getExtendBtnList():this.debug.warn("JbPro","getExtendBtnList() player is null"),e}getFlvMetaData(){this.debug.log("JbPro","getFlvMetaData()");let e=null;return this.player?e=this.player.getMetaData():this.debug.warn("JbPro","getFlvMetaData() player is null"),e}updateAiFaceDetectInterval(e){this.debug.log("JbPro","updateAiFaceDetectInterval()",e);const t=1e3*(e=Number(e));this._opt.aiFaceDetectInterval=t,this.player?this.player.updateOption({aiFaceDetectInterval:t}):this.debug.warn("JbPro","updateAiFaceDetectInterval() player is null")}updateAiFaceDetectLevel(e){if(this.debug.log("JbPro","updateAiFaceDetectLevel()",e),!Ls[e])return void this.debug.warn("JbPro",`'updateAiFaceDetectLevel() level ${e} is invalid'`);const t=Ls[e];this._opt.aiFaceDetectWidth=t,this.player?(this.player.updateOption({aiFaceDetectWidth:t}),this.player.ai&&this.player.ai.updateFaceDetectorConfig({detectWidth:t})):this.debug.warn("JbPro","updateAiFaceDetectLevel() player is null")}updateAiObjectDetectInterval(e){this.debug.log("JbPro","updateAiObjectDetectInterval()",e);const t=1e3*(e=Number(e));this._opt.aiObjectDetectInterval=t,this.player?this.player.updateOption({aiObjectDetectInterval:t}):this.debug.warn("JbPro","updateAiObjectDetectInterval() player is null")}updateAiObjectDetectLevel(e){if(this.debug.log("JbPro","updateAiObjectDetectLevel()",e),!Is[e])return void this.debug.warn("JbPro",`'updateAiObjectDetectLevel() level ${e} is invalid'`);const t=Is[e];this._opt.aiObjectDetectWidth=t,this.player?(this.player.updateOption({aiObjectDetectWidth:t}),this.player.ai&&this.player.ai.updateObjectDetectorConfig({detectWidth:t})):this.debug.warn("JbPro","updateAiObjectDetectLevel() player is null")}setCryptoKeyUrl(e){this.debug.log("JbPro","setCryptoKeyUrl()",e),e&&(this._opt.cryptoKeyUrl=e)}showErrorMessageTips(e){this.debug.log("JbPro","showErrorMessageTips()",e),e&&(this.player?this.player.showTipsMessageByContent(e):this.debug.warn("JbPro","showErrorMessageTips() player is null"))}hideErrorMessageTips(){this.debug.log("JbPro","hideErrorMessageTips()"),this.player?this.player.hideTipsMessage():this.debug.warn("JbPro","hideErrorMessageTips() player is null")}}mA.ERROR=it,mA.EVENTS=et,window.JessibucaPro=mA,window.WebPlayerPro=mA;dh('.jessibuca-multi-container .jessibuca-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)}.jessibuca-multi-container .jessibuca-multi-player-container-v2 .jessibuca-multi-player{overflow:hidden;position:relative;width:100%;height:100%}.jessibuca-multi-container .jessibuca-multi-player-container-v2 .jessibuca-multi-player .jessibuca-multi-player-draw-window{position:absolute;z-index:1;width:calc(100% - 2px);height:calc(100% - 2px);color:#fff;transition:all .25s}.jessibuca-multi-container .jessibuca-multi-player-container-v2 .jessibuca-multi-player .jessibuca-multi-player-video-window{position:absolute;left:1px;top:1px;z-index:2;width:calc(100% - 2px);height:calc(100% - 2px)}.jessibuca-multi-container .jessibuca-multi-player[fullscreen="1"]{grid-column-start:1;grid-column-end:9;grid-row-start:1;grid-row-end:9}.jessibuca-multi-container .jessibuca-multi-layout-6 .jessibuca-multi-player[order="0"]{grid-column-start:1;grid-column-end:3;grid-row-start:1;grid-row-end:3}.jessibuca-multi-container .jessibuca-multi-layout-9 .jessibuca-multi-player[order="0"]{grid-column-start:1;grid-column-end:4;grid-row-start:1;grid-row-end:4}');class gA extends t{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),this._opt={},Object.keys(e).forEach((t=>{if(void 0===e[t])throw new Error(`Jessibuca-pro-multi option "${t}" can not be undefined`)}));const t=ha(ns);this._opt=Object.assign({},t,e),this.LOG_TAG="jessibucaProMulti";let i=e.container;if("string"==typeof e.container&&(i=document.querySelector(e.container)),!i)throw new Error("Jessibuca-pro-multi need container option");if("CANVAS"===i.nodeName||"VIDEO"===i.nodeName)throw new Error(`Jessibuca-pro-multi container type can not be ${i.nodeName} type`);i.classList.add("jessibuca-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 Gs(this),this.events=new Ta(this),this._opt.draggable?this._initWindows$2():this._initWindows(),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("jessibuca-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 s=new mA({...i,isMulti:!0,multiIndex:t,container:e.$player});return Object.keys(et).forEach((e=>{s.on(et[e],(i=>{this.emit(e,t,i)}))})),s.on(Ze.close,(()=>{this.emit(Ze.close,t),e.player=null})),s}_initWindows(){const e=this._getContainerRect(),t=e.width,i=e.height;let s="";const r=this._opt.split,a=t%r,o=i%r,n=(t-a-2*r)/r,l=(i-o-2*r)/r,h=(t-a)/r,d=(i-o)/r;let c=0,u=0,p=0,f=0;for(let e=0;e<this.maxWindowSize;e++)c=n+(e%r==r-1?a:0),u=l+(e+r>=Math.pow(r,2)?o:0),p=h+(e%r==r-1?a:0),f=d+(e+r>=Math.pow(r,2)?o:0),s+=`\n <div class="jessibuca-multi-player" wid="${e}" style='float: left;position:relative;overflow: hidden; background-color:${this._opt.style.background};width: ${p+"px"};height: ${f+"px"}'>\n <div class="jessibuca-multi-player-draw-window" wid="${e}" style='position:absolute; z-index: 1; width:${c+"px"}; height:${u+"px"};border: 1px solid ${this._opt.style.border}'></div>\n <div class="jessibuca-multi-player-video-window" wid="${e}" style='position:absolute;left: 1px;top:1px; z-index: 2; width:${c+"px"}; height:${u+"px"};'></div>\n </div>\n `;const m=`<div class="jessibuca-multi-player-container" style="overflow: hidden;width:100%; height:100%; position: relative;">${s}</div>`;this.$container.innerHTML=m;const g=this.$container.querySelectorAll(".jessibuca-multi-player");for(let e=0;e<this.maxWindowSize;e++){const t=g[e],i=t.querySelector(".jessibuca-multi-player-draw-window"),s=t.querySelector(".jessibuca-multi-player-video-window"),r=Er();ma(t,"uuid",r),this.windowList[e]={uuid:r,isContainerFullscreen:!1,$playerContainer:t,$playerBorder:i,$player:s,$playerContainerEvents:[],player:null}}for(let e=this._getCurrentMaxSplit();e<this.maxWindowSize;e++){const t=this.windowList[e];t.$player.style.display="none",t.$playerBorder.style.display="none",t.$playerContainer.style.width="0",t.$playerContainer.style.height="0"}}_initWindows$2(){const e=this._getContainerRect();e.width,e.height;let t="";const i=this._opt.split,s=i>1&&this._opt.draggable||!1;for(let e=0;e<this.maxWindowSize;e++)t+=`\n <div class="jessibuca-multi-player" draggable="${s}" wid="${e}" order='${e}' style='order:${e};background-color:${this._opt.style.background};'>\n <div class="jessibuca-multi-player-draw-window" wid="${e}"></div>\n <div class="jessibuca-multi-player-video-window" wid="${e}"></div>\n </div>\n `;const r=`<div class="jessibuca-multi-player-container-v2" style="--split:${i}">\n ${t}\n </div>`;this.$container.innerHTML=r,this.$multiContainer=this.$container.querySelector(".jessibuca-multi-player-container-v2");const a=this.$container.querySelectorAll(".jessibuca-multi-player");for(let e=0;e<this.maxWindowSize;e++){const t=a[e],i=t.querySelector(".jessibuca-multi-player-draw-window"),s=t.querySelector(".jessibuca-multi-player-video-window"),r=Er();ma(t,"uuid",r),this.windowList[e]={uuid:r,isContainerFullscreen:!1,$playerContainer:t,$playerBorder:i,$player:s,$playerContainerEvents:[],player:null}}for(let e=this._getCurrentMaxSplit();e<this.maxWindowSize;e++){this.windowList[e].$player.style.display="none"}}_initEvents(){const{proxy:e}=this.events;this.windowList.forEach(((t,i)=>{const s=t.$playerContainer,r=e(s,"click",(e=>{const t=ga(s,"uuid"),i=this._findWindowItemIndexByUuid(t);if(this.emit(ls.selected,i,e),this.getSelectedWindowUuid()===t){if(this._getWindowItem(t).isContainerFullscreen)return}1!==this._opt.split&&this._handleWindowSelect(i)})),a=e(s,"dblclick",(e=>{const t=ga(s,"uuid"),i=this._findWindowItemIndexByUuid(t);this.emit(ls.dblSelected,i,e),this._opt.supportDblclickContainerFullscreen&&1!==this._opt.split&&this._handleWindowContainerFullscreen(i)})),o=e(s,"mouseup",(e=>{const t=ga(s,"uuid"),i=this._findWindowItemIndexByUuid(t);this.emit(ls.mouseup,i,e)})),n=e(s,"mouseover",(e=>{const t=ga(s,"uuid"),i=this._findWindowItemIndexByUuid(t);this.emit(ls.mouseover,i,e)})),l=e(s,"mouseout",(e=>{const t=ga(s,"uuid"),i=this._findWindowItemIndexByUuid(t);this.emit(ls.mouseout,i,e)})),h=e(s,"dragover",(e=>{e.preventDefault()})),d=e(s,"dragenter",(e=>{const t=ga(s,"uuid"),i=this._findWindowItemIndexByUuid(t);this.emit(ls.dragenter,i,e)})),c=e(s,"dragleave",(e=>{const t=ga(s,"uuid"),i=this._findWindowItemIndexByUuid(t);this.emit(ls.dragleave,i,e)})),u=e(s,"drop",(e=>{const t=ga(s,"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=s.style.order,e.setAttribute("order",e.style.order),s.setAttribute("order",t),s.style.order=t,this.debug.log(this.LOG_TAG,`player Drop ${t} -> ${e.style.order}`),this._sortWindows()}this.emit(ls.drop,i,e)}));if(t.$playerContainerEvents=[r,o,n,l,a,h,d,c,u],this._opt.draggable){const i=e(s,"dragstart",(e=>{const t=ga(s,"uuid"),i=this._findWindowItemIndexByUuid(t);this._handleWindowSelect(i),this.startDragWindowItem=this._getWindowItem(i),this.emit(ls.dragstart,i,e,s)}));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,s=this._opt.split,r=t%s,a=i%s,o=(t-r-2*s)/s,n=(i-a-2*s)/s,l=(t-r)/s,h=(i-a)/s;let d=this._getCurrentMaxSplit();for(let e=0;e<d;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 d=t.$playerBorder,c=t.$player,u=o+(e%s==s-1?r:0),p=n+(e+s>=Math.pow(s,2)?a:0),f=l+(e%s==s-1?r:0),m=h+(e+s>=Math.pow(s,2)?a:0);i.style.width=f+"px",i.style.height=m+"px",i.style.display="block",c.style.width=u+"px",c.style.height=p+"px",c.style.display="block",d.style.width=u+"px",d.style.height=p+"px",d.style.display="block",t.player&&t.player.resize()}if(this.specialLayoutType){const e=this.windowList[0],t=e.$playerContainer,i=e.$player,s=e.$playerBorder,r=t.style.width.replace("px",""),a=t.style.height.replace("px",""),o=i.style.width.replace("px",""),n=i.style.height.replace("px","");let l,h,c,u;this.specialLayoutType===hs?(l=2*r,h=2*a,c=2*o+2,u=2*n+2):this.specialLayoutType===ds&&(l=3*r,h=3*a,c=3*o+4,u=3*n+4),t.style.width=l+"px",t.style.height=h+"px",i.style.width=c+"px",i.style.height=u+"px",s.style.width=c+"px",s.style.height=u+"px",e.player&&e.player.resize(),d=this._getSpecialMaxSplit()}for(let e=d;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="jessibuca-multi-layout-6",i="jessibuca-multi-layout-9";this.$multiContainer.classList.remove(t,i),this.specialLayoutType===hs?this.$multiContainer.classList.add(t):this.specialLayoutType===ds&&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(Mr(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,s=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=s+"px",i.$player.style.width=t+"px",i.$player.style.height=s+"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(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,t=this._getContainerRect(),i=0;const s=setInterval((()=>{const r=Ws.isFullscreen,a=this._getContainerRect(),o={width:screen.width,height:screen.height};this.debug.log(this.LOG_TAG,`isInFullscreen ${r} , checkRectInterval times : ${i} nowRect:${JSON.stringify(a)}, prevRect:${JSON.stringify(t)} ,window screen rect:${JSON.stringify(o)}`);const n=a.width===t.width&&a.height===t.height,l=!r||o.width-a.width<10&&o.height-a.height<10;if(n&&l||i>=e)return this.resize(),void clearInterval(s);t=a,i++}),1e3)}_listenFullscreenChange(){try{const e=e=>{Yr(e)===this.$container&&(this.emit(et.multiFullscreen,Ws.isFullscreen),Ws.isFullscreen||-1!==window.navigator.userAgent.indexOf("Edg")?this._handleFullscreenResize():this.resize())};Ws.on("change",e),this.events.destroys.push((()=>{Ws.off("change",e)}))}catch(e){}}play(e,t,i){return new Promise(((s,r)=>{(xr(t)||Jr(t))&&(i=t,t={});const a=()=>{const i=this._createPlayer(o);o.player=i,i.play(e,t).then((()=>{s()})).catch((e=>{r(e)}))},o=this._getWindowItem(i);o?o.player?o.player.destroy().then((()=>{o.player=null,a()})).catch((()=>{})):a():r(`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(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1?arguments[1]:void 0;return new Promise(((i,s)=>{const r=this._getWindowItem(t);r&&r.player?r.player.pause(e).then((()=>{i()})).catch((e=>{s(e)})):s(`pause() windowIndex ${t} is not exist`)}))}close(e){return new Promise(((t,i)=>{const s=this._getWindowItem(e);s&&s.player?s.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(((s,r)=>{const a=this._getWindowItem(i);a&&a.player?a.player.startRecord(e,t).then((()=>{s()})).catch((e=>{r(e)})):(this.debug.warn(this.LOG_TAG,`startRecord() windowIndex ${i} is not exist`),r(`windowIndex ${i} is not exist`))}))}stopRecordAndSave(e,t,i){return new Promise(((s,r)=>{const a=this._getWindowItem(i);a&&a.player?a.player.stopRecordAndSave(e,t).then((e=>{s(e)})).catch((e=>{r(e)})):(this.debug.warn(this.LOG_TAG,`stopRecordAndSave() windowIndex ${i} is not exist`),r(`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 s=this._getWindowItem(e);s?s.player&&s.player.destroy().then((()=>{s.player=null,t()})).catch((e=>{i(e)})):(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{Ws.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{Ws.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){if(this.debug.log(this.LOG_TAG,"arrangeWindow",e),!e)return void this.debug.warn(this.LOG_TAG,`arrangeWindow() split ${e} is not valid`);if([hs,ds].includes(e))this._arrangeSpecialWindow(e);else{if(this._opt.split===e&&null===this.specialLayoutType)return void this.debug.warn(this.LOG_TAG,`arrangeWindow() split ${e} is not changed`);this.specialLayoutType=null,this._arrangeWindow(e)}}_arrangeWindow(e){(e=Tr(e))<1||!xr(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===ds||this._opt.maxSplit<=2&&e===hs?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===hs?this._arrangeWindow(3):e===ds?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===hs?e=9:this.specialLayoutType===ds&&(e=16),e}return this._opt.split*this._opt.split}_getSpecialMaxSplit(){let e=0;return this.specialLayoutType===hs?e=6:this.specialLayoutType===ds&&(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()||[],s=e.findIndex((e=>e===i.uuid));if(s<e.length-1){const i=s+1,r=this._findWindowItemByUuid(e[i]);r&&(t={index:i,$player:r.$player,$playerContainer:r.$playerContainer,player:r.player,uuid:r.uuid})}}return t}getPrevWindowItem(e){let t=null,i=this._getWindowItem(e);if(i){const e=this._getWindowUuidList()||[],s=e.findIndex((e=>e===i.uuid));if(s>0){const i=s-1,r=this._findWindowItemByUuid(e[i]);r&&(t={index:i,$player:r.$player,$playerContainer:r.$playerContainer,player:r.player,uuid:r.uuid})}}return t}_getWindowItem(e){let t=null;const i=Jr(e)&&16===e.length;return t=i||!xr(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))}}gA.MULTI_EVENTS=ls,gA.EVENTS=Ze,gA.ERROR=it,window.JessibucaProMulti=gA,window.WebPlayerProMulti=gA}));