package com.discord.stores; import c.d.b.a.a; import com.discord.models.domain.emoji.ModelEmojiUnicode; import com.discord.stores.updates.ObservationDeck; import com.discord.utilities.persister.Persister; import com.discord.utilities.textprocessing.node.EmojiNode; import d0.e0.c; import d0.g; import d0.t.n0; import d0.t.u; import d0.z.d.a0; import d0.z.d.m; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.Set; import kotlin.Lazy; import kotlin.jvm.internal.DefaultConstructorMarker; import rx.Observable; /* compiled from: StoreMediaFavorites.kt */ public final class StoreMediaFavorites extends StoreV2 { public static final Companion Companion = new Companion(null); public static final String FAVORITES_CACHE_KEY = "STORE_FAVORITES"; private final Dispatcher dispatcher; private final Set favorites; private Set favoritesSnapshot; private final ObservationDeck observationDeck; private final Persister> persister; /* compiled from: StoreMediaFavorites.kt */ public static final class Companion { private Companion() { } public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } } /* compiled from: StoreMediaFavorites.kt */ public static abstract class Favorite { private static final Lazy AllTypes$delegate = g.lazy(StoreMediaFavorites$Favorite$Companion$AllTypes$2.INSTANCE); public static final Companion Companion = new Companion(null); private static final Set> EmojiTypes = n0.setOf((Object[]) new c[]{a0.getOrCreateKotlinClass(FavCustomEmoji.class), a0.getOrCreateKotlinClass(FavUnicodeEmoji.class)}); /* compiled from: StoreMediaFavorites.kt */ public static final class Companion { private Companion() { } public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } public final Set> getAllTypes() { Lazy access$getAllTypes$cp = Favorite.access$getAllTypes$cp(); Companion companion = Favorite.Companion; return (Set) access$getAllTypes$cp.getValue(); } public final Set> getEmojiTypes() { return Favorite.access$getEmojiTypes$cp(); } } /* compiled from: StoreMediaFavorites.kt */ public static final class FavCustomEmoji extends Favorite implements FavoriteEmoji { private final String emojiUniqueId; /* JADX INFO: this call moved to the top of the method (can break code semantics) */ public FavCustomEmoji(EmojiNode.EmojiIdAndType.Custom custom) { this(String.valueOf(custom.getId())); m.checkNotNullParameter(custom, "custom"); } /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public FavCustomEmoji(String str) { super(null); m.checkNotNullParameter(str, "emojiUniqueId"); this.emojiUniqueId = str; } public static /* synthetic */ FavCustomEmoji copy$default(FavCustomEmoji favCustomEmoji, String str, int i, Object obj) { if ((i & 1) != 0) { str = favCustomEmoji.getEmojiUniqueId(); } return favCustomEmoji.copy(str); } public final String component1() { return getEmojiUniqueId(); } public final FavCustomEmoji copy(String str) { m.checkNotNullParameter(str, "emojiUniqueId"); return new FavCustomEmoji(str); } public boolean equals(Object obj) { if (this != obj) { return (obj instanceof FavCustomEmoji) && m.areEqual(getEmojiUniqueId(), ((FavCustomEmoji) obj).getEmojiUniqueId()); } return true; } @Override // com.discord.stores.StoreMediaFavorites.FavoriteEmoji public String getEmojiUniqueId() { return this.emojiUniqueId; } public int hashCode() { String emojiUniqueId = getEmojiUniqueId(); if (emojiUniqueId != null) { return emojiUniqueId.hashCode(); } return 0; } public String toString() { StringBuilder L = a.L("FavCustomEmoji(emojiUniqueId="); L.append(getEmojiUniqueId()); L.append(")"); return L.toString(); } } /* compiled from: StoreMediaFavorites.kt */ public static final class FavUnicodeEmoji extends Favorite implements FavoriteEmoji { private final String emojiUniqueId; /* JADX WARNING: Illegal instructions before constructor call */ public FavUnicodeEmoji(ModelEmojiUnicode modelEmojiUnicode) { this(r2); m.checkNotNullParameter(modelEmojiUnicode, "unicode"); String uniqueId = modelEmojiUnicode.getUniqueId(); m.checkNotNullExpressionValue(uniqueId, "unicode.uniqueId"); } /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public FavUnicodeEmoji(String str) { super(null); m.checkNotNullParameter(str, "emojiUniqueId"); this.emojiUniqueId = str; } public static /* synthetic */ FavUnicodeEmoji copy$default(FavUnicodeEmoji favUnicodeEmoji, String str, int i, Object obj) { if ((i & 1) != 0) { str = favUnicodeEmoji.getEmojiUniqueId(); } return favUnicodeEmoji.copy(str); } public final String component1() { return getEmojiUniqueId(); } public final FavUnicodeEmoji copy(String str) { m.checkNotNullParameter(str, "emojiUniqueId"); return new FavUnicodeEmoji(str); } public boolean equals(Object obj) { if (this != obj) { return (obj instanceof FavUnicodeEmoji) && m.areEqual(getEmojiUniqueId(), ((FavUnicodeEmoji) obj).getEmojiUniqueId()); } return true; } @Override // com.discord.stores.StoreMediaFavorites.FavoriteEmoji public String getEmojiUniqueId() { return this.emojiUniqueId; } public int hashCode() { String emojiUniqueId = getEmojiUniqueId(); if (emojiUniqueId != null) { return emojiUniqueId.hashCode(); } return 0; } public String toString() { StringBuilder L = a.L("FavUnicodeEmoji(emojiUniqueId="); L.append(getEmojiUniqueId()); L.append(")"); return L.toString(); } } private Favorite() { } public /* synthetic */ Favorite(DefaultConstructorMarker defaultConstructorMarker) { this(); } public static final /* synthetic */ Lazy access$getAllTypes$cp() { return AllTypes$delegate; } public static final /* synthetic */ Set access$getEmojiTypes$cp() { return EmojiTypes; } } /* compiled from: StoreMediaFavorites.kt */ public interface FavoriteEmoji { String getEmojiUniqueId(); } public StoreMediaFavorites(ObservationDeck observationDeck, Dispatcher dispatcher, Persister> persister) { m.checkNotNullParameter(observationDeck, "observationDeck"); m.checkNotNullParameter(dispatcher, "dispatcher"); m.checkNotNullParameter(persister, "persister"); this.observationDeck = observationDeck; this.dispatcher = dispatcher; this.persister = persister; Set set = persister.get(); this.favoritesSnapshot = set; this.favorites = u.toMutableSet(set); } /* JADX INFO: this call moved to the top of the method (can break code semantics) */ public /* synthetic */ StoreMediaFavorites(ObservationDeck observationDeck, Dispatcher dispatcher, Persister persister, int i, DefaultConstructorMarker defaultConstructorMarker) { this(observationDeck, dispatcher, (i & 4) != 0 ? new Persister("STORE_FAVORITES", n0.emptySet()) : persister); } public static final /* synthetic */ Set access$getFavorites$p(StoreMediaFavorites storeMediaFavorites) { return storeMediaFavorites.favorites; } /* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.stores.StoreMediaFavorites */ /* JADX WARN: Multi-variable type inference failed */ public static /* synthetic */ Set getFavorites$default(StoreMediaFavorites storeMediaFavorites, Set set, int i, Object obj) { Set> set2 = set; if ((i & 1) != 0) { set2 = Favorite.Companion.getAllTypes(); } return storeMediaFavorites.getFavorites(set2); } /* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.stores.StoreMediaFavorites */ /* JADX WARN: Multi-variable type inference failed */ public static /* synthetic */ Observable observeFavorites$default(StoreMediaFavorites storeMediaFavorites, Set set, int i, Object obj) { Set> set2 = set; if ((i & 1) != 0) { set2 = Favorite.Companion.getAllTypes(); } return storeMediaFavorites.observeFavorites(set2); } public final void addFavorite(Favorite favorite) { m.checkNotNullParameter(favorite, "favorite"); this.dispatcher.schedule(new StoreMediaFavorites$addFavorite$1(this, favorite)); } public final Set getFavorites(Set> set) { m.checkNotNullParameter(set, "types"); Set set2 = this.favoritesSnapshot; LinkedHashSet linkedHashSet = new LinkedHashSet(); for (Object obj : set2) { if (set.contains(a0.getOrCreateKotlinClass(((Favorite) obj).getClass()))) { linkedHashSet.add(obj); } } return linkedHashSet; } public final Observable> observeFavorites(Set> set) { m.checkNotNullParameter(set, "types"); Observable> r = ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreMediaFavorites$observeFavorites$1(this, set), 14, null).r(); m.checkNotNullExpressionValue(r, "observationDeck.connectR… .distinctUntilChanged()"); return r; } public final void removeFavorite(Favorite favorite) { m.checkNotNullParameter(favorite, "favorite"); this.dispatcher.schedule(new StoreMediaFavorites$removeFavorite$1(this, favorite)); } @Override // com.discord.stores.StoreV2 public void snapshotData() { super.snapshotData(); HashSet hashSet = new HashSet(this.favorites); this.favoritesSnapshot = hashSet; this.persister.set(hashSet, true); } }