// @formatter:off
import { UIBuilder } from "./util/uiBuilder";
import { isOp, translate } from "./util/miscUtils";
export const ConfigsComponent = {
    onUse(event) {
        const player = event.source;
        if (isOp(player)) {
            configs.configUI.open(player);
        }
        else {
            player.onScreenDisplay.setActionBar(translate("message", "not_op"));
        }
    }
};
class Configs {
    constructor() {
        // Initialize the configBook property with the BookBuilder instance and use the wallLanternsEnabled
        const builder = UIBuilder.create('configs')
            .configPage()
            .setOpenSound("item.spyglass.use");
        this.wallLanternsEnabled = builder.defineBool("enable_wall_lanterns", true);
        this.placeableBooksEnabled = builder.defineBool("enable_placeable_books", true);
        this.placeableStick = builder.defineBool("enable_placeable_stick", true);
        this.rakedGravelEnabled = builder.defineBool("enable_raked_gravel", true);
        this.clockAndCompassEnabled = builder.defineBool("enable_clock_and_compass", true);
        //mega dumb the slider doesnt show decimal
        this.soapSlip = builder.defineBool("soap_slip", true);
        this.ropeInteraction = builder.defineBool("rope_interaction", true);
        this.ashFromMobsChance = builder.defineNumber("ash_from_mobs", 0, 100, 20, 0.5);
        this.flaxDropChance = builder.defineNumber("flax_from_grass", 0, 100, 1, 0.1);
        this.wrenchUp = builder.defineBool("wrench_up", true);
        this.faucetIrrigate = builder.defineBool("faucet_irrigate", true);
        this.nausea = builder.defineBool("nausea", true);
        this.slingshotScalar = builder.defineNumber("slingshot_power", 0.1, 3, 1, 0.01);
        this.placeableConfetti = builder.defineBool("placeable_confetti", true);
        this.confettiAmount = builder.defineNumber("confetti_amount", 1, 200, 80, 1);
        this.speakerMaxRange = builder.defineNumber("speaker_range", 0, 100, 32, 1);
        this.speakerPrefix = builder.defineBool("speaker_prefix", true);
        this.speakerCensor = builder.defineStr("speaker_censoring", "", (s) => {
            try {
                new RegExp(s, "gi"); // "gi" for global & case-insensitive matching
                return true;
            }
            catch (e) {
                return false;
            }
        });
        this.cushionLockRotation = builder.defineBool("cushion_lock_rotation", false);
        this.configsInBook = builder.defineBool("configs_in_book", false);
        builder.onSubmit((context, changed) => {
            if (changed) {
                context.player.onScreenDisplay.setActionBar(translate("message", "configs"));
            }
        });
        this.configUI = builder.build();
    }
}
export const configs = new Configs();
