@samline/string 1.0.0 → 1.5.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/CHANGELOG.md +66 -3
- package/README.md +95 -32
- package/dist/browser/string.global.js +1 -1
- package/dist/browser/string.global.js.map +1 -1
- package/dist/chunk-3EFE2B7D.js +567 -0
- package/dist/chunk-3EFE2B7D.js.map +1 -0
- package/dist/index.cjs +503 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +280 -9
- package/dist/index.d.ts +280 -9
- package/dist/index.js +1 -1
- package/dist/vanilla/index.cjs +1239 -15
- package/dist/vanilla/index.cjs.map +1 -1
- package/dist/vanilla/index.d.cts +254 -1
- package/dist/vanilla/index.d.ts +254 -1
- package/dist/vanilla/index.js +714 -1
- package/dist/vanilla/index.js.map +1 -1
- package/package.json +56 -8
- package/dist/chunk-7CEOX6CZ.js +0 -105
- package/dist/chunk-7CEOX6CZ.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/index.ts","../../src/core/words.ts","../../src/core/accents.ts","../../src/core/case.ts","../../src/core/slugify.ts","../../src/core/text.ts","../../src/browser/global.ts"],"sourcesContent":["export { words } from './words.js'\nexport { removeAccents } from './accents.js'\nexport {\n camelCase,\n capitalize,\n constantCase,\n dotCase,\n kebabCase,\n pascalCase,\n sentenceCase,\n snakeCase,\n titleCase,\n uncapitalize,\n type CaseOptions,\n type TitleCaseOptions,\n} from './case.js'\nexport { slugify, type SlugifyOptions } from './slugify.js'\nexport { initials, truncate, type InitialsOptions, type TruncateOptions } from './text.js'\n","/**\n * Split any identifier or phrase into words.\n *\n * Handles separators (spaces, `-`, `_`, `.`, `/`, punctuation), camelCase,\n * PascalCase and acronyms (`XMLHttpRequest` → `XML`, `Http`, `Request`), keeps\n * digits attached to their word (`version2` stays one word) and works with any\n * script (`añoNuevo` → `año`, `Nuevo`).\n */\nexport const words = (input: string): string[] => {\n if (typeof input !== 'string' || input === '') return []\n return (\n input\n // fooBar → foo Bar, foo2Bar → foo2 Bar\n .replace(/([\\p{Ll}\\p{N}])(\\p{Lu})/gu, '$1 $2')\n // XMLHttp → XML Http\n .replace(/(\\p{Lu})(\\p{Lu}\\p{Ll})/gu, '$1 $2')\n .split(/[^\\p{L}\\p{N}]+/u)\n .filter(Boolean)\n )\n}\n","/** Letters that Unicode normalization does not decompose into ASCII. */\nconst TRANSLITERATIONS: Record<string, string> = {\n ß: 'ss',\n ẞ: 'SS',\n æ: 'ae',\n Æ: 'AE',\n œ: 'oe',\n Œ: 'OE',\n ø: 'o',\n Ø: 'O',\n đ: 'd',\n Đ: 'D',\n ł: 'l',\n Ł: 'L',\n þ: 'th',\n Þ: 'TH',\n ð: 'd',\n Ð: 'D',\n ı: 'i',\n}\nconst SPECIAL = new RegExp(`[${Object.keys(TRANSLITERATIONS).join('')}]`, 'g')\n\n/** Remove diacritics and transliterate common Latin letters: `Ñandú Straße` → `Nandu Strasse`. */\nexport const removeAccents = (input: string): string =>\n String(input ?? '')\n .normalize('NFKD')\n .replace(/\\p{M}+/gu, '')\n .replace(SPECIAL, char => TRANSLITERATIONS[char] ?? char)\n","import { words } from './words.js'\n\nexport interface CaseOptions {\n /** Locale for upper/lower casing, for example `'tr'` for Turkish dotted i. */\n locale?: string | string[]\n}\n\nconst lower = (value: string, locale?: string | string[]) => value.toLocaleLowerCase(locale)\nconst upper = (value: string, locale?: string | string[]) => value.toLocaleUpperCase(locale)\nconst upperFirst = (value: string, locale?: string | string[]) => {\n const [first = '', ...rest] = Array.from(value)\n return upper(first, locale) + rest.join('')\n}\nconst titleWord = (value: string, locale?: string | string[]) =>\n upperFirst(lower(value, locale), locale)\n\n/** `hello world` → `helloWorld` */\nexport const camelCase = (input: string, { locale }: CaseOptions = {}): string =>\n words(input)\n .map((word, index) => (index === 0 ? lower(word, locale) : titleWord(word, locale)))\n .join('')\n\n/** `hello world` → `HelloWorld` */\nexport const pascalCase = (input: string, { locale }: CaseOptions = {}): string =>\n words(input)\n .map(word => titleWord(word, locale))\n .join('')\n\nconst joinLower =\n (separator: string) =>\n (input: string, { locale }: CaseOptions = {}) =>\n words(input)\n .map(word => lower(word, locale))\n .join(separator)\n\n/** `Hello World` → `hello-world` */\nexport const kebabCase = joinLower('-')\n/** `Hello World` → `hello_world` */\nexport const snakeCase = joinLower('_')\n/** `Hello World` → `hello.world` */\nexport const dotCase = joinLower('.')\n\n/** `Hello World` → `HELLO_WORLD` */\nexport const constantCase = (input: string, { locale }: CaseOptions = {}): string =>\n words(input)\n .map(word => upper(word, locale))\n .join('_')\n\nexport interface TitleCaseOptions extends CaseOptions {\n /**\n * Words kept in lower case unless they come first, for example\n * `['de', 'la', 'y']` or `['of', 'the', 'and']`. Defaults to none.\n */\n smallWords?: readonly string[]\n}\n\n/**\n * `the lord of the rings` → `The Lord Of The Rings` (or `The Lord of the Rings`\n * with `smallWords`). Keeps the original spacing and punctuation.\n */\nexport const titleCase = (\n input: string,\n { locale, smallWords = [] }: TitleCaseOptions = {}\n): string => {\n const small = new Set(smallWords.map(word => lower(word, locale)))\n let index = 0\n return String(input ?? '').replace(/[\\p{L}\\p{N}]+/gu, word => {\n const first = index++ === 0\n const lowered = lower(word, locale)\n return !first && small.has(lowered) ? lowered : upperFirst(lowered, locale)\n })\n}\n\n/** `HELLO world. NEW sentence` → `Hello world. new sentence`; only the first letter is upper case. */\nexport const sentenceCase = (input: string, { locale }: CaseOptions = {}): string =>\n upperFirst(lower(String(input ?? ''), locale), locale)\n\n/** Upper-case the first letter and leave the rest untouched: `hello World` → `Hello World`. */\nexport const capitalize = (input: string, { locale }: CaseOptions = {}): string =>\n upperFirst(String(input ?? ''), locale)\n\n/** Lower-case the first letter and leave the rest untouched: `Hello` → `hello`. */\nexport const uncapitalize = (input: string, { locale }: CaseOptions = {}): string => {\n const [first = '', ...rest] = Array.from(String(input ?? ''))\n return lower(first, locale) + rest.join('')\n}\n","import { removeAccents } from './accents.js'\n\nexport interface SlugifyOptions {\n /** Word separator. Defaults to `'-'`. */\n separator?: string\n /** Lower-case the result. Defaults to `true`. */\n lower?: boolean\n /**\n * Replacements applied before anything else, for example\n * `{ '&': 'y', '%': 'por ciento' }`. Keys are matched literally.\n */\n replacements?: Readonly<Record<string, string>>\n /** Maximum length; cuts at a separator when possible. */\n maxLength?: number\n /**\n * Remove leading and trailing separators. Defaults to `true`. Use `false`\n * while the user is typing, so a trailing space can become a separator.\n */\n trim?: boolean\n /** Locale for lower-casing. */\n locale?: string | string[]\n}\n\nconst escape = (value: string) => value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n\n/**\n * `¡Hola, Ñandú & Café!` → `hola-nandu-cafe`\n *\n * Removes accents, transliterates common letters (ß, æ, ø, œ, ł…), keeps\n * only ASCII letters and digits, and collapses everything else into one\n * separator.\n */\nexport const slugify = (\n input: string,\n {\n separator = '-',\n lower = true,\n replacements = {},\n maxLength,\n trim = true,\n locale,\n }: SlugifyOptions = {}\n): string => {\n let value = String(input ?? '')\n for (const [from, to] of Object.entries(replacements)) value = value.split(from).join(` ${to} `)\n // Lower-case first: some locales produce letters (Turkish ı) that removeAccents transliterates.\n if (lower) value = value.toLocaleLowerCase(locale)\n value = removeAccents(value)\n\n const sep = escape(separator)\n value = value.replace(/[^A-Za-z0-9]+/g, separator)\n if (separator) value = value.replace(new RegExp(`(?:${sep}){2,}`, 'g'), separator)\n if (trim && separator) value = value.replace(new RegExp(`^(?:${sep})+|(?:${sep})+$`, 'g'), '')\n else if (separator) value = value.replace(new RegExp(`^(?:${sep})+`), '')\n\n if (\n maxLength !== undefined &&\n Number.isFinite(maxLength) &&\n maxLength >= 0 &&\n value.length > maxLength\n ) {\n const cut = value.slice(0, maxLength)\n const boundary = separator ? cut.lastIndexOf(separator) : -1\n value = boundary > 0 && value[maxLength] !== separator ? cut.slice(0, boundary) : cut\n if (separator) value = value.replace(new RegExp(`(?:${sep})+$`), '')\n }\n return value\n}\n","import { words } from './words.js'\n\nexport interface TruncateOptions {\n /** Appended when the text is cut. Defaults to `'…'`. Counts toward `length`. */\n ellipsis?: string\n /** Cut at the last whole word instead of mid-word. Defaults to `true`. */\n wordBoundary?: boolean\n}\n\n/**\n * Shorten text to at most `length` characters (code points, so emoji and\n * accents are never split).\n */\nexport const truncate = (\n input: string,\n length: number,\n { ellipsis = '…', wordBoundary = true }: TruncateOptions = {}\n): string => {\n const chars = Array.from(String(input ?? ''))\n if (!Number.isFinite(length) || length < 0 || chars.length <= length) return chars.join('')\n const room = Math.max(0, length - Array.from(ellipsis).length)\n let cut = chars.slice(0, room).join('')\n if (wordBoundary && chars[room] !== undefined && /[\\p{L}\\p{N}]/u.test(chars[room]!)) {\n const lastSpace = cut.search(/\\s\\S*$/u)\n if (lastSpace > 0) cut = cut.slice(0, lastSpace)\n }\n return cut.replace(/[\\s.,;:!?-]+$/u, '') + ellipsis\n}\n\nexport interface InitialsOptions {\n /** Maximum number of letters. Defaults to `2`. */\n max?: number\n locale?: string | string[]\n}\n\n/** `Samuel Olvera` → `SO`, `ana maría lópez` → `AM` */\nexport const initials = (input: string, { max = 2, locale }: InitialsOptions = {}): string =>\n words(String(input ?? ''))\n .slice(0, Math.max(0, max))\n .map(word => Array.from(word)[0]!.toLocaleUpperCase(locale))\n .join('')\n","import * as api from '../core/index.js'\n\nexport type SamlineStringGlobal = typeof api\n\n;(globalThis as typeof globalThis & { SamlineString?: SamlineStringGlobal }).SamlineString = api\n\nexport * from '../core/index.js'\n"],"mappings":"6GAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,eAAAE,EAAA,eAAAC,EAAA,iBAAAC,EAAA,YAAAC,EAAA,aAAAC,EAAA,cAAAC,EAAA,eAAAC,EAAA,kBAAAC,EAAA,iBAAAC,EAAA,YAAAC,EAAA,cAAAC,EAAA,cAAAC,EAAA,aAAAC,EAAA,iBAAAC,EAAA,UAAAC,ICQO,IAAMC,EAASC,GAChB,OAAOA,GAAU,UAAYA,IAAU,GAAW,CAAC,EAErDA,E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A,CAAE,SAAAC,EAAW,SAAK,aAAAC,EAAe,EAAK,EAAqB,CAAC,IACjD,CACX,IAAMC,EAAQ,MAAM,KAAK,OAAOJ,GAAS,EAAE,CAAC,EAC5C,GAAI,CAAC,OAAO,SAASC,CAAM,GAAKA,EAAS,GAAKG,EAAM,QAAUH,EAAQ,OAAOG,EAAM,KAAK,EAAE,EAC1F,IAAMC,EAAO,KAAK,IAAI,EAAGJ,EAAS,MAAM,KAAKC,CAAQ,EAAE,MAAM,EACzDI,EAAMF,EAAM,MAAM,EAAGC,CAAI,EAAE,KAAK,EAAE,EACtC,GAAIF,GAAgBC,EAAMC,CAAI,IAAM,QAAa,gBAAgB,KAAKD,EAAMC,CAAI,CAAE,EAAG,CACnF,IAAME,EAAYD,EAAI,OAAO,SAAS,EAClCC,EAAY,IAAGD,EAAMA,EAAI,MAAM,EAAGC,CAAS,EACjD,CACA,OAAOD,EAAI,QAAQ,iBAAkB,EAAE,EAAIJ,CAC7C,EASaM,EAAW,CAACR,EAAe,CAAE,IAAAS,EAAM,EAAG,OAAAC,CAAO,EAAqB,CAAC,IAC9EC,EAAM,OAAOX,GAAS,EAAE,CAAC,EACtB,MAAM,EAAG,KAAK,IAAI,EAAGS,CAAG,CAAC,EACzB,IAAIG,GAAQ,MAAM,KAAKA,CAAI,EAAE,CAAC,EAAG,kBAAkBF,CAAM,CAAC,EAC1D,KAAK,EAAE,ECpCV,WAA2E,cAAgBG","names":["core_exports","__export","camelCase","capitalize","constantCase","dotCase","initials","kebabCase","pascalCase","removeAccents","sentenceCase","slugify","snakeCase","titleCase","truncate","uncapitalize","words","words","input","TRANSLITERATIONS","SPECIAL","removeAccents","input","char","lower","value","locale","upper","upperFirst","first","rest","titleWord","camelCase","input","words","word","index","pascalCase","joinLower","separator","kebabCase","snakeCase","dotCase","constantCase","titleCase","smallWords","small","lowered","sentenceCase","capitalize","uncapitalize","escape","value","slugify","input","separator","lower","replacements","maxLength","trim","locale","from","to","removeAccents","sep","cut","boundary","truncate","input","length","ellipsis","wordBoundary","chars","room","cut","lastSpace","initials","max","locale","words","word","core_exports"]}
|
|
1
|
+
{"version":3,"sources":["../../src/core/index.ts","../../src/core/words.ts","../../src/core/accents.ts","../../src/core/charmaps.ts","../../src/core/case.ts","../../src/core/slugify.ts","../../src/core/graphemes.ts","../../src/core/text.ts","../../src/core/convert.ts","../../src/core/search.ts","../../src/core/prose.ts","../../src/core/html.ts","../../src/core/color.ts","../../node_modules/.pnpm/@samline+internal@1.0.0/node_modules/@samline/internal/src/env.ts","../../node_modules/.pnpm/@samline+internal@1.0.0/node_modules/@samline/internal/src/elements.ts","../../node_modules/.pnpm/@samline+internal@1.0.0/node_modules/@samline/internal/src/attributes.ts","../../node_modules/.pnpm/@samline+internal@1.0.0/node_modules/@samline/internal/src/motion.ts","../../node_modules/.pnpm/@samline+internal@1.0.0/node_modules/@samline/internal/src/auto-init.ts","../../src/vanilla/controller.ts","../../src/vanilla/copy.ts","../../src/vanilla/count.ts","../../src/vanilla/fit.ts","../../src/vanilla/search.ts","../../src/vanilla/string.ts","../../src/browser/global.ts"],"sourcesContent":["export { words } from './words.js'\nexport { removeAccents, type RemoveAccentsOptions } from './accents.js'\nexport { CHAR_MAPS, CYRILLIC, GERMAN, GREEK, type CharMap, type CharMapName } from './charmaps.js'\nexport {\n camelCase,\n capitalize,\n constantCase,\n dotCase,\n kebabCase,\n pascalCase,\n pathCase,\n sentenceCase,\n snakeCase,\n titleCase,\n trainCase,\n uncapitalize,\n type CaseOptions,\n type TitleCaseOptions,\n} from './case.js'\nexport {\n slugify,\n uniqueSlug,\n type Replacements,\n type SlugifyOptions,\n type TakenSlugs,\n type UniqueSlugOptions,\n} from './slugify.js'\nexport {\n initials,\n truncate,\n type InitialsOptions,\n type TruncateOptions,\n type TruncatePosition,\n} from './text.js'\nexport {\n CONVERSIONS,\n convert,\n isConversion,\n type Conversion,\n type ConvertOptions,\n} from './convert.js'\nexport {\n closest,\n compareNatural,\n contains,\n distance,\n fold,\n highlight,\n similarity,\n type ClosestOptions,\n type CompareOptions,\n type FoldOptions,\n type HighlightSegment,\n type MatchOptions,\n type SimilarityOptions,\n} from './search.js'\nexport { graphemes } from './graphemes.js'\nexport {\n pluralize,\n readingTime,\n template,\n wordCount,\n type PluralForms,\n type PluralizeOptions,\n type ReadingTime,\n type ReadingTimeOptions,\n type TemplateOptions,\n type WordCountOptions,\n} from './prose.js'\nexport { escapeHtml, stripTags, unescapeHtml } from './html.js'\nexport { hashColor, type HashColorOptions } from './color.js'\n","/**\n * Split any identifier or phrase into words.\n *\n * Handles separators (spaces, `-`, `_`, `.`, `/`, punctuation), camelCase,\n * PascalCase and acronyms (`XMLHttpRequest` → `XML`, `Http`, `Request`), keeps\n * digits attached to their word (`version2` stays one word) and works with any\n * script (`añoNuevo` → `año`, `Nuevo`).\n */\nexport const words = (input: string): string[] => {\n if (typeof input !== 'string' || input === '') return []\n return (\n input\n // fooBar → foo Bar, foo2Bar → foo2 Bar\n .replace(/([\\p{Ll}\\p{N}]\\p{M}*)(\\p{Lu})/gu, '$1 $2')\n // XMLHttp → XML Http\n .replace(/(\\p{Lu})(\\p{Lu}\\p{Ll})/gu, '$1 $2')\n .split(/[^\\p{L}\\p{M}\\p{N}]+/u)\n .filter(Boolean)\n )\n}\n","/** Letters that Unicode normalization does not decompose into ASCII. */\nconst TRANSLITERATIONS: Record<string, string> = {\n ß: 'ss',\n ẞ: 'SS',\n æ: 'ae',\n Æ: 'AE',\n œ: 'oe',\n Œ: 'OE',\n ø: 'o',\n Ø: 'O',\n đ: 'd',\n Đ: 'D',\n ł: 'l',\n Ł: 'L',\n þ: 'th',\n Þ: 'TH',\n ð: 'd',\n Ð: 'D',\n ı: 'i',\n}\nconst SPECIAL = new RegExp(`[${Object.keys(TRANSLITERATIONS).join('')}]`, 'g')\n\nexport interface RemoveAccentsOptions {\n /**\n * Extra replacements, applied before and after accents are removed, for\n * scripts or conventions the built-in table does not cover:\n * `{ charMap: CYRILLIC }`, `{ charMap: { ä: 'ae' } }`. Keys may be longer\n * than one character; the longest key wins.\n */\n charMap?: Readonly<Record<string, string>>\n}\n\nconst escape = (value: string) => value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\nconst patterns = new WeakMap<object, RegExp | null>()\n\nconst patternFor = (map: Readonly<Record<string, string>>): RegExp | null => {\n if (patterns.has(map)) return patterns.get(map)!\n const keys = Object.keys(map)\n .filter(Boolean)\n .sort((a, b) => b.length - a.length)\n const pattern = keys.length ? new RegExp(keys.map(escape).join('|'), 'gu') : null\n patterns.set(map, pattern)\n return pattern\n}\n\nconst applyMap = (value: string, map: Readonly<Record<string, string>>) => {\n const pattern = patternFor(map)\n return pattern ? value.replace(pattern, key => map[key] ?? key) : value\n}\n\n/** Remove diacritics and transliterate common Latin letters: `Ñandú Straße` → `Nandu Strasse`. */\nexport const removeAccents = (input: string, { charMap }: RemoveAccentsOptions = {}): string => {\n let value = String(input ?? '')\n // Before: exact letters such as ё or ä. After: letters whose accent was removed (й → и).\n if (charMap) value = applyMap(value, charMap)\n value = value\n .normalize('NFKD')\n .replace(/\\p{M}+/gu, '')\n .replace(SPECIAL, char => TRANSLITERATIONS[char] ?? char)\n return charMap ? applyMap(value, charMap) : value\n}\n","/** A map from characters (or short sequences) to their Latin replacement. */\nexport type CharMap = Readonly<Record<string, string>>\n\n/** Add the upper-case form of every lower-case entry: `ж: 'zh'` → `Ж: 'Zh'`. */\nconst withUpper = (lower: Record<string, string>): CharMap => {\n const map: Record<string, string> = { ...lower }\n for (const [char, latin] of Object.entries(lower)) {\n const upper = char.toUpperCase()\n if (upper !== char && !(upper in map))\n map[upper] = latin.charAt(0).toUpperCase() + latin.slice(1)\n }\n return map\n}\n\n/** Russian, Ukrainian, Belarusian and Bulgarian letters: `Щука` → `Shchuka`. */\nexport const CYRILLIC: CharMap = withUpper({\n а: 'a',\n б: 'b',\n в: 'v',\n г: 'g',\n ґ: 'g',\n д: 'd',\n е: 'e',\n ё: 'yo',\n є: 'ye',\n ж: 'zh',\n з: 'z',\n и: 'i',\n і: 'i',\n ї: 'yi',\n й: 'y',\n к: 'k',\n л: 'l',\n м: 'm',\n н: 'n',\n о: 'o',\n п: 'p',\n р: 'r',\n с: 's',\n т: 't',\n у: 'u',\n ў: 'u',\n ф: 'f',\n х: 'kh',\n ц: 'ts',\n ч: 'ch',\n ш: 'sh',\n щ: 'shch',\n ъ: '',\n ы: 'y',\n ь: '',\n э: 'e',\n ю: 'yu',\n я: 'ya',\n})\n\n/** Modern Greek letters: `Αθήνα` → `Athina`. */\nexport const GREEK: CharMap = withUpper({\n α: 'a',\n β: 'v',\n γ: 'g',\n δ: 'd',\n ε: 'e',\n ζ: 'z',\n η: 'i',\n θ: 'th',\n ι: 'i',\n κ: 'k',\n λ: 'l',\n μ: 'm',\n ν: 'n',\n ξ: 'x',\n ο: 'o',\n π: 'p',\n ρ: 'r',\n σ: 's',\n ς: 's',\n τ: 't',\n υ: 'y',\n φ: 'f',\n χ: 'ch',\n ψ: 'ps',\n ω: 'o',\n})\n\n/** German umlauts as two letters, the way German speakers write them: `Müller` → `Mueller`. */\nexport const GERMAN: CharMap = withUpper({ ä: 'ae', ö: 'oe', ü: 'ue' })\n\n/** Presets by name, for the `data-string-transliterate` attribute. */\nexport const CHAR_MAPS = { cyrillic: CYRILLIC, greek: GREEK, german: GERMAN } as const\n\nexport type CharMapName = keyof typeof CHAR_MAPS\n","import { words } from './words.js'\n\nexport interface CaseOptions {\n /** Locale for upper/lower casing, for example `'tr'` for Turkish dotted i. */\n locale?: string | string[]\n}\n\nconst lower = (value: string, locale?: string | string[]) => value.toLocaleLowerCase(locale)\nconst upper = (value: string, locale?: string | string[]) => value.toLocaleUpperCase(locale)\nconst upperFirst = (value: string, locale?: string | string[]) => {\n const [first = '', ...rest] = Array.from(value)\n return upper(first, locale) + rest.join('')\n}\nconst titleWord = (value: string, locale?: string | string[]) =>\n upperFirst(lower(value, locale), locale)\n\n/** `hello world` → `helloWorld` */\nexport const camelCase = (input: string, { locale }: CaseOptions = {}): string =>\n words(input)\n .map((word, index) => (index === 0 ? lower(word, locale) : titleWord(word, locale)))\n .join('')\n\n/** `hello world` → `HelloWorld` */\nexport const pascalCase = (input: string, { locale }: CaseOptions = {}): string =>\n words(input)\n .map(word => titleWord(word, locale))\n .join('')\n\nconst joinLower =\n (separator: string) =>\n (input: string, { locale }: CaseOptions = {}) =>\n words(input)\n .map(word => lower(word, locale))\n .join(separator)\n\n/** `Hello World` → `hello-world` */\nexport const kebabCase = joinLower('-')\n/** `Hello World` → `hello_world` */\nexport const snakeCase = joinLower('_')\n/** `Hello World` → `hello.world` */\nexport const dotCase = joinLower('.')\n/** `Hello World` → `hello/world` */\nexport const pathCase = joinLower('/')\n\n/** `hello world` → `Hello-World`, the casing of HTTP headers. */\nexport const trainCase = (input: string, { locale }: CaseOptions = {}): string =>\n words(input)\n .map(word => titleWord(word, locale))\n .join('-')\n\n/** `Hello World` → `HELLO_WORLD` */\nexport const constantCase = (input: string, { locale }: CaseOptions = {}): string =>\n words(input)\n .map(word => upper(word, locale))\n .join('_')\n\nexport interface TitleCaseOptions extends CaseOptions {\n /**\n * Words kept in lower case unless they come first, for example\n * `['de', 'la', 'y']` or `['of', 'the', 'and']`. Defaults to none.\n */\n smallWords?: readonly string[]\n}\n\n/**\n * `the lord of the rings` → `The Lord Of The Rings` (or `The Lord of the Rings`\n * with `smallWords`). Keeps the original spacing and punctuation.\n */\nexport const titleCase = (\n input: string,\n { locale, smallWords = [] }: TitleCaseOptions = {}\n): string => {\n const small = new Set(smallWords.map(word => lower(word, locale)))\n let index = 0\n return String(input ?? '').replace(/[\\p{L}\\p{M}\\p{N}]+/gu, word => {\n const first = index++ === 0\n const lowered = lower(word, locale)\n return !first && small.has(lowered) ? lowered : upperFirst(lowered, locale)\n })\n}\n\n/** `HELLO world. NEW sentence` → `Hello world. new sentence`; only the first letter is upper case. */\nexport const sentenceCase = (input: string, { locale }: CaseOptions = {}): string =>\n upperFirst(lower(String(input ?? ''), locale), locale)\n\n/** Upper-case the first letter and leave the rest untouched: `hello World` → `Hello World`. */\nexport const capitalize = (input: string, { locale }: CaseOptions = {}): string =>\n upperFirst(String(input ?? ''), locale)\n\n/** Lower-case the first letter and leave the rest untouched: `Hello` → `hello`. */\nexport const uncapitalize = (input: string, { locale }: CaseOptions = {}): string => {\n const [first = '', ...rest] = Array.from(String(input ?? ''))\n return lower(first, locale) + rest.join('')\n}\n","import { removeAccents } from './accents.js'\n\nexport type Replacements =\n Readonly<Record<string, string>> | ReadonlyArray<readonly [string | RegExp, string]>\n\nexport interface SlugifyOptions {\n /** Word separator. Defaults to `'-'`. */\n separator?: string\n /** Lower-case the result. Defaults to `true`. */\n lower?: boolean\n /**\n * Replacements applied before anything else, for example\n * `{ '&': 'y', '%': 'por ciento' }`. Object keys are matched literally; for\n * patterns pass pairs: `[[/\\bC\\+\\+/g, 'cpp'], ['&', 'and']]` (use the `g` flag\n * to replace every match).\n */\n replacements?: Replacements\n /**\n * Extra transliteration, for example `CYRILLIC`, `GREEK`, `GERMAN` or your\n * own `{ ä: 'ae' }`. See `removeAccents`.\n */\n charMap?: Readonly<Record<string, string>>\n /** Characters kept as they are, for example `'.'` for `v1.2` or `'_'`. */\n preserve?: string\n /** Maximum length; cuts at a separator when possible. */\n maxLength?: number\n /**\n * Remove leading and trailing separators. Defaults to `true`. Use `false`\n * while the user is typing, so a trailing space can become a separator.\n */\n trim?: boolean\n /** Locale for lower-casing. */\n locale?: string | string[]\n}\n\nconst escape = (value: string) => value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n\n/**\n * `¡Hola, Ñandú & Café!` → `hola-nandu-cafe`\n *\n * Removes accents, transliterates common letters (ß, æ, ø, œ, ł…), keeps\n * only ASCII letters and digits, and collapses everything else into one\n * separator.\n */\nexport const slugify = (\n input: string,\n {\n separator = '-',\n lower = true,\n replacements = {},\n maxLength,\n trim = true,\n locale,\n charMap,\n preserve = '',\n }: SlugifyOptions = {}\n): string => {\n let value = String(input ?? '')\n const pairs = Array.isArray(replacements)\n ? (replacements as ReadonlyArray<readonly [string | RegExp, string]>)\n : Object.entries(replacements)\n for (const [from, to] of pairs) {\n value =\n typeof from === 'string' ? value.split(from).join(` ${to} `) : value.replace(from, ` ${to} `)\n }\n // Lower-case first: some locales produce letters (Turkish ı) that removeAccents transliterates.\n if (lower) value = value.toLocaleLowerCase(locale)\n value = removeAccents(value, charMap ? { charMap } : {})\n\n const sep = escape(separator)\n const kept = preserve.replace(/[\\]\\\\^-]/g, '\\\\$&')\n value = value.replace(new RegExp(`[^A-Za-z0-9${kept}]+`, 'g'), separator)\n if (separator) value = value.replace(new RegExp(`(?:${sep}){2,}`, 'g'), separator)\n if (trim && separator) value = value.replace(new RegExp(`^(?:${sep})+|(?:${sep})+$`, 'g'), '')\n else if (separator) value = value.replace(new RegExp(`^(?:${sep})+`), '')\n\n if (\n maxLength !== undefined &&\n Number.isFinite(maxLength) &&\n maxLength >= 0 &&\n value.length > maxLength\n ) {\n const cut = value.slice(0, maxLength)\n const boundary = separator ? cut.lastIndexOf(separator) : -1\n value = boundary > 0 && value[maxLength] !== separator ? cut.slice(0, boundary) : cut\n if (separator) value = value.replace(new RegExp(`(?:${sep})+$`), '')\n }\n return value\n}\n\nexport interface UniqueSlugOptions extends SlugifyOptions {\n /** First number tried. Defaults to `2`, so the second \"Hola\" becomes `hola-2`. */\n start?: number\n}\n\n/** Slugs already in use: a list, a `Set`, or a function that answers for one slug. */\nexport type TakenSlugs = Iterable<string> | ((slug: string) => boolean)\n\nconst LIMIT = 100_000\n\n/**\n * A slug that is not `taken`: `uniqueSlug('Hola', ['hola', 'hola-2'])` →\n * `'hola-3'`. The number is joined with the separator, and with `maxLength`\n * the base is shortened so the number always fits.\n *\n * When editing a record, leave its own current slug out of `taken`.\n */\nexport const uniqueSlug = (\n input: string,\n taken: TakenSlugs,\n { start = 2, ...options }: UniqueSlugOptions = {}\n): string => {\n const base = slugify(input, options)\n let isTaken: (slug: string) => boolean\n if (typeof taken === 'function') isTaken = taken\n else {\n const set = new Set(taken)\n isTaken = slug => set.has(slug)\n }\n if (base && !isTaken(base)) return base\n\n const separator = options.separator ?? '-'\n const { maxLength } = options\n const first = Number.isFinite(start) ? Math.floor(start) : 2\n for (let n = first; n < first + LIMIT; n++) {\n const suffix = base ? `${separator}${n}` : String(n)\n let head = base\n if (maxLength !== undefined && maxLength >= 0 && head.length + suffix.length > maxLength) {\n head = head.slice(0, Math.max(0, maxLength - suffix.length))\n if (separator) while (head.endsWith(separator)) head = head.slice(0, -separator.length)\n }\n const candidate = head ? head + suffix : String(n)\n if (!isTaken(candidate)) return candidate\n }\n throw new RangeError(`uniqueSlug: no free slug for \"${base}\" after ${LIMIT} tries`)\n}\n","type Segmenter = { segment: (input: string) => Iterable<{ segment: string; isWordLike?: boolean }> }\ntype SegmenterConstructor = new (\n locale?: string | string[],\n options?: { granularity: 'grapheme' | 'word' }\n) => Segmenter\n\n/** `Intl.Segmenter` when the runtime has it (every current browser, Node 16+). */\nconst SegmenterImpl = (globalThis.Intl as { Segmenter?: SegmenterConstructor } | undefined)\n ?.Segmenter\n\nconst segmenters = new Map<string, Segmenter>()\n\n/** A cached `Intl.Segmenter`, or `undefined` in runtimes without one. */\nexport const segmenter = (\n granularity: 'grapheme' | 'word',\n locale?: string | string[]\n): Segmenter | undefined => {\n if (!SegmenterImpl) return undefined\n const key = `${granularity}|${locale === undefined ? '' : [locale].flat().join(',')}`\n let instance = segmenters.get(key)\n if (!instance) {\n instance = new SegmenterImpl(locale, { granularity })\n segmenters.set(key, instance)\n }\n return instance\n}\n\n/**\n * Split text into user-perceived characters, so a family emoji (👨👩👧), a\n * flag (🇲🇽) or a letter with a combining accent counts as one:\n * `graphemes('🇲🇽é')` → `['🇲🇽', 'é']`. Falls back to code points without\n * `Intl.Segmenter`.\n */\nexport const graphemes = (input: string): string[] => {\n const text = String(input ?? '')\n const instance = segmenter('grapheme')\n return instance ? Array.from(instance.segment(text), part => part.segment) : Array.from(text)\n}\n","import { graphemes } from './graphemes.js'\nimport { words } from './words.js'\n\nexport type TruncatePosition = 'end' | 'middle' | 'start'\n\nexport interface TruncateOptions {\n /** Appended when the text is cut. Defaults to `'…'`. Counts toward `length`. */\n ellipsis?: string\n /**\n * Cut at a whole word instead of mid-word. Defaults to `true`. Applies to\n * `'end'` and `'start'`; `'middle'` always keeps exact characters.\n */\n wordBoundary?: boolean\n /**\n * Where the text is cut. `'end'` (default) keeps the beginning,\n * `'start'` keeps the ending, and `'middle'` keeps both ends, which suits\n * file names and IDs: `annual-report-2026-final.pdf` → `annual-r…final.pdf`.\n */\n position?: TruncatePosition\n}\n\nconst WORD_CHAR = /[\\p{L}\\p{N}]/u\nconst EDGE = '[\\\\s.,;:!?-]+'\nconst TRAILING = new RegExp(`${EDGE}$`, 'u')\nconst LEADING = new RegExp(`^${EDGE}`, 'u')\n\n/**\n * Shorten text to at most `length` characters. Characters are graphemes, so\n * emoji (👨👩👧, 🇲🇽) and accented letters are never split.\n */\nexport const truncate = (\n input: string,\n length: number,\n { ellipsis = '…', wordBoundary = true, position = 'end' }: TruncateOptions = {}\n): string => {\n const chars = graphemes(input)\n if (!Number.isFinite(length) || length < 0 || chars.length <= length) return chars.join('')\n const room = Math.max(0, length - graphemes(ellipsis).length)\n\n if (position === 'middle') {\n const head = chars.slice(0, Math.ceil(room / 2)).join('')\n const tail = room > 1 ? chars.slice(chars.length - Math.floor(room / 2)).join('') : ''\n return head.replace(/\\s+$/u, '') + ellipsis + tail.replace(/^\\s+/u, '')\n }\n\n if (position === 'start') {\n const start = chars.length - room\n let cut = chars.slice(start).join('')\n if (wordBoundary && room > 0 && WORD_CHAR.test(chars[start - 1]!)) {\n const firstSpace = cut.search(/\\s/u)\n if (firstSpace >= 0 && firstSpace < cut.length - 1) cut = cut.slice(firstSpace)\n }\n return ellipsis + cut.replace(LEADING, '')\n }\n\n let cut = chars.slice(0, room).join('')\n if (wordBoundary && chars[room] !== undefined && WORD_CHAR.test(chars[room]!)) {\n const lastSpace = cut.search(/\\s\\S*$/u)\n if (lastSpace > 0) cut = cut.slice(0, lastSpace)\n }\n return cut.replace(TRAILING, '') + ellipsis\n}\n\nexport interface InitialsOptions {\n /** Maximum number of letters. Defaults to `2`. */\n max?: number\n locale?: string | string[]\n}\n\n/** `Samuel Olvera` → `SO`, `ana maría lópez` → `AM` */\nexport const initials = (input: string, { max = 2, locale }: InitialsOptions = {}): string =>\n words(String(input ?? ''))\n .slice(0, Math.max(0, max))\n .map(word => graphemes(word)[0]!.toLocaleUpperCase(locale))\n .join('')\n","import { removeAccents } from './accents.js'\nimport {\n camelCase,\n capitalize,\n constantCase,\n dotCase,\n kebabCase,\n pascalCase,\n pathCase,\n sentenceCase,\n snakeCase,\n titleCase,\n trainCase,\n uncapitalize,\n type TitleCaseOptions,\n} from './case.js'\nimport { slugify, uniqueSlug, type SlugifyOptions, type TakenSlugs } from './slugify.js'\nimport { initials, truncate, type InitialsOptions, type TruncateOptions } from './text.js'\n\n/** Every conversion `convert()` and the `data-string` attribute understand. */\nexport const CONVERSIONS = [\n 'camel',\n 'pascal',\n 'kebab',\n 'snake',\n 'dot',\n 'path',\n 'constant',\n 'train',\n 'title',\n 'sentence',\n 'capitalize',\n 'uncapitalize',\n 'lower',\n 'upper',\n 'slug',\n 'accents',\n 'truncate',\n 'initials',\n] as const\n\nexport type Conversion = (typeof CONVERSIONS)[number]\n\nexport interface ConvertOptions\n extends TitleCaseOptions, Omit<SlugifyOptions, 'locale'>, TruncateOptions, InitialsOptions {\n /** Maximum length for `'truncate'`. Without it, `'truncate'` returns the text unchanged. */\n length?: number\n /** Slugs already in use: `'slug'` then returns a free one (`hola-2`). See `uniqueSlug`. */\n taken?: TakenSlugs\n}\n\n/** True when `value` names a conversion, for example `'kebab'` or `'slug'`. */\nexport const isConversion = (value: unknown): value is Conversion =>\n (CONVERSIONS as readonly unknown[]).includes(value)\n\n/**\n * Run a conversion by name, so it can come from configuration, a select menu\n * or an HTML attribute: `convert('Hello World', 'kebab')` → `hello-world`.\n *\n * Options are passed through to the underlying function (`smallWords` for\n * `'title'`, `separator` and `replacements` for `'slug'`, `length` and\n * `position` for `'truncate'`, `max` for `'initials'`, `locale` for all of\n * them). An unknown name returns the text unchanged.\n */\nexport const convert = (input: string, to: Conversion, options: ConvertOptions = {}): string => {\n const text = String(input ?? '')\n const { locale } = options\n const caseOptions = locale === undefined ? {} : { locale }\n switch (to) {\n case 'camel':\n return camelCase(text, caseOptions)\n case 'pascal':\n return pascalCase(text, caseOptions)\n case 'kebab':\n return kebabCase(text, caseOptions)\n case 'snake':\n return snakeCase(text, caseOptions)\n case 'dot':\n return dotCase(text, caseOptions)\n case 'path':\n return pathCase(text, caseOptions)\n case 'constant':\n return constantCase(text, caseOptions)\n case 'train':\n return trainCase(text, caseOptions)\n case 'title':\n return titleCase(text, options)\n case 'sentence':\n return sentenceCase(text, caseOptions)\n case 'capitalize':\n return capitalize(text, caseOptions)\n case 'uncapitalize':\n return uncapitalize(text, caseOptions)\n case 'lower':\n return text.toLocaleLowerCase(locale)\n case 'upper':\n return text.toLocaleUpperCase(locale)\n case 'slug':\n return options.taken === undefined\n ? slugify(text, options)\n : uniqueSlug(text, options.taken, options)\n case 'accents':\n return removeAccents(text, options.charMap ? { charMap: options.charMap } : {})\n case 'truncate':\n return options.length === undefined ? text : truncate(text, options.length, options)\n case 'initials':\n return initials(text, options)\n default:\n return text\n }\n}\n","import { removeAccents } from './accents.js'\n\nexport interface FoldOptions {\n /** Locale for lower-casing, for example `'tr'` so `I` folds like `ı`. */\n locale?: string | string[]\n}\n\n/**\n * Fold text for comparison: lower case, no accents, common letters\n * transliterated and full-width forms mapped to ASCII.\n * `Ñandú ABC Straße` → `nandu abc strasse`.\n */\nexport const fold = (input: string, { locale }: FoldOptions = {}): string =>\n removeAccents(String(input ?? '').toLocaleLowerCase(locale))\n\nexport interface MatchOptions extends FoldOptions {\n /**\n * Treat every word of the query as its own term. Defaults to `true`:\n * `'cafe mex'` matches `México: Café de olla`. `false` matches the query\n * as one phrase.\n */\n split?: boolean\n}\n\nconst termsOf = (query: string, { locale, split = true }: MatchOptions): string[] => {\n const folded = fold(query, locale === undefined ? {} : { locale }).trim()\n if (!folded) return []\n return split ? Array.from(new Set(folded.split(/\\s+/u))) : [folded]\n}\n\n/**\n * Accent- and case-insensitive search: `contains('Café de olla', 'CAFE')` is\n * `true`. Every term must appear; an empty query matches everything.\n */\nexport const contains = (input: string, query: string, options: MatchOptions = {}): boolean => {\n const terms = termsOf(query, options)\n if (terms.length === 0) return true\n const text = fold(input, options.locale === undefined ? {} : { locale: options.locale })\n return terms.every(term => text.includes(term))\n}\n\nconst ASCII = /^[\\u0000-\\u007f]*$/\n\nexport interface HighlightSegment {\n /** A piece of the original text, unchanged. */\n text: string\n /** True when the piece matches the query. */\n match: boolean\n}\n\n/**\n * Split text into matching and non-matching pieces of the original text, for\n * highlighting search results without building HTML strings:\n * `highlight('Café de olla', 'cafe')` →\n * `[{ text: 'Café', match: true }, { text: ' de olla', match: false }]`.\n *\n * Matching ignores accents and case, like `contains`; terms do not need to\n * all appear.\n */\nexport const highlight = (\n input: string,\n query: string,\n options: MatchOptions = {}\n): HighlightSegment[] => {\n const chars = Array.from(String(input ?? ''))\n if (chars.length === 0) return []\n const terms = termsOf(query, options)\n if (terms.length === 0) return [{ text: chars.join(''), match: false }]\n\n // Fold each character on its own and remember which character produced\n // each folded unit, so matches map back onto the original text.\n const locale = options.locale\n let folded = ''\n const owner: number[] = []\n const empty = new Set<number>()\n chars.forEach((char, index) => {\n // ASCII fast path, unless the locale lower-cases into another script (tr: I → ı).\n const lower = char.toLocaleLowerCase(locale)\n const piece = ASCII.test(lower) ? lower : removeAccents(lower)\n folded += piece\n if (piece === '') empty.add(index)\n for (let unit = 0; unit < piece.length; unit++) owner.push(index)\n })\n\n const marked = new Array<boolean>(chars.length).fill(false)\n for (const term of terms) {\n for (let at = folded.indexOf(term); at !== -1; at = folded.indexOf(term, at + term.length)) {\n for (let index = owner[at]!; index <= owner[at + term.length - 1]!; index++) {\n marked[index] = true\n }\n }\n }\n\n // Combining marks fold to nothing; they belong to the letter before them.\n empty.forEach(index => {\n if (index > 0) marked[index] = marked[index - 1]!\n })\n\n const segments: HighlightSegment[] = []\n chars.forEach((char, index) => {\n const match = marked[index]!\n const last = segments[segments.length - 1]\n if (last && last.match === match) last.text += char\n else segments.push({ text: char, match })\n })\n return segments\n}\n\nexport interface CompareOptions {\n /** Locale for ordering. Defaults to the runtime's locale. */\n locale?: string | string[]\n /**\n * What counts as different, as in `Intl.Collator`. Defaults to `'base'`:\n * `a`, `á` and `A` sort as equal.\n */\n sensitivity?: 'base' | 'accent' | 'case' | 'variant'\n}\n\nconst collators = new Map<string, Intl.Collator>()\n\n/**\n * Natural, locale-aware ordering: numbers compare by value and accents are\n * ignored, so `file2` comes before `file10` and `Árbol` sits with `arbol`.\n * Pass it straight to sort: `names.sort(compareNatural)`.\n */\nexport const compareNatural = (\n a: string,\n b: string,\n { locale, sensitivity = 'base' }: CompareOptions = {}\n): number => {\n const key = `${locale === undefined ? '' : [locale].flat().join(',')}|${sensitivity}`\n let collator = collators.get(key)\n if (!collator) {\n collator = new Intl.Collator(locale, { numeric: true, sensitivity })\n collators.set(key, collator)\n }\n return collator.compare(String(a ?? ''), String(b ?? ''))\n}\n\n/**\n * Levenshtein distance in code points: the number of single-character\n * insertions, deletions and substitutions between two strings.\n * `distance('kitten', 'sitting')` → `3`.\n */\nexport const distance = (a: string, b: string): number => {\n const left = Array.from(String(a ?? ''))\n const right = Array.from(String(b ?? ''))\n if (left.length === 0) return right.length\n if (right.length === 0) return left.length\n let previous = Array.from({ length: right.length + 1 }, (_, index) => index)\n for (let i = 1; i <= left.length; i++) {\n const current = [i]\n for (let j = 1; j <= right.length; j++) {\n const cost = left[i - 1] === right[j - 1] ? 0 : 1\n current[j] = Math.min(previous[j]! + 1, current[j - 1]! + 1, previous[j - 1]! + cost)\n }\n previous = current\n }\n return previous[right.length]!\n}\n\nexport interface SimilarityOptions extends FoldOptions {\n /** Compare folded text, ignoring accents and case. Defaults to `true`. */\n fold?: boolean\n}\n\n/**\n * How alike two strings are, from `0` (nothing in common) to `1` (equal),\n * based on `distance`. Accents and case are ignored unless `fold: false`.\n * `similarity('Mexico', 'México')` → `1`.\n */\nexport const similarity = (\n a: string,\n b: string,\n { fold: shouldFold = true, locale }: SimilarityOptions = {}\n): number => {\n const options = locale === undefined ? {} : { locale }\n const left = shouldFold ? fold(a, options) : String(a ?? '')\n const right = shouldFold ? fold(b, options) : String(b ?? '')\n const longest = Math.max(Array.from(left).length, Array.from(right).length)\n return longest === 0 ? 1 : 1 - distance(left, right) / longest\n}\n\nexport interface ClosestOptions extends SimilarityOptions {\n /** Minimum similarity, from `0` to `1`. Defaults to `0.5`. */\n threshold?: number\n /**\n * Also compare the input with the start of each word of a longer\n * candidate, so `horchatta` finds `Horchata de arroz`. Needs at least three\n * characters. Defaults to `true`.\n */\n partial?: boolean\n}\n\n/** Partial matches score a little lower, so a whole match wins a tie. */\nconst PARTIAL_WEIGHT = 0.98\n\nconst partialScore = (input: string, candidate: string): number => {\n const left = Array.from(input)\n const right = Array.from(candidate)\n if (left.length < 3 || right.length <= left.length) return 0\n const needle = left.join('')\n let best = 0\n right.forEach((char, index) => {\n if (index > 0 && !/[\\s\\p{P}]/u.test(right[index - 1]!)) return\n if (/\\s/u.test(char)) return\n const piece = right.slice(index, index + left.length).join('')\n best = Math.max(best, similarity(needle, piece, { fold: false }))\n })\n return best * PARTIAL_WEIGHT\n}\n\n/**\n * The candidate most similar to `input`, for \"Did you mean…?\" hints, or\n * `undefined` when none reaches `threshold`.\n * `closest('mexcio', ['Chile', 'México', 'Perú'])` → `'México'`.\n */\nexport const closest = <T extends string>(\n input: string,\n candidates: Iterable<T>,\n { threshold = 0.5, partial = true, ...options }: ClosestOptions = {}\n): T | undefined => {\n const shouldFold = options.fold ?? true\n const foldOptions = options.locale === undefined ? {} : { locale: options.locale }\n const prepare = (value: string) => (shouldFold ? fold(value, foldOptions) : String(value ?? ''))\n const needle = prepare(input)\n let best: T | undefined\n let bestScore = -1\n for (const candidate of candidates) {\n const whole = similarity(input, candidate, options)\n const score = partial ? Math.max(whole, partialScore(needle, prepare(candidate))) : whole\n if (score > bestScore) {\n best = candidate\n bestScore = score\n }\n }\n return bestScore >= threshold ? best : undefined\n}\n","import { segmenter } from './graphemes.js'\n\nexport interface WordCountOptions {\n /** Locale for word boundaries, which matters for Chinese, Japanese or Thai. */\n locale?: string | string[]\n}\n\n/**\n * Count the words people read, with `Intl.Segmenter` when available, so\n * punctuation is ignored and Chinese or Japanese text is split correctly:\n * `wordCount('¡Hola, mundo! It's 2026.')` → `4`.\n */\nexport const wordCount = (input: string, { locale }: WordCountOptions = {}): number => {\n const text = String(input ?? '')\n const instance = segmenter('word', locale)\n if (!instance) return text.split(/[^\\p{L}\\p{M}\\p{N}'’]+/u).filter(Boolean).length\n let count = 0\n for (const part of instance.segment(text)) if (part.isWordLike) count++\n return count\n}\n\nexport interface ReadingTimeOptions extends WordCountOptions {\n /** Reading speed. Defaults to `200` words per minute. */\n wordsPerMinute?: number\n}\n\nexport interface ReadingTime {\n words: number\n /** Whole minutes, rounded up; `1` for any text with words, `0` for none. */\n minutes: number\n}\n\n/** `readingTime(article)` → `{ words: 1240, minutes: 7 }`. */\nexport const readingTime = (\n input: string,\n { wordsPerMinute = 200, ...options }: ReadingTimeOptions = {}\n): ReadingTime => {\n const words = wordCount(input, options)\n const speed = Number.isFinite(wordsPerMinute) && wordsPerMinute > 0 ? wordsPerMinute : 200\n return { words, minutes: words === 0 ? 0 : Math.max(1, Math.ceil(words / speed)) }\n}\n\n/** Plural forms by `Intl.PluralRules` category; `other` is required. */\nexport interface PluralForms {\n zero?: string\n one?: string\n two?: string\n few?: string\n many?: string\n other: string\n}\n\nexport interface PluralizeOptions {\n /** Locale for the plural rules and the number format. */\n locale?: string | string[]\n /** Use ordinal rules: `1st`, `2nd`, `3rd`, `4th`. Defaults to `false`. */\n ordinal?: boolean\n}\n\nconst pluralRules = new Map<string, Intl.PluralRules>()\nconst numberFormats = new Map<string, Intl.NumberFormat>()\nconst keyOf = (locale?: string | string[]) =>\n locale === undefined ? '' : [locale].flat().join(',')\n\n/**\n * Pick the right plural form for any language and put the formatted count\n * where `#` is: `pluralize(1234, { one: '# file', other: '# files' })` →\n * `'1,234 files'`. `zero` is used for `0` when you give it, in any language.\n */\nexport const pluralize = (\n count: number,\n forms: PluralForms,\n { locale, ordinal = false }: PluralizeOptions = {}\n): string => {\n const key = keyOf(locale)\n const rulesKey = `${key}|${ordinal}`\n let rules = pluralRules.get(rulesKey)\n if (!rules) {\n rules = new Intl.PluralRules(locale, { type: ordinal ? 'ordinal' : 'cardinal' })\n pluralRules.set(rulesKey, rules)\n }\n let format = numberFormats.get(key)\n if (!format) {\n format = new Intl.NumberFormat(locale)\n numberFormats.set(key, format)\n }\n const category = rules.select(count) as keyof PluralForms\n const form = (count === 0 && forms.zero) || forms[category] || forms.other\n return form.replace(/#/g, format.format(count))\n}\n\nexport interface TemplateOptions {\n /**\n * What to put where a value is missing (`undefined` or `null`): a string,\n * or a function of the key. Defaults to keeping the placeholder as it is.\n */\n missing?: string | ((key: string) => string)\n}\n\n/**\n * Fill `{placeholders}` with values, including nested paths:\n * `template('Hola {user.name}, tienes {count}', { user: { name: 'Ana' }, count: 3 })`\n * → `'Hola Ana, tienes 3'`. Write `{{` and `}}` for literal braces.\n */\nexport const template = (\n input: string,\n values: Readonly<Record<string, unknown>>,\n { missing }: TemplateOptions = {}\n): string =>\n String(input ?? '').replace(\n /\\{\\{|\\}\\}|\\{\\s*([^{}\\s]+)\\s*\\}/g,\n (match: string, path: string | undefined) => {\n if (path === undefined) return match[0]!\n let value: unknown = values\n for (const key of path.split('.')) {\n value =\n value !== null &&\n typeof value === 'object' &&\n Object.prototype.hasOwnProperty.call(value, key)\n ? (value as Record<string, unknown>)[key]\n : undefined\n }\n if (value !== undefined && value !== null) return String(value)\n if (missing === undefined) return match\n return typeof missing === 'function' ? missing(path) : missing\n }\n )\n","const ESCAPES: Record<string, string> = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": ''',\n}\n\n/** Make text safe inside HTML text and quoted attributes: `<b>` → `<b>`. */\nexport const escapeHtml = (input: string): string =>\n String(input ?? '').replace(/[&<>\"']/g, char => ESCAPES[char]!)\n\nconst NAMED: Record<string, string> = {\n amp: '&',\n lt: '<',\n gt: '>',\n quot: '\"',\n apos: \"'\",\n nbsp: ' ',\n copy: '©',\n reg: '®',\n hellip: '…',\n mdash: '—',\n ndash: '–',\n laquo: '«',\n raquo: '»',\n}\n\nconst fromCodePoint = (code: number, entity: string) =>\n Number.isInteger(code) && code > 0 && code <= 0x10ffff && (code < 0xd800 || code > 0xdfff)\n ? String.fromCodePoint(code)\n : entity\n\n/**\n * Decode numeric entities (`'`, `'`) and the common named ones\n * (`&`, ` `, `…`…). Unknown entities are left as they are.\n */\nexport const unescapeHtml = (input: string): string =>\n String(input ?? '').replace(/&(#x[\\da-f]+|#\\d+|[a-z]+);/gi, (entity, body: string) => {\n if (body[0] !== '#') return NAMED[body.toLowerCase()] ?? entity\n const hex = body[1] === 'x' || body[1] === 'X'\n return fromCodePoint(parseInt(body.slice(hex ? 2 : 1), hex ? 16 : 10), entity)\n })\n\nconst BLOCK =\n /<\\/?(?:p|div|br|li|ul|ol|h[1-6]|tr|td|th|table|section|article|header|footer|blockquote|pre|hr)\\b[^>]*>/gi\n\n/**\n * Plain text from HTML, for excerpts, meta descriptions and search indexes:\n * removes comments, `<script>` and `<style>` with their content and every\n * tag, turns block tags into spaces, decodes entities and collapses spaces.\n *\n * The result is text: insert it with `textContent`. It is not an HTML\n * sanitizer.\n */\nexport const stripTags = (input: string): string =>\n unescapeHtml(\n String(input ?? '')\n .replace(/<!--[\\s\\S]*?-->/g, '')\n .replace(/<(script|style|template|noscript)\\b[\\s\\S]*?<\\/\\1\\s*>/gi, '')\n .replace(BLOCK, ' ')\n .replace(/<[^>]*>/g, '')\n )\n .replace(/\\s+/g, ' ')\n .trim()\n","import { fold } from './search.js'\n\nexport interface HashColorOptions {\n /** Saturation in percent. Defaults to `55`. */\n saturation?: number\n /** Highest lightness in percent. Defaults to `45`. */\n lightness?: number\n /**\n * Minimum contrast ratio of white text on the color; lightness is lowered\n * until it is reached. Defaults to `4.5` (WCAG AA); `0` keeps `lightness`.\n */\n contrast?: number\n}\n\n/** FNV-1a: a small, well-spread 32-bit hash. */\nconst hash = (text: string): number => {\n let value = 0x811c9dc5\n for (let index = 0; index < text.length; index++) {\n value ^= text.charCodeAt(index)\n value = Math.imul(value, 0x01000193)\n }\n return value >>> 0\n}\n\n/** Contrast ratio of white on an HSL color (0–360, 0–100, 0–100). */\nconst whiteContrast = (hue: number, saturation: number, lightness: number): number => {\n const s = saturation / 100\n const l = lightness / 100\n const channel = (n: number) => {\n const k = (n + hue / 30) % 12\n const value = l - s * Math.min(l, 1 - l) * Math.max(-1, Math.min(k - 3, 9 - k, 1))\n return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4\n }\n const luminance = 0.2126 * channel(0) + 0.7152 * channel(8) + 0.0722 * channel(4)\n return 1.05 / (luminance + 0.05)\n}\n\n/**\n * A stable color for a name, for avatars and tags: the same text always gets\n * the same hue, ignoring case, accents and surrounding spaces, and white text\n * on it stays readable. `hashColor('Ana López')` → `'hsl(214 55% 45%)'`.\n */\nexport const hashColor = (\n input: string,\n { saturation = 55, lightness = 45, contrast = 4.5 }: HashColorOptions = {}\n): string => {\n const hue = hash(fold(String(input ?? '').trim())) % 360\n let light = Math.max(0, Math.min(100, lightness))\n while (light > 0 && whiteContrast(hue, saturation, light) < contrast) light--\n return `hsl(${hue} ${saturation}% ${light}%)`\n}\n","/** True when a DOM is available. Never touch `window` or `document` at import time. */\nexport const isBrowser = (): boolean =>\n typeof window !== 'undefined' && typeof document !== 'undefined'\n\n/** No-op used as a safe default callback and cleanup. */\nexport const noop = (): void => {}\n","import { isBrowser } from './env.js'\n\n/** Anything a utility accepts as its target. */\nexport type ElementTarget =\n Element | string | Iterable<Element> | ArrayLike<Element> | null | undefined\n\nconst isElement = (value: unknown): value is Element =>\n typeof Element !== 'undefined' && value instanceof Element\n\n/**\n * Normalize a target into a de-duplicated array of elements.\n *\n * - `Element` → `[element]`\n * - CSS selector → every match inside `root` (defaults to `document`)\n * - `NodeList`, `HTMLCollection`, arrays and other iterables → their elements\n * - `null`, `undefined`, unknown values, or no DOM → `[]`\n */\nexport const resolveElements = (\n target: ElementTarget,\n root: ParentNode | null = isBrowser() ? document : null\n): Element[] => {\n if (target == null) return []\n if (isElement(target)) return [target]\n\n if (typeof target === 'string') {\n if (!root) return []\n return Array.from(root.querySelectorAll(target))\n }\n\n const source =\n typeof (target as Iterable<Element>)[Symbol.iterator] === 'function'\n ? Array.from(target as Iterable<Element>)\n : Array.from(target as ArrayLike<Element>)\n\n return Array.from(new Set(source.filter(isElement)))\n}\n","/**\n * Typed readers for `data-*` options, so every utility can be configured from\n * plain HTML in the same way.\n *\n * Each reader gets the attribute's full name (`data-reveal-delay`) and a\n * fallback. An absent attribute always returns the fallback.\n */\n\nconst read = (el: Element, name: string): string | null =>\n el.hasAttribute(name) ? el.getAttribute(name) : null\n\n/** Present-but-empty attributes return the fallback: they are markers, not values. */\nexport const readString = (el: Element, name: string, fallback: string): string => {\n const raw = read(el, name)\n return raw === null || raw.trim() === '' ? fallback : raw.trim()\n}\n\n/**\n * Boolean attributes follow HTML semantics: present, empty, `\"true\"` or the\n * attribute's own name mean true. `\"false\"` means false. Anything else returns\n * the fallback.\n */\nexport const readBoolean = (el: Element, name: string, fallback: boolean): boolean => {\n const raw = read(el, name)\n if (raw === null) return fallback\n const value = raw.trim().toLowerCase()\n if (value === '' || value === 'true' || value === name.toLowerCase()) return true\n if (value === 'false') return false\n return fallback\n}\n\n/** Finite numbers only. `NaN`, `Infinity` and empty values return the fallback. */\nexport const readNumber = (el: Element, name: string, fallback: number): number => {\n const raw = read(el, name)\n if (raw === null || raw.trim() === '') return fallback\n const value = Number(raw)\n return Number.isFinite(value) ? value : fallback\n}\n\n/**\n * `\"100\"` → `[100, 100]`, `\"100 200\"` or `\"100,200\"` → `[100, 200]`.\n * Useful for `[enter, leave]` style options.\n */\nexport const readNumberPair = (\n el: Element,\n name: string,\n fallback: readonly [number, number]\n): [number, number] => {\n const raw = read(el, name)\n if (raw === null) return [fallback[0], fallback[1]]\n const parts = raw\n .split(/[\\s,]+/)\n .filter(Boolean)\n .map(Number)\n .filter(Number.isFinite)\n if (parts.length === 1) return [parts[0]!, parts[0]!]\n if (parts.length >= 2) return [parts[0]!, parts[1]!]\n return [fallback[0], fallback[1]]\n}\n\n/** Returns the value only when it is one of `allowed`. */\nexport const readEnum = <T extends string>(\n el: Element,\n name: string,\n allowed: readonly T[],\n fallback: T\n): T => {\n const raw = read(el, name)?.trim()\n return raw !== undefined && (allowed as readonly string[]).includes(raw) ? (raw as T) : fallback\n}\n","import { isBrowser, noop } from './env.js'\n\nexport const REDUCED_MOTION_QUERY = '(prefers-reduced-motion: reduce)'\n\nconst getQuery = (): MediaQueryList | null =>\n isBrowser() && typeof window.matchMedia === 'function'\n ? window.matchMedia(REDUCED_MOTION_QUERY)\n : null\n\n/** True when the visitor asked the system to reduce motion. False without a DOM. */\nexport const prefersReducedMotion = (): boolean => getQuery()?.matches ?? false\n\n/** Call `listener` whenever the preference changes. Returns an unsubscribe function. */\nexport const onReducedMotionChange = (listener: (reduced: boolean) => void): (() => void) => {\n const query = getQuery()\n if (!query) return noop\n const handler = (event: MediaQueryListEvent) => listener(event.matches)\n query.addEventListener('change', handler)\n return () => query.removeEventListener('change', handler)\n}\n","import { isBrowser, noop } from './env.js'\n\nexport type Cleanup = () => void\n\nexport interface AutoInitOptions {\n /** Elements to initialize, for example `[data-reveal]`. */\n selector: string\n /** Initialize one element. Return a cleanup to run when it is removed or on destroy. */\n init: (element: Element) => Cleanup | void\n /** Where to look. Defaults to `document`. */\n root?: ParentNode\n /**\n * Watch `root` for elements added or removed later (AJAX content, framework\n * swaps, drawers). Defaults to true.\n */\n observe?: boolean\n}\n\nexport interface AutoInitController {\n /** Initialize matching elements that are not initialized yet. */\n refresh: () => void\n /** Run every cleanup and stop watching. */\n destroy: () => void\n}\n\n/**\n * Initialize every element matching `selector` exactly once, pick up elements\n * added later, and clean up elements that leave the DOM.\n *\n * Safe to call without a DOM: it returns an inert controller.\n */\nexport const autoInit = ({\n selector,\n init,\n root,\n observe = true,\n}: AutoInitOptions): AutoInitController => {\n if (!isBrowser()) return { refresh: noop, destroy: noop }\n\n const scope: ParentNode = root ?? document\n const cleanups = new Map<Element, Cleanup>()\n\n const initOne = (element: Element) => {\n if (cleanups.has(element)) return\n cleanups.set(element, init(element) ?? noop)\n }\n\n const destroyOne = (element: Element) => {\n const cleanup = cleanups.get(element)\n if (!cleanup) return\n cleanups.delete(element)\n cleanup()\n }\n\n const forEachMatch = (node: Node, callback: (element: Element) => void) => {\n if (!(node instanceof Element)) return\n if (node.matches(selector)) callback(node)\n node.querySelectorAll(selector).forEach(callback)\n }\n\n const refresh = () => scope.querySelectorAll(selector).forEach(initOne)\n\n let observer: MutationObserver | null = null\n\n if (observe && typeof MutationObserver === 'function') {\n observer = new MutationObserver(mutations => {\n for (const mutation of mutations) {\n mutation.removedNodes.forEach(node =>\n forEachMatch(node, element => {\n // A node moved inside the same document is removed and re-added in\n // one batch; only clean up elements that really left.\n if (!element.isConnected) destroyOne(element)\n })\n )\n mutation.addedNodes.forEach(node => forEachMatch(node, initOne))\n }\n })\n const target = scope instanceof Document ? scope.documentElement : (scope as Node)\n observer.observe(target, { childList: true, subtree: true })\n }\n\n refresh()\n\n return {\n refresh,\n destroy: () => {\n observer?.disconnect()\n observer = null\n Array.from(cleanups.keys()).forEach(destroyOne)\n },\n }\n}\n","import {\n autoInit,\n isBrowser,\n noop,\n resolveElements,\n type AutoInitController,\n type ElementTarget,\n} from '@samline/internal'\n\nexport interface Controller {\n /** Read the attributes again and update. */\n refresh: () => void\n /** Remove listeners and restore the original markup. Safe to call twice. */\n destroy: () => void\n}\n\nexport interface AutoOptions {\n /** Elements to start. Defaults to the behavior's attribute. */\n selector?: string\n /** Where to look. Defaults to `document`. */\n scope?: ParentNode\n /** Pick up elements added later and clean up removed ones. Defaults to `true`. */\n observe?: boolean\n}\n\n/** Bind every element of `target` and combine their controllers. Inert without a DOM. */\nexport const bindAll =\n <O>(selector: string, bind: (element: HTMLElement, options: O) => Controller | null) =>\n (target: ElementTarget = selector, options = {} as O): Controller => {\n if (!isBrowser()) return { refresh: noop, destroy: noop }\n const controllers = resolveElements(target)\n .filter((element): element is HTMLElement => element instanceof HTMLElement)\n .map(element => bind(element, options))\n .filter((controller): controller is Controller => controller !== null)\n return {\n refresh: () => controllers.forEach(controller => controller.refresh()),\n destroy: () => controllers.forEach(controller => controller.destroy()),\n }\n }\n\n/** The `auto*()` version of a behavior: every match in `scope`, now and later. */\nexport const autoAll =\n <O>(selector: string, run: (target: ElementTarget, options: O) => Controller) =>\n (\n {\n selector: chosen = selector,\n scope,\n observe = true,\n ...options\n }: AutoOptions & O = {} as AutoOptions & O\n ): AutoInitController =>\n autoInit({\n selector: chosen,\n observe,\n ...(scope && { root: scope }),\n init: element => run(element, options as O).destroy,\n })\n\n/** Restore an element's original child nodes, keeping element identity. */\nexport const snapshot = (element: Element) => {\n const nodes = Array.from(element.childNodes)\n return () => element.replaceChildren(...nodes)\n}\n\n/** Track attributes we set, so the author's own values win and ours are removed on destroy. */\nexport const attributes = (element: Element) => {\n const authored = new Map<string, string | null>()\n return {\n set: (name: string, value: string | null) => {\n if (!authored.has(name)) authored.set(name, element.getAttribute(name))\n if (authored.get(name) !== null) return\n if (value === null) element.removeAttribute(name)\n else element.setAttribute(name, value)\n },\n restore: () =>\n authored.forEach((before, name) => before === null && element.removeAttribute(name)),\n }\n}\n\n/** Locale from an attribute, an option or the closest `lang`. */\nexport const localeOf = (element: Element, attribute: string, option?: string | string[]) =>\n element.getAttribute(attribute)?.trim() ||\n option ||\n element.closest('[lang]')?.getAttribute('lang') ||\n undefined\n\n/** Text of a field or an element. */\nexport const textOf = (element: Element): string =>\n element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement\n ? element.value\n : (element.textContent ?? '')\n","import { readNumber, readString, resolveElements, type ElementTarget } from '@samline/internal'\n\nimport { convert, isConversion, type Conversion, type ConvertOptions } from '../core/convert.js'\nimport { autoAll, bindAll, textOf, type AutoOptions, type Controller } from './controller.js'\n\nexport const COPY_ATTRIBUTE = 'data-string-copy'\nexport const COPY_STATE_ATTRIBUTE = 'data-string-copy-state'\nexport const COPY_EVENT = 'string:copy'\n\n/** `copied` or `error` for `reset` milliseconds after a click. */\nexport type CopyState = 'copied' | 'error'\n\nexport interface CopyDetail {\n value: string\n ok: boolean\n}\n\nexport interface CopyOptions extends ConvertOptions {\n /** Element or field whose text is copied. `data-string-copy=\"#title\"` wins. */\n source?: ElementTarget\n /** Conversion applied before copying. `data-string-copy-as=\"kebab\"` wins. */\n as?: Conversion\n /** Milliseconds before the state is cleared. Defaults to `2000`. */\n reset?: number\n /** Called after every copy attempt. */\n onCopy?: (detail: CopyDetail, button: HTMLElement) => void\n}\n\nexport type AutoCopyOptions = CopyOptions & AutoOptions\n\nconst bindCopy = (button: HTMLElement, options: CopyOptions): Controller | null => {\n const {\n source: sourceOption,\n as: asOption,\n reset: resetOption,\n onCopy,\n ...convertOptions\n } = options\n let timer: ReturnType<typeof setTimeout> | undefined\n\n const finish = (detail: CopyDetail) => {\n clearTimeout(timer)\n button.setAttribute(COPY_STATE_ATTRIBUTE, detail.ok ? 'copied' : 'error')\n const reset = readNumber(button, `${COPY_ATTRIBUTE}-reset`, resetOption ?? 2000)\n timer = setTimeout(() => button.removeAttribute(COPY_STATE_ATTRIBUTE), reset)\n onCopy?.(detail, button)\n button.dispatchEvent(new CustomEvent(COPY_EVENT, { bubbles: true, detail }))\n }\n\n const onClick = async () => {\n const source = resolveElements(readString(button, COPY_ATTRIBUTE, '') || sourceOption)[0]\n const raw = source ? textOf(source) : ''\n const name = readString(button, `${COPY_ATTRIBUTE}-as`, '')\n const as = isConversion(name) ? name : asOption\n const value = as ? convert(raw, as, convertOptions) : raw\n try {\n if (!source || !navigator.clipboard) throw new Error('No source or clipboard')\n await navigator.clipboard.writeText(value)\n finish({ value, ok: true })\n } catch {\n finish({ value, ok: false })\n }\n }\n\n button.addEventListener('click', onClick)\n\n let alive = true\n return {\n refresh: () => {},\n destroy: () => {\n if (!alive) return\n alive = false\n clearTimeout(timer)\n button.removeEventListener('click', onClick)\n button.removeAttribute(COPY_STATE_ATTRIBUTE)\n },\n }\n}\n\n/**\n * Copy another element's text, converted, to the clipboard:\n * `<button data-string-copy=\"#title\" data-string-copy-as=\"kebab\">Copy</button>`.\n * The button gets `data-string-copy-state=\"copied\"` (or `error`) for two seconds.\n */\nexport const copy = bindAll<CopyOptions>(`[${COPY_ATTRIBUTE}]`, bindCopy)\n\n/** Start every `[data-string-copy]` button in `scope`, including buttons added later. */\nexport const autoCopy = autoAll<CopyOptions>(`[${COPY_ATTRIBUTE}]`, copy)\n","import {\n readEnum,\n readNumber,\n readString,\n resolveElements,\n type ElementTarget,\n} from '@samline/internal'\n\nimport { graphemes } from '../core/graphemes.js'\nimport { template, wordCount } from '../core/prose.js'\nimport {\n autoAll,\n bindAll,\n localeOf,\n snapshot,\n type AutoOptions,\n type Controller,\n} from './controller.js'\n\nexport const COUNT_ATTRIBUTE = 'data-string-count'\nexport const COUNT_STATE_ATTRIBUTE = 'data-string-count-state'\nexport const COUNT_EVENT = 'string:count'\n\n/** `ok` below `near`, `near` when few are left, `over` past `max`. */\nexport type CountState = 'ok' | 'near' | 'over'\nexport type CountUnit = 'characters' | 'words'\n\nexport interface CountInfo {\n count: number\n /** `undefined` without a maximum. */\n max: number | undefined\n /** `max - count`, negative when over; `undefined` without a maximum. */\n remaining: number | undefined\n state: CountState\n}\n\nexport interface CountOptions {\n /** The field to count. `data-string-count=\"#bio\"` wins over this option. */\n field?: ElementTarget\n /** Count characters (graphemes, so 😀 is one) or words. Defaults to `'characters'`. */\n unit?: CountUnit\n /** Maximum. Defaults to the field's `maxlength`, if any. */\n max?: number\n /** Remaining count at which the state becomes `near`. Defaults to 10% of `max`. */\n near?: number\n /**\n * Text shown: a template with `{count}`, `{max}` and `{remaining}`, or a\n * function. Defaults to `'{remaining}'` with a maximum and `'{count}'` without.\n */\n format?: string | ((info: CountInfo) => string)\n /** Locale for word boundaries. */\n locale?: string | string[]\n /** Called after every update. */\n onCount?: (info: CountInfo, element: HTMLElement) => void\n}\n\nexport type AutoCountOptions = CountOptions & AutoOptions\n\nconst UNITS = ['characters', 'words'] as const\n\nconst bindCount = (output: HTMLElement, options: CountOptions): Controller | null => {\n const attr = (name: string) => `${COUNT_ATTRIBUTE}-${name}`\n const field = resolveElements(readString(output, COUNT_ATTRIBUTE, '') || options.field)[0]\n if (!(field instanceof HTMLInputElement || field instanceof HTMLTextAreaElement)) return null\n\n const restoreChildren = snapshot(output)\n\n const update = () => {\n const unit = readEnum(output, attr('unit'), UNITS, options.unit ?? 'characters')\n const locale = localeOf(output, attr('locale'), options.locale)\n const count =\n unit === 'words'\n ? wordCount(field.value, locale ? { locale } : {})\n : graphemes(field.value).length\n const fallbackMax = options.max ?? (field.maxLength > 0 ? field.maxLength : NaN)\n const rawMax = readNumber(output, attr('max'), fallbackMax)\n const max = Number.isFinite(rawMax) && rawMax >= 0 ? rawMax : undefined\n const remaining = max === undefined ? undefined : max - count\n const near = readNumber(output, attr('near'), options.near ?? Math.ceil((max ?? 0) * 0.1))\n const state: CountState =\n remaining === undefined ? 'ok' : remaining < 0 ? 'over' : remaining <= near ? 'near' : 'ok'\n const info: CountInfo = { count, max, remaining, state }\n\n const format = output.hasAttribute(attr('format'))\n ? (output.getAttribute(attr('format')) ?? '')\n : (options.format ?? (max === undefined ? '{count}' : '{remaining}'))\n output.textContent =\n typeof format === 'function'\n ? format(info)\n : template(format, { count, max, remaining }, { missing: '' })\n output.setAttribute(COUNT_STATE_ATTRIBUTE, state)\n options.onCount?.(info, output)\n output.dispatchEvent(new CustomEvent(COUNT_EVENT, { bubbles: true, detail: info }))\n }\n\n field.addEventListener('input', update)\n update()\n\n let alive = true\n return {\n refresh: () => alive && update(),\n destroy: () => {\n if (!alive) return\n alive = false\n field.removeEventListener('input', update)\n restoreChildren()\n output.removeAttribute(COUNT_STATE_ATTRIBUTE)\n },\n }\n}\n\n/**\n * Show how many characters or words a field has, or how many are left:\n * `<textarea id=\"bio\" maxlength=\"160\"></textarea>\n * <output data-string-count=\"#bio\"></output>`.\n */\nexport const count = bindAll<CountOptions>(`[${COUNT_ATTRIBUTE}]`, bindCount)\n\n/** Start every `[data-string-count]` element in `scope`, including elements added later. */\nexport const autoCount = autoAll<CountOptions>(`[${COUNT_ATTRIBUTE}]`, count)\n","import { readEnum } from '@samline/internal'\n\nimport { graphemes } from '../core/graphemes.js'\nimport { truncate, type TruncatePosition } from '../core/text.js'\nimport {\n attributes,\n autoAll,\n bindAll,\n snapshot,\n type AutoOptions,\n type Controller,\n} from './controller.js'\n\nexport const FIT_ATTRIBUTE = 'data-string-fit'\nexport const FIT_STATE_ATTRIBUTE = 'data-string-fit-state'\n\n/** `full` when the whole text fits, `truncated` when it was shortened. */\nexport type FitState = 'full' | 'truncated'\n\nexport interface FitOptions {\n /** Where the text is cut. `data-string-fit=\"end\"` wins. Defaults to `'middle'`. */\n position?: TruncatePosition\n /** Defaults to `'…'`. */\n ellipsis?: string\n}\n\nexport type AutoFitOptions = FitOptions & AutoOptions\n\nconst POSITIONS = ['end', 'middle', 'start'] as const\n\nconst bindFit = (element: HTMLElement, options: FitOptions): Controller | null => {\n const restoreChildren = snapshot(element)\n const managed = attributes(element)\n const text = element.textContent ?? ''\n const styleBefore = element.getAttribute('style')\n let alive = true\n element.style.whiteSpace = 'nowrap'\n element.style.overflow = 'hidden'\n\n const fits = () => element.scrollWidth <= element.clientWidth\n\n const fit = () => {\n const position = readEnum(element, FIT_ATTRIBUTE, POSITIONS, options.position ?? 'middle')\n const ellipsis = element.hasAttribute(`${FIT_ATTRIBUTE}-ellipsis`)\n ? (element.getAttribute(`${FIT_ATTRIBUTE}-ellipsis`) ?? '')\n : (options.ellipsis ?? '…')\n if (element.textContent !== text) element.textContent = text\n // Without a width (inline or hidden elements) there is nothing to fit.\n if (element.clientWidth === 0 || fits()) {\n element.setAttribute(FIT_STATE_ATTRIBUTE, 'full')\n managed.set('title', null)\n return\n }\n // Binary search for the longest text that fits.\n let low = 0\n let high = graphemes(text).length - 1\n let best = truncate(text, 0, { position, ellipsis, wordBoundary: false })\n while (low <= high) {\n const middle = Math.floor((low + high) / 2)\n const candidate = truncate(text, middle, { position, ellipsis, wordBoundary: false })\n element.textContent = candidate\n if (fits()) {\n best = candidate\n low = middle + 1\n } else high = middle - 1\n }\n element.textContent = best\n element.setAttribute(FIT_STATE_ATTRIBUTE, 'truncated')\n managed.set('title', text)\n }\n\n let frame = 0\n const schedule = () => {\n cancelAnimationFrame(frame)\n frame = requestAnimationFrame(fit)\n }\n let observer: ResizeObserver | null = null\n if (typeof ResizeObserver === 'function') {\n observer = new ResizeObserver(schedule)\n observer.observe(element)\n } else {\n window.addEventListener('resize', schedule)\n }\n // Web fonts change text width once they load.\n void element.ownerDocument.fonts?.ready.then(() => alive && fit())\n fit()\n\n return {\n refresh: () => alive && fit(),\n destroy: () => {\n if (!alive) return\n alive = false\n cancelAnimationFrame(frame)\n observer?.disconnect()\n window.removeEventListener('resize', schedule)\n restoreChildren()\n managed.restore()\n if (styleBefore === null) element.removeAttribute('style')\n else element.setAttribute('style', styleBefore)\n element.removeAttribute(FIT_STATE_ATTRIBUTE)\n },\n }\n}\n\n/**\n * Shorten text to fit its element's width, cutting in the middle by\n * default, and fit again when the width changes:\n * `<span data-string-fit style=\"display: block\">annual-report-2026-final.pdf</span>`.\n * The element needs a width (block, inline-block, flex or grid item).\n */\nexport const fit = bindAll<FitOptions>(`[${FIT_ATTRIBUTE}]`, bindFit)\n\n/** Start every `[data-string-fit]` element in `scope`, including elements added later. */\nexport const autoFit = autoAll<FitOptions>(`[${FIT_ATTRIBUTE}]`, fit)\n","import {\n autoInit,\n isBrowser,\n noop,\n readBoolean,\n readNumber,\n readString,\n resolveElements,\n type AutoInitController,\n type ElementTarget,\n} from '@samline/internal'\n\nimport { contains, highlight, type MatchOptions } from '../core/search.js'\n\nexport const SEARCH_ATTRIBUTE = 'data-string-search'\nexport const SEARCH_STATE_ATTRIBUTE = 'data-string-search-state'\nexport const SEARCH_EMPTY_ATTRIBUTE = 'data-string-search-empty'\nexport const SEARCH_EVENT = 'string:search'\n\n/**\n * - `idle`: the query is shorter than `min`; every item is shown.\n * - `results`: at least one item matches.\n * - `empty`: nothing matches; the empty message is shown.\n */\nexport type SearchState = 'idle' | 'results' | 'empty'\n\nexport interface SearchResult {\n query: string\n /** Items that match, in document order. */\n matches: HTMLElement[]\n /** Number of items searched. */\n total: number\n state: SearchState\n}\n\nexport interface SearchOptions extends MatchOptions {\n /** The search field. `data-string-search=\"#q\"` wins over this option. */\n input?: ElementTarget\n /** Selector for the items inside the list. Defaults to its direct children. */\n items?: string\n /** Wrap matching text in `<mark>`. Defaults to `true`. */\n highlight?: boolean\n /** Shortest query that filters, in characters. Defaults to `1`. */\n min?: number\n /** Element shown when nothing matches. Defaults to a `[data-string-search-empty]` child. */\n empty?: ElementTarget\n /** Called after every search. */\n onSearch?: (result: SearchResult, list: HTMLElement) => void\n}\n\nexport interface SearchController {\n /** Collect the items again (after adding or removing some) and search again. */\n refresh: () => void\n /** Remove listeners and marks and show every item as it was. Safe to call twice. */\n destroy: () => void\n}\n\nexport interface AutoSearchOptions extends SearchOptions {\n /** Lists to filter. Defaults to `[data-string-search]`. */\n selector?: string\n /** Where to look. Defaults to `document`. */\n scope?: ParentNode\n /** Pick up lists added later and clean up removed ones. Defaults to `true`. */\n observe?: boolean\n}\n\ninterface MarkRecord {\n original: Text\n nodes: Node[]\n}\n\nconst textNodes = (root: Node): Text[] => {\n const walker = root.ownerDocument!.createTreeWalker(root, NodeFilter.SHOW_TEXT)\n const nodes: Text[] = []\n for (let node = walker.nextNode(); node; node = walker.nextNode()) nodes.push(node as Text)\n return nodes\n}\n\nconst bindSearch = (list: HTMLElement, options: SearchOptions): SearchController | null => {\n const attr = (name: string) => `${SEARCH_ATTRIBUTE}-${name}`\n const selector = readString(list, SEARCH_ATTRIBUTE, '')\n const input = resolveElements(selector || options.input)[0]\n if (!(input instanceof HTMLInputElement || input instanceof HTMLTextAreaElement)) return null\n\n const doc = list.ownerDocument\n const authoredHidden = new Map<HTMLElement, boolean>()\n let marks: MarkRecord[] = []\n let items: HTMLElement[] = []\n let empty: HTMLElement | null = null\n\n const settings = () => {\n const locale =\n readString(list, attr('locale'), '') ||\n options.locale ||\n list.closest('[lang]')?.getAttribute('lang') ||\n ''\n const match: MatchOptions = {\n split: readBoolean(list, attr('split'), options.split ?? true),\n ...(locale && { locale }),\n }\n return {\n match,\n mark: readBoolean(list, attr('highlight'), options.highlight ?? true),\n min: Math.max(1, readNumber(list, attr('min'), options.min ?? 1)),\n items: readString(list, attr('items'), options.items ?? ''),\n }\n }\n\n const remember = (element: HTMLElement) => {\n if (!authoredHidden.has(element)) authoredHidden.set(element, element.hidden)\n }\n\n const collect = () => {\n const { items: itemSelector } = settings()\n const found = itemSelector\n ? Array.from(list.querySelectorAll<HTMLElement>(itemSelector))\n : (Array.from(list.children) as HTMLElement[])\n const emptyOption = resolveElements(options.empty)[0]\n empty =\n list.querySelector<HTMLElement>(`[${SEARCH_EMPTY_ATTRIBUTE}]`) ??\n (emptyOption instanceof HTMLElement ? emptyOption : null)\n items = found.filter(\n item => item instanceof HTMLElement && item !== empty && !item.contains(empty)\n )\n items.forEach(remember)\n if (empty) remember(empty)\n // Items the author hid stay hidden and are not searched.\n items = items.filter(item => !authoredHidden.get(item))\n }\n\n const clearMarks = () => {\n for (const { original, nodes } of marks) {\n const first = nodes[0]\n if (first?.parentNode) first.parentNode.insertBefore(original, first)\n nodes.forEach(node => node.parentNode?.removeChild(node))\n }\n marks = []\n }\n\n const markItem = (item: HTMLElement, query: string, match: MatchOptions) => {\n for (const node of textNodes(item)) {\n const segments = highlight(node.data, query, match)\n if (!segments.some(segment => segment.match)) continue\n const nodes = segments.map(segment => {\n if (!segment.match) return doc.createTextNode(segment.text)\n const mark = doc.createElement('mark')\n mark.textContent = segment.text\n return mark\n })\n const parent = node.parentNode!\n nodes.forEach(created => parent.insertBefore(created, node))\n parent.removeChild(node)\n marks.push({ original: node, nodes })\n }\n }\n\n const search = () => {\n const { match, mark, min } = settings()\n const query = input.value\n clearMarks()\n const active = Array.from(query.trim()).length >= min\n const matches = items.filter(item => {\n const visible = !active || contains(item.textContent ?? '', query, match)\n item.hidden = visible ? authoredHidden.get(item)! : true\n if (visible && active && mark) markItem(item, query, match)\n return visible && active\n })\n const state: SearchState = !active ? 'idle' : matches.length > 0 ? 'results' : 'empty'\n list.setAttribute(SEARCH_STATE_ATTRIBUTE, state)\n if (empty) empty.hidden = state !== 'empty'\n const result: SearchResult = {\n query,\n matches: active ? matches : [...items],\n total: items.length,\n state,\n }\n options.onSearch?.(result, list)\n list.dispatchEvent(new CustomEvent(SEARCH_EVENT, { bubbles: true, detail: result }))\n }\n\n input.addEventListener('input', search)\n collect()\n search()\n\n let alive = true\n return {\n refresh: () => {\n if (!alive) return\n clearMarks()\n collect()\n search()\n },\n destroy: () => {\n if (!alive) return\n alive = false\n input.removeEventListener('input', search)\n clearMarks()\n authoredHidden.forEach((hidden, element) => (element.hidden = hidden))\n list.removeAttribute(SEARCH_STATE_ATTRIBUTE)\n },\n }\n}\n\n/**\n * Filter a list as the user types, ignoring accents and case, and highlight\n * the matching text.\n *\n * ```html\n * <input id=\"q\" type=\"search\" />\n * <ul data-string-search=\"#q\">\n * <li>Café de olla</li>\n * <li hidden data-string-search-empty>No results</li>\n * </ul>\n * ```\n *\n * Items that do not match get `hidden`; matches are wrapped in `<mark>`.\n * Returns `{ refresh, destroy }`. Without a DOM it does nothing.\n */\nexport const search = (\n target: ElementTarget = `[${SEARCH_ATTRIBUTE}]`,\n options: SearchOptions = {}\n): SearchController => {\n if (!isBrowser()) return { refresh: noop, destroy: noop }\n const controllers = resolveElements(target)\n .filter((element): element is HTMLElement => element instanceof HTMLElement)\n .map(element => bindSearch(element, options))\n .filter((controller): controller is SearchController => controller !== null)\n return {\n refresh: () => controllers.forEach(controller => controller.refresh()),\n destroy: () => controllers.forEach(controller => controller.destroy()),\n }\n}\n\n/** Filter every `[data-string-search]` list in `scope`, including lists added later. */\nexport const autoSearch = ({\n selector = `[${SEARCH_ATTRIBUTE}]`,\n scope,\n observe = true,\n ...options\n}: AutoSearchOptions = {}): AutoInitController =>\n autoInit({\n selector,\n observe,\n ...(scope && { root: scope }),\n init: element => search(element, options).destroy,\n })\n","import {\n autoInit,\n isBrowser,\n noop,\n readBoolean,\n readEnum,\n readNumber,\n readString,\n resolveElements,\n type AutoInitController,\n type ElementTarget,\n} from '@samline/internal'\n\nimport { CHAR_MAPS, type CharMapName } from '../core/charmaps.js'\nimport { hashColor, type HashColorOptions } from '../core/color.js'\nimport { convert, isConversion, type Conversion, type ConvertOptions } from '../core/convert.js'\n\nexport type { AutoInitController, ElementTarget }\n\nexport const ATTRIBUTE = 'data-string'\nexport const STATE_ATTRIBUTE = 'data-string-state'\nexport const CHANGE_EVENT = 'string:change'\n/** CSS custom property set by `data-string-color`. */\nexport const COLOR_PROPERTY = '--string-color'\n\n/**\n * - `ready`: the element shows its converted text.\n * - `following`: a field copies its converted `source` (a slug that follows the title).\n * - `edited`: the user typed in a field that had a `source`; it no longer follows.\n */\nexport type StringState = 'ready' | 'following' | 'edited'\n\nexport interface StringOptions extends ConvertOptions {\n /** The conversion. `data-string=\"kebab\"` wins over this option. */\n to?: Conversion\n /**\n * An input, textarea or element whose text feeds this element, for example\n * the title that fills a slug field. `data-string-source=\"#title\"`.\n */\n source?: ElementTarget\n /**\n * Convert fields while the user types (separators the user just typed are\n * kept until the field loses focus). Defaults to `true`; `false` converts on\n * blur only. `truncate` and `initials` always wait for blur.\n */\n live?: boolean\n /** Called with the new value after every conversion that changed it. */\n onChange?: (value: string, element: HTMLElement) => void\n /**\n * Set `--string-color` to a stable color for the text (before conversion),\n * for avatar backgrounds: `background: var(--string-color)`. `true` or\n * `hashColor` options. `data-string-color` turns it on.\n */\n color?: boolean | HashColorOptions\n}\n\nexport interface StringController {\n /** Read the attributes again and convert again. */\n refresh: () => void\n /** Remove every listener and restore the original markup. Safe to call twice. */\n destroy: () => void\n}\n\nexport interface AutoStringOptions extends StringOptions {\n /** Elements to convert. Defaults to `[data-string]`. */\n selector?: string\n /** Where to look. Defaults to `document`. */\n scope?: ParentNode\n /** Pick up elements added later and clean up removed ones. Defaults to `true`. */\n observe?: boolean\n}\n\ntype Field = HTMLInputElement | HTMLTextAreaElement\n\nconst POSITIONS = ['end', 'middle', 'start'] as const\n\n/** Separators kept at the end of a field while the user is still typing. */\nconst TYPING_SEPARATOR: Partial<Record<Conversion, string>> = {\n kebab: '-',\n snake: '_',\n dot: '.',\n path: '/',\n constant: '_',\n train: '-',\n camel: ' ',\n pascal: ' ',\n}\n\nconst isField = (element: Element): element is Field =>\n element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement\n\nconst textOf = (element: Element): string =>\n isField(element) ? element.value : (element.textContent ?? '')\n\nconst parseReplacements = (raw: string): Record<string, string> | undefined => {\n try {\n const value: unknown = JSON.parse(raw)\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n return Object.fromEntries(\n Object.entries(value).filter(\n (entry): entry is [string, string] => typeof entry[1] === 'string'\n )\n )\n }\n } catch {\n // Invalid JSON: ignore the attribute.\n }\n return undefined\n}\n\ninterface Config {\n color: HashColorOptions | null\n to: Conversion\n options: ConvertOptions\n source: Element | null\n live: boolean\n}\n\n/** Options from `data-string-*` attributes; attributes win over JavaScript options. */\nconst readConfig = (element: HTMLElement, options: StringOptions): Config | null => {\n const raw = element.getAttribute(ATTRIBUTE)?.trim()\n const to = isConversion(raw) ? raw : options.to\n if (!to) return null\n\n const { to: _to, source: sourceOption, live, onChange: _onChange, color, ...base } = options\n const converted: ConvertOptions = { ...base }\n const attr = (name: string) => `${ATTRIBUTE}-${name}`\n const has = (name: string) => element.hasAttribute(attr(name))\n\n const locale =\n readString(element, attr('locale'), '') ||\n base.locale ||\n element.closest('[lang]')?.getAttribute('lang') ||\n ''\n if (locale) converted.locale = locale\n else delete converted.locale\n\n if (has('separator')) converted.separator = element.getAttribute(attr('separator')) ?? ''\n if (has('lower')) converted.lower = readBoolean(element, attr('lower'), base.lower ?? true)\n if (has('max-length')) {\n const maxLength = readNumber(element, attr('max-length'), NaN)\n if (Number.isFinite(maxLength)) converted.maxLength = maxLength\n }\n if (has('replacements')) {\n const replacements = parseReplacements(element.getAttribute(attr('replacements')) ?? '')\n if (replacements) converted.replacements = replacements\n }\n if (has('preserve')) converted.preserve = element.getAttribute(attr('preserve')) ?? ''\n if (has('transliterate')) {\n const names = readString(element, attr('transliterate'), '').split(/[\\s,]+/)\n const maps = names\n .filter((name): name is CharMapName => name in CHAR_MAPS)\n .map(name => CHAR_MAPS[name])\n if (maps.length) converted.charMap = Object.assign({}, base.charMap, ...maps)\n }\n if (has('taken')) {\n const raw = element.getAttribute(attr('taken')) ?? ''\n let taken: unknown\n try {\n taken = JSON.parse(raw)\n } catch {\n taken = raw.split(/[\\s,]+/)\n }\n if (Array.isArray(taken)) {\n converted.taken = taken.filter(\n (slug): slug is string => typeof slug === 'string' && slug !== ''\n )\n }\n }\n if (has('small-words')) {\n converted.smallWords = readString(element, attr('small-words'), '')\n .split(/[\\s,]+/)\n .filter(Boolean)\n }\n if (has('length')) {\n const length = readNumber(element, attr('length'), NaN)\n if (Number.isFinite(length)) converted.length = length\n }\n if (has('ellipsis')) converted.ellipsis = element.getAttribute(attr('ellipsis')) ?? ''\n if (has('position'))\n converted.position = readEnum(element, attr('position'), POSITIONS, base.position ?? 'end')\n if (has('word-boundary'))\n converted.wordBoundary = readBoolean(element, attr('word-boundary'), true)\n if (has('max')) {\n const max = readNumber(element, attr('max'), NaN)\n if (Number.isFinite(max)) converted.max = max\n }\n\n const sourceSelector = readString(element, attr('source'), '')\n const source = resolveElements(sourceSelector || sourceOption)[0] ?? null\n\n return {\n to,\n options: converted,\n source: source === element ? null : source,\n live: readBoolean(element, attr('live'), live ?? true),\n color: readBoolean(element, attr('color'), Boolean(color))\n ? typeof color === 'object'\n ? color\n : {}\n : null,\n }\n}\n\n/** Live conversion keeps what the user is still typing: a trailing separator. */\nconst convertWhileTyping = (value: string, { to, options }: Config): string => {\n // A free slug is picked on blur, not on every keystroke.\n if (to === 'slug') {\n const { taken: _taken, ...typing } = options\n return convert(value, to, { ...typing, trim: false })\n }\n const separator = TYPING_SEPARATOR[to]\n const result = convert(value, to, options)\n return separator !== undefined && result && /[^\\p{L}\\p{N}]$/u.test(value)\n ? result + separator\n : result\n}\n\nconst bind = (element: HTMLElement, options: StringOptions): StringController | null => {\n let config = readConfig(element, options)\n if (!config) return null\n\n const field = isField(element) ? element : null\n const originalNodes = Array.from(element.childNodes)\n const originalText = textOf(element)\n let detachSource = noop\n let state: StringState = 'ready'\n let composing = false\n\n const setState = (next: StringState) => {\n state = next\n element.setAttribute(STATE_ATTRIBUTE, next)\n }\n\n const notify = (value: string) => {\n options.onChange?.(value, element)\n element.dispatchEvent(\n new CustomEvent(CHANGE_EVENT, { bubbles: true, detail: { value, state } })\n )\n }\n\n /** Attributes the author wrote before we started; theirs always win. */\n const authored = new Map<string, string | null>()\n const describe = (name: string, value: string | null) => {\n if (!authored.has(name)) authored.set(name, element.getAttribute(name))\n if (authored.get(name) !== null) return\n if (value === null) element.removeAttribute(name)\n else element.setAttribute(name, value)\n }\n\n const setFieldValue = (value: string) => {\n if (!field || field.value === value) return\n const focused = field.ownerDocument.activeElement === field\n let fromEnd = 0\n try {\n fromEnd = field.value.length - (field.selectionEnd ?? field.value.length)\n } catch {\n // Inputs like type=\"email\" have no selection API.\n }\n field.value = value\n if (focused) {\n const caret = Math.max(0, value.length - fromEnd)\n try {\n field.setSelectionRange(caret, caret)\n } catch {\n // See above.\n }\n }\n notify(value)\n }\n\n const render = (text: string) => {\n const current = config!\n const output = convert(text, current.to, current.options)\n if (field) return setFieldValue(output)\n if (element.textContent !== output) {\n element.textContent = output\n notify(output)\n }\n // The full text stays available when the visible text is shorter.\n describe('title', current.to === 'truncate' && output !== text ? text : null)\n const label = current.to === 'initials' ? text.trim() : ''\n describe('role', label ? 'img' : null)\n describe('aria-label', label || null)\n if (current.color) element.style.setProperty(COLOR_PROPERTY, hashColor(text, current.color))\n else element.style.removeProperty(COLOR_PROPERTY)\n }\n\n const fromSource = () => config!.source && render(textOf(config!.source))\n\n const onSourceInput = () => {\n if (!field || state === 'following') fromSource()\n }\n\n const onFieldInput = () => {\n if (!field || composing) return\n if (config!.source) {\n if (field.value === '') return setState('following')\n if (state !== 'edited') setState('edited')\n }\n if (config!.live && config!.to !== 'truncate' && config!.to !== 'initials') {\n setFieldValue(convertWhileTyping(field.value, config!))\n }\n }\n\n // blur, not change: Safari skips change when a script edited the value during input.\n const onFieldBlur = () => {\n if (!field) return\n if (config!.source && state === 'following') return fromSource()\n render(field.value)\n }\n\n const onCompositionStart = () => (composing = true)\n const onCompositionEnd = () => {\n composing = false\n onFieldInput()\n }\n\n const attachSource = () => {\n detachSource()\n const source = config!.source\n if (!source) return (detachSource = noop)\n // string:change too, so conversions chain: title → slug field → URL preview.\n source.addEventListener('input', onSourceInput)\n source.addEventListener(CHANGE_EVENT, onSourceInput)\n detachSource = () => {\n source.removeEventListener('input', onSourceInput)\n source.removeEventListener(CHANGE_EVENT, onSourceInput)\n }\n }\n\n const start = () => {\n const current = config!\n attachSource()\n if (field && current.source) {\n const expected = convert(textOf(current.source), current.to, current.options)\n setState(field.value === '' || field.value === expected ? 'following' : 'edited')\n if (state === 'following') fromSource()\n else render(field.value)\n } else {\n setState('ready')\n if (current.source) fromSource()\n else render(field ? field.value : originalText)\n }\n }\n\n if (field) {\n field.addEventListener('input', onFieldInput)\n field.addEventListener('blur', onFieldBlur)\n field.addEventListener('compositionstart', onCompositionStart)\n field.addEventListener('compositionend', onCompositionEnd)\n }\n start()\n\n let active = true\n return {\n refresh: () => {\n if (!active) return\n const next = readConfig(element, options)\n if (!next) return\n config = next\n // A field keeps following, or keeps the user's edit, across refreshes.\n if (field && config.source && state !== 'ready') {\n attachSource()\n return state === 'following' ? fromSource() : render(field.value)\n }\n start()\n },\n destroy: () => {\n if (!active) return\n active = false\n detachSource()\n if (field) {\n field.removeEventListener('input', onFieldInput)\n field.removeEventListener('blur', onFieldBlur)\n field.removeEventListener('compositionstart', onCompositionStart)\n field.removeEventListener('compositionend', onCompositionEnd)\n } else {\n element.replaceChildren(...originalNodes)\n }\n authored.forEach((before, name) => before === null && element.removeAttribute(name))\n element.style.removeProperty(COLOR_PROPERTY)\n if (element.getAttribute('style') === '') element.removeAttribute('style')\n element.removeAttribute(STATE_ATTRIBUTE)\n },\n }\n}\n\n/**\n * Convert text in the page from HTML attributes.\n *\n * - On any element, `data-string=\"kebab\"` replaces its text with the\n * converted text; `destroy()` puts the original markup back.\n * - On an input or textarea, the value is converted as the user types and\n * finalized on blur.\n * - With `data-string-source=\"#title\"`, the element follows another field:\n * a slug field fills itself from the title until the user edits it, and\n * follows again when the user empties it.\n *\n * Returns `{ refresh, destroy }`. Without a DOM it does nothing.\n */\nexport const string = (\n target: ElementTarget = `[${ATTRIBUTE}]`,\n options: StringOptions = {}\n): StringController => {\n if (!isBrowser()) return { refresh: noop, destroy: noop }\n const controllers = resolveElements(target)\n .filter((element): element is HTMLElement => element instanceof HTMLElement)\n .map(element => bind(element, options))\n .filter((controller): controller is StringController => controller !== null)\n return {\n refresh: () => controllers.forEach(controller => controller.refresh()),\n destroy: () => controllers.forEach(controller => controller.destroy()),\n }\n}\n\n/**\n * Convert every `[data-string]` element in `scope`, including elements added\n * later, and clean up elements that are removed.\n */\nexport const autoString = ({\n selector = `[${ATTRIBUTE}]`,\n scope,\n observe = true,\n ...options\n}: AutoStringOptions = {}): AutoInitController =>\n autoInit({\n selector,\n observe,\n ...(scope && { root: scope }),\n init: element => {\n const controller = string(element, options)\n return controller.destroy\n },\n })\n","import * as core from '../core/index.js'\nimport { autoCopy, copy, type AutoCopyOptions } from '../vanilla/copy.js'\nimport { autoCount, count, type AutoCountOptions } from '../vanilla/count.js'\nimport { autoFit, fit, type AutoFitOptions } from '../vanilla/fit.js'\nimport { autoSearch, search, type AutoSearchOptions } from '../vanilla/search.js'\nimport {\n autoString,\n string,\n type AutoInitController,\n type AutoStringOptions,\n} from '../vanilla/string.js'\n\n/**\n * Classic script for pages without a build step. Every function is on\n * `window.SamlineString`. As soon as the DOM is ready it starts every\n * `[data-string]`, `[data-string-search]`, `[data-string-count]`,\n * `[data-string-fit]` and `[data-string-copy]` element, including elements\n * added later. Add `data-manual` to the script tag to start it yourself with\n * `SamlineString.auto()`.\n */\nconst script = typeof document !== 'undefined' ? document.currentScript : null\nconst manual = script?.hasAttribute('data-manual') ?? false\n\nexport interface AutoAllOptions extends AutoStringOptions {\n search?: AutoSearchOptions\n count?: AutoCountOptions\n fit?: AutoFitOptions\n copy?: AutoCopyOptions\n}\n\nlet controller: AutoInitController | null = null\n\nconst api = {\n ...core,\n string,\n autoString,\n search,\n autoSearch,\n count,\n autoCount,\n fit,\n autoFit,\n copy,\n autoCopy,\n /**\n * Start (or restart) every behavior. `scope` and `locale` go to all of\n * them; the other options go to `data-string`, and each behavior takes its\n * own under `search`, `count`, `fit` and `copy`. Returns the controller.\n */\n auto: (options: AutoAllOptions = {}) => {\n controller?.destroy()\n const { search: s, count: c, fit: f, copy: p, ...stringOptions } = options\n const shared = {\n ...(stringOptions.scope && { scope: stringOptions.scope }),\n ...(stringOptions.locale !== undefined && { locale: stringOptions.locale }),\n }\n const { locale: _locale, ...fitShared } = shared\n const running = [\n autoString(stringOptions),\n autoSearch({ ...shared, ...s }),\n autoCount({ ...shared, ...c }),\n autoFit({ ...fitShared, ...f }),\n autoCopy({ ...shared, ...p }),\n ]\n controller = {\n refresh: () => running.forEach(each => each.refresh()),\n destroy: () => running.forEach(each => each.destroy()),\n }\n return controller\n },\n /** The controller of the automatic run, or `null`. */\n get controller() {\n return controller\n },\n}\n\nexport type SamlineStringGlobal = typeof api\n\nconst scope = globalThis as typeof globalThis & { SamlineString?: SamlineStringGlobal }\nscope.SamlineString = api\n\nif (!manual && typeof document !== 'undefined') {\n if (document.readyState === 'loading') {\n // A page script may already have started it with its own options.\n document.addEventListener('DOMContentLoaded', () => controller ?? api.auto(), { once: true })\n } else {\n api.auto()\n }\n}\n\nexport * from '../core/index.js'\nexport { autoCopy, autoCount, autoFit, autoSearch, autoString, copy, count, fit, search, string }\n"],"mappings":"gHAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,eAAAE,EAAA,gBAAAC,GAAA,aAAAC,GAAA,WAAAC,GAAA,UAAAC,GAAA,cAAAC,EAAA,eAAAC,GAAA,YAAAC,GAAA,mBAAAC,GAAA,iBAAAC,GAAA,aAAAC,GAAA,YAAAC,EAAA,aAAAC,GAAA,YAAAC,GAAA,eAAAC,GAAA,SAAAC,EAAA,cAAAC,EAAA,cAAAC,GAAA,cAAAC,GAAA,aAAAC,GAAA,iBAAAC,EAAA,cAAAC,GAAA,eAAAC,GAAA,aAAAC,GAAA,cAAAC,GAAA,gBAAAC,GAAA,kBAAAC,EAAA,iBAAAC,GAAA,eAAAC,GAAA,YAAAC,EAAA,cAAAC,GAAA,cAAAC,GAAA,aAAAC,GAAA,cAAAC,GAAA,cAAAC,GAAA,aAAAC,EAAA,iBAAAC,GAAA,iBAAAC,GAAA,eAAAC,GAAA,cAAAC,EAAA,UAAAC,ICQO,IAAMC,EAASC,GAChB,OAAOA,GAAU,UAAYA,IAAU,GAAW,CAAC,EAErDA,EAEG,QAAQ,kCAAmC,OAAO,EAElD,QAAQ,2BAA4B,OAAO,EAC3C,MAAM,sBAAsB,EAC5B,OAAO,OAAO,EChBrB,IAAMC,GAA2C,CAC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GACA,KAAAC,GACA,SAAAC,GAMA,KAAM,CAACC,EAA0B,CAAC,IAAM,CACtCb,GAAY,QAAQ,EACpB,GAAM,CAAE,OAAQc,EAAG,MAAOC,EAAG,IAAKC,EAAG,KAAMC,EAAG,GAAGC,CAAc,EAAIL,EAC7DM,EAAS,CACb,GAAID,EAAc,OAAS,CAAE,MAAOA,EAAc,KAAM,EACxD,GAAIA,EAAc,SAAW,QAAa,CAAE,OAAQA,EAAc,MAAO,CAC3E,EACM,CAAE,OAAQE,EAAS,GAAGC,CAAU,EAAIF,EACpCG,EAAU,CACdlB,GAAWc,CAAa,EACxBZ,GAAW,CAAE,GAAGa,EAAQ,GAAGL,CAAE,CAAC,EAC9BN,GAAU,CAAE,GAAGW,EAAQ,GAAGJ,CAAE,CAAC,EAC7BL,GAAQ,CAAE,GAAGW,EAAW,GAAGL,CAAE,CAAC,EAC9BJ,GAAS,CAAE,GAAGO,EAAQ,GAAGF,CAAE,CAAC,CAC9B,EACA,OAAAjB,EAAa,CACX,QAAS,IAAMsB,EAAQ,QAAQC,GAAQA,EAAK,QAAQ,CAAC,EACrD,QAAS,IAAMD,EAAQ,QAAQC,GAAQA,EAAK,QAAQ,CAAC,CACvD,EACOvB,CACT,EAEA,IAAI,YAAa,CACf,OAAOA,CACT,CACF,EAIMwB,GAAQ,WACdA,GAAM,cAAgBvB,GAElB,CAACF,IAAU,OAAO,SAAa,MAC7B,SAAS,aAAe,UAE1B,SAAS,iBAAiB,mBAAoB,IAAMC,GAAcC,GAAI,KAAK,EAAG,CAAE,KAAM,EAAK,CAAC,EAE5FA,GAAI,KAAK","names":["core_exports","__export","CHAR_MAPS","CONVERSIONS","CYRILLIC","GERMAN","GREEK","camelCase","capitalize","closest","compareNatural","constantCase","contains","convert","distance","dotCase","escapeHtml","fold","graphemes","hashColor","highlight","initials","isConversion","kebabCase","pascalCase","pathCase","pluralize","readingTime","removeAccents","sentenceCase","similarity","slugify","snakeCase","stripTags","template","titleCase","trainCase","truncate","uncapitalize","unescapeHtml","uniqueSlug","wordCount","words","words","input","TRANSLITERATIONS","SPECIAL","escape","value","patterns","patternFor","map","keys","a","b","pattern","applyMap","key","removeAccents","input","charMap","char","withUpper","lower","map","char","latin","upper","CYRILLIC","GREEK","GERMAN","CHAR_MAPS","lower","value","locale","upper","upperFirst","first","rest","titleWord","camelCase","input","words","word","index","pascalCase","joinLower","separator","kebabCase","snakeCase","dotCase","pathCase","trainCase","constantCase","titleCase","smallWords","small","lowered","sentenceCase","capitalize","uncapitalize","escape","value","slugify","input","separator","lower","replacements","maxLength","trim","locale","charMap","preserve","pairs","from","to","removeAccents","sep","kept","cut","boundary","LIMIT","uniqueSlug","taken","start","options","base","isTaken","set","slug","first","n","suffix","head","candidate","SegmenterImpl","segmenters","segmenter","granularity","locale","key","instance","graphemes","input","text","part","WORD_CHAR","EDGE","TRAILING","LEADING","truncate","input","length","ellipsis","wordBoundary","position","chars","graphemes","room","head","tail","start","cut","firstSpace","lastSpace","initials","max","locale","words","word","CONVERSIONS","isConversion","value","convert","input","to","options","text","locale","caseOptions","camelCase","pascalCase","kebabCase","snakeCase","dotCase","pathCase","constantCase","trainCase","titleCase","sentenceCase","capitalize","uncapitalize","slugify","uniqueSlug","removeAccents","truncate","initials","fold","input","locale","removeAccents","termsOf","query","split","folded","contains","options","terms","text","term","ASCII","highlight","chars","owner","empty","char","index","lower","piece","unit","marked","at","segments","match","last","collators","compareNatural","a","b","sensitivity","key","collator","distance","left","right","previous","_","i","current","j","cost","similarity","shouldFold","longest","PARTIAL_WEIGHT","partialScore","candidate","needle","best","closest","candidates","threshold","partial","foldOptions","prepare","value","bestScore","whole","score","wordCount","input","locale","text","instance","segmenter","count","part","readingTime","wordsPerMinute","options","words","speed","pluralRules","numberFormats","keyOf","pluralize","forms","ordinal","key","rulesKey","rules","format","category","template","values","missing","match","path","value","ESCAPES","escapeHtml","input","char","NAMED","fromCodePoint","code","entity","unescapeHtml","body","hex","BLOCK","stripTags","hash","text","value","index","whiteContrast","hue","saturation","lightness","s","l","channel","n","k","hashColor","input","contrast","fold","light","isBrowser","noop","isElement","value","resolveElements","target","root","source","read","el","name","readString","fallback","raw","readBoolean","readNumber","readEnum","el","name","allowed","fallback","raw","read","autoInit","selector","init","root","observe","isBrowser","noop","scope","cleanups","initOne","element","destroyOne","cleanup","forEachMatch","node","callback","refresh","observer","mutations","mutation","target","bindAll","selector","bind","target","options","isBrowser","noop","controllers","resolveElements","element","controller","autoAll","run","chosen","scope","observe","autoInit","snapshot","nodes","attributes","authored","name","value","before","localeOf","attribute","option","textOf","COPY_ATTRIBUTE","COPY_STATE_ATTRIBUTE","COPY_EVENT","bindCopy","button","options","sourceOption","asOption","resetOption","onCopy","convertOptions","timer","finish","detail","reset","readNumber","onClick","source","resolveElements","readString","raw","textOf","name","as","isConversion","value","convert","alive","copy","bindAll","autoCopy","autoAll","COUNT_ATTRIBUTE","COUNT_STATE_ATTRIBUTE","COUNT_EVENT","UNITS","bindCount","output","options","attr","name","field","resolveElements","readString","restoreChildren","snapshot","update","unit","readEnum","locale","localeOf","count","wordCount","graphemes","fallbackMax","rawMax","readNumber","max","remaining","near","state","info","format","template","alive","bindAll","autoCount","autoAll","FIT_ATTRIBUTE","FIT_STATE_ATTRIBUTE","POSITIONS","bindFit","element","options","restoreChildren","snapshot","managed","attributes","text","styleBefore","alive","fits","fit","position","readEnum","ellipsis","low","high","graphemes","best","truncate","middle","candidate","frame","schedule","observer","bindAll","autoFit","autoAll","SEARCH_ATTRIBUTE","SEARCH_STATE_ATTRIBUTE","SEARCH_EMPTY_ATTRIBUTE","SEARCH_EVENT","textNodes","root","walker","nodes","node","bindSearch","list","options","attr","name","selector","readString","input","resolveElements","doc","authoredHidden","marks","items","empty","settings","locale","readBoolean","readNumber","remember","element","collect","itemSelector","found","emptyOption","item","clearMarks","original","first","markItem","query","match","segments","highlight","segment","mark","parent","created","search","min","active","matches","visible","contains","state","result","alive","hidden","target","isBrowser","noop","controllers","controller","autoSearch","scope","observe","autoInit","ATTRIBUTE","STATE_ATTRIBUTE","CHANGE_EVENT","COLOR_PROPERTY","POSITIONS","TYPING_SEPARATOR","isField","element","textOf","parseReplacements","raw","value","entry","readConfig","options","to","isConversion","_to","sourceOption","live","_onChange","color","base","converted","attr","name","has","locale","readString","readBoolean","maxLength","readNumber","replacements","maps","CHAR_MAPS","taken","slug","length","readEnum","max","sourceSelector","source","resolveElements","convertWhileTyping","_taken","typing","convert","separator","result","bind","config","field","originalNodes","originalText","detachSource","noop","state","composing","setState","next","notify","authored","describe","setFieldValue","focused","fromEnd","caret","render","text","current","output","label","hashColor","fromSource","onSourceInput","onFieldInput","onFieldBlur","onCompositionStart","onCompositionEnd","attachSource","start","expected","active","before","string","target","isBrowser","controllers","controller","autoString","selector","scope","observe","autoInit","script","manual","controller","api","core_exports","string","autoString","search","autoSearch","count","autoCount","fit","autoFit","copy","autoCopy","options","s","c","f","p","stringOptions","shared","_locale","fitShared","running","each","scope"]}
|