#include <iostream>
#include <sstream>
#include "Errorseal.h"

/*
 * Coder: TheSkyWinds
 * Translator: MewTheNekomata
 *
 * Created: 12/16/24.
 */

// Mew's translations:
// A=; B=x C=* D=x E=& F=( G=x H=) I=[ J=x K=x L=| M=x N=/ O=? P=+ Q=x R=] S={ T=} U=. V=x W=- X=x Y=x Z=x

// Sky's translations:
// A=; B=@ C=* D=< E=& F=( G=" H=) I=[ J=x K=x L=| M=x N=/ O=? P=+ Q=x R=] S={ T=} U=. V=x W=- X=x Y=x Z=x

std::string translateInput(const std::string& input) {
    std::string translatedText{};

    for (std::size_t i = 0; i < input.length(); i++) {
        switch (input[i]) {
            case ';':
                translatedText.push_back('a');
                break;

            case '@':
                translatedText.push_back('b');
                break;

            case '*':
                translatedText.push_back('c');
                break;

            case '<':
                translatedText.push_back('d');
                break;

            case '&':
                translatedText.push_back('e');
                break;

            case '(':
                translatedText.push_back('f');
                break;

            case '"':
                translatedText.push_back('g');
                break;

            case ')':
                translatedText.push_back('h');
                break;

            case '[':
                translatedText.push_back('i');
                break;

            // MISSING J

            // MISSING K

            case '|':
                translatedText.push_back('l');
                break;

            // MISSING M

            case '/':
                translatedText.push_back('n');
                break;

            case '?':
                translatedText.push_back('o');
                break;

            case '+':
                translatedText.push_back('p');
                break;

            // MISSING Q

            case ']':
                translatedText.push_back('r');
                break;

            case '{':
                translatedText.push_back('s');
                break;

            case '}':
                translatedText.push_back('t');
                break;

            case '.':
                translatedText.push_back('u');
                break;

            // MISSING V

            case 'w':
                translatedText.push_back('w');
                break;

            // MISSING X

            // MISSING Y

            // MISSING Z

            case ' ':
                translatedText.push_back(' ');
                break;

            default:
                translatedText.push_back('?');
                break;
        }
    }
    return translatedText;
}

std::string usrInput() {

    std::string input{};

    // Ensures that whitespace is preserved.
    std::cout << "Enter the untranslated text: ";
    std::getline(std::cin, input);

    // Checks if there's any error & clears the buffer.
    error::cinErrorVerbose();

    return input;
}



int main() {
    std::string untranslatedText{};

    while (true) {
        untranslatedText = {usrInput()};

        if (untranslatedText == "exit") {
            break;
        }

        std::cout << "Translation: " << translateInput(untranslatedText) << std::endl;
    }
}