"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.JaaruGamaka = exports.Gamaka = exports.GamakaType = void 0;
exports.parseEmbelishment = parseEmbelishment;
const core_1 = require("../core");
var GamakaType;
(function (GamakaType) {
    GamakaType["Kampitham"] = "Kampitham";
    GamakaType["Nokku"] = "Nokku";
    GamakaType["Spuritham"] = "Spuritham";
    GamakaType["Prathyagatham"] = "Prathyagatham";
    GamakaType["Aahaatam_Raavi"] = "Raavi";
    GamakaType["Aahaatam_Kandippu"] = "Kandippu";
    GamakaType["Vaali"] = "Vaali";
    GamakaType["Odukkal"] = "Odukkal";
    GamakaType["Jaaru_Eetra"] = "EetraJaaru";
    GamakaType["Jaaru_Irakka"] = "IrakkaJaaru";
    GamakaType["Orikkai"] = "Orikkai";
})(GamakaType || (exports.GamakaType = GamakaType = {}));
class Gamaka {
    constructor(type) {
        this.type = type;
    }
    debugValue() {
        return { type: this.type };
    }
}
exports.Gamaka = Gamaka;
class JaaruGamaka extends Gamaka {
    constructor(ascending = true, startingNote = null) {
        super(ascending ? GamakaType.Jaaru_Eetra : GamakaType.Jaaru_Irakka);
        this.ascending = ascending;
        this.startingNote = startingNote;
    }
    debugValue() {
        const out = Object.assign(Object.assign({}, super.debugValue()), { ascending: this.ascending });
        if (this.startingNote)
            out["startingNote"] = this.startingNote.debugValue();
        return out;
    }
}
exports.JaaruGamaka = JaaruGamaka;
function parseEmbelishment(value) {
    value = value.substring(1);
    if (value == "") {
        return [new Gamaka(GamakaType.Kampitham), true];
    }
    else if (value == "^") {
        return [new Gamaka(GamakaType.Aahaatam_Raavi), true];
    }
    else if (value == "~") {
        return [new Gamaka(GamakaType.Vaali), true];
    }
    else if (value == "w" || value == "W") {
        return [new Gamaka(GamakaType.Nokku), true];
    }
    else if (value == "∴" || value == ":-") {
        return [new Gamaka(GamakaType.Spuritham), true];
    }
    else if (value == "∵" || value == "-:") {
        return [new Gamaka(GamakaType.Prathyagatham), true];
    }
    else if (value == "✓" || value == "./" || value == ".\\") {
        return [new Gamaka(GamakaType.Aahaatam_Kandippu), true];
    }
    else if (value.endsWith("/")) {
        value = value.substring(0, value.length - 1).trim();
        return [new JaaruGamaka(true, value.length > 0 ? new core_1.Note(value) : null), true];
    }
    else if (value.endsWith("\\")) {
        value = value.substring(0, value.length - 1);
        return [new JaaruGamaka(false, value.length > 0 ? new core_1.Note(value) : null), true];
    }
    else if (value == "x") {
        return [new Gamaka(GamakaType.Odukkal), true];
    }
    else if (value == "γ" || value == "Y") {
        return [new Gamaka(GamakaType.Orikkai), true];
    }
    return [null, false];
}
//# sourceMappingURL=gamakas.js.map