@dev-pi2pie/word-counter 0.1.2 → 0.1.3-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -215,7 +215,7 @@ Skip details stay debug-gated and can still be suppressed with `--quiet-skips`.
215
215
 
216
216
  ## How It Works
217
217
 
218
- - The runtime inspects each character's Unicode script to infer its likely locale tag (e.g., `und-Latn`, `zh-Hani`, `ja`).
218
+ - The runtime inspects each character's Unicode script to infer its likely locale tag (e.g., `und-Latn`, `und-Hani`, `ja`).
219
219
  - Adjacent characters that share the same locale tag are grouped into a chunk.
220
220
  - Each chunk is counted with `Intl.Segmenter` at `granularity: "word"`, caching segmenters to avoid re-instantiation.
221
221
  - Per-locale counts are summed into an overall total and printed to stdout.
@@ -223,7 +223,7 @@ Skip details stay debug-gated and can still be suppressed with `--quiet-skips`.
223
223
  ## Locale vs Language Code
224
224
 
225
225
  - Output keeps the field name `locale` for compatibility.
226
- - In this project, locale values are BCP 47 tags and are often language/script focused (for example: `en`, `und-Latn`, `zh-Hani`) rather than region-specific tags (for example: `en-US`, `zh-TW`).
226
+ - In this project, locale values are BCP 47 tags and are often language/script focused (for example: `en`, `und-Latn`, `und-Hani`) rather than region-specific tags (for example: `en-US`, `zh-TW`).
227
227
  - Default detection prefers language/script tags to avoid incorrect region assumptions.
228
228
  - You can still provide region-specific locale tags through hint flags when needed.
229
229
 
@@ -563,10 +563,17 @@ Example JSON (trimmed):
563
563
  > [!Note]
564
564
  > Text-default symbols (e.g. ©) count as `symbols` unless explicitly emoji-presented (e.g. ©️ with VS16).
565
565
 
566
- ## Locale Tag Detection Notes (Migration)
566
+ ## Locale Tag Detection Notes
567
567
 
568
+ - Detection is regex/script based (Unicode script checks), not a statistical language-ID model.
568
569
  - Ambiguous Latin text uses `und-Latn` unless a Latin hint is provided.
569
- - Han-script fallback uses `zh-Hani` by default because regex script checks cannot natively distinguish `zh-Hans` vs `zh-Hant`.
570
+ - Han-script fallback uses `und-Hani` by default because regex script checks cannot natively distinguish `zh-Hans` vs `zh-Hant`.
571
+ - Current built-in Latin diacritic heuristics are intentionally limited:
572
+ - `de`: `äöüÄÖÜß`
573
+ - `es`: `ñÑ¿¡`
574
+ - `pt`: `ãõÃÕ`
575
+ - `fr`: `œŒæÆ`
576
+ - Latin text with other European diacritics may still remain in `und-Latn` unless a hint is provided.
570
577
  - Use `--mode chunk`/`--mode segments` or `--format json` to see the exact locale tag assigned to each chunk.
571
578
  - Regex/script-only detection cannot reliably identify English vs. other Latin-script languages; 100% certainty requires explicit metadata (document language tags, user-provided locale, headers) or a language-ID model.
572
579
  - Use `--latin-language <tag>` or `--latin-tag <tag>` for ambiguous Latin text.
@@ -325,7 +325,7 @@ function resolveMode(input, fallback = "chunk") {
325
325
  //#endregion
326
326
  //#region src/wc/locale-detect.ts
327
327
  const DEFAULT_LOCALE = "und-Latn";
328
- const DEFAULT_HAN_TAG = "zh-Hani";
328
+ const DEFAULT_HAN_TAG = "und-Hani";
329
329
  const regex = {
330
330
  hiragana: /\p{Script=Hiragana}/u,
331
331
  katakana: /\p{Script=Katakana}/u,
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["wordCounter","wordCounter"],"sources":["../../src/wc/segmenter.ts","../../src/utils/append-all.ts","../../src/wc/non-words.ts","../../src/wc/analyze.ts","../../src/wc/mode.ts","../../src/wc/locale-detect.ts","../../src/wc/segment.ts","../../src/wc/wc.ts","../../src/wc/index.ts","../../src/markdown/toml/arrays.ts","../../src/markdown/toml/keys.ts","../../src/markdown/toml/strings.ts","../../src/markdown/toml/values.ts","../../src/markdown/toml/parse-frontmatter.ts","../../src/markdown/parse-markdown.ts","../../src/markdown/section-count.ts","../../src/utils/show-singular-or-plural-word.ts","../../src/index.cjs.ts"],"sourcesContent":["const segmenterCache = new Map<string, Intl.Segmenter>();\nconst graphemeSegmenterCache = new Map<string, Intl.Segmenter>();\n\nexport function getSegmenter(locale: string): Intl.Segmenter {\n const cached = segmenterCache.get(locale);\n if (cached) {\n return cached;\n }\n const segmenter = new Intl.Segmenter(locale, { granularity: \"word\" });\n segmenterCache.set(locale, segmenter);\n return segmenter;\n}\n\nexport function getGraphemeSegmenter(locale: string): Intl.Segmenter {\n const cached = graphemeSegmenterCache.get(locale);\n if (cached) {\n return cached;\n }\n const segmenter = new Intl.Segmenter(locale, { granularity: \"grapheme\" });\n graphemeSegmenterCache.set(locale, segmenter);\n return segmenter;\n}\n\nfunction supportsSegmenter(): boolean {\n return typeof Intl !== \"undefined\" && typeof Intl.Segmenter === \"function\";\n}\n\nexport function countWordsForLocale(text: string, locale: string): number {\n const segmenter = getSegmenter(locale);\n let count = 0;\n for (const segment of segmenter.segment(text)) {\n if (segment.isWordLike) {\n count++;\n }\n }\n return count;\n}\n\nexport function countCharsForLocale(text: string, locale: string): number {\n if (!supportsSegmenter()) {\n return Array.from(text).length;\n }\n const segmenter = getGraphemeSegmenter(locale);\n let count = 0;\n for (const _segment of segmenter.segment(text)) {\n count++;\n }\n return count;\n}\n","export function appendAll<T>(target: T[], source: readonly T[]): void {\n for (const item of source) {\n target.push(item);\n }\n}\n","import type { NonWordCollection, WhitespaceCounts } from \"./types\";\nimport { appendAll } from \"../utils/append-all\";\n\nconst emojiRegex = /(?:\\p{Extended_Pictographic}|\\p{Emoji_Presentation})/u;\nconst emojiPresentationRegex = /\\p{Emoji_Presentation}/u;\nconst keycapEmojiRegex = /[0-9#*]\\uFE0F?\\u20E3/u;\nconst symbolRegex = /\\p{S}/u;\nconst punctuationRegex = /\\p{P}/u;\nconst whitespaceRegex = /\\s/u;\nconst newlineChars = new Set([\"\\n\", \"\\r\", \"\\u2028\", \"\\u2029\"]);\n\nexport function createNonWordCollection(): NonWordCollection {\n return {\n emoji: [],\n symbols: [],\n punctuation: [],\n counts: {\n emoji: 0,\n symbols: 0,\n punctuation: 0,\n },\n };\n}\n\nexport function addNonWord(\n collection: NonWordCollection,\n category: \"emoji\" | \"symbol\" | \"punctuation\",\n segment: string,\n): void {\n if (category === \"emoji\") {\n collection.emoji.push(segment);\n collection.counts.emoji += 1;\n return;\n }\n if (category === \"symbol\") {\n collection.symbols.push(segment);\n collection.counts.symbols += 1;\n return;\n }\n collection.punctuation.push(segment);\n collection.counts.punctuation += 1;\n}\n\nexport function addWhitespace(\n collection: NonWordCollection,\n segment: string,\n): number {\n let whitespace = collection.whitespace;\n let count = 0;\n for (const char of segment) {\n if (char === \" \") {\n whitespace = whitespace ?? createWhitespaceCounts();\n whitespace.spaces += 1;\n count += 1;\n continue;\n }\n if (char === \"\\t\") {\n whitespace = whitespace ?? createWhitespaceCounts();\n whitespace.tabs += 1;\n count += 1;\n continue;\n }\n if (newlineChars.has(char)) {\n whitespace = whitespace ?? createWhitespaceCounts();\n whitespace.newlines += 1;\n count += 1;\n continue;\n }\n if (whitespaceRegex.test(char)) {\n whitespace = whitespace ?? createWhitespaceCounts();\n whitespace.other += 1;\n count += 1;\n }\n }\n\n if (count > 0) {\n collection.whitespace = whitespace ?? createWhitespaceCounts();\n collection.counts.whitespace = (collection.counts.whitespace ?? 0) + count;\n }\n\n return count;\n}\n\nexport function classifyNonWordSegment(\n segment: string,\n): \"emoji\" | \"symbol\" | \"punctuation\" | null {\n const hasEmojiVariationSelector = segment.includes(\"\\uFE0F\");\n if (\n keycapEmojiRegex.test(segment) ||\n emojiPresentationRegex.test(segment) ||\n (hasEmojiVariationSelector && emojiRegex.test(segment))\n ) {\n return \"emoji\";\n }\n if (symbolRegex.test(segment)) {\n return \"symbol\";\n }\n if (punctuationRegex.test(segment)) {\n return \"punctuation\";\n }\n return null;\n}\n\nexport function mergeNonWordCollections(\n target: NonWordCollection,\n source: NonWordCollection,\n): NonWordCollection {\n if (source.counts.emoji > 0) {\n appendAll(target.emoji, source.emoji);\n target.counts.emoji += source.counts.emoji;\n }\n if (source.counts.symbols > 0) {\n appendAll(target.symbols, source.symbols);\n target.counts.symbols += source.counts.symbols;\n }\n if (source.counts.punctuation > 0) {\n appendAll(target.punctuation, source.punctuation);\n target.counts.punctuation += source.counts.punctuation;\n }\n if (source.counts.whitespace && source.counts.whitespace > 0 && source.whitespace) {\n const whitespace = target.whitespace ?? createWhitespaceCounts();\n whitespace.spaces += source.whitespace.spaces;\n whitespace.tabs += source.whitespace.tabs;\n whitespace.newlines += source.whitespace.newlines;\n whitespace.other += source.whitespace.other;\n target.whitespace = whitespace;\n target.counts.whitespace = (target.counts.whitespace ?? 0) + source.counts.whitespace;\n }\n return target;\n}\n\nfunction createWhitespaceCounts(): WhitespaceCounts {\n return { spaces: 0, tabs: 0, newlines: 0, other: 0 };\n}\n","import { countCharsForLocale, getSegmenter } from \"./segmenter\";\nimport {\n addNonWord,\n addWhitespace,\n classifyNonWordSegment,\n createNonWordCollection,\n mergeNonWordCollections,\n} from \"./non-words\";\nimport { appendAll } from \"../utils/append-all\";\nimport type {\n CharCollectorBreakdown,\n ChunkAnalysis,\n CollectorBreakdown,\n LocaleChunk,\n NonWordCollection,\n} from \"./types\";\n\ntype CharAnalysis = LocaleChunk & { chars: number; nonWords?: NonWordCollection };\ntype CharChunkAnalysis = CharAnalysis & { wordChars: number; nonWordChars: number };\n\nexport function analyzeChunk(\n chunk: LocaleChunk,\n collectNonWords?: boolean,\n includeWhitespace?: boolean,\n): ChunkAnalysis {\n const segmenter = getSegmenter(chunk.locale);\n const segments: string[] = [];\n const nonWords: NonWordCollection | null = collectNonWords\n ? createNonWordCollection()\n : null;\n for (const part of segmenter.segment(chunk.text)) {\n if (part.isWordLike) {\n segments.push(part.segment);\n } else if (collectNonWords && nonWords) {\n if (includeWhitespace) {\n addWhitespace(nonWords, part.segment);\n }\n const category = classifyNonWordSegment(part.segment);\n if (category) {\n addNonWord(nonWords, category, part.segment);\n }\n }\n }\n return {\n locale: chunk.locale,\n text: chunk.text,\n segments,\n words: segments.length,\n nonWords: nonWords ?? undefined,\n };\n}\n\nexport function analyzeCharChunk(\n chunk: LocaleChunk,\n collectNonWords?: boolean,\n includeWhitespace?: boolean,\n): CharChunkAnalysis {\n const segmenter = getSegmenter(chunk.locale);\n const nonWords: NonWordCollection | null = collectNonWords\n ? createNonWordCollection()\n : null;\n let chars = 0;\n let wordChars = 0;\n let nonWordChars = 0;\n\n for (const part of segmenter.segment(chunk.text)) {\n if (part.isWordLike) {\n const count = countCharsForLocale(part.segment, chunk.locale);\n chars += count;\n wordChars += count;\n continue;\n }\n\n if (collectNonWords && nonWords) {\n let whitespaceCount = 0;\n if (includeWhitespace) {\n whitespaceCount = addWhitespace(nonWords, part.segment);\n }\n const category = classifyNonWordSegment(part.segment);\n if (category) {\n addNonWord(nonWords, category, part.segment);\n }\n if (category || whitespaceCount > 0) {\n const count = countCharsForLocale(part.segment, chunk.locale);\n chars += count;\n nonWordChars += count;\n }\n }\n }\n\n return {\n locale: chunk.locale,\n text: chunk.text,\n chars,\n wordChars,\n nonWordChars,\n nonWords: nonWords ?? undefined,\n };\n}\n\nexport function aggregateCharsByLocale(\n chunks: CharChunkAnalysis[],\n): Array<CharCollectorBreakdown & { wordChars: number; nonWordChars: number }> {\n const order: string[] = [];\n const map = new Map<\n string,\n CharCollectorBreakdown & { wordChars: number; nonWordChars: number }\n >();\n\n for (const chunk of chunks) {\n const existing = map.get(chunk.locale);\n if (existing) {\n existing.chars += chunk.chars;\n existing.wordChars += chunk.wordChars;\n existing.nonWordChars += chunk.nonWordChars;\n if (chunk.nonWords) {\n if (!existing.nonWords) {\n existing.nonWords = createNonWordCollection();\n }\n mergeNonWordCollections(existing.nonWords, chunk.nonWords);\n }\n continue;\n }\n\n order.push(chunk.locale);\n map.set(chunk.locale, {\n locale: chunk.locale,\n chars: chunk.chars,\n wordChars: chunk.wordChars,\n nonWordChars: chunk.nonWordChars,\n nonWords: chunk.nonWords\n ? mergeNonWordCollections(createNonWordCollection(), chunk.nonWords)\n : undefined,\n });\n }\n\n return order.map((locale) => map.get(locale)!);\n}\n\nexport function aggregateByLocale(\n chunks: ChunkAnalysis[]\n): CollectorBreakdown[] {\n const order: string[] = [];\n const map = new Map<string, CollectorBreakdown>();\n\n for (const chunk of chunks) {\n const existing = map.get(chunk.locale);\n if (existing) {\n existing.words += chunk.words;\n appendAll(existing.segments, chunk.segments);\n continue;\n }\n\n order.push(chunk.locale);\n map.set(chunk.locale, {\n locale: chunk.locale,\n words: chunk.words,\n segments: [...chunk.segments],\n });\n }\n\n return order.map((locale) => map.get(locale)!);\n}\n","import type { WordCounterMode } from \"./types\";\n\nconst MODE_ALIASES: Record<string, WordCounterMode> = {\n chunk: \"chunk\",\n chunks: \"chunk\",\n segments: \"segments\",\n segment: \"segments\",\n seg: \"segments\",\n collector: \"collector\",\n collect: \"collector\",\n colle: \"collector\",\n char: \"char\",\n chars: \"char\",\n character: \"char\",\n characters: \"char\",\n \"char-collector\": \"char-collector\",\n};\n\nconst CHAR_MODE_ALIASES = new Set([\"char\", \"chars\", \"character\", \"characters\"]);\nconst COLLECTOR_MODE_ALIASES = new Set([\"collector\", \"collect\", \"colle\", \"col\"]);\n\nfunction collapseSeparators(value: string): string {\n return value.replace(/[-_\\s]+/g, \"\");\n}\n\nfunction isComposedCharCollectorFromTokens(value: string): boolean {\n const tokens = value\n .split(/[-_\\s]+/)\n .map((token) => token.trim())\n .filter((token) => token.length > 0);\n if (tokens.length < 2) {\n return false;\n }\n\n let hasCharAlias = false;\n let hasCollectorAlias = false;\n for (const token of tokens) {\n if (CHAR_MODE_ALIASES.has(token)) {\n hasCharAlias = true;\n continue;\n }\n if (COLLECTOR_MODE_ALIASES.has(token)) {\n hasCollectorAlias = true;\n continue;\n }\n return false;\n }\n\n return hasCharAlias && hasCollectorAlias;\n}\n\nfunction isComposedCharCollectorCompact(value: string): boolean {\n for (const charAlias of CHAR_MODE_ALIASES) {\n for (const collectorAlias of COLLECTOR_MODE_ALIASES) {\n if (value === `${charAlias}${collectorAlias}` || value === `${collectorAlias}${charAlias}`) {\n return true;\n }\n }\n }\n return false;\n}\n\nexport function normalizeMode(input?: string | null): WordCounterMode | null {\n if (!input) {\n return null;\n }\n const normalized = input.trim().toLowerCase();\n const direct = MODE_ALIASES[normalized];\n if (direct) {\n return direct;\n }\n\n if (isComposedCharCollectorFromTokens(normalized)) {\n return \"char-collector\";\n }\n\n const compact = collapseSeparators(normalized);\n if (isComposedCharCollectorCompact(compact)) {\n return \"char-collector\";\n }\n\n return MODE_ALIASES[compact] ?? null;\n}\n\nexport function resolveMode(\n input?: string | null,\n fallback: WordCounterMode = \"chunk\",\n): WordCounterMode {\n return normalizeMode(input) ?? fallback;\n}\n","export const DEFAULT_LOCALE = \"und-Latn\";\nexport const DEFAULT_HAN_TAG = \"zh-Hani\";\n\nexport interface LocaleDetectOptions {\n latinLanguageHint?: string;\n latinTagHint?: string;\n latinLocaleHint?: string;\n hanLanguageHint?: string;\n hanTagHint?: string;\n}\n\nconst regex = {\n hiragana: /\\p{Script=Hiragana}/u,\n katakana: /\\p{Script=Katakana}/u,\n hangul: /\\p{Script=Hangul}/u,\n han: /\\p{Script=Han}/u,\n latin: /\\p{Script=Latin}/u,\n arabic: /\\p{Script=Arabic}/u,\n cyrillic: /\\p{Script=Cyrillic}/u,\n devanagari: /\\p{Script=Devanagari}/u,\n thai: /\\p{Script=Thai}/u,\n};\n\nconst latinLocaleHints: Array<{ locale: string; regex: RegExp }> = [\n { locale: \"de\", regex: /[äöüÄÖÜß]/ },\n { locale: \"es\", regex: /[ñÑ¿¡]/ },\n { locale: \"pt\", regex: /[ãõÃÕ]/ },\n { locale: \"fr\", regex: /[œŒæÆ]/ },\n];\n\nconst latinLocales = new Set<string>([\n DEFAULT_LOCALE,\n ...latinLocaleHints.map((hint) => hint.locale),\n]);\n\nexport function isLatinLocale(locale: string): boolean {\n return latinLocales.has(locale);\n}\n\nfunction detectLatinLocale(char: string): string {\n for (const hint of latinLocaleHints) {\n if (hint.regex.test(char)) {\n return hint.locale;\n }\n }\n return DEFAULT_LOCALE;\n}\n\nfunction resolveLatinHint(options: LocaleDetectOptions): string | undefined {\n const latinTagHint = options.latinTagHint?.trim();\n if (latinTagHint) {\n return latinTagHint;\n }\n\n const latinLanguageHint = options.latinLanguageHint?.trim();\n if (latinLanguageHint) {\n return latinLanguageHint;\n }\n\n const latinLocaleHint = options.latinLocaleHint?.trim();\n if (latinLocaleHint) {\n return latinLocaleHint;\n }\n\n return undefined;\n}\n\nfunction resolveHanHint(options: LocaleDetectOptions): string | undefined {\n const hanTagHint = options.hanTagHint?.trim();\n if (hanTagHint) {\n return hanTagHint;\n }\n\n const hanLanguageHint = options.hanLanguageHint?.trim();\n if (hanLanguageHint) {\n return hanLanguageHint;\n }\n\n return undefined;\n}\n\nexport function detectLocaleForChar(\n char: string,\n previousLocale?: string | null,\n options: LocaleDetectOptions = {}\n): string | null {\n if (regex.hiragana.test(char) || regex.katakana.test(char)) {\n return \"ja\";\n }\n if (regex.hangul.test(char)) {\n return \"ko\";\n }\n if (regex.arabic.test(char)) {\n return \"ar\";\n }\n if (regex.cyrillic.test(char)) {\n return \"ru\";\n }\n if (regex.devanagari.test(char)) {\n return \"hi\";\n }\n if (regex.thai.test(char)) {\n return \"th\";\n }\n\n if (regex.han.test(char)) {\n if (previousLocale && previousLocale.startsWith(\"ja\")) {\n return previousLocale;\n }\n return resolveHanHint(options) ?? DEFAULT_HAN_TAG;\n }\n\n if (regex.latin.test(char)) {\n const hintedLocale = detectLatinLocale(char);\n if (hintedLocale !== DEFAULT_LOCALE) {\n return hintedLocale;\n }\n if (previousLocale && isLatinLocale(previousLocale) && previousLocale !== DEFAULT_LOCALE) {\n return previousLocale;\n }\n const latinHint = resolveLatinHint(options);\n if (latinHint) {\n return latinHint;\n }\n return DEFAULT_LOCALE;\n }\n\n return null;\n}\n","import {\n DEFAULT_LOCALE,\n detectLocaleForChar,\n isLatinLocale,\n type LocaleDetectOptions,\n} from \"./locale-detect\";\nimport type { LocaleChunk } from \"./types\";\n\nexport function segmentTextByLocale(\n text: string,\n options: LocaleDetectOptions = {}\n): LocaleChunk[] {\n const chunks: LocaleChunk[] = [];\n // Keep currentLocale as a non-null string to simplify type-narrowing.\n let currentLocale: string = DEFAULT_LOCALE;\n let buffer = \"\";\n let bufferHasScript = false;\n\n for (const char of text) {\n const detected = detectLocaleForChar(char, currentLocale, options);\n const targetLocale = detected ?? currentLocale;\n\n // If buffer is empty, this is the first character for a new chunk.\n if (buffer === \"\") {\n currentLocale = targetLocale;\n buffer = char;\n bufferHasScript = detected !== null;\n continue;\n }\n\n if (detected !== null && !bufferHasScript) {\n currentLocale = targetLocale;\n buffer += char;\n bufferHasScript = true;\n continue;\n }\n\n if (targetLocale !== currentLocale && detected !== null) {\n if (currentLocale === DEFAULT_LOCALE && isLatinLocale(targetLocale)) {\n currentLocale = targetLocale;\n buffer += char;\n bufferHasScript = true;\n continue;\n }\n // currentLocale is guaranteed to be a string here.\n chunks.push({ locale: currentLocale, text: buffer });\n currentLocale = targetLocale;\n buffer = char;\n bufferHasScript = true;\n continue;\n }\n\n buffer += char;\n if (detected !== null) {\n bufferHasScript = true;\n }\n }\n\n if (buffer.length > 0) {\n chunks.push({ locale: currentLocale, text: buffer });\n }\n\n return mergeAdjacentChunks(chunks);\n}\n\nfunction mergeAdjacentChunks(chunks: LocaleChunk[]): LocaleChunk[] {\n if (chunks.length === 0) {\n return chunks;\n }\n\n const merged: LocaleChunk[] = [];\n // We already returned for empty arrays above, so the first element is present.\n let last = chunks[0]!;\n\n for (let i = 1; i < chunks.length; i++) {\n const chunk = chunks[i]!;\n if (chunk.locale === last.locale) {\n last = { locale: last.locale, text: last.text + chunk.text };\n } else {\n merged.push(last);\n last = chunk;\n }\n }\n\n merged.push(last);\n return merged;\n}\n","import {\n analyzeCharChunk,\n analyzeChunk,\n aggregateByLocale,\n aggregateCharsByLocale,\n} from \"./analyze\";\nimport { resolveMode } from \"./mode\";\nimport { segmentTextByLocale } from \"./segment\";\nimport { countCharsForLocale, countWordsForLocale } from \"./segmenter\";\nimport { createNonWordCollection, mergeNonWordCollections } from \"./non-words\";\nimport type {\n CharBreakdown,\n CharCollectorBreakdown,\n ChunkBreakdown,\n ChunkWithSegments,\n NonWordCollection,\n WordCounterMode,\n WordCounterOptions,\n WordCounterResult,\n} from \"./types\";\n\nexport type {\n NonWordCollection,\n WordCounterMode,\n WordCounterOptions,\n WordCounterResult,\n WordCounterBreakdown,\n} from \"./types\";\n\nexport { countCharsForLocale, countWordsForLocale, segmentTextByLocale };\n\nexport function wordCounter(\n text: string,\n options: WordCounterOptions = {}\n): WordCounterResult {\n const mode: WordCounterMode = resolveMode(options.mode, \"chunk\");\n const collectNonWords = Boolean(options.nonWords);\n const includeWhitespace = Boolean(options.includeWhitespace);\n const chunks = segmentTextByLocale(text, {\n latinLanguageHint: options.latinLanguageHint,\n latinTagHint: options.latinTagHint,\n latinLocaleHint: options.latinLocaleHint,\n hanLanguageHint: options.hanLanguageHint,\n hanTagHint: options.hanTagHint,\n });\n\n if (mode === \"char\" || mode === \"char-collector\") {\n const analyzed = chunks.map((chunk) =>\n analyzeCharChunk(chunk, collectNonWords, includeWhitespace),\n );\n const total = analyzed.reduce((sum, chunk) => sum + chunk.chars, 0);\n const counts = collectNonWords\n ? {\n words: analyzed.reduce((sum, chunk) => sum + chunk.wordChars, 0),\n nonWords: analyzed.reduce((sum, chunk) => sum + chunk.nonWordChars, 0),\n total,\n }\n : undefined;\n\n if (mode === \"char\") {\n const items: CharBreakdown[] = analyzed.map((chunk) => ({\n locale: chunk.locale,\n text: chunk.text,\n chars: chunk.chars,\n nonWords: chunk.nonWords,\n }));\n return {\n total,\n counts,\n breakdown: {\n mode,\n items,\n },\n };\n }\n\n const aggregated = aggregateCharsByLocale(analyzed);\n const items: CharCollectorBreakdown[] = aggregated.map((chunk) => ({\n locale: chunk.locale,\n chars: chunk.chars,\n nonWords: chunk.nonWords,\n }));\n return {\n total,\n counts,\n breakdown: {\n mode,\n items,\n },\n };\n }\n\n const analyzed = chunks.map((chunk) =>\n analyzeChunk(chunk, collectNonWords, includeWhitespace),\n );\n const wordsTotal = analyzed.reduce((sum, chunk) => sum + chunk.words, 0);\n const nonWordsTotal = collectNonWords\n ? analyzed.reduce((sum, chunk) => {\n if (!chunk.nonWords) {\n return sum;\n }\n return sum + getNonWordTotal(chunk.nonWords);\n }, 0)\n : 0;\n const total = analyzed.reduce((sum, chunk) => {\n let chunkTotal = chunk.words;\n if (collectNonWords && chunk.nonWords) {\n chunkTotal += getNonWordTotal(chunk.nonWords);\n }\n return sum + chunkTotal;\n }, 0);\n\n const counts = collectNonWords ? { words: wordsTotal, nonWords: nonWordsTotal, total } : undefined;\n\n if (mode === \"segments\") {\n const items: ChunkWithSegments[] = analyzed.map((chunk) => ({\n locale: chunk.locale,\n text: chunk.text,\n words: chunk.words,\n segments: chunk.segments,\n nonWords: chunk.nonWords,\n }));\n return {\n total,\n counts,\n breakdown: {\n mode,\n items,\n },\n };\n }\n\n if (mode === \"collector\") {\n const items = aggregateByLocale(analyzed);\n const nonWords = collectNonWordsAggregate(analyzed, collectNonWords);\n return {\n total,\n counts,\n breakdown: {\n mode,\n items,\n nonWords,\n },\n };\n }\n\n const items: ChunkBreakdown[] = analyzed.map((chunk) => ({\n locale: chunk.locale,\n text: chunk.text,\n words: chunk.words,\n nonWords: chunk.nonWords,\n }));\n\n return {\n total,\n counts,\n breakdown: {\n mode,\n items,\n },\n };\n}\n\nfunction getNonWordTotal(nonWords: NonWordCollection): number {\n return (\n nonWords.counts.emoji +\n nonWords.counts.symbols +\n nonWords.counts.punctuation +\n (nonWords.counts.whitespace ?? 0)\n );\n}\n\n\nfunction collectNonWordsAggregate(\n analyzed: Array<{ nonWords?: NonWordCollection }>,\n enabled: boolean,\n): NonWordCollection | undefined {\n if (!enabled) {\n return undefined;\n }\n const collection = createNonWordCollection();\n for (const chunk of analyzed) {\n if (!chunk.nonWords) {\n continue;\n }\n mergeNonWordCollections(collection, chunk.nonWords);\n }\n return collection;\n}\n","import { wordCounter } from \"./wc\";\n\nexport default wordCounter;\nexport { countCharsForLocale, countWordsForLocale, segmentTextByLocale } from \"./wc\";\nexport type {\n NonWordCollection,\n WordCounterMode,\n WordCounterOptions,\n WordCounterResult,\n WordCounterBreakdown,\n} from \"./wc\";\n","export function ensureArrayContainer(\n result: Record<string, unknown>,\n key: string,\n): Record<string, unknown>[] {\n const existing = result[key];\n if (Array.isArray(existing)) {\n return existing as Record<string, unknown>[];\n }\n const list: Record<string, unknown>[] = [];\n result[key] = list;\n return list;\n}\n\nexport function flattenArrayTables(result: Record<string, unknown>): void {\n for (const [key, value] of Object.entries(result)) {\n if (!Array.isArray(value)) {\n continue;\n }\n const flattened = value\n .map((entry) =>\n Object.entries(entry)\n .map(([entryKey, entryValue]) => `${entryKey}=${entryValue}`)\n .join(\", \"),\n )\n .join(\" | \");\n result[key] = flattened;\n }\n}\n","function stripKeyQuotes(key: string): string {\n const trimmed = key.trim();\n if (\n (trimmed.startsWith(\"\\\"\") && trimmed.endsWith(\"\\\"\")) ||\n (trimmed.startsWith(\"'\") && trimmed.endsWith(\"'\"))\n ) {\n return trimmed.slice(1, -1);\n }\n return trimmed;\n}\n\nexport function normalizeKeyPath(key: string): string | null {\n const trimmed = key.trim();\n if (!trimmed) {\n return null;\n }\n\n if (\n (trimmed.startsWith(\"\\\"\") && trimmed.endsWith(\"\\\"\")) ||\n (trimmed.startsWith(\"'\") && trimmed.endsWith(\"'\"))\n ) {\n const unquoted = stripKeyQuotes(trimmed);\n return unquoted ? unquoted : null;\n }\n\n const segments = trimmed.split(\".\").map((segment) => segment.trim());\n if (segments.some((segment) => !segment)) {\n return null;\n }\n return segments.join(\".\");\n}\n","export function stripInlineComment(line: string): string {\n let inString: \"single\" | \"double\" | null = null;\n let escaped = false;\n\n for (let i = 0; i < line.length; i += 1) {\n const char = line[i] ?? \"\";\n\n if (inString) {\n if (escaped) {\n escaped = false;\n continue;\n }\n\n if (char === \"\\\\\" && inString === \"double\") {\n escaped = true;\n continue;\n }\n\n if (inString === \"double\" && char === \"\\\"\") {\n inString = null;\n continue;\n }\n\n if (inString === \"single\" && char === \"'\") {\n inString = null;\n continue;\n }\n\n continue;\n }\n\n if (char === \"\\\"\") {\n inString = \"double\";\n continue;\n }\n\n if (char === \"'\") {\n inString = \"single\";\n continue;\n }\n\n if (char === \"#\") {\n return line.slice(0, i).trimEnd();\n }\n }\n\n return line;\n}\n\nfunction unescapeBasic(input: string): string {\n return input\n .replace(/\\\\\\\\/g, \"\\\\\")\n .replace(/\\\\\"/g, \"\\\"\")\n .replace(/\\\\n/g, \"\\n\")\n .replace(/\\\\t/g, \"\\t\")\n .replace(/\\\\r/g, \"\\r\");\n}\n\nexport function parseStringLiteral(value: string): string | null {\n if (value.startsWith('\"\"\"') && value.endsWith('\"\"\"')) {\n const inner = value.slice(3, -3);\n return unescapeBasic(inner);\n }\n\n if (value.startsWith(\"'''\") && value.endsWith(\"'''\")) {\n return value.slice(3, -3);\n }\n\n if (value.startsWith(\"\\\"\") && value.endsWith(\"\\\"\")) {\n return unescapeBasic(value.slice(1, -1));\n }\n\n if (value.startsWith(\"'\") && value.endsWith(\"'\")) {\n return value.slice(1, -1);\n }\n\n return null;\n}\n","import { normalizeKeyPath } from \"./keys\";\nimport { parseStringLiteral } from \"./strings\";\nimport type { TomlValue } from \"./types\";\n\nfunction parsePrimitive(raw: string): string | number | boolean | null {\n const value = raw.trim();\n if (!value) {\n return null;\n }\n\n const stringLiteral = parseStringLiteral(value);\n if (stringLiteral !== null) {\n return stringLiteral;\n }\n\n if (value === \"true\") {\n return true;\n }\n\n if (value === \"false\") {\n return false;\n }\n\n if (/^[+-]?\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$/.test(value)) {\n return Number(value);\n }\n\n if (/^\\d{4}-\\d{2}-\\d{2}/.test(value)) {\n return value;\n }\n\n return value;\n}\n\nfunction parseArray(raw: string): Array<string | number | boolean> | null {\n const value = raw.trim();\n if (!value.startsWith(\"[\") || !value.endsWith(\"]\")) {\n return null;\n }\n\n const inner = value.slice(1, -1).trim();\n if (!inner) {\n return [];\n }\n\n const items: Array<string | number | boolean> = [];\n let current = \"\";\n let inString: \"single\" | \"double\" | null = null;\n let escaped = false;\n\n for (let i = 0; i < inner.length; i += 1) {\n const char = inner[i] ?? \"\";\n\n if (inString) {\n current += char;\n if (escaped) {\n escaped = false;\n continue;\n }\n\n if (char === \"\\\\\" && inString === \"double\") {\n escaped = true;\n continue;\n }\n\n if (inString === \"double\" && char === \"\\\"\") {\n inString = null;\n } else if (inString === \"single\" && char === \"'\") {\n inString = null;\n }\n continue;\n }\n\n if (char === \"\\\"\") {\n inString = \"double\";\n current += char;\n continue;\n }\n\n if (char === \"'\") {\n inString = \"single\";\n current += char;\n continue;\n }\n\n if (char === \",\") {\n const item = parsePrimitive(current);\n if (item === null) {\n return null;\n }\n items.push(item);\n current = \"\";\n continue;\n }\n\n current += char;\n }\n\n const finalItem = parsePrimitive(current);\n if (finalItem === null) {\n return null;\n }\n items.push(finalItem);\n\n return items;\n}\n\nfunction parseInlineTable(raw: string): Record<string, TomlValue> | null {\n const trimmed = raw.trim();\n if (!trimmed.startsWith(\"{\") || !trimmed.endsWith(\"}\")) {\n return null;\n }\n\n const inner = trimmed.slice(1, -1).trim();\n if (!inner) {\n return {};\n }\n\n const pairs: string[] = [];\n let current = \"\";\n let inString: \"single\" | \"double\" | null = null;\n let escaped = false;\n let bracketDepth = 0;\n let braceDepth = 0;\n\n for (let i = 0; i < inner.length; i += 1) {\n const char = inner[i] ?? \"\";\n\n if (inString) {\n current += char;\n if (escaped) {\n escaped = false;\n continue;\n }\n\n if (char === \"\\\\\" && inString === \"double\") {\n escaped = true;\n continue;\n }\n\n if (inString === \"double\" && char === \"\\\"\") {\n inString = null;\n } else if (inString === \"single\" && char === \"'\") {\n inString = null;\n }\n continue;\n }\n\n if (char === \"\\\"\") {\n inString = \"double\";\n current += char;\n continue;\n }\n\n if (char === \"'\") {\n inString = \"single\";\n current += char;\n continue;\n }\n\n if (char === \"[\") {\n bracketDepth += 1;\n current += char;\n continue;\n }\n\n if (char === \"]\") {\n if (bracketDepth > 0) {\n bracketDepth -= 1;\n }\n current += char;\n continue;\n }\n\n if (char === \"{\") {\n braceDepth += 1;\n current += char;\n continue;\n }\n\n if (char === \"}\") {\n if (braceDepth > 0) {\n braceDepth -= 1;\n }\n current += char;\n continue;\n }\n\n if (char === \",\" && bracketDepth === 0 && braceDepth === 0) {\n pairs.push(current);\n current = \"\";\n continue;\n }\n\n current += char;\n }\n\n if (current.trim()) {\n pairs.push(current);\n }\n\n const output: Record<string, TomlValue> = {};\n for (const pair of pairs) {\n const separatorIndex = pair.indexOf(\"=\");\n if (separatorIndex === -1) {\n return null;\n }\n const key = normalizeKeyPath(pair.slice(0, separatorIndex));\n if (!key) {\n return null;\n }\n const valueRaw = pair.slice(separatorIndex + 1).trim();\n if (!valueRaw) {\n return null;\n }\n if (valueRaw.startsWith(\"{\")) {\n return null;\n }\n const normalized = normalizeValue(valueRaw);\n if (normalized === null) {\n return null;\n }\n if (typeof normalized === \"object\" && !Array.isArray(normalized)) {\n return null;\n }\n output[key] = normalized;\n }\n\n return output;\n}\n\nexport function normalizeValue(value: string): TomlValue | null {\n if (!value) {\n return null;\n }\n\n const trimmed = value.trim();\n if (trimmed.startsWith(\"{\") && trimmed.endsWith(\"}\")) {\n return parseInlineTable(trimmed);\n }\n\n const array = parseArray(trimmed);\n if (array) {\n return array;\n }\n\n if (trimmed.startsWith(\"[\") && trimmed.endsWith(\"]\")) {\n return null;\n }\n\n return parsePrimitive(trimmed);\n}\n\nexport function toPlainText(value: unknown): string {\n if (value == null) {\n return \"\";\n }\n if (Array.isArray(value)) {\n return value.map((item) => String(item)).join(\", \");\n }\n return String(value);\n}\n","import { ensureArrayContainer, flattenArrayTables } from \"./arrays\";\nimport { normalizeKeyPath } from \"./keys\";\nimport { stripInlineComment } from \"./strings\";\nimport { normalizeValue, toPlainText } from \"./values\";\n\nexport function parseTomlFrontmatter(frontmatter: string): Record<string, unknown> | null {\n const result: Record<string, unknown> = {};\n const lines = frontmatter.split(\"\\n\");\n let tablePrefix = \"\";\n let tableTarget: Record<string, unknown> | null = null;\n let tablePrefixInList = false;\n\n for (let index = 0; index < lines.length; index += 1) {\n const rawLine = lines[index] ?? \"\";\n const trimmedLine = rawLine.trim();\n if (!trimmedLine || trimmedLine.startsWith(\"#\")) {\n continue;\n }\n\n if (trimmedLine.startsWith(\"[[\")) {\n const match = trimmedLine.match(/^\\[\\[([^\\]]+)]]$/);\n if (!match) {\n return null;\n }\n const normalizedTable = normalizeKeyPath(match[1] ?? \"\");\n if (!normalizedTable) {\n return null;\n }\n const list = ensureArrayContainer(result, normalizedTable);\n const newEntry: Record<string, unknown> = {};\n list.push(newEntry);\n tableTarget = newEntry;\n tablePrefix = normalizedTable;\n tablePrefixInList = true;\n continue;\n }\n\n const tableMatch = trimmedLine.match(/^\\[([^\\]]+)]$/);\n if (tableMatch) {\n const normalizedTable = normalizeKeyPath(tableMatch[1] ?? \"\");\n if (!normalizedTable) {\n return null;\n }\n tablePrefix = normalizedTable;\n tablePrefixInList = false;\n tableTarget = null;\n continue;\n }\n\n const lineForParsing = /(\"\"\"|''')/.test(rawLine) ? rawLine : stripInlineComment(rawLine);\n const separatorIndex = lineForParsing.indexOf(\"=\");\n if (separatorIndex === -1) {\n return null;\n }\n\n const keyRaw = lineForParsing.slice(0, separatorIndex);\n const key = normalizeKeyPath(keyRaw);\n let valueRaw = lineForParsing.slice(separatorIndex + 1).trim();\n if (!key) {\n return null;\n }\n\n const tripleDelimiter = valueRaw.startsWith('\"\"\"') ? '\"\"\"' : valueRaw.startsWith(\"'''\") ? \"'''\" : null;\n if (tripleDelimiter) {\n const closingIndex = valueRaw.indexOf(tripleDelimiter, tripleDelimiter.length);\n if (closingIndex !== -1) {\n const after = valueRaw.slice(closingIndex + tripleDelimiter.length);\n const strippedAfter = stripInlineComment(after);\n valueRaw = `${valueRaw.slice(0, closingIndex + tripleDelimiter.length)}${strippedAfter}`;\n } else {\n const delimiter = tripleDelimiter;\n let combined = valueRaw;\n let closed = false;\n while (index + 1 < lines.length) {\n index += 1;\n const nextLine = lines[index] ?? \"\";\n combined += `\\n${nextLine}`;\n if (new RegExp(`${delimiter}\\\\s*$`).test(nextLine)) {\n closed = true;\n break;\n }\n }\n if (!closed) {\n return null;\n }\n valueRaw = combined;\n }\n }\n\n const normalized = normalizeValue(valueRaw);\n if (normalized === null) {\n return null;\n }\n\n const fullKey = tablePrefix ? `${tablePrefix}.${key}` : key;\n if (typeof normalized === \"object\" && !Array.isArray(normalized)) {\n for (const [inlineKey, inlineValue] of Object.entries(normalized)) {\n const entryKey = tablePrefixInList ? `${key}.${inlineKey}` : `${fullKey}.${inlineKey}`;\n if (tablePrefixInList && tableTarget) {\n tableTarget[entryKey] = toPlainText(inlineValue);\n } else {\n result[entryKey] = toPlainText(inlineValue);\n }\n }\n continue;\n }\n\n if (tablePrefixInList && tableTarget) {\n tableTarget[key] = toPlainText(normalized);\n continue;\n }\n\n result[fullKey] = toPlainText(normalized);\n }\n\n flattenArrayTables(result);\n\n return result;\n}\n","import { parseDocument } from \"yaml\";\nimport { parseTomlFrontmatter } from \"./toml-simple\";\nimport type { FrontmatterType, ParsedMarkdown } from \"./types\";\n\nconst FENCE_TO_TYPE: Record<string, FrontmatterType> = {\n \"---\": \"yaml\",\n \"+++\": \"toml\",\n \";;;\": \"json\",\n};\n\nfunction normalizeNewlines(input: string): string {\n return input.replace(/\\r\\n/g, \"\\n\");\n}\n\nfunction stripBom(line: string): string {\n return line.startsWith(\"\\uFEFF\") ? line.slice(1) : line;\n}\n\nfunction getFenceType(line: string): FrontmatterType | null {\n const match = line.match(/^[\\t ]*(---|\\+\\+\\+|;;;)[\\t ]*$/);\n if (!match) {\n return null;\n }\n return FENCE_TO_TYPE[match[1] ?? \"\"] ?? null;\n}\n\nfunction parseFrontmatter(frontmatter: string, type: FrontmatterType | null): Record<string, unknown> | null {\n if (!type) {\n return null;\n }\n\n if (type === \"json\") {\n try {\n return JSON.parse(frontmatter) as Record<string, unknown>;\n } catch {\n return null;\n }\n }\n\n if (type === \"yaml\") {\n const doc = parseDocument(frontmatter, { prettyErrors: false });\n if (doc.errors.length > 0) {\n return null;\n }\n const data = doc.toJSON();\n if (!data || typeof data !== \"object\" || Array.isArray(data)) {\n return null;\n }\n return data as Record<string, unknown>;\n }\n\n if (type === \"toml\") {\n return parseTomlFrontmatter(frontmatter);\n }\n\n return null;\n}\n\nfunction extractJsonBlock(text: string, startIndex: number): { jsonText: string; endIndex: number } | null {\n let depth = 0;\n let inString = false;\n let escaped = false;\n\n for (let i = startIndex; i < text.length; i += 1) {\n const char = text[i] ?? \"\";\n\n if (inString) {\n if (escaped) {\n escaped = false;\n continue;\n }\n\n if (char === \"\\\\\") {\n escaped = true;\n continue;\n }\n\n if (char === \"\\\"\") {\n inString = false;\n }\n\n continue;\n }\n\n if (char === \"\\\"\") {\n inString = true;\n continue;\n }\n\n if (char === \"{\") {\n depth += 1;\n continue;\n }\n\n if (char === \"}\") {\n depth -= 1;\n if (depth === 0) {\n const jsonText = text.slice(startIndex, i + 1);\n return { jsonText, endIndex: i };\n }\n }\n }\n\n return null;\n}\n\nexport function parseMarkdown(input: string): ParsedMarkdown {\n const normalized = normalizeNewlines(input);\n const lines = normalized.split(\"\\n\");\n if (lines.length === 0) {\n return { frontmatter: null, content: normalized, data: null, frontmatterType: null };\n }\n\n lines[0] = stripBom(lines[0] ?? \"\");\n const normalizedWithoutBom = lines.join(\"\\n\");\n\n const openingType = getFenceType(lines[0] ?? \"\");\n if (!openingType) {\n const leadingWhitespace = normalizedWithoutBom.match(/^[\\t \\n]*/)?.[0] ?? \"\";\n const jsonStart = leadingWhitespace.length;\n if (normalizedWithoutBom[jsonStart] !== \"{\") {\n return { frontmatter: null, content: normalizedWithoutBom, data: null, frontmatterType: null };\n }\n\n const jsonBlock = extractJsonBlock(normalizedWithoutBom, jsonStart);\n if (!jsonBlock) {\n return { frontmatter: null, content: normalizedWithoutBom, data: null, frontmatterType: null };\n }\n\n const frontmatter = jsonBlock.jsonText;\n let content = normalizedWithoutBom.slice(jsonBlock.endIndex + 1);\n if (content.startsWith(\"\\n\")) {\n content = content.slice(1);\n }\n const data = parseFrontmatter(frontmatter, \"json\");\n if (!data) {\n return { frontmatter: null, content: normalizedWithoutBom, data: null, frontmatterType: null };\n }\n\n return {\n frontmatter,\n content,\n data,\n frontmatterType: \"json\",\n };\n }\n\n let closingIndex = -1;\n for (let i = 1; i < lines.length; i += 1) {\n if (getFenceType(lines[i] ?? \"\") === openingType) {\n closingIndex = i;\n break;\n }\n }\n\n if (closingIndex === -1) {\n return { frontmatter: null, content: normalizedWithoutBom, data: null, frontmatterType: null };\n }\n\n const frontmatter = lines.slice(1, closingIndex).join(\"\\n\");\n const content = lines.slice(closingIndex + 1).join(\"\\n\");\n const data = parseFrontmatter(frontmatter, openingType);\n\n return {\n frontmatter,\n content,\n data,\n frontmatterType: openingType,\n };\n}\n","import type { WordCounterMode, WordCounterOptions, WordCounterResult } from \"../wc/types\";\nimport wordCounter from \"../wc\";\nimport { parseMarkdown } from \"./parse-markdown\";\nimport type { SectionMode, SectionedResult } from \"./types\";\n\nfunction normalizeText(value: unknown): string {\n if (value == null) {\n return \"\";\n }\n if (typeof value === \"string\") {\n return value;\n }\n if (typeof value === \"number\" || typeof value === \"boolean\") {\n return String(value);\n }\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n}\n\nfunction buildPerKeyItems(\n data: Record<string, unknown> | null,\n mode: WordCounterMode,\n options: WordCounterOptions,\n): Array<{ name: string; source: \"frontmatter\"; result: WordCounterResult }> {\n if (!data || typeof data !== \"object\" || Array.isArray(data)) {\n return [];\n }\n\n return Object.entries(data).map(([key, value]) => {\n const valueText = normalizeText(value);\n const text = valueText ? `${key}: ${valueText}` : key;\n return {\n name: key,\n source: \"frontmatter\",\n result: wordCounter(text, options),\n };\n });\n}\n\nfunction buildSingleItem(\n name: string,\n text: string,\n mode: WordCounterMode,\n options: WordCounterOptions,\n source: \"frontmatter\" | \"content\",\n) {\n return [{ name, source, result: wordCounter(text, options) }];\n}\n\nfunction sumTotals(items: Array<{ result: WordCounterResult }>): number {\n return items.reduce((sum, item) => sum + item.result.total, 0);\n}\n\nexport function countSections(\n input: string,\n section: SectionMode,\n options: WordCounterOptions = {},\n): SectionedResult {\n const mode: WordCounterMode = options.mode ?? \"chunk\";\n if (section === \"all\") {\n const result = wordCounter(input, options);\n return {\n section,\n total: result.total,\n frontmatterType: null,\n items: [{ name: \"all\", source: \"content\", result }],\n };\n }\n\n const parsed = parseMarkdown(input);\n const frontmatterText = parsed.frontmatter ?? \"\";\n const contentText = parsed.content ?? \"\";\n\n let items: Array<{ name: string; source: \"frontmatter\" | \"content\"; result: WordCounterResult }> = [];\n\n if (section === \"frontmatter\") {\n items = buildSingleItem(\"frontmatter\", frontmatterText, mode, options, \"frontmatter\");\n } else if (section === \"content\") {\n items = buildSingleItem(\"content\", contentText, mode, options, \"content\");\n } else if (section === \"split\") {\n items = [\n ...buildSingleItem(\"frontmatter\", frontmatterText, mode, options, \"frontmatter\"),\n ...buildSingleItem(\"content\", contentText, mode, options, \"content\"),\n ];\n } else if (section === \"per-key\") {\n items = buildPerKeyItems(parsed.data, mode, options);\n } else if (section === \"split-per-key\") {\n items = [\n ...buildPerKeyItems(parsed.data, mode, options),\n ...buildSingleItem(\"content\", contentText, mode, options, \"content\"),\n ];\n }\n\n return {\n section,\n total: sumTotals(items),\n frontmatterType: parsed.frontmatterType,\n items,\n };\n}\n","export function showSingularOrPluralWord(count: number, word: string): string {\n return `${count} ${word}${count === 1 ? \"\" : \"s\"}`;\n}\n","import wordCounter, {\n countCharsForLocale,\n countWordsForLocale,\n segmentTextByLocale,\n} from \"./wc\";\nimport { parseMarkdown, countSections } from \"./markdown\";\nimport { showSingularOrPluralWord } from \"./utils\";\n\nconst cjsExports = Object.assign(wordCounter, {\n default: wordCounter,\n wordCounter,\n countCharsForLocale,\n countWordsForLocale,\n segmentTextByLocale,\n parseMarkdown,\n countSections,\n showSingularOrPluralWord,\n});\n\nexport = cjsExports;\n"],"mappings":";;;AAA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"version":3,"file":"index.cjs","names":["wordCounter","wordCounter"],"sources":["../../src/wc/segmenter.ts","../../src/utils/append-all.ts","../../src/wc/non-words.ts","../../src/wc/analyze.ts","../../src/wc/mode.ts","../../src/wc/locale-detect.ts","../../src/wc/segment.ts","../../src/wc/wc.ts","../../src/wc/index.ts","../../src/markdown/toml/arrays.ts","../../src/markdown/toml/keys.ts","../../src/markdown/toml/strings.ts","../../src/markdown/toml/values.ts","../../src/markdown/toml/parse-frontmatter.ts","../../src/markdown/parse-markdown.ts","../../src/markdown/section-count.ts","../../src/utils/show-singular-or-plural-word.ts","../../src/index.cjs.ts"],"sourcesContent":["const segmenterCache = new Map<string, Intl.Segmenter>();\nconst graphemeSegmenterCache = new Map<string, Intl.Segmenter>();\n\nexport function getSegmenter(locale: string): Intl.Segmenter {\n const cached = segmenterCache.get(locale);\n if (cached) {\n return cached;\n }\n const segmenter = new Intl.Segmenter(locale, { granularity: \"word\" });\n segmenterCache.set(locale, segmenter);\n return segmenter;\n}\n\nexport function getGraphemeSegmenter(locale: string): Intl.Segmenter {\n const cached = graphemeSegmenterCache.get(locale);\n if (cached) {\n return cached;\n }\n const segmenter = new Intl.Segmenter(locale, { granularity: \"grapheme\" });\n graphemeSegmenterCache.set(locale, segmenter);\n return segmenter;\n}\n\nfunction supportsSegmenter(): boolean {\n return typeof Intl !== \"undefined\" && typeof Intl.Segmenter === \"function\";\n}\n\nexport function countWordsForLocale(text: string, locale: string): number {\n const segmenter = getSegmenter(locale);\n let count = 0;\n for (const segment of segmenter.segment(text)) {\n if (segment.isWordLike) {\n count++;\n }\n }\n return count;\n}\n\nexport function countCharsForLocale(text: string, locale: string): number {\n if (!supportsSegmenter()) {\n return Array.from(text).length;\n }\n const segmenter = getGraphemeSegmenter(locale);\n let count = 0;\n for (const _segment of segmenter.segment(text)) {\n count++;\n }\n return count;\n}\n","export function appendAll<T>(target: T[], source: readonly T[]): void {\n for (const item of source) {\n target.push(item);\n }\n}\n","import type { NonWordCollection, WhitespaceCounts } from \"./types\";\nimport { appendAll } from \"../utils/append-all\";\n\nconst emojiRegex = /(?:\\p{Extended_Pictographic}|\\p{Emoji_Presentation})/u;\nconst emojiPresentationRegex = /\\p{Emoji_Presentation}/u;\nconst keycapEmojiRegex = /[0-9#*]\\uFE0F?\\u20E3/u;\nconst symbolRegex = /\\p{S}/u;\nconst punctuationRegex = /\\p{P}/u;\nconst whitespaceRegex = /\\s/u;\nconst newlineChars = new Set([\"\\n\", \"\\r\", \"\\u2028\", \"\\u2029\"]);\n\nexport function createNonWordCollection(): NonWordCollection {\n return {\n emoji: [],\n symbols: [],\n punctuation: [],\n counts: {\n emoji: 0,\n symbols: 0,\n punctuation: 0,\n },\n };\n}\n\nexport function addNonWord(\n collection: NonWordCollection,\n category: \"emoji\" | \"symbol\" | \"punctuation\",\n segment: string,\n): void {\n if (category === \"emoji\") {\n collection.emoji.push(segment);\n collection.counts.emoji += 1;\n return;\n }\n if (category === \"symbol\") {\n collection.symbols.push(segment);\n collection.counts.symbols += 1;\n return;\n }\n collection.punctuation.push(segment);\n collection.counts.punctuation += 1;\n}\n\nexport function addWhitespace(\n collection: NonWordCollection,\n segment: string,\n): number {\n let whitespace = collection.whitespace;\n let count = 0;\n for (const char of segment) {\n if (char === \" \") {\n whitespace = whitespace ?? createWhitespaceCounts();\n whitespace.spaces += 1;\n count += 1;\n continue;\n }\n if (char === \"\\t\") {\n whitespace = whitespace ?? createWhitespaceCounts();\n whitespace.tabs += 1;\n count += 1;\n continue;\n }\n if (newlineChars.has(char)) {\n whitespace = whitespace ?? createWhitespaceCounts();\n whitespace.newlines += 1;\n count += 1;\n continue;\n }\n if (whitespaceRegex.test(char)) {\n whitespace = whitespace ?? createWhitespaceCounts();\n whitespace.other += 1;\n count += 1;\n }\n }\n\n if (count > 0) {\n collection.whitespace = whitespace ?? createWhitespaceCounts();\n collection.counts.whitespace = (collection.counts.whitespace ?? 0) + count;\n }\n\n return count;\n}\n\nexport function classifyNonWordSegment(\n segment: string,\n): \"emoji\" | \"symbol\" | \"punctuation\" | null {\n const hasEmojiVariationSelector = segment.includes(\"\\uFE0F\");\n if (\n keycapEmojiRegex.test(segment) ||\n emojiPresentationRegex.test(segment) ||\n (hasEmojiVariationSelector && emojiRegex.test(segment))\n ) {\n return \"emoji\";\n }\n if (symbolRegex.test(segment)) {\n return \"symbol\";\n }\n if (punctuationRegex.test(segment)) {\n return \"punctuation\";\n }\n return null;\n}\n\nexport function mergeNonWordCollections(\n target: NonWordCollection,\n source: NonWordCollection,\n): NonWordCollection {\n if (source.counts.emoji > 0) {\n appendAll(target.emoji, source.emoji);\n target.counts.emoji += source.counts.emoji;\n }\n if (source.counts.symbols > 0) {\n appendAll(target.symbols, source.symbols);\n target.counts.symbols += source.counts.symbols;\n }\n if (source.counts.punctuation > 0) {\n appendAll(target.punctuation, source.punctuation);\n target.counts.punctuation += source.counts.punctuation;\n }\n if (source.counts.whitespace && source.counts.whitespace > 0 && source.whitespace) {\n const whitespace = target.whitespace ?? createWhitespaceCounts();\n whitespace.spaces += source.whitespace.spaces;\n whitespace.tabs += source.whitespace.tabs;\n whitespace.newlines += source.whitespace.newlines;\n whitespace.other += source.whitespace.other;\n target.whitespace = whitespace;\n target.counts.whitespace = (target.counts.whitespace ?? 0) + source.counts.whitespace;\n }\n return target;\n}\n\nfunction createWhitespaceCounts(): WhitespaceCounts {\n return { spaces: 0, tabs: 0, newlines: 0, other: 0 };\n}\n","import { countCharsForLocale, getSegmenter } from \"./segmenter\";\nimport {\n addNonWord,\n addWhitespace,\n classifyNonWordSegment,\n createNonWordCollection,\n mergeNonWordCollections,\n} from \"./non-words\";\nimport { appendAll } from \"../utils/append-all\";\nimport type {\n CharCollectorBreakdown,\n ChunkAnalysis,\n CollectorBreakdown,\n LocaleChunk,\n NonWordCollection,\n} from \"./types\";\n\ntype CharAnalysis = LocaleChunk & { chars: number; nonWords?: NonWordCollection };\ntype CharChunkAnalysis = CharAnalysis & { wordChars: number; nonWordChars: number };\n\nexport function analyzeChunk(\n chunk: LocaleChunk,\n collectNonWords?: boolean,\n includeWhitespace?: boolean,\n): ChunkAnalysis {\n const segmenter = getSegmenter(chunk.locale);\n const segments: string[] = [];\n const nonWords: NonWordCollection | null = collectNonWords\n ? createNonWordCollection()\n : null;\n for (const part of segmenter.segment(chunk.text)) {\n if (part.isWordLike) {\n segments.push(part.segment);\n } else if (collectNonWords && nonWords) {\n if (includeWhitespace) {\n addWhitespace(nonWords, part.segment);\n }\n const category = classifyNonWordSegment(part.segment);\n if (category) {\n addNonWord(nonWords, category, part.segment);\n }\n }\n }\n return {\n locale: chunk.locale,\n text: chunk.text,\n segments,\n words: segments.length,\n nonWords: nonWords ?? undefined,\n };\n}\n\nexport function analyzeCharChunk(\n chunk: LocaleChunk,\n collectNonWords?: boolean,\n includeWhitespace?: boolean,\n): CharChunkAnalysis {\n const segmenter = getSegmenter(chunk.locale);\n const nonWords: NonWordCollection | null = collectNonWords\n ? createNonWordCollection()\n : null;\n let chars = 0;\n let wordChars = 0;\n let nonWordChars = 0;\n\n for (const part of segmenter.segment(chunk.text)) {\n if (part.isWordLike) {\n const count = countCharsForLocale(part.segment, chunk.locale);\n chars += count;\n wordChars += count;\n continue;\n }\n\n if (collectNonWords && nonWords) {\n let whitespaceCount = 0;\n if (includeWhitespace) {\n whitespaceCount = addWhitespace(nonWords, part.segment);\n }\n const category = classifyNonWordSegment(part.segment);\n if (category) {\n addNonWord(nonWords, category, part.segment);\n }\n if (category || whitespaceCount > 0) {\n const count = countCharsForLocale(part.segment, chunk.locale);\n chars += count;\n nonWordChars += count;\n }\n }\n }\n\n return {\n locale: chunk.locale,\n text: chunk.text,\n chars,\n wordChars,\n nonWordChars,\n nonWords: nonWords ?? undefined,\n };\n}\n\nexport function aggregateCharsByLocale(\n chunks: CharChunkAnalysis[],\n): Array<CharCollectorBreakdown & { wordChars: number; nonWordChars: number }> {\n const order: string[] = [];\n const map = new Map<\n string,\n CharCollectorBreakdown & { wordChars: number; nonWordChars: number }\n >();\n\n for (const chunk of chunks) {\n const existing = map.get(chunk.locale);\n if (existing) {\n existing.chars += chunk.chars;\n existing.wordChars += chunk.wordChars;\n existing.nonWordChars += chunk.nonWordChars;\n if (chunk.nonWords) {\n if (!existing.nonWords) {\n existing.nonWords = createNonWordCollection();\n }\n mergeNonWordCollections(existing.nonWords, chunk.nonWords);\n }\n continue;\n }\n\n order.push(chunk.locale);\n map.set(chunk.locale, {\n locale: chunk.locale,\n chars: chunk.chars,\n wordChars: chunk.wordChars,\n nonWordChars: chunk.nonWordChars,\n nonWords: chunk.nonWords\n ? mergeNonWordCollections(createNonWordCollection(), chunk.nonWords)\n : undefined,\n });\n }\n\n return order.map((locale) => map.get(locale)!);\n}\n\nexport function aggregateByLocale(\n chunks: ChunkAnalysis[]\n): CollectorBreakdown[] {\n const order: string[] = [];\n const map = new Map<string, CollectorBreakdown>();\n\n for (const chunk of chunks) {\n const existing = map.get(chunk.locale);\n if (existing) {\n existing.words += chunk.words;\n appendAll(existing.segments, chunk.segments);\n continue;\n }\n\n order.push(chunk.locale);\n map.set(chunk.locale, {\n locale: chunk.locale,\n words: chunk.words,\n segments: [...chunk.segments],\n });\n }\n\n return order.map((locale) => map.get(locale)!);\n}\n","import type { WordCounterMode } from \"./types\";\n\nconst MODE_ALIASES: Record<string, WordCounterMode> = {\n chunk: \"chunk\",\n chunks: \"chunk\",\n segments: \"segments\",\n segment: \"segments\",\n seg: \"segments\",\n collector: \"collector\",\n collect: \"collector\",\n colle: \"collector\",\n char: \"char\",\n chars: \"char\",\n character: \"char\",\n characters: \"char\",\n \"char-collector\": \"char-collector\",\n};\n\nconst CHAR_MODE_ALIASES = new Set([\"char\", \"chars\", \"character\", \"characters\"]);\nconst COLLECTOR_MODE_ALIASES = new Set([\"collector\", \"collect\", \"colle\", \"col\"]);\n\nfunction collapseSeparators(value: string): string {\n return value.replace(/[-_\\s]+/g, \"\");\n}\n\nfunction isComposedCharCollectorFromTokens(value: string): boolean {\n const tokens = value\n .split(/[-_\\s]+/)\n .map((token) => token.trim())\n .filter((token) => token.length > 0);\n if (tokens.length < 2) {\n return false;\n }\n\n let hasCharAlias = false;\n let hasCollectorAlias = false;\n for (const token of tokens) {\n if (CHAR_MODE_ALIASES.has(token)) {\n hasCharAlias = true;\n continue;\n }\n if (COLLECTOR_MODE_ALIASES.has(token)) {\n hasCollectorAlias = true;\n continue;\n }\n return false;\n }\n\n return hasCharAlias && hasCollectorAlias;\n}\n\nfunction isComposedCharCollectorCompact(value: string): boolean {\n for (const charAlias of CHAR_MODE_ALIASES) {\n for (const collectorAlias of COLLECTOR_MODE_ALIASES) {\n if (value === `${charAlias}${collectorAlias}` || value === `${collectorAlias}${charAlias}`) {\n return true;\n }\n }\n }\n return false;\n}\n\nexport function normalizeMode(input?: string | null): WordCounterMode | null {\n if (!input) {\n return null;\n }\n const normalized = input.trim().toLowerCase();\n const direct = MODE_ALIASES[normalized];\n if (direct) {\n return direct;\n }\n\n if (isComposedCharCollectorFromTokens(normalized)) {\n return \"char-collector\";\n }\n\n const compact = collapseSeparators(normalized);\n if (isComposedCharCollectorCompact(compact)) {\n return \"char-collector\";\n }\n\n return MODE_ALIASES[compact] ?? null;\n}\n\nexport function resolveMode(\n input?: string | null,\n fallback: WordCounterMode = \"chunk\",\n): WordCounterMode {\n return normalizeMode(input) ?? fallback;\n}\n","export const DEFAULT_LOCALE = \"und-Latn\";\nexport const DEFAULT_HAN_TAG = \"und-Hani\";\n\nexport interface LocaleDetectOptions {\n latinLanguageHint?: string;\n latinTagHint?: string;\n latinLocaleHint?: string;\n hanLanguageHint?: string;\n hanTagHint?: string;\n}\n\nconst regex = {\n hiragana: /\\p{Script=Hiragana}/u,\n katakana: /\\p{Script=Katakana}/u,\n hangul: /\\p{Script=Hangul}/u,\n han: /\\p{Script=Han}/u,\n latin: /\\p{Script=Latin}/u,\n arabic: /\\p{Script=Arabic}/u,\n cyrillic: /\\p{Script=Cyrillic}/u,\n devanagari: /\\p{Script=Devanagari}/u,\n thai: /\\p{Script=Thai}/u,\n};\n\nconst latinLocaleHints: Array<{ locale: string; regex: RegExp }> = [\n { locale: \"de\", regex: /[äöüÄÖÜß]/ },\n { locale: \"es\", regex: /[ñÑ¿¡]/ },\n { locale: \"pt\", regex: /[ãõÃÕ]/ },\n { locale: \"fr\", regex: /[œŒæÆ]/ },\n];\n\nconst latinLocales = new Set<string>([\n DEFAULT_LOCALE,\n ...latinLocaleHints.map((hint) => hint.locale),\n]);\n\nexport function isLatinLocale(locale: string): boolean {\n return latinLocales.has(locale);\n}\n\nfunction detectLatinLocale(char: string): string {\n for (const hint of latinLocaleHints) {\n if (hint.regex.test(char)) {\n return hint.locale;\n }\n }\n return DEFAULT_LOCALE;\n}\n\nfunction resolveLatinHint(options: LocaleDetectOptions): string | undefined {\n const latinTagHint = options.latinTagHint?.trim();\n if (latinTagHint) {\n return latinTagHint;\n }\n\n const latinLanguageHint = options.latinLanguageHint?.trim();\n if (latinLanguageHint) {\n return latinLanguageHint;\n }\n\n const latinLocaleHint = options.latinLocaleHint?.trim();\n if (latinLocaleHint) {\n return latinLocaleHint;\n }\n\n return undefined;\n}\n\nfunction resolveHanHint(options: LocaleDetectOptions): string | undefined {\n const hanTagHint = options.hanTagHint?.trim();\n if (hanTagHint) {\n return hanTagHint;\n }\n\n const hanLanguageHint = options.hanLanguageHint?.trim();\n if (hanLanguageHint) {\n return hanLanguageHint;\n }\n\n return undefined;\n}\n\nexport function detectLocaleForChar(\n char: string,\n previousLocale?: string | null,\n options: LocaleDetectOptions = {}\n): string | null {\n if (regex.hiragana.test(char) || regex.katakana.test(char)) {\n return \"ja\";\n }\n if (regex.hangul.test(char)) {\n return \"ko\";\n }\n if (regex.arabic.test(char)) {\n return \"ar\";\n }\n if (regex.cyrillic.test(char)) {\n return \"ru\";\n }\n if (regex.devanagari.test(char)) {\n return \"hi\";\n }\n if (regex.thai.test(char)) {\n return \"th\";\n }\n\n if (regex.han.test(char)) {\n if (previousLocale && previousLocale.startsWith(\"ja\")) {\n return previousLocale;\n }\n return resolveHanHint(options) ?? DEFAULT_HAN_TAG;\n }\n\n if (regex.latin.test(char)) {\n const hintedLocale = detectLatinLocale(char);\n if (hintedLocale !== DEFAULT_LOCALE) {\n return hintedLocale;\n }\n if (previousLocale && isLatinLocale(previousLocale) && previousLocale !== DEFAULT_LOCALE) {\n return previousLocale;\n }\n const latinHint = resolveLatinHint(options);\n if (latinHint) {\n return latinHint;\n }\n return DEFAULT_LOCALE;\n }\n\n return null;\n}\n","import {\n DEFAULT_LOCALE,\n detectLocaleForChar,\n isLatinLocale,\n type LocaleDetectOptions,\n} from \"./locale-detect\";\nimport type { LocaleChunk } from \"./types\";\n\nexport function segmentTextByLocale(\n text: string,\n options: LocaleDetectOptions = {}\n): LocaleChunk[] {\n const chunks: LocaleChunk[] = [];\n // Keep currentLocale as a non-null string to simplify type-narrowing.\n let currentLocale: string = DEFAULT_LOCALE;\n let buffer = \"\";\n let bufferHasScript = false;\n\n for (const char of text) {\n const detected = detectLocaleForChar(char, currentLocale, options);\n const targetLocale = detected ?? currentLocale;\n\n // If buffer is empty, this is the first character for a new chunk.\n if (buffer === \"\") {\n currentLocale = targetLocale;\n buffer = char;\n bufferHasScript = detected !== null;\n continue;\n }\n\n if (detected !== null && !bufferHasScript) {\n currentLocale = targetLocale;\n buffer += char;\n bufferHasScript = true;\n continue;\n }\n\n if (targetLocale !== currentLocale && detected !== null) {\n if (currentLocale === DEFAULT_LOCALE && isLatinLocale(targetLocale)) {\n currentLocale = targetLocale;\n buffer += char;\n bufferHasScript = true;\n continue;\n }\n // currentLocale is guaranteed to be a string here.\n chunks.push({ locale: currentLocale, text: buffer });\n currentLocale = targetLocale;\n buffer = char;\n bufferHasScript = true;\n continue;\n }\n\n buffer += char;\n if (detected !== null) {\n bufferHasScript = true;\n }\n }\n\n if (buffer.length > 0) {\n chunks.push({ locale: currentLocale, text: buffer });\n }\n\n return mergeAdjacentChunks(chunks);\n}\n\nfunction mergeAdjacentChunks(chunks: LocaleChunk[]): LocaleChunk[] {\n if (chunks.length === 0) {\n return chunks;\n }\n\n const merged: LocaleChunk[] = [];\n // We already returned for empty arrays above, so the first element is present.\n let last = chunks[0]!;\n\n for (let i = 1; i < chunks.length; i++) {\n const chunk = chunks[i]!;\n if (chunk.locale === last.locale) {\n last = { locale: last.locale, text: last.text + chunk.text };\n } else {\n merged.push(last);\n last = chunk;\n }\n }\n\n merged.push(last);\n return merged;\n}\n","import {\n analyzeCharChunk,\n analyzeChunk,\n aggregateByLocale,\n aggregateCharsByLocale,\n} from \"./analyze\";\nimport { resolveMode } from \"./mode\";\nimport { segmentTextByLocale } from \"./segment\";\nimport { countCharsForLocale, countWordsForLocale } from \"./segmenter\";\nimport { createNonWordCollection, mergeNonWordCollections } from \"./non-words\";\nimport type {\n CharBreakdown,\n CharCollectorBreakdown,\n ChunkBreakdown,\n ChunkWithSegments,\n NonWordCollection,\n WordCounterMode,\n WordCounterOptions,\n WordCounterResult,\n} from \"./types\";\n\nexport type {\n NonWordCollection,\n WordCounterMode,\n WordCounterOptions,\n WordCounterResult,\n WordCounterBreakdown,\n} from \"./types\";\n\nexport { countCharsForLocale, countWordsForLocale, segmentTextByLocale };\n\nexport function wordCounter(\n text: string,\n options: WordCounterOptions = {}\n): WordCounterResult {\n const mode: WordCounterMode = resolveMode(options.mode, \"chunk\");\n const collectNonWords = Boolean(options.nonWords);\n const includeWhitespace = Boolean(options.includeWhitespace);\n const chunks = segmentTextByLocale(text, {\n latinLanguageHint: options.latinLanguageHint,\n latinTagHint: options.latinTagHint,\n latinLocaleHint: options.latinLocaleHint,\n hanLanguageHint: options.hanLanguageHint,\n hanTagHint: options.hanTagHint,\n });\n\n if (mode === \"char\" || mode === \"char-collector\") {\n const analyzed = chunks.map((chunk) =>\n analyzeCharChunk(chunk, collectNonWords, includeWhitespace),\n );\n const total = analyzed.reduce((sum, chunk) => sum + chunk.chars, 0);\n const counts = collectNonWords\n ? {\n words: analyzed.reduce((sum, chunk) => sum + chunk.wordChars, 0),\n nonWords: analyzed.reduce((sum, chunk) => sum + chunk.nonWordChars, 0),\n total,\n }\n : undefined;\n\n if (mode === \"char\") {\n const items: CharBreakdown[] = analyzed.map((chunk) => ({\n locale: chunk.locale,\n text: chunk.text,\n chars: chunk.chars,\n nonWords: chunk.nonWords,\n }));\n return {\n total,\n counts,\n breakdown: {\n mode,\n items,\n },\n };\n }\n\n const aggregated = aggregateCharsByLocale(analyzed);\n const items: CharCollectorBreakdown[] = aggregated.map((chunk) => ({\n locale: chunk.locale,\n chars: chunk.chars,\n nonWords: chunk.nonWords,\n }));\n return {\n total,\n counts,\n breakdown: {\n mode,\n items,\n },\n };\n }\n\n const analyzed = chunks.map((chunk) =>\n analyzeChunk(chunk, collectNonWords, includeWhitespace),\n );\n const wordsTotal = analyzed.reduce((sum, chunk) => sum + chunk.words, 0);\n const nonWordsTotal = collectNonWords\n ? analyzed.reduce((sum, chunk) => {\n if (!chunk.nonWords) {\n return sum;\n }\n return sum + getNonWordTotal(chunk.nonWords);\n }, 0)\n : 0;\n const total = analyzed.reduce((sum, chunk) => {\n let chunkTotal = chunk.words;\n if (collectNonWords && chunk.nonWords) {\n chunkTotal += getNonWordTotal(chunk.nonWords);\n }\n return sum + chunkTotal;\n }, 0);\n\n const counts = collectNonWords ? { words: wordsTotal, nonWords: nonWordsTotal, total } : undefined;\n\n if (mode === \"segments\") {\n const items: ChunkWithSegments[] = analyzed.map((chunk) => ({\n locale: chunk.locale,\n text: chunk.text,\n words: chunk.words,\n segments: chunk.segments,\n nonWords: chunk.nonWords,\n }));\n return {\n total,\n counts,\n breakdown: {\n mode,\n items,\n },\n };\n }\n\n if (mode === \"collector\") {\n const items = aggregateByLocale(analyzed);\n const nonWords = collectNonWordsAggregate(analyzed, collectNonWords);\n return {\n total,\n counts,\n breakdown: {\n mode,\n items,\n nonWords,\n },\n };\n }\n\n const items: ChunkBreakdown[] = analyzed.map((chunk) => ({\n locale: chunk.locale,\n text: chunk.text,\n words: chunk.words,\n nonWords: chunk.nonWords,\n }));\n\n return {\n total,\n counts,\n breakdown: {\n mode,\n items,\n },\n };\n}\n\nfunction getNonWordTotal(nonWords: NonWordCollection): number {\n return (\n nonWords.counts.emoji +\n nonWords.counts.symbols +\n nonWords.counts.punctuation +\n (nonWords.counts.whitespace ?? 0)\n );\n}\n\n\nfunction collectNonWordsAggregate(\n analyzed: Array<{ nonWords?: NonWordCollection }>,\n enabled: boolean,\n): NonWordCollection | undefined {\n if (!enabled) {\n return undefined;\n }\n const collection = createNonWordCollection();\n for (const chunk of analyzed) {\n if (!chunk.nonWords) {\n continue;\n }\n mergeNonWordCollections(collection, chunk.nonWords);\n }\n return collection;\n}\n","import { wordCounter } from \"./wc\";\n\nexport default wordCounter;\nexport { countCharsForLocale, countWordsForLocale, segmentTextByLocale } from \"./wc\";\nexport type {\n NonWordCollection,\n WordCounterMode,\n WordCounterOptions,\n WordCounterResult,\n WordCounterBreakdown,\n} from \"./wc\";\n","export function ensureArrayContainer(\n result: Record<string, unknown>,\n key: string,\n): Record<string, unknown>[] {\n const existing = result[key];\n if (Array.isArray(existing)) {\n return existing as Record<string, unknown>[];\n }\n const list: Record<string, unknown>[] = [];\n result[key] = list;\n return list;\n}\n\nexport function flattenArrayTables(result: Record<string, unknown>): void {\n for (const [key, value] of Object.entries(result)) {\n if (!Array.isArray(value)) {\n continue;\n }\n const flattened = value\n .map((entry) =>\n Object.entries(entry)\n .map(([entryKey, entryValue]) => `${entryKey}=${entryValue}`)\n .join(\", \"),\n )\n .join(\" | \");\n result[key] = flattened;\n }\n}\n","function stripKeyQuotes(key: string): string {\n const trimmed = key.trim();\n if (\n (trimmed.startsWith(\"\\\"\") && trimmed.endsWith(\"\\\"\")) ||\n (trimmed.startsWith(\"'\") && trimmed.endsWith(\"'\"))\n ) {\n return trimmed.slice(1, -1);\n }\n return trimmed;\n}\n\nexport function normalizeKeyPath(key: string): string | null {\n const trimmed = key.trim();\n if (!trimmed) {\n return null;\n }\n\n if (\n (trimmed.startsWith(\"\\\"\") && trimmed.endsWith(\"\\\"\")) ||\n (trimmed.startsWith(\"'\") && trimmed.endsWith(\"'\"))\n ) {\n const unquoted = stripKeyQuotes(trimmed);\n return unquoted ? unquoted : null;\n }\n\n const segments = trimmed.split(\".\").map((segment) => segment.trim());\n if (segments.some((segment) => !segment)) {\n return null;\n }\n return segments.join(\".\");\n}\n","export function stripInlineComment(line: string): string {\n let inString: \"single\" | \"double\" | null = null;\n let escaped = false;\n\n for (let i = 0; i < line.length; i += 1) {\n const char = line[i] ?? \"\";\n\n if (inString) {\n if (escaped) {\n escaped = false;\n continue;\n }\n\n if (char === \"\\\\\" && inString === \"double\") {\n escaped = true;\n continue;\n }\n\n if (inString === \"double\" && char === \"\\\"\") {\n inString = null;\n continue;\n }\n\n if (inString === \"single\" && char === \"'\") {\n inString = null;\n continue;\n }\n\n continue;\n }\n\n if (char === \"\\\"\") {\n inString = \"double\";\n continue;\n }\n\n if (char === \"'\") {\n inString = \"single\";\n continue;\n }\n\n if (char === \"#\") {\n return line.slice(0, i).trimEnd();\n }\n }\n\n return line;\n}\n\nfunction unescapeBasic(input: string): string {\n return input\n .replace(/\\\\\\\\/g, \"\\\\\")\n .replace(/\\\\\"/g, \"\\\"\")\n .replace(/\\\\n/g, \"\\n\")\n .replace(/\\\\t/g, \"\\t\")\n .replace(/\\\\r/g, \"\\r\");\n}\n\nexport function parseStringLiteral(value: string): string | null {\n if (value.startsWith('\"\"\"') && value.endsWith('\"\"\"')) {\n const inner = value.slice(3, -3);\n return unescapeBasic(inner);\n }\n\n if (value.startsWith(\"'''\") && value.endsWith(\"'''\")) {\n return value.slice(3, -3);\n }\n\n if (value.startsWith(\"\\\"\") && value.endsWith(\"\\\"\")) {\n return unescapeBasic(value.slice(1, -1));\n }\n\n if (value.startsWith(\"'\") && value.endsWith(\"'\")) {\n return value.slice(1, -1);\n }\n\n return null;\n}\n","import { normalizeKeyPath } from \"./keys\";\nimport { parseStringLiteral } from \"./strings\";\nimport type { TomlValue } from \"./types\";\n\nfunction parsePrimitive(raw: string): string | number | boolean | null {\n const value = raw.trim();\n if (!value) {\n return null;\n }\n\n const stringLiteral = parseStringLiteral(value);\n if (stringLiteral !== null) {\n return stringLiteral;\n }\n\n if (value === \"true\") {\n return true;\n }\n\n if (value === \"false\") {\n return false;\n }\n\n if (/^[+-]?\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$/.test(value)) {\n return Number(value);\n }\n\n if (/^\\d{4}-\\d{2}-\\d{2}/.test(value)) {\n return value;\n }\n\n return value;\n}\n\nfunction parseArray(raw: string): Array<string | number | boolean> | null {\n const value = raw.trim();\n if (!value.startsWith(\"[\") || !value.endsWith(\"]\")) {\n return null;\n }\n\n const inner = value.slice(1, -1).trim();\n if (!inner) {\n return [];\n }\n\n const items: Array<string | number | boolean> = [];\n let current = \"\";\n let inString: \"single\" | \"double\" | null = null;\n let escaped = false;\n\n for (let i = 0; i < inner.length; i += 1) {\n const char = inner[i] ?? \"\";\n\n if (inString) {\n current += char;\n if (escaped) {\n escaped = false;\n continue;\n }\n\n if (char === \"\\\\\" && inString === \"double\") {\n escaped = true;\n continue;\n }\n\n if (inString === \"double\" && char === \"\\\"\") {\n inString = null;\n } else if (inString === \"single\" && char === \"'\") {\n inString = null;\n }\n continue;\n }\n\n if (char === \"\\\"\") {\n inString = \"double\";\n current += char;\n continue;\n }\n\n if (char === \"'\") {\n inString = \"single\";\n current += char;\n continue;\n }\n\n if (char === \",\") {\n const item = parsePrimitive(current);\n if (item === null) {\n return null;\n }\n items.push(item);\n current = \"\";\n continue;\n }\n\n current += char;\n }\n\n const finalItem = parsePrimitive(current);\n if (finalItem === null) {\n return null;\n }\n items.push(finalItem);\n\n return items;\n}\n\nfunction parseInlineTable(raw: string): Record<string, TomlValue> | null {\n const trimmed = raw.trim();\n if (!trimmed.startsWith(\"{\") || !trimmed.endsWith(\"}\")) {\n return null;\n }\n\n const inner = trimmed.slice(1, -1).trim();\n if (!inner) {\n return {};\n }\n\n const pairs: string[] = [];\n let current = \"\";\n let inString: \"single\" | \"double\" | null = null;\n let escaped = false;\n let bracketDepth = 0;\n let braceDepth = 0;\n\n for (let i = 0; i < inner.length; i += 1) {\n const char = inner[i] ?? \"\";\n\n if (inString) {\n current += char;\n if (escaped) {\n escaped = false;\n continue;\n }\n\n if (char === \"\\\\\" && inString === \"double\") {\n escaped = true;\n continue;\n }\n\n if (inString === \"double\" && char === \"\\\"\") {\n inString = null;\n } else if (inString === \"single\" && char === \"'\") {\n inString = null;\n }\n continue;\n }\n\n if (char === \"\\\"\") {\n inString = \"double\";\n current += char;\n continue;\n }\n\n if (char === \"'\") {\n inString = \"single\";\n current += char;\n continue;\n }\n\n if (char === \"[\") {\n bracketDepth += 1;\n current += char;\n continue;\n }\n\n if (char === \"]\") {\n if (bracketDepth > 0) {\n bracketDepth -= 1;\n }\n current += char;\n continue;\n }\n\n if (char === \"{\") {\n braceDepth += 1;\n current += char;\n continue;\n }\n\n if (char === \"}\") {\n if (braceDepth > 0) {\n braceDepth -= 1;\n }\n current += char;\n continue;\n }\n\n if (char === \",\" && bracketDepth === 0 && braceDepth === 0) {\n pairs.push(current);\n current = \"\";\n continue;\n }\n\n current += char;\n }\n\n if (current.trim()) {\n pairs.push(current);\n }\n\n const output: Record<string, TomlValue> = {};\n for (const pair of pairs) {\n const separatorIndex = pair.indexOf(\"=\");\n if (separatorIndex === -1) {\n return null;\n }\n const key = normalizeKeyPath(pair.slice(0, separatorIndex));\n if (!key) {\n return null;\n }\n const valueRaw = pair.slice(separatorIndex + 1).trim();\n if (!valueRaw) {\n return null;\n }\n if (valueRaw.startsWith(\"{\")) {\n return null;\n }\n const normalized = normalizeValue(valueRaw);\n if (normalized === null) {\n return null;\n }\n if (typeof normalized === \"object\" && !Array.isArray(normalized)) {\n return null;\n }\n output[key] = normalized;\n }\n\n return output;\n}\n\nexport function normalizeValue(value: string): TomlValue | null {\n if (!value) {\n return null;\n }\n\n const trimmed = value.trim();\n if (trimmed.startsWith(\"{\") && trimmed.endsWith(\"}\")) {\n return parseInlineTable(trimmed);\n }\n\n const array = parseArray(trimmed);\n if (array) {\n return array;\n }\n\n if (trimmed.startsWith(\"[\") && trimmed.endsWith(\"]\")) {\n return null;\n }\n\n return parsePrimitive(trimmed);\n}\n\nexport function toPlainText(value: unknown): string {\n if (value == null) {\n return \"\";\n }\n if (Array.isArray(value)) {\n return value.map((item) => String(item)).join(\", \");\n }\n return String(value);\n}\n","import { ensureArrayContainer, flattenArrayTables } from \"./arrays\";\nimport { normalizeKeyPath } from \"./keys\";\nimport { stripInlineComment } from \"./strings\";\nimport { normalizeValue, toPlainText } from \"./values\";\n\nexport function parseTomlFrontmatter(frontmatter: string): Record<string, unknown> | null {\n const result: Record<string, unknown> = {};\n const lines = frontmatter.split(\"\\n\");\n let tablePrefix = \"\";\n let tableTarget: Record<string, unknown> | null = null;\n let tablePrefixInList = false;\n\n for (let index = 0; index < lines.length; index += 1) {\n const rawLine = lines[index] ?? \"\";\n const trimmedLine = rawLine.trim();\n if (!trimmedLine || trimmedLine.startsWith(\"#\")) {\n continue;\n }\n\n if (trimmedLine.startsWith(\"[[\")) {\n const match = trimmedLine.match(/^\\[\\[([^\\]]+)]]$/);\n if (!match) {\n return null;\n }\n const normalizedTable = normalizeKeyPath(match[1] ?? \"\");\n if (!normalizedTable) {\n return null;\n }\n const list = ensureArrayContainer(result, normalizedTable);\n const newEntry: Record<string, unknown> = {};\n list.push(newEntry);\n tableTarget = newEntry;\n tablePrefix = normalizedTable;\n tablePrefixInList = true;\n continue;\n }\n\n const tableMatch = trimmedLine.match(/^\\[([^\\]]+)]$/);\n if (tableMatch) {\n const normalizedTable = normalizeKeyPath(tableMatch[1] ?? \"\");\n if (!normalizedTable) {\n return null;\n }\n tablePrefix = normalizedTable;\n tablePrefixInList = false;\n tableTarget = null;\n continue;\n }\n\n const lineForParsing = /(\"\"\"|''')/.test(rawLine) ? rawLine : stripInlineComment(rawLine);\n const separatorIndex = lineForParsing.indexOf(\"=\");\n if (separatorIndex === -1) {\n return null;\n }\n\n const keyRaw = lineForParsing.slice(0, separatorIndex);\n const key = normalizeKeyPath(keyRaw);\n let valueRaw = lineForParsing.slice(separatorIndex + 1).trim();\n if (!key) {\n return null;\n }\n\n const tripleDelimiter = valueRaw.startsWith('\"\"\"') ? '\"\"\"' : valueRaw.startsWith(\"'''\") ? \"'''\" : null;\n if (tripleDelimiter) {\n const closingIndex = valueRaw.indexOf(tripleDelimiter, tripleDelimiter.length);\n if (closingIndex !== -1) {\n const after = valueRaw.slice(closingIndex + tripleDelimiter.length);\n const strippedAfter = stripInlineComment(after);\n valueRaw = `${valueRaw.slice(0, closingIndex + tripleDelimiter.length)}${strippedAfter}`;\n } else {\n const delimiter = tripleDelimiter;\n let combined = valueRaw;\n let closed = false;\n while (index + 1 < lines.length) {\n index += 1;\n const nextLine = lines[index] ?? \"\";\n combined += `\\n${nextLine}`;\n if (new RegExp(`${delimiter}\\\\s*$`).test(nextLine)) {\n closed = true;\n break;\n }\n }\n if (!closed) {\n return null;\n }\n valueRaw = combined;\n }\n }\n\n const normalized = normalizeValue(valueRaw);\n if (normalized === null) {\n return null;\n }\n\n const fullKey = tablePrefix ? `${tablePrefix}.${key}` : key;\n if (typeof normalized === \"object\" && !Array.isArray(normalized)) {\n for (const [inlineKey, inlineValue] of Object.entries(normalized)) {\n const entryKey = tablePrefixInList ? `${key}.${inlineKey}` : `${fullKey}.${inlineKey}`;\n if (tablePrefixInList && tableTarget) {\n tableTarget[entryKey] = toPlainText(inlineValue);\n } else {\n result[entryKey] = toPlainText(inlineValue);\n }\n }\n continue;\n }\n\n if (tablePrefixInList && tableTarget) {\n tableTarget[key] = toPlainText(normalized);\n continue;\n }\n\n result[fullKey] = toPlainText(normalized);\n }\n\n flattenArrayTables(result);\n\n return result;\n}\n","import { parseDocument } from \"yaml\";\nimport { parseTomlFrontmatter } from \"./toml-simple\";\nimport type { FrontmatterType, ParsedMarkdown } from \"./types\";\n\nconst FENCE_TO_TYPE: Record<string, FrontmatterType> = {\n \"---\": \"yaml\",\n \"+++\": \"toml\",\n \";;;\": \"json\",\n};\n\nfunction normalizeNewlines(input: string): string {\n return input.replace(/\\r\\n/g, \"\\n\");\n}\n\nfunction stripBom(line: string): string {\n return line.startsWith(\"\\uFEFF\") ? line.slice(1) : line;\n}\n\nfunction getFenceType(line: string): FrontmatterType | null {\n const match = line.match(/^[\\t ]*(---|\\+\\+\\+|;;;)[\\t ]*$/);\n if (!match) {\n return null;\n }\n return FENCE_TO_TYPE[match[1] ?? \"\"] ?? null;\n}\n\nfunction parseFrontmatter(frontmatter: string, type: FrontmatterType | null): Record<string, unknown> | null {\n if (!type) {\n return null;\n }\n\n if (type === \"json\") {\n try {\n return JSON.parse(frontmatter) as Record<string, unknown>;\n } catch {\n return null;\n }\n }\n\n if (type === \"yaml\") {\n const doc = parseDocument(frontmatter, { prettyErrors: false });\n if (doc.errors.length > 0) {\n return null;\n }\n const data = doc.toJSON();\n if (!data || typeof data !== \"object\" || Array.isArray(data)) {\n return null;\n }\n return data as Record<string, unknown>;\n }\n\n if (type === \"toml\") {\n return parseTomlFrontmatter(frontmatter);\n }\n\n return null;\n}\n\nfunction extractJsonBlock(text: string, startIndex: number): { jsonText: string; endIndex: number } | null {\n let depth = 0;\n let inString = false;\n let escaped = false;\n\n for (let i = startIndex; i < text.length; i += 1) {\n const char = text[i] ?? \"\";\n\n if (inString) {\n if (escaped) {\n escaped = false;\n continue;\n }\n\n if (char === \"\\\\\") {\n escaped = true;\n continue;\n }\n\n if (char === \"\\\"\") {\n inString = false;\n }\n\n continue;\n }\n\n if (char === \"\\\"\") {\n inString = true;\n continue;\n }\n\n if (char === \"{\") {\n depth += 1;\n continue;\n }\n\n if (char === \"}\") {\n depth -= 1;\n if (depth === 0) {\n const jsonText = text.slice(startIndex, i + 1);\n return { jsonText, endIndex: i };\n }\n }\n }\n\n return null;\n}\n\nexport function parseMarkdown(input: string): ParsedMarkdown {\n const normalized = normalizeNewlines(input);\n const lines = normalized.split(\"\\n\");\n if (lines.length === 0) {\n return { frontmatter: null, content: normalized, data: null, frontmatterType: null };\n }\n\n lines[0] = stripBom(lines[0] ?? \"\");\n const normalizedWithoutBom = lines.join(\"\\n\");\n\n const openingType = getFenceType(lines[0] ?? \"\");\n if (!openingType) {\n const leadingWhitespace = normalizedWithoutBom.match(/^[\\t \\n]*/)?.[0] ?? \"\";\n const jsonStart = leadingWhitespace.length;\n if (normalizedWithoutBom[jsonStart] !== \"{\") {\n return { frontmatter: null, content: normalizedWithoutBom, data: null, frontmatterType: null };\n }\n\n const jsonBlock = extractJsonBlock(normalizedWithoutBom, jsonStart);\n if (!jsonBlock) {\n return { frontmatter: null, content: normalizedWithoutBom, data: null, frontmatterType: null };\n }\n\n const frontmatter = jsonBlock.jsonText;\n let content = normalizedWithoutBom.slice(jsonBlock.endIndex + 1);\n if (content.startsWith(\"\\n\")) {\n content = content.slice(1);\n }\n const data = parseFrontmatter(frontmatter, \"json\");\n if (!data) {\n return { frontmatter: null, content: normalizedWithoutBom, data: null, frontmatterType: null };\n }\n\n return {\n frontmatter,\n content,\n data,\n frontmatterType: \"json\",\n };\n }\n\n let closingIndex = -1;\n for (let i = 1; i < lines.length; i += 1) {\n if (getFenceType(lines[i] ?? \"\") === openingType) {\n closingIndex = i;\n break;\n }\n }\n\n if (closingIndex === -1) {\n return { frontmatter: null, content: normalizedWithoutBom, data: null, frontmatterType: null };\n }\n\n const frontmatter = lines.slice(1, closingIndex).join(\"\\n\");\n const content = lines.slice(closingIndex + 1).join(\"\\n\");\n const data = parseFrontmatter(frontmatter, openingType);\n\n return {\n frontmatter,\n content,\n data,\n frontmatterType: openingType,\n };\n}\n","import type { WordCounterMode, WordCounterOptions, WordCounterResult } from \"../wc/types\";\nimport wordCounter from \"../wc\";\nimport { parseMarkdown } from \"./parse-markdown\";\nimport type { SectionMode, SectionedResult } from \"./types\";\n\nfunction normalizeText(value: unknown): string {\n if (value == null) {\n return \"\";\n }\n if (typeof value === \"string\") {\n return value;\n }\n if (typeof value === \"number\" || typeof value === \"boolean\") {\n return String(value);\n }\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n}\n\nfunction buildPerKeyItems(\n data: Record<string, unknown> | null,\n mode: WordCounterMode,\n options: WordCounterOptions,\n): Array<{ name: string; source: \"frontmatter\"; result: WordCounterResult }> {\n if (!data || typeof data !== \"object\" || Array.isArray(data)) {\n return [];\n }\n\n return Object.entries(data).map(([key, value]) => {\n const valueText = normalizeText(value);\n const text = valueText ? `${key}: ${valueText}` : key;\n return {\n name: key,\n source: \"frontmatter\",\n result: wordCounter(text, options),\n };\n });\n}\n\nfunction buildSingleItem(\n name: string,\n text: string,\n mode: WordCounterMode,\n options: WordCounterOptions,\n source: \"frontmatter\" | \"content\",\n) {\n return [{ name, source, result: wordCounter(text, options) }];\n}\n\nfunction sumTotals(items: Array<{ result: WordCounterResult }>): number {\n return items.reduce((sum, item) => sum + item.result.total, 0);\n}\n\nexport function countSections(\n input: string,\n section: SectionMode,\n options: WordCounterOptions = {},\n): SectionedResult {\n const mode: WordCounterMode = options.mode ?? \"chunk\";\n if (section === \"all\") {\n const result = wordCounter(input, options);\n return {\n section,\n total: result.total,\n frontmatterType: null,\n items: [{ name: \"all\", source: \"content\", result }],\n };\n }\n\n const parsed = parseMarkdown(input);\n const frontmatterText = parsed.frontmatter ?? \"\";\n const contentText = parsed.content ?? \"\";\n\n let items: Array<{ name: string; source: \"frontmatter\" | \"content\"; result: WordCounterResult }> = [];\n\n if (section === \"frontmatter\") {\n items = buildSingleItem(\"frontmatter\", frontmatterText, mode, options, \"frontmatter\");\n } else if (section === \"content\") {\n items = buildSingleItem(\"content\", contentText, mode, options, \"content\");\n } else if (section === \"split\") {\n items = [\n ...buildSingleItem(\"frontmatter\", frontmatterText, mode, options, \"frontmatter\"),\n ...buildSingleItem(\"content\", contentText, mode, options, \"content\"),\n ];\n } else if (section === \"per-key\") {\n items = buildPerKeyItems(parsed.data, mode, options);\n } else if (section === \"split-per-key\") {\n items = [\n ...buildPerKeyItems(parsed.data, mode, options),\n ...buildSingleItem(\"content\", contentText, mode, options, \"content\"),\n ];\n }\n\n return {\n section,\n total: sumTotals(items),\n frontmatterType: parsed.frontmatterType,\n items,\n };\n}\n","export function showSingularOrPluralWord(count: number, word: string): string {\n return `${count} ${word}${count === 1 ? \"\" : \"s\"}`;\n}\n","import wordCounter, {\n countCharsForLocale,\n countWordsForLocale,\n segmentTextByLocale,\n} from \"./wc\";\nimport { parseMarkdown, countSections } from \"./markdown\";\nimport { showSingularOrPluralWord } from \"./utils\";\n\nconst cjsExports = Object.assign(wordCounter, {\n default: wordCounter,\n wordCounter,\n countCharsForLocale,\n countWordsForLocale,\n segmentTextByLocale,\n parseMarkdown,\n countSections,\n showSingularOrPluralWord,\n});\n\nexport = cjsExports;\n"],"mappings":";;;AAAA,MAAM,iCAAiB,IAAI,KAA6B;AACxD,MAAM,yCAAyB,IAAI,KAA6B;AAEhE,SAAgB,aAAa,QAAgC;CAC3D,MAAM,SAAS,eAAe,IAAI,OAAO;AACzC,KAAI,OACF,QAAO;CAET,MAAM,YAAY,IAAI,KAAK,UAAU,QAAQ,EAAE,aAAa,QAAQ,CAAC;AACrE,gBAAe,IAAI,QAAQ,UAAU;AACrC,QAAO;;AAGT,SAAgB,qBAAqB,QAAgC;CACnE,MAAM,SAAS,uBAAuB,IAAI,OAAO;AACjD,KAAI,OACF,QAAO;CAET,MAAM,YAAY,IAAI,KAAK,UAAU,QAAQ,EAAE,aAAa,YAAY,CAAC;AACzE,wBAAuB,IAAI,QAAQ,UAAU;AAC7C,QAAO;;AAGT,SAAS,oBAA6B;AACpC,QAAO,OAAO,SAAS,eAAe,OAAO,KAAK,cAAc;;AAGlE,SAAgB,oBAAoB,MAAc,QAAwB;CACxE,MAAM,YAAY,aAAa,OAAO;CACtC,IAAI,QAAQ;AACZ,MAAK,MAAM,WAAW,UAAU,QAAQ,KAAK,CAC3C,KAAI,QAAQ,WACV;AAGJ,QAAO;;AAGT,SAAgB,oBAAoB,M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AAa,MAAM,SAAS,UAAU,CACrE;UACQ,YAAY,UACrB,SAAQ,iBAAiB,OAAO,MAAM,MAAM,QAAQ;UAC3C,YAAY,gBACrB,SAAQ,CACN,GAAG,iBAAiB,OAAO,MAAM,MAAM,QAAQ,EAC/C,GAAG,gBAAgB,WAAW,aAAa,MAAM,SAAS,UAAU,CACrE;AAGH,QAAO;EACL;EACA,OAAO,UAAU,MAAM;EACvB,iBAAiB,OAAO;EACxB;EACD;;;;;ACrGH,SAAgB,yBAAyB,OAAe,MAAsB;AAC5E,QAAO,GAAG,MAAM,GAAG,OAAO,UAAU,IAAI,KAAK;;;;;ACO/C,MAAM,aAAa,OAAO,OAAOC,YAAa;CAC5C,SAASA;CACT;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;iBAEO"}
package/dist/esm/bin.mjs CHANGED
@@ -418,7 +418,7 @@ var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
418
418
  //#endregion
419
419
  //#region src/cli/program/version-embedded.ts
420
420
  var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
421
- const EMBEDDED_PACKAGE_VERSION = "0.1.2";
421
+ const EMBEDDED_PACKAGE_VERSION = "0.1.3-canary.0";
422
422
 
423
423
  //#endregion
424
424
  //#region src/cli/program/version.ts
@@ -1608,7 +1608,7 @@ function resolveMode(input, fallback = "chunk") {
1608
1608
  //#endregion
1609
1609
  //#region src/wc/locale-detect.ts
1610
1610
  const DEFAULT_LOCALE = "und-Latn";
1611
- const DEFAULT_HAN_TAG = "zh-Hani";
1611
+ const DEFAULT_HAN_TAG = "und-Hani";
1612
1612
  const regex = {
1613
1613
  hiragana: /\p{Script=Hiragana}/u,
1614
1614
  katakana: /\p{Script=Katakana}/u,