!function(e, t, s) { "use strict"; String.prototype.replaceTagsToValues = String.prototype.replaceTagsToValues || function(e) { let t = this; for (let s in e) t = t.replace(RegExp(`<${s}>`, "g"), e[s]); return t } , XF.Messenger = e.extend(XF.Messenger || {}, { noticesUrl: "", popupUrl: "", popup: null, enableSound: !1, soundPath: "", $audio: null, init() { setTimeout(()=>{ this.noticesUrl = XF.config.messenger.noticesUrl, this.popupUrl = XF.config.messenger.popupUrl, t.getWebsocketsPromise?.().then(({manager: e})=>{ e.channels.visitor.listen("XFM.NewMessage", XF.proxy(this, "onNewMessage")) } ), XF.config.messenger.popupEnabled && (this.popup = new XF.ChatPopup({ url: this.popupUrl, eventPrefix: "XFM", draggable: !0 }), this.isValidPage() && this.popup.setupFromCookie()), XF.config.messenger.enableSound && (this.enableSound = !0, this.soundPath = XF.config.messenger.soundPath, this.$audio = e("").attr("src", this.soundPath).appendTo(s.body)) } , 500) }, isValidPage() { return !this.isConversationsPage() && !this.isAdminPage() }, isConversationsPage: ()=>!!t.location.href.match(/conversations/)?.length, isAdminPage: ()=>!!t.location.href.match(/admin\.php/)?.length, onNewMessage({message: t}) { t.user_id !== XF.config.userId && this.isValidPage() && (this.popup && this.popup.isOpened() || ((()=>{ if (!this.enableSound) return !1; let e = this.getSoundConfig() , o = e[t.room_tag] || e[parseInt(t.room_tag, 10)]; return void 0 === o || !!o && !s.hasFocus() } )() && this.playSound(), XF.ajax("GET", this.noticesUrl.replaceTagsToValues({ tag: t.room_tag }), { start_message_id: t.id }, ({html: t})=>{ XF.setupHtmlInsert(t, t=>{ s.hasFocus() ? this.showFloatingNotices(t) : e(s).one("focus", ()=>{ this.showFloatingNotices(t) } ) } ) } , { global: !1 }))) }, showFloatingNotices(s) { let o = e(".js-notices.notices--floating"); o.length || (o = e('