ngwr 16.5.0 → 16.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (450) hide show
  1. package/avatar/styles/_index.scss +39 -0
  2. package/back-top/styles/_index.scss +6 -0
  3. package/breadcrumbs/styles/_rules.scss +34 -0
  4. package/button/styles/_index.scss +45 -2
  5. package/cascader/styles/_rules.scss +7 -0
  6. package/charts/chart-legend/styles/_index.scss +1 -9
  7. package/copy-value/styles/_index.scss +4 -0
  8. package/counter/styles/_index.scss +1 -8
  9. package/date-picker/styles/_index.scss +15 -9
  10. package/dialog/styles/_index.scss +37 -0
  11. package/dropdown/styles/_index.scss +17 -0
  12. package/editor/styles/_index.scss +1 -8
  13. package/event-calendar/styles/_index.scss +2 -6
  14. package/fesm2022/ngwr-affix.mjs +4 -4
  15. package/fesm2022/ngwr-affix.mjs.map +1 -1
  16. package/fesm2022/ngwr-alert.mjs +3 -3
  17. package/fesm2022/ngwr-anchor.mjs +12 -5
  18. package/fesm2022/ngwr-anchor.mjs.map +1 -1
  19. package/fesm2022/ngwr-animations-aurora.mjs +3 -3
  20. package/fesm2022/ngwr-animations-aurora.mjs.map +1 -1
  21. package/fesm2022/ngwr-animations-blur-reveal.mjs +3 -3
  22. package/fesm2022/ngwr-animations-blur-reveal.mjs.map +1 -1
  23. package/fesm2022/ngwr-animations-click-sparks.mjs +3 -3
  24. package/fesm2022/ngwr-animations-click-sparks.mjs.map +1 -1
  25. package/fesm2022/ngwr-animations-confetti.mjs +3 -3
  26. package/fesm2022/ngwr-animations-confetti.mjs.map +1 -1
  27. package/fesm2022/ngwr-animations-decode.mjs +3 -3
  28. package/fesm2022/ngwr-animations-decode.mjs.map +1 -1
  29. package/fesm2022/ngwr-animations-destruct.mjs +3 -3
  30. package/fesm2022/ngwr-animations-destruct.mjs.map +1 -1
  31. package/fesm2022/ngwr-animations-dot-grid.mjs +3 -3
  32. package/fesm2022/ngwr-animations-dot-grid.mjs.map +1 -1
  33. package/fesm2022/ngwr-animations-falling-letters.mjs +3 -3
  34. package/fesm2022/ngwr-animations-falling-letters.mjs.map +1 -1
  35. package/fesm2022/ngwr-animations-flow-lines.mjs +3 -3
  36. package/fesm2022/ngwr-animations-flow-lines.mjs.map +1 -1
  37. package/fesm2022/ngwr-animations-fluid-cursor.mjs +3 -3
  38. package/fesm2022/ngwr-animations-fluid-cursor.mjs.map +1 -1
  39. package/fesm2022/ngwr-animations-glitch.mjs +3 -3
  40. package/fesm2022/ngwr-animations-glitch.mjs.map +1 -1
  41. package/fesm2022/ngwr-animations-glow-border.mjs +3 -3
  42. package/fesm2022/ngwr-animations-glow-border.mjs.map +1 -1
  43. package/fesm2022/ngwr-animations-gradient-flow.mjs +3 -3
  44. package/fesm2022/ngwr-animations-gradient-flow.mjs.map +1 -1
  45. package/fesm2022/ngwr-animations-marquee.mjs +4 -3
  46. package/fesm2022/ngwr-animations-marquee.mjs.map +1 -1
  47. package/fesm2022/ngwr-animations-orbit.mjs +3 -3
  48. package/fesm2022/ngwr-animations-orbit.mjs.map +1 -1
  49. package/fesm2022/ngwr-animations-reveal.mjs +3 -3
  50. package/fesm2022/ngwr-animations-reveal.mjs.map +1 -1
  51. package/fesm2022/ngwr-animations-ripple-grid.mjs +3 -3
  52. package/fesm2022/ngwr-animations-ripple-grid.mjs.map +1 -1
  53. package/fesm2022/ngwr-animations-rotate-reveal.mjs +3 -3
  54. package/fesm2022/ngwr-animations-rotate-reveal.mjs.map +1 -1
  55. package/fesm2022/ngwr-animations-shimmer.mjs +3 -3
  56. package/fesm2022/ngwr-animations-shimmer.mjs.map +1 -1
  57. package/fesm2022/ngwr-animations-spotlight.mjs +3 -3
  58. package/fesm2022/ngwr-animations-spotlight.mjs.map +1 -1
  59. package/fesm2022/ngwr-animations-thread-lines.mjs +3 -3
  60. package/fesm2022/ngwr-animations-thread-lines.mjs.map +1 -1
  61. package/fesm2022/ngwr-animations-tilt.mjs +23 -16
  62. package/fesm2022/ngwr-animations-tilt.mjs.map +1 -1
  63. package/fesm2022/ngwr-animations-typewriter.mjs +3 -3
  64. package/fesm2022/ngwr-animations-typewriter.mjs.map +1 -1
  65. package/fesm2022/ngwr-avatar.mjs +171 -6
  66. package/fesm2022/ngwr-avatar.mjs.map +1 -1
  67. package/fesm2022/ngwr-back-top.mjs +3 -3
  68. package/fesm2022/ngwr-badge.mjs +6 -6
  69. package/fesm2022/ngwr-breadcrumbs.mjs +47 -13
  70. package/fesm2022/ngwr-breadcrumbs.mjs.map +1 -1
  71. package/fesm2022/ngwr-burger.mjs +3 -3
  72. package/fesm2022/ngwr-button.mjs +38 -9
  73. package/fesm2022/ngwr-button.mjs.map +1 -1
  74. package/fesm2022/ngwr-calendar.mjs +3 -3
  75. package/fesm2022/ngwr-card.mjs +9 -9
  76. package/fesm2022/ngwr-carousel.mjs +14 -8
  77. package/fesm2022/ngwr-carousel.mjs.map +1 -1
  78. package/fesm2022/ngwr-cascader.mjs +27 -7
  79. package/fesm2022/ngwr-cascader.mjs.map +1 -1
  80. package/fesm2022/ngwr-charts-bar-chart.mjs +3 -3
  81. package/fesm2022/ngwr-charts-boxplot-chart.mjs +3 -3
  82. package/fesm2022/ngwr-charts-bullet-chart.mjs +3 -3
  83. package/fesm2022/ngwr-charts-calendar-heatmap.mjs +3 -3
  84. package/fesm2022/ngwr-charts-candlestick-chart.mjs +3 -3
  85. package/fesm2022/ngwr-charts-chart-legend.mjs +9 -9
  86. package/fesm2022/ngwr-charts-core.mjs +18 -11
  87. package/fesm2022/ngwr-charts-core.mjs.map +1 -1
  88. package/fesm2022/ngwr-charts-donut-chart.mjs +3 -3
  89. package/fesm2022/ngwr-charts-funnel-chart.mjs +3 -3
  90. package/fesm2022/ngwr-charts-gauge.mjs +3 -3
  91. package/fesm2022/ngwr-charts-heatmap-chart.mjs +3 -3
  92. package/fesm2022/ngwr-charts-line-chart.mjs +3 -3
  93. package/fesm2022/ngwr-charts-meter-group.mjs +7 -5
  94. package/fesm2022/ngwr-charts-meter-group.mjs.map +1 -1
  95. package/fesm2022/ngwr-charts-radar-chart.mjs +3 -3
  96. package/fesm2022/ngwr-charts-scatter-chart.mjs +3 -3
  97. package/fesm2022/ngwr-charts-sparkline.mjs +3 -3
  98. package/fesm2022/ngwr-charts-treemap-chart.mjs +3 -3
  99. package/fesm2022/ngwr-charts-waterfall-chart.mjs +3 -3
  100. package/fesm2022/ngwr-checkbox.mjs +9 -8
  101. package/fesm2022/ngwr-checkbox.mjs.map +1 -1
  102. package/fesm2022/ngwr-clipboard.mjs +3 -3
  103. package/fesm2022/ngwr-collapse.mjs +9 -9
  104. package/fesm2022/ngwr-color-picker.mjs +27 -7
  105. package/fesm2022/ngwr-color-picker.mjs.map +1 -1
  106. package/fesm2022/ngwr-command-palette.mjs +3 -3
  107. package/fesm2022/ngwr-comment.mjs +7 -6
  108. package/fesm2022/ngwr-comment.mjs.map +1 -1
  109. package/fesm2022/ngwr-compare.mjs +3 -3
  110. package/fesm2022/ngwr-context-menu.mjs +16 -17
  111. package/fesm2022/ngwr-context-menu.mjs.map +1 -1
  112. package/fesm2022/ngwr-cookie.mjs +3 -3
  113. package/fesm2022/ngwr-copy-value.mjs +3 -3
  114. package/fesm2022/ngwr-counter.mjs +6 -6
  115. package/fesm2022/ngwr-date-picker-testing.mjs +35 -0
  116. package/fesm2022/ngwr-date-picker-testing.mjs.map +1 -1
  117. package/fesm2022/ngwr-date-picker.mjs +151 -54
  118. package/fesm2022/ngwr-date-picker.mjs.map +1 -1
  119. package/fesm2022/ngwr-date-stamp.mjs +3 -3
  120. package/fesm2022/ngwr-date.mjs +40 -16
  121. package/fesm2022/ngwr-date.mjs.map +1 -1
  122. package/fesm2022/ngwr-density.mjs +6 -6
  123. package/fesm2022/ngwr-descriptions.mjs +6 -6
  124. package/fesm2022/ngwr-dialog.mjs +35 -24
  125. package/fesm2022/ngwr-dialog.mjs.map +1 -1
  126. package/fesm2022/ngwr-directives.mjs +189 -23
  127. package/fesm2022/ngwr-directives.mjs.map +1 -1
  128. package/fesm2022/ngwr-divider.mjs +3 -3
  129. package/fesm2022/ngwr-drawer.mjs +18 -18
  130. package/fesm2022/ngwr-dropdown-testing.mjs +5 -1
  131. package/fesm2022/ngwr-dropdown-testing.mjs.map +1 -1
  132. package/fesm2022/ngwr-dropdown.mjs +59 -16
  133. package/fesm2022/ngwr-dropdown.mjs.map +1 -1
  134. package/fesm2022/ngwr-editor.mjs +6 -5
  135. package/fesm2022/ngwr-editor.mjs.map +1 -1
  136. package/fesm2022/ngwr-empty.mjs +3 -3
  137. package/fesm2022/ngwr-event-calendar.mjs +27 -15
  138. package/fesm2022/ngwr-event-calendar.mjs.map +1 -1
  139. package/fesm2022/ngwr-file-upload-testing.mjs +5 -0
  140. package/fesm2022/ngwr-file-upload-testing.mjs.map +1 -1
  141. package/fesm2022/ngwr-file-upload.mjs +68 -13
  142. package/fesm2022/ngwr-file-upload.mjs.map +1 -1
  143. package/fesm2022/ngwr-form.mjs +181 -12
  144. package/fesm2022/ngwr-form.mjs.map +1 -1
  145. package/fesm2022/ngwr-graph-testing.mjs +30 -0
  146. package/fesm2022/ngwr-graph-testing.mjs.map +1 -1
  147. package/fesm2022/ngwr-graph.mjs +100 -11
  148. package/fesm2022/ngwr-graph.mjs.map +1 -1
  149. package/fesm2022/ngwr-hotkey.mjs +6 -6
  150. package/fesm2022/ngwr-i18n-ar.mjs +21 -2
  151. package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
  152. package/fesm2022/ngwr-i18n-cs.mjs +21 -2
  153. package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
  154. package/fesm2022/ngwr-i18n-de.mjs +21 -2
  155. package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
  156. package/fesm2022/ngwr-i18n-en.mjs +21 -2
  157. package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
  158. package/fesm2022/ngwr-i18n-es.mjs +21 -2
  159. package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
  160. package/fesm2022/ngwr-i18n-fr.mjs +21 -2
  161. package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
  162. package/fesm2022/ngwr-i18n-he.mjs +21 -2
  163. package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
  164. package/fesm2022/ngwr-i18n-hi.mjs +21 -2
  165. package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
  166. package/fesm2022/ngwr-i18n-id.mjs +21 -2
  167. package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
  168. package/fesm2022/ngwr-i18n-it.mjs +21 -2
  169. package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
  170. package/fesm2022/ngwr-i18n-ja.mjs +21 -2
  171. package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
  172. package/fesm2022/ngwr-i18n-kk.mjs +520 -0
  173. package/fesm2022/ngwr-i18n-kk.mjs.map +1 -0
  174. package/fesm2022/ngwr-i18n-ko.mjs +21 -2
  175. package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
  176. package/fesm2022/ngwr-i18n-nl.mjs +21 -2
  177. package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
  178. package/fesm2022/ngwr-i18n-pl.mjs +21 -2
  179. package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
  180. package/fesm2022/ngwr-i18n-pt.mjs +21 -2
  181. package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
  182. package/fesm2022/ngwr-i18n-ru.mjs +21 -2
  183. package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
  184. package/fesm2022/ngwr-i18n-sv.mjs +21 -2
  185. package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
  186. package/fesm2022/ngwr-i18n-tr.mjs +21 -2
  187. package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
  188. package/fesm2022/ngwr-i18n-uk.mjs +21 -2
  189. package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
  190. package/fesm2022/ngwr-i18n-vi.mjs +21 -2
  191. package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
  192. package/fesm2022/ngwr-i18n-zh-tw.mjs +21 -2
  193. package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
  194. package/fesm2022/ngwr-i18n-zh.mjs +21 -2
  195. package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
  196. package/fesm2022/ngwr-i18n.mjs +91 -20
  197. package/fesm2022/ngwr-i18n.mjs.map +1 -1
  198. package/fesm2022/ngwr-icon.mjs +6 -6
  199. package/fesm2022/ngwr-image-cropper.mjs +8 -4
  200. package/fesm2022/ngwr-image-cropper.mjs.map +1 -1
  201. package/fesm2022/ngwr-input-number.mjs +27 -4
  202. package/fesm2022/ngwr-input-number.mjs.map +1 -1
  203. package/fesm2022/ngwr-input-otp.mjs +5 -5
  204. package/fesm2022/ngwr-input-otp.mjs.map +1 -1
  205. package/fesm2022/ngwr-input.mjs +25 -17
  206. package/fesm2022/ngwr-input.mjs.map +1 -1
  207. package/fesm2022/ngwr-keyboard.mjs +3 -3
  208. package/fesm2022/ngwr-knob.mjs +3 -3
  209. package/fesm2022/ngwr-layout.mjs +15 -15
  210. package/fesm2022/ngwr-layout.mjs.map +1 -1
  211. package/fesm2022/ngwr-lightbox.mjs +8 -8
  212. package/fesm2022/ngwr-lightbox.mjs.map +1 -1
  213. package/fesm2022/ngwr-list.mjs +9 -9
  214. package/fesm2022/ngwr-list.mjs.map +1 -1
  215. package/fesm2022/ngwr-load-state.mjs +16 -15
  216. package/fesm2022/ngwr-load-state.mjs.map +1 -1
  217. package/fesm2022/ngwr-loading-bar-router.mjs.map +1 -1
  218. package/fesm2022/ngwr-loading-bar.mjs +8 -8
  219. package/fesm2022/ngwr-loading-bar.mjs.map +1 -1
  220. package/fesm2022/ngwr-mention.mjs +14 -6
  221. package/fesm2022/ngwr-mention.mjs.map +1 -1
  222. package/fesm2022/ngwr-meta.mjs +15 -12
  223. package/fesm2022/ngwr-meta.mjs.map +1 -1
  224. package/fesm2022/ngwr-overlay.mjs +9 -9
  225. package/fesm2022/ngwr-page-header.mjs +24 -3
  226. package/fesm2022/ngwr-page-header.mjs.map +1 -1
  227. package/fesm2022/ngwr-pagination-testing.mjs +3 -0
  228. package/fesm2022/ngwr-pagination-testing.mjs.map +1 -1
  229. package/fesm2022/ngwr-pagination.mjs +34 -5
  230. package/fesm2022/ngwr-pagination.mjs.map +1 -1
  231. package/fesm2022/ngwr-pipes.mjs +35 -28
  232. package/fesm2022/ngwr-pipes.mjs.map +1 -1
  233. package/fesm2022/ngwr-platform.mjs +9 -9
  234. package/fesm2022/ngwr-popconfirm.mjs +9 -7
  235. package/fesm2022/ngwr-popconfirm.mjs.map +1 -1
  236. package/fesm2022/ngwr-popover.mjs +162 -18
  237. package/fesm2022/ngwr-popover.mjs.map +1 -1
  238. package/fesm2022/ngwr-progress.mjs +75 -10
  239. package/fesm2022/ngwr-progress.mjs.map +1 -1
  240. package/fesm2022/ngwr-pull-to-refresh.mjs +3 -3
  241. package/fesm2022/ngwr-qr.mjs +9 -5
  242. package/fesm2022/ngwr-qr.mjs.map +1 -1
  243. package/fesm2022/ngwr-radio.mjs +77 -11
  244. package/fesm2022/ngwr-radio.mjs.map +1 -1
  245. package/fesm2022/ngwr-rating.mjs +3 -3
  246. package/fesm2022/ngwr-resizable.mjs +3 -3
  247. package/fesm2022/ngwr-result.mjs +12 -12
  248. package/fesm2022/ngwr-schema-form.mjs +20 -7
  249. package/fesm2022/ngwr-schema-form.mjs.map +1 -1
  250. package/fesm2022/ngwr-scroll.mjs +233 -10
  251. package/fesm2022/ngwr-scroll.mjs.map +1 -1
  252. package/fesm2022/ngwr-segmented.mjs +23 -3
  253. package/fesm2022/ngwr-segmented.mjs.map +1 -1
  254. package/fesm2022/ngwr-select.mjs +106 -26
  255. package/fesm2022/ngwr-select.mjs.map +1 -1
  256. package/fesm2022/ngwr-sidebar-testing.mjs +17 -1
  257. package/fesm2022/ngwr-sidebar-testing.mjs.map +1 -1
  258. package/fesm2022/ngwr-sidebar.mjs +66 -11
  259. package/fesm2022/ngwr-sidebar.mjs.map +1 -1
  260. package/fesm2022/ngwr-skeleton.mjs +3 -3
  261. package/fesm2022/ngwr-slider.mjs +3 -3
  262. package/fesm2022/ngwr-sortable-list.mjs +27 -15
  263. package/fesm2022/ngwr-sortable-list.mjs.map +1 -1
  264. package/fesm2022/ngwr-speed-dial.mjs +3 -3
  265. package/fesm2022/ngwr-spinner.mjs +3 -3
  266. package/fesm2022/ngwr-splitter.mjs +3 -3
  267. package/fesm2022/ngwr-statistic.mjs +9 -9
  268. package/fesm2022/ngwr-stepper.mjs +6 -6
  269. package/fesm2022/ngwr-storage.mjs +4 -4
  270. package/fesm2022/ngwr-storage.mjs.map +1 -1
  271. package/fesm2022/ngwr-switch.mjs +5 -5
  272. package/fesm2022/ngwr-switch.mjs.map +1 -1
  273. package/fesm2022/ngwr-table-router.mjs +89 -0
  274. package/fesm2022/ngwr-table-router.mjs.map +1 -0
  275. package/fesm2022/ngwr-table-testing.mjs +5 -0
  276. package/fesm2022/ngwr-table-testing.mjs.map +1 -1
  277. package/fesm2022/ngwr-table.mjs +307 -47
  278. package/fesm2022/ngwr-table.mjs.map +1 -1
  279. package/fesm2022/ngwr-tabs-router.mjs +9 -5
  280. package/fesm2022/ngwr-tabs-router.mjs.map +1 -1
  281. package/fesm2022/ngwr-tabs-testing.mjs +8 -1
  282. package/fesm2022/ngwr-tabs-testing.mjs.map +1 -1
  283. package/fesm2022/ngwr-tabs.mjs +60 -10
  284. package/fesm2022/ngwr-tabs.mjs.map +1 -1
  285. package/fesm2022/ngwr-textarea.mjs +5 -5
  286. package/fesm2022/ngwr-textarea.mjs.map +1 -1
  287. package/fesm2022/ngwr-theme.mjs +3 -3
  288. package/fesm2022/ngwr-timeline.mjs +6 -6
  289. package/fesm2022/ngwr-toast.mjs +43 -15
  290. package/fesm2022/ngwr-toast.mjs.map +1 -1
  291. package/fesm2022/ngwr-toolbar.mjs +3 -3
  292. package/fesm2022/ngwr-tour.mjs +9 -8
  293. package/fesm2022/ngwr-tour.mjs.map +1 -1
  294. package/fesm2022/ngwr-transfer.mjs +4 -3
  295. package/fesm2022/ngwr-transfer.mjs.map +1 -1
  296. package/fesm2022/ngwr-tree.mjs +3 -3
  297. package/fesm2022/ngwr-typography.mjs +23 -3
  298. package/fesm2022/ngwr-typography.mjs.map +1 -1
  299. package/fesm2022/ngwr-utils-router.mjs +3 -3
  300. package/fesm2022/ngwr-utils-router.mjs.map +1 -1
  301. package/fesm2022/ngwr-utils.mjs +74 -4
  302. package/fesm2022/ngwr-utils.mjs.map +1 -1
  303. package/fesm2022/ngwr-validators.mjs +33 -1
  304. package/fesm2022/ngwr-validators.mjs.map +1 -1
  305. package/fesm2022/ngwr-version.mjs +1 -1
  306. package/fesm2022/ngwr-version.mjs.map +1 -1
  307. package/fesm2022/ngwr-virtual-scroll.mjs +3 -3
  308. package/fesm2022/ngwr-window.mjs +18 -13
  309. package/fesm2022/ngwr-window.mjs.map +1 -1
  310. package/file-upload/styles/_index.scss +16 -0
  311. package/form/styles/_index.scss +37 -0
  312. package/graph/styles/_index.scss +49 -9
  313. package/i18n/ar.json +19 -2
  314. package/i18n/cs.json +19 -2
  315. package/i18n/de.json +19 -2
  316. package/i18n/en.json +19 -2
  317. package/i18n/es.json +19 -2
  318. package/i18n/fr.json +19 -2
  319. package/i18n/he.json +19 -2
  320. package/i18n/hi.json +19 -2
  321. package/i18n/id.json +19 -2
  322. package/i18n/it.json +19 -2
  323. package/i18n/ja.json +19 -2
  324. package/i18n/kk.json +567 -0
  325. package/i18n/ko.json +19 -2
  326. package/i18n/nl.json +19 -2
  327. package/i18n/pl.json +19 -2
  328. package/i18n/pt.json +19 -2
  329. package/i18n/ru.json +19 -2
  330. package/i18n/sv.json +19 -2
  331. package/i18n/tr.json +19 -2
  332. package/i18n/uk.json +19 -2
  333. package/i18n/vi.json +19 -2
  334. package/i18n/zh-TW.json +19 -2
  335. package/i18n/zh.json +19 -2
  336. package/image-cropper/styles/_index.scss +1 -9
  337. package/input-number/styles/_index.scss +7 -0
  338. package/layout/styles/_index.scss +13 -1
  339. package/llms-full.txt +37 -26
  340. package/llms.txt +4 -1
  341. package/loading-bar/styles/_rules.scss +6 -0
  342. package/package.json +16 -8
  343. package/page-header/styles/_index.scss +18 -0
  344. package/pagination/styles/_index.scss +6 -0
  345. package/popover/styles/_index.scss +9 -0
  346. package/progress/styles/_index.scss +64 -0
  347. package/schematics/use/symbol-map.json +7 -0
  348. package/segmented/styles/_index.scss +7 -0
  349. package/select/styles/_index.scss +7 -0
  350. package/sidebar/styles/_index.scss +64 -6
  351. package/skills/ngwr/SKILL.md +7 -6
  352. package/skills/ngwr/references/catalog.md +7 -5
  353. package/sortable-list/styles/_rules.scss +1 -9
  354. package/speed-dial/styles/_index.scss +6 -0
  355. package/stepper/styles/_index.scss +1 -9
  356. package/table/styles/_index.scss +168 -30
  357. package/tabs/styles/_index.scss +9 -0
  358. package/theme/_index.scss +12 -1
  359. package/theme/styles/_colors.scss +11 -0
  360. package/theme/styles/_contrast.scss +6 -0
  361. package/theme/styles/_focus.scss +3 -1
  362. package/theme/styles/_index.scss +1 -0
  363. package/theme/styles/_mixins.scss +45 -0
  364. package/theme/styles/_print.scss +17 -0
  365. package/toast/styles/_index.scss +7 -0
  366. package/tour/styles/_index.scss +9 -0
  367. package/tree/styles/_index.scss +1 -9
  368. package/types/ngwr-anchor.d.ts +3 -0
  369. package/types/ngwr-animations-aurora.d.ts +6 -0
  370. package/types/ngwr-animations-blur-reveal.d.ts +6 -0
  371. package/types/ngwr-animations-click-sparks.d.ts +6 -0
  372. package/types/ngwr-animations-confetti.d.ts +6 -0
  373. package/types/ngwr-animations-decode.d.ts +6 -0
  374. package/types/ngwr-animations-destruct.d.ts +6 -0
  375. package/types/ngwr-animations-dot-grid.d.ts +6 -0
  376. package/types/ngwr-animations-falling-letters.d.ts +6 -0
  377. package/types/ngwr-animations-flow-lines.d.ts +6 -0
  378. package/types/ngwr-animations-fluid-cursor.d.ts +6 -0
  379. package/types/ngwr-animations-glitch.d.ts +6 -0
  380. package/types/ngwr-animations-glow-border.d.ts +6 -0
  381. package/types/ngwr-animations-gradient-flow.d.ts +6 -0
  382. package/types/ngwr-animations-marquee.d.ts +6 -0
  383. package/types/ngwr-animations-orbit.d.ts +6 -0
  384. package/types/ngwr-animations-reveal.d.ts +6 -0
  385. package/types/ngwr-animations-ripple-grid.d.ts +6 -0
  386. package/types/ngwr-animations-rotate-reveal.d.ts +6 -0
  387. package/types/ngwr-animations-shimmer.d.ts +6 -0
  388. package/types/ngwr-animations-spotlight.d.ts +6 -0
  389. package/types/ngwr-animations-thread-lines.d.ts +6 -0
  390. package/types/ngwr-animations-tilt.d.ts +10 -0
  391. package/types/ngwr-animations-typewriter.d.ts +6 -0
  392. package/types/ngwr-avatar.d.ts +39 -0
  393. package/types/ngwr-breadcrumbs.d.ts +25 -0
  394. package/types/ngwr-button.d.ts +35 -3
  395. package/types/ngwr-carousel.d.ts +2 -0
  396. package/types/ngwr-cascader.d.ts +7 -0
  397. package/types/ngwr-charts-core.d.ts +16 -0
  398. package/types/ngwr-charts-meter-group.d.ts +2 -0
  399. package/types/ngwr-checkbox.d.ts +1 -0
  400. package/types/ngwr-color-picker.d.ts +1 -0
  401. package/types/ngwr-context-menu.d.ts +1 -1
  402. package/types/ngwr-date-picker-testing.d.ts +22 -0
  403. package/types/ngwr-date-picker.d.ts +97 -17
  404. package/types/ngwr-date.d.ts +51 -0
  405. package/types/ngwr-dialog.d.ts +39 -8
  406. package/types/ngwr-directives.d.ts +57 -4
  407. package/types/ngwr-drawer.d.ts +1 -1
  408. package/types/ngwr-dropdown-testing.d.ts +8 -1
  409. package/types/ngwr-dropdown.d.ts +30 -1
  410. package/types/ngwr-event-calendar.d.ts +4 -0
  411. package/types/ngwr-file-upload-testing.d.ts +10 -0
  412. package/types/ngwr-file-upload.d.ts +55 -1
  413. package/types/ngwr-form.d.ts +87 -1
  414. package/types/ngwr-graph-testing.d.ts +28 -1
  415. package/types/ngwr-graph.d.ts +53 -3
  416. package/types/ngwr-i18n-kk.d.ts +3 -0
  417. package/types/ngwr-i18n.d.ts +65 -5
  418. package/types/ngwr-image-cropper.d.ts +6 -0
  419. package/types/ngwr-input-number.d.ts +8 -0
  420. package/types/ngwr-input.d.ts +7 -0
  421. package/types/ngwr-layout.d.ts +1 -1
  422. package/types/ngwr-loading-bar-router.d.ts +6 -0
  423. package/types/ngwr-page-header.d.ts +23 -1
  424. package/types/ngwr-pagination-testing.d.ts +8 -0
  425. package/types/ngwr-pagination.d.ts +16 -0
  426. package/types/ngwr-popconfirm.d.ts +1 -1
  427. package/types/ngwr-popover.d.ts +67 -4
  428. package/types/ngwr-progress.d.ts +63 -1
  429. package/types/ngwr-radio.d.ts +47 -5
  430. package/types/ngwr-scroll.d.ts +86 -0
  431. package/types/ngwr-segmented.d.ts +7 -0
  432. package/types/ngwr-select.d.ts +88 -25
  433. package/types/ngwr-sidebar-testing.d.ts +21 -7
  434. package/types/ngwr-sidebar.d.ts +66 -4
  435. package/types/ngwr-sortable-list.d.ts +20 -7
  436. package/types/ngwr-table-router.d.ts +49 -0
  437. package/types/ngwr-table-testing.d.ts +7 -0
  438. package/types/ngwr-table.d.ts +241 -10
  439. package/types/ngwr-tabs-router.d.ts +7 -1
  440. package/types/ngwr-tabs-testing.d.ts +5 -1
  441. package/types/ngwr-tabs.d.ts +34 -1
  442. package/types/ngwr-toast.d.ts +11 -0
  443. package/types/ngwr-tour.d.ts +0 -1
  444. package/types/ngwr-typography.d.ts +7 -0
  445. package/types/ngwr-utils-router.d.ts +6 -0
  446. package/types/ngwr-utils.d.ts +69 -2
  447. package/types/ngwr-validators.d.ts +49 -1
  448. package/types/ngwr-version.d.ts +1 -1
  449. package/typography/styles/_index.scss +4 -0
  450. package/window/styles/_index.scss +1 -9
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-i18n.mjs","names":[],"sources":["../../../projects/lib/i18n/i18n-base-catalogs.ts","../../../projects/lib/i18n/i18n-config.ts","../../../projects/lib/i18n/i18n-loader.ts","../../../projects/lib/i18n/i18n.ts","../../../projects/lib/i18n/t.pipe.ts","../../../projects/lib/i18n/t.directive.ts","../../../projects/lib/i18n/loaders/static-loader.ts","../../../projects/lib/i18n/loaders/http-loader.ts","../../../projects/lib/i18n/provide-wr-i18n.ts","../../../projects/lib/i18n/util.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport { type WrI18nCatalog } from './i18n-config';\n\n/** Base catalogs keyed by locale, contributed by {@link provideWrI18nBaseCatalogs}. */\nexport type WrI18nBaseCatalogs = Readonly<Record<string, WrI18nCatalog>>;\n\n/**\n * Catalogs consulted *underneath* whatever the loader returned — the place for\n * ngwr's own built-in strings.\n *\n * A loader **replaces** the catalog for a locale rather than extending it, so an\n * app whose JSON holds only its own keys used to lose every built-in label to\n * its hardcoded English fallback, silently. Registering `wrRu` / `wrEn` here\n * puts them back without the app having to merge anything itself.\n *\n * `multi`, so several features can each contribute; later contributions win on\n * a key collision, and anything the loader returned still wins over all of them.\n *\n * It has to be handed in by the consumer rather than wired up inside\n * `provideWrI18n()`: the catalogs are their own entry points (`ngwr/i18n/ru`)\n * and they already import from `ngwr/i18n`, so importing them back here would\n * be a circular dependency between entry points. Passing them in also keeps\n * the locales you don't ship out of your bundle.\n */\nexport const WR_I18N_BASE_CATALOGS = new InjectionToken<readonly WrI18nBaseCatalogs[]>('WR_I18N_BASE_CATALOGS');\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken, LOCALE_ID, inject } from '@angular/core';\n\n/** Translation catalog — flat or nested record of strings. */\nexport interface WrI18nCatalog {\n readonly [key: string]: string | WrI18nCatalog;\n}\n\n/** Parameters passed to interpolation — coerced to strings via `String(v)`. */\nexport type WrI18nParams = Readonly<Record<string, unknown>>;\n\n/**\n * The third argument of `WrI18n.t()`, `WrI18n.translate()` and the `wrT` pipe,\n * where a bare string is the scope.\n */\nexport interface WrI18nTranslateOptions {\n /** Scoped lookup first, then the root catalog. */\n readonly scope?: string;\n\n /**\n * Returned as is when the key is missing: no interpolation, no\n * `missingHandler` call. `null` and `undefined` mean no fallback.\n */\n readonly fallback?: string | null;\n}\n\n/** Hook called once on every key that resolves to nothing. */\nexport type WrI18nMissingHandler = (key: string, locale: string) => string;\n\n/** User-facing config for {@link provideWrI18n}. */\nexport interface WrI18nConfig {\n /**\n * BCP-47 tag used until the user calls `use()`.\n *\n * Omitted, it is Angular's own `LOCALE_ID` — the app already states its\n * locale there, and ngwr having a second, unrelated default is how a fully\n * Russian app came to render an English calendar inside itself. See\n * {@link WrI18n} for the whole precedence.\n *\n * @default LOCALE_ID\n */\n readonly defaultLocale?: string;\n\n /**\n * Whitelisted locales — `use()` ignores anything outside this list. Omitted,\n * it is `[defaultLocale]`: it used to be a hardcoded `['en']`, so\n * `provideWrI18n({ defaultLocale: 'ru' })` produced a service whose own\n * default locale was not switchable back to.\n *\n * @default [defaultLocale]\n */\n readonly availableLocales?: readonly string[];\n\n /**\n * Storage key for persisting the active locale (via `WrStorage`).\n * Set to `null` to disable persistence. @default 'wr:i18n:locale'\n */\n readonly storageKey?: string | null;\n\n /** Called when a key is missing. Default returns the key itself. */\n readonly missingHandler?: WrI18nMissingHandler;\n}\n\n/** Resolved config — every field non-optional. @internal */\nexport interface WrI18nConfigResolved {\n readonly defaultLocale: string;\n readonly availableLocales: readonly string[];\n readonly storageKey: string | null;\n readonly missingHandler: WrI18nMissingHandler;\n}\n\n/**\n * Everything but the locale, which cannot be a constant: it is resolved from\n * `LOCALE_ID` in an injection context. @internal\n */\nexport const DEFAULT_WR_I18N_CONFIG: Omit<WrI18nConfigResolved, 'defaultLocale' | 'availableLocales'> = {\n storageKey: 'wr:i18n:locale',\n missingHandler: key => key,\n};\n\n/**\n * Resolve the locale half of the config. Callable only from an injection\n * context, because the seed is `LOCALE_ID`. @internal\n */\nexport function resolveWrI18nLocales(\n config: WrI18nConfig\n): Pick<WrI18nConfigResolved, 'defaultLocale' | 'availableLocales'> {\n const defaultLocale = config.defaultLocale ?? inject(LOCALE_ID);\n return { defaultLocale, availableLocales: config.availableLocales ?? [defaultLocale] };\n}\n\nexport const WR_I18N_CONFIG = new InjectionToken<WrI18nConfigResolved>('WR_I18N_CONFIG', {\n factory: () => ({ ...DEFAULT_WR_I18N_CONFIG, ...resolveWrI18nLocales({}) }),\n});\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport { of, type Observable } from 'rxjs';\n\nimport { type WrI18nCatalog } from './i18n-config';\n\n/**\n * Loads a catalog for a `(locale, scope)` pair. `scope` is `null` for the\n * root catalog. Implementations may return the catalog synchronously\n * (via `of(...)`) for static catalogs or asynchronously (via HTTP) for\n * lazy fetches.\n */\nexport interface WrI18nLoader {\n load(locale: string, scope: string | null): Observable<WrI18nCatalog>;\n}\n\n/**\n * The active loader.\n *\n * Defaults to one that serves an empty catalog, which is what makes\n * `provideWrI18n()` genuinely optional: every ngwr component routes its\n * built-in strings through `useI18nText` / `wrReadI18nText`, those inject\n * `WrI18n` optionally — and because `WrI18n` is `providedIn: 'root'`, an\n * optional inject still CONSTRUCTS it. Without a default here that construction\n * threw `NG0201: No provider found for WR_I18N_LOADER`, so an app that had\n * simply not configured i18n could not render `<wr-alert>` at all.\n *\n * With the empty catalog, every lookup misses, `t()` hands back the key, and\n * the helpers fall through to the component's own English default — the\n * documented no-i18n behaviour.\n */\nexport const WR_I18N_LOADER = new InjectionToken<WrI18nLoader>('WR_I18N_LOADER', {\n providedIn: 'root',\n factory: () => ({ load: () => of({}) }),\n});\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { LOCALE_ID, Service, type Signal, computed, effect, inject, isDevMode, signal } from '@angular/core';\n\nimport { type Observable, firstValueFrom } from 'rxjs';\n\nimport { WrStorage } from 'ngwr/storage';\n\nimport { WR_I18N_BASE_CATALOGS } from './i18n-base-catalogs';\nimport { WR_I18N_CONFIG, type WrI18nCatalog, type WrI18nParams, type WrI18nTranslateOptions } from './i18n-config';\nimport { WR_I18N_LOADER } from './i18n-loader';\n\n/** Cache key shape: `<locale>::<scope|''>`. @internal */\nfunction cacheKey(locale: string, scope: string | null): string {\n return `${locale}::${scope ?? ''}`;\n}\n\n/**\n * A locale and the language under it: `'ru-RU'` gives `['ru-RU', 'ru']`.\n *\n * Every lookup and every load walks this, so a catalog registered as `ru`\n * answers an app running `ru-RU`. Without it the two spellings are unrelated\n * strings, and the miss is silent — `t()` returns the key, `useI18nText` reads\n * that as \"missing\" and serves the English fallback, so a fully translated app\n * renders English with nothing logged. It only ever truncates: an `en` lookup\n * never reaches an `en-US` catalog, because a language is not a region.\n *\n * @internal\n */\nfunction localeChain(locale: string): readonly string[] {\n const dash = locale.indexOf('-');\n return dash > 0 ? [locale, locale.slice(0, dash)] : [locale];\n}\n\n/** Walk a dotted path through a catalog tree. Returns string | null. @internal */\nfunction walk(cat: WrI18nCatalog | null, key: string): string | null {\n if (!cat) return null;\n let node: string | WrI18nCatalog | undefined = cat;\n for (const part of key.split('.')) {\n if (node === undefined || typeof node === 'string') return null;\n node = node[part];\n }\n return typeof node === 'string' ? node : null;\n}\n\n/**\n * `{{name}}` interpolation. Missing params resolve to `''`. Exported so\n * helpers in `util.ts` can interpolate the fallback template when no\n * `WrI18n` provider is wired up.\n *\n * @internal\n */\nexport function wrInterpolate(template: string, params: WrI18nParams | undefined): string {\n if (!params) return template;\n return template.replace(/\\{\\{\\s*([\\w.-]+)\\s*\\}\\}/g, (_match, name: string) => {\n const v = params[name];\n if (v === undefined || v === null) return '';\n if (typeof v === 'string') return v;\n if (typeof v === 'number' || typeof v === 'boolean') return String(v);\n try {\n return JSON.stringify(v);\n } catch {\n return '';\n }\n });\n}\n\n/**\n * Reactive i18n service. Holds:\n *\n * - the active locale as a `Signal<string>`\n * - per-`(locale, scope)` catalogs in a `Map` (loaded once, then cached)\n * - a per-locale signal counter so every `translate()` reading the signal\n * re-evaluates the moment a new catalog finishes loading\n *\n * Translations are looked up scope-first then root, per locale, and the locale\n * itself is tried as the full tag before the bare language underneath it — so\n * an app running `ru-RU` resolves against a catalog registered as `ru`, and a\n * regional catalog is never shadowed by a scope in the base language. For an\n * app that spells its locale one way, which is every app that existed before\n * the chain, the order is exactly what it always was.\n *\n * ## Which locale wins\n *\n * ngwr has three locale inputs and they used to be three unrelated answers — an\n * app that set `LOCALE_ID: 'ru-RU'` correctly still rendered an English\n * calendar, because the date token defaulted to `navigator.language`. The\n * precedence is now stated, highest first:\n *\n * 1. **A subsystem's own explicit option.** `withDates({ locale })` pins\n * dates; `provideWrI18n({ defaultLocale })` pins the catalog. The most\n * specific statement wins, because it can only have been deliberate.\n * 2. **`WrI18n.locale()` — the runtime value.** The only one of the three that\n * can change without a reload, so it is what a language switcher writes.\n * With `provideWrI18n()` in the app, dates are written in it.\n * 3. **`LOCALE_ID`.** Angular's app-wide constant, and the seed for both of the\n * above when neither was given. One statement, one answer.\n * 4. `'en-US'`, which is what `LOCALE_ID` itself falls back to.\n *\n * `navigator.language` is deliberately NOT in that list. It is the browser's\n * preference, not the application's, and reading it made prerendered output and\n * the hydrated page disagree.\n *\n * **What a runtime switch reaches, and what it does not.** `use()` repaints\n * every catalog string, and every date: the date adapter, and so\n * `wr-calendar`, `wr-date-picker`, `wrDate` and `wr-date-stamp`, formats in\n * this locale unless `withDates({ locale })` pinned another. It does not move\n * `LOCALE_ID`, which is a constant, so anything keyed on it — `wrNumber` /\n * `wrPlural`, `wr-input-number`, `wr-statistic`, `wr-counter` — stays where it\n * was. `use()` says so once in dev mode rather than leaving it to be\n * discovered.\n *\n * @example\n * ```ts\n * const i18n = inject(WrI18n);\n * i18n.use('ru'); // switch locale\n * i18n.t('cart.checkout'); // → 'Оформить заказ'\n * i18n.t('greeting', { name: 'Ada' }); // → 'Hello, Ada!'\n * i18n.t(`types.${type}`, undefined, { fallback: type }); // → type, when no key\n *\n * effect(() => console.log(i18n.translate('hi')())); // re-runs on locale change\n * ```\n *\n * @see https://ngwr.dev/reference/services/i18n\n */\n@Service()\nexport class WrI18n {\n private readonly config = inject(WR_I18N_CONFIG);\n private readonly loader = inject(WR_I18N_LOADER);\n private readonly storage = inject(WrStorage);\n\n /**\n * Angular's own locale. Read for the dev-mode drift warning only — the\n * resolved default already folded it in through `WR_I18N_CONFIG`. @internal\n */\n private readonly localeId = inject(LOCALE_ID);\n\n /**\n * Catalogs registered via `provideWrI18nBaseCatalogs()` — the floor under the\n * loader's own catalogs, so ngwr's built-in strings survive an app that only\n * ships its own keys. @internal\n */\n private readonly baseCatalogs = inject(WR_I18N_BASE_CATALOGS, { optional: true }) ?? [];\n\n /** Per-(locale,scope) catalogs, populated by `loadCatalog`. @internal */\n private readonly catalogs = new Map<string, WrI18nCatalog>();\n\n /** Bumped after each catalog write so reactive translates recompute. @internal */\n private readonly revision = signal(0);\n\n /** In-flight load promises — dedupes parallel `t()` callers. @internal */\n private readonly inflight = new Map<string, Promise<WrI18nCatalog>>();\n\n /** Registered scopes — auto-loaded whenever the locale changes. @internal */\n private readonly scopes = new Set<string>();\n\n /** Active locale. Writes go through `use()` so storage stays in sync. */\n private readonly _locale = signal<string>(this.initialLocale());\n readonly locale: Signal<string> = this._locale.asReadonly();\n\n constructor() {\n // Eagerly load the root catalog + every registered scope for the\n // current locale. Subsequent locale changes refire the same effect.\n effect(() => {\n const lc = this._locale();\n void this.loadChain(lc, null);\n for (const sc of this.scopes) void this.loadChain(lc, sc);\n });\n }\n\n // Locale\n\n /**\n * Switch active locale. Ignored when not whitelisted.\n *\n * Text and dates — see the class docs for what a runtime switch cannot reach. The\n * dev-mode warning below is the whole reporting of that limit; without it the\n * failure is a screen showing German labels beside `1,234.5`, with nothing\n * anywhere saying why.\n */\n use(locale: string): void {\n if (!this.config.availableLocales.includes(locale)) return;\n const previous = this._locale();\n this._locale.set(locale);\n if (this.config.storageKey) this.storage.set(this.config.storageKey, locale);\n if (isDevMode() && previous !== locale) this.warnOnLocaleIdDrift(locale);\n }\n\n /** Available locales — pass-through from config. */\n available(): readonly string[] {\n return this.config.availableLocales;\n }\n\n // Scopes\n\n /**\n * Register a scope so its catalog loads alongside the root one. Idempotent.\n * Returns a promise resolving once the current locale's scope catalog is in\n * the cache — handy for feature `canActivate` guards.\n */\n registerScope(scope: string): Promise<WrI18nCatalog> {\n this.scopes.add(scope);\n const lc = this._locale();\n // Resolve on the exact tag: the promise is what a `canActivate` waits on,\n // and the base-language catalog is only ever a fallback under it.\n const exact = this.loadCatalog(lc, scope);\n void this.loadChain(lc, scope);\n return exact;\n }\n\n // Translate\n\n /**\n * Eager translate — returns the current value or the missing-handler\n * fallback. Does NOT auto-load missing catalogs; combine with the\n * reactive `translate(...)` if you want load-on-demand.\n *\n * The third argument is a scope, or `{ scope, fallback }`. With a `fallback`\n * a missing key returns it as is, not interpolated, and `missingHandler` is\n * not called: for a key built from a server value that may have no\n * translation.\n */\n t(key: string, params?: WrI18nParams, scopeOrOptions?: string | WrI18nTranslateOptions): string {\n // Read revision so callers inside computed/effect re-run on updates.\n this.revision();\n const lc = this._locale();\n const options = typeof scopeOrOptions === 'string' ? { scope: scopeOrOptions } : scopeOrOptions;\n const scope = options?.scope;\n\n const chain = localeChain(lc);\n let hit: string | null = null;\n for (const candidate of chain) {\n if (scope) hit = walk(this.catalogs.get(cacheKey(candidate, scope)) ?? null, key);\n hit ??= walk(this.catalogs.get(cacheKey(candidate, null)) ?? null, key);\n if (hit !== null) break;\n }\n // Base catalogs are the floor: consulted only once the loader's own catalogs\n // have missed, so an app's keys always win, but ngwr's built-in strings are\n // still there when the app's catalog doesn't carry them.\n hit ??= this.walkBase(chain, key);\n\n if (hit === null) {\n // Fire a background load so a future read can resolve it.\n void this.loadChain(lc, scope ?? null);\n return options?.fallback ?? this.config.missingHandler(key, lc);\n }\n return wrInterpolate(hit, params);\n }\n\n /** Reactive translate — re-evaluates on locale or catalog updates. */\n translate(key: string, params?: WrI18nParams, scopeOrOptions?: string | WrI18nTranslateOptions): Signal<string> {\n return computed(() => this.t(key, params, scopeOrOptions));\n }\n\n // Internals\n\n /**\n * Look a key up in the registered base catalogs, later contributions first so\n * a feature can shadow an earlier one.\n */\n private walkBase(chain: readonly string[], key: string): string | null {\n for (const locale of chain) {\n for (let i = this.baseCatalogs.length - 1; i >= 0; i--) {\n const hit = walk(this.baseCatalogs[i][locale] ?? null, key);\n if (hit !== null) return hit;\n }\n }\n return null;\n }\n\n private initialLocale(): string {\n if (this.config.storageKey) {\n const saved = this.storage.get<string>(this.config.storageKey);\n if (saved && this.config.availableLocales.includes(saved)) return saved;\n }\n return this.config.defaultLocale;\n }\n\n /**\n * Load a `(locale, scope)` catalog and, when the locale carries a region, the\n * bare-language one under it. Both go in the cache; `t()` reads them in that\n * order.\n */\n private loadChain(locale: string, scope: string | null): Promise<unknown> {\n return Promise.all(localeChain(locale).map(candidate => this.loadCatalog(candidate, scope)));\n }\n\n /** One warning per service, not one per switch. @internal */\n private warnedLocaleIdDrift = false;\n\n /**\n * Say once, in dev, that a runtime switch moved the text and nothing else.\n *\n * The mismatch is otherwise invisible in the way that costs the most time:\n * the catalog strings and the dates all change, which reads as \"the switch\n * worked\", and the numbers beside them are still correct-looking output in\n * the old locale. Silent when the new locale IS `LOCALE_ID`, because then nothing is\n * out of step and a warning that fires when everything agrees is one people\n * learn to ignore. Production builds drop the call entirely via `isDevMode()`\n * tree-shaking.\n */\n private warnOnLocaleIdDrift(locale: string): void {\n if (this.warnedLocaleIdDrift || locale === this.localeId) return;\n this.warnedLocaleIdDrift = true;\n // eslint-disable-next-line no-console -- dev-mode validation\n console.warn(\n `[NGWR] WrI18n.use('${locale}') switched the catalog, but LOCALE_ID is still '${this.localeId}'. ` +\n `Dates follow the switch (wrDate, wr-calendar, wr-date-picker), unless withDates({ locale }) pinned ` +\n `them. LOCALE_ID is an Angular constant, so formatted numbers do not and stay on '${this.localeId}': ` +\n `the wrNumber / wrPlural pipes, wr-input-number, wr-statistic, wr-counter, wr-pagination's total ` +\n `and wr-file-upload's sizes. Reload the app with the new LOCALE_ID to move those.`\n );\n }\n\n private loadCatalog(locale: string, scope: string | null): Promise<WrI18nCatalog> {\n const ck = cacheKey(locale, scope);\n const cached = this.catalogs.get(ck);\n if (cached) return Promise.resolve(cached);\n\n const pending = this.inflight.get(ck);\n if (pending) return pending;\n\n const stream: Observable<WrI18nCatalog> = this.loader.load(locale, scope);\n const promise = firstValueFrom(stream)\n .then(catalog => {\n this.catalogs.set(ck, catalog);\n this.revision.update(v => v + 1);\n return catalog;\n })\n .catch((err: unknown) => {\n // eslint-disable-next-line no-console -- intentional diagnostic for missing catalog\n console.warn(`[ngwr/i18n] failed to load (${locale}, ${scope ?? 'root'})`, err);\n const empty: WrI18nCatalog = {};\n this.catalogs.set(ck, empty);\n return empty;\n })\n .finally(() => {\n this.inflight.delete(ck);\n });\n\n this.inflight.set(ck, promise);\n return promise;\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Pipe, type PipeTransform, inject } from '@angular/core';\n\nimport { WrI18n } from './i18n';\nimport { type WrI18nParams, type WrI18nTranslateOptions } from './i18n-config';\n\n/**\n * Translate a key. Impure — re-evaluates on every CD so locale switches\n * and catalog loads propagate without a manual refresh.\n *\n * @example\n * ```html\n * <h1>{{ 'home.title' | wrT }}</h1>\n * <p>{{ 'greeting' | wrT: { name: user().name } }}</p>\n * <button>{{ 'forms.save' | wrT: null : 'checkout' }}</button>\n * <span>{{ 'types.' + type | wrT: null : { fallback: type } }}</span>\n * ```\n */\n// eslint-disable-next-line @angular-eslint/no-pipe-impure -- intentional: locale + catalog updates must propagate even when args are stable\n@Pipe({ name: 'wrT', pure: false })\nexport class WrTPipe implements PipeTransform {\n private readonly i18n = inject(WrI18n);\n\n transform(key: string, params?: WrI18nParams | null, scopeOrOptions?: string | WrI18nTranslateOptions): string {\n return this.i18n.t(key, params ?? undefined, scopeOrOptions);\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Directive, ElementRef, computed, effect, inject, input } from '@angular/core';\n\nimport { WrI18n } from './i18n';\nimport { type WrI18nParams } from './i18n-config';\n\n/**\n * Attribute directive that sets `textContent` of its host to the translation\n * of the bound key. Reactive — re-renders on locale + catalog changes.\n *\n * @example\n * ```html\n * <span [wrT]=\"'home.title'\"></span>\n * <span [wrT]=\"'greeting'\" [wrTParams]=\"{ name: user().name }\"></span>\n * <span [wrT]=\"'forms.save'\" wrTScope=\"checkout\"></span>\n * <span [wrT]=\"'types.' + type\" [wrTFallback]=\"type\"></span>\n * ```\n */\n@Directive({\n selector: '[wrT]',\n})\nexport class WrTDirective {\n /** Translation key. Required. */\n readonly wrT = input.required<string>();\n\n /** Interpolation params for `{{name}}` tokens. */\n readonly wrTParams = input<WrI18nParams | null>(null);\n\n /** Optional scope — scoped lookup first, then root fallback. */\n readonly wrTScope = input<string | null>(null);\n\n /** Text shown as is when the key is missing; `missingHandler` is not called. */\n readonly wrTFallback = input<string | null>(null);\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly i18n = inject(WrI18n);\n\n private readonly text = computed(() =>\n this.i18n.t(this.wrT(), this.wrTParams() ?? undefined, {\n scope: this.wrTScope() ?? undefined,\n fallback: this.wrTFallback(),\n })\n );\n\n constructor() {\n effect(() => {\n this.host.nativeElement.textContent = this.text();\n });\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type Observable, of } from 'rxjs';\n\nimport { type WrI18nCatalog } from '../i18n-config';\nimport { type WrI18nLoader } from '../i18n-loader';\n\n/** Root catalogs keyed by locale: `{ en: catalog, ru: catalog, … }`. */\nexport type WrI18nStaticCatalogs = Readonly<Record<string, WrI18nCatalog>>;\n\n/** Per-scope catalogs: `{ checkout: { en: catalog, ru: catalog }, … }`. */\nexport type WrI18nStaticScopedCatalogs = Readonly<Record<string, WrI18nStaticCatalogs>>;\n\n/**\n * Loader for catalogs already in memory (imported from JSON or generated).\n *\n * - Pass `catalogs` for the root catalog of every locale.\n * - Pass `scopes` if you ship per-feature catalogs the loader should serve\n * to `WrI18n.registerScope(name)` calls.\n *\n * Missing locale or scope resolves to `{}` — the missing-key handler then\n * decides what to render.\n */\nexport class WrI18nStaticLoader implements WrI18nLoader {\n constructor(\n private readonly catalogs: WrI18nStaticCatalogs,\n private readonly scopes: WrI18nStaticScopedCatalogs = {}\n ) {}\n\n load(locale: string, scope: string | null): Observable<WrI18nCatalog> {\n if (scope === null) return of(this.catalogs[locale] ?? {});\n return of(this.scopes[scope]?.[locale] ?? {});\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { HttpClient } from '@angular/common/http';\nimport { inject } from '@angular/core';\n\nimport { type Observable, catchError, of } from 'rxjs';\n\nimport { type WrI18nCatalog } from '../i18n-config';\nimport { type WrI18nLoader } from '../i18n-loader';\n\n/** Configuration for {@link WrI18nHttpLoader}. */\nexport interface WrI18nHttpLoaderConfig {\n /**\n * URL template. Tokens:\n * - `{locale}` — required, BCP-47 tag (e.g. `en`).\n * - `{scope}` — optional, scope name. Use the `rootPath` if you need a\n * different path entirely for the root catalog.\n *\n * @example\n * ```ts\n * { path: '/assets/i18n/{locale}.json' } // root only\n * { path: '/assets/i18n/{scope}/{locale}.json',\n * rootPath: '/assets/i18n/{locale}.json' } // root + scopes\n * ```\n */\n readonly path: string;\n /** Path template for the root catalog. Defaults to `path`. */\n readonly rootPath?: string;\n}\n\n/**\n * Loader that fetches catalogs via `HttpClient`. Failures resolve to `{}`\n * (logged once at the service layer) so a missing file never throws into\n * user code.\n */\nexport class WrI18nHttpLoader implements WrI18nLoader {\n private readonly http = inject(HttpClient);\n\n constructor(private readonly config: WrI18nHttpLoaderConfig) {}\n\n load(locale: string, scope: string | null): Observable<WrI18nCatalog> {\n const template = scope === null ? (this.config.rootPath ?? this.config.path) : this.config.path;\n const url = template.replace('{locale}', locale).replace('{scope}', scope ?? '');\n return this.http.get<WrI18nCatalog>(url).pipe(catchError(() => of<WrI18nCatalog>({})));\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport {\n ApplicationRef,\n EnvironmentInjector,\n type EnvironmentProviders,\n type Provider,\n inject,\n makeEnvironmentProviders,\n provideEnvironmentInitializer,\n} from '@angular/core';\n\nimport { WR_LIVE_LOCALE } from 'ngwr/utils';\n\nimport { WrI18n } from './i18n';\nimport { WR_I18N_BASE_CATALOGS, type WrI18nBaseCatalogs } from './i18n-base-catalogs';\nimport {\n DEFAULT_WR_I18N_CONFIG,\n WR_I18N_CONFIG,\n type WrI18nConfig,\n type WrI18nConfigResolved,\n resolveWrI18nLocales,\n} from './i18n-config';\nimport { WR_I18N_LOADER, type WrI18nLoader } from './i18n-loader';\nimport { WrI18nHttpLoader, type WrI18nHttpLoaderConfig } from './loaders/http-loader';\nimport {\n WrI18nStaticLoader,\n type WrI18nStaticCatalogs,\n type WrI18nStaticScopedCatalogs,\n} from './loaders/static-loader';\n\n/**\n * Configure {@link WrI18n}. Either pass a `loader` directly, or use the\n * `provideWrI18nHttpLoader` / `provideWrI18nStaticLoader` helpers in the\n * same providers array.\n */\nexport interface ProvideWrI18nOptions extends WrI18nConfig {\n readonly loader?: WrI18nLoader;\n}\n\n/**\n * Configure {@link WrI18n} for the application.\n *\n * Call it in the application's root providers (`bootstrapApplication` or\n * `ApplicationConfig`), together with {@link provideWrI18nBaseCatalogs} and the\n * loader. `WrI18n` is a root service: a route's `providers` or a lazy module\n * never reach it, so a locale or catalogs given there do nothing, and dev mode\n * warns. A lazy area switches the language at runtime with\n * `inject(WrI18n).use('de')`, for example in its resolver. The switch is\n * app-wide, and the locale must be in the root `availableLocales`. The area's\n * own keys load with `registerScope()`.\n */\nexport function provideWrI18n(options: ProvideWrI18nOptions = {}): EnvironmentProviders {\n const { loader, ...config } = options;\n\n const providers: (Provider | EnvironmentProviders)[] = [\n {\n provide: WR_I18N_CONFIG,\n // A factory rather than a value: `defaultLocale` falls back to `LOCALE_ID`,\n // which only an injection context can read.\n useFactory: (): WrI18nConfigResolved => ({\n ...DEFAULT_WR_I18N_CONFIG,\n ...config,\n ...resolveWrI18nLocales(config),\n }),\n },\n ];\n if (loader) providers.push({ provide: WR_I18N_LOADER, useValue: loader });\n // What `ngwr/date` formats in, so dates follow `use()` without importing this entry point.\n providers.push({ provide: WR_LIVE_LOCALE, useFactory: () => inject(WrI18n).locale });\n\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n providers.push(\n provideEnvironmentInitializer(() => {\n const here = inject(EnvironmentInjector);\n if (here === inject(ApplicationRef, { optional: true })?.injector) return;\n // An injector that lists WrI18n itself owns an instance that does read this config.\n if (here.get(WrI18n, null, { self: true })) return;\n // eslint-disable-next-line no-console -- dev-mode validation\n console.warn(\n '[NGWR] provideWrI18n() is in a route or child injector. WrI18n is a root service, so this ' +\n \"configuration is ignored. Move provideWrI18n() and the catalogs to the application's root \" +\n 'providers, and switch a lazy area with inject(WrI18n).use(locale).'\n );\n })\n );\n }\n\n return makeEnvironmentProviders(providers);\n}\n\n/**\n * Provide a static loader — catalogs already in memory.\n *\n * A loader serves only the catalog you pass it, and ngwr registers none of its\n * own. Pass only your own keys here and register ngwr's catalogs with\n * {@link provideWrI18nBaseCatalogs} — not `{ ...wrRu, ...yours }`. A spread is\n * shallow, so any namespace you share with ngwr, e.g. `common`, `form`,\n * `table`, keeps only the keys of the side spread last, and the other side's\n * keys stop resolving with nothing logged: ngwr's components fall back to their\n * English defaults, and a `wrT` read of a lost key renders the raw key under the\n * default missing handler.\n *\n * @param catalogs Root catalogs keyed by locale.\n * @param scopes Optional per-scope catalogs served to `registerScope(name)`.\n */\nexport function provideWrI18nStaticLoader(\n catalogs: WrI18nStaticCatalogs,\n scopes?: WrI18nStaticScopedCatalogs\n): Provider {\n return { provide: WR_I18N_LOADER, useValue: new WrI18nStaticLoader(catalogs, scopes) };\n}\n\n/**\n * Register catalogs consulted *underneath* the loader — this is how ngwr's own\n * built-in strings survive when you supply your own catalogs.\n *\n * A loader replaces the catalog for a locale instead of extending it, so a JSON\n * file holding only your keys leaves every built-in label on its hardcoded\n * English fallback, with nothing logged. One line fixes it, on either loader:\n *\n * @example\n * ```ts\n * import { wrRu } from 'ngwr/i18n/ru';\n *\n * providers: [\n * provideWrI18n({ defaultLocale: 'ru', availableLocales: ['ru'] }),\n * provideWrI18nBaseCatalogs({ ru: wrRu }),\n * provideWrI18nHttpLoader({ path: '/assets/i18n/{locale}.json' }),\n * ]\n * ```\n *\n * Pass only the locales you ship — the ones you leave out stay out of the\n * bundle. Your own keys always win; this is a floor, not an override.\n *\n * Use it instead of spreading `wrRu` into your own catalog, too: the lookup\n * walks these key by key after the loader's catalog misses, so a namespace both\n * define keeps both halves, where a shallow spread keeps only one.\n */\nexport function provideWrI18nBaseCatalogs(catalogs: WrI18nBaseCatalogs): Provider {\n return { provide: WR_I18N_BASE_CATALOGS, useValue: catalogs, multi: true };\n}\n\n/** Provide an HTTP loader — catalogs fetched from URLs. Requires `provideHttpClient`. */\nexport function provideWrI18nHttpLoader(config: WrI18nHttpLoaderConfig): Provider {\n return { provide: WR_I18N_LOADER, useFactory: () => new WrI18nHttpLoader(config) };\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type Signal, computed, inject, signal } from '@angular/core';\n\nimport { WrI18n, wrInterpolate } from './i18n';\nimport type { WrI18nParams } from './i18n-config';\n\n/**\n * Helper for component default text. Returns a reactive string that:\n *\n * 1. Prefers the consumer's override (an `input<string | null>()` value).\n * 2. Falls back to the i18n catalog under `key` — re-renders on locale\n * change so a switcher updates the DOM live.\n * 3. Falls back to `fallback` when no `WrI18n` is provided OR the catalog\n * is missing the key.\n *\n * Components don't need a hard dependency on `provideWrI18n` — without it,\n * the fallback is returned and everything still works.\n *\n * @example\n * ```ts\n * readonly emptyText = input<string | null>(null);\n * protected readonly empty = useI18nText(this.emptyText, 'table.empty', 'No data');\n *\n * // In template: <div>{{ empty() }}</div>\n * ```\n */\nexport function useI18nText(binding: Signal<string | null | undefined>, key: string, fallback: string): Signal<string> {\n const i18n = inject(WrI18n, { optional: true });\n if (!i18n) {\n return computed(() => {\n const v = binding();\n return v ?? fallback;\n });\n }\n\n return computed(() => {\n const v = binding();\n if (v !== null && v !== undefined && v !== '') return v;\n const translated = i18n.t(key);\n // Default missing handler returns the key itself — treat that as \"missing\"\n // and use our explicit fallback.\n return translated === key ? fallback : translated;\n });\n}\n\n/**\n * {@link useI18nText} without a binding to forward — for a built-in string the\n * component exposes no override input for. Same reactivity, same fallback\n * rules; the only difference is the missing first argument.\n *\n * It used to return a plain `string`, resolved once at injection time, and\n * that was wrong in the ordinary case rather than an edge one: `WrI18n` writes\n * every loader-backed catalog from `firstValueFrom(...).then(...)`, so even a\n * static loader serving an object literal lands a microtask AFTER the first\n * change-detection pass. Every component built in that pass read an empty\n * catalog and froze its English fallback for the life of the app — in one\n * `<wr-date-picker>` the field said \"Открыть календарь\" and the calendar\n * button beside it \"Open calendar\", off the same key.\n */\nexport function wrReadI18nText(key: string, fallback: string): Signal<string> {\n const i18n = inject(WrI18n, { optional: true });\n if (!i18n) return computed(() => fallback);\n\n return computed(() => {\n const v = i18n.t(key);\n return v === key ? fallback : v;\n });\n}\n\n/** Tiny shim — useful when the caller doesn't have an `input` to forward. */\nexport function nullSignal(): Signal<null> {\n return signal(null).asReadonly();\n}\n\n/**\n * Build a per-call formatter for parametrized labels (e.g. ARIA labels\n * that interpolate a per-row value: `\"Remove {{label}}\"`). Returns a\n * function the template calls with the params for the current item.\n *\n * The returned function:\n * - Re-resolves the i18n catalog on every call (live locale switches just\n * work — re-rendered templates pick up new strings).\n * - Falls back to the literal `fallback` template with the same\n * `{{name}}` syntax when no `WrI18n` provider is present, or when the\n * key is missing.\n *\n * Use this for labels that vary per row. For static labels, prefer\n * {@link useI18nText} or {@link wrReadI18nText}.\n *\n * @example\n * ```ts\n * protected readonly removeChipLabel = useI18nFormatter('select.removeItem', 'Remove {{label}}');\n *\n * // In template:\n * // [attr.aria-label]=\"removeChipLabel({ label: chip.label })\"\n * ```\n */\nexport function useI18nFormatter(key: string, fallback: string): (params?: WrI18nParams) => string {\n const i18n = inject(WrI18n, { optional: true });\n if (!i18n) {\n return (params?: WrI18nParams) => wrInterpolate(fallback, params);\n }\n return (params?: WrI18nParams) => {\n const v = i18n.t(key, params);\n return v === key ? wrInterpolate(fallback, params) : v;\n };\n}\n"],"mappings":";;;;;;;;;;;;AAgCA,MAAa,wBAAwB,IAAI,eAA8C,uBAAuB;;;;;;;ACiD9G,MAAa,yBAA2F;CACtG,YAAY;CACZ,iBAAgB,QAAO;AACxB;AAMD,SAAgB,qBACd,QAAoB;CAEpB,MAAM,gBAAgB,OAAO,iBAAiB,OAAO,SAAS;CAC9D,OAAO;EAAE;EAAe,kBAAkB,OAAO,oBAAoB,CAAC,aAAa;CAAC;AACtF;AAEA,MAAa,iBAAiB,IAAI,eAAqC,kBAAkB,EACvF,gBAAgB;CAAE,GAAG;CAAwB,GAAG,qBAAqB,CAAA,CAAE;AAAC,GACzE,CAAA;;;;;;;AC7DD,MAAa,iBAAiB,IAAI,eAA6B,kBAAkB;C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QAAQ,MAAM,UAAa,MAAM,IAAI,OAAO;EACtD,MAAM,aAAa,KAAK,EAAE,GAAG;EAG7B,OAAO,eAAe,MAAM,WAAW;CACzC,CAAC;AACH;AAgBA,SAAgB,eAAe,KAAa,UAAgB;CAC1D,MAAM,OAAO,OAAO,QAAQ,EAAE,UAAU,KAAI,CAAE;CAC9C,IAAI,CAAC,MAAM,OAAO,eAAe,QAAQ;CAEzC,OAAO,eAAc;EACnB,MAAM,IAAI,KAAK,EAAE,GAAG;EACpB,OAAO,MAAM,MAAM,WAAW;CAChC,CAAC;AACH;AA8BA,SAAgB,iBAAiB,KAAa,UAAgB;CAC5D,MAAM,OAAO,OAAO,QAAQ,EAAE,UAAU,KAAI,CAAE;CAC9C,IAAI,CAAC,MACH,QAAQ,WAA0B,cAAc,UAAU,MAAM;CAElE,QAAQ,WAAyB;EAC/B,MAAM,IAAI,KAAK,EAAE,KAAK,MAAM;EAC5B,OAAO,MAAM,MAAM,cAAc,UAAU,MAAM,IAAI;CACvD;AACF"}
1
+ {"version":3,"file":"ngwr-i18n.mjs","names":[],"sources":["../../../projects/lib/i18n/i18n-base-catalogs.ts","../../../projects/lib/i18n/i18n-config.ts","../../../projects/lib/i18n/i18n-loader.ts","../../../projects/lib/i18n/i18n.ts","../../../projects/lib/i18n/t.pipe.ts","../../../projects/lib/i18n/t.directive.ts","../../../projects/lib/i18n/loaders/static-loader.ts","../../../projects/lib/i18n/loaders/http-loader.ts","../../../projects/lib/i18n/provide-wr-i18n.ts","../../../projects/lib/i18n/util.ts","../../../projects/lib/i18n/http-error.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport { type WrI18nCatalog } from './i18n-config';\n\n/** Base catalogs keyed by locale, contributed by {@link provideWrI18nBaseCatalogs}. */\nexport type WrI18nBaseCatalogs = Readonly<Record<string, WrI18nCatalog>>;\n\n/**\n * Catalogs consulted *underneath* whatever the loader returned — the place for\n * ngwr's own built-in strings.\n *\n * A loader **replaces** the catalog for a locale rather than extending it, so an\n * app whose JSON holds only its own keys used to lose every built-in label to\n * its hardcoded English fallback, silently. Registering `wrRu` / `wrEn` here\n * puts them back without the app having to merge anything itself.\n *\n * `multi`, so several features can each contribute; later contributions win on\n * a key collision, and anything the loader returned still wins over all of them.\n *\n * It has to be handed in by the consumer rather than wired up inside\n * `provideWrI18n()`: the catalogs are their own entry points (`ngwr/i18n/ru`)\n * and they already import from `ngwr/i18n`, so importing them back here would\n * be a circular dependency between entry points. Passing them in also keeps\n * the locales you don't ship out of your bundle.\n */\nexport const WR_I18N_BASE_CATALOGS = new InjectionToken<readonly WrI18nBaseCatalogs[]>('WR_I18N_BASE_CATALOGS');\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken, LOCALE_ID, inject } from '@angular/core';\n\n/** Translation catalog — flat or nested record of strings. */\nexport interface WrI18nCatalog {\n readonly [key: string]: string | WrI18nCatalog;\n}\n\n/** Parameters passed to interpolation — coerced to strings via `String(v)`. */\nexport type WrI18nParams = Readonly<Record<string, unknown>>;\n\n/**\n * The third argument of `WrI18n.t()`, `WrI18n.translate()` and the `wrT` pipe,\n * where a bare string is the scope.\n */\nexport interface WrI18nTranslateOptions {\n /** Scoped lookup first, then the root catalog. */\n readonly scope?: string;\n\n /**\n * Returned as is when the key is missing: no interpolation, no\n * `missingHandler` call. `null` and `undefined` mean no fallback.\n */\n readonly fallback?: string | null;\n}\n\n/** Hook called once on every key that resolves to nothing. */\nexport type WrI18nMissingHandler = (key: string, locale: string) => string;\n\n/** User-facing config for {@link provideWrI18n}. */\nexport interface WrI18nConfig {\n /**\n * BCP-47 tag used until the user calls `use()`.\n *\n * Omitted, it is Angular's own `LOCALE_ID` — the app already states its\n * locale there, and ngwr having a second, unrelated default is how a fully\n * Russian app came to render an English calendar inside itself. See\n * {@link WrI18n} for the whole precedence.\n *\n * @default LOCALE_ID\n */\n readonly defaultLocale?: string;\n\n /**\n * Whitelisted locales — `use()` ignores anything outside this list. Omitted,\n * it is `[defaultLocale]`: it used to be a hardcoded `['en']`, so\n * `provideWrI18n({ defaultLocale: 'ru' })` produced a service whose own\n * default locale was not switchable back to.\n *\n * @default [defaultLocale]\n */\n readonly availableLocales?: readonly string[];\n\n /**\n * Storage key for persisting the active locale (via `WrStorage`).\n * Set to `null` to disable persistence. @default 'wr:i18n:locale'\n */\n readonly storageKey?: string | null;\n\n /** Called when a key is missing. Default returns the key itself. */\n readonly missingHandler?: WrI18nMissingHandler;\n}\n\n/** Resolved config — every field non-optional. @internal */\nexport interface WrI18nConfigResolved {\n readonly defaultLocale: string;\n readonly availableLocales: readonly string[];\n readonly storageKey: string | null;\n readonly missingHandler: WrI18nMissingHandler;\n}\n\n/**\n * Everything but the locale, which cannot be a constant: it is resolved from\n * `LOCALE_ID` in an injection context. @internal\n */\nexport const DEFAULT_WR_I18N_CONFIG: Omit<WrI18nConfigResolved, 'defaultLocale' | 'availableLocales'> = {\n storageKey: 'wr:i18n:locale',\n missingHandler: key => key,\n};\n\n/**\n * Resolve the locale half of the config. Callable only from an injection\n * context, because the seed is `LOCALE_ID`. @internal\n */\nexport function resolveWrI18nLocales(\n config: WrI18nConfig\n): Pick<WrI18nConfigResolved, 'defaultLocale' | 'availableLocales'> {\n const defaultLocale = config.defaultLocale ?? inject(LOCALE_ID);\n return { defaultLocale, availableLocales: config.availableLocales ?? [defaultLocale] };\n}\n\nexport const WR_I18N_CONFIG = new InjectionToken<WrI18nConfigResolved>('WR_I18N_CONFIG', {\n factory: () => ({ ...DEFAULT_WR_I18N_CONFIG, ...resolveWrI18nLocales({}) }),\n});\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport { of, type Observable } from 'rxjs';\n\nimport { type WrI18nCatalog } from './i18n-config';\n\n/**\n * Loads a catalog for a `(locale, scope)` pair. `scope` is `null` for the\n * root catalog. Implementations may return the catalog synchronously\n * (via `of(...)`) for static catalogs or asynchronously (via HTTP) for\n * lazy fetches.\n */\nexport interface WrI18nLoader {\n load(locale: string, scope: string | null): Observable<WrI18nCatalog>;\n}\n\n/**\n * The active loader.\n *\n * Defaults to one that serves an empty catalog, which is what makes\n * `provideWrI18n()` genuinely optional: every ngwr component routes its\n * built-in strings through `useI18nText` / `wrReadI18nText`, those inject\n * `WrI18n` optionally — and because `WrI18n` is `providedIn: 'root'`, an\n * optional inject still CONSTRUCTS it. Without a default here that construction\n * threw `NG0201: No provider found for WR_I18N_LOADER`, so an app that had\n * simply not configured i18n could not render `<wr-alert>` at all.\n *\n * With the empty catalog, every lookup misses, `t()` hands back the key, and\n * the helpers fall through to the component's own English default — the\n * documented no-i18n behaviour.\n */\nexport const WR_I18N_LOADER = new InjectionToken<WrI18nLoader>('WR_I18N_LOADER', {\n providedIn: 'root',\n factory: () => ({ load: () => of({}) }),\n});\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { LOCALE_ID, Service, type Signal, computed, effect, inject, isDevMode, signal } from '@angular/core';\n\nimport { type Observable, firstValueFrom } from 'rxjs';\n\nimport { WrStorage } from 'ngwr/storage';\n\nimport { WR_I18N_BASE_CATALOGS } from './i18n-base-catalogs';\nimport { WR_I18N_CONFIG, type WrI18nCatalog, type WrI18nParams, type WrI18nTranslateOptions } from './i18n-config';\nimport { WR_I18N_LOADER } from './i18n-loader';\n\n/** Cache key shape: `<locale>::<scope|''>`. @internal */\nfunction cacheKey(locale: string, scope: string | null): string {\n return `${locale}::${scope ?? ''}`;\n}\n\n/**\n * A locale and the language under it: `'ru-RU'` gives `['ru-RU', 'ru']`.\n *\n * Every lookup and every load walks this, so a catalog registered as `ru`\n * answers an app running `ru-RU`. Without it the two spellings are unrelated\n * strings, and the miss is silent — `t()` returns the key, `useI18nText` reads\n * that as \"missing\" and serves the English fallback, so a fully translated app\n * renders English with nothing logged. It only ever truncates: an `en` lookup\n * never reaches an `en-US` catalog, because a language is not a region.\n *\n * @internal\n */\nfunction localeChain(locale: string): readonly string[] {\n const dash = locale.indexOf('-');\n return dash > 0 ? [locale, locale.slice(0, dash)] : [locale];\n}\n\n/** Walk a dotted path through a catalog tree. Returns string | null. @internal */\nfunction walk(cat: WrI18nCatalog | null, key: string): string | null {\n if (!cat) return null;\n let node: string | WrI18nCatalog | undefined = cat;\n for (const part of key.split('.')) {\n if (node === undefined || typeof node === 'string') return null;\n node = node[part];\n }\n return typeof node === 'string' ? node : null;\n}\n\n/**\n * `{{name}}` interpolation. Missing params resolve to `''`. Exported so\n * helpers in `util.ts` can interpolate the fallback template when no\n * `WrI18n` provider is wired up.\n *\n * @internal\n */\nexport function wrInterpolate(template: string, params: WrI18nParams | undefined): string {\n if (!params) return template;\n return template.replace(/\\{\\{\\s*([\\w.-]+)\\s*\\}\\}/g, (_match, name: string) => {\n const v = params[name];\n if (v === undefined || v === null) return '';\n if (typeof v === 'string') return v;\n if (typeof v === 'number' || typeof v === 'boolean') return String(v);\n try {\n return JSON.stringify(v);\n } catch {\n return '';\n }\n });\n}\n\n/**\n * Reactive i18n service. Holds:\n *\n * - the active locale as a `Signal<string>`\n * - per-`(locale, scope)` catalogs in a `Map` (loaded once, then cached)\n * - a per-locale signal counter so every `translate()` reading the signal\n * re-evaluates the moment a new catalog finishes loading\n *\n * Translations are looked up scope-first then root, per locale, and the locale\n * itself is tried as the full tag before the bare language underneath it — so\n * an app running `ru-RU` resolves against a catalog registered as `ru`, and a\n * regional catalog is never shadowed by a scope in the base language. For an\n * app that spells its locale one way, which is every app that existed before\n * the chain, the order is exactly what it always was.\n *\n * ## Which locale wins\n *\n * ngwr has three locale inputs and they used to be three unrelated answers — an\n * app that set `LOCALE_ID: 'ru-RU'` correctly still rendered an English\n * calendar, because the date token defaulted to `navigator.language`. The\n * precedence is now stated, highest first:\n *\n * 1. **A subsystem's own explicit option.** `withDates({ locale })` pins\n * dates; `provideWrI18n({ defaultLocale })` pins the catalog. The most\n * specific statement wins, because it can only have been deliberate.\n * 2. **`WrI18n.locale()` — the runtime value.** The only one of the three that\n * can change without a reload, so it is what a language switcher writes.\n * With `provideWrI18n()` in the app, dates are written in it.\n * 3. **`LOCALE_ID`.** Angular's app-wide constant, and the seed for both of the\n * above when neither was given. One statement, one answer.\n * 4. `'en-US'`, which is what `LOCALE_ID` itself falls back to.\n *\n * `navigator.language` is deliberately NOT in that list. It is the browser's\n * preference, not the application's, and reading it made prerendered output and\n * the hydrated page disagree.\n *\n * **What a runtime switch reaches, and what it does not.** `use()` repaints\n * every catalog string, and every date: the date adapter, and so\n * `wr-calendar`, `wr-date-picker`, `wrDate` and `wr-date-stamp`, formats in\n * this locale unless `withDates({ locale })` pinned another. It does not move\n * `LOCALE_ID`, which is a constant, so anything keyed on it — `wrNumber` /\n * `wrPlural`, `wr-input-number`, `wr-statistic`, `wr-counter` — stays where it\n * was. `use()` says so once in dev mode rather than leaving it to be\n * discovered.\n *\n * @example\n * ```ts\n * const i18n = inject(WrI18n);\n * i18n.use('ru'); // switch locale\n * i18n.t('cart.checkout'); // → 'Оформить заказ'\n * i18n.t('greeting', { name: 'Ada' }); // → 'Hello, Ada!'\n * i18n.t(`types.${type}`, undefined, { fallback: type }); // → type, when no key\n *\n * effect(() => console.log(i18n.translate('hi')())); // re-runs on locale change\n * ```\n *\n * @see https://ngwr.dev/reference/services/i18n\n */\n@Service()\nexport class WrI18n {\n private readonly config = inject(WR_I18N_CONFIG);\n private readonly loader = inject(WR_I18N_LOADER);\n private readonly storage = inject(WrStorage);\n\n /**\n * Angular's own locale. Read for the dev-mode drift warning only — the\n * resolved default already folded it in through `WR_I18N_CONFIG`. @internal\n */\n private readonly localeId = inject(LOCALE_ID);\n\n /**\n * Catalogs registered via `provideWrI18nBaseCatalogs()` — the floor under the\n * loader's own catalogs, so ngwr's built-in strings survive an app that only\n * ships its own keys. @internal\n */\n private readonly baseCatalogs = inject(WR_I18N_BASE_CATALOGS, { optional: true }) ?? [];\n\n /** Per-(locale,scope) catalogs, populated by `loadCatalog`. @internal */\n private readonly catalogs = new Map<string, WrI18nCatalog>();\n\n /** Bumped after each catalog write so reactive translates recompute. @internal */\n private readonly revision = signal(0);\n\n /** In-flight load promises — dedupes parallel `t()` callers. @internal */\n private readonly inflight = new Map<string, Promise<WrI18nCatalog>>();\n\n /** Keys whose last load failed: `t()` does not retry them, `use()` and `registerScope()` do. @internal */\n private readonly failed = new Set<string>();\n\n /** Registered scopes — auto-loaded whenever the locale changes. @internal */\n private readonly scopes = new Set<string>();\n\n /** Active locale. Writes go through `use()` so storage stays in sync. */\n private readonly _locale = signal<string>(this.initialLocale());\n readonly locale: Signal<string> = this._locale.asReadonly();\n\n constructor() {\n // Eagerly load the root catalog + every registered scope for the\n // current locale. Subsequent locale changes refire the same effect.\n effect(() => {\n const lc = this._locale();\n void this.loadChain(lc, null);\n for (const sc of this.scopes) void this.loadChain(lc, sc);\n });\n }\n\n // Locale\n\n /**\n * Switch active locale. Ignored when not whitelisted.\n *\n * Text and dates — see the class docs for what a runtime switch cannot reach. The\n * dev-mode warning below is the whole reporting of that limit; without it the\n * failure is a screen showing German labels beside `1,234.5`, with nothing\n * anywhere saying why.\n */\n use(locale: string): void {\n if (!this.config.availableLocales.includes(locale)) return;\n const previous = this._locale();\n this._locale.set(locale);\n if (this.config.storageKey) this.storage.set(this.config.storageKey, locale);\n void this.loadChain(locale, null);\n for (const sc of this.scopes) void this.loadChain(locale, sc);\n if (isDevMode() && previous !== locale) this.warnOnLocaleIdDrift(locale);\n }\n\n /** Available locales — pass-through from config. */\n available(): readonly string[] {\n return this.config.availableLocales;\n }\n\n // Scopes\n\n /**\n * Register a scope so its catalog loads alongside the root one. Idempotent.\n * Returns a promise resolving once the current locale's scope catalog is in\n * the cache — handy for feature `canActivate` guards.\n */\n registerScope(scope: string): Promise<WrI18nCatalog> {\n this.scopes.add(scope);\n const lc = this._locale();\n // Resolve on the exact tag: the promise is what a `canActivate` waits on,\n // and the base-language catalog is only ever a fallback under it.\n const exact = this.loadCatalog(lc, scope);\n void this.loadChain(lc, scope);\n return exact;\n }\n\n // Translate\n\n /**\n * Eager translate — returns the current value or the missing-handler\n * fallback. Does NOT auto-load missing catalogs; combine with the\n * reactive `translate(...)` if you want load-on-demand.\n *\n * The third argument is a scope, or `{ scope, fallback }`. With a `fallback`\n * a missing key returns it as is, not interpolated, and `missingHandler` is\n * not called: for a key built from a server value that may have no\n * translation.\n */\n t(key: string, params?: WrI18nParams, scopeOrOptions?: string | WrI18nTranslateOptions): string {\n // Read revision so callers inside computed/effect re-run on updates.\n this.revision();\n const lc = this._locale();\n const options = typeof scopeOrOptions === 'string' ? { scope: scopeOrOptions } : scopeOrOptions;\n const scope = options?.scope;\n\n const chain = localeChain(lc);\n let hit: string | null = null;\n for (const candidate of chain) {\n if (scope) hit = walk(this.catalogs.get(cacheKey(candidate, scope)) ?? null, key);\n hit ??= walk(this.catalogs.get(cacheKey(candidate, null)) ?? null, key);\n if (hit !== null) break;\n }\n // Base catalogs are the floor: consulted only once the loader's own catalogs\n // have missed, so an app's keys always win, but ngwr's built-in strings are\n // still there when the app's catalog doesn't carry them.\n hit ??= this.walkBase(chain, key);\n\n if (hit === null) {\n // Fire a background load so a future read can resolve it.\n void this.loadChain(lc, scope ?? null, true);\n return options?.fallback ?? this.config.missingHandler(key, lc);\n }\n return wrInterpolate(hit, params);\n }\n\n /** Reactive translate — re-evaluates on locale or catalog updates. */\n translate(key: string, params?: WrI18nParams, scopeOrOptions?: string | WrI18nTranslateOptions): Signal<string> {\n return computed(() => this.t(key, params, scopeOrOptions));\n }\n\n // Internals\n\n /**\n * Look a key up in the registered base catalogs, later contributions first so\n * a feature can shadow an earlier one.\n */\n private walkBase(chain: readonly string[], key: string): string | null {\n for (const locale of chain) {\n for (let i = this.baseCatalogs.length - 1; i >= 0; i--) {\n const hit = walk(this.baseCatalogs[i][locale] ?? null, key);\n if (hit !== null) return hit;\n }\n }\n return null;\n }\n\n private initialLocale(): string {\n if (this.config.storageKey) {\n const saved = this.storage.get<string>(this.config.storageKey);\n if (saved && this.config.availableLocales.includes(saved)) return saved;\n }\n return this.config.defaultLocale;\n }\n\n /**\n * Load a `(locale, scope)` catalog and, when the locale carries a region, the\n * bare-language one under it. Both go in the cache; `t()` reads them in that\n * order.\n */\n private loadChain(locale: string, scope: string | null, auto = false): Promise<unknown> {\n return Promise.all(localeChain(locale).map(candidate => this.loadCatalog(candidate, scope, auto)));\n }\n\n /** One warning per service, not one per switch. @internal */\n private warnedLocaleIdDrift = false;\n\n /**\n * Say once, in dev, that a runtime switch moved the text and nothing else.\n *\n * The mismatch is otherwise invisible in the way that costs the most time:\n * the catalog strings and the dates all change, which reads as \"the switch\n * worked\", and the numbers beside them are still correct-looking output in\n * the old locale. Silent when the new locale IS `LOCALE_ID`, because then nothing is\n * out of step and a warning that fires when everything agrees is one people\n * learn to ignore. Production builds drop the call entirely via `isDevMode()`\n * tree-shaking.\n */\n private warnOnLocaleIdDrift(locale: string): void {\n if (this.warnedLocaleIdDrift || locale === this.localeId) return;\n this.warnedLocaleIdDrift = true;\n // eslint-disable-next-line no-console -- dev-mode validation\n console.warn(\n `[NGWR] WrI18n.use('${locale}') switched the catalog, but LOCALE_ID is still '${this.localeId}'. ` +\n `Dates follow the switch (wrDate, wr-calendar, wr-date-picker), unless withDates({ locale }) pinned ` +\n `them. LOCALE_ID is an Angular constant, so formatted numbers do not and stay on '${this.localeId}': ` +\n `the wrNumber / wrPlural pipes, wr-input-number, wr-statistic, wr-counter, wr-pagination's total ` +\n `and wr-file-upload's sizes. Reload the app with the new LOCALE_ID to move those.`\n );\n }\n\n private loadCatalog(locale: string, scope: string | null, auto = false): Promise<WrI18nCatalog> {\n const ck = cacheKey(locale, scope);\n const cached = this.catalogs.get(ck);\n if (cached) return Promise.resolve(cached);\n if (auto && this.failed.has(ck)) return Promise.resolve({});\n\n const pending = this.inflight.get(ck);\n if (pending) return pending;\n\n const stream: Observable<WrI18nCatalog> = this.loader.load(locale, scope);\n const promise = firstValueFrom(stream)\n .then(catalog => {\n this.failed.delete(ck);\n this.catalogs.set(ck, catalog);\n this.revision.update(v => v + 1);\n return catalog;\n })\n .catch((err: unknown) => {\n // eslint-disable-next-line no-console -- intentional diagnostic for missing catalog\n console.warn(`[ngwr/i18n] failed to load (${locale}, ${scope ?? 'root'})`, err);\n this.failed.add(ck);\n const empty: WrI18nCatalog = {};\n return empty;\n })\n .finally(() => {\n this.inflight.delete(ck);\n });\n\n this.inflight.set(ck, promise);\n return promise;\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Pipe, type PipeTransform, inject } from '@angular/core';\n\nimport { WrI18n } from './i18n';\nimport { type WrI18nParams, type WrI18nTranslateOptions } from './i18n-config';\n\n/**\n * Translate a key. Impure — re-evaluates on every CD so locale switches\n * and catalog loads propagate without a manual refresh.\n *\n * @example\n * ```html\n * <h1>{{ 'home.title' | wrT }}</h1>\n * <p>{{ 'greeting' | wrT: { name: user().name } }}</p>\n * <button>{{ 'forms.save' | wrT: null : 'checkout' }}</button>\n * <span>{{ 'types.' + type | wrT: null : { fallback: type } }}</span>\n * ```\n */\n// eslint-disable-next-line @angular-eslint/no-pipe-impure -- intentional: locale + catalog updates must propagate even when args are stable\n@Pipe({ name: 'wrT', pure: false })\nexport class WrTPipe implements PipeTransform {\n private readonly i18n = inject(WrI18n);\n\n transform(key: string, params?: WrI18nParams | null, scopeOrOptions?: string | WrI18nTranslateOptions): string {\n return this.i18n.t(key, params ?? undefined, scopeOrOptions);\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Directive, ElementRef, computed, effect, inject, input } from '@angular/core';\n\nimport { WrI18n } from './i18n';\nimport { type WrI18nParams } from './i18n-config';\n\n/**\n * Attribute directive that sets `textContent` of its host to the translation\n * of the bound key. Reactive — re-renders on locale + catalog changes.\n *\n * @example\n * ```html\n * <span [wrT]=\"'home.title'\"></span>\n * <span [wrT]=\"'greeting'\" [wrTParams]=\"{ name: user().name }\"></span>\n * <span [wrT]=\"'forms.save'\" wrTScope=\"checkout\"></span>\n * <span [wrT]=\"'types.' + type\" [wrTFallback]=\"type\"></span>\n * ```\n */\n@Directive({\n selector: '[wrT]',\n})\nexport class WrTDirective {\n /** Translation key. Required. */\n readonly wrT = input.required<string>();\n\n /** Interpolation params for `{{name}}` tokens. */\n readonly wrTParams = input<WrI18nParams | null>(null);\n\n /** Optional scope — scoped lookup first, then root fallback. */\n readonly wrTScope = input<string | null>(null);\n\n /** Text shown as is when the key is missing; `missingHandler` is not called. */\n readonly wrTFallback = input<string | null>(null);\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly i18n = inject(WrI18n);\n\n private readonly text = computed(() =>\n this.i18n.t(this.wrT(), this.wrTParams() ?? undefined, {\n scope: this.wrTScope() ?? undefined,\n fallback: this.wrTFallback(),\n })\n );\n\n constructor() {\n effect(() => {\n this.host.nativeElement.textContent = this.text();\n });\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type Observable, of } from 'rxjs';\n\nimport { type WrI18nCatalog } from '../i18n-config';\nimport { type WrI18nLoader } from '../i18n-loader';\n\n/** Root catalogs keyed by locale: `{ en: catalog, ru: catalog, … }`. */\nexport type WrI18nStaticCatalogs = Readonly<Record<string, WrI18nCatalog>>;\n\n/** Per-scope catalogs: `{ checkout: { en: catalog, ru: catalog }, … }`. */\nexport type WrI18nStaticScopedCatalogs = Readonly<Record<string, WrI18nStaticCatalogs>>;\n\n/**\n * Loader for catalogs already in memory (imported from JSON or generated).\n *\n * - Pass `catalogs` for the root catalog of every locale.\n * - Pass `scopes` if you ship per-feature catalogs the loader should serve\n * to `WrI18n.registerScope(name)` calls.\n *\n * Missing locale or scope resolves to `{}` — the missing-key handler then\n * decides what to render.\n */\nexport class WrI18nStaticLoader implements WrI18nLoader {\n constructor(\n private readonly catalogs: WrI18nStaticCatalogs,\n private readonly scopes: WrI18nStaticScopedCatalogs = {}\n ) {}\n\n load(locale: string, scope: string | null): Observable<WrI18nCatalog> {\n if (scope === null) return of(this.catalogs[locale] ?? {});\n return of(this.scopes[scope]?.[locale] ?? {});\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { HttpClient } from '@angular/common/http';\nimport { inject } from '@angular/core';\n\nimport { type Observable } from 'rxjs';\n\nimport { type WrI18nCatalog } from '../i18n-config';\nimport { type WrI18nLoader } from '../i18n-loader';\n\n/** Configuration for {@link WrI18nHttpLoader}. */\nexport interface WrI18nHttpLoaderConfig {\n /**\n * URL template. Tokens:\n * - `{locale}` — required, BCP-47 tag (e.g. `en`).\n * - `{scope}` — optional, scope name. Use the `rootPath` if you need a\n * different path entirely for the root catalog.\n *\n * @example\n * ```ts\n * { path: '/assets/i18n/{locale}.json' } // root only\n * { path: '/assets/i18n/{scope}/{locale}.json',\n * rootPath: '/assets/i18n/{locale}.json' } // root + scopes\n * ```\n */\n readonly path: string;\n /** Path template for the root catalog. Defaults to `path`. */\n readonly rootPath?: string;\n}\n\n/**\n * Loader that fetches catalogs via `HttpClient`. A failure errors the stream;\n * the service logs it, serves the key and retries on the next `use()`.\n */\nexport class WrI18nHttpLoader implements WrI18nLoader {\n private readonly http = inject(HttpClient);\n\n constructor(private readonly config: WrI18nHttpLoaderConfig) {}\n\n load(locale: string, scope: string | null): Observable<WrI18nCatalog> {\n const template = scope === null ? (this.config.rootPath ?? this.config.path) : this.config.path;\n const url = template.replaceAll('{locale}', locale).replaceAll('{scope}', scope ?? '');\n return this.http.get<WrI18nCatalog>(url);\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport {\n ApplicationRef,\n EnvironmentInjector,\n type EnvironmentProviders,\n type Provider,\n inject,\n makeEnvironmentProviders,\n provideEnvironmentInitializer,\n} from '@angular/core';\n\nimport { WR_LIVE_LOCALE } from 'ngwr/utils';\n\nimport { WrI18n } from './i18n';\nimport { WR_I18N_BASE_CATALOGS, type WrI18nBaseCatalogs } from './i18n-base-catalogs';\nimport {\n DEFAULT_WR_I18N_CONFIG,\n WR_I18N_CONFIG,\n type WrI18nConfig,\n type WrI18nConfigResolved,\n resolveWrI18nLocales,\n} from './i18n-config';\nimport { WR_I18N_LOADER, type WrI18nLoader } from './i18n-loader';\nimport { WrI18nHttpLoader, type WrI18nHttpLoaderConfig } from './loaders/http-loader';\nimport {\n WrI18nStaticLoader,\n type WrI18nStaticCatalogs,\n type WrI18nStaticScopedCatalogs,\n} from './loaders/static-loader';\n\n/**\n * Configure {@link WrI18n}. Either pass a `loader` directly, or use the\n * `provideWrI18nHttpLoader` / `provideWrI18nStaticLoader` helpers in the\n * same providers array.\n */\nexport interface ProvideWrI18nOptions extends WrI18nConfig {\n readonly loader?: WrI18nLoader;\n}\n\n/**\n * Configure {@link WrI18n} for the application.\n *\n * Call it in the application's root providers (`bootstrapApplication` or\n * `ApplicationConfig`), together with {@link provideWrI18nBaseCatalogs} and the\n * loader. `WrI18n` is a root service: a route's `providers` or a lazy module\n * never reach it, so a locale or catalogs given there do nothing, and dev mode\n * warns. A lazy area switches the language at runtime with\n * `inject(WrI18n).use('de')`, for example in its resolver. The switch is\n * app-wide, and the locale must be in the root `availableLocales`. The area's\n * own keys load with `registerScope()`.\n */\nexport function provideWrI18n(options: ProvideWrI18nOptions = {}): EnvironmentProviders {\n const { loader, ...config } = options;\n\n const providers: (Provider | EnvironmentProviders)[] = [\n {\n provide: WR_I18N_CONFIG,\n // A factory rather than a value: `defaultLocale` falls back to `LOCALE_ID`,\n // which only an injection context can read.\n useFactory: (): WrI18nConfigResolved => ({\n ...DEFAULT_WR_I18N_CONFIG,\n ...config,\n ...resolveWrI18nLocales(config),\n }),\n },\n ];\n if (loader) providers.push({ provide: WR_I18N_LOADER, useValue: loader });\n // What `ngwr/date` formats in, so dates follow `use()` without importing this entry point.\n providers.push({ provide: WR_LIVE_LOCALE, useFactory: () => inject(WrI18n).locale });\n\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n providers.push(\n provideEnvironmentInitializer(() => {\n const here = inject(EnvironmentInjector);\n if (here === inject(ApplicationRef, { optional: true })?.injector) return;\n // An injector that lists WrI18n itself owns an instance that does read this config.\n if (here.get(WrI18n, null, { self: true })) return;\n // eslint-disable-next-line no-console -- dev-mode validation\n console.warn(\n '[NGWR] provideWrI18n() is in a route or child injector. WrI18n is a root service, so this ' +\n \"configuration is ignored. Move provideWrI18n() and the catalogs to the application's root \" +\n 'providers, and switch a lazy area with inject(WrI18n).use(locale).'\n );\n })\n );\n }\n\n return makeEnvironmentProviders(providers);\n}\n\n/**\n * Provide a static loader — catalogs already in memory.\n *\n * A loader serves only the catalog you pass it, and ngwr registers none of its\n * own. Pass only your own keys here and register ngwr's catalogs with\n * {@link provideWrI18nBaseCatalogs} — not `{ ...wrRu, ...yours }`. A spread is\n * shallow, so any namespace you share with ngwr, e.g. `common`, `form`,\n * `table`, keeps only the keys of the side spread last, and the other side's\n * keys stop resolving with nothing logged: ngwr's components fall back to their\n * English defaults, and a `wrT` read of a lost key renders the raw key under the\n * default missing handler.\n *\n * @param catalogs Root catalogs keyed by locale.\n * @param scopes Optional per-scope catalogs served to `registerScope(name)`.\n */\nexport function provideWrI18nStaticLoader(\n catalogs: WrI18nStaticCatalogs,\n scopes?: WrI18nStaticScopedCatalogs\n): Provider {\n return { provide: WR_I18N_LOADER, useValue: new WrI18nStaticLoader(catalogs, scopes) };\n}\n\n/**\n * Register catalogs consulted *underneath* the loader — this is how ngwr's own\n * built-in strings survive when you supply your own catalogs.\n *\n * A loader replaces the catalog for a locale instead of extending it, so a JSON\n * file holding only your keys leaves every built-in label on its hardcoded\n * English fallback, with nothing logged. One line fixes it, on either loader:\n *\n * @example\n * ```ts\n * import { wrRu } from 'ngwr/i18n/ru';\n *\n * providers: [\n * provideWrI18n({ defaultLocale: 'ru', availableLocales: ['ru'] }),\n * provideWrI18nBaseCatalogs({ ru: wrRu }),\n * provideWrI18nHttpLoader({ path: '/assets/i18n/{locale}.json' }),\n * ]\n * ```\n *\n * Pass only the locales you ship — the ones you leave out stay out of the\n * bundle. Your own keys always win; this is a floor, not an override.\n *\n * Use it instead of spreading `wrRu` into your own catalog, too: the lookup\n * walks these key by key after the loader's catalog misses, so a namespace both\n * define keeps both halves, where a shallow spread keeps only one.\n */\nexport function provideWrI18nBaseCatalogs(catalogs: WrI18nBaseCatalogs): Provider {\n return { provide: WR_I18N_BASE_CATALOGS, useValue: catalogs, multi: true };\n}\n\n/** Provide an HTTP loader — catalogs fetched from URLs. Requires `provideHttpClient`. */\nexport function provideWrI18nHttpLoader(config: WrI18nHttpLoaderConfig): Provider {\n return { provide: WR_I18N_LOADER, useFactory: () => new WrI18nHttpLoader(config) };\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type Signal, computed, inject, signal } from '@angular/core';\n\nimport { WrI18n, wrInterpolate } from './i18n';\nimport type { WrI18nParams } from './i18n-config';\n\n/**\n * Helper for component default text. Returns a reactive string that:\n *\n * 1. Prefers the consumer's override (an `input<string | null>()` value).\n * 2. Falls back to the i18n catalog under `key` — re-renders on locale\n * change so a switcher updates the DOM live.\n * 3. Falls back to `fallback` when no `WrI18n` is provided OR the catalog\n * is missing the key.\n *\n * Components don't need a hard dependency on `provideWrI18n` — without it,\n * the fallback is returned and everything still works.\n *\n * @example\n * ```ts\n * readonly emptyText = input<string | null>(null);\n * protected readonly empty = useI18nText(this.emptyText, 'table.empty', 'No data');\n *\n * // In template: <div>{{ empty() }}</div>\n * ```\n */\nexport function useI18nText(binding: Signal<string | null | undefined>, key: string, fallback: string): Signal<string> {\n const i18n = inject(WrI18n, { optional: true });\n if (!i18n) {\n return computed(() => {\n const v = binding();\n return v ?? fallback;\n });\n }\n\n return computed(() => {\n const v = binding();\n if (v !== null && v !== undefined && v !== '') return v;\n const translated = i18n.t(key);\n // Default missing handler returns the key itself — treat that as \"missing\"\n // and use our explicit fallback.\n return translated === key ? fallback : translated;\n });\n}\n\n/**\n * {@link useI18nText} without a binding to forward — for a built-in string the\n * component exposes no override input for. Same reactivity, same fallback\n * rules; the only difference is the missing first argument.\n *\n * It used to return a plain `string`, resolved once at injection time, and\n * that was wrong in the ordinary case rather than an edge one: `WrI18n` writes\n * every loader-backed catalog from `firstValueFrom(...).then(...)`, so even a\n * static loader serving an object literal lands a microtask AFTER the first\n * change-detection pass. Every component built in that pass read an empty\n * catalog and froze its English fallback for the life of the app — in one\n * `<wr-date-picker>` the field said \"Открыть календарь\" and the calendar\n * button beside it \"Open calendar\", off the same key.\n */\nexport function wrReadI18nText(key: string, fallback: string): Signal<string> {\n const i18n = inject(WrI18n, { optional: true });\n if (!i18n) return computed(() => fallback);\n\n return computed(() => {\n const v = i18n.t(key);\n return v === key ? fallback : v;\n });\n}\n\n/** Tiny shim — useful when the caller doesn't have an `input` to forward. */\nexport function nullSignal(): Signal<null> {\n return signal(null).asReadonly();\n}\n\n/**\n * Build a per-call formatter for parametrized labels (e.g. ARIA labels\n * that interpolate a per-row value: `\"Remove {{label}}\"`). Returns a\n * function the template calls with the params for the current item.\n *\n * The returned function:\n * - Re-resolves the i18n catalog on every call (live locale switches just\n * work — re-rendered templates pick up new strings).\n * - Falls back to the literal `fallback` template with the same\n * `{{name}}` syntax when no `WrI18n` provider is present, or when the\n * key is missing.\n *\n * Use this for labels that vary per row. For static labels, prefer\n * {@link useI18nText} or {@link wrReadI18nText}.\n *\n * @example\n * ```ts\n * protected readonly removeChipLabel = useI18nFormatter('select.removeItem', 'Remove {{label}}');\n *\n * // In template:\n * // [attr.aria-label]=\"removeChipLabel({ label: chip.label })\"\n * ```\n */\nexport function useI18nFormatter(key: string, fallback: string): (params?: WrI18nParams) => string {\n const i18n = inject(WrI18n, { optional: true });\n if (!i18n) {\n return (params?: WrI18nParams) => wrInterpolate(fallback, params);\n }\n return (params?: WrI18nParams) => {\n const v = i18n.t(key, params);\n return v === key ? wrInterpolate(fallback, params) : v;\n };\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type Injector, inject } from '@angular/core';\n\nimport { WrI18n, wrInterpolate } from './i18n';\n\n/** The English catalog's `httpError`, for an app with no catalog registered. */\nconst FALLBACK: Readonly<Record<string, string>> = {\n network: 'No connection to the server. Check your network and try again.',\n 400: 'The server did not accept the data. Check the fields.',\n 401: 'Your session has ended. Sign in again.',\n 403: 'You do not have permission for this action.',\n 404: 'Not found. It may have been deleted.',\n 409: 'This conflicts with existing data. Refresh the page and try again.',\n 413: 'The data is too large to send.',\n 422: 'Some of the data is not valid. Check the fields.',\n 429: 'Too many requests. Try again in a moment.',\n 503: 'The server is unavailable. Try again in a minute.',\n '4xx': 'The request was refused. Error code: {{status}}.',\n '5xx': 'The server failed. Try again later. Error code: {{status}}.',\n unknown: 'Something went wrong. Try again later.',\n};\n\n/** Most specific first. */\nfunction catalogKeys(status: number | null): readonly string[] {\n if (status === null) return ['unknown'];\n if (status === 0) return ['network'];\n if (status >= 400 && status < 500) return [String(status), '4xx', 'unknown'];\n if (status >= 500 && status < 600) return [String(status), '5xx', 'unknown'];\n return [String(status), 'unknown'];\n}\n\nfunction serverMessage(error: unknown): string | null {\n const body = (error as { error?: unknown } | null | undefined)?.error;\n if (typeof body === 'string') {\n const text = body.trim();\n // A proxy answers with an HTML page, which is a string body too.\n return text === '' || text.startsWith('<') ? null : text;\n }\n const message = (body as { message?: unknown } | null | undefined)?.message;\n return typeof message === 'string' && message.trim() !== '' ? message.trim() : null;\n}\n\n/** A screen's own sentence for one status: the text, or a function of the error. */\nexport type WrHttpErrorOverride = string | ((error: unknown) => string);\n\n/** Options of {@link wrHttpErrorText}. */\nexport interface WrHttpErrorTextOptions {\n /** The screen's own sentence per status, `0` being a network failure. Wins over everything else. */\n readonly overrides?: Readonly<Partial<Record<number, WrHttpErrorOverride>>>;\n /**\n * Prefer the sentence the server put in the body: `error.error.message`, or\n * a body that is a plain string. For an API that writes its errors for the\n * person at the screen.\n * @default false\n */\n readonly serverMessage?: boolean;\n /** Where to read `WrI18n` from when the call is outside an injection context, such as a `catch`. */\n readonly injector?: Injector;\n}\n\n/**\n * The HTTP status of a failed request: of an `HttpErrorResponse`, a `Response`\n * or anything else carrying a numeric `status`. `0` is a request nothing\n * answered (offline, CORS, a dropped connection); `null` is a value that is not\n * an HTTP error at all.\n *\n * @example\n * ```ts\n * if (wrHttpStatus(error) === 401) void router.navigate(['/login']);\n * ```\n *\n * @see https://ngwr.dev/reference/utils/wr-http-error-text\n */\nexport function wrHttpStatus(error: unknown): number | null {\n const status = (error as { status?: unknown } | null | undefined)?.status;\n return typeof status === 'number' && Number.isInteger(status) && status >= 0 ? status : null;\n}\n\n/**\n * A sentence for a failed request, in the active language. Highest first:\n *\n * 1. `overrides[status]`, the screen's own wording.\n * 2. With `serverMessage`, the sentence in the response body.\n * 3. The catalog: `httpError.<status>`, then `httpError.4xx` / `httpError.5xx`\n * (both take `{{status}}`), `httpError.network` for status `0`, and\n * `httpError.unknown` for the rest. An app's own catalog wins over ngwr's,\n * and English is the floor when neither has the key.\n *\n * Call it in an injection context, or pass `injector` from a `catch` or a\n * callback.\n *\n * @example\n * ```ts\n * private readonly injector = inject(Injector);\n *\n * try {\n * await this.api.save(order);\n * } catch (error) {\n * this.toast.danger(\n * wrHttpErrorText(error, { injector: this.injector, overrides: { 409: 'This name is taken.' } })\n * );\n * }\n * ```\n *\n * @see https://ngwr.dev/reference/utils/wr-http-error-text\n */\nexport function wrHttpErrorText(error: unknown, options: WrHttpErrorTextOptions = {}): string {\n const status = wrHttpStatus(error);\n\n const override = status === null ? undefined : options.overrides?.[status];\n if (override !== undefined) return typeof override === 'function' ? override(error) : override;\n\n if (options.serverMessage && status !== null) {\n const said = serverMessage(error);\n if (said !== null) return said;\n }\n\n const i18n = options.injector ? options.injector.get(WrI18n, null) : inject(WrI18n, { optional: true });\n const keys = catalogKeys(status);\n const params = { status };\n\n for (const key of keys) {\n const hit = i18n?.t(`httpError.${key}`, params, { fallback: '' });\n if (hit) return hit;\n }\n for (const key of keys) {\n if (key in FALLBACK) return wrInterpolate(FALLBACK[key], params);\n }\n return FALLBACK['unknown'];\n}\n"],"mappings":";;;;;;;;;;;;AAgCA,MAAa,wBAAwB,IAAI,eAA8C,uBAAuB;;;;;;;ACiD9G,MAAa,yBAA2F;CACtG,YAAY;CACZ,iBAAgB,QAAO;AACxB;AAMD,SAAgB,qBACd,QAAoB;CAEpB,MAAM,gBAAgB,OAAO,iBAAiB,OAAO,SAAS;CAC9D,OAAO;EAAE;EAAe,kBAAkB,OAAO,oBAAoB,CAAC,aAAa;CAAC;AACtF;AAEA,MAAa,iBAAiB,IAAI,eAAqC,kBAAkB,EACvF,gBAAgB;CAAE,GAAG;CAAwB,GAAG,qBAAqB,CAAA,CAAE;AAAC,GACzE,CAAA;;;;;;;AC7DD,MAAa,iBAAiB,IAAI,eAA6B,kBAAkB;CAC/E,YAAY;CACZ,gBAAgB,EAAE,YAAY,GAAG,CAAA,CAAE,EAAC;AACrC,CAAA;;;;;;;ACvBD,SAAS,SAAS,QAAgB,OAAoB;CACpD,OAAO,GAAG,OAAM,IAAK,SAAS;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,SAAS,UAAU;EAC5B,MAAM,OAAO,KAAK,KAAI;EAEtB,OAAO,SAAS,MAAM,KAAK,WAAW,GAAG,IAAI,OAAO;CACtD;CACA,MAAM,UAAW,MAAmD;CACpE,OAAO,OAAO,YAAY,YAAY,QAAQ,KAAI,MAAO,KAAK,QAAQ,KAAI,IAAK;AACjF;AAiCA,SAAgB,aAAa,OAAc;CACzC,MAAM,SAAU,OAAmD;CACnE,OAAO,OAAO,WAAW,YAAY,OAAO,UAAU,MAAM,KAAK,UAAU,IAAI,SAAS;AAC1F;AA8BA,SAAgB,gBAAgB,OAAgB,UAAkC,CAAA,GAAE;CAClF,MAAM,SAAS,aAAa,KAAK;CAEjC,MAAM,WAAW,WAAW,OAAO,SAAY,QAAQ,YAAY;CACnE,IAAI,aAAa,QAAW,OAAO,OAAO,aAAa,aAAa,SAAS,KAAK,IAAI;CAEtF,IAAI,QAAQ,iBAAiB,WAAW,MAAM;EAC5C,MAAM,OAAO,cAAc,KAAK;EAChC,IAAI,SAAS,MAAM,OAAO;CAC5B;CAEA,MAAM,OAAO,QAAQ,WAAW,QAAQ,SAAS,IAAI,QAAQ,IAAI,IAAI,OAAO,QAAQ,EAAE,UAAU,KAAI,CAAE;CACtG,MAAM,OAAO,YAAY,MAAM;CAC/B,MAAM,SAAS,EAAE,OAAM;CAEvB,KAAK,MAAM,OAAO,MAAM;EACtB,MAAM,MAAM,MAAM,EAAE,aAAa,OAAO,QAAQ,EAAE,UAAU,GAAE,CAAE;EAChE,IAAI,KAAK,OAAO;CAClB;CACA,KAAK,MAAM,OAAO,MAChB,IAAI,OAAO,UAAU,OAAO,cAAc,SAAS,MAAM,MAAM;CAEjE,OAAO,SAAS;AAClB"}
@@ -31,7 +31,7 @@ var WrIconRegistry = class WrIconRegistry {
31
31
  }
32
32
  static ɵfac = i0.ɵɵngDeclareFactory({
33
33
  minVersion: "12.0.0",
34
- version: "22.2.6",
34
+ version: "22.3.0",
35
35
  ngImport: i0,
36
36
  type: WrIconRegistry,
37
37
  deps: [],
@@ -39,14 +39,14 @@ var WrIconRegistry = class WrIconRegistry {
39
39
  });
40
40
  static ɵprov = i0.ɵɵngDeclareInjectable({
41
41
  minVersion: "12.0.0",
42
- version: "22.2.6",
42
+ version: "22.3.0",
43
43
  ngImport: i0,
44
44
  type: WrIconRegistry
45
45
  });
46
46
  };
47
47
  i0.ɵɵngDeclareClassMetadata({
48
48
  minVersion: "12.0.0",
49
- version: "22.2.6",
49
+ version: "22.3.0",
50
50
  ngImport: i0,
51
51
  type: WrIconRegistry,
52
52
  decorators: [{ type: Injectable }]
@@ -318,7 +318,7 @@ var WrIcon = class WrIcon {
318
318
  static reported = /* @__PURE__ */ new WeakSet();
319
319
  static ɵfac = i0.ɵɵngDeclareFactory({
320
320
  minVersion: "12.0.0",
321
- version: "22.2.6",
321
+ version: "22.3.0",
322
322
  ngImport: i0,
323
323
  type: WrIcon,
324
324
  deps: [],
@@ -326,7 +326,7 @@ var WrIcon = class WrIcon {
326
326
  });
327
327
  static ɵcmp = i0.ɵɵngDeclareComponent({
328
328
  minVersion: "17.1.0",
329
- version: "22.2.6",
329
+ version: "22.3.0",
330
330
  type: WrIcon,
331
331
  isStandalone: true,
332
332
  selector: "wr-icon",
@@ -349,7 +349,7 @@ var WrIcon = class WrIcon {
349
349
  };
350
350
  i0.ɵɵngDeclareClassMetadata({
351
351
  minVersion: "12.0.0",
352
- version: "22.2.6",
352
+ version: "22.3.0",
353
353
  ngImport: i0,
354
354
  type: WrIcon,
355
355
  decorators: [{
@@ -1,7 +1,7 @@
1
1
  import * as i0 from "@angular/core";
2
2
  import { Component, DestroyRef, ViewEncapsulation, computed, effect, inject, input, isDevMode, output, signal, viewChild } from "@angular/core";
3
3
  import { coerceNumberProperty } from "@angular/cdk/coercion";
4
- import { wrCheckStyles, wrClamp, wrRandomId } from "ngwr/utils";
4
+ import { wrCheckStyles, wrClamp, wrFileNameForType, wrRandomId } from "ngwr/utils";
5
5
  import { useI18nText } from "ngwr/i18n";
6
6
  /**
7
7
  * @license
@@ -376,6 +376,10 @@ var WrImageCropper = class WrImageCropper {
376
376
  }, type, quality);
377
377
  });
378
378
  }
379
+ async toFile(name, type = this.outputType(), quality = this.outputQuality()) {
380
+ const blob = await this.toBlob(type, quality);
381
+ return new File([blob], wrFileNameForType(name, blob.type), { type: blob.type });
382
+ }
379
383
  toDataUrl(type = this.outputType(), quality = this.outputQuality()) {
380
384
  return this.toCanvas().toDataURL(type, quality);
381
385
  }
@@ -415,7 +419,7 @@ var WrImageCropper = class WrImageCropper {
415
419
  }
416
420
  static ɵfac = i0.ɵɵngDeclareFactory({
417
421
  minVersion: "12.0.0",
418
- version: "22.2.6",
422
+ version: "22.3.0",
419
423
  ngImport: i0,
420
424
  type: WrImageCropper,
421
425
  deps: [],
@@ -423,7 +427,7 @@ var WrImageCropper = class WrImageCropper {
423
427
  });
424
428
  static ɵcmp = i0.ɵɵngDeclareComponent({
425
429
  minVersion: "17.0.0",
426
- version: "22.2.6",
430
+ version: "22.3.0",
427
431
  type: WrImageCropper,
428
432
  isStandalone: true,
429
433
  selector: "wr-image-cropper",
@@ -500,7 +504,7 @@ var WrImageCropper = class WrImageCropper {
500
504
  };
501
505
  i0.ɵɵngDeclareClassMetadata({
502
506
  minVersion: "12.0.0",
503
- version: "22.2.6",
507
+ version: "22.3.0",
504
508
  ngImport: i0,
505
509
  type: WrImageCropper,
506
510
  decorators: [{
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-image-cropper.mjs","names":[],"sources":["../../../projects/lib/image-cropper/image-cropper.ts","../../../projects/lib/image-cropper/image-cropper.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceNumberProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n DestroyRef,\n type ElementRef,\n ViewEncapsulation,\n computed,\n effect,\n inject,\n input,\n isDevMode,\n output,\n signal,\n viewChild,\n} from '@angular/core';\n\nimport { useI18nText } from 'ngwr/i18n';\nimport { wrClamp, wrRandomId, wrCheckStyles } from 'ngwr/utils';\n\nimport type { WrCropHandle, WrCropRect, WrImageCropperStatus, WrImageLoadError, WrImageOutputType } from './types';\n\n/**\n * `[maxOutputSize]`'s transform. Anything that is not a positive, finite number —\n * `null`, an empty attribute, `0`, a typo — means \"no cap\" rather than a 1px export:\n * a bad config should cost resolution nobody asked to lose, not the whole image.\n */\nfunction coerceMaxOutputSize(value: unknown): number | null {\n if (value === null || value === undefined || value === '') return null;\n const n = coerceNumberProperty(value, Number.NaN);\n return Number.isFinite(n) && n > 0 ? n : null;\n}\n\n/**\n * Stands in for the consumer input `useI18nText` expects. None of this\n * component's three strings has a `*Label` input behind it — the catalog is the\n * override channel — so they share one empty override.\n */\nconst NO_OVERRIDE = signal<string | null>(null).asReadonly();\n\n/** Keyboard step in display pixels, and what Shift promotes it to. */\nconst KEY_STEP = 1;\nconst KEY_STEP_COARSE = 10;\n\ninterface RectPx {\n x: number;\n y: number;\n w: number;\n h: number;\n}\n\ninterface SizePx {\n w: number;\n h: number;\n}\n\n/** Distances, in CSS pixels, past each side of a box. */\ninterface SidesPx {\n left: number;\n top: number;\n right: number;\n bottom: number;\n}\n\nconst NO_SIDES: SidesPx = { left: 0, top: 0, right: 0, bottom: 0 };\n\n/**\n * The rect a resize gesture produces: a pure function of the rect the gesture started\n * from and the TOTAL pointer offset, so the same pointer position always gives the same\n * rect however the pointer got there.\n *\n * The anchor never moves. It is the edge or corner opposite the handle — for `se` the\n * top-left corner, for `e` the west edge's line. The old version clamped `x`, `y`, `w`\n * and `h` one at a time after deriving the second axis, so once the derived axis ran\n * into the image edge the rect slid AWAY from its anchor and, past the far bound, off\n * the image entirely.\n *\n * With a ratio the size is the largest along that ratio which fits from the anchor —\n * the smaller of the width-limited and height-limited sizes — and no smaller than both\n * minimums allow. Where the image cannot fit the minimum from this anchor, the bound\n * wins: a crop past the edge of the image is worse than one under the minimum.\n *\n * An edge handle with a ratio also sizes the axis it does not drive, and that axis has\n * the image's WHOLE extent to grow into: the rect stays centred on its old midline where\n * it can and slides along that axis only as far as it must to stay on the image. Capping\n * the size at twice the distance from the midline to the nearer side instead would leave\n * a square crop resting against the top edge unable to widen at all.\n */\nfunction resizeFrom(\n r: RectPx,\n handle: WrCropHandle,\n dx: number,\n dy: number,\n bounds: SizePx,\n min: SizePx,\n ratio: number | null\n): RectPx {\n const east = handle.includes('e');\n const west = handle.includes('w');\n const south = handle.includes('s');\n const north = handle.includes('n');\n const right = r.x + r.w;\n const bottom = r.y + r.h;\n\n if (!ratio || ratio <= 0) {\n let { x, y, w, h } = r;\n if (east) w = wrClamp(r.w + dx, min.w, bounds.w - r.x);\n if (west) {\n w = wrClamp(r.w - dx, min.w, right);\n x = right - w;\n }\n if (south) h = wrClamp(r.h + dy, min.h, bounds.h - r.y);\n if (north) {\n h = wrClamp(r.h - dy, min.h, bottom);\n y = bottom - h;\n }\n return { x, y, w, h };\n }\n\n // Room from the anchor to the image edge on each axis the handle drives; the whole\n // image on an axis it does not.\n const roomW = east ? bounds.w - r.x : west ? right : bounds.w;\n const roomH = south ? bounds.h - r.y : north ? bottom : bounds.h;\n // Corners follow the horizontal delta, as they always have; `n` / `s` the vertical one.\n const wanted = east ? r.w + dx : west ? r.w - dx : (south ? r.h + dy : r.h - dy) * ratio;\n const w = wrClamp(wanted, Math.max(min.w, min.h * ratio), Math.min(roomW, roomH * ratio));\n const h = w / ratio;\n\n return {\n x: east ? r.x : west ? right - w : wrClamp(r.x + r.w / 2 - w / 2, 0, bounds.w - w),\n y: south ? r.y : north ? bottom - h : wrClamp(r.y + r.h / 2 - h / 2, 0, bounds.h - h),\n w,\n h,\n };\n}\n\n/**\n * Image crop UI. Pass `[src]` (URL, `File`, or `Blob`); the user drags\n * the crop window or any of its eight handles. Optionally lock the crop\n * to a fixed `[aspectRatio]`.\n *\n * The crop window is also the one tab stop: arrow keys move it, Alt with an\n * arrow key resizes it, and Shift makes either step ten pixels instead of one.\n *\n * `(cropped)` fires after each drag end — or each run of arrow keys — with a\n * freshly-rendered `Blob` of the cropped region. For one-off reads use\n * `toBlob()` / `toDataUrl()`.\n *\n * A source the browser cannot decode fires `(loadError)` once, sets `status()` to\n * `'failed'` and puts `wr-image-cropper--failed` on the host. The component renders\n * no message of its own for it — what went wrong and what to do next is the host's\n * to say.\n *\n * The image is requested with `crossorigin=\"anonymous\"`, because a canvas will not\n * export pixels from another origin otherwise. A URL on another origin therefore has\n * to be served with `Access-Control-Allow-Origin`; one that is not fails to load and\n * fires `(loadError)`, where it used to show and then refuse every export.\n *\n * @example\n * ```html\n * <wr-image-cropper\n * [src]=\"file\"\n * [aspectRatio]=\"1\"\n * (cropped)=\"onBlob($event)\"\n * (loadError)=\"onUnreadable($event)\"\n * />\n * ```\n *\n * @see https://ngwr.dev/reference/components/image-cropper\n */\n@Component({\n selector: 'wr-image-cropper',\n templateUrl: './image-cropper.html',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-image-cropper',\n '[class.wr-image-cropper--failed]': \"status() === 'failed'\",\n },\n})\nexport class WrImageCropper {\n /** Image source — URL string, `File`, or `Blob`. */\n readonly src = input<string | File | Blob | null>(null);\n\n /** Aspect ratio (width / height). `null` = free. @default null */\n readonly aspectRatio = input<number | null>(null);\n\n /** Minimum crop width in display pixels. @default 32 */\n readonly minWidth = input(32, { transform: (v: unknown): number => Math.max(8, coerceNumberProperty(v, 32)) });\n\n /** Minimum crop height in display pixels. @default 32 */\n readonly minHeight = input(32, { transform: (v: unknown): number => Math.max(8, coerceNumberProperty(v, 32)) });\n\n /** Default output type for `(cropped)`. @default 'image/png' */\n readonly outputType = input<WrImageOutputType>('image/png');\n\n /** JPEG / WebP quality for `(cropped)` in [0, 1]. @default 0.92 */\n readonly outputQuality = input(0.92);\n\n /**\n * Longest side of the exported image, in pixels — for `(cropped)`, `toBlob()` and\n * `toDataUrl()` alike. A crop larger than this is scaled down to fit, keeping its\n * aspect ratio; a smaller one is exported as it is, never upscaled. The crop itself\n * — `cropRect()`, in source pixels — is not affected. `null` (or anything that is\n * not a positive number) exports at the source image's own resolution.\n * @default null\n */\n readonly maxOutputSize = input<number | null>(null, { transform: coerceMaxOutputSize });\n\n /** Emits a Blob after each drag end. */\n readonly cropped = output<Blob>();\n\n /**\n * Fires once when the browser cannot decode the current `src` — a format it does\n * not support, a broken file, a URL that fails. Nothing is rendered for it; show\n * your own message. A new `src` clears the failure.\n */\n readonly loadError = output<WrImageLoadError>();\n\n protected readonly imgEl = viewChild.required<ElementRef<HTMLImageElement>>('img');\n\n /** Resolved object URL for `src` (so File / Blob render in `<img>`). */\n protected readonly emptyText = useI18nText(NO_OVERRIDE, 'imageCropper.empty', 'No image');\n\n /** Accessible name of the crop window — the component's only tab stop. */\n protected readonly resolvedWindowLabel = useI18nText(NO_OVERRIDE, 'imageCropper.window', 'Crop region');\n\n /** The key model, referenced by the window's `aria-describedby`. */\n protected readonly resolvedKeyHelp = useI18nText(\n NO_OVERRIDE,\n 'imageCropper.keyHelp',\n 'Arrow keys move the crop. Hold Alt with an arrow key to resize it, and Shift for larger steps. ' +\n 'The crop is announced as left, top, width and height in image pixels.'\n );\n\n /** Id linking the crop window to the help text. Random rather than counted:\n * the crop UI only exists after a real image load, so it never prerenders. */\n protected readonly helpId = wrRandomId('wr-image-cropper-help');\n\n /** Live-region text — written by the keyboard path only (see `onWindowKeydown`). */\n protected readonly announcement = signal<string>('');\n\n protected readonly objectUrl = signal<string | null>(null);\n\n /** Previous object URL we created — kept off-signal so the resolve\n * effect doesn't depend on its own writes (which would loop). */\n private previousObjectUrl: string | null = null;\n\n /** Natural (source) pixel dimensions. */\n protected readonly natural = signal<{ w: number; h: number }>({ w: 0, h: 0 });\n\n /** Display (rendered) pixel dimensions. */\n protected readonly display = signal<{ w: number; h: number }>({ w: 0, h: 0 });\n\n /** Crop rect in display coordinates. */\n protected readonly cropDisplay = signal<RectPx>({ x: 0, y: 0, w: 0, h: 0 });\n\n /** Watches the rendered image box — see `watchResize`. */\n private resizeObserver: ResizeObserver | null = null;\n\n /** Currently active drag handle. */\n private active: WrCropHandle | null = null;\n private startPointer: { x: number; y: number } = { x: 0, y: 0 };\n private startRect: RectPx = { x: 0, y: 0, w: 0, h: 0 };\n\n /** The element the live drag set pointer capture on, so the end releases that one. */\n private captureTarget: HTMLElement | null = null;\n\n /** The pointer the live drag belongs to. Every other pointer's events are ignored. */\n private pointerId: number | null = null;\n\n /** How far past each side of the crop the live resize was pressed — see `onPointerMove`. */\n private overhang: SidesPx = NO_SIDES;\n\n private readonly destroyRef = inject(DestroyRef);\n\n private readonly statusState = signal<WrImageCropperStatus>('empty');\n\n /**\n * Where the source stands: `'empty'`, `'loading'`, `'loaded'` or `'failed'`. Reset\n * to `'loading'` (or `'empty'`) whenever `src` changes, so a failure never outlives\n * the source that caused it.\n */\n readonly status = this.statusState.asReadonly();\n\n /** Resolved crop rect in natural (source) pixel coordinates. */\n readonly cropRect = computed<WrCropRect>(() => {\n const display = this.display();\n const natural = this.natural();\n const c = this.cropDisplay();\n if (display.w === 0 || display.h === 0) return { x: 0, y: 0, width: 0, height: 0 };\n const sx = natural.w / display.w;\n const sy = natural.h / display.h;\n return {\n x: Math.round(c.x * sx),\n y: Math.round(c.y * sy),\n width: Math.round(c.w * sx),\n height: Math.round(c.h * sy),\n };\n });\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('image-cropper');\n // Resolve the source into a usable URL the <img> can render.\n // We only read `src()` here — `previousObjectUrl` is a plain field, so\n // writing to `objectUrl` doesn't re-trigger this effect (and hang the\n // tab on file upload).\n effect(() => {\n const src = this.src();\n if (this.previousObjectUrl) {\n URL.revokeObjectURL(this.previousObjectUrl);\n this.previousObjectUrl = null;\n }\n // The crop is measured against the image that WAS showing, and `cropRect` is a\n // public signal a consumer can read at any moment. Left in place it kept\n // reporting a rect scaled to the previous image for the whole gap between a new\n // `src` and its load event — long enough to crop the wrong thing.\n this.resetGeometry();\n if (!src) {\n this.objectUrl.set(null);\n this.statusState.set('empty');\n return;\n }\n // A new source starts over: a failure belongs to the source that caused it, and\n // left in place it would mark a perfectly good next image as broken until the\n // browser answered for that one too.\n this.statusState.set('loading');\n if (typeof src === 'string') {\n this.objectUrl.set(src);\n } else {\n const url = URL.createObjectURL(src);\n this.previousObjectUrl = url;\n this.objectUrl.set(url);\n }\n });\n\n this.destroyRef.onDestroy(() => {\n if (this.previousObjectUrl) URL.revokeObjectURL(this.previousObjectUrl);\n this.resizeObserver?.disconnect();\n });\n }\n\n // Image load\n\n /**\n * Back to \"nothing measured yet\", which is also what an absent `src` means.\n *\n * `display` is the field that gates everything downstream — the crop UI renders on\n * `display().w > 0` and `cropRect` returns zeros without it — so it is the only one\n * a test can observe. The other two are reset for coherence: the resize observer\n * below also writes `display`, and left alone they would resurrect a crop measured\n * against the previous image (which is why `onResize` refuses to run on a zeroed\n * `display` — see there).\n */\n private resetGeometry(): void {\n this.natural.set({ w: 0, h: 0 });\n this.display.set({ w: 0, h: 0 });\n this.cropDisplay.set({ x: 0, y: 0, w: 0, h: 0 });\n }\n\n protected onImageLoad(): void {\n const img = this.imgEl().nativeElement;\n const rect = img.getBoundingClientRect();\n const display = { w: rect.width, h: rect.height };\n // Some SVGs and odd images report zero natural dimensions — fall back\n // to the rendered size so the crop math stays well-defined.\n const natural = {\n w: img.naturalWidth || display.w,\n h: img.naturalHeight || display.h,\n };\n this.statusState.set('loaded');\n this.natural.set(natural);\n this.display.set(display);\n this.cropDisplay.set(this.initialCrop(display));\n this.watchResize(img);\n }\n\n /**\n * The `<img>` could not decode its source.\n *\n * Before this handler existed a failed decode left the component exactly as it\n * looks while loading — an image with no size, no crop window, nothing emitted —\n * so a host had no way to tell \"still decoding\" from \"never going to\", and a user\n * who picked a `.heic` the browser cannot read saw an empty box and no reason.\n *\n * Once per source: `status` is reset by a new `src` and by nothing else, so a\n * second `error` for the same source says nothing new and is not re-emitted.\n */\n protected onImageError(): void {\n const url = this.objectUrl();\n if (!url || this.statusState() === 'failed') return;\n this.statusState.set('failed');\n this.resetGeometry();\n\n const src = this.src();\n const isBlob = typeof src !== 'string' && src !== null;\n this.loadError.emit({\n url,\n name: typeof File !== 'undefined' && src instanceof File ? src.name : null,\n type: isBlob ? src.type : null,\n size: isBlob ? src.size : null,\n });\n }\n\n /**\n * Keep `display` on the box the image is actually rendered at.\n *\n * The stylesheet sizes the image responsively — `max-width: 100%`,\n * `max-height: 70dvh`, `height: auto` — so the single measurement taken in the\n * `(load)` handler stops being true as soon as the container or the viewport\n * changes. Everything the user sees and touches is in DISPLAY pixels: the crop\n * window's inline `left` / `top` / `width` / `height`, the backdrop cut-out, and\n * the bounds `applyMove` / `applyResize` clamp against. Measured once, a narrowed\n * window leaves the crop painted past the edge of the image and draggable off it.\n *\n * Re-observed per load rather than once, because a new `src` may mount a new\n * `<img>`; the old observation would then be on a detached element.\n */\n private watchResize(el: HTMLImageElement): void {\n if (typeof ResizeObserver === 'undefined') return;\n this.resizeObserver?.disconnect();\n // Re-read the same way `onImageLoad` does rather than take the entry's\n // `contentRect`, so the two measurements can't disagree about the box.\n const ro = new ResizeObserver(() => this.onResize(el));\n ro.observe(el);\n this.resizeObserver = ro;\n }\n\n /**\n * Rescale the crop by however much the image did, so the user keeps the region\n * they picked instead of having it re-centred: `cropRect()` — the source-pixel\n * value a consumer acts on — comes out the same across the resize.\n */\n private onResize(el: HTMLImageElement): void {\n const previous = this.display();\n // Nothing measured yet, or measured and then dropped by `resetGeometry` while a\n // new `src` loads. There is no crop to carry over, and the load will measure.\n if (previous.w === 0 || previous.h === 0) return;\n const rect = el.getBoundingClientRect();\n // A hidden image (a closed tab, `display: none`) reports zeros. Scaling by that\n // would collapse the crop and there would be nothing to scale back from, so hold\n // the last real box until it is shown again.\n if (rect.width === 0 || rect.height === 0) return;\n if (rect.width === previous.w && rect.height === previous.h) return;\n\n const sx = rect.width / previous.w;\n const sy = rect.height / previous.h;\n const c = this.cropDisplay();\n this.display.set({ w: rect.width, h: rect.height });\n this.cropDisplay.set({ x: c.x * sx, y: c.y * sy, w: c.w * sx, h: c.h * sy });\n }\n\n /** Compute a sensible initial crop — centered, respecting aspectRatio. */\n private initialCrop(display: { w: number; h: number }): RectPx {\n const ratio = this.aspectRatio();\n let w = display.w * 0.6;\n let h = display.h * 0.6;\n if (ratio && ratio > 0) {\n const candidate = w / ratio;\n if (candidate > h) w = h * ratio;\n else h = w / ratio;\n }\n return {\n x: (display.w - w) / 2,\n y: (display.h - h) / 2,\n w,\n h,\n };\n }\n\n // Drag handlers\n\n protected readonly handles: readonly WrCropHandle[] = ['n', 's', 'e', 'w', 'ne', 'nw', 'se', 'sw'];\n\n protected onPointerDown(handle: WrCropHandle, event: PointerEvent): void {\n // Any pointerdown used to start a drag, so the right button moved the crop window and\n // a second finger could take over a drag already in progress.\n if (event.button !== 0 || !event.isPrimary) return;\n event.preventDefault();\n event.stopPropagation();\n this.active = handle;\n this.pointerId = event.pointerId;\n this.startPointer = { x: event.clientX, y: event.clientY };\n this.startRect = { ...this.cropDisplay() };\n this.captureTarget = event.currentTarget as HTMLElement;\n this.captureTarget.setPointerCapture(event.pointerId);\n this.overhang = handle === 'move' ? NO_SIDES : this.pastCrop(event);\n }\n\n /**\n * A resize ENDS when the pointer leaves the image, exactly as `pointerup` would end it:\n * the move that carried it out is applied — clamped to the image like any other — and\n * then the drag is over. Nothing after that resumes it or changes the crop, pointer\n * back over the image or not, until a new `pointerdown`. A move drag is not affected:\n * its size is fixed, so it simply rests against the edge.\n *\n * The move that leaves is applied rather than dropped because pointer moves are\n * SAMPLES. Dropped, a quick drag toward a corner would stop wherever its last sample\n * inside happened to fall — a single move from a handle to past the image would change\n * nothing at all — and even a slow one would stop a fraction of a pixel short of the\n * edge. A drag that leaves across one edge still ends there: heading for a corner at a\n * slant that crosses the bottom first, the crop's right edge stays where it was then.\n *\n * \"The image\" is the `<img>`'s own box — the bounds `applyMove` / `applyResize` clamp\n * the crop to — with its edges counting as inside, since the crop may reach them. The\n * box is re-measured on every move and compared with `clientX` / `clientY`: both are\n * viewport coordinates, so a scroll mid-drag cannot put them out of step. The moves\n * outside reach this handler at all only because the drag holds pointer capture.\n *\n * One allowance, fixed at `pointerdown`: the box is widened on each side by however far\n * past that side of the CROP the press landed — at most as far as the pressed handle\n * reaches past it. Half of an edge handle, and three quarters of a corner handle, lies\n * outside the crop, so a press there already has the pointer ahead of the edge it drags.\n * Measured without the allowance, that pointer would leave the image while the crop was\n * still short of the image's edge by the same distance, with nothing able to close the\n * gap; and a handle resting on the image's edge, pressed on its outer part, would begin\n * its drag already outside. A press on a handle's inner part widens nothing.\n */\n protected onPointerMove(event: PointerEvent): void {\n if (!this.active || event.pointerId !== this.pointerId) return;\n const dx = event.clientX - this.startPointer.x;\n const dy = event.clientY - this.startPointer.y;\n if (this.active === 'move') {\n this.applyMove(dx, dy);\n return;\n }\n this.applyResize(this.active, dx, dy);\n if (!this.withinImage(event)) this.onPointerUp(event);\n }\n\n /**\n * Ends the drag — for `pointerup`, `pointercancel`, a capture lost to something else,\n * and a resize whose pointer left the image. Once per drag: the capture released here\n * fires `lostpointercapture` afterwards, and by then there is nothing left to end.\n *\n * Only for the pointer that started it. A second finger is refused a drag of its own at\n * `pointerdown`, but its moves and its lifting reach these handlers all the same, and\n * would otherwise drive or end the first finger's drag.\n */\n protected onPointerUp(event: PointerEvent): void {\n if (!this.active || event.pointerId !== this.pointerId) return;\n const target = this.captureTarget;\n this.active = null;\n this.pointerId = null;\n this.captureTarget = null;\n this.overhang = NO_SIDES;\n // Asked first: a capture that is already gone has nothing to release, and releasing\n // one for a pointer that is no longer active throws.\n if (target?.hasPointerCapture(event.pointerId)) target.releasePointerCapture(event.pointerId);\n void this.emitCropped();\n }\n\n /** How far past each side of the crop window the pointer is, in CSS pixels. */\n private pastCrop(event: PointerEvent): SidesPx {\n const box = this.imgEl().nativeElement.getBoundingClientRect();\n const c = this.startRect;\n return {\n left: Math.max(0, box.left + c.x - event.clientX),\n top: Math.max(0, box.top + c.y - event.clientY),\n right: Math.max(0, event.clientX - (box.left + c.x + c.w)),\n bottom: Math.max(0, event.clientY - (box.top + c.y + c.h)),\n };\n }\n\n /** Whether the pointer is on the image, edges and the press's `overhang` included. */\n private withinImage(event: PointerEvent): boolean {\n const box = this.imgEl().nativeElement.getBoundingClientRect();\n const o = this.overhang;\n return (\n event.clientX >= box.left - o.left &&\n event.clientX <= box.right + o.right &&\n event.clientY >= box.top - o.top &&\n event.clientY <= box.bottom + o.bottom\n );\n }\n\n // Keyboard\n\n /** Whether a key has moved the crop since the last `keyup`. */\n private keyboardDirty = false;\n\n /**\n * The component's only keyboard path. Arrow keys move the crop window; Alt\n * with an arrow key resizes it from the east / south edge; Shift makes either\n * one ten display pixels instead of one — the coarse modifier `wr-slider`,\n * `wr-knob` and `wr-splitter` all use, which is why Alt and not Shift carries\n * the mode switch here.\n *\n * Nothing mirrors under `dir=\"rtl\"`: the image is not flipped and the window\n * is placed with a physical `left`, so ArrowLeft moves the crop visually left\n * in both directions.\n *\n * Both branches go through `applyMove` / `applyResize`, so the `aspectRatio`\n * lock, the `minWidth` / `minHeight` floors and the canvas bounds hold for a\n * keystroke exactly as they do for a drag. Those two measure from `startRect`\n * rather than from the live rect, so it is re-seeded per keystroke — a 1px\n * delta against the rect from the first press would make a held arrow stall\n * after one pixel instead of accumulating.\n */\n protected onWindowKeydown(event: KeyboardEvent): void {\n const step = event.shiftKey ? KEY_STEP_COARSE : KEY_STEP;\n let dx = 0;\n let dy = 0;\n switch (event.key) {\n case 'ArrowLeft':\n dx = -step;\n break;\n case 'ArrowRight':\n dx = step;\n break;\n case 'ArrowUp':\n dy = -step;\n break;\n case 'ArrowDown':\n dy = step;\n break;\n default:\n return;\n }\n\n event.preventDefault();\n this.startRect = { ...this.cropDisplay() };\n if (event.altKey) this.applyResize(dx !== 0 ? 'e' : 's', dx, dy);\n else this.applyMove(dx, dy);\n\n this.keyboardDirty = true;\n const c = this.cropRect();\n // Bare numbers on purpose — `resolvedKeyHelp` has already told the reader\n // what the four are, and a sentence here would be a translated string.\n this.announcement.set(`${c.x}, ${c.y}, ${c.width} × ${c.height}`);\n }\n\n /**\n * Emit once per gesture, not once per keystroke. A held arrow repeats its\n * keydown many times a second and each `emitCropped` renders a canvas and\n * encodes a Blob; `keyup` fires once when the run ends, which is the keyboard's\n * equivalent of the `pointerup` the drag path emits on.\n */\n protected onWindowKeyup(): void {\n if (!this.keyboardDirty) return;\n this.keyboardDirty = false;\n void this.emitCropped();\n }\n\n private applyMove(dx: number, dy: number): void {\n const display = this.display();\n const r = this.startRect;\n const next = {\n x: wrClamp(r.x + dx, 0, display.w - r.w),\n y: wrClamp(r.y + dy, 0, display.h - r.h),\n w: r.w,\n h: r.h,\n };\n this.cropDisplay.set(next);\n }\n\n private applyResize(handle: WrCropHandle, dx: number, dy: number): void {\n const min = { w: this.minWidth(), h: this.minHeight() };\n this.cropDisplay.set(resizeFrom(this.startRect, handle, dx, dy, this.display(), min, this.aspectRatio()));\n }\n\n // Public API\n\n /**\n * Render the current crop as a Blob. Rejects while `status()` is anything but\n * `'loaded'`, since there is no image to draw.\n */\n async toBlob(type: WrImageOutputType = this.outputType(), quality: number = this.outputQuality()): Promise<Blob> {\n const canvas = this.toCanvas();\n return new Promise<Blob>((resolve, reject) => {\n canvas.toBlob(\n blob => {\n if (blob) resolve(blob);\n else reject(new Error('toBlob returned null'));\n },\n type,\n quality\n );\n });\n }\n\n /**\n * Render the current crop as a data URL. Throws while `status()` is anything but\n * `'loaded'`, since there is no image to draw.\n */\n toDataUrl(type: WrImageOutputType = this.outputType(), quality: number = this.outputQuality()): string {\n return this.toCanvas().toDataURL(type, quality);\n }\n\n /** Re-emit the crop without waiting for a drag (e.g. after a programmatic change). */\n async refresh(): Promise<void> {\n await this.emitCropped();\n }\n\n // Internals\n\n /**\n * The exported image's pixel size: the crop in source pixels, scaled down so its\n * longer side fits `maxOutputSize`. `Math.min(1, …)` is the never-upscale rule — a\n * crop already inside the cap keeps its own size, which is also the whole of the\n * uncapped path.\n */\n private outputSize(c: WrCropRect): { width: number; height: number } {\n const cap = this.maxOutputSize();\n const longest = Math.max(c.width, c.height);\n const scale = cap === null || longest === 0 ? 1 : Math.min(1, cap / longest);\n return {\n width: Math.max(1, Math.round(c.width * scale)),\n height: Math.max(1, Math.round(c.height * scale)),\n };\n }\n\n private toCanvas(): HTMLCanvasElement {\n // Without this, no image threw NG0951 from the required `imgEl` query, and a\n // `'failed'` one the canvas's own complaint about a broken image: two internals\n // messages for one plain fact.\n const status = this.status();\n if (status !== 'loaded') {\n throw new Error(`[NGWR] <wr-image-cropper>: there is no loaded image to export (status \"${status}\").`);\n }\n const img = this.imgEl().nativeElement;\n const c = this.cropRect();\n const canvas = document.createElement('canvas');\n const size = this.outputSize(c);\n canvas.width = size.width;\n canvas.height = size.height;\n // The SOURCE rect stays the whole crop and the destination is the canvas, so a\n // capped export is the same region drawn smaller rather than a smaller region.\n const ctx = canvas.getContext('2d');\n if (ctx) ctx.drawImage(img, c.x, c.y, c.width, c.height, 0, 0, canvas.width, canvas.height);\n return canvas;\n }\n\n private async emitCropped(): Promise<void> {\n if (this.status() !== 'loaded') return;\n try {\n const blob = await this.toBlob();\n this.cropped.emit(blob);\n } catch (error) {\n // An image IS loaded, so a failure here is the browser refusing to encode it,\n // and `(cropped)` not firing has to be visible to the developer. It used to be\n // swallowed, which is how a tainted cross-origin canvas went unnoticed.\n if (isDevMode()) {\n // eslint-disable-next-line no-console -- dev-mode diagnostics\n console.warn('[NGWR] <wr-image-cropper>: the crop could not be encoded, so (cropped) did not fire.', error);\n }\n }\n }\n}\n","@if (objectUrl(); as url) {\n <div class=\"wr-image-cropper__canvas\">\n <!--\n `crossorigin` is what lets a URL on another origin be exported at all: an image\n fetched without it taints the canvas `toCanvas` draws into, even when the server\n sends CORS headers, and every export then throws a SecurityError. It is static\n so it is in place before `src` starts the request.\n -->\n <img\n #img\n class=\"wr-image-cropper__image\"\n crossorigin=\"anonymous\"\n [src]=\"url\"\n alt=\"\"\n draggable=\"false\"\n (load)=\"onImageLoad()\"\n (error)=\"onImageError()\"\n />\n\n @if (display().w > 0) {\n <!-- Semi-transparent backdrop with a cut-out for the crop window. -->\n <div\n class=\"wr-image-cropper__backdrop\"\n [style.clip-path]=\"`polygon(0 0, 100% 0, 100% 100%, 0 100%, 0 ${cropDisplay().y}px, ${cropDisplay().x}px ${cropDisplay().y}px, ${cropDisplay().x}px ${cropDisplay().y + cropDisplay().h}px, ${cropDisplay().x + cropDisplay().w}px ${cropDisplay().y + cropDisplay().h}px, ${cropDisplay().x + cropDisplay().w}px ${cropDisplay().y}px, 0 ${cropDisplay().y}px)`\"\n ></div>\n\n <!--\n Crop window — drag to move, with eight resize handles, and the ONE\n keyboard control the component has (see `onWindowKeydown`). The eight\n handles stay pointer-only and `aria-hidden`: eight extra tab stops per\n cropper would be hostile. The keys resize from the east and south edges\n only, so a west or north drag comes out as a resize plus a move rather\n than as one gesture.\n\n `role=\"group\"` rather than no role at all, because `aria-label` is\n prohibited on a roleless `<div>` and this needs a name; and rather than\n `role=\"application\"`, which would switch the reader out of its own\n browse mode for the whole subtree — far more than one rectangle is worth.\n -->\n <div\n class=\"wr-image-cropper__window\"\n role=\"group\"\n tabindex=\"0\"\n [attr.aria-label]=\"resolvedWindowLabel()\"\n [attr.aria-describedby]=\"helpId\"\n [style.left.px]=\"cropDisplay().x\"\n [style.top.px]=\"cropDisplay().y\"\n [style.width.px]=\"cropDisplay().w\"\n [style.height.px]=\"cropDisplay().h\"\n (pointerdown)=\"onPointerDown('move', $event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n (lostpointercapture)=\"onPointerUp($event)\"\n (keydown)=\"onWindowKeydown($event)\"\n (keyup)=\"onWindowKeyup()\"\n >\n @for (h of handles; track h) {\n <span\n aria-hidden=\"true\"\n [class]=\"`wr-image-cropper__handle wr-image-cropper__handle--${h}`\"\n (pointerdown)=\"onPointerDown(h, $event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n (lostpointercapture)=\"onPointerUp($event)\"\n ></span>\n }\n </div>\n\n <p class=\"wr-image-cropper__sr-only\" [id]=\"helpId\">{{ resolvedKeyHelp() }}</p>\n\n <!--\n The crop rect in SOURCE pixels, announced after a keyboard change only —\n a pointer drag already gives sighted feedback and would flood the region,\n and the initial crop is not news. Deliberately bare numbers: a sentence\n here would be a translated string the catalog does not carry, and the\n reader has just been told what the four numbers mean by `helpId`.\n -->\n <p class=\"wr-image-cropper__sr-only\" role=\"status\">{{ announcement() }}</p>\n }\n </div>\n} @else {\n <div class=\"wr-image-cropper__empty\">{{ emptyText() }}</div>\n}\n"],"mappings":";;;;;;;;;;;AAiCA,SAAS,oBAAoB,OAAc;CACzC,IAAI,UAAU,QAAQ,UAAU,UAAa,UAAU,IAAI,OAAO;CAClE,MAAM,IAAI,qBAAqB,OAAO,GAAU;CAChD,OAAO,OAAO,SAAS,CAAC,KAAK,IAAI,IAAI,IAAI;AAC3C;AAOA,MAAM,cAAc,OAAsB,IAAI,CAAC,CAAC,WAAU;AAG1D,MAAM,WAAW;AACjB,MAAM,kBAAkB;AAsBxB,MAAM,WAAoB;CAAE,MAAM;CAAG,KAAK;CAAG,OAAO;CAAG,QAAQ;AAAC;AAwBhE,SAAS,WACP,GACA,QACA,IACA,IACA,QACA,KACA,OAAoB;CAEpB,MAAM,OAAO,OAAO,SAAS,GAAG;CAChC,MAAM,OAAO,OAAO,SAAS,GAAG;CAChC,MAAM,QAAQ,OAAO,SAAS,GAAG;CACjC,MAAM,QAAQ,OAAO,SAAS,GAAG;CACjC,MAAM,QAAQ,EAAE,IAAI,EAAE;CACtB,MAAM,SAAS,EAAE,IAAI,EAAE;CAEvB,IAAI,CAAC,SAAS,SAAS,GAAG;EACxB,IAAI,EAAE,GAAG,GAAG,GAAG,MAAM;EACrB,IAAI,MAAM,IAAI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AAA;GAAA,CAAA;EAAA,CAAA;EAAA,UAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,WAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,YAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,eAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,eAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,SAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,SAAA;EAAA,CAAA;EAAA,WAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,WAAA;EAAA,CAAA;EAAA,OAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,OAAK,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
1
+ {"version":3,"file":"ngwr-image-cropper.mjs","names":[],"sources":["../../../projects/lib/image-cropper/image-cropper.ts","../../../projects/lib/image-cropper/image-cropper.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceNumberProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n DestroyRef,\n type ElementRef,\n ViewEncapsulation,\n computed,\n effect,\n inject,\n input,\n isDevMode,\n output,\n signal,\n viewChild,\n} from '@angular/core';\n\nimport { useI18nText } from 'ngwr/i18n';\nimport { wrClamp, wrFileNameForType, wrRandomId, wrCheckStyles } from 'ngwr/utils';\n\nimport type { WrCropHandle, WrCropRect, WrImageCropperStatus, WrImageLoadError, WrImageOutputType } from './types';\n\n/**\n * `[maxOutputSize]`'s transform. Anything that is not a positive, finite number —\n * `null`, an empty attribute, `0`, a typo — means \"no cap\" rather than a 1px export:\n * a bad config should cost resolution nobody asked to lose, not the whole image.\n */\nfunction coerceMaxOutputSize(value: unknown): number | null {\n if (value === null || value === undefined || value === '') return null;\n const n = coerceNumberProperty(value, Number.NaN);\n return Number.isFinite(n) && n > 0 ? n : null;\n}\n\n/**\n * Stands in for the consumer input `useI18nText` expects. None of this\n * component's three strings has a `*Label` input behind it — the catalog is the\n * override channel — so they share one empty override.\n */\nconst NO_OVERRIDE = signal<string | null>(null).asReadonly();\n\n/** Keyboard step in display pixels, and what Shift promotes it to. */\nconst KEY_STEP = 1;\nconst KEY_STEP_COARSE = 10;\n\ninterface RectPx {\n x: number;\n y: number;\n w: number;\n h: number;\n}\n\ninterface SizePx {\n w: number;\n h: number;\n}\n\n/** Distances, in CSS pixels, past each side of a box. */\ninterface SidesPx {\n left: number;\n top: number;\n right: number;\n bottom: number;\n}\n\nconst NO_SIDES: SidesPx = { left: 0, top: 0, right: 0, bottom: 0 };\n\n/**\n * The rect a resize gesture produces: a pure function of the rect the gesture started\n * from and the TOTAL pointer offset, so the same pointer position always gives the same\n * rect however the pointer got there.\n *\n * The anchor never moves. It is the edge or corner opposite the handle — for `se` the\n * top-left corner, for `e` the west edge's line. The old version clamped `x`, `y`, `w`\n * and `h` one at a time after deriving the second axis, so once the derived axis ran\n * into the image edge the rect slid AWAY from its anchor and, past the far bound, off\n * the image entirely.\n *\n * With a ratio the size is the largest along that ratio which fits from the anchor —\n * the smaller of the width-limited and height-limited sizes — and no smaller than both\n * minimums allow. Where the image cannot fit the minimum from this anchor, the bound\n * wins: a crop past the edge of the image is worse than one under the minimum.\n *\n * An edge handle with a ratio also sizes the axis it does not drive, and that axis has\n * the image's WHOLE extent to grow into: the rect stays centred on its old midline where\n * it can and slides along that axis only as far as it must to stay on the image. Capping\n * the size at twice the distance from the midline to the nearer side instead would leave\n * a square crop resting against the top edge unable to widen at all.\n */\nfunction resizeFrom(\n r: RectPx,\n handle: WrCropHandle,\n dx: number,\n dy: number,\n bounds: SizePx,\n min: SizePx,\n ratio: number | null\n): RectPx {\n const east = handle.includes('e');\n const west = handle.includes('w');\n const south = handle.includes('s');\n const north = handle.includes('n');\n const right = r.x + r.w;\n const bottom = r.y + r.h;\n\n if (!ratio || ratio <= 0) {\n let { x, y, w, h } = r;\n if (east) w = wrClamp(r.w + dx, min.w, bounds.w - r.x);\n if (west) {\n w = wrClamp(r.w - dx, min.w, right);\n x = right - w;\n }\n if (south) h = wrClamp(r.h + dy, min.h, bounds.h - r.y);\n if (north) {\n h = wrClamp(r.h - dy, min.h, bottom);\n y = bottom - h;\n }\n return { x, y, w, h };\n }\n\n // Room from the anchor to the image edge on each axis the handle drives; the whole\n // image on an axis it does not.\n const roomW = east ? bounds.w - r.x : west ? right : bounds.w;\n const roomH = south ? bounds.h - r.y : north ? bottom : bounds.h;\n // Corners follow the horizontal delta, as they always have; `n` / `s` the vertical one.\n const wanted = east ? r.w + dx : west ? r.w - dx : (south ? r.h + dy : r.h - dy) * ratio;\n const w = wrClamp(wanted, Math.max(min.w, min.h * ratio), Math.min(roomW, roomH * ratio));\n const h = w / ratio;\n\n return {\n x: east ? r.x : west ? right - w : wrClamp(r.x + r.w / 2 - w / 2, 0, bounds.w - w),\n y: south ? r.y : north ? bottom - h : wrClamp(r.y + r.h / 2 - h / 2, 0, bounds.h - h),\n w,\n h,\n };\n}\n\n/**\n * Image crop UI. Pass `[src]` (URL, `File`, or `Blob`); the user drags\n * the crop window or any of its eight handles. Optionally lock the crop\n * to a fixed `[aspectRatio]`.\n *\n * The crop window is also the one tab stop: arrow keys move it, Alt with an\n * arrow key resizes it, and Shift makes either step ten pixels instead of one.\n *\n * `(cropped)` fires after each drag end — or each run of arrow keys — with a\n * freshly-rendered `Blob` of the cropped region. For one-off reads use\n * `toBlob()` / `toDataUrl()`.\n *\n * A source the browser cannot decode fires `(loadError)` once, sets `status()` to\n * `'failed'` and puts `wr-image-cropper--failed` on the host. The component renders\n * no message of its own for it — what went wrong and what to do next is the host's\n * to say.\n *\n * The image is requested with `crossorigin=\"anonymous\"`, because a canvas will not\n * export pixels from another origin otherwise. A URL on another origin therefore has\n * to be served with `Access-Control-Allow-Origin`; one that is not fails to load and\n * fires `(loadError)`, where it used to show and then refuse every export.\n *\n * @example\n * ```html\n * <wr-image-cropper\n * [src]=\"file\"\n * [aspectRatio]=\"1\"\n * (cropped)=\"onBlob($event)\"\n * (loadError)=\"onUnreadable($event)\"\n * />\n * ```\n *\n * @see https://ngwr.dev/reference/components/image-cropper\n */\n@Component({\n selector: 'wr-image-cropper',\n templateUrl: './image-cropper.html',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-image-cropper',\n '[class.wr-image-cropper--failed]': \"status() === 'failed'\",\n },\n})\nexport class WrImageCropper {\n /** Image source — URL string, `File`, or `Blob`. */\n readonly src = input<string | File | Blob | null>(null);\n\n /** Aspect ratio (width / height). `null` = free. @default null */\n readonly aspectRatio = input<number | null>(null);\n\n /** Minimum crop width in display pixels. @default 32 */\n readonly minWidth = input(32, { transform: (v: unknown): number => Math.max(8, coerceNumberProperty(v, 32)) });\n\n /** Minimum crop height in display pixels. @default 32 */\n readonly minHeight = input(32, { transform: (v: unknown): number => Math.max(8, coerceNumberProperty(v, 32)) });\n\n /** Default output type for `(cropped)`. @default 'image/png' */\n readonly outputType = input<WrImageOutputType>('image/png');\n\n /** JPEG / WebP quality for `(cropped)` in [0, 1]. @default 0.92 */\n readonly outputQuality = input(0.92);\n\n /**\n * Longest side of the exported image, in pixels — for `(cropped)`, `toBlob()` and\n * `toDataUrl()` alike. A crop larger than this is scaled down to fit, keeping its\n * aspect ratio; a smaller one is exported as it is, never upscaled. The crop itself\n * — `cropRect()`, in source pixels — is not affected. `null` (or anything that is\n * not a positive number) exports at the source image's own resolution.\n * @default null\n */\n readonly maxOutputSize = input<number | null>(null, { transform: coerceMaxOutputSize });\n\n /** Emits a Blob after each drag end. */\n readonly cropped = output<Blob>();\n\n /**\n * Fires once when the browser cannot decode the current `src` — a format it does\n * not support, a broken file, a URL that fails. Nothing is rendered for it; show\n * your own message. A new `src` clears the failure.\n */\n readonly loadError = output<WrImageLoadError>();\n\n protected readonly imgEl = viewChild.required<ElementRef<HTMLImageElement>>('img');\n\n /** Resolved object URL for `src` (so File / Blob render in `<img>`). */\n protected readonly emptyText = useI18nText(NO_OVERRIDE, 'imageCropper.empty', 'No image');\n\n /** Accessible name of the crop window — the component's only tab stop. */\n protected readonly resolvedWindowLabel = useI18nText(NO_OVERRIDE, 'imageCropper.window', 'Crop region');\n\n /** The key model, referenced by the window's `aria-describedby`. */\n protected readonly resolvedKeyHelp = useI18nText(\n NO_OVERRIDE,\n 'imageCropper.keyHelp',\n 'Arrow keys move the crop. Hold Alt with an arrow key to resize it, and Shift for larger steps. ' +\n 'The crop is announced as left, top, width and height in image pixels.'\n );\n\n /** Id linking the crop window to the help text. Random rather than counted:\n * the crop UI only exists after a real image load, so it never prerenders. */\n protected readonly helpId = wrRandomId('wr-image-cropper-help');\n\n /** Live-region text — written by the keyboard path only (see `onWindowKeydown`). */\n protected readonly announcement = signal<string>('');\n\n protected readonly objectUrl = signal<string | null>(null);\n\n /** Previous object URL we created — kept off-signal so the resolve\n * effect doesn't depend on its own writes (which would loop). */\n private previousObjectUrl: string | null = null;\n\n /** Natural (source) pixel dimensions. */\n protected readonly natural = signal<{ w: number; h: number }>({ w: 0, h: 0 });\n\n /** Display (rendered) pixel dimensions. */\n protected readonly display = signal<{ w: number; h: number }>({ w: 0, h: 0 });\n\n /** Crop rect in display coordinates. */\n protected readonly cropDisplay = signal<RectPx>({ x: 0, y: 0, w: 0, h: 0 });\n\n /** Watches the rendered image box — see `watchResize`. */\n private resizeObserver: ResizeObserver | null = null;\n\n /** Currently active drag handle. */\n private active: WrCropHandle | null = null;\n private startPointer: { x: number; y: number } = { x: 0, y: 0 };\n private startRect: RectPx = { x: 0, y: 0, w: 0, h: 0 };\n\n /** The element the live drag set pointer capture on, so the end releases that one. */\n private captureTarget: HTMLElement | null = null;\n\n /** The pointer the live drag belongs to. Every other pointer's events are ignored. */\n private pointerId: number | null = null;\n\n /** How far past each side of the crop the live resize was pressed — see `onPointerMove`. */\n private overhang: SidesPx = NO_SIDES;\n\n private readonly destroyRef = inject(DestroyRef);\n\n private readonly statusState = signal<WrImageCropperStatus>('empty');\n\n /**\n * Where the source stands: `'empty'`, `'loading'`, `'loaded'` or `'failed'`. Reset\n * to `'loading'` (or `'empty'`) whenever `src` changes, so a failure never outlives\n * the source that caused it.\n */\n readonly status = this.statusState.asReadonly();\n\n /** Resolved crop rect in natural (source) pixel coordinates. */\n readonly cropRect = computed<WrCropRect>(() => {\n const display = this.display();\n const natural = this.natural();\n const c = this.cropDisplay();\n if (display.w === 0 || display.h === 0) return { x: 0, y: 0, width: 0, height: 0 };\n const sx = natural.w / display.w;\n const sy = natural.h / display.h;\n return {\n x: Math.round(c.x * sx),\n y: Math.round(c.y * sy),\n width: Math.round(c.w * sx),\n height: Math.round(c.h * sy),\n };\n });\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('image-cropper');\n // Resolve the source into a usable URL the <img> can render.\n // We only read `src()` here — `previousObjectUrl` is a plain field, so\n // writing to `objectUrl` doesn't re-trigger this effect (and hang the\n // tab on file upload).\n effect(() => {\n const src = this.src();\n if (this.previousObjectUrl) {\n URL.revokeObjectURL(this.previousObjectUrl);\n this.previousObjectUrl = null;\n }\n // The crop is measured against the image that WAS showing, and `cropRect` is a\n // public signal a consumer can read at any moment. Left in place it kept\n // reporting a rect scaled to the previous image for the whole gap between a new\n // `src` and its load event — long enough to crop the wrong thing.\n this.resetGeometry();\n if (!src) {\n this.objectUrl.set(null);\n this.statusState.set('empty');\n return;\n }\n // A new source starts over: a failure belongs to the source that caused it, and\n // left in place it would mark a perfectly good next image as broken until the\n // browser answered for that one too.\n this.statusState.set('loading');\n if (typeof src === 'string') {\n this.objectUrl.set(src);\n } else {\n const url = URL.createObjectURL(src);\n this.previousObjectUrl = url;\n this.objectUrl.set(url);\n }\n });\n\n this.destroyRef.onDestroy(() => {\n if (this.previousObjectUrl) URL.revokeObjectURL(this.previousObjectUrl);\n this.resizeObserver?.disconnect();\n });\n }\n\n // Image load\n\n /**\n * Back to \"nothing measured yet\", which is also what an absent `src` means.\n *\n * `display` is the field that gates everything downstream — the crop UI renders on\n * `display().w > 0` and `cropRect` returns zeros without it — so it is the only one\n * a test can observe. The other two are reset for coherence: the resize observer\n * below also writes `display`, and left alone they would resurrect a crop measured\n * against the previous image (which is why `onResize` refuses to run on a zeroed\n * `display` — see there).\n */\n private resetGeometry(): void {\n this.natural.set({ w: 0, h: 0 });\n this.display.set({ w: 0, h: 0 });\n this.cropDisplay.set({ x: 0, y: 0, w: 0, h: 0 });\n }\n\n protected onImageLoad(): void {\n const img = this.imgEl().nativeElement;\n const rect = img.getBoundingClientRect();\n const display = { w: rect.width, h: rect.height };\n // Some SVGs and odd images report zero natural dimensions — fall back\n // to the rendered size so the crop math stays well-defined.\n const natural = {\n w: img.naturalWidth || display.w,\n h: img.naturalHeight || display.h,\n };\n this.statusState.set('loaded');\n this.natural.set(natural);\n this.display.set(display);\n this.cropDisplay.set(this.initialCrop(display));\n this.watchResize(img);\n }\n\n /**\n * The `<img>` could not decode its source.\n *\n * Before this handler existed a failed decode left the component exactly as it\n * looks while loading — an image with no size, no crop window, nothing emitted —\n * so a host had no way to tell \"still decoding\" from \"never going to\", and a user\n * who picked a `.heic` the browser cannot read saw an empty box and no reason.\n *\n * Once per source: `status` is reset by a new `src` and by nothing else, so a\n * second `error` for the same source says nothing new and is not re-emitted.\n */\n protected onImageError(): void {\n const url = this.objectUrl();\n if (!url || this.statusState() === 'failed') return;\n this.statusState.set('failed');\n this.resetGeometry();\n\n const src = this.src();\n const isBlob = typeof src !== 'string' && src !== null;\n this.loadError.emit({\n url,\n name: typeof File !== 'undefined' && src instanceof File ? src.name : null,\n type: isBlob ? src.type : null,\n size: isBlob ? src.size : null,\n });\n }\n\n /**\n * Keep `display` on the box the image is actually rendered at.\n *\n * The stylesheet sizes the image responsively — `max-width: 100%`,\n * `max-height: 70dvh`, `height: auto` — so the single measurement taken in the\n * `(load)` handler stops being true as soon as the container or the viewport\n * changes. Everything the user sees and touches is in DISPLAY pixels: the crop\n * window's inline `left` / `top` / `width` / `height`, the backdrop cut-out, and\n * the bounds `applyMove` / `applyResize` clamp against. Measured once, a narrowed\n * window leaves the crop painted past the edge of the image and draggable off it.\n *\n * Re-observed per load rather than once, because a new `src` may mount a new\n * `<img>`; the old observation would then be on a detached element.\n */\n private watchResize(el: HTMLImageElement): void {\n if (typeof ResizeObserver === 'undefined') return;\n this.resizeObserver?.disconnect();\n // Re-read the same way `onImageLoad` does rather than take the entry's\n // `contentRect`, so the two measurements can't disagree about the box.\n const ro = new ResizeObserver(() => this.onResize(el));\n ro.observe(el);\n this.resizeObserver = ro;\n }\n\n /**\n * Rescale the crop by however much the image did, so the user keeps the region\n * they picked instead of having it re-centred: `cropRect()` — the source-pixel\n * value a consumer acts on — comes out the same across the resize.\n */\n private onResize(el: HTMLImageElement): void {\n const previous = this.display();\n // Nothing measured yet, or measured and then dropped by `resetGeometry` while a\n // new `src` loads. There is no crop to carry over, and the load will measure.\n if (previous.w === 0 || previous.h === 0) return;\n const rect = el.getBoundingClientRect();\n // A hidden image (a closed tab, `display: none`) reports zeros. Scaling by that\n // would collapse the crop and there would be nothing to scale back from, so hold\n // the last real box until it is shown again.\n if (rect.width === 0 || rect.height === 0) return;\n if (rect.width === previous.w && rect.height === previous.h) return;\n\n const sx = rect.width / previous.w;\n const sy = rect.height / previous.h;\n const c = this.cropDisplay();\n this.display.set({ w: rect.width, h: rect.height });\n this.cropDisplay.set({ x: c.x * sx, y: c.y * sy, w: c.w * sx, h: c.h * sy });\n }\n\n /** Compute a sensible initial crop — centered, respecting aspectRatio. */\n private initialCrop(display: { w: number; h: number }): RectPx {\n const ratio = this.aspectRatio();\n let w = display.w * 0.6;\n let h = display.h * 0.6;\n if (ratio && ratio > 0) {\n const candidate = w / ratio;\n if (candidate > h) w = h * ratio;\n else h = w / ratio;\n }\n return {\n x: (display.w - w) / 2,\n y: (display.h - h) / 2,\n w,\n h,\n };\n }\n\n // Drag handlers\n\n protected readonly handles: readonly WrCropHandle[] = ['n', 's', 'e', 'w', 'ne', 'nw', 'se', 'sw'];\n\n protected onPointerDown(handle: WrCropHandle, event: PointerEvent): void {\n // Any pointerdown used to start a drag, so the right button moved the crop window and\n // a second finger could take over a drag already in progress.\n if (event.button !== 0 || !event.isPrimary) return;\n event.preventDefault();\n event.stopPropagation();\n this.active = handle;\n this.pointerId = event.pointerId;\n this.startPointer = { x: event.clientX, y: event.clientY };\n this.startRect = { ...this.cropDisplay() };\n this.captureTarget = event.currentTarget as HTMLElement;\n this.captureTarget.setPointerCapture(event.pointerId);\n this.overhang = handle === 'move' ? NO_SIDES : this.pastCrop(event);\n }\n\n /**\n * A resize ENDS when the pointer leaves the image, exactly as `pointerup` would end it:\n * the move that carried it out is applied — clamped to the image like any other — and\n * then the drag is over. Nothing after that resumes it or changes the crop, pointer\n * back over the image or not, until a new `pointerdown`. A move drag is not affected:\n * its size is fixed, so it simply rests against the edge.\n *\n * The move that leaves is applied rather than dropped because pointer moves are\n * SAMPLES. Dropped, a quick drag toward a corner would stop wherever its last sample\n * inside happened to fall — a single move from a handle to past the image would change\n * nothing at all — and even a slow one would stop a fraction of a pixel short of the\n * edge. A drag that leaves across one edge still ends there: heading for a corner at a\n * slant that crosses the bottom first, the crop's right edge stays where it was then.\n *\n * \"The image\" is the `<img>`'s own box — the bounds `applyMove` / `applyResize` clamp\n * the crop to — with its edges counting as inside, since the crop may reach them. The\n * box is re-measured on every move and compared with `clientX` / `clientY`: both are\n * viewport coordinates, so a scroll mid-drag cannot put them out of step. The moves\n * outside reach this handler at all only because the drag holds pointer capture.\n *\n * One allowance, fixed at `pointerdown`: the box is widened on each side by however far\n * past that side of the CROP the press landed — at most as far as the pressed handle\n * reaches past it. Half of an edge handle, and three quarters of a corner handle, lies\n * outside the crop, so a press there already has the pointer ahead of the edge it drags.\n * Measured without the allowance, that pointer would leave the image while the crop was\n * still short of the image's edge by the same distance, with nothing able to close the\n * gap; and a handle resting on the image's edge, pressed on its outer part, would begin\n * its drag already outside. A press on a handle's inner part widens nothing.\n */\n protected onPointerMove(event: PointerEvent): void {\n if (!this.active || event.pointerId !== this.pointerId) return;\n const dx = event.clientX - this.startPointer.x;\n const dy = event.clientY - this.startPointer.y;\n if (this.active === 'move') {\n this.applyMove(dx, dy);\n return;\n }\n this.applyResize(this.active, dx, dy);\n if (!this.withinImage(event)) this.onPointerUp(event);\n }\n\n /**\n * Ends the drag — for `pointerup`, `pointercancel`, a capture lost to something else,\n * and a resize whose pointer left the image. Once per drag: the capture released here\n * fires `lostpointercapture` afterwards, and by then there is nothing left to end.\n *\n * Only for the pointer that started it. A second finger is refused a drag of its own at\n * `pointerdown`, but its moves and its lifting reach these handlers all the same, and\n * would otherwise drive or end the first finger's drag.\n */\n protected onPointerUp(event: PointerEvent): void {\n if (!this.active || event.pointerId !== this.pointerId) return;\n const target = this.captureTarget;\n this.active = null;\n this.pointerId = null;\n this.captureTarget = null;\n this.overhang = NO_SIDES;\n // Asked first: a capture that is already gone has nothing to release, and releasing\n // one for a pointer that is no longer active throws.\n if (target?.hasPointerCapture(event.pointerId)) target.releasePointerCapture(event.pointerId);\n void this.emitCropped();\n }\n\n /** How far past each side of the crop window the pointer is, in CSS pixels. */\n private pastCrop(event: PointerEvent): SidesPx {\n const box = this.imgEl().nativeElement.getBoundingClientRect();\n const c = this.startRect;\n return {\n left: Math.max(0, box.left + c.x - event.clientX),\n top: Math.max(0, box.top + c.y - event.clientY),\n right: Math.max(0, event.clientX - (box.left + c.x + c.w)),\n bottom: Math.max(0, event.clientY - (box.top + c.y + c.h)),\n };\n }\n\n /** Whether the pointer is on the image, edges and the press's `overhang` included. */\n private withinImage(event: PointerEvent): boolean {\n const box = this.imgEl().nativeElement.getBoundingClientRect();\n const o = this.overhang;\n return (\n event.clientX >= box.left - o.left &&\n event.clientX <= box.right + o.right &&\n event.clientY >= box.top - o.top &&\n event.clientY <= box.bottom + o.bottom\n );\n }\n\n // Keyboard\n\n /** Whether a key has moved the crop since the last `keyup`. */\n private keyboardDirty = false;\n\n /**\n * The component's only keyboard path. Arrow keys move the crop window; Alt\n * with an arrow key resizes it from the east / south edge; Shift makes either\n * one ten display pixels instead of one — the coarse modifier `wr-slider`,\n * `wr-knob` and `wr-splitter` all use, which is why Alt and not Shift carries\n * the mode switch here.\n *\n * Nothing mirrors under `dir=\"rtl\"`: the image is not flipped and the window\n * is placed with a physical `left`, so ArrowLeft moves the crop visually left\n * in both directions.\n *\n * Both branches go through `applyMove` / `applyResize`, so the `aspectRatio`\n * lock, the `minWidth` / `minHeight` floors and the canvas bounds hold for a\n * keystroke exactly as they do for a drag. Those two measure from `startRect`\n * rather than from the live rect, so it is re-seeded per keystroke — a 1px\n * delta against the rect from the first press would make a held arrow stall\n * after one pixel instead of accumulating.\n */\n protected onWindowKeydown(event: KeyboardEvent): void {\n const step = event.shiftKey ? KEY_STEP_COARSE : KEY_STEP;\n let dx = 0;\n let dy = 0;\n switch (event.key) {\n case 'ArrowLeft':\n dx = -step;\n break;\n case 'ArrowRight':\n dx = step;\n break;\n case 'ArrowUp':\n dy = -step;\n break;\n case 'ArrowDown':\n dy = step;\n break;\n default:\n return;\n }\n\n event.preventDefault();\n this.startRect = { ...this.cropDisplay() };\n if (event.altKey) this.applyResize(dx !== 0 ? 'e' : 's', dx, dy);\n else this.applyMove(dx, dy);\n\n this.keyboardDirty = true;\n const c = this.cropRect();\n // Bare numbers on purpose — `resolvedKeyHelp` has already told the reader\n // what the four are, and a sentence here would be a translated string.\n this.announcement.set(`${c.x}, ${c.y}, ${c.width} × ${c.height}`);\n }\n\n /**\n * Emit once per gesture, not once per keystroke. A held arrow repeats its\n * keydown many times a second and each `emitCropped` renders a canvas and\n * encodes a Blob; `keyup` fires once when the run ends, which is the keyboard's\n * equivalent of the `pointerup` the drag path emits on.\n */\n protected onWindowKeyup(): void {\n if (!this.keyboardDirty) return;\n this.keyboardDirty = false;\n void this.emitCropped();\n }\n\n private applyMove(dx: number, dy: number): void {\n const display = this.display();\n const r = this.startRect;\n const next = {\n x: wrClamp(r.x + dx, 0, display.w - r.w),\n y: wrClamp(r.y + dy, 0, display.h - r.h),\n w: r.w,\n h: r.h,\n };\n this.cropDisplay.set(next);\n }\n\n private applyResize(handle: WrCropHandle, dx: number, dy: number): void {\n const min = { w: this.minWidth(), h: this.minHeight() };\n this.cropDisplay.set(resizeFrom(this.startRect, handle, dx, dy, this.display(), min, this.aspectRatio()));\n }\n\n // Public API\n\n /**\n * Render the current crop as a Blob. Rejects while `status()` is anything but\n * `'loaded'`, since there is no image to draw.\n */\n async toBlob(type: WrImageOutputType = this.outputType(), quality: number = this.outputQuality()): Promise<Blob> {\n const canvas = this.toCanvas();\n return new Promise<Blob>((resolve, reject) => {\n canvas.toBlob(\n blob => {\n if (blob) resolve(blob);\n else reject(new Error('toBlob returned null'));\n },\n type,\n quality\n );\n });\n }\n\n /**\n * Render the current crop as a `File`. The extension of `name` is replaced by that of\n * the type the browser actually encoded, which can differ from `type`: a browser falls\n * back to PNG for a type it cannot encode. Rejects like `toBlob()`.\n */\n async toFile(\n name: string,\n type: WrImageOutputType = this.outputType(),\n quality: number = this.outputQuality()\n ): Promise<File> {\n const blob = await this.toBlob(type, quality);\n return new File([blob], wrFileNameForType(name, blob.type), { type: blob.type });\n }\n\n /**\n * Render the current crop as a data URL. Throws while `status()` is anything but\n * `'loaded'`, since there is no image to draw.\n */\n toDataUrl(type: WrImageOutputType = this.outputType(), quality: number = this.outputQuality()): string {\n return this.toCanvas().toDataURL(type, quality);\n }\n\n /** Re-emit the crop without waiting for a drag (e.g. after a programmatic change). */\n async refresh(): Promise<void> {\n await this.emitCropped();\n }\n\n // Internals\n\n /**\n * The exported image's pixel size: the crop in source pixels, scaled down so its\n * longer side fits `maxOutputSize`. `Math.min(1, …)` is the never-upscale rule — a\n * crop already inside the cap keeps its own size, which is also the whole of the\n * uncapped path.\n */\n private outputSize(c: WrCropRect): { width: number; height: number } {\n const cap = this.maxOutputSize();\n const longest = Math.max(c.width, c.height);\n const scale = cap === null || longest === 0 ? 1 : Math.min(1, cap / longest);\n return {\n width: Math.max(1, Math.round(c.width * scale)),\n height: Math.max(1, Math.round(c.height * scale)),\n };\n }\n\n private toCanvas(): HTMLCanvasElement {\n // Without this, no image threw NG0951 from the required `imgEl` query, and a\n // `'failed'` one the canvas's own complaint about a broken image: two internals\n // messages for one plain fact.\n const status = this.status();\n if (status !== 'loaded') {\n throw new Error(`[NGWR] <wr-image-cropper>: there is no loaded image to export (status \"${status}\").`);\n }\n const img = this.imgEl().nativeElement;\n const c = this.cropRect();\n const canvas = document.createElement('canvas');\n const size = this.outputSize(c);\n canvas.width = size.width;\n canvas.height = size.height;\n // The SOURCE rect stays the whole crop and the destination is the canvas, so a\n // capped export is the same region drawn smaller rather than a smaller region.\n const ctx = canvas.getContext('2d');\n if (ctx) ctx.drawImage(img, c.x, c.y, c.width, c.height, 0, 0, canvas.width, canvas.height);\n return canvas;\n }\n\n private async emitCropped(): Promise<void> {\n if (this.status() !== 'loaded') return;\n try {\n const blob = await this.toBlob();\n this.cropped.emit(blob);\n } catch (error) {\n // An image IS loaded, so a failure here is the browser refusing to encode it,\n // and `(cropped)` not firing has to be visible to the developer. It used to be\n // swallowed, which is how a tainted cross-origin canvas went unnoticed.\n if (isDevMode()) {\n // eslint-disable-next-line no-console -- dev-mode diagnostics\n console.warn('[NGWR] <wr-image-cropper>: the crop could not be encoded, so (cropped) did not fire.', error);\n }\n }\n }\n}\n","@if (objectUrl(); as url) {\n <div class=\"wr-image-cropper__canvas\">\n <!--\n `crossorigin` is what lets a URL on another origin be exported at all: an image\n fetched without it taints the canvas `toCanvas` draws into, even when the server\n sends CORS headers, and every export then throws a SecurityError. It is static\n so it is in place before `src` starts the request.\n -->\n <img\n #img\n class=\"wr-image-cropper__image\"\n crossorigin=\"anonymous\"\n [src]=\"url\"\n alt=\"\"\n draggable=\"false\"\n (load)=\"onImageLoad()\"\n (error)=\"onImageError()\"\n />\n\n @if (display().w > 0) {\n <!-- Semi-transparent backdrop with a cut-out for the crop window. -->\n <div\n class=\"wr-image-cropper__backdrop\"\n [style.clip-path]=\"`polygon(0 0, 100% 0, 100% 100%, 0 100%, 0 ${cropDisplay().y}px, ${cropDisplay().x}px ${cropDisplay().y}px, ${cropDisplay().x}px ${cropDisplay().y + cropDisplay().h}px, ${cropDisplay().x + cropDisplay().w}px ${cropDisplay().y + cropDisplay().h}px, ${cropDisplay().x + cropDisplay().w}px ${cropDisplay().y}px, 0 ${cropDisplay().y}px)`\"\n ></div>\n\n <!--\n Crop window — drag to move, with eight resize handles, and the ONE\n keyboard control the component has (see `onWindowKeydown`). The eight\n handles stay pointer-only and `aria-hidden`: eight extra tab stops per\n cropper would be hostile. The keys resize from the east and south edges\n only, so a west or north drag comes out as a resize plus a move rather\n than as one gesture.\n\n `role=\"group\"` rather than no role at all, because `aria-label` is\n prohibited on a roleless `<div>` and this needs a name; and rather than\n `role=\"application\"`, which would switch the reader out of its own\n browse mode for the whole subtree — far more than one rectangle is worth.\n -->\n <div\n class=\"wr-image-cropper__window\"\n role=\"group\"\n tabindex=\"0\"\n [attr.aria-label]=\"resolvedWindowLabel()\"\n [attr.aria-describedby]=\"helpId\"\n [style.left.px]=\"cropDisplay().x\"\n [style.top.px]=\"cropDisplay().y\"\n [style.width.px]=\"cropDisplay().w\"\n [style.height.px]=\"cropDisplay().h\"\n (pointerdown)=\"onPointerDown('move', $event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n (lostpointercapture)=\"onPointerUp($event)\"\n (keydown)=\"onWindowKeydown($event)\"\n (keyup)=\"onWindowKeyup()\"\n >\n @for (h of handles; track h) {\n <span\n aria-hidden=\"true\"\n [class]=\"`wr-image-cropper__handle wr-image-cropper__handle--${h}`\"\n (pointerdown)=\"onPointerDown(h, $event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n (lostpointercapture)=\"onPointerUp($event)\"\n ></span>\n }\n </div>\n\n <p class=\"wr-image-cropper__sr-only\" [id]=\"helpId\">{{ resolvedKeyHelp() }}</p>\n\n <!--\n The crop rect in SOURCE pixels, announced after a keyboard change only —\n a pointer drag already gives sighted feedback and would flood the region,\n and the initial crop is not news. Deliberately bare numbers: a sentence\n here would be a translated string the catalog does not carry, and the\n reader has just been told what the four numbers mean by `helpId`.\n -->\n <p class=\"wr-image-cropper__sr-only\" role=\"status\">{{ announcement() }}</p>\n }\n </div>\n} @else {\n <div class=\"wr-image-cropper__empty\">{{ emptyText() }}</div>\n}\n"],"mappings":";;;;;;;;;;;AAiCA,SAAS,oBAAoB,OAAc;CACzC,IAAI,UAAU,QAAQ,UAAU,UAAa,UAAU,IAAI,OAAO;CAClE,MAAM,IAAI,qBAAqB,OAAO,GAAU;CAChD,OAAO,OAAO,SAAS,CAAC,KAAK,IAAI,IAAI,IAAI;AAC3C;AAOA,MAAM,cAAc,OAAsB,IAAI,CAAC,CAAC,WAAU;AAG1D,MAAM,WAAW;AACjB,MAAM,kBAAkB;AAsBxB,MAAM,WAAoB;CAAE,MAAM;CAAG,KAAK;CAAG,OAAO;CAAG,QAAQ;AAAC;AAwBhE,SAAS,WACP,GACA,QACA,IACA,IACA,QACA,KACA,OAAoB;CAEpB,MAAM,OAAO,OAAO,SAAS,GAAG;CAChC,MAAM,OAAO,OAAO,SAAS,GAAG;CAChC,MA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