'use strict'; Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const getLastChar = (str) => (str = str.replace(/'|"|\([^)]*\)/g, ""))[str.length - 1]; const ppMap = [ ["(은)는", ["은", "는"]], ["(이)가", ["이", "가"]], ["(을)를", ["을", "를"]], ["(과)와", ["과", "와"]], ["(으)로", ["으로", "로"]], ["(이)여", ["이어", "여"]], ["(이)", ["이", ""]], ["(아)야", ["아", "야"]] ]; const foreignCharsRecord = { 0: 1, 1: 8, 3: 1, 6: 1, 7: 8, 8: 8, b: 1, c: 1, g: 1, k: 1, l: 8, m: 1, n: 1, p: 1 }; const hasNoCoda = (char, ignore_ㄹ) => { let coda = char >= "가" && char <= "힣" ? (char.charCodeAt(0) - 16) % 28 : foreignCharsRecord[char]; return !coda || ignore_ㄹ && coda == 8; }; const resolve = (tokenString, testString) => { let foundPair = ppMap.find((pair) => tokenString.startsWith(pair[0])); return foundPair ? [foundPair[0], foundPair[1][+hasNoCoda(getLastChar(testString), foundPair[0] == "(으)로")]] : null; }; const ko = (template, ...words) => words.reduce((acc, word, index) => { let withoutPronunciation = "" + word === word; let succeeding = template[index + 1]; let tokenInfo = resolve(succeeding, withoutPronunciation ? word : word[1]); return acc + (withoutPronunciation ? word : word[0]) + (tokenInfo ? tokenInfo[1] + succeeding.slice(tokenInfo[0].length) : succeeding); }, template[0]); exports.ko = ko; exports.resolve = resolve; //# sourceMappingURL=index.cjs.map