text: let SOCKET_HTTP_URL="http://localhost:1337",SOCKET_HTTPS_URL="http://localhost:7331";SOCKET_HTTP_URL=`${window.location.origin}:1337`,SOCKET_HTTPS_URL=`${window.location.origin}:7331`;let btnHeaderSetting,btnHeaderMessage,sidebarList,mainHeader,contentChatboxHeader,contentChatboxList,contentChatboxInput,contentChatboxInputBox,btnChatboxPhoto,btnChatboxFile,btnChatboxEmoji,btnChatboxSend,cMsg,btnDetailsHamburg,btnEmployeeSearch,inputChatSearch,inputEmployeeSearch,userList,SIMPLE,GROUP,FR_HTTP_URL="http://fr.msgr.io",BK_HTTP_URL="http://bk.msgr.io",FR_HTTPS_URL="https://fr.msgr.io",BK_HTTPS_URL="https://bk.msgr.io";FR_HTTP_URL=window.location.href.replace("backend","frontend").replace("/chat",""),BK_HTTP_URL=window.location.href.replace("frontend","backend").replace("/chat","");const fileTypes=["application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/msword","application/vnd.ms-excel","application/vnd.ms-powerpoint","application/vnd.sun.xml.writer","application/vnd.sun.xml.writer.global","application/vnd.sun.xml.calc","application/vnd.sun.xml.impress","application/pdf","text/plain"],leaveGroup=async e=>{GROUP.emit("leave-group",{groupId:e,memberId:M_ID})},initSearch=(e,t,n)=>{Array.from(e.getElementsByClassName(t)).forEach(e=>{-1!=e.children[0].children[1].children[0].textContent.toLowerCase().indexOf(n.toLowerCase())?e.style.display="flex":e.style.display="none"})},initUpload=(e,t)=>{const n=`filepond-${t.toLowerCase()}`;swal({title:`Upload your ${"IMG"===t?"image/s":"file/s"} here ..`,html:`<input id="${n}" type="file" class="filepond" name="${n}" multiple data-max-files="10"/>`,showCloseButton:!0,showCancelButton:!1,showConfirmButton:!0,focusConfirm:!1,allowOutsideClick:!1,customClass:"mSwal",confirmButtonText:'Upload all <i class="fa fa-upload"></i>',showLoaderOnConfirm:!0,allowOutsideClick:e=>!Swal.isLoading(),preConfirm:async e=>a.getFiles().length?(swal.resetValidationMessage(),a.processFiles()):swal.showValidationMessage("Should have enough files first.")}).then(e=>{});const a=FilePond.create(document.querySelector(`#${n}`),{acceptedFileTypes:"IMG"===t?["image/*"]:fileTypes,instantUpload:!1,server:{url:null,process:(t,n,a,i,s,o,l)=>{switch(i("OK"),e.getAttribute("data-conn")){case"SIMPLE":const t=new SocketIOFileUpload(SIMPLE);t.addEventListener("start",function(e){e.file.meta={threadId:mConn.cId,memberId:M_ID,fileType:n.type,createdAt:moment().format("YYYY-MM-DD HH:mm:ss")}}),t.submitFiles([new File([n],n.name)]);break;case"GROUP":const a=new SocketIOFileUpload(GROUP);a.addEventListener("start",function(e){e.file.meta={threadId:mConn.cId,memberId:M_ID,fileType:n.type,createdAt:moment().format("YYYY-MM-DD HH:mm:ss")}}),a.submitFiles([new File([n],n.name)])}return{abort:()=>{request.abort(),l()}}}}})},buildURLQuery=e=>Object.entries(e).map(e=>e.map(encodeURIComponent).join("=")).join("&"),initUI=e=>{const t=e.firstElementChild.children[0].src;contentChatboxHeaderImg.setAttribute("src",t);const n=e.firstElementChild.children[1].children[0].textContent;mainHeaderDetailsH4.textContent=n,contentChatboxHeaderDetailsH4.textContent=n,cMsg=e.firstElementChild.children[1].children[1],contentChatboxInput.children[0].style.visibility="visible",contentChatboxInput.children[1].style.visibility="visible"},playSound=e=>{if(M_ID!==e){new Howl({src:[`${FR_HTTP_URL}/audio/notif.mp3`]}).play()}},initConn=(e,t)=>{const n=buildURLQuery({id:e,name:t});(SIMPLE=io(`${SOCKET_HTTP_URL}/simple`,{query:n,secure:!0})).on("connect",e=>{console.log("You connected to Private Messaging")}),SIMPLE.on("chat-confirm",e=>{const{id:t,name:n,type:a,thread_members:i}=JSON.parse(e);console.log(i)}),SIMPLE.on("chat",t=>{const{uId:n,message:a,timestamp:i}=JSON.parse(t);let s=contentChatboxHeaderImg.getAttribute("src");s=s.replace("/.+(?=/w+/w+)/",FR_HTTP_URL);const o=moment(i).format("MMM DD, YYYY"),l=moment(i).format("hh:mm a"),r=contentChatboxList.lastElementChild.firstElementChild.firstElementChild,c=contentChatboxList.lastElementChild.firstElementChild.lastElementChild,m=`\n            <div class="msgr-main-content-chatbox-list-item">\n                <span class="${r.textContent==o&&c.textContent==l?"stamp-hide":""}">\n                    <span class="${r.textContent==o?"stamp-hide":""}">${o}</span> \n                    <span class="${c.textContent==l?"stamp-hide":""}">${l}</span>\n                </span>\n\n                <div class="msgr-main-content-chatbox-list-item-details ${n===e?"owner":""}">\n                    <img class="img-circle" src="${s}" alt="User image">\n                    <div class="msgr-main-content-chatbox-list-item-details-content">\n                        <p>${a.trim()}</p>\n                    </div>\n                </div>\n            </div>\n        `;cMsg.textContent=strTruncate(a,20),contentChatboxList.insertAdjacentHTML("beforeend",m),contentChatboxList.parentNode.scrollTop=contentChatboxList.parentNode.scrollHeight,playSound(n)}),SIMPLE.on("file",async t=>{const{member_id:n,filename:a,filepath:i,type:s,created_at:o}=t;let l=contentChatboxHeaderImg.getAttribute("src");l=l.replace("/.+(?=/w+/w+)/",FR_HTTP_URL);const r=moment(o).format("MMM DD, YYYY"),c=moment(o).format("hh:mm a"),m=contentChatboxList.lastElementChild.firstElementChild.firstElementChild,d=contentChatboxList.lastElementChild.firstElementChild.lastElementChild,p=i.replace("http://localhost:80/msgr/frontend/web",FR_HTTP_URL),h=`\n            <div class="msgr-main-content-chatbox-list-item">\n                <span class="${m.textContent==r&&d.textContent==c?"stamp-hide":""}">\n                    <span class="${m.textContent==r?"stamp-hide":""}">${r}</span>\n                    <span class="${d.textContent==c?"stamp-hide":""}">${c}</span>\n                </span>\n\n                <div class="msgr-main-content-chatbox-list-item-details ${n===e?"owner":""}">\n                    <img class="img-circle" src="${l}" alt="User image">\n                    <div class="msgr-main-content-chatbox-list-item-details-content">\n                        ${"image"===s?`<img src="${p}" alt="${a}">`:`<p><a href="${p}" target="_blank">${a}</a></p>`}\n                    </div>\n                </div>\n            </div>\n        `;if("image"===s){const e=$("#tab-image");e.nanogallery2("destroy");const t=await axios.get(`${BK_HTTP_URL}/api/thread/${mConn.cId}?expand=images`);e.nanogallery2({items:t.data.images.map(e=>{if(e.file_path)return{src:e.file_path,srct:e.file_thumb,title:e.file_name}}),thumbnailWidth:"auto",thumbnailHeight:100})}else{$("#tab-docs").append(`\n                <li style="margin: 1rem 0;">\n                    <a href="${i}" target="_blank" style="text-decoration:underline;" title="${a}">${a}</a> <br/>\n                    <span class="label label-default">${moment(o).format("MMM DD, YYYY hh:mm a")}</span>\n                </li>\n            `)}cMsg.textContent=strTruncate("image"===s?"You sent an image.":"You sent a document.",20),contentChatboxList.insertAdjacentHTML("beforeend",h),contentChatboxList.parentNode.scrollTop=contentChatboxList.parentNode.scrollHeight,playSound(n)}),SIMPLE.on("disconnect",e=>{console.log("Disconnected to PM"),SIMPLE.disconnect()}),(GROUP=io(`${SOCKET_HTTP_URL}/group`,{query:n,secure:!0})).on("connect",e=>{console.log("You connected to Group Messaging")}),GROUP.on("chat",t=>{const{uId:n,message:a,timestamp:i}=JSON.parse(t);let s=contentChatboxHeaderImg.getAttribute("src");s=s.replace("/.+(?=/w+/w+)/",FR_HTTP_URL);const o=moment(i).format("MMM DD, YYYY"),l=moment(i).format("hh:mm a"),r=contentChatboxList.lastElementChild.firstElementChild.firstElementChild,c=contentChatboxList.lastElementChild.firstElementChild.lastElementChild,m=`\n            <div class="msgr-main-content-chatbox-list-item">\n                <span class="${r.textContent==o&&c.textContent==l?"stamp-hide":""}">\n                    <span class="${r.textContent==o?"stamp-hide":""}">${o}</span> \n                    <span class="${c.textContent==l?"stamp-hide":""}">${l}</span>\n                </span>\n\n                <div class="msgr-main-content-chatbox-list-item-details ${n===e?"owner":""}">\n                    <img class="img-circle" src="${s}" alt="User image">\n                    <div class="msgr-main-content-chatbox-list-item-details-content">\n                        <p>${a.trim()}</p>\n                    </div>\n                </div>\n            </div>\n        `;cMsg.textContent=strTruncate(a,20),contentChatboxList.insertAdjacentHTML("beforeend",m),contentChatboxList.parentNode.scrollTop=contentChatboxList.parentNode.scrollHeight,playSound(n)}),GROUP.on("file",async t=>{const{member_id:n,filename:a,filepath:i,type:s,created_at:o}=t;let l=contentChatboxHeaderImg.getAttribute("src");l=l.replace("/.+(?=/w+/w+)/",FR_HTTP_URL);const r=moment(o).format("MMM DD, YYYY"),c=moment(o).format("hh:mm a"),m=contentChatboxList.lastElementChild.firstElementChild.firstElementChild,d=contentChatboxList.lastElementChild.firstElementChild.lastElementChild,p=i.replace("http://localhost:80/msgr/frontend/web",FR_HTTP_URL),h=`\n            <div class="msgr-main-content-chatbox-list-item">\n                <span class="${m.textContent==r&&d.textContent==c?"stamp-hide":""}">\n                    <span class="${m.textContent==r?"stamp-hide":""}">${r}</span>\n                    <span class="${d.textContent==c?"stamp-hide":""}">${c}</span>\n                </span>\n\n                <div class="msgr-main-content-chatbox-list-item-details ${n===e?"owner":""}">\n                    <img class="img-circle" src="${l}" alt="User image">\n                    <div class="msgr-main-content-chatbox-list-item-details-content">\n                        ${"image"===s?`<img src="${p}" alt="${a}" style="border: 1.5rem solid #09f; border-radius: 2.5rem; max-width:70%;">`:`<p><a href="${p}" target="_blank" style="color:#fff !important; text-decoration:underline;">${a}</a></p>`}\n                    </div>\n                </div>\n            </div>\n        `;if("image"===s){const e=$("#tab-image");e.nanogallery2("destroy");const t=await axios.get(`${BK_HTTP_URL}/api/thread/${mConn.cId}?expand=images`);e.nanogallery2({items:t.data.images.map(e=>{if(e.file_path)return{src:e.file_path,srct:e.file_thumb,title:e.file_name}}),thumbnailWidth:"auto",thumbnailHeight:100})}else{$("#tab-docs").append(`\n                <li style="margin: 1rem 0;">\n                    <a href="${i}" target="_blank" style="text-decoration:underline;" title="${a}">${a}</a> <br/>\n                    <span class="label label-default">${moment(o).format("MMM DD, YYYY hh:mm a")}</span>\n                </li>\n            `)}cMsg.textContent=strTruncate("image"===s?"You sent an image.":"You sent a document.",20),contentChatboxList.insertAdjacentHTML("beforeend",h),contentChatboxList.parentNode.scrollTop=contentChatboxList.parentNode.scrollHeight,playSound(n)}),GROUP.on("disconnect",e=>{console.log("Disconnected to GM"),GROUP.disconnect()})},renderUI=async e=>{if(1==contentChatboxList.children.length){const t=$(".tab-about-header"),n=$("#tab-about");t.empty(),n.empty();const a=await axios.get(`${BK_HTTP_URL}/api/thread/${e}?expand=members`);"GROUP"==a.data.type?(n.append("<h4>Members</h4>"),a.data.members.map(e=>{n.append(`<li>${e.name} ${e.id===M_ID?"(You)":""}</li>`)}),n.append(`\n                <div style="display:flex; justify-content:center; padding:1rem 0;">\n                    <button class="btn btn-danger" onclick="leaveGroup('${a.data.id}')">\n                        Leave group\n                        <i class="fa fa-sign-out" aria-hidden="true"></i>\n                    </button>\n                </div>\n            `),btnChatboxPhoto.setAttribute("data-conn","GROUP"),btnChatboxFile.setAttribute("data-conn","GROUP")):(btnChatboxPhoto.setAttribute("data-conn","SIMPLE"),btnChatboxFile.setAttribute("data-conn","SIMPLE")),M_OFFSET=1,t.append(`\n            <img class="img-circle" src="${contentChatboxHeaderImg.src}" alt="User image">\n            <h4>${contentChatboxHeaderDetailsH4.textContent}</h4>\n        `);const i=await axios.get(`${BK_HTTP_URL}/api/thread/${e}?expand=messages`);i.data.messages.map(e=>{let t,n=contentChatboxHeaderImg.getAttribute("src");n=n.replace("/.+(?=/w+/w+)/",FR_HTTP_URL);const a=moment(e.created_at).format("MMM DD, YYYY"),s=moment(e.created_at).format("hh:mm a"),o=contentChatboxList.lastElementChild.firstElementChild.firstElementChild,l=contentChatboxList.lastElementChild.firstElementChild.lastElementChild;let r,c,m;e.member&&(r=e.member.id,c=e.member.name,m=e.member.sex),"NOTIF"==e.type&&(t=`\n                    <div class="msgr-main-content-chatbox-list-item">\n                        <span style="display:flex; align-items:center; flex-direction:column;">\n                            <span>\n                                <span>${a}</span> at\n                                <span>${s}</span>\n                            </span>\n                            <span>${e.text}</span>\n                        </span>\n                    </div>\n                `),"MSG"==e.type&&(t=e.text?`\n                        <div class="msgr-main-content-chatbox-list-item">\n                            <span class="${o.textContent==a&&l.textContent==s?"stamp-hide":""}">\n                                <span class="${o.textContent==a?"stamp-hide":""}">${a}</span> \n                                <span class="${l.textContent==s?"stamp-hide":""}">${s}</span>\n                            </span>\n    \n                            <p style="display: ${"GROUP"==i.data.type?r===M_ID?"none;":"block;":"none;"} color:#999; margin:0 0 .5rem;">${c}</p>\n                            <div class="msgr-main-content-chatbox-list-item-details ${r===M_ID?"owner":""}">\n                                <img class="img-circle" src="${"GROUP"==i.data.type?"M"==m?`${FR_HTTP_URL}/img/1.png`:`${FR_HTTP_URL}/img/2.png`:n}" alt="User image">\n                                <div class="msgr-main-content-chatbox-list-item-details-content">\n                                    <p>${e.text}</p>\n                                </div>\n                            </div>\n                        </div>\n                    `:`\n                        <div class="msgr-main-content-chatbox-list-item">\n                            <span class="${o.textContent==a&&l.textContent==s?"stamp-hide":""}">\n                                <span class="${o.textContent==a?"stamp-hide":""}">${a}</span> \n                                <span class="${l.textContent==s?"stamp-hide":""}">${s}</span>\n                            </span>\n    \n                            <p style="display: ${"GROUP"==i.data.type?r===M_ID?"none;":"block;":"none;"} color:#999; margin:0 0 .5rem;">${c}</p>\n                            <div class="msgr-main-content-chatbox-list-item-details ${r===M_ID?"owner":""}">\n                                <img class="img-circle" src="${"GROUP"==i.data.type?"M"==m?`${FR_HTTP_URL}/img/1.png`:`${FR_HTTP_URL}/img/2.png`:n}" alt="User image">\n                                <div class="msgr-main-content-chatbox-list-item-details-content">\n                                    ${"image"===e.file_type?`<img src="${e.file_thumb}" alt="${e.file_name}" style="border: 1.5rem solid #09f; border-radius: 2.5rem; max-width:70%;">`:`<p><a href="${e.file_path}" target="_blank" style="color: ${r===M_ID?"#fff":"#0099ff"} !important; text-decoration:underline;">${e.file_name}</a></p>`}\n                                </div>\n                            </div>\n                        </div>\n                    `),contentChatboxList.insertAdjacentHTML("beforeend",t),$(".msgr-main-content-chatbox-list").overlayScrollbars().scroll({y:"100%"})});const s=$("#tab-image");s.nanogallery2("destroy");const o=await axios.get(`${BK_HTTP_URL}/api/thread/${e}?expand=images`);s.nanogallery2({items:o.data.images.map(e=>{if(e.file_path)return{src:e.file_path,srct:e.file_thumb,title:e.file_name}}),thumbnailWidth:"auto",thumbnailHeight:100});const l=$("#tab-docs");l.html(""),(await axios.get(`${BK_HTTP_URL}/api/thread/${e}?expand=docs`)).data.docs.map(e=>{l.append(`\n                <li style="margin: 1rem 0;">\n                    <a href="${e.file_path}" target="_blank" style="text-decoration:underline;" title="${e.file_name}">${e.file_name}</a> <br/>\n                    <span class="label label-default">${moment(e.created_at).format("MMM DD, YYYY hh:mm a")}</span>\n                </li>\n            `)})}};let mConn={};const connect=async(e,t,n)=>{switch(n){case"SIMPLE":if(void 0===mConn.cId&&(SIMPLE.emit("join-room",{id:t}),mConn={cId:t,type:"SIMPLE"}),t!==mConn.cId){SIMPLE.emit("join-room",{id:t}),mConn={cId:t,type:"SIMPLE"},$("#spinner-container").removeClass("spinner-show").addClass("spinner-hide");for(const e of $(contentChatboxList).children().splice(1,$(contentChatboxList).children().length))$(e).remove();renderUI(mConn.cId)}else renderUI(mConn.cId);break;case"GROUP":if(void 0===mConn.cId&&(GROUP.emit("join-room",{id:t}),mConn={cId:t,type:"GROUP"}),t!==mConn.cId){GROUP.emit("join-room",{id:t}),mConn={cId:t,type:"GROUP"},$("#spinner-container").removeClass("spinner-show").addClass("spinner-hide");for(const e of $(contentChatboxList).children().splice(1,$(contentChatboxList).children().length))$(e).remove();renderUI(mConn.cId)}else renderUI(mConn.cId)}initUI(e)},chatConfirm=e=>{e.style.display="none";const t=e.parentElement.previousElementSibling.children[1].children[0],n=e.parentElement.previousElementSibling.children[0],a=t.dataset.id,i=t.textContent,s=(n.src,[{member_id:M_ID,role:"ADMIN"},{member_id:a,role:"MEMBER"}]);SIMPLE.emit("chat-confirm",{type:"SIMPLE",name:`${M_NAME}:${i}`,members:s})},groupConfirm=e=>{const t=e.parentElement.previousElementSibling.children[1].children[0],n=t.dataset.id,a=t.textContent,i=[{member_id:M_ID,role:"ADMIN"},{member_id:n,role:"MEMBER"}];swal({width:"50rem",type:"question",title:"Please choose an option",focusConfirm:!1,showCloseButton:!0,showCancelButton:!0,showConfirmButton:!0,allowOutsideClick:!1,confirmButtonColor:"#5cb85c",confirmButtonText:`\n            <i class="fa fa-user-plus fa-2x" aria-hidden="true"></i>\n            <br/>Add <strong>${a}</strong> <br/>to a New Group\n        `,confirmButtonAriaLabel:"Add to New Group",cancelButtonColor:"#337ab7",cancelButtonText:`\n            <i class="fa fa-users fa-2x" aria-hidden="true"></i>\n            <br/>Add <strong>${a}</strong> <br/>to an Existing Group\n        `,cancelButtonAriaLabel:"Add to an Existing Group"}).then(async e=>{if(e.value)swal({title:"Please specify a group name",input:"text",inputAttributes:{autocapitalize:"off"},confirmButtonText:"Submit",showLoaderOnConfirm:!0,preConfirm:e=>{if(e)return fetch(`${BK_HTTP_URL}/api/thread`,{method:"POST",body:JSON.stringify({type:"GROUP",name:e,members:i}),headers:{Accept:"application/json","Content-Type":"application/json"}}).then(async t=>{if(!t.ok)throw new Error(t.statusText);const n=await t.json();return n.result=e,n.members=i,n}).catch(e=>{Swal.showValidationMessage(`Request failed: ${e}`)});Swal.showValidationMessage("Please specify a group name")},allowOutsideClick:()=>!Swal.isLoading()}).then(e=>{const t=`\n                    <div class="msgr-sidebar-list-item" onclick="connect(this, '${e.value.id}', 'GROUP')">\n                        <div class="msgr-sidebar-list-item-content">\n                            <img class="img-circle" src="${FR_HTTP_URL}/img/3.png" alt="User image">                        \n                            <div class="msgr-sidebar-list-item-content-details">\n                                <h4>${e.value.result}</h4>\n                                <p>-</p>\n                            </div>\n                        </div>\n\n                        <div class="msgr-sidebar-list-item-settings">\n                            <span>-</span>\n                        </div>\n                    </div>\n                `;$(".msgr-sidebar-list > .os-padding > .os-viewport > .os-content").prepend(t)});else{const e=await axios.get(`${BK_HTTP_URL}/api/member/${M_ID}?expand=threads_group`),t=Object.keys(e.data.threads_group).map(t=>e.data.threads_group[t]).filter(e=>!e.members.find(e=>e.id===n)).map(e=>({id:e.id,name:e.global_config.name})).reduce((e,t)=>(e[t.id]=t.name,e),{});_.isEmpty(t)||swal({title:"Select an existing group ..",input:"select",inputOptions:t,showCancelButton:!0,allowOutsideClick:!1}).then(async e=>{if(e.value){const t=await axios.post(`${BK_HTTP_URL}/api/thread-member`,{thread_id:e.value,member_id:n,role:"MEMBER"});t.data&&$(`<li>${a}}</li>`).insertBefore("#tab-about > button"),console.log(t.data)}})}})},checkSWSupport=e=>{let t=!0;return"serviceWorker"in navigator||(console.warn("No Service Worker support!"),t=!1),"PushManager"in window||(console.warn("No Push API Support!"),t=!1),t},initialize=async e=>{axios.get(`${BK_HTTP_URL}/api/member/${M_ID}?expand=threads`,{headers:{"Access-Control-Allow-Origin":"*"}}).then(e=>{const t=e.data.threads.map(e=>(Array.from(userList.getElementsByClassName("msgr-main-content-tools-user-list-item")).forEach(t=>{t.children[0].children[1].children[0].textContent.toLowerCase()==e.name.toLowerCase()&&(t.children[1].children[0].style.display="none")}),`\n                <div class="msgr-sidebar-list-item" onClick="connect(this, '${e.id}', '${e.type}')">\n                    <div class="msgr-sidebar-list-item-content">\n                        <img class="img-circle" src="${FR_HTTP_URL}/img/${"GROUP"==e.type?"3":"M"==e.sex?"1":"2"}.png" alt="User image">                        \n                        <div class="msgr-sidebar-list-item-content-details">\n                            <h4 style="font-weight: ${e.message&&e.message.unread&&M_ID!==e.message.sent_by?"bold;":"normal;"}">${e.name}</h4>\n                            <p style="font-weight: ${e.message&&e.message.unread&&M_ID!==e.message.sent_by?"bold; color:#000;":"normal;"}">${e.message?strTruncate(e.message.latest,20):"-"}</p>\n                        </div>\n                    </div>\n    \n                    <div class="msgr-sidebar-list-item-settings">\n                        <span>${e.message?moment(e.message.time).format("ddd"):"-"}</span>\n                    </div>\n                </div>\n            `)).join("");sidebarList.innerHTML=t,OverlayScrollbars(sidebarList,{})}),initConn(M_ID,M_NAME),contentChatboxInputBox.addEventListener("keydown",e=>{if(13===e.keyCode&&!e.shiftKey){e.preventDefault();const t=moment().format("YYYY-MM-DD HH:mm:ss"),n=e.target.value,a="MSG";n&&("GROUP"==mConn.type?GROUP.emit("chat",{cId:mConn.cId,uId:M_ID,type:a,message:n,timestamp:t}):SIMPLE.emit("chat",{cId:mConn.cId,uId:M_ID,type:a,message:n,timestamp:t}),contentChatboxInputBox.value="")}})};document.addEventListener("DOMContentLoaded",async e=>{if(checkSWSupport()){console.log("Registering service worker ..");const e=await navigator.serviceWorker.register(`${FR_HTTP_URL}/js/base/worker.js`).catch(e=>console.error(e));await e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:urlBase64ToUint8Array(PUB_VAPID_KEY)}).catch(e=>console.error(e))}FilePond.registerPlugin(FilePondPluginImageCrop,FilePondPluginImageEdit,FilePondPluginImageExifOrientation,FilePondPluginImagePreview,FilePondPluginImageResize,FilePondPluginImageTransform,FilePondPluginImageValidateSize,FilePondPluginFileEncode,FilePondPluginFileMetadata,FilePondPluginFilePoster,FilePondPluginFileRename,FilePondPluginFileValidateSize,FilePondPluginFileValidateType),btnHeaderSetting=document.querySelector("#btn-header-setting"),btnHeaderMessage=document.querySelector("#btn-header-message"),sidebarList=document.querySelector(".msgr-sidebar-list"),mainHeaderDetailsH4=document.querySelector(".msgr-main-header-details > h4"),contentChatboxHeaderImg=document.querySelector(".msgr-main-content-chatbox-header > img"),contentChatboxHeaderDetailsH4=document.querySelector(".msgr-main-content-chatbox-header-details > h4"),contentChatboxList=document.querySelector(".msgr-main-content-chatbox-list > .os-padding > .os-viewport > .os-content"),contentChatboxInput=document.querySelector(".msgr-main-content-chatbox-input"),contentChatboxInputBox=document.querySelector("#content-chatbox-input-box"),btnChatboxPhoto=document.querySelector("#btn-chatbox-photo"),btnChatboxFile=document.querySelector("#btn-chatbox-file"),btnChatboxEmoji=document.querySelector("#btn-chatbox-emoji"),btnChatboxSend=document.querySelector("#btn-chatbox-send"),btnDetailsHamburg=document.querySelector("#btn-details-hamburg"),btnEmployeeSearch=document.querySelector("#btn-employee-search"),inputChatSearch=document.querySelector("#input-chat-search"),inputEmployeeSearch=document.querySelector("#input-employee-search"),userList=document.querySelector(".msgr-main-content-tools-user-list");const t=document.querySelector(".msgr-main-content-tools-user-header-container"),n=document.querySelector("#input-chat-search-container");let a=!1;btnDetailsHamburg.addEventListener("click",e=>{a?(a=!1,$(".msgr-main-content-chatbox").css("width","75%"),$(".msgr-main-content-tools").css("display","block")):(a=!0,$(".msgr-main-content-chatbox").css("width","100%"),$(".msgr-main-content-tools").css("display","none"))}),inputChatSearch.addEventListener("keyup",e=>initSearch(sidebarList,"msgr-sidebar-list-item",e.target.value)),inputEmployeeSearch.addEventListener("keyup",e=>initSearch(userList,"msgr-main-content-tools-user-list-item",e.target.value)),inputEmployeeSearch.addEventListener("focusout",e=>{t.style.display="flex",n.style.display="none"}),btnEmployeeSearch.addEventListener("click",e=>{t.style.display="none",n.style.display="flex",inputEmployeeSearch.focus()}),M_ID&&M_NAME?initialize():Swal.mixin({input:"text",confirmButtonText:"Next &rarr;",showCancelButton:!1,allowOutsideClick:!1,progressSteps:["1","2"],inputValidator:e=>!e&&"You need to write something!"}).queue([{title:"Question 1",text:"Enter your ID"},{title:"Question 2",text:"Enter your name"}]).then(e=>{if(e.value){M_ID=e.value[0],M_NAME=e.value[1];const t=document.querySelector(".msgr-main-content-tools-user-list > .os-padding > .os-viewport > .os-content");Array.from(t.children).forEach(e=>{e.children[0].children[1].children[0].dataset.id==M_ID&&(e.style.display="none")}),initialize()}})});