File size: 226,693 Bytes
6fa5b70 |
1 |
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[463],{26347:function(e,t,i){let n,a,s,r;i.d(t,{$A:function(){return aB},Bl:function(){return N},F3:function(){return eb},GR:function(){return sl},HS:function(){return aD},IH:function(){return aO},JM:function(){return nF},Jq:function(){return e8},NJ:function(){return aP},Ne:function(){return aR},OX:function(){return nM},PP:function(){return ey},Uq:function(){return O},VJ:function(){return nk},WV:function(){return ay},WW:function(){return aN},_J:function(){return iz},_l:function(){return aE},aG:function(){return aU},dP:function(){return aF},dg:function(){return aW},iE:function(){return aL},pJ:function(){return aV},st:function(){return aK},sy:function(){return ah},xX:function(){return av},xp:function(){return nW}}),i(98394);var o,l,c,d,h,u,p,g,m,f,y,b,v,k,w,T,C,S,I,R,E,D,_,P,U,N,A,O,L,B=i(16323),j=i(32701),F=i(55439),W=i(85424),V=i(35614),M=i(94863),x=i(3406),H=i(5279),z=i(38472),q=i(86623),K=i(48156),J=i(25575),G=i(89759),$=i(45715),Q=i(65690),X=i(57324),Y=i(39864),Z=i(76913),ee=i(12531),et=i(88007),ei=i(43182),en=i(29809),ea=i(92660),es=i(14),er=i(71134),eo=i(37369),el=i(8450),ec=i(70394),ed=i(2127),eh=i(12270),eu=i(48793),ep=i(26088),eg=i(74811),em=i(48738),ef=i(20357);let ey={BLOCK_USERS:"block-users",CREATE_CALL:"create-call",CREATE_REACTION:"create-reaction",END_CALL:"end-call",JOIN_BACKSTAGE:"join-backstage",JOIN_CALL:"join-call",JOIN_ENDED_CALL:"join-ended-call",MUTE_USERS:"mute-users",PIN_FOR_EVERYONE:"pin-for-everyone",READ_CALL:"read-call",REMOVE_CALL_MEMBER:"remove-call-member",SCREENSHARE:"screenshare",SEND_AUDIO:"send-audio",SEND_VIDEO:"send-video",START_BROADCAST_CALL:"start-broadcast-call",START_RECORD_CALL:"start-record-call",START_TRANSCRIPTION_CALL:"start-transcription-call",STOP_BROADCAST_CALL:"stop-broadcast-call",STOP_RECORD_CALL:"stop-record-call",STOP_TRANSCRIPTION_CALL:"stop-transcription-call",UPDATE_CALL:"update-call",UPDATE_CALL_MEMBER:"update-call-member",UPDATE_CALL_PERMISSIONS:"update-call-permissions",UPDATE_CALL_SETTINGS:"update-call-settings"},eb={FRONT:"front",BACK:"back",EXTERNAL:"external"};class ev extends Error{}(o=T||(T={}))[o.NULL_VALUE=0]="NULL_VALUE";class ek extends B.C{internalJsonWrite(e,t){let i={};for(let[t,n]of Object.entries(e.fields))i[t]=eC.toJson(n);return i}internalJsonRead(e,t,i){if(!(0,j.b)(e))throw new globalThis.Error("Unable to parse message "+this.typeName+" from JSON "+(0,j.Z)(e)+".");for(let[t,n]of(i||(i=this.create()),globalThis.Object.entries(e)))i.fields[t]=eC.fromJson(n);return i}create(e){let t={fields:{}};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();if(1===t)this.binaryReadMap1(a.fields,e,i);else{let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}binaryReadMap1(e,t,i){let n=t.uint32(),a=t.pos+n,s,r;for(;t.pos<a;){let[e,n]=t.tag();switch(e){case 1:s=t.string();break;case 2:r=eC.internalBinaryRead(t,t.uint32(),i);break;default:throw new globalThis.Error("unknown map entry field for field google.protobuf.Struct.fields")}}e[null!=s?s:""]=null!=r?r:eC.create()}internalBinaryWrite(e,t,i){for(let n of Object.keys(e.fields))t.tag(1,V.TD.LengthDelimited).fork().tag(1,V.TD.LengthDelimited).string(n),t.tag(2,V.TD.LengthDelimited).fork(),eC.internalBinaryWrite(e.fields[n],t,i),t.join().join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("google.protobuf.Struct",[{no:1,name:"fields",kind:"map",K:9,V:{kind:"message",T:()=>eC}}])}}let ew=new ek;class eT extends B.C{internalJsonWrite(e,t){if(void 0===e.kind.oneofKind)throw new globalThis.Error;switch(e.kind.oneofKind){case void 0:throw new globalThis.Error;case"boolValue":return e.kind.boolValue;case"nullValue":return null;case"numberValue":return e.kind.numberValue;case"stringValue":return e.kind.stringValue;case"listValue":let i=this.fields.find(e=>6===e.no);if((null==i?void 0:i.kind)!=="message")throw new globalThis.Error;return i.T().toJson(e.kind.listValue);case"structValue":let n=this.fields.find(e=>5===e.no);if((null==n?void 0:n.kind)!=="message")throw new globalThis.Error;return n.T().toJson(e.kind.structValue)}}internalJsonRead(e,t,i){switch(i||(i=this.create()),typeof e){case"number":i.kind={oneofKind:"numberValue",numberValue:e};break;case"string":i.kind={oneofKind:"stringValue",stringValue:e};break;case"boolean":i.kind={oneofKind:"boolValue",boolValue:e};break;case"object":null===e?i.kind={oneofKind:"nullValue",nullValue:T.NULL_VALUE}:globalThis.Array.isArray(e)?i.kind={oneofKind:"listValue",listValue:eI.fromJson(e)}:i.kind={oneofKind:"structValue",structValue:ew.fromJson(e)};break;default:throw new globalThis.Error("Unable to parse "+this.typeName+" from JSON "+(0,j.Z)(e))}return i}create(e){let t={kind:{oneofKind:void 0}};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.kind={oneofKind:"nullValue",nullValue:e.int32()};break;case 2:a.kind={oneofKind:"numberValue",numberValue:e.double()};break;case 3:a.kind={oneofKind:"stringValue",stringValue:e.string()};break;case 4:a.kind={oneofKind:"boolValue",boolValue:e.bool()};break;case 5:a.kind={oneofKind:"structValue",structValue:ew.internalBinaryRead(e,e.uint32(),i,a.kind.structValue)};break;case 6:a.kind={oneofKind:"listValue",listValue:eI.internalBinaryRead(e,e.uint32(),i,a.kind.listValue)};break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){"nullValue"===e.kind.oneofKind&&t.tag(1,V.TD.Varint).int32(e.kind.nullValue),"numberValue"===e.kind.oneofKind&&t.tag(2,V.TD.Bit64).double(e.kind.numberValue),"stringValue"===e.kind.oneofKind&&t.tag(3,V.TD.LengthDelimited).string(e.kind.stringValue),"boolValue"===e.kind.oneofKind&&t.tag(4,V.TD.Varint).bool(e.kind.boolValue),"structValue"===e.kind.oneofKind&&ew.internalBinaryWrite(e.kind.structValue,t.tag(5,V.TD.LengthDelimited).fork(),i).join(),"listValue"===e.kind.oneofKind&&eI.internalBinaryWrite(e.kind.listValue,t.tag(6,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("google.protobuf.Value",[{no:1,name:"null_value",kind:"enum",oneof:"kind",T:()=>["google.protobuf.NullValue",T]},{no:2,name:"number_value",kind:"scalar",oneof:"kind",T:1},{no:3,name:"string_value",kind:"scalar",oneof:"kind",T:9},{no:4,name:"bool_value",kind:"scalar",oneof:"kind",T:8},{no:5,name:"struct_value",kind:"message",oneof:"kind",T:()=>ew},{no:6,name:"list_value",kind:"message",oneof:"kind",T:()=>eI}])}}let eC=new eT;class eS extends B.C{internalJsonWrite(e,t){return e.values.map(e=>eC.toJson(e))}internalJsonRead(e,t,i){if(!globalThis.Array.isArray(e))throw new globalThis.Error("Unable to parse "+this.typeName+" from JSON "+(0,j.Z)(e));i||(i=this.create());let n=e.map(e=>eC.fromJson(e));return i.values.push(...n),i}create(e){let t={values:[]};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();if(1===t)a.values.push(eC.internalBinaryRead(e,e.uint32(),i));else{let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){for(let n=0;n<e.values.length;n++)eC.internalBinaryWrite(e.values[n],t.tag(1,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("google.protobuf.ListValue",[{no:1,name:"values",kind:"message",repeat:1,T:()=>eC}])}}let eI=new eS;class eR extends B.C{now(){let e=this.create(),t=Date.now();return e.seconds=M.MJ.from(Math.floor(t/1e3)).toString(),e.nanos=t%1e3*1e6,e}toDate(e){return new Date(1e3*M.MJ.from(e.seconds).toNumber()+Math.ceil(e.nanos/1e6))}fromDate(e){let t=this.create(),i=e.getTime();return t.seconds=M.MJ.from(Math.floor(i/1e3)).toString(),t.nanos=i%1e3*1e6,t}internalJsonWrite(e,t){let i=1e3*M.MJ.from(e.seconds).toNumber();if(i<Date.parse("0001-01-01T00:00:00Z")||i>Date.parse("9999-12-31T23:59:59Z"))throw Error("Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");if(e.nanos<0)throw Error("Unable to encode invalid Timestamp to JSON. Nanos must not be negative.");let n="Z";if(e.nanos>0){let t=(e.nanos+1e9).toString().substring(1);n="000000"===t.substring(3)?"."+t.substring(0,3)+"Z":"000"===t.substring(6)?"."+t.substring(0,6)+"Z":"."+t+"Z"}return new Date(i).toISOString().replace(".000Z",n)}internalJsonRead(e,t,i){if("string"!=typeof e)throw Error("Unable to parse Timestamp from JSON "+(0,j.Z)(e)+".");let n=e.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);if(!n)throw Error("Unable to parse Timestamp from JSON. Invalid format.");let a=Date.parse(n[1]+"-"+n[2]+"-"+n[3]+"T"+n[4]+":"+n[5]+":"+n[6]+(n[8]?n[8]:"Z"));if(Number.isNaN(a))throw Error("Unable to parse Timestamp from JSON. Invalid value.");if(a<Date.parse("0001-01-01T00:00:00Z")||a>Date.parse("9999-12-31T23:59:59Z"))throw new globalThis.Error("Unable to parse Timestamp from JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");return i||(i=this.create()),i.seconds=M.MJ.from(a/1e3).toString(),i.nanos=0,n[7]&&(i.nanos=parseInt("1"+n[7]+"0".repeat(9-n[7].length))-1e9),i}create(e){let t={seconds:"0",nanos:0};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.seconds=e.int64().toString();break;case 2:a.nanos=e.int32();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){"0"!==e.seconds&&t.tag(1,V.TD.Varint).int64(e.seconds),0!==e.nanos&&t.tag(2,V.TD.Varint).int32(e.nanos);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("google.protobuf.Timestamp",[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}])}}let eE=new eR;(l=C||(C={}))[l.PUBLISHER_UNSPECIFIED=0]="PUBLISHER_UNSPECIFIED",l[l.SUBSCRIBER=1]="SUBSCRIBER",(c=S||(S={}))[c.UNSPECIFIED=0]="UNSPECIFIED",c[c.POOR=1]="POOR",c[c.GOOD=2]="GOOD",c[c.EXCELLENT=3]="EXCELLENT",(d=I||(I={}))[d.LOW_UNSPECIFIED=0]="LOW_UNSPECIFIED",d[d.MID=1]="MID",d[d.HIGH=2]="HIGH",d[d.OFF=3]="OFF",(h=R||(R={}))[h.UNSPECIFIED=0]="UNSPECIFIED",h[h.AUDIO=1]="AUDIO",h[h.VIDEO=2]="VIDEO",h[h.SCREEN_SHARE=3]="SCREEN_SHARE",h[h.SCREEN_SHARE_AUDIO=4]="SCREEN_SHARE_AUDIO",(u=E||(E={}))[u.UNSPECIFIED=0]="UNSPECIFIED",u[u.PUBLISH_TRACK_NOT_FOUND=100]="PUBLISH_TRACK_NOT_FOUND",u[u.PUBLISH_TRACKS_MISMATCH=101]="PUBLISH_TRACKS_MISMATCH",u[u.PUBLISH_TRACK_OUT_OF_ORDER=102]="PUBLISH_TRACK_OUT_OF_ORDER",u[u.PUBLISH_TRACK_VIDEO_LAYER_NOT_FOUND=103]="PUBLISH_TRACK_VIDEO_LAYER_NOT_FOUND",u[u.LIVE_ENDED=104]="LIVE_ENDED",u[u.PARTICIPANT_NOT_FOUND=200]="PARTICIPANT_NOT_FOUND",u[u.PARTICIPANT_MIGRATING_OUT=201]="PARTICIPANT_MIGRATING_OUT",u[u.PARTICIPANT_MIGRATION_FAILED=202]="PARTICIPANT_MIGRATION_FAILED",u[u.PARTICIPANT_MIGRATING=203]="PARTICIPANT_MIGRATING",u[u.PARTICIPANT_RECONNECT_FAILED=204]="PARTICIPANT_RECONNECT_FAILED",u[u.PARTICIPANT_MEDIA_TRANSPORT_FAILURE=205]="PARTICIPANT_MEDIA_TRANSPORT_FAILURE",u[u.CALL_NOT_FOUND=300]="CALL_NOT_FOUND",u[u.REQUEST_VALIDATION_FAILED=400]="REQUEST_VALIDATION_FAILED",u[u.UNAUTHENTICATED=401]="UNAUTHENTICATED",u[u.PERMISSION_DENIED=403]="PERMISSION_DENIED",u[u.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",u[u.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",u[u.SFU_SHUTTING_DOWN=600]="SFU_SHUTTING_DOWN",u[u.SFU_FULL=700]="SFU_FULL",(p=D||(D={}))[p.UNSPECIFIED=0]="UNSPECIFIED",p[p.REACT=1]="REACT",p[p.ANGULAR=2]="ANGULAR",p[p.ANDROID=3]="ANDROID",p[p.IOS=4]="IOS",p[p.FLUTTER=5]="FLUTTER",p[p.REACT_NATIVE=6]="REACT_NATIVE",p[p.UNITY=7]="UNITY",(g=_||(_={}))[g.UNSPECIFIED=0]="UNSPECIFIED",g[g.USER_MUTED=1]="USER_MUTED",g[g.PERMISSION_REVOKED=2]="PERMISSION_REVOKED",g[g.MODERATION=3]="MODERATION",(m=P||(P={}))[m.UNSPECIFIED=0]="UNSPECIFIED",m[m.SHUTTING_DOWN=1]="SHUTTING_DOWN",m[m.REBALANCE=2]="REBALANCE";class eD extends B.C{create(e){let t={participants:[],pins:[]};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.participants.push(eL.internalBinaryRead(e,e.uint32(),i));break;case 2:a.startedAt=eE.internalBinaryRead(e,e.uint32(),i,a.startedAt);break;case 3:a.participantCount=eU.internalBinaryRead(e,e.uint32(),i,a.participantCount);break;case 4:a.pins.push(eA.internalBinaryRead(e,e.uint32(),i));break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){for(let n=0;n<e.participants.length;n++)eL.internalBinaryWrite(e.participants[n],t.tag(1,V.TD.LengthDelimited).fork(),i).join();e.startedAt&&eE.internalBinaryWrite(e.startedAt,t.tag(2,V.TD.LengthDelimited).fork(),i).join(),e.participantCount&&eU.internalBinaryWrite(e.participantCount,t.tag(3,V.TD.LengthDelimited).fork(),i).join();for(let n=0;n<e.pins.length;n++)eA.internalBinaryWrite(e.pins[n],t.tag(4,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.models.CallState",[{no:1,name:"participants",kind:"message",repeat:1,T:()=>eL},{no:2,name:"started_at",kind:"message",T:()=>eE},{no:3,name:"participant_count",kind:"message",T:()=>eU},{no:4,name:"pins",kind:"message",repeat:1,T:()=>eA}])}}let e_=new eD;class eP extends B.C{create(e){let t={total:0,anonymous:0};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.total=e.uint32();break;case 2:a.anonymous=e.uint32();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){0!==e.total&&t.tag(1,V.TD.Varint).uint32(e.total),0!==e.anonymous&&t.tag(2,V.TD.Varint).uint32(e.anonymous);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.models.ParticipantCount",[{no:1,name:"total",kind:"scalar",T:13},{no:2,name:"anonymous",kind:"scalar",T:13}])}}let eU=new eP;class eN extends B.C{create(e){let t={userId:"",sessionId:""};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.userId=e.string();break;case 2:a.sessionId=e.string();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){""!==e.userId&&t.tag(1,V.TD.LengthDelimited).string(e.userId),""!==e.sessionId&&t.tag(2,V.TD.LengthDelimited).string(e.sessionId);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.models.Pin",[{no:1,name:"user_id",kind:"scalar",T:9},{no:2,name:"session_id",kind:"scalar",T:9}])}}let eA=new eN;class eO extends B.C{create(e){let t={userId:"",sessionId:"",publishedTracks:[],trackLookupPrefix:"",connectionQuality:0,isSpeaking:!1,isDominantSpeaker:!1,audioLevel:0,name:"",image:"",roles:[]};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.userId=e.string();break;case 2:a.sessionId=e.string();break;case 3:if(n===V.TD.LengthDelimited)for(let t=e.int32()+e.pos;e.pos<t;)a.publishedTracks.push(e.int32());else a.publishedTracks.push(e.int32());break;case 4:a.joinedAt=eE.internalBinaryRead(e,e.uint32(),i,a.joinedAt);break;case 5:a.trackLookupPrefix=e.string();break;case 6:a.connectionQuality=e.int32();break;case 7:a.isSpeaking=e.bool();break;case 8:a.isDominantSpeaker=e.bool();break;case 9:a.audioLevel=e.float();break;case 10:a.name=e.string();break;case 11:a.image=e.string();break;case 12:a.custom=ew.internalBinaryRead(e,e.uint32(),i,a.custom);break;case 13:a.roles.push(e.string());break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){if(""!==e.userId&&t.tag(1,V.TD.LengthDelimited).string(e.userId),""!==e.sessionId&&t.tag(2,V.TD.LengthDelimited).string(e.sessionId),e.publishedTracks.length){t.tag(3,V.TD.LengthDelimited).fork();for(let i=0;i<e.publishedTracks.length;i++)t.int32(e.publishedTracks[i]);t.join()}e.joinedAt&&eE.internalBinaryWrite(e.joinedAt,t.tag(4,V.TD.LengthDelimited).fork(),i).join(),""!==e.trackLookupPrefix&&t.tag(5,V.TD.LengthDelimited).string(e.trackLookupPrefix),0!==e.connectionQuality&&t.tag(6,V.TD.Varint).int32(e.connectionQuality),!1!==e.isSpeaking&&t.tag(7,V.TD.Varint).bool(e.isSpeaking),!1!==e.isDominantSpeaker&&t.tag(8,V.TD.Varint).bool(e.isDominantSpeaker),0!==e.audioLevel&&t.tag(9,V.TD.Bit32).float(e.audioLevel),""!==e.name&&t.tag(10,V.TD.LengthDelimited).string(e.name),""!==e.image&&t.tag(11,V.TD.LengthDelimited).string(e.image),e.custom&&ew.internalBinaryWrite(e.custom,t.tag(12,V.TD.LengthDelimited).fork(),i).join();for(let i=0;i<e.roles.length;i++)t.tag(13,V.TD.LengthDelimited).string(e.roles[i]);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.models.Participant",[{no:1,name:"user_id",kind:"scalar",T:9},{no:2,name:"session_id",kind:"scalar",T:9},{no:3,name:"published_tracks",kind:"enum",repeat:1,T:()=>["stream.video.sfu.models.TrackType",R,"TRACK_TYPE_"]},{no:4,name:"joined_at",kind:"message",T:()=>eE},{no:5,name:"track_lookup_prefix",kind:"scalar",T:9},{no:6,name:"connection_quality",kind:"enum",T:()=>["stream.video.sfu.models.ConnectionQuality",S,"CONNECTION_QUALITY_"]},{no:7,name:"is_speaking",kind:"scalar",T:8},{no:8,name:"is_dominant_speaker",kind:"scalar",T:8},{no:9,name:"audio_level",kind:"scalar",T:2},{no:10,name:"name",kind:"scalar",T:9},{no:11,name:"image",kind:"scalar",T:9},{no:12,name:"custom",kind:"message",T:()=>ew},{no:13,name:"roles",kind:"scalar",repeat:2,T:9}])}}let eL=new eO;class eB extends B.C{create(e){let t={videoQuality:0,userId:""};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.videoQuality=e.int32();break;case 2:a.userId=e.string();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){0!==e.videoQuality&&t.tag(1,V.TD.Varint).int32(e.videoQuality),""!==e.userId&&t.tag(2,V.TD.LengthDelimited).string(e.userId);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.models.StreamQuality",[{no:1,name:"video_quality",kind:"enum",T:()=>["stream.video.sfu.models.VideoQuality",I,"VIDEO_QUALITY_"]},{no:2,name:"user_id",kind:"scalar",T:9}])}}let ej=new eB;class eF extends B.C{create(e){let t={width:0,height:0};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.width=e.uint32();break;case 2:a.height=e.uint32();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){0!==e.width&&t.tag(1,V.TD.Varint).uint32(e.width),0!==e.height&&t.tag(2,V.TD.Varint).uint32(e.height);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.models.VideoDimension",[{no:1,name:"width",kind:"scalar",T:13},{no:2,name:"height",kind:"scalar",T:13}])}}let eW=new eF;class eV extends B.C{create(e){let t={rid:"",bitrate:0,fps:0,quality:0};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.rid=e.string();break;case 2:a.videoDimension=eW.internalBinaryRead(e,e.uint32(),i,a.videoDimension);break;case 4:a.bitrate=e.uint32();break;case 5:a.fps=e.uint32();break;case 6:a.quality=e.int32();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){""!==e.rid&&t.tag(1,V.TD.LengthDelimited).string(e.rid),e.videoDimension&&eW.internalBinaryWrite(e.videoDimension,t.tag(2,V.TD.LengthDelimited).fork(),i).join(),0!==e.bitrate&&t.tag(4,V.TD.Varint).uint32(e.bitrate),0!==e.fps&&t.tag(5,V.TD.Varint).uint32(e.fps),0!==e.quality&&t.tag(6,V.TD.Varint).int32(e.quality);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.models.VideoLayer",[{no:1,name:"rid",kind:"scalar",T:9},{no:2,name:"video_dimension",kind:"message",T:()=>eW},{no:4,name:"bitrate",kind:"scalar",T:13},{no:5,name:"fps",kind:"scalar",T:13},{no:6,name:"quality",kind:"enum",T:()=>["stream.video.sfu.models.VideoQuality",I,"VIDEO_QUALITY_"]}])}}let eM=new eV;class ex extends B.C{create(e){let t={payloadType:0,name:"",fmtpLine:"",clockRate:0,encodingParameters:"",feedbacks:[]};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.payloadType=e.uint32();break;case 2:a.name=e.string();break;case 3:a.fmtpLine=e.string();break;case 4:a.clockRate=e.uint32();break;case 5:a.encodingParameters=e.string();break;case 6:a.feedbacks.push(e.string());break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){0!==e.payloadType&&t.tag(1,V.TD.Varint).uint32(e.payloadType),""!==e.name&&t.tag(2,V.TD.LengthDelimited).string(e.name),""!==e.fmtpLine&&t.tag(3,V.TD.LengthDelimited).string(e.fmtpLine),0!==e.clockRate&&t.tag(4,V.TD.Varint).uint32(e.clockRate),""!==e.encodingParameters&&t.tag(5,V.TD.LengthDelimited).string(e.encodingParameters);for(let i=0;i<e.feedbacks.length;i++)t.tag(6,V.TD.LengthDelimited).string(e.feedbacks[i]);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.models.Codec",[{no:1,name:"payload_type",kind:"scalar",T:13},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"fmtp_line",kind:"scalar",T:9},{no:4,name:"clock_rate",kind:"scalar",T:13},{no:5,name:"encoding_parameters",kind:"scalar",T:9},{no:6,name:"feedbacks",kind:"scalar",repeat:2,T:9}])}}let eH=new ex,ez=new class extends B.C{create(e){let t={peerType:0,iceCandidate:"",sessionId:""};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.peerType=e.int32();break;case 2:a.iceCandidate=e.string();break;case 3:a.sessionId=e.string();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){0!==e.peerType&&t.tag(1,V.TD.Varint).int32(e.peerType),""!==e.iceCandidate&&t.tag(2,V.TD.LengthDelimited).string(e.iceCandidate),""!==e.sessionId&&t.tag(3,V.TD.LengthDelimited).string(e.sessionId);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.models.ICETrickle",[{no:1,name:"peer_type",kind:"enum",T:()=>["stream.video.sfu.models.PeerType",C,"PEER_TYPE_"]},{no:2,name:"ice_candidate",kind:"scalar",T:9},{no:3,name:"session_id",kind:"scalar",T:9}])}};class eq extends B.C{create(e){let t={trackId:"",trackType:0,layers:[],mid:"",dtx:!1,stereo:!1,red:!1};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.trackId=e.string();break;case 2:a.trackType=e.int32();break;case 5:a.layers.push(eM.internalBinaryRead(e,e.uint32(),i));break;case 6:a.mid=e.string();break;case 7:a.dtx=e.bool();break;case 8:a.stereo=e.bool();break;case 9:a.red=e.bool();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){""!==e.trackId&&t.tag(1,V.TD.LengthDelimited).string(e.trackId),0!==e.trackType&&t.tag(2,V.TD.Varint).int32(e.trackType);for(let n=0;n<e.layers.length;n++)eM.internalBinaryWrite(e.layers[n],t.tag(5,V.TD.LengthDelimited).fork(),i).join();""!==e.mid&&t.tag(6,V.TD.LengthDelimited).string(e.mid),!1!==e.dtx&&t.tag(7,V.TD.Varint).bool(e.dtx),!1!==e.stereo&&t.tag(8,V.TD.Varint).bool(e.stereo),!1!==e.red&&t.tag(9,V.TD.Varint).bool(e.red);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.models.TrackInfo",[{no:1,name:"track_id",kind:"scalar",T:9},{no:2,name:"track_type",kind:"enum",T:()=>["stream.video.sfu.models.TrackType",R,"TRACK_TYPE_"]},{no:5,name:"layers",kind:"message",repeat:1,T:()=>eM},{no:6,name:"mid",kind:"scalar",T:9},{no:7,name:"dtx",kind:"scalar",T:8},{no:8,name:"stereo",kind:"scalar",T:8},{no:9,name:"red",kind:"scalar",T:8}])}}let eK=new eq;class eJ extends B.C{create(e){let t={type:"",id:"",createdByUserId:"",hostUserId:""};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.type=e.string();break;case 2:a.id=e.string();break;case 3:a.createdByUserId=e.string();break;case 4:a.hostUserId=e.string();break;case 5:a.custom=ew.internalBinaryRead(e,e.uint32(),i,a.custom);break;case 6:a.createdAt=eE.internalBinaryRead(e,e.uint32(),i,a.createdAt);break;case 7:a.updatedAt=eE.internalBinaryRead(e,e.uint32(),i,a.updatedAt);break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){""!==e.type&&t.tag(1,V.TD.LengthDelimited).string(e.type),""!==e.id&&t.tag(2,V.TD.LengthDelimited).string(e.id),""!==e.createdByUserId&&t.tag(3,V.TD.LengthDelimited).string(e.createdByUserId),""!==e.hostUserId&&t.tag(4,V.TD.LengthDelimited).string(e.hostUserId),e.custom&&ew.internalBinaryWrite(e.custom,t.tag(5,V.TD.LengthDelimited).fork(),i).join(),e.createdAt&&eE.internalBinaryWrite(e.createdAt,t.tag(6,V.TD.LengthDelimited).fork(),i).join(),e.updatedAt&&eE.internalBinaryWrite(e.updatedAt,t.tag(7,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.models.Call",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"id",kind:"scalar",T:9},{no:3,name:"created_by_user_id",kind:"scalar",T:9},{no:4,name:"host_user_id",kind:"scalar",T:9},{no:5,name:"custom",kind:"message",T:()=>ew},{no:6,name:"created_at",kind:"message",T:()=>eE},{no:7,name:"updated_at",kind:"message",T:()=>eE}])}}let eG=new eJ,e$=new class extends B.C{create(e){let t={code:0,message:"",shouldRetry:!1};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.code=e.int32();break;case 2:a.message=e.string();break;case 3:a.shouldRetry=e.bool();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){0!==e.code&&t.tag(1,V.TD.Varint).int32(e.code),""!==e.message&&t.tag(2,V.TD.LengthDelimited).string(e.message),!1!==e.shouldRetry&&t.tag(3,V.TD.Varint).bool(e.shouldRetry);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.models.Error",[{no:1,name:"code",kind:"enum",T:()=>["stream.video.sfu.models.ErrorCode",E,"ERROR_CODE_"]},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"should_retry",kind:"scalar",T:8}])}};class eQ extends B.C{create(e){let t={};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.sdk=eZ.internalBinaryRead(e,e.uint32(),i,a.sdk);break;case 2:a.os=e1.internalBinaryRead(e,e.uint32(),i,a.os);break;case 3:a.browser=e3.internalBinaryRead(e,e.uint32(),i,a.browser);break;case 4:a.device=e4.internalBinaryRead(e,e.uint32(),i,a.device);break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){e.sdk&&eZ.internalBinaryWrite(e.sdk,t.tag(1,V.TD.LengthDelimited).fork(),i).join(),e.os&&e1.internalBinaryWrite(e.os,t.tag(2,V.TD.LengthDelimited).fork(),i).join(),e.browser&&e3.internalBinaryWrite(e.browser,t.tag(3,V.TD.LengthDelimited).fork(),i).join(),e.device&&e4.internalBinaryWrite(e.device,t.tag(4,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.models.ClientDetails",[{no:1,name:"sdk",kind:"message",T:()=>eZ},{no:2,name:"os",kind:"message",T:()=>e1},{no:3,name:"browser",kind:"message",T:()=>e3},{no:4,name:"device",kind:"message",T:()=>e4}])}}let eX=new eQ;class eY extends B.C{create(e){let t={type:0,major:"",minor:"",patch:""};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.type=e.int32();break;case 2:a.major=e.string();break;case 3:a.minor=e.string();break;case 4:a.patch=e.string();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){0!==e.type&&t.tag(1,V.TD.Varint).int32(e.type),""!==e.major&&t.tag(2,V.TD.LengthDelimited).string(e.major),""!==e.minor&&t.tag(3,V.TD.LengthDelimited).string(e.minor),""!==e.patch&&t.tag(4,V.TD.LengthDelimited).string(e.patch);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.models.Sdk",[{no:1,name:"type",kind:"enum",T:()=>["stream.video.sfu.models.SdkType",D,"SDK_TYPE_"]},{no:2,name:"major",kind:"scalar",T:9},{no:3,name:"minor",kind:"scalar",T:9},{no:4,name:"patch",kind:"scalar",T:9}])}}let eZ=new eY;class e0 extends B.C{create(e){let t={name:"",version:"",architecture:""};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.name=e.string();break;case 2:a.version=e.string();break;case 3:a.architecture=e.string();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){""!==e.name&&t.tag(1,V.TD.LengthDelimited).string(e.name),""!==e.version&&t.tag(2,V.TD.LengthDelimited).string(e.version),""!==e.architecture&&t.tag(3,V.TD.LengthDelimited).string(e.architecture);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.models.OS",[{no:1,name:"name",kind:"scalar",T:9},{no:2,name:"version",kind:"scalar",T:9},{no:3,name:"architecture",kind:"scalar",T:9}])}}let e1=new e0;class e2 extends B.C{create(e){let t={name:"",version:""};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.name=e.string();break;case 2:a.version=e.string();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){""!==e.name&&t.tag(1,V.TD.LengthDelimited).string(e.name),""!==e.version&&t.tag(2,V.TD.LengthDelimited).string(e.version);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.models.Browser",[{no:1,name:"name",kind:"scalar",T:9},{no:2,name:"version",kind:"scalar",T:9}])}}let e3=new e2;class e9 extends B.C{create(e){let t={name:"",version:""};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.name=e.string();break;case 2:a.version=e.string();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){""!==e.name&&t.tag(1,V.TD.LengthDelimited).string(e.name),""!==e.version&&t.tag(2,V.TD.LengthDelimited).string(e.version);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.models.Device",[{no:1,name:"name",kind:"scalar",T:9},{no:2,name:"version",kind:"scalar",T:9}])}}let e4=new e9;class e5 extends B.C{create(e){let t={canPublishAudio:!1,canPublishVideo:!1,canScreenshare:!1};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.canPublishAudio=e.bool();break;case 2:a.canPublishVideo=e.bool();break;case 3:a.canScreenshare=e.bool();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){!1!==e.canPublishAudio&&t.tag(1,V.TD.Varint).bool(e.canPublishAudio),!1!==e.canPublishVideo&&t.tag(2,V.TD.Varint).bool(e.canPublishVideo),!1!==e.canScreenshare&&t.tag(3,V.TD.Varint).bool(e.canScreenshare);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.models.CallGrants",[{no:1,name:"can_publish_audio",kind:"scalar",T:8},{no:2,name:"can_publish_video",kind:"scalar",T:8},{no:3,name:"can_screenshare",kind:"scalar",T:8}])}}let e6=new e5;var e8=Object.freeze({__proto__:null,Browser:e3,Call:eG,CallGrants:e6,CallState:e_,ClientDetails:eX,Codec:eH,get ConnectionQuality(){return S},Device:e4,Error:e$,get ErrorCode(){return E},get GoAwayReason(){return P},ICETrickle:ez,OS:e1,Participant:eL,ParticipantCount:eU,get PeerType(){return C},Pin:eA,Sdk:eZ,get SdkType(){return D},StreamQuality:ej,TrackInfo:eK,get TrackType(){return R},get TrackUnpublishReason(){return _},VideoDimension:eW,VideoLayer:eM,get VideoQuality(){return I}});class e7 extends B.C{create(e){let t={sessionId:"",peerType:0};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.sessionId=e.string();break;case 2:a.peerType=e.int32();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){""!==e.sessionId&&t.tag(1,V.TD.LengthDelimited).string(e.sessionId),0!==e.peerType&&t.tag(2,V.TD.Varint).int32(e.peerType);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.signal.ICERestartRequest",[{no:1,name:"session_id",kind:"scalar",T:9},{no:2,name:"peer_type",kind:"enum",T:()=>["stream.video.sfu.models.PeerType",C,"PEER_TYPE_"]}])}}let te=new e7;class tt extends B.C{create(e){let t={};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();if(1===t)a.error=e$.internalBinaryRead(e,e.uint32(),i,a.error);else{let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){e.error&&e$.internalBinaryWrite(e.error,t.tag(1,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.signal.ICERestartResponse",[{no:1,name:"error",kind:"message",T:()=>e$}])}}let ti=new tt;class tn extends B.C{create(e){let t={sessionId:"",muteStates:[]};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.sessionId=e.string();break;case 3:a.muteStates.push(tl.internalBinaryRead(e,e.uint32(),i));break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){""!==e.sessionId&&t.tag(1,V.TD.LengthDelimited).string(e.sessionId);for(let n=0;n<e.muteStates.length;n++)tl.internalBinaryWrite(e.muteStates[n],t.tag(3,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.signal.UpdateMuteStatesRequest",[{no:1,name:"session_id",kind:"scalar",T:9},{no:3,name:"mute_states",kind:"message",repeat:1,T:()=>tl}])}}let ta=new tn;class ts extends B.C{create(e){let t={};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();if(4===t)a.error=e$.internalBinaryRead(e,e.uint32(),i,a.error);else{let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){e.error&&e$.internalBinaryWrite(e.error,t.tag(4,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.signal.UpdateMuteStatesResponse",[{no:4,name:"error",kind:"message",T:()=>e$}])}}let tr=new ts;class to extends B.C{create(e){let t={trackType:0,muted:!1};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.trackType=e.int32();break;case 2:a.muted=e.bool();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){0!==e.trackType&&t.tag(1,V.TD.Varint).int32(e.trackType),!1!==e.muted&&t.tag(2,V.TD.Varint).bool(e.muted);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.signal.TrackMuteState",[{no:1,name:"track_type",kind:"enum",T:()=>["stream.video.sfu.models.TrackType",R,"TRACK_TYPE_"]},{no:2,name:"muted",kind:"scalar",T:8}])}}let tl=new to;class tc extends B.C{create(e){let t={muted:!1};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();if(1===t)a.muted=e.bool();else{let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){!1!==e.muted&&t.tag(1,V.TD.Varint).bool(e.muted);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.signal.AudioMuteChanged",[{no:1,name:"muted",kind:"scalar",T:8}])}}new tc;class td extends B.C{create(e){let t={muted:!1};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();if(2===t)a.muted=e.bool();else{let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){!1!==e.muted&&t.tag(2,V.TD.Varint).bool(e.muted);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.signal.VideoMuteChanged",[{no:2,name:"muted",kind:"scalar",T:8}])}}new td;class th extends B.C{create(e){let t={sessionId:"",tracks:[]};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 2:a.sessionId=e.string();break;case 3:a.tracks.push(tf.internalBinaryRead(e,e.uint32(),i));break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){""!==e.sessionId&&t.tag(2,V.TD.LengthDelimited).string(e.sessionId);for(let n=0;n<e.tracks.length;n++)tf.internalBinaryWrite(e.tracks[n],t.tag(3,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.signal.UpdateSubscriptionsRequest",[{no:2,name:"session_id",kind:"scalar",T:9},{no:3,name:"tracks",kind:"message",repeat:1,T:()=>tf}])}}let tu=new th;class tp extends B.C{create(e){let t={};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();if(4===t)a.error=e$.internalBinaryRead(e,e.uint32(),i,a.error);else{let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){e.error&&e$.internalBinaryWrite(e.error,t.tag(4,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.signal.UpdateSubscriptionsResponse",[{no:4,name:"error",kind:"message",T:()=>e$}])}}let tg=new tp;class tm extends B.C{create(e){let t={userId:"",sessionId:"",trackType:0};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.userId=e.string();break;case 2:a.sessionId=e.string();break;case 3:a.trackType=e.int32();break;case 4:a.dimension=eW.internalBinaryRead(e,e.uint32(),i,a.dimension);break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){""!==e.userId&&t.tag(1,V.TD.LengthDelimited).string(e.userId),""!==e.sessionId&&t.tag(2,V.TD.LengthDelimited).string(e.sessionId),0!==e.trackType&&t.tag(3,V.TD.Varint).int32(e.trackType),e.dimension&&eW.internalBinaryWrite(e.dimension,t.tag(4,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.signal.TrackSubscriptionDetails",[{no:1,name:"user_id",kind:"scalar",T:9},{no:2,name:"session_id",kind:"scalar",T:9},{no:3,name:"track_type",kind:"enum",T:()=>["stream.video.sfu.models.TrackType",R,"TRACK_TYPE_"]},{no:4,name:"dimension",kind:"message",T:()=>eW}])}}let tf=new tm;class ty extends B.C{create(e){let t={peerType:0,sdp:"",sessionId:""};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.peerType=e.int32();break;case 2:a.sdp=e.string();break;case 3:a.sessionId=e.string();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){0!==e.peerType&&t.tag(1,V.TD.Varint).int32(e.peerType),""!==e.sdp&&t.tag(2,V.TD.LengthDelimited).string(e.sdp),""!==e.sessionId&&t.tag(3,V.TD.LengthDelimited).string(e.sessionId);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.signal.SendAnswerRequest",[{no:1,name:"peer_type",kind:"enum",T:()=>["stream.video.sfu.models.PeerType",C,"PEER_TYPE_"]},{no:2,name:"sdp",kind:"scalar",T:9},{no:3,name:"session_id",kind:"scalar",T:9}])}}let tb=new ty;class tv extends B.C{create(e){let t={};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();if(4===t)a.error=e$.internalBinaryRead(e,e.uint32(),i,a.error);else{let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){e.error&&e$.internalBinaryWrite(e.error,t.tag(4,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.signal.SendAnswerResponse",[{no:4,name:"error",kind:"message",T:()=>e$}])}}let tk=new tv;class tw extends B.C{create(e){let t={};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();if(4===t)a.error=e$.internalBinaryRead(e,e.uint32(),i,a.error);else{let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){e.error&&e$.internalBinaryWrite(e.error,t.tag(4,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.signal.ICETrickleResponse",[{no:4,name:"error",kind:"message",T:()=>e$}])}}let tT=new tw;class tC extends B.C{create(e){let t={sdp:"",sessionId:"",tracks:[]};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.sdp=e.string();break;case 2:a.sessionId=e.string();break;case 3:a.tracks.push(eK.internalBinaryRead(e,e.uint32(),i));break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){""!==e.sdp&&t.tag(1,V.TD.LengthDelimited).string(e.sdp),""!==e.sessionId&&t.tag(2,V.TD.LengthDelimited).string(e.sessionId);for(let n=0;n<e.tracks.length;n++)eK.internalBinaryWrite(e.tracks[n],t.tag(3,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.signal.SetPublisherRequest",[{no:1,name:"sdp",kind:"scalar",T:9},{no:2,name:"session_id",kind:"scalar",T:9},{no:3,name:"tracks",kind:"message",repeat:1,T:()=>eK}])}}let tS=new tC;class tI extends B.C{create(e){let t={sdp:"",sessionId:"",iceRestart:!1};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.sdp=e.string();break;case 2:a.sessionId=e.string();break;case 3:a.iceRestart=e.bool();break;case 4:a.error=e$.internalBinaryRead(e,e.uint32(),i,a.error);break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){""!==e.sdp&&t.tag(1,V.TD.LengthDelimited).string(e.sdp),""!==e.sessionId&&t.tag(2,V.TD.LengthDelimited).string(e.sessionId),!1!==e.iceRestart&&t.tag(3,V.TD.Varint).bool(e.iceRestart),e.error&&e$.internalBinaryWrite(e.error,t.tag(4,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.signal.SetPublisherResponse",[{no:1,name:"sdp",kind:"scalar",T:9},{no:2,name:"session_id",kind:"scalar",T:9},{no:3,name:"ice_restart",kind:"scalar",T:8},{no:4,name:"error",kind:"message",T:()=>e$}])}}let tR=new tI,tE=new x.U("stream.video.sfu.signal.SignalServer",[{name:"SetPublisher",options:{},I:tS,O:tR},{name:"SendAnswer",options:{},I:tb,O:tk},{name:"IceTrickle",options:{},I:ez,O:tT},{name:"UpdateSubscriptions",options:{},I:tu,O:tg},{name:"UpdateMuteStates",options:{},I:ta,O:tr},{name:"IceRestart",options:{},I:te,O:ti}]);(f=U||(U={}))[f.HIGH_UNSPECIFIED=0]="HIGH_UNSPECIFIED",f[f.LOW=1]="LOW",f[f.MEDIUM=2]="MEDIUM",f[f.VERY_LOW=3]="VERY_LOW";class tD extends B.C{create(e){let t={eventPayload:{oneofKind:void 0}};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.eventPayload={oneofKind:"subscriberOffer",subscriberOffer:t9.internalBinaryRead(e,e.uint32(),i,a.eventPayload.subscriberOffer)};break;case 2:a.eventPayload={oneofKind:"publisherAnswer",publisherAnswer:t5.internalBinaryRead(e,e.uint32(),i,a.eventPayload.publisherAnswer)};break;case 3:a.eventPayload={oneofKind:"connectionQualityChanged",connectionQualityChanged:t8.internalBinaryRead(e,e.uint32(),i,a.eventPayload.connectionQualityChanged)};break;case 4:a.eventPayload={oneofKind:"audioLevelChanged",audioLevelChanged:io.internalBinaryRead(e,e.uint32(),i,a.eventPayload.audioLevelChanged)};break;case 5:a.eventPayload={oneofKind:"iceTrickle",iceTrickle:ez.internalBinaryRead(e,e.uint32(),i,a.eventPayload.iceTrickle)};break;case 6:a.eventPayload={oneofKind:"changePublishQuality",changePublishQuality:ik.internalBinaryRead(e,e.uint32(),i,a.eventPayload.changePublishQuality)};break;case 10:a.eventPayload={oneofKind:"participantJoined",participantJoined:t0.internalBinaryRead(e,e.uint32(),i,a.eventPayload.participantJoined)};break;case 11:a.eventPayload={oneofKind:"participantLeft",participantLeft:t2.internalBinaryRead(e,e.uint32(),i,a.eventPayload.participantLeft)};break;case 12:a.eventPayload={oneofKind:"dominantSpeakerChanged",dominantSpeakerChanged:ii.internalBinaryRead(e,e.uint32(),i,a.eventPayload.dominantSpeakerChanged)};break;case 13:a.eventPayload={oneofKind:"joinResponse",joinResponse:tY.internalBinaryRead(e,e.uint32(),i,a.eventPayload.joinResponse)};break;case 14:a.eventPayload={oneofKind:"healthCheckResponse",healthCheckResponse:tx.internalBinaryRead(e,e.uint32(),i,a.eventPayload.healthCheckResponse)};break;case 16:a.eventPayload={oneofKind:"trackPublished",trackPublished:tz.internalBinaryRead(e,e.uint32(),i,a.eventPayload.trackPublished)};break;case 17:a.eventPayload={oneofKind:"trackUnpublished",trackUnpublished:tK.internalBinaryRead(e,e.uint32(),i,a.eventPayload.trackUnpublished)};break;case 18:a.eventPayload={oneofKind:"error",error:tA.internalBinaryRead(e,e.uint32(),i,a.eventPayload.error)};break;case 19:a.eventPayload={oneofKind:"callGrantsUpdated",callGrantsUpdated:iT.internalBinaryRead(e,e.uint32(),i,a.eventPayload.callGrantsUpdated)};break;case 20:a.eventPayload={oneofKind:"goAway",goAway:iS.internalBinaryRead(e,e.uint32(),i,a.eventPayload.goAway)};break;case 21:a.eventPayload={oneofKind:"iceRestart",iceRestart:tB.internalBinaryRead(e,e.uint32(),i,a.eventPayload.iceRestart)};break;case 22:a.eventPayload={oneofKind:"pinsUpdated",pinsUpdated:tU.internalBinaryRead(e,e.uint32(),i,a.eventPayload.pinsUpdated)};break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){"subscriberOffer"===e.eventPayload.oneofKind&&t9.internalBinaryWrite(e.eventPayload.subscriberOffer,t.tag(1,V.TD.LengthDelimited).fork(),i).join(),"publisherAnswer"===e.eventPayload.oneofKind&&t5.internalBinaryWrite(e.eventPayload.publisherAnswer,t.tag(2,V.TD.LengthDelimited).fork(),i).join(),"connectionQualityChanged"===e.eventPayload.oneofKind&&t8.internalBinaryWrite(e.eventPayload.connectionQualityChanged,t.tag(3,V.TD.LengthDelimited).fork(),i).join(),"audioLevelChanged"===e.eventPayload.oneofKind&&io.internalBinaryWrite(e.eventPayload.audioLevelChanged,t.tag(4,V.TD.LengthDelimited).fork(),i).join(),"iceTrickle"===e.eventPayload.oneofKind&&ez.internalBinaryWrite(e.eventPayload.iceTrickle,t.tag(5,V.TD.LengthDelimited).fork(),i).join(),"changePublishQuality"===e.eventPayload.oneofKind&&ik.internalBinaryWrite(e.eventPayload.changePublishQuality,t.tag(6,V.TD.LengthDelimited).fork(),i).join(),"participantJoined"===e.eventPayload.oneofKind&&t0.internalBinaryWrite(e.eventPayload.participantJoined,t.tag(10,V.TD.LengthDelimited).fork(),i).join(),"participantLeft"===e.eventPayload.oneofKind&&t2.internalBinaryWrite(e.eventPayload.participantLeft,t.tag(11,V.TD.LengthDelimited).fork(),i).join(),"dominantSpeakerChanged"===e.eventPayload.oneofKind&&ii.internalBinaryWrite(e.eventPayload.dominantSpeakerChanged,t.tag(12,V.TD.LengthDelimited).fork(),i).join(),"joinResponse"===e.eventPayload.oneofKind&&tY.internalBinaryWrite(e.eventPayload.joinResponse,t.tag(13,V.TD.LengthDelimited).fork(),i).join(),"healthCheckResponse"===e.eventPayload.oneofKind&&tx.internalBinaryWrite(e.eventPayload.healthCheckResponse,t.tag(14,V.TD.LengthDelimited).fork(),i).join(),"trackPublished"===e.eventPayload.oneofKind&&tz.internalBinaryWrite(e.eventPayload.trackPublished,t.tag(16,V.TD.LengthDelimited).fork(),i).join(),"trackUnpublished"===e.eventPayload.oneofKind&&tK.internalBinaryWrite(e.eventPayload.trackUnpublished,t.tag(17,V.TD.LengthDelimited).fork(),i).join(),"error"===e.eventPayload.oneofKind&&tA.internalBinaryWrite(e.eventPayload.error,t.tag(18,V.TD.LengthDelimited).fork(),i).join(),"callGrantsUpdated"===e.eventPayload.oneofKind&&iT.internalBinaryWrite(e.eventPayload.callGrantsUpdated,t.tag(19,V.TD.LengthDelimited).fork(),i).join(),"goAway"===e.eventPayload.oneofKind&&iS.internalBinaryWrite(e.eventPayload.goAway,t.tag(20,V.TD.LengthDelimited).fork(),i).join(),"iceRestart"===e.eventPayload.oneofKind&&tB.internalBinaryWrite(e.eventPayload.iceRestart,t.tag(21,V.TD.LengthDelimited).fork(),i).join(),"pinsUpdated"===e.eventPayload.oneofKind&&tU.internalBinaryWrite(e.eventPayload.pinsUpdated,t.tag(22,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.SfuEvent",[{no:1,name:"subscriber_offer",kind:"message",oneof:"eventPayload",T:()=>t9},{no:2,name:"publisher_answer",kind:"message",oneof:"eventPayload",T:()=>t5},{no:3,name:"connection_quality_changed",kind:"message",oneof:"eventPayload",T:()=>t8},{no:4,name:"audio_level_changed",kind:"message",oneof:"eventPayload",T:()=>io},{no:5,name:"ice_trickle",kind:"message",oneof:"eventPayload",T:()=>ez},{no:6,name:"change_publish_quality",kind:"message",oneof:"eventPayload",T:()=>ik},{no:10,name:"participant_joined",kind:"message",oneof:"eventPayload",T:()=>t0},{no:11,name:"participant_left",kind:"message",oneof:"eventPayload",T:()=>t2},{no:12,name:"dominant_speaker_changed",kind:"message",oneof:"eventPayload",T:()=>ii},{no:13,name:"join_response",kind:"message",oneof:"eventPayload",T:()=>tY},{no:14,name:"health_check_response",kind:"message",oneof:"eventPayload",T:()=>tx},{no:16,name:"track_published",kind:"message",oneof:"eventPayload",T:()=>tz},{no:17,name:"track_unpublished",kind:"message",oneof:"eventPayload",T:()=>tK},{no:18,name:"error",kind:"message",oneof:"eventPayload",T:()=>tA},{no:19,name:"call_grants_updated",kind:"message",oneof:"eventPayload",T:()=>iT},{no:20,name:"go_away",kind:"message",oneof:"eventPayload",T:()=>iS},{no:21,name:"ice_restart",kind:"message",oneof:"eventPayload",T:()=>tB},{no:22,name:"pins_updated",kind:"message",oneof:"eventPayload",T:()=>tU}])}}let t_=new tD;class tP extends B.C{create(e){let t={pins:[]};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();if(1===t)a.pins.push(eA.internalBinaryRead(e,e.uint32(),i));else{let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){for(let n=0;n<e.pins.length;n++)eA.internalBinaryWrite(e.pins[n],t.tag(1,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.PinsChanged",[{no:1,name:"pins",kind:"message",repeat:1,T:()=>eA}])}}let tU=new tP;class tN extends B.C{create(e){let t={};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();if(4===t)a.error=e$.internalBinaryRead(e,e.uint32(),i,a.error);else{let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){e.error&&e$.internalBinaryWrite(e.error,t.tag(4,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.Error",[{no:4,name:"error",kind:"message",T:()=>e$}])}}let tA=new tN;class tO extends B.C{create(e){let t={peerType:0,iceCandidate:""};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.peerType=e.int32();break;case 2:a.iceCandidate=e.string();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){0!==e.peerType&&t.tag(1,V.TD.Varint).int32(e.peerType),""!==e.iceCandidate&&t.tag(2,V.TD.LengthDelimited).string(e.iceCandidate);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.ICETrickle",[{no:1,name:"peer_type",kind:"enum",T:()=>["stream.video.sfu.models.PeerType",C,"PEER_TYPE_"]},{no:2,name:"ice_candidate",kind:"scalar",T:9}])}}new tO;class tL extends B.C{create(e){let t={peerType:0};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();if(1===t)a.peerType=e.int32();else{let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){0!==e.peerType&&t.tag(1,V.TD.Varint).int32(e.peerType);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.ICERestart",[{no:1,name:"peer_type",kind:"enum",T:()=>["stream.video.sfu.models.PeerType",C,"PEER_TYPE_"]}])}}let tB=new tL;class tj extends B.C{create(e){let t={requestPayload:{oneofKind:void 0}};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.requestPayload={oneofKind:"joinRequest",joinRequest:tG.internalBinaryRead(e,e.uint32(),i,a.requestPayload.joinRequest)};break;case 2:a.requestPayload={oneofKind:"healthCheckRequest",healthCheckRequest:tV.internalBinaryRead(e,e.uint32(),i,a.requestPayload.healthCheckRequest)};break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){"joinRequest"===e.requestPayload.oneofKind&&tG.internalBinaryWrite(e.requestPayload.joinRequest,t.tag(1,V.TD.LengthDelimited).fork(),i).join(),"healthCheckRequest"===e.requestPayload.oneofKind&&tV.internalBinaryWrite(e.requestPayload.healthCheckRequest,t.tag(2,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.SfuRequest",[{no:1,name:"join_request",kind:"message",oneof:"requestPayload",T:()=>tG},{no:2,name:"health_check_request",kind:"message",oneof:"requestPayload",T:()=>tV}])}}let tF=new tj;class tW extends B.C{create(e){let t={};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){return null!=n?n:this.create()}internalBinaryWrite(e,t,i){let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.HealthCheckRequest",[])}}let tV=new tW;class tM extends B.C{create(e){let t={};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();if(1===t)a.participantCount=eU.internalBinaryRead(e,e.uint32(),i,a.participantCount);else{let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){e.participantCount&&eU.internalBinaryWrite(e.participantCount,t.tag(1,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.HealthCheckResponse",[{no:1,name:"participant_count",kind:"message",T:()=>eU}])}}let tx=new tM;class tH extends B.C{create(e){let t={userId:"",sessionId:"",type:0};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.userId=e.string();break;case 2:a.sessionId=e.string();break;case 3:a.type=e.int32();break;case 4:a.participant=eL.internalBinaryRead(e,e.uint32(),i,a.participant);break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){""!==e.userId&&t.tag(1,V.TD.LengthDelimited).string(e.userId),""!==e.sessionId&&t.tag(2,V.TD.LengthDelimited).string(e.sessionId),0!==e.type&&t.tag(3,V.TD.Varint).int32(e.type),e.participant&&eL.internalBinaryWrite(e.participant,t.tag(4,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.TrackPublished",[{no:1,name:"user_id",kind:"scalar",T:9},{no:2,name:"session_id",kind:"scalar",T:9},{no:3,name:"type",kind:"enum",T:()=>["stream.video.sfu.models.TrackType",R,"TRACK_TYPE_"]},{no:4,name:"participant",kind:"message",T:()=>eL}])}}let tz=new tH;class tq extends B.C{create(e){let t={userId:"",sessionId:"",type:0,cause:0};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.userId=e.string();break;case 2:a.sessionId=e.string();break;case 3:a.type=e.int32();break;case 4:a.cause=e.int32();break;case 5:a.participant=eL.internalBinaryRead(e,e.uint32(),i,a.participant);break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){""!==e.userId&&t.tag(1,V.TD.LengthDelimited).string(e.userId),""!==e.sessionId&&t.tag(2,V.TD.LengthDelimited).string(e.sessionId),0!==e.type&&t.tag(3,V.TD.Varint).int32(e.type),0!==e.cause&&t.tag(4,V.TD.Varint).int32(e.cause),e.participant&&eL.internalBinaryWrite(e.participant,t.tag(5,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.TrackUnpublished",[{no:1,name:"user_id",kind:"scalar",T:9},{no:2,name:"session_id",kind:"scalar",T:9},{no:3,name:"type",kind:"enum",T:()=>["stream.video.sfu.models.TrackType",R,"TRACK_TYPE_"]},{no:4,name:"cause",kind:"enum",T:()=>["stream.video.sfu.models.TrackUnpublishReason",_,"TRACK_UNPUBLISH_REASON_"]},{no:5,name:"participant",kind:"message",T:()=>eL}])}}let tK=new tq;class tJ extends B.C{create(e){let t={token:"",sessionId:"",subscriberSdp:"",fastReconnect:!1};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.token=e.string();break;case 2:a.sessionId=e.string();break;case 3:a.subscriberSdp=e.string();break;case 4:a.clientDetails=eX.internalBinaryRead(e,e.uint32(),i,a.clientDetails);break;case 5:a.migration=tQ.internalBinaryRead(e,e.uint32(),i,a.migration);break;case 6:a.fastReconnect=e.bool();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){""!==e.token&&t.tag(1,V.TD.LengthDelimited).string(e.token),""!==e.sessionId&&t.tag(2,V.TD.LengthDelimited).string(e.sessionId),""!==e.subscriberSdp&&t.tag(3,V.TD.LengthDelimited).string(e.subscriberSdp),e.clientDetails&&eX.internalBinaryWrite(e.clientDetails,t.tag(4,V.TD.LengthDelimited).fork(),i).join(),e.migration&&tQ.internalBinaryWrite(e.migration,t.tag(5,V.TD.LengthDelimited).fork(),i).join(),!1!==e.fastReconnect&&t.tag(6,V.TD.Varint).bool(e.fastReconnect);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.JoinRequest",[{no:1,name:"token",kind:"scalar",T:9},{no:2,name:"session_id",kind:"scalar",T:9},{no:3,name:"subscriber_sdp",kind:"scalar",T:9},{no:4,name:"client_details",kind:"message",T:()=>eX},{no:5,name:"migration",kind:"message",T:()=>tQ},{no:6,name:"fast_reconnect",kind:"scalar",T:8}])}}let tG=new tJ;class t$ extends B.C{create(e){let t={fromSfuId:"",announcedTracks:[],subscriptions:[]};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.fromSfuId=e.string();break;case 2:a.announcedTracks.push(eK.internalBinaryRead(e,e.uint32(),i));break;case 3:a.subscriptions.push(tf.internalBinaryRead(e,e.uint32(),i));break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){""!==e.fromSfuId&&t.tag(1,V.TD.LengthDelimited).string(e.fromSfuId);for(let n=0;n<e.announcedTracks.length;n++)eK.internalBinaryWrite(e.announcedTracks[n],t.tag(2,V.TD.LengthDelimited).fork(),i).join();for(let n=0;n<e.subscriptions.length;n++)tf.internalBinaryWrite(e.subscriptions[n],t.tag(3,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.Migration",[{no:1,name:"from_sfu_id",kind:"scalar",T:9},{no:2,name:"announced_tracks",kind:"message",repeat:1,T:()=>eK},{no:3,name:"subscriptions",kind:"message",repeat:1,T:()=>tf}])}}let tQ=new t$;class tX extends B.C{create(e){let t={reconnected:!1};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.callState=e_.internalBinaryRead(e,e.uint32(),i,a.callState);break;case 2:a.reconnected=e.bool();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){e.callState&&e_.internalBinaryWrite(e.callState,t.tag(1,V.TD.LengthDelimited).fork(),i).join(),!1!==e.reconnected&&t.tag(2,V.TD.Varint).bool(e.reconnected);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.JoinResponse",[{no:1,name:"call_state",kind:"message",T:()=>e_},{no:2,name:"reconnected",kind:"scalar",T:8}])}}let tY=new tX;class tZ extends B.C{create(e){let t={callCid:""};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.callCid=e.string();break;case 2:a.participant=eL.internalBinaryRead(e,e.uint32(),i,a.participant);break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){""!==e.callCid&&t.tag(1,V.TD.LengthDelimited).string(e.callCid),e.participant&&eL.internalBinaryWrite(e.participant,t.tag(2,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.ParticipantJoined",[{no:1,name:"call_cid",kind:"scalar",T:9},{no:2,name:"participant",kind:"message",T:()=>eL}])}}let t0=new tZ;class t1 extends B.C{create(e){let t={callCid:""};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.callCid=e.string();break;case 2:a.participant=eL.internalBinaryRead(e,e.uint32(),i,a.participant);break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){""!==e.callCid&&t.tag(1,V.TD.LengthDelimited).string(e.callCid),e.participant&&eL.internalBinaryWrite(e.participant,t.tag(2,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.ParticipantLeft",[{no:1,name:"call_cid",kind:"scalar",T:9},{no:2,name:"participant",kind:"message",T:()=>eL}])}}let t2=new t1;class t3 extends B.C{create(e){let t={iceRestart:!1,sdp:""};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.iceRestart=e.bool();break;case 2:a.sdp=e.string();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){!1!==e.iceRestart&&t.tag(1,V.TD.Varint).bool(e.iceRestart),""!==e.sdp&&t.tag(2,V.TD.LengthDelimited).string(e.sdp);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.SubscriberOffer",[{no:1,name:"ice_restart",kind:"scalar",T:8},{no:2,name:"sdp",kind:"scalar",T:9}])}}let t9=new t3;class t4 extends B.C{create(e){let t={sdp:""};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();if(1===t)a.sdp=e.string();else{let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){""!==e.sdp&&t.tag(1,V.TD.LengthDelimited).string(e.sdp);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.PublisherAnswer",[{no:1,name:"sdp",kind:"scalar",T:9}])}}let t5=new t4;class t6 extends B.C{create(e){let t={connectionQualityUpdates:[]};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();if(1===t)a.connectionQualityUpdates.push(ie.internalBinaryRead(e,e.uint32(),i));else{let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){for(let n=0;n<e.connectionQualityUpdates.length;n++)ie.internalBinaryWrite(e.connectionQualityUpdates[n],t.tag(1,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.ConnectionQualityChanged",[{no:1,name:"connection_quality_updates",kind:"message",repeat:1,T:()=>ie}])}}let t8=new t6;class t7 extends B.C{create(e){let t={userId:"",sessionId:"",connectionQuality:0};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.userId=e.string();break;case 2:a.sessionId=e.string();break;case 3:a.connectionQuality=e.int32();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){""!==e.userId&&t.tag(1,V.TD.LengthDelimited).string(e.userId),""!==e.sessionId&&t.tag(2,V.TD.LengthDelimited).string(e.sessionId),0!==e.connectionQuality&&t.tag(3,V.TD.Varint).int32(e.connectionQuality);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.ConnectionQualityInfo",[{no:1,name:"user_id",kind:"scalar",T:9},{no:2,name:"session_id",kind:"scalar",T:9},{no:3,name:"connection_quality",kind:"enum",T:()=>["stream.video.sfu.models.ConnectionQuality",S,"CONNECTION_QUALITY_"]}])}}let ie=new t7;class it extends B.C{create(e){let t={userId:"",sessionId:""};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.userId=e.string();break;case 2:a.sessionId=e.string();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){""!==e.userId&&t.tag(1,V.TD.LengthDelimited).string(e.userId),""!==e.sessionId&&t.tag(2,V.TD.LengthDelimited).string(e.sessionId);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.DominantSpeakerChanged",[{no:1,name:"user_id",kind:"scalar",T:9},{no:2,name:"session_id",kind:"scalar",T:9}])}}let ii=new it;class ia extends B.C{create(e){let t={userId:"",sessionId:"",level:0,isSpeaking:!1};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.userId=e.string();break;case 2:a.sessionId=e.string();break;case 3:a.level=e.float();break;case 4:a.isSpeaking=e.bool();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){""!==e.userId&&t.tag(1,V.TD.LengthDelimited).string(e.userId),""!==e.sessionId&&t.tag(2,V.TD.LengthDelimited).string(e.sessionId),0!==e.level&&t.tag(3,V.TD.Bit32).float(e.level),!1!==e.isSpeaking&&t.tag(4,V.TD.Varint).bool(e.isSpeaking);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.AudioLevel",[{no:1,name:"user_id",kind:"scalar",T:9},{no:2,name:"session_id",kind:"scalar",T:9},{no:3,name:"level",kind:"scalar",T:2},{no:4,name:"is_speaking",kind:"scalar",T:8}])}}let is=new ia;class ir extends B.C{create(e){let t={audioLevels:[]};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();if(1===t)a.audioLevels.push(is.internalBinaryRead(e,e.uint32(),i));else{let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){for(let n=0;n<e.audioLevels.length;n++)is.internalBinaryWrite(e.audioLevels[n],t.tag(1,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.AudioLevelChanged",[{no:1,name:"audio_levels",kind:"message",repeat:1,T:()=>is}])}}let io=new ir;class il extends B.C{create(e){let t={channelCount:0};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();if(1===t)a.channelCount=e.int32();else{let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){0!==e.channelCount&&t.tag(1,V.TD.Varint).int32(e.channelCount);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.AudioMediaRequest",[{no:1,name:"channel_count",kind:"scalar",T:5}])}}let ic=new il;class id extends B.C{create(e){let t={};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.mediaRequest=ic.internalBinaryRead(e,e.uint32(),i,a.mediaRequest);break;case 2:a.codec=eH.internalBinaryRead(e,e.uint32(),i,a.codec);break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){e.mediaRequest&&ic.internalBinaryWrite(e.mediaRequest,t.tag(1,V.TD.LengthDelimited).fork(),i).join(),e.codec&&eH.internalBinaryWrite(e.codec,t.tag(2,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.AudioSender",[{no:1,name:"media_request",kind:"message",T:()=>ic},{no:2,name:"codec",kind:"message",T:()=>eH}])}}let ih=new id;class iu extends B.C{create(e){let t={idealHeight:0,idealWidth:0,idealFrameRate:0};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.idealHeight=e.int32();break;case 2:a.idealWidth=e.int32();break;case 3:a.idealFrameRate=e.int32();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){0!==e.idealHeight&&t.tag(1,V.TD.Varint).int32(e.idealHeight),0!==e.idealWidth&&t.tag(2,V.TD.Varint).int32(e.idealWidth),0!==e.idealFrameRate&&t.tag(3,V.TD.Varint).int32(e.idealFrameRate);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.VideoMediaRequest",[{no:1,name:"ideal_height",kind:"scalar",T:5},{no:2,name:"ideal_width",kind:"scalar",T:5},{no:3,name:"ideal_frame_rate",kind:"scalar",T:5}])}}let ip=new iu;class ig extends B.C{create(e){let t={name:"",active:!1,maxBitrate:0,scaleResolutionDownBy:0,priority:0,maxFramerate:0};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.name=e.string();break;case 2:a.active=e.bool();break;case 3:a.maxBitrate=e.int32();break;case 4:a.scaleResolutionDownBy=e.float();break;case 5:a.priority=e.int32();break;case 6:a.codec=eH.internalBinaryRead(e,e.uint32(),i,a.codec);break;case 7:a.maxFramerate=e.uint32();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){""!==e.name&&t.tag(1,V.TD.LengthDelimited).string(e.name),!1!==e.active&&t.tag(2,V.TD.Varint).bool(e.active),0!==e.maxBitrate&&t.tag(3,V.TD.Varint).int32(e.maxBitrate),0!==e.scaleResolutionDownBy&&t.tag(4,V.TD.Bit32).float(e.scaleResolutionDownBy),0!==e.priority&&t.tag(5,V.TD.Varint).int32(e.priority),e.codec&&eH.internalBinaryWrite(e.codec,t.tag(6,V.TD.LengthDelimited).fork(),i).join(),0!==e.maxFramerate&&t.tag(7,V.TD.Varint).uint32(e.maxFramerate);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.VideoLayerSetting",[{no:1,name:"name",kind:"scalar",T:9},{no:2,name:"active",kind:"scalar",T:8},{no:3,name:"max_bitrate",kind:"scalar",T:5},{no:4,name:"scale_resolution_down_by",kind:"scalar",T:2},{no:5,name:"priority",kind:"enum",T:()=>["stream.video.sfu.event.VideoLayerSetting.Priority",U,"PRIORITY_"]},{no:6,name:"codec",kind:"message",T:()=>eH},{no:7,name:"max_framerate",kind:"scalar",T:13}])}}let im=new ig;class iy extends B.C{create(e){let t={layers:[]};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.mediaRequest=ip.internalBinaryRead(e,e.uint32(),i,a.mediaRequest);break;case 2:a.codec=eH.internalBinaryRead(e,e.uint32(),i,a.codec);break;case 3:a.layers.push(im.internalBinaryRead(e,e.uint32(),i));break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){e.mediaRequest&&ip.internalBinaryWrite(e.mediaRequest,t.tag(1,V.TD.LengthDelimited).fork(),i).join(),e.codec&&eH.internalBinaryWrite(e.codec,t.tag(2,V.TD.LengthDelimited).fork(),i).join();for(let n=0;n<e.layers.length;n++)im.internalBinaryWrite(e.layers[n],t.tag(3,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.VideoSender",[{no:1,name:"media_request",kind:"message",T:()=>ip},{no:2,name:"codec",kind:"message",T:()=>eH},{no:3,name:"layers",kind:"message",repeat:1,T:()=>im}])}}let ib=new iy;class iv extends B.C{create(e){let t={audioSenders:[],videoSenders:[]};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.audioSenders.push(ih.internalBinaryRead(e,e.uint32(),i));break;case 2:a.videoSenders.push(ib.internalBinaryRead(e,e.uint32(),i));break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){for(let n=0;n<e.audioSenders.length;n++)ih.internalBinaryWrite(e.audioSenders[n],t.tag(1,V.TD.LengthDelimited).fork(),i).join();for(let n=0;n<e.videoSenders.length;n++)ib.internalBinaryWrite(e.videoSenders[n],t.tag(2,V.TD.LengthDelimited).fork(),i).join();let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.ChangePublishQuality",[{no:1,name:"audio_senders",kind:"message",repeat:1,T:()=>ih},{no:2,name:"video_senders",kind:"message",repeat:1,T:()=>ib}])}}let ik=new iv;class iw extends B.C{create(e){let t={message:""};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();switch(t){case 1:a.currentGrants=e6.internalBinaryRead(e,e.uint32(),i,a.currentGrants);break;case 2:a.message=e.string();break;default:let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){e.currentGrants&&e6.internalBinaryWrite(e.currentGrants,t.tag(1,V.TD.LengthDelimited).fork(),i).join(),""!==e.message&&t.tag(2,V.TD.LengthDelimited).string(e.message);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.CallGrantsUpdated",[{no:1,name:"current_grants",kind:"message",T:()=>e6},{no:2,name:"message",kind:"scalar",T:9}])}}let iT=new iw;class iC extends B.C{create(e){let t={reason:0};return globalThis.Object.defineProperty(t,F.C,{enumerable:!1,value:this}),void 0!==e&&(0,W.l)(this,t,e),t}internalBinaryRead(e,t,i,n){let a=null!=n?n:this.create(),s=e.pos+t;for(;e.pos<s;){let[t,n]=e.tag();if(1===t)a.reason=e.int32();else{let s=i.readUnknownField;if("throw"===s)throw new globalThis.Error("Unknown field ".concat(t," (wire type ").concat(n,") for ").concat(this.typeName));let r=e.skip(n);!1!==s&&(!0===s?V.z.onRead:s)(this.typeName,a,t,n,r)}}return a}internalBinaryWrite(e,t,i){0!==e.reason&&t.tag(1,V.TD.Varint).int32(e.reason);let n=i.writeUnknownFields;return!1!==n&&(!0==n?V.z.onWrite:n)(this.typeName,e,t),t}constructor(){super("stream.video.sfu.event.GoAway",[{no:1,name:"reason",kind:"enum",T:()=>["stream.video.sfu.models.GoAwayReason",P,"GO_AWAY_REASON_"]}])}}let iS=new iC;(y=N||(N={})).UNKNOWN="UNKNOWN",y.VISIBLE="VISIBLE",y.INVISIBLE="INVISIBLE",(b=A||(A={}))[b.IMMEDIATE=20]="IMMEDIATE",b[b.FAST=100]="FAST",b[b.MEDIUM=600]="MEDIUM",b[b.SLOW=1200]="SLOW";let iI=e=>!!e.isLocalParticipant;class iR{setPublisher(e,t){let i=this.methods[0],n=this._transport.mergeOptions(t);return(0,H.xA)("unary",this._transport,i,n,e)}sendAnswer(e,t){let i=this.methods[1],n=this._transport.mergeOptions(t);return(0,H.xA)("unary",this._transport,i,n,e)}iceTrickle(e,t){let i=this.methods[2],n=this._transport.mergeOptions(t);return(0,H.xA)("unary",this._transport,i,n,e)}updateSubscriptions(e,t){let i=this.methods[3],n=this._transport.mergeOptions(t);return(0,H.xA)("unary",this._transport,i,n,e)}updateMuteStates(e,t){let i=this.methods[4],n=this._transport.mergeOptions(t);return(0,H.xA)("unary",this._transport,i,n,e)}iceRestart(e,t){let i=this.methods[5],n=this._transport.mergeOptions(t);return(0,H.xA)("unary",this._transport,i,n,e)}constructor(e){this._transport=e,this.typeName=tE.typeName,this.methods=tE.methods,this.options=tE.options}}let iE={baseUrl:"",sendJson:!0,timeout:5e3,jsonOptions:{ignoreUnknownFields:!0}},iD=e=>({interceptUnary:(t,i,n,a)=>(a.meta={...a.meta,...e},t(i,n,a))}),i_=e=>new iR(new K.M({...iE,...e})),iP=Object.freeze({trace:0,debug:1,info:2,warn:3,error:4}),iU="info",iN=function(e,t){let i;for(var n=arguments.length,a=Array(n>2?n-2:0),s=2;s<n;s++)a[s-2]=arguments[s];switch(e){case"error":i=console.error;break;case"warn":i=console.warn;break;case"info":i=console.info;break;case"trace":i=console.trace;break;default:i=console.log}i(t,...a)},iA=(e,t)=>{n=e,t&&iO(t)},iO=e=>{iU=e},iL=e=>{let t=n||iN,i=(e||[]).join(":");return function(e,n){for(var a=arguments.length,s=Array(a>2?a-2:0),r=2;r<a;r++)s[r-2]=arguments[r];iP[e]>=iP[iU]&&t(e,"[".concat(i,"]: ").concat(n),...s)}},iB=(e,t,i)=>{let n=iL(["codecs"]);if(!("getCapabilities"in RTCRtpSender)){null==n||n("warn","RTCRtpSender.getCapabilities is not supported");return}let a=RTCRtpSender.getCapabilities(e);if(!a)return;let s=[],r=[],o=[];a.codecs.forEach(a=>{let l=a.mimeType.toLowerCase();if(null==n||n("debug","Found supported codec: ".concat(l)),!i||l!=="".concat(e,"/").concat(i.toLowerCase())){if(l!=="".concat(e,"/").concat(t.toLowerCase())){o.push(a);return}if("h264"===l){a.sdpFmtpLine&&a.sdpFmtpLine.includes("profile-level-id=42e01f")?s.push(a):r.push(a);return}s.push(a)}});let l=[...s,...r,...o];return null==n||n("info","Preffered codecs: ",l),l},ij=async e=>{var t;let i=new RTCPeerConnection;i.addTransceiver("video",{direction:e}),i.addTransceiver("audio",{direction:e});let n=null!==(t=(await i.createOffer()).sdp)&&void 0!==t?t:"";return i.getTransceivers().forEach(e=>{e.stop()}),i.close(),n},iF={subscriberOffer:void 0,publisherAnswer:void 0,connectionQualityChanged:void 0,audioLevelChanged:void 0,iceTrickle:void 0,changePublishQuality:void 0,participantJoined:void 0,participantLeft:void 0,dominantSpeakerChanged:void 0,joinResponse:void 0,healthCheckResponse:void 0,trackPublished:void 0,trackUnpublished:void 0,error:void 0,callGrantsUpdated:void 0,goAway:void 0,iceRestart:void 0,pinsUpdated:void 0},iW=e=>Object.prototype.hasOwnProperty.call(iF,e);class iV{constructor(){this.subscribers={},this.logger=iL(["sfu-client"]),this.dispatch=e=>{let t=e.eventPayload.oneofKind;if(t){this.logger("debug","Dispatching ".concat(t),e.eventPayload[t]);let i=this.subscribers[t];null==i||i.forEach(t=>{try{t(e)}catch(e){this.logger("warn","Listener failed with error",e)}})}},this.on=(e,t)=>{var i,n;return(null!==(n=(i=this.subscribers)[e])&&void 0!==n?n:i[e]=[]).push(t),()=>{this.off(e,t)}},this.off=(e,t)=>{this.subscribers[e]=(this.subscribers[e]||[]).filter(e=>e!==t)},this.offAll=e=>{e?this.subscribers[e]=[]:this.subscribers={}}}}class iM{constructor(){this.subscriberCandidates=new J.t,this.publisherCandidates=new J.t,this.push=e=>{if(e.peerType===C.SUBSCRIBER)this.subscriberCandidates.next(e);else if(e.peerType===C.PUBLISHER_UNSPECIFIED)this.publisherCandidates.next(e);else{var t;null===(t=this.logger)||void 0===t||t.call(this,"warn","ICETrickle, Unknown peer type",e)}},this.logger=iL(["sfu-client"])}}function ix(e){if(e.usernameFragment)return JSON.stringify(e.toJSON());{let t=e.candidate.split(" "),i=t.findIndex(e=>"ufrag"===e)+1,n=t[i];return JSON.stringify({...e,usernameFragment:n})}}let iH=()=>{var e;return"undefined"!=typeof navigator&&(null===(e=navigator.product)||void 0===e?void 0:e.toLowerCase())==="reactnative"},iz=e=>{a=e},iq=()=>a,iK=()=>s,iJ=()=>r,iG=()=>{if(iH())return{sdk:iq(),os:iK(),device:iJ()};let{browser:e,os:t,device:i,cpu:n}=new ep.UAParser(navigator.userAgent).getResult();return{sdk:iq(),browser:{name:e.name||navigator.userAgent,version:e.version||""},os:{name:t.name||"",version:t.version||"",architecture:n.architecture||""},device:{name:"".concat(i.vendor||""," ").concat(i.model||""," ").concat(i.type||""),version:""}}},i$={bitrate:125e4,width:1280,height:720},iQ=function(e){var t;let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i$,n=[],a=e.getSettings(),{width:s=0,height:r=0}=a,o=iH()&&(null===(t=iK())||void 0===t?void 0:t.name.toLowerCase())==="ios",l=iX(i,s,r),c=1;return["f","h","q"].forEach(e=>{n.unshift({active:!0,rid:e,width:Math.round(s/c),height:Math.round(r/c),maxBitrate:Math.round(l/c),scaleResolutionDownBy:c,maxFramerate:{f:30,h:o?30:25,q:o?30:20}[e]}),c*=2}),iY(a,n)},iX=(e,t,i)=>{let{width:n,height:a}=e;return t<n||i<a?Math.round(e.bitrate*(t*i/(n*a))):e.bitrate},iY=(e,t)=>{let i;let n=Math.max(e.width||0,e.height||0);i=n<=320?t.filter(e=>"f"===e.rid):n<=640?t.filter(e=>"h"!==e.rid):t;let a=["q","h","f"];return i.map((e,t)=>({...e,rid:a[t]}))},iZ=(e,t)=>{var i,n;let a=e.getSettings();return[{active:!0,rid:"q",width:a.width||0,height:a.height||0,scaleResolutionDownBy:1,maxBitrate:null!==(i=null==t?void 0:t.maxBitrate)&&void 0!==i?i:3e6,maxFramerate:null!==(n=null==t?void 0:t.maxFramerate)&&void 0!==n?n:30}]},i0=e=>{switch(e){case R.SCREEN_SHARE:return"screenShareStream";case R.SCREEN_SHARE_AUDIO:return"screenShareAudioStream";case R.VIDEO:return"videoStream";case R.AUDIO:return"audioStream";case R.UNSPECIFIED:throw Error("Track type is unspecified");default:throw Error("Unknown track type: ".concat(e))}},i1=e=>{switch(e){case R.AUDIO:return"audioDeviceId";case R.VIDEO:return"videoDeviceId";case R.SCREEN_SHARE:case R.SCREEN_SHARE_AUDIO:case R.UNSPECIFIED:return;default:throw Error("Unknown track type: ".concat(e))}},i2=e=>{switch(e){case"audio":return R.AUDIO;case"video":return R.VIDEO;case"screenshare":return R.SCREEN_SHARE;case"screenshare_audio":return R.SCREEN_SHARE_AUDIO;default:throw Error("Unknown mute type: ".concat(e))}},i3=e=>{let t=/^a=rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/.exec(e);if(t)return{original:t[0],payload:t[1],codec:t[2]}},i9=e=>{let t=/^a=fmtp:(\d*) (.*)/.exec(e);if(t)return{original:t[0],payload:t[1],config:t[2]}},i4=(e,t)=>{let i=new RegExp("(m=".concat(t," \\d+ [\\w/]+) ([\\d\\s]+)")).exec(e);if(i)return{original:i[0],mediaWithPorts:i[1],codecOrder:i[2]}},i5=(e,t)=>{let i;let n=[],a=[],s=!1;if(e.split(/(\r\n|\r|\n)/).forEach(e=>{if(!/^([a-z])=(.*)/.test(e))return;let r=e[0];if("m"===r){let n=i4(e,t);s=!!n,n&&(i=n)}else if(s&&"a"===r){let t=i3(e),i=i9(e);t?n.push(t):i&&a.push(i)}}),i)return{media:i,rtpMap:n,fmtp:a}},i6=e=>{let t=i5(e,"audio"),i=null==t?void 0:t.rtpMap.find(e=>"opus"===e.codec.toLowerCase()),n=null==i?void 0:i.payload;if(n)return null==t?void 0:t.fmtp.find(e=>e.payload===n)},i8=(e,t)=>{let i=i6(e);if(i){let n=/usedtx=(\d)/.exec(i.config),a="usedtx=".concat(t?"1":"0");if(n){let t=i.original.replace(/usedtx=(\d)/,a);return e.replace(i.original,t)}{let t="".concat(i.original,";").concat(a);return e.replace(i.original,t)}}return e},i7=function(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:51e4;i=Math.max(Math.min(i,51e4),96e3);let n=eu.Qc(e),a=n.media.find(e=>"audio"===e.type&&String(e.mid)===t);if(!a)return e;let s=a.rtp.find(e=>"opus"===e.codec);if(!s)return e;let r=a.fmtp.find(e=>e.payload===s.payload);return r?(r.config.match(/stereo=(\d)/)?r.config=r.config.replace(/stereo=(\d)/,"stereo=1"):r.config="".concat(r.config,";stereo=1"),r.config.match(/maxaveragebitrate=(\d*)/)?r.config=r.config.replace(/maxaveragebitrate=(\d*)/,"maxaveragebitrate=".concat(i)):r.config="".concat(r.config,";maxaveragebitrate=").concat(i),eu.cW(n)):e},ne=iL(["Publisher"]);class nt{constructor({connectionConfig:e,sfuClient:t,dispatcher:i,state:n,isDtxEnabled:a,isRedEnabled:s,iceRestartDelay:r=2500}){var o=this;this.transceiverRegistry={[R.AUDIO]:void 0,[R.VIDEO]:void 0,[R.SCREEN_SHARE]:void 0,[R.SCREEN_SHARE_AUDIO]:void 0,[R.UNSPECIFIED]:void 0},this.publishOptionsPerTrackType=new Map,this.transceiverInitOrder=[],this.trackKindMapping={[R.AUDIO]:"audio",[R.VIDEO]:"video",[R.SCREEN_SHARE]:"video",[R.SCREEN_SHARE_AUDIO]:"audio",[R.UNSPECIFIED]:void 0},this.trackLayersCache={[R.AUDIO]:void 0,[R.VIDEO]:void 0,[R.SCREEN_SHARE]:void 0,[R.SCREEN_SHARE_AUDIO]:void 0,[R.UNSPECIFIED]:void 0},this.isIceRestarting=!1,this.createPeerConnection=e=>{let t=new RTCPeerConnection(e);return t.addEventListener("icecandidate",this.onIceCandidate),t.addEventListener("negotiationneeded",this.onNegotiationNeeded),t.addEventListener("icecandidateerror",this.onIceCandidateError),t.addEventListener("iceconnectionstatechange",this.onIceConnectionStateChange),t.addEventListener("icegatheringstatechange",this.onIceGatheringStateChange),t.addEventListener("signalingstatechange",this.onSignalingStateChange),t},this.close=function(){let{stopTracks:e=!0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e&&(o.stopPublishing(),Object.keys(o.transceiverRegistry).forEach(e=>{o.transceiverRegistry[e]=void 0}),Object.keys(o.trackLayersCache).forEach(e=>{o.trackLayersCache[e]=void 0})),o.unsubscribeOnIceRestart(),o.pc.removeEventListener("negotiationneeded",o.onNegotiationNeeded),o.pc.close()},this.publishStream=async function(e,t,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if("ended"===t.readyState)throw Error("Can't publish a track that has ended already.");let a=o.pc.getTransceivers().find(e=>{var t;return e===o.transceiverRegistry[i]&&e.sender.track&&(null===(t=e.sender.track)||void 0===t?void 0:t.kind)===o.trackKindMapping[i]}),s=async()=>{ne("info","Track ".concat(R[i]," has ended, notifying the SFU")),await o.notifyTrackMuteStateChanged(e,t,i,!0),t.removeEventListener("ended",s)};if(a){let e=a.sender.track;e&&e!==t&&(e.stop(),e.removeEventListener("ended",s),t.addEventListener("ended",s)),t.enabled||(t.enabled=!0),await a.sender.replaceTrack(t)}else{let{settings:l}=o.state,c=null==l?void 0:l.video.target_resolution,d=i===R.VIDEO?iQ(t,c):i===R.SCREEN_SHARE?iZ(t,n.screenShareSettings):void 0,h=n.preferredCodec;if(!h&&i===R.VIDEO){var r;iH()&&(null===(r=iK())||void 0===r?void 0:r.name.toLowerCase())==="android"&&(h="VP8")}let u=o.getCodecPreferences(i,h);t.addEventListener("ended",s),t.enabled||(t.enabled=!0),a=o.pc.addTransceiver(t,{direction:"sendonly",streams:i===R.VIDEO||i===R.SCREEN_SHARE?[e]:void 0,sendEncodings:d}),ne("debug","Added ".concat(R[i]," transceiver")),o.transceiverInitOrder.push(i),o.transceiverRegistry[i]=a,o.publishOptionsPerTrackType.set(i,n),"setCodecPreferences"in a&&u&&(ne("info","Setting ".concat(R[i]," codec preferences"),u),a.setCodecPreferences(u))}await o.notifyTrackMuteStateChanged(e,t,i,!1)},this.unpublishStream=async(e,t)=>{let i=this.pc.getTransceivers().find(t=>t===this.transceiverRegistry[e]&&t.sender.track);if(i&&i.sender.track&&(t?"live"===i.sender.track.readyState:i.sender.track.enabled)){var n;if(t?i.sender.track.stop():i.sender.track.enabled=!1,!(null===(n=this.state.localParticipant)||void 0===n?void 0:n.publishedTracks.includes(e)))return;return this.notifyTrackMuteStateChanged(void 0,i.sender.track,e,!0)}},this.isPublishing=e=>{let t=this.transceiverRegistry[e];if(t&&t.sender){let e=t.sender;return!!e.track&&"live"===e.track.readyState&&e.track.enabled}return!1},this.isLive=e=>{let t=this.transceiverRegistry[e];if(t&&t.sender){let e=t.sender;return!!e.track&&"live"===e.track.readyState}return!1},this.notifyTrackMuteStateChanged=async(e,t,i,n)=>{await this.sfuClient.updateMuteState(i,n);let a=i0(i);if(n)this.state.updateParticipant(this.sfuClient.sessionId,e=>({publishedTracks:e.publishedTracks.filter(e=>e!==i),[a]:void 0}));else{let n=t.getSettings().deviceId,s=i1(i);this.state.updateParticipant(this.sfuClient.sessionId,t=>({publishedTracks:t.publishedTracks.includes(i)?t.publishedTracks:[...t.publishedTracks,i],...s&&{[s]:n},[a]:e}))}},this.stopPublishing=()=>{ne("debug","Stopping publishing all tracks"),this.pc.getSenders().forEach(e=>{var t;null===(t=e.track)||void 0===t||t.stop(),"closed"!==this.pc.signalingState&&this.pc.removeTrack(e)})},this.updateVideoPublishQuality=async e=>{var t;ne("info","Update publish quality, requested layers by SFU:",e);let i=null===(t=this.transceiverRegistry[R.VIDEO])||void 0===t?void 0:t.sender;if(!i){ne("warn","Update publish quality, no video sender found.");return}let n=i.getParameters();if(0===n.encodings.length){ne("warn","Update publish quality, No suitable video encoding quality found");return}let a=!1,s=e.filter(e=>e.active).map(e=>e.name);n.encodings.forEach(t=>{let i=s.includes(t.rid);if(i!==t.active&&(t.active=i,a=!0),i){let i=e.find(e=>e.name===t.rid);void 0!==i&&(i.scaleResolutionDownBy>=1&&i.scaleResolutionDownBy!==t.scaleResolutionDownBy&&(ne("debug","[dynascale]: setting scaleResolutionDownBy from server","layer",i.name,"scale-resolution-down-by",i.scaleResolutionDownBy),t.scaleResolutionDownBy=i.scaleResolutionDownBy,a=!0),i.maxBitrate>0&&i.maxBitrate!==t.maxBitrate&&(ne("debug","[dynascale] setting max-bitrate from the server","layer",i.name,"max-bitrate",i.maxBitrate),t.maxBitrate=i.maxBitrate,a=!0),i.maxFramerate>0&&i.maxFramerate!==t.maxFramerate&&(ne("debug","[dynascale]: setting maxFramerate from server","layer",i.name,"max-framerate",i.maxFramerate),t.maxFramerate=i.maxFramerate,a=!0))}});let r=n.encodings.filter(e=>e.active);a?(await i.setParameters(n),ne("info","Update publish quality, enabled rids: ",r)):ne("info","Update publish quality, no change: ",r)},this.getStats=e=>this.pc.getStats(e),this.getCodecPreferences=(e,t)=>{if(e===R.VIDEO)return iB("video",t||"vp8");if(e===R.AUDIO){let e=this.isRedEnabled?"red":"opus";return iB("audio",null!=t?t:e,this.isRedEnabled?void 0:"red")}},this.onIceCandidate=async e=>{let{candidate:t}=e;if(!t){ne("debug","null ice candidate");return}await this.sfuClient.iceTrickle({iceCandidate:ix(t),peerType:C.PUBLISHER_UNSPECIFIED})},this.migrateTo=async(e,t)=>{this.sfuClient=e,this.pc.setConfiguration(t),"connected"===this.pc.iceConnectionState&&await this.negotiate({iceRestart:!0})},this.restartIce=async()=>{ne("debug","Restarting ICE connection");let e=this.pc.signalingState;if(this.isIceRestarting||"have-local-offer"===e){ne("debug","ICE restart is already in progress");return}await this.negotiate({iceRestart:!0})},this.onNegotiationNeeded=async()=>{await this.negotiate()},this.negotiate=async e=>{var t,i;this.isIceRestarting=null!==(t=null==e?void 0:e.iceRestart)&&void 0!==t&&t;let n=await this.pc.createOffer(e),a=this.mungeCodecs(n.sdp);if(a&&this.isPublishing(R.SCREEN_SHARE_AUDIO)){let e=this.transceiverRegistry[R.SCREEN_SHARE_AUDIO];if(e&&e.sender.track){let t=null!==(i=e.mid)&&void 0!==i?i:this.extractMid(a,e.sender.track,R.SCREEN_SHARE_AUDIO);a=i7(a,t)}}n.sdp=a;let s=this.getCurrentTrackInfos(n.sdp);if(0===s.length)throw Error("Can't initiate negotiation without announcing any tracks");await this.pc.setLocalDescription(n);let{response:r}=await this.sfuClient.setPublisher({sdp:n.sdp||"",tracks:s});try{await this.pc.setRemoteDescription({type:"answer",sdp:r.sdp})}catch(e){ne("error","setRemoteDescription error",{sdp:r.sdp,error:e})}this.isIceRestarting=!1,this.sfuClient.iceTrickleBuffer.publisherCandidates.subscribe(async e=>{try{let t=JSON.parse(e.iceCandidate);await this.pc.addIceCandidate(t)}catch(t){ne("warn","ICE candidate error",[t,e])}})},this.mungeCodecs=e=>(e&&(e=i8(e,this.isDtxEnabled)),e),this.extractMid=(e,t,i)=>{if(!e)return ne("warn","No SDP found. Returning empty mid"),"";ne("debug","No 'mid' found for track. Trying to find it from the Offer SDP");let n=eu.Qc(e).media.find(e=>{var i,n;return e.type===t.kind&&(null===(n=null===(i=e.msid)||void 0===i?void 0:i.includes(t.id))||void 0===n||n)});if(void 0===(null==n?void 0:n.mid)){ne("debug","No mid found in SDP for track type ".concat(t.kind," and id ").concat(t.id,". Attempting to find a heuristic mid"));let e=this.transceiverInitOrder.indexOf(i);return -1!==e?String(e):(ne("debug","No heuristic mid found. Returning empty mid"),"")}return String(n.mid)},this.getCurrentTrackInfos=e=>{var t;e=e||(null===(t=this.pc.localDescription)||void 0===t?void 0:t.sdp);let{settings:i}=this.state,n=null==i?void 0:i.video.target_resolution;return this.pc.getTransceivers().filter(e=>"sendonly"===e.direction&&e.sender.track).map(t=>{var i;let a;let s=Number(Object.keys(this.transceiverRegistry).find(e=>this.transceiverRegistry[e]===t)),r=t.sender.track;if("live"===r.readyState){let e=this.publishOptionsPerTrackType.get(s);a=s===R.VIDEO?iQ(r,n):s===R.SCREEN_SHARE?iZ(r,null==e?void 0:e.screenShareSettings):[],this.trackLayersCache[s]=a}else a=this.trackLayersCache[s]||[],ne("debug","Track ".concat(R[s]," is ended. Announcing last known optimal layers"),a);let o=a.map(e=>({rid:e.rid||"",bitrate:e.maxBitrate||0,fps:e.maxFramerate||0,quality:this.ridToVideoQuality(e.rid||""),videoDimension:{width:e.width,height:e.height}})),l=[R.AUDIO,R.SCREEN_SHARE_AUDIO].includes(s),c=r.getSettings(),d=l&&2===c.channelCount;return{trackId:r.id,layers:o,trackType:s,mid:null!==(i=t.mid)&&void 0!==i?i:this.extractMid(e,r,s),stereo:d,dtx:l&&this.isDtxEnabled,red:l&&this.isRedEnabled}})},this.onIceCandidateError=e=>{ne("error","ICE Candidate error",e instanceof RTCPeerConnectionIceErrorEvent&&"".concat(e.errorCode,": ").concat(e.errorText))},this.onIceConnectionStateChange=()=>{let e=this.pc.iceConnectionState;ne("debug","ICE Connection state changed to",e),"failed"===e?(ne("warn","Attempting to restart ICE"),this.restartIce().catch(e=>{ne("error","ICE restart error",e)})):"disconnected"===e&&(ne("warn","Scheduling ICE restart in ".concat(this.iceRestartDelay," ms.")),setTimeout(()=>{"disconnected"===this.pc.iceConnectionState||"failed"===this.pc.iceConnectionState?this.restartIce().catch(e=>{ne("error","ICE restart error",e)}):ne("debug","Scheduled ICE restart: connection recovered, canceled.")},this.iceRestartDelay))},this.onIceGatheringStateChange=()=>{ne("debug","ICE Gathering State",this.pc.iceGatheringState)},this.onSignalingStateChange=()=>{ne("debug","Signaling state changed",this.pc.signalingState)},this.ridToVideoQuality=e=>"q"===e?I.LOW_UNSPECIFIED:"h"===e?I.MID:I.HIGH,this.pc=this.createPeerConnection(e),this.sfuClient=t,this.state=n,this.isDtxEnabled=a,this.isRedEnabled=s,this.iceRestartDelay=r,this.unsubscribeOnIceRestart=i.on("iceRestart",async e=>{if("iceRestart"!==e.eventPayload.oneofKind)return;let{iceRestart:t}=e.eventPayload;t.peerType===C.PUBLISHER_UNSPECIFIED&&await this.restartIce()})}}let ni=iL(["Subscriber"]);class nn{constructor({sfuClient:e,dispatcher:t,state:i,connectionConfig:n,iceRestartDelay:a=2500}){this.isIceRestarting=!1,this.createPeerConnection=e=>{let t=new RTCPeerConnection(e);return t.addEventListener("icecandidate",this.onIceCandidate),t.addEventListener("track",this.handleOnTrack),t.addEventListener("icecandidateerror",this.onIceCandidateError),t.addEventListener("iceconnectionstatechange",this.onIceConnectionStateChange),t.addEventListener("icegatheringstatechange",this.onIceGatheringStateChange),t},this.close=()=>{this.unregisterOnSubscriberOffer(),this.unregisterOnIceRestart(),this.pc.close()},this.getStats=e=>this.pc.getStats(e),this.migrateTo=(e,t)=>{let i;this.sfuClient=e;let n=this.pc,a=new Set;n.getReceivers().forEach(e=>{"video"===e.track.kind&&a.add(e.track.id)});let s=this.createPeerConnection(t),r=()=>{n.close(),clearTimeout(i)},o=e=>{ni("debug","[Migration]: Migrated track: ".concat(e.track.id,", ").concat(e.track.kind)),a.delete(e.track.id),0===a.size&&(ni("debug","[Migration]: Migration complete"),s.removeEventListener("track",o),r())},l=()=>{"connected"===s.connectionState&&(i=setTimeout(()=>{s.removeEventListener("track",o),r()},2e3),s.removeEventListener("connectionstatechange",l))};s.addEventListener("track",o),s.addEventListener("connectionstatechange",l),this.pc=s},this.restartIce=async()=>{if(ni("debug","Restarting ICE connection"),"have-remote-offer"===this.pc.signalingState){ni("debug","ICE restart is already in progress");return}let e=this.isIceRestarting;try{this.isIceRestarting=!0,await this.sfuClient.iceRestart({peerType:C.SUBSCRIBER})}catch(t){throw this.isIceRestarting=e,t}},this.handleOnTrack=e=>{let[t]=e.streams,[i,n]=t.id.split(":"),a=this.state.participants.find(e=>e.trackLookupPrefix===i);if(ni("debug","[onTrack]: Got remote ".concat(n," track for userId: ").concat(null==a?void 0:a.userId),e.track.id,e.track),!a){ni("error","[onTrack]: Received track for unknown participant: ".concat(i),e);return}e.track.addEventListener("mute",()=>{ni("info","[onTrack]: Track muted: ".concat(a.userId," ").concat(n,":").concat(i))}),e.track.addEventListener("unmute",()=>{ni("info","[onTrack]: Track unmuted: ".concat(a.userId," ").concat(n,":").concat(i))}),e.track.addEventListener("ended",()=>{ni("info","[onTrack]: Track ended: ".concat(a.userId," ").concat(n,":").concat(i))});let s={TRACK_TYPE_AUDIO:"audioStream",TRACK_TYPE_VIDEO:"videoStream",TRACK_TYPE_SCREEN_SHARE:"screenShareStream",TRACK_TYPE_SCREEN_SHARE_AUDIO:"screenShareAudioStream"}[n];if(!s){ni("error","Unknown track type: ".concat(n));return}let r=a[s];r&&(ni("info","[onTrack]: Cleaning up previous remote ".concat(e.track.kind," tracks for userId: ").concat(a.userId)),r.getTracks().forEach(e=>{e.stop(),r.removeTrack(e)})),this.state.updateParticipant(a.sessionId,{[s]:t})},this.onIceCandidate=async e=>{let{candidate:t}=e;if(!t){ni("debug","null ice candidate");return}await this.sfuClient.iceTrickle({iceCandidate:ix(t),peerType:C.SUBSCRIBER})},this.negotiate=async e=>{ni("info","Received subscriberOffer",e),await this.pc.setRemoteDescription({type:"offer",sdp:e.sdp}),this.sfuClient.iceTrickleBuffer.subscriberCandidates.subscribe(async e=>{try{let t=JSON.parse(e.iceCandidate);await this.pc.addIceCandidate(t)}catch(t){ni("warn","ICE candidate error",[t,e])}});let t=await this.pc.createAnswer();await this.pc.setLocalDescription(t),await this.sfuClient.sendAnswer({peerType:C.SUBSCRIBER,sdp:t.sdp||""}),this.isIceRestarting=!1},this.onIceConnectionStateChange=()=>{let e=this.pc.iceConnectionState;ni("debug","ICE connection state changed",e),this.isIceRestarting||("failed"===e?(ni("warn","Attempting to restart ICE"),this.restartIce().catch(e=>{ni("error","ICE restart failed",e)})):"disconnected"===e&&(ni("warn","Scheduling ICE restart in ".concat(this.iceRestartDelay," ms.")),setTimeout(()=>{"disconnected"===this.pc.iceConnectionState||"failed"===this.pc.iceConnectionState?this.restartIce().catch(e=>{ni("error","ICE restart failed",e)}):ni("debug","Scheduled ICE restart: connection recovered, canceled.")},5e3)))},this.onIceGatheringStateChange=()=>{ni("debug","ICE gathering state changed",this.pc.iceGatheringState)},this.onIceCandidateError=e=>{let t=e instanceof RTCPeerConnectionIceErrorEvent&&"".concat(e.errorCode,": ").concat(e.errorText);ni("connected"===this.pc.iceConnectionState?"debug":"error","ICE Candidate error",t)},this.sfuClient=e,this.dispatcher=t,this.state=i,this.iceRestartDelay=a,this.pc=this.createPeerConnection(n),this.unregisterOnSubscriberOffer=t.on("subscriberOffer",async e=>{if("subscriberOffer"!==e.eventPayload.oneofKind)return;let{subscriberOffer:t}=e.eventPayload;await this.negotiate(t)}),this.unregisterOnIceRestart=t.on("iceRestart",async e=>{if("iceRestart"!==e.eventPayload.oneofKind)return;let{iceRestart:t}=e.eventPayload;t.peerType===C.SUBSCRIBER&&await this.restartIce()})}}let na=e=>{let t=iL(["sfu-client"]),{endpoint:i,onMessage:n}=e,a=new eg.Z(i);return a.binaryType="arraybuffer",a.addEventListener("error",e=>{t("error","Signaling WS channel error",e)}),a.addEventListener("close",e=>{t("info","Signaling WS channel is closed",e)}),a.addEventListener("open",e=>{t("info","Signaling WS channel is open",e)}),n&&a.addEventListener("message",e=>{try{let t=e.data instanceof ArrayBuffer?t_.fromBinary(new Uint8Array(e.data)):t_.fromJsonString(e.data.toString());n(t)}catch(i){t("error","Failed to decode a message. Check whether the Proto models match.",{event:e,error:i})}}),a},ns=e=>new Promise(t=>setTimeout(t,e));function nr(e){return e&&("[object Function]"===Object.prototype.toString.call(e)||"function"==typeof e||e instanceof Function)}let no={TOKEN_EXPIRED:40,WS_CLOSED_SUCCESS:1e3,WS_CLOSED_ABRUPTLY:1006,WS_POLICY_VIOLATION:1008};function nl(e){let t=Math.min(Math.max(250,(e-1)*2e3),5e3);return Math.floor(Math.random()*(Math.min(500+2e3*e,5e3)-t)+t)}function nc(e){let t="";for(let i=0;i<e.length;i++)t+=e[i].toString(16).padStart(2,"0");return t}function nd(){let e=function(e){let t=new Uint8Array(16);return nh(t),t}(0);return e[6]=15&e[6]|64,e[8]=191&e[8]|128,nc(e.subarray(0,4))+"-"+nc(e.subarray(4,6))+"-"+nc(e.subarray(6,8))+"-"+nc(e.subarray(8,10))+"-"+nc(e.subarray(10,16))}let nh="undefined"!=typeof crypto&&void 0!==(null===(v=crypto)||void 0===v?void 0:v.getRandomValues)?crypto.getRandomValues.bind(crypto):"undefined"!=typeof msCrypto?msCrypto.getRandomValues.bind(msCrypto):function(e){let t=Math.pow(2,8*e.byteLength/e.length);for(let i=0;i<e.length;i++)e[i]=Math.random()*t};function nu(e){"undefined"!=typeof window&&window.addEventListener&&(window.addEventListener("offline",e),window.addEventListener("online",e))}function np(e){"undefined"!=typeof window&&window.removeEventListener&&(window.removeEventListener("offline",e),window.removeEventListener("online",e))}class ng{constructor({dispatcher:e,sfuServer:t,token:i,sessionId:n}){var a=this;this.iceTrickleBuffer=new iM,this.isMigratingAway=!1,this.pingIntervalInMs=1e4,this.unhealthyTimeoutInMs=this.pingIntervalInMs+5e3,this.close=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e3,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Requested signal connection close";a.logger("debug","Closing SFU WS connection",e,t),a.signalWs.close(e,t),a.unsubscribeIceTrickle(),clearInterval(a.keepAliveInterval),clearTimeout(a.connectionCheckTimeout)},this.updateSubscriptions=async e=>nm(()=>this.rpc.updateSubscriptions({sessionId:this.sessionId,tracks:e}),this.logger),this.setPublisher=async e=>nm(()=>this.rpc.setPublisher({...e,sessionId:this.sessionId}),this.logger),this.sendAnswer=async e=>nm(()=>this.rpc.sendAnswer({...e,sessionId:this.sessionId}),this.logger),this.iceTrickle=async e=>nm(()=>this.rpc.iceTrickle({...e,sessionId:this.sessionId}),this.logger),this.iceRestart=async e=>nm(()=>this.rpc.iceRestart({...e,sessionId:this.sessionId}),this.logger),this.updateMuteState=async(e,t)=>this.updateMuteStates({muteStates:[{trackType:e,muted:t}]}),this.updateMuteStates=async e=>nm(()=>this.rpc.updateMuteStates({...e,sessionId:this.sessionId}),this.logger),this.join=async e=>{let t=tG.create({...e,sessionId:this.sessionId,token:this.token});return this.send(tF.create({requestPayload:{oneofKind:"joinRequest",joinRequest:t}}))},this.send=e=>this.signalReady.then(t=>{this.logger("debug","Sending message to: ".concat(this.edgeName),tF.toJson(e)),t.send(tF.toBinary(e))}),this.keepAlive=()=>{this.keepAliveInterval&&clearInterval(this.keepAliveInterval),this.keepAliveInterval=setInterval(()=>{this.logger("trace","Sending healthCheckRequest to SFU");let e=tF.create({requestPayload:{oneofKind:"healthCheckRequest",healthCheckRequest:{}}});this.send(e)},this.pingIntervalInMs)},this.scheduleConnectionCheck=()=>{this.connectionCheckTimeout&&clearTimeout(this.connectionCheckTimeout),this.connectionCheckTimeout=setTimeout(()=>{this.lastMessageTimestamp&&new Date().getTime()-this.lastMessageTimestamp.getTime()>this.unhealthyTimeoutInMs&&this.close(4001,"SFU connection unhealthy. Didn't receive any healthcheck messages for ".concat(this.unhealthyTimeoutInMs,"ms"))},this.unhealthyTimeoutInMs)},this.sessionId=n||nd(),this.sfuServer=t,this.edgeName=t.edge_name,this.token=i,this.logger=iL(["sfu-client"]),this.rpc=i_({baseUrl:t.url,interceptors:[iD({Authorization:"Bearer ".concat(i)}),{interceptUnary:(e,t,i,n)=>(this.logger("trace","Calling SFU RPC method ".concat(t.name),{input:i,options:n}),e(t,i,n))}]}),this.unsubscribeIceTrickle=e.on("iceTrickle",e=>{if("iceTrickle"!==e.eventPayload.oneofKind)return;let{iceTrickle:t}=e.eventPayload;this.iceTrickleBuffer.push(t)}),this.signalWs=na({endpoint:t.ws_endpoint,onMessage:t=>{this.lastMessageTimestamp=new Date,this.scheduleConnectionCheck(),e.dispatch(t)}}),this.signalReady=new Promise(e=>{let t=()=>{this.signalWs.removeEventListener("open",t),this.keepAlive(),e(this.signalWs)};this.signalWs.addEventListener("open",t)})}}let nm=async(e,t)=>{var i;let n;let a=0;do a>0&&await ns(nl(a)),n=await e(),t("trace","SFU RPC response received for ".concat(n.method.name),n),n.response.error&&t("error","SFU RPC Error (".concat(n.method.name,"):"),n.response.error),a++;while((null===(i=n.response.error)||void 0===i?void 0:i.shouldRetry)&&a<5);if(n.response.error)throw n.response.error;return n},nf=e=>"function"==typeof e,ny=e=>{let t,i;if((0,G.a)([e]).subscribe({next:e=>{let[i]=e;t=i},error:e=>{i=e}}).unsubscribe(),i)throw i;return t},nb=(e,t)=>{let i=nf(t)?t(ny(e)):t;return e.next(i),i},nv=(e,t)=>{let i=e.subscribe(t);return()=>{i.unsubscribe()}};var nk=Object.freeze({__proto__:null,createSubscription:nv,getCurrentValue:ny,setCurrentValue:nb});class nw{get connectedUser(){return this.getCurrentValue(this.connectedUserSubject)}get calls(){return this.getCurrentValue(this.callsSubject)}constructor(){this.connectedUserSubject=new $.X(void 0),this.callsSubject=new $.X([]),this.getCurrentValue=ny,this.setCurrentValue=nb,this.setConnectedUser=e=>this.setCurrentValue(this.connectedUserSubject,e),this.setCalls=e=>this.setCurrentValue(this.callsSubject,e),this.registerCall=e=>{this.calls.find(t=>t.cid===e.cid)||this.setCalls(t=>[...t,e])},this.unregisterCall=e=>this.setCalls(t=>t.filter(t=>t!==e)),this.findCall=(e,t)=>this.calls.find(i=>i.type===e&&i.id===t),this.connectedUserSubject.subscribe(async e=>{if(!e)for(let e of this.calls)iL(["client-state"])("info","User disconnected, leaving call: ".concat(e.cid)),await e.leave()})}}class nT{get connectedUser(){return ny(this.connectedUser$)}get calls(){return ny(this.calls$)}constructor(e){this.getCurrentValue=ny,this.connectedUser$=e.connectedUserSubject.asObservable(),this.calls$=e.callsSubject.asObservable()}}let nC=function(){for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];return(e,i)=>{for(let n of t){let t=n(e,i);if(0!==t)return t}return 0}},nS=e=>t=>(i,n)=>e(i,n)?t(i,n):0,nI=(e,t)=>e.isDominantSpeaker&&!t.isDominantSpeaker?-1:!e.isDominantSpeaker&&t.isDominantSpeaker?1:0,nR=(e,t)=>e.isSpeaking&&!t.isSpeaking?-1:!e.isSpeaking&&t.isSpeaking?1:0,nE=(e,t)=>nA(e)&&!nA(t)?-1:!nA(e)&&nA(t)?1:0,nD=(e,t)=>nO(e)&&!nO(t)?-1:!nO(e)&&nO(t)?1:0,n_=(e,t)=>nL(e)&&!nL(t)?-1:!nL(e)&&nL(t)?1:0,nP=(e,t)=>{if(e.pin&&t.pin){if(!e.pin.isLocalPin&&t.pin.isLocalPin)return -1;if(e.pin.isLocalPin&&!t.pin.isLocalPin)return 1;if(e.pin.pinnedAt>t.pin.pinnedAt)return -1;if(e.pin.pinnedAt<t.pin.pinnedAt)return 1}return e.pin&&!t.pin?-1:!e.pin&&t.pin?1:0},nU=e=>(t,i)=>{var n,a,s,r;return(null===(n=t.reaction)||void 0===n?void 0:n.type)===e&&(null===(a=i.reaction)||void 0===a?void 0:a.type)!==e?-1:(null===(s=t.reaction)||void 0===s?void 0:s.type)!==e&&(null===(r=i.reaction)||void 0===r?void 0:r.type)===e?1:0},nN=(e,t)=>(e.roles||[]).some(e=>t.includes(e)),nA=e=>e.publishedTracks.includes(R.SCREEN_SHARE),nO=e=>e.publishedTracks.includes(R.VIDEO),nL=e=>e.publishedTracks.includes(R.AUDIO),nB=nS((e,t)=>{var i,n;return(null===(i=e.viewportVisibilityState)||void 0===i?void 0:i.videoTrack)===N.INVISIBLE||(null===(n=t.viewportVisibilityState)||void 0===n?void 0:n.videoTrack)===N.INVISIBLE}),nj=nS((e,t)=>{var i,n,a,s;return(null===(i=e.viewportVisibilityState)||void 0===i?void 0:i.videoTrack)===N.INVISIBLE||(null===(n=e.viewportVisibilityState)||void 0===n?void 0:n.videoTrack)===N.UNKNOWN||(null===(a=t.viewportVisibilityState)||void 0===a?void 0:a.videoTrack)===N.INVISIBLE||(null===(s=t.viewportVisibilityState)||void 0===s?void 0:s.videoTrack)===N.UNKNOWN}),nF=nC(nP,nE,nB(nC(nI,nR,nU("raised-hand"),nD,n_)));nC(nP,nE,nI,nB(nC(nR,nU("raised-hand"),nD,n_)));let nW=nC(nP,nj(nC(nI,nR,nU("raised-hand"),nD,n_))),nV=nC(nB(nC(nI,nR,nU("raised-hand"),nD,n_)),function(){for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];return(e,i)=>nN(e,t)&&!nN(i,t)?-1:!nN(e,t)&&nN(i,t)?1:0}("admin","host","speaker"));(k=O||(O={})).UNKNOWN="unknown",k.IDLE="idle",k.RINGING="ringing",k.JOINING="joining",k.JOINED="joined",k.LEFT="left",k.RECONNECTING="reconnecting",k.MIGRATING="migrating",k.RECONNECTING_FAILED="reconnecting-failed",k.OFFLINE="offline";class nM{get participantCount(){return this.getCurrentValue(this.participantCount$)}get startedAt(){return this.getCurrentValue(this.startedAt$)}get anonymousParticipantCount(){return this.getCurrentValue(this.anonymousParticipantCount$)}get participants(){return this.getCurrentValue(this.participants$)}get localParticipant(){return this.getCurrentValue(this.localParticipant$)}get remoteParticipants(){return this.getCurrentValue(this.remoteParticipants$)}get dominantSpeaker(){return this.getCurrentValue(this.dominantSpeaker$)}get pinnedParticipants(){return this.getCurrentValue(this.pinnedParticipants$)}get hasOngoingScreenShare(){return this.getCurrentValue(this.hasOngoingScreenShare$)}get callingState(){return this.getCurrentValue(this.callingState$)}get callStatsReport(){return this.getCurrentValue(this.callStatsReport$)}get members(){return this.getCurrentValue(this.members$)}get ownCapabilities(){return this.getCurrentValue(this.ownCapabilities$)}get backstage(){return this.getCurrentValue(this.backstage$)}get blockedUserIds(){return this.getCurrentValue(this.blockedUserIds$)}get createdAt(){return this.getCurrentValue(this.createdAt$)}get endedAt(){return this.getCurrentValue(this.endedAt$)}get startsAt(){return this.getCurrentValue(this.startsAt$)}get updatedAt(){return this.getCurrentValue(this.updatedAt$)}get createdBy(){return this.getCurrentValue(this.createdBy$)}get custom(){return this.getCurrentValue(this.custom$)}get egress(){return this.getCurrentValue(this.egress$)}get ingress(){return this.getCurrentValue(this.ingress$)}get recording(){return this.getCurrentValue(this.recording$)}get session(){return this.getCurrentValue(this.session$)}get settings(){return this.getCurrentValue(this.settings$)}get transcribing(){return this.getCurrentValue(this.transcribing$)}get endedBy(){return this.getCurrentValue(this.endedBy$)}get thumbnails(){return this.getCurrentValue(this.thumbnails$)}constructor(){this.backstageSubject=new $.X(!0),this.blockedUserIdsSubject=new $.X([]),this.createdAtSubject=new $.X(new Date),this.endedAtSubject=new $.X(void 0),this.startsAtSubject=new $.X(void 0),this.updatedAtSubject=new $.X(new Date),this.createdBySubject=new $.X(void 0),this.customSubject=new $.X({}),this.egressSubject=new $.X(void 0),this.ingressSubject=new $.X(void 0),this.recordingSubject=new $.X(!1),this.sessionSubject=new $.X(void 0),this.settingsSubject=new $.X(void 0),this.transcribingSubject=new $.X(!1),this.endedBySubject=new $.X(void 0),this.thumbnailsSubject=new $.X(void 0),this.membersSubject=new $.X([]),this.ownCapabilitiesSubject=new $.X([]),this.callingStateSubject=new $.X(O.UNKNOWN),this.startedAtSubject=new $.X(void 0),this.participantCountSubject=new $.X(0),this.anonymousParticipantCountSubject=new $.X(0),this.participantsSubject=new $.X([]),this.callStatsReportSubject=new $.X(void 0),this.sortParticipantsBy=nF,this.setSortParticipantsBy=e=>{this.sortParticipantsBy=e,this.setCurrentValue(this.participantsSubject,e=>e)},this.getCurrentValue=ny,this.setCurrentValue=nb,this.setParticipantCount=e=>this.setCurrentValue(this.participantCountSubject,e),this.setStartedAt=e=>this.setCurrentValue(this.startedAtSubject,e),this.setAnonymousParticipantCount=e=>this.setCurrentValue(this.anonymousParticipantCountSubject,e),this.setParticipants=e=>this.setCurrentValue(this.participantsSubject,e),this.setCallingState=e=>this.setCurrentValue(this.callingStateSubject,e),this.setCallStatsReport=e=>this.setCurrentValue(this.callStatsReportSubject,e),this.setMembers=e=>{this.setCurrentValue(this.membersSubject,e)},this.setOwnCapabilities=e=>this.setCurrentValue(this.ownCapabilitiesSubject,e),this.findParticipantBySessionId=e=>this.participants.find(t=>t.sessionId===e),this.getParticipantLookupBySessionId=()=>this.participants.reduce((e,t)=>(e[t.sessionId]=t,e),{}),this.updateParticipant=(e,t)=>{let i=this.findParticipantBySessionId(e);if(!i){this.logger("warn","Participant with sessionId ".concat(e," not found"));return}let n="function"==typeof t?t(i):t,a={...i,...n};return this.setParticipants(t=>t.map(t=>t.sessionId===e?a:t))},this.updateOrAddParticipant=(e,t)=>this.findParticipantBySessionId(e)?this.setParticipants(i=>i.map(i=>i.sessionId===e?{...i,...t}:i)):this.setParticipants(e=>[...e,t]),this.updateParticipants=e=>{if(0!==Object.keys(e).length)return this.setParticipants(t=>t.map(t=>{let i=e[t.sessionId];return i?{...t,...i}:t}))},this.updateFromEvent=e=>{let t=this.eventHandlers[e.type];t&&t(e)},this.setServerSidePins=e=>{let t=e.reduce((e,t)=>(e[t.sessionId]=Date.now(),e),{});return this.setParticipants(e=>e.map(e=>{let i=t[e.sessionId];return i?{...e,pin:{isLocalPin:!1,pinnedAt:i}}:e.pin&&!e.pin.isLocalPin?{...e,pin:void 0}:e}))},this.updateFromCallResponse=e=>{this.setCurrentValue(this.backstageSubject,e.backstage),this.setCurrentValue(this.blockedUserIdsSubject,e.blocked_user_ids),this.setCurrentValue(this.createdAtSubject,new Date(e.created_at)),this.setCurrentValue(this.updatedAtSubject,new Date(e.updated_at)),this.setCurrentValue(this.startsAtSubject,e.starts_at?new Date(e.starts_at):void 0),this.setCurrentValue(this.endedAtSubject,e.ended_at?new Date(e.ended_at):void 0),this.setCurrentValue(this.createdBySubject,e.created_by),this.setCurrentValue(this.customSubject,e.custom),this.setCurrentValue(this.egressSubject,e.egress),this.setCurrentValue(this.ingressSubject,e.ingress),this.setCurrentValue(this.recordingSubject,e.recording),this.setCurrentValue(this.sessionSubject,e.session),this.setCurrentValue(this.settingsSubject,e.settings),this.setCurrentValue(this.transcribingSubject,e.transcribing),this.setCurrentValue(this.thumbnailsSubject,e.thumbnails)},this.updateFromMemberRemoved=e=>{this.setCurrentValue(this.membersSubject,t=>t.filter(t=>-1===e.members.indexOf(t.user_id)))},this.updateFromMemberAdded=e=>{this.setCurrentValue(this.membersSubject,t=>[...t,...e.members])},this.updateFromHLSBroadcastStopped=()=>{this.setCurrentValue(this.egressSubject,e=>({...e,broadcasting:!1}))},this.updateFromHLSBroadcastingFailed=()=>{this.setCurrentValue(this.egressSubject,e=>({...e,broadcasting:!1}))},this.updateFromHLSBroadcastStarted=e=>{this.setCurrentValue(this.egressSubject,t=>({...t,broadcasting:!0,hls:{...t.hls,playlist_url:e.hls_playlist_url}}))},this.updateFromSessionParticipantLeft=e=>{this.setCurrentValue(this.sessionSubject,t=>{if(!t)return this.logger("warn","Received call.session_participant_left event but no session is available.",e),t;let{participants:i,participants_count_by_role:n}=t,{user:a,user_session_id:s}=e.participant;return{...t,participants:i.filter(e=>e.user_session_id!==s),participants_count_by_role:{...n,[a.role]:Math.max(0,(n[a.role]||0)-1)}}})},this.updateFromSessionParticipantJoined=e=>{this.setCurrentValue(this.sessionSubject,t=>{if(!t)return this.logger("warn","Received call.session_participant_joined event but no session is available.",e),t;let{participants:i,participants_count_by_role:n}=t,{user:a}=e.participant;return{...t,participants:[...i,e.participant],participants_count_by_role:{...n,[a.role]:(n[a.role]||0)+1}}})},this.updateMembers=e=>{this.setCurrentValue(this.membersSubject,t=>t.map(t=>e.members.find(e=>e.user_id===t.user_id)||t))},this.updateParticipantReaction=e=>{let{user:t,custom:i,type:n,emoji_code:a}=e.reaction;this.setParticipants(e=>e.map(e=>e.userId!==t.id?e:{...e,reaction:{type:n,emoji_code:a,custom:i}}))},this.unblockUser=e=>{this.setCurrentValue(this.blockedUserIdsSubject,t=>t?t.filter(t=>t!==e.user.id):t)},this.blockUser=e=>{this.setCurrentValue(this.blockedUserIdsSubject,t=>[...t||[],e.user.id])},this.updateOwnCapabilities=e=>{var t;e.user.id===(null===(t=this.localParticipant)||void 0===t?void 0:t.userId)&&this.setCurrentValue(this.ownCapabilitiesSubject,e.own_capabilities)},this.logger=iL(["CallState"]),this.participants$=this.participantsSubject.asObservable().pipe((0,Q.U)(e=>e.sort(this.sortParticipantsBy)),(0,X.d)({bufferSize:1,refCount:!0})),this.localParticipant$=this.participants$.pipe((0,Q.U)(e=>e.find(iI)),(0,X.d)({bufferSize:1,refCount:!0})),this.remoteParticipants$=this.participants$.pipe((0,Q.U)(e=>e.filter(e=>!e.isLocalParticipant)),(0,X.d)({bufferSize:1,refCount:!0})),this.pinnedParticipants$=this.participants$.pipe((0,Q.U)(e=>e.filter(e=>!!e.pin)),(0,X.d)({bufferSize:1,refCount:!0})),this.dominantSpeaker$=this.participants$.pipe((0,Q.U)(e=>e.find(e=>e.isDominantSpeaker)),(0,X.d)({bufferSize:1,refCount:!0})),this.hasOngoingScreenShare$=this.participants$.pipe((0,Q.U)(e=>e.some(e=>e.publishedTracks.includes(R.SCREEN_SHARE))),(0,Y.x)(),(0,X.d)({bufferSize:1,refCount:!0})),this.startedAt$=this.startedAtSubject.asObservable(),this.participantCount$=this.participantCountSubject.asObservable(),this.anonymousParticipantCount$=this.anonymousParticipantCountSubject.asObservable(),this.callStatsReport$=this.callStatsReportSubject.asObservable(),this.members$=this.membersSubject.asObservable(),this.ownCapabilities$=this.ownCapabilitiesSubject.asObservable(),this.callingState$=this.callingStateSubject.asObservable(),this.backstage$=this.backstageSubject.asObservable(),this.blockedUserIds$=this.blockedUserIdsSubject.asObservable(),this.createdAt$=this.createdAtSubject.asObservable(),this.endedAt$=this.endedAtSubject.asObservable(),this.startsAt$=this.startsAtSubject.asObservable(),this.updatedAt$=this.updatedAtSubject.asObservable(),this.createdBy$=this.createdBySubject.asObservable(),this.custom$=this.customSubject.asObservable(),this.egress$=this.egressSubject.asObservable(),this.ingress$=this.ingressSubject.asObservable(),this.recording$=this.recordingSubject.asObservable(),this.session$=this.sessionSubject.asObservable(),this.settings$=this.settingsSubject.asObservable(),this.transcribing$=this.transcribingSubject.asObservable(),this.endedBy$=this.endedBySubject.asObservable(),this.thumbnails$=this.thumbnailsSubject.asObservable(),this.eventHandlers={"call.permission_request":void 0,"call.recording_failed":void 0,"call.recording_ready":void 0,"call.user_muted":void 0,"connection.error":void 0,"connection.ok":void 0,"health.check":void 0,custom:void 0,"call.accepted":e=>this.updateFromCallResponse(e.call),"call.blocked_user":this.blockUser,"call.created":e=>this.updateFromCallResponse(e.call),"call.ended":e=>{this.updateFromCallResponse(e.call),this.setCurrentValue(this.endedBySubject,e.user)},"call.hls_broadcasting_failed":this.updateFromHLSBroadcastingFailed,"call.hls_broadcasting_started":this.updateFromHLSBroadcastStarted,"call.hls_broadcasting_stopped":this.updateFromHLSBroadcastStopped,"call.live_started":e=>this.updateFromCallResponse(e.call),"call.member_added":this.updateFromMemberAdded,"call.member_removed":this.updateFromMemberRemoved,"call.member_updated_permission":this.updateMembers,"call.member_updated":this.updateMembers,"call.notification":e=>{this.updateFromCallResponse(e.call),this.setMembers(e.members)},"call.permissions_updated":this.updateOwnCapabilities,"call.reaction_new":this.updateParticipantReaction,"call.recording_started":()=>this.setCurrentValue(this.recordingSubject,!0),"call.recording_stopped":()=>this.setCurrentValue(this.recordingSubject,!1),"call.rejected":e=>this.updateFromCallResponse(e.call),"call.ring":e=>this.updateFromCallResponse(e.call),"call.session_ended":e=>this.updateFromCallResponse(e.call),"call.session_participant_joined":this.updateFromSessionParticipantJoined,"call.session_participant_left":this.updateFromSessionParticipantLeft,"call.session_started":e=>this.updateFromCallResponse(e.call),"call.unblocked_user":this.unblockUser,"call.updated":e=>this.updateFromCallResponse(e.call)}}}let nx=e=>async function(t){if("call.accepted"!==t.type||t.user.id===e.currentUserId)return;let{state:i}=e;i.callingState===O.RINGING&&await e.join()},nH=e=>async function(t){if("call.rejected"!==t.type||t.user.id===e.currentUserId)return;let{call:i}=t,{session:n}=i;if(!n){e.logger("warn","No call session provided. Ignoring call.rejected event.",t);return}let a=n.rejected_by,{members:s,callingState:r}=e.state;if(r!==O.RINGING){e.logger("warn","Call is not in ringing mode (it is either accepted or rejected already). Ignoring call.rejected event.",t);return}e.isCreatedByMe?s.filter(t=>t.user_id!==e.currentUserId).every(e=>a[e.user_id])&&(e.logger("info","everyone rejected, leaving the call"),await e.leave()):a[i.created_by.id]&&(e.logger("info","call creator rejected, leaving call"),await e.leave())},nz=e=>async function(t){if("call.ended"!==t.type)return;let{callingState:i}=e.state;(i===O.RINGING||i===O.JOINED||i===O.JOINING)&&await e.leave()},nq=e=>function(t){if("callGrantsUpdated"!==t.eventPayload.oneofKind)return;let{currentGrants:i}=t.eventPayload.callGrantsUpdated;if(i){let{canPublishAudio:t,canPublishVideo:n,canScreenshare:a}=i,s={[ey.SEND_AUDIO]:t,[ey.SEND_VIDEO]:n,[ey.SCREENSHARE]:a},r=e.ownCapabilities.filter(e=>!1!==s[e]);Object.entries(s).forEach(e=>{let[t,i]=e;i&&!r.includes(t)&&r.push(t)}),e.setOwnCapabilities(r)}},nK=iL(["events"]),nJ=(e,t)=>e.on("changePublishQuality",e=>{if("changePublishQuality"!==e.eventPayload.oneofKind)return;let{videoSenders:i}=e.eventPayload.changePublishQuality;i.forEach(e=>{let{layers:i}=e;t.updatePublishQuality(i.filter(e=>e.active))})}),nG=(e,t)=>e.on("connectionQualityChanged",e=>{if("connectionQualityChanged"!==e.eventPayload.oneofKind)return;let{connectionQualityChanged:i}=e.eventPayload,{connectionQualityUpdates:n}=i;n&&t.updateParticipants(n.reduce((e,t)=>{let{sessionId:i,connectionQuality:n}=t;return e[i]={connectionQuality:n},e},{}))}),n$=(e,t)=>e.on("healthCheckResponse",e=>{if("healthCheckResponse"!==e.eventPayload.oneofKind)return;let{participantCount:i}=e.eventPayload.healthCheckResponse;i&&(t.setParticipantCount(i.total),t.setAnonymousParticipantCount(i.anonymous))}),nQ=(e,t)=>e.on("error",e=>{"error"===e.eventPayload.oneofKind&&e.eventPayload.error.error&&e.eventPayload.error.error.code===E.LIVE_ENDED&&!t.permissionsContext.hasPermission(ey.JOIN_BACKSTAGE)&&t.leave()}),nX=e=>e.on("error",e=>{if("error"!==e.eventPayload.oneofKind||!e.eventPayload.error.error)return;let t=e.eventPayload.error.error;nK("error","SFU reported error",{code:E[t.code],message:t.message,shouldRetry:t.shouldRetry})}),nY=e=>function(t){if("pinsUpdated"!==t.eventPayload.oneofKind)return;let{pins:i}=t.eventPayload.pinsUpdated;e.setServerSidePins(i)},nZ=e=>e.on("trackUnpublished",async t=>{if("trackUnpublished"!==t.eventPayload.oneofKind)return;let{trackUnpublished:{cause:i,type:n,sessionId:a}}=t.eventPayload,{localParticipant:s}=e.state;if(i===_.MODERATION&&a===(null==s?void 0:s.sessionId)){let t=e.logger;t("info","Local participant's ".concat(R[n]," track is muted remotely"));try{var r;n===R.VIDEO?await e.camera.disable():n===R.AUDIO?await e.microphone.disable():t("warn","Unsupported track type to soft mute",R[n]),(null===(r=e.publisher)||void 0===r?void 0:r.isPublishing(n))&&await e.stopPublish(n)}catch(e){t("error","Failed to stop publishing",e)}}}),n0=e=>function(t){if("participantJoined"!==t.eventPayload.oneofKind)return;let{participant:i}=t.eventPayload.participantJoined;i&&e.updateOrAddParticipant(i.sessionId,Object.assign(i,{viewportVisibilityState:{videoTrack:N.UNKNOWN,screenShareTrack:N.UNKNOWN}}))},n1=e=>function(t){if("participantLeft"!==t.eventPayload.oneofKind)return;let{participant:i}=t.eventPayload.participantLeft;i&&e.setParticipants(e=>e.filter(e=>e.sessionId!==i.sessionId))},n2=e=>function(t){if("trackPublished"!==t.eventPayload.oneofKind)return;let{trackPublished:{type:i,sessionId:n,participant:a}}=t.eventPayload;a?e.updateOrAddParticipant(n,a):e.updateParticipant(n,e=>({publishedTracks:[...e.publishedTracks,i].filter(n9)}))},n3=e=>function(t){if("trackUnpublished"!==t.eventPayload.oneofKind)return;let{trackUnpublished:{type:i,sessionId:n,participant:a}}=t.eventPayload;a?e.updateOrAddParticipant(n,a):e.updateParticipant(n,e=>({publishedTracks:e.publishedTracks.filter(e=>e!==i)}))},n9=(e,t,i)=>i.indexOf(e)===t,n4=(e,t)=>e.on("dominantSpeakerChanged",e=>{var i;if("dominantSpeakerChanged"!==e.eventPayload.oneofKind)return;let{dominantSpeakerChanged:{sessionId:n}}=e.eventPayload;n!==(null===(i=t.dominantSpeaker)||void 0===i?void 0:i.sessionId)&&t.setParticipants(e=>e.map(e=>e.sessionId===n?{...e,isDominantSpeaker:!0}:e.isDominantSpeaker?{...e,isDominantSpeaker:!1}:e))}),n5=(e,t)=>e.on("audioLevelChanged",e=>{if("audioLevelChanged"!==e.eventPayload.oneofKind)return;let{audioLevels:i}=e.eventPayload.audioLevelChanged;t.updateParticipants(i.reduce((e,t)=>(e[t.sessionId]={audioLevel:t.level,isSpeaking:t.isSpeaking},e),{}))}),n6=(e,t,i)=>{let n=[e.on("call.ended",nz(e)),nQ(i,e),nX(i),nJ(i,e),nG(i,t),n$(i,t),e.on("participantJoined",n0(t)),e.on("participantLeft",n1(t)),e.on("trackPublished",n2(t)),e.on("trackUnpublished",n3(t)),n5(i,t),n4(i,t),e.on("callGrantsUpdated",nq(t)),e.on("pinsUpdated",nY(t)),nZ(e)];return e.ringing&&n.push(n8(e)),()=>{n.forEach(e=>e())}},n8=e=>{let t={"call.accepted":nx(e),"call.rejected":nH(e)},i=Object.keys(t).map(i=>e.on(i,t[i]));return()=>{i.forEach(e=>e())}},n7=async(e,t,i,n)=>{let{call:a,credentials:s,members:r,own_capabilities:o}=await ae(e,t,i,n);return{connectionConfig:at(s.ice_servers),sfuServer:s.server,token:s.token,metadata:a,members:r,ownCapabilities:o}},ae=async(e,t,i,n)=>{let a=await e.getLocationHint(),s={...n,location:a},r=ai();return r?((null==n?void 0:n.migrating_from)&&r.next_sfu_id&&(r.sfu_id=r.next_sfu_id),e.doAxiosRequest("post","/call/".concat(t,"/").concat(i,"/join"),s,{params:{...r}})):e.post("/call/".concat(t,"/").concat(i,"/join"),s)},at=e=>{if(e&&0!==e.length)return{iceServers:e.map(e=>({urls:e.urls,username:e.username,credential:e.password}))}},ai=()=>{var e;if("undefined"==typeof window)return null;let t=new URLSearchParams(null===(e=window.location)||void 0===e?void 0:e.search);if(null!==t.get("cascading")){let e={};return t.forEach((t,i)=>{e[i]=t}),e}return null},an=(e,t)=>(t&&(Object.assign(e,t),iI(t)&&iI(e)&&(e.audioDeviceId=t.audioDeviceId,e.videoDeviceId=t.videoDeviceId,e.audioOutputDeviceId=t.audioOutputDeviceId)),e),aa=e=>{let t,{subscriber:i,publisher:n,state:a,pollingIntervalInMs:s=2e3}=e,r=iL(["stats"]),o=async(e,t)=>"subscriber"===e&&i?i.getStats(t):"publisher"===e&&n?n.getStats(t):void r("warn","Can't retrieve RTC stats for ".concat(e)),l=async(e,t)=>{let a="subscriber"===e?i:n,s=[];for(let i of t.getTracks()){let t=as(await a.getStats(i),{trackKind:i.kind,kind:e});s.push(t)}return s},c=new Set,d=async()=>{let e={},t=new Set(c);if(t.size>0)for(let i of a.participants){if(!t.has(i.sessionId))continue;let n=i.isLocalParticipant?"publisher":"subscriber";try{var s,d;let t=new MediaStream([...(null===(s=i.videoStream)||void 0===s?void 0:s.getVideoTracks())||[],...(null===(d=i.audioStream)||void 0===d?void 0:d.getAudioTracks())||[]]);e[i.sessionId]=await l(n,t),t.getTracks().forEach(e=>{t.removeTrack(e)})}catch(e){r("error","Failed to collect stats for ".concat(n," if ").concat(i.userId),e)}}let[h,u]=await Promise.all([i.getStats().then(e=>as(e,{kind:"subscriber",trackKind:"video"})).then(ar),n.getStats().then(e=>as(e,{kind:"publisher",trackKind:"video"})).then(ar)]),[p,g]=await Promise.all([o("subscriber"),o("publisher")]);a.setCallStatsReport({datacenter:n.sfuClient.edgeName,publisherStats:u,subscriberStats:h,subscriberRawStats:p,publisherRawStats:g,participants:e,timestamp:Date.now()})};if(s>0){let e=async()=>{await d().catch(e=>{r("debug","Failed to collect stats",e)}),t=setTimeout(e,s)};e()}return{getRawStatsForTrack:o,getStatsForStream:l,startReportingStatsFor:e=>{c.add(e),d()},stopReportingStatsFor:e=>{c.delete(e),d()},stop:()=>{t&&clearTimeout(t)}}},as=(e,t)=>{let{trackKind:i,kind:n}=t,a="subscriber"===n?"inbound-rtp":"outbound-rtp",s=ao(e);return{rawStats:e,streams:s.filter(e=>e.type===a&&e.kind===i).map(e=>{let t;let i=s.find(t=>"codec"===t.type&&t.id===e.codecId),n=s.find(t=>"transport"===t.type&&t.id===e.transportId);if(n&&"connected"===n.dtlsState){let e=s.find(e=>"candidate-pair"===e.type&&e.id===n.selectedCandidatePairId);t=null==e?void 0:e.currentRoundTripTime}return{bytesSent:e.bytesSent,bytesReceived:e.bytesReceived,codec:null==i?void 0:i.mimeType,currentRoundTripTime:t,frameHeight:e.frameHeight,frameWidth:e.frameWidth,framesPerSecond:e.framesPerSecond,jitter:e.jitter,kind:e.kind,qualityLimitationReason:e.qualityLimitationReason,rid:e.rid,ssrc:e.ssrc}}),timestamp:Date.now()}},ar=e=>{let t={rawReport:e,totalBytesSent:0,totalBytesReceived:0,averageJitterInMs:0,averageRoundTripTimeInMs:0,qualityLimitationReasons:"none",highestFrameWidth:0,highestFrameHeight:0,highestFramesPerSecond:0,timestamp:Date.now()},i=-1,n=(e,t)=>e*t,a=new Set,s=e.streams,r=s.reduce((e,t)=>{e.totalBytesSent+=t.bytesSent||0,e.totalBytesReceived+=t.bytesReceived||0,e.averageJitterInMs+=t.jitter||0,e.averageRoundTripTimeInMs+=t.currentRoundTripTime||0;let s=n(t.frameWidth||0,t.frameHeight||0);return s>i&&(e.highestFrameWidth=t.frameWidth||0,e.highestFrameHeight=t.frameHeight||0,e.highestFramesPerSecond=t.framesPerSecond||0,i=s),a.add(t.qualityLimitationReason||""),e},t);s.length>0&&(r.averageJitterInMs=Math.round(r.averageJitterInMs/s.length*1e3),r.averageRoundTripTimeInMs=Math.round(r.averageRoundTripTimeInMs/s.length*1e3));let o=[a.has("cpu")&&"cpu",a.has("bandwidth")&&"bandwidth",a.has("other")&&"other"].filter(Boolean).join(", ");return o&&(r.qualityLimitationReasons=o),r},ao=e=>{let t=[];return e.forEach(e=>{t.push(e)}),t};class al{constructor(){this.elementHandlerMap=new Map,this.observer=null,this.queueSet=new Set,this.setViewport=(e,t)=>{var i;return this.observer=new IntersectionObserver(e=>{e.forEach(e=>{let t=this.elementHandlerMap.get(e.target);null==t||t(e)})},{root:e,...t,threshold:null!==(i=null==t?void 0:t.threshold)&&void 0!==i?i:.35}),this.queueSet.size&&(this.queueSet.forEach(t=>{let[i,n]=t;e.contains(i)&&(this.observer.observe(i),this.elementHandlerMap.set(i,n))}),this.queueSet.clear()),()=>{var e;null===(e=this.observer)||void 0===e||e.disconnect(),this.observer=null,this.elementHandlerMap.clear()}},this.observe=(e,t)=>{let i=[e,t];return this.elementHandlerMap.has(e)||(this.observer?this.observer.root.contains(e)&&(this.elementHandlerMap.set(e,t),this.observer.observe(e)):this.queueSet.add(i)),()=>{var t;this.elementHandlerMap.delete(e),null===(t=this.observer)||void 0===t||t.unobserve(e),this.queueSet.delete(i)}}}}let ac=()=>"undefined"!=typeof navigator&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent||""),ad=()=>{var e;return"undefined"!=typeof navigator&&(null===(e=navigator.userAgent)||void 0===e?void 0:e.includes("Firefox"))};var ah=Object.freeze({__proto__:null,isChrome:()=>{var e;return"undefined"!=typeof navigator&&(null===(e=navigator.userAgent)||void 0===e?void 0:e.includes("Chrome"))},isFirefox:ad,isSafari:ac});let au={videoTrack:N.UNKNOWN,screenShareTrack:N.UNKNOWN};class ap{constructor(e){this.viewportTracker=new al,this.logger=iL(["DynascaleManager"]),this.trackElementVisibility=(e,t,i)=>{let n=this.viewportTracker.observe(e,n=>{this.call.state.updateParticipant(t,t=>{var a;let s=null!==(a=t.viewportVisibilityState)&&void 0!==a?a:au,r=n.isIntersecting||document.fullscreenElement===e?N.VISIBLE:N.INVISIBLE;return{...t,viewportVisibilityState:{...s,[i]:r}}})});return()=>{n(),this.call.state.updateParticipant(t,e=>{var t;let n=null!==(t=e.viewportVisibilityState)&&void 0!==t?t:au;return{...e,viewportVisibilityState:{...n,[i]:N.UNKNOWN}}})}},this.setViewport=e=>this.viewportTracker.setViewport(e),this.bindVideoElement=(e,t,i)=>{let n,a;let s=this.call.state.findParticipantBySessionId(t);if(!s)return;let r=(e,n)=>{n&&(0===n.width||0===n.height)&&(this.logger("debug","Ignoring 0x0 dimension",s),n=void 0),this.call.updateSubscriptionsPartial(i,{[t]:{dimension:n}},e)},o=this.call.state.participants$.pipe((0,Q.U)(e=>e.find(e=>e.sessionId===t)),(0,Z.o)(e=>!!e),(0,Y.x)(),(0,X.d)({bufferSize:1,refCount:!0})),l=s.isLocalParticipant?null:o.pipe((0,Q.U)(e=>{var t;return null===(t=e.viewportVisibilityState)||void 0===t?void 0:t[i]}),(0,Y.x)()).subscribe(t=>{if(!n){n=null!=t?t:N.UNKNOWN;return}if(n=null!=t?t:N.UNKNOWN,t===N.INVISIBLE)return r(A.MEDIUM,void 0);r(A.MEDIUM,{width:e.clientWidth,height:e.clientHeight})}),c=s.isLocalParticipant?null:new ResizeObserver(()=>{let t="".concat(e.clientWidth,",").concat(e.clientHeight);if(!a){a=t;return}a!==t&&n!==N.INVISIBLE&&(r(A.SLOW,{width:e.clientWidth,height:e.clientHeight}),a=t)});null==c||c.observe(e);let d=s.isLocalParticipant?null:o.pipe((0,ee.g)("publishedTracks"),(0,Q.U)(e=>e.publishedTracks.includes("videoTrack"===i?R.VIDEO:R.SCREEN_SHARE)),(0,Y.x)()).subscribe(t=>{t?r(A.FAST,{width:e.clientWidth,height:e.clientHeight}):r(A.FAST,void 0)});e.autoplay=!0,e.playsInline=!0,e.muted=!0;let h=o.pipe((0,ee.g)("videoTrack"===i?"videoStream":"screenShareStream")).subscribe(t=>{let n="videoTrack"===i?t.videoStream:t.screenShareStream;e.srcObject!==n&&(e.srcObject=null!=n?n:null,(ac()||ad())&&setTimeout(()=>{e.srcObject=null!=n?n:null,e.play().catch(e=>{this.logger("warn","Failed to play stream",e)})},25))});return()=>{r(A.FAST,void 0),null==l||l.unsubscribe(),null==d||d.unsubscribe(),h.unsubscribe(),null==c||c.disconnect()}},this.bindAudioElement=(e,t,i)=>{let n=this.call.state.findParticipantBySessionId(t);if(!n||n.isLocalParticipant)return;let a=this.call.state.participants$.pipe((0,Q.U)(e=>e.find(e=>e.sessionId===t)),(0,Z.o)(e=>!!e),(0,Y.x)(),(0,X.d)({bufferSize:1,refCount:!0})).pipe((0,ee.g)("screenShareAudioTrack"===i?"screenShareAudioStream":"audioStream")).subscribe(t=>{let n="screenShareAudioTrack"===i?t.screenShareAudioStream:t.audioStream;e.srcObject!==n&&setTimeout(()=>{e.srcObject=null!=n?n:null,e.srcObject&&e.play().catch(e=>{this.logger("warn","Failed to play stream",e)})})}),s=(0,G.a)([this.call.state.localParticipant$,this.call.speaker.state.selectedDevice$]).subscribe(t=>{var i;let[n,a]=t,s=(null===(i=iq())||void 0===i?void 0:i.type)===D.REACT?null==n?void 0:n.audioOutputDeviceId:a;"setSinkId"in e&&"string"==typeof s&&e.setSinkId(s)}),r=this.call.speaker.state.volume$.subscribe(t=>{e.volume=t});return e.autoplay=!0,()=>{s.unsubscribe(),r.unsubscribe(),a.unsubscribe()}},this.call=e}}class ag{constructor(){this.permissions=[],this.setPermissions=e=>{this.permissions=e||[]},this.setCallSettings=e=>{this.settings=e},this.hasPermission=e=>this.permissions.includes(e),this.canRequest=e=>{if(!this.settings)return!1;let{audio:t,video:i,screensharing:n}=this.settings;switch(e){case ey.SEND_AUDIO:return t.access_request_enabled;case ey.SEND_VIDEO:return i.access_request_enabled;case ey.SCREENSHARE:return n.access_request_enabled;default:return!1}}}}class am{constructor(e,t={sortParticipantsBy:nF}){this.name=e,this.options=t}}class af{constructor(e){this.register=e=>{this.callTypes[e.name]=e},this.unregister=e=>{delete this.callTypes[e]},this.get=e=>(this.callTypes[e]||this.register(new am(e)),this.callTypes[e]),this.callTypes=e.reduce((e,t)=>(e[t.name]=t,e),{})}}let ay=new af([new am("default",{sortParticipantsBy:nF}),new am("development",{sortParticipantsBy:nF}),new am("livestream",{sortParticipantsBy:nV}),new am("audio_room",{sortParticipantsBy:nV})]),ab=e=>new et.y(t=>{navigator.mediaDevices.getUserMedia(e).then(e=>{navigator.mediaDevices.enumerateDevices().then(i=>{t.next(i),aV(e),t.complete()})}).catch(e=>{iL(["devices"])("error","Failed to get devices",e),t.error(e)})}),av=()=>"undefined"!=typeof document&&void 0!==document.createElement("audio").sinkId,ak={audio:{autoGainControl:!0,noiseSuppression:!0,echoCancellation:!0}},aw={video:{width:1280,height:720}},aT=e=>{let t;return()=>(t||(t=e()),t)},aC=aT(()=>new et.y(e=>{if(!navigator.mediaDevices.addEventListener)return;let t=()=>e.next();return navigator.mediaDevices.addEventListener("devicechange",t),()=>{navigator.mediaDevices.removeEventListener("devicechange",t)}}).pipe((0,ei.b)(500),(0,en.b)(()=>(0,ea.D)(navigator.mediaDevices.enumerateDevices())),(0,X.d)(1))),aS=aT(()=>(0,es.T)(ab(ak),aC()).pipe((0,X.d)(1))),aI=aT(()=>(0,es.T)(ab(aw),aC()).pipe((0,X.d)(1))),aR=()=>aS().pipe((0,Q.U)(e=>e.filter(e=>"audioinput"===e.kind))),aE=()=>aI().pipe((0,Q.U)(e=>e.filter(e=>"videoinput"===e.kind))),aD=()=>aS().pipe((0,Q.U)(e=>e.filter(e=>"audiooutput"===e.kind))),a_=async e=>{try{return await navigator.mediaDevices.getUserMedia(e)}catch(t){throw iL(["devices"])("error","Failed get user media",{error:t,constraints:e}),t}},aP=async e=>a_({audio:{...ak.audio,...e}}),aU=async e=>a_({video:{...aw.video,...e}}),aN=async e=>{try{return await navigator.mediaDevices.getDisplayMedia({video:!0,audio:{channelCount:{ideal:2},echoCancellation:!1,autoGainControl:!1,noiseSuppression:!1},systemAudio:"include",...e})}catch(e){throw iL(["devices"])("error","Failed to get screen share stream",e),e}},aA=(e,t)=>{let i;switch(e){case"audioinput":i=aR();break;case"videoinput":i=aE();break;case"audiooutput":i=aD()}return(0,G.a)([i,t]).pipe((0,er.h)(e=>{let[t,i]=e;return!!i&&!t.find(e=>e.deviceId===i)}),(0,Q.U)(()=>!0))},aO=e=>aA("audioinput",e),aL=e=>aA("videoinput",e),aB=e=>aA("audiooutput",e),aj=e=>{let t;switch(e){case"audioinput":t=aR();break;case"videoinput":t=aE();break;case"audiooutput":t=aD();break;default:throw Error("Unknown MediaDeviceKind",e)}return t.pipe((0,eo.G)(),(0,er.h)(e=>{let[t,i]=e,n=t.find(e=>"default"===e.deviceId),a=i.find(e=>"default"===e.deviceId);return!!(i.length>t.length&&n&&a&&n.groupId!==a.groupId)}),(0,Q.U)(()=>!0))},aF=()=>aj("audioinput"),aW=()=>aj("videoinput"),aV=e=>{e.active&&(e.getTracks().forEach(t=>{t.stop(),e.removeTrack(t)}),"function"==typeof e.release&&e.release())};class aM{listDevices(){return this.getDevices()}async enable(){if("enabled"!==this.state.status){this.enablePromise=this.unmuteStream();try{await this.enablePromise,this.state.setStatus("enabled")}catch(e){throw this.enablePromise=void 0,e}}}async disable(){if(this.state.prevStatus=this.state.status,"disabled"!==this.state.status){this.disablePromise=this.muteStream("stop-tracks"===this.state.disableMode);try{await this.disablePromise,this.state.setStatus("disabled"),this.disablePromise=void 0}catch(e){throw this.disablePromise=void 0,e}}}async resume(){"enabled"===this.state.prevStatus&&"disabled"===this.state.status&&await this.enable()}async toggle(){return"enabled"===this.state.status?this.disable():this.enable()}async setDefaultConstraints(e){this.state.setDefaultConstraints(e)}async select(e){if(iH())throw Error("This method is not supported in React Native");e!==this.state.selectedDevice&&(this.state.setDevice(e),await this.applySettingsToStream())}async applySettingsToStream(){"enabled"===this.state.status&&(await this.muteStream(),await this.unmuteStream())}getTracks(){var e,t;return null!==(t=null===(e=this.state.mediaStream)||void 0===e?void 0:e.getTracks())&&void 0!==t?t:[]}async muteStream(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];this.state.mediaStream&&(this.logger("debug","".concat(e?"Stopping":"Disabling"," stream")),this.call.state.callingState===O.JOINED&&await this.stopPublishStream(e),this.muteLocalStream(e),this.getTracks().forEach(e=>{"ended"===e.readyState&&("function"==typeof this.state.mediaStream.release&&this.state.mediaStream.release(),this.state.setMediaStream(void 0))}))}muteTracks(){this.getTracks().forEach(e=>{e.enabled&&(e.enabled=!1)})}unmuteTracks(){this.getTracks().forEach(e=>{e.enabled||(e.enabled=!0)})}stopTracks(){this.getTracks().forEach(e=>{"live"===e.readyState&&e.stop()})}muteLocalStream(e){this.state.mediaStream&&(e?this.stopTracks():this.muteTracks())}async unmuteStream(){let e;if(this.logger("debug","Starting stream"),this.state.mediaStream&&this.getTracks().every(e=>"live"===e.readyState))e=this.state.mediaStream,this.unmuteTracks();else{this.state.mediaStream&&this.stopTracks();let t={...this.state.defaultConstraints,deviceId:this.state.selectedDevice};e=await this.getStream(t)}this.call.state.callingState===O.JOINED&&await this.publishStream(e),this.state.mediaStream!==e&&this.state.setMediaStream(e)}constructor(e,t,i){this.call=e,this.state=t,this.trackType=i,this.logger=iL(["".concat(R[i].toLowerCase()," manager")])}}class ax{get status(){return this.getCurrentValue(this.status$)}get selectedDevice(){return this.getCurrentValue(this.selectedDevice$)}get mediaStream(){return this.getCurrentValue(this.mediaStream$)}setStatus(e){this.setCurrentValue(this.statusSubject,e)}setMediaStream(e){this.setCurrentValue(this.mediaStreamSubject,e),e&&this.setDevice(this.getDeviceIdFromStream(e))}setDevice(e){this.setCurrentValue(this.selectedDeviceSubject,e)}get defaultConstraints(){return this.getCurrentValue(this.defaultConstraints$)}setDefaultConstraints(e){this.setCurrentValue(this.defaultConstraintsSubject,e)}constructor(e="stop-tracks"){this.disableMode=e,this.statusSubject=new $.X(void 0),this.mediaStreamSubject=new $.X(void 0),this.selectedDeviceSubject=new $.X(void 0),this.defaultConstraintsSubject=new $.X(void 0),this.mediaStream$=this.mediaStreamSubject.asObservable(),this.selectedDevice$=this.selectedDeviceSubject.asObservable().pipe((0,Y.x)()),this.status$=this.statusSubject.asObservable().pipe((0,Y.x)()),this.defaultConstraints$=this.defaultConstraintsSubject.asObservable(),this.getCurrentValue=ny,this.setCurrentValue=nb}}class aH extends ax{get direction(){return this.getCurrentValue(this.direction$)}setDirection(e){this.setCurrentValue(this.directionSubject,e)}setMediaStream(e){if(super.setMediaStream(e),e){var t;let i=iH()?this.direction:(null===(t=e.getVideoTracks()[0])||void 0===t?void 0:t.getSettings().facingMode)==="environment"?"back":"front";this.setDirection(i)}}getDeviceIdFromStream(e){var t;return null===(t=e.getVideoTracks()[0])||void 0===t?void 0:t.getSettings().deviceId}constructor(){super("stop-tracks"),this.directionSubject=new $.X(void 0),this.direction$=this.directionSubject.asObservable().pipe((0,Y.x)())}}class az extends aM{async selectDirection(e){this.state.setDirection(e),this.state.setDevice(void 0),await this.applySettingsToStream()}async flip(){let e="front"===this.state.direction?"back":"front";await this.selectDirection(e)}async selectTargetResolution(e){if(this.targetResolution.height=e.height,this.targetResolution.width=e.width,this.enablePromise)try{await this.enablePromise}catch(e){}if("enabled"===this.state.status){var t;let{width:e,height:i}=null===(t=this.state.mediaStream.getVideoTracks()[0])||void 0===t?void 0:t.getSettings();(e!==this.targetResolution.width||i!==this.targetResolution.height)&&await this.applySettingsToStream(),this.logger("debug","".concat(e,"x").concat(i," target resolution applied to media stream"))}}getDevices(){return aE()}getStream(e){return e.width=this.targetResolution.width,e.height=this.targetResolution.height,!e.deviceId&&this.state.direction&&(e.facingMode="front"===this.state.direction?"user":"environment"),aU(e)}publishStream(e){return this.call.publishVideoStream(e)}stopPublishStream(e){return this.call.stopPublish(R.VIDEO,e)}constructor(e){super(e,new aH,R.VIDEO),this.targetResolution={width:1280,height:720}}}class aq extends ax{get speakingWhileMuted(){return this.getCurrentValue(this.speakingWhileMuted$)}setSpeakingWhileMuted(e){this.setCurrentValue(this.speakingWhileMutedSubject,e)}getDeviceIdFromStream(e){var t;return null===(t=e.getAudioTracks()[0])||void 0===t?void 0:t.getSettings().deviceId}constructor(){super("disable-tracks"),this.speakingWhileMutedSubject=new $.X(!1),this.speakingWhileMuted$=this.speakingWhileMutedSubject.asObservable().pipe((0,Y.x)())}}let aK=function(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{detectionFrequencyInMs:n=500,audioLevelThreshold:a=150,fftSize:s=128,destroyStreamOnStop:r=!0}=i,o=new AudioContext,l=o.createAnalyser();l.fftSize=s;let c=o.createMediaStreamSource(e);c.connect(l);let d=setInterval(()=>{var i;let n=new Uint8Array(l.frequencyBinCount);l.getByteFrequencyData(n);let s=n.some(e=>e>=a),r=n.reduce((e,t)=>e+t,0)/n.length;(null===(i=e.getAudioTracks()[0])||void 0===i?void 0:i.enabled)?t({isSoundDetected:s,audioLevel:r>a?100:Math.round(r/a*100)}):t({isSoundDetected:!1,audioLevel:0})},n);return async function(){clearInterval(d),c.disconnect(),l.disconnect(),await o.close(),r&&e.getTracks().forEach(t=>{t.stop(),e.removeTrack(t)})}};class aJ extends aM{getDevices(){return aR()}getStream(e){return aP(e)}publishStream(e){return this.call.publishAudioStream(e)}stopPublishStream(e){return this.call.stopPublish(R.AUDIO,e)}async startSpeakingWhileMutedDetection(e){if(iH())return;await this.stopSpeakingWhileMutedDetection();let t=await this.getStream({deviceId:e});this.soundDetectorCleanup=aK(t,e=>{this.state.setSpeakingWhileMuted(e.isSoundDetected)})}async stopSpeakingWhileMutedDetection(){if(!iH()&&this.soundDetectorCleanup){this.state.setSpeakingWhileMuted(!1);try{await this.soundDetectorCleanup()}finally{this.soundDetectorCleanup=void 0}}}constructor(e){super(e,new aq,R.AUDIO),(0,G.a)([this.call.state.callingState$,this.call.state.ownCapabilities$,this.state.selectedDevice$,this.state.status$]).subscribe(async e=>{let[t,i,n,a]=e;if(t!==O.JOINED){t===O.LEFT&&await this.stopSpeakingWhileMutedDetection();return}i.includes(ey.SEND_AUDIO)&&"disabled"===a?await this.startSpeakingWhileMutedDetection(n):await this.stopSpeakingWhileMutedDetection()})}}class aG extends ax{get audioEnabled(){return this.getCurrentValue(this.audioEnabled$)}setAudioEnabled(e){this.setCurrentValue(this.audioEnabledSubject,e)}get settings(){return this.getCurrentValue(this.settings$)}setSettings(e){this.setCurrentValue(this.settingsSubject,e)}constructor(){super(...arguments),this.audioEnabledSubject=new $.X(!0),this.settingsSubject=new $.X(void 0),this.audioEnabled$=this.audioEnabledSubject.asObservable().pipe((0,Y.x)()),this.settings$=this.settingsSubject.asObservable(),this.getDeviceIdFromStream=e=>{let[t]=e.getTracks();return null==t?void 0:t.getSettings().deviceId}}}class a$ extends aM{enableScreenShareAudio(){this.state.setAudioEnabled(!0)}async disableScreenShareAudio(){var e;this.state.setAudioEnabled(!1),(null===(e=this.call.publisher)||void 0===e?void 0:e.isPublishing(R.SCREEN_SHARE_AUDIO))&&await this.call.stopPublish(R.SCREEN_SHARE_AUDIO,!0)}getSettings(){return this.state.settings}setSettings(e){this.state.setSettings(e)}getDevices(){return(0,el.of)([])}getStream(e){return this.state.audioEnabled||(e.audio=!1),aN(e)}publishStream(e){return this.call.publishScreenShareStream(e,{screenShareSettings:this.state.settings})}async stopPublishStream(e){await this.call.stopPublish(R.SCREEN_SHARE,e),await this.call.stopPublish(R.SCREEN_SHARE_AUDIO,e)}async select(e){throw Error("This method is not supported in for Screen Share")}constructor(e){super(e,new aG,R.SCREEN_SHARE)}}class aQ{get selectedDevice(){return this.getCurrentValue(this.selectedDevice$)}get volume(){return this.getCurrentValue(this.volume$)}setDevice(e){this.setCurrentValue(this.selectedDeviceSubject,e)}setVolume(e){this.setCurrentValue(this.volumeSubject,e)}constructor(){this.selectedDeviceSubject=new $.X(""),this.volumeSubject=new $.X(1),this.isDeviceSelectionSupported=av(),this.getCurrentValue=ny,this.setCurrentValue=nb,this.selectedDevice$=this.selectedDeviceSubject.asObservable().pipe((0,Y.x)()),this.volume$=this.volumeSubject.asObservable().pipe((0,Y.x)())}}class aX{listDevices(){return aD()}select(e){if(iH())throw Error("This feature is not supported in React Native");this.state.setDevice(e)}setVolume(e){if(iH())throw Error("This feature is not supported in React Native");if(e&&(e<0||e>1))throw Error("Volume must be between 0 and 1");this.state.setVolume(e)}constructor(){this.state=new aQ}}class aY{registerEffects(){this.leaveCallHooks.add(nv(this.state.settings$,e=>{e&&this.permissionsContext.setCallSettings(e)})),this.leaveCallHooks.add(nv(this.state.ownCapabilities$,e=>{if(this.permissionsContext.setPermissions(e),this.publisher)for(let[e,t]of Object.entries({[ey.SEND_AUDIO]:R.AUDIO,[ey.SEND_VIDEO]:R.VIDEO,[ey.SCREENSHARE]:R.SCREEN_SHARE}))!this.permissionsContext.hasPermission(e)&&(this.publisher.isPublishing(t)||this.publisher.isLive(t))&&this.stopPublish(t).catch(e=>{this.logger("error","Error stopping publish ".concat(t),e)}).then(()=>{t===R.VIDEO&&"enabled"===this.camera.state.status&&this.camera.disable().catch(e=>this.logger("error","Error disabling camera after pemission revoked",e)),t===R.AUDIO&&"enabled"===this.microphone.state.status&&this.microphone.disable().catch(e=>this.logger("error","Error disabling microphone after pemission revoked",e))})})),this.leaveCallHooks.add(nv(this.state.blockedUserIds$,async e=>{if(!e||0===e.length)return;let t=this.currentUserId;t&&e.includes(t)&&(this.logger("info","Leaving call because of being blocked"),await this.leave())})),this.leaveCallHooks.add(nv(this.state.callingState$,e=>{this.ringing&&(e===O.JOINED||e===O.JOINING||e===O.LEFT)&&(clearTimeout(this.dropTimeout),this.dropTimeout=void 0)})),this.leaveCallHooks.add(nv(this.ringingSubject,e=>{e&&(this.scheduleAutoDrop(),this.state.callingState===O.IDLE&&this.state.setCallingState(O.RINGING),this.leaveCallHooks.add(n8(this)))}))}on(e,t){if(iW(e))return this.dispatcher.on(e,t);{let i=e=>{e.call_cid&&e.call_cid===this.cid&&t(e)};return this.streamClientEventHandlers.set(t,i),this.streamClient.on(e,i)}}off(e,t){if(iW(e))return this.dispatcher.off(e,t);{let i=this.streamClientEventHandlers.get(t);if(i)return this.streamClient.off(e,i)}}get ringing(){return ny(this.ringingSubject)}get currentUserId(){var e;return null===(e=this.clientStore.connectedUser)||void 0===e?void 0:e.id}get isCreatedByMe(){var e;return(null===(e=this.state.createdBy)||void 0===e?void 0:e.id)===this.currentUserId}async initCamera(){var e,t,i,n,a;if(this.camera.enablePromise&&await this.camera.enablePromise,this.camera.disablePromise&&await this.camera.disablePromise,(null===(e=this.state.localParticipant)||void 0===e?void 0:e.videoStream)||!this.permissionsContext.hasPermission("send-video"))return;if(!this.camera.state.direction&&!this.camera.state.selectedDevice){let e="front",t=null===(a=this.state.settings)||void 0===a?void 0:a.video.camera_facing;t&&(e="front"===t?"front":"back"),this.camera.state.setDirection(e)}let s=null===(t=this.state.settings)||void 0===t?void 0:t.video.target_resolution;s&&await this.camera.selectTargetResolution(s),"enabled"!==this.camera.state.status||!this.camera.state.mediaStream||(null===(i=this.publisher)||void 0===i?void 0:i.isPublishing(R.VIDEO))||await this.publishVideoStream(this.camera.state.mediaStream),void 0===this.camera.state.status&&(null===(n=this.state.settings)||void 0===n?void 0:n.video.camera_default_on)&&await this.camera.enable()}async initMic(){var e,t,i;this.microphone.enablePromise&&await this.microphone.enablePromise,this.microphone.disablePromise&&await this.microphone.disablePromise,(null===(e=this.state.localParticipant)||void 0===e||!e.audioStream)&&this.permissionsContext.hasPermission("send-audio")&&("enabled"!==this.microphone.state.status||!this.microphone.state.mediaStream||(null===(t=this.publisher)||void 0===t?void 0:t.isPublishing(R.AUDIO))||await this.publishAudioStream(this.microphone.state.mediaStream),void 0===this.microphone.state.status&&(null===(i=this.state.settings)||void 0===i?void 0:i.audio.mic_default_on)&&await this.microphone.enable())}constructor({type:e,id:t,streamClient:i,members:n,ownCapabilities:a,sortParticipantsBy:s,clientStore:r,ringing:o=!1,watching:l=!1}){var c=this;this.state=new nM,this.dynascaleManager=new ap(this),this.permissionsContext=new ag,this.dispatcher=new iV,this.trackSubscriptionsSubject=new $.X({type:A.MEDIUM,data:[]}),this.reconnectAttempts=0,this.maxReconnectAttempts=10,this.leaveCallHooks=new Set,this.streamClientEventHandlers=new Map,this.leave=async function(){var e,t,i,n;let{reject:a=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=c.state.callingState;if(s===O.LEFT)throw Error("Cannot leave call that has already been left.");if(s===O.JOINING&&await c.assertCallJoined(),c.ringing){let e=c.state.remoteParticipants.length>0;c.isCreatedByMe&&!e?await c.reject():a&&s===O.RINGING&&await c.reject()}null===(e=c.statsReporter)||void 0===e||e.stop(),c.statsReporter=void 0,null===(t=c.subscriber)||void 0===t||t.close(),c.subscriber=void 0,null===(i=c.publisher)||void 0===i||i.close(),c.publisher=void 0,null===(n=c.sfuClient)||void 0===n||n.close(),c.sfuClient=void 0,c.dispatcher.offAll(),c.leaveCallHooks.forEach(e=>e()),c.clientStore.unregisterCall(c),c.state.setCallingState(O.LEFT)},this.get=async e=>{let t=await this.streamClient.get(this.streamClientBasePath,e);return(null==e?void 0:e.ring)&&!this.ringing&&this.ringingSubject.next(!0),this.state.updateFromCallResponse(t.call),this.state.setMembers(t.members),this.state.setOwnCapabilities(t.own_capabilities),this.streamClient._hasConnectionID()&&(this.watching=!0,this.clientStore.registerCall(this)),t},this.getOrCreate=async e=>{let t=await this.streamClient.post(this.streamClientBasePath,e);return(null==e?void 0:e.ring)&&!this.ringing&&this.ringingSubject.next(!0),this.state.updateFromCallResponse(t.call),this.state.setMembers(t.members),this.state.setOwnCapabilities(t.own_capabilities),this.streamClient._hasConnectionID()&&(this.watching=!0,this.clientStore.registerCall(this)),t},this.create=async e=>this.getOrCreate(e),this.ring=async()=>await this.get({ring:!0}),this.notify=async()=>await this.get({notify:!0}),this.accept=async()=>this.streamClient.post("".concat(this.streamClientBasePath,"/accept")),this.reject=async()=>this.streamClient.post("".concat(this.streamClientBasePath,"/reject")),this.join=async e=>{let t,i,n;var a,s,r,o,l=this;let c=this.state.callingState;if([O.JOINED,O.JOINING].includes(c))throw this.logger("warn","Join method called twice, you should only call this once"),Error("Illegal State: Already joined.");if(c===O.LEFT)throw Error("Illegal State: Cannot join already left call. Create a new Call instance to join a call.");let d=c===O.MIGRATING;this.state.setCallingState(O.JOINING),this.logger("debug","Starting join flow"),(null==e?void 0:e.ring)&&!this.ringing&&this.ringingSubject.next(!0),this.ringing&&!this.isCreatedByMe&&await this.accept();try{let a=await n7(this.streamClient,this.type,this.id,e);this.state.updateFromCallResponse(a.metadata),this.state.setMembers(a.members),this.state.setOwnCapabilities(a.ownCapabilities),n=a.connectionConfig,t=a.sfuServer,i=a.token,this.streamClient._hasConnectionID()&&(this.watching=!0,this.clientStore.registerCall(this))}catch(e){throw this.state.setCallingState(c),e}if("undefined"!=typeof window&&(null===(a=window.location)||void 0===a?void 0:a.search)){let e=new URLSearchParams(window.location.search);t.url=e.get("sfuUrl")||t.url,t.ws_endpoint=e.get("sfuWsUrl")||t.ws_endpoint,t.edge_name=e.get("sfuUrl")||t.edge_name}let h=this.sfuClient,u=this.sfuClient=new ng({dispatcher:this.dispatcher,sfuServer:t,token:i,sessionId:null==h?void 0:h.sessionId}),p=async function(){let{migrate:i=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l.reconnectAttempts++,l.state.setCallingState(i?O.MIGRATING:O.RECONNECTING),i?(l.logger("debug","[Migration]: migrating call ".concat(l.cid," away from ").concat(t.edge_name)),u.isMigratingAway=!0):l.logger("debug","[Rejoin]: Rejoining call ".concat(l.cid," (").concat(l.reconnectAttempts,")..."));let n=l.state.localParticipant,a=()=>{if(!i){var e,t,n;null===(e=l.subscriber)||void 0===e||e.close(),l.subscriber=void 0,null===(t=l.publisher)||void 0===t||t.close({stopTracks:!1}),l.publisher=void 0,null===(n=l.statsReporter)||void 0===n||n.stop(),l.statsReporter=void 0}null==h||h.close()};if(i||(await ns(nl(l.reconnectAttempts)),a()),await l.join({...e,...i&&{migrating_from:t.edge_name}}),i&&a(),l.logger("info","[Rejoin]: Attempt ".concat(l.reconnectAttempts," successful!")),n&&!i){let e;let{audioStream:t,videoStream:i,screenShareStream:a,screenShareAudioStream:s}=n;(a||s)&&(e=new MediaStream,null==a||a.getVideoTracks().forEach(t=>{null==e||e.addTrack(t)}),null==s||s.getAudioTracks().forEach(t=>{null==e||e.addTrack(t)})),t&&await l.publishAudioStream(t),i&&await l.publishVideoStream(i),e&&await l.publishScreenShareStream(e)}l.logger("info","[Rejoin]: State restored. Attempt: ".concat(l.reconnectAttempts))};u.signalReady.then(()=>{let e=this.dispatcher.on("goAway",e=>{if("goAway"!==e.eventPayload.oneofKind)return;let{reason:t}=e.eventPayload.goAway;this.logger("info","[Migration]: Going away from SFU... Reason: ".concat(P[t])),p({migrate:!0}).catch(e=>{this.logger("warn","[Migration]: Failed to migrate to another SFU.",e)})});u.signalWs.addEventListener("close",t=>{e(),t.code!==no.WS_CLOSED_SUCCESS&&t.code!==no.WS_POLICY_VIOLATION&&(t.code===no.WS_CLOSED_ABRUPTLY&&u.isMigratingAway||(this.reconnectAttempts<this.maxReconnectAttempts?p().catch(e=>{this.logger("error","[Rejoin]: Rejoin failed for ".concat(this.reconnectAttempts," times. Giving up."),e),this.state.setCallingState(O.RECONNECTING_FAILED)}):(this.logger("error","[Rejoin]: Reconnect attempts exceeded. Giving up..."),this.state.setCallingState(O.RECONNECTING_FAILED))))})});let g=this.streamClient.on("connection.changed",e=>{if("connection.changed"!==e.type||!e.online)return;g();let t=this.state.callingState;(t===O.OFFLINE||t===O.RECONNECTING_FAILED)&&(this.logger("info","[Rejoin]: Going online..."),p().catch(e=>{this.logger("error","[Rejoin]: Rejoin failed for ".concat(this.reconnectAttempts," times. Giving up."),e),this.state.setCallingState(O.RECONNECTING_FAILED)}))}),m=this.streamClient.on("connection.changed",e=>{"connection.changed"===e.type&&(e.online||(m(),this.state.setCallingState(O.OFFLINE)))});this.leaveCallHooks.add(()=>{g(),m()}),this.subscriber||(this.subscriber=new nn({sfuClient:u,dispatcher:this.dispatcher,state:this.state,connectionConfig:n}));let f=null===(s=this.state.settings)||void 0===s?void 0:s.audio,y=!!(null==f?void 0:f.opus_dtx_enabled),b=!!(null==f?void 0:f.redundant_coding_enabled);this.publisher||(this.publisher=new nt({sfuClient:u,dispatcher:this.dispatcher,state:this.state,connectionConfig:n,isDtxEnabled:y,isRedEnabled:b})),d||(this.statsReporter=aa({subscriber:this.subscriber,publisher:this.publisher,state:this.state}));try{u.signalReady.catch(e=>this.logger("error","Signal ready failed",e)).then(()=>ij("recvonly")).then(t=>{var i;let n=ny(this.trackSubscriptionsSubject),a=d?{fromSfuId:(null==e?void 0:e.migrating_from)||"",subscriptions:n.data||[],announcedTracks:(null===(i=this.publisher)||void 0===i?void 0:i.getCurrentTrackInfos())||[]}:void 0;return u.join({subscriberSdp:t||"",clientDetails:iG(),migration:a,fastReconnect:!1})});let{callState:t}=await this.waitForJoinResponse();d&&(await this.subscriber.migrateTo(u,n),await this.publisher.migrateTo(u,n));let i=(null==t?void 0:t.participants)||[],a=null==t?void 0:t.participantCount,s=(null==t?void 0:t.startedAt)?eE.toDate(t.startedAt):new Date,l=null!==(o=null==t?void 0:t.pins)&&void 0!==o?o:[];if(this.state.setParticipants(()=>{let e=this.state.getParticipantLookupBySessionId();return i.map(t=>{let i=Object.assign(t,{isLocalParticipant:t.sessionId===u.sessionId,viewportVisibilityState:{videoTrack:N.UNKNOWN,screenShareTrack:N.UNKNOWN}}),n=e[t.sessionId];return an(i,n)})}),this.state.setParticipantCount((null==a?void 0:a.total)||0),this.state.setAnonymousParticipantCount((null==a?void 0:a.anonymous)||0),this.state.setStartedAt(s),this.state.setServerSidePins(l),this.reconnectAttempts=0,this.state.setCallingState(O.JOINED),(null===(r=iq())||void 0===r?void 0:r.type)!==D.REACT)try{await this.initCamera(),await this.initMic()}catch(e){this.logger("warn","Camera and/or mic init failed during join call")}let{remoteParticipants:c}=this.state;c.length>0&&this.updateSubscriptions(c,A.FAST),this.logger("info","Joined call ".concat(this.cid))}catch(e){if(this.reconnectAttempts<this.maxReconnectAttempts)this.logger("error","[Rejoin]: Rejoin ".concat(this.reconnectAttempts," failed."),e),await p(),this.logger("info","[Rejoin]: Rejoin ".concat(this.reconnectAttempts," successful!"));else throw this.logger("error","[Rejoin]: Rejoin failed for ".concat(this.reconnectAttempts," times. Giving up.")),this.state.setCallingState(O.RECONNECTING_FAILED),Error("Join failed")}},this.waitForJoinResponse=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5e3;return new Promise((t,i)=>{let n=c.on("joinResponse",e=>{"joinResponse"===e.eventPayload.oneofKind&&(clearTimeout(a),n(),t(e.eventPayload.joinResponse))}),a=setTimeout(()=>{n(),i(Error('Waiting for "joinResponse" has timed out'))},e)})},this.publishVideoStream=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(await c.assertCallJoined(),!c.publisher)throw c.logger("error","Trying to publish video before join is completed"),Error("Call not joined yet.");let[i]=e.getVideoTracks();if(!i){c.logger("error","There is no video track to publish in the stream.");return}await c.publisher.publishStream(e,i,R.VIDEO,t)},this.publishAudioStream=async e=>{if(await this.assertCallJoined(),!this.publisher)throw this.logger("error","Trying to publish audio before join is completed"),Error("Call not joined yet.");let[t]=e.getAudioTracks();if(!t){this.logger("error","There is no audio track in the stream to publish");return}await this.publisher.publishStream(e,t,R.AUDIO)},this.publishScreenShareStream=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(await c.assertCallJoined(),!c.publisher)throw c.logger("error","Trying to publish screen share before join is completed"),Error("Call not joined yet.");let[i]=e.getVideoTracks();if(!i){c.logger("error","There is no video track in the screen share stream to publish");return}await c.publisher.publishStream(e,i,R.SCREEN_SHARE,t);let[n]=e.getAudioTracks();n&&await c.publisher.publishStream(e,n,R.SCREEN_SHARE_AUDIO,t)},this.stopPublish=async function(e){var t;let i=!(arguments.length>1)||void 0===arguments[1]||arguments[1];c.logger("info","stopPublish ".concat(R[e],", stop tracks: ").concat(i)),await (null===(t=c.publisher)||void 0===t?void 0:t.unpublishStream(e,i))},this.updateSubscriptionsPartial=function(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:A.SLOW;"video"===e?(c.logger("warn","updateSubscriptionsPartial: ".concat(e," is deprecated. Please switch to 'videoTrack'")),e="videoTrack"):"screen"===e&&(c.logger("warn","updateSubscriptionsPartial: ".concat(e," is deprecated. Please switch to 'screenShareTrack'")),e="screenShareTrack");let n=c.state.updateParticipants(Object.entries(t).reduce((t,i)=>{var n,a;let[s,r]=i;(null===(n=r.dimension)||void 0===n?void 0:n.height)&&(r.dimension.height=Math.ceil(r.dimension.height)),(null===(a=r.dimension)||void 0===a?void 0:a.width)&&(r.dimension.width=Math.ceil(r.dimension.width));let o="videoTrack"===e?"videoDimension":"screenShareTrack"===e?"screenShareDimension":void 0;return o&&(t[s]={[o]:r.dimension}),t},{}));n&&c.updateSubscriptions(n,i)},this.updateSubscriptions=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:A.SLOW,i=[];for(let t of e)!t.isLocalParticipant&&(t.videoDimension&&t.publishedTracks.includes(R.VIDEO)&&i.push({userId:t.userId,sessionId:t.sessionId,trackType:R.VIDEO,dimension:t.videoDimension}),t.screenShareDimension&&t.publishedTracks.includes(R.SCREEN_SHARE)&&i.push({userId:t.userId,sessionId:t.sessionId,trackType:R.SCREEN_SHARE,dimension:t.screenShareDimension}),t.publishedTracks.includes(R.SCREEN_SHARE_AUDIO)&&i.push({userId:t.userId,sessionId:t.sessionId,trackType:R.SCREEN_SHARE_AUDIO}));c.trackSubscriptionsSubject.next({type:t,data:i})},this.startReportingStatsFor=e=>{var t;return null===(t=this.statsReporter)||void 0===t?void 0:t.startReportingStatsFor(e)},this.stopReportingStatsFor=e=>{var t;return null===(t=this.statsReporter)||void 0===t?void 0:t.stopReportingStatsFor(e)},this.setAudioOutputDevice=e=>{this.sfuClient&&this.state.updateParticipant(this.sfuClient.sessionId,{audioOutputDeviceId:e})},this.setAudioDevice=e=>{this.sfuClient&&this.state.updateParticipant(this.sfuClient.sessionId,{audioDeviceId:e})},this.setVideoDevice=e=>{this.sfuClient&&this.state.updateParticipant(this.sfuClient.sessionId,{videoDeviceId:e})},this.resetReaction=e=>{this.state.updateParticipant(e,{reaction:void 0})},this.setSortParticipantsBy=e=>this.state.setSortParticipantsBy(e),this.updatePublishQuality=async e=>{var t;return null===(t=this.publisher)||void 0===t?void 0:t.updateVideoPublishQuality(e)},this.assertCallJoined=()=>new Promise(e=>{this.state.callingState$.pipe((0,Z.o)(e=>e!==O.JOINED,!0),(0,er.h)(e=>e===O.JOINED)).subscribe(()=>e())}),this.sendReaction=async e=>this.streamClient.post("".concat(this.streamClientBasePath,"/reaction"),e),this.blockUser=async e=>this.streamClient.post("".concat(this.streamClientBasePath,"/block"),{user_id:e}),this.unblockUser=async e=>this.streamClient.post("".concat(this.streamClientBasePath,"/unblock"),{user_id:e}),this.muteSelf=e=>{let t=this.currentUserId;if(t)return this.muteUser(t,e)},this.muteOthers=e=>{let t=i2(e);if(!t)return;let i=[];for(let e of this.state.remoteParticipants)e.publishedTracks.includes(t)&&i.push(e.userId);return this.muteUser(i,e)},this.muteUser=(e,t)=>this.streamClient.post("".concat(this.streamClientBasePath,"/mute_users"),{user_ids:Array.isArray(e)?e:[e],[t]:!0}),this.muteAllUsers=e=>this.streamClient.post("".concat(this.streamClientBasePath,"/mute_users"),{mute_all_users:!0,[e]:!0}),this.startRecording=async()=>this.streamClient.post("".concat(this.streamClientBasePath,"/start_recording"),{}),this.stopRecording=async()=>this.streamClient.post("".concat(this.streamClientBasePath,"/stop_recording"),{}),this.requestPermissions=async e=>{let{permissions:t}=e;if(!t.every(e=>this.permissionsContext.canRequest(e)))throw Error("You are not allowed to request permissions: ".concat(t.join(", ")));return this.streamClient.post("".concat(this.streamClientBasePath,"/request_permission"),e)},this.grantPermissions=async(e,t)=>this.updateUserPermissions({user_id:e,grant_permissions:t}),this.revokePermissions=async(e,t)=>this.updateUserPermissions({user_id:e,revoke_permissions:t}),this.updateUserPermissions=async e=>this.streamClient.post("".concat(this.streamClientBasePath,"/user_permissions"),e),this.goLive=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return c.streamClient.post("".concat(c.streamClientBasePath,"/go_live"),e,t)},this.stopLive=async()=>this.streamClient.post("".concat(this.streamClientBasePath,"/stop_live"),{}),this.startHLS=async()=>this.streamClient.post("".concat(this.streamClientBasePath,"/start_broadcasting"),{}),this.stopHLS=async()=>this.streamClient.post("".concat(this.streamClientBasePath,"/stop_broadcasting"),{}),this.update=async e=>{let t=await this.streamClient.patch("".concat(this.streamClientBasePath),e),{call:i,members:n,own_capabilities:a}=t;return this.state.updateFromCallResponse(i),this.state.setMembers(n),this.state.setOwnCapabilities(a),t},this.endCall=async()=>this.streamClient.post("".concat(this.streamClientBasePath,"/mark_ended")),this.pin=e=>{this.state.updateParticipant(e,{pin:{isLocalPin:!0,pinnedAt:Date.now()}})},this.unpin=e=>{this.state.updateParticipant(e,{pin:void 0})},this.pinForEveryone=async e=>this.streamClient.post("".concat(this.streamClientBasePath,"/pin"),e),this.unpinForEveryone=async e=>this.streamClient.post("".concat(this.streamClientBasePath,"/unpin"),e),this.queryMembers=e=>this.streamClient.post("/call/members",{...e||{},id:this.id,type:this.type}),this.updateCallMembers=async e=>this.streamClient.post("".concat(this.streamClientBasePath,"/members"),e),this.scheduleAutoDrop=()=>{this.dropTimeout&&clearTimeout(this.dropTimeout);let e=this.state.settings$.pipe((0,eo.G)(),(0,ec.b)(e=>{var t;let[i,n]=e;if(!n||!this.clientStore.connectedUser)return;let[a,s]=this.currentUserId===(null===(t=this.state.createdBy)||void 0===t?void 0:t.id)?[null==i?void 0:i.ring.auto_cancel_timeout_ms,n.ring.auto_cancel_timeout_ms]:[null==i?void 0:i.ring.incoming_call_timeout_ms,n.ring.incoming_call_timeout_ms];void 0!==s&&s!==a&&0!==s&&(this.dropTimeout&&clearTimeout(this.dropTimeout),this.dropTimeout=setTimeout(()=>this.leave(),s))}),(0,Z.o)(()=>!!this.clientStore.calls.find(e=>e.cid===this.cid))).subscribe();this.leaveCallHooks.add(()=>{e.closed||e.unsubscribe()})},this.queryRecordings=async e=>{let t=this.streamClientBasePath;return e&&(t="".concat(t,"/").concat(e)),this.streamClient.get("".concat(t,"/recordings"))},this.sendCustomEvent=async e=>this.streamClient.post("".concat(this.streamClientBasePath,"/event"),{custom:e}),this.trackElementVisibility=(e,t,i)=>this.dynascaleManager.trackElementVisibility(e,t,i),this.setViewport=e=>this.dynascaleManager.setViewport(e),this.bindVideoElement=(e,t,i)=>{let n=this.dynascaleManager.bindVideoElement(e,t,i);if(n)return this.leaveCallHooks.add(n),()=>{this.leaveCallHooks.delete(n),n()}},this.bindAudioElement=function(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"audioTrack",n=c.dynascaleManager.bindAudioElement(e,t,i);if(n)return c.leaveCallHooks.add(n),()=>{c.leaveCallHooks.delete(n),n()}},this.bindCallThumbnailElement=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=()=>{e.src=t.fallbackImageSource||"https://getstream.io/random_svg/?name=x&id=x"},n=nv(c.state.thumbnails$,t=>{if(!t)return;e.addEventListener("error",i);let n=new URL(t.image_url);n.searchParams.set("w",String(e.clientWidth)),n.searchParams.set("h",String(e.clientHeight)),e.src=n.toString()});return()=>{n(),e.removeEventListener("error",i)}},this.type=e,this.id=t,this.cid="".concat(e,":").concat(t),this.ringingSubject=new $.X(o),this.watching=l,this.streamClient=i,this.clientStore=r,this.streamClientBasePath="/call/".concat(this.type,"/").concat(this.id),this.logger=iL(["Call"]);let d=ay.get(e),h=s||d.options.sortParticipantsBy;h&&this.state.setSortParticipantsBy(h),this.state.setMembers(n||[]),this.state.setOwnCapabilities(a||[]),this.state.setCallingState(o?O.RINGING:O.IDLE),this.on("all",e=>{this.state.updateFromEvent(e)}),this.leaveCallHooks.add(n6(this,this.state,this.dispatcher)),this.registerEffects(),this.leaveCallHooks.add(nv(this.trackSubscriptionsSubject.pipe((0,ed.D)(e=>(0,eh.H)(e.type)),(0,Q.U)(e=>e.data)),e=>{var t;return null===(t=this.sfuClient)||void 0===t?void 0:t.updateSubscriptions(e)})),this.camera=new az(this),this.microphone=new aJ(this),this.speaker=new aX,this.screenShare=new a$(this)}}class aZ{constructor(){this.connectionStartTimestamp=null,this.wsTotalFailures=0,this.wsConsecutiveFailures=0,this.instanceClientId=nd()}}let a0=async(e,t)=>{for(let i=0;i<3;i++){try{await z.default.post("https://chat-insights.getstream.io/insights/".concat(e),t)}catch(e){await ns((i+1)*3e3);continue}break}};function a1(e){var t,i,n;let{client:a}=e;return{ready_state:null===(t=e.ws)||void 0===t?void 0:t.readyState,url:e._buildUrl(),api_key:a.key,start_ts:a.insightMetrics.connectionStartTimestamp,end_ts:new Date().getTime(),auth_type:a.getAuthType(),token:a.tokenManager.token,user_id:a.userID,user_details:a._user,device:"browser",client_id:e.connectionID,ws_details:e.ws,ws_consecutive_failures:a.insightMetrics.wsConsecutiveFailures,ws_total_failures:a.insightMetrics.wsTotalFailures,request_id:e.requestID,online:"undefined"!=typeof navigator?null===(i=navigator)||void 0===i?void 0:i.onLine:null,user_agent:"undefined"!=typeof navigator?null===(n=navigator)||void 0===n?void 0:n.userAgent:null,instance_client_id:a.insightMetrics.instanceClientId}}let a2=e=>void 0!==e.code,a3=e=>void 0!==e.error;class a9{async connect(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:15e3;if(this.isConnecting)throw Error("You've called connect twice, can only attempt 1 connection at the time");this.isDisconnected=!1;try{let e=await this._connect();this.consecutiveFailures=0,this._log("connect() - Established ws connection with healthcheck: ".concat(e))}catch(e){if(this.isHealthy=!1,this.consecutiveFailures+=1,e.code!==no.TOKEN_EXPIRED||this.client.tokenManager.isStatic()){if(!e.isWSFailure)throw Error(JSON.stringify({code:e.code,StatusCode:e.StatusCode,message:e.message,isWSFailure:e.isWSFailure}))}else this._log("connect() - WS failure due to expired token, so going to try to reload token and reconnect"),this._reconnect({refreshToken:!0})}return await this._waitForHealthy(e)}async _waitForHealthy(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:15e3;return Promise.race([(async()=>{for(let t=0;t<=e;t+=50)try{return await this.connectionOpen}catch(i){if(t===e)throw Error(JSON.stringify({code:i.code,StatusCode:i.StatusCode,message:i.message,isWSFailure:i.isWSFailure}));await ns(50)}})(),(async()=>{throw await ns(e),this.isConnecting=!1,Error(JSON.stringify({code:"",StatusCode:"",message:"initial WS connection could not be established",isWSFailure:!0}))})()])}disconnect(e){let t;this._log("disconnect() - Closing the websocket connection for wsID ".concat(this.wsID)),this.wsID+=1,this.isConnecting=!1,this.isDisconnected=!0,this.healthCheckTimeoutRef&&clearInterval(this.healthCheckTimeoutRef),this.connectionCheckTimeoutRef&&clearInterval(this.connectionCheckTimeoutRef),np(this.onlineStatusChanged),this.isHealthy=!1,this.ws&&this.ws.removeAllListeners&&this.ws.removeAllListeners();let{ws:i}=this;return i&&i.close&&i.readyState===i.OPEN?(t=new Promise(t=>{let n=e=>{this._log("disconnect() - resolving isClosedPromise ".concat(e?"with":"without"," close frame"),{event:e}),t()};i.onclose=n,setTimeout(n,null!=e?e:1e3)}),this._log("disconnect() - Manually closed connection by calling client.disconnect()"),i.close(no.WS_CLOSED_SUCCESS,"Manually closed connection by calling client.disconnect()")):(this._log("disconnect() - ws connection doesn't exist or it is already closed."),t=Promise.resolve()),delete this.ws,t}async _connect(){var e,t,i,n;if(this.isConnecting||this.isDisconnected&&this.client.options.enableWSFallback)return;this.isConnecting=!0,this.requestID=nd(),this.client.insightMetrics.connectionStartTimestamp=new Date().getTime();let a=!1;try{this._log("_connect() - waiting for token"),await this.client.tokenManager.tokenReady(),a=!0}catch(e){}try{a||(this._log("_connect() - tokenProvider failed before, so going to retry"),await this.client.tokenManager.loadToken()),this._setupConnectionPromise();let i=this._buildUrl();this._log("_connect() - Connecting to ".concat(i),{wsURL:i,requestID:this.requestID}),this.ws=new eg.Z(i),this.ws.onopen=this.onopen.bind(this,this.wsID),this.ws.onclose=this.onclose.bind(this,this.wsID),this.ws.onerror=this.onerror.bind(this,this.wsID),this.ws.onmessage=this.onmessage.bind(this,this.wsID);let n=await this.connectionOpen;if(this.isConnecting=!1,n)return this.connectionID=n.connection_id,null===(e=(t=this.client).resolveConnectionId)||void 0===e||e.call(t,this.connectionID),this.client.insightMetrics.wsConsecutiveFailures>0&&this.client.options.enableInsights&&(a0("ws_success_after_failure",a1(this)),this.client.insightMetrics.wsConsecutiveFailures=0),n}catch(e){if(this.isConnecting=!1,this._log("_connect() - Error - ",e),this.client.options.enableInsights){this.client.insightMetrics.wsConsecutiveFailures++,this.client.insightMetrics.wsTotalFailures++;let t={...function(e){let t={};if(!e)return t;try{Object.getOwnPropertyNames(e).forEach(i=>{t[i]=Object.getOwnPropertyDescriptor(e,i)})}catch(e){return{error:"failed to serialize the error"}}return t}(e),...a1(this)};null==a0||a0("ws_fatal",t)}throw null===(i=(n=this.client).rejectConnectionId)||void 0===i||i.call(n),e}}async _reconnect(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this._log("_reconnect() - Initiating the reconnect"),this.isConnecting||this.isHealthy){this._log("_reconnect() - Abort (1) since already connecting or healthy");return}let t=e.interval;if(t||(t=nl(this.consecutiveFailures)),await ns(t),this.isConnecting||this.isHealthy){this._log("_reconnect() - Abort (2) since already connecting or healthy");return}if(this.isDisconnected&&this.client.options.enableWSFallback){this._log("_reconnect() - Abort (3) since disconnect() is called");return}this._log("_reconnect() - Destroying current WS connection"),this._destroyCurrentWSConnection(),e.refreshToken&&await this.client.tokenManager.loadToken();try{await this._connect(),this._log("_reconnect() - Waiting for recoverCallBack"),this._log("_reconnect() - Finished recoverCallBack"),this.consecutiveFailures=0}catch(e){if(this.isHealthy=!1,this.consecutiveFailures+=1,e.code===no.TOKEN_EXPIRED&&!this.client.tokenManager.isStatic())return this._log("_reconnect() - WS failure due to expired token, so going to try to reload token and reconnect"),this._reconnect({refreshToken:!0});e.isWSFailure&&(this._log("_reconnect() - WS failure, so going to try to reconnect"),this._reconnect())}this._log("_reconnect() - == END ==")}_destroyCurrentWSConnection(){this.wsID+=1;try{var e,t;null===this||void 0===this||null===(e=this.ws)||void 0===e||e.removeAllListeners(),null===this||void 0===this||null===(t=this.ws)||void 0===t||t.close()}catch(e){}}constructor(e){var t=this;this._log=function(e){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"info";t.client.logger(n,"connection:"+e,{...i})},this.setClient=e=>{this.client=e},this._buildUrl=()=>{let e=new URLSearchParams;return e.set("api_key",this.client.key),e.set("stream-auth-type",this.client.getAuthType()),e.set("X-Stream-Client",this.client.getUserAgent()),"".concat(this.client.wsBaseURL,"/connect?").concat(e.toString())},this.onlineStatusChanged=e=>{"offline"===e.type?(this._log("onlineStatusChanged() - Status changing to offline"),this._setHealth(!1,!0)):"online"!==e.type||(this._log("onlineStatusChanged() - Status changing to online. isHealthy: ".concat(this.isHealthy)),this.isHealthy||this._reconnect({interval:10}))},this.onopen=e=>{var t;if(this.wsID!==e)return;let i=this.client.user;if(!i){this.client.logger("error","User not set, can't connect to WS");return}let n=this.client._getToken();if(!n){this.client.logger("error","Token not set, can't connect authenticate");return}let a={token:n,user_details:{id:i.id,name:i.name,image:i.image,custom:i.custom}};this.authenticationSent=!0,null===(t=this.ws)||void 0===t||t.send(JSON.stringify(a)),this._log("onopen() - onopen callback",{wsID:e})},this.onmessage=(e,t)=>{if(this.wsID!==e)return;this._log("onmessage() - onmessage callback",{event:t,wsID:e});let i="string"==typeof t.data?JSON.parse(t.data):null;if(!this.isResolved&&i&&"connection.ok"===i.type){var n,a;if(this.isResolved=!0,i.error){null===(a=this.rejectPromise)||void 0===a||a.call(this,this._errorFromWSEvent(i,!1));return}null===(n=this.resolvePromise)||void 0===n||n.call(this,i),this._setHealth(!0)}if(this.lastEvent=new Date,i&&("health.check"===i.type||"connection.ok"===i.type)&&this.scheduleNextPing(),i&&i.error){let{code:e}=this._errorFromWSEvent(i,!0);this.isHealthy=!1,this.isConnecting=!1,this.consecutiveFailures+=1,e!==no.TOKEN_EXPIRED||this.client.tokenManager.isStatic()||(clearTimeout(this.connectionCheckTimeoutRef),this._log("connect() - WS failure due to expired token, so going to try to reload token and reconnect"),this._reconnect({refreshToken:!0}))}this.client.handleEvent(t),this.scheduleConnectionCheck()},this.onclose=(e,t)=>{var i,n;if(this.wsID===e){if(this._log("onclose() - onclose callback - "+t.code,{event:t,wsID:e}),t.code===no.WS_CLOSED_SUCCESS){let e=Error("WS connection reject with error ".concat(t.reason));e.reason=t.reason,e.code=t.code,e.wasClean=t.wasClean,e.target=t.target,null===(i=this.rejectPromise)||void 0===i||i.call(this,e),this._log("onclose() - WS connection reject with error ".concat(t.reason),{event:t})}else this.consecutiveFailures+=1,this.totalFailures+=1,this._setHealth(!1),this.isConnecting=!1,null===(n=this.rejectPromise)||void 0===n||n.call(this,this._errorFromWSEvent(t)),this._log("onclose() - WS connection closed. Calling reconnect ...",{event:t}),this._reconnect()}},this.onerror=(e,t)=>{var i;this.wsID===e&&(this.consecutiveFailures+=1,this.totalFailures+=1,this._setHealth(!1),this.isConnecting=!1,null===(i=this.rejectPromise)||void 0===i||i.call(this,this._errorFromWSEvent(t)),this._log("onerror() - WS connection resulted into error",{event:t}),this._reconnect())},this._setHealth=function(e){let i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(e!==t.isHealthy){if(t.isHealthy=e,t.isHealthy||i){t.client.dispatchEvent({type:"connection.changed",online:t.isHealthy});return}setTimeout(()=>{t.isHealthy||t.client.dispatchEvent({type:"connection.changed",online:t.isHealthy})},5e3)}},this._errorFromWSEvent=function(e){let i,n,a,s=!(arguments.length>1)||void 0===arguments[1]||arguments[1];a2(e)&&(i=e.code,n="unknown",a=e.reason),a3(e)&&(i=e.error.code,n=e.error.StatusCode,a=e.error.message),t._log("_errorFromWSEvent() - WS failed with code ".concat(i),{event:e},"warn");let r=Error("WS failed with code ".concat(i," and reason - ").concat(a));return r.code=i,r.StatusCode=n,r.isWSFailure=s,r},this._setupConnectionPromise=()=>{this.isResolved=!1,this.connectionOpen=new Promise((e,t)=>{this.resolvePromise=e,this.rejectPromise=t})},this.scheduleNextPing=()=>{this.healthCheckTimeoutRef&&clearTimeout(this.healthCheckTimeoutRef),this.healthCheckTimeoutRef=setTimeout(()=>{let e=[{type:"health.check",client_id:this.client.clientID}];try{var t;null===(t=this.ws)||void 0===t||t.send(JSON.stringify(e))}catch(e){}},this.pingInterval)},this.scheduleConnectionCheck=()=>{this.connectionCheckTimeoutRef&&clearTimeout(this.connectionCheckTimeoutRef),this.connectionCheckTimeoutRef=setTimeout(()=>{let e=new Date;this.lastEvent&&e.getTime()-this.lastEvent.getTime()>this.connectionCheckTimeout&&(this._log("scheduleConnectionCheck - going to reconnect"),this._setHealth(!1),this._reconnect())},this.connectionCheckTimeout)},this.client=e,this.consecutiveFailures=0,this.totalFailures=0,this.isConnecting=!1,this.authenticationSent=!1,this.isDisconnected=!1,this.isResolved=!1,this.isHealthy=!1,this.wsID=1,this.lastEvent=null,this.pingInterval=25e3,this.connectionCheckTimeout=this.pingInterval+1e4,nu(this.onlineStatusChanged)}}function a4(e){return"string"==typeof e}let a5=e=>(0,em.JQ)(new Uint8Array(function(e,t){let i=[];if(a4(e)&&t&&a4(e)){for(let n=0,a=e.length;n<a;n++)if(e.charAt(n)){let a=t(e.charAt(n),n,e);i[n]=a}}else if(!a4(e)&&!(t&&a4(e))){for(let n=0,a=e.length;n<a;n++)if(n in e){let a=t(e[n],n,e);i[n]=a}}return i}(e,e=>e.charCodeAt(0)))),a6=e=>{let t={},i=String.fromCharCode,n=e.length,a,s=0,r,o=0,l,c="";for(a=0;a<64;a++)t["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a)]=a;for(r=0;r<n;r++)for(s=(s<<6)+t[e.charAt(r)],o+=6;o>=8;)((l=s>>>(o-=8)&255)||r<n-2)&&(c+=i(l));return c};function a8(e,t){if(arguments.length>2&&void 0!==arguments[2]&&arguments[2],arguments.length>3&&void 0!==arguments[3]&&arguments[3],"string"!=typeof t)throw TypeError("userId should be a string");throw Error("Unable to find jwt crypto, if you are getting this error is probably because you are trying to generate tokens on browser or React Native (or other environment where crypto functions are not available). Please Note: token should only be generated server-side.")}function a7(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=Object.assign({algorithm:"HS256",noTimestamp:!0},t);return null.sign({server:!0},e,i)}class se{constructor(e){this.setTokenOrProvider=async(e,t,i)=>{this.validateToken(e,t,i),this.user=t,nr(e)&&(this.tokenProvider=e,this.type="provider"),"string"==typeof e&&(this.token=e,this.type="static"),!e&&this.user&&this.secret&&(this.token=a8(this.secret,t.id,{},{}),this.type="static"),await this.loadToken()},this.reset=()=>{this.token=void 0,this.user=void 0,this.loadTokenPromise=null},this.validateToken=(e,t,i)=>{if(!t||!i||e){if(!this.secret&&!e)throw Error("UserWithId token can not be empty");if(e&&"string"!=typeof e&&!nr(e))throw Error("user token should either be a string or a function");if("string"==typeof e){if(i&&""===e)return;let n=function(e){let t=e.split(".");return 3!==t.length?"":JSON.parse(a6(t[1])).user_id}(e);if(null!=e&&(null==n||""===n||!i&&n!==t.id))throw Error("userToken does not have a user_id or is not matching with user.id")}}},this.tokenReady=()=>this.loadTokenPromise,this.loadToken=()=>(this.loadTokenPromise=new Promise(async(e,t)=>{if("static"===this.type)return e(this.token);if(this.tokenProvider&&"string"!=typeof this.tokenProvider){try{this.token=await this.tokenProvider()}catch(e){return t(Error("Call to tokenProvider failed with message: ".concat(e)))}e(this.token)}}),this.loadTokenPromise),this.getToken=()=>{if(this.token||this.user&&!this.token)return this.token;if(this.secret)return a7(this.secret);throw Error("Both secret and user tokens are not set. Either client.connectUser wasn't called or client.disconnect was called")},this.isStatic=()=>"static"===this.type,this.loadTokenPromise=null,e&&(this.secret=e),this.type="static",this.secret&&(this.token=a7(this.secret))}}let st={"-1":{name:"InternalSystemError",retryable:!0},2:{name:"AccessKeyError",retryable:!1},3:{name:"AuthenticationFailedError",retryable:!0},4:{name:"InputError",retryable:!1},6:{name:"DuplicateUsernameError",retryable:!1},9:{name:"RateLimitError",retryable:!0},16:{name:"DoesNotExistError",retryable:!1},17:{name:"NotAllowedError",retryable:!1},18:{name:"EventNotSupportedError",retryable:!1},19:{name:"ChannelFeatureNotSupportedError",retryable:!1},20:{name:"MessageTooLongError",retryable:!1},21:{name:"MultipleNestingLevelError",retryable:!1},22:{name:"PayloadTooBigError",retryable:!1},23:{name:"RequestTimeoutError",retryable:!0},24:{name:"MaxHeaderSizeExceededError",retryable:!1},40:{name:"AuthErrorTokenExpired",retryable:!1},41:{name:"AuthErrorTokenNotValidYet",retryable:!1},42:{name:"AuthErrorTokenUsedBeforeIssuedAt",retryable:!1},43:{name:"AuthErrorTokenSignatureInvalid",retryable:!1},44:{name:"CustomCommandEndpointMissingError",retryable:!1},45:{name:"CustomCommandEndpointCallError",retryable:!0},46:{name:"ConnectionIDNotFoundError",retryable:!1},60:{name:"CoolDownError",retryable:!0},69:{name:"ErrWrongRegion",retryable:!1},70:{name:"ErrQueryChannelPermissions",retryable:!1},71:{name:"ErrTooManyConnections",retryable:!0},99:{name:"AppSuspendedError",retryable:!1}};function si(e){if(!e.code)return!1;let t=st["".concat(e.code)];return!!t&&t.retryable}(w=L||(L={})).Closed="CLOSED",w.Connected="CONNECTED",w.Connecting="CONNECTING",w.Disconnected="DISCONNECTED",w.Init="INIT";class sn{_log(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"info";this.client.logger(i,"WSConnectionFallback:"+e,{...t})}_setState(e){this._log("_setState() - ".concat(e)),this.state===L.Connecting&&e===L.Connected&&this.client.dispatchEvent({type:"connection.changed",online:!0}),(e===L.Closed||e===L.Disconnected)&&this.client.dispatchEvent({type:"connection.changed",online:!1}),this.state=e}constructor(e){var t=this;this._onlineStatusChanged=e=>{if(this._log("_onlineStatusChanged() - ".concat(e.type)),"offline"===e.type){var t;this._setState(L.Closed),null===(t=this.cancelToken)||void 0===t||t.cancel("disconnect() is called"),this.cancelToken=void 0;return}"online"===e.type&&this.state===L.Closed&&this.connect(!0)},this._req=async(e,t,i)=>{this.cancelToken||e.close||(this.cancelToken=z.default.CancelToken.source());try{var n;let i=await this.client.doAxiosRequest("get",this.client.baseURL.replace(":3030",":8900")+"/longpoll",void 0,{config:{...t,cancelToken:null===(n=this.cancelToken)||void 0===n?void 0:n.token},params:e,publicEndpoint:!0});return this.consecutiveFailures=0,i}catch(n){if(this.consecutiveFailures+=1,i&&si(n))return this._log("_req() - Retryable error, retrying request"),await ns(nl(this.consecutiveFailures)),this._req(e,t,i);throw n}},this._poll=async()=>{for(;this.state===L.Connected;)try{var e;let t=await this._req({},{timeout:3e4},!0);if(null===(e=t.events)||void 0===e?void 0:e.length)for(let e=0;e<t.events.length;e++)this.client.dispatchEvent(t.events[e])}catch(e){if(z.default.isCancel(e)){this._log("_poll() - axios canceled request");return}if(46===e.code){this._log("_poll() - ConnectionID error, connecting without ID..."),this._setState(L.Disconnected),this.connect(!0);return}if(void 0!==e.code&&!si(e)){this._setState(L.Closed);return}await ns(nl(this.consecutiveFailures))}},this.connect=async function(){var e,i,n,a;let s=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(t.state===L.Connecting){t._log("connect() - connecting already in progress",{reconnect:s},"warn");return}if(t.state===L.Connected){t._log("connect() - already connected and polling",{reconnect:s},"warn");return}t._setState(L.Connecting),t.connectionID=void 0;try{let{event:n}=await t._req({json:t.client._buildWSPayload()},{timeout:8e3},s);return t._setState(L.Connected),t.connectionID=n.connection_id,null===(e=(i=t.client).resolveConnectionId)||void 0===e||e.call(i),t.client.dispatchEvent(n),t._poll(),n}catch(e){throw t._setState(L.Closed),null===(n=(a=t.client).rejectConnectionId)||void 0===n||n.call(a),e}},this.isHealthy=()=>!!this.connectionID&&this.state===L.Connected,this.disconnect=async function(){var e;let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3;np(t._onlineStatusChanged),t._setState(L.Disconnected),null===(e=t.cancelToken)||void 0===e||e.cancel("disconnect() is called"),t.cancelToken=void 0;let n=t.connectionID;t.connectionID=void 0;try{await t._req({close:!0,connection_id:n},{timeout:i},!1),t._log("disconnect() - Closed connectionID")}catch(e){t._log("disconnect() - Failed",{err:e},"error")}},this.client=e,this.state=L.Init,this.consecutiveFailures=0,nu(this._onlineStatusChanged)}}let sa=iL(["location"]),ss="https://hint.stream-io-video.com/",sr=async function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0];let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2e3,t=new AbortController,i=setTimeout(()=>t.abort(),e);try{let e=(await fetch(ss,{method:"HEAD",signal:t.signal})).headers.get("x-amz-cf-pop")||"ERR";return sa("debug","Location header: ".concat(e)),e.substring(0,3)}catch(e){return sa("warn","Failed to get location hint from ".concat(ss),e),"ERR"}finally{clearTimeout(i)}};class so{constructor(e,t){var i,n=this;this.nextRequestAbortController=null,this.devToken=e=>["eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9",a5(JSON.stringify({user_id:e})),"devtoken"].join("."),this.getAuthType=()=>this.anonymous?"anonymous":"jwt",this.setBaseURL=e=>{this.baseURL=e,this.wsBaseURL=this.baseURL.replace("http","ws").replace(":3030",":8800")},this.getLocationHint=async(e,t)=>{let i=await this.locationHint;return i&&"ERR"!==i?i:(this.locationHint=sr(null!=e?e:this.options.locationHintUrl,null!=t?t:this.options.locationHintTimeout),this.locationHint)},this._getConnectionID=()=>{var e,t;return(null===(e=this.wsConnection)||void 0===e?void 0:e.connectionID)||(null===(t=this.wsFallback)||void 0===t?void 0:t.connectionID)},this._hasConnectionID=()=>!!this._getConnectionID(),this.connectUser=async(e,t)=>{if(!e.id)throw Error('The "id" field on the user is missing');if(this.userID===e.id&&this.setUserPromise)return this.logger("warn","Consecutive calls to connectUser is detected, ideally you should only call this function once in your app."),this.setUserPromise;if(this.userID)throw Error("Use client.disconnect() before trying to connect as a different user. connectUser was called twice.");(this._isUsingServerAuth()||this.node)&&!this.options.allowServerSideConnect&&this.logger("warn",'Please do not use connectUser server side. connectUser impacts MAU and concurrent connection usage and thus your bill. If you have a valid use-case, add "allowServerSideConnect: true" to the client options to disable this warning.'),this.userID=e.id,this.anonymous=!1;let i=this._setToken(e,t,this.anonymous);this._setUser(e);let n=this.openConnection();this.setUserPromise=Promise.all([i,n]).then(e=>e[1]);try{return await this.setUserPromise}catch(e){throw this.persistUserOnConnectionFailure?this.closeConnection():this.disconnectUser(),e}},this._setToken=(e,t,i)=>this.tokenManager.setTokenOrProvider(t,e,i),this._setUser=e=>{this.user=e,this.userID=e.id,this._user={...e}},this.closeConnection=async e=>{var t,i;return null!=this.cleaningIntervalRef&&(clearInterval(this.cleaningIntervalRef),this.cleaningIntervalRef=void 0),await Promise.all([null===(t=this.wsConnection)||void 0===t?void 0:t.disconnect(e),null===(i=this.wsFallback)||void 0===i?void 0:i.disconnect(e)]),Promise.resolve()},this.openConnection=async()=>{var e,t,i;if(!this.userID)throw Error("UserWithId is not set on client, use client.connectUser or client.connectAnonymousUser instead");return(null===(e=this.wsConnection)||void 0===e?void 0:e.isConnecting)&&this.wsPromise?(this.logger("info","client:openConnection() - connection already in progress"),this.wsPromise):((null===(t=this.wsConnection)||void 0===t?void 0:t.isHealthy)||(null===(i=this.wsFallback)||void 0===i?void 0:i.isHealthy()))&&this._hasConnectionID()?(this.logger("info","client:openConnection() - openConnection called twice, healthy connection already exists"),Promise.resolve()):(this.connectionIdPromise=new Promise((e,t)=>{this.resolveConnectionId=e,this.rejectConnectionId=t}),this.clientID="".concat(this.userID,"--").concat(nd()),this.wsPromise=this.connect(),this.wsPromise)},this._normalizeDate=e=>{if(e instanceof Date&&(e=e.toISOString()),""===e)throw Error("Don't pass blank string for since, use null instead if resetting the token revoke");return e},this.disconnectUser=async e=>{this.logger("info","client:disconnect() - Disconnecting the client"),delete this.user,delete this._user,delete this.userID,this.anonymous=!1,await this.closeConnection(e),this.tokenManager.reset(),this.connectionIdPromise=void 0,this.rejectConnectionId=void 0,this.resolveConnectionId=void 0},this.connectGuestUser=async e=>{this.guestUserCreatePromise=this.doAxiosRequest("post","/guest",{user:{...e,role:"guest"}},{publicEndpoint:!0});let t=await this.guestUserCreatePromise;return this.guestUserCreatePromise.finally(()=>this.guestUserCreatePromise=void 0),this.connectUser(t.user,t.access_token)},this.connectAnonymousUser=async(e,t)=>{var i;this.connectionIdPromise=new Promise((e,t)=>{this.resolveConnectionId=e,this.rejectConnectionId=t}),this.anonymous=!0,await this._setToken(e,t,this.anonymous),this._setUser(e),null===(i=this.resolveConnectionId)||void 0===i||i.call(this)},this.on=(e,t)=>{let i=t?e:"all",n=t||e;return i in this.listeners||(this.listeners[i]=[]),this.listeners[i].push(n),()=>{this.off(i,n)}},this.off=(e,t)=>{let i=t?e:"all",n=t||e;i in this.listeners||(this.listeners[i]=[]),this.logger("debug","Removing listener for ".concat(i," event")),this.listeners[i]=this.listeners[i].filter(e=>e!==n)},this._logApiRequest=(e,t,i,n)=>{this.logger("trace","client: ".concat(e," - Request - ").concat(t),{payload:i,config:n})},this._logApiResponse=(e,t,i)=>{this.logger("trace","client:".concat(e," - Response - url: ").concat(t," > status ").concat(i.status),{response:i})},this._logApiError=(e,t,i)=>{this.logger("error","client:".concat(e," - Error - url: ").concat(t),{url:t,error:i})},this.doAxiosRequest=async function(e,t,i){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};a.publicEndpoint||await Promise.all([n.tokenManager.tokenReady(),n.guestUserCreatePromise,n.connectionIdPromise]);let s=n._enrichAxiosOptions(a);try{let a;switch(n._logApiRequest(e,t,i,s),e){case"get":a=await n.axiosInstance.get(t,s);break;case"delete":a=await n.axiosInstance.delete(t,s);break;case"post":a=await n.axiosInstance.post(t,i,s);break;case"put":a=await n.axiosInstance.put(t,i,s);break;case"patch":a=await n.axiosInstance.patch(t,i,s);break;case"options":a=await n.axiosInstance.options(t,s);break;default:throw Error("Invalid request type")}return n._logApiResponse(e,t,a),n.consecutiveFailures=0,n.handleResponse(a)}catch(o){var r;if(o.client_request_id=null===(r=s.headers)||void 0===r?void 0:r["x-client-request-id"],n.consecutiveFailures+=1,o.response){if(n._logApiError(e,t,o.response),o.response.data.code===no.TOKEN_EXPIRED&&!n.tokenManager.isStatic())return n.consecutiveFailures>1&&await ns(nl(n.consecutiveFailures)),await n.tokenManager.loadToken(),await n.doAxiosRequest(e,t,i,a);return n.handleResponse(o.response)}throw n._logApiError(e,t,o),o}},this.get=(e,t)=>this.doAxiosRequest("get",e,null,{params:t}),this.put=(e,t,i)=>this.doAxiosRequest("put",e,t,{params:i}),this.post=(e,t,i)=>this.doAxiosRequest("post",e,t,{params:i}),this.patch=(e,t,i)=>this.doAxiosRequest("patch",e,t,{params:i}),this.delete=(e,t)=>this.doAxiosRequest("delete",e,null,{params:t}),this.errorFromResponse=e=>{let t;return t=new ev("Stream error HTTP code: ".concat(e.status)),e.data&&e.data.code&&((t=Error("Stream error code ".concat(e.data.code,": ").concat(e.data.message))).code=e.data.code),t.response=e,t.status=e.status,t},this.handleResponse=e=>{let t=e.data;if(!e.status||e.status<200||300<=e.status)throw this.errorFromResponse(e);return t},this.dispatchEvent=e=>{e.received_at||(e.received_at=new Date),this.logger("debug","Dispatching event: ".concat(e.type),e),this._callClientListeners(e)},this.handleEvent=e=>{let t=JSON.parse(e.data);this.dispatchEvent(t)},this._callClientListeners=e=>{let t=[];for(let i of(this.listeners.all&&t.push(...this.listeners.all),this.listeners[e.type]&&t.push(...this.listeners[e.type]),t))i(e)},this.connect=async()=>{if(!this.userID||!this._user)throw Error("Call connectUser or connectAnonymousUser before starting the connection");if(!this.wsBaseURL)throw Error("Websocket base url not set");if(!this.clientID)throw Error("clientID is not set");!this.wsConnection&&(this.options.warmUp||this.options.enableInsights)&&this._sayHi(),this.options.wsConnection&&this.node?(this.options.wsConnection.setClient(this),this.wsConnection=this.options.wsConnection):this.wsConnection=new a9(this);try{if(this.wsFallback)return await this.wsFallback.connect();return this.logger("info","StreamClient.connect: this.wsConnection.connect()"),await this.wsConnection.connect(this.options.enableWSFallback?this.defaultWSTimeoutWithFallback:this.defaultWSTimeout)}catch(e){if(this.options.enableWSFallback&&function(e){if("boolean"==typeof e.isWSFailure)return e.isWSFailure;try{return JSON.parse(e.message).isWSFailure}catch(e){return!1}}(e)&&function(e){let t="undefined"!=typeof navigator?navigator:"undefined"!=typeof window&&window.navigator?window.navigator:void 0;return t?"boolean"!=typeof t.onLine||t.onLine:(e("warn","isOnline failed to access window.navigator and assume browser is online"),!0)}(this.logger))return this.logger("warn","client:connect() - WS failed, fallback to longpoll"),this.dispatchEvent({type:"transport.changed",mode:"longpoll"}),this.wsConnection._destroyCurrentWSConnection(),this.wsConnection.disconnect().then(),this.wsFallback=new sn(this),await this.wsFallback.connect();throw e}},this._sayHi=()=>{let e=nd(),t={headers:q.uu.from({"x-client-request-id":e})};this.doAxiosRequest("get",this.baseURL+"/hi",null,t).catch(t=>{this.options.enableInsights&&a0("http_hi_failed",{api_key:this.key,err:t,client_request_id:e})})},this.getUserAgent=()=>this.userAgent||"stream-video-javascript-client-".concat(this.node?"node":"browser","-").concat("0.3.36"),this.setUserAgent=e=>{this.userAgent=e},this._isUsingServerAuth=()=>!!this.secret,this._enrichAxiosOptions=function(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{params:{},headers:{},config:{}},i=t.publicEndpoint&&!n.user?void 0:n._getToken(),a=null;return null!==n.nextRequestAbortController&&(a=n.nextRequestAbortController.signal,n.nextRequestAbortController=null),(null===(e=t.headers)||void 0===e?void 0:e["x-client-request-id"])||(t.headers={...t.headers,"x-client-request-id":nd()}),{params:{user_id:n.userID,connection_id:n._getConnectionID(),api_key:n.key,...t.params},headers:{...i?{Authorization:i}:void 0,"stream-auth-type":t.publicEndpoint&&!n.user?"anonymous":n.getAuthType(),"X-Stream-Client":n.getUserAgent(),...t.headers},...a?{signal:a}:{},...t.config,...n.options.axiosRequestConfig}},this._getToken=()=>this.tokenManager?this.tokenManager.getToken():null,this._buildWSPayload=e=>JSON.stringify({user_id:this.userID,user_details:this._user,client_request_id:e}),this.createAbortControllerForNextRequest=()=>this.nextRequestAbortController=new AbortController,this.createToken=(e,t,i,n)=>{if(null==this.secret)throw Error("tokens can only be created server-side using the API Secret");let a={};return t&&(a.exp=t),i&&(a.iat=i),n&&(a.call_cids=n),a8(this.secret,e,a,{})},this.key=e,this.listeners={},this.secret=null==t?void 0:t.secret;let a=t||{browser:"undefined"!=typeof window};this.browser=a.browser||"undefined"!=typeof window,this.node=!this.browser,this.browser&&(this.locationHint=sr(null==t?void 0:t.locationHintUrl,null==t?void 0:t.locationHintTimeout)),this.options={timeout:5e3,withCredentials:!1,warmUp:!1,...a},this.node&&!this.options.httpsAgent&&(this.options.httpsAgent=new null.Agent({keepAlive:!0,keepAliveMsecs:3e3})),this.setBaseURL(this.options.baseURL||"https://video.stream-io-api.com/video"),void 0!==ef&&ef.env.STREAM_LOCAL_TEST_RUN&&this.setBaseURL("http://localhost:3030/video"),void 0!==ef&&ef.env.STREAM_LOCAL_TEST_HOST&&this.setBaseURL("http://".concat(ef.env.STREAM_LOCAL_TEST_HOST,"/video")),this.axiosInstance=z.default.create({...this.options,baseURL:this.baseURL}),this.wsConnection=null,this.wsPromise=null,this.setUserPromise=null,this.anonymous=!1,this.persistUserOnConnectionFailure=null===(i=this.options)||void 0===i?void 0:i.persistUserOnConnectionFailure,this.tokenManager=new se(this.secret),this.consecutiveFailures=0,this.insightMetrics=new aZ,this.defaultWSTimeoutWithFallback=6e3,this.defaultWSTimeout=15e3,this.logger=nr(a.logger)?a.logger:()=>null}}class sl{get state(){return this.readOnlyStateStore}async connectUser(e,t){var i;if("anonymous"===e.type)return e.id="!anon",this.connectAnonymousUser(e,t);let n=()=>this.streamClient.connectUser(e,t);"guest"===e.type&&(n=async()=>this.streamClient.connectGuestUser(e)),this.connectionPromise=this.disconnectionPromise?this.disconnectionPromise.then(()=>n()):n(),null===(i=this.connectionPromise)||void 0===i||i.finally(()=>this.connectionPromise=void 0);let a=await this.connectionPromise;return(null==a?void 0:a.me)&&this.writeableStateStore.setConnectedUser(a.me),this.eventHandlersToUnregister.push(this.on("connection.changed",e=>{if(e.online){let e=this.writeableStateStore.calls.filter(e=>e.watching).map(e=>e.cid);this.logger("info","Rewatching calls after connection changed ".concat(e.join(", "))),e.length>0&&this.queryCalls({watch:!0,filter_conditions:{cid:{$in:e}},sort:[{field:"cid",direction:1}]}).catch(e=>{this.logger("error","Failed to re-watch calls",e)})}})),this.eventHandlersToUnregister.push(this.on("call.created",t=>{if("call.created"!==t.type)return;let{call:i,members:n}=t;if(e.id===i.created_by.id){this.logger("warn","Received `call.created` sent by the current user");return}this.logger("info","New call created and registered: ".concat(i.cid));let a=new aY({streamClient:this.streamClient,type:i.type,id:i.id,members:n,clientStore:this.writeableStateStore});a.state.updateFromCallResponse(i),this.writeableStateStore.registerCall(a)})),this.eventHandlersToUnregister.push(this.on("call.ring",async t=>{if("call.ring"!==t.type)return;let{call:i,members:n}=t;if(e.id===i.created_by.id){this.logger("debug","Received `call.ring` sent by the current user so ignoring the event");return}let a=this.writeableStateStore.findCall(i.type,i.id);await (null==a?void 0:a.leave());let s=new aY({streamClient:this.streamClient,type:i.type,id:i.id,members:n,clientStore:this.writeableStateStore,ringing:!0});s.state.updateFromCallResponse(i),await s.get(),this.writeableStateStore.registerCall(s)})),a}async addVoipDevice(e,t,i,n){return await this.addDevice(e,t,i,n,!0)}constructor(e,t){var i,n,a=this;this.logLevel="warn",this.eventHandlersToUnregister=[],this.disconnectUser=async e=>{if(!this.streamClient.user&&!this.connectionPromise)return;let t=()=>this.streamClient.disconnectUser(e);this.disconnectionPromise=this.connectionPromise?this.connectionPromise.then(()=>t()):t(),this.disconnectionPromise.finally(()=>this.disconnectionPromise=void 0),await this.disconnectionPromise,this.eventHandlersToUnregister.forEach(e=>e()),this.eventHandlersToUnregister=[],this.writeableStateStore.setConnectedUser(void 0)},this.on=(e,t)=>this.streamClient.on(e,t),this.off=(e,t)=>this.streamClient.off(e,t),this.call=(e,t)=>new aY({streamClient:this.streamClient,id:t,type:e,clientStore:this.writeableStateStore}),this.createGuestUser=async e=>this.streamClient.doAxiosRequest("post","/guest",e,{publicEndpoint:!0}),this.queryCalls=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=await a.streamClient.post("/calls",e),i=t.calls.map(t=>{let i=new aY({streamClient:a.streamClient,id:t.call.id,type:t.call.type,members:t.members,ownCapabilities:t.own_capabilities,watching:e.watch,clientStore:a.writeableStateStore});return i.state.updateFromCallResponse(t.call),e.watch&&a.writeableStateStore.registerCall(i),i});return{...t,calls:i}},this.edges=async()=>this.streamClient.get("/edges"),this.addDevice=async(e,t,i,n,a)=>await this.streamClient.post("/devices",{id:e,push_provider:t,voip_token:a,...null!=n?{user_id:n}:{},...null!=i?{push_provider_name:i}:{}}),this.getDevices=async e=>await this.streamClient.get("/devices",e?{user_id:e}:{}),this.removeDevice=async(e,t)=>await this.streamClient.delete("/devices",{id:e,...t?{user_id:t}:{}}),this.onRingingCall=async e=>{let t=this.readOnlyStateStore.calls.find(t=>t.cid===e&&t.ringing);if(!t){let[i,n]=e.split(":");t=new aY({streamClient:this.streamClient,type:i,id:n,clientStore:this.writeableStateStore,ringing:!0}),await t.get()}return t},this.connectAnonymousUser=async(e,t)=>{let i=()=>this.streamClient.connectAnonymousUser(e,t);return this.connectionPromise=this.disconnectionPromise?this.disconnectionPromise.then(()=>i()):i(),this.connectionPromise.finally(()=>this.connectionPromise=void 0),this.connectionPromise};let s=iN,r="warn";if("string"==typeof e?(r=(null==t?void 0:t.logLevel)||r,s=(null==t?void 0:t.logger)||s):(r=(null===(i=e.options)||void 0===i?void 0:i.logLevel)||r,s=(null===(n=e.options)||void 0===n?void 0:n.logger)||s),iA(s,r),this.logger=iL(["client"]),"string"==typeof e)this.streamClient=new so(e,{persistUserOnConnectionFailure:!0,...t,logLevel:r,logger:this.logger});else{this.streamClient=new so(e.apiKey,{persistUserOnConnectionFailure:!0,...e.options,logLevel:r,logger:this.logger});let t=iq();t&&this.streamClient.setUserAgent(this.streamClient.getUserAgent()+"-video-".concat(D[t.type].toLowerCase(),"-sdk-").concat(t.major,".").concat(t.minor,".").concat(t.patch))}if(this.writeableStateStore=new nw,this.readOnlyStateStore=new nT(this.writeableStateStore),"string"!=typeof e){let t=e.user,i=e.token||e.tokenProvider;t&&this.connectUser(t,i)}}}}}]); |