#![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 {
    Label087AC6,
    Label087ACB,
    Label087AD1,
    Label087AD8,
    Label087AE1,
    Label087AE7,
    Label087AF0,
    Label087AF8,
    Label087AFD,
    Label087B03,
    Label087B07,
    Label087B0E,
    Label087B13,
    Label087B1A,
    Label087B1F,
    Label087B25,
    Label087B2A,
    Label087B34,
    Label087B3B,
    Label087B43,
    Label087B4A,
    Label087B51,
    Label087B5D,
    Label087B5E,
    Label087B5F,
    Label087B60,
    Label087B65,
    Label087B6D,
    Label087B76,
    Label087B7E,
    Label087B85,
    Label087B8B,
    Label087B90,
    Label087B95,
    Label087B9D,
    Label087BA6,
    Label087BAB,
    Label087BB0,
    Label087BB5,
    Label087BBA,
    Label087BBF,
    Label087BC4,
    Label087BCC,
    Label087BD4,
    Label087BDC,
    Label087BE4,
    Label087BF0,
    Label087BF9,
    Label087C01,
    Label087C0E,
    Label087C17,
    Label087C1E,
    Label087C28,
    Label087C2F,
    Label087C39,
    Label087C43,
    Label087C4A,
    Label087C5C,
    Label087C67,
    Label087C72,
    Label087C84,
    Label087C93,
    Label087CA2,
    Label087CC2,
    Label087CE4,
    Label087D06,
    Label087D18,
    Label087D2A,
    Label087D2D,
    Label087D30,
    Label087D33,
    Label087D36,
    Label087D37,
    Label087D56,
    Label087D77,
    Label087D97,
    Label087D98,
    Label087D99,
    Label087DCA,
    Label087DF9,
    Label087DFA,
    Label087E1F,
    Label087E3A,
    Label087E56,
    Label087E67,
    Label087E82,
    Label087E8E,
    Label087EA1,
    Label087EB8,
    Label087ECC,
    Label087EE2,
    Label087EF7,
    Label087F12,
    Label087F2F,
    Label087F49,
    Label087F64,
    Label087F7F,
    Label087F9C,
}

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(Label087AC6)
    Character(Asha) "の�" End

Label(Label087ACB)
    "ハーンの�" End

Label(Label087AD1)
    "シャーの�" End

Label(Label087AD8)
    "キュロスの�" End

Label(Label087AE1)
    "カリフの�" End

Label(Label087AE7)
    "イシュタルの�" End

Label(Label087AF0)
    "バベルの�" End

Label(Label087AF8)
    "��の�" End

Label(Label087AFD)
    "ふつうの盾" End

Label(Label087B03)
    "炎の盾" End

Label(Label087B07)
    "��の盾" End

Label(Label087B0E)
    "�の盾" End

Label(Label087B13)
    "はがねの盾" End

Label(Label087B1A)
    "�の盾" End

Label(Label087B1F)
    "��の盾" End

Label(Label087B25)
    "��の盾" End

Label(Label087B2A)
    "��ちのよろい" End

Label(Label087B34)
    "�士のよろい" End

Label(Label087B3B)
    "�士のよろい" End

Label(Label087B43)
    "��のよろい" End

Label(Label087B4A)
    "��のよろい" End

Label(Label087B51)
    "デバッグのよろい" End

Label(Label087B5D)
    End

Label(Label087B5E)
    End

Label(Label087B5F)
    End

Label(Label087B60)
    "��" End

Label(Label087B65)
    "��の�" End

Label(Label087B6D)
    "��のランプ" End

Label(Label087B76)
    Character(Pepelogoo) "のタマゴ" End

Label(Label087B7E)
    "��の��" End

Label(Label087B85)
    "�のカギ" End

Label(Label087B8B)
    "��" End

Label(Label087B90)
    "バケツ" End

Label(Label087B95)
    "��りバケツ" End

Label(Label087B9D)
    "�ののべ�" End

Label(Label087BA6)
    Snippet(Leopard) "の�" End

Label(Label087BAB)
    Snippet(Witch) "の�" End

Label(Label087BB0)
    Snippet(DesertTurtle) "の�" End

Label(Label087BB5)
    Snippet(HornedOwl) "の�" End

Label(Label087BBA)
    Snippet(Swallow) "の�" End

Label(Label087BBF)
    "マップ" End

Label(Label087BC4)
    "��のメダル" End

Label(Label087BCC)
    "月のメダル" End

Label(Label087BD4)
    "太�のメダル" End

Label(Label087BDC)
    "�のメダル" End

Label(Label087BE4)
    "��のジュータン" End

Label(Label087BF0)
    "ビッグハート" End

Label(Label087BF9)
    "�のしずく" End

Label(Label087C01)
    "父からもらった�" NewLine
    Snippet(StrengthPlus1) End

Label(Label087C0E)
    Snippet(StrengthPlus1) Snippet(MagicalHit) "�\u{3000}〸２" End

Label(Label087C17)
    Snippet(StrengthPlus2) Snippet(MagicalHit) "なし" End

Label(Label087C1E)
    Snippet(StrengthPlus2) Snippet(MagicalHit) "�\u{3000}〸４" End

Label(Label087C28)
    Snippet(StrengthPlus4) Snippet(MagicalHit) "なし" End

Label(Label087C2F)
    Snippet(StrengthPlus4) Snippet(MagicalHit) "�\u{3000}〸８" End

Label(Label087C39)
    Snippet(StrengthPlus1) Snippet(MagicalHit) "�\u{3000}〸８" End

Label(Label087C43)
    Snippet(StrengthPlus8) Snippet(MagicalHit) "なし" End

Label(Label087C4A)
    "�ボタンで盾をかまえる" NewLine
    Snippet(DefensePlus0) End

Label(Label087C5C)
    Snippet(DefensePlus2) More NewLine
    Style(RedOnBlack) "炎" Style(WhiteOnBlack)
Label(Label087C67)
    "�の攻�をうけた�に"
Label(Label087C72)
    NewLine
    "マジカルディフェンスあり" End

Label(Label087C84)
    Snippet(DefensePlus2) More NewLine
    Style(YellowOnBlack) "�" Style(WhiteOnBlack) Seek(Label087C67)

Label(Label087C93)
    Snippet(DefensePlus2) More NewLine
    Style(LightBlueOnBlack) "�" Style(WhiteOnBlack) Seek(Label087C67)

Label(Label087CA2)
    Snippet(DefensePlus2) More NewLine
    Style(RedOnBlack) "炎" Style(YellowOnBlack) "�" Style(LightBlueOnBlack) "�" Style(WhiteOnBlack) "�いがいの�" Seek(Label087C72)

Label(Label087CC2)
    Snippet(DefensePlus1) More NewLine
    Style(RedOnBlack) "炎" Style(YellowOnBlack) "�" Style(LightBlueOnBlack) "�" Style(WhiteOnBlack) "�の攻�をうけた�" Seek(Label087C72)

Label(Label087CE4)
    Snippet(DefensePlus2) More NewLine
    Style(RedOnBlack) "炎" Style(YellowOnBlack) "�" Style(LightBlueOnBlack) "�" Style(WhiteOnBlack) "�の攻�をうけた�" Seek(Label087C72)

Label(Label087D06)
    Snippet(DefensePlus3) More NewLine
    "すべての攻�において" Seek(Label087C72)

Label(Label087D18)
    "母がつくってくれたよろい" NewLine
    Snippet(EndurancePlus3) End

Label(Label087D2A)
    Snippet(EndurancePlus5) End

Label(Label087D2D)
    Snippet(EndurancePlus7) End

Label(Label087D30)
    Snippet(EndurancePlus10) End

Label(Label087D33)
    Snippet(EndurancePlus15) End

Label(Label087D36)
    End

Label(Label087D37)
    "ペペレベルを" NewLine
    "１に�えますか？" Prompt(Condition0027) JumpIfNo(Label087D56) SetPepelogooLevel(0) End

Label(Label087D56)
    Clear
    "ペペレベルを" NewLine
    "２に�えますか？" Prompt(Condition0027) JumpIfNo(Label087D77) SetPepelogooLevel(1) End

Label(Label087D77)
    Clear
    "ペペレベルを" NewLine
    "３に�えますか？" Prompt(Condition0027) JumpIfNo(Label087D97) SetPepelogooLevel(2)
Label(Label087D97)
    End

Label(Label087D98)
    End

Label(Label087D99)
    "�力を�しだけ��" NewLine
    "することができる" More CheckCanGainHearts(69) Clear
    "�いますか？" Prompt(Condition0027) JumpIfNo(Label087DF9) UseItem End

Label(Label087DCA)
    "�力をいっぱいまで" NewLine
    "��してくれる�" More CheckCanGainHearts(21) Clear
    "�いますか？" Prompt(Condition0027) JumpIfNo(Label087DF9) UseItem
Label(Label087DF9)
    End

Label(Label087DFA)
    "ここは�の中でごじゃる。" NewLine
    SeekIfRand(32768, Label087E3A)
    SeekIfRand(49152, Label087E1F)
    "う〜ん\u{3000}いけずぅ。" End

Label(Label087E1F)
    "あんまり�にたよるのは" NewLine
    "よくないでごじゃるよ。" End

Label(Label087E3A)
    "�のそとで�わないと" NewLine
    "いみがないでごじゃる。" End

Label(Label087E56)
    "ナゾの�き�" NewLine
    Character(Pepelogoo) "のタマゴ。" End

Label(Label087E67)
    "�士としての��をためす" NewLine
    Location(TowerOfSilence) "へのパスポート" End

Label(Label087E82)
    "カギつきの�を�ける" End

Label(Label087E8E)
    "�力な��" NewLine
    "�をも��する" End

Label(Label087EA1)
    "カラッポのバケツ" NewLine
    "�が�れられそう‥‥" End

Label(Label087EB8)
    "�の�ったバケツ" NewLine
    "�かにかけると‥‥" End

Label(Label087ECC)
    "�のかたまり" NewLine
    "高い��で�れる" End

Label(Label087EE2)
    "ふしぎな石�" NewLine
    "正しい��へ‥‥" End

Label(Label087EF7)
    "ピラミッドのマップ" NewLine
    "じぶんのいちがわかる" End

Label(Label087F12)
    "ハンデラ火山へつづく�を" NewLine
    "�けることができる" End

Label(Label087F2F)
    "�の神�へつづく�を" NewLine
    "�けることができる" End

Label(Label087F49)
    "ピラミッドへつづく�を" NewLine
    "�けることができる" End

Label(Label087F64)
    "天空の�へつづく�を" NewLine
    "�けることができる" End

Label(Label087F7F)
    "空を�ぶことができる" NewLine
    "ふしぎなジュータン" End

Label(Label087F9C)
    End
    ];

pub const INDEXED: &[usize] = &[
    find_label(SCRIPTS, Label087AC6),
    find_label(SCRIPTS, Label087ACB),
    find_label(SCRIPTS, Label087AD1),
    find_label(SCRIPTS, Label087AD8),
    find_label(SCRIPTS, Label087AE1),
    find_label(SCRIPTS, Label087AE7),
    find_label(SCRIPTS, Label087AF0),
    find_label(SCRIPTS, Label087AF8),
    find_label(SCRIPTS, Label087AFD),
    find_label(SCRIPTS, Label087B03),
    find_label(SCRIPTS, Label087B07),
    find_label(SCRIPTS, Label087B0E),
    find_label(SCRIPTS, Label087B13),
    find_label(SCRIPTS, Label087B1A),
    find_label(SCRIPTS, Label087B1F),
    find_label(SCRIPTS, Label087B25),
    find_label(SCRIPTS, Label087B2A),
    find_label(SCRIPTS, Label087B34),
    find_label(SCRIPTS, Label087B3B),
    find_label(SCRIPTS, Label087B43),
    find_label(SCRIPTS, Label087B4A),
    find_label(SCRIPTS, Label087B51),
    find_label(SCRIPTS, Label087B51),
    find_label(SCRIPTS, Label087B51),
    find_label(SCRIPTS, Label087B5D),
    find_label(SCRIPTS, Label087B5E),
    find_label(SCRIPTS, Label087B5F),
    find_label(SCRIPTS, Label087B60),
    find_label(SCRIPTS, Label087B65),
    find_label(SCRIPTS, Label087B6D),
    find_label(SCRIPTS, Label087B76),
    find_label(SCRIPTS, Label087B7E),
    find_label(SCRIPTS, Label087B85),
    find_label(SCRIPTS, Label087B8B),
    find_label(SCRIPTS, Label087B90),
    find_label(SCRIPTS, Label087B95),
    find_label(SCRIPTS, Label087B9D),
    find_label(SCRIPTS, Label087BA6),
    find_label(SCRIPTS, Label087BAB),
    find_label(SCRIPTS, Label087BB0),
    find_label(SCRIPTS, Label087BB5),
    find_label(SCRIPTS, Label087BBA),
    find_label(SCRIPTS, Label087BBF),
    find_label(SCRIPTS, Label087BC4),
    find_label(SCRIPTS, Label087BCC),
    find_label(SCRIPTS, Label087BD4),
    find_label(SCRIPTS, Label087BDC),
    find_label(SCRIPTS, Label087BE4),
    find_label(SCRIPTS, Label087BF0),
    find_label(SCRIPTS, Label087BF0),
    find_label(SCRIPTS, Label087BF0),
    find_label(SCRIPTS, Label087BF0),
    find_label(SCRIPTS, Label087BF0),
    find_label(SCRIPTS, Label087BF0),
    find_label(SCRIPTS, Label087BF0),
    find_label(SCRIPTS, Label087BF0),
    find_label(SCRIPTS, Label087BF9),
    find_label(SCRIPTS, Label087C01),
    find_label(SCRIPTS, Label087C01),
    find_label(SCRIPTS, Label087C01),
    find_label(SCRIPTS, Label087C01),
    find_label(SCRIPTS, Label087C01),
    find_label(SCRIPTS, Label087C01),
    find_label(SCRIPTS, Label087C01),
    find_label(SCRIPTS, Label087C01),
    find_label(SCRIPTS, Label087C01),
    find_label(SCRIPTS, Label087C0E),
    find_label(SCRIPTS, Label087C17),
    find_label(SCRIPTS, Label087C1E),
    find_label(SCRIPTS, Label087C28),
    find_label(SCRIPTS, Label087C2F),
    find_label(SCRIPTS, Label087C39),
    find_label(SCRIPTS, Label087C43),
    find_label(SCRIPTS, Label087C4A),
    find_label(SCRIPTS, Label087C5C),
    find_label(SCRIPTS, Label087C84),
    find_label(SCRIPTS, Label087C93),
    find_label(SCRIPTS, Label087CA2),
    find_label(SCRIPTS, Label087CC2),
    find_label(SCRIPTS, Label087CE4),
    find_label(SCRIPTS, Label087D06),
    find_label(SCRIPTS, Label087D18),
    find_label(SCRIPTS, Label087D2A),
    find_label(SCRIPTS, Label087D2D),
    find_label(SCRIPTS, Label087D30),
    find_label(SCRIPTS, Label087D33),
    find_label(SCRIPTS, Label087D36),
    find_label(SCRIPTS, Label087D36),
    find_label(SCRIPTS, Label087D37),
    find_label(SCRIPTS, Label087D98),
    find_label(SCRIPTS, Label087D98),
    find_label(SCRIPTS, Label087D98),
    find_label(SCRIPTS, Label087D99),
    find_label(SCRIPTS, Label087DCA),
    find_label(SCRIPTS, Label087DFA),
    find_label(SCRIPTS, Label087E56),
    find_label(SCRIPTS, Label087E67),
    find_label(SCRIPTS, Label087E82),
    find_label(SCRIPTS, Label087E8E),
    find_label(SCRIPTS, Label087EA1),
    find_label(SCRIPTS, Label087EB8),
    find_label(SCRIPTS, Label087ECC),
    find_label(SCRIPTS, Label087EE2),
    find_label(SCRIPTS, Label087EE2),
    find_label(SCRIPTS, Label087EE2),
    find_label(SCRIPTS, Label087EE2),
    find_label(SCRIPTS, Label087EE2),
    find_label(SCRIPTS, Label087EF7),
    find_label(SCRIPTS, Label087F12),
    find_label(SCRIPTS, Label087F2F),
    find_label(SCRIPTS, Label087F49),
    find_label(SCRIPTS, Label087F64),
    find_label(SCRIPTS, Label087F7F),
    find_label(SCRIPTS, Label087F9C),
    find_label(SCRIPTS, Label087F9C),
    find_label(SCRIPTS, Label087F9C),
    find_label(SCRIPTS, Label087F9C),
    find_label(SCRIPTS, Label087F9C),
    find_label(SCRIPTS, Label087F9C),
    find_label(SCRIPTS, Label087F9C),
    find_label(SCRIPTS, Label087F9C),
    find_label(SCRIPTS, Label087F9C),
    find_label(SCRIPTS, Label087F9C),
    find_label(SCRIPTS, Label087F9C),
    find_label(SCRIPTS, Label087F9C),
    find_label(SCRIPTS, Label087F9C),
    find_label(SCRIPTS, Label087F9C),
    find_label(SCRIPTS, Label087F9C),
    find_label(SCRIPTS, Label087F9C),
    find_label(SCRIPTS, Label087F9C),
];
