@carto/meridian-ds 1.0.0 → 1.1.0-alpha.2

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 (262) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/{Alert-CU0-7Oca.js → Alert-DDz3-_16.js} +1 -1
  3. package/dist/{Alert-CT76xuh3.cjs → Alert-FLV5jJYV.cjs} +1 -1
  4. package/dist/ArrowDown-B1AG0MlL.js +24 -0
  5. package/dist/MenuItem-BTaTqbU8.js +3565 -0
  6. package/dist/MenuItem-CxZTr9gk.cjs +9 -0
  7. package/dist/SwatchSquare-DAne_6Gi.js +35 -0
  8. package/dist/TablePaginationActions-DyJEKn3l.cjs +9 -0
  9. package/dist/{TablePaginationActions-C9YCSB32.js → TablePaginationActions-GazQOp5y.js} +775 -548
  10. package/dist/components/index.cjs +5 -1
  11. package/dist/components/index.js +13831 -617
  12. package/dist/custom-icons/index.js +3984 -257
  13. package/dist/theme/index.cjs +1 -1
  14. package/dist/theme/index.js +401 -149
  15. package/dist/types/components/atoms/Button.d.ts.map +1 -1
  16. package/dist/types/components/atoms/PasswordField.d.ts.map +1 -1
  17. package/dist/types/components/atoms/SelectField.d.ts.map +1 -1
  18. package/dist/types/components/molecules/Autocomplete.d.ts.map +1 -1
  19. package/dist/types/components/molecules/Menu/MenuItem.d.ts.map +1 -1
  20. package/dist/types/components/molecules/MultipleSelectField/MultipleSelectField.d.ts.map +1 -1
  21. package/dist/types/components/molecules/UploadField/StyledUploadField.d.ts.map +1 -1
  22. package/dist/types/components/organisms/DatePickers/ClearButton.d.ts +6 -0
  23. package/dist/types/components/organisms/DatePickers/ClearButton.d.ts.map +1 -0
  24. package/dist/types/components/organisms/DatePickers/DateFieldContainer.d.ts +8 -0
  25. package/dist/types/components/organisms/DatePickers/DateFieldContainer.d.ts.map +1 -0
  26. package/dist/types/components/organisms/DatePickers/DatePicker.d.ts +4 -0
  27. package/dist/types/components/organisms/DatePickers/DatePicker.d.ts.map +1 -0
  28. package/dist/types/components/organisms/DatePickers/DateRangePicker.d.ts +4 -0
  29. package/dist/types/components/organisms/DatePickers/DateRangePicker.d.ts.map +1 -0
  30. package/dist/types/components/organisms/DatePickers/DateTimePicker.d.ts +4 -0
  31. package/dist/types/components/organisms/DatePickers/DateTimePicker.d.ts.map +1 -0
  32. package/dist/types/components/organisms/DatePickers/PickersDay.d.ts +4 -0
  33. package/dist/types/components/organisms/DatePickers/PickersDay.d.ts.map +1 -0
  34. package/dist/types/components/organisms/DatePickers/TimePicker.d.ts +4 -0
  35. package/dist/types/components/organisms/DatePickers/TimePicker.d.ts.map +1 -0
  36. package/dist/types/components/organisms/DatePickers/index.d.ts +5 -0
  37. package/dist/types/components/organisms/DatePickers/index.d.ts.map +1 -0
  38. package/dist/types/components/organisms/DatePickers/types.d.ts +35 -0
  39. package/dist/types/components/organisms/DatePickers/types.d.ts.map +1 -0
  40. package/dist/types/components/organisms/DatePickers/utils.d.ts +3 -0
  41. package/dist/types/components/organisms/DatePickers/utils.d.ts.map +1 -0
  42. package/dist/types/components/organisms/index.d.ts +2 -0
  43. package/dist/types/components/organisms/index.d.ts.map +1 -1
  44. package/dist/types/custom-icons/AccessIn.d.ts.map +1 -1
  45. package/dist/types/custom-icons/AddApp.d.ts.map +1 -1
  46. package/dist/types/custom-icons/AddSection.d.ts.map +1 -1
  47. package/dist/types/custom-icons/AdvancedSettings.d.ts.map +1 -1
  48. package/dist/types/custom-icons/Annotation.d.ts.map +1 -1
  49. package/dist/types/custom-icons/ApiCall.d.ts.map +1 -1
  50. package/dist/types/custom-icons/ArrowDown.d.ts.map +1 -1
  51. package/dist/types/custom-icons/ArrowLeft.d.ts.map +1 -1
  52. package/dist/types/custom-icons/ArrowRight.d.ts.map +1 -1
  53. package/dist/types/custom-icons/ArrowUp.d.ts.map +1 -1
  54. package/dist/types/custom-icons/Autostyle.d.ts.map +1 -1
  55. package/dist/types/custom-icons/Avg.d.ts.map +1 -1
  56. package/dist/types/custom-icons/Behavioral.d.ts.map +1 -1
  57. package/dist/types/custom-icons/Bigquery.d.ts.map +1 -1
  58. package/dist/types/custom-icons/Blending.d.ts.map +1 -1
  59. package/dist/types/custom-icons/BlockLabel.d.ts.map +1 -1
  60. package/dist/types/custom-icons/BlockLabelOff.d.ts.map +1 -1
  61. package/dist/types/custom-icons/BottomRow.d.ts.map +1 -1
  62. package/dist/types/custom-icons/Carto.d.ts.map +1 -1
  63. package/dist/types/custom-icons/CartoAi.d.ts.map +1 -1
  64. package/dist/types/custom-icons/CartoSymbol.d.ts.map +1 -1
  65. package/dist/types/custom-icons/CatalogView.d.ts.map +1 -1
  66. package/dist/types/custom-icons/CatastropheModeling.d.ts.map +1 -1
  67. package/dist/types/custom-icons/Center.d.ts.map +1 -1
  68. package/dist/types/custom-icons/CenterLayer.d.ts.map +1 -1
  69. package/dist/types/custom-icons/CloseDiagonallyLeft.d.ts.map +1 -1
  70. package/dist/types/custom-icons/CloseDiagonallyRight.d.ts.map +1 -1
  71. package/dist/types/custom-icons/CloseVertically.d.ts.map +1 -1
  72. package/dist/types/custom-icons/CodeBlock.d.ts.map +1 -1
  73. package/dist/types/custom-icons/Console.d.ts.map +1 -1
  74. package/dist/types/custom-icons/Covid19.d.ts.map +1 -1
  75. package/dist/types/custom-icons/CreateMap.d.ts.map +1 -1
  76. package/dist/types/custom-icons/CreateSpatialAnalysis.d.ts.map +1 -1
  77. package/dist/types/custom-icons/CreateTileset.d.ts.map +1 -1
  78. package/dist/types/custom-icons/CreateWorkflow.d.ts.map +1 -1
  79. package/dist/types/custom-icons/Data.d.ts.map +1 -1
  80. package/dist/types/custom-icons/DataAccess.d.ts.map +1 -1
  81. package/dist/types/custom-icons/DataExplorer.d.ts.map +1 -1
  82. package/dist/types/custom-icons/DataMonetization.d.ts.map +1 -1
  83. package/dist/types/custom-icons/DataObservatory.d.ts.map +1 -1
  84. package/dist/types/custom-icons/DataOk.d.ts.map +1 -1
  85. package/dist/types/custom-icons/DataPending.d.ts.map +1 -1
  86. package/dist/types/custom-icons/DataPremium.d.ts.map +1 -1
  87. package/dist/types/custom-icons/DataPublic.d.ts.map +1 -1
  88. package/dist/types/custom-icons/DataSample.d.ts.map +1 -1
  89. package/dist/types/custom-icons/DataUnavailable.d.ts.map +1 -1
  90. package/dist/types/custom-icons/Databricks.d.ts.map +1 -1
  91. package/dist/types/custom-icons/Demographics.d.ts.map +1 -1
  92. package/dist/types/custom-icons/Derived.d.ts.map +1 -1
  93. package/dist/types/custom-icons/Distance.d.ts.map +1 -1
  94. package/dist/types/custom-icons/Dot.d.ts.map +1 -1
  95. package/dist/types/custom-icons/DrawCircle.d.ts.map +1 -1
  96. package/dist/types/custom-icons/DrawLasso.d.ts.map +1 -1
  97. package/dist/types/custom-icons/DrawLine.d.ts.map +1 -1
  98. package/dist/types/custom-icons/DrawPolygon.d.ts.map +1 -1
  99. package/dist/types/custom-icons/DrawSquare.d.ts.map +1 -1
  100. package/dist/types/custom-icons/DropAPin.d.ts.map +1 -1
  101. package/dist/types/custom-icons/DualMap.d.ts.map +1 -1
  102. package/dist/types/custom-icons/Environmental.d.ts.map +1 -1
  103. package/dist/types/custom-icons/EnvironmentalManagement.d.ts.map +1 -1
  104. package/dist/types/custom-icons/Equal.d.ts.map +1 -1
  105. package/dist/types/custom-icons/ExitToAppLeft.d.ts.map +1 -1
  106. package/dist/types/custom-icons/Fabric.d.ts.map +1 -1
  107. package/dist/types/custom-icons/Facebook.d.ts.map +1 -1
  108. package/dist/types/custom-icons/Financial.d.ts.map +1 -1
  109. package/dist/types/custom-icons/FlipInverse.d.ts.map +1 -1
  110. package/dist/types/custom-icons/Framed.d.ts.map +1 -1
  111. package/dist/types/custom-icons/FraudDetection.d.ts.map +1 -1
  112. package/dist/types/custom-icons/Functions.d.ts.map +1 -1
  113. package/dist/types/custom-icons/GeneratingDescription.d.ts.map +1 -1
  114. package/dist/types/custom-icons/GeocodeTable.d.ts.map +1 -1
  115. package/dist/types/custom-icons/Geography.d.ts.map +1 -1
  116. package/dist/types/custom-icons/Geomarketing.d.ts.map +1 -1
  117. package/dist/types/custom-icons/Geometry.d.ts.map +1 -1
  118. package/dist/types/custom-icons/Github.d.ts.map +1 -1
  119. package/dist/types/custom-icons/Google.d.ts.map +1 -1
  120. package/dist/types/custom-icons/H3.d.ts.map +1 -1
  121. package/dist/types/custom-icons/HealthAnalytics.d.ts.map +1 -1
  122. package/dist/types/custom-icons/HideLeftsidebar.d.ts.map +1 -1
  123. package/dist/types/custom-icons/Home.d.ts.map +1 -1
  124. package/dist/types/custom-icons/Housing.d.ts.map +1 -1
  125. package/dist/types/custom-icons/HumanMobility.d.ts.map +1 -1
  126. package/dist/types/custom-icons/Id.d.ts.map +1 -1
  127. package/dist/types/custom-icons/Image.d.ts.map +1 -1
  128. package/dist/types/custom-icons/Infrastructure.d.ts.map +1 -1
  129. package/dist/types/custom-icons/IotAnalytics.d.ts.map +1 -1
  130. package/dist/types/custom-icons/LabelDeprecated.d.ts.map +1 -1
  131. package/dist/types/custom-icons/Layers.d.ts.map +1 -1
  132. package/dist/types/custom-icons/Linkedin.d.ts.map +1 -1
  133. package/dist/types/custom-icons/MapCoordinates.d.ts.map +1 -1
  134. package/dist/types/custom-icons/MapCopy.d.ts +4 -0
  135. package/dist/types/custom-icons/MapCopy.d.ts.map +1 -0
  136. package/dist/types/custom-icons/MapOthers.d.ts.map +1 -1
  137. package/dist/types/custom-icons/MapPin.d.ts.map +1 -1
  138. package/dist/types/custom-icons/MarketAnalysis.d.ts.map +1 -1
  139. package/dist/types/custom-icons/Max.d.ts.map +1 -1
  140. package/dist/types/custom-icons/MeasureTool.d.ts.map +1 -1
  141. package/dist/types/custom-icons/Min.d.ts.map +1 -1
  142. package/dist/types/custom-icons/MobilityPlanning.d.ts.map +1 -1
  143. package/dist/types/custom-icons/NetworkDeployment.d.ts.map +1 -1
  144. package/dist/types/custom-icons/NightsThermostat.d.ts.map +1 -1
  145. package/dist/types/custom-icons/NoApp.d.ts.map +1 -1
  146. package/dist/types/custom-icons/NoMap.d.ts.map +1 -1
  147. package/dist/types/custom-icons/NoSpatialExtension.d.ts.map +1 -1
  148. package/dist/types/custom-icons/NoTileset.d.ts.map +1 -1
  149. package/dist/types/custom-icons/NotEqual.d.ts.map +1 -1
  150. package/dist/types/custom-icons/Number.d.ts.map +1 -1
  151. package/dist/types/custom-icons/Onboarding.d.ts.map +1 -1
  152. package/dist/types/custom-icons/OohAnalytics.d.ts.map +1 -1
  153. package/dist/types/custom-icons/Opacity.d.ts.map +1 -1
  154. package/dist/types/custom-icons/OpenDiagonallyLeft.d.ts.map +1 -1
  155. package/dist/types/custom-icons/OpenDiagonallyRight.d.ts.map +1 -1
  156. package/dist/types/custom-icons/OpenNewWindow.d.ts.map +1 -1
  157. package/dist/types/custom-icons/OpenVertically.d.ts.map +1 -1
  158. package/dist/types/custom-icons/ParameterSettings.d.ts.map +1 -1
  159. package/dist/types/custom-icons/PawnChess.d.ts.map +1 -1
  160. package/dist/types/custom-icons/PlaceSelect.d.ts.map +1 -1
  161. package/dist/types/custom-icons/PointsOfInterest.d.ts.map +1 -1
  162. package/dist/types/custom-icons/Postgre.d.ts.map +1 -1
  163. package/dist/types/custom-icons/PostgreOutlined.d.ts.map +1 -1
  164. package/dist/types/custom-icons/Preferences.d.ts.map +1 -1
  165. package/dist/types/custom-icons/ProcessData.d.ts.map +1 -1
  166. package/dist/types/custom-icons/PublicWithPassword.d.ts.map +1 -1
  167. package/dist/types/custom-icons/Publish.d.ts.map +1 -1
  168. package/dist/types/custom-icons/Quadbin.d.ts.map +1 -1
  169. package/dist/types/custom-icons/Quadkey.d.ts.map +1 -1
  170. package/dist/types/custom-icons/QueryTable.d.ts.map +1 -1
  171. package/dist/types/custom-icons/Rain.d.ts.map +1 -1
  172. package/dist/types/custom-icons/Raster.d.ts.map +1 -1
  173. package/dist/types/custom-icons/Redshift.d.ts.map +1 -1
  174. package/dist/types/custom-icons/Report.d.ts.map +1 -1
  175. package/dist/types/custom-icons/Reset.d.ts.map +1 -1
  176. package/dist/types/custom-icons/RiskAnalysis.d.ts.map +1 -1
  177. package/dist/types/custom-icons/RoadTraffic.d.ts.map +1 -1
  178. package/dist/types/custom-icons/RunSettings.d.ts.map +1 -1
  179. package/dist/types/custom-icons/RunStep.d.ts.map +1 -1
  180. package/dist/types/custom-icons/Salesforce.d.ts.map +1 -1
  181. package/dist/types/custom-icons/Sample.d.ts.map +1 -1
  182. package/dist/types/custom-icons/SaveOk.d.ts.map +1 -1
  183. package/dist/types/custom-icons/ScheduleRun.d.ts.map +1 -1
  184. package/dist/types/custom-icons/Search.d.ts.map +1 -1
  185. package/dist/types/custom-icons/SelectTool.d.ts.map +1 -1
  186. package/dist/types/custom-icons/SelectVariable.d.ts.map +1 -1
  187. package/dist/types/custom-icons/SingleLayer.d.ts.map +1 -1
  188. package/dist/types/custom-icons/SiteSelection.d.ts.map +1 -1
  189. package/dist/types/custom-icons/Snowflake.d.ts.map +1 -1
  190. package/dist/types/custom-icons/SpatialAnalysis.d.ts.map +1 -1
  191. package/dist/types/custom-icons/SpatialExtension.d.ts.map +1 -1
  192. package/dist/types/custom-icons/SpatialIndexes.d.ts.map +1 -1
  193. package/dist/types/custom-icons/Sql.d.ts.map +1 -1
  194. package/dist/types/custom-icons/SqlError.d.ts.map +1 -1
  195. package/dist/types/custom-icons/Sso.d.ts.map +1 -1
  196. package/dist/types/custom-icons/StrokeCustom.d.ts.map +1 -1
  197. package/dist/types/custom-icons/StrokeDash.d.ts.map +1 -1
  198. package/dist/types/custom-icons/StrokeSolid.d.ts.map +1 -1
  199. package/dist/types/custom-icons/SupplyChain.d.ts.map +1 -1
  200. package/dist/types/custom-icons/SwatchCircle.d.ts.map +1 -1
  201. package/dist/types/custom-icons/SwatchCircleNone.d.ts.map +1 -1
  202. package/dist/types/custom-icons/SwatchSquare.d.ts.map +1 -1
  203. package/dist/types/custom-icons/TableColumn.d.ts.map +1 -1
  204. package/dist/types/custom-icons/TableColumnLimited.d.ts.map +1 -1
  205. package/dist/types/custom-icons/TempTable.d.ts.map +1 -1
  206. package/dist/types/custom-icons/TerritoryPlanning.d.ts.map +1 -1
  207. package/dist/types/custom-icons/TextBox.d.ts.map +1 -1
  208. package/dist/types/custom-icons/Tileset.d.ts.map +1 -1
  209. package/dist/types/custom-icons/TilesetsAggregated.d.ts.map +1 -1
  210. package/dist/types/custom-icons/TimeBuckets.d.ts.map +1 -1
  211. package/dist/types/custom-icons/TimeCar.d.ts.map +1 -1
  212. package/dist/types/custom-icons/TimeWindowIncremental.d.ts.map +1 -1
  213. package/dist/types/custom-icons/TimeWindowMoving.d.ts.map +1 -1
  214. package/dist/types/custom-icons/Tooltip.d.ts.map +1 -1
  215. package/dist/types/custom-icons/TopRow.d.ts.map +1 -1
  216. package/dist/types/custom-icons/TwinArea.d.ts.map +1 -1
  217. package/dist/types/custom-icons/Twitter.d.ts.map +1 -1
  218. package/dist/types/custom-icons/UpdateGen.d.ts.map +1 -1
  219. package/dist/types/custom-icons/UploadFileUrl.d.ts.map +1 -1
  220. package/dist/types/custom-icons/View2d.d.ts.map +1 -1
  221. package/dist/types/custom-icons/View3d.d.ts.map +1 -1
  222. package/dist/types/custom-icons/ViewLeftsidebar.d.ts.map +1 -1
  223. package/dist/types/custom-icons/WfComponent.d.ts.map +1 -1
  224. package/dist/types/custom-icons/WfComponentInvalid.d.ts.map +1 -1
  225. package/dist/types/custom-icons/WfExtensionPackageDefault.d.ts.map +1 -1
  226. package/dist/types/custom-icons/WfInput.d.ts.map +1 -1
  227. package/dist/types/custom-icons/WfInputAlt.d.ts.map +1 -1
  228. package/dist/types/custom-icons/WfModule.d.ts.map +1 -1
  229. package/dist/types/custom-icons/WfOutput.d.ts.map +1 -1
  230. package/dist/types/custom-icons/WfOutputAlt.d.ts.map +1 -1
  231. package/dist/types/custom-icons/WhiteSpace.d.ts.map +1 -1
  232. package/dist/types/custom-icons/WidgetOptions.d.ts.map +1 -1
  233. package/dist/types/custom-icons/Workflow.d.ts.map +1 -1
  234. package/dist/types/custom-icons/WorkflowTemp.d.ts.map +1 -1
  235. package/dist/types/custom-icons/index.d.ts.map +1 -1
  236. package/dist/types/localization/en.d.ts +9 -0
  237. package/dist/types/localization/en.d.ts.map +1 -1
  238. package/dist/types/localization/es.d.ts +9 -0
  239. package/dist/types/localization/es.d.ts.map +1 -1
  240. package/dist/types/localization/id.d.ts +9 -0
  241. package/dist/types/localization/id.d.ts.map +1 -1
  242. package/dist/types/localization/index.d.ts +27 -0
  243. package/dist/types/localization/index.d.ts.map +1 -1
  244. package/dist/types/theme/carto-theme.d.ts +303 -119
  245. package/dist/types/theme/carto-theme.d.ts.map +1 -1
  246. package/dist/types/theme/sections/components/data-display.d.ts +1 -2
  247. package/dist/types/theme/sections/components/data-display.d.ts.map +1 -1
  248. package/dist/types/theme/sections/components/date-pickers.d.ts +3 -0
  249. package/dist/types/theme/sections/components/date-pickers.d.ts.map +1 -0
  250. package/dist/types/theme/sections/typography.d.ts +1 -1
  251. package/dist/types/theme/types.d.ts.map +1 -1
  252. package/dist/types/widgets/CategoryWidgetUI/CategoryWidgetUI.d.ts +2 -1
  253. package/dist/types/widgets/CategoryWidgetUI/CategoryWidgetUI.d.ts.map +1 -1
  254. package/dist/types/widgets/comparative/ComparativeFormulaWidgetUI/FormulaLabel.d.ts.map +1 -1
  255. package/dist/types/widgets/legend/LegendLayer.d.ts.map +1 -1
  256. package/dist/types/widgets/legend/LegendWidgetUI.d.ts.map +1 -1
  257. package/dist/widgets/index.cjs +16 -16
  258. package/dist/widgets/index.js +1554 -1552
  259. package/package.json +21 -15
  260. package/dist/ArrowDown-TqD1eTx5.js +0 -6
  261. package/dist/SwatchSquare-DVuvnme5.js +0 -7
  262. package/dist/TablePaginationActions-5u10SobX.cjs +0 -9
@@ -1,22 +1,22 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),u=require("react"),o=require("@mui/material"),Z=require("react-intl"),j=require("../TablePaginationActions-5u10SobX.cjs"),mn=require("echarts-for-react"),Te=require("../SwatchSquare-C-QxZLYN.cjs"),fe=require("@mui/icons-material"),Me=require("../paletteUtils-DLQVT9qo.cjs"),Et=require("@mui/material/styles"),yn=require("@mui/icons-material/KeyboardArrowDown"),vn=require("@mui/icons-material/Close"),jn=require("@mui/icons-material/LayersOutlined"),wn=require("@mui/icons-material/VisibilityOutlined"),bn=require("@mui/icons-material/VisibilityOffOutlined"),Sn=require("@mui/icons-material/ExpandMore"),kn=require("@mui/icons-material/ExpandLess"),In=require("../Alert-CT76xuh3.cjs");function Bt(){let e=!1;return window.PointerEvent&&"maxTouchPoints"in navigator?navigator.maxTouchPoints>0&&(e=!0):(window.matchMedia&&window.matchMedia("(any-pointer:coarse)").matches||window.TouchEvent||"ontouchstart"in window)&&(e=!0),e}function te(e){return!e||typeof e!="object"?e:`${e.prefix??""}${e.value}${e.suffix??""}`}const Tn=[],Mn={},st=e=>e;function Cn(e,n){if(!e||Array.isArray(e)&&e.length===0)return null;const r=Array.isArray(e)?e:[e];let i="";return i+=String(r[0].axisValueLabel),i+=r.map(({seriesName:s,value:l,data:a,marker:p})=>{const c=s?s+": ":"",g=te(n(Number(l))),h=a,d=`<div style="margin-left: 8px; display: inline">
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),u=require("react"),o=require("@mui/material"),J=require("react-intl"),j=require("../TablePaginationActions-DyJEKn3l.cjs"),mn=require("echarts-for-react"),Te=require("../SwatchSquare-C-QxZLYN.cjs"),ee=require("@mui/icons-material"),yn=require("../Alert-FLV5jJYV.cjs"),Me=require("../paletteUtils-DLQVT9qo.cjs");function Et(){let e=!1;return window.PointerEvent&&"maxTouchPoints"in navigator?navigator.maxTouchPoints>0&&(e=!0):(window.matchMedia&&window.matchMedia("(any-pointer:coarse)").matches||window.TouchEvent||"ontouchstart"in window)&&(e=!0),e}function te(e){return!e||typeof e!="object"?e:`${e.prefix??""}${e.value}${e.suffix??""}`}const vn=[],jn={},st=e=>e;function wn(e,n){if(!e||Array.isArray(e)&&e.length===0)return null;const i=Array.isArray(e)?e:[e];let r="";return r+=String(i[0].axisValueLabel),r+=i.map(({seriesName:s,value:a,data:l,marker:p})=>{const c=s?s+": ":"",g=te(n(Number(a))),h=l,d=`<div style="margin-left: 8px; display: inline">
2
2
  ${c}${g}${String((h==null?void 0:h.unit)||"")}
3
- </div>`;return`<div style="margin-top: 4px">${String(p)}${d}</div>`}).join(" "),i}function An({height:e,labels:n=Mn,yAxisData:r,selectedBars:i=Tn,series:s,colors:l,tooltip:a=!0,tooltipFormatter:p=Cn,xAxisFormatter:c=st,yAxisFormatter:g=st,onSelectedBarsChange:h,animation:d=!0,filterable:v=!0,stacked:f=!0,...y}){const m=o.useTheme(),x=u.useMemo(()=>(s??[]).map(k=>n[k]??k),[s,n]),S=u.useMemo(()=>Array.isArray(r[0])?r:[r],[r]),b=u.useMemo(()=>typeof l=="string"?[l]:Array.isArray(l)&&l.length?l:S.length<=1||x.length===1?[m.palette.secondary.main]:S.length===2||x.length===2?[m.palette.secondary.light,m.palette.secondary.dark]:Object.values(m.palette.qualitative.bold||{}),[l,m,S,x]);return{...y,tooltip:a,tooltipFormatter:p,xAxisFormatter:c,yAxisFormatter:g,onSelectedBarsChange:h,animation:d,filterable:v,stacked:f,labels:n,height:e??parseInt(m.spacing(22)),selectedBars:En(i),yAxisData:S,colors:b,series:x}}function En(e){return(e??[]).length?e.map(n=>Array.isArray(n)&&n.length===2?n:Array.isArray(n)?[...Array(2)].map((i,s)=>n[s]??0):[n,0]):[]}var Bn=function e(n,r){if(n===r)return!0;if(n&&r&&typeof n=="object"&&typeof r=="object"){if(n.constructor!==r.constructor)return!1;var i,s,l;if(Array.isArray(n)){if(i=n.length,i!=r.length)return!1;for(s=i;s--!==0;)if(!e(n[s],r[s]))return!1;return!0}if(n.constructor===RegExp)return n.source===r.source&&n.flags===r.flags;if(n.valueOf!==Object.prototype.valueOf)return n.valueOf()===r.valueOf();if(n.toString!==Object.prototype.toString)return n.toString()===r.toString();if(l=Object.keys(n),i=l.length,i!==Object.keys(r).length)return!1;for(s=i;s--!==0;)if(!Object.prototype.hasOwnProperty.call(r,l[s]))return!1;for(s=i;s--!==0;){var a=l[s];if(!e(n[a],r[a]))return!1}return!0}return n!==n&&r!==r};const xe=j.getDefaultExportFromCjs(Bn);class ye extends mn{componentDidUpdate(n){const{shouldSetOption:r}=this.props;if(typeof r=="function"&&!r(n,this.props))return;if(!xe(n.theme,this.props.theme)||!xe(n.opts,this.props.opts)){this.dispose(),this.renderNewEcharts();return}const i=this.getEchartsInstance();xe(n.onEvents,this.props.onEvents)||(this.offEvents(i,n.onEvents),this.bindEvents(i,this.props.onEvents));const s=["option","notMerge","lazyUpdate","showLoading","loadingOption"];xe(lt(this.props,s),lt(n,s))||this.updateEChartsOption(),(!xe(n.style,this.props.style)||!xe(n.className,this.props.className))&&this.resize()}updateEChartsOption(){const n=this.props.option,r=this.props.loadingOption||null,{lazyUpdate:i,showLoading:s}=this.props,l=this.getEchartsInstance();return l.setOption(n,{replaceMerge:["series"],lazyUpdate:i}),s?l.showLoading(r):l.hideLoading(),l}offEvents(n,r){if(r)for(const i in r)typeof i=="string"&&n.off(i)}}function lt(e,n){const r={};return n.forEach(i=>{r[i]=e[i]}),r}const _e=240,Pt=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"flex-end",justifyContent:"space-between",position:"relative",padding:e.spacing(0,2),"&::before":{content:'""',position:"absolute",top:0,right:0,left:0,bottom:0,backgroundSize:e.spacing(4,4),backgroundImage:`linear-gradient(to bottom, ${e.palette.grey[50]} 1px, transparent 1px)`,transform:"scaleY(-1)"}})),Lt=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"flex-end",justifyContent:"space-between",backgroundImage:`linear-gradient(${e.palette.grey[50]} 0.5px, transparent 0.5px, transparent calc(100% - 0.5px), ${e.palette.grey[50]} calc(100% - 0.5px)), linear-gradient(90deg, ${e.palette.grey[50]} 0.5px, transparent 0.5px, transparent calc(100% - 0.5px), ${e.palette.grey[50]} calc(100% - 0.5px))`,backgroundSize:"8.33% 20%",border:`0.5px solid ${e.palette.grey[50]}`})),je=o.styled(o.Skeleton)(({theme:e})=>({flex:1,maxWidth:e.spacing(12),"& + &":{marginLeft:e.spacing(1)}})),ne=o.styled(o.Skeleton)(({theme:e})=>({flex:1,maxWidth:e.spacing(8),"& + &":{marginLeft:"1px"}})),Pn=o.styled(o.Skeleton)(({theme:e})=>({backgroundColor:e.palette.common.white})),at=o.styled(o.Skeleton)(({theme:e})=>({backgroundColor:e.palette.grey[100]}));function Ln({height:e}){return t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{mb:2,children:t.jsx(o.Skeleton,{width:48,height:8})}),t.jsxs(Pt,{style:{height:e||_e},children:[t.jsx(je,{variant:"rectangular",height:"20%"}),t.jsx(je,{variant:"rectangular",height:"40%"}),t.jsx(je,{variant:"rectangular",height:"60%"}),t.jsx(je,{variant:"rectangular",height:"20%"}),t.jsx(je,{variant:"rectangular",height:"80%"})]})]})}function ce(e){const[n,r]=u.useState(!1),[i,s]=u.useState(!1);return u.useEffect(()=>{e&&!i&&(r(!0),s(!0)),e||r(!1)},[e,i]),{showSkeleton:n}}const Dn=Bt(),Nn=o.styled(o.Grid)(({theme:e})=>({marginBottom:e.spacing(2),flexDirection:"row",justifyContent:"space-between",alignItems:"center","& .MuiTypography-caption":{color:e.palette.text.secondary}})),$n=o.styled(o.Link)(({theme:e})=>({...e.typography.caption,cursor:"pointer"}));function On(e){const{yAxisData:n,xAxisData:r,series:i,selectedBars:s,onSelectedBarsChange:l,tooltip:a,tooltipFormatter:p,labels:c,colors:g,xAxisFormatter:h,yAxisFormatter:d,stacked:v,height:f,filterable:y,animation:m,isLoading:x}=An(e),S=i.length>1,b=o.useTheme(),k=Z.useIntl(),I=j.useImperativeIntl(k),{showSkeleton:w}=ce(!!x),C=u.useMemo(()=>({show:a,trigger:"axis",padding:[parseInt(b.spacing(.5)),parseInt(b.spacing(1))],borderWidth:0,textStyle:{...b.typography.caption,fontSize:11,color:b.palette.common.white},backgroundColor:b.palette.black[90],position:function(M,$,G,R,H){const U={top:0};return H.contentSize[0]<H.viewSize[0]-M[0]?U.left=M[0]:U.right=H.viewSize[0]-M[0],U},formatter:M=>p(M,d)}),[b,a,p,d]),A=u.useMemo(()=>r.map(M=>te(h(c[M]??String(M)))),[r,c,h]),D=u.useMemo(()=>({type:"category",axisLine:{show:!1},axisTick:{show:!1},axisLabel:{...b.typography.overlineDelicate,padding:[parseInt(b.spacing(.5)),0,0,0]},data:A}),[b,A]),B=u.useMemo(()=>{let M=[];return v?M=n.reduce(($,G)=>(G.forEach((R,H)=>$[H]=($[H]??0)+(R??Number.MIN_SAFE_INTEGER)),$),[]):M=n.flat().map($=>$??Number.MIN_SAFE_INTEGER),Math.max(...M)},[n,v]),P=u.useMemo(()=>({type:"value",axisLabel:{margin:0,verticalAlign:"bottom",padding:[0,0,parseInt(b.spacing(1.25)),0],show:!0,showMaxLabel:!0,showMinLabel:!1,inside:!0,color:M=>M>=B?b.palette.black[60]:"transparent",...b.typography.overlineDelicate,formatter:M=>te(d(M))},axisLine:{show:!1},axisTick:{show:!1},splitLine:{show:!0,onZero:!1,lineStyle:{color:b.palette.black[4]}}}),[b,B,d]),L=u.useMemo(()=>n.map((M,$)=>({type:"bar",name:i[$]??"",animation:m,barMaxWidth:100,data:M.map((G,R)=>{const H=s.some(([F,z=0])=>F===R&&z===$),U=!!s.length&&!H;return{value:G,...U&&{itemStyle:{color:b.palette.black[25]},disabled:!0}}}),...v&&{stack:"total"},...!Dn&&{emphasis:{focus:"series",itemStyle:{color:o.darken(g[$]??"#000",.25)}}}})),[m,g,i,n,s,v,b]),N=u.useMemo(()=>({grid:{left:A.length>=4?ct(String(A[0]),A.length):0,top:parseInt(b.spacing(2)),right:A.length>=4?ct(String(A[A.length-1]),A.length):0,bottom:0,containLabel:!0},axisPointer:{lineStyle:{color:b.palette.black[40]}},color:g,tooltip:C,xAxis:D,yAxis:P,series:L}),[A,b,g,C,D,P,L]),V=()=>{l&&l([],[])},_=M=>{M.key==="Enter"&&V()},T=u.useCallback(M=>{if(l){const $=[...s],{dataIndex:G,componentIndex:R}=M,H=$.findIndex(([F,z=0])=>G===F&&R===z);H===-1?$.push([G,R]):$.splice(H,1);const U=$.map(([F,z=0])=>({xAxis:r[F],serie:i[z],yAxis:n[z][F]}));l(S?$:$.map(F=>F[0]),U)}},[n,l,s,r,i,S]),O=u.useMemo(()=>y?{click:T}:{},[y,T]);return w?t.jsx(Ln,{height:f}):t.jsxs("div",{children:[l&&t.jsxs(Nn,{container:!0,children:[t.jsx(j.Typography,{variant:"caption",children:s.length>0?I.formatMessage({id:"c4r.widgets.bar.selectedItems"},{items:s.length}):I.formatMessage({id:"c4r.widgets.bar.all"})}),s&&s.length>0&&t.jsx($n,{onClick:()=>V(),onKeyDown:_,underline:"hover",tabIndex:0,children:I.formatMessage({id:"c4r.widgets.bar.clear"})})]}),!!N&&t.jsx(ye,{option:N,lazyUpdate:!0,notMerge:!0,onEvents:O,style:{height:f}})]})}function ct(e="",n=0){return n<=15&&e.length<=8?0:e.length*8.5/6}const ue="__rest__",me="Others";var pe=(e=>(e.RANKING="ranking",e.FIXED="fixed",e))(pe||{});const Dt=o.styled(o.Grid)(({theme:e})=>({maxHeight:e.spacing(40),overflow:"auto",padding:0})),Nt=o.styled(o.Grid,{shouldForwardProp:e=>e!=="selectable"&&e!=="name"&&e!=="unselected"})(({theme:e,selectable:n,name:r,unselected:i})=>({flexDirection:"row",maxWidth:"100%",padding:e.spacing(.5,.25),margin:0,"> .MuiGrid-item":{paddingTop:0,paddingLeft:0},"&:focus-visible":{outline:"none !important",boxShadow:`inset 0 0 0 2px ${e.palette.primary.main} !important`},...i&&{color:e.palette.text.disabled,".progressbar div":{backgroundColor:e.palette.text.disabled}},...r!==ue&&n&&{cursor:"pointer",flexWrap:"nowrap","&:hover .progressbar div":{backgroundColor:e.palette.secondary.dark}},...r===ue&&{cursor:"default",".progressbar div":{backgroundColor:e.palette.text.disabled}}})),dt=o.styled(o.Grid)(({theme:{spacing:e,palette:n}})=>({flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:e(1.5),paddingRight:e(1),"& .MuiTypography-caption":{color:n.text.secondary}})),Rn=o.styled(o.Grid)(({theme:e})=>({height:e.spacing(.5),width:"100%",margin:e.spacing(.5,0,.25,0),borderRadius:e.spacing(.5),backgroundColor:e.palette.action.disabledBackground,"& div":{width:0,height:"100%",borderRadius:e.spacing(.5),backgroundColor:e.palette.secondary.main,transition:`background-color ${e.transitions.easing.sharp} ${e.transitions.duration.shortest}ms,
4
- width ${e.transitions.easing.sharp} ${e.transitions.duration.complex}ms`}})),Fn=o.styled(o.Grid,{shouldForwardProp:e=>e!=="isSelectable"})(({theme:e,isSelectable:n})=>({...n&&{width:`calc(100% - ${e.spacing(4)})`}})),Wn=o.styled(j.Typography)(({theme:e})=>({fontWeight:e.typography.fontWeightBold,marginRight:e.spacing(2)})),Ae=o.styled(o.Link)(({theme:e})=>({...e.typography.caption,cursor:"pointer","& + hr":{margin:e.spacing(0,1)}})),_n=o.styled(o.Box)(({theme:e})=>({...e.typography.body2})),ut=o.styled(o.Button)(({theme:e})=>({position:"absolute",left:"-999px",top:"-1px",width:"1px",height:"1px",display:"inline-flex","&:focus-visible":{position:"static",width:"auto",height:"auto",marginTop:e.spacing(2)}})),Gn=o.styled(o.Skeleton)(({theme:e})=>({marginTop:e.spacing(1.25),marginBottom:e.spacing(1.75)})),Hn=e=>e%2===1,$t=()=>t.jsxs(t.Fragment,{children:[t.jsx(o.Skeleton,{width:48,height:8}),t.jsx(Dt,{container:!0,mt:3,children:[...Array(6)].map((e,n)=>t.jsxs(Nt,{container:!0,spacing:1,children:[t.jsxs(o.Grid,{container:!0,item:!0,direction:"row",justifyContent:"space-between",children:[t.jsx(o.Skeleton,{width:Hn(n)?72:48,height:8}),t.jsx(o.Skeleton,{width:48,height:8})]}),t.jsx(Gn,{height:4,width:"100%"})]},n))})]});function Ot(e){const n=u.useRef();return u.useEffect(()=>{n.current=e}),n.current}function Ke({start:e,end:n,duration:r,drawFrame:i,requestRef:s}){if(e===n&&!(e===0&&n===0))return;const a=n-e;let p=e;const c=a/(r/1e3*60),g=()=>{p+=c,i(Math.floor(p)),c>0&&p<n||c<0&&p>n?s.current=requestAnimationFrame(g):i(n)};s.current=requestAnimationFrame(g)}function zn({start:e,end:n,duration:r,drawFrame:i,requestRef:s}){if(e.length===n.length&&e.every((f,y)=>f.value===n[y].value))return;let a=n.map((f,y)=>e[y]&&e[y].name===f.name?{...f,value:e[y].value}:f),p=0;const c=a.map((f,y)=>n[y].value-f.value);if(c.every(f=>f===0)){i(n);return}const h=r/1e3*60,d=c.map(f=>f/h),v=()=>{p<h?(a=a.map((f,y)=>{const m=Math.floor(f.value+d[y]),x=y>0&&Math.floor(f.value+d[y-1]);return{...f,value:m===x?n[y].value:m}}),i(a),p++,s.current=requestAnimationFrame(v)):i(n)};s.current=requestAnimationFrame(v)}const Yn=[],Vn={},Un=e=>e,Ve=()=>{};function qn({data:e,formatter:n=Un,labels:r=Vn,maxItems:i=5,order:s=pe.RANKING,selectedCategories:l=Yn,onSelectedCategoriesChange:a=Ve,animation:p=!0,filterable:c=!0,searchable:g=!0,isLoading:h}){const[d,v]=u.useState([]),[f,y]=u.useState(1),[m,x]=u.useState(!1),[S,b]=u.useState(""),[k,I]=u.useState([]),[w,C]=u.useState([]),[A,D]=u.useState([]),B=u.useRef(null),P=u.useRef(),L=Ot(A),N=u.useRef([]),{showSkeleton:V}=ce(!!h),_=Z.useIntl(),T=j.useImperativeIntl(_);function O(E){return d.reduce((Y,K)=>(E.includes(K.name)&&Y.push(K.name),Y),[])}function M(E){if(E!==ue){let Y;l.includes(E)?Y=l.filter(K=>K!==E):Y=[...l,E],a&&a(Y)}}const $=()=>a([]),G=E=>{E.key==="Enter"&&$()},R=()=>{a([]),I([])},H=E=>{E.key==="Enter"&&R()},U=()=>{I(O(l))},F=E=>{E.key==="Enter"&&U()},z=()=>{const E=O(w);a([...E]),I([...E]),C([]),x(!1),b("")},Q=E=>{E.key==="Enter"&&z()},de=()=>{b(""),x(!1)},re=E=>{if(E!==ue){let Y;w.includes(E)?Y=w.filter(K=>K!==E):Y=[...w,E],C(Y)}},W=E=>{E.currentTarget.scrollIntoView()},q=E=>{b(E.currentTarget.value)},X=()=>{x(!0),C([...l])},J=u.useCallback(E=>{if(m)return S?E.filter(Y=>{var ee;if(!Y.name)return!1;const K=String(Y.name);return!!(K.toLowerCase().includes(S.toLowerCase())||(ee=r[K])!=null&&ee.toLowerCase().includes(S.toLowerCase()))}):E;if(k.length)return k.reduce((K,ee)=>{const ge=E.find(se=>se.name===ee);return K.push({name:ee,value:ge?ge.value:null}),K},[]);{const Y=E.slice(0,i);if(Y.length<E.length){const K=E.slice(i).reduce((ee,ge)=>(ge.value!==null&&ee.value!==null&&(ee.value+=ge.value),ee),{name:ue,value:0});return[...Y,K]}else return Y}},[k,r,i,S,m]),ie=u.useCallback(()=>{const E=k.length;return E?e.length-E:e.length-i},[e,i,k]),Ce=u.useCallback(E=>E===ue?`Others ${g?"":`(${ie()})`}`:r[String(E)]??String(E),[ie,r,g]),ve=u.useCallback(E=>E>=f?E!=null?"100%":0:`${(E||0)*100/f}%`,[f]);u.useEffect(()=>{l.length===0&&I([])},[l]),u.useEffect(()=>{if(e){if(s===pe.RANKING){const E=[...e].sort((K,ee)=>(ee.value??0)-(K.value??0)),Y=J(E);Y.length>0?y(Y[0].value??0):y(1),v(Y)}else if(s===pe.FIXED){y(Math.max(...e.map(Y=>Y.value??0)));const E=J(e);v(E)}}},[k,J,e,r,i,s,S,m]),u.useEffect(()=>{L&&(N.current=L)},[L]),u.useEffect(()=>{if(p)return zn({start:(N.current||[]).map(E=>({...E,value:E.value??0})),end:d.map(E=>({...E,value:E.value??0})),duration:500,drawFrame:E=>D(E),requestRef:B}),()=>{B.current&&cancelAnimationFrame(B.current)};D(d)},[p,d]),u.useEffect(()=>{m&&P.current&&P.current.focus()},[m,P]);function hn({data:E,onCategoryClick:Y}){const K=n(E.value??0),[ee,ge]=u.useState(!1),se=u.useRef(null),ze=()=>{var rt,it;const Ye=(((rt=se==null?void 0:se.current)==null?void 0:rt.scrollWidth)??0)>(((it=se==null?void 0:se.current)==null?void 0:it.clientWidth)??0);ge(Ye)};u.useEffect(()=>(ze(),window.addEventListener("resize",ze),()=>{window.removeEventListener("resize",ze)}),[]);const fn=Ye=>{Ye.key==="Enter"&&Y()},xn=!m&&l.length>0&&!l.includes(E.name);return t.jsxs(Nt,{container:!0,direction:"row",spacing:1,onClick:c?Y:Ve,onKeyDown:c?fn:Ve,selectable:c,unselected:xn,name:E.name===ue?ue:"",tabIndex:c?0:-1,children:[c&&m&&t.jsx(o.Grid,{item:!0,mr:1,children:t.jsx(o.Checkbox,{checked:w.includes(E.name),tabIndex:-1})}),t.jsxs(Fn,{container:!0,item:!0,xs:!0,isSelectable:m,children:[t.jsxs(o.Grid,{container:!0,item:!0,direction:"row",justifyContent:"space-between",wrap:"nowrap",children:[t.jsx(o.Tooltip,{title:Ce(E.name),disableHoverListener:!ee,children:t.jsx(Wn,{variant:"body2",noWrap:!0,ref:se,children:Ce(E.name)})}),typeof K=="object"&&K!==null?t.jsxs("span",{children:[K.prefix,K.value,K.suffix]}):t.jsx("span",{children:K})]}),t.jsx(Rn,{className:"progressbar",item:!0,children:t.jsx("div",{style:{width:ve(E.value??0)}})})]})]})}return(e==null?void 0:e.length)===0||V?t.jsx($t,{}):t.jsxs(_n,{children:[c&&d.length>0&&t.jsxs(dt,{container:!0,children:[t.jsx(j.Typography,{variant:"caption",children:l.length>0?T.formatMessage({id:"c4r.widgets.category.selectedItems"},{items:l.length}):T.formatMessage({id:"c4r.widgets.category.all"})}),m?t.jsx(Ae,{onClick:z,onKeyDown:Q,underline:"hover",tabIndex:0,"data-testid":"primaryApplyButton",children:T.formatMessage({id:"c4r.widgets.category.apply"})}):k.length>0?t.jsx(Ae,{onClick:R,onKeyDown:H,underline:"hover",tabIndex:0,children:T.formatMessage({id:"c4r.widgets.category.unlock"})}):l.length>0&&t.jsxs(o.Grid,{container:!0,direction:"row",justifyContent:"flex-end",item:!0,xs:!0,children:[t.jsx(Ae,{onClick:U,onKeyDown:F,underline:"hover",tabIndex:0,children:T.formatMessage({id:"c4r.widgets.category.lock"})}),t.jsx(o.Divider,{orientation:"vertical",flexItem:!0}),t.jsx(Ae,{onClick:$,onKeyDown:G,underline:"hover",tabIndex:0,children:T.formatMessage({id:"c4r.widgets.category.clear"})})]})]}),e.length>i&&m&&t.jsxs(dt,{container:!0,children:[t.jsx(o.TextField,{size:"small",sx:{mt:-.5},placeholder:T.formatMessage({id:"c4r.widgets.category.search"}),onChange:q,onFocus:W,InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",children:t.jsx(Te.Search,{})})},inputProps:{tabIndex:0,ref:P}}),t.jsx(ut,{size:"small",onClick:de,children:T.formatMessage({id:"c4r.widgets.category.cancel"})})]}),t.jsx(Dt,{container:!0,item:!0,children:A.length?A.map((E,Y)=>t.jsx(hn,{data:E,onCategoryClick:()=>m?re(E.name):M(E.name)},Y)):t.jsxs(o.Box,{children:[t.jsx(j.Typography,{variant:"body2",children:T.formatMessage({id:"c4r.widgets.category.noResults"})}),t.jsx(j.Typography,{component:"p",variant:"caption",mb:2,children:T.formatMessage({id:"c4r.widgets.category.noResultsMessage"},{searchValue:S})})]})}),m&&t.jsx(ut,{size:"small",onClick:z,children:T.formatMessage({id:"c4r.widgets.category.apply"})}),e.length>i&&g?m?t.jsx(o.Box,{mt:1.5,children:t.jsx(o.Button,{size:"small",color:"primary",onClick:de,"data-testid":"primaryCancelButton",children:T.formatMessage({id:"c4r.widgets.category.cancel"})})}):t.jsx(o.Box,{mt:1.5,children:t.jsx(o.Button,{size:"small",color:"primary",startIcon:t.jsx(Te.Search,{}),onClick:X,children:T.formatMessage({id:"c4r.widgets.category.searchInfo"},{elements:ie()})})}):null]})}const Rt=()=>t.jsx(o.Box,{pt:.5,children:t.jsx(o.Skeleton,{height:24,width:120})}),Kn=o.styled("span")(()=>({marginRight:"2px"})),Xn=o.styled("span")(()=>({marginLeft:"2px"})),Ee="-",Zn=e=>e;function Jn({data:e=Ee,formatter:n=Zn,animation:r=!0,isLoading:i=!1}){const[s,l]=u.useState(Ee),a=u.useRef(null),p=Ot(s),c=u.useRef(p),{showSkeleton:g}=ce(!!i);u.useEffect(()=>(typeof e=="number"&&r?Ke({start:c.current||0,end:e,duration:500,drawFrame:f=>l(f),requestRef:a}):typeof e=="object"&&r&&e&&c.current&&e.value!==null&&e.value!==void 0?Ke({start:Number(c.current.value),end:Number(e.value),duration:1e3,drawFrame:f=>l({value:f,prefix:e.prefix,suffix:e.suffix}),requestRef:a}):l(e??Ee),()=>{a.current&&cancelAnimationFrame(a.current)}),[r,e,l]);const h=n(s),d=typeof h=="object"&&h!==null,v=h===Ee;return g?t.jsx(Rt,{}):d?t.jsxs(j.Typography,{variant:"h5",component:"div",weight:"medium",children:[t.jsx(Kn,{children:h.prefix}),h.value,t.jsx(Xn,{children:h.suffix})]}):t.jsx(j.Typography,{variant:"h5",component:"div",weight:"medium",color:v?"text.disabled":"default",whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden",children:h})}const pt={};let we=null;function Qn({data:e,filterable:n,selectedBars:r,onSelectedBarsChange:i,echartsInstance:s}){const l=o.useTheme(),[a,p]=u.useState([]),c=u.useMemo(()=>s==null?void 0:s.getZr(),[s]);u.useEffect(()=>{function h(v){if(s){const[f]=s.convertFromPixel({seriesIndex:0},[v.offsetX,v.offsetY]);we=f??null}}function d(v){if(s&&we!==null){const[f]=s.convertFromPixel({seriesIndex:0},[v.offsetX,v.offsetY]);p(we===f?[]:[we,f].sort((y,m)=>y-m))}}if(s&&n){const v=Ue(c,"mousedown",h),f=Ue(c,"mousemove",d);return()=>{v==null||v(),f==null||f()}}},[c,s,n]),u.useEffect(()=>{function h(){if(a.length===2&&i){const d=e.reduce((v,f,y)=>((a[0]>=f[0]&&a[0]<=f[1]||a[1]>=f[0]&&a[1]<=f[1]||a[0]<=f[0]&&a[1]>=f[1])&&v.push(y),v),[]);i(e.length===d.length?[]:d)}p([]),we=null}if(s&&n)return Ue(c,"mouseup",h)},[c,s,a,e,i,n]);const g=u.useCallback(h=>{if(i){const d=new Set(r);d.has(h.dataIndex)?d.delete(h.dataIndex):d.add(h.dataIndex),i(d.size===e.length?[]:Array.from(d))}},[i,r,e.length]);return{markAreaOptions:a.length===2&&{data:[[{coord:[a[0]]},{coord:[a[1]]}]],itemStyle:{color:l.palette.primary.main,opacity:.2}},onEvents:n?{click:g}:{}}}function Ue(e,n,r){if(e!=null&&e.handler)return pt[n]=r,e.on(n,r),()=>{pt[n]&&(e!=null&&e.handler)&&e.off(n,r)}}function eo({height:e}){return t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{mb:2,children:t.jsx(o.Skeleton,{width:48,height:8})}),t.jsxs(Lt,{style:{height:e??_e},children:[t.jsx(ne,{variant:"rectangular",height:"20%"}),t.jsx(ne,{variant:"rectangular",height:"40%"}),t.jsx(ne,{variant:"rectangular",height:"60%"}),t.jsx(ne,{variant:"rectangular",height:"20%"}),t.jsx(ne,{variant:"rectangular",height:"80%"}),t.jsx(ne,{variant:"rectangular",height:"50%"}),t.jsx(ne,{variant:"rectangular",height:"20%"}),t.jsx(ne,{variant:"rectangular",height:"40%"}),t.jsx(ne,{variant:"rectangular",height:"60%"}),t.jsx(ne,{variant:"rectangular",height:"20%"}),t.jsx(ne,{variant:"rectangular",height:"80%"}),t.jsx(ne,{variant:"rectangular",height:"50%"})]})]})}const to=Bt(),no=o.styled(o.Grid)(({theme:e})=>({marginBottom:e.spacing(2),flexDirection:"row",justifyContent:"space-between",alignItems:"center","& .MuiTypography-caption":{color:e.palette.text.secondary}})),oo=o.styled(o.Link)(({theme:e})=>({...e.typography.caption,cursor:"pointer"})),ro=[],io=()=>{},$e=e=>e;function so(e,n=$e,r=$e){if(!e)return null;if(Array.isArray(e)&&e.length===0)return;const i=Array.isArray(e)?e[0].marker:e.marker,s=Array.isArray(e)?e[0].data:e.data;if((s==null?void 0:s.value)===void 0)return;const[l,a,p]=s.value,c=te(n(l)),g=te(n(a)),h=te(r(p)),d=`${c} <span style="vertical-align: 1px;">—</span> ${g}`,v=`<div style="margin-left: 8px; display: inline">${h}</div>`;return`${d} <div style="margin-top: 4px">${String(i)}${v}</div>`}function lo({data:e,ticks:n,min:r,max:i,xAxisFormatter:s=$e,yAxisFormatter:l=$e,yAxisType:a="dense",selectedBars:p=ro,onSelectedBarsChange:c=io,tooltip:g=!0,tooltipFormatter:h=so,animation:d=!0,filterable:v=!0,height:f=200,isLoading:y}){const m=Z.useIntl(),x=o.useTheme(),S=j.useImperativeIntl(m),{showSkeleton:b}=ce(!!y),k=!!v&&!!c,[I,w]=u.useState(),C=M=>w(M),A=u.useMemo(()=>uo(e,n,r,i),[e,n,r,i]),{onEvents:D,markAreaOptions:B}=Qn({data:A,filterable:k,selectedBars:p,onSelectedBarsChange:c,echartsInstance:I}),P=u.useMemo(()=>({show:g,trigger:"item",padding:[j.SPACING*.5,j.SPACING],borderWidth:0,textStyle:{...x.typography.caption,fontSize:11,color:x.palette.common.white},backgroundColor:x.palette.black[90],confine:!0,position:"top",formatter(M){return h(M,s,l)}}),[x,g,h,s,l]),L=u.useMemo(()=>({min:r,max:i,interval:(i-r)/A.length,axisLine:{show:!1},splitLine:{show:!0,lineStyle:{color:x.palette.black[4]}},axisTick:{show:!1},axisLabel:{showMinLabel:!0,showMaxLabel:!0,...x.typography.overlineDelicate,hideOverlap:!0,padding:[j.SPACING*.5,j.SPACING*.5,0,j.SPACING*.5],formatter:M=>{const $=te(s(M));return M===r?ao($):M===i?co($):$},color:x.palette.black[60]}}),[r,i,A.length,x,s]),N=u.useMemo(()=>{const M={margin:0,verticalAlign:"bottom",padding:[0,0,j.SPACING*1.25,0],inside:!0,color:R=>{const H=Math.max(...e.map(F=>F??Number.MIN_SAFE_INTEGER))||1;let U="transparent";return R>=H&&(U=x.palette.black[60]),U},...x.typography.overlineDelicate,formatter:R=>te(l(R))},$={verticalAlign:"middle",padding:[0,0,0,j.SPACING*.5],color:x.palette.black[60]},G=a==="dense"?M:$;return{type:"value",axisLine:{show:!1},splitLine:{show:!0,lineStyle:{color:x.palette.black[4]}},axisTick:{show:!1},axisLabel:{show:!0,showMaxLabel:!0,showMinLabel:!1,...G,...x.typography.overlineDelicate,formatter:R=>te(l(R))}}},[x.palette.black,x.typography.overlineDelicate,e,l,a]),V=u.useMemo(()=>{const M=r===i&&A.filter(R=>R[2]!==0).length===1,G=(M?[A[0],A[A.length-1]]:A).map((R,H)=>{const F=p.length&&!p.includes(H)?x.palette.black[25]:x.palette.secondary.main;return{value:R,itemStyle:{color:F}}});return{type:"custom",cursor:"pointer",markArea:B,renderItem:function(R,H){const U=R.dataIndex===A.length-1,F=R.dataIndex===0,z=G[R.dataIndex].itemStyle.color,Q=H.value(0),de=H.value(1),re=H.value(2),[W,q]=H.coord([Q,re]),[X,J]=H.size([de-Q,re]);return{type:"rect",shape:{x:M?W/10:W+(F?0:1),y:q,width:M?W-W/10:X-(U?0:1),height:J},style:{fill:z},...!to&&{emphasis:{style:{fill:o.darken(z,.25)}}}}},encode:{x:[0,1],y:2,tooltip:[0,1,2]},data:G,animation:d}},[r,i,A,B,x.palette.black,x.palette.secondary.main,p,d]),_=u.useMemo(()=>({grid:{left:j.SPACING*.1,right:j.SPACING*.1,top:j.SPACING*2,bottom:j.SPACING*.5,containLabel:!0},tooltip:P,xAxis:L,yAxis:N,series:[V]}),[P,L,N,V]),T=p.reduce((M,$)=>M+=e[$]??0,0),O=M=>{M.key==="Enter"&&c([])};return b?t.jsx(eo,{height:f}):t.jsxs("div",{children:[k&&t.jsxs(no,{container:!0,children:[t.jsx(j.Typography,{variant:"caption",weight:"strong",children:p.length>0?S.formatMessage({id:"c4r.widgets.histogram.selectedItems"},{items:te(l(T))}):S.formatMessage({id:"c4r.widgets.histogram.all"})}),p.length>0&&t.jsx(oo,{onClick:()=>c([]),onKeyDown:O,underline:"hover",tabIndex:0,children:S.formatMessage({id:"c4r.widgets.histogram.clear"})})]}),t.jsx(ye,{option:_,onEvents:D,lazyUpdate:!0,onChartReady:C,style:{maxHeight:f}})]})}function ao(e){return`${Array(String(e).length).fill(" ").join("")}${e}`}function co(e){const n=Array(String(e).length).fill(" ").join("");return`${e}${n}`}function uo(e,n,r,i){return e.map((s,l)=>[l===0?r:n[l-1],l===e.length-1?i:n[l],s])}function po(e,n,r,i){const s=o.useTheme(),l=u.useMemo(()=>n===pe.RANKING?e.slice().sort((c,g)=>(g.value??0)-(c.value??0)):e,[e,n]),a=u.useMemo(()=>{const c=[];let g=0;for(const h of l)c.length<r?c.push({...h}):g+=h.value??0;return g>0&&c.push({name:me,value:g,emphasis:{scale:!1}}),c},[r,l]);return u.useMemo(()=>{const c=s.palette.common.white;return a.map((g,h)=>{let d=c;if(i.length){const f=i[h%i.length];f&&(d=f)}else{const y=s.palette.qualitative.bold[h];y&&(d=y)}const v=g;return v.color=d,v})},[a,i,s])}const go=o.styled(o.Box)(({theme:e})=>({zIndex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",paddingBottom:e.spacing(1)})),ho=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1),maxWidth:"140px",textTransform:"uppercase"})),fo=o.styled(o.Box)(({theme:e})=>({display:"inline-block",borderRadius:e.spacing(.5),width:e.spacing(1),minWidth:e.spacing(1),height:e.spacing(1)}));function xo({data:e,selectedCategories:n,formatter:r}){const[i,s]=u.useState(),l=u.useMemo(()=>{if(!e||e.length===0)return null;let g;n.length>0?g=e.filter(y=>n.includes(y.name)):g=e;const h=mo(g),d=g.find(y=>y===h);if(!d)return null;let v=0;for(const y of e)v+=y.value??0;const f=yo(d.value??0,v,r);return{...d,percentage:f}},[e,n,r]);u.useEffect(()=>{l&&s(l)},[l,s]);const{name:a,percentage:p,color:c}=i??{};return i?t.jsxs(go,{children:[t.jsx(j.Typography,{variant:"h5",children:p}),t.jsxs(ho,{children:[t.jsx(fo,{bgcolor:c,component:"span"}),t.jsx(j.Typography,{component:"span",variant:"body2",noWrap:!0,children:a})]})]}):null}function mo(e){const n=e.filter(r=>r.name!==me);return n.length===0?e[0]:n.reduce((r,i)=>(i.value??0)>(r.value??0)?i:r)}function yo(e,n,r){let i=0;return n!==0&&(i=e/n*100),r?r(i):`${i}%`}const gt=32,vo=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",marginTop:e.spacing(.5)})),jo=o.styled("div")(()=>({display:"flex",alignItems:"center",justifyContent:"center",position:"relative"})),wo=o.styled(Pn)(()=>({position:"absolute",zIndex:1})),bo=o.styled("div")(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",gap:e.spacing(1),position:"absolute",zIndex:2})),So=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(2),height:e.spacing(5)})),ko=o.styled("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1.5)}));function Ft({height:e}){const n=parseInt(String(e),10)||_e,r=n-gt,i=r-gt;return t.jsxs(o.Box,{mt:.5,children:[t.jsx(o.Skeleton,{height:8,width:64}),t.jsx(vo,{height:n,children:t.jsxs(jo,{children:[t.jsx(o.Skeleton,{variant:"circular",width:r,height:r}),t.jsx(wo,{variant:"circular",width:i,height:i}),t.jsxs(bo,{children:[t.jsx(o.Skeleton,{height:24,width:72}),t.jsx(o.Skeleton,{height:8,width:48})]})]})}),t.jsx(So,{children:[...Array(2)].map((s,l)=>t.jsxs(ko,{children:[t.jsx(o.Skeleton,{variant:"circular",width:8,height:8}),t.jsx(o.Skeleton,{width:48,height:8})]},l))})]})}const Io=o.styled(o.Box)(({theme:e})=>({position:"relative",padding:e.spacing(1.25,1,0,1),width:"100%"})),To=o.styled(o.Box)(({theme:e})=>({position:"relative",display:"flex",flexDirection:"row",overflowX:"hidden",gap:e.spacing(2),padding:e.spacing(.5),margin:e.spacing(-.5)})),Mo=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",gap:e.spacing(1),alignItems:"center",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:"pointer"})),Co=o.styled(o.Box)(({theme:e})=>({display:"inline-block",position:"absolute",left:e.spacing(-2),top:e.spacing(1),bottom:e.spacing(1),zIndex:1,width:e.spacing(2.5),background:`linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, ${e.palette.background.paper} 100%)`})),Ao=o.styled(o.Box)(({theme:e})=>({position:"absolute",padding:e.spacing(.25,1),top:e.spacing(0),right:0,background:e.palette.background.paper})),Eo=o.styled(o.Box,{shouldForwardProp:e=>e!=="color"})(({theme:e,color:n})=>{const r=e.spacing(1);return{backgroundColor:n,borderRadius:"50%",width:r,height:r}});function Wt({series:e,selectedCategories:n,onCategoryClick:r}){var k,I;const i=o.useTheme(),[s,l]=u.useState(!1),[a,p]=u.useState(0),[c,g]=u.useState(void 0),h=u.useRef(null),d=u.useRef(null),v=u.useRef(null),f=Z.useIntl(),y=j.useImperativeIntl(f);function m(){p(a+1)}function x(){p(Math.max(a-1))}function S(w,C){w.key==="Enter"&&(r==null||r(C))}const b=u.useCallback(()=>{var C,A,D;const w=!!d.current&&d.current.scrollWidth>d.current.clientWidth;l(w),g(w&&d.current?(((C=h.current)==null?void 0:C.clientWidth)??0)-(((A=v.current)==null?void 0:A.clientWidth)??70):(((D=h.current)==null?void 0:D.clientWidth)??0)-12||500)},[h,d,v]);return u.useEffect(()=>{b()},[d,(k=d.current)==null?void 0:k.scrollWidth,(I=d.current)==null?void 0:I.clientWidth,b,a]),u.useEffect(()=>{if(typeof ResizeObserver>"u")return;let w;return h.current&&(w=new ResizeObserver(()=>{b()}),w.observe(h.current)),()=>{w==null||w.disconnect()}},[h,b]),t.jsxs(Io,{ref:h,children:[t.jsx(To,{ref:d,style:{maxWidth:`${c}px`},children:e.map((w,C)=>{if(C<a)return null;const A=n.length===0||n.includes(w.name);return t.jsxs(Mo,{tabIndex:0,onClick:r?()=>r(w.name):void 0,onKeyDown:r?D=>S(D,w.name):void 0,style:{pointerEvents:!r||w.name==="Others"?"none":void 0},children:[t.jsx(Eo,{color:A?w.color:i.palette.text.disabled}),t.jsx(j.Typography,{variant:"overline",color:A?void 0:"text.disabled",children:w.name})]},C)})}),(s||a>0)&&t.jsxs(Ao,{ref:v,children:[t.jsx(Co,{}),t.jsx(o.Tooltip,{title:y.formatMessage({id:"c4r.widgets.chartLegend.next"}),children:t.jsx(o.IconButton,{size:"small",disabled:a===0,onClick:x,children:t.jsx(fe.ChevronLeft,{})})}),t.jsx(o.Tooltip,{title:y.formatMessage({id:"c4r.widgets.chartLegend.prev"}),children:t.jsx(o.IconButton,{size:"small",disabled:!s,onClick:m,children:t.jsx(fe.ChevronRight,{})})})]})]})}const Xe="232px",Bo=o.styled(o.Grid)(({theme:e})=>({flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:e.spacing(.5)})),Po=o.styled(o.Box,{shouldForwardProp:e=>e!=="height"&&e!=="width"})(({height:e,width:n})=>({position:"relative",margin:"0 auto",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:n||"100%",height:e||"100%"})),Lo=o.styled(ye)(()=>({position:"absolute",top:0,right:0,left:0,bottom:0})),ht=[],Do={},No=e=>e;function $o({name:e,data:n,formatter:r=No,tooltipFormatter:i=Oo,percentFormatter:s,height:l=Xe,width:a=Xe,labels:p=Do,colors:c=ht,animation:g=!0,filterable:h=!0,selectedCategories:d=ht,onSelectedCategoriesChange:v,isLoading:f,maxItems:y=11,order:m=pe.RANKING}){const x=o.useTheme(),S=po(n,m,y,c),{showSkeleton:b}=ce(!!f),k=Z.useIntl(),I=j.useImperativeIntl(k),w=u.useMemo(()=>s||(_=>`${k.formatNumber(_,{maximumFractionDigits:2,minimumFractionDigits:2})}%`),[k,s]),C=u.useMemo(()=>{let _;return i&&(_=T=>i(T,r,w)),{padding:[j.SPACING*.5,j.SPACING],backgroundColor:x.palette.black[90],borderColor:"transparent",textStyle:{color:x.palette.common.white},confine:!0,formatter:_}},[x.palette.black,x.palette.common.white,i,r,w]),A=u.useMemo(()=>[{type:"pie",name:e,animation:g,data:S.map(_=>{const T={..._},O=(d==null?void 0:d.length)&&!d.includes(T.name);return p!=null&&p[T.name]&&(T.name=p[T.name]),O?{...T,disabled:!0,itemStyle:{color:x.palette.black[25]}}:{...T,itemStyle:{color:T.color}}}),radius:["74%","90%"],selectedOffset:0,bottom:j.SPACING*1.5,label:{show:!1},emphasis:{focus:"series",scaleSize:5},itemStyle:{borderColor:x.palette.background.paper,borderWidth:1}}],[e,g,S,p,d,x]),D=u.useMemo(()=>({grid:{left:0,top:0,right:0,bottom:0},tooltip:C,legend:{show:!1},series:A}),[C,A]),B=u.useCallback(_=>{if(v){const T=[...d],{name:O}=S[_.dataIndex];if(O===me)return;const M=T.indexOf(O);M===-1?T.push(O):T.splice(M,1),v(T)}},[S,v,d]),P=u.useCallback(_=>{if(v){const T=[...d],O=T.indexOf(_);O===-1?T.push(_):T.splice(O,1),v(T)}},[v,d]),L={...h&&{click:B}},N=()=>{v==null||v([])},V=_=>{_.key==="Enter"&&N()};return b?t.jsx(Ft,{height:l}):t.jsxs(t.Fragment,{children:[h&&t.jsxs(Bo,{container:!0,children:[t.jsx(j.Typography,{variant:"caption",color:"textSecondary",children:d.length?I.formatMessage({id:"c4r.widgets.pie.selectedItems"},{items:d.length}):I.formatMessage({id:"c4r.widgets.pie.allSelected"})}),d.length>0&&t.jsx(o.Link,{variant:"caption",onClick:N,onKeyDown:V,tabIndex:0,children:I.formatMessage({id:"c4r.widgets.pie.clear"})})]}),t.jsxs(Po,{height:l,width:a,children:[t.jsx(xo,{data:S,selectedCategories:d,formatter:w}),t.jsx(Lo,{option:D,onEvents:L,lazyUpdate:!0,style:{height:l,width:a}})]}),S.length>0&&t.jsx(Wt,{series:S,selectedCategories:d,onCategoryClick:v&&P})]})}function Oo(e,n,r){var c;const i=Array.isArray(e)?e[0]:e;if(!i)return null;const s=te(n(i.value)),l=r(i.percent)||`${i.percent}%`,p=`display:inline-block;border-radius:4px;width:8px;height:8px;background-color:${((c=i.data)==null?void 0:c.color)||i.textStyle.color}`;return`
5
- <div style="white-space:normal;"><p style="max-width:${Xe};font-size:11px;font-weight:500;line-height:1.454;text-transform:uppercase;margin:0 0 4px 0;">${i.name}</p>
6
- <p style="display:flex;align-items:center;font-size: 11px;font-weight:500;line-height:1.454;margin:0;"><span style="${p}"></span> <span style="margin:0 4px;font-weight:400;">${s}</span> (${l})</p></div>
7
- `.trim()}const Ro=o.styled(o.Grid)(({theme:e})=>({position:"relative",alignItems:"center",height:e.spacing(4)})),Fo=o.styled(o.Grid)(({theme:e})=>({position:"absolute",zIndex:1,padding:e.spacing(0,3)}));function Wo(){return t.jsxs(o.Grid,{container:!0,children:[t.jsxs(Ro,{container:!0,item:!0,children:[t.jsxs(Fo,{container:!0,item:!0,justifyContent:"space-between",children:[t.jsx(at,{variant:"circular",width:12,height:12}),t.jsx(at,{variant:"circular",width:12,height:12})]}),t.jsx(o.Skeleton,{height:2,width:"100%"})]}),t.jsxs(o.Grid,{container:!0,item:!0,justifyContent:"space-between",children:[t.jsx(o.Skeleton,{width:56,height:32}),t.jsx(o.Skeleton,{width:56,height:32})]})]})}const _o=o.styled(o.Box)(()=>({position:"relative"})),Go=o.styled(o.Box)(({theme:{spacing:e}})=>({display:"flex",flexDirection:"row-reverse",height:e(1.5)})),Ho=o.styled(o.Link)(()=>({cursor:"pointer"})),ft=o.styled(o.TextField)(({theme:{spacing:e}})=>({maxWidth:e(9),margin:0,"& fieldset":{borderWidth:1},"& input":{"&[type=number]":{appearance:"textfield"},"&::-webkit-outer-spin-button":{appearance:"none",margin:0},"&::-webkit-inner-spin-button":{appearance:"none",margin:0}}})),zo=o.styled(o.Slider)(({theme:{palette:e}})=>({"& .MuiSlider-rail":{color:e.text.hint}})),Yo=o.styled(o.Slider)(({theme:{palette:e,spacing:n}})=>({pointerEvents:"none",position:"absolute",zIndex:1,left:0,right:0,"& .MuiSlider-rail":{display:"none"},"& .MuiSlider-thumb":{display:"none"},"& .MuiSlider-track":{color:e.primary.main,opacity:.38},"& .MuiSlider-mark, & .MuiSlider-markActive":{backgroundColor:e.primary.main,opacity:.38,height:n(1),width:n(.25),top:"50%",transform:"translateY(-50%)"}}));function Vo({data:e,min:n,max:r,limits:i,onSelectedRangeChange:s,isLoading:l}){const[a,p]=u.useState([n,r]),[c,g]=u.useState([n,r]),h=Z.useIntl(),d=j.useImperativeIntl(h),{showSkeleton:v}=ce(!!l),f=u.useMemo(()=>{if(!i||i.length!==2)return;if(i[0]===i[1])return[{value:i[0]}];const w=[{value:Math.max(i[0],n)},{value:Math.min(i[1],r)}];if(!(w[0].value>w[1].value))return w},[i,r,n]),y=u.useMemo(()=>s?o.debounce(s,250):null,[s]),m=w=>{g([...w]),p([...w]),y&&y([...w])};function x(w,C){const A=w.target.value===""?"":Number(w.target.value);C===0&&g([A,c[1]]),C===1&&g([c[0],A])}const S=n!==c[0]||r!==c[1];u.useEffect(()=>{e&&(g([...e]),p([...e]))},[e]);function b(w){let C=c[w];C===""&&(C=a[w]),C>r&&(C=r),C<n&&(C=n);const A=w===0?[C,c[1]]:[c[0],C];m(A.sort((D,B)=>D-B))}const k=()=>{m([n,r])};function I(w){w.key==="Enter"&&k()}return v?t.jsx(Wo,{}):t.jsxs(_o,{children:[t.jsx(Go,{children:S&&t.jsx(j.Typography,{variant:"caption",color:"primary",children:t.jsx(Ho,{onClick:k,onKeyDown:I,tabIndex:0,component:"button",underline:"hover",children:d.formatMessage({id:"c4r.widgets.range.clear"})})})}),t.jsxs(o.Box,{children:[t.jsx(zo,{getAriaLabel:w=>w===0?d.formatMessage({id:"c4r.widgets.range.minValue"}):d.formatMessage({id:"c4r.widgets.range.maxValue"}),value:a,min:n,max:r,onChange:(w,C)=>m(C)}),i&&i.length===2&&t.jsx(Yo,{getAriaLabel:w=>w===0?d.formatMessage({id:"c4r.widgets.range.minLimit"}):d.formatMessage({id:"c4r.widgets.range.maxLimit"}),value:i,min:n,max:r,marks:f})]}),t.jsxs(o.Box,{display:"flex",justifyContent:"space-between",mb:1,children:[t.jsx(ft,{value:c[0],size:"small",onChange:w=>x(w,0),onBlur:()=>b(0),inputProps:{min:n,max:r,type:"number","aria-label":d.formatMessage({id:"c4r.widgets.range.minValue"})}}),t.jsx(ft,{value:c[1],size:"small",onChange:w=>x(w,1),onBlur:()=>b(1),inputProps:{min:n,max:r,type:"number","aria-label":d.formatMessage({id:"c4r.widgets.range.maxValue"})}})]})]})}const Uo=o.styled(Lt)(({theme:e})=>({flexDirection:"column",alignItems:"center",justifyContent:"center",marginLeft:e.spacing(4),containerType:"inline-size",[`@container (max-width: ${j.BREAKPOINTS.XS}px)`]:{" > div":{maxWidth:"75%"}}})),qo=o.styled(o.Box)(()=>({position:"relative",display:"flex",justifyContent:"space-between",width:"80%",maxWidth:"50%"}));function Ko({height:e}){function n(){return Math.floor(Math.random()*5)}return t.jsxs(o.Box,{height:e??_e,children:[t.jsx(o.Box,{mb:4,children:t.jsx(o.Skeleton,{width:48,height:8})}),t.jsx(Uo,{height:"80%",children:[...Array(3)].map((r,i)=>t.jsx(qo,{ml:i*3,children:[...Array(4)].map((s,l)=>t.jsx(o.Box,{mt:n(),ml:n(),children:t.jsx(o.Skeleton,{variant:"circular",width:12,height:12})},l))},i))})]})}function Xo(e,n){var c;const r=Array.isArray(e.tooltip)?e.tooltip[0]:e.tooltip,i=Array.isArray(n.tooltip)?n.tooltip[0]:n.tooltip,s=r==null?void 0:r.formatter,l=i==null?void 0:i.formatter,a=(c=e.series[0])==null?void 0:c.data,p=n.series[0].data;return s!==l?!1:a&&p&&a.length===p.length?!p.some(({value:g},h)=>{var d;return g!==((d=a[h])==null?void 0:d.value)}):!1}function Zo({tooltipFormatter:e,xAxisFormatter:n=Oe,yAxisFormatter:r=Oe},i){return{grid:{top:10,left:5,bottom:10,right:15,containLabel:!0},tooltip:{padding:[j.SPACING*.5,j.SPACING],textStyle:{...i.typography.caption,fontSize:11,color:i.palette.common.white},backgroundColor:i.palette.black[90],...e?{formatter:e}:{}},color:[i.palette.secondary.main],xAxis:{axisLabel:{...i.typography.overlineDelicate,padding:[j.SPACING*.5,0,0,0],formatter:s=>te(n(s))}},yAxis:{axisLabel:{...i.typography.overlineDelicate,formatter:s=>te(r(s))}}}}function Jo({name:e,data:n,animation:r}){return[{type:"scatter",name:e,data:n,animation:r}]}const Qo=u.memo(ye,(e,n)=>Xo(e.option,n.option)),xt=225,er=[],Oe=e=>e;function tr({name:e=null,data:n=er,animation:r=!0,xAxisFormatter:i=Oe,yAxisFormatter:s=Oe,tooltipFormatter:l=nr,isLoading:a}){const p=o.useTheme(),c=u.useRef(),[g,h]=u.useState({series:[]}),{showSkeleton:d}=ce(!!a);return u.useEffect(()=>{const v=Zo({xAxisFormatter:i,yAxisFormatter:s,tooltipFormatter:l},p),f=Jo({name:e,data:n||[],animation:r});h({...v,series:f})},[n,e,r,p,i,s,l]),d?t.jsx(Ko,{height:xt}):t.jsx(Qo,{ref:c,option:g,lazyUpdate:!0,style:{height:xt}})}function nr(e){const n=Array.isArray(e)?e[0]:e,r=(n==null?void 0:n.value)||[];return`[${r[0]}, ${r[1]})`}function Be({width:e,rows:n=4,index:r=0}){function i(s){const l=[72,48,96,32,64],a=s%l.length;return l[a]}return[...Array(n)].map((s,l)=>t.jsx(o.TableCell,{children:t.jsx(o.Skeleton,{width:e??i(r),height:8})},l))}const or=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:e.spacing(2),margin:0,padding:e.spacing(2,1)})),rr=o.styled(o.TableContainer)(()=>({overflow:"hidden"}));function ir({style:e,dense:n,pagination:r,rowsPerPage:i}){return t.jsxs(t.Fragment,{children:[t.jsx(rr,{style:e,children:t.jsxs(o.Table,{"aria-label":"skeleton table",size:n?"small":"medium",children:[t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{children:[t.jsx(Be,{rows:1,width:8}),t.jsx(Be,{width:56})]})}),t.jsx(o.TableBody,{children:[...Array(Math.min(10,i??10))].map((s,l)=>t.jsxs(o.TableRow,{children:[t.jsx(Be,{rows:1,width:8}),t.jsx(Be,{index:l})]},l))})]})}),r&&t.jsxs(or,{children:[t.jsx(o.Skeleton,{width:56,height:8}),t.jsx(o.Box,{mr:1,children:t.jsx(o.Skeleton,{width:52,height:16})}),t.jsx(o.Skeleton,{width:60,height:8}),t.jsx(o.Skeleton,{width:16,height:16}),t.jsx(o.Skeleton,{width:16,height:16})]})]})}const sr=o.styled(o.TableSortLabel)(({theme:e})=>({...e.typography.caption,color:e.palette.text.secondary,whiteSpace:"nowrap"})),lr=o.styled(o.TableRow)(({theme:e})=>({maxHeight:e.spacing(6.5),transition:"background-color 0.25s ease","&.MuiTableRow-hover:hover":{cursor:"pointer",backgroundColor:e.palette.background.default}})),ar=o.styled(o.TableCell)(()=>({overflow:"hidden","& p":{maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}})),cr=o.styled(o.TablePagination)(({theme:e})=>({height:e.spacing(6),overflowX:"auto",overflowY:"hidden"})),dr=10,ur=[5,10,25],be=()=>{};function pr({columns:e,rows:n,sorting:r=!1,sortBy:i,sortDirection:s="asc",onSetSortBy:l=be,onSetSortDirection:a=be,pagination:p=!1,totalCount:c,page:g,onSetPage:h=be,rowsPerPage:d=dr,rowsPerPageOptions:v=ur,onSetRowsPerPage:f=be,onRowClick:y=be,onRowMouseEnter:m,onRowMouseLeave:x,height:S,dense:b=!1,isLoading:k,lastPageTooltip:I}){var _;const w=u.useRef(null),C=Z.useIntl(),A=j.useImperativeIntl(C),{showSkeleton:D}=ce(!!k);function B({from:T,to:O,count:M}){return A.formatMessage({id:"c4r.widgets.table.of"},{from:T,to:O,count:M})}function P(T){a(i===T&&s==="asc"?"desc":"asc"),l(T)}function L(T,O){h(O)}function N(T){f(parseInt(T.target.value,10)),h(0)}const V={height:void 0};if(S){const T=Math.max(((_=w==null?void 0:w.current)==null?void 0:_.clientHeight)??0,p?j.SPACING*6:0);V.height=`calc(${S} - ${T}px)`}return D?t.jsx(ir,{rowsPerPage:d,style:V,dense:b,pagination:p}):t.jsxs(t.Fragment,{children:[t.jsx(o.TableContainer,{style:V,children:t.jsxs(o.Table,{stickyHeader:!0,size:b?"small":"medium",children:[t.jsx(gr,{columns:e,sorting:r,sortBy:i,sortDirection:s,onSort:P}),t.jsx(hr,{columns:e,rows:n,onRowMouseEnter:m,onRowMouseLeave:x,onRowClick:y})]})}),p&&t.jsx(cr,{ref:w,rowsPerPageOptions:v,labelRowsPerPage:A.formatMessage({id:"c4r.widgets.table.rowsPerPage"}),labelDisplayedRows:B,component:"div",count:c,rowsPerPage:d,page:g,onPageChange:L,onRowsPerPageChange:N,ActionsComponent:()=>t.jsx(j.TablePaginationActions,{count:c,rowsPerPage:d,page:g,onPageChange:L,lastPageTooltip:I})})]})}function gr({columns:e,sorting:n,sortBy:r,sortDirection:i,onSort:s}){return t.jsx(o.TableHead,{children:t.jsx(o.TableRow,{children:e.map(({field:l,headerName:a,align:p})=>t.jsx(o.TableCell,{align:p??"left",children:n?t.jsx(sr,{active:r===l,direction:r===l?i:"asc",onClick:()=>s(l),children:a??l}):a??l},l))})})}function hr({columns:e,rows:n,onRowMouseEnter:r,onRowMouseLeave:i,onRowClick:s}){return t.jsx(o.TableBody,{children:n.map((l,a)=>{const p=String(l.cartodb_id||l.id||a);return t.jsx(lr,{hover:!!s,onMouseEnter:()=>r==null?void 0:r(l),onMouseLeave:()=>i==null?void 0:i(l),onClick:()=>s&&s(l),children:e.map(({field:c,headerName:g,align:h,component:d,formatter:v})=>{var y;let f=(y=Object.entries(l).find(([m])=>m.toUpperCase()===c.toUpperCase()))==null?void 0:y[1];return v?f=v(f):typeof f=="bigint"?f=f.toString():Array.isArray(f)?f=`[${f.map(m=>typeof m=="string"?`"${m}"`:String(m)).join(", ")}]`:typeof f=="object"&&f!==null&&(f=JSON.stringify(f)),(g??c)&&t.jsx(ar,{scope:"row",align:h??"left",children:d?d(f):f},`${p}_${c}`)})},p)})})}function _t(e,n,r,i,s){const l=Array.isArray(e)?e:[e],[a]=l[0].data,p=new Date(a);return`<div style='minWidth: 160px;'>
8
- <p style='font-weight: 600; line-height: 1; margin: 4px 0;'>${Ht({date:p,stepMultiplier:i,stepSize:n})}</p>
9
- ${l.reduce((g,h)=>{if(h.value!==void 0&&h.value!==null){const d=`<div style='display: flex; flex-direction: row; align-items: center; justify-content: spread; height: 20px; gap: 8px;'>
3
+ </div>`;return`<div style="margin-top: 4px">${String(p)}${d}</div>`}).join(" "),r}function bn({height:e,labels:n=jn,yAxisData:i,selectedBars:r=vn,series:s,colors:a,tooltip:l=!0,tooltipFormatter:p=wn,xAxisFormatter:c=st,yAxisFormatter:g=st,onSelectedBarsChange:h,animation:d=!0,filterable:y=!0,stacked:f=!0,...m}){const v=o.useTheme(),x=u.useMemo(()=>(s??[]).map(k=>n[k]??k),[s,n]),S=u.useMemo(()=>Array.isArray(i[0])?i:[i],[i]),b=u.useMemo(()=>typeof a=="string"?[a]:Array.isArray(a)&&a.length?a:S.length<=1||x.length===1?[v.palette.secondary.main]:S.length===2||x.length===2?[v.palette.secondary.light,v.palette.secondary.dark]:Object.values(v.palette.qualitative.bold||{}),[a,v,S,x]);return{...m,tooltip:l,tooltipFormatter:p,xAxisFormatter:c,yAxisFormatter:g,onSelectedBarsChange:h,animation:d,filterable:y,stacked:f,labels:n,height:e??parseInt(v.spacing(22)),selectedBars:Sn(r),yAxisData:S,colors:b,series:x}}function Sn(e){return(e??[]).length?e.map(n=>Array.isArray(n)&&n.length===2?n:Array.isArray(n)?[...Array(2)].map((r,s)=>n[s]??0):[n,0]):[]}var kn=function e(n,i){if(n===i)return!0;if(n&&i&&typeof n=="object"&&typeof i=="object"){if(n.constructor!==i.constructor)return!1;var r,s,a;if(Array.isArray(n)){if(r=n.length,r!=i.length)return!1;for(s=r;s--!==0;)if(!e(n[s],i[s]))return!1;return!0}if(n.constructor===RegExp)return n.source===i.source&&n.flags===i.flags;if(n.valueOf!==Object.prototype.valueOf)return n.valueOf()===i.valueOf();if(n.toString!==Object.prototype.toString)return n.toString()===i.toString();if(a=Object.keys(n),r=a.length,r!==Object.keys(i).length)return!1;for(s=r;s--!==0;)if(!Object.prototype.hasOwnProperty.call(i,a[s]))return!1;for(s=r;s--!==0;){var l=a[s];if(!e(n[l],i[l]))return!1}return!0}return n!==n&&i!==i};const xe=j.getDefaultExportFromCjs(kn);class ye extends mn{componentDidUpdate(n){const{shouldSetOption:i}=this.props;if(typeof i=="function"&&!i(n,this.props))return;if(!xe(n.theme,this.props.theme)||!xe(n.opts,this.props.opts)){this.dispose(),this.renderNewEcharts();return}const r=this.getEchartsInstance();xe(n.onEvents,this.props.onEvents)||(this.offEvents(r,n.onEvents),this.bindEvents(r,this.props.onEvents));const s=["option","notMerge","lazyUpdate","showLoading","loadingOption"];xe(at(this.props,s),at(n,s))||this.updateEChartsOption(),(!xe(n.style,this.props.style)||!xe(n.className,this.props.className))&&this.resize()}updateEChartsOption(){const n=this.props.option,i=this.props.loadingOption||null,{lazyUpdate:r,showLoading:s}=this.props,a=this.getEchartsInstance();return a.setOption(n,{replaceMerge:["series"],lazyUpdate:r}),s?a.showLoading(i):a.hideLoading(),a}offEvents(n,i){if(i)for(const r in i)typeof r=="string"&&n.off(r)}}function at(e,n){const i={};return n.forEach(r=>{i[r]=e[r]}),i}const _e=240,Bt=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"flex-end",justifyContent:"space-between",position:"relative",padding:e.spacing(0,2),"&::before":{content:'""',position:"absolute",top:0,right:0,left:0,bottom:0,backgroundSize:e.spacing(4,4),backgroundImage:`linear-gradient(to bottom, ${e.palette.grey[50]} 1px, transparent 1px)`,transform:"scaleY(-1)"}})),Pt=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"flex-end",justifyContent:"space-between",backgroundImage:`linear-gradient(${e.palette.grey[50]} 0.5px, transparent 0.5px, transparent calc(100% - 0.5px), ${e.palette.grey[50]} calc(100% - 0.5px)), linear-gradient(90deg, ${e.palette.grey[50]} 0.5px, transparent 0.5px, transparent calc(100% - 0.5px), ${e.palette.grey[50]} calc(100% - 0.5px))`,backgroundSize:"8.33% 20%",border:`0.5px solid ${e.palette.grey[50]}`})),je=o.styled(o.Skeleton)(({theme:e})=>({flex:1,maxWidth:e.spacing(12),"& + &":{marginLeft:e.spacing(1)}})),ne=o.styled(o.Skeleton)(({theme:e})=>({flex:1,maxWidth:e.spacing(8),"& + &":{marginLeft:"1px"}})),In=o.styled(o.Skeleton)(({theme:e})=>({backgroundColor:e.palette.common.white})),lt=o.styled(o.Skeleton)(({theme:e})=>({backgroundColor:e.palette.grey[100]}));function Tn({height:e}){return t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{mb:2,children:t.jsx(o.Skeleton,{width:48,height:8})}),t.jsxs(Bt,{style:{height:e||_e},children:[t.jsx(je,{variant:"rectangular",height:"20%"}),t.jsx(je,{variant:"rectangular",height:"40%"}),t.jsx(je,{variant:"rectangular",height:"60%"}),t.jsx(je,{variant:"rectangular",height:"20%"}),t.jsx(je,{variant:"rectangular",height:"80%"})]})]})}function de(e){const[n,i]=u.useState(!1),[r,s]=u.useState(!1);return u.useEffect(()=>{e&&!r&&(i(!0),s(!0)),e||i(!1)},[e,r]),{showSkeleton:n}}const Mn=Et(),Cn=o.styled(o.Grid)(({theme:e})=>({marginBottom:e.spacing(2),flexDirection:"row",justifyContent:"space-between",alignItems:"center","& .MuiTypography-caption":{color:e.palette.text.secondary}})),An=o.styled(o.Link)(({theme:e})=>({...e.typography.caption,cursor:"pointer"}));function En(e){const{yAxisData:n,xAxisData:i,series:r,selectedBars:s,onSelectedBarsChange:a,tooltip:l,tooltipFormatter:p,labels:c,colors:g,xAxisFormatter:h,yAxisFormatter:d,stacked:y,height:f,filterable:m,animation:v,isLoading:x}=bn(e),S=r.length>1,b=o.useTheme(),k=J.useIntl(),I=j.useImperativeIntl(k),{showSkeleton:w}=de(!!x),M=u.useMemo(()=>({show:l,trigger:"axis",padding:[parseInt(b.spacing(.5)),parseInt(b.spacing(1))],borderWidth:0,textStyle:{...b.typography.caption,fontSize:11,color:b.palette.common.white},backgroundColor:b.palette.black[90],position:function(T,$,G,F,H){const K={top:0};return H.contentSize[0]<H.viewSize[0]-T[0]?K.left=T[0]:K.right=H.viewSize[0]-T[0],K},formatter:T=>p(T,d)}),[b,l,p,d]),C=u.useMemo(()=>i.map(T=>te(h(c[T]??String(T)))),[i,c,h]),D=u.useMemo(()=>({type:"category",axisLine:{show:!1},axisTick:{show:!1},axisLabel:{...b.typography.overlineDelicate,padding:[parseInt(b.spacing(.5)),0,0,0]},data:C}),[b,C]),B=u.useMemo(()=>{let T=[];return y?T=n.reduce(($,G)=>(G.forEach((F,H)=>$[H]=($[H]??0)+(F??Number.MIN_SAFE_INTEGER)),$),[]):T=n.flat().map($=>$??Number.MIN_SAFE_INTEGER),Math.max(...T)},[n,y]),L=u.useMemo(()=>({type:"value",axisLabel:{margin:0,verticalAlign:"bottom",padding:[0,0,parseInt(b.spacing(1.25)),0],show:!0,showMaxLabel:!0,showMinLabel:!1,inside:!0,color:T=>T>=B?b.palette.black[60]:"transparent",...b.typography.overlineDelicate,formatter:T=>te(d(T))},axisLine:{show:!1},axisTick:{show:!1},splitLine:{show:!0,onZero:!1,lineStyle:{color:b.palette.black[4]}}}),[b,B,d]),P=u.useMemo(()=>n.map((T,$)=>({type:"bar",name:r[$]??"",animation:v,barMaxWidth:100,data:T.map((G,F)=>{const H=s.some(([R,z=0])=>R===F&&z===$),K=!!s.length&&!H;return{value:G,...K&&{itemStyle:{color:b.palette.black[25]},disabled:!0}}}),...y&&{stack:"total"},...!Mn&&{emphasis:{focus:"series",itemStyle:{color:o.darken(g[$]??"#000",.25)}}}})),[v,g,r,n,s,y,b]),O=u.useMemo(()=>({grid:{left:C.length>=4?ct(String(C[0]),C.length):0,top:parseInt(b.spacing(2)),right:C.length>=4?ct(String(C[C.length-1]),C.length):0,bottom:0,containLabel:!0},axisPointer:{lineStyle:{color:b.palette.black[40]}},color:g,tooltip:M,xAxis:D,yAxis:L,series:P}),[C,b,g,M,D,L,P]),V=()=>{a&&a([],[])},_=T=>{T.key==="Enter"&&V()},E=u.useCallback(T=>{if(a){const $=[...s],{dataIndex:G,componentIndex:F}=T,H=$.findIndex(([R,z=0])=>G===R&&F===z);H===-1?$.push([G,F]):$.splice(H,1);const K=$.map(([R,z=0])=>({xAxis:i[R],serie:r[z],yAxis:n[z][R]}));a(S?$:$.map(R=>R[0]),K)}},[n,a,s,i,r,S]),N=u.useMemo(()=>m?{click:E}:{},[m,E]);return w?t.jsx(Tn,{height:f}):t.jsxs("div",{children:[a&&t.jsxs(Cn,{container:!0,children:[t.jsx(j.Typography,{variant:"caption",children:s.length>0?I.formatMessage({id:"c4r.widgets.bar.selectedItems"},{items:s.length}):I.formatMessage({id:"c4r.widgets.bar.all"})}),s&&s.length>0&&t.jsx(An,{onClick:()=>V(),onKeyDown:_,underline:"hover",tabIndex:0,children:I.formatMessage({id:"c4r.widgets.bar.clear"})})]}),!!O&&t.jsx(ye,{option:O,lazyUpdate:!0,notMerge:!0,onEvents:N,style:{height:f}})]})}function ct(e="",n=0){return n<=15&&e.length<=8?0:e.length*8.5/6}const ue="__rest__",me="Others";var pe=(e=>(e.RANKING="ranking",e.FIXED="fixed",e))(pe||{});const Lt=o.styled(o.Grid)(({theme:e})=>({maxHeight:e.spacing(40),overflow:"auto",padding:0})),Dt=o.styled(o.Grid,{shouldForwardProp:e=>e!=="selectable"&&e!=="name"&&e!=="unselected"})(({theme:e,selectable:n,name:i,unselected:r})=>({flexDirection:"row",maxWidth:"100%",padding:e.spacing(.5,.25),margin:0,"> .MuiGrid-item":{paddingTop:0,paddingLeft:0},"&:focus-visible":{outline:"none !important",boxShadow:`inset 0 0 0 2px ${e.palette.primary.main} !important`},...r&&{color:e.palette.text.disabled,".progressbar div":{backgroundColor:e.palette.text.disabled}},...i!==ue&&n&&{cursor:"pointer",flexWrap:"nowrap","&:hover .progressbar div":{backgroundColor:e.palette.secondary.dark}},...i===ue&&{cursor:"default",".progressbar div":{backgroundColor:e.palette.text.disabled}}})),dt=o.styled(o.Grid)(({theme:{spacing:e,palette:n}})=>({flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:e(1.5),paddingRight:e(1),"& .MuiTypography-caption":{color:n.text.secondary}})),Bn=o.styled(o.Grid)(({theme:e})=>({height:e.spacing(.5),width:"100%",margin:e.spacing(.5,0,.25,0),borderRadius:e.spacing(.5),backgroundColor:e.palette.action.disabledBackground,"& div":{width:0,height:"100%",borderRadius:e.spacing(.5),backgroundColor:e.palette.secondary.main,transition:`background-color ${e.transitions.easing.sharp} ${e.transitions.duration.shortest}ms,
4
+ width ${e.transitions.easing.sharp} ${e.transitions.duration.complex}ms`}})),Pn=o.styled(o.Grid,{shouldForwardProp:e=>e!=="isSelectable"})(({theme:e,isSelectable:n})=>({...n&&{width:`calc(100% - ${e.spacing(4)})`}})),Ln=o.styled(j.Typography)(({theme:e})=>({fontWeight:e.typography.fontWeightBold,marginRight:e.spacing(2)})),Ae=o.styled(o.Link)(({theme:e})=>({...e.typography.caption,cursor:"pointer","& + hr":{margin:e.spacing(0,1)}})),Dn=o.styled(o.Box)(({theme:e})=>({...e.typography.body2})),ut=o.styled(o.Button)(({theme:e})=>({position:"absolute",left:"-999px",top:"-1px",width:"1px",height:"1px",display:"inline-flex","&:focus-visible":{position:"static",width:"auto",height:"auto",marginTop:e.spacing(2)}})),Nn=o.styled(o.Skeleton)(({theme:e})=>({marginTop:e.spacing(1.25),marginBottom:e.spacing(1.75)})),On=e=>e%2===1,Nt=()=>t.jsxs(t.Fragment,{children:[t.jsx(o.Skeleton,{width:48,height:8}),t.jsx(Lt,{container:!0,mt:3,children:[...Array(6)].map((e,n)=>t.jsxs(Dt,{container:!0,spacing:1,children:[t.jsxs(o.Grid,{container:!0,item:!0,direction:"row",justifyContent:"space-between",children:[t.jsx(o.Skeleton,{width:On(n)?72:48,height:8}),t.jsx(o.Skeleton,{width:48,height:8})]}),t.jsx(Nn,{height:4,width:"100%"})]},n))})]});function Ot(e){const n=u.useRef();return u.useEffect(()=>{n.current=e}),n.current}function Ke({start:e,end:n,duration:i,drawFrame:r,requestRef:s}){if(e===n&&!(e===0&&n===0))return;const l=n-e;let p=e;const c=l/(i/1e3*60),g=()=>{p+=c,r(Math.floor(p)),c>0&&p<n||c<0&&p>n?s.current=requestAnimationFrame(g):r(n)};s.current=requestAnimationFrame(g)}function $n({start:e,end:n,duration:i,drawFrame:r,requestRef:s}){if(e.length===n.length&&e.every((f,m)=>f.value===n[m].value))return;let l=n.map((f,m)=>e[m]&&e[m].name===f.name?{...f,value:e[m].value}:f),p=0;const c=l.map((f,m)=>n[m].value-f.value);if(c.every(f=>f===0)){r(n);return}const h=i/1e3*60,d=c.map(f=>f/h),y=()=>{p<h?(l=l.map((f,m)=>{const v=Math.floor(f.value+d[m]),x=m>0&&Math.floor(f.value+d[m-1]);return{...f,value:v===x?n[m].value:v}}),r(l),p++,s.current=requestAnimationFrame(y)):r(n)};s.current=requestAnimationFrame(y)}const Rn=[],Fn={},Wn=e=>e,Ve=()=>{},_n=e=>e.reduce((n,i)=>n+(i.value??0),0);function Gn({data:e,formatter:n=Wn,labels:i=Fn,maxItems:r=5,order:s=pe.RANKING,selectedCategories:a=Rn,onSelectedCategoriesChange:l=Ve,onMaxItemsOverflow:p=_n,animation:c=!0,filterable:g=!0,searchable:h=!0,isLoading:d}){const[y,f]=u.useState([]),[m,v]=u.useState(1),[x,S]=u.useState(!1),[b,k]=u.useState(""),[I,w]=u.useState([]),[M,C]=u.useState([]),[D,B]=u.useState([]),L=u.useRef(null),P=u.useRef(),O=Ot(D),V=u.useRef([]),{showSkeleton:_}=de(!!d),E=J.useIntl(),N=j.useImperativeIntl(E);function T(A){return y.reduce((Y,q)=>(A.includes(q.name)&&Y.push(q.name),Y),[])}function $(A){if(A!==ue){let Y;a.includes(A)?Y=a.filter(q=>q!==A):Y=[...a,A],l&&l(Y)}}const G=()=>l([]),F=A=>{A.key==="Enter"&&G()},H=()=>{l([]),w([])},K=A=>{A.key==="Enter"&&H()},R=()=>{w(T(a))},z=A=>{A.key==="Enter"&&R()},Z=()=>{const A=T(M);l([...A]),w([...A]),C([]),S(!1),k("")},ge=A=>{A.key==="Enter"&&Z()},oe=()=>{k(""),S(!1)},W=A=>{if(A!==ue){let Y;M.includes(A)?Y=M.filter(q=>q!==A):Y=[...M,A],C(Y)}},U=A=>{A.currentTarget.scrollIntoView()},X=A=>{k(A.currentTarget.value)},Q=()=>{S(!0),C([...a])},re=u.useCallback(A=>{if(x)return b?A.filter(Y=>{var se;if(!Y.name)return!1;const q=String(Y.name);return!!(q.toLowerCase().includes(b.toLowerCase())||(se=i[q])!=null&&se.toLowerCase().includes(b.toLowerCase()))}):A;if(I.length)return I.reduce((q,se)=>{const Ce=A.find(ae=>ae.name===se);return q.push({name:se,value:Ce?Ce.value:null}),q},[]);{const Y=A.slice(0,r);if(Y.length<A.length){const q={name:ue,value:p(A.slice(r))};return[...Y,q]}else return Y}},[I,i,r,b,x,p]),ve=u.useCallback(()=>{const A=I.length;return A?e.length-A:e.length-r},[e,r,I]),fe=u.useCallback(A=>A===ue?`Others ${h?"":`(${ve()})`}`:i[String(A)]??String(A),[ve,i,h]),gn=u.useCallback(A=>A>=m?A!=null?"100%":0:`${(A||0)*100/m}%`,[m]);u.useEffect(()=>{a.length===0&&w([])},[a]),u.useEffect(()=>{if(e){if(s===pe.RANKING){const A=[...e].sort((q,se)=>(se.value??0)-(q.value??0)),Y=re(A);Y.length>0?v(Y[0].value??0):v(1),f(Y)}else if(s===pe.FIXED){v(Math.max(...e.map(Y=>Y.value??0)));const A=re(e);f(A)}}},[I,re,e,i,r,s,b,x]),u.useEffect(()=>{O&&(V.current=O)},[O]),u.useEffect(()=>{if(c)return $n({start:(V.current||[]).map(A=>({...A,value:A.value??0})),end:y.map(A=>({...A,value:A.value??0})),duration:500,drawFrame:A=>B(A),requestRef:L}),()=>{L.current&&cancelAnimationFrame(L.current)};B(y)},[c,y]),u.useEffect(()=>{x&&P.current&&P.current.focus()},[x,P]);function hn({data:A,onCategoryClick:Y}){const q=n(A.value??0),[se,Ce]=u.useState(!1),ae=u.useRef(null),ze=()=>{var it,rt;const Ye=(((it=ae==null?void 0:ae.current)==null?void 0:it.scrollWidth)??0)>(((rt=ae==null?void 0:ae.current)==null?void 0:rt.clientWidth)??0);Ce(Ye)};u.useEffect(()=>(ze(),window.addEventListener("resize",ze),()=>{window.removeEventListener("resize",ze)}),[]);const fn=Ye=>{Ye.key==="Enter"&&Y()},xn=!x&&a.length>0&&!a.includes(A.name);return t.jsxs(Dt,{container:!0,direction:"row",spacing:1,onClick:g?Y:Ve,onKeyDown:g?fn:Ve,selectable:g,unselected:xn,name:A.name===ue?ue:"",tabIndex:g?0:-1,children:[g&&x&&t.jsx(o.Grid,{item:!0,mr:1,children:t.jsx(o.Checkbox,{checked:M.includes(A.name),tabIndex:-1})}),t.jsxs(Pn,{container:!0,item:!0,xs:!0,isSelectable:x,children:[t.jsxs(o.Grid,{container:!0,item:!0,direction:"row",justifyContent:"space-between",wrap:"nowrap",children:[t.jsx(o.Tooltip,{title:fe(A.name),disableHoverListener:!se,children:t.jsx(Ln,{variant:"body2",noWrap:!0,ref:ae,children:fe(A.name)})}),typeof q=="object"&&q!==null?t.jsxs("span",{children:[q.prefix,q.value,q.suffix]}):t.jsx("span",{children:q})]}),t.jsx(Bn,{className:"progressbar",item:!0,children:t.jsx("div",{style:{width:gn(A.value??0)}})})]})]})}return(e==null?void 0:e.length)===0||_?t.jsx(Nt,{}):t.jsxs(Dn,{children:[g&&y.length>0&&t.jsxs(dt,{container:!0,children:[t.jsx(j.Typography,{variant:"caption",children:a.length>0?N.formatMessage({id:"c4r.widgets.category.selectedItems"},{items:a.length}):N.formatMessage({id:"c4r.widgets.category.all"})}),x?t.jsx(Ae,{onClick:Z,onKeyDown:ge,underline:"hover",tabIndex:0,"data-testid":"primaryApplyButton",children:N.formatMessage({id:"c4r.widgets.category.apply"})}):I.length>0?t.jsx(Ae,{onClick:H,onKeyDown:K,underline:"hover",tabIndex:0,children:N.formatMessage({id:"c4r.widgets.category.unlock"})}):a.length>0&&t.jsxs(o.Grid,{container:!0,direction:"row",justifyContent:"flex-end",item:!0,xs:!0,children:[t.jsx(Ae,{onClick:R,onKeyDown:z,underline:"hover",tabIndex:0,children:N.formatMessage({id:"c4r.widgets.category.lock"})}),t.jsx(o.Divider,{orientation:"vertical",flexItem:!0}),t.jsx(Ae,{onClick:G,onKeyDown:F,underline:"hover",tabIndex:0,children:N.formatMessage({id:"c4r.widgets.category.clear"})})]})]}),e.length>r&&x&&t.jsxs(dt,{container:!0,children:[t.jsx(o.TextField,{size:"small",sx:{mt:-.5},placeholder:N.formatMessage({id:"c4r.widgets.category.search"}),onChange:X,onFocus:U,InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",children:t.jsx(Te.Search,{})})},inputProps:{tabIndex:0,ref:P}}),t.jsx(ut,{size:"small",onClick:oe,children:N.formatMessage({id:"c4r.widgets.category.cancel"})})]}),t.jsx(Lt,{container:!0,item:!0,children:D.length?D.map((A,Y)=>t.jsx(hn,{data:A,onCategoryClick:()=>x?W(A.name):$(A.name)},Y)):t.jsxs(o.Box,{children:[t.jsx(j.Typography,{variant:"body2",children:N.formatMessage({id:"c4r.widgets.category.noResults"})}),t.jsx(j.Typography,{component:"p",variant:"caption",mb:2,children:N.formatMessage({id:"c4r.widgets.category.noResultsMessage"},{searchValue:b})})]})}),x&&t.jsx(ut,{size:"small",onClick:Z,children:N.formatMessage({id:"c4r.widgets.category.apply"})}),e.length>r&&h?x?t.jsx(o.Box,{mt:1.5,children:t.jsx(o.Button,{size:"small",color:"primary",onClick:oe,"data-testid":"primaryCancelButton",children:N.formatMessage({id:"c4r.widgets.category.cancel"})})}):t.jsx(o.Box,{mt:1.5,children:t.jsx(o.Button,{size:"small",color:"primary",startIcon:t.jsx(Te.Search,{}),onClick:Q,children:N.formatMessage({id:"c4r.widgets.category.searchInfo"},{elements:ve()})})}):null]})}const $t=()=>t.jsx(o.Box,{pt:.5,children:t.jsx(o.Skeleton,{height:24,width:120})}),Hn=o.styled("span")(()=>({marginRight:"2px"})),zn=o.styled("span")(()=>({marginLeft:"2px"})),Ee="-",Yn=e=>e;function Vn({data:e=Ee,formatter:n=Yn,animation:i=!0,isLoading:r=!1}){const[s,a]=u.useState(Ee),l=u.useRef(null),p=Ot(s),c=u.useRef(p),{showSkeleton:g}=de(!!r);u.useEffect(()=>(typeof e=="number"&&i?Ke({start:c.current||0,end:e,duration:500,drawFrame:f=>a(f),requestRef:l}):typeof e=="object"&&i&&e&&c.current&&e.value!==null&&e.value!==void 0?Ke({start:Number(c.current.value),end:Number(e.value),duration:1e3,drawFrame:f=>a({value:f,prefix:e.prefix,suffix:e.suffix}),requestRef:l}):a(e??Ee),()=>{l.current&&cancelAnimationFrame(l.current)}),[i,e,a]);const h=n(s),d=typeof h=="object"&&h!==null,y=h===Ee;return g?t.jsx($t,{}):d?t.jsxs(j.Typography,{variant:"h5",component:"div",weight:"medium",children:[t.jsx(Hn,{children:h.prefix}),h.value,t.jsx(zn,{children:h.suffix})]}):t.jsx(j.Typography,{variant:"h5",component:"div",weight:"medium",color:y?"text.disabled":"default",whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden",children:h})}const pt={};let we=null;function Un({data:e,filterable:n,selectedBars:i,onSelectedBarsChange:r,echartsInstance:s}){const a=o.useTheme(),[l,p]=u.useState([]),c=u.useMemo(()=>s==null?void 0:s.getZr(),[s]);u.useEffect(()=>{function h(y){if(s){const[f]=s.convertFromPixel({seriesIndex:0},[y.offsetX,y.offsetY]);we=f??null}}function d(y){if(s&&we!==null){const[f]=s.convertFromPixel({seriesIndex:0},[y.offsetX,y.offsetY]);p(we===f?[]:[we,f].sort((m,v)=>m-v))}}if(s&&n){const y=Ue(c,"mousedown",h),f=Ue(c,"mousemove",d);return()=>{y==null||y(),f==null||f()}}},[c,s,n]),u.useEffect(()=>{function h(){if(l.length===2&&r){const d=e.reduce((y,f,m)=>((l[0]>=f[0]&&l[0]<=f[1]||l[1]>=f[0]&&l[1]<=f[1]||l[0]<=f[0]&&l[1]>=f[1])&&y.push(m),y),[]);r(e.length===d.length?[]:d)}p([]),we=null}if(s&&n)return Ue(c,"mouseup",h)},[c,s,l,e,r,n]);const g=u.useCallback(h=>{if(r){const d=new Set(i);d.has(h.dataIndex)?d.delete(h.dataIndex):d.add(h.dataIndex),r(d.size===e.length?[]:Array.from(d))}},[r,i,e.length]);return{markAreaOptions:l.length===2&&{data:[[{coord:[l[0]]},{coord:[l[1]]}]],itemStyle:{color:a.palette.primary.main,opacity:.2}},onEvents:n?{click:g}:{}}}function Ue(e,n,i){if(e!=null&&e.handler)return pt[n]=i,e.on(n,i),()=>{pt[n]&&(e!=null&&e.handler)&&e.off(n,i)}}function qn({height:e}){return t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{mb:2,children:t.jsx(o.Skeleton,{width:48,height:8})}),t.jsxs(Pt,{style:{height:e??_e},children:[t.jsx(ne,{variant:"rectangular",height:"20%"}),t.jsx(ne,{variant:"rectangular",height:"40%"}),t.jsx(ne,{variant:"rectangular",height:"60%"}),t.jsx(ne,{variant:"rectangular",height:"20%"}),t.jsx(ne,{variant:"rectangular",height:"80%"}),t.jsx(ne,{variant:"rectangular",height:"50%"}),t.jsx(ne,{variant:"rectangular",height:"20%"}),t.jsx(ne,{variant:"rectangular",height:"40%"}),t.jsx(ne,{variant:"rectangular",height:"60%"}),t.jsx(ne,{variant:"rectangular",height:"20%"}),t.jsx(ne,{variant:"rectangular",height:"80%"}),t.jsx(ne,{variant:"rectangular",height:"50%"})]})]})}const Kn=Et(),Xn=o.styled(o.Grid)(({theme:e})=>({marginBottom:e.spacing(2),flexDirection:"row",justifyContent:"space-between",alignItems:"center","& .MuiTypography-caption":{color:e.palette.text.secondary}})),Zn=o.styled(o.Link)(({theme:e})=>({...e.typography.caption,cursor:"pointer"})),Jn=[],Qn=()=>{},Oe=e=>e;function eo(e,n=Oe,i=Oe){if(!e)return null;if(Array.isArray(e)&&e.length===0)return;const r=Array.isArray(e)?e[0].marker:e.marker,s=Array.isArray(e)?e[0].data:e.data;if((s==null?void 0:s.value)===void 0)return;const[a,l,p]=s.value,c=te(n(a)),g=te(n(l)),h=te(i(p)),d=`${c} <span style="vertical-align: 1px;">—</span> ${g}`,y=`<div style="margin-left: 8px; display: inline">${h}</div>`;return`${d} <div style="margin-top: 4px">${String(r)}${y}</div>`}function to({data:e,ticks:n,min:i,max:r,xAxisFormatter:s=Oe,yAxisFormatter:a=Oe,yAxisType:l="dense",selectedBars:p=Jn,onSelectedBarsChange:c=Qn,tooltip:g=!0,tooltipFormatter:h=eo,animation:d=!0,filterable:y=!0,height:f=200,isLoading:m}){const v=J.useIntl(),x=o.useTheme(),S=j.useImperativeIntl(v),{showSkeleton:b}=de(!!m),k=!!y&&!!c,[I,w]=u.useState(),M=T=>w(T),C=u.useMemo(()=>io(e,n,i,r),[e,n,i,r]),{onEvents:D,markAreaOptions:B}=Un({data:C,filterable:k,selectedBars:p,onSelectedBarsChange:c,echartsInstance:I}),L=u.useMemo(()=>({show:g,trigger:"item",padding:[j.SPACING*.5,j.SPACING],borderWidth:0,textStyle:{...x.typography.caption,fontSize:11,color:x.palette.common.white},backgroundColor:x.palette.black[90],confine:!0,position:"top",formatter(T){return h(T,s,a)}}),[x,g,h,s,a]),P=u.useMemo(()=>({min:i,max:r,interval:(r-i)/C.length,axisLine:{show:!1},splitLine:{show:!0,lineStyle:{color:x.palette.black[4]}},axisTick:{show:!1},axisLabel:{showMinLabel:!0,showMaxLabel:!0,...x.typography.overlineDelicate,hideOverlap:!0,padding:[j.SPACING*.5,j.SPACING*.5,0,j.SPACING*.5],formatter:T=>{const $=te(s(T));return T===i?no($):T===r?oo($):$},color:x.palette.black[60]}}),[i,r,C.length,x,s]),O=u.useMemo(()=>{const T={margin:0,verticalAlign:"bottom",padding:[0,0,j.SPACING*1.25,0],inside:!0,color:F=>{const H=Math.max(...e.map(R=>R??Number.MIN_SAFE_INTEGER))||1;let K="transparent";return F>=H&&(K=x.palette.black[60]),K},...x.typography.overlineDelicate,formatter:F=>te(a(F))},$={verticalAlign:"middle",padding:[0,0,0,j.SPACING*.5],color:x.palette.black[60]},G=l==="dense"?T:$;return{type:"value",axisLine:{show:!1},splitLine:{show:!0,lineStyle:{color:x.palette.black[4]}},axisTick:{show:!1},axisLabel:{show:!0,showMaxLabel:!0,showMinLabel:!1,...G,...x.typography.overlineDelicate,formatter:F=>te(a(F))}}},[x.palette.black,x.typography.overlineDelicate,e,a,l]),V=u.useMemo(()=>{const T=i===r&&C.filter(F=>F[2]!==0).length===1,G=(T?[C[0],C[C.length-1]]:C).map((F,H)=>{const R=p.length&&!p.includes(H)?x.palette.black[25]:x.palette.secondary.main;return{value:F,itemStyle:{color:R}}});return{type:"custom",cursor:"pointer",markArea:B,renderItem:function(F,H){const K=F.dataIndex===C.length-1,R=F.dataIndex===0,z=G[F.dataIndex].itemStyle.color,Z=H.value(0),ge=H.value(1),oe=H.value(2),[W,U]=H.coord([Z,oe]),[X,Q]=H.size([ge-Z,oe]);return{type:"rect",shape:{x:T?W/10:W+(R?0:1),y:U,width:T?W-W/10:X-(K?0:1),height:Q},style:{fill:z},...!Kn&&{emphasis:{style:{fill:o.darken(z,.25)}}}}},encode:{x:[0,1],y:2,tooltip:[0,1,2]},data:G,animation:d}},[i,r,C,B,x.palette.black,x.palette.secondary.main,p,d]),_=u.useMemo(()=>({grid:{left:j.SPACING*.1,right:j.SPACING*.1,top:j.SPACING*2,bottom:j.SPACING*.5,containLabel:!0},tooltip:L,xAxis:P,yAxis:O,series:[V]}),[L,P,O,V]),E=p.reduce((T,$)=>T+=e[$]??0,0),N=T=>{T.key==="Enter"&&c([])};return b?t.jsx(qn,{height:f}):t.jsxs("div",{children:[k&&t.jsxs(Xn,{container:!0,children:[t.jsx(j.Typography,{variant:"caption",weight:"strong",children:p.length>0?S.formatMessage({id:"c4r.widgets.histogram.selectedItems"},{items:te(a(E))}):S.formatMessage({id:"c4r.widgets.histogram.all"})}),p.length>0&&t.jsx(Zn,{onClick:()=>c([]),onKeyDown:N,underline:"hover",tabIndex:0,children:S.formatMessage({id:"c4r.widgets.histogram.clear"})})]}),t.jsx(ye,{option:_,onEvents:D,lazyUpdate:!0,onChartReady:M,style:{maxHeight:f}})]})}function no(e){return`${Array(String(e).length).fill(" ").join("")}${e}`}function oo(e){const n=Array(String(e).length).fill(" ").join("");return`${e}${n}`}function io(e,n,i,r){return e.map((s,a)=>[a===0?i:n[a-1],a===e.length-1?r:n[a],s])}function ro(e,n,i,r){const s=o.useTheme(),a=u.useMemo(()=>n===pe.RANKING?e.slice().sort((c,g)=>(g.value??0)-(c.value??0)):e,[e,n]),l=u.useMemo(()=>{const c=[];let g=0;for(const h of a)c.length<i?c.push({...h}):g+=h.value??0;return g>0&&c.push({name:me,value:g,emphasis:{scale:!1}}),c},[i,a]);return u.useMemo(()=>{const c=s.palette.common.white;return l.map((g,h)=>{let d=c;if(r.length){const f=r[h%r.length];f&&(d=f)}else{const m=s.palette.qualitative.bold[h];m&&(d=m)}const y=g;return y.color=d,y})},[l,r,s])}const so=o.styled(o.Box)(({theme:e})=>({zIndex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",paddingBottom:e.spacing(1)})),ao=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1),maxWidth:"140px",textTransform:"uppercase"})),lo=o.styled(o.Box)(({theme:e})=>({display:"inline-block",borderRadius:e.spacing(.5),width:e.spacing(1),minWidth:e.spacing(1),height:e.spacing(1)}));function co({data:e,selectedCategories:n,formatter:i}){const[r,s]=u.useState(),a=u.useMemo(()=>{if(!e||e.length===0)return null;let g;n.length>0?g=e.filter(m=>n.includes(m.name)):g=e;const h=uo(g),d=g.find(m=>m===h);if(!d)return null;let y=0;for(const m of e)y+=m.value??0;const f=po(d.value??0,y,i);return{...d,percentage:f}},[e,n,i]);u.useEffect(()=>{a&&s(a)},[a,s]);const{name:l,percentage:p,color:c}=r??{};return r?t.jsxs(so,{children:[t.jsx(j.Typography,{variant:"h5",children:p}),t.jsxs(ao,{children:[t.jsx(lo,{bgcolor:c,component:"span"}),t.jsx(j.Typography,{component:"span",variant:"body2",noWrap:!0,children:l})]})]}):null}function uo(e){const n=e.filter(i=>i.name!==me);return n.length===0?e[0]:n.reduce((i,r)=>(r.value??0)>(i.value??0)?r:i)}function po(e,n,i){let r=0;return n!==0&&(r=e/n*100),i?i(r):`${r}%`}const gt=32,go=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",marginTop:e.spacing(.5)})),ho=o.styled("div")(()=>({display:"flex",alignItems:"center",justifyContent:"center",position:"relative"})),fo=o.styled(In)(()=>({position:"absolute",zIndex:1})),xo=o.styled("div")(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",gap:e.spacing(1),position:"absolute",zIndex:2})),mo=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(2),height:e.spacing(5)})),yo=o.styled("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1.5)}));function Rt({height:e}){const n=parseInt(String(e),10)||_e,i=n-gt,r=i-gt;return t.jsxs(o.Box,{mt:.5,children:[t.jsx(o.Skeleton,{height:8,width:64}),t.jsx(go,{height:n,children:t.jsxs(ho,{children:[t.jsx(o.Skeleton,{variant:"circular",width:i,height:i}),t.jsx(fo,{variant:"circular",width:r,height:r}),t.jsxs(xo,{children:[t.jsx(o.Skeleton,{height:24,width:72}),t.jsx(o.Skeleton,{height:8,width:48})]})]})}),t.jsx(mo,{children:[...Array(2)].map((s,a)=>t.jsxs(yo,{children:[t.jsx(o.Skeleton,{variant:"circular",width:8,height:8}),t.jsx(o.Skeleton,{width:48,height:8})]},a))})]})}const vo=o.styled(o.Box)(({theme:e})=>({position:"relative",padding:e.spacing(1.25,1,0,1),width:"100%"})),jo=o.styled(o.Box)(({theme:e})=>({position:"relative",display:"flex",flexDirection:"row",overflowX:"hidden",gap:e.spacing(2),padding:e.spacing(.5),margin:e.spacing(-.5)})),wo=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",gap:e.spacing(1),alignItems:"center",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:"pointer"})),bo=o.styled(o.Box)(({theme:e})=>({display:"inline-block",position:"absolute",left:e.spacing(-2),top:e.spacing(1),bottom:e.spacing(1),zIndex:1,width:e.spacing(2.5),background:`linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, ${e.palette.background.paper} 100%)`})),So=o.styled(o.Box)(({theme:e})=>({position:"absolute",padding:e.spacing(.25,1),top:e.spacing(0),right:0,background:e.palette.background.paper})),ko=o.styled(o.Box,{shouldForwardProp:e=>e!=="color"})(({theme:e,color:n})=>{const i=e.spacing(1);return{backgroundColor:n,borderRadius:"50%",width:i,height:i}});function Ft({series:e,selectedCategories:n,onCategoryClick:i}){var k,I;const r=o.useTheme(),[s,a]=u.useState(!1),[l,p]=u.useState(0),[c,g]=u.useState(void 0),h=u.useRef(null),d=u.useRef(null),y=u.useRef(null),f=J.useIntl(),m=j.useImperativeIntl(f);function v(){p(l+1)}function x(){p(Math.max(l-1))}function S(w,M){w.key==="Enter"&&(i==null||i(M))}const b=u.useCallback(()=>{var M,C,D;const w=!!d.current&&d.current.scrollWidth>d.current.clientWidth;a(w),g(w&&d.current?(((M=h.current)==null?void 0:M.clientWidth)??0)-(((C=y.current)==null?void 0:C.clientWidth)??70):(((D=h.current)==null?void 0:D.clientWidth)??0)-12||500)},[h,d,y]);return u.useEffect(()=>{b()},[d,(k=d.current)==null?void 0:k.scrollWidth,(I=d.current)==null?void 0:I.clientWidth,b,l]),u.useEffect(()=>{if(typeof ResizeObserver>"u")return;let w;return h.current&&(w=new ResizeObserver(()=>{b()}),w.observe(h.current)),()=>{w==null||w.disconnect()}},[h,b]),t.jsxs(vo,{ref:h,children:[t.jsx(jo,{ref:d,style:{maxWidth:`${c}px`},children:e.map((w,M)=>{if(M<l)return null;const C=n.length===0||n.includes(w.name);return t.jsxs(wo,{tabIndex:0,onClick:i?()=>i(w.name):void 0,onKeyDown:i?D=>S(D,w.name):void 0,style:{pointerEvents:!i||w.name==="Others"?"none":void 0},children:[t.jsx(ko,{color:C?w.color:r.palette.text.disabled}),t.jsx(j.Typography,{variant:"overline",color:C?void 0:"text.disabled",children:w.name})]},M)})}),(s||l>0)&&t.jsxs(So,{ref:y,children:[t.jsx(bo,{}),t.jsx(o.Tooltip,{title:m.formatMessage({id:"c4r.widgets.chartLegend.next"}),children:t.jsx(o.IconButton,{size:"small",disabled:l===0,onClick:x,children:t.jsx(ee.ChevronLeft,{})})}),t.jsx(o.Tooltip,{title:m.formatMessage({id:"c4r.widgets.chartLegend.prev"}),children:t.jsx(o.IconButton,{size:"small",disabled:!s,onClick:v,children:t.jsx(ee.ChevronRight,{})})})]})]})}const Xe="232px",Io=o.styled(o.Grid)(({theme:e})=>({flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:e.spacing(.5)})),To=o.styled(o.Box,{shouldForwardProp:e=>e!=="height"&&e!=="width"})(({height:e,width:n})=>({position:"relative",margin:"0 auto",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:n||"100%",height:e||"100%"})),Mo=o.styled(ye)(()=>({position:"absolute",top:0,right:0,left:0,bottom:0})),ht=[],Co={},Ao=e=>e;function Eo({name:e,data:n,formatter:i=Ao,tooltipFormatter:r=Bo,percentFormatter:s,height:a=Xe,width:l=Xe,labels:p=Co,colors:c=ht,animation:g=!0,filterable:h=!0,selectedCategories:d=ht,onSelectedCategoriesChange:y,isLoading:f,maxItems:m=11,order:v=pe.RANKING}){const x=o.useTheme(),S=ro(n,v,m,c),{showSkeleton:b}=de(!!f),k=J.useIntl(),I=j.useImperativeIntl(k),w=u.useMemo(()=>s||(_=>`${k.formatNumber(_,{maximumFractionDigits:2,minimumFractionDigits:2})}%`),[k,s]),M=u.useMemo(()=>{let _;return r&&(_=E=>r(E,i,w)),{padding:[j.SPACING*.5,j.SPACING],backgroundColor:x.palette.black[90],borderColor:"transparent",textStyle:{color:x.palette.common.white},confine:!0,formatter:_}},[x.palette.black,x.palette.common.white,r,i,w]),C=u.useMemo(()=>[{type:"pie",name:e,animation:g,data:S.map(_=>{const E={..._},N=(d==null?void 0:d.length)&&!d.includes(E.name);return p!=null&&p[E.name]&&(E.name=p[E.name]),N?{...E,disabled:!0,itemStyle:{color:x.palette.black[25]}}:{...E,itemStyle:{color:E.color}}}),radius:["74%","90%"],selectedOffset:0,bottom:j.SPACING*1.5,label:{show:!1},emphasis:{focus:"series",scaleSize:5},itemStyle:{borderColor:x.palette.background.paper,borderWidth:1}}],[e,g,S,p,d,x]),D=u.useMemo(()=>({grid:{left:0,top:0,right:0,bottom:0},tooltip:M,legend:{show:!1},series:C}),[M,C]),B=u.useCallback(_=>{if(y){const E=[...d],{name:N}=S[_.dataIndex];if(N===me)return;const T=E.indexOf(N);T===-1?E.push(N):E.splice(T,1),y(E)}},[S,y,d]),L=u.useCallback(_=>{if(y){const E=[...d],N=E.indexOf(_);N===-1?E.push(_):E.splice(N,1),y(E)}},[y,d]),P={...h&&{click:B}},O=()=>{y==null||y([])},V=_=>{_.key==="Enter"&&O()};return b?t.jsx(Rt,{height:a}):t.jsxs(t.Fragment,{children:[h&&t.jsxs(Io,{container:!0,children:[t.jsx(j.Typography,{variant:"caption",color:"textSecondary",children:d.length?I.formatMessage({id:"c4r.widgets.pie.selectedItems"},{items:d.length}):I.formatMessage({id:"c4r.widgets.pie.allSelected"})}),d.length>0&&t.jsx(o.Link,{variant:"caption",onClick:O,onKeyDown:V,tabIndex:0,children:I.formatMessage({id:"c4r.widgets.pie.clear"})})]}),t.jsxs(To,{height:a,width:l,children:[t.jsx(co,{data:S,selectedCategories:d,formatter:w}),t.jsx(Mo,{option:D,onEvents:P,lazyUpdate:!0,style:{height:a,width:l}})]}),S.length>0&&t.jsx(Ft,{series:S,selectedCategories:d,onCategoryClick:y&&L})]})}function Bo(e,n,i){var c;const r=Array.isArray(e)?e[0]:e;if(!r)return null;const s=te(n(r.value)),a=i(r.percent)||`${r.percent}%`,p=`display:inline-block;border-radius:4px;width:8px;height:8px;background-color:${((c=r.data)==null?void 0:c.color)||r.textStyle.color}`;return`
5
+ <div style="white-space:normal;"><p style="max-width:${Xe};font-size:11px;font-weight:500;line-height:1.454;text-transform:uppercase;margin:0 0 4px 0;">${r.name}</p>
6
+ <p style="display:flex;align-items:center;font-size: 11px;font-weight:500;line-height:1.454;margin:0;"><span style="${p}"></span> <span style="margin:0 4px;font-weight:400;">${s}</span> (${a})</p></div>
7
+ `.trim()}const Po=o.styled(o.Grid)(({theme:e})=>({position:"relative",alignItems:"center",height:e.spacing(4)})),Lo=o.styled(o.Grid)(({theme:e})=>({position:"absolute",zIndex:1,padding:e.spacing(0,3)}));function Do(){return t.jsxs(o.Grid,{container:!0,children:[t.jsxs(Po,{container:!0,item:!0,children:[t.jsxs(Lo,{container:!0,item:!0,justifyContent:"space-between",children:[t.jsx(lt,{variant:"circular",width:12,height:12}),t.jsx(lt,{variant:"circular",width:12,height:12})]}),t.jsx(o.Skeleton,{height:2,width:"100%"})]}),t.jsxs(o.Grid,{container:!0,item:!0,justifyContent:"space-between",children:[t.jsx(o.Skeleton,{width:56,height:32}),t.jsx(o.Skeleton,{width:56,height:32})]})]})}const No=o.styled(o.Box)(()=>({position:"relative"})),Oo=o.styled(o.Box)(({theme:{spacing:e}})=>({display:"flex",flexDirection:"row-reverse",height:e(1.5)})),$o=o.styled(o.Link)(()=>({cursor:"pointer"})),ft=o.styled(o.TextField)(({theme:{spacing:e}})=>({maxWidth:e(9),margin:0,"& fieldset":{borderWidth:1},"& input":{"&[type=number]":{appearance:"textfield"},"&::-webkit-outer-spin-button":{appearance:"none",margin:0},"&::-webkit-inner-spin-button":{appearance:"none",margin:0}}})),Ro=o.styled(o.Slider)(({theme:{palette:e}})=>({"& .MuiSlider-rail":{color:e.text.hint}})),Fo=o.styled(o.Slider)(({theme:{palette:e,spacing:n}})=>({pointerEvents:"none",position:"absolute",zIndex:1,left:0,right:0,"& .MuiSlider-rail":{display:"none"},"& .MuiSlider-thumb":{display:"none"},"& .MuiSlider-track":{color:e.primary.main,opacity:.38},"& .MuiSlider-mark, & .MuiSlider-markActive":{backgroundColor:e.primary.main,opacity:.38,height:n(1),width:n(.25),top:"50%",transform:"translateY(-50%)"}}));function Wo({data:e,min:n,max:i,limits:r,onSelectedRangeChange:s,isLoading:a}){const[l,p]=u.useState([n,i]),[c,g]=u.useState([n,i]),h=J.useIntl(),d=j.useImperativeIntl(h),{showSkeleton:y}=de(!!a),f=u.useMemo(()=>{if(!r||r.length!==2)return;if(r[0]===r[1])return[{value:r[0]}];const w=[{value:Math.max(r[0],n)},{value:Math.min(r[1],i)}];if(!(w[0].value>w[1].value))return w},[r,i,n]),m=u.useMemo(()=>s?o.debounce(s,250):null,[s]),v=w=>{g([...w]),p([...w]),m&&m([...w])};function x(w,M){const C=w.target.value===""?"":Number(w.target.value);M===0&&g([C,c[1]]),M===1&&g([c[0],C])}const S=n!==c[0]||i!==c[1];u.useEffect(()=>{e&&(g([...e]),p([...e]))},[e]);function b(w){let M=c[w];M===""&&(M=l[w]),M>i&&(M=i),M<n&&(M=n);const C=w===0?[M,c[1]]:[c[0],M];v(C.sort((D,B)=>D-B))}const k=()=>{v([n,i])};function I(w){w.key==="Enter"&&k()}return y?t.jsx(Do,{}):t.jsxs(No,{children:[t.jsx(Oo,{children:S&&t.jsx(j.Typography,{variant:"caption",color:"primary",children:t.jsx($o,{onClick:k,onKeyDown:I,tabIndex:0,component:"button",underline:"hover",children:d.formatMessage({id:"c4r.widgets.range.clear"})})})}),t.jsxs(o.Box,{children:[t.jsx(Ro,{getAriaLabel:w=>w===0?d.formatMessage({id:"c4r.widgets.range.minValue"}):d.formatMessage({id:"c4r.widgets.range.maxValue"}),value:l,min:n,max:i,onChange:(w,M)=>v(M)}),r&&r.length===2&&t.jsx(Fo,{getAriaLabel:w=>w===0?d.formatMessage({id:"c4r.widgets.range.minLimit"}):d.formatMessage({id:"c4r.widgets.range.maxLimit"}),value:r,min:n,max:i,marks:f})]}),t.jsxs(o.Box,{display:"flex",justifyContent:"space-between",mb:1,children:[t.jsx(ft,{value:c[0],size:"small",onChange:w=>x(w,0),onBlur:()=>b(0),inputProps:{min:n,max:i,type:"number","aria-label":d.formatMessage({id:"c4r.widgets.range.minValue"})}}),t.jsx(ft,{value:c[1],size:"small",onChange:w=>x(w,1),onBlur:()=>b(1),inputProps:{min:n,max:i,type:"number","aria-label":d.formatMessage({id:"c4r.widgets.range.maxValue"})}})]})]})}const _o=o.styled(Pt)(({theme:e})=>({flexDirection:"column",alignItems:"center",justifyContent:"center",marginLeft:e.spacing(4),containerType:"inline-size",[`@container (max-width: ${j.BREAKPOINTS.XS}px)`]:{" > div":{maxWidth:"75%"}}})),Go=o.styled(o.Box)(()=>({position:"relative",display:"flex",justifyContent:"space-between",width:"80%",maxWidth:"50%"}));function Ho({height:e}){function n(){return Math.floor(Math.random()*5)}return t.jsxs(o.Box,{height:e??_e,children:[t.jsx(o.Box,{mb:4,children:t.jsx(o.Skeleton,{width:48,height:8})}),t.jsx(_o,{height:"80%",children:[...Array(3)].map((i,r)=>t.jsx(Go,{ml:r*3,children:[...Array(4)].map((s,a)=>t.jsx(o.Box,{mt:n(),ml:n(),children:t.jsx(o.Skeleton,{variant:"circular",width:12,height:12})},a))},r))})]})}function zo(e,n){var c;const i=Array.isArray(e.tooltip)?e.tooltip[0]:e.tooltip,r=Array.isArray(n.tooltip)?n.tooltip[0]:n.tooltip,s=i==null?void 0:i.formatter,a=r==null?void 0:r.formatter,l=(c=e.series[0])==null?void 0:c.data,p=n.series[0].data;return s!==a?!1:l&&p&&l.length===p.length?!p.some(({value:g},h)=>{var d;return g!==((d=l[h])==null?void 0:d.value)}):!1}function Yo({tooltipFormatter:e,xAxisFormatter:n=$e,yAxisFormatter:i=$e},r){return{grid:{top:10,left:5,bottom:10,right:15,containLabel:!0},tooltip:{padding:[j.SPACING*.5,j.SPACING],textStyle:{...r.typography.caption,fontSize:11,color:r.palette.common.white},backgroundColor:r.palette.black[90],...e?{formatter:e}:{}},color:[r.palette.secondary.main],xAxis:{axisLabel:{...r.typography.overlineDelicate,padding:[j.SPACING*.5,0,0,0],formatter:s=>te(n(s))}},yAxis:{axisLabel:{...r.typography.overlineDelicate,formatter:s=>te(i(s))}}}}function Vo({name:e,data:n,animation:i}){return[{type:"scatter",name:e,data:n,animation:i}]}const Uo=u.memo(ye,(e,n)=>zo(e.option,n.option)),xt=225,qo=[],$e=e=>e;function Ko({name:e=null,data:n=qo,animation:i=!0,xAxisFormatter:r=$e,yAxisFormatter:s=$e,tooltipFormatter:a=Xo,isLoading:l}){const p=o.useTheme(),c=u.useRef(),[g,h]=u.useState({series:[]}),{showSkeleton:d}=de(!!l);return u.useEffect(()=>{const y=Yo({xAxisFormatter:r,yAxisFormatter:s,tooltipFormatter:a},p),f=Vo({name:e,data:n||[],animation:i});h({...y,series:f})},[n,e,i,p,r,s,a]),d?t.jsx(Ho,{height:xt}):t.jsx(Uo,{ref:c,option:g,lazyUpdate:!0,style:{height:xt}})}function Xo(e){const n=Array.isArray(e)?e[0]:e,i=(n==null?void 0:n.value)||[];return`[${i[0]}, ${i[1]})`}function Be({width:e,rows:n=4,index:i=0}){function r(s){const a=[72,48,96,32,64],l=s%a.length;return a[l]}return[...Array(n)].map((s,a)=>t.jsx(o.TableCell,{children:t.jsx(o.Skeleton,{width:e??r(i),height:8})},a))}const Zo=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:e.spacing(2),margin:0,padding:e.spacing(2,1)})),Jo=o.styled(o.TableContainer)(()=>({overflow:"hidden"}));function Qo({style:e,dense:n,pagination:i,rowsPerPage:r}){return t.jsxs(t.Fragment,{children:[t.jsx(Jo,{style:e,children:t.jsxs(o.Table,{"aria-label":"skeleton table",size:n?"small":"medium",children:[t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{children:[t.jsx(Be,{rows:1,width:8}),t.jsx(Be,{width:56})]})}),t.jsx(o.TableBody,{children:[...Array(Math.min(10,r??10))].map((s,a)=>t.jsxs(o.TableRow,{children:[t.jsx(Be,{rows:1,width:8}),t.jsx(Be,{index:a})]},a))})]})}),i&&t.jsxs(Zo,{children:[t.jsx(o.Skeleton,{width:56,height:8}),t.jsx(o.Box,{mr:1,children:t.jsx(o.Skeleton,{width:52,height:16})}),t.jsx(o.Skeleton,{width:60,height:8}),t.jsx(o.Skeleton,{width:16,height:16}),t.jsx(o.Skeleton,{width:16,height:16})]})]})}const ei=o.styled(o.TableSortLabel)(({theme:e})=>({...e.typography.caption,color:e.palette.text.secondary,whiteSpace:"nowrap"})),ti=o.styled(o.TableRow)(({theme:e})=>({maxHeight:e.spacing(6.5),transition:"background-color 0.25s ease","&.MuiTableRow-hover:hover":{cursor:"pointer",backgroundColor:e.palette.background.default}})),ni=o.styled(o.TableCell)(()=>({overflow:"hidden","& p":{maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}})),oi=o.styled(o.TablePagination)(({theme:e})=>({height:e.spacing(6),overflowX:"auto",overflowY:"hidden"})),ii=10,ri=[5,10,25],be=()=>{};function si({columns:e,rows:n,sorting:i=!1,sortBy:r,sortDirection:s="asc",onSetSortBy:a=be,onSetSortDirection:l=be,pagination:p=!1,totalCount:c,page:g,onSetPage:h=be,rowsPerPage:d=ii,rowsPerPageOptions:y=ri,onSetRowsPerPage:f=be,onRowClick:m=be,onRowMouseEnter:v,onRowMouseLeave:x,height:S,dense:b=!1,isLoading:k,lastPageTooltip:I}){var _;const w=u.useRef(null),M=J.useIntl(),C=j.useImperativeIntl(M),{showSkeleton:D}=de(!!k);function B({from:E,to:N,count:T}){return C.formatMessage({id:"c4r.widgets.table.of"},{from:E,to:N,count:T})}function L(E){l(r===E&&s==="asc"?"desc":"asc"),a(E)}function P(E,N){h(N)}function O(E){f(parseInt(E.target.value,10)),h(0)}const V={height:void 0};if(S){const E=Math.max(((_=w==null?void 0:w.current)==null?void 0:_.clientHeight)??0,p?j.SPACING*6:0);V.height=`calc(${S} - ${E}px)`}return D?t.jsx(Qo,{rowsPerPage:d,style:V,dense:b,pagination:p}):t.jsxs(t.Fragment,{children:[t.jsx(o.TableContainer,{style:V,children:t.jsxs(o.Table,{stickyHeader:!0,size:b?"small":"medium",children:[t.jsx(ai,{columns:e,sorting:i,sortBy:r,sortDirection:s,onSort:L}),t.jsx(li,{columns:e,rows:n,onRowMouseEnter:v,onRowMouseLeave:x,onRowClick:m})]})}),p&&t.jsx(oi,{ref:w,rowsPerPageOptions:y,labelRowsPerPage:C.formatMessage({id:"c4r.widgets.table.rowsPerPage"}),labelDisplayedRows:B,component:"div",count:c,rowsPerPage:d,page:g,onPageChange:P,onRowsPerPageChange:O,ActionsComponent:()=>t.jsx(j.TablePaginationActions,{count:c,rowsPerPage:d,page:g,onPageChange:P,lastPageTooltip:I})})]})}function ai({columns:e,sorting:n,sortBy:i,sortDirection:r,onSort:s}){return t.jsx(o.TableHead,{children:t.jsx(o.TableRow,{children:e.map(({field:a,headerName:l,align:p})=>t.jsx(o.TableCell,{align:p??"left",children:n?t.jsx(ei,{active:i===a,direction:i===a?r:"asc",onClick:()=>s(a),children:l??a}):l??a},a))})})}function li({columns:e,rows:n,onRowMouseEnter:i,onRowMouseLeave:r,onRowClick:s}){return t.jsx(o.TableBody,{children:n.map((a,l)=>{const p=String(a.cartodb_id||a.id||l);return t.jsx(ti,{hover:!!s,onMouseEnter:()=>i==null?void 0:i(a),onMouseLeave:()=>r==null?void 0:r(a),onClick:()=>s&&s(a),children:e.map(({field:c,headerName:g,align:h,component:d,formatter:y})=>{var m;let f=(m=Object.entries(a).find(([v])=>v.toUpperCase()===c.toUpperCase()))==null?void 0:m[1];return y?f=y(f):typeof f=="bigint"?f=f.toString():Array.isArray(f)?f=`[${f.map(v=>typeof v=="string"?`"${v}"`:String(v)).join(", ")}]`:typeof f=="object"&&f!==null&&(f=JSON.stringify(f)),(g??c)&&t.jsx(ni,{scope:"row",align:h??"left",children:d?d(f):f},`${p}_${c}`)})},p)})})}function Wt(e,n,i,r,s){const a=Array.isArray(e)?e:[e],[l]=a[0].data,p=new Date(l);return`<div style='minWidth: 160px;'>
8
+ <p style='font-weight: 600; line-height: 1; margin: 4px 0;'>${Gt({date:p,stepMultiplier:r,stepSize:n})}</p>
9
+ ${a.reduce((g,h)=>{if(h.value!==void 0&&h.value!==null){const d=`<div style='display: flex; flex-direction: row; align-items: center; justify-content: spread; height: 20px; gap: 8px;'>
10
10
  <div style='display: flex; flex-direction: row; align-items: center; margin: 4px 0;'>
11
11
  <div style='width: 8px; height: 8px; margin-right: 4px; border-radius: 50%; border: 2px solid ${String(h.color)}'></div>
12
12
  </div>
13
13
  <p style='line-height: 1; flex: 1; margin-left: 0.5em; min-width: 20px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; align-self: left;'>
14
14
  ${s&&h.seriesName?`${h.seriesName}</p>`:""}
15
15
  </p>
16
- <p style='line-height: 1; justify-self: flex-end;'>${r(h.data[1])}</p>
16
+ <p style='line-height: 1; justify-self: flex-end;'>${i(h.data[1])}</p>
17
17
  </div>`;g.push(d)}return g},[]).join("")}
18
- </div>`}var Ge=(e=>(e.LINE="line",e.BAR="bar",e))(Ge||{});function mt(e){if(typeof e=="object"&&typeof(e==null?void 0:e.getTime)=="function")return e.getTime();const n=new Date(e).getTime();if(isFinite(n))return n}function Gt(e){return typeof e=="object"&&typeof(e==null?void 0:e.getTime)=="function"?e:new Date(e)}function Re(e,n){var r,i;for(let s=0;s<n.length;s++){const l=n[s].name,a=s<n.length?(r=n[s+1])==null?void 0:r.name:l,p=s>0?(i=n[s-1])==null?void 0:i.name:l,c=Math.abs(l-a),g=Math.abs(l-p),h=l-g*.5,d=l+c*.5;if(isFinite(h)&&isFinite(d)){if(e>=h&&e<=d)return s}else if(isFinite(h)){if(e>=h)return s}else if(isFinite(d)&&e<=d)return s}}function fr(e){let n,r=0;for(const{name:i}of e)i!==n&&(n=i,r++);return r}function xr(e){const n=new Date(e),r=n.getDay(),i=n.getDate()-r+(r?1:-6);return n.setDate(i),n.setHours(0,0,0,0),n.getTime()}var le=(e=>(e.YEARS="year",e.MONTHS="month",e.WEEKS="week",e.DAYS="day",e.HOURS="hour",e.MINUTES="minute",e.SECONDS="second",e))(le||{});const et={year:he,month:he,week:he,day:he,hour:jr,minute:yt,second:yt},mr={year:Cr,month:Mr,week:Tr,day:Ir,hour:kr,minute:Sr,second:br};function yr({date:e,stepSize:n}){const r=et[n];if(!r)throw new Error("formatTime: invalid stepSize");return r(e)}function Fe({start:e,end:n,stepSize:r}){if(e>n)return Fe({start:n,end:e,stepSize:r});const i=et[r];if(!i)throw new Error("formatTimeRange: missing formatter or invalid stepSize");const s=i(e),l=i(n);return`${s} - ${l}`}function Ht({date:e,stepSize:n,stepMultiplier:r}){if(!et[n])throw new Error("formatBucketRange: missing formatter or invalid stepSize");const{start:s,end:l}=wr({date:e,stepSize:n,stepMultiplier:r});if(r===1){if(n==="day")return yr({date:s,stepSize:n});if(n==="second")return`${he(s)} ${Ze(s)} - ${Ze(l)}`}return Fe({start:s,end:l,stepSize:n})}const tt=e=>1e3*e,nt=e=>tt(60*e),vr=e=>nt(60*e);function he(e){return e.toLocaleDateString()}function jr(e){return he(e)+" "+e.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit",hour12:!0})}function Ze(e){return e.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!0,second:"2-digit"})}function yt(e){return he(e)+" "+Ze(e)}function wr({date:e,stepSize:n,stepMultiplier:r=1}){const i=mr[n];if(!i)throw new Error("getBucketInterval: invalid bucket size");return i({date:e,stepMultiplier:r})}function br({date:e,stepMultiplier:n=1}){const r=new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),0),i=new Date(r.getTime()+tt(n-1)+999);return{start:r,end:i}}function Sr({date:e,stepMultiplier:n=1}){const r=new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),0,0),i=new Date(r.getTime()+nt(n-1)+tt(59));return{start:r,end:i}}function kr({date:e,stepMultiplier:n=1}){const r=new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),0,0,0),i=new Date(r.getTime()+vr(n-1)+nt(59));return{start:r,end:i}}function Ir({date:e,stepMultiplier:n=1}){const r=new Date(e.getFullYear(),e.getMonth(),e.getDate(),0,0,0,0),i=new Date(e.getFullYear(),e.getMonth(),e.getDate()+n-1);return{start:r,end:i}}function Tr({date:e,stepMultiplier:n=1}){const r=new Date(xr(e)),i=new Date(r.getFullYear(),r.getMonth(),r.getDate()+6+7*(n-1));return{start:r,end:i}}function Mr({date:e,stepMultiplier:n=1}){const r=new Date(e.getFullYear(),e.getMonth(),1),i=new Date(e.getFullYear(),e.getMonth()+n,0);return{start:r,end:i}}function Cr({date:e,stepMultiplier:n=1}){const r=new Date(e.getFullYear(),0,1),i=new Date(e.getFullYear()+(n-1),11,31);return{start:r,end:i}}const oe=()=>{},zt=u.createContext({isPlaying:!1,setIsPlaying:oe,isPaused:!1,setIsPaused:oe,timeWindow:[],setTimeWindow:oe,onTimeWindowUpdate:oe,togglePlay:oe,stop:oe,intl:{}});function He(){return u.useContext(zt)}function Yt({children:e,isPlaying:n,isPaused:r,onPlay:i=oe,onPause:s=oe,onStop:l=oe,timeWindow:a,onTimeWindowUpdate:p=oe,intl:c}){const[g,h]=u.useState(n),[d,v]=u.useState(r),[f,y]=u.useState([]),m=j.useImperativeIntl(c);u.useEffect(()=>{const k=f.sort((I,w)=>I<w?-1:1).map(Gt);p==null||p(k)},[f,p]);const x=u.useCallback(()=>{g&&(s&&s(),v(!0)),g||(i&&i(),v(!1)),h(k=>!k)},[g,s,i]),S=u.useCallback(()=>{h(!1),v(!1),y([])},[]),b=u.useCallback(()=>{S(),setTimeout(l)},[l,S]);return u.useEffect(()=>{n!==g&&h(n)},[n]),u.useEffect(()=>{r!==d&&v(r)},[r]),u.useEffect(()=>{if(!a)return;const k=a.map(mt),I=f.map(mt);(k[0]!==I[0]||k[1]!==I[1])&&y(k)},a),t.jsx(zt.Provider,{value:{isPlaying:!!g,setIsPlaying:h,isPaused:!!d,setIsPaused:v,timeWindow:f,setTimeWindow:y,onTimeWindowUpdate:p,togglePlay:x,stop:b,intl:m},children:e})}const vt={};let Pe=null;const Se={seriesId:"0"};function Vt({echartsInstance:e,data:n,canSelectLines:r,filterable:i}){const s=o.useTheme(),{isPlaying:l,isPaused:a,setIsPaused:p,timeWindow:c,setTimeWindow:g,stop:h}=He(),[d,v]=u.useState(!1),[f,y]=u.useState(!1),[m,x]=u.useState(!1),[S,b]=u.useState(0),k=u.useMemo(()=>e==null?void 0:e.getZr(),[e]),I=u.useCallback(D=>k==null?void 0:k.setCursorStyle(D),[k]),w=u.useCallback(D=>{if(e){const[B]=e.convertFromPixel(Se,[D.offsetX,D.offsetY]),P=Re(B,n);g(P!==void 0?[n[P].name]:[])}},[n,e,g]);u.useEffect(()=>{function D(B){i&&(r&&B.target||(c.length||(w(B),!a&&!l&&p(!0)),c.length===2&&(g([]),h())))}return Le(k,"click",D)},[k,a,l,p,g,h,c.length,w,r,i]),u.useEffect(()=>{function D(B){var P;if(i){if(((P=B.target)==null?void 0:P.type)==="ec-line"){v(!0),I("grabbing");return}if(c.length===2){const[L]=e.convertFromPixel(Se,[B.offsetX,B.offsetY]);if(L>=c[0]&&L<=c[1]){x(!0);const N=L-c[0];b(N);return}}if(e){y(!0);const[L]=e.convertFromPixel(Se,[B.offsetX,B.offsetY]);Pe=L;return}}}return Le(k,"mousedown",D)},[k,e,c,I,i]),u.useEffect(()=>{function D(B){var P;if(((P=B==null?void 0:B.target)==null?void 0:P.type)==="polygon"&&I("move"),d&&e&&(w(B),I("grabbing")),f&&e){const[L]=e.convertFromPixel(Se,[B.offsetX,B.offsetY]);g(Pe===L?[]:[Pe,L])}}return Le(k,"mousemove",D)},[k,e,f,d,g,I,w]),u.useEffect(()=>{function D(B){if(d&&(v(!1),I("default")),f&&(y(!1),Pe=null,c.length===1&&g([])),m&&e){const[P]=e.convertFromPixel(Se,[B.offsetX,B.offsetY]),L=P-c[0];if(S){const N=L-S;g([c[0]+N,c[1]+N])}x(!1)}}return Le(k,"mouseup",D)},[k,e,m,f,d,S,g,c,I]),u.useEffect(()=>{!i&&c.length&&g([])},[i,g,c.length]);const C=u.useMemo(()=>{var L;if(c.length!==1)return;const D=c[0],B=Re(D,n);if(B===void 0)return;const P=(L=n[B])==null?void 0:L.name;return P!==void 0&&{symbol:["none","none"],animationDuration:100,animationDurationUpdate:150,animationEasingUpdate:"linear",data:a||l?[{label:{show:!1},emphasis:{label:{show:!1}},xAxis:P,lineStyle:{type:"solid",color:s.palette.primary.main,width:1.5,shadowColor:s.palette.primary.light,shadowBlur:3}}]:[]}},[n,a,l,s,c]),A=u.useMemo(()=>c.length===2&&{data:[[{coord:[c[0]]},{coord:[c[1]]}]],itemStyle:{color:s.palette.primary.main,opacity:.2}},[s,c]);return{timelineOptions:C,timeWindowOptions:A}}function Le(e,n,r){if(e!=null&&e.handler)return vt[n]=r,e.on(n,r),()=>{vt[n]&&(e!=null&&e.handler)&&e.off(n,r)}}const Ut=j.SPACING*22,qt="100%",Ar=5,Er=3,Br=j.SPACING*20;function Pr({chartType:e,formatter:n,timeAxisSplitNumber:r,tooltip:i,tooltipFormatter:s,data:l,series:a,categories:p,height:c,fitHeight:g,animation:h,filterable:d,selectedCategories:v,onCategoryClick:f,yAxisType:y}){const m=o.useTheme(),[x,S]=u.useState(),b=T=>S(T),[k,I]=u.useState(),w=u.useMemo(()=>a.reduce((T,{data:O})=>O.reduce((M,$)=>$[1]>M?$[1]:M,T),Number.MIN_VALUE),[a]),C=u.useMemo(()=>({show:i,trigger:"axis",appendToBody:!0,padding:[j.SPACING*.5,j.SPACING],textStyle:{...m.typography.caption,fontSize:11,color:m.palette.common.white},borderWidth:0,backgroundColor:m.palette.black[90],position:(T,O,M,$,G)=>{const R={top:0};return G.contentSize[0]<G.viewSize[0]-T[0]?R.left=T[0]+j.SPACING*1.5:R.right=G.viewSize[0]-T[0]+j.SPACING*1.5,R},...s?{formatter:s}:{}}),[m,i,s]),A=u.useMemo(()=>{const T={margin:0,verticalAlign:"bottom",padding:[0,0,j.SPACING*1.25,0],inside:!0,color:$=>{let G="transparent";return $>=w&&(G=m.palette.black[60]),G}},O={margin:0,verticalAlign:"middle",padding:[0,j.SPACING*.75,0,0],color:m.palette.black[60]},M=y==="dense"?T:O;return{axisPointer:{lineStyle:{color:m.palette.black[40]}},xAxis:{type:"time",axisLine:{show:!0,lineStyle:{color:m.palette.grey[900],opacity:.2}},axisLabel:{fontWeight:m.typography.fontWeightRegular,fontSize:m.typography.caption.fontSize,fontFamily:m.typography.caption.fontFamily,lineHeight:m.typography.caption.lineHeight*8,letterSpacing:m.typography.caption.letterSpacing,formatter:{year:"{yearStyle|{yyyy}}"},rich:{yearStyle:{fontWeight:m.typography.fontWeightMedium,fontSize:m.typography.caption.fontSize,fontFamily:m.typography.caption.fontFamily,letterSpacing:m.typography.caption.letterSpacing,lineHeight:m.typography.caption.lineHeight*8}}},axisTick:{show:!1},splitNumber:r??(k!==void 0?Math.min(Er,Math.ceil(k/Br)):Ar)},yAxis:{type:"value",axisLabel:{show:!0,showMaxLabel:!0,showMinLabel:!1,...M,...n?{formatter:$=>n($)}:{},fontWeight:m.typography.fontWeightRegular,fontSize:m.typography.overlineDelicate.fontSize,fontFamily:m.typography.overlineDelicate.fontFamily,lineHeight:m.typography.overlineDelicate.lineHeight*8,letterSpacing:m.typography.overlineDelicate.letterSpacing},axisLine:{show:!1},axisTick:{show:!1},splitLine:{show:!0,onZero:!1,lineStyle:{color:m.palette.black[4]}},max:w}}},[m,w,n,k,r,y]),{timelineOptions:D,timeWindowOptions:B}=Vt({echartsInstance:x,data:l,canSelectLines:!!f,filterable:d}),P=u.useMemo(()=>a.map(({data:T,color:O,name:M},$)=>{const G=v&&v.length>0,R=G&&v.includes(M),H=!G||R?O:m.palette.action.disabledBackground;return{id:String($),name:M,markLine:$===0?D:void 0,markArea:$===0?B:void 0,animation:h,data:T,type:e,smooth:!0,color:H,z:G&&R?10:0,lineStyle:{width:2},showSymbol:!1,emphasis:{scale:2,lineStyle:{width:2,color:H}}}}),[a,D,B,h,e,v,m]),L=u.useMemo(()=>({grid:{left:j.SPACING*(y==="dense"?2:3.5),top:j.SPACING*4,right:j.SPACING*2,bottom:j.SPACING*3},color:[m.palette.secondary.main],tooltip:C,...A,series:P}),[A,P,y,m.palette.secondary.main,C]),V={click:u.useCallback(T=>{if(p&&f&&T.componentType==="series"){const O=p[T.seriesIndex];f(O)}},[p,f])};u.useEffect(()=>{var M;if(typeof ResizeObserver>"u"||!x)return;const T=(M=x==null?void 0:x.getDom())==null?void 0:M.parentElement;if(!T)return;const O=new ResizeObserver(()=>{I(T.clientWidth),x.resize()});return O.observe(T),()=>{O.disconnect()}},[x]);const _=g?qt:c??Ut;return u.useLayoutEffect(()=>{var O;const T=(O=x==null?void 0:x.getDom())==null?void 0:O.parentElement;T&&I(T.clientWidth),x==null||x.resize()},[_,g,x]),t.jsx(ye,{option:L,onEvents:V,onChartReady:b,style:{height:_}})}const Lr={[le.YEARS]:60*60*24*7,[le.MONTHS]:60*60*24,[le.WEEKS]:60*60*24,[le.DAYS]:60*60*12,[le.HOURS]:60*60,[le.MINUTES]:60*15,[le.SECONDS]:1},Dr=[.5,1,2,3];function Nr({data:e,stepSize:n}){const[r,i]=u.useState(null),[s,l]=u.useState(1),a=u.useRef({animationFrameId:null,timeoutId:null}),{isPlaying:p,isPaused:c,timeWindow:g,setTimeWindow:h,stop:d,togglePlay:v,intl:f}=He();Wr(()=>(p||c)&&d(),[e]);const y=()=>{const{animationFrameId:I,timeoutId:w}=a.current;I&&window.cancelAnimationFrame(I),w&&clearTimeout(w)},m=u.useCallback(()=>{y(),d()},[d]),x=()=>{y(),v()};u.useEffect(()=>{if(p&&g.length===2&&e.length){const w=Lr[n]*1e3;return _r({data:e,timeWindow:g,msTimeWindowStep:w*s,drawFrame:C=>{h(C)},onEnd:()=>{setTimeout(m,250)},animationRef:a}),()=>y()}},[e,p,n,h,m,s]),u.useEffect(()=>{if(p&&g.length===1&&e.length)return Hr({speed:s,timelinePosition:g[0],data:e,drawFrame:I=>{h([I])},onEnd:()=>{setTimeout(m,250)},animationRef:a}),()=>y();p&&g.length===0&&h([e[0].name])},[e,p,s,g.length,m]);const S=I=>{I!=null&&I.currentTarget&&i(I.currentTarget)},b=()=>{i(null)},k=I=>{l(I),b()};return t.jsxs(t.Fragment,{children:[t.jsx(o.IconButton,{size:"small",color:"default",onClick:S,"data-testid":"clock",children:t.jsx($r,{})}),t.jsxs(o.Menu,{anchorEl:r,keepMounted:!0,open:!!r,onClose:b,children:[t.jsx(o.MenuItem,{disabled:!0,children:t.jsx(j.Typography,{variant:"caption",color:"textSecondary",children:f.formatMessage({id:"c4r.widgets.timeSeries.speed"})})}),Dr.map(I=>t.jsxs(o.MenuItem,{selected:I===s,onClick:()=>k(I),children:[I,"x"]},I))]}),t.jsx(o.Box,{mt:2,children:t.jsx(o.IconButton,{size:"small",color:"primary",disabled:!(c||p),onClick:m,"data-testid":"stop",children:t.jsx(Rr,{})})}),t.jsx(o.Box,{mt:.75,children:t.jsx(o.IconButton,{"data-testid":"play-pause",size:"small",color:"primary",onClick:x,children:p?t.jsx(Fr,{}):t.jsx(Or,{})})})]})}function $r(){return t.jsx(o.SvgIcon,{viewBox:"0 0 20 20",children:t.jsx("path",{d:"M12.5 1.254h-5v1.667h5V1.254zM9.167 12.088h1.666v-5H9.167v5zm6.691-5.517 1.184-1.183a9.207 9.207 0 0 0-1.175-1.175l-1.184 1.183A7.468 7.468 0 0 0 10 3.746a7.5 7.5 0 0 0-7.5 7.5c0 4.141 3.35 7.5 7.5 7.5s7.5-3.358 7.5-7.5a7.504 7.504 0 0 0-1.642-4.675zM10 17.088a5.83 5.83 0 0 1-5.833-5.834A5.83 5.83 0 0 1 10 5.421a5.83 5.83 0 0 1 5.833 5.833A5.83 5.83 0 0 1 10 17.087z",id:"-↳Color",fill:"inherit"})})}function Or(){return t.jsx(o.SvgIcon,{"data-testid":"play-icon",children:t.jsx("path",{d:"M10 16.5l6-4.5-6-4.5v9zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z",id:"-↳Color",fill:"inherit"})})}function Rr(){return t.jsx(o.SvgIcon,{children:t.jsx("path",{d:"M12 2c5.52 0 10 4.48 10 10s-4.48 10-10 10S2 17.52 2 12 6.48 2 12 2zm0 2c-4.41 0-8 3.59-8 8s3.59 8 8 8 8-3.59 8-8-3.59-8-8-8zm4 4v8H8V8h8zm-2 2h-4v4h4v-4z",id:"-↳Color",fill:"inherit"})})}function Fr(){return t.jsx(o.SvgIcon,{"data-testid":"pause-icon",children:t.jsx("path",{d:"M9,16 L11,16 L11,8 L9,8 L9,16 Z M12,2 C6.48,2 2,6.48 2,12 C2,17.52 6.48,22 12,22 C17.52,22 22,17.52 22,12 C22,6.48 17.52,2 12,2 Z M12,20 C7.59,20 4,16.41 4,12 C4,7.59 7.59,4 12,4 C16.41,4 20,7.59 20,12 C20,16.41 16.41,20 12,20 Z M13,16 L15,16 L15,8 L13,8 L13,16 Z",id:"-↳Color",fill:"inherit"})})}function Wr(e,n=[]){const r=u.useRef(!1);u.useEffect(()=>{r.current?e():r.current=!0},n)}function _r({msTimeWindowStep:e,timeWindow:n,data:r,drawFrame:i,onEnd:s,animationRef:l}){let a=n;const p=()=>{l.current.animationFrameId=window.requestAnimationFrame(c)},c=()=>{a=[a[0]+e,a[1]+e],a[1]>r[r.length-1].name?s():(i(a),p())};p()}const Gr=2;function Hr({speed:e,timelinePosition:n,data:r,drawFrame:i,onEnd:s,animationRef:l}){let a=Re(n,r)??0,p=r[a].name;const c=fr(r),g=Math.max(Math.round(Math.sqrt(c)/2),Gr)*e,h=()=>{l.current.timeoutId=setTimeout(()=>{l.current.animationFrameId=window.requestAnimationFrame(d)},1e3/g)},d=()=>{for(;a<r.length;a++){const v=r[a].name;if(v!==p){p=v;break}}a===r.length?s():(i(p),h())};h()}const zr=o.styled(o.Box)(()=>({containerType:"inline-size",display:"flex",flexDirection:"column"})),Yr=o.styled(o.Box)(()=>({display:"flex",flexDirection:"column"})),Kt=o.styled(o.Box)(()=>({display:"flex",flexDirection:"row"})),Vr=o.styled(Kt)(()=>({alignItems:"center",justifyContent:"space-between"})),Ur=o.styled(o.Box)(({theme:e})=>({flexShrink:0,marginLeft:0,paddingLeft:e.spacing(1),[`@container (max-width: ${j.BREAKPOINTS.XS}px)`]:{paddingLeft:0},paddingBottom:e.spacing(1.5),alignSelf:"flex-end"})),qr=o.styled(o.Box)(({theme:e})=>({alignSelf:"normal",minWidth:0,paddingLeft:e.spacing(5),paddingBottom:e.spacing(1.5),[`@container (max-width: ${j.BREAKPOINTS.XS}px)`]:{paddingLeft:e.spacing(1)}}));function Xt({fitHeight:e,header:n,controls:r,chart:i,legend:s}){const l=s&&t.jsx(o.Box,{flex:0,mt:2,children:s});return t.jsxs(zr,{style:{flex:e?"1":void 0},children:[t.jsx(Vr,{flex:0,children:n}),r?t.jsxs(Yr,{flex:1,children:[t.jsxs(Kt,{flex:1,children:[t.jsx(Ur,{flex:0,children:r}),t.jsx(qr,{flex:1,children:i})]}),l]}):t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{pb:1.5,flex:1,children:i}),l]})]})}const Kr=e=>t.jsx(o.SvgIcon,{width:"720",height:"124",viewBox:"0 0 720 124",...e,children:t.jsx("path",{d:"M0.74707 123C11.8168 119.656 26.7934 118.37 53.4909 102.164C73.1959 90.2031 92.5604 81.3284 108.188 76.6983C122.841 72.357 136.188 74.3832 144.653 75.1549C150.496 75.6876 195.443 82.8718 207.164 83.6435C218.885 84.4152 241.676 87.502 274.234 80.5567C306.791 73.6115 305.869 75.4585 330.233 67.438C388.837 48.1456 433.461 2.6348 458.511 1.07229C495.627 -1.24279 512.557 52.7758 539.255 58.1776C565.952 63.5795 583.534 64.3512 601.766 55.0909C619.999 45.8305 625.859 40.4287 646.045 38.1136C666.231 35.7985 683.812 41.972 718.975 70.5247",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})}),Xr=o.styled(o.Box)(()=>({display:"flex",flexDirection:"column",justifyContent:"flex-end"})),Zr=o.styled(o.Box)(()=>({position:"relative",height:"100%",alignSelf:"normal",display:"flex",flexDirection:"column",justifyContent:"flex-end"})),Jr=o.styled(o.Box)(({theme:e})=>({padding:e.spacing(2.25,0,.5,2)})),Qr=o.styled(Pt)(({theme:e})=>({flexDirection:"column",flex:1,height:"100%",overflow:"hidden",svg:{height:"100%",width:"100%",fontSize:"initial",fill:"none",path:{stroke:e.palette.black[8]}}})),ei=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",justifyContent:"space-between",padding:e.spacing(1.25,.5,.75,.5)})),ti=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",gap:e.spacing(2),margin:0,padding:e.spacing(1.5,1,.25,1)})),jt=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",gap:e.spacing(1)})),ni=({fitHeight:e,height:n,showControls:r,showLegend:i})=>{const s=t.jsx(o.Box,{pt:1.25,pb:.75,children:t.jsx(o.Skeleton,{width:48,height:8})}),l=r&&t.jsxs(Xr,{children:[t.jsx(o.Box,{p:.5,children:t.jsx(o.Skeleton,{width:16,height:16})}),t.jsx(o.Box,{mt:2,p:.5,children:t.jsx(o.Skeleton,{width:16,height:16})}),t.jsx(o.Box,{mt:1,p:.5,children:t.jsx(o.Skeleton,{width:16,height:16})})]}),a=e?qt:n??Ut,p=t.jsxs(Zr,{style:{height:a},children:[t.jsx(Jr,{flex:0,children:t.jsx(o.Skeleton,{width:24,height:8})}),t.jsx(Qr,{flex:1,children:t.jsx(Kr,{preserveAspectRatio:"none"})}),t.jsxs(ei,{flex:0,children:[t.jsx(o.Skeleton,{width:32,height:8}),t.jsx(o.Skeleton,{width:32,height:8})]})]}),c=i&&t.jsxs(ti,{children:[t.jsxs(jt,{children:[t.jsx(o.Skeleton,{width:8,height:8}),t.jsx(o.Skeleton,{width:48,height:8})]}),t.jsxs(jt,{children:[t.jsx(o.Skeleton,{width:8,height:8}),t.jsx(o.Skeleton,{width:48,height:8})]})]});return t.jsx(Xt,{fitHeight:!!e,header:s,controls:l,chart:p,legend:i&&c})},Zt=e=>e,Jt=[];function oi({data:e=Jt,categories:n,stepSize:r,stepMultiplier:i=1,chartType:s=Ge.LINE,timeAxisSplitNumber:l,tooltip:a=!0,tooltipFormatter:p=_t,formatter:c=Zt,height:g,fitHeight:h,showControls:d=!0,animation:v=!0,filterable:f=!0,onTimelineUpdate:y,timeWindow:m,timelinePosition:x,onTimeWindowUpdate:S,selectedCategories:b,onSelectedCategoriesChange:k,isPlaying:I=!1,onPlay:w,isPaused:C=!1,onPause:A,onStop:D,isLoading:B=!1,palette:P=Object.values(Me.commonPalette.qualitative.bold),showLegend:L,yAxisType:N="dense"}){const V=u.useRef([]),_=Z.useIntl(),{showSkeleton:T}=ce(!!B),O=u.useCallback(M=>{var $,G;if(M.length===2){(($=V.current)==null?void 0:$.length)===1&&(y==null||y(void 0));const R=M.sort((H,U)=>H<U?-1:1).map(Gt);S==null||S(R)}if(M.length===1){((G=V.current)==null?void 0:G.length)===2&&(S==null||S([]));const R=Re(Number(M[0]),e);y==null||y(R)}V.current=M},[S,y,e]);return T?t.jsx(ni,{fitHeight:h,height:g,showControls:d,showLegend:L}):t.jsx(Yt,{isPlaying:I,onPlay:w,isPaused:C,onPause:A,onStop:D,timeWindow:m,onTimeWindowUpdate:O,intl:_,children:t.jsx(ri,{data:e,categories:n,stepSize:r,stepMultiplier:i,chartType:s,timeAxisSplitNumber:l,tooltip:a,tooltipFormatter:p,formatter:c,height:g,fitHeight:h,showControls:d,animation:v,filterable:f,palette:P,showLegend:L,selectedCategories:b,timelinePosition:x,onSelectedCategoriesChange:k,yAxisType:N})})}function ri({data:e=Jt,categories:n,stepSize:r,stepMultiplier:i=1,chartType:s=Ge.LINE,timeAxisSplitNumber:l,tooltip:a=!0,tooltipFormatter:p=_t,formatter:c=Zt,height:g,fitHeight:h=!1,showControls:d=!0,animation:v=!0,filterable:f=!0,palette:y=Object.values(Me.commonPalette.qualitative.bold),selectedCategories:m=[],onSelectedCategoriesChange:x,showLegend:S,timelinePosition:b,yAxisType:k="dense"}){const I=o.useTheme(),w=I.palette.secondary.main,{isPlaying:C,isPaused:A,timeWindow:D,stop:B,setTimeWindow:P,intl:L}=He();u.useEffect(()=>{if(b!==void 0){if(b<0||b>=e.length)return;const F=e[b].name;P([F])}},[b,e]),u.useEffect(()=>{if(!e.length)return;const F=e[0].name,z=e[e.length-1].name;(D[0]<F||D[1]>z||D[1]<F||D[1]>z)&&P([])},[e]);const N=u.useMemo(()=>{const F={},z=n?n.map(Q=>({name:Q,data:[],color:Me.getColorByCategory(Q,{palette:y,fallbackColor:w,colorMapping:F})})):[{name:"",data:[],color:I.palette.secondary.main}];for(const{name:Q,value:de,category:re,categoryIndex:W}of e){const q=W??(n&&re?n.indexOf(re):0);q===-1||n&&q>=n.length||!Number.isFinite(q)||z[q].data.push([Q,de])}return z},[n,e,y,w,I.palette.secondary.main]),V=u.useMemo(()=>{if(!e.length)return"";if(D.length===2){const[F,z]=D.map(Q=>new Date(Q));return Fe({start:F,end:z,stepSize:r})}if(!C&&!A){const F=new Date(e[0].name),z=new Date(e[e.length-1].name);return Fe({start:F,end:z,stepSize:r})}if(D.length===1){const F=new Date(D[0]);return Ht({date:F,stepSize:r,stepMultiplier:i})}},[e,D,C,A,r,i]),_=u.useMemo(()=>C||A||D.length>0||(m==null?void 0:m.length)>0,[A,C,m==null?void 0:m.length,D.length]),T=()=>{B(),P([]),x==null||x([])},O=F=>{F.key==="Enter"&&T()},M=u.useCallback(F=>{if(x){const z=[...m],Q=z.indexOf(F);Q===-1?z.push(F):z.splice(Q,1),x(z)}},[x,m]),$=!!(S??N.length>1),G=t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{children:t.jsx(j.Typography,{color:"textSecondary",variant:"caption",children:V??"-"})}),f&&_&&t.jsx(o.Link,{variant:"caption",style:{cursor:"pointer"},onClick:T,onKeyDown:O,tabIndex:0,underline:"hover",children:L.formatMessage({id:"c4r.widgets.timeSeries.clear"})})]}),R=f&&d&&t.jsx(Nr,{data:e,stepSize:r}),H=t.jsx(Pr,{chartType:s,timeAxisSplitNumber:l,data:e,series:N,categories:n,tooltip:a,formatter:c,tooltipFormatter:F=>p(F,r,c,i,$),height:g,fitHeight:h,animation:v,filterable:f,selectedCategories:m,onCategoryClick:x&&M,yAxisType:k}),U=$&&t.jsx(Wt,{series:N,selectedCategories:m,onCategoryClick:x&&M});return t.jsx(Xt,{fitHeight:h,header:G,controls:R,chart:H,legend:U})}const ii=o.styled("div")(({theme:e})=>({padding:e.spacing(2,0),...e.typography.body2})),si=o.styled(o.Box)(({theme:e})=>({overflow:"auto",maxHeight:e.spacing(40),paddingRight:e.spacing(1),margin:e.spacing(.5,0)})),li=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",flexWrap:"wrap",gap:e.spacing(1.5),padding:e.spacing(2,0)})),Qt=o.styled(o.Box)(({theme:e,alignItems:n="center"})=>({display:"flex",alignItems:n,gap:e.spacing(.75)})),en=o.styled("div",{shouldForwardProp:e=>e!=="color"})(({theme:e,color:n})=>({flexShrink:0,width:e.spacing(1),height:e.spacing(1),borderRadius:e.spacing(1),backgroundColor:n})),ai=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(2)})),ci=o.styled("div")(({theme:e})=>({height:e.spacing(.5),width:"100%",borderRadius:e.spacing(.5),backgroundColor:e.palette.action.disabledBackground,"& div":{width:0,height:"100%",borderRadius:e.spacing(.5),transition:`background-color ${e.transitions.easing.sharp} ${e.transitions.duration.shortest}ms,
19
- width ${e.transitions.easing.sharp} ${e.transitions.duration.complex}ms`}})),wt=o.styled(o.Box,{shouldForwardProp:e=>e!=="center"})(({theme:e,center:n=!1})=>({marginBottom:e.spacing(2),paddingRight:e.spacing(1),...n&&{display:"flex",justifyContent:"space-between",alignItems:"center"},"& .MuiTypography-caption":{color:e.palette.text.secondary},"& .MuiButton-label":{...e.typography.caption},"& a":{cursor:"pointer"}})),di=o.styled(o.Tooltip)(({theme:e})=>({".MuiTooltip-tooltip":{color:e.palette.common.white,maxWidth:260,marginBottom:0,overflow:"hidden"}})),ui=o.styled(o.TextField)(({theme:e})=>({marginTop:e.spacing(-.5)}));o.styled(o.Box)(()=>({display:"flex",flexWrap:"nowrap",justifyContent:"space-between"}));const pi=o.styled("div",{shouldForwardProp:e=>e!=="filterable"})(({filterable:e})=>({"& .progressbar div":{backgroundColor:"var(--color)"},...e&&{cursor:"pointer","& .MuiBox-root:hover .progressbar div":{backgroundColor:"var(--hover-color)"}}})),gi=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",flexWrap:"nowrap",overflow:"hidden",gap:e.spacing(1)})),hi=o.styled(o.Box)(({theme:e})=>({padding:e.spacing(.5,0),flexGrow:"1",maxWidth:"100%",minWidth:0})),fi=o.styled(o.Box,{shouldForwardProp:e=>e!=="backgroundColor"})(({theme:e,backgroundColor:n})=>({marginLeft:e.spacing(1),padding:e.spacing(0,1),backgroundColor:n,color:"white",borderRadius:e.spacing(2)}));function xi(e,n,r,i,s){const a=(e[0]??[]).map((p,c)=>{const g=String(p.name),h=i.length>0&&!i.includes(g),d=r[c]??g,v=e.map((f,y)=>{var m;return{color:h?Et.lighten(n[y],.8):n[y],value:((m=f[c])==null?void 0:m.value)??0}});return{label:d,key:g,data:v}});return s===pe.RANKING&&a.sort((p,c)=>{const g=Math.max(...p.data.map(d=>d.value));return Math.max(...c.data.map(d=>d.value))-g}),a}const mi=500;function yi(e,n={}){const{disabled:r,duration:i,animateOnMount:s,initialValue:l=0}=n,a=u.useRef(null),[p,c]=u.useState(()=>s?l:e);return u.useEffect(()=>(r?c(e):Ke({start:p,end:e,duration:i??mi,drawFrame:g=>c(g),requestRef:a}),()=>{a.current&&cancelAnimationFrame(a.current)}),[e,r,i]),p}const vi={};function tn({enabled:e=!0,value:n=0,options:r=vi,formatter:i}){const l=yi(n||0,{...{animateOnMount:!0,disabled:e===!1||n===null||n===void 0},...r});return t.jsx("span",{children:i?i(l):l})}const Je=e=>e,ji=()=>{},wi=[];function bi({item:e,index:n=0,names:r=wi,formatter:i=Je}){const s=o.useTheme(),l=e.data[0],a=e.data[n],p=r[n],c=(a.value-l.value)/(l.value||1)*100,g=Math.sign(c)===-1?"-":"+",h=Math.sign(c)===-1?s.palette.error.main:s.palette.success.main,d=e.key===me?s.palette.text.disabled:h;return t.jsxs("div",{children:[t.jsx(o.Typography,{color:"inherit",variant:"caption",noWrap:!0,children:e.label}),t.jsx(o.Box,{pt:1,pb:.5,children:t.jsxs(Qt,{alignItems:"baseline",children:[t.jsx(en,{color:e.key===me?s.palette.background.default:a.color}),t.jsx(o.Typography,{color:"inherit",variant:"caption",children:p}),t.jsx(o.Box,{style:{flexGrow:1}}),t.jsx(fi,{backgroundColor:d,children:t.jsxs(o.Typography,{color:"inherit",variant:"caption",children:[g,i(Math.abs(c))]})})]})})]})}function Si({item:e,animation:n=!0,animationOptions:r,maxValue:i,showCheckbox:s,checkboxChecked:l,formatter:a=Je,tooltipFormatter:p=Je,onClick:c=ji,names:g,tooltip:h}){function d(f){return`${Math.min(100,(f||0)/i*100)}%`}const v=f=>t.jsx(bi,{item:e,names:g,formatter:p,index:f});return t.jsxs(gi,{onClick:()=>c(e.key),children:[s?t.jsx(o.Checkbox,{checked:l}):null,t.jsxs(hi,{children:[t.jsx(o.Typography,{variant:"body2",noWrap:!0,children:e.label}),e.data.map((f,y)=>t.jsx(di,{title:v(y),placement:"top-start",arrow:!1,disableHoverListener:!h,children:t.jsxs(ai,{children:[t.jsx(ci,{className:"progressbar",children:t.jsx("div",{style:{"--hover-color":o.darken(f.color,.2),"--color":f.color,width:d(f.value)}})}),t.jsx(o.Typography,{variant:y===0?"body2":"caption",color:y===0?"textPrimary":"textSecondary",children:t.jsx(tn,{value:f.value,enabled:n,options:r,formatter:a})})]})},`${e.key}_${y}`))]})]})}const bt=e=>e,ki=()=>{},ke=[];function Ii({names:e=ke,data:n=ke,labels:r=ke,colors:i=ke,maxItems:s=5,order:l=pe.FIXED,animation:a=!0,animationOptions:p,searchable:c=!0,filterable:g=!0,selectedCategories:h=ke,onSelectedCategoriesChange:d=ki,formatter:v=bt,tooltipFormatter:f=bt,tooltip:y=!0,isLoading:m=!1}){const x=o.useTheme(),[S,b]=u.useState(!1),[k,I]=u.useState(!1),[w,C]=u.useState(h),[A,D]=u.useState(""),B=Z.useIntl(),P=j.useImperativeIntl(B),L=u.useMemo(()=>{const W=i.length?i:[x.palette.secondary.main,x.palette.primary.main,x.palette.info.main];return xi(n,W,r,h,l)},[n,i,r,x,h,l]),N=u.useMemo(()=>Math.max(...n.map(W=>W.map(q=>q.value??0)).flat()),[n]),V=u.useMemo(()=>{if(s>=L.length)return L;const W=L.slice(0,s),q=L.slice(s),X=[];for(const ie of q)ie.data.forEach((Ce,ve)=>{X[ve]=X[ve]??0,X[ve]+=Ce.value});const J={key:me,label:c?"Others":`Others (${L.length-s})`,data:X.map(ie=>({value:ie,color:x.palette.divider}))};return[...W,J]},[L,c,s,x.palette.divider]),_=u.useMemo(()=>L.filter(W=>h.includes(W.key)),[L,h]),T=u.useMemo(()=>A?L.filter(W=>{const q=(W.key||"").toLowerCase(),X=(W.label||"").toLowerCase(),J=q==null?void 0:q.includes(A.toLowerCase()),ie=X==null?void 0:X.includes(A.toLowerCase());return J||ie}):L,[L,A]),O=L.length-V.length+1,M=c&&!S&&s<L.length;if(L.length===0||m)return t.jsx($t,{});const $=S?T:k?_:V;function G(){I(!0),d([...w]),z()}function R(){I(!1)}function H(){d([])}function U(){I(!0)}function F(){b(!0),C([...h])}function z(){b(!1),C([])}function Q(W){const q=h.includes(W),X=new Set(h);q?X.delete(W):X.add(W);let J=Array.from(X);J.length===L.length&&(J=[]),d(J)}function de(W){const q=w.includes(W),X=new Set(w);q?X.delete(W):X.add(W);let J=Array.from(X);J.length===L.length&&(J=[]),C(J)}const re=g?S?de:Q:void 0;return t.jsxs(ii,{children:[g?t.jsxs(wt,{center:!0,children:[t.jsx(j.Typography,{variant:"caption",children:h.length>0?P.formatMessage({id:"c4r.widgets.category.selectedItems"},{items:h.length}):P.formatMessage({id:"c4r.widgets.category.all"})}),t.jsx(j.Typography,{variant:"caption",children:S?t.jsx(o.Link,{onClick:G,children:P.formatMessage({id:"c4r.widgets.category.apply"})}):k?t.jsx(o.Link,{onClick:R,children:P.formatMessage({id:"c4r.widgets.category.unlock"})}):h.length?t.jsxs(o.Box,{style:{display:"flex",justifyContent:"flex-end",gap:x.spacing(1)},children:[t.jsx(o.Link,{onClick:U,children:P.formatMessage({id:"c4r.widgets.category.lock"})}),t.jsx(o.Divider,{orientation:"vertical",flexItem:!0}),t.jsx(o.Link,{onClick:H,children:P.formatMessage({id:"c4r.widgets.category.clear"})})]}):null})]}):null,S?t.jsx(wt,{children:t.jsx(ui,{size:"small",placeholder:P.formatMessage({id:"c4r.widgets.category.search"}),onChange:W=>D(W.currentTarget.value),onFocus:W=>W.currentTarget.scrollIntoView(),InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",children:t.jsx(Te.Search,{})})}})}):null,t.jsxs(si,{children:[$.length===0?t.jsxs(t.Fragment,{children:[t.jsx(j.Typography,{variant:"body2",children:P.formatMessage({id:"c4r.widgets.category.noResults"})}),t.jsx(j.Typography,{variant:"caption",children:P.formatMessage({id:"c4r.widgets.category.noResultsMessage"},{searchValue:A})})]}):null,$.map(W=>t.jsx(pi,{children:t.jsx(Si,{item:W,animation:a,animationOptions:p,maxValue:N,showCheckbox:g&&S,checkboxChecked:w.includes(W.key),formatter:v,tooltipFormatter:f,tooltip:y,onClick:re,names:e})},W.key))]}),M?t.jsx(o.Button,{size:"small",color:"primary",startIcon:t.jsx(Te.Search,{}),onClick:F,children:P.formatMessage({id:"c4r.widgets.category.searchInfo"},{elements:O})}):null,S?t.jsx(o.Button,{size:"small",color:"primary",onClick:z,children:P.formatMessage({id:"c4r.widgets.category.cancel"})}):null,t.jsx(li,{children:e.map((W,q)=>t.jsxs(Qt,{children:[t.jsx(en,{color:(i==null?void 0:i[q])??x.palette.background.default}),t.jsx(j.Typography,{variant:"overline",children:W})]},e[q]))})]})}const Ti=Et.styled(j.Typography)(({theme:e})=>({display:"inline-block",marginTop:e.spacing(.5)}));function Mi({row:e}){const n=o.useTheme();return e.label?t.jsx(o.Box,{color:e.color??n.palette.text.secondary,children:t.jsx(Ti,{color:"inherit",variant:"caption",children:e.label})}):null}const Ci=o.styled("div")(({theme:e})=>({margin:0,...e.typography.h5,fontWeight:Number(e.typography.fontWeightMedium),color:e.palette.text.primary,display:"flex"})),Ai=o.styled(j.Typography)(({theme:e})=>({marginRight:e.spacing(.5)})),Ei=o.styled(j.Typography)(({theme:e})=>({marginLeft:e.spacing(.5)}));function Bi({row:e,animated:n,animationOptions:r,formatter:i}){const s=o.useTheme(),{prefix:l,value:a,suffix:p,shouldBeHighlighted:c}=e;return t.jsxs(Ci,{children:[l?t.jsx(o.Box,{color:s.palette.text.secondary,children:t.jsx(Ai,{color:"inherit",component:"span",variant:"subtitle2",children:l})}):null,t.jsx(o.Box,{fontWeight:c?"bold":"",children:t.jsx(tn,{value:a,enabled:n,options:r,formatter:i})}),p?t.jsx(o.Box,{color:s.palette.text.secondary,children:t.jsx(Ei,{color:"inherit",component:"span",variant:"subtitle2",children:p})}):null]})}const Pi=e=>e,St=[],Li=o.styled("div")(({theme:e})=>({"&:nth-of-type(n+2)":{marginTop:e.spacing(2)}}));function Di({data:e=St,colors:n=St,animated:r=!0,animationOptions:i,formatter:s=Pi,isLoading:l=!1}){const a=Ni(e,n);return l?t.jsx(Rt,{}):t.jsx("div",{children:a.map((p,c)=>t.jsxs(Li,{children:[t.jsx(Bi,{row:p,animated:r,animationOptions:i,formatter:s}),t.jsx(Mi,{row:p})]},c))})}function Ni(e,n){const r=e.map((s,l)=>({...s,color:n[l],shouldBeHighlighted:!1})).filter(s=>s.value!==void 0);return r&&r.length>1&&(r[0].shouldBeHighlighted=!0),r}function $i(e,n=[],r=[],i,s=[]){return e.map((l,a)=>{const p=s.length>0&&!s.includes(l.name),g=(n!=null&&n.length?n:i.palette.qualitative.bold)[a];return{...l,key:l.name,color:p?o.lighten(g,.8):g,name:r[a]??l.name}})}function Oi(e,n,r){const i=`
18
+ </div>`}var Ge=(e=>(e.LINE="line",e.BAR="bar",e))(Ge||{});function mt(e){if(typeof e=="object"&&typeof(e==null?void 0:e.getTime)=="function")return e.getTime();const n=new Date(e).getTime();if(isFinite(n))return n}function _t(e){return typeof e=="object"&&typeof(e==null?void 0:e.getTime)=="function"?e:new Date(e)}function Re(e,n){var i,r;for(let s=0;s<n.length;s++){const a=n[s].name,l=s<n.length?(i=n[s+1])==null?void 0:i.name:a,p=s>0?(r=n[s-1])==null?void 0:r.name:a,c=Math.abs(a-l),g=Math.abs(a-p),h=a-g*.5,d=a+c*.5;if(isFinite(h)&&isFinite(d)){if(e>=h&&e<=d)return s}else if(isFinite(h)){if(e>=h)return s}else if(isFinite(d)&&e<=d)return s}}function ci(e){let n,i=0;for(const{name:r}of e)r!==n&&(n=r,i++);return i}function di(e){const n=new Date(e),i=n.getDay(),r=n.getDate()-i+(i?1:-6);return n.setDate(r),n.setHours(0,0,0,0),n.getTime()}var le=(e=>(e.YEARS="year",e.MONTHS="month",e.WEEKS="week",e.DAYS="day",e.HOURS="hour",e.MINUTES="minute",e.SECONDS="second",e))(le||{});const et={year:he,month:he,week:he,day:he,hour:hi,minute:yt,second:yt},ui={year:bi,month:wi,week:ji,day:vi,hour:yi,minute:mi,second:xi};function pi({date:e,stepSize:n}){const i=et[n];if(!i)throw new Error("formatTime: invalid stepSize");return i(e)}function Fe({start:e,end:n,stepSize:i}){if(e>n)return Fe({start:n,end:e,stepSize:i});const r=et[i];if(!r)throw new Error("formatTimeRange: missing formatter or invalid stepSize");const s=r(e),a=r(n);return`${s} - ${a}`}function Gt({date:e,stepSize:n,stepMultiplier:i}){if(!et[n])throw new Error("formatBucketRange: missing formatter or invalid stepSize");const{start:s,end:a}=fi({date:e,stepSize:n,stepMultiplier:i});if(i===1){if(n==="day")return pi({date:s,stepSize:n});if(n==="second")return`${he(s)} ${Ze(s)} - ${Ze(a)}`}return Fe({start:s,end:a,stepSize:n})}const tt=e=>1e3*e,nt=e=>tt(60*e),gi=e=>nt(60*e);function he(e){return e.toLocaleDateString()}function hi(e){return he(e)+" "+e.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit",hour12:!0})}function Ze(e){return e.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!0,second:"2-digit"})}function yt(e){return he(e)+" "+Ze(e)}function fi({date:e,stepSize:n,stepMultiplier:i=1}){const r=ui[n];if(!r)throw new Error("getBucketInterval: invalid bucket size");return r({date:e,stepMultiplier:i})}function xi({date:e,stepMultiplier:n=1}){const i=new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),0),r=new Date(i.getTime()+tt(n-1)+999);return{start:i,end:r}}function mi({date:e,stepMultiplier:n=1}){const i=new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),0,0),r=new Date(i.getTime()+nt(n-1)+tt(59));return{start:i,end:r}}function yi({date:e,stepMultiplier:n=1}){const i=new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),0,0,0),r=new Date(i.getTime()+gi(n-1)+nt(59));return{start:i,end:r}}function vi({date:e,stepMultiplier:n=1}){const i=new Date(e.getFullYear(),e.getMonth(),e.getDate(),0,0,0,0),r=new Date(e.getFullYear(),e.getMonth(),e.getDate()+n-1);return{start:i,end:r}}function ji({date:e,stepMultiplier:n=1}){const i=new Date(di(e)),r=new Date(i.getFullYear(),i.getMonth(),i.getDate()+6+7*(n-1));return{start:i,end:r}}function wi({date:e,stepMultiplier:n=1}){const i=new Date(e.getFullYear(),e.getMonth(),1),r=new Date(e.getFullYear(),e.getMonth()+n,0);return{start:i,end:r}}function bi({date:e,stepMultiplier:n=1}){const i=new Date(e.getFullYear(),0,1),r=new Date(e.getFullYear()+(n-1),11,31);return{start:i,end:r}}const ie=()=>{},Ht=u.createContext({isPlaying:!1,setIsPlaying:ie,isPaused:!1,setIsPaused:ie,timeWindow:[],setTimeWindow:ie,onTimeWindowUpdate:ie,togglePlay:ie,stop:ie,intl:{}});function He(){return u.useContext(Ht)}function zt({children:e,isPlaying:n,isPaused:i,onPlay:r=ie,onPause:s=ie,onStop:a=ie,timeWindow:l,onTimeWindowUpdate:p=ie,intl:c}){const[g,h]=u.useState(n),[d,y]=u.useState(i),[f,m]=u.useState([]),v=j.useImperativeIntl(c);u.useEffect(()=>{const k=f.sort((I,w)=>I<w?-1:1).map(_t);p==null||p(k)},[f,p]);const x=u.useCallback(()=>{g&&(s&&s(),y(!0)),g||(r&&r(),y(!1)),h(k=>!k)},[g,s,r]),S=u.useCallback(()=>{h(!1),y(!1),m([])},[]),b=u.useCallback(()=>{S(),setTimeout(a)},[a,S]);return u.useEffect(()=>{n!==g&&h(n)},[n]),u.useEffect(()=>{i!==d&&y(i)},[i]),u.useEffect(()=>{if(!l)return;const k=l.map(mt),I=f.map(mt);(k[0]!==I[0]||k[1]!==I[1])&&m(k)},l),t.jsx(Ht.Provider,{value:{isPlaying:!!g,setIsPlaying:h,isPaused:!!d,setIsPaused:y,timeWindow:f,setTimeWindow:m,onTimeWindowUpdate:p,togglePlay:x,stop:b,intl:v},children:e})}const vt={};let Pe=null;const Se={seriesId:"0"};function Yt({echartsInstance:e,data:n,canSelectLines:i,filterable:r}){const s=o.useTheme(),{isPlaying:a,isPaused:l,setIsPaused:p,timeWindow:c,setTimeWindow:g,stop:h}=He(),[d,y]=u.useState(!1),[f,m]=u.useState(!1),[v,x]=u.useState(!1),[S,b]=u.useState(0),k=u.useMemo(()=>e==null?void 0:e.getZr(),[e]),I=u.useCallback(D=>k==null?void 0:k.setCursorStyle(D),[k]),w=u.useCallback(D=>{if(e){const[B]=e.convertFromPixel(Se,[D.offsetX,D.offsetY]),L=Re(B,n);g(L!==void 0?[n[L].name]:[])}},[n,e,g]);u.useEffect(()=>{function D(B){r&&(i&&B.target||(c.length||(w(B),!l&&!a&&p(!0)),c.length===2&&(g([]),h())))}return Le(k,"click",D)},[k,l,a,p,g,h,c.length,w,i,r]),u.useEffect(()=>{function D(B){var L;if(r){if(((L=B.target)==null?void 0:L.type)==="ec-line"){y(!0),I("grabbing");return}if(c.length===2){const[P]=e.convertFromPixel(Se,[B.offsetX,B.offsetY]);if(P>=c[0]&&P<=c[1]){x(!0);const O=P-c[0];b(O);return}}if(e){m(!0);const[P]=e.convertFromPixel(Se,[B.offsetX,B.offsetY]);Pe=P;return}}}return Le(k,"mousedown",D)},[k,e,c,I,r]),u.useEffect(()=>{function D(B){var L;if(((L=B==null?void 0:B.target)==null?void 0:L.type)==="polygon"&&I("move"),d&&e&&(w(B),I("grabbing")),f&&e){const[P]=e.convertFromPixel(Se,[B.offsetX,B.offsetY]);g(Pe===P?[]:[Pe,P])}}return Le(k,"mousemove",D)},[k,e,f,d,g,I,w]),u.useEffect(()=>{function D(B){if(d&&(y(!1),I("default")),f&&(m(!1),Pe=null,c.length===1&&g([])),v&&e){const[L]=e.convertFromPixel(Se,[B.offsetX,B.offsetY]),P=L-c[0];if(S){const O=P-S;g([c[0]+O,c[1]+O])}x(!1)}}return Le(k,"mouseup",D)},[k,e,v,f,d,S,g,c,I]),u.useEffect(()=>{!r&&c.length&&g([])},[r,g,c.length]);const M=u.useMemo(()=>{var P;if(c.length!==1)return;const D=c[0],B=Re(D,n);if(B===void 0)return;const L=(P=n[B])==null?void 0:P.name;return L!==void 0&&{symbol:["none","none"],animationDuration:100,animationDurationUpdate:150,animationEasingUpdate:"linear",data:l||a?[{label:{show:!1},emphasis:{label:{show:!1}},xAxis:L,lineStyle:{type:"solid",color:s.palette.primary.main,width:1.5,shadowColor:s.palette.primary.light,shadowBlur:3}}]:[]}},[n,l,a,s,c]),C=u.useMemo(()=>c.length===2&&{data:[[{coord:[c[0]]},{coord:[c[1]]}]],itemStyle:{color:s.palette.primary.main,opacity:.2}},[s,c]);return{timelineOptions:M,timeWindowOptions:C}}function Le(e,n,i){if(e!=null&&e.handler)return vt[n]=i,e.on(n,i),()=>{vt[n]&&(e!=null&&e.handler)&&e.off(n,i)}}const Vt=j.SPACING*22,Ut="100%",Si=5,ki=3,Ii=j.SPACING*20;function Ti({chartType:e,formatter:n,timeAxisSplitNumber:i,tooltip:r,tooltipFormatter:s,data:a,series:l,categories:p,height:c,fitHeight:g,animation:h,filterable:d,selectedCategories:y,onCategoryClick:f,yAxisType:m}){const v=o.useTheme(),[x,S]=u.useState(),b=E=>S(E),[k,I]=u.useState(),w=u.useMemo(()=>l.reduce((E,{data:N})=>N.reduce((T,$)=>$[1]>T?$[1]:T,E),Number.MIN_VALUE),[l]),M=u.useMemo(()=>({show:r,trigger:"axis",appendToBody:!0,padding:[j.SPACING*.5,j.SPACING],textStyle:{...v.typography.caption,fontSize:11,color:v.palette.common.white},borderWidth:0,backgroundColor:v.palette.black[90],position:(E,N,T,$,G)=>{const F={top:0};return G.contentSize[0]<G.viewSize[0]-E[0]?F.left=E[0]+j.SPACING*1.5:F.right=G.viewSize[0]-E[0]+j.SPACING*1.5,F},...s?{formatter:s}:{}}),[v,r,s]),C=u.useMemo(()=>{const E={margin:0,verticalAlign:"bottom",padding:[0,0,j.SPACING*1.25,0],inside:!0,color:$=>{let G="transparent";return $>=w&&(G=v.palette.black[60]),G}},N={margin:0,verticalAlign:"middle",padding:[0,j.SPACING*.75,0,0],color:v.palette.black[60]},T=m==="dense"?E:N;return{axisPointer:{lineStyle:{color:v.palette.black[40]}},xAxis:{type:"time",axisLine:{show:!0,lineStyle:{color:v.palette.grey[900],opacity:.2}},axisLabel:{fontWeight:v.typography.fontWeightRegular,fontSize:v.typography.caption.fontSize,fontFamily:v.typography.caption.fontFamily,lineHeight:v.typography.caption.lineHeight*8,letterSpacing:v.typography.caption.letterSpacing,formatter:{year:"{yearStyle|{yyyy}}"},rich:{yearStyle:{fontWeight:v.typography.fontWeightMedium,fontSize:v.typography.caption.fontSize,fontFamily:v.typography.caption.fontFamily,letterSpacing:v.typography.caption.letterSpacing,lineHeight:v.typography.caption.lineHeight*8}}},axisTick:{show:!1},splitNumber:i??(k!==void 0?Math.min(ki,Math.ceil(k/Ii)):Si)},yAxis:{type:"value",axisLabel:{show:!0,showMaxLabel:!0,showMinLabel:!1,...T,...n?{formatter:$=>n($)}:{},fontWeight:v.typography.fontWeightRegular,fontSize:v.typography.overlineDelicate.fontSize,fontFamily:v.typography.overlineDelicate.fontFamily,lineHeight:v.typography.overlineDelicate.lineHeight*8,letterSpacing:v.typography.overlineDelicate.letterSpacing},axisLine:{show:!1},axisTick:{show:!1},splitLine:{show:!0,onZero:!1,lineStyle:{color:v.palette.black[4]}},max:w}}},[v,w,n,k,i,m]),{timelineOptions:D,timeWindowOptions:B}=Yt({echartsInstance:x,data:a,canSelectLines:!!f,filterable:d}),L=u.useMemo(()=>l.map(({data:E,color:N,name:T},$)=>{const G=y&&y.length>0,F=G&&y.includes(T),H=!G||F?N:v.palette.action.disabledBackground;return{id:String($),name:T,markLine:$===0?D:void 0,markArea:$===0?B:void 0,animation:h,data:E,type:e,smooth:!0,color:H,z:G&&F?10:0,lineStyle:{width:2},showSymbol:!1,emphasis:{scale:2,lineStyle:{width:2,color:H}}}}),[l,D,B,h,e,y,v]),P=u.useMemo(()=>({grid:{left:j.SPACING*(m==="dense"?2:3.5),top:j.SPACING*4,right:j.SPACING*2,bottom:j.SPACING*3},color:[v.palette.secondary.main],tooltip:M,...C,series:L}),[C,L,m,v.palette.secondary.main,M]),V={click:u.useCallback(E=>{if(p&&f&&E.componentType==="series"){const N=p[E.seriesIndex];f(N)}},[p,f])};u.useEffect(()=>{var T;if(typeof ResizeObserver>"u"||!x)return;const E=(T=x==null?void 0:x.getDom())==null?void 0:T.parentElement;if(!E)return;const N=new ResizeObserver(()=>{I(E.clientWidth),x.resize()});return N.observe(E),()=>{N.disconnect()}},[x]);const _=g?Ut:c??Vt;return u.useLayoutEffect(()=>{var N;const E=(N=x==null?void 0:x.getDom())==null?void 0:N.parentElement;E&&I(E.clientWidth),x==null||x.resize()},[_,g,x]),t.jsx(ye,{option:P,onEvents:V,onChartReady:b,style:{height:_}})}const Mi={[le.YEARS]:60*60*24*7,[le.MONTHS]:60*60*24,[le.WEEKS]:60*60*24,[le.DAYS]:60*60*12,[le.HOURS]:60*60,[le.MINUTES]:60*15,[le.SECONDS]:1},Ci=[.5,1,2,3];function Ai({data:e,stepSize:n}){const[i,r]=u.useState(null),[s,a]=u.useState(1),l=u.useRef({animationFrameId:null,timeoutId:null}),{isPlaying:p,isPaused:c,timeWindow:g,setTimeWindow:h,stop:d,togglePlay:y,intl:f}=He();Di(()=>(p||c)&&d(),[e]);const m=()=>{const{animationFrameId:I,timeoutId:w}=l.current;I&&window.cancelAnimationFrame(I),w&&clearTimeout(w)},v=u.useCallback(()=>{m(),d()},[d]),x=()=>{m(),y()};u.useEffect(()=>{if(p&&g.length===2&&e.length){const w=Mi[n]*1e3;return Ni({data:e,timeWindow:g,msTimeWindowStep:w*s,drawFrame:M=>{h(M)},onEnd:()=>{setTimeout(v,250)},animationRef:l}),()=>m()}},[e,p,n,h,v,s]),u.useEffect(()=>{if(p&&g.length===1&&e.length)return $i({speed:s,timelinePosition:g[0],data:e,drawFrame:I=>{h([I])},onEnd:()=>{setTimeout(v,250)},animationRef:l}),()=>m();p&&g.length===0&&h([e[0].name])},[e,p,s,g.length,v]);const S=I=>{I!=null&&I.currentTarget&&r(I.currentTarget)},b=()=>{r(null)},k=I=>{a(I),b()};return t.jsxs(t.Fragment,{children:[t.jsx(o.IconButton,{size:"small",color:"default",onClick:S,"data-testid":"clock",children:t.jsx(Ei,{})}),t.jsxs(o.Menu,{anchorEl:i,keepMounted:!0,open:!!i,onClose:b,children:[t.jsx(o.MenuItem,{disabled:!0,children:t.jsx(j.Typography,{variant:"caption",color:"textSecondary",children:f.formatMessage({id:"c4r.widgets.timeSeries.speed"})})}),Ci.map(I=>t.jsxs(o.MenuItem,{selected:I===s,onClick:()=>k(I),children:[I,"x"]},I))]}),t.jsx(o.Box,{mt:2,children:t.jsx(o.IconButton,{size:"small",color:"primary",disabled:!(c||p),onClick:v,"data-testid":"stop",children:t.jsx(Pi,{})})}),t.jsx(o.Box,{mt:.75,children:t.jsx(o.IconButton,{"data-testid":"play-pause",size:"small",color:"primary",onClick:x,children:p?t.jsx(Li,{}):t.jsx(Bi,{})})})]})}function Ei(){return t.jsx(o.SvgIcon,{viewBox:"0 0 20 20",children:t.jsx("path",{d:"M12.5 1.254h-5v1.667h5V1.254zM9.167 12.088h1.666v-5H9.167v5zm6.691-5.517 1.184-1.183a9.207 9.207 0 0 0-1.175-1.175l-1.184 1.183A7.468 7.468 0 0 0 10 3.746a7.5 7.5 0 0 0-7.5 7.5c0 4.141 3.35 7.5 7.5 7.5s7.5-3.358 7.5-7.5a7.504 7.504 0 0 0-1.642-4.675zM10 17.088a5.83 5.83 0 0 1-5.833-5.834A5.83 5.83 0 0 1 10 5.421a5.83 5.83 0 0 1 5.833 5.833A5.83 5.83 0 0 1 10 17.087z",id:"-↳Color",fill:"inherit"})})}function Bi(){return t.jsx(o.SvgIcon,{"data-testid":"play-icon",children:t.jsx("path",{d:"M10 16.5l6-4.5-6-4.5v9zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z",id:"-↳Color",fill:"inherit"})})}function Pi(){return t.jsx(o.SvgIcon,{children:t.jsx("path",{d:"M12 2c5.52 0 10 4.48 10 10s-4.48 10-10 10S2 17.52 2 12 6.48 2 12 2zm0 2c-4.41 0-8 3.59-8 8s3.59 8 8 8 8-3.59 8-8-3.59-8-8-8zm4 4v8H8V8h8zm-2 2h-4v4h4v-4z",id:"-↳Color",fill:"inherit"})})}function Li(){return t.jsx(o.SvgIcon,{"data-testid":"pause-icon",children:t.jsx("path",{d:"M9,16 L11,16 L11,8 L9,8 L9,16 Z M12,2 C6.48,2 2,6.48 2,12 C2,17.52 6.48,22 12,22 C17.52,22 22,17.52 22,12 C22,6.48 17.52,2 12,2 Z M12,20 C7.59,20 4,16.41 4,12 C4,7.59 7.59,4 12,4 C16.41,4 20,7.59 20,12 C20,16.41 16.41,20 12,20 Z M13,16 L15,16 L15,8 L13,8 L13,16 Z",id:"-↳Color",fill:"inherit"})})}function Di(e,n=[]){const i=u.useRef(!1);u.useEffect(()=>{i.current?e():i.current=!0},n)}function Ni({msTimeWindowStep:e,timeWindow:n,data:i,drawFrame:r,onEnd:s,animationRef:a}){let l=n;const p=()=>{a.current.animationFrameId=window.requestAnimationFrame(c)},c=()=>{l=[l[0]+e,l[1]+e],l[1]>i[i.length-1].name?s():(r(l),p())};p()}const Oi=2;function $i({speed:e,timelinePosition:n,data:i,drawFrame:r,onEnd:s,animationRef:a}){let l=Re(n,i)??0,p=i[l].name;const c=ci(i),g=Math.max(Math.round(Math.sqrt(c)/2),Oi)*e,h=()=>{a.current.timeoutId=setTimeout(()=>{a.current.animationFrameId=window.requestAnimationFrame(d)},1e3/g)},d=()=>{for(;l<i.length;l++){const y=i[l].name;if(y!==p){p=y;break}}l===i.length?s():(r(p),h())};h()}const Ri=o.styled(o.Box)(()=>({containerType:"inline-size",display:"flex",flexDirection:"column"})),Fi=o.styled(o.Box)(()=>({display:"flex",flexDirection:"column"})),qt=o.styled(o.Box)(()=>({display:"flex",flexDirection:"row"})),Wi=o.styled(qt)(()=>({alignItems:"center",justifyContent:"space-between"})),_i=o.styled(o.Box)(({theme:e})=>({flexShrink:0,marginLeft:0,paddingLeft:e.spacing(1),[`@container (max-width: ${j.BREAKPOINTS.XS}px)`]:{paddingLeft:0},paddingBottom:e.spacing(1.5),alignSelf:"flex-end"})),Gi=o.styled(o.Box)(({theme:e})=>({alignSelf:"normal",minWidth:0,paddingLeft:e.spacing(5),paddingBottom:e.spacing(1.5),[`@container (max-width: ${j.BREAKPOINTS.XS}px)`]:{paddingLeft:e.spacing(1)}}));function Kt({fitHeight:e,header:n,controls:i,chart:r,legend:s}){const a=s&&t.jsx(o.Box,{flex:0,mt:2,children:s});return t.jsxs(Ri,{style:{flex:e?"1":void 0},children:[t.jsx(Wi,{flex:0,children:n}),i?t.jsxs(Fi,{flex:1,children:[t.jsxs(qt,{flex:1,children:[t.jsx(_i,{flex:0,children:i}),t.jsx(Gi,{flex:1,children:r})]}),a]}):t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{pb:1.5,flex:1,children:r}),a]})]})}const Hi=e=>t.jsx(o.SvgIcon,{width:"720",height:"124",viewBox:"0 0 720 124",...e,children:t.jsx("path",{d:"M0.74707 123C11.8168 119.656 26.7934 118.37 53.4909 102.164C73.1959 90.2031 92.5604 81.3284 108.188 76.6983C122.841 72.357 136.188 74.3832 144.653 75.1549C150.496 75.6876 195.443 82.8718 207.164 83.6435C218.885 84.4152 241.676 87.502 274.234 80.5567C306.791 73.6115 305.869 75.4585 330.233 67.438C388.837 48.1456 433.461 2.6348 458.511 1.07229C495.627 -1.24279 512.557 52.7758 539.255 58.1776C565.952 63.5795 583.534 64.3512 601.766 55.0909C619.999 45.8305 625.859 40.4287 646.045 38.1136C666.231 35.7985 683.812 41.972 718.975 70.5247",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})}),zi=o.styled(o.Box)(()=>({display:"flex",flexDirection:"column",justifyContent:"flex-end"})),Yi=o.styled(o.Box)(()=>({position:"relative",height:"100%",alignSelf:"normal",display:"flex",flexDirection:"column",justifyContent:"flex-end"})),Vi=o.styled(o.Box)(({theme:e})=>({padding:e.spacing(2.25,0,.5,2)})),Ui=o.styled(Bt)(({theme:e})=>({flexDirection:"column",flex:1,height:"100%",overflow:"hidden",svg:{height:"100%",width:"100%",fontSize:"initial",fill:"none",path:{stroke:e.palette.black[8]}}})),qi=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",justifyContent:"space-between",padding:e.spacing(1.25,.5,.75,.5)})),Ki=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",gap:e.spacing(2),margin:0,padding:e.spacing(1.5,1,.25,1)})),jt=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",gap:e.spacing(1)})),Xi=({fitHeight:e,height:n,showControls:i,showLegend:r})=>{const s=t.jsx(o.Box,{pt:1.25,pb:.75,children:t.jsx(o.Skeleton,{width:48,height:8})}),a=i&&t.jsxs(zi,{children:[t.jsx(o.Box,{p:.5,children:t.jsx(o.Skeleton,{width:16,height:16})}),t.jsx(o.Box,{mt:2,p:.5,children:t.jsx(o.Skeleton,{width:16,height:16})}),t.jsx(o.Box,{mt:1,p:.5,children:t.jsx(o.Skeleton,{width:16,height:16})})]}),l=e?Ut:n??Vt,p=t.jsxs(Yi,{style:{height:l},children:[t.jsx(Vi,{flex:0,children:t.jsx(o.Skeleton,{width:24,height:8})}),t.jsx(Ui,{flex:1,children:t.jsx(Hi,{preserveAspectRatio:"none"})}),t.jsxs(qi,{flex:0,children:[t.jsx(o.Skeleton,{width:32,height:8}),t.jsx(o.Skeleton,{width:32,height:8})]})]}),c=r&&t.jsxs(Ki,{children:[t.jsxs(jt,{children:[t.jsx(o.Skeleton,{width:8,height:8}),t.jsx(o.Skeleton,{width:48,height:8})]}),t.jsxs(jt,{children:[t.jsx(o.Skeleton,{width:8,height:8}),t.jsx(o.Skeleton,{width:48,height:8})]})]});return t.jsx(Kt,{fitHeight:!!e,header:s,controls:a,chart:p,legend:r&&c})},Xt=e=>e,Zt=[];function Zi({data:e=Zt,categories:n,stepSize:i,stepMultiplier:r=1,chartType:s=Ge.LINE,timeAxisSplitNumber:a,tooltip:l=!0,tooltipFormatter:p=Wt,formatter:c=Xt,height:g,fitHeight:h,showControls:d=!0,animation:y=!0,filterable:f=!0,onTimelineUpdate:m,timeWindow:v,timelinePosition:x,onTimeWindowUpdate:S,selectedCategories:b,onSelectedCategoriesChange:k,isPlaying:I=!1,onPlay:w,isPaused:M=!1,onPause:C,onStop:D,isLoading:B=!1,palette:L=Object.values(Me.commonPalette.qualitative.bold),showLegend:P,yAxisType:O="dense"}){const V=u.useRef([]),_=J.useIntl(),{showSkeleton:E}=de(!!B),N=u.useCallback(T=>{var $,G;if(T.length===2){(($=V.current)==null?void 0:$.length)===1&&(m==null||m(void 0));const F=T.sort((H,K)=>H<K?-1:1).map(_t);S==null||S(F)}if(T.length===1){((G=V.current)==null?void 0:G.length)===2&&(S==null||S([]));const F=Re(Number(T[0]),e);m==null||m(F)}V.current=T},[S,m,e]);return E?t.jsx(Xi,{fitHeight:h,height:g,showControls:d,showLegend:P}):t.jsx(zt,{isPlaying:I,onPlay:w,isPaused:M,onPause:C,onStop:D,timeWindow:v,onTimeWindowUpdate:N,intl:_,children:t.jsx(Ji,{data:e,categories:n,stepSize:i,stepMultiplier:r,chartType:s,timeAxisSplitNumber:a,tooltip:l,tooltipFormatter:p,formatter:c,height:g,fitHeight:h,showControls:d,animation:y,filterable:f,palette:L,showLegend:P,selectedCategories:b,timelinePosition:x,onSelectedCategoriesChange:k,yAxisType:O})})}function Ji({data:e=Zt,categories:n,stepSize:i,stepMultiplier:r=1,chartType:s=Ge.LINE,timeAxisSplitNumber:a,tooltip:l=!0,tooltipFormatter:p=Wt,formatter:c=Xt,height:g,fitHeight:h=!1,showControls:d=!0,animation:y=!0,filterable:f=!0,palette:m=Object.values(Me.commonPalette.qualitative.bold),selectedCategories:v=[],onSelectedCategoriesChange:x,showLegend:S,timelinePosition:b,yAxisType:k="dense"}){const I=o.useTheme(),w=I.palette.secondary.main,{isPlaying:M,isPaused:C,timeWindow:D,stop:B,setTimeWindow:L,intl:P}=He();u.useEffect(()=>{if(b!==void 0){if(b<0||b>=e.length)return;const R=e[b].name;L([R])}},[b,e]),u.useEffect(()=>{if(!e.length)return;const R=e[0].name,z=e[e.length-1].name;(D[0]<R||D[1]>z||D[1]<R||D[1]>z)&&L([])},[e]);const O=u.useMemo(()=>{const R={},z=n?n.map(Z=>({name:Z,data:[],color:Me.getColorByCategory(Z,{palette:m,fallbackColor:w,colorMapping:R})})):[{name:"",data:[],color:I.palette.secondary.main}];for(const{name:Z,value:ge,category:oe,categoryIndex:W}of e){const U=W??(n&&oe?n.indexOf(oe):0);U===-1||n&&U>=n.length||!Number.isFinite(U)||z[U].data.push([Z,ge])}return z},[n,e,m,w,I.palette.secondary.main]),V=u.useMemo(()=>{if(!e.length)return"";if(D.length===2){const[R,z]=D.map(Z=>new Date(Z));return Fe({start:R,end:z,stepSize:i})}if(!M&&!C){const R=new Date(e[0].name),z=new Date(e[e.length-1].name);return Fe({start:R,end:z,stepSize:i})}if(D.length===1){const R=new Date(D[0]);return Gt({date:R,stepSize:i,stepMultiplier:r})}},[e,D,M,C,i,r]),_=u.useMemo(()=>M||C||D.length>0||(v==null?void 0:v.length)>0,[C,M,v==null?void 0:v.length,D.length]),E=()=>{B(),L([]),x==null||x([])},N=R=>{R.key==="Enter"&&E()},T=u.useCallback(R=>{if(x){const z=[...v],Z=z.indexOf(R);Z===-1?z.push(R):z.splice(Z,1),x(z)}},[x,v]),$=!!(S??O.length>1),G=t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{children:t.jsx(j.Typography,{color:"textSecondary",variant:"caption",children:V??"-"})}),f&&_&&t.jsx(o.Link,{variant:"caption",style:{cursor:"pointer"},onClick:E,onKeyDown:N,tabIndex:0,underline:"hover",children:P.formatMessage({id:"c4r.widgets.timeSeries.clear"})})]}),F=f&&d&&t.jsx(Ai,{data:e,stepSize:i}),H=t.jsx(Ti,{chartType:s,timeAxisSplitNumber:a,data:e,series:O,categories:n,tooltip:l,formatter:c,tooltipFormatter:R=>p(R,i,c,r,$),height:g,fitHeight:h,animation:y,filterable:f,selectedCategories:v,onCategoryClick:x&&T,yAxisType:k}),K=$&&t.jsx(Ft,{series:O,selectedCategories:v,onCategoryClick:x&&T});return t.jsx(Kt,{fitHeight:h,header:G,controls:F,chart:H,legend:K})}const Qi=o.styled("div")(({theme:e})=>({padding:e.spacing(2,0),...e.typography.body2})),er=o.styled(o.Box)(({theme:e})=>({overflow:"auto",maxHeight:e.spacing(40),paddingRight:e.spacing(1),margin:e.spacing(.5,0)})),tr=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",flexWrap:"wrap",gap:e.spacing(1.5),padding:e.spacing(2,0)})),Jt=o.styled(o.Box)(({theme:e,alignItems:n="center"})=>({display:"flex",alignItems:n,gap:e.spacing(.75)})),Qt=o.styled("div",{shouldForwardProp:e=>e!=="color"})(({theme:e,color:n})=>({flexShrink:0,width:e.spacing(1),height:e.spacing(1),borderRadius:e.spacing(1),backgroundColor:n})),nr=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(2)})),or=o.styled("div")(({theme:e})=>({height:e.spacing(.5),width:"100%",borderRadius:e.spacing(.5),backgroundColor:e.palette.action.disabledBackground,"& div":{width:0,height:"100%",borderRadius:e.spacing(.5),transition:`background-color ${e.transitions.easing.sharp} ${e.transitions.duration.shortest}ms,
19
+ width ${e.transitions.easing.sharp} ${e.transitions.duration.complex}ms`}})),wt=o.styled(o.Box,{shouldForwardProp:e=>e!=="center"})(({theme:e,center:n=!1})=>({marginBottom:e.spacing(2),paddingRight:e.spacing(1),...n&&{display:"flex",justifyContent:"space-between",alignItems:"center"},"& .MuiTypography-caption":{color:e.palette.text.secondary},"& .MuiButton-label":{...e.typography.caption},"& a":{cursor:"pointer"}})),ir=o.styled(o.Tooltip)(({theme:e})=>({".MuiTooltip-tooltip":{color:e.palette.common.white,maxWidth:260,marginBottom:0,overflow:"hidden"}})),rr=o.styled(o.TextField)(({theme:e})=>({marginTop:e.spacing(-.5)}));o.styled(o.Box)(()=>({display:"flex",flexWrap:"nowrap",justifyContent:"space-between"}));const sr=o.styled("div",{shouldForwardProp:e=>e!=="filterable"})(({filterable:e})=>({"& .progressbar div":{backgroundColor:"var(--color)"},...e&&{cursor:"pointer","& .MuiBox-root:hover .progressbar div":{backgroundColor:"var(--hover-color)"}}})),ar=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",flexWrap:"nowrap",overflow:"hidden",gap:e.spacing(1)})),lr=o.styled(o.Box)(({theme:e})=>({padding:e.spacing(.5,0),flexGrow:"1",maxWidth:"100%",minWidth:0})),cr=o.styled(o.Box,{shouldForwardProp:e=>e!=="backgroundColor"})(({theme:e,backgroundColor:n})=>({marginLeft:e.spacing(1),padding:e.spacing(0,1),backgroundColor:n,color:"white",borderRadius:e.spacing(2)}));function dr(e,n,i,r,s){const l=(e[0]??[]).map((p,c)=>{const g=String(p.name),h=r.length>0&&!r.includes(g),d=i[c]??g,y=e.map((f,m)=>{var v;return{color:h?o.lighten(n[m],.8):n[m],value:((v=f[c])==null?void 0:v.value)??0}});return{label:d,key:g,data:y}});return s===pe.RANKING&&l.sort((p,c)=>{const g=Math.max(...p.data.map(d=>d.value));return Math.max(...c.data.map(d=>d.value))-g}),l}const ur=500;function pr(e,n={}){const{disabled:i,duration:r,animateOnMount:s,initialValue:a=0}=n,l=u.useRef(null),[p,c]=u.useState(()=>s?a:e);return u.useEffect(()=>(i?c(e):Ke({start:p,end:e,duration:r??ur,drawFrame:g=>c(g),requestRef:l}),()=>{l.current&&cancelAnimationFrame(l.current)}),[e,i,r]),p}const gr={};function en({enabled:e=!0,value:n=0,options:i=gr,formatter:r}){const a=pr(n||0,{...{animateOnMount:!0,disabled:e===!1||n===null||n===void 0},...i});return t.jsx("span",{children:r?r(a):a})}const Je=e=>e,hr=()=>{},fr=[];function xr({item:e,index:n=0,names:i=fr,formatter:r=Je}){const s=o.useTheme(),a=e.data[0],l=e.data[n],p=i[n],c=(l.value-a.value)/(a.value||1)*100,g=Math.sign(c)===-1?"-":"+",h=Math.sign(c)===-1?s.palette.error.main:s.palette.success.main,d=e.key===me?s.palette.text.disabled:h;return t.jsxs("div",{children:[t.jsx(o.Typography,{color:"inherit",variant:"caption",noWrap:!0,children:e.label}),t.jsx(o.Box,{pt:1,pb:.5,children:t.jsxs(Jt,{alignItems:"baseline",children:[t.jsx(Qt,{color:e.key===me?s.palette.background.default:l.color}),t.jsx(o.Typography,{color:"inherit",variant:"caption",children:p}),t.jsx(o.Box,{style:{flexGrow:1}}),t.jsx(cr,{backgroundColor:d,children:t.jsxs(o.Typography,{color:"inherit",variant:"caption",children:[g,r(Math.abs(c))]})})]})})]})}function mr({item:e,animation:n=!0,animationOptions:i,maxValue:r,showCheckbox:s,checkboxChecked:a,formatter:l=Je,tooltipFormatter:p=Je,onClick:c=hr,names:g,tooltip:h}){function d(f){return`${Math.min(100,(f||0)/r*100)}%`}const y=f=>t.jsx(xr,{item:e,names:g,formatter:p,index:f});return t.jsxs(ar,{onClick:()=>c(e.key),children:[s?t.jsx(o.Checkbox,{checked:a}):null,t.jsxs(lr,{children:[t.jsx(o.Typography,{variant:"body2",noWrap:!0,children:e.label}),e.data.map((f,m)=>t.jsx(ir,{title:y(m),placement:"top-start",arrow:!1,disableHoverListener:!h,children:t.jsxs(nr,{children:[t.jsx(or,{className:"progressbar",children:t.jsx("div",{style:{"--hover-color":o.darken(f.color,.2),"--color":f.color,width:d(f.value)}})}),t.jsx(o.Typography,{variant:m===0?"body2":"caption",color:m===0?"textPrimary":"textSecondary",children:t.jsx(en,{value:f.value,enabled:n,options:i,formatter:l})})]})},`${e.key}_${m}`))]})]})}const bt=e=>e,yr=()=>{},ke=[];function vr({names:e=ke,data:n=ke,labels:i=ke,colors:r=ke,maxItems:s=5,order:a=pe.FIXED,animation:l=!0,animationOptions:p,searchable:c=!0,filterable:g=!0,selectedCategories:h=ke,onSelectedCategoriesChange:d=yr,formatter:y=bt,tooltipFormatter:f=bt,tooltip:m=!0,isLoading:v=!1}){const x=o.useTheme(),[S,b]=u.useState(!1),[k,I]=u.useState(!1),[w,M]=u.useState(h),[C,D]=u.useState(""),B=J.useIntl(),L=j.useImperativeIntl(B),P=u.useMemo(()=>{const W=r.length?r:[x.palette.secondary.main,x.palette.primary.main,x.palette.info.main];return dr(n,W,i,h,a)},[n,r,i,x,h,a]),O=u.useMemo(()=>Math.max(...n.map(W=>W.map(U=>U.value??0)).flat()),[n]),V=u.useMemo(()=>{if(s>=P.length)return P;const W=P.slice(0,s),U=P.slice(s),X=[];for(const re of U)re.data.forEach((ve,fe)=>{X[fe]=X[fe]??0,X[fe]+=ve.value});const Q={key:me,label:c?"Others":`Others (${P.length-s})`,data:X.map(re=>({value:re,color:x.palette.divider}))};return[...W,Q]},[P,c,s,x.palette.divider]),_=u.useMemo(()=>P.filter(W=>h.includes(W.key)),[P,h]),E=u.useMemo(()=>C?P.filter(W=>{const U=(W.key||"").toLowerCase(),X=(W.label||"").toLowerCase(),Q=U==null?void 0:U.includes(C.toLowerCase()),re=X==null?void 0:X.includes(C.toLowerCase());return Q||re}):P,[P,C]),N=P.length-V.length+1,T=c&&!S&&s<P.length;if(P.length===0||v)return t.jsx(Nt,{});const $=S?E:k?_:V;function G(){I(!0),d([...w]),z()}function F(){I(!1)}function H(){d([])}function K(){I(!0)}function R(){b(!0),M([...h])}function z(){b(!1),M([])}function Z(W){const U=h.includes(W),X=new Set(h);U?X.delete(W):X.add(W);let Q=Array.from(X);Q.length===P.length&&(Q=[]),d(Q)}function ge(W){const U=w.includes(W),X=new Set(w);U?X.delete(W):X.add(W);let Q=Array.from(X);Q.length===P.length&&(Q=[]),M(Q)}const oe=g?S?ge:Z:void 0;return t.jsxs(Qi,{children:[g?t.jsxs(wt,{center:!0,children:[t.jsx(j.Typography,{variant:"caption",children:h.length>0?L.formatMessage({id:"c4r.widgets.category.selectedItems"},{items:h.length}):L.formatMessage({id:"c4r.widgets.category.all"})}),t.jsx(j.Typography,{variant:"caption",children:S?t.jsx(o.Link,{onClick:G,children:L.formatMessage({id:"c4r.widgets.category.apply"})}):k?t.jsx(o.Link,{onClick:F,children:L.formatMessage({id:"c4r.widgets.category.unlock"})}):h.length?t.jsxs(o.Box,{style:{display:"flex",justifyContent:"flex-end",gap:x.spacing(1)},children:[t.jsx(o.Link,{onClick:K,children:L.formatMessage({id:"c4r.widgets.category.lock"})}),t.jsx(o.Divider,{orientation:"vertical",flexItem:!0}),t.jsx(o.Link,{onClick:H,children:L.formatMessage({id:"c4r.widgets.category.clear"})})]}):null})]}):null,S?t.jsx(wt,{children:t.jsx(rr,{size:"small",placeholder:L.formatMessage({id:"c4r.widgets.category.search"}),onChange:W=>D(W.currentTarget.value),onFocus:W=>W.currentTarget.scrollIntoView(),InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",children:t.jsx(Te.Search,{})})}})}):null,t.jsxs(er,{children:[$.length===0?t.jsxs(t.Fragment,{children:[t.jsx(j.Typography,{variant:"body2",children:L.formatMessage({id:"c4r.widgets.category.noResults"})}),t.jsx(j.Typography,{variant:"caption",children:L.formatMessage({id:"c4r.widgets.category.noResultsMessage"},{searchValue:C})})]}):null,$.map(W=>t.jsx(sr,{children:t.jsx(mr,{item:W,animation:l,animationOptions:p,maxValue:O,showCheckbox:g&&S,checkboxChecked:w.includes(W.key),formatter:y,tooltipFormatter:f,tooltip:m,onClick:oe,names:e})},W.key))]}),T?t.jsx(o.Button,{size:"small",color:"primary",startIcon:t.jsx(Te.Search,{}),onClick:R,children:L.formatMessage({id:"c4r.widgets.category.searchInfo"},{elements:N})}):null,S?t.jsx(o.Button,{size:"small",color:"primary",onClick:z,children:L.formatMessage({id:"c4r.widgets.category.cancel"})}):null,t.jsx(tr,{children:e.map((W,U)=>t.jsxs(Jt,{children:[t.jsx(Qt,{color:(r==null?void 0:r[U])??x.palette.background.default}),t.jsx(j.Typography,{variant:"overline",children:W})]},e[U]))})]})}const jr=o.styled(j.Typography)(({theme:e})=>({display:"inline-block",marginTop:e.spacing(.5)}));function wr({row:e}){const n=o.useTheme();return e.label?t.jsx(o.Box,{color:e.color??n.palette.text.secondary,children:t.jsx(jr,{color:"inherit",variant:"caption",children:e.label})}):null}const br=o.styled("div")(({theme:e})=>({margin:0,...e.typography.h5,fontWeight:Number(e.typography.fontWeightMedium),color:e.palette.text.primary,display:"flex"})),Sr=o.styled(j.Typography)(({theme:e})=>({marginRight:e.spacing(.5)})),kr=o.styled(j.Typography)(({theme:e})=>({marginLeft:e.spacing(.5)}));function Ir({row:e,animated:n,animationOptions:i,formatter:r}){const s=o.useTheme(),{prefix:a,value:l,suffix:p,shouldBeHighlighted:c}=e;return t.jsxs(br,{children:[a?t.jsx(o.Box,{color:s.palette.text.secondary,children:t.jsx(Sr,{color:"inherit",component:"span",variant:"subtitle2",children:a})}):null,t.jsx(o.Box,{fontWeight:c?"bold":"",children:t.jsx(en,{value:l,enabled:n,options:i,formatter:r})}),p?t.jsx(o.Box,{color:s.palette.text.secondary,children:t.jsx(kr,{color:"inherit",component:"span",variant:"subtitle2",children:p})}):null]})}const Tr=e=>e,St=[],Mr=o.styled("div")(({theme:e})=>({"&:nth-of-type(n+2)":{marginTop:e.spacing(2)}}));function Cr({data:e=St,colors:n=St,animated:i=!0,animationOptions:r,formatter:s=Tr,isLoading:a=!1}){const l=Ar(e,n);return a?t.jsx($t,{}):t.jsx("div",{children:l.map((p,c)=>t.jsxs(Mr,{children:[t.jsx(Ir,{row:p,animated:i,animationOptions:r,formatter:s}),t.jsx(wr,{row:p})]},c))})}function Ar(e,n){const i=e.map((s,a)=>({...s,color:n[a],shouldBeHighlighted:!1})).filter(s=>s.value!==void 0);return i&&i.length>1&&(i[0].shouldBeHighlighted=!0),i}function Er(e,n=[],i=[],r,s=[]){return e.map((a,l)=>{const p=s.length>0&&!s.includes(a.name),g=(n!=null&&n.length?n:r.palette.qualitative.bold)[l];return{...a,key:a.name,color:p?o.lighten(g,.8):g,name:i[l]??a.name}})}function Br(e,n,i){const r=`
20
20
  font-size: 12px;
21
21
  line-height: 1.33;
22
22
  font-weight: 600;
@@ -26,8 +26,8 @@
26
26
  line-height: 1.33;
27
27
  font-weight: normal;
28
28
  margin: 0 0 4px 0;
29
- `,l=Array.isArray(e)?e[0]:e;if(!l)return null;const a=l.data,p=n(a.value),c=r?l.seriesName:p,g=n(l.percent);return`
30
- <p style="${i}">${a.name}</p>
31
- <p style="${s}">${String(l.marker)} ${c} (${g} %)</p>
32
- `.trim()}const Ri=e=>e,Fi=()=>{},De=[],Wi="260px";function _i({names:e=De,data:n=De,labels:r=De,colors:i=De,height:s=Wi,animation:l=!0,formatter:a=Ri,tooltipFormatter:p=Oi,selectedCategories:c=[],onCategorySelected:g=Fi,isLoading:h=!1}){const d=o.useTheme(),v=u.useRef(),f=u.useMemo(()=>n.map((S,b)=>$i(S,i[b],r[b],d,c)),[n,i,r,d,c]),y=u.useMemo(()=>{const S=f.length>1;let b;p&&(b=B=>p(B,a,S));const k={trigger:"item",show:!0,backgroundColor:d.palette.black[90],textStyle:{color:d.palette.common.white},confine:!0,borderWidth:0,formatter:b},w={data:S?f.map((B,P)=>e[P]):(f[0]??[]).map(B=>B.name),selectedMode:!1,type:"scroll",left:j.SPACING,bottom:j.SPACING*-.5,itemGap:j.SPACING*3,icon:"circle",itemWidth:j.SPACING,itemHeight:j.SPACING,textStyle:{...d.typography.overline,color:d.palette.text.primary,fontWeight:400,lineHeight:1,verticalAlign:"bottom",padding:[0,0,0,j.SPACING*.5]},inactiveColor:d.palette.text.disabled,pageIcons:{horizontal:["path://M15.41 7.41 14 6 8 12 14 18 15.41 16.59 10.83 12z","path://M9 16.59 13.3265857 12 9 7.41 10.3319838 6 16 12 10.3319838 18z"]},pageIconSize:j.SPACING*1.5,pageIconColor:d.palette.text.secondary,pageIconInactiveColor:d.palette.text.disabled,pageTextStyle:{fontFamily:d.typography.overline.fontFamily,fontSize:j.SPACING*1.5,lineHeight:j.SPACING*1.75,fontWeight:400,color:d.palette.text.primary}},C={formatter:({name:B,percent:P})=>`{per|${a(P)}%}
33
- {b|${B}}`,position:"center",rich:{b:{fontFamily:d.typography.overline.fontFamily,fontSize:j.SPACING*1.75,lineHeight:j.SPACING*1.75,fontWeight:400,color:d.palette.text.primary},per:{...d.typography.overline,fontSize:j.SPACING*3,lineHeight:j.SPACING*4.5,fontWeight:600,color:d.palette.text.primary}}},A=f.map((B,P)=>{var L;return{type:"pie",name:e[P],itemStyle:{color:(L=B[0])==null?void 0:L.color},animation:l,data:B.map(N=>({...N,itemStyle:{color:N.color}})),radius:P===0?["75%","90%"]:["56%","72%"],selectedOffset:0,hoverOffset:5,bottom:j.SPACING*2.5,avoidLabelOverlap:!0,label:{show:!1,...C},emphasis:{label:{show:!0,formatter:C.formatter,rich:C.rich}}}});return{grid:{left:0,top:0,right:0,bottom:0},tooltip:k,legend:w,series:A}},[d,e,l,f,a,p]),m={mouseover:(S,b)=>{f.length===1&&(S.seriesIndex!==0||S.dataIndex!==0)&&b.dispatchAction({type:"downplay",seriesIndex:0,dataIndex:0})},mouseout:(S,b)=>{f.length===1&&b.dispatchAction({type:"highlight",seriesIndex:0,dataIndex:0})},click:S=>{const k=f[S.seriesIndex][S.dataIndex].key,I=c.includes(k),w=new Set(c);I?w.delete(k):w.add(k);const C=f[0].length;let A=Array.from(w);A.length===C&&(A=[]),g(A)}};u.useEffect(()=>{v.current&&v.current.dispatchAction({type:f.length===1?"highlight":"downplay",seriesIndex:0,dataIndex:0})},[f]);function x(S){v.current=S}return f.length?h?t.jsx(Ft,{height:s}):t.jsx(ye,{onChartReady:x,notMerge:!0,option:y,onEvents:m,style:{maxHeight:s,width:"100%"}}):null}const Gi=()=>{};function nn({icon:e,hoverTooltip:n,clickTooltip:r,enabled:i,onEnabledChange:s=Gi,tooltipPlacement:l="bottom"}){const[a,p]=u.useState(!1),[c,g]=u.useState(i);u.useEffect(()=>{g(i)},[i]),u.useEffect(()=>{if(i){const d=v=>{v.key==="Escape"&&s&&s(!1)};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d)}}},[i,s]);const h=c?r:n;return t.jsx(o.ClickAwayListener,{onClickAway:()=>g(!1),children:t.jsx(o.Tooltip,{title:h,placement:l,open:a,onOpen:()=>p(!0),onClose:()=>{c||p(!1)},children:t.jsx(o.ToggleButton,{value:"selectedMode",selected:i,onClick:()=>s&&s(!i),children:e})})})}const Hi=o.styled(o.IconButton,{shouldForwardProp:e=>e!=="isOpen"})(({isOpen:e,theme:n})=>({color:n.palette.text.secondary,width:n.spacing(3),transform:`rotate(${e?"180":"0"}deg)`,backgroundColor:e?n.palette.action.hover:void 0})),zi=o.styled(o.MenuItem,{shouldForwardProp:e=>e!=="disabled"})(({disabled:e,theme:n})=>({...e&&{pointerEvents:"none",color:n.palette.text.disabled}})),Yi=o.styled(o.MenuItem)(()=>({"&.Mui-disabled":{opacity:1}})),Vi=()=>{};function on({selectionModes:e,editModes:n,selectedMode:r,onSelectMode:i=Vi,enabled:s,tooltipPlacement:l="bottom",tooltipText:a="",menuHeaderText:p="",editDisabled:c}){const g=o.useTheme(),[h,d]=u.useState(null),v=!!h,f=k=>d(k.currentTarget),y=()=>d(null),m=k=>{i&&i(k),y()},x=!!e.length&&!!n.length,S=k=>n.some(I=>I.id===k.id);function b(k){return t.jsx(zi,{selected:s&&r===k.id,onClick:()=>m(k.id),disabled:c&&S(k),children:t.jsxs(o.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[k.icon,t.jsx(o.Box,{ml:2,children:t.jsx(j.Typography,{variant:"body2",color:"inherit",children:o.capitalize(k.label)})})]})},k.id)}return t.jsxs(t.Fragment,{children:[t.jsx(o.Tooltip,{title:a,placement:l,children:t.jsx(Hi,{id:"feature-selection-menu-button","aria-controls":"feature-selection-menu","aria-haspopup":"true","aria-expanded":v?"true":void 0,onClick:f,isOpen:v,children:t.jsx(yn,{})})}),t.jsxs(o.Menu,{id:"feature-selection-menu",style:{zIndex:g.zIndex.tooltip+1},anchorEl:h,open:v,onClose:y,MenuListProps:{"aria-labelledby":"feature-selection-menu-button"},children:[p&&t.jsx(Yi,{disabled:!0,children:t.jsx(j.Typography,{variant:"caption",color:"textSecondary",children:p})}),!!e.length&&e.map(b),x&&t.jsx(o.Divider,{sx:{margin:({spacing:k})=>k(1,0)}}),!!n.length&&n.map(b)]})]})}const Ui=o.styled(o.List)(({theme:e})=>({display:"flex",alignItems:"center",marginLeft:e.spacing(1.5),padding:e.spacing(.5),overflowX:"auto",maxWidth:"100%",scrollbarWidth:"none",msOverflowStyle:"none","&::-webkit-scrollbar":{display:"none"}})),qi=()=>{};function rn({features:e,onSelectGeometry:n=qi,onDeleteGeometry:r,chipTooltip:i,disabledChipTooltip:s,size:l="medium",tooltipPlacement:a="bottom",chipLabel:p}){const c=Z.useIntl(),g=j.useImperativeIntl(c);function h(y){return y==="MultiPoint"?g.formatMessage({id:"c4r.widgets.featureSelection.point"}):y==="MultiLineString"?g.formatMessage({id:"c4r.widgets.featureSelection.lineString"}):y==="MultiPolygon"||y==="Polygon"||y==="GeometryCollection"?g.formatMessage({id:"c4r.widgets.featureSelection.polygon"}):y}function d(y,m){var S;const x=h(y.geometry.type);return p||((S=y.properties)==null?void 0:S.name)||`${x} ${m+1}`}const[v,f]=u.useState(!1);return t.jsx(o.Box,{sx:{overflowX:"auto"},children:t.jsx(Ui,{sx:{gap:l==="small"?.5:1},children:e.map((y,m)=>{var I,w;const x=(I=y.properties)==null?void 0:I.disabled,S=(w=y.properties)==null?void 0:w.invalid;let b=i;x&&(b=s||i),S&&(b=g.formatMessage({id:"c4r.widgets.featureSelection.invalid"})),v&&(b=g.formatMessage({id:"c4r.widgets.featureSelection.remove"}));let k="secondary";return x&&(k="default"),S&&(k="error"),t.jsx(o.ListItem,{disablePadding:!0,children:t.jsx(o.Tooltip,{disableHoverListener:x?!s:!i,title:b,placement:a,children:t.jsx(o.Chip,{size:l,label:d(y,m),color:k,onClick:()=>n(y),onDelete:r?()=>r(y):void 0,icon:S?t.jsx(fe.ErrorOutline,{color:"error"}):void 0,deleteIcon:t.jsx(fe.Cancel,{onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1)})})})},m)})})})}const Ki=o.styled(o.Paper)(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",maxHeight:e.spacing(5),padding:e.spacing(.5)})),Xi=[];function Zi({selectionModes:e,editModes:n=Xi,selectedMode:r,onSelectMode:i,enabled:s=!1,onEnabledChange:l,geometry:a,onSelectGeometry:p,onDeleteGeometry:c,tooltipPlacement:g="bottom",size:h="medium",chipLabel:d}){const v=Z.useIntl(),f=j.useImperativeIntl(v),y=u.useMemo(()=>e.map(I=>({...I,label:f.formatMessage({id:`c4r.widgets.featureSelection.${kt(I.id)}`})})),[e,f]),m=u.useMemo(()=>n.map(I=>({...I,label:f.formatMessage({id:`c4r.widgets.featureSelection.${kt(I.id)}`})})),[n,f]),x=u.useMemo(()=>{const w=[...y.map(C=>({...C,isEdit:!1})),...m.map(C=>({...C,isEdit:!0}))].find(C=>C.id===r);if(!w)throw new Error(`Selected mode "${r}" not supported`);return w},[m,y,r]),S=o.capitalize((x==null?void 0:x.label)||""),b=x!=null&&x.isEdit?S:f.formatMessage({id:"c4r.widgets.featureSelection.selectTool"},{label:S}),k=x!=null&&x.isEdit?f.formatMessage({id:"c4r.widgets.featureSelection.clickToEdit"}):f.formatMessage({id:"c4r.widgets.featureSelection.clickToCreate"});return t.jsxs(Ki,{children:[t.jsx(nn,{icon:x==null?void 0:x.icon,hoverTooltip:b,clickTooltip:k,enabled:s,onEnabledChange:l,tooltipPlacement:g}),t.jsx(on,{selectionModes:y,editModes:m,selectedMode:r,onSelectMode:i,enabled:s,tooltipPlacement:g,tooltipText:f.formatMessage({id:"c4r.widgets.featureSelection.selectMode"}),menuHeaderText:f.formatMessage({id:"c4r.widgets.featureSelection.chooseSelectionMode"}),editDisabled:!a}),!!a&&t.jsx(rn,{features:[a],onSelectGeometry:p,onDeleteGeometry:c,disabledChipTooltip:f.formatMessage({id:"c4r.widgets.featureSelection.applyMask"}),chipTooltip:f.formatMessage({id:"c4r.widgets.featureSelection.clearMask"}),tooltipPlacement:g,size:h,chipLabel:d})]})}function kt(e){return e.charAt(0).toLowerCase()+e.slice(1)}const sn=240,Ji=o.styled(o.Paper,{shouldForwardProp:e=>e!=="collapsed"})(({theme:e,collapsed:n})=>({width:n?"min-content":sn,background:e.palette.background.paper,maxHeight:"calc(100% - 120px)",display:"flex",flexDirection:"column"})),Qi=o.styled("header",{shouldForwardProp:e=>e!=="collapsed"})(({theme:e,collapsed:n})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:e.spacing(1),paddingLeft:e.spacing(2),borderBottom:n?void 0:`1px solid ${e.palette.divider}`})),es=o.styled("header")(({theme:e})=>({padding:e.spacing(1.5),paddingRight:e.spacing(2),gap:e.spacing(.5),display:"flex",justifyContent:"space-between",position:"sticky",zIndex:2,top:0,background:e.palette.background.paper})),ts=o.styled("div")(({theme:e})=>({display:"flex",gap:e.spacing(2),alignItems:"center",padding:e.spacing(1),minWidth:`calc(${sn}px - ${e.spacing(4)})`})),ns=o.styled(o.TextField)(({theme:e})=>({display:"flex",width:e.spacing(7.5),flexShrink:0,"input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button":{WebkitAppearance:"none",margin:0}})),os=o.styled("ul",{shouldForwardProp:e=>e!=="opacity"})(({theme:e,opacity:n})=>({opacity:n,margin:0,padding:0,display:"flex",flexDirection:"column",gap:e.spacing(1)})),ln=o.styled("ul")(({theme:e})=>({margin:0,padding:0,paddingBottom:e.spacing(1),display:"flex",flexDirection:"column"})),rs=o.styled("li")(()=>({display:"flex",alignItems:"center"})),is=o.styled("div")(({theme:e})=>({marginRight:e.spacing(1.5),width:j.ICON_SIZE_MEDIUM,height:j.ICON_SIZE_MEDIUM,"& img":{margin:"auto",display:"block"}})),It=o.styled(o.Box,{shouldForwardProp:e=>e!=="width"})(({width:e,theme:n})=>({width:e,overflow:"auto",maxHeight:`calc(100% - ${n.spacing(1.5)})`})),ss=o.styled("section")(({theme:e})=>({"&:not(:first-of-type)":{borderTop:`1px solid ${e.palette.divider}`}})),ls=o.styled("div")(()=>({flexGrow:1,flexShrink:1,minWidth:0}));function as({menuRef:e,open:n,toggleOpen:r,opacity:i,onChange:s}){const l=Z.useIntl(),a=j.useImperativeIntl(l);function p(c){const g=parseInt(c.target.value||"0"),h=Math.min(Math.max(g,0),100);s(h/100)}return t.jsxs(t.Fragment,{children:[t.jsx(o.Tooltip,{title:a.formatMessage({id:"c4r.widgets.legend.opacity"}),children:t.jsx(o.IconButton,{size:"small",color:n?"primary":"default",onClick:()=>r(!n),children:t.jsx(Te.SwatchSquare,{})})}),t.jsx(o.Popover,{open:n,onClose:()=>r(!1),anchorEl:e.current,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{root:{sx:{transform:"translate(-12px, 36px)"}}},children:t.jsxs(ts,{children:[t.jsx(o.Slider,{value:i*100,onChange:(c,g)=>s(g/100),min:0,max:100,step:1}),t.jsx(ns,{size:"small",type:"number",value:Math.round(i*100),onChange:p,inputProps:{step:1,min:0,max:100,style:{appearance:"textfield"},"data-testid":"opacity-slider"},InputProps:{endAdornment:t.jsxs(o.InputAdornment,{position:"end",sx:{margin:0},children:[" ","%"]})}})]})})]})}function ot({title:e,visible:n,typographyProps:r}){const i=u.useRef(null),[s,l]=u.useState(!1);u.useLayoutEffect(()=>{if(n&&i.current){const{offsetWidth:p,scrollWidth:c}=i.current;l(p<c)}},[e,n]);const a=t.jsx(j.Typography,{ref:i,color:n?"textPrimary":"textSecondary",variant:"button",weight:"medium",component:"p",noWrap:!0,my:.25,...r,children:e});return s?t.jsx(o.Tooltip,{title:e,children:a}):a}var ae=(e=>(e.CATEGORY="category",e.ICON="icon",e.CONTINUOUS_RAMP="continuous_ramp",e.BINS="bins",e.PROPORTION="proportion",e))(ae||{});const qe=20;function an({legend:e}){const{labels:n=[],colors:r=[],isStrokeColor:i=!1,customMarkers:s,maskedMarkers:l=!0}=e,a=Me.getPalette(r,n.length),p=n.length>qe,c=Z.useIntl(),g=j.useImperativeIntl(c);return t.jsxs(t.Fragment,{children:[t.jsx(ln,{"data-testid":"categories-legend",children:n.slice(0,qe).map((h,d)=>t.jsx(ps,{label:String(h),color:a[d%a.length],icon:s&&Array.isArray(s)?s[d]:s,maskedIcon:l,isStrokeColor:i},`${h}${d}`))}),p&&t.jsx(j.Typography,{variant:"caption",color:"textSecondary",component:"div",py:2,children:g.formatMessage({id:"c4r.widgets.legend.maxCategories"},{n:qe})})]})}const cs=({isMax:e,color:n,isStrokeColor:r,theme:i})=>({border:"2px solid transparent","&::after":{position:"absolute",display:e?"block":"none",content:'""',width:i.spacing(2),height:i.spacing(2),border:`2px solid ${i.palette.grey[900]}`,transform:"translate(-30%, -30%)",borderRadius:"50%",boxSizing:"content-box"},...r?{borderColor:n}:{backgroundColor:n}}),ds=({icon:e,color:n,maskedIcon:r})=>({maskRepeat:"no-repeat",maskSize:"cover",backgroundRepeat:"no-repeat",backgroundSize:"cover",...r?{backgroundColor:n,maskImage:`url(${e})`,WebkitMaskImage:`url(${e})`}:{backgroundColor:"rgba(0,0,0,0)",backgroundImage:`url(${e})`}}),us=o.styled(o.Box,{shouldForwardProp:e=>e!=="icon"&&e!=="maskedIcon"&&e!=="color"&&e!=="isStrokeColor"})(({icon:e,maskedIcon:n,color:r,isStrokeColor:i,theme:s})=>({whiteSpace:"nowrap",display:"block",width:s.spacing(1.5),height:s.spacing(1.5),flexShrink:"0",borderRadius:"50%",position:"relative",border:"2px solid transparent",...e?ds({icon:e,color:r,maskedIcon:n}):cs({color:r,isStrokeColor:i,theme:s})}));function ps({label:e,isStrokeColor:n,color:r="#000",icon:i,maskedIcon:s}){return t.jsxs(o.Box,{component:"li",sx:{display:"flex",alignItems:"center"},children:[t.jsx(us,{className:"marker",mr:1.5,component:"span",icon:i,maskedIcon:s,isStrokeColor:n,color:r}),t.jsx(ot,{title:e,visible:!0,typographyProps:{variant:"overline",my:.75}})]})}const Ne=6,We={0:12,1:9,2:6,3:3},gs=o.styled(o.Box,{shouldForwardProp:e=>e!=="index"})(({index:e=0,theme:n})=>{const r=n.spacing(We[e]),i=n.spacing(We[e]);return{border:`solid 1px ${n.palette.divider}`,backgroundColor:n.palette.background.default,borderRadius:"50%",position:"absolute",right:0,bottom:0,width:r,height:i}}),hs=o.styled(o.Box)(({theme:{spacing:e}})=>({display:"flex",justifyContent:"flex-end",flexShrink:0,position:"relative",width:e(We[0]),height:e(We[0])})),fs=o.styled(o.Box)(({theme:{spacing:e}})=>({display:"flex",gap:e(1),alignItems:"stretch",justifyContent:"stretch",padding:e(2,0)})),xs=o.styled(o.Box)(()=>({display:"flex",flexDirection:"column",justifyContent:"space-around",gap:1,flexGrow:1,flexShrink:1}));function cn({legend:e}){const n=Z.useIntl(),r=j.useImperativeIntl(n),i=e.showMinMax??!0,{min:s,max:l,error:a}=ms(e),[p,c]=a?[0,0]:ys(s,l);return t.jsxs(fs,{"data-testid":"proportion-legend",children:[t.jsx(hs,{children:[...Array(4)].map((g,h)=>t.jsx(gs,{index:h,component:"span"},h))}),t.jsx(xs,{children:a?t.jsx(o.Box,{maxWidth:240,children:t.jsx(j.Typography,{variant:"overline",children:"You need to specify valid numbers for the labels property"})}):t.jsxs(t.Fragment,{children:[t.jsxs(j.Typography,{variant:"overline",color:"textSecondary",children:[i&&r.formatMessage({id:"c4r.widgets.legend.max"})+": ",n.formatNumber(l,{maximumSignificantDigits:Ne})]}),t.jsx(j.Typography,{variant:"overline",color:"textSecondary",children:n.formatNumber(c,{maximumSignificantDigits:Ne})}),t.jsx(j.Typography,{variant:"overline",color:"textSecondary",children:n.formatNumber(p,{maximumSignificantDigits:Ne})}),t.jsxs(j.Typography,{variant:"overline",color:"textSecondary",children:[i&&r.formatMessage({id:"c4r.widgets.legend.min"})+": ",n.formatNumber(s,{maximumSignificantDigits:Ne})]})]})})]})}function dn({labels:e}){let n=e==null?void 0:e[e.length-1],r=e==null?void 0:e[0];return Number.isFinite(r)||(r=parseInt(String(r),10)),Number.isFinite(n)||(n=parseInt(String(n),10)),[r,n]}function ms(e){let n=!1;const[r,i]=dn(e);return(Number.isNaN(r)||Number.isNaN(i))&&(n=!0),{min:r,max:i,error:n}}function ys(e,n){const r=(n-e)/3;return[e+r,n-r]}function un({legend:e}){const{labels:n=[],icons:r=[]}=e;return t.jsx(ln,{"data-testid":"icon-legend",children:n.map((i,s)=>t.jsxs(rs,{children:[t.jsx(is,{children:t.jsx("img",{src:r[s],alt:i,width:"auto",height:j.ICON_SIZE_MEDIUM})}),t.jsx(ot,{visible:!0,title:i,typographyProps:{variant:"overline",my:.75}})]},i))})}function vs(e){return typeof e[0]=="object"&&"label"in e[0]}function Qe({isContinuous:e=!1,legend:n}){const{labels:r=[],colors:i=[],showMinMax:s=!0}=n,l=Me.getPalette(i,!r.length||e?2:r.length+1),a=vs(r),p=a?r.map(({value:y})=>y):r,c=a?r.map(({label:y})=>y):r,[g,h]=dn({labels:p}),d=Number.isNaN(g)||Number.isNaN(h);let v=c[c.length-1],f=c[0];return!e&&s&&(f="< "+f,v="≥ "+v),t.jsx(o.Box,{py:2,"data-testid":"ramp-legend",children:d?t.jsx(o.Box,{maxWidth:240,children:t.jsx(j.Typography,{variant:"overline",children:"You need to specify valid numbers for the labels property"})}):t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{display:"flex",pb:1,children:e?t.jsx(js,{"data-testid":"step-continuous",palette:l}):t.jsx(bs,{palette:l,labels:c,max:v,min:f})}),t.jsxs(o.Box,{display:"flex",justifyContent:"space-between",children:[t.jsx(j.Typography,{variant:"overlineDelicate",color:"textSecondary",children:f}),t.jsx(j.Typography,{variant:"overlineDelicate",color:"textSecondary",children:v})]})]})})}const js=o.styled(o.Box,{shouldForwardProp:e=>e!=="palette"})(({palette:e,theme:n})=>({display:"block",flexGrow:1,height:n.spacing(1),borderRadius:n.spacing(.5),background:`linear-gradient(to right, ${e.join()})`})),ws=o.styled(o.Box,{shouldForwardProp:e=>e!=="color"})(({color:e,theme:n})=>({display:"block",flexGrow:1,height:n.spacing(1),backgroundColor:e,"&:first-of-type":{borderRadius:n.spacing(.5,0,0,.5)},"&:last-of-type":{borderRadius:n.spacing(0,.5,.5,0)}}));function bs({labels:e=[],palette:n=[],max:r,min:i}){const s=e.length?[i,...e]:[i,r];return t.jsx(t.Fragment,{children:s.map((l,a)=>{const p=a===0?i:a===s.length-1?r:`${l} - ${s[a+1]}`;return t.jsx(o.Tooltip,{title:p,children:t.jsx(ws,{"data-testid":"step-discontinuous",color:n[a]})},a)})})}const Ss={[ae.CATEGORY]:an,[ae.PROPORTION]:cn,[ae.ICON]:un,[ae.BINS]:e=>t.jsx(Qe,{...e,isContinuous:!1}),[ae.CONTINUOUS_RAMP]:e=>t.jsx(Qe,{...e,isContinuous:!0})};function ks({legend:e}){const n=Z.useIntl(),r=j.useImperativeIntl(n);return e.select||!e.type?null:t.jsxs(j.Typography,{variant:"body2",color:"textSecondary",component:"p",children:[e.type," ",r.formatMessage({id:"c4r.widgets.legend.notSupported"}),"."]})}function Is(e){return e.type===ae.PROPORTION?"c4r.widgets.legend.subtitles.proportion":e.type===ae.ICON||e.customMarkers?"c4r.widgets.legend.subtitles.icon":e.isStrokeColor?"c4r.widgets.legend.subtitles.strokeColor":"c4r.widgets.legend.subtitles.color"}function Ts({layer:e,legend:n,customLegendTypes:r,onChangeSelection:i}){var h;const s=Z.useIntl(),l=j.useImperativeIntl(s),a=n.type,c=Ss[a]??r[a]??ks,g=((h=n.select)==null?void 0:h.options)??[];return t.jsxs(o.Box,{component:"li","data-testid":"legend-layer-variable",px:2,children:[n.attr?t.jsxs(o.Box,{pb:1,children:[t.jsx(j.Typography,{gutterBottom:!0,variant:"overlineDelicate",color:"textSecondary",component:"p",children:l.formatMessage({id:Is(n)})}),t.jsx(j.Typography,{variant:"caption",component:"p",children:n.attr})]}):null,n.select?t.jsxs(o.Box,{pb:1,children:[t.jsx(j.Typography,{variant:"caption",weight:"medium",component:"p",children:n.select.label}),t.jsx(o.Select,{"data-testid":"legend-layer-variable-select",name:"legend-select",value:n.select.value,renderValue:d=>{var v;return((v=g.find(f=>f.value===d))==null?void 0:v.label)??d},onChange:d=>i(d.target.value),MenuProps:{transformOrigin:{vertical:"bottom",horizontal:"left"},anchorOrigin:{vertical:"top",horizontal:"left"},PaperProps:{style:{maxHeight:240}}},children:g.map(d=>t.jsx(o.MenuItem,{value:d.value,children:t.jsx(o.ListItemText,{primary:d.label})},d.value))})]}):null,t.jsx(c,{layer:e,legend:n})]})}const Ms={};function pn(e){return e?Array.isArray(e)?e.every(n=>pn(n)):!e.select&&!e.type:!0}function Tt({customLegendTypes:e=Ms,layer:n,onChangeCollapsed:r,onChangeOpacity:i,onChangeVisibility:s,onChangeSelection:l,maxZoom:a=21,minZoom:p=0,currentZoom:c=0}){const g=Z.useIntl(),h=j.useImperativeIntl(g),d=u.useRef(null),[v,f]=u.useState(!1),y=n.id,m=n.title,x=n.visible??!0,S=n.switchable??!0,b=n.collapsed??!1,k=(n.collapsible??!0)&&!pn(n.legend),I=n.opacity??1,w=n.showOpacityControl??!0,C=x&&!b,A=C?t.jsx(kn,{}):t.jsx(Sn,{}),D=(n==null?void 0:n.minZoom)!==void 0||(n==null?void 0:n.maxZoom)!==void 0,B=n.minZoom??p,P=n.maxZoom??a,L=D&&(B>p||P<a),N=c<B||c>P,V=Cs({intl:h,minZoom:p,maxZoom:a,layerMinZoom:B,layerMaxZoom:P}),_=n.helperText??(L?V:""),T=u.useMemo(()=>n.legend?Array.isArray(n.legend)?n.legend:[n.legend]:[],[n.legend]);return n.legend?t.jsxs(ss,{"data-testid":"legend-layer","aria-label":m,children:[t.jsxs(es,{ref:d,children:[k&&t.jsx(o.IconButton,{size:"small","aria-label":h.formatMessage({id:b?"c4r.widgets.legend.expand":"c4r.widgets.legend.collapse"}),disabled:!x,onClick:()=>r({id:y,collapsed:!b}),children:A}),t.jsxs(ls,{children:[t.jsx(ot,{visible:x,title:m??""}),L&&t.jsx(o.Tooltip,{title:h.formatMessage({id:"c4r.widgets.legend.zoomLevelTooltip"}),children:t.jsxs(j.Typography,{color:x?"textPrimary":"textSecondary",variant:"caption",component:"p",children:[h.formatMessage({id:"c4r.widgets.legend.zoomLevel"})," ",n.minZoom," - ",n.maxZoom]})})]}),w&&x&&!b&&t.jsx(as,{menuRef:d,open:v,toggleOpen:f,opacity:I,onChange:O=>i({id:y,opacity:O})}),S&&t.jsx(o.Tooltip,{title:h.formatMessage({id:x?"c4r.widgets.legend.hideLayer":"c4r.widgets.legend.showLayer"}),children:t.jsx(o.IconButton,{size:"small",onClick:()=>s({id:y,collapsed:x?b:!1,visible:!x}),children:x?t.jsx(wn,{}):t.jsx(bn,{})})})]}),t.jsxs(o.Collapse,{unmountOnExit:!0,timeout:100,in:C,children:[t.jsx(os,{"data-testid":"legend-layer-variable-list",opacity:N?.5:1,children:T.map((O,M)=>t.jsx(Ts,{legend:O,layer:n,customLegendTypes:e,onChangeSelection:$=>l({id:y,index:M,selection:$})},`${O.type}-${M}`))}),_&&t.jsx(j.Typography,{variant:"caption",color:"textSecondary",component:"div",p:2,children:t.jsx("div",{dangerouslySetInnerHTML:{__html:_}})})]})]}):null}function Cs({intl:e,minZoom:n,maxZoom:r,layerMinZoom:i,layerMaxZoom:s}){const l=e.formatMessage({id:"c4r.widgets.legend.and"}),a=e.formatMessage({id:"c4r.widgets.legend.lowerThan"}),p=e.formatMessage({id:"c4r.widgets.legend.greaterThan"}),c=e.formatMessage({id:"c4r.widgets.legend.zoomNote"}),g=s<r?`${a} ${s}`:"",h=i>n?`${p} ${i}`:"",d=[g,h].filter(Boolean).join(` ${l} `);return d?`${c} ${d}`:""}const As={},Ie=()=>{},Es=[];function Bs({customLegendTypes:e=As,layers:n=Es,collapsed:r=!1,onChangeCollapsed:i=Ie,onChangeVisibility:s=Ie,onChangeOpacity:l=Ie,onChangeLegendRowCollapsed:a=Ie,onChangeSelection:p=Ie,title:c="Layers",maxZoom:g=20,minZoom:h=0,currentZoom:d,isMobile:v,sx:f}){const y=Z.useIntl(),m=j.useImperativeIntl(y),x=t.jsxs(Qi,{collapsed:r,children:[t.jsx(j.Typography,{variant:"caption",flexGrow:1,children:c}),t.jsx(o.Tooltip,{title:m.formatMessage({id:"c4r.widgets.legend.close"}),children:t.jsx(o.IconButton,{size:"small",onClick:()=>i(!0),children:t.jsx(vn,{})})})]}),S=t.jsx(o.Tooltip,{title:m.formatMessage({id:"c4r.widgets.legend.open"}),children:t.jsx(o.IconButton,{"aria-label":c,onClick:()=>i(!1),children:t.jsx(jn,{})})});return t.jsx(Ji,{sx:f,elevation:3,collapsed:r||!!v,children:v?t.jsxs(t.Fragment,{children:[S,t.jsxs(o.Drawer,{anchor:"bottom",open:!r,onClose:()=>i(!0),children:[x,t.jsx(It,{children:n.map(b=>t.jsx(Tt,{layer:b,onChangeCollapsed:a,onChangeOpacity:l,onChangeVisibility:s,onChangeSelection:p,maxZoom:g,minZoom:h,currentZoom:d,customLegendTypes:e},b.id))})]})]}):t.jsxs(t.Fragment,{children:[r?S:x,t.jsx(It,{width:r?0:void 0,children:t.jsx(o.Collapse,{unmountOnExit:!0,in:!r,timeout:500,children:n.map(b=>t.jsx(Tt,{layer:b,onChangeCollapsed:a,onChangeOpacity:l,onChangeVisibility:s,onChangeSelection:p,maxZoom:g,minZoom:h,currentZoom:d,customLegendTypes:e},b.id))})})]})})}function Mt({color:e=void 0,children:n}){return n?t.jsx(o.Box,{mt:.5,children:t.jsx(j.Typography,{component:"div",variant:"caption",color:e??"inherit",style:{fontWeight:"normal"},children:n})}):t.jsx(o.Box,{mt:-1})}function Ps({title:e="No data available",body:n="There are no results for the combination of filters applied to your data. Try tweaking your filters, or zoom and pan the map to adjust the Map View.",severity:r=void 0,...i}){return r?t.jsx(In.Alert,{title:e,severity:r,...i,children:t.jsx(Mt,{children:n})}):t.jsxs(o.Box,{...i,children:[e&&t.jsx(j.Typography,{variant:"body2",children:e}),t.jsx(Mt,{color:"textSecondary",children:n})]})}const Ls=o.styled(o.Box,{shouldForwardProp:e=>e!=="margin"})(({theme:e,margin:n})=>({margin:0,position:"relative",maxWidth:"100%",padding:n??e.spacing(2,2.5)})),Ds=o.styled(o.LinearProgress)(({theme:e})=>({position:"absolute",top:0,left:0,width:"100%",height:e.spacing(.25)})),Ns=o.styled(o.Grid,{shouldForwardProp:e=>e!=="expanded"})(({theme:e,expanded:n=!0})=>({display:"flex",flexDirection:"row",alignItems:"flex-start",justifyContent:"space-between",width:"100%",...n?{minHeight:e.spacing(3)}:{height:e.spacing(3)},padding:0})),$s=o.styled(o.Button,{shouldForwardProp:e=>e!=="expandable"})(({theme:e,expandable:n=!0})=>({flex:1,padding:0,alignItems:"flex-start",justifyContent:"flex-start",height:"auto",minHeight:"auto",marginBottom:e.spacing(1),cursor:n?"pointer":"default","& .MuiButton-startIcon":{marginTop:"3px",marginRight:e.spacing(1)},"&:hover":{background:"none"}})),gn=({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",width:e.spacing(3),height:e.spacing(3),color:e.palette.text.secondary}),Os=o.styled(fe.ExpandLess)(({theme:e})=>gn({theme:e})),Rs=o.styled(fe.ExpandMore)(({theme:e})=>gn({theme:e})),Fs=o.styled(o.Typography,{shouldForwardProp:e=>e!=="expanded"})(({expanded:e=!0})=>({wordBreak:"break-word",overflow:"hidden",...e&&{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},...!e&&{whiteSpace:"nowrap",textOverflow:"ellipsis"}})),Ws=o.styled(o.Grid)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1),marginRight:e.spacing(-.5),marginLeft:e.spacing(1)})),Ct=o.styled(o.IconButton)(({theme:e})=>({color:e.palette.text.secondary})),_s=o.styled(o.Menu)(({theme:e})=>({".MuiPaper-root":{marginTop:e.spacing(5),maxHeight:e.spacing(21),minWidth:e.spacing(16)}})),At=[],Gs=t.jsx(fe.MoreVert,{});function Hs({title:e,actions:n=At,options:r=At,optionsIcon:i=Gs,children:s,contentProps:l,disabled:a=!1,expandable:p=!0,expanded:c=!0,onExpandedChange:g,footer:h,headerItems:d,isLoading:v=!1,margin:f}){const y=u.createRef(),[m,x]=u.useState(!0),S=c!==void 0&&g!==void 0,b=p!==!1?S?c:m:!0,k=S?g:x,[I,w]=u.useState(null),C=!!I,A=()=>{p&&k(!b)},D=N=>w(N.currentTarget),B=()=>w(null);function P(N){N&&N(),B()}const L=N=>t.jsx(Ct,{"aria-label":N.label,onClick:N.action,size:"small",children:N.icon},N.id);return a?s?t.jsx(t.Fragment,{children:s}):null:t.jsxs(Ls,{margin:f,component:"section","aria-label":e,children:[v?t.jsx(Ds,{}):null,t.jsxs(Ns,{container:!0,expanded:c,children:[t.jsx($s,{expandable:p,startIcon:p&&t.jsx(o.Icon,{children:b?t.jsx(Os,{}):t.jsx(Rs,{})}),onClick:A,tabIndex:p?0:-1,children:t.jsx(o.Tooltip,{title:e,children:t.jsx(Fs,{expanded:c,align:"left",variant:"subtitle1",children:e})})}),t.jsxs(Ws,{item:!0,children:[d,n.length>0&&n.map(N=>N.tooltip?t.jsx(o.Tooltip,{title:N.tooltip.text,placement:N.tooltip.placement??"top",children:L(N)},N.id):L(N)),r.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(Ct,{"aria-label":"options","aria-controls":"options-menu","aria-haspopup":"true",onClick:D,size:"small",children:i}),t.jsx(_s,{id:"options-menu",elevation:8,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},anchorEl:I,keepMounted:!0,open:C,onClose:B,children:r.map(N=>t.jsx(o.MenuItem,{selected:N.selected,onClick:()=>P(N.action),children:N.name},N.id))})]})]})]}),t.jsx(o.Collapse,{ref:y,in:b,timeout:"auto",unmountOnExit:!0,children:t.jsxs(o.Box,{...l,children:[t.jsx(o.Box,{pt:1,children:s}),h??t.jsx(o.Box,{children:h})]})})]})}exports.BarWidgetUI=On;exports.CategoryWidgetUI=qn;exports.ComparativeCategoryWidgetUI=Ii;exports.ComparativeFormulaWidgetUI=Di;exports.ComparativePieWidgetUI=_i;exports.FeatureSelectionUIDropdown=on;exports.FeatureSelectionUIGeometryChips=rn;exports.FeatureSelectionUIToggleButton=nn;exports.FeatureSelectionWidgetUI=Zi;exports.FormulaWidgetUI=Jn;exports.GroupDateTypes=le;exports.HistogramWidgetUI=lo;exports.LEGEND_TYPES=ae;exports.LegendCategories=an;exports.LegendIcon=un;exports.LegendProportion=cn;exports.LegendRamp=Qe;exports.LegendWidgetUI=Bs;exports.NoDataAlert=Ps;exports.PieWidgetUI=$o;exports.RangeWidgetUI=Vo;exports.ScatterPlotWidgetUI=tr;exports.TIME_SERIES_CHART_TYPES=Ge;exports.TableWidgetUI=pr;exports.TimeSeriesProvider=Yt;exports.TimeSeriesWidgetUI=oi;exports.WrapperWidgetUI=Hs;exports.useTimeSeriesContext=He;exports.useTimeSeriesInteractivity=Vt;
29
+ `,a=Array.isArray(e)?e[0]:e;if(!a)return null;const l=a.data,p=n(l.value),c=i?a.seriesName:p,g=n(a.percent);return`
30
+ <p style="${r}">${l.name}</p>
31
+ <p style="${s}">${String(a.marker)} ${c} (${g} %)</p>
32
+ `.trim()}const Pr=e=>e,Lr=()=>{},De=[],Dr="260px";function Nr({names:e=De,data:n=De,labels:i=De,colors:r=De,height:s=Dr,animation:a=!0,formatter:l=Pr,tooltipFormatter:p=Br,selectedCategories:c=[],onCategorySelected:g=Lr,isLoading:h=!1}){const d=o.useTheme(),y=u.useRef(),f=u.useMemo(()=>n.map((S,b)=>Er(S,r[b],i[b],d,c)),[n,r,i,d,c]),m=u.useMemo(()=>{const S=f.length>1;let b;p&&(b=B=>p(B,l,S));const k={trigger:"item",show:!0,backgroundColor:d.palette.black[90],textStyle:{color:d.palette.common.white},confine:!0,borderWidth:0,formatter:b},w={data:S?f.map((B,L)=>e[L]):(f[0]??[]).map(B=>B.name),selectedMode:!1,type:"scroll",left:j.SPACING,bottom:j.SPACING*-.5,itemGap:j.SPACING*3,icon:"circle",itemWidth:j.SPACING,itemHeight:j.SPACING,textStyle:{...d.typography.overline,color:d.palette.text.primary,fontWeight:400,lineHeight:1,verticalAlign:"bottom",padding:[0,0,0,j.SPACING*.5]},inactiveColor:d.palette.text.disabled,pageIcons:{horizontal:["path://M15.41 7.41 14 6 8 12 14 18 15.41 16.59 10.83 12z","path://M9 16.59 13.3265857 12 9 7.41 10.3319838 6 16 12 10.3319838 18z"]},pageIconSize:j.SPACING*1.5,pageIconColor:d.palette.text.secondary,pageIconInactiveColor:d.palette.text.disabled,pageTextStyle:{fontFamily:d.typography.overline.fontFamily,fontSize:j.SPACING*1.5,lineHeight:j.SPACING*1.75,fontWeight:400,color:d.palette.text.primary}},M={formatter:({name:B,percent:L})=>`{per|${l(L)}%}
33
+ {b|${B}}`,position:"center",rich:{b:{fontFamily:d.typography.overline.fontFamily,fontSize:j.SPACING*1.75,lineHeight:j.SPACING*1.75,fontWeight:400,color:d.palette.text.primary},per:{...d.typography.overline,fontSize:j.SPACING*3,lineHeight:j.SPACING*4.5,fontWeight:600,color:d.palette.text.primary}}},C=f.map((B,L)=>{var P;return{type:"pie",name:e[L],itemStyle:{color:(P=B[0])==null?void 0:P.color},animation:a,data:B.map(O=>({...O,itemStyle:{color:O.color}})),radius:L===0?["75%","90%"]:["56%","72%"],selectedOffset:0,hoverOffset:5,bottom:j.SPACING*2.5,avoidLabelOverlap:!0,label:{show:!1,...M},emphasis:{label:{show:!0,formatter:M.formatter,rich:M.rich}}}});return{grid:{left:0,top:0,right:0,bottom:0},tooltip:k,legend:w,series:C}},[d,e,a,f,l,p]),v={mouseover:(S,b)=>{f.length===1&&(S.seriesIndex!==0||S.dataIndex!==0)&&b.dispatchAction({type:"downplay",seriesIndex:0,dataIndex:0})},mouseout:(S,b)=>{f.length===1&&b.dispatchAction({type:"highlight",seriesIndex:0,dataIndex:0})},click:S=>{const k=f[S.seriesIndex][S.dataIndex].key,I=c.includes(k),w=new Set(c);I?w.delete(k):w.add(k);const M=f[0].length;let C=Array.from(w);C.length===M&&(C=[]),g(C)}};u.useEffect(()=>{y.current&&y.current.dispatchAction({type:f.length===1?"highlight":"downplay",seriesIndex:0,dataIndex:0})},[f]);function x(S){y.current=S}return f.length?h?t.jsx(Rt,{height:s}):t.jsx(ye,{onChartReady:x,notMerge:!0,option:m,onEvents:v,style:{maxHeight:s,width:"100%"}}):null}const Or=()=>{};function tn({icon:e,hoverTooltip:n,clickTooltip:i,enabled:r,onEnabledChange:s=Or,tooltipPlacement:a="bottom"}){const[l,p]=u.useState(!1),[c,g]=u.useState(r);u.useEffect(()=>{g(r)},[r]),u.useEffect(()=>{if(r){const d=y=>{y.key==="Escape"&&s&&s(!1)};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d)}}},[r,s]);const h=c?i:n;return t.jsx(o.ClickAwayListener,{onClickAway:()=>g(!1),children:t.jsx(o.Tooltip,{title:h,placement:a,open:l,onOpen:()=>p(!0),onClose:()=>{c||p(!1)},children:t.jsx(o.ToggleButton,{value:"selectedMode",selected:r,onClick:()=>s&&s(!r),children:e})})})}const $r=o.styled(o.IconButton,{shouldForwardProp:e=>e!=="isOpen"})(({isOpen:e,theme:n})=>({color:n.palette.text.secondary,width:n.spacing(3),transform:`rotate(${e?"180":"0"}deg)`,backgroundColor:e?n.palette.action.hover:void 0})),Rr=o.styled(o.MenuItem,{shouldForwardProp:e=>e!=="disabled"})(({disabled:e,theme:n})=>({...e&&{pointerEvents:"none",color:n.palette.text.disabled}})),Fr=o.styled(o.MenuItem)(()=>({"&.Mui-disabled":{opacity:1}})),Wr=()=>{};function nn({selectionModes:e,editModes:n,selectedMode:i,onSelectMode:r=Wr,enabled:s,tooltipPlacement:a="bottom",tooltipText:l="",menuHeaderText:p="",editDisabled:c}){const g=o.useTheme(),[h,d]=u.useState(null),y=!!h,f=k=>d(k.currentTarget),m=()=>d(null),v=k=>{r&&r(k),m()},x=!!e.length&&!!n.length,S=k=>n.some(I=>I.id===k.id);function b(k){return t.jsx(Rr,{selected:s&&i===k.id,onClick:()=>v(k.id),disabled:c&&S(k),children:t.jsxs(o.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[k.icon,t.jsx(o.Box,{ml:2,children:t.jsx(j.Typography,{variant:"body2",color:"inherit",children:o.capitalize(k.label)})})]})},k.id)}return t.jsxs(t.Fragment,{children:[t.jsx(o.Tooltip,{title:l,placement:a,children:t.jsx($r,{id:"feature-selection-menu-button","aria-controls":"feature-selection-menu","aria-haspopup":"true","aria-expanded":y?"true":void 0,onClick:f,isOpen:y,children:t.jsx(ee.KeyboardArrowDown,{})})}),t.jsxs(o.Menu,{id:"feature-selection-menu",style:{zIndex:g.zIndex.tooltip+1},anchorEl:h,open:y,onClose:m,MenuListProps:{"aria-labelledby":"feature-selection-menu-button"},children:[p&&t.jsx(Fr,{disabled:!0,children:t.jsx(j.Typography,{variant:"caption",color:"textSecondary",children:p})}),!!e.length&&e.map(b),x&&t.jsx(o.Divider,{sx:{margin:({spacing:k})=>k(1,0)}}),!!n.length&&n.map(b)]})]})}const _r=o.styled(o.List)(({theme:e})=>({display:"flex",alignItems:"center",marginLeft:e.spacing(1.5),padding:e.spacing(.5),overflowX:"auto",maxWidth:"100%",scrollbarWidth:"none",msOverflowStyle:"none","&::-webkit-scrollbar":{display:"none"}})),Gr=()=>{};function on({features:e,onSelectGeometry:n=Gr,onDeleteGeometry:i,chipTooltip:r,disabledChipTooltip:s,size:a="medium",tooltipPlacement:l="bottom",chipLabel:p}){const c=J.useIntl(),g=j.useImperativeIntl(c);function h(m){return m==="MultiPoint"?g.formatMessage({id:"c4r.widgets.featureSelection.point"}):m==="MultiLineString"?g.formatMessage({id:"c4r.widgets.featureSelection.lineString"}):m==="MultiPolygon"||m==="Polygon"||m==="GeometryCollection"?g.formatMessage({id:"c4r.widgets.featureSelection.polygon"}):m}function d(m,v){var S;const x=h(m.geometry.type);return p||((S=m.properties)==null?void 0:S.name)||`${x} ${v+1}`}const[y,f]=u.useState(!1);return t.jsx(o.Box,{sx:{overflowX:"auto"},children:t.jsx(_r,{sx:{gap:a==="small"?.5:1},children:e.map((m,v)=>{var I,w;const x=(I=m.properties)==null?void 0:I.disabled,S=(w=m.properties)==null?void 0:w.invalid;let b=r;x&&(b=s||r),S&&(b=g.formatMessage({id:"c4r.widgets.featureSelection.invalid"})),y&&(b=g.formatMessage({id:"c4r.widgets.featureSelection.remove"}));let k="secondary";return x&&(k="default"),S&&(k="error"),t.jsx(o.ListItem,{disablePadding:!0,children:t.jsx(o.Tooltip,{disableHoverListener:x?!s:!r,title:b,placement:l,children:t.jsx(o.Chip,{size:a,label:d(m,v),color:k,onClick:()=>n(m),onDelete:i?()=>i(m):void 0,icon:S?t.jsx(ee.ErrorOutline,{color:"error"}):void 0,deleteIcon:t.jsx(ee.Cancel,{onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1)})})})},v)})})})}const Hr=o.styled(o.Paper)(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",maxHeight:e.spacing(5),padding:e.spacing(.5)})),zr=[];function Yr({selectionModes:e,editModes:n=zr,selectedMode:i,onSelectMode:r,enabled:s=!1,onEnabledChange:a,geometry:l,onSelectGeometry:p,onDeleteGeometry:c,tooltipPlacement:g="bottom",size:h="medium",chipLabel:d}){const y=J.useIntl(),f=j.useImperativeIntl(y),m=u.useMemo(()=>e.map(I=>({...I,label:f.formatMessage({id:`c4r.widgets.featureSelection.${kt(I.id)}`})})),[e,f]),v=u.useMemo(()=>n.map(I=>({...I,label:f.formatMessage({id:`c4r.widgets.featureSelection.${kt(I.id)}`})})),[n,f]),x=u.useMemo(()=>{const w=[...m.map(M=>({...M,isEdit:!1})),...v.map(M=>({...M,isEdit:!0}))].find(M=>M.id===i);if(!w)throw new Error(`Selected mode "${i}" not supported`);return w},[v,m,i]),S=o.capitalize((x==null?void 0:x.label)||""),b=x!=null&&x.isEdit?S:f.formatMessage({id:"c4r.widgets.featureSelection.selectTool"},{label:S}),k=x!=null&&x.isEdit?f.formatMessage({id:"c4r.widgets.featureSelection.clickToEdit"}):f.formatMessage({id:"c4r.widgets.featureSelection.clickToCreate"});return t.jsxs(Hr,{children:[t.jsx(tn,{icon:x==null?void 0:x.icon,hoverTooltip:b,clickTooltip:k,enabled:s,onEnabledChange:a,tooltipPlacement:g}),t.jsx(nn,{selectionModes:m,editModes:v,selectedMode:i,onSelectMode:r,enabled:s,tooltipPlacement:g,tooltipText:f.formatMessage({id:"c4r.widgets.featureSelection.selectMode"}),menuHeaderText:f.formatMessage({id:"c4r.widgets.featureSelection.chooseSelectionMode"}),editDisabled:!l}),!!l&&t.jsx(on,{features:[l],onSelectGeometry:p,onDeleteGeometry:c,disabledChipTooltip:f.formatMessage({id:"c4r.widgets.featureSelection.applyMask"}),chipTooltip:f.formatMessage({id:"c4r.widgets.featureSelection.clearMask"}),tooltipPlacement:g,size:h,chipLabel:d})]})}function kt(e){return e.charAt(0).toLowerCase()+e.slice(1)}const rn=240,Vr=o.styled(o.Paper,{shouldForwardProp:e=>e!=="collapsed"})(({theme:e,collapsed:n})=>({width:n?"min-content":rn,background:e.palette.background.paper,maxHeight:"calc(100% - 120px)",display:"flex",flexDirection:"column"})),Ur=o.styled("header",{shouldForwardProp:e=>e!=="collapsed"})(({theme:e,collapsed:n})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:e.spacing(1),paddingLeft:e.spacing(2),borderBottom:n?void 0:`1px solid ${e.palette.divider}`})),qr=o.styled("header")(({theme:e})=>({padding:e.spacing(1.5),paddingRight:e.spacing(2),gap:e.spacing(.5),display:"flex",justifyContent:"space-between",position:"sticky",zIndex:2,top:0,background:e.palette.background.paper})),Kr=o.styled("div")(({theme:e})=>({display:"flex",gap:e.spacing(2),alignItems:"center",padding:e.spacing(1),minWidth:`calc(${rn}px - ${e.spacing(4)})`})),Xr=o.styled(o.TextField)(({theme:e})=>({display:"flex",width:e.spacing(7.5),flexShrink:0,"input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button":{WebkitAppearance:"none",margin:0}})),Zr=o.styled("ul",{shouldForwardProp:e=>e!=="opacity"})(({theme:e,opacity:n})=>({opacity:n,margin:0,padding:0,display:"flex",flexDirection:"column",gap:e.spacing(1)})),sn=o.styled("ul")(({theme:e})=>({margin:0,padding:0,paddingBottom:e.spacing(1),display:"flex",flexDirection:"column"})),Jr=o.styled("li")(()=>({display:"flex",alignItems:"center"})),Qr=o.styled("div")(({theme:e})=>({marginRight:e.spacing(1.5),width:j.ICON_SIZE_MEDIUM,height:j.ICON_SIZE_MEDIUM,"& img":{margin:"auto",display:"block"}})),It=o.styled(o.Box,{shouldForwardProp:e=>e!=="width"})(({width:e,theme:n})=>({width:e,overflow:"auto",maxHeight:`calc(100% - ${n.spacing(1.5)})`})),es=o.styled("section")(({theme:e})=>({"&:not(:first-of-type)":{borderTop:`1px solid ${e.palette.divider}`}})),ts=o.styled("div")(()=>({flexGrow:1,flexShrink:1,minWidth:0}));function ns({menuRef:e,open:n,toggleOpen:i,opacity:r,onChange:s}){const a=J.useIntl(),l=j.useImperativeIntl(a);function p(c){const g=parseInt(c.target.value||"0"),h=Math.min(Math.max(g,0),100);s(h/100)}return t.jsxs(t.Fragment,{children:[t.jsx(o.Tooltip,{title:l.formatMessage({id:"c4r.widgets.legend.opacity"}),children:t.jsx(o.IconButton,{size:"small",color:n?"primary":"default",onClick:()=>i(!n),children:t.jsx(Te.SwatchSquare,{})})}),t.jsx(o.Popover,{open:n,onClose:()=>i(!1),anchorEl:e.current,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{root:{sx:{transform:"translate(-12px, 36px)"}}},children:t.jsxs(Kr,{children:[t.jsx(o.Slider,{value:r*100,onChange:(c,g)=>s(g/100),min:0,max:100,step:1}),t.jsx(Xr,{size:"small",type:"number",value:Math.round(r*100),onChange:p,inputProps:{step:1,min:0,max:100,style:{appearance:"textfield"},"data-testid":"opacity-slider"},InputProps:{endAdornment:t.jsxs(o.InputAdornment,{position:"end",sx:{margin:0},children:[" ","%"]})}})]})})]})}function ot({title:e,visible:n,typographyProps:i}){const r=u.useRef(null),[s,a]=u.useState(!1);u.useLayoutEffect(()=>{if(n&&r.current){const{offsetWidth:p,scrollWidth:c}=r.current;a(p<c)}},[e,n]);const l=t.jsx(j.Typography,{ref:r,color:n?"textPrimary":"textSecondary",variant:"button",weight:"medium",component:"p",noWrap:!0,my:.25,...i,children:e});return s?t.jsx(o.Tooltip,{title:e,children:l}):l}var ce=(e=>(e.CATEGORY="category",e.ICON="icon",e.CONTINUOUS_RAMP="continuous_ramp",e.BINS="bins",e.PROPORTION="proportion",e))(ce||{});const qe=20;function an({legend:e}){const{labels:n=[],colors:i=[],isStrokeColor:r=!1,customMarkers:s,maskedMarkers:a=!0}=e,l=Me.getPalette(i,n.length),p=n.length>qe,c=J.useIntl(),g=j.useImperativeIntl(c);return t.jsxs(t.Fragment,{children:[t.jsx(sn,{"data-testid":"categories-legend",children:n.slice(0,qe).map((h,d)=>t.jsx(ss,{label:String(h),color:l[d%l.length],icon:s&&Array.isArray(s)?s[d]:s,maskedIcon:a,isStrokeColor:r},`${h}${d}`))}),p&&t.jsx(j.Typography,{variant:"caption",color:"textSecondary",component:"div",py:2,children:g.formatMessage({id:"c4r.widgets.legend.maxCategories"},{n:qe})})]})}const os=({isMax:e,color:n,isStrokeColor:i,theme:r})=>({border:"2px solid transparent","&::after":{position:"absolute",display:e?"block":"none",content:'""',width:r.spacing(2),height:r.spacing(2),border:`2px solid ${r.palette.grey[900]}`,transform:"translate(-30%, -30%)",borderRadius:"50%",boxSizing:"content-box"},...i?{borderColor:n}:{backgroundColor:n}}),is=({icon:e,color:n,maskedIcon:i})=>({maskRepeat:"no-repeat",maskSize:"cover",backgroundRepeat:"no-repeat",backgroundSize:"cover",...i?{backgroundColor:n,maskImage:`url(${e})`,WebkitMaskImage:`url(${e})`}:{backgroundColor:"rgba(0,0,0,0)",backgroundImage:`url(${e})`}}),rs=o.styled(o.Box,{shouldForwardProp:e=>e!=="icon"&&e!=="maskedIcon"&&e!=="color"&&e!=="isStrokeColor"})(({icon:e,maskedIcon:n,color:i,isStrokeColor:r,theme:s})=>({whiteSpace:"nowrap",display:"block",width:s.spacing(1.5),height:s.spacing(1.5),flexShrink:"0",borderRadius:"50%",position:"relative",border:"2px solid transparent",...e?is({icon:e,color:i,maskedIcon:n}):os({color:i,isStrokeColor:r,theme:s})}));function ss({label:e,isStrokeColor:n,color:i="#000",icon:r,maskedIcon:s}){return t.jsxs(o.Box,{component:"li",sx:{display:"flex",alignItems:"center"},children:[t.jsx(rs,{className:"marker",mr:1.5,component:"span",icon:r,maskedIcon:s,isStrokeColor:n,color:i}),t.jsx(ot,{title:e,visible:!0,typographyProps:{variant:"overline",my:.75}})]})}const Ne=6,We={0:12,1:9,2:6,3:3},as=o.styled(o.Box,{shouldForwardProp:e=>e!=="index"})(({index:e=0,theme:n})=>{const i=n.spacing(We[e]),r=n.spacing(We[e]);return{border:`solid 1px ${n.palette.divider}`,backgroundColor:n.palette.background.default,borderRadius:"50%",position:"absolute",right:0,bottom:0,width:i,height:r}}),ls=o.styled(o.Box)(({theme:{spacing:e}})=>({display:"flex",justifyContent:"flex-end",flexShrink:0,position:"relative",width:e(We[0]),height:e(We[0])})),cs=o.styled(o.Box)(({theme:{spacing:e}})=>({display:"flex",gap:e(1),alignItems:"stretch",justifyContent:"stretch",padding:e(2,0)})),ds=o.styled(o.Box)(()=>({display:"flex",flexDirection:"column",justifyContent:"space-around",gap:1,flexGrow:1,flexShrink:1}));function ln({legend:e}){const n=J.useIntl(),i=j.useImperativeIntl(n),r=e.showMinMax??!0,{min:s,max:a,error:l}=us(e),[p,c]=l?[0,0]:ps(s,a);return t.jsxs(cs,{"data-testid":"proportion-legend",children:[t.jsx(ls,{children:[...Array(4)].map((g,h)=>t.jsx(as,{index:h,component:"span"},h))}),t.jsx(ds,{children:l?t.jsx(o.Box,{maxWidth:240,children:t.jsx(j.Typography,{variant:"overline",children:"You need to specify valid numbers for the labels property"})}):t.jsxs(t.Fragment,{children:[t.jsxs(j.Typography,{variant:"overline",color:"textSecondary",children:[r&&i.formatMessage({id:"c4r.widgets.legend.max"})+": ",n.formatNumber(a,{maximumSignificantDigits:Ne})]}),t.jsx(j.Typography,{variant:"overline",color:"textSecondary",children:n.formatNumber(c,{maximumSignificantDigits:Ne})}),t.jsx(j.Typography,{variant:"overline",color:"textSecondary",children:n.formatNumber(p,{maximumSignificantDigits:Ne})}),t.jsxs(j.Typography,{variant:"overline",color:"textSecondary",children:[r&&i.formatMessage({id:"c4r.widgets.legend.min"})+": ",n.formatNumber(s,{maximumSignificantDigits:Ne})]})]})})]})}function cn({labels:e}){let n=e==null?void 0:e[e.length-1],i=e==null?void 0:e[0];return Number.isFinite(i)||(i=parseInt(String(i),10)),Number.isFinite(n)||(n=parseInt(String(n),10)),[i,n]}function us(e){let n=!1;const[i,r]=cn(e);return(Number.isNaN(i)||Number.isNaN(r))&&(n=!0),{min:i,max:r,error:n}}function ps(e,n){const i=(n-e)/3;return[e+i,n-i]}function dn({legend:e}){const{labels:n=[],icons:i=[]}=e;return t.jsx(sn,{"data-testid":"icon-legend",children:n.map((r,s)=>t.jsxs(Jr,{children:[t.jsx(Qr,{children:t.jsx("img",{src:i[s],alt:r,width:"auto",height:j.ICON_SIZE_MEDIUM})}),t.jsx(ot,{visible:!0,title:r,typographyProps:{variant:"overline",my:.75}})]},r))})}function gs(e){return typeof e[0]=="object"&&"label"in e[0]}function Qe({isContinuous:e=!1,legend:n}){const{labels:i=[],colors:r=[],showMinMax:s=!0}=n,a=Me.getPalette(r,!i.length||e?2:i.length+1),l=gs(i),p=l?i.map(({value:m})=>m):i,c=l?i.map(({label:m})=>m):i,[g,h]=cn({labels:p}),d=Number.isNaN(g)||Number.isNaN(h);let y=c[c.length-1],f=c[0];return!e&&s&&(f="< "+f,y="≥ "+y),t.jsx(o.Box,{py:2,"data-testid":"ramp-legend",children:d?t.jsx(o.Box,{maxWidth:240,children:t.jsx(j.Typography,{variant:"overline",children:"You need to specify valid numbers for the labels property"})}):t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{display:"flex",pb:1,children:e?t.jsx(hs,{"data-testid":"step-continuous",palette:a}):t.jsx(xs,{palette:a,labels:c,max:y,min:f})}),t.jsxs(o.Box,{display:"flex",justifyContent:"space-between",children:[t.jsx(j.Typography,{variant:"overlineDelicate",color:"textSecondary",children:f}),t.jsx(j.Typography,{variant:"overlineDelicate",color:"textSecondary",children:y})]})]})})}const hs=o.styled(o.Box,{shouldForwardProp:e=>e!=="palette"})(({palette:e,theme:n})=>({display:"block",flexGrow:1,height:n.spacing(1),borderRadius:n.spacing(.5),background:`linear-gradient(to right, ${e.join()})`})),fs=o.styled(o.Box,{shouldForwardProp:e=>e!=="color"})(({color:e,theme:n})=>({display:"block",flexGrow:1,height:n.spacing(1),backgroundColor:e,"&:first-of-type":{borderRadius:n.spacing(.5,0,0,.5)},"&:last-of-type":{borderRadius:n.spacing(0,.5,.5,0)}}));function xs({labels:e=[],palette:n=[],max:i,min:r}){const s=e.length?[r,...e]:[r,i];return t.jsx(t.Fragment,{children:s.map((a,l)=>{const p=l===0?r:l===s.length-1?i:`${a} - ${s[l+1]}`;return t.jsx(o.Tooltip,{title:p,children:t.jsx(fs,{"data-testid":"step-discontinuous",color:n[l]})},l)})})}const ms={[ce.CATEGORY]:an,[ce.PROPORTION]:ln,[ce.ICON]:dn,[ce.BINS]:e=>t.jsx(Qe,{...e,isContinuous:!1}),[ce.CONTINUOUS_RAMP]:e=>t.jsx(Qe,{...e,isContinuous:!0})};function ys({legend:e}){const n=J.useIntl(),i=j.useImperativeIntl(n);return e.select||!e.type?null:t.jsxs(j.Typography,{variant:"body2",color:"textSecondary",component:"p",children:[e.type," ",i.formatMessage({id:"c4r.widgets.legend.notSupported"}),"."]})}function vs(e){return e.type===ce.PROPORTION?"c4r.widgets.legend.subtitles.proportion":e.type===ce.ICON||e.customMarkers?"c4r.widgets.legend.subtitles.icon":e.isStrokeColor?"c4r.widgets.legend.subtitles.strokeColor":"c4r.widgets.legend.subtitles.color"}function js({layer:e,legend:n,customLegendTypes:i,onChangeSelection:r}){var h;const s=J.useIntl(),a=j.useImperativeIntl(s),l=n.type,c=ms[l]??i[l]??ys,g=((h=n.select)==null?void 0:h.options)??[];return t.jsxs(o.Box,{component:"li","data-testid":"legend-layer-variable",px:2,children:[n.attr?t.jsxs(o.Box,{pb:1,children:[t.jsx(j.Typography,{gutterBottom:!0,variant:"overlineDelicate",color:"textSecondary",component:"p",children:a.formatMessage({id:vs(n)})}),t.jsx(j.Typography,{variant:"caption",component:"p",children:n.attr})]}):null,n.select?t.jsxs(o.Box,{pb:1,children:[t.jsx(j.Typography,{variant:"caption",weight:"medium",component:"p",children:n.select.label}),t.jsx(o.Select,{"data-testid":"legend-layer-variable-select",name:"legend-select",value:n.select.value,renderValue:d=>{var y;return((y=g.find(f=>f.value===d))==null?void 0:y.label)??d},onChange:d=>r(d.target.value),MenuProps:{transformOrigin:{vertical:"bottom",horizontal:"left"},anchorOrigin:{vertical:"top",horizontal:"left"},PaperProps:{style:{maxHeight:240}}},children:g.map(d=>t.jsx(o.MenuItem,{value:d.value,children:t.jsx(o.ListItemText,{primary:d.label})},d.value))})]}):null,t.jsx(c,{layer:e,legend:n})]})}const ws={};function un(e){return e?Array.isArray(e)?e.every(n=>un(n)):!e.select&&!e.type:!0}function Tt({customLegendTypes:e=ws,layer:n,onChangeCollapsed:i,onChangeOpacity:r,onChangeVisibility:s,onChangeSelection:a,maxZoom:l=21,minZoom:p=0,currentZoom:c=0}){const g=J.useIntl(),h=j.useImperativeIntl(g),d=u.useRef(null),[y,f]=u.useState(!1),m=n.id,v=n.title,x=n.visible??!0,S=n.switchable??!0,b=n.collapsed??!1,k=(n.collapsible??!0)&&!un(n.legend),I=n.opacity??1,w=n.showOpacityControl??!0,M=x&&!b,C=M?t.jsx(ee.ExpandLess,{}):t.jsx(ee.ExpandMore,{}),D=(n==null?void 0:n.minZoom)!==void 0||(n==null?void 0:n.maxZoom)!==void 0,B=n.minZoom??p,L=n.maxZoom??l,P=D&&(B>p||L<l),O=c<B||c>L,V=bs({intl:h,minZoom:p,maxZoom:l,layerMinZoom:B,layerMaxZoom:L}),_=n.helperText??(P?V:""),E=u.useMemo(()=>n.legend?Array.isArray(n.legend)?n.legend:[n.legend]:[],[n.legend]);return n.legend?t.jsxs(es,{"data-testid":"legend-layer","aria-label":v,children:[t.jsxs(qr,{ref:d,children:[k&&t.jsx(o.IconButton,{size:"small","aria-label":h.formatMessage({id:b?"c4r.widgets.legend.expand":"c4r.widgets.legend.collapse"}),disabled:!x,onClick:()=>i({id:m,collapsed:!b}),children:C}),t.jsxs(ts,{children:[t.jsx(ot,{visible:x,title:v??""}),P&&t.jsx(o.Tooltip,{title:h.formatMessage({id:"c4r.widgets.legend.zoomLevelTooltip"}),children:t.jsxs(j.Typography,{color:x?"textPrimary":"textSecondary",variant:"caption",component:"p",children:[h.formatMessage({id:"c4r.widgets.legend.zoomLevel"})," ",n.minZoom," - ",n.maxZoom]})})]}),w&&x&&!b&&t.jsx(ns,{menuRef:d,open:y,toggleOpen:f,opacity:I,onChange:N=>r({id:m,opacity:N})}),S&&t.jsx(o.Tooltip,{title:h.formatMessage({id:x?"c4r.widgets.legend.hideLayer":"c4r.widgets.legend.showLayer"}),children:t.jsx(o.IconButton,{size:"small",onClick:()=>s({id:m,collapsed:x?b:!1,visible:!x}),children:x?t.jsx(ee.VisibilityOutlined,{}):t.jsx(ee.VisibilityOffOutlined,{})})})]}),t.jsxs(o.Collapse,{unmountOnExit:!0,timeout:100,in:M,children:[t.jsx(Zr,{"data-testid":"legend-layer-variable-list",opacity:O?.5:1,children:E.map((N,T)=>t.jsx(js,{legend:N,layer:n,customLegendTypes:e,onChangeSelection:$=>a({id:m,index:T,selection:$})},`${N.type}-${T}`))}),_&&t.jsx(j.Typography,{variant:"caption",color:"textSecondary",component:"div",p:2,children:t.jsx("div",{dangerouslySetInnerHTML:{__html:_}})})]})]}):null}function bs({intl:e,minZoom:n,maxZoom:i,layerMinZoom:r,layerMaxZoom:s}){const a=e.formatMessage({id:"c4r.widgets.legend.and"}),l=e.formatMessage({id:"c4r.widgets.legend.lowerThan"}),p=e.formatMessage({id:"c4r.widgets.legend.greaterThan"}),c=e.formatMessage({id:"c4r.widgets.legend.zoomNote"}),g=s<i?`${l} ${s}`:"",h=r>n?`${p} ${r}`:"",d=[g,h].filter(Boolean).join(` ${a} `);return d?`${c} ${d}`:""}const Ss={},Ie=()=>{},ks=[];function Is({customLegendTypes:e=Ss,layers:n=ks,collapsed:i=!1,onChangeCollapsed:r=Ie,onChangeVisibility:s=Ie,onChangeOpacity:a=Ie,onChangeLegendRowCollapsed:l=Ie,onChangeSelection:p=Ie,title:c="Layers",maxZoom:g=20,minZoom:h=0,currentZoom:d,isMobile:y,sx:f}){const m=J.useIntl(),v=j.useImperativeIntl(m),x=t.jsxs(Ur,{collapsed:i,children:[t.jsx(j.Typography,{variant:"caption",flexGrow:1,children:c}),t.jsx(o.Tooltip,{title:v.formatMessage({id:"c4r.widgets.legend.close"}),children:t.jsx(o.IconButton,{size:"small",onClick:()=>r(!0),children:t.jsx(ee.Close,{})})})]}),S=t.jsx(o.Tooltip,{title:v.formatMessage({id:"c4r.widgets.legend.open"}),children:t.jsx(o.IconButton,{"aria-label":c,onClick:()=>r(!1),children:t.jsx(ee.LayersOutlined,{})})});return t.jsx(Vr,{sx:f,elevation:3,collapsed:i||!!y,children:y?t.jsxs(t.Fragment,{children:[S,t.jsxs(o.Drawer,{anchor:"bottom",open:!i,onClose:()=>r(!0),children:[x,t.jsx(It,{children:n.map(b=>t.jsx(Tt,{layer:b,onChangeCollapsed:l,onChangeOpacity:a,onChangeVisibility:s,onChangeSelection:p,maxZoom:g,minZoom:h,currentZoom:d,customLegendTypes:e},b.id))})]})]}):t.jsxs(t.Fragment,{children:[i?S:x,t.jsx(It,{width:i?0:void 0,children:t.jsx(o.Collapse,{unmountOnExit:!0,in:!i,timeout:500,children:n.map(b=>t.jsx(Tt,{layer:b,onChangeCollapsed:l,onChangeOpacity:a,onChangeVisibility:s,onChangeSelection:p,maxZoom:g,minZoom:h,currentZoom:d,customLegendTypes:e},b.id))})})]})})}function Mt({color:e=void 0,children:n}){return n?t.jsx(o.Box,{mt:.5,children:t.jsx(j.Typography,{component:"div",variant:"caption",color:e??"inherit",style:{fontWeight:"normal"},children:n})}):t.jsx(o.Box,{mt:-1})}function Ts({title:e="No data available",body:n="There are no results for the combination of filters applied to your data. Try tweaking your filters, or zoom and pan the map to adjust the Map View.",severity:i=void 0,...r}){return i?t.jsx(yn.Alert,{title:e,severity:i,...r,children:t.jsx(Mt,{children:n})}):t.jsxs(o.Box,{...r,children:[e&&t.jsx(j.Typography,{variant:"body2",children:e}),t.jsx(Mt,{color:"textSecondary",children:n})]})}const Ms=o.styled(o.Box,{shouldForwardProp:e=>e!=="margin"})(({theme:e,margin:n})=>({margin:0,position:"relative",maxWidth:"100%",padding:n??e.spacing(2,2.5)})),Cs=o.styled(o.LinearProgress)(({theme:e})=>({position:"absolute",top:0,left:0,width:"100%",height:e.spacing(.25)})),As=o.styled(o.Grid,{shouldForwardProp:e=>e!=="expanded"})(({theme:e,expanded:n=!0})=>({display:"flex",flexDirection:"row",alignItems:"flex-start",justifyContent:"space-between",width:"100%",...n?{minHeight:e.spacing(3)}:{height:e.spacing(3)},padding:0})),Es=o.styled(o.Button,{shouldForwardProp:e=>e!=="expandable"})(({theme:e,expandable:n=!0})=>({flex:1,padding:0,alignItems:"flex-start",justifyContent:"flex-start",height:"auto",minHeight:"auto",marginBottom:e.spacing(1),cursor:n?"pointer":"default","& .MuiButton-startIcon":{marginTop:"3px",marginRight:e.spacing(1)},"&:hover":{background:"none"}})),pn=({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",width:e.spacing(3),height:e.spacing(3),color:e.palette.text.secondary}),Bs=o.styled(ee.ExpandLess)(({theme:e})=>pn({theme:e})),Ps=o.styled(ee.ExpandMore)(({theme:e})=>pn({theme:e})),Ls=o.styled(o.Typography,{shouldForwardProp:e=>e!=="expanded"})(({expanded:e=!0})=>({wordBreak:"break-word",overflow:"hidden",...e&&{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},...!e&&{whiteSpace:"nowrap",textOverflow:"ellipsis"}})),Ds=o.styled(o.Grid)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1),marginRight:e.spacing(-.5),marginLeft:e.spacing(1)})),Ct=o.styled(o.IconButton)(({theme:e})=>({color:e.palette.text.secondary})),Ns=o.styled(o.Menu)(({theme:e})=>({".MuiPaper-root":{marginTop:e.spacing(5),maxHeight:e.spacing(21),minWidth:e.spacing(16)}})),At=[],Os=t.jsx(ee.MoreVert,{});function $s({title:e,actions:n=At,options:i=At,optionsIcon:r=Os,children:s,contentProps:a,disabled:l=!1,expandable:p=!0,expanded:c=!0,onExpandedChange:g,footer:h,headerItems:d,isLoading:y=!1,margin:f}){const m=u.createRef(),[v,x]=u.useState(!0),S=c!==void 0&&g!==void 0,b=p!==!1?S?c:v:!0,k=S?g:x,[I,w]=u.useState(null),M=!!I,C=()=>{p&&k(!b)},D=O=>w(O.currentTarget),B=()=>w(null);function L(O){O&&O(),B()}const P=O=>t.jsx(Ct,{"aria-label":O.label,onClick:O.action,size:"small",children:O.icon},O.id);return l?s?t.jsx(t.Fragment,{children:s}):null:t.jsxs(Ms,{margin:f,component:"section","aria-label":e,children:[y?t.jsx(Cs,{}):null,t.jsxs(As,{container:!0,expanded:c,children:[t.jsx(Es,{expandable:p,startIcon:p&&t.jsx(o.Icon,{children:b?t.jsx(Bs,{}):t.jsx(Ps,{})}),onClick:C,tabIndex:p?0:-1,children:t.jsx(o.Tooltip,{title:e,children:t.jsx(Ls,{expanded:c,align:"left",variant:"subtitle1",children:e})})}),t.jsxs(Ds,{item:!0,children:[d,n.length>0&&n.map(O=>O.tooltip?t.jsx(o.Tooltip,{title:O.tooltip.text,placement:O.tooltip.placement??"top",children:P(O)},O.id):P(O)),i.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(Ct,{"aria-label":"options","aria-controls":"options-menu","aria-haspopup":"true",onClick:D,size:"small",children:r}),t.jsx(Ns,{id:"options-menu",elevation:8,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},anchorEl:I,keepMounted:!0,open:M,onClose:B,children:i.map(O=>t.jsx(o.MenuItem,{selected:O.selected,onClick:()=>L(O.action),children:O.name},O.id))})]})]})]}),t.jsx(o.Collapse,{ref:m,in:b,timeout:"auto",unmountOnExit:!0,children:t.jsxs(o.Box,{...a,children:[t.jsx(o.Box,{pt:1,children:s}),h??t.jsx(o.Box,{children:h})]})})]})}exports.BarWidgetUI=En;exports.CategoryWidgetUI=Gn;exports.ComparativeCategoryWidgetUI=vr;exports.ComparativeFormulaWidgetUI=Cr;exports.ComparativePieWidgetUI=Nr;exports.FeatureSelectionUIDropdown=nn;exports.FeatureSelectionUIGeometryChips=on;exports.FeatureSelectionUIToggleButton=tn;exports.FeatureSelectionWidgetUI=Yr;exports.FormulaWidgetUI=Vn;exports.GroupDateTypes=le;exports.HistogramWidgetUI=to;exports.LEGEND_TYPES=ce;exports.LegendCategories=an;exports.LegendIcon=dn;exports.LegendProportion=ln;exports.LegendRamp=Qe;exports.LegendWidgetUI=Is;exports.NoDataAlert=Ts;exports.PieWidgetUI=Eo;exports.RangeWidgetUI=Wo;exports.ScatterPlotWidgetUI=Ko;exports.TIME_SERIES_CHART_TYPES=Ge;exports.TableWidgetUI=si;exports.TimeSeriesProvider=zt;exports.TimeSeriesWidgetUI=Zi;exports.WrapperWidgetUI=$s;exports.useTimeSeriesContext=He;exports.useTimeSeriesInteractivity=Yt;