{"version":3,"file":"flattenBundle.mjs","names":["FlatTranslationMap","Record","flattenBundle","bundle","prefix","out","Array","isArray","key","value","Object","entries","path","String"],"sources":["../../../src/utilities/i18n/flattenBundle.ts"],"sourcesContent":["export type FlatTranslationMap = Record<string, string>;\n\n/**\n * Flatten a nested translation bundle into literal dotted keys:\n *   { translations: { page: { title: 'Translations' } } }\n *   -> { 'translations.page.title': 'Translations' }\n *\n * The runtime looks translations up FLAT (apps run keySeparator: false so the\n * db-fetched bundles - arbitrary user-authored labels where a dot is just a\n * character - resolve literally). Authoring stays nested for readability;\n * flattening is one-way-safe because the nesting defines where the dots go.\n * Already-flat maps pass through unchanged, so apps with either structure can\n * feed defaultBundles.\n */\nexport const flattenBundle = (\n  bundle: unknown,\n  prefix = '',\n  out: FlatTranslationMap = {}\n): FlatTranslationMap => {\n  if (bundle == null || typeof bundle !== 'object' || Array.isArray(bundle)) {\n    return out;\n  }\n  for (const [key, value] of Object.entries(\n    bundle as Record<string, unknown>\n  )) {\n    const path = prefix ? `${prefix}.${key}` : key;\n    if (value != null && typeof value === 'object' && !Array.isArray(value)) {\n      flattenBundle(value, path, out);\n    } else if (\n      typeof value === 'string' ||\n      typeof value === 'number' ||\n      typeof value === 'boolean'\n    ) {\n      out[path] = String(value);\n    }\n  }\n  return out;\n};\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAaE,iBACXC,QACAC,SAAS,IACTC,MAA0B,EAAE,KACL;AACvB,KAAIF,UAAU,QAAQ,OAAOA,WAAW,YAAYG,MAAMC,QAAQJ,OAAO,CACvE,QAAOE;AAET,MAAK,MAAM,CAACG,KAAKC,UAAUC,OAAOC,QAChCR,OACD,EAAE;EACD,MAAMS,OAAOR,SAAS,GAAGA,OAAM,GAAII,QAAQA;AAC3C,MAAIC,SAAS,QAAQ,OAAOA,UAAU,YAAY,CAACH,MAAMC,QAAQE,MAAM,CACrEP,eAAcO,OAAOG,MAAMP,IAAI;WAE/B,OAAOI,UAAU,YACjB,OAAOA,UAAU,YACjB,OAAOA,UAAU,UAEjBJ,KAAIO,QAAQC,OAAOJ,MAAM;;AAG7B,QAAOJ"}