import type { ZxcvbnFactory } from '@zxcvbn-ts/core';
let loading: Promise<ZxcvbnFactory> | undefined;
// The dictionaries are ~1MB, so they load on the first keystroke instead of with the page.
export const loadStrength = () =>
(loading ??= Promise.all([
import('@zxcvbn-ts/core'),
import('@zxcvbn-ts/language-common'),
import('@zxcvbn-ts/language-en')
]).then(
([core, common, en]) =>
new core.ZxcvbnFactory({
dictionary: { ...common.dictionary, ...en.dictionary },
graphs: common.adjacencyGraphs,
translations: en.translations
})
));