@realsee/live 0.6.3 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,29 +1,27 @@
1
- "use strict";var Ut=Object.defineProperty;var Bt=(t,s,e)=>s in t?Ut(t,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[s]=e;var o=(t,s,e)=>(Bt(t,typeof s!="symbol"?s+"":s,e),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Wt=require("@realsee/jsbridge-x"),Ne=require("trtc-js-sdk"),X=require("amazon-chime-sdk-js"),L=require("react"),ae=Symbol("$$REALSEE_LIVE_EVENT$$");function me(t){return t[ae]||(t[ae]={}),t[ae]}function Ft(t){t[ae]||delete t[ae]}class ce{hasListener(s){const e=me(this);return e&&e[s]&&e[s].length>0}on(s,e,n){const i=me(this);return i[s]||(i[s]=[]),i[s].push([e,n||!1]),()=>this.off(s,e)}once(s,e){return this.on(s,e,!0)}off(s,e){if(s===void 0){Ft(this);return}const n=me(this);if(n[s]||(n[s]=[]),e===void 0){n[s].length=0;return}let i=0;for(;i<n[s].length&&n[s][i][0]!==e;i++);i<n[s].length&&n[s].splice(i,1)}emit(s,...e){let n=!1;const a=me(this)[s]||[];for(let u of a.slice()){const[f,v=!1]=u,h=f(...e);v&&this.off(s,f),h===!1&&(n=!0)}return n}}class be extends ce{}var ee=(t=>(t.RealseeBrowserRTC="RealseeBrowserRTC",t.RealseeVRWebViewRTC="RealseeVRWebViewRTC",t.RealseeBrowserChimeRTC="RealseeBrowserChimeRTC",t))(ee||{}),Ue=(t=>(t.RealseeXTRTC="trtc",t.RealseeXChimeRTC="chime",t))(Ue||{});const qt=()=>{const t=new Date,s=t.getFullYear(),e=(t.getMonth()+1).toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),i=t.getHours().toString().padStart(2,"0"),a=t.getMinutes().toString().padStart(2,"0"),u=t.getSeconds().toString().padStart(2,"0"),f=t.getMilliseconds();return`[${s}-${e}-${n} ${i}:${a}:${u}.${f}]`},Ce=(t,s=[])=>{switch(s.unshift(`Realsee Live ${qt()} <${t}> `),t){case"INFO":return console.info(...s);case"ERROR":return console.error(...s);case"WARN":return console.warn(...s);default:return console.log(...s)}},Kt=(...t)=>Ce("LOG",t),Yt=(...t)=>Ce("INFO",t),Gt=(...t)=>Ce("ERROR",t),Ht=(...t)=>Ce("WARN",t),Jt={log:Kt,info:Yt,error:Gt,warn:Ht},A=Jt;function Z(){return((1+Math.random())*65536|0).toString(16).substring(1)}function ve(){return(Z()+Z()+"-"+Z()+"-4"+Z().substr(0,3)+"-"+Z()+"-"+Z()+Z()+Z()).toLowerCase()}class Me extends be{constructor(e){super();o(this,"type",ee.RealseeBrowserRTC);o(this,"joined",!1);o(this,"micro",!1);o(this,"voiceId","");o(this,"_getVoiceSign",()=>{throw new Error("方法 getVoiceSign 未实现")});o(this,"_autoPlayConfirm");o(this,"checkRequirement",()=>Ne.checkSystemRequirements());o(this,"$dom",document.createElement("div"));o(this,"_trtc",{client:null,stream:null});o(this,"join",async e=>{var a;this.emit("joinWillStart");const n=await this._getVoiceSign({voiceId:e.voiceId,roomId:e.roomId,userId:e.userId});this._trtc.client=Ne.createClient({mode:"rtc",...n,enableAutoPlayDialog:typeof this._autoPlayConfirm!="function"}),(a=this._trtc.client)==null||a.enableAudioVolumeEvaluation(),this._registerRtcEvent();let i=await new Promise(u=>{var f;(f=this._trtc.client)==null||f.join({roomId:Number(e.voiceId)}).then(()=>u(!0)).catch(()=>u(!1))});return this.joined=i,i?(this._trtc.stream=Ne.createStream({userId:n.userId,audio:!0,video:!1}),i=await new Promise(u=>{var f;(f=this._trtc.stream)==null||f.initialize().then(()=>u(!0)).catch(()=>u(!1))}),i=await new Promise(u=>{var f;(f=this._trtc.client)==null||f.publish(this._trtc.stream).then(()=>u(!0)).catch(()=>u(!1))}),this.joined=i,this.joined&&this.emit("joined"),i):!1});o(this,"_handleStreamAdded",e=>{var i;const n=e.stream;console.log("远端流增加: "+n.getId()),(i=this._trtc.client)==null||i.subscribe(n)});o(this,"_handleStreamSubscribed",e=>{const n=e.stream;console.log("远端流订阅成功:"+n.getId());const a=`rs-rtc-remote_stream-${n.getId()}`,u=document.createElement("div");u.id=a,this.$dom.appendChild(u),typeof this._autoPlayConfirm=="function"?(n.play(a).catch(f=>{}),n.on("error",f=>{if(f.getCode()===16451){const h=()=>n.resume();this._autoPlayConfirm({onConfirm:h})}})):n.play(a)});this._getVoiceSign=e.getVoiceSign,this._autoPlayConfirm=e.autoPlayConfirm,this._initParentDom()}_initParentDom(){this.$dom.id=`rs-rtc-${ve()}`,this.$dom.style.display="none",document.body.appendChild(this.$dom)}quit(){return new Promise(async e=>{var n,i;this.joined=!1,this._trtc.stream&&(await((n=this._trtc.client)==null?void 0:n.unpublish(this._trtc.stream)),this._trtc.stream.stop(),this._trtc.stream.close(),this._trtc.stream=null),(i=this._trtc.client)==null||i.leave().then(()=>this._trtc.client=null).then(()=>e(!0)).catch(()=>e(!1)),e(!0)})}detectMicro(){return new Promise(e=>{const n={audio:!0,video:!1};try{navigator.mediaDevices.getUserMedia(n).then(()=>e(!0)).catch(i=>{A.error(i.message),e(!1)})}catch(i){console.error(i),e(!1)}})}toggleMicro(e){var n,i,a,u;return Promise.resolve((e?(i=(n=this._trtc)==null?void 0:n.stream)==null?void 0:i.unmuteAudio():(u=(a=this._trtc)==null?void 0:a.stream)==null?void 0:u.muteAudio())||!1)}shock(){throw new Error("Method not implemented.")}_registerRtcEvent(){var e,n,i,a;(e=this._trtc.client)==null||e.on("stream-added",this._handleStreamAdded),(n=this._trtc.client)==null||n.on("stream-subscribed",this._handleStreamSubscribed),(i=this._trtc.client)==null||i.on("audio-volume",u=>this.emit("userVolumes",u.result.map(({userId:f,audioVolume:v})=>({userId:f,audioVolume:v})))),(a=this._trtc.client)==null||a.on("error",u=>this.emit("error",u))}}class Ve extends be{constructor(e){super();o(this,"type",ee.RealseeBrowserChimeRTC);o(this,"joined",!1);o(this,"micro",!1);o(this,"voiceId","");o(this,"userId","");o(this,"logger");o(this,"deviceController");o(this,"meetingSession");o(this,"audioInput");o(this,"audioOutput");o(this,"deviceChangeObserver",{});o(this,"audioVideoObserver",{});o(this,"_getVoiceSign",()=>{throw new Error("方法 getVoiceSign 未实现")});o(this,"$dom",document.createElement("div"));o(this,"$audio",document.createElement("audio"));o(this,"_initDom",()=>{this.$audio.id=`rs-rtc-${ve()}`,this.$dom.id=`rs-rtc-${ve()}`,this.$dom.appendChild(this.$audio),document.body.appendChild(this.$dom)});o(this,"initObservers",()=>{this.deviceChangeObserver={audioInputsChanged:e=>{this.logger.info(`audioInputsChanged ${typeof e}`),e==null||e.forEach(n=>{this.logger.info(`Device ID: ${n.deviceId} Microphone: ${n.label}`)})},audioOutputsChanged:e=>{this.logger.info(`audioOutputsChanged ${typeof e}`),e==null||e.forEach(n=>{this.logger.info(`Device ID: ${n.deviceId} Speaker: ${n.label}`)})},audioInputMuteStateChanged:(e,n)=>{this.logger.info(`Device ${e.toString()} ${n?"is muted in hardware":"is not muted"}`)}},this.audioVideoObserver={audioVideoDidStart:()=>{this.logger.info("Started")},audioVideoDidStop:e=>{this.logger.info(`Stopped with a session status code: ${e.statusCode()}`)},audioVideoDidStartConnecting:e=>{e&&this.logger.info("Attempting to reconnect")}}});o(this,"_registerRtcEvent",()=>{var n,i,a,u,f,v;const e=((a=(i=(n=this.meetingSession)==null?void 0:n.configuration)==null?void 0:i.credentials)==null?void 0:a.attendeeId)||"";if(e){const h=new Map,_=()=>{const E=[];return h.forEach((S,m)=>{E.push({userId:S.userId,volume:S.muted||S.signalStrength===0||!Boolean(S.volume)?0:S.volume})}),E};(u=this.meetingSession)==null||u.audioVideo.realtimeSubscribeToAttendeeIdPresence((E,S,m)=>{var D;if(!S){h.delete(E),this.emit("userVolumes",_());return}(D=this.meetingSession)==null||D.audioVideo.realtimeSubscribeToVolumeIndicator(E,(V,k,H,J)=>{new X.DefaultModality(V).base()===V&&(h.set(V,{userId:m||V,volume:k,muted:H,signalStrength:J}),this.emit("userVolumes",_()))})}),(f=this.meetingSession)==null||f.audioVideo.realtimeSubscribeToVolumeIndicator(e,(E,S,m,D)=>{new X.DefaultModality(E).base()===E&&D!==null&&D!==1&&this.emit("weakNetwork")}),(v=this.meetingSession)==null||v.audioVideo.realtimeSubscribeToFatalError(E=>this.emit("error",E))}});this._getVoiceSign=e.getVoiceSign,this._initDom(),this.logger=new X.ConsoleLogger("WebRTCLogger",e.logLevel||X.LogLevel.INFO),this.deviceController=new X.DefaultDeviceController(this.logger),this.initObservers()}async join(e){return new Promise(async(n,i)=>{var a;this.emit("joinWillStart");try{const{sdkAppId:u,userId:f,roomId:v,userSig:h}=await this._getVoiceSign({...e,roomId:e.roomId||0});this.userId=f;const{attendence:_,vendor_wrapper:E}=JSON.parse(decodeURIComponent(h)),S=new X.MeetingSessionConfiguration({Meeting:E},{Attendee:{ExternalUserId:_.external_user_id,AttendeeId:_.attendee_id,JoinToken:_.join_token}});this.meetingSession=new X.DefaultMeetingSession(S,this.logger,this.deviceController),this._registerRtcEvent(),this.meetingSession.audioVideo.addDeviceChangeObserver(this.deviceChangeObserver),this.meetingSession.audioVideo.addObserver(this.audioVideoObserver),this.meetingSession.audioVideo.bindAudioElement(this.$audio);const m={audioVideoDidStart:()=>{var k;(k=this.meetingSession)==null||k.audioVideo.realtimeMuteLocalAudio(),this.joined=!0,this.emit("joined"),n(!0)},audioVideoDidStop:()=>{this.joined=!1,n(!1)}};this.meetingSession.audioVideo.addObserver(m),this.meetingSession.audioVideo.setDeviceLabelTrigger(async()=>await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}));const V=((a=(await this.meetingSession.audioVideo.listAudioInputDevices())[0])==null?void 0:a.deviceId)||"default";await this.meetingSession.audioVideo.startAudioInput(V),this.meetingSession.audioVideo.start()}catch(u){this.emit("error",u),this.logger.error(u.message),n(!1)}})}quit(){return this.joined?new Promise((e,n)=>{var a,u;this.joined=!1;const i={audioVideoDidStop:async f=>{var h;const v=f.statusCode();(h=this.meetingSession)==null||h.deviceController.destroy(),v===X.MeetingSessionStatusCode.Left?(this.logger.info("You left the session"),e(!0)):(this.logger.info(`Stopped with a session status code: ${v}`),e(!0))}};(a=this.meetingSession)==null||a.audioVideo.addObserver(i),(u=this.meetingSession)==null||u.audioVideo.stop()}):Promise.resolve(!0)}async detectMicro(){return new Promise(e=>{const n={audio:!0,video:!1};try{navigator.mediaDevices.getUserMedia(n).then(()=>e(!0)).catch(()=>e(!1))}catch(i){this.logger.error(i.message),e(!1)}})}async toggleMicro(e){var i,a,u;e?(i=this.meetingSession)==null||i.audioVideo.realtimeUnmuteLocalAudio():(a=this.meetingSession)==null||a.audioVideo.realtimeMuteLocalAudio();const n=(u=this.meetingSession)==null?void 0:u.audioVideo.realtimeIsLocalAudioMuted();return n!==void 0?e!==n:!1}shock(){throw new Error("Method not implemented.")}}var Be=(t=>(t[t.Success=0]="Success",t[t.Failure=1]="Failure",t[t.ReJoin=2]="ReJoin",t[t.NoMicroPermission=3]="NoMicroPermission",t))(Be||{});class $e extends be{constructor({jsBridge:e,getVoiceSign:n}){super();o(this,"type",ee.RealseeVRWebViewRTC);o(this,"joined",!1);o(this,"micro",!1);o(this,"voiceId","");o(this,"options");this.options={jsBridge:e,getVoiceSign:n},this.jsBridge.webViewType!=="WxMiniProgramWebView"&&this.jsBridge.callAndListen("live/userVolumes",i=>{this.emit("userVolumes",i)}),this.jsBridge.callAndListen("live/weakNetwork",i=>{i&&this.emit("weakNetwork")})}get jsBridge(){return this.options.jsBridge}async join(e){try{this.emit("joinWillStart");const{sdkAppId:n,userId:i,userSig:a}=await this.options.getVoiceSign(e);if(!(Boolean(n)&&Boolean(i)&&Boolean(a)))return this.emit("error",new Error("加入房间失败:rtc 签名请求异常")),this.joined=!1,this.joined;this.type=e.type;const[u,f]=await this.jsBridge.callAndBackfeed(`live/join?sdkAppID=${n}&userID=${i}&roomID=${Number(e.voiceId)}&userSig=${a}`);return u?u.code===Be.Success?(this.emit("joined"),this.joined=!0):(this.emit("error",u),this.joined=!1):(this.emit("error",f||new Error("加入房间失败:未知异常。")),this.joined=!1),this.joined}catch(n){return this.emit("error",new Error("加入房间失败:"+n.message)),this.joined=!1,this.joined}}async quit(){const[e,n]=await this.jsBridge.callAndBackfeed("live/quit");return e===null&&this.emit("error",n||new Error("退出房间失败:未知异常。")),this.joined=!1,!!e}async detectMicro(){const[e,n]=await this.jsBridge.detectMicro();return e===null?(this.emit("error",n||new Error("麦克风监测异常!")),!1):e}async toggleMicro(e){const[n,i]=await this.jsBridge.callAndBackfeed(`live/toggleMicro?flag=${e?1:0}`);return n===null?(this.emit("error",i||new Error("麦克风监测异常!")),!1):(this.micro=n,n)}shock(){this.jsBridge.shock(1)}}var U=(t=>(t.SelfUserInfo="SELF_USER_INFO",t.RoomInfo="ROOM_INFO",t.RTCInfo="RTC_INFO",t.UserList="USER_LIST",t.BuiltinMsg="BUILTIN_MSG",t.CustomEvent="CUSTOM_EVENT",t.KeyframeSync="KEYFRAME_SYNC",t.UserKickOut="USER_KICK_OUT",t))(U||{}),F=(t=>(t.UserChange="user_change",t.RoomChange="room_change",t))(F||{}),K=(t=>(t.UserMicroStatus="change_micro_status",t.UserMicroStatusSync="sync_micro_status",t.UserPermission="change_permission",t.UserStatus="change_status",t.UserInfo="change_info",t.RoomClose="close",t))(K||{}),Q=(t=>(t.OPEN="OPEN",t.CLOSE="CLOSE",t))(Q||{});function zt(t){try{const s=JSON.parse(t),e={code:s.code,message:s.message,command:s.command,roomCode:s.room_code,appID:s.app_id,requestId:s.request_id,frontRequestId:s.front_request_id,triggerUserID:s.trigger_user_id,data:s.data||{}},n=Object.keys(e).filter(i=>e[i]===void 0);return n.length>0&&console.warn(`推送数据格式异常:${n.join(" ")} 值不存在!`),e}catch(s){return!1}}var $=(t=>(t[t.NOTINITIALIZED=-1]="NOTINITIALIZED",t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED",t))($||{}),ft=(t=>(t[t.Normal=0]="Normal",t[t.Removed=1]="Removed",t[t.Replaced=2]="Replaced",t))(ft||{}),dt=(t=>(t.WAIT_ENTER="WAIT_ENTER",t.ONLINE="ONLINE",t.LEAVE="LEAVE",t.KICK_OUT="KICK_OUT",t.BE_REPLACE="BE_REPLACE",t.EXCEPTION="EXCEPTION",t))(dt||{}),pe=(t=>(t[t.NOTINITIALIZED=-1]="NOTINITIALIZED",t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSING=2]="CLOSING",t[t.CLOSED=3]="CLOSED",t))(pe||{}),ht=(t=>(t.Error="Error",t.Close="Close",t.MicroAuth="MicroAuth",t.DuplicateConnect="DuplicateConnect",t.IllegalURL="IllegalURL",t.Unknown="Unknown",t.IllegalArgs="IllegalArgs",t))(ht||{}),_t=(t=>(t.Err_1000="CLOSE_NORMAL",t.Err_1001="CLOSE_GOING_AWAY",t.Err_1002="CLOSE_PROTOCOL_ERROR",t.Err_1003="CLOSE_UNSUPPORTED",t.Err_1006="CLOSE_ABNORMAL",t.Err_1007="Unsupported Data",t.Err_1008="Policy Violation",t.Err_1009="CLOSE_TOO_LARGE",t.Err_unknown="unknown",t))(_t||{});function gt(t){switch(t){case 1e3:return"CLOSE_NORMAL";case 1001:return"CLOSE_GOING_AWAY";case 1002:return"CLOSE_PROTOCOL_ERROR";case 1003:return"CLOSE_UNSUPPORTED";case 1006:return"CLOSE_ABNORMAL";case 1007:return"Unsupported Data";case 1008:return"Policy Violation";case 1009:return"CLOSE_TOO_LARGE"}return"unknown"}function Xt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var mt={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.LogLevel=void 0;var 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.OFF=4]="OFF"})(s=t.LogLevel||(t.LogLevel={})),t.default=s})(mt);const ot=Xt(mt);function Zt(t,s={}){const e=t.indexOf("?")!==-1,n=Object.keys(s).reduce((i,a,u)=>`${i}${u===0&&!e?"?":"&"}${a}=${s[a]}`,"");return t+n}const ue=globalThis.navigator.userAgent,Qt=/android/gi.test(ue),er=/iPhone|iPad\s+OS/gi.test(ue),tr=/MicroMessenger/gi.test(ue)&&/miniProgram/gi.test(ue),rr=/realsee/gi.test(ue);function Ee(t){return Object.prototype.toString.call(t)==="[object Object]"}function ye(t,s){return t===s?!0:typeof t!=typeof s?!1:!!(Number.isNaN(t)&&Number.isNaN(s))}function nr(t,s){const e=Object.getOwnPropertyNames(t),n=Object.getOwnPropertyNames(s);if(e.length!==n.length)return!1;for(let i=0,a=e.length;i<a;i++){const u=e[i];if(!ye(t[u],s[u]))return!1}return!0}function ir(t,s){if(t.length!==s.length)return!1;for(let e=0,n=t.length;e<n;e++)if(!ye(t[e],s[e]))return!1;return!0}function sr(t,s){return ye(t,s)?!0:Ee(t)&&Ee(s)?nr(t,s):Array.isArray(t)&&Array.isArray(s)?ir(t,s):!1}function We(t,s){return ye(t,s)?!0:Ee(t)&&Ee(s)?ar(t,s):Array.isArray(t)&&Array.isArray(s)?or(t,s):!1}function or(t,s){if(t.length!==s.length)return!1;for(let e=0,n=t.length;e<n;e++)if(!We(t[e],s[e]))return!1;return!0}function ar(t,s){const e=Object.getOwnPropertyNames(t),n=Object.getOwnPropertyNames(s);if(e.length!==n.length)return!1;for(let i=0,a=e.length;i<a;i++){const u=e[i];if(!We(t[u],s[u]))return!1}return!0}function at(t,s,e={deep:!1}){return e.deep?We(t,s):sr(t,s)}class cr extends ce{constructor(e){super();o(this,"_realWebSocket");o(this,"_url");o(this,"_protocols");o(this,"_readyState",pe.NOTINITIALIZED);o(this,"_options",{timeout:1e4,shouldReconnect:(e,n)=>{if(!(e.code===1008||e.code===1011))return[0,3e3,1e4][n.attempts]},should1000Reconnect:!1,ignoreConnectivityEvents:!1,automaticOpen:!1});o(this,"_connectTimeout");o(this,"_attempts",0);o(this,"_reconnects",-1);o(this,"_reconnectWhenOnlineAgain",!1);o(this,"_explicitlyClosed",!1);o(this,"_pendingReconnect");o(this,"_connectivityEventsAttached",!1);o(this,"_heathCheckTimer");o(this,"_healthCheck",async()=>{this._realWebSocket&&this._realWebSocket.readyState!==this._readyState&&(this._readyState=this._realWebSocket.readyState,this._readyState===pe.CLOSING&&this.emit("closing")),await new Promise(e=>setTimeout(e,2e3)),this._heathCheckTimer=requestAnimationFrame(this._healthCheck)});o(this,"_clearHeathCheckIfNeed",()=>{this._heathCheckTimer&&(cancelAnimationFrame(this._heathCheckTimer),this._heathCheckTimer=void 0)});o(this,"_startHealthCheck",()=>{this._clearHeathCheckIfNeed(),this._heathCheckTimer=requestAnimationFrame(this._healthCheck)});o(this,"_stopHealthCheck",()=>{this._clearHeathCheckIfNeed()});o(this,"_clearPendingReconnectIfNeeded",()=>{this._pendingReconnect&&(clearTimeout(this._pendingReconnect),this._pendingReconnect=void 0)});o(this,"_online",e=>{this._reconnectWhenOnlineAgain&&(this._clearPendingReconnectIfNeeded(),this._reconnect(e))});o(this,"_offline",()=>{var e;this._reconnectWhenOnlineAgain=!0,(e=this._realWebSocket)==null||e.close(1e3,"offline")});o(this,"_detachConnectivityEvents",()=>{this._connectivityEventsAttached&&(globalThis==null||globalThis.removeEventListener("online",this._online),globalThis==null||globalThis.removeEventListener("offline",this._offline),this._connectivityEventsAttached=!1)});o(this,"_attachConnectivityEvents",()=>{this._connectivityEventsAttached||(globalThis==null||globalThis.addEventListener("online",this._online),globalThis==null||globalThis.addEventListener("offline",this._offline),this._connectivityEventsAttached=!0)});o(this,"send",e=>{var n,i,a;((n=this._realWebSocket)==null?void 0:n.readyState)===((i=this._realWebSocket)==null?void 0:i.OPEN)&&((a=this._realWebSocket)==null||a.send(e))});o(this,"close",(e,n)=>{var i;return typeof e!="number"&&(n=e,e=1e3),this._clearPendingReconnectIfNeeded(),this._reconnectWhenOnlineAgain=!1,this._explicitlyClosed=!0,this._detachConnectivityEvents(),(i=this._realWebSocket)==null?void 0:i.close(e,n)});o(this,"open",e=>{var n,i;e&&(this._url=e),((n=this._realWebSocket)==null?void 0:n.readyState)!==WebSocket.OPEN&&((i=this._realWebSocket)==null?void 0:i.readyState)!==WebSocket.CONNECTING&&(this._clearPendingReconnectIfNeeded(),this._reconnectWhenOnlineAgain=!1,this._explicitlyClosed=!1,this._createWebSocket())});o(this,"_createWebSocket",()=>{var i,a,u;const e=typeof this._url=="string"?this._url:(i=this._url)==null?void 0:i.call(this,this);if(!e)return;this._pendingReconnect=void 0,this._removeWebSocketEvent(),this._realWebSocket=new WebSocket(e,this._protocols||void 0),this._attempts=this._attempts+1,this.emit("connecting",new CustomEvent("connecting",{detail:{attempts:this._attempts,reconnects:this._reconnects}}));const n=()=>{this._connectTimeout=void 0,this._detachConnectivityEvents(),this.emit("timeout",new CustomEvent("connecting",{detail:{attempts:this._attempts,reconnects:this._reconnects}}))};this._connectTimeout=setTimeout(n,(a=this._options)==null?void 0:a.timeout),this._dispatchWebSocketEvent(),(u=this._options)!=null&&u.ignoreConnectivityEvents||this._attachConnectivityEvents()});o(this,"_removeWebSocketEvent",()=>{var e,n,i,a;(e=this._realWebSocket)==null||e.removeEventListener("open",this._webSocketOpenHandler),(n=this._realWebSocket)==null||n.removeEventListener("close",this._webSocketCloseHandler),(i=this._realWebSocket)==null||i.removeEventListener("error",this._webSocketErrorHandler),(a=this._realWebSocket)==null||a.removeEventListener("message",this._webSocketMessageHandler)});o(this,"_dispatchWebSocketEvent",()=>{var e,n,i,a;(e=this._realWebSocket)==null||e.addEventListener("open",this._webSocketOpenHandler),(n=this._realWebSocket)==null||n.addEventListener("close",this._webSocketCloseHandler),(i=this._realWebSocket)==null||i.addEventListener("error",this._webSocketErrorHandler),(a=this._realWebSocket)==null||a.addEventListener("message",this._webSocketMessageHandler)});o(this,"_webSocketOpenHandler",e=>{this._connectTimeout&&(clearTimeout(this._connectTimeout),this._connectTimeout=void 0);const n=++this._reconnects,i=this._attempts;return this._attempts=0,this._reconnectWhenOnlineAgain=!1,this._startHealthCheck(),this.emit("open",Object.assign(e,{detail:{reconnects:n,attempts:i}}))});o(this,"_webSocketCloseHandler",e=>(this._reconnect(e),this._stopHealthCheck(),this.emit("close",e)));o(this,"_webSocketErrorHandler",e=>this.emit("error",new CustomEvent("error",{detail:{error:e}})));o(this,"_webSocketMessageHandler",e=>this.emit("message",e));e&&this.setOptions(e),this._startHealthCheck()}get attempts(){return this._attempts}setOptions(e){if(!e)return;this._url=e.url,this._protocols=e.protocols;const n=Object.assign(this._options,e.robustOptions||{});if(typeof(n==null?void 0:n.timeout)!="number")throw new Error("timeout must be the number of milliseconds to timeout a connection attempt");if(typeof(n==null?void 0:n.shouldReconnect)!="function")throw new Error("shouldReconnect must be a function that returns the number of milliseconds to wait for a reconnect attempt, or null or undefined to not reconnect.");this._options=n,this._options.automaticOpen&&this._createWebSocket()}_reconnect(e){var i,a,u,f;if(!((i=this._options)!=null&&i.should1000Reconnect)&&e.code===1e3||this._explicitlyClosed){this._attempts=0;return}if(((a=globalThis==null?void 0:globalThis.navigator)==null?void 0:a.onLine)===!1){this._reconnectWhenOnlineAgain=!0;return}const n=(f=(u=this._options)==null?void 0:u.shouldReconnect)==null?void 0:f.call(u,e,this);typeof n=="number"&&(this._pendingReconnect=setTimeout(this._createWebSocket,n))}}class ur extends ce{constructor(){super();o(this,"_ws",new cr({url:"",robustOptions:{timeout:18e4}}));o(this,"_state",$.NOTINITIALIZED);o(this,"_addWebSocketEventListeners",()=>{this._ws.on("close",this._handleCloseEvent),this._ws.on("closing",this._handleClosingEvent),this._ws.on("connecting",this._handleConnectingEvent),this._ws.on("error",this._handleErrorEvent),this._ws.on("message",this._handleMessageEvent),this._ws.on("open",this._handleOpenEvent),this._ws.on("timeout",this._handleTimeoutEvent)});o(this,"_removeWebSocketEventListeners",()=>{this._ws.off("close",this._handleCloseEvent),this._ws.off("closing",this._handleClosingEvent),this._ws.off("connecting",this._handleConnectingEvent),this._ws.off("error",this._handleErrorEvent),this._ws.off("message",this._handleMessageEvent),this._ws.off("open",this._handleOpenEvent),this._ws.off("timeout",this._handleTimeoutEvent)});o(this,"_handleCloseEvent",e=>{A.info(`live room closed bacause of ${e.code}-${e.reason||gt(e.code)}`),this.state=$.CLOSED});o(this,"_handleClosingEvent",()=>{var e;A.info("live room is closing, onLine:",(e=globalThis==null?void 0:globalThis.navigator)==null?void 0:e.onLine),this.state=$.CLOSED});o(this,"_handleConnectingEvent",()=>{A.info("live room is connecting"),this.state=$.CONNECTING});o(this,"_handleErrorEvent",e=>{A.error("live room error",e),this.state=$.CLOSED});o(this,"_handleMessageEvent",e=>{let n=(()=>{try{return JSON.parse(e.data)}catch(i){return e.data}})();this.emit("message",n)});o(this,"_handleOpenEvent",e=>{A.info("live room open",e.detail),this.state=$.OPEN,e.detail.reconnects>0&&this.emit("reconnected",e.detail)});o(this,"_handleTimeoutEvent",e=>{A.error("live room connect timeout!",e.detail),this.state=$.CLOSED});o(this,"dispose",async()=>(this._removeWebSocketEventListeners(),await this.close("live room close by controller disposed!")));o(this,"open",e=>this._ws.open(e));o(this,"close",(e,n)=>new Promise(i=>{this._ws.once("close",()=>i(!0)),this._ws.close(e,n)}));this._addWebSocketEventListeners()}set state(e){const n=JSON.parse(JSON.stringify(this._state));this._state=e,this.emit("stateChange",this.state,n)}get state(){return this._state}sendMessage(e=""){if(e==null||e==="")throw new Error("live message is empty!");if(this.state===$.OPEN)return this._ws.send(JSON.stringify(e));throw new Error("live has not yet been initialized!")}}const lr=t=>Promise.reject("unimplemented method GetVoiceSign"),Le=(t,s={},e=[])=>({command:t,front_request_id:ve(),data:{...s,to_user_ids:Array.isArray(e)?e:[e]}}),fr=()=>{var t,s;window!=null&&window.__Realsee_Live__&&((s=(t=window==null?void 0:window.__Realsee_Live__)==null?void 0:t.dispose)==null||s.call(t),window.__Realsee_Live__=null)};class dr extends ce{constructor(e){var n;super();o(this,"_options",{});o(this,"keyframes",new ce);o(this,"_buildInData",{keyframes:{}});o(this,"getFramesByKey",e=>this.snapshot[e]);o(this,"sendKeyframe",(e,n)=>{if(this.state!==$.OPEN)return!1;this._buildInData.keyframes={...this._buildInData.keyframes,[e]:n};const i=Le(U.KeyframeSync,this.snapshot);try{return this._controller.sendMessage(i),!0}catch(a){return A.error(a),!1}});o(this,"_controller",new ur);o(this,"_addLiveControllerEventListeners",()=>{this._controller.on("stateChange",this._handleStateChange),this._controller.on("message",this._handleMessage)});o(this,"_removeLiveControllerEventListeners",()=>{this._controller.off("stateChange",this._handleStateChange),this._controller.off("message",this._handleMessage)});o(this,"_handleStateChange",(e,n)=>this.emit("stateChange",e,n));o(this,"_handleMessage",async e=>{var n,i,a,u,f;if(typeof e=="object"){const{command:v,data:h={},frontRequestId:_,code:E,message:S}=e;if(E==="SUCCESS")switch(v){case U.SelfUserInfo:{const m=h;at(this.selfInfo,m,{deep:!0})||(this._buildInData.selfInfo=m,this.emit("selfInfoUpdate",this._buildInData.selfInfo,_));break}case U.RoomInfo:{const m=h;this._buildInData.roomInfo=Object.assign({},m),this.emit("readyKeyframeSync",m.last_frame||{});break}case U.RTCInfo:{const{voice_id:m,type:D}=h;if(this._buildInData.rtcInfo={voiceId:m,type:D},(n=this.$RTC)!=null&&n.joined)A.warn("已加入语音房间,无需重复加入!");else if(await((u=this.$RTC)==null?void 0:u.join({voiceId:m,userId:((i=this.selfInfo)==null?void 0:i.id)||"",roomId:(a=this.roomInfo)==null?void 0:a.info.room_code,type:D}))){const k=(f=this._options.initialMicroStatus)!=null?f:Q.OPEN;await this.toggleMicro(k===Q.OPEN)}else A.error("加入语音房间失败");break}case U.UserList:{const m=h;this._buildInData.userList=m,this.emit("userListUpdate",this.userList,_);break}case U.CustomEvent:{const m=h;this.emit("broadcast",m,_);break}case U.KeyframeSync:{const m=h,D=Object.keys(m).reduce((V,k)=>{if(at(m[k],this._buildInData.keyframes[k],{deep:!0}))return V;const H=[m[k],this._buildInData.keyframes[k],_],J=k;return this.keyframes.emit(J,...H),this._buildInData.keyframes[k]=m[k],V[k]=m[k],V},{});this.emit("keyframes",D,_);break}case U.BuiltinMsg:{const m=h;this.emit("builtinEvent",m),m.event_type===F.UserChange&&this.emit("userChange",m),m.event_type===F.RoomChange&&this.emit("roomChange",m),m.event_type===F.UserChange&&m.action===K.UserMicroStatus&&await this.toggleMicro(m.data.status===Q.OPEN),m.event_type===F.RoomChange&&m.action===K.RoomClose&&await this.exit();break}case U.UserKickOut:{this.emit("kickOut");break}default:console.warn("unknown command: ",v)}else this.emit("error",e)}});o(this,"_clearLiveData",()=>{this._buildInData={keyframes:{}}});o(this,"connect",async(e={})=>{var u,f,v,h;if(this._options.url=(f=(u=e.url)!=null?u:this._options.url)!=null?f:"",this._options.getTicket=(v=e.getTicket)!=null?v:this._options.getTicket,this._options.initialMicroStatus=(h=e.rtcMicStatus)!=null?h:this._options.initialMicroStatus,!/^ws(s):\/\//.test(this._options.url)||typeof this._options.getTicket!="function")return/^ws(s):\/\//.test(this._options.url)?typeof this._options.getTicket!="function"?new Error("getTicket muse be function"):!1:new Error("Illegal realsee live room link");const{force:n=!1}=e;if(this._options.rtc&&!await this._options.rtc.detectMicro())return new Error("Failed to obtain microphone authorization");const i=this.state;if(i===$.CONNECTING||i===$.OPEN)if(n)try{await this._controller.close("force close by connect")}catch(_){console.warn(_)}else return new Error("已有Live实例正在连接中,请勿重复连接!");this._clearLiveData();const a=Zt(this._options.url,{ticket:await this._options.getTicket(),force:Number(!!n)});return this._controller.open(a),!0});o(this,"exit",async()=>{var e;if(this._clearLiveData(),this.state!==$.OPEN)return!0;try{await((e=this.$RTC)==null?void 0:e.quit())}catch(n){A.warn(n)}return await this._controller.close()});o(this,"close",async()=>{var e,n;if((n=(e=this.selfInfo)==null?void 0:e.permission)!=null&&n.close_live_room)return await this.updateStatus(F.RoomChange,K.RoomClose,{})});o(this,"dispose",async()=>(this._removeLiveControllerEventListeners(),this._clearLiveData(),await this._controller.dispose()));o(this,"setSelfInfo",async e=>await this.updateStatus(F.UserChange,K.UserInfo,e));o(this,"toggleMicro",async e=>{var i,a,u;if(!((a=(i=this.selfInfo)==null?void 0:i.permission)!=null&&a.control_own_micro))return!1;const n=await((u=this.$RTC)==null?void 0:u.toggleMicro(e));return n&&await this.updateStatus(F.UserChange,K.UserMicroStatus,{status:e?Q.OPEN:Q.CLOSE},[]),n});o(this,"forbidMicro",async(e,n)=>{var i,a;return typeof this._options.canForbidUserMicro=="function"&&!this._options.canForbidUserMicro(n)||!((a=(i=this.selfInfo)==null?void 0:i.permission)!=null&&a.control_other_micro)?!1:await this.updateStatus(F.UserChange,K.UserMicroStatus,{status:e},n)});o(this,"forbidSync",async(e,n)=>{var i,a;return typeof this._options.canForbidUserSync=="function"&&!this._options.canForbidUserSync(n)||!((a=(i=this.selfInfo)==null?void 0:i.permission)!=null&&a.control_other_sync)?!1:await this.updateStatus(F.UserChange,K.UserPermission,{sync_frame:e},n)});o(this,"kick",async e=>{var n,i;return typeof this._options.canForbidUserKick=="function"&&!this._options.canForbidUserKick(e)||!((i=(n=this.selfInfo)==null?void 0:n.permission)!=null&&i.change_other_status)?!1:await this.updateStatus(F.UserChange,K.UserStatus,{status:"KICK_OUT"},e)});this._addLiveControllerEventListeners(),this._options=Object.assign({initialMicroStatus:Q.OPEN},e),this._options.jsBridge=(()=>{if(e.jsBridge)return e.jsBridge;if(e.useBuiltInJsBridge)return new Wt})(),this._options.getVoiceSign=(n=e.getVoiceSign)!=null?n:lr,this._options.autoPlayConfirm=e.autoPlayConfirm,this._options.rtc=(()=>{if(e.rtc)return e.rtc;if(e.rtcType)switch(e.getVoiceSign||A.error("GetVoiceSign method must be passed when using built-in RTC instances"),e.rtcType){case ee.RealseeVRWebViewRTC:{if(this._options.jsBridge)return new $e({jsBridge:this._options.jsBridge,getVoiceSign:this._options.getVoiceSign});A.error("JsBridge instance must be passed when using built-in VRWebViewRTC instances");return}case ee.RealseeBrowserChimeRTC:return new Ve({getVoiceSign:this._options.getVoiceSign,logLevel:e.__debug__?ot.DEBUG:ot.INFO});case ee.RealseeBrowserRTC:return this._options.autoPlayConfirm||A.error("autoPlayConfirm method must be passed when using built-in RealseeBrowserRTC instances"),new Me({getVoiceSign:this._options.getVoiceSign,autoPlayConfirm:this._options.autoPlayConfirm});default:{A.error("unknown built-in RTC type");return}}if(e.useBuiltInRTC){if(e.getVoiceSign||A.error("GetVoiceSign method must be passed when using built-in RTC instances"),this._options.jsBridge)return rr&&(Qt||er)||tr?new $e({jsBridge:this._options.jsBridge,getVoiceSign:this._options.getVoiceSign}):e.builtInRTCType===Ue.RealseeXChimeRTC?new Ve({getVoiceSign:this._options.getVoiceSign}):new Me({getVoiceSign:this._options.getVoiceSign,autoPlayConfirm:this._options.autoPlayConfirm});A.error("jsBridge instance must be passed when using built-in RTC instances");return}})(),this._options.rtc||A.warn("unused rtc"),this._options.url&&this._options.getTicket&&this.connect(),this._options.__debug__&&Object.assign(window,{$liveController:this._controller,$live:this})}get options(){return Object.freeze(this._options||{})}get state(){return this._controller.state}get readyState(){return this._controller.state}get url(){return this.options.url}get $RTC(){return this._options.rtc}get jsBridge(){return this._options.jsBridge}get snapshot(){return this._buildInData.keyframes}get selfInfo(){return this._buildInData.selfInfo}get userList(){return this._buildInData.userList||[]}get roomInfo(){return this._buildInData.roomInfo}async updateStatus(e,n,i,a){if(this.state!==$.OPEN)return!1;const u=Object.assign({event_type:e,action:n},{data:i}),f=Le(U.BuiltinMsg,u,a);try{return this._controller.sendMessage(f),!0}catch(v){return A.error(v),!1}}broadcast(e,n,i){return this.state!==$.OPEN?!1:new Promise((a,u)=>{const f=Le(U.CustomEvent,e,n),v=f.front_request_id,h=i?setTimeout(()=>{u(new Error("RESPONSE TIMEOUT")),this.off("broadcast",_)},i):void 0,_=(E,S)=>{S===v&&(h&&clearTimeout(h),this.off("broadcast",_),a(E))};this.on("broadcast",_);try{this._controller.sendMessage(f)}catch(E){u(E)}})}}const vt=t=>(fr(),new dr(t));var xe={},hr={get exports(){return xe},set exports(t){xe=t}},se={};/*
2
- object-assign
3
- (c) Sindre Sorhus
4
- @license MIT
5
- */var Ae,ct;function pt(){if(ct)return Ae;ct=1;var t=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,e=Object.prototype.propertyIsEnumerable;function n(a){if(a==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(a)}function i(){try{if(!Object.assign)return!1;var a=new String("abc");if(a[5]="de",Object.getOwnPropertyNames(a)[0]==="5")return!1;for(var u={},f=0;f<10;f++)u["_"+String.fromCharCode(f)]=f;var v=Object.getOwnPropertyNames(u).map(function(_){return u[_]});if(v.join("")!=="0123456789")return!1;var h={};return"abcdefghijklmnopqrst".split("").forEach(function(_){h[_]=_}),Object.keys(Object.assign({},h)).join("")==="abcdefghijklmnopqrst"}catch(_){return!1}}return Ae=i()?Object.assign:function(a,u){for(var f,v=n(a),h,_=1;_<arguments.length;_++){f=Object(arguments[_]);for(var E in f)s.call(f,E)&&(v[E]=f[E]);if(t){h=t(f);for(var S=0;S<h.length;S++)e.call(f,h[S])&&(v[h[S]]=f[h[S]])}}return v},Ae}/** @license React v17.0.2
1
+ "use strict";var Ft=Object.defineProperty;var qt=(r,s,e)=>s in r?Ft(r,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[s]=e;var o=(r,s,e)=>(qt(r,typeof s!="symbol"?s+"":s,e),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Kt=require("@realsee/jsbridge-x"),Me=require("trtc-js-sdk"),X=require("amazon-chime-sdk-js"),D=require("react"),ue=Symbol("$$REALSEE_LIVE_EVENT$$");function Ee(r){return r[ue]||(r[ue]={}),r[ue]}function Gt(r){r[ue]||delete r[ue]}class le{hasListener(s){const e=Ee(this);return e&&e[s]&&e[s].length>0}on(s,e,i){const n=Ee(this);return n[s]||(n[s]=[]),n[s].push([e,i||!1]),()=>this.off(s,e)}once(s,e){return this.on(s,e,!0)}off(s,e){if(s===void 0){Gt(this);return}const i=Ee(this);if(i[s]||(i[s]=[]),e===void 0){i[s].length=0;return}let n=0;for(;n<i[s].length&&i[s][n][0]!==e;n++);n<i[s].length&&i[s].splice(n,1)}emit(s,...e){let i=!1;const c=Ee(this)[s]||[];for(let u of c.slice()){const[d,g=!1]=u,v=d(...e);g&&this.off(s,d),v===!1&&(i=!0)}return i}}class Ce extends le{}var ee=(r=>(r.RealseeBrowserRTC="RealseeBrowserRTC",r.RealseeVRWebViewRTC="RealseeVRWebViewRTC",r.RealseeBrowserChimeRTC="RealseeBrowserChimeRTC",r))(ee||{}),Ue=(r=>(r.RealseeXTRTC="trtc",r.RealseeXChimeRTC="chime",r))(Ue||{});const Yt=()=>{const r=new Date,s=r.getFullYear(),e=(r.getMonth()+1).toString().padStart(2,"0"),i=r.getDate().toString().padStart(2,"0"),n=r.getHours().toString().padStart(2,"0"),c=r.getMinutes().toString().padStart(2,"0"),u=r.getSeconds().toString().padStart(2,"0"),d=r.getMilliseconds();return`[${s}-${e}-${i} ${n}:${c}:${u}.${d}]`},we=(r,s=[])=>{switch(s.unshift(`Realsee Live ${Yt()} <${r}> `),r){case"INFO":return console.info(...s);case"ERROR":return console.error(...s);case"WARN":return console.warn(...s);default:return console.log(...s)}},Ht=(...r)=>we("LOG",r),Jt=(...r)=>we("INFO",r),zt=(...r)=>we("ERROR",r),Xt=(...r)=>we("WARN",r),Zt={log:Ht,info:Jt,error:zt,warn:Xt},O=Zt;function Z(){return((1+Math.random())*65536|0).toString(16).substring(1)}function ye(){return(Z()+Z()+"-"+Z()+"-4"+Z().substr(0,3)+"-"+Z()+"-"+Z()+Z()+Z()).toLowerCase()}class De extends Ce{constructor(e){super();o(this,"type",ee.RealseeBrowserRTC);o(this,"joined",!1);o(this,"micro",!1);o(this,"voiceId","");o(this,"_getVoiceSign",()=>{throw new Error("方法 getVoiceSign 未实现")});o(this,"_autoPlayConfirm");o(this,"checkRequirement",()=>Me.checkSystemRequirements());o(this,"$dom",document.createElement("div"));o(this,"_trtc",{client:null,stream:null});o(this,"join",async e=>{var c;this.emit("joinWillStart");const i=await this._getVoiceSign({voiceId:e.voiceId,roomId:e.roomId,userId:e.userId});this._trtc.client=Me.createClient({mode:"rtc",...i,enableAutoPlayDialog:typeof this._autoPlayConfirm!="function"}),(c=this._trtc.client)==null||c.enableAudioVolumeEvaluation(),this._registerRtcEvent();let n=await new Promise(u=>{var d;(d=this._trtc.client)==null||d.join({roomId:Number(e.voiceId)}).then(()=>u(!0)).catch(()=>u(!1))});return this.joined=n,n?(this._trtc.stream=Me.createStream({userId:i.userId,audio:!0,video:!1}),n=await new Promise(u=>{var d;(d=this._trtc.stream)==null||d.initialize().then(()=>u(!0)).catch(()=>u(!1))}),n=await new Promise(u=>{var d;(d=this._trtc.client)==null||d.publish(this._trtc.stream).then(()=>u(!0)).catch(()=>u(!1))}),this.joined=n,this.joined&&this.emit("joined"),n):!1});o(this,"_handleStreamAdded",e=>{var n;const i=e.stream;console.log("远端流增加: "+i.getId()),(n=this._trtc.client)==null||n.subscribe(i)});o(this,"_handleStreamSubscribed",e=>{const i=e.stream;console.log("远端流订阅成功:"+i.getId());const c=`rs-rtc-remote_stream-${i.getId()}`,u=document.createElement("div");u.id=c,this.$dom.appendChild(u),typeof this._autoPlayConfirm=="function"?(i.play(c).catch(d=>{}),i.on("error",d=>{if(d.getCode()===16451){const v=()=>i.resume();this._autoPlayConfirm({onConfirm:v})}})):i.play(c)});this._getVoiceSign=e.getVoiceSign,this._autoPlayConfirm=e.autoPlayConfirm,this._initParentDom()}_initParentDom(){this.$dom.id=`rs-rtc-${ye()}`,this.$dom.style.display="none",document.body.appendChild(this.$dom)}quit(){return new Promise(async e=>{var i,n;this.joined=!1,this._trtc.stream&&(await((i=this._trtc.client)==null?void 0:i.unpublish(this._trtc.stream)),this._trtc.stream.stop(),this._trtc.stream.close(),this._trtc.stream=null),(n=this._trtc.client)==null||n.leave().then(()=>this._trtc.client=null).then(()=>e(!0)).catch(()=>e(!1)),e(!0)})}detectMicro(){return new Promise(e=>{const i={audio:!0,video:!1};try{navigator.mediaDevices.getUserMedia(i).then(()=>e(!0)).catch(n=>{O.error(n.message),e(!1)})}catch(n){console.error(n),e(!1)}})}toggleMicro(e){var i,n,c,u;return Promise.resolve((e?(n=(i=this._trtc)==null?void 0:i.stream)==null?void 0:n.unmuteAudio():(u=(c=this._trtc)==null?void 0:c.stream)==null?void 0:u.muteAudio())||!1)}shock(){throw new Error("Method not implemented.")}_registerRtcEvent(){var e,i,n,c;(e=this._trtc.client)==null||e.on("stream-added",this._handleStreamAdded),(i=this._trtc.client)==null||i.on("stream-subscribed",this._handleStreamSubscribed),(n=this._trtc.client)==null||n.on("audio-volume",u=>this.emit("userVolumes",u.result.map(({userId:d,audioVolume:g})=>({userId:d,audioVolume:g})))),(c=this._trtc.client)==null||c.on("error",u=>this.emit("error",u))}}class Ve extends Ce{constructor(e){super();o(this,"type",ee.RealseeBrowserChimeRTC);o(this,"joined",!1);o(this,"micro",!1);o(this,"voiceId","");o(this,"userId","");o(this,"logger");o(this,"deviceController");o(this,"meetingSession");o(this,"audioInput");o(this,"audioOutput");o(this,"deviceChangeObserver",{});o(this,"audioVideoObserver",{});o(this,"audioMixObserver");o(this,"_getVoiceSign",()=>{throw new Error("方法 getVoiceSign 未实现")});o(this,"_autoPlayConfirm");o(this,"$dom",document.createElement("div"));o(this,"$audio",document.createElement("audio"));o(this,"_initDom",()=>{this.$audio.id=`rs-rtc-${ye()}`,this.$dom.id=`rs-rtc-${ye()}`,this.$dom.appendChild(this.$audio),document.body.appendChild(this.$dom)});o(this,"initObservers",()=>{this.deviceChangeObserver={audioInputsChanged:e=>{this.logger.info(`audioInputsChanged ${typeof e}`),e==null||e.forEach(i=>{this.logger.info(`Device ID: ${i.deviceId} Microphone: ${i.label}`)})},audioOutputsChanged:e=>{this.logger.info(`audioOutputsChanged ${typeof e}`),e==null||e.forEach(i=>{this.logger.info(`Device ID: ${i.deviceId} Speaker: ${i.label}`)})},audioInputMuteStateChanged:(e,i)=>{this.logger.info(`Device ${e.toString()} ${i?"is muted in hardware":"is not muted"}`)}},this.audioVideoObserver={audioVideoDidStart:()=>{this.logger.info("Started")},audioVideoDidStop:e=>{this.logger.info(`Stopped with a session status code: ${e.statusCode()}`)},audioVideoDidStartConnecting:e=>{e&&this.logger.info("Attempting to reconnect")}},this.audioMixObserver={meetingAudioStreamBecameActive:e=>{if(this.$audio.paused){const i=()=>this.$audio.play().then(()=>{}).catch(n=>{if(O.error("播放远端流失败!",n),typeof this._autoPlayConfirm=="function"){const c=()=>i();this._autoPlayConfirm({onConfirm:c})}});i()}},meetingAudioStreamBecameInactive:e=>{}}});o(this,"_registerRtcEvent",()=>{var i,n,c,u,d,g;const e=((c=(n=(i=this.meetingSession)==null?void 0:i.configuration)==null?void 0:n.credentials)==null?void 0:c.attendeeId)||"";if(e){const v=new Map,E=()=>{const y=[];return v.forEach((I,_)=>{y.push({userId:I.userId,volume:I.muted||I.signalStrength===0||!Boolean(I.volume)?0:I.volume})}),y};(u=this.meetingSession)==null||u.audioVideo.realtimeSubscribeToAttendeeIdPresence((y,I,_)=>{var V;if(!I){v.delete(y),this.emit("userVolumes",E());return}(V=this.meetingSession)==null||V.audioVideo.realtimeSubscribeToVolumeIndicator(y,(C,k,B,P)=>{new X.DefaultModality(C).base()===C&&(v.set(C,{userId:_||C,volume:k,muted:B,signalStrength:P}),this.emit("userVolumes",E()))})}),(d=this.meetingSession)==null||d.audioVideo.realtimeSubscribeToVolumeIndicator(e,(y,I,_,V)=>{new X.DefaultModality(y).base()===y&&V!==null&&V!==1&&this.emit("weakNetwork")}),(g=this.meetingSession)==null||g.audioVideo.realtimeSubscribeToFatalError(y=>this.emit("error",y))}});this._getVoiceSign=e.getVoiceSign,this._autoPlayConfirm=e.autoPlayConfirm,this._initDom(),this.logger=new X.ConsoleLogger("WebRTCLogger",e.logLevel||X.LogLevel.INFO),this.deviceController=new X.DefaultDeviceController(this.logger),this.initObservers()}async join(e){return new Promise(async(i,n)=>{var c,u;this.emit("joinWillStart");try{const{sdkAppId:d,userId:g,roomId:v,userSig:E}=await this._getVoiceSign({...e,roomId:e.roomId||0});this.userId=g;const{attendence:y,vendor_wrapper:I}=JSON.parse(decodeURIComponent(E)),_=new X.MeetingSessionConfiguration({Meeting:I},{Attendee:{ExternalUserId:y.external_user_id,AttendeeId:y.attendee_id,JoinToken:y.join_token}});this.meetingSession=new X.DefaultMeetingSession(_,this.logger,this.deviceController),this._registerRtcEvent(),this.meetingSession.audioVideo.addDeviceChangeObserver(this.deviceChangeObserver),this.meetingSession.audioVideo.addObserver(this.audioVideoObserver),this.meetingSession.audioVideo.bindAudioElement(this.$audio);const V={audioVideoDidStart:()=>{var C;(C=this.meetingSession)==null||C.audioVideo.realtimeMuteLocalAudio(),this.joined=!0,this.emit("joined"),i(!0)},audioVideoDidStop:()=>{this.joined=!1,i(!1)}};this.meetingSession.audioVideo.addObserver(V),this.audioMixObserver&&this.meetingSession.audioVideo.addAudioMixObserver(this.audioMixObserver),this.meetingSession.audioVideo.setDeviceLabelTrigger(async()=>await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}));try{const C=await this.meetingSession.audioVideo.listAudioInputDevices();O.info("audioInputDevices ===>",C);const k=((c=C[0])==null?void 0:c.deviceId)||"default";await this.meetingSession.audioVideo.startAudioInput(k)}catch(C){O.error(`设置语音输入设备失败:${C.message}`)}try{const C=await this.meetingSession.audioVideo.listAudioOutputDevices();O.info("audioOutputDevices ===>",C);const k=((u=C[0])==null?void 0:u.deviceId)||"default";await this.meetingSession.audioVideo.chooseAudioOutput(k)}catch(C){O.error(`设置语音输出设备失败:${C.message}`)}this.meetingSession.audioVideo.start()}catch(d){this.emit("error",d),this.logger.error(d.message),i(!1)}})}quit(){return this.joined?new Promise((e,i)=>{var c,u;this.joined=!1;const n={audioVideoDidStop:async d=>{var v;const g=d.statusCode();(v=this.meetingSession)==null||v.deviceController.destroy(),g===X.MeetingSessionStatusCode.Left?(this.logger.info("You left the session"),e(!0)):(this.logger.info(`Stopped with a session status code: ${g}`),e(!0))}};(c=this.meetingSession)==null||c.audioVideo.addObserver(n),(u=this.meetingSession)==null||u.audioVideo.stop()}):Promise.resolve(!0)}async detectMicro(){return new Promise(e=>{const i={audio:!0,video:!1};try{navigator.mediaDevices.getUserMedia(i).then(()=>e(!0)).catch(()=>e(!1))}catch(n){this.logger.error(n.message),e(!1)}})}async toggleMicro(e){var n,c,u;e?(n=this.meetingSession)==null||n.audioVideo.realtimeUnmuteLocalAudio():(c=this.meetingSession)==null||c.audioVideo.realtimeMuteLocalAudio();const i=(u=this.meetingSession)==null?void 0:u.audioVideo.realtimeIsLocalAudioMuted();return i!==void 0?e!==i:!1}shock(){throw new Error("Method not implemented.")}}var Be=(r=>(r[r.Success=0]="Success",r[r.Failure=1]="Failure",r[r.ReJoin=2]="ReJoin",r[r.NoMicroPermission=3]="NoMicroPermission",r))(Be||{});class $e extends Ce{constructor({jsBridge:e,getVoiceSign:i}){super();o(this,"type",ee.RealseeVRWebViewRTC);o(this,"joined",!1);o(this,"micro",!1);o(this,"voiceId","");o(this,"options");this.options={jsBridge:e,getVoiceSign:i},this.jsBridge.webViewType!=="WxMiniProgramWebView"&&this.jsBridge.callAndListen("live/userVolumes",n=>{this.emit("userVolumes",n)}),this.jsBridge.callAndListen("live/weakNetwork",n=>{n&&this.emit("weakNetwork")})}get jsBridge(){return this.options.jsBridge}async join(e){try{this.emit("joinWillStart");const{sdkAppId:i,userId:n,userSig:c}=await this.options.getVoiceSign(e);if(!(Boolean(i)&&Boolean(n)&&Boolean(c)))return this.emit("error",new Error("加入房间失败:rtc 签名请求异常")),this.joined=!1,this.joined;this.type=e.type;const[u,d]=await this.jsBridge.callAndBackfeed(`live/join?sdkAppID=${i}&userID=${n}&roomID=${Number(e.voiceId)}&userSig=${c}`);return u?u.code===Be.Success?(this.emit("joined"),this.joined=!0):(this.emit("error",u),this.joined=!1):(this.emit("error",d||new Error("加入房间失败:未知异常。")),this.joined=!1),this.joined}catch(i){return this.emit("error",new Error("加入房间失败:"+i.message)),this.joined=!1,this.joined}}async quit(){const[e,i]=await this.jsBridge.callAndBackfeed("live/quit");return e===null&&this.emit("error",i||new Error("退出房间失败:未知异常。")),this.joined=!1,!!e}async detectMicro(){const[e,i]=await this.jsBridge.detectMicro();return e===null?(this.emit("error",i||new Error("麦克风监测异常!")),!1):e}async toggleMicro(e){const[i,n]=await this.jsBridge.callAndBackfeed(`live/toggleMicro?flag=${e?1:0}`);return i===null?(this.emit("error",n||new Error("麦克风监测异常!")),!1):(this.micro=i,i)}shock(){this.jsBridge.shock(1)}}var U=(r=>(r.SelfUserInfo="SELF_USER_INFO",r.RoomInfo="ROOM_INFO",r.RTCInfo="RTC_INFO",r.UserList="USER_LIST",r.BuiltinMsg="BUILTIN_MSG",r.CustomEvent="CUSTOM_EVENT",r.KeyframeSync="KEYFRAME_SYNC",r.UserKickOut="USER_KICK_OUT",r))(U||{}),K=(r=>(r.UserChange="user_change",r.RoomChange="room_change",r))(K||{}),Y=(r=>(r.UserMicroStatus="change_micro_status",r.UserMicroStatusSync="sync_micro_status",r.UserPermission="change_permission",r.UserStatus="change_status",r.UserInfo="change_info",r.RoomClose="close",r))(Y||{}),Q=(r=>(r.OPEN="OPEN",r.CLOSE="CLOSE",r))(Q||{});function Qt(r){try{const s=JSON.parse(r),e={code:s.code,message:s.message,command:s.command,roomCode:s.room_code,appID:s.app_id,requestId:s.request_id,frontRequestId:s.front_request_id,triggerUserID:s.trigger_user_id,data:s.data||{}},i=Object.keys(e).filter(n=>e[n]===void 0);return i.length>0&&console.warn(`推送数据格式异常:${i.join(" ")} 值不存在!`),e}catch(s){return!1}}var $=(r=>(r[r.NOTINITIALIZED=-1]="NOTINITIALIZED",r[r.CONNECTING=0]="CONNECTING",r[r.OPEN=1]="OPEN",r[r.CLOSED=3]="CLOSED",r))($||{}),ft=(r=>(r[r.Normal=0]="Normal",r[r.Removed=1]="Removed",r[r.Replaced=2]="Replaced",r))(ft||{}),dt=(r=>(r.WAIT_ENTER="WAIT_ENTER",r.ONLINE="ONLINE",r.LEAVE="LEAVE",r.KICK_OUT="KICK_OUT",r.BE_REPLACE="BE_REPLACE",r.EXCEPTION="EXCEPTION",r))(dt||{}),be=(r=>(r[r.NOTINITIALIZED=-1]="NOTINITIALIZED",r[r.CONNECTING=0]="CONNECTING",r[r.OPEN=1]="OPEN",r[r.CLOSING=2]="CLOSING",r[r.CLOSED=3]="CLOSED",r))(be||{}),ht=(r=>(r.Error="Error",r.Close="Close",r.MicroAuth="MicroAuth",r.DuplicateConnect="DuplicateConnect",r.IllegalURL="IllegalURL",r.Unknown="Unknown",r.IllegalArgs="IllegalArgs",r))(ht||{}),_t=(r=>(r.Err_1000="CLOSE_NORMAL",r.Err_1001="CLOSE_GOING_AWAY",r.Err_1002="CLOSE_PROTOCOL_ERROR",r.Err_1003="CLOSE_UNSUPPORTED",r.Err_1006="CLOSE_ABNORMAL",r.Err_1007="Unsupported Data",r.Err_1008="Policy Violation",r.Err_1009="CLOSE_TOO_LARGE",r.Err_unknown="unknown",r))(_t||{});function gt(r){switch(r){case 1e3:return"CLOSE_NORMAL";case 1001:return"CLOSE_GOING_AWAY";case 1002:return"CLOSE_PROTOCOL_ERROR";case 1003:return"CLOSE_UNSUPPORTED";case 1006:return"CLOSE_ABNORMAL";case 1007:return"Unsupported Data";case 1008:return"Policy Violation";case 1009:return"CLOSE_TOO_LARGE"}return"unknown"}function er(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var mt={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.LogLevel=void 0;var 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.OFF=4]="OFF"})(s=r.LogLevel||(r.LogLevel={})),r.default=s})(mt);const at=er(mt);function tr(r,s={}){const e=r.indexOf("?")!==-1,i=Object.keys(s).reduce((n,c,u)=>`${n}${u===0&&!e?"?":"&"}${c}=${s[c]}`,"");return r+i}const fe=globalThis.navigator.userAgent,rr=/android/gi.test(fe),ir=/iPhone|iPad\s+OS/gi.test(fe),nr=/MicroMessenger/gi.test(fe)&&/miniProgram/gi.test(fe),sr=/realsee/gi.test(fe);function Se(r){return Object.prototype.toString.call(r)==="[object Object]"}function Re(r,s){return r===s?!0:typeof r!=typeof s?!1:!!(Number.isNaN(r)&&Number.isNaN(s))}function or(r,s){const e=Object.getOwnPropertyNames(r),i=Object.getOwnPropertyNames(s);if(e.length!==i.length)return!1;for(let n=0,c=e.length;n<c;n++){const u=e[n];if(!Re(r[u],s[u]))return!1}return!0}function ar(r,s){if(r.length!==s.length)return!1;for(let e=0,i=r.length;e<i;e++)if(!Re(r[e],s[e]))return!1;return!0}function cr(r,s){return Re(r,s)?!0:Se(r)&&Se(s)?or(r,s):Array.isArray(r)&&Array.isArray(s)?ar(r,s):!1}function We(r,s){return Re(r,s)?!0:Se(r)&&Se(s)?lr(r,s):Array.isArray(r)&&Array.isArray(s)?ur(r,s):!1}function ur(r,s){if(r.length!==s.length)return!1;for(let e=0,i=r.length;e<i;e++)if(!We(r[e],s[e]))return!1;return!0}function lr(r,s){const e=Object.getOwnPropertyNames(r),i=Object.getOwnPropertyNames(s);if(e.length!==i.length)return!1;for(let n=0,c=e.length;n<c;n++){const u=e[n];if(!We(r[u],s[u]))return!1}return!0}function ct(r,s,e={deep:!1}){return e.deep?We(r,s):cr(r,s)}class fr extends le{constructor(e){super();o(this,"_realWebSocket");o(this,"_url");o(this,"_protocols");o(this,"_readyState",be.NOTINITIALIZED);o(this,"_options",{timeout:1e4,shouldReconnect:(e,i)=>{if(!(e.code===1008||e.code===1011))return[0,3e3,1e4][i.attempts%3]},should1000Reconnect:!1,ignoreConnectivityEvents:!1,automaticOpen:!1});o(this,"_connectTimeout");o(this,"_attempts",0);o(this,"_reconnects",-1);o(this,"_reconnectWhenOnlineAgain",!1);o(this,"_explicitlyClosed",!1);o(this,"_pendingReconnect");o(this,"_connectivityEventsAttached",!1);o(this,"_heathCheckTimer");o(this,"_healthCheck",async()=>{this._realWebSocket&&this._realWebSocket.readyState!==this._readyState&&(this._readyState=this._realWebSocket.readyState,this._readyState===be.CLOSING&&this.emit("closing")),await new Promise(e=>setTimeout(e,2e3)),this._heathCheckTimer=requestAnimationFrame(this._healthCheck)});o(this,"_clearHeathCheckIfNeed",()=>{this._heathCheckTimer&&(cancelAnimationFrame(this._heathCheckTimer),this._heathCheckTimer=void 0)});o(this,"_startHealthCheck",()=>{this._clearHeathCheckIfNeed(),this._heathCheckTimer=requestAnimationFrame(this._healthCheck)});o(this,"_stopHealthCheck",()=>{this._clearHeathCheckIfNeed()});o(this,"_clearPendingReconnectIfNeeded",()=>{this._pendingReconnect&&(clearTimeout(this._pendingReconnect),this._pendingReconnect=void 0)});o(this,"_online",e=>{this._reconnectWhenOnlineAgain&&(this._clearPendingReconnectIfNeeded(),this._reconnect(e))});o(this,"_offline",()=>{var e;this._reconnectWhenOnlineAgain=!0,(e=this._realWebSocket)==null||e.close(1e3,"offline")});o(this,"_detachConnectivityEvents",()=>{this._connectivityEventsAttached&&(globalThis==null||globalThis.removeEventListener("online",this._online),globalThis==null||globalThis.removeEventListener("offline",this._offline),this._connectivityEventsAttached=!1)});o(this,"_attachConnectivityEvents",()=>{this._connectivityEventsAttached||(globalThis==null||globalThis.addEventListener("online",this._online),globalThis==null||globalThis.addEventListener("offline",this._offline),this._connectivityEventsAttached=!0)});o(this,"send",e=>{var i,n,c;((i=this._realWebSocket)==null?void 0:i.readyState)===((n=this._realWebSocket)==null?void 0:n.OPEN)&&((c=this._realWebSocket)==null||c.send(e))});o(this,"close",(e,i)=>{var n;return typeof e!="number"&&(i=e,e=1e3),this._clearPendingReconnectIfNeeded(),this._reconnectWhenOnlineAgain=!1,this._explicitlyClosed=!0,this._detachConnectivityEvents(),(n=this._realWebSocket)==null?void 0:n.close(e,i)});o(this,"open",e=>{var i,n;e&&(this._url=e),((i=this._realWebSocket)==null?void 0:i.readyState)!==WebSocket.OPEN&&((n=this._realWebSocket)==null?void 0:n.readyState)!==WebSocket.CONNECTING&&(this._clearPendingReconnectIfNeeded(),this._reconnectWhenOnlineAgain=!1,this._explicitlyClosed=!1,this._createWebSocket())});o(this,"_createWebSocket",()=>{var n,c,u;const e=typeof this._url=="string"?this._url:(n=this._url)==null?void 0:n.call(this,this);if(!e)return;this._pendingReconnect=void 0,this._removeWebSocketEvent(),this._realWebSocket=new WebSocket(e,this._protocols||void 0),this._attempts=this._attempts+1,this.emit("connecting",new CustomEvent("connecting",{detail:{attempts:this._attempts,reconnects:this._reconnects}}));const i=()=>{this._connectTimeout=void 0,this._detachConnectivityEvents(),this.emit("timeout",new CustomEvent("connecting",{detail:{attempts:this._attempts,reconnects:this._reconnects}}))};this._connectTimeout=setTimeout(i,(c=this._options)==null?void 0:c.timeout),this._dispatchWebSocketEvent(),(u=this._options)!=null&&u.ignoreConnectivityEvents||this._attachConnectivityEvents()});o(this,"_removeWebSocketEvent",()=>{var e,i,n,c;(e=this._realWebSocket)==null||e.removeEventListener("open",this._webSocketOpenHandler),(i=this._realWebSocket)==null||i.removeEventListener("close",this._webSocketCloseHandler),(n=this._realWebSocket)==null||n.removeEventListener("error",this._webSocketErrorHandler),(c=this._realWebSocket)==null||c.removeEventListener("message",this._webSocketMessageHandler)});o(this,"_dispatchWebSocketEvent",()=>{var e,i,n,c;(e=this._realWebSocket)==null||e.addEventListener("open",this._webSocketOpenHandler),(i=this._realWebSocket)==null||i.addEventListener("close",this._webSocketCloseHandler),(n=this._realWebSocket)==null||n.addEventListener("error",this._webSocketErrorHandler),(c=this._realWebSocket)==null||c.addEventListener("message",this._webSocketMessageHandler)});o(this,"_webSocketOpenHandler",e=>{this._connectTimeout&&(clearTimeout(this._connectTimeout),this._connectTimeout=void 0);const i=++this._reconnects,n=this._attempts;return this._attempts=0,this._reconnectWhenOnlineAgain=!1,this._startHealthCheck(),this.emit("open",Object.assign(e,{detail:{reconnects:i,attempts:n}}))});o(this,"_webSocketCloseHandler",e=>(this._reconnect(e),this._stopHealthCheck(),this.emit("close",e)));o(this,"_webSocketErrorHandler",e=>this.emit("error",new CustomEvent("error",{detail:{error:e}})));o(this,"_webSocketMessageHandler",e=>this.emit("message",e));e&&this.setOptions(e),this._startHealthCheck()}get attempts(){return this._attempts}setOptions(e){if(!e)return;this._url=e.url,this._protocols=e.protocols;const i=Object.assign(this._options,e.robustOptions||{});if(typeof(i==null?void 0:i.timeout)!="number")throw new Error("timeout must be the number of milliseconds to timeout a connection attempt");if(typeof(i==null?void 0:i.shouldReconnect)!="function")throw new Error("shouldReconnect must be a function that returns the number of milliseconds to wait for a reconnect attempt, or null or undefined to not reconnect.");this._options=i,this._options.automaticOpen&&this._createWebSocket()}_reconnect(e){var n,c,u,d;if(!((n=this._options)!=null&&n.should1000Reconnect)&&e.code===1e3||this._explicitlyClosed){this._attempts=0;return}if(((c=globalThis==null?void 0:globalThis.navigator)==null?void 0:c.onLine)===!1){this._reconnectWhenOnlineAgain=!0;return}const i=(d=(u=this._options)==null?void 0:u.shouldReconnect)==null?void 0:d.call(u,e,this);typeof i=="number"&&(this._pendingReconnect=setTimeout(this._createWebSocket,i))}}class dr extends le{constructor(){super();o(this,"_ws",new fr({url:"",robustOptions:{timeout:18e4}}));o(this,"_state",$.NOTINITIALIZED);o(this,"_addWebSocketEventListeners",()=>{this._ws.on("close",this._handleCloseEvent),this._ws.on("closing",this._handleClosingEvent),this._ws.on("connecting",this._handleConnectingEvent),this._ws.on("error",this._handleErrorEvent),this._ws.on("message",this._handleMessageEvent),this._ws.on("open",this._handleOpenEvent),this._ws.on("timeout",this._handleTimeoutEvent)});o(this,"_removeWebSocketEventListeners",()=>{this._ws.off("close",this._handleCloseEvent),this._ws.off("closing",this._handleClosingEvent),this._ws.off("connecting",this._handleConnectingEvent),this._ws.off("error",this._handleErrorEvent),this._ws.off("message",this._handleMessageEvent),this._ws.off("open",this._handleOpenEvent),this._ws.off("timeout",this._handleTimeoutEvent)});o(this,"_handleCloseEvent",e=>{O.info(`live room closed bacause of ${e.code}-${e.reason||gt(e.code)}`),this.state=$.CLOSED});o(this,"_handleClosingEvent",()=>{var e;O.info("live room is closing, onLine:",(e=globalThis==null?void 0:globalThis.navigator)==null?void 0:e.onLine),this.state=$.CLOSED});o(this,"_handleConnectingEvent",()=>{O.info("live room is connecting"),this.state=$.CONNECTING});o(this,"_handleErrorEvent",e=>{O.error("live room error",e),this.state=$.CLOSED});o(this,"_handleMessageEvent",e=>{let i=(()=>{try{return JSON.parse(e.data)}catch(n){return e.data}})();this.emit("message",i)});o(this,"_handleOpenEvent",e=>{O.info("live room open",e.detail),this.state=$.OPEN,e.detail.reconnects>0&&this.emit("reconnected",e.detail)});o(this,"_handleTimeoutEvent",e=>{O.error("live room connect timeout!",e.detail),this.state=$.CLOSED});o(this,"dispose",async()=>(this._removeWebSocketEventListeners(),await this.close("live room close by controller disposed!")));o(this,"open",e=>this._ws.open(e));o(this,"close",(e,i)=>new Promise(n=>{this._ws.once("close",()=>n(!0)),this._ws.close(e,i)}));this._addWebSocketEventListeners()}set state(e){const i=JSON.parse(JSON.stringify(this._state));this._state=e,this.emit("stateChange",this.state,i)}get state(){return this._state}sendMessage(e=""){if(e==null||e==="")throw new Error("live message is empty!");if(this.state===$.OPEN)return this._ws.send(JSON.stringify(e));throw new Error("live has not yet been initialized!")}}const hr=r=>Promise.reject("unimplemented method GetVoiceSign"),Ae=(r,s={},e=[])=>({command:r,front_request_id:ye(),data:{...s,to_user_ids:Array.isArray(e)?e:[e]}}),_r=()=>{var r,s;window!=null&&window.__Realsee_Live__&&((s=(r=window==null?void 0:window.__Realsee_Live__)==null?void 0:r.dispose)==null||s.call(r),window.__Realsee_Live__=null)};class gr extends le{constructor(e){var i;super();o(this,"_options",{});o(this,"keyframes",new le);o(this,"_buildInData",{keyframes:{}});o(this,"getFramesByKey",e=>this.snapshot[e]);o(this,"sendKeyframe",(e,i)=>{if(this.state!==$.OPEN)return!1;this._buildInData.keyframes={...this._buildInData.keyframes,[e]:i};const n=Ae(U.KeyframeSync,this.snapshot);try{return this._controller.sendMessage(n),!0}catch(c){return O.error(c),!1}});o(this,"_controller",new dr);o(this,"_addLiveControllerEventListeners",()=>{this._controller.on("stateChange",this._handleStateChange),this._controller.on("message",this._handleMessage)});o(this,"_removeLiveControllerEventListeners",()=>{this._controller.off("stateChange",this._handleStateChange),this._controller.off("message",this._handleMessage)});o(this,"_handleStateChange",(e,i)=>this.emit("stateChange",e,i));o(this,"_handleMessage",async e=>{var i,n,c,u,d;if(typeof e=="object"){const{command:g,data:v={},frontRequestId:E,code:y,message:I}=e;if(y==="SUCCESS")switch(g){case U.SelfUserInfo:{const _=v;ct(this.selfInfo,_,{deep:!0})||(this._buildInData.selfInfo=_,this.emit("selfInfoUpdate",this._buildInData.selfInfo,E));break}case U.RoomInfo:{const _=v;this._buildInData.roomInfo=Object.assign({},_),this.emit("readyKeyframeSync",_.last_frame||{});break}case U.RTCInfo:{const{voice_id:_,type:V}=v;if(this._buildInData.rtcInfo={voiceId:_,type:V},(i=this.$RTC)!=null&&i.joined)O.warn("已加入语音房间,无需重复加入!");else if(await((u=this.$RTC)==null?void 0:u.join({voiceId:_,userId:((n=this.selfInfo)==null?void 0:n.id)||"",roomId:(c=this.roomInfo)==null?void 0:c.info.room_code,type:V}))){const k=(d=this._options.initialMicroStatus)!=null?d:Q.OPEN;await this.toggleMicro(k===Q.OPEN)}else O.error("加入语音房间失败");break}case U.UserList:{const _=v;this._buildInData.userList=_,this.emit("userListUpdate",this.userList,E);break}case U.CustomEvent:{const _=v;this.emit("broadcast",_,E);break}case U.KeyframeSync:{const _=v,V=Object.keys(_).reduce((C,k)=>{if(ct(_[k],this._buildInData.keyframes[k],{deep:!0}))return C;const B=[_[k],this._buildInData.keyframes[k],E],P=k;return this.keyframes.emit(P,...B),this._buildInData.keyframes[k]=_[k],C[k]=_[k],C},{});this.emit("keyframes",V,E);break}case U.BuiltinMsg:{const _=v;this.emit("builtinEvent",_),_.event_type===K.UserChange&&this.emit("userChange",_),_.event_type===K.RoomChange&&this.emit("roomChange",_),_.event_type===K.UserChange&&_.action===Y.UserMicroStatus&&await this.toggleMicro(_.data.status===Q.OPEN),_.event_type===K.RoomChange&&_.action===Y.RoomClose&&await this.exit();break}case U.UserKickOut:{this.emit("kickOut");break}default:console.warn("unknown command: ",g)}else this.emit("error",e)}});o(this,"_clearLiveData",()=>{this._buildInData={keyframes:{}}});o(this,"connect",async(e={})=>{var u,d,g,v;if(this._options.url=(d=(u=e.url)!=null?u:this._options.url)!=null?d:"",this._options.getTicket=(g=e.getTicket)!=null?g:this._options.getTicket,this._options.initialMicroStatus=(v=e.rtcMicStatus)!=null?v:this._options.initialMicroStatus,!/^ws(s):\/\//.test(this._options.url)||typeof this._options.getTicket!="function")return/^ws(s):\/\//.test(this._options.url)?typeof this._options.getTicket!="function"?new Error("getTicket muse be function"):!1:new Error("Illegal realsee live room link");const{force:i=!1}=e;if(this._options.rtc&&!await this._options.rtc.detectMicro())return new Error("Failed to obtain microphone authorization");const n=this.state;if(n===$.CONNECTING||n===$.OPEN)if(i)try{await this._controller.close("force close by connect")}catch(E){console.warn(E)}else return new Error("已有Live实例正在连接中,请勿重复连接!");this._clearLiveData();const c=tr(this._options.url,{ticket:await this._options.getTicket(),force:Number(!!i)});return this._controller.open(c),!0});o(this,"exit",async()=>{var e;if(this._clearLiveData(),this.state!==$.OPEN)return!0;try{await((e=this.$RTC)==null?void 0:e.quit())}catch(i){O.warn(i)}return await this._controller.close()});o(this,"close",async()=>{var e,i;if((i=(e=this.selfInfo)==null?void 0:e.permission)!=null&&i.close_live_room)return await this.updateStatus(K.RoomChange,Y.RoomClose,{})});o(this,"dispose",async()=>(this._removeLiveControllerEventListeners(),this._clearLiveData(),await this._controller.dispose()));o(this,"setSelfInfo",async e=>await this.updateStatus(K.UserChange,Y.UserInfo,e));o(this,"toggleMicro",async e=>{var n,c,u;if(!((c=(n=this.selfInfo)==null?void 0:n.permission)!=null&&c.control_own_micro))return!1;const i=await((u=this.$RTC)==null?void 0:u.toggleMicro(e));return i&&await this.updateStatus(K.UserChange,Y.UserMicroStatus,{status:e?Q.OPEN:Q.CLOSE},[]),i});o(this,"forbidMicro",async(e,i)=>{var n,c;return typeof this._options.canForbidUserMicro=="function"&&!this._options.canForbidUserMicro(i)||!((c=(n=this.selfInfo)==null?void 0:n.permission)!=null&&c.control_other_micro)?!1:await this.updateStatus(K.UserChange,Y.UserMicroStatus,{status:e},i)});o(this,"forbidSync",async(e,i)=>{var n,c;return typeof this._options.canForbidUserSync=="function"&&!this._options.canForbidUserSync(i)||!((c=(n=this.selfInfo)==null?void 0:n.permission)!=null&&c.control_other_sync)?!1:await this.updateStatus(K.UserChange,Y.UserPermission,{sync_frame:e},i)});o(this,"kick",async e=>{var i,n;return typeof this._options.canForbidUserKick=="function"&&!this._options.canForbidUserKick(e)||!((n=(i=this.selfInfo)==null?void 0:i.permission)!=null&&n.change_other_status)?!1:await this.updateStatus(K.UserChange,Y.UserStatus,{status:"KICK_OUT"},e)});this._addLiveControllerEventListeners(),this._options=Object.assign({initialMicroStatus:Q.OPEN},e),this._options.jsBridge=(()=>{if(e.jsBridge)return e.jsBridge;if(e.useBuiltInJsBridge)return new Kt})(),this._options.getVoiceSign=(i=e.getVoiceSign)!=null?i:hr,this._options.autoPlayConfirm=e.autoPlayConfirm,this._options.rtc=(()=>{if(e.rtc)return e.rtc;if(e.rtcType)switch(e.getVoiceSign||O.error("GetVoiceSign method must be passed when using built-in RTC instances"),e.rtcType){case ee.RealseeVRWebViewRTC:{if(this._options.jsBridge)return new $e({jsBridge:this._options.jsBridge,getVoiceSign:this._options.getVoiceSign});O.error("JsBridge instance must be passed when using built-in VRWebViewRTC instances");return}case ee.RealseeBrowserChimeRTC:return new Ve({getVoiceSign:this._options.getVoiceSign,logLevel:e.__debug__?at.DEBUG:at.INFO});case ee.RealseeBrowserRTC:return this._options.autoPlayConfirm||O.error("autoPlayConfirm method must be passed when using built-in RealseeBrowserRTC instances"),new De({getVoiceSign:this._options.getVoiceSign,autoPlayConfirm:this._options.autoPlayConfirm});default:{O.error("unknown built-in RTC type");return}}if(e.useBuiltInRTC){if(e.getVoiceSign||O.error("GetVoiceSign method must be passed when using built-in RTC instances"),this._options.jsBridge)return sr&&(rr||ir)||nr?new $e({jsBridge:this._options.jsBridge,getVoiceSign:this._options.getVoiceSign}):e.builtInRTCType===Ue.RealseeXChimeRTC?new Ve({getVoiceSign:this._options.getVoiceSign}):new De({getVoiceSign:this._options.getVoiceSign,autoPlayConfirm:this._options.autoPlayConfirm});O.error("jsBridge instance must be passed when using built-in RTC instances");return}})(),this._options.rtc||O.warn("unused rtc"),this._options.url&&this._options.getTicket&&this.connect(),this._options.__debug__&&Object.assign(window,{$liveController:this._controller,$live:this})}get options(){return Object.freeze(this._options||{})}get state(){return this._controller.state}get readyState(){return this._controller.state}get url(){return this.options.url}get $RTC(){return this._options.rtc}get jsBridge(){return this._options.jsBridge}get snapshot(){return this._buildInData.keyframes}get selfInfo(){return this._buildInData.selfInfo}get userList(){return this._buildInData.userList||[]}get roomInfo(){return this._buildInData.roomInfo}async updateStatus(e,i,n,c){if(this.state!==$.OPEN)return!1;const u=Object.assign({event_type:e,action:i},{data:n}),d=Ae(U.BuiltinMsg,u,c);try{return this._controller.sendMessage(d),!0}catch(g){return O.error(g),!1}}broadcast(e,i,n){return this.state!==$.OPEN?!1:new Promise((c,u)=>{const d=Ae(U.CustomEvent,e,i),g=d.front_request_id,v=n?setTimeout(()=>{u(new Error("RESPONSE TIMEOUT")),this.off("broadcast",E)},n):void 0,E=(y,I)=>{I===g&&(v&&clearTimeout(v),this.off("broadcast",E),c(y))};this.on("broadcast",E);try{this._controller.sendMessage(d)}catch(y){u(y)}})}}const vt=r=>(_r(),new gr(r));var xe={},mr={get exports(){return xe},set exports(r){xe=r}},ae={};/**
2
+ * @license React
6
3
  * react-jsx-runtime.production.min.js
7
4
  *
8
5
  * Copyright (c) Facebook, Inc. and its affiliates.
9
6
  *
10
7
  * This source code is licensed under the MIT license found in the
11
8
  * LICENSE file in the root directory of this source tree.
12
- */var ut;function _r(){if(ut)return se;ut=1,pt();var t=L,s=60103;if(se.Fragment=60107,typeof Symbol=="function"&&Symbol.for){var e=Symbol.for;s=e("react.element"),se.Fragment=e("react.fragment")}var n=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i=Object.prototype.hasOwnProperty,a={key:!0,ref:!0,__self:!0,__source:!0};function u(f,v,h){var _,E={},S=null,m=null;h!==void 0&&(S=""+h),v.key!==void 0&&(S=""+v.key),v.ref!==void 0&&(m=v.ref);for(_ in v)i.call(v,_)&&!a.hasOwnProperty(_)&&(E[_]=v[_]);if(f&&f.defaultProps)for(_ in v=f.defaultProps,v)E[_]===void 0&&(E[_]=v[_]);return{$$typeof:s,type:f,key:S,ref:m,props:E,_owner:n.current}}return se.jsx=u,se.jsxs=u,se}var De={};/** @license React v17.0.2
9
+ */var ut;function vr(){if(ut)return ae;ut=1;var r=D,s=Symbol.for("react.element"),e=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,n=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function u(d,g,v){var E,y={},I=null,_=null;v!==void 0&&(I=""+v),g.key!==void 0&&(I=""+g.key),g.ref!==void 0&&(_=g.ref);for(E in g)i.call(g,E)&&!c.hasOwnProperty(E)&&(y[E]=g[E]);if(d&&d.defaultProps)for(E in g=d.defaultProps,g)y[E]===void 0&&(y[E]=g[E]);return{$$typeof:s,type:d,key:I,ref:_,props:y,_owner:n.current}}return ae.Fragment=e,ae.jsx=u,ae.jsxs=u,ae}var ce={};/**
10
+ * @license React
13
11
  * react-jsx-runtime.development.js
14
12
  *
15
13
  * Copyright (c) Facebook, Inc. and its affiliates.
16
14
  *
17
15
  * This source code is licensed under the MIT license found in the
18
16
  * LICENSE file in the root directory of this source tree.
19
- */var lt;function gr(){return lt||(lt=1,function(t){process.env.NODE_ENV!=="production"&&function(){var s=L,e=pt(),n=60103,i=60106;t.Fragment=60107;var a=60108,u=60114,f=60109,v=60110,h=60112,_=60113,E=60120,S=60115,m=60116,D=60121,V=60122,k=60117,H=60129,J=60131;if(typeof Symbol=="function"&&Symbol.for){var I=Symbol.for;n=I("react.element"),i=I("react.portal"),t.Fragment=I("react.fragment"),a=I("react.strict_mode"),u=I("react.profiler"),f=I("react.provider"),v=I("react.context"),h=I("react.forward_ref"),_=I("react.suspense"),E=I("react.suspense_list"),S=I("react.memo"),m=I("react.lazy"),D=I("react.block"),V=I("react.server.block"),k=I("react.fundamental"),I("react.scope"),I("react.opaque.id"),H=I("react.debug_trace_mode"),I("react.offscreen"),J=I("react.legacy_hidden")}var d=typeof Symbol=="function"&&Symbol.iterator,w="@@iterator";function N(r){if(r===null||typeof r!="object")return null;var c=d&&r[d]||r[w];return typeof c=="function"?c:null}var b=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function C(r){{for(var c=arguments.length,l=new Array(c>1?c-1:0),g=1;g<c;g++)l[g-1]=arguments[g];M("error",r,l)}}function M(r,c,l){{var g=b.ReactDebugCurrentFrame,R=g.getStackAddendum();R!==""&&(c+="%s",l=l.concat([R]));var O=l.map(function(y){return""+y});O.unshift("Warning: "+c),Function.prototype.apply.call(console[r],console,O)}}var B=!1;function z(r){return!!(typeof r=="string"||typeof r=="function"||r===t.Fragment||r===u||r===H||r===a||r===_||r===E||r===J||B||typeof r=="object"&&r!==null&&(r.$$typeof===m||r.$$typeof===S||r.$$typeof===f||r.$$typeof===v||r.$$typeof===h||r.$$typeof===k||r.$$typeof===D||r[0]===V))}function le(r,c,l){var g=c.displayName||c.name||"";return r.displayName||(g!==""?l+"("+g+")":l)}function Se(r){return r.displayName||"Context"}function q(r){if(r==null)return null;if(typeof r.tag=="number"&&C("Received an unexpected object in getComponentName(). This is likely a bug in React. Please file an issue."),typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case t.Fragment:return"Fragment";case i:return"Portal";case u:return"Profiler";case a:return"StrictMode";case _:return"Suspense";case E:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case v:var c=r;return Se(c)+".Consumer";case f:var l=r;return Se(l._context)+".Provider";case h:return le(r,r.render,"ForwardRef");case S:return q(r.type);case D:return q(r._render);case m:{var g=r,R=g._payload,O=g._init;try{return q(O(R))}catch(y){return null}}}return null}var te=0,T,W,re,fe,Fe,qe,Ke;function Ye(){}Ye.__reactDisabledLog=!0;function Et(){{if(te===0){T=console.log,W=console.info,re=console.warn,fe=console.error,Fe=console.group,qe=console.groupCollapsed,Ke=console.groupEnd;var r={configurable:!0,enumerable:!0,value:Ye,writable:!0};Object.defineProperties(console,{info:r,log:r,warn:r,error:r,group:r,groupCollapsed:r,groupEnd:r})}te++}}function bt(){{if(te--,te===0){var r={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:e({},r,{value:T}),info:e({},r,{value:W}),warn:e({},r,{value:re}),error:e({},r,{value:fe}),group:e({},r,{value:Fe}),groupCollapsed:e({},r,{value:qe}),groupEnd:e({},r,{value:Ke})})}te<0&&C("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var we=b.ReactCurrentDispatcher,Re;function de(r,c,l){{if(Re===void 0)try{throw Error()}catch(R){var g=R.stack.trim().match(/\n( *(at )?)/);Re=g&&g[1]||""}return`
20
- `+Re+r}}var Oe=!1,he;{var Ct=typeof WeakMap=="function"?WeakMap:Map;he=new Ct}function Ge(r,c){if(!r||Oe)return"";{var l=he.get(r);if(l!==void 0)return l}var g;Oe=!0;var R=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var O;O=we.current,we.current=null,Et();try{if(c){var y=function(){throw Error()};if(Object.defineProperty(y.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(y,[])}catch(G){g=G}Reflect.construct(r,[],y)}else{try{y.call()}catch(G){g=G}r.call(y.prototype)}}else{try{throw Error()}catch(G){g=G}r()}}catch(G){if(G&&g&&typeof G.stack=="string"){for(var p=G.stack.split(`
21
- `),x=g.stack.split(`
22
- `),P=p.length-1,j=x.length-1;P>=1&&j>=0&&p[P]!==x[j];)j--;for(;P>=1&&j>=0;P--,j--)if(p[P]!==x[j]){if(P!==1||j!==1)do if(P--,j--,j<0||p[P]!==x[j]){var Y=`
23
- `+p[P].replace(" at new "," at ");return typeof r=="function"&&he.set(r,Y),Y}while(P>=1&&j>=0);break}}}finally{Oe=!1,we.current=O,bt(),Error.prepareStackTrace=R}var ie=r?r.displayName||r.name:"",st=ie?de(ie):"";return typeof r=="function"&&he.set(r,st),st}function He(r,c,l){return Ge(r,!1)}function yt(r){var c=r.prototype;return!!(c&&c.isReactComponent)}function _e(r,c,l){if(r==null)return"";if(typeof r=="function")return Ge(r,yt(r));if(typeof r=="string")return de(r);switch(r){case _:return de("Suspense");case E:return de("SuspenseList")}if(typeof r=="object")switch(r.$$typeof){case h:return He(r.render);case S:return _e(r.type,c,l);case D:return He(r._render);case m:{var g=r,R=g._payload,O=g._init;try{return _e(O(R),c,l)}catch(y){}}}return""}var Je={},ze=b.ReactDebugCurrentFrame;function ge(r){if(r){var c=r._owner,l=_e(r.type,r._source,c?c.type:null);ze.setExtraStackFrame(l)}else ze.setExtraStackFrame(null)}function St(r,c,l,g,R){{var O=Function.call.bind(Object.prototype.hasOwnProperty);for(var y in r)if(O(r,y)){var p=void 0;try{if(typeof r[y]!="function"){var x=Error((g||"React class")+": "+l+" type `"+y+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof r[y]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw x.name="Invariant Violation",x}p=r[y](c,y,g,l,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(P){p=P}p&&!(p instanceof Error)&&(ge(R),C("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",g||"React class",l,y,typeof p),ge(null)),p instanceof Error&&!(p.message in Je)&&(Je[p.message]=!0,ge(R),C("Failed %s type: %s",l,p.message),ge(null))}}}var oe=b.ReactCurrentOwner,Ie=Object.prototype.hasOwnProperty,wt={key:!0,ref:!0,__self:!0,__source:!0},Xe,Ze,Te;Te={};function Rt(r){if(Ie.call(r,"ref")){var c=Object.getOwnPropertyDescriptor(r,"ref").get;if(c&&c.isReactWarning)return!1}return r.ref!==void 0}function Ot(r){if(Ie.call(r,"key")){var c=Object.getOwnPropertyDescriptor(r,"key").get;if(c&&c.isReactWarning)return!1}return r.key!==void 0}function It(r,c){if(typeof r.ref=="string"&&oe.current&&c&&oe.current.stateNode!==c){var l=q(oe.current.type);Te[l]||(C('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',q(oe.current.type),r.ref),Te[l]=!0)}}function Tt(r,c){{var l=function(){Xe||(Xe=!0,C("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",c))};l.isReactWarning=!0,Object.defineProperty(r,"key",{get:l,configurable:!0})}}function kt(r,c){{var l=function(){Ze||(Ze=!0,C("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",c))};l.isReactWarning=!0,Object.defineProperty(r,"ref",{get:l,configurable:!0})}}var Pt=function(r,c,l,g,R,O,y){var p={$$typeof:n,type:r,key:c,ref:l,props:y,_owner:O};return p._store={},Object.defineProperty(p._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(p,"_self",{configurable:!1,enumerable:!1,writable:!1,value:g}),Object.defineProperty(p,"_source",{configurable:!1,enumerable:!1,writable:!1,value:R}),Object.freeze&&(Object.freeze(p.props),Object.freeze(p)),p};function jt(r,c,l,g,R){{var O,y={},p=null,x=null;l!==void 0&&(p=""+l),Ot(c)&&(p=""+c.key),Rt(c)&&(x=c.ref,It(c,R));for(O in c)Ie.call(c,O)&&!wt.hasOwnProperty(O)&&(y[O]=c[O]);if(r&&r.defaultProps){var P=r.defaultProps;for(O in P)y[O]===void 0&&(y[O]=P[O])}if(p||x){var j=typeof r=="function"?r.displayName||r.name||"Unknown":r;p&&Tt(y,j),x&&kt(y,j)}return Pt(r,p,x,R,g,oe.current,y)}}var ke=b.ReactCurrentOwner,Qe=b.ReactDebugCurrentFrame;function ne(r){if(r){var c=r._owner,l=_e(r.type,r._source,c?c.type:null);Qe.setExtraStackFrame(l)}else Qe.setExtraStackFrame(null)}var Pe;Pe=!1;function je(r){return typeof r=="object"&&r!==null&&r.$$typeof===n}function et(){{if(ke.current){var r=q(ke.current.type);if(r)return`
17
+ */var lt;function pr(){return lt||(lt=1,process.env.NODE_ENV!=="production"&&function(){var r=D,s=Symbol.for("react.element"),e=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),d=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),v=Symbol.for("react.suspense"),E=Symbol.for("react.suspense_list"),y=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),_=Symbol.for("react.offscreen"),V=Symbol.iterator,C="@@iterator";function k(t){if(t===null||typeof t!="object")return null;var a=V&&t[V]||t[C];return typeof a=="function"?a:null}var B=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function P(t){{for(var a=arguments.length,l=new Array(a>1?a-1:0),h=1;h<a;h++)l[h-1]=arguments[h];de("error",t,l)}}function de(t,a,l){{var h=B.ReactDebugCurrentFrame,b=h.getStackAddendum();b!==""&&(a+="%s",l=l.concat([b]));var R=l.map(function(p){return String(p)});R.unshift("Warning: "+a),Function.prototype.apply.call(console[t],console,R)}}var f=!1,w=!1,M=!1,S=!1,N=!1,A;A=Symbol.for("react.module.reference");function W(t){return!!(typeof t=="string"||typeof t=="function"||t===i||t===c||N||t===n||t===v||t===E||S||t===_||f||w||M||typeof t=="object"&&t!==null&&(t.$$typeof===I||t.$$typeof===y||t.$$typeof===u||t.$$typeof===d||t.$$typeof===g||t.$$typeof===A||t.getModuleId!==void 0))}function J(t,a,l){var h=t.displayName;if(h)return h;var b=a.displayName||a.name||"";return b!==""?l+"("+b+")":l}function se(t){return t.displayName||"Context"}function G(t){if(t==null)return null;if(typeof t.tag=="number"&&P("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case i:return"Fragment";case e:return"Portal";case c:return"Profiler";case n:return"StrictMode";case v:return"Suspense";case E:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case d:var a=t;return se(a)+".Consumer";case u:var l=t;return se(l._context)+".Provider";case g:return J(t,t.render,"ForwardRef");case y:var h=t.displayName||null;return h!==null?h:G(t.type)||"Memo";case I:{var b=t,R=b._payload,p=b._init;try{return G(p(R))}catch(m){return null}}}return null}var z=Object.assign,te=0,T,F,re,he,Fe,qe,Ke;function Ge(){}Ge.__reactDisabledLog=!0;function pt(){{if(te===0){T=console.log,F=console.info,re=console.warn,he=console.error,Fe=console.group,qe=console.groupCollapsed,Ke=console.groupEnd;var t={configurable:!0,enumerable:!0,value:Ge,writable:!0};Object.defineProperties(console,{info:t,log:t,warn:t,error:t,group:t,groupCollapsed:t,groupEnd:t})}te++}}function Et(){{if(te--,te===0){var t={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:z({},t,{value:T}),info:z({},t,{value:F}),warn:z({},t,{value:re}),error:z({},t,{value:he}),group:z({},t,{value:Fe}),groupCollapsed:z({},t,{value:qe}),groupEnd:z({},t,{value:Ke})})}te<0&&P("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Oe=B.ReactCurrentDispatcher,Ie;function _e(t,a,l){{if(Ie===void 0)try{throw Error()}catch(b){var h=b.stack.trim().match(/\n( *(at )?)/);Ie=h&&h[1]||""}return`
18
+ `+Ie+t}}var Te=!1,ge;{var yt=typeof WeakMap=="function"?WeakMap:Map;ge=new yt}function Ye(t,a){if(!t||Te)return"";{var l=ge.get(t);if(l!==void 0)return l}var h;Te=!0;var b=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var R;R=Oe.current,Oe.current=null,pt();try{if(a){var p=function(){throw Error()};if(Object.defineProperty(p.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(p,[])}catch(H){h=H}Reflect.construct(t,[],p)}else{try{p.call()}catch(H){h=H}t.call(p.prototype)}}else{try{throw Error()}catch(H){h=H}t()}}catch(H){if(H&&h&&typeof H.stack=="string"){for(var m=H.stack.split(`
19
+ `),x=h.stack.split(`
20
+ `),j=m.length-1,L=x.length-1;j>=1&&L>=0&&m[j]!==x[L];)L--;for(;j>=1&&L>=0;j--,L--)if(m[j]!==x[L]){if(j!==1||L!==1)do if(j--,L--,L<0||m[j]!==x[L]){var q=`
21
+ `+m[j].replace(" at new "," at ");return t.displayName&&q.includes("<anonymous>")&&(q=q.replace("<anonymous>",t.displayName)),typeof t=="function"&&ge.set(t,q),q}while(j>=1&&L>=0);break}}}finally{Te=!1,Oe.current=R,Et(),Error.prepareStackTrace=b}var ne=t?t.displayName||t.name:"",ot=ne?_e(ne):"";return typeof t=="function"&&ge.set(t,ot),ot}function bt(t,a,l){return Ye(t,!1)}function St(t){var a=t.prototype;return!!(a&&a.isReactComponent)}function me(t,a,l){if(t==null)return"";if(typeof t=="function")return Ye(t,St(t));if(typeof t=="string")return _e(t);switch(t){case v:return _e("Suspense");case E:return _e("SuspenseList")}if(typeof t=="object")switch(t.$$typeof){case g:return bt(t.render);case y:return me(t.type,a,l);case I:{var h=t,b=h._payload,R=h._init;try{return me(R(b),a,l)}catch(p){}}}return""}var ve=Object.prototype.hasOwnProperty,He={},Je=B.ReactDebugCurrentFrame;function pe(t){if(t){var a=t._owner,l=me(t.type,t._source,a?a.type:null);Je.setExtraStackFrame(l)}else Je.setExtraStackFrame(null)}function Ct(t,a,l,h,b){{var R=Function.call.bind(ve);for(var p in t)if(R(t,p)){var m=void 0;try{if(typeof t[p]!="function"){var x=Error((h||"React class")+": "+l+" type `"+p+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof t[p]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw x.name="Invariant Violation",x}m=t[p](a,p,h,l,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(j){m=j}m&&!(m instanceof Error)&&(pe(b),P("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",h||"React class",l,p,typeof m),pe(null)),m instanceof Error&&!(m.message in He)&&(He[m.message]=!0,pe(b),P("Failed %s type: %s",l,m.message),pe(null))}}}var wt=Array.isArray;function ke(t){return wt(t)}function Rt(t){{var a=typeof Symbol=="function"&&Symbol.toStringTag,l=a&&t[Symbol.toStringTag]||t.constructor.name||"Object";return l}}function Ot(t){try{return ze(t),!1}catch(a){return!0}}function ze(t){return""+t}function Xe(t){if(Ot(t))return P("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Rt(t)),ze(t)}var oe=B.ReactCurrentOwner,It={key:!0,ref:!0,__self:!0,__source:!0},Ze,Qe,Pe;Pe={};function Tt(t){if(ve.call(t,"ref")){var a=Object.getOwnPropertyDescriptor(t,"ref").get;if(a&&a.isReactWarning)return!1}return t.ref!==void 0}function kt(t){if(ve.call(t,"key")){var a=Object.getOwnPropertyDescriptor(t,"key").get;if(a&&a.isReactWarning)return!1}return t.key!==void 0}function Pt(t,a){if(typeof t.ref=="string"&&oe.current&&a&&oe.current.stateNode!==a){var l=G(oe.current.type);Pe[l]||(P('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',G(oe.current.type),t.ref),Pe[l]=!0)}}function Nt(t,a){{var l=function(){Ze||(Ze=!0,P("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",a))};l.isReactWarning=!0,Object.defineProperty(t,"key",{get:l,configurable:!0})}}function jt(t,a){{var l=function(){Qe||(Qe=!0,P("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",a))};l.isReactWarning=!0,Object.defineProperty(t,"ref",{get:l,configurable:!0})}}var Lt=function(t,a,l,h,b,R,p){var m={$$typeof:s,type:t,key:a,ref:l,props:p,_owner:R};return m._store={},Object.defineProperty(m._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(m,"_self",{configurable:!1,enumerable:!1,writable:!1,value:h}),Object.defineProperty(m,"_source",{configurable:!1,enumerable:!1,writable:!1,value:b}),Object.freeze&&(Object.freeze(m.props),Object.freeze(m)),m};function Mt(t,a,l,h,b){{var R,p={},m=null,x=null;l!==void 0&&(Xe(l),m=""+l),kt(a)&&(Xe(a.key),m=""+a.key),Tt(a)&&(x=a.ref,Pt(a,b));for(R in a)ve.call(a,R)&&!It.hasOwnProperty(R)&&(p[R]=a[R]);if(t&&t.defaultProps){var j=t.defaultProps;for(R in j)p[R]===void 0&&(p[R]=j[R])}if(m||x){var L=typeof t=="function"?t.displayName||t.name||"Unknown":t;m&&Nt(p,L),x&&jt(p,L)}return Lt(t,m,x,b,h,oe.current,p)}}var Ne=B.ReactCurrentOwner,et=B.ReactDebugCurrentFrame;function ie(t){if(t){var a=t._owner,l=me(t.type,t._source,a?a.type:null);et.setExtraStackFrame(l)}else et.setExtraStackFrame(null)}var je;je=!1;function Le(t){return typeof t=="object"&&t!==null&&t.$$typeof===s}function tt(){{if(Ne.current){var t=G(Ne.current.type);if(t)return`
24
22
 
25
- Check the render method of \``+r+"`."}return""}}function Nt(r){{if(r!==void 0){var c=r.fileName.replace(/^.*[\\\/]/,""),l=r.lineNumber;return`
23
+ Check the render method of \``+t+"`."}return""}}function At(t){{if(t!==void 0){var a=t.fileName.replace(/^.*[\\\/]/,""),l=t.lineNumber;return`
26
24
 
27
- Check your code at `+c+":"+l+"."}return""}}var tt={};function Lt(r){{var c=et();if(!c){var l=typeof r=="string"?r:r.displayName||r.name;l&&(c=`
25
+ Check your code at `+a+":"+l+"."}return""}}var rt={};function Dt(t){{var a=tt();if(!a){var l=typeof t=="string"?t:t.displayName||t.name;l&&(a=`
28
26
 
29
- Check the top-level render call using <`+l+">.")}return c}}function rt(r,c){{if(!r._store||r._store.validated||r.key!=null)return;r._store.validated=!0;var l=Lt(c);if(tt[l])return;tt[l]=!0;var g="";r&&r._owner&&r._owner!==ke.current&&(g=" It was passed a child from "+q(r._owner.type)+"."),ne(r),C('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',l,g),ne(null)}}function nt(r,c){{if(typeof r!="object")return;if(Array.isArray(r))for(var l=0;l<r.length;l++){var g=r[l];je(g)&&rt(g,c)}else if(je(r))r._store&&(r._store.validated=!0);else if(r){var R=N(r);if(typeof R=="function"&&R!==r.entries)for(var O=R.call(r),y;!(y=O.next()).done;)je(y.value)&&rt(y.value,c)}}}function At(r){{var c=r.type;if(c==null||typeof c=="string")return;var l;if(typeof c=="function")l=c.propTypes;else if(typeof c=="object"&&(c.$$typeof===h||c.$$typeof===S))l=c.propTypes;else return;if(l){var g=q(c);St(l,r.props,"prop",g,r)}else if(c.PropTypes!==void 0&&!Pe){Pe=!0;var R=q(c);C("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",R||"Unknown")}typeof c.getDefaultProps=="function"&&!c.getDefaultProps.isReactClassApproved&&C("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Dt(r){{for(var c=Object.keys(r.props),l=0;l<c.length;l++){var g=c[l];if(g!=="children"&&g!=="key"){ne(r),C("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",g),ne(null);break}}r.ref!==null&&(ne(r),C("Invalid attribute `ref` supplied to `React.Fragment`."),ne(null))}}function it(r,c,l,g,R,O){{var y=z(r);if(!y){var p="";(r===void 0||typeof r=="object"&&r!==null&&Object.keys(r).length===0)&&(p+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var x=Nt(R);x?p+=x:p+=et();var P;r===null?P="null":Array.isArray(r)?P="array":r!==void 0&&r.$$typeof===n?(P="<"+(q(r.type)||"Unknown")+" />",p=" Did you accidentally export a JSX literal instead of a component?"):P=typeof r,C("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",P,p)}var j=jt(r,c,l,R,O);if(j==null)return j;if(y){var Y=c.children;if(Y!==void 0)if(g)if(Array.isArray(Y)){for(var ie=0;ie<Y.length;ie++)nt(Y[ie],r);Object.freeze&&Object.freeze(Y)}else C("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else nt(Y,r)}return r===t.Fragment?Dt(j):At(j),j}}function Mt(r,c,l){return it(r,c,l,!0)}function Vt(r,c,l){return it(r,c,l,!1)}var $t=Vt,xt=Mt;t.jsx=$t,t.jsxs=xt}()}(De)),De}(function(t){process.env.NODE_ENV==="production"?t.exports=_r():t.exports=gr()})(hr);const mr=xe.jsx;function vr(t){const s=L.createContext(null),e=vt(t),n=e.jsBridge,i=d=>mr(s.Provider,{value:e,children:d.children}),a=()=>{const d=L.useContext(s);if(!d)throw new Error("LiveProvider never found.");return d},u=()=>e,f=()=>e.$RTC,v=()=>f(),h=()=>async d=>await e.connect(d);function _(d,w,N=[]){const b=a(),C=[b,name,...N],M=()=>b.keyframes.off(d,w);return L.useEffect(()=>(b.keyframes.on(d,w),M),C),M}function E(){const d=a();return{connect:async T=>await d.connect(T),broadcast:async(T,W,re=0)=>await d.broadcast(T,W,re),exit:async()=>await d.exit(),kick:async T=>await d.kick(T),toggleMicro:T=>d.toggleMicro(T),forbidMicro:async(T,W=[])=>await d.forbidMicro(T,W),forbidSync:(T,W=[])=>d.forbidSync(T,W),sendKeyframe:(T,W)=>d.sendKeyframe(T,W),getFramesByKey:T=>d.getFramesByKey(T),setSelfInfo:T=>d.setSelfInfo(T),updateStatus:(T,W,re,fe)=>d.updateStatus(T,W,re,fe)}}function S(d){const w=a(),[N,b]=L.useState(w.getFramesByKey(d));L.useEffect(()=>{const M=le=>b(le),B=d,z=M;return w.keyframes.on(B,z),()=>w.keyframes.off(B,z)},[w]);const C=L.useCallback(M=>w.sendKeyframe(d,M),[w]);return[N,C]}function m(d,w,N=[]){const b=a(),C=()=>b.off(d,w),M=[b,d,...N];return L.useEffect(()=>(b.on(d,w),C),M),C}function D(){const d=a(),[w,N]=L.useState(d.state);return L.useEffect(()=>{const b=C=>N(C);return d.on("stateChange",b),()=>d.off("stateChange",b)},[d]),w}function V(){const d=a();return{join:B=>d.$RTC.join(B),quit:()=>d.$RTC.quit(),shock:()=>{var B,z;return(z=(B=d.$RTC).shock)==null?void 0:z.call(B)},toggleMicro:B=>d.$RTC.toggleMicro(B),detectMicro:()=>d.$RTC.detectMicro()}}function k(d,w,N=[]){const b=a(),C=()=>b.$RTC.off(d,w),M=[b,d,...N];return L.useEffect(()=>(b.$RTC.on(d,w),C),M),C}function H(){const d=a(),[w,N]=L.useState(d.selfInfo||{}),b=M=>N(M);L.useEffect(()=>(d.on("selfInfoUpdate",b),()=>d.off("selfInfoUpdate",b)),[d]);const C=L.useCallback(async M=>await d.setSelfInfo(M),[d]);return[w,C]}function J(){const d=a(),[w,N]=L.useState(d.snapshot);return L.useEffect(()=>{const b=C=>N(C);return d.on("keyframes",b),()=>d.off("keyframes",b)}),w}function I(){const d=a(),[w,N]=L.useState(d.userList),b=C=>N(C);return L.useEffect(()=>(d.on("userListUpdate",b),()=>d.off("userListUpdate",b)),[d]),w}return{live:e,jsBridge:n,LiveProvider:i,unsafe__useLiveInstance:u,unsafe__useRTCInstance:v,useConnect:h,useKeyframe:S,useKeyframeUpdateCallback:_,useLiveAction:E,useLiveEventCallback:m,useLiveState:D,useRTCAction:V,useRTCEventCallback:k,useSelfInfo:H,useKeyframesSnapshot:J,useUserList:I}}exports.BrowserRTC=Me;exports.BrowserRTC4Chime=Ve;exports.BuiltInRTCType=Ue;exports.BuiltinActionType=K;exports.BuiltinEventType=F;exports.Command=U;exports.CoreRTC=be;exports.LiveState=$;exports.MemUserStatus=dt;exports.MicroStatus=Q;exports.RTCJoinedInfoCodeEnum=Be;exports.RTCType=ee;exports.UserStatus=ft;exports.VRWebViewRTC=$e;exports.WebSocketCloseError=_t;exports.WebSocketErrorType=ht;exports.WebSocketState=pe;exports.createLive=vt;exports.createLiveReact=vr;exports.parseLiveMsg=zt;exports.parseWSClsErr=gt;
27
+ Check the top-level render call using <`+l+">.")}return a}}function it(t,a){{if(!t._store||t._store.validated||t.key!=null)return;t._store.validated=!0;var l=Dt(a);if(rt[l])return;rt[l]=!0;var h="";t&&t._owner&&t._owner!==Ne.current&&(h=" It was passed a child from "+G(t._owner.type)+"."),ie(t),P('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',l,h),ie(null)}}function nt(t,a){{if(typeof t!="object")return;if(ke(t))for(var l=0;l<t.length;l++){var h=t[l];Le(h)&&it(h,a)}else if(Le(t))t._store&&(t._store.validated=!0);else if(t){var b=k(t);if(typeof b=="function"&&b!==t.entries)for(var R=b.call(t),p;!(p=R.next()).done;)Le(p.value)&&it(p.value,a)}}}function Vt(t){{var a=t.type;if(a==null||typeof a=="string")return;var l;if(typeof a=="function")l=a.propTypes;else if(typeof a=="object"&&(a.$$typeof===g||a.$$typeof===y))l=a.propTypes;else return;if(l){var h=G(a);Ct(l,t.props,"prop",h,t)}else if(a.PropTypes!==void 0&&!je){je=!0;var b=G(a);P("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",b||"Unknown")}typeof a.getDefaultProps=="function"&&!a.getDefaultProps.isReactClassApproved&&P("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function $t(t){{for(var a=Object.keys(t.props),l=0;l<a.length;l++){var h=a[l];if(h!=="children"&&h!=="key"){ie(t),P("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",h),ie(null);break}}t.ref!==null&&(ie(t),P("Invalid attribute `ref` supplied to `React.Fragment`."),ie(null))}}function st(t,a,l,h,b,R){{var p=W(t);if(!p){var m="";(t===void 0||typeof t=="object"&&t!==null&&Object.keys(t).length===0)&&(m+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var x=At(b);x?m+=x:m+=tt();var j;t===null?j="null":ke(t)?j="array":t!==void 0&&t.$$typeof===s?(j="<"+(G(t.type)||"Unknown")+" />",m=" Did you accidentally export a JSX literal instead of a component?"):j=typeof t,P("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",j,m)}var L=Mt(t,a,l,b,R);if(L==null)return L;if(p){var q=a.children;if(q!==void 0)if(h)if(ke(q)){for(var ne=0;ne<q.length;ne++)nt(q[ne],t);Object.freeze&&Object.freeze(q)}else P("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else nt(q,t)}return t===i?$t(L):Vt(L),L}}function xt(t,a,l){return st(t,a,l,!0)}function Ut(t,a,l){return st(t,a,l,!1)}var Bt=Ut,Wt=xt;ce.Fragment=i,ce.jsx=Bt,ce.jsxs=Wt}()),ce}(function(r){process.env.NODE_ENV==="production"?r.exports=vr():r.exports=pr()})(mr);const Er=xe.jsx;function yr(r){const s=D.createContext(null),e=vt(r),i=e.jsBridge,n=f=>Er(s.Provider,{value:e,children:f.children}),c=()=>{const f=D.useContext(s);if(!f)throw new Error("LiveProvider never found.");return f},u=()=>e,d=()=>e.$RTC,g=()=>d(),v=()=>async f=>await e.connect(f);function E(f,w,M=[]){const S=c(),N=[S,name,...M],A=()=>S.keyframes.off(f,w);return D.useEffect(()=>(S.keyframes.on(f,w),A),N),A}function y(){const f=c();return{connect:async T=>await f.connect(T),broadcast:async(T,F,re=0)=>await f.broadcast(T,F,re),exit:async()=>await f.exit(),kick:async T=>await f.kick(T),toggleMicro:T=>f.toggleMicro(T),forbidMicro:async(T,F=[])=>await f.forbidMicro(T,F),forbidSync:(T,F=[])=>f.forbidSync(T,F),sendKeyframe:(T,F)=>f.sendKeyframe(T,F),getFramesByKey:T=>f.getFramesByKey(T),setSelfInfo:T=>f.setSelfInfo(T),updateStatus:(T,F,re,he)=>f.updateStatus(T,F,re,he)}}function I(f){const w=c(),[M,S]=D.useState(w.getFramesByKey(f));D.useEffect(()=>{const A=se=>S(se),W=f,J=A;return w.keyframes.on(W,J),()=>w.keyframes.off(W,J)},[w]);const N=D.useCallback(A=>w.sendKeyframe(f,A),[w]);return[M,N]}function _(f,w,M=[]){const S=c(),N=()=>S.off(f,w),A=[S,f,...M];return D.useEffect(()=>(S.on(f,w),N),A),N}function V(){const f=c(),[w,M]=D.useState(f.state);return D.useEffect(()=>{const S=N=>M(N);return f.on("stateChange",S),()=>f.off("stateChange",S)},[f]),w}function C(){const f=c();return{join:W=>f.$RTC.join(W),quit:()=>f.$RTC.quit(),shock:()=>{var W,J;return(J=(W=f.$RTC).shock)==null?void 0:J.call(W)},toggleMicro:W=>f.$RTC.toggleMicro(W),detectMicro:()=>f.$RTC.detectMicro()}}function k(f,w,M=[]){const S=c(),N=()=>S.$RTC.off(f,w),A=[S,f,...M];return D.useEffect(()=>(S.$RTC.on(f,w),N),A),N}function B(){const f=c(),[w,M]=D.useState(f.selfInfo||{}),S=A=>M(A);D.useEffect(()=>(f.on("selfInfoUpdate",S),()=>f.off("selfInfoUpdate",S)),[f]);const N=D.useCallback(async A=>await f.setSelfInfo(A),[f]);return[w,N]}function P(){const f=c(),[w,M]=D.useState(f.snapshot);return D.useEffect(()=>{const S=N=>M(N);return f.on("keyframes",S),()=>f.off("keyframes",S)}),w}function de(){const f=c(),[w,M]=D.useState(f.userList),S=N=>M(N);return D.useEffect(()=>(f.on("userListUpdate",S),()=>f.off("userListUpdate",S)),[f]),w}return{live:e,jsBridge:i,LiveProvider:n,unsafe__useLiveInstance:u,unsafe__useRTCInstance:g,useConnect:v,useKeyframe:I,useKeyframeUpdateCallback:E,useLiveAction:y,useLiveEventCallback:_,useLiveState:V,useRTCAction:C,useRTCEventCallback:k,useSelfInfo:B,useKeyframesSnapshot:P,useUserList:de}}exports.BrowserRTC=De;exports.BrowserRTC4Chime=Ve;exports.BuiltInRTCType=Ue;exports.BuiltinActionType=Y;exports.BuiltinEventType=K;exports.Command=U;exports.CoreRTC=Ce;exports.LiveState=$;exports.MemUserStatus=dt;exports.MicroStatus=Q;exports.RTCJoinedInfoCodeEnum=Be;exports.RTCType=ee;exports.UserStatus=ft;exports.VRWebViewRTC=$e;exports.WebSocketCloseError=_t;exports.WebSocketErrorType=ht;exports.WebSocketState=be;exports.createLive=vt;exports.createLiveReact=yr;exports.parseLiveMsg=Qt;exports.parseWSClsErr=gt;