package com.discord.stores; import com.discord.api.commands.ApplicationCommand; import com.discord.models.commands.Application; import d0.t.n; import d0.t.u; import d0.z.d.o; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; import kotlin.Unit; import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function1; /* compiled from: StoreApplicationCommands.kt */ public final class StoreApplicationCommands$getApplicationCommandsViaRest$1 extends o implements Function1, Unit> { public final /* synthetic */ long $applicationId; public final /* synthetic */ StoreApplicationCommands this$0; /* compiled from: StoreApplicationCommands.kt */ /* renamed from: com.discord.stores.StoreApplicationCommands$getApplicationCommandsViaRest$1$1 reason: invalid class name */ public static final class AnonymousClass1 extends o implements Function0 { public final /* synthetic */ List $commands; public final /* synthetic */ StoreApplicationCommands$getApplicationCommandsViaRest$1 this$0; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public AnonymousClass1(StoreApplicationCommands$getApplicationCommandsViaRest$1 storeApplicationCommands$getApplicationCommandsViaRest$1, List list) { super(0); this.this$0 = storeApplicationCommands$getApplicationCommandsViaRest$1; this.$commands = list; } @Override // kotlin.jvm.functions.Function0 /* renamed from: invoke */ public final void mo1invoke() { List list; Collection collection; StoreApplicationCommands.access$setLoadingDiscoveryCommands$p(this.this$0.this$0, false); Iterator it = StoreApplicationCommands.access$getApplications$p(this.this$0.this$0).iterator(); int i = 0; while (true) { if (!it.hasNext()) { i = -1; break; } if (((Application) it.next()).getId() == this.this$0.$applicationId) { break; } i++; } if (i != -1) { List list2 = this.$commands; int size = list2 != null ? list2.size() : 0; ArrayList arrayList = new ArrayList(StoreApplicationCommands.access$getApplications$p(this.this$0.this$0)); Application application = (Application) arrayList.remove(i); if (size > 0) { arrayList.add(i, new Application(application.getId(), application.getName(), application.getIcon(), null, size, application.getBot(), application.getBuiltIn(), 8, null)); } StoreApplicationCommands.access$setApplications$p(this.this$0.this$0, arrayList); StoreApplicationCommands storeApplicationCommands = this.this$0.this$0; StoreApplicationCommands.access$handleGuildApplicationsUpdate(storeApplicationCommands, u.toList(StoreApplicationCommands.access$getApplications$p(storeApplicationCommands))); StoreApplicationCommands storeApplicationCommands2 = this.this$0.this$0; List list3 = this.$commands; if (list3 != null) { list = new ArrayList(d0.t.o.collectionSizeOrDefault(list3, 10)); for (ApplicationCommand applicationCommand : list3) { list.add(StoreApplicationCommandsKt.toSlashCommand(applicationCommand)); } } else { list = n.emptyList(); } StoreApplicationCommands.access$handleDiscoverCommandsUpdate(storeApplicationCommands2, list); List list4 = this.$commands; if (list4 != null) { collection = new ArrayList(d0.t.o.collectionSizeOrDefault(list4, 10)); for (ApplicationCommand applicationCommand2 : list4) { collection.add(StoreApplicationCommandsKt.toSlashCommand(applicationCommand2)); } } else { collection = n.emptyList(); } StoreApplicationCommands.access$handleQueryCommandsUpdate(this.this$0.this$0, u.plus(collection, (Iterable) StoreApplicationCommands.access$getBuiltInCommandsProvider$p(this.this$0.this$0).getBuiltInCommands())); } } } /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public StoreApplicationCommands$getApplicationCommandsViaRest$1(StoreApplicationCommands storeApplicationCommands, long j) { super(1); this.this$0 = storeApplicationCommands; this.$applicationId = j; } /* Return type fixed from 'java.lang.Object' to match base method */ /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */ @Override // kotlin.jvm.functions.Function1 public /* bridge */ /* synthetic */ Unit invoke(List list) { invoke((List) list); return Unit.a; } public final void invoke(List list) { StoreApplicationCommands.access$getDispatcher$p(this.this$0).schedule(new AnonymousClass1(this, list)); } }