2025-12-30 13:38:34 +08:00

2 lines
193 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).WSPlayer={})}(this,function(e){"use strict";var t=Object.defineProperty,s=(e,s,i)=>((e,s,i)=>s in e?t(e,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[s]=i)(e,"symbol"!=typeof s?s+"":s,i);const i={websocketPorts:{realmonitor:"realmonitor-websocket",playback:"playback-websocket",realmonitor_ws:"9100",playback_ws:"9320",realmonitor_wss:"9102",playback_wss:"9322"},errorVideoInfoCode:{224:401,227:404,253:503},errorVideoInfo:{100:"浏览器资源不足",101:"当前浏览器不支持硬解码",102:"硬解码播放失败",103:"硬解码播放延时超过8秒",104:"硬解码失败",201:"当前音频无法播放",202:"安全证书验证失败",203:"文件播放完成",205:"设备忙线",210:"请求设备异常",211:"连接异常断开",223:"非法请求视频",224:"码流token过期",226:"码流禁止访问",227:"未查询到设备码流",248:"当前传输方式不支持",250:"服务器内部报错",253:"当前拉流服务不正确",254:"网络异常",258:"设备账户锁定,无法拉流",401:"码流token过期",404:"未查询到设备码流",405:"播放超时",406:"视频流类型解析失败,请检查通道配置",407:"请求超时",408:"请求超时",409:"服务未推送码流",410:"视频流异常断开",411:"录像播放完成",457:"时间设置错误",503:"当前拉流服务不正确",504:"对讲失败",701:"Chrome版本低请升级到最新的Chrome版本",702:"Firefox版本低请升级到最新的Firefox版本",703:"Edge版本低请升级到最新的Edge版本",defaultErrorMsg:"播放失败,请检查配置"},errorInfo:{101:"所选通道离线,无法播放",102:"登录权限过期查询实时预览rtsp失败",103:"获取实时预览rtsp失败",104:"操作失败,请稍后重试",105:"通道休眠,正在唤醒中,请稍后再试",106:"请传入rtsp地址和websocket地址",107:"当前未传records录像文件, 将无法拖动进度条",108:"请求超时,请稍后重试",201:"所选通道未查询到录像文件",202:"查询录像文件列表失败",203:"查询录像rtsp失败",204:"{0}倍速无法播放音频",205:"通道休眠,正在唤醒中,请稍后再试",206:"当前倍速不支持",301:"正在对讲,无法关闭音频",302:"其他设备对讲中,无法开启音频",303:"其他设备对讲中,无法开启对讲",304:"查询对讲rtsp失败",305:"http协议不支持对讲",306:"设备对讲失败",307:"不支持PCM音频格式对讲",308:"不支持ARM音频格式对讲",309:"不支持G711u音频格式对讲",310:"不支持G726音频格式对讲",311:"不支持AAC音频格式对讲",312:"不支持G722音频格式对讲",402:"该用户无播放权限",501:"解码库未初始化完成,请稍后播放!",502:"解码库未初始化完成,请稍后对讲!",503:"请检查创建播放器时,播放器容器是否存在",601:"所操作播放器不存在",602:"所选播放器正在本地录像中,不可重复本地录像",603:"所选播放器未播放录像,不可本地录像",604:"所选播放器未开始本地录像,不可操作关闭本地录像",605:"时间跳转播放传参错误",606:"设置画面实际比例/画面平铺传参错误",607:"实时预览不支持倍速播放",608:"需传入正确的{0}方法:{1}",609:"超出当前设置最大窗口布局数量",610:"操作自定义窗口布局失败:{0}",611:"实时预览不支持播放方法",612:"实时预览不支持暂停方法",613:"实时预览不支持跳转播放",614:"当前窗口未播放实时预览画面, 无法进行对讲",701:"云台被用户{0}锁定,无法操作",702:"控制云台三维定位失败{0}",703:"控制云台{0}{1}失败{2}",704:"控制云台方向失败{0}",30000001:"SDP初始化失败",30000002:"接入服务内部错误(信令建立过程)",30000101:"请求失败",30000102:"拉流过程异常中断",30000103:"接入服务内部异常(码流传输过程)",30000104:"老设备回放时登入设备失败",30000105:"设备离线",30000106:"通道离线",30000107:"设备被删除",30000108:"通道被删除",30001001:"创建子链接失败",30001002:"设备不支持",30001003:"设备资源不足",30001004:"查询不到录像",30001005:"设备返回超时",30001006:"超过最大连接数",30002001:"拒绝对讲",30002002:"对讲被其他客户端打开,请稍后重试",30002003:"资源冲突",30002004:"不支持的语音编码格式",30002005:"无权限",30002006:"请求对讲失败",30002007:"请求喊话失败",30003001:"码率超限"},windowDefaultCustomDivision:{2:[{lStep:0,tStep:0,wStep:50,hStep:100},{lStep:50,tStep:0,wStep:50,hStep:100}],3:[{wStep:50,hStep:100,tStep:0,lStep:0},{wStep:50,hStep:50,tStep:0,lStep:50},{wStep:50,hStep:50,tStep:50,lStep:50}],6:[{wStep:66,hStep:66,tStep:0,lStep:0,selectIndex:0},{wStep:34,hStep:33,tStep:0,lStep:66,selectIndex:1},{wStep:34,hStep:33,tStep:33,lStep:66,selectIndex:2},{wStep:33,hStep:34,tStep:66,lStep:0,selectIndex:3},{wStep:33,hStep:34,tStep:66,lStep:33,selectIndex:4},{wStep:34,hStep:34,tStep:66,lStep:66,selectIndex:5}],8:[{wStep:75,hStep:75,tStep:0,lStep:0,selectIndex:0},{wStep:25,hStep:25,tStep:0,lStep:75,selectIndex:1},{wStep:25,hStep:25,tStep:25,lStep:75,selectIndex:2},{wStep:25,hStep:25,tStep:50,lStep:75,selectIndex:3},{wStep:25,hStep:25,tStep:75,lStep:0,selectIndex:4},{wStep:25,hStep:25,tStep:75,lStep:25,selectIndex:5},{wStep:25,hStep:25,tStep:75,lStep:50,selectIndex:6},{wStep:25,hStep:25,tStep:75,lStep:75,selectIndex:7}]},iconConfig:[{key:"refreshReplay",labelKey:"wsPlayer.refreshReplay",buttonParentClass:"ws-refresh-replay",buttonIconClass:"opt-icon refresh-replay-icon"},{key:"drawTriangle",labelKey:"wsPlayer.drawTriangle",buttonParentClass:"ws-draw-triangle",buttonIconClass:"opt-icon draw-triangle-icon off"},{key:"talkIcon",labelKey:"wsPlayer.talk",buttonParentClass:"ws-talk",buttonIconClass:"opt-icon talk-icon off"},{key:"localRecordIcon",labelKey:"wsPlayer.recording",buttonParentClass:"ws-record",buttonIconClass:"opt-icon record-icon"},{key:"audioIcon",labelKey:"wsPlayer.sound",buttonParentClass:"ws-audio",buttonIconClass:"opt-icon audio-icon off"},{key:"snapshotIcon",labelKey:"wsPlayer.capture",buttonParentClass:"ws-capture",buttonIconClass:"opt-icon capture-icon"}],_translate(e,t,s){Object.keys(this[e]).forEach(i=>{let r=t.$t(`${s}${i}`);r&&(this[e][i]=r)})},updateLocale(e){this._translate("errorInfo",e,"wsPlayer.error."),this._translate("errorVideoInfo",e,"wsPlayer.play.error."),this.iconConfig.forEach(t=>{t.label=e.$t(t.labelKey)})},transParam:8192,contentPadding:16,tagHeight:50,contentTop:64,lineHeight:24},r="Opera",a="Chrome",l="Firefox",n="Edge",o="Edg",c="IE",d="Safari",h="UOS",p="Qaxbrowser";function y(e){const{userAgent:t}=navigator;return t.split(e)[1].split(".")[0].slice(1)}function u(e){return"[object Object]"===toString.call(e)}function m(){return function(){let e=new Date;return[e.getFullYear(),e.getMonth()+1,e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()]}().join("_")}const w={checkBrowser:function(){const e=function(){const{userAgent:e}=navigator;return e.includes("UOS")?a:e.includes("Qaxbrowser")?p:e.includes("Edge")?n:e.includes("Edg")?o:e.includes("Firefox")?l:e.includes("Chrome")?a:e.includes("Safari")?d:e.includes("compatible")&&e.includes("MSIE")&&e.includes("Opera")?c:e.includes("Opera")?r:""}(),t=navigator.userAgent.includes("x64")||navigator.userAgent.includes("x86_64")||navigator.userAgent.includes("aarch64")?64:32,s=y(e);let i=!1,u=0;switch(e){case a:i=s>=91&&64===t,u=701;break;case l:i=s>=97,u=702;break;case n:case o:i=s>=91,u=703;break;case h:i=y("Chrome")>=91,u=704;break;case p:i=y("Chrome")>=91,u=705;break;default:i=0}return{isVersionCompliance:i,browserType:e,errorCode:u}},validFunction:function(e){return"[object Function]"===toString.call(e)},mergeObject:function e(){let t={};for(let s=0;s<arguments.length;s++){let i=arguments[s];for(let s in i){let r=i[s];"localeI18n"===s?t[s]=r:u(r)?t[s]=e(r):null!=r&&(t[s]=r)}}return t},getDateFormatByUnderline:m,throttle:function(e,t){let s;return function(){s||(e.apply(this,arguments),s=setTimeout(()=>{s=0},t))}},debounce:function(e,t){let s;return function(){s&&clearTimeout(s),s=setTimeout(()=>{e.apply(this,arguments),s=0},t)}},getToday12Time:function(){let e=new Date;return e.setHours(12,0,0),e.getTime()/1e3},uint8ArraysToFileUrl:function(e,t="video/mp4"){let s=e.map(e=>e.buffer),i=e.map(e=>e.offset);const r=s.reduce((e,t)=>e+t.length,0),a=new Uint8Array(r);s.forEach((e,t)=>{let s=i[t];if(!(e instanceof Uint8Array))throw new TypeError("Expected an ArrayBuffer");a.set(e,s)});const l=new Blob([a],{type:t});return{blob:l,file:new File([l],"video_"+m()+("video/mp4"===t?".mp4":".dav"),{type:t}),blobUrl:URL.createObjectURL(l)}},watchDomObserver:function(e,t){const s=new ResizeObserver(e=>{e.forEach(e=>{t&&t()})});return s.observe(e[0]),s}};var f=function(){return f=Object.assign||function(e){for(var t,s=1,i=arguments.length;s<i;s++)for(var r in t=arguments[s])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},f.apply(this,arguments)},P={lines:12,length:7,width:5,radius:10,scale:1,corners:1,color:"#000",fadeColor:"transparent",animation:"spinner-line-fade-default",rotate:0,direction:1,speed:1,zIndex:2e9,className:"spinner",top:"50%",left:"50%",shadow:"0 0 1px transparent",position:"absolute"},g=function(){function e(e){void 0===e&&(e={}),this.opts=f(f({},P),e)}return e.prototype.spin=function(e){return this.stop(),this.el=document.createElement("div"),this.el.className=this.opts.className,this.el.setAttribute("role","progressbar"),S(this.el,{position:this.opts.position,width:0,zIndex:this.opts.zIndex,left:this.opts.left,top:this.opts.top,transform:"scale("+this.opts.scale+")"}),e&&e.insertBefore(this.el,e.firstChild||null),function(e,t){var s=Math.round(t.corners*t.width*500)/1e3+"px",i="none";!0===t.shadow?i="0 2px 4px #000":"string"==typeof t.shadow&&(i=t.shadow);for(var r=function(e){for(var t=/^\s*([a-zA-Z]+\s+)?(-?\d+(\.\d+)?)([a-zA-Z]*)\s+(-?\d+(\.\d+)?)([a-zA-Z]*)(.*)$/,s=[],i=0,r=e.split(",");i<r.length;i++){var a=r[i].match(t);if(null!==a){var l=+a[2],n=+a[5],o=a[4],c=a[7];0!==l||o||(o=c),0!==n||c||(c=o),o===c&&s.push({prefix:a[1]||"",x:l,y:n,xUnits:o,yUnits:c,end:a[8]})}}return s}(i),a=0;a<t.lines;a++){var l=~~(360/t.lines*a+t.rotate),n=S(document.createElement("div"),{position:"absolute",top:-t.width/2+"px",width:t.length+t.width+"px",height:t.width+"px",background:v(t.fadeColor,a),borderRadius:s,transformOrigin:"left",transform:"rotate("+l+"deg) translateX("+t.radius+"px)"}),o=a*t.direction/t.lines/t.speed;o-=1/t.speed;var c=S(document.createElement("div"),{width:"100%",height:"100%",background:v(t.color,a),borderRadius:s,boxShadow:x(r,l),animation:1/t.speed+"s linear "+o+"s infinite "+t.animation});n.appendChild(c),e.appendChild(n)}}(this.el,this.opts),this},e.prototype.stop=function(){return this.el&&("undefined"!=typeof requestAnimationFrame?cancelAnimationFrame(this.animateId):clearTimeout(this.animateId),this.el.parentNode&&this.el.parentNode.removeChild(this.el),this.el=void 0),this},e}();function S(e,t){for(var s in t)e.style[s]=t[s];return e}function v(e,t){return"string"==typeof e?e:e[t%e.length]}function x(e,t){for(var s=[],i=0,r=e;i<r.length;i++){var a=r[i],l=I(a.x,a.y,t);s.push(a.prefix+l[0]+a.xUnits+" "+l[1]+a.yUnits+a.end)}return s.join(", ")}function I(e,t,s){var i=s*Math.PI/180,r=Math.sin(i),a=Math.cos(i);return[Math.round(1e3*(e*a+t*r))/1e3,Math.round(1e3*(-e*r+t*a))/1e3]}const T={zhCN:{"common.more":"更多","common.close":"关闭","common.ok":"确定","common.cancel":"取消","common.reset":"重置","storagePlan.stream.main":"主码流","video.player.sub.stream":"辅码流{0}","video.player.ptz.down":"下","video.player.ptz.left":"左","video.player.ptz.lower.left":"左下","video.player.ptz.lower.right":"右下","video.player.ptz.right":"右","video.player.ptz.up":"上","video.player.ptz.upper.left":"左上","video.player.ptz.upper.right":"右上","inspec.ptz.position1":"三维定位","video.player.ptz.zoom":"变倍","video.player.ptz.focus":"聚焦","video.player.ptz.halo":"光圈","channel.videoSource.video":"视频","wsPlayer.decode.software":"软解","wsPlayer.decode.hardware":"硬解","wsPlayer.proxy":"代理模式, 此模式不做自动处理","wsPlayer.recording":"本地录像","wsplayer.more":"更多","wsPlayer.fastForward":"快进","wsPlayer.fastBackward":"快退","wsPlayer.chromeMemoryOut":"浏览器资源不足, 请等待3-5秒后重试","wsPlayer.request.realtime.preview.interface":"请求实时预览接口","wsPlayer.request.realtime.preview.interface.error.tip":"在传入的 {0} 方法上resolve 返回的值应该为一个icc返回的标准对象","wsPlayer.request.recording.interface":"请求录像接口","wsPlayer.request.talk.interface":"请求对讲接口","wsPlayer.screen.custom.split":"自定义","wsPlayer.screen.four":"四分屏","wsPlayer.screen.full":"全屏","wsPlayer.screen.nine":"九分屏","wsPlayer.screen.one":"单屏","wsPlayer.screen.selfAdaption":"实际比例","wsPlayer.screen.split":"{0}分屏","wsPlayer.screen.stretching":"画面铺满","wsPlayer.speed.sub":"倍速-","wsPlayer.speed.add":"倍速+","wsPlayer.drawTriangle":"智能规则线","wsPlayer.refreshReplay":"刷新重播","wsPlayer.sound":"音频","wsPlayer.talk":"对讲","wsPlayer.establishTalk":"正在建立对讲...","wsPlayer.talking":"对讲中...","wsPlayer.localRecording":"录制视频中...","wsPlayer.income.format.error":"传入格式错误,请重新传入","wsPlayer.one.click.off":"一键关闭","wsPlayer.pause":"暂停","wsPlayer.play":"播放","ws.device.awakening":"{0}通道正在唤醒中","wsPlayer.auto.recognition.failed":"自动识别失败,存在端口为非默认端口,开始通过参数判断,请注意传参!","wsPlayer.capture":"抓图","wsPlayer.video":"视频","wsPlayer.current.window.cannot.be.merged":"当前窗口无法被合并","wsPlayer.custom.player.max.support.tip":"自定义播放器只支持最大分割{0}个窗口","wsPlayer.drag.tip":"不能拖拽到当前位置,请重新拖拽","wsPlayer.play.error.101":"当前浏览器不支持硬解码","wsPlayer.play.error.102":"硬解码播放失败","wsPlayer.play.error.103":"硬解码播放延时超过8秒","wsPlayer.play.error.104":"硬解码失败","wsPlayer.play.error.201":"当前音频无法播放","wsPlayer.play.error.202":"安全证书验证失败","wsPlayer.play.error.203":"文件播放完成","wsPlayer.play.error.205":"设备忙线","wsPlayer.play.error.210":"请求设备异常","wsPlayer.play.error.211":"连接异常断开","wsPlayer.play.error.223":"非法请求视频","wsPlayer.play.error.224":"码流token过期","wsPlayer.play.error.226":"码流禁止访问","wsPlayer.play.error.227":"未查询到设备码流","wsPlayer.play.error.248":"当前传输方式不支持","wsPlayer.play.error.250":"服务器内部报错","wsPlayer.play.error.253":"当前拉流服务不正确","wsPlayer.play.error.254":"网络异常","wsPlayer.play.error.258":"设备账户锁定,无法拉流","wsPlayer.play.error.401":"码流token过期","wsPlayer.play.error.402":"该用户无播放权限","wsPlayer.play.error.404":"未查询到设备码流","wsPlayer.play.error.405":"播放超时","wsPlayer.play.error.406":"视频流类型解析失败,请检查通道配置","wsPlayer.play.error.407":"请求超时","wsPlayer.play.error.408":"请求超时","wsPlayer.play.error.409":"服务未推送码流","wsPlayer.play.error.410":"视频流异常断开","wsPlayer.play.error.411":"录像已播放完成","wsPlayer.play.error.457":"时间设置错误","wsPlayer.play.error.503":"当前拉流服务不正确","wsPlayer.play.error.504":"对讲失败","wsPlayer.play.error.701":"Chrome版本低请升级到最新的Chrome版本","wsPlayer.play.error.702":"Firefox版本低请升级到最新的Firefox版本","wsPlayer.play.error.703":"Edge版本低请升级到最新的Edge版本","wsPlayer.play.error.default":"播放失败,请检查配置","wsPlayer.error.101":"所选通道离线,无法播放","wsPlayer.error.102":"登录权限过期查询实时预览rtsp失败","wsPlayer.error.103":"获取实时预览rtsp失败","wsPlayer.error.104":"操作失败,请稍后重试","wsPlayer.error.105":"通道休眠,正在唤醒中,请稍后再试","wsPlayer.error.106":"请传入rtspURL和wsURL参数注意大小写","wsPlayer.error.107":"当前未传records录像文件, 将无法拖动进度条","wsPlayer.error.108":"请求超时,请稍后重试","wsPlayer.error.109":"rtsp未拼接token请注意拼接token","wsPlayer.error.110":"请传入正确的 'rtsp://xxx?token=' 地址","wsPlayer.error.111":"当前初始化播放器不是录像回放,请设置(type: record)","wsPlayer.error.112":"当前初始化播放器不是实时预览,请设置(type: real)","wsPlayer.error.113":"HTTP协议下浏览器不支持对讲, 请用HTTPS协议对讲","wsPlayer.error.201":"未查询到录像文件","wsPlayer.error.202":"查询录像文件列表失败","wsPlayer.error.203":"查询录像rtsp失败","wsPlayer.error.204":"{0}倍速无法播放音频","wsPlayer.error.205":"通道休眠,正在唤醒中,请稍后再试","wsPlayer.error.206":"当前倍速不支持","wsPlayer.error.301":"正在对讲,无法关闭音频","wsPlayer.error.302":"其他设备对讲中,无法开启音频","wsPlayer.error.303":"其他设备对讲中,无法开启对讲","wsPlayer.error.304":"查询对讲rtsp失败","wsPlayer.error.305":"http协议不支持对讲","wsPlayer.error.306":"设备对讲失败","wsPlayer.error.307":"不支持PCM音频格式对讲","wsPlayer.error.308":"不支持ARM音频格式对讲","wsPlayer.error.309":"不支持G711u音频格式对讲","wsPlayer.error.310":"不支持G726音频格式对讲","wsPlayer.error.311":"不支持AAC音频格式对讲","wsPlayer.error.312":"不支持G722音频格式对讲","wsPlayer.error.501":"解码库未初始化完成,请稍后播放!","wsPlayer.error.502":"解码库未初始化完成,请稍后对讲!","wsPlayer.error.503":"请检查创建播放器时,播放器容器是否存在","wsPlayer.error.601":"所操作播放器不存在","wsPlayer.error.602":"所选播放器正在本地录像中,不可重复本地录像","wsPlayer.error.603":"所选播放器未播放录像,不可本地录像","wsPlayer.error.604":"所选播放器未开始本地录像,不可操作关闭本地录像","wsPlayer.error.605":"时间跳转播放传参错误","wsPlayer.error.606":"设置画面实际比例/画面平铺传参错误","wsPlayer.error.607":"实时预览不支持倍速播放","wsPlayer.error.608":"需传入正确的{0}方法:{1}","wsPlayer.error.609":"超出当前设置最大窗口布局数量","wsPlayer.error.610":"操作自定义窗口布局失败:{0}","wsPlayer.error.611":"实时预览不支持播放方法","wsPlayer.error.612":"实时预览不支持暂停方法","wsPlayer.error.613":"实时预览不支持跳转播放","wsPlayer.error.614":"当前窗口未播放实时预览画面, 无法进行对讲","wsPlayer.error.701":"云台被用户{0}锁定,无法操作","wsPlayer.error.702":"控制云台三维定位失败{0}","wsPlayer.error.703":"控制云台{0}{1}失败{2}","wsPlayer.error.704":"控制云台方向失败{0}",error2084:"您无权限进行此操作","wsPlayer.error.30002002":"对讲被其他客户端打开,请稍后重试"},enUS:{"common.close":"Close","common.more":"More","common.ok":"OK","common.cancel":"Cancel","common.reset":"Reset","storagePlan.stream.main":"Main Stream","video.player.sub.stream":"Sub Stream {0}","video.player.ptz.down":"Down","video.player.ptz.left":"Left","video.player.ptz.lower.left":"Left Down","video.player.ptz.lower.right":"Right Down","video.player.ptz.right":"Right","video.player.ptz.up":"Up","video.player.ptz.upper.left":"Left Up","video.player.ptz.upper.right":"Right Up","inspec.ptz.position1":"3D Position","video.player.ptz.zoom":"Zoom","video.player.ptz.focus":"Focus","video.player.ptz.halo":"Aperture","channel.videoSource.video":"Video","wsPlayer.proxy":"The current proxy pattern cannot perform automatic handling.","wsPlayer.recording":"Local Record","wsplayer.more":"More","wsPlayer.request.realtime.preview.interface":"Request to check the interface in live view.","wsPlayer.request.realtime.preview.interface.error.tip":"For the {0} method you pass in, the value returned by resolve should be a standard object returned by ICC.","wsPlayer.request.recording.interface":"Request the recording interface.","wsPlayer.request.talk.interface":"Request the intercom interface.","wsPlayer.screen.custom.split":"Custom Split","wsPlayer.screen.four":"Quad split screen","wsPlayer.screen.full":"Full Screen","wsPlayer.screen.nine":"Nine split screens","wsPlayer.screen.one":"Single","wsPlayer.screen.selfAdaption":"Fit","wsPlayer.screen.split":"{0} Windows","wsPlayer.screen.stretching":"Stretch","wsPlayer.speed.sub":"Speed-","wsPlayer.speed.add":"Speed+","wsPlayer.sound":"Audio","wsPlayer.drawTriangle":"Smart Guideline Triangle","wsPlayer.refreshReplay":"refresh Replay","wsPlayer.talk":"Intercom","wsPlayer.establishTalk":"Establish Talk...","wsPlayer.talking":"Talking...","wsPlayer.localRecording":"Recording video...","wsPlayer.income.format.error":"The format is incorrect. Please try again.","wsPlayer.one.click.off":"Close All","wsPlayer.pause":"Pause","wsPlayer.play":"Play","wsPlayer.chromeMemoryOut":"Insufficient browser resources, please wait 3-5 seconds and try again","ws.device.awakening":"Waking up channel {0}...","wsPlayer.auto.recognition.failed":"Automatic recognition failed. The existing port is not a default one. Begin to judge by parameters. Please pass in parameters!","wsPlayer.capture":"Snapshot","wsPlayer.current.window.cannot.be.merged":"The current window cannot be merged.","wsPlayer.custom.player.max.support.tip":"Up to {0} window splits are supported for custom players.","wsPlayer.drag.tip":"You cannot drop it here. Please try again.","wsPlayer.decode.hardware":"Hardware Decoding","wsPlayer.decode.software":"Software Decoding","wsPlayer.play.error.101":"The browser does not support hardware decoding.","wsPlayer.play.error.102":"Failed to play video for hardware decoding.","wsPlayer.play.error.103":"The video for hardware decoding delay is higher than 8 seconds.","wsPlayer.play.error.104":"Hardware decoding failed.","wsPlayer.play.error.201":"Failed to play the audio.","wsPlayer.play.error.202":"ERR_CERT_AUTHORITY_INVALID","wsPlayer.play.error.203":"File ended.","wsPlayer.play.error.205":"Device is busy","wsPlayer.play.error.210":"Exception occurred while requesting device stream","wsPlayer.play.error.211":"WebScoket DisConnected","wsPlayer.play.error.223":"Illegal video request","wsPlayer.play.error.224":"Stream token has expired","wsPlayer.play.error.226":"Stream access is forbidden","wsPlayer.play.error.227":"Device stream not queried","wsPlayer.play.error.248":"Current transmission method is not supported","wsPlayer.play.error.250":"Internal server error","wsPlayer.play.error.253":"Current stream pulling service is incorrect","wsPlayer.play.error.254":"Network error.","wsPlayer.play.error.258":"Device account locked, unable to pull stream","wsPlayer.play.error.401":"Stream token has expired","wsPlayer.play.error.402":"This user has no playback permission.","wsPlayer.play.error.404":"Device stream not queried","wsPlayer.play.error.405":"Time out playing the video.","wsPlayer.play.error.406":"Failed to parse the video stream type. Please check the channel configuration.","wsPlayer.play.error.407":"Request timed out.","wsPlayer.play.error.408":"Request timed out.","wsPlayer.play.error.409":"Service has not pushed the stream code.","wsPlayer.play.error.410":"The video stream abnormally disconnected.","wsPlayer.play.error.411":"Video ended.","wsPlayer.play.error.457":"The time was incorrectly set.","wsPlayer.play.error.503":"Current stream pulling service is incorrect","wsPlayer.play.error.504":"Talk failed.","wsPlayer.play.error.701":"Your Google Chrome is not up to date. Please update it to the latest version.","wsPlayer.play.error.702":"Your Firefox is not up to date. Please update it to the latest version.","wsPlayer.play.error.703":"Your Edge is not up to date. Please update it to the latest version.","wsPlayer.play.error.default":"Failed to play. Please check the configuration.","wsPlayer.error.101":"Failed to play. The selected channel is offline.","wsPlayer.error.102":"Failed to search the RTSP address for the live video. Your login permission has expired.","wsPlayer.error.103":"Failed to obtain real-time preview RTSP.","wsPlayer.error.104":"Operation failed. Please try again later.","wsPlayer.error.105":"Waking up the channel which is currently in sleep status...Please try again later.","wsPlayer.error.106":"Please pass in rtspURL and wsURL parameters, pay attention to case","wsPlayer.error.107":"No records file passed, unable to scrub the timeline","wsPlayer.error.108":"The request timed out. Please try again later","wsPlayer.error.109":"RTSP does not splice token, please note that token is spliced","wsPlayer.error.110":"Please pass in the correct 'rtsp://XXX?token=' address","wsPlayer.error.111":"The current initialized player is not recordplease setting (type: record)","wsPlayer.error.112":"The current initialized player is not real,please setting (type: real)","wsPlayer.error.113":"The browser does not support intercom under the HTTP protocol, please use the HTTPS protocol for intercom.","wsPlayer.error.201":"No video files were found.","wsPlayer.error.202":"Failed to search for the list of video files.","wsPlayer.error.203":"Failed to search the RTSP address for videos.","wsPlayer.error.204":"Failed to play audio in {0}x speed.","wsPlayer.error.205":"Waking up the channel which is currently in sleep status...Please try again later.","wsPlayer.error.206":"Unsupported playback speed","wsPlayer.error.301":"Audio cannot be disabled when using talk.","wsPlayer.error.302":"Audio cannot be opened when another device is using talk.","wsPlayer.error.303":"Talk cannot be enabled when another device is using it.","wsPlayer.error.304":"Failed to search the RTSP address for talk.","wsPlayer.error.305":"HTTP protocol does not support talk.","wsPlayer.error.306":"Failed to talk through the device.","wsPlayer.error.307":"Talk does not support the PCM audio format.","wsPlayer.error.308":"Talk does not support the ARM audio format.","wsPlayer.error.309":"Talk does not support the G711u audio format.","wsPlayer.error.310":"Talk does not support the G726 audio format.","wsPlayer.error.311":"Talk does not support the AAC audio format.","wsPlayer.error.312":"Talk does not support the G722 audio format.","wsPlayer.error.501":"The decoding database is not yet fully initialized. Please try again later.","wsPlayer.error.502":"The decoding database is not yet fully initialized. Please try again later.","wsPlayer.error.503":"Please check if the player container exists when you create a player.","wsPlayer.error.601":"The player that you are trying to use does not exist.","wsPlayer.error.602":"The selected player has already started to make a local recording.","wsPlayer.error.603":"The selected player is not playing videos now. You cannot start the local recording.","wsPlayer.error.604":"The selected player is not playing a local recording now. You cannot stop the local recording.","wsPlayer.error.605":"Error jumping to a specific time in a video.","wsPlayer.error.606":"Error configuring self-adaptive image scale.","wsPlayer.error.607":"You cannot control the speed of live video.","wsPlayer.error.608":"Incorrect {0} method: {1}","wsPlayer.error.609":"Exceeded the current limit for the number of split windows.","wsPlayer.error.610":"Failed to customize the layout of the window. {0}","wsPlayer.error.611":"Real-time preview does not support playback method","wsPlayer.error.612":"Real-time preview does not support pause method","wsPlayer.error.613":"Real-time preview does not support jump playback","wsPlayer.error.614":"Real-time preview is not playing in the current window, unable to perform intercom.","wsPlayer.error.701":"Failed to operate. The PTZ was locked by user {0}.","wsPlayer.error.702":"Failed to control PTZ 3D positioning {0}","wsPlayer.error.703":"Failed to control PTZ {0}{1}. {2}","wsPlayer.error.704":"Failed to control the PTZ direction {0}",error2084:"You have no permission to perform this operation."}};let C={},b=null;const D={setLocal:function(e){C=T[e]},setI18n:function(e){b=e},$t:function(e,t){if(b&&b.t&&b.t(e,t)!==e)return b.t(e,t);if(b&&b.$t&&b.$t(e,t)!==e)return b.$t(e,t);let s=C[e];return Array.isArray(t)&&t.forEach((e,t)=>{s=s.replace(`{${t}}`,e)}),s}};let k="font-weight: 100; line-height: 18px;",R="font-weight: bold; line-height: 18px;",W="color: red; font-weight: bold;",L="font-size: 18px; font-weight: bold; color: #1677ff;",E="font-weight: bold;";const M=(...e)=>{localStorage.openWsplayerLog&&console.log("%c 📹",E,...e)},_=(...e)=>{localStorage.openStreamLog&&console.log("%c 📹",E,...e)},J=e=>{console.log(`%c 📹 WSPlayer 播放器日志信息\n\n %c🚨 当前连接 ${e.wsURL} 证书不安全\n\n %c临时处理方案:\n %c1. 访问 ${e.wsURL.startsWith("wss://")?e.wsURL.replace("wss","https"):e.wsURL.replace("ws","http")}, 页面提示 "您的连接不是私密连接"\n 2. 点击:高级 -> 继续前往不安全链接 -> 页面显示 “无法访问此网站”\n 3. 回到本页面, 刷新页面即可正常拉流\n\n %c推荐方案购买SSL证书\n %c1. 阿里云证书介绍 (https://developer.aliyun.com/article/1054207)\n 2. 阿里云证书购买 (https://www.aliyun.com/product/cas)\n\n %c其他原因\n %c1. 可能是ip或端口错误网络不通等原因, 请检查网络配置。\n 2. 检查端口,默认拉流端口 \n %c实时预览 ws是9100 wss是9102 \n 录像回放 ws是9320 wss是9322\n %c3. 如果仍然无法拉流,请联系技术人员排查。\n`,L,W,R,k,R,k,R,k,"color: #409EFF;",k)},Q=e=>{console.log("%c 📹 WSPlayer 播放器日志信息\n %c🚨 请求超时原因:\n %c1、当前播放的是辅码流,设备未启用辅码流播放\n 2、网络卡顿导致请求超时\n 3、设备不稳定平台无法登录设备获取码流导致请求超时\n 4、默认 8 秒请求超时,可自行修改请求超时时间, 初始化时配置 rtspResponseTimeout: 30, 可延长至30s, 最大300s\n",L,W,"font-weight: 100; line-height: 20px")},N=e=>{console.log("%c 📹 WSPlayer 播放器日志信息\n %c🚨 服务未推送码流排查步骤:\n %c1、是否设备离线\n 2、是否服务异常导致\n 3、设备播放是否为辅码流辅码流无法播放可进入平台客户端播放录像查看。\n",L,W,k)},z=function(e,t,s,i){console.log(" 📹 ====开始解析视频码流====",t),this.closeCRaw(),this.setLoading(!1,"playing",e.closeReason),"video"===t.decodeMode?(this.videoElem.style.display="",this.canvasElem.style.display="none"):(this.videoElem.style.display="none",this.canvasElem.style.display=""),this.customDomElem&&this.customDomElem.css("display",""),this.updateAdapter(e.playerAdapter,t),this.width=t.width,this.height=t.height,WSPlayerJQ.$(".stream-info",this.$el).text(`${t.encodeMode?`${t.encodeMode}, `:""}${t.width?`${t.width}*`:""}${t.height?t.height:""}${"video"===t.decodeMode?`, ${D.$t("wsPlayer.decode.hardware")}`:`, ${D.$t("wsPlayer.decode.software")}`}`),WSPlayerJQ.$(".ws-draw-triangle",this.$el).removeClass(s?"off":"on").addClass(s?"on":"off"),Y.call(this,s,100*this.wsPlayer.wsPlayerIndex+this.initIndex,i)},F=function(e,t,s){try{let i="";if(this.wsPlayer.setWSUrl)i=this.wsPlayer.setRedirectWSUrl(e.wsURL,t);else if(s){let s=i=t.split("rtsp://")[1].split("/")[0];i=e.wsURL.split("serverIp=")[0]+"serverIp="+s}else i=e.wsURL.split("://")[0]+t.split("rtsp://")[1].split("/")[0];self.playSDK.StartPullStream({strRtspvUri:i,strRtspvUrl:t,bStandardPack:this.wsPlayer.config.isRTPStream,strSourceId:"",bTalkService:!1,nRange:0,nShortTimeout:this.wsPlayer.rtspResponseTimeout||8,nRtspResponseTimeout:this.wsPlayer.rtspResponseTimeout+2||10})}catch(i){M("redirect_ws_err:",i)}},B=function(e){if(M("====浏览器资源nPort句柄====",e),e>160){this.chromeResourceOutOfMemory=!0,console.warn("浏览器资源不足, 请等待3-5秒后重试"),this.wsPlayer.sendMessage("chromeMemoryOut",{channelData:self.options.channelData,channelInfo:{...options},selectIndex:self.index,message:D.$t("wsPlayer.chromeMemoryOut")});let e=setTimeout(()=>{this.wsPlayer.close(this.currentIndex,"chromeMemoryOut"),clearTimeout(e)},10),t=setTimeout(()=>{this.chromeResourceOutOfMemory=!1,clearTimeout(t)},3e3);return}this.playSDK.nPlayPort=e,window.wsPlayerManager.bindPlayer(this.playSDK.nPlayPort,this.playSDK),window.wsPlayerManager.bindCanvasPlayer(this.canvasId,this.playSDK)},A=function(e){if(this.wsPlayer.config.recordCb||!this.wsPlayer.config.downloadMp4Record){if(this.localRecordbufferLength>e.offset){try{this.localRecordbufferLength+=e.length,this.localRecordList.push({offset:e.offset,buffer:e.data});let{blob:t,file:s,blobUrl:i,form:r}=w.uint8ArraysToFileUrl(this.localRecordList,this.wsPlayer.config.downloadMp4Record?"video/mp4":"application/octet-stream");this.wsPlayer.sendMessage("localRecordFile",{channelData:this.options.channelData,channelInfo:{...this.options},selectIndex:this.options.index,blob:t,file:s,blobUrl:i,form:r})}catch(t){M("localRecordFileFailed",t)}return this.localRecordList=[],void(this.localRecordbufferLength=0)}this.localRecordbufferLength+=e.length,this.localRecordList.push({offset:e.offset,buffer:e.data}),this.wsPlayer.sendMessage("localRecordBuf",{channelData:this.options.channelData,channelInfo:{...this.options},selectIndex:this.index,recordBuf:{...e}})}},U=function(e,t,s,r,a){if(5===Number(s))try{let e=new Uint8Array(t),s=new TextDecoder("utf-8").decode(e),r=JSON.parse(s);if(this.wsPlayer.sendMessage("IVSData",{channelData:this.options.channelData,channelInfo:{...this.options},selectIndex:this.index,data:JSON.parse(s)}),M("====辅助帧信息====",r,`窗口号: ${this.index}`),r.Events){if(!r.Events[0].Data)return;let e=r.Events[0].Data.RealtimeData.filter(e=>null!==e),{curCRawMap:t,curInfoMap:s}=this.getCRawArr(e);if(self.isFirstInfo){self.LastCRawMap=t,self.LastCRawInfo=s;let r=self.cRawCanvasElem.clientWidth,a=self.cRawCanvasElem.clientHeight,l=document.createDocumentFragment(),n=$("#"+self.cRawCanvasId);for(let t=0;t<e.length;t++){const s=e[t];if(s){let{DeviceName:e,Text:t,Rect:n}=s,o=n[0]*r/i.transParam,c=n[1]*a/i.transParam,d=self.LastCRawMap[e],h=self.getCRawTemplate(!1,t,e,d,o,c,s.AlarmEnable),p=document.createRange().createContextualFragment(h);l.appendChild(p)}}n.append(l)}else{let e=Object.keys(self.LastCRawMap),i=Object.keys(t);self.handleCRawArrs(e,i,s)}self.isFirstInfo&&(self.isFirstInfo=!1)}}catch(l){M("辅助帧数据存在异常不做展示")}},O=function(){"4"===String(this.wsPlayer.config.cacheMode)?(this.playSDK.SetCacheMode(0),this.playSDK.SetPlayMethod(200,1e3,3e3)):["0","1","2","3"].includes(String(this.wsPlayer.config.cacheMode))?this.playSDK.SetCacheMode(this.wsPlayer.config.cacheMode||1):this.playSDK.SetCacheMode(1)},V=function(e,t,s,i){if(window.wsPlayerManager.canvasToPlayer[this.canvasId]){let e=setTimeout(()=>{clearTimeout(e),this.setLoading(!1),this.showMsgInWindow("视频资源未释放"),console.log("%c📹 WSPlayer 播放器日志信息 \n %c🚨 当前窗口视频关闭异常\n \n %c问题描述\n %c当前窗口存在关闭视频异常请检查调用逻辑没有调用关闭方法或没有在正确的时间调用 close() 方法,\n \n %c解决方法\n %c1、未在dom销毁前触发 close() 方法销毁视频\n 2、切换页面时页面销毁前需要调用 close() 方法\n\n %c用户解决方法\n %c1、刷新浏览器页面\n 2、切换页面前先关闭视频\n",L,W,R,k,R,k,R,k)},50);return}this.playSDK.Init({canvasElem:this.canvasElem,videoElem:this.videoElem,ivsCanvasElem:this.ivsCanvasElem,bPlayBack:t,strDecodeFilePath:`${this.wsPlayer.prefixUrl}/WSPlayer/singleThread`},null,this.wsPlayer.config.isWebView);const{platform:r}=navigator;0==r.indexOf("iPhone")?this.playSDK.SetDecodeMode(!1,!1):this.playSDK.SetDecodeMode(s,i),!t&&O.call(this),M("====开始拉流====",{...e}),this.playSDK.m_rtspvHandle=this.playSDK.StartPullStream({strRtspvUri:e.wsURL,strRtspvUrl:e.rtspURL,bStandardPack:e.isRTPStream,strSourceId:"",bTalkService:!1,nRange:0,nShortTimeout:this.wsPlayer.rtspResponseTimeout||8,nRtspResponseTimeout:this.wsPlayer.rtspResponseTimeout+2||10}),null!=this.playSDK.m_rtspvHandle&&window.wsPlayerManager.bindHandlePlayer(this.playSDK.m_rtspvHandle,this.playSDK)},K=function(e,t){const{onlyLoadSingleLib:s,useH264MSE:r,useH265MSE:a,useNginxProxy:l,openIvs:n,ivsTypeArr:o}=e;let c=this;this.playSDK=new window.PlaySDKInterface(!s),this.setLogLevel(),this.playSDK.SetCallBack("StreamRedirect",function(e){F.call(c,t,e,l)}),this.playSDK.SetCallBack("GetPlayPort",e=>{B.call(c,e)}),this.playSDK.SetCallBack("PlayStart",e=>{z.call(c,t,e,n,o),c.talkWSUrl=t.wsURL,c.wsPlayer.sendMessage("realSuccess",{channelData:{...t.channelData||{}},channelInfo:{...t},selectIndex:t.selectIndex,customDomId:c.customDomId,streamInfo:{...e}})}),this.playSDK.SetCallBack("DecodeStart",e=>{}),this.playSDK.SetCallBack("Disconnect",()=>{c.isclosing=!1,c.isError?c.setLoading(!1,"closed"):c.setStatus("streamError",{errorCode:"410",description:"Video Stream Abnormality"})}),this.playSDK.SetCallBack("VideoFrameInfo",e=>{_("====视频帧信息打印====",`窗口号:${c.index}`,e),c.wsPlayer.sendMessage("getVideoFrameInfo",{channelData:c.options.channelData,channelInfo:c.options,selectIndex:c.index,audioFrameInfo:e})}),this.playSDK.SetCallBack("AudioFrameInfo",e=>{_("====音频帧信息打印====",`窗口号:${c.index}`,e),c.wsPlayer.sendMessage("getAudioFrameInfo",{channelData:c.options.channelData,channelInfo:c.options,selectIndex:c.index,audioFrameInfo:e})}),this.playSDK.SetCallBack("CapturePicDataCallBack",e=>{if(c.wsPlayer.config.picCapCb)try{const s=c.playSDK.GetCurrentFrameInfo();c.wsPlayer.sendMessage("picCap",{channelData:c.options.channelData,channelInfo:{...t},selectIndex:c.index,base64Img:c.currentWindowPlaying?this.uint8ArrayToBase64(e):"",imgBuf:e,timeStamp:s.utcTimeStamp})}catch(s){M("picCap_error",s)}}),this.playSDK.SetCallBack("RecordDataInfo",e=>{A.call(c,e)}),this.playSDK.SetCallBack("IVSDrawData",(e,t,s,i,r)=>{U.call(this,e,t,s,i,r)}),this.playSDK.SetCallBack("Error",e=>{if(c.playSDK&&![101,102,103,104,204].includes(Number(e.errorCode))){switch(c.isError=!0,c.setLoading(!1),c.close(!1,!1,"closed","playSDKError",!1),"202"===String(e.errorCode)&&(e.errorCode=t.wsURL.startsWith("wss://")?"202":"254"),e.errorCode=i.errorVideoInfoCode[e.errorCode]||e.errorCode,M("====错误码打印Error==== "+JSON.stringify(e),`窗口号: ${c.index}`),c.setStatus("error",e),String(e.errorCode)){case"100":let e=setTimeout(()=>{c.setLoading(!1,"closed"),clearTimeout(e)});this.wsPlayer.sendMessage("chromeMemoryOut",{channelData:c.options.channelData,channelInfo:{...t},selectIndex:c.index,message:D.$t("wsPlayer.chromeMemoryOut")});break;case"408":Q();break;case"409":N();break;case"202":J(t)}c.wsPlayer.sendMessage("realError",{selectIndex:t.selectIndex,channelData:{...t.channelData||{}},channelInfo:{...t}},{code:e.errorCode,msg:i.errorVideoInfo[e.errorCode]})}}),V.call(this,t,0,r,a)},H=function(e,t){let s=this,r=0;const{useH264MSE:a,useH265MSE:l,onlyLoadSingleLib:n,useNginxProxy:o,ivsTypeArr:c,openIvs:d}=e;this.playSDK=new window.PlaySDKInterface(!n),this.setLogLevel(),this.playSDK.SetCallBack("StreamRedirect",function(e){F.call(s,t,e,o)}),this.playSDK.SetCallBack("GetPlayPort",e=>{B.call(s,e)}),this.playSDK.SetCallBack("PlayStart",e=>{z.call(s,t,e,d,c),s.wsPlayer.selectIndex===s.index&&(WSPlayerJQ.$(".ws-record-play",s.wsPlayer.$el).css({display:"none"}),WSPlayerJQ.$(".ws-record-pause",s.wsPlayer.$el).css({display:"block"})),this.isFirstInfo=!0,s.wsPlayer.sendMessage("recordSuccess",{selectIndex:t.selectIndex,channelData:{...t.channelData||{}},channelInfo:{...t},customDomId:s.customDomId,streamInfo:{...e}})}),this.playSDK.SetCallBack("DecodeStart",e=>{}),this.playSDK.SetCallBack("Disconnect",()=>{s.isError?s.setLoading(!1,"closed"):s.setStatus("streamError",{errorCode:"410",description:"Video Stream Abnormality"})}),this.playSDK.SetCallBack("VideoFrameInfo",e=>{_("====视频帧信息打印====",`窗口号:${s.index}`,e);let i=new Date(e.nYear,e.nMonth-1,e.nDay,e.nHour,e.nMinute,e.nSecond).getTime()/1e3;t.isRTPStream?r?s.wsPlayer.__setPlayingTime(s.index,t.startTime+(i-r)):(r=i,s.wsPlayer.__setPlayingTime(s.index,t.startTime)):"playing"===s.status&&s.wsPlayer.__setPlayingTime(s.index,i),s.wsPlayer.sendMessage("getVideoFrameInfo",{channelData:s.options.channelData,channelInfo:s.options,selectIndex:s.index,videoFrameInfo:t.isRTPStream?null:e,timeStamp:i})}),this.playSDK.SetCallBack("AudioFrameInfo",e=>{_("====音频帧信息打印====",`窗口号:${s.index}`,e),s.wsPlayer.sendMessage("getAudioFrameInfo",{channelData:s.options.channelData,channelInfo:s.options,selectIndex:s.index,audioFrameInfo:e})}),this.playSDK.SetCallBack("CapturePicDataCallBack",e=>{if(s.wsPlayer.config.picCapCb)try{const i=s.playSDK.GetCurrentFrameInfo();s.wsPlayer.sendMessage("picCap",{channelData:s.options.channelData,channelInfo:{...t},selectIndex:s.index,base64Img:s.currentWindowPlaying?this.uint8ArrayToBase64(e):"",imgBuf:e,timeStamp:i.utcTimeStamp})}catch(i){M("picCap_error",i)}}),this.playSDK.SetCallBack("RecordDataInfo",e=>{A.call(s,e)}),this.playSDK.SetCallBack("PlayBackStreamRange",e=>{try{this.options&&"url"===t.playType&&s.options.selectIndex===s.wsPlayer.selectIndex&&s.wsPlayer.setTimeLine(t.records),s.wsPlayer.sendMessage("getPlayBackStreamRange",{channelData:s.options.channelData,channelInfo:s.options,selectIndex:s.index,recordRange:e})}catch(i){M("playback_range_error",i)}}),this.playSDK.SetCallBack("StreamPlayOver",e=>{if(M("====回放播放完成====",e),s.options.playRecordByFile)s.wsPlayer.playNextRecordByFile(s.index,()=>{s.setStatus("recordFinish",{errorCode:"411",description:"Record Finished"})});else{if(!s.options.playRecordByTime){if(s.options.playType&&s.options.currentRecordIndex<s.options.records.length-1)return void s.wsPlayer.sendMessage("switchStartTime",{selectIndex:s.index,timeStamp:s.options.records[s.options.currentRecordIndex+1].startTime,channelInfo:s.options,channelData:s.options.channelData,hasVideoRecord:!0,currentRecordFinish:!0});let e="",t=s.options.ssId,i=s.options.ssIdList||[];if(t&&(e=i[i.indexOf(t)+1]),e)return void s.wsPlayer.playNextRecord(s.index,e)}s.setStatus("recordFinish",{errorCode:"411",description:"Record Finished"})}}),this.playSDK.SetCallBack("IVSDrawData",(e,t,s,i,r)=>{U.call(this,e,t,s,i,r)}),this.playSDK.SetCallBack("Error",e=>{if(s.playSDK){if(s.isError=!0,[101,102,103,104,204].includes(Number(e.errorCode)))return;switch(s.setLoading(!1),s.close(!1,!1,"closed","playSDKError",!1),"202"===String(e.errorCode)&&(e.errorCode=t.wsURL.startsWith("wss://")?"202":"254"),e.errorCode=i.errorVideoInfoCode[e.errorCode]||e.errorCode,M("====错误码打印Error==== "+JSON.stringify(e),`窗口号: ${s.index}`),s.setStatus("error",e),String(e.errorCode)){case"100":let e=setTimeout(()=>{s.setLoading(!1,"closed"),clearTimeout(e)});this.wsPlayer.sendMessage("chromeMemoryOut",{channelData:s.options.channelData,channelInfo:{...t},selectIndex:s.index,message:D.$t("wsPlayer.chromeMemoryOut")});break;case"408":Q();break;case"409":N();case"202":J(t)}s.wsPlayer.sendMessage("recordError",{selectIndex:t.selectIndex,channelData:{...t.channelData||{}},channelInfo:{...t}},{code:i.errorVideoInfoCode[e.errorCode]||e.errorCode,msg:i.errorVideoInfo[e.errorCode]})}}),V.call(this,t,1,a,l),this.timeLong=t.endTime-t.startTime;let h=this.timeLong%60,p=parseInt(this.timeLong/60)%60,y=parseInt(this.timeLong/3600)%60;this.timeLongStr=`${y>0?y+":":""}${p<10?"0"+p:p}:${h<10?"0"+h:h}`,WSPlayerJQ.$(".time-long",this.$el).text(this.timeLongStr),this.setStatus("ready")},X=function(e,t){const{audioType:s,sampleRate:r}=t;this.wsPlayer.isTalking=!0,this.isTalking=!0,WSPlayerJQ.$(".talk-icon",this.$el).removeClass("off").addClass("on");let a=this;this.talkPlaySDK=new window.PlaySDKInterface(!this.wsPlayer.config.onlyLoadSingleLib),this.setLogLevel(),this.talkPlaySDK.SetCallBack("GetPlayPort",e=>{this.talkPlaySDK.nPlayPort=e,window.wsPlayerManager.bindPlayer(this.talkPlaySDK.nPlayPort,this.talkPlaySDK)}),this.talkPlaySDK.SetCallBack("AVTalkDataSendSuccess",t=>{WSPlayerJQ.$(".ws-talking",this.$el).html(`${D.$t("wsPlayer.talking")}`),a.wsPlayer.sendMessage("talkSuccess",{selectIndex:e.selectIndex,channelData:{...this.options.channelData||{}},channelInfo:this.options})}),this.talkPlaySDK.SetCallBack("Error",t=>{a.wsPlayer.sendMessage("talkError",{selectIndex:e.selectIndex,channelData:{...this.options.channelData||{}},channelInfo:this.options},{code:i.errorVideoInfoCode[t.errorCode]||t.errorCode,msg:i.errorVideoInfo[t.errorCode]}),a.stopTalk()}),this.talkPlaySDK.SetCallBack("Disconnect",e=>{a.stopTalk&&a.stopTalk()}),this.talkPlaySDK.Init({canvasElem:null,videoElem:null,ivsCanvasElem:null,bPlayBack:0,strDecodeFilePath:`${this.wsPlayer.prefixUrl}/WSPlayer/singleThread`}),M("====开始拉流====",{...e});let l=this.talkPlaySDK.StartPullStream({strRtspvUri:e.wsURL||this.talkWSUrl,strRtspvUrl:e.rtspURL+"&trackID=501",bStandardPack:e.isRTPStream,strSourceId:"",bTalkService:!0,nRange:0,nShortTimeout:this.wsPlayer.rtspResponseTimeout||8,nRtspResponseTimeout:this.wsPlayer.rtspResponseTimeout+2||10,bBroadcast:Boolean(e.gbDevice)});null!=l&&window.wsPlayerManager.bindHandlePlayer(l,this.talkPlaySDK),M("====开始对讲====","窗口号:",a.index,t),"4"===String(s)?this.talkPlaySDK.StartTalk(1,r):this.talkPlaySDK.StartTalk(0,r),window.wsPlayerManager.bindPlayer(this.talkPlaySDK.nPlayPort,this.talkPlaySDK),WSPlayerJQ.$(".ws-talking",this.$el).html(`${D.$t("wsPlayer.establishTalk")}`),WSPlayerJQ.$(".ws-talking",this.$el).css({visibility:"visible"}),this.openVolume(1,!Boolean(e.gbDevice))},q=function(){if(window.wsAudioPlayer)window.wsAudioPlayer.manualResume("fromTalk");else{let e=setInterval(()=>{window.wsAudioPlayer&&(window.wsAudioPlayer.manualResume("fromTalk"),clearInterval(e))},100)}},j=function(e,t=!1){this.playSDK&&(0===e?(this.playSDK&&this.playSDK.SetSoundState(!1),this.talkPlaySDK&&this.talkPlaySDK.SetSoundState(!1),WSPlayerJQ.$(".ws-audio",this.$el).removeClass("on").addClass("off"),WSPlayerJQ.$(".audio-icon",this.$el).removeClass("on").addClass("off")):(t?(this.talkPlaySDK.SetSoundState(!0),this.talkPlaySDK.SetVolume(e>1?1:e)):(this.playSDK.SetSoundState(!0),this.playSDK.SetVolume(e>1?1:e)),q(),WSPlayerJQ.$(".ws-audio",this.$el).removeClass("off").addClass("on"),WSPlayerJQ.$(".audio-icon",this.$el).removeClass("off").addClass("on")))},Y=function(e,t,s){if(this.playSDK)try{e?(this.ivsCanvasElem.style.display="block",this.playSDK.OpenIVS(t),this.playSDK.SetIvsLanguageEnvi("en"===localStorage.getItem("language")?1:0),s.includes(1)||this.playSDK.SetIvsEnable(3,0),s.includes(2)||(this.playSDK.SetIvsEnable(1,0),this.playSDK.SetIvsEnable(14,0))):(this.ivsCanvasElem.style.display="none",this.playSDK.CloseIVS())}catch(i){M("set_ivsDraw_error:",i)}};let G=[],Z=[];const ee=function(e,t,s){return new Promise((i,r)=>{let a=(e=e.map(e=>t+"://"+e)).filter(e=>G.includes(e));if(a.length)return void i(a[0]);if(e.every(e=>Z.includes(e)))return void r({code:-105,message:D.$t("wsPlayer.auto.recognition.failed")});let l=0,n=t=>{let a,o=new WebSocket(t),c=!1;o.onopen=()=>{c=!0,G.push(t),clearTimeout(a),o.close(),i(e[l-1])},o.onerror=()=>{Z.push(t),clearTimeout(a),c=!1,l>=e.length?r({code:-105,message:D.$t("wsPlayer.auto.recognition.failed")}):n(e[l++])},a=setTimeout(()=>{Z.push(t),!c&&o.close()},1e3*s)};n(e[l++])})},te=function(e,t){if(this.intranetMap)for(let i in this.intranetMap)i.includes(t)&&(t=this.intranetMap[i]);if(!t)return void console.warn("please configure 【streamServerIp】 in new PlayerManager({...})");if(t.includes(":"))return`${e}://${t}`;let s="";return s="wss"===e?"real"===this.type?i.websocketPorts.realmonitor_wss:i.websocketPorts.playback_wss:"real"===this.type?i.websocketPorts.realmonitor_ws:i.websocketPorts.playback_ws,`${e}://${t}:${s}`},se=function(e,t,s){let r="";t.match(/\d{1,3}(\.\d{1,3}){3}/g)&&(r=t.split("//")[1].split(":")[0]);let a="real"===this.type?i.websocketPorts.realmonitor:i.websocketPorts.playback;return this.proxyServerIp?`${e}://${this.proxyServerIp}/${a}?serverIp=${s||r}`:(console.warn("please configure 【proxyServerIp】 in new PlayerManager({...})\n now i use 【location.host】 instead of 【proxyServerIp】 or set configure【localStorage.wsplayerProxyIp】"),`${e}://${localStorage.wsplayerProxyIp||location.host}/${a}?serverIp=${s||r}`)},ie=function(e){let{rtspURL:t,streamServerIp:s,wsList:i,playType:r,wssDirect:a,talkData:l}=e;return new Promise((e,l)=>{if("url"===r)return void e();if(localStorage.wsUrl)return void e(localStorage.wsUrl);if(this.setWSUrl)return void e(this.setWSUrl(i));let n=this.wsProtocol||(this.isHttps?"wss":"ws");"DEVTOOL"===this.ENV&&this.config.useNginxProxy?e(se.call(this,"wss",t,s||this.streamServerIp)):ee(i,n,this.WS_TIMEOUT).then(t=>{e(t)}).catch(i=>{if(console.warn(i.message),"ICC"===this.ENV)return void(this.isHttps&&0==a?e(se.call(this,"wss",t,s||this.streamServerIp||window.location.hostname)):e(te.call(this,n,this.streamServerIp||s||window.location.hostname)));if(this.isHttps&&this.config.useNginxProxy&&this.proxyServerIp)return void e(se.call(this,"wss",t,"ICC"===this.ENV&&s||this.streamServerIp||s));let r=te.call(this,n,this.streamServerIp||s);r&&e(r)})})},re=function(){let e=parseInt(this.config.maxNum,10);this.maxWindow=e>16?25:e>9?16:e>8?9:e>6?8:e>4?6:e},ae=function(e){let t=100/e,s=[];for(var i=0;i<e;i++)for(var r=0;r<e;r++)s.push({lStep:r*t,tStep:i*t,wStep:t,hStep:t});return s},le=function(e,t){let s=[];s="number"==typeof t?ae(t):t;let i=100;for(var r=0;r<e.length;r++){let t=e[r].getAttribute("id"),a=t.split("-"),l=Number(a[a.length-1]);s[l]?WSPlayerJQ.$(`#${t}`).css({top:`${s[l].tStep}%`,left:`${s[l].lStep}%`,width:`${s[l].wStep}%`,height:`${s[l].hStep}%`,visibility:"visible","z-index":i--}):WSPlayerJQ.$(`#${t}`).css({top:"150%",left:0,width:0,height:0,visibility:"hidden"})}},ne=function(e,t){for(let s=0;s<t;s++)e[s]&&WSPlayerJQ.$(`#${e[s].getAttribute("id")}`).css({top:"150%",left:0,width:0,height:0,visibility:"hidden"})},oe=function(e,t){let s=WSPlayerJQ.$(`#${this.el} .wsplayer-item`);ne(s,this.config.maxNum);let r=parseInt(e)||1;switch(r){case 1:r=1,le(s,1);break;case 2:r=2,le(s,i.windowDefaultCustomDivision[2]);break;case 3:r=3,le(s,i.windowDefaultCustomDivision[3]);break;case 4:r=4,le(s,2);break;case 5:case 6:r=6,le(s,i.windowDefaultCustomDivision[6]);break;case 7:case 8:r=8,le(s,i.windowDefaultCustomDivision[8]);break;case 9:r=9,le(s,3);break;case 10:case 11:case 12:case 13:case 14:case 15:case 16:r=16,le(s,4);break;case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:r=25,le(s,5)}r>this.maxWindow&&(r=this.maxWindow),this.showNum!==r&&(this.showNum=r,!t&&this.sendMessage("windowNumChanged",this.showNum),setTimeout(()=>{this.__updatePlayerWindow()},200))},ce=function(e,t){let s=WSPlayerJQ.$(`#${this.el} .wsplayer-item`);ne(s,this.config.maxNum),le(s,JSON.parse(e)),this.showNum=e,!t&&this.sendMessage("windowNumChanged",this.showNum),setTimeout(()=>{this.__updatePlayerWindow()},200)},de=function(e,t,s){WSPlayerJQ.$(`#${this.el}-${t}`).css({top:`${e[s].tStep}%`,left:`${e[s].lStep}%`,width:`${e[s].wStep}%`,height:`${e[s].hStep}%`}),WSPlayerJQ.$(`#${this.el}-${s}`).css({top:`${e[t].tStep}%`,left:`${e[t].lStep}%`,width:`${e[t].wStep}%`,height:`${e[t].hStep}%`});let i=WSPlayerJQ.$(`#${this.el}-${t} .default-status`).css("transform"),r=WSPlayerJQ.$(`#${this.el}-${s} .default-status`).css("transform");WSPlayerJQ.$(`#${this.el}-${t} .default-status`).css({transform:r}),WSPlayerJQ.$(`#${this.el}-${s} .default-status`).css({transform:i}),WSPlayerJQ.$(`#${this.el}-${t}`).attr("id",`${this.el}-temp`),WSPlayerJQ.$(`#${this.el}-${s}`).attr("id",`${this.el}-${t}`).removeClass(`wsplayer-item-${s}`).addClass(`wsplayer-item-${t}`),WSPlayerJQ.$(`#${this.el}-temp`).attr("id",`${this.el}-${s}`).removeClass(`wsplayer-item-${t}`).addClass(`wsplayer-item-${s}`);let a=this.playerList[t];this.playerList[t]=this.playerList[s],this.playerList[s]=a,this.playerList[t].index=t,this.playerList[t].currentIndex=t,this.playerList[t].domId=`${this.el}-${s}`,this.playerList[s].index=s,this.playerList[s].currentIndex=s,this.playerList[s].domId=`${this.el}-${t}`},he=function(e){if(this.currentDragWindowIndex<0||this.currentDragWindowIndex===e)return void(this.currentDragWindowIndex=-1);let t=[];t="number"==typeof this.showNum?i.windowDefaultCustomDivision[this.showNum]?i.windowDefaultCustomDivision[this.showNum]:ae(Math.sqrt(this.showNum)):JSON.parse(this.showNum),de.call(this,t,this.currentDragWindowIndex,e),this.sendMessage("dragWindow",{dragIndex:this.currentDragWindowIndex,dropIndex:e}),this.currentDragWindowIndex===this.selectIndex&&this.setSelectIndex(e,{},null,!1),this.currentDragWindowIndex=-1,setTimeout(()=>{this.__updatePlayerWindow()},200)},pe=function(e){ie.call(this,e).then(t=>{e.wsURL=e.wsURL||t,e.playerAdapter=e.playerAdapter||this.playerAdapter;let s=this.playerList[e.selectIndex];s.playType=e.playType,this.selectIndex===e.selectIndex&&s&&this.setPtzChannel(e.channelData),s&&s.init(e)})},ye=function(e){let t=this.playerList[e.selectIndex];ee(e.wsList,"wss",this.WS_TIMEOUT).then(t=>{e.wsURL=t}).catch(()=>{}).finally(()=>{t.startTalk(e)})},ue=function(e){return new Promise((t,s)=>{let i=this.playerList[e.selectIndex];i?(i.playType=e.playType,ie.call(this,e).then(s=>{e.wsURL=e.wsURL||s,e.playerAdapter=e.playerAdapter||this.playerAdapter,WSPlayerJQ.$(".ws-record-play",this.$el).css({display:"none"}),WSPlayerJQ.$(".ws-record-pause",this.$el).css({display:"block"}),i&&i.init(e),t()})):s()})};class me{constructor(e){this.$el=null,this.canvasElem=null,this.videoElem=null,this.wrapperDomId=e.wrapperDomId,this.i18n=e.locale,this.isclosing=!1,this.domId=e.wrapperDomId+"-"+e.index,this.canvasId=`${this.domId}-livecanvas`,this.ivsCanvasId=`${this.domId}-ivs-livecanvas`,this.cRawCanvasId=`${this.domId}-cRaw-livecanvas`,this.pztCanvasId=`${this.domId}-pzt-livecanvas`,this.videoId=`${this.domId}-liveVideo`,this.wsPlayer=e.wsPlayer,this.index=e.index,this.initIndex=e.index,this.firstTime=0,this.isAudioPlay=!1,this.speed=1,this.localRecordList=[],this.localRecordbufferLength=0,this.singleClickTimer=null}initDom(){let e=this.getTemplate(),t=WSPlayerJQ.$(e);this.wsPlayer.$wrapper.append(t[0]),this.$el=WSPlayerJQ.$("#"+this.domId),this.canvasElem=document.getElementById(this.canvasId)||{},this.ivsCanvasElem=document.getElementById(this.ivsCanvasId)||{},this.cRawCanvasElem=document.getElementById(this.cRawCanvasId)||{},this.pztCanvasElem=document.getElementById(this.pztCanvasId)||{},this.videoElem=document.getElementById(this.videoId),this.showIcons=this.wsPlayer.config.showIcons||{},this.showIconNum=7,this.showIcons.streamChangeSelect||this.setDomHiddenDeep(WSPlayerJQ.$(".select-container",this.$el),!1),this.showIcons.replayIcon||(this.setDomHiddenDeep(WSPlayerJQ.$(".ws-refresh-replay",this.$el),!1),this.showIconNum--),this.showIcons.ivsIcon||(this.setDomHiddenDeep(WSPlayerJQ.$(".ws-draw-triangle",this.$el),!1),this.showIconNum--),this.setTalkIconShow(),this.showIcons.audioIcon||(this.setDomHiddenDeep(WSPlayerJQ.$(".ws-audio",this.$el),!1),this.showIconNum--),this.showIcons.snapshotIcon||(this.setDomHiddenDeep(WSPlayerJQ.$(".ws-capture",this.$el),!1),this.showIconNum--),this.showIcons.localRecordIcon||(this.setDomHiddenDeep(WSPlayerJQ.$(".ws-record",this.$el),!1),this.showIconNum--),this.showIcons.closeIcon||(this.setDomHiddenDeep(WSPlayerJQ.$(".ws-close",this.$el),!1),this.showIconNum--),this.showMoreIcon=!1}setTalkIconShow(){let{talkIcon:e}=this.wsPlayer.config.showIcons||{},t=location.protocol;e&&"https:"===t&&"real"===this.wsPlayer.type?WSPlayerJQ.$(".ws-talk",this.$el).css({display:""}):(this.setDomHiddenDeep(WSPlayerJQ.$(".ws-talk",this.$el),!1),this.showIconNum--)}initMouseEvent(){this.$el.click(e=>{clearTimeout(this.singleClickTimer),this.singleClickTimer=setTimeout(()=>{this.wsPlayer.setSelectIndex(this.index,{},{offsetX:e.offsetX,offsetY:e.offsetY}),this.$el.siblings().removeClass("selected").addClass("unselected"),this.$el.removeClass("unselected").addClass("selected"),this.singleClickTimer=null},300)}),this.$el.dblclick(e=>{if(this.singleClickTimer&&(clearTimeout(this.singleClickTimer),this.singleClickTimer=null),1===this.wsPlayer.options.config.maxNum)return;if(!this.wsPlayer.options.config.dblclickDisabled)if(1!==this.wsPlayer.showNum){this.wsPlayer.beforeShowNum=this.wsPlayer.showNum;let e=WSPlayerJQ.$(`#${this.wrapperDomId} .wsplayer-item`);ne(e,this.wsPlayer.options.config.maxNum),WSPlayerJQ.$(`#${this.wrapperDomId}-${this.index}`).css({top:0,left:0,width:"100%",height:"100%",visibility:"visible"}),this.wsPlayer.showNum=1}else this.wsPlayer.setPlayerNum(this.wsPlayer.beforeShowNum,!0);this.wsPlayer.setSelectIndex(this.index,{},{offsetX:e.offsetX,offsetY:e.offsetY},!1),this.$el.siblings().removeClass("selected").addClass("unselected"),this.$el.removeClass("unselected").addClass("selected");let t=setTimeout(()=>{this.wsPlayer.__updatePlayerWindow(),clearTimeout(t)},200),s=0,i=0;if(e&&this.currentWindowPlaying){let t=this["video"===this.decodeMode?"videoElem":"canvasElem"].getBoundingClientRect();s=8192*e.offsetX/t.width,i=8192*e.offsetY/t.height}this.wsPlayer.sendMessage("dblclickWindow",{selectIndex:this.index,showNum:this.wsPlayer.showNum,currentWindowPlaying:this.currentWindowPlaying,channelInfo:{...this.options},channelData:this.options&&this.options.channelData,dPointX:s,dPointY:i})}),WSPlayerJQ.$(".ws-audio",this.$el).click(e=>{if(this.currentWindowPlaying){if(this.wsPlayer.isTalking&&this.isTalking&&this.gbTalk);else if(this.wsPlayer.isTalking)return void this.wsPlayer.sendErrorMessage(this.isTalking?"301":"302");if(this.isAudioPlay)this.closeVolume();else{if("record"===this.wsPlayer.type&&![.25,.5,1,1.25,1.5,2,4].includes(Number(this.speed)))return void this.wsPlayer.sendErrorMessage("204",{insert:[this.speed]});this.openVolume()}}}),WSPlayerJQ.$(".ws-refresh-replay",this.$el).click(e=>{"url"===this.wsPlayer.playerList[this.index].playType?this.wsPlayer.sendMessage("refreshReplay",{selectIndex:this.options.selectIndex,channelInfo:{...this.options},channelData:{...this.options.channelData||{}}}):"real"===this.wsPlayer.type?this.wsPlayer.playRealVideo({channelList:[{...this.options.channelData}],streamType:this.options.streamType,windowIndex:this.index,closeReason:"refreshWindow"}):this.wsPlayer.playRecordVideo({channelList:[{...this.options.channelData}],startTime:this.options.startTime,endTime:this.options.endTime,recordSource:this.options.recordSource,streamType:this.options.streamType,recordType:this.options.recordType,windowIndex:this.index,playRecordByFile:this.options.playRecordByFile,closeReason:"refreshWindow"})}),WSPlayerJQ.$(".ws-draw-triangle",this.$el).click(e=>{this.currentWindowPlaying&&(e.target.getAttribute("class").includes("off")?(WSPlayerJQ.$(".ws-draw-triangle",this.$el).removeClass("off").addClass("on"),WSPlayerJQ.$(".draw-triangle-icon",this.$el).removeClass("off").addClass("on"),Y.call(this,!0,100*this.wsPlayer.wsPlayerIndex+this.options.selectIndex,this.wsPlayer.config.ivsTypeArr)):(WSPlayerJQ.$(".ws-draw-triangle",this.$el).removeClass("on").addClass("off"),WSPlayerJQ.$(".draw-triangle-icon",this.$el).removeClass("on").addClass("off"),this.playSDK.CloseIVS()))});WSPlayerJQ.$(".ws-talk",this.$el).click(w.throttle(e=>{if(this.currentWindowPlaying)if("http:"!==location.protocol)if(this.wsPlayer.isTalking&&!this.isTalking)this.wsPlayer.sendErrorMessage("303");else if(this.isTalking)this.stopTalk();else{const{selectIndex:e,channelData:t}=this.options;if(this.options&&"url"===this.options.playType)return void this.wsPlayer.sendMessage("notifyTalk",{selectIndex:e,channelData:{...t},channelInfo:{...this.options}});q(),this.setAuthority({channelCode:this.options.channelData?this.options.channelData.channelCode:this.options.channelId,function:"3"},()=>{this.wsPlayer.__startTalk(this.options.channelData,this.index)},s=>{1103===s.code&&this.wsPlayer.sendErrorMessage(401,{selectIndex:e,channelData:{...t},type:"talk"})})}else this.wsPlayer.sendErrorMessage("305")},2e3)),WSPlayerJQ.$(".ws-capture",this.$el).click(e=>{this.currentWindowPlaying&&this.setAuthority({channelCode:this.options.channelData?this.options.channelData.channelCode:this.options.channelId,function:"4"},()=>{this.picCap()},e=>{1103===e.code&&this.wsPlayer.sendErrorMessage(401,{type:"capture"})})}),WSPlayerJQ.$(".ws-close",this.$el).click(e=>{this.close(!1,!1,"closed","btnClick")}),WSPlayerJQ.$(".ws-record",this.$el).click(e=>{if(!this.currentWindowPlaying)return;let t=(this.options.channelData||{}).name||this.i18n.$t("wsPlayer.recording");this.isRecording?this.stopRecord("btnClick"):"playing"===this.status&&this.setAuthority({channelCode:this.options.channelData?this.options.channelData.channelCode:this.options.channelId,function:"8"},()=>{this.isRecording=!0,this.startRecord(`${this.i18n.$t("wsPlayer.video")}_${t}_${w.getDateFormatByUnderline()}`),WSPlayerJQ.$(".ws-record",this.$el).addClass("recording")},e=>{1103===e.code&&this.wsPlayer.sendErrorMessage(401,{type:"record"})})}),WSPlayerJQ.$(".more-icon",this.$el).click(e=>{this.showMoreIcon=!this.showMoreIcon,this.setDomVisible(WSPlayerJQ.$(".opt-icons-vertical",this.$el),this.showMoreIcon)}),WSPlayerJQ.$(".cRaw-container",this.$el).click(e=>{let t=e.target.dataset&&e.target.dataset.pid;if(t){"hidden"===WSPlayerJQ.$(`#${t} .ws-tag-content`,this.$el).css("visibility")?(this.setTagContentPosition(t),WSPlayerJQ.$(`#${t} .ws-tag-content`,this.$el).css("visibility","visible"),WSPlayerJQ.$(`#${t} .ws-tag-title`,this.$el).css("max-width","180px")):(WSPlayerJQ.$(`#${t} .ws-tag-content`,this.$el).css("visibility","hidden"),WSPlayerJQ.$(`#${t} .ws-tag-title`,this.$el).css("max-width",""))}}),this.wsPlayer.config.draggable&&(this.$el.on("mousedown",e=>{this.wsPlayer.currentDragWindowIndex=this.currentIndex,e.preventDefault()}),this.$el.on("mouseup",e=>{he.call(this.wsPlayer,this.currentIndex),e.preventDefault()}))}setLoading(e,t,s){this.spinner&&this.spinner.stop(),e&&["playing","pause"].includes(this.status)&&this.close(!1,!1,"closed",s||"changeStream"),t&&this.setStatus(t),e&&(this.spinner=new g({color:"#ffffff"}).spin(this.$el[0]))}picCap(e){let t=e;if(!t){let e=(this.options.channelData||{}).name||"";t=`${this.i18n.$t("wsPlayer.capture")}_${e}_${w.getDateFormatByUnderline()}`}this.playSDK.CapturePic(this.wsPlayer.config.picCapCb?null:t+".png")}startRecord(e,t,s,i=!0){const{downloadMp4Record:r,localRecordSize:a}=this.wsPlayer.config;let l="boolean"==typeof s?s:r;l=!localStorage.playSDKLogLevel&&l;let n=t||a,o=`${e}.${l?"mp4":"dav"}`;this.playSDK.StartRecord(l?5:0,n,this.wsPlayer.config.recordCb?null:o,i),WSPlayerJQ.$(".ws-local-recording",this.$el).html(this.i18n.$t("wsPlayer.localRecording")),WSPlayerJQ.$(".ws-local-recording",this.$el).css({visibility:"visible"})}stopRecord(e){this.isRecording=!1,this.playSDK.StopRecord(),WSPlayerJQ.$(".ws-record",this.$el).removeClass("recording"),WSPlayerJQ.$(".ws-local-recording",this.$el).html(""),WSPlayerJQ.$(".ws-local-recording",this.$el).css({visibility:"hidden"})}closeOtherAudio(){this.wsPlayer.playerList.forEach(e=>{e.isAudioPlay&&e.closeVolume()})}openVolume(e=1,t=!1){this.closeOtherAudio(),j.call(this,e,t),this.isAudioPlay=!0}closeVolume(){j.call(this,0),this.isAudioPlay=!1}setAuthority(e,t,s){this.wsPlayer.fetchChannelAuthority?this.wsPlayer.fetchChannelAuthority(e).then(e=>{e.data.result&&t()}).catch(e=>{s(e)}):t()}showMsgInWindow(e){let t=((e,t)=>{var s,i,r;return{"视频资源未释放":"上次打开的视频资源未正常关闭, 导致资源未释放。\n\n解决方案\n1、刷新浏览器页面\n2、切换页面前先关闭视频资源\n ","请求超时":"码流请求超时\n1、检查设备是否处于离线状态\n2、设备可能未启用辅码流播放\n3、网络环境较差\n4、设备登录失败导致码流请求超时","网络异常":"当前连接的ip或端口不通, 请联系相应人员排查网络问题","安全证书验证失败":`当前连接 ${null==t?void 0:t.wsURL} 证书不安全。\n\n临时处理方案:\n1. 访问 ${(null==(s=null==t?void 0:t.wsURL)?void 0:s.startsWith("wss://"))?null==(i=null==t?void 0:t.wsURL)?void 0:i.replace("wss","https"):null==(r=null==t?void 0:t.wsURL)?void 0:r.replace("ws","http")}, 页面提示 "您的连接不是私密连接"\n2. 点击:高级 -> 继续前往不安全链接 -> 页面显示 “无法访问此网站”\n3. 回到本页面, 刷新页面即可正常拉流\n`}[e]})(e,this.options);this.setDomVisible(this.defaultStatus,!1),WSPlayerJQ.$(".wsplayer-error-message",this.$el).text(e),t&&(WSPlayerJQ.$(".wsplayer-error-message",this.$el).attr("title",t),WSPlayerJQ.$(".wsplayer-error-message",this.$el).css("text-decoration","underline")),this.setDomVisible(this.error,!0)}play(){this.playSDK.Pause(0),this.playSDK.SetSpeed(this.speed),this.setStatus("playing"),WSPlayerJQ.$(".ws-record-play",this.wsPlayer.$el).css({display:"none"}),WSPlayerJQ.$(".ws-record-pause",this.wsPlayer.$el).css({display:""}),this.wsPlayer.sendMessage("playCallback",{selectIndex:this.index})}pause(){this.playSDK.Pause(1),this.setStatus("pause"),WSPlayerJQ.$(".ws-record-pause",this.wsPlayer.$el).css({display:"none"}),WSPlayerJQ.$(".ws-record-play",this.wsPlayer.$el).css({display:""}),this.wsPlayer.sendMessage("pauseCallback",{selectIndex:this.index})}close(e=!1,t=!1,s="closed",i="unknown",r=!0){if(this.currentWindowPlaying=!1,this.setDomVisible(WSPlayerJQ.$(".play-pause-wrapper",this.$el),!1),["seekRecord"].includes(i)||(this.videoElem.style.display="none",this.canvasElem.style.display="none",this.ivsCanvasElem.style.display="none",this.customDomElem&&this.customDomElem.css("display","none")),this.wsPlayer.playerList.forEach(e=>{e.closeCRaw()}),this.isTalking&&!t&&this.stopTalk(),!["seekRecord"].includes(i)&&(this.speed=1),this.index===this.wsPlayer.selectIndex&&("real"===this.wsPlayer.type?!e&&this.wsPlayer.setPtzChannel():["btnClick","api","recordFinish","playSDKError"].includes(i)&&(this.wsPlayer.setTimeLine([]),this.wsPlayer.__setPlaySpeed(),WSPlayerJQ.$(".ws-record-play",this.wsPlayer.$el).css({display:""}),WSPlayerJQ.$(".ws-record-pause",this.wsPlayer.$el).css({display:"none"}))),this.isRecording&&this.stopRecord("closeVideo"),this.wsPlayer.config.openIvs&&this.playSDK)try{this.playSDK.CloseIVS()}catch(a){console.debug("关闭规则线")}!["seekRecord"].includes(i)&&this.spinner&&this.spinner.stop(),WSPlayerJQ.$(".stream-info",this.$el).text(""),this.wsPlayer.videoClosed(this.index,e,{...this.options&&this.options.channelData||{}},this.customDomId,i),this.isclosing=["windowDestroy"].includes(i),this.playSDK&&(M("Run StopPullStream!"),this.playSDK.StopPullStream(),["seekRecord"].includes(i)||(this.playSDK.Stop(),window.wsPlayerManager.unbindPlayer(this.playSDK.nPlayPort),window.wsPlayerManager.unbindHandlePlayer(this.playSDK.m_rtspvHandle),window.wsPlayerManager.unbindCanvasPlayer(this.canvasId))),!e&&["btnClick","api"].includes(i)&&(this.playSDK=null,this.options=null),r&&!["recordFinish","seekRecord"].includes(s)&&this.setStatus(s)}setDomVisible(e,t){e&&e.css({visibility:t?"visible":"hidden"})}setDomDisplay(e,t){e&&e.css({display:t?"":"none"})}setDomHiddenDeep(e,t){e&&(t?e.removeClass("hidden-deep"):e.addClass("hidden-deep"))}setLogLevel(){this.playSDK.SetPrintLogLevel&&this.playSDK.SetPrintLogLevel(localStorage.playSDKLogLevel)}uint8ArrayToBase64(e){if(!e||0===e.byteLength)return"";let t="",s=e.byteLength;for(let i=0;i<s;i++)t+=String.fromCharCode(e[i]);return window.btoa(t)}updateAdapter(e,t={}){let s=t.width/t.height,i="video"===(t.decodeMode||this.decodeMode)?this.videoElem:this.canvasElem,r=i.parentNode;t.decodeMode?(this.decodeMode=t.decodeMode,this.width=t.width,this.height=t.height):s=this.width/this.height;let a="100%",l="100%",n=null;if("selfAdaption"===e){let e=r.offsetHeight,t=r.offsetWidth,o=t/e;s>o?l=t/s+"px":s<o&&(a=e*s+"px"),"video"===this.decodeMode?(WSPlayerJQ.$(i).css({width:a,height:l,"object-fit":"contain"}),WSPlayerJQ.$(this.canvasElem).css({width:a,height:l,"object-fit":"contain"}),n=this.canvasElem.getBoundingClientRect(),this.canvasElem.width=n.width,this.canvasElem.height=n.height):(WSPlayerJQ.$(i).css({width:a,height:l}),n=i.getBoundingClientRect(),i.width=n.width,i.height=n.height),WSPlayerJQ.$(this.ivsCanvasElem).css({width:a,height:l,"object-fit":"contain"}),WSPlayerJQ.$(this.pztCanvasElem).css&&WSPlayerJQ.$(this.pztCanvasElem).css({width:a,height:l,"object-fit":"contain"}),WSPlayerJQ.$(this.cRawCanvasElem).css({width:a,height:l,"object-fit":"contain"})}else WSPlayerJQ.$(i).css({width:a,height:l,"object-fit":"fill"}),"video"===this.decodeMode?(WSPlayerJQ.$(this.canvasElem).css({width:a,height:l,"object-fit":"fill"}),n=this.canvasElem.getBoundingClientRect(),this.canvasElem.width=n.width,this.canvasElem.height=n.height):(n=i.getBoundingClientRect(),i.width=n.width,i.height=n.height),WSPlayerJQ.$(this.ivsCanvasElem).css({width:a,height:l,"object-fit":"fill"}),WSPlayerJQ.$(this.pztCanvasElem).css&&WSPlayerJQ.$(this.pztCanvasElem).css({width:a,height:l,"object-fit":"fill"}),WSPlayerJQ.$(this.cRawCanvasElem).css({width:a,height:l,"object-fit":"fill"});if(this.customDomElem&&this.customDomElem.css({width:a,height:l}),this.customDomElem&&this.wsPlayer.sendMessage("customDomInfo",{customDomId:this.customDomId,width:a,height:l,currentWindowPlaying:this.currentWindowPlaying||!1,channelInfo:this.options,channelData:this.options&&this.options.channelData}),this.playSDK){this.ivsCanvasElem.width=i.offsetWidth,this.ivsCanvasElem.height=i.offsetHeight,this.cRawCanvasElem.width=i.offsetWidth,this.cRawCanvasElem.height=i.offsetHeight,this.pztCanvasElem.width=i.offsetWidth,this.pztCanvasElem.height=i.offsetHeight;let e=setTimeout(()=>{this.wsPlayer.playerList.forEach(e=>{"playing"===e.status&&e.setCRawTagsPos()}),clearTimeout(e)},100)}}renderDefaultStats(){let e=WSPlayerJQ.$(".default-status",this.$el),t=e.width(),s=e.height(),i=WSPlayerJQ.$(".wsplayer-error-message",this.$el);t&&s&&(t<100||s<100?(e.css({transform:"scale(0.3)"}),i.css({transform:"scale(0.3)"})):t<200||s<200?(e.css({transform:"scale(0.5)"}),i.css({transform:"scale(0.5)"})):(e.css({transform:"scale(1)"}),i.css({transform:"scale(1)"})))}getCRawTemplate(e=!1,t,s,i,r,a,l){let n=t.split("|"),o="",c="";for(let p=0;p<n.length;p++)o+=`<p>${n[p]}</p>`;let{prefixUrl:d}=this.wsPlayer,h=`\n <div>\n <p class="ws-tag-title" data-pid="${i}" title="${s}">\n <img src="${d}/WSPlayer/icon/tag-left-${l?"alarm":"normal"}.png" class="ws-left-png" data-pid="${i}"/>\n <img src="${d}/WSPlayer/icon/tag-middle-${l?"alarm":"normal"}.png" class="ws-middle-png" height="75" data-pid="${i}"/>\n <img src="${d}/WSPlayer/icon/tag-right-${l?"alarm":"normal"}.png" class="ws-right-png" data-pid="${i}"/>\n <span data-pid="${i}">${s}</span>\n </p>\n <div class="ws-tag-content ${l?"ws-tag-content-alarm":""}" style="visibility: hidden">\n ${o}\n </div>\n </div>`;return c=e?h:`\n <div id="${i}" class="ws-tag-container" style="left:${r}px;top:${a}px">\n ${h}\n </div>`,c}setTagContentPosition(e){if(!e)return;let t=WSPlayerJQ.$(`#${this.cRawCanvasId}`,this.$el).outerHeight(),s=WSPlayerJQ.$(`#${this.cRawCanvasId}`,this.$el).outerWidth(),i=WSPlayerJQ.$(`#${e}`,this.$el),r=i[0].offsetTop,a=i[0].offsetLeft,l=t-r-i.innerHeight(),n=WSPlayerJQ.$(`#${e} .ws-tag-content`,this.$el),o=n.innerHeight(),c=n.innerWidth(),d=64;l<o&&r>l&&(d=-o);let h=42;a+h+c>s&&(h=s-a-c),WSPlayerJQ.$(`#${e} .ws-tag-content`,this.$el).css("top",`${d}px`),WSPlayerJQ.$(`#${e} .ws-tag-content`,this.$el).css("left",`${h}px`)}getCRawArr(e){let t={},s={};for(let i=0;i<e.length;i++){const r=e[i];if(null!==r){let{DeviceName:e}=r;t[e]=+new Date+i,s[e]=r}}return{curCRawMap:t,curInfoMap:s}}handleCRawArrs(e,t,s){let r=e.filter(e=>!t.includes(e)),a=t.filter(t=>!e.includes(t)),l=e.filter(e=>t.includes(e));if(r.length)for(let i=0;i<r.length;i++){const e=r[i];let t=`#${this.LastCRawMap[e]}`;$(t).remove(),delete this.LastCRawMap[e],delete this.LastCRawInfo[e]}if(a.length){let e=document.createDocumentFragment();for(let t=0;t<a.length;t++){const r=a[t];if(s[r]){this.LastCRawMap[r]=+new Date+t,this.LastCRawInfo[r]=s[r];let{DeviceName:a,Text:l,Rect:n,AlarmEnable:o}=s[r],c=this.cRawCanvasElem.width,d=this.cRawCanvasElem.height,h=n[0]*c/i.transParam,p=n[1]*d/i.transParam,y=this.LastCRawMap[a],u=this.getCRawTemplate(!1,l,a,y,h,p,o),m=document.createRange().createContextualFragment(u);e.appendChild(m)}}$("#"+this.cRawCanvasId).append(e)}if(l.length)for(let n=0;n<l.length;n++){const e=l[n];if(s[e]){let{DeviceName:t,Text:r,Rect:a,AlarmEnable:l}=s[e],n=`#${this.LastCRawMap[t]}`,o=this.LastCRawInfo[e].Rect,c=this.LastCRawInfo[e].Text,d=this.cRawCanvasElem.width,h=this.cRawCanvasElem.height,p=a[0]*d/i.transParam,y=a[1]*h/i.transParam;if(a[0]===o[0]&&a[1]===o[1]||(WSPlayerJQ.$(n,this.$el).css({left:`${p}px`,top:`${y}px`}),this.setTagContentPosition(this.LastCRawMap[t])),c!==r){let e=this.getCRawTemplate(!0,r,t,this.LastCRawMap[t],p,y,l,!0);WSPlayerJQ.$(n,this.$el).html(e)}this.LastCRawInfo[e]=s[e]}}}setCRawTagsPos(){for(const e in this.LastCRawMap){let t=`#${this.LastCRawMap[e]}`,s=this.cRawCanvasElem.width,r=this.cRawCanvasElem.height,{Text:a,Rect:l}=this.LastCRawInfo[e],n=l[0]*s/i.transParam,o=l[1]*r/i.transParam;WSPlayerJQ.$(t,this.$el).css({left:`${n}px`,top:`${o}px`}),this.setTagContentPosition(this.LastCRawMap[e])}}closeCRaw(){WSPlayerJQ.$(`#${this.cRawCanvasId}`,this.$el).empty(),this.LastCRawMap={},this.LastCRawInfo={}}updateTopBarStyle(){let e=WSPlayerJQ.$(".top-control-bar",this.$el).width(),t=94,s=130;"zh-cn"!==localStorage.getItem("language")&&(t=134,s=220);let r=e-(this.showIcons.streamChangeSelect&&"real"===this.type?t:0)-10;if(r>28*this.showIconNum+s)this.setDomDisplay(WSPlayerJQ.$(".more-icon",this.$el),!1),this.setDomDisplay(WSPlayerJQ.$(".stream-info",this.$el),!0),i.iconConfig.forEach((e,t)=>{this.setDomDisplay(WSPlayerJQ.$(`.opt-icons > .${e.buttonParentClass}`,this.$el),!0)});else if(r>28*this.showIconNum)this.setDomDisplay(WSPlayerJQ.$(".more-icon",this.$el),!1),this.setDomDisplay(WSPlayerJQ.$(".stream-info",this.$el),!1),i.iconConfig.forEach((e,t)=>{this.setDomDisplay(WSPlayerJQ.$(`.opt-icons > .${e.buttonParentClass}`,this.$el),!0)});else{let e=Math.floor(r/28);this.setDomDisplay(WSPlayerJQ.$(".stream-info",this.$el),!1),this.setDomDisplay(WSPlayerJQ.$(".more-icon",this.$el),!0),i.iconConfig.forEach((t,s)=>{e>s+2?(this.setDomDisplay(WSPlayerJQ.$(`.opt-icons > .${t.buttonParentClass}`,this.$el),!0),this.setDomDisplay(WSPlayerJQ.$(`.opt-icons-vertical > .${t.buttonParentClass}`,this.$el),!1)):(this.setDomDisplay(WSPlayerJQ.$(`.opt-icons > .${t.buttonParentClass}`,this.$el),!1),this.setDomDisplay(WSPlayerJQ.$(`.opt-icons-vertical > .${t.buttonParentClass}`,this.$el),!0))})}}}const we=[3600,1800,900,300];const fe=class{constructor(e){this.records=e.records||[],this.currentTime=Number(e.currentTime),this.getCurrentTime=e.getCurrentTime,this.rulerCanvas=null,this.rulerCtx=null,this.canvas_middle_length=0,this.rulerLength=e.rulerLength||{short:15,middle:25,long:40},this.centerFontOffsetX=e.centerFontOffsetX||55,this.fontOffsetX=e.fontOffsetX||0,this.fontSize=e.fontSize,this.centerFontSize=e.centerFontSize,this.canvasBgColor="transparent",this.rulerColor="#afafaf",this.textColor="#fff",this.recordsColor=e.recordsColor||"#318efd",this.alarmRecordsColor="#f64153",this.cursorColor="#fff",this.oldScaleInfo={scale_step:this.scale_step,scale_step_offsetX:this.scale_step_offsetX},this.scale_step=5*e.rulerScale||10,this.scale_step_offsetX=this.scale_step%30,this.time_ruler_line=we[0],this.move_1px_time=1,this.moveCurrentTime=0,this.move_offset=0,this.isMouseDown=!1,this.initRuler(e)}initRuler(e){if(!e.canvasId)return e.onError&&e.onError({code:801,message:"请传入canvas的id"});this.rulerCanvas=document.querySelector(e.canvasId),this.rulerCtx=this.rulerCanvas.getContext("2d"),this.canvas_middle_length=Math.floor(this.rulerCanvas.width/2),this.initDrawLine(),this.addEventListener()}initDrawLine(){this.clearRuler(),this.rulerCtx.fillStyle=this.canvasBgColor,this.rulerCtx.fillRect(0,0,this.rulerCanvas.width,this.rulerCanvas.height),this.setScaleStepOffset(),this.setMoveTime(),!this.isMouseDown&&this.getMoveOffset(),this.renderRecordList(),this.renderLeftRuler(),this.renderRightRuler(),this.drawMarkRuler()}updateProgress(e){e&&(e.currentTime||e.records&&e.records.length)?(this.records=e.records||this.records,this.currentTime=e.currentTime||this.records&&this.records[0]&&this.records[0].startTime||this.currentTime,this.initDrawLine()):(this.currentTime=this.currentTime||0,this.records=[],this.initDrawLine())}addEventListener(){let e,t=null;const s=e=>{e.preventDefault&&e.preventDefault(),t=null,this.isMouseDown=!1,0!==this.moveCurrentTime&&(this.currentTime=this.currentTime-this.moveCurrentTime,this.moveCurrentTime=0,this.initDrawLine(),this.getCurrentTime&&this.getCurrentTime(parseInt(this.currentTime)))},i=e=>{e.preventDefault&&e.preventDefault(),t=null,this.isMouseDown=!1,this.currentTime=this.currentTime-this.moveCurrentTime,this.moveCurrentTime=0,this.initDrawLine()},r=e=>{e.preventDefault&&e.preventDefault(),this.isMouseDown||(this.oldScaleInfo={scale_step:this.scale_step,scale_step_offsetX:this.scale_step_offsetX},(e.deltaY<0||e.wheelDelta>0)&&(this.scale_step+=5,this.scale_step>=120&&(this.scale_step=115)),(e.deltaY>0||e.wheelDelta<0)&&(this.scale_step-=5,this.scale_step<10&&(this.scale_step=10)),this.initDrawLine())},a=s=>{if(s.preventDefault&&s.preventDefault(),s.touches&&2===s.touches.length&&null!==t){this.isMouseDown=!1;const e=s.touches[0],i=s.touches[1],a=this.calculateDistance(e,i);return r({wheelDelta:a/t-1}),void(t=a)}if(this.isMouseDown){let t=0;"movementX"in s?t=s.movementX:(t=(s.touches[0].clientX-e)/5,e=s.touches[0].clientX),this.move_offset+=t,this.moveCurrentTime+=t*this.move_1px_time,this.initDrawLine()}};this.rulerCanvas.addEventListener("touchstart",s=>{if(s.preventDefault&&s.preventDefault(),s.touches&&2===s.touches.length){const e=s.touches[0],i=s.touches[1];return void(t=this.calculateDistance(e,i))}e=s.touches[0].clientX,this.isMouseDown=!0}),this.rulerCanvas.addEventListener("mousedown",t=>{e=t.clientX,this.isMouseDown=!0}),this.rulerCanvas.addEventListener("touchmove",function(e,t=160){var s,i,r=0;return function(){var a=+new Date;s=this,i=arguments,a-r>t&&(e.apply(s,i),r=a)}}(a)),this.rulerCanvas.addEventListener("mousemove",a),this.rulerCanvas.addEventListener("mouseup",s),this.rulerCanvas.addEventListener("touchend",s),this.rulerCanvas.addEventListener("mouseleave",i),this.rulerCanvas.addEventListener("touchleave",i),this.rulerCanvas.addEventListener("mouseout",i),this.rulerCanvas.addEventListener("mousewheel",r);let l=()=>{this.rulerCanvas.width===this.rulerCanvas.getBoundingClientRect().width&&this.rulerCanvas.height===this.rulerCanvas.getBoundingClientRect().height||(this.rulerCanvas.width=this.rulerCanvas.getBoundingClientRect().width,this.rulerCanvas.height=this.rulerCanvas.getBoundingClientRect().height,this.canvas_middle_length=Math.floor(this.rulerCanvas.width/2),this.initDrawLine()),window.requestAnimationFrame(l)};window.requestAnimationFrame(l)}calculateDistance(e,t){return t.clientX-e.clientX}clearRuler(){this.rulerCtx&&this.rulerCtx.clearRect(0,0,this.rulerCanvas.width,this.rulerCanvas.height)}setScaleStepOffset(){this.scale_step_offsetX=this.scale_step%30,this.scale_step_offsetX<10&&(this.scale_step_offsetX=10)}setMoveTime(){this.time_ruler_line=we[Math.floor((this.scale_step+1)/30)],this.move_1px_time=this.time_ruler_line/10/this.scale_step_offsetX}getMoveOffset(){this.move_offset=-Math.floor(this.currentTime%this.time_ruler_line/this.move_1px_time)}renderLeftRuler(){let e=0;for(;e<=this.canvas_middle_length+this.move_offset;){let t=this.canvas_middle_length+this.move_offset-e;e/this.scale_step_offsetX%10==0?(this.drawRulerLine(t,this.rulerLength.long),this.rulerCtx.fillStyle=this.textColor,this.rulerCtx.font=`${this.fontSize}px Verdana`,this.rulerCtx.fillText(this.getRenderTime(0-e),t-this.fontOffsetX,this.rulerLength.long+10),this.rulerCtx.font=`${this.fontSize}px Verdana`):e/this.scale_step_offsetX%10==5?this.drawRulerLine(t,this.rulerLength.middle):this.drawRulerLine(t,this.rulerLength.short),e+=this.scale_step_offsetX}}renderRightRuler(){let e=0;for(;e<=this.canvas_middle_length-this.move_offset;){let t=this.canvas_middle_length+this.move_offset+e;e/this.scale_step_offsetX%10==0?(this.drawRulerLine(t,this.rulerLength.long),this.rulerCtx.fillStyle=this.textColor,this.rulerCtx.font=`${this.fontSize}px Verdana`,this.rulerCtx.fillText(this.getRenderTime(e),t-this.fontOffsetX,this.rulerLength.long+10),this.rulerCtx.font=`${this.fontSize}px Verdana`):e/this.scale_step_offsetX%10==5?this.drawRulerLine(t,this.rulerLength.middle):this.drawRulerLine(t,this.rulerLength.short),e+=this.scale_step_offsetX}}getRenderTime(e){let t=this.currentTime-this.currentTime%this.time_ruler_line;return this.formatter(1e3*(t+e*this.move_1px_time),"HH:mm")}drawRulerLine(e,t,s=this.rulerColor){this.rulerCtx.beginPath(),this.rulerCtx.strokeStyle=s,this.rulerCtx.moveTo(e,0),this.rulerCtx.lineTo(e,t),this.rulerCtx.stroke(),this.rulerCtx.closePath()}renderRecordList(){let e=this.records.filter(e=>!e.isImportant),t=this.records.filter(e=>e.isImportant);this.renderRecordOnCanvas(e,"records"),this.renderRecordOnCanvas(t,"alarmRecords")}renderRecordOnCanvas(e,t){let s=this.currentTime-this.moveCurrentTime,i=s-this.canvas_middle_length*this.move_1px_time,r=s+this.canvas_middle_length*this.move_1px_time,a=0;this.rulerCtx.beginPath(),e.forEach(e=>{e.endTime<i||e.startTime>r||(e.endTime<r&&e.endTime>i?(a=e.startTime<i?i:e.startTime,this.rulerCtx.fillStyle=this[`${t}Color`],this.rulerCtx.fillRect(this.canvas_middle_length-Math.floor(s-a)/this.move_1px_time,0,(e.endTime-a)/this.move_1px_time,this.rulerCanvas.height)):e.startTime>i&&e.startTime<r?(a=e.endTime>r?r:e.endTime,this.rulerCtx.fillStyle=this[`${t}Color`],this.rulerCtx.fillRect(this.canvas_middle_length-(s-e.startTime)/this.move_1px_time,0,(a-e.startTime)/this.move_1px_time,this.rulerCanvas.height)):e.startTime<i&&e.endTime>r&&(this.rulerCtx.fillStyle=this[`${t}Color`],this.rulerCtx.fillRect(0,0,this.rulerCanvas.width,this.rulerCanvas.height)))}),this.rulerCtx.closePath()}drawMarkRuler(){this.rulerCtx.beginPath(),this.rulerCtx.strokeStyle=this.cursorColor,this.rulerCtx.moveTo(this.canvas_middle_length-3,0),this.rulerCtx.lineTo(this.canvas_middle_length+3,0),this.rulerCtx.lineTo(this.canvas_middle_length,24),this.rulerCtx.lineTo(this.canvas_middle_length-3,0),this.rulerCtx.stroke(),this.rulerCtx.fillStyle=this.cursorColor,this.rulerCtx.fill(),this.rulerCtx.closePath(),this.rulerCtx.fillStyle=this.textColor,this.rulerCtx.font=`${this.centerFontSize}px Verdana`,this.rulerCtx.fillText(this.formatter(1e3*(this.currentTime-this.moveCurrentTime),"YYYY-MM-DD HH:mm:ss"),this.canvas_middle_length-this.centerFontOffsetX,this.rulerCanvas.height-10),this.rulerCtx.font=`${this.centerFontSize}px Verdana`}addZero(e){return e<10?"0"+e:e}formatter(e,t){let s=(e=new Date(e)).getFullYear(),i=this.addZero(e.getMonth()+1),r=this.addZero(e.getDate()),a=this.addZero(e.getHours()),l=this.addZero(e.getMinutes()),n=this.addZero(e.getSeconds()),o="";switch(t){case"YYYY-MM-DD HH:mm:ss":o=`${s}-${i}-${r} ${a}:${l}:${n}`;break;case"HH:mm":o=`${a}:${l}`}return o}},Pe=100;let ge,Se,ve=null,$e=20,xe={},Ie=!0,Te="",Ce={x:0,y:0},be=[],De={},ke={},Re=0,We="",Le=()=>{try{ge.removeEventListener("selectstart",Ee),ge.removeEventListener("mousemove",Me),ge.removeEventListener("mouseup",_e),ge.addEventListener("selectstart",Ee),ge.addEventListener("mousemove",Me),ge.addEventListener("mouseup",_e)}catch(e){let t=setTimeout(()=>{Le(),clearTimeout(t)},300)}};function Ee(e){return e.preventDefault(),!1}function Me(e){if(!Te)return;e.preventDefault();let t=Se.getBoundingClientRect(),s=t.width/Pe,i=t.height/Pe;switch(Te){case"right-border":if(Ce.x+=e.movementX,Re!==Math.round(Ce.x/s)){if(Re=Math.round(Ce.x/s),ke.lStep+Re<=0)return void(Re=1-ke.lStep);if(ke.lStep+Re>=Pe)return void(Re=Pe-ke.lStep-1);document.querySelector("#division-move-line").style.left=1*(ke.lStep+Re)+"%"}break;case"bottom-border":if(Ce.y+=e.movementY,Re!==Math.round(Ce.y/i)){if(Re=Math.round(Ce.y/i),ke.tStep+Re<=0)return void(Re=1-ke.tStep);ke.tStep+Re>=Pe&&(Re=Pe-ke.tStep-1),document.querySelector("#division-move-line").style.top=1*(ke.tStep+Re)+"%"}}}function _e(e){if(Te){e.preventDefault();let t=[],s=!0;switch(Te){case"right-border":if(!Re)return;let{l_window:e,r_window:i}=De;if(t=[...e.map(e=>(e.wStep-=Re,e.lStep+=Re,e.wStep<1&&(s=!1),e)),...i.map(e=>(e.wStep+=Re,e.wStep<1&&(s=!1),e))],!s)return Te="",document.querySelector("#division-move-line").remove(),Ae(),void xe.onError(ve.$t("wsPlayer.drag.tip"));t.forEach(e=>be[e.selectIndex]=e);break;case"bottom-border":if(!Re)return;let{t_window:r,b_window:a}=De;if(t=[...r.map(e=>(e.hStep-=Re,e.tStep+=Re,e.hStep<1&&(s=!1),e)),...a.map(e=>(e.hStep+=Re,e.hStep<1&&(s=!1),e))],!s)return Te="",document.querySelector("#division-move-line").remove(),Ae(),void xe.onError(ve.$t("wsPlayer.drag.tip"));t.forEach(e=>be[e.selectIndex]=e)}Te="",Ae()}}function Je(e=[]){if(!e.length||1===e.length)return be=[{wStep:Pe,hStep:Pe,tStep:0,lStep:0,selectIndex:0}],be;e=e.sort((e,t)=>e.tStep-t.tStep);for(let t=0;t<e.length-1;t++)if(e[t].tStep===e[t+1].tStep&&e[t].lStep>e[t+1].lStep){let s={...e[t]};e[t]={...e[t+1]},e[t+1]=s}return e.map((e,t)=>(e.selectIndex=t,e))}function Qe(e,t){let s=document.querySelector("#temp-preview-line");s.style.display="block",s.style.background="#1d79f4",s.style.opacity=.4,"col"===t&&(s.style.left=`${Math.floor(e.lStep+e.wStep/2)}%`,s.style.top=`${e.tStep}%`,s.style.width="2px",s.style.height=`${e.hStep}%`),"raw"===t&&(s.style.left=`${e.lStep}%`,s.style.top=`${Math.floor(e.tStep+e.hStep/2)}%`,s.style.width=`${e.wStep}%`,s.style.height="2px")}function Ne(e,t){be.length!==$e?1===e.wStep&&1===e.hStep||("col"===t&&(be.push({...e,lStep:e.lStep+Math.floor(e.wStep/2),wStep:Math.ceil(e.wStep/2)}),be[e.selectIndex]={...e,wStep:Math.floor(e.wStep/2)}),"raw"===t&&(be.push({...e,tStep:e.tStep+Math.floor(e.hStep/2),hStep:Math.ceil(e.hStep/2)}),be[e.selectIndex]={...e,hStep:Math.floor(e.hStep/2)}),Ae()):xe.onError(ve.$t("wsPlayer.custom.player.max.support.tip",[$e]))}function ze(e,t){let s="";return"x"===t&&(s=`<div id="division-move-line" style="position: absolute; background: #1d79f4; top: ${1*e.tStep}%; left: ${1*e.lStep}%; width: 2px; height: ${1*e.hStep}%; "></div>`),"y"===t&&(s=`<div id="division-move-line" style="position: absolute; background: #1d79f4; top: ${1*e.tStep}%; left: ${1*e.lStep}%; width: ${1*e.wStep}%; height: 2px; "></div>`),s}function Fe(e){return`<div\n id="dom-item-${e.selectIndex}"\n class="${Ie?"dom-item-flex":"dom-item"}"\n style="top: ${e.top}%; left: ${e.left}%; width: ${e.width}%; height: ${e.height}%;"\n >\n <div class="point-n-resize" id="dom-item-${e.selectIndex}-bottom-border" style="bottom: -4px; left: 0; width: 100%; height: 6px;"></div>\n <div class="point-e-resize" id="dom-item-${e.selectIndex}-right-border" style="top: 0; right: -4px; width: 6px; height: 100%;"></div>\n <div style="width: 68px; display: flex;">\n <div id="dom-item-${e.selectIndex}-btn-col" class="dom-item-split-btn"></div>\n <div id="dom-item-${e.selectIndex}-btn-raw" class="dom-item-split-btn" style="margin-left: 11px; transform: rotate(90deg)"></div>\n </div>\n <div id="dom-item-${e.selectIndex}-delete-btn" class="dom-item-merge-btn"></div>\n </div>`}function Be(e=[]){Ie=!1;let t=[];e.forEach(e=>{t.push(Fe({selectIndex:e.selectIndex,width:1*e.wStep,height:1*e.hStep,top:1*e.tStep,left:1*e.lStep}))}),Se.innerHTML=t.join("")+'<div id="temp-preview-line" style="position: absolute; z-index: 10; display: none;"></div>',e.forEach(e=>{document.querySelector(`#dom-item-${e.selectIndex}-btn-raw`).addEventListener("click",()=>{Ne(e,"raw")}),document.querySelector(`#dom-item-${e.selectIndex}-btn-col`).addEventListener("click",()=>{Ne(e,"col")}),document.querySelector(`#dom-item-${e.selectIndex}-delete-btn`).addEventListener("click",()=>{!function(e){if(1===be.length)return void xe.onError(ve.$t("wsPlayer.current.window.cannot.be.merged"));let t=be.findIndex(t=>t.wStep===e.wStep&&t.lStep===e.lStep&&(t.tStep+t.hStep===e.tStep||e.tStep+e.hStep===t.tStep)||t.hStep===e.hStep&&t.tStep===e.tStep&&(t.lStep+t.wStep===e.lStep||e.lStep+e.wStep===t.lStep));if(t>-1){let s=be[t];s.tStep===e.tStep&&(s.selectIndex>e.selectIndex?(be[e.selectIndex].wStep=e.wStep+s.wStep,be.splice(s.selectIndex,1)):(be[s.selectIndex].wStep=s.wStep+e.wStep,be.splice(e.selectIndex,1))),s.lStep===e.lStep&&(s.selectIndex>e.selectIndex?(be[e.selectIndex].hStep=e.hStep+s.hStep,be.splice(s.selectIndex,1)):(be[s.selectIndex].hStep=s.hStep+e.hStep,be.splice(e.selectIndex,1)))}else xe.onError(ve.$t("wsPlayer.current.window.cannot.be.merged"));Ae()}(e)}),document.querySelector(`#dom-item-${e.selectIndex}-btn-raw`).addEventListener("mouseenter",t=>{Qe(e,"raw")}),document.querySelector(`#dom-item-${e.selectIndex}-btn-raw`).addEventListener("mouseleave",e=>{document.querySelector("#temp-preview-line").style.display="none"}),document.querySelector(`#dom-item-${e.selectIndex}-btn-col`).addEventListener("mouseenter",t=>{Qe(e,"col")}),document.querySelector(`#dom-item-${e.selectIndex}-btn-col`).addEventListener("mouseleave",e=>{document.querySelector("#temp-preview-line").style.display="none"}),document.querySelector(`#dom-item-${e.selectIndex}-right-border`).addEventListener("mousedown",t=>{t.stopPropagation(),e.lStep+e.wStep!==Pe&&(Te="right-border",Ce={x:0},Re=0,De=function({wStep:e,lStep:t,selectIndex:s},i){let r=i.filter(s=>s.lStep+s.wStep===t+e).sort((e,t)=>e.tStep-t.tStep),a=i.filter(s=>s.lStep===t+e).sort((e,t)=>e.tStep-t.tStep);for(var l=0;l<r.length-1;l++)r[l].tStep+r[l].hStep!==r[l+1].tStep&&(s<=r[l].selectIndex?r.splice(l+1):(r.splice(0,l),l=-1));let n=-1,o=-1;return a.forEach(e=>{let t=r.findIndex(t=>e.tStep===t.tStep),s=r.findLastIndex(t=>e.tStep+e.hStep===t.tStep+t.hStep);t>-1&&(n=0===t?0:Math.min(t,n)),s>-1&&(o=Math.max(s,o))}),a=a.filter(e=>e.tStep>=r[n].tStep&&e.tStep+e.hStep<=r[o].tStep+r[o].hStep),{l_window:a,r_window:r}}({...e},JSON.parse(JSON.stringify(be))),ke={hStep:De.r_window.reduce((e,t)=>e+t.hStep,0),tStep:De.r_window[0].tStep,lStep:De.l_window[0].lStep},We=ze(ke,"x"),Se.innerHTML+=We)}),document.querySelector(`#dom-item-${e.selectIndex}-bottom-border`).addEventListener("mousedown",t=>{e.tStep+e.hStep!==Pe&&(Te="bottom-border",Ce={y:0},Re=0,De=function({hStep:e,tStep:t,selectIndex:s},i){let r=i.filter(s=>s.tStep+s.hStep===t+e).sort((e,t)=>e.lStep-t.lStep),a=i.filter(s=>s.tStep===t+e).sort((e,t)=>e.lStep-t.lStep);for(var l=0;l<r.length-1;l++)r[l].lStep+r[l].wStep!==r[l+1].lStep&&(s<=r[l].selectIndex?r.splice(l+1):(r.splice(0,l),l=-1));let n=-1,o=-1;return a.forEach(e=>{let t=r.findIndex(t=>e.lStep===t.lStep),s=r.findLastIndex(t=>e.lStep+e.wStep===t.lStep+t.wStep);t>-1&&(n=0===t?0:Math.min(t,n)),s>-1&&(o=Math.max(s,o))}),a=a.filter(e=>e.lStep>=r[n].lStep&&e.lStep+e.wStep<=r[o].lStep+r[o].wStep),{t_window:a,b_window:r}}({...e},JSON.parse(JSON.stringify(be))),ke={wStep:De.b_window.reduce((e,t)=>e+t.wStep,0),lStep:De.b_window[0].lStep,tStep:De.t_window[0].tStep},We=ze(ke,"y"),Se.innerHTML+=We)})})}function Ae(){Se.innerHTML="",be=Je(be),Be(be)}const Ue=e=>{let{division:t,windowId:s,callback:i,maxNum:r,locale:a}=e;if(ve=a,$e=r,ge=document.querySelector(`#${s}`),ge.innerHTML=function(e){return`<div id="${e}-container" style="width: 100%; height: 100%; border: 1px solid #aaa; position: relative;"></div>\n <div class="window-division-bottom-container">\n <button class="window-division-btn window-division-btn-primary" id="${e}-confirm-btn">${ve.$t("common.ok")}</button>\n <button class="window-division-btn window-division-btn-info" id="${e}-reset-btn">${ve.$t("common.reset")}</button>\n <button class="window-division-btn window-division-btn-info" id="${e}-cancel-btn">${ve.$t("common.cancel")}</button>\n </div>\n `}(s),Se=document.querySelector(`#${s}-container`),xe=i,Le(),document.querySelector(`#${s}-confirm-btn`).addEventListener("click",()=>{i.onConfirm&&i.onConfirm(JSON.stringify(be))}),document.querySelector(`#${s}-cancel-btn`).addEventListener("click",()=>{i.onCancel&&i.onCancel()}),document.querySelector(`#${s}-reset-btn`).addEventListener("click",()=>{be=[{wStep:100,hStep:100,tStep:0,lStep:0,selectIndex:0}],Be(be)}),t)if([1,4,9,16,25].includes(Number(t)))!function(e=4){Ie=!0;let t=[],s=100/Math.sqrt(e);for(var i=0;i<e;i++)t.push({selectIndex:i,width:s,height:s});var r=t.map(e=>Fe(e));Se.innerHTML=r.join("")}(Number(t));else if("string"!=typeof t)i.onError&&i.onError(ve.$t("wsPlayer.income.format.error"));else try{be=Je(JSON.parse(t)),Be(be)}catch(l){i.onError&&i.onError(ve.$t("wsPlayer.income.format.error"))}else Be(Je())},Oe=function(){let e=`<div id="${this.el}-custom-container" class="custom-division-container"></div>`;this.$el.append(e),Ue({locale:D,maxNum:this.config.maxNum,division:localStorage.customDivision||"",windowId:`${this.el}-custom-container`,callback:{onError:e=>{this.sendErrorMessage(610,{method:"customDivisionError",arguments:{},insert:[e]})},onConfirm:e=>{localStorage.customDivision=e,WSPlayerJQ.$(`#${this.el}-custom-container`).remove(),ce.call(this,e)},onCancel:()=>{WSPlayerJQ.$(`#${this.el}-custom-container`).remove()}}})},Ve=function(){let e=WSPlayerJQ.$(".ws-ctrl-ellipsis-list",this.$el);""===e.css("display")||"none"===e.css("display")?e.css("display","block"):e.css("display","none")},Ke=function(){return`\n <div id="${this.domId}" style="visibility: hidden; top: 150%; left: 0; width: 0; height: 0;" class="wsplayer-item wsplayer-item-${this.index} ${0===this.index?"selected":"unselected"}">\n <div class="ws-full-content ws-flex">\n <canvas id="${this.canvasId}" class="kind-stream-canvas" kind-channel-id="0" width="800" height="600" style="display:none;"></canvas>\n <video id="${this.videoId}" class="kind-stream-canvas" kind-channel-id="0" muted style="display:none" width="800" height="600"></video>\n <canvas id="${this.ivsCanvasId}" class="kind-stream-canvas" style="position: absolute; display:none;" kind-channel-id="0" width="800" height="600"></canvas>\n <div id="${this.cRawCanvasId}" class="kind-stream-canvas cRaw-container" style="position: absolute;" kind-channel-id="0" width="800" height="600"></div>\n <canvas id="${this.pztCanvasId}" class="kind-stream-canvas" style="display: none; position: absolute; z-index: 2;" kind-channel-id="0" width="800" height="600"></canvas>\n </div>\n <div class="default-status">\n <img src="${this.wsPlayer.prefixUrl}/WSPlayer/icon/default.png" alt="">\n </div>\n <div class="player-control top-control-bar">\n <div class="stream">\n <div class="select-container">\n <div class="select-show select">\n <div class="code-stream">${D.$t("storagePlan.stream.main")}</div>\n \x3c!-- 下拉箭头 --\x3e\n <img src="${this.wsPlayer.prefixUrl}/WSPlayer/icon/spread.png" />\n </div>\n <div class="stream-type" style="display: none">\n <ul class="select-ul">\n \x3c!--主码流--\x3e\n <li stream-type="1" class="stream-type-item">${D.$t("storagePlan.stream.main")}</li>\n \x3c!--辅码流1--\x3e\n <li stream-type="2" class="stream-type-item">${D.$t("video.player.sub.stream",[1])}</li>\n \x3c!--辅码流2--\x3e\n <li stream-type="3" class="stream-type-item">${D.$t("video.player.sub.stream",[2])}</li>\n </ul>\n </div>\n </div>\n <span class="stream-info"></span>\n </div>\n <div class="opt-icons">\n \x3c!--刷新重播--\x3e\n <div class="opt-icon ws-refresh-replay refresh-replay-icon" title='${D.$t("wsPlayer.refreshReplay")}'></div>\n \x3c!--智能帧--\x3e\n <div class="opt-icon ws-draw-triangle draw-triangle-icon off" title='${D.$t("wsPlayer.drawTriangle")}'></div>\n \x3c!--对讲--\x3e\n <div class="opt-icon ws-talk talk-icon off" title='${D.$t("wsPlayer.talk")}'></div>\n \x3c!--录像--\x3e\n <div class="opt-icon ws-record record-icon" title='${D.$t("wsPlayer.recording")}'></div>\n \x3c!--声音--\x3e\n <div class="opt-icon ws-audio audio-icon off" title='${D.$t("wsPlayer.sound")}'></div>\n \x3c!--抓图--\x3e\n <div class="opt-icon ws-capture capture-icon" title='${D.$t("wsPlayer.capture")}'></div>\n \x3c!--更多--\x3e\n <div class="opt-icon ws-more more-icon" title='${D.$t("common.more")}'>\n <div class="opt-icons-vertical">\n \x3c!--刷新重播--\x3e\n <div class="ws-refresh-replay" title='${D.$t("wsPlayer.refreshReplay")}'><div class="opt-icon refresh-replay-icon"></div><div class="ws-icon-tip">${D.$t("wsPlayer.refreshReplay")}</div></div>\n \x3c!--智能帧--\x3e\n <div class="ws-draw-triangle" title='${D.$t("wsPlayer.drawTriangle")}'><div class="opt-icon draw-triangle-icon off"></div><div class="ws-icon-tip">${D.$t("wsPlayer.drawTriangle")}</div></div>\n \x3c!--对讲--\x3e\n <div class="ws-talk" title='${D.$t("wsPlayer.talk")}'><div class="opt-icon talk-icon off"></div><div class="ws-icon-tip">${D.$t("wsPlayer.talk")}</div></div>\n \x3c!--录像--\x3e\n <div class="ws-record" title='${D.$t("wsPlayer.recording")}'><div class="opt-icon record-icon"></div><div class="ws-icon-tip">${D.$t("wsPlayer.recording")}</div></div>\n \x3c!--声音--\x3e\n <div class="ws-audio" title='${D.$t("wsPlayer.sound")}'><div class="opt-icon audio-icon off"></div><div class="ws-icon-tip">${D.$t("wsPlayer.sound")}</div></div>\n \x3c!--抓图--\x3e\n <div class="ws-capture" title='${D.$t("wsPlayer.capture")}'><div class="opt-icon capture-icon"></div><div class="ws-icon-tip">${D.$t("wsPlayer.capture")}</div></div>\n </div>\n </div>\n \x3c!--关闭--\x3e\n <div class="opt-icon ws-close close-icon" title='${D.$t("common.close")}'></div>\n </div>\n </div>\n <div class="ws-talking-recording">\n \x3c!--对讲中--\x3e\n <div class="ws-talking"></div>\n \x3c!--本地录制--\x3e\n <div class="ws-local-recording"></div>\n </div>\n <div class="error">\n <div class="wsplayer-error-message"></div>\n </div>\n </div>\n `},He=function(){return`\n <div id="${this.domId}" style="visibility: hidden; top: 150%; left: 0; width: 0; height: 0;" class="wsplayer-item wsplayer-item-${this.index} ${0===this.index?"selected":"unselected"}">\n <div class="ws-full-content ws-flex">\n <canvas id="${this.canvasId}" class="kind-stream-canvas" kind-channel-id="0" width="800" height="600" style="display:none;"></canvas>\n <video id="${this.videoId}" class="kind-stream-canvas" kind-channel-id="0" muted style="display:none" width="800" height="600"></video>\n <canvas id="${this.ivsCanvasId}" class="kind-stream-canvas" style="position: absolute; display:none;" kind-channel-id="0" width="800" height="600"></canvas>\n <div id="${this.cRawCanvasId}" class="kind-stream-canvas cRaw-container" style="position: absolute" kind-channel-id="0" width="800" height="600"></div>\n </div>\n <div class="default-status">\n <img src="${this.wsPlayer.prefixUrl}/WSPlayer/icon/default.png" alt="">\n </div>\n <div class="player-control top-control-bar">\n <span class="stream-info"></span>\n <div class="opt-icons">\n \x3c!--刷新重播--\x3e\n <div class="opt-icon ws-refresh-replay refresh-replay-icon" title='${D.$t("wsPlayer.refreshReplay")}'></div>\n \x3c!--智能帧--\x3e\n <div class="opt-icon ws-draw-triangle draw-triangle-icon off" title='${D.$t("wsPlayer.drawTriangle")}'></div>\n \x3c!--录像--\x3e\n <div class="opt-icon ws-record record-icon" title='${D.$t("wsPlayer.recording")}'></div>\n \x3c!--声音--\x3e\n <div class="opt-icon ws-audio audio-icon off" title='${D.$t("wsPlayer.sound")}'></div>\n \x3c!--抓图--\x3e\n <div class="opt-icon ws-capture capture-icon" title='${D.$t("wsPlayer.capture")}'></div>\n \x3c!--更多--\x3e\n <div class="opt-icon ws-more more-icon" title='${D.$t("common.more")}'>\n <div class="opt-icons-vertical">\n \x3c!--刷新重播--\x3e\n <div class="ws-refresh-replay" title='${D.$t("wsPlayer.refreshReplay")}'><div class="opt-icon refresh-replay-icon"></div><div class="ws-icon-tip">${D.$t("wsPlayer.refreshReplay")}</div></div>\n \x3c!--智能帧--\x3e\n <div class="ws-draw-triangle" title='${D.$t("wsPlayer.drawTriangle")}'><div class="opt-icon draw-triangle-icon off"></div><div class="ws-icon-tip">${D.$t("wsPlayer.drawTriangle")}</div></div>\n \x3c!--录像--\x3e\n <div class="ws-record" title='${D.$t("wsPlayer.recording")}'><div class="opt-icon record-icon"></div><div class="ws-icon-tip">${D.$t("wsPlayer.recording")}</div></div>\n \x3c!--声音--\x3e\n <div class="ws-audio" title='${D.$t("wsPlayer.sound")}'><div class="opt-icon audio-icon off"></div><div class="ws-icon-tip">${D.$t("wsPlayer.sound")}</div></div>\n \x3c!--抓图--\x3e\n <div class="ws-capture" title='${D.$t("wsPlayer.capture")}'><div class="opt-icon capture-icon"></div><div class="ws-icon-tip">${D.$t("wsPlayer.capture")}</div></div>\n </div>\n </div>\n \x3c!--关闭--\x3e\n <div class="ws-close opt-icon close-icon" title='${D.$t("common.close")}'></div>\n </div>\n </div>\n <div class="player-control record-control-bar">\n <div class="wsplayer-progress-bar">\n <div class="progress-bar_background"></div>\n <div class="progress-bar_hover_light"></div>\n <div class="progress-bar_light"></div>\n </div>\n <div class="record-control-left">\n <div class="opt-icon play-ctrl-btn play-icon play"></div>\n <div class="time-info"></div>/<div class="time-long"></div>\n </div>\n <div class="record-control-right">\n <div class="opt-icon close-icon"></div>\n </div>\n </div>\n <div class="ws-talking-recording">\n \x3c!--本地录制--\x3e\n <div class="ws-local-recording"></div>\n </div>\n <div class="error">\n <div class="wsplayer-error-message"></div>\n </div>\n <div class="play-pause-wrapper">\n <div class="play-ctrl-btn center-play-icon"></div>\n </div>\n </div>\n `},Xe=function(){return`<div class="ws-control">\n <div class="ws-flex ws-control-record ws-flex-left">\n <div class="ws-ctrl-record-icon ws-record-play" style="display: none" title='${D.$t("wsPlayer.play")}'></div>\n <div class="ws-ctrl-record-icon ws-record-pause" title='${D.$t("wsPlayer.pause")}'></div>\n <div class="ws-ctrl-record-icon ws-record-speed-sub" title='${D.$t("wsPlayer.speed.sub")}'></div>\n <div class="ws-ctrl-record-icon ws-record-speed-txt">1x</div>\n <div class="ws-ctrl-record-icon ws-record-speed-add" title='${D.$t("wsPlayer.speed.add")}'></div>\n </div>\n <div style="flex: 1;"></div>\n <div class="ws-flex ws-flex-end">\n <div id="btn-icon-adaption" class="ws-select-self-adaption">\n <div class="ws-select-show select">\n <div class="ws-select-show-option">${D.$t("wsPlayer.screen."+this.playerAdapter)}</div>\n \x3c!-- 下拉箭头 --\x3e\n <img src="${this.prefixUrl}/WSPlayer/icon/spread.png" />\n </div>\n <div class="ws-self-adaption-type" style="display: none">\n <ul class="ws-select-ul">\n \x3c!--自定义--\x3e\n <li value="selfAdaption" class="ws-select-type-item">${D.$t("wsPlayer.screen.selfAdaption")}</li>\n \x3c!--拉伸--\x3e\n <li value="stretching" class="ws-select-type-item">${D.$t("wsPlayer.screen.stretching")}</li>\n </ul>\n </div>\n </div>\n <span class="ws-ctrl-btn-spread ws-ctrl-btn-spread-1"></span>\n <div id="btn-icon-1" class="ws-ctrl-icon one-screen-icon" title='${D.$t("wsPlayer.screen.one")}'></div>\x3c!--单屏--\x3e\n <div id="btn-icon-2" class="ws-ctrl-icon two-screen-icon" title='${D.$t("wsPlayer.screen.split",[2])}'></div>\x3c!--2分屏--\x3e\n <div id="btn-icon-4" class="ws-ctrl-icon four-screen-icon" title='${D.$t("wsPlayer.screen.split",[4])}'></div>\x3c!--4分屏--\x3e\n <div id="btn-icon-9" class="ws-ctrl-icon nine-screen-icon" title='${D.$t("wsPlayer.screen.split",[9])}'></div>\x3c!--9分屏--\x3e\n <div id="btn-icon-more" class="ws-ctrl-icon screen-more-icon" title="${D.$t("wsplayer.more")}"></div>\x3c!--更多--\x3e\n <span class="ws-ctrl-btn-spread ws-ctrl-btn-spread-2"></span>\n <div id="btn-icon-close" class="ws-ctrl-icon close-all-video" title='${D.$t("wsPlayer.one.click.off")}'></div>\x3c!--一键关闭--\x3e\n <div id="btn-icon-full" class="ws-ctrl-icon full-screen-icon" title='${D.$t("wsPlayer.screen.full")}'></div>\x3c!--全屏--\x3e\n </div>\n <div class="ws-screen-num-list-container" style="display: none;">\n <div class="ws-screen-num-list-cont">\n <div id="btn-icon-3" class="ws-screen-num-list ws-screen-num-list-3" value="3">\n <div class="ws-screen-num-list-bg three-screen-icon"></div>\n <div class="ws-screen-num-list-text screen-3-text">${D.$t("wsPlayer.screen.split",[3])}</div>\n </div>\n <div id="btn-icon-6" class="ws-screen-num-list ws-screen-num-list-6" value="6">\n <div class="ws-screen-num-list-bg six-screen-icon"></div>\n <div class="ws-screen-num-list-text screen-6-text">${D.$t("wsPlayer.screen.split",[6])}</div>\n </div>\n <div id="btn-icon-8" class="ws-screen-num-list ws-screen-num-list-8" value="8">\n <div class="ws-screen-num-list-bg eight-screen-icon"></div>\n <div class="ws-screen-num-list-text screen-8-text">${D.$t("wsPlayer.screen.split",[8])}</div>\n </div>\n <div id="btn-icon-16" class="ws-screen-num-list ws-screen-num-list-16" value="16">\n <div class="ws-screen-num-list-bg sixteen-screen-icon"></div>\n <div class="ws-screen-num-list-text screen-16-text">${D.$t("wsPlayer.screen.split",[16])}</div>\n </div>\n <div id="btn-icon-25" class="ws-screen-num-list ws-screen-num-list-25" value="25">\n <div class="ws-screen-num-list-bg twenty-five-screen-icon"></div>\n <div class="ws-screen-num-list-text screen-25-text">${D.$t("wsPlayer.screen.split",[25])}</div>\n </div>\n \n <div id="btn-icon-custom" class="ws-screen-num-list ws-screen-num-list-diy" value="diy">\n <div class="ws-screen-num-list-bg custom-screen-icon"></div>\n <div class="ws-screen-num-list-text screen-diy-text">${D.$t("wsPlayer.screen.custom.split")}</div>\n </div>\n </div>\n </div>\n <div class="ws-ctrl-ellipsis" title='${D.$t("wsplayer.more")}'>\n <ul class="ws-ctrl-ellipsis-list">\n <li id="ws-record-pause">${D.$t("wsPlayer.pause")}</li>\n <li id="ws-record-play">${D.$t("wsPlayer.play")}</li>\n <li id="ws-record-speed-add">${D.$t("wsPlayer.fastForward")}</li>\n <li id="ws-record-speed-sub">${D.$t("wsPlayer.fastBackward")}</li>\n <li id="ws-select-stretching">${D.$t("wsPlayer.screen.stretching")}</li>\n <li id="ws-select-selfAdaption">${D.$t("wsPlayer.screen.selfAdaption")}</li>\n <li id="one-screen-icon">${D.$t("wsPlayer.screen.one")}</li>\n <li id="two-screen-icon">${D.$t("wsPlayer.screen.split",[2])}</li>\n <li id="four-screen-icon">${D.$t("wsPlayer.screen.split",[4])}</li>\n <li id="nine-screen-icon">${D.$t("wsPlayer.screen.split",[9])}</li>\n <li id="sixteen-screen-icon">${D.$t("wsPlayer.screen.split",[16])}</li>\n <li id="twenty-five-screen-icon">${D.$t("wsPlayer.screen.split",[25])}</li>\n <li id="three-screen-icon">${D.$t("wsPlayer.screen.split",[3])}</li>\n <li id="six-screen-icon">${D.$t("wsPlayer.screen.split",[6])}</li>\n <li id="eight-screen-icon">${D.$t("wsPlayer.screen.split",[8])}</li>\n <li id="custom-screen-icon">${D.$t("wsPlayer.screen.custom.split")}</li>\n <li id="close-all-video">${D.$t("wsPlayer.one.click.off")}</li>\n <li id="full-screen-icon">${D.$t("wsPlayer.screen.full")}</li>\n </ul>\n </div>\n </div>\n `},qe=function(){this.$el.append(Xe.call(this)),this.maxWindow<=16&&(WSPlayerJQ.$(".twenty-five-screen-icon",this.$el).css({display:"none"}),WSPlayerJQ.$("#twenty-five-screen-icon",this.$el).css({display:"none"}),WSPlayerJQ.$(".ws-screen-num-list-25",this.$el).css({display:"none"})),this.maxWindow<=9&&(WSPlayerJQ.$(".sixteen-screen-icon",this.$el).css({display:"none"}),WSPlayerJQ.$("#sixteen-screen-icon",this.$el).css({display:"none"}),WSPlayerJQ.$(".ws-screen-num-list-16",this.$el).css({display:"none"})),this.maxWindow<=8&&(WSPlayerJQ.$(".nine-screen-icon",this.$el).css({display:"none"}),WSPlayerJQ.$("#nine-screen-icon",this.$el).css({display:"none"}),WSPlayerJQ.$(".ws-screen-num-list-9",this.$el).css({display:"none"})),this.maxWindow<=6&&(WSPlayerJQ.$(".eight-screen-icon",this.$el).css({display:"none"}),WSPlayerJQ.$("#eight-screen-icon",this.$el).css({display:"none"}),WSPlayerJQ.$(".ws-screen-num-list-8",this.$el).css({display:"none"}),WSPlayerJQ.$(".ws-screen-num-list-container",this.$el).css({height:"unset"})),this.maxWindow<=4&&(WSPlayerJQ.$(".six-screen-icon",this.$el).css({display:"none"}),WSPlayerJQ.$("#six-screen-icon",this.$el).css({display:"none"}),WSPlayerJQ.$(".ws-screen-num-list-6",this.$el).css({display:"none"}),WSPlayerJQ.$(".ws-screen-num-list-container",this.$el).css({width:"120px",right:"80px"})),this.maxWindow<=3&&(WSPlayerJQ.$(".four-screen-icon",this.$el).css({display:"none"}),WSPlayerJQ.$("#four-screen-icon",this.$el).css({display:"none"}),WSPlayerJQ.$(".ws-screen-num-list-4",this.$el).css({display:"none"})),this.maxWindow<=2&&(WSPlayerJQ.$(".three-screen-icon",this.$el).css({display:"none"}),WSPlayerJQ.$("#three-screen-icon",this.$el).css({display:"none"}),WSPlayerJQ.$(".ws-screen-num-list-3",this.$el).css({display:"none"})),1===this.maxWindow&&(WSPlayerJQ.$(".two-screen-icon",this.$el).css({display:"none"}),WSPlayerJQ.$("#two-screen-icon",this.$el).css({display:"none"}),WSPlayerJQ.$(".one-screen-icon",this.$el).css({display:"none"}),WSPlayerJQ.$("#one-screen-icon",this.$el).css({display:"none"}),WSPlayerJQ.$(".custom-screen-icon",this.$el).css({display:"none"}),WSPlayerJQ.$("#custom-screen-icon",this.$el).css({display:"none"}),WSPlayerJQ.$(".ws-ctrl-btn-spread-2",this.$el).css({display:"none"}),WSPlayerJQ.$(".ws-screen-num-list-2",this.$el).css({display:"none"}),WSPlayerJQ.$(".screen-more-icon",this.$el).css({display:"none"})),WSPlayerJQ.$("#ws-select-stretching",this.$el).click(()=>{this.setPlayerAdapter("stretching")}),WSPlayerJQ.$("#ws-select-selfAdaption",this.$el).click(()=>{this.setPlayerAdapter("selfAdaption")}),WSPlayerJQ.$(".full-screen-icon",this.$el).click(()=>{this.setFullScreen()}),WSPlayerJQ.$("#full-screen-icon",this.$el).click(()=>{this.setFullScreen()}),WSPlayerJQ.$(".one-screen-icon",this.$el).click(()=>{this.setPlayerNum(1)}),WSPlayerJQ.$("#one-screen-icon",this.$el).click(()=>{this.setPlayerNum(1)}),WSPlayerJQ.$(".two-screen-icon",this.$el).click(()=>{this.setPlayerNum(2)}),WSPlayerJQ.$("#two-screen-icon",this.$el).click(()=>{this.setPlayerNum(2)}),WSPlayerJQ.$(".three-screen-icon",this.$el).click(()=>{this.setPlayerNum(3)}),WSPlayerJQ.$("#three-screen-icon",this.$el).click(()=>{this.setPlayerNum(3)}),WSPlayerJQ.$(".four-screen-icon",this.$el).click(()=>{this.setPlayerNum(4)}),WSPlayerJQ.$("#four-screen-icon",this.$el).click(()=>{this.setPlayerNum(4)}),WSPlayerJQ.$(".six-screen-icon",this.$el).click(()=>{this.setPlayerNum(6)}),WSPlayerJQ.$("#six-screen-icon",this.$el).click(()=>{this.setPlayerNum(6)}),WSPlayerJQ.$(".eight-screen-icon",this.$el).click(()=>{this.setPlayerNum(8)}),WSPlayerJQ.$("#eight-screen-icon",this.$el).click(()=>{this.setPlayerNum(8)}),WSPlayerJQ.$(".nine-screen-icon",this.$el).click(()=>{this.setPlayerNum(9)}),WSPlayerJQ.$("#nine-screen-icon",this.$el).click(()=>{this.setPlayerNum(9)}),WSPlayerJQ.$(".sixteen-screen-icon",this.$el).click(()=>{this.setPlayerNum(16)}),WSPlayerJQ.$("#sixteen-screen-icon",this.$el).click(()=>{this.setPlayerNum(16)}),WSPlayerJQ.$(".twenty-five-screen-icon",this.$el).click(()=>{this.setPlayerNum(25)}),WSPlayerJQ.$("#twenty-five-screen-icon",this.$el).click(()=>{this.setPlayerNum(25)}),WSPlayerJQ.$(".close-all-video",this.$el).click(()=>{this.close(void 0,"btnClick")}),WSPlayerJQ.$("#close-all-video",this.$el).click(()=>{this.close(void 0,"btnClick")}),WSPlayerJQ.$(".custom-screen-icon",this.$el).click(()=>{Oe.call(this)}),WSPlayerJQ.$("#custom-screen-icon",this.$el).click(()=>{Oe.call(this)}),WSPlayerJQ.$(".ws-ctrl-ellipsis",this.$el).click(()=>{Ve.call(this)}),this.iconScreenCurSelectShow=!1,WSPlayerJQ.$("#btn-icon-more",this.$el).click(e=>{this.iconScreenCurSelectShow?(WSPlayerJQ.$(".ws-screen-num-list-container",this.$el).hide(),this.iconScreenCurSelectShow=!1):(WSPlayerJQ.$(".ws-screen-num-list-container",this.$el).show(),this.iconScreenCurSelectShow=!0)}),this.selfAdaptionSelectShow=!1,WSPlayerJQ.$(".ws-select-self-adaption",this.$el).click(e=>{WSPlayerJQ.$(".ws-screen-num-list-container",this.$el).hide(),this.selfAdaptionSelectShow?(WSPlayerJQ.$(".ws-self-adaption-type",this.$el).hide(),this.selfAdaptionSelectShow=!1):(WSPlayerJQ.$(".ws-self-adaption-type",this.$el).show(),this.selfAdaptionSelectShow=!0,WSPlayerJQ.$(".ws-select-ul .ws-select-type-item",this.$el).css({background:"none"}),WSPlayerJQ.$(`.ws-select-ul [value=${this.playerAdapter}]`,this.$el).css({background:"#1A78EA"}))}),WSPlayerJQ.$(".ws-self-adaption-type",this.$el).click(e=>{let t=e.target.getAttribute("value");this.setPlayerAdapter(t),WSPlayerJQ.$(".ws-select-show-option",this.$el).text(this.wsAdaption[t])}),"record"!==this.type&&(WSPlayerJQ.$(".ws-control-record",this.$el).css({display:"none"}),WSPlayerJQ.$("#ws-record-pause",this.$el).css({display:"none"}),WSPlayerJQ.$("#ws-record-play",this.$el).css({display:"none"}),WSPlayerJQ.$("#ws-record-speed-add",this.$el).css({display:"none"}),WSPlayerJQ.$("#ws-record-speed-sub",this.$el).css({display:"none"})),WSPlayerJQ.$(".ws-record-pause",this.$el).click(e=>{this.pause()}),WSPlayerJQ.$("#ws-record-pause",this.$el).click(e=>{this.pause()}),WSPlayerJQ.$(".ws-record-play",this.$el).click(e=>{this.play()}),WSPlayerJQ.$("#ws-record-play",this.$el).click(e=>{this.play()}),WSPlayerJQ.$(".ws-record-speed-sub",this.$el).click(e=>{"playing"===this.playerList[this.selectIndex].status&&this.__setPlaySpeed("PREV")}),WSPlayerJQ.$("#ws-record-speed-sub",this.$el).click(e=>{"playing"===this.playerList[this.selectIndex].status&&this.__setPlaySpeed("PREV")}),WSPlayerJQ.$(".ws-record-speed-add",this.$el).click(e=>{"playing"===this.playerList[this.selectIndex].status&&this.__setPlaySpeed("NEXT")}),WSPlayerJQ.$("#ws-record-speed-add",this.$el).click(e=>{"playing"===this.playerList[this.selectIndex].status&&this.__setPlaySpeed("NEXT")}),WSPlayerJQ.$(document).on("click",e=>{let t=WSPlayerJQ.$(".ws-screen-num-list-container",this.$el),s=WSPlayerJQ.$("#btn-icon-more",this.$el);t.is(e.target)||0!==t.has(e.target).length||s.is(e.target)||0!==s.has(e.target).length||(t.hide(),this.iconScreenCurSelectShow=!1);let i=WSPlayerJQ.$(".select-container",this.$el),r=WSPlayerJQ.$(".stream-type",this.$el);r.is(e.target)||0!==r.has(e.target).length||i.is(e.target)||0!==i.has(e.target).length||r.hide()})},je=function(){this.$el.append('\n <div class="ws-control ws-record-control">\n <canvas id="wsplayer-record-progress" height="60" class="ws-record-area"></canvas>\n </div>\n ');let{fontSize:e,centerFontSize:t,rulerLength:s,recordsColor:i,fontOffsetX:r,centerFontOffsetX:a}=this.config.recordProgressStyle;this.recordProgressRuler=new fe({canvasId:`#${this.el} canvas#wsplayer-record-progress`,records:[],currentTime:w.getToday12Time(),fontSize:e,centerFontSize:t,centerFontOffsetX:a,fontOffsetX:r,rulerLength:s||{short:10,middle:20,long:25},recordsColor:i,rulerScale:2,getCurrentTime:e=>{this.clickRecordsTimer&&clearTimeout(this.clickRecordsTimer),this.clickRecordsTimer=setTimeout(()=>{clearTimeout(this.clickRecordsTimer),this.clickRecordsTimer=null},1500),this.clickRecordTimeLine(e),this.play()}})};class Ye extends me{constructor(e){super(e),this.currentIndex=e.index,this.wrapperDomId=e.wrapperDomId,this.type="real",this.i18n=e.locale,this.options={},this.chromeResourceOutOfMemory=!1,this.initDom(),this.defaultStatus=WSPlayerJQ.$(".default-status",this.$el),this.error=WSPlayerJQ.$(".error",this.$el),this.controller=WSPlayerJQ.$(".player-control",this.$el),this.controller.dblclick(e=>{e.stopPropagation()}),this.initMouseEvent(),this.setStatus("created"),this.isFirstInfo=!0}getTemplate(){return Ke.call(this)}initMouseEvent(){super.initMouseEvent();let e=this;this.hideTimer=null,this.$el.on("mouseenter mousemove",e=>{this.wsPlayer.config.showTopOperate&&(["created","closed"].includes(this.status)||this.setDomVisible(WSPlayerJQ.$(".player-control",WSPlayerJQ.$(`#${this.wrapperDomId}-${this.currentIndex}`)),!0),"playing"!==this.status&&"error"!==this.status||this.hideTimer&&clearTimeout(this.hideTimer))}),this.$el.on("mouseleave",e=>{this.wsPlayer.config.showTopOperate&&(this.hideTimer=setTimeout(()=>{WSPlayerJQ.$(".stream-type",this.$el).hide(),this.setDomVisible(WSPlayerJQ.$(".player-control",WSPlayerJQ.$(`#${this.wrapperDomId}-${this.currentIndex}`)),!1),this.streamSelectShow=!1,this.setDomVisible(WSPlayerJQ.$(".opt-icons-vertical",this.$el),!1),this.showMoreIcon=!1},300))}),this.streamSelectShow=!1,WSPlayerJQ.$(".select",this.$el).click(e=>{this.streamSelectShow?(WSPlayerJQ.$(".stream-type",this.$el).hide(),this.streamSelectShow=!1):(WSPlayerJQ.$(".stream-type",this.$el).show(),this.streamSelectShow=!0)}),WSPlayerJQ.$(".stream-type",this.$el).click(t=>{let s=t.target.getAttribute("stream-type");e.streamType!==s&&e.options&&("url"===e.playType?e.wsPlayer.sendMessage("changeStreamType",{channelData:e.options.channelData,channelInfo:{...this.options},streamType:Number(s),selectIndex:e.index}):e.wsPlayer.changeStreamType(e.options.channelData,s,e.index,"changeStreamType"))})}setStreamType(e){this.streamType=e;let t=WSPlayerJQ.$(".stream-type .select-ul",this.$el)[0].children[e-1],s=t&&WSPlayerJQ.$(t).text();WSPlayerJQ.$(".code-stream",this.$el).text(s),t&&WSPlayerJQ.$(t).addClass("stream-type-select").siblings().removeClass("stream-type-select")}setStatus(e,t){switch(this.wsPlayer.sendMessage("statusChanged",{status:e,windowIndex:this.index,selectIndex:this.index}),this.status=e,this.currentWindowPlaying=!1,this.status){case"created":case"closed":this.setDomVisible(this.defaultStatus,!0),this.setDomVisible(this.error,!1),this.setDomVisible(this.controller,!1),this.isAudioPlay=!1,WSPlayerJQ.$(".audio-icon",this.$el).removeClass("on").addClass("off");break;case"loading":case"ready":case"showmsg":this.setDomVisible(this.defaultStatus,!1),this.setDomVisible(this.error,!1);break;case"playing":case"pause":self.isclosing=!1,this.currentWindowPlaying=!0,this.setDomVisible(this.defaultStatus,!1),this.setDomVisible(this.error,!1);break;case"streamError":const{selectIndex:e,channelData:s={}}=this.options;this.wsPlayer.sendMessage("realError",{selectIndex:e,channelData:{...s},channelInfo:{...this.options}},{code:t.errorCode,msg:i.errorVideoInfo[t.errorCode]}),this.close(!0,!1,"none","playSDKError");case"error":self.isclosing=!1,this.showMsgInWindow(i.errorVideoInfo[t.errorCode]?i.errorVideoInfo[t.errorCode]:i.errorVideoInfo.defaultErrorMsg)}}init(e){if(this.wsPlayer.config.isDynamicLoadLib&&!window.m_nModuleInitialized){let t=setTimeout(()=>{this.init(e),clearTimeout(t)},100);return}let t=(this.options||{}).channelId===e.channelId;if(this.options=e,this.playSDK&&(this.isAudioPlay&&WSPlayerJQ.$(".audio-icon",this.$el).removeClass("on").addClass("off"),this.close(!0,t,"closed",e.closeReason||"changeStream")),this.setLoading(!0,"ready",e.closeReason),this.setStreamType(e.streamType),this.chromeResourceOutOfMemory)return this.wsPlayer.close(this.currentIndex,"chromeMemoryOut"),console.warn("浏览器资源不足, 请等待3-5秒后重试"),this.wsPlayer.sendMessage("chromeMemoryOut",{channelInfo:{...this.options},channelData:this.options&&{...this.options.channelData},selectIndex:this.currentIndex,message:this.i18n.$t("wsPlayer.chromeMemoryOut")});this.isclosing?this.isclosing=!1:K.call(this,this.wsPlayer.config,e)}startTalk(e){!this.wsPlayer.config.isDynamicLoadLib||window.m_nModuleInitialized?(this.talkData=e.talkData,X.call(this,e,e.talkData)):this.wsPlayer.sendErrorMessage("502")}talkByUrl(e){if(!this.wsPlayer.config.isDynamicLoadLib||window.m_nModuleInitialized)if(this.currentWindowPlaying){if(![2,4].includes(Number(e.audioType))){let t={1:307,3:308,4:309,5:310,8:311,101:312};return void this.wsPlayer.sendErrorMessage(t[e.audioType],{channelList:[e]})}X.call(this,e,e)}else this.wsPlayer.sendErrorMessage("614");else this.wsPlayer.sendErrorMessage("502")}stopTalk(e){if(this.talkPlaySDK&&window.wsPlayerManager.unbindPlayer(this.talkPlaySDK.nPlayPort),"url"!==e&&this.talkData&&this.wsPlayer.stopTalk(this.talkData),this.isTalking&&(this.wsPlayer.isTalking=!1,this.isTalking=!1),this.talkPlaySDK&&(this.talkPlaySDK.StopTalk(),this.talkPlaySDK.StopPullStream(),this.talkPlaySDK=null),WSPlayerJQ.$(".talk-icon",this.$el).removeClass("on").addClass("off"),WSPlayerJQ.$(".ws-talking",this.$el).css({visibility:"hidden"}),this.closeVolume(),this.options&&"url"===this.options.playType){const{selectIndex:e,channelData:t={}}=this.options;this.wsPlayer.sendMessage("stopTalk",{selectIndex:e,channelData:{...t},channelInfo:{...this.options}})}}}class Ge extends me{constructor(e){super(e),this.currentIndex=e.index,this.wrapperDomId=e.wrapperDomId,this.i18n=e.locale,this.speed=1,this.curTimestamp=0,this.type="record",this.initDom(),this.defaultStatus=WSPlayerJQ.$(".default-status",this.$el),this.error=WSPlayerJQ.$(".error",this.$el),this.controller=WSPlayerJQ.$(".player-control",this.$el),this.timeInfo=WSPlayerJQ.$(".time-info",this.$el),this.chromeResourceOutOfMemory=!1,this.initMouseEvent(),this.setStatus("created"),this.isFirstInfo=!0}getTemplate(){return He.call(this)}initMouseEvent(){super.initMouseEvent(),this.hideTimer=null,this.$el.on("mouseenter mousemove",e=>{this.wsPlayer.config.showTopOperate&&(["created","closed"].includes(this.status)||this.setDomVisible(WSPlayerJQ.$(".player-control",WSPlayerJQ.$(`#${this.wrapperDomId}-${this.currentIndex}`)),!0),"playing"===this.status?this.hideTimer&&clearTimeout(this.hideTimer):"ready"===this.status&&this.setDomVisible(this.progressBar,!0))}),this.$el.on("mouseleave",e=>{this.wsPlayer.config.showTopOperate&&"pause"!==this.status&&(this.hideTimer=setTimeout(()=>{this.setDomVisible(WSPlayerJQ.$(".player-control",WSPlayerJQ.$(`#${this.wrapperDomId}-${this.currentIndex}`)),!1),this.setDomVisible(WSPlayerJQ.$(".opt-icons-vertical",this.$el),!1),this.showMoreIcon=!1},300))}),WSPlayerJQ.$(".wsplayer-progress-bar",this.$el).on("mousemove",e=>{WSPlayerJQ.$(".progress-bar_hover_light",this.$el).css({width:e.offsetX+"px"})}),WSPlayerJQ.$(".wsplayer-progress-bar",this.$el).on("mouseleave",e=>{WSPlayerJQ.$(".progress-bar_hover_light",this.$el).css({width:0})}),WSPlayerJQ.$(".play-ctrl-btn",this.$el).click(e=>{"recordFinish"===this.status&&("url"===this.playType&&this.wsPlayer.sendMessage("refreshReplay",{selectIndex:this.options.selectIndex,channelInfo:{...this.options},channelData:{...this.options.channelData||{}}}),this.wsPlayer.playRecordVideo({channelList:[{...this.options.channelData}],startTime:this.options.startTime,endTime:this.options.endTime,recordSource:this.options.recordSource,streamType:this.options.streamType,recordType:this.options.recordType,windowIndex:this.index,playRecordByFile:this.options.playRecordByFile})),"playing"===this.status?(this.pause(),WSPlayerJQ.$(".play-icon",this.$el).removeClass("play").addClass("pause")):(this.play(),WSPlayerJQ.$(".play-icon",this.$el).removeClass("pause").addClass("play"))})}setStatus(e,t){this.wsPlayer.sendMessage("statusChanged",{status:e,windowIndex:this.index,selectIndex:this.index}),this.status=e,this.currentWindowPlaying=!1;let{selectIndex:s,channelData:r={}}=this.options||{};switch(this.status){case"created":case"closed":this.setDomVisible(this.defaultStatus,!0),this.setDomVisible(this.error,!1),this.setDomVisible(this.controller,!1),this.isAudioPlay=!1,WSPlayerJQ.$(".audio-icon",this.$el).removeClass("on").addClass("off");break;case"loading":case"ready":case"showmsg":this.setDomVisible(this.defaultStatus,!1),this.setDomVisible(this.error,!1);break;case"playing":this.currentWindowPlaying=!0,this.setDomVisible(this.defaultStatus,!1),this.setDomVisible(this.error,!1),this.setDomVisible(WSPlayerJQ.$(".play-pause-wrapper",this.$el),!1);break;case"pause":this.currentWindowPlaying=!0,this.setDomVisible(this.defaultStatus,!1),this.setDomVisible(this.error,!1),this.setDomVisible(this.controller,!1),this.setDomVisible(WSPlayerJQ.$(".play-pause-wrapper",this.$el),!0);break;case"streamError":let e=setTimeout(()=>{this.close(!0,!1,"none","playSDKError"),clearTimeout(e)},0);this.wsPlayer.sendMessage("recordError",{selectIndex:s,channelData:{...r},channelInfo:{...this.options}},{code:t.errorCode,msg:i.errorVideoInfo[t.errorCode]}),this.showMsgInWindow(i.errorVideoInfo[t.errorCode]?i.errorVideoInfo[t.errorCode]:i.errorVideoInfo.defaultErrorMsg);break;case"recordFinish":let a=setTimeout(()=>{this.close(!0,!1,"recordFinish","recordFinish"),clearTimeout(a)},0);this.wsPlayer.sendMessage("recordFinish",{selectIndex:s,channelData:{...r},channelInfo:{...this.options}}),this.showMsgInWindow(i.errorVideoInfo[t.errorCode]?i.errorVideoInfo[t.errorCode]:i.errorVideoInfo.defaultErrorMsg);break;case"error":this.showMsgInWindow(i.errorVideoInfo[t.errorCode]?i.errorVideoInfo[t.errorCode]:i.errorVideoInfo.defaultErrorMsg)}}init(e){if(this.wsPlayer.config.isDynamicLoadLib&&!window.m_nModuleInitialized){let t=setTimeout(()=>{this.init(e),clearTimeout(t)},100);return}if(this.options=e,this.playSDK&&(this.isAudioPlay&&WSPlayerJQ.$(".audio-icon",this.$el).removeClass("on").addClass("off"),this.close(!0,!1,e.isSeekRecord?"seekRecord":"closed",e.isSeekRecord?"seekRecord":e.closeReason||"changeStream")),!e.isSeekRecord&&this.setLoading(!0),this.chromeResourceOutOfMemory)return this.wsPlayer.close(this.currentIndex,"chromeMemoryOut"),console.warn("浏览器资源不足, 请等待3-5秒后重试"),this.wsPlayer.sendMessage("chromeMemoryOut",{message:this.i18n.$t("wsPlayer.chromeMemoryOut"),channelData:this.options&&this.options.channelData,channelInfo:{...this.options},selectIndex:this.currentIndex});e.isSeekRecord?(M("Seek Run StartPullStream!"),this.playSDK.m_rtspvHandle=this.playSDK.StartPullStream({strRtspvUri:e.wsURL,strRtspvUrl:e.rtspURL,bStandardPack:this.wsPlayer.config.isRTPStream,strSourceId:"",bTalkService:!1,nRange:0,nShortTimeout:this.wsPlayer.rtspResponseTimeout||8,nRtspResponseTimeout:this.wsPlayer.rtspResponseTimeout+2||10}),this.playSDK.SetSpeed(this.speed),window.wsPlayerManager.bindHandlePlayer(this.playSDK.m_rtspvHandle,this.playSDK)):H.call(this,this.wsPlayer.config,e)}playSpeed(e){this.speed=e,1!==e&&this.closeVolume(),this.playSDK&&this.playSDK.SetSpeed(e)}}class Ze{constructor(){s(this,"cPlusMediaFrameCallBack",function(e,t,s,i){this.handleToPlayer[e]&&this.handleToPlayer[e].InputDataEx(s,i)}),s(this,"cPlusRtspMsgCallBack",function(e,t,s){switch(M("====cPlusRtspMsgCallBack====",t,s),t){case 4096:setTimeout(()=>{this.handleToPlayer[e].StreamFailedCallback(s)},500);break;case 4097:break;case 4099:this.handleToPlayer[e]&&this.handleToPlayer[e].StreamMsgPlay();break;case 4100:this.handleToPlayer[e]&&this.handleToPlayer[e].StreamFinishCallback();break;case 4102:let t=this.handleToPlayer[e];this.wsPlayerList.forEach(e=>{e.playerList.forEach((i,r)=>{i.talkPlaySDK!==t&&i.playSDK!==t||e.dealRTSPError(s,r)})});break;case 4104:this.handleToPlayer[e].StreamRedirectCallback(s);break;case 4109:this.handleToPlayer[e].StreamDisconnectCallback()}}),s(this,"cPlusRtsvMsgCallBack",function(e,t,s){switch(t){case 16385:break;case 16386:this.handleToPlayer[e]&&this.handleToPlayer[e].StreamFinishCallback()}}),s(this,"cIVSDrawDataCallBack",function(e,t,s,i,r){this.portToPlayer[e]&&this.portToPlayer[e].SetIVSDrawData(e,t,s,i,r)}),this.wsPlayerList=[],this.portToPlayer={},this.handleToPlayer={},this.canvasToPlayer={},window.cPlusVisibleDecCallBack=this.cPlusVisibleDecCallBack.bind(this),window.cDigitalSignCallBack=this.cDigitalSignCallBack.bind(this),window.cRecordDataCallBack=this.cRecordDataCallBack.bind(this),window.cIVSDrawDataCallBack=this.cIVSDrawDataCallBack.bind(this),window.cPlusMediaFrameCallBack=this.cPlusMediaFrameCallBack.bind(this),window.cPlusRtspMsgCallBack=this.cPlusRtspMsgCallBack.bind(this),window.cPlusRtsvMsgCallBack=this.cPlusRtsvMsgCallBack.bind(this),window.cDemuxDecCBFun=this.cDemuxDecCBFun.bind(this)}cPlusVisibleDecCallBack(e,t,s,i,r,a){this.portToPlayer[e]&&this.portToPlayer[e].SetFrameData(e,t,s,i,r,a)}cDigitalSignCallBack(e,t,s){this.portToPlayer[e]&&this.portToPlayer[e].SetDecryptionResult(e,t,s)}cDemuxDecCBFun(e,t,s,i){this.handleToPlayer[e]&&this.handleToPlayer[e].cDemuxDecCBFun(e,t,s,i)}cRecordDataCallBack(e,t,s,i,r){this.portToPlayer[e]&&this.portToPlayer[e].SetRecordData(e,t,s,i,r)}bindPlayer(e,t){this.portToPlayer[e]||(this.portToPlayer[e]=t)}unbindPlayer(e){this.portToPlayer[e]=null}bindHandlePlayer(e,t){this.handleToPlayer[e]||(this.handleToPlayer[e]=t)}unbindHandlePlayer(e){this.handleToPlayer[e]=null}bindCanvasPlayer(e,t){this.canvasToPlayer[e]||(this.canvasToPlayer[e]=t)}unbindCanvasPlayer(e){this.canvasToPlayer[e]=null}addWSPlayer(e){this.wsPlayerList.push(e)}removeWSPlayer(e){this.wsPlayerList=this.wsPlayerList.filter(t=>t===e)}}const et={data:{dataType:"3",streamType:"2",channelId:"",urlType:1,packtype:"Private"}},tt={data:{deviceCode:"",talkType:"1",audioBit:16,audioType:2,sampleRate:8e3,talkMode:"",channelSeq:"0",enableGBParamAutoAdapt:1,urlType:1,optModule:"ADMIN_001031",audioTypeList:["2","4"]}},st={data:{streamType:"0",recordType:"0",recordSource:"3",startTime:"",endTime:"",channelId:""}},it={data:{recordType:"0",recordSource:"1",streamType:"1",channelId:"",startTime:"",endTime:"",urlType:"1"}},rt={data:{ssId:"",startTime:"",endTime:"",fileName:"",diskId:"",recordSource:"",channelId:"",streamId:"",urlType:"1"}},at={1:307,3:308,4:309,5:310,8:311,101:312};class lt{constructor(e){this.realPlayer=null,this.recordPlayer=null,this.playCenterRecordByTime=e.playCenterRecordByTime,this.i18n=e.i18n,"real"===e.type?this.realPlayer=e.player:this.recordPlayer=e.player,this.playIndex=0,this.recordList=[],this.getRealRtsp=e.getRealRtsp,this.getRecords=e.getRecords,this.getRecordRtspByTime=e.getRecordRtspByTime,this.getRecordRtspByFile=e.getRecordRtspByFile,this.getTalkRtsp=e.getTalkRtsp,this.stopTalk=e.stopTalk}concatToken(e,t){return e.includes("myToken")?e:t&&!e.includes("token=")?e+(e.includes("?")?"&":"?")+"token="+t:e}getCurrentRtsp(e,t){const s=this.getRTSPUrls(e),i=s.find(e=>e.includes(window.location.hostname))||s[0];return this.concatToken(i,t)}getRTSPUrls(e){return e.split("|").filter(e=>!e.includes("localhost")&&!e.includes("127.0.0.1")&&!e.startsWith("rtsp://["))}processResponse(e,t){try{return"string"==typeof e&&e.includes("rtsp://")&&e.includes("&token=")?{url:e,innerIp:null}:e.url&&e||e.data.url&&e.data||e.data.data.url&&e.data.data}catch{return null}}getWSUrl(e){return this.getRTSPUrls(e).map(e=>e.split("//")[1].split("/")[0])}wssRedirectParam(e){"wss"===((this.realPlayer||this.recordPlayer).protocol||("https:"===window.location.protocol?"wss":"ws"))&&(e.data.clientSupportWSSDirect=1,e.data.enableXNetFlag=1)}playRealVideo(e,t="2",s,i=!1,r){if(!w.validFunction(this.getRealRtsp))return void this.realPlayer.sendErrorMessage(608,{insert:[this.i18n.$t("wsPlayer.request.realtime.preview.interface"),"getRealRtsp"]});let a="number"==typeof s?s:this.playIndex;"number"==typeof this.realPlayer.showNum?this.realPlayer.openSomeWindow(a+e.length):e=e.slice(0,JSON.parse(this.realPlayer.showNum).length-a),"number"==typeof this.realPlayer.showNum?this.realPlayer.setSelectIndex(Math.min(a+e.length,this.realPlayer.showNum-1)):"string"==typeof this.realPlayer.showNum&&opt.selectIndex+1<JSON.parse(this.showNum).length&&this.realPlayer.setSelectIndex(Math.min(a+e.length,JSON.parse(this.realPlayer.showNum).length-1)),e.map((e,s)=>{let l=a+s;et.data.streamType=t,et.data.channelId=e.id,e.deviceCode=e.deviceCode||e.id&&e.id.split("$1$0$")[0],e.channelSeq=e.channelSeq||e.id&&e.id.split("$1$0$")[1],this.wssRedirectParam(et),this.realPlayer.setLoading(l,!e.isWaiting,"loading",r),this.getRealRtsp(JSON.parse(JSON.stringify(et))).then(s=>{if(this.realPlayer.playerList[l].isclosing)return void(this.realPlayer.playerList[l].isclosing=!1);let i=this.processResponse(s,e);if(!i)return this.realPlayer.sendErrorMessage(103,{channelList:[e]});i.rtspURL=this.getCurrentRtsp(i.url,i.token),pe.call(this.realPlayer,{selectIndex:l,streamServerIp:i.innerIp,rtspURL:i.rtspURL,channelId:e.id,channelData:e,streamType:t,wsList:this.getWSUrl(i.url),wssDirect:i.wssDirect,closeReason:r})},t=>{this.realPlayer.setLoading(l,!1,"closed");let s={channelList:[e],channelData:{...e},selectIndex:l,apiErrorInfo:t};t?401===Number(t.status)||27001007===Number(t.code)?this.realPlayer.sendErrorMessage(102,s):3033===Number(t.code)?(this.realPlayer.showMsgInWindow(l,D.$t("wsPlayer.error.105"),e),this.realPlayer.sendErrorMessage(105,s)):2084===Number(t.code)?(this.realPlayer.showMsgInWindow(l,D.$t("wsPlayer.play.error.402"),e),this.realPlayer.sendErrorMessage(402,s)):i?(this.realPlayer.showMsgInWindow(l,D.$t("wsPlayer.error.103"),e),this.realPlayer.sendErrorMessage(103,s)):this.playRealVideo([e],"1",l,!0,r):this.realPlayer.sendErrorMessage(108)})})}startTalk(e){if(!w.validFunction(this.getTalkRtsp))return void this.realPlayer.sendErrorMessage(608,{insert:[this.i18n.$t("wsPlayer.request.talk.interface"),"getTalkRtsp"]});tt.data.deviceCode=e.deviceCode,tt.data.audioBit=e.audioBit||16,tt.data.sampleRate=e.sampleRate||8e3,[1,3,6,10,13,14,43].includes(e.deviceType)?(tt.data.talkType="2",tt.data.channelSeq=e.channelSeq):(tt.data.talkType="1",tt.data.channelSeq="0"),this.wssRedirectParam(tt);let t={talkType:tt.data.talkType,deviceCode:e.deviceCode,session:"",channelSeq:tt.data.channelSeq,audioType:2,sampleRate:8e3,audioBit:16},s=s=>{ye.call(this.realPlayer,{selectIndex:this.realPlayer.talkIndex,channelId:e.id,channelData:e,wssDirect:s.wssDirect,rtspURL:this.getCurrentRtsp(s.url,s.token),streamServerIp:s.innerIp,wsList:this.getWSUrl(s.url),talkData:t,gbDevice:s.gbDevice})};this.getTalkRtsp(JSON.parse(JSON.stringify(tt))).then(i=>{let r=this.processResponse(i,e);return r?(t.session=r.session,t.audioType=r.audioType,t.sampleRate=r.sampleRate,t.audioBit=r.audioBit,"2"!==t.audioType&&"4"!==t.audioType?(this.stopTalk({data:t}),tt.data.audioType=4,void this.getTalkRtsp(JSON.parse(JSON.stringify(tt))).then(i=>(r=this.processResponse(i,e),r?(t.session=r.session,t.audioType=r.audioType,t.sampleRate=r.sampleRate,t.audioBit=r.audioBit,"4"!==i.audioType?(this.realPlayer.sendErrorMessage(at[t.audioType],{channelList:[e]}),void this.stopTalk({data:t})):void s(r)):this.realPlayer.sendErrorMessage(304,{channelList:[e]}))).catch(t=>{this.realPlayer.sendErrorMessage(304,{channelList:[e],apiErrorInfo:t})})):void s(r)):this.realPlayer.sendErrorMessage(304,{channelList:[e]})}).catch(t=>{this.realPlayer.sendErrorMessage(304,{channelList:[e],apiErrorInfo:t})})}getRecordList(e){if(!w.validFunction(this.getRecords))return void this.recordPlayer.sendErrorMessage(608,{insert:[this.i18n.$t("wsPlayer.request.recording.interface"),"getRecords"]});e.playRecordByTime=!e.playRecordByFile,st.data.streamType=e.streamType||"0",st.data.recordType=e.recordType||"0",st.data.recordSource=e.recordSource||1,st.data.startTime=e.startTime,st.data.endTime=e.endTime;let t="number"==typeof e.windowIndex?e.windowIndex:this.playIndex;"number"==typeof this.recordPlayer.showNum?e.channelList.length>1&&this.recordPlayer.openSomeWindow(t+e.channelList.length):e.channelList=e.channelList.slice(0,JSON.parse(this.recordPlayer.showNum).length-t),"number"==typeof this.recordPlayer.showNum?this.recordPlayer.setSelectIndex(Math.min(t+e.channelList.length,this.recordPlayer.showNum-1)):"string"==typeof this.recordPlayer.showNum&&e.selectIndex+1<JSON.parse(this.showNum).length&&this.recordPlayer.setSelectIndex(Math.min(t+e.channelList.length,JSON.parse(this.recordPlayer.showNum).length-1)),e.channelList.forEach((s,i)=>{let r=t+i;this.recordPlayer.setLoading(r,!s.isWaiting,"loading",e.closeReason),st.data.channelId=s.id;let a=[];if("0"==st.data.streamType){a.push(this.getRecords(JSON.parse(JSON.stringify(st))));let e=JSON.parse(JSON.stringify(st));e.data.streamType="3",a.push(this.getRecords(e))}else a.push(this.getRecords(JSON.parse(JSON.stringify(st))));Promise.allSettled(a).then(t=>{let i=[],a=[];if(t[0]&&"rejected"===t[0].status&&t[1]&&"rejected"===t[1].status){this.recordPlayer.setLoading(r,!1,"closed");let i={channelList:[s],channelData:{...s},selectIndex:r,apiErrorInfo:t[0].reason};return void(t[0].reason.code?3033===Number(t[0].reason.code)?(this.recordPlayer.showMsgInWindow(r,D.$t("wsPlayer.error.205"),e.channel),this.recordPlayer.sendErrorMessage(205,i)):(this.recordPlayer.showMsgInWindow(r,D.$t("wsPlayer.error.202"),s),this.recordPlayer.sendErrorMessage(202,i)):this.recordPlayer.sendErrorMessage(108,i))}t[0]&&"fulfilled"===t[0].status&&(i=t[0].value.records||t[0].value.data&&t[0].value.data.records||t[0].value.data&&t[0].value.data.data&&t[0].value.data.data.records||[]),t[1]&&"fulfilled"===t[1].status&&(a=t[1].value.records||t[1].value.data&&t[1].value.data.records||t[1].value.data&&t[1].value.data.data&&t[1].value.data.data.records||[]);let l=([...i,...a]||[]).sort((e,t)=>e.startTime-t.startTime);if(!l.length)return this.recordPlayer.setLoading(r,!1,"closed"),this.recordPlayer.showMsgInWindow(r,D.$t("wsPlayer.error.201"),s),void this.recordPlayer.sendErrorMessage(201,{channelList:[s]});this.getRecordRtsp({...e,channel:s},l.map(e=>(e.isImportant=["2","4","5"].includes(e.recordType),e)),!e.isUpdateRecords,r)})})}getRecordRtsp(e,t,s=!0,i){let r=null,a=t[0].recordSource||e.recordSource,l=e.ssId,n=[],o="byTime",c=t[0].poolType;if(["3","5"].includes(c)||e.playRecordByFile){if(o="byFile",!w.validFunction(this.getRecordRtspByFile))return void this.recordPlayer.sendErrorMessage(608,{insert:[this.i18n.$t("wsPlayer.request.recording.interface"),"getRecordRtspByFile"]});let e=t[0];rt.data={...rt.data,ssId:e.ssId,startTime:e.startTime,endTime:e.endTime,fileName:e.fileName,diskId:e.diskId,recordSource:e.recordSource||"3",channelId:e.channelId,streamId:e.streamId},this.wssRedirectParam(rt),r=this.getRecordRtspByFile(JSON.parse(JSON.stringify(rt)))}else it.data={...it.data,streamType:t[0].streamType||e.streamType||"0",recordType:"1",recordSource:a,startTime:e.startTime,endTime:e.endTime,channelId:e.channel.id,streamId:t[0].streamId||""},l=l||t[0].ssId,n=Array.from(new Set(t.map(e=>e.ssId))),it.data.ssId=l,this.wssRedirectParam(it),r=this.getRecordRtspByTime(JSON.parse(JSON.stringify(it)));r&&r.then(r=>{let c=this.processResponse(r,e.channel);return c?(c.channelId=e.channel.id,c.rtspURL=this.getCurrentRtsp(c.url,c.token),c.wsList=this.getWSUrl(c.url),c.rtspURL?(c.channelData=e.channel,c.startTime=e.startTime,c.endTime=e.endTime,c.recordSource=a,void this.recordPlay(c,i,l,n,e.isSeekRecord,o,t,e.closeReason).then(()=>{let r=this.recordList[i];if(s)this.recordList[i]={...e,recordList:t,recordIndex:0,isPlaying:!0};else{let e=t[0].recordName;r.recordIndex=r.recordList.findIndex(t=>t.recordName===e),r.isPlaying=!0}this.playIndex===i&&(s||(t=r.recordList,r.isPlaying=!0),this.setTimeLine(t,e.isSeekRecord?e.seekRecordTime:t[0].startTime))})):(this.recordPlayer.setLoading(i,!1,"closed"),void this.recordPlayer.sendErrorMessage(203,{channelList:[e.channel]}))):(this.recordPlayer.setLoading(i,!1,"closed"),this.realPlayer.sendErrorMessage(203,{channelList:[e.channel]}))},t=>{this.recordPlayer.setLoading(i,!1,"closed");let s={channelList:[e.channel],channelData:{...e.channel},selectIndex:i,apiErrorInfo:t};t?1103===Number(t.code)?(this.recordPlayer.showMsgInWindow(i,D.$t("wsPlayer.play.error.402"),e.channel),this.recordPlayer.sendErrorMessage(402,s)):this.recordPlayer.sendErrorMessage(203,s):this.recordPlayer.sendErrorMessage(108,s)})}recordPlay(e,t,s,i,r,a,l,n){return new Promise(o=>{ue.call(this.recordPlayer,{...e,streamServerIp:e.innerIp,selectIndex:t,ssId:s,ssIdList:i,isSeekRecord:r,playRecordByFile:"byFile"===a,playRecordByTime:"byTime"===a||this.recordPlayer.config.playCenterRecordByTime&&!!s,recordList:l,closeReason:n}).then(()=>o())})}setTimeLine(e,t){this.recordPlayer.setTimeLine(e,t)}clickRecordTimeLine(e,t){let s=this.recordList[this.playIndex];if(this.recordPlayer.playerList[this.playIndex],s.isGetRtspByFile)return;s.isGetRtspByFile=!0,s.recordIndex=s.recordList.findIndex(t=>t.startTime<=e&&t.endTime>=e),-1===s.recordIndex&&(s.recordIndex=s.recordList.findIndex(t=>t.startTime>=e||t.endTime>=e)),s.isPlaying=!0;let i=s.recordList[s.recordIndex];this.getSeekRecordRtsp({...i,startTime:e,diskId:`${e}-${i.endTime}`},s,e)}playNextRecordByFile(e,t){if(!w.validFunction(this.getRecordRtspByFile))return void this.recordPlayer.sendErrorMessage(608,{insert:[this.i18n.$t("wsPlayer.request.recording.interface"),"getRecordRtspByFile"]});let s=this.recordList[e];if(s.isGetRtspByFile)return;s.isGetRtspByFile=!0,s.recordIndex++,s.isPlaying=!0;let i=s.recordList[s.recordIndex];this.getSeekRecordRtsp(i,s,i.startTime,t)}getSeekRecordRtsp(e,t,s,i){e?(rt.data={...rt.data,ssId:e.ssId,startTime:s,endTime:e.endTime,fileName:e.fileName,diskId:e.diskId,recordSource:e.recordSource||"3",channelId:e.channelId,streamId:e.streamId},this.wssRedirectParam(rt),this.getRecordRtspByFile(JSON.parse(JSON.stringify(rt))).then(s=>{if(s.rtspURL=this.getCurrentRtsp(s.url,s.token),s.wsList=this.getWSUrl(s.url),!s.rtspURL)return t.isGetRtspByFile=!1,void this.recordPlayer.sendErrorMessage(203,{channelList:[t.channel]});s.channelData=t.channel,s.startTime=t.startTime,s.endTime=t.endTime,s.recordSource=e.recordSource,this.recordPlay({...t.channel,...s},this.playIndex,"",[],!0).then(()=>{t.isGetRtspByFile=!1})},e=>{t.isGetRtspByFile=!1,this.recordPlayer.sendErrorMessage(203,{channelList:[t.channel],apiErrorInfo:e})})):(t.isGetRtspByFile=!1,i&&i())}playNextRecord(e,t){if(t){if(!w.validFunction(this.getRecordRtspByTime))return void this.recordPlayer.sendErrorMessage(608,{insert:[this.i18n.$t("wsPlayer.request.recording.interface"),"getRecordRtspByTime"]});let s=this.recordList[e],i=s.recordList.find(e=>e.ssId===t);it.data={...it.data,streamType:i.streamType||"0",recordType:"1",recordSource:i.recordSource,startTime:new Date(1e3*i.startTime).setHours(0,0,0)/1e3,endTime:new Date(1e3*i.endTime).setHours(23,59,59)/1e3,channelId:i.channelId,ssId:t,streamId:i.streamId||""},this.wssRedirectParam(it);let r=Array.from(new Set(s.recordList.map(e=>e.ssId)));return void this.getRecordRtspByTime(JSON.parse(JSON.stringify(it))).then(a=>{let l=this.processResponse(a,opt.channel);if(!l)return this.realPlayer.sendErrorMessage(203,{channelList:[opt.channel]});l.channelId=i.channelId,l.rtspURL=this.getCurrentRtsp(l.url,l.token),l.wsList=this.getWSUrl(l.url),l.startTime=it.data.startTime,l.endTime=it.data.endTime,this.recordPlay(l,e,t,r,!0).then(()=>{this.setTimeLine(s.recordList)})})}}changeTimeLine(e){let t=this.recordList[e];t&&t.isPlaying&&this.setTimeLine(t.recordList)}videoClosed(e,t,s){this.recordList[e]&&(this.recordList[e].isPlaying=!1)}setPlayIndex(e){this.playIndex=e}}class nt{constructor(e={},t){this.i18n=e.locale,this.el=e.el,this.$el=WSPlayerJQ.$("#"+this.el),this.$el.empty(),this.wsPlayer=t,this.prefixUrl=e.prefixUrl||"./static",this.$el&&this.__createPanTilt(),this.channel=null,this.channelCodeForPositionList=[],this.setPtzDirection=e.setPtzDirection,this.setPtzCamera=e.setPtzCamera,this.controlSitPosition=e.controlSitPosition,this.mousedownCanvasEvent=this.__mousedownCanvasEvent.bind(this),this.mousemoveCanvasEvent=this.__mousemoveCanvasEvent.bind(this),this.mouseupCanvasEvent=this.__mouseupCanvasEvent.bind(this),this.clickDirectFlag=!1,this.setPtzDirectionPromiseList=[],this.setPtzDirectionRun=!1,this.setPtzCameraPromiseList=[],this.setPtzCameraRun=!1}setChannel(e){this.channel=e&&{...e}||{};let t=this.wsPlayer.selectIndex,s=this.channelCodeForPositionList[t];if(!e)return WSPlayerJQ.$(".ws-pan-tilt-mask",this.$el).css({display:"block"}),WSPlayerJQ.$(".ws-pan-tilt-mask-position",this.$el).css({display:"none"}),void this.__removeCanvasEvent();s?s!==e.id?(this.channelCodeForPositionList[t]=null,this.__removeCanvasEvent()):this.__openSitPosition(!0):this.openSitPositionFlag&&this.__removeCanvasEvent();let i=e.capability;switch(e.cameraType+""){case"1":parseInt(i,2)&parseInt("100",2)||parseInt(i,2)&parseInt("10000000000000000",2)?WSPlayerJQ.$(".ws-pan-tilt-mask-zoom",this.$el).css({display:"none"}):WSPlayerJQ.$(".ws-pan-tilt-mask-zoom",this.$el).css({display:"block"}),parseInt(i,2)&parseInt("10000000000000000",2)?(WSPlayerJQ.$(".ws-pan-tilt-mask-direction",this.$el).css({display:"none"}),WSPlayerJQ.$(".ws-pan-tilt-mask-position",this.$el).css({display:"block"}),this.__removeCanvasEvent()):(WSPlayerJQ.$(".ws-pan-tilt-mask-direction",this.$el).css({display:"block"}),WSPlayerJQ.$(".ws-pan-tilt-mask-position",this.$el).css({display:"none"})),WSPlayerJQ.$(".ws-pan-tilt-mask-aperture",this.$el).css({display:"block"});break;case"2":WSPlayerJQ.$(".ws-pan-tilt-mask",this.$el).css({display:"none"}),WSPlayerJQ.$(".ws-pan-tilt-mask-position",this.$el).css({display:"none"});break;default:WSPlayerJQ.$(".ws-pan-tilt-mask",this.$el).css({display:"block"}),WSPlayerJQ.$(".ws-pan-tilt-mask-position",this.$el).css({display:"none"}),this.__removeCanvasEvent()}}__createPanTilt(){this.$el.append(`\n <div class="ws-pan-tilt-control">\n <div class="ws-pan-tilt-circle-wrapper">\n \x3c!--云台方向控制--\x3e\n <div class="ws-pan-tilt-circle-rotate">\n <div class="ws-pan-tilt-circle">\n <div class="ws-pan-tilt-direction-item"><img src="${this.prefixUrl}/WSPlayer/icon/arrow-t.svg" title="${this.i18n.$t("video.player.ptz.up")}" direct="1"/></div>\n <div class="ws-pan-tilt-direction-item"><img src="${this.prefixUrl}/WSPlayer/icon/arrow-rt.svg" title="${this.i18n.$t("video.player.ptz.upper.right")}" direct="7"/></div>\n <div class="ws-pan-tilt-direction-item"><img src="${this.prefixUrl}/WSPlayer/icon/arrow-r.svg" title="${this.i18n.$t("video.player.ptz.right")}" direct="4"/></div>\n <div class="ws-pan-tilt-direction-item"><img src="${this.prefixUrl}/WSPlayer/icon/arrow-rb.svg" title="${this.i18n.$t("video.player.ptz.lower.right")}" direct="8"/></div>\n <div class="ws-pan-tilt-direction-item"><img src="${this.prefixUrl}/WSPlayer/icon/arrow-b.svg" title="${this.i18n.$t("video.player.ptz.down")}" direct="2"/></div>\n <div class="ws-pan-tilt-direction-item"><img src="${this.prefixUrl}/WSPlayer/icon/arrow-lb.svg" title="${this.i18n.$t("video.player.ptz.lower.left")}" direct="6"/></div>\n <div class="ws-pan-tilt-direction-item"><img src="${this.prefixUrl}/WSPlayer/icon/arrow-l.svg" title="${this.i18n.$t("video.player.ptz.left")}" direct="3"/></div>\n <div class="ws-pan-tilt-direction-item"><img src="${this.prefixUrl}/WSPlayer/icon/arrow-lt.svg" title="${this.i18n.$t("video.player.ptz.upper.left")}" direct="5"/></div>\n <div class="ws-pan-tilt-inner-circle">\n <img\n class="ws-pan-tilt-pzt-select"\n src="${this.prefixUrl}/WSPlayer/icon/ptz-select.svg"\n title="${this.i18n.$t("inspec.ptz.position1")}"\n />\n </div>\n </div>\n </div>\n </div>\n \n \x3c!--云台变倍、聚焦、光圈控制--\x3e\n <div class="ws-cloud-control-wrapper">\n <div class="ws-pan-tilt-control-item"><img src="${this.prefixUrl}/WSPlayer/icon/ptz-icon1.svg" title="${this.i18n.$t("video.player.ptz.zoom")}-" operateType="1" direct="2"/></div>\n <div class="ws-pan-tilt-control-item"><img src="${this.prefixUrl}/WSPlayer/icon/ptz-icon2.svg" title="${this.i18n.$t("video.player.ptz.zoom")}+" operateType="1" direct="1"/></div>\n <div class="cloud-control-separate"></div>\n <div class="ws-pan-tilt-control-item"><img src="${this.prefixUrl}/WSPlayer/icon/ptz-icon3.svg" title="${this.i18n.$t("video.player.ptz.focus")}-" operateType="2" direct="2"/></div>\n <div class="ws-pan-tilt-control-item"><img src="${this.prefixUrl}/WSPlayer/icon/ptz-icon4.svg" title="${this.i18n.$t("video.player.ptz.focus")}+" operateType="2" direct="1"/></div>\n <div class="cloud-control-separate"></div>\n <div class="ws-pan-tilt-control-item"><img src="${this.prefixUrl}/WSPlayer/icon/ptz-icon5.svg" title="${this.i18n.$t("video.player.ptz.halo")}-" operateType="3" direct="2"/></div>\n <div class="ws-pan-tilt-control-item"><img src="${this.prefixUrl}/WSPlayer/icon/ptz-icon6.svg" title="${this.i18n.$t("video.player.ptz.halo")}+" operateType="3" direct="1"/></div>\n </div>\n \n \x3c!--遮罩,当通道没有云台功能时,使用遮罩遮住云台按钮--\x3e\n \x3c!--方向按钮遮罩--\x3e\n <div class="ws-pan-tilt-mask ws-pan-tilt-mask-direction"></div>\n \x3c!--三维定位遮罩--\x3e\n <div class="ws-pan-tilt-mask ws-pan-tilt-mask-position"></div>\n \x3c!--变倍、聚焦遮罩--\x3e\n <div class="ws-pan-tilt-mask ws-pan-tilt-mask-zoom"></div>\n \x3c!--光圈遮罩--\x3e\n <div class="ws-pan-tilt-mask ws-pan-tilt-mask-aperture"></div>\n </div>\n `),WSPlayerJQ.$(".ws-pan-tilt-circle",this.$el).mouseup(e=>{if(this.clickDirectFlag){this.clickDirectFlag=!1;let t=this.__getDirect(e.target);t&&this.__setPtzDirection(t,"0")}}),WSPlayerJQ.$(".ws-pan-tilt-circle",this.$el).mouseout(this._throttle(e=>{if(this.clickDirectFlag){this.clickDirectFlag=!1;let t=this.__getDirect(e.target);t&&this.__setPtzDirection(t,"0")}})),WSPlayerJQ.$(".ws-pan-tilt-circle",this.$el).mousedown(this._throttle(e=>{if(!this.clickDirectFlag){let t=this.__getDirect(e.target);t&&(this.clickDirectFlag=!0,t&&this.__setPtzDirection(t,"1"))}},1e3)),WSPlayerJQ.$(".ws-pan-tilt-control-item img",this.$el).mouseup(e=>{this.operateFlag&&(this.operateFlag=!1,this.__setPtzCamera(e.target.getAttribute("operateType"),e.target.getAttribute("direct"),"0"))}),WSPlayerJQ.$(".ws-pan-tilt-control-item img",this.$el).mouseout(this._throttle(e=>{this.operateFlag&&(this.operateFlag=!1,this.__setPtzCamera(e.target.getAttribute("operateType"),e.target.getAttribute("direct"),"0"))})),WSPlayerJQ.$(".ws-pan-tilt-control-item img",this.$el).mousedown(this._throttle(e=>{this.operateFlag=!0,this.__setPtzCamera(e.target.getAttribute("operateType"),e.target.getAttribute("direct"),"1")},1e3)),WSPlayerJQ.$(".ws-pan-tilt-pzt-select",this.$el).click(e=>{this.__openSitPosition(!this.openSitPositionFlag)})}__getDirect(e){let t=e.getAttribute("direct");if(!t){let s=e.childNodes[0];s&&s.getAttribute&&(t=s.getAttribute("direct"))}return t}__setPtzDirection(e,t){const s={project:"PSDK",method:"DMS.Ptz.OperateDirect",data:{direct:e,command:t,stepX:"4",stepY:"4",channelId:this.channel.id}};if(this.setPtzDirectionPromiseList.push(()=>new Promise((e,i)=>{this.setPtzDirection&&this.setPtzDirection(s).then(s=>{let i=s.data||s;"1"===t&&i.result&&"0"===i.result&&this.wsPlayer.sendErrorMessage(701,{insert:[s.data.lockUser.userName],apiErrorInfo:s}),e()}).catch(e=>{let s=[""];1103===(e.data||e).code&&(s=[`${this.i18n.$t("error2084")}`]),"1"===t&&this.wsPlayer.sendErrorMessage(704,{apiErrorInfo:e,insert:s}),i()})})),!this.setPtzDirectionRun){let e=()=>{this.setPtzDirectionRun=!0,this.setPtzDirectionPromiseList[0]().then(()=>{}).catch(()=>{}).finally(()=>{this.setPtzDirectionPromiseList.shift(),this.setPtzDirectionPromiseList.length?e():this.setPtzDirectionRun=!1})};e()}}__setPtzCamera(e,t,s){const i={project:"PSDK",method:"DMS.Ptz.OperateCamera",data:{operateType:e,direct:t,command:s,step:"4",channelId:this.channel.id}};if(this.setPtzCameraPromiseList.push(()=>new Promise((e,t)=>{this.setPtzCamera&&this.setPtzCamera(i).then(t=>{let i=t.data||t;"1"===s&&i.result&&"0"===i.result&&this.wsPlayer.sendErrorMessage(701,{insert:[t.data.lockUser.userName],apiErrorInfo:t}),e()}).catch(e=>{let r=["",this.i18n.$t("video.player.ptz.zoom"),this.i18n.$t("video.player.ptz.focus"),this.i18n.$t("video.player.ptz.halo")],a=["","+","-"],l=["","",""];1103===(e.data||e).code&&(l=[r[i.data.operateType],a[i.data.direct],`${this.i18n.$t("error2084")}`]),"1"===s&&this.wsPlayer.sendErrorMessage(703,{apiErrorInfo:e,insert:l}),t()})})),!this.setPtzCameraRun){let e=()=>{this.setPtzCameraRun=!0,this.setPtzCameraPromiseList[0]().then(()=>{}).catch(()=>{}).finally(()=>{this.setPtzCameraPromiseList.shift(),this.setPtzCameraPromiseList.length?e():this.setPtzCameraRun=!1})};e()}}__openSitPosition(e){this.openSitPositionFlag=e;let t=this.wsPlayer.playerList,s=this.wsPlayer.selectIndex;this.canvasElem=t[s].pztCanvasElem,this.canvasElem.addEventListener("mousedown",this.mousedownCanvasEvent),this.canvasElem.addEventListener("mousemove",this.mousemoveCanvasEvent),this.canvasElem.addEventListener("mouseup",this.mouseupCanvasEvent),this.canvasContext=this.canvasElem.getContext("2d"),this.canvasContext.lineWidth=2,this.canvasContext.strokeStyle="#009cff",this.openSitPositionFlag?(this.channelCodeForPositionList[s]=this.channel.id,WSPlayerJQ.$(this.canvasElem).css({display:"block"}),WSPlayerJQ.$(".ws-pan-tilt-pzt-select",this.$el)[0].src=`${this.prefixUrl}/WSPlayer/icon/ptz-select-hover.svg`):(this.channelCodeForPositionList[s]=null,WSPlayerJQ.$(this.canvasElem).css({display:"none"}),WSPlayerJQ.$(".ws-pan-tilt-pzt-select",this.$el)[0].src=`${this.prefixUrl}/WSPlayer/icon/ptz-select.svg`)}__mousedownCanvasEvent(e){e.target===this.canvasElem&&(e.offsetX||e.layerX)&&(this.pointX=e.offsetX||e.layerX,this.pointY=e.offsetY||e.layerY,this.startDraw=!0)}__mousemoveCanvasEvent(e){if(e.target===this.canvasElem&&this.startDraw&&(e.offsetX||e.layerX)){const t=e.offsetX||e.layerX,s=e.offsetY||e.layerY,i=t-this.pointX,r=s-this.pointY;this.canvasContext.clearRect(0,0,this.canvasElem.width,this.canvasElem.height),this.canvasContext.beginPath(),this.canvasContext.strokeRect(this.pointX,this.pointY,i,r)}}__mouseupCanvasEvent(e){if(e.target===this.canvasElem&&(e.offsetX||e.layerX)){this.startDraw=!1;const t=e.offsetX||e.layerX,s=e.offsetY||e.layerY;let i="",r="",a="";const l=(t+this.pointX)/2,n=(s+this.pointY)/2,o=this.canvasElem.width/2,c=this.canvasElem.height/2,d=Math.abs(t-this.pointX),h=Math.abs(s-this.pointY),p=t<this.pointX;i=8192*(l-o)*2/this.canvasElem.width,r=8192*(n-c)*2/this.canvasElem.height,t===this.pointX||s===this.pointY?a=0:(a=this.canvasElem.width*this.canvasElem.height/(d*h),p&&(a=-a)),this.canvasContext.clearRect(0,0,this.canvasElem.width,this.canvasElem.height),this.__controlSitPosition(i,r,a)}}__removeCanvasEvent(){this.canvasElem&&(this.canvasElem.removeEventListener("mousedown",this.mousedownCanvasEvent),this.canvasElem.removeEventListener("mousemove",this.mousemoveCanvasEvent),this.canvasElem.removeEventListener("mouseup",this.mouseupCanvasEvent),WSPlayerJQ.$(this.canvasElem).css({display:"none"}),this.canvasElem=null,this.canvasContext=null,this.openSitPositionFlag=!1,WSPlayerJQ.$(".ws-pan-tilt-pzt-select",this.$el)[0].src=`${this.prefixUrl}/WSPlayer/icon/ptz-select.svg`)}__controlSitPosition(e,t,s){const i={project:"PSDK",method:"DMS.Ptz.SitPosition",data:{magicId:localStorage.getItem("magicId")||"",pointX:String(Math.round(e)),pointY:String(Math.round(t)),pointZ:String(Math.round(s)),extend:"1",channelId:this.channel.id}};this.controlSitPosition&&this.controlSitPosition(i).then(e=>{let t=e.data||e;t.result&&"0"===t.result&&this.wsPlayer.sendErrorMessage(701,{insert:[e.data.lockUser.userName],apiErrorInfo:e})}).catch(e=>{let t=[""];1103===(e.data||e).code&&(t[0]=`${this.i18n.$t("error2084")}`),this.wsPlayer.sendErrorMessage(702,{apiErrorInfo:e,insert:t})})}_throttle(e,t=300){let s=0;return function(...i){const r=(new Date).getTime();if(!(r-s<t))return s=r,e.apply(this,i)}}}const ot={num:1,maxNum:25,showControl:!0,showTopOperate:!0,draggable:!1,showRecordProgressBar:!0,isDynamicLoadLib:!0,onlyLoadSingleLib:!1,useNginxProxy:!1,openIvs:!0,ivsTypeArr:[1,2],useH264MSE:!0,useH265MSE:!0,showIcons:{streamChangeSelect:!0,ivsIcon:!0,talkIcon:!0,localRecordIcon:!0,audioIcon:!0,snapshotIcon:!0,closeIcon:!0},downloadMp4Record:!0,localRecordSize:100,playCenterRecordByTime:!1,localeLang:"zhCN",cacheMode:1,nMSEFrameCount:1,isWebView:!1,picCapCb:!1,dblclickDisabled:!1},ct=function(e,t){let s=document.createElement("script");s.src=e,document.head.appendChild(s);var i=!1;"function"==typeof t&&(s.onload=s.onreadystatechange=function(){i||s.readyState&&!/loaded|complete/.test(s.readyState)||(s.onload=s.onreadystatechange=null,i=!0,t())},s.onerror=function(t){console.error(`\n配置的文件路径加载失败: ${window.location.origin}${e},\nprefixUrl参数配置有误, 请按照标准的配置方式prefixUrl的参数保证能够访问到路径\n绝对路径配置方式:'/path',\n相对路径配置方式:'path', './path'\n `)})},dt=function(e){let t=`${e}/WSPlayer/PlaySDKInterface.js`;var s,i;s=`${e}/WSPlayer/player.css`,(i=document.createElement("link")).href=s,i.rel="stylesheet",i.type="text/css",document.head?document.head.appendChild(i):document.getElementsByTagName("head")[0].appendChild(i),ct(t,null)},ht=function(e){let t=this;ct(`${e}/WSPlayer/singleThread/libStreamClient.js`,function(){Single_Client_Module().then(e=>{window.SCModule=e,window.SCModule._GLOBAL_Init(2),window.m_bClientInitialized=!0,window.m_nModuleInitialized=!0,console.log(`%cwsplayer播放器 版本号V${$t.version} 单线程`,"background: rgb(115, 189, 224); color: #fff; font-size: 20px"),t.sendMessage("initializationCompleted")})})},pt=function(e){ct(`${e}/WSPlayer/commonThread/libRenderEngine.js`,function(){RenderEngine_Module().then(e=>{window.REModule=e})})},yt=function(e){let t=`${e}/WSPlayer/commonThread/libmavasp_litepacket.data`;ct(`${e}/WSPlayer/commonThread/libmavasp_litepacket.js`,function(){ASPLite_Module.locateFile=function(e,s){return e.endsWith(".data")?t:s+e},ASPLite_Module(ASPLite_Module).then(e=>{window.ASPLiteModule=e})})},ut=function(e){ct(`${e}/WSPlayer/commonThread/libIVSDrawer.js`,function(){IVSDrawer_Module().then(e=>{window.IVSModule=e})})},mt=function(e){let t=this,s=this.prefixUrl;if(window.loadLibPlayerFlag){this.config.onlyLoadSingleLib=window.onlyLoadSingleLib;let e=setTimeout(()=>{t.sendMessage("initializationCompleted"),clearTimeout(e)},300);return}if(this.importLoad&&dt(s),window.loadLibPlayerFlag=!0,window.m_bClientInitialized=!1,window.Module||(window.Module={}),Module.onRuntimeInitialized=function(){let e=setTimeout(()=>{window.m_nModuleInitialized=!0,t.sendMessage("initializationCompleted"),clearTimeout(e)},300)},Module.locateFile=function(e,s){return e.endsWith(".data")?`${t.prefixUrl}/WSPlayer/multiThread/libplay.data`:s+e},!this.isHttps||!e||this.config.onlyLoadSingleLib)return pt(s),ut(s),!this.config.isWebView&&yt(s),ht.call(this,s),this.config.onlyLoadSingleLib=!0,void(window.onlyLoadSingleLib=this.config.onlyLoadSingleLib);try{new SharedArrayBuffer(1),function(e){ct(`${e}/WSPlayer/multiThread/libplay.js`,null)}(s),function(e){ct(`${e}/WSPlayer/multiThread/libStreamClient.js`,function(){Multi_Client_Module().then(e=>{window.SCModule=e,window.SCModule._GLOBAL_Init(2),window.m_bClientInitialized=!0})})}(s),console.log(`%cwsplayer播放器 版本号V${$t.version} 多线程`,"background: rgb(91, 66, 181); color: #fff; font-size: 20px"),pt(s)}catch(i){pt(s),ht.call(this,s),this.config.onlyLoadSingleLib=!0,window.onlyLoadSingleLib=this.config.onlyLoadSingleLib}ut(s),!this.config.isWebView&&yt(s)};!function(e){function t(e,s){if(!(this instanceof t))return new t(e,s);if(e instanceof Node||e instanceof t){if(e.length)return e;this.length=1,this[0]=e}else if(e instanceof Array)this.length=e.length,e.forEach((e,t)=>{this[t]=e});else{if("string"!=typeof e)return[];if(e.startsWith("<")||e.startsWith("\n")){const t=(new DOMParser).parseFromString(e,"text/html").body.childNodes;this.length=t.length;for(let e=0;e<this.length;e++)this[e]=t[e]}else{const i=(s=s instanceof t?s[0]:s||document)&&s.querySelectorAll(e)||[];this.length=i.length;for(let e=0;e<this.length;e++)this[e]=i[e]}}}t.prototype.each=function(e){for(var t=0;t<this.length;t++)e.call(this[t],t,this[t]);return this},t.prototype.css=function(e,t){if("object"==typeof e)for(const s in e)e.hasOwnProperty(s)&&this.each(function(){this.style[s]=e[s]});else{if(void 0===t)return getComputedStyle(this[0])[e];this.each(function(){this.style[e]=t})}return this},t.prototype.click=function(e){return this.each(function(){this.addEventListener("click",e)})},t.prototype.src=function(e){return this.each(function(){if("IMG"!==this.tagName&&"AUDIO"!==this.tagName&&"VIDEO"!==this.tagName)throw new Error('The "src" method can only be used on <img>, <audio>, or <video> elements.');if(void 0===e)return this.src;this.src=e})},t.prototype.dblclick=function(e){return this.each(function(){this.addEventListener("dblclick",e)})},t.prototype.parseHTML=function(e){const t=document.createElement("div");return t.innerHTML=e,t.childNodes},t.prototype.html=function(e){return void 0===e?this[0].innerHTML:(this.each(function(){this.innerHTML=e}),this)},t.prototype.empty=function(){return this.each(function(){for(;this.firstChild;)this.removeChild(this.firstChild)})},t.prototype.addClass=function(e){return this.each(function(){e.trim().split(/\s+/).forEach(e=>{e&&!this.classList.contains(e)&&this.classList.add(e)})})},t.prototype.removeClass=function(e){return"string"!=typeof e?this:this.each(function(){const t=e.trim().split(/\s+/);if(this.classList)t.forEach(e=>{e&&this.classList.remove(e)});else{const e=this.className.split(/\s+/).filter(e=>!t.includes(e));this.className=e.join(" ")}})},t.prototype.remove=function(){for(let e=0;e<this.length;e++)this[e].parentNode&&this[e].parentNode.removeChild(this[e])},t.prototype.children=function(e){const s=[];return this.each(function(){const e=this.children;for(let t=0;t<e.length;t++){const i=e[t];i.nodeType===Node.ELEMENT_NODE&&s.push(i)}}),new t(s,this.context)},t.prototype.siblings=function(e){const s=[];return this.each(function(){const i=this.parentNode;if(i){const r=i.children;for(let i=0;i<r.length;i++){const a=r[i];a!==this&&a.nodeType===Node.ELEMENT_NODE&&(e?e instanceof Node||e instanceof t?e===a&&s.push(a):a.matches(e)&&s.push(a):s.push(a))}}}),new t(s,this.context)},t.prototype.show=function(){return this.each(function(){this.style.display=""}),this},t.prototype.hide=function(){return this.each(function(){this.style.display="none"}),this},t.prototype.is=function(e){if(!this.length)return!1;if(e instanceof t){const t=e[0];for(let e=0;e<this.length;e++)if(this[e]===t)return!0;return!1}if(e instanceof Node||e instanceof Element){for(let t=0;t<this.length;t++)if(this[t]===e)return!0;return!1}if("string"==typeof e){for(let t=0;t<this.length;t++){const s=this[t];if(s.matches&&s.matches(e))return!0}return!1}return!1},t.prototype.has=function(e){const s=[];return this.each(function(){let i=!1;if(e instanceof t||e instanceof Node||e instanceof Element){let s=e instanceof t?e[0]:e;for(;s=s&&s.parentNode;)if(s===this){i=!0;break}}else"string"==typeof e&&(i=!!this.querySelector(e));i&&s.push(this)}),new t(s,this.context)},t.prototype.append=function(e){if("string"==typeof e)this.each(function(){this.insertAdjacentHTML("beforeend",e)});else{if(!(e instanceof Node||Array.isArray(e)))throw new TypeError("Invalid content provided to append method.");{const t=Array.isArray(e)?e:[e];this.each(function(){t.forEach(e=>this.appendChild(e))})}}return this},t.prototype.attr=function(e,t){if(void 0!==t)return this.each(function(s,i){i.setAttribute(e,t)});let s;for(let i=0;i<this.length;i++){const t=this[i].getAttribute(e);if(null!==t){s=t;break}}return s},t.prototype.on=function(e,t){return this.each(function(){e.split(/\s+/).forEach(function(e){this.addEventListener(e,t)},this)})},t.prototype.html=function(e){return void 0!==e?this.each(function(){this.innerHTML=e}):this[0].innerHTML},t.prototype.text=function(e){return void 0!==e?this.each(function(){this.textContent=e}):this[0].textContent},t.prototype.width=function(e){return void 0!==e?this.each(function(){this.style.width=e}):this[0]&&this[0].clientWidth||null},t.prototype.height=function(e){return void 0!==e?this.each(function(){this.style.height=e}):this[0]&&this[0].clientHeight||null},t.prototype.mouseup=function(e){return this.each(function(){this.addEventListener("mouseup",e)})},t.prototype.mouseout=function(e){return this.each(function(){this.addEventListener("mouseout",e)})},t.prototype.mousedown=function(e){return this.each(function(){this.addEventListener("mousedown",e)})},t.prototype.prop=function(e,t){if("string"==typeof e&&void 0===t){const t=this[0];if(!(t&&t instanceof Element))return;return"boolean"==typeof t[e]?!!t[e]:t[e]}return"string"==typeof e&&void 0!==t?this.each(function(){this instanceof Element&&(this[e]=t)}):"object"==typeof e&&null!==e?this.each(function(){if(this instanceof Element)for(const t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}):this},t.prototype.off=function(e,t){if(!e&&!t)return this.each(function(){if(this instanceof Element){const e=this.cloneNode(!0);this.parentNode&&this.parentNode.replaceChild(e,this)}});const s=e.split(/\s+/);return this.each(function(){const e=this;e instanceof Element&&s.forEach(function(s){if(!s)return;const i=e._eventListeners&&e._eventListeners[s]||[];if(!t)return i.forEach(function(t){e.removeEventListener(s,t)}),void(e._eventListeners&&delete e._eventListeners[s]);i.forEach(function(i,r){i===t&&(e.removeEventListener(s,i),e._eventListeners[s].splice(r,1))})})})},e.WSPlayerJQ={$:function(s,i){return e.$&&e.$.fn&&function(e,t){if(!e||!t)return!1;let s=e.split("."),i=t.split(".");for(let r=0;r<i.length;r++){if(s[r]>i[r])return!0;if(s[r]<i[r])return!1}return!0}(e.$.fn.jquery,"3.6.0")?e.$(s,i):new t(s,i)}}}(window);const wt=[["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"]],ft=(()=>{if("undefined"==typeof document)return!1;const e=wt[0],t={};for(const s of wt){if((null==s?void 0:s[1])in document){for(const[i,r]of s.entries())t[e[i]]=r;return t}}return!1})(),Pt={change:ft.fullscreenchange,error:ft.fullscreenerror};let gt={request:(e=document.documentElement,t)=>new Promise((s,i)=>{const r=()=>{gt.off("change",r),s()};gt.on("change",r);const a=e[ft.requestFullscreen](t);a instanceof Promise&&a.then(r).catch(i)}),exit:()=>new Promise((e,t)=>{if(!gt.isFullscreen)return void e();const s=()=>{gt.off("change",s),e()};gt.on("change",s);const i=document[ft.exitFullscreen]();i instanceof Promise&&i.then(s).catch(t)}),toggle:(e,t)=>gt.isFullscreen?gt.exit():gt.request(e,t),onchange(e){gt.on("change",e)},onerror(e){gt.on("error",e)},on(e,t){const s=Pt[e];s&&document.addEventListener(s,t,!1)},off(e,t){const s=Pt[e];s&&document.removeEventListener(s,t,!1)},raw:ft};Object.defineProperties(gt,{isFullscreen:{get:()=>Boolean(document[ft.fullscreenElement])},element:{enumerable:!0,get:()=>document[ft.fullscreenElement]??void 0},isEnabled:{enumerable:!0,get:()=>Boolean(document[ft.fullscreenEnabled])}}),ft||(gt={isEnabled:!1});const St=gt;class vt{constructor(e,t){this.el=e.el,this.wsplayer=t,this.$el=document.getElementById(this.el),this.$el.innerHTML=`<div id="${e.el}-stick" class="mobile-panTilt-stick"></div>`,this.$stick=document.getElementById(`${e.el}-stick`),this.touchStartX=0,this.touchStartY=0,this.setPtzDirection=e.setPtzDirection,this.setPtzCamera=e.setPtzCamera,this.channel=null,this.initPantiltEvent(),this.direct="",this.directionMap={left:3,"left-up":5,up:1,"right-up":7,right:4,"right-down":8,down:2,"left-down":6},this.pantiltStyle=["l","lt","t","rt","r","rb","b","lb"],this.setPtzDirectionPromiseList=[],this.setPtzDirectionRun=!1,this.setPtzCameraPromiseList=[],this.setPtzCameraRun=!1,this.lastCall=0,this.currentPanTiltDirect=e.currentPanTiltDirect}setChannel(e){this.channel={...e};let t=!1;if(!e)return void this.removePantiltEvent();let s=e.capability;switch(e.cameraType+""){case"1":t=!(parseInt(s,2)&parseInt("10000000000000000",2));break;case"2":t=!0;break;default:t=!1}return t}removePantiltEvent(){this.$stick.removeEventListener("touchstart",this.onTouchStart.bind(this)),this.$stick.removeEventListener("touchmove",this.onTouchMove.bind(this)),this.$stick.removeEventListener("touchend",this.onTouchEnd.bind(this))}initPantiltEvent(){this.$stick.addEventListener("touchstart",this.onTouchStart.bind(this)),this.$stick.addEventListener("touchmove",this.onTouchMove.bind(this)),this.$stick.addEventListener("touchend",this.onTouchEnd.bind(this))}onTouchStart(e){e.preventDefault(),e.stopPropagation();const t=e.touches[0];this.touchStartX=t.clientX,this.touchStartY=t.clientY}onTouchMove(e){e.preventDefault(),e.stopPropagation();const t=e.touches[0],s=t.clientX-this.touchStartX,i=t.clientY-this.touchStartY,r=Math.atan2(i,s),a=this.getDirection(r);this.moveStick(s,i);this._throttle(this.controlGimbal.bind(this))(a)}onTouchEnd(e){e.preventDefault(),e.stopPropagation(),this.$stick.style.transform="translate(0, 0)",this.pantiltStyle.forEach(e=>WSPlayerJQ.$(`#${this.el}`).removeClass(`${e}-bg`)),WSPlayerJQ.$(`#${this.el}`).addClass("default-bg"),this.direct&&(this.setPtzDirection&&this.__setPtzDirection(this.direct,"0")||this.currentPanTiltDirect({...this.channel,direct:this.direct,command:"0"})),this.direct=""}getDirection(e){const t=Math.round((e+Math.PI)/(Math.PI/4))%8;return WSPlayerJQ.$(`#${this.el}`).addClass(this.pantiltStyle[t]+"-bg").removeClass("default-bg"),this.pantiltStyle.forEach((e,s)=>t!==s&&WSPlayerJQ.$(`#${this.el}`).removeClass(`${e}-bg`)),["left","left-up","up","right-up","right","right-down","down","left-down"][t]}moveStick(e,t){const s=Math.min(Math.sqrt(e*e+t*t),45),i=Math.atan2(t,e);this.$stick.style.transform=`translate(${Math.cos(i)*s}px, ${Math.sin(i)*s}px)`}controlGimbal(e){this.channel&&this.channel.id&&this.direct!==this.directionMap[e]&&(this.direct&&this.__setPtzDirection(this.direct,"0"),this.direct=this.directionMap[e],this.setPtzDirection?this.__setPtzDirection(this.directionMap[e],"1"):this.currentPanTiltDirect({...this.channel,direct:this.direct,command:"1"}))}__setPtzDirection(e,t){const s={project:"PSDK",method:"DMS.Ptz.OperateDirect",data:{direct:e,command:t,stepX:"4",stepY:"4",channelId:this.channel.id}};if(this.setPtzDirectionPromiseList.push(()=>new Promise((e,t)=>{this.setPtzDirection&&this.setPtzDirection(s).then(()=>{e()}).catch(e=>{t(e)})})),!this.setPtzDirectionRun){let e=()=>{this.setPtzDirectionRun=!0,this.setPtzDirectionPromiseList[0]().then(()=>{}).catch(e=>{console.error("云台方向控制err:",e)}).finally(()=>{this.setPtzDirectionPromiseList.shift(),this.setPtzDirectionPromiseList.length?e():this.setPtzDirectionRun=!1})};e()}}__setPtzCamera(e,t,s){const i={project:"PSDK",method:"DMS.Ptz.OperateCamera",data:{operateType:e,direct:t,command:s,step:"4",channelId:this.channel.id}};if(this.setPtzCameraPromiseList.push(()=>new Promise((e,t)=>{this.setPtzCamera&&this.setPtzCamera(i).then(()=>{e()}).catch(e=>{t(e)})})),!this.setPtzCameraRun){let e=()=>{this.setPtzCameraRun=!0,this.setPtzCameraPromiseList[0]().then(()=>{}).catch(e=>{console.error("云台方向控制err:",e)}).finally(()=>{this.setPtzCameraPromiseList.shift(),this.setPtzCameraPromiseList.length?e():this.setPtzCameraRun=!1})};e()}}_throttle(e,t=500){return(...s)=>{const i=(new Date).getTime();if(!(i-this.lastCall<t))return this.lastCall=i,e.apply(this,s)}}}class $t{constructor(e){if(!e.type)return console.error("type 为必传参数,请校验入参"),!1;if(this.options=e,this.type=e.type,this.importLoad=e.importLoad,this.config=w.mergeObject(ot,e.config),this.config.localeI18n&&D.setI18n(this.config.localeI18n),D.setLocal(this.config.localeLang),this.wsAdaption={selfAdaption:D.$t("wsPlayer.screen.selfAdaption"),stretching:D.$t("wsPlayer.screen.stretching")},i.updateLocale(D),this.setWSUrl=e.setWSUrl,this.WS_TIMEOUT=e.WS_TIMEOUT||1,this.wsProtocol=e.protocol,this.isIntranet=e.isIntranet,this.ENV=localStorage.ENV||e.ENV,this.intranetMap=e.intranetMap,this.proxyServerIp=e.proxyServerIp||e.serverIp,this.streamServerIp=e.streamServerIp||e.serverIp,this.prefixUrl=this.processPrefixUrl(e.prefixUrl),this.rtspResponseTimeout=e.rtspResponseTimeout-0,this.procedure=new lt({i18n:D,type:this.type,player:this,playCenterRecordByTime:this.config.playCenterRecordByTime,getRealRtsp:e.getRealRtsp,getRecords:e.getRecords,getRecordRtspByTime:e.getRecordRtspByTime,getRecordRtspByFile:e.getRecordRtspByFile,getTalkRtsp:e.getTalkRtsp,stopTalk:e.stopTalk}),this.sendMessage=e.receiveMessageFromWSPlayer||function(e,t,s){},this.el=e.el,this.fetchChannelAuthority=e.getChannelAuthority,this.$el=WSPlayerJQ.$("#"+this.el),this.$el.empty(),!this.$el.length)return void this.sendErrorMessage(503);this.width=this.$el.attr("width"),this.height=this.$el.attr("height"),this.$el.height(`${this.height}px`),this.$el.width(`${this.width}px`),this.$el.addClass("ws-player"),this.$el.append('<div class="player-wrapper"></div>'),this.$wrapper=WSPlayerJQ.$(".player-wrapper",this.$el),this.playerList=[],this.playerAdapter=e.playerAdapter||"selfAdaption",this.canvas={},this.ctx={},this.showNum=1,this.maxWindow=1,this.recordProgressRuler=null,this.clickRecordsTimer=null,this.$el.attr("inited",!0);let{isVersionCompliance:t}=w.checkBrowser();switch(this.isHttps="https:"===location.protocol,this.config.isDynamicLoadLib&&mt.call(this,t),re.call(this),this.currentDragWindowIndex=-1,this.beforeShowNum=1,this.type){case"real":this.createRealPlayer(e);break;case"record":this.createRecordPlayer(e)}this.setSelectIndex(0,{},null,!1),this.setPlayerNum(this.config.division||this.config.num),this.bindUpdatePlayerWindow=this.__updatePlayerWindow.bind(this),this.resizeObserver=w.watchDomObserver(this.$el,this.bindUpdatePlayerWindow),window.wsPlayerManager||(window.wsPlayerManager=new Ze),window.wsPlayerManager.addWSPlayer(this),this.wsPlayerIndex=window.wsPlayerManager.wsPlayerList.findIndex(e=>e===this),this.__updateTopBarStyle(),this.__showBottomBarMore()}processPrefixUrl(e){return e&&e.startsWith("./")?e:e?`/${e}`:"./static"}createRealPlayer(){this.config.showControl?qe.call(this):this.$wrapper.addClass("nocontrol"),Array(this.maxWindow).fill(1).forEach((e,t)=>{let s=new Ye({locale:D,wrapperDomId:this.el,index:t,wsPlayer:this});this.playerList.push(s)})}createRecordPlayer(){this.config.showRecordProgressBar&&je.call(this),this.config.showControl&&qe.call(this),!this.config.showRecordProgressBar&&!this.config.showControl&&this.$wrapper.addClass("nocontrol"),Array(this.maxWindow).fill(1).forEach((e,t)=>{let s=new Ge({locale:D,wrapperDomId:this.el,index:t,wsPlayer:this});this.playerList.push(s)})}openVolume(e){let t=this.playerList[void 0===e?this.selectIndex:e];!t.isAudioPlay&&t.openVolume()}closeVolume(e){let t=this.playerList[void 0===e?this.selectIndex:e];t.isAudioPlay&&t.closeVolume()}setVolume(e,t){let s=this.playerList[void 0===e?this.selectIndex:e];t>0?(s.playSDK.SetSoundState(!0),s.openVolume(t)):s.closeVolume()}picCap(e,t){this.playerList[void 0===e?this.selectIndex:e].picCap(t)}play(e=this.selectIndex){if("real"===this.type)return void this.sendErrorMessage(611,{method:"play",arguments:{index:e,selectIndex:e}});let t=this.playerList[e];t?"pause"===t.status&&t.play():this.sendErrorMessage(601,{method:"play",arguments:{index:e,selectIndex:e}})}pause(e=this.selectIndex){if("real"===this.type)return void this.sendErrorMessage(612,{method:"pause",arguments:{index:e,selectIndex:e}});let t=this.playerList[e];t?"playing"===t.status&&t.pause():this.sendErrorMessage(601,{method:"pause",arguments:{index:e,selectIndex:e}})}playSpeed(e,t=this.selectIndex){if(![.125,.25,.5,1,1.25,1.5,2,4,8,16].includes(e))return void console.error(D.$t("wsPlayer.error.206"));if("real"===this.type)return void this.sendErrorMessage(607,{method:"playSpeed",arguments:{speed:e,index:t,selectIndex:t}});let s=this.playerList[t];s?s.playSpeed(parseFloat(e)):this.sendErrorMessage(601,{method:"playSpeed",arguments:{speed:e,index:t,selectIndex:t}})}openSomeWindow(e){e>this.showNum&&(e<this.maxWindow?this.playNum=e>16?25:e>9?16:e>4?9:4:this.playNum=this.maxWindow,this.setPlayerNum(this.playNum))}setSelectIndex(e=this.selectIndex,t={},s,i=!0){e=Number(e);let r=this.playerList[e];if(!r)return void this.sendErrorMessage(601,{method:"setSelectIndex",arguments:{index:e,selectIndex:e}});let a=0,l=0;if(s&&r.currentWindowPlaying){let e=r["video"===r.decodeMode?"videoElem":"canvasElem"].getBoundingClientRect();a=8192*s.offsetX/e.width,l=8192*s.offsetY/e.height}if(i&&this.sendMessage("clickWindow",{channelId:(r.options||{}).channelId,channelInfo:r.options,playIndex:e,selectIndex:e,currentWindowPlaying:r.currentWindowPlaying,dPointX:a,dPointY:l}),this.selectIndex!==e&&void 0!==e){if(this.procedure&&this.procedure.setPlayIndex(e),"record"===this.type){let t=r.status;"playing"===t?(WSPlayerJQ.$(".ws-record-play",this.$el).css({display:"none"}),WSPlayerJQ.$(".ws-record-pause",this.$el).css({display:"block"})):"pause"===t&&(WSPlayerJQ.$(".ws-record-pause",this.$el).css({display:"none"}),WSPlayerJQ.$(".ws-record-play",this.$el).css({display:"block"})),["playing","pause"].includes(t)?this.setTimeLine(r.options.recordList||r.options.records,r.currentTime):(this.setTimeLine([]),WSPlayerJQ.$(".ws-record-pause",this.$el).css({display:"none"}),WSPlayerJQ.$(".ws-record-play",this.$el).css({display:"block"})),this.__setPlaySpeed("",e)}this.sendMessage("selectWindowChanged",{channelId:(r.options||{}).channelId||t.id,channelInfo:r.options||t,playIndex:e,selectIndex:e,currentWindowPlaying:r.currentWindowPlaying}),this.selectIndex=e,this.setPtzChannel((r.options||{}).channelData),this.playerList.forEach((t,s)=>{s===e?t.$el.removeClass("unselected").addClass("selected"):t.$el.removeClass("selected").addClass("unselected")})}}createWSPlayerLayer(e,t){let s=`<div id="${this.el}-${e}" style="width: 100%; height: 100%;"></div>`;this.$wrapper.append(s),t&&t(`${this.el}-${e}`)}createCustomDom(e){this.playerList.forEach((t,s)=>{t.customDomId=`${t.domId}-${e}`;let i=`\n <div id="${t.customDomId}" style="display: none;" class="ws-custom-dom-style"></div>\n `;WSPlayerJQ.$(".ws-full-content",t.$el).append(i),t.customDomElem=WSPlayerJQ.$(`#${t.customDomId}`)})}setPlayerNum(e,t){Number(e)>this.config.maxNum&&(console.warn(D.$t("wsPlayer.error.609")),e=this.config.maxNum),this.setSelectIndex(0,{},null,!1),Number(e)>0?oe.call(this,Number(e),t):ce.call(this,e,t)}setPlayerAdapter(e){this.playerAdapter!==e&&(["selfAdaption","stretching"].includes(e)?(this.playerAdapter=e,WSPlayerJQ.$(".ws-select-show-option",this.$el).text(this.wsAdaption[e]),this.__updatePlayerWindow()):this.sendErrorMessage(606,{method:"setPlayerAdapter",arguments:{playerAdapter:e}}))}setTimeLine(e=[],t=w.getToday12Time()){this.timeList=e,this.config.showRecordProgressBar&&this.recordProgressRuler&&this.recordProgressRuler.updateProgress({records:e,currentTime:t})}isIOS(){return/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream}setFullScreen(){try{let e=this.$el[0].children[0];if(this.isIOS()){if(WSPlayerJQ.$(e).addClass("wsplayerfullscreen"),document.documentElement.scrollHeight<=document.documentElement.clientHeight){const e=window.visualViewport||window;bodyTag.style.height=`${e.height}px`}let t=setTimeout(function(){window.scrollTo(0,1),clearTimeout(t)},100)}else St.isEnabled&&St.request(e);this.__updatePlayerWindow(),this.sendMessage("fullScreen",{fullScreen:!0})}catch(e){console.log("全屏失败:",e)}}setExitFullScreen(){try{let e=this.$el[0].children[0];this.isIOS()?WSPlayerJQ.$(e).removeClass("wsplayerfullscreen"):St.exit(),this.__updatePlayerWindow(),this.sendMessage("fullScreen",{fullScreen:!1})}catch(e){console.log("退出全屏失败:",e)}}close(e,t){let s=Number(e);if(isNaN(s))return void(this.playerList&&this.playerList.forEach(e=>{e.isclosing=!0,e.close(!1,!1,"closed",t)}));let i=this.playerList[s];i.isclosing=!0,i&&i.close(!1,!1,"closed",t)}destroy(){this.close(void 0,"destroy"),this.resizeObserver.disconnect()}__setPlaySpeed(e,t,s){let i,r,a=[{value:.125,label:"0.125x"},{value:.25,label:"0.25x"},{value:.5,label:"0.5x"},{value:1,label:"1x"},{value:1.25,label:"1.25x"},{value:1.5,label:"1.5x"},{value:2,label:"2x"},{value:4,label:"4x"},{value:8,label:"8x"}],l=this.playerList[void 0===t?this.selectIndex:t];a.some((n,o)=>{if(n.value===l.speed)return r="PREV"===e?o-1:"NEXT"===e?"mobile"===s?(o+1)%9:o+1:o,i=a[r],!i||(r?r===a.length-1?WSPlayerJQ.$(".ws-record-speed-add",this.$el).css({cursor:"not-allowed"}):(WSPlayerJQ.$(".ws-record-speed-sub",this.$el).css({cursor:"pointer"}),WSPlayerJQ.$(".ws-record-speed-add",this.$el).css({cursor:"pointer"})):WSPlayerJQ.$(".ws-record-speed-sub",this.$el).css({cursor:"not-allowed"}),WSPlayerJQ.$(".ws-record-speed-txt",this.$el).text(i.label),"playing"===l.status&&this.playSpeed(i.value,t),!0)})}__setPlayingTime(e,t){if(this.selectIndex===e){this.playerList[e].currentTime=t,this.clickRecordsTimer||this.recordProgressRuler&&this.recordProgressRuler.updateProgress({currentTime:t})}}showMsgInWindow(e=this.selectIndex,t,s){let i=this.playerList[e];i?(i.options={...i.options,...s,channelId:s.id||s.channelId},i.setStatus("showmsg"),i.showMsgInWindow(t)):this.sendErrorMessage(601,{method:"showMsgInWindow",arguments:{index:e,msg:t,channelData:s,selectIndex:e}})}__updatePlayerWindow(){let e=setTimeout(()=>{this.playerList.forEach(e=>{e.updateAdapter(this.playerAdapter)}),clearTimeout(e)},24);this.__updateTopBarStyle(),this.__renderDefaultStats(),this.__showBottomBarMore()}__renderDefaultStats(){let e=setTimeout(()=>{this.playerList.forEach(t=>{t.renderDefaultStats(),clearTimeout(e)})},24)}__updateTopBarStyle(){let e=setTimeout(()=>{this.playerList.forEach(e=>{e.updateTopBarStyle()}),clearTimeout(e)},24)}__showBottomBarMore(){let e=setTimeout(()=>{this.$el.width()<("real"===this.type?540:700)?WSPlayerJQ.$(".ws-ctrl-ellipsis",this.$el).css({display:"unset"}):WSPlayerJQ.$(".ws-ctrl-ellipsis",this.$el).css({display:"none"}),clearTimeout(e)},24)}__startTalk(e,t){this.talkIndex=t,this.procedure&&this.procedure.startTalk(e)}playTalkAudio(e){let t=this.playerList[e];if(t.currentWindowPlaying)if("http:"!==location.protocol)if(this.isTalking&&!this.isTalking)this.sendErrorMessage("303");else if(t.isTalking)t.stopTalk();else{const{channelData:s}=t.options;if(t.options&&"url"===t.options.playType)return void this.sendMessage("notifyTalk",{selectIndex:e,channelData:{...s},channelInfo:{...t.options}});q(),t.setAuthority({channelCode:t.options.channelData?t.options.channelData.channelCode:t.options.channelId,function:"3"},()=>{this.__startTalk(t.options.channelData,t.index)},t=>{1103===t.code&&this.sendErrorMessage(401,{selectIndex:e,channelData:{...s},type:"talk"})})}else this.sendErrorMessage("305")}talkByUrl(e){if("http:"===window.location.protocol)return console.error(D.$t("wsPlayer.error.113"));if("real"!==this.type)return console.error(D.$t("wsPlayer.error.112"));if(this.__checkWSRTSP(e)){this.playerList[e.selectIndex].talkByUrl(e)}}stopUrlTalk(e){this.playerList[e].stopTalk("url")}playRealVideo(e){let{channelList:t=[],streamType:s="2",windowIndex:i,showError:r,closeReason:a}=e;this.procedure&&this.procedure.playRealVideo(t,s,i,r||!1,a)}playReal(e){pe.call(this,e)}playRecord(e){ue.call(this,e)}playTalk(e){ye.call(this,e)}__checkWSRTSP(e){return e.rtspURL&&e.wsURL?e.rtspURL.startsWith("rtsp://")?!(!this.config.isRTPStream&&!e.rtspURL.includes("token="))||(console.error(D.$t("wsPlayer.error.109")),!1):(console.error(D.$t("wsPlayer.error.110")),!1):(console.error(D.$t("wsPlayer.error.106")),!1)}realByUrl(e){if("real"!==this.type)return console.error(D.$t("wsPlayer.error.112"));if(e.selectIndex=e.selectIndex||this.selectIndex,e.isContinue);else if("number"==typeof this.showNum)this.openSomeWindow(e.selectIndex+1);else if(e.selectIndex>=JSON.parse(this.showNum).length)return;"number"==typeof this.showNum?this.setSelectIndex(Math.min(e.selectIndex+1,this.showNum-1)):"string"==typeof this.showNum&&e.selectIndex+1<JSON.parse(this.showNum).length&&this.setSelectIndex(Math.min(e.selectIndex+1,JSON.parse(this.showNum).length-1)),this.__checkWSRTSP(e)&&pe.call(this,{playType:"url",rtspURL:e.rtspURL,wsURL:e.wsURL,channelId:e.channelId,streamType:e.streamType,streamServerIp:e.streamServerIp,playerAdapter:e.playerAdapter,selectIndex:e.selectIndex-0,channelData:e.channelData||{},isRTPStream:e.isRTPStream})}changeStreamType(e,t,s,i){this.procedure&&this.procedure.playRealVideo([e],t,s,!1,i)}playRecordVideo(e){this.procedure&&this.procedure.getRecordList(e)}recordByUrl(e){if("record"!==this.type)return console.error(D.$t("wsPlayer.error.111"));if(e.selectIndex=e.selectIndex||this.selectIndex,e.isContinue||e.isSeekRecord);else if("number"==typeof this.showNum)this.openSomeWindow(e.selectIndex+1);else if(e.selectIndex>=JSON.parse(this.showNum).length)return;e.isSeekRecord||e.isContinue||("number"==typeof this.showNum?this.setSelectIndex(Math.min(e.selectIndex+1,this.showNum-1)):"string"==typeof this.showNum&&e.selectIndex+1<JSON.parse(this.showNum).length&&this.setSelectIndex(Math.min(e.selectIndex+1,JSON.parse(this.showNum).length-1))),!e.records&&(e.records=[]),this.__checkWSRTSP(e)&&(e.records.length||console.warn(D.$t("wsPlayer.error.107")),e.records=e.records.sort((e,t)=>e.startTime-t.startTime),ue.call(this,{playType:"url",wsURL:e.wsURL,rtspURL:e.rtspURL,records:e.records||[],channelId:e.channelId,startTime:Number(e.startTime||e.records.length&&e.records[0].startTime),endTime:Number(e.endTime||e.records.length&&e.records[e.records.length-1].endTime),playerAdapter:e.playerAdapter,selectIndex:e.selectIndex-0,channelData:e.channelData||{},recordSource:e.recordSource,playRecordByTime:"boolean"!=typeof e.playRecordByTime||e.playRecordByTime,ssId:e.records&&e.records[0]&&e.records[0].ssId||"",isSeekRecord:e.isSeekRecord,closeReason:e.isSeekRecord?"seekRecord":"changeStream",isRTPStream:e.isRTPStream,currentRecordIndex:e.currentRecordIndex||0}))}clickRecordTimeLine(e){let t=this.playerList[this.selectIndex];this.timeList.some(s=>{if(e>=s.startTime&&e<s.endTime){if(t.options.playRecordByTime&&t.options.ssId===s.ssId)t.playSDK.SetSeekTime(e-t.options.startTime),this.sendMessage("setSeekTime",{timeStamp:e,selectIndex:this.selectIndex,channelInfo:t.options,channelData:t.options.channelData,hasVideoRecord:!0});else{if("url"===t.playType)return this.sendMessage("switchStartTime",{timeStamp:e,selectIndex:this.selectIndex,channelInfo:t.options,channelData:t.options.channelData,hasVideoRecord:!0}),!0;this.procedure&&this.procedure.clickRecordTimeLine(e,s.ssId)}return!0}return!1})||("url"===t.playType&&this.sendMessage("switchStartTime",{timeStamp:e,selectIndex:this.selectIndex,channelInfo:t.options,channelData:t.options.channelData,hasVideoRecord:!1}),console.warn("所选时间点无录像"))}jumpPlayByTime(e,t){if("real"===this.type)return void this.sendErrorMessage(613,{method:"jumpPlayByTime",arguments:{time:e,selectIndex:t}});let s,i=this.playerList[void 0===t?this.selectIndex:t];if(i){if(["playing","pause"].includes(i.status)){if("object"==typeof e)return s=e.getTime&&e.getTime()/1e3,void this.clickRecordTimeLine(s);if(e.indexOf&&-1===e.indexOf(":")&&(e=Number(e)),"string"==typeof e){const t=new Date(e);if(isNaN(t.getTime())){const t=e.split(":");if(3===t.length){const e=parseInt(t[0],10),i=parseInt(t[1],10),r=parseInt(t[2],10);s=new Date(1e3*this.timeList[0].startTime).setHours(e,i,r,0)/1e3}}else s=t.getTime()/1e3}"number"==typeof e&&(s=e<=86400&&e/1e3===parseInt(e/1e3)?Number(this.timeList[0].startTime)+e:e<=864e5?Number(this.timeList[0].startTime)+e/1e3:e.toString().length<=10?e:e/1e3),this.clickRecordTimeLine(s)}}else this.sendErrorMessage(601,{method:"jumpPlayByTime",arguments:{time:e,selectIndex:t}})}playNextRecord(e,t){this.procedure&&this.procedure.playNextRecord(e,t)}playNextRecordByFile(e,t){this.procedure&&this.procedure.playNextRecordByFile(e,t)}videoClosed(e,t,s,i,r){this.sendMessage("closeVideo",{selectIndex:e,changeVideoFlag:t,channelData:s,customDomId:i,closeReason:r}),this.procedure&&this.procedure.videoClosed(e,t,s)}sendErrorMessage(e,t={}){let s=i.errorInfo[e];t.insert&&(t.insert.forEach((e,t)=>{s=s.replace(`{${t}}`,e)}),delete t.insert),this.sendMessage("errorInfo",{errorCode:e,errorInfo:s,errorData:t})}dealRTSPError(e,t){this.sendErrorMessage(e,{res:"rtsp",arguments:{index:t}})}startLocalRecord(e,t,s,i,r){let a=void 0===i,l=this.playerList[void 0===e?this.selectIndex:e];l?"playing"===l.status||"pause"===l.status?l.isRecording?this.sendErrorMessage(602,{method:"startLocalRecord",arguments:{selectIndex:e,name:t,size:s}}):(l.isRecording=!0,l.startRecord(t,s,a,r),WSPlayerJQ.$(".record-icon",l.$el).addClass("recording")):this.sendErrorMessage(603,{method:"startLocalRecord",arguments:{selectIndex:e,name:t,size:s}}):this.sendErrorMessage(601,{method:"startLocalRecord",arguments:{selectIndex:e,name:t,size:s}})}stopLocalRecord(e,t){let s=this.playerList[void 0===e?this.selectIndex:e];s?s.isRecording?s.stopRecord("api"):this.sendErrorMessage(604,{method:"stopLocalRecord",arguments:{selectIndex:e}}):this.sendErrorMessage(601,{method:"stopLocalRecord",arguments:{selectIndex:e}})}setLoading(e,t,s,i){let r=this.playerList[void 0===e?this.selectIndex:e];r?r.setLoading(t,s,i):this.sendErrorMessage(601,{method:"setLoading",arguments:{selectIndex:e}})}setIvs({showIvs:e,selectIndex:t,ivsType:s=[1,2]}){let i=this.playerList[void 0===t?this.selectIndex:t];i?e?(WSPlayerJQ.$(".ws-draw-triangle",i.$el).removeClass("off").addClass("on"),WSPlayerJQ.$(".draw-triangle-icon",i.$el).removeClass("off").addClass("on"),Y.call(this,e,100*this.wsPlayerIndex+t,s)):(WSPlayerJQ.$(".ws-draw-triangle",i.$el).removeClass("on").addClass("off"),WSPlayerJQ.$(".draw-triangle-icon",i.$el).removeClass("on").addClass("off"),i.playSDK.CloseIVS()):this.sendErrorMessage(601,{method:"setIvs",arguments:{showIvs:e,selectIndex:t,ivsType:s}})}initPanTilt(e){this.panTilt=new nt({...e,prefixUrl:this.prefixUrl,locale:D},this)}setPtzChannel(e){this.panTilt&&this.panTilt.setChannel(e)}stopTalk(e){this.procedure&&this.procedure.stopTalk({data:e})}initMobilePanTilt(e){return new vt({...e,locale:D},this)}initRecordProgress(e){return new fe({canvasId:e.recordProgressId,records:[],currentTime:w.getToday12Time(),rulerLength:{short:10,middle:20,long:25},rulerScale:2,getCurrentTime:t=>{e.getCurrentTime?e.getCurrentTime(t):(this.clickRecordsTimer&&clearTimeout(this.clickRecordsTimer),this.clickRecordsTimer=setTimeout(()=>{clearTimeout(this.clickRecordsTimer),this.clickRecordsTimer=null},2e3),this.clickRecordTimeLine(t),this.play())}})}getArEvent(){return arEvent}}s($t,"version","1.3.6"),s($t,"updateTime","2025-08-30"),s($t,"SDKVersion","9f666bb54509959ec3b027e918351ca25fbd1a63"),e.WSPlayer=$t,e.default=$t,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});