@realsee/live 0.7.1 → 0.7.2

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.
Files changed (62) hide show
  1. package/dist/index.cjs.js +3 -41
  2. package/dist/index.cjs.js.map +1 -0
  3. package/dist/index.d.ts +5 -1336
  4. package/dist/index.es.js +6165 -0
  5. package/dist/index.es.js.map +1 -0
  6. package/dist/live/controller.d.ts +118 -0
  7. package/dist/live/createLive.d.ts +8 -0
  8. package/dist/live/createLiveReact.d.ts +54 -0
  9. package/dist/live/live.d.ts +200 -0
  10. package/dist/rtc/BrowserRTC.d.ts +39 -0
  11. package/dist/rtc/BrowserRTC4Chime.d.ts +60 -0
  12. package/dist/rtc/CoreRTC.d.ts +23 -0
  13. package/dist/rtc/VRWebViewRTC.d.ts +97 -0
  14. package/dist/rtc/index.d.ts +5 -0
  15. package/dist/typings/chime/AttendeeResponse.d.ts +5 -0
  16. package/dist/typings/chime/MeetingResponse.d.ts +12 -0
  17. package/dist/typings/chime/MeetingSessionConfigurationOptions.d.ts +16 -0
  18. package/dist/typings/chime/index.d.ts +3 -0
  19. package/dist/typings/index.d.ts +4 -0
  20. package/dist/typings/live/EventType.d.ts +74 -0
  21. package/dist/typings/live/GetVoiceSign.d.ts +52 -0
  22. package/dist/typings/live/LiveConnectOptions.d.ts +24 -0
  23. package/dist/typings/live/LiveErrorType.d.ts +9 -0
  24. package/dist/typings/live/LiveMsg.d.ts +133 -0
  25. package/dist/typings/live/LiveOptions.d.ts +79 -0
  26. package/dist/typings/live/LiveState.d.ts +15 -0
  27. package/dist/typings/live/RoomInfo.d.ts +13 -0
  28. package/dist/typings/live/UserInfo.d.ts +103 -0
  29. package/dist/typings/live/UserVolume.d.ts +7 -0
  30. package/dist/typings/live/WebSocket.d.ts +82 -0
  31. package/dist/typings/live/index.d.ts +10 -0
  32. package/dist/typings/react/RTCActionReactCallback.d.ts +2 -0
  33. package/dist/typings/react/index.d.ts +1 -0
  34. package/dist/typings/rtc/VRWebViewRTCOptions.d.ts +6 -0
  35. package/dist/typings/rtc/eventType.d.ts +44 -0
  36. package/dist/typings/rtc/index.d.ts +5 -0
  37. package/dist/typings/rtc/joinedInfo.d.ts +38 -0
  38. package/dist/typings/rtc/protocol.d.ts +77 -0
  39. package/dist/typings/rtc/type.d.ts +12 -0
  40. package/dist/utils/RobustWebSocket.d.ts +160 -0
  41. package/dist/utils/appendUri.d.ts +1 -0
  42. package/dist/utils/clientDetector.d.ts +4 -0
  43. package/dist/utils/equal.d.ts +10 -0
  44. package/dist/utils/isServer.d.ts +5 -0
  45. package/dist/utils/logger.d.ts +19 -0
  46. package/dist/utils/subscribe.d.ts +75 -0
  47. package/dist/utils/uuid.d.ts +4 -0
  48. package/docs/classes/CoreRTC.md +7 -7
  49. package/docs/classes/Live.md +29 -56
  50. package/docs/globals.md +0 -6
  51. package/docs/interfaces/RTCProtocol.md +6 -6
  52. package/package.json +16 -21
  53. package/dist/index.d.cts +0 -1336
  54. package/dist/index.esm.js +0 -10
  55. package/docs/classes/Subscribe.md +0 -211
  56. package/docs/namespaces/SubscribeMixinType/README.md +0 -17
  57. package/docs/namespaces/SubscribeMixinType/interfaces/emit.md +0 -31
  58. package/docs/namespaces/SubscribeMixinType/interfaces/hasListener.md +0 -25
  59. package/docs/namespaces/SubscribeMixinType/interfaces/off.md +0 -31
  60. package/docs/namespaces/SubscribeMixinType/interfaces/on.md +0 -37
  61. package/docs/namespaces/SubscribeMixinType/interfaces/once.md +0 -35
  62. package/docs/type-aliases/EventMap.md +0 -17
package/dist/index.esm.js DELETED
@@ -1,10 +0,0 @@
1
- import vt from 'trtc-js-sdk';
2
- import { ConsoleLogger, LogLevel, DefaultDeviceController, MeetingSessionConfiguration, DefaultMeetingSession, DefaultModality, MeetingSessionStatusCode } from 'amazon-chime-sdk-js';
3
- import Ys from '@realsee/jsbridge-x';
4
- import D, { createContext, useCallback } from 'react';
5
-
6
- var Ee=Symbol("$$REALSEE_LIVE_EVENT$$");function $e(n){return n[Ee]||(n[Ee]={}),n[Ee]}function ti(n){n[Ee]?.length||delete n[Ee];}var M=class{hasListener(e){let t=$e(this);return t&&t[e]&&t[e].length>0}on(e,t,r){let i=$e(this);return i[e]||(i[e]=[]),i[e].push([t,r||!1]),()=>this.off(e,t)}once(e,t){return this.on(e,t,!0)}off(e,t){let r=$e(this);if(!e){ti(this);return}if(r[e]||(r[e]=[]),t===void 0){r[e].length=0;return}let i=r[e].findIndex(s=>s[0]===t);i!==-1&&r[e].splice(i,1);}emit(e,...t){let r=!1,s=$e(this)[e]||[];for(let o of s.slice()){let[c,a=!1]=o,l=c(...t);a&&this.off(e,c),l===!1&&(r=!0);}return r}};var q=class extends M{};var ni=(r=>(r.RealseeBrowserRTC="RealseeBrowserRTC",r.RealseeVRWebViewRTC="RealseeVRWebViewRTC",r.RealseeBrowserChimeRTC="RealseeBrowserChimeRTC",r))(ni||{}),ri=(t=>(t.RealseeXTRTC="trtc",t.RealseeXChimeRTC="chime",t))(ri||{});var ii=()=>{let n=new Date,e=n.getFullYear(),t=(n.getMonth()+1).toString().padStart(2,"0"),r=n.getDate().toString().padStart(2,"0"),i=n.getHours().toString().padStart(2,"0"),s=n.getMinutes().toString().padStart(2,"0"),o=n.getSeconds().toString().padStart(2,"0"),c=n.getMilliseconds().toString().padStart(3,"0");return `[${e}-${t}-${r} ${i}:${s}:${o}.${c}]`};var ke=(n,e=[])=>{let t=`Realsee Live ${ii()} <${n}> `;switch(n){case"INFO":console.info(t,...e);break;case"ERROR":console.error(t,...e);break;case"WARN":console.warn(t,...e);break;case"DEBUG":console.debug(t,...e);break;default:console.log(t,...e);}},si={log:(...n)=>ke("LOG",n),info:(...n)=>ke("INFO",n),error:(...n)=>ke("ERROR",n),warn:(...n)=>ke("WARN",n),debug:(...n)=>ke("DEBUG",n)},p=si;function Y(){return ((1+Math.random())*65536|0).toString(16).substring(1)}function X(){return [Y(),Y(),"4"+Y().substring(0,3),Y(),Y(),Y()+Y()+Y()].join("-").toLowerCase()}var Ce=class extends q{type="RealseeBrowserRTC";joined=!1;micro=!1;voiceId="";_getVoiceSign=()=>{throw new Error("\u65B9\u6CD5 getVoiceSign \u672A\u5B9E\u73B0")};_autoPlayConfirm;checkRequirement=()=>vt.checkSystemRequirements();$dom=document.createElement("div");_trtc={client:null,stream:null};constructor(e){super(),this._getVoiceSign=e.getVoiceSign,this._autoPlayConfirm=e.autoPlayConfirm,this._initParentDom();}_initParentDom(){this.$dom.id=`rs-rtc-${X()}`,this.$dom.style.display="none",document.body.appendChild(this.$dom);}join=async e=>{this.emit("joinWillStart");let t=await this._getVoiceSign({voiceId:e.voiceId,roomId:e.roomId,userId:e.userId});this._trtc.client=vt.createClient({mode:"rtc",...t,enableAutoPlayDialog:typeof this._autoPlayConfirm!="function"}),this._trtc.client?.enableAudioVolumeEvaluation(),this._registerRtcEvent();let r=await new Promise(i=>{this._trtc.client?.join({roomId:Number(e.voiceId)}).then(()=>i(!0)).catch(()=>i(!1));});return this.joined=r,r?(this._trtc.stream=vt.createStream({userId:t.userId,audio:!0,video:!1}),r=await new Promise(i=>{this._trtc.stream?.initialize().then(()=>i(!0)).catch(()=>i(!1));}),r=await new Promise(i=>{this._trtc.client?.publish(this._trtc.stream).then(()=>i(!0)).catch(()=>i(!1));}),this.joined=r,this.joined&&this.emit("joined"),r):!1};quit(){return new Promise(async e=>{this.joined=!1,this._trtc.stream&&(await this._trtc.client?.unpublish(this._trtc.stream),this._trtc.stream.stop(),this._trtc.stream.close(),this._trtc.stream=null),this._trtc.client?.leave().then(()=>this._trtc.client=null).then(()=>e(!0)).catch(()=>e(!1)),e(!0);})}detectMicro(){return new Promise(e=>{let t={audio:!0,video:!1};try{navigator.mediaDevices.getUserMedia(t).then(()=>e(!0)).catch(r=>{p.error(r.message),e(!1);});}catch(r){console.error(r),e(!1);}})}toggleMicro(e){return Promise.resolve((e?this._trtc?.stream?.unmuteAudio():this._trtc?.stream?.muteAudio())||!1)}shock(){throw new Error("Method not implemented.")}_registerRtcEvent(){this._trtc.client?.on("stream-added",this._handleStreamAdded),this._trtc.client?.on("stream-subscribed",this._handleStreamSubscribed),this._trtc.client?.on("audio-volume",e=>this.emit("userVolumes",e.result.map(({userId:t,audioVolume:r})=>({userId:t,audioVolume:r})))),this._trtc.client?.on("error",e=>this.emit("error",e));}_handleStreamAdded=e=>{let t=e.stream;console.log("\u8FDC\u7AEF\u6D41\u589E\u52A0: "+t.getId()),this._trtc.client?.subscribe(t);};_handleStreamSubscribed=e=>{let t=e.stream;console.log("\u8FDC\u7AEF\u6D41\u8BA2\u9605\u6210\u529F\uFF1A"+t.getId());let i=`rs-rtc-remote_stream-${t.getId()}`,s=document.createElement("div");s.id=i,this.$dom.appendChild(s),typeof this._autoPlayConfirm=="function"?(t.play(i).catch(o=>{}),t.on("error",o=>{if(o.getCode()===16451){let a=()=>t.resume();this._autoPlayConfirm({onConfirm:a});}})):t.play(i);}};var ue=class extends q{type="RealseeBrowserChimeRTC";joined=!1;micro=!1;voiceId="";userId="";logger;deviceController;meetingSession;audioInput;audioOutput;deviceChangeObserver={};audioVideoObserver={};audioMixObserver;_getVoiceSign=()=>{throw new Error("\u65B9\u6CD5 getVoiceSign \u672A\u5B9E\u73B0")};_autoPlayConfirm;$dom=document.createElement("div");$audio=document.createElement("audio");constructor(e){super(),this._getVoiceSign=e.getVoiceSign,this._autoPlayConfirm=e.autoPlayConfirm,this._initDom(),this.logger=new ConsoleLogger("WebRTCLogger",e.logLevel||LogLevel.INFO),this.deviceController=new DefaultDeviceController(this.logger),this.initObservers();}_initDom=()=>{this.$audio.id=`rs-rtc-${X()}`,this.$dom.id=`rs-rtc-${X()}`,this.$dom.appendChild(this.$audio),document.body.appendChild(this.$dom);};initObservers=()=>{this.deviceChangeObserver={audioInputsChanged:e=>{this.logger.info(`audioInputsChanged ${typeof e}`),e?.forEach(t=>{this.logger.info(`Device ID: ${t.deviceId} Microphone: ${t.label}`);});},audioOutputsChanged:e=>{this.logger.info(`audioOutputsChanged ${typeof e}`),e?.forEach(t=>{this.logger.info(`Device ID: ${t.deviceId} Speaker: ${t.label}`);});},audioInputMuteStateChanged:(e,t)=>{this.logger.info(`Device ${e.toString()} ${t?"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){let t=()=>this.$audio.play().then(()=>{}).catch(r=>{if(p.error("\u64AD\u653E\u8FDC\u7AEF\u6D41\u5931\u8D25\uFF01",r),typeof this._autoPlayConfirm=="function"){let i=()=>t();this._autoPlayConfirm({onConfirm:i});}});t();}},meetingAudioStreamBecameInactive:e=>{}};};async join(e){return new Promise(async(t,r)=>{this.emit("joinWillStart");try{let{sdkAppId:i,userId:s,roomId:o,userSig:c}=await this._getVoiceSign({...e,roomId:e.roomId||0});this.userId=s;let{attendence:a,vendor_wrapper:l}=JSON.parse(decodeURIComponent(c)),d=new MeetingSessionConfiguration({Meeting:l},{Attendee:{ExternalUserId:a.external_user_id,AttendeeId:a.attendee_id,JoinToken:a.join_token}});this.meetingSession=new DefaultMeetingSession(d,this.logger,this.deviceController),this._registerRtcEvent(),this.meetingSession.audioVideo.addDeviceChangeObserver(this.deviceChangeObserver),this.meetingSession.audioVideo.addObserver(this.audioVideoObserver),this.meetingSession.audioVideo.bindAudioElement(this.$audio);let u={audioVideoDidStart:()=>{this.meetingSession?.audioVideo.realtimeMuteLocalAudio(),this.joined=!0,this.emit("joined"),t(!0);},audioVideoDidStop:()=>{this.joined=!1,t(!1);}};this.meetingSession.audioVideo.addObserver(u),this.audioMixObserver&&this.meetingSession.audioVideo.addAudioMixObserver(this.audioMixObserver),this.meetingSession.audioVideo.setDeviceLabelTrigger(async()=>await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}));try{let g=await this.meetingSession.audioVideo.listAudioInputDevices();p.info("audioInputDevices ===>",g);let f=g[0]?.deviceId||"default";await this.meetingSession.audioVideo.startAudioInput(f);}catch(g){p.error(`\u8BBE\u7F6E\u8BED\u97F3\u8F93\u5165\u8BBE\u5907\u5931\u8D25:${g.message}`);}try{let g=await this.meetingSession.audioVideo.listAudioOutputDevices();p.info("audioOutputDevices ===>",g);let f=g[0]?.deviceId||"default";await this.meetingSession.audioVideo.chooseAudioOutput(f);}catch(g){p.error(`\u8BBE\u7F6E\u8BED\u97F3\u8F93\u51FA\u8BBE\u5907\u5931\u8D25:${g.message}`);}this.meetingSession.audioVideo.start();}catch(i){this.emit("error",i),this.logger.error(i.message),t(!1);}})}_registerRtcEvent=()=>{let e=this.meetingSession?.configuration?.credentials?.attendeeId||"";if(e){let t=new Map,r=()=>{let i=[];return t.forEach((s,o)=>{i.push({userId:s.userId,volume:s.muted||s.signalStrength===0||!s.volume?0:s.volume});}),i};this.meetingSession?.audioVideo.realtimeSubscribeToAttendeeIdPresence((i,s,o)=>{if(!s){t.delete(i),this.emit("userVolumes",r());return}this.meetingSession?.audioVideo.realtimeSubscribeToVolumeIndicator(i,(c,a,l,d)=>{new DefaultModality(c).base()===c&&(t.set(c,{userId:o||c,volume:a,muted:l,signalStrength:d}),this.emit("userVolumes",r()));});}),this.meetingSession?.audioVideo.realtimeSubscribeToVolumeIndicator(e,(i,s,o,c)=>{new DefaultModality(i).base()===i&&c!==null&&c!==1&&this.emit("weakNetwork");}),this.meetingSession?.audioVideo.realtimeSubscribeToFatalError(i=>this.emit("error",i));}};quit(){return this.joined?new Promise((e,t)=>{this.joined=!1;let r={audioVideoDidStop:async i=>{let s=i.statusCode();this.meetingSession?.deviceController.destroy(),s===MeetingSessionStatusCode.Left?(this.logger.info("You left the session"),e(!0)):(this.logger.info(`Stopped with a session status code: ${s}`),e(!0));}};this.meetingSession?.audioVideo.addObserver(r),this.meetingSession?.audioVideo.stop();}):Promise.resolve(!0)}async detectMicro(){return new Promise(e=>{let t={audio:!0,video:!1};try{navigator.mediaDevices.getUserMedia(t).then(()=>e(!0)).catch(()=>e(!1));}catch(r){this.logger.error(r.message),e(!1);}})}async toggleMicro(e){e?this.meetingSession?.audioVideo.realtimeUnmuteLocalAudio():this.meetingSession?.audioVideo.realtimeMuteLocalAudio();let t=this.meetingSession?.audioVideo.realtimeIsLocalAudioMuted();return t!==void 0?e!==t:!1}shock(){throw new Error("Method not implemented.")}};var ui=(s=>(s[s.Success=0]="Success",s[s.Failure=1]="Failure",s[s.ReJoin=2]="ReJoin",s[s.NoMicroPermission=3]="NoMicroPermission",s[s.Unknown=500]="Unknown",s))(ui||{});var xe=class extends q{type="RealseeVRWebViewRTC";joined=!1;micro=!1;voiceId="";_joinOptions=null;options;get jsBridge(){return this.options.jsBridge}constructor({jsBridge:e,getVoiceSign:t}){super(),this.options={jsBridge:e,getVoiceSign:t},this.jsBridge.webViewType!=="WxMiniProgramWebView"&&this.jsBridge.callAndListen("live/userVolumes",this.handleUserVolumes),this.jsBridge.callAndListen("live/weakNetwork",this.handleWeakNetwork),this.on("inner.rtc.fail",this.handleJoinResult);}handleUserVolumes=e=>{this.emit("userVolumes",e);};handleWeakNetwork=e=>{e&&this.emit("weakNetwork");};join=async e=>{this._joinOptions=e,this.emit("joinWillStart");let{sdkAppId:t,userId:r,userSig:i}=await this.getVoiceSignOrEmitError(e);return !t||!r||!i?!1:(this.type=e.type,this.jsBridge.webViewType==="WxMiniProgramWebView"?this.handleWxMiniProgramWebViewJoin({sdkAppId:t,userId:r,userSig:i,voiceId:e.voiceId}):this.handleAppWebViewJoin({sdkAppId:t,userId:r,userSig:i,voiceId:e.voiceId}))};reJoin=async()=>this._joinOptions?this.join({voiceId:this._joinOptions.voiceId,userId:this._joinOptions.userId,roomId:this._joinOptions.roomId,type:this._joinOptions.type}):(this.emitErrorAndSetJoinedFalse("\u91CD\u8FDE\u5931\u8D25\uFF1A\u672A\u627E\u5230\u52A0\u5165\u623F\u95F4\u53C2\u6570\u3002"),!1);getVoiceSignOrEmitError=async e=>{try{return await this.options.getVoiceSign(e)}catch{return this.emitErrorAndSetJoinedFalse("\u52A0\u5165\u623F\u95F4\u5931\u8D25\uFF1Artc \u7B7E\u540D\u8BF7\u6C42\u5F02\u5E38"),{}}};handleWxMiniProgramWebViewJoin=async e=>{let[t,r]=await this.joinRoomOrEmitError(e);return r?!1:this.handleJoinResult(t)};handleAppWebViewJoin=e=>new Promise(t=>{this.off("inner.rtc.success");let r=i=>{this.off("inner.rtc.fail",r),this.off("inner.rtc.success",r),t(this.handleJoinResult(i));};this.once("inner.rtc.fail",r),this.once("inner.rtc.success",r);try{let{sdkAppId:i,userId:s,userSig:o,voiceId:c}=e;this.jsBridge.callAndListen(`live/join?sdkAppID=${i}&userID=${s}&roomID=${c}&userSig=${o}`,a=>{a===!0?this.emit("inner.rtc.success",a):typeof a=="object"?a.code===0||a.code===2?this.emit("inner.rtc.success",a):this.emit("inner.rtc.fail",a):this.emit("inner.rtc.fail",a);});}catch(i){t(this.handleJoinResult({message:i.message,code:500}));}});joinRoomOrEmitError=async({sdkAppId:e,userId:t,voiceId:r,userSig:i})=>{try{return await this.jsBridge.callAndBackfeed(`live/join?sdkAppID=${e}&userID=${t}&roomID=${Number(r)}&userSig=${i}`)}catch(s){return this.emitErrorAndSetJoinedFalse("\u52A0\u5165\u623F\u95F4\u5931\u8D25\uFF1A"+s.message),[null,s]}};handleJoinResult=e=>{switch(!0){case e===!0:case(typeof e=="object"&&e.code===0):case(typeof e=="object"&&e.code===2):{this.emit("joined"),this.joined=!0;break}default:{this.joined=!1;let t=typeof e=="object"?e.message:"\u52A0\u5165\u623F\u95F4\u5931\u8D25\uFF1A\u672A\u77E5\u5F02\u5E38\u3002";this.emit("error",new Error(t,{cause:e}));}}return this.joined};emitErrorAndSetJoinedFalse=e=>{this.emit("error",new Error(e)),this.joined=!1;};quit=async()=>{let[e,t]=await this.jsBridge.callAndBackfeed("live/quit");return e===null&&this.emit("error",t||new Error("\u9000\u51FA\u623F\u95F4\u5931\u8D25\uFF1A\u672A\u77E5\u5F02\u5E38\u3002")),this.joined=!1,!!e};detectMicro=async()=>{let[e,t]=await this.jsBridge.detectMicro();return e===null?(this.emit("error",t||new Error("\u9EA6\u514B\u98CE\u76D1\u6D4B\u5F02\u5E38\uFF01")),!1):e};toggleMicro=async e=>{let[t,r]=await this.jsBridge.callAndBackfeed(`live/toggleMicro?flag=${e?1:0}`);return t===null?(this.emit("error",r||new Error("\u9EA6\u514B\u98CE\u76D1\u6D4B\u5F02\u5E38\uFF01")),!1):(this.micro=t,t)};shock=()=>{this.jsBridge.shock(1);}};var fi=(a=>(a.SelfUserInfo="SELF_USER_INFO",a.RoomInfo="ROOM_INFO",a.RTCInfo="RTC_INFO",a.UserList="USER_LIST",a.BuiltinMsg="BUILTIN_MSG",a.CustomEvent="CUSTOM_EVENT",a.KeyframeSync="KEYFRAME_SYNC",a.UserKickOut="USER_KICK_OUT",a))(fi||{}),gi=(t=>(t.UserChange="user_change",t.RoomChange="room_change",t))(gi||{}),pi=(o=>(o.UserMicroStatus="change_micro_status",o.UserMicroStatusSync="sync_micro_status",o.UserPermission="change_permission",o.UserStatus="change_status",o.UserInfo="change_info",o.RoomClose="close",o))(pi||{}),mi=(t=>(t.OPEN="OPEN",t.CLOSE="CLOSE",t))(mi||{});function Ro(n){try{let e=JSON.parse(n),t={code:e.code,message:e.message,command:e.command,roomCode:e.room_code,appID:e.app_id,requestId:e.request_id,frontRequestId:e.front_request_id,triggerUserID:e.trigger_user_id,data:e.data||{}},r=Object.keys(t).filter(i=>t[i]===void 0);return r.length>0&&console.warn(`\u63A8\u9001\u6570\u636E\u683C\u5F0F\u5F02\u5E38\uFF1A${r.join(" ")} \u503C\u4E0D\u5B58\u5728\uFF01`),t}catch{return !1}}var yi=(i=>(i[i.NOTINITIALIZED=-1]="NOTINITIALIZED",i[i.CONNECTING=0]="CONNECTING",i[i.OPEN=1]="OPEN",i[i.CLOSED=3]="CLOSED",i))(yi||{});var wi=(r=>(r[r.Normal=0]="Normal",r[r.Removed=1]="Removed",r[r.Replaced=2]="Replaced",r))(wi||{}),_i=(o=>(o.WAIT_ENTER="WAIT_ENTER",o.ONLINE="ONLINE",o.LEAVE="LEAVE",o.KICK_OUT="KICK_OUT",o.BE_REPLACE="BE_REPLACE",o.EXCEPTION="EXCEPTION",o))(_i||{});var bi=(s=>(s[s.NOTINITIALIZED=-1]="NOTINITIALIZED",s[s.CONNECTING=0]="CONNECTING",s[s.OPEN=1]="OPEN",s[s.CLOSING=2]="CLOSING",s[s.CLOSED=3]="CLOSED",s))(bi||{}),Si=(c=>(c.Error="Error",c.Close="Close",c.MicroAuth="MicroAuth",c.DuplicateConnect="DuplicateConnect",c.IllegalURL="IllegalURL",c.Unknown="Unknown",c.IllegalArgs="IllegalArgs",c))(Si||{}),vi=(l=>(l.Err_1000="CLOSE_NORMAL",l.Err_1001="CLOSE_GOING_AWAY",l.Err_1002="CLOSE_PROTOCOL_ERROR",l.Err_1003="CLOSE_UNSUPPORTED",l.Err_1006="CLOSE_ABNORMAL",l.Err_1007="Unsupported Data",l.Err_1008="Policy Violation",l.Err_1009="CLOSE_TOO_LARGE",l.Err_unknown="unknown",l))(vi||{});function bn(n){switch(n){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 Sn(n,e={}){let t=new URL(n,"http://localhost"),r=new URLSearchParams(t.search);return Object.entries(e).forEach(([i,s])=>{r.append(i,String(s));}),n.split("?")[0]+"?"+r.toString()}var vn=(()=>{let n=typeof process<"u"&&process.versions?.node!=null;return typeof window<"u"&&"Deno"in window||n||typeof window>"u"})();var Ie=vn?"":navigator.userAgent,En=/android/i.test(Ie),kn=/iPhone|iPad\s+OS/i.test(Ie),Cn=/MicroMessenger/i.test(Ie)&&/miniProgram/i.test(Ie),xn=/realsee/i.test(Ie);function Ge(n){return Object.prototype.toString.call(n)==="[object Object]"}function qe(n,e){return n===e?!0:n==null||e==null||typeof n!=typeof e?!1:Number.isNaN(n)&&Number.isNaN(e)}function Ei(n,e){if(n===e)return !0;if(n==null||e==null)return !1;let t=Object.keys(n),r=Object.keys(e);return t.length!==r.length?!1:t.every(i=>qe(n[i],e[i]))}function ki(n,e){return n===e?!0:n==null||e==null||n.length!==e.length?!1:n.every((t,r)=>qe(t,e[r]))}function Ci(n,e){return qe(n,e)?!0:Ge(n)&&Ge(e)?Ei(n,e):Array.isArray(n)&&Array.isArray(e)?ki(n,e):!1}function Et(n,e){return qe(n,e)?!0:Ge(n)&&Ge(e)?Ii(n,e):Array.isArray(n)&&Array.isArray(e)?xi(n,e):!1}function xi(n,e){if(n.length!==e.length)return !1;for(let t=0,r=n.length;t<r;t++)if(!Et(n[t],e[t]))return !1;return !0}function Ii(n,e){if(n===e)return !0;if(n==null||e==null)return !1;let t=Object.keys(n),r=Object.keys(e);return t.length!==r.length?!1:t.every(i=>Et(n[i],e[i]))}function In(n,e,t={deep:!1}){return t.deep?Et(n,e):Ci(n,e)}var Je=class extends M{_realWebSocket;_url;_protocols;_readyState=-1;_options={timeout:1e4,shouldReconnect:(e,t)=>{if(!(e.code===1008||e.code===1011))return [0,1e3,2e3][t.attempts%3]},should1000Reconnect:!1,ignoreConnectivityEvents:!1,automaticOpen:!1};_connectTimeout;_attempts=0;_reconnects=-1;_reconnectWhenOnlineAgain=!1;_explicitlyClosed=!1;_pendingReconnect;_connectivityEventsAttached=!1;_heathCheckTimer;get attempts(){return this._attempts}constructor(e){super(),e&&this.setOptions(e),this._startHealthCheck();}setOptions(e){if(!e)return;this._url=e.url,this._protocols=e.protocols;let t=Object.assign(this._options,e.robustOptions||{});if(typeof t?.timeout!="number")throw new Error("timeout must be the number of milliseconds to timeout a connection attempt");if(typeof t?.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=t,this._options.automaticOpen&&this._createWebSocket();}_healthCheck=async()=>{if(this._realWebSocket){let e=this._realWebSocket.readyState;e!==this._readyState&&(this._readyState=e,this._readyState===2&&this.emit("closing"));}await new Promise(e=>setTimeout(e,2e3)),this._heathCheckTimer=requestAnimationFrame(this._healthCheck);};_clearConnectTimeoutIfNeed=()=>{this._connectTimeout&&(clearTimeout(this._connectTimeout),this._connectTimeout=void 0);};_clearHeathCheckIfNeed=()=>{this._heathCheckTimer&&(cancelAnimationFrame(this._heathCheckTimer),this._heathCheckTimer=void 0);};_startHealthCheck=()=>{this._clearHeathCheckIfNeed(),this._heathCheckTimer=requestAnimationFrame(this._healthCheck);};_stopHealthCheck=()=>{this._clearHeathCheckIfNeed();};_clearPendingReconnectIfNeeded=()=>{this._pendingReconnect&&(clearTimeout(this._pendingReconnect),this._pendingReconnect=void 0);};_online=e=>{this._reconnectWhenOnlineAgain&&(this._clearPendingReconnectIfNeeded(),this._reconnect(e));};_offline=()=>{this._reconnectWhenOnlineAgain=!0,this._realWebSocket?.close(1e3,"offline");};_detachConnectivityEvents=()=>{this._connectivityEventsAttached&&(globalThis?.removeEventListener("online",this._online),globalThis?.removeEventListener("offline",this._offline),this._connectivityEventsAttached=!1);};_attachConnectivityEvents=()=>{this._connectivityEventsAttached||(globalThis?.addEventListener("online",this._online),globalThis?.addEventListener("offline",this._offline),this._connectivityEventsAttached=!0);};send=e=>{this._realWebSocket?.readyState===this._realWebSocket?.OPEN&&this._realWebSocket?.send(e);};close=(e,t)=>(typeof e!="number"&&(t=e,e=1e3),this._clearPendingReconnectIfNeeded(),this._reconnectWhenOnlineAgain=!1,this._explicitlyClosed=!0,this._detachConnectivityEvents(),this._realWebSocket?.close(e,t));open=e=>{e&&(this._url=e),this._realWebSocket?.readyState!==WebSocket.OPEN&&this._realWebSocket?.readyState!==WebSocket.CONNECTING&&(this._clearPendingReconnectIfNeeded(),this._reconnectWhenOnlineAgain=!1,this._explicitlyClosed=!1,this._createWebSocket());};_createWebSocket=()=>{let e=typeof this._url=="string"?this._url:this._url?.(this);if(!e)return;this._clearConnectTimeoutIfNeed(),this._clearPendingReconnectIfNeeded(),this._removeWebSocketEvent(),this._realWebSocket=new WebSocket(e,this._protocols||void 0),this._attempts++,this.emit("connecting",new CustomEvent("connecting",{detail:{attempts:this._attempts,reconnects:this._reconnects}}));let t=()=>{this._connectTimeout=void 0,this._detachConnectivityEvents(),this.emit("timeout",new CustomEvent("timeout",{detail:{attempts:this._attempts,reconnects:this._reconnects}}));};this._connectTimeout=setTimeout(t,this._options.timeout),this._dispatchWebSocketEvent(),this._options.ignoreConnectivityEvents||this._attachConnectivityEvents();};_removeWebSocketEvent=()=>{this._realWebSocket?.removeEventListener("open",this._webSocketOpenHandler),this._realWebSocket?.removeEventListener("close",this._webSocketCloseHandler),this._realWebSocket?.removeEventListener("error",this._webSocketErrorHandler),this._realWebSocket?.removeEventListener("message",this._webSocketMessageHandler);};_dispatchWebSocketEvent=()=>{this._realWebSocket?.addEventListener("open",this._webSocketOpenHandler),this._realWebSocket?.addEventListener("close",this._webSocketCloseHandler),this._realWebSocket?.addEventListener("error",this._webSocketErrorHandler),this._realWebSocket?.addEventListener("message",this._webSocketMessageHandler);};_webSocketOpenHandler=e=>{this._connectTimeout&&(clearTimeout(this._connectTimeout),this._connectTimeout=void 0);let t=++this._reconnects,r=this._attempts;return this._attempts=0,this._reconnectWhenOnlineAgain=!1,this._startHealthCheck(),this.emit("open",Object.assign(e,{detail:{reconnects:t,attempts:r}}))};_webSocketCloseHandler=e=>(this._reconnect(e),this._stopHealthCheck(),this.emit("close",e));_webSocketErrorHandler=e=>this.emit("error",new CustomEvent("error",{detail:{error:e}}));_webSocketMessageHandler=e=>this.emit("message",e);_reconnect(e){if(!this._options.should1000Reconnect&&e.code===1e3||this._explicitlyClosed){this._attempts=0;return}if(this._connectivityEventsAttached&&globalThis?.navigator?.onLine===!1){this._reconnectWhenOnlineAgain=!0;return}let i=this._options.shouldReconnect?.(e,this);typeof i=="number"?(console.log(`Reconnecting in ${i}ms...`),this._pendingReconnect=setTimeout(this._createWebSocket,i)):console.log("No reconnection will be attempted.");}};var He=class extends M{_ws=new Je({url:"",robustOptions:{should1000Reconnect:!0,ignoreConnectivityEvents:!0}});_state=-1;set state(e){let t=JSON.parse(JSON.stringify(this._state));this._state=e,this.emit("stateChange",this.state,t);}get state(){return this._state}constructor(){super(),this._addWebSocketEventListeners();}_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);};_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);};_handleCloseEvent=e=>{p.info(`live room closed bacause of ${e.code}-${e.reason||bn(e.code)}`),this.state=3;};_handleClosingEvent=()=>{p.info("live room is closing, onLine:",globalThis?.navigator?.onLine),this.state=3;};_handleConnectingEvent=e=>{p.info("live room is connecting"),this.state=0,e.detail.reconnects>0&&this.emit("reconnecting",e.detail);};_handleErrorEvent=e=>{p.error("live room error",e),this.state=3;};_handleMessageEvent=e=>{let t=(()=>{try{return JSON.parse(e.data)}catch{return e.data}})();this.emit("message",t);};_handleOpenEvent=e=>{p.info("live room open",e.detail),this.state=1,e.detail.reconnects>0&&this.emit("reconnected",e.detail);};_handleTimeoutEvent=e=>{p.error("live room connect timeout!",e.detail),this.state=3;};dispose=async()=>(this._removeWebSocketEventListeners(),await this.close("live room close by controller disposed!"));open=e=>this._ws.open(e);close=(e,t)=>new Promise(r=>{this._ws.once("close",()=>r(!0)),this._ws.close(e,t);});sendMessage(e=""){if(e==null)throw new Error("live message is empty!");if(this.state!==1)throw new Error("live has not yet been initialized!");return this._ws.send(JSON.stringify(e))}readyClose(){this._ws&&(this._ws._explicitlyClosed=!0);}};var A=()=>new Map,ze=n=>{let e=A();return n.forEach((t,r)=>{e.set(r,t);}),e},Z=(n,e,t)=>{let r=n.get(e);return r===void 0&&n.set(e,r=t()),r},Tn=(n,e)=>{let t=[];for(let[r,i]of n)t.push(e(i,r));return t},Rn=(n,e)=>{for(let[t,r]of n)if(e(r,t))return !0;return !1};var J=()=>new Set;var Ye=n=>n[n.length-1];var Q=Array.from;var Ct=Array.isArray;var Xe=class{constructor(){this._observers=A();}on(e,t){return Z(this._observers,e,J).add(t),t}once(e,t){let r=(...i)=>{this.off(e,r),t(...i);};this.on(e,r);}off(e,t){let r=this._observers.get(e);r!==void 0&&(r.delete(t),r.size===0&&this._observers.delete(e));}emit(e,t){return Q((this._observers.get(e)||A()).values()).forEach(r=>r(...t))}destroy(){this._observers=A();}};var K=Math.floor;var fe=Math.abs;var Ze=(n,e)=>n<e?n:e,ee=(n,e)=>n>e?n:e;var Dn=n=>n!==0?n<0:1/n<0;var Un=Number.isInteger||(n=>typeof n=="number"&&isFinite(n)&&K(n)===n);var Di=n=>n.toLowerCase(),Ui=/^\s*/g,Oi=n=>n.replace(Ui,""),Ai=/([A-Z])/g,Rt=(n,e)=>Oi(n.replace(Ai,t=>`${e}${Di(t)}`));var Li=n=>{let e=unescape(encodeURIComponent(n)),t=e.length,r=new Uint8Array(t);for(let i=0;i<t;i++)r[i]=e.codePointAt(i);return r},ge=typeof TextEncoder<"u"?new TextEncoder:null,Vi=n=>ge.encode(n),On=ge?Vi:Li;var Tt=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Tt&&Tt.decode(new Uint8Array).length===1&&(Tt=null);var oe=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[];}},tt=()=>new oe;var Bi=n=>{let e=n.cpos;for(let t=0;t<n.bufs.length;t++)e+=n.bufs[t].length;return e};var P=n=>{let e=new Uint8Array(Bi(n)),t=0;for(let r=0;r<n.bufs.length;r++){let i=n.bufs[r];e.set(i,t),t+=i.length;}return e.set(new Uint8Array(n.cbuf.buffer,0,n.cpos),t),e},Ki=(n,e)=>{let t=n.cbuf.length;t-n.cpos<e&&(n.bufs.push(new Uint8Array(n.cbuf.buffer,0,n.cpos)),n.cbuf=new Uint8Array(ee(t,e)*2),n.cpos=0);},I=(n,e)=>{let t=n.cbuf.length;n.cpos===t&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(t*2),n.cpos=0),n.cbuf[n.cpos++]=e;};var nt=I;var y=(n,e)=>{for(;e>127;)I(n,128|127&e),e=K(e/128);I(n,127&e);},rt=(n,e)=>{let t=Dn(e);for(t&&(e=-e),I(n,(e>63?128:0)|(t?64:0)|63&e),e=K(e/64);e>0;)I(n,(e>127?128:0)|127&e),e=K(e/128);},Ut=new Uint8Array(3e4),Pi=Ut.length/3,ji=(n,e)=>{if(e.length<Pi){let t=ge.encodeInto(e,Ut).written||0;y(n,t);for(let r=0;r<t;r++)I(n,Ut[r]);}else L(n,On(e));},Fi=(n,e)=>{let t=unescape(encodeURIComponent(e)),r=t.length;y(n,r);for(let i=0;i<r;i++)I(n,t.codePointAt(i));},ce=ge&&ge.encodeInto?ji:Fi;var it=(n,e)=>{let t=n.cbuf.length,r=n.cpos,i=Ze(t-r,e.length),s=e.length-i;n.cbuf.set(e.subarray(0,i),r),n.cpos+=i,s>0&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(ee(t*2,s)),n.cbuf.set(e.subarray(i)),n.cpos=s);},L=(n,e)=>{y(n,e.byteLength),it(n,e);},Ot=(n,e)=>{Ki(n,e);let t=new DataView(n.cbuf.buffer,n.cpos,e);return n.cpos+=e,t},Wi=(n,e)=>Ot(n,4).setFloat32(0,e,!1),$i=(n,e)=>Ot(n,8).setFloat64(0,e,!1),Gi=(n,e)=>Ot(n,8).setBigInt64(0,e,!1);var Ln=new DataView(new ArrayBuffer(4)),qi=n=>(Ln.setFloat32(0,n),Ln.getFloat32(0)===n),pe=(n,e)=>{switch(typeof e){case"string":I(n,119),ce(n,e);break;case"number":Un(e)&&fe(e)<=2147483647?(I(n,125),rt(n,e)):qi(e)?(I(n,124),Wi(n,e)):(I(n,123),$i(n,e));break;case"bigint":I(n,122),Gi(n,e);break;case"object":if(e===null)I(n,126);else if(Ct(e)){I(n,117),y(n,e.length);for(let t=0;t<e.length;t++)pe(n,e[t]);}else if(e instanceof Uint8Array)I(n,116),L(n,e);else {I(n,118);let t=Object.keys(e);y(n,t.length);for(let r=0;r<t.length;r++){let i=t[r];ce(n,i),pe(n,e[i]);}}break;case"boolean":I(n,e?120:121);break;default:I(n,127);}},Re=class extends oe{constructor(e){super(),this.w=e,this.s=null,this.count=0;}write(e){this.s===e?this.count++:(this.count>0&&y(this,this.count-1),this.count=1,this.w(this,e),this.s=e);}};var Vn=n=>{n.count>0&&(rt(n.encoder,n.count===1?n.s:-n.s),n.count>1&&y(n.encoder,n.count-2));},ae=class{constructor(){this.encoder=new oe,this.s=0,this.count=0;}write(e){this.s===e?this.count++:(Vn(this),this.count=1,this.s=e);}toUint8Array(){return Vn(this),P(this.encoder)}};var Mn=n=>{if(n.count>0){let e=n.diff*2+(n.count===1?0:1);rt(n.encoder,e),n.count>1&&y(n.encoder,n.count-2);}},me=class{constructor(){this.encoder=new oe,this.s=0,this.count=0,this.diff=0;}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Mn(this),this.count=1,this.diff=e-this.s,this.s=e);}toUint8Array(){return Mn(this),P(this.encoder)}},et=class{constructor(){this.sarr=[],this.s="",this.lensE=new ae;}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length);}toUint8Array(){let e=new oe;return this.sarr.push(this.s),this.s="",ce(e,this.sarr.join("")),it(e,this.lensE.toUint8Array()),P(e)}};var le=n=>new Error(n),N=()=>{throw le("Method unimplemented")},te=()=>{throw le("Unexpected case")};var Nn=crypto.getRandomValues.bind(crypto);var At=()=>Nn(new Uint32Array(1))[0];var zi="10000000-1000-4000-8000"+-1e11,Bn=()=>zi.replace(/[018]/g,n=>(n^At()&15>>n/4).toString(16));var Lt=n=>new Promise(n);Promise.all.bind(Promise);var Vt=n=>n===void 0?null:n;var Mt=class{constructor(){this.map=new Map;}setItem(e,t){this.map.set(e,t);}getItem(e){return this.map.get(e)}},Pn=new Mt,es=!0;try{typeof localStorage<"u"&&localStorage&&(Pn=localStorage,es=!1);}catch{}var jn=Pn;var Wn=Object.assign,ns=Object.keys,$n=(n,e)=>{for(let t in n)e(n[t],t);};var Fn=n=>ns(n).length;var Gn=n=>{for(let e in n)return !1;return !0},rs=(n,e)=>{for(let t in n)if(!e(n[t],t))return !1;return !0},is=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),qn=(n,e)=>n===e||Fn(n)===Fn(e)&&rs(n,(t,r)=>(t!==void 0||is(e,r))&&e[r]===t),ss=Object.freeze,Nt=n=>{for(let e in n){let t=n[e];(typeof t=="object"||typeof t=="function")&&Nt(n[e]);}return ss(n)};var De=(n,e,t=0)=>{try{for(;t<n.length;t++)n[t](...e);}finally{t<n.length&&De(n,e,t+1);}};var Jn=(n,e)=>e.includes(n);var Ue=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]";var j,cs=[],as=()=>{if(j===void 0)if(Ue){j=A();let n=process.argv,e=null;for(let t=0;t<n.length;t++){let r=n[t];r[0]==="-"?(e!==null&&j.set(e,""),e=r):e!==null?(j.set(e,r),e=null):cs.push(r);}e!==null&&j.set(e,"");}else typeof location=="object"?(j=A(),(location.search||"?").slice(1).split("&").forEach(n=>{if(n.length!==0){let[e,t]=n.split("=");j.set(`--${Rt(e,"-")}`,t),j.set(`-${Rt(e,"-")}`,t);}})):j=A();return j},Bt=n=>as().has(n);var Oe=n=>Ue?Vt(process.env[n.toUpperCase().replaceAll("-","_")]):Vt(jn.getItem(n));var zn=n=>Bt("--"+n)||Oe(n)!==null;zn("production");var ls=Ue&&Jn(process.env.FORCE_COLOR,["true","1","2"]),Yn=ls||!Bt("--no-colors")&&!zn("no-color")&&(!Ue||process.stdout.isTTY)&&(!Ue||Bt("--color")||Oe("COLORTERM")!==null||(Oe("TERM")||"").includes("color"));var Kt=class{constructor(e,t){this.left=e,this.right=t;}},F=(n,e)=>new Kt(n,e);typeof DOMParser<"u"?new DOMParser:null;var Zn=n=>Tn(n,(e,t)=>`${t}:${e};`).join("");var W=Symbol;var Ae=W(),Le=W(),Pt=W(),jt=W(),Ft=W(),Ve=W(),Wt=W(),ye=W(),$t=W(),Qn=n=>{n.length===1&&n[0]?.constructor===Function&&(n=n[0]());let e=[],t=[],r=0;for(;r<n.length;r++){let i=n[r];if(i===void 0)break;if(i.constructor===String||i.constructor===Number)e.push(i);else if(i.constructor===Object)break}for(r>0&&t.push(e.join(""));r<n.length;r++){let i=n[r];i instanceof Symbol||t.push(i);}return t};var gs={[Ae]:F("font-weight","bold"),[Le]:F("font-weight","normal"),[Pt]:F("color","blue"),[Ft]:F("color","green"),[jt]:F("color","grey"),[Ve]:F("color","red"),[Wt]:F("color","purple"),[ye]:F("color","orange"),[$t]:F("color","black")},ps=n=>{n.length===1&&n[0]?.constructor===Function&&(n=n[0]());let e=[],t=[],r=A(),i=[],s=0;for(;s<n.length;s++){let o=n[s],c=gs[o];if(c!==void 0)r.set(c.left,c.right);else {if(o===void 0)break;if(o.constructor===String||o.constructor===Number){let a=Zn(r);s>0||a.length>0?(e.push("%c"+o),t.push(a)):e.push(o);}else break}}for(s>0&&(i=t,i.unshift(e.join("")));s<n.length;s++){let o=n[s];o instanceof Symbol||i.push(o);}return i},er=Yn?ps:Qn,tr=(...n)=>{console.log(...er(n)),rr.forEach(e=>e.print(n));},nr=(...n)=>{console.warn(...er(n)),n.unshift(ye),rr.forEach(e=>e.print(n));};var rr=J();var ir=n=>({[Symbol.iterator](){return this},next:n}),sr=(n,e)=>ir(()=>{let t;do t=n.next();while(!t.done&&!e(t.value));return t}),st=(n,e)=>ir(()=>{let{done:t,value:r}=n.next();return {done:t,value:t?void 0:e(r)}});var Jt=class{constructor(e,t){this.clock=e,this.len=t;}},dt=class{constructor(){this.clients=new Map;}},wr=(n,e,t)=>e.clients.forEach((r,i)=>{let s=n.doc.store.clients.get(i);for(let o=0;o<r.length;o++){let c=r[o];Cr(n,s,c.clock,c.len,t);}}),bs=(n,e)=>{let t=0,r=n.length-1;for(;t<=r;){let i=K((t+r)/2),s=n[i],o=s.clock;if(o<=e){if(e<o+s.len)return i;t=i+1;}else r=i-1;}return null},_r=(n,e)=>{let t=n.clients.get(e.client);return t!==void 0&&bs(t,e.clock)!==null},br=n=>{n.clients.forEach(e=>{e.sort((i,s)=>i.clock-s.clock);let t,r;for(t=1,r=1;t<e.length;t++){let i=e[r-1],s=e[t];i.clock+i.len>=s.clock?i.len=ee(i.len,s.clock+s.len-i.clock):(r<t&&(e[r]=s),r++);}e.length=r;});};var Sr=(n,e,t,r)=>{Z(n.clients,e,()=>[]).push(new Jt(t,r));};var vs=(n,e)=>{y(n.restEncoder,e.clients.size),Q(e.clients.entries()).sort((t,r)=>r[0]-t[0]).forEach(([t,r])=>{n.resetDsCurVal(),y(n.restEncoder,t);let i=r.length;y(n.restEncoder,i);for(let s=0;s<i;s++){let o=r[s];n.writeDsClock(o.clock),n.writeDsLen(o.len);}});};var vr=At,he=class n extends Xe{constructor({guid:e=Bn(),collectionid:t=null,gc:r=!0,gcFilter:i=()=>!0,meta:s=null,autoLoad:o=!1,shouldLoad:c=!0}={}){super(),this.gc=r,this.gcFilter=i,this.clientID=vr(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new tn,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=c,this.autoLoad=o,this.meta=s,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Lt(l=>{this.on("load",()=>{this.isLoaded=!0,l(this);});});let a=()=>Lt(l=>{let d=u=>{(u===void 0||u===!0)&&(this.off("sync",d),l());};this.on("sync",d);});this.on("sync",l=>{l===!1&&this.isSynced&&(this.whenSynced=a()),this.isSynced=l===void 0||l===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this]);}),this.whenSynced=a();}load(){let e=this._item;e!==null&&!this.shouldLoad&&b(e.parent.doc,t=>{t.subdocsLoaded.add(this);},null,!0),this.shouldLoad=!0;}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Q(this.subdocs).map(e=>e.guid))}transact(e,t=null){return b(this,e,t)}get(e,t=k){let r=Z(this.share,e,()=>{let s=new t;return s._integrate(this,null),s}),i=r.constructor;if(t!==k&&i!==t)if(i===k){let s=new t;s._map=r._map,r._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=s;}),s._start=r._start;for(let o=s._start;o!==null;o=o.right)o.parent=s;return s._length=r._length,this.share.set(e,s),s._integrate(this,null),s}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,cn)}getText(e=""){return this.get(e,hn)}getMap(e=""){return this.get(e,ln)}getXmlElement(e=""){return this.get(e,ft)}getXmlFragment(e=""){return this.get(e,Pe)}toJSON(){let e={};return this.share.forEach((t,r)=>{e[r]=t.toJSON();}),e}destroy(){this.isDestroyed=!0,Q(this.subdocs).forEach(t=>t.destroy());let e=this._item;if(e!==null){this._item=null;let t=e.content;t.doc=new n({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,b(e.parent.doc,r=>{let i=t.doc;e.deleted||r.subdocsAdded.add(i),r.subdocsRemoved.add(this);},null,!0);}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy();}};var Ht=class{constructor(){this.restEncoder=tt();}toUint8Array(){return P(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){y(this.restEncoder,e);}writeDsLen(e){y(this.restEncoder,e);}},zt=class extends Ht{writeLeftID(e){y(this.restEncoder,e.client),y(this.restEncoder,e.clock);}writeRightID(e){y(this.restEncoder,e.client),y(this.restEncoder,e.clock);}writeClient(e){y(this.restEncoder,e);}writeInfo(e){nt(this.restEncoder,e);}writeString(e){ce(this.restEncoder,e);}writeParentInfo(e){y(this.restEncoder,e?1:0);}writeTypeRef(e){y(this.restEncoder,e);}writeLen(e){y(this.restEncoder,e);}writeAny(e){pe(this.restEncoder,e);}writeBuf(e){L(this.restEncoder,e);}writeJSON(e){ce(this.restEncoder,JSON.stringify(e));}writeKey(e){ce(this.restEncoder,e);}},Yt=class{constructor(){this.restEncoder=tt(),this.dsCurrVal=0;}toUint8Array(){return P(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0;}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,y(this.restEncoder,t);}writeDsLen(e){e===0&&te(),y(this.restEncoder,e-1),this.dsCurrVal+=e;}},Xt=class extends Yt{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new me,this.clientEncoder=new ae,this.leftClockEncoder=new me,this.rightClockEncoder=new me,this.infoEncoder=new Re(nt),this.stringEncoder=new et,this.parentInfoEncoder=new Re(nt),this.typeRefEncoder=new ae,this.lenEncoder=new ae;}toUint8Array(){let e=tt();return y(e,0),L(e,this.keyClockEncoder.toUint8Array()),L(e,this.clientEncoder.toUint8Array()),L(e,this.leftClockEncoder.toUint8Array()),L(e,this.rightClockEncoder.toUint8Array()),L(e,P(this.infoEncoder)),L(e,this.stringEncoder.toUint8Array()),L(e,P(this.parentInfoEncoder)),L(e,this.typeRefEncoder.toUint8Array()),L(e,this.lenEncoder.toUint8Array()),it(e,P(this.restEncoder)),P(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock);}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock);}writeClient(e){this.clientEncoder.write(e);}writeInfo(e){this.infoEncoder.write(e);}writeString(e){this.stringEncoder.write(e);}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0);}writeTypeRef(e){this.typeRefEncoder.write(e);}writeLen(e){this.lenEncoder.write(e);}writeAny(e){pe(this.restEncoder,e);}writeBuf(e){L(this.restEncoder,e);}writeJSON(e){pe(this.restEncoder,e);}writeKey(e){let t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t);}},Es=(n,e,t,r)=>{r=ee(r,e[0].id.clock);let i=H(e,r);y(n.restEncoder,e.length-i),n.writeClient(t),y(n.restEncoder,r);let s=e[i];s.write(n,r-s.id.clock);for(let o=i+1;o<e.length;o++)e[o].write(n,0);},ks=(n,e,t)=>{let r=new Map;t.forEach((i,s)=>{V(e,s)>i&&r.set(s,i);}),gn(e).forEach((i,s)=>{t.has(s)||r.set(s,0);}),y(n.restEncoder,r.size),Q(r.entries()).sort((i,s)=>s[0]-i[0]).forEach(([i,s])=>{Es(n,e.clients.get(i),i,s);});};var Cs=(n,e)=>ks(n,e.doc.store,e.beforeState);var Zt=class{constructor(){this.l=[];}},ar=()=>new Zt,lr=(n,e)=>n.l.push(e),dr=(n,e)=>{let t=n.l,r=t.length;n.l=t.filter(i=>e!==i),r===n.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.");},Er=(n,e,t)=>De(n.l,[e,t]),_e=class{constructor(e,t){this.client=e,this.clock=t;}},ot=(n,e)=>n===e||n!==null&&e!==null&&n.client===e.client&&n.clock===e.clock,S=(n,e)=>new _e(n,e);var xs=n=>{for(let[e,t]of n.doc.share.entries())if(t===n)return e;throw te()};var we=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&(e.sv.get(n.id.client)||0)>n.id.clock&&!_r(e.ds,n.id),en=(n,e)=>{let t=Z(n.meta,en,J),r=n.doc.store;t.has(e)||(e.sv.forEach((i,s)=>{i<V(r,s)&&re(n,S(s,i));}),wr(n,e.ds,i=>{}),t.add(e));};var tn=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null;}},gn=n=>{let e=new Map;return n.clients.forEach((t,r)=>{let i=t[t.length-1];e.set(r,i.id.clock+i.length);}),e},V=(n,e)=>{let t=n.clients.get(e);if(t===void 0)return 0;let r=t[t.length-1];return r.id.clock+r.length},kr=(n,e)=>{let t=n.clients.get(e.id.client);if(t===void 0)t=[],n.clients.set(e.id.client,t);else {let r=t[t.length-1];if(r.id.clock+r.length!==e.id.clock)throw te()}t.push(e);},H=(n,e)=>{let t=0,r=n.length-1,i=n[r],s=i.id.clock;if(s===e)return r;let o=K(e/(s+i.length-1)*r);for(;t<=r;){if(i=n[o],s=i.id.clock,s<=e){if(e<s+i.length)return o;t=o+1;}else r=o-1;o=K((t+r)/2);}throw te()},Ts=(n,e)=>{let t=n.clients.get(e.client);return t[H(t,e.clock)]},Gt=Ts,nn=(n,e,t)=>{let r=H(e,t),i=e[r];return i.id.clock<t&&i instanceof O?(e.splice(r+1,0,Fr(n,i,t-i.id.clock)),r+1):r},re=(n,e)=>{let t=n.doc.store.clients.get(e.client);return t[nn(n,t,e.clock)]},hr=(n,e,t)=>{let r=e.clients.get(t.client),i=H(r,t.clock),s=r[i];return t.clock!==s.id.clock+s.length-1&&s.constructor!==$&&r.splice(i+1,0,Fr(n,s,t.clock-s.id.clock+1)),s},Rs=(n,e,t)=>{let r=n.clients.get(e.id.client);r[H(r,e.id.clock)]=t;},Cr=(n,e,t,r,i)=>{if(r===0)return;let s=t+r,o=nn(n,e,t),c;do c=e[o++],s<c.id.clock+c.length&&nn(n,e,s),i(c);while(o<e.length&&e[o].id.clock<s)},rn=class{constructor(e,t,r){this.doc=e,this.deleteSet=new dt,this.beforeState=gn(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1;}},ur=(n,e)=>e.deleteSet.clients.size===0&&!Rn(e.afterState,(t,r)=>e.beforeState.get(r)!==t)?!1:(br(e.deleteSet),Cs(n,e),vs(n,e.deleteSet),!0),fr=(n,e,t)=>{let r=e._item;(r===null||r.id.clock<(n.beforeState.get(r.id.client)||0)&&!r.deleted)&&Z(n.changed,e,J).add(t);},lt=(n,e)=>{let t=n[e],r=n[e-1],i=e;for(;i>0;t=r,r=n[--i-1]){if(r.deleted===t.deleted&&r.constructor===t.constructor&&r.mergeWith(t)){t instanceof O&&t.parentSub!==null&&t.parent._map.get(t.parentSub)===t&&t.parent._map.set(t.parentSub,r);continue}break}let s=e-i;return s&&n.splice(e+1-s,s),s},Ds=(n,e,t)=>{for(let[r,i]of n.clients.entries()){let s=e.clients.get(r);for(let o=i.length-1;o>=0;o--){let c=i[o],a=c.clock+c.len;for(let l=H(s,c.clock),d=s[l];l<s.length&&d.id.clock<a;d=s[++l]){let u=s[l];if(c.clock+c.len<=u.id.clock)break;u instanceof O&&u.deleted&&!u.keep&&t(u)&&u.gc(e,!1);}}}},Us=(n,e)=>{n.clients.forEach((t,r)=>{let i=e.clients.get(r);for(let s=t.length-1;s>=0;s--){let o=t[s],c=Ze(i.length-1,1+H(i,o.clock+o.len-1));for(let a=c,l=i[a];a>0&&l.id.clock>=o.clock;l=i[a])a-=1+lt(i,a);}});};var xr=(n,e)=>{if(e<n.length){let t=n[e],r=t.doc,i=r.store,s=t.deleteSet,o=t._mergeStructs;try{br(s),t.afterState=gn(t.doc.store),r.emit("beforeObserverCalls",[t,r]);let c=[];t.changed.forEach((a,l)=>c.push(()=>{(l._item===null||!l._item.deleted)&&l._callObserver(t,a);})),c.push(()=>{t.changedParentTypes.forEach((a,l)=>{l._dEH.l.length>0&&(l._item===null||!l._item.deleted)&&(a=a.filter(d=>d.target._item===null||!d.target._item.deleted),a.forEach(d=>{d.currentTarget=l,d._path=null;}),a.sort((d,u)=>d.path.length-u.path.length),Er(l._dEH,a,t));});}),c.push(()=>r.emit("afterTransaction",[t,r])),De(c,[]),t._needFormattingCleanup&&Ps(t);}finally{r.gc&&Ds(s,i,r.gcFilter),Us(s,i),t.afterState.forEach((d,u)=>{let g=t.beforeState.get(u)||0;if(g!==d){let f=i.clients.get(u),w=ee(H(f,g),1);for(let C=f.length-1;C>=w;)C-=1+lt(f,C);}});for(let d=o.length-1;d>=0;d--){let{client:u,clock:g}=o[d].id,f=i.clients.get(u),w=H(f,g);w+1<f.length&&lt(f,w+1)>1||w>0&&lt(f,w);}if(!t.local&&t.afterState.get(r.clientID)!==t.beforeState.get(r.clientID)&&(tr(ye,Ae,"[yjs] ",Le,Ve,"Changed the client-id because another client seems to be using it."),r.clientID=vr()),r.emit("afterTransactionCleanup",[t,r]),r._observers.has("update")){let d=new zt;ur(d,t)&&r.emit("update",[d.toUint8Array(),t.origin,r,t]);}if(r._observers.has("updateV2")){let d=new Xt;ur(d,t)&&r.emit("updateV2",[d.toUint8Array(),t.origin,r,t]);}let{subdocsAdded:c,subdocsLoaded:a,subdocsRemoved:l}=t;(c.size>0||l.size>0||a.size>0)&&(c.forEach(d=>{d.clientID=r.clientID,d.collectionid==null&&(d.collectionid=r.collectionid),r.subdocs.add(d);}),l.forEach(d=>r.subdocs.delete(d)),r.emit("subdocs",[{loaded:a,added:c,removed:l},r,t]),l.forEach(d=>d.destroy())),n.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,n])):xr(n,e+1);}}},b=(n,e,t=null,r=!0)=>{let i=n._transactionCleanups,s=!1,o=null;n._transaction===null&&(s=!0,n._transaction=new rn(n,t,r),i.push(n._transaction),i.length===1&&n.emit("beforeAllTransactions",[n]),n.emit("beforeTransaction",[n._transaction,n]));try{o=e(n._transaction);}finally{if(s){let c=n._transaction===i[0];n._transaction=null,c&&xr(i,0);}}return o};var gr="You must not compute changes after the event-handler fired.",be=class{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null;}get path(){return this._path||(this._path=Os(this.currentTarget,this.target))}deletes(e){return _r(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw le(gr);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach(i=>{if(i!==null){let s=t._map.get(i),o,c;if(this.adds(s)){let a=s.left;for(;a!==null&&this.adds(a);)a=a.left;if(this.deletes(s))if(a!==null&&this.deletes(a))o="delete",c=Ye(a.content.getContent());else return;else a!==null&&this.deletes(a)?(o="update",c=Ye(a.content.getContent())):(o="add",c=void 0);}else if(this.deletes(s))o="delete",c=Ye(s.content.getContent());else return;e.set(i,{action:o,oldValue:c});}}),this._keys=e;}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw le(gr);let t=this.target,r=J(),i=J(),s=[];if(e={added:r,deleted:i,delta:s,keys:this.keys},this.transaction.changed.get(t).has(null)){let c=null,a=()=>{c&&s.push(c);};for(let l=t._start;l!==null;l=l.right)l.deleted?this.deletes(l)&&!this.adds(l)&&((c===null||c.delete===void 0)&&(a(),c={delete:0}),c.delete+=l.length,i.add(l)):this.adds(l)?((c===null||c.insert===void 0)&&(a(),c={insert:[]}),c.insert=c.insert.concat(l.content.getContent()),r.add(l)):((c===null||c.retain===void 0)&&(a(),c={retain:0}),c.retain+=l.length);c!==null&&c.retain===void 0&&a();}this._changes=e;}return e}},Os=(n,e)=>{let t=[];for(;e._item!==null&&e!==n;){if(e._item.parentSub!==null)t.unshift(e._item.parentSub);else {let r=0,i=e._item.parent._start;for(;i!==e._item&&i!==null;)!i.deleted&&i.countable&&(r+=i.length),i=i.right;t.unshift(r);}e=e._item.parent;}return t},U=()=>{nr("Invalid access: Add Yjs type to a document before reading data.");},Ir=80,pn=0,sn=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=pn++;}},As=n=>{n.timestamp=pn++;},Tr=(n,e,t)=>{n.p.marker=!1,n.p=e,e.marker=!0,n.index=t,n.timestamp=pn++;},Ls=(n,e,t)=>{if(n.length>=Ir){let r=n.reduce((i,s)=>i.timestamp<s.timestamp?i:s);return Tr(r,e,t),r}else {let r=new sn(e,t);return n.push(r),r}},yt=(n,e)=>{if(n._start===null||e===0||n._searchMarker===null)return null;let t=n._searchMarker.length===0?null:n._searchMarker.reduce((s,o)=>fe(e-s.index)<fe(e-o.index)?s:o),r=n._start,i=0;for(t!==null&&(r=t.p,i=t.index,As(t));r.right!==null&&i<e;){if(!r.deleted&&r.countable){if(e<i+r.length)break;i+=r.length;}r=r.right;}for(;r.left!==null&&i>e;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return t!==null&&fe(t.index-i)<r.parent.length/Ir?(Tr(t,r,i),t):Ls(n._searchMarker,r,i)},Ne=(n,e,t)=>{for(let r=n.length-1;r>=0;r--){let i=n[r];if(t>0){let s=i.p;for(s.marker=!1;s&&(s.deleted||!s.countable);)s=s.left,s&&!s.deleted&&s.countable&&(i.index-=s.length);if(s===null||s.marker===!0){n.splice(r,1);continue}i.p=s,s.marker=!0;}(e<i.index||t>0&&e===i.index)&&(i.index=ee(e,i.index+t));}};var wt=(n,e,t)=>{let r=n,i=e.changedParentTypes;for(;Z(i,n,()=>[]).push(t),n._item!==null;)n=n._item.parent;Er(r._eH,t,e);},k=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=ar(),this._dEH=ar(),this._searchMarker=null;}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t;}_copy(){throw N()}clone(){throw N()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0);}observe(e){lr(this._eH,e);}observeDeep(e){lr(this._dEH,e);}unobserve(e){dr(this._eH,e);}unobserveDeep(e){dr(this._dEH,e);}toJSON(){}},Rr=(n,e,t)=>{n.doc??U(),e<0&&(e=n._length+e),t<0&&(t=n._length+t);let r=t-e,i=[],s=n._start;for(;s!==null&&r>0;){if(s.countable&&!s.deleted){let o=s.content.getContent();if(o.length<=e)e-=o.length;else {for(let c=e;c<o.length&&r>0;c++)i.push(o[c]),r--;e=0;}}s=s.right;}return i},Dr=n=>{n.doc??U();let e=[],t=n._start;for(;t!==null;){if(t.countable&&!t.deleted){let r=t.content.getContent();for(let i=0;i<r.length;i++)e.push(r[i]);}t=t.right;}return e};var Be=(n,e)=>{let t=0,r=n._start;for(n.doc??U();r!==null;){if(r.countable&&!r.deleted){let i=r.content.getContent();for(let s=0;s<i.length;s++)e(i[s],t++,n);}r=r.right;}},Ur=(n,e)=>{let t=[];return Be(n,(r,i)=>{t.push(e(r,i,n));}),t},Vs=n=>{let e=n._start,t=null,r=0;return {[Symbol.iterator](){return this},next:()=>{if(t===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return {done:!0,value:void 0};t=e.content.getContent(),r=0,e=e.right;}let i=t[r++];return t.length<=r&&(t=null),{done:!1,value:i}}}},Or=(n,e)=>{n.doc??U();let t=yt(n,e),r=n._start;for(t!==null&&(r=t.p,e-=t.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length;}},ht=(n,e,t,r)=>{let i=t,s=n.doc,o=s.clientID,c=s.store,a=t===null?e._start:t.right,l=[],d=()=>{l.length>0&&(i=new O(S(o,V(c,o)),i,i&&i.lastId,a,a&&a.id,e,null,new je(l)),i.integrate(n,0),l=[]);};r.forEach(u=>{if(u===null)l.push(u);else switch(u.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(u);break;default:switch(d(),u.constructor){case Uint8Array:case ArrayBuffer:i=new O(S(o,V(c,o)),i,i&&i.lastId,a,a&&a.id,e,null,new pt(new Uint8Array(u))),i.integrate(n,0);break;case he:i=new O(S(o,V(c,o)),i,i&&i.lastId,a,a&&a.id,e,null,new mt(u)),i.integrate(n,0);break;default:if(u instanceof k)i=new O(S(o,V(c,o)),i,i&&i.lastId,a,a&&a.id,e,null,new se(u)),i.integrate(n,0);else throw new Error("Unexpected content type in insert operation")}}}),d();},Ar=()=>le("Length exceeded!"),Lr=(n,e,t,r)=>{if(t>e._length)throw Ar();if(t===0)return e._searchMarker&&Ne(e._searchMarker,t,r.length),ht(n,e,null,r);let i=t,s=yt(e,t),o=e._start;for(s!==null&&(o=s.p,t-=s.index,t===0&&(o=o.prev,t+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(t<=o.length){t<o.length&&re(n,S(o.id.client,o.id.clock+t));break}t-=o.length;}return e._searchMarker&&Ne(e._searchMarker,i,r.length),ht(n,e,o,r)},Ms=(n,e,t)=>{let i=(e._searchMarker||[]).reduce((s,o)=>o.index>s.index?o:s,{index:0,p:e._start}).p;if(i)for(;i.right;)i=i.right;return ht(n,e,i,t)},Vr=(n,e,t,r)=>{if(r===0)return;let i=t,s=r,o=yt(e,t),c=e._start;for(o!==null&&(c=o.p,t-=o.index);c!==null&&t>0;c=c.right)!c.deleted&&c.countable&&(t<c.length&&re(n,S(c.id.client,c.id.clock+t)),t-=c.length);for(;r>0&&c!==null;)c.deleted||(r<c.length&&re(n,S(c.id.client,c.id.clock+r)),c.delete(n),r-=c.length),c=c.right;if(r>0)throw Ar();e._searchMarker&&Ne(e._searchMarker,i,-s+r);},ut=(n,e,t)=>{let r=e._map.get(t);r!==void 0&&r.delete(n);},mn=(n,e,t,r)=>{let i=e._map.get(t)||null,s=n.doc,o=s.clientID,c;if(r==null)c=new je([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:c=new je([r]);break;case Uint8Array:c=new pt(r);break;case he:c=new mt(r);break;default:if(r instanceof k)c=new se(r);else throw new Error("Unexpected content type")}new O(S(o,V(s.store,o)),i,i&&i.lastId,null,null,e,t,c).integrate(n,0);},yn=(n,e)=>{n.doc??U();let t=n._map.get(e);return t!==void 0&&!t.deleted?t.content.getContent()[t.length-1]:void 0},Mr=n=>{let e={};return n.doc??U(),n._map.forEach((t,r)=>{t.deleted||(e[r]=t.content.getContent()[t.length-1]);}),e},Nr=(n,e)=>{n.doc??U();let t=n._map.get(e);return t!==void 0&&!t.deleted};var Ns=(n,e)=>{let t={};return n._map.forEach((r,i)=>{let s=r;for(;s!==null&&(!e.sv.has(s.id.client)||s.id.clock>=(e.sv.get(s.id.client)||0));)s=s.left;s!==null&&we(s,e)&&(t[i]=s.content.getContent()[s.length-1]);}),t},ct=n=>(n.doc??U(),sr(n._map.entries(),e=>!e[1].deleted)),on=class extends be{},cn=class n extends k{constructor(){super(),this._prelimContent=[],this._searchMarker=[];}static from(e){let t=new n;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null;}_copy(){return new n}clone(){let e=new n;return e.insert(0,this.toArray().map(t=>t instanceof k?t.clone():t)),e}get length(){return this.doc??U(),this._length}_callObserver(e,t){super._callObserver(e,t),wt(this,e,new on(this,e));}insert(e,t){this.doc!==null?b(this.doc,r=>{Lr(r,this,e,t);}):this._prelimContent.splice(e,0,...t);}push(e){this.doc!==null?b(this.doc,t=>{Ms(t,this,e);}):this._prelimContent.push(...e);}unshift(e){this.insert(0,e);}delete(e,t=1){this.doc!==null?b(this.doc,r=>{Vr(r,this,e,t);}):this._prelimContent.splice(e,t);}get(e){return Or(this,e)}toArray(){return Dr(this)}slice(e=0,t=this.length){return Rr(this,e,t)}toJSON(){return this.map(e=>e instanceof k?e.toJSON():e)}map(e){return Ur(this,e)}forEach(e){Be(this,e);}[Symbol.iterator](){return Vs(this)}_write(e){e.writeTypeRef($s);}};var an=class extends be{constructor(e,t,r){super(e,t),this.keysChanged=r;}},ln=class n extends k{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e);}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((r,i)=>{this.set(i,r);}),this._prelimContent=null;}_copy(){return new n}clone(){let e=new n;return this.forEach((t,r)=>{e.set(r,t instanceof k?t.clone():t);}),e}_callObserver(e,t){wt(this,e,new an(this,e,t));}toJSON(){this.doc??U();let e={};return this._map.forEach((t,r)=>{if(!t.deleted){let i=t.content.getContent()[t.length-1];e[r]=i instanceof k?i.toJSON():i;}}),e}get size(){return [...ct(this)].length}keys(){return st(ct(this),e=>e[0])}values(){return st(ct(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return st(ct(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??U(),this._map.forEach((t,r)=>{t.deleted||e(t.content.getContent()[t.length-1],r,this);});}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?b(this.doc,t=>{ut(t,this,e);}):this._prelimContent.delete(e);}set(e,t){return this.doc!==null?b(this.doc,r=>{mn(r,this,e,t);}):this._prelimContent.set(e,t),t}get(e){return yn(this,e)}has(e){return Nr(this,e)}clear(){this.doc!==null?b(this.doc,e=>{this.forEach(function(t,r,i){ut(e,i,r);});}):this._prelimContent.clear();}_write(e){e.writeTypeRef(Gs);}};var ne=(n,e)=>n===e||typeof n=="object"&&typeof e=="object"&&n&&e&&qn(n,e),Ke=class{constructor(e,t,r,i){this.left=e,this.right=t,this.index=r,this.currentAttributes=i;}forward(){switch(this.right===null&&te(),this.right.content.constructor){case T:this.right.deleted||ve(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right;}},pr=(n,e,t)=>{for(;e.right!==null&&t>0;){switch(e.right.content.constructor){case T:e.right.deleted||ve(e.currentAttributes,e.right.content);break;default:e.right.deleted||(t<e.right.length&&re(n,S(e.right.id.client,e.right.id.clock+t)),e.index+=e.right.length,t-=e.right.length);break}e.left=e.right,e.right=e.right.right;}return e},at=(n,e,t,r)=>{let i=new Map,s=r?yt(e,t):null;if(s){let o=new Ke(s.p.left,s.p,s.index,i);return pr(n,o,t-s.index)}else {let o=new Ke(null,e._start,0,i);return pr(n,o,t)}},Br=(n,e,t,r)=>{for(;t.right!==null&&(t.right.deleted===!0||t.right.content.constructor===T&&ne(r.get(t.right.content.key),t.right.content.value));)t.right.deleted||r.delete(t.right.content.key),t.forward();let i=n.doc,s=i.clientID;r.forEach((o,c)=>{let a=t.left,l=t.right,d=new O(S(s,V(i.store,s)),a,a&&a.lastId,l,l&&l.id,e,null,new T(c,o));d.integrate(n,0),t.right=d,t.forward();});},ve=(n,e)=>{let{key:t,value:r}=e;r===null?n.delete(t):n.set(t,r);},Kr=(n,e)=>{for(;n.right!==null;){if(!(n.right.deleted||n.right.content.constructor===T&&ne(e[n.right.content.key]??null,n.right.content.value)))break;n.forward();}},Pr=(n,e,t,r)=>{let i=n.doc,s=i.clientID,o=new Map;for(let c in r){let a=r[c],l=t.currentAttributes.get(c)??null;if(!ne(l,a)){o.set(c,l);let{left:d,right:u}=t;t.right=new O(S(s,V(i.store,s)),d,d&&d.lastId,u,u&&u.id,e,null,new T(c,a)),t.right.integrate(n,0),t.forward();}}return o},qt=(n,e,t,r,i)=>{t.currentAttributes.forEach((g,f)=>{i[f]===void 0&&(i[f]=null);});let s=n.doc,o=s.clientID;Kr(t,i);let c=Pr(n,e,t,i),a=r.constructor===String?new ie(r):r instanceof k?new se(r):new Se(r),{left:l,right:d,index:u}=t;e._searchMarker&&Ne(e._searchMarker,t.index,a.getLength()),d=new O(S(o,V(s.store,o)),l,l&&l.lastId,d,d&&d.id,e,null,a),d.integrate(n,0),t.right=d,t.index=u,t.forward(),Br(n,e,t,c);},mr=(n,e,t,r,i)=>{let s=n.doc,o=s.clientID;Kr(t,i);let c=Pr(n,e,t,i);e:for(;t.right!==null&&(r>0||c.size>0&&(t.right.deleted||t.right.content.constructor===T));){if(!t.right.deleted)switch(t.right.content.constructor){case T:{let{key:a,value:l}=t.right.content,d=i[a];if(d!==void 0){if(ne(d,l))c.delete(a);else {if(r===0)break e;c.set(a,l);}t.right.delete(n);}else t.currentAttributes.set(a,l);break}default:r<t.right.length&&re(n,S(t.right.id.client,t.right.id.clock+r)),r-=t.right.length;break}t.forward();}if(r>0){let a="";for(;r>0;r--)a+=`
7
- `;t.right=new O(S(o,V(s.store,o)),t.left,t.left&&t.left.lastId,t.right,t.right&&t.right.id,e,null,new ie(a)),t.right.integrate(n,0),t.forward();}Br(n,e,t,c);},jr=(n,e,t,r,i)=>{let s=e,o=A();for(;s&&(!s.countable||s.deleted);){if(!s.deleted&&s.content.constructor===T){let l=s.content;o.set(l.key,l);}s=s.right;}let c=0,a=!1;for(;e!==s;){if(t===e&&(a=!0),!e.deleted){let l=e.content;switch(l.constructor){case T:{let{key:d,value:u}=l,g=r.get(d)??null;(o.get(d)!==l||g===u)&&(e.delete(n),c++,!a&&(i.get(d)??null)===u&&g!==u&&(g===null?i.delete(d):i.set(d,g))),!a&&!e.deleted&&ve(i,l);break}}}e=e.right;}return c},Bs=(n,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;let t=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===T){let r=e.content.key;t.has(r)?e.delete(n):t.add(r);}e=e.left;}},Ks=n=>{let e=0;return b(n.doc,t=>{let r=n._start,i=n._start,s=A(),o=ze(s);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case T:ve(o,i.content);break;default:e+=jr(t,r,i,s,o),s=ze(o),r=i;break}i=i.right;}}),e},Ps=n=>{let e=new Set,t=n.doc;for(let[r,i]of n.afterState.entries()){let s=n.beforeState.get(r)||0;i!==s&&Cr(n,t.store.clients.get(r),s,i,o=>{!o.deleted&&o.content.constructor===T&&o.constructor!==$&&e.add(o.parent);});}b(t,r=>{wr(n,n.deleteSet,i=>{if(i instanceof $||!i.parent._hasFormatting||e.has(i.parent))return;let s=i.parent;i.content.constructor===T?e.add(s):Bs(r,i);});for(let i of e)Ks(i);});},yr=(n,e,t)=>{let r=t,i=ze(e.currentAttributes),s=e.right;for(;t>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case se:case Se:case ie:t<e.right.length&&re(n,S(e.right.id.client,e.right.id.clock+t)),t-=e.right.length,e.right.delete(n);break}e.forward();}s&&jr(n,s,e.right,i,e.currentAttributes);let o=(e.left||e.right).parent;return o._searchMarker&&Ne(o._searchMarker,e.index,-r+t),e},dn=class extends be{constructor(e,t,r){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(i=>{i===null?this.childListChanged=!0:this.keysChanged.add(i);});}get changes(){if(this._changes===null){let e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e;}return this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];b(e,r=>{let i=new Map,s=new Map,o=this.target._start,c=null,a={},l="",d=0,u=0,g=()=>{if(c!==null){let f=null;switch(c){case"delete":u>0&&(f={delete:u}),u=0;break;case"insert":(typeof l=="object"||l.length>0)&&(f={insert:l},i.size>0&&(f.attributes={},i.forEach((w,C)=>{w!==null&&(f.attributes[C]=w);}))),l="";break;case"retain":d>0&&(f={retain:d},Gn(a)||(f.attributes=Wn({},a))),d=0;break}f&&t.push(f),c=null;}};for(;o!==null;){switch(o.content.constructor){case se:case Se:this.adds(o)?this.deletes(o)||(g(),c="insert",l=o.content.getContent()[0],g()):this.deletes(o)?(c!=="delete"&&(g(),c="delete"),u+=1):o.deleted||(c!=="retain"&&(g(),c="retain"),d+=1);break;case ie:this.adds(o)?this.deletes(o)||(c!=="insert"&&(g(),c="insert"),l+=o.content.str):this.deletes(o)?(c!=="delete"&&(g(),c="delete"),u+=o.length):o.deleted||(c!=="retain"&&(g(),c="retain"),d+=o.length);break;case T:{let{key:f,value:w}=o.content;if(this.adds(o)){if(!this.deletes(o)){let C=i.get(f)??null;ne(C,w)?w!==null&&o.delete(r):(c==="retain"&&g(),ne(w,s.get(f)??null)?delete a[f]:a[f]=w);}}else if(this.deletes(o)){s.set(f,w);let C=i.get(f)??null;ne(C,w)||(c==="retain"&&g(),a[f]=C);}else if(!o.deleted){s.set(f,w);let C=a[f];C!==void 0&&(ne(C,w)?C!==null&&o.delete(r):(c==="retain"&&g(),w===null?delete a[f]:a[f]=w));}o.deleted||(c==="insert"&&g(),ve(i,o.content));break}}o=o.right;}for(g();t.length>0;){let f=t[t.length-1];if(f.retain!==void 0&&f.attributes===void 0)t.pop();else break}}),this._delta=t;}return this._delta}},hn=class n extends k{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1;}get length(){return this.doc??U(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(r=>r());}catch(r){console.error(r);}this._pending=null;}_copy(){return new n}clone(){let e=new n;return e.applyDelta(this.toDelta()),e}_callObserver(e,t){super._callObserver(e,t);let r=new dn(this,e,t);wt(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0);}toString(){this.doc??U();let e="",t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===ie&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc!==null?b(this.doc,r=>{let i=new Ke(null,this._start,0,new Map);for(let s=0;s<e.length;s++){let o=e[s];if(o.insert!==void 0){let c=!t&&typeof o.insert=="string"&&s===e.length-1&&i.right===null&&o.insert.slice(-1)===`
8
- `?o.insert.slice(0,-1):o.insert;(typeof c!="string"||c.length>0)&&qt(r,this,i,c,o.attributes||{});}else o.retain!==void 0?mr(r,this,i,o.retain,o.attributes||{}):o.delete!==void 0&&yr(r,i,o.delete);}}):this._pending.push(()=>this.applyDelta(e));}toDelta(e,t,r){this.doc??U();let i=[],s=new Map,o=this.doc,c="",a=this._start;function l(){if(c.length>0){let u={},g=!1;s.forEach((w,C)=>{g=!0,u[C]=w;});let f={insert:c};g&&(f.attributes=u),i.push(f),c="";}}let d=()=>{for(;a!==null;){if(we(a,e)||t!==void 0&&we(a,t))switch(a.content.constructor){case ie:{let u=s.get("ychange");e!==void 0&&!we(a,e)?(u===void 0||u.user!==a.id.client||u.type!=="removed")&&(l(),s.set("ychange",r?r("removed",a.id):{type:"removed"})):t!==void 0&&!we(a,t)?(u===void 0||u.user!==a.id.client||u.type!=="added")&&(l(),s.set("ychange",r?r("added",a.id):{type:"added"})):u!==void 0&&(l(),s.delete("ychange")),c+=a.content.str;break}case se:case Se:{l();let u={insert:a.content.getContent()[0]};if(s.size>0){let g={};u.attributes=g,s.forEach((f,w)=>{g[w]=f;});}i.push(u);break}case T:we(a,e)&&(l(),ve(s,a.content));break}a=a.right;}l();};return e||t?b(o,u=>{e&&en(u,e),t&&en(u,t),d();},"cleanup"):d(),i}insert(e,t,r){if(t.length<=0)return;let i=this.doc;i!==null?b(i,s=>{let o=at(s,this,e,!r);r||(r={},o.currentAttributes.forEach((c,a)=>{r[a]=c;})),qt(s,this,o,t,r);}):this._pending.push(()=>this.insert(e,t,r));}insertEmbed(e,t,r){let i=this.doc;i!==null?b(i,s=>{let o=at(s,this,e,!r);qt(s,this,o,t,r||{});}):this._pending.push(()=>this.insertEmbed(e,t,r||{}));}delete(e,t){if(t===0)return;let r=this.doc;r!==null?b(r,i=>{yr(i,at(i,this,e,!0),t);}):this._pending.push(()=>this.delete(e,t));}format(e,t,r){if(t===0)return;let i=this.doc;i!==null?b(i,s=>{let o=at(s,this,e,!1);o.right!==null&&mr(s,this,o,t,r);}):this._pending.push(()=>this.format(e,t,r));}removeAttribute(e){this.doc!==null?b(this.doc,t=>{ut(t,this,e);}):this._pending.push(()=>this.removeAttribute(e));}setAttribute(e,t){this.doc!==null?b(this.doc,r=>{mn(r,this,e,t);}):this._pending.push(()=>this.setAttribute(e,t));}getAttribute(e){return yn(this,e)}getAttributes(){return Mr(this)}_write(e){e.writeTypeRef(qs);}};var Me=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??U();}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===ft||t.constructor===Pe)&&t._start!==null)e=t._start;else for(;e!==null;)if(e.right!==null){e=e.right;break}else e.parent===this._root?e=null:e=e.parent._item;while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}},Pe=class n extends k{constructor(){super(),this._prelimContent=[];}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null;}_copy(){return new n}clone(){let e=new n;return e.insert(0,this.toArray().map(t=>t instanceof k?t.clone():t)),e}get length(){return this.doc??U(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new Me(this,e)}querySelector(e){e=e.toUpperCase();let r=new Me(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),Q(new Me(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){wt(this,e,new un(this,t,e));}toString(){return Ur(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,t={},r){let i=e.createDocumentFragment();return r!==void 0&&r._createAssociation(i,this),Be(this,s=>{i.insertBefore(s.toDOM(e,t,r),null);}),i}insert(e,t){this.doc!==null?b(this.doc,r=>{Lr(r,this,e,t);}):this._prelimContent.splice(e,0,...t);}insertAfter(e,t){if(this.doc!==null)b(this.doc,r=>{let i=e&&e instanceof k?e._item:e;ht(r,this,i,t);});else {let r=this._prelimContent,i=e===null?0:r.findIndex(s=>s===e)+1;if(i===0&&e!==null)throw le("Reference item not found");r.splice(i,0,...t);}}delete(e,t=1){this.doc!==null?b(this.doc,r=>{Vr(r,this,e,t);}):this._prelimContent.splice(e,t);}toArray(){return Dr(this)}push(e){this.insert(this.length,e);}unshift(e){this.insert(0,e);}get(e){return Or(this,e)}slice(e=0,t=this.length){return Rr(this,e,t)}forEach(e){Be(this,e);}_write(e){e.writeTypeRef(Hs);}};var ft=class n extends Pe{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map;}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((r,i)=>{this.setAttribute(i,r);}),this._prelimAttrs=null;}_copy(){return new n(this.nodeName)}clone(){let e=new n(this.nodeName),t=this.getAttributes();return $n(t,(r,i)=>{typeof r=="string"&&e.setAttribute(i,r);}),e.insert(0,this.toArray().map(r=>r instanceof k?r.clone():r)),e}toString(){let e=this.getAttributes(),t=[],r=[];for(let c in e)r.push(c);r.sort();let i=r.length;for(let c=0;c<i;c++){let a=r[c];t.push(a+'="'+e[a]+'"');}let s=this.nodeName.toLocaleLowerCase(),o=t.length>0?" "+t.join(" "):"";return `<${s}${o}>${super.toString()}</${s}>`}removeAttribute(e){this.doc!==null?b(this.doc,t=>{ut(t,this,e);}):this._prelimAttrs.delete(e);}setAttribute(e,t){this.doc!==null?b(this.doc,r=>{mn(r,this,e,t);}):this._prelimAttrs.set(e,t);}getAttribute(e){return yn(this,e)}hasAttribute(e){return Nr(this,e)}getAttributes(e){return e?Ns(this,e):Mr(this)}toDOM(e=document,t={},r){let i=e.createElement(this.nodeName),s=this.getAttributes();for(let o in s){let c=s[o];typeof c=="string"&&i.setAttribute(o,c);}return Be(this,o=>{i.appendChild(o.toDOM(e,t,r));}),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(Js),e.writeKey(this.nodeName);}};var un=class extends be{constructor(e,t,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(i=>{i===null?this.childListChanged=!0:this.attributesChanged.add(i);});}};var gt=class{constructor(e,t){this.id=e,this.length=t;}get deleted(){throw N()}mergeWith(e){return !1}write(e,t,r){throw N()}integrate(e,t){throw N()}},js=0,$=class extends gt{get deleted(){return !0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),kr(e.doc.store,this);}write(e,t){e.writeInfo(js),e.writeLen(this.length-t);}getMissing(e,t){return null}},pt=class n{constructor(e){this.content=e;}getLength(){return 1}getContent(){return [this.content]}isCountable(){return !0}copy(){return new n(this.content)}splice(e){throw N()}mergeWith(e){return !1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content);}getRef(){return 3}};var fn=class n{constructor(e){this.len=e;}getLength(){return this.len}getContent(){return []}isCountable(){return !1}copy(){return new n(this.len)}splice(e){let t=new n(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){Sr(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted();}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t);}getRef(){return 1}};var Fs=(n,e)=>new he({guid:n,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1}),mt=class n{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;let t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta);}getLength(){return 1}getContent(){return [this.doc]}isCountable(){return !0}copy(){return new n(Fs(this.doc.guid,this.opts))}splice(e){throw N()}mergeWith(e){return !1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc);}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc);}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts);}getRef(){return 9}};var Se=class n{constructor(e){this.embed=e;}getLength(){return 1}getContent(){return [this.embed]}isCountable(){return !0}copy(){return new n(this.embed)}splice(e){throw N()}mergeWith(e){return !1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed);}getRef(){return 5}};var T=class n{constructor(e,t){this.key=e,this.value=t;}getLength(){return 1}getContent(){return []}isCountable(){return !1}copy(){return new n(this.key,this.value)}splice(e){throw N()}mergeWith(e){return !1}integrate(e,t){let r=t.parent;r._searchMarker=null,r._hasFormatting=!0;}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value);}getRef(){return 6}};var Ws=Oe("node_env")==="development",je=class n{constructor(e){this.arr=e,Ws&&Nt(e);}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return !0}copy(){return new n(this.arr)}splice(e){let t=new n(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let r=this.arr.length;e.writeLen(r-t);for(let i=t;i<r;i++){let s=this.arr[i];e.writeAny(s);}}getRef(){return 8}};var ie=class n{constructor(e){this.str=e;}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return !0}copy(){return new n(this.str)}splice(e){let t=new n(this.str.slice(e));this.str=this.str.slice(0,e);let r=this.str.charCodeAt(e-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"\uFFFD",t.str="\uFFFD"+t.str.slice(1)),t}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t));}getRef(){return 4}};var $s=0,Gs=1,qs=2,Js=3,Hs=4;var se=class n{constructor(e){this.type=e;}getLength(){return 1}getContent(){return [this.type]}isCountable(){return !0}copy(){return new n(this.type._copy())}splice(e){throw N()}mergeWith(e){return !1}integrate(e,t){this.type._integrate(e.doc,t);}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e);}),e.changed.delete(this.type);}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(e,!0),r=r.left;}),this.type._map=new Map;}write(e,t){this.type._write(e);}getRef(){return 7}};var Fr=(n,e,t)=>{let{client:r,clock:i}=e.id,s=new O(S(r,i+t),e,S(r,i+t-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(t));return e.deleted&&s.markDeleted(),e.keep&&(s.keep=!0),e.redone!==null&&(s.redone=S(e.redone.client,e.redone.clock+t)),e.right=s,s.right!==null&&(s.right.left=s),n._mergeStructs.push(s),s.parentSub!==null&&s.right===null&&s.parent._map.set(s.parentSub,s),e.length=t,s};var O=class n extends gt{constructor(e,t,r,i,s,o,c,a){super(e,a.getLength()),this.origin=r,this.left=t,this.right=i,this.rightOrigin=s,this.parent=o,this.parentSub=c,this.redone=null,this.content=a,this.info=this.content.isCountable()?2:0;}set marker(e){(this.info&8)>0!==e&&(this.info^=8);}get marker(){return (this.info&8)>0}get keep(){return (this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1);}get countable(){return (this.info&2)>0}get deleted(){return (this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4);}markDeleted(){this.info|=4;}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=V(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=V(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===_e&&this.id.client!==this.parent.client&&this.parent.clock>=V(t,this.parent.client))return this.parent.client;if(this.origin&&(this.left=hr(e,t,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=re(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===$||this.right&&this.right.constructor===$)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===n&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===n&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===_e){let r=Gt(t,this.parent);r.constructor===$?this.parent=null:this.parent=r.content.type;}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=hr(e,e.doc.store,S(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,i;if(r!==null)i=r.right;else if(this.parentSub!==null)for(i=this.parent._map.get(this.parentSub)||null;i!==null&&i.left!==null;)i=i.left;else i=this.parent._start;let s=new Set,o=new Set;for(;i!==null&&i!==this.right;){if(o.add(i),s.add(i),ot(this.origin,i.origin)){if(i.id.client<this.id.client)r=i,s.clear();else if(ot(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&o.has(Gt(e.doc.store,i.origin)))s.has(Gt(e.doc.store,i.origin))||(r=i,s.clear());else break;i=i.right;}this.left=r;}if(this.left!==null){let r=this.left.right;this.right=r,this.left.right=this;}else {let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r;}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),kr(e.doc.store,this),this.content.integrate(e,this),fr(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e);}else new $(this.id,this.length).integrate(e,0);}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:S(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&ot(e.origin,this.lastId)&&this.right===e&&ot(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let t=this.parent._searchMarker;return t&&t.forEach(r=>{r.p===e&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length));}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return !1}delete(e){if(!this.deleted){let t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),Sr(e.deleteSet,this.id.client,this.id.clock,this.length),fr(e,t,this.parentSub),this.content.delete(e);}}gc(e,t){if(!this.deleted)throw te();this.content.gc(e),t?Rs(e,this,new $(this.id,this.length)):this.content=new fn(this.length);}write(e,t){let r=t>0?S(this.id.client,this.id.clock+t-1):this.origin,i=this.rightOrigin,s=this.parentSub,o=this.content.getRef()&31|(r===null?0:128)|(i===null?0:64)|(s===null?0:32);if(e.writeInfo(o),r!==null&&e.writeLeftID(r),i!==null&&e.writeRightID(i),r===null&&i===null){let c=this.parent;if(c._item!==void 0){let a=c._item;if(a===null){let l=xs(c);e.writeParentInfo(!0),e.writeString(l);}else e.writeParentInfo(!1),e.writeLeftID(a.id);}else c.constructor===String?(e.writeParentInfo(!0),e.writeString(c)):c.constructor===_e?(e.writeParentInfo(!1),e.writeLeftID(c)):te();s!==null&&e.writeString(s);}this.content.write(e,t);}};var Wr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},$r="__ $YJS$ __";Wr[$r]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Wr[$r]=!0;var Fe=n=>Promise.reject("unimplemented method GetVoiceSign"),wn=(n,e={},t=[])=>({command:n,front_request_id:X(),data:{...e,to_user_ids:Array.isArray(t)?t:[t]}}),Gr=()=>{window?.__Realsee_Live__&&(window?.__Realsee_Live__?.dispose?.(),window.__Realsee_Live__=null);},_t=class extends M{_options={};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}keyframes=new M;_yDoc;_buildInData;constructor(e){super(),p.info("Initializing Live instance with options:",e),this._addLiveControllerEventListeners(),this._yDoc=new he({guid:X()}),this._buildInData={keyframes:this._yDoc.getMap("keyframes")},this._initializeKeyframesObservers(),this._initializeOptions(e),this._autoConnect(),this._debugSetup();}get _buildInKeyframes(){return this._buildInData.keyframes}get snapshot(){return this._buildInData.keyframes.toJSON()}_initializeKeyframesObservers=()=>{this._buildInKeyframes.observe(this._handleKeyframesChange);};_handleKeyframesChange=e=>{let{transaction:t,target:r,changes:i}=e;if(r===this._buildInKeyframes)if(t.origin.triggerUserId===this.selfInfo?.id){let s=wn("KEYFRAME_SYNC",this.snapshot,void 0);try{this._controller.sendMessage(s);}catch(o){p.error("Failed to send keyframe sync message:",o);}}else i.keys.forEach((s,o)=>{let c=s.oldValue,a=this.getFramesByKey(o),l=t.origin.frontRequestId;this.keyframes.emit(o,a,c,l);}),i.keys.size!==0&&this.emit("keyframes",this.snapshot,t.origin.frontRequestId);};getFramesByKey=e=>this.snapshot[e];sendKeyframe=(e,t)=>this.state!==1?(p.warn("Attempted to send keyframe while connection is not open"),!1):(this._yDoc.transact(()=>{this._buildInKeyframes.set(e,t);},{triggerUserId:this.selfInfo?.id,frontRequestId:""}),!0);get selfInfo(){return this._buildInData.selfInfo}get userList(){return this._buildInData.userList||[]}get roomInfo(){return this._buildInData.roomInfo}_controller=new He;_initializeOptions(e){this._options=Object.assign({initialMicroStatus:"OPEN"},e),this._options.jsBridge=this._initializeJsBridge(e),this._options.getVoiceSign=e.getVoiceSign??Fe,this._options.autoPlayConfirm=e.autoPlayConfirm,this._options.rtc=this._initializeRTC(e);}_initializeJsBridge(e){if(e.jsBridge)return e.jsBridge;if(e.useBuiltInJsBridge)return new Ys}_initializeRTC(e){if(e.rtc)return e.rtc;if(e.rtcType)return this._createBuiltInRTC(e);if(e.useBuiltInRTC)return this._createDefaultRTC(e)}_createBuiltInRTC(e){if(!e.getVoiceSign){p.error("GetVoiceSign method must be passed when using built-in RTC instances");return}switch(e.rtcType){case"RealseeVRWebViewRTC":return this._createVRWebViewRTC();case"RealseeBrowserChimeRTC":return new ue({getVoiceSign:this._options.getVoiceSign??Fe,logLevel:e.__debug__?0:1});case"RealseeBrowserRTC":return this._createBrowserRTC();default:p.error("unknown built-in RTC type");return}}_createVRWebViewRTC(){if(this._options.jsBridge)return new xe({jsBridge:this._options.jsBridge,getVoiceSign:this._options.getVoiceSign??Fe});p.error("JsBridge instance must be passed when using built-in VRWebViewRTC instances");}_createBrowserRTC(){if(!this._options.autoPlayConfirm){p.error("autoPlayConfirm method must be passed when using built-in RealseeBrowserRTC instances");return}return new Ce({getVoiceSign:this._options.getVoiceSign??Fe,autoPlayConfirm:this._options.autoPlayConfirm})}_createDefaultRTC(e){if(!e.getVoiceSign){p.error("GetVoiceSign method must be passed when using built-in RTC instances");return}if(this._options.jsBridge){if(xn&&(En||kn)||Cn)return this._createVRWebViewRTC();{let t=this._options.getVoiceSign??Fe;return e.builtInRTCType==="chime"?new ue({getVoiceSign:t}):this._createBrowserRTC()}}else {p.error("jsBridge instance must be passed when using built-in RTC instances");return}}_autoConnect(){this._options.url&&this._options.getTicket&&this.connect();}_debugSetup(){this._options.__debug__&&Object.assign(window,{$liveController:this._controller,$live:this});}_addLiveControllerEventListeners=()=>{this._controller.on("stateChange",this._handleStateChange),this._controller.on("message",this._handleMessage);};_removeLiveControllerEventListeners=()=>{this._controller.off("stateChange",this._handleStateChange),this._controller.off("message",this._handleMessage);};_handleStateChange=(e,t)=>{p.info(`State changed from ${t} to ${e}`),this.emit("stateChange",e,t);};_handleMessage=async e=>{if(p.debug("Received message:",e),typeof e=="object"){let{command:t,data:r={},frontRequestId:i,code:s,message:o,triggerUserId:c}=e;if(s==="SUCCESS")switch(t){case"SELF_USER_INFO":{let a=r;In(this.selfInfo,a,{deep:!0})||(this._buildInData.selfInfo=a,this.emit("selfInfoUpdate",this._buildInData.selfInfo,i));break}case"ROOM_INFO":{let a=r;this._buildInData.roomInfo=Object.assign({},a);let l=a.last_frame||{};this._yDoc.transact(()=>{for(let d in l)this._buildInKeyframes.set(d,l[d]);},{triggerUserId:"readyKeyframeSync",frontRequestId:i}),this.emit("readyKeyframeSync",a.last_frame||{});break}case"RTC_INFO":{p.info("RTC info updated:",r);let{voice_id:a,type:l}=r;if(this._buildInData.rtcInfo={voiceId:a,type:l},this.$RTC?.joined)p.warn("\u5DF2\u52A0\u5165\u8BED\u97F3\u623F\u95F4\uFF0C\u65E0\u9700\u91CD\u590D\u52A0\u5165\uFF01");else if(await this.$RTC?.join({voiceId:a,userId:this.selfInfo?.id||"",roomId:this.roomInfo?.info.room_code,type:l})){let u=this._options.initialMicroStatus??"OPEN";await this.toggleMicro(u==="OPEN");}else p.error("\u52A0\u5165\u8BED\u97F3\u623F\u95F4\u5931\u8D25");break}case"USER_LIST":{let a=r;this._buildInData.userList=a,this.emit("userListUpdate",this.userList,i);break}case"CUSTOM_EVENT":{let a=r;this.emit("broadcast",a,i);break}case"KEYFRAME_SYNC":{let a=r;if(c===this.selfInfo?.id)return;this._yDoc.transact(()=>{for(let l in a)this._buildInKeyframes.set(l,a[l]);},{triggerUserId:c,frontRequestId:i});break}case"BUILTIN_MSG":{let a=r;this.emit("builtinEvent",a),a.event_type==="user_change"&&this.emit("userChange",a),a.event_type==="room_change"&&this.emit("roomChange",a),a.event_type==="user_change"&&a.action==="change_micro_status"&&await this.toggleMicro(a.data.status==="OPEN"),a.event_type==="room_change"&&a.action==="close"&&await this._exit();break}case"USER_KICK_OUT":{this.emit("kickOut");break}default:p.warn("Unknown command received:",t);}else p.error("Error in message:",o),this.emit("error",e);}};_clearLiveData=()=>{this._buildInKeyframes.clear(),this._buildInData={keyframes:this._yDoc.getMap("keyframes")};};connect=async(e={})=>{if(p.info("Attempting to connect with options:",e),this._options.url=e.url??this._options.url??"",this._options.getTicket=e.getTicket??this._options.getTicket,this._options.initialMicroStatus=e.rtcMicStatus??this._options.initialMicroStatus,!/^ws(s):\/\//.test(this._options.url)||typeof this._options.getTicket!="function")return new Error("Invalid connection parameters");if(this._options.rtc&&!await this._options.rtc.detectMicro())return new Error("Failed to obtain microphone authorization");let t=this.state;if(t===0||t===1)if(e.force)await this._controller.close("force close by connect").catch(console.warn);else return new Error("\u5DF2\u6709Live\u5B9E\u4F8B\u6B63\u5728\u8FDE\u63A5\u4E2D\uFF0C\u8BF7\u52FF\u91CD\u590D\u8FDE\u63A5\uFF01");this._clearLiveData();try{let r=await this._options.getTicket(),i=Sn(this._options.url,{ticket:r,force:+!!e.force});return this._controller.open(i),p.info("Connection established successfully"),!0}catch(r){return p.error("Failed to connect:",r),new Error("Failed to connect")}};_exit=async()=>{this._clearLiveData();try{await this.$RTC?.quit();}catch(e){p.warn(e);}return this.state!==1?!0:await this._controller.close()};exit=async()=>this.close();close=async()=>{await this._controller.readyClose();try{await this.$RTC?.quit();}catch(e){p.warn(e);}await this.updateStatus("room_change","close",{});};dispose=async()=>(this._removeLiveControllerEventListeners(),this._clearLiveData(),await this._controller.dispose());async updateStatus(e,t,r,i){if(this.state!==1)return !1;let s=Object.assign({event_type:e,action:t},{data:r}),o=wn("BUILTIN_MSG",s,i);try{return this._controller.sendMessage(o),!0}catch(c){return p.error(c),!1}}setSelfInfo=async e=>await this.updateStatus("user_change","change_info",e);broadcast(e,t,r){return this.state!==1?!1:new Promise((i,s)=>{let o=wn("CUSTOM_EVENT",e,t),c=o.front_request_id,a=r?setTimeout(()=>{s(new Error("RESPONSE TIMEOUT")),this.off("broadcast",l);},r):void 0,l=(d,u)=>{u===c&&(a&&clearTimeout(a),this.off("broadcast",l),i(d));};this.on("broadcast",l);try{this._controller.sendMessage(o);}catch(d){s(d);}})}toggleMicro=async e=>{if(!this.selfInfo?.permission?.control_own_micro)return !1;let t=await this.$RTC?.toggleMicro(e);return t&&await this.updateStatus("user_change","change_micro_status",{status:e?"OPEN":"CLOSE"},[]),t};forbidMicro=async(e,t)=>typeof this._options.canForbidUserMicro=="function"&&!this._options.canForbidUserMicro(t)||!this.selfInfo?.permission?.control_other_micro?!1:await this.updateStatus("user_change","change_micro_status",{status:e},t);forbidSync=async(e,t)=>typeof this._options.canForbidUserSync=="function"&&!this._options.canForbidUserSync(t)||!this.selfInfo?.permission?.control_other_sync?!1:await this.updateStatus("user_change","change_permission",{sync_frame:e},t);kick=async e=>typeof this._options.canForbidUserKick=="function"&&!this._options.canForbidUserKick(e)||!this.selfInfo?.permission?.change_other_status?!1:await this.updateStatus("user_change","change_status",{status:"KICK_OUT"},e);getSnapshotForKey(e){return this.snapshot[e]}};var qr=n=>(Gr(),new _t(n));function Zc(n){let e=createContext(null),t=qr(n),r=t.jsBridge,i=h=>D.createElement(e.Provider,{value:t},h.children),s=()=>{let h=D.useContext(e);if(!h)throw new Error("LiveProvider never found.");return h},o=()=>t,c=()=>t.$RTC,a=()=>c(),l=()=>async h=>await t.connect(h);function d(h,_,x=[]){let m=s(),v=[m,name,...x],R=()=>m.keyframes.off(h,_);return D.useEffect(()=>(m.keyframes.on(h,_),R),v),R}function u(){let h=s(),_=useCallback(async E=>{await h.connect(E);},[h]),x=useCallback(E=>{h.toggleMicro(E);},[h]),m=useCallback(async(E,G,St=0)=>{await h.broadcast(E,G,St);},[h]),v=useCallback(async()=>{await h.exit();},[h]),R=useCallback(async E=>{await h.kick(E);},[h]),z=useCallback(async(E,G=[])=>{await h.forbidMicro(E,G);},[h]),We=useCallback((E,G=[])=>{h.forbidSync(E,G);},[h]),bt=useCallback(E=>h.getFramesByKey(E),[h]),Xr=useCallback((E,G)=>{h.sendKeyframe(E,G);},[h]),Zr=useCallback(E=>{h.setSelfInfo(E);},[h]),Qr=useCallback((E,G,St,ei)=>{h.updateStatus(E,G,St,ei);},[h]);return {connect:_,broadcast:m,exit:v,kick:R,toggleMicro:x,forbidMicro:z,forbidSync:We,sendKeyframe:Xr,getFramesByKey:bt,setSelfInfo:Zr,updateStatus:Qr}}function g(h){let _=s(),[x,m]=D.useState(_.getFramesByKey(h));D.useEffect(()=>{let R=bt=>m(bt),z=h,We=R;return _.keyframes.on(z,We),()=>_.keyframes.off(z,We)},[_]);let v=D.useCallback(R=>_.sendKeyframe(h,R),[_]);return [x,v]}function f(h,_,x=[]){let m=s(),v=()=>m.off(h,_),R=[m,h,...x];return D.useEffect(()=>(m.on(h,_),v),R),v}function w(){let h=s(),[_,x]=D.useState(h.state);return D.useEffect(()=>{let m=v=>x(v);return h.on("stateChange",m),()=>h.off("stateChange",m)},[h]),_}function C(){let h=s();return {join:z=>h.$RTC.join(z),quit:()=>h.$RTC.quit(),shock:()=>h.$RTC.shock?.(),toggleMicro:z=>h.$RTC.toggleMicro(z),detectMicro:()=>h.$RTC.detectMicro()}}function Jr(h,_,x=[]){let m=s(),v=()=>m.$RTC.off(h,_),R=[m,h,...x];return D.useEffect(()=>(m.$RTC.on(h,_),v),R),v}function Hr(){let h=s(),[_,x]=D.useState(h.selfInfo||{}),m=R=>x(R);D.useEffect(()=>(h.on("selfInfoUpdate",m),()=>h.off("selfInfoUpdate",m)),[h]);let v=D.useCallback(async R=>await h.setSelfInfo(R),[h]);return [_,v]}function zr(){let h=s(),[_,x]=D.useState(h.snapshot);return D.useEffect(()=>{let m=v=>x(v);return h.on("keyframes",m),()=>h.off("keyframes",m)},[h]),_}function Yr(){let h=s(),[_,x]=D.useState(h.userList),m=v=>x(v);return D.useEffect(()=>(h.on("userListUpdate",m),()=>h.off("userListUpdate",m)),[h]),_}return {live:t,jsBridge:r,LiveProvider:i,unsafe__useLiveInstance:o,unsafe__useRTCInstance:a,useConnect:l,useKeyframe:g,useKeyframeUpdateCallback:d,useLiveAction:u,useLiveEventCallback:f,useLiveState:w,useRTCAction:C,useRTCEventCallback:Jr,useSelfInfo:Hr,useKeyframesSnapshot:zr,useUserList:Yr}}console.log(`%c${process.env.__REALSEE_LIVE_VERSION__}`,"background: #237804; color: white; padding: 2px 4px; border-radius: 4px;");
9
-
10
- export { Ce as BrowserRTC, ue as BrowserRTC4Chime, ri as BuiltInRTCType, pi as BuiltinActionType, gi as BuiltinEventType, fi as Command, q as CoreRTC, _t as Live, yi as LiveState, _i as MemUserStatus, mi as MicroStatus, ui as RTCJoinedInfoCodeEnum, ni as RTCType, M as Subscribe, wi as UserStatus, xe as VRWebViewRTC, vi as WebSocketCloseError, Si as WebSocketErrorType, bi as WebSocketState, Gr as _clearLiveInstanceIfNeed, qr as createLive, Zc as createLiveReact, Ro as parseLiveMsg, bn as parseWSClsErr };
@@ -1,211 +0,0 @@
1
- [**如视 Live SDK**](../README.md) • **Docs**
2
-
3
- ***
4
-
5
- [如视 Live SDK](../globals.md) / Subscribe
6
-
7
- # Class: Subscribe\<T\>
8
-
9
- 监听者模式
10
-
11
- ## Example
12
-
13
- ```
14
- new Subscribe<{
15
- "foo": [arg1: number, arg2: string],
16
- "bar": [arg: boolean],
17
- }>()
18
- ```
19
-
20
- ## Extended by
21
-
22
- - [`CoreRTC`](CoreRTC.md)
23
- - [`RTCProtocol`](../interfaces/RTCProtocol.md)
24
- - [`Live`](Live.md)
25
-
26
- ## Type Parameters
27
-
28
- • **T** *extends* [`EventMap`](../type-aliases/EventMap.md)
29
-
30
- 预设的监听回调类型
31
-
32
- ## Constructors
33
-
34
- ### new Subscribe()
35
-
36
- > **new Subscribe**\<`T`\>(): [`Subscribe`](Subscribe.md)\<`T`\>
37
-
38
- #### Returns
39
-
40
- [`Subscribe`](Subscribe.md)\<`T`\>
41
-
42
- ## Methods
43
-
44
- ### emit()
45
-
46
- > **emit**\<`K`\>(`name`, ...`data`): `boolean`
47
-
48
- 触发事件
49
-
50
- #### Type Parameters
51
-
52
- • **K** *extends* `string` \| `number` \| `symbol`
53
-
54
- 预设的监听事件名称
55
-
56
- #### Parameters
57
-
58
- • **name**: `K`
59
-
60
- 事件类型
61
-
62
- • ...**data**: `Parameters`\<`T`\[`K`\]\>
63
-
64
- 触发事件的数据
65
-
66
- #### Returns
67
-
68
- `boolean`
69
-
70
- canceled 是否被触发取消
71
-
72
- #### Defined in
73
-
74
- utils/subscribe.ts:113
75
-
76
- ***
77
-
78
- ### hasListener()
79
-
80
- > **hasListener**(`name`): `boolean`
81
-
82
- 判断是否注册了事件
83
-
84
- #### Parameters
85
-
86
- • **name**: keyof `T`
87
-
88
- 事件类型
89
-
90
- #### Returns
91
-
92
- `boolean`
93
-
94
- #### Defined in
95
-
96
- utils/subscribe.ts:41
97
-
98
- ***
99
-
100
- ### off()
101
-
102
- > **off**\<`K`\>(`name`?, `callback`?): `void`
103
-
104
- 解除事件
105
-
106
- 如果 name 不传的话解除对应所有事件
107
- 如果 name, callback 不传的话解除所有name的所有事件
108
-
109
- #### Type Parameters
110
-
111
- • **K** *extends* `string` \| `number` \| `symbol`
112
-
113
- 预设的监听事件名称
114
-
115
- #### Parameters
116
-
117
- • **name?**: `K`
118
-
119
- 事件类型
120
-
121
- • **callback?**
122
-
123
- 事件回调函数
124
-
125
- #### Returns
126
-
127
- `void`
128
-
129
- #### Defined in
130
-
131
- utils/subscribe.ts:87
132
-
133
- ***
134
-
135
- ### on()
136
-
137
- > **on**\<`K`\>(`name`, `callback`, `once`?): () => `void`
138
-
139
- 注册事件
140
-
141
- #### Type Parameters
142
-
143
- • **K** *extends* `string` \| `number` \| `symbol`
144
-
145
- 预设的监听事件名称
146
-
147
- #### Parameters
148
-
149
- • **name**: `K`
150
-
151
- 事件类型
152
-
153
- • **callback**
154
-
155
- 事件回调函数
156
-
157
- • **once?**: `boolean`
158
-
159
- 是否只执行一次
160
-
161
- #### Returns
162
-
163
- `Function`
164
-
165
- 解除事件
166
-
167
- ##### Returns
168
-
169
- `void`
170
-
171
- #### Defined in
172
-
173
- utils/subscribe.ts:55
174
-
175
- ***
176
-
177
- ### once()
178
-
179
- > **once**\<`K`\>(`name`, `callback`): () => `void`
180
-
181
- 注册事件(是否只执行一次)
182
-
183
- #### Type Parameters
184
-
185
- • **K** *extends* `string` \| `number` \| `symbol`
186
-
187
- 预设的监听事件名称
188
-
189
- #### Parameters
190
-
191
- • **name**: `K`
192
-
193
- 事件类型
194
-
195
- • **callback**
196
-
197
- 事件回调函数
198
-
199
- #### Returns
200
-
201
- `Function`
202
-
203
- 解除事件
204
-
205
- ##### Returns
206
-
207
- `void`
208
-
209
- #### Defined in
210
-
211
- utils/subscribe.ts:74
@@ -1,17 +0,0 @@
1
- [**如视 Live SDK**](../../README.md) • **Docs**
2
-
3
- ***
4
-
5
- [如视 Live SDK](../../globals.md) / SubscribeMixinType
6
-
7
- # SubscribeMixinType
8
-
9
- ## Index
10
-
11
- ### Interfaces
12
-
13
- - [emit](interfaces/emit.md)
14
- - [hasListener](interfaces/hasListener.md)
15
- - [off](interfaces/off.md)
16
- - [on](interfaces/on.md)
17
- - [once](interfaces/once.md)
@@ -1,31 +0,0 @@
1
- [**如视 Live SDK**](../../../README.md) • **Docs**
2
-
3
- ***
4
-
5
- [如视 Live SDK](../../../globals.md) / [SubscribeMixinType](../README.md) / emit
6
-
7
- # Interface: emit()\<T\>
8
-
9
- ## Type Parameters
10
-
11
- • **T** *extends* [`EventMap`](../../../type-aliases/EventMap.md)
12
-
13
- > **emit**\<`K`\>(`name`, ...`data`): `boolean`
14
-
15
- ## Type Parameters
16
-
17
- • **K** *extends* `string` \| `number` \| `symbol`
18
-
19
- ## Parameters
20
-
21
- • **name**: `K`
22
-
23
- • ...**data**: `Parameters`\<`T`\[`K`\]\>
24
-
25
- ## Returns
26
-
27
- `boolean`
28
-
29
- ## Defined in
30
-
31
- utils/subscribe.ts:141
@@ -1,25 +0,0 @@
1
- [**如视 Live SDK**](../../../README.md) • **Docs**
2
-
3
- ***
4
-
5
- [如视 Live SDK](../../../globals.md) / [SubscribeMixinType](../README.md) / hasListener
6
-
7
- # Interface: hasListener()\<T\>
8
-
9
- ## Type Parameters
10
-
11
- • **T** *extends* [`EventMap`](../../../type-aliases/EventMap.md)
12
-
13
- > **hasListener**(`name`): `boolean`
14
-
15
- ## Parameters
16
-
17
- • **name**: keyof `T`
18
-
19
- ## Returns
20
-
21
- `boolean`
22
-
23
- ## Defined in
24
-
25
- utils/subscribe.ts:129
@@ -1,31 +0,0 @@
1
- [**如视 Live SDK**](../../../README.md) • **Docs**
2
-
3
- ***
4
-
5
- [如视 Live SDK](../../../globals.md) / [SubscribeMixinType](../README.md) / off
6
-
7
- # Interface: off()\<T\>
8
-
9
- ## Type Parameters
10
-
11
- • **T** *extends* [`EventMap`](../../../type-aliases/EventMap.md)
12
-
13
- > **off**\<`K`\>(`names`?, `callback`?): `void`
14
-
15
- ## Type Parameters
16
-
17
- • **K** *extends* `string` \| `number` \| `symbol`
18
-
19
- ## Parameters
20
-
21
- • **names?**: `K` \| `K`[]
22
-
23
- • **callback?**
24
-
25
- ## Returns
26
-
27
- `void`
28
-
29
- ## Defined in
30
-
31
- utils/subscribe.ts:138
@@ -1,37 +0,0 @@
1
- [**如视 Live SDK**](../../../README.md) • **Docs**
2
-
3
- ***
4
-
5
- [如视 Live SDK](../../../globals.md) / [SubscribeMixinType](../README.md) / on
6
-
7
- # Interface: on()\<T\>
8
-
9
- ## Type Parameters
10
-
11
- • **T** *extends* [`EventMap`](../../../type-aliases/EventMap.md)
12
-
13
- > **on**\<`K`\>(`name`, `callback`, `once`?): () => `void`
14
-
15
- ## Type Parameters
16
-
17
- • **K** *extends* `string` \| `number` \| `symbol`
18
-
19
- ## Parameters
20
-
21
- • **name**: `K`
22
-
23
- • **callback**
24
-
25
- • **once?**: `boolean`
26
-
27
- ## Returns
28
-
29
- `Function`
30
-
31
- ### Returns
32
-
33
- `void`
34
-
35
- ## Defined in
36
-
37
- utils/subscribe.ts:132
@@ -1,35 +0,0 @@
1
- [**如视 Live SDK**](../../../README.md) • **Docs**
2
-
3
- ***
4
-
5
- [如视 Live SDK](../../../globals.md) / [SubscribeMixinType](../README.md) / once
6
-
7
- # Interface: once()\<T\>
8
-
9
- ## Type Parameters
10
-
11
- • **T** *extends* [`EventMap`](../../../type-aliases/EventMap.md)
12
-
13
- > **once**\<`K`\>(`name`, `callback`): () => `void`
14
-
15
- ## Type Parameters
16
-
17
- • **K** *extends* `string` \| `number` \| `symbol`
18
-
19
- ## Parameters
20
-
21
- • **name**: `K`
22
-
23
- • **callback**
24
-
25
- ## Returns
26
-
27
- `Function`
28
-
29
- ### Returns
30
-
31
- `void`
32
-
33
- ## Defined in
34
-
35
- utils/subscribe.ts:135
@@ -1,17 +0,0 @@
1
- [**如视 Live SDK**](../README.md) • **Docs**
2
-
3
- ***
4
-
5
- [如视 Live SDK](../globals.md) / EventMap
6
-
7
- # Type Alias: EventMap
8
-
9
- > **EventMap**: `object`
10
-
11
- ## Index Signature
12
-
13
- \[`name`: `string`\]: (...`args`) => `void` \| `boolean`
14
-
15
- ## Defined in
16
-
17
- utils/subscribe.ts:3