/* @flow */
import { createSelector } from 'reselect';
import { getRawRealmEmoji } from '../directSelectors';
import { getAuth } from '../account/accountSelectors';
import { getFullUrl } from '../utils/url';

export const getAllRealmEmojiById = createSelector(getAuth, getRawRealmEmoji, (auth, emojis) =>
  Object.keys(emojis).reduce((result, id) => {
    result[id] = { ...emojis[id], source_url: getFullUrl(emojis[id].source_url, auth.realm) };
    return result;
  }, {}),
);

export const getActiveRealmEmojiById = createSelector(getAllRealmEmojiById, emojis =>
  Object.keys(emojis)
    .filter(id => !emojis[id].deactivated)
    .reduce((result, id) => {
      result[id] = emojis[id];
      return result;
    }, {}),
);

@@ -48,16 +48,75 @@
 elect';%0A
+import type %7B Selector, RealmEmojiState %7D from '../types';%0A
 import %7B
@@ -286,32 +286,59 @@
 llRealmEmojiById
+: Selector%3CRealmEmojiState%3E
  = createSelecto
@@ -343,16 +343,19 @@
 tor(
+%0A  
 getAuth,
  get
@@ -350,16 +350,18 @@
 getAuth,
+%0A 
  getRawR
@@ -370,16 +370,18 @@
 lmEmoji,
+%0A 
  (auth, 
@@ -387,24 +387,26 @@
  emojis) =%3E%0A
+  
   Object.key
@@ -436,24 +436,26 @@
 t, id) =%3E %7B%0A
+  
     result%5Bi
@@ -537,24 +537,26 @@
 alm) %7D;%0A    
+  
 return resul
@@ -560,16 +560,18 @@
 sult;%0A  
+ 
+ 
 %7D, %7B%7D),%0A
@@ -610,16 +610,43 @@
 mojiById
+: Selector%3CRealmEmojiState%3E
  = creat
@@ -655,16 +655,19 @@
 elector(
+%0A  
 getAllRe
@@ -679,16 +679,18 @@
 ojiById,
+%0A 
  emojis 
@@ -692,16 +692,18 @@
 ojis =%3E%0A
+  
   Object
@@ -720,16 +720,18 @@
 is)%0A    
+ 
+ 
 .filter(
@@ -765,16 +765,18 @@
 ed)%0A    
+  
 .reduce(
@@ -785,32 +785,34 @@
 esult, id) =%3E %7B%0A
+  
       result%5Bid%5D
@@ -824,32 +824,34 @@
 ojis%5Bid%5D;%0A      
+  
 return result;%0A 
@@ -841,31 +841,33 @@
  return result;%0A
+  
     %7D, %7B%7D),%0A);%0A

Add type annotations to selectors.