"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LangZh = void 0; const index_js_1 = require("../hash/index.js"); const index_js_2 = require("../utils/index.js"); const wordlist_js_1 = require("./wordlist.js"); const data = "}aE#4A=Yv&co#4N#6G=cJ&SM#66|/Z#4t&kn~46#4K~4q%b9=IR#7l,mB#7W_X2*dl}Uo~7s}Uf&Iw#9c&cw~6O&H6&wx&IG%v5=IQ~8a&Pv#47$PR&50%Ko&QM&3l#5f,D9#4L|/H&tQ;v0~6n]nN> 2), 128 + codes.indexOf(data[i * 3 + 1]), 128 + codes.indexOf(data[i * 3 + 2]), ]; if (locale === "zh_tw") { const common = s % 4; for (let i = common; i < 3; i++) { bytes[i] = codes.indexOf(deltaData[deltaOffset++]) + ((i == 0) ? 228 : 128); } } wordlist.push((0, index_js_2.toUtf8String)(new Uint8Array(bytes))); } // Verify the computed list matches the official list const checksum = (0, index_js_1.id)(wordlist.join("\n") + "\n"); /* c8 ignore start */ if (checksum !== Checks[locale]) { throw new Error(`BIP39 Wordlist for ${locale} (Chinese) FAILED`); } /* c8 ignore stop */ _wordlist[locale] = wordlist; return wordlist; } const wordlists = {}; /** * The [[link-bip39-zh_cn]] and [[link-bip39-zh_tw]] for * [mnemonic phrases](link-bip-39). * * @_docloc: api/wordlists */ class LangZh extends wordlist_js_1.Wordlist { /** * Creates a new instance of the Chinese language Wordlist for * the %%dialect%%, either ``"cn"`` or ``"tw"`` for simplified * or traditional, respectively. * * This should be unnecessary most of the time as the exported * [[langZhCn]] and [[langZhTw]] should suffice. * * @_ignore: */ constructor(dialect) { super("zh_" + dialect); } getWord(index) { const words = loadWords(this.locale); (0, index_js_2.assertArgument)(index >= 0 && index < words.length, `invalid word index: ${index}`, "index", index); return words[index]; } getWordIndex(word) { return loadWords(this.locale).indexOf(word); } split(phrase) { phrase = phrase.replace(/(?:\u3000| )+/g, ""); return phrase.split(""); } /** * Returns a singleton instance of a ``LangZh`` for %%dialect%%, * creating it if this is the first time being called. * * Use the %%dialect%% ``"cn"`` or ``"tw"`` for simplified or * traditional, respectively. */ static wordlist(dialect) { if (wordlists[dialect] == null) { wordlists[dialect] = new LangZh(dialect); } return wordlists[dialect]; } } exports.LangZh = LangZh; //# sourceMappingURL=lang-zh.js.map