@jp-web/ts-sdk
Version:
视频客服,视频会议Web端及微信小程序端SDK
21 lines (19 loc) • 67.9 kB
JavaScript
/*!
* version: 2.3.3 2293823
* git-hash: 77e84ccdeb86f789f7609c9021cdcc955b84eb71 [77e84cc]
* build time: 2020-09-17T13:16:01.706Z
*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.JuphoonWeChatConferenceSDK=t():e.JuphoonWeChatConferenceSDK=t()}(window,(function(){return function(e){function t(t){for(var n,o,i=t[0],s=t[1],a=0,u=[];a<i.length;a++)o=i[a],Object.prototype.hasOwnProperty.call(r,o)&&r[o]&&u.push(r[o][0]),r[o]=0;for(n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n]);for(c&&c(t);u.length;)u.shift()()}var n={},r={0:0};function o(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,o),r.l=!0,r.exports}o.e=function(e){var t=[],n=r[e];if(0!==n)if(n)t.push(n[2]);else{var i=new Promise((function(t,o){n=r[e]=[t,o]}));t.push(n[2]=i);var s,a=document.createElement("script");a.charset="utf-8",a.timeout=120,o.nc&&a.setAttribute("nonce",o.nc),a.src=function(e){return o.p+""+e+".juphoon-sdk.we-chat.conference.js"}(e);var c=new Error;s=function(t){a.onerror=a.onload=null,clearTimeout(u);var n=r[e];if(0!==n){if(n){var o=t&&("load"===t.type?"missing":t.type),i=t&&t.target&&t.target.src;c.message="Loading chunk "+e+" failed.\n("+o+": "+i+")",c.name="ChunkLoadError",c.type=o,c.request=i,n[1](c)}r[e]=void 0}};var u=setTimeout((function(){s({type:"timeout",target:a})}),12e4);a.onerror=a.onload=s,document.head.appendChild(a)}return Promise.all(t)},o.m=e,o.c=n,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)o.d(n,r,function(t){return e[t]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o.oe=function(e){throw console.error(e),e};var i=window.webpackJsonpJuphoonWeChatConferenceSDK=window.webpackJsonpJuphoonWeChatConferenceSDK||[],s=i.push.bind(i);i.push=t,i=i.slice();for(var a=0;a<i.length;a++)t(i[a]);var c=s;return o(o.s=2)}([function(e,t,n){!function(){var t;function n(e){for(var t,n,r,o,i=1,s=[].slice.call(arguments),a=0,c=e.length,u="",p=!1,l=!1,f=function(){return s[i++]},d=function(){for(var n="";/\d/.test(e[a]);)n+=e[a++],t=e[a];return n.length>0?parseInt(n):null};a<c;++a)if(t=e[a],p)switch(p=!1,"."==t?(l=!1,t=e[++a]):"0"==t&&"."==e[a+1]?(l=!0,t=e[a+=2]):l=!0,o=d(),t){case"b":u+=parseInt(f(),10).toString(2);break;case"c":u+="string"==typeof(n=f())||n instanceof String?n:String.fromCharCode(parseInt(n,10));break;case"d":u+=parseInt(f(),10);break;case"f":r=String(parseFloat(f()).toFixed(o||6)),u+=l?r:r.replace(/^0/,"");break;case"j":u+=JSON.stringify(f());break;case"o":u+="0"+parseInt(f(),10).toString(8);break;case"s":u+=f();break;case"x":u+="0x"+parseInt(f(),10).toString(16);break;case"X":u+="0x"+parseInt(f(),10).toString(16).toUpperCase();break;default:u+=t}else"%"===t?p=!0:u+=t;return u}(t=e.exports=n).format=n,t.vsprintf=function(e,t){return n.apply(null,[e].concat(t))},"undefined"!=typeof console&&"function"==typeof console.log&&(t.printf=function(){console.log(n.apply(null,arguments))})}()},function(e,t,n){(function(){var e,n,r,o,i={}.hasOwnProperty,s=[].slice;e={LF:"\n",NULL:"\0"},r=function(){var t;function n(e,t,n){this.command=e,this.headers=null!=t?t:{},this.body=null!=n?n:""}return n.prototype.toString=function(){var t,r,o,s,a;for(r in t=[this.command],(o=!1===this.headers["content-length"])&&delete this.headers["content-length"],a=this.headers)i.call(a,r)&&(s=a[r],t.push(r+":"+s));return this.body&&!o&&t.push("content-length:"+n.sizeOfUTF8(this.body)),t.push(e.LF+this.body),t.join(e.LF)},n.sizeOfUTF8=function(e){return e?encodeURI(e).match(/%..|./g).length:0},t=function(t){var r,o,i,s,a,c,u,p,l,f,d,E,h,m,g,_,v;for(s=t.search(RegExp(""+e.LF+e.LF)),i=(a=t.substring(0,s).split(e.LF)).shift(),c={},E=function(e){return e.replace(/^\s+|\s+$/g,"")},h=0,g=(_=a.reverse()).length;h<g;h++)p=(f=_[h]).indexOf(":"),c[E(f.substring(0,p))]=E(f.substring(p+1));if(r="",d=s+2,c["content-length"])l=parseInt(c["content-length"]),r=(""+t).substring(d,d+l);else for(o=null,u=m=d,v=t.length;(d<=v?m<v:m>v)&&(o=t.charAt(u))!==e.NULL;u=d<=v?++m:--m)r+=o;return new n(i,c,r)},n.unmarshall=function(n){var r;return function(){var o,i,s,a;for(a=[],o=0,i=(s=n.split(RegExp(""+e.NULL+e.LF+"*"))).length;o<i;o++)(null!=(r=s[o])?r.length:void 0)>0&&a.push(t(r));return a}()},n.marshall=function(t,r,o){return new n(t,r,o).toString()+e.NULL},n}(),n=function(){var t;function n(e){this.ws=e,this.ws.binaryType="arraybuffer",this.counter=0,this.connected=!1,this.heartbeat={outgoing:1e4,incoming:1e4},this.maxWebSocketFrameSize=16384,this.subscriptions={}}return n.prototype.debug=function(e){var t;return"undefined"!=typeof window&&null!==window&&null!=(t=window.console)?t.log(e):void 0},t=function(){return Date.now?Date.now():(new Date).valueOf},n.prototype._transmit=function(e,t,n){var o;for(o=r.marshall(e,t,n),"function"==typeof this.debug&&this.debug(">>> "+o);;){if(!(o.length>this.maxWebSocketFrameSize))return this.ws.send(o);this.ws.send(o.substring(0,this.maxWebSocketFrameSize)),o=o.substring(this.maxWebSocketFrameSize),"function"==typeof this.debug&&this.debug("remaining = "+o.length)}},n.prototype._setupHeartbeat=function(n){var r,i,s,a,c,u;if((c=n.version)===o.VERSIONS.V1_1||c===o.VERSIONS.V1_2)return i=(u=function(){var e,t,r,o;for(o=[],e=0,t=(r=n["heart-beat"].split(",")).length;e<t;e++)a=r[e],o.push(parseInt(a));return o}())[0],r=u[1],0!==this.heartbeat.outgoing&&0!==r&&(s=Math.max(this.heartbeat.outgoing,r),"function"==typeof this.debug&&this.debug("send PING every "+s+"ms"),this.pinger=o.setInterval(s,function(t){return function(){return t.ws.send(e.LF),"function"==typeof t.debug?t.debug(">>> PING"):void 0}}(this))),0!==this.heartbeat.incoming&&0!==i?(s=Math.max(this.heartbeat.incoming,i),"function"==typeof this.debug&&this.debug("check PONG every "+s+"ms"),this.ponger=o.setInterval(s,function(e){return function(){var n;if((n=t()-e.serverActivity)>2*s)return"function"==typeof e.debug&&e.debug("did not receive server activity for the last "+n+"ms"),e.ws.close()}}(this))):void 0},n.prototype._parseConnect=function(){var e,t,n,r;switch(r={},(e=1<=arguments.length?s.call(arguments,0):[]).length){case 2:r=e[0],t=e[1];break;case 3:e[1]instanceof Function?(r=e[0],t=e[1],n=e[2]):(r.login=e[0],r.passcode=e[1],t=e[2]);break;case 4:r.login=e[0],r.passcode=e[1],t=e[2],n=e[3];break;default:r.login=e[0],r.passcode=e[1],t=e[2],n=e[3],r.host=e[4]}return[r,t,n]},n.prototype.connect=function(){var n,i,a,c;return n=1<=arguments.length?s.call(arguments,0):[],c=this._parseConnect.apply(this,n),a=c[0],this.connectCallback=c[1],i=c[2],"function"==typeof this.debug&&this.debug("Opening Web Socket..."),this.ws.onmessage=function(n){return function(o){var s,a,c,u,p,l,f,d,E,h,m,g;if(u="undefined"!=typeof ArrayBuffer&&o.data instanceof ArrayBuffer?(s=new Uint8Array(o.data),"function"==typeof n.debug&&n.debug("--- got data length: "+s.length),function(){var e,t,n;for(n=[],e=0,t=s.length;e<t;e++)a=s[e],n.push(String.fromCharCode(a));return n}().join("")):o.data,n.serverActivity=t(),u!==e.LF){for("function"==typeof n.debug&&n.debug("<<< "+u),g=[],E=0,h=(m=r.unmarshall(u)).length;E<h;E++)switch((p=m[E]).command){case"CONNECTED":"function"==typeof n.debug&&n.debug("connected to server "+p.headers.server),n.connected=!0,n._setupHeartbeat(p.headers),g.push("function"==typeof n.connectCallback?n.connectCallback(p):void 0);break;case"MESSAGE":d=p.headers.subscription,(f=n.subscriptions[d]||n.onreceive)?(c=n,l=p.headers["message-id"],p.ack=function(e){return null==e&&(e={}),c.ack(l,d,e)},p.nack=function(e){return null==e&&(e={}),c.nack(l,d,e)},g.push(f(p))):g.push("function"==typeof n.debug?n.debug("Unhandled received MESSAGE: "+p):void 0);break;case"RECEIPT":g.push("function"==typeof n.onreceipt?n.onreceipt(p):void 0);break;case"ERROR":g.push("function"==typeof i?i(p):void 0);break;default:g.push("function"==typeof n.debug?n.debug("Unhandled frame: "+p):void 0)}return g}"function"==typeof n.debug&&n.debug("<<< PONG")}}(this),this.ws.onclose=function(e){return function(){var t;return t="Whoops! Lost connection to "+e.ws.url,"function"==typeof e.debug&&e.debug(t),e._cleanUp(),"function"==typeof i?i(t):void 0}}(this),this.ws.onopen=function(e){return function(){return"function"==typeof e.debug&&e.debug("Web Socket Opened..."),a["accept-version"]=o.VERSIONS.supportedVersions(),a["heart-beat"]=[e.heartbeat.outgoing,e.heartbeat.incoming].join(","),e._transmit("CONNECT",a)}}(this)},n.prototype.disconnect=function(e,t){return null==t&&(t={}),this._transmit("DISCONNECT",t),this.ws.onclose=null,this.ws.close(),this._cleanUp(),"function"==typeof e?e():void 0},n.prototype._cleanUp=function(){if(this.connected=!1,this.pinger&&o.clearInterval(this.pinger),this.ponger)return o.clearInterval(this.ponger)},n.prototype.send=function(e,t,n){return null==t&&(t={}),null==n&&(n=""),t.destination=e,this._transmit("SEND",t,n)},n.prototype.subscribe=function(e,t,n){var r;return null==n&&(n={}),n.id||(n.id="sub-"+this.counter++),n.destination=e,this.subscriptions[n.id]=t,this._transmit("SUBSCRIBE",n),r=this,{id:n.id,unsubscribe:function(){return r.unsubscribe(n.id)}}},n.prototype.unsubscribe=function(e){return delete this.subscriptions[e],this._transmit("UNSUBSCRIBE",{id:e})},n.prototype.begin=function(e){var t,n;return n=e||"tx-"+this.counter++,this._transmit("BEGIN",{transaction:n}),t=this,{id:n,commit:function(){return t.commit(n)},abort:function(){return t.abort(n)}}},n.prototype.commit=function(e){return this._transmit("COMMIT",{transaction:e})},n.prototype.abort=function(e){return this._transmit("ABORT",{transaction:e})},n.prototype.ack=function(e,t,n){return null==n&&(n={}),n["message-id"]=e,n.subscription=t,this._transmit("ACK",n)},n.prototype.nack=function(e,t,n){return null==n&&(n={}),n["message-id"]=e,n.subscription=t,this._transmit("NACK",n)},n}(),o={VERSIONS:{V1_0:"1.0",V1_1:"1.1",V1_2:"1.2",supportedVersions:function(){return"1.1,1.0"}},client:function(e,t){var r;return null==t&&(t=["v10.stomp","v11.stomp"]),r=new(o.WebSocketClass||WebSocket)(e,t),new n(r)},over:function(e){return new n(e)},Frame:r},null!==t&&(t.Stomp=o),"undefined"!=typeof window&&null!==window?(o.setInterval=function(e,t){return window.setInterval(t,e)},o.clearInterval=function(e){return window.clearInterval(e)},window.Stomp=o):t||(self.Stomp=o)}).call(this)},function(e,t,n){"use strict";n.r(t),n.d(t,"JuphoonWeChatConference",(function(){return pe})),n.d(t,"Reporter",(function(){return L})),n.d(t,"LoggerLevel",(function(){return O})),n.d(t,"RenderType",(function(){return se})),n.d(t,"SocketEventType",(function(){return y})),n.d(t,"StreamErrorType",(function(){return ue})),n.d(t,"StreamEventType",(function(){return ce})),n.d(t,"ConferencePictureSize",(function(){return I})),n.d(t,"ConferenceErrorType",(function(){return B})),n.d(t,"ConferenceEventType",(function(){return x})),n.d(t,"VideoLayoutScreenShareMode",(function(){return V})),n.d(t,"VideoLayoutIntellegenceMergeMode",(function(){return G})),n.d(t,"VideoLayoutMergeMode",(function(){return F})),n.d(t,"ConferenceClientState",(function(){return A})),n.d(t,"MediaRecorderEventType",(function(){return Y})),n.d(t,"MediaRecorderState",(function(){return W})),n.d(t,"MediaRecorderErrorType",(function(){return J})),n.d(t,"MediaRemoteRecordPictureSize",(function(){return H})),n.d(t,"Platform",(function(){return fe})),n.d(t,"PlatformType",(function(){return re})),n.d(t,"ConferenceRole",(function(){return k})),n.d(t,"SimpleRoleCompose",(function(){return D}));
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function o(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var i,s=function(){return(s=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function a(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r}!function(e){e.Array="[object Array]",e.Boolean="[object Boolean]",e.BigInt="[object BigInt]",e.Date="[object Date]",e.Error="[object Error]",e.Function="[object Function]",e.Number="[object Number]",e.Null="[object Null]",e.Math="[object Math]",e.MediaStream="[object MediaStream]",e.LocalMediaStream="[object LocalMediaStream]",e.MediaStreamTrack="[object MediaStreamTrack]",e.AudioStreamTrack="[object AudioStreamTrack]",e.VideoStreamTrack="[object VideoStreamTrack]",e.Object="[object Object]",e.RegExp="[object RegExp]",e.String="[object String]",e.Symbol="[object Symbol]",e.Undefined="[object Undefined]",e.UnKnown="[object Unknown]",e.Promise="[object Promise]"}(i||(i={}));var c={UAN:[i.Undefined,i.Null]};function u(e){return void 0===e||void 0===e?i.Undefined:null===e?i.Null:Object.prototype.toString.call(e)}function p(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var r=u(e),o=t.length;o--;)if(r===t[o])return!0;return!1}function l(e,t){return void 0===t&&(t=!0),p(e,i.String)&&(!t||e.length>0)}function f(e,t){return void 0===t&&(t=!0),p(e,i.Number)&&(!t||!isNaN(e))}function d(e){return!p.apply(void 0,a([e],c.UAN))}function E(e){return p(e,i.Function)}function h(e){return p(e,i.Boolean)&&e}function m(e){return p(e,i.Boolean)&&!e}function g(e){return p(e,i.Array)}function _(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return!!p.apply(void 0,a([e],t))||new Error("type of variable "+JSON.stringify(e)+" is not "+JSON.stringify(t))}function v(e){if(!g(e))return{error:new Error("variableParameterArr is not a array")};for(var t=e.length,n=void 0,r=void 0;n=e[--t];)if(!h(r=_.apply(void 0,n)))return{accept:!1,error:r};return{accept:!0}}var R,y,S,O,N="undefined"!=typeof window,b="undefined"!=typeof wx,T=n(0),C=n.n(T);!function(e){e[e.CONNECTING=0]="CONNECTING",e[e.OPEN=1]="OPEN",e[e.CLOSING=2]="CLOSING",e[e.CLOSED=3]="CLOSED",e[e.RECONNECTING=4]="RECONNECTING"}(R||(R={})),function(e){e.OPENED="opened",e.RECONNECTED="reconnected",e.BEFORE_CLOSE="beforeClose",e.CLOSED="closed",e.ERROR="error",e.MESSAGE="message",e.DISCONNECTED="disconnected"}(y||(y={})),function(e){e.RECONNECT_TIMES_EXCEED_ERROR="reconnectTimesExceedError",e.RECONNECT_ERROR="reconnectError"}(S||(S={})),function(e){e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e[e.NONE=4]="NONE"}(O||(O={}));var L=function(){function e(e){this.className=d(e)?e:""}return e._reportSuccessCallback=function(){e._lastReportedIndex=e._logList.length},e._mergeLog=function(t){var n=[];if(!d(t)||!f(t.length)||t.length<=0)return n;for(var r=t.length,o=e._config.maxSize,i=0,s=[],a=0,c=void 0,u=void 0,p=void 0;c=t[a],a<r;a++)d(e._reportLevelMap[c.type])&&(u=JSON.stringify(t[a]),i+(p=new Blob([u]).size)>o&&(s.length>0&&n.push(s),i=0,s=[]),i+=p,s.push(u),a+1>=r&&s.length>0&&n.push(s));return n},e.setLogLevel=function(t){e._level=t},e.setReportLevel=function(t){g(t)&&(e._reportLevels=t,e._reportLevelMap={},e._reportLevels.forEach((function(t){return e._reportLevelMap[O[t]]=t})))},e.startReport=function(t,n){if(e.reporter.info("invoke startReport\thas socket: %s\tinfo: %j",d(t),n),-1!==e._intervalKey)return e.reporter.warning("Reporter started."),Promise.reject();if(e._reportLevels.forEach((function(t){return e._reportLevelMap[O[t]]=t})),d(t)){if(e._socket=t,d(n.timestamp)||(n.timestamp=Date.now()),d(n.params)||(n.params={}),d(n.params.userAgent)||(n.params.userAgent=navigator.userAgent),!d(n.type))throw new Error("report info param [type] is undefined or null");if(d(n.tags)||(n.tags=[]),!d(n.from))throw new Error("report info param [from] is undefined or null");return e.DEFAULT_LOG_INFO={timestamp:null,tags:n.logTags||[],from:n.from,refer:this._reportReferMap,type:null,info:null},e._report=function(t){return d(t)?l(t.length)&&t.length<=0?Promise.resolve():e._socket.sendTo(t,"/acd/log",{_report:!1}):Promise.reject(new Error("log string is undefined or null"))},e._reportReferMap={},this._getInfoId(n).then((function(){e._intervalKey=window.setInterval((function(){e.flush().then()}),e._config.interval)}))}Promise.resolve()},e.flush=function(){if(e._lastReportedIndex+1===e._logList.length)return Promise.resolve();var t=e._mergeLog(e._logList.slice(e._lastReportedIndex,e._logList.length));return e._reportSuccessCallback(),t.length<=0?Promise.resolve():Promise.all(t.map((function(t){return e._report(t)}))).then()},e.stopReport=function(){return e.reporter.info("invoke stopReporter\tinterval key: %s",e._intervalKey),-1===e._intervalKey?Promise.resolve():(clearInterval(e._intervalKey),e._intervalKey=-1,e.flush())},e.addReferKey=function(t,n,r){if(e.reporter.info("invoke addReferKey\tkey: %s\ttags: %j\tparams: %j",t,n,r),d(t)){d(n)||(n=[t]),d(r)||(r={}),r.referMap=e._reportReferMap;var o={timestamp:Date.now(),type:t,tags:n,params:r};return this._getInfoId(o)}e.reporter.error("key is undefined or null")},e.removeReferKey=function(t){e.reporter.info("invoke removeInfoId\tkey: %s",t),d(e._reportReferMap)&&d(e._reportReferMap[t])&&delete e._reportReferMap[t]},e._getInfoId=function(t){return e.reporter.info("invoke _getInfoId\tinfo: %j",t),new Promise((function(n,r){e._socket.addEventListener(y.MESSAGE,(function(r,o){var i=r.message,s=i.type,a=i.txt,c=void 0===a?{}:a,u=c.cmd,p=c.val;"msg"===s&&"getinfoid"===u&&(e._reportReferMap[t.type]=p,o(),n())})),t.params=JSON.stringify(t.params),new Promise((function(t,n){e._socket.state===R.OPEN?t():(e._socket.addEventListener(y.OPENED,(function(){return t()})),e._socket.addEventListener(y.ERROR,(function(e){return n(e)})))})).then((function(){return e._socket.sendTo(t,"/acd/info_id")})).catch((function(e){return r(e)}))}))},e.prototype.debug=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];this.log.apply(this,a([O.DEBUG,e],t))},e.prototype.info=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];this.log.apply(this,a([O.INFO,e],t))},e.prototype.warning=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];this.log.apply(this,a([O.WARN,e],t))},e.prototype.error=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];this.log.apply(this,a([O.ERROR,e],t))},e.prototype.log=function(t,n){for(var r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];var i=s(s({},e.DEFAULT_LOG_INFO),{timestamp:Date.now(),type:t,info:{className:this.className,content:C.a.apply(void 0,a([n],r))}});e._logList.push(i),e._level<=t&&e.onlog.apply(e,a([C.a.apply(void 0,a([(new Date).toISOString()+"\t["+O[t]+"]\t"+this.className+"\t"+n],r)),t,this.className,n],r))},e.asText=function(t){return void 0===t&&(t=O.DEBUG),e._logList.filter((function(e){return e.type>=t})).map((function(e){return C()(new Date(e.timestamp).toISOString()+"\t["+O[e.type]+"]\t"+e.info.className+"\t"+e.info.content)})).join("\n")},e.asArray=function(t){return void 0===t&&(t=O.DEBUG),e._logList.filter((function(e){return e.type>=t}))},e.asTextFile=function(t,n){void 0===t&&(t=""+(new Date).toISOString()),void 0===n&&(n=O.DEBUG);var r=URL.createObjectURL(new Blob([e.asText(n)],{type:"text/plain;charset=utf-8"})),o=document.createElement("a");o.href=r,o.setAttribute("download",t+".log"),o.style.display="none",o.click(),URL.revokeObjectURL(r)},e.onlog=function(e,t,n,r){for(var o=[],i=4;i<arguments.length;i++)o[i-4]=arguments[i];console.log(e)},e.plugin=function(t){e._pluginList.push(t),t.use()},e.clearPlugin=function(){for(var t=e._pluginList,n=t.length;n--;)t[n].unuse()},e.reporter=new e("Reporter"),e.DEFAULT_REPORT_LEVELS=[O.INFO,O.ERROR],e.DEFAULT_LEVEL=O.DEBUG,e.DEFAULT_REPORT_FUNC=function(e){return new Promise((function(e,t){e()}))},e._lastReportedIndex=-1,e._logList=[],e._level=e.DEFAULT_LEVEL,e._reportLevels=e.DEFAULT_REPORT_LEVELS,e._reportLevelMap={},e._config={interval:5e3,maxSize:8192},e._reportReferMap={},e._intervalKey=-1,e._pluginList=[],e._report=e.DEFAULT_REPORT_FUNC,e}();var I,A,P=function(){function e(){this.listenerMap={}}return e.prototype.addEventListener=function(t,n,r){var o=this;if(!p(t,i.String,i.Number)||!p(n,i.Function))return null;var a=function(){return o.removeEventListener(t,n)},c=this.listenerMap[t];return r=s(s({},e.DEFAULT_EVENT_LISTENER_OPTIONS),r),n.listenerOptions=r,n.removeSelf=a,p(c,i.Array)||(this.listenerMap[t]=[],c=this.listenerMap[t]),c.push(n),a},e.prototype.addEventListeners=function(e,t,n){var r=this;if(!p(e,i.Array)||!p(t,i.Function))return!1;var o=[];return e.forEach((function(e){return o.push(r.addEventListener(e,t))})),function(){return o.forEach((function(e){return e()}))}},e.prototype.removeEventListener=function(e,t){if(!p(e,i.String,i.Number)||!p(t,i.Function)||!p(this.listenerMap[e],i.Array))return!1;var n=this.listenerMap[e],r=n.indexOf(t);return!(r<=-1)&&(n.splice(r,1),!0)},e.prototype.dispatchEvent=function(e){var t=this.listenerMap[e.type];if(!p(t,i.Array))return!1;if(t.slice().forEach((function(t){return t(e,t.removeSelf)})),l(e.type)){var n=e.type,r="on"+n.substring(0,1).toUpperCase()+n.substring(1);p(this[r],i.Function)&&this[r](e)}return this.listenerMap[e.type]=t.filter((function(e){return!function(e){return p(e,i.Boolean)&&e}(e.listenerOptions.once)})),!0},e.prototype.dispatchEventLite=function(e,t,n){var r;r=d(n)?new M(e,n,t):new w(e,t),this.dispatchEvent(r)},e.prototype.hasListener=function(e){var t=this.listenerMap[e];return d(t)&&p(t,i.Array)&&t.length>0},e.prototype.clearListener=function(){for(var e=0,t=Object.keys(this.listenerMap);e<t.length;e++){var n=t[e];delete this.listenerMap[n]}},e.DEFAULT_EVENT_LISTENER_OPTIONS={once:!1},e}(),w=function(e,t){this.type=e,this.message=t},M=function(e){function t(t,n,r){var o=e.call(this,t,r)||this;return o.error=n,o}return o(t,e),t}(w);!function(e){e.NONE="0x0",e.MIN="0x100",e.SMALL="0x200",e.LARGE="0x300",e.MAX="0x400"}(I||(I={})),function(e){e.CLIENT_INIT="clientInit",e.CONFERENCE_JOIN="conferenceJoin",e.CONFERENCE_LEAVE="conferenceLeave",e.CLIENT_DESTROY="clientDestroy"}(A||(A={}));var k,D,U=function(e){function t(n,r,o){var i=e.call(this)||this;return i._pageTarget=n,i.userId=r,i.options=s(s({},t.DEFAULT_STREAM_OPTIONS),o),t.reporter.info("instance created\thas pageTarget: %s\tuserId: %s\toptions: %j",d(n),r,o),i}return o(t,e),t.prototype.bindComponent=function(e,n){var r=this;return t.reporter.info("invoke bindComponent\tid: %s\thas pageTarget: %s",e,d(n)),this.component=this._pageTarget.selectComponent("#"+e),this.component.onStateChange=function(e){return r.onstatechange&&r.onstatechange(e)},this.component.onNetStateChange=function(e){return r.onnetstatechange&&r.onnetstatechange(e)},this.component.onError=function(e){return r.onerror&&r.onerror(e)},this.component.onBGMStart=function(e){return r.onbgmstart&&r.onbgmstart(e)},this.component.onBGMProcess=function(e){return r.onbgmprocess&&r.onbgmprocess(e)},this.component.onBGMComplete=function(e){return r.onbgmcomplete&&r.onbgmcomplete(e)},this.reset()},t.prototype.start=function(e,n){var r=this;return t.reporter.info("invoke start\tid: %s\thas pageTarget: %j",e,d(n)),new Promise((function(t){return d(n)?r.bindComponent(e,n).then((function(){return t()})):t()})).then((function(){return l(e)?new Promise((function(e,t){return r.component.start({success:e,fail:t})})):Promise.reject(new Error("id not a string."))}))},t.prototype.stop=function(){var e=this;return new Promise((function(t,n){return e.component.stop({success:t,fail:n})}))},t.prototype.pause=function(){var e=this;return new Promise((function(t,n){return e.component.pause({success:t,fail:n})}))},t.prototype.enableAudio=function(){return t.reporter.info("invoke enableAudio"),this.options.enableMic=!0,this.reset()},t.prototype.disableAudio=function(){return t.reporter.info("invoke disableAudio"),this.options.enableMic=!1,this.reset()},t.prototype.enableVideo=function(){return t.reporter.info("invoke enableVideo"),this.options.enableCamera=!0,this.reset()},t.prototype.disableVideo=function(){return t.reporter.info("invoke disableVideo"),this.options.enableCamera=!1,this.reset()},t.prototype.enablePreview=function(){var e=this;return new Promise((function(t,n){return e.component.startPreview({success:t,fail:n})}))},t.prototype.disablePreview=function(){var e=this;return new Promise((function(t,n){return e.component.stopPreview({success:t,fail:n})}))},t.prototype.switchCamera=function(e){var n,r=this;return t.reporter.info("invoke switchCamera\t camera: %s",e),d(e)?l(e)?"front"!==e&&"back"!==e?n=Promise.reject(new Error("camera not allow "+e)):this.options.devicePosition!==e&&(n=Promise.all([this.reset({devicePosition:e}),new Promise((function(e,t){return r.component.switchCamera({success:e,fail:t})}))])):n=Promise.reject(new Error("camera not s string.")):n=Promise.reject(new Error("camera is undefined or null.")),n},t.prototype.snapshot=function(e){return this.component.snapshot(e)},t.prototype.reset=function(e){var n=this;return void 0===e&&(e=this.options),new Promise((function(r,o){t.reporter.info("local stream reset options:\t\nold options:\t%j\nnew options:\t%j",n.options,e),Object.assign(n.options,e),n.component?n.component._propertyObserver(n).then((function(){t.reporter.info("local stream reset options success."),r()})).catch((function(e){t.reporter.warning("local stream reset options fail:\t\nmessage:\t%j",e),o(e)})):o("property component is null.")}))},t.prototype.onstatechange=function(e){t.reporter.debug("onstatechange\t\nevent: %j",e)},t.prototype.onnetstatechange=function(e){t.reporter.debug("onnetstatechange\t\nevent: %j",e)},t.prototype.onerror=function(e){t.reporter.debug("onerror\t\nevent: %j",e)},t.prototype.onbgmstart=function(e){t.reporter.debug("onbgmstart\t\nevent: %j",e)},t.prototype.onbgmprocess=function(e){t.reporter.debug("onbgmprocess\t\nevent: %j",e)},t.prototype.onbgmcomplete=function(e){t.reporter.debug("onbgmcomplete\t\nevent: %j",e)},t.prototype.setAudioOutput=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Promise.reject(new Error("setAudioOutput not supported."))},t.DEFAULT_STREAM_OPTIONS={pushUrl:null,mode:"RTC",autopush:!1,enableCamera:!0,autoFocus:!0,orientation:"vertical",beauty:0,whiteness:0,aspect:"9:16",minBitrate:450,maxBitrate:600,audioQuality:"high",waitingImage:"",waitingImageHash:"",zoom:!1,devicePosition:"front",backgroundMute:!0,remoteMirror:!1,localMirror:"auto",audioReverbType:0,enableMic:!0,enableAgc:!1,enableAns:!1,audioVolumeType:"voicecall",videoWidth:360,videoHeight:640,debug:!1,hidden:!1},t.reporter=new L("WeChatLocalStream"),t}(P),j=function(e){function t(n,r,o){var i=e.call(this)||this;return i._pageTarget=n,i.userId=r,i.options=s(s({},t.DEFAULT_STREAM_OPTIONS),o),t.reporter.info("instance created\thas pageTarget: %j\tuserId: %s\toptions: %j",d(n),r,o),i}return o(t,e),t.prototype.bindComponent=function(e,n){return t.reporter.info("invoke bindComponent\tid: %s\thas pageTarget: %s",e,d(n)),this._pageTarget=n,this.component=this._pageTarget.selectComponent("#"+e),this.reset()},t.prototype.start=function(e,n){var r=this;return t.reporter.info("invoke start\tid: %s\thas pageTarget: %j",e,d(n)),new Promise((function(t){return d(n)?r.bindComponent(e,n).then((function(){return t()})):t()})).then((function(){return l(e)?new Promise((function(e,t){return r.component.play({success:e,fail:t})})):Promise.reject(new Error("id not a string."))}))},t.prototype.stop=function(){var e=this;return new Promise((function(t,n){return e.component.stop({success:t,fail:n})}))},t.prototype.pause=function(){var e=this;return new Promise((function(t,n){return e.component.pause({success:t,fail:n})}))},t.prototype.enableAudio=function(){return t.reporter.info("invoke enableAudio"),this.options.muted=!1,this.reset()},t.prototype.disableAudio=function(){return t.reporter.info("invoke disableAudio"),this.options.muted=!0,this.reset()},t.prototype.enableVideo=function(){return t.reporter.info("invoke enableVideo"),this.options.muteVideo=!1,this.reset()},t.prototype.disableVideo=function(){return t.reporter.info("invoke disableVideo"),this.options.muteVideo=!0,this.reset()},t.prototype.setAudioOutput=function(e){return t.reporter.info("invoke setAudioOutput\tsoundMode: %s",e),this.reset({soundMode:e})},t.prototype.reset=function(e){var n=this;return void 0===e&&(e=this.options),new Promise((function(r,o){t.reporter.info("remote stream reset config:\t\nold config:\t%j\nnew config:\t%j",n.options,e),Object.assign(n.options,e),n.component?n.component._propertyObserver(n).then((function(){t.reporter.info("remote stream reset config success."),r()})).catch((function(e){t.reporter.warning("remote stream reset config fail:\t\nmessage:\t%j",e),o(e)})):o("property component is null.")}))},t.prototype.attachComponent=function(e){var t=this;this.component=e,this.component.onStateChange=function(e){return t.onstatechange&&t.onstatechange(e)},this.component.onFullScreenChange=function(e){return t.onfullscreenchange&&t.onfullscreenchange(e)},this.component.onNetStateChange=function(e){return t.onnetstatechange&&t.onnetstatechange(e)},this.component.onAudioVolumeNotify=function(e){return t.onaudiovolumenotify&&t.onaudiovolumenotify(e)},this.component.onEnterPictureInPicture=function(e){return t.onenterpictureinpicturechange&&t.onenterpictureinpicturechange(e)},this.component.onLeavePictureInPicture=function(e){return t.onleavepictureinpicturechange&&t.onleavepictureinpicturechange(e)},this.reset(this.options).then()},t.prototype.onstatechange=function(e){t.reporter.debug("onstatechange\t\nevent: %j",e)},t.prototype.onfullscreenchange=function(e){t.reporter.debug("onfullscreenchange\t\nevent: %j",e)},t.prototype.onnetstatechange=function(e){t.reporter.debug("onnetstatechange\t\nevent: %j",e)},t.prototype.onaudiovolumenotify=function(e){t.reporter.debug("onaudiovolumenotify\t\nevent: %j",e)},t.prototype.onenterpictureinpicturechange=function(e){t.reporter.debug("onenterpictureinpicturechange\t\nevent: %j",e)},t.prototype.onleavepictureinpicturechange=function(e){t.reporter.debug("onleavepictureinpicturechange\t\nevent: %j",e)},t.prototype.snapshot=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t]},t.DEFAULT_STREAM_OPTIONS={src:null,mode:"RTC",autoplay:!0,muted:!1,orientation:"vertical",objectFit:"contain",minCache:.2,maxCache:.8,soundMode:"speaker",pictureInPictureMode:[],autoPauseIfNavigate:!0,autoPauseIfOpenNative:!0,enableRecvMessage:"false",muteAudio:!1,muteVideo:!1,debug:!1,hidden:!1},t.reporter=new L("WeChatRemoteStream"),t}(P);!function(e){e[e.VIEWER=1]="VIEWER",e[e.SENDER=2]="SENDER",e[e.ACTOR=3]="ACTOR",e[e.PLAYER=4]="PLAYER",e[e.PARTP=7]="PARTP",e[e.OWNER=8]="OWNER",e[e.AGENT=64]="AGENT",e[e.DELIVERY_RECORD=100]="DELIVERY_RECORD",e[e.GUEST=128]="GUEST",e[e.DELIVERY_IRC=256]="DELIVERY_IRC",e[e.DELIVERY_WEBRTC=512]="DELIVERY_WEBRTC",e[e.DELIVERY_PSTN=1024]="DELIVERY_PSTN",e[e.DELIVERY_MCU=2048]="DELIVERY_MCU",e[e.SERVICE_MASK=65535]="SERVICE_MASK",e[e.DELIVERY_MASK=1792]="DELIVERY_MASK"}(k||(k={})),function(e){e[e.NORNAL=7]="NORNAL",e[e.AGENT=71]="AGENT",e[e.GUEST=135]="GUEST"}(D||(D={}));var F,G,V,x,B,K=function(){function e(e,t,n,r,o){this.id0=e,this.nick=t,this.role=n,this.state=r,this.subscribe=o,this.leave=!1}return e.prototype.isRelayVideo=function(){return 0!=(this.state&e.RELAY_VIDEO)},e.prototype.isRelayAudio=function(){return 0!=(this.state&e.RELAY_AUDIO)},e.prototype.enableVideo=function(){return 0!=(this.state&e.ENABLE_VIDEO)},e.prototype.enableAudio=function(){return 0!=(this.state&e.ENABLE_AUDIO)},e.prototype.isSender=function(){return 0!=(this.role&k.SENDER)},e.prototype.isPlayer=function(){return 0!=(this.role&k.PLAYER)},e.prototype.isOwner=function(){return 0!=(this.role&k.OWNER)},e.prototype.isRecordDelivery=function(){return 0!=(this.role&k.DELIVERY_RECORD)},e.prototype.isAgent=function(){return 0!=(this.role&k.AGENT)},e.prototype.isGuest=function(){return 0!=(this.role&k.GUEST)},e.prototype.isConferenceDelivery=function(){return 0!=(this.role&k.DELIVERY_IRC)},e.prototype.isSubscribeVideo=function(){return 0!=(this.subscribe&e.SUBSCRIBE_VIDEO)},e.prototype.changeConferenceRole=function(e){this.role&=e},e.prototype._updateParticipantInfo=function(e,t,n,r){l(e)&&(this.nick=e),f(t)&&(this.role=t),f(n)&&(this.state=n),f(r)&&(this.subscribe=r)},e.RELAY_VIDEO=1,e.RELAY_AUDIO=2,e.ENABLE_VIDEO=4,e.ENABLE_AUDIO=8,e.SUBSCRIBE_VIDEO=1,e}();!function(e){e[e.SCREEN=1]="SCREEN",e[e.PLATFORM=2]="PLATFORM",e[e.SPEAKER=3]="SPEAKER",e[e.LAYOUT=4]="LAYOUT",e[e.INTELLEGNCE=5]="INTELLEGNCE",e[e.SCREEN_SHARING=6]="SCREEN_SHARING"}(F||(F={})),function(e){e[e.FREE_LAYOUT=1]="FREE_LAYOUT",e[e.RECT_LAYOUT=2]="RECT_LAYOUT",e[e.BIG_SMALLX2=3]="BIG_SMALLX2",e[e.BIG_SMALLX3=4]="BIG_SMALLX3",e[e.BIG_SMALLX4=5]="BIG_SMALLX4",e[e.BIG_SMALLX5=6]="BIG_SMALLX5",e[e.BIG_SMALLX6=7]="BIG_SMALLX6",e[e.BIG_SMALLX7=8]="BIG_SMALLX7",e[e.BIG_SMALLX8=9]="BIG_SMALLX8",e[e.BIG_SMALLX9=10]="BIG_SMALLX9",e[e.BIG_SMALLX10=11]="BIG_SMALLX10",e[e.BIG_SMALL_TOP=12]="BIG_SMALL_TOP",e[e.BIG_SMALL_BOTTOM=13]="BIG_SMALL_BOTTOM"}(G||(G={})),function(e){e[e.SCREEN=1]="SCREEN",e[e.PLATOFORM=2]="PLATOFORM",e[e.PLATFORM_COVER=3]="PLATFORM_COVER",e[e.SPEAKER=4]="SPEAKER"}(V||(V={})),function(e){e.LOGIN="login",e.LOGOUT="logout",e.CONFERENCE_JOIN="conferenceJoin",e.CONFERENCE_LEAVE="conferenceLeave",e.CONFERENCE_PARTICIPANT_UPDATE="conferenceParticipantUpdate",e.CONFERENCE_PARTICIPANT_LEFT="conferenceParticipantLeft",e.REQUEST_VIDEO_SIZE_CHANGE="requestVideoSizeChange",e.REQUEST_VIDEO_SIZE_RESULT="requestVideoSizeChange",e.MESSAGE_RECEIVE="messageReceive",e.SOCKET_STATE_CHANGED="socketStateChange",e.SOCKET_STATE_CHANGE="socketStateChange",e.SET_MERGE_RESULT="setMergeResult",e.SET_INTELLEGENCE_MERGE_RESULT="setIntellegenceMergeResult",e.SET_MERGE_MODE_RESULT="setMergeModeResult",e.SET_INTELLEGENCE_MERGE_MODE_RESULT="setIntellegenceMergeModeResult",e.START_REMOTE_RECORD_RESULT="startRemoteRecordResult",e.STOP_REMOTE_RECORD_RESULT="stopRemoteRecordResult",e.START_LOCAL_RECORD_RESULT="startLocalRecordResult",e.STOP_LOCAL_RECORD_RESULT="stopLocalRecordResult",e.RECORD_DELIVERY_JOIN="recordDeliveryJoin",e.CLIENT_STATE_CHANGE="clientStateChange",e.CONFERENCE_DESTROY="conferenceDestroy",e.QUERY="query",e.ERROR="error"}(x||(x={})),function(e){e.LOGIN_PASSWORD_ERROR="loginPasswordError",e.REQUEST_VIDEO_SIZE_ERROR="requestVideoSizeError",e.CONFERENCE_PASSWORD_ERROR="conferencePasswordError"}(B||(B={}));var W,H,Y,J,X=function(){function e(t){this._config=s({},e.DEFAULT_VIDEO_LAYOUT_CONFIG),this._client=t,this._listenerList=[],this._destroy=this._init()}return e.prototype.setMergeMode=function(t){var n=this;return e.reporter.info("invoke setMergeMode\tmode: %s",t),d(t)&&d(F[t])?(this._client._sendSignalling("setmergemode "+t,{isPlainText:!0}).then(),new Promise((function(e,t){var r=n._client.addEventListener(x.SET_MERGE_MODE_RESULT,(function(n,r){var o=n.message.result;h(o)?e(o):t(o),r()}));n._listenerList.push(r)}))):Promise.reject(new Error("mode is undefined or null or unknown value."))},e.prototype.setIntellegenceMergeMode=function(t,n,r){var o=this;return e.reporter.info("invoke setIntellegenceMergeMode\tintellegenceMode: %s\tscreenShareMode: %s\tparticipant: %s",t,n,r),d(t)&&d(G[t])?d(n)&&d(V)?d(r)?(this._client._sendSignalling("setmergemode_i "+t+" "+n+" "+r.id0,{isPlainText:!0}),new Promise((function(e,t){var n=o._client.addEventListener(x.SET_INTELLEGENCE_MERGE_MODE_RESULT,(function(n,r){var o=n.message.result;h(o)?e(o):t(o),r()}));o._listenerList.push(n)}))):Promise.reject(new Error("participant is undefined or null or unknown value.")):Promise.reject(new Error("screenShareMode is undefined or null or unknown value.")):Promise.reject(new Error("intellegenceMode is undefined or null or unknown value."))},e.prototype.setMergeModeEx=function(t){var n=this;if(e.reporter.info("invoke setMergeModeEx\tmode: %s",t),!d(t)||!d(F[t]))return Promise.reject(new Error("mode is undefined or null or unknown value."));var r={cmd:"configmediamerge",val:{MergeMode:t}};return this._client._sendSignalling(r).then(),new Promise((function(e,t){var r=n._client.addEventListener(x.SET_MERGE_MODE_RESULT,(function(n,r){var o=n.message.result;h(o)?e(o):t(o),r()}));n._listenerList.push(r)}))},e.prototype.setIntellegenceMergeModeEx=function(t,n,r){var o=this;if(e.reporter.info("invoke setIntellegenceMergeMode\tintellegenceMode: %s\tscreenShareMode: %s\tparticipant: %s",t,n,r),!d(t)||!d(G[t]))return Promise.reject(new Error("intellegenceMode is undefined or null or unknown value."));if(!d(n)||!d(V))return Promise.reject(new Error("screenShareMode is undefined or null or unknown value."));if(!d(r))return Promise.reject(new Error("participant is undefined or null or unknown value."));var i={cmd:"configmediamerge",val:{MergeMode:F.INTELLEGNCE,MergeModeI:t,ScsMode:n}};return this._client._sendSignalling(i).then(),new Promise((function(e,t){var n=o._client.addEventListener(x.SET_INTELLEGENCE_MERGE_MODE_RESULT,(function(n,r){var o=n.message.result;h(o)?e(o):t(o),r()}));o._listenerList.push(n)}))},e.prototype.destroy=function(){this._destroy(),this._listenerList.forEach((function(e){return e()}))},e.prototype._init=function(){return function(){}},e.DEFAULT_VIDEO_LAYOUT_CONFIG={mergeMode:F.SCREEN,intellegenceMergeMode:G.RECT_LAYOUT,screenShareMode:V.SCREEN},e.reporter=new L("VideoLayout"),e}(),q="ABCDEFGHIJKLMNOPQRSTUVWXYZ",Q="abcdefghijklmnopqrstuvwxyz",z="0123456789";function Z(e,t){if(e<0||e>65536)return null;for(var n="",r=(t=t||""+q+Q+z).length,o=e;o--;)n+=t[Math.floor(1e10*Math.random())%r];return n}!function(e){e[e.INIT=0]="INIT",e[e.REMOTE_RECORDING=1]="REMOTE_RECORDING",e[e.LOCAL_RECORDING=2]="LOCAL_RECORDING"}(W||(W={})),function(e){e[e.INIT=-1]="INIT",e[e.NONE=0]="NONE",e[e.MIN=256]="MIN",e[e.SMALL=512]="SMALL",e[e.LARGE=768]="LARGE",e[e.MAX=1024]="MAX"}(H||(H={})),Y||(Y={}),J||(J={});var $,ee=function(e){function t(t){var n=e.call(this)||this;return n._state=W.INIT,n._client=t,n}return o(t,e),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},set:function(e){t.reporter.warning("attribute state is readonly\tnew value: %j",e)},enumerable:!1,configurable:!0}),t.prototype.startRemoteRecord=function(e){var n=this;t.reporter.info("invoke startRemoteRecord\toptions: %j",e);var r,o=v([[e,i.Object],[e.recordResolution,i.Undefined,i.Number],[e.frameRate,i.Undefined,i.Number],[e.mergeMode,i.Undefined,i.Number],[e.videoWidth,i.Undefined,i.Number],[e.videoHeight,i.Undefined,i.Number],[e.bitrate,i.Undefined,i.Number],[e.storage,i.Object],[e.storage.protocol,i.String],[e.fileName,i.Undefined,i.String],[e.remoteFileName,i.Undefined,i.String]]);if(this._state!==W.INIT)r=Promise.reject(new Error("current state is "+this._state+", not allow start remote record"));else if(m(o.accept))r=Promise.reject(o.error),t.reporter.info("%s %s\n%s",o.error.name,o.error.message,o.error.stack);else{this._state=W.REMOTE_RECORDING,e=s(s({},t.DEFAULT_REMOTE_RECORD_OPTIONS),e);var a={cmd:"startremoterecord",val:{param:JSON.stringify({MtcConfIsVideoKey:!0,VideoLevel:e.recordResolution,MergeFPS:e.frameRate,MergeMode:e.mergeMode,MergeWidth:e.videoWidth,MergeHeight:e.videoHeight,MergeBitrate:e.bitrate,FileName:e.fileName,FileKey:e.remoteFileName,Storage:{Protocol:e.storage.protocol},RemoteFileName:e.remoteFileName})}};r=new Promise((function(e,r){n._client._sendSignalling(a).then(),n._client.addEventListener(x.START_REMOTE_RECORD_RESULT,(function(o,i){h(o.message.result)?(t.reporter.info("start remote record success"),e()):(t.reporter.info("start remote record fail\n%j",o.message),r(),n._state=W.INIT),i()}))}))}return r},t.prototype.stopRemoteRecord=function(){var e,n=this;if(t.reporter.info("invoke stopRemoteRecord"),this._state!==W.REMOTE_RECORDING)e=Promise.reject(new Error("current state is "+this._state+", not allow stop remote record"));else{var r={cmd:"stopremoterecord"};e=new Promise((function(e,t){n._client._sendSignalling(r).then(),n._client.addEventListener(x.STOP_REMOTE_RECORD_RESULT,(function(r,o){h(r.message.result)?(e(),n._state=W.INIT):t(new Error("stop record fail")),o()}))}))}return e},t.DEFAULT_REMOTE_RECORD_OPTIONS={recordResolution:H.LARGE,frameRate:void 0,mergeMode:F.SCREEN,videoWidth:640,videoHeight:360,bitrate:void 0,storage:{protocol:null},fileName:void 0,remoteFileName:void 0},t.reporter=new L("WeChatMediaRecorder"),t}(P);!function(e){e.NUMBER_AND_LETTER="^[0-9A-Za-z]*$",e.ALL="^.*$"}($||($={}));var te={};function ne(e,t){var n=v([[e,i.String],[t,i.String]]);if(m(n.accept))throw n.error;return d(te[t])||(te[t]=new RegExp(t)),te[t].test(e)}var re,oe=function(e){function t(n,r){var o=e.call(this)||this;return o.socket=n,o._appKey=r,o.destinations=s({},t.DEFAULT_SOCKET_DESTINATIONS),o.clientInfo={clientType:"conference",confDeliveryInfo:{iceServers:[],pushUrl:null,pullUrl:null,instanceId:null},confNUmber:null,username:null},o._localStream=null,o._remoteStream=null,o._remoteStreamMap={},o._participantMap={},o._revoke=o._clientInit(),o.state=A.CLIENT_INIT,t.reporter.info("instance created. appKey: %j",r),o}return o(t,e),Object.defineProperty(t.prototype,"selfParticipant",{get:function(){return this._selfParticipant},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"participantMap",{get:function(){return this._participantMap},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},set:function(e){t.reporter.info("state changed. current state: %s",e),this._state=e,this.dispatchEventLite(x.CLIENT_STATE_CHANGE,{state:this._state})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"videoLayout",{get:function(){return this._videoLayout},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"recorder",{get:function(){return this._recorder},enumerable:!1,configurable:!0}),t.prototype.disableAudioOutput=function(){return this._remoteStream.disableAudio()},t.prototype.disableUploadAudioStream=function(){return this._localStream.disableAudio()},t.prototype.disableUploadVideoStream=function(){return this._localStream.disableVideo()},t.prototype.enableAudioOutput=function(){return this._remoteStream.enableAudio()},t.prototype.enableUploadAudioStream=function(){return this._localStream.enableAudio()},t.prototype.enableUploadVideoStream=function(){return this._localStream.enableVideo()},t.prototype.setAudioRoute=function(e){return t.reporter.info("invoke setAudioRoute.\troute: %j",e),this._remoteStream.setAudioOutput(e)},t.prototype.join=function(e,n,r){var o=this;void 0===r&&(r={}),t.reporter.info("invoke join.\tconfNumber: %s\tvideo: %s\tjoinParam: %j",e,n,r);var a,c=v([[e,i.String],[n,i.Boolean],[r,i.Object]]);if(c.accept)if(l(e))if(m(ne(e,$.ALL)))a=Promise.reject(new Error("conference number exist illegal character."));else if(e.length<=0||e.length>64)a=Promise.reject(new Error("conference number exceeds length."));else{if(l((r=s(s({},t.DEFAULT_JOIN_CONFERENCE_PARAM),r)).conferencePassword)||(r.conferencePassword=t.DEFAULT_CONFERENCE_PROPS.mtcConfPasswordKey),d(r.enableRecord)||(r.enableRecord=t.DEFAULT_CONFERENCE_PROPS.mtcConfReplayKey),m(ne(r.conferencePassword,$.NUMBER_AND_LETTER)))return Promise.reject(new Error("conference password exist illegal character."));if(r.conferencePassword.length<=0||r.conferencePassword.length>16)return Promise.reject(new Error("conference password exceeds length."));this._sendSignalling({cmd:"joinroom",val:{roomId:e,bVideo:!0,displayName:r.displayName||this.confProps.nickName||this.confProps.accountName,roomParm:JSON.stringify({MtcConfResolutionInfoKey:"1 144 150 272 450",MtcConfStateKey:15,MtcConfRoleKey:r.role,MtcConfPasswordKey:r.conferencePassword,MtcConfReplayKey:r.enableRecord,MtcConfCapacityKey:r.capacity}),subScreenShare:!0}}).then(),a=new Promise((function(e){o.addEventListener(x.CONFERENCE_JOIN,(function(){o.state=A.CONFERENCE_JOIN,e()}))}))}else a=Promise.reject(new Error("conference number not a string"));else a=Promise.reject(c.error);return a},t.prototype.leave=function(){var e=this;return t.reporter.info("invoke leave."),this._sendSignalling({cmd:"leave",val:{}}).then(),new Promise((function(t,n){e.addEventListener(x.CONFERENCE_LEAVE,(function(e,r){h(e.message.result)?t():n(),r()}))})).then((function(){return e._destroy()}))},t.prototype.login=function(e){var n=this;return void 0===e&&(e={}),t.reporter.info("invoke login\tconfProps: %j",e),l(e.accountName)||(e.accountName=Z(16)),l(e.nickName)||(e.nickName=e.accountName),this.confProps=s(s(s({},t.DEFAULT_CONFERENCE_PROPS),e),{appKey:this._appKey,isStart:1}),L.addReferKey("clientInfoId",[this.confProps.nickName,this.confProps.accountName]).then(),this.clientInfo.username=this.confProps.accountName,this.socket.sendTo(this.confProps,this.destinations.createConference).then(),new Promise((function(e,t){n.addEventListener(x.LOGIN,(function(n){return n.message.result?e():t()}))}))},t.prototype.requestVideo=function(e,t){return Promise.resolve(void 0)},t.prototype.sendMessage=function(e,n,r){t.reporter.info("invoke sendMessage.\ttype: %s\tcontent: %j\ttoUserId: %s",e,n,r);var o=l(n)?n:JSON.stringify(n),i=d(r)?l(r)?r:r.id0:void 0;return this._sendSignalling("sendtext "+JSON.stringify({type:e,text:o})+(d(i)?" "+i:""),{isPlainText:!0})},t.prototype.start=function(e,n,r){var o=this;void 0===r&&(r={}),t.reporter.info("invoke start.\tconfNumber: %s\tvideo: %s\tjoinParam: %j",e,n,r);var a,c=v([[e,i.String],[n,i.Boolean]]);if(c.accept)if(l(e))if(m(ne(e,$.ALL)))a=Promise.reject(new Error("conference number exist illegal character."));else if(e.length<=0||e.length>64)a=Promise.reject(new Error("conference number exceeds length."));else{if(l((r=s(s({},t.DEFAULT_JOIN_CONFERENCE_PARAM),r)).conferencePassword)||(r.conferencePassword=t.DEFAULT_CONFERENCE_PROPS.mtcConfPasswordKey),d(r.enableRecord)||(r.enableRecord=t.DEFAULT_CONFERENCE_PROPS.mtcConfReplayKey),m(ne(r.conferencePassword,$.NUMBER_AND_LETTER)))return Promise.reject(new Error("conference password exist illegal character."));if(r.conferencePassword.length<=0||r.conferencePassword.length>16)return Promise.reject(new Error("conference password exceeds length."));this._sendSignalling({cmd:"joinroom",val:{roomId:e,bVideo:!0,displayName:r.displayName||this.confProps.nickName||this.confProps.accountName,roomParm:JSON.stringify({MtcConfResolutionInfoKey:"1 144 150 272 450",MtcConfStateKey:15,MtcConfReplayKey:r.enableRecord,MtcConfPasswordKey:r.conferencePassword,MtcConfRoleKey:r.role,MtcConfCapacityKey:r.capacity}),subScreenShare:!0}}).then(),a=new Promise((function(e){o.addEventListener(x.CONFERENCE_JOIN,(function(){o._sendSignalling("subscribe 0x1f",{isPlainText:!0}).then(),o.state=A.CONFERENCE_JOIN,e()}))}))}else a=Promise.reject(new Error("conference number not a string"));else a=Promise.reject(c.error);return a},t.prototype.startCameraVideo=function(){return t.reporter.info("invoke startCameraVideo"),this._localStream=new U(this.pageTarget,this.clientInfo.username,{pushUrl:this.clientInfo.confDeliveryInfo.pushUrl}),Promise.resolve(this._localStream)},t.prototype.startVideo=function(){return t.reporter.info("invoke startVideo."),this._remoteStream=new j(this.pageTarget,"remote",{src:this.clientInfo.confDeliveryInfo.pullUrl}),Promise.resolve(this._remoteStream)},t.prototype.stop=function(){var e=this;return t.reporter.info("invoke stop."),this._sendSignalling({cmd:"closeconference"}).then(),new Promise((function(t,n){e.addEventListener(x.CONFERENCE_DESTROY,(function(r){r.message.result?e._destroy().then((function(){return t()})).catch((function(e){return n(e)})):n()}))}))},t.prototype.switchCamera=function(e){return t.reporter.info("invoke switchCamera.\tconstraints: %j",e),d(e)?l(e.facingMode)?this._localStream.switchCamera("user"===e.facingMode?"front":"back"):Promise.reject(new Error("constraints.facingMode not a string.")):Promise.reject(new Error("constraints is undefined or null."))},t.prototype.query=function(e){var n=this;t.reporter.info("invoke query\tchannelId: %s",e);var r,o=Number.parseInt(Z(8,z),10);return l(e)?(this._sendSignalling({cmd:"queryroom",val:{roomId:e,cookie:o}}).then(),r=new Promise((function(r,i){n.addEventListener(x.QUERY,(function(n,s){n.message.cookie===o&&(h(n.message.result)?(t.reporter.info("query channelId %s success\tmemberList: %j",e,n.message.result,n.message.memberList),r({number:e,queryInfo:{clientCount:n.message.memberList.length,members:n.message.memberList}})):(t.reporter.info("query channelId %s fail\treason: %s\tdetail: %s",e,n.message.reason,n.message.reasonDetail),i(new Error