"use strict";(self["webpackChunkquick_vue3"]=self["webpackChunkquick_vue3"]||[]).push([[443],{6079:function(e,t,i){i.r(t),i.d(t,{default:function(){return J}});i(6885),i(8839),i(6809);var s=i(6939),o=i(7610),a=i(5791),l=i(3396),n=i(7139),r=i(4870),d=i(4940),c=i(5574),h=i(2026),u=i(2482),m=i(2741),p=i.n(m),g=i(1735);class I{constructor(e){(0,u.Z)(this,"sdkAppId",void 0),(0,u.Z)(this,"userId",void 0),(0,u.Z)(this,"secretKey",void 0),(0,u.Z)(this,"roomId",void 0),(0,u.Z)(this,"userSig",void 0),(0,u.Z)(this,"client",void 0),(0,u.Z)(this,"localStream",void 0),(0,u.Z)(this,"isJoined",void 0),(0,u.Z)(this,"isPublished",void 0),(0,u.Z)(this,"remoteStreams",void 0),(0,u.Z)(this,"video",void 0),(0,u.Z)(this,"audio",void 0),(0,u.Z)(this,"cameraId",void 0),(0,u.Z)(this,"microphoneId",void 0);const{sdkAppId:t,userId:i,roomId:s,secretKey:o,userSig:a}=e;this.sdkAppId=t,this.userId=i,this.secretKey=o,this.userSig=a,this.roomId=s,this.client=null,this.localStream=null,this.remoteStreams=[],this.isJoined=!1,this.isPublished=!1,this.cameraId="",this.microphoneId="",this.video=!0,this.audio=!0,this.initClient()}initClient(){const e=this.userSig||(0,g.h)({sdkAppId:this.sdkAppId,userId:this.userId,secretKey:this.secretKey}).userSig;try{this.client=p().createClient({mode:"rtc",sdkAppId:this.sdkAppId,userId:this.userId,userSig:e}),console.log(`Client [${this.userId}] created.`),this.installEventHandlers()}catch(t){console.log(`Failed to create Client [${this.userId}].`)}}createShareLink(){const e=String(Math.floor(1e6*Math.random())),{userSig:t}=(0,g.h)({sdkAppId:this.sdkAppId,userId:e,secretKey:this.secretKey}),{origin:i}=window.location,s=window.location.pathname.replace("index.html","invite/invite.html");return`${i}${s}?userSig=${t}&&SDKAppId=${this.sdkAppId}&&userId=${e}&&roomId=${this.roomId}`}async initLocalStream(){try{this.localStream=p().createStream({userId:this.userId,audio:!0,video:!0,cameraId:this.cameraId,microphoneId:this.microphoneId}),this.localStream.setVideoProfile("480p");try{await this.localStream.initialize(),console.log(`LocalStream [${this.userId}] initialized`)}catch(e){console.log(`LocalStream failed to initialize. Error: ${e.message_}`)}}catch(e){console.log(`${this.userId} failed to create LocalStream. Error: ${e.message_}`)}}async join(){console.log("join room clicked");try{await this.client.join({roomId:this.roomId}),this.isJoined=!0,console.log(`Join room [${this.roomId}] success`);try{await this.initLocalStream()}catch(e){console.log(`Init LocalStream failed. Error: ${e.message_}`)}}catch(t){console.log(`Join room ${this.roomId} failed, please check your params. Error: ${t.message_}`)}}async publish(){if(this.isJoined){if(this.isPublished)console.warn("duplicate publish() observed");else if(this.localStream)try{await this.client.publish(this.localStream),this.isPublished=!0,console.log("LocalStream is published successfully")}catch(e){console.log(`LocalStream is failed to publish. Error: ${e.message_}`)}}else console.warn("call publish()- please join() firstly")}async unpublish(){if(this.isJoined)if(this.isPublished)try{await this.client.unpublish(this.localStream),this.isPublished=!1,console.log("Unpublish localStream success")}catch(e){console.log(`LocalStream is failed to unpublish. Error: ${e.message_}`)}else console.warn("call unpublish() - you have not published yet");else console.warn("unpublish() - please join() firstly")}async leave(){if(this.isJoined){await this.unpublish();try{await this.client.leave(),console.log("Leave room success"),this.isJoined=!1,this.localStream&&(this.localStream.stop(),this.localStream.close(),this.localStream=null)}catch(e){console.error("leave failed",e),console.log(`Leave room failed. Error: ${e.message_}`)}}else console.warn("leave() - please join() firstly")}async switchDevice({videoId:e,audioId:t}){if(this.isJoined){if(e)try{await this.localStream.switchDevice("video",e),console.log("Switch video device success")}catch(i){console.error("switchDevice failed",i),console.log("Switch video device failed")}if(t)try{await this.localStream.switchDevice("audio",t),console.log("Switch audio device success")}catch(i){console.error("switchDevice failed",i),console.log("Switch audio device failed")}}}installEventHandlers(){this.client.on("error",this.handleError.bind(this)),this.client.on("client-banned",this.handleBanned.bind(this)),this.client.on("peer-join",this.handlePeerJoin.bind(this)),this.client.on("peer-leave",this.handlePeerLeave.bind(this)),this.client.on("stream-added",this.handleStreamAdded.bind(this)),this.client.on("stream-updated",this.handleStreamUpdated.bind(this)),this.client.on("connection-state-changed",this.handleConnection.bind(this)),this.client.on("mute-video",this.handleMuteVideo.bind(this)),this.client.on("mute-audio",this.handleMuteAudio.bind(this)),this.client.on("unmute-video",this.handleUnmuteVideo.bind(this)),this.client.on("unmute-audio",this.handleUnmuteAudio.bind(this))}handleMuteVideo(e){console.log(`[${e.userId}] mute video`)}handleMuteAudio(e){console.log(`[${e.userId}] mute audio`)}handleUnmuteVideo(e){console.log(`[${e.userId}] unmute video`)}handleUnmuteAudio(e){console.log(`[${e.userId}] unmute audio`)}handleError(e){(0,c.z8)({message:e.message_,type:"error"}),console.log(`RTCError: ${e.message_}`)}handleBanned(e){console.warn(`client has been banned for ${e.reason}`)}handlePeerJoin(e){const{userId:t}=e;"local-screen"!==t&&console.log(`Peer Client [${t}] joined`)}handlePeerLeave(e){const{userId:t}=e;"local-screen"!==t&&console.log(`[${t}] leave`)}handleStreamAdded(e){const t=e.stream,i=t.getId(),s=t.getUserId();t.getUserId()===`share_${this.userId}`?this.client.unsubscribe(t).catch((()=>{console.log(`Unsubscribe [${s}] failed`)})):(console.log(`remote stream added: [${s}] ID: ${i} type: ${t.getType()}`),this.client.subscribe(t).catch((()=>{console.log(`Subscribe [${s}] failed`)})))}handleStreamSubscribed(e){const t=e.stream,i=t.getId(),s=t.getUserId();console.log(`RemoteStream subscribed: [${s}]`),this.remoteStreams.push(t),console.log("stream-subscribed ID: ",i)}handleStreamRemoved(e){const t=e.stream,i=t.getId(),s=t.getUserId();t.stop(),t.getUserId()!==`share_${this.userId}`&&console.log(`RemoteStream removed: [${s}]`),this.remoteStreams=this.remoteStreams.filter((e=>e.getId()!==i))}handleStreamUpdated(e){const t=e.stream,i=t.getUserId();console.log(`RemoteStream updated: [${i}] audio:${t.hasAudio()} video:${t.hasVideo()}`)}handleConnection(e){console.log(`connection state changed: ${e.state}`)}getClient(){return this.client}getLocalStream(){return this.localStream}}var v=I,S=i(630);const b=e=>((0,l.dD)("data-v-ca3824de"),e=e(),(0,l.Cn)(),e),y={class:"invite"},w={class:"share-link"},f={class:"alert"},$={style:{"padding-top":"10px"}},k=(0,l.Uk)(" Join "),_=(0,l.Uk)(" Leave "),A=b((()=>(0,l._)("div",{id:"local",style:{"max-width":"640px","margin-top":"20px"}},null,-1))),U={class:"remote-container"},L=["id"];var Z=(0,l.aZ)({setup(e){const{t:t}=(0,d.QT)(),i=(0,S.Z)(),u=parseInt((0,h.cP)("sdkAppId"),10),m=(0,h.cP)("userId"),p=(0,h.cP)("userSig"),g=parseInt((0,h.cP)("roomId"),10),I={url:window.location.href.split("?")[0]};let b;async function Z(){try{b=new v({sdkAppId:u,userSig:p,userId:m,roomId:g});const e=b.getClient();e.on("stream-subscribed",C),e.on("stream-removed",P),await b.join(),await b.publish();const t=b.getLocalStream();await(0,l.Y3)(),t.play("local")}catch(e){(0,c.z8)({message:e.message_,type:"error"})}}async function C(e){const t=e.stream,s=t.getId(),o=`${s}`;console.log(1212,e),i.invitedRemoteStreams.push(t),await(0,l.Y3)(),t.play(o).then((()=>{console.log(`RemoteStream play success: [${m}]`)})).catch((e=>{console.log(`RemoteStream play failed: [${m}], error: ${e.message_}`)}))}async function P(e){const t=e.stream,s=t.getId();i.invitedRemoteStreams=i.invitedRemoteStreams.filter((e=>e.getId()!==s))}async function J(){await b.leave()}return window.history.pushState(I,"","index.html#/invite"),u&&m&&p&&g||c.z8.error(t("check")),(e,d)=>{const c=a.mi,h=o.Dv,u=s.dq;return(0,l.wg)(),(0,l.j4)(u,{style:{padding:"0 10px 40px 10px"}},{default:(0,l.w5)((()=>[(0,l.Wm)(h,{md:{span:18,offset:3},sm:{span:24}},{default:(0,l.w5)((()=>[(0,l._)("div",y,[(0,l._)("div",w,[(0,l._)("div",f,(0,n.zw)((0,r.SU)(t)("inviteUrl")),1)])]),(0,l._)("div",$,[(0,l.Wm)(c,{type:"primary",onClick:Z},{default:(0,l.w5)((()=>[k])),_:1}),(0,l.Wm)(c,{type:"primary",onClick:J},{default:(0,l.w5)((()=>[_])),_:1})]),A,(0,l._)("div",U,[((0,l.wg)(!0),(0,l.iD)(l.HY,null,(0,l.Ko)((0,r.SU)(i).invitedRemoteStreams,(e=>((0,l.wg)(),(0,l.iD)("div",{key:e.getId(),id:e.getId(),style:{"max-width":"640px","margin-top":"20px"}},null,8,L)))),128))])])),_:1})])),_:1})}}}),C=i(89);const P=(0,C.Z)(Z,[["__scopeId","data-v-ca3824de"]]);var J=P}}]); //# sourceMappingURL=about.24e22fde.js.map