web-mojo 2.2.101 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/CHANGELOG.md +603 -0
  2. package/README.md +2 -2
  3. package/dist/admin-models.cjs.js +2 -0
  4. package/dist/admin-models.cjs.js.map +1 -0
  5. package/dist/admin-models.es.js +2 -0
  6. package/dist/admin-models.es.js.map +1 -0
  7. package/dist/admin.cjs.js +1 -1
  8. package/dist/admin.css +42 -0
  9. package/dist/admin.es.js +1 -1
  10. package/dist/auth.cjs.js +1 -1
  11. package/dist/auth.cjs.js.map +1 -1
  12. package/dist/auth.es.js +1 -1
  13. package/dist/auth.es.js.map +1 -1
  14. package/dist/charts.cjs.js +1 -1
  15. package/dist/charts.cjs.js.map +1 -1
  16. package/dist/charts.css +897 -1
  17. package/dist/charts.es.js +1 -1
  18. package/dist/charts.es.js.map +1 -1
  19. package/dist/chat.css +96 -0
  20. package/dist/chunks/AssistantPanelView-BG34Qbfj.js +2 -0
  21. package/dist/chunks/AssistantPanelView-BG34Qbfj.js.map +1 -0
  22. package/dist/chunks/AssistantPanelView-DCEV6VeI.js +2 -0
  23. package/dist/chunks/AssistantPanelView-DCEV6VeI.js.map +1 -0
  24. package/dist/chunks/ChatView-B73uox2v.js +2 -0
  25. package/dist/chunks/ChatView-B73uox2v.js.map +1 -0
  26. package/dist/chunks/ChatView-W8daOwIo.js +2 -0
  27. package/dist/chunks/ChatView-W8daOwIo.js.map +1 -0
  28. package/dist/chunks/Collection-BZlmtcuL.js +2 -0
  29. package/dist/chunks/Collection-BZlmtcuL.js.map +1 -0
  30. package/dist/chunks/Collection-Bwoq6muu.js +2 -0
  31. package/dist/chunks/Collection-Bwoq6muu.js.map +1 -0
  32. package/dist/chunks/ContextMenu-BPPtuqKk.js +2 -0
  33. package/dist/chunks/ContextMenu-BPPtuqKk.js.map +1 -0
  34. package/dist/chunks/ContextMenu-q76hjQb6.js +2 -0
  35. package/dist/chunks/ContextMenu-q76hjQb6.js.map +1 -0
  36. package/dist/chunks/DataView-BbrwHMV4.js +2 -0
  37. package/dist/chunks/{DataView-BFx2glFg.js.map → DataView-BbrwHMV4.js.map} +1 -1
  38. package/dist/chunks/DataView-k-7wmk5_.js +2 -0
  39. package/dist/chunks/{DataView-D5C_lDdg.js.map → DataView-k-7wmk5_.js.map} +1 -1
  40. package/dist/chunks/FormView-DPSuwWMq.js +3 -0
  41. package/dist/chunks/{FormView-e-PeRx1s.js.map → FormView-DPSuwWMq.js.map} +1 -1
  42. package/dist/chunks/FormView-Dcy7XOtC.js +3 -0
  43. package/dist/chunks/{FormView-Cu4iPfvU.js.map → FormView-Dcy7XOtC.js.map} +1 -1
  44. package/dist/chunks/ListView-DHC-yBIw.js +2 -0
  45. package/dist/chunks/ListView-DHC-yBIw.js.map +1 -0
  46. package/dist/chunks/ListView-iGBsD4a7.js +2 -0
  47. package/dist/chunks/ListView-iGBsD4a7.js.map +1 -0
  48. package/dist/chunks/MetricsCountryMapView-CAD9wR_T.js +2 -0
  49. package/dist/chunks/MetricsCountryMapView-CAD9wR_T.js.map +1 -0
  50. package/dist/chunks/MetricsCountryMapView-Dzk3Yrzx.js +2 -0
  51. package/dist/chunks/MetricsCountryMapView-Dzk3Yrzx.js.map +1 -0
  52. package/dist/chunks/Modal-DBJU16cc.js +3 -0
  53. package/dist/chunks/Modal-DBJU16cc.js.map +1 -0
  54. package/dist/chunks/Modal-DuULCMFZ.js +3 -0
  55. package/dist/chunks/Modal-DuULCMFZ.js.map +1 -0
  56. package/dist/chunks/Passkeys-CGRZ8ZMv.js +2 -0
  57. package/dist/chunks/{Passkeys-DfVHrRPY.js.map → Passkeys-CGRZ8ZMv.js.map} +1 -1
  58. package/dist/chunks/Passkeys-Dr8-oSm9.js +2 -0
  59. package/dist/chunks/{Passkeys-Bj-ufmei.js.map → Passkeys-Dr8-oSm9.js.map} +1 -1
  60. package/dist/chunks/TokenManager-CcQFvaFD.js +2 -0
  61. package/dist/chunks/TokenManager-CcQFvaFD.js.map +1 -0
  62. package/dist/chunks/TokenManager-DEWZqbuo.js +2 -0
  63. package/dist/chunks/TokenManager-DEWZqbuo.js.map +1 -0
  64. package/dist/chunks/User-DNQhdBtI.js +2 -0
  65. package/dist/chunks/User-DNQhdBtI.js.map +1 -0
  66. package/dist/chunks/User-Dg7xpYEI.js +2 -0
  67. package/dist/chunks/User-Dg7xpYEI.js.map +1 -0
  68. package/dist/chunks/UserProfileView-B5nczdfw.js +2 -0
  69. package/dist/chunks/UserProfileView-B5nczdfw.js.map +1 -0
  70. package/dist/chunks/UserProfileView-Bpz3VZmP.js +2 -0
  71. package/dist/chunks/UserProfileView-Bpz3VZmP.js.map +1 -0
  72. package/dist/chunks/View-C5n3sIFi.js +2 -0
  73. package/dist/chunks/View-C5n3sIFi.js.map +1 -0
  74. package/dist/chunks/View-Yazho7OL.js +2 -0
  75. package/dist/chunks/View-Yazho7OL.js.map +1 -0
  76. package/dist/chunks/WebApp-CeiDNV6L.js +2 -0
  77. package/dist/chunks/WebApp-CeiDNV6L.js.map +1 -0
  78. package/dist/chunks/WebApp-irKlhuFX.js +2 -0
  79. package/dist/chunks/WebApp-irKlhuFX.js.map +1 -0
  80. package/dist/chunks/admin-B5tf0zOO.js +2 -0
  81. package/dist/chunks/admin-B5tf0zOO.js.map +1 -0
  82. package/dist/chunks/admin-CGoTpXfs.js +2 -0
  83. package/dist/chunks/admin-CGoTpXfs.js.map +1 -0
  84. package/dist/chunks/exportChart-BTJBYkOz.js +2 -0
  85. package/dist/chunks/exportChart-BTJBYkOz.js.map +1 -0
  86. package/dist/chunks/exportChart-kQ-we4Cp.js +2 -0
  87. package/dist/chunks/exportChart-kQ-we4Cp.js.map +1 -0
  88. package/dist/chunks/index-BNjCQA7q.js +2 -0
  89. package/dist/chunks/{index-BY54viKF.js.map → index-BNjCQA7q.js.map} +1 -1
  90. package/dist/chunks/index-DBsIDOAa.js +2 -0
  91. package/dist/chunks/{index-Df5lx5TH.js.map → index-DBsIDOAa.js.map} +1 -1
  92. package/dist/chunks/version-BURwX10Q.js +2 -0
  93. package/dist/chunks/version-BURwX10Q.js.map +1 -0
  94. package/dist/chunks/version-CYGIXntv.js +2 -0
  95. package/dist/chunks/version-CYGIXntv.js.map +1 -0
  96. package/dist/core.css +306 -0
  97. package/dist/css/web-mojo.css +1 -1
  98. package/dist/docit.cjs.js +1 -1
  99. package/dist/docit.cjs.js.map +1 -1
  100. package/dist/docit.es.js +1 -1
  101. package/dist/docit.es.js.map +1 -1
  102. package/dist/index.cjs.js +1 -1
  103. package/dist/index.cjs.js.map +1 -1
  104. package/dist/index.es.js +1 -1
  105. package/dist/index.es.js.map +1 -1
  106. package/dist/lightbox.cjs.js +1 -1
  107. package/dist/lightbox.cjs.js.map +1 -1
  108. package/dist/lightbox.es.js +1 -1
  109. package/dist/lightbox.es.js.map +1 -1
  110. package/dist/map.cjs.js +1 -1
  111. package/dist/map.cjs.js.map +1 -1
  112. package/dist/map.es.js +1 -1
  113. package/dist/map.es.js.map +1 -1
  114. package/dist/mojo-auth.es.js +94 -65
  115. package/dist/mojo-auth.umd.js +1 -1
  116. package/dist/portal.css +86 -0
  117. package/dist/timeline.cjs.js +1 -1
  118. package/dist/timeline.cjs.js.map +1 -1
  119. package/dist/timeline.es.js +1 -1
  120. package/dist/timeline.es.js.map +1 -1
  121. package/dist/user-profile.cjs.js +1 -1
  122. package/dist/user-profile.es.js +1 -1
  123. package/dist/web-mojo.lite.iife.js +4183 -3916
  124. package/dist/web-mojo.lite.iife.js.map +1 -1
  125. package/dist/web-mojo.lite.iife.min.js +289 -311
  126. package/dist/web-mojo.lite.iife.min.js.map +1 -1
  127. package/package.json +7 -2
  128. package/dist/chunks/AssistantPanelView-Bdpmd4z7.js +0 -2
  129. package/dist/chunks/AssistantPanelView-Bdpmd4z7.js.map +0 -1
  130. package/dist/chunks/AssistantPanelView-C0bdbEWr.js +0 -2
  131. package/dist/chunks/AssistantPanelView-C0bdbEWr.js.map +0 -1
  132. package/dist/chunks/ChatView-B1MZNPGy.js +0 -2
  133. package/dist/chunks/ChatView-B1MZNPGy.js.map +0 -1
  134. package/dist/chunks/ChatView-DXl9nVVV.js +0 -2
  135. package/dist/chunks/ChatView-DXl9nVVV.js.map +0 -1
  136. package/dist/chunks/Collection-C39Oy2q0.js +0 -2
  137. package/dist/chunks/Collection-C39Oy2q0.js.map +0 -1
  138. package/dist/chunks/Collection-CyK0u557.js +0 -2
  139. package/dist/chunks/Collection-CyK0u557.js.map +0 -1
  140. package/dist/chunks/ContextMenu-D-C7V6J6.js +0 -2
  141. package/dist/chunks/ContextMenu-D-C7V6J6.js.map +0 -1
  142. package/dist/chunks/ContextMenu-hjqR1pGW.js +0 -2
  143. package/dist/chunks/ContextMenu-hjqR1pGW.js.map +0 -1
  144. package/dist/chunks/DataView-BFx2glFg.js +0 -2
  145. package/dist/chunks/DataView-D5C_lDdg.js +0 -2
  146. package/dist/chunks/Dialog-1umNJi4B.js +0 -3
  147. package/dist/chunks/Dialog-1umNJi4B.js.map +0 -1
  148. package/dist/chunks/Dialog-BnxWLMfr.js +0 -3
  149. package/dist/chunks/Dialog-BnxWLMfr.js.map +0 -1
  150. package/dist/chunks/FormView-Cu4iPfvU.js +0 -3
  151. package/dist/chunks/FormView-e-PeRx1s.js +0 -3
  152. package/dist/chunks/ListView-D_hOtfWZ.js +0 -2
  153. package/dist/chunks/ListView-D_hOtfWZ.js.map +0 -1
  154. package/dist/chunks/ListView-Jkke6pU1.js +0 -2
  155. package/dist/chunks/ListView-Jkke6pU1.js.map +0 -1
  156. package/dist/chunks/MetricsCountryMapView-UdvJWArx.js +0 -2
  157. package/dist/chunks/MetricsCountryMapView-UdvJWArx.js.map +0 -1
  158. package/dist/chunks/MetricsCountryMapView-jLWCL6Hm.js +0 -2
  159. package/dist/chunks/MetricsCountryMapView-jLWCL6Hm.js.map +0 -1
  160. package/dist/chunks/MetricsMiniChartWidget-BaXxR9C6.js +0 -2
  161. package/dist/chunks/MetricsMiniChartWidget-BaXxR9C6.js.map +0 -1
  162. package/dist/chunks/MetricsMiniChartWidget-DSKmKY2Z.js +0 -2
  163. package/dist/chunks/MetricsMiniChartWidget-DSKmKY2Z.js.map +0 -1
  164. package/dist/chunks/MiniPieChart-B3sM4Bjv.js +0 -2
  165. package/dist/chunks/MiniPieChart-B3sM4Bjv.js.map +0 -1
  166. package/dist/chunks/MiniPieChart-DL5Rynvm.js +0 -2
  167. package/dist/chunks/MiniPieChart-DL5Rynvm.js.map +0 -1
  168. package/dist/chunks/MiniSeriesChart-C4DPVbU_.js +0 -2
  169. package/dist/chunks/MiniSeriesChart-C4DPVbU_.js.map +0 -1
  170. package/dist/chunks/MiniSeriesChart-DdNMLwfh.js +0 -2
  171. package/dist/chunks/MiniSeriesChart-DdNMLwfh.js.map +0 -1
  172. package/dist/chunks/Modal-COT4zRh3.js +0 -2
  173. package/dist/chunks/Modal-COT4zRh3.js.map +0 -1
  174. package/dist/chunks/Modal-DgMMvDnw.js +0 -2
  175. package/dist/chunks/Modal-DgMMvDnw.js.map +0 -1
  176. package/dist/chunks/Passkeys-Bj-ufmei.js +0 -2
  177. package/dist/chunks/Passkeys-DfVHrRPY.js +0 -2
  178. package/dist/chunks/TokenManager-DIEaBGJh.js +0 -2
  179. package/dist/chunks/TokenManager-DIEaBGJh.js.map +0 -1
  180. package/dist/chunks/TokenManager-DeXkJy0u.js +0 -2
  181. package/dist/chunks/TokenManager-DeXkJy0u.js.map +0 -1
  182. package/dist/chunks/UserProfileView-B_jyMUp0.js +0 -2
  183. package/dist/chunks/UserProfileView-B_jyMUp0.js.map +0 -1
  184. package/dist/chunks/UserProfileView-DcpvvGQS.js +0 -2
  185. package/dist/chunks/UserProfileView-DcpvvGQS.js.map +0 -1
  186. package/dist/chunks/WebApp-BvFnKj-I.js +0 -2
  187. package/dist/chunks/WebApp-BvFnKj-I.js.map +0 -1
  188. package/dist/chunks/WebApp-CfDWKmwH.js +0 -2
  189. package/dist/chunks/WebApp-CfDWKmwH.js.map +0 -1
  190. package/dist/chunks/WebSocketClient-BQAZr8C4.js +0 -2
  191. package/dist/chunks/WebSocketClient-BQAZr8C4.js.map +0 -1
  192. package/dist/chunks/WebSocketClient-YR5d82h8.js +0 -2
  193. package/dist/chunks/WebSocketClient-YR5d82h8.js.map +0 -1
  194. package/dist/chunks/admin-BgvcCWQp.js +0 -2
  195. package/dist/chunks/admin-BgvcCWQp.js.map +0 -1
  196. package/dist/chunks/admin-DzhyZ_Tn.js +0 -2
  197. package/dist/chunks/admin-DzhyZ_Tn.js.map +0 -1
  198. package/dist/chunks/index-BY54viKF.js +0 -2
  199. package/dist/chunks/index-Df5lx5TH.js +0 -2
  200. package/dist/chunks/version-8mBBYRDe.js +0 -2
  201. package/dist/chunks/version-8mBBYRDe.js.map +0 -1
  202. package/dist/chunks/version-CoLHxZIU.js +0 -2
  203. package/dist/chunks/version-CoLHxZIU.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"MetricsCountryMapView-jLWCL6Hm.js","sources":["../../src/extensions/map/MapView.js","../../src/extensions/map/MapLibreView.js","../../src/extensions/map/countryCentroids.js","../../src/extensions/map/MetricsCountryMapView.js"],"sourcesContent":["/**\n * MapView - Interactive map component using Leaflet\n *\n * Features:\n * - Display single or multiple markers\n * - Auto-zoom to fit markers\n * - Customizable marker popups\n * - Support for different tile layers\n *\n * @example\n * const mapView = new MapView({\n * markers: [\n * { lat: 37.422, lng: -122.084, popup: 'Mountain View, CA' }\n * ],\n * zoom: 10,\n * height: 400\n * });\n */\n\nimport View from '@core/View.js';\n\nclass MapView extends View {\n constructor(options = {}) {\n super({\n className: 'map-view',\n ...options\n });\n\n this.markers = options.markers || [];\n this.center = options.center || null;\n this.zoom = options.zoom || 13;\n this.height = options.height || 400;\n this.showZoomControl = options.showZoomControl !== false;\n this.tileLayer = options.tileLayer || 'osm'; // 'osm', 'satellite', 'terrain'\n this.showLeafletBranding = options.showLeafletBranding === true;\n this.showLayerControl = options.showLayerControl === true;\n this.layerOptions = options.layerOptions || {\n osm: 'OSM',\n satellite: 'Satellite',\n terrain: 'Terrain',\n dark: 'Dark',\n light: 'Light',\n watercolor: 'Watercolor',\n bw: 'B/W',\n streets: 'Streets'\n };\n\n this.map = null;\n this.leafletMarkers = [];\n this._tileLayer = null;\n\n this.template = `\n <div class=\"map-container\">\n <div id=\"map-{{id}}\" style=\"height: {{height}}px; width: 100%; border-radius: 0.375rem; border: 1px solid #dee2e6;\"></div>\n </div>\n `;\n }\n\n async onAfterRender() {\n await this.loadLeaflet();\n await this.initializeMap();\n }\n\n async loadLeaflet() {\n // Check if Leaflet is already loaded\n if (window.L) return;\n\n // Load Leaflet CSS and wait for it\n const cssLoaded = new Promise((resolve) => {\n const link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = 'https://unpkg.com/leaflet@1.9.4/dist/leaflet.css';\n link.onload = resolve;\n link.onerror = resolve; // Continue even if CSS fails\n document.head.appendChild(link);\n });\n\n // Load Leaflet JS\n const jsLoaded = new Promise((resolve, reject) => {\n const script = document.createElement('script');\n script.src = 'https://unpkg.com/leaflet@1.9.4/dist/leaflet.js';\n script.onload = resolve;\n script.onerror = reject;\n document.head.appendChild(script);\n });\n\n // Wait for both CSS and JS to load\n await Promise.all([cssLoaded, jsLoaded]);\n }\n\n getTileLayerUrl() {\n const tileLayers = {\n // Standard street maps\n osm: {\n url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',\n attribution: '© OpenStreetMap contributors',\n maxZoom: 19\n },\n\n // Satellite imagery\n satellite: {\n url: 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',\n attribution: '© Esri',\n maxZoom: 19\n },\n\n // Terrain and topographic\n terrain: {\n url: 'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png',\n attribution: '© OpenTopoMap contributors',\n maxZoom: 17\n },\n\n // Dark mode styles\n dark: {\n url: 'https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png',\n attribution: '© OpenStreetMap contributors © CARTO',\n maxZoom: 20\n },\n\n // Light/minimal styles\n light: {\n url: 'https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png',\n attribution: '© OpenStreetMap contributors © CARTO',\n maxZoom: 20\n },\n\n // Watercolor artistic style\n watercolor: {\n url: 'https://tiles.stadiamaps.com/tiles/stamen_watercolor/{z}/{x}/{y}.jpg',\n attribution: '© Stadia Maps © Stamen Design © OpenStreetMap contributors',\n maxZoom: 16\n },\n\n // Black and white\n bw: {\n url: 'https://{s}.basemaps.cartocdn.com/light_nolabels/{z}/{x}/{y}{r}.png',\n attribution: '© OpenStreetMap contributors © CARTO',\n maxZoom: 20\n },\n\n // Streets with labels\n streets: {\n url: 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png',\n attribution: '© OpenStreetMap contributors © CARTO',\n maxZoom: 20\n }\n };\n\n return tileLayers[this.tileLayer] || tileLayers.osm;\n }\n\n async initializeMap() {\n const mapElement = this.element.querySelector(`#map-${this.id}`);\n if (!mapElement || !window.L) return;\n\n // Determine map center\n let mapCenter = this.center;\n if (!mapCenter && this.markers.length > 0) {\n // Use first marker as center\n mapCenter = [this.markers[0].lat, this.markers[0].lng];\n }\n if (!mapCenter) {\n // Default to world view\n mapCenter = [0, 0];\n }\n\n // Create map\n this.map = window.L.map(mapElement, {\n center: mapCenter,\n zoom: this.zoom,\n zoomControl: this.showZoomControl\n });\n // Optionally hide Leaflet branding/prefix (removes Leaflet link/flag in attribution control)\n if (this.map && this.map.attributionControl && this.showLeafletBranding === false) {\n try { this.map.attributionControl.setPrefix(''); } catch (e) {}\n }\n\n // Add tile layer\n const tileConfig = this.getTileLayerUrl();\n this._tileLayer = window.L.tileLayer(tileConfig.url, {\n attribution: tileConfig.attribution,\n maxZoom: tileConfig.maxZoom\n }).addTo(this.map);\n\n // Optional built-in tile layer selector UI\n if (this.showLayerControl) {\n const container = mapElement.parentElement || this.element.querySelector('.map-container');\n if (container) {\n container.style.position = container.style.position || 'relative';\n const selector = document.createElement('select');\n selector.className = 'form-select form-select-sm';\n selector.style.position = 'absolute';\n selector.style.top = '8px';\n selector.style.right = '8px';\n selector.style.zIndex = '1000';\n selector.style.maxWidth = '180px';\n selector.setAttribute('aria-label', 'Map tile layer');\n\n // Populate options\n Object.entries(this.layerOptions || {}).forEach(([key, label]) => {\n const opt = document.createElement('option');\n opt.value = key;\n opt.textContent = label;\n if (key === this.tileLayer) opt.selected = true;\n selector.appendChild(opt);\n });\n\n selector.addEventListener('change', () => this.setTileLayer(selector.value));\n container.appendChild(selector);\n }\n }\n\n // Add markers\n this.addMarkers(this.markers);\n\n // Auto-fit bounds if multiple markers\n if (this.markers.length > 1) {\n this.fitBounds();\n }\n\n // Fix tile rendering issues by invalidating size after a delay\n // This ensures the container has proper dimensions and CSS is applied\n setTimeout(() => {\n if (this.map) {\n this.map.invalidateSize();\n }\n }, 300);\n }\n\n addMarkers(markers) {\n if (!this.map || !Array.isArray(markers)) return;\n\n markers.forEach(markerData => {\n const { lat, lng, popup, icon } = markerData;\n\n if (!lat || !lng) return;\n\n const markerOptions = {};\n\n // Custom icon if provided\n if (icon) {\n markerOptions.icon = window.L.icon(icon);\n }\n\n const marker = window.L.marker([lat, lng], markerOptions).addTo(this.map);\n\n // Add popup if provided\n if (popup) {\n marker.bindPopup(popup);\n }\n\n this.leafletMarkers.push(marker);\n });\n }\n\n fitBounds() {\n if (!this.map || this.leafletMarkers.length === 0) return;\n\n const group = new window.L.featureGroup(this.leafletMarkers);\n this.map.fitBounds(group.getBounds().pad(0.1));\n }\n\n updateMarkers(newMarkers) {\n // Clear existing markers\n this.clearMarkers();\n\n // Add new markers\n this.markers = newMarkers;\n this.addMarkers(newMarkers);\n\n // Fit bounds if multiple markers\n if (newMarkers.length > 1) {\n this.fitBounds();\n } else if (newMarkers.length === 1) {\n this.map.setView([newMarkers[0].lat, newMarkers[0].lng], this.zoom);\n }\n }\n\n clearMarkers() {\n this.leafletMarkers.forEach(marker => {\n this.map.removeLayer(marker);\n });\n this.leafletMarkers = [];\n }\n\n setView(lat, lng, zoom = null) {\n if (!this.map) return;\n this.map.setView([lat, lng], zoom || this.zoom);\n }\n\n setZoom(zoom) {\n if (!this.map) return;\n this.map.setZoom(zoom);\n }\n\n setTileLayer(key) {\n if (!this.map) return;\n // Resolve tile layer config using the same logic as getTileLayerUrl\n const original = this.tileLayer;\n this.tileLayer = key || this.tileLayer;\n const tileConfig = this.getTileLayerUrl();\n try {\n if (this._tileLayer) {\n this.map.removeLayer(this._tileLayer);\n }\n } catch (e) {\n // ignore if layer already removed\n }\n this._tileLayer = window.L.tileLayer(tileConfig.url, {\n attribution: tileConfig.attribution,\n maxZoom: tileConfig.maxZoom\n }).addTo(this.map);\n // Keep property in sync\n this.tileLayer = key || original;\n\n // Nudge map to ensure proper redraw\n setTimeout(() => {\n try { this.map.invalidateSize(); } catch (e) {}\n }, 150);\n }\n\n async onBeforeDestroy() {\n if (this.map) {\n this.map.remove();\n this.map = null;\n }\n await super.onBeforeDestroy();\n }\n\n static async showAsDialog(options = {}) {\n const view = new MapView(options);\n const dopts = options.dialogOptions || {};\n const dialogOptions = {\n title: \"Map View\",\n header: true,\n body: view,\n size: 'lg',\n centered: false,\n ...dopts\n }\n await view.init();\n await view.getApp().showDialog(dialogOptions);\n }\n}\n\nexport default MapView;\n","/**\n * MapLibreView - Interactive vector map component using MapLibre GL JS\n * \n * MapLibre GL is better for:\n * - Vector tiles and custom styling\n * - 3D terrain and buildings\n * - High-performance rendering\n * - Heat maps and data visualizations\n * - Complex animations\n * \n * Use MapView (Leaflet) for simple marker maps.\n * Use MapLibreView for advanced visualizations.\n * \n * @example\n * const mapView = new MapLibreView({\n * markers: [\n * { lng: -122.084, lat: 37.422, popup: 'Mountain View, CA' }\n * ],\n * style: 'streets', // 'streets', 'satellite', 'dark', 'light'\n * zoom: 10,\n * height: 400\n * });\n */\n\nimport View from '@core/View.js';\n\nclass MapLibreView extends View {\n constructor(options = {}) {\n super({\n className: 'maplibre-view',\n ...options\n });\n\n this.markers = options.markers || [];\n this.center = options.center || null;\n this.zoom = options.zoom || 13;\n this.height = options.height || 400;\n this.pitch = options.pitch || 0; // 0-60 degrees (3D tilt)\n this.bearing = options.bearing || 0; // 0-360 degrees (rotation)\n this.mapStyle = options.style || 'streets'; // 'streets', 'satellite', 'dark', 'light', 'terrain'\n this.showNavigationControl = options.showNavigationControl !== false;\n this.autoFitBounds = options.autoFitBounds !== false;\n \n this.map = null;\n this.mapMarkers = [];\n this.pendingMarkers = [...this.markers];\n this.lineSources = options.lineSources || [];\n this.pendingLineData = new Map();\n\n this.template = `\n <div class=\"maplibre-container\">\n <div id=\"maplibre-{{id}}\" style=\"height: {{height}}px; width: 100%; border-radius: 0.375rem; border: 1px solid #dee2e6;\"></div>\n </div>\n `;\n }\n\n async onAfterRender() {\n await this.loadMapLibre();\n await this.initializeMap();\n }\n\n async loadMapLibre() {\n // Check if MapLibre is already loaded\n if (window.maplibregl) return;\n\n // Load MapLibre CSS\n const link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = 'https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl.css';\n document.head.appendChild(link);\n\n // Load MapLibre JS\n return new Promise((resolve, reject) => {\n const script = document.createElement('script');\n script.src = 'https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl.js';\n script.onload = resolve;\n script.onerror = reject;\n document.head.appendChild(script);\n });\n }\n\n getMapStyle() {\n const styles = {\n streets: 'https://demotiles.maplibre.org/style.json',\n dark: {\n version: 8,\n sources: {\n osm: {\n type: 'raster',\n tiles: ['https://a.tile.openstreetmap.org/{z}/{x}/{y}.png'],\n tileSize: 256,\n attribution: '© OpenStreetMap contributors'\n }\n },\n layers: [{\n id: 'osm',\n type: 'raster',\n source: 'osm'\n }],\n glyphs: 'https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf'\n },\n light: {\n version: 8,\n sources: {\n osm: {\n type: 'raster',\n tiles: ['https://a.tile.openstreetmap.org/{z}/{x}/{y}.png'],\n tileSize: 256,\n attribution: '© OpenStreetMap contributors'\n }\n },\n layers: [{\n id: 'osm',\n type: 'raster',\n source: 'osm'\n }],\n glyphs: 'https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf'\n },\n satellite: {\n version: 8,\n sources: {\n satellite: {\n type: 'raster',\n tiles: ['https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}'],\n tileSize: 256,\n attribution: '© Esri'\n }\n },\n layers: [{\n id: 'satellite',\n type: 'raster',\n source: 'satellite'\n }],\n glyphs: 'https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf'\n },\n terrain: {\n version: 8,\n sources: {\n terrain: {\n type: 'raster',\n tiles: ['https://a.tile.opentopomap.org/{z}/{x}/{y}.png'],\n tileSize: 256,\n attribution: '© OpenTopoMap contributors'\n }\n },\n layers: [{\n id: 'terrain',\n type: 'raster',\n source: 'terrain'\n }],\n glyphs: 'https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf'\n }\n };\n\n return styles[this.mapStyle] || styles.streets;\n }\n\n async initializeMap() {\n const mapElement = this.element.querySelector(`#maplibre-${this.id}`);\n if (!mapElement || !window.maplibregl) return;\n\n // Determine map center\n let mapCenter = this.center;\n if (!mapCenter && this.markers.length > 0) {\n // Use first marker as center (MapLibre uses [lng, lat])\n mapCenter = [this.markers[0].lng, this.markers[0].lat];\n }\n if (!mapCenter) {\n // Default to world view\n mapCenter = [0, 0];\n }\n\n // Create map\n this.map = new window.maplibregl.Map({\n container: mapElement,\n style: this.getMapStyle(),\n center: mapCenter,\n zoom: this.zoom,\n pitch: this.pitch,\n bearing: this.bearing\n });\n\n // Add navigation control\n if (this.showNavigationControl) {\n this.map.addControl(new window.maplibregl.NavigationControl(), 'top-right');\n }\n\n // Wait for map to load before adding markers\n this.map.on('load', () => {\n const initialMarkers = this.pendingMarkers.length ? this.pendingMarkers : this.markers;\n this.updateMarkers(initialMarkers);\n this.lineSources.forEach(source => this.addLineSource(source));\n this.pendingLineData.forEach(source => this.addLineSource(source));\n this.pendingLineData.clear();\n });\n }\n\n addMarkers(markers) {\n if (!this.map || !Array.isArray(markers)) {\n this.pendingMarkers = Array.isArray(markers) ? markers : [];\n return;\n }\n\n markers.forEach(markerData => {\n const { lng, lat, popup, color, icon, size } = markerData;\n \n if (!lng || !lat) return;\n\n // Create marker element\n const el = document.createElement('div');\n el.className = 'maplibre-marker';\n const markerSize = Number(size) || 30;\n el.style.width = `${markerSize}px`;\n el.style.height = `${markerSize}px`;\n el.style.borderRadius = '50%';\n el.style.backgroundColor = color || '#3b82f6';\n el.style.border = '3px solid white';\n el.style.boxShadow = '0 2px 4px rgba(0,0,0,0.3)';\n el.style.cursor = 'pointer';\n el.style.display = 'flex';\n el.style.alignItems = 'center';\n el.style.justifyContent = 'center';\n\n // Optional icon\n if (icon) {\n el.innerHTML = `<i class=\"${icon}\" style=\"color: white;\"></i>`;\n }\n\n // Create marker\n const marker = new window.maplibregl.Marker({ element: el })\n .setLngLat([lng, lat])\n .addTo(this.map);\n\n // Add popup if provided\n if (popup) {\n const mapPopup = new window.maplibregl.Popup({ offset: 25 })\n .setHTML(popup);\n marker.setPopup(mapPopup);\n }\n\n this.mapMarkers.push(marker);\n });\n }\n\n fitBounds() {\n if (!this.map || this.markers.length === 0) return;\n\n const bounds = new window.maplibregl.LngLatBounds();\n \n this.markers.forEach(marker => {\n bounds.extend([marker.lng, marker.lat]);\n });\n\n this.map.fitBounds(bounds, {\n padding: 50,\n maxZoom: 15\n });\n }\n\n updateMarkers(newMarkers) {\n const markers = Array.isArray(newMarkers) ? newMarkers : [];\n this.markers = markers;\n this.pendingMarkers = markers;\n if (!this.map) return;\n\n this.clearMarkers();\n this.addMarkers(markers);\n\n if (this.autoFitBounds && markers.length > 1) {\n this.fitBounds();\n } else if (markers.length === 1 && this.map) {\n this.map.flyTo({\n center: [markers[0].lng, markers[0].lat],\n zoom: this.zoom\n });\n }\n }\n\n clearMarkers() {\n this.mapMarkers.forEach(marker => {\n marker.remove();\n });\n this.mapMarkers = [];\n }\n\n addLineSource({ id, data, paint, layout }) {\n if (!id || !data) return;\n\n const sourceId = `${id}-source`;\n\n if (!this.map) {\n this.pendingLineData.set(id, { id, data, paint, layout });\n return;\n }\n\n if (this.map.getLayer(id)) {\n this.map.removeLayer(id);\n }\n if (this.map.getSource(sourceId)) {\n this.map.removeSource(sourceId);\n }\n\n this.map.addSource(sourceId, {\n type: 'geojson',\n data\n });\n\n this.map.addLayer({\n id,\n type: 'line',\n source: sourceId,\n paint: {\n 'line-color': '#3b82f6',\n 'line-width': 2,\n 'line-opacity': 0.6,\n ...paint\n },\n layout: {\n 'line-cap': 'round',\n 'line-join': 'round',\n ...layout\n }\n });\n }\n\n updateLineSource(id, { data, paint, layout } = {}) {\n if (!id || !data) return;\n const sourceId = `${id}-source`;\n if (!this.map) {\n this.pendingLineData.set(id, { id, data, paint, layout });\n return;\n }\n if (this.map.getSource(sourceId)) {\n this.map.getSource(sourceId).setData(data);\n if (paint || layout) {\n if (paint) {\n Object.entries(paint).forEach(([key, value]) => {\n this.map.setPaintProperty(id, key, value);\n });\n }\n if (layout) {\n Object.entries(layout).forEach(([key, value]) => {\n this.map.setLayoutProperty(id, key, value);\n });\n }\n }\n } else {\n this.addLineSource({ id, data, paint, layout });\n }\n }\n\n setView(lng, lat, zoom = null) {\n if (!this.map) return;\n this.map.flyTo({\n center: [lng, lat],\n zoom: zoom || this.zoom\n });\n }\n\n setZoom(zoom) {\n if (!this.map) return;\n this.map.setZoom(zoom);\n }\n\n setPitch(pitch) {\n if (!this.map) return;\n this.map.setPitch(pitch);\n }\n\n setBearing(bearing) {\n if (!this.map) return;\n this.map.setBearing(bearing);\n }\n\n async onBeforeDestroy() {\n if (this.map) {\n this.map.remove();\n this.map = null;\n }\n await super.onBeforeDestroy();\n }\n}\n\nexport default MapLibreView;\n","// Auto-generated from countries.geojson - do not edit manually.\nexport const COUNTRY_CENTROIDS = {\n \"AD\": { name: \"Andorra\", lat: 42.54859834854764, lng: 1.5802243611232873 },\n \"AE\": { name: \"United Arab Emirates\", lat: 24.18250292309135, lng: 54.27920525789581 },\n \"AF\": { name: \"Afghanistan\", lat: 34.13402601376932, lng: 66.59216131095278 },\n \"AG\": { name: \"Antigua and Barbuda\", lat: 17.07146759372967, lng: -61.78530823226373 },\n \"AI\": { name: \"Anguilla\", lat: 18.222874004219086, lng: -63.06008343771806 },\n \"AL\": { name: \"Albania\", lat: 41.14165894891656, lng: 20.061082767269493 },\n \"AM\": { name: \"Armenia\", lat: 40.17841274230679, lng: 45.05490831965259 },\n \"AO\": { name: \"Angola\", lat: -12.167424062667942, lng: 17.651768783079 },\n \"AQ\": { name: \"Antarctica\", lat: -77.16987521415838, lng: -177.56451613408842 },\n \"AR\": { name: \"Argentina\", lat: -35.697270518120085, lng: -64.53238503843076 },\n \"AS\": { name: \"American Samoa\", lat: -14.305711987770538, lng: -170.7007316174498 },\n \"AT\": { name: \"Austria\", lat: 47.631858269895794, lng: 13.797778364631036 },\n \"AU\": { name: \"Australia\", lat: -25.697337673983082, lng: 134.02277170916162 },\n \"AW\": { name: \"Aruba\", lat: 12.515625722992898, lng: -69.97564014284046 },\n \"AZ\": { name: \"Azerbaijan\", lat: 40.3920509942049, lng: 48.634592670644324 },\n \"BA\": { name: \"Bosnia and Herzegovina\", lat: 44.14415356126429, lng: 17.83467240787538 },\n \"BB\": { name: \"Barbados\", lat: 13.183219369337529, lng: -59.557383949150285 },\n \"BD\": { name: \"Bangladesh\", lat: 23.673728665121, lng: 90.43212562608613 },\n \"BE\": { name: \"Belgium\", lat: 50.6182138854095, lng: 4.675010154696485 },\n \"BF\": { name: \"Burkina Faso\", lat: 12.108709036312737, lng: -1.6932816211842325 },\n \"BG\": { name: \"Bulgaria\", lat: 42.82043677302438, lng: 25.251739122561908 },\n \"BH\": { name: \"Bahrain\", lat: 26.04798501537066, lng: 50.540695402276775 },\n \"BI\": { name: \"Burundi\", lat: -3.261251993278643, lng: 29.88518227845293 },\n \"BJ\": { name: \"Benin\", lat: 9.503013199615893, lng: 2.305714528830206 },\n \"BL\": { name: \"Saint Barthelemy\", lat: 17.90561691241738, lng: -62.83051610005156 },\n \"BM\": { name: \"Bermuda\", lat: 32.315067430740726, lng: -64.7458500599169 },\n \"BN\": { name: \"Brunei Darussalam\", lat: 4.543205889917609, lng: 114.6430958360464 },\n \"BO\": { name: \"Bolivia\", lat: -16.7312488393574, lng: -64.45209597511206 },\n \"BQ\": { name: \"Bonaire\", lat: 12.180844982440338, lng: -68.29350445958761 },\n \"BQ\": { name: \"Saba\", lat: 17.632512616389718, lng: -63.23739481909494 },\n \"BQ\": { name: \"Saint Eustatius\", lat: 17.4919042294197, lng: -62.978230589445026 },\n \"BR\": { name: \"Brazil\", lat: -11.524630416426652, lng: -54.355206608256424 },\n \"BS\": { name: \"Bahamas\", lat: 24.72162633646784, lng: -78.07275370060313 },\n \"BT\": { name: \"Bhutan\", lat: 27.42163933959824, lng: 90.46716647173861 },\n \"BV\": { name: \"Bouvet Island\", lat: -54.42316679395248, lng: 3.411969465057627 },\n \"BW\": { name: \"Botswana\", lat: -22.236609002062902, lng: 23.85779956995608 },\n \"BY\": { name: \"Belarus\", lat: 53.46791374543163, lng: 27.964252054715104 },\n \"BZ\": { name: \"Belize\", lat: 17.24252476647155, lng: -88.68273510023441 },\n \"CA\": { name: \"Canada\", lat: 57.550480044655636, lng: -98.41680517868062 },\n \"CC\": { name: \"Cocos Islands\", lat: -12.171249450199545, lng: 96.83688767323002 },\n \"CD\": { name: \"Congo DRC\", lat: -3.338629596207896, lng: 23.419827574282188 },\n \"CF\": { name: \"Central African Republic\", lat: 6.331390033944319, lng: 20.520743419397256 },\n \"CG\": { name: \"Congo\", lat: -0.7294391595233845, lng: 14.879732849491393 },\n \"CH\": { name: \"Switzerland\", lat: 46.73678128684938, lng: 8.286928794895285 },\n \"CI\": { name: \"Côte d'Ivoire\", lat: 7.536779279421307, lng: -5.571710194917734 },\n \"CK\": { name: \"Cook Islands\", lat: -21.222613253399842, lng: -159.78768870952257 },\n \"CL\": { name: \"Chile\", lat: -37.82938283049967, lng: -70.76863431739216 },\n \"CM\": { name: \"Cameroon\", lat: 6.294168487480992, lng: 12.948474142398263 },\n \"CN\": { name: \"China\", lat: 38.07325481105728, lng: 104.69113855849604 },\n \"CO\": { name: \"Colombia\", lat: 4.187753877352739, lng: -72.6445066243485 },\n \"CR\": { name: \"Costa Rica\", lat: 9.863467407406214, lng: -84.14673625701816 },\n \"CU\": { name: \"Cuba\", lat: 21.476176522869448, lng: -79.69817857618705 },\n \"CV\": { name: \"Cabo Verde\", lat: 15.076411518651643, lng: -23.63401005900474 },\n \"CW\": { name: \"Curacao\", lat: 12.199996647939832, lng: -68.96939768599042 },\n \"CX\": { name: \"Christmas Island\", lat: -10.446440802183416, lng: 105.70209512200549 },\n \"CY\": { name: \"Cyprus\", lat: 35.11700416345239, lng: 33.375346009199205 },\n \"CZ\": { name: \"Czech Republic\", lat: 49.74917370930982, lng: 15.383273292023533 },\n \"DE\": { name: \"Germany\", lat: 51.08304539800482, lng: 10.426171427430804 },\n \"DJ\": { name: \"Djibouti\", lat: 11.750235727618804, lng: 42.613496898789506 },\n \"DK\": { name: \"Denmark\", lat: 56.00118817971057, lng: 9.378670542409406 },\n \"DM\": { name: \"Dominica\", lat: 15.429269860940513, lng: -61.360471946942994 },\n \"DO\": { name: \"Dominican Republic\", lat: 18.77954818522993, lng: -70.43495198520012 },\n \"DZ\": { name: \"Algeria\", lat: 28.350969744889056, lng: 2.6558464719769135 },\n \"EC\": { name: \"Ecuador\", lat: -1.5642721388853116, lng: -78.4630326109714 },\n \"EE\": { name: \"Estonia\", lat: 58.648108311231034, lng: 25.916870250633806 },\n \"EG\": { name: \"Egypt\", lat: 26.60517034450628, lng: 30.240135435012338 },\n \"ER\": { name: \"Eritrea\", lat: 15.005533147667684, lng: 39.2672401449901 },\n \"ES\": { name: \"Spain\", lat: 40.365008336683836, lng: -3.6516251409956983 },\n \"ES\": { name: \"Canarias\", lat: 28.297665106525546, lng: -16.53799441021647 },\n \"ET\": { name: \"Ethiopia\", lat: 8.729389557048396, lng: 39.914902886544276 },\n \"FI\": { name: \"Finland\", lat: 65.01578959749911, lng: 25.65738433454702 },\n \"FJ\": { name: \"Fiji\", lat: -17.822470952336204, lng: 177.98144613732626 },\n \"FK\": { name: \"Falkland Islands\", lat: -51.75901312766726, lng: -58.746646363799854 },\n \"FM\": { name: \"Micronesia\", lat: 6.8789448129255435, lng: 158.2291899444527 },\n \"FO\": { name: \"Faroe Islands\", lat: 62.130896281495346, lng: -6.9811060913122835 },\n \"FR\": { name: \"France\", lat: 46.6423682169416, lng: 2.1940236627886227 },\n \"GA\": { name: \"Gabon\", lat: -0.628448459921234, lng: 11.839410898545754 },\n \"GB\": { name: \"United Kingdom\", lat: 53.97844735080214, lng: -2.852943909329258 },\n \"GD\": { name: \"Grenada\", lat: 12.112926656338907, lng: -61.67937937204098 },\n \"GE\": { name: \"Georgia\", lat: 42.17986277737226, lng: 43.378866534112234 },\n \"GF\": { name: \"French Guiana\", lat: 3.857429742497078, lng: -53.32232307156624 },\n \"GG\": { name: \"Guernsey\", lat: 49.45870771378872, lng: -2.576392582891568 },\n \"GH\": { name: \"Ghana\", lat: 7.94530467243628, lng: -1.219233362526581 },\n \"GI\": { name: \"Gibraltar\", lat: 36.14022671336082, lng: -5.345549484594358 },\n \"GL\": { name: \"Greenland\", lat: 74.16847218965994, lng: -42.07567788066985 },\n \"GM\": { name: \"Gambia\", lat: 13.428617959189328, lng: -15.383380385869662 },\n \"GN\": { name: \"Guinea\", lat: 10.255986541378112, lng: -10.986948848040218 },\n \"GP\": { name: \"Guadeloupe\", lat: 16.24420002705553, lng: -61.54382262282755 },\n \"GQ\": { name: \"Equatorial Guinea\", lat: 1.5954643936590733, lng: 10.425456672353823 },\n \"GR\": { name: \"Greece\", lat: 39.42012261727978, lng: 23.110368936161876 },\n \"GS\": { name: \"South Georgia and South Sandwich Islands\", lat: -54.37666443862139, lng: -36.77509575898928 },\n \"GT\": { name: \"Guatemala\", lat: 15.820878515352684, lng: -90.31219349119617 },\n \"GU\": { name: \"Guam\", lat: 13.445430479945276, lng: 144.78024458298802 },\n \"GW\": { name: \"Guinea-Bissau\", lat: 11.980075324820504, lng: -14.980186756910847 },\n \"GY\": { name: \"Guyana\", lat: 4.68211981385056, lng: -58.91352612754667 },\n \"HM\": { name: \"Heard Island and McDonald Islands\", lat: -53.084170035513736, lng: 73.49298560844045 },\n \"HN\": { name: \"Honduras\", lat: 14.740370695750006, lng: -86.49251679006962 },\n \"HR\": { name: \"Croatia\", lat: 44.91192100856702, lng: 16.625761129583374 },\n \"HT\": { name: \"Haiti\", lat: 18.883520486983567, lng: -72.89291379842 },\n \"HU\": { name: \"Hungary\", lat: 47.22527332486294, lng: 19.39620048366142 },\n \"ID\": { name: \"Indonesia\", lat: 0.15591979959037652, lng: 113.96538246847302 },\n \"IE\": { name: \"Ireland\", lat: 53.30489539816495, lng: -8.241128545554096 },\n \"IL\": { name: \"Israel\", lat: 31.513542220043195, lng: 35.027923472437024 },\n \"IM\": { name: \"Isle of Man\", lat: 54.22855301008011, lng: -4.532995055468449 },\n \"IN\": { name: \"India\", lat: 23.586300567746722, lng: 81.17300408530181 },\n \"IO\": { name: \"British Indian Ocean Territory\", lat: -7.323548444385743, lng: 72.43501618476016 },\n \"IQ\": { name: \"Iraq\", lat: 33.105075667527906, lng: 43.832529181056884 },\n \"IR\": { name: \"Iran\", lat: 32.906023742890056, lng: 54.237077001065444 },\n \"IS\": { name: \"Iceland\", lat: 65.12360920205514, lng: -19.05682967106099 },\n \"IT\": { name: \"Italy\", lat: 42.98201127614267, lng: 12.763657166123137 },\n \"JE\": { name: \"Jersey\", lat: 49.215396925724306, lng: -2.1291601162653575 },\n \"JM\": { name: \"Jamaica\", lat: 18.12207889341651, lng: -77.30358894542778 },\n \"JO\": { name: \"Jordan\", lat: 31.387064884449156, lng: 36.95728884547246 },\n \"JP\": { name: \"Japan\", lat: 36.76738832597829, lng: 137.46934234351835 },\n \"KE\": { name: \"Kenya\", lat: 0.6899182318376179, lng: 37.95309411262371 },\n \"KG\": { name: \"Kyrgyzstan\", lat: 41.35698905438358, lng: 74.17532903468319 },\n \"KH\": { name: \"Cambodia\", lat: 12.699186865507775, lng: 105.03973078680701 },\n \"KI\": { name: \"Kiribati\", lat: 1.8676673749241066, lng: -157.39024189323504 },\n \"KM\": { name: \"Comoros\", lat: -11.658861474508491, lng: 43.34826587429403 },\n \"KN\": { name: \"Saint Kitts and Nevis\", lat: 17.314736299587768, lng: -62.74560385895787 },\n \"KP\": { name: \"North Korea\", lat: 40.19198091470839, lng: 127.3379805653744 },\n \"KR\": { name: \"South Korea\", lat: 36.402386712544114, lng: 127.76224551357649 },\n \"KW\": { name: \"Kuwait\", lat: 29.281360965443092, lng: 47.56311109320184 },\n \"KY\": { name: \"Cayman Islands\", lat: 19.311231805620288, lng: -81.25203208977878 },\n \"KZ\": { name: \"Kazakhstan\", lat: 47.641465195176835, lng: 66.3759193479301 },\n \"LA\": { name: \"Laos\", lat: 18.117282736873282, lng: 103.76375899026448 },\n \"LB\": { name: \"Lebanon\", lat: 33.91160170722086, lng: 35.89651946324749 },\n \"LC\": { name: \"Saint Lucia\", lat: 13.895749185129906, lng: -60.9689510935251 },\n \"LI\": { name: \"Liechtenstein\", lat: 47.14627562133036, lng: 9.547674672376376 },\n \"LK\": { name: \"Sri Lanka\", lat: 7.696630939329944, lng: 80.66931169770622 },\n \"LR\": { name: \"Liberia\", lat: 6.52012979398834, lng: -9.258988935497618 },\n \"LS\": { name: \"Lesotho\", lat: -29.60168116924817, lng: 28.24475317864227 },\n \"LT\": { name: \"Lithuania\", lat: 55.29437393417175, lng: 23.946021605013534 },\n \"LU\": { name: \"Luxembourg\", lat: 49.77523454542369, lng: 6.103230338458876 },\n \"LV\": { name: \"Latvia\", lat: 56.813853047554154, lng: 24.693671325654403 },\n \"LY\": { name: \"Libya\", lat: 27.202915771690794, lng: 17.91133392454237 },\n \"MA\": { name: \"Morocco\", lat: 28.687598134979325, lng: -8.817212587250811 },\n \"MC\": { name: \"Monaco\", lat: 43.74798224995656, lng: 7.412820873271196 },\n \"MD\": { name: \"Moldova\", lat: 47.0725674580696, lng: 28.391111865941348 },\n \"ME\": { name: \"Montenegro\", lat: 42.73694835210454, lng: 19.29505087156758 },\n \"MF\": { name: \"Saint Martin\", lat: 18.078012113224464, lng: -63.06678525361946 },\n \"MG\": { name: \"Madagascar\", lat: -19.04163612493041, lng: 46.68493466832544 },\n \"MH\": { name: \"Marshall Islands\", lat: 7.307929900994344, lng: 168.72016025351076 },\n \"MK\": { name: \"North Macedonia\", lat: 41.59402890143112, lng: 21.70998923872772 },\n \"ML\": { name: \"Mali\", lat: 17.168146208584837, lng: -4.346399841781153 },\n \"MM\": { name: \"Myanmar\", lat: 19.901227931399873, lng: 97.08892285397344 },\n \"MN\": { name: \"Mongolia\", lat: 47.08644454604851, lng: 103.3987360327455 },\n \"MP\": { name: \"Northern Mariana Islands\", lat: 15.178063516432115, lng: 145.74119737203134 },\n \"MQ\": { name: \"Martinique\", lat: 14.642697353597645, lng: -61.01432380875083 },\n \"MR\": { name: \"Mauritania\", lat: 20.466731212820022, lng: -10.495079045035716 },\n \"MS\": { name: \"Montserrat\", lat: 16.735363391460357, lng: -62.18693281256255 },\n \"MT\": { name: \"Malta\", lat: 35.890522650899314, lng: 14.441922442508494 },\n \"MU\": { name: \"Mauritius\", lat: -20.28142317475198, lng: 57.56415671066546 },\n \"MV\": { name: \"Maldives\", lat: -0.6065577168009924, lng: 73.10076245140479 },\n \"MW\": { name: \"Malawi\", lat: -13.128986464184024, lng: 34.23441182298881 },\n \"MX\": { name: \"Mexico\", lat: 23.87436068093592, lng: -101.55399731630118 },\n \"MY\": { name: \"Malaysia\", lat: 3.6716608556387857, lng: 114.63330303992869 },\n \"MZ\": { name: \"Mozambique\", lat: -17.525230309488748, lng: 35.208577031290176 },\n \"NA\": { name: \"Namibia\", lat: -21.90858163281473, lng: 18.16451345845268 },\n \"NC\": { name: \"New Caledonia\", lat: -21.33003372660827, lng: 165.50767040438612 },\n \"NE\": { name: \"Niger\", lat: 17.08105392407292, lng: 8.86863247002646 },\n \"NF\": { name: \"Norfolk Island\", lat: -29.037654445046282, lng: 167.95259597483337 },\n \"NG\": { name: \"Nigeria\", lat: 9.61029352034213, lng: 8.147714845256194 },\n \"NI\": { name: \"Nicaragua\", lat: 12.893566631930554, lng: -85.016088327669 },\n \"NL\": { name: \"Netherlands\", lat: 52.134054128923886, lng: 5.554136426128487 },\n \"NO\": { name: \"Norway\", lat: 64.97775882947745, lng: 16.670259272390894 },\n \"NP\": { name: \"Nepal\", lat: 28.300920699755657, lng: 84.1338898313567 },\n \"NR\": { name: \"Nauru\", lat: -0.5221021440668993, lng: 166.92937633139178 },\n \"NU\": { name: \"Niue\", lat: -19.05230921680393, lng: -169.86878106699083 },\n \"NZ\": { name: \"New Zealand\", lat: -43.82765432544426, lng: 170.69035541428696 },\n \"OM\": { name: \"Oman\", lat: 20.7242833183209, lng: 55.841088119829 },\n \"PA\": { name: \"Panama\", lat: 8.439536749576892, lng: -80.14428761482796 },\n \"PE\": { name: \"Peru\", lat: -8.522717984240291, lng: -74.11416196781884 },\n \"PF\": { name: \"French Polynesia\", lat: -17.674684080120677, lng: -149.40041671099763 },\n \"PG\": { name: \"Papua New Guinea\", lat: -7.156912819152135, lng: 144.8348942994695 },\n \"PH\": { name: \"Philippines\", lat: 15.586542251094242, lng: 121.82208941416745 },\n \"PK\": { name: \"Pakistan\", lat: 30.116188371410882, lng: 69.08835090769651 },\n \"PL\": { name: \"Poland\", lat: 52.06848055692473, lng: 19.43573279234468 },\n \"PM\": { name: \"Saint Pierre and Miquelon\", lat: 46.95153913615198, lng: -56.32465353437558 },\n \"PN\": { name: \"Pitcairn\", lat: -24.366121747565458, lng: -128.3149848627581 },\n \"PR\": { name: \"Puerto Rico\", lat: 18.216224086610914, lng: -66.49425339593509 },\n \"PS\": { name: \"Palestinian Territory\", lat: 31.930818736453883, lng: 35.24251184154588 },\n \"PT\": { name: \"Portugal\", lat: 39.67529214702138, lng: -7.933662183874006 },\n \"PW\": { name: \"Palau\", lat: 7.534775852547396, lng: 134.57965086721052 },\n \"PY\": { name: \"Paraguay\", lat: -23.42190559259428, lng: -58.38906357428651 },\n \"QA\": { name: \"Qatar\", lat: 25.318528486425386, lng: 51.19794918743203 },\n \"RE\": { name: \"Réunion\", lat: -21.119825460665105, lng: 55.54393506194689 },\n \"RO\": { name: \"Romania\", lat: 45.82454894397586, lng: 25.094158201563292 },\n \"RS\": { name: \"Serbia\", lat: 44.02679870131969, lng: 20.85677444395745 },\n \"RU\": { name: \"Russian Federation\", lat: 59.039434214106194, lng: 98.6704990698032 },\n \"RW\": { name: \"Rwanda\", lat: -2.014687460047154, lng: 29.919439681764082 },\n \"SA\": { name: \"Saudi Arabia\", lat: 24.136038144757897, lng: 44.600958178225596 },\n \"SB\": { name: \"Solomon Islands\", lat: -9.613104734596515, lng: 160.16475795033884 },\n \"SC\": { name: \"Seychelles\", lat: -4.660002318822744, lng: 55.47250789595527 },\n \"SD\": { name: \"Sudan\", lat: 15.67060230984256, lng: 29.951458283594064 },\n \"SE\": { name: \"Sweden\", lat: 62.73420986108448, lng: 17.062431988004956 },\n \"SG\": { name: \"Singapore\", lat: 1.3528251890006349, lng: 103.81025757634053 },\n \"SH\": { name: \"Saint Helena\", lat: -15.962963318340398, lng: -5.717391620813109 },\n \"SI\": { name: \"Slovenia\", lat: 46.13759229564504, lng: 14.890636899973781 },\n \"SJ\": { name: \"Svalbard\", lat: 78.57318936469626, lng: 16.036378851505283 },\n \"SK\": { name: \"Slovakia\", lat: 48.69808390520484, lng: 19.581015362490966 },\n \"SL\": { name: \"Sierra Leone\", lat: 8.561330384750587, lng: -11.78656695731115 },\n \"SM\": { name: \"San Marino\", lat: 43.942820729097896, lng: 12.461278349581722 },\n \"SN\": { name: \"Senegal\", lat: 14.228861491763402, lng: -14.610875368352305 },\n \"SO\": { name: \"Somalia\", lat: 6.524534573103924, lng: 45.40037867243972 },\n \"SR\": { name: \"Suriname\", lat: 4.098723595920171, lng: -55.855514311561286 },\n \"SS\": { name: \"South Sudan\", lat: 7.657782041763295, lng: 30.3851856901788 },\n \"ST\": { name: \"Sao Tome and Principe\", lat: 0.22744704294793774, lng: 6.606158796857607 },\n \"SV\": { name: \"El Salvador\", lat: 13.758041517055418, lng: -88.85911489238985 },\n \"SX\": { name: \"Sint Maarten\", lat: 18.03942608463078, lng: -63.06883135915303 },\n \"SY\": { name: \"Syria\", lat: 35.09751106058316, lng: 38.5117323139514 },\n \"SZ\": { name: \"Eswatini\", lat: -26.562540935608702, lng: 31.510685746082007 },\n \"TC\": { name: \"Turks and Caicos Islands\", lat: 21.799865427483745, lng: -71.74058946811508 },\n \"TD\": { name: \"Chad\", lat: 15.283493546654503, lng: 18.427113900363025 },\n \"TF\": { name: \"Juan De Nova Island\", lat: -17.06449193630804, lng: 42.74374761089645 },\n \"TF\": { name: \"French Southern Territories\", lat: -49.26329687105643, lng: 69.54686984724839 },\n \"TF\": { name: \"Glorioso Islands\", lat: -11.566224871643417, lng: 47.290948081543384 },\n \"TG\": { name: \"Togo\", lat: 8.660743037717811, lng: 0.8990857571109684 },\n \"TH\": { name: \"Thailand\", lat: 13.66222784745538, lng: 101.08675116214552 },\n \"TJ\": { name: \"Tajikistan\", lat: 38.56933138382972, lng: 70.94215281065698 },\n \"TK\": { name: \"Tokelau\", lat: -9.195174767256544, lng: -171.85265950722743 },\n \"TL\": { name: \"Timor-Leste\", lat: -8.809894630601962, lng: 125.95024049562659 },\n \"TM\": { name: \"Turkmenistan\", lat: 39.06069118001429, lng: 58.4577357627054 },\n \"TN\": { name: \"Tunisia\", lat: 34.08636179565723, lng: 9.65587551697984 },\n \"TO\": { name: \"Tonga\", lat: -21.15927212823853, lng: -175.20415878511247 },\n \"TR\": { name: \"Turkey\", lat: 38.93207363123396, lng: 35.56886764076691 },\n \"TT\": { name: \"Trinidad and Tobago\", lat: 10.415515638298093, lng: -61.37236579976247 },\n \"TV\": { name: \"Tuvalu\", lat: -8.514701506447222, lng: 179.217833977593 },\n \"TZ\": { name: \"Tanzania\", lat: -6.355794440041147, lng: 34.81832206060381 },\n \"UA\": { name: \"Ukraine\", lat: 48.657532515563794, lng: 31.27377208442636 },\n \"UG\": { name: \"Uganda\", lat: 1.2821729218416205, lng: 32.34371768463123 },\n \"UM\": { name: \"United States Minor Outlying Islands\", lat: 19.302045812215958, lng: 166.63800339749642 },\n \"US\": { name: \"United States\", lat: 38.8208089190304, lng: -96.33161660829639 },\n \"UY\": { name: \"Uruguay\", lat: -32.78195043831093, lng: -56.01919523458085 },\n \"UZ\": { name: \"Uzbekistan\", lat: 41.4879065244633, lng: 63.8548297593985 },\n \"VA\": { name: \"Vatican City\", lat: 41.90402351316735, lng: 12.451312917026133 },\n \"VC\": { name: \"Saint Vincent and the Grenadines\", lat: 13.254808122970651, lng: -61.193766354393034 },\n \"VE\": { name: \"Venezuela\", lat: 7.148324760507107, lng: -66.36492135985132 },\n \"VG\": { name: \"British Virgin Islands\", lat: 18.42195819619707, lng: -64.62406519257699 },\n \"VI\": { name: \"US Virgin Islands\", lat: 17.738009708772523, lng: -64.76155341409797 },\n \"VN\": { name: \"Vietnam\", lat: 16.517347170839393, lng: 105.91338832758704 },\n \"VU\": { name: \"Vanuatu\", lat: -15.189132121699332, lng: 166.84912735669738 },\n \"WF\": { name: \"Wallis and Futuna\", lat: -14.283442307826677, lng: -178.12735555777184 },\n \"WS\": { name: \"Samoa\", lat: -13.634252953274622, lng: -172.44107655740137 },\n \"YE\": { name: \"Yemen\", lat: 16.001392616307445, lng: 47.46815793206386 },\n \"YT\": { name: \"Mayotte\", lat: -12.824468416301052, lng: 45.128142327031064 },\n \"ZA\": { name: \"South Africa\", lat: -28.55361930679731, lng: 24.75252746489084 },\n \"ZM\": { name: \"Zambia\", lat: -13.162832953186246, lng: 27.75521363430896 },\n \"ZW\": { name: \"Zimbabwe\", lat: -18.92700121981475, lng: 29.717829640720844 },\n};\n\nexport function getCountryCentroid(code) {\n if (!code) return null;\n return COUNTRY_CENTROIDS[code.toUpperCase()] || null;\n}\n\nexport function getCountryCentroids() {\n return COUNTRY_CENTROIDS;\n}","import View from '@core/View.js';\nimport MapLibreView from './MapLibreView.js';\nimport { COUNTRY_CENTROIDS } from './countryCentroids.js';\n\nclass MetricsCountryMapView extends View {\n constructor(options = {}) {\n const mapHeight = options.height || 320;\n super({\n className: 'metrics-country-map-view',\n ...options\n });\n\n this.endpoint = options.endpoint || '/api/metrics/fetch';\n this.account = options.account || 'global';\n this.category = options.category || null;\n this.slugs = options.slugs || null;\n this.granularity = options.granularity || 'days';\n this.maxCountries = options.maxCountries || 12;\n this.metricLabel = options.metricLabel || 'Events';\n this.height = mapHeight;\n this.mapStyle = options.mapStyle || 'dark';\n this.mapOptions = options.mapOptions || {};\n this.showRoutes = options.showRoutes !== false;\n this.routeOrigin = options.routeOrigin || { lng: -77.346, lat: 38.958, name: 'Reston, VA' };\n this._refreshing = false;\n }\n\n async getTemplate() {\n return `\n <div class=\"metrics-country-map\">\n <div class=\"map-container mb-3\" data-container=\"${this.id}-map\" style=\"height:${this.height}px\"></div>\n <div class=\"map-legend small\" data-region=\"legend\"></div>\n </div>\n `;\n }\n\n async onInit() {\n this.statusEl = document.createElement('div');\n this.statusEl.className = 'text-muted small px-3 pb-2';\n this.element.appendChild(this.statusEl);\n\n this.mapView = new MapLibreView({\n containerId: `${this.id}-map`,\n height: this.height,\n style: this.mapStyle,\n zoom: this.mapOptions.zoom ?? 1.3,\n center: this.mapOptions.center || [10, 20],\n pitch: this.mapOptions.pitch ?? 20,\n bearing: this.mapOptions.bearing ?? 0,\n showNavigationControl: this.mapOptions.showNavigationControl ?? true,\n autoFitBounds: this.mapOptions.autoFitBounds ?? false\n });\n this.addChild(this.mapView);\n await this.refresh();\n }\n\n async refresh() {\n if (this._refreshing) return;\n this._refreshing = true;\n this.setStatus('Loading hotspots…');\n try {\n const metrics = await this.fetchMetrics();\n await this.applyMetrics(metrics);\n this.setStatus('');\n } catch (error) {\n console.error('MetricsCountryMapView refresh error', error);\n this.setStatus('Unable to load country metrics.');\n } finally {\n this._refreshing = false;\n }\n }\n\n async fetchMetrics() {\n const rest = this.getApp()?.rest;\n if (!rest) {\n throw new Error('REST client unavailable');\n }\n const params = {\n account: this.account,\n granularity: this.granularity,\n with_labels: true\n };\n if (this.category) params.category = this.category;\n if (this.slugs) {\n const slugsArray = Array.isArray(this.slugs) ? this.slugs : [this.slugs];\n params['slugs[]'] = slugsArray;\n }\n\n const response = await rest.GET(this.endpoint, params);\n if (!response.success || !response.data?.status) {\n throw new Error(response.data?.error || 'Metrics API error');\n }\n return response.data.data;\n }\n\n async applyMetrics(data) {\n const metrics = data?.data || {};\n const labels = data?.labels || [];\n const entries = [];\n\n Object.entries(metrics).forEach(([iso, series]) => {\n const total = series.reduce((sum, value) => sum + (Number(value) || 0), 0);\n if (!total) return;\n const centroid = COUNTRY_CENTROIDS[iso.toUpperCase()];\n if (!centroid) return;\n entries.push({\n code: iso.toUpperCase(),\n total,\n values: series,\n centroid\n });\n });\n\n if (!entries.length) {\n this.mapView.updateMarkers([]);\n this.renderLegend([]);\n this.setStatus('No country data available for the selected range.');\n return;\n }\n\n entries.sort((a, b) => b.total - a.total);\n const topEntries = entries.slice(0, this.maxCountries);\n const maxValue = topEntries[0]?.total || 1;\n\n const markers = topEntries.map(entry => {\n const intensity = entry.total / maxValue;\n const markerSize = Math.round(18 + intensity * 24);\n return {\n lng: entry.centroid.lng,\n lat: entry.centroid.lat,\n size: markerSize,\n color: this.getMarkerColor(intensity),\n popup: `\n <div class=\"text-center\">\n <strong>${entry.centroid.name}</strong><br/>\n <span class=\"text-muted\">${entry.total.toLocaleString()} ${this.metricLabel}</span>\n </div>\n `\n };\n });\n\n if (this.showRoutes && this.routeOrigin?.lng && this.routeOrigin?.lat) {\n markers.push({\n lng: this.routeOrigin.lng,\n lat: this.routeOrigin.lat,\n size: 26,\n color: '#0d6efd',\n icon: 'bi bi-broadcast-pin',\n popup: `\n <div class=\"text-center\">\n <strong>${this.routeOrigin.name || 'Operations Hub'}</strong><br/>\n <span class=\"text-muted\">Origin</span>\n </div>\n `\n });\n }\n\n this.mapView.updateMarkers(markers);\n this.renderLegend(topEntries, labels);\n if (this.showRoutes) {\n this.renderRoutes(topEntries, maxValue);\n }\n }\n\n getMarkerColor(intensity) {\n const start = [32, 201, 151]; // teal\n const end = [255, 193, 7]; // amber\n const mix = start.map((value, idx) =>\n Math.round(value + (end[idx] - value) * intensity)\n );\n return `rgba(${mix[0]}, ${mix[1]}, ${mix[2]}, 0.9)`;\n }\n\n renderLegend(entries) {\n const legendEl = this.element.querySelector('[data-region=\"legend\"]');\n if (!legendEl) return;\n if (!entries.length) {\n legendEl.innerHTML = '';\n return;\n }\n\n const maxValue = entries[0]?.total || 1;\n const rows = entries.map(entry => {\n const percent = ((entry.total / maxValue) * 100).toFixed(0);\n return `\n <div class=\"d-flex justify-content-between align-items-center py-1 border-top\">\n <div>\n <span class=\"fw-semibold\">${entry.centroid.name}</span>\n <span class=\"text-muted ms-1\">(${entry.code})</span>\n </div>\n <div class=\"text-end\">\n <div class=\"fw-semibold\">${entry.total.toLocaleString()}</div>\n <small class=\"text-muted\">${percent}% of top</small>\n </div>\n </div>\n `;\n }).join('');\n\n legendEl.innerHTML = rows;\n }\n\n renderRoutes(entries, maxValue) {\n const origin = this.routeOrigin || null;\n if (!origin || !origin.lng || !origin.lat || !this.mapView) return;\n\n const features = entries.map(entry => ({\n type: 'Feature',\n geometry: {\n type: 'LineString',\n coordinates: [\n [origin.lng, origin.lat],\n [entry.centroid.lng, entry.centroid.lat]\n ]\n },\n properties: {\n total: entry.total,\n intensity: entry.total / maxValue\n }\n }));\n\n const geojson = {\n type: 'FeatureCollection',\n features\n };\n\n const paint = {\n 'line-color': [\n 'interpolate',\n ['linear'],\n ['get', 'intensity'],\n 0,\n 'rgba(32, 201, 151, 0.6)',\n 1,\n 'rgba(255, 193, 7, 0.95)'\n ],\n 'line-width': [\n 'interpolate',\n ['linear'],\n ['get', 'intensity'],\n 0,\n 1.75,\n 1,\n 6\n ],\n 'line-opacity': [\n 'interpolate',\n ['linear'],\n ['get', 'intensity'],\n 0,\n 0.45,\n 1,\n 0.95\n ]\n };\n\n this.mapView.lineSources = this.mapView.lineSources.filter(src => src.id !== `${this.id}-routes`);\n this.mapView.updateLineSource(`${this.id}-routes`, {\n data: geojson,\n paint\n });\n }\n\n setStatus(message) {\n if (!this.statusEl) return;\n this.statusEl.textContent = message || '';\n this.statusEl.style.display = message ? 'block' : 'none';\n }\n\n}\n\nexport default MetricsCountryMapView;\n"],"names":["MapView","View","constructor","options","super","className","this","markers","center","zoom","height","showZoomControl","tileLayer","showLeafletBranding","showLayerControl","layerOptions","osm","satellite","terrain","dark","light","watercolor","bw","streets","map","leafletMarkers","_tileLayer","template","onAfterRender","loadLeaflet","initializeMap","window","L","cssLoaded","Promise","resolve","link","document","createElement","rel","href","onload","onerror","head","appendChild","jsLoaded","reject","script","src","all","getTileLayerUrl","tileLayers","url","attribution","maxZoom","mapElement","element","querySelector","id","mapCenter","length","lat","lng","zoomControl","attributionControl","setPrefix","e","tileConfig","addTo","container","parentElement","style","position","selector","top","right","zIndex","maxWidth","setAttribute","Object","entries","forEach","key","label","opt","value","textContent","selected","addEventListener","setTileLayer","addMarkers","fitBounds","setTimeout","invalidateSize","Array","isArray","markerData","popup","icon","markerOptions","marker","bindPopup","push","group","featureGroup","getBounds","pad","updateMarkers","newMarkers","clearMarkers","setView","removeLayer","setZoom","original","onBeforeDestroy","remove","showAsDialog","view","dialogOptions","title","header","body","size","centered","init","getApp","showDialog","MapLibreView","pitch","bearing","mapStyle","showNavigationControl","autoFitBounds","mapMarkers","pendingMarkers","lineSources","pendingLineData","Map","loadMapLibre","maplibregl","getMapStyle","styles","version","sources","type","tiles","tileSize","layers","source","glyphs","addControl","NavigationControl","on","initialMarkers","addLineSource","clear","color","el","markerSize","Number","width","borderRadius","backgroundColor","border","boxShadow","cursor","display","alignItems","justifyContent","innerHTML","Marker","setLngLat","mapPopup","Popup","offset","setHTML","setPopup","bounds","LngLatBounds","extend","padding","flyTo","data","paint","layout","sourceId","getLayer","getSource","removeSource","addSource","addLayer","set","updateLineSource","setData","setPaintProperty","setLayoutProperty","setPitch","setBearing","COUNTRY_CENTROIDS","AD","name","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MH","MK","ML","MM","MN","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","YE","YT","ZA","ZM","ZW","MetricsCountryMapView","mapHeight","endpoint","account","category","slugs","granularity","maxCountries","metricLabel","mapOptions","showRoutes","routeOrigin","_refreshing","getTemplate","onInit","statusEl","mapView","containerId","addChild","refresh","setStatus","metrics","fetchMetrics","applyMetrics","error","console","rest","Error","params","with_labels","slugsArray","response","GET","success","status","labels","iso","series","total","reduce","sum","centroid","toUpperCase","code","values","renderLegend","sort","a","b","topEntries","slice","maxValue","entry","intensity","Math","round","getMarkerColor","toLocaleString","renderRoutes","end","mix","idx","legendEl","rows","percent","toFixed","join","origin","geojson","features","geometry","coordinates","properties","filter","message"],"mappings":"6CAqBA,MAAMA,gBAAgBC,EAClB,WAAAC,CAAYC,EAAU,IAClBC,MAAM,CACFC,UAAW,cACRF,IAGPG,KAAKC,QAAUJ,EAAQI,SAAW,GAClCD,KAAKE,OAASL,EAAQK,QAAU,KAChCF,KAAKG,KAAON,EAAQM,MAAQ,GAC5BH,KAAKI,OAASP,EAAQO,QAAU,IAChCJ,KAAKK,iBAA8C,IAA5BR,EAAQQ,gBAC/BL,KAAKM,UAAYT,EAAQS,WAAa,MACtCN,KAAKO,qBAAsD,IAAhCV,EAAQU,oBACnCP,KAAKQ,kBAAgD,IAA7BX,EAAQW,iBAChCR,KAAKS,aAAeZ,EAAQY,cAAgB,CACxCC,IAAK,MACLC,UAAW,YACXC,QAAS,UACTC,KAAM,OACNC,MAAO,QACPC,WAAY,aACZC,GAAI,MACJC,QAAS,WAGbjB,KAAKkB,IAAM,KACXlB,KAAKmB,eAAiB,GACtBnB,KAAKoB,WAAa,KAElBpB,KAAKqB,SAAW,qNAKpB,CAEA,mBAAMC,SACItB,KAAKuB,oBACLvB,KAAKwB,eACf,CAEA,iBAAMD,GAEF,GAAIE,OAAOC,EAAG,OAGd,MAAMC,EAAY,IAAIC,QAASC,IAC3B,MAAMC,EAAOC,SAASC,cAAc,QACpCF,EAAKG,IAAM,aACXH,EAAKI,KAAO,mDACZJ,EAAKK,OAASN,EACdC,EAAKM,QAAUP,EACfE,SAASM,KAAKC,YAAYR,KAIxBS,EAAW,IAAIX,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7R,uEACVwS,EAAMT,0IAGZS,EAAMd,MAAMmB,6EACXO,wFAIzCE,KAAK,IAERJ,EAASjV,UAAYkV,CACzB,CAEA,YAAAL,CAAata,EAAS+Z,GAClB,MAAMgB,EAASzf,KAAKic,aAAe,KACnC,KAAKwD,GAAWA,EAAOjc,KAAQic,EAAOlc,KAAQvD,KAAKsc,SAAS,OAE5D,MAeMoD,EAAU,CACZhX,KAAM,oBACNiX,SAjBajb,EAAQxD,IAAIwd,IAAA,CACzBhW,KAAM,UACNkX,SAAU,CACNlX,KAAM,aACNmX,YAAa,CACT,CAACJ,EAAOjc,IAAKic,EAAOlc,KACpB,CAACmb,EAAMX,SAASva,IAAKkb,EAAMX,SAASxa,OAG5Cuc,WAAY,CACRlC,MAAOc,EAAMd,MACbe,UAAWD,EAAMd,MAAQa,OAuCjCze,KAAKsc,QAAQrU,YAAcjI,KAAKsc,QAAQrU,YAAY8X,OAAOrd,GAAOA,EAAIU,KAAO,GAAGpD,KAAKoD,aACrFpD,KAAKsc,QAAQ5Q,iBAAiB,GAAG1L,KAAKoD,YAAa,CAC/C4H,KAAM0U,EACNzU,MAjCU,CACV,aAAc,CACV,cACA,CAAC,UACD,CAAC,MAAO,aACR,EACA,0BACA,EACA,2BAEJ,aAAc,CACV,cACA,CAAC,UACD,CAAC,MAAO,aACR,EACA,KACA,EACA,GAEJ,eAAgB,CACZ,cACA,CAAC,UACD,CAAC,MAAO,aACR,EACA,IACA,EACA,OASZ,CAEA,SAAAyR,CAAUsD,GACDhgB,KAAKqc,WACVrc,KAAKqc,SAASrX,YAAcgb,GAAW,GACvChgB,KAAKqc,SAASpY,MAAM+F,QAAUgW,EAAU,QAAU,OACtD"}
@@ -1,2 +0,0 @@
1
- import{D as t}from"./Dialog-1umNJi4B.js";import{V as e,d as s}from"./Collection-C39Oy2q0.js";import{W as a}from"./WebSocketClient-BQAZr8C4.js";class BaseChart extends e{constructor(t={}){super({...t,className:`chart-component ${t.className||""}`,tagName:"div"}),this.chart=null,this.chartType=t.chartType||"line",this.endpoint=t.endpoint||null,this.data=t.data||null,this.dataTransform=t.dataTransform||null,this.refreshInterval=t.refreshInterval||null,this.autoRefresh=!1!==t.autoRefresh,this.refreshTimer=null,this.websocketUrl=t.websocketUrl||null,this.websocket=null,this.websocketReconnect=!1!==t.websocketReconnect,this.width=t.width||null,this.height=t.height||null,this.contentStyle=[this.width?`width: ${this.width}px;`:"",this.height?`height: ${this.height}px;`:""].filter(Boolean).join(" "),void 0===t.maintainAspectRatio&&(t.maintainAspectRatio=!0),this.title=t.title||"",this.chartTitle=t.chartTitle||"",this.chartOptions={responsive:!0,maintainAspectRatio:t.maintainAspectRatio,interaction:{intersect:!1,mode:"index"},plugins:{legend:{display:!1!==t.showLegend,position:t.legendPosition||"top"},title:{display:!!this.chartTitle,text:this.chartTitle},tooltip:{enabled:!1!==t.showTooltips,backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",bodyColor:"#fff",borderColor:"rgba(255,255,255,0.1)",borderWidth:1}},...t.chartOptions},this.xAxis=t.xAxis||null,this.yAxis=t.yAxis||null,this.tooltipFormatters=t.tooltip||{},this.theme=t.theme||"light",this.colorScheme=t.colorScheme||"default",this.animations=!1!==t.animations,this.exportEnabled=!0===t.exportEnabled,this.exportFormats=t.exportFormats||["png","jpg","csv"],this.isLoading=!1,this.hasError=!1,this.lastFetch=null,this.dataPoints=0,this.canvas=null,this.chartJsCdn=t.chartJsCdn||"https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.js",this.dataFormatter=s,this._essentialListeners=[]}get refreshEnabled(){return!(!this.endpoint&&!this.websocketUrl)}buildDefaultHeaderConfig(){return{titleHtml:this.title||"",chartTitle:this.chartTitle||"",showExport:!0===this.exportEnabled,showRefresh:this.refreshEnabled,showTheme:!0,controls:[]}}async getTemplate(){return'\n <div class="chart-container" data-theme="{{theme}}">\n <div class="chart-header mb-3">\n <div data-container="header"></div>\n <div class="chart-header-aux mt-2">\n <div data-container="header-aux"></div>\n </div>\n </div>\n\n <div class="chart-content position-relative" {{#contentStyle}}style="{{contentStyle}}"{{/contentStyle}}>\n <canvas class="chart-canvas" data-container="canvas"></canvas>\n\n \x3c!-- Loading overlay --\x3e\n <div class="chart-overlay d-none" data-loading>\n <div class="d-flex flex-column align-items-center">\n <div class="spinner-border text-primary mb-2" role="status">\n <span class="visually-hidden">Loading...</span>\n </div>\n <small class="text-muted">Loading chart data...</small>\n </div>\n </div>\n\n \x3c!-- Error overlay --\x3e\n <div class="chart-overlay d-none" data-error>\n <div class="alert alert-danger mb-0" role="alert">\n <div class="d-flex align-items-center">\n <i class="bi bi-exclamation-triangle me-2"></i>\n <div class="flex-grow-1">\n <strong>Error:</strong> <span class="error-message">Failed to load chart data</span>\n </div>\n <button class="btn btn-sm btn-outline-danger ms-2" data-action="retry-load">\n <i class="bi bi-arrow-clockwise"></i> Retry\n </button>\n </div>\n </div>\n </div>\n\n \x3c!-- No data overlay --\x3e\n <div class="chart-overlay d-none" data-no-data>\n <div class="text-center text-muted">\n <i class="bi bi-bar-chart display-4 mb-3 opacity-50"></i>\n <p class="mb-0">No data available</p>\n {{#refreshEnabled}}\n <button class="btn btn-sm btn-outline-secondary mt-2" data-action="refresh-chart">\n <i class="bi bi-arrow-clockwise"></i> Refresh\n </button>\n {{/refreshEnabled}}\n </div>\n </div>\n\n \x3c!-- WebSocket status indicator --\x3e\n <div class="position-absolute top-0 end-0 mt-2 me-2">\n <span class="badge bg-success websocket-status" style="display: none;" data-websocket-status>\n <i class="bi bi-wifi"></i> Live\n </span>\n </div>\n </div>\n\n <div class="chart-footer mt-2" style="display: none;">\n <div class="row">\n <div class="col">\n <small class="text-muted">\n <i class="bi bi-graph-up me-1"></i>\n <span class="data-points">0 data points</span>\n </small>\n </div>\n <div class="col text-end">\n <small class="text-muted refresh-info">\n Auto-refresh: <span class="refresh-status">Off</span>\n </small>\n </div>\n </div>\n </div>\n </div>\n '}async onInit(){await this.initializeChartJS();try{const t=this.headerConfig||(this.buildDefaultHeaderConfig?this.buildDefaultHeaderConfig():null);t&&(this.headerView=new ChartHeaderView({...t,containerId:"header"}),this.addChild(this.headerView))}catch(t){}}async onAfterRender(){this.canvas=this.element.querySelector(".chart-canvas"),this.titleElement=this.element.querySelector(".chart-title"),this.contentElement=this.element.querySelector(".chart-content"),this.footerElement=this.element.querySelector(".chart-footer"),this.loadingOverlay=this.element.querySelector("[data-loading]"),this.errorOverlay=this.element.querySelector("[data-error]"),this.noDataOverlay=this.element.querySelector("[data-no-data]"),this.websocketStatus=this.element.querySelector("[data-websocket-status]"),this.refreshBtn=this.element.querySelector(".refresh-btn"),this.themeToggle=this.element.querySelector(".theme-toggle"),this.applyTheme(),this.endpoint?(await this.fetchData(),await this.updateChart(this.data,!0),(this.height||this.width)&&this._updateChartDimensions()):this.data?(await this.updateChart(this.data,!0),(this.height||this.width)&&this._updateChartDimensions()):this.showNoData(),this.autoRefresh&&this.refreshInterval&&this.endpoint&&this.startAutoRefresh(),this.websocketUrl&&await this.connectWebSocket(),this.setupResizeObserver(),this.showFooter()}async initializeChartJS(){try{return void 0===window.Chart&&await this.loadChartJS(),!0}catch(t){return console.error("Failed to initialize Chart.js:",t),this.showError("Failed to initialize charting library"),!1}}async loadChartJS(){return new Promise((t,e)=>{const s=document.createElement("script");s.src=this.chartJsCdn,s.onload=()=>{t()},s.onerror=()=>{e(new Error("Failed to load Chart.js"))},document.head.appendChild(s)})}async handleActionRefreshChart(){await this.fetchData()}async handleActionRetryLoad(){this.hideError(),await this.fetchData()}async handleActionExportChart(t,e){const s=e.getAttribute("data-format")||"png";this.exportChart(s)}async handleActionToggleTheme(){this.toggleTheme()}async handleActionSetChartType(t,e){const s=e.getAttribute("data-type");s&&this.setChartType&&await this.setChartType(s)}async fetchData(){if(this.endpoint){this.showLoading(),this.setRefreshButtonState(!0);try{const t=await fetch(this.endpoint,{method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json"}});if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`);let e=await t.json();this.dataTransform&&"function"==typeof this.dataTransform&&(e=this.dataTransform(e)),this.lastFetch=/* @__PURE__ */new Date,this.data=e,this.updateLastUpdatedTime();const s=this.getApp()?.events;s&&s.emit("chart:data-loaded",{chart:this,data:e,source:"http",endpoint:this.endpoint})}catch(t){console.error("Failed to fetch chart data:",t),this.showError(`Failed to load data: ${t.message}`),this.emit("chart:error",{chart:this,error:t,source:"http",endpoint:this.endpoint})}finally{this.hideLoading(),this.setRefreshButtonState(!1)}}}async connectWebSocket(){if(this.websocketUrl)try{this.websocket=new a({url:this.websocketUrl,autoReconnect:this.websocketReconnect,dataTransform:this.dataTransform,eventBus:this.getApp()?.events,debug:!1}),this.websocket.on("connected",()=>{this.showWebSocketStatus(!0)}),this.websocket.on("disconnected",()=>{this.showWebSocketStatus(!1)}),this.websocket.on("data",async t=>{await this.updateChart(t),this.updateLastUpdatedTime(),this.emit("chart:data-updated",{chart:this,data:t,source:"websocket"})}),this.websocket.on("error",t=>{console.error("WebSocket error:",t),this.showWebSocketStatus(!1,"error")}),await this.websocket.connect()}catch(t){console.error("Failed to connect WebSocket:",t),this.showWebSocketStatus(!1,"error")}}async updateChart(t,e=!1){if(!t)return void this.showNoData();if(this.data=t,!this.canvas||void 0===window.Chart)return;this.hideAllOverlays();const s=this.processChartData(t);e&&this.chart&&(this.chart.destroy(),this.chart=null),this.chart?(this.chart.data=s,this.chart.update("none")):await this.createChart(s),this.updateDataStats(s),(this.height||this.width)&&this._updateChartDimensions()}processChartData(t){let e={...t};const s=this.normalizeAxis(this.xAxis);return s&&s.formatter&&e.labels&&(e.labels=e.labels.map(t=>this.dataFormatter.pipe(t,s.formatter))),e}async createChart(t){if(!this.canvas||void 0===window.Chart)throw new Error("Chart.js not loaded or canvas not found");const e={type:this.chartType,data:t,options:this.buildChartOptions()};try{this.chart=new window.Chart(this.canvas,e),this.setupChartEventHandlers()}catch(s){throw console.error("Failed to create chart:",s),s}}buildChartOptions(){const t={...this.chartOptions};(this.width||this.height)&&(t.responsive=!0,t.maintainAspectRatio=!1);const e=this.normalizeAxis(this.xAxis),s=this.normalizeAxis(this.yAxis);return t.scales=t.scales||{},t.scales.x={type:this._detectAxisType(this.data,e,"x"),display:!0,title:{display:!!e.label,text:e.label||""},grid:{display:!0},ticks:{}},e.formatter&&(t.scales.x.ticks.callback=this._createFormatterCallback(e.formatter)),t.scales.y={type:this._detectAxisType(this.data,s,"y"),display:!0,beginAtZero:!1!==s.beginAtZero,title:{display:!!s.label,text:s.label||""},grid:{display:!0},ticks:{}},s.formatter&&(t.scales.y.ticks.callback=this._createFormatterCallback(s.formatter)),this.applyThemeToOptions(t),(this.tooltipFormatters.x||this.tooltipFormatters.y)&&(t.plugins=t.plugins||{},t.plugins.tooltip=t.plugins.tooltip||{},t.plugins.tooltip.callbacks=t.plugins.tooltip.callbacks||{},this.tooltipFormatters.x&&(t.plugins.tooltip.callbacks.title=t=>{const e=t[0]?.label;return e?this.dataFormatter.pipe(e,this.tooltipFormatters.x):e}),this.tooltipFormatters.y&&(t.plugins.tooltip.callbacks.label=t=>{const e=t.raw,s=this.dataFormatter.pipe(e,this.tooltipFormatters.y);return`${t.dataset.label}: ${s}`})),"function"==typeof this.applySubclassChartOptions&&this.applySubclassChartOptions(t),t}_createFormatterCallback(t){return t?e=>{try{return this.dataFormatter.pipe(e,t)}catch(s){return console.warn("Chart formatter error:",s),e}}:null}normalizeAxis(t){if(!t)return{};if("string"==typeof t)return{formatter:t};if("object"==typeof t){const{formatter:e,label:s,type:a,beginAtZero:i,...r}=t;return{formatter:e,label:s,type:a,beginAtZero:i,...r}}return{}}_detectAxisType(t,e,s="x"){if(e&&e.type)return e.type;if(e&&e.formatter){const t=e.formatter.toLowerCase();if(t.includes("date")||t.includes("time"))return"time"}if(t){if("x"===s&&t.labels&&t.labels.length>0){const e=t.labels[0];return"string"!=typeof e||/^\d+\.?\d*$/.test(e.trim())?e instanceof Date||"string"==typeof e&&!isNaN(Date.parse(e))?"time":"linear":"category"}if("y"===s&&t.datasets&&t.datasets.length>0){const e=t.datasets[0];if(e.data&&e.data.length>0){const t=e.data[0];return"number"!=typeof t&&isNaN(parseFloat(t))?"category":"linear"}}}return"x"===s?"category":"linear"}setupChartEventHandlers(){this.chart&&(this.chart.options.onClick=(t,e)=>{if(e.length>0){const t=e[0],s=t.datasetIndex,a=t.index,i=this.chart.data.datasets[s].data[a],r=this.chart.data.labels[a];this.emit("chart:point-clicked",{chart:this,datasetIndex:s,index:a,value:i,label:r,dataset:this.chart.data.datasets[s]})}},this.chart.options.onHover=(t,e)=>{this.canvas.style.cursor=e.length>0?"pointer":"default"})}applyTheme(){this.element.setAttribute("data-theme",this.theme),this.chart&&(this.chart.options=this.buildChartOptions(),this.chart.update("none"))}applyThemeToOptions(t){const e="dark"===this.theme;t.scales&&Object.keys(t.scales).forEach(s=>{const a=t.scales[s];a.grid=a.grid||{},a.ticks=a.ticks||{},a.grid.color=e?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",a.ticks.color=e?"#e9ecef":"#495057"}),t.plugins?.legend&&(t.plugins.legend.labels=t.plugins.legend.labels||{},t.plugins.legend.labels.color=e?"#e9ecef":"#495057"),t.plugins?.title&&(t.plugins.title.color=e?"#ffffff":"#212529")}toggleTheme(){this.theme="light"===this.theme?"dark":"light",this.applyTheme(),this.emit("chart:theme-changed",{chart:this,theme:this.theme})}startAutoRefresh(){this.endpoint&&this.refreshInterval&&(this.stopAutoRefresh(),this.refreshTimer=setInterval(()=>{this.fetchData()},this.refreshInterval),this.updateRefreshStatus(!0))}stopAutoRefresh(){this.refreshTimer&&(clearInterval(this.refreshTimer),this.refreshTimer=null),this.updateRefreshStatus(!1)}exportChart(t="png"){if(this.chart)try{if("csv"===t)this.exportCSV();else{const e=this.chart.toBase64Image("image/"+t,1),s=document.createElement("a");s.download=`chart-${Date.now()}.${t}`,s.href=e,s.click(),this.emit("chart:exported",{chart:this,format:t,filename:s.download})}}catch(e){console.error("Failed to export chart:",e),this.showError("Failed to export chart")}}exportCSV(){if(this.chart&&this.chart.data)try{const t=this.generateCSV(),e=new Blob([t],{type:"text/csv;charset=utf-8;"}),s=URL.createObjectURL(e),a=document.createElement("a");a.download=`chart-data-${Date.now()}.csv`,a.href=s,a.click(),URL.revokeObjectURL(s),this.emit("chart:exported",{chart:this,format:"csv",filename:a.download})}catch(t){console.error("Failed to export CSV:",t),this.showError("Failed to export CSV")}}generateCSV(){const t=this.chart.data,e=t.labels||[],s=t.datasets||[];let a="Label";return s.forEach(t=>{a+=","+(t.label||"Data")}),a+="\n",e.forEach((t,e)=>{a+=`"${t}"`,s.forEach(t=>{const s=t.data[e]||"";a+=","+s}),a+="\n"}),a}showLoading(){this.isLoading=!0,this.hideAllOverlays(),this.loadingOverlay?.classList.remove("d-none")}hideLoading(){this.isLoading=!1,this.loadingOverlay?.classList.add("d-none")}showError(t){this.hasError=!0,this.hideAllOverlays();const e=this.errorOverlay?.querySelector(".error-message");e&&(e.textContent=t),this.errorOverlay?.classList.remove("d-none")}hideError(){this.hasError=!1,this.errorOverlay?.classList.add("d-none")}showNoData(){this.hideAllOverlays(),this.noDataOverlay?.classList.remove("d-none")}hideAllOverlays(){this.loadingOverlay?.classList.add("d-none"),this.errorOverlay?.classList.add("d-none"),this.noDataOverlay?.classList.add("d-none")}showWebSocketStatus(t,e="connected"){this.websocketStatus&&(t?(this.websocketStatus.className="badge bg-success",this.websocketStatus.innerHTML='<i class="bi bi-wifi"></i> Live'):(this.websocketStatus.className="error"===e?"badge bg-danger":"badge bg-secondary",this.websocketStatus.innerHTML="error"===e?'<i class="bi bi-wifi-off"></i> Error':'<i class="bi bi-wifi-off"></i> Offline'),this.websocketStatus.style.display="inline-block")}setRefreshButtonState(t){if(!this.refreshBtn)return;const e=this.refreshBtn.querySelector("i");t?(this.refreshBtn.disabled=!0,e?.classList.add("spin")):(this.refreshBtn.disabled=!1,e?.classList.remove("spin"))}updateLastUpdatedTime(){const t=this.element.querySelector(".last-updated"),e=this.element.querySelector(".timestamp");t&&e&&(e.textContent=/* @__PURE__ */(new Date).toLocaleTimeString(),t.style.display="block")}updateRefreshStatus(t){const e=this.element.querySelector(".refresh-status");e&&(e.textContent=t?`Every ${this.refreshInterval/1e3}s`:"Off")}updateDataStats(t){let e=0;t.datasets&&(e=t.datasets.reduce((t,e)=>t+(e.data?e.data.length:0),0)),this.dataPoints=e;const s=this.element.querySelector(".data-points");s&&(s.textContent=`${e} data point${1!==e?"s":""}`)}showFooter(){this.footerElement&&(this.footerElement.style.display="block")}setupResizeObserver(){if(!window.ResizeObserver||!this.contentElement)return;const t=new ResizeObserver(()=>{this.chart&&this.chart.resize()});t.observe(this.contentElement),this._resizeObserver=t}async onBeforeDestroy(){this.stopAutoRefresh(),this.websocket&&(this.websocket.disconnect(),this.websocket=null),this.chart&&(this.chart.destroy(),this.chart=null),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),this._essentialListeners&&(this._essentialListeners.forEach(({el:t,type:e,fn:s})=>{t&&t.removeEventListener(e,s)}),this._essentialListeners=[]),this.emit("chart:destroyed",{chart:this})}setData(t){return this.data=t,this.updateChart(t)}setEndpoint(t){if(this.endpoint=t,t)return this.fetchData()}setWebSocketUrl(t){if(this.websocket&&this.websocket.disconnect(),this.websocketUrl=t,t)return this.connectWebSocket()}setWidth(t){this.width=t,this.contentStyle=[this.width?`width: ${this.width}px;`:"",this.height?`height: ${this.height}px;`:""].filter(Boolean).join(" "),this.contentElement&&this._updateChartDimensions()}setHeight(t){this.height=t,this.contentStyle=[this.width?`width: ${this.width}px;`:"",this.height?`height: ${this.height}px;`:""].filter(Boolean).join(" "),this.contentElement&&this._updateChartDimensions()}setDimensions(t,e){this.width=t,this.height=e,this.contentStyle=[this.width?`width: ${this.width}px;`:"",this.height?`height: ${this.height}px;`:""].filter(Boolean).join(" "),this.contentElement&&this._updateChartDimensions()}_updateChartDimensions(){this.chart&&(this.width||this.height?(this.chart.options.responsive=!0,this.chart.options.maintainAspectRatio=!1,this.width&&this.contentElement&&(this.contentElement.style.width=this.width?this.width+"px":""),this.height&&this.contentElement&&(this.contentElement.style.height=this.height?this.height+"px":"")):(this.chart.options.responsive=!0,this.chart.options.maintainAspectRatio=this.chartOptions.maintainAspectRatio),this.chart.resize())}resize(){this.chart&&this.chart.resize()}refresh(){return this.fetchData()}export(t="png"){return this.exportChart(t)}setTheme(t){this.theme=t,this.applyTheme()}getStats(){return{isLoading:this.isLoading,hasError:this.hasError,dataPoints:this.dataPoints,lastFetch:this.lastFetch,theme:this.theme,chartType:this.chartType,autoRefresh:!!this.refreshTimer,websocketConnected:this.websocket?.isConnected||!1}}}class ChartHeaderView extends e{constructor(t={}){super({...t,className:`mojo-chart-header ${t.className||""}`,tagName:"div"}),this.titleHtml=t.titleHtml||"",this.chartTitle=t.chartTitle||"",this.showExport=!0===t.showExport,this.showRefresh=!!t.showRefresh,this.showTheme=!1,this.showTheme=!0===t.showTheme,this.controls=Array.isArray(t.controls)?t.controls:[],this.controlsHtml=this._buildControlsHtml(this.controls)}async getTemplate(){return'\n <div class="d-flex justify-content-between align-items-center">\n <div class="chart-title-section">\n <h5 class="mb-2 chart-title">{{{titleHtml}}}</h5>\n <small class="text-muted last-updated" style="display: none;">\n Last updated: <span class="timestamp"></span>\n </small>\n </div>\n\n <div class="chart-controls">\n <div class="btn-toolbar" role="toolbar">\n {{{controlsHtml}}}\n\n <div class="btn-group btn-group-sm" role="group">\n\n {{#showTheme}}\n <button type="button" class="btn btn-outline-secondary theme-toggle" data-action="toggle-theme" title="Toggle Theme">\n <i class="bi bi-palette"></i>\n </button>\n {{/showTheme}}\n\n {{#showExport}}\n <div class="btn-group btn-group-sm" role="group">\n <button type="button" class="btn btn-outline-secondary dropdown-toggle" data-bs-toggle="dropdown" title="Export Chart">\n <i class="bi bi-download"></i>\n </button>\n <ul class="dropdown-menu">\n <li><a class="dropdown-item" href="#" data-action="export-chart" data-format="png">\n <i class="bi bi-image"></i> PNG\n </a></li>\n <li><a class="dropdown-item" href="#" data-action="export-chart" data-format="jpg">\n <i class="bi bi-image"></i> JPEG\n </a></li>\n <li><a class="dropdown-item" href="#" data-action="export-chart" data-format="csv">\n <i class="bi bi-file-earmark-spreadsheet"></i> CSV\n </a></li>\n </ul>\n </div>\n {{/showExport}}\n\n {{#showRefresh}}\n <button type="button" class="btn btn-outline-secondary refresh-btn" data-action="refresh-chart" title="Refresh Data">\n <i class="bi bi-arrow-clockwise"></i>\n </button>\n {{/showRefresh}}\n </div>\n </div>\n </div>\n </div>\n '}_buildControlsHtml(t){if(!Array.isArray(t)||0===t.length)return"";const e=[];return t.forEach(t=>{if(t&&t.type)switch(t.type){case"select":{const s=`form-select${"md"===t.size?"":" form-select-sm"} ${t.className||""}`.trim(),a=(t.options||[]).map(t=>`<option value="${this._escapeAttr(t.value)}"${t.selected?" selected":""}>${this._escapeHtml(t.label)}</option>`).join("");e.push(`\n <div class="btn-group btn-group-sm me-2" role="group">\n <select class="${s}" data-change-action="${this._escapeAttr(t.action||t.name||"select-changed")}" style="width: auto;">\n ${a}\n </select>\n </div>\n `);break}case"button":{const{variant:s="outline-secondary",size:a="sm"}=t,i=`btn btn-${s}${"md"===a?"":" btn-sm"} ${t.className||""}`.trim(),r=t.title?` title="${this._escapeAttr(t.title)}"`:"",n=this._buildDataAttrs(t.data);e.push(`\n <div class="btn-group btn-group-sm me-2" role="group">\n <button type="button" class="${i}" data-action="${this._escapeAttr(t.action||"button-action")}"${r}${n}>\n ${t.labelHtml||""}\n </button>\n </div>\n `);break}case"buttongroup":{const s=t.size||"sm",a=`btn-group btn-group-${s} me-2 ${t.className||""}`.trim(),i=(t.buttons||[]).map(t=>{const e=`btn btn-${t.variant||"outline-secondary"}${"md"===s?"":" btn-sm"} ${t.className||""}`.trim(),a=t.title?` title="${this._escapeAttr(t.title)}"`:"",i=this._buildDataAttrs(t.data);return`<button type="button" class="${e}" data-action="${this._escapeAttr(t.action||"button-action")}"${a}${i}>${t.labelHtml||""}</button>`}).join("");e.push(`\n <div class="${a}" role="group">\n ${i}\n </div>\n `);break}case"divider":e.push('<div class="vr mx-2"></div>');break;case"html":{const s=t.html||"";e.push(`<div class="me-2 d-inline-block">${s}</div>`);break}}}),e.join("\n")}_buildDataAttrs(t){return t&&"object"==typeof t?Object.entries(t).map(([t,e])=>` data-${this._kebabCase(String(t))}="${this._escapeAttr(String(e))}"`).join(""):""}_kebabCase(t){return t.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase().replace(/[^a-z0-9\-]/g,"-").replace(/--+/g,"-").replace(/^-|-$/g,"")}_escapeAttr(t){return String(t).replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}_escapeHtml(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}}const i=["rgba(52, 152, 219, 0.85)","rgba(231, 76, 60, 0.85)","rgba(46, 204, 113, 0.85)","rgba(241, 196, 15, 0.85)","rgba(155, 89, 182, 0.85)","rgba(230, 126, 34, 0.85)","rgba(26, 188, 156, 0.85)","rgba(52, 73, 94, 0.85)","rgba(243, 156, 18, 0.85)","rgba(142, 68, 173, 0.85)","rgba(39, 174, 96, 0.85)","rgba(41, 128, 185, 0.85)","rgba(192, 57, 43, 0.85)","rgba(127, 140, 141, 0.85)","rgba(22, 160, 133, 0.85)","rgba(211, 84, 0, 0.85)","rgba(44, 62, 80, 0.85)","rgba(214, 69, 65, 0.85)","rgba(149, 165, 166, 0.85)","rgba(52, 232, 158, 0.85)"];class SeriesChart extends BaseChart{constructor(t={}){super({...t,chartType:t.chartType||"line"}),this.showTypeSwitch=!0,void 0!==t.showTypeSwitch&&(this.showTypeSwitch=t.showTypeSwitch),this.orientation=t.orientation||"vertical",this.stacked=t.stacked||!1,this.stepped=t.stepped||!1,this.tension=t.tension||.4,this.fill=t.fill||!1,this.showRefreshButton=!1!==t.showRefreshButton,this.headerConfig||(this.headerConfig={titleHtml:this.title||"",chartTitle:this.chartTitle||"",showExport:this.exportEnabled,showRefresh:this.refreshEnabled,showTheme:!0,controls:[]}),this.series=t.series||[],this.xField=t.xField||"x",this.yField=t.yField||"y";const e=Array.isArray(t.colors)&&t.colors.length?t.colors:i;this.colors=[...e],this.tooltipFormatters=t.tooltip||{}}getColor(t){return this.ensureColorPool(t+1),this.colors[t]}ensureColorPool(t){if(!(this.colors.length>=t))for(;this.colors.length<t;){const t=`hsla(${37*this.colors.length%360}, 70%, 55%, 0.85)`;this.colors.push(t)}}withAlpha(t,e=.4){if(!t)return t;const s=t.match(/rgba?\(([^)]+)\)/i);if(s){const t=s[1].split(",").map(t=>t.trim()),[a,i,r]=t;return`rgba(${a}, ${i}, ${r}, ${e})`}const a=t.match(/hsla?\(([^)]+)\)/i);if(a){const t=a[1].split(",").map(t=>t.trim()),[s,i,r]=t;return`hsla(${s}, ${i}, ${r}, ${e})`}return t}async getTemplate(){return await super.getTemplate()}async onInit(){this.showTypeSwitch&&this.headerConfig.controls.push({type:"buttongroup",size:"sm",buttons:[{action:"set-chart-type",labelHtml:'<i class="bi bi-graph-up"></i>',title:"Line",variant:"line"===this.chartType?"primary":"outline-primary",data:{type:"line"}},{action:"set-chart-type",labelHtml:'<i class="bi bi-bar-chart"></i>',title:"Bar",variant:"bar"===this.chartType?"primary":"outline-primary",data:{type:"bar"}}]}),await super.onInit()}async onActionSetChartType(t,e){t.stopPropagation();const s=e.getAttribute("data-type");s&&s!==this.chartType&&await this.setChartType(s)}async rebuildChart(){if(this.chart&&this.data){this.chart.destroy(),this.chart=null;const t=this.processChartData(this.data);await this.createChart(t)}}async setChartType(t){if(!["line","bar"].includes(t))throw new Error(`Unsupported chart type: ${t}`);const e=this.chartType;if(this.chartType=t,this.chart&&this.data){this.chart.destroy(),this.chart=null;const t=this.processChartData(this.data);await this.createChart(t)}this._updateTypeSwitcherButtons();const s=this.getApp()?.events;s&&s.emit("chart:type-changed",{chart:this,oldType:e,newType:this.chartType})}processChartData(t){if(!t)return t;let e;return e=Array.isArray(t)?this.processArrayData(t):t.labels&&t.datasets?this.processChartJSData(t):t.series?this.processSeriesData(t):t,this.applyFormattersToData(e)}processArrayData(t){const e=[],s=[];t.forEach(t=>{const a=t[this.xField],i=t[this.yField];e.push(a),s.push(i)}),this.ensureColorPool(1);const a=this.getColor(0),i="line"===this.chartType?.25:.65;return{labels:e,datasets:[{label:this.title||"Data",data:s,backgroundColor:this.withAlpha(a,i),borderColor:a,borderWidth:2,tension:"line"===this.chartType?this.tension:0,fill:"line"===this.chartType&&this.fill,stepped:"line"===this.chartType&&this.stepped}]}}processChartJSData(t){const e={...t};if(!e.datasets)return e.datasets=[],e;const s=e.datasets.length;this.ensureColorPool(s);const a="line"===this.chartType?.25:.65;return e.datasets=e.datasets.map((t,e)=>{const s=t.borderColor||this.getColor(e);return{...t,backgroundColor:t.backgroundColor||this.withAlpha(s,a),borderColor:s,borderWidth:t.borderWidth||2,tension:"line"===this.chartType?t.tension??this.tension:0,fill:"line"===this.chartType&&(t.fill??this.fill),stepped:"line"===this.chartType&&(t.stepped??this.stepped)}}),e}processSeriesData(t){const e=t.labels||[],s=[],a=t.series?.length||0;this.ensureColorPool(a);const i="line"===this.chartType?.25:.65;return t.series.forEach((t,e)=>{const a=t.borderColor||this.getColor(e);s.push({label:t.name||t.label||`Series ${e+1}`,data:t.data||[],backgroundColor:t.backgroundColor||this.withAlpha(a,i),borderColor:a,borderWidth:t.borderWidth||2,tension:"line"===this.chartType?t.tension??this.tension:0,fill:"line"===this.chartType&&(t.fill??this.fill),stepped:"line"===this.chartType&&(t.stepped??this.stepped)})}),{labels:e,datasets:s}}applyFormattersToData(t){if(!t)return t;const e={...t},s=this.normalizeAxis?this.normalizeAxis(this.xAxis):{};return s.formatter&&e.labels&&(e.labels=e.labels.map(t=>this.dataFormatter.pipe(t,s.formatter))),e}applySubclassChartOptions(t){this.stacked&&"bar"===this.chartType&&t.scales&&(t.scales.x&&(t.scales.x.stacked=!0),t.scales.y&&(t.scales.y.stacked=!0)),"bar"===this.chartType&&"horizontal"===this.orientation&&(t.indexAxis="y"),t.interaction=t.interaction||{},t.interaction.intersect=!1,t.interaction.mode="line"===this.chartType?"index":"nearest",t.elements=t.elements||{},t.elements.line={...t.elements.line||{},tension:this.tension,borderWidth:2},t.elements.point={...t.elements.point||{},radius:"line"===this.chartType?4:0,hoverRadius:6,hitRadius:8},t.elements.bar={...t.elements.bar||{},borderWidth:1,borderSkipped:!1}}processAxisConfig(t){return t?"string"==typeof t?{formatter:t}:"object"==typeof t?{formatter:t.formatter,label:t.label,type:t.type,beginAtZero:t.beginAtZero,...t}:{}:{}}_updateTypeSwitcherButtons(){const t=this.element?.querySelectorAll('[data-action="set-chart-type"]');t&&0!==t.length&&t.forEach(t=>{const e=t.getAttribute("data-type")===this.chartType;t.classList.toggle("btn-primary",e),t.classList.toggle("btn-outline-primary",!e),t.classList.toggle("active",e)})}setOrientation(t){if(!["vertical","horizontal"].includes(t))throw new Error(`Invalid orientation: ${t}`);if(this.orientation=t,this.chart&&(this.chart.destroy(),this.chart=null,this.data)){const t=this.processChartData(this.data);this.createChart(t)}}setStacked(t){this.stacked=t,this.chart&&(this.chart.options.scales.x.stacked=t,this.chart.options.scales.y.stacked=t,this.chart.update())}addSeries(t){if(!this.data||!this.data.datasets)return;const e={label:t.label||t.name||`Series ${this.data.datasets.length+1}`,data:t.data||[],backgroundColor:t.backgroundColor||this.colors[this.data.datasets.length%this.colors.length].replace("0.8","0.6"),borderColor:t.borderColor||this.colors[this.data.datasets.length%this.colors.length],borderWidth:t.borderWidth||2,tension:"line"===this.chartType?t.tension??this.tension:0,fill:"line"===this.chartType&&(t.fill??this.fill)};this.data.datasets.push(e),this.chart&&(this.chart.data.datasets.push(e),this.chart.update());const s=this.getApp()?.events;s&&s.emit("chart:series-added",{chart:this,series:e})}removeSeries(t){if(!this.data||!this.data.datasets||t<0||t>=this.data.datasets.length)return;const e=this.data.datasets.splice(t,1)[0];this.chart&&(this.chart.data.datasets.splice(t,1),this.chart.update());const s=this.getApp()?.events;s&&s.emit("chart:series-removed",{chart:this,series:e,index:t})}static async showDialog(e={}){const{title:s="Chart Viewer",size:a="xl",...i}=e,r=new SeriesChart({...i,title:s}),n=new t({title:s,body:r,size:a,centered:!0,backdrop:"static",keyboard:!0,buttons:[{text:"Export PNG",action:"export",class:"btn btn-outline-primary"},{text:"Close",action:"close",class:"btn btn-secondary",dismiss:!0}]});return await n.render(),document.body.appendChild(n.element),await n.mount(),n.show(),new Promise(t=>{n.on("hidden",()=>{n.destroy(),t(r)}),n.on("action:export",()=>{r.exportChart("png")}),n.on("action:close",()=>{n.hide()})})}}class PieChart extends BaseChart{constructor(t={}){super({...t,chartType:"pie"}),this.cutout=t.cutout||0,this.rotation=t.rotation||0,this.circumference=t.circumference||360,this.borderWidth=t.borderWidth||2,this.borderColor=t.borderColor||"#ffffff",this.hoverBorderWidth=t.hoverBorderWidth||3,this.showLabels=!1!==t.showLabels,this.labelPosition=t.labelPosition||"outside",this.labelFormatter=t.labelFormatter||null,this.valueFormatter=t.valueFormatter||null,this.labelField=t.labelField||"label",this.valueField=t.valueField||"value",this.colors=t.colors||["#FF6384","#36A2EB","#FFCE56","#4BC0C0","#9966FF","#FF9F40","#C9CBCF","#4BC0C0","#FF6384","#36A2EB"],this.animateRotate=!1!==t.animateRotate,this.animateScale=t.animateScale||!1,this.clickable=!1!==t.clickable,this.hoverable=!1!==t.hoverable,this.selectedSegment=null,this.highlightedSegments=/* @__PURE__ */new Set,this.valueFormatter=t.valueFormatter||null}processChartData(t){if(!t)return t;let e;return e=Array.isArray(t)?this.processArrayData(t):t.labels&&t.datasets?this.processChartJSData(t):"object"!=typeof t||t.labels?t:this.processObjectData(t),this.applyFormattersToData(e)}processArrayData(t){const e=[],s=[];return t.forEach(t=>{const a=t[this.labelField],i=t[this.valueField];void 0!==a&&void 0!==i&&(e.push(a),s.push(i))}),{labels:e,datasets:[{data:s,backgroundColor:this.generateColors(e.length),borderColor:this.borderColor,borderWidth:this.borderWidth,hoverBorderWidth:this.hoverBorderWidth}]}}processChartJSData(t){const e={...t};return e.datasets=e.datasets.map(t=>({...t,backgroundColor:t.backgroundColor||this.generateColors(e.labels.length),borderColor:t.borderColor||this.borderColor,borderWidth:t.borderWidth||this.borderWidth,hoverBorderWidth:t.hoverBorderWidth||this.hoverBorderWidth})),e}processObjectData(t){const e=Object.keys(t);return{labels:e,datasets:[{data:Object.values(t),backgroundColor:this.generateColors(e.length),borderColor:this.borderColor,borderWidth:this.borderWidth,hoverBorderWidth:this.hoverBorderWidth}]}}applyFormattersToData(t){if(!t)return t;const e={...t};return this.labelFormatter&&e.labels&&(e.labels=e.labels.map(t=>this.dataFormatter.pipe(t,this.labelFormatter))),e}generateColors(t){const e=[];for(let s=0;s<t;s++)e.push(this.colors[s%this.colors.length]);return e}buildChartOptions(){const t=super.buildChartOptions();return t.cutout=this.cutout,t.rotation=this.rotation,t.circumference=this.circumference,t.animation={animateRotate:this.animateRotate,animateScale:this.animateScale,duration:this.animations?1e3:0},t.plugins={...t.plugins,legend:{...t.plugins.legend,position:t.plugins.legend.position||"right",labels:{...t.plugins.legend.labels,usePointStyle:!0,padding:20,generateLabels:t=>{const e=t.data;return e.labels.length&&e.datasets.length?e.labels.map((t,s)=>{const a=e.datasets[0],i=a.data[s],r=a.backgroundColor[s];return{text:`${t} (${(i/a.data.reduce((t,e)=>t+e,0)*100).toFixed(1)}%)`,fillStyle:r,strokeStyle:r,lineWidth:0,hidden:!1,index:s}}):[]}}},tooltip:{...t.plugins.tooltip,callbacks:{...t.plugins.tooltip.callbacks,label:t=>{const e=t.label||"",s=t.raw,a=(s/t.dataset.data.reduce((t,e)=>t+e,0)*100).toFixed(1);let i=s;return this.valueFormatter?i=this.dataFormatter.pipe(s,this.valueFormatter):this.tooltipFormatters&&this.tooltipFormatters.y&&(i=this.dataFormatter.pipe(s,this.tooltipFormatters.y)),`${e}: ${i} (${a}%)`}}}},delete t.scales,t}setupChartEventHandlers(){super.setupChartEventHandlers(),this.chart&&this.clickable&&(this.chart.options.onClick=(t,e)=>{if(e.length>0){const t=e[0].index,s=this.chart.data.datasets[0],a=this.chart.data.labels[t],i=s.data[t],r=(i/s.data.reduce((t,e)=>t+e,0)*100).toFixed(1);this.toggleSegmentSelection(t);const n=this.getApp()?.events;n&&n.emit("chart:segment-clicked",{chart:this,index:t,label:a,value:i,percentage:parseFloat(r),isSelected:this.selectedSegment===t})}},this.hoverable&&(this.chart.options.onHover=(t,e)=>{if(this.canvas.style.cursor=e.length>0?"pointer":"default",e.length>0){const t=e[0].index,s=this.getApp()?.events;s&&s.emit("chart:segment-hover",{chart:this,index:t,label:this.chart.data.labels[t],value:this.chart.data.datasets[0].data[t]})}}))}toggleSegmentSelection(t){this.selectedSegment===t?(this.selectedSegment=null,this.resetSegmentStyle(t)):(null!==this.selectedSegment&&this.resetSegmentStyle(this.selectedSegment),this.selectedSegment=t,this.highlightSegment(t))}highlightSegment(t){if(!this.chart)return;const e=this.chart.getDatasetMeta(0).data[t];e&&(e.outerRadius+=10,this.chart.update("none"))}resetSegmentStyle(t){if(!this.chart)return;const e=this.chart.getDatasetMeta(0).data[t];e&&(e.outerRadius-=10,this.chart.update("none"))}highlightSegments(t){Array.isArray(t)||(t=[t]),this.highlightedSegments.clear(),t.forEach(t=>{this.highlightedSegments.add(t),this.highlightSegment(t)})}clearHighlights(){this.highlightedSegments.forEach(t=>{this.resetSegmentStyle(t)}),this.highlightedSegments.clear(),null!==this.selectedSegment&&(this.resetSegmentStyle(this.selectedSegment),this.selectedSegment=null)}selectSegment(t){t>=0&&t<this.chart?.data?.labels?.length&&this.toggleSegmentSelection(t)}getSegmentData(t){if(!this.chart||!this.chart.data)return null;const e=this.chart.data.datasets[0],s=this.chart.data.labels[t],a=e.data[t],i=(a/e.data.reduce((t,e)=>t+e,0)*100).toFixed(1);return{index:t,label:s,value:a,percentage:parseFloat(i),color:e.backgroundColor[t],isSelected:this.selectedSegment===t}}getAllSegments(){return this.chart&&this.chart.data?this.chart.data.labels.map((t,e)=>this.getSegmentData(e)):[]}updateSegmentColor(t,e){if(!this.chart||!this.chart.data.datasets[0])return;this.chart.data.datasets[0].backgroundColor[t]=e,this.chart.update("none");const s=this.getApp()?.events;s&&s.emit("chart:segment-color-changed",{chart:this,index:t,color:e,segment:this.getSegmentData(t)})}addSegment(t,e,s=null){if(!this.chart||!this.chart.data)return;const a=this.chart.data.datasets[0],i=s||this.colors[this.chart.data.labels.length%this.colors.length];this.chart.data.labels.push(t),a.data.push(e),a.backgroundColor.push(i),this.chart.update();const r=this.getApp()?.events;r&&r.emit("chart:segment-added",{chart:this,label:t,value:e,color:i,index:this.chart.data.labels.length-1})}removeSegment(t){if(!this.chart||!this.chart.data||t<0||t>=this.chart.data.labels.length)return;const e=this.chart.data.datasets[0],s=this.chart.data.labels[t],a=e.data[t];this.chart.data.labels.splice(t,1),e.data.splice(t,1),e.backgroundColor.splice(t,1),this.selectedSegment===t?this.selectedSegment=null:this.selectedSegment>t&&this.selectedSegment--,this.chart.update();const i=this.getApp()?.events;i&&i.emit("chart:segment-removed",{chart:this,label:s,value:a,index:t,removedSegment:{label:s,value:a,index:t}})}applyThemeToOptions(t){super.applyThemeToOptions(t);const e="dark"===this.theme;this.borderColor=e?"#404449":"#ffffff"}static async showDialog(e={}){const{title:s="Pie Chart",size:a="lg",...i}=e,r=new PieChart({...i,title:s}),n=new t({title:s,body:r,size:a,centered:!0,backdrop:"static",keyboard:!0,buttons:[{text:"Export PNG",action:"export",class:"btn btn-outline-primary"},{text:"Close",action:"close",class:"btn btn-secondary",dismiss:!0}]});return await n.render(),document.body.appendChild(n.element),await n.mount(),n.show(),new Promise(t=>{n.on("hidden",()=>{n.destroy(),t(r)}),n.on("action:export",()=>{r.exportChart("png")}),n.on("action:close",()=>{n.hide()})})}}class MetricsChart extends SeriesChart{constructor(t={}){super({...t,chartType:t.chartType||"line",title:t.title||"Metrics",colors:t.colors,yAxis:t.yAxis||{label:"Count",beginAtZero:!0},tooltip:t.tooltip||{y:"number"},width:t.width,height:t.height}),this.endpoint=t.endpoint||"/api/metrics/fetch",this.account=t.account||"global",this.granularity=t.granularity||"hours",this.slugs=t.slugs||null,this.category=t.category||null,this.dateStart=t.dateStart||null,this.dateEnd=t.dateEnd||null,this.defaultDateRange=t.defaultDateRange||"24h",this.showGranularity=!1!==t.showGranularity,this.showDateRange=!1!==t.showDateRange,this.granularityOptions=t.granularityOptions||[{value:"minutes",label:"Minutes"},{value:"hours",label:"Hours"},{value:"days",label:"Days"},{value:"weeks",label:"Weeks"},{value:"months",label:"Months"}],this.quickRanges=t.quickRanges||[{value:"1h",label:"1H"},{value:"24h",label:"24H"},{value:"7d",label:"7D"},{value:"30d",label:"30D"}],this.availableMetrics=t.availableMetrics||[{value:"api_calls",label:"API Calls"},{value:"api_errors",label:"API Errors"},{value:"incident_evt",label:"System Events"},{value:"incidents",label:"Incidents"}],this.maxDatasets=Number.isFinite(t.maxDatasets)?t.maxDatasets:null,this.groupRemainingLabel=t.groupRemainingLabel||"Other",this.isLoading=!1,this.lastFetch=null,this.dateStart&&this.dateEnd||this.setQuickRange(this.defaultDateRange)}async onInit(){const t=[];if(this.showGranularity){t.push('<li><h6 class="dropdown-header">Granularity</h6></li>');for(const e of this.granularityOptions){const s=e.value===this.granularity?" mc-selected":"";t.push(`<li><a class="dropdown-item${s}" role="button" data-action="granularity-changed" data-value="${e.value}">${e.label}</a></li>`)}}if(this.showDateRange){t.length&&t.push('<li><hr class="dropdown-divider"></li>'),t.push('<li><h6 class="dropdown-header">Date Range</h6></li>');for(const e of this.quickRanges){const s=e.value===this.defaultDateRange?" mc-selected":"";t.push(`<li><a class="dropdown-item${s}" role="button" data-action="quick-range" data-range="${e.value}">${e.label}</a></li>`)}t.push('<li><a class="dropdown-item" role="button" data-action="show-date-range-dialog"><i class="bi bi-calendar-range me-1"></i>Custom Range...</a></li>')}const e=t.length?`\n <style>\n .mc-gear-menu .dropdown-item.mc-selected { background: #f0f0f0; color: inherit; }\n .mc-gear-menu .dropdown-item.mc-selected::before { content: '\\F633'; font-family: 'bootstrap-icons'; margin-right: 0.4rem; font-size: 0.75em; }\n </style>\n <div class="btn-group btn-group-sm me-2">\n <button type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false" title="Chart Settings">\n <i class="bi bi-gear"></i>\n </button>\n <ul class="dropdown-menu dropdown-menu-end mc-gear-menu">${t.join("")}</ul>\n </div>`:"";this.showTypeSwitch=!0;const s=[];e&&s.push({type:"html",html:e}),this.headerConfig={titleHtml:this.title||"Metrics",chartTitle:this.chartTitle||"",showExport:!0===this.exportEnabled,showRefresh:this.refreshEnabled,showTheme:!1,controls:s},await super.onInit()}static GRANULARITY_DEFAULTS={minutes:"1h",hours:"24h",days:"30d",weeks:"30d",months:"30d"};async onActionGranularityChanged(t,e){const s=e.dataset?.value||e.value;if(s&&s!==this.granularity){this.granularity=s;const t=MetricsChart.GRANULARITY_DEFAULTS[s]||"24h";this.setQuickRange(t),this._updateDropdownActive("granularity-changed",s,"value"),await this.fetchData()}return!0}async onActionShowDateRangeDialog(){try{const e=await t.showForm({title:"Select Date Range",size:"sm",fields:[{name:"dt_start",type:"datetime-local",label:"Start",value:this.formatDateTimeLocal(this.dateStart),required:!0},{name:"dt_end",type:"datetime-local",label:"End",value:this.formatDateTimeLocal(this.dateEnd),required:!0}]});e?.dt_start&&e?.dt_end&&(this.dateStart=new Date(e.dt_start),this.dateEnd=new Date(e.dt_end),this._updateDropdownActive("quick-range","","range"),await this.fetchData())}catch(e){console.error("Date range dialog error:",e)}return!0}async onActionQuickRange(t,e){const s=e.dataset?.range;return!s||(this.setQuickRange(s),this._updateDropdownActive("quick-range",s,"range"),await this.fetchData(),!0)}_updateDropdownActive(t,e,s){const a=this.element?.querySelectorAll(`[data-action="${t}"]`);a&&a.forEach(t=>{const a=t.dataset?.[s];t.classList.toggle("mc-selected",a===e)})}buildApiParams(){const t={granularity:this.granularity,account:this.account,with_labels:!0};return this.slugs&&this.slugs.forEach(e=>{t["slugs[]"]||(t["slugs[]"]=[]),t["slugs[]"].push(e)}),this.category&&(t.category=this.category),this.dateStart&&(t.dr_start=Math.floor(this.dateStart.getTime()/1e3)),this.dateEnd&&(t.dr_end=Math.floor(this.dateEnd.getTime()/1e3)),t._=Date.now(),t}async fetchData(){if(this.endpoint){this.isLoading=!0,this.showLoading();try{const t=this.getApp()?.rest;if(!t)throw new Error("No REST client available");const e=this.buildApiParams(),s=await t.GET(this.endpoint,e);if(!s.success)throw new Error(s.message||"Network error");if(!s.data?.status)throw new Error(s.data?.error||"Server error");const a=s.data.data,i=this.processMetricsData(a);await this.setData(i),this.lastFetch=/* @__PURE__ */new Date,this.emit("metrics:data-loaded",{chart:this,data:a,params:e})}catch(t){console.error("Failed to fetch metrics data:",t),this.showError(`Failed to load metrics: ${t.message}`),this.emit("metrics:error",{chart:this,error:t})}finally{this.isLoading=!1,this.hideLoading()}}}processMetricsData(t){const{data:e,labels:s}=t,a=Object.entries(e||{}).map(([t,e])=>{const s=e.map(t=>null==t||""===t?0:"number"==typeof t?t:parseFloat(t)||0),a=s.reduce((t,e)=>t+e,0);return{metric:t,values:s,total:a}});a.sort((t,e)=>e.total-t.total);let i=a,r=null;if(this.maxDatasets&&this.maxDatasets>0&&a.length>this.maxDatasets){i=a.slice(0,this.maxDatasets);const t=a.slice(this.maxDatasets),e=s.map((e,s)=>t.reduce((t,e)=>t+(e.values[s]||0),0));r={metric:this.groupRemainingLabel,values:e,total:e.reduce((t,e)=>t+e,0),isGrouped:!0}}const n=[],h=r?[...i,r]:i;this.ensureColorPool(h.length);const o="line"===this.chartType?.25:.65;return h.forEach((t,e)=>{const s=this.getColor(e);n.push({label:this.formatMetricLabel(t.metric),data:t.values,backgroundColor:this.withAlpha(s,o),borderColor:s,borderWidth:2,tension:"line"===this.chartType?.4:0,fill:!1,pointRadius:"line"===this.chartType?3:0,pointHoverRadius:5})}),{labels:s,datasets:n}}formatMetricLabel(t){return t.split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}setQuickRange(t){const e=/* @__PURE__ */new Date;let s;switch(t){case"1h":s=new Date(e.getTime()-36e5);break;case"24h":default:s=new Date(e.getTime()-864e5);break;case"7d":s=new Date(e.getTime()-6048e5);break;case"30d":s=new Date(e.getTime()-2592e6)}this.dateStart=s,this.dateEnd=e}formatDateTimeLocal(t){return t?`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}T${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`:""}formatDateRangeDisplay(){if(!this.dateStart||!this.dateEnd)return"Select Range";const t=t=>`${t.toLocaleString("default",{month:"short"})} ${t.getDate()} ${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`,e=this.dateEnd.getTime()-this.dateStart.getTime(),s=e/36e5;if(Math.abs(s-1)<.05)return"Last 1H";if(Math.abs(s-24)<.05)return"Last 24H";const a=e/864e5;return Math.abs(a-7)<.05?"Last 7D":Math.abs(a-30)<.5?"Last 30D":`${t(this.dateStart)} – ${t(this.dateEnd)}`}setGranularity(t){return this.granularity=t,this.fetchData()}setDateRange(t,e){return this.dateStart=new Date(t),this.dateEnd=new Date(e),this.fetchData()}setMetrics(t){return this.slugs=[...t],this.fetchData()}getStats(){return{...super.getStats(),lastFetch:this.lastFetch,granularity:this.granularity,slugs:[...this.slugs],dateRange:{start:this.dateStart,end:this.dateEnd}}}}class MiniChart extends e{constructor(t={}){super({className:"mini-chart",...t}),this.chartType=t.chartType||"line",this.data=t.data||[],this.width=t.width||"100%",this.height=t.height||30,this.maintainAspectRatio=t.maintainAspectRatio||!1,this.color=t.color||"rgba(54, 162, 235, 1)",this.fillColor=t.fillColor||"rgba(54, 162, 235, 0.1)",this.strokeWidth=t.strokeWidth||2,this.barGap=t.barGap||2,this.fill=!1!==t.fill,this.smoothing=t.smoothing||.3,this.padding=t.padding||2,this.minValue=t.minValue,this.maxValue=t.maxValue,this.showDots=t.showDots||!1,this.dotRadius=t.dotRadius||2,this.animate=!1!==t.animate,this.animationDuration=t.animationDuration||300,this.showTooltip=!1!==t.showTooltip,this.tooltipFormatter=t.tooltipFormatter||null,this.tooltipTemplate=t.tooltipTemplate||null,this.valueFormat=t.valueFormat||null,this.labelFormat=t.labelFormat||null,this.showCrosshair=!1!==t.showCrosshair,this.crosshairColor=t.crosshairColor||"rgba(0, 0, 0, 0.2)",this.crosshairWidth=t.crosshairWidth||1,this.showXAxis=t.showXAxis||!1,this.xAxisColor=t.xAxisColor||this.color,this.xAxisWidth=t.xAxisWidth||1,this.xAxisDashed=!1!==t.xAxisDashed,this.tooltip=null,this.crosshair=null,this.hoveredIndex=-1,this.dataFormatter=s,this.labels=t.labels||null}getTemplate(){const t="number"==typeof this.width?`${this.width}px`:this.width,e="number"==typeof this.height?`${this.height}px`:this.height,s=this.maintainAspectRatio?"xMidYMid meet":"none";return`\n <div class="mini-chart-wrapper" style="position: relative; display: block; width: ${t}; height: ${e};">\n <svg\n class="mini-chart-svg"\n width="100%"\n height="100%"\n viewBox="0 0 100 ${this.height}"\n preserveAspectRatio="${s}"\n style="display: block;">\n </svg>\n ${this.showTooltip?'<div class="mini-chart-tooltip" style="display: none;"></div>':""}\n </div>\n `}async onAfterRender(){this.svg=this.element.querySelector(".mini-chart-svg"),this.tooltip=this.element.querySelector(".mini-chart-tooltip"),this.updateDimensions(),this.data&&this.data.length>0&&this.renderChart(),this.showTooltip&&this.svg&&this.setupTooltip(),this.setupResizeObserver()}updateDimensions(){if(!this.svg)return;const t=this.svg.getBoundingClientRect();this.actualWidth=t.width||100,this.actualHeight=t.height||this.height,this.svg.setAttribute("viewBox",`0 0 ${this.actualWidth} ${this.actualHeight}`)}setupResizeObserver(){"undefined"!=typeof ResizeObserver&&(this.resizeObserver=new ResizeObserver(()=>{this.updateDimensions(),this.data&&this.data.length>0&&this.renderChart()}),this.svg&&this.resizeObserver.observe(this.svg))}renderChart(){if(!this.svg||!this.data||0===this.data.length)return;this.svg.innerHTML="";const{min:t,max:e}=this.calculateBounds();if(this.showXAxis&&this.renderXAxis(t,e),"line"===this.chartType?this.renderLine(t,e):"bar"===this.chartType&&this.renderBar(t,e),this.showCrosshair){const t=this.getActualHeight();this.crosshair=this.createSVGElement("line",{x1:0,y1:0,x2:0,y2:t,stroke:this.crosshairColor,"stroke-width":this.crosshairWidth,"stroke-dasharray":"3,3",style:"display: none; pointer-events: none;"}),this.svg.appendChild(this.crosshair)}this.showTooltip&&this.tooltip&&this.setupTooltip(),this.animate&&this.applyAnimation()}renderXAxis(t,e){const s=this.getActualWidth(),a=this.getActualHeight();let i;if(t<=0&&e>=0){const s=e-t,r=(a-2*this.padding)/s;i=a-this.padding-(0-t)*r}else i=a-this.padding;const r=this.createSVGElement("line",{x1:this.padding,y1:i,x2:s-this.padding,y2:i,stroke:this.xAxisColor,"stroke-width":this.xAxisWidth,"stroke-dasharray":this.xAxisDashed?"2,2":"none","stroke-opacity":"0.5"});this.svg.appendChild(r)}calculateBounds(){const t=this.data.map(t=>"object"==typeof t?t.value:t);let e=void 0!==this.minValue?this.minValue:Math.min(...t),s=void 0!==this.maxValue?this.maxValue:Math.max(...t);return 0===s-e&&("bar"===this.chartType&&0===e?(e=0,s=1):(e-=1,s+=1)),{min:e,max:s}}getActualWidth(){return this.actualWidth||this.width||100}getActualHeight(){return this.actualHeight||this.height||30}renderLine(t,e){const s=this.data.map(t=>"object"==typeof t?t.value:t),a=this.calculatePoints(s,t,e);if(this.fill){const t=this.createAreaPath(a),e=this.createSVGElement("path",{d:t,fill:this.fillColor,stroke:"none"});this.svg.appendChild(e)}const i=this.smoothing>0?this.createSmoothPath(a):this.createLinePath(a),r=this.createSVGElement("path",{d:i,fill:"none",stroke:this.color,"stroke-width":this.strokeWidth,"stroke-linecap":"round","stroke-linejoin":"round"});this.svg.appendChild(r),this.showDots&&a.forEach(t=>{const e=this.createSVGElement("circle",{cx:t.x,cy:t.y,r:this.dotRadius,fill:this.color});this.svg.appendChild(e)})}renderBar(t,e){const s=this.data.map(t=>"object"==typeof t?t.value:t),a=this.calculatePoints(s,t,e),i=this.getActualWidth(),r=this.getActualHeight(),n=(i-2*this.padding-this.barGap*(s.length-1))/s.length;a.forEach((t,e)=>{const s=r-2*this.padding-t.y+this.padding,a=t.x-n/2,i=t.y,h=this.createSVGElement("rect",{x:a,y:i,width:n,height:s,fill:this.color,rx:1,"data-bar-index":e,class:"mini-chart-bar"});this.svg.appendChild(h)})}calculatePoints(t,e,s){const a=s-e,i=this.getActualWidth(),r=this.getActualHeight(),n=(i-2*this.padding)/(t.length-1||1),h=(r-2*this.padding)/a;return t.map((t,s)=>({x:this.padding+s*n,y:r-this.padding-(t-e)*h}))}createLinePath(t){if(0===t.length)return"";let e=`M ${t[0].x},${t[0].y}`;for(let s=1;s<t.length;s++)e+=` L ${t[s].x},${t[s].y}`;return e}createSmoothPath(t){if(t.length<2)return this.createLinePath(t);let e=`M ${t[0].x},${t[0].y}`;for(let s=0;s<t.length-1;s++){const a=t[s],i=t[s+1];e+=` C ${a.x+(i.x-a.x)*this.smoothing},${a.y} ${i.x-(i.x-a.x)*this.smoothing},${i.y} ${i.x},${i.y}`}return e}createAreaPath(t){if(0===t.length)return"";const e=this.smoothing>0?this.createSmoothPath(t):this.createLinePath(t),s=t[t.length-1],a=t[0],i=this.getActualHeight();return`${e} L ${s.x},${i-this.padding} L ${a.x},${i-this.padding} Z`}createSVGElement(t,e={}){const s=document.createElementNS("http://www.w3.org/2000/svg",t);return Object.entries(e).forEach(([t,e])=>{s.setAttribute(t,e)}),s}applyAnimation(){this.svg.querySelectorAll("path").forEach(t=>{const e=t.getTotalLength();t.style.strokeDasharray=e,t.style.strokeDashoffset=e,t.style.animation=`mini-chart-draw ${this.animationDuration}ms ease-out forwards`}),this.svg.querySelectorAll("rect").forEach((t,e)=>{t.style.transformOrigin="bottom",t.style.animation=`mini-chart-bar-grow ${this.animationDuration}ms ease-out ${20*e}ms forwards`,t.style.transform="scaleY(0)"})}setupTooltip(){if(!this.svg||!this.tooltip)return;const t=this.data.map(t=>"object"==typeof t?t.value:t),e=this.calculatePoints(t,...Object.values(this.calculateBounds())),s=this.getActualWidth(),a=this.getActualHeight(),i=s/t.length;e.forEach((t,e)=>{const s=this.createSVGElement("rect",{x:e*i,y:0,width:i,height:a,fill:"transparent",style:"cursor: pointer;"});s.addEventListener("mouseenter",t=>{this.showTooltipAtIndex(e,t)}),s.addEventListener("mousemove",t=>{this.updateTooltipPosition(t)}),s.addEventListener("mouseleave",()=>{this.hideTooltip()}),this.svg.appendChild(s)})}showTooltipAtIndex(t,e){if(!this.tooltip)return;this.hoveredIndex=t;const s="object"==typeof this.data[t]?this.data[t].value:this.data[t],a="object"==typeof this.data[t]?this.data[t].label:null,i=this.labels?this.labels[t]:a;let r;if(this.tooltipTemplate&&"function"==typeof this.tooltipTemplate)r=this.tooltipTemplate({value:s,label:i,index:t,data:this.data[t]});else{let e=s;e=this.valueFormat&&this.dataFormatter?this.dataFormatter.pipe(s,this.valueFormat):this.tooltipFormatter&&"function"==typeof this.tooltipFormatter?this.tooltipFormatter(s,t):"number"==typeof s?s.toLocaleString():s;let a=i;i&&this.labelFormat&&this.dataFormatter&&(a=this.dataFormatter.pipe(i,this.labelFormat)),r=`<strong>${e}</strong>`,a&&(r=`<div class="mini-chart-tooltip-label">${a}</div>${r}`)}if(this.tooltip.innerHTML=r,this.tooltip.style.display="block",this.updateTooltipPosition(e),"bar"===this.chartType&&this.highlightBar(t),this.crosshair&&this.showCrosshair){const e=this.getActualWidth()/this.data.length,s=t*e+e/2;this.crosshair.setAttribute("x1",s),this.crosshair.setAttribute("x2",s),this.crosshair.style.display="block"}}updateTooltipPosition(t){if(!this.tooltip||"none"===this.tooltip.style.display)return;const e=this.svg.getBoundingClientRect(),s=t.clientX-e.left,a=t.clientY-e.top;this.tooltip.style.left=`${s}px`,this.tooltip.style.top=a-10+"px",this.tooltip.style.transform="translate(-50%, -100%)"}hideTooltip(){this.tooltip&&(this.tooltip.style.display="none",this.hoveredIndex=-1),"bar"===this.chartType&&this.unhighlightBars(),this.crosshair&&(this.crosshair.style.display="none")}highlightBar(t){if(!this.svg)return;this.unhighlightBars();const e=this.svg.querySelector(`rect.mini-chart-bar[data-bar-index="${t}"]`);e&&(e.style.opacity="0.7")}unhighlightBars(){this.svg&&this.svg.querySelectorAll("rect.mini-chart-bar").forEach(t=>{t.style.opacity="1"})}setData(t){this.data=t,this.svg&&this.renderChart()}setColor(t){this.color=t,this.svg&&this.renderChart()}setType(t){["line","bar"].includes(t)&&(this.chartType=t,this.svg&&this.renderChart())}resize(t,e){this.width=t,this.height=e,this.updateDimensions(),this.svg&&this.renderChart()}async onBeforeDestroy(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),await super.onBeforeDestroy()}}class MetricsMiniChart extends MiniChart{constructor(t={}){super(t),this.endpoint=t.endpoint||"/api/metrics/fetch",this.account=t.account||"global",this.granularity=t.granularity||"hours",this.slugs=t.slugs||null,this.category=t.category||null,this.dateStart=t.dateStart||null,this.dateEnd=t.dateEnd||null,this.defaultDateRange=t.defaultDateRange||null,this.isLoading=!1,this.lastFetch=null,this.refreshInterval=t.refreshInterval,!this.defaultDateRange||this.dateStart||this.dateEnd||this.setQuickRange(this.defaultDateRange),this.slugs&&!Array.isArray(this.slugs)&&(this.slugs=[this.slugs])}async onAfterRender(){await super.onAfterRender(),!this.endpoint||this.data&&0!==this.data.length||this.fetchData(),this.refreshInterval&&this.endpoint&&this.startAutoRefresh()}buildApiParams(){const t={granularity:this.granularity,account:this.account,with_labels:!0};return this.slugs&&this.slugs.length>0&&this.slugs.forEach(e=>{t["slugs[]"]||(t["slugs[]"]=[]),t["slugs[]"].push(e)}),this.category&&(t.category=this.category),this.dateStart&&(t.dr_start=Math.floor(this.dateStart.getTime()/1e3)),this.dateEnd&&(t.dr_end=Math.floor(this.dateEnd.getTime()/1e3)),t._=Date.now(),t}async fetchData(){if(this.endpoint){this.isLoading=!0;try{const t=this.getApp()?.rest;if(!t)throw new Error("No REST client available");const e=this.buildApiParams(),s=await t.GET(this.endpoint,e);if(!s.success)throw new Error(s.message||"Network error");if(!s.data?.status)throw new Error(s.data?.error||"Server error");const a=s.data.data;this.processMetricsData(a),this.lastFetch=/* @__PURE__ */new Date,await this.render(),this.emit("metrics:loaded",{chart:this,data:a,params:e})}catch(t){console.error("Failed to fetch metrics:",t),this.emit("metrics:error",{chart:this,error:t})}finally{this.isLoading=!1}}}processMetricsData(t){const{data:e,labels:s}=t;if(!e)return;const a=Object.keys(e);if(0===a.length)return;const i=e[a[0]].map(t=>null==t||""===t?0:"number"==typeof t?t:parseFloat(t)||0);this.labels=s||null,this.setData(i)}setQuickRange(t){const e=/* @__PURE__ */new Date;let s;switch(t){case"1h":s=new Date(e.getTime()-36e5);break;case"24h":default:s=new Date(e.getTime()-864e5);break;case"7d":s=new Date(e.getTime()-6048e5);break;case"30d":s=new Date(e.getTime()-2592e6)}this.dateStart=s,this.dateEnd=e}startAutoRefresh(){this.refreshTimer&&clearInterval(this.refreshTimer),this.refreshTimer=setInterval(()=>{this.fetchData()},this.refreshInterval)}stopAutoRefresh(){this.refreshTimer&&(clearInterval(this.refreshTimer),this.refreshTimer=null)}setGranularity(t){return this.granularity=t,this.fetchData()}setDateRange(t,e){return this.dateStart=new Date(t),this.dateEnd=new Date(e),this.fetchData()}setMetrics(t){return this.slugs=Array.isArray(t)?t:[t],this.fetchData()}refresh(){return this.fetchData()}async onBeforeDestroy(){this.stopAutoRefresh(),await super.onBeforeDestroy()}}class SettingsView extends e{constructor(t={}){super({tagName:"div",className:"metrics-chart-settings-content",...t}),this.granularity=t.granularity,this.chartType=t.chartType,this.dateStart=t.dateStart,this.dateEnd=t.dateEnd,this.showDateRange=t.showDateRange}formatDateForInput(t){if(!t)return"";if("string"==typeof t&&/^\d{4}-\d{2}-\d{2}$/.test(t))return t;const e=t instanceof Date?t:new Date(t);return isNaN(e.getTime())?"":`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}getTemplate(){return`\n <div style="min-width: 220px;">\n <div class="d-flex justify-content-between align-items-center mb-2 pb-2 border-bottom">\n <h6 class="mb-0">Chart Settings</h6>\n <button type="button" class="btn-close btn-close-sm" data-action="close" aria-label="Close"></button>\n </div>\n\n <label class="form-label small mb-1">Granularity</label>\n <select class="form-select form-select-sm mb-2" data-setting="granularity">\n <option value="hours" ${"hours"===this.granularity?"selected":""}>Hours</option>\n <option value="days" ${"days"===this.granularity?"selected":""}>Days</option>\n <option value="weeks" ${"weeks"===this.granularity?"selected":""}>Weeks</option>\n <option value="months" ${"months"===this.granularity?"selected":""}>Months</option>\n <option value="years" ${"years"===this.granularity?"selected":""}>Years</option>\n </select>\n \n <label class="form-label small mb-1">Chart Type</label>\n <select class="form-select form-select-sm mb-2" data-setting="chartType">\n <option value="line" ${"line"===this.chartType?"selected":""}>Line</option>\n <option value="bar" ${"bar"===this.chartType?"selected":""}>Bar</option>\n </select>\n \n ${this.showDateRange?`\n <label class="form-label small mb-1">Date Range</label>\n <input type="date" class="form-control form-control-sm mb-1" data-setting="dateStart" value="${this.formatDateForInput(this.dateStart)}" />\n <input type="date" class="form-control form-control-sm mb-2" data-setting="dateEnd" value="${this.formatDateForInput(this.dateEnd)}" />\n `:""}\n \n <div class="d-grid gap-2">\n <button type="button" class="btn btn-sm btn-primary" data-action="apply">Apply</button>\n <button type="button" class="btn btn-sm btn-outline-secondary" data-action="cancel">Cancel</button>\n </div>\n </div>\n `}async onActionApply(){const t=this.element.querySelector('[data-setting="granularity"]')?.value,e=this.element.querySelector('[data-setting="chartType"]')?.value,s=this.element.querySelector('[data-setting="dateStart"]')?.value,a=this.element.querySelector('[data-setting="dateEnd"]')?.value;this.emit("settings:apply",{granularity:t,chartType:e,dateStart:s,dateEnd:a})}async onActionCancel(){this.emit("settings:cancel")}async onActionClose(){this.emit("settings:cancel")}}class MetricsMiniChartWidget extends e{constructor(t={}){super({...t,tagName:"div",className:`metrics-mini-chart-widget ${t.className||""}`.trim()}),this.icon=t.icon||null,this.title=t.title||"",this.subtitle=t.subtitle||"",this.background=t.background||null,this.textColor=t.textColor||null,this.showSettings=t.showSettings||!1,this.settingsKey=t.settingsKey||null,this.showDateRange=t.showDateRange||!1,this.showRefresh=!1!==t.showRefresh,this.showTrending=!!t.showTrending,this.trendRange=t.trendRange??null,this.trendOffset=t.trendOffset??0,this.prevTrendOffset=t.prevTrendOffset??0,this.total=0,this.lastValue=0,this.prevValue=0,this.trendingPercent=0,this.trendingUp=null,this.hasTrending=!1,this.trendingClass="metrics-mini-chart-trending-text",this.trendingIcon="",this.trendingLabel="",this.chartOptions={endpoint:t.endpoint,account:t.account,granularity:t.granularity,slugs:t.slugs,category:t.category,dateStart:t.dateStart,dateEnd:t.dateEnd,defaultDateRange:t.defaultDateRange,refreshInterval:t.refreshInterval,chartType:t.chartType||"line",showTooltip:void 0===t.showTooltip||t.showTooltip,showXAxis:t.showXAxis||!1,height:t.height||80,width:t.chartWidth||t.width||"100%",color:t.color,fill:void 0===t.fill||t.fill,fillColor:t.fillColor,smoothing:t.smoothing??.3,strokeWidth:t.strokeWidth,barGap:t.barGap,valueFormat:t.valueFormat,labelFormat:t.labelFormat,tooltipFormatter:t.tooltipFormatter,tooltipTemplate:t.tooltipTemplate,showCrosshair:t.showCrosshair,crosshairColor:t.crosshairColor,crosshairWidth:t.crosshairWidth,xAxisColor:t.xAxisColor,xAxisWidth:t.xAxisWidth,xAxisDashed:t.xAxisDashed,padding:t.padding,minValue:t.minValue,maxValue:t.maxValue,showDots:t.showDots,dotRadius:t.dotRadius,animate:t.animate,animationDuration:t.animationDuration}}async onInit(){this.showSettings&&this.settingsKey&&this._loadSettings(),this.chart=new MetricsMiniChart({...this.chartOptions,containerId:"chart"}),this.addChild(this.chart),this.header=new e({containerId:"chart-header",title:this.title,icon:this.icon,template:`\n <div class="d-flex justify-content-between align-items-start mb-2">\n <div class="flex-grow-1">\n <h6 class="card-title mb-1" style="${this.textColor?`color: ${this.textColor}`:""}">${this.title}</h6>\n <div class="metrics-mini-chart-subtitle" style="${this.textColor?`color: ${this.textColor}`:""}">${this.subtitle}</div>\n {{#hasTrending}}\n <div class="{{trendingClass}}" style="${this.textColor?`color: ${this.textColor}`:""}">\n <i class="{{trendingIcon}} me-1"></i>{{trendingLabel}}\n </div>\n {{/hasTrending}}\n </div>\n ${this.icon?`<i class="${this.icon} fs-4 flex-shrink-0" aria-hidden="true" style="${this.textColor?`color: ${this.textColor}`:""}"></i>`:""}\n </div>`}),this.addChild(this.header),this.showSettings&&(this.settingsView=new SettingsView({containerId:"settings",granularity:this.chartOptions.granularity,chartType:this.chartOptions.chartType,dateStart:this.chartOptions.dateStart,dateEnd:this.chartOptions.dateEnd,showDateRange:this.showDateRange}),this.settingsView.on("settings:apply",t=>this._handleSettingsApply(t)),this.settingsView.on("settings:cancel",()=>this._handleSettingsCancel()),this.addChild(this.settingsView)),this.chart?.on&&this.chart.on("metrics:loaded",this.onChildMetricsLoaded,this),this.updateFromChartData({render:!1})}async onAfterRender(){await super.onAfterRender(),this.showSettings&&this.settingsView&&this._initSettingsPopover()}onChildMetricsLoaded(){this.updateFromChartData({render:!0})}updateFromChartData({render:t=!0}={}){const e=Array.isArray(this.chart?.data)?this.chart.data:null;if(!e||0===e.length)return this.total=0,this.hasTrending=!1,this.header.title=this.title,void(t&&this.render());const s=e.map(t=>{if("number"==typeof t)return t;if(t&&"number"==typeof t.value)return t.value;const e=parseFloat(t);return Number.isNaN(e)?0:e});this.header.title=this.title,this.header.total=s.reduce((t,e)=>t+e,0);const a=Math.max(0,parseInt(this.trendOffset||0,10)||0),i=Math.max(0,s.length-1-a);this.header.now_value=s[i],this._updateGranularityLabels();let r=!1,n=0,h=0;const o=this.trendRange&&this.trendRange>=2?Math.max(1,Math.floor(this.trendRange/2)):1;if(i>=0){const t=i,e=t-(o-1);let a,l;if(this.prevTrendOffset&&this.prevTrendOffset>0?(a=e-this.prevTrendOffset,l=t-this.prevTrendOffset):(l=e-1,a=l-(o-1)),e>=0&&a>=0){const i=(t,e,s)=>{let a=0;for(let i=e;i<=s;i++)a+=t[i]||0;return a};n=i(s,e,t),h=i(s,a,l),r=!0}}if(!r){const t=i-(this.prevTrendOffset&&this.prevTrendOffset>0?this.prevTrendOffset:1);t>=0&&(n=s[i],h=s[t],r=!0)}if(r){this.header.lastValue=n,this.header.prevValue=h;let t=0;t=0===h?n>0?100:0:(n-h)/Math.abs(h)*100,this.header.trendingPercent=t,this.header.trendingUp=t>=0,this.textColor?this.header.trendingClass="":this.header.trendingClass=this.header.trendingUp?"text-success":"text-danger",this.header.trendingIcon=this.header.trendingUp?"bi bi-arrow-up":"bi bi-arrow-down";const e=t>0?"+":"";this.header.trendingLabel=`${e}${t.toFixed(1)}%`,this.header.hasTrending=this.showTrending}else this.header.hasTrending=!1;t&&this.header.render()}_updateGranularityLabels(){const t=this.chartOptions.granularity||"days";this.header.now_label={hours:"This Hour",days:"Today",weeks:"This Week",months:"This Month",years:"This Year"}[t]||"Current",this.header.total_label={hours:"Total (24h)",days:"Total (Period)",weeks:"Total (Period)",months:"Total (Period)",years:"Total (Period)"}[t]||"Total"}get cardStyle(){const t=[];return this.background&&t.push(`background: ${this.background}`),this.textColor&&t.push(`color: ${this.textColor}`),t.push("border: 0"),t.join("; ")}async getTemplate(){return`\n <div class="card h-100 shadow-sm" style="${this.cardStyle}; position: relative;">\n ${this.showRefresh||this.showSettings?`\n <div class="metrics-chart-actions">\n ${this.showRefresh?`\n <button class="btn btn-link p-0 text-muted metrics-refresh-btn" type="button" data-action="refresh-chart" style="${this.textColor?`color: ${this.textColor} !important`:""}">\n <i class="bi bi-arrow-clockwise"></i>\n </button>\n `:""}\n ${this.showSettings?`\n <button class="btn btn-link p-0 text-muted metrics-settings-btn" type="button" data-action="toggle-settings" style="${this.textColor?`color: ${this.textColor} !important`:""}">\n <i class="bi bi-gear-fill"></i>\n </button>\n `:""}\n </div>\n `:""}\n <div class="card-body p-3">\n <div data-container="chart-header"></div>\n <div data-container="chart"></div>\n <div data-container="settings" style="display: none;"></div>\n </div>\n </div>\n `}async onBeforeDestroy(){this._settingsPopover&&(this._settingsPopover.dispose(),this._settingsPopover=null),this.chart?.off&&this.chart.off("metrics:loaded",this.onChildMetricsLoaded,this),await super.onBeforeDestroy()}async onActionToggleSettings(t,e){this._settingsPopover||this._initSettingsPopover(),this._settingsPopover?.toggle()}_initSettingsPopover(){const t=this.element.querySelector('[data-action="toggle-settings"]');t&&this.settingsView&&this.settingsView.element&&(this._settingsPopover||(this._settingsPopover=new bootstrap.Popover(t,{content:this.settingsView.element,html:!0,placement:"bottom",trigger:"manual",sanitize:!1,customClass:"metrics-chart-settings-popover"})))}async _handleSettingsApply(t){this._settingsPopover&&this._settingsPopover.hide();let e=!1,s=!1,a=!1;if((t.dateStart&&t.dateStart!==this.chartOptions.dateStart||t.dateEnd&&t.dateEnd!==this.chartOptions.dateEnd)&&(a=!0),t.granularity&&t.granularity!==this.chartOptions.granularity&&(this.chartOptions.granularity=t.granularity,this.chart.granularity=t.granularity,s=!0,e=!0),t.chartType&&t.chartType!==this.chartOptions.chartType&&(this.chartOptions.chartType=t.chartType,this.chart.chartType=t.chartType,e=!0),a)t.dateStart&&(this.chartOptions.dateStart=new Date(t.dateStart),this.chart.dateStart=new Date(t.dateStart)),t.dateEnd&&(this.chartOptions.dateEnd=new Date(t.dateEnd),this.chart.dateEnd=new Date(t.dateEnd)),e=!0;else if(s&&(this.chartOptions.dateStart||this.chartOptions.dateEnd)){const e=/* @__PURE__ */new Date;let s;switch(t.granularity){case"hours":s=new Date(e.getTime()-864e5);break;case"days":default:s=new Date(e.getTime()-2592e6);break;case"weeks":s=new Date(e.getTime()-72576e5);break;case"months":s=new Date(e),s.setMonth(s.getMonth()-12);break;case"years":s=new Date(e),s.setFullYear(s.getFullYear()-5)}this.chartOptions.dateStart=s,this.chart.dateStart=s,this.chartOptions.dateEnd=e,this.chart.dateEnd=e}e&&(this._saveSettings(),await this.chart.refresh())}_handleSettingsCancel(){this._settingsPopover&&this._settingsPopover.hide()}async onActionRefreshChart(t,e){const s=e.querySelector("i");s&&s.classList.add("spin"),this.chart&&(this.account&&(this.chart.account=this.account),await this.chart.refresh()),s&&s.classList.remove("spin")}refresh(){this.chart&&(this.account&&(this.chart.account=this.account),this.chart.refresh())}_loadSettings(){if(this.settingsKey)try{const t=localStorage.getItem(`metrics-chart-${this.settingsKey}`);if(t){const e=JSON.parse(t);e.granularity&&(this.chartOptions.granularity=e.granularity),e.chartType&&(this.chartOptions.chartType=e.chartType),void 0!==e.dateStart&&(this.chartOptions.dateStart=e.dateStart),void 0!==e.dateEnd&&(this.chartOptions.dateEnd=e.dateEnd)}}catch(t){console.error("Failed to load chart settings:",t)}}_saveSettings(){if(this.settingsKey)try{const t={granularity:this.chartOptions.granularity,chartType:this.chartOptions.chartType,dateStart:this.chartOptions.dateStart,dateEnd:this.chartOptions.dateEnd};localStorage.setItem(`metrics-chart-${this.settingsKey}`,JSON.stringify(t))}catch(t){console.error("Failed to save chart settings:",t)}}}export{BaseChart as B,MetricsChart as M,PieChart as P,SeriesChart as S,MetricsMiniChart as a,MetricsMiniChartWidget as b,MiniChart as c};
2
- //# sourceMappingURL=MetricsMiniChartWidget-BaXxR9C6.js.map