#![allow(dead_code)]
#![allow(long_running_const_eval)]
#![allow(unused_imports)]

use crate::character::Character::{self, *};
use crate::condition::Condition::{self, *};
use crate::entity::Entity;
use crate::item::Item::{self, *};
use crate::location::Location::{self, *};
use crate::save_point::SavePoint::{self, *};
use crate::script::Token::{self, *};
use crate::script::script;
use crate::snippet::Snippet::{self, *};
use crate::sound::Sound::{self, *};
use crate::style::Style::{self, *};

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[repr(u32)]
pub enum Label {
    Label1570A0,
    Label1570A8,
    Label1570B2,
    Label1570C3,
    Label1570D3,
    Label1570E4,
    Label1570F0,
    Label1570FB,
}

use self::Label::*;

const fn find_label(script: &'static [Token<Label>], label: Label) -> usize {
    let mut i = 0;
    while i < script.len() {
        match script[i] {
            Token::Label(l) if l as u8 == label as u8 => return i,
            _ => i += 1,
        };
    }
    unreachable!();
}

pub fn dialog_for_label(index: usize) -> &'static [Token<'static, Label>] {
    &SCRIPTS[INDEXED[index]..]
}

pub fn dialog(index: usize) -> &'static [Token<'static, Label>] {
    &SCRIPTS[INDEXED[index]..]
}

const SCRIPTS: &[Token<Label>] = script![

Label(Label1570A0)
    "Estafan" End

Label(Label1570A8)
    "Rapadagna" End

Label(Label1570B2)
    "Tower of Silence" End

Label(Label1570C3)
    "Handera Volcano" End

Label(Label1570D3)
    "Stream Sanctuary" End

Label(Label1570E4)
    "Ice Pyramid" End

Label(Label1570F0)
    "Sky Castle" End

Label(Label1570FB)
    "Underground Fort" End
    ];

pub const INDEXED: &[usize] = &[
    find_label(SCRIPTS, Label1570A0),
    find_label(SCRIPTS, Label1570A8),
    find_label(SCRIPTS, Label1570B2),
    find_label(SCRIPTS, Label1570C3),
    find_label(SCRIPTS, Label1570D3),
    find_label(SCRIPTS, Label1570E4),
    find_label(SCRIPTS, Label1570F0),
    find_label(SCRIPTS, Label1570FB),
];
