"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.langFr = void 0;
var strings_1 = require("@ethersproject/strings");
var wordlist_1 = require("./wordlist");
var words = "[encoded data, 14341 characters]";
var wordlist = null;
var lookup = {};
function dropDiacritic(word) {
    wordlist_1.logger.checkNormalize();
    return (0, strings_1.toUtf8String)(Array.prototype.filter.call((0, strings_1.toUtf8Bytes)(word.normalize("NFD").toLowerCase()), function (c) {
        return ((c >= 65 && c <= 90) || (c >= 97 && c <= 123));
    }));
}
function expand(word) {
    var output = [];
    Array.prototype.forEach.call((0, strings_1.toUtf8Bytes)(word), function (c) {
        // Acute accent
        if (c === 47) {
            output.push(204);
            output.push(129);
            // Grave accent
        }
        else if (c === 45) {
            output.push(204);
            output.push(128);
        }
        else {
            output.push(c);
        }
    });
    return (0, strings_1.toUtf8String)(output);
}
function loadWords(lang) {
    if (wordlist != null) {
        return;
    }
    wordlist = words.replace(/([A-Z])/g, " $1").toLowerCase().substring(1).split(" ").map(function (w) { return expand(w); });
    wordlist.forEach(function (word, index) {
        lookup[dropDiacritic(word)] = index;
    });
    // Verify the computed list matches the official list
    /* istanbul ignore if */
    if (wordlist_1.Wordlist.check(lang) !== "0x51deb7ae009149dc61a6bd18a918eb7ac78d2775726c68e598b92d002519b045") {
        wordlist = null;
        throw new Error("BIP39 Wordlist for fr (French) FAILED");
    }
}
var LangFr = /** @class */ (function (_super) {
    __extends(LangFr, _super);
    function LangFr() {
        return _super.call(this, "fr") || this;
    }
    LangFr.prototype.getWord = function (index) {
        loadWords(this);
        return wordlist[index];
    };
    LangFr.prototype.getWordIndex = function (word) {
        loadWords(this);
        return lookup[dropDiacritic(word)];
    };
    return LangFr;
}(wordlist_1.Wordlist));
var langFr = new LangFr();
exports.langFr = langFr;
wordlist_1.Wordlist.register(langFr);
//# sourceMappingURL=lang-fr.js.map