MDL-65896 admin: add admin setting to show emoji picker
[moodle.git] / message / amd / build / message_drawer_view_conversation.min.js
1 function _typeof(e){if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(e){return typeof e}}else{_typeof=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e}}return _typeof(e)}define ("core_message/message_drawer_view_conversation",["jquery","core/auto_rows","core/backoff_timer","core/custom_interaction_events","core/notification","core/pubsub","core/str","core_message/message_repository","core_message/message_drawer_events","core_message/message_drawer_view_conversation_constants","core_message/message_drawer_view_conversation_patcher","core_message/message_drawer_view_conversation_renderer","core_message/message_drawer_view_conversation_state_manager","core_message/message_drawer_router","core_message/message_drawer_routes","core/emoji/auto_complete","core/emoji/picker"],function(s,e,t,n,a,d,i,o,r,g,l,m,c,E,I,C,_){var u={},T=null,A=!1,h=0,f=null,O=!1,M=[],p=!0,N=!1,S=[],v=null,b=[],U=g.NEWEST_MESSAGES_FIRST,R=g.LOAD_MESSAGE_LIMIT,L=g.MILLISECONDS_IN_SEC,D=g.SELECTORS,y=g.CONVERSATION_TYPES,P=function(){if(!T||T.type==y.PUBLIC){return null}var e=T.loggedInUserId;if(T.type==y.SELF){return e}var s=Object.keys(T.members).filter(function(s){return e!=s});return s.length?s[0]:null},B=function(e){return Object.keys(u).reduce(function(s,t){if(!s){var n=u[t].state;if(n.type!=y.PUBLIC){if(e in n.members){s=n.id}}}return s},null)},F=function(e){return{id:parseInt(e.attr("data-user-id"),10),fullname:null,profileimageurl:null,profileimageurlsmall:null,isonline:null,showonlinestatus:null,isblocked:null,iscontact:null,isdeleted:null,canmessage:null,canmessageevenifblocked:null,requirescontact:null,contactrequests:[]}},w=function(){return h},k=function(e){h=e;u[T.id].messagesOffset=e},V=function(){return A},x=function(e){A=e;u[T.id].loadedAllMessages=e},G=function(e){return e.find(D.MESSAGES_CONTAINER)},q=function(e){return{id:e.id,name:e.name,subname:e.subname,imageUrl:e.imageUrl,isFavourite:e.isFavourite,isMuted:e.isMuted,type:e.type,totalMemberCount:e.totalMemberCount,loggedInUserId:e.loggedInUserId,messages:e.messages.map(function(e){return s.extend({},e)}),members:Object.keys(e.members).map(function(t){var n=s.extend({},e.members[t]);n.contactrequests=e.members[t].contactrequests.map(function(e){return s.extend({},e)});return n})}},Q=function(e,s){var t=e.id,n=t==s?y.SELF:y.PRIVATE,d=c.setLoadingMembers(T,!0);d=c.setLoadingMessages(d,!0);v(d);return o.getMemberInfo(t,[s],!0,!0).then(function(e){if(e.length){return e[0]}else{throw new Error("Unable to load other user profile")}}).then(function(s){var t=n==y.SELF?[s]:[s,e],a=c.addMembers(T,t);a=c.setLoadingMembers(a,!1);a=c.setLoadingMessages(a,!1);a=c.setName(a,s.fullname);a=c.setType(a,n);a=c.setImageUrl(a,s.profileimageurl);a=c.setTotalMemberCount(a,t.length);v(a);return s}).catch(function(e){var s=c.setLoadingMembers(T,!1);v(s);a.exception(e)})},K=function(e,s){var t=null;if(e.type==y.PRIVATE){var n=e.members.filter(function(e){return e.id!=s});t=n.length?n[0]:null}else if(e.type==y.SELF){t=e.members[0]}var a=e.name,d=e.imageurl;if(e.type!=y.PUBLIC){a=a||t?t.fullname:"";d=d||t?t.profileimageurl:""}var i=c.addMembers(T,e.members);i=c.setName(i,a);i=c.setSubname(i,e.subname);i=c.setType(i,e.type);i=c.setImageUrl(i,d);i=c.setTotalMemberCount(i,e.membercount);i=c.setIsFavourite(i,e.isfavourite);i=c.setIsMuted(i,e.ismuted);i=c.addMessages(i,e.messages);i=c.setCanDeleteMessagesForAllUsers(i,e.candeletemessagesforallusers);return i},j=function(e,s,t,n,d){var i=s.id,r=c.setLoadingMembers(T,!0);r=c.setLoadingMessages(r,!0);v(r);return o.getConversation(i,e,!0,!0,0,0,t+1,n,d).then(function(e){if(e.messages.length>t){e.messages=e.messages.slice(1)}else{x(!0)}k(n+t);return e}).then(function(e){var t=e.members.filter(function(e){return e.id==s.id});if(1>t.length){e.members=e.members.concat([s])}var n=K(e,s.id);n=c.setLoadingMembers(n,!1);n=c.setLoadingMessages(n,!1);return v(n).then(function(){return e})}).then(function(){return Y(e)}).catch(function(e){var s=c.setLoadingMembers(T,!1);s=c.setLoadingMessages(s,!1);v(s);a.exception(e)})},W=function(e,s,t,n){var d=e.members.filter(function(e){return e.id==s.id});if(1>d.length){e.members=e.members.concat([s])}var i=e.messages.length,o=i>=t,r=K(e,s.id);r=c.setLoadingMembers(r,!1);r=c.setLoadingMessages(r,!o);var g=v(r);return g.then(function(){if(!o){return J(e.id,t,i,n,[])}else{return{messages:e.messages}}}).then(function(){var e=T.messages;k(e.length);Y(T.id);return e}).catch(a.exception)},J=function(e,s,t,n,a,d){return o.getMessages(T.loggedInUserId,e,s?s+1:s,t,n,d).then(function(e){if(e.messages.length&&a.length){e.messages=e.messages.filter(function(e){return 0>a.indexOf(parseInt(e.id,10))})}return e}).then(function(e){if(!s){return e}else if(e.messages.length>s){e.messages=e.messages.slice(0,-1)}else{x(!0)}return e}).then(function(e){var s=e.members.filter(function(e){return!(e.id in T.members)}),t=c.addMembers(T,s);t=c.addMessages(t,e.messages);t=c.setLoadingMessages(t,!1);return v(t).then(function(){return e})}).catch(function(e){var s=c.setLoadingMessages(T,!1);v(s);throw e})},X=function(e,t){return function(){var n=T.messages,a=n.length?n[n.length-1]:null,o=a?a.timeCreated:null;if(o&&!p&&!N){for(var g=[],l=n.length-1,m;0<=l;l--){m=n[l];if(m.timeCreated===o){g.push(m.id)}else{break}}return J(e,0,0,t,g,o).then(function(s){if(s.messages.length){f.restart();var t=q(T);d.publish(r.CONVERSATION_NEW_LAST_MESSAGE,t);return Y(e)}else{return s}})}return s.Deferred().resolve().promise()}},Y=function(e){var s=T.loggedInUserId;return o.markAllConversationMessagesAsRead(s,e).then(function(){var s=c.markMessagesAsRead(T,T.messages);d.publish(r.CONVERSATION_READ,e);return v(s)})},H=function(e){ce(e);var s=c.addPendingBlockUsersById(T,[e]);v(s)},z=function(e){var s=c.setLoadingConfirmAction(T,!0);v(s);return o.blockUser(T.loggedInUserId,e).then(function(s){var t=c.addMembers(T,[s]);t=c.removePendingBlockUsersById(t,[e]);t=c.setLoadingConfirmAction(t,!1);d.publish(r.CONTACT_BLOCKED,e);return v(t)})},Z=function(e){ce(e);var s=c.addPendingUnblockUsersById(T,[e]);v(s)},$=function(e){var s=c.setLoadingConfirmAction(T,!0);v(s);return o.unblockUser(T.loggedInUserId,e).then(function(s){var t=c.addMembers(T,[s]);t=c.removePendingUnblockUsersById(t,[e]);t=c.setLoadingConfirmAction(t,!1);d.publish(r.CONTACT_UNBLOCKED,e);return v(t)})},ee=function(e){ce(e);var s=c.addPendingRemoveContactsById(T,[e]);v(s)},se=function(e){var s=c.setLoadingConfirmAction(T,!0);v(s);return o.deleteContacts(T.loggedInUserId,[e]).then(function(s){var t=c.addMembers(T,s);t=c.removePendingRemoveContactsById(t,[e]);t=c.setLoadingConfirmAction(t,!1);d.publish(r.CONTACT_REMOVED,e);return v(t)})},te=function(e){ce(e);var s=c.addPendingAddContactsById(T,[e]);v(s)},ne=function(e){var s=c.setLoadingConfirmAction(T,!0);v(s);return o.createContactRequest(T.loggedInUserId,e).then(function(e){if(!e.request){throw new Error(e.warnings[0].message)}return e.request}).then(function(s){var t=c.removePendingAddContactsById(T,[e]);t=c.addContactRequests(t,[s]);t=c.setLoadingConfirmAction(t,!1);return v(t)})},ae=function(){var e=T.loggedInUserId,s=T.id;return o.setFavouriteConversations(e,[s]).then(function(){var e=c.setIsFavourite(T,!0);return v(e)}).then(function(){return d.publish(r.CONVERSATION_SET_FAVOURITE,q(T))})},de=function(){var e=T.loggedInUserId,s=T.id;return o.unsetFavouriteConversations(e,[s]).then(function(){var e=c.setIsFavourite(T,!1);return v(e)}).then(function(){return d.publish(r.CONVERSATION_UNSET_FAVOURITE,q(T))})},ie=function(){var e=T.loggedInUserId,s=T.id;return o.setMutedConversations(e,[s]).then(function(){var e=c.setIsMuted(T,!0);return v(e)}).then(function(){return d.publish(r.CONVERSATION_SET_MUTED,q(T))})},oe=function(){var e=T.loggedInUserId,s=T.id;return o.unsetMutedConversations(e,[s]).then(function(){var e=c.setIsMuted(T,!1);return v(e)}).then(function(){return d.publish(r.CONVERSATION_UNSET_MUTED,q(T))})},re=function(e){var s=T.selectedMessageIds;ce(e);var t=c.addPendingDeleteMessagesById(T,s);v(t)},ge=function(){var e=T.pendingDeleteMessageIds,t=T.messages.filter(function(s){return 0<=e.indexOf(s.id)&&("sent"==s.sendState||null===s.sendState)}),n=c.setLoadingConfirmAction(T,!0);v(n);var i=s.Deferred().resolve().promise();if(t.length){var g=t.map(function(e){return e.id});if(n.deleteMessagesForAllUsers){i=o.deleteMessagesForAllUsers(T.loggedInUserId,g)}else{i=o.deleteMessages(T.loggedInUserId,g)}}return i.then(function(){var s=c.removeMessagesById(T,e);s=c.removePendingDeleteMessagesById(s,e);s=c.removeSelectedMessagesById(s,e);s=c.setLoadingConfirmAction(s,!1);s=c.setDeleteMessagesForAllUsers(s,!1);var t=T.messages[T.messages.length-1],n=s.messages.length?s.messages[s.messages.length-1]:null;if(n&&n.id!=t.id){var a=q(s);d.publish(r.CONVERSATION_NEW_LAST_MESSAGE,a)}else if(!s.messages.length){d.publish(r.CONVERSATION_DELETED,s.id)}return v(s)}).catch(a.exception)},le=function(e){ce(e);var s=c.setPendingDeleteConversation(T,!0);v(s)},me=function(){var e=c.setLoadingConfirmAction(T,!0);v(e);return o.deleteConversation(T.loggedInUserId,T.id).then(function(){var e=c.removeMessages(T,T.messages);e=c.removeSelectedMessagesById(e,T.selectedMessageIds);e=c.setPendingDeleteConversation(e,!1);e=c.setLoadingConfirmAction(e,!1);d.publish(r.CONVERSATION_DELETED,e.id);return v(e)})},ce=function(e){var s=T.pendingDeleteMessageIds,t=c.removePendingAddContactsById(T,[e]);t=c.removePendingRemoveContactsById(t,[e]);t=c.removePendingUnblockUsersById(t,[e]);t=c.removePendingBlockUsersById(t,[e]);t=c.removePendingDeleteMessagesById(t,s);t=c.setPendingDeleteConversation(t,!1);t=c.setDeleteMessagesForAllUsers(t,!1);v(t)},Ee=function(e){var s=T.loggedInUserId,t=T.members[e].contactrequests.filter(function(e){return e.requesteduserid==s}),n=t[0],a=c.setLoadingConfirmAction(T,!0);v(a);return o.acceptContactRequest(e,s).then(function(e){var s=c.removeContactRequests(T,[n]);s=c.addMembers(T,[e]);s=c.setLoadingConfirmAction(s,!1);return v(s)}).then(function(){d.publish(r.CONTACT_ADDED,T.members[e]);d.publish(r.CONTACT_REQUEST_ACCEPTED,n)})},Ie=function(e){var s=T.loggedInUserId,t=T.members[e].contactrequests.filter(function(e){return e.requesteduserid==s}),n=t[0],a=c.setLoadingConfirmAction(T,!0);v(a);return o.declineContactRequest(e,s).then(function(e){var s=c.removeContactRequests(T,[n]);s=c.addMembers(T,[e]);s=c.setLoadingConfirmAction(s,!1);return v(s)}).then(function(){d.publish(r.CONTACT_REQUEST_DECLINED,n)})},Ce=function(){if(N){return}if(!S.length){return}N=!0;var e=S.slice();S=[];var t=T.id,n=null,a=e.map(function(e){return e.text}),g=e.map(function(e){return e.id}),l=null,m=null;if(!t&&T.type!=y.PUBLIC){var E=P();l=o.sendMessagesToUser(E,a).then(function(e){if(e.length){n=parseInt(e[0].conversationid,10);m=e[0].candeletemessagesforallusers}return e})}else{l=o.sendMessagesToConversation(t,a)}l.then(function(s){var t=s.map(function(e){return e.id}),a=[],i=[],o=[];e.forEach(function(e,t){var n=s[t];a.push([e,n]);if(0<=T.selectedMessageIds.indexOf(e.id)){i.push(e.id);o.push(n.id)}});var g=c.updateMessages(T,a);g=c.setMessagesSendSuccessById(g,t);if(i.length){g=c.removeSelectedMessagesById(g,i)}if(o.length){g=c.addSelectedMessagesById(g,o)}var l=q(g);if(!g.id){g=c.setId(g,n);l.id=n;we(n);d.publish(r.CONVERSATION_CREATED,l);g=c.setCanDeleteMessagesForAllUsers(g,m)}v(g);N=!1;Ce();d.publish(r.CONVERSATION_NEW_LAST_MESSAGE,l)}).catch(function(t){if(t.message){var e=s.Deferred().resolve(t.message).promise()}else{var e=i.get_string("unknownerror","core")}var n=function(e){var s=c.setMessagesSendFailById(T,g,e);v(s);N=!1;Ce()};e.then(n).catch(function(s){var e=s.message||"Something went wrong!";n(e)})})},_e=function(e){var s="temp"+Date.now(),t={id:s,useridfrom:T.loggedInUserId,text:e,timecreated:null},n=c.addMessages(T,[t]);v(n);S.push(t);Ce()},ue=function(e){var s=c.setMessagesSendPendingById(T,[e.id]);v(s);S.push(e);Ce()},Te=function(e){var s=T;if(-1<T.selectedMessageIds.indexOf(e)){s=c.removeSelectedMessagesById(T,[e])}else{s=c.addSelectedMessagesById(T,[e])}v(s)},Ae=function(){ce(P());var e=c.removeSelectedMessagesById(T,T.selectedMessageIds);v(e)},he=function(e,t,n){if(O){return}if(!M.length){return}O=!0;var d=M.shift(),i=b.map(function(e){return e(d.patch)});s.when.apply(null,i).then(function(){O=!1;d.deferred.resolve(!0);he(e,t,n)}).catch(function(e){O=!1;d.deferred.reject(e);a.exception(e)})},fe=function(e,t,n,a){var d=function(s){return m.render(e,t,n,s)};if(!a){var i=c.buildInitialState(T.midnight,T.loggedInUserId,T.id),o=l.buildPatch(i,T);d(o)}b.push(d);return function(a){var d=l.buildPatch(T,a),i=s.Deferred();if(Object.keys(d).length){M.push({patch:d,deferred:i})}else{i.resolve(!0)}T=a;if(a.id){u[a.id]={state:a,messagesOffset:w(),loadedAllMessages:V()}}he(e,t,n);return i.promise()}},Oe=function(e){return function(s,t){if(!T.loadingConfirmAction){e(P());var n=c.setLoadingConfirmAction(T,!1);v(n)}t.originalEvent.preventDefault()}},Me=function(t,e){var n=s(t.target),a=n.closest(D.FOOTER_CONTAINER),d=a.find(D.MESSAGE_TEXT_AREA),i=d.val().trim();if(""!==i){_e(i);d.val("");d.focus()}e.originalEvent.preventDefault()},pe=function(t,e){var n=window.getSelection(),a=s(t.target);if(""!=n.toString()){return}if(a.is("a")){return}var d=a.closest(D.MESSAGE),i=d.attr("data-message-id");Te(i);e.originalEvent.preventDefault()},Ne=function(t,e){var n=s(t.target),a=n.closest(D.MESSAGE),d=a.attr("data-message-id"),i=T.messages.filter(function(e){return e.id==d}),o=i.length?i[0]:null;if(o){ue(o)}e.originalEvent.preventDefault();e.originalEvent.stopPropagation();t.stopPropagation()},Se=function(s,e){Ae();e.originalEvent.preventDefault()},ve=function(s){return function(t,e){var n=P(),a=T.members[n];E.go(s,I.VIEW_CONTACT,a);e.originalEvent.preventDefault()}},be=function(s,e){ae().catch(a.exception);e.originalEvent.preventDefault()},Ue=function(s,e){de().catch(a.exception);e.originalEvent.preventDefault()},Re=function(s,e){ie().catch(a.exception);e.originalEvent.preventDefault()},Le=function(s,e){oe().catch(a.exception);e.originalEvent.preventDefault()},De=function(t){var e=s(t.target).prop("checked"),n=c.setDeleteMessagesForAllUsers(T,e);v(n)},ye=function(s){return function(t,e){E.go(s,I.VIEW_GROUP_INFO,{id:T.id,name:T.name,subname:T.subname,imageUrl:T.imageUrl,totalMemberCount:T.totalMemberCount},T.loggedInUserId);e.originalEvent.preventDefault()}},Pe=function(s,e){var t=c.setShowEmojiPicker(T,!T.showEmojiPicker);v(t);e.originalEvent.preventDefault()},Be=function(t){var e=s(t.target);if(T.showEmojiPicker&&!e.closest(D.EMOJI_PICKER_CONTAINER).length&&!e.closest(D.TOGGLE_EMOJI_PICKER_BUTTON).length){var n=c.setShowEmojiPicker(T,!1);v(n)}},Fe=function(t,i,o,g){var l=!1,m=G(o),E=g.find(D.EMOJI_PICKER),u=g.find(D.EMOJI_AUTO_COMPLETE_CONTAINER),A=g.find(D.MESSAGE_TEXT_AREA),h=[[D.ACTION_REQUEST_BLOCK,Oe(H)],[D.ACTION_REQUEST_UNBLOCK,Oe(Z)],[D.ACTION_REQUEST_ADD_CONTACT,Oe(te)],[D.ACTION_REQUEST_REMOVE_CONTACT,Oe(ee)],[D.ACTION_REQUEST_DELETE_CONVERSATION,Oe(le)],[D.ACTION_CANCEL_EDIT_MODE,Se],[D.ACTION_VIEW_CONTACT,ve(t)],[D.ACTION_VIEW_GROUP_INFO,ye(t)],[D.ACTION_CONFIRM_FAVOURITE,be],[D.ACTION_CONFIRM_MUTE,Re],[D.ACTION_CONFIRM_UNFAVOURITE,Ue],[D.ACTION_CONFIRM_UNMUTE,Le]],O=[[D.ACTION_CANCEL_CONFIRM,Oe(ce)],[D.ACTION_CONFIRM_BLOCK,Oe(z)],[D.ACTION_CONFIRM_UNBLOCK,Oe($)],[D.ACTION_CONFIRM_ADD_CONTACT,Oe(ne)],[D.ACTION_CONFIRM_REMOVE_CONTACT,Oe(se)],[D.ACTION_CONFIRM_DELETE_SELECTED_MESSAGES,Oe(ge)],[D.ACTION_CONFIRM_DELETE_CONVERSATION,Oe(me)],[D.ACTION_OKAY_CONFIRM,Oe(ce)],[D.ACTION_REQUEST_ADD_CONTACT,Oe(te)],[D.ACTION_ACCEPT_CONTACT_REQUEST,Oe(Ee)],[D.ACTION_DECLINE_CONTACT_REQUEST,Oe(Ie)],[D.MESSAGE,pe],[D.DELETE_MESSAGES_FOR_ALL_USERS_TOGGLE,De],[D.RETRY_SEND,Ne]],M=[[D.SEND_MESSAGE_BUTTON,Me],[D.TOGGLE_EMOJI_PICKER_BUTTON,Pe],[D.ACTION_REQUEST_DELETE_SELECTED_MESSAGES,Oe(re)],[D.ACTION_REQUEST_ADD_CONTACT,Oe(te)],[D.ACTION_REQUEST_UNBLOCK,Oe(Z)]];e.init(g);if(u.length){C(u[0],A[0],function(e){var s=c.setShowEmojiAutoComplete(T,e);v(s)},function(e){var s=c.setShowEmojiAutoComplete(T,!1);v(s);A.focus();var t=A.prop("selectionStart"),n=A.val(),a=n.substring(0,t).replace(/\S*$/,""),d=n.substring(t).replace(/^\S*/,"");A.val(a+e+d);A.prop("selectionStart",a.length+e.length);A.prop("selectionEnd",a.length+e.length)})}if(E.length){_(E[0],function(e){var s=c.setShowEmojiPicker(T,!T.showEmojiPicker);v(s);A.focus();var t=A.prop("selectionStart"),n=A.val(),a=n.substring(0,t),d=n.substring(t,n.length);A.val(a+e+d);A.prop("selectionStart",t+e.length);A.prop("selectionEnd",t+e.length)})}n.define(i,[n.events.activate]);n.define(o,[n.events.activate]);n.define(g,[n.events.activate,n.events.enter,n.events.escape]);n.define(m,[n.events.scrollTop,n.events.scrollLock]);m.on(n.events.scrollTop,function(s,e){var t=1<Object.keys(T.members).length;if(!p&&!l&&!V()&&t){l=!0;var n=c.setLoadingMessages(T,!0);v(n);J(T.id,R,w(),U,[]).then(function(){l=!1;k(w()+R)}).catch(function(e){l=!1;a.exception(e)})}e.originalEvent.preventDefault()});h.forEach(function(e){var s=e[0],t=e[1];i.on(n.events.activate,s,t)});O.forEach(function(e){var s=e[0],t=e[1];o.on(n.events.activate,s,t)});M.forEach(function(e){var s=e[0],t=e[1];g.on(n.events.activate,s,t)});g.on(n.events.enter,D.MESSAGE_TEXT_AREA,function(s,e){var t=g.attr("data-enter-to-send");if(t&&"false"!=t&&"0"!=t){Me(s,e)}});g.on(n.events.escape,D.EMOJI_PICKER_CONTAINER,Pe);s(document.body).on("click",Be);d.subscribe(r.ROUTE_CHANGED,function(e){if(f){if(e.route!=I.VIEW_CONVERSATION){f.stop()}}})},we=function(e){if(f){f.stop()}f=new t(X(e,U),t.getIncrementalCallback(T.messagePollMin*L,L,T.messagePollMax*L,T.messagePollAfterMax*L));f.start()},ke=function(e,s,t){A=!1;h=0;f=null;O=!1;M=[];p=!0;N=!1;S=[];var n=t.id,a=parseInt(e.attr("data-midnight"),10),d=parseInt(e.attr("data-message-poll-min"),10),i=parseInt(e.attr("data-message-poll-max"),10),o=parseInt(e.attr("data-message-poll-after-max"),10),r=c.buildInitialState(a,n,s,d,i,o);if(!T){T=r}if(f){f.stop()}v(r)},Ve=function(e,s,t){ke(e,null,s);var n=null;if(s.id!=t){n=o.getConversationBetweenUsers(s.id,t,!0,!0,0,0,R,0,U)}else{n=o.getSelfConversation(s.id,R,0,U)}return n.then(function(t){return Ge(e,t,s)}).catch(function(){return Q(s,t)})},xe=function(e,t,n){var a=null;if(t in u){a=u[t]}ke(e,t,n);var d=s.Deferred().resolve({}).promise();if(a){var i=a.state;i=c.setLoadingMessages(i,!1);i=c.setLoadingMembers(i,!1);k(a.messagesOffset);x(a.loadedAllMessages);v(i)}else{d=j(t,n,R,0,U)}return d.then(function(){return we(t)})},Ge=function(e,t,n){var a=null;if(t.id in u){a=u[t.id]}ke(e,t.id,n);var d=s.Deferred().resolve({}).promise();if(a){var i=a.state;i=c.setLoadingMessages(i,!1);i=c.setLoadingMembers(i,!1);k(a.messagesOffset);x(a.loadedAllMessages);v(i)}else{d=W(t,n,R,U)}return d.then(function(){return we(t.id)})},qe=function(e,t,n,d,i,o,r){var l=null,m=null;if(i&&null!==i&&"object"==_typeof(i)){l=i;m=parseInt(l.id,10)}else{l=null;m=parseInt(i,10);m=isNaN(m)?null:m}if(!m&&o&&r){m=B(r)}var c=!T||T.id!=m||r&&r!=P();if(!n.attr("data-init")){v=fe(t,n,d,c);Fe(e,t,n,d);n.attr("data-init",!0)}if(c){var E=null,I=F(n);if(l){E=Ge(n,l,I,r)}else if(m){E=xe(n,m,I,r)}else{E=Ve(n,I,r)}return E.then(function(){p=!1;t.find(g.SELECTORS.CAN_RECEIVE_FOCUS).first().focus()}).catch(function(e){p=!1;a.exception(e)})}we(m);if(T.type==y.PRIVATE&&o){var C=P();switch(o){case"block":return H(C);case"unblock":return Z(C);case"add-contact":return te(C);case"remove-contact":return ee(C);}}return s.Deferred().resolve().promise()},Qe=function(){return i.get_string("messagedrawerviewconversation","core_message",T.name)};return{show:qe,description:Qe}});
2 //# sourceMappingURL=message_drawer_view_conversation.min.js.map