{"version":3,"file":"index.mjs","names":["createI18n","stripSiteBase","isModuleNamespace","mod","key","value","messagesFromGlob","messages","path","modules","file","code","FormatService","I18nGroup","I18nLink","I18nSwitcher","I18nT","defaultPlural","getLocaleFromPath","interpolate","routeNameFromPath","useI18n"],"sources":["../src/runtime/messages-from-glob.ts"],"sourcesContent":["import type { Translations } from '@i18n-micro/types'\n\n/**\n * Vite `import.meta.glob(..., { eager: true })` modules look like\n * `{ default: { …json } }` or `{ default: { … }, __esModule: true }`.\n * Do not treat a real dictionary that only has a `default` string key as a namespace.\n */\nfunction isModuleNamespace(mod: object): mod is { default: Translations } {\n  if (!('default' in mod)) return false\n  const keys = Object.keys(mod)\n  if (!keys.every((key) => key === 'default' || key === '__esModule')) return false\n  const value = (mod as { default: unknown }).default\n  return value !== null && typeof value === 'object' && !Array.isArray(value)\n}\n\n/**\n * Tiny helper if you still prefer `import.meta.glob` instead of `defineI18nTheme`.\n * Only unwraps Vite module namespaces — dictionaries with a `default` key stay intact.\n */\nexport function messagesFromGlob(modules: Record<string, { default: Translations } | Translations>): Record<string, Translations> {\n  const messages: Record<string, Translations> = {}\n  for (const [path, mod] of Object.entries(modules)) {\n    const file = path.split('/').pop() || ''\n    const code = file.endsWith('.json') ? file.slice(0, -5) : file\n    if (!code) continue\n    if (mod && typeof mod === 'object' && isModuleNamespace(mod)) {\n      messages[code] = mod.default\n    } else {\n      messages[code] = mod as Translations\n    }\n  }\n  return messages\n}\n"],"mappings":";;;;;AAOA,SAASE,EAAkB,GAA+C;CAGxE,IAFI,EAAE,aAAaC,MAEf,CADS,OAAO,KAAKA,CACpB,CAAA,CAAK,OAAO,MAAQC,MAAQ,aAAaA,MAAQ,YAAY,GAAG,OAAO;CAC5E,IAAMC,IAASF,EAA6B;CAC5C,OAAyB,OAAOE,KAAU,cAAnCA,KAA+C,CAAC,MAAM,QAAQA,CAAK;AAC5E;AAMA,SAAgBC,EAAiB,GAAiG;CAChI,IAAMC,IAAyC,CAAC;CAChD,KAAK,IAAM,CAACC,GAAML,MAAQ,OAAO,QAAQM,CAAO,GAAG;EACjD,IAAMC,IAAOF,EAAK,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK,IAChCG,IAAOD,EAAK,SAAS,OAAO,IAAIA,EAAK,MAAM,GAAG,EAAE,IAAIA;EAC1D,AAAKC,MACL,AAGEJ,EAASI,KAHPR,KAAO,OAAOA,KAAQ,YAAYD,EAAkBC,CAAG,IACxCA,EAAI,UAEJA;CAErB;CACA,OAAOI;AACT"}