xertica-ui 2.1.2 → 2.1.3

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 (402) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +1 -1
  3. package/assets/xertica-logo.svg +37 -37
  4. package/assets/xertica-x-logo.svg +20 -20
  5. package/bin/cli.ts +1 -1
  6. package/bin/generate-tokens.ts +13 -7
  7. package/components/assistant/index.ts +6 -6
  8. package/components/assistant/xertica-assistant/index.ts +2 -0
  9. package/components/assistant/xertica-assistant/use-assistant.ts +564 -0
  10. package/components/assistant/xertica-assistant/xertica-assistant.stories.tsx +200 -0
  11. package/components/assistant/xertica-assistant/xertica-assistant.tsx +183 -474
  12. package/components/blocks/card-patterns/ActivityCard.tsx +72 -72
  13. package/components/blocks/card-patterns/FeatureCard.tsx +100 -100
  14. package/components/blocks/card-patterns/NotificationCard.tsx +127 -127
  15. package/components/blocks/card-patterns/ProfileCard.tsx +84 -84
  16. package/components/blocks/card-patterns/ProjectCard.tsx +89 -89
  17. package/components/blocks/card-patterns/QuickActionCard.tsx +62 -62
  18. package/components/blocks/card-patterns/card-patterns.stories.tsx +445 -445
  19. package/components/blocks/card-patterns/index.ts +17 -17
  20. package/components/blocks/index.ts +1 -1
  21. package/components/brand/index.ts +6 -6
  22. package/components/brand/xertica-provider/XerticaProvider.tsx +48 -48
  23. package/components/brand/xertica-provider/xertica-provider.mdx +61 -61
  24. package/components/brand/xertica-provider/xertica-provider.test.tsx +52 -52
  25. package/components/examples/MapExamples.tsx +282 -282
  26. package/components/examples/SimpleFilterableMap.tsx +191 -191
  27. package/components/examples/index.ts +51 -51
  28. package/components/figma/ImageWithFallback.tsx +27 -27
  29. package/components/hooks/index.ts +7 -7
  30. package/components/index.ts +5 -5
  31. package/components/layout/header/header.test.tsx +8 -8
  32. package/components/layout/header/header.tsx +4 -4
  33. package/components/layout/index.ts +2 -2
  34. package/components/layout/sidebar/index.ts +2 -0
  35. package/components/layout/sidebar/sidebar.mdx +1 -1
  36. package/components/layout/sidebar/sidebar.stories.tsx +160 -8
  37. package/components/layout/sidebar/sidebar.test.tsx +11 -11
  38. package/components/layout/sidebar/sidebar.tsx +610 -471
  39. package/components/layout/sidebar/use-sidebar.ts +113 -0
  40. package/components/media/FloatingMediaWrapper.tsx +11 -11
  41. package/components/media/audio-player/AudioPlayer.tsx +22 -22
  42. package/components/media/index.ts +3 -3
  43. package/components/pages/home-content/HomeContent.tsx +7 -7
  44. package/components/pages/home-content/home-content.mdx +62 -62
  45. package/components/pages/home-page/HomePage.stories.tsx +39 -39
  46. package/components/pages/home-page/HomePage.tsx +1 -1
  47. package/components/pages/home-page/home-page.mdx +53 -53
  48. package/components/pages/index.ts +8 -8
  49. package/components/pages/template-content/TemplateContent.tsx +5 -5
  50. package/components/pages/template-content/template-content.mdx +61 -61
  51. package/components/pages/template-page/TemplatePage.stories.tsx +39 -39
  52. package/components/pages/template-page/TemplatePage.tsx +5 -5
  53. package/components/pages/template-page/template-page.mdx +53 -53
  54. package/components/public-api-smoke.test.tsx +52 -52
  55. package/components/shared/assistant-utils.ts +43 -43
  56. package/components/shared/layout-constants.ts +1 -1
  57. package/components/ui/accordion/accordion.mdx +8 -8
  58. package/components/ui/accordion/accordion.stories.tsx +53 -53
  59. package/components/ui/alert/alert.mdx +8 -8
  60. package/components/ui/alert-dialog/alert-dialog.mdx +8 -8
  61. package/components/ui/aspect-ratio/aspect-ratio.mdx +8 -8
  62. package/components/ui/assistant-chart/assistant-chart.mdx +8 -8
  63. package/components/ui/avatar/avatar.mdx +8 -8
  64. package/components/ui/badge/badge.mdx +8 -8
  65. package/components/ui/badge/badge.tsx +9 -9
  66. package/components/ui/breadcrumb/breadcrumb.mdx +8 -8
  67. package/components/ui/button/button.mdx +8 -8
  68. package/components/ui/calendar/calendar.mdx +8 -8
  69. package/components/ui/calendar/calendar.tsx +258 -258
  70. package/components/ui/card/card.mdx +8 -8
  71. package/components/ui/card/card.stories.tsx +245 -245
  72. package/components/ui/carousel/carousel.mdx +8 -8
  73. package/components/ui/chart/chart.mdx +8 -8
  74. package/components/ui/chart/chart.stories.tsx +1303 -344
  75. package/components/ui/chart/chart.test.tsx +154 -154
  76. package/components/ui/chart/chart.tsx +2367 -1494
  77. package/components/ui/checkbox/checkbox.mdx +8 -8
  78. package/components/ui/checkbox/checkbox.stories.tsx +20 -20
  79. package/components/ui/collapsible/collapsible.mdx +8 -8
  80. package/components/ui/command/command.mdx +8 -8
  81. package/components/ui/context-menu/context-menu.mdx +8 -8
  82. package/components/ui/dialog/dialog.mdx +8 -8
  83. package/components/ui/drawer/drawer.mdx +8 -8
  84. package/components/ui/dropdown-menu/dropdown-menu.mdx +8 -8
  85. package/components/ui/empty/empty.mdx +8 -8
  86. package/components/ui/file-upload/file-upload.mdx +8 -8
  87. package/components/ui/file-upload/file-upload.stories.tsx +100 -0
  88. package/components/ui/file-upload/file-upload.tsx +14 -74
  89. package/components/ui/file-upload/index.ts +1 -0
  90. package/components/ui/file-upload/use-file-upload.ts +181 -0
  91. package/components/ui/google-maps-loader/google-maps-loader.tsx +2 -2
  92. package/components/ui/hover-card/hover-card.mdx +8 -8
  93. package/components/ui/input/input.mdx +8 -8
  94. package/components/ui/input-otp/input-otp.mdx +8 -8
  95. package/components/ui/input-otp/input-otp.stories.tsx +6 -6
  96. package/components/ui/label/label.mdx +8 -8
  97. package/components/ui/map/map.mdx +8 -8
  98. package/components/ui/map/map.stories.tsx +51 -51
  99. package/components/ui/map/map.tsx +2 -2
  100. package/components/ui/menubar/menubar.mdx +8 -8
  101. package/components/ui/navigation-menu/navigation-menu.mdx +8 -8
  102. package/components/ui/notification-badge/notification-badge.mdx +8 -8
  103. package/components/ui/pagination/index.ts +2 -0
  104. package/components/ui/pagination/pagination.mdx +8 -8
  105. package/components/ui/pagination/pagination.stories.tsx +94 -0
  106. package/components/ui/pagination/use-pagination.ts +194 -0
  107. package/components/ui/popover/popover.mdx +8 -8
  108. package/components/ui/progress/progress.mdx +8 -8
  109. package/components/ui/progress/progress.tsx +68 -68
  110. package/components/ui/radio-group/radio-group.mdx +8 -8
  111. package/components/ui/rating/rating.mdx +8 -8
  112. package/components/ui/resizable/resizable.mdx +8 -8
  113. package/components/ui/rich-text-editor/index.ts +2 -0
  114. package/components/ui/rich-text-editor/rich-text-editor.stories.tsx +129 -1
  115. package/components/ui/rich-text-editor/rich-text-editor.tsx +86 -305
  116. package/components/ui/rich-text-editor/use-rich-text-editor.ts +439 -0
  117. package/components/ui/route-map/route-map.mdx +8 -8
  118. package/components/ui/route-map/route-map.stories.tsx +54 -54
  119. package/components/ui/route-map/route-map.tsx +2 -2
  120. package/components/ui/scroll-area/scroll-area.mdx +8 -8
  121. package/components/ui/search/search.mdx +8 -8
  122. package/components/ui/select/select.mdx +8 -8
  123. package/components/ui/select/select.stories.tsx +9 -9
  124. package/components/ui/separator/separator.mdx +8 -8
  125. package/components/ui/sheet/sheet.mdx +8 -8
  126. package/components/ui/sheet/sheet.stories.tsx +95 -95
  127. package/components/ui/simple-map/simple-map.mdx +8 -8
  128. package/components/ui/simple-map/simple-map.stories.tsx +48 -48
  129. package/components/ui/skeleton/skeleton.mdx +8 -8
  130. package/components/ui/slider/slider.mdx +8 -8
  131. package/components/ui/sonner/sonner.mdx +8 -8
  132. package/components/ui/stats-card/stats-card.mdx +8 -8
  133. package/components/ui/stepper/index.ts +3 -1
  134. package/components/ui/stepper/stepper.mdx +8 -8
  135. package/components/ui/stepper/stepper.stories.tsx +116 -0
  136. package/components/ui/stepper/stepper.tsx +4 -4
  137. package/components/ui/stepper/use-stepper.ts +137 -0
  138. package/components/ui/switch/switch.mdx +8 -8
  139. package/components/ui/switch/switch.stories.tsx +20 -20
  140. package/components/ui/table/table.mdx +8 -8
  141. package/components/ui/tabs/tabs.mdx +8 -8
  142. package/components/ui/tabs/tabs.stories.tsx +26 -26
  143. package/components/ui/textarea/textarea.mdx +8 -8
  144. package/components/ui/timeline/timeline.mdx +8 -8
  145. package/components/ui/toggle/toggle.mdx +8 -8
  146. package/components/ui/toggle-group/toggle-group.mdx +8 -8
  147. package/components/ui/tooltip/tooltip.mdx +8 -8
  148. package/components/ui/tree-view/index.ts +4 -1
  149. package/components/ui/tree-view/tree-view.mdx +8 -8
  150. package/components/ui/tree-view/tree-view.stories.tsx +110 -4
  151. package/components/ui/tree-view/tree-view.tsx +17 -125
  152. package/components/ui/tree-view/use-tree-view.ts +229 -0
  153. package/components.json +1512 -1512
  154. package/contexts/ApiKeyContext.tsx +72 -72
  155. package/contexts/BrandColorsContext.tsx +26 -26
  156. package/contexts/LanguageContext.tsx +13 -13
  157. package/contexts/LayoutContext.test.tsx +11 -11
  158. package/contexts/LayoutContext.tsx +29 -29
  159. package/contexts/ThemeContext.tsx +26 -26
  160. package/contexts/theme-data.ts +4 -4
  161. package/dist/{AssistantChart-CVzmmhx4.js → AssistantChart-C_hwFRRr.js} +4 -4
  162. package/dist/{AssistantChart-BAx9VQvb.cjs → AssistantChart-CldVCVDe.cjs} +311 -94
  163. package/dist/{AssistantChart-CVko2A1W.js → AssistantChart-Cu3m7RBo.js} +314 -97
  164. package/dist/{AssistantChart-9w31gdAb.cjs → AssistantChart-DoZCyS5r.cjs} +4 -4
  165. package/dist/AudioPlayer-B1lt5cPl.cjs +989 -0
  166. package/dist/AudioPlayer-BZ7bibzU.cjs +982 -0
  167. package/dist/AudioPlayer-C12BjQBV.cjs +997 -0
  168. package/dist/AudioPlayer-DMcG_c7L.js +990 -0
  169. package/dist/AudioPlayer-DcFKRJE_.js +998 -0
  170. package/dist/AudioPlayer-e8LfNoqO.js +983 -0
  171. package/dist/{xertica-assistant-Qp3ydksa.cjs → CodeBlock-7TTgmdGG.cjs} +263 -51
  172. package/dist/{xertica-assistant-gnCJdcZY.js → CodeBlock-BeSt1h5P.js} +219 -7
  173. package/dist/CodeBlock-BgfYL_rD.cjs +2094 -0
  174. package/dist/CodeBlock-BlcqlA9M.cjs +2094 -0
  175. package/dist/CodeBlock-Bnmeu5ez.cjs +2094 -0
  176. package/dist/CodeBlock-BtfPlbAI.js +2078 -0
  177. package/dist/CodeBlock-CIySIuYr.js +2078 -0
  178. package/dist/CodeBlock-CuPtUM-7.cjs +2094 -0
  179. package/dist/CodeBlock-D6ffWXgc.js +2078 -0
  180. package/dist/CodeBlock-D8dcwbit.cjs +2094 -0
  181. package/dist/CodeBlock-DMZrFnlw.cjs +2094 -0
  182. package/dist/CodeBlock-DlBehYN8.js +2078 -0
  183. package/dist/CodeBlock-DnYNI8rQ.js +2078 -0
  184. package/dist/CodeBlock-DvKWbSnE.cjs +2094 -0
  185. package/dist/CodeBlock-DwMCfkFY.js +2078 -0
  186. package/dist/CodeBlock-Dy6CNYyj.js +2078 -0
  187. package/dist/CodeBlock-U1pPOQI7.cjs +2094 -0
  188. package/dist/CodeBlock-f_GpNhEB.js +2078 -0
  189. package/dist/CodeBlock-oB6u8nI1.js +2078 -0
  190. package/dist/CodeBlock-tZC31B73.cjs +2094 -0
  191. package/dist/ImageWithFallback-CGtidP6B.cjs +4542 -0
  192. package/dist/ImageWithFallback-lsg3pdFg.js +4508 -0
  193. package/dist/LanguageSelector-B5YfbHra.js +231 -0
  194. package/dist/LanguageSelector-D6uacAIM.cjs +230 -0
  195. package/dist/LayoutContext-BAql6ZRY.js +97 -0
  196. package/dist/LayoutContext-BvK-ggDa.cjs +96 -0
  197. package/dist/ThemeContext-BoH4NLfN.js +734 -0
  198. package/dist/{ThemeContext-BbBNoFTG.js → ThemeContext-C2EwAPDt.js} +2 -2
  199. package/dist/ThemeContext-r69W20Xg.cjs +733 -0
  200. package/dist/{ThemeContext-Cmr8Ex8H.cjs → ThemeContext-vTjumZeM.cjs} +2 -2
  201. package/dist/{VerifyEmailPage-BE-L9mB7.js → VerifyEmailPage-C0c2e5n0.js} +7 -7
  202. package/dist/{VerifyEmailPage-DMBh4NM9.cjs → VerifyEmailPage-CYXtbKi3.cjs} +1 -1
  203. package/dist/{VerifyEmailPage-CR7kb5df.cjs → VerifyEmailPage-Cwi3kbol.cjs} +7 -7
  204. package/dist/{VerifyEmailPage-CdYPSJoO.js → VerifyEmailPage-DvMLZgFt.js} +1 -1
  205. package/dist/XerticaOrbe-KL1RBHzw.cjs +1354 -0
  206. package/dist/XerticaOrbe-zwS1p2a8.js +1355 -0
  207. package/dist/XerticaProvider-6btlAlzc.js +17 -0
  208. package/dist/XerticaProvider-BNoNOxQ5.cjs +16 -0
  209. package/dist/XerticaProvider-BlY2limY.cjs +38 -0
  210. package/dist/{XerticaProvider-BITjgC5p.js → XerticaProvider-CEoWMTxu.js} +2 -2
  211. package/dist/{XerticaProvider-By8q3Roe.cjs → XerticaProvider-CllrbMEJ.cjs} +2 -2
  212. package/dist/XerticaProvider-DDuiIcKo.js +39 -0
  213. package/dist/XerticaProvider-cI9hSs27.cjs +38 -0
  214. package/dist/XerticaProvider-hSwhNQex.js +39 -0
  215. package/dist/{alert-dialog-yckpaOpy.cjs → alert-dialog-DSKByiKZ.cjs} +3 -3
  216. package/dist/{alert-dialog-iDe5VE5o.js → alert-dialog-s-vmNkJ_.js} +3 -3
  217. package/dist/assistant.cjs.js +2 -1
  218. package/dist/assistant.es.js +3 -2
  219. package/dist/brand.cjs.js +1 -1
  220. package/dist/brand.es.js +1 -1
  221. package/dist/breadcrumb-CqJ7bHY5.js +161 -0
  222. package/dist/breadcrumb-m9Hb2_XN.cjs +177 -0
  223. package/dist/cli.js +14 -8
  224. package/dist/components/assistant/xertica-assistant/index.d.ts +2 -0
  225. package/dist/components/assistant/xertica-assistant/use-assistant.d.ts +126 -0
  226. package/dist/components/assistant/xertica-assistant/xertica-assistant.d.ts +7 -2
  227. package/dist/components/blocks/audio-player/AudioPlayer.d.ts +35 -0
  228. package/dist/components/blocks/audio-player/index.d.ts +1 -0
  229. package/dist/components/blocks/document-editor/DocumentEditor.d.ts +26 -0
  230. package/dist/components/blocks/document-editor/index.d.ts +1 -0
  231. package/dist/components/blocks/podcast-player/PodcastPlayer.d.ts +41 -0
  232. package/dist/components/blocks/podcast-player/index.d.ts +1 -0
  233. package/dist/components/layout/sidebar/index.d.ts +2 -0
  234. package/dist/components/layout/sidebar/sidebar.d.ts +80 -0
  235. package/dist/components/layout/sidebar/use-sidebar.d.ts +22 -0
  236. package/dist/components/shared/layout-constants.d.ts +1 -1
  237. package/dist/components/ui/button/button.d.ts +1 -1
  238. package/dist/components/ui/chart/chart.d.ts +162 -5
  239. package/dist/components/ui/file-upload/file-upload.d.ts +2 -0
  240. package/dist/components/ui/file-upload/index.d.ts +1 -0
  241. package/dist/components/ui/file-upload/use-file-upload.d.ts +49 -0
  242. package/dist/components/ui/pagination/index.d.ts +2 -0
  243. package/dist/components/ui/pagination/use-pagination.d.ts +78 -0
  244. package/dist/components/ui/rich-text-editor/index.d.ts +2 -0
  245. package/dist/components/ui/rich-text-editor/use-rich-text-editor.d.ts +107 -0
  246. package/dist/components/ui/stepper/index.d.ts +3 -1
  247. package/dist/components/ui/stepper/stepper.d.ts +2 -2
  248. package/dist/components/ui/stepper/use-stepper.d.ts +60 -0
  249. package/dist/components/ui/tree-view/index.d.ts +4 -1
  250. package/dist/components/ui/tree-view/tree-view.d.ts +4 -6
  251. package/dist/components/ui/tree-view/use-tree-view.d.ts +60 -0
  252. package/dist/dropdown-menu-BDB5CmQs.cjs +247 -0
  253. package/dist/dropdown-menu-DQidbKBD.js +231 -0
  254. package/dist/google-maps-loader-BFWp6VPd.js +287 -0
  255. package/dist/{google-maps-loader-t2IlYBzw.js → google-maps-loader-CTYySAun.js} +4 -0
  256. package/dist/{google-maps-loader-BqsYL48U.cjs → google-maps-loader-Y-QkD-Li.cjs} +5 -0
  257. package/dist/google-maps-loader-eS3uQ5TA.cjs +287 -0
  258. package/dist/header-Cgy6vYPk.cjs +731 -0
  259. package/dist/header-DRlT4jgI.js +715 -0
  260. package/dist/header-Dux00SI4.cjs +731 -0
  261. package/dist/header-EkGKXPsD.js +715 -0
  262. package/dist/header-WfEywpyc.cjs +731 -0
  263. package/dist/header-tifNQn2U.js +715 -0
  264. package/dist/hooks.cjs.js +1 -1
  265. package/dist/hooks.es.js +1 -1
  266. package/dist/index-BhapVLVj.js +8 -0
  267. package/dist/{index-D3RLKRAs.cjs → index-COtD8bRW.cjs} +1 -1
  268. package/dist/index-D6fxYEY8.cjs +7 -0
  269. package/dist/index-DW5tYe26.js +8 -0
  270. package/dist/index.cjs.js +19 -8
  271. package/dist/index.es.js +39 -28
  272. package/dist/index.umd.js +1043 -470
  273. package/dist/input-2R4loU86.js +127 -0
  274. package/dist/input-DWANSKGb.cjs +145 -0
  275. package/dist/layout.cjs.js +89 -1
  276. package/dist/layout.es.js +90 -2
  277. package/dist/pages.cjs.js +1 -1
  278. package/dist/pages.es.js +1 -1
  279. package/dist/rich-text-editor-0mraWT5y.cjs +2376 -0
  280. package/dist/rich-text-editor-B6jMRLzk.cjs +1939 -0
  281. package/dist/rich-text-editor-B8_oYcIR.js +1730 -0
  282. package/dist/rich-text-editor-B9UbSXNb.js +1203 -0
  283. package/dist/rich-text-editor-BYuRBNBU.js +2373 -0
  284. package/dist/rich-text-editor-Bb9pySTs.cjs +2374 -0
  285. package/dist/rich-text-editor-BcL6L3cm.cjs +2374 -0
  286. package/dist/rich-text-editor-BoVZYtTs.cjs +2391 -0
  287. package/dist/rich-text-editor-CPV1lEPH.cjs +1748 -0
  288. package/dist/rich-text-editor-CoKqbCtu.cjs +1799 -0
  289. package/dist/rich-text-editor-Cw56T_mB.js +2356 -0
  290. package/dist/rich-text-editor-Cyt8qs2b.js +1921 -0
  291. package/dist/rich-text-editor-D6H84OcX.cjs +1220 -0
  292. package/dist/rich-text-editor-D76gD-QI.js +2328 -0
  293. package/dist/rich-text-editor-DKkokOnA.js +1781 -0
  294. package/dist/rich-text-editor-DNsdpN64.cjs +2359 -0
  295. package/dist/rich-text-editor-DfG8bCyY.js +2358 -0
  296. package/dist/rich-text-editor-DgF8s7xW.js +2949 -0
  297. package/dist/rich-text-editor-Dxjw31Z4.js +2341 -0
  298. package/dist/rich-text-editor-DzP0Epmb.js +2356 -0
  299. package/dist/rich-text-editor-mWoaSCE4.cjs +2966 -0
  300. package/dist/rich-text-editor-skplNlBM.cjs +2345 -0
  301. package/dist/select-Bkbr0f-Z.cjs +162 -0
  302. package/dist/select-CvIVdX2n.js +145 -0
  303. package/dist/sidebar-CK_0ZQHj.cjs +803 -0
  304. package/dist/sidebar-CUuOvYhK.js +787 -0
  305. package/dist/slider-Bc5Hd0y1.js +56 -0
  306. package/dist/slider-N7hFFj6X.cjs +73 -0
  307. package/dist/tooltip-Ded96neP.cjs +137 -0
  308. package/dist/tooltip-HDOoD2-0.js +120 -0
  309. package/dist/ui.cjs.js +14 -4
  310. package/dist/ui.es.js +26 -16
  311. package/dist/use-mobile-B0hNy_Y6.cjs +4303 -0
  312. package/dist/use-mobile-BXuYROXM.js +4202 -0
  313. package/dist/use-mobile-Bbd51ASU.cjs +4392 -0
  314. package/dist/use-mobile-Bk6CX-TC.js +4359 -0
  315. package/dist/use-mobile-BvYdisLP.js +4202 -0
  316. package/dist/use-mobile-BzuxjzNX.cjs +4392 -0
  317. package/dist/use-mobile-CG2-SdXV.cjs +4235 -0
  318. package/dist/use-mobile-CKb5pqTs.js +4269 -0
  319. package/dist/use-mobile-CYuAuGDl.js +4202 -0
  320. package/dist/use-mobile-CaENcqm-.js +4508 -0
  321. package/dist/use-mobile-CbrYgJGJ.js +4203 -0
  322. package/dist/use-mobile-DMOvImGQ.cjs +4542 -0
  323. package/dist/use-mobile-DRB3BQgD.cjs +4235 -0
  324. package/dist/use-mobile-DZvv7QMR.js +4359 -0
  325. package/dist/use-mobile-DdI_TXam.cjs +4235 -0
  326. package/dist/use-mobile-DlceKf8a.js +4359 -0
  327. package/dist/use-mobile-DsOnow1o.cjs +4236 -0
  328. package/dist/use-mobile-Kcj6jSnK.cjs +4392 -0
  329. package/dist/use-mobile-bnKcua_i.js +4202 -0
  330. package/dist/use-mobile-ncXBeE2z.cjs +4235 -0
  331. package/dist/{xertica-assistant-B1IaHXnB.cjs → xertica-assistant-dyP7KHM5.cjs} +533 -392
  332. package/dist/{xertica-assistant-DPsESB6t.js → xertica-assistant-yX1CFBBo.js} +535 -394
  333. package/dist/xertica-ui.css +2 -2
  334. package/docs/ai-usage.md +28 -10
  335. package/docs/architecture.md +76 -0
  336. package/docs/components/assistant.md +159 -0
  337. package/docs/components/calendar.md +154 -154
  338. package/docs/components/card-patterns.md +337 -337
  339. package/docs/components/card.md +235 -235
  340. package/docs/components/chart.md +354 -39
  341. package/docs/components/file-upload.md +119 -2
  342. package/docs/components/map.md +84 -84
  343. package/docs/components/pagination.md +187 -0
  344. package/docs/components/rich-text-editor.md +164 -0
  345. package/docs/components/sidebar.md +153 -4
  346. package/docs/components/stepper.md +157 -12
  347. package/docs/components/tree-view.md +164 -6
  348. package/docs/components/xertica-provider.md +24 -24
  349. package/docs/decision-tree.md +287 -287
  350. package/docs/getting-started.md +1 -1
  351. package/docs/guidelines.md +14 -8
  352. package/docs/layout.md +2 -2
  353. package/docs/llms.md +4 -4
  354. package/guidelines/Guidelines.md +252 -250
  355. package/hooks/useTheme.ts +3 -3
  356. package/imports/Podcast.tsx +388 -388
  357. package/imports/XerticaAi.tsx +45 -45
  358. package/imports/XerticaX.tsx +19 -19
  359. package/imports/svg-aueiaqngck.ts +11 -11
  360. package/imports/svg-v9krss1ozd.ts +16 -16
  361. package/imports/svg-vhrdofe3qe.ts +5 -5
  362. package/llms-compact.txt +327 -327
  363. package/llms.txt +160 -160
  364. package/package.json +203 -203
  365. package/styles/xertica/app-overrides/chat.css +61 -61
  366. package/styles/xertica/app-overrides/scrollbar.css +33 -33
  367. package/styles/xertica/integrations/google-maps.css +76 -76
  368. package/styles/xertica/integrations/sonner.css +73 -73
  369. package/styles/xertica/tokens.css +41 -12
  370. package/templates/CLAUDE.md +182 -172
  371. package/templates/guidelines/Guidelines.md +325 -313
  372. package/templates/package.json +3 -3
  373. package/templates/src/features/auth/index.ts +4 -4
  374. package/templates/src/features/auth/ui/AuthPageShell.tsx +34 -34
  375. package/templates/src/features/auth/ui/ForgotPasswordContent.tsx +70 -70
  376. package/templates/src/features/auth/ui/LoginContent.tsx +90 -90
  377. package/templates/src/features/auth/ui/ResetPasswordContent.tsx +151 -151
  378. package/templates/src/features/auth/ui/SocialLoginButtons.tsx +59 -59
  379. package/templates/src/features/auth/ui/VerifyEmailContent.tsx +82 -82
  380. package/templates/src/features/home/index.ts +1 -1
  381. package/templates/src/features/home/ui/HomeContent.tsx +100 -100
  382. package/templates/src/features/template/index.ts +5 -5
  383. package/templates/src/features/template/ui/CrudTemplate.tsx +3 -3
  384. package/templates/src/features/template/ui/DashboardTemplate.tsx +3 -3
  385. package/templates/src/features/template/ui/FormTemplate.tsx +120 -120
  386. package/templates/src/features/template/ui/LoginTemplate.tsx +3 -3
  387. package/templates/src/pages/AssistantPage.tsx +328 -328
  388. package/templates/src/pages/ForgotPasswordPage.tsx +6 -6
  389. package/templates/src/pages/HomePage.tsx +57 -57
  390. package/templates/src/pages/LoginPage.tsx +10 -10
  391. package/templates/src/pages/ResetPasswordPage.tsx +6 -6
  392. package/templates/src/pages/TemplatePage.tsx +30 -30
  393. package/templates/src/pages/VerifyEmailPage.tsx +6 -6
  394. package/templates/src/shared/config/navigation.ts +20 -20
  395. package/templates/src/shared/lib/auth.ts +20 -20
  396. package/templates/src/shared/types/auth.ts +3 -3
  397. package/templates/src/styles/xertica/tokens.css +39 -10
  398. package/templates/tsconfig.json +5 -5
  399. package/utils/gemini.ts +140 -140
  400. package/dist/VerifyEmailPage-Bae2cBXT.cjs +0 -2827
  401. package/dist/VerifyEmailPage-CbgjOF0v.js +0 -2828
  402. package/dist/index-CkTUgOwX.js +0 -8
@@ -0,0 +1,2341 @@
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { useRef, useState, useEffect } from "react";
4
+ import * as RechartsPrimitive from "recharts";
5
+ import { e as cn, B as Button } from "./tooltip-HDOoD2-0.js";
6
+ import { cva } from "class-variance-authority";
7
+ import { XCircle, AlertTriangle, Info, CheckCircle, RefreshCw, BarChart3, WifiOff, XIcon, Undo, Redo, ChevronDown, Type, Heading1, Heading2, Heading3, Bold, Italic, Underline, AlignLeft, AlignCenter, AlignRight, List, ListOrdered, Link, X, Search, ChevronUp } from "lucide-react";
8
+ import { S as Select, h as SelectTrigger, i as SelectValue, a as SelectContent, c as SelectItem } from "./select-CvIVdX2n.js";
9
+ import * as TabsPrimitive from "@radix-ui/react-tabs";
10
+ import * as DialogPrimitive from "@radix-ui/react-dialog";
11
+ import { D as DropdownMenu, n as DropdownMenuTrigger, b as DropdownMenuContent, d as DropdownMenuItem } from "./dropdown-menu-DQidbKBD.js";
12
+ import { P as Popover, b as PopoverTrigger, a as PopoverContent, I as Input } from "./input-2R4loU86.js";
13
+ const alertVariants = cva(
14
+ "relative w-full rounded-[var(--radius)] border-l-4 px-4 py-3 grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-5 [&>svg]:translate-y-0.5 [&>svg]:text-current",
15
+ {
16
+ variants: {
17
+ variant: {
18
+ default: "bg-muted/50 border-l-border text-foreground [&>svg]:text-muted-foreground",
19
+ success: "bg-[color:var(--success)]/10 dark:bg-[color:var(--success)]/20 border-l-[color:var(--success)] text-foreground [&>svg]:text-[color:var(--success)]",
20
+ info: "bg-[color:var(--info)]/10 dark:bg-[color:var(--info)]/20 border-l-[color:var(--info)] text-foreground [&>svg]:text-[color:var(--info)]",
21
+ warning: "bg-[color:var(--warning)]/10 dark:bg-[color:var(--warning)]/20 border-l-[color:var(--warning)] text-foreground [&>svg]:text-[color:var(--warning)]",
22
+ destructive: "bg-[color:var(--destructive)]/10 dark:bg-[color:var(--destructive)]/20 border-l-[color:var(--destructive)] text-foreground [&>svg]:text-[color:var(--destructive)]"
23
+ }
24
+ },
25
+ defaultVariants: {
26
+ variant: "default"
27
+ }
28
+ }
29
+ );
30
+ const alertIcons = {
31
+ default: Info,
32
+ success: CheckCircle,
33
+ info: Info,
34
+ warning: AlertTriangle,
35
+ destructive: XCircle
36
+ };
37
+ function Alert({
38
+ className,
39
+ variant,
40
+ icon,
41
+ children,
42
+ ...props
43
+ }) {
44
+ const alertVariant = variant && variant in alertIcons ? variant : "default";
45
+ const DefaultIcon = alertIcons[alertVariant];
46
+ return /* @__PURE__ */ jsxs(
47
+ "div",
48
+ {
49
+ "data-slot": "alert",
50
+ role: "alert",
51
+ className: cn(alertVariants({ variant }), className),
52
+ ...props,
53
+ children: [
54
+ icon !== void 0 ? icon : /* @__PURE__ */ jsx(DefaultIcon, { className: "flex-shrink-0" }),
55
+ /* @__PURE__ */ jsx("div", { className: "flex-1", children })
56
+ ]
57
+ }
58
+ );
59
+ }
60
+ function AlertTitle({ className, ...props }) {
61
+ return /* @__PURE__ */ jsx(
62
+ "div",
63
+ {
64
+ "data-slot": "alert-title",
65
+ className: cn(
66
+ "font-medium mb-1 leading-tight",
67
+ className
68
+ ),
69
+ ...props
70
+ }
71
+ );
72
+ }
73
+ function AlertDescription({
74
+ className,
75
+ ...props
76
+ }) {
77
+ return /* @__PURE__ */ jsx(
78
+ "div",
79
+ {
80
+ "data-slot": "alert-description",
81
+ className: cn(
82
+ "leading-relaxed",
83
+ className
84
+ ),
85
+ ...props
86
+ }
87
+ );
88
+ }
89
+ function Card({ className, ...props }) {
90
+ return /* @__PURE__ */ jsx(
91
+ "div",
92
+ {
93
+ "data-slot": "card",
94
+ className: cn(
95
+ "bg-card text-card-foreground flex flex-col gap-6 rounded-[var(--radius-card)]",
96
+ className
97
+ ),
98
+ ...props
99
+ }
100
+ );
101
+ }
102
+ function CardHeader({ className, ...props }) {
103
+ return /* @__PURE__ */ jsx(
104
+ "div",
105
+ {
106
+ "data-slot": "card-header",
107
+ className: cn(
108
+ "@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 pt-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
109
+ className
110
+ ),
111
+ ...props
112
+ }
113
+ );
114
+ }
115
+ function CardTitle({ className, ...props }) {
116
+ return /* @__PURE__ */ jsx(
117
+ "h4",
118
+ {
119
+ "data-slot": "card-title",
120
+ className: cn("leading-none", className),
121
+ ...props
122
+ }
123
+ );
124
+ }
125
+ function CardDescription({ className, ...props }) {
126
+ return /* @__PURE__ */ jsx(
127
+ "p",
128
+ {
129
+ "data-slot": "card-description",
130
+ className: cn("text-muted-foreground", className),
131
+ ...props
132
+ }
133
+ );
134
+ }
135
+ function CardAction({ className, ...props }) {
136
+ return /* @__PURE__ */ jsx(
137
+ "div",
138
+ {
139
+ "data-slot": "card-action",
140
+ className: cn(
141
+ "col-start-2 row-span-2 row-start-1 self-start justify-self-end",
142
+ className
143
+ ),
144
+ ...props
145
+ }
146
+ );
147
+ }
148
+ function CardContent({ className, ...props }) {
149
+ return /* @__PURE__ */ jsx(
150
+ "div",
151
+ {
152
+ "data-slot": "card-content",
153
+ className: cn("px-6 [&:last-child]:pb-6", className),
154
+ ...props
155
+ }
156
+ );
157
+ }
158
+ function CardFooter({ className, ...props }) {
159
+ return /* @__PURE__ */ jsx(
160
+ "div",
161
+ {
162
+ "data-slot": "card-footer",
163
+ className: cn("flex items-center px-6 pb-6 [.border-t]:pt-6", className),
164
+ ...props
165
+ }
166
+ );
167
+ }
168
+ const Empty = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
169
+ "div",
170
+ {
171
+ ref,
172
+ className: cn(
173
+ "flex min-h-[400px] flex-col items-center justify-center rounded-[var(--radius-card)] border border-dashed border-border p-8 text-center animate-in fade-in-50",
174
+ className
175
+ ),
176
+ ...props
177
+ }
178
+ ));
179
+ Empty.displayName = "Empty";
180
+ const EmptyIcon = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
181
+ "div",
182
+ {
183
+ ref,
184
+ className: cn(
185
+ "mx-auto flex h-20 w-20 items-center justify-center rounded-full bg-muted",
186
+ className
187
+ ),
188
+ ...props
189
+ }
190
+ ));
191
+ EmptyIcon.displayName = "EmptyIcon";
192
+ const EmptyImage = React.forwardRef(({ className, alt, ...props }, ref) => /* @__PURE__ */ jsx(
193
+ "img",
194
+ {
195
+ ref,
196
+ alt,
197
+ className: cn("mx-auto mb-4 h-48 w-48 object-contain opacity-50", className),
198
+ ...props
199
+ }
200
+ ));
201
+ EmptyImage.displayName = "EmptyImage";
202
+ const EmptyTitle = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
203
+ "h3",
204
+ {
205
+ ref,
206
+ className: cn("mt-4 font-semibold text-foreground", className),
207
+ ...props
208
+ }
209
+ ));
210
+ EmptyTitle.displayName = "EmptyTitle";
211
+ const EmptyDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
212
+ "p",
213
+ {
214
+ ref,
215
+ className: cn("mt-2 text-sm text-muted-foreground max-w-sm mx-auto", className),
216
+ ...props
217
+ }
218
+ ));
219
+ EmptyDescription.displayName = "EmptyDescription";
220
+ const EmptyAction = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
221
+ "div",
222
+ {
223
+ ref,
224
+ className: cn("mt-6 flex flex-col gap-2 sm:flex-row sm:gap-4", className),
225
+ ...props
226
+ }
227
+ ));
228
+ EmptyAction.displayName = "EmptyAction";
229
+ function Skeleton({ className, ...props }) {
230
+ return /* @__PURE__ */ jsx(
231
+ "div",
232
+ {
233
+ "data-slot": "skeleton",
234
+ className: cn("bg-accent animate-pulse rounded-md", className),
235
+ ...props
236
+ }
237
+ );
238
+ }
239
+ function Tabs({
240
+ className,
241
+ ...props
242
+ }) {
243
+ return /* @__PURE__ */ jsx(
244
+ TabsPrimitive.Root,
245
+ {
246
+ "data-slot": "tabs",
247
+ className: cn("flex flex-col gap-2", className),
248
+ ...props
249
+ }
250
+ );
251
+ }
252
+ function TabsList({
253
+ className,
254
+ ...props
255
+ }) {
256
+ return /* @__PURE__ */ jsx(
257
+ TabsPrimitive.List,
258
+ {
259
+ "data-slot": "tabs-list",
260
+ className: cn(
261
+ "relative inline-flex h-12 w-fit items-end justify-start border-b border-border bg-transparent",
262
+ className
263
+ ),
264
+ ...props
265
+ }
266
+ );
267
+ }
268
+ function TabsTrigger({
269
+ className,
270
+ ...props
271
+ }) {
272
+ return /* @__PURE__ */ jsx(
273
+ TabsPrimitive.Trigger,
274
+ {
275
+ "data-slot": "tabs-trigger",
276
+ className: cn(
277
+ "relative inline-flex h-12 items-center justify-center gap-1.5 bg-transparent px-4 py-3 text-sm font-medium whitespace-nowrap transition-all duration-200 ease-in-out border-b-2 border-transparent text-muted-foreground hover:text-foreground hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 data-[state=active]:text-primary data-[state=active]:border-primary data-[state=active]:bg-transparent [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
278
+ className
279
+ ),
280
+ ...props
281
+ }
282
+ );
283
+ }
284
+ function TabsContent({
285
+ className,
286
+ ...props
287
+ }) {
288
+ return /* @__PURE__ */ jsx(
289
+ TabsPrimitive.Content,
290
+ {
291
+ "data-slot": "tabs-content",
292
+ className: cn("flex-1 outline-none", className),
293
+ ...props
294
+ }
295
+ );
296
+ }
297
+ const THEMES = { light: "", dark: ".dark" };
298
+ const defaultPeriods = [
299
+ { value: "7d", label: "7 days" },
300
+ { value: "30d", label: "30 days" },
301
+ { value: "90d", label: "90 days" }
302
+ ];
303
+ const defaultChartColors = [
304
+ "var(--chart-1)",
305
+ "var(--chart-2)",
306
+ "var(--chart-3)",
307
+ "var(--chart-4)",
308
+ "var(--chart-5)"
309
+ ];
310
+ const ChartContext = React.createContext(null);
311
+ function useChart() {
312
+ const context = React.useContext(ChartContext);
313
+ if (!context) {
314
+ throw new Error("useChart must be used within a <ChartContainer />");
315
+ }
316
+ return context;
317
+ }
318
+ function ChartContainer({
319
+ id,
320
+ className,
321
+ children,
322
+ config,
323
+ ...props
324
+ }) {
325
+ const uniqueId = React.useId();
326
+ const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
327
+ return /* @__PURE__ */ jsx(ChartContext.Provider, { value: { config }, children: /* @__PURE__ */ jsxs(
328
+ "div",
329
+ {
330
+ "data-slot": "chart",
331
+ "data-chart": chartId,
332
+ className: cn(
333
+ "[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border flex justify-center text-xs overflow-hidden [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden h-[300px] w-full",
334
+ className
335
+ ),
336
+ ...props,
337
+ children: [
338
+ /* @__PURE__ */ jsx(ChartStyle, { id: chartId, config }),
339
+ /* @__PURE__ */ jsx(RechartsPrimitive.ResponsiveContainer, { width: "100%", height: "100%", children })
340
+ ]
341
+ }
342
+ ) });
343
+ }
344
+ const ChartStyle = ({ id, config }) => {
345
+ const colorConfig = Object.entries(config).filter(
346
+ ([, config2]) => config2.theme || config2.color
347
+ );
348
+ if (!colorConfig.length) {
349
+ return null;
350
+ }
351
+ return /* @__PURE__ */ jsx(
352
+ "style",
353
+ {
354
+ dangerouslySetInnerHTML: {
355
+ __html: Object.entries(THEMES).map(
356
+ ([theme, prefix]) => `
357
+ ${prefix} [data-chart=${id}] {
358
+ ${colorConfig.map(([key, itemConfig]) => {
359
+ var _a;
360
+ const color = ((_a = itemConfig.theme) == null ? void 0 : _a[theme]) || itemConfig.color;
361
+ return color ? ` --color-${key}: ${color};` : null;
362
+ }).join("\n")}
363
+ }
364
+ `
365
+ ).join("\n")
366
+ }
367
+ }
368
+ );
369
+ };
370
+ const ChartTooltip = RechartsPrimitive.Tooltip;
371
+ function ChartTooltipContent({
372
+ active,
373
+ payload,
374
+ className,
375
+ indicator = "dot",
376
+ hideLabel = false,
377
+ hideIndicator = false,
378
+ label,
379
+ labelFormatter,
380
+ labelClassName,
381
+ formatter,
382
+ color,
383
+ nameKey,
384
+ labelKey
385
+ }) {
386
+ const { config } = useChart();
387
+ const tooltipLabel = React.useMemo(() => {
388
+ var _a;
389
+ if (hideLabel || !(payload == null ? void 0 : payload.length)) {
390
+ return null;
391
+ }
392
+ const [item] = payload;
393
+ const key = `${labelKey || (item == null ? void 0 : item.dataKey) || (item == null ? void 0 : item.name) || "value"}`;
394
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
395
+ const value = !labelKey && typeof label === "string" ? ((_a = config[label]) == null ? void 0 : _a.label) || label : itemConfig == null ? void 0 : itemConfig.label;
396
+ if (labelFormatter) {
397
+ return /* @__PURE__ */ jsx("div", { className: cn("font-medium", labelClassName), children: labelFormatter(value, payload) });
398
+ }
399
+ if (!value) {
400
+ return null;
401
+ }
402
+ return /* @__PURE__ */ jsx("div", { className: cn("font-medium", labelClassName), children: value });
403
+ }, [
404
+ label,
405
+ labelFormatter,
406
+ payload,
407
+ hideLabel,
408
+ labelClassName,
409
+ config,
410
+ labelKey
411
+ ]);
412
+ if (!active || !(payload == null ? void 0 : payload.length)) {
413
+ return null;
414
+ }
415
+ const nestLabel = payload.length === 1 && indicator !== "dot";
416
+ return /* @__PURE__ */ jsxs(
417
+ "div",
418
+ {
419
+ className: cn(
420
+ "border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl",
421
+ className
422
+ ),
423
+ children: [
424
+ !nestLabel ? tooltipLabel : null,
425
+ /* @__PURE__ */ jsx("div", { className: "grid gap-1.5", children: payload.map((item, index) => {
426
+ var _a;
427
+ const key = `${nameKey || item.name || item.dataKey || "value"}`;
428
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
429
+ const indicatorColor = color || ((_a = item.payload) == null ? void 0 : _a.fill) || item.color;
430
+ return /* @__PURE__ */ jsx(
431
+ "div",
432
+ {
433
+ className: cn(
434
+ "[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",
435
+ indicator === "dot" && "items-center"
436
+ ),
437
+ children: formatter && (item == null ? void 0 : item.value) !== void 0 && item.name ? formatter(item.value, item.name, item, index, item.payload) : /* @__PURE__ */ jsxs(Fragment, { children: [
438
+ (itemConfig == null ? void 0 : itemConfig.icon) ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : !hideIndicator && /* @__PURE__ */ jsx(
439
+ "div",
440
+ {
441
+ className: cn(
442
+ "shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
443
+ {
444
+ "h-2.5 w-2.5": indicator === "dot",
445
+ "w-1": indicator === "line",
446
+ "w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
447
+ "my-0.5": nestLabel && indicator === "dashed"
448
+ }
449
+ ),
450
+ style: {
451
+ "--color-bg": indicatorColor,
452
+ "--color-border": indicatorColor
453
+ }
454
+ }
455
+ ),
456
+ /* @__PURE__ */ jsxs(
457
+ "div",
458
+ {
459
+ className: cn(
460
+ "flex flex-1 justify-between leading-none",
461
+ nestLabel ? "items-end" : "items-center"
462
+ ),
463
+ children: [
464
+ /* @__PURE__ */ jsxs("div", { className: "grid gap-1.5", children: [
465
+ nestLabel ? tooltipLabel : null,
466
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: (itemConfig == null ? void 0 : itemConfig.label) || item.name })
467
+ ] }),
468
+ item.value && /* @__PURE__ */ jsx("span", { className: "text-foreground font-mono font-medium tabular-nums", children: item.value.toLocaleString() })
469
+ ]
470
+ }
471
+ )
472
+ ] })
473
+ },
474
+ item.dataKey
475
+ );
476
+ }) })
477
+ ]
478
+ }
479
+ );
480
+ }
481
+ const ChartLegend = RechartsPrimitive.Legend;
482
+ function ChartLegendContent({
483
+ className,
484
+ hideIcon = false,
485
+ payload,
486
+ verticalAlign = "bottom",
487
+ nameKey
488
+ }) {
489
+ const { config } = useChart();
490
+ if (!(payload == null ? void 0 : payload.length)) {
491
+ return null;
492
+ }
493
+ return /* @__PURE__ */ jsx(
494
+ "div",
495
+ {
496
+ className: cn(
497
+ "flex items-center justify-center gap-4",
498
+ verticalAlign === "top" ? "pb-3" : "pt-3",
499
+ className
500
+ ),
501
+ children: payload.map((item) => {
502
+ const key = `${nameKey ? item.value : item.dataKey || item.value || "value"}`;
503
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
504
+ return /* @__PURE__ */ jsxs(
505
+ "div",
506
+ {
507
+ className: cn(
508
+ "[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"
509
+ ),
510
+ children: [
511
+ (itemConfig == null ? void 0 : itemConfig.icon) && !hideIcon ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : /* @__PURE__ */ jsx(
512
+ "div",
513
+ {
514
+ className: "h-2 w-2 shrink-0 rounded-[2px] bg-(--color-bg)",
515
+ style: {
516
+ "--color-bg": item.color || `var(--color-${key})`
517
+ }
518
+ }
519
+ ),
520
+ /* @__PURE__ */ jsx("span", { children: (itemConfig == null ? void 0 : itemConfig.label) || item.value })
521
+ ]
522
+ },
523
+ item.value
524
+ );
525
+ })
526
+ }
527
+ );
528
+ }
529
+ function getPayloadConfigFromPayload(config, payload, key) {
530
+ if (typeof payload !== "object" || payload === null) {
531
+ return void 0;
532
+ }
533
+ const payloadPayload = "payload" in payload && typeof payload.payload === "object" && payload.payload !== null ? payload.payload : void 0;
534
+ let configLabelKey = key;
535
+ if (key in payload && typeof payload[key] === "string") {
536
+ configLabelKey = payload[key];
537
+ } else if (payloadPayload && key in payloadPayload && typeof payloadPayload[key] === "string") {
538
+ configLabelKey = payloadPayload[key];
539
+ }
540
+ return configLabelKey in config ? config[configLabelKey] : config[key];
541
+ }
542
+ function getChartSeries(config, series) {
543
+ if (series == null ? void 0 : series.length) {
544
+ return series;
545
+ }
546
+ return Object.entries(config).map(([key, item]) => ({
547
+ key,
548
+ label: item.label
549
+ }));
550
+ }
551
+ function getSeriesColor(key, index, colors) {
552
+ if (Array.isArray(colors)) {
553
+ return colors[index] || defaultChartColors[index % defaultChartColors.length];
554
+ }
555
+ return (colors == null ? void 0 : colors[key]) || defaultChartColors[index % defaultChartColors.length];
556
+ }
557
+ function getChartConfigWithColors(config, keys, colors) {
558
+ return keys.reduce((nextConfig, key, index) => {
559
+ const item = config[key];
560
+ if ((item == null ? void 0 : item.theme) && !colors) {
561
+ nextConfig[key] = item;
562
+ return nextConfig;
563
+ }
564
+ nextConfig[key] = {
565
+ label: (item == null ? void 0 : item.label) || key,
566
+ icon: item == null ? void 0 : item.icon,
567
+ color: colors ? getSeriesColor(key, index, colors) : (item == null ? void 0 : item.color) || getSeriesColor(key, index)
568
+ };
569
+ return nextConfig;
570
+ }, {});
571
+ }
572
+ function formatTick(value) {
573
+ if (typeof value !== "number") {
574
+ return value;
575
+ }
576
+ return Intl.NumberFormat("en", {
577
+ notation: "compact",
578
+ maximumFractionDigits: 1
579
+ }).format(value);
580
+ }
581
+ function defaultFilterData(data, period) {
582
+ const match = period.match(/^(\d+)/);
583
+ if (!match) {
584
+ return data;
585
+ }
586
+ const limit = Number(match[1]);
587
+ return data.slice(Math.max(data.length - limit, 0));
588
+ }
589
+ function getErrorDescription(error) {
590
+ if (typeof error === "string") {
591
+ return error;
592
+ }
593
+ if (error instanceof Error) {
594
+ return error.message;
595
+ }
596
+ return void 0;
597
+ }
598
+ function hasChartData(data, series) {
599
+ if (!data.length || !series.length) {
600
+ return false;
601
+ }
602
+ return data.some(
603
+ (item) => series.some((serie) => {
604
+ const value = item[serie.key];
605
+ return value !== null && value !== void 0 && value !== "";
606
+ })
607
+ );
608
+ }
609
+ function hasPieData(data, nameKey, valueKey) {
610
+ return data.some((item) => {
611
+ const name = item[nameKey];
612
+ const value = item[valueKey];
613
+ return name !== null && name !== void 0 && name !== "" && value !== null && value !== void 0 && value !== "";
614
+ });
615
+ }
616
+ function ChartState({
617
+ type,
618
+ className,
619
+ error,
620
+ onRetry,
621
+ retryLabel = "Try again",
622
+ emptyTitle = "No data available",
623
+ emptyDescription = "There is no data available for this chart yet.",
624
+ errorTitle = "Connection error",
625
+ errorDescription,
626
+ loadingLabel = "Loading chart data"
627
+ }) {
628
+ if (type === "loading") {
629
+ return /* @__PURE__ */ jsxs(
630
+ "div",
631
+ {
632
+ className: cn(
633
+ "flex min-h-[240px] flex-col justify-end gap-3 rounded-[var(--radius-card)] border border-border p-6",
634
+ className
635
+ ),
636
+ "aria-label": typeof loadingLabel === "string" ? loadingLabel : void 0,
637
+ children: [
638
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-2/5" }),
639
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-14 w-3/5" }),
640
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-24 w-4/5" }),
641
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-36 w-full" })
642
+ ]
643
+ }
644
+ );
645
+ }
646
+ if (type === "error") {
647
+ return /* @__PURE__ */ jsx(
648
+ "div",
649
+ {
650
+ className: cn(
651
+ "flex min-h-[240px] items-center justify-center rounded-[var(--radius-card)] border border-border p-6",
652
+ className
653
+ ),
654
+ children: /* @__PURE__ */ jsxs(Alert, { variant: "destructive", className: "max-w-xl", children: [
655
+ /* @__PURE__ */ jsx(AlertTitle, { children: errorTitle }),
656
+ /* @__PURE__ */ jsx(AlertDescription, { children: errorDescription || getErrorDescription(error) || "Unable to load chart data. Check your connection and try again." }),
657
+ onRetry ? /* @__PURE__ */ jsx("div", { className: "mt-3", children: /* @__PURE__ */ jsxs(Button, { size: "sm", variant: "outline", onClick: onRetry, children: [
658
+ /* @__PURE__ */ jsx(RefreshCw, { className: "size-4" }),
659
+ retryLabel
660
+ ] }) }) : null
661
+ ] })
662
+ }
663
+ );
664
+ }
665
+ return /* @__PURE__ */ jsxs(Empty, { className: cn("min-h-[240px]", className), children: [
666
+ /* @__PURE__ */ jsx(EmptyIcon, { children: /* @__PURE__ */ jsx(BarChart3, { className: "size-10 text-muted-foreground" }) }),
667
+ /* @__PURE__ */ jsx(EmptyTitle, { children: emptyTitle }),
668
+ /* @__PURE__ */ jsx(EmptyDescription, { children: emptyDescription }),
669
+ onRetry ? /* @__PURE__ */ jsx(EmptyAction, { children: /* @__PURE__ */ jsxs(Button, { size: "sm", variant: "outline", onClick: onRetry, children: [
670
+ /* @__PURE__ */ jsx(WifiOff, { className: "size-4" }),
671
+ retryLabel
672
+ ] }) }) : null
673
+ ] });
674
+ }
675
+ function getChartState(state, hasData, className) {
676
+ if (state.isLoading) {
677
+ return /* @__PURE__ */ jsx(ChartState, { ...state, type: "loading", className });
678
+ }
679
+ if (state.error) {
680
+ return /* @__PURE__ */ jsx(ChartState, { ...state, type: "error", className });
681
+ }
682
+ if (!hasData) {
683
+ return /* @__PURE__ */ jsx(ChartState, { ...state, type: "empty", className });
684
+ }
685
+ return null;
686
+ }
687
+ function ChartCard({
688
+ title,
689
+ description,
690
+ action,
691
+ footer,
692
+ children,
693
+ className,
694
+ contentClassName,
695
+ ...props
696
+ }) {
697
+ return /* @__PURE__ */ jsxs(Card, { className: cn("overflow-hidden", className), ...props, children: [
698
+ /* @__PURE__ */ jsxs(CardHeader, { children: [
699
+ /* @__PURE__ */ jsx(CardTitle, { children: title }),
700
+ description ? /* @__PURE__ */ jsx(CardDescription, { children: description }) : null,
701
+ action ? /* @__PURE__ */ jsx(CardAction, { children: action }) : null
702
+ ] }),
703
+ /* @__PURE__ */ jsx(CardContent, { className: contentClassName, children }),
704
+ footer ? /* @__PURE__ */ jsx(CardFooter, { children: footer }) : null
705
+ ] });
706
+ }
707
+ function DashboardBarChart({
708
+ data,
709
+ config,
710
+ indexKey = "name",
711
+ series,
712
+ colors,
713
+ stacked = false,
714
+ showGrid = true,
715
+ showLegend = true,
716
+ valueFormatter = formatTick,
717
+ isLoading,
718
+ error,
719
+ onRetry,
720
+ retryLabel,
721
+ emptyTitle,
722
+ emptyDescription,
723
+ errorTitle,
724
+ errorDescription,
725
+ loadingLabel,
726
+ stateClassName,
727
+ className,
728
+ ...props
729
+ }) {
730
+ const chartSeries = getChartSeries(config, series);
731
+ const chartConfig = getChartConfigWithColors(
732
+ config,
733
+ chartSeries.map((item) => item.key),
734
+ colors
735
+ );
736
+ const chartState = getChartState(
737
+ {
738
+ isLoading,
739
+ error,
740
+ onRetry,
741
+ retryLabel,
742
+ emptyTitle,
743
+ emptyDescription,
744
+ errorTitle,
745
+ errorDescription,
746
+ loadingLabel
747
+ },
748
+ hasChartData(data, chartSeries),
749
+ cn("h-[320px]", stateClassName)
750
+ );
751
+ if (chartState) {
752
+ return chartState;
753
+ }
754
+ return /* @__PURE__ */ jsx(
755
+ ChartContainer,
756
+ {
757
+ config: chartConfig,
758
+ className: cn("h-[320px] w-full", className),
759
+ ...props,
760
+ children: /* @__PURE__ */ jsxs(RechartsPrimitive.BarChart, { data, accessibilityLayer: true, children: [
761
+ showGrid ? /* @__PURE__ */ jsx(RechartsPrimitive.CartesianGrid, { vertical: false }) : null,
762
+ /* @__PURE__ */ jsx(
763
+ RechartsPrimitive.XAxis,
764
+ {
765
+ dataKey: indexKey,
766
+ tickLine: false,
767
+ axisLine: false,
768
+ tickMargin: 8
769
+ }
770
+ ),
771
+ /* @__PURE__ */ jsx(
772
+ RechartsPrimitive.YAxis,
773
+ {
774
+ tickLine: false,
775
+ axisLine: false,
776
+ tickMargin: 8,
777
+ tickFormatter: valueFormatter
778
+ }
779
+ ),
780
+ /* @__PURE__ */ jsx(ChartTooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) }),
781
+ showLegend ? /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }) : null,
782
+ chartSeries.map((item) => /* @__PURE__ */ jsx(
783
+ RechartsPrimitive.Bar,
784
+ {
785
+ dataKey: item.key,
786
+ fill: `var(--color-${item.key})`,
787
+ radius: [4, 4, 0, 0],
788
+ stackId: stacked ? item.stackId || "total" : item.stackId
789
+ },
790
+ item.key
791
+ ))
792
+ ] })
793
+ }
794
+ );
795
+ }
796
+ function DashboardLineChart({
797
+ data,
798
+ config,
799
+ indexKey = "name",
800
+ series,
801
+ colors,
802
+ showDots = false,
803
+ showGrid = true,
804
+ showLegend = true,
805
+ valueFormatter = formatTick,
806
+ isLoading,
807
+ error,
808
+ onRetry,
809
+ retryLabel,
810
+ emptyTitle,
811
+ emptyDescription,
812
+ errorTitle,
813
+ errorDescription,
814
+ loadingLabel,
815
+ stateClassName,
816
+ className,
817
+ ...props
818
+ }) {
819
+ const chartSeries = getChartSeries(config, series);
820
+ const chartConfig = getChartConfigWithColors(
821
+ config,
822
+ chartSeries.map((item) => item.key),
823
+ colors
824
+ );
825
+ const chartState = getChartState(
826
+ {
827
+ isLoading,
828
+ error,
829
+ onRetry,
830
+ retryLabel,
831
+ emptyTitle,
832
+ emptyDescription,
833
+ errorTitle,
834
+ errorDescription,
835
+ loadingLabel
836
+ },
837
+ hasChartData(data, chartSeries),
838
+ cn("h-[320px]", stateClassName)
839
+ );
840
+ if (chartState) {
841
+ return chartState;
842
+ }
843
+ return /* @__PURE__ */ jsx(
844
+ ChartContainer,
845
+ {
846
+ config: chartConfig,
847
+ className: cn("h-[320px] w-full", className),
848
+ ...props,
849
+ children: /* @__PURE__ */ jsxs(RechartsPrimitive.LineChart, { data, accessibilityLayer: true, children: [
850
+ showGrid ? /* @__PURE__ */ jsx(RechartsPrimitive.CartesianGrid, { vertical: false }) : null,
851
+ /* @__PURE__ */ jsx(
852
+ RechartsPrimitive.XAxis,
853
+ {
854
+ dataKey: indexKey,
855
+ tickLine: false,
856
+ axisLine: false,
857
+ tickMargin: 8
858
+ }
859
+ ),
860
+ /* @__PURE__ */ jsx(
861
+ RechartsPrimitive.YAxis,
862
+ {
863
+ tickLine: false,
864
+ axisLine: false,
865
+ tickMargin: 8,
866
+ tickFormatter: valueFormatter
867
+ }
868
+ ),
869
+ /* @__PURE__ */ jsx(ChartTooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, { indicator: "line" }) }),
870
+ showLegend ? /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }) : null,
871
+ chartSeries.map((item) => /* @__PURE__ */ jsx(
872
+ RechartsPrimitive.Line,
873
+ {
874
+ type: "monotone",
875
+ dataKey: item.key,
876
+ stroke: `var(--color-${item.key})`,
877
+ strokeWidth: 2,
878
+ dot: showDots ? { r: 3, fill: `var(--color-${item.key})` } : false,
879
+ activeDot: { r: 5 },
880
+ yAxisId: item.yAxisId
881
+ },
882
+ item.key
883
+ ))
884
+ ] })
885
+ }
886
+ );
887
+ }
888
+ function HorizontalBarChart({
889
+ data,
890
+ config,
891
+ indexKey = "name",
892
+ series,
893
+ colors,
894
+ stacked = false,
895
+ categoryWidth = 96,
896
+ showGrid = true,
897
+ showLegend = true,
898
+ valueFormatter = formatTick,
899
+ isLoading,
900
+ error,
901
+ onRetry,
902
+ retryLabel,
903
+ emptyTitle,
904
+ emptyDescription,
905
+ errorTitle,
906
+ errorDescription,
907
+ loadingLabel,
908
+ stateClassName,
909
+ className,
910
+ ...props
911
+ }) {
912
+ const chartSeries = getChartSeries(config, series);
913
+ const chartConfig = getChartConfigWithColors(
914
+ config,
915
+ chartSeries.map((item) => item.key),
916
+ colors
917
+ );
918
+ const chartState = getChartState(
919
+ {
920
+ isLoading,
921
+ error,
922
+ onRetry,
923
+ retryLabel,
924
+ emptyTitle,
925
+ emptyDescription,
926
+ errorTitle,
927
+ errorDescription,
928
+ loadingLabel
929
+ },
930
+ hasChartData(data, chartSeries),
931
+ cn("h-[320px]", stateClassName)
932
+ );
933
+ if (chartState) {
934
+ return chartState;
935
+ }
936
+ return /* @__PURE__ */ jsx(
937
+ ChartContainer,
938
+ {
939
+ config: chartConfig,
940
+ className: cn("h-[320px] w-full", className),
941
+ ...props,
942
+ children: /* @__PURE__ */ jsxs(
943
+ RechartsPrimitive.BarChart,
944
+ {
945
+ data,
946
+ layout: "vertical",
947
+ accessibilityLayer: true,
948
+ margin: { left: 8, right: 16 },
949
+ children: [
950
+ showGrid ? /* @__PURE__ */ jsx(RechartsPrimitive.CartesianGrid, { horizontal: false }) : null,
951
+ /* @__PURE__ */ jsx(
952
+ RechartsPrimitive.XAxis,
953
+ {
954
+ type: "number",
955
+ tickLine: false,
956
+ axisLine: false,
957
+ tickMargin: 8,
958
+ tickFormatter: valueFormatter
959
+ }
960
+ ),
961
+ /* @__PURE__ */ jsx(
962
+ RechartsPrimitive.YAxis,
963
+ {
964
+ dataKey: indexKey,
965
+ type: "category",
966
+ tickLine: false,
967
+ axisLine: false,
968
+ tickMargin: 8,
969
+ width: categoryWidth
970
+ }
971
+ ),
972
+ /* @__PURE__ */ jsx(ChartTooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) }),
973
+ showLegend ? /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }) : null,
974
+ chartSeries.map((item) => /* @__PURE__ */ jsx(
975
+ RechartsPrimitive.Bar,
976
+ {
977
+ dataKey: item.key,
978
+ fill: `var(--color-${item.key})`,
979
+ radius: [0, 4, 4, 0],
980
+ stackId: stacked ? item.stackId || "total" : item.stackId
981
+ },
982
+ item.key
983
+ ))
984
+ ]
985
+ }
986
+ )
987
+ }
988
+ );
989
+ }
990
+ function InteractiveTimeSeriesChart({
991
+ data,
992
+ config,
993
+ indexKey = "date",
994
+ series,
995
+ colors,
996
+ periods = defaultPeriods,
997
+ defaultPeriod = ((_a) => (_a = periods[1]) == null ? void 0 : _a.value)() || ((_b) => (_b = periods[0]) == null ? void 0 : _b.value)() || "30d",
998
+ defaultSeries,
999
+ filterData = defaultFilterData,
1000
+ showGrid = true,
1001
+ showLegend = false,
1002
+ valueFormatter = formatTick,
1003
+ isLoading,
1004
+ error,
1005
+ onRetry,
1006
+ retryLabel,
1007
+ emptyTitle,
1008
+ emptyDescription,
1009
+ errorTitle,
1010
+ errorDescription,
1011
+ loadingLabel,
1012
+ stateClassName,
1013
+ className,
1014
+ ...props
1015
+ }) {
1016
+ var _a2;
1017
+ const chartSeries = getChartSeries(config, series);
1018
+ const chartConfig = getChartConfigWithColors(
1019
+ config,
1020
+ chartSeries.map((item) => item.key),
1021
+ colors
1022
+ );
1023
+ const [period, setPeriod] = React.useState(defaultPeriod);
1024
+ const [activeSeries, setActiveSeries] = React.useState(
1025
+ defaultSeries || ((_a2 = chartSeries[0]) == null ? void 0 : _a2.key) || ""
1026
+ );
1027
+ const filteredData = React.useMemo(
1028
+ () => filterData(data, period),
1029
+ [data, filterData, period]
1030
+ );
1031
+ const visibleSeries = chartSeries.length > 1 ? chartSeries.filter((item) => item.key === activeSeries) : chartSeries;
1032
+ const chartState = getChartState(
1033
+ {
1034
+ isLoading,
1035
+ error,
1036
+ onRetry,
1037
+ retryLabel,
1038
+ emptyTitle,
1039
+ emptyDescription,
1040
+ errorTitle,
1041
+ errorDescription,
1042
+ loadingLabel
1043
+ },
1044
+ hasChartData(filteredData, visibleSeries),
1045
+ cn("h-[320px]", stateClassName)
1046
+ );
1047
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
1048
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between", children: [
1049
+ chartSeries.length > 1 ? /* @__PURE__ */ jsx(Tabs, { value: activeSeries, onValueChange: setActiveSeries, children: /* @__PURE__ */ jsx(TabsList, { className: "h-10", children: chartSeries.map((item) => {
1050
+ var _a3;
1051
+ return /* @__PURE__ */ jsx(TabsTrigger, { value: item.key, className: "h-10", children: item.label || ((_a3 = config[item.key]) == null ? void 0 : _a3.label) || item.key }, item.key);
1052
+ }) }) }) : /* @__PURE__ */ jsx("div", {}),
1053
+ /* @__PURE__ */ jsxs(Select, { value: period, onValueChange: setPeriod, children: [
1054
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full sm:w-[160px]", size: "sm", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Period" }) }),
1055
+ /* @__PURE__ */ jsx(SelectContent, { children: periods.map((item) => /* @__PURE__ */ jsx(SelectItem, { value: item.value, children: item.label }, item.value)) })
1056
+ ] })
1057
+ ] }),
1058
+ chartState || /* @__PURE__ */ jsx(
1059
+ ChartContainer,
1060
+ {
1061
+ config: chartConfig,
1062
+ className: cn("h-[320px] w-full", className),
1063
+ ...props,
1064
+ children: /* @__PURE__ */ jsxs(RechartsPrimitive.AreaChart, { data: filteredData, accessibilityLayer: true, children: [
1065
+ showGrid ? /* @__PURE__ */ jsx(RechartsPrimitive.CartesianGrid, { vertical: false }) : null,
1066
+ /* @__PURE__ */ jsx(
1067
+ RechartsPrimitive.XAxis,
1068
+ {
1069
+ dataKey: indexKey,
1070
+ tickLine: false,
1071
+ axisLine: false,
1072
+ tickMargin: 8
1073
+ }
1074
+ ),
1075
+ /* @__PURE__ */ jsx(
1076
+ RechartsPrimitive.YAxis,
1077
+ {
1078
+ tickLine: false,
1079
+ axisLine: false,
1080
+ tickMargin: 8,
1081
+ tickFormatter: valueFormatter
1082
+ }
1083
+ ),
1084
+ /* @__PURE__ */ jsx(ChartTooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, { indicator: "line" }) }),
1085
+ showLegend ? /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }) : null,
1086
+ visibleSeries.map((item) => /* @__PURE__ */ jsx(
1087
+ RechartsPrimitive.Area,
1088
+ {
1089
+ type: "monotone",
1090
+ dataKey: item.key,
1091
+ stroke: `var(--color-${item.key})`,
1092
+ fill: `var(--color-${item.key})`,
1093
+ fillOpacity: 0.16,
1094
+ strokeWidth: 2,
1095
+ dot: false
1096
+ },
1097
+ item.key
1098
+ ))
1099
+ ] })
1100
+ }
1101
+ )
1102
+ ] });
1103
+ }
1104
+ function ComboMetricChart({
1105
+ data,
1106
+ config,
1107
+ indexKey = "name",
1108
+ series,
1109
+ colors,
1110
+ showGrid = true,
1111
+ showLegend = true,
1112
+ valueFormatter = formatTick,
1113
+ isLoading,
1114
+ error,
1115
+ onRetry,
1116
+ retryLabel,
1117
+ emptyTitle,
1118
+ emptyDescription,
1119
+ errorTitle,
1120
+ errorDescription,
1121
+ loadingLabel,
1122
+ stateClassName,
1123
+ className,
1124
+ ...props
1125
+ }) {
1126
+ const chartSeries = getChartSeries(config, series);
1127
+ const chartConfig = getChartConfigWithColors(
1128
+ config,
1129
+ chartSeries.map((item) => item.key),
1130
+ colors
1131
+ );
1132
+ const chartState = getChartState(
1133
+ {
1134
+ isLoading,
1135
+ error,
1136
+ onRetry,
1137
+ retryLabel,
1138
+ emptyTitle,
1139
+ emptyDescription,
1140
+ errorTitle,
1141
+ errorDescription,
1142
+ loadingLabel
1143
+ },
1144
+ hasChartData(data, chartSeries),
1145
+ cn("h-[340px]", stateClassName)
1146
+ );
1147
+ if (chartState) {
1148
+ return chartState;
1149
+ }
1150
+ return /* @__PURE__ */ jsx(
1151
+ ChartContainer,
1152
+ {
1153
+ config: chartConfig,
1154
+ className: cn("h-[340px] w-full", className),
1155
+ ...props,
1156
+ children: /* @__PURE__ */ jsxs(RechartsPrimitive.ComposedChart, { data, accessibilityLayer: true, children: [
1157
+ showGrid ? /* @__PURE__ */ jsx(RechartsPrimitive.CartesianGrid, { vertical: false }) : null,
1158
+ /* @__PURE__ */ jsx(
1159
+ RechartsPrimitive.XAxis,
1160
+ {
1161
+ dataKey: indexKey,
1162
+ tickLine: false,
1163
+ axisLine: false,
1164
+ tickMargin: 8
1165
+ }
1166
+ ),
1167
+ /* @__PURE__ */ jsx(
1168
+ RechartsPrimitive.YAxis,
1169
+ {
1170
+ tickLine: false,
1171
+ axisLine: false,
1172
+ tickMargin: 8,
1173
+ tickFormatter: valueFormatter
1174
+ }
1175
+ ),
1176
+ /* @__PURE__ */ jsx(ChartTooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) }),
1177
+ showLegend ? /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }) : null,
1178
+ chartSeries.map(
1179
+ (item) => item.type === "line" ? /* @__PURE__ */ jsx(
1180
+ RechartsPrimitive.Line,
1181
+ {
1182
+ type: "monotone",
1183
+ dataKey: item.key,
1184
+ stroke: `var(--color-${item.key})`,
1185
+ strokeWidth: 2,
1186
+ dot: false,
1187
+ yAxisId: item.yAxisId
1188
+ },
1189
+ item.key
1190
+ ) : item.type === "area" ? /* @__PURE__ */ jsx(
1191
+ RechartsPrimitive.Area,
1192
+ {
1193
+ type: "monotone",
1194
+ dataKey: item.key,
1195
+ stroke: `var(--color-${item.key})`,
1196
+ fill: `var(--color-${item.key})`,
1197
+ fillOpacity: 0.12,
1198
+ strokeWidth: 2,
1199
+ dot: false,
1200
+ yAxisId: item.yAxisId
1201
+ },
1202
+ item.key
1203
+ ) : /* @__PURE__ */ jsx(
1204
+ RechartsPrimitive.Bar,
1205
+ {
1206
+ dataKey: item.key,
1207
+ fill: `var(--color-${item.key})`,
1208
+ radius: [4, 4, 0, 0],
1209
+ yAxisId: item.yAxisId
1210
+ },
1211
+ item.key
1212
+ )
1213
+ )
1214
+ ] })
1215
+ }
1216
+ );
1217
+ }
1218
+ function DonutBreakdownChart({
1219
+ data,
1220
+ config,
1221
+ nameKey = "name",
1222
+ valueKey = "value",
1223
+ colors,
1224
+ centerLabel,
1225
+ centerValue,
1226
+ showLegend = true,
1227
+ isLoading,
1228
+ error,
1229
+ onRetry,
1230
+ retryLabel,
1231
+ emptyTitle,
1232
+ emptyDescription,
1233
+ errorTitle,
1234
+ errorDescription,
1235
+ loadingLabel,
1236
+ stateClassName,
1237
+ className,
1238
+ ...props
1239
+ }) {
1240
+ const [activeIndex, setActiveIndex] = React.useState(0);
1241
+ const chartKeys = data.map(
1242
+ (entry, index) => String(entry[nameKey] || `segment-${index}`)
1243
+ );
1244
+ const chartConfig = getChartConfigWithColors(config, chartKeys, colors);
1245
+ const chartState = getChartState(
1246
+ {
1247
+ isLoading,
1248
+ error,
1249
+ onRetry,
1250
+ retryLabel,
1251
+ emptyTitle,
1252
+ emptyDescription,
1253
+ errorTitle,
1254
+ errorDescription,
1255
+ loadingLabel
1256
+ },
1257
+ hasPieData(data, nameKey, valueKey),
1258
+ cn("h-[320px]", stateClassName)
1259
+ );
1260
+ if (chartState) {
1261
+ return chartState;
1262
+ }
1263
+ return /* @__PURE__ */ jsx(
1264
+ ChartContainer,
1265
+ {
1266
+ config: chartConfig,
1267
+ className: cn("h-[320px] w-full", className),
1268
+ ...props,
1269
+ children: /* @__PURE__ */ jsxs(RechartsPrimitive.PieChart, { accessibilityLayer: true, children: [
1270
+ /* @__PURE__ */ jsx(
1271
+ ChartTooltip,
1272
+ {
1273
+ cursor: false,
1274
+ content: /* @__PURE__ */ jsx(ChartTooltipContent, { hideLabel: true, nameKey })
1275
+ }
1276
+ ),
1277
+ showLegend ? /* @__PURE__ */ jsx(
1278
+ ChartLegend,
1279
+ {
1280
+ content: /* @__PURE__ */ jsx(ChartLegendContent, { nameKey }),
1281
+ verticalAlign: "bottom"
1282
+ }
1283
+ ) : null,
1284
+ /* @__PURE__ */ jsxs(
1285
+ RechartsPrimitive.Pie,
1286
+ {
1287
+ data,
1288
+ dataKey: valueKey,
1289
+ nameKey,
1290
+ innerRadius: "58%",
1291
+ outerRadius: "82%",
1292
+ paddingAngle: 2,
1293
+ activeIndex,
1294
+ onMouseEnter: (_, index) => setActiveIndex(index),
1295
+ children: [
1296
+ data.map((entry, index) => {
1297
+ const key = String(entry[nameKey] || `segment-${index}`);
1298
+ return /* @__PURE__ */ jsx(
1299
+ RechartsPrimitive.Cell,
1300
+ {
1301
+ fill: `var(--color-${key})`,
1302
+ opacity: index === activeIndex ? 1 : 0.72
1303
+ },
1304
+ key
1305
+ );
1306
+ }),
1307
+ centerValue || centerLabel ? /* @__PURE__ */ jsx(
1308
+ RechartsPrimitive.Label,
1309
+ {
1310
+ position: "center",
1311
+ content: ({ viewBox }) => {
1312
+ if (!viewBox || !("cx" in viewBox) || !("cy" in viewBox)) {
1313
+ return null;
1314
+ }
1315
+ return /* @__PURE__ */ jsxs(
1316
+ "text",
1317
+ {
1318
+ x: viewBox.cx,
1319
+ y: viewBox.cy,
1320
+ textAnchor: "middle",
1321
+ dominantBaseline: "middle",
1322
+ children: [
1323
+ centerValue ? /* @__PURE__ */ jsx(
1324
+ "tspan",
1325
+ {
1326
+ x: viewBox.cx,
1327
+ y: viewBox.cy,
1328
+ className: "fill-foreground text-2xl font-semibold",
1329
+ children: centerValue
1330
+ }
1331
+ ) : null,
1332
+ centerLabel ? /* @__PURE__ */ jsx(
1333
+ "tspan",
1334
+ {
1335
+ x: viewBox.cx,
1336
+ y: Number(viewBox.cy) + 22,
1337
+ className: "fill-muted-foreground text-xs",
1338
+ children: centerLabel
1339
+ }
1340
+ ) : null
1341
+ ]
1342
+ }
1343
+ );
1344
+ }
1345
+ }
1346
+ ) : null
1347
+ ]
1348
+ }
1349
+ )
1350
+ ] })
1351
+ }
1352
+ );
1353
+ }
1354
+ function Table({ className, ...props }) {
1355
+ return /* @__PURE__ */ jsx(
1356
+ "div",
1357
+ {
1358
+ "data-slot": "table-container",
1359
+ className: "relative w-full overflow-x-auto",
1360
+ children: /* @__PURE__ */ jsx(
1361
+ "table",
1362
+ {
1363
+ "data-slot": "table",
1364
+ className: cn("w-full caption-bottom text-sm", className),
1365
+ ...props
1366
+ }
1367
+ )
1368
+ }
1369
+ );
1370
+ }
1371
+ function TableHeader({ className, ...props }) {
1372
+ return /* @__PURE__ */ jsx(
1373
+ "thead",
1374
+ {
1375
+ "data-slot": "table-header",
1376
+ className: cn("[&_tr]:border-b", className),
1377
+ ...props
1378
+ }
1379
+ );
1380
+ }
1381
+ function TableBody({ className, ...props }) {
1382
+ return /* @__PURE__ */ jsx(
1383
+ "tbody",
1384
+ {
1385
+ "data-slot": "table-body",
1386
+ className: cn("[&_tr:last-child]:border-0", className),
1387
+ ...props
1388
+ }
1389
+ );
1390
+ }
1391
+ function TableFooter({ className, ...props }) {
1392
+ return /* @__PURE__ */ jsx(
1393
+ "tfoot",
1394
+ {
1395
+ "data-slot": "table-footer",
1396
+ className: cn(
1397
+ "bg-muted/50 border-t font-medium [&>tr]:last:border-b-0",
1398
+ className
1399
+ ),
1400
+ ...props
1401
+ }
1402
+ );
1403
+ }
1404
+ function TableRow({ className, ...props }) {
1405
+ return /* @__PURE__ */ jsx(
1406
+ "tr",
1407
+ {
1408
+ "data-slot": "table-row",
1409
+ className: cn(
1410
+ "hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",
1411
+ className
1412
+ ),
1413
+ ...props
1414
+ }
1415
+ );
1416
+ }
1417
+ function TableHead({ className, ...props }) {
1418
+ return /* @__PURE__ */ jsx(
1419
+ "th",
1420
+ {
1421
+ "data-slot": "table-head",
1422
+ className: cn(
1423
+ "text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
1424
+ className
1425
+ ),
1426
+ ...props
1427
+ }
1428
+ );
1429
+ }
1430
+ function TableCell({ className, ...props }) {
1431
+ return /* @__PURE__ */ jsx(
1432
+ "td",
1433
+ {
1434
+ "data-slot": "table-cell",
1435
+ className: cn(
1436
+ "p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
1437
+ className
1438
+ ),
1439
+ ...props
1440
+ }
1441
+ );
1442
+ }
1443
+ function TableCaption({
1444
+ className,
1445
+ ...props
1446
+ }) {
1447
+ return /* @__PURE__ */ jsx(
1448
+ "caption",
1449
+ {
1450
+ "data-slot": "table-caption",
1451
+ className: cn("text-muted-foreground mt-4 text-sm", className),
1452
+ ...props
1453
+ }
1454
+ );
1455
+ }
1456
+ function Dialog({
1457
+ ...props
1458
+ }) {
1459
+ return /* @__PURE__ */ jsx(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
1460
+ }
1461
+ function DialogTrigger({
1462
+ ...props
1463
+ }) {
1464
+ return /* @__PURE__ */ jsx(DialogPrimitive.Trigger, { "data-slot": "dialog-trigger", ...props });
1465
+ }
1466
+ function DialogPortal({
1467
+ ...props
1468
+ }) {
1469
+ return /* @__PURE__ */ jsx(DialogPrimitive.Portal, { "data-slot": "dialog-portal", ...props });
1470
+ }
1471
+ function DialogClose({
1472
+ ...props
1473
+ }) {
1474
+ return /* @__PURE__ */ jsx(DialogPrimitive.Close, { "data-slot": "dialog-close", ...props });
1475
+ }
1476
+ const DialogOverlay = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1477
+ DialogPrimitive.Overlay,
1478
+ {
1479
+ ref,
1480
+ "data-slot": "dialog-overlay",
1481
+ className: cn(
1482
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/40 backdrop-blur-sm",
1483
+ className
1484
+ ),
1485
+ ...props
1486
+ }
1487
+ ));
1488
+ DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
1489
+ const dialogVariants = cva(
1490
+ "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 flex flex-col w-full translate-x-[-50%] translate-y-[-50%] border shadow-elevation-sm duration-200 rounded-[var(--radius-card)] overflow-hidden max-h-[calc(100dvh-2rem)]",
1491
+ {
1492
+ variants: {
1493
+ size: {
1494
+ sm: "max-w-sm",
1495
+ md: "max-w-md",
1496
+ lg: "max-w-lg",
1497
+ xl: "max-w-xl",
1498
+ "2xl": "max-w-2xl",
1499
+ "3xl": "max-w-3xl",
1500
+ "4xl": "max-w-4xl",
1501
+ "5xl": "max-w-5xl",
1502
+ full: "max-w-[calc(100vw-2rem)] h-[calc(100dvh-2rem)]"
1503
+ }
1504
+ },
1505
+ defaultVariants: {
1506
+ size: "lg"
1507
+ }
1508
+ }
1509
+ );
1510
+ const DialogContent = React.forwardRef(({ className, children, size, showClose = true, ...props }, ref) => /* @__PURE__ */ jsxs(DialogPortal, { "data-slot": "dialog-portal", children: [
1511
+ /* @__PURE__ */ jsx(DialogOverlay, {}),
1512
+ /* @__PURE__ */ jsxs(
1513
+ DialogPrimitive.Content,
1514
+ {
1515
+ ref,
1516
+ "data-slot": "dialog-content",
1517
+ className: cn(dialogVariants({ size }), className),
1518
+ ...props,
1519
+ children: [
1520
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-4 p-6 overflow-y-auto flex-1 min-h-0", children }),
1521
+ showClose && /* @__PURE__ */ jsxs(DialogPrimitive.Close, { className: "absolute top-4 right-4 z-10 rounded-full p-2 opacity-70 transition-all hover:opacity-100 hover:bg-accent focus:ring-2 focus:ring-primary focus:ring-offset-2 focus:outline-none disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", children: [
1522
+ /* @__PURE__ */ jsx(XIcon, {}),
1523
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
1524
+ ] })
1525
+ ]
1526
+ }
1527
+ )
1528
+ ] }));
1529
+ DialogContent.displayName = DialogPrimitive.Content.displayName;
1530
+ function DialogHeader({ className, ...props }) {
1531
+ return /* @__PURE__ */ jsx(
1532
+ "div",
1533
+ {
1534
+ "data-slot": "dialog-header",
1535
+ className: cn("flex flex-col gap-2 text-left shrink-0", className),
1536
+ ...props
1537
+ }
1538
+ );
1539
+ }
1540
+ function DialogBody({ className, ...props }) {
1541
+ return /* @__PURE__ */ jsx(
1542
+ "div",
1543
+ {
1544
+ "data-slot": "dialog-body",
1545
+ className: cn("flex-1 overflow-y-auto min-h-0 -mx-6 px-6", className),
1546
+ ...props
1547
+ }
1548
+ );
1549
+ }
1550
+ function DialogFooter({ className, ...props }) {
1551
+ return /* @__PURE__ */ jsx(
1552
+ "div",
1553
+ {
1554
+ "data-slot": "dialog-footer",
1555
+ className: cn(
1556
+ "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end shrink-0",
1557
+ className
1558
+ ),
1559
+ ...props
1560
+ }
1561
+ );
1562
+ }
1563
+ function DialogTitle({
1564
+ className,
1565
+ ...props
1566
+ }) {
1567
+ return /* @__PURE__ */ jsx(
1568
+ DialogPrimitive.Title,
1569
+ {
1570
+ "data-slot": "dialog-title",
1571
+ className: cn("text-foreground font-semibold leading-tight text-[length:var(--text-h4)]", className),
1572
+ ...props
1573
+ }
1574
+ );
1575
+ }
1576
+ function DialogDescription({
1577
+ className,
1578
+ ...props
1579
+ }) {
1580
+ return /* @__PURE__ */ jsx(
1581
+ DialogPrimitive.Description,
1582
+ {
1583
+ "data-slot": "dialog-description",
1584
+ className: cn("text-muted-foreground", className),
1585
+ ...props
1586
+ }
1587
+ );
1588
+ }
1589
+ const Textarea = React.forwardRef(
1590
+ ({ className, size = "md", ...props }, ref) => {
1591
+ const sizeClasses = {
1592
+ sm: "px-2 py-1 text-sm",
1593
+ md: "px-3 py-2 text-base",
1594
+ lg: "px-4 py-3 text-base"
1595
+ };
1596
+ return /* @__PURE__ */ jsx(
1597
+ "textarea",
1598
+ {
1599
+ "data-slot": "textarea",
1600
+ className: cn(
1601
+ "flex min-h-16 w-full bg-background rounded-[var(--radius)] border border-border transition-colors outline-none resize-none text-foreground",
1602
+ "placeholder:text-muted-foreground",
1603
+ "focus:ring-2 focus:ring-primary focus:border-transparent",
1604
+ "disabled:cursor-not-allowed disabled:opacity-50",
1605
+ sizeClasses[size],
1606
+ className
1607
+ ),
1608
+ ref,
1609
+ ...props
1610
+ }
1611
+ );
1612
+ }
1613
+ );
1614
+ Textarea.displayName = "Textarea";
1615
+ function RichTextEditor({
1616
+ value,
1617
+ onChange,
1618
+ placeholder,
1619
+ className,
1620
+ actionButton,
1621
+ allowSearch = true,
1622
+ allowLinks = true,
1623
+ allowUndoRedo = true,
1624
+ allowHeadings = true,
1625
+ allowFormatting = true,
1626
+ allowAlignment = true,
1627
+ allowLists = true,
1628
+ showWordCount = true,
1629
+ showCharacterCount = true,
1630
+ disabled = false,
1631
+ readOnly = false,
1632
+ onFocus,
1633
+ onBlur,
1634
+ minHeight,
1635
+ maxHeight
1636
+ }) {
1637
+ const isEditable = !disabled && !readOnly;
1638
+ const showToolbar = isEditable;
1639
+ const editorRef = useRef(null);
1640
+ const [activeFormats, setActiveFormats] = useState({});
1641
+ const [isSearchOpen, setIsSearchOpen] = useState(false);
1642
+ const [searchQuery, setSearchQuery] = useState("");
1643
+ const [linkUrl, setLinkUrl] = useState("https://");
1644
+ const [isLinkOpen, setIsLinkOpen] = useState(false);
1645
+ const searchInputRef = useRef(null);
1646
+ const linkInputRef = useRef(null);
1647
+ const savedSelection = useRef(null);
1648
+ const findParentTag = (node, tagName) => {
1649
+ let current = node;
1650
+ while (current && current !== editorRef.current) {
1651
+ if (current.nodeName === tagName) return current;
1652
+ current = current.parentNode;
1653
+ }
1654
+ return null;
1655
+ };
1656
+ const updateActiveFormats = () => {
1657
+ let formatBlock = "";
1658
+ try {
1659
+ formatBlock = document.queryCommandValue("formatBlock");
1660
+ } catch (e) {
1661
+ }
1662
+ const selection = window.getSelection();
1663
+ const anchorNode = selection == null ? void 0 : selection.anchorNode;
1664
+ const focusNode = selection == null ? void 0 : selection.focusNode;
1665
+ setActiveFormats({
1666
+ bold: document.queryCommandState("bold"),
1667
+ italic: document.queryCommandState("italic"),
1668
+ underline: document.queryCommandState("underline"),
1669
+ justifyLeft: document.queryCommandState("justifyLeft"),
1670
+ justifyCenter: document.queryCommandState("justifyCenter"),
1671
+ justifyRight: document.queryCommandState("justifyRight"),
1672
+ insertUnorderedList: document.queryCommandState("insertUnorderedList"),
1673
+ insertOrderedList: document.queryCommandState("insertOrderedList"),
1674
+ link: !!(findParentTag(anchorNode || null, "A") || findParentTag(focusNode || null, "A")),
1675
+ h1: formatBlock === "h1" || formatBlock === "H1",
1676
+ h2: formatBlock === "h2" || formatBlock === "H2",
1677
+ h3: formatBlock === "h3" || formatBlock === "H3",
1678
+ p: formatBlock === "p" || formatBlock === "P" || formatBlock === "div" || formatBlock === "DIV" || formatBlock === ""
1679
+ });
1680
+ };
1681
+ const getCurrentBlockLabel = () => {
1682
+ if (activeFormats.h1) return /* @__PURE__ */ jsxs(Fragment, { children: [
1683
+ /* @__PURE__ */ jsx(Heading1, { className: "w-4 h-4 mr-1 shrink-0" }),
1684
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: "Título 1" })
1685
+ ] });
1686
+ if (activeFormats.h2) return /* @__PURE__ */ jsxs(Fragment, { children: [
1687
+ /* @__PURE__ */ jsx(Heading2, { className: "w-4 h-4 mr-1 shrink-0" }),
1688
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: "Título 2" })
1689
+ ] });
1690
+ if (activeFormats.h3) return /* @__PURE__ */ jsxs(Fragment, { children: [
1691
+ /* @__PURE__ */ jsx(Heading3, { className: "w-4 h-4 mr-1 shrink-0" }),
1692
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: "Título 3" })
1693
+ ] });
1694
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1695
+ /* @__PURE__ */ jsx(Type, { className: "w-4 h-4 mr-1 shrink-0" }),
1696
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: "Parágrafo" })
1697
+ ] });
1698
+ };
1699
+ useEffect(() => {
1700
+ if (editorRef.current && editorRef.current.innerHTML !== value) {
1701
+ editorRef.current.innerHTML = value;
1702
+ }
1703
+ const handleSelectionChange = () => {
1704
+ if (document.activeElement === editorRef.current) {
1705
+ updateActiveFormats();
1706
+ }
1707
+ };
1708
+ document.addEventListener("selectionchange", handleSelectionChange);
1709
+ return () => document.removeEventListener("selectionchange", handleSelectionChange);
1710
+ }, []);
1711
+ const execCommand = (command, value2 = "") => {
1712
+ var _a;
1713
+ document.execCommand(command, false, value2);
1714
+ updateActiveFormats();
1715
+ (_a = editorRef.current) == null ? void 0 : _a.focus();
1716
+ handleInput();
1717
+ };
1718
+ const handleInput = () => {
1719
+ if (editorRef.current) {
1720
+ onChange == null ? void 0 : onChange(editorRef.current.innerHTML);
1721
+ updateActiveFormats();
1722
+ }
1723
+ };
1724
+ const getWordCount = () => {
1725
+ var _a;
1726
+ const text = ((_a = editorRef.current) == null ? void 0 : _a.innerText) || "";
1727
+ return text.trim() ? text.trim().split(/\s+/).length : 0;
1728
+ };
1729
+ const getCharacterCount = () => {
1730
+ var _a;
1731
+ const text = ((_a = editorRef.current) == null ? void 0 : _a.innerText) || "";
1732
+ return text.trim() ? text.length : 0;
1733
+ };
1734
+ const performSearch = (text, backward = false) => {
1735
+ var _a, _b;
1736
+ if (!text || !editorRef.current) return;
1737
+ const editor = editorRef.current;
1738
+ const selection = window.getSelection();
1739
+ if (!selection) return;
1740
+ const walker = document.createTreeWalker(editor, NodeFilter.SHOW_TEXT);
1741
+ const segments = [];
1742
+ let offset = 0;
1743
+ let node;
1744
+ while (node = walker.nextNode()) {
1745
+ segments.push({ node, start: offset });
1746
+ offset += node.length;
1747
+ }
1748
+ const fullText = segments.reduce((acc, s) => acc + (s.node.textContent ?? ""), "");
1749
+ let searchFrom = 0;
1750
+ if (selection.rangeCount > 0) {
1751
+ const range2 = selection.getRangeAt(0);
1752
+ if (editor.contains(range2.startContainer)) {
1753
+ const seg = segments.find((s) => s.node === range2.startContainer);
1754
+ if (seg) {
1755
+ searchFrom = backward ? seg.start + range2.startOffset - 1 : seg.start + range2.endOffset;
1756
+ }
1757
+ }
1758
+ }
1759
+ const lowerFull = fullText.toLowerCase();
1760
+ const lowerQuery = text.toLowerCase();
1761
+ let matchStart = -1;
1762
+ if (backward) {
1763
+ matchStart = lowerFull.lastIndexOf(lowerQuery, Math.max(0, searchFrom));
1764
+ if (matchStart === -1) matchStart = lowerFull.lastIndexOf(lowerQuery);
1765
+ } else {
1766
+ matchStart = lowerFull.indexOf(lowerQuery, searchFrom);
1767
+ if (matchStart === -1) matchStart = lowerFull.indexOf(lowerQuery);
1768
+ }
1769
+ if (matchStart === -1) return;
1770
+ const matchEnd = matchStart + text.length;
1771
+ const range = document.createRange();
1772
+ let startSet = false;
1773
+ let endSet = false;
1774
+ for (let i = 0; i < segments.length && !endSet; i++) {
1775
+ const seg = segments[i];
1776
+ const segEnd = seg.start + seg.node.length;
1777
+ if (!startSet && matchStart < segEnd && matchStart >= seg.start) {
1778
+ range.setStart(seg.node, matchStart - seg.start);
1779
+ startSet = true;
1780
+ }
1781
+ if (startSet && matchEnd <= segEnd) {
1782
+ range.setEnd(seg.node, matchEnd - seg.start);
1783
+ endSet = true;
1784
+ }
1785
+ }
1786
+ if (startSet && endSet) {
1787
+ selection.removeAllRanges();
1788
+ selection.addRange(range);
1789
+ (_b = (_a = range.startContainer.parentElement) == null ? void 0 : _a.scrollIntoView) == null ? void 0 : _b.call(_a, { block: "nearest" });
1790
+ }
1791
+ };
1792
+ const handleCreateLink = () => {
1793
+ if (savedSelection.current) {
1794
+ const selection2 = window.getSelection();
1795
+ selection2 == null ? void 0 : selection2.removeAllRanges();
1796
+ selection2 == null ? void 0 : selection2.addRange(savedSelection.current);
1797
+ }
1798
+ const selection = window.getSelection();
1799
+ const anchorNode = selection == null ? void 0 : selection.anchorNode;
1800
+ const existingLink = findParentTag(anchorNode || null, "A");
1801
+ if (existingLink) {
1802
+ if (linkUrl) {
1803
+ existingLink.setAttribute("href", linkUrl);
1804
+ existingLink.setAttribute("target", "_blank");
1805
+ existingLink.setAttribute("rel", "noopener noreferrer");
1806
+ existingLink.style.color = "hsl(var(--primary))";
1807
+ existingLink.style.textDecoration = "underline";
1808
+ existingLink.style.cursor = "pointer";
1809
+ }
1810
+ handleInput();
1811
+ setIsLinkOpen(false);
1812
+ savedSelection.current = null;
1813
+ return;
1814
+ }
1815
+ if (!selection || selection.rangeCount === 0 || selection.isCollapsed) {
1816
+ return;
1817
+ }
1818
+ if (linkUrl) {
1819
+ execCommand("createLink", linkUrl);
1820
+ setTimeout(() => {
1821
+ var _a;
1822
+ const anchor = findParentTag(((_a = window.getSelection()) == null ? void 0 : _a.anchorNode) || null, "A");
1823
+ if (anchor) {
1824
+ anchor.setAttribute("target", "_blank");
1825
+ anchor.setAttribute("rel", "noopener noreferrer");
1826
+ anchor.style.color = "hsl(var(--primary))";
1827
+ anchor.style.textDecoration = "underline";
1828
+ anchor.style.cursor = "pointer";
1829
+ }
1830
+ handleInput();
1831
+ }, 10);
1832
+ setIsLinkOpen(false);
1833
+ savedSelection.current = null;
1834
+ }
1835
+ };
1836
+ const handleUnlink = () => {
1837
+ const selection = window.getSelection();
1838
+ const anchorNode = selection == null ? void 0 : selection.anchorNode;
1839
+ const existingLink = findParentTag(anchorNode || null, "A");
1840
+ if (existingLink) {
1841
+ const parent = existingLink.parentNode;
1842
+ while (existingLink.firstChild) {
1843
+ parent == null ? void 0 : parent.insertBefore(existingLink.firstChild, existingLink);
1844
+ }
1845
+ parent == null ? void 0 : parent.removeChild(existingLink);
1846
+ handleInput();
1847
+ } else {
1848
+ execCommand("unlink");
1849
+ }
1850
+ };
1851
+ const onLinkPopoverOpenChange = (open) => {
1852
+ if (open) {
1853
+ const selection = window.getSelection();
1854
+ const anchorNode = selection == null ? void 0 : selection.anchorNode;
1855
+ const focusNode = selection == null ? void 0 : selection.focusNode;
1856
+ const existingLink = findParentTag(anchorNode || null, "A") || findParentTag(focusNode || null, "A");
1857
+ if (existingLink) {
1858
+ setLinkUrl(existingLink.getAttribute("href") || "https://");
1859
+ } else {
1860
+ setLinkUrl("https://");
1861
+ }
1862
+ if (selection && selection.rangeCount > 0 && (!selection.isCollapsed || existingLink)) {
1863
+ savedSelection.current = selection.getRangeAt(0).cloneRange();
1864
+ } else {
1865
+ savedSelection.current = null;
1866
+ }
1867
+ setTimeout(() => {
1868
+ var _a;
1869
+ return (_a = linkInputRef.current) == null ? void 0 : _a.focus();
1870
+ }, 100);
1871
+ }
1872
+ setIsLinkOpen(open);
1873
+ };
1874
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col h-full w-full bg-background sm:border border-border sm:shadow-sm sm:rounded-lg overflow-hidden", disabled && "opacity-50 pointer-events-none", className), children: [
1875
+ /* @__PURE__ */ jsx("style", { children: `
1876
+ [contenteditable]:empty:before {
1877
+ content: attr(data-placeholder);
1878
+ color: hsl(var(--muted-foreground));
1879
+ pointer-events: none;
1880
+ display: block;
1881
+ }
1882
+ .prose-editor ul {
1883
+ list-style-type: disc !important;
1884
+ padding-left: 1.5rem !important;
1885
+ margin-top: 0.5rem !important;
1886
+ margin-bottom: 0.5rem !important;
1887
+ }
1888
+ .prose-editor ol {
1889
+ list-style-type: decimal !important;
1890
+ padding-left: 1.5rem !important;
1891
+ margin-top: 0.5rem !important;
1892
+ margin-bottom: 0.5rem !important;
1893
+ }
1894
+ .prose-editor b, .prose-editor strong {
1895
+ font-weight: 600 !important;
1896
+ }
1897
+ .prose-editor i, .prose-editor em {
1898
+ font-style: italic !important;
1899
+ }
1900
+ .prose-editor u {
1901
+ text-decoration: underline !important;
1902
+ }
1903
+ .prose-editor h1 {
1904
+ font-size: 2.25rem !important;
1905
+ font-weight: 700 !important;
1906
+ margin-bottom: 1.25rem !important;
1907
+ line-height: 1.2 !important;
1908
+ margin-top: 2rem !important;
1909
+ color: hsl(var(--foreground));
1910
+ }
1911
+ .prose-editor h2 {
1912
+ font-size: 1.75rem !important;
1913
+ font-weight: 600 !important;
1914
+ margin-bottom: 1rem !important;
1915
+ margin-top: 1.5rem !important;
1916
+ color: hsl(var(--foreground));
1917
+ }
1918
+ .prose-editor h3 {
1919
+ font-size: 1.35rem !important;
1920
+ font-weight: 600 !important;
1921
+ margin-bottom: 0.75rem !important;
1922
+ margin-top: 1.25rem !important;
1923
+ color: hsl(var(--foreground));
1924
+ }
1925
+ .prose-editor p {
1926
+ margin-bottom: 1rem !important;
1927
+ line-height: 1.6 !important;
1928
+ }
1929
+ .prose-editor a {
1930
+ color: var(--info) !important;
1931
+ text-decoration: underline !important;
1932
+ cursor: pointer !important;
1933
+ }
1934
+ .prose-editor h1:first-child, .prose-editor h2:first-child, .prose-editor h3:first-child, .prose-editor p:first-child {
1935
+ margin-top: 0 !important;
1936
+ }
1937
+ .prose-editor {
1938
+ outline: none !important;
1939
+ }
1940
+ ` }),
1941
+ showToolbar && /* @__PURE__ */ jsxs("div", { className: "px-3 py-2 border-b border-border bg-muted/30 flex items-center gap-1 flex-wrap shrink-0", children: [
1942
+ allowUndoRedo && /* @__PURE__ */ jsxs(Fragment, { children: [
1943
+ /* @__PURE__ */ jsx(
1944
+ Button,
1945
+ {
1946
+ variant: "ghost",
1947
+ size: "icon",
1948
+ className: "h-8 w-8 text-muted-foreground",
1949
+ onClick: () => execCommand("undo"),
1950
+ title: "Desfazer",
1951
+ "aria-label": "Desfazer",
1952
+ children: /* @__PURE__ */ jsx(Undo, { className: "w-4 h-4" })
1953
+ }
1954
+ ),
1955
+ /* @__PURE__ */ jsx(
1956
+ Button,
1957
+ {
1958
+ variant: "ghost",
1959
+ size: "icon",
1960
+ className: "h-8 w-8 text-muted-foreground",
1961
+ onClick: () => execCommand("redo"),
1962
+ title: "Refazer",
1963
+ "aria-label": "Refazer",
1964
+ children: /* @__PURE__ */ jsx(Redo, { className: "w-4 h-4" })
1965
+ }
1966
+ ),
1967
+ /* @__PURE__ */ jsx("div", { className: "w-px h-6 bg-border mx-1 hidden sm:block" })
1968
+ ] }),
1969
+ allowHeadings && /* @__PURE__ */ jsxs(Fragment, { children: [
1970
+ /* @__PURE__ */ jsxs(DropdownMenu, { modal: false, children: [
1971
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "ghost", size: "sm", className: "h-8 gap-0 text-muted-foreground w-[120px] justify-start px-2", children: [
1972
+ getCurrentBlockLabel(),
1973
+ /* @__PURE__ */ jsx(ChevronDown, { className: "w-3 h-3 ml-auto opacity-50 shrink-0" })
1974
+ ] }) }),
1975
+ /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "start", className: "w-[160px]", style: { zIndex: 9999 }, children: [
1976
+ /* @__PURE__ */ jsxs(DropdownMenuItem, { onPointerDown: (e) => e.preventDefault(), onClick: () => execCommand("formatBlock", "P"), className: "gap-2", children: [
1977
+ /* @__PURE__ */ jsx(Type, { className: "w-4 h-4 text-muted-foreground" }),
1978
+ " Parágrafo"
1979
+ ] }),
1980
+ /* @__PURE__ */ jsxs(DropdownMenuItem, { onPointerDown: (e) => e.preventDefault(), onClick: () => execCommand("formatBlock", "H1"), className: "gap-2", children: [
1981
+ /* @__PURE__ */ jsx(Heading1, { className: "w-4 h-4 text-muted-foreground" }),
1982
+ " Título 1"
1983
+ ] }),
1984
+ /* @__PURE__ */ jsxs(DropdownMenuItem, { onPointerDown: (e) => e.preventDefault(), onClick: () => execCommand("formatBlock", "H2"), className: "gap-2", children: [
1985
+ /* @__PURE__ */ jsx(Heading2, { className: "w-4 h-4 text-muted-foreground" }),
1986
+ " Título 2"
1987
+ ] }),
1988
+ /* @__PURE__ */ jsxs(DropdownMenuItem, { onPointerDown: (e) => e.preventDefault(), onClick: () => execCommand("formatBlock", "H3"), className: "gap-2", children: [
1989
+ /* @__PURE__ */ jsx(Heading3, { className: "w-4 h-4 text-muted-foreground" }),
1990
+ " Título 3"
1991
+ ] })
1992
+ ] })
1993
+ ] }),
1994
+ /* @__PURE__ */ jsx("div", { className: "w-px h-6 bg-border mx-1 hidden sm:block" })
1995
+ ] }),
1996
+ allowFormatting && /* @__PURE__ */ jsxs(Fragment, { children: [
1997
+ /* @__PURE__ */ jsx(
1998
+ Button,
1999
+ {
2000
+ variant: "ghost",
2001
+ size: "icon",
2002
+ className: cn("h-8 w-8 text-muted-foreground", activeFormats.bold && "bg-muted text-foreground"),
2003
+ onClick: () => execCommand("bold"),
2004
+ title: "Negrito",
2005
+ "aria-label": "Negrito",
2006
+ children: /* @__PURE__ */ jsx(Bold, { className: "w-4 h-4" })
2007
+ }
2008
+ ),
2009
+ /* @__PURE__ */ jsx(
2010
+ Button,
2011
+ {
2012
+ variant: "ghost",
2013
+ size: "icon",
2014
+ className: cn("h-8 w-8 text-muted-foreground", activeFormats.italic && "bg-muted text-foreground"),
2015
+ onClick: () => execCommand("italic"),
2016
+ title: "Itálico",
2017
+ "aria-label": "Itálico",
2018
+ children: /* @__PURE__ */ jsx(Italic, { className: "w-4 h-4" })
2019
+ }
2020
+ ),
2021
+ /* @__PURE__ */ jsx(
2022
+ Button,
2023
+ {
2024
+ variant: "ghost",
2025
+ size: "icon",
2026
+ className: cn("h-8 w-8 text-muted-foreground", activeFormats.underline && "bg-muted text-foreground"),
2027
+ onClick: () => execCommand("underline"),
2028
+ title: "Sublinhado",
2029
+ "aria-label": "Sublinhado",
2030
+ children: /* @__PURE__ */ jsx(Underline, { className: "w-4 h-4" })
2031
+ }
2032
+ ),
2033
+ /* @__PURE__ */ jsx("div", { className: "w-px h-6 bg-border mx-1 hidden sm:block" })
2034
+ ] }),
2035
+ allowAlignment && /* @__PURE__ */ jsxs(Fragment, { children: [
2036
+ /* @__PURE__ */ jsx(
2037
+ Button,
2038
+ {
2039
+ variant: "ghost",
2040
+ size: "icon",
2041
+ className: cn("h-8 w-8 text-muted-foreground", activeFormats.justifyLeft && "bg-muted text-foreground"),
2042
+ onClick: () => execCommand("justifyLeft"),
2043
+ title: "Alinhar à esquerda",
2044
+ "aria-label": "Alinhar à esquerda",
2045
+ children: /* @__PURE__ */ jsx(AlignLeft, { className: "w-4 h-4" })
2046
+ }
2047
+ ),
2048
+ /* @__PURE__ */ jsx(
2049
+ Button,
2050
+ {
2051
+ variant: "ghost",
2052
+ size: "icon",
2053
+ className: cn("h-8 w-8 text-muted-foreground", activeFormats.justifyCenter && "bg-muted text-foreground"),
2054
+ onClick: () => execCommand("justifyCenter"),
2055
+ title: "Centralizar",
2056
+ "aria-label": "Centralizar",
2057
+ children: /* @__PURE__ */ jsx(AlignCenter, { className: "w-4 h-4" })
2058
+ }
2059
+ ),
2060
+ /* @__PURE__ */ jsx(
2061
+ Button,
2062
+ {
2063
+ variant: "ghost",
2064
+ size: "icon",
2065
+ className: cn("h-8 w-8 text-muted-foreground", activeFormats.justifyRight && "bg-muted text-foreground"),
2066
+ onClick: () => execCommand("justifyRight"),
2067
+ title: "Alinhar à direita",
2068
+ "aria-label": "Alinhar à direita",
2069
+ children: /* @__PURE__ */ jsx(AlignRight, { className: "w-4 h-4" })
2070
+ }
2071
+ ),
2072
+ /* @__PURE__ */ jsx("div", { className: "w-px h-6 bg-border mx-1 hidden sm:block" })
2073
+ ] }),
2074
+ allowLists && /* @__PURE__ */ jsxs(Fragment, { children: [
2075
+ /* @__PURE__ */ jsx(
2076
+ Button,
2077
+ {
2078
+ variant: "ghost",
2079
+ size: "icon",
2080
+ className: cn("h-8 w-8 text-muted-foreground", activeFormats.insertUnorderedList && "bg-muted text-foreground"),
2081
+ onClick: () => execCommand("insertUnorderedList"),
2082
+ title: "Lista com marcadores",
2083
+ "aria-label": "Lista com marcadores",
2084
+ children: /* @__PURE__ */ jsx(List, { className: "w-4 h-4" })
2085
+ }
2086
+ ),
2087
+ /* @__PURE__ */ jsx(
2088
+ Button,
2089
+ {
2090
+ variant: "ghost",
2091
+ size: "icon",
2092
+ className: cn("h-8 w-8 text-muted-foreground", activeFormats.insertOrderedList && "bg-muted text-foreground"),
2093
+ onClick: () => execCommand("insertOrderedList"),
2094
+ title: "Lista numerada",
2095
+ "aria-label": "Lista numerada",
2096
+ children: /* @__PURE__ */ jsx(ListOrdered, { className: "w-4 h-4" })
2097
+ }
2098
+ ),
2099
+ /* @__PURE__ */ jsx("div", { className: "w-px h-6 bg-border mx-1 hidden sm:block" })
2100
+ ] }),
2101
+ allowLinks && /* @__PURE__ */ jsxs(Fragment, { children: [
2102
+ /* @__PURE__ */ jsxs(Popover, { open: isLinkOpen, onOpenChange: onLinkPopoverOpenChange, modal: false, children: [
2103
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
2104
+ Button,
2105
+ {
2106
+ variant: "ghost",
2107
+ size: "icon",
2108
+ className: cn("h-8 w-8 text-muted-foreground", (activeFormats.link || isLinkOpen) && "bg-muted text-foreground"),
2109
+ title: "Inserir link",
2110
+ "aria-label": "Inserir link",
2111
+ children: /* @__PURE__ */ jsx(Link, { className: "w-4 h-4" })
2112
+ }
2113
+ ) }),
2114
+ /* @__PURE__ */ jsx(PopoverContent, { className: "w-80 p-3", align: "start", style: { zIndex: 9999 }, children: !savedSelection.current && !activeFormats.link ? /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground py-1", children: "Selecione um texto para criar um link." }) : /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
2115
+ /* @__PURE__ */ jsx("div", { className: "text-xs font-medium", children: activeFormats.link ? "Editar Link" : "Inserir Link" }),
2116
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
2117
+ /* @__PURE__ */ jsx(
2118
+ Input,
2119
+ {
2120
+ ref: linkInputRef,
2121
+ placeholder: "https://...",
2122
+ value: linkUrl,
2123
+ onChange: (e) => setLinkUrl(e.target.value),
2124
+ onKeyDown: (e) => e.key === "Enter" && handleCreateLink(),
2125
+ className: "h-8 text-xs"
2126
+ }
2127
+ ),
2128
+ /* @__PURE__ */ jsx(Button, { size: "sm", className: "h-8", onClick: handleCreateLink, children: "Aplicar" })
2129
+ ] })
2130
+ ] }) })
2131
+ ] }),
2132
+ /* @__PURE__ */ jsx(
2133
+ Button,
2134
+ {
2135
+ variant: "ghost",
2136
+ size: "icon",
2137
+ className: "h-8 w-8 text-muted-foreground",
2138
+ onClick: handleUnlink,
2139
+ title: "Remover link",
2140
+ "aria-label": "Remover link",
2141
+ children: /* @__PURE__ */ jsx(X, { className: "w-4 h-4" })
2142
+ }
2143
+ ),
2144
+ /* @__PURE__ */ jsx("div", { className: "w-px h-6 bg-border mx-1 hidden sm:block" })
2145
+ ] }),
2146
+ (allowFormatting || allowHeadings || allowAlignment || allowLists || allowLinks) && /* @__PURE__ */ jsx(
2147
+ Button,
2148
+ {
2149
+ variant: "ghost",
2150
+ size: "icon",
2151
+ className: "h-8 w-8 text-muted-foreground",
2152
+ onClick: () => execCommand("removeFormat"),
2153
+ title: "Limpar formatação",
2154
+ "aria-label": "Limpar formatação",
2155
+ children: /* @__PURE__ */ jsx(Type, { className: "w-4 h-4" })
2156
+ }
2157
+ ),
2158
+ allowSearch && /* @__PURE__ */ jsx(
2159
+ Button,
2160
+ {
2161
+ variant: "ghost",
2162
+ size: "icon",
2163
+ className: cn("h-8 w-8 text-muted-foreground", isSearchOpen && "bg-muted text-foreground"),
2164
+ onClick: () => {
2165
+ setIsSearchOpen(!isSearchOpen);
2166
+ if (!isSearchOpen) setTimeout(() => {
2167
+ var _a;
2168
+ return (_a = searchInputRef.current) == null ? void 0 : _a.focus();
2169
+ }, 100);
2170
+ },
2171
+ title: "Buscar",
2172
+ "aria-label": "Buscar",
2173
+ children: /* @__PURE__ */ jsx(Search, { className: "w-4 h-4" })
2174
+ }
2175
+ ),
2176
+ actionButton && /* @__PURE__ */ jsxs(Fragment, { children: [
2177
+ /* @__PURE__ */ jsx("div", { className: "flex-1" }),
2178
+ actionButton
2179
+ ] })
2180
+ ] }),
2181
+ isSearchOpen && /* @__PURE__ */ jsxs("div", { className: "px-3 py-1.5 border-b border-border bg-muted/20 flex items-center gap-2", children: [
2182
+ /* @__PURE__ */ jsxs("div", { className: "relative flex-1 max-w-sm", children: [
2183
+ /* @__PURE__ */ jsx(Search, { className: "absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground" }),
2184
+ /* @__PURE__ */ jsx(
2185
+ Input,
2186
+ {
2187
+ ref: searchInputRef,
2188
+ placeholder: "Buscar no texto...",
2189
+ value: searchQuery,
2190
+ onChange: (e) => setSearchQuery(e.target.value),
2191
+ onKeyDown: (e) => {
2192
+ if (e.key === "Enter") {
2193
+ e.preventDefault();
2194
+ performSearch(searchQuery, e.shiftKey);
2195
+ }
2196
+ if (e.key === "Escape") {
2197
+ setIsSearchOpen(false);
2198
+ }
2199
+ },
2200
+ className: "h-8 pl-8 text-xs bg-background"
2201
+ }
2202
+ )
2203
+ ] }),
2204
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
2205
+ /* @__PURE__ */ jsx(
2206
+ Button,
2207
+ {
2208
+ variant: "ghost",
2209
+ size: "icon",
2210
+ className: "h-7 w-7",
2211
+ onMouseDown: (e) => e.preventDefault(),
2212
+ onClick: () => performSearch(searchQuery, true),
2213
+ title: "Anterior",
2214
+ children: /* @__PURE__ */ jsx(ChevronUp, { className: "w-4 h-4" })
2215
+ }
2216
+ ),
2217
+ /* @__PURE__ */ jsx(
2218
+ Button,
2219
+ {
2220
+ variant: "ghost",
2221
+ size: "icon",
2222
+ className: "h-7 w-7",
2223
+ onMouseDown: (e) => e.preventDefault(),
2224
+ onClick: () => performSearch(searchQuery, false),
2225
+ title: "Próximo",
2226
+ children: /* @__PURE__ */ jsx(ChevronDown, { className: "w-4 h-4" })
2227
+ }
2228
+ ),
2229
+ /* @__PURE__ */ jsx("div", { className: "w-px h-4 bg-border mx-1" }),
2230
+ /* @__PURE__ */ jsx(
2231
+ Button,
2232
+ {
2233
+ variant: "ghost",
2234
+ size: "icon",
2235
+ className: "h-7 w-7 text-muted-foreground hover:text-foreground",
2236
+ onClick: () => setIsSearchOpen(false),
2237
+ title: "Fechar busca",
2238
+ children: /* @__PURE__ */ jsx(X, { className: "w-4 h-4" })
2239
+ }
2240
+ )
2241
+ ] }),
2242
+ /* @__PURE__ */ jsx("div", { className: "hidden sm:block text-[10px] text-muted-foreground ml-auto uppercase tracking-wider font-medium", children: "Pressione Enter para buscar" })
2243
+ ] }),
2244
+ /* @__PURE__ */ jsx(
2245
+ "div",
2246
+ {
2247
+ className: "flex-1 overflow-y-auto p-4 sm:p-8 bg-background scrollbar-thin",
2248
+ style: { minHeight, maxHeight },
2249
+ children: /* @__PURE__ */ jsx(
2250
+ "div",
2251
+ {
2252
+ ref: editorRef,
2253
+ contentEditable: isEditable,
2254
+ onInput: handleInput,
2255
+ onSelect: isEditable ? updateActiveFormats : void 0,
2256
+ onFocus: () => {
2257
+ updateActiveFormats();
2258
+ onFocus == null ? void 0 : onFocus();
2259
+ },
2260
+ onBlur,
2261
+ className: "prose-editor min-h-full max-w-none focus:outline-none",
2262
+ "data-placeholder": placeholder
2263
+ }
2264
+ )
2265
+ }
2266
+ ),
2267
+ (showWordCount || showCharacterCount) && /* @__PURE__ */ jsxs("div", { className: "px-4 py-2 border-t border-border bg-muted/20 flex items-center justify-between", children: [
2268
+ /* @__PURE__ */ jsxs("div", { className: "text-[10px] sm:text-xs text-muted-foreground font-medium uppercase tracking-wider flex items-center gap-2", children: [
2269
+ showWordCount && /* @__PURE__ */ jsxs("span", { children: [
2270
+ getWordCount(),
2271
+ " ",
2272
+ getWordCount() === 1 ? "palavra" : "palavras"
2273
+ ] }),
2274
+ showWordCount && showCharacterCount && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground/40", children: "•" }),
2275
+ showCharacterCount && /* @__PURE__ */ jsxs("span", { children: [
2276
+ getCharacterCount(),
2277
+ " ",
2278
+ getCharacterCount() === 1 ? "caractere" : "caracteres"
2279
+ ] })
2280
+ ] }),
2281
+ /* @__PURE__ */ jsx("div", { className: "text-[10px] sm:text-xs text-muted-foreground/60 italic", children: "Auto-save ativo" })
2282
+ ] })
2283
+ ] });
2284
+ }
2285
+ export {
2286
+ TabsTrigger as $,
2287
+ Alert as A,
2288
+ DialogTitle as B,
2289
+ Card as C,
2290
+ DashboardBarChart as D,
2291
+ DialogTrigger as E,
2292
+ DonutBreakdownChart as F,
2293
+ Empty as G,
2294
+ EmptyAction as H,
2295
+ EmptyDescription as I,
2296
+ EmptyIcon as J,
2297
+ EmptyImage as K,
2298
+ EmptyTitle as L,
2299
+ HorizontalBarChart as M,
2300
+ InteractiveTimeSeriesChart as N,
2301
+ TableBody as O,
2302
+ TableCaption as P,
2303
+ TableCell as Q,
2304
+ RichTextEditor as R,
2305
+ Skeleton as S,
2306
+ Table as T,
2307
+ TableFooter as U,
2308
+ TableHead as V,
2309
+ TableHeader as W,
2310
+ TableRow as X,
2311
+ Tabs as Y,
2312
+ TabsContent as Z,
2313
+ TabsList as _,
2314
+ AlertDescription as a,
2315
+ Textarea as a0,
2316
+ AlertTitle as b,
2317
+ CardAction as c,
2318
+ CardContent as d,
2319
+ CardDescription as e,
2320
+ CardFooter as f,
2321
+ CardHeader as g,
2322
+ CardTitle as h,
2323
+ ChartCard as i,
2324
+ ChartContainer as j,
2325
+ ChartLegend as k,
2326
+ ChartLegendContent as l,
2327
+ ChartStyle as m,
2328
+ ChartTooltip as n,
2329
+ ChartTooltipContent as o,
2330
+ ComboMetricChart as p,
2331
+ DashboardLineChart as q,
2332
+ Dialog as r,
2333
+ DialogBody as s,
2334
+ DialogClose as t,
2335
+ DialogContent as u,
2336
+ DialogDescription as v,
2337
+ DialogFooter as w,
2338
+ DialogHeader as x,
2339
+ DialogOverlay as y,
2340
+ DialogPortal as z
2341
+ };