/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  net.minecraft.class_1268
 *  net.minecraft.class_1799
 *  net.minecraft.class_2596
 *  net.minecraft.class_2820
 *  net.minecraft.class_3872$class_3931
 *  net.minecraft.class_9262
 *  net.minecraft.class_9302
 *  net.minecraft.class_9334
 */
package meteordevelopment.meteorclient.gui.screens;

import java.util.ArrayList;
import java.util.Optional;
import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.gui.GuiTheme;
import meteordevelopment.meteorclient.gui.WindowScreen;
import meteordevelopment.meteorclient.gui.widgets.containers.WTable;
import meteordevelopment.meteorclient.gui.widgets.input.WTextBox;
import net.minecraft.class_1268;
import net.minecraft.class_1799;
import net.minecraft.class_2596;
import net.minecraft.class_2820;
import net.minecraft.class_3872;
import net.minecraft.class_9262;
import net.minecraft.class_9302;
import net.minecraft.class_9334;

public class EditBookTitleAndAuthorScreen
extends WindowScreen {
    private final class_1799 itemStack;
    private final class_1268 hand;

    public EditBookTitleAndAuthorScreen(GuiTheme theme, class_1799 itemStack, class_1268 hand) {
        super(theme, "Edit title & author");
        this.itemStack = itemStack;
        this.hand = hand;
    }

    @Override
    public void initWidgets() {
        WTable t = this.add(this.theme.table()).expandX().widget();
        t.add(this.theme.label("Title"));
        WTextBox title = t.add(this.theme.textBox((String)((class_9302)this.itemStack.method_58694(class_9334.field_49606)).comp_2419().method_57140(MeteorClient.mc.method_33883()))).minWidth(220.0).expandX().widget();
        t.row();
        t.add(this.theme.label("Author"));
        WTextBox author = t.add(this.theme.textBox(((class_9302)this.itemStack.method_58694(class_9334.field_49606)).comp_2420())).minWidth(220.0).expandX().widget();
        t.row();
        t.add(this.theme.button((String)"Done")).expandX().widget().action = () -> {
            class_9302 component = (class_9302)this.itemStack.method_58694(class_9334.field_49606);
            class_9302 newComponent = new class_9302(class_9262.method_57137((Object)title.get()), author.get(), component.comp_2421(), component.comp_2422(), component.comp_2423());
            this.itemStack.method_57379(class_9334.field_49606, (Object)newComponent);
            class_3872.class_3931 contents = new class_3872.class_3931(((class_9302)this.itemStack.method_58694(class_9334.field_49606)).method_57525(MeteorClient.mc.method_33883()));
            ArrayList<String> pages = new ArrayList<String>(contents.method_17560());
            for (int i = 0; i < contents.method_17560(); ++i) {
                pages.add(contents.method_17563(i).getString());
            }
            MeteorClient.mc.method_1562().method_52787((class_2596)new class_2820(this.hand == class_1268.field_5808 ? MeteorClient.mc.field_1724.method_31548().method_67532() : 40, pages, Optional.of(title.get())));
            this.method_25419();
        };
    }
}

