@intlayer/core 8.4.0-canary.0 → 8.4.1

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.
Files changed (533) hide show
  1. package/dist/cjs/{_virtual/_rolldown/runtime.cjs → chunk-Bmb41Sf3.cjs} +1 -1
  2. package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs +1 -1
  3. package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs.map +1 -1
  4. package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs +1 -1
  5. package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs.map +1 -1
  6. package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs +1 -1
  7. package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs.map +1 -1
  8. package/dist/cjs/deepTransformPlugins/getLocalizedContent.cjs +1 -1
  9. package/dist/cjs/deepTransformPlugins/getLocalizedContent.cjs.map +1 -1
  10. package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs +1 -1
  11. package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs.map +1 -1
  12. package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs +1 -1
  13. package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs.map +1 -1
  14. package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs +1 -1
  15. package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs.map +1 -1
  16. package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs +1 -1
  17. package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs.map +1 -1
  18. package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs +1 -1
  19. package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs.map +1 -1
  20. package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs +1 -1
  21. package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs.map +1 -1
  22. package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs +1 -1
  23. package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs.map +1 -1
  24. package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs +1 -1
  25. package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs.map +1 -1
  26. package/dist/cjs/dictionaryManipulator/getNodeType.cjs +1 -1
  27. package/dist/cjs/dictionaryManipulator/getNodeType.cjs.map +1 -1
  28. package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs +1 -1
  29. package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs.map +1 -1
  30. package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs +1 -1
  31. package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs.map +1 -1
  32. package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs +1 -1
  33. package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs.map +1 -1
  34. package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs +1 -1
  35. package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs.map +1 -1
  36. package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs +1 -1
  37. package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs.map +1 -1
  38. package/dist/cjs/formatters/compact.cjs +1 -1
  39. package/dist/cjs/formatters/compact.cjs.map +1 -1
  40. package/dist/cjs/formatters/currency.cjs +1 -1
  41. package/dist/cjs/formatters/currency.cjs.map +1 -1
  42. package/dist/cjs/formatters/date.cjs +1 -1
  43. package/dist/cjs/formatters/date.cjs.map +1 -1
  44. package/dist/cjs/formatters/list.cjs +1 -1
  45. package/dist/cjs/formatters/list.cjs.map +1 -1
  46. package/dist/cjs/formatters/number.cjs +1 -1
  47. package/dist/cjs/formatters/number.cjs.map +1 -1
  48. package/dist/cjs/formatters/percentage.cjs +1 -1
  49. package/dist/cjs/formatters/percentage.cjs.map +1 -1
  50. package/dist/cjs/formatters/relativeTime.cjs +1 -1
  51. package/dist/cjs/formatters/relativeTime.cjs.map +1 -1
  52. package/dist/cjs/formatters/units.cjs +1 -1
  53. package/dist/cjs/formatters/units.cjs.map +1 -1
  54. package/dist/cjs/getContent-DrqM8pqO.cjs +2 -0
  55. package/dist/cjs/getContent-DrqM8pqO.cjs.map +1 -0
  56. package/dist/cjs/getStorageAttributes.cjs +1 -1
  57. package/dist/cjs/getStorageAttributes.cjs.map +1 -1
  58. package/dist/cjs/html-CZ1N-VL0.cjs +2 -0
  59. package/dist/cjs/html-CZ1N-VL0.cjs.map +1 -0
  60. package/dist/cjs/index.cjs +1 -1
  61. package/dist/cjs/interpreter/getContent/deepTransform.cjs +1 -1
  62. package/dist/cjs/interpreter/getContent/deepTransform.cjs.map +1 -1
  63. package/dist/cjs/interpreter/getContent/getContent.cjs +1 -2
  64. package/dist/cjs/interpreter/getContent/index.cjs +1 -1
  65. package/dist/cjs/interpreter/getContent/plugins.cjs +1 -2
  66. package/dist/cjs/interpreter/getDictionary.cjs +1 -2
  67. package/dist/cjs/interpreter/getIntlayer.cjs +1 -2
  68. package/dist/cjs/interpreter/getNesting.cjs +1 -2
  69. package/dist/cjs/interpreter/index.cjs +1 -1
  70. package/dist/cjs/localization/getBrowserLocale.cjs +1 -1
  71. package/dist/cjs/localization/getBrowserLocale.cjs.map +1 -1
  72. package/dist/cjs/localization/getHTMLTextDir.cjs +1 -1
  73. package/dist/cjs/localization/getHTMLTextDir.cjs.map +1 -1
  74. package/dist/cjs/localization/getLocale.cjs +1 -1
  75. package/dist/cjs/localization/getLocale.cjs.map +1 -1
  76. package/dist/cjs/localization/getLocaleFromPath.cjs +1 -1
  77. package/dist/cjs/localization/getLocaleFromPath.cjs.map +1 -1
  78. package/dist/cjs/localization/getLocalizedUrl.cjs +1 -1
  79. package/dist/cjs/localization/getLocalizedUrl.cjs.map +1 -1
  80. package/dist/cjs/localization/getMultilingualUrls.cjs +1 -1
  81. package/dist/cjs/localization/getMultilingualUrls.cjs.map +1 -1
  82. package/dist/cjs/localization/getPathWithoutLocale.cjs +1 -1
  83. package/dist/cjs/localization/getPathWithoutLocale.cjs.map +1 -1
  84. package/dist/cjs/localization/getPrefix.cjs +1 -1
  85. package/dist/cjs/localization/getPrefix.cjs.map +1 -1
  86. package/dist/cjs/localization/localeMapper.cjs +1 -1
  87. package/dist/cjs/localization/localeMapper.cjs.map +1 -1
  88. package/dist/cjs/localization/localeResolver.cjs +1 -1
  89. package/dist/cjs/localization/localeResolver.cjs.map +1 -1
  90. package/dist/cjs/localization/validatePrefix.cjs +1 -1
  91. package/dist/cjs/localization/validatePrefix.cjs.map +1 -1
  92. package/dist/cjs/messageFormat/ICU.cjs +1 -1
  93. package/dist/cjs/messageFormat/ICU.cjs.map +1 -1
  94. package/dist/cjs/messageFormat/i18next.cjs +1 -1
  95. package/dist/cjs/messageFormat/i18next.cjs.map +1 -1
  96. package/dist/cjs/messageFormat/vue-i18n.cjs +1 -1
  97. package/dist/cjs/messageFormat/vue-i18n.cjs.map +1 -1
  98. package/dist/cjs/transpiler/condition/condition.cjs +1 -1
  99. package/dist/cjs/transpiler/condition/condition.cjs.map +1 -1
  100. package/dist/cjs/transpiler/enumeration/enumeration.cjs +1 -1
  101. package/dist/cjs/transpiler/enumeration/enumeration.cjs.map +1 -1
  102. package/dist/cjs/transpiler/file/file.cjs +1 -1
  103. package/dist/cjs/transpiler/file/file.cjs.map +1 -1
  104. package/dist/cjs/transpiler/gender/gender.cjs +1 -1
  105. package/dist/cjs/transpiler/gender/gender.cjs.map +1 -1
  106. package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs +1 -2
  107. package/dist/cjs/transpiler/html/html.cjs +1 -2
  108. package/dist/cjs/transpiler/html/index.cjs +1 -1
  109. package/dist/cjs/transpiler/index.cjs +1 -1
  110. package/dist/cjs/transpiler/insertion/insertion.cjs +1 -1
  111. package/dist/cjs/transpiler/insertion/insertion.cjs.map +1 -1
  112. package/dist/cjs/transpiler/markdown/markdown.cjs +1 -1
  113. package/dist/cjs/transpiler/markdown/markdown.cjs.map +1 -1
  114. package/dist/cjs/transpiler/nesting/nesting.cjs +1 -1
  115. package/dist/cjs/transpiler/nesting/nesting.cjs.map +1 -1
  116. package/dist/cjs/transpiler/translation/translation.cjs +1 -1
  117. package/dist/cjs/transpiler/translation/translation.cjs.map +1 -1
  118. package/dist/cjs/utils/intl.cjs +1 -1
  119. package/dist/cjs/utils/intl.cjs.map +1 -1
  120. package/dist/cjs/utils/localeStorage.cjs +1 -1
  121. package/dist/cjs/utils/localeStorage.cjs.map +1 -1
  122. package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs +1 -1
  123. package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs.map +1 -1
  124. package/dist/esm/formatters/list.mjs.map +1 -1
  125. package/dist/esm/getContent-DKqtIZGL.mjs +2 -0
  126. package/dist/esm/getContent-DKqtIZGL.mjs.map +1 -0
  127. package/dist/esm/html-3bo80xzx.mjs +2 -0
  128. package/dist/esm/html-3bo80xzx.mjs.map +1 -0
  129. package/dist/esm/index.mjs +1 -1
  130. package/dist/esm/interpreter/getContent/getContent.mjs +1 -2
  131. package/dist/esm/interpreter/getContent/index.mjs +1 -1
  132. package/dist/esm/interpreter/getContent/plugins.mjs +1 -2
  133. package/dist/esm/interpreter/getDictionary.mjs +1 -2
  134. package/dist/esm/interpreter/getIntlayer.mjs +1 -2
  135. package/dist/esm/interpreter/getNesting.mjs +1 -2
  136. package/dist/esm/interpreter/index.mjs +1 -1
  137. package/dist/esm/localization/getBrowserLocale.mjs +1 -1
  138. package/dist/esm/localization/getBrowserLocale.mjs.map +1 -1
  139. package/dist/esm/localization/getHTMLTextDir.mjs +1 -1
  140. package/dist/esm/localization/getHTMLTextDir.mjs.map +1 -1
  141. package/dist/esm/localization/localeMapper.mjs.map +1 -1
  142. package/dist/esm/messageFormat/ICU.mjs +1 -1
  143. package/dist/esm/messageFormat/ICU.mjs.map +1 -1
  144. package/dist/esm/messageFormat/i18next.mjs +1 -1
  145. package/dist/esm/messageFormat/i18next.mjs.map +1 -1
  146. package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs +1 -2
  147. package/dist/esm/transpiler/html/html.mjs +1 -2
  148. package/dist/esm/transpiler/html/index.mjs +1 -1
  149. package/dist/esm/transpiler/index.mjs +1 -1
  150. package/dist/esm/transpiler/markdown/markdown.mjs +1 -1
  151. package/dist/esm/transpiler/markdown/markdown.mjs.map +1 -1
  152. package/dist/esm/utils/intl.mjs +1 -1
  153. package/dist/esm/utils/intl.mjs.map +1 -1
  154. package/dist/types/ICU-tA3ZHN5U.d.ts +11 -0
  155. package/dist/types/ICU-tA3ZHN5U.d.ts.map +1 -0
  156. package/dist/types/checkIsURLAbsolute-CTf3JFU6.d.ts +5 -0
  157. package/dist/types/checkIsURLAbsolute-CTf3JFU6.d.ts.map +1 -0
  158. package/dist/types/compact-IHXcM4pT.d.ts +20 -0
  159. package/dist/types/compact-IHXcM4pT.d.ts.map +1 -0
  160. package/dist/types/compiler-DFiAsUdH.d.ts +9 -0
  161. package/dist/types/compiler-DFiAsUdH.d.ts.map +1 -0
  162. package/dist/types/condition-BDUtoh_1.d.ts +28 -0
  163. package/dist/types/condition-BDUtoh_1.d.ts.map +1 -0
  164. package/dist/types/constants-CI_D82B1.d.ts +177 -0
  165. package/dist/types/constants-CI_D82B1.d.ts.map +1 -0
  166. package/dist/types/currency-PbMCnHep.d.ts +20 -0
  167. package/dist/types/currency-PbMCnHep.d.ts.map +1 -0
  168. package/dist/types/date-C-PI8KqU.d.ts +20 -0
  169. package/dist/types/date-C-PI8KqU.d.ts.map +1 -0
  170. package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts +2 -50
  171. package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts +2 -42
  172. package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts +2 -34
  173. package/dist/types/deepTransformPlugins/getLocalizedContent.d.ts +2 -18
  174. package/dist/types/deepTransformPlugins/getMaskContent.d.ts +2 -10
  175. package/dist/types/deepTransformPlugins/getMissingLocalesContent.d.ts +2 -19
  176. package/dist/types/deepTransformPlugins/getMultilingualDictionary.d.ts +2 -32
  177. package/dist/types/deepTransformPlugins/getReplacedValuesContent.d.ts +2 -8
  178. package/dist/types/deepTransformPlugins/getSplittedContent.d.ts +2 -43
  179. package/dist/types/deepTransformPlugins/index.d.ts +10 -10
  180. package/dist/types/deepTransformPlugins/insertContentInDictionary.d.ts +2 -25
  181. package/dist/types/dictionaryManipulator/editDictionaryByKeyPath.d.ts +2 -8
  182. package/dist/types/dictionaryManipulator/getContentNodeByKeyPath.d.ts +2 -9
  183. package/dist/types/dictionaryManipulator/getDefaultNode.d.ts +2 -9
  184. package/dist/types/dictionaryManipulator/getEmptyNode.d.ts +2 -7
  185. package/dist/types/dictionaryManipulator/getNodeChildren.d.ts +2 -7
  186. package/dist/types/dictionaryManipulator/getNodeType.d.ts +2 -8
  187. package/dist/types/dictionaryManipulator/index.d.ts +12 -12
  188. package/dist/types/dictionaryManipulator/mergeDictionaries.d.ts +2 -7
  189. package/dist/types/dictionaryManipulator/normalizeDictionary.d.ts +2 -9
  190. package/dist/types/dictionaryManipulator/orderDictionaries.d.ts +2 -15
  191. package/dist/types/dictionaryManipulator/removeContentNodeByKeyPath.d.ts +2 -8
  192. package/dist/types/dictionaryManipulator/renameContentNodeByKeyPath.d.ts +2 -8
  193. package/dist/types/dictionaryManipulator/updateNodeChildren.d.ts +2 -7
  194. package/dist/types/editDictionaryByKeyPath-BYIHcsyf.d.ts +8 -0
  195. package/dist/types/editDictionaryByKeyPath-BYIHcsyf.d.ts.map +1 -0
  196. package/dist/types/enumeration-CtuvB5Zz.d.ts +40 -0
  197. package/dist/types/enumeration-CtuvB5Zz.d.ts.map +1 -0
  198. package/dist/types/file-C3q8xvQb.d.ts +28 -0
  199. package/dist/types/file-C3q8xvQb.d.ts.map +1 -0
  200. package/dist/types/formatters/compact.d.ts +2 -20
  201. package/dist/types/formatters/currency.d.ts +2 -20
  202. package/dist/types/formatters/date.d.ts +2 -20
  203. package/dist/types/formatters/index.d.ts +10 -10
  204. package/dist/types/formatters/list.d.ts +2 -24
  205. package/dist/types/formatters/number.d.ts +2 -16
  206. package/dist/types/formatters/percentage.d.ts +2 -16
  207. package/dist/types/formatters/relativeTime.d.ts +2 -11
  208. package/dist/types/formatters/units.d.ts +2 -16
  209. package/dist/types/gender-Dd39Ijmf.d.ts +29 -0
  210. package/dist/types/gender-Dd39Ijmf.d.ts.map +1 -0
  211. package/dist/types/getBrowserLocale-RD_Mwv1t.d.ts +35 -0
  212. package/dist/types/getBrowserLocale-RD_Mwv1t.d.ts.map +1 -0
  213. package/dist/types/getContentNodeByKeyPath-B0Tdi5mj.d.ts +9 -0
  214. package/dist/types/getContentNodeByKeyPath-B0Tdi5mj.d.ts.map +1 -0
  215. package/dist/types/getCookie-DPOvVv_h.d.ts +11 -0
  216. package/dist/types/getCookie-DPOvVv_h.d.ts.map +1 -0
  217. package/dist/types/getDefaultNode-DQNsje2D.d.ts +9 -0
  218. package/dist/types/getDefaultNode-DQNsje2D.d.ts.map +1 -0
  219. package/dist/types/getEmptyNode-DW27TTBj.d.ts +7 -0
  220. package/dist/types/getEmptyNode-DW27TTBj.d.ts.map +1 -0
  221. package/dist/types/getFilterMissingTranslationsContent-CDNQqoy1.d.ts +50 -0
  222. package/dist/types/getFilterMissingTranslationsContent-CDNQqoy1.d.ts.map +1 -0
  223. package/dist/types/getFilterTranslationsOnlyContent-D2YgBkHn.d.ts +42 -0
  224. package/dist/types/getFilterTranslationsOnlyContent-D2YgBkHn.d.ts.map +1 -0
  225. package/dist/types/getFilteredLocalesContent-D0GP-uEg.d.ts +34 -0
  226. package/dist/types/getFilteredLocalesContent-D0GP-uEg.d.ts.map +1 -0
  227. package/dist/types/getHTML-CP6OXtdo.d.ts +32 -0
  228. package/dist/types/getHTML-CP6OXtdo.d.ts.map +1 -0
  229. package/dist/types/getHTMLTextDir-4Zh8J3x7.d.ts +21 -0
  230. package/dist/types/getHTMLTextDir-4Zh8J3x7.d.ts.map +1 -0
  231. package/dist/types/getInsertionValues-Cu9IdbuE.d.ts +5 -0
  232. package/dist/types/getInsertionValues-Cu9IdbuE.d.ts.map +1 -0
  233. package/dist/types/getLocale-B9dECUM_.d.ts +11 -0
  234. package/dist/types/getLocale-B9dECUM_.d.ts.map +1 -0
  235. package/dist/types/getLocaleFromPath-621W32QA.d.ts +26 -0
  236. package/dist/types/getLocaleFromPath-621W32QA.d.ts.map +1 -0
  237. package/dist/types/getLocaleLang-Bcan1gS4.d.ts +20 -0
  238. package/dist/types/getLocaleLang-Bcan1gS4.d.ts.map +1 -0
  239. package/dist/types/getLocaleName-CfRAD9Hc.d.ts +7 -0
  240. package/dist/types/getLocaleName-CfRAD9Hc.d.ts.map +1 -0
  241. package/dist/types/getLocalizedContent-DOncZd-0.d.ts +18 -0
  242. package/dist/types/getLocalizedContent-DOncZd-0.d.ts.map +1 -0
  243. package/dist/types/getLocalizedUrl-BbqeA3-W.d.ts +49 -0
  244. package/dist/types/getLocalizedUrl-BbqeA3-W.d.ts.map +1 -0
  245. package/dist/types/getMarkdownMetadata-Bf1S1NQ0.d.ts +5 -0
  246. package/dist/types/getMarkdownMetadata-Bf1S1NQ0.d.ts.map +1 -0
  247. package/dist/types/getMaskContent-BwLFqp7v.d.ts +10 -0
  248. package/dist/types/getMaskContent-BwLFqp7v.d.ts.map +1 -0
  249. package/dist/types/getMissingLocalesContent-BYffYcdx.d.ts +19 -0
  250. package/dist/types/getMissingLocalesContent-BYffYcdx.d.ts.map +1 -0
  251. package/dist/types/getMultilingualDictionary-DO3i1MFs.d.ts +32 -0
  252. package/dist/types/getMultilingualDictionary-DO3i1MFs.d.ts.map +1 -0
  253. package/dist/types/getMultilingualUrls-CUxYYfA4.d.ts +47 -0
  254. package/dist/types/getMultilingualUrls-CUxYYfA4.d.ts.map +1 -0
  255. package/dist/types/getNodeChildren-OT7Liqke.d.ts +7 -0
  256. package/dist/types/getNodeChildren-OT7Liqke.d.ts.map +1 -0
  257. package/dist/types/getNodeType-Cp765I26.d.ts +8 -0
  258. package/dist/types/getNodeType-Cp765I26.d.ts.map +1 -0
  259. package/dist/types/getPathWithoutLocale-B_aIR7O0.d.ts +31 -0
  260. package/dist/types/getPathWithoutLocale-B_aIR7O0.d.ts.map +1 -0
  261. package/dist/types/getPrefix-X9XKkrZD.d.ts +68 -0
  262. package/dist/types/getPrefix-X9XKkrZD.d.ts.map +1 -0
  263. package/dist/types/getReplacedValuesContent-BvL25pdt.d.ts +8 -0
  264. package/dist/types/getReplacedValuesContent-BvL25pdt.d.ts.map +1 -0
  265. package/dist/types/getSplittedContent-YD4JDMfB.d.ts +43 -0
  266. package/dist/types/getSplittedContent-YD4JDMfB.d.ts.map +1 -0
  267. package/dist/types/getStorageAttributes-CIO2xWqQ.d.ts +29 -0
  268. package/dist/types/getStorageAttributes-CIO2xWqQ.d.ts.map +1 -0
  269. package/dist/types/getStorageAttributes.d.ts +2 -29
  270. package/dist/types/getTranslation-BG2Wg-af.d.ts +30 -0
  271. package/dist/types/getTranslation-BG2Wg-af.d.ts.map +1 -0
  272. package/dist/types/html-Dn6KrpJ3.d.ts +25 -0
  273. package/dist/types/html-Dn6KrpJ3.d.ts.map +1 -0
  274. package/dist/types/htmlTags-YxTtVUx6.d.ts +115 -0
  275. package/dist/types/htmlTags-YxTtVUx6.d.ts.map +1 -0
  276. package/dist/types/i18next-qY0AixrB.d.ts +9 -0
  277. package/dist/types/i18next-qY0AixrB.d.ts.map +1 -0
  278. package/dist/types/index-1CTsSKEn.d.ts +1 -0
  279. package/dist/types/index-B8xF2zGo.d.ts +1 -0
  280. package/dist/types/index-BcsOTSQF.d.ts +1 -0
  281. package/dist/types/index-BnEeKNKW.d.ts +322 -0
  282. package/dist/types/index-BnEeKNKW.d.ts.map +1 -0
  283. package/dist/types/index-Cf8zm5QQ.d.ts +1 -0
  284. package/dist/types/index-CfvILin8.d.ts +1 -0
  285. package/dist/types/index-DK_kKFOF.d.ts +1 -0
  286. package/dist/types/index-DeJa0xZp.d.ts +1 -0
  287. package/dist/types/index-Vlqtiwjx.d.ts +1 -0
  288. package/dist/types/index.d.ts +80 -88
  289. package/dist/types/insertContentInDictionary-DZ3UzG4K.d.ts +25 -0
  290. package/dist/types/insertContentInDictionary-DZ3UzG4K.d.ts.map +1 -0
  291. package/dist/types/insertion-M5fwK-29.d.ts +23 -0
  292. package/dist/types/insertion-M5fwK-29.d.ts.map +1 -0
  293. package/dist/types/interpreter/getCondition.d.ts +2 -22
  294. package/dist/types/interpreter/getContent/deepTransform.d.ts +2 -12
  295. package/dist/types/interpreter/getContent/getContent.d.ts +2 -16
  296. package/dist/types/interpreter/getContent/index.d.ts +1 -3
  297. package/dist/types/interpreter/getContent/plugins.d.ts +2 -151
  298. package/dist/types/interpreter/getDictionary.d.ts +2 -17
  299. package/dist/types/interpreter/getEnumeration.d.ts +2 -58
  300. package/dist/types/interpreter/getGender.d.ts +1 -1
  301. package/dist/types/interpreter/getGender.d.ts.map +1 -1
  302. package/dist/types/interpreter/getHTML.d.ts +2 -32
  303. package/dist/types/interpreter/getInsertion.d.ts +1 -1
  304. package/dist/types/interpreter/getInsertion.d.ts.map +1 -1
  305. package/dist/types/interpreter/getIntlayer.d.ts +2 -8
  306. package/dist/types/interpreter/getNesting.d.ts +2 -27
  307. package/dist/types/interpreter/getTranslation.d.ts +2 -30
  308. package/dist/types/interpreter/index.d.ts +4 -11
  309. package/dist/types/interpreter/splitAndJoinInsertion.d.ts +2 -25
  310. package/dist/types/intl-B2Ap8I5x.d.ts +33 -0
  311. package/dist/types/intl-B2Ap8I5x.d.ts.map +1 -0
  312. package/dist/types/isSameKeyPath-CkH8NdJh.d.ts +7 -0
  313. package/dist/types/isSameKeyPath-CkH8NdJh.d.ts.map +1 -0
  314. package/dist/types/isValidReactElement-BsoJ01oP.d.ts +12 -0
  315. package/dist/types/isValidReactElement-BsoJ01oP.d.ts.map +1 -0
  316. package/dist/types/list-BdjJM2Gx.d.ts +30 -0
  317. package/dist/types/list-BdjJM2Gx.d.ts.map +1 -0
  318. package/dist/types/localeDetector-BWNCQRiZ.d.ts +18 -0
  319. package/dist/types/localeDetector-BWNCQRiZ.d.ts.map +1 -0
  320. package/dist/types/localeMapper-DoAnasqf.d.ts +92 -0
  321. package/dist/types/localeMapper-DoAnasqf.d.ts.map +1 -0
  322. package/dist/types/localeResolver-bb7AWQNX.d.ts +12 -0
  323. package/dist/types/localeResolver-bb7AWQNX.d.ts.map +1 -0
  324. package/dist/types/localeStorage-CZHwY0u3.d.ts +108 -0
  325. package/dist/types/localeStorage-CZHwY0u3.d.ts.map +1 -0
  326. package/dist/types/localization/getBrowserLocale.d.ts +2 -35
  327. package/dist/types/localization/getHTMLTextDir.d.ts +2 -21
  328. package/dist/types/localization/getLocale.d.ts +2 -11
  329. package/dist/types/localization/getLocaleFromPath.d.ts +2 -26
  330. package/dist/types/localization/getLocaleLang.d.ts +2 -20
  331. package/dist/types/localization/getLocaleName.d.ts +2 -7
  332. package/dist/types/localization/getLocalizedUrl.d.ts +2 -49
  333. package/dist/types/localization/getMultilingualUrls.d.ts +2 -47
  334. package/dist/types/localization/getPathWithoutLocale.d.ts +2 -31
  335. package/dist/types/localization/getPrefix.d.ts +2 -68
  336. package/dist/types/localization/index.d.ts +16 -16
  337. package/dist/types/localization/localeDetector.d.ts +2 -18
  338. package/dist/types/localization/localeMapper.d.ts +2 -92
  339. package/dist/types/localization/localeResolver.d.ts +2 -12
  340. package/dist/types/localization/rewriteUtils.d.ts +2 -34
  341. package/dist/types/localization/validatePrefix.d.ts +2 -38
  342. package/dist/types/markdown/compiler.d.ts +2 -9
  343. package/dist/types/markdown/constants.d.ts +2 -177
  344. package/dist/types/markdown/index.d.ts +10 -10
  345. package/dist/types/markdown/parser.d.ts +2 -16
  346. package/dist/types/markdown/renderer.d.ts +2 -22
  347. package/dist/types/markdown/types.d.ts +2 -333
  348. package/dist/types/markdown/utils.d.ts +2 -140
  349. package/dist/types/markdown-MzfikrI1.d.ts +26 -0
  350. package/dist/types/markdown-MzfikrI1.d.ts.map +1 -0
  351. package/dist/types/mergeDictionaries-D6WUMQN5.d.ts +7 -0
  352. package/dist/types/mergeDictionaries-D6WUMQN5.d.ts.map +1 -0
  353. package/dist/types/messageFormat/ICU.d.ts +2 -11
  354. package/dist/types/messageFormat/i18next.d.ts +2 -9
  355. package/dist/types/messageFormat/index.d.ts +3 -3
  356. package/dist/types/messageFormat/vue-i18n.d.ts +2 -9
  357. package/dist/types/normalizeDictionary-coviIGTW.d.ts +9 -0
  358. package/dist/types/normalizeDictionary-coviIGTW.d.ts.map +1 -0
  359. package/dist/types/number-C8izkCmU.d.ts +16 -0
  360. package/dist/types/number-C8izkCmU.d.ts.map +1 -0
  361. package/dist/types/orderDictionaries-SSCMY6qG.d.ts +15 -0
  362. package/dist/types/orderDictionaries-SSCMY6qG.d.ts.map +1 -0
  363. package/dist/types/parseYaml-D5gxutvA.d.ts +5 -0
  364. package/dist/types/parseYaml-D5gxutvA.d.ts.map +1 -0
  365. package/dist/types/parser-BVwR6Tjw.d.ts +16 -0
  366. package/dist/types/parser-BVwR6Tjw.d.ts.map +1 -0
  367. package/dist/types/percentage-BqsvW0Zw.d.ts +16 -0
  368. package/dist/types/percentage-BqsvW0Zw.d.ts.map +1 -0
  369. package/dist/types/relativeTime-mJaYEq7H.d.ts +11 -0
  370. package/dist/types/relativeTime-mJaYEq7H.d.ts.map +1 -0
  371. package/dist/types/removeContentNodeByKeyPath-CotCOOsD.d.ts +8 -0
  372. package/dist/types/removeContentNodeByKeyPath-CotCOOsD.d.ts.map +1 -0
  373. package/dist/types/renameContentNodeByKeyPath-BuyH5gOr.d.ts +8 -0
  374. package/dist/types/renameContentNodeByKeyPath-BuyH5gOr.d.ts.map +1 -0
  375. package/dist/types/renderer-C06x2Orf.d.ts +22 -0
  376. package/dist/types/renderer-C06x2Orf.d.ts.map +1 -0
  377. package/dist/types/rewriteUtils-Bd82NiGR.d.ts +34 -0
  378. package/dist/types/rewriteUtils-Bd82NiGR.d.ts.map +1 -0
  379. package/dist/types/splitAndJoinInsertion-bkuLa7o2.d.ts +25 -0
  380. package/dist/types/splitAndJoinInsertion-bkuLa7o2.d.ts.map +1 -0
  381. package/dist/types/translation-CiC-Avxc.d.ts +33 -0
  382. package/dist/types/translation-CiC-Avxc.d.ts.map +1 -0
  383. package/dist/types/transpiler/condition/condition.d.ts +2 -28
  384. package/dist/types/transpiler/condition/index.d.ts +1 -1
  385. package/dist/types/transpiler/enumeration/enumeration.d.ts +2 -40
  386. package/dist/types/transpiler/enumeration/index.d.ts +1 -1
  387. package/dist/types/transpiler/file/file.d.ts +2 -28
  388. package/dist/types/transpiler/file/fileBrowser.d.ts +1 -1
  389. package/dist/types/transpiler/file/index.d.ts +1 -1
  390. package/dist/types/transpiler/gender/gender.d.ts +2 -29
  391. package/dist/types/transpiler/gender/index.d.ts +1 -1
  392. package/dist/types/transpiler/html/html.d.ts +2 -25
  393. package/dist/types/transpiler/html/htmlTags.d.ts +2 -115
  394. package/dist/types/transpiler/html/index.d.ts +3 -3
  395. package/dist/types/transpiler/html/validateHTML.d.ts +2 -21
  396. package/dist/types/transpiler/index.d.ts +15 -15
  397. package/dist/types/transpiler/insertion/getInsertionValues.d.ts +2 -5
  398. package/dist/types/transpiler/insertion/index.d.ts +2 -2
  399. package/dist/types/transpiler/insertion/insertion.d.ts +2 -23
  400. package/dist/types/transpiler/markdown/getMarkdownMetadata.d.ts +2 -5
  401. package/dist/types/transpiler/markdown/index.d.ts +4 -4
  402. package/dist/types/transpiler/markdown/markdown.d.ts +2 -26
  403. package/dist/types/transpiler/markdown/validateMarkdown.d.ts +3 -18
  404. package/dist/types/transpiler/nesting/index.d.ts +1 -1
  405. package/dist/types/transpiler/nesting/nesting.d.ts +2 -49
  406. package/dist/types/transpiler/translation/index.d.ts +1 -1
  407. package/dist/types/transpiler/translation/translation.d.ts +2 -33
  408. package/dist/types/types-C2Om0aEM.d.ts +333 -0
  409. package/dist/types/types-C2Om0aEM.d.ts.map +1 -0
  410. package/dist/types/units-CouGqa8j.d.ts +16 -0
  411. package/dist/types/units-CouGqa8j.d.ts.map +1 -0
  412. package/dist/types/updateNodeChildren-B5Tu1UBZ.d.ts +7 -0
  413. package/dist/types/updateNodeChildren-B5Tu1UBZ.d.ts.map +1 -0
  414. package/dist/types/utils/checkIsURLAbsolute.d.ts +2 -5
  415. package/dist/types/utils/getCookie.d.ts +2 -11
  416. package/dist/types/utils/index.d.ts +8 -8
  417. package/dist/types/utils/intl.d.ts +2 -33
  418. package/dist/types/utils/isSameKeyPath.d.ts +2 -7
  419. package/dist/types/utils/isValidReactElement.d.ts +2 -12
  420. package/dist/types/utils/localeStorage.d.ts +2 -108
  421. package/dist/types/utils/parseYaml.d.ts +2 -5
  422. package/dist/types/utils-Dcmgh_80.d.ts +140 -0
  423. package/dist/types/utils-Dcmgh_80.d.ts.map +1 -0
  424. package/dist/types/validateHTML-U7UKTtFd.d.ts +21 -0
  425. package/dist/types/validateHTML-U7UKTtFd.d.ts.map +1 -0
  426. package/dist/types/validateMarkdown-BUaTDDIu.d.ts +18 -0
  427. package/dist/types/validateMarkdown-BUaTDDIu.d.ts.map +1 -0
  428. package/dist/types/validatePrefix-Dtmg7QLq.d.ts +38 -0
  429. package/dist/types/validatePrefix-Dtmg7QLq.d.ts.map +1 -0
  430. package/dist/types/vue-i18n-JtUB7N_m.d.ts +9 -0
  431. package/dist/types/vue-i18n-JtUB7N_m.d.ts.map +1 -0
  432. package/package.json +6 -6
  433. package/dist/cjs/interpreter/getContent/getContent.cjs.map +0 -1
  434. package/dist/cjs/interpreter/getContent/plugins.cjs.map +0 -1
  435. package/dist/cjs/interpreter/getDictionary.cjs.map +0 -1
  436. package/dist/cjs/interpreter/getIntlayer.cjs.map +0 -1
  437. package/dist/cjs/interpreter/getNesting.cjs.map +0 -1
  438. package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs.map +0 -1
  439. package/dist/cjs/transpiler/html/html.cjs.map +0 -1
  440. package/dist/esm/interpreter/getContent/getContent.mjs.map +0 -1
  441. package/dist/esm/interpreter/getContent/plugins.mjs.map +0 -1
  442. package/dist/esm/interpreter/getDictionary.mjs.map +0 -1
  443. package/dist/esm/interpreter/getIntlayer.mjs.map +0 -1
  444. package/dist/esm/interpreter/getNesting.mjs.map +0 -1
  445. package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs.map +0 -1
  446. package/dist/esm/transpiler/html/html.mjs.map +0 -1
  447. package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts.map +0 -1
  448. package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts.map +0 -1
  449. package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts.map +0 -1
  450. package/dist/types/deepTransformPlugins/getLocalizedContent.d.ts.map +0 -1
  451. package/dist/types/deepTransformPlugins/getMaskContent.d.ts.map +0 -1
  452. package/dist/types/deepTransformPlugins/getMissingLocalesContent.d.ts.map +0 -1
  453. package/dist/types/deepTransformPlugins/getMultilingualDictionary.d.ts.map +0 -1
  454. package/dist/types/deepTransformPlugins/getReplacedValuesContent.d.ts.map +0 -1
  455. package/dist/types/deepTransformPlugins/getSplittedContent.d.ts.map +0 -1
  456. package/dist/types/deepTransformPlugins/insertContentInDictionary.d.ts.map +0 -1
  457. package/dist/types/dictionaryManipulator/editDictionaryByKeyPath.d.ts.map +0 -1
  458. package/dist/types/dictionaryManipulator/getContentNodeByKeyPath.d.ts.map +0 -1
  459. package/dist/types/dictionaryManipulator/getDefaultNode.d.ts.map +0 -1
  460. package/dist/types/dictionaryManipulator/getEmptyNode.d.ts.map +0 -1
  461. package/dist/types/dictionaryManipulator/getNodeChildren.d.ts.map +0 -1
  462. package/dist/types/dictionaryManipulator/getNodeType.d.ts.map +0 -1
  463. package/dist/types/dictionaryManipulator/mergeDictionaries.d.ts.map +0 -1
  464. package/dist/types/dictionaryManipulator/normalizeDictionary.d.ts.map +0 -1
  465. package/dist/types/dictionaryManipulator/orderDictionaries.d.ts.map +0 -1
  466. package/dist/types/dictionaryManipulator/removeContentNodeByKeyPath.d.ts.map +0 -1
  467. package/dist/types/dictionaryManipulator/renameContentNodeByKeyPath.d.ts.map +0 -1
  468. package/dist/types/dictionaryManipulator/updateNodeChildren.d.ts.map +0 -1
  469. package/dist/types/formatters/compact.d.ts.map +0 -1
  470. package/dist/types/formatters/currency.d.ts.map +0 -1
  471. package/dist/types/formatters/date.d.ts.map +0 -1
  472. package/dist/types/formatters/list.d.ts.map +0 -1
  473. package/dist/types/formatters/number.d.ts.map +0 -1
  474. package/dist/types/formatters/percentage.d.ts.map +0 -1
  475. package/dist/types/formatters/relativeTime.d.ts.map +0 -1
  476. package/dist/types/formatters/units.d.ts.map +0 -1
  477. package/dist/types/getStorageAttributes.d.ts.map +0 -1
  478. package/dist/types/interpreter/getCondition.d.ts.map +0 -1
  479. package/dist/types/interpreter/getContent/deepTransform.d.ts.map +0 -1
  480. package/dist/types/interpreter/getContent/getContent.d.ts.map +0 -1
  481. package/dist/types/interpreter/getContent/plugins.d.ts.map +0 -1
  482. package/dist/types/interpreter/getDictionary.d.ts.map +0 -1
  483. package/dist/types/interpreter/getEnumeration.d.ts.map +0 -1
  484. package/dist/types/interpreter/getHTML.d.ts.map +0 -1
  485. package/dist/types/interpreter/getIntlayer.d.ts.map +0 -1
  486. package/dist/types/interpreter/getNesting.d.ts.map +0 -1
  487. package/dist/types/interpreter/getTranslation.d.ts.map +0 -1
  488. package/dist/types/interpreter/splitAndJoinInsertion.d.ts.map +0 -1
  489. package/dist/types/localization/getBrowserLocale.d.ts.map +0 -1
  490. package/dist/types/localization/getHTMLTextDir.d.ts.map +0 -1
  491. package/dist/types/localization/getLocale.d.ts.map +0 -1
  492. package/dist/types/localization/getLocaleFromPath.d.ts.map +0 -1
  493. package/dist/types/localization/getLocaleLang.d.ts.map +0 -1
  494. package/dist/types/localization/getLocaleName.d.ts.map +0 -1
  495. package/dist/types/localization/getLocalizedUrl.d.ts.map +0 -1
  496. package/dist/types/localization/getMultilingualUrls.d.ts.map +0 -1
  497. package/dist/types/localization/getPathWithoutLocale.d.ts.map +0 -1
  498. package/dist/types/localization/getPrefix.d.ts.map +0 -1
  499. package/dist/types/localization/localeDetector.d.ts.map +0 -1
  500. package/dist/types/localization/localeMapper.d.ts.map +0 -1
  501. package/dist/types/localization/localeResolver.d.ts.map +0 -1
  502. package/dist/types/localization/rewriteUtils.d.ts.map +0 -1
  503. package/dist/types/localization/validatePrefix.d.ts.map +0 -1
  504. package/dist/types/markdown/compiler.d.ts.map +0 -1
  505. package/dist/types/markdown/constants.d.ts.map +0 -1
  506. package/dist/types/markdown/parser.d.ts.map +0 -1
  507. package/dist/types/markdown/renderer.d.ts.map +0 -1
  508. package/dist/types/markdown/types.d.ts.map +0 -1
  509. package/dist/types/markdown/utils.d.ts.map +0 -1
  510. package/dist/types/messageFormat/ICU.d.ts.map +0 -1
  511. package/dist/types/messageFormat/i18next.d.ts.map +0 -1
  512. package/dist/types/messageFormat/vue-i18n.d.ts.map +0 -1
  513. package/dist/types/transpiler/condition/condition.d.ts.map +0 -1
  514. package/dist/types/transpiler/enumeration/enumeration.d.ts.map +0 -1
  515. package/dist/types/transpiler/file/file.d.ts.map +0 -1
  516. package/dist/types/transpiler/gender/gender.d.ts.map +0 -1
  517. package/dist/types/transpiler/html/html.d.ts.map +0 -1
  518. package/dist/types/transpiler/html/htmlTags.d.ts.map +0 -1
  519. package/dist/types/transpiler/html/validateHTML.d.ts.map +0 -1
  520. package/dist/types/transpiler/insertion/getInsertionValues.d.ts.map +0 -1
  521. package/dist/types/transpiler/insertion/insertion.d.ts.map +0 -1
  522. package/dist/types/transpiler/markdown/getMarkdownMetadata.d.ts.map +0 -1
  523. package/dist/types/transpiler/markdown/markdown.d.ts.map +0 -1
  524. package/dist/types/transpiler/markdown/validateMarkdown.d.ts.map +0 -1
  525. package/dist/types/transpiler/nesting/nesting.d.ts.map +0 -1
  526. package/dist/types/transpiler/translation/translation.d.ts.map +0 -1
  527. package/dist/types/utils/checkIsURLAbsolute.d.ts.map +0 -1
  528. package/dist/types/utils/getCookie.d.ts.map +0 -1
  529. package/dist/types/utils/intl.d.ts.map +0 -1
  530. package/dist/types/utils/isSameKeyPath.d.ts.map +0 -1
  531. package/dist/types/utils/isValidReactElement.d.ts.map +0 -1
  532. package/dist/types/utils/localeStorage.d.ts.map +0 -1
  533. package/dist/types/utils/parseYaml.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ICU.cjs","names":["html","insert","enu","gender","NodeType","deepTransformNode"],"sources":["../../../src/messageFormat/ICU.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\n\nimport { NodeType } from '@intlayer/types/nodeType';\nimport { deepTransformNode } from '../interpreter';\nimport { enu, gender, html, insert } from '../transpiler';\n\n/**\n * ICU MessageFormat Converter\n *\n * This module converts between ICU MessageFormat and Intlayer's internal format.\n *\n * IMPORTANT: Two different formats are used:\n *\n * 1. ICU MessageFormat (external format):\n * - Simple variables: {name}\n * - Formatted variables: {amount, number, currency}\n * - Plural: {count, plural, =0 {none} other {# items}}\n * - Select: {gender, select, male {He} female {She} other {They}}\n *\n * 2. Intlayer Internal Format:\n * - Simple variables: {{name}} (double braces for clarity and to distinguish from literal text)\n * - Formatted variables: {amount, number, currency} (keeps ICU format)\n * - Plural: enu({ 0: 'none', fallback: '{{count}} items' })\n * - Select/Gender: gender({ male: 'He', female: 'She', fallback: 'They' })\n *\n * Conversion flow:\n * - ICU → Intlayer: {name} → {{name}}\n * - Intlayer → ICU: {{name}} → {name}\n *\n * The double braces in Intlayer format serve to:\n * - Distinguish variables from literal text containing braces\n * - Work with getInsertion() runtime function which expects {{var}} patterns\n * - Provide clear visual distinction in content dictionaries\n */\n\n// Types for our AST\ntype ICUNode =\n | string\n | {\n type: 'argument';\n name: string;\n format?: { type: string; style?: string };\n }\n | { type: 'plural'; name: string; options: Record<string, ICUNode[]> }\n | { type: 'select'; name: string; options: Record<string, ICUNode[]> };\n\nexport type JsonValue =\n | string\n | number\n | boolean\n | null\n | JsonValue[]\n | { [key: string]: JsonValue };\n\nconst parseICU = (text: string): ICUNode[] => {\n let index = 0;\n\n const parseNodes = (): ICUNode[] => {\n const nodes: ICUNode[] = [];\n let currentText = '';\n\n while (index < text.length) {\n const char = text[index];\n\n if (char === '{') {\n if (currentText) {\n nodes.push(currentText);\n currentText = '';\n }\n index++; // skip {\n nodes.push(parseArgument());\n } else if (char === '}') {\n // End of current block\n break;\n } else if (char === \"'\") {\n // Escaping\n if (index + 1 < text.length && text[index + 1] === \"'\") {\n currentText += \"'\";\n index += 2;\n } else {\n // Find next quote\n const nextQuote = text.indexOf(\"'\", index + 1);\n if (nextQuote !== -1) {\n // Determine if this is escaping syntax characters\n // For simplicity, we'll treat content between single quotes as literal\n // provided it contains syntax chars.\n // Standard ICU: ' quoted string '\n // If it is just an apostrophe, it should be doubled.\n // But simplified: take content between quotes literally.\n currentText += text.substring(index + 1, nextQuote);\n index = nextQuote + 1;\n } else {\n currentText += \"'\";\n index++;\n }\n }\n } else {\n currentText += char;\n index++;\n }\n }\n\n if (currentText) {\n nodes.push(currentText);\n }\n return nodes;\n };\n\n const parseArgument = (): ICUNode => {\n // We are past '{'\n // Parse name\n let name = '';\n while (index < text.length && /[^,}]/.test(text[index])) {\n name += text[index];\n index++;\n }\n name = name.trim();\n\n if (index >= text.length) throw new Error('Unclosed argument');\n\n if (text[index] === '}') {\n index++;\n return { type: 'argument', name };\n }\n\n // Must be comma\n if (text[index] === ',') {\n index++;\n // Parse type\n let type = '';\n while (index < text.length && /[^,}]/.test(text[index])) {\n type += text[index];\n index++;\n }\n type = type.trim();\n\n if (index >= text.length) throw new Error('Unclosed argument');\n\n if (text[index] === '}') {\n index++;\n return { type: 'argument', name, format: { type } };\n }\n\n if (text[index] === ',') {\n index++;\n\n // If plural or select, parse options\n if (type === 'plural' || type === 'select') {\n // Parse options\n const options: Record<string, ICUNode[]> = {};\n\n while (index < text.length && text[index] !== '}') {\n // skip whitespace\n while (index < text.length && /\\s/.test(text[index])) index++;\n\n // parse key\n let key = '';\n while (index < text.length && /[^{\\s]/.test(text[index])) {\n key += text[index];\n index++;\n }\n\n while (index < text.length && /\\s/.test(text[index])) index++;\n\n if (text[index] !== '{')\n throw new Error('Expected { after option key');\n index++; // skip {\n\n const value = parseNodes();\n\n if (text[index] !== '}')\n throw new Error('Expected } after option value');\n index++; // skip }\n\n options[key] = value;\n\n while (index < text.length && /\\s/.test(text[index])) index++;\n }\n\n index++; // skip closing argument }\n\n if (type === 'plural') {\n return { type: 'plural', name, options };\n } else if (type === 'select') {\n return { type: 'select', name, options };\n }\n } else {\n // Parse style for number/date/time\n let style = '';\n while (index < text.length && text[index] !== '}') {\n style += text[index];\n index++;\n }\n if (index >= text.length) throw new Error('Unclosed argument');\n\n style = style.trim();\n index++; // skip }\n\n return { type: 'argument', name, format: { type, style } };\n }\n }\n }\n\n throw new Error('Malformed argument');\n };\n\n return parseNodes();\n};\n\nconst icuNodesToIntlayer = (nodes: ICUNode[]): any => {\n if (nodes.length === 0) return '';\n if (nodes.length === 1 && typeof nodes[0] === 'string') {\n const node = nodes[0];\n if (/<[a-zA-Z0-9-]+[^>]*>/.test(node)) {\n return html(node);\n }\n return node;\n }\n\n // Check if we can flatten to a single string (insert)\n const canFlatten = nodes.every(\n (node) => typeof node === 'string' || node.type === 'argument'\n );\n if (canFlatten) {\n let str = '';\n for (const node of nodes) {\n if (typeof node === 'string') {\n str += node;\n } else if (typeof node !== 'string' && node.type === 'argument') {\n if (node.format) {\n // Formatted variables keep ICU format: {var, type, style}\n str += `{${node.name}, ${node.format.type}${\n node.format.style ? `, ${node.format.style}` : ''\n }}`;\n } else {\n // Simple variables use Intlayer format: {{var}}\n str += `{{${node.name}}}`;\n }\n }\n }\n if (/<[a-zA-Z0-9-]+[^>]*>/.test(str)) {\n return html(str);\n }\n return insert(str);\n }\n\n // Mix of string and complex types.\n // If we have just one complex type and it covers everything?\n if (nodes.length === 1) {\n const node = nodes[0];\n\n if (typeof node === 'string') {\n if (/<[a-zA-Z0-9-]+[^>]*>/.test(node)) {\n return html(node);\n }\n return node;\n }\n if (node.type === 'argument') {\n if (node.format) {\n return insert(\n `{${node.name}, ${node.format.type}${\n node.format.style ? `, ${node.format.style}` : ''\n }}`\n );\n }\n return insert(`{{${node.name}}}`);\n }\n if (node.type === 'plural') {\n const options: Record<string, any> = {};\n\n for (const [key, val] of Object.entries(node.options)) {\n // Map ICU keys to Intlayer keys\n let newKey = key;\n if (key.startsWith('=')) {\n newKey = key.substring(1); // =0 -> 0\n } else if (key === 'one') {\n newKey = '1';\n } else if (key === 'two') {\n newKey = '2';\n } else if (key === 'few') {\n newKey = '<=3';\n } else if (key === 'many') {\n newKey = '>=4';\n } else if (key === 'other') {\n newKey = 'fallback';\n }\n // Handle # in plural value\n // For plural, we need to pass the variable name down or replace #\n // Intlayer uses {{n}} (or whatever var name) for simple variables\n // We should replace # with {{n}} in the string parts of val\n const replacedVal = val.map((v) => {\n if (typeof v === 'string') {\n return v.replace(/#/g, `{{${node.name}}}`);\n }\n return v;\n });\n\n options[newKey] = icuNodesToIntlayer(replacedVal);\n }\n\n // Preserve variable name\n options.__intlayer_icu_var = node.name;\n\n return enu(options);\n }\n if (node.type === 'select') {\n const options: Record<string, any> = {};\n\n for (const [key, val] of Object.entries(node.options)) {\n options[key] = icuNodesToIntlayer(val);\n }\n\n // Check if it looks like gender\n const optionKeys = Object.keys(options);\n // It is gender if it has 'male' OR 'female' AND only contains gender keys (male, female, other)\n const isGender =\n (options.male || options.female) &&\n optionKeys.every((k) =>\n ['male', 'female', 'other', 'fallback'].includes(k)\n );\n\n if (isGender) {\n return gender({\n fallback: options.other,\n male: options.male,\n female: options.female,\n });\n }\n\n // Preserve variable name\n options.__intlayer_icu_var = node.name;\n\n return enu(options);\n }\n }\n\n // If multiple nodes, return array\n return nodes.map((node) => icuNodesToIntlayer([node]));\n};\n\nconst icuToIntlayerPlugin = {\n canHandle: (node: any) =>\n typeof node === 'string' &&\n (node.includes('{') ||\n node.includes('}') ||\n /<[a-zA-Z0-9-]+[^>]*>/.test(node)),\n transform: (node: any) => {\n try {\n const ast = parseICU(node);\n return icuNodesToIntlayer(ast);\n } catch {\n // If parsing fails, return original string\n return node;\n }\n },\n};\n\nconst intlayerToIcuPlugin = {\n canHandle: (node: any) => {\n if (\n typeof node === 'string' &&\n (node.includes('{') || node.includes('}'))\n ) {\n return true;\n }\n\n if (\n node &&\n typeof node === 'object' &&\n (node.nodeType === NodeType.Insertion ||\n node.nodeType === NodeType.HTML ||\n node.nodeType === NodeType.Enumeration ||\n node.nodeType === NodeType.Gender ||\n node.nodeType === 'composite')\n ) {\n return true;\n }\n\n if (Array.isArray(node)) {\n if (node.length === 0) return false;\n\n let hasNode = false;\n let hasPlainObjectOrArray = false;\n\n for (const item of node) {\n if (typeof item === 'string') {\n } else if (\n item &&\n typeof item === 'object' &&\n (item.nodeType === NodeType.Insertion ||\n item.nodeType === NodeType.HTML ||\n item.nodeType === NodeType.Enumeration ||\n item.nodeType === NodeType.Gender ||\n item.nodeType === 'composite')\n ) {\n hasNode = true;\n } else {\n hasPlainObjectOrArray = true;\n }\n }\n\n // If it contains plain objects or nested arrays, it's a structural array\n if (hasPlainObjectOrArray) return false;\n // If it contains ONLY strings, it's a structural array, not a composite string\n if (!hasNode) return false;\n\n return true;\n }\n\n return false;\n },\n transform: (node: any, props: any, next: any) => {\n // Convert Intlayer's double-brace format {{var}} to ICU's single-brace format {var}\n if (typeof node === 'string') {\n return node.replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n }\n\n if (node.nodeType === NodeType.Insertion) {\n return node.insertion.replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n }\n\n if (node.nodeType === NodeType.HTML) {\n return node.html;\n }\n\n if (node.nodeType === NodeType.Enumeration) {\n const options = node.enumeration;\n\n const transformedOptions: Record<string, string> = {};\n for (const [key, val] of Object.entries(options)) {\n if (key === '__intlayer_icu_var') continue;\n const childVal = next(val, props);\n transformedOptions[key] =\n typeof childVal === 'string' ? childVal : JSON.stringify(childVal);\n }\n\n let varName = options.__intlayer_icu_var || 'n';\n\n if (!options.__intlayer_icu_var) {\n const fallbackVal =\n transformedOptions.fallback ||\n transformedOptions.other ||\n Object.values(transformedOptions)[0];\n const match = fallbackVal.match(/\\{([a-zA-Z0-9_]+)\\}(?!,)/);\n if (match) {\n varName = match[1];\n }\n }\n\n const keys = Object.keys(transformedOptions);\n const pluralKeys = [\n '1',\n '2',\n '<=3',\n '>=4',\n 'fallback',\n 'other',\n 'zero',\n 'one',\n 'two',\n 'few',\n 'many',\n ];\n\n const isPlural = keys.every(\n (k) => pluralKeys.includes(k) || /^[<>=]?\\d+(\\.\\d+)?$/.test(k)\n );\n\n const parts = [];\n\n if (isPlural) {\n for (const [key, val] of Object.entries(transformedOptions)) {\n let icuKey = key;\n if (key === 'fallback') icuKey = 'other';\n else if (key === '<=3') icuKey = 'few';\n else if (key === '>=4') icuKey = 'many';\n else if (/^\\d+$/.test(key)) icuKey = `=${key}`;\n else if (['zero', 'few', 'many'].includes(key)) icuKey = key;\n else icuKey = 'other';\n\n let strVal = val;\n strVal = strVal.replace(new RegExp(`\\\\{${varName}\\\\}`, 'g'), '#');\n parts.push(`${icuKey} {${strVal}}`);\n }\n return `{${varName}, plural, ${parts.join(' ')}}`;\n } else {\n const entries = Object.entries(transformedOptions).sort(\n ([keyA], [keyB]) => {\n if (keyA === 'fallback' || keyA === 'other') return 1;\n if (keyB === 'fallback' || keyB === 'other') return -1;\n return 0;\n }\n );\n\n for (const [key, val] of entries) {\n let icuKey = key;\n if (key === 'fallback') icuKey = 'other';\n parts.push(`${icuKey} {${val}}`);\n }\n return `{${varName}, select, ${parts.join(' ')}}`;\n }\n }\n\n if (node.nodeType === NodeType.Gender) {\n const options = node.gender;\n const varName = 'gender';\n const parts = [];\n\n const entries = Object.entries(options).sort(([keyA], [keyB]) => {\n if (keyA === 'fallback') return 1;\n if (keyB === 'fallback') return -1;\n return 0;\n });\n\n for (const [key, val] of entries) {\n let icuKey = key;\n if (key === 'fallback') icuKey = 'other';\n\n const childVal = next(val, props);\n const strVal =\n typeof childVal === 'string' ? childVal : JSON.stringify(childVal);\n\n parts.push(`${icuKey} {${strVal}}`);\n }\n return `{${varName}, select, ${parts.join(' ')}}`;\n }\n\n if (\n Array.isArray(node) ||\n (node.nodeType === 'composite' && Array.isArray(node.composite))\n ) {\n // handle array/composite strings that passed canHandle\n const arr = Array.isArray(node) ? node : node.composite;\n const items = arr.map((item: any) => next(item, props));\n return items.join('');\n }\n\n return next(node, props);\n },\n};\n\nexport const intlayerToICUFormatter = (\n message: Dictionary['content']\n): JsonValue => {\n return deepTransformNode(message, {\n dictionaryKey: 'icu',\n keyPath: [],\n plugins: [{ id: 'icu', ...intlayerToIcuPlugin }],\n });\n};\n\nexport const icuToIntlayerFormatter = (\n message: Dictionary['content']\n): JsonValue => {\n return deepTransformNode(message, {\n dictionaryKey: 'icu',\n keyPath: [],\n plugins: [{ id: 'icu', ...icuToIntlayerPlugin }],\n });\n};\n"],"mappings":"yZAsDA,MAAM,EAAY,GAA4B,CAC5C,IAAI,EAAQ,EAEN,MAA8B,CAClC,IAAM,EAAmB,EAAE,CACvB,EAAc,GAElB,KAAO,EAAQ,EAAK,QAAQ,CAC1B,IAAM,EAAO,EAAK,GAElB,GAAI,IAAS,IACX,AAEE,KADA,EAAM,KAAK,EAAY,CACT,IAEhB,IACA,EAAM,KAAK,GAAe,CAAC,SAClB,IAAS,IAElB,cACS,IAAS,IAElB,GAAI,EAAQ,EAAI,EAAK,QAAU,EAAK,EAAQ,KAAO,IACjD,GAAe,IACf,GAAS,MACJ,CAEL,IAAM,EAAY,EAAK,QAAQ,IAAK,EAAQ,EAAE,CAC1C,IAAc,IAUhB,GAAe,IACf,MAJA,GAAe,EAAK,UAAU,EAAQ,EAAG,EAAU,CACnD,EAAQ,EAAY,QAOxB,GAAe,EACf,IAOJ,OA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M,KAAK,IAAI,CAAC,IAInD,GAAI,EAAK,WAAaA,EAAAA,SAAS,OAAQ,CACrC,IAAM,EAAU,EAAK,OAEf,EAAQ,EAAE,CAEV,EAAU,OAAO,QAAQ,EAAQ,CAAC,MAAM,CAAC,GAAO,CAAC,KACjD,IAAS,WAAmB,EAC5B,IAAS,WAAmB,GACzB,EACP,CAEF,IAAK,GAAM,CAAC,EAAK,KAAQ,EAAS,CAChC,IAAI,EAAS,EACT,IAAQ,aAAY,EAAS,SAEjC,IAAM,EAAW,EAAK,EAAK,EAAM,CAC3B,EACJ,OAAO,GAAa,SAAW,EAAW,KAAK,UAAU,EAAS,CAEpE,EAAM,KAAK,GAAG,EAAO,IAAI,EAAO,GAAG,CAErC,MAAO,oBAAwB,EAAM,KAAK,IAAI,CAAC,GAajD,OATE,MAAM,QAAQ,EAAK,EAClB,EAAK,WAAa,aAAe,MAAM,QAAQ,EAAK,UAAU,EAGnD,MAAM,QAAQ,EAAK,CAAG,EAAO,EAAK,WAC5B,IAAK,GAAc,EAAK,EAAM,EAAM,CAAC,CAC1C,KAAK,GAAG,CAGhB,EAAK,EAAM,EAAM,EAE3B,CAEY,EACX,GAEOC,EAAAA,kBAAkB,EAAS,CAChC,cAAe,MACf,QAAS,EAAE,CACX,QAAS,CAAC,CAAE,GAAI,MAAO,GAAG,EAAqB,CAAC,CACjD,CAAC,CAGS,EACX,GAEOA,EAAAA,kBAAkB,EAAS,CAChC,cAAe,MACf,QAAS,EAAE,CACX,QAAS,CAAC,CAAE,GAAI,MAAO,GAAG,EAAqB,CAAC,CACjD,CAAC"}
1
+ {"version":3,"file":"ICU.cjs","names":["html","insert","enu","gender","NodeType","deepTransformNode"],"sources":["../../../src/messageFormat/ICU.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\n\nimport { NodeType } from '@intlayer/types/nodeType';\nimport { deepTransformNode } from '../interpreter';\nimport { enu, gender, html, insert } from '../transpiler';\n\n/**\n * ICU MessageFormat Converter\n *\n * This module converts between ICU MessageFormat and Intlayer's internal format.\n *\n * IMPORTANT: Two different formats are used:\n *\n * 1. ICU MessageFormat (external format):\n * - Simple variables: {name}\n * - Formatted variables: {amount, number, currency}\n * - Plural: {count, plural, =0 {none} other {# items}}\n * - Select: {gender, select, male {He} female {She} other {They}}\n *\n * 2. Intlayer Internal Format:\n * - Simple variables: {{name}} (double braces for clarity and to distinguish from literal text)\n * - Formatted variables: {amount, number, currency} (keeps ICU format)\n * - Plural: enu({ 0: 'none', fallback: '{{count}} items' })\n * - Select/Gender: gender({ male: 'He', female: 'She', fallback: 'They' })\n *\n * Conversion flow:\n * - ICU → Intlayer: {name} → {{name}}\n * - Intlayer → ICU: {{name}} → {name}\n *\n * The double braces in Intlayer format serve to:\n * - Distinguish variables from literal text containing braces\n * - Work with getInsertion() runtime function which expects {{var}} patterns\n * - Provide clear visual distinction in content dictionaries\n */\n\n// Types for our AST\ntype ICUNode =\n | string\n | {\n type: 'argument';\n name: string;\n format?: { type: string; style?: string };\n }\n | { type: 'plural'; name: string; options: Record<string, ICUNode[]> }\n | { type: 'select'; name: string; options: Record<string, ICUNode[]> };\n\nexport type JsonValue =\n | string\n | number\n | boolean\n | null\n | JsonValue[]\n | { [key: string]: JsonValue };\n\nconst parseICU = (text: string): ICUNode[] => {\n let index = 0;\n\n const parseNodes = (): ICUNode[] => {\n const nodes: ICUNode[] = [];\n let currentText = '';\n\n while (index < text.length) {\n const char = text[index];\n\n if (char === '{') {\n if (currentText) {\n nodes.push(currentText);\n currentText = '';\n }\n index++; // skip {\n nodes.push(parseArgument());\n } else if (char === '}') {\n // End of current block\n break;\n } else if (char === \"'\") {\n // Escaping\n if (index + 1 < text.length && text[index + 1] === \"'\") {\n currentText += \"'\";\n index += 2;\n } else {\n // Find next quote\n const nextQuote = text.indexOf(\"'\", index + 1);\n if (nextQuote !== -1) {\n // Determine if this is escaping syntax characters\n // For simplicity, we'll treat content between single quotes as literal\n // provided it contains syntax chars.\n // Standard ICU: ' quoted string '\n // If it is just an apostrophe, it should be doubled.\n // But simplified: take content between quotes literally.\n currentText += text.substring(index + 1, nextQuote);\n index = nextQuote + 1;\n } else {\n currentText += \"'\";\n index++;\n }\n }\n } else {\n currentText += char;\n index++;\n }\n }\n\n if (currentText) {\n nodes.push(currentText);\n }\n return nodes;\n };\n\n const parseArgument = (): ICUNode => {\n // We are past '{'\n // Parse name\n let name = '';\n while (index < text.length && /[^,}]/.test(text[index])) {\n name += text[index];\n index++;\n }\n name = name.trim();\n\n if (index >= text.length) throw new Error('Unclosed argument');\n\n if (text[index] === '}') {\n index++;\n return { type: 'argument', name };\n }\n\n // Must be comma\n if (text[index] === ',') {\n index++;\n // Parse type\n let type = '';\n while (index < text.length && /[^,}]/.test(text[index])) {\n type += text[index];\n index++;\n }\n type = type.trim();\n\n if (index >= text.length) throw new Error('Unclosed argument');\n\n if (text[index] === '}') {\n index++;\n return { type: 'argument', name, format: { type } };\n }\n\n if (text[index] === ',') {\n index++;\n\n // If plural or select, parse options\n if (type === 'plural' || type === 'select') {\n // Parse options\n const options: Record<string, ICUNode[]> = {};\n\n while (index < text.length && text[index] !== '}') {\n // skip whitespace\n while (index < text.length && /\\s/.test(text[index])) index++;\n\n // parse key\n let key = '';\n while (index < text.length && /[^{\\s]/.test(text[index])) {\n key += text[index];\n index++;\n }\n\n while (index < text.length && /\\s/.test(text[index])) index++;\n\n if (text[index] !== '{')\n throw new Error('Expected { after option key');\n index++; // skip {\n\n const value = parseNodes();\n\n if (text[index] !== '}')\n throw new Error('Expected } after option value');\n index++; // skip }\n\n options[key] = value;\n\n while (index < text.length && /\\s/.test(text[index])) index++;\n }\n\n index++; // skip closing argument }\n\n if (type === 'plural') {\n return { type: 'plural', name, options };\n } else if (type === 'select') {\n return { type: 'select', name, options };\n }\n } else {\n // Parse style for number/date/time\n let style = '';\n while (index < text.length && text[index] !== '}') {\n style += text[index];\n index++;\n }\n if (index >= text.length) throw new Error('Unclosed argument');\n\n style = style.trim();\n index++; // skip }\n\n return { type: 'argument', name, format: { type, style } };\n }\n }\n }\n\n throw new Error('Malformed argument');\n };\n\n return parseNodes();\n};\n\nconst icuNodesToIntlayer = (nodes: ICUNode[]): any => {\n if (nodes.length === 0) return '';\n if (nodes.length === 1 && typeof nodes[0] === 'string') {\n const node = nodes[0];\n if (/<[a-zA-Z0-9-]+[^>]*>/.test(node)) {\n return html(node);\n }\n return node;\n }\n\n // Check if we can flatten to a single string (insert)\n const canFlatten = nodes.every(\n (node) => typeof node === 'string' || node.type === 'argument'\n );\n if (canFlatten) {\n let str = '';\n for (const node of nodes) {\n if (typeof node === 'string') {\n str += node;\n } else if (typeof node !== 'string' && node.type === 'argument') {\n if (node.format) {\n // Formatted variables keep ICU format: {var, type, style}\n str += `{${node.name}, ${node.format.type}${\n node.format.style ? `, ${node.format.style}` : ''\n }}`;\n } else {\n // Simple variables use Intlayer format: {{var}}\n str += `{{${node.name}}}`;\n }\n }\n }\n if (/<[a-zA-Z0-9-]+[^>]*>/.test(str)) {\n return html(str);\n }\n return insert(str);\n }\n\n // Mix of string and complex types.\n // If we have just one complex type and it covers everything?\n if (nodes.length === 1) {\n const node = nodes[0];\n\n if (typeof node === 'string') {\n if (/<[a-zA-Z0-9-]+[^>]*>/.test(node)) {\n return html(node);\n }\n return node;\n }\n if (node.type === 'argument') {\n if (node.format) {\n return insert(\n `{${node.name}, ${node.format.type}${\n node.format.style ? `, ${node.format.style}` : ''\n }}`\n );\n }\n return insert(`{{${node.name}}}`);\n }\n if (node.type === 'plural') {\n const options: Record<string, any> = {};\n\n for (const [key, val] of Object.entries(node.options)) {\n // Map ICU keys to Intlayer keys\n let newKey = key;\n if (key.startsWith('=')) {\n newKey = key.substring(1); // =0 -> 0\n } else if (key === 'one') {\n newKey = '1';\n } else if (key === 'two') {\n newKey = '2';\n } else if (key === 'few') {\n newKey = '<=3';\n } else if (key === 'many') {\n newKey = '>=4';\n } else if (key === 'other') {\n newKey = 'fallback';\n }\n // Handle # in plural value\n // For plural, we need to pass the variable name down or replace #\n // Intlayer uses {{n}} (or whatever var name) for simple variables\n // We should replace # with {{n}} in the string parts of val\n const replacedVal = val.map((v) => {\n if (typeof v === 'string') {\n return v.replace(/#/g, `{{${node.name}}}`);\n }\n return v;\n });\n\n options[newKey] = icuNodesToIntlayer(replacedVal);\n }\n\n // Preserve variable name\n options.__intlayer_icu_var = node.name;\n\n return enu(options);\n }\n if (node.type === 'select') {\n const options: Record<string, any> = {};\n\n for (const [key, val] of Object.entries(node.options)) {\n options[key] = icuNodesToIntlayer(val);\n }\n\n // Check if it looks like gender\n const optionKeys = Object.keys(options);\n // It is gender if it has 'male' OR 'female' AND only contains gender keys (male, female, other)\n const isGender =\n (options.male || options.female) &&\n optionKeys.every((k) =>\n ['male', 'female', 'other', 'fallback'].includes(k)\n );\n\n if (isGender) {\n return gender({\n fallback: options.other,\n male: options.male,\n female: options.female,\n });\n }\n\n // Preserve variable name\n options.__intlayer_icu_var = node.name;\n\n return enu(options);\n }\n }\n\n // If multiple nodes, return array\n return nodes.map((node) => icuNodesToIntlayer([node]));\n};\n\nconst icuToIntlayerPlugin = {\n canHandle: (node: any) =>\n typeof node === 'string' &&\n (node.includes('{') ||\n node.includes('}') ||\n /<[a-zA-Z0-9-]+[^>]*>/.test(node)),\n transform: (node: any) => {\n try {\n const ast = parseICU(node);\n return icuNodesToIntlayer(ast);\n } catch {\n // If parsing fails, return original string\n return node;\n }\n },\n};\n\nconst intlayerToIcuPlugin = {\n canHandle: (node: any) => {\n if (\n typeof node === 'string' &&\n (node.includes('{') || node.includes('}'))\n ) {\n return true;\n }\n\n if (\n node &&\n typeof node === 'object' &&\n (node.nodeType === NodeType.Insertion ||\n node.nodeType === NodeType.HTML ||\n node.nodeType === NodeType.Enumeration ||\n node.nodeType === NodeType.Gender ||\n node.nodeType === 'composite')\n ) {\n return true;\n }\n\n if (Array.isArray(node)) {\n if (node.length === 0) return false;\n\n let hasNode = false;\n let hasPlainObjectOrArray = false;\n\n for (const item of node) {\n if (typeof item === 'string') {\n } else if (\n item &&\n typeof item === 'object' &&\n (item.nodeType === NodeType.Insertion ||\n item.nodeType === NodeType.HTML ||\n item.nodeType === NodeType.Enumeration ||\n item.nodeType === NodeType.Gender ||\n item.nodeType === 'composite')\n ) {\n hasNode = true;\n } else {\n hasPlainObjectOrArray = true;\n }\n }\n\n // If it contains plain objects or nested arrays, it's a structural array\n if (hasPlainObjectOrArray) return false;\n // If it contains ONLY strings, it's a structural array, not a composite string\n if (!hasNode) return false;\n\n return true;\n }\n\n return false;\n },\n transform: (node: any, props: any, next: any) => {\n // Convert Intlayer's double-brace format {{var}} to ICU's single-brace format {var}\n if (typeof node === 'string') {\n return node.replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n }\n\n if (node.nodeType === NodeType.Insertion) {\n return node.insertion.replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n }\n\n if (node.nodeType === NodeType.HTML) {\n return node.html;\n }\n\n if (node.nodeType === NodeType.Enumeration) {\n const options = node.enumeration;\n\n const transformedOptions: Record<string, string> = {};\n for (const [key, val] of Object.entries(options)) {\n if (key === '__intlayer_icu_var') continue;\n const childVal = next(val, props);\n transformedOptions[key] =\n typeof childVal === 'string' ? childVal : JSON.stringify(childVal);\n }\n\n let varName = options.__intlayer_icu_var || 'n';\n\n if (!options.__intlayer_icu_var) {\n const fallbackVal =\n transformedOptions.fallback ||\n transformedOptions.other ||\n Object.values(transformedOptions)[0];\n const match = fallbackVal.match(/\\{([a-zA-Z0-9_]+)\\}(?!,)/);\n if (match) {\n varName = match[1];\n }\n }\n\n const keys = Object.keys(transformedOptions);\n const pluralKeys = [\n '1',\n '2',\n '<=3',\n '>=4',\n 'fallback',\n 'other',\n 'zero',\n 'one',\n 'two',\n 'few',\n 'many',\n ];\n\n const isPlural = keys.every(\n (k) => pluralKeys.includes(k) || /^[<>=]?\\d+(\\.\\d+)?$/.test(k)\n );\n\n const parts = [];\n\n if (isPlural) {\n for (const [key, val] of Object.entries(transformedOptions)) {\n let icuKey = key;\n if (key === 'fallback') icuKey = 'other';\n else if (key === '<=3') icuKey = 'few';\n else if (key === '>=4') icuKey = 'many';\n else if (/^\\d+$/.test(key)) icuKey = `=${key}`;\n else if (['zero', 'few', 'many'].includes(key)) icuKey = key;\n else icuKey = 'other';\n\n let strVal = val;\n strVal = strVal.replace(new RegExp(`\\\\{${varName}\\\\}`, 'g'), '#');\n parts.push(`${icuKey} {${strVal}}`);\n }\n return `{${varName}, plural, ${parts.join(' ')}}`;\n } else {\n const entries = Object.entries(transformedOptions).sort(\n ([keyA], [keyB]) => {\n if (keyA === 'fallback' || keyA === 'other') return 1;\n if (keyB === 'fallback' || keyB === 'other') return -1;\n return 0;\n }\n );\n\n for (const [key, val] of entries) {\n let icuKey = key;\n if (key === 'fallback') icuKey = 'other';\n parts.push(`${icuKey} {${val}}`);\n }\n return `{${varName}, select, ${parts.join(' ')}}`;\n }\n }\n\n if (node.nodeType === NodeType.Gender) {\n const options = node.gender;\n const varName = 'gender';\n const parts = [];\n\n const entries = Object.entries(options).sort(([keyA], [keyB]) => {\n if (keyA === 'fallback') return 1;\n if (keyB === 'fallback') return -1;\n return 0;\n });\n\n for (const [key, val] of entries) {\n let icuKey = key;\n if (key === 'fallback') icuKey = 'other';\n\n const childVal = next(val, props);\n const strVal =\n typeof childVal === 'string' ? childVal : JSON.stringify(childVal);\n\n parts.push(`${icuKey} {${strVal}}`);\n }\n return `{${varName}, select, ${parts.join(' ')}}`;\n }\n\n if (\n Array.isArray(node) ||\n (node.nodeType === 'composite' && Array.isArray(node.composite))\n ) {\n // handle array/composite strings that passed canHandle\n const arr = Array.isArray(node) ? node : node.composite;\n const items = arr.map((item: any) => next(item, props));\n return items.join('');\n }\n\n return next(node, props);\n },\n};\n\nexport const intlayerToICUFormatter = (\n message: Dictionary['content']\n): JsonValue => {\n return deepTransformNode(message, {\n dictionaryKey: 'icu',\n keyPath: [],\n plugins: [{ id: 'icu', ...intlayerToIcuPlugin }],\n });\n};\n\nexport const icuToIntlayerFormatter = (\n message: Dictionary['content']\n): JsonValue => {\n return deepTransformNode(message, {\n dictionaryKey: 'icu',\n keyPath: [],\n plugins: [{ id: 'icu', ...icuToIntlayerPlugin }],\n });\n};\n"],"mappings":"sYAsDA,MAAM,EAAY,GAA4B,CAC5C,IAAI,EAAQ,EAEN,MAA8B,CAClC,IAAM,EAAmB,EAAE,CACvB,EAAc,GAElB,KAAO,EAAQ,EAAK,QAAQ,CAC1B,IAAM,EAAO,EAAK,GAElB,GAAI,IAAS,IACX,AAEE,KADA,EAAM,KAAK,EAAY,CACT,IAEhB,IACA,EAAM,KAAK,GAAe,CAAC,SAClB,IAAS,IAElB,cACS,IAAS,IAElB,GAAI,EAAQ,EAAI,EAAK,QAAU,EAAK,EAAQ,KAAO,IACjD,GAAe,IACf,GAAS,MACJ,CAEL,IAAM,EAAY,EAAK,QAAQ,IAAK,EAAQ,EAAE,CAC1C,IAAc,IAUhB,GAAe,IACf,MAJA,GAAe,EAAK,UAAU,EAAQ,EAAG,EAAU,CACnD,EAAQ,EAAY,QAOxB,GAAe,EACf,IAOJ,OAHI,GACF,EAAM,KAAK,EAAY,CAElB,GAGH,MAA+B,CAGnC,IAAI,EAAO,GACX,KAAO,EAAQ,EAAK,QAAU,QAAQ,KAAK,EAAK,GAAO,EACrD,GAAQ,EAAK,GACb,IAIF,GAFA,EAAO,EAAK,MAAM,CAEd,GAAS,EAAK,OAAQ,MAAU,MAAM,oBAAoB,CAE9D,GAAI,EAAK,KAAW,IAElB,MADA,KACO,CAAE,KAAM,WAAY,OAAM,CAInC,GAAI,EAAK,KAAW,IAAK,CACvB,IAEA,IAAI,EAAO,GACX,KAAO,EAAQ,EAAK,QAAU,QAAQ,KAAK,EAAK,GAAO,EACrD,GAAQ,EAAK,GACb,IAIF,GAFA,EAAO,EAAK,MAAM,CAEd,GAAS,EAAK,OAAQ,MAAU,MAAM,oBAAoB,CAE9D,GAAI,EAAK,KAAW,IAElB,MADA,KACO,CAAE,KAAM,WAAY,OA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AAQ,EAAK,UAAU,EAGnD,MAAM,QAAQ,EAAK,CAAG,EAAO,EAAK,WAC5B,IAAK,GAAc,EAAK,EAAM,EAAM,CAAC,CAC1C,KAAK,GAAG,CAGhB,EAAK,EAAM,EAAM,EAE3B,CAEY,EACX,GAEOC,EAAAA,kBAAkB,EAAS,CAChC,cAAe,MACf,QAAS,EAAE,CACX,QAAS,CAAC,CAAE,GAAI,MAAO,GAAG,EAAqB,CAAC,CACjD,CAAC,CAGS,EACX,GAEOA,EAAAA,kBAAkB,EAAS,CAChC,cAAe,MACf,QAAS,EAAE,CACX,QAAS,CAAC,CAAE,GAAI,MAAO,GAAG,EAAqB,CAAC,CACjD,CAAC"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../interpreter/getContent/deepTransform.cjs`),t=require(`../transpiler/enumeration/enumeration.cjs`),n=require(`../transpiler/gender/gender.cjs`),r=require(`../transpiler/html/html.cjs`),i=require(`../transpiler/insertion/insertion.cjs`);let a=require(`@intlayer/types/nodeType`);const o=e=>{let t=0,n=()=>{let n=[],a=``;for(;t<e.length;){let o=e[t];if(o===`{`&&e[t+1]===`{`)a&&=(n.push(a),``),t+=2,n.push(r());else if(o===`{`)a&&=(n.push(a),``),t++,n.push(i());else if(o===`}`)break;else a+=o,t++}return a&&n.push(a),n},r=()=>{let n=``;for(;t<e.length;){if(e[t]===`}`&&e[t+1]===`}`)return t+=2,{type:`argument`,name:n.trim()};n+=e[t],t++}throw Error(`Unclosed i18next variable`)},i=()=>{let r=``;for(;t<e.length&&/[^,}]/.test(e[t]);)r+=e[t],t++;if(r=r.trim(),t>=e.length)throw Error(`Unclosed argument`);if(e[t]===`}`)return t++,{type:`argument`,name:r};if(e[t]===`,`){t++;let i=``;for(;t<e.length&&/[^,}]/.test(e[t]);)i+=e[t],t++;if(i=i.trim(),t>=e.length)throw Error(`Unclosed argument`);if(e[t]===`}`)return t++,{type:`argument`,name:r,format:{type:i}};if(e[t]===`,`)if(t++,i===`plural`||i===`select`){let a={};for(;t<e.length&&e[t]!==`}`;){for(;t<e.length&&/\s/.test(e[t]);)t++;let r=``;for(;t<e.length&&/[^{\s]/.test(e[t]);)r+=e[t],t++;for(;t<e.length&&/\s/.test(e[t]);)t++;if(e[t]!==`{`)throw Error(`Expected { after option key`);t++;let i=n();if(e[t]!==`}`)throw Error(`Expected } after option value`);for(t++,a[r]=i;t<e.length&&/\s/.test(e[t]);)t++}if(t++,i===`plural`)return{type:`plural`,name:r,options:a};if(i===`select`)return{type:`select`,name:r,options:a}}else{let n=``;for(;t<e.length&&e[t]!==`}`;)n+=e[t],t++;if(t>=e.length)throw Error(`Unclosed argument`);return n=n.trim(),t++,{type:`argument`,name:r,format:{type:i,style:n}}}}throw Error(`Malformed argument`)};return n()},s=e=>{if(e.length===0)return``;if(e.length===1&&typeof e[0]==`string`){let t=e[0];return/<[a-zA-Z0-9-]+[^>]*>/.test(t)?r.html(t):t}if(e.every(e=>typeof e==`string`||e.type===`argument`)){let t=``;for(let n of e)typeof n==`string`?t+=n:typeof n!=`string`&&n.type===`argument`&&(n.format?t+=`{${n.name}, ${n.format.type}${n.format.style?`, ${n.format.style}`:``}}`:t+=`{{${n.name}}}`);return/<[a-zA-Z0-9-]+[^>]*>/.test(t)?r.html(t):i.insert(t)}if(e.length===1){let a=e[0];if(typeof a==`string`)return/<[a-zA-Z0-9-]+[^>]*>/.test(a)?r.html(a):a;if(a.type===`argument`)return a.format?i.insert(`{${a.name}, ${a.format.type}${a.format.style?`, ${a.format.style}`:``}}`):i.insert(`{{${a.name}}}`);if(a.type===`plural`){let e={};for(let[t,n]of Object.entries(a.options)){let r=t;t.startsWith(`=`)?r=t.substring(1):t===`one`?r=`1`:t===`two`?r=`2`:t===`few`?r=`<=3`:t===`many`?r=`>=4`:t===`other`&&(r=`fallback`),e[r]=s(n.map(e=>typeof e==`string`?e.replace(/#/g,`{{${a.name}}}`):e))}return e.__intlayer_icu_var=a.name,t.enu(e)}if(a.type===`select`){let e={};for(let[t,n]of Object.entries(a.options))e[t]=s(n);let r=Object.keys(e);return(e.male||e.female)&&r.every(e=>[`male`,`female`,`other`,`fallback`].includes(e))?n.gender({fallback:e.other,male:e.male,female:e.female}):(e.__intlayer_icu_var=a.name,t.enu(e))}}return e.map(e=>s([e]))},c={canHandle:e=>typeof e==`string`&&(e.includes(`{`)||e.includes(`}`)||/<[a-zA-Z0-9-]+[^>]*>/.test(e)),transform:e=>{try{return s(o(e))}catch{return e}}},l={canHandle:e=>{if(typeof e==`string`||e&&typeof e==`object`&&(e.nodeType===a.NodeType.Insertion||e.nodeType===a.NodeType.HTML||e.nodeType===a.NodeType.Enumeration||e.nodeType===a.NodeType.Gender||e.nodeType===`composite`))return!0;if(Array.isArray(e)){if(e.length===0)return!1;let t=!1,n=!1;for(let r of e)typeof r==`string`||(r&&typeof r==`object`&&(r.nodeType===a.NodeType.Insertion||r.nodeType===a.NodeType.HTML||r.nodeType===a.NodeType.Enumeration||r.nodeType===a.NodeType.Gender||r.nodeType===`composite`)?t=!0:n=!0);return!(n||!t)}return!1},transform:(e,t,n)=>{if(typeof e==`string`)return e;if(e.nodeType===a.NodeType.Insertion)return e.insertion.match(/\{[^}]*,[^}]*\}/),e.insertion;if(e.nodeType===a.NodeType.HTML)return e.html;if(e.nodeType===a.NodeType.Enumeration){let r=e.enumeration,i={};for(let[e,a]of Object.entries(r)){if(e===`__intlayer_icu_var`)continue;let r=n(a,t);i[e]=typeof r==`string`?r:JSON.stringify(r)}let a=r.__intlayer_icu_var||`count`;if(!r.__intlayer_icu_var){let e=i.fallback||i.other||Object.values(i)[0],t=e.match(/\{\{([a-zA-Z0-9_]+)\}\}/)||e.match(/\{([a-zA-Z0-9_]+)\}(?!,)/);t&&(a=t[1])}let o=Object.keys(i),s=[`1`,`2`,`<=3`,`>=4`,`fallback`,`other`,`zero`,`one`,`two`,`few`,`many`],c=o.every(e=>s.includes(e)||/^[<>=]?\d+(\.\d+)?$/.test(e)),l=[];if(c){for(let[e,t]of Object.entries(i)){let n=e;e===`fallback`?n=`other`:e===`<=3`?n=`few`:e===`>=4`?n=`many`:/^\d+$/.test(e)&&(n=`=${e}`);let r=t;r=r.replace(/\{\{([^}]+)\}\}/g,`{$1}`),r=r.replace(RegExp(`\\{${a}\\}`,`g`),`#`),l.push(`${n} {${r}}`)}return`{${a}, plural, ${l.join(` `)}}`}else{let e=Object.entries(i).sort(([e],[t])=>e===`fallback`||e===`other`?1:t===`fallback`||t===`other`?-1:0);for(let[t,n]of e){let e=t;t===`fallback`&&(e=`other`);let r=n;r=r.replace(/\{\{([^}]+)\}\}/g,`{$1}`),l.push(`${e} {${r}}`)}return`{${a}, select, ${l.join(` `)}}`}}if(e.nodeType===a.NodeType.Gender){let r=e.gender,i=[],a=Object.entries(r).sort(([e],[t])=>e===`fallback`?1:t===`fallback`?-1:0);for(let[e,r]of a){let a=e;e===`fallback`&&(a=`other`);let o=n(r,t),s=typeof o==`string`?o:JSON.stringify(o);s=s.replace(/\{\{([^}]+)\}\}/g,`{$1}`),i.push(`${a} {${s}}`)}return`{gender, select, ${i.join(` `)}}`}return Array.isArray(e)||e.nodeType===`composite`&&Array.isArray(e.composite)?(Array.isArray(e)?e:e.composite).map(e=>n(e,t)).join(``):n(e,t)}},u=t=>e.deepTransformNode(t,{dictionaryKey:`i18next`,keyPath:[],plugins:[{id:`i18next`,...l}]}),d=t=>e.deepTransformNode(t,{dictionaryKey:`i18next`,keyPath:[],plugins:[{id:`i18next`,...c}]});exports.i18nextToIntlayerFormatter=d,exports.intlayerToI18nextFormatter=u;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);const e=require(`../interpreter/getContent/deepTransform.cjs`),t=require(`../transpiler/enumeration/enumeration.cjs`),n=require(`../transpiler/gender/gender.cjs`),r=require(`../html-CZ1N-VL0.cjs`),i=require(`../transpiler/insertion/insertion.cjs`);let a=require(`@intlayer/types/nodeType`);const o=e=>{let t=0,n=()=>{let n=[],a=``;for(;t<e.length;){let o=e[t];if(o===`{`&&e[t+1]===`{`)a&&=(n.push(a),``),t+=2,n.push(r());else if(o===`{`)a&&=(n.push(a),``),t++,n.push(i());else if(o===`}`)break;else a+=o,t++}return a&&n.push(a),n},r=()=>{let n=``;for(;t<e.length;){if(e[t]===`}`&&e[t+1]===`}`)return t+=2,{type:`argument`,name:n.trim()};n+=e[t],t++}throw Error(`Unclosed i18next variable`)},i=()=>{let r=``;for(;t<e.length&&/[^,}]/.test(e[t]);)r+=e[t],t++;if(r=r.trim(),t>=e.length)throw Error(`Unclosed argument`);if(e[t]===`}`)return t++,{type:`argument`,name:r};if(e[t]===`,`){t++;let i=``;for(;t<e.length&&/[^,}]/.test(e[t]);)i+=e[t],t++;if(i=i.trim(),t>=e.length)throw Error(`Unclosed argument`);if(e[t]===`}`)return t++,{type:`argument`,name:r,format:{type:i}};if(e[t]===`,`)if(t++,i===`plural`||i===`select`){let a={};for(;t<e.length&&e[t]!==`}`;){for(;t<e.length&&/\s/.test(e[t]);)t++;let r=``;for(;t<e.length&&/[^{\s]/.test(e[t]);)r+=e[t],t++;for(;t<e.length&&/\s/.test(e[t]);)t++;if(e[t]!==`{`)throw Error(`Expected { after option key`);t++;let i=n();if(e[t]!==`}`)throw Error(`Expected } after option value`);for(t++,a[r]=i;t<e.length&&/\s/.test(e[t]);)t++}if(t++,i===`plural`)return{type:`plural`,name:r,options:a};if(i===`select`)return{type:`select`,name:r,options:a}}else{let n=``;for(;t<e.length&&e[t]!==`}`;)n+=e[t],t++;if(t>=e.length)throw Error(`Unclosed argument`);return n=n.trim(),t++,{type:`argument`,name:r,format:{type:i,style:n}}}}throw Error(`Malformed argument`)};return n()},s=e=>{if(e.length===0)return``;if(e.length===1&&typeof e[0]==`string`){let t=e[0];return/<[a-zA-Z0-9-]+[^>]*>/.test(t)?r.t(t):t}if(e.every(e=>typeof e==`string`||e.type===`argument`)){let t=``;for(let n of e)typeof n==`string`?t+=n:typeof n!=`string`&&n.type===`argument`&&(n.format?t+=`{${n.name}, ${n.format.type}${n.format.style?`, ${n.format.style}`:``}}`:t+=`{{${n.name}}}`);return/<[a-zA-Z0-9-]+[^>]*>/.test(t)?r.t(t):i.insert(t)}if(e.length===1){let a=e[0];if(typeof a==`string`)return/<[a-zA-Z0-9-]+[^>]*>/.test(a)?r.t(a):a;if(a.type===`argument`)return a.format?i.insert(`{${a.name}, ${a.format.type}${a.format.style?`, ${a.format.style}`:``}}`):i.insert(`{{${a.name}}}`);if(a.type===`plural`){let e={};for(let[t,n]of Object.entries(a.options)){let r=t;t.startsWith(`=`)?r=t.substring(1):t===`one`?r=`1`:t===`two`?r=`2`:t===`few`?r=`<=3`:t===`many`?r=`>=4`:t===`other`&&(r=`fallback`),e[r]=s(n.map(e=>typeof e==`string`?e.replace(/#/g,`{{${a.name}}}`):e))}return e.__intlayer_icu_var=a.name,t.enu(e)}if(a.type===`select`){let e={};for(let[t,n]of Object.entries(a.options))e[t]=s(n);let r=Object.keys(e);return(e.male||e.female)&&r.every(e=>[`male`,`female`,`other`,`fallback`].includes(e))?n.gender({fallback:e.other,male:e.male,female:e.female}):(e.__intlayer_icu_var=a.name,t.enu(e))}}return e.map(e=>s([e]))},c={canHandle:e=>typeof e==`string`&&(e.includes(`{`)||e.includes(`}`)||/<[a-zA-Z0-9-]+[^>]*>/.test(e)),transform:e=>{try{return s(o(e))}catch{return e}}},l={canHandle:e=>{if(typeof e==`string`||e&&typeof e==`object`&&(e.nodeType===a.NodeType.Insertion||e.nodeType===a.NodeType.HTML||e.nodeType===a.NodeType.Enumeration||e.nodeType===a.NodeType.Gender||e.nodeType===`composite`))return!0;if(Array.isArray(e)){if(e.length===0)return!1;let t=!1,n=!1;for(let r of e)typeof r==`string`||(r&&typeof r==`object`&&(r.nodeType===a.NodeType.Insertion||r.nodeType===a.NodeType.HTML||r.nodeType===a.NodeType.Enumeration||r.nodeType===a.NodeType.Gender||r.nodeType===`composite`)?t=!0:n=!0);return!(n||!t)}return!1},transform:(e,t,n)=>{if(typeof e==`string`)return e;if(e.nodeType===a.NodeType.Insertion)return e.insertion.match(/\{[^}]*,[^}]*\}/),e.insertion;if(e.nodeType===a.NodeType.HTML)return e.html;if(e.nodeType===a.NodeType.Enumeration){let r=e.enumeration,i={};for(let[e,a]of Object.entries(r)){if(e===`__intlayer_icu_var`)continue;let r=n(a,t);i[e]=typeof r==`string`?r:JSON.stringify(r)}let a=r.__intlayer_icu_var||`count`;if(!r.__intlayer_icu_var){let e=i.fallback||i.other||Object.values(i)[0],t=e.match(/\{\{([a-zA-Z0-9_]+)\}\}/)||e.match(/\{([a-zA-Z0-9_]+)\}(?!,)/);t&&(a=t[1])}let o=Object.keys(i),s=[`1`,`2`,`<=3`,`>=4`,`fallback`,`other`,`zero`,`one`,`two`,`few`,`many`],c=o.every(e=>s.includes(e)||/^[<>=]?\d+(\.\d+)?$/.test(e)),l=[];if(c){for(let[e,t]of Object.entries(i)){let n=e;e===`fallback`?n=`other`:e===`<=3`?n=`few`:e===`>=4`?n=`many`:/^\d+$/.test(e)&&(n=`=${e}`);let r=t;r=r.replace(/\{\{([^}]+)\}\}/g,`{$1}`),r=r.replace(RegExp(`\\{${a}\\}`,`g`),`#`),l.push(`${n} {${r}}`)}return`{${a}, plural, ${l.join(` `)}}`}else{let e=Object.entries(i).sort(([e],[t])=>e===`fallback`||e===`other`?1:t===`fallback`||t===`other`?-1:0);for(let[t,n]of e){let e=t;t===`fallback`&&(e=`other`);let r=n;r=r.replace(/\{\{([^}]+)\}\}/g,`{$1}`),l.push(`${e} {${r}}`)}return`{${a}, select, ${l.join(` `)}}`}}if(e.nodeType===a.NodeType.Gender){let r=e.gender,i=[],a=Object.entries(r).sort(([e],[t])=>e===`fallback`?1:t===`fallback`?-1:0);for(let[e,r]of a){let a=e;e===`fallback`&&(a=`other`);let o=n(r,t),s=typeof o==`string`?o:JSON.stringify(o);s=s.replace(/\{\{([^}]+)\}\}/g,`{$1}`),i.push(`${a} {${s}}`)}return`{gender, select, ${i.join(` `)}}`}return Array.isArray(e)||e.nodeType===`composite`&&Array.isArray(e.composite)?(Array.isArray(e)?e:e.composite).map(e=>n(e,t)).join(``):n(e,t)}},u=t=>e.deepTransformNode(t,{dictionaryKey:`i18next`,keyPath:[],plugins:[{id:`i18next`,...l}]}),d=t=>e.deepTransformNode(t,{dictionaryKey:`i18next`,keyPath:[],plugins:[{id:`i18next`,...c}]});exports.i18nextToIntlayerFormatter=d,exports.intlayerToI18nextFormatter=u;
2
2
  //# sourceMappingURL=i18next.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"i18next.cjs","names":["html","insert","enu","gender","NodeType","deepTransformNode"],"sources":["../../../src/messageFormat/i18next.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport { NodeType } from '@intlayer/types/nodeType';\nimport { deepTransformNode } from '../interpreter';\nimport { enu, gender, html, insert } from '../transpiler';\nimport type { JsonValue } from './ICU';\n\n// Types for our AST\ntype I18NextNode =\n | string\n | {\n type: 'argument';\n name: string;\n format?: { type: string; style?: string };\n }\n | { type: 'plural'; name: string; options: Record<string, I18NextNode[]> }\n | { type: 'select'; name: string; options: Record<string, I18NextNode[]> };\n\nconst parseI18Next = (text: string): I18NextNode[] => {\n let index = 0;\n\n const parseNodes = (): I18NextNode[] => {\n const nodes: I18NextNode[] = [];\n let currentText = '';\n\n while (index < text.length) {\n const char = text[index];\n\n // Standard i18next variable: {{var}}\n if (char === '{' && text[index + 1] === '{') {\n if (currentText) {\n nodes.push(currentText);\n currentText = '';\n }\n index += 2; // skip {{\n nodes.push(parseStandardArgument());\n }\n // ICU syntax: {var} or {var, plural, ...}\n else if (char === '{') {\n if (currentText) {\n nodes.push(currentText);\n currentText = '';\n }\n index++; // skip {\n nodes.push(parseICUArgument());\n } else if (char === '}') {\n // End of current block (likely ICU block end)\n break;\n } else {\n currentText += char;\n index++;\n }\n }\n\n if (currentText) {\n nodes.push(currentText);\n }\n return nodes;\n };\n\n const parseStandardArgument = (): I18NextNode => {\n // We are past '{{'\n let name = '';\n while (index < text.length) {\n // Check for closing }}\n if (text[index] === '}' && text[index + 1] === '}') {\n index += 2; // skip }}\n return { type: 'argument', name: name.trim() };\n }\n name += text[index];\n index++;\n }\n throw new Error('Unclosed i18next variable');\n };\n\n const parseICUArgument = (): I18NextNode => {\n // We are past '{'\n let name = '';\n while (index < text.length && /[^,}]/.test(text[index])) {\n name += text[index];\n index++;\n }\n name = name.trim();\n\n if (index >= text.length) throw new Error('Unclosed argument');\n\n if (text[index] === '}') {\n index++;\n return { type: 'argument', name };\n }\n\n // Must be comma\n if (text[index] === ',') {\n index++;\n // Parse type\n let type = '';\n while (index < text.length && /[^,}]/.test(text[index])) {\n type += text[index];\n index++;\n }\n type = type.trim();\n\n if (index >= text.length) throw new Error('Unclosed argument');\n\n if (text[index] === '}') {\n index++;\n return { type: 'argument', name, format: { type } };\n }\n\n if (text[index] === ',') {\n index++;\n\n // If plural or select, parse options\n if (type === 'plural' || type === 'select') {\n const options: Record<string, I18NextNode[]> = {};\n\n while (index < text.length && text[index] !== '}') {\n while (index < text.length && /\\s/.test(text[index])) index++;\n\n let key = '';\n while (index < text.length && /[^{\\s]/.test(text[index])) {\n key += text[index];\n index++;\n }\n\n while (index < text.length && /\\s/.test(text[index])) index++;\n\n if (text[index] !== '{')\n throw new Error('Expected { after option key');\n index++; // skip {\n\n const value = parseNodes();\n\n if (text[index] !== '}')\n throw new Error('Expected } after option value');\n index++; // skip }\n\n options[key] = value;\n\n while (index < text.length && /\\s/.test(text[index])) index++;\n }\n\n index++; // skip closing argument }\n\n if (type === 'plural') {\n return { type: 'plural', name, options };\n } else if (type === 'select') {\n return { type: 'select', name, options };\n }\n } else {\n // Parse style for number/date/time\n let style = '';\n while (index < text.length && text[index] !== '}') {\n style += text[index];\n index++;\n }\n if (index >= text.length) throw new Error('Unclosed argument');\n\n style = style.trim();\n index++; // skip }\n\n return { type: 'argument', name, format: { type, style } };\n }\n }\n }\n\n throw new Error('Malformed argument');\n };\n\n return parseNodes();\n};\n\nconst i18nextNodesToIntlayer = (nodes: I18NextNode[]): any => {\n if (nodes.length === 0) return '';\n if (nodes.length === 1 && typeof nodes[0] === 'string') {\n const node = nodes[0];\n if (/<[a-zA-Z0-9-]+[^>]*>/.test(node)) {\n return html(node);\n }\n return node;\n }\n\n const canFlatten = nodes.every(\n (node) => typeof node === 'string' || node.type === 'argument'\n );\n\n if (canFlatten) {\n let str = '';\n for (const node of nodes) {\n if (typeof node === 'string') {\n str += node;\n } else if (typeof node !== 'string' && node.type === 'argument') {\n if (node.format) {\n // For formatted arguments, use ICU syntax: {name, type, style}\n str += `{${node.name}, ${node.format.type}${\n node.format.style ? `, ${node.format.style}` : ''\n }}`;\n } else {\n // For simple arguments, use standard i18next: {{name}}\n str += `{{${node.name}}}`;\n }\n }\n }\n if (/<[a-zA-Z0-9-]+[^>]*>/.test(str)) {\n return html(str);\n }\n return insert(str);\n }\n\n if (nodes.length === 1) {\n const node = nodes[0];\n if (typeof node === 'string') {\n if (/<[a-zA-Z0-9-]+[^>]*>/.test(node)) {\n return html(node);\n }\n return node;\n }\n\n if (node.type === 'argument') {\n if (node.format) {\n return insert(\n `{${node.name}, ${node.format.type}${\n node.format.style ? `, ${node.format.style}` : ''\n }}`\n );\n }\n return insert(`{{${node.name}}}`);\n }\n\n if (node.type === 'plural') {\n const options: Record<string, any> = {};\n for (const [key, val] of Object.entries(node.options)) {\n let newKey = key;\n if (key.startsWith('=')) {\n newKey = key.substring(1);\n } else if (key === 'one') {\n newKey = '1';\n } else if (key === 'two') {\n newKey = '2';\n } else if (key === 'few') {\n newKey = '<=3';\n } else if (key === 'many') {\n newKey = '>=4';\n } else if (key === 'other') {\n newKey = 'fallback';\n }\n // Handle # replacement\n const replacedVal = val.map((v) => {\n if (typeof v === 'string') {\n // In ICU plural, # is replaced by the number\n // In i18next, if using ICU plugin, it behaves same.\n // We map it to {{varName}} in Intlayer\n return v.replace(/#/g, `{{${node.name}}}`);\n }\n return v;\n });\n\n options[newKey] = i18nextNodesToIntlayer(replacedVal);\n }\n\n // Preserve variable name\n options.__intlayer_icu_var = node.name;\n\n return enu(options);\n }\n\n if (node.type === 'select') {\n const options: Record<string, any> = {};\n for (const [key, val] of Object.entries(node.options)) {\n options[key] = i18nextNodesToIntlayer(val);\n }\n\n // Check for gender\n const optionKeys = Object.keys(options);\n const isGender =\n (options.male || options.female) &&\n optionKeys.every((k) =>\n ['male', 'female', 'other', 'fallback'].includes(k)\n );\n\n if (isGender) {\n return gender({\n fallback: options.other,\n male: options.male,\n female: options.female,\n });\n }\n\n // Preserve variable name for generic select\n options.__intlayer_icu_var = node.name;\n\n return enu(options);\n }\n }\n\n return nodes.map((node) => i18nextNodesToIntlayer([node]));\n};\n\nconst i18nextToIntlayerPlugin = {\n canHandle: (node: any) =>\n typeof node === 'string' &&\n (node.includes('{') ||\n node.includes('}') ||\n /<[a-zA-Z0-9-]+[^>]*>/.test(node)),\n transform: (node: any) => {\n try {\n const ast = parseI18Next(node);\n return i18nextNodesToIntlayer(ast);\n } catch {\n return node;\n }\n },\n};\n\nconst intlayerToI18nextPlugin = {\n canHandle: (node: any) => {\n if (typeof node === 'string') return true;\n\n if (\n node &&\n typeof node === 'object' &&\n (node.nodeType === NodeType.Insertion ||\n node.nodeType === NodeType.HTML ||\n node.nodeType === NodeType.Enumeration ||\n node.nodeType === NodeType.Gender ||\n node.nodeType === 'composite')\n ) {\n return true;\n }\n\n if (Array.isArray(node)) {\n if (node.length === 0) return false;\n\n let hasNode = false;\n let hasPlainObjectOrArray = false;\n\n for (const item of node) {\n if (typeof item === 'string') {\n } else if (\n item &&\n typeof item === 'object' &&\n (item.nodeType === NodeType.Insertion ||\n item.nodeType === NodeType.HTML ||\n item.nodeType === NodeType.Enumeration ||\n item.nodeType === NodeType.Gender ||\n item.nodeType === 'composite')\n ) {\n hasNode = true;\n } else {\n hasPlainObjectOrArray = true;\n }\n }\n\n // If it contains plain objects or nested arrays, it's a structural array\n if (hasPlainObjectOrArray) return false;\n // If it contains ONLY strings, it's a structural array, not a composite string\n if (!hasNode) return false;\n\n return true;\n }\n\n return false;\n },\n transform: (node: any, props: any, next: any) => {\n if (typeof node === 'string') {\n return node;\n }\n\n if (node.nodeType === NodeType.Insertion) {\n if (node.insertion.match(/\\{[^}]*,[^}]*\\}/)) {\n return node.insertion;\n }\n return node.insertion;\n }\n\n if (node.nodeType === NodeType.HTML) {\n return node.html;\n }\n\n if (node.nodeType === NodeType.Enumeration) {\n const options = node.enumeration;\n\n const transformedOptions: Record<string, string> = {};\n for (const [key, val] of Object.entries(options)) {\n if (key === '__intlayer_icu_var') continue;\n const childVal = next(val, props);\n transformedOptions[key] =\n typeof childVal === 'string' ? childVal : JSON.stringify(childVal);\n }\n\n let varName = options.__intlayer_icu_var || 'count';\n\n if (!options.__intlayer_icu_var) {\n const fallbackVal =\n transformedOptions.fallback ||\n transformedOptions.other ||\n Object.values(transformedOptions)[0];\n\n const match =\n fallbackVal.match(/\\{\\{([a-zA-Z0-9_]+)\\}\\}/) ||\n fallbackVal.match(/\\{([a-zA-Z0-9_]+)\\}(?!,)/);\n if (match) {\n varName = match[1];\n }\n }\n\n const keys = Object.keys(transformedOptions);\n const pluralKeys = [\n '1',\n '2',\n '<=3',\n '>=4',\n 'fallback',\n 'other',\n 'zero',\n 'one',\n 'two',\n 'few',\n 'many',\n ];\n const isPlural = keys.every(\n (k) => pluralKeys.includes(k) || /^[<>=]?\\d+(\\.\\d+)?$/.test(k)\n );\n\n const parts = [];\n\n if (isPlural) {\n for (const [key, val] of Object.entries(transformedOptions)) {\n let icuKey = key;\n if (key === 'fallback') icuKey = 'other';\n else if (key === '<=3') icuKey = 'few';\n else if (key === '>=4') icuKey = 'many';\n else if (/^\\d+$/.test(key)) icuKey = `=${key}`;\n\n let strVal = val;\n\n strVal = strVal.replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n strVal = strVal.replace(new RegExp(`\\\\{${varName}\\\\}`, 'g'), '#');\n\n parts.push(`${icuKey} {${strVal}}`);\n }\n return `{${varName}, plural, ${parts.join(' ')}}`;\n } else {\n const entries = Object.entries(transformedOptions).sort(\n ([keyA], [keyB]) => {\n if (keyA === 'fallback' || keyA === 'other') return 1;\n if (keyB === 'fallback' || keyB === 'other') return -1;\n return 0;\n }\n );\n\n for (const [key, val] of entries) {\n let icuKey = key;\n if (key === 'fallback') icuKey = 'other';\n\n let strVal = val;\n strVal = strVal.replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n\n parts.push(`${icuKey} {${strVal}}`);\n }\n return `{${varName}, select, ${parts.join(' ')}}`;\n }\n }\n\n if (node.nodeType === NodeType.Gender) {\n const options = node.gender;\n const varName = 'gender';\n const parts = [];\n\n const entries = Object.entries(options).sort(([keyA], [keyB]) => {\n if (keyA === 'fallback') return 1;\n if (keyB === 'fallback') return -1;\n return 0;\n });\n\n for (const [key, val] of entries) {\n let icuKey = key;\n if (key === 'fallback') icuKey = 'other';\n\n const childVal = next(val, props);\n let strVal =\n typeof childVal === 'string' ? childVal : JSON.stringify(childVal);\n\n strVal = strVal.replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n parts.push(`${icuKey} {${strVal}}`);\n }\n return `{${varName}, select, ${parts.join(' ')}}`;\n }\n\n if (\n Array.isArray(node) ||\n (node.nodeType === 'composite' && Array.isArray(node.composite))\n ) {\n const arr = Array.isArray(node) ? node : node.composite;\n const items = arr.map((item: any) => next(item, props));\n return items.join('');\n }\n\n return next(node, props);\n },\n};\n\nexport const intlayerToI18nextFormatter = (\n message: Dictionary['content']\n): JsonValue => {\n return deepTransformNode(message, {\n dictionaryKey: 'i18next',\n keyPath: [],\n plugins: [{ id: 'i18next', ...intlayerToI18nextPlugin }],\n });\n};\n\nexport const i18nextToIntlayerFormatter = (\n message: JsonValue\n): Dictionary['content'] => {\n return deepTransformNode(message, {\n dictionaryKey: 'i18next',\n keyPath: [],\n plugins: [{ id: 'i18next',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AK,IAAI,CAAC,GAYjD,OARE,MAAM,QAAQ,EAAK,EAClB,EAAK,WAAa,aAAe,MAAM,QAAQ,EAAK,UAAU,EAEnD,MAAM,QAAQ,EAAK,CAAG,EAAO,EAAK,WAC5B,IAAK,GAAc,EAAK,EAAM,EAAM,CAAC,CAC1C,KAAK,GAAG,CAGhB,EAAK,EAAM,EAAM,EAE3B,CAEY,EACX,GAEOC,EAAAA,kBAAkB,EAAS,CAChC,cAAe,UACf,QAAS,EAAE,CACX,QAAS,CAAC,CAAE,GAAI,UAAW,GAAG,EAAyB,CAAC,CACzD,CAAC,CAGS,EACX,GAEOA,EAAAA,kBAAkB,EAAS,CAChC,cAAe,UACf,QAAS,EAAE,CACX,QAAS,CAAC,CAAE,GAAI,UAAW,GAAG,EAAyB,CAAC,CACzD,CAAC"}
1
+ {"version":3,"file":"i18next.cjs","names":["html","insert","enu","gender","NodeType","deepTransformNode"],"sources":["../../../src/messageFormat/i18next.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport { NodeType } from '@intlayer/types/nodeType';\nimport { deepTransformNode } from '../interpreter';\nimport { enu, gender, html, insert } from '../transpiler';\nimport type { JsonValue } from './ICU';\n\n// Types for our AST\ntype I18NextNode =\n | string\n | {\n type: 'argument';\n name: string;\n format?: { type: string; style?: string };\n }\n | { type: 'plural'; name: string; options: Record<string, I18NextNode[]> }\n | { type: 'select'; name: string; options: Record<string, I18NextNode[]> };\n\nconst parseI18Next = (text: string): I18NextNode[] => {\n let index = 0;\n\n const parseNodes = (): I18NextNode[] => {\n const nodes: I18NextNode[] = [];\n let currentText = '';\n\n while (index < text.length) {\n const char = text[index];\n\n // Standard i18next variable: {{var}}\n if (char === '{' && text[index + 1] === '{') {\n if (currentText) {\n nodes.push(currentText);\n currentText = '';\n }\n index += 2; // skip {{\n nodes.push(parseStandardArgument());\n }\n // ICU syntax: {var} or {var, plural, ...}\n else if (char === '{') {\n if (currentText) {\n nodes.push(currentText);\n currentText = '';\n }\n index++; // skip {\n nodes.push(parseICUArgument());\n } else if (char === '}') {\n // End of current block (likely ICU block end)\n break;\n } else {\n currentText += char;\n index++;\n }\n }\n\n if (currentText) {\n nodes.push(currentText);\n }\n return nodes;\n };\n\n const parseStandardArgument = (): I18NextNode => {\n // We are past '{{'\n let name = '';\n while (index < text.length) {\n // Check for closing }}\n if (text[index] === '}' && text[index + 1] === '}') {\n index += 2; // skip }}\n return { type: 'argument', name: name.trim() };\n }\n name += text[index];\n index++;\n }\n throw new Error('Unclosed i18next variable');\n };\n\n const parseICUArgument = (): I18NextNode => {\n // We are past '{'\n let name = '';\n while (index < text.length && /[^,}]/.test(text[index])) {\n name += text[index];\n index++;\n }\n name = name.trim();\n\n if (index >= text.length) throw new Error('Unclosed argument');\n\n if (text[index] === '}') {\n index++;\n return { type: 'argument', name };\n }\n\n // Must be comma\n if (text[index] === ',') {\n index++;\n // Parse type\n let type = '';\n while (index < text.length && /[^,}]/.test(text[index])) {\n type += text[index];\n index++;\n }\n type = type.trim();\n\n if (index >= text.length) throw new Error('Unclosed argument');\n\n if (text[index] === '}') {\n index++;\n return { type: 'argument', name, format: { type } };\n }\n\n if (text[index] === ',') {\n index++;\n\n // If plural or select, parse options\n if (type === 'plural' || type === 'select') {\n const options: Record<string, I18NextNode[]> = {};\n\n while (index < text.length && text[index] !== '}') {\n while (index < text.length && /\\s/.test(text[index])) index++;\n\n let key = '';\n while (index < text.length && /[^{\\s]/.test(text[index])) {\n key += text[index];\n index++;\n }\n\n while (index < text.length && /\\s/.test(text[index])) index++;\n\n if (text[index] !== '{')\n throw new Error('Expected { after option key');\n index++; // skip {\n\n const value = parseNodes();\n\n if (text[index] !== '}')\n throw new Error('Expected } after option value');\n index++; // skip }\n\n options[key] = value;\n\n while (index < text.length && /\\s/.test(text[index])) index++;\n }\n\n index++; // skip closing argument }\n\n if (type === 'plural') {\n return { type: 'plural', name, options };\n } else if (type === 'select') {\n return { type: 'select', name, options };\n }\n } else {\n // Parse style for number/date/time\n let style = '';\n while (index < text.length && text[index] !== '}') {\n style += text[index];\n index++;\n }\n if (index >= text.length) throw new Error('Unclosed argument');\n\n style = style.trim();\n index++; // skip }\n\n return { type: 'argument', name, format: { type, style } };\n }\n }\n }\n\n throw new Error('Malformed argument');\n };\n\n return parseNodes();\n};\n\nconst i18nextNodesToIntlayer = (nodes: I18NextNode[]): any => {\n if (nodes.length === 0) return '';\n if (nodes.length === 1 && typeof nodes[0] === 'string') {\n const node = nodes[0];\n if (/<[a-zA-Z0-9-]+[^>]*>/.test(node)) {\n return html(node);\n }\n return node;\n }\n\n const canFlatten = nodes.every(\n (node) => typeof node === 'string' || node.type === 'argument'\n );\n\n if (canFlatten) {\n let str = '';\n for (const node of nodes) {\n if (typeof node === 'string') {\n str += node;\n } else if (typeof node !== 'string' && node.type === 'argument') {\n if (node.format) {\n // For formatted arguments, use ICU syntax: {name, type, style}\n str += `{${node.name}, ${node.format.type}${\n node.format.style ? `, ${node.format.style}` : ''\n }}`;\n } else {\n // For simple arguments, use standard i18next: {{name}}\n str += `{{${node.name}}}`;\n }\n }\n }\n if (/<[a-zA-Z0-9-]+[^>]*>/.test(str)) {\n return html(str);\n }\n return insert(str);\n }\n\n if (nodes.length === 1) {\n const node = nodes[0];\n if (typeof node === 'string') {\n if (/<[a-zA-Z0-9-]+[^>]*>/.test(node)) {\n return html(node);\n }\n return node;\n }\n\n if (node.type === 'argument') {\n if (node.format) {\n return insert(\n `{${node.name}, ${node.format.type}${\n node.format.style ? `, ${node.format.style}` : ''\n }}`\n );\n }\n return insert(`{{${node.name}}}`);\n }\n\n if (node.type === 'plural') {\n const options: Record<string, any> = {};\n for (const [key, val] of Object.entries(node.options)) {\n let newKey = key;\n if (key.startsWith('=')) {\n newKey = key.substring(1);\n } else if (key === 'one') {\n newKey = '1';\n } else if (key === 'two') {\n newKey = '2';\n } else if (key === 'few') {\n newKey = '<=3';\n } else if (key === 'many') {\n newKey = '>=4';\n } else if (key === 'other') {\n newKey = 'fallback';\n }\n // Handle # replacement\n const replacedVal = val.map((v) => {\n if (typeof v === 'string') {\n // In ICU plural, # is replaced by the number\n // In i18next, if using ICU plugin, it behaves same.\n // We map it to {{varName}} in Intlayer\n return v.replace(/#/g, `{{${node.name}}}`);\n }\n return v;\n });\n\n options[newKey] = i18nextNodesToIntlayer(replacedVal);\n }\n\n // Preserve variable name\n options.__intlayer_icu_var = node.name;\n\n return enu(options);\n }\n\n if (node.type === 'select') {\n const options: Record<string, any> = {};\n for (const [key, val] of Object.entries(node.options)) {\n options[key] = i18nextNodesToIntlayer(val);\n }\n\n // Check for gender\n const optionKeys = Object.keys(options);\n const isGender =\n (options.male || options.female) &&\n optionKeys.every((k) =>\n ['male', 'female', 'other', 'fallback'].includes(k)\n );\n\n if (isGender) {\n return gender({\n fallback: options.other,\n male: options.male,\n female: options.female,\n });\n }\n\n // Preserve variable name for generic select\n options.__intlayer_icu_var = node.name;\n\n return enu(options);\n }\n }\n\n return nodes.map((node) => i18nextNodesToIntlayer([node]));\n};\n\nconst i18nextToIntlayerPlugin = {\n canHandle: (node: any) =>\n typeof node === 'string' &&\n (node.includes('{') ||\n node.includes('}') ||\n /<[a-zA-Z0-9-]+[^>]*>/.test(node)),\n transform: (node: any) => {\n try {\n const ast = parseI18Next(node);\n return i18nextNodesToIntlayer(ast);\n } catch {\n return node;\n }\n },\n};\n\nconst intlayerToI18nextPlugin = {\n canHandle: (node: any) => {\n if (typeof node === 'string') return true;\n\n if (\n node &&\n typeof node === 'object' &&\n (node.nodeType === NodeType.Insertion ||\n node.nodeType === NodeType.HTML ||\n node.nodeType === NodeType.Enumeration ||\n node.nodeType === NodeType.Gender ||\n node.nodeType === 'composite')\n ) {\n return true;\n }\n\n if (Array.isArray(node)) {\n if (node.length === 0) return false;\n\n let hasNode = false;\n let hasPlainObjectOrArray = false;\n\n for (const item of node) {\n if (typeof item === 'string') {\n } else if (\n item &&\n typeof item === 'object' &&\n (item.nodeType === NodeType.Insertion ||\n item.nodeType === NodeType.HTML ||\n item.nodeType === NodeType.Enumeration ||\n item.nodeType === NodeType.Gender ||\n item.nodeType === 'composite')\n ) {\n hasNode = true;\n } else {\n hasPlainObjectOrArray = true;\n }\n }\n\n // If it contains plain objects or nested arrays, it's a structural array\n if (hasPlainObjectOrArray) return false;\n // If it contains ONLY strings, it's a structural array, not a composite string\n if (!hasNode) return false;\n\n return true;\n }\n\n return false;\n },\n transform: (node: any, props: any, next: any) => {\n if (typeof node === 'string') {\n return node;\n }\n\n if (node.nodeType === NodeType.Insertion) {\n if (node.insertion.match(/\\{[^}]*,[^}]*\\}/)) {\n return node.insertion;\n }\n return node.insertion;\n }\n\n if (node.nodeType === NodeType.HTML) {\n return node.html;\n }\n\n if (node.nodeType === NodeType.Enumeration) {\n const options = node.enumeration;\n\n const transformedOptions: Record<string, string> = {};\n for (const [key, val] of Object.entries(options)) {\n if (key === '__intlayer_icu_var') continue;\n const childVal = next(val, props);\n transformedOptions[key] =\n typeof childVal === 'string' ? childVal : JSON.stringify(childVal);\n }\n\n let varName = options.__intlayer_icu_var || 'count';\n\n if (!options.__intlayer_icu_var) {\n const fallbackVal =\n transformedOptions.fallback ||\n transformedOptions.other ||\n Object.values(transformedOptions)[0];\n\n const match =\n fallbackVal.match(/\\{\\{([a-zA-Z0-9_]+)\\}\\}/) ||\n fallbackVal.match(/\\{([a-zA-Z0-9_]+)\\}(?!,)/);\n if (match) {\n varName = match[1];\n }\n }\n\n const keys = Object.keys(transformedOptions);\n const pluralKeys = [\n '1',\n '2',\n '<=3',\n '>=4',\n 'fallback',\n 'other',\n 'zero',\n 'one',\n 'two',\n 'few',\n 'many',\n ];\n const isPlural = keys.every(\n (k) => pluralKeys.includes(k) || /^[<>=]?\\d+(\\.\\d+)?$/.test(k)\n );\n\n const parts = [];\n\n if (isPlural) {\n for (const [key, val] of Object.entries(transformedOptions)) {\n let icuKey = key;\n if (key === 'fallback') icuKey = 'other';\n else if (key === '<=3') icuKey = 'few';\n else if (key === '>=4') icuKey = 'many';\n else if (/^\\d+$/.test(key)) icuKey = `=${key}`;\n\n let strVal = val;\n\n strVal = strVal.replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n strVal = strVal.replace(new RegExp(`\\\\{${varName}\\\\}`, 'g'), '#');\n\n parts.push(`${icuKey} {${strVal}}`);\n }\n return `{${varName}, plural, ${parts.join(' ')}}`;\n } else {\n const entries = Object.entries(transformedOptions).sort(\n ([keyA], [keyB]) => {\n if (keyA === 'fallback' || keyA === 'other') return 1;\n if (keyB === 'fallback' || keyB === 'other') return -1;\n return 0;\n }\n );\n\n for (const [key, val] of entries) {\n let icuKey = key;\n if (key === 'fallback') icuKey = 'other';\n\n let strVal = val;\n strVal = strVal.replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n\n parts.push(`${icuKey} {${strVal}}`);\n }\n return `{${varName}, select, ${parts.join(' ')}}`;\n }\n }\n\n if (node.nodeType === NodeType.Gender) {\n const options = node.gender;\n const varName = 'gender';\n const parts = [];\n\n const entries = Object.entries(options).sort(([keyA], [keyB]) => {\n if (keyA === 'fallback') return 1;\n if (keyB === 'fallback') return -1;\n return 0;\n });\n\n for (const [key, val] of entries) {\n let icuKey = key;\n if (key === 'fallback') icuKey = 'other';\n\n const childVal = next(val, props);\n let strVal =\n typeof childVal === 'string' ? childVal : JSON.stringify(childVal);\n\n strVal = strVal.replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n parts.push(`${icuKey} {${strVal}}`);\n }\n return `{${varName}, select, ${parts.join(' ')}}`;\n }\n\n if (\n Array.isArray(node) ||\n (node.nodeType === 'composite' && Array.isArray(node.composite))\n ) {\n const arr = Array.isArray(node) ? node : node.composite;\n const items = arr.map((item: any) => next(item, props));\n return items.join('');\n }\n\n return next(node, props);\n },\n};\n\nexport const intlayerToI18nextFormatter = (\n message: Dictionary['content']\n): JsonValue => {\n return deepTransformNode(message, {\n dictionaryKey: 'i18next',\n keyPath: [],\n plugins: [{ id: 'i18next', ...intlayerToI18nextPlugin }],\n });\n};\n\nexport const i18nextToIntlayerFormatter = (\n message: JsonValue\n): Dictionary['content'] => {\n return deepTransformNode(message, {\n dictionaryKey: 'i18next',\n keyPath: [],\n plugins: [{ id: 'i18next', ...i18nextToIntlayerPlugin }],\n });\n};\n"],"mappings":"sYAiBA,MAAM,EAAgB,GAAgC,CACpD,IAAI,EAAQ,EAEN,MAAkC,CACtC,IAAM,EAAuB,EAAE,CAC3B,EAAc,GAElB,KAAO,EAAQ,EAAK,QAAQ,CAC1B,IAAM,EAAO,EAAK,GAGlB,GAAI,IAAS,KAAO,EAAK,EAAQ,KAAO,IACtC,AAEE,KADA,EAAM,KAAK,EAAY,CACT,IAEhB,GAAS,EACT,EAAM,KAAK,GAAuB,CAAC,SAG5B,IAAS,IAChB,AAEE,KADA,EAAM,KAAK,EAAY,CACT,IAEhB,IACA,EAAM,KAAK,GAAkB,CAAC,SACrB,IAAS,IAElB,WAEA,GAAe,EACf,IAOJ,OAHI,GACF,EAAM,KAAK,EAAY,CAElB,GAGH,MAA2C,CAE/C,IAAI,EAAO,GACX,KAAO,EAAQ,EAAK,QAAQ,CAE1B,GAAI,EAAK,KAAW,KAAO,EAAK,EAAQ,KAAO,IAE7C,MADA,IAAS,EACF,CAAE,KAAM,WAAY,KAAM,EAAK,MAAM,CAAE,CAEhD,GAAQ,EAAK,GACb,IAEF,MAAU,MAAM,4BAA4B,EAGxC,MAAsC,CAE1C,IAAI,EAAO,GACX,KAAO,EAAQ,EAAK,QAAU,QAAQ,KAAK,EAAK,GAAO,EACrD,GAAQ,EAAK,GACb,IAIF,GAFA,EAAO,EAAK,MAAM,CAEd,GAAS,EAAK,OAAQ,MAAU,MAAM,oBAAoB,CAE9D,GAAI,EAAK,KAAW,IAElB,MADA,KACO,CAAE,KAAM,WAAY,OAAM,CAInC,GAAI,EAAK,KAAW,IAAK,CACvB,IAEA,IAAI,EAAO,GACX,KAAO,EAAQ,EAAK,QAAU,QAAQ,KAAK,EAAK,GAAO,EACrD,GAAQ,EAAK,GACb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AS,CAEpE,EAAS,EAAO,QAAQ,mBAAoB,OAAO,CACnD,EAAM,KAAK,GAAG,EAAO,IAAI,EAAO,GAAG,CAErC,MAAO,oBAAwB,EAAM,KAAK,IAAI,CAAC,GAYjD,OARE,MAAM,QAAQ,EAAK,EAClB,EAAK,WAAa,aAAe,MAAM,QAAQ,EAAK,UAAU,EAEnD,MAAM,QAAQ,EAAK,CAAG,EAAO,EAAK,WAC5B,IAAK,GAAc,EAAK,EAAM,EAAM,CAAC,CAC1C,KAAK,GAAG,CAGhB,EAAK,EAAM,EAAM,EAE3B,CAEY,EACX,GAEOC,EAAAA,kBAAkB,EAAS,CAChC,cAAe,UACf,QAAS,EAAE,CACX,QAAS,CAAC,CAAE,GAAI,UAAW,GAAG,EAAyB,CAAC,CACzD,CAAC,CAGS,EACX,GAEOA,EAAAA,kBAAkB,EAAS,CAChC,cAAe,UACf,QAAS,EAAE,CACX,QAAS,CAAC,CAAE,GAAI,UAAW,GAAG,EAAyB,CAAC,CACzD,CAAC"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../interpreter/getContent/deepTransform.cjs`),t=require(`../transpiler/enumeration/enumeration.cjs`),n=require(`../transpiler/insertion/insertion.cjs`);let r=require(`@intlayer/types/nodeType`);const i=e=>{let t=0,n=[],r=``;for(;t<e.length;){let i=e[t];if(i===`{`){r&&=(n.push(r),``),t++;let i=``;for(;t<e.length&&e[t]!==`}`;)i+=e[t],t++;t<e.length&&t++,n.push({type:`argument`,name:i.trim()})}else r+=i,t++}return r&&n.push(r),n},a=e=>{let t=[],n=``,r=0;for(;r<e.length;){let i=e[r];i===`\\`&&r+1<e.length&&e[r+1]===`|`?(n+=`|`,r+=2):i===`|`?(t.push(n.trim()),n=``,r++):(n+=i,r++)}return t.push(n.trim()),t.map(i)},o=e=>{if(e.length===0)return``;if(e.length===1&&typeof e[0]==`string`)return e[0];let t=``;for(let n of e)typeof n==`string`?t+=n:t+=`{{${n.name}}}`;return n.insert(t)},s=e=>{if(e.length===1)return o(e[0]);let n={};return e.length===2?(n[1]=o(e[0]),n.fallback=o(e[1])):e.length===3?(n[0]=o(e[0]),n[1]=o(e[1]),n.fallback=o(e[2])):e.forEach((t,r)=>{r===e.length-1?n.fallback=o(t):n[r.toString()]=o(t)}),n.__intlayer_vue_i18n_var=`count`,t.enu(n)},c={canHandle:e=>typeof e==`string`&&(e.includes(`{`)||e.includes(`|`)),transform:e=>{try{return s(a(e))}catch{return e}}},l={canHandle:e=>{if(typeof e==`string`||e&&typeof e==`object`&&(e.nodeType===r.NodeType.Insertion||e.nodeType===r.NodeType.Enumeration||e.nodeType===r.NodeType.Gender||e.nodeType===`composite`))return!0;if(Array.isArray(e)){if(e.length===0)return!1;let t=!1,n=!1;for(let i of e)typeof i==`string`||(i&&typeof i==`object`&&(i.nodeType===r.NodeType.Insertion||i.nodeType===r.NodeType.Enumeration||i.nodeType===r.NodeType.Gender||i.nodeType===`composite`)?t=!0:n=!0);return!(n||!t)}return!1},transform:(e,t,n)=>{if(typeof e==`string`)return e.replace(/\{\{([^}]+)\}\}/g,`{$1}`);if(e.nodeType===r.NodeType.Insertion)return e.insertion.replace(/\{\{([^}]+)\}\}/g,`{$1}`);if(e.nodeType===r.NodeType.Enumeration){let r=e.enumeration,i={};for(let[e,a]of Object.entries(r)){if(e===`__intlayer_vue_i18n_var`)continue;let r=n(a,t);i[e]=typeof r==`string`?r:JSON.stringify(r)}let a=Object.keys(i);if(a.includes(`0`)){let e=a.filter(e=>/^\d+$/.test(e)).map(Number),t=Math.max(...e),n=i.fallback||i.other,r=[];if(t<=1&&!a.includes(`2`))return`${i[0]||``} | ${i[1]||``} | ${n}`;let o=Math.max(1,t);for(let e=0;e<=o;e++){let t=e.toString();i[t]?r.push(i[t]):r.push(``)}return r.push(n),r.join(` | `).replace(/ \| {2}\| /g,` | | `)}return a.includes(`1`)&&(a.includes(`fallback`)||a.includes(`other`))?`${i[1]} | ${i.fallback||i.other}`:a.length===1&&(a.includes(`fallback`)||a.includes(`other`))?i.fallback||i.other:i.fallback||Object.values(i)[0]}if(e.nodeType===r.NodeType.Gender){let r=e.gender,i={};for(let[e,a]of Object.entries(r)){let r=e;e===`fallback`&&(r=`other`),i[r]=n(a,t)}return i}return Array.isArray(e)||e.nodeType===`composite`&&Array.isArray(e.composite)?(Array.isArray(e)?e:e.composite).map(e=>n(e,t)).join(``):n(e,t)}},u=t=>e.deepTransformNode(t,{dictionaryKey:`vue-i18n`,keyPath:[],plugins:[{id:`vue-i18n`,...l}]}),d=t=>e.deepTransformNode(t,{dictionaryKey:`vue-i18n`,keyPath:[],plugins:[{id:`vue-i18n`,...c}]});exports.intlayerToVueI18nFormatter=u,exports.vueI18nToIntlayerFormatter=d;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);const e=require(`../interpreter/getContent/deepTransform.cjs`),t=require(`../transpiler/enumeration/enumeration.cjs`),n=require(`../transpiler/insertion/insertion.cjs`);let r=require(`@intlayer/types/nodeType`);const i=e=>{let t=0,n=[],r=``;for(;t<e.length;){let i=e[t];if(i===`{`){r&&=(n.push(r),``),t++;let i=``;for(;t<e.length&&e[t]!==`}`;)i+=e[t],t++;t<e.length&&t++,n.push({type:`argument`,name:i.trim()})}else r+=i,t++}return r&&n.push(r),n},a=e=>{let t=[],n=``,r=0;for(;r<e.length;){let i=e[r];i===`\\`&&r+1<e.length&&e[r+1]===`|`?(n+=`|`,r+=2):i===`|`?(t.push(n.trim()),n=``,r++):(n+=i,r++)}return t.push(n.trim()),t.map(i)},o=e=>{if(e.length===0)return``;if(e.length===1&&typeof e[0]==`string`)return e[0];let t=``;for(let n of e)typeof n==`string`?t+=n:t+=`{{${n.name}}}`;return n.insert(t)},s=e=>{if(e.length===1)return o(e[0]);let n={};return e.length===2?(n[1]=o(e[0]),n.fallback=o(e[1])):e.length===3?(n[0]=o(e[0]),n[1]=o(e[1]),n.fallback=o(e[2])):e.forEach((t,r)=>{r===e.length-1?n.fallback=o(t):n[r.toString()]=o(t)}),n.__intlayer_vue_i18n_var=`count`,t.enu(n)},c={canHandle:e=>typeof e==`string`&&(e.includes(`{`)||e.includes(`|`)),transform:e=>{try{return s(a(e))}catch{return e}}},l={canHandle:e=>{if(typeof e==`string`||e&&typeof e==`object`&&(e.nodeType===r.NodeType.Insertion||e.nodeType===r.NodeType.Enumeration||e.nodeType===r.NodeType.Gender||e.nodeType===`composite`))return!0;if(Array.isArray(e)){if(e.length===0)return!1;let t=!1,n=!1;for(let i of e)typeof i==`string`||(i&&typeof i==`object`&&(i.nodeType===r.NodeType.Insertion||i.nodeType===r.NodeType.Enumeration||i.nodeType===r.NodeType.Gender||i.nodeType===`composite`)?t=!0:n=!0);return!(n||!t)}return!1},transform:(e,t,n)=>{if(typeof e==`string`)return e.replace(/\{\{([^}]+)\}\}/g,`{$1}`);if(e.nodeType===r.NodeType.Insertion)return e.insertion.replace(/\{\{([^}]+)\}\}/g,`{$1}`);if(e.nodeType===r.NodeType.Enumeration){let r=e.enumeration,i={};for(let[e,a]of Object.entries(r)){if(e===`__intlayer_vue_i18n_var`)continue;let r=n(a,t);i[e]=typeof r==`string`?r:JSON.stringify(r)}let a=Object.keys(i);if(a.includes(`0`)){let e=a.filter(e=>/^\d+$/.test(e)).map(Number),t=Math.max(...e),n=i.fallback||i.other,r=[];if(t<=1&&!a.includes(`2`))return`${i[0]||``} | ${i[1]||``} | ${n}`;let o=Math.max(1,t);for(let e=0;e<=o;e++){let t=e.toString();i[t]?r.push(i[t]):r.push(``)}return r.push(n),r.join(` | `).replace(/ \| {2}\| /g,` | | `)}return a.includes(`1`)&&(a.includes(`fallback`)||a.includes(`other`))?`${i[1]} | ${i.fallback||i.other}`:a.length===1&&(a.includes(`fallback`)||a.includes(`other`))?i.fallback||i.other:i.fallback||Object.values(i)[0]}if(e.nodeType===r.NodeType.Gender){let r=e.gender,i={};for(let[e,a]of Object.entries(r)){let r=e;e===`fallback`&&(r=`other`),i[r]=n(a,t)}return i}return Array.isArray(e)||e.nodeType===`composite`&&Array.isArray(e.composite)?(Array.isArray(e)?e:e.composite).map(e=>n(e,t)).join(``):n(e,t)}},u=t=>e.deepTransformNode(t,{dictionaryKey:`vue-i18n`,keyPath:[],plugins:[{id:`vue-i18n`,...l}]}),d=t=>e.deepTransformNode(t,{dictionaryKey:`vue-i18n`,keyPath:[],plugins:[{id:`vue-i18n`,...c}]});exports.intlayerToVueI18nFormatter=u,exports.vueI18nToIntlayerFormatter=d;
2
2
  //# sourceMappingURL=vue-i18n.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"vue-i18n.cjs","names":["insert","enu","NodeType","deepTransformNode"],"sources":["../../../src/messageFormat/vue-i18n.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\n\nimport { NodeType } from '@intlayer/types/nodeType';\nimport { deepTransformNode } from '../interpreter';\nimport { enu, insert } from '../transpiler';\nimport type { JsonValue } from './ICU';\n\n// Types for our AST\ntype VueI18nNode =\n | string\n | {\n type: 'argument';\n name: string;\n };\n\nconst parseVueI18nPart = (text: string): VueI18nNode[] => {\n let index = 0;\n const nodes: VueI18nNode[] = [];\n let currentText = '';\n\n while (index < text.length) {\n const char = text[index];\n\n if (char === '{') {\n if (currentText) {\n nodes.push(currentText);\n currentText = '';\n }\n index++; // skip {\n let name = '';\n while (index < text.length && text[index] !== '}') {\n name += text[index];\n index++;\n }\n if (index < text.length) {\n index++; // skip }\n }\n nodes.push({ type: 'argument', name: name.trim() });\n } else {\n currentText += char;\n index++;\n }\n }\n\n if (currentText) {\n nodes.push(currentText);\n }\n\n return nodes;\n};\n\nconst parseVueI18n = (text: string): VueI18nNode[][] => {\n // Split by | but handle escaped \\|\n const parts: string[] = [];\n let currentPart = '';\n let index = 0;\n\n while (index < text.length) {\n const char = text[index];\n if (char === '\\\\' && index + 1 < text.length && text[index + 1] === '|') {\n currentPart += '|';\n index += 2;\n } else if (char === '|') {\n parts.push(currentPart.trim()); // Trim to remove surrounding spaces\n currentPart = '';\n index++;\n } else {\n currentPart += char;\n index++;\n }\n }\n parts.push(currentPart.trim()); // Trim last part too\n\n return parts.map(parseVueI18nPart);\n};\n\nconst vueI18nPartToIntlayer = (nodes: VueI18nNode[]): any => {\n if (nodes.length === 0) return '';\n if (nodes.length === 1 && typeof nodes[0] === 'string') return nodes[0];\n\n let str = '';\n for (const node of nodes) {\n if (typeof node === 'string') {\n str += node;\n } else {\n str += `{{${node.name}}}`;\n }\n }\n return insert(str);\n};\n\nconst vueI18nNodesToIntlayer = (parts: VueI18nNode[][]): any => {\n if (parts.length === 1) {\n return vueI18nPartToIntlayer(parts[0]);\n }\n\n // Handle pluralization (choice)\n const options: Record<string, any> = {};\n const varName = 'count'; // Default variable for vue-i18n choices\n\n if (parts.length === 2) {\n // 2 choices: 1 | other\n options['1'] = vueI18nPartToIntlayer(parts[0]);\n options.fallback = vueI18nPartToIntlayer(parts[1]);\n } else if (parts.length === 3) {\n // 3 choices: 0 | 1 | other\n options['0'] = vueI18nPartToIntlayer(parts[0]);\n options['1'] = vueI18nPartToIntlayer(parts[1]);\n options.fallback = vueI18nPartToIntlayer(parts[2]);\n } else {\n // > 3 choices: 0 | 1 | 2 | ... | other\n parts.forEach((part, index) => {\n if (index === parts.length - 1) {\n options.fallback = vueI18nPartToIntlayer(part);\n } else {\n options[index.toString()] = vueI18nPartToIntlayer(part);\n }\n });\n }\n\n // Preserve variable name\n options.__intlayer_vue_i18n_var = varName;\n\n return enu(options);\n};\n\nconst vueI18nToIntlayerPlugin = {\n canHandle: (node: any) =>\n typeof node === 'string' && (node.includes('{') || node.includes('|')),\n transform: (node: any) => {\n try {\n const ast = parseVueI18n(node);\n return vueI18nNodesToIntlayer(ast);\n } catch {\n return node;\n }\n },\n};\n\nconst intlayerToVueI18nPlugin = {\n canHandle: (node: any) => {\n if (typeof node === 'string') return true;\n\n if (\n node &&\n typeof node === 'object' &&\n (node.nodeType === NodeType.Insertion ||\n node.nodeType === NodeType.Enumeration ||\n node.nodeType === NodeType.Gender ||\n node.nodeType === 'composite')\n ) {\n return true;\n }\n\n if (Array.isArray(node)) {\n if (node.length === 0) return false;\n\n let hasNode = false;\n let hasPlainObjectOrArray = false;\n\n for (const item of node) {\n if (typeof item === 'string') {\n } else if (\n item &&\n typeof item === 'object' &&\n (item.nodeType === NodeType.Insertion ||\n item.nodeType === NodeType.Enumeration ||\n item.nodeType === NodeType.Gender ||\n item.nodeType === 'composite')\n ) {\n hasNode = true;\n } else {\n hasPlainObjectOrArray = true;\n }\n }\n\n // If it contains plain objects or nested arrays, it's a structural array\n if (hasPlainObjectOrArray) return false;\n // If it contains ONLY strings, it's a structural array, not a composite string\n if (!hasNode) return false;\n\n return true;\n }\n\n return false;\n },\n transform: (node: any, props: any, next: any) => {\n if (typeof node === 'string') {\n // replace {{...}} with {...} even in strings\n return node.replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n }\n\n if (node.nodeType === NodeType.Insertion) {\n // {{name}} -> {name}\n return node.insertion.replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n }\n\n if (node.nodeType === NodeType.Enumeration) {\n const options = node.enumeration;\n\n const transformedOptions: Record<string, string> = {};\n for (const [key, val] of Object.entries(options)) {\n if (key === '__intlayer_vue_i18n_var') continue;\n const childVal = next(val, props);\n transformedOptions[key] =\n typeof childVal === 'string' ? childVal : JSON.stringify(childVal);\n }\n\n const keys = Object.keys(transformedOptions);\n\n if (keys.includes('0')) {\n const indices = keys.filter((key) => /^\\d+$/.test(key)).map(Number);\n const maxIndex = Math.max(...indices);\n\n const fallback =\n transformedOptions.fallback || transformedOptions.other;\n const resultParts = [];\n\n if (maxIndex <= 1 && !keys.includes('2')) {\n const zero = transformedOptions['0'] || '';\n const one = transformedOptions['1'] || '';\n return `${zero} | ${one} | ${fallback}`;\n }\n\n const limit = Math.max(1, maxIndex);\n\n for (let i = 0; i <= limit; i++) {\n const key = i.toString();\n if (transformedOptions[key]) {\n resultParts.push(transformedOptions[key]);\n } else {\n resultParts.push('');\n }\n }\n resultParts.push(fallback);\n return resultParts.join(' | ').replace(/ \\| {2}\\| /g, ' | | ');\n }\n\n if (\n keys.includes('1') &&\n (keys.includes('fallback') || keys.includes('other'))\n ) {\n return `${transformedOptions['1']} | ${transformedOptions.fallback || transformedOptions.other}`;\n }\n\n if (\n keys.length === 1 &&\n (keys.includes('fallback') || keys.includes('other'))\n ) {\n return transformedOptions.fallback || transformedOptions.other;\n }\n\n return (\n transformedOptions.fallback || Object.values(transformedOptions)[0]\n );\n }\n\n if (node.nodeType === NodeType.Gender) {\n const options = node.gender;\n const transformedOptions: Record<string, any> = {};\n\n for (const [key, val] of Object.entries(options)) {\n let newKey = key;\n if (key === 'fallback') newKey = 'other';\n\n const childVal = next(val, props);\n transformedOptions[newKey] = childVal;\n }\n return transformedOptions;\n }\n\n if (\n Array.isArray(node) ||\n (node.nodeType === 'composite' && Array.isArray(node.composite))\n ) {\n const arr = Array.isArray(node) ? node : node.composite;\n const items = arr.map((item: any) => next(item, props));\n return items.join('');\n }\n\n return next(node, props);\n },\n};\n\nexport const intlayerToVueI18nFormatter = (\n message: Dictionary['content']\n): JsonValue => {\n return deepTransformNode(message, {\n dictionaryKey: 'vue-i18n',\n keyPath: [],\n plugins: [{ id: 'vue-i18n', ...intlayerToVueI18nPlugin }],\n });\n};\n\nexport const vueI18nToIntlayerFormatter = (\n message: JsonValue\n): Dictionary['content'] => {\n return deepTransformNode(message, {\n dictionaryKey: 'vue-i18n',\n keyPath: [],\n plugins: [{ id: 'vue-i18n', ...vueI18nToIntlayerPlugin }],\n });\n};\n"],"mappings":"mUAeA,MAAM,EAAoB,GAAgC,CACxD,IAAI,EAAQ,EACN,EAAuB,EAAE,CAC3B,EAAc,GAElB,KAAO,EAAQ,EAAK,QAAQ,CAC1B,IAAM,EAAO,EAAK,GAElB,GAAI,IAAS,IAAK,CAChB,AAEE,KADA,EAAM,KAAK,EAAY,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CAAE,CAChD,IAAI,EAAS,EACT,IAAQ,aAAY,EAAS,SAGjC,EAAmB,GADF,EAAK,EAAK,EAAM,CAGnC,OAAO,EAYT,OARE,MAAM,QAAQ,EAAK,EAClB,EAAK,WAAa,aAAe,MAAM,QAAQ,EAAK,UAAU,EAEnD,MAAM,QAAQ,EAAK,CAAG,EAAO,EAAK,WAC5B,IAAK,GAAc,EAAK,EAAM,EAAM,CAAC,CAC1C,KAAK,GAAG,CAGhB,EAAK,EAAM,EAAM,EAE3B,CAEY,EACX,GAEOC,EAAAA,kBAAkB,EAAS,CAChC,cAAe,WACf,QAAS,EAAE,CACX,QAAS,CAAC,CAAE,GAAI,WAAY,GAAG,EAAyB,CAAC,CAC1D,CAAC,CAGS,EACX,GAEOA,EAAAA,kBAAkB,EAAS,CAChC,cAAe,WACf,QAAS,EAAE,CACX,QAAS,CAAC,CAAE,GAAI,WAAY,GAAG,EAAyB,CAAC,CAC1D,CAAC"}
1
+ {"version":3,"file":"vue-i18n.cjs","names":["insert","enu","NodeType","deepTransformNode"],"sources":["../../../src/messageFormat/vue-i18n.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\n\nimport { NodeType } from '@intlayer/types/nodeType';\nimport { deepTransformNode } from '../interpreter';\nimport { enu, insert } from '../transpiler';\nimport type { JsonValue } from './ICU';\n\n// Types for our AST\ntype VueI18nNode =\n | string\n | {\n type: 'argument';\n name: string;\n };\n\nconst parseVueI18nPart = (text: string): VueI18nNode[] => {\n let index = 0;\n const nodes: VueI18nNode[] = [];\n let currentText = '';\n\n while (index < text.length) {\n const char = text[index];\n\n if (char === '{') {\n if (currentText) {\n nodes.push(currentText);\n currentText = '';\n }\n index++; // skip {\n let name = '';\n while (index < text.length && text[index] !== '}') {\n name += text[index];\n index++;\n }\n if (index < text.length) {\n index++; // skip }\n }\n nodes.push({ type: 'argument', name: name.trim() });\n } else {\n currentText += char;\n index++;\n }\n }\n\n if (currentText) {\n nodes.push(currentText);\n }\n\n return nodes;\n};\n\nconst parseVueI18n = (text: string): VueI18nNode[][] => {\n // Split by | but handle escaped \\|\n const parts: string[] = [];\n let currentPart = '';\n let index = 0;\n\n while (index < text.length) {\n const char = text[index];\n if (char === '\\\\' && index + 1 < text.length && text[index + 1] === '|') {\n currentPart += '|';\n index += 2;\n } else if (char === '|') {\n parts.push(currentPart.trim()); // Trim to remove surrounding spaces\n currentPart = '';\n index++;\n } else {\n currentPart += char;\n index++;\n }\n }\n parts.push(currentPart.trim()); // Trim last part too\n\n return parts.map(parseVueI18nPart);\n};\n\nconst vueI18nPartToIntlayer = (nodes: VueI18nNode[]): any => {\n if (nodes.length === 0) return '';\n if (nodes.length === 1 && typeof nodes[0] === 'string') return nodes[0];\n\n let str = '';\n for (const node of nodes) {\n if (typeof node === 'string') {\n str += node;\n } else {\n str += `{{${node.name}}}`;\n }\n }\n return insert(str);\n};\n\nconst vueI18nNodesToIntlayer = (parts: VueI18nNode[][]): any => {\n if (parts.length === 1) {\n return vueI18nPartToIntlayer(parts[0]);\n }\n\n // Handle pluralization (choice)\n const options: Record<string, any> = {};\n const varName = 'count'; // Default variable for vue-i18n choices\n\n if (parts.length === 2) {\n // 2 choices: 1 | other\n options['1'] = vueI18nPartToIntlayer(parts[0]);\n options.fallback = vueI18nPartToIntlayer(parts[1]);\n } else if (parts.length === 3) {\n // 3 choices: 0 | 1 | other\n options['0'] = vueI18nPartToIntlayer(parts[0]);\n options['1'] = vueI18nPartToIntlayer(parts[1]);\n options.fallback = vueI18nPartToIntlayer(parts[2]);\n } else {\n // > 3 choices: 0 | 1 | 2 | ... | other\n parts.forEach((part, index) => {\n if (index === parts.length - 1) {\n options.fallback = vueI18nPartToIntlayer(part);\n } else {\n options[index.toString()] = vueI18nPartToIntlayer(part);\n }\n });\n }\n\n // Preserve variable name\n options.__intlayer_vue_i18n_var = varName;\n\n return enu(options);\n};\n\nconst vueI18nToIntlayerPlugin = {\n canHandle: (node: any) =>\n typeof node === 'string' && (node.includes('{') || node.includes('|')),\n transform: (node: any) => {\n try {\n const ast = parseVueI18n(node);\n return vueI18nNodesToIntlayer(ast);\n } catch {\n return node;\n }\n },\n};\n\nconst intlayerToVueI18nPlugin = {\n canHandle: (node: any) => {\n if (typeof node === 'string') return true;\n\n if (\n node &&\n typeof node === 'object' &&\n (node.nodeType === NodeType.Insertion ||\n node.nodeType === NodeType.Enumeration ||\n node.nodeType === NodeType.Gender ||\n node.nodeType === 'composite')\n ) {\n return true;\n }\n\n if (Array.isArray(node)) {\n if (node.length === 0) return false;\n\n let hasNode = false;\n let hasPlainObjectOrArray = false;\n\n for (const item of node) {\n if (typeof item === 'string') {\n } else if (\n item &&\n typeof item === 'object' &&\n (item.nodeType === NodeType.Insertion ||\n item.nodeType === NodeType.Enumeration ||\n item.nodeType === NodeType.Gender ||\n item.nodeType === 'composite')\n ) {\n hasNode = true;\n } else {\n hasPlainObjectOrArray = true;\n }\n }\n\n // If it contains plain objects or nested arrays, it's a structural array\n if (hasPlainObjectOrArray) return false;\n // If it contains ONLY strings, it's a structural array, not a composite string\n if (!hasNode) return false;\n\n return true;\n }\n\n return false;\n },\n transform: (node: any, props: any, next: any) => {\n if (typeof node === 'string') {\n // replace {{...}} with {...} even in strings\n return node.replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n }\n\n if (node.nodeType === NodeType.Insertion) {\n // {{name}} -> {name}\n return node.insertion.replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n }\n\n if (node.nodeType === NodeType.Enumeration) {\n const options = node.enumeration;\n\n const transformedOptions: Record<string, string> = {};\n for (const [key, val] of Object.entries(options)) {\n if (key === '__intlayer_vue_i18n_var') continue;\n const childVal = next(val, props);\n transformedOptions[key] =\n typeof childVal === 'string' ? childVal : JSON.stringify(childVal);\n }\n\n const keys = Object.keys(transformedOptions);\n\n if (keys.includes('0')) {\n const indices = keys.filter((key) => /^\\d+$/.test(key)).map(Number);\n const maxIndex = Math.max(...indices);\n\n const fallback =\n transformedOptions.fallback || transformedOptions.other;\n const resultParts = [];\n\n if (maxIndex <= 1 && !keys.includes('2')) {\n const zero = transformedOptions['0'] || '';\n const one = transformedOptions['1'] || '';\n return `${zero} | ${one} | ${fallback}`;\n }\n\n const limit = Math.max(1, maxIndex);\n\n for (let i = 0; i <= limit; i++) {\n const key = i.toString();\n if (transformedOptions[key]) {\n resultParts.push(transformedOptions[key]);\n } else {\n resultParts.push('');\n }\n }\n resultParts.push(fallback);\n return resultParts.join(' | ').replace(/ \\| {2}\\| /g, ' | | ');\n }\n\n if (\n keys.includes('1') &&\n (keys.includes('fallback') || keys.includes('other'))\n ) {\n return `${transformedOptions['1']} | ${transformedOptions.fallback || transformedOptions.other}`;\n }\n\n if (\n keys.length === 1 &&\n (keys.includes('fallback') || keys.includes('other'))\n ) {\n return transformedOptions.fallback || transformedOptions.other;\n }\n\n return (\n transformedOptions.fallback || Object.values(transformedOptions)[0]\n );\n }\n\n if (node.nodeType === NodeType.Gender) {\n const options = node.gender;\n const transformedOptions: Record<string, any> = {};\n\n for (const [key, val] of Object.entries(options)) {\n let newKey = key;\n if (key === 'fallback') newKey = 'other';\n\n const childVal = next(val, props);\n transformedOptions[newKey] = childVal;\n }\n return transformedOptions;\n }\n\n if (\n Array.isArray(node) ||\n (node.nodeType === 'composite' && Array.isArray(node.composite))\n ) {\n const arr = Array.isArray(node) ? node : node.composite;\n const items = arr.map((item: any) => next(item, props));\n return items.join('');\n }\n\n return next(node, props);\n },\n};\n\nexport const intlayerToVueI18nFormatter = (\n message: Dictionary['content']\n): JsonValue => {\n return deepTransformNode(message, {\n dictionaryKey: 'vue-i18n',\n keyPath: [],\n plugins: [{ id: 'vue-i18n', ...intlayerToVueI18nPlugin }],\n });\n};\n\nexport const vueI18nToIntlayerFormatter = (\n message: JsonValue\n): Dictionary['content'] => {\n return deepTransformNode(message, {\n dictionaryKey: 'vue-i18n',\n keyPath: [],\n plugins: [{ id: 'vue-i18n', ...vueI18nToIntlayerPlugin }],\n });\n};\n"],"mappings":"uTAeA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zD,EAAmB,UAAY,OAAO,OAAO,EAAmB,CAAC,GAIrE,GAAI,EAAK,WAAaA,EAAAA,SAAS,OAAQ,CACrC,IAAM,EAAU,EAAK,OACf,EAA0C,EAAE,CAElD,IAAK,GAAM,CAAC,EAAK,KAAQ,OAAO,QAAQ,EAAQ,CAAE,CAChD,IAAI,EAAS,EACT,IAAQ,aAAY,EAAS,SAGjC,EAAmB,GADF,EAAK,EAAK,EAAM,CAGnC,OAAO,EAYT,OARE,MAAM,QAAQ,EAAK,EAClB,EAAK,WAAa,aAAe,MAAM,QAAQ,EAAK,UAAU,EAEnD,MAAM,QAAQ,EAAK,CAAG,EAAO,EAAK,WAC5B,IAAK,GAAc,EAAK,EAAM,EAAM,CAAC,CAC1C,KAAK,GAAG,CAGhB,EAAK,EAAM,EAAM,EAE3B,CAEY,EACX,GAEOC,EAAAA,kBAAkB,EAAS,CAChC,cAAe,WACf,QAAS,EAAE,CACX,QAAS,CAAC,CAAE,GAAI,WAAY,GAAG,EAAyB,CAAC,CAC1D,CAAC,CAGS,EACX,GAEOA,EAAAA,kBAAkB,EAAS,CAChC,cAAe,WACf,QAAS,EAAE,CACX,QAAS,CAAC,CAAE,GAAI,WAAY,GAAG,EAAyB,CAAC,CAC1D,CAAC"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);let e=require(`@intlayer/types/nodeType`);const t=t=>(0,e.formatNodeType)(e.NodeType.Condition,t);exports.cond=t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../chunk-Bmb41Sf3.cjs`);let e=require(`@intlayer/types/nodeType`);const t=t=>(0,e.formatNodeType)(e.NodeType.Condition,t);exports.cond=t;
2
2
  //# sourceMappingURL=condition.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"condition.cjs","names":["NodeType"],"sources":["../../../../src/transpiler/condition/condition.ts"],"sourcesContent":["import { formatNodeType, NodeType } from '@intlayer/types/nodeType';\nimport type { TypedNodeModel } from '@intlayer/types/nodeType';;\n\nexport type ConditionContentStates<Content> = Record<`${boolean}`, Content> & {\n fallback?: Content;\n};\n\nexport type ConditionContent<Content = unknown> = TypedNodeModel<\n NodeType.Condition,\n ConditionContentStates<Content>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a condition.\n *\n * Usage:\n *\n * ```ts\n * cond({\n * 'true': 'The condition is validated',\n * 'false': 'The condition is not validated',\n * });\n * ```\n *\n * The last key provided will be used as the fallback value.\n *\n */\nconst condition = <Content>(content?: ConditionContentStates<Content>) =>\n formatNodeType(NodeType.Condition, content);\n\nexport { condition as cond };\n"],"mappings":"6JA6BA,MAAM,EAAsB,IAAA,EAAA,EAAA,gBACXA,EAAAA,SAAS,UAAW,EAAQ"}
1
+ {"version":3,"file":"condition.cjs","names":["NodeType"],"sources":["../../../../src/transpiler/condition/condition.ts"],"sourcesContent":["import { formatNodeType, NodeType } from '@intlayer/types/nodeType';\nimport type { TypedNodeModel } from '@intlayer/types/nodeType';;\n\nexport type ConditionContentStates<Content> = Record<`${boolean}`, Content> & {\n fallback?: Content;\n};\n\nexport type ConditionContent<Content = unknown> = TypedNodeModel<\n NodeType.Condition,\n ConditionContentStates<Content>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a condition.\n *\n * Usage:\n *\n * ```ts\n * cond({\n * 'true': 'The condition is validated',\n * 'false': 'The condition is not validated',\n * });\n * ```\n *\n * The last key provided will be used as the fallback value.\n *\n */\nconst condition = <Content>(content?: ConditionContentStates<Content>) =>\n formatNodeType(NodeType.Condition, content);\n\nexport { condition as cond };\n"],"mappings":"iJA6BA,MAAM,EAAsB,IAAA,EAAA,EAAA,gBACXA,EAAAA,SAAS,UAAW,EAAQ"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);let e=require(`@intlayer/types/nodeType`);const t=t=>(0,e.formatNodeType)(e.NodeType.Enumeration,t);exports.enu=t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../chunk-Bmb41Sf3.cjs`);let e=require(`@intlayer/types/nodeType`);const t=t=>(0,e.formatNodeType)(e.NodeType.Enumeration,t);exports.enu=t;
2
2
  //# sourceMappingURL=enumeration.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"enumeration.cjs","names":["NodeType"],"sources":["../../../../src/transpiler/enumeration/enumeration.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, NodeType } from '@intlayer/types/nodeType';\n\ntype Positive = number | `${number}`;\ntype Negative = `-${number}`;\ntype Numbers = Positive | Negative;\n\ntype Equal = Numbers;\ntype EqualString = `=${Numbers}`;\ntype Superior = `>${Numbers}`;\ntype SuperiorOrEqual = `>=${Numbers}`;\ntype Inferior = `<${Numbers}`;\ntype InferiorOrEqual = `<=${Numbers}`;\n\nexport type EnterFormat =\n | Equal\n | EqualString\n | Superior\n | SuperiorOrEqual\n | Inferior\n | InferiorOrEqual;\n\nexport type EnumerationContentState<Content> = Partial<\n Record<EnterFormat, Content>\n> & {\n fallback?: Content;\n};\n\nexport type EnumerationContent<Content = unknown> = TypedNodeModel<\n NodeType.Enumeration,\n EnumerationContentState<Content>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a quantity.\n *\n * Usage:\n *\n * ```ts\n * enu({\n * '<=-2.3': 'You have less than -2.3',\n * '<1': 'You have less than one',\n * '2': 'You have two',\n * '>=3': 'You have three or more',\n * });\n * ```\n *\n * > The order of the keys will define the priority of the content.\n *\n */\nconst enumeration = <Content = unknown>(\n content?: EnumerationContentState<Content>\n) => formatNodeType(NodeType.Enumeration, content);\n\nexport { enumeration as enu };\n"],"mappings":"6JAoDA,MAAM,EACJ,IAAA,EAAA,EAAA,gBACkBA,EAAAA,SAAS,YAAa,EAAQ"}
1
+ {"version":3,"file":"enumeration.cjs","names":["NodeType"],"sources":["../../../../src/transpiler/enumeration/enumeration.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, NodeType } from '@intlayer/types/nodeType';\n\ntype Positive = number | `${number}`;\ntype Negative = `-${number}`;\ntype Numbers = Positive | Negative;\n\ntype Equal = Numbers;\ntype EqualString = `=${Numbers}`;\ntype Superior = `>${Numbers}`;\ntype SuperiorOrEqual = `>=${Numbers}`;\ntype Inferior = `<${Numbers}`;\ntype InferiorOrEqual = `<=${Numbers}`;\n\nexport type EnterFormat =\n | Equal\n | EqualString\n | Superior\n | SuperiorOrEqual\n | Inferior\n | InferiorOrEqual;\n\nexport type EnumerationContentState<Content> = Partial<\n Record<EnterFormat, Content>\n> & {\n fallback?: Content;\n};\n\nexport type EnumerationContent<Content = unknown> = TypedNodeModel<\n NodeType.Enumeration,\n EnumerationContentState<Content>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a quantity.\n *\n * Usage:\n *\n * ```ts\n * enu({\n * '<=-2.3': 'You have less than -2.3',\n * '<1': 'You have less than one',\n * '2': 'You have two',\n * '>=3': 'You have three or more',\n * });\n * ```\n *\n * > The order of the keys will define the priority of the content.\n *\n */\nconst enumeration = <Content = unknown>(\n content?: EnumerationContentState<Content>\n) => formatNodeType(NodeType.Enumeration, content);\n\nexport { enumeration as enu };\n"],"mappings":"iJAoDA,MAAM,EACJ,IAAA,EAAA,EAAA,gBACkBA,EAAAA,SAAS,YAAa,EAAQ"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);let e=require(`@intlayer/types/nodeType`),t=require(`@intlayer/config/logger`),n=require(`node:fs`),r=require(`node:path`);const i=(i,a,o)=>{let s=i.startsWith(`./`)||i.startsWith(`../`),c=(0,t.getAppLogger)(),l;if((0,r.isAbsolute)(i)?(c(`Using absolute path for file is not recommended. Use relative paths instead. Path: ${i}, imported from: ${a}`,{level:`warn`}),l=i):l=s?(0,r.resolve)(a,i):(0,r.resolve)(o,i),(0,n.existsSync)(l)&&(0,n.statSync)(l).isFile())try{let t=(0,n.readFileSync)(l,`utf8`);return(0,e.formatNodeType)(e.NodeType.File,i,{content:t,fixedPath:(0,r.relative)(o,l)})}catch{c(`Unable to read path: ${(0,t.colorizePath)((0,r.relative)(o,l))}`,{level:`warn`})}else c(`File not found: ${(0,t.colorizePath)((0,r.relative)(o,l))}`,{level:`warn`});return(0,e.formatNodeType)(e.NodeType.File,i,{content:`-`})},a=e=>{let{INTLAYER_FILE_PATH:t,INTLAYER_BASE_DIR:n}=globalThis;return i(e,(0,r.dirname)(t),n)};exports.file=a,exports.fileContent=i;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../chunk-Bmb41Sf3.cjs`);let e=require(`@intlayer/types/nodeType`),t=require(`@intlayer/config/logger`),n=require(`node:fs`),r=require(`node:path`);const i=(i,a,o)=>{let s=i.startsWith(`./`)||i.startsWith(`../`),c=(0,t.getAppLogger)(),l;if((0,r.isAbsolute)(i)?(c(`Using absolute path for file is not recommended. Use relative paths instead. Path: ${i}, imported from: ${a}`,{level:`warn`}),l=i):l=s?(0,r.resolve)(a,i):(0,r.resolve)(o,i),(0,n.existsSync)(l)&&(0,n.statSync)(l).isFile())try{let t=(0,n.readFileSync)(l,`utf8`);return(0,e.formatNodeType)(e.NodeType.File,i,{content:t,fixedPath:(0,r.relative)(o,l)})}catch{c(`Unable to read path: ${(0,t.colorizePath)((0,r.relative)(o,l))}`,{level:`warn`})}else c(`File not found: ${(0,t.colorizePath)((0,r.relative)(o,l))}`,{level:`warn`});return(0,e.formatNodeType)(e.NodeType.File,i,{content:`-`})},a=e=>{let{INTLAYER_FILE_PATH:t,INTLAYER_BASE_DIR:n}=globalThis;return i(e,(0,r.dirname)(t),n)};exports.file=a,exports.fileContent=i;
2
2
  //# sourceMappingURL=file.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"file.cjs","names":["NodeType"],"sources":["../../../../src/transpiler/file/file.ts"],"sourcesContent":["import { existsSync, readFileSync, statSync } from 'node:fs';\nimport { dirname, isAbsolute, relative, resolve } from 'node:path';\nimport { colorizePath, getAppLogger } from '@intlayer/config/logger';\nimport type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, NodeType } from '@intlayer/types/nodeType';\n\nexport type FileContentConstructor<T extends Record<string, any> = {}> =\n TypedNodeModel<NodeType.File, string, T>;\n\nexport type FileContent = FileContentConstructor<{\n content: string;\n fixedPath?: string;\n}>;\n\nexport const fileContent = (\n path: string,\n callerDir: string,\n baseDir: string\n): FileContent => {\n const isRelativePath = path.startsWith('./') || path.startsWith('../');\n const appLogger = getAppLogger();\n\n let filePath: string;\n if (isAbsolute(path)) {\n appLogger(\n `Using absolute path for file is not recommended. Use relative paths instead. Path: ${path}, imported from: ${callerDir}`,\n { level: 'warn' }\n );\n filePath = path;\n } else if (isRelativePath) {\n filePath = resolve(callerDir, path);\n } else {\n filePath = resolve(baseDir, path);\n }\n\n if (existsSync(filePath) && statSync(filePath).isFile()) {\n try {\n const content = readFileSync(filePath, 'utf8');\n\n return formatNodeType(NodeType.File, path, {\n content,\n fixedPath: relative(baseDir, filePath),\n });\n } catch {\n appLogger(\n `Unable to read path: ${colorizePath(relative(baseDir, filePath))}`,\n { level: 'warn' }\n );\n }\n } else {\n appLogger(`File not found: ${colorizePath(relative(baseDir, filePath))}`, {\n level: 'warn',\n });\n }\n\n return formatNodeType(NodeType.File, path, {\n content: `-`,\n });\n};\n\ntype GlobalIntlayerFilePath = {\n INTLAYER_FILE_PATH: string;\n INTLAYER_BASE_DIR: string;\n};\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow identify the usage of an external resource.\n *\n * Usage:\n *\n * ```ts\n * file('/path/to/file.md') // absolute path\n *\n * // or\n *\n * file('path/to/file.md') // relative path\n * ```\n */\nexport const file = (path: string): FileContent => {\n const { INTLAYER_FILE_PATH, INTLAYER_BASE_DIR } =\n globalThis as unknown as GlobalIntlayerFilePath;\n\n const callerDir = dirname(INTLAYER_FILE_PATH);\n const baseDir = INTLAYER_BASE_DIR;\n\n return fileContent(path, callerDir, baseDir);\n};\n"],"mappings":"8OAcA,MAAa,GACX,EACA,EACA,IACgB,CAChB,IAAM,EAAiB,EAAK,WAAW,KAAK,EAAI,EAAK,WAAW,MAAM,CAChE,GAAA,EAAA,EAAA,eAA0B,CAE5B,EAaJ,IAZA,EAAA,EAAA,YAAe,EAAK,EAClB,EACE,sFAAsF,EAAK,mBAAmB,IAC9G,CAAE,MAAO,OAAQ,CAClB,CACD,EAAW,GAIX,EAHS,GACT,EAAA,EAAA,SAAmB,EAAW,EAAK,EAEnC,EAAA,EAAA,SAAmB,EAAS,EAAK,EAGnC,EAAA,EAAA,YAAe,EAAS,GAAA,EAAA,EAAA,UAAa,EAAS,CAAC,QAAQ,CACrD,GAAI,CACF,IAAM,GAAA,EAAA,EAAA,cAAuB,EAAU,OAAO,CAE9C,OAAA,EAAA,EAAA,gBAAsBA,EAAAA,SAAS,KAAM,EAAM,CACzC,UACA,WAAA,EAAA,EAAA,UAAoB,EAAS,EAAS,CACvC,CAAC,MACI,CACN,EACE,yBAAA,EAAA,EAAA,eAAA,EAAA,EAAA,UAA8C,EAAS,EAAS,CAAC,GACjE,CAAE,MAAO,OAAQ,CAClB,MAGH,EAAU,oBAAA,EAAA,EAAA,eAAA,EAAA,EAAA,UAAyC,EAAS,EAAS,CAAC,GAAI,CACxE,MAAO,OACR,CAAC,CAGJ,OAAA,EAAA,EAAA,gBAAsBA,EAAAA,SAAS,KAAM,EAAM,CACzC,QAAS,IACV,CAAC,EAuBS,EAAQ,GAA8B,CACjD,GAAM,CAAE,qBAAoB,qBAC1B,WAKF,OAAO,EAAY,GAAA,EAAA,EAAA,SAHO,EAAmB,CAC7B,EAE4B"}
1
+ {"version":3,"file":"file.cjs","names":["NodeType"],"sources":["../../../../src/transpiler/file/file.ts"],"sourcesContent":["import { existsSync, readFileSync, statSync } from 'node:fs';\nimport { dirname, isAbsolute, relative, resolve } from 'node:path';\nimport { colorizePath, getAppLogger } from '@intlayer/config/logger';\nimport type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, NodeType } from '@intlayer/types/nodeType';\n\nexport type FileContentConstructor<T extends Record<string, any> = {}> =\n TypedNodeModel<NodeType.File, string, T>;\n\nexport type FileContent = FileContentConstructor<{\n content: string;\n fixedPath?: string;\n}>;\n\nexport const fileContent = (\n path: string,\n callerDir: string,\n baseDir: string\n): FileContent => {\n const isRelativePath = path.startsWith('./') || path.startsWith('../');\n const appLogger = getAppLogger();\n\n let filePath: string;\n if (isAbsolute(path)) {\n appLogger(\n `Using absolute path for file is not recommended. Use relative paths instead. Path: ${path}, imported from: ${callerDir}`,\n { level: 'warn' }\n );\n filePath = path;\n } else if (isRelativePath) {\n filePath = resolve(callerDir, path);\n } else {\n filePath = resolve(baseDir, path);\n }\n\n if (existsSync(filePath) && statSync(filePath).isFile()) {\n try {\n const content = readFileSync(filePath, 'utf8');\n\n return formatNodeType(NodeType.File, path, {\n content,\n fixedPath: relative(baseDir, filePath),\n });\n } catch {\n appLogger(\n `Unable to read path: ${colorizePath(relative(baseDir, filePath))}`,\n { level: 'warn' }\n );\n }\n } else {\n appLogger(`File not found: ${colorizePath(relative(baseDir, filePath))}`, {\n level: 'warn',\n });\n }\n\n return formatNodeType(NodeType.File, path, {\n content: `-`,\n });\n};\n\ntype GlobalIntlayerFilePath = {\n INTLAYER_FILE_PATH: string;\n INTLAYER_BASE_DIR: string;\n};\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow identify the usage of an external resource.\n *\n * Usage:\n *\n * ```ts\n * file('/path/to/file.md') // absolute path\n *\n * // or\n *\n * file('path/to/file.md') // relative path\n * ```\n */\nexport const file = (path: string): FileContent => {\n const { INTLAYER_FILE_PATH, INTLAYER_BASE_DIR } =\n globalThis as unknown as GlobalIntlayerFilePath;\n\n const callerDir = dirname(INTLAYER_FILE_PATH);\n const baseDir = INTLAYER_BASE_DIR;\n\n return fileContent(path, callerDir, baseDir);\n};\n"],"mappings":"kOAcA,MAAa,GACX,EACA,EACA,IACgB,CAChB,IAAM,EAAiB,EAAK,WAAW,KAAK,EAAI,EAAK,WAAW,MAAM,CAChE,GAAA,EAAA,EAAA,eAA0B,CAE5B,EAaJ,IAZA,EAAA,EAAA,YAAe,EAAK,EAClB,EACE,sFAAsF,EAAK,mBAAmB,IAC9G,CAAE,MAAO,OAAQ,CAClB,CACD,EAAW,GAIX,EAHS,GACT,EAAA,EAAA,SAAmB,EAAW,EAAK,EAEnC,EAAA,EAAA,SAAmB,EAAS,EAAK,EAGnC,EAAA,EAAA,YAAe,EAAS,GAAA,EAAA,EAAA,UAAa,EAAS,CAAC,QAAQ,CACrD,GAAI,CACF,IAAM,GAAA,EAAA,EAAA,cAAuB,EAAU,OAAO,CAE9C,OAAA,EAAA,EAAA,gBAAsBA,EAAAA,SAAS,KAAM,EAAM,CACzC,UACA,WAAA,EAAA,EAAA,UAAoB,EAAS,EAAS,CACvC,CAAC,MACI,CACN,EACE,yBAAA,EAAA,EAAA,eAAA,EAAA,EAAA,UAA8C,EAAS,EAAS,CAAC,GACjE,CAAE,MAAO,OAAQ,CAClB,MAGH,EAAU,oBAAA,EAAA,EAAA,eAAA,EAAA,EAAA,UAAyC,EAAS,EAAS,CAAC,GAAI,CACxE,MAAO,OACR,CAAC,CAGJ,OAAA,EAAA,EAAA,gBAAsBA,EAAAA,SAAS,KAAM,EAAM,CACzC,QAAS,IACV,CAAC,EAuBS,EAAQ,GAA8B,CACjD,GAAM,CAAE,qBAAoB,qBAC1B,WAKF,OAAO,EAAY,GAAA,EAAA,EAAA,SAHO,EAAmB,CAC7B,EAE4B"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);let e=require(`@intlayer/types/nodeType`);const t=t=>(0,e.formatNodeType)(e.NodeType.Gender,t);exports.gender=t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../chunk-Bmb41Sf3.cjs`);let e=require(`@intlayer/types/nodeType`);const t=t=>(0,e.formatNodeType)(e.NodeType.Gender,t);exports.gender=t;
2
2
  //# sourceMappingURL=gender.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"gender.cjs","names":["NodeType"],"sources":["../../../../src/transpiler/gender/gender.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, NodeType } from '@intlayer/types/nodeType';\n\nexport type Gender = 'male' | 'female' | 'fallback';\n\nexport type GenderContentStates<Content> = Record<`${Gender}`, Content> & {\n fallback?: Content;\n};\n\nexport type GenderContent<Content = unknown> = TypedNodeModel<\n NodeType.Gender,\n GenderContentStates<Content>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a gender.\n *\n * Usage:\n *\n * ```ts\n * gender({\n * 'true': 'The gender is validated',\n * 'false': 'The gender is not validated',\n * });\n * ```\n *\n * The last key provided will be used as the fallback value.\n *\n */\nconst gender = <Content>(content?: GenderContentStates<Content>) =>\n formatNodeType(NodeType.Gender, content);\n\nexport { gender };\n"],"mappings":"6JA+BA,MAAM,EAAmB,IAAA,EAAA,EAAA,gBACRA,EAAAA,SAAS,OAAQ,EAAQ"}
1
+ {"version":3,"file":"gender.cjs","names":["NodeType"],"sources":["../../../../src/transpiler/gender/gender.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, NodeType } from '@intlayer/types/nodeType';\n\nexport type Gender = 'male' | 'female' | 'fallback';\n\nexport type GenderContentStates<Content> = Record<`${Gender}`, Content> & {\n fallback?: Content;\n};\n\nexport type GenderContent<Content = unknown> = TypedNodeModel<\n NodeType.Gender,\n GenderContentStates<Content>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a gender.\n *\n * Usage:\n *\n * ```ts\n * gender({\n * 'true': 'The gender is validated',\n * 'false': 'The gender is not validated',\n * });\n * ```\n *\n * The last key provided will be used as the fallback value.\n *\n */\nconst gender = <Content>(content?: GenderContentStates<Content>) =>\n formatNodeType(NodeType.Gender, content);\n\nexport { gender };\n"],"mappings":"iJA+BA,MAAM,EAAmB,IAAA,EAAA,EAAA,gBACRA,EAAAA,SAAS,OAAQ,EAAQ"}
@@ -1,2 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./htmlTags.cjs`),t=e=>{let t={};return!e||!e.trim()||[...e.matchAll(/([a-zA-Z0-9-:_@]+)(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+))?/g)].forEach(e=>{let n=e[1];t[n]=`string`}),t},n=n=>{if(typeof n!=`string`)throw Error(`content must be a string`);let r=[...n.matchAll(/<(\/)?([a-zA-Z0-9.-]+)\s*([\s\S]*?)(\/?)>/g)],i={};return r.forEach(n=>{let r=!!n[1],a=n[2],o=n[3],s=!!n[4];if(e.HTML_TAGS.includes(a.toLowerCase())){i[a]=!0;return}if(i[a]||(i[a]={}),i[a]===!0||r)return;let c=t(o),l=i[a];Object.assign(l,c),s||(l.children=`string`)}),i};exports.getHTMLCustomComponents=n;
2
- //# sourceMappingURL=getHTMLCustomComponents.cjs.map
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../html-CZ1N-VL0.cjs`);exports.getHTMLCustomComponents=e.n;
@@ -1,2 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`./getHTMLCustomComponents.cjs`),t=require(`./validateHTML.cjs`);let n=require(`@intlayer/types/nodeType`);const r=(r,i)=>(0,n.formatNodeType)(n.NodeType.HTML,r,{tags:(()=>{if(i)return i;if(typeof r==`string`){let{issues:n}=t.validateHTML(r);for(let e of n)e.type===`error`?console.error(`[intlayer/html] ${e.message}`):console.warn(`[intlayer/html] ${e.message}`);return e.getHTMLCustomComponents(r)}let n;if(typeof r==`function`?n=r():typeof r.then==`function`&&(n=async()=>e.getHTMLCustomComponents(await r)),typeof n==`string`)return e.getHTMLCustomComponents(n);try{return e.getHTMLCustomComponents(JSON.stringify(r))}catch{return[]}})()});exports.html=r;
2
- //# sourceMappingURL=html.cjs.map
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../html-CZ1N-VL0.cjs`);exports.html=e.t;
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./validateHTML.cjs`),t=require(`./html.cjs`),n=require(`./htmlTags.cjs`);exports.HTML_TAGS=n.HTML_TAGS,exports.VOID_ELEMENTS=e.VOID_ELEMENTS,exports.html=t.html,exports.validateHTML=e.validateHTML;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../html-CZ1N-VL0.cjs`),t=require(`./validateHTML.cjs`),n=require(`./htmlTags.cjs`);exports.HTML_TAGS=n.HTML_TAGS,exports.VOID_ELEMENTS=t.VOID_ELEMENTS,exports.html=e.t,exports.validateHTML=t.validateHTML;
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./condition/condition.cjs`),t=require(`./enumeration/enumeration.cjs`),n=require(`./gender/gender.cjs`),r=require(`./html/validateHTML.cjs`),i=require(`./html/html.cjs`),a=require(`./html/htmlTags.cjs`),o=require(`./insertion/getInsertionValues.cjs`),s=require(`./insertion/insertion.cjs`),c=require(`./markdown/getMarkdownMetadata.cjs`),l=require(`./markdown/validateMarkdown.cjs`),u=require(`./markdown/markdown.cjs`),d=require(`./nesting/nesting.cjs`),f=require(`./translation/translation.cjs`);exports.HTML_TAGS=a.HTML_TAGS,exports.VOID_ELEMENTS=r.VOID_ELEMENTS,exports.cond=e.cond,exports.enu=t.enu,exports.gender=n.gender,exports.getInsertionValues=o.getInsertionValues,exports.getMarkdownMetadata=c.getMarkdownMetadata,exports.html=i.html,exports.insert=s.insert,exports.md=u.md,exports.nest=d.nest,exports.t=f.t,exports.validateHTML=r.validateHTML,exports.validateMarkdown=l.validateMarkdown;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./condition/condition.cjs`),t=require(`./enumeration/enumeration.cjs`),n=require(`./gender/gender.cjs`),r=require(`../html-CZ1N-VL0.cjs`),i=require(`./html/validateHTML.cjs`),a=require(`./html/htmlTags.cjs`),o=require(`./insertion/getInsertionValues.cjs`),s=require(`./insertion/insertion.cjs`),c=require(`./markdown/getMarkdownMetadata.cjs`),l=require(`./markdown/validateMarkdown.cjs`),u=require(`./markdown/markdown.cjs`),d=require(`./nesting/nesting.cjs`),f=require(`./translation/translation.cjs`);exports.HTML_TAGS=a.HTML_TAGS,exports.VOID_ELEMENTS=i.VOID_ELEMENTS,exports.cond=e.cond,exports.enu=t.enu,exports.gender=n.gender,exports.getInsertionValues=o.getInsertionValues,exports.getMarkdownMetadata=c.getMarkdownMetadata,exports.html=r.t,exports.insert=s.insert,exports.md=u.md,exports.nest=d.nest,exports.t=f.t,exports.validateHTML=i.validateHTML,exports.validateMarkdown=l.validateMarkdown;
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`./getInsertionValues.cjs`);let t=require(`@intlayer/types/nodeType`);const n=n=>(0,t.formatNodeType)(t.NodeType.Insertion,n,{fields:(()=>{if(typeof n==`string`)return e.getInsertionValues(n);let t;if(typeof n==`function`?t=n():typeof n.then==`function`&&(t=async()=>e.getInsertionValues(await n)),typeof t==`string`)return e.getInsertionValues(t);try{return e.getInsertionValues(JSON.stringify(n))}catch{return[]}})()});exports.insert=n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../chunk-Bmb41Sf3.cjs`);const e=require(`./getInsertionValues.cjs`);let t=require(`@intlayer/types/nodeType`);const n=n=>(0,t.formatNodeType)(t.NodeType.Insertion,n,{fields:(()=>{if(typeof n==`string`)return e.getInsertionValues(n);let t;if(typeof n==`function`?t=n():typeof n.then==`function`&&(t=async()=>e.getInsertionValues(await n)),typeof t==`string`)return e.getInsertionValues(t);try{return e.getInsertionValues(JSON.stringify(n))}catch{return[]}})()});exports.insert=n;
2
2
  //# sourceMappingURL=insertion.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"insertion.cjs","names":["getInsertionValues","NodeType"],"sources":["../../../../src/transpiler/insertion/insertion.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, NodeType } from '@intlayer/types/nodeType';\nimport { getInsertionValues } from './getInsertionValues';\n\nexport type InsertionContentConstructor<\n Content = unknown,\n T extends Record<string, any> = {},\n> = TypedNodeModel<NodeType.Insertion, Content, T>;\n\nexport type InsertionContent<Content = unknown> = InsertionContentConstructor<\n Content,\n {\n fields: string[];\n }\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to identify insertions inside a content.\n *\n * Usage:\n *\n * ```ts\n * insertion('Hi, my name is {{name}} and I am {{age}} years old.')\n * ```\n *\n */\nconst insertion = <Content = unknown>(\n content: Content\n): InsertionContent<Content> => {\n const getInsertions = () => {\n if (typeof content === 'string') {\n return getInsertionValues(content);\n }\n\n let stringContent: any;\n\n if (typeof content === 'function') {\n stringContent = content();\n } else if (typeof (content as Promise<string>).then === 'function') {\n stringContent = async () =>\n getInsertionValues(await (content as Promise<string>));\n }\n\n if (typeof stringContent === 'string') {\n return getInsertionValues(stringContent);\n }\n\n try {\n return getInsertionValues(JSON.stringify(content));\n } catch (_e) {\n return [];\n }\n };\n\n return formatNodeType(NodeType.Insertion, content, {\n fields: getInsertions(),\n });\n};\n\nexport { insertion as insert };\n"],"mappings":"yMA4BA,MAAM,EACJ,IA2BA,EAAA,EAAA,gBAAsBC,EAAAA,SAAS,UAAW,EAAS,CACjD,YA1B0B,CAC1B,GAAI,OAAO,GAAY,SACrB,OAAOD,EAAAA,mBAAmB,EAAQ,CAGpC,IAAI,EASJ,GAPI,OAAO,GAAY,WACrB,EAAgB,GAAS,CAChB,OAAQ,EAA4B,MAAS,aACtD,EAAgB,SACdA,EAAAA,mBAAmB,MAAO,EAA4B,EAGtD,OAAO,GAAkB,SAC3B,OAAOA,EAAAA,mBAAmB,EAAc,CAG1C,GAAI,CACF,OAAOA,EAAAA,mBAAmB,KAAK,UAAU,EAAQ,CAAC,MACvC,CACX,MAAO,EAAE,KAKY,CACxB,CAAC"}
1
+ {"version":3,"file":"insertion.cjs","names":["getInsertionValues","NodeType"],"sources":["../../../../src/transpiler/insertion/insertion.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, NodeType } from '@intlayer/types/nodeType';\nimport { getInsertionValues } from './getInsertionValues';\n\nexport type InsertionContentConstructor<\n Content = unknown,\n T extends Record<string, any> = {},\n> = TypedNodeModel<NodeType.Insertion, Content, T>;\n\nexport type InsertionContent<Content = unknown> = InsertionContentConstructor<\n Content,\n {\n fields: string[];\n }\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to identify insertions inside a content.\n *\n * Usage:\n *\n * ```ts\n * insertion('Hi, my name is {{name}} and I am {{age}} years old.')\n * ```\n *\n */\nconst insertion = <Content = unknown>(\n content: Content\n): InsertionContent<Content> => {\n const getInsertions = () => {\n if (typeof content === 'string') {\n return getInsertionValues(content);\n }\n\n let stringContent: any;\n\n if (typeof content === 'function') {\n stringContent = content();\n } else if (typeof (content as Promise<string>).then === 'function') {\n stringContent = async () =>\n getInsertionValues(await (content as Promise<string>));\n }\n\n if (typeof stringContent === 'string') {\n return getInsertionValues(stringContent);\n }\n\n try {\n return getInsertionValues(JSON.stringify(content));\n } catch (_e) {\n return [];\n }\n };\n\n return formatNodeType(NodeType.Insertion, content, {\n fields: getInsertions(),\n });\n};\n\nexport { insertion as insert };\n"],"mappings":"6LA4BA,MAAM,EACJ,IA2BA,EAAA,EAAA,gBAAsBC,EAAAA,SAAS,UAAW,EAAS,CACjD,YA1B0B,CAC1B,GAAI,OAAO,GAAY,SACrB,OAAOD,EAAAA,mBAAmB,EAAQ,CAGpC,IAAI,EASJ,GAPI,OAAO,GAAY,WACrB,EAAgB,GAAS,CAChB,OAAQ,EAA4B,MAAS,aACtD,EAAgB,SACdA,EAAAA,mBAAmB,MAAO,EAA4B,EAGtD,OAAO,GAAkB,SAC3B,OAAOA,EAAAA,mBAAmB,EAAc,CAG1C,GAAI,CACF,OAAOA,EAAAA,mBAAmB,KAAK,UAAU,EAAQ,CAAC,MACvC,CACX,MAAO,EAAE,KAKY,CACxB,CAAC"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../interpreter/getContent/getContent.cjs`),t=require(`../html/getHTMLCustomComponents.cjs`),n=require(`./getMarkdownMetadata.cjs`),r=require(`./validateMarkdown.cjs`);let i=require(`@intlayer/types/nodeType`);const a=async e=>{if(typeof e==`string`||typeof e==`object`)return e;if(typeof e==`function`)return e();if(typeof e.then==`function`)return await e},o=(o,s)=>(0,i.formatNodeType)(i.NodeType.Markdown,o,{metadata:async()=>{let t=e.getContent(await a(o),{dictionaryKey:``,keyPath:[]});if(typeof t==`string`){if(process.env.NODE_ENV!==`production`){let{issues:e}=r.validateMarkdown(t);for(let t of e)t.type===`error`?console.error(`[intlayer/markdown] ${t.message}`):console.warn(`[intlayer/markdown] ${t.message}`)}return n.getMarkdownMetadata(t)}},tags:(()=>{if(s)return s;if(typeof o==`string`)return t.getHTMLCustomComponents(o);let e;if(typeof o==`function`?e=o():typeof o.then==`function`&&(e=async()=>t.getHTMLCustomComponents(await o)),typeof e==`string`)return t.getHTMLCustomComponents(e);try{return t.getHTMLCustomComponents(JSON.stringify(o))}catch{return[]}})()});exports.md=o;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../chunk-Bmb41Sf3.cjs`);const e=require(`../../getContent-DrqM8pqO.cjs`),t=require(`../../html-CZ1N-VL0.cjs`),n=require(`./getMarkdownMetadata.cjs`),r=require(`./validateMarkdown.cjs`);let i=require(`@intlayer/types/nodeType`);const a=async e=>{if(typeof e==`string`||typeof e==`object`)return e;if(typeof e==`function`)return e();if(typeof e.then==`function`)return await e},o=(o,s)=>(0,i.formatNodeType)(i.NodeType.Markdown,o,{metadata:async()=>{let t=e.n(await a(o),{dictionaryKey:``,keyPath:[]});if(typeof t==`string`){if(process.env.NODE_ENV!==`production`){let{issues:e}=r.validateMarkdown(t);for(let t of e)t.type===`error`?console.error(`[intlayer/markdown] ${t.message}`):console.warn(`[intlayer/markdown] ${t.message}`)}return n.getMarkdownMetadata(t)}},tags:(()=>{if(s)return s;if(typeof o==`string`)return t.n(o);let e;if(typeof o==`function`?e=o():typeof o.then==`function`&&(e=async()=>t.n(await o)),typeof e==`string`)return t.n(e);try{return t.n(JSON.stringify(o))}catch{return[]}})()});exports.md=o;
2
2
  //# sourceMappingURL=markdown.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"markdown.cjs","names":["getContent","validateMarkdown","getMarkdownMetadata","getHTMLCustomComponents","NodeType"],"sources":["../../../../src/transpiler/markdown/markdown.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, NodeType } from '@intlayer/types/nodeType';\nimport { getContent } from '../../interpreter/getContent/getContent';\nimport { getHTMLCustomComponents } from '../html/getHTMLCustomComponents';\nimport { getMarkdownMetadata } from './getMarkdownMetadata';\nimport { validateMarkdown } from './validateMarkdown';\n\ntype PropsType = 'number' | 'string' | 'node';\n\ntype ComponentName = string;\n\nexport type MarkdownContentConstructor<\n T extends Record<string, any> = {},\n Content = unknown,\n> = TypedNodeModel<NodeType.Markdown, Content, T>;\n\nexport type MarkdownContent<\n Content = unknown,\n Components extends Record<ComponentName, PropsType> = Record<\n ComponentName,\n PropsType\n >,\n> = MarkdownContentConstructor<\n {\n metadata?: Record<string, any>;\n tags?: string[] | Components;\n },\n Content\n>;\n\nconst awaitContent = async (content: any) => {\n if (typeof content === 'string' || typeof content === 'object') {\n return content as any;\n }\n\n if (typeof content === 'function') {\n return content();\n }\n if (typeof content.then === 'function') {\n return await content;\n }\n};\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a quantity.\n *\n * Usage:\n *\n * ```ts\n * markdown('## Hello world!');\n * ```\n *\n */\nconst markdown = <\n Components extends Record<string, any> = Record<string, any>,\n Content = unknown,\n>(\n content: Content,\n components?: Components\n): MarkdownContent<Content, Components> => {\n const metadata = async () => {\n const awaitedContent = await awaitContent(content);\n\n const flatContent = getContent(awaitedContent, {\n dictionaryKey: '',\n keyPath: [],\n });\n\n if (typeof flatContent === 'string') {\n if (process.env.NODE_ENV !== 'production') {\n const { issues } = validateMarkdown(flatContent);\n for (const issue of issues) {\n if (issue.type === 'error') {\n console.error(`[intlayer/markdown] ${issue.message}`);\n } else {\n console.warn(`[intlayer/markdown] ${issue.message}`);\n }\n }\n }\n\n return getMarkdownMetadata(flatContent);\n }\n };\n\n const getComponents = () => {\n if (components) {\n return components;\n }\n\n if (typeof content === 'string') {\n return getHTMLCustomComponents(content);\n }\n\n let stringContent: any;\n\n if (typeof content === 'function') {\n stringContent = content();\n } else if (typeof (content as Promise<string>).then === 'function') {\n stringContent = async () =>\n getHTMLCustomComponents((await (content as Promise<string>)) as string);\n }\n\n if (typeof stringContent === 'string') {\n return getHTMLCustomComponents(stringContent);\n }\n\n try {\n return getHTMLCustomComponents(JSON.stringify(content));\n } catch (_e) {\n return [];\n }\n };\n\n return formatNodeType(NodeType.Markdown, content, {\n metadata,\n tags: getComponents(),\n });\n};\n\nexport { markdown as md };\n"],"mappings":"wVA8BA,MAAM,EAAe,KAAO,IAAiB,CAC3C,GAAI,OAAO,GAAY,UAAY,OAAO,GAAY,SACpD,OAAO,EAGT,GAAI,OAAO,GAAY,WACrB,OAAO,GAAS,CAElB,GAAI,OAAO,EAAQ,MAAS,WAC1B,OAAO,MAAM,GAgBX,GAIJ,EACA,KAuDA,EAAA,EAAA,gBAAsBI,EAAAA,SAAS,SAAU,EAAS,CAChD,SAtDe,SAAY,CAG3B,IAAM,EAAcJ,EAAAA,WAFG,MAAM,EAAa,EAAQ,CAEH,CAC7C,cAAe,GACf,QAAS,EAAE,CACZ,CAAC,CAEF,GAAI,OAAO,GAAgB,SAAU,CACnC,GAAI,QAAQ,IAAI,WAAa,aAAc,CACzC,GAAM,CAAE,UAAWC,EAAAA,iBAAiB,EAAY,CAChD,IAAK,IAAM,KAAS,EACd,EAAM,OAAS,QACjB,QAAQ,MAAM,uBAAuB,EAAM,UAAU,CAErD,QAAQ,KAAK,uBAAuB,EAAM,UAAU,CAK1D,OAAOC,EAAAA,oBAAoB,EAAY,GAmCzC,UA/B0B,CAC1B,GAAI,EACF,OAAO,EAGT,GAAI,OAAO,GAAY,SACrB,OAAOC,EAAAA,wBAAwB,EAAQ,CAGzC,IAAI,EASJ,GAPI,OAAO,GAAY,WACrB,EAAgB,GAAS,CAChB,OAAQ,EAA4B,MAAS,aACtD,EAAgB,SACdA,EAAAA,wBAAyB,MAAO,EAAuC,EAGvE,OAAO,GAAkB,SAC3B,OAAOA,EAAAA,wBAAwB,EAAc,CAG/C,GAAI,CACF,OAAOA,EAAAA,wBAAwB,KAAK,UAAU,EAAQ,CAAC,MAC5C,CACX,MAAO,EAAE,KAMU,CACtB,CAAC"}
1
+ {"version":3,"file":"markdown.cjs","names":["getContent","validateMarkdown","getMarkdownMetadata","getHTMLCustomComponents","NodeType"],"sources":["../../../../src/transpiler/markdown/markdown.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, NodeType } from '@intlayer/types/nodeType';\nimport { getContent } from '../../interpreter/getContent/getContent';\nimport { getHTMLCustomComponents } from '../html/getHTMLCustomComponents';\nimport { getMarkdownMetadata } from './getMarkdownMetadata';\nimport { validateMarkdown } from './validateMarkdown';\n\ntype PropsType = 'number' | 'string' | 'node';\n\ntype ComponentName = string;\n\nexport type MarkdownContentConstructor<\n T extends Record<string, any> = {},\n Content = unknown,\n> = TypedNodeModel<NodeType.Markdown, Content, T>;\n\nexport type MarkdownContent<\n Content = unknown,\n Components extends Record<ComponentName, PropsType> = Record<\n ComponentName,\n PropsType\n >,\n> = MarkdownContentConstructor<\n {\n metadata?: Record<string, any>;\n tags?: string[] | Components;\n },\n Content\n>;\n\nconst awaitContent = async (content: any) => {\n if (typeof content === 'string' || typeof content === 'object') {\n return content as any;\n }\n\n if (typeof content === 'function') {\n return content();\n }\n if (typeof content.then === 'function') {\n return await content;\n }\n};\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a quantity.\n *\n * Usage:\n *\n * ```ts\n * markdown('## Hello world!');\n * ```\n *\n */\nconst markdown = <\n Components extends Record<string, any> = Record<string, any>,\n Content = unknown,\n>(\n content: Content,\n components?: Components\n): MarkdownContent<Content, Components> => {\n const metadata = async () => {\n const awaitedContent = await awaitContent(content);\n\n const flatContent = getContent(awaitedContent, {\n dictionaryKey: '',\n keyPath: [],\n });\n\n if (typeof flatContent === 'string') {\n if (process.env.NODE_ENV !== 'production') {\n const { issues } = validateMarkdown(flatContent);\n for (const issue of issues) {\n if (issue.type === 'error') {\n console.error(`[intlayer/markdown] ${issue.message}`);\n } else {\n console.warn(`[intlayer/markdown] ${issue.message}`);\n }\n }\n }\n\n return getMarkdownMetadata(flatContent);\n }\n };\n\n const getComponents = () => {\n if (components) {\n return components;\n }\n\n if (typeof content === 'string') {\n return getHTMLCustomComponents(content);\n }\n\n let stringContent: any;\n\n if (typeof content === 'function') {\n stringContent = content();\n } else if (typeof (content as Promise<string>).then === 'function') {\n stringContent = async () =>\n getHTMLCustomComponents((await (content as Promise<string>)) as string);\n }\n\n if (typeof stringContent === 'string') {\n return getHTMLCustomComponents(stringContent);\n }\n\n try {\n return getHTMLCustomComponents(JSON.stringify(content));\n } catch (_e) {\n return [];\n }\n };\n\n return formatNodeType(NodeType.Markdown, content, {\n metadata,\n tags: getComponents(),\n });\n};\n\nexport { markdown as md };\n"],"mappings":"kTA8BA,MAAM,EAAe,KAAO,IAAiB,CAC3C,GAAI,OAAO,GAAY,UAAY,OAAO,GAAY,SACpD,OAAO,EAGT,GAAI,OAAO,GAAY,WACrB,OAAO,GAAS,CAElB,GAAI,OAAO,EAAQ,MAAS,WAC1B,OAAO,MAAM,GAgBX,GAIJ,EACA,KAuDA,EAAA,EAAA,gBAAsBI,EAAAA,SAAS,SAAU,EAAS,CAChD,SAtDe,SAAY,CAG3B,IAAM,EAAcJ,EAAAA,EAFG,MAAM,EAAa,EAAQ,CAEH,CAC7C,cAAe,GACf,QAAS,EAAE,CACZ,CAAC,CAEF,GAAI,OAAO,GAAgB,SAAU,CACnC,GAAI,QAAQ,IAAI,WAAa,aAAc,CACzC,GAAM,CAAE,UAAWC,EAAAA,iBAAiB,EAAY,CAChD,IAAK,IAAM,KAAS,EACd,EAAM,OAAS,QACjB,QAAQ,MAAM,uBAAuB,EAAM,UAAU,CAErD,QAAQ,KAAK,uBAAuB,EAAM,UAAU,CAK1D,OAAOC,EAAAA,oBAAoB,EAAY,GAmCzC,UA/B0B,CAC1B,GAAI,EACF,OAAO,EAGT,GAAI,OAAO,GAAY,SACrB,OAAOC,EAAAA,EAAwB,EAAQ,CAGzC,IAAI,EASJ,GAPI,OAAO,GAAY,WACrB,EAAgB,GAAS,CAChB,OAAQ,EAA4B,MAAS,aACtD,EAAgB,SACdA,EAAAA,EAAyB,MAAO,EAAuC,EAGvE,OAAO,GAAkB,SAC3B,OAAOA,EAAAA,EAAwB,EAAc,CAG/C,GAAI,CACF,OAAOA,EAAAA,EAAwB,KAAK,UAAU,EAAQ,CAAC,MAC5C,CACX,MAAO,EAAE,KAMU,CACtB,CAAC"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);let e=require(`@intlayer/types/nodeType`);const t=(t,n)=>(0,e.formatNodeType)(e.NodeType.Nested,{dictionaryKey:t,path:n});exports.nest=t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../chunk-Bmb41Sf3.cjs`);let e=require(`@intlayer/types/nodeType`);const t=(t,n)=>(0,e.formatNodeType)(e.NodeType.Nested,{dictionaryKey:t,path:n});exports.nest=t;
2
2
  //# sourceMappingURL=nesting.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"nesting.cjs","names":["NodeType"],"sources":["../../../../src/transpiler/nesting/nesting.ts"],"sourcesContent":["import type { DictionaryRegistryContent } from '@intlayer/types/module_augmentation';\nimport type { DictionaryKeys } from '@intlayer/types/module_augmentation';\nimport type { TypedNodeModel } from '@intlayer/types/nodeType';;\nimport { formatNodeType, NodeType } from '@intlayer/types/nodeType';\nimport type { DeepTransformContent } from '../../interpreter';\n\n/**\n * Recursively builds dot-notation strings for all valid paths in T.\n * Example:\n * type X = { a: { b: { c: string }}, d: number };\n * DotPath<X> = \"a\" | \"a.b\" | \"a.b.c\" | \"d\"\n */\nexport type DotPath<T> = T extends object\n ? {\n [K in keyof T & (string | number)]: T[K] extends object\n ? // Either just K, or K + '.' + deeper path\n `${K}` | `${K}.${DotPath<T[K]>}`\n : `${K}`;\n }[keyof T & (string | number)]\n : never;\n\ntype DeepReplace<T, From, To> = T extends From\n ? To\n : T extends object\n ? { [K in keyof T]: DeepReplace<T[K], From, To> }\n : T;\n\n/** Build all valid dot-notation strings for a dictionary entry. */\nexport type ValidDotPathsFor<K extends DictionaryKeys> = DotPath<\n DeepReplace<\n DeepTransformContent<DictionaryRegistryContent<K>>,\n // Replace ReactElement type with string\n {\n type: any;\n props: any;\n key: any;\n },\n string\n >\n>;\n\nexport type NestedContentState<K extends DictionaryKeys> = {\n dictionaryKey: K;\n\n /**\n * Path must match existing keys in DictionaryRegistryContent<K>.\n * Can be either:\n * - \"dot.dot.dot\" format\n */\n path?: ValidDotPathsFor<K>;\n};\n\nexport type NestedContent<K extends DictionaryKeys = never> = TypedNodeModel<\n NodeType.Nested,\n NestedContentState<K>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to extract the content of another dictionary and nest it in the current dictionary.\n *\n * Usage:\n *\n * ```ts\n * nest(\"dictionaryKey\");\n * nest(\"dictionaryKey\", \"path.to.content\");\n * ```\n *\n * The order of the keys will define the priority of the content.\n *\n */\nconst nesting = <K extends DictionaryKeys>(\n dictionaryKey: K,\n path?: ValidDotPathsFor<K>\n): NestedContent<K> =>\n formatNodeType(NodeType.Nested, {\n dictionaryKey,\n path,\n });\n\nexport { nesting as nest };\n"],"mappings":"6JAwEA,MAAM,GACJ,EACA,KAAA,EAAA,EAAA,gBAEeA,EAAAA,SAAS,OAAQ,CAC9B,gBACA,OACD,CAAC"}
1
+ {"version":3,"file":"nesting.cjs","names":["NodeType"],"sources":["../../../../src/transpiler/nesting/nesting.ts"],"sourcesContent":["import type { DictionaryRegistryContent } from '@intlayer/types/module_augmentation';\nimport type { DictionaryKeys } from '@intlayer/types/module_augmentation';\nimport type { TypedNodeModel } from '@intlayer/types/nodeType';;\nimport { formatNodeType, NodeType } from '@intlayer/types/nodeType';\nimport type { DeepTransformContent } from '../../interpreter';\n\n/**\n * Recursively builds dot-notation strings for all valid paths in T.\n * Example:\n * type X = { a: { b: { c: string }}, d: number };\n * DotPath<X> = \"a\" | \"a.b\" | \"a.b.c\" | \"d\"\n */\nexport type DotPath<T> = T extends object\n ? {\n [K in keyof T & (string | number)]: T[K] extends object\n ? // Either just K, or K + '.' + deeper path\n `${K}` | `${K}.${DotPath<T[K]>}`\n : `${K}`;\n }[keyof T & (string | number)]\n : never;\n\ntype DeepReplace<T, From, To> = T extends From\n ? To\n : T extends object\n ? { [K in keyof T]: DeepReplace<T[K], From, To> }\n : T;\n\n/** Build all valid dot-notation strings for a dictionary entry. */\nexport type ValidDotPathsFor<K extends DictionaryKeys> = DotPath<\n DeepReplace<\n DeepTransformContent<DictionaryRegistryContent<K>>,\n // Replace ReactElement type with string\n {\n type: any;\n props: any;\n key: any;\n },\n string\n >\n>;\n\nexport type NestedContentState<K extends DictionaryKeys> = {\n dictionaryKey: K;\n\n /**\n * Path must match existing keys in DictionaryRegistryContent<K>.\n * Can be either:\n * - \"dot.dot.dot\" format\n */\n path?: ValidDotPathsFor<K>;\n};\n\nexport type NestedContent<K extends DictionaryKeys = never> = TypedNodeModel<\n NodeType.Nested,\n NestedContentState<K>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to extract the content of another dictionary and nest it in the current dictionary.\n *\n * Usage:\n *\n * ```ts\n * nest(\"dictionaryKey\");\n * nest(\"dictionaryKey\", \"path.to.content\");\n * ```\n *\n * The order of the keys will define the priority of the content.\n *\n */\nconst nesting = <K extends DictionaryKeys>(\n dictionaryKey: K,\n path?: ValidDotPathsFor<K>\n): NestedContent<K> =>\n formatNodeType(NodeType.Nested, {\n dictionaryKey,\n path,\n });\n\nexport { nesting as nest };\n"],"mappings":"iJAwEA,MAAM,GACJ,EACA,KAAA,EAAA,EAAA,gBAEeA,EAAAA,SAAS,OAAQ,CAC9B,gBACA,OACD,CAAC"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);let e=require(`@intlayer/types/nodeType`);const t=t=>(0,e.formatNodeType)(e.NodeType.Translation,t);exports.t=t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../chunk-Bmb41Sf3.cjs`);let e=require(`@intlayer/types/nodeType`);const t=t=>(0,e.formatNodeType)(e.NodeType.Translation,t);exports.t=t;
2
2
  //# sourceMappingURL=translation.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"translation.cjs","names":["NodeType"],"sources":["../../../../src/transpiler/translation/translation.ts"],"sourcesContent":["import type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, NodeType } from '@intlayer/types/nodeType';\n\nexport type TranslationContent<\n Content = unknown,\n RecordContent extends\n StrictModeLocaleMap<Content> = StrictModeLocaleMap<Content>,\n> = TypedNodeModel<NodeType.Translation, RecordContent>;\n\n/**\n *\n * Function intended to be used to build intlayer dictionaries.\n *\n * Get the content of a translation based on the locale.\n *\n * Usage:\n *\n * ```ts\n * translation<string>({\n * \"en\": \"Hello\",\n * \"fr\": \"Bonjour\",\n * // ... any other available locale\n * })\n * ```\n *\n * Using TypeScript:\n * - this function require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nconst translation = <\n Content = unknown,\n ContentRecord extends\n StrictModeLocaleMap<Content> = StrictModeLocaleMap<Content>,\n>(\n content: ContentRecord\n) =>\n formatNodeType(NodeType.Translation, content) satisfies TranslationContent<\n Content,\n ContentRecord\n >;\n\nexport { translation as t };\n"],"mappings":"6JA8BA,MAAM,EAKJ,IAAA,EAAA,EAAA,gBAEeA,EAAAA,SAAS,YAAa,EAAQ"}
1
+ {"version":3,"file":"translation.cjs","names":["NodeType"],"sources":["../../../../src/transpiler/translation/translation.ts"],"sourcesContent":["import type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, NodeType } from '@intlayer/types/nodeType';\n\nexport type TranslationContent<\n Content = unknown,\n RecordContent extends\n StrictModeLocaleMap<Content> = StrictModeLocaleMap<Content>,\n> = TypedNodeModel<NodeType.Translation, RecordContent>;\n\n/**\n *\n * Function intended to be used to build intlayer dictionaries.\n *\n * Get the content of a translation based on the locale.\n *\n * Usage:\n *\n * ```ts\n * translation<string>({\n * \"en\": \"Hello\",\n * \"fr\": \"Bonjour\",\n * // ... any other available locale\n * })\n * ```\n *\n * Using TypeScript:\n * - this function require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nconst translation = <\n Content = unknown,\n ContentRecord extends\n StrictModeLocaleMap<Content> = StrictModeLocaleMap<Content>,\n>(\n content: ContentRecord\n) =>\n formatNodeType(NodeType.Translation, content) satisfies TranslationContent<\n Content,\n ContentRecord\n >;\n\nexport { translation as t };\n"],"mappings":"iJA8BA,MAAM,EAKJ,IAAA,EAAA,EAAA,gBAEeA,EAAAA,SAAS,YAAa,EAAQ"}