@rebasepro/plugin-insights 0.0.1-canary.000dc36

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 (303) hide show
  1. package/LICENSE +6 -0
  2. package/dist/common/src/collections/CollectionRegistry.d.ts +56 -0
  3. package/dist/common/src/collections/index.d.ts +1 -0
  4. package/dist/common/src/data/buildRebaseData.d.ts +14 -0
  5. package/dist/common/src/index.d.ts +3 -0
  6. package/dist/common/src/util/builders.d.ts +57 -0
  7. package/dist/common/src/util/callbacks.d.ts +6 -0
  8. package/dist/common/src/util/collections.d.ts +11 -0
  9. package/dist/common/src/util/common.d.ts +2 -0
  10. package/dist/common/src/util/conditions.d.ts +26 -0
  11. package/dist/common/src/util/entities.d.ts +58 -0
  12. package/dist/common/src/util/enums.d.ts +3 -0
  13. package/dist/common/src/util/index.d.ts +16 -0
  14. package/dist/common/src/util/navigation_from_path.d.ts +34 -0
  15. package/dist/common/src/util/navigation_utils.d.ts +20 -0
  16. package/dist/common/src/util/parent_references_from_path.d.ts +6 -0
  17. package/dist/common/src/util/paths.d.ts +14 -0
  18. package/dist/common/src/util/permissions.d.ts +5 -0
  19. package/dist/common/src/util/references.d.ts +2 -0
  20. package/dist/common/src/util/relations.d.ts +22 -0
  21. package/dist/common/src/util/resolutions.d.ts +72 -0
  22. package/dist/common/src/util/storage.d.ts +24 -0
  23. package/dist/core/src/components/AIIcon.d.ts +16 -0
  24. package/dist/core/src/components/ConfirmationDialog.d.ts +9 -0
  25. package/dist/core/src/components/Debug/UIReferenceView.d.ts +1 -0
  26. package/dist/core/src/components/Debug/UIStyleGuide.d.ts +1 -0
  27. package/dist/core/src/components/ErrorTooltip.d.ts +2 -0
  28. package/dist/core/src/components/ErrorView.d.ts +21 -0
  29. package/dist/core/src/components/LanguageToggle.d.ts +1 -0
  30. package/dist/core/src/components/LoginView/LoginView.d.ts +68 -0
  31. package/dist/core/src/components/LoginView/index.d.ts +2 -0
  32. package/dist/core/src/components/NotFoundPage.d.ts +1 -0
  33. package/dist/core/src/components/RebaseAuth.d.ts +10 -0
  34. package/dist/core/src/components/RebaseLogo.d.ts +7 -0
  35. package/dist/core/src/components/UnsavedChangesDialog.d.ts +9 -0
  36. package/dist/core/src/components/UserDisplay.d.ts +7 -0
  37. package/dist/core/src/components/UserSelectPopover.d.ts +62 -0
  38. package/dist/core/src/components/UserSettingsView.d.ts +1 -0
  39. package/dist/core/src/components/common/index.d.ts +6 -0
  40. package/dist/core/src/components/common/table_height.d.ts +5 -0
  41. package/dist/core/src/components/common/types.d.ts +63 -0
  42. package/dist/core/src/components/common/useColumnsIds.d.ts +9 -0
  43. package/dist/core/src/components/common/useDataTableController.d.ts +45 -0
  44. package/dist/core/src/components/common/useDebouncedData.d.ts +9 -0
  45. package/dist/core/src/components/common/useScrollRestoration.d.ts +14 -0
  46. package/dist/core/src/components/index.d.ts +16 -0
  47. package/dist/core/src/contexts/AdminModeController.d.ts +4 -0
  48. package/dist/core/src/contexts/AnalyticsContext.d.ts +3 -0
  49. package/dist/core/src/contexts/AuthControllerContext.d.ts +3 -0
  50. package/dist/core/src/contexts/CustomizationControllerContext.d.ts +3 -0
  51. package/dist/core/src/contexts/DataDriverContext.d.ts +3 -0
  52. package/dist/core/src/contexts/DatabaseAdminContext.d.ts +3 -0
  53. package/dist/core/src/contexts/DialogsProvider.d.ts +4 -0
  54. package/dist/core/src/contexts/EffectiveRoleController.d.ts +4 -0
  55. package/dist/core/src/contexts/InternalUserManagementContext.d.ts +3 -0
  56. package/dist/core/src/contexts/ModeController.d.ts +4 -0
  57. package/dist/core/src/contexts/RebaseClientInstanceContext.d.ts +6 -0
  58. package/dist/core/src/contexts/RebaseDataContext.d.ts +3 -0
  59. package/dist/core/src/contexts/SnackbarProvider.d.ts +2 -0
  60. package/dist/core/src/contexts/StorageSourceContext.d.ts +3 -0
  61. package/dist/core/src/contexts/UserConfigurationPersistenceContext.d.ts +3 -0
  62. package/dist/core/src/contexts/index.d.ts +13 -0
  63. package/dist/core/src/core/PluginLifecycleManager.d.ts +17 -0
  64. package/dist/core/src/core/PluginProviderStack.d.ts +21 -0
  65. package/dist/core/src/core/Rebase.d.ts +14 -0
  66. package/dist/core/src/core/RebaseProps.d.ts +136 -0
  67. package/dist/core/src/core/RebaseRouter.d.ts +4 -0
  68. package/dist/core/src/core/RebaseRoutes.d.ts +17 -0
  69. package/dist/core/src/core/index.d.ts +4 -0
  70. package/dist/core/src/hooks/ApiConfigContext.d.ts +24 -0
  71. package/dist/core/src/hooks/data/delete.d.ts +31 -0
  72. package/dist/core/src/hooks/data/save.d.ts +34 -0
  73. package/dist/core/src/hooks/data/useCollectionFetch.d.ts +51 -0
  74. package/dist/core/src/hooks/data/useData.d.ts +13 -0
  75. package/dist/core/src/hooks/data/useDataOrder.d.ts +12 -0
  76. package/dist/core/src/hooks/data/useEntityFetch.d.ts +38 -0
  77. package/dist/core/src/hooks/data/useRelationSelector.d.ts +52 -0
  78. package/dist/core/src/hooks/data/useUserSelector.d.ts +31 -0
  79. package/dist/core/src/hooks/index.d.ts +37 -0
  80. package/dist/core/src/hooks/useAdminModeController.d.ts +19 -0
  81. package/dist/core/src/hooks/useAnalyticsController.d.ts +5 -0
  82. package/dist/core/src/hooks/useAuthController.d.ts +11 -0
  83. package/dist/core/src/hooks/useAuthSubscription.d.ts +2 -0
  84. package/dist/core/src/hooks/useBackendStorageSource.d.ts +30 -0
  85. package/dist/core/src/hooks/useBridgeRegistration.d.ts +18 -0
  86. package/dist/core/src/hooks/useBrowserTitleAndIcon.d.ts +6 -0
  87. package/dist/core/src/hooks/useBuildAdminModeController.d.ts +6 -0
  88. package/dist/core/src/hooks/useBuildEffectiveRoleController.d.ts +8 -0
  89. package/dist/core/src/hooks/useBuildLocalConfigurationPersistence.d.ts +2 -0
  90. package/dist/core/src/hooks/useBuildModeController.d.ts +6 -0
  91. package/dist/core/src/hooks/useClipboard.d.ts +57 -0
  92. package/dist/core/src/hooks/useCollapsedGroups.d.ts +12 -0
  93. package/dist/core/src/hooks/useCustomizationController.d.ts +11 -0
  94. package/dist/core/src/hooks/useDialogsController.d.ts +11 -0
  95. package/dist/core/src/hooks/useEffectiveRoleController.d.ts +7 -0
  96. package/dist/core/src/hooks/useInternalUserManagementController.d.ts +12 -0
  97. package/dist/core/src/hooks/useLargeLayout.d.ts +1 -0
  98. package/dist/core/src/hooks/useModeController.d.ts +19 -0
  99. package/dist/core/src/hooks/usePermissions.d.ts +12 -0
  100. package/dist/core/src/hooks/useRebaseClient.d.ts +5 -0
  101. package/dist/core/src/hooks/useRebaseContext.d.ts +11 -0
  102. package/dist/core/src/hooks/useRebaseRegistry.d.ts +34 -0
  103. package/dist/core/src/hooks/useSlot.d.ts +18 -0
  104. package/dist/core/src/hooks/useSnackbarController.d.ts +20 -0
  105. package/dist/core/src/hooks/useStorageSource.d.ts +7 -0
  106. package/dist/core/src/hooks/useStudioBridge.d.ts +91 -0
  107. package/dist/core/src/hooks/useTranslation.d.ts +17 -0
  108. package/dist/core/src/hooks/useUnsavedChangesDialog.d.ts +12 -0
  109. package/dist/core/src/hooks/useUserConfigurationPersistence.d.ts +8 -0
  110. package/dist/core/src/hooks/useValidateAuthenticator.d.ts +21 -0
  111. package/dist/core/src/i18n/RebaseI18nProvider.d.ts +33 -0
  112. package/dist/core/src/index.d.ts +15 -0
  113. package/dist/core/src/internal/common.d.ts +3 -0
  114. package/dist/core/src/internal/useRestoreScroll.d.ts +6 -0
  115. package/dist/core/src/locales/de.d.ts +2 -0
  116. package/dist/core/src/locales/en.d.ts +10 -0
  117. package/dist/core/src/locales/es.d.ts +10 -0
  118. package/dist/core/src/locales/fr.d.ts +2 -0
  119. package/dist/core/src/locales/hi.d.ts +2 -0
  120. package/dist/core/src/locales/it.d.ts +2 -0
  121. package/dist/core/src/locales/pt.d.ts +7 -0
  122. package/dist/core/src/util/constants.d.ts +1 -0
  123. package/dist/core/src/util/createFormexStub.d.ts +2 -0
  124. package/dist/core/src/util/entity_cache.d.ts +27 -0
  125. package/dist/core/src/util/enums.d.ts +5 -0
  126. package/dist/core/src/util/icon_list.d.ts +5 -0
  127. package/dist/core/src/util/icon_synonyms.d.ts +1 -0
  128. package/dist/core/src/util/icons.d.ts +20 -0
  129. package/dist/core/src/util/index.d.ts +10 -0
  130. package/dist/core/src/util/previews.d.ts +4 -0
  131. package/dist/core/src/util/useStorageUploadController.d.ts +38 -0
  132. package/dist/core/src/util/useTraceUpdate.d.ts +2 -0
  133. package/dist/formex/src/Field.d.ts +52 -0
  134. package/dist/formex/src/Formex.d.ts +7 -0
  135. package/dist/formex/src/index.d.ts +5 -0
  136. package/dist/formex/src/types.d.ts +40 -0
  137. package/dist/formex/src/useCreateFormex.d.ts +14 -0
  138. package/dist/formex/src/utils.d.ts +16 -0
  139. package/dist/index.es.js +1045 -0
  140. package/dist/index.es.js.map +1 -0
  141. package/dist/index.umd.js +1044 -0
  142. package/dist/index.umd.js.map +1 -0
  143. package/dist/plugin-insights/src/components/CollectionInsightsInline.d.ts +17 -0
  144. package/dist/plugin-insights/src/components/HomeCardInsightSlot.d.ts +16 -0
  145. package/dist/plugin-insights/src/components/HomeInsightsSlot.d.ts +13 -0
  146. package/dist/plugin-insights/src/components/InsightWidget.d.ts +22 -0
  147. package/dist/plugin-insights/src/components/InsightWidgetSkeleton.d.ts +26 -0
  148. package/dist/plugin-insights/src/components/InsightsScorecardView.d.ts +19 -0
  149. package/dist/plugin-insights/src/engine/InsightsCache.d.ts +18 -0
  150. package/dist/plugin-insights/src/engine/InsightsProvider.d.ts +22 -0
  151. package/dist/plugin-insights/src/engine/useInsightsData.d.ts +17 -0
  152. package/dist/plugin-insights/src/index.d.ts +8 -0
  153. package/dist/plugin-insights/src/types/engine.d.ts +88 -0
  154. package/dist/plugin-insights/src/types/index.d.ts +2 -0
  155. package/dist/plugin-insights/src/types/widgets.d.ts +59 -0
  156. package/dist/plugin-insights/src/useInsightsPlugin.d.ts +37 -0
  157. package/dist/types/src/controllers/analytics_controller.d.ts +7 -0
  158. package/dist/types/src/controllers/auth.d.ts +119 -0
  159. package/dist/types/src/controllers/client.d.ts +170 -0
  160. package/dist/types/src/controllers/collection_registry.d.ts +46 -0
  161. package/dist/types/src/controllers/customization_controller.d.ts +60 -0
  162. package/dist/types/src/controllers/data.d.ts +168 -0
  163. package/dist/types/src/controllers/data_driver.d.ts +195 -0
  164. package/dist/types/src/controllers/database_admin.d.ts +11 -0
  165. package/dist/types/src/controllers/dialogs_controller.d.ts +36 -0
  166. package/dist/types/src/controllers/effective_role.d.ts +4 -0
  167. package/dist/types/src/controllers/email.d.ts +34 -0
  168. package/dist/types/src/controllers/index.d.ts +18 -0
  169. package/dist/types/src/controllers/local_config_persistence.d.ts +20 -0
  170. package/dist/types/src/controllers/navigation.d.ts +213 -0
  171. package/dist/types/src/controllers/registry.d.ts +54 -0
  172. package/dist/types/src/controllers/side_dialogs_controller.d.ts +67 -0
  173. package/dist/types/src/controllers/side_entity_controller.d.ts +90 -0
  174. package/dist/types/src/controllers/snackbar.d.ts +24 -0
  175. package/dist/types/src/controllers/storage.d.ts +171 -0
  176. package/dist/types/src/index.d.ts +4 -0
  177. package/dist/types/src/rebase_context.d.ts +105 -0
  178. package/dist/types/src/types/backend.d.ts +536 -0
  179. package/dist/types/src/types/backend_hooks.d.ts +187 -0
  180. package/dist/types/src/types/builders.d.ts +15 -0
  181. package/dist/types/src/types/chips.d.ts +5 -0
  182. package/dist/types/src/types/collections.d.ts +857 -0
  183. package/dist/types/src/types/cron.d.ts +102 -0
  184. package/dist/types/src/types/data_source.d.ts +64 -0
  185. package/dist/types/src/types/entities.d.ts +145 -0
  186. package/dist/types/src/types/entity_actions.d.ts +98 -0
  187. package/dist/types/src/types/entity_callbacks.d.ts +173 -0
  188. package/dist/types/src/types/entity_link_builder.d.ts +7 -0
  189. package/dist/types/src/types/entity_overrides.d.ts +10 -0
  190. package/dist/types/src/types/entity_views.d.ts +59 -0
  191. package/dist/types/src/types/export_import.d.ts +21 -0
  192. package/dist/types/src/types/formex.d.ts +40 -0
  193. package/dist/types/src/types/index.d.ts +25 -0
  194. package/dist/types/src/types/locales.d.ts +4 -0
  195. package/dist/types/src/types/modify_collections.d.ts +5 -0
  196. package/dist/types/src/types/plugins.d.ts +282 -0
  197. package/dist/types/src/types/properties.d.ts +1148 -0
  198. package/dist/types/src/types/property_config.d.ts +70 -0
  199. package/dist/types/src/types/relations.d.ts +336 -0
  200. package/dist/types/src/types/slots.d.ts +262 -0
  201. package/dist/types/src/types/translations.d.ts +874 -0
  202. package/dist/types/src/types/user_management_delegate.d.ts +121 -0
  203. package/dist/types/src/types/websockets.d.ts +78 -0
  204. package/dist/types/src/users/index.d.ts +2 -0
  205. package/dist/types/src/users/roles.d.ts +22 -0
  206. package/dist/types/src/users/user.d.ts +46 -0
  207. package/dist/ui/src/components/Alert.d.ts +12 -0
  208. package/dist/ui/src/components/Autocomplete.d.ts +21 -0
  209. package/dist/ui/src/components/Avatar.d.ts +11 -0
  210. package/dist/ui/src/components/Badge.d.ts +8 -0
  211. package/dist/ui/src/components/BooleanSwitch.d.ts +14 -0
  212. package/dist/ui/src/components/BooleanSwitchWithLabel.d.ts +17 -0
  213. package/dist/ui/src/components/Button.d.ts +14 -0
  214. package/dist/ui/src/components/Card.d.ts +9 -0
  215. package/dist/ui/src/components/CenteredView.d.ts +9 -0
  216. package/dist/ui/src/components/Checkbox.d.ts +13 -0
  217. package/dist/ui/src/components/Chip.d.ts +26 -0
  218. package/dist/ui/src/components/CircularProgress.d.ts +5 -0
  219. package/dist/ui/src/components/CircularProgressCenter.d.ts +11 -0
  220. package/dist/ui/src/components/Collapse.d.ts +9 -0
  221. package/dist/ui/src/components/ColorPicker.d.ts +30 -0
  222. package/dist/ui/src/components/Container.d.ts +8 -0
  223. package/dist/ui/src/components/DateTimeField.d.ts +24 -0
  224. package/dist/ui/src/components/DebouncedTextField.d.ts +2 -0
  225. package/dist/ui/src/components/Dialog.d.ts +39 -0
  226. package/dist/ui/src/components/DialogActions.d.ts +7 -0
  227. package/dist/ui/src/components/DialogContent.d.ts +7 -0
  228. package/dist/ui/src/components/DialogTitle.d.ts +10 -0
  229. package/dist/ui/src/components/ErrorBoundary.d.ts +11 -0
  230. package/dist/ui/src/components/ExpandablePanel.d.ts +12 -0
  231. package/dist/ui/src/components/FileUpload.d.ts +23 -0
  232. package/dist/ui/src/components/IconButton.d.ts +12 -0
  233. package/dist/ui/src/components/InfoLabel.d.ts +5 -0
  234. package/dist/ui/src/components/InputLabel.d.ts +11 -0
  235. package/dist/ui/src/components/Label.d.ts +7 -0
  236. package/dist/ui/src/components/LoadingButton.d.ts +7 -0
  237. package/dist/ui/src/components/Markdown.d.ts +10 -0
  238. package/dist/ui/src/components/Menu.d.ts +23 -0
  239. package/dist/ui/src/components/Menubar.d.ts +80 -0
  240. package/dist/ui/src/components/MultiSelect.d.ts +48 -0
  241. package/dist/ui/src/components/Paper.d.ts +6 -0
  242. package/dist/ui/src/components/Popover.d.ts +24 -0
  243. package/dist/ui/src/components/RadioGroup.d.ts +28 -0
  244. package/dist/ui/src/components/ResizablePanels.d.ts +18 -0
  245. package/dist/ui/src/components/SearchBar.d.ts +22 -0
  246. package/dist/ui/src/components/Select.d.ts +43 -0
  247. package/dist/ui/src/components/Separator.d.ts +5 -0
  248. package/dist/ui/src/components/Sheet.d.ts +22 -0
  249. package/dist/ui/src/components/Skeleton.d.ts +6 -0
  250. package/dist/ui/src/components/Slider.d.ts +21 -0
  251. package/dist/ui/src/components/Table.d.ts +34 -0
  252. package/dist/ui/src/components/Tabs.d.ts +19 -0
  253. package/dist/ui/src/components/TextField.d.ts +58 -0
  254. package/dist/ui/src/components/TextareaAutosize.d.ts +43 -0
  255. package/dist/ui/src/components/ToggleButtonGroup.d.ts +30 -0
  256. package/dist/ui/src/components/Tooltip.d.ts +19 -0
  257. package/dist/ui/src/components/Typography.d.ts +36 -0
  258. package/dist/ui/src/components/VirtualTable/VirtualTable.d.ts +11 -0
  259. package/dist/ui/src/components/VirtualTable/VirtualTableCell.d.ts +21 -0
  260. package/dist/ui/src/components/VirtualTable/VirtualTableHeader.d.ts +29 -0
  261. package/dist/ui/src/components/VirtualTable/VirtualTableHeaderRow.d.ts +2 -0
  262. package/dist/ui/src/components/VirtualTable/VirtualTableProps.d.ts +243 -0
  263. package/dist/ui/src/components/VirtualTable/VirtualTableRow.d.ts +3 -0
  264. package/dist/ui/src/components/VirtualTable/index.d.ts +3 -0
  265. package/dist/ui/src/components/VirtualTable/types.d.ts +38 -0
  266. package/dist/ui/src/components/common/SelectInputLabel.d.ts +5 -0
  267. package/dist/ui/src/components/index.d.ts +53 -0
  268. package/dist/ui/src/hooks/PortalContainerContext.d.ts +31 -0
  269. package/dist/ui/src/hooks/index.d.ts +6 -0
  270. package/dist/ui/src/hooks/useDebounceCallback.d.ts +1 -0
  271. package/dist/ui/src/hooks/useDebounceValue.d.ts +1 -0
  272. package/dist/ui/src/hooks/useDebouncedCallback.d.ts +1 -0
  273. package/dist/ui/src/hooks/useInjectStyles.d.ts +7 -0
  274. package/dist/ui/src/hooks/useOutsideAlerter.d.ts +5 -0
  275. package/dist/ui/src/icons/GitHubIcon.d.ts +2 -0
  276. package/dist/ui/src/icons/HandleIcon.d.ts +1 -0
  277. package/dist/ui/src/icons/Icon.d.ts +20 -0
  278. package/dist/ui/src/icons/cool_icon_keys.d.ts +1 -0
  279. package/dist/ui/src/icons/icon_keys.d.ts +1 -0
  280. package/dist/ui/src/icons/index.d.ts +6 -0
  281. package/dist/ui/src/index.d.ts +5 -0
  282. package/dist/ui/src/styles.d.ts +12 -0
  283. package/dist/ui/src/util/chip_colors.d.ts +4 -0
  284. package/dist/ui/src/util/cls.d.ts +2 -0
  285. package/dist/ui/src/util/debounce.d.ts +10 -0
  286. package/dist/ui/src/util/hash.d.ts +1 -0
  287. package/dist/ui/src/util/index.d.ts +4 -0
  288. package/dist/ui/src/util/key_to_icon_component.d.ts +1 -0
  289. package/package.json +80 -0
  290. package/src/components/CollectionInsightsInline.tsx +38 -0
  291. package/src/components/HomeCardInsightSlot.tsx +40 -0
  292. package/src/components/HomeInsightsSlot.tsx +30 -0
  293. package/src/components/InsightWidget.tsx +69 -0
  294. package/src/components/InsightWidgetSkeleton.tsx +204 -0
  295. package/src/components/InsightsScorecardView.tsx +160 -0
  296. package/src/engine/InsightsCache.ts +52 -0
  297. package/src/engine/InsightsProvider.tsx +38 -0
  298. package/src/engine/useInsightsData.ts +100 -0
  299. package/src/index.ts +22 -0
  300. package/src/types/engine.ts +95 -0
  301. package/src/types/index.ts +5 -0
  302. package/src/types/widgets.ts +66 -0
  303. package/src/useInsightsPlugin.tsx +117 -0
@@ -0,0 +1,1044 @@
1
+ (function(global, factory) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("react-compiler-runtime"), require("react"), require("@rebasepro/core"), require("@rebasepro/ui")) : typeof define === "function" && define.amd ? define(["exports", "react/jsx-runtime", "react-compiler-runtime", "react", "@rebasepro/core", "@rebasepro/ui"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.Rebase = {}, global.jsxRuntime, global.reactCompilerRuntime, global.React, global.core, global.ui));
3
+ })(this, (function(exports2, jsxRuntime, reactCompilerRuntime, React, core, ui) {
4
+ "use strict";
5
+ class InsightsCache {
6
+ constructor(ttl = 6e4) {
7
+ this.ttl = ttl;
8
+ }
9
+ cache = /* @__PURE__ */ new Map();
10
+ inflight = /* @__PURE__ */ new Map();
11
+ get(key) {
12
+ const entry = this.cache.get(key);
13
+ if (!entry) return null;
14
+ if (Date.now() - entry.timestamp > this.ttl) {
15
+ this.cache.delete(key);
16
+ return null;
17
+ }
18
+ return entry.data;
19
+ }
20
+ set(key, data) {
21
+ this.cache.set(key, {
22
+ data,
23
+ timestamp: Date.now()
24
+ });
25
+ this.inflight.delete(key);
26
+ }
27
+ getInflight(key) {
28
+ return this.inflight.get(key) ?? null;
29
+ }
30
+ setInflight(key, promise) {
31
+ this.inflight.set(key, promise);
32
+ }
33
+ invalidate(key) {
34
+ if (key) {
35
+ this.cache.delete(key);
36
+ this.inflight.delete(key);
37
+ } else {
38
+ this.cache.clear();
39
+ this.inflight.clear();
40
+ }
41
+ }
42
+ }
43
+ const InsightsContext = React.createContext(null);
44
+ function InsightsProvider(t0) {
45
+ const $ = reactCompilerRuntime.c(7);
46
+ const {
47
+ cacheTTL,
48
+ children
49
+ } = t0;
50
+ let t1;
51
+ let t2;
52
+ if ($[0] !== cacheTTL) {
53
+ t2 = new InsightsCache(cacheTTL);
54
+ $[0] = cacheTTL;
55
+ $[1] = t2;
56
+ } else {
57
+ t2 = $[1];
58
+ }
59
+ t1 = t2;
60
+ const cache = t1;
61
+ let t3;
62
+ let t4;
63
+ if ($[2] !== cache) {
64
+ t4 = {
65
+ cache
66
+ };
67
+ $[2] = cache;
68
+ $[3] = t4;
69
+ } else {
70
+ t4 = $[3];
71
+ }
72
+ t3 = t4;
73
+ const value = t3;
74
+ let t5;
75
+ if ($[4] !== children || $[5] !== value) {
76
+ t5 = /* @__PURE__ */ jsxRuntime.jsx(InsightsContext.Provider, { value, children });
77
+ $[4] = children;
78
+ $[5] = value;
79
+ $[6] = t5;
80
+ } else {
81
+ t5 = $[6];
82
+ }
83
+ return t5;
84
+ }
85
+ function useInsightsEngine() {
86
+ return React.useContext(InsightsContext);
87
+ }
88
+ function useInsightsData(definition, context) {
89
+ const $ = reactCompilerRuntime.c(18);
90
+ const engine = useInsightsEngine();
91
+ const cache = engine?.cache ?? null;
92
+ const {
93
+ initialLoading,
94
+ authLoading,
95
+ user,
96
+ loginSkipped
97
+ } = core.useAuthController();
98
+ const authReady = !initialLoading && !authLoading && (Boolean(user) || loginSkipped);
99
+ const [data, setData] = React.useState(null);
100
+ const [loading, setLoading] = React.useState(true);
101
+ const [error, setError] = React.useState(null);
102
+ const cacheKey = `${definition.id}:${context.path ?? context.collectionSlug ?? "global"}`;
103
+ let t0;
104
+ if ($[0] !== authReady || $[1] !== cache || $[2] !== cacheKey || $[3] !== context || $[4] !== definition) {
105
+ t0 = () => {
106
+ if (!authReady || !cache) {
107
+ return;
108
+ }
109
+ let cancelled;
110
+ cancelled = false;
111
+ const cached = cache.get(cacheKey);
112
+ if (cached) {
113
+ setData(cached);
114
+ setLoading(false);
115
+ return;
116
+ }
117
+ const inflight = cache.getInflight(cacheKey);
118
+ if (inflight) {
119
+ setLoading(true);
120
+ inflight.then((result) => {
121
+ if (!cancelled) {
122
+ setData(result);
123
+ }
124
+ }).catch((err) => {
125
+ if (!cancelled) {
126
+ setError(err instanceof Error ? err : new Error(String(err)));
127
+ }
128
+ }).finally(() => {
129
+ if (!cancelled) {
130
+ setLoading(false);
131
+ }
132
+ });
133
+ return;
134
+ }
135
+ setLoading(true);
136
+ setError(null);
137
+ const promise = definition.data(context);
138
+ cache.setInflight(cacheKey, promise);
139
+ promise.then((result_0) => {
140
+ cache.set(cacheKey, result_0);
141
+ if (!cancelled) {
142
+ setData(result_0);
143
+ }
144
+ }).catch((err_0) => {
145
+ if (!cancelled) {
146
+ setError(err_0 instanceof Error ? err_0 : new Error(String(err_0)));
147
+ }
148
+ }).finally(() => {
149
+ if (!cancelled) {
150
+ setLoading(false);
151
+ }
152
+ });
153
+ return () => {
154
+ cancelled = true;
155
+ };
156
+ };
157
+ $[0] = authReady;
158
+ $[1] = cache;
159
+ $[2] = cacheKey;
160
+ $[3] = context;
161
+ $[4] = definition;
162
+ $[5] = t0;
163
+ } else {
164
+ t0 = $[5];
165
+ }
166
+ let t1;
167
+ if ($[6] !== authReady || $[7] !== cache || $[8] !== cacheKey || $[9] !== context.collectionSlug || $[10] !== context.path || $[11] !== definition.data || $[12] !== definition.id) {
168
+ t1 = [definition.id, definition.data, context.path, context.collectionSlug, cacheKey, cache, authReady];
169
+ $[6] = authReady;
170
+ $[7] = cache;
171
+ $[8] = cacheKey;
172
+ $[9] = context.collectionSlug;
173
+ $[10] = context.path;
174
+ $[11] = definition.data;
175
+ $[12] = definition.id;
176
+ $[13] = t1;
177
+ } else {
178
+ t1 = $[13];
179
+ }
180
+ React.useEffect(t0, t1);
181
+ let t2;
182
+ if ($[14] !== data || $[15] !== error || $[16] !== loading) {
183
+ t2 = {
184
+ data,
185
+ loading,
186
+ error
187
+ };
188
+ $[14] = data;
189
+ $[15] = error;
190
+ $[16] = loading;
191
+ $[17] = t2;
192
+ } else {
193
+ t2 = $[17];
194
+ }
195
+ return t2;
196
+ }
197
+ function formatNumber(value, format) {
198
+ if (value === null || value === void 0) return "N/A";
199
+ const options = {
200
+ style: format?.style ?? "decimal",
201
+ notation: format?.notation ?? "standard",
202
+ maximumFractionDigits: format?.decimals ?? 1,
203
+ minimumFractionDigits: format?.decimals ?? 1
204
+ };
205
+ if (format?.style === "currency") {
206
+ options.currency = format.currency ?? "USD";
207
+ }
208
+ let formatted = new Intl.NumberFormat("en-US", options).format(value);
209
+ if (format?.showSign && value > 0) {
210
+ formatted = "+" + formatted;
211
+ }
212
+ return formatted;
213
+ }
214
+ function InsightsScorecardView(t0) {
215
+ const $ = reactCompilerRuntime.c(58);
216
+ const {
217
+ config,
218
+ data,
219
+ title,
220
+ compact: t1,
221
+ embedded: t2
222
+ } = t0;
223
+ const compact = t1 === void 0 ? false : t1;
224
+ const embedded = t2 === void 0 ? false : t2;
225
+ const containerRef = React.useRef(null);
226
+ const [containerWidth, setContainerWidth] = React.useState(null);
227
+ let t3;
228
+ let t4;
229
+ if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
230
+ t3 = () => {
231
+ if (!containerRef.current) {
232
+ return;
233
+ }
234
+ setContainerWidth(containerRef.current.offsetWidth);
235
+ const observer = new ResizeObserver((entries) => {
236
+ for (const entry of entries) {
237
+ setContainerWidth(entry.contentRect.width);
238
+ }
239
+ });
240
+ observer.observe(containerRef.current);
241
+ return () => observer.disconnect();
242
+ };
243
+ t4 = [];
244
+ $[0] = t3;
245
+ $[1] = t4;
246
+ } else {
247
+ t3 = $[0];
248
+ t4 = $[1];
249
+ }
250
+ React.useLayoutEffect(t3, t4);
251
+ const mainValue = data[config.value.field];
252
+ let t5;
253
+ if ($[2] !== config.value.format || $[3] !== mainValue) {
254
+ t5 = typeof mainValue === "number" ? formatNumber(mainValue, config.value.format) : String(mainValue ?? "N/A");
255
+ $[2] = config.value.format;
256
+ $[3] = mainValue;
257
+ $[4] = t5;
258
+ } else {
259
+ t5 = $[4];
260
+ }
261
+ const formattedValue = t5;
262
+ let comparisonElement = null;
263
+ if (config.comparison) {
264
+ const comparisonValue = data[config.comparison.field];
265
+ if (typeof comparisonValue === "number") {
266
+ let t62;
267
+ if ($[5] !== comparisonValue || $[6] !== config.comparison.format) {
268
+ t62 = formatNumber(comparisonValue, config.comparison.format);
269
+ $[5] = comparisonValue;
270
+ $[6] = config.comparison.format;
271
+ $[7] = t62;
272
+ } else {
273
+ t62 = $[7];
274
+ }
275
+ const formattedComparison = t62;
276
+ const isPositive = comparisonValue > 0;
277
+ const isNegative = comparisonValue < 0;
278
+ let colorClass = "text-surface-500 dark:text-surface-400";
279
+ if (config.comparison.intent === "increase_is_good") {
280
+ if (isPositive) {
281
+ colorClass = "text-emerald-500";
282
+ }
283
+ if (isNegative) {
284
+ colorClass = "text-red-500";
285
+ }
286
+ } else {
287
+ if (config.comparison.intent === "decrease_is_good") {
288
+ if (isPositive) {
289
+ colorClass = "text-red-500";
290
+ }
291
+ if (isNegative) {
292
+ colorClass = "text-emerald-500";
293
+ }
294
+ }
295
+ }
296
+ const t72 = `font-medium ${compact ? "text-[10px]" : "text-xs"} ${colorClass}`;
297
+ let t82;
298
+ if ($[8] !== formattedComparison || $[9] !== t72) {
299
+ t82 = /* @__PURE__ */ jsxRuntime.jsx("span", { className: t72, children: formattedComparison });
300
+ $[8] = formattedComparison;
301
+ $[9] = t72;
302
+ $[10] = t82;
303
+ } else {
304
+ t82 = $[10];
305
+ }
306
+ comparisonElement = t82;
307
+ }
308
+ }
309
+ const isSmall = compact || containerWidth !== null && containerWidth < 200;
310
+ let t6;
311
+ if ($[11] !== config.icon || $[12] !== isSmall) {
312
+ t6 = config.icon ? core.getIcon(config.icon, "text-surface-400 dark:text-surface-500", void 0, isSmall ? 14 : 18) : null;
313
+ $[11] = config.icon;
314
+ $[12] = isSmall;
315
+ $[13] = t6;
316
+ } else {
317
+ t6 = $[13];
318
+ }
319
+ const iconElement = t6;
320
+ if (compact) {
321
+ let t72;
322
+ if ($[14] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
323
+ t72 = ui.cls("flex flex-col gap-0.5 px-2.5 py-2 rounded-md bg-transparent border min-w-0", ui.defaultBorderMixin);
324
+ $[14] = t72;
325
+ } else {
326
+ t72 = $[14];
327
+ }
328
+ let t82;
329
+ if ($[15] !== title) {
330
+ t82 = /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] uppercase tracking-wider text-surface-400 dark:text-surface-500 truncate", children: title });
331
+ $[15] = title;
332
+ $[16] = t82;
333
+ } else {
334
+ t82 = $[16];
335
+ }
336
+ let t92;
337
+ if ($[17] !== formattedValue) {
338
+ t92 = /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-semibold tabular-nums text-surface-800 dark:text-surface-100", children: formattedValue });
339
+ $[17] = formattedValue;
340
+ $[18] = t92;
341
+ } else {
342
+ t92 = $[18];
343
+ }
344
+ let t102;
345
+ if ($[19] !== comparisonElement || $[20] !== t92) {
346
+ t102 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-baseline gap-1.5", children: [
347
+ t92,
348
+ comparisonElement
349
+ ] });
350
+ $[19] = comparisonElement;
351
+ $[20] = t92;
352
+ $[21] = t102;
353
+ } else {
354
+ t102 = $[21];
355
+ }
356
+ let t112;
357
+ if ($[22] !== t102 || $[23] !== t82) {
358
+ t112 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: t72, children: [
359
+ t82,
360
+ t102
361
+ ] });
362
+ $[22] = t102;
363
+ $[23] = t82;
364
+ $[24] = t112;
365
+ } else {
366
+ t112 = $[24];
367
+ }
368
+ return t112;
369
+ }
370
+ let t7;
371
+ if ($[25] !== embedded || $[26] !== isSmall) {
372
+ t7 = embedded ? `flex flex-col min-w-0 h-full ${isSmall ? "px-3.5 py-3" : "px-5 py-4"}` : ui.cls("rounded-lg flex flex-col min-w-0 bg-transparent border", ui.defaultBorderMixin, isSmall ? "px-3.5 py-3" : "px-5 py-4");
373
+ $[25] = embedded;
374
+ $[26] = isSmall;
375
+ $[27] = t7;
376
+ } else {
377
+ t7 = $[27];
378
+ }
379
+ const baseClass = t7;
380
+ let t8;
381
+ if ($[28] !== embedded || $[29] !== isSmall) {
382
+ t8 = embedded ? void 0 : {
383
+ minHeight: isSmall ? 68 : 92
384
+ };
385
+ $[28] = embedded;
386
+ $[29] = isSmall;
387
+ $[30] = t8;
388
+ } else {
389
+ t8 = $[30];
390
+ }
391
+ const t9 = `flex items-center justify-between ${isSmall ? "mb-1" : "mb-2"}`;
392
+ const t10 = `font-medium leading-snug truncate text-surface-500 dark:text-surface-400 ${isSmall ? "text-[11px]" : "text-xs"}`;
393
+ let t11;
394
+ if ($[31] !== t10 || $[32] !== title) {
395
+ t11 = /* @__PURE__ */ jsxRuntime.jsx("span", { className: t10, children: title });
396
+ $[31] = t10;
397
+ $[32] = title;
398
+ $[33] = t11;
399
+ } else {
400
+ t11 = $[33];
401
+ }
402
+ let t12;
403
+ if ($[34] !== config.dateRange || $[35] !== isSmall) {
404
+ t12 = config.dateRange && !isSmall && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-surface-400 dark:text-surface-500 truncate mt-0.5", children: config.dateRange });
405
+ $[34] = config.dateRange;
406
+ $[35] = isSmall;
407
+ $[36] = t12;
408
+ } else {
409
+ t12 = $[36];
410
+ }
411
+ let t13;
412
+ if ($[37] !== t11 || $[38] !== t12) {
413
+ t13 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col min-w-0", children: [
414
+ t11,
415
+ t12
416
+ ] });
417
+ $[37] = t11;
418
+ $[38] = t12;
419
+ $[39] = t13;
420
+ } else {
421
+ t13 = $[39];
422
+ }
423
+ let t14;
424
+ if ($[40] !== iconElement) {
425
+ t14 = iconElement && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2 shrink-0", children: iconElement });
426
+ $[40] = iconElement;
427
+ $[41] = t14;
428
+ } else {
429
+ t14 = $[41];
430
+ }
431
+ let t15;
432
+ if ($[42] !== t13 || $[43] !== t14 || $[44] !== t9) {
433
+ t15 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: t9, children: [
434
+ t13,
435
+ t14
436
+ ] });
437
+ $[42] = t13;
438
+ $[43] = t14;
439
+ $[44] = t9;
440
+ $[45] = t15;
441
+ } else {
442
+ t15 = $[45];
443
+ }
444
+ const t16 = `font-semibold leading-tight tracking-tight break-all text-surface-800 dark:text-surface-100 ${isSmall ? "text-lg" : containerWidth !== null && containerWidth < 300 ? "text-xl" : "text-2xl"}`;
445
+ let t17;
446
+ if ($[46] !== formattedValue || $[47] !== t16) {
447
+ t17 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: t16, children: formattedValue });
448
+ $[46] = formattedValue;
449
+ $[47] = t16;
450
+ $[48] = t17;
451
+ } else {
452
+ t17 = $[48];
453
+ }
454
+ let t18;
455
+ if ($[49] !== comparisonElement || $[50] !== isSmall) {
456
+ t18 = comparisonElement && /* @__PURE__ */ jsxRuntime.jsx("div", { className: isSmall ? "mt-0.5" : "mt-1", children: comparisonElement });
457
+ $[49] = comparisonElement;
458
+ $[50] = isSmall;
459
+ $[51] = t18;
460
+ } else {
461
+ t18 = $[51];
462
+ }
463
+ let t19;
464
+ if ($[52] !== baseClass || $[53] !== t15 || $[54] !== t17 || $[55] !== t18 || $[56] !== t8) {
465
+ t19 = /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: baseClass, style: t8, children: [
466
+ t15,
467
+ t17,
468
+ t18
469
+ ] });
470
+ $[52] = baseClass;
471
+ $[53] = t15;
472
+ $[54] = t17;
473
+ $[55] = t18;
474
+ $[56] = t8;
475
+ $[57] = t19;
476
+ } else {
477
+ t19 = $[57];
478
+ }
479
+ return t19;
480
+ }
481
+ InsightsScorecardView.displayName = "InsightsScorecardView";
482
+ function InsightWidgetSkeleton(t0) {
483
+ const $ = reactCompilerRuntime.c(17);
484
+ const {
485
+ config,
486
+ compact: t1,
487
+ embedded: t2
488
+ } = t0;
489
+ const compact = t1 === void 0 ? false : t1;
490
+ const embedded = t2 === void 0 ? false : t2;
491
+ const hasComparison = Boolean(config.comparison);
492
+ const hasIcon = Boolean(config.icon);
493
+ const hasDateRange = Boolean(config.dateRange);
494
+ if (compact) {
495
+ const t32 = embedded ? "h-full px-2.5 py-2" : "flex flex-col gap-0.5 rounded-md bg-transparent border min-w-0 px-2.5 py-2";
496
+ const t4 = !embedded && ui.defaultBorderMixin;
497
+ let t5;
498
+ if ($[0] !== t32 || $[1] !== t4) {
499
+ t5 = ui.cls("animate-pulse", t32, t4);
500
+ $[0] = t32;
501
+ $[1] = t4;
502
+ $[2] = t5;
503
+ } else {
504
+ t5 = $[2];
505
+ }
506
+ let t6;
507
+ if ($[3] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
508
+ t6 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface-200 dark:bg-surface-700 rounded-sm", style: {
509
+ height: 14,
510
+ width: 48
511
+ } });
512
+ $[3] = t6;
513
+ } else {
514
+ t6 = $[3];
515
+ }
516
+ let t7;
517
+ if ($[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
518
+ t7 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface-200 dark:bg-surface-700 rounded-sm", style: {
519
+ height: 20,
520
+ width: 40
521
+ } });
522
+ $[4] = t7;
523
+ } else {
524
+ t7 = $[4];
525
+ }
526
+ let t8;
527
+ if ($[5] !== hasComparison) {
528
+ t8 = hasComparison && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface-200/60 dark:bg-surface-700/60 rounded-sm", style: {
529
+ height: 14,
530
+ width: 28
531
+ } });
532
+ $[5] = hasComparison;
533
+ $[6] = t8;
534
+ } else {
535
+ t8 = $[6];
536
+ }
537
+ let t9;
538
+ if ($[7] !== t8) {
539
+ t9 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-baseline gap-1.5", children: [
540
+ t7,
541
+ t8
542
+ ] });
543
+ $[7] = t8;
544
+ $[8] = t9;
545
+ } else {
546
+ t9 = $[8];
547
+ }
548
+ let t10;
549
+ if ($[9] !== t5 || $[10] !== t9) {
550
+ t10 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: t5, children: [
551
+ t6,
552
+ t9
553
+ ] });
554
+ $[9] = t5;
555
+ $[10] = t9;
556
+ $[11] = t10;
557
+ } else {
558
+ t10 = $[11];
559
+ }
560
+ return t10;
561
+ }
562
+ let t3;
563
+ if ($[12] !== embedded || $[13] !== hasComparison || $[14] !== hasDateRange || $[15] !== hasIcon) {
564
+ t3 = /* @__PURE__ */ jsxRuntime.jsx(StandardSkeleton, { hasComparison, hasIcon, hasDateRange, embedded });
565
+ $[12] = embedded;
566
+ $[13] = hasComparison;
567
+ $[14] = hasDateRange;
568
+ $[15] = hasIcon;
569
+ $[16] = t3;
570
+ } else {
571
+ t3 = $[16];
572
+ }
573
+ return t3;
574
+ }
575
+ function StandardSkeleton(t0) {
576
+ const $ = reactCompilerRuntime.c(36);
577
+ const {
578
+ hasComparison,
579
+ hasIcon,
580
+ hasDateRange,
581
+ embedded
582
+ } = t0;
583
+ const containerRef = React.useRef(null);
584
+ const [containerWidth, setContainerWidth] = React.useState(null);
585
+ let t1;
586
+ let t2;
587
+ if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
588
+ t1 = () => {
589
+ if (!containerRef.current) {
590
+ return;
591
+ }
592
+ setContainerWidth(containerRef.current.offsetWidth);
593
+ const observer = new ResizeObserver((entries) => {
594
+ for (const entry of entries) {
595
+ setContainerWidth(entry.contentRect.width);
596
+ }
597
+ });
598
+ observer.observe(containerRef.current);
599
+ return () => observer.disconnect();
600
+ };
601
+ t2 = [];
602
+ $[0] = t1;
603
+ $[1] = t2;
604
+ } else {
605
+ t1 = $[0];
606
+ t2 = $[1];
607
+ }
608
+ React.useLayoutEffect(t1, t2);
609
+ const isSmall = containerWidth !== null && containerWidth < 200;
610
+ const titleHeight = isSmall ? 15 : 16.5;
611
+ const valueHeight = isSmall ? 22.5 : containerWidth !== null && containerWidth < 300 ? 25 : 30;
612
+ const iconSize = isSmall ? 14 : 18;
613
+ let t3;
614
+ let t4;
615
+ if ($[2] !== embedded || $[3] !== isSmall) {
616
+ const baseClass = embedded ? `flex flex-col min-w-0 h-full ${isSmall ? "px-3.5 py-3" : "px-5 py-4"}` : ui.cls("rounded-lg flex flex-col min-w-0 bg-transparent border", ui.defaultBorderMixin, isSmall ? "px-3.5 py-3" : "px-5 py-4");
617
+ t3 = containerRef;
618
+ t4 = ui.cls("animate-pulse", baseClass);
619
+ $[2] = embedded;
620
+ $[3] = isSmall;
621
+ $[4] = t3;
622
+ $[5] = t4;
623
+ } else {
624
+ t3 = $[4];
625
+ t4 = $[5];
626
+ }
627
+ let t5;
628
+ if ($[6] !== embedded || $[7] !== isSmall) {
629
+ t5 = embedded ? void 0 : {
630
+ minHeight: isSmall ? 68 : 92
631
+ };
632
+ $[6] = embedded;
633
+ $[7] = isSmall;
634
+ $[8] = t5;
635
+ } else {
636
+ t5 = $[8];
637
+ }
638
+ const t6 = `flex items-center justify-between ${isSmall ? "mb-1" : "mb-2"}`;
639
+ let t7;
640
+ if ($[9] !== titleHeight) {
641
+ t7 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface-200 dark:bg-surface-700 rounded", style: {
642
+ height: titleHeight,
643
+ width: "60%"
644
+ } });
645
+ $[9] = titleHeight;
646
+ $[10] = t7;
647
+ } else {
648
+ t7 = $[10];
649
+ }
650
+ let t8;
651
+ if ($[11] !== hasDateRange || $[12] !== isSmall) {
652
+ t8 = hasDateRange && !isSmall && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface-200/60 dark:bg-surface-700/60 rounded mt-0.5", style: {
653
+ height: 14,
654
+ width: "40%"
655
+ } });
656
+ $[11] = hasDateRange;
657
+ $[12] = isSmall;
658
+ $[13] = t8;
659
+ } else {
660
+ t8 = $[13];
661
+ }
662
+ let t9;
663
+ if ($[14] !== t7 || $[15] !== t8) {
664
+ t9 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col min-w-0", children: [
665
+ t7,
666
+ t8
667
+ ] });
668
+ $[14] = t7;
669
+ $[15] = t8;
670
+ $[16] = t9;
671
+ } else {
672
+ t9 = $[16];
673
+ }
674
+ let t10;
675
+ if ($[17] !== hasIcon || $[18] !== iconSize) {
676
+ t10 = hasIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2 shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface-200 dark:bg-surface-700 rounded", style: {
677
+ height: iconSize,
678
+ width: iconSize
679
+ } }) });
680
+ $[17] = hasIcon;
681
+ $[18] = iconSize;
682
+ $[19] = t10;
683
+ } else {
684
+ t10 = $[19];
685
+ }
686
+ let t11;
687
+ if ($[20] !== t10 || $[21] !== t6 || $[22] !== t9) {
688
+ t11 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: t6, children: [
689
+ t9,
690
+ t10
691
+ ] });
692
+ $[20] = t10;
693
+ $[21] = t6;
694
+ $[22] = t9;
695
+ $[23] = t11;
696
+ } else {
697
+ t11 = $[23];
698
+ }
699
+ let t12;
700
+ if ($[24] !== valueHeight) {
701
+ t12 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface-200 dark:bg-surface-700 rounded", style: {
702
+ height: valueHeight,
703
+ width: "40%"
704
+ } });
705
+ $[24] = valueHeight;
706
+ $[25] = t12;
707
+ } else {
708
+ t12 = $[25];
709
+ }
710
+ let t13;
711
+ if ($[26] !== hasComparison || $[27] !== isSmall) {
712
+ t13 = hasComparison && /* @__PURE__ */ jsxRuntime.jsx("div", { className: isSmall ? "mt-0.5" : "mt-1", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface-200/60 dark:bg-surface-700/60 rounded", style: {
713
+ height: 16,
714
+ width: "25%"
715
+ } }) });
716
+ $[26] = hasComparison;
717
+ $[27] = isSmall;
718
+ $[28] = t13;
719
+ } else {
720
+ t13 = $[28];
721
+ }
722
+ let t14;
723
+ if ($[29] !== t11 || $[30] !== t12 || $[31] !== t13 || $[32] !== t3 || $[33] !== t4 || $[34] !== t5) {
724
+ t14 = /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: t3, className: t4, style: t5, children: [
725
+ t11,
726
+ t12,
727
+ t13
728
+ ] });
729
+ $[29] = t11;
730
+ $[30] = t12;
731
+ $[31] = t13;
732
+ $[32] = t3;
733
+ $[33] = t4;
734
+ $[34] = t5;
735
+ $[35] = t14;
736
+ } else {
737
+ t14 = $[35];
738
+ }
739
+ return t14;
740
+ }
741
+ InsightWidgetSkeleton.displayName = "InsightWidgetSkeleton";
742
+ function InsightWidget(t0) {
743
+ const $ = reactCompilerRuntime.c(25);
744
+ const {
745
+ definition,
746
+ collectionSlug,
747
+ path,
748
+ parentCollectionSlugs,
749
+ compact: t1,
750
+ embedded: t2
751
+ } = t0;
752
+ const compact = t1 === void 0 ? false : t1;
753
+ const embedded = t2 === void 0 ? false : t2;
754
+ let t3;
755
+ if ($[0] !== collectionSlug || $[1] !== parentCollectionSlugs || $[2] !== path) {
756
+ t3 = {
757
+ path,
758
+ collectionSlug,
759
+ parentCollectionSlugs
760
+ };
761
+ $[0] = collectionSlug;
762
+ $[1] = parentCollectionSlugs;
763
+ $[2] = path;
764
+ $[3] = t3;
765
+ } else {
766
+ t3 = $[3];
767
+ }
768
+ const {
769
+ data,
770
+ loading,
771
+ error
772
+ } = useInsightsData(definition, t3);
773
+ if (loading) {
774
+ let t42;
775
+ if ($[4] !== compact || $[5] !== definition.scorecard || $[6] !== embedded) {
776
+ t42 = /* @__PURE__ */ jsxRuntime.jsx(InsightWidgetSkeleton, { config: definition.scorecard, compact, embedded });
777
+ $[4] = compact;
778
+ $[5] = definition.scorecard;
779
+ $[6] = embedded;
780
+ $[7] = t42;
781
+ } else {
782
+ t42 = $[7];
783
+ }
784
+ return t42;
785
+ }
786
+ if (error) {
787
+ const t42 = `text-red-500/70 dark:text-red-400/70 text-[0.8125rem] ${embedded ? "px-5 py-4 h-full" : `rounded-lg bg-red-500/5 dark:bg-red-400/5 border border-red-500/10 dark:border-red-400/10 ${compact ? "px-3.5 py-3" : "px-5 py-4"}`}`;
788
+ let t52;
789
+ if ($[8] !== definition.title) {
790
+ t52 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-semibold mb-1", children: definition.title });
791
+ $[8] = definition.title;
792
+ $[9] = t52;
793
+ } else {
794
+ t52 = $[9];
795
+ }
796
+ let t6;
797
+ if ($[10] !== error.message) {
798
+ t6 = /* @__PURE__ */ jsxRuntime.jsx("div", { children: error.message });
799
+ $[10] = error.message;
800
+ $[11] = t6;
801
+ } else {
802
+ t6 = $[11];
803
+ }
804
+ let t7;
805
+ if ($[12] !== t42 || $[13] !== t52 || $[14] !== t6) {
806
+ t7 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: t42, children: [
807
+ t52,
808
+ t6
809
+ ] });
810
+ $[12] = t42;
811
+ $[13] = t52;
812
+ $[14] = t6;
813
+ $[15] = t7;
814
+ } else {
815
+ t7 = $[15];
816
+ }
817
+ return t7;
818
+ }
819
+ if (!data || data.rows.length === 0) {
820
+ const t42 = `text-surface-400 dark:text-surface-500 text-[0.8125rem] ${embedded ? "px-5 py-4 h-full" : `rounded-lg bg-surface-100 dark:bg-surface-800 border border-surface-200 dark:border-surface-700 ${compact ? "px-3.5 py-3" : "px-5 py-4"}`}`;
821
+ let t52;
822
+ if ($[16] !== definition.title || $[17] !== t42) {
823
+ t52 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: t42, children: [
824
+ definition.title,
825
+ " — No data"
826
+ ] });
827
+ $[16] = definition.title;
828
+ $[17] = t42;
829
+ $[18] = t52;
830
+ } else {
831
+ t52 = $[18];
832
+ }
833
+ return t52;
834
+ }
835
+ const t4 = data.rows[0];
836
+ let t5;
837
+ if ($[19] !== compact || $[20] !== definition.scorecard || $[21] !== definition.title || $[22] !== embedded || $[23] !== t4) {
838
+ t5 = /* @__PURE__ */ jsxRuntime.jsx(InsightsScorecardView, { config: definition.scorecard, data: t4, title: definition.title, compact, embedded });
839
+ $[19] = compact;
840
+ $[20] = definition.scorecard;
841
+ $[21] = definition.title;
842
+ $[22] = embedded;
843
+ $[23] = t4;
844
+ $[24] = t5;
845
+ } else {
846
+ t5 = $[24];
847
+ }
848
+ return t5;
849
+ }
850
+ InsightWidget.displayName = "InsightWidget";
851
+ function HomeCardInsightSlot(t0) {
852
+ const $ = reactCompilerRuntime.c(10);
853
+ const {
854
+ slug,
855
+ insights
856
+ } = t0;
857
+ if (!insights || insights.length === 0) {
858
+ return null;
859
+ }
860
+ const estimatedRows = Math.ceil(insights.length / 2);
861
+ const minHeight = estimatedRows * 42 + (estimatedRows - 1) * 6;
862
+ let t1;
863
+ if ($[0] !== minHeight) {
864
+ t1 = {
865
+ minHeight
866
+ };
867
+ $[0] = minHeight;
868
+ $[1] = t1;
869
+ } else {
870
+ t1 = $[1];
871
+ }
872
+ let t2;
873
+ if ($[2] !== insights || $[3] !== slug) {
874
+ let t32;
875
+ if ($[5] !== slug) {
876
+ t32 = (def) => /* @__PURE__ */ jsxRuntime.jsx(InsightWidget, { definition: def, collectionSlug: slug, compact: true }, def.id);
877
+ $[5] = slug;
878
+ $[6] = t32;
879
+ } else {
880
+ t32 = $[6];
881
+ }
882
+ t2 = insights.map(t32);
883
+ $[2] = insights;
884
+ $[3] = slug;
885
+ $[4] = t2;
886
+ } else {
887
+ t2 = $[4];
888
+ }
889
+ let t3;
890
+ if ($[7] !== t1 || $[8] !== t2) {
891
+ t3 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap items-center gap-1.5 mt-2", style: t1, children: t2 });
892
+ $[7] = t1;
893
+ $[8] = t2;
894
+ $[9] = t3;
895
+ } else {
896
+ t3 = $[9];
897
+ }
898
+ return t3;
899
+ }
900
+ HomeCardInsightSlot.displayName = "HomeCardInsightSlot";
901
+ function HomeInsightsSlot(t0) {
902
+ const $ = reactCompilerRuntime.c(5);
903
+ const {
904
+ insights
905
+ } = t0;
906
+ if (!insights || insights.length === 0) {
907
+ return null;
908
+ }
909
+ let t1;
910
+ if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
911
+ t1 = {
912
+ minHeight: 92
913
+ };
914
+ $[0] = t1;
915
+ } else {
916
+ t1 = $[0];
917
+ }
918
+ let t2;
919
+ if ($[1] !== insights) {
920
+ t2 = insights.map(_temp);
921
+ $[1] = insights;
922
+ $[2] = t2;
923
+ } else {
924
+ t2 = $[2];
925
+ }
926
+ let t3;
927
+ if ($[3] !== t2) {
928
+ t3 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 pb-6", style: t1, children: t2 });
929
+ $[3] = t2;
930
+ $[4] = t3;
931
+ } else {
932
+ t3 = $[4];
933
+ }
934
+ return t3;
935
+ }
936
+ function _temp(def) {
937
+ return /* @__PURE__ */ jsxRuntime.jsx(InsightWidget, { definition: def }, def.id);
938
+ }
939
+ HomeInsightsSlot.displayName = "HomeInsightsSlot";
940
+ function CollectionInsightsInline(t0) {
941
+ const $ = reactCompilerRuntime.c(11);
942
+ const {
943
+ insights,
944
+ path,
945
+ parentCollectionSlugs,
946
+ parentEntityIds
947
+ } = t0;
948
+ if (!insights || insights.length === 0) {
949
+ return null;
950
+ }
951
+ let t1;
952
+ if ($[0] !== insights || $[1] !== parentCollectionSlugs || $[2] !== parentEntityIds || $[3] !== path) {
953
+ let t22;
954
+ if ($[5] !== parentCollectionSlugs || $[6] !== parentEntityIds || $[7] !== path) {
955
+ t22 = (def) => /* @__PURE__ */ jsxRuntime.jsx(InsightWidget, { definition: def, path, parentCollectionSlugs, parentEntityIds }, def.id);
956
+ $[5] = parentCollectionSlugs;
957
+ $[6] = parentEntityIds;
958
+ $[7] = path;
959
+ $[8] = t22;
960
+ } else {
961
+ t22 = $[8];
962
+ }
963
+ t1 = insights.map(t22);
964
+ $[0] = insights;
965
+ $[1] = parentCollectionSlugs;
966
+ $[2] = parentEntityIds;
967
+ $[3] = path;
968
+ $[4] = t1;
969
+ } else {
970
+ t1 = $[4];
971
+ }
972
+ let t2;
973
+ if ($[9] !== t1) {
974
+ t2 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 pb-4", children: t1 });
975
+ $[9] = t1;
976
+ $[10] = t2;
977
+ } else {
978
+ t2 = $[10];
979
+ }
980
+ return t2;
981
+ }
982
+ CollectionInsightsInline.displayName = "CollectionInsightsInline";
983
+ function useInsightsPlugin(config) {
984
+ const {
985
+ insights,
986
+ cacheTTL
987
+ } = config;
988
+ const slots = [];
989
+ if (insights.home && insights.home.length > 0) {
990
+ const homeInsights = insights.home;
991
+ slots.push({
992
+ slot: "home.children.start",
993
+ Component: (props) => /* @__PURE__ */ jsxRuntime.jsx(HomeInsightsSlot, { ...props, insights: homeInsights }),
994
+ order: 10
995
+ });
996
+ }
997
+ if (insights.collections) {
998
+ for (const [slug, defs] of Object.entries(insights.collections)) {
999
+ if (defs.length === 0) continue;
1000
+ const collectionInsights = defs;
1001
+ slots.push({
1002
+ slot: "collection.insights",
1003
+ Component: (props) => {
1004
+ const path = props.path;
1005
+ const collectionSlug = path?.split("/").filter(Boolean).pop() ?? "";
1006
+ if (collectionSlug !== slug) return null;
1007
+ return /* @__PURE__ */ jsxRuntime.jsx(CollectionInsightsInline, { ...props, insights: collectionInsights });
1008
+ },
1009
+ order: 10
1010
+ });
1011
+ slots.push({
1012
+ slot: "home.card.insight",
1013
+ Component: (props) => {
1014
+ const cardSlug = props.slug;
1015
+ if (cardSlug !== slug) return null;
1016
+ return /* @__PURE__ */ jsxRuntime.jsx(HomeCardInsightSlot, { ...props, insights: collectionInsights });
1017
+ },
1018
+ order: 10
1019
+ });
1020
+ }
1021
+ }
1022
+ return {
1023
+ key: "plugin-insights",
1024
+ slots,
1025
+ providers: [{
1026
+ scope: "root",
1027
+ Component: InsightsProvider,
1028
+ props: {
1029
+ cacheTTL
1030
+ }
1031
+ }]
1032
+ };
1033
+ }
1034
+ exports2.InsightWidget = InsightWidget;
1035
+ exports2.InsightWidgetSkeleton = InsightWidgetSkeleton;
1036
+ exports2.InsightsCache = InsightsCache;
1037
+ exports2.InsightsProvider = InsightsProvider;
1038
+ exports2.InsightsScorecardView = InsightsScorecardView;
1039
+ exports2.useInsightsData = useInsightsData;
1040
+ exports2.useInsightsEngine = useInsightsEngine;
1041
+ exports2.useInsightsPlugin = useInsightsPlugin;
1042
+ Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
1043
+ }));
1044
+ //# sourceMappingURL=index.umd.js.map