(window.webpackJsonp=window.webpackJsonp||[]).push([[179,57,58,70,83],{627:function(t,e,o){"use strict";o.r(e);o(30),o(27),o(34),o(39),o(29),o(40);var r=o(7),n=o(0),c=(o(50),o(65),o(56),o(78),o(14));function l(object,t){var e=Object.keys(object);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(object);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(object,t).enumerable}))),e.push.apply(e,o)}return e}function d(t){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?l(Object(source),!0).forEach((function(e){Object(n.a)(t,e,source[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(source)):l(Object(source)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(source,e))}))}return t}var m=o(2).default.extend({name:"ProfileSwitch",data:function(){return{toggleUsersDropdown:!1}},computed:d(d(d({},Object(c.e)({token:"token",students:"students",institution:"institution"})),Object(c.c)({isAuthenticated:"isAuthenticated",curStudent:"curStudent"})),{},{userFullName:function(){var t,e;return(null===(t=this.curStudent)||void 0===t?void 0:t.surname)?this.curStudent.firstName+" "+(null===(e=this.curStudent)||void 0===e?void 0:e.surname):this.curStudent.firstName}}),methods:d(d(d({},Object(c.d)({setInstitutionData:"SET_ORGANIZATIONDATA",setCurrentUserIndex:"SET_CURRENT_USER_INDEX"})),Object(c.b)({storeStudentInstitutions:"studentLogin/getInstitutionList",userSwitchSession:"switchUserSession"})),{},{userInitials:function(t){return this.isAuthenticated&&t?null!==t.surname?t.firstName.split(" ").reduce((function(t,e){return t+e[0]}),"").slice(0,2).toUpperCase():t.firstName.charAt(0):""},handleSwitchOrganizationClick:function(){var t=this;return Object(r.a)(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.$router.push("/".concat(t.$i18n.locale,"/branches"));case 1:case"end":return e.stop()}}),e)})))()},handleUsersDropdown:function(){this.toggleUsersDropdown=!this.toggleUsersDropdown},userName:function(t){return t.surname?t.firstName+" "+t.surname:t.firstName},handleUserChange:function(t,e){this.setCurrentUserIndex(t);var data={id:e,should_reload:!0};this.userSwitchSession(data),this.toggleUsersDropdown=!1}})}),f=o(13),component=Object(f.a)(m,(function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"pb-5"},[o("div",{staticClass:"relative"},[o("div",[o("button",{staticClass:"group w-full rounded-md bg-gray-50 px-3.5 py-2 text-left text-sm font-medium text-gray-900 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 focus:ring-offset-gray-100",attrs:{type:"button",id:"options-menu-button","aria-expanded":"false","aria-haspopup":"true"},on:{click:t.handleUsersDropdown}},[o("div",{staticClass:"flex w-full items-center justify-between"},[o("div",{staticClass:"flex min-w-0 items-center justify-between space-x-3"},[o("div",[t.curStudent&&null!==t.curStudent.image_240&&t.isAuthenticated?o("c-avatar",{attrs:{size:"small",rounded:!0,image:t.curStudent.image_240}}):t._e(),t._v(" "),!t.isAuthenticated||t.curStudent&&null!==t.curStudent.image_240?t._e():o("c-avatar",{attrs:{size:"small",nameInitials:t.userInitials(t.curStudent),rounded:!0}})],1),t._v(" "),o("div",{staticClass:"flex min-w-0 flex-1 flex-col"},[o("p",{staticClass:"truncate text-sm font-medium text-gray-900"},[t._v("\n                "+t._s(t.userFullName)+"\n              ")]),t._v(" "),o("p",{staticClass:"truncate text-sm text-gray-500"},[t._v("\n                "+t._s(t.curStudent.email)+"\n              ")])])]),t._v(" "),o("div",{staticClass:"ml-2"},[o("c-icon",{staticClass:"h-5 w-5 text-gray-400 group-hover:text-gray-500",attrs:{name:"chevron-up-down-outline-v2",type:"outline"}})],1)])])]),t._v(" "),o("transition",{attrs:{"enter-class":"transform opacity-0 scale-95","enter-active-class":"transition ease-out duration-100","enter-to-class":"transform opacity-100 scale-100","leave-class":"transform opacity-100 scale-100","leave-active-class":"transition ease-in duration-75","leave-to-class":"transform opacity-0 scale-95"}},[t.isAuthenticated&&t.toggleUsersDropdown?o("div",{staticClass:"absolute top-16 left-0 z-50 mt-2 max-h-60 w-full overflow-y-auto rounded-md border border-gray-200 bg-white",attrs:{role:"none"}},t._l(t.students,(function(e,r){return o("label",{key:e.user_detail_id,class:[0!==t.curStudent.user_detail_id&&t.curStudent.user_detail_id===e.user_detail_id?"bg-indigo-50":"bg-white hover:bg-gray-100","relative flex cursor-pointer items-center p-3 shadow-sm focus-within:ring-1 focus-within:ring-indigo-500 focus-within:ring-offset-2 hover:border-gray-400"],on:{click:function(o){return t.handleUserChange(r,e.user_detail_id)}}},[o("div",{staticClass:"flex-none"},[null!==e.image_240?o("c-avatar",{staticClass:"mr-3 inline-block h-7 w-7 rounded-full object-cover",attrs:{size:"extraextrasmall",rounded:!0,image:e.image_240}}):o("c-avatar",{attrs:{size:"extraextrasmall",nameInitials:t.userInitials(e),rounded:!0}})],1),t._v(" "),o("div",{staticClass:"ml-2"},[o("p",{staticClass:"text-sm text-gray-900"},[t._v(t._s(t.userName(e)))])])])})),0):t._e()])],1),t._v(" "),1==t.institution.branchesExist?o("button",{staticClass:"mt-5 inline-flex w-full justify-center rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2",attrs:{type:"button"},on:{click:t.handleSwitchOrganizationClick}},[o("svg",{staticClass:"mr-3 h-5 w-5 text-gray-400 group-hover:text-gray-500",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"{1.5}",stroke:"currentColor"}},[o("path",{attrs:{strokeLinecap:"round",strokeLinejoin:"round","stroke-width":"2",d:"M7.5 21L3 16.5m0 0L7.5 12M3 16.5h13.5m0-13.5L21 7.5m0 0L16.5 12M21 7.5H7.5"}})]),t._v("\n    "+t._s(t.$t("Switch_branch"))+"\n  ")]):t._e()])}),[],!1,null,null,null);e.default=component.exports},633:function(t,e,o){"use strict";o.r(e);var r=o(2).default.extend({name:"ProfileLayout"}),n=o(13),component=Object(n.a)(r,(function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"lg:flex lg:items-start"},[o("aside",{staticClass:"hidden pr-2 pl-2 pb-6 pt-3 sm:pl-0 sm:pr-6 lg:block lg:w-1/4"},[t._t("sidebar")],2),t._v(" "),o("div",{staticClass:"hidden h-[580px] w-px bg-gray-200 lg:block"}),t._v(" "),o("div",{staticClass:"sm:pl-6 lg:flex-1 lg:pt-3"},[t._t("default")],2)])}),[],!1,null,null,null);e.default=component.exports},634:function(t,e,o){"use strict";o.r(e);o(30),o(27),o(34),o(39),o(29),o(40);var r=o(0),n=o(2),c=o(14);function l(object,t){var e=Object.keys(object);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(object);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(object,t).enumerable}))),e.push.apply(e,o)}return e}function d(t){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?l(Object(source),!0).forEach((function(e){Object(r.a)(t,e,source[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(source)):l(Object(source)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(source,e))}))}return t}var m=n.default.extend({name:"ProfileNav",computed:d(d({},Object(c.e)({institution:"institution"})),{},{tabsArray:function(){var t="/".concat(this.$i18n.locale);return[{name:this.$t("My_calendar"),value:"".concat(t,"/profile/calendar"),icon:"calendar-outline",isSelected:"/profile/calendar"==this.$route.path},{name:this.$t("My_bookings"),value:"".concat(t,"/profile/bookings"),icon:"click-cursor-rays-outline",isSelected:"/profile/bookings"==this.$route.path},{name:this.$t("Chat"),value:"".concat(t,"/profile/chat"),icon:"chat-oval-left-outline-v2",isBorder:!0,isSelected:"/profile/chat"==this.$route.path},{name:this.$t("Attendance"),value:"".concat(t,"/profile/attendance"),icon:"raise-hand-outline",isSelected:"/profile/attendance"==this.$route.path},{name:this.$t("Billing"),value:"".concat(t,"/profile/billing"),icon:"dollar-outline",isSelected:"/profile/billing"==this.$route.path},{name:this.$t("My_files"),value:"".concat(t,"/profile/files"),icon:"document",isSelected:"/profile/files"==this.$route.path},{name:this.$t("My_courses"),value:"".concat(t,"/profile/coursesList"),icon:"collection-outline",isSelected:"/profile/coursesList"==this.$route.path},{name:"en"!=this.$i18n.locale?this.$t("Grades"):"gradebook"==this.institution.wordCustomisation.gradebook&&"Grades"==this.$t("Grades")?"Grades":"gradebook"!=this.institution.wordCustomisation.gradebook&&"Grades"==this.$t("Grades")?this.institution.wordCustomisation.gradebookPlural:this.$t("Grades"),value:"".concat(t,"/profile/grades"),icon:"chart-bar-outline",isSelected:"/profile/grades"==this.$route.path}]}}),methods:{handleSidebarOptions:function(t){this.$router.push(t.value)}}}),f=o(13),component=Object(f.a)(m,(function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"space-y-2"},t._l(t.tabsArray,(function(e,r){return o("div",{key:r},[o("div",{class:"group flex cursor-pointer items-center rounded-md px-3 py-2 text-sm font-medium text-gray-900 hover:bg-gray-100 hover:text-gray-900 "+(e.isSelected?"bg-gray-100":""),on:{click:function(o){return t.handleSidebarOptions(e)}}},[o("c-icon",{class:"mr-2 h-6 w-6 "+(e.isSelected?"text-gray-500":"text-gray-400")+" shrink-0",attrs:{name:e.icon,type:"outline"}}),t._v(" "),o("p",{staticClass:"text-sm text-gray-900"},[t._v(t._s(e.name))])],1),t._v(" "),e.isBorder?o("div",{staticClass:"mt-8 ml-4 w-full"},[o("p",{staticClass:"text-sm text-gray-500"},[t._v(t._s(t.$t("Profile")))])]):t._e()])})),0)}),[],!1,null,null,null);e.default=component.exports},655:function(t,e,o){var content=o(680);content.__esModule&&(content=content.default),"string"==typeof content&&(content=[[t.i,content,""]]),content.locals&&(t.exports=content.locals);(0,o(72).default)("ffe342b8",content,!0,{sourceMap:!1})},679:function(t,e,o){"use strict";o(655)},680:function(t,e,o){var r=o(71)((function(i){return i[1]}));r.push([t.i,'span.toolTipBottom[data-v-724422d2]:after{content:"";position:absolute;width:0;height:0;border:8px solid transparent;border-bottom:8px solid var(--color);top:-15px;left:106px}span.tooltip[data-v-724422d2]:after{rotate:270deg;bottom:-12px}span.tooltip[data-v-724422d2]:after,span.tooltipFirst[data-v-724422d2]:after{content:"";position:absolute;width:0;height:0;border:8px solid transparent;border-right:8px solid var(--color);left:calc(100% - 15px)}span.tooltipFirst[data-v-724422d2]:after{rotate:90deg;top:-13px}span.tooltipSender[data-v-724422d2]:after{rotate:270deg;bottom:-12px}span.tooltipSender[data-v-724422d2]:after,span.tooltipSenderFirst[data-v-724422d2]:after{content:"";position:absolute;width:0;height:0;border:8px solid transparent;border-right:8px solid var(--color);right:calc(100% - 15px)}span.tooltipSenderFirst[data-v-724422d2]:after{rotate:90deg;top:-13px}.fade-enter-active[data-v-724422d2],.fade-leave-active[data-v-724422d2]{transition:opacity .5s}.fade-enter[data-v-724422d2],.fade-leave-to[data-v-724422d2]{opacity:0}',""]),r.locals={},t.exports=r},689:function(t,e,o){"use strict";o.r(e);var r={props:{classes:{type:String},tooltipText:{type:String},color:{type:String},isSender:{type:Boolean,default:!1},isFirstIndex:{type:Boolean,default:!1},isBottom:{type:Boolean,default:!1}},data:function(){return{}},computed:{arrowColor:function(){return{"--color":this.color}}}},n=(o(679),o(13)),component=Object(n.a)(r,(function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("transition",{attrs:{name:"fade"}},[o("span",{staticClass:"absolute z-100 rounded-md px-3 py-2 text-sm opacity-100 shadow-lg",class:[t.classes,t.isBottom?"toolTipBottom":t.isSender?t.isFirstIndex?"tooltipSenderFirst":"tooltipSender":t.isFirstIndex?"tooltipFirst":"tooltip"],style:t.arrowColor},[t._v(t._s(t.tooltipText))])])}),[],!1,null,"724422d2",null);e.default=component.exports},787:function(t,e,o){var content=o(861);content.__esModule&&(content=content.default),"string"==typeof content&&(content=[[t.i,content,""]]),content.locals&&(t.exports=content.locals);(0,o(72).default)("16650fab",content,!0,{sourceMap:!1})},860:function(t,e,o){"use strict";o(787)},861:function(t,e,o){var r=o(71)((function(i){return i[1]}));r.push([t.i,".chat-message{max-width:80%}@media (max-width:640px){.chat-messages{max-height:calc(100vh - 266px)}.chat-input-container{position:fixed;bottom:0px;left:0px;right:0px;--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity));padding-left:1rem;padding-right:1rem;padding-top:0.75rem;padding-bottom:0.75rem;--tw-shadow:0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.chat-input-container input{margin-right:0.5rem}}",""]),r.locals={},t.exports=r},887:function(t,e,o){"use strict";o.r(e);o(30),o(27),o(39),o(40);var r=o(7),n=o(0),c=(o(50),o(45),o(77),o(29),o(392),o(394),o(221),o(34),o(2)),l=o(633),d=o(634),m=o(49),f=o.n(m),h=o(266),v=o.n(h),x=o(267),w=o.n(x),y=o(119),_=o.n(y),C=o(864),S=(o(858),o(689)),k=o(14),O=o(627);function j(object,t){var e=Object.keys(object);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(object);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(object,t).enumerable}))),e.push.apply(e,o)}return e}function R(t){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?j(Object(source),!0).forEach((function(e){Object(n.a)(t,e,source[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(source)):j(Object(source)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(source,e))}))}return t}var T=Object(C.a)("https://chat-api.classcardapp.com",{});f.a.extend(v.a),f.a.extend(w.a);var I=c.default.extend({components:{ProfileLayout:l.default,ProfileNav:d.default,ToolTipTop:S.default,ProfileSwitch:O.default},data:function(){return{registration:null,rooms:[],messages:[],newMessage:"",loggedUserId:null,userId:null,selectedRoom:null,selectedRoomDetails:null,participantsSearchTerm:null,participantSearchResults:[],notificationSoundUrl:"https://chat-api.classcardapp.com/api/notification-sound",showMenu:!0,showEditIcon:!1,shouldShowRoomDetails:!1,showRoomEdit:!1,noUser:!1,boringAvatarsBeamUrl:"https://source.boringavatars.com/beam/"}},mounted:function(){this.registerServiceWorker()},created:function(){var t=this,e=_.a.get("cc-chat-user");e&&(this.userId=e),this.login(),T.on("messageReceived",(function(e){e.sender!==t.loggedUserId&&t.selectedRoom&&e.room_id==t.selectedRoom.room_id&&(t.messages.push(e),t.playNotificationSound()),t.updateRoomWithLatestMessage(e),t.scrollChatToBottom()}))},methods:R(R(R({},Object(k.b)({checkLoginStatus:"checkLoginStatus"})),Object(k.d)({setShowAuthModal:"SET_SHOW_AUTH_MODAL",setAuthContentToShow:"SET_AUTH_CONTENT_TO_SHOW"})),{},{convertTimestamp:function(t){var e={month:"short",day:"numeric",hour:"numeric",minute:"numeric",hour12:!0,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone};return new Intl.DateTimeFormat("en-GB",e).format(t)},notificationPrompt:function(){var t=this;return Object(r.a)(regeneratorRuntime.mark((function e(){var o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("Notification"in window){e.next=4;break}alert("This browser does not support desktop notification"),e.next=12;break;case 4:if("granted"!==Notification.permission){e.next=11;break}return e.next=7,t.registration.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:"BA5mo_e-nqwx1zT3ZtkccwFaE0CS7dApQTVogPaWy1Oq8W1YH2TWSqlTwwwHernvluy2umDBxo_TxQQAbmZMa00"});case 7:o=e.sent,fetch("https://chat-api.classcardapp.com/api/subscribe/".concat(t.loggedUserId),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}).then((function(t){return t.json()})).then((function(data){})).catch((function(t){console.error("Error:",t)})),e.next=12;break;case 11:"denied"!==Notification.permission&&Notification.requestPermission().then((function(e){if("granted"===e){var o=t.registration.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:"BA5mo_e-nqwx1zT3ZtkccwFaE0CS7dApQTVogPaWy1Oq8W1YH2TWSqlTwwwHernvluy2umDBxo_TxQQAbmZMa00"});fetch("https://chat-api.classcardapp.com/api/subscribe/".concat(t.loggedUserId),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}).then((function(t){return t.json()})).then((function(data){})).catch((function(t){console.error("Error:",t)}))}}));case 12:case"end":return e.stop()}}),e)})))()},login:function(){var t=this;Object(r.a)(regeneratorRuntime.mark((function e(){var o,r,data;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,o={"api-key":"01472325-210f-4638-b7d2-65cc90b11389","user-type":t.userId?"chat_user":"cc_user","Content-Type":"application/json"},e.next=4,t.$axios({method:"get",url:"".concat(t.userId?"/users/".concat(t.userId):"/users/".concat(t.curStudent.user_detail_id)),baseURL:"https://chat-api.classcardapp.com/api",headers:o});case 4:if(r=e.sent,!(data=r.data).error){e.next=10;break}console.error(data.error),e.next=16;break;case 10:return t.loggedUserId=data.user.user_id,t.userId=data.user.user_id,_.a.set("cc-chat-user",t.loggedUserId,{expires:7}),e.next=15,t.getUserRooms();case 15:t.joinRooms(t.rooms);case 16:e.next=24;break;case 18:if(e.prev=18,e.t0=e.catch(0),console.log(e.t0),400!=e.t0.response.status){e.next=24;break}return t.noUser=!0,e.abrupt("return");case 24:case"end":return e.stop()}}),e,null,[[0,18]])})))()},getUserRooms:function(){var t=this;return Object(r.a)(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch("https://chat-api.classcardapp.com/api/users/rooms/".concat(t.userId)).then((function(t){return t.json()})).then((function(data){data.error?console.error(data.error):t.rooms=data.rooms})).catch((function(t){console.error("Error fetching user details:",t)}));case 2:case"end":return e.stop()}}),e)})))()},logout:function(){_.a.remove("cc-chat-user"),this.userId=null,this.loggedUserId=null},selectRoom:function(t){var e=this;this.selectedRoom=t,fetch("https://chat-api.classcardapp.com/api/messages/".concat(t.room_id)).then((function(t){return t.json()})).then((function(data){data.error?(e.messages=[],console.error(data.error)):(e.messages=data.processedMessages,e.messages.map((function(t){t.isDisplay=!1})),e.scrollChatToBottom())})).catch((function(t){console.error("Error fetching messages:",t)}))},joinRooms:function(t){t.forEach((function(t){T.emit("joinRoom",t.room_id)}))},sendMessage:function(){if(""!==this.newMessage.trim()){var t={id:this.messages.length+1,room_id:this.selectedRoom.room_id,text:this.newMessage.trim(),sender:this.loggedUserId,timestamp:Date.now()};this.messages.push(t),this.updateRoomWithLatestMessage(t),T.emit("sendMessage",{room_id:this.selectedRoom.room_id,message:t}),this.newMessage="",this.scrollChatToBottom()}},scrollChatToBottom:function(){var t=this;this.$nextTick((function(){var e=t.$refs.chatMessages;e&&(e.scrollTop=e.scrollHeight,t.markRoomAsRead(t.selectedRoom.room_id,t.loggedUserId))}))},handleDisplayToolTip:function(t,e,o){t.isDisplay=o,this.messages.splice(e,1),this.messages.splice(e,0,t)},updateRoomWithLatestMessage:function(t){var e=t.room_id,o=this.rooms.findIndex((function(t){return t.room_id===e}));-1!==o&&(this.rooms[o].content=t.text,this.rooms[o].is_read=0)},markRoomAsRead:function(t,e){var o=this,r={userId:e};fetch("https://chat-api.classcardapp.com/api/rooms/read/".concat(t),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}).then((function(t){return t.json()})).then((function(data){var e=t,r=o.rooms.findIndex((function(t){return t.room_id===e}));-1!==r&&(o.rooms[r].is_read=1)})).catch((function(t){console.error("Error:",t)}))},enableRoomEdit:function(){var t=this;this.showRoomEdit=!0,this.$nextTick((function(){t.$refs.roomNameInput.focus()}))},showRoomDetails:function(){var t=this;this.shouldShowRoomDetails=!0,fetch("https://chat-api.classcardapp.com/api/rooms/".concat(this.selectedRoom.room_id)).then((function(t){return t.json()})).then((function(data){data.error?console.error(data.error):t.selectedRoomDetails=data.result})).catch((function(t){console.error("Error fetching messages:",t)}))},updateRoomName:function(input){this.showRoomEdit=!1;var t={roomName:this.selectedRoom.room_name};fetch("https://chat-api.classcardapp.com/api/rooms/".concat(this.selectedRoom.room_id),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then((function(t){return t.json()})).then((function(data){})).catch((function(t){console.error("Error:",t)}))},endRoom:function(){var t=this;fetch("https://chat-api.classcardapp.com/api/rooms/".concat(this.selectedRoom.room_id),{method:"DELETE"}).then((function(t){return t.json()})).then((function(data){t.selectedRoomDetails=null,t.shouldShowRoomDetails=!1;var e=t.rooms.findIndex((function(e){return e.room_id===t.selectedRoom.room_id}));-1!==e&&t.rooms.splice(e,1),t.selectedRoom=null})).catch((function(t){console.error("Error:",t)}))},playNotificationSound:function(){var t=new(window.AudioContext||window.webkitAudioContext);fetch(this.notificationSoundUrl).then((function(t){return t.arrayBuffer()})).then((function(e){return t.decodeAudioData(e)})).then((function(e){var source=t.createBufferSource();source.buffer=e,source.connect(t.destination),source.start(0)})).catch((function(t){console.error("Error loading or playing the notification sound:",t)}))},registerServiceWorker:function(){var t=this;return Object(r.a)(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!("serviceWorker"in navigator)){e.next=11;break}return e.prev=1,e.next=4,navigator.serviceWorker.register("/sw.js",{scope:"/"});case 4:t.registration=e.sent,t.registration.installing?console.log("Service worker installing"):t.registration.waiting?console.log("Service worker installed"):t.registration.active&&console.log("Service worker active"),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),console.error("Registration failed with ".concat(e.t0));case 11:case"end":return e.stop()}}),e,null,[[1,8]])})))()},getChatName:function(t){var e=this,o="",data=t.roomUsers.filter((function(t){return e.loggedUserId!=t.user_id}));if(data.length<=3)for(var i=0;i<data.length;i++)o+=data[i].firstname,i!==data.length-1?o+=", ":o+=" ";else{for(var r=0;r<3;r++)o+=data[r].firstname,r!==data.length-1?o+=", ":o+=" ";o+="..."}return o}}),computed:R(R({},Object(k.e)({students:"students",institution:"institution",token:"token"})),Object(k.c)({curStudent:"curStudent"})),watch:{token:function(t){t||this.$router.push("/".concat(this.$i18n.locale,"/"))}}}),D=(o(860),o(13)),component=Object(D.a)(I,(function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"w-full bg-gray-50 pb-10 pt-4"},[o("div",{staticClass:"mx-auto max-w-7xl px-4 sm:px-6 lg:px-8"},[o("profile-layout",{scopedSlots:t._u([{key:"sidebar",fn:function(){return[o("profile-switch"),t._v(" "),o("profile-nav")]},proxy:!0}])},[t._v(" "),[o("div",{staticClass:"border-b border-gray-200 pb-3"},[o("h2",{staticClass:"text-2xl font-semibold leading-6 text-gray-900"},[t._v("\n            "+t._s(t.$t("Chats"))+"\n          ")])]),t._v(" "),o("div",{staticClass:"mt-6 flex max-h-132 min-h-132 rounded-md border border-solid border-gray-200 text-sm sm:flex"},[o("div",{staticClass:"flex w-full flex-col rounded-l-md border-r border-solid border-gray-200 bg-white md:w-1/4",class:{"hidden sm:flex":t.selectedRoom}},[o("div",{staticClass:"flex h-132 flex-col"},[o("div",{staticClass:"flex flex-grow flex-col"},[o("h2",{staticClass:"m-3 text-base font-semibold text-gray-900"},[t._v("\n                  "+t._s(t.$t("All_chats"))+"\n                ")]),t._v(" "),o("div",{staticClass:"border-b border-solid border-gray-200"}),t._v(" "),t.loggedUserId?o("ul",t._l(t.rooms,(function(e){return o("li",{key:e.room_id,staticClass:"cursor-pointer border-b border-solid border-gray-200 p-3 hover:bg-gray-100",class:{"border-l-2 border-l-gray-300 bg-gray-50":t.selectedRoom&&t.selectedRoom.room_id==e.room_id},on:{click:function(o){return t.selectRoom(e)}}},[o("div",{staticClass:"font-semibold text-gray-700"},[t._v("\n                      "+t._s(e.room_name&&""!=e.room_name?e.room_name:t.getChatName(e))+"\n                    ")]),t._v(" "),o("div",{staticClass:"text-gray-500"},[0==e.is_read&&e.sender_id!=t.loggedUserId?o("span",{staticClass:"mr-1 inline-block h-2 w-2 rounded-full bg-red-800 text-gray-500"}):t._e(),t._v("\n                      "+t._s(e.content)+"\n                    ")])])})),0):t.loggedUserId||t.noUser?o("div",{staticClass:"flex p-2 px-3 text-gray-500"},[t._v("\n                  "+t._s(t.$t("No_active_chats"))+"\n                ")]):o("div",{staticClass:"flex items-center justify-center"},[o("c-icon",{staticClass:"h-8 w-8 text-indigo-700",attrs:{name:"loader"}})],1)]),t._v(" "),o("div",[o("div",{staticClass:"p-3 text-sm text-gray-500"},[t._v("\n                  "+t._s(t.$t("Do_not_want_to_miss_a_message"))+"\n                  "),o("a",{staticClass:"cursor-pointer text-indigo-800",on:{click:t.notificationPrompt}},[t._v(t._s(t.$t("Enable_notifications_now")))])])])])]),t._v(" "),o("div",{staticClass:"block w-full rounded-r-md border-b border-solid border-gray-200 bg-gray-50",class:{"hidden sm:block":!t.selectedRoom,"sm:w-2/4":t.shouldShowRoomDetails,"sm:w-3/4":!t.shouldShowRoomDetails}},[o("button",{staticClass:"block bg-transparent py-2 px-4 font-semibold text-gray-700 hover:bg-gray-200 hover:text-gray-900 sm:hidden",on:{click:function(e){t.selectedRoom=null}}},[t._v("\n              "+t._s(t.$t("Back"))+"\n            ")]),t._v(" "),t.selectedRoom?[o("div",{staticClass:"flex h-132 flex-col rounded-r-md"},[o("div",{staticClass:"border-b border-solid border-gray-200"},[o("div",{staticClass:"flex cursor-pointer items-center justify-between p-3 text-base font-semibold"},[t.showRoomEdit?t._e():o("div",{staticClass:"flex items-center",on:{click:t.enableRoomEdit,mouseover:function(e){t.showEditIcon=!0},mouseout:function(e){t.showEditIcon=!1}}},[o("span",{staticClass:"cursor-pointer text-gray-900"},[t._v(t._s(t.selectedRoom.room_name&&""!=t.selectedRoom.room_name?t.selectedRoom.room_name:t.getChatName(t.selectedRoom)))]),t._v(" "),t.showEditIcon?o("svg",{staticClass:"ml-2 h-4 w-4",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"}},[o("path",{attrs:{"stroke-linecap":"round","stroke-linejoin":"round",d:"M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L6.832 19.82a4.5 4.5 0 01-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 011.13-1.897L16.863 4.487zm0 0L19.5 7.125"}})]):t._e()]),t._v(" "),t.showRoomEdit?o("div",{staticClass:"border-b border-solid border-gray-700",on:{mouseover:function(e){t.showEditIcon=!0},mouseout:function(e){t.showEditIcon=!1}}},[t.showRoomEdit?o("input",{directives:[{name:"model",rawName:"v-model",value:t.selectedRoom.room_name,expression:"selectedRoom.room_name"}],ref:"roomNameInput",staticClass:"w-auto border-none bg-transparent p-0",domProps:{value:t.selectedRoom.room_name},on:{blur:t.updateRoomName,input:function(e){e.target.composing||t.$set(t.selectedRoom,"room_name",e.target.value)}}}):t._e()]):t._e(),t._v(" "),t.showRoomEdit?t._e():o("div",{staticClass:"p-1.5 hover:rounded-md hover:bg-gray-200",on:{click:t.showRoomDetails}},[o("c-icon",{staticClass:"h-3 w-3",attrs:{name:"information-outline",type:"outline",viewBox:"0 0 20 20"}})],1)])]),t._v(" "),o("div",{ref:"chatMessages",staticClass:"chat-messages flex-grow overflow-y-auto p-3"},t._l(t.messages,(function(e,r){return o("div",{key:e.id,staticClass:"mb-4 flex"},[e.sender===t.loggedUserId?o("div",{staticClass:"flex w-full flex-col items-end"},[o("div",{staticClass:"chat-message rounded-tl-2xl rounded-tr-2xl rounded-bl-2xl bg-gray-700 p-2 px-3 text-white shadow-md",on:{mouseover:function(o){return t.handleDisplayToolTip(e,r,!0)},mouseleave:function(o){return t.handleDisplayToolTip(e,r,!1)}}},[0!=r?o("div",{staticClass:"relative flex w-full justify-end whitespace-nowrap"},[e.isDisplay?o("tool-tip-top",{attrs:{tooltipText:"You, "+t.convertTimestamp(e.timestamp),color:"#1f2937",isSender:!1,isFirstIndex:!1,classes:"text-gray-400 bg-gray-800 -mt-11"}}):t._e()],1):t._e(),t._v("\n                        "+t._s(e.text)+"\n                        "),0==r?o("div",{staticClass:"relative flex w-full justify-end whitespace-nowrap"},[e.isDisplay?o("tool-tip-top",{attrs:{tooltipText:e.sender_name+", "+t.convertTimestamp(e.timestamp),color:"#1f2937",isSender:!1,isFirstIndex:!0,classes:"text-gray-400 bg-gray-800 mt-2"}}):t._e()],1):t._e()])]):o("div",{staticClass:"flex w-full flex-col items-start"},[o("div",{staticClass:"chat-message rounded-tl-2xl rounded-tr-2xl rounded-br-2xl border border-solid border-gray-200 bg-white p-2 px-3 shadow-md",on:{mouseover:function(o){return t.handleDisplayToolTip(e,r,!0)},mouseleave:function(o){return t.handleDisplayToolTip(e,r,!1)}}},[0!=r?o("div",{staticClass:"relative flex w-full justify-start whitespace-nowrap"},[e.isDisplay?o("tool-tip-top",{attrs:{tooltipText:e.sender_name+", "+t.convertTimestamp(e.timestamp),color:"#1f2937",isSender:!0,isFirstIndex:!1,classes:"text-gray-400 bg-gray-800  -mt-10"}}):t._e()],1):t._e(),t._v("\n                        "+t._s(e.text)+"\n                        "),0==r?o("div",{staticClass:"relative flex w-full justify-start whitespace-nowrap"},[e.isDisplay?o("tool-tip-top",{attrs:{tooltipText:e.sender_name+", "+t.convertTimestamp(e.timestamp),color:"#1f2937",isSender:!0,isFirstIndex:!0,classes:"text-gray-400 bg-gray-800 mt-2"}}):t._e()],1):t._e()])])])})),0),t._v(" "),o("div",{staticClass:"flex flex-col items-stretch border-t border-solid border-gray-200 p-3"},[o("div",{staticClass:"flex"},[o("input",{directives:[{name:"model",rawName:"v-model",value:t.newMessage,expression:"newMessage"}],staticClass:"h-10 w-3/4 rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6",attrs:{type:"text",placeholder:"Enter your message"},domProps:{value:t.newMessage},on:{keyup:function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"enter",13,e.key,"Enter")?null:t.sendMessage.apply(null,arguments)},input:function(e){e.target.composing||(t.newMessage=e.target.value)}}}),t._v(" "),o("button",{staticClass:"ml-3 inline-flex h-10 grow items-center justify-center truncate rounded-md border-none bg-indigo-700 px-6 py-3 text-base font-semibold text-white opacity-100 hover:bg-indigo-800 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",on:{click:t.sendMessage}},[t._v("\n                      "+t._s(t.$t("Send"))+"\n                    ")])])])])]:o("div",{staticClass:"flex h-132 items-center justify-center"},[t.loggedUserId||t.noUser?o("p",{staticClass:"text-xl font-semibold text-gray-700"},[t._v("\n                "+t._s(t.$t("Select_a_chat"))+"\n              ")]):t.loggedUserId||t.noUser?t._e():o("div",{staticClass:"flex flex-col items-center justify-center"},[o("c-icon",{staticClass:"h-7 w-7 text-indigo-700",attrs:{name:"loader"}})],1)])],2),t._v(" "),o("div",{staticClass:"flex hidden grow flex-col rounded-r-md border-l border-solid border-gray-300 bg-gray-100 md:w-1/4",class:{"sm:block":t.shouldShowRoomDetails}},[o("div",{staticClass:"flex h-132 flex-col justify-between"},[o("div",{},[o("div",{staticClass:"flex items-center justify-between border-b border-solid border-gray-200 p-3"},[t.selectedRoom?o("div",{staticClass:"text-base font-semibold text-gray-900"},[t._v("\n                    "+t._s(t.$t("Chat_info"))+"\n                  ")]):t._e(),t._v(" "),o("div",[o("svg",{staticClass:"h-5 w-5 cursor-pointer text-gray-700",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},on:{click:function(e){t.shouldShowRoomDetails=!1}}},[o("path",{attrs:{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"}})])])]),t._v(" "),o("div",{staticClass:"p-3"},[o("div",{staticClass:"mb-2 font-semibold text-gray-700"},[t._v("\n                    "+t._s(t.$t("Participants"))+"\n                  ")]),t._v(" "),o("ul",{staticClass:"flex-grow overflow-auto text-sm text-gray-700"},t._l(t.selectedRoomDetails,(function(e){return o("li",{key:e.user_id,staticClass:"mb-2 flex cursor-pointer items-center"},[o("p",{staticClass:"flex items-center"},[o("img",{staticClass:"mr-2 h-6 w-6 object-cover",attrs:{src:t.boringAvatarsBeamUrl,alt:"dp"},on:{error:function(e){return e.target.src=t.boringAvatarsBeamUrl}}}),t._v(" "),o("span",{staticClass:"ml-2 text-gray-500"},[t._v("\n                          "+t._s(e.surname?e.firstname+" "+e.surname:e.firstname)+"\n                        ")])])])})),0)])])])])])]],2)],1)])}),[],!1,null,null,null);e.default=component.exports}}]);