PageSourceSearch

https://covey-town-705.onrender.com/_next/static/chunks/210.6e87bd42eb3fb637.js

js covey-town-705.onrender.com collected 2026-10-03 11:40:09 UTC 183,914 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[210],{20210:function(e,t,n){n.r(t),n.d(t,{default:function(){return Qi}});var r=n(47568),i=n(70655),o=n(85893),a=n(63833),s=n(13457),c=n(69282),l=n.n(c),u=n(67294),d=n(73727),h=n(51438),f=n(52951),p=n(28668),v=n(82670),m=n(26042),g=n(69396),x=n(29815),w=n(26626),y=n(17187),b=n.n(y),C=n(96486),j=n.n(C),_=n(53416),k=n(9367),Z=function e(t){(0,h.Z)(this,e),this.config=t},S=n(14924),T=n(828),P=n(9669),I=n.n(P),E=n(6230),L=n.n(E),A=n(25892),N=function(e){(0,p.Z)(n,e);var t=(0,w.Z)(n);function n(e,r,i){var o;return(0,h.Z)(this,n),(o=t.call(this,i)).name="ApiError",o.url=r.url,o.status=r.status,o.statusText=r.statusText,o.body=r.body,o.request=e,o}return n}((0,A.Z)(Error)),D=function(e){(0,p.Z)(n,e);var t=(0,w.Z)(n);function n(e){var r;return(0,h.Z)(this,n),(r=t.call(this,e)).name="CancelError",r}return(0,f.Z)(n,[{key:"isCancelled",get:function(){return!0}}]),n}((0,A.Z)(Error)),O=function(){function e(t){var n=this;(0,h.Z)(this,e),this._isResolved=!1,this._isRejected=!1,this._isCancelled=!1,this._cancelHandlers=[],this._promise=new Promise((function(e,r){n._resolve=e,n._reject=r;var i=function(e){n._isResolved||n._isRejected||n._isCancelled||n._cancelHandlers.push(e)};return Object.defineProperty(i,"isResolved",{get:function(){return n._isResolved}}),Object.defineProperty(i,"isRejected",{get:function(){return n._isRejected}}),Object.defineProperty(i,"isCancelled",{get:function(){return n._isCancelled}}),t((function(e){var t,r;n._isResolved||n._isRejected||n._isCancelled||(n._isResolved=!0,null===(r=(t=n)._resolve)||void 0===r||r.call(t,e))}),(function(e){var t,r;n._isResolved||n._isRejected||n._isCancelled||(n._isRejected=!0,null===(r=(t=n)._reject)||void 0===r||r.call(t,e))}),i)}))}var t=e.prototype;return t.then=function(e,t){return this._promise.then(e,t)},t.catch=function(e){return this._promise.catch(e)},t.finally=function(e){return this._promise.finally(e)},t.cancel=function(){var e;if(!(this._isResolved||this._isRejected||this._isCancelled)){if(this._isCancelled=!0,this._cancelHandlers.length)try{var t=!0,n=!1,r=void 0;try{for(var i,o=this._cancelHandlers[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){(0,i.value)()}}catch(a){n=!0,r=a}finally{try{t||null==o.return||o.return()}finally{if(n)throw r}}}catch(s){return void console.warn("Cancellation threw an error",s)}this._cancelHandlers.length=0,null===(e=this._reject)||void 0===e||e.call(this,new D("Request aborted"))}},(0,f.Z)(e,[{key:"isCancelled",get:function(){return this._isCancelled}}]),e}(),R=n(48764).lW,B=function(e){return void 0!==e&&null!==e},M=function(e){return"string"===typeof e},F=function(e){return M(e)&&""!==e},V=function(e){return"object"===typeof e&&"string"===typeof e.type&&"function"===typeof e.stream&&"function"===typeof e.arrayBuffer&&"function"===typeof e.constructor&&"string"===typeof e.constructor.name&&/^(Blob|File)$/.test(e.constructor.name)&&/^(Blob|File)$/.test(e[Symbol.toStringTag])},W=function(e){var t=[],n=function(e,r){B(r)&&(Array.isArray(r)?r.forEach((function(t){n(e,t)})):"object"===typeof r?Object.entries(r).forEach((function(t){var r=(0,T.Z)(t,2),i=r[0],o=r[1];n("".concat(e,"[").concat(i,"]"),o)})):function(e,n){t.push("".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(String(n))))}(e,r))};return Object.entries(e).forEach((function(e){var t=(0,T.Z)(e,2),r=t[0],i=t[1];n(r,i)})),t.length>0?"?".concat(t.join("&")):""},z=function(){var e=(0,r.Z)((function(e,t){return(0,i.__generator)(this,(function(n){return"function"===typeof t?[2,t(e)]:[2,t]}))}));return function(t,n){return e.apply(this,arguments)}}(),U=function(){var e=(0,r.Z)((function(e,t,n){var r,o,a,s,c,l,u;return(0,i.__generator)(this,(function(i){switch(i.label){case 0:return[4,z(t,e.TOKEN)];case 1:return r=i.sent(),[4,z(t,e.USERNAME)];case 2:return o=i.sent(),[4,z(t,e.PASSWORD)];case 3:return a=i.sent(),[4,z(t,e.HEADERS)];case 4:return s=i.sent(),c="function"===typeof(null===n||void 0===n?void 0:n.getHeaders)&&(null===n||void 0===n?void 0:n.getHeaders())||{},l=Object.entries((0,m.Z)({Accept:"application/json"},s,t.headers,c)).filter((function(e){var t=(0,T.Z)(e,2),n=(t[0],t[1]);return B(n)})).reduce((function(e,t){var n=(0,T.Z)(t,2),r=n[0],i=n[1];return(0,g.Z)((0,m.Z)({},e),(0,S.Z)({},r,String(i)))}),{}),F(r)&&(l.Authorization="Bearer ".concat(r)),F(o)&&F(a)&&(u=function(e){try{return btoa(e)}catch(t){return R.from(e).toString("base64")}}("".concat(o,":").concat(a)),l.Authorization="Basic ".concat(u)),t.body&&(t.mediaType?l["Content-Type"]=t.mediaType:V(t.body)?l["Content-Type"]=t.body.type||"application/octet-stream":M(t.body)?l["Content-Type"]="text/plain":(d=t.body,(0,v.Z)(d,L())||(l["Content-Type"]="application/json"))),[2,l]}var d}))}));return function(t,n,r){return e.apply(this,arguments)}}(),G=function(){var e=(0,r.Z)((function(e,t,n,r,o,a,s){var c,l,u,d;return(0,i.__generator)(this,(function(i){switch(i.label){case 0:c=I().CancelToken.source(),l={url:n,headers:a,data:null!==r&&void 0!==r?r:o,method:t.method,withCredentials:e.WITH_CREDENTIALS,cancelToken:c.token},s((function(){return c.cancel("The user aborted a request.")})),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,I().request(l)];case 2:return[2,i.sent()];case 3:if(u=i.sent(),(d=u).response)return[2,d.response];throw u;case 4:return[2]}}
1))}));return function(t,n,r,i,o,a,s){return e.apply(this,arguments)}}(),H=function(e,t){return new O(function(){var n=(0,r.Z)((function(n,r,o){var a,s,c,l,u,d,h,f,p;return(0,i.__generator)(this,(function(i){switch(i.label){case 0:return i.trys.push([0,4,,5]),a=function(e,t){var n=e.ENCODE_PATH||encodeURI,r=t.url.replace("{api-version}",e.VERSION).replace(/{(.*?)}/g,(function(e,r){var i;return(null===(i=t.path)||void 0===i?void 0:i.hasOwnProperty(r))?n(String(t.path[r])):e})),i="".concat(e.BASE).concat(r);return t.query?"".concat(i).concat(W(t.query)):i}(e,t),s=function(e){if(e.formData){var t=new(L()),n=function(e,n){M(n)||V(n)?t.append(e,n):t.append(e,JSON.stringify(n))};return Object.entries(e.formData).filter((function(e){var t=(0,T.Z)(e,2),n=(t[0],t[1]);return B(n)})).forEach((function(e){var t=(0,T.Z)(e,2),r=t[0],i=t[1];Array.isArray(i)?i.forEach((function(e){return n(r,e)})):n(r,i)})),t}}(t),c=function(e){if(e.body)return e.body}(t),[4,U(e,t,s)];case 1:return l=i.sent(),o.isCancelled?[3,3]:[4,G(e,t,a,c,s,l,o)];case 2:u=i.sent(),d=function(e){if(204!==e.status)return e.data}(u),h=function(e,t){if(t){var n=e.headers[t];if(M(n))return n}}(u,t.responseHeader),f={url:a,ok:(v=u.status,v>=200&&v<300),status:u.status,statusText:u.statusText,body:null!==h&&void 0!==h?h:d},function(e,t){var n=(0,m.Z)({400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable"},e.errors)[t.status];if(n)throw new N(e,t,n);if(!t.ok)throw new N(e,t,"Generic Error")}(t,f),n(f.body),i.label=3;case 3:return[3,5];case 4:return p=i.sent(),r(p),[3,5];case 5:return[2]}var v}))}));return function(e,t,r){return n.apply(this,arguments)}}())},X=function(e){(0,p.Z)(n,e);var t=(0,w.Z)(n);function n(e){return(0,h.Z)(this,n),t.call(this,e)}return n.prototype.request=function(e){return H(this.config,e)},n}(Z),K=function(){function e(t){(0,h.Z)(this,e),this.httpRequest=t}var t=e.prototype;return t.listTowns=function(){return this.httpRequest.request({method:"GET",url:"/towns"})},t.createTown=function(e){return this.httpRequest.request({method:"POST",url:"/towns",body:e,mediaType:"application/json"})},t.updateTown=function(e,t,n){return this.httpRequest.request({method:"PATCH",url:"/towns/{townID}",path:{townID:e},headers:{"X-CoveyTown-Password":t},body:n,mediaType:"application/json",errors:{400:"Invalid password or update values specified"}})},t.deleteTown=function(e,t){return this.httpRequest.request({method:"DELETE",url:"/towns/{townID}",path:{townID:e},headers:{"X-CoveyTown-Password":t},errors:{400:"Invalid password or update values specified"}})},t.createConversationArea=function(e,t,n){return this.httpRequest.request({method:"POST",url:"/towns/{townID}/conversationArea",path:{townID:e},headers:{"X-Session-Token":t},body:n,mediaType:"application/json",errors:{400:"Invalid values specified"}})},t.createViewingArea=function(e,t,n){return this.httpRequest.request({method:"POST",url:"/towns/{townID}/viewingArea",path:{townID:e},headers:{"X-Session-Token":t},body:n,mediaType:"application/json",errors:{400:"Invalid values specified"}})},e}(),q=function e(t){var n,r,i,o,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:X;(0,h.Z)(this,e),this.request=new a({BASE:null!==(n=null===t||void 0===t?void 0:t.BASE)&&void 0!==n?n:"",VERSION:null!==(r=null===t||void 0===t?void 0:t.VERSION)&&void 0!==r?r:"1.0.0",WITH_CREDENTIALS:null!==(i=null===t||void 0===t?void 0:t.WITH_CREDENTIALS)&&void 0!==i&&i,CREDENTIALS:null!==(o=null===t||void 0===t?void 0:t.CREDENTIALS)&&void 0!==o?o:"include",TOKEN:null===t||void 0===t?void 0:t.TOKEN,USERNAME:null===t||void 0===t?void 0:t.USERNAME,PASSWORD:null===t||void 0===t?void 0:t.PASSWORD,HEADERS:null===t||void 0===t?void 0:t.HEADERS,ENCODE_PATH:null===t||void 0===t?void 0:t.ENCODE_PATH}),this.towns=new K(this.request)},Y=u.createContext(null);function J(){var e=(0,u.useContext)(Y);return l()(e,"TownController context should be defined in order to use this hook."),e}var Q=function(){function e(t){(0,h.Z)(this,e),this._occupants=[],this._listeners=new Map,this._id=t}var t=e.prototype;return t.addListener=function(e,t){var n,r=null!==(n=this._listeners.get(e))&&void 0!==n?n:[];return r.push(t),this._listeners.set(e,r),this},t.removeListener=function(e,t){var n,r=null!==(n=this._listeners.get(e))&&void 0!==n?n:[];return j().remove(r,(function(e){return e===t})),this._listeners.set(e,r),this},t.emit=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var i,o=null!==(i=this._listeners.get(e))&&void 0!==i?i:[];return o.forEach((function(e){return e.apply(void 0,(0,x.Z)(n))})),!0},t.updateFrom=function(e,t){this.occupants=t,this._updateFrom(e)},t.isEmpty=function(){return 0===this._occupants.length},(0,f.Z)(e,[{key:"id",get:function(){return this._id}},{key:"occupantsByID",get:function(){return this._occupants.map((function(e){return e.id}))}},{key:"occupants",get:function(){return this._occupants},set:function(e){(e.length!==this._occupants.length||j().xor(e,this._occupants).length>
10)&&(this.emit("occupantsChange",e),this._occupants=e)}}]),e}();var $=function(e){(0,p.Z)(n,e);var t=(0,w.Z)(n);function n(e,r){var i;return(0,h.Z)(this,n),(i=t.call(this,e))._topic=r,i}var r=n.prototype;return r.isActive=function(){return void 0!==this.topic&&this.occupants.length>0},r._updateFrom=function(e){this.topic=e.topic},r.isEmpty=function(){return void 0===this._topic||0===this.occupants.length},r.toInteractableAreaModel=function(){return{id:this.id,occupants:this.occupants.map((function(e){return e.id})),topic:this.topic,type:"ConversationArea"}},n.fromConversationAreaModel=function(e,t){var r=new n(e.id,e.topic);return r.occupants=t(e.occupants),r},(0,f.Z)(n,[{key:"topic",get:function(){return this._topic},set:function(e){this._topic!==e&&this.emit("topicChange",e),this._topic=e}}]),n}(Q);var ee=function(e){(0,p.Z)(n,e);var t=(0,w.Z)(n);function n(e,r,i){var o;(0,h.Z)(this,n),(o=t.call(this,e))._players=[],o._model=r,o._townController=i;var a=r.game;return a&&a.players&&(o._players=a.players.map((function(e){return o._townController.getPlayer(e)}))),o}var o=n.prototype;return o.joinGame=function(){var e=this;return(0,r.Z)((function(){var t;return(0,i.__generator)(this,(function(n){switch(n.label){case 0:return[4,e._townController.sendInteractableCommand(e.id,{type:"JoinGame"})];case 1:return t=n.sent().gameID,e._instanceID=t,[2]}}))}))()},o.leaveGame=function(){var e=this;return(0,r.Z)((function(){var t;return(0,i.__generator)(this,(function(n){switch(n.label){case 0:return(t=e._instanceID)?[4,e._townController.sendInteractableCommand(e.id,{type:"LeaveGame",gameID:t})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}
1))}))()},o._updateFrom=function(e){var t,n,r,i,o,a,s,c=this,l="IN_PROGRESS"===(null===(t=this._model.game)||void 0===t?void 0:t.state.status)&&"OVER"===(null===(n=e.game)||void 0===n?void 0:n.state.status),u=null!==(a=null===(r=e.game)||void 0===r?void 0:r.players.map((function(e){return c._townController.getPlayer(e)})))&&void 0!==a?a:[];!u&&this._players.length>0&&(this._players=[],this.emit("playersChange",[])),(this._players.length!=(null===(i=e.game)||void 0===i?void 0:i.players.length)||j().xor(u,this._players).length>0)&&(this._players=u,this.emit("playersChange",u)),this._model=e,this.emit("gameUpdated"),this._instanceID=null!==(s=null===(o=e.game)||void 0===o?void 0:o.id)&&void 0!==s?s:this._instanceID,l&&this.emit("gameEnd")},o.toInteractableAreaModel=function(){return this._model},(0,f.Z)(n,[{key:"history",get:function(){return this._model.history}},{key:"players",get:function(){return this._players}},{key:"observers",get:function(){var e=this;return this.occupants.filter((function(t){return!e._players.includes(t)}))}}]),n}(Q),te=n(45785),ne=n(82662),re=function(e){(0,p.Z)(n,e);var t=(0,w.Z)(n);function n(){var e;return(0,h.Z)(this,n),(e=t.apply(this,arguments))._board=[[void 0,void 0,void 0],[void 0,void 0,void 0],[void 0,void 0,void 0]],e}var o=n.prototype;return o.isActive=function(){var e;return"IN_PROGRESS"===(null===(e=this._model.game)||void 0===e?void 0:e.state.status)},o._updateFrom=function(e){var t,r,i=(null===(t=this.whoseTurn)||void 0===t?void 0:t.id)===this._townController.ourPlayer.id;(0,te.Z)((0,ne.Z)(n.prototype),"_updateFrom",this).call(this,e);var o=e.game;if(o){var a=[[void 0,void 0,void 0],[void 0,void 0,void 0],[void 0,void 0,void 0]];o.state.moves.forEach((function(e){a[e.row][e.col]=e.gamePiece})),j().isEqual(a,this._board)||(this._board=a,this.emit("boardChanged",this._board))}var s=(null===(r=this.whoseTurn)||void 0===r?void 0:r.id)===this._townController.ourPlayer.id;i!=s&&this.emit("turnChanged",s)},o.makeMove=function(e,t){var n=this;return(0,r.Z)((function(){var r,o;return(0,i.__generator)(this,(function(i){switch(i.label){case 0:if(!(o=n._instanceID)||"IN_PROGRESS"!==(null===(r=n._model.game)||void 0===r?void 0:r.state.status))throw new Error("No game in progress");return[4,n._townController.sendInteractableCommand(n.id,{type:"GameMove",gameID:o,move:{row:e,col:t,gamePiece:n.gamePiece}})];case 1:return i.sent(),[2]}}))}))()},(0,f.Z)(n,[{key:"board",get:function(){return this._board}},{key:"x",get:function(){var e,t=null===(e=this._model.game)||void 0===e?void 0:e.state.x;if(t)return this.occupants.find((function(e){return e.id===t}))}},{key:"o",get:function(){var e,t=null===(e=this._model.game)||void 0===e?void 0:e.state.o;if(t)return this.occupants.find((function(e){return e.id===t}))}},{key:"moveCount",get:function(){var e;return(null===(e=this._model.game)||void 0===e?void 0:e.state.moves.length)||0}},{key:"winner",get:function(){var e,t=null===(e=this._model.game)||void 0===e?void 0:e.state.winner;if(t)return this.occupants.find((function(e){return e.id===t}))}},{key:"whoseTurn",get:function(){var e,t=this.x,n=this.o;if(t&&n&&"IN_PROGRESS"===(null===(e=this._model.game)||void 0===e?void 0:e.state.status)){if(this.moveCount%2===0)return t;if(this.moveCount%2===1)return n;throw new Error("Invalid move count")}}},{key:"isOurTurn",get:function(){var e;return(null===(e=this.whoseTurn)||void 0===e?void 0:e.id)===this._townController.ourPlayer.id}},{key:"isPlayer",get:function(){var e;return(null===(e=this._model.game)||void 0===e?void 0:e.players.includes(this._townController.ourPlayer.id))||!1}},{key:"gamePiece",get:function(){var e,t;if((null===(e=this.x)||void 0===e?void 0:e.id)===this._townController.ourPlayer.id)return"X";if((null===(t=this.o)||void 0===t?void 0:t.id)===this._townController.ourPlayer.id)return"O";throw new Error("Player is not in game")}},{key:"status",get:function(){var e,t=null===(e=this._model.game)||void 0===e?void 0:e.state.status;return t||"WAITING_TO_START"}}]),n}(ee),ie=function(e){(0,p.Z)(n,e);var t=(0,w.Z)(n);function n(e){var r;return(0,h.Z)(this,n),(r=t.call(this,e.id))._model=e,r}var r=n.prototype;return r.isActive=function(){return void 0!==this._model.video},r.toInteractableAreaModel=function(){return this._model},r._updateFrom=function(e){this.isPlaying=e.isPlaying,this.elapsedTimeSec=e.elapsedTimeSec,this.video=e.video},(0,f.Z)(n,[{key:"video",get:function(){return this._model.video}
1,set:function(e){this._model.video!==e&&(this._model.video=e,this.emit("videoChange",e))}},{key:"elapsedTimeSec",get:function(){return this._model.elapsedTimeSec},set:function(e){this._model.elapsedTimeSec!=e&&(this._model.elapsedTimeSec=e,this.emit("progressChange",e))}},{key:"isPlaying",get:function(){return this._model.isPlaying},set:function(e){this._model.isPlaying!=e&&(this._model.isPlaying=e,this.emit("playbackChange",e))}}]),n}(Q),oe=function(e){(0,p.Z)(n,e);var t=(0,w.Z)(n);function n(e,r,i){var o;return(0,h.Z)(this,n),(o=t.call(this,e))._model=r,o._townController=i,o}var o=n.prototype;return o.isActive=function(){return this.occupants.length>0},o.isDrawer=function(){return void 0!==this._model.drawer&&this._model.drawer.id===this._townController.ourPlayer.id},o._updateFrom=function(){},o.handleServerResponse=function(e){"WhiteboardPlayerJoin"===e.type&&this._handlePlayerJoin(e.player,e.isDrawer,e.drawer,e.viewers,e.elements),"WhiteboardPlayerLeave"===e.type&&this._handlePlayerLeave(e.player,e.isDrawer,e.drawer,e.viewers),"WhiteboardNewScene"===e.type&&this._handleDrawerChange(e.elements),"WhiteboardPointerUpdate"===e.type&&this._handlePointerUpdate(e.player,e.payload),"WhiteboardNewDrawer"===e.type&&this._handleNewDrawer(e.drawer,e.viewers),"WhiteboardClearDrawer"===e.type&&this._handleClearDrawer(e.viewers)},o._handlePointerUpdate=function(e,t){this._townController.ourPlayer.id!==e.id&&this.emit("whiteboardPointerUpdate",{player:e,payload:t})},o._handleDrawerChange=function(e){this.isDrawer()||this.emit("whiteboardNewScene",{elements:e})},o._handlePlayerJoin=function(e,t,n,r,i){this._model.drawer=n,this._model.viewers=r,this._townController.ourPlayer.id===e.id&&this.emit("whiteboardNewScene",{elements:i}),this.emit("whiteboardPlayerJoin",{player:e,isDrawer:t})},o._handlePlayerLeave=function(e,t,n,r){this._model.drawer=n,this._model.viewers=r,t&&this.emit("whiteboardNewDrawer",{player:n}),this.emit("whiteboardPlayerLeave",{player:e})},o._handleNewDrawer=function(e,t){this._model.drawer=e,this._model.viewers=t,this.emit("whiteboardNewDrawer",{player:e})},o._handleClearDrawer=function(e){this._model.drawer=void 0,this._model.viewers=e,this.emit("whiteboardClearDrawer")},o.isEmpty=function(){return 0===this.occupants.length},o.toInteractableAreaModel=function(){return{id:this.id,occupants:this.occupants.map((function(e){return e.id})),type:"WhiteboardArea",drawer:this._model.drawer,viewers:this._model.viewers}},o.leaveArea=function(){var e=this;return(0,r.Z)((function(){return(0,i.__generator)(this,(function(t){switch(t.label){case 0:return[4,e._townController.sendInteractableCommand(e.id,{type:"WhiteboardLeave"})];case 1:return t.sent(),[2]}}))}))()},o.joinArea=function(){var e=this;return(0,r.Z)((function(){return(0,i.__generator)(this,(function(t){switch(t.label){case 0:return[4,e._townController.sendInteractableCommand(e.id,{type:"WhiteboardJoin"})];case 1:return t.sent(),[2]}}))}))()},o.boardChange=function(e){var t=this;return(0,r.Z)((function(){return(0,i.__generator)(this,(function(n){switch(n.label){case 0:return[4,t._townController.sendInteractableCommand(t.id,{type:"WhiteboardChange",elements:e})];case 1:return n.sent(),[2]}}))}))()},o.pointerChange=function(e){var t=this;return(0,r.Z)((function(){return(0,i.__generator)(this,(function(n){switch(n.label){case 0:return e.pointersMap.size<2?[4,t._townController.sendInteractableCommand(t.id,{type:"WhiteboardPointerChange",payload:e})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}
1))}))()},o.drawerChange=function(e,t){var n=this;return(0,r.Z)((function(){return(0,i.__generator)(this,(function(r){switch(r.label){case 0:return[4,n._townController.sendInteractableCommand(n.id,{type:"WhiteboardDrawerChange",newDrawerId:e,eraseBoard:t})];case 1:return r.sent(),[2]}}))}))()},o.clearDrawer=function(){var e=this;return(0,r.Z)((function(){return(0,i.__generator)(this,(function(t){switch(t.label){case 0:return[4,e._townController.sendInteractableCommand(e.id,{type:"WhiteboardClearDrawerChange"})];case 1:return t.sent(),[2]}}))}))()},(0,f.Z)(n,[{key:"drawer",get:function(){return this._model.drawer}},{key:"viewers",get:function(){return this._model.viewers}}]),n}(Q),ae="No game in progress",se=function(e){(0,p.Z)(n,e);var t=(0,w.Z)(n);function n(e,r,i,o){var a;return(0,h.Z)(this,n),(a=t.call(this,e,r,i))._whiteboardAreaController=o,a}var o=n.prototype;return o.isActive=function(){var e;return"IN_PROGRESS"===(null===(e=this._model.game)||void 0===e?void 0:e.state.status)},o._updateWhiteboard=function(e,t,n,o){var a=this;return(0,r.Z)((function(){return(0,i.__generator)(this,(function(r){switch(r.label){case 0:return e?[4,a._whiteboardAreaController.joinArea()]:[3,2];case 1:return r.sent(),[3,4];case 2:return t?[4,a._whiteboardAreaController.leaveArea()]:[3,4];case 3:r.sent(),r.label=4;case 4:return n?[4,a._whiteboardAreaController.clearDrawer()]:[3,6];case 5:return r.sent(),[3,8];case 6:return o?[4,a._whiteboardAreaController.drawerChange(o,!0)]:[3,8];case 7:r.sent(),r.label=8;case 8:return[2]}}
1))}))()},o._updateFrom=function(e){var t,r,i=void 0!==this._model.game&&this._model.game.players.includes(this._townController.ourPlayer.id),o=void 0!==e.game&&e.game.players.includes(this._townController.ourPlayer.id),a=!i&&o,s=i&&!o,c=null===(t=e.game)||void 0===t?void 0:t.state.drawer,l=(null===(r=this._model.game)||void 0===r?void 0:r.state.drawer)!==c,u=l&&void 0===c;l?this._updateWhiteboard(a,s,u,c):this._updateWhiteboard(a,s,u),(0,te.Z)((0,ne.Z)(n.prototype),"_updateFrom",this).call(this,e)},o.makeGuess=function(e){var t=this;return(0,r.Z)((function(){var n,r;return(0,i.__generator)(this,(function(i){switch(i.label){case 0:if(!(r=t._instanceID)||"IN_PROGRESS"!==(null===(n=t._model.game)||void 0===n?void 0:n.state.status))throw new Error(ae);return[4,t._townController.sendInteractableCommand(t.id,{type:"GameMove",gameID:r,move:{guesser:t._townController.ourPlayer.id,guessWord:e}})];case 1:return i.sent(),[2]}}))}))()},o.startGame=function(){var e=this;return(0,r.Z)((function(){var t;return(0,i.__generator)(this,(function(n){switch(n.label){case 0:if(!(t=e._instanceID))throw new Error(ae);return[4,e._townController.sendInteractableCommand(e.id,{type:"StartGame",gameID:t})];case 1:return n.sent(),[2]}}))}))()},(0,f.Z)(n,[{key:"currentWord",get:function(){return this._model.game?this._model.game.state.currentWord:""}},{key:"timer",get:function(){return this._model.game?this._model.game.state.timer:0}},{key:"drawer",get:function(){var e,t=null===(e=this._model.game)||void 0===e?void 0:e.state.drawer;if(t)return this.occupants.find((function(e){return e.id===t}))}},{key:"winner",get:function(){var e,t=null===(e=this._model.game)||void 0===e?void 0:e.state.winner;if(t)return this.occupants.find((function(e){return e.id===t}))}},{key:"isOurTurn",get:function(){var e;return(null===(e=this.drawer)||void 0===e?void 0:e.id)===this._townController.ourPlayer.id}},{key:"isPlayer",get:function(){var e;return(null===(e=this._model.game)||void 0===e?void 0:e.players.includes(this._townController.ourPlayer.id))||!1}},{key:"weAlreadyGuessedCorrectly",get:function(){var e,t;return!!(null===(t=null===(e=this._model.game)||void 0===e?void 0:e.state.alreadyGuessedCorrectly)||void 0===t?void 0:t.includes(this._townController.ourPlayer.id))}},{key:"status",get:function(){var e,t=null===(e=this._model.game)||void 0===e?void 0:e.state.status;return t||"WAITING_TO_START"}},{key:"betweenTurns",get:function(){var e,t=null===(e=this._model.game)||void 0===e?void 0:e.state.betweenTurns;return t||!1}},{key:"scores",get:function(){var e;return null===(e=this._model.game)||void 0===e?void 0:e.state.scores}}]),n}(ee),ce=175,le=function(e){(0,p.Z)(n,e);var t=(0,w.Z)(n);function n(e,r,i){var o;return(0,h.Z)(this,n),(o=t.call(this))._id=e,o._userName=r,o._location=i,o}var r=n.prototype;return r.toPlayerModel=function(){return{id:this.id,userName:this.userName,location:this.location}},r._updateGameComponentLocation=function(){if(this.gameObjects&&!this.gameObjects.locationManagedByGameScene){var e=this.gameObjects,t=e.sprite,n=e.label;if(!t.anims)return;if(t.setX(this.location.x),t.setY(this.location.y),this.location.moving){switch(t.anims.play("misa-".concat(this.location.rotation,"-walk"),!0),this.location.rotation){case"front":t.body.setVelocity(0,ce);break;case"right":t.body.setVelocity(ce,0);break;case"back":t.body.setVelocity(0,-175);break;case"left":t.body.setVelocity(-175,0)}t.body.velocity.normalize().scale(175)}else t.body.setVelocity(0,0),t.anims.stop(),t.setTexture("atlas","misa-".concat(this.location.rotation));n.setX(t.body.x),n.setY(t.body.y-20)}},n.fromPlayerModel=function(e){return new n(e.id,e.userName,e.location)},(0,f.Z)(n,[{key:"location",get:function(){return this._location},set:function(e){this._location=e,this._updateGameComponentLocation(),this.emit("movement",e)}},{key:"userName",get:function(){return this._userName}},{key:"id",get:function(){return this._id}}]),n}(b()),ue=function(e){(0,p.Z)(n,e);var t=(0,w.Z)(n);function n(e){var r,i=e.userName,o=e.townID,a=e.loginController;(0,h.Z)(this,n),(r=t.call(this))._playersInternal=[],r._interactableControllers=[],r._townIsPubliclyListedInternal=!1,r._paused=!1,r._interactableEmitter=new(b()),r._townID=o,r._userName=i,r._loginController=a,r.setMaxListeners(30);var s="https://town-service.onrender.com";return l()(s),r._socket=(0,k.io)(s,{auth:{userName:i,townID:o}}),r._townsService=new q({BASE:s}).towns,r.registerSocketListeners(),r}var o=n.prototype;return o.pause=function(){this._paused||(this._paused=!0,this.emit
1("pause"))},o.unPause=function(){this._paused&&(this._paused=!1,this.emit("unPause"))},o.getPlayer=function(e){var t=this._playersInternal.find((function(t){return t.id===e}));return l()(t),t},o.interact=function(e){this._interactableEmitter.emit(e.getType(),e)},o.interactEnd=function(e){this._interactableEmitter.emit("endInteraction",e)},o.registerSocketListeners=function(){var e=this;this._socket.on("chatMessage",(function(t){e.emit("chatMessage",t)})),this._socket.on("townSettingsUpdated",(function(t){var n=t.friendlyName;void 0!==n&&(e._friendlyName=n),void 0!==t.isPubliclyListed&&(e._townIsPubliclyListed=t.isPubliclyListed)})),this._socket.on("townClosing",(function(){e.emit("disconnect"),e._loginController.setTownController(null)})),this._socket.on("playerJoined",(function(t){var n=le.fromPlayerModel(t);e._players=e.players.concat([n]),e.emit("playerMoved",n)})),this._socket.on("playerDisconnect",(function(t){e._players=e.players.filter((function(e){return e.id!==t.id}))})),this._socket.on("playerMoved",(function(t){var n=e.players.find((function(e){return e.id===t.id}));n&&(n===e._ourPlayer?n.location.interactableID=t.location.interactableID:n.location=t.location,e.emit("playerMoved",n))})),this._socket.on("interactableUpdate",(function(t){try{var n=e._interactableControllers.find((function(e){return e.id===t.id}));if(n){var r=n.isActive();n.updateFrom(t,e._playersByIDs(t.occupants)),r!==n.isActive()&&e.emit("interactableAreasChanged")}}catch(i){console.error("Error updating interactable",t),console.trace(i)}})),this._socket.on("whiteboardReponse",(function(t){try{e.getWhiteboardAreaController(t.id).handleServerResponse(t)}catch(n){console.error("Error with whiteboard",t),console.trace(n)}}))},o.emitMovement=function(e){this._socket.emit("playerMovement",e);var t=this._ourPlayer;l()(t),t.location=e,this.emit("playerMoved",t)},o.emitChatMessage=function(e){this._socket.emit("chatMessage",e)},o.sendInteractableCommand=function(e,t){var n=this;return(0,r.Z)((function(){var r;return(0,i.__generator)(this,(function(i){return r=(0,g.Z)((0,m.Z)({},t),{commandID:(0,_.x0)(),interactableID:e}),[2,new Promise((function(e,t){var i=setTimeout((function(){t("Command timed out")}),5e3),o=function(a){a.commandID===r.commandID&&(clearTimeout(i),n._socket.off("commandResponse",o),a.error?t(a.error):e(a.payload))};n._socket.on("commandResponse",o),n._socket.emit("interactableCommand",r)}))]}))}))()},o.updateTown=function(e,t){var n=this;return(0,r.Z)((function(){return(0,i.__generator)(this,(function(r){switch(r.label){case 0:return[4,n._townsService.updateTown(n._townID,e,t)];case 1:return r.sent(),[2]}}))}))()},o.deleteTown=function(e){var t=this;return(0,r.Z)((function(){return(0,i.__generator)(this,(function(n){switch(n.label){case 0:return[4,t._townsService.deleteTown(t._townID,e)];case 1:return n.sent(),[2]}}))}))()},o.createConversationArea=function(e){var t=this;return(0,r.Z)((function(){return(0,i.__generator)(this,(function(n){switch(n.label){case 0:return[4,t._townsService.createConversationArea(t.townID,t.sessionToken,e)];case 1:return n.sent(),[2]}}))}))()},o.createWhiteboardArea=function(e){var t=this;return(0,r.Z)((function(){return(0,i.__generator)(this,(function(n){switch(n.label){case 0:return[4,t._townsService.createConversationArea(t.townID,t.sessionToken,e)];case 1:return n.sent(),[2]}}))}))()},o.createViewingArea=function(e){var t=this;return(0,r.Z)((function(){return(0,i.__generator)(this,(function(n){switch(n.label){case 0:return[4,t._townsService.createViewingArea(t.townID,t.sessionToken,e)];case 1:return n.sent(),[2]}}))}))()},o.disconnect=function(){this._socket.disconnect(),this._loginController.setTownController(null)},o.connect=function(){var e=this;return(0,r.Z)((function(){return(0,i.__generator)(this,(function(t){return[2,new Promise((function(t,n){e._socket.connect(),e._socket.on("initialize",(function(n){e._providerVideoToken=n.providerVideoToken,e._friendlyNameInternal=n.friendlyName,e._townIsPubliclyListedInternal=n.isPubliclyListed,e._sessionToken=n.sessionToken,e._players=n.currentPlayers.map((function(e){return le.fromPlayerModel(e)})),e._interactableControllers=[];var r=[];
1n.interactables.forEach((function(t){if("ConversationArea"===t.type)e._interactableControllers.push($.fromConversationAreaModel(t,e._playersByIDs.bind(e)));else if(function(e){return"ViewingArea"===e.type}(t))e._interactableControllers.push(new ie(t));else if(function(e){return"WhiteboardArea"===e.type}(t)){var n=new oe(t.id,t,e);e._interactableControllers.push(n),r.push(n)}else(function(e){return"TicTacToeArea"===e.type})(t)&&e._interactableControllers.push(new re(t.id,t,e))})),n.interactables.forEach((function(t){if("PictionaryArea"===t.type){var n=r.find((function(e){return e.id==="".concat(t.id,"WhiteboardArea")}));if(!n)throw new Error("PictionaryAreaController is missing it's companion WhiteboardAreaController.");e._interactableControllers.push(new se(t.id,t,e,n))}})),e._userID=n.userID,e._ourPlayer=e.players.find((function(t){return t.id==e.userID})),e.emit("connect",n.providerVideoToken),t()})),e._socket.on("disconnect",(function(){n(new Error("Invalid town ID"))}))}))]}))}))()},o.getWhiteboardAreaController=function(e){var t=this._interactableControllers.find((function(t){return t.id===e}));if((0,v.Z)(t,oe))return t;throw new Error("No such whiteboard area controller with id ".concat(e))},o.getViewingAreaController=function(e){var t=this._interactableControllers.find((function(t){return t.id===e.name}));if((0,v.Z)(t,ie))return t;throw new Error("No such viewing area controller ".concat(t))},o.getConversationAreaController=function(e){var t=this._interactableControllers.find((function(t){return t.id===e.name}));if((0,v.Z)(t,$))return t;throw new Error("No such viewing area controller ".concat(t))},o.getGameAreaController=function(e){var t=this._interactableControllers.find((function(t){return t.id===e.name}));if((0,v.Z)(t,ee))return t;throw new Error("Game area controller not created")},o.emitViewingAreaUpdate=function(e){this._socket.emit("interactableUpdate",e.toInteractableAreaModel())},o.nearbyPlayers=function(){var e=this;return this.players.filter((function(t){return function(t){if(t.location&&e.ourPlayer.location){if(e.ourPlayer.location.interactableID||t.location.interactableID)return t.location.interactableID===e.ourPlayer.location.interactableID;var n=t.location.x-e.ourPlayer.location.x,r=t.location.y-e.ourPlayer.location.y;return Math.sqrt(n*n+r*r)<80}return!1}(t)}))},o._playersByIDs=function(e){return this._playersInternal.filter((function(t){return e.includes(t.id)}))},(0,f.Z)(n,[{key:"sessionToken",get:function(){return this._sessionToken||""}},{key:"userID",get:function(){var e=this._userID;return l()(e),e}},{key:"townIsPubliclyListed",get:function(){return this._townIsPubliclyListedInternal}},{key:"_townIsPubliclyListed",set:function(e){this._townIsPubliclyListedInternal=e,this.emit("townSettingsUpdated",{isPubliclyListed:e})}},{key:"providerVideoToken",get:function(){var e=this._providerVideoToken;return l()(e),e}},{key:"userName",get:function(){return this._userName}},{key:"friendlyName",get:function(){var e=this._friendlyNameInternal;return l()(e),e}},{key:"_friendlyName",set:function(e){this._friendlyNameInternal=e,this.emit("townSettingsUpdated",{friendlyName:e})}},{key:"paused",get:function(){return this._paused}},{key:"ourPlayer",get:function(){var e=this._ourPlayer;return l()(e),e}},{key:"townID",get:function(){return this._townID}},{key:"players",get:function(){return this._playersInternal}},{key:"_players",set:function(e){this.emit("playersChanged",e),this._playersInternal=e}},{key:"conversationAreas",get:function(){return this._interactableControllers.filter((function(e){return(0,v.Z)(e,$)}))}},{key:"interactableEmitter",get:function(){return this._interactableEmitter}},{key:"viewingAreas",get:function(){return this._interactableControllers.filter((function(e){return(0,v.Z)(e,ie)}))}},{key:"whiteboardAreas",get:function(){return this._interactableControllers.filter((function(e){return(0,v.Z)(e,oe)}))}},{key:"gameAreas",get:function(){return this._interactableControllers.filter((function(e){return(0,v.Z)(e,ee)}))}}]),n}(b());function de(e){var t=J(),n=(0,x.Z)(t.gameAreas).concat((0,x.Z)(t.whiteboardAreas)).find((function(t){return t.id==e}));if(!n)throw new Error("Requested interactable area ".concat(e," does not exist"));return n}function he(){var e=J(),t=(0,u.useState)(e.players),n=t[0],r=t[1];return(0,u.useEffect)((function(){return e.addListener("playersChanged",r),function(){e.removeListener("playersChanged",r)}}),[e,r]),n}function fe(e){var t=J(),n=(0,u.useState)(void 0),r=n[0],i=n[1];return(0,u.useEffect)((function(){var n=function(e){i(e)},r=function(){i(void 0)};return t.interactableEmitter.on(e,n),t.interactableEmitter.on("endInteraction",r),function(){t.interactableEmitter.off(e,n),t.interactableEmitter.off("endInteraction",r)}}),[e,t,i]),r}function pe(){var e=J(),t=(0,u.useState)([]),n=t[0],r=t[1];return(0,u.useEffect)((function(){var t=0,n=[],i=function(){var i=Date.now();if(i-t>300){t=i;var o=e.nearbyPlayers();(function(e,t){if(e.length!==t.length)return!1;var n=e.map((function(e){return e.id})).sort(),r=t.map((function(e){return e.id})).sort();return j().isEqual(n,r)})(o,n)||(n=o,r(o))}};return e.addListener("playerMoved",i),e.addListener("playersChanged",i),i(),function(){e.removeListener("playerMoved",i),e.removeListener("playersChanged",i)}}),[e,r]),n}var ve=function(){function e(t){var n=this;(0,h.Z)(this,e),this._callbacks=[],this._coveyTownController=t,this._authorName=t.userName,this._coveyTownController.addListener("chatMessage",(function(e){e.dateCreated=new Date(e.dateCreated),n._onChatMessage(e)}))}var t=e.prototype;return t._onChatMessage=function(e){this._callbacks.forEach((function(t){return t(e)}))},t.sendMessage=function(e){var t={sid:(0,_.x0)(),body:e,author:this._authorName,dateCreated:new Date};this._coveyTownController.emitChatMessage(t)},t.onMessageAdded=function(e){this._callbacks.push(e)},t.offMessageAdded=function(e){this._callbacks=this._callbacks.filter((function(t){return t!==e}))},t.close=function(){this._coveyTownController.removeAllListeners("chatMessage")},e}(),me=(0,u.createContext)(null),ge=function(e){var t=e.children,n=J(),r=(0,u.useRef)(!1),i=(0,u.useState)(!1),a=i[0],s=i[1],c=(0,u.useState)(null),l=c[0],d=c[1],h=(0,u.useState)([]),f=h[0],p=h[1],v=(0,u.useState)(!1),m=v[0],g=v[1];return(0,u.useEffect)((function(){if(l){var e=function(e){return p((function(t){return(0,x.Z)(t).concat([e])}))};return l.onMessageAdded(e),function(){l.offMessageAdded(e)}}}),[l]),(0,u.useEffect)((function(){!r.current&&f.length&&g(!0)}),[f]),(0,u.useEffect)((function(){r.current=a,a&&g(!1)}),[a]),(0,u.useEffect)((function(){var e=new ve(n);return d(e),function(){e.close()}}),[n,d]),(0,o.jsx)(me.Provider,{value:{isChatWindowOpen:a,setIsChatWindowOpen:s,hasUnreadMessages:m,messages:f,conversation:l}
1,children:t})},xe=n(282),we=n(52663),ye=n(29525),be=n(66856),Ce=n(66083),je=n(7212);var _e=function(e){var t=e.dismissError,n=e.error,r=n||{},i=r.message,a=r.code,s=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return 20101===(arguments.length>1?arguments[1]:void 0)?e+". Please make sure you are using the correct credentials.":e}(i,a);return(0,o.jsxs)(we.Z,{open:null!==n,onClose:function(){return t()},fullWidth:!0,maxWidth:"xs",children:[(0,o.jsx)(Ce.Z,{children:"ERROR"}),(0,o.jsxs)(ye.Z,{children:[(0,o.jsx)(je.Z,{children:s}),Boolean(a)&&(0,o.jsx)("pre",{children:(0,o.jsxs)("code",{children:["Error Code: ",a]})})]}),(0,o.jsx)(be.Z,{children:(0,o.jsx)(xe.Z,{onClick:function(){return t()},color:"primary",autoFocus:!0,children:"OK"})})]})},ke=n(51351),Ze=n(41120),Se=n(41749),Te=n(53450);function Pe(){return(0,o.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"73",height:"73",viewBox:"0 0 73 73",children:(0,o.jsxs)("g",{fill:"none",fillRule:"evenodd",children:[(0,o.jsx)("circle",{cx:"36.5",cy:"36.5",r:"36.5",fill:"#FFF"}),(0,o.jsx)("path",{fill:"#282A2B",strokeLinejoin:"round",d:"M30.973 23.925c-3.162 3.794-3.162 9.886 0 13.68l.262.301c.266.293.548.564.842.812l.192.154v2.95l-6.71 2.397-.213.082c-2.03.834-3.346 2.793-3.346 4.97v2.766c0 .532.431.963.963.963h27.874c.531 0 .962-.431.962-.963V49.27l-.005-.228-.015-.233c-.187-2.092-1.562-3.883-3.539-4.59l-6.71-2.397v-2.95l.192-.154c.393-.33.762-.702 1.104-1.112 3.162-3.795 3.162-9.887 0-13.681-3.25-3.9-8.603-3.9-11.853 0zm10.374 1.232c2.567 3.08 2.567 8.135 0 11.216-.404.484-.85.894-1.328 1.226-.26.18-.414.476-.414.791v4.111c0 .407.255.77.639.907l7.348 2.625c1.314.47 2.213 1.687 2.278 3.077l.004.183v1.781h-25.95l.002-1.804c0-1.394.843-2.65 2.131-3.18l.172-.065 7.327-2.617c.383-.137.639-.5.639-.907v-4.11c0-.316-.155-.612-.415-.792-.478-.332-.924-.742-1.328-1.226-2.567-3.08-2.567-8.135 0-11.216 2.427-2.912 6.248-2.974 8.735-.186l.16.186z"})]})})}var Ie=n(22318),Ee=(0,u.createContext)(null);function Le(){var e=(0,u.useContext)(Ee);return[e[0],e[1]]}function Ae(e){var t=e.room,n=e.children,r=(0,u.useState)(null),i=r[0],a=r[1];return(0,u.useEffect)((function(){if(t){var e=function(){return a(null)},n=function(e){return a((function(t){return t===e?null:t}))};return t.on("disconnected",e),t.on("participantDisconnected",n),function(){t.off("disconnected",e),t.off("participantDisconnected",n)}}}),[t]),(0,o.jsx)(Ee.Provider,{value:[i,function(e){return a((function(t){return t===e?null:e}))}],children:n})}var Ne=n(90111),De="undefined"!==typeof navigator&&"string"===typeof navigator.userAgent&&/Mobile/.test(navigator.userAgent);function Oe(e){if(!(0,Ne.P)(e))return e;var t={};for(var n in e){var r=e[n];"undefined"!==typeof r&&(t[n]=Oe(r))}return t}function Re(){return Be.apply(this,arguments)}function Be(){return(Be=(0,r.Z)((function(){var e;return(0,i.__generator)(this,(function(t){switch(t.label){case 0:return[4,navigator.mediaDevices.enumerateDevices()];case 1:return[2,{audioInputDevices:(e=t.sent()).filter((function(e){return"audioinput"===e.kind})),videoInputDevices:e.filter((function(e){return"videoinput"===e.kind})),audioOutputDevices:e.filter((function(e){return"audiooutput"===e.kind})),hasAudioInputDevices:e.some((function(e){return"audioinput"===e.kind})),hasVideoInputDevices:e.some((function(e){return"videoinput"===e.kind}))}]}}))}))).apply(this,arguments)}function Me(e){return Fe.apply(this,arguments)}function Fe(){return(Fe=(0,r.Z)((function(e){var t;return(0,i.__generator)(this,(function(n){switch(n.label){case 0:if(t=e,!navigator.permissions)return[3,5];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,navigator.permissions.query({name:t})];case 2:return[2,"denied"===n.sent().state];case 3:return n.sent(),[2,!1];case 4:return[3,6];case 5:return[2,!1];case 6:return[2]}}
1))}))).apply(this,arguments)}function Ve(){var e=Qe(),t=e.room,n=e.localTracks,r=e.getLocalVideoTrack,i=e.removeLocalVideoTrack,o=e.onError,a=null===t||void 0===t?void 0:t.localParticipant,s=n.find((function(e){return!e.name.includes("screen")&&"video"===e.kind})),c=(0,u.useState)(!1),l=c[0],d=c[1],h=(0,u.useCallback)((function(){if(!l)if(s){var e=null===a||void 0===a?void 0:a.unpublishTrack(s);null===a||void 0===a||a.emit("trackUnpublished",e),i()}else d(!0),r().then((function(e){return null===a||void 0===a?void 0:a.publishTrack(e,{priority:"low"})})).catch(o).finally((function(){d(!1)}))}),[s,a,r,l,o,i]);return[!!s,h]}function We(){var e=Qe().room,t=(0,T.Z)(Ve(),2),n=t[0],r=t[1],i=(0,u.useRef)(!1);return(0,u.useEffect)((function(){if(e&&De){var t=function(){"hidden"===document.visibilityState&&n?(i.current=!0,r()):i.current&&(i.current=!1,r())};return document.addEventListener("visibilitychange",t),function(){document.removeEventListener("visibilitychange",t)}}}),[n,e,r]),null}var ze={width:1280,height:720,frameRate:24},Ue="TwilioVideoApp-selectedAudioInput",Ge="TwilioVideoApp-selectedAudioOutput",He="TwilioVideoApp-selectedVideoInput";new Map;var Xe=n(98445),Ke=n.n(Xe);var qe=n(66893);window.TwilioVideo=Ke();var Ye=(0,u.createContext)(null);function Je(e){var t=e.options,n=e.children,a=e.onError,s=void 0===a?function(){}:a,c=e.onDisconnect,l=void 0===c?function(){}:c,d=(0,u.useCallback)((function(e){console.log("ERROR: ".concat(e.message),e),s(e)}),[s]),h=function(){var e=(0,u.useState)(),t=e[0],n=e[1],o=(0,u.useState)(),a=o[0],s=o[1],c=(0,u.useState)(!1),l=c[0],d=c[1],h=(0,u.useCallback)((function(e){var t={};return e&&(t.deviceId={exact:e}),Ke().createLocalAudioTrack(t).then((function(e){return n(e),e}))}),[]),f=(0,u.useCallback)((0,r.Z)((function(){var e,t,n,r;return(0,i.__generator)(this,(function(i){switch(i.label){case 0:return e=window.localStorage.getItem(He),[4,Re()];case 1:return t=i.sent().videoInputDevices,n=t.some((function(t){return e&&t.deviceId===e})),r=(0,m.Z)((0,g.Z)((0,m.Z)({},ze),{name:"camera-".concat(Date.now())}),n&&{deviceId:{exact:e}}),[2,Ke().createLocalVideoTrack(r).then((function(e){return s(e),e}))]}}))})),[]),p=(0,u.useCallback)((function(){t&&(t.stop(),n(void 0))}),[t]),v=(0,u.useCallback)((function(){a&&(a.stop(),s(void 0))}),[a]),x=(0,u.useCallback)((0,r.Z)((function(){var e,r,o,c,u,h,f,p,v,x,w,y,b;return(0,i.__generator)(this,(function(i){switch(i.label){case 0:return[4,Re()];case 1:return e=i.sent(),r=e.audioInputDevices,o=e.videoInputDevices,c=e.hasAudioInputDevices,u=e.hasVideoInputDevices,c||u?l||t||a?[2,Promise.resolve()]:(d(!0),h=window.localStorage.getItem(Ue),f=window.localStorage.getItem(He),p=r.some((function(e){return h&&e.deviceId===h})),v=o.some((function(e){return f&&e.deviceId===f})),[4,Me("camera")]):[2,Promise.resolve()];case 2:return x=i.sent(),[4,Me("microphone")];case 3:return w=i.sent(),y=c&&!w,b={video:u&&!x&&(0,m.Z)((0,g.Z)((0,m.Z)({},ze),{name:"camera-".concat(Date.now())}),v&&{deviceId:{exact:f}}),audio:y&&(p?{deviceId:{exact:h}}:c)},[2,Ke().createLocalTracks(b).then((function(e){var t,r=e.find((function(e){return"video"===e.kind})),i=e.find((function(e){return"audio"===e.kind}));if(r&&(s(r),window.localStorage.setItem(He,null!==(t=r.mediaStreamTrack.getSettings().deviceId)&&void 0!==t?t:"")),i&&n(i),x&&w){var o=new Error;throw o.name="NotAllowedError",o}if(x)throw new Error("CameraPermissionsDenied");if(w)throw new Error("MicrophonePermissionsDenied")})).finally((function(){return d(!1)}))]}}))})),[t,a,l]);return{localTracks:[t,a].filter((function(e){return void 0!==e})),getLocalVideoTrack:f,getLocalAudioTrack:h,isAcquiringLocalTracks:l,removeLocalAudioTrack:p,removeLocalVideoTrack:v,getAudioAndVideoTracks:x}}(),f=h.localTracks,p=h.getLocalVideoTrack,v=h.getLocalAudioTrack,x=h.isAcquiringLocalTracks,w=h.removeLocalAudioTrack,y=h.removeLocalVideoTrack,b=h.getAudioAndVideoTracks,C=function(e,t,n){var r=(0,u.useState)(null),i=r[0],o=r[1],a=(0,u.useState)(!1),s=a[0],c=a[1],l=(0,u.useRef)(n);return(0,u.useEffect)((function(){l.current=n}),[n]),{room:i,isConnecting:s,connect:(0,u.useCallback)((function(n){return c(!0),Ke().connect(n,(0,g.Z)((0,m.Z)({},l.current),{tracks:e})).then((function(e){o(e),qe.VideoRoomMonitor.registerVideoRoom(e);var t=function(){return e.disconnect()};e.setMaxListeners(15),e.once("disconnected",(function(){setTimeout((function(){return o(null)})),window.removeEventListener("beforeunload",t),De&&window.removeEventListener("pagehide",t)})),window.twilioRoom=e,e.localParticipant.videoTracks.forEach((function(e){return e.setPriority("low")})),c(!1),window.addEventListener("beforeunload",t),De&&window.addEventListener("pagehide",t)}),(function(e){t(e),c(!1)}))}),[e,t])}}(f,d,t),j=C.room,_=C.isConnecting,k=C.connect,Z=(0,T.Z)(function(e,t){var n=(0,u.useState)(!1),r=n[0],i=n[1],o=(0,u.useRef)(null),a=(0,u.useCallback)((function(){navigator.mediaDevices.getDisplayMedia({audio:!1,video:{frameRate:10,height:1080,width:1920}}).then((function(n){var r=n.getTracks()[0];e.localParticipant.publishTrack(r,{name:"screen",priority:"low"}).then((function(t){o.current=function(){e.localParticipant.unpublishTrack(r),e.localParticipant.emit("trackUnpublished",t),r.stop(),i(!1)},r.onended=o.current,i(!0)})).catch(t)})).catch((function(e){"AbortError"!==e.name&&"NotAllowedError"!==e.name&&t(e)}))}),[e,t]),s=(0,u.useCallback)((function(){e&&(r?o.current():a())}),[r,a,e]);return[r,s]}(j,s),2),S=Z[0],P=Z[1];!function(e,t,n,r,i,o,a){(0,u.useEffect)((function(){if(e){var s=function(e,s){s&&t(s),n(),r(),i&&o(),a()};return e.on("disconnected",s),function(){e.off("disconnected",s)}}}),[e,t,n,r,i,o,a])}(j,s,w,y,S,P,l),function(e,t){(0,u.useEffect)((function(){if(e)return e.localParticipant.on("trackPublicationFailed",t),function(){e.localParticipant.off("trackPublicationFailed",t)}}),[e,t])}(j,s),function(e){var t=e.find((function(e){return"audio"===e.kind}));(0,u.useEffect)((function(){var e=function(){"ended"===(null===t||void 0===t?void 0:t.mediaStreamTrack.readyState)&&t.restart({})};return navigator.mediaDevices.addEventListener("devicechange",e),function(){navigator.mediaDevices.removeEventListener("devicechange",e)}}),[t])}(f);var I=(0,u.useState)(!1),E=I[0],L=I[1],A=f.find((function(e){return!e.name.includes("screen")&&"video"===e.kind})),N=(0,T.Z)(function(e,t){var n=(0,u.useState)((function(){var e=window.localStorage.getItem("TwilioVideoApp-selectedBackgroun
1dSettings");return e?JSON.parse(e):{type:"none",index:0}})),r=n[0],i=n[1],o=(0,u.useCallback)((function(){e&&e.processor&&e.removeProcessor(e.processor)}),[e]);return(0,u.useCallback)((function(t){e&&e.processor!==t&&(o(),e.addProcessor(t))}),[e,o]),[r,i]}(A),2),D=N[0],O=N[1];return(0,o.jsxs)(Ye.Provider,{value:{room:j,localTracks:f,isConnecting:_,onError:d,onDisconnect:l,getLocalVideoTrack:p,getLocalAudioTrack:v,connect:k,isAcquiringLocalTracks:x,removeLocalVideoTrack:y,isSharingScreen:S,toggleScreenShare:P,getAudioAndVideoTracks:b,isBackgroundSelectionOpen:E,setIsBackgroundSelectionOpen:L,backgroundSettings:D,setBackgroundSettings:O},children:[(0,o.jsx)(Ae,{room:j,children:n}),(0,o.jsx)(We,{})]})}function Qe(){var e=(0,u.useContext)(Ye);if(!e)throw new Error("useVideoContext must be used within a VideoProvider");return e}var $e=n(48318);function et(e){var t=(0,u.useState)(!!e&&e.isEnabled),n=t[0],r=t[1];return(0,u.useEffect)((function(){if(r(!!e&&e.isEnabled),e){var t=function(){return r(!0)},n=function(){return r(!1)};return e.on("enabled",t),e.on("disabled",n),function(){e.off("enabled",t),e.off("disabled",n)}}}),[e]),n}function tt(e){var t=(0,u.useState)(null===e||void 0===e?void 0:e.mediaStreamTrack),n=t[0],r=t[1];return(0,u.useEffect)((function(){if(r(null===e||void 0===e?void 0:e.mediaStreamTrack),e){var t=function(){return r(e.mediaStreamTrack)};return e.on("started",t),function(){e.off("started",t)}}}),[e]),n}var nt,rt=0;function it(e){var t=window.AudioContext||window.webkitAudioContext,n=(nt=nt||new t).createMediaStreamSource(e),r=nt.createAnalyser();return r.smoothingTimeConstant=.2,r.fftSize=256,n.connect(r),r}function ot(e){var t=e.audioTrack,n=e.color,r=void 0===n?"white":n,i=(0,u.useRef)(null),a=(0,u.useState)(),s=a[0],c=a[1],l=et(t),d=tt(t);(0,u.useEffect)((function(){if(t&&d&&l){var e=new MediaStream([d.clone()]),n=function(){return e.getTracks().forEach((function(e){return e.stop()}))};t.on("stopped",n);var r=function(){n(),e=new MediaStream([d.clone()]),c(it(e))};return c(it(e)),window.addEventListener("focus",r),function(){n(),window.removeEventListener("focus",r),t.off("stopped",n)}}}),[l,d,t]),(0,u.useEffect)((function(){var e=i.current;if(l&&e&&s){var t=new Uint8Array(s.frequencyBinCount),n=(0,$e.Z)((function(){s.getByteFrequencyData(t);for(var n=0,r=t.length,i=0;i<r;i++)n+=t[i];var o=Math.min(14,Math.max(0,7*Math.log10(n/r/3)));null===e||void 0===e||e.setAttribute("y",String(14-o))}),100);return function(){e.setAttribute("y","14"),n.stop()}}}),[l,s]);var h="audio-level-clip-".concat(rt++);return l?(0,o.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24","data-test-audio-indicator":!0,children:[(0,o.jsx)("defs",{children:(0,o.jsx)("clipPath",{id:h,children:(0,o.jsx)("rect",{ref:i,x:"0",y:"14",width:"24",height:"24"})})}),(0,o.jsxs)("g",{fill:"none",fillRule:"evenodd",transform:"translate(.5)",children:[(0,o.jsx)("rect",{clipPath:"url(#".concat(h,")"),width:"5.2",height:"10",x:"9.5",y:"3.5",rx:"6",ry:"3",fill:"#23BF6E"}),(0,o.jsx)("path",{fill:r,strokeWidth:"0",d:"M17.389 10.667c.276 0 .5.224.5.5 0 3.114-2.396 5.67-5.445 5.923v2.632c0 .276-.223.5-.5.5-.245 0-.45-.177-.491-.41l-.009-.09V17.09C8.395 16.836 6 14.281 6 11.167c0-.276.224-.5.5-.5s.5.224.5.5c0 2.73 2.214 4.944 4.944 4.944 2.731 0 4.945-2.214 4.945-4.944 0-.276.224-.5.5-.5zM11.944 4c1.566 0 2.834 1.268 2.834 2.833v4.334c0 1.564-1.268 2.833-2.834 2.833-1.564 0-2.833-1.27-2.833-2.833V6.833C9.111 5.268 10.38 4 11.944 4zm0 1c-1.012 0-1.833.82-1.833 1.833v4.334c0 1.012.822 1.833 1.833 1.833 1.013 0 1.834-.82 1.834-1.833V6.833c0-1.013-.82-1.833-1.834-1.833z"})]})]}):(0,o.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",transform:"translate(-0.5, 0)","data-test-audio-mute-icon":!0,children:(0,o.jsxs)("g",{fill:"none",fillRule:"evenodd",children:[(0,o.jsx)("path",{fill:r,strokeWidth:"0",d:"M11.889 6.667c.276 0 .5.224.5.5 0 3.114-2.396 5.67-5.445 5.923v2.632c0 .276-.223.5-.5.5-.245 0-.45-.177-.491-.41l-.009-.09V13.09c-1.116-.093-2.145-.494-3-1.119l.717-.717c.793.54 1.751.857 2.783.857 2.731 0 4.945-2.214 4.945-4.944 0-.276.224-.5.5-.5zM1 6.667c.276 0 .5.224.5.5 0 .975.282 1.884.77 2.65l-.722.721C.888 9.58.5 8.418.5 7.167c0-.276.224-.5.5-.5zm8.277-1.031v1.53C9.278 8.732 8.01 10 6.445 10c-.446 0-.868-.103-1.243-.287l.776-.773c.149.039.306.06.467.06.963 0 1.751-.74 1.828-1.683l.006-.15v-.531l1-1zM6.444 0C8.01 0 9.278 1.268 9.278 2.833l-.002-.025-.999.999v-.974c0-.962-.74-1.75-1.682-1.827L6.445 1c-.962 0-1.751.74-1.828 1.683l-.006.15v4.334c0 .097.008.192.022.285l-.804.805c-.112-.269-.184-.558-.209-.86l-.009-.23V2.833C3.611 1.268 4.88 0 6.444 0z",transform:"translate(6.5 4)"}),(0,o.jsx)("path",{fill:"red",strokeWidth:"0",d:"M12.146.646c.196-.195.512-.195.708 0 .173.174.192.443.057.638l-.057.07-12 12c-.196.195-.512.195-.708 0-.173-.174-.192-.443-.057-.638l.057-.07 12-12z",transform:"translate(6.5 4)"})]})})}var at=u.memo(ot);function st(){var e=Qe().localTracks.find((function(e){return"audio"===e.kind}));return(0,o.jsx)(at,{audioTrack:e})}var ct=n(34266);var lt=(0,ct.Z)("video")({width:"100%",height:"100%"});function ut(e){var t,n,r=e.track,i=e.isLocal,a=e.priority,s=(0,u.useRef)(null),c=tt(r),l=function(e){var t=(0,u.useState)(null===e||void 0===e?void 0:e.dimensions),n=t[0],r=t[1];return(0,u.useEffect)((function(){if(r(null===e||void 0===e?void 0:e.dimensions),e){var t=function(e){return r({width:e.dimensions.width,height:e.dimensions.height})};return e.on("dimensionsChanged",t),function(){e.off("dimensionsChanged",t)}}}),[e]),n}(r),d=(null!==(t=null===l||void 0===l?void 0:l.height)&&void 0!==t?t:0)>(null!==(n=null===l||void 0===l?void 0:l.width)&&void 0!==n?n:0);(0,u.useEffect)((function(){var e=s.current;return e.muted=!0,r.setPriority&&a&&r.setPriority(a),r.attach(e),function(){r.detach(e),e.srcObject=null,r.setPriority&&a&&r.setPriority(null)}}),[r,a]);var h="environment"!==(null===c||void 0===c?void 0:c.getSettings().facingMode),f={transform:i&&h?"rotateY(180deg)":"",objectFit:d||r.name.includes("screen")?"contain":"cover"};return(0,o.jsx)(lt,{ref:s,style:f})}var dt=(0,Ze.Z)((function(e){return{container:{position:"relative",height:0,overflow:"hidden",paddingTop:"".concat(56.25,"%"),background:"black"},innerContainer:{position:"absolute",top:0,left:0,width:"100%",height:"100%"},identityContainer:{position:"absolute",bottom:0,zIndex:1},identity:{background:"rgba(0, 0, 0, 0.5)",color:"white",padding:"0.18em 0.3em",margin:0,display:"flex",alignItems:"center"},avatarContainer:(0,S.Z)({display:"flex",alignItems:"center",justifyContent:"center",background:"black",position:"absolute",top:0,right:0,bottom:0,left:0,zIndex:1},e.breakpoints.down("sm"),{"& svg":{transform:"scale(0.7)"}})}}));function ht(e){var t=e.identity,n=dt(),r=Qe().localTracks.find((function(e){return!e.name.includes("screen")&&"video"===e.kind}));return(0,o.jsxs)("div",{className:n.container,children:[(0,o.jsx)("div",{className:n.innerContainer,children:r?(0,o.jsx)(ut,{track:r,
1isLocal:!0}):(0,o.jsx)("div",{className:n.avatarContainer,children:(0,o.jsx)(Pe,{})})}),(0,o.jsx)("div",{className:n.identityContainer,children:(0,o.jsxs)("span",{className:n.identity,children:[(0,o.jsx)(st,{}),(0,o.jsx)(Ie.Z,{variant:"body1",color:"inherit",component:"span",children:t})]})})]})}var ft=n(8202),pt=n(37702),vt=n(78513),mt=n(63457),gt=n(55517),xt={trackSwitchOffMode:void 0,dominantSpeakerPriority:"standard",bandwidthProfileMode:"collaboration",maxAudioBitrate:"16000",contentPreferencesMode:"auto",clientTrackSwitchOffControl:"auto"},wt=function(){var e={};for(var t in xt)e[t]=t;return e}();function yt(e,t){return(0,g.Z)((0,m.Z)({},e),(0,S.Z)({},t.name,"default"===t.value?void 0:t.value))}function bt(){var e=(0,u.useState)({audioInputDevices:[],videoInputDevices:[],audioOutputDevices:[],hasAudioInputDevices:!1,hasVideoInputDevices:!1}),t=e[0],n=e[1];return(0,u.useEffect)((function(){var e=function(){return Re().then((function(e){return n(e)}))};return navigator.mediaDevices.addEventListener("devicechange",e),e(),function(){navigator.mediaDevices.removeEventListener("devicechange",e)}}),[]),t}var Ct=n(83454),jt=(0,u.createContext)(null);function _t(e){var t=(0,u.useState)(null),n=t[0],a=t[1],s=(0,u.useState)(!1),c=s[0],l=s[1],d=(0,T.Z)(function(){var e=bt().audioOutputDevices,t=(0,u.useState)("default"),n=t[0],r=t[1],i=(0,u.useCallback)((function(e){window.localStorage.setItem(Ge,e),r(e)}),[]);return(0,u.useEffect)((function(){var t=window.localStorage.getItem(Ge);e.some((function(e){return t&&e.deviceId===t}))&&r(t)}),[e]),[n,i]}(),2),h=d[0],f=d[1],p=(0,u.useReducer)(yt,xt),v=p[0],x=p[1],w=(0,u.useState)(),y=w[0],b=w[1],C={error:n,setError:a,isFetching:c,activeSinkId:h,setActiveSinkId:f,settings:v,dispatchSetting:x,roomType:y};C=(0,g.Z)((0,m.Z)({},C),{getToken:function(){var e=(0,r.Z)((function(e,t){var n;return(0,i.__generator)(this,(function(r){return n=Ct.env.REACT_APP_TOKEN_ENDPOINT||"/token",[2,fetch(n,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({user_identity:e,room_name:t,create_conversation:"true"!==Ct.env.REACT_APP_DISABLE_TWILIO_CONVERSATIONS})}).then((function(e){return e.json()}))]}))}));return function(t,n){return e.apply(this,arguments)}}(),updateRecordingRules:function(){var e=(0,r.Z)((function(e,t){var n;return(0,i.__generator)(this,(function(o){return n=Ct.env.REACT_APP_TOKEN_ENDPOINT||"/recordingrules",[2,fetch(n,{headers:{"Content-Type":"application/json"},body:JSON.stringify({room_sid:e,rules:t}),method:"POST"}).then(function(){var e=(0,r.Z)((function(e){var t,n,r,o;return(0,i.__generator)(this,(function(i){switch(i.label){case 0:return[4,e.json()];case 1:return t=i.sent(),e.ok?[2,t]:((o=new Error((null===(n=t.error)||void 0===n?void 0:n.message)||"There was an error updating recording rules")).code=null===(r=t.error)||void 0===r?void 0:r.code,[2,Promise.reject(o)])}}))}));return function(t){return e.apply(this,arguments)}}()).catch((function(e){return a(e)}))]}))}));return function(t,n){return e.apply(this,arguments)}}()});return(0,o.jsx)(jt.Provider,{value:(0,g.Z)((0,m.Z)({},C),{getToken:function(e,t){return l(!0),C.getToken(e,t).then((function(e){return b(e.room_type),l(!1),e})).catch((function(e){return a(e),l(!1),Promise.reject(e)}))},updateRecordingRules:function(e,t){return l(!0),C.updateRecordingRules(e,t).then((function(e){return l(!1),e})).catch((function(e){return a(e),l(!1),Promise.reject(e)}))}}),children:e.children})}function kt(){var e=(0,u.useContext)(jt);if(!e)throw new Error("useAppState must be used within the AppStateProvider");return e}var Zt=n(83454);var St=function(e){var t=e.open,n=e.onClose,r=kt().roomType;return(0,o.jsxs)(we.Z,{open:t,onClose:n,fullWidth:!0,maxWidth:"xs",children:[(0,o.jsx)(Ce.Z,{children:"About"}),(0,o.jsx)(gt.Z,{}),(0,o.jsxs)(ye.Z,{children:[(0,o.jsxs)(je.Z,{children:["Browser supported: ",String(Ke().isSupported)]}),(0,o.jsxs)(je.Z,{children:["SDK Version: ",Ke().version]}),(0,o.jsxs)(je.Z,{children:["Deployed Tag: ",Zt.env.REACT_APP_GIT_TAG||"N/A"]}),(0,o.jsxs)(je.Z,{children:["Deployed Commit Hash: ",Zt.env.REACT_APP_GIT_COMMIT||"N/A"]}),r&&(0,o.jsxs)(je.Z,{children:["Room Type: ",r]})]}),(0,o.jsx)(gt.Z,{}),(0,o.jsx)(be.Z,{children:(0,o.jsx)(xe.Z,{onClick:n,color:"primary",variant:"contained",autoFocus:!0,children:"OK"})})]})},Tt=n(64436),Pt=n(85161),It=n(94924),Et=n(33426);function Lt(){var e=Qe().room,t=(0,u.useState)("disconnected"),n=t[0],r=t[1];return(0,u.useEffect)((function(){if(e){var t=function(){return r(e.state)};return t(),e.on("disconnected",t).on("reconnected",t).on("reconnecting",t),function(){e.off("disconnected",t).off("reconnected",t).off("reconnecting",t)}}}),[e]),n}var At=(0,Ze.Z)((function(e){var t;return{container:(t={width:"600px",minHeight:"400px"},(0,S.Z)(t,e.breakpoints.down("xs"),{width:"calc(100vw - 32px)"}),(0,S.Z)(t,"& .inputSelect",{width:"calc(100% - 35px)"}),t),button:{float:"right"},paper:(0,S.Z)({},e.breakpoints.down("xs"),{margin:"16px"}),formControl:{display:"block",margin:"1.5em 0","&:first-child":{margin:"0 0 1.5em 0"}},label:{width:"133%"}}})),Nt=function(e){return"undefined"===typeof e?"default":e};function Dt(e){var t=e.open,n=e.onClose,r=At(),i=kt(),a=i.settings,s=i.dispatchSetting,c="disconnected"!==Lt(),l=(0,u.useCallback)((function(e){s({name:e.target.name,value:e.target.value})}),[s]),d=(0,u.useCallback)((function(e){/[^\d]/.test(e.target.value)||l(e)}),[l]);return(0,o.jsxs)(we.Z,{open:t,onClose:n,classes:{paper:r.paper},children:[(0,o.jsx)(Ce.Z,{children:"Connection Settings"}),(0,o.jsx)(gt.Z,{}),(0,o.jsx)(ye.Z,{className:r.container,children:(0,o.jsxs)(Se.Z,{container:!0,spacing:2,children:[(0,o.jsx)(Se.Z,{item:!0,xs:12,children:(0,o.jsx)(Ie.Z,{hidden:!c,variant:"body2",children:"These settings cannot be changed when connected to a room."})}),(0,o.jsxs)(Se.Z,{item:!0,sm:6,xs:12,children:[(0,o.jsxs)(Tt.Z,{className:r.formControl,children:[(0,o.jsx)(Pt.Z,{id:wt.dominantSpeakerPriority,children:"Dominant Speaker Priority:"}),(0,o.jsxs)(It.Z,{fullWidth:!0,disabled:c,name:wt.dominantSpeakerPriority,label:wt.dominantSpeakerPriority,value:Nt(a.dominantSpeakerPriority),onChange:l,children:[(0,o.jsx)(pt.Z,{value:"low",children:"Low"}),(0,o.jsx)(pt.Z,{value:"standard",children:"Standard"}),(0,o.jsx)(pt.Z,{value:"high",children:"High"}),(0,o.jsx)(pt.Z,{value:"default",children:"Server Default"})]})]}),(0,o.jsxs)(Tt.Z,{className:r.formControl,children:[(0,o.jsx)(Pt.Z,{id:wt.trackSwitchOffMode,children:"Track Switch Off Mode:"}),(0,o.jsxs)(It.Z,{fullWidth:!0,disabled:c,name:wt.trackSwitchOffMode,label:wt.trackSwitchOffMode,value:Nt(a.trackSwitchOffMode),onChange:l,children:[(0,o.jsx)(pt.Z,{value:"predicted",children:"Predicted"}),(0,o.jsx)(pt.Z,{value:"detected",children:"Detected"}),(0,o.jsx)(pt.Z,{value:"disabled",children:"Disabled"}),(0,o.jsx)(pt.Z,{value:"default",children:"Server Default"})]})]}),(0,o.jsxs)(Tt.Z,{className:r.formControl,children:[(0,o.jsx)(Pt.Z,{id:wt.bandwidthProfileMode,children:"Mode:"}),(0,o.jsxs)(It.Z,{fullWidth:!0,disabled:c,name:wt.bandwidthProfileMode,label:wt.bandwidthProfileMode,value:Nt(a.bandwidthProfileMode),onChange:l,children:[(0,o.jsx)(pt.Z,{value:"grid",children:"Grid"}),(0,o.jsx)(pt.Z,{value:"collaboration",children:"Collaboration"}),(0,o.jsx)(pt.Z,{value:"presentation",children:"Presentation"}),(0,o.jsx)(pt.Z,{value:"default",children:"Server Default"})]})]})]}),(0,o.jsxs)(Se.Z,{item:!0,sm:6,xs:12,children:[(0,o.jsxs)(Tt.Z,{className:r.formControl,children:[(0,o.jsx)(Pt.Z,{id:wt.clientTrackSwitchOffControl,children:"Client Track Switch Off Control:"}),(0,o.jsxs)(It.Z,{fullWidth:!0,disabled:c,name:wt.clientTrackSwitchOffControl,label:wt.clientTrackSwitchOffControl,value:Nt(a.clientTrackSwitchOffControl),onChange:l,children:[(0,o.jsx)(pt.Z,{value:"auto",children:"Auto"}),(0,o.jsx)(pt.Z,{value:"manual",children:"Manual"}),(0,o.jsx)(pt.Z,{value:"default",children:"Default"})]})]}),(0,o.jsxs)(Tt.Z,{className:r.formControl,children:[(0,o.jsx)(Pt.Z,{id:wt.contentPreferencesMode,children:"Content Preferences Mode:"}),(0,o.jsxs)(It.Z,{fullWidth:!0,disabled:c,name:wt.contentPreferencesMode,label:wt.contentPreferencesMode,value:Nt(a.contentPreferencesMode),onChange:l,children:[(0,o.jsx)(pt.Z,{value:"auto",children:"Auto"}),(0,o.jsx)(pt.Z,{value:"manual",children:"Manual"}),(0,o.jsx)(pt.Z,{value:"default",children:"Default"})]})]}),(0,o.jsx)(Tt.Z,{className:r.formControl,children:(0,o.jsx)(Et.Z,{disabled:c,fullWidth:!0,id:wt.maxAudioBitrate,label:"Max Audio Bitrate",placeholder:"Leave blank for no limit",name:wt.maxAudioBitrate,value:Nt(a.maxAudioBitrate),onChange:d})})]})]})}),(0,o.jsx)(gt.Z,{}),(0,o.jsx)(be.Z,{children:(0,o.jsx)(xe.Z,{className:r.button,color:"primary",variant:"contained",onClick:n,children:"Done"})})]})}function Ot(){var e=bt().audioInputDevices,t=Qe().localTracks.find((function(e){return"audio"===e.kind})),n=tt(t),r=null===n||void 0===n?void 0:n.getSettings().deviceId;return(0,o.jsxs)("div",{children:[(0,o.jsx)(Ie.Z,{variant:"subtitle2",gutterBottom:!0,children:"Audio Input"}),(0,o.jsxs)(Se.Z,{container:!0,alignItems:"center",justifyContent:"space-between",children:[(0,o.jsx)("div",{className:"inputSelect",children:e.length>1?(0,o.jsx)(Tt.Z,{fullWidth:!0,children:(0,o.jsx)(It.Z,{onChange:function(e){return n=e.target.value,console.log(n),window.localStorage.setItem(Ue,n),null===t||void 0===t||t.restart({deviceId:{exact:n}}),void console.log(t);var n},value:r||"",variant:"outlined",children:e.map((function(e){return(0,o.jsx)(pt.Z,{value:e.deviceId,children:e.label},e.deviceId)}))})}):(0,o.jsx)(Ie.Z,{children:(null===t||void 0===t?void 0:t.mediaStreamTrack.label)||"No Local Audio"})}),(0,o.jsx)(at,{audioTrack:t,color:"black"})]})]})}function Rt(){var e,t=bt().audioOutputDevices,n=kt(),r=n.activeSinkId,i=n.setActiveSinkId,a=null===(e=t.find((function(e){return e.deviceId===r})))||void 0===e?void 0:e.label;return(0,o.jsx)("div",{className:"inputSelect",children:t.length>1?(0,o.jsxs)(Tt.Z,{fullWidth:!0,children:[(0,o.jsx)(Ie.Z,{variant:"subtitle2",gutterBottom:!0,children:"Audio Output"}),(0,o.jsx)(It.Z,{onChange:function(e){return i(e.target.value)},value:r,variant:"outlined",children:t.map((function(e){return(0,o.jsx)(pt.Z,{value:e.deviceId,children:e.label},e.deviceId)}))})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(Ie.Z,{variant:"subtitle2",children:"Audio Output"}),(0,o.jsx)(Ie.Z,{children:a||"System Default Audio Output"})]})})}var Bt=(0,Ze.Z)({preview:{width:"300px",maxHeight:"200px",margin:"0.5em auto","& video":{maxHeight:"200px"}}});function Mt(){var e=Bt(),t=bt().videoInputDevices,n=Qe().localTracks.find((function(e){return"video"===e.kind})),r=tt(n),i=(0,u.useState)(window.localStorage.getItem(He)),a=i[0],s=i[1],c=(null===r||void 0===r?void 0:r.getSettings().deviceId)||a;return(0,o.jsxs)("div",{children:[n&&(0,o.jsx)("div",{className:e.preview,children:(0,o.jsx)(ut,{isLocal:!0,track:n})}),t.length>1?(0,o.jsxs)(Tt.Z,{fullWidth:!0,children:[(0,o.jsx)(Ie.Z,{variant:"subtitle2",gutterBottom:!0,children:"Video Input"}),(0,o.jsx)(It.Z,{onChange:function(e){return t=e.target.value,s(t),window.localStorage.setItem(He,t),void(null===n||void 0===n||n.restart((0,g.Z)((0,m.Z)({},ze),{deviceId:{exact:t}})));var t},value:c||"",variant:"outlined",children:t.map((function(e){return(0,o.jsx)(pt.Z,{value:e.deviceId,children:e.label},e.deviceId)}))})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(Ie.Z,{variant:"subtitle2",gutterBottom:!0,children:"Video Input"}),(0,o.jsx)(Ie.Z,{children:(null===n||void 0===n?void 0:n.mediaStreamTrack.label)||"No Local Video"})]})]})}var Ft=(0,Ze.Z)((function(e){var t;return{container:(t={width:"600px",minHeight:"400px"},(0,S.Z)(t,e.breakpoints.down("xs"),{width:"calc(100vw - 32px)"}),(0,S.Z)(t,"& .inputSelect",{width:"calc(100% - 35px)"}),t),button:{float:"right"},paper:(0,S.Z)({},e.breakpoints.down("xs"),{margin:"16px"}),headline:{marginBottom:"1.3em",fontSize:"1.1rem"},listSection:{margin:"2em 0 0.8em","&:first-child":{margin:"1em 0 2em 0"}}}}));function Vt(e){var t=e.open,n=e.onClose,r=Ft();return(0,o.jsxs)(we.Z,{open:t,onClose:n,classes:{paper:r.paper},children:[(0,o.jsx)(Ce.Z,{children:"Audio and Video Settings"}),(0,o.jsx)(gt.Z,{}),(0,o.jsxs)(ye.Z,{className:r.container,children:[(0,o.jsxs)("div",{className:r.listSection,children:[(0,o.jsx)(Ie.Z,{variant:"h6",className:r.headline,children:"Video"}),(0,o.jsx)(Mt,{})]}),(0,o.jsx)(gt.Z,{}),(0,o.jsxs)("div",{className:r.listSection,children:[(0,o.jsx)(Ie.Z,{variant:"h6",className:r.headline,children:"Audio"}),(0,o.jsx)(Ot,{})]}),(0,o.jsx)("div",{className:r.listSection,children:(0,o.jsx)(Rt,{})})]}),(0,o.jsx)(gt.Z,{}),(0,o.jsx)(be.Z,{children:(0,o.jsx)(xe.Z,{color:"primary",variant:"contained",className:r.button,onClick:n,children:"Done"})})]})}function Wt(){return(0,o.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,o.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.774 14.14L16.3413 13.2506C16.3286 13.2244 16.3173 13.1974 16.3075 13.17C16.1465 12.7274 16.3736 12.2377 16.8155 12.0749L17.7467 11.7347C18.5055 11.4566 19.0077 10.7311 19.0011 9.92278C18.9944 9.11441 18.4804 8.39788 17.7172 8.13314L16.7859 7.81039C16.758 7.80094 16.7306 7.7894 16.7056 7.77843C16.2794 7.57999 16.0942 7.07384 16.2915 6.64668L16.7082 5.74887C17.049 5.01563 16.8921 4.14738 16.3163 3.58049C15.7405 3.0136 14.8703 2.87065 14.1431 3.2235L13.246 3.65462C13.2199 3.66744 13.1931 3.67882 13.1658 3.68869C12.954 3.76821 12.7189 3.75812 12.5148 3.66073C12.3097 3.56606 12.1511 3.39306 12.0746 3.18044L12.0741 3.17844L11.7334 2.25081C11.4547 1.49408 10.7313 
10.994061 9.92513 1.00105C9.119 1.00804 8.40369 1.52053 8.13727 2.28199L7.8091 3.22223C7.79964 3.25006 7.78863 3.27733 7.7761 3.30391C7.57656 3.73058 7.06934 3.91499 6.64288 3.71592L5.74485 3.29868C5.01263 2.96105 4.14713 3.11998 3.58195 3.69585C3.01677 4.27171 2.87367 5.14046 3.22434 5.86685L3.65571 6.76067C3.66851 6.78686 3.67999 6.81368 3.69009 6.84103C3.85069 7.28399 3.62314 7.77372 3.18105 7.9366L2.25109 8.27683C1.74395 8.46368 1.33939 8.85649 1.13749 9.3581C0.935598 9.8597 0.955223 10.4232 1.19151 10.9093C1.41059 11.3666 1.80499 11.7159 2.28525 11.878L3.21579 12.2005C3.24614 12.2114 3.27565 12.2233 3.30063 12.2343C3.72728 12.4329 3.91226 12.9399 3.7139 13.3671L3.29483 14.2675C3.07772 14.742 3.06371 15.2845 3.25603 15.7693C3.44835 16.2542 3.83032 16.6393 4.31342 16.8354C4.34216 16.847 4.3712 16.8578 4.40056 16.8679C4.87879 17.0366 5.40471 17.0069 5.86112 16.7853L6.75557 16.3531C6.78218 16.3402 6.81093 16.3286 6.8356 16.3194C7.04851 16.2445 7.282 16.2542 7.48788 16.3465C7.6933 16.4413 7.85223 16.6144 7.92922 16.8273L8.27064 17.7606C8.55155 18.5147 9.27456 19.0117 10.079 19.0036C10.8834 18.9955 11.5969 18.4841 11.8635 17.7245L12.1864 16.7928C12.1968 16.7627 12.2087 16.7332 12.2201 16.7083C12.4211 16.2836 12.9258 16.099 13.3529 16.2939L14.2494 16.7105C14.9825 17.0512 15.8508 16.8933 16.4177 16.3161C16.9845 15.7389 17.1272 14.8675 16.774 14.14ZM15.4272 15.7438C15.1965 15.8557 14.9279 15.8582 14.6953 15.7505L13.7992 15.334C13.3395 15.1185 12.8127 15.0956 12.3358 15.2705C11.8589 15.4453 11.4714 15.8035 11.2594 16.2653C11.2334 16.3231 11.21 16.381 11.1879 16.4434L10.8648 17.3755C10.7896 17.5889 10.6327 17.7637 10.4286 17.8613C10.2245 17.959 9.9901 17.9714 9.77695 17.8959C9.53792 17.8159 9.34868 17.6308 9.26323 17.3935L8.92318 16.4634C8.74891 15.9867 8.39229 15.5989 7.93192 15.3856C7.47155 15.1724 6.94522 15.1511 6.46891 15.3264C6.40896 15.349 6.35008 15.3734 6.29456 15.4005L5.4017 15.832C5.198 15.9306 4.96337 15.9438 4.75003 15.8685C4.53569 15.7956 4.36017 15.6387 4.26376 15.4338C4.15381 15.2059 4.15081 14.9409 4.25558 14.7105L4.6727 13.8138C4.88722 13.3534 4.9098 12.8267 4.73547 12.3499C4.56113 11.8731 4.20422 11.4855 3.74357 11.2726C3.71568 11.26 3.68725 11.2477 3.65813 11.2359C3.62824 11.2238 3.59766 11.2124 3.56562 11.2012L2.6307 10.8774C2.29028 10.7597 2.06067 10.4405 2.0571 10.0801C2.05353 9.71966 2.27677 9.39575 2.61479 9.2709L3.54421 8.93088C4.05237 8.74551 4.45826 8.35329 4.66113 7.8516C4.864 7.34991 4.8448 6.7858 4.60832 6.29933L4.17719 5.40605C4.0208 5.08228 4.08434 4.69501 4.33601 4.43805C4.58769 4.18109 4.97337 4.1097 5.30004 4.2596L6.19629 4.67569C6.65433 4.89215 7.1799 4.91661 7.65626 4.74364C8.13263 4.57067 8.52036 4.21458 8.73335 3.75445C8.7625 3.69314 8.78809 3.6302 8.80997 3.56594L9.13622 2.6316C9.29214 2.18707 9.77837 1.95273 10.2227 2.10793C10.4645 2.18868 10.6555 2.37645 10.7405 2.61689L11.0804 3.54291C11.2533 4.01887 11.6082 4.40647 12.067 4.62043C12.5257 4.83438 13.0507 4.85716 13.5265 4.68374C13.5885 4.66176 13.6492 4.63608 13.7082 4.60683L14.6033 4.17624C14.8065 4.07688 15.0408 4.06283 15.2542 4.13722C15.4693 4.20945 15.6456 4.36621 15.7425 4.57137C15.8549 4.80183 15.8573 5.07079 15.749 5.30333L15.3321 6.20153C15.1187 6.66179 15.0968 7.18798 15.2714 7.66415C15.446 8.14033 15.8026 8.52742 16.2627 8.74013C16.3185 8.76535 16.3747 8.78849 16.4369 8.81002L17.3702 9.13315C17.7106 9.2515 17.9398 9.57117 17.9428 9.93176C17.9458 10.2924 17.722 10.6161 17.3836 10.7405L16.4524 11.0806C15.4631 11.4445 14.9535 12.54 15.3125 13.5312C15.335 13.5933 15.3607 13.6541 15.3895 13.7135L15.8224 14.6035C15.9214 14.807 15.9353 15.0416 15.8612 15.2555C15.787 15.4694 15.6309 15.6451 15.4272 15.7438L15.4272 15.7438ZM11.3877 6.5684C9.49155 5.80233 7.33291 6.71966 6.5662 8.61733C5.79949 10.515 6.71505 12.6744 8.61116 13.4405C10.5073 14.2065 12.6659 13.2892 13.4326 11.3915C14.197 9.49389 13.2821 7.33617 11.3877 6.5684ZM9.00779 12.4587C7.65343 11.9115 6.99946 10.3691 7.54711 9.01364C8.09476 7.65816 9.63664 7.00292 10.991 7.55012C12.3454 8.09732 12.9993 9.63974 12.4517 10.9952C11.9028 12.3495 10.3621 13.0042 9.00779 12.4587Z",fill:"#606B85"})})}var zt=(0,Ze.Z)({settingsButton:{margin:"1.8em 0 0"}});function Ut(e){var t=e.mobileButtonClass,n=zt(),r=kt().roomType,i=(0,mt.Z)((function(e){return e.breakpoints.down("sm")})),a=(0,u.useState)(!1),s=a[0],c=a[1],l=(0,u.useState)(!1),d=l[0],h=l[1],f=(0,u.useState)(!1),p=f[0],v=f[1],m=(0,u.useState)(!1),g=m[0],x=m[1],w=(0,u.useRef)(null);return(0,o.jsxs)(o.Fragment,{children:[i?(0,o.jsx)(xe.Z,{ref:w,onClick:function(){return c(!0)},startIcon:(0,o.jsx)(vt.Z,{}),className:t,children:"More"}):(0,o.jsx)(xe.Z,{ref:w,onClick:function(){return c(!0)},startIcon:(0,o.jsx)(Wt,{}),className:n.settingsButton,children:"Settings"}),(0,o.jsxs)(ft.Z,{open:s,onClose:function(){return c((function(e){return!e}))},anchorEl:w.current,getContentAnchorEl:null,anchorOrigin:{vertical:"top",horizontal:i?"left":"right"},transformOrigin:{vertical:0,horizontal:"center"},children:[(0,o.jsx)(pt.Z,{onClick:function(){return h(!0)},children:(0,o.jsx)(Ie.Z,{variant:"body1",children:"About"})}),(0,o.jsx)(pt.Z,{onClick:function(){return v(!0)},children:(0,o.jsx)(Ie.Z,{variant:"body1",children:"Audio and Video Settings"})}),"peer-to-peer"!==r&&"go"!==r&&(0,o.jsx)(pt.Z,{onClick:function(){return x(!0)},children:(0,o.jsx)(Ie.Z,{variant:"body1",children:"Connection Settings"})})]}),(0,o.jsx)(St,{open:d,onClose:function(){h(!1),c(!1)}}),(0,o.jsx)(Vt,{open:p,onClose:function(){v(!1),c(!1)}}),(0,o.jsx)(Dt,{open:g,onClose:function(){x(!1),c(!1)}})]})}function Gt(){return(0,o.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"17",viewBox:"0 0 12 17",children:(0,o.jsx)("path",{fill:"#707578",fillRule:"evenodd",d:"M11.389 6.667c.276 0 .5.224.5.5 0 3.114-2.396 5.67-5.445 5.923v2.632c0 .276-.223.5-.5.5-.245 0-.45-.177-.491-.41l-.009-.09V13.09C2.395 12.836 0 10.281 0 7.167c0-.276.224-.5.5-.5s.5.224.5.5c0 2.73 2.214 4.944 4.944 4.944 2.731 0 4.945-2.214 4.945-4.944 0-.276.224-.5.5-.5zM5.944 0C7.51 0 8.778 1.268 8.778 2.833v4.334C8.778 8.73 7.51 10 5.944 10 4.38 10 3.111 8.73 3.111 7.167V2.833C3.111 1.268 4.38 0 5.944 0zm0 1c-1.012 0-1.833.82-1.833 1.833v4.334C4.111 8.179 4.933 9 5.944 9c1.013 0 1.834-.82 1.834-1.833V2.833C7.778 1.82 6.958 1 5.944 1z"})})}function Ht(){return(0,o.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"24",viewBox:"0 0 25 24",children:(0,o.jsxs)("g",{fill:"none",fillRule:"evenodd",children:[(0,o.jsx)("path",{fill:"#707578",d:"M11.889 6.667c.276 0 .5.224.5.5 0 3.114-2.396 5.67-5.445 5.923v2.632c0 .276-.223.5-.5.5-.245 0-.45-.177-.491-.41l-.009-.09V13.09c-1.116-.093-2.145-.494-3
1-1.119l.717-.717c.793.54 1.751.857 2.783.857 2.731 0 4.945-2.214 4.945-4.944 0-.276.224-.5.5-.5zM1 6.667c.276 0 .5.224.5.5 0 .975.282 1.884.77 2.65l-.722.721C.888 9.58.5 8.418.5 7.167c0-.276.224-.5.5-.5zm8.277-1.031v1.53C9.278 8.732 8.01 10 6.445 10c-.446 0-.868-.103-1.243-.287l.776-.773c.149.039.306.06.467.06.963 0 1.751-.74 1.828-1.683l.006-.15v-.531l1-1zM6.444 0C8.01 0 9.278 1.268 9.278 2.833l-.002-.025-.999.999v-.974c0-.962-.74-1.75-1.682-1.827L6.445 1c-.962 0-1.751.74-1.828 1.683l-.006.15v4.334c0 .097.008.192.022.285l-.804.805c-.112-.269-.184-.558-.209-.86l-.009-.23V2.833C3.611 1.268 4.88 0 6.444 0z",transform:"translate(6.5 4)"}),(0,o.jsx)("path",{fill:"red",d:"M12.146.646c.196-.195.512-.195.708 0 .173.174.192.443.057.638l-.057.07-12 12c-.196.195-.512.195-.708 0-.173-.174-.192-.443-.057-.638l.057-.07 12-12z",transform:"translate(6.5 4)"})]})})}function Xt(){var e=Qe().localTracks.find((function(e){return"audio"===e.kind}));return[et(e),(0,u.useCallback)((function(){e&&(e.isEnabled?e.disable():e.enable())}),[e])]}function Kt(e){var t=(0,T.Z)(Xt(),2),n=t[0],r=t[1],i=Qe().localTracks.some((function(e){return"audio"===e.kind}));return(0,o.jsx)(xe.Z,{className:e.className,onClick:r,disabled:!i||e.disabled,startIcon:n?(0,o.jsx)(Gt,{}):(0,o.jsx)(Ht,{}),"data-cy-audio-toggle":!0,children:i?n?"Mute":"Unmute":"No Audio"})}function qt(){return(0,o.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",children:(0,o.jsxs)("g",{fill:"none",fillRule:"evenodd",children:[(0,o.jsx)("path",{fill:"#707578",d:"M10.503.85c.32 0 .611.125.827.329l-.696.697c-.025-.018-.053-.032-.084-.038l-.047-.006H1.207c-.102 0-.19.071-.216.165l-.008.059v7.866c0 .101.07.189.165.215l.059.008h1.156l-.983.983h-.173c-.624 0-1.139-.476-1.2-1.083L0 9.922V2.056C0 1.433.476.917 1.084.856l.123-.007h9.296zm5.49 1.124l.007.082v7.866c0 .337-.328.566-.635.47l-.076-.03-3.58-1.79v1.35c0 .623-.476 1.138-1.083 1.2l-.123.006H4.16l.984-.983h5.359c.101 0 .189-.07.215-.164l.008-.06V4.564l.983-.982.353-.353 3.227-1.612c.301-.15.652.04.704.358zm-.977.876L11.71 4.504v2.967l3.307 1.654V2.85z",transform:"translate(4 6)"}),(0,o.jsx)("path",{fill:"red",fillRule:"nonzero",d:"M13.06.144c.192-.192.503-.192.695 0 .171.17.19.436.057.627l-.057.068-12.29 12.29c-.192.193-.503.193-.695 0-.171-.17-.19-.435-.057-.626l.057-.069L13.06.144z",transform:"translate(4 6)"})]})})}function Yt(){return(0,o.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"24",viewBox:"0 0 25 24",children:(0,o.jsx)("path",{fill:"#707578",fillRule:"evenodd",d:"M15.003 7c.665 0 1.206.542 1.206 1.207v1.349l3.58-1.789c.301-.15.652.04.704.358l.007.082v7.866c0 .365-.385.603-.711.44l-3.58-1.79v1.35c0 .623-.476 1.138-1.083 1.2l-.123.006H5.707c-.665 0-1.207-.542-1.207-1.206V8.207C4.5 7.542 5.042 7 5.707 7zm0 .983H5.707c-.122 0-.224.102-.224.224v7.866c0 .121.102.223.224.223h9.296c.122 0 .223-.102.223-.223V8.207c0-.122-.101-.224-.223-.224zm4.513 1.019l-3.307 1.654v2.968l3.307 1.653V9.002z"})})}function Jt(e){var t=(0,T.Z)(Ve(),2),n=t[0],r=t[1],i=(0,u.useRef)(0),a=bt().hasVideoInputDevices,s=(0,u.useCallback)((function(){Date.now()-i.current>500&&(i.current=Date.now(),r())}),[r]);return(0,o.jsx)(xe.Z,{className:e.className,onClick:s,disabled:!a||e.disabled,startIcon:n?(0,o.jsx)(Yt,{}):(0,o.jsx)(qt,{}),children:a?n?"Stop Video":"Start Video":"No Video"})}var Qt=(0,Ze.Z)((function(e){return{gutterBottom:{marginBottom:"1em"},marginTop:{marginTop:"1em"},deviceButton:{width:"100%",border:"2px solid #aaa",margin:"1em 0"},localPreviewContainer:(0,S.Z)({paddingRight:"2em"},e.breakpoints.down("sm"),{padding:"0 2.5em"}),joinButtons:(0,S.Z)({display:"flex",justifyContent:"space-between"},e.breakpoints.down("sm"),{flexDirection:"column-reverse",width:"100%","& button":{margin:"0.5em 0"}}),mobileButtonBar:(0,S.Z)({},e.breakpoints.down("sm"),{display:"flex",justifyContent:"space-between",margin:"1.5em 0 1em"}),mobileButton:{padding:"0.8em 0",margin:0}}}));function $t(e){e=null!==e?e:(0,ke.Z)(new TypeError("Cannot destructure undefined"));var t=Qt(),n=kt(),r=(n.getToken,n.isFetching),i=Qe(),a=(i.connect,i.isAcquiringLocalTracks),s=i.isConnecting,c=r||a||s;return(0,o.jsx)(o.Fragment,{children:(0,o.jsxs)(Se.Z,{container:!0,justifyContent:"center",children:[(0,o.jsxs)(Se.Z,{item:!0,md:7,sm:12,xs:12,children:[(0,o.jsx)("div",{className:t.localPreviewContainer,children:(0,o.jsx)(ht,{identity:"You"})}),(0,o.jsxs)("div",{className:t.mobileButtonBar,children:[(0,o.jsxs)(Te.Z,{mdUp:!0,children:[(0,o.jsx)(Kt,{className:t.mobileButton,disabled:c}),(0,o.jsx)(Jt,{className:t.mobileButton,disabled:c})]}),(0,o.jsx)(Ut,{mobileButtonClass:t.mobileButton})]})]}),(0,o.jsx)(Se.Z,{item:!0,md:5,sm:12,xs:12,children:(0,o.jsx)(Se.Z,{container:!0,direction:"column",justifyContent:"space-between",style:{height:"100%"},children:(0,o.jsx)("div",{children:(0,o.jsxs)(Te.Z,{smDown:!0,children:[(0,o.jsx)(Kt,{className:t.deviceButton,disabled:c}),(0,o.jsx)(Jt,{className:t.deviceButton,disabled:c})]})})})})]})})}var en=n(76775),tn=(0,Ze.Z)((function(e){return{background:{display:"flex",alignItems:"center",justifyContent:"center",background:"rgb(40, 42, 43)",height:"100%"},container:{position:"relative",flex:"1"},innerContainer:{display:"block",height:"auto",width:"calc(100% - 40px)",margin:"10px auto",maxWidth:"700px",borderRadius:"8px",border:"1px solid #ccc",overflow:"hidden",position:"relative"},swooshContainer:(0,S.Z)({position:"relative",display:"flex",alignItems:"center",justifyContent:"center",backgroundImage:"url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='296' height='378' viewBox='0 0 296 378'%3E%3Cdefs%3E%3ClinearGradient id='utbttnlrpc' x1='78.976%25' x2='63.882%25' y1='60.873%25' y2='45.554%25'%3E%3Cstop offset='0%25' stop-opacity='0'/%3E%3Cstop offset='100%25'/%3E%3C/linearGradient%3E%3ClinearGradient id='aim8r3oczd' x1='78.976%25' x2='63.882%25' y1='56.106%25' y2='47.503%25'%3E%3Cstop offset='0%25' stop-opacity='0'/%3E%3Cstop offset='100%25'/%3E%3C/linearGradient%3E%3Cpath id='5tk4i6f80a' d='M0 0H296V378H0z'/%3E%3C/defs%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cmask id='m1ihwluuxb' fill='%23fff'%3E%3Cuse xlink:href='%235tk4i6f80a'/%3E%3C/mask%3E%3Cuse fill='%23DE5858' xlink:href='%235tk4i6f80a'/%3E%3Cg mask='url(%23m1ihwluuxb)'%3E%3Cg%3E%3Cpath fill='url(%23utbttnlrpc)' d='M0 286.83c87.695-83.937 175.802-132.682 264.323-146.233 132.78-20.328 183.24 4.255 225.143-23.414 73.409-48.471 93.039-15.154 148.326-20.892 44.84-4.654 98.48-77.401 135.81-91.717C795.596-3.86 821.469.801 851.22 18.56L891 476.5H0V286.83z' opacity='.06' transform='translate(-457 -22.5)'/%3E%3Cpath fill='url(%23aim8r3oczd)' d='M137 604.5c63.759-109.686 155.8-165.124 276.126-166.315 180.488-1.786 157.888-146.686 387.11-146.33 229.223.356 170.665-151.786 341.36-166.888 113.797-10.068 180.265 10.685 199.404 62.26V604.5H137z' opacity='.08' transform='translate(-457 -22.5)'/%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A\");",backgroundSize:"cover",width:"296px"},e.breakpoints.down("sm"),{width:"100%",height:"100px",backgroundPositionY:"140px"}),logoContainer:(0,S.Z)({position:"absolute",width:"210px",textAlign:"center"},e.breakpoints.down("sm"),{display:"flex",alignItems:"center",width:"90%",textAlign:"initial","& svg":{height:"64px"}}),twilioLogo:{position:"absolute",top:0,left:0,margin:"20px"},content:(0,S.Z)({background:"white",width:"100%",padding:"4em",flex:1},e.breakpoints.down("sm"),{padding:"2em"}),title:(0,S.Z)({color:"white",margin:"1em 0 0"},e.breakpoints.down("sm"),{margin:0,fontSize:"1.1rem"})}})),nn=function(e){var t=tn();(0,en.TH)();return(0,o.jsx)("div",{className:t.background,children:(0,o.jsx)("div",{className:t.container,children:(0,o.jsx)("div",{className:t.innerContainer,children:(0,o.jsx)("div",{className:t.content,children:e.children})})})})},rn=n(86010),on=n(80366);function an(){return(0,o.jsx)("svg",{width:"14px",height:"14px",viewBox:"0 0 14 14",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:(0,o.jsx)("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:(0,o.jsx)("g",{transform:"translate(-299.000000, -723.000000)",fill:"#D61F1F",children:(0,o.jsx)("g",{transform:"translate(276.000000, 704.000000)",children:(0,o.jsx)("g",{transform:"translate(23.000000, 19.000000)",children:(0,o.jsx)("path",{d:"M8.03935839,0.763849674 L13.2361503,5.96064161 C13.8101721,6.5346634 13.8101721,7.4653366 13.2361503,8.03935839 L8.03935839,13.2361503 C7.4653366,13.8101721 6.5346634,13.8101721 5.96064161,13.2361503 L0.763849674,8.03935839 C0.189827887,7.4653366 0.189827887,6.5346634 0.763849674,5.96064161 L5.96064161,0.763849674 C6.5346634,0.189827887 7.4653366,0.189827887 8.03935839,0.763849674 Z M7,8.66666667 C6.53976271,8.66666667 6.16666667,9.03976271 6.16666667,9.5 C6.16666667,9.96023729 6.53976271,10.3333333 7,10.3333333 C7.46023729,10.3333333 7.83333333,9.96023729 7.83333333,9.5 C7.83333333,9.03976271 7.46023729,8.66666667 7,8.66666667 Z M7.00842529,4.5 L6.99145559,4.5 C6.48802096,4.5 6.09771
1771,4.99363437 6.17690967,5.53663218 L6.53327351,7.40140326 C6.56721292,7.64822044 6.76519283,7.83333333 6.99711216,7.83333333 L7.00276873,7.83333333 C7.23468805,7.83333333 7.43266796,7.64822044 7.46660737,7.40140326 L7.82297121,5.53663218 C7.90216317,4.99363437 7.51751649,4.50617043 7.00842529,4.5 Z",id:"Error"})})})})})})}var sn=n(17812),cn=n(43950);function ln(){return(0,o.jsx)("svg",{width:"16px",height:"14px",viewBox:"0 0 16 14",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:(0,o.jsx)("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:(0,o.jsx)("g",{transform:"translate(-273.000000, -162.000000)",fill:"#E46216",children:(0,o.jsx)("g",{transform:"translate(251.000000, 143.000000)",children:(0,o.jsx)("g",{transform:"translate(22.000000, 19.000000)",children:(0,o.jsx)("path",{d:"M6.68405227,0.743750848 C7.26590697,-0.247916949 8.73410873,-0.247916949 9.31596344,0.743750848 L9.31596344,0.743750848 L15.7980583,11.7915293 C16.3754418,12.775573 15.6458879,14 14.4821027,14 L14.4821027,14 L1.5178827,14 C0.354135396,14 -0.375441293,12.775573 0.201934693,11.7915293 L0.201934693,11.7915293 Z M8,10 C7.44771525,10 7,10.4477153 7,11 C7,11.5522847 7.44771525,12 8,12 C8.55228475,12 9,11.5522847 9,11 C9,10.4477153 8.55228475,10 8,10 Z M8.01011035,5 L7.98974671,5 L7.87816923,5.00681158 C7.32928042,5.07427655 6.92320065,5.63308608 7.01229161,6.24395862 L7.01229161,6.24395862 L7.43992821,8.48168391 L7.46058982,8.57746523 C7.53403676,8.82448556 7.74990819,9 8.00332247,9 L8.00332247,9 L8.09436762,8.9919759 C8.33199007,8.94972242 8.5237268,8.74495557 8.55992884,8.48168391 L8.55992884,8.48168391 L8.98756545,6.24395862 L8.99896034,6.12268979 C9.02431547,5.52149772 8.58283795,5.00694173 8.01011035,5 L8.01011035,5 Z"})})})})})})}function un(){return(0,o.jsx)("svg",{width:"20px",height:"20px",viewBox:"0 0 20 20",children:(0,o.jsx)("path",{fill:"#0263e0",fillRule:"evenodd",d:"M10 2a8 8 0 110 16 8 8 0 010-16zm0 7c-.26.01-.528.08-.707.24-.178.158-.292.355-.292.575v3.37c0 .21.11.428.292.577.173.14.457.247.707.237.26-.008.528-.078.707-.237.178-.16.292-.355.292-.577v-3.37a.766.766 0 00-.292-.575A1.14 1.14 0 0010 9zm0-3l-.266.036c-.17.047-.318.131-.441.253l-.156.198A.958.958 0 009 6.98v.04a.728.728 0 00.086.378c.04.121.108.227.206.315.09.094.197.163.321.202.12.06.248.09.386.084l.266-.035c.17-.047.318-.131.441-.253l.156-.198A.958.958 0 0011 7.02v-.04a.728.728 0 00-.086-.378.721.721 0 00-.206-.315.757.757 0 00-.321-.202.767.767 0 00-.386-.084z"})})}var dn=(0,Ze.Z)((function(e){return{container:(0,S.Z)({display:"flex",justifyContent:"space-between",width:"400px",minHeight:"50px",background:"white",padding:"1em",borderRadius:"3px",boxShadow:"0 12px 24px 4px rgba(40,42,43,0.2)"},e.breakpoints.down("sm"),{width:"100%"}),contentContainer:{display:"flex",lineHeight:1.8},iconContainer:{display:"flex",padding:"0 1.3em 0 0.3em",transform:"translateY(3px)"},headline:{fontWeight:"bold"},error:{borderLeft:"4px solid #D61F1F"},warning:{borderLeft:"4px solid #E46216"},info:{borderLeft:"4px solid #0263e0"}}}));function hn(e){var t,n=e.headline,r=e.message,i=e.variant,a=e.open,s=e.handleClose,c=dn();return(0,o.jsx)(cn.Z,{anchorOrigin:{vertical:"top",horizontal:"right"},open:a,onClose:function(e,t){"clickaway"!==t&&(null===s||void 0===s||s())},autoHideDuration:1e4,children:(0,o.jsxs)("div",{className:(0,rn.Z)(c.container,(t={},(0,S.Z)(t,c.error,"error"===i),(0,S.Z)(t,c.warning,"warning"===i),(0,S.Z)(t,c.info,"info"===i),t)),children:[(0,o.jsxs)("div",{className:c.contentContainer,children:[(0,o.jsxs)("div",{className:c.iconContainer,children:["warning"===i&&(0,o.jsx)(ln,{}),"error"===i&&(0,o.jsx)(an,{}),"info"===i&&(0,o.jsx)(un,{})]}),(0,o.jsxs)("div",{children:[(0,o.jsx)(Ie.Z,{variant:"body1",className:c.headline,component:"span",children:n}),(0,o.jsxs)(Ie.Z,{variant:"body1",component:"span",children:[" ",r]})]})]}),(0,o.jsx)("div",{children:s&&(0,o.jsx)(sn.Z,{size:"small","aria-label":"close",color:"inherit",onClick:s,children:(0,o.jsx)(on.Z,{fontSize:"small"})})})]})})}function fn(e){var t=e.error,n=bt(),r=n.hasAudioInputDevices,i=n.hasVideoInputDevices,a=Qe().isAcquiringLocalTracks,s=(0,u.useState)(!1),c=s[0],l=s[1],d=!c&&!a&&(Boolean(t)||!r||!i),h=function(e,t,n){var r="",i="";switch(!0){case"CameraPermissionsDenied"===(null===n||void 0===n?void 0:n.message):r="Unable to Access Media:",i="The user has denied permission to use video. Please grant permission to the browser to access the camera.";break;case"MicrophonePermissionsDenied"===(null===n||void 0===n?void 0:n.message):r="Unable to Access Media:",i="The user has denied permission to use audio. Please grant permission to the browser to access the microphone.";break;case"NotAllowedError"===(null===n||void 0===n?void 0:n.name):r="Unable to Access Media:",i="Permission denied by system"===n.message?"The operating system has blocked the browser from accessing the microphone or camera. Please check your operating system settings.":"The user has denied permission to use audio and video. Please grant permission to the browser to access the microphone and camera.";break;case"NotFoundError"===(null===n||void 0===n?void 0:n.name):r="Cannot Find Microphone or Camera:",i="The browser cannot access the microphone or camera. Please make sure all input devices are connected and enabled.";break;case Boolean(n):r="Error Acquiring Media:",i="".concat(n.name," ").concat(n.message);break;case!e&&!t:r="No Camera or Microphone Detected:",i="Other participants in the room will be unable to see and hear you.";break;case!t:r="No Camera Detected:",i="Other participants in the room will be unable to see you.";break;case!e:r="No Microphone Detected:",i="Other participants in the room will be unable to hear you."}return{headline:r,message:i}}
1(r,i,t),f=h.headline,p=h.message;return(0,o.jsx)(hn,{open:d,handleClose:function(){return l(!0)},headline:f,message:p,variant:"warning"})}var pn,vn=n(68527),mn=n(43238),gn=n(79762),xn=n(4612),wn=n(68133),yn=n(26723),bn=n(79042),Cn=u.createContext(null);function jn(){var e=(0,u.useState)(""),t=e[0],n=e[1],a=(0,u.useState)(""),s=a[0],c=a[1],d=(0,u.useState)(!0),h=d[0],f=d[1],p=(0,u.useState)(""),m=p[0],g=p[1],x=(0,u.useState)(),w=x[0],y=x[1],b=(0,u.useState)(!1),C=b[0],j=b[1],_=function(){var e=(0,u.useContext)(Cn);return l()(e,"LoginController context should be defined."),e}(),k=_.setTownController,Z=_.townsService,S=Qe().connect,T=(0,mn.pm)(),P=(0,u.useCallback)((function(){Z.listTowns().then((function(e){y(e.sort((function(e,t){return t.currentOccupancy-e.currentOccupancy})))}))}),[Z]);(0,u.useEffect)((function(){P();var e=setInterval(P,2e3);return function(){clearInterval(e)}}),[P]);var I=(0,u.useCallback)(function(){var e=(0,r.Z)((function(e){var n,r,o,a,s,c,u;return(0,i.__generator)(this,(function(i){switch(i.label){case 0:n=void 0,r=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),t&&0!==t.length?e&&0!==e.length?(a=null===(o="https://town-service.onrender.com")?void 0:o.includes("onrender.com"),n=setTimeout((function(){r=T(a?{title:"Please be patient...",description:"The TownService is starting up - this may take 15-30 seconds, because it is hosted on a free Render.com service. Render.com's free tier automatically puts the TownService to sleep when it is inactive for 15 minutes.",status:"info",isClosable:!1,duration:null}:{title:"Connecting to town...",description:"This is taking a bit longer than normal - please be patient...",status:"info",isClosable:!1,duration:null})}),1e3),j(!0),[4,(s=new ue({userName:t,townID:e,loginController:_})).connect()]):(T({title:"Unable to join town",description:"Please enter a town ID",status:"error"}),[2]):(T({title:"Unable to join town",description:"Please select a username",status:"error"}),[2]);case 2:return i.sent(),c=s.providerVideoToken,l()(c),[4,S(c)];case 3:return i.sent(),j(!1),r&&T.close(r),clearTimeout(n),k(s),[3,5];case 4:return u=i.sent(),j(!1),r&&T.close(r),n&&clearTimeout(n),(0,v.Z)(u,Error)?T({title:"Unable to connect to Towns Service",description:u.toString(),status:"error"}):(console.trace(u),T({title:"Unexpected error, see browser console for details.",status:"error"})),[3,5];case 5:return[2]}}
1))}));return function(t){return e.apply(this,arguments)}}(),[k,t,T,S,_]),E=function(){var e=(0,r.Z)((function(){var e,n,r,a,c,l,u;return(0,i.__generator)(this,(function(i){switch(i.label){case 0:if(!t||0===t.length)return T({title:"Unable to create town",description:"Please select a username before creating a town",status:"error"}),[2];if(!s||0===s.length)return T({title:"Unable to create town",description:"Please enter a town name",status:"error"}),[2];n=null===(e="https://town-service.onrender.com")?void 0:e.includes("onrender.com"),r=void 0,a=setTimeout((function(){r=T(n?{title:"Please be patient...",description:"The TownService is starting up - this may take 15-30 seconds, because it is hosted on a free Render.com service. Render.com's free tier automatically puts the TownService to sleep when it is inactive for 15 minutes.",status:"info",isClosable:!1,duration:null}:{title:"Connecting to town...",description:"This is taking a bit longer than normal - please be patient...",status:"info",isClosable:!1,duration:null})}),2e3),j(!0),i.label=1;case 1:return i.trys.push([1,4,,5]),[4,Z.createTown({friendlyName:s,isPubliclyListed:h})];case 2:return c=i.sent(),clearTimeout(a),j(!1),r&&T.close(r),l=(0,o.jsx)(o.Fragment,{}),h||(l=(0,o.jsxs)("p",{children:["This town will NOT be publicly listed. To re-enter it, you will need to use this ID:"," ",c.townID]})),T({title:"Town ".concat(s," is ready to go!"),description:(0,o.jsxs)(o.Fragment,{children:[l,"Please record these values in case you need to change the town:",(0,o.jsx)("br",{}),"Town ID: ",c.townID,(0,o.jsx)("br",{}),"Town Editing Password: ",c.townUpdatePassword]}),status:"success",isClosable:!0,duration:null}),[4,I(c.townID)];case 3:return i.sent(),[3,5];case 4:return u=i.sent(),clearTimeout(a),j(!1),r&&T.close(r),(0,v.Z)(u,Error)?T({title:"Unable to connect to Towns Service",description:u.toString(),status:"error"}):(console.trace(u),T({title:"Unexpected error, see browser console for details.",status:"error"})),[3,5];case 5:return[2]}}
1))}));return function(){return e.apply(this,arguments)}}();return(0,o.jsx)(o.Fragment,{children:(0,o.jsx)("form",{children:(0,o.jsxs)(vn.Kq,{children:[(0,o.jsxs)(vn.xu,{p:"4",borderWidth:"1px",borderRadius:"lg",children:[(0,o.jsx)(vn.X6,{as:"h2",size:"lg",children:"Select a username"}),(0,o.jsxs)(gn.NI,{children:[(0,o.jsx)(gn.lX,{htmlFor:"name",children:"Name"}),(0,o.jsx)(xn.II,{autoFocus:!0,name:"name",placeholder:"Your name",value:t,onChange:function(e){return n(e.target.value)}})]})]}),(0,o.jsxs)(vn.xu,{borderWidth:"1px",borderRadius:"lg",children:[(0,o.jsx)(vn.X6,{p:"4",as:"h2",size:"lg",children:"Create a New Town"}),(0,o.jsxs)(vn.kC,{p:"4",children:[(0,o.jsx)(vn.xu,{flex:"1",children:(0,o.jsxs)(gn.NI,{children:[(0,o.jsx)(gn.lX,{htmlFor:"townName",children:"New Town Name"}),(0,o.jsx)(xn.II,{name:"townName",placeholder:"New Town Name",value:s,onChange:function(e){return c(e.target.value)}})]})}),(0,o.jsx)(vn.xu,{children:(0,o.jsxs)(gn.NI,{children:[(0,o.jsx)(gn.lX,{htmlFor:"isPublic",children:"Publicly Listed"}),(0,o.jsx)(wn.XZ,{id:"isPublic",name:"isPublic",isChecked:h,onChange:function(e){f(e.target.checked)}})]})}),(0,o.jsx)(vn.xu,{children:(0,o.jsx)(yn.zx,{"data-testid":"newTownButton",onClick:E,isLoading:C,disabled:C,children:"Create"})})]})]}),(0,o.jsx)(vn.X6,{p:"4",as:"h2",size:"lg",children:"-or-"}),(0,o.jsxs)(vn.xu,{borderWidth:"1px",borderRadius:"lg",children:[(0,o.jsx)(vn.X6,{p:"4",as:"h2",size:"lg",children:"Join an Existing Town"}),(0,o.jsx)(vn.xu,{borderWidth:"1px",borderRadius:"lg",children:(0,o.jsxs)(vn.kC,{p:"4",children:[(0,o.jsxs)(gn.NI,{children:[(0,o.jsx)(gn.lX,{htmlFor:"townIDToJoin",children:"Town ID"}),(0,o.jsx)(xn.II,{name:"townIDToJoin",placeholder:"ID of town to join, or select from list",value:m,onChange:function(e){return g(e.target.value)}})]}),(0,o.jsx)(yn.zx,{"data-testid":"joinTownByIDButton",onClick:function(){return I(m)},isLoading:C,disabled:C,children:"Connect"})]})}),(0,o.jsx)(vn.X6,{p:"4",as:"h4",size:"md",children:"Select a public town to join"}),(0,o.jsx)(vn.xu,{maxH:"500px",overflowY:"scroll",children:(0,o.jsxs)(bn.iA,{children:[(0,o.jsx)(bn.Rn,{placement:"bottom",children:"Publicly Listed Towns"}),(0,o.jsx)(bn.hr,{children:(0,o.jsxs)(bn.Tr,{children:[(0,o.jsx)(bn.Th,{children:"Town Name"}),(0,o.jsx)(bn.Th,{children:"Town ID"}),(0,o.jsx)(bn.Th,{children:"Activity"})]})}),(0,o.jsx)(bn.p3,{children:null===w||void 0===w?void 0:w.map((function(e){return(0,o.jsxs)(bn.Tr,{children:[(0,o.jsx)(bn.Td,{role:"cell",children:e.friendlyName}),(0,o.jsx)(bn.Td,{role:"cell",children:e.townID}),(0,o.jsxs)(bn.Td,{role:"cell",children:[e.currentOccupancy,"/",e.maximumOccupancy,(0,o.jsx)(yn.zx,{onClick:function(){return I(e.townID)},disabled:e.currentOccupancy>=e.maximumOccupancy||C,isLoading:C,children:"Connect"})]})]},e.townID)}))})]})})]})]})})})}function _n(){kt().user;var e=Qe().getAudioAndVideoTracks,t=(0,u.useState)(),n=t[0],r=t[1];return(0,u.useEffect)((function(){n||e().catch((function(e){console.log("Error acquiring local media:"),console.dir(e),r(e)}))}),[e,n]),(0,o.jsxs)(nn,{children:[(0,o.jsx)(fn,{error:n}),(0,o.jsx)(vn.X6,{as:"h2",size:"xl",children:"Welcome to Covey.Town!"}),(0,o.jsx)(vn.xv,{p:"4",children:"Covey.Town is a social platform that integrates a 2D game-like metaphor with video chat. To get started, setup your camera and microphone, choose a username, and then create a new town to hang out in, or join an existing one."}),(0,o.jsx)($t,{}),(0,o.jsx)(jn,{})]})}!function(e){e[e.roomNameStep=0]="roomNameStep",e[e.deviceSelectionStep=1]="deviceSelectionStep"}(pn||(pn={}));var kn=n(43832),Zn=n(79895),Sn=n(89659),Tn=(0,Ze.Z)({container:{marginTop:"2.5em"},paper:{padding:"1em"},heading:{marginBottom:"0.4em"}});function Pn(e){var t=e.children,n=Tn();return Ke().isSupported?t:(0,o.jsx)(kn.Z,{children:(0,o.jsx)(Se.Z,{container:!0,justifyContent:"center",className:n.container,children:(0,o.jsx)(Se.Z,{item:!0,xs:12,sm:6,children:(0,o.jsxs)(Zn.Z,{className:n.paper,children:[(0,o.jsx)(Ie.Z,{variant:"h4",className:n.heading,children:"Browser or context not supported"}),(0,o.jsxs)(Ie.Z,{children:["Please open this application in one of the"," ",(0,o.jsx)(Sn.Z,{href:"https://www.twilio.com/docs/video/javascript#supported-browsers",target:"_blank",rel:"noopener",children:"supported browsers"}),".",(0,o.jsx)("br",{}),"If you are using a supported browser, please ensure that this app is served over a"," ",(0,o.jsx)(Sn.Z,{href:"https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts",target:"_blank",rel:"noopener",children:"secure context"})," ","(e.g. https or localhost)."]})]})})})})}var In=n(92671),En=(0,In.Z)(),Ln=(0,In.Z)({overrides:{MuiCssBaseline:{"@global":{"html, body, #root":{height:"100%"}}},MuiButton:{root:{borderRadius:"4px",textTransform:"none",color:"rgb(40, 42, 43)",fontSize:"0.9rem",transition:En.transitions.create(["background-color","box-shadow","border","color"],{duration:En.transitions.duration.short})},text:{padding:"6px 14px"},contained:{boxShadow:"none","&:hover":{boxShadow:"none"}}
1,outlinedPrimary:{border:"2px solid #027AC5","&:hover":{border:"2px solid rgb(1, 85, 137)"}},startIcon:{marginRight:"6px"}},MuiTypography:{body1:{color:"rgb(40, 42, 43)",fontSize:"0.9rem"}},MuiInputBase:{root:{fontSize:"0.9rem"}},MuiSelect:{root:{padding:"0.85em"}},MuiDialogActions:{root:{padding:"16px"}},MuiTextField:{root:{color:"rgb(40, 42, 43)"}},MuiInputLabel:{root:{color:"rgb(40, 42, 43)",fontSize:"1.1rem",marginBottom:"0.2em",fontWeight:500}},MuiOutlinedInput:{notchedOutline:{borderColor:"rgb(136, 140, 142)"}}},typography:{fontFamily:"Inter, sans-serif"},palette:{primary:{main:"#027AC5"}},brand:"#E22525",footerHeight:72,mobileFooterHeight:56,sidebarWidth:300,sidebarMobileHeight:90,sidebarMobilePadding:8,participantBorderWidth:2,mobileTopBarHeight:52,rightDrawerWidth:320}),An=n(83454);function Nn(){var e,t=kt(),n=t.roomType,r=t.settings,i={bandwidthProfile:{video:{mode:r.bandwidthProfileMode,dominantSpeakerPriority:r.dominantSpeakerPriority,trackSwitchOffMode:r.trackSwitchOffMode,contentPreferencesMode:r.contentPreferencesMode,clientTrackSwitchOffControl:r.clientTrackSwitchOffControl}},dominantSpeaker:!0,networkQuality:{local:1,remote:1},maxAudioBitrate:Number(r.maxAudioBitrate),preferredVideoCodecs:[{codec:"VP8",simulcast:"peer-to-peer"!==n&&"go"!==n}],environment:An.env.REACT_APP_TWILIO_ENVIRONMENT};return De&&(null===i||void 0===i||null===(e=i.bandwidthProfile)||void 0===e?void 0:e.video)&&(i.bandwidthProfile.video.maxSubscriptionBitrate=25e5),"dev"===An.env.REACT_APP_TWILIO_ENVIRONMENT&&(i.wsServer="wss://us2.vss.dev.twilio.com/signaling"),Oe(i)}var Dn=n(75154);function On(){return(0,o.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,o.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.64645 2.64645C2.84171 2.45118 3.15829 2.45118 3.35355 2.64645L21.3536 20.6464C21.5488 20.8417 21.5488 21.1583 21.3536 21.3536C21.1583 21.5488 20.8417 21.5488 20.6464 21.3536L2.64645 3.35355C2.45118 3.15829 2.45118 2.84171 2.64645 2.64645Z",fill:"#707578"}),(0,o.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21.3536 2.64645C21.5488 2.84171 21.5488 3.15829 21.3536 3.35355L3.35355 21.3536C3.15829 21.5488 2.84171 21.5488 2.64645 21.3536C2.45118 21.1583 2.45118 20.8417 2.64645 20.6464L20.6464 2.64645C20.8417 2.45118 21.1583 2.45118 21.3536 2.64645Z",fill:"#707578"})]})}function Rn(){var e=(0,u.useContext)(me);if(!e)throw new Error("useChatContext must be used within a ChatProvider");return e}var Bn=(0,Ze.Z)((function(){return(0,Dn.Z)({container:{height:"56px",background:"#F4F4F6",borderBottom:"1px solid #E4E7E9",display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0 1em"},text:{fontWeight:"bold"},closeChatWindow:{cursor:"pointer",display:"flex",background:"transparent",border:"0",padding:"0.4em"}})}));function Mn(){var e=Bn(),t=Rn().setIsChatWindowOpen;return(0,o.jsxs)("div",{className:e.container,children:[(0,o.jsx)("div",{className:e.text,children:"Chat"}),(0,o.jsx)("button",{className:e.closeChatWindow,onClick:function(){return t(!1)},children:(0,o.jsx)(On,{})})]})}var Fn=n(87343),Vn=(0,Ze.Z)((function(e){return{chatInputContainer:{borderTop:"1px solid #e4e7e9",borderBottom:"1px solid #e4e7e9",padding:"1em 1.2em 1em"},textArea:{width:"100%",border:"0",resize:"none",fontSize:"14px",fontFamily:"Inter",outline:"none"},button:{padding:"0.56em",minWidth:"auto","&:disabled":{background:"none","& path":{fill:"#d8d8d8"}}},buttonContainer:{margin:"1em 0 0 1em",display:"flex"},fileButtonContainer:{position:"relative",marginRight:"1em"},fileButtonLoadingSpinner:{position:"absolute",top:"50%",left:"50%",marginTop:-12,marginLeft:-12},textAreaContainer:{display:"flex",marginTop:"0.4em",padding:"0.48em 0.7em",border:"2px solid transparent"},isTextareaFocused:{borderColor:e.palette.primary.main,borderRadius:"4px"}}}));function Wn(e){var t=e.conversation,n=e.isChatWindowOpen,r=Vn(),i=(0,u.useState)(""),a=i[0],s=i[1],c=(0,u.useState)(!1),l=(c[0],c[1],(0,u.useState)(null)),d=l[0],h=l[1],f=/\S/.test(a),p=(0,u.useRef)(null),v=((0,u.useRef)(null),(0,u.useState)(!1)),m=v[0],g=v[1],x=J();(0,u.useEffect)((function(){m?x.pause():x.unPause()}),[m,x]),(0,u.useEffect)((function(){var e;n&&(null===(e=p.current)||void 0===e||e.focus())}),[n]);return(0,o.jsxs)("div",{className:r.chatInputContainer,children:[(0,o.jsx)(hn,{open:Boolean(d),headline:"Error",message:d||"",variant:"error",handleClose:function(){return h(null)}}),(0,o.jsx)("div",{className:(0,rn.Z)(r.textAreaContainer,(0,S.Z)({},r.isTextareaFocused,m)),children:(0,o.jsx)(Fn.Z,{minRows:1,maxRows:3,className:r.textArea,"aria-label":"chat input",placeholder:"Write a message...",onKeyPress:function(e){var n;De||"Enter"!==e.key||e.shiftKey||(e.preventDefault(),n=a,f&&(t.sendMessage(n.trim()),s("")))},onChange:function(e){s(e.target.value)}
1,value:a,"data-cy-chat-input":!0,ref:p,onFocus:function(){return g(!0)},onBlur:function(){return g(!1)}})})]})}var zn=(0,Ze.Z)((function(){return(0,Dn.Z)({messageInfoContainer:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"1.425em 0 0.083em",fontSize:"12px",color:"#606B85"}})}));function Un(e){var t=e.author,n=e.dateCreated,r=e.isLocalParticipant,i=zn();return(0,o.jsxs)("div",{className:i.messageInfoContainer,children:[(0,o.jsx)("div",{children:r?"".concat(t," (You)"):t}),(0,o.jsx)("div",{children:n})]})}var Gn=n(21673),Hn=n(93096),Xn=n.n(Hn),Kn=n(1591),qn=(0,Dn.Z)({outerContainer:{minHeight:0,flex:1,position:"relative"},innerScrollContainer:{height:"100%",overflowY:"auto",padding:"0 1.2em 0"},messageListContainer:{overflowY:"auto",flex:"1",paddingBottom:"1em"},button:{position:"absolute",bottom:"14px",right:"2em",zIndex:100,padding:"0.5em 0.9em",visibility:"hidden",opacity:0,boxShadow:"0px 4px 16px rgba(18, 28, 45, 0.2)",transition:"all 0.5s ease"},showButton:{visibility:"visible",opacity:1,bottom:"24px"}}),Yn=function(e){(0,p.Z)(n,e);var t=(0,w.Z)(n);function n(){var e;return(0,h.Z)(this,n),(e=t.apply(this,arguments)).chatThreadRef=u.createRef(),e.state={isScrolledToBottom:!0,showButton:!1,messageNotificationCount:0},e.handleScroll=Xn()((function(){var t=e.chatThreadRef.current;if(t){var n=Math.abs(t.clientHeight+t.scrollTop-t.scrollHeight)<1;e.setState((function(e){return{isScrolledToBottom:n,showButton:!n&&e.showButton}}))}}),300),e.handleClick=function(){var t=e.chatThreadRef.current;t.scrollTo({top:t.scrollHeight,behavior:"smooth"}),e.setState({showButton:!1})},e}var r=n.prototype;return r.scrollToBottom=function(){var e=this.chatThreadRef.current;e.scrollTop=e.scrollHeight},r.componentDidMount=function(){this.scrollToBottom(),this.chatThreadRef.current.addEventListener("scroll",this.handleScroll)},r.componentDidUpdate=function(e,t){var n=this.props.messages.length!==e.messages.length;if(t.isScrolledToBottom&&n)this.scrollToBottom();else if(n){var r=this.props.messages.length-e.messages.length;this.setState((function(e){return{showButton:!e.isScrolledToBottom,messageNotificationCount:e.showButton?e.messageNotificationCount+r:1}}))}},r.componentWillUnmount=function(){this.chatThreadRef.current.removeEventListener("scroll",this.handleScroll)},r.render=function(){var e=this.props.classes;return(0,o.jsx)("div",{className:e.outerContainer,children:(0,o.jsx)("div",{className:e.innerScrollContainer,ref:this.chatThreadRef,"data-cy-message-list-inner-scroll":!0,children:(0,o.jsxs)("div",{className:e.messageListContainer,children:[this.props.children,(0,o.jsxs)(xe.Z,{className:(0,rn.Z)(e.button,(0,S.Z)({},e.showButton,this.state.showButton)),onClick:this.handleClick,startIcon:(0,o.jsx)(Gn.Z,{}),color:"primary",variant:"contained","data-cy-new-message-button":!0,children:[this.state.messageNotificationCount," new message",this.state.messageNotificationCount>1&&"s"]})]})})})},n}(u.Component),Jn=(0,Kn.Z)(qn)(Yn),Qn=n(68337),$n=n.n(Qn),er=(0,Ze.Z)({messageContainer:{borderRadius:"16px",display:"inline-flex",alignItems:"center",padding:"0.5em 0.8em 0.6em",margin:"0.3em 0 0",wordBreak:"break-word",backgroundColor:"#E1E3EA",hyphens:"auto",whiteSpace:"pre-wrap"},isLocalParticipant:{backgroundColor:"#CCE4FF"}});function tr(e){var t=$n()().match(e);if(!t)return e;var n=[],r=0;return t.forEach((function(t,i){n.push(e.slice(r,t.index)),n.push((0,o.jsx)(Sn.Z,{target:"_blank",rel:"noreferrer",href:t.url,children:t.text},i)),r=t.lastIndex})),n.push(e.slice(r,e.length)),n}function nr(e){var t=e.body,n=e.isLocalParticipant,r=er();return(0,o.jsx)("div",{children:(0,o.jsx)("div",{className:(0,rn.Z)(r.messageContainer,(0,S.Z)({},r.isLocalParticipant,n)),children:(0,o.jsx)("div",{children:tr(t)})})})}var rr=function(e){return null===e||void 0===e?void 0:e.dateCreated.toLocaleTimeString("en-us",{hour:"numeric",minute:"numeric"}).toLowerCase()};function ir(e){var t=e.messages,n=Qe().room.localParticipant,r=he();return(0,o.jsx)(Jn,{messages:t,children:t.map((function(e,i){var a,s=rr(e),c=s!==rr(t[i-1])||e.author!==(null===(a=t[i-1])||void 0===a?void 0:a.author),l=n.identity===e.author,d=r.find((function(t){return t.id==e.author}));return(0,o.jsxs)(u.Fragment,{children:[c&&(0,o.jsx)(Un,{author:(null===d||void 0===d?void 0:d.userName)||e.author,isLocalParticipant:l,dateCreated:s}),(0,o.jsx)(nr,{body:e.body,isLocalParticipant:l})]},e.sid)}))})}var or=(0,Ze.Z)((function(e){var t;return(0,Dn.Z)({chatWindowContainer:(t={pointerEvents:"auto",background:"#FFFFFF",zIndex:1e3,display:"flex",flexDirection:"column",borderLeft:"1px solid #E4E7E9"},(0,S.Z)(t,e.breakpoints.down("sm"),{position:"fixed",top:0,left:0,bottom:0,right:0,zIndex:100}),(0,S.Z)(t,"position","fixed"),(0,S.Z)(t,"bottom",0),(0,S.Z)(t,"left",0),(0,S.Z)(t,"top",0),(0,S.Z)(t,"max-width","250px"),t),hide:{display:"none"}})}
1));function ar(){var e=or(),t=Rn(),n=t.isChatWindowOpen,r=t.messages,i=t.conversation;return(0,o.jsxs)("aside",{className:(0,rn.Z)(e.chatWindowContainer,(0,S.Z)({},e.hide,!n)),children:[(0,o.jsx)(Mn,{}),(0,o.jsx)(ir,{messages:r}),(0,o.jsx)(Wn,{conversation:i,isChatWindowOpen:n})]})}var sr=n(22004),cr=n(56387);function lr(e){var t=e.isOpen,n=e.close,a=e.viewingArea,s=J(),c=de(null===a||void 0===a?void 0:a.name),l=(0,u.useState)((null===a||void 0===a?void 0:a.defaultVideoURL)||""),d=l[0],h=l[1];(0,u.useEffect)((function(){t?s.pause():s.unPause()}),[s,t]);var f=(0,u.useCallback)((function(){s.unPause(),n()}),[s,n]),p=(0,mn.pm)(),m=(0,u.useCallback)((0,r.Z)((function(){var e,t;return(0,i.__generator)(this,(function(n){switch(n.label){case 0:if(!d||!c)return[3,4];e={id:c.id,video:d,isPlaying:!0,elapsedTimeSec:0,occupants:[]},n.label=1;case 1:return n.trys.push([1,3,,4]),[4,s.createViewingArea(e)];case 2:return n.sent(),p({title:"Video set!",status:"success"}),s.unPause(),[3,4];case 3:return t=n.sent(),(0,v.Z)(t,Error)?p({title:"Unable to set video URL",description:t.toString(),status:"error"}):(console.trace(t),p({title:"Unexpected Error",status:"error"})),[3,4];case 4:return[2]}}
1))})),[d,s,c,p]);return(0,o.jsxs)(cr.u_,{isOpen:t,onClose:function(){f(),s.unPause()},children:[(0,o.jsx)(cr.ZA,{}),(0,o.jsxs)(cr.hz,{children:[(0,o.jsxs)(cr.xB,{children:["Pick a video to watch in ",null===c||void 0===c?void 0:c.id," "]}),(0,o.jsx)(cr.ol,{}),(0,o.jsxs)("form",{onSubmit:function(e){e.preventDefault(),m()},children:[(0,o.jsx)(cr.fe,{pb:6,children:(0,o.jsxs)(gn.NI,{children:[(0,o.jsx)(gn.lX,{htmlFor:"video",children:"Video URL"}),(0,o.jsx)(xn.II,{id:"video",name:"video",value:d,onChange:function(e){return h(e.target.value)}})]})}),(0,o.jsxs)(cr.mz,{children:[(0,o.jsx)(yn.zx,{colorScheme:"blue",mr:3,onClick:m,children:"Set video"}),(0,o.jsx)(yn.zx,{onClick:f,children:"Cancel"})]})]})]})]})}function ur(e){var t=e.controller,n=(0,u.useState)(t.isPlaying),r=n[0],i=n[1],a=J(),s=(0,u.useRef)(null);return(0,u.useEffect)((function(){var e=function(e){var t,n,r=null===(t=s.current)||void 0===t?void 0:t.getCurrentTime();void 0!==r&&Math.abs(r-e)>3&&(null===(n=s.current)||void 0===n||n.seekTo(e,"seconds"))};return t.addListener("progressChange",e),t.addListener("playbackChange",i),function(){t.removeListener("playbackChange",i),t.removeListener("progressChange",e)}}),[t]),(0,o.jsxs)(vn.W2,{className:"participant-wrapper",children:["Viewing Area: ",t.id,(0,o.jsx)(sr.Z,{url:t.video,ref:s,config:{youtube:{playerVars:{disablekb:1,autoplay:1}}},playing:r,onProgress:function(e){0!=e.playedSeconds&&e.playedSeconds!=t.elapsedTimeSec&&(t.elapsedTimeSec=e.playedSeconds,a.emitViewingAreaUpdate(t))},onPlay:function(){t.isPlaying||(t.isPlaying=!0,a.emitViewingAreaUpdate(t))},onPause:function(){t.isPlaying&&(t.isPlaying=!1,a.emitViewingAreaUpdate(t))},onEnded:function(){t.isPlaying&&(t.isPlaying=!1,a.emitViewingAreaUpdate(t))},controls:!0,width:"100%",height:"100%"})]})}function dr(e){var t=e.viewingArea,n=J(),r=de(t.name),i=(0,u.useState)(void 0===r.video),a=i[0],s=i[1],c=(0,u.useState)(r.video),l=c[0],d=c[1];return(0,u.useEffect)((function(){var e=function(e){e?d(e):n.interactableEmitter.emit("endIteraction",r)};return r.addListener("videoChange",e),function(){r.removeListener("videoChange",e)}}),[r,n]),l?(0,o.jsx)(o.Fragment,{children:(0,o.jsx)(ur,{controller:r})}):(0,o.jsx)(lr,{isOpen:a,close:function(){s(!1),n.interactEnd(t)},viewingArea:t})}function hr(){var e=fe("viewingArea");return e?(0,o.jsx)(dr,{viewingArea:e}):(0,o.jsx)(o.Fragment,{})}function fr(){var e,t=Qe().room,n=(0,u.useState)(Array.from(null!==(e=null===t||void 0===t?void 0:t.participants.values())&&void 0!==e?e:[]).map((function(e,t){return{participant:e,slot:t+1}}))),r=n[0],i=n[1];return(0,u.useEffect)((function(){if(t){var e=function(e){return i((function(t){for(var n=0,r=t.sort((function(e,t){return e.slot<t.slot?-1:e.slot===t.slot?0:1}));n<r.length&&n+1===r[n].slot;)n++;return(0,x.Z)(t).concat([{participant:e,slot:n+1}])}))},n=function(e){return i((function(t){return t.filter((function(t){return t.participant!==e}))}))};return t.on("participantConnected",e),t.on("participantDisconnected",n),function(){t.off("participantConnected",e),t.off("participantDisconnected",n)}}}),[t]),r}function pr(){var e=Qe().room,t=(0,u.useState)(),n=t[0],r=t[1];return(0,u.useEffect)((function(){if(e){var t=function(){r(Array.from(e.participants.values()).concat(e.localParticipant).find((function(e){return Array.from(e.tracks.values()).find((function(e){return e.trackName.includes("screen")}))})))};return t(),e.on("trackPublished",t),e.on("trackUnpublished",t),e.on("participantDisconnected",t),e.localParticipant.on("trackPublished",t),e.localParticipant.on("trackUnpublished",t),function(){e.off("trackPublished",t),e.off("trackUnpublished",t),e.off("participantDisconnected",t),e.localParticipant.off("trackPublished",t),e.localParticipant.off("trackUnpublished",t)}}}),[e]),n}function vr(){var e=(0,T.Z)(Le(),1)[0],t=pr(),n=function(){var e,t=Qe().room,n=(0,u.useState)(null!==(e=null===t||void 0===t?void 0:t.dominantSpeaker)&&void 0!==e?e:null),r=n[0],i=n[1];return(0,u.useEffect)((function(){if(t){var e=function(e){null!==e&&i(e)},n=function(e){i((function(t){return t===e?null:t}))};return t.on("dominantSpeakerChanged",e),t.on("participantDisconnected",n),function(){t.off("dominantSpeakerChanged",e),t.off("participantDisconnected",n)}}}),[t]),r}(),r=(fr(),Qe().room),i=null===r||void 0===r?void 0:r.localParticipant;return e||(t!==i?t:null)||n||i}var mr=(0,Ze.Z)({outerContainer:{width:"2em",height:"2em",padding:"0.9em",display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0, 0, 0, 0.5)"},innerContainer:{display:"flex",alignItems:"flex-end","& div":{width:"2px",marginRight:"1px","&:not(:last-child)":{borderRight:"none"}}}}),gr=[0,1,2,3,4];function xr(e){var t=e.participant,n=mr(),r=function(e){var t=(0,u.useState)(e.networkQualityLevel),n=t[0],r=t[1];return(0,u.useEffect)((function(){var t=function(e){return r(e)};return r(e.networkQualityLevel),e.on("networkQualityLevelChanged",t),function(){e.off("networkQualityLevelChanged",t)}}),[e]),n}(t);return null===r?null:(0,o.jsx)("div",{className:n.outerContainer,children:(0,o.jsx)("div",{className:n.innerContainer,children:gr.map((function(e){return(0,o.jsx)("div",{style:{height:"".concat(3*(e+1),"px"),background:r>e?"white":"rgba(255, 255, 255, 0.2)"}},e)}))})})}var wr=n(87083),yr=n(62087);function br(){return(0,o.jsx)(wr.ZP,{title:"Participant is pinned. Click to un-pin.",placement:"top",children:(0,o.jsx)(yr.Z,{style:{float:"right",background:"rgba(0, 0, 0, 0.5)",padding:"0.1em",boxSizing:"content-box"},width:"26",height:"26",viewBox:"0 0 26 26",children:(0,o.jsx)("path",{fill:"#FFF",fillRule:"evenodd",strokeWidth:"0",d:"M15.808 4.489c.208-.207.544-.207.75 0l4.953 4.952c.207.207.207.543 0 .75l-1.415 1.415c-.207.208-.543.208-.75 0l-.333-.333-3.007 3.007v2.611c0 .113-.035.222-.1.312l-.055.063-1.
106 1.062c-.208.207-.544.207-.751 0l-2.809-2.81-5.992 5.993c-.207.207-.543.207-.75 0-.184-.184-.205-.47-.062-.677l.062-.073 5.991-5.993-2.808-2.808c-.184-.184-.204-.47-.061-.677l.061-.073 1.062-1.061c.1-.1.234-.156.375-.156h2.61l3.007-3.007-.332-.332c-.185-.184-.205-.47-.062-.677l.062-.073zm.376 1.125l-.666.664.333.333c.185.184.205.47.062.677l-.062.074-3.537 3.537c-.1.1-.234.155-.375.155h-2.61l-.531.531 2.803 2.803.005.006.005.005 2.804 2.803.53-.531v-2.61c0-.112.036-.221.102-.311l.054-.064 3.537-3.537c.208-.208.544-.208.75 0l.333.332.664-.666-4.201-4.201z"})})})}function Cr(){return(0,o.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",children:(0,o.jsx)("path",{fill:"#707578",fillRule:"evenodd",d:"M17.657 6.343c3.124 3.124 3.124 8.19 0 11.314-3.124 3.124-8.19 3.124-11.314 0-3.124-3.124-3.124-8.19 0-11.314 3.124-3.124 8.19-3.124 11.314 0zm-10.444.87c-2.643 2.644-2.643 6.93 0 9.574 2.644 2.643 6.93 2.643 9.574 0 2.57-2.57 2.641-6.693.214-9.35l-.214-.224L16.563 7c-2.657-2.427-6.78-2.356-9.35.214zm4.865.484l.02.003.026.005.041.01c.025.007.045.014.063.021l.043.019c.018.009.036.019.053.03.01.005.02.012.03.02.027.019.053.04.077.063l2.773 2.774c.24.24.24.63 0 .87-.213.214-.545.237-.785.071l-.085-.07-1.719-1.72v5.9c0 .34-.275.615-.615.615-.302 0-.553-.218-.605-.505l-.01-.11-.001-5.9-1.718 1.72c-.24.24-.63.24-.87 0-.214-.215-.238-.546-.072-.786l.072-.085 2.769-2.77.015-.014c.02-.018.04-.035.062-.05l.005-.004.008-.006c.027-.018.055-.034.085-.048l.034-.015.059-.02.032-.008c.021-.005.044-.008.068-.011l.038-.003H12.025l.027.002.026.002z"})})}function jr(e){var t=(0,u.useState)([]),n=t[0],r=t[1];return(0,u.useEffect)((function(){r(Array.from(e.tracks.values()));var t=function(e){return r((function(t){return(0,x.Z)(t).concat([e])}))},n=function(e){return r((function(t){return t.filter((function(t){return t!==e}))}))};return e.on("trackPublished",t),e.on("trackUnpublished",n),function(){e.off("trackPublished",t),e.off("trackUnpublished",n)}}),[e]),n}function _r(e){var t=(0,u.useState)(e&&e.track),n=t[0],r=t[1];return(0,u.useEffect)((function(){if(r(e&&e.track),e){var t=function(){return r(null)};return e.on("subscribed",r),e.on("unsubscribed",t),function(){e.off("subscribed",r),e.off("unsubscribed",t)}}}),[e]),n}var kr=(0,Ze.Z)((function(e){return(0,Dn.Z)({container:{position:"relative",display:"flex",alignItems:"center",height:0,overflow:"hidden",marginBottom:"0.5em","& video":{filter:"none",objectFit:"contain !important"},borderRadius:"4px",border:"".concat(e.participantBorderWidth,"px solid rgb(245, 248, 255)"),paddingTop:"calc(".concat(56.25,"% - ").concat(e.participantBorderWidth,"px)"),background:"black"},innerContainer:{position:"absolute",top:0,left:0,width:"100%",height:"100%"},infoContainer:{position:"absolute",zIndex:2,display:"flex",flexDirection:"column",justifyContent:"space-between",height:"100%",width:"100%",background:"transparent",top:0},avatarContainer:(0,S.Z)({display:"flex",alignItems:"center",justifyContent:"center",background:"black",position:"absolute",top:0,right:0,bottom:0,left:0,zIndex:1},e.breakpoints.down("sm"),{"& svg":{transform:"scale(0.7)"}}),reconnectingContainer:{position:"absolute",top:0,right:0,bottom:0,left:0,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(40, 42, 43, 0.75)",zIndex:1},screenShareIconContainer:{background:"rgba(0, 0, 0, 0.5)",padding:"0.18em 0.3em",marginRight:"0.3em",display:"flex","& path":{fill:"white"}},identity:{background:"rgba(0, 0, 0, 0.5)",color:"white",padding:"0.18em 0.3em",margin:0,display:"flex",alignItems:"center"},infoRowBottom:{display:"flex",justifyContent:"space-between",position:"absolute",bottom:0,left:0},typeography:(0,S.Z)({color:"white"},e.breakpoints.down("sm"),{fontSize:"0.75rem"}),hideParticipant:{display:"none"},cursorPointer:{cursor:"pointer"}})}));function Zr(e){var t,n=e.participant,r=e.profile,i=e.onClick,a=e.isSelected,s=e.children,c=e.isLocalParticipant,l=e.slot,d=(e.insideGrid,e.hideParticipant),h=jr(n),f=h.find((function(e){return"audio"===e.kind})),p=h.find((function(e){return!e.trackName.includes("screen")&&"video"===e.kind})),v=Boolean(p),m=h.find((function(e){return e.trackName.includes("screen")})),g=function(e){var t=(0,u.useState)(e&&e.isSwitchedOff),n=t[0],r=t[1];return(0,u.useEffect)((function(){if(r(e&&e.isSwitchedOff),e){var t=function(){return r(!0)},n=function(){return r(!1)};return e.on("switchedOff",t),e.on("switchedOn",n),function(){e.off("switchedOff",t),e.off("switchedOn",n)}}}),[e]),!!n}(_r(p)),x=_r(f),w=function(e){var t=(0,u.useState)(!1),n=t[0],r=t[1];return(0,u.useEffect)((function(){var t=function(){return r(!0)},n=function(){return r(!1)};return n(),e.on("reconnecting",t),e.on("reconnected",n),function(){e.off("reconnecting",t),e.off("reconnected",n)}}),[e]),n}(n),y=kr();return(0,o.jsxs)("div",{className:(0,rn.Z)(y.container,(t={},(0,S.Z)(t,y.hideParticipant,d),(0,S.Z)(t,y.cursorPointer,Boolean(i)),t),void 0!==l?"area-".concat(l):void 0),onClick:i,"data-cy-participant":n.identity,children:[(0,o.jsxs)("div",{className:y.infoContainer,children:[(0,o.jsx)(xr,{participant:n}),(0,o.jsxs)("div",{className:y.infoRowBottom,children:[m&&(0,o.jsx)("span",{className:y.screenShareIconContainer,children:(0,o.jsx)(Cr,{})}),(0,o.jsxs)("span",{className:y.identity,children:[(0,o.jsx)(at,{audioTrack:x}),(0,o.jsxs)(Ie.Z,{variant:"body1",className:y.typeography,component:"span",children:[r?r.displayName:"",c&&" (You)"]})]})]}),(0,o.jsx)("div",{children:a&&(0,o.jsx)(br,{})})]}),(0,o.jsxs)("div",{className:y.innerContainer,children:[(!v||g)&&(0,o.jsx)("div",{className:y.avatarContainer,children:(0,o.jsx)(Pe,{})}),w&&(0,o.jsx)("div",{className:y.reconnectingContainer,children:(0,o.jsx)(Ie.Z,{variant:"body1",className:y.typeography,children:"Reconnecting..."})}),s]})]})}function Sr(e){var t=e.track,n=kt().activeSinkId,r=(0,u.useRef)();return(0,u.useEffect)((function(){return r.current=t.attach(),r.current.setAttribute("data-cy-audio-track-name",t.name),document.body.appendChild(r.current),function(){return t.detach().forEac
1h((function(e){e.remove(),e.srcObject=null}))}}),[t]),(0,u.useEffect)((function(){var e,t;null===(e=r.current)||void 0===e||null===(t=e.setSinkId)||void 0===t||t.call(e,n)}),[n]),null}function Tr(e){var t=e.publication,n=e.isLocalParticipant,r=e.videoOnly,i=e.videoPriority,a=_r(t);if(!a)return null;switch(a.kind){case"video":return(0,o.jsx)(ut,{track:a,priority:i,isLocal:!a.name.includes("screen")&&n});case"audio":return r?null:(0,o.jsx)(Sr,{track:a});default:return null}}function Pr(e){var t,n=e.participant,r=e.videoOnly,i=e.enableScreenShare,a=e.videoPriority,s=e.isLocalParticipant,c=jr(n);return t=i&&c.some((function(e){return e.trackName.includes("screen")}))?c.filter((function(e){return e.trackName.includes("screen")||"video"!==e.kind})):c.filter((function(e){return!e.trackName.includes("screen")})),(0,o.jsx)(o.Fragment,{children:t.map((function(e){return(0,o.jsx)(Tr,{publication:e,participant:n,isLocalParticipant:s,videoOnly:r,videoPriority:a},e.kind)}))})}function Ir(e){var t=e.participant,n=e.profile,r=e.videoOnly,i=e.enableScreenShare,a=e.onClick,s=e.isSelected,c=e.isLocalParticipant,l=e.hideParticipant,u=e.slot,d=e.insideGrid;return(0,o.jsx)("div",{className:"participant-wrapper",children:(0,o.jsx)(Zr,{participant:t,profile:n,onClick:a,isSelected:s,isLocalParticipant:c,hideParticipant:l,slot:u,insideGrid:d,children:(0,o.jsx)(Pr,{participant:t,videoOnly:r,enableScreenShare:i,isLocalParticipant:c})})})}var Er=(0,Ze.Z)((function(e){return(0,Dn.Z)({container:(0,S.Z)({overflowY:"auto",background:"rgb(79, 83, 85)",gridArea:"1 / 2 / 1 / 3",zIndex:5},e.breakpoints.down("sm"),{gridArea:"2 / 1 / 3 / 3",overflowY:"initial",overflowX:"auto",display:"flex"}),transparentBackground:{background:"transparent"},scrollContainer:{display:"flex",justifyContent:"center"},innerScrollContainer:(0,S.Z)({width:"calc(".concat(e.sidebarWidth,"px - 3em)"),padding:"1.5em 0"},e.breakpoints.down("sm"),{width:"auto",padding:"".concat(e.sidebarMobilePadding,"px"),display:"flex"}),gridContainer:(0,S.Z)({gridArea:"1 / 1 / 1 / 3",overflowX:"hidden",overflowY:"auto"},e.breakpoints.down("sm"),{gridArea:"1 / 1 / 3 / 1"}),gridInnerContainer:{width:"100%",justifyContent:"center",alignContent:"center"}})}));function Lr(){var e=Qe().room.localParticipant,t=fr(),n=(0,T.Z)(Le(),2),r=n[0],i=n[1],a=pr(),s=vr(),c=pe(),l=Er("fullwidth"),u=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(Ir,{participant:e,isLocalParticipant:!0,insideGrid:!0,slot:0}),(0,o.jsx)(hr,{}),t.filter((function(e){return c.find((function(t){return t.id==e.participant.identity}))})).sort((function(e,t){return e.slot<t.slot?-1:e.slot===t.slot?0:1})).map((function(e){var n=e.participant,l=n===s&&n!==a&&!(n===r)&&t.length>1,u=c.find((function(t){return t.id==e.participant.identity})),d={displayName:u?u.userName:"unknown",id:e.participant.identity};return(0,o.jsx)(Ir,{participant:n,profile:d,isSelected:n===r,onClick:function(){return i(n)},hideParticipant:l,slot:e.slot,insideGrid:!1},n.sid)}))]});return(0,o.jsx)("main",{children:(0,o.jsx)("div",{className:l.gridInnerContainer,children:u})})}var Ar=n(1518),Nr=(0,Ze.Z)((function(e){return{drawer:{display:"flex",width:e.rightDrawerWidth,height:"calc(100% - ".concat(e.footerHeight,"px)")},thumbnailContainer:{display:"flex",flexWrap:"wrap",padding:"5px",overflowY:"auto"}}}));var Dr=function(){var e=Nr(),t=Qe(),n=t.isBackgroundSelectionOpen;return t.setIsBackgroundSelectionOpen,(0,o.jsx)(Ar.ZP,{variant:"persistent",anchor:"right",open:n,transitionDuration:0,classes:{paper:e.drawer}})},Or=(0,Ze.Z)((function(e){var t="".concat(e.sidebarMobileHeight+2*e.sidebarMobilePadding+e.participantBorderWidth,"px");return{container:function(n){return(0,S.Z)({position:"relative",height:"100%",display:"grid",gridTemplateColumns:"1fr ".concat(e.sidebarWidth,"px"),gridTemplateRows:"100%"},e.breakpoints.down("sm"),{gridTemplateColumns:"100%",gridTemplateRows:"calc(100% - ".concat(t,") ").concat(t),overflow:"auto"})},rightDrawerOpen:{gridTemplateColumns:"1fr ".concat(e.sidebarWidth,"px ").concat(e.rightDrawerWidth,"px")}}}));function Rr(){var e=Or(),t=Rn().isChatWindowOpen,n=Qe().isBackgroun
1dSelectionOpen;return(0,o.jsxs)("div",{className:(0,rn.Z)(e.container,(0,S.Z)({},e.rightDrawerOpen,t||n)),children:[(0,o.jsx)(Lr,{}),(0,o.jsx)(ar,{}),(0,o.jsx)(Dr,{})]})}var Br=(0,Ze.Z)((function(e){return(0,Dn.Z)({button:{background:e.brand,color:"white","&:hover":{background:"#600101"}}})}));function Mr(e){var t=Br(),n=Qe().room;return(0,o.jsx)(xe.Z,{onClick:function(){return n.disconnect()},className:(0,rn.Z)(t.button,e.className),"data-cy-disconnect":!0,children:"Disconnect"})}var Fr=n(64566);function Vr(){return(0,o.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",children:(0,o.jsx)("g",{fill:"none",fillRule:"evenodd",children:(0,o.jsx)("g",{fill:"#707578",children:(0,o.jsx)("path",{d:"M10 2c4.418 0 8 3.582 8 8s-3.582 8-8 8-8-3.582-8-8 3.582-8 8-8zm0 1.25c-3.728 0-6.75 3.022-6.75 6.75s3.022 6.75 6.75 6.75 6.75-3.022 6.75-6.75S13.728 3.25 10 3.25zM10 9c.552 0 1 .448 1 1v3c0 .552-.448 1-1 1s-1-.448-1-1v-3c0-.552.448-1 1-1zm0-3c.552 0 1 .448 1 1s-.448 1-1 1-1-.448-1-1 .448-1 1-1z",transform:"translate(-1107 -888) translate(1082 799) translate(1 81) translate(24 8)"})})})})}function Wr(){return(0,o.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",children:(0,o.jsx)("g",{fill:"none",fillRule:"evenodd",children:(0,o.jsx)("g",{fill:"#707578",children:(0,o.jsx)("path",{d:"M14.714 5.286c2.604 2.603 2.604 6.825 0 9.428-2.603 2.604-6.825 2.604-9.428 0-2.604-2.603-2.604-6.825 0-9.428 2.603-2.604 6.825-2.604 9.428 0zm-8.703.725c-2.203 2.203-2.203 5.775 0 7.978 2.203 2.203 5.775 2.203 7.978 0 2.142-2.142 2.201-5.577.178-7.791l-.178-.187-.187-.178c-2.214-2.023-5.649-1.964-7.79.178zM10 5.833c2.301 0 4.167 1.866 4.167 4.167 0 2.301-1.866 4.167-4.167 4.167-2.301 0-4.167-1.866-4.167-4.167C5.833 7.699 7.7 5.833 10 5.833z",transform:"translate(-175 -158) translate(150 141) translate(1 9) translate(24 8)"})})})})}function zr(){return(0,o.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",children:(0,o.jsx)("g",{fill:"none",fillRule:"evenodd",children:(0,o.jsx)("g",{fill:"#707578",children:(0,o.jsx)("path",{d:"M15 3.333c.92 0 1.667.747 1.667 1.667v10c0 .92-.747 1.667-1.667 1.667H5c-.92 0-1.667-.747-1.667-1.667V5c0-.92.747-1.667 1.667-1.667h10zm0 .834H5c-.427 0-.78.321-.828.736L4.167 5v10c0 .427.321.78.736.828l.097.005h10c.427 0 .78-.321.828-.736l.005-.097V5c0-.427-.321-.78-.736-.828L15 4.167zm-.833 1.666v8.334H5.833V5.833h8.334z",transform:"translate(-175 -158) translate(150 141) translate(1 9) translate(24 8)"})})})})}var Ur=n(88995);function Gr(){return(0,o.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"24",viewBox:"0 0 25 24",children:(0,o.jsx)("g",{fill:"none",fillRule:"evenodd",children:(0,o.jsx)("g",{fill:"#707578",children:(0,o.jsx)("path",{d:"M12 3.5c4.694 0 8.5 3.806 8.5 8.5s-3.806 8.5-8.5 8.5-8.5-3.806-8.5-8.5S7.306 3.5 12 3.5zm0 1c-4.142 0-7.5 3.358-7.5 7.5 0 4.142 3.358 7.5 7.5 7.5 4.142 0 7.5-3.358 7.5-7.5 0-4.142-3.358-7.5-7.5-7.5zm1.367 3.429C14.959 8.492 16.1 10.215 16.1 12c0 1.16-.481 2.294-1.256 3.1h.356c.245 0 .45.177.492.41l.008.09c0 .245-.177.45-.41.492l-.09.008h-2.008l-.048-.003-.034-.005c-.088-.017-.167-.055-.233-.11l-.06-.06c-.037-.044-.067-.096-.087-.151l-.001-.004-.012-.04c-.004-.012-.007-.024-.009-.037v-.005c-.005-.024-.006-.042-.007-.06L12.7 13.6c0-.276.224-.5.5-.5.245 0 .45.177.492.41l.008.09v1.176c.833-.6 1.4-1.676 1.4-2.776 0-1.373-.886-2.71-2.067-3.129-.26-.092-.396-.377-.304-.638.092-.26.378-.396.638-.304zm-2.559-.03c.03.001.058.004.086.01l.062.016.018.006c.04.015.075.034.108.056.086.059.152.143.188.242l.001.004.008.025c.006.017.01.034.013.052l.008.09v2c0 .276-.224.5-.5.5-.245 0-.45-.177-.492-.41l-.008-.09V9.224c-.833.6-1.4 1.676-1.4 2.776 0 1.373.886 2.71 2.067 3.129.26.092.396.377.304.638-.092.26-.378.396-.638.304C9.041 15.508 7.9 13.785 7.9 12c0-1.16.481-2.294 1.255-3.1H8.8c-.245 0-.45-.177-.492-.41L8.3 8.4c0-.245.177-.45.41-.492L8.8 7.9h2.008z",transform:"translate(-233 -689) translate(-1 673) translate(37 16) translate(197.298)"})})})})}var Hr=(0,ct.Z)("div")({display:"flex",justifyContent:"center",width:"1.5em",marginRight:"0.3em"});function Xr(e){var t=(0,mt.Z)((function(e){return e.breakpoints.down("sm")})),n=(0,u.useState)(!1),r=n[0],i=n[1],a=(0,u.useState)(!1),s=a[0],c=a[1],l=(0,u.useState)(!1),d=l[0],h=l[1],f=kt(),p=f.isFetching,v=f.updateRecordingRules,x=f.roomType,w=(Rn().setIsChatWindowOpen,function(){var e=Qe().room,t=(0,u.useState)(Boolean(null===e||void 0===e?void 0:e.isRecording)),n=t[0],r=t[1];return(0,u.useEffect)((function(){if(e){r(e.isRecording);var t=function(){return r(!0)},n=function(){return r(!1)};return e.on("recordingStarted",t),e.on("recordingStopped",n),function(){e.off("recordingStarted",t),e.off("recordingStopped",n)}}}),[e]),n}
1()),y=Qe(),b=y.room,C=(y.setIsBackgroundSelectionOpen,(0,u.useRef)(null)),j=function(){var e=Qe().localTracks,t=(0,u.useState)(!1),n=t[0],r=t[1],i=e.find((function(e){return!e.name.includes("screen")&&"video"===e.kind})),o=tt(i),a=bt().videoInputDevices;(0,u.useEffect)((function(){(null===o||void 0===o?void 0:o.getSettings().facingMode)&&!1===n&&r(!0)}),[o,n]);var s=(0,u.useCallback)((function(){var e="user"===(null===o||void 0===o?void 0:o.getSettings().facingMode)?"environment":"user";null===i||void 0===i||i.restart((0,g.Z)((0,m.Z)({},ze),{facingMode:e}))}),[o,i]);return{flipCameraDisabled:!i,toggleFacingMode:s,flipCameraSupported:n&&a.length>1}}(),_=j.flipCameraDisabled,k=j.toggleFacingMode,Z=j.flipCameraSupported;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(xe.Z,{onClick:function(){return c((function(e){return!e}))},ref:C,className:e.buttonClassName,"data-cy-more-button":!0,children:t?(0,o.jsx)(vt.Z,{}):(0,o.jsxs)(o.Fragment,{children:["More",(0,o.jsx)(Fr.Z,{})]})}),(0,o.jsxs)(ft.Z,{open:s,onClose:function(){return c((function(e){return!e}))},anchorEl:C.current,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:t?-55:"bottom",horizontal:"center"},children:[(0,o.jsxs)(pt.Z,{onClick:function(){return h(!0)},children:[(0,o.jsx)(Hr,{children:(0,o.jsx)(Wt,{})}),(0,o.jsx)(Ie.Z,{variant:"body1",children:"Audio and Video Settings"})]}),Z&&(0,o.jsxs)(pt.Z,{disabled:_,onClick:k,children:[(0,o.jsx)(Hr,{children:(0,o.jsx)(Gr,{})}),(0,o.jsx)(Ie.Z,{variant:"body1",children:"Flip Camera"})]}),"peer-to-peer"!==x&&"go"!==x&&(0,o.jsxs)(pt.Z,{disabled:p,onClick:function(){c(!1),v(b.sid,w?[{type:"exclude",all:!0}]:[{type:"include",all:!0}])},"data-cy-recording-button":!0,children:[(0,o.jsx)(Hr,{children:w?(0,o.jsx)(zr,{}):(0,o.jsx)(Wr,{})}),(0,o.jsxs)(Ie.Z,{variant:"body1",children:[w?"Stop":"Start"," Recording"]})]}),(0,o.jsxs)(pt.Z,{onClick:function(){qe.VideoRoomMonitor.toggleMonitor(),c(!1)},children:[(0,o.jsx)(Hr,{children:(0,o.jsx)(Ur.Z,{style:{fill:"#707578",width:"0.9em"}})}),(0,o.jsx)(Ie.Z,{variant:"body1",children:"Room Monitor"})]}),(0,o.jsxs)(pt.Z,{onClick:function(){return i(!0)},children:[(0,o.jsx)(Hr,{children:(0,o.jsx)(Vr,{})}),(0,o.jsx)(Ie.Z,{variant:"body1",children:"About"})]})]}),(0,o.jsx)(St,{open:r,onClose:function(){i(!1),c(!1)}}),(0,o.jsx)(Vt,{open:d,onClose:function(){h(!1),c(!1)}})]})}function Kr(){return(0,o.jsx)("svg",{width:"19",height:"17",viewBox:"0 0 19 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,o.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0 1C0 0.723858 0.223858 0.5 0.5 0.5H18.5C18.7761 0.5 19 0.723858 19 1V13C19 13.2761 18.7761 13.5 18.5 13.5H9.3096L6.32421 16.361C6.1796 16.4996 5.96624 16.5385 5.78202 16.4599C5.59779 16.3813 5.47826 16.2003 5.47826 16V13.5H0.5C0.223858 13.5 0 13.2761 0 13V1ZM1 1.5V12.5H5.97826C6.2544 12.5 6.47826 12.7239 6.47826 13V14.8283L8.76274 12.639C8.85583 12.5498 8.97977 12.5 9.1087 12.5H18V1.5H1Z",fill:"#707578"})})}var qr=(0,Ze.Z)({iconContainer:{position:"relative",display:"flex"},circle:{width:"10px",height:"10px",backgroundColor:"#5BB75B",borderRadius:"50%",position:"absolute",top:"-3px",left:"13px",opacity:0,transition:"opacity ".concat(350,"ms ease-in")},hasUnreadMessages:{opacity:1},ring:{border:"3px solid #5BB75B",borderRadius:"30px",height:"14px",width:"14px",position:"absolute",left:"11px",top:"-5px",opacity:0},animateRing:{animation:"$expand ".concat(700,"ms ease-out"),animationIterationCount:1},"@keyframes expand":{"0%":{transform:"scale(0.1, 0.1)",opacity:0},"50%":{opacity:1},"100%":{transform:"scale(1.4, 1.4)",opacity:0}
1}});function Yr(){var e=qr(),t=(0,u.useState)(!1),n=t[0],r=t[1],i=Rn(),a=i.isChatWindowOpen,s=i.setIsChatWindowOpen,c=i.conversation,l=i.hasUnreadMessages,d=Qe().setIsBackgroundSelectionOpen;return(0,u.useEffect)((function(){n&&setTimeout((function(){return r(!1)}),700)}),[n]),(0,u.useEffect)((function(){if(c&&!a){var e=function(){return r(!0)};return c.onMessageAdded(e),function(){c.offMessageAdded(e)}}}),[c,a]),(0,o.jsx)(xe.Z,{"data-cy-chat-button":!0,onClick:function(){s(!a),d(!1)},disabled:!c,startIcon:(0,o.jsxs)("div",{className:e.iconContainer,children:[(0,o.jsx)(Kr,{}),(0,o.jsx)("div",{className:(0,rn.Z)(e.ring,(0,S.Z)({},e.animateRing,n))}),(0,o.jsx)("div",{className:(0,rn.Z)(e.circle,(0,S.Z)({},e.hasUnreadMessages,l))})]}),children:"Chat"})}var Jr=(0,Ze.Z)((function(){return(0,Dn.Z)({button:{"&[disabled]":{color:"#bbb","& svg *":{fill:"#bbb"}}}})}));function Qr(e){var t=Jr(),n=pr(),r=Qe().toggleScreenShare,i=Boolean(n),a=navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia,s=e.disabled||i||!a,c="";return i&&(c="Cannot share screen when another user is sharing"),a||(c="Screen sharing is not supported with this browser"),(0,o.jsx)(wr.ZP,{title:c,placement:"top",PopperProps:{disablePortal:!0},style:{cursor:s?"not-allowed":"pointer"},children:(0,o.jsx)("span",{children:(0,o.jsx)(xe.Z,{className:t.button,onClick:r,disabled:s,startIcon:(0,o.jsx)(Cr,{}),"data-cy-share-screen":!0,children:"Share Screen"})})})}var $r=n(97375);var ei=function(){var e=(0,$r.qY)(),t=e.isOpen,n=e.onOpen,a=e.onClose,s=J(),c=(0,u.useState)(s.friendlyName),l=c[0],d=c[1],h=(0,u.useState)(s.townIsPubliclyListed),f=h[0],p=h[1],m=(0,u.useState)(""),g=m[0],x=m[1],w=(0,u.useCallback)((function(){n(),s.pause()}),[n,s]),y=(0,u.useCallback)((function(){a(),s.unPause()}),[a,s]),b=(0,mn.pm)(),C=function(){var e=(0,r.Z)((function(e){var t,n;return(0,i.__generator)(this,(function(r){switch(r.label){case 0:if("delete"!==e)return[3,5];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,s.deleteTown(g)];case 2:return r.sent(),b({title:"Town deleted",status:"success"}),y(),[3,4];case 3:return t=r.sent(),(0,v.Z)(t,Error)?b({title:"Unable to delete town",description:t.toString(),status:"error"}):(console.trace(t),b({title:"Unexpected error, see browser console for details.",status:"error"})),[3,4];case 4:return[3,8];case 5:return r.trys.push([5,7,,8]),[4,s.updateTown(g,{isPubliclyListed:f,friendlyName:l})];case 6:return r.sent(),b({title:"Town updated",description:"To see the updated town, please exit and re-join this town",status:"success"}),y(),[3,8];case 7:return n=r.sent(),(0,v.Z)(n,Error)?b({title:"Unable to update town",description:n.toString(),status:"error"}):(console.trace(n),b({title:"Unexpected error, see browser console for details.",status:"error"})),[3,8];case 8:return[2]}}
1))}));return function(t){return e.apply(this,arguments)}}();return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(pt.Z,{"data-testid":"openMenuButton",onClick:w,children:(0,o.jsx)(Ie.Z,{variant:"body1",children:"Town Settings"})}),(0,o.jsxs)(cr.u_,{isOpen:t,onClose:y,children:[(0,o.jsx)(cr.ZA,{}),(0,o.jsxs)(cr.hz,{children:[(0,o.jsxs)(cr.xB,{children:["Edit town ",s.friendlyName," (",s.townID,")"]}),(0,o.jsx)(cr.ol,{}),(0,o.jsxs)("form",{onSubmit:function(e){e.preventDefault(),C("edit")},children:[(0,o.jsxs)(cr.fe,{pb:6,children:[(0,o.jsxs)(gn.NI,{children:[(0,o.jsx)(gn.lX,{htmlFor:"friendlyName",children:"Friendly Name"}),(0,o.jsx)(xn.II,{id:"friendlyName",placeholder:"Friendly Name",name:"friendlyName",value:l,onChange:function(e){return d(e.target.value)}})]}),(0,o.jsxs)(gn.NI,{mt:4,children:[(0,o.jsx)(gn.lX,{htmlFor:"isPubliclyListed",children:"Publicly Listed"}),(0,o.jsx)(wn.XZ,{id:"isPubliclyListed",name:"isPubliclyListed",isChecked:f,onChange:function(e){return p(e.target.checked)}})]}),(0,o.jsxs)(gn.NI,{isRequired:!0,children:[(0,o.jsx)(gn.lX,{htmlFor:"updatePassword",children:"Town Update Password"}),(0,o.jsx)(xn.II,{"data-testid":"updatePassword",id:"updatePassword",placeholder:"Password",name:"password",type:"password",value:g,onChange:function(e){return x(e.target.value)}})]})]}),(0,o.jsxs)(cr.mz,{children:[(0,o.jsx)(yn.zx,{"data-testid":"deletebutton",colorScheme:"red",mr:3,value:"delete",name:"action1",onClick:function(){return C("delete")},children:"Delete"}),(0,o.jsx)(yn.zx,{"data-testid":"updatebutton",colorScheme:"blue",mr:3,value:"update",name:"action2",onClick:function(){return C("edit")},children:"Update"}),(0,o.jsx)(yn.zx,{onClick:y,children:"Cancel"})]})]})]})]})]})},ti=n(83454),ni=(0,Ze.Z)((function(e){return(0,Dn.Z)({container:(0,S.Z)({backgroundColor:e.palette.background.default,bottom:20,left:0,right:0,height:"".concat(e.footerHeight,"px"),position:"absolute",display:"flex",padding:"0 1.43em",zIndex:10},e.breakpoints.down("sm"),{height:"".concat(e.mobileFooterHeight,"px"),padding:0}),screenShareBanner:{position:"fixed",zIndex:8,bottom:"".concat(e.footerHeight,"px"),left:0,right:0,height:"104px",background:"rgba(0, 0, 0, 0.5)","& h6":{color:"white"},"& button":{background:"white",color:e.brand,border:"2px solid ".concat(e.brand),margin:"0 2em","&:hover":{color:"#600101",border:"2px solid #600101",background:"#FFE9E7"}}},hideMobile:(0,S.Z)({display:"initial"},e.breakpoints.down("sm"),{display:"none"})})}));function ri(){var e=ni(),t=Qe(),n=t.isSharingScreen,r=t.toggleScreenShare,i="reconnecting"===Lt();Qe().room;return(0,o.jsxs)(o.Fragment,{children:[n&&(0,o.jsxs)(Se.Z,{container:!0,justifyContent:"center",alignItems:"center",className:e.screenShareBanner,children:[(0,o.jsx)(Ie.Z,{variant:"h6",children:"You are sharing your screen"}),(0,o.jsx)(xe.Z,{onClick:function(){return r()},children:"Stop Sharing"})]}),(0,o.jsx)("footer",{className:e.container,children:(0,o.jsxs)(Se.Z,{container:!0,justifyContent:"space-around",alignItems:"center",children:[(0,o.jsx)(Se.Z,{item:!0,children:(0,o.jsxs)(Se.Z,{container:!0,justifyContent:"center",children:["true"!==ti.env.REACT_APP_DISABLE_TWILIO_CONVERSATIONS&&(0,o.jsx)(Yr,{}),(0,o.jsx)(Kt,{disabled:i}),(0,o.jsx)(Jt,{disabled:i}),!n&&!De&&(0,o.jsx)(Qr,{disabled:i}),(0,o.jsxs)(Te.Z,{smDown:!0,children:[(0,o.jsx)(Xr,{}),(0,o.jsx)(ei,{})]})]})}),(0,o.jsx)(Te.Z,{smDown:!0,children:(0,o.jsx)(Se.Z,{style:{flex:1},children:(0,o.jsx)(Se.Z,{container:!0,justifyContent:"flex-end",children:(0,o.jsx)(Mr,{})})})})]})})]})}var ii=(0,Ze.Z)((function(e){return{container:(0,S.Z)({background:"white",paddingLeft:"1em",display:"none",height:"".concat(e.mobileTopBarHeight,"px")},e.breakpoints.down("sm"),{display:"flex"}),endCallButton:{height:"28px",fontSize:"0.85rem",padding:"0 0.6em"},settingsButton:(0,S.Z)({},e.breakpoints.down("sm"),{height:"28px",minWidth:"28px",border:"1px solid rgb(136, 140, 142)",padding:0,margin:"0 1em"})}}));function oi(){var e=ii(),t=Qe().room;return(0,o.jsxs)(Se.Z,{container:!0,alignItems:"center",justifyContent:"space-between",className:e.container,children:[(0,o.jsx)(Ie.Z,{variant:"subtitle1",children:t.name}),(0,o.jsxs)("div",{children:[(0,o.jsx)(Mr,{className:e.endCallButton}),(0,o.jsx)(Xr,{buttonClassName:e.settingsButton})]})]})}function ai(){var e=Lt();return(0,o.jsx)(hn,{variant:"error",headline:"Connection Lost:",message:"Reconnecting to room...",open:"reconnecting"===e})}var si=(0,ct.Z)("div")({}),ci=(0,ct.Z)("main")((function(e){var t=e.theme;return(0,S.Z)({overflow:"hidden",position:"relative",paddingBottom:"".concat(t.footerHeight,"px")},t.breakpoints.down("sm"),{paddingBottom:"".concat(t.mobileFooterHeight+t.mobileTopBarHeight,"px")})}));function li(e){var t=Qe().room,n=Lt(),r=J(),i=(0,T.Z)(Xt(),2),a=i[0],s=i[1],c=(0,T.Z)(Ve(),2),l=c[0],d=c[1],h=(0,u.useRef)(),f=(0,u.useRef)(),p=(0,u.useRef)(),v=(0,u.useState)(),m=v[0],g=(v[1],null===r||void 0===r?void 0:r.townID);g||(g="Disconnected"),(0,u.useEffect)((function(){var e=function(){try{a&&s()}catch(e){}try{l&&d()}catch(r){}try{!t||"connected"!==n&&"reconnecting"!==n||t.disconnect()}catch(i){}};h.current=function(){e()},f.current=function(t){t.preventDefault(),e()}}),[t,n,l,a,s,d]),(0,u.useEffect)((function(){return function(){h&&h.current&&h.current()}}),[]),(0,u.useEffect)((function(){return f&&f.current&&window.addEventListener("beforeunload",f.current),function(){f&&f.current&&window.removeEventListener("beforeunload",f.current)}}),[]);var x=null===t||void 0===t?void 0:t.sid;return(0,u.useEffect)((function(){!p.current||x===p.current.sid&&g===p.current.sid||"connected"===p.current.state&&p.current.disconnect(),p.current=t||void 0}),[x,t,g]),(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(en.NL,{when:"disconnected"!==n,message:"Are you sure you want to leave the video room?"}),(0,o.jsxs)(si,{style:{height:"100%"},children:["disconnected"===n?(0,o.jsx)("div",{children:"Connecting..."}):(0,o.jsxs)(ci,{style:{paddingBottom:"90px"},children:[(0,o.jsx)(ai,{}),(0,o.jsx)(oi,{}),(0,o.jsx)(si,{className:"videochat-container",children:(0,o.jsx)(Rr,{})}),(0,o.jsx)(ri,{})]}),(0,o.jsx)(fn,{error:m})]})]})}var ui=n(82260),di=n.n(ui);function hi(e){var t=e.player;return(0,o.jsx)(o.Fragment,{children:t.userName})}function fi(e){var t=e.area,n=function(e){var t=(0,u.useState)(e.occupants),n=t[0],r=t[1];return(0,u.useEffect)((function(){return e.addListener("occupantsChange",r),function(){e.removeListener("occupantsChange",r)}}),[e]),n}(t),r=function(e){var t=(0,u.useState)(e.topic),n=t[0],r=t[1];return(0,u.useEffect)((function(){return e.addListener("topicChange",r),function(){e.removeListener("topicChange",r)}}),[e]),n||"(No topic)"}(t);return(0,o.jsxs)(vn.xu,{children:[(0,o.jsxs)(vn.X6,{as:"h3",fontSize:"m",children:[t.id,": ",r]}),(0,o.jsx)(vn.QI,{children:n.map((function(e){return(0,o.jsx)(vn.HC,{children:(0,o.jsx)(hi,{player:e})},e.id)}))})]})}function pi(){var e=function(){var e=J(),t=(0,u.useState)(e.conversationAreas.filter((function(e){return!e.isEmpty()}))),n=t[0],r=t[1];return(0,u.useEffect)((function(){var t=function(){var t=e.conversationAreas;r(t.filter((function(e){return!e.isEmpty()})))};return e.addListener("interactableAreasChanged",t),function(){e.removeListener("interactableAreasChanged",t)}}),[e,r]),n}();return(0,o.jsxs)(vn.xu,{children:[(0,o.jsx)(vn.X6,{as:"h2",fontSize:"l",children:"Active Conversation Areas:"}),0===e.length?(0,o.jsx)(o.Fragment,{children:"No active conversation areas"}):e.sort((function(e,t){return e.id.localeCompare(t.id,void 0,{numeric:!0,sensitivity:"base"})})).map((function(e){return(0,o.jsx)(fi,{area:e},e.id)}))]})}var vi=n(86541);function mi(){var e=he(),t=J(),n=t.friendlyName,r=t.townID,i=e.concat([]);return i.sort((function(e,t){return e.userName.localeCompare(t.userName,void 0,{numeric:!0,sensitivity:"base"})})),(0,o.jsxs)(vn.xu,{children:[(0,o.jsx)(vi.u,{label:"Town ID: ".concat(r),children:(0,o.jsxs)(vn.X6,{as:"h2",fontSize:"l",children:["Current town: ",n]})}),(0,o.jsx)(vn.GS,{children:i.map((function(e){return(0,o.jsx)(vn.HC,{children:(0,o.jsx)(hi,{player:e})},e.id)}))})]})}function gi(){return(0,o.jsxs)(vn.gC,{align:"left",spacing:2,border:"2px",padding:2,marginLeft:2,borderColor:"gray.500",height:"100%",divider:(0,o.jsx)(vn.cX,{borderColor:"gray.200"}),borderRadius:"4px",children:[(0,o.jsx)(vn.X6,{fontSize:"xl",as:"h1",children:"Players In This Town"}),(0,o.jsx)(mi,{}),(0,o.jsx)(pi,{})]})}function xi(){var e=J(),t=fe("conversationArea"),n=(0,u.useState)(""),a=n[0],s=n[1],c=void 0!==t;(0,u.useEffect)((function(){t?e.pause():e.unPause()}),[e,t]);var l=(0,u.useCallback)((function(){t&&e.interactEnd(t)}),[e,t]),d=(0,mn.pm)(),h=(0,u.useCallback)((0,r.Z)((function(){var n,r;return(0,i.__generator)(this,(function(i){switch(i.label){case 0:if(!a||!t)return[3,4];n={topic:a,id:t.name,occupants:[]},i.label=1;case 1:return i.trys.push([1,3,,4]),[4,e.createConversationArea(n)];case 2:return i.sent(),d({title:"Conversation Created!",status:"success"}),s(""),e.unPause(),l(),[3,4];case 3:return r=i.sent(),(0,v.Z)(r,Error)?d({title:"Unable to create conversation",description:r.toString(),status:"error"}):(console.trace(r),d({title:"Unexpected Error",status:"error"})),[3,4];case 4:return[2]}}
1))})),[a,s,e,t,l,d]);return(0,o.jsxs)(cr.u_,{isOpen:c,onClose:function(){l(),e.unPause()},children:[(0,o.jsx)(cr.ZA,{}),(0,o.jsxs)(cr.hz,{children:[(0,o.jsxs)(cr.xB,{children:["Create a conversation in ",null===t||void 0===t?void 0:t.name," "]}),(0,o.jsx)(cr.ol,{}),(0,o.jsxs)("form",{onSubmit:function(e){e.preventDefault(),h()},children:[(0,o.jsx)(cr.fe,{pb:6,children:(0,o.jsxs)(gn.NI,{children:[(0,o.jsx)(gn.lX,{htmlFor:"topic",children:"Topic of Conversation"}),(0,o.jsx)(xn.II,{id:"topic",placeholder:"Share the topic of your conversation",name:"topic",value:a,onChange:function(e){return s(e.target.value)}})]})}),(0,o.jsxs)(cr.mz,{children:[(0,o.jsx)(yn.zx,{colorScheme:"blue",mr:3,onClick:h,children:"Create"}),(0,o.jsx)(yn.zx,{onClick:l,children:"Cancel"})]})]})]})]})}var wi=n(4111),yi=function(e){(0,p.Z)(n,e);var t=(0,w.Z)(n);function n(e){var r;return(0,h.Z)(this,n),(r=t.call(this,e,0,0,"Interactable"))._isOverlapping=!1,r._scene=e,r.townController=e.coveyTownController,e.physics.world.enable((0,wi.Z)(r)),r}var r=n.prototype;return r.addedToScene=function(){var e,t=this;(0,te.Z)((0,ne.Z)(n.prototype),"addedToScene",this).call(this),this.townController=this.scene.coveyTownController,this._id=this.name;var r=null===(e=this.townController.ourPlayer.gameObjects)||void 0===e?void 0:e.sprite;if(!r)throw new Error("Expected player sprite created by now");this.scene.physics.add.overlap(r,this,(function(){t._isOverlapping||(t._isOverlapping=!0,t._scene.addOverlapExit(t,(function(){t._isOverlapping=!1,t.overlapExit()})),t.overlap()),t.isOverlapping&&t._scene.cursorKeys.space.isDown&&!t.townController.paused&&(t.townController.interact(t),t.interact())}))},r.overlap=function(){},r.overlapExit=function(){},r.interact=function(){},(0,f.Z)(n,[{key:"id",get:function(){if(!this._id)throw new Error("Expected ID to be set");return this._id}},{key:"isOverlapping",get:function(){return this._isOverlapping}}]),n}(Phaser.GameObjects.Sprite),bi=function(e){(0,p.Z)(n,e);var t=(0,w.Z)(n);function n(){return(0,h.Z)(this,n),t.apply(this,arguments)}var r=n.prototype;return r.getType=function(){return"conversationArea"},r.removedFromScene=function(){var e;this._changeListener&&(null===(e=this._conversationArea)||void 0===e||e.removeListener("topicChange",this._changeListener))},r.addedToScene=function(){var e=this;(0,te.Z)((0,ne.Z)(n.prototype),"addedToScene",this).call(this),this.setTintFill(),this.setAlpha(.3),this.scene.add.text(this.x-this.displayWidth/2,this.y-this.displayHeight/2,this.name,{color:"#FFFFFF",backgroundColor:"#000000"}),this._topicTextOrUndefined=this.scene.add.text(this.x-this.displayWidth/2,this.y+this.displayHeight/2,"(No Topic)",{color:"#000000"}),this._conversationArea=this.townController.getConversationAreaController(this),this._updateLabelText(this._conversationArea.topic),this._changeListener=function(t){return e._updateLabelText(t)},this._conversationArea.addListener("topicChange",this._changeListener)},r._updateLabelText=function(e){void 0===e?this._topicText.text="(No topic)":(this.isOverlapping&&this._scene.moveOurPlayerTo({interactableID:this.name}),this._topicText.text=e,this._infoTextBox&&this._infoTextBox.visible&&this._infoTextBox.setVisible(!1))},r.getBoundingBox=function(){var e=this.getBounds();return{x:e.x,y:e.y,width:e.width,height:e.height}},r._showInfoBox=function(){this._infoTextBox||(this._infoTextBox=this.scene.add.text(this.scene.scale.width/2,this.scene.scale.height/2,"You've found an empty conversation area!\nTell others what you'd like to talk about here\nby providing a topic label for the conversation.\nSpecify a topic by pressing the spacebar.",{color:"#000000",backgroundColor:"#FFFFFF"}).setScrollFactor(0).setDepth(30)),this._infoTextBox.setVisible(!0),this._infoTextBox.x=this.scene.scale.width/2-this._infoTextBox.width/2},r.overlap=function(){var e;void 0===(null===(e=this._conversationArea)||void 0===e?void 0:e.topic)&&this._showInfoBox()},r.overlapExit=function(){var e;null===(e=this._infoTextBox)||void 0===e||e.setVisible(!1)},(0,f.Z)(n,[{key:"_topicText",get:function(){var e=this._topicTextOrUndefined;if(!e)throw new Error("Expected topic text to be defined");return e}}]),n}(yi),Ci=function(e){(0,p.Z)(n,e);var t=(0,w.Z)(n);function n(){var e;return(0,h.Z)(this,n),(e=t.apply(this,arguments))._isInteracting=!1,e}var r=n.prototype;return r.addedToScene=function(){(0,te.Z)((0,ne.Z)(n.prototype),"addedToScene",this).call(this),this.setTintFill(),this.setAlpha(.3),this.setDepth(-1),this.scene.add.text(this.x-this.displayWidth/2,this.y+this.displayHeight/2,this.name,{color:"#FFFFFF",backgroundColor:"#000000"})},r.overlapExit=function(){this._isInteracting&&(this.townController.interactableEmitter.emit("endInteraction",this),this._isInteracting=!1)},r.interact=function(){this._isInteracting=!0},r.getType=function(){return"gameArea"},n}(yi),ji=function(e){(0,p.Z)(n,e);var t=(0,w.Z)(n);function n(){return(0,h.Z)(this,n),t.apply(this,arguments)}var r=n.prototype;return r.addedToScene=function(){(0,te.Z)((0,ne.Z)(n.prototype),"addedToScene",this).call(this);var e=this.findTargetObject();if(void 0===e.x||void 0===e.y)throw new Error("Expected target object to have x,y coordinates");this._targetX=e.x,this._targetY=e.y,this.setVisible(!1)},r.isOverlappingOnServer=function(){return!0},r.findTargetObject=function(){var e=this.getData("target"),t=this._scene.map.findObject("Objects",(function(t){return t.id==e}));if(!t)throw new Error("Unable to find target object ".concat(e," for transporter ").concat(this.name));return t},r.overlap=function(){this._scene.moveOurPlayerTo({x:this._targetX,y:this._targetY})},r.getType=function(){return"transporter"},n}(yi),_i=function(e){(0,p.Z)(n,e);var t=(0,w.Z)(n);function n(){var e;return(0,h.Z)(this,n),(e=t.apply(this,arguments))._isInteracting=!1,e}var r=n.prototype;return r.addedToScene=function(){(0,te.Z)((0,ne.Z)(n.prototype),"addedToScene",this).call(this),this.setTintFill(),this.setAlpha(.3),this._defaultVideoURL=this.getData("video"),this._labelText=this.scene.add.text(this.x-this.displayWidth/2,this.y-this.displayHeight/2,"Press space to watch the ".concat(this.name," video"),{color:"#FFFFFF",backgroundColor:"#000000"}),this._labelText.setVisible(!1),this.setDepth(-1)},r.overlap=function(){if(!this._labelText)throw new Error("Should not be able to overlap with this interactable before added to scene");var e=this.townController.ourPlayer.location;this._labelText.setX(e.x),this._labelText.setY(e.y),this._labelText.setVisible(!0)},r.overlapExit=function(){var e;null===(e=this._labelText)||void 0===e||e.setVisible(!1),this._isInteracting&&(this.townController.interactableEmitter.emit("endInteraction",this),this._isInteracting=!1)},r.interact=function(){var e;null===(e=this._labelText)||void 0===e||e.setVisible(!1),this._isInteracting=!0},r.getType=function(){return"viewingArea"},(0,f.Z)(n,[{key:"defaultVideoURL",get:function(){return this._defaultVideoURL?this._defaultVideoURL:"No URL found"}}]),n}
1(yi),ki=function(e){(0,p.Z)(n,e);var t=(0,w.Z)(n);function n(){var e;return(0,h.Z)(this,n),(e=t.apply(this,arguments))._isInteracting=!1,e}var r=n.prototype;return r.addedToScene=function(){(0,te.Z)((0,ne.Z)(n.prototype),"addedToScene",this).call(this),this.setTintFill(),this.setAlpha(.3),this.setDepth(-1),this.scene.add.text(this.x-this.displayWidth/2,this.y+this.displayHeight/2,this.name,{color:"#FFFFFF",backgroundColor:"#000000"})},r.overlapExit=function(){this._isInteracting&&(this.townController.interactableEmitter.emit("endInteraction",this),this._isInteracting=!1)},r.interact=function(){this._isInteracting=!0},r.getType=function(){return"whiteboardArea"},n}(yi);function Zi(e){if("ConversationArea"===e)return bi;if("Transporter"===e)return ji;if("ViewingArea"===e)return _i;if("GameArea"===e)return Ci;if("WhiteboardArea"===e)return ki;throw new Error("Unknown object type: ".concat(e))}var Si=function(e){(0,p.Z)(n,e);var t=(0,w.Z)(n);function n(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return(0,h.Z)(this,n),(r=t.call(this,"TownGameScene"))._pendingOverlapExits=new Map,r._players=[],r._interactables=[],r._cursors=[],r._previouslyCapturedKeys=[],r._ready=!1,r._paused=!1,r._onGameReadyListeners=[],r._collidingLayers=[],r._gameIsReady=new Promise((function(e){r._ready?e():r._onGameReadyListeners.push(e)})),r._resourcePathPrefix=i,r.coveyTownController=e,r._players=r.coveyTownController.players,r}var r=n.prototype;return r.addOverlapExit=function(e,t){this._pendingOverlapExits.set(e,t)},r.preload=function(){this.load.image("Room_Builder_32x32",this._resourcePathPrefix+"/assets/tilesets/Room_Builder_32x32.png"),this.load.image("22_Museum_32x32",this._resourcePathPrefix+"/assets/tilesets/22_Museum_32x32.png"),this.load.image("5_Classroom_and_library_32x32",this._resourcePathPrefix+"/assets/tilesets/5_Classroom_and_library_32x32.png"),this.load.image("12_Kitchen_32x32",this._resourcePathPrefix+"/assets/tilesets/12_Kitchen_32x32.png"),this.load.image("1_Generic_32x32",this._resourcePathPrefix+"/assets/tilesets/1_Generic_32x32.png"),this.load.image("13_Conference_Hall_32x32",this._resourcePathPrefix+"/assets/tilesets/13_Conference_Hall_32x32.png"),this.load.image("14_Basement_32x32",this._resourcePathPrefix+"/assets/tilesets/14_Basement_32x32.png"),this.load.image("16_Grocery_store_32x32",this._resourcePathPrefix+"/assets/tilesets/16_Grocery_store_32x32.png"),this.load.tilemapTiledJSON("map",this._resourcePathPrefix+"/assets/tilemaps/indoors.json"),this.load.atlas("atlas",this._resourcePathPrefix+"/assets/atlas/atlas.png",this._resourcePathPrefix+"/assets/atlas/atlas.json")},r.updatePlayers=function(e){var t=this;e.map((function(e){return t.createPlayerSprites(e)})),this._players.filter((function(t){return!e.find((function(e){return e.id===t.id}))})).forEach((function(e){if(e.gameObjects){var t=e.gameObjects,n=t.sprite,r=t.label;n&&r&&(n.destroy(),r.destroy())}})),this._players=e},r.getNewMovementDirection=function(){return this._cursors.find((function(e){var t;return null===(t=e.left)||void 0===t?void 0:t.isDown}))?"left":this._cursors.find((function(e){var t;return null===(t=e.right)||void 0===t?void 0:t.isDown}))?"right":this._cursors.find((function(e){var t;return null===(t=e.down)||void 0===t?void 0:t.isDown}))?"front":this._cursors.find((function(e){var t;return null===(t=e.up)||void 0===t?void 0:t.isDown}))?"back":void 0},r.moveOurPlayerTo=function(e){var t=this.coveyTownController.ourPlayer.gameObjects;if(!t)throw new Error("Unable to move player without game objects created first");this._lastLocation||(this._lastLocation={moving:!1,rotation:"front",x:0,y:0}),void 0!==e.x&&(t.sprite.x=e.x,this._lastLocation.x=e.x),void 0!==e.y&&(t.sprite.y=e.y,this._lastLocation.y=e.y),void 0!==e.moving&&(this._lastLocation.moving=e.moving),void 0!==e.rotation&&(this._lastLocation.rotation=e.rotation),this.coveyTownController.emitMovement(this._lastLocation)},r.update=function(){var e=this;if(!this._paused){var t=this.coveyTownController.ourPlayer.gameObjects;if(t&&this._cursors){var n=t.sprite.body.velocity.clone(),r=t.sprite.body;r.setVelocity(0);var i=this.getNewMovementDirection();switch(i){case"left":r.setVelocityX(-175),t.sprite.anims.play("misa-left-walk",!0);break;case"right":r.setVelocityX(ce),t.sprite.anims.play("misa-right-walk",!0);break;case"front":r.setVelocityY(ce),t.sprite.anims.play("misa-front-walk",!0);break;case"back":r.setVelocityY(-175),t.sprite.anims.play("misa-back-walk",!0);break;default:t.sprite.anims.stop(),n.x<0?t.sprite.setTexture("atlas","misa-left"):n.x>0?t.sprite.setTexture("atlas","misa-right"):n.y<0?t.sprite.setTexture("atlas","misa-back"):n.y>0&&t.sprite.setTexture("atlas","misa-front")}t.sprite.body.velocity.normalize().scale(ce);var o=void 0!==i;t.label.setX(r.x),t.label.setY(r.y-20);var a=t.sprite.getBounds().centerX,s=t.sprite.getBounds().centerY;(!this._lastLocation||o&&this._lastLocation.rotation!==i||this._lastLocation.moving!==o)&&(this._lastLocation||(this._lastLocation={x:a,y:s,rotation:i||"front",moving:o}),this._lastLocation.x=a,this._lastLocation.y=s,this._lastLocation.rotation=i||this._lastLocation.rotation||"front",this._lastLocation.moving=o,this._pendingOverlapExits.forEac
1h((function(n,r){di().Geom.Rectangle.Overlaps(r.getBounds(),t.sprite.getBounds())||(e._pendingOverlapExits.delete(r),n())})),this.coveyTownController.emitMovement(this._lastLocation));var c=!0,l=!1,u=void 0;try{for(var d,h=this._players[Symbol.iterator]();!(c=(d=h.next()).done);c=!0){var f,p,v=d.value;(null===(f=v.gameObjects)||void 0===f?void 0:f.label)&&(null===(p=v.gameObjects)||void 0===p?void 0:p.sprite.body)&&(v.gameObjects.label.setX(v.gameObjects.sprite.body.x),v.gameObjects.label.setY(v.gameObjects.sprite.body.y-20))}}catch(m){l=!0,u=m}finally{try{c||null==h.return||h.return()}finally{if(l)throw u}}}}},r.getInteractables=function(){var e=this.map.filterObjects("Objects",(function(e){return""!==e.type}));return l()(e),this.map.createFromObjects("Objects",e.map((function(e){return{id:e.id,classType:Zi(e.type)}})))},r.create=function(){var e=this;this._map=this.make.tilemap({key:"map"});var t=["Room_Builder_32x32","22_Museum_32x32","5_Classroom_and_library_32x32","12_Kitchen_32x32","1_Generic_32x32","13_Conference_Hall_32x32","14_Basement_32x32","16_Grocery_store_32x32"].map((function(t){var n=e.map.addTilesetImage(t);return l()(n),n}));this._collidingLayers=[];var n=this.map.createLayer("Below Player",t,0,0);l()(n),n.setDepth(-10);var r=this.map.createLayer("Walls",t,0,0),i=this.map.createLayer("On The Walls",t,0,0);l()(r),l()(i),r.setCollisionByProperty({collides:!0}),i.setCollisionByProperty({collides:!0});var o=this.map.createLayer("World",t,0,0);l()(o),o.setCollisionByProperty({collides:!0});var a=this.map.createLayer("Above Player",t,0,0);l()(a),a.setCollisionByProperty({collides:!0});var s=this.map.createLayer("Very Above Player",t,0,0);l()(s),o.setDepth(5),a.setDepth(10),s.setDepth(15);var c=this.map.findObject("Objects",(function(e){return"Spawn Point"===e.name})),u=this.map.filterObjects("Objects",(function(e){return"label"===e.name}));null===u||void 0===u||u.forEach((function(t){t.x&&t.y&&e.add.text(t.x,t.y,t.text.text,{color:"#FFFFFF",backgroundColor:"#000000"})})),l()(this.input.keyboard),this._cursorKeys=this.input.keyboard.createCursorKeys(),this._cursors.push(this._cursorKeys),this._cursors.push(this.input.keyboard.addKeys({up:di().Input.Keyboard.KeyCodes.W,down:di().Input.Keyboard.KeyCodes.S,left:di().Input.Keyboard.KeyCodes.A,right:di().Input.Keyboard.KeyCodes.D},!1)),this._cursors.push(this.input.keyboard.addKeys({up:di().Input.Keyboard.KeyCodes.H,down:di().Input.Keyboard.KeyCodes.J,left:di().Input.Keyboard.KeyCodes.K,right:di().Input.Keyboard.KeyCodes.L},!1));var d=this.physics.add.sprite(c.x,c.y,"atlas","misa-front").setSize(30,40).setOffset(0,24).setDepth(6),h=this.add.text(c.x,c.y-20,"(You)",{font:"18px monospace",color:"#000000",backgroundColor:"#ffffff"}).setDepth(6);this.coveyTownController.ourPlayer.gameObjects={sprite:d,label:h,locationManagedByGameScene:!0},this._interactables=this.getInteractables(),this.moveOurPlayerTo({rotation:"front",moving:!1,x:c.x,y:c.y}),this._collidingLayers.push(o),this._collidingLayers.push(r),this._collidingLayers.push(a),this._collidingLayers.push(i),this._collidingLayers.forEach((function(t){return e.physics.add.collider(d,t)}));var f=this.anims;f.create({key:"misa-left-walk",frames:f.generateFrameNames("atlas",{prefix:"misa-left-walk.",start:0,end:3,zeroPad:3}),frameRate:10,repeat:-1}),f.create({key:"misa-right-walk",frames:f.generateFrameNames("atlas",{prefix:"misa-right-walk.",start:0,end:3,zeroPad:3}),frameRate:10,repeat:-1}),f.create({key:"misa-front-walk",frames:f.generateFrameNames("atlas",{prefix:"misa-front-walk.",start:0,end:3,zeroPad:3}),frameRate:10,repeat:-1}),f.create({key:"misa-back-walk",frames:f.generateFrameNames("atlas",{prefix:"misa-back-walk.",start:0,end:3,zeroPad:3}),frameRate:10,repeat:-1});var p=this.cameras.main;p.startFollow(this.coveyTownController.ourPlayer.gameObjects.sprite),p.setBounds(0,0,this.map.widthInPixels,this.map.heightInPixels),this.add.text(16,16,"Arrow keys to move",{font:"18px monospace",color:"#000000",padding:{x:20,y:10},backgroundColor:"#ffffff"}).setScrollFactor(0).setDepth(30),this._ready=!0,this.updatePlayers(this.coveyTownController.players),this._onGameReadyListeners.forEac
1h((function(e){return e()})),this._onGameReadyListeners=[],this.coveyTownController.addListener("playersChanged",(function(t){return e.updatePlayers(t)}))},r.createPlayerSprites=function(e){var t=this;if(!e.gameObjects){var n=this.physics.add.sprite(e.location.x,e.location.y,"atlas","misa-front").setSize(30,40).setOffset(0,24),r=this.add.text(e.location.x,e.location.y-20,e===this.coveyTownController.ourPlayer?"(You)":e.userName,{font:"18px monospace",color:"#000000",backgroundColor:"#ffffff"});e.gameObjects={sprite:n,label:r,locationManagedByGameScene:!1},this._collidingLayers.forEach((function(e){return t.physics.add.collider(n,e)}))}},r.pause=function(){if(!this._paused){this._paused=!0;var e=this.coveyTownController.ourPlayer.gameObjects;if(e)e.sprite.anims.stop(),e.sprite.body.setVelocity(0);l()(this.input.keyboard),this._previouslyCapturedKeys=this.input.keyboard.getCaptures(),this.input.keyboard.clearCaptures()}},r.resume=function(){this._paused&&(this._paused=!1,this.input&&this.input.keyboard&&this.input.keyboard.addCapture(this._previouslyCapturedKeys),this._previouslyCapturedKeys=[])},(0,f.Z)(n,[{key:"gameIsReady",get:function(){return this._gameIsReady}},{key:"cursorKeys",get:function(){var e=this._cursorKeys;if(!e)throw new Error("Unable to access cursors before game scene is loaded");return e}},{key:"map",get:function(){var e=this._map;if(!e)throw new Error("Cannot access map before it is initialized");return e}}]),n}(di().Scene),Ti=n(88429);function Pi(e){var t=e.results,n={};t.forEach((function(e){var t,r,i,o,a,s,c,l,u,d,h,f,p=Object.keys(e.scores),v=p[0],m=p[1],g=e.scores[v]>e.scores[m]?v:e.scores[m]>e.scores[v]?m:void 0,x=e.scores[v]<e.scores[m]?v:e.scores[m]<e.scores[v]?m:void 0;g&&(n[g]={player:g,wins:((null===(t=n[g])||void 0===t?void 0:t.wins)||0)+1,losses:(null===(r=n[g])||void 0===r?void 0:r.losses)||0,ties:(null===(i=n[g])||void 0===i?void 0:i.ties)||0});x&&(n[x]={player:x,wins:(null===(o=n[x])||void 0===o?void 0:o.wins)||0,losses:((null===(a=n[x])||void 0===a?void 0:a.losses)||0)+1,ties:(null===(s=n[x])||void 0===s?void 0:s.ties)||0});g||x||(n[v]={player:v,wins:(null===(c=n[v])||void 0===c?void 0:c.wins)||0,losses:(null===(l=n[v])||void 0===l?void 0:l.losses)||0,ties:((null===(u=n[v])||void 0===u?void 0:u.ties)||0)+1},n[m]={player:m,wins:(null===(d=n[m])||void 0===d?void 0:d.wins)||0,losses:(null===(h=n[m])||void 0===h?void 0:h.losses)||0,ties:((null===(f=n[m])||void 0===f?void 0:f.ties)||0)+1})}));var r=Object.keys(n).map((function(e){return n[e]}));return r.sort((function(e,t){return t.wins-e.wins})),(0,o.jsxs)(bn.iA,{children:[(0,o.jsx)(bn.hr,{children:(0,o.jsxs)(bn.Tr,{children:[(0,o.jsx)("th",{children:"Player"}),(0,o.jsx)("th",{children:"Wins"}),(0,o.jsx)("th",{children:"Losses"}),(0,o.jsx)("th",{children:"Ties"})]})}),(0,o.jsx)(bn.p3,{children:r.map((function(e){return(0,o.jsxs)(bn.Tr,{children:[(0,o.jsx)(bn.Td,{children:e.player}),(0,o.jsx)(bn.Td,{children:e.wins}),(0,o.jsx)(bn.Td,{children:e.losses}),(0,o.jsx)(bn.Td,{children:e.ties})]},e.player)}))})]})}function Ii(e){var t=e.results,n={},r=[];t.forEach((function(e){var t=Object.keys(e.scores);t.filter((function(e){return r.includes(e)})).forEach((function(t){var r={player:t,score:n[t].score+e.scores[t]};n[t]=r})),t.filter((function(e){return!r.includes(e)})).forEach((function(t){var i={player:t,score:e.scores[t]};n[t]=i,r.push(t)}))}));var i=Object.keys(n).map((function(e){return n[e]}));return i.sort((function(e,t){return t.score-e.score})),(0,o.jsxs)(bn.iA,{children:[(0,o.jsx)(bn.hr,{children:(0,o.jsxs)(bn.Tr,{children:[(0,o.jsx)("th",{children:"Player"}),(0,o.jsx)("th",{children:"score"})]})}),(0,o.jsx)(bn.p3,{children:i.map((function(e){return(0,o.jsxs)(bn.Tr,{children:[(0,o.jsx)(bn.Td,{children:e.player}),(0,o.jsx)(bn.Td,{children:e.score})]},e.player)}))})]})}var Ei=n(5993),Li=(0,Ei.m$)(yn.zx,{baseStyle:{justifyContent:"center",alignItems:"center",flexBasis:"33%",border:"1px solid black",height:"33%",fontSize:"50px",_disabled:{opacity:"100%"}}}),Ai=(0,Ei.m$)(vn.W2,{baseStyle:{display:"flex",width:"400px",height:"400px",padding:"5px",flexWrap:"wrap"}});function Ni(e){var t=e.gameAreaController,n=(0,u.useState)(t.board),a=n[0],s=n[1],c=(0,u.useState)(t.isOurTurn),l=c[0],d=c[1],h=(0,mn.pm)();return(0,u.useEffect)((function(){return t.addListener("turnChanged",d),t.addListener("boardChanged",s),function(){t.removeListener("boardChanged",s),t.removeListener("turnChanged",d)}}),[t]),(0,o.jsx)(Ai,{"aria-label":"Tic-Tac-Toe Board",children:a.map((function(e,n){return e.map((function(e,a){return(0,o.jsx)(Li,{onClick:(0,r.Z)((function(){var e;return(0,i.__generator)(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,t.makeMove(n,a)];case 1:return r.sent(),[3,3];case 2:return e=r.sent(),h({title:"Error making move",description:e.toString(),status:"error"}),[3,3];case 3:return[2]}}
1))})),disabled:!l,"aria-label":"Cell ".concat(n,",").concat(a),children:e},"".concat(n,".").concat(a))}))}))})}function Di(e){var t=de(e.interactableID),n=J(),a=(0,u.useState)(t.history),s=a[0],c=a[1],l=(0,u.useState)(t.status),d=l[0],h=l[1],f=(0,u.useState)(t.moveCount),p=f[0],v=f[1],m=(0,u.useState)(t.observers),g=m[0],x=m[1],w=(0,u.useState)(!1),y=w[0],b=w[1],C=(0,u.useState)(t.x),j=C[0],_=C[1],k=(0,u.useState)(t.o),Z=k[0],S=k[1],T=(0,mn.pm)();(0,u.useEffect)((function(){var e=function(){c(t.history),h(t.status||"WAITING_TO_START"),v(t.moveCount||0),x(t.observers),_(t.x),S(t.o)};t.addListener("gameUpdated",e);var r=function(){var e=t.winner;e?e===n.ourPlayer?T({title:"Game over",description:"You won!",status:"success"}):T({title:"Game over",description:"You lost :(",status:"error"}):T({title:"Game over",description:"Game ended in a tie",status:"info"})};return t.addListener("gameEnd",r),function(){t.removeListener("gameEnd",r),t.removeListener("gameUpdated",e)}}),[n,t,T]);var P=(0,o.jsx)(o.Fragment,{});if("IN_PROGRESS"===d){var I;P=(0,o.jsxs)(o.Fragment,{children:["Game in progress, ",p," moves in, currently"," ",t.whoseTurn===n.ourPlayer?"your":(null===(I=t.whoseTurn)||void 0===I?void 0:I.userName)+"'s"," ","turn"]})}else{var E=(0,o.jsx)(o.Fragment,{});("WAITING_TO_START"===t.status&&!t.isPlayer||"OVER"===t.status)&&(E=(0,o.jsx)(yn.zx,{onClick:(0,r.Z)((function(){var e;return(0,i.__generator)(this,(function(n){switch(n.label){case 0:b(!0),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,t.joinGame()];case 2:return n.sent(),[3,4];case 3:return e=n.sent(),T({title:"Error joining game",description:e.toString(),status:"error"}),[3,4];case 4:return b(!1),[2]}}))})),isLoading:y,disabled:y,children:"Join New Game"})),P=(0,o.jsxs)("b",{children:["Game ","WAITING_TO_START"===d?"not yet started":"over",". ",E]})}return(0,o.jsxs)(vn.W2,{children:[(0,o.jsxs)(Ti.UQ,{allowToggle:!0,children:[(0,o.jsxs)(Ti.Qd,{children:[(0,o.jsx)(vn.X6,{as:"h3",children:(0,o.jsx)(Ti.KF,{children:(0,o.jsxs)(vn.xu,{as:"span",flex:"1",textAlign:"left",children:["Leaderboard",(0,o.jsx)(Ti.XE,{})]})})}),(0,o.jsx)(Ti.Hk,{children:(0,o.jsx)(Pi,{results:s})})]}),(0,o.jsxs)(Ti.Qd,{children:[(0,o.jsx)(vn.X6,{as:"h3",children:(0,o.jsx)(Ti.KF,{children:(0,o.jsxs)(vn.xu,{as:"span",flex:"1",textAlign:"left",children:["Current Observers",(0,o.jsx)(Ti.XE,{})]})})}),(0,o.jsx)(Ti.Hk,{children:(0,o.jsx)(vn.aV,{"aria-label":"list of observers in the game",children:g.map((function(e){return(0,o.jsx)(vn.HC,{children:e.userName},e.id)}))})})]})]}),P,(0,o.jsxs)(vn.aV,{"aria-label":"list of players in the game",children:[(0,o.jsxs)(vn.HC,{children:["X: ",(null===j||void 0===j?void 0:j.userName)||"(No player yet!)"]}),(0,o.jsxs)(vn.HC,{children:["O: ",(null===Z||void 0===Z?void 0:Z.userName)||"(No player yet!)"]})]}),(0,o.jsx)(Ni,{gameAreaController:t})]})}function Oi(){var e=fe("gameArea"),t=J(),n=(0,u.useCallback)((function(){e&&(t.interactEnd(e),t.getGameAreaController(e).leaveGame())}),[t,e]);return e&&"TicTacToe"===e.getData("type")?(0,o.jsxs)(cr.u_,{isOpen:!0,onClose:n,closeOnOverlayClick:!1,children:[(0,o.jsx)(cr.ZA,{}),(0,o.jsxs)(cr.hz,{children:[(0,o.jsx)(cr.xB,{children:e.name}),(0,o.jsx)(cr.ol,{}),(0,o.jsx)(Di,{interactableID:e.name}),";"]})]}):(0,o.jsx)(o.Fragment,{})}var Ri=function(e){var t=e.gameStatusText,n=e.observers,r=e.gameAreaController,i=(0,u.useState)(r.history),a=i[0],s=i[1];return(0,u.useEffect)((function(){s(r.history)}),[r.history]),(0,o.jsxs)("div",{children:[(0,o.jsxs)(Ti.UQ,{allowToggle:!0,children:[(0,o.jsxs)(Ti.Qd,{children:[(0,o.jsx)(vn.X6,{as:"h3",children:(0,o.jsx)(Ti.KF,{children:(0,o.jsxs)(vn.xu,{as:"span",flex:"1",textAlign:"left",children:["Leaderboard",(0,o.jsx)(Ti.XE,{})]})})}),(0,o.jsx)(Ti.Hk,{children:(0,o.jsx)(Ii,{results:a})})]}),(0,o.jsxs)(Ti.Qd,{children:[(0,o.jsx)(vn.X6,{as:"h3",children:(0,o.jsx)(Ti.KF,{children:(0,o.jsxs)(vn.xu,{as:"span",flex:"1",textAlign:"left",children:["Current Observers",(0,o.jsx)(Ti.XE,{})]})})}),(0,o.jsx)(Ti.Hk,{children:(0,o.jsx)(vn.aV,{"aria-label":"list of observers in the game",children:n.map((function(e){return(0,o.jsx)(vn.HC,{children:e.userName},e.id)}))})})]})]}),t]})};var Bi=function(e){var t=e.scores,n=e.players;return(0,o.jsxs)(vn.W2,{children:[(0,o.jsx)(vn.X6,{as:"h4",size:"md",children:"Scores:"}),t?(0,o.jsx)(vn.QI,{children:Object.entries(t).map((function(e){var t=(0,T.Z)(e,2),r=t[0],i=t[1],a=n.find((function(e){return e.id===r}));return(0,o.jsx)(vn.HC,{children:"Player ".concat(a?a.userName:r,": ").concat(i)},r)}))}):(0,o.jsx)("p",{children:"No scores available"})]})},Mi=n(11391),Fi=n(74474);function Vi(e){var t=e.interactableId,n=e.isPictionaryWhiteboard,r=J(),i=r.getWhiteboardAreaController(t),a=(0,u.useState)(),s=a[0],c=a[1],l=(0,u.useCallback)((function(e){return c(e)}),[]),d=(0,u.useState)(!1),h=d[0],f=d[1],p=(0,u.useState)(i.viewers),v=p[0],x=p[1],w=(0,mn.pm)(),y=(0,u.useCallback)((function(e){var t=e.title,r=e.description,i=e.status;n||w({title:t,description:r,status:i,isClosable:!0,position:"top-right",duration:2e3})}),[w,n]),b=(0,u.useCallback)((function(e){var t=e.newDrawer,n=e.newViewers,r=new Map;
1t&&r.set(t.id,{id:t.id,username:t.userName}),n.forEach((function(e){r.set(e.id,{id:e.id,username:e.userName})})),null===s||void 0===s||s.updateScene({collaborators:r})}),[s]);return(0,u.useEffect)((function(){f(i.isDrawer()),x(i.viewers),b({newDrawer:i.drawer,newViewers:i.viewers})}),[b,i]),(0,u.useEffect)((function(){var e=function(e){var t=e.player,n=e.isDrawer?"Drawer":"Viewer",o=t.id===r.ourPlayer.id?"You have joined the whiteboard":"".concat(t.userName," has joined the whiteboard");y({title:"A wild ".concat(n," has appeared!"),description:o,status:"info"}),f(i.isDrawer()),x(i.viewers),b({newDrawer:i.drawer,newViewers:i.viewers})},t=function(e){var t=e.player,n=t.id===r.ourPlayer.id,o=n?"You have become the Drawer, the holder of Excalidraw":"".concat(t.userName," has become the Drawer, the holder of Excalidraw");y({title:"New Drawer has emerged!",description:o,status:n?"success":"info"}),f(i.isDrawer()),x(i.viewers),b({newDrawer:i.drawer,newViewers:i.viewers})},n=function(){f(!1),x(i.viewers),b({newDrawer:void 0,newViewers:i.viewers})},o=function(e){var t=e.player;y({title:"Player Leave",description:"Player ".concat(t.userName," has returned to the shadow realm"),status:"info"}),f(i.isDrawer()),x(i.viewers),b({newDrawer:i.drawer,newViewers:i.viewers})},a=function(e){var t=e.elements;null===s||void 0===s||s.updateScene({elements:t})},c=function(e){var t=e.player,n=e.payload,r=null===s||void 0===s?void 0:s.getAppState().collaborators,i=null===r||void 0===r?void 0:r.get(t.id);null===r||void 0===r||r.set(t.id,(0,g.Z)((0,m.Z)({},i),{pointer:(0,m.Z)({},n.pointer),button:n.button})),null===s||void 0===s||s.updateScene({collaborators:new Map(r)})};return i.addListener("whiteboardPlayerJoin",e),i.addListener("whiteboardNewDrawer",t),i.addListener("whiteboardClearDrawer",n),i.addListener("whiteboardPlayerLeave",o),i.addListener("whiteboardNewScene",a),i.addListener("whiteboardPointerUpdate",c),function(){i.removeListener("whiteboardPlayerJoin",e),i.removeListener("whiteboardNewDrawer",t),i.removeListener("whiteboardClearDrawer",n),i.removeListener("whiteboardPlayerLeave",o),i.removeListener("whiteboardNewScene",a),i.removeListener("whiteboardPointerUpdate",c)}}),[i,w,r.ourPlayer.id,s,y,b]),(0,o.jsx)(o.Fragment,{children:(0,o.jsxs)(vn.gC,{h:"2xl",w:["sm","2xl","6xl"],margin:2,children:[h&&!n&&(0,o.jsx)("form",{onSubmit:function(e){e.preventDefault();var t=e.target.drawerId.value;t?i.drawerChange(t):y({title:"No new drawer selected",description:"Need to select a new drawer to change",status:"error"})},children:(0,o.jsxs)(vn.Ug,{justify:"center",children:[(0,o.jsx)(Mi.Ph,{placeholder:"Select new drawer",w:"2xs",name:"drawerId",children:v.map((function(e){return(0,o.jsx)("option",{value:e.id,children:e.userName},e.id)}))}),(0,o.jsx)(yn.zx,{type:"submit",children:"Change Drawer"})]})}),(0,o.jsx)(Fi.Excalidraw,{ref:l,isCollaborating:!0,viewModeEnabled:!h,onChange:Xn()((function(e){h&&i.boardChange(e)}),20),onPointerUpdate:Xn()((function(e){i.pointerChange(e)}),20)})]})})}var Wi=function(e){var t=e.gameAreaController,n=(0,u.useState)(t.isPlayer),a=n[0],s=n[1],c=(0,u.useState)(t.isOurTurn),l=c[0],d=c[1],h=(0,u.useState)(t.currentWord),f=h[0],p=h[1],v=(0,u.useState)(t.betweenTurns),m=v[0],g=v[1],x=(0,u.useState)(t.timer),w=x[0],y=x[1],b=(0,u.useState)(t.players),C=b[0],j=b[1],_=(0,u.useState)(""),k=_[0],Z=_[1],S=(0,mn.pm)();(0,u.useEffect)((function(){s(t.isPlayer),d(t.isOurTurn),p(t.currentWord),y(t.timer),g(t.betweenTurns),j(t.players)}),[t.isPlayer,t.isOurTurn,t.currentWord,t.timer,t.betweenTurns,t.players]);var T=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(vn.X6,{as:"h4",size:"md",children:m?"The word was:":"Your word:"}),f]});return(0,o.jsxs)(vn.Ug,{h:"2xl",w:["sm","2xl","6xl"],alignItems:"top",margin:2,children:[(0,o.jsx)(Vi,{interactableId:"".concat(e.interactableID,"WhiteboardArea"),isPictionaryWhiteboard:!0}),(0,o.jsxs)(vn.gC,{width:250,spacing:"12",paddingTop:4,align:"flex-start",children:[(0,o.jsx)(vn.X6,{as:"h4",size:"md",children:m?"".concat(5-w," seconds until next turn."):"".concat(30-w," seconds left to ").concat(l?"draw":"guess",".")}),a?l||m?T:(0,o.jsx)(o.Fragment,{children:(0,o.jsxs)(vn.kC,{direction:"column",children:[(0,o.jsx)(xn.II,{placeholder:"Type your guess here",value:k,onChange:function(e){return Z(e.target.value)}},"guessInput"),(0,o.jsx)(yn.zx,{onClick:(0,r.Z)((function(){var e;return(0,i.__generator)(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,t.makeGuess(k).then((function(){Z(""),t.weAlreadyGuessedCorrectly?S({title:"Correct!",status:"success"}):S({title:"Incorrect.",status:"error"})}))];case 1:return n.sent(),[3,3];case 2:return e=n.sent(),S({title:"Error making guess",description:e.toString(),status:"error"}),[3,3];case 3:return[2]}}
1))})),children:"Guess"})]})}):m?T:(0,o.jsx)(o.Fragment,{}),(0,o.jsx)(Bi,{scores:t.scores,players:C})]})]})};function zi(e){var t=e.interactableID,n=de(t),a=J(),s=(0,u.useState)(n.isPlayer),c=s[0],l=s[1],d=(0,u.useState)(n.status),h=d[0],f=d[1],p=(0,u.useState)(n.observers),v=p[0],m=p[1],g=(0,u.useState)(!1),x=g[0],w=g[1],y=(0,u.useState)(n.drawer),b=y[0],C=y[1],j=(0,mn.pm)(),_=fe("gameArea");(0,u.useEffect)((function(){_&&(console.log("pause town controller"),a.pause())}),[_,a]),(0,u.useEffect)((function(){var e=function(){l(n.isPlayer),f(n.status||"WAITING_TO_START"),m(n.observers),C(n.drawer)};n.addListener("gameUpdated",e);var t=function(){var e=n.winner;e?e===a.ourPlayer?j({title:"Game over",description:"You won!",status:"success"}):j({title:"Game over",description:"You lost :(",status:"error"}):j({title:"Game over",description:"Game ended in a tie",status:"info"})};return n.addListener("gameEnd",t),function(){n.removeListener("gameEnd",t),n.removeListener("gameUpdated",e)}}),[a,n.isPlayer,n.status,n.observers,n.drawer,n.currentWord,n.betweenTurns,n.timer,n,j]);var k=(0,o.jsx)(o.Fragment,{});if("IN_PROGRESS"===h)k=(0,o.jsxs)(o.Fragment,{children:["Game in progress, currently"," ",b===a.ourPlayer?"your":(null===b||void 0===b?void 0:b.userName)+"'s"," turn"]});else{var Z=(0,o.jsx)(o.Fragment,{});"WAITING_TO_START"===n.status&&!c||"OVER"===n.status?Z=(0,o.jsx)(yn.zx,{onClick:(0,r.Z)((function(){var e;return(0,i.__generator)(this,(function(t){switch(t.label){case 0:w(!0),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,n.joinGame()];case 2:return t.sent(),[3,4];case 3:return e=t.sent(),j({title:"Error joining game",description:e.toString(),status:"error"}),[3,4];case 4:return w(!1),[2]}}))})),isLoading:x,disabled:x,children:"Join New Game"}):"WAITING_TO_START"===n.status&&c&&(Z=(0,o.jsx)(yn.zx,{disabled:n.players.length<2,onClick:(0,r.Z)((function(){var e;return(0,i.__generator)(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,n.startGame()];case 1:return t.sent(),[3,3];case 2:return e=t.sent(),j({title:"Error starting game",description:e.toString(),status:"error"}),[3,3];case 3:return[2]}}
1))})),children:"Start"})),k=(0,o.jsxs)("b",{children:["Game ","WAITING_TO_START"===h?"not yet started":"over",". ",Z]})}return(0,o.jsx)(vn.W2,{maxW:"fit-content",maxH:"fit-content",children:"IN_PROGRESS"===h?(0,o.jsx)(Wi,{gameAreaController:n,interactableID:t}):(0,o.jsx)(Ri,{gameStatusText:k,observers:v,gameAreaController:n})})}function Ui(){var e=fe("gameArea"),t=J(),n=(0,u.useCallback)((function(){e&&(t.interactEnd(e),t.getGameAreaController(e).leaveGame(),t.unPause())}),[t,e]);return e&&"Pictionary"===e.getData("type")?(0,o.jsxs)(cr.u_,{isOpen:!0,onClose:n,closeOnOverlayClick:!1,children:[(0,o.jsx)(cr.ZA,{}),(0,o.jsxs)(cr.hz,{maxW:"fit-content",maxH:"fit-content",marginTop:10,children:[(0,o.jsx)(cr.xB,{children:e.name}),(0,o.jsx)(cr.ol,{}),(0,o.jsx)(zi,{interactableID:e.name}),";"]})]}):(0,o.jsx)(o.Fragment,{})}function Gi(){var e=J(),t=fe("whiteboardArea");(0,u.useEffect)((function(){t&&(e.getWhiteboardAreaController(t.id).joinArea(),e.pause())}),[e,t]);var n=(0,u.useCallback)((function(){t&&(e.interactEnd(t),e.getWhiteboardAreaController(t.id).leaveArea(),e.unPause())}),[e,t]);return t?(0,o.jsxs)(cr.u_,{isOpen:void 0!==t,onClose:n,trapFocus:!1,children:[(0,o.jsx)(cr.ZA,{}),(0,o.jsxs)(cr.hz,{maxW:"fit-content",maxH:"fit-content",marginTop:10,children:[(0,o.jsx)(cr.xB,{paddingBottom:0,children:"Whiteboard"}),(0,o.jsx)(cr.ol,{}),(0,o.jsx)(Vi,{interactableId:t.id,isPictionaryWhiteboard:!1})]})]}):(0,o.jsx)(o.Fragment,{})}function Hi(){var e=J();return(0,u.useEffect)((function(){var t={type:di().AUTO,backgroundColor:"#000000",parent:"map-container",render:{pixelArt:!0,powerPreference:"high-performance"},scale:{expandParent:!1,mode:di().Scale.ScaleModes.WIDTH_CONTROLS_HEIGHT,autoRound:!0},width:800,height:600,fps:{target:30},physics:{default:"arcade",arcade:{gravity:{y:0}}}},n=new(di().Game)(t),r=new Si(e);n.scene.add("coveyBoard",r,!0);var i=r.pause.bind(r),o=r.resume.bind(r);return e.addListener("pause",i),e.addListener("unPause",o),function(){e.removeListener("pause",i),e.removeListener("unPause",o),n.destroy(!0)}}),[e]),(0,o.jsxs)("div",{id:"app-container",children:[(0,o.jsx)(xi,{}),(0,o.jsx)(Oi,{}),(0,o.jsx)(Gi,{}),(0,o.jsx)(Ui,{}),(0,o.jsx)("div",{id:"map-container"}),(0,o.jsx)("div",{id:"social-container",children:(0,o.jsx)(gi,{})})]})}var Xi=n(83454);function Ki(){var e,t=(0,u.useState)(null),n=t[0],r=t[1],i=kt(),a=i.error,s=i.setError,c=Nn(),d=(0,u.useCallback)((function(){null===n||void 0===n||n.disconnect()}),[n]);e=n?(0,o.jsx)(Y.Provider,{value:n,children:(0,o.jsxs)(ge,{children:[(0,o.jsx)(Hi,{}),(0,o.jsx)(li,{preferredMode:"fullwidth"})]})}):(0,o.jsx)(_n,{});var h="https://town-service.onrender.com";l()(h,"NEXT_PUBLIC_TOWNS_SERVICE_URL must be defined");var f=new q({BASE:h}).towns;return(0,o.jsx)(Cn.Provider,{value:{setTownController:r,townsService:f},children:(0,o.jsx)(Pn,{children:(0,o.jsxs)(Je,{options:c,onError:s,onDisconnect:d,children:[(0,o.jsx)(_e,{dismissError:function(){return s(null)},error:a}),e]})})})}var qi="DEBUG_TOWN";function Yi(){var e=(0,u.useState)(null),t=e[0],n=e[1];return(0,u.useEffect)((function(){var e="https://town-service.onrender.com";l()(e,"NEXT_PUBLIC_TOWNS_SERVICE_URL must be defined");var t=new q({BASE:e}).towns;function o(){return(o=(0,r.Z)((function(){var e,n,r,o,a;return(0,i.__generator)(this,(function(i){switch(i.label){case 0:return[4,t.listTowns()];case 1:return e=i.sent(),(n=e.find((function(e){return e.friendlyName===qi})))?[2,n.townID]:[3,2];case 2:return i.trys.push([2,4,,6]),[4,t.createTown({friendlyName:qi,isPubliclyListed:!0})];case 3:return[2,i.sent().townID];case 4:return r=i.sent(),console.error(r),[4,t.listTowns()];case 5:if(o=i.sent(),a=o.find((function(e){return e.friendlyName===qi})))return[2,a.townID];throw r;case 6:return[2]}}
1))}))).apply(this,arguments)}(function(){return o.apply(this,arguments)})().then((function(e){l()(e);var r=new ue({townID:e,loginController:{setTownController:function(){},townsService:t},userName:(0,_.x0)()});r.connect().then((function(){n(r)}))}))}),[]),t?(0,o.jsx)(Y.Provider,{value:t,children:(0,o.jsx)(ge,{children:(0,o.jsx)(Hi,{})})}):(0,o.jsx)("div",{children:"Loading..."})}function Ji(){var e=Xi.env.NEXT_PUBLIC_TOWN_DEV_MODE;return e&&"true"===e.toLowerCase()?(0,o.jsx)(Yi,{}):(0,o.jsx)(Ki,{})}function Qi(){return(0,o.jsx)(d.VK,{children:(0,o.jsx)(a.xjn,{children:(0,o.jsx)(s.Z,{theme:Ln,children:(0,o.jsx)(_t,{children:(0,o.jsx)(Ji,{})})})})})}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.