@fldr/ui 0.0.0-stage → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (555) hide show
  1. package/CHANGELOG.md +2366 -0
  2. package/LICENSE +21 -0
  3. package/README.md +488 -2
  4. package/ai/USAGE.md +216 -0
  5. package/ai/component-registry.json +8694 -0
  6. package/ai/component-registry.md +11933 -0
  7. package/ai/schemas.ts +1239 -0
  8. package/bin/kumo.js +36 -0
  9. package/dist/.build-complete +1 -0
  10. package/dist/ai/schemas.d.ts +3229 -0
  11. package/dist/ai/schemas.js +5963 -0
  12. package/dist/blocks-source/delete-resource/delete-resource.test.tsx +21 -0
  13. package/dist/blocks-source/delete-resource/delete-resource.tsx +219 -0
  14. package/dist/blocks-source/page-header/page-header.tsx +99 -0
  15. package/dist/blocks-source/resource-list/resource-list.test.tsx +28 -0
  16. package/dist/blocks-source/resource-list/resource-list.tsx +66 -0
  17. package/dist/button-DzavLWXm.d.ts +227 -0
  18. package/dist/catalog.d.ts +380 -0
  19. package/dist/catalog.js +387 -0
  20. package/dist/chunks/AccordionPanelDataAttributes-mmrmkky28u1010l5.js +457 -0
  21. package/dist/chunks/AlertDialogTrigger-l1r1gbxcky1xq889.js +24 -0
  22. package/dist/chunks/AlertDialogTriggerDataAttributes-go49qon601catpgn.js +56 -0
  23. package/dist/chunks/AutocompleteItem-36ysm5nwbsd0snr6.js +70 -0
  24. package/dist/chunks/AutocompleteItemDataAttributes-n5rigpf0s9ylnwi3.js +232 -0
  25. package/dist/chunks/AutocompleteSeparator-bnqeqh7i983d92gx.js +12 -0
  26. package/dist/chunks/AvatarImageDataAttributes-jw70u384c83lhqfp.js +247 -0
  27. package/dist/chunks/ButtonDataAttributes-nceand1fi7lvnmkb.js +35 -0
  28. package/dist/chunks/CSPContext-iv67i0qqhihg8mur.js +11 -0
  29. package/dist/chunks/CSPProvider-finau3a8hnc9o2td.js +24 -0
  30. package/dist/chunks/CheckboxGroup-581mfftu99wvjb3a.js +190 -0
  31. package/dist/chunks/CheckboxGroupContext-jf1bt3znvqlhrql6.js +10 -0
  32. package/dist/chunks/CheckboxGroupDataAttributes-nskqcxts64symbvf.js +10 -0
  33. package/dist/chunks/CheckboxIndicator-i13dmhacfgqo328c.js +414 -0
  34. package/dist/chunks/CheckboxIndicatorDataAttributes-3p29ju7nkczz1l2y.js +85 -0
  35. package/dist/chunks/CollapsiblePanel-md5suzmtnsyz1kab.js +178 -0
  36. package/dist/chunks/CollapsibleRootDataAttributes-bynmgxmt4jikaoha.js +36 -0
  37. package/dist/chunks/ComboboxClear-ioejwvtnmqanph88.js +294 -0
  38. package/dist/chunks/ComboboxClearDataAttributes-lo0enstdmrqpywsy.js +402 -0
  39. package/dist/chunks/ComboboxEmpty-gkt1y5b81a4983v7.js +1950 -0
  40. package/dist/chunks/ComboboxItemIndicatorDataAttributes-iku7l9ig0ve09an4.js +259 -0
  41. package/dist/chunks/ComboboxPopup-n8cbgys9st446j1i.js +205 -0
  42. package/dist/chunks/CompositeItem-kepwg8jtvgap06o6.js +20 -0
  43. package/dist/chunks/CompositeList-gwuaf6d14s4da0j0.js +182 -0
  44. package/dist/chunks/CompositeListContext-bejvmlu39hsfjzgu.js +15 -0
  45. package/dist/chunks/CompositeRoot-dnlkb27uw4g5aocf.js +223 -0
  46. package/dist/chunks/CompositeRootContext-obm54j7y6s86qwhq.js +12 -0
  47. package/dist/chunks/ContextMenuTriggerDataAttributes-xwozccynxv6pk5s0.js +237 -0
  48. package/dist/chunks/DialogBackdropDataAttributes-jwqxd6jla03xh8ke.js +28 -0
  49. package/dist/chunks/DialogCloseDataAttributes-12m7gwh3i6fd7d05.js +76 -0
  50. package/dist/chunks/DialogPopup-n6w7b389e7bs0472.js +133 -0
  51. package/dist/chunks/DialogRoot-hkkqj7vcjpkx8qk8.js +16 -0
  52. package/dist/chunks/DialogTrigger-kpugfkbfswqrus4u.js +142 -0
  53. package/dist/chunks/DialogTriggerDataAttributes-bp9bu13cvwuddh5b.js +18 -0
  54. package/dist/chunks/DialogViewportDataAttributes-mma9emv1edsc1vuy.js +78 -0
  55. package/dist/chunks/DirectionContext-kpby968j030psajn.js +10 -0
  56. package/dist/chunks/DirectionProvider-cg0pwzgdyg6r73r6.js +21 -0
  57. package/dist/chunks/DrawerViewport-mzqpwvqtylnad8ib.js +1532 -0
  58. package/dist/chunks/DrawerViewportDataAttributes-dd9593zm9fl9vcsm.js +1072 -0
  59. package/dist/chunks/FieldControl-hjj2tcqruozadgdi.js +122 -0
  60. package/dist/chunks/FieldDescription-orix2gepowrp5ni4.js +122 -0
  61. package/dist/chunks/FieldItemContext-ohsf45im6xhpay40.js +10 -0
  62. package/dist/chunks/FieldItemDataAttributes-m52srx69pispz49i.js +283 -0
  63. package/dist/chunks/FieldLabel-fjc7tdis7rcbq8o4.js +353 -0
  64. package/dist/chunks/FieldsetLegend-gl9z9eezr0xg9zr7.js +61 -0
  65. package/dist/chunks/FieldsetLegendDataAttributes-fn20251jxjqkpkxm.js +17 -0
  66. package/dist/chunks/FieldsetRootContext-fphwizvcm55ydg94.js +12 -0
  67. package/dist/chunks/FloatingPortalLite-j7dsy7gokbxdoe1i.js +25 -0
  68. package/dist/chunks/FloatingRootStore-men6ufp3a2b296fh.js +840 -0
  69. package/dist/chunks/FloatingTree-kiyzavvaum442o1s.js +115 -0
  70. package/dist/chunks/Form-oz425k7r4abea8o4.js +113 -0
  71. package/dist/chunks/FormContext-jv19engyccpf6xcl.js +18 -0
  72. package/dist/chunks/Input-ozudotydd679ly63.js +20 -0
  73. package/dist/chunks/InputDataAttributes-oy8t6q5y5t8ik02j.js +42 -0
  74. package/dist/chunks/ItemIndicator-cvf8cw5fv5l3cd8j.js +37 -0
  75. package/dist/chunks/LabelableContext-dz4wz3lu3lgqusu7.js +135 -0
  76. package/dist/chunks/ListboxSeparator-skazx18vzzj7i9zp.js +21 -0
  77. package/dist/chunks/MenuClearDataAttributes-fo0pekd36n56mdxu.js +1645 -0
  78. package/dist/chunks/MenuSubmenuTrigger-hm5xbgik6aq95x35.js +1976 -0
  79. package/dist/chunks/MenuSubmenuTriggerDataAttributes-gdfxdjymgmnaxdds.js +372 -0
  80. package/dist/chunks/MenuTrigger-dlfvicsaggss0o9m.js +265 -0
  81. package/dist/chunks/Menubar-ja5int05ihjj0ra4.js +116 -0
  82. package/dist/chunks/MenubarContext-ooz0h08i55c8oip5.js +12 -0
  83. package/dist/chunks/MeterLabel-cykbkvqys5263z05.js +148 -0
  84. package/dist/chunks/NavigationMenuIconDataAttributes-l82pkpm61d0meqxf.js +1654 -0
  85. package/dist/chunks/NullStore-my62xo2vfcfkerri.js +110 -0
  86. package/dist/chunks/NumberFieldScrubAreaCursorDataAttributes-k2lsbk35svshnwf5.js +1493 -0
  87. package/dist/chunks/OTPFieldInputDataAttributes-gvgtu2gg85kgjzwr.js +683 -0
  88. package/dist/chunks/PopoverViewport-peh28i8q4hqfjy97.js +713 -0
  89. package/dist/chunks/PopoverViewportDataAttributes-gplhq9d7ffp9q8u3.js +329 -0
  90. package/dist/chunks/PrehydrationScript-hs2je3mndbxuts7w.js +78 -0
  91. package/dist/chunks/PreviewCardViewportDataAttributes-bgfwmyshey7fx6nr.js +914 -0
  92. package/dist/chunks/ProgressLabelDataAttributes-j8mutcz11ei0ohvj.js +287 -0
  93. package/dist/chunks/RadioGroup-kioqngmmuo7a1lfa.js +163 -0
  94. package/dist/chunks/RadioGroupContext-dr6uihsj7oky0eol.js +10 -0
  95. package/dist/chunks/RadioGroupDataAttributes-dpdr6xe4ve204qwb.js +10 -0
  96. package/dist/chunks/RadioIndicator-bhxqih8wzv7hyrec.js +299 -0
  97. package/dist/chunks/RadioIndicatorDataAttributes-n5yupp5psifu0d4f.js +80 -0
  98. package/dist/chunks/ScrollAreaThumb-hxig41yn4lrurd3o.js +928 -0
  99. package/dist/chunks/ScrollAreaThumbDataAttributes-gup5wfxvqye6jj27.js +137 -0
  100. package/dist/chunks/SelectScrollUpArrowDataAttributes-fce5i1afjkb0necr.js +473 -0
  101. package/dist/chunks/SelectSeparator-nnak70azojox8b2b.js +1632 -0
  102. package/dist/chunks/Separator-fhwve0tfny3tht3a.js +24 -0
  103. package/dist/chunks/SeparatorDataAttributes-ch6e63bas7zflw00.js +11 -0
  104. package/dist/chunks/SliderIndicator-h1o3qbrvr8x0t4t2.js +1171 -0
  105. package/dist/chunks/SliderIndicatorDataAttributes-ff2f1cjealif5nvo.js +240 -0
  106. package/dist/chunks/SwitchRoot-m4t2tq5zn5wibyxk.js +244 -0
  107. package/dist/chunks/SwitchThumbDataAttributes-f95ld864on9y6ptk.js +90 -0
  108. package/dist/chunks/TabsList-n5n93rxr4sy704u8.js +664 -0
  109. package/dist/chunks/TabsListDataAttributes-e03a7kbubuf02z1l.js +183 -0
  110. package/dist/chunks/ToastArrowDataAttributes-jbnvz3kp6a35slgj.js +136 -0
  111. package/dist/chunks/ToggleDataAttributes-jl9ojyvwgrvefke6.js +103 -0
  112. package/dist/chunks/ToggleGroupContext-hg8zbkgqpscqhz83.js +10 -0
  113. package/dist/chunks/ToggleGroupDataAttributes-n1dwona1alvabstl.js +102 -0
  114. package/dist/chunks/ToolbarGroupContext-eawva8xkxb4osbxb.js +10 -0
  115. package/dist/chunks/ToolbarInput-kyxl1be0p3cyuayp.js +174 -0
  116. package/dist/chunks/ToolbarInputDataAttributes-n4a18a4km735du04.js +150 -0
  117. package/dist/chunks/ToolbarRootContext-difqbj720teyt8lu.js +12 -0
  118. package/dist/chunks/TooltipPopup-furysmeyb68uycbz.js +839 -0
  119. package/dist/chunks/TooltipProvider-hyans0ens4axh1y8.js +61 -0
  120. package/dist/chunks/TooltipViewportDataAttributes-gkwbezdq40ssuevg.js +312 -0
  121. package/dist/chunks/adaptiveOriginMiddleware-m9tqzw58wya9sdds.js +51 -0
  122. package/dist/chunks/addEventListener-ku3x23446prmd1kz.js +13 -0
  123. package/dist/chunks/areArraysEqual-nnpg93s9g7aqcaoh.js +15 -0
  124. package/dist/chunks/autocomplete-gdd9aruremdgdvx7.js +152 -0
  125. package/dist/chunks/badge-gca8xfu79ne55d5k.js +165 -0
  126. package/dist/chunks/banner-mo1xl9ww734kgsqh.js +269 -0
  127. package/dist/chunks/breadcrumbs-z1jo40oxlw8e4eh4.js +159 -0
  128. package/dist/chunks/button-group-biv43ksvaipc3p5n.js +59 -0
  129. package/dist/chunks/button-hzvowfkbathmx8yg.js +274 -0
  130. package/dist/chunks/chart-dgh98nbzo2sux2bs.js +3985 -0
  131. package/dist/chunks/checkbox-eifiwbw34xwsikvf.js +211 -0
  132. package/dist/chunks/clamp-rcpupxvhqrn8uuyf.js +7 -0
  133. package/dist/chunks/clipboard-text-oukrnke1s3kebk3y.js +209 -0
  134. package/dist/chunks/cloudflare-logo-d8mid9xr190h78cu.js +186 -0
  135. package/dist/chunks/code-hp2x28uiufmk3elz.js +94 -0
  136. package/dist/chunks/collapsible-ic6813hc4yv5s5hv.js +185 -0
  137. package/dist/chunks/combobox-mzvobpvalz2gnpli.js +321 -0
  138. package/dist/chunks/command-palette-d45ueqbuxygu87ir.js +507 -0
  139. package/dist/chunks/composite-c11t1ok72s3cggjc.js +90 -0
  140. package/dist/chunks/constants-l10cgj6pyqg27jod.js +5 -0
  141. package/dist/chunks/createBaseUIEventDetails-nvee6bghv2reeqdb.js +50 -0
  142. package/dist/chunks/createItems-n07tfwx89cdoar18.js +323 -0
  143. package/dist/chunks/createToastManager-cxjmn4jx3ejh85fs.js +1225 -0
  144. package/dist/chunks/date-picker-ija2bz17ai6ypnao.js +6865 -0
  145. package/dist/chunks/date-range-picker-oivlshld01jbel29.js +336 -0
  146. package/dist/chunks/dialog-g7wavhkdv2gplwq9.js +173 -0
  147. package/dist/chunks/dropdown-m5a8nwer5hpvnkfk.js +384 -0
  148. package/dist/chunks/empty-e0onzpyokyl6h9bp.js +96 -0
  149. package/dist/chunks/engine-hzmefiqm63hu0c7i.js +10 -0
  150. package/dist/chunks/error-lbnic2b20qr3mukp.js +6 -0
  151. package/dist/chunks/field-fowmq5smvp17pnqe.js +75 -0
  152. package/dist/chunks/flow-fak0fyldoaozd32s.js +10290 -0
  153. package/dist/chunks/formatNumber-b4kjdsebslm2b3t0.js +21 -0
  154. package/dist/chunks/getCssDimensions-gckwdrp86f73cv51.js +21 -0
  155. package/dist/chunks/getElementTransform-cz3jyftv0x5io95f.js +38 -0
  156. package/dist/chunks/getFiniteAnimations-jwd833ybtz81j5f0.js +13 -0
  157. package/dist/chunks/getHighlightReason-fhc53kq6qakcct9s.js +15 -0
  158. package/dist/chunks/getPseudoElementBounds-csuw8kwsoeyxd5tv.js +37 -0
  159. package/dist/chunks/grid-nwiczrab3r4w0zr2.js +118 -0
  160. package/dist/chunks/highlighter-mouttug0tu8xg1i8.js +1364 -0
  161. package/dist/chunks/index.parts-db9pzsm9rrs9tp0t.js +200 -0
  162. package/dist/chunks/index.parts-ggacwr0yakuemead.js +24 -0
  163. package/dist/chunks/index.parts-pcg3pmf3yyro841t.js +13 -0
  164. package/dist/chunks/inertValue-n09gkjvwwa1kddov.js +9 -0
  165. package/dist/chunks/inline-copy-text-izxpvnrtebcqlquf.js +104 -0
  166. package/dist/chunks/input-group-h9fepskc84e1h11n.js +457 -0
  167. package/dist/chunks/input-kfi46426y22ocoo4.js +85 -0
  168. package/dist/chunks/input-m2tfec2viezoz9hh.js +146 -0
  169. package/dist/chunks/isElementDisabled-dyqutxpzdfppbohx.js +7 -0
  170. package/dist/chunks/itemEquality-ki3x4tzdhjlqjey6.js +56 -0
  171. package/dist/chunks/label-f18fnpbv85jddo4q.js +76 -0
  172. package/dist/chunks/layer-card-lsmeuqic9i1isv2b.js +74 -0
  173. package/dist/chunks/layer-dialog-ejtz9s7bbfhjk1md.js +414 -0
  174. package/dist/chunks/link-h84bkh8eem39p529.js +112 -0
  175. package/dist/chunks/link-provider-kbwllpbo24fvgioj.js +60 -0
  176. package/dist/chunks/loader-kv5nk8j8tsuesxqo.js +87 -0
  177. package/dist/chunks/locale-provider-j4ii538ntyok36r6.js +50 -0
  178. package/dist/chunks/menubar-gzlyhmmc4i24prn1.js +106 -0
  179. package/dist/chunks/mergeCleanups-nw73c6jfwl5tyhw4.js +15 -0
  180. package/dist/chunks/meter-poh8jpe0qtq6mvee.js +35 -0
  181. package/dist/chunks/pagination-lmogkvvtu19mnr7f.js +296 -0
  182. package/dist/chunks/popover-nqrt3ykqv6sic8pz.js +206 -0
  183. package/dist/chunks/popupHandle-dk3ixgc8flr7v971.js +177 -0
  184. package/dist/chunks/popupStoreUtils-czfnxn051xakask5.js +868 -0
  185. package/dist/chunks/portal-provider-eveknxf26oudn7pp.js +63 -0
  186. package/dist/chunks/radio-nf717i5ypsga9zdh.js +204 -0
  187. package/dist/chunks/reason-parts-hssx64rmlxyn6gw5.js +40 -0
  188. package/dist/chunks/resolve-variant-l6x5ksfrjtu4m66l.js +35 -0
  189. package/dist/chunks/resolveAriaLabelledBy-knaucrjrjwnk7tvs.js +10 -0
  190. package/dist/chunks/resolveValueLabel-ntacnb58mhka5gg0.js +70 -0
  191. package/dist/chunks/rolldown-runtime-hi7ti5xiuxsegr96.js +18 -0
  192. package/dist/chunks/safePolygon-ep4133qogeu5vjf3.js +661 -0
  193. package/dist/chunks/safeReact-ek77ilng4ekk7mgz.js +18 -0
  194. package/dist/chunks/scrollable-k784b35i80aolmvg.js +29 -0
  195. package/dist/chunks/select-lnekz415wm4v6d6m.js +279 -0
  196. package/dist/chunks/sensitive-input-dvwlnntm7rdudwp0.js +252 -0
  197. package/dist/chunks/serializeValue-d1otz2i7h5tygrwf.js +13 -0
  198. package/dist/chunks/sidebar-mhlgvpawixxoey2k.js +1466 -0
  199. package/dist/chunks/skeleton-line-kmhnp0lx3rxhioxa.js +74 -0
  200. package/dist/chunks/slider-e395gihi5cjd62ss.js +87 -0
  201. package/dist/chunks/stringifyLocale-gbxouqj7ol627jxh.js +9 -0
  202. package/dist/chunks/styles-eb8bvypmayf578jf.js +35 -0
  203. package/dist/chunks/surface-jr8x5hy0gucjk5ig.js +30 -0
  204. package/dist/chunks/switch-nc8thi7ogd51m3gi.js +202 -0
  205. package/dist/chunks/table-ngl1b5yc8mcur662.js +238 -0
  206. package/dist/chunks/table-of-contents-gkjv9ck8etbz64ej.js +234 -0
  207. package/dist/chunks/tabs-o59bv7348nh2gppm.js +280 -0
  208. package/dist/chunks/tag-input-lbx9yzt33d4wu07o.js +156 -0
  209. package/dist/chunks/text-nqum95flcp07ac9s.js +126 -0
  210. package/dist/chunks/toast-ljpenshot856xqq4.js +341 -0
  211. package/dist/chunks/toolbar-kh6pc12ii7b6dv1x.js +141 -0
  212. package/dist/chunks/tooltip-bcymn9bfyz29fvji.js +92 -0
  213. package/dist/chunks/unwrap-lazy-element-hzbdkmujhd7iksau.js +45 -0
  214. package/dist/chunks/use-copy-feedback-gl55ghst0csvpv4j.js +55 -0
  215. package/dist/chunks/useAnchoredPopupScrollLock-msm8tzkewysnunut.js +31 -0
  216. package/dist/chunks/useAnimationFrame-k9lqdj9quln3sd85.js +87 -0
  217. package/dist/chunks/useAriaLabelledBy-j3j9jqlr9ukyk08s.js +36 -0
  218. package/dist/chunks/useBaseUiId-nk4k7nj9h1cy76ny.js +13 -0
  219. package/dist/chunks/useButton-lklvdzuhvj22bx07.js +186 -0
  220. package/dist/chunks/useClick-pcbkcc7r620v1smu.js +87 -0
  221. package/dist/chunks/useCollapsiblePanel-lrfsgx21ds36cwlp.js +415 -0
  222. package/dist/chunks/useCompositeItem-2juex3zh9gyrs8e9.js +31 -0
  223. package/dist/chunks/useCompositeListItem-ekwo2j2rjkggg7xj.js +54 -0
  224. package/dist/chunks/useControlled-i3srnkxy598s0au9.js +52 -0
  225. package/dist/chunks/useFieldValidation-oe16jiigp971yrzr.js +224 -0
  226. package/dist/chunks/useFloatingRootContext-k676b6m7f80bdapd.js +51 -0
  227. package/dist/chunks/useFocus-mn7a9t9v6fnlb4mf.js +124 -0
  228. package/dist/chunks/useId-82z8yqlmc1hy1c5t.js +50 -0
  229. package/dist/chunks/useInitialLiveRegionTextMutation-nl2hus7zx1h7ggno.js +86 -0
  230. package/dist/chunks/useLabel-me6zzfvkypo458pi.js +58 -0
  231. package/dist/chunks/useLabelableId-bjeh6q3pgrqjb7er.js +56 -0
  232. package/dist/chunks/useListNavigation-hpddbd0cc9pvt461.js +441 -0
  233. package/dist/chunks/useOnMount-gxggz1m0n869s6r0.js +12 -0
  234. package/dist/chunks/useOpenChangeComplete-edtabjwqmechsyv6.js +129 -0
  235. package/dist/chunks/usePopupHandleStore-gawjmfjf1xdgiph3.js +27 -0
  236. package/dist/chunks/usePopupViewport-l6w01iohvzloghy8.js +367 -0
  237. package/dist/chunks/usePositioner-mzvgnazldqvy44z2.js +580 -0
  238. package/dist/chunks/usePressAndHold-k9ynk78pgf677kpx.js +179 -0
  239. package/dist/chunks/usePreviousValue-o6swt5tb7xhpdu4e.js +21 -0
  240. package/dist/chunks/useRegisterFieldControl-m1stc9l9y4cndf0k.js +40 -0
  241. package/dist/chunks/useRegisteredLabelId-b7u9ygya03448zzn.js +16 -0
  242. package/dist/chunks/useRender-h9ktka9xt4obdv6y.js +13 -0
  243. package/dist/chunks/useRenderDialogRoot-bsqrqpc1ddau7xg4.js +312 -0
  244. package/dist/chunks/useRenderElement-nkklxbq1rp7h2kw0.js +436 -0
  245. package/dist/chunks/useScrollLock-le7ajwlt7oh6fzxi.js +877 -0
  246. package/dist/chunks/useSetFieldFocused-fbvj7gcv67dqfkp0.js +35 -0
  247. package/dist/chunks/useStableCallback-le5qgj6p9l04729n.js +38 -0
  248. package/dist/chunks/useSwipeDismiss-e8tfxzlp05p86mgb.js +697 -0
  249. package/dist/chunks/useTimeout-f0ayn2l2l9aop4l8.js +43 -0
  250. package/dist/chunks/useTransitionStatus-disysoblzgk34w14.js +74 -0
  251. package/dist/chunks/useTriggerFocusGuards-dyd3hb1m8en8ct50.js +40 -0
  252. package/dist/chunks/useTriggerSwitchTransition-hk5j36hd5dq2ok6w.js +62 -0
  253. package/dist/chunks/useTypeahead-kfdsw1ksl5bgvvzl.js +111 -0
  254. package/dist/chunks/useValueAsRef-dv0tmfr1xlpzdlru.js +27 -0
  255. package/dist/chunks/useValueChanged-fjssa2v6d4w8y332.js +15 -0
  256. package/dist/chunks/utils-o44zfmzz9z7uyj1v.js +18 -0
  257. package/dist/chunks/valueToPercent-djk2mqnihth2uvf6.js +7 -0
  258. package/dist/chunks/vendor-floating-ui-fqblx3wa0r71mjoo.js +1458 -0
  259. package/dist/chunks/vendor-styling-gs32v7xt5znc8kg0.js +1167 -0
  260. package/dist/chunks/vendor-utils-io8z5lsfxq8m2dcc.js +660 -0
  261. package/dist/chunks/visuallyHidden-kzzs9hbe93is3rci.js +25 -0
  262. package/dist/code/server.d.ts +11 -0
  263. package/dist/code/server.js +18 -0
  264. package/dist/code.d.ts +65 -0
  265. package/dist/code.js +232 -0
  266. package/dist/command-line/cli.js +1705 -0
  267. package/dist/command-line/commands/add.js +282 -0
  268. package/dist/command-line/commands/ai.js +22 -0
  269. package/dist/command-line/commands/blocks.js +61 -0
  270. package/dist/command-line/commands/doc.js +167 -0
  271. package/dist/command-line/commands/init.js +95 -0
  272. package/dist/command-line/commands/ls.js +53 -0
  273. package/dist/command-line/commands/theme.js +850 -0
  274. package/dist/components/autocomplete.d.ts +2 -0
  275. package/dist/components/autocomplete.js +3 -0
  276. package/dist/components/badge.d.ts +2 -0
  277. package/dist/components/badge.js +3 -0
  278. package/dist/components/banner.d.ts +2 -0
  279. package/dist/components/banner.js +3 -0
  280. package/dist/components/breadcrumbs.d.ts +2 -0
  281. package/dist/components/breadcrumbs.js +3 -0
  282. package/dist/components/button-group.d.ts +2 -0
  283. package/dist/components/button-group.js +3 -0
  284. package/dist/components/button.d.ts +3 -0
  285. package/dist/components/button.js +3 -0
  286. package/dist/components/chart.d.ts +2 -0
  287. package/dist/components/chart.js +3 -0
  288. package/dist/components/checkbox.d.ts +2 -0
  289. package/dist/components/checkbox.js +3 -0
  290. package/dist/components/clipboard-text.d.ts +2 -0
  291. package/dist/components/clipboard-text.js +3 -0
  292. package/dist/components/cloudflare-logo.d.ts +2 -0
  293. package/dist/components/cloudflare-logo.js +3 -0
  294. package/dist/components/code.d.ts +2 -0
  295. package/dist/components/code.js +3 -0
  296. package/dist/components/collapsible.d.ts +2 -0
  297. package/dist/components/collapsible.js +3 -0
  298. package/dist/components/combobox.d.ts +2 -0
  299. package/dist/components/combobox.js +3 -0
  300. package/dist/components/command-palette.d.ts +2 -0
  301. package/dist/components/command-palette.js +3 -0
  302. package/dist/components/date-picker.d.ts +2 -0
  303. package/dist/components/date-picker.js +3 -0
  304. package/dist/components/date-range-picker.d.ts +2 -0
  305. package/dist/components/date-range-picker.js +3 -0
  306. package/dist/components/dialog.d.ts +2 -0
  307. package/dist/components/dialog.js +3 -0
  308. package/dist/components/dropdown.d.ts +2 -0
  309. package/dist/components/dropdown.js +3 -0
  310. package/dist/components/empty.d.ts +2 -0
  311. package/dist/components/empty.js +3 -0
  312. package/dist/components/field.d.ts +2 -0
  313. package/dist/components/field.js +3 -0
  314. package/dist/components/flow.d.ts +2 -0
  315. package/dist/components/flow.js +3 -0
  316. package/dist/components/grid.d.ts +2 -0
  317. package/dist/components/grid.js +3 -0
  318. package/dist/components/inline-copy-text.d.ts +2 -0
  319. package/dist/components/inline-copy-text.js +3 -0
  320. package/dist/components/input-group.d.ts +2 -0
  321. package/dist/components/input-group.js +3 -0
  322. package/dist/components/input.d.ts +4 -0
  323. package/dist/components/input.js +5 -0
  324. package/dist/components/label.d.ts +2 -0
  325. package/dist/components/label.js +3 -0
  326. package/dist/components/layer-card.d.ts +2 -0
  327. package/dist/components/layer-card.js +3 -0
  328. package/dist/components/layer-dialog.d.ts +2 -0
  329. package/dist/components/layer-dialog.js +3 -0
  330. package/dist/components/link.d.ts +67 -0
  331. package/dist/components/link.js +3 -0
  332. package/dist/components/loader.d.ts +2 -0
  333. package/dist/components/loader.js +4 -0
  334. package/dist/components/menubar.d.ts +2 -0
  335. package/dist/components/menubar.js +3 -0
  336. package/dist/components/meter.d.ts +2 -0
  337. package/dist/components/meter.js +3 -0
  338. package/dist/components/pagination.d.ts +2 -0
  339. package/dist/components/pagination.js +3 -0
  340. package/dist/components/popover.d.ts +2 -0
  341. package/dist/components/popover.js +3 -0
  342. package/dist/components/radio.d.ts +2 -0
  343. package/dist/components/radio.js +3 -0
  344. package/dist/components/select.d.ts +2 -0
  345. package/dist/components/select.js +3 -0
  346. package/dist/components/sensitive-input.d.ts +2 -0
  347. package/dist/components/sensitive-input.js +3 -0
  348. package/dist/components/sidebar.d.ts +2 -0
  349. package/dist/components/sidebar.js +3 -0
  350. package/dist/components/slider.d.ts +2 -0
  351. package/dist/components/slider.js +3 -0
  352. package/dist/components/surface.d.ts +2 -0
  353. package/dist/components/surface.js +3 -0
  354. package/dist/components/switch.d.ts +2 -0
  355. package/dist/components/switch.js +3 -0
  356. package/dist/components/table-of-contents.d.ts +2 -0
  357. package/dist/components/table-of-contents.js +3 -0
  358. package/dist/components/table.d.ts +2 -0
  359. package/dist/components/table.js +3 -0
  360. package/dist/components/tabs.d.ts +2 -0
  361. package/dist/components/tabs.js +3 -0
  362. package/dist/components/tag-input.d.ts +2 -0
  363. package/dist/components/tag-input.js +3 -0
  364. package/dist/components/text.d.ts +2 -0
  365. package/dist/components/text.js +3 -0
  366. package/dist/components/toast.d.ts +2 -0
  367. package/dist/components/toast.js +4 -0
  368. package/dist/components/toolbar.d.ts +2 -0
  369. package/dist/components/toolbar.js +3 -0
  370. package/dist/components/tooltip.d.ts +2 -0
  371. package/dist/components/tooltip.js +3 -0
  372. package/dist/config-BKj6nyHa.d.ts +620 -0
  373. package/dist/field-DIjlHM8W.d.ts +91 -0
  374. package/dist/highlighter-BT3TakhJ.d.ts +13 -0
  375. package/dist/index-2jvVmJ8P.d.ts +46 -0
  376. package/dist/index-5PpauI_2.d.ts +85 -0
  377. package/dist/index-AMEc1MEg.d.ts +180 -0
  378. package/dist/index-AUC5xRcO.d.ts +236 -0
  379. package/dist/index-B7epkoHc.d.ts +72 -0
  380. package/dist/index-B9-RdY6D.d.ts +75 -0
  381. package/dist/index-BD-gTiEv.d.ts +71 -0
  382. package/dist/index-BK1tZgmP.d.ts +426 -0
  383. package/dist/index-BVgXnR1V.d.ts +137 -0
  384. package/dist/index-BW1HVU7T.d.ts +119 -0
  385. package/dist/index-BWe6haHU.d.ts +64 -0
  386. package/dist/index-BkTAB4wj.d.ts +673 -0
  387. package/dist/index-Bwhwpw_j.d.ts +189 -0
  388. package/dist/index-BzE0aNpx.d.ts +143 -0
  389. package/dist/index-C7RoG_CH.d.ts +57 -0
  390. package/dist/index-CE09bLNb.d.ts +72 -0
  391. package/dist/index-CJRe-8P-.d.ts +174 -0
  392. package/dist/index-CNL6VDYZ.d.ts +138 -0
  393. package/dist/index-CReGk3Dc.d.ts +91 -0
  394. package/dist/index-CU_lnxg7.d.ts +287 -0
  395. package/dist/index-CYoiniZ4.d.ts +135 -0
  396. package/dist/index-ClS-eFxE.d.ts +104 -0
  397. package/dist/index-CzIWigmH.d.ts +62 -0
  398. package/dist/index-CzTgKPh-.d.ts +105 -0
  399. package/dist/index-D2Gvly0i.d.ts +96 -0
  400. package/dist/index-DIV3riUd.d.ts +148 -0
  401. package/dist/index-DL1-uSuH.d.ts +1 -0
  402. package/dist/index-DYYiDxZs.d.ts +243 -0
  403. package/dist/index-DjSGDESy.d.ts +222 -0
  404. package/dist/index-Dmbgjww7.d.ts +157 -0
  405. package/dist/index-DwNMa4LN.d.ts +166 -0
  406. package/dist/index-Dx7hOWUc.d.ts +93 -0
  407. package/dist/index-DxOyYZaJ.d.ts +251 -0
  408. package/dist/index-NnHba-T1.d.ts +136 -0
  409. package/dist/index-RP_rt8vB.d.ts +140 -0
  410. package/dist/index-T1sSoiWG.d.ts +184 -0
  411. package/dist/index-aahL-0Zw.d.ts +60 -0
  412. package/dist/index-bBPKMepR.d.ts +73 -0
  413. package/dist/index-g-eFm1Bq.d.ts +877 -0
  414. package/dist/index-gYC6cQVO.d.ts +105 -0
  415. package/dist/index-lOWfpkxK.d.ts +118 -0
  416. package/dist/index-pjdgauIH.d.ts +170 -0
  417. package/dist/index-yK3Hayg_.d.ts +40 -0
  418. package/dist/index.d.ts +108 -0
  419. package/dist/index.js +207 -0
  420. package/dist/input-BeWEb-jD.d.ts +122 -0
  421. package/dist/input-group-8gEtPiKw.d.ts +100 -0
  422. package/dist/layer-card-BNIn9pqy.d.ts +56 -0
  423. package/dist/link-provider-tz-NJp9x.d.ts +67 -0
  424. package/dist/locale-provider-CHMCQ0-J.d.ts +40 -0
  425. package/dist/panda.d.ts +25 -0
  426. package/dist/panda.js +32 -0
  427. package/dist/portal-provider-BAqPpq_a.d.ts +55 -0
  428. package/dist/primitives/accordion.d.ts +1 -0
  429. package/dist/primitives/accordion.js +3 -0
  430. package/dist/primitives/alert-dialog.d.ts +1 -0
  431. package/dist/primitives/alert-dialog.js +8 -0
  432. package/dist/primitives/autocomplete.d.ts +1 -0
  433. package/dist/primitives/autocomplete.js +6 -0
  434. package/dist/primitives/avatar.d.ts +1 -0
  435. package/dist/primitives/avatar.js +3 -0
  436. package/dist/primitives/button.d.ts +1 -0
  437. package/dist/primitives/button.js +3 -0
  438. package/dist/primitives/checkbox-group.d.ts +1 -0
  439. package/dist/primitives/checkbox-group.js +4 -0
  440. package/dist/primitives/checkbox.d.ts +1 -0
  441. package/dist/primitives/checkbox.js +4 -0
  442. package/dist/primitives/collapsible.d.ts +1 -0
  443. package/dist/primitives/collapsible.js +5 -0
  444. package/dist/primitives/combobox.d.ts +1 -0
  445. package/dist/primitives/combobox.js +6 -0
  446. package/dist/primitives/context-menu.d.ts +1 -0
  447. package/dist/primitives/context-menu.js +6 -0
  448. package/dist/primitives/csp-provider.d.ts +1 -0
  449. package/dist/primitives/csp-provider.js +3 -0
  450. package/dist/primitives/dialog.d.ts +1 -0
  451. package/dist/primitives/dialog.js +9 -0
  452. package/dist/primitives/direction-provider.d.ts +1 -0
  453. package/dist/primitives/direction-provider.js +4 -0
  454. package/dist/primitives/drawer.d.ts +1 -0
  455. package/dist/primitives/drawer.js +6 -0
  456. package/dist/primitives/field.d.ts +1 -0
  457. package/dist/primitives/field.js +4 -0
  458. package/dist/primitives/fieldset.d.ts +1 -0
  459. package/dist/primitives/fieldset.js +3 -0
  460. package/dist/primitives/form.d.ts +1 -0
  461. package/dist/primitives/form.js +3 -0
  462. package/dist/primitives/input.d.ts +1 -0
  463. package/dist/primitives/input.js +4 -0
  464. package/dist/primitives/menu.d.ts +1 -0
  465. package/dist/primitives/menu.js +6 -0
  466. package/dist/primitives/menubar.d.ts +1 -0
  467. package/dist/primitives/menubar.js +3 -0
  468. package/dist/primitives/meter.d.ts +1 -0
  469. package/dist/primitives/meter.js +3 -0
  470. package/dist/primitives/navigation-menu.d.ts +1 -0
  471. package/dist/primitives/navigation-menu.js +3 -0
  472. package/dist/primitives/number-field.d.ts +1 -0
  473. package/dist/primitives/number-field.js +3 -0
  474. package/dist/primitives/otp-field.d.ts +3 -0
  475. package/dist/primitives/otp-field.js +4 -0
  476. package/dist/primitives/popover.d.ts +1 -0
  477. package/dist/primitives/popover.js +3 -0
  478. package/dist/primitives/preview-card.d.ts +1 -0
  479. package/dist/primitives/preview-card.js +3 -0
  480. package/dist/primitives/progress.d.ts +1 -0
  481. package/dist/primitives/progress.js +3 -0
  482. package/dist/primitives/radio-group.d.ts +1 -0
  483. package/dist/primitives/radio-group.js +4 -0
  484. package/dist/primitives/radio.d.ts +1 -0
  485. package/dist/primitives/radio.js +4 -0
  486. package/dist/primitives/scroll-area.d.ts +1 -0
  487. package/dist/primitives/scroll-area.js +4 -0
  488. package/dist/primitives/select.d.ts +1 -0
  489. package/dist/primitives/select.js +5 -0
  490. package/dist/primitives/separator.d.ts +1 -0
  491. package/dist/primitives/separator.js +4 -0
  492. package/dist/primitives/slider.d.ts +1 -0
  493. package/dist/primitives/slider.js +4 -0
  494. package/dist/primitives/switch.d.ts +1 -0
  495. package/dist/primitives/switch.js +4 -0
  496. package/dist/primitives/tabs.d.ts +1 -0
  497. package/dist/primitives/tabs.js +4 -0
  498. package/dist/primitives/toast.d.ts +1 -0
  499. package/dist/primitives/toast.js +5 -0
  500. package/dist/primitives/toggle-group.d.ts +1 -0
  501. package/dist/primitives/toggle-group.js +3 -0
  502. package/dist/primitives/toggle.d.ts +1 -0
  503. package/dist/primitives/toggle.js +3 -0
  504. package/dist/primitives/toolbar.d.ts +1 -0
  505. package/dist/primitives/toolbar.js +3 -0
  506. package/dist/primitives/tooltip.d.ts +1 -0
  507. package/dist/primitives/tooltip.js +4 -0
  508. package/dist/primitives.d.ts +42 -0
  509. package/dist/primitives.js +71 -0
  510. package/dist/registry.d.ts +2 -0
  511. package/dist/registry.js +1 -0
  512. package/dist/scripts/theme-generator/config.d.ts +2 -0
  513. package/dist/scripts/theme-generator/config.js +487 -0
  514. package/dist/scripts/theme-generator/types.d.ts +2 -0
  515. package/dist/scripts/theme-generator/types.js +1 -0
  516. package/dist/styles/kumo-binding.css +491 -0
  517. package/dist/styles/kumo-standalone.css +2 -0
  518. package/dist/styles/kumo.css +135 -0
  519. package/dist/styles/theme-code.css +142 -0
  520. package/dist/styles/theme-fedramp.css +31 -0
  521. package/dist/styles/theme-fldr.css +481 -0
  522. package/dist/styles/theme-kumo.css +464 -0
  523. package/dist/text-CRRU2g-u.d.ts +183 -0
  524. package/dist/theming.d.ts +224 -0
  525. package/dist/theming.js +386 -0
  526. package/dist/tooltip-D_vhi1PN.d.ts +105 -0
  527. package/dist/types-CdzJnnIl.d.ts +193 -0
  528. package/dist/types-Cl4HuOrB.d.ts +84 -0
  529. package/dist/utils.d.ts +4 -0
  530. package/dist/utils.js +7 -0
  531. package/package.json +481 -3
  532. package/scripts/component-registry/cache.ts +123 -0
  533. package/scripts/component-registry/discovery.ts +560 -0
  534. package/scripts/component-registry/example-cleanup.ts +168 -0
  535. package/scripts/component-registry/index.test.ts +1075 -0
  536. package/scripts/component-registry/index.ts +1065 -0
  537. package/scripts/component-registry/markdown-generator.ts +222 -0
  538. package/scripts/component-registry/metadata.ts +1030 -0
  539. package/scripts/component-registry/props-filter.ts +312 -0
  540. package/scripts/component-registry/schema-generator.ts +333 -0
  541. package/scripts/component-registry/sub-components.ts +393 -0
  542. package/scripts/component-registry/types.ts +158 -0
  543. package/scripts/component-registry/utils.ts +280 -0
  544. package/scripts/component-registry/variant-parser.ts +262 -0
  545. package/scripts/css-build.ts +107 -0
  546. package/scripts/format-generated.ts +12 -0
  547. package/scripts/generate-globe-land-mask.mjs +80 -0
  548. package/scripts/generate-primitives.ts +196 -0
  549. package/scripts/publish-fldr.ts +120 -0
  550. package/scripts/theme-generator/config.ts +666 -0
  551. package/scripts/theme-generator/generate-css.test.ts +30 -0
  552. package/scripts/theme-generator/generate-css.ts +352 -0
  553. package/scripts/theme-generator/index.ts +175 -0
  554. package/scripts/theme-generator/migrate.ts +560 -0
  555. package/scripts/theme-generator/types.ts +92 -0
@@ -0,0 +1,3985 @@
1
+ "use client";
2
+ import { t as cn } from "./vendor-styling-gs32v7xt5znc8kg0.js";
3
+ import { a as TooltipTrigger, i as TooltipPortal, n as TooltipPositioner, s as TooltipRoot, t as TooltipPopup } from "./TooltipPopup-furysmeyb68uycbz.js";
4
+ import { t as Text } from "./text-nqum95flcp07ac9s.js";
5
+ import { t as SkeletonLine } from "./skeleton-line-kmhnp0lx3rxhioxa.js";
6
+ import { forwardRef, memo, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
7
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
8
+ //#region src/components/chart/Color.ts
9
+ /**
10
+ * Semantic colors for light mode — used to convey meaning (status, severity)
11
+ * rather than just distinguishing series. Use via `ChartPalette.semantic()`.
12
+ */
13
+ var ChartSemanticLightColors = /* @__PURE__ */ function(ChartSemanticLightColors) {
14
+ ChartSemanticLightColors["Attention"] = "#FC574A";
15
+ ChartSemanticLightColors["Warning"] = "#F8A054";
16
+ ChartSemanticLightColors["Success"] = "#00A63E";
17
+ ChartSemanticLightColors["Neutral"] = "#B9D6FF";
18
+ ChartSemanticLightColors["Disabled"] = "#CBCBCB";
19
+ ChartSemanticLightColors["Skeleton"] = "#DDDDDD";
20
+ return ChartSemanticLightColors;
21
+ }(ChartSemanticLightColors || {});
22
+ /**
23
+ * Semantic colors for dark mode
24
+ */
25
+ var ChartSemanticDarkColors = /* @__PURE__ */ function(ChartSemanticDarkColors) {
26
+ ChartSemanticDarkColors["Attention"] = "#FC574A";
27
+ ChartSemanticDarkColors["Warning"] = "#F8A054";
28
+ ChartSemanticDarkColors["Success"] = "#00A63E";
29
+ ChartSemanticDarkColors["Neutral"] = "#8EC5FF";
30
+ ChartSemanticDarkColors["Disabled"] = "#878787";
31
+ ChartSemanticDarkColors["Skeleton"] = "#5C5C5C";
32
+ return ChartSemanticDarkColors;
33
+ }(ChartSemanticDarkColors || {});
34
+ /**
35
+ * Sequential color palettes for light mode with the colour in position #2 of the array as the base.
36
+ */
37
+ const sequentialLight = { blues: [
38
+ "#E1EAF4",
39
+ "#8EBCF6",
40
+ "#4290F0",
41
+ "#0E58B4",
42
+ "#03254F"
43
+ ] };
44
+ /**
45
+ * Sequential color palettes for dark mode. These are the reverse of the light mode palettes using the same base color (position 2).
46
+ */
47
+ const sequentialDark = { blues: [
48
+ "#03254F",
49
+ "#0E58B4",
50
+ "#4290F0",
51
+ "#A6BFDD",
52
+ "#E1EAF4"
53
+ ] };
54
+ /** Neutral land fill per mode; bubbles use the shared categorical palette. */
55
+ const mapAreaByMode = {
56
+ light: "#E5E7EB",
57
+ dark: "#2B2C31"
58
+ };
59
+ /**
60
+ * Choropleth shading ramp per mode (ordered low → high), anchored on the shared
61
+ * chart blue `#4290F0` (same as BubbleMap and `categorical(0)`) so the maps read
62
+ * as one family. Every step stays clearly blue, and the low ends are kept
63
+ * distinct from the neutral no-data fill in both modes.
64
+ */
65
+ const mapScaleByMode = {
66
+ light: [
67
+ "#C8DEFB",
68
+ "#8FBDF6",
69
+ "#4290F0",
70
+ "#1E60BE",
71
+ "#0A3A7A"
72
+ ],
73
+ dark: [
74
+ "#26456C",
75
+ "#2C68BE",
76
+ "#4290F0",
77
+ "#79AEF4",
78
+ "#BBD6FA"
79
+ ]
80
+ };
81
+ /**
82
+ * Ordered list of categorical colors for light mode, indexed by series position.
83
+ * Used as the default ECharts color palette when `isDarkMode` is `false`.
84
+ */
85
+ const CHART_LIGHT_COLORS = [
86
+ "#4290F0",
87
+ "#F5B647",
88
+ "#E8649D",
89
+ "#8D58EE",
90
+ "#50C3B6",
91
+ "#D37536"
92
+ ];
93
+ /**
94
+ * Ordered list of categorical colors for dark mode, indexed by series position.
95
+ * Used as the default ECharts color palette when `isDarkMode` is `true`.
96
+ */
97
+ const CHART_DARK_COLORS = [
98
+ "#4290F0",
99
+ "#EEB720",
100
+ "#E8649D",
101
+ "#8D58EE",
102
+ "#50C3B6",
103
+ "#D37536"
104
+ ];
105
+ let ChartPalette;
106
+ (function(_ChartPalette) {
107
+ function semantic(name, isDarkMode = false) {
108
+ return isDarkMode ? ChartSemanticDarkColors[name] : ChartSemanticLightColors[name];
109
+ }
110
+ _ChartPalette.semantic = semantic;
111
+ function categorical(index, isDarkMode = false) {
112
+ return isDarkMode ? CHART_DARK_COLORS[index % CHART_DARK_COLORS.length] : CHART_LIGHT_COLORS[index % CHART_LIGHT_COLORS.length];
113
+ }
114
+ _ChartPalette.categorical = categorical;
115
+ function sequential(palette, isDarkMode = false) {
116
+ return isDarkMode ? [...sequentialDark[palette]] : [...sequentialLight[palette]];
117
+ }
118
+ _ChartPalette.sequential = sequential;
119
+ function text(variant, isDarkMode = false) {
120
+ const colors = {
121
+ light: {
122
+ primary: "#6B7280",
123
+ secondary: "#9CA3AF"
124
+ },
125
+ dark: {
126
+ primary: "#9CA3AF",
127
+ secondary: "#6B7280"
128
+ }
129
+ };
130
+ return isDarkMode ? colors.dark[variant] : colors.light[variant];
131
+ }
132
+ _ChartPalette.text = text;
133
+ function mapColors(isDarkMode = false) {
134
+ const mode = isDarkMode ? "dark" : "light";
135
+ return {
136
+ area: mapAreaByMode[mode],
137
+ bubble: categorical(0, isDarkMode),
138
+ scale: [...mapScaleByMode[mode]]
139
+ };
140
+ }
141
+ _ChartPalette.mapColors = mapColors;
142
+ })(ChartPalette || (ChartPalette = {}));
143
+ //#endregion
144
+ //#region src/components/chart/EChart.tsx
145
+ const transformTooltip = (tooltipObj) => {
146
+ const { dangerousHtmlFormatter, ...restOfTooltip } = tooltipObj;
147
+ return {
148
+ ...restOfTooltip,
149
+ formatter: dangerousHtmlFormatter
150
+ };
151
+ };
152
+ const prepareChartOptions = ({ options, isDarkMode }) => {
153
+ const withDefaults = {
154
+ backgroundColor: "transparent",
155
+ color: isDarkMode ? CHART_DARK_COLORS : CHART_LIGHT_COLORS,
156
+ ...options
157
+ };
158
+ if (!withDefaults.tooltip) return withDefaults;
159
+ return {
160
+ ...withDefaults,
161
+ tooltip: Array.isArray(withDefaults.tooltip) ? withDefaults.tooltip.map(transformTooltip) : transformTooltip(withDefaults.tooltip)
162
+ };
163
+ };
164
+ /**
165
+ * Chart — a low-level wrapper around [Apache ECharts](https://echarts.apache.org).
166
+ *
167
+ * Manages the ECharts instance lifecycle (init, option updates, event binding,
168
+ * resize observation, and disposal). Exposes the raw `echarts.ECharts` instance
169
+ * via `ref` for imperative access when needed.
170
+ *
171
+ * Prefer `TimeseriesChart` for time-series data; use this component when you
172
+ * need full control over the ECharts option object.
173
+ *
174
+ * @example
175
+ * ```tsx
176
+ * import * as echarts from "echarts/core";
177
+ * import { BarChart } from "echarts/charts";
178
+ * import { GridComponent } from "echarts/components";
179
+ * import { CanvasRenderer } from "echarts/renderers";
180
+ *
181
+ * echarts.use([BarChart, GridComponent, CanvasRenderer]);
182
+ *
183
+ * <Chart
184
+ * echarts={echarts}
185
+ * options={{ xAxis: { data: ["A", "B"] }, yAxis: {}, series: [{ type: "bar", data: [1, 2] }] }}
186
+ * />
187
+ * ```
188
+ */
189
+ const Chart = forwardRef(function Chart({ echarts, options, optionUpdateBehavior, className, isDarkMode, height = 350, aspectRatio, onEvents }, ref) {
190
+ const elRef = useRef(null);
191
+ const chartRef = useRef(null);
192
+ const handlersRef = useRef({});
193
+ const wrappersRef = useRef({});
194
+ const boundEventsRef = useRef(/* @__PURE__ */ new Set());
195
+ useEffect(() => {
196
+ if (!elRef.current) return;
197
+ const chart = echarts.init(elRef.current, isDarkMode ? "dark" : void 0);
198
+ chartRef.current = chart;
199
+ if (typeof ref === "function") ref(chart);
200
+ else if (ref) ref.current = chart;
201
+ return () => {
202
+ for (const event of boundEventsRef.current) {
203
+ const wrapper = wrappersRef.current[event];
204
+ if (wrapper) chart.off(event, wrapper);
205
+ }
206
+ boundEventsRef.current.clear();
207
+ if (typeof ref === "function") ref(null);
208
+ else if (ref) ref.current = null;
209
+ chartRef.current = null;
210
+ chart.dispose();
211
+ };
212
+ }, [elRef, isDarkMode]);
213
+ useEffect(() => {
214
+ const chart = chartRef.current;
215
+ if (!chart) return;
216
+ chart.setOption(prepareChartOptions({
217
+ options,
218
+ isDarkMode
219
+ }), {
220
+ notMerge: false,
221
+ lazyUpdate: true,
222
+ ...optionUpdateBehavior
223
+ });
224
+ }, [
225
+ isDarkMode,
226
+ optionUpdateBehavior,
227
+ options
228
+ ]);
229
+ useEffect(() => {
230
+ handlersRef.current = onEvents ?? {};
231
+ }, [onEvents]);
232
+ useEffect(() => {
233
+ const chart = chartRef.current;
234
+ if (!chart) return;
235
+ const nextBound = /* @__PURE__ */ new Set();
236
+ for (const [event, handler] of Object.entries(onEvents ?? {})) {
237
+ if (typeof handler !== "function") continue;
238
+ nextBound.add(event);
239
+ if (!wrappersRef.current[event]) wrappersRef.current[event] = (params) => {
240
+ handlersRef.current[event]?.(params);
241
+ };
242
+ if (!boundEventsRef.current.has(event)) chart.on(event, wrappersRef.current[event]);
243
+ }
244
+ for (const event of boundEventsRef.current) {
245
+ if (nextBound.has(event)) continue;
246
+ const wrapper = wrappersRef.current[event];
247
+ if (wrapper) chart.off(event, wrapper);
248
+ }
249
+ boundEventsRef.current = nextBound;
250
+ }, [
251
+ echarts,
252
+ isDarkMode,
253
+ onEvents
254
+ ]);
255
+ useEffect(() => {
256
+ const chart = chartRef.current;
257
+ const el = elRef.current;
258
+ if (!chart || !el) return;
259
+ let isInitial = true;
260
+ const ro = new ResizeObserver(() => {
261
+ if (isInitial) {
262
+ isInitial = false;
263
+ return;
264
+ }
265
+ chart.resize();
266
+ });
267
+ ro.observe(el);
268
+ return () => ro.disconnect();
269
+ }, []);
270
+ return /* @__PURE__ */ jsx("div", {
271
+ ref: elRef,
272
+ className: cn("w-full", className),
273
+ style: aspectRatio !== void 0 ? { aspectRatio: String(aspectRatio) } : { height },
274
+ tabIndex: options.aria?.enabled ? 0 : void 0,
275
+ role: options.aria?.enabled ? "img" : void 0
276
+ });
277
+ });
278
+ Chart.displayName = "Chart";
279
+ //#endregion
280
+ //#region src/components/chart/timeseries-markers.ts
281
+ function buildTimeseriesMarkerAnnotations(clusters, style) {
282
+ if (clusters.length === 0) return void 0;
283
+ const labelStyle = {
284
+ backgroundColor: style.labelBackgroundColor,
285
+ padding: [2, 4],
286
+ borderRadius: 6,
287
+ shadowBlur: 8,
288
+ shadowColor: style.labelBackgroundColor
289
+ };
290
+ return { markLine: {
291
+ symbol: "none",
292
+ silent: false,
293
+ animation: false,
294
+ z: 10,
295
+ lineStyle: {
296
+ type: "dashed",
297
+ color: style.color,
298
+ width: 1
299
+ },
300
+ emphasis: { lineStyle: { width: 2 } },
301
+ blur: {
302
+ lineStyle: { opacity: 1 },
303
+ label: { opacity: 1 }
304
+ },
305
+ label: {
306
+ show: true,
307
+ formatter: (params) => params.name ?? "",
308
+ position: "insideEndTop",
309
+ color: style.color,
310
+ ...labelStyle
311
+ },
312
+ data: clusters.map((cluster) => ({
313
+ name: cluster.label,
314
+ xAxis: cluster.timestamp,
315
+ lineStyle: {
316
+ type: cluster.lineStyle ?? "dashed",
317
+ color: cluster.color ?? style.color,
318
+ width: 1
319
+ },
320
+ emphasis: { lineStyle: { width: 2 } },
321
+ blur: {
322
+ lineStyle: { opacity: 1 },
323
+ label: { opacity: 1 }
324
+ },
325
+ label: {
326
+ show: Boolean(cluster.label),
327
+ color: cluster.color ?? style.color,
328
+ ...labelStyle
329
+ },
330
+ tooltip: { marker: cluster }
331
+ }))
332
+ } };
333
+ }
334
+ function clusterTimeseriesMarkers(markers, interval) {
335
+ if (!markers?.length) return [];
336
+ const sorted = [...markers].sort((a, b) => a.timestamp - b.timestamp);
337
+ const clusters = [];
338
+ for (const marker of sorted) {
339
+ const previous = clusters.at(-1);
340
+ if (previous && marker.timestamp - previous[previous.length - 1].timestamp <= interval) previous.push(marker);
341
+ else clusters.push([marker]);
342
+ }
343
+ return clusters.map((cluster) => {
344
+ const first = cluster[0];
345
+ return {
346
+ timestamp: first.timestamp,
347
+ label: cluster.length === 1 ? first.label : `${cluster.length} changes`,
348
+ color: first.color,
349
+ lineStyle: first.lineStyle,
350
+ markers: cluster
351
+ };
352
+ });
353
+ }
354
+ function getApproximateMarkerClusterInterval(timestamps, tickCount) {
355
+ let min = Infinity;
356
+ let max = -Infinity;
357
+ let count = 0;
358
+ for (const timestamp of timestamps) {
359
+ if (timestamp < min) min = timestamp;
360
+ if (timestamp > max) max = timestamp;
361
+ count++;
362
+ }
363
+ if (count < 2) return 0;
364
+ return (max - min) / tickCount;
365
+ }
366
+ function getTimeseriesMarkerFromEvent(params) {
367
+ if (params.componentType !== "markLine") return;
368
+ return params.data?.tooltip?.marker;
369
+ }
370
+ //#endregion
371
+ //#region src/components/chart/timeseries-tooltip.tsx
372
+ const TooltipContent = memo(function TooltipContent({ state, formatValue, formatTimestamp, footer }) {
373
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [state.type === "marker" ? /* @__PURE__ */ jsx(MarkerTooltipContent, {
374
+ state,
375
+ formatValue,
376
+ formatTimestamp
377
+ }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
378
+ className: "mb-1 text-xs font-semibold text-kumo-default",
379
+ children: formatTimestamp(state.ts)
380
+ }), /* @__PURE__ */ jsx(SeriesTooltipRows, {
381
+ rows: state.rows,
382
+ hiddenCount: state.hiddenCount,
383
+ formatValue
384
+ })] }), footer && /* @__PURE__ */ jsx("div", {
385
+ className: "mt-1",
386
+ children: /* @__PURE__ */ jsx(Text, {
387
+ variant: "secondary",
388
+ size: "xs",
389
+ children: footer
390
+ })
391
+ })] });
392
+ });
393
+ function MarkerTooltipContent({ state, formatValue, formatTimestamp }) {
394
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
395
+ state.markers.length === 1 && /* @__PURE__ */ jsx("div", {
396
+ className: "mb-1 text-xs font-semibold text-kumo-default",
397
+ children: formatTimestamp(state.markers[0].timestamp)
398
+ }),
399
+ /* @__PURE__ */ jsx("div", {
400
+ className: "space-y-1",
401
+ children: state.markers.map((marker, index) => /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("div", {
402
+ className: "flex items-center gap-2 text-xs text-kumo-default",
403
+ children: [
404
+ /* @__PURE__ */ jsx("span", {
405
+ className: "h-3 w-3 shrink-0 rounded-full",
406
+ style: { backgroundColor: marker.color ?? state.color }
407
+ }),
408
+ /* @__PURE__ */ jsx("span", {
409
+ className: "font-medium",
410
+ children: marker.label ?? "Reference marker"
411
+ }),
412
+ state.markers.length > 1 && /* @__PURE__ */ jsx("span", {
413
+ className: "text-kumo-subtle",
414
+ children: formatTimestamp(marker.timestamp)
415
+ })
416
+ ]
417
+ }), marker.description && /* @__PURE__ */ jsx("div", {
418
+ className: "mt-0.5 ml-5 text-xs text-kumo-default",
419
+ children: marker.description
420
+ })] }, `${marker.timestamp}-${marker.label}-${index}`))
421
+ }),
422
+ state.rows.length > 0 && /* @__PURE__ */ jsx("div", {
423
+ className: "mt-2 border-t border-kumo-line pt-2",
424
+ children: /* @__PURE__ */ jsx(SeriesTooltipRows, {
425
+ rows: state.rows,
426
+ hiddenCount: state.hiddenCount,
427
+ formatValue
428
+ })
429
+ })
430
+ ] });
431
+ }
432
+ function SeriesTooltipRows({ rows, hiddenCount, formatValue }) {
433
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [rows.map((row) => /* @__PURE__ */ jsxs("div", {
434
+ className: "flex items-center justify-between gap-4 py-0.5",
435
+ children: [/* @__PURE__ */ jsxs("div", {
436
+ className: "flex min-w-0 items-center gap-2",
437
+ children: [/* @__PURE__ */ jsx("span", {
438
+ className: "h-3 w-3 shrink-0 rounded-full",
439
+ style: { backgroundColor: row.color }
440
+ }), /* @__PURE__ */ jsx("span", {
441
+ className: "truncate text-xs font-medium text-kumo-default",
442
+ title: row.name,
443
+ children: row.name
444
+ })]
445
+ }), /* @__PURE__ */ jsx("span", {
446
+ className: "shrink-0 text-xs font-semibold text-kumo-default",
447
+ children: formatValue ? formatValue(row.value) : formatDefaultValue(row.value)
448
+ })]
449
+ }, row.name)), hiddenCount > 0 && /* @__PURE__ */ jsxs("div", {
450
+ className: "mt-1 text-xs text-kumo-subtle",
451
+ children: [
452
+ "+",
453
+ hiddenCount,
454
+ " more"
455
+ ]
456
+ })] });
457
+ }
458
+ const defaultNumberFormat = new Intl.NumberFormat(void 0, { maximumFractionDigits: 3 });
459
+ function formatDefaultValue(value) {
460
+ if (Number.isInteger(value)) return String(value);
461
+ return defaultNumberFormat.format(value);
462
+ }
463
+ //#endregion
464
+ //#region src/components/chart/timeseries-thresholds.ts
465
+ function buildTimeseriesThresholdAnnotations(thresholds) {
466
+ if (!thresholds?.length) return void 0;
467
+ return { markLine: {
468
+ symbol: "none",
469
+ silent: true,
470
+ animation: false,
471
+ z: 9,
472
+ lineStyle: {
473
+ type: "dashed",
474
+ width: 1
475
+ },
476
+ blur: {
477
+ lineStyle: { opacity: 1 },
478
+ label: { opacity: 1 }
479
+ },
480
+ label: {
481
+ show: true,
482
+ position: "insideEndTop",
483
+ formatter: (params) => params.name ?? ""
484
+ },
485
+ data: thresholds.map((threshold) => ({
486
+ name: threshold.label,
487
+ yAxis: threshold.value,
488
+ lineStyle: {
489
+ color: threshold.color,
490
+ width: 1,
491
+ type: "dashed"
492
+ },
493
+ blur: {
494
+ lineStyle: { opacity: 1 },
495
+ label: { opacity: 1 }
496
+ },
497
+ label: {
498
+ show: Boolean(threshold.label),
499
+ color: threshold.color
500
+ }
501
+ }))
502
+ } };
503
+ }
504
+ function getThresholdValueExtent(thresholds) {
505
+ if (!thresholds?.length) return void 0;
506
+ const values = thresholds.map((threshold) => threshold.value);
507
+ return {
508
+ min: Math.min(...values),
509
+ max: Math.max(...values)
510
+ };
511
+ }
512
+ //#endregion
513
+ //#region src/components/chart/TimeseriesChart.tsx
514
+ const DEFAULT_X_AXIS_TICK_COUNT = 5;
515
+ /**
516
+ * TimeseriesChart — a time-series line or bar chart.
517
+ *
518
+ * Built on `Chart` (Apache ECharts) with opinionated defaults for time-series data:
519
+ * a time-typed x-axis, dashed lines for incomplete data periods, brush-based
520
+ * time range selection, and automatic tooltip deduplication.
521
+ *
522
+ * @example
523
+ * ```tsx
524
+ * import * as echarts from "echarts/core";
525
+ * import { LineChart } from "echarts/charts";
526
+ * import { GridComponent, TooltipComponent, BrushComponent, ToolboxComponent } from "echarts/components";
527
+ * import { CanvasRenderer } from "echarts/renderers";
528
+ *
529
+ * echarts.use([LineChart, GridComponent, TooltipComponent, BrushComponent, ToolboxComponent, CanvasRenderer]);
530
+ *
531
+ * const [range, setRange] = useState<[number, number]>();
532
+ *
533
+ * <TimeseriesChart
534
+ * echarts={echarts}
535
+ * data={[{ name: "Requests", data: [[Date.now(), 42]], color: "#086FFF" }]}
536
+ * xAxisName="Time"
537
+ * xAxisTickFormat={(ts) => new Date(ts).toLocaleTimeString()}
538
+ * yAxisName="Count"
539
+ * yAxisTickFormat={(value) => `${value / 1000}k`}
540
+ * tooltipValueFormat={(value) => `${value.toFixed(2)} req/s`}
541
+ * tooltipTimestampFormat={(timestamp) => new Intl.DateTimeFormat(undefined, {
542
+ * timeZone: "UTC",
543
+ * dateStyle: "medium",
544
+ * timeStyle: "medium",
545
+ * }).format(timestamp)}
546
+ * onTimeRangeChange={(from, to) => setRange([from, to])}
547
+ * />
548
+ * ```
549
+ */
550
+ const TimeseriesChart = forwardRef(function TimeseriesChart({ echarts, type = "line", data, markers, thresholds, xAxisName, xAxisTickCount, xAxisHideLabelOverlap = true, xAxisTickFormat, yAxisTickFormat, yAxisTickLabelFormat, yAxisName, yAxisTickCount, yAxisMinInterval, tooltipValueFormat, tooltipTimestampFormat, tooltipFooter, onTimeRangeChange, height = 350, incomplete, enableLegendSelection = false, isDarkMode, gradient, loading, ariaDescription, optionUpdateBehavior, tooltipMode = "all", tooltipMaxItems = 10, tooltipFollowCursor = "both", tooltipBoundary }, ref) {
551
+ const chartRef = useRef(null);
552
+ const containerRef = useRef(null);
553
+ const mergedRef = useCallback((instance) => {
554
+ chartRef.current = instance;
555
+ if (typeof ref === "function") ref(instance);
556
+ else if (ref) ref.current = instance;
557
+ }, [ref]);
558
+ const dataRef = useRef(data);
559
+ dataRef.current = data;
560
+ const legendSelectedRef = useRef(null);
561
+ useEffect(() => {
562
+ legendSelectedRef.current = null;
563
+ }, [enableLegendSelection, isDarkMode]);
564
+ const markerHoverRef = useRef(false);
565
+ const activeMarkerKeyRef = useRef(null);
566
+ const tooltipModeRef = useRef(tooltipMode);
567
+ tooltipModeRef.current = tooltipMode;
568
+ const tooltipMaxItemsRef = useRef(tooltipMaxItems);
569
+ tooltipMaxItemsRef.current = tooltipMaxItems;
570
+ const [tooltipState, setTooltipState] = useState(null);
571
+ const closeTooltip = useCallback(() => {
572
+ activeMarkerKeyRef.current = null;
573
+ markerHoverRef.current = false;
574
+ setTooltipState(null);
575
+ }, []);
576
+ const tooltipOpen = tooltipState !== null;
577
+ useEffect(() => {
578
+ if (!tooltipOpen) return;
579
+ if (typeof window === "undefined") return;
580
+ const closeWhenOutsideChart = (event) => {
581
+ const container = containerRef.current;
582
+ if (!container) return;
583
+ const rect = container.getBoundingClientRect();
584
+ if (event.clientX < rect.left || event.clientX > rect.right || event.clientY < rect.top || event.clientY > rect.bottom) closeTooltip();
585
+ };
586
+ window.addEventListener("mousemove", closeWhenOutsideChart);
587
+ return () => window.removeEventListener("mousemove", closeWhenOutsideChart);
588
+ }, [tooltipOpen, closeTooltip]);
589
+ const mousePosRef = useRef({
590
+ x: 0,
591
+ y: 0
592
+ });
593
+ useEffect(() => {
594
+ const container = containerRef.current;
595
+ if (!container) return;
596
+ const onMove = (e) => {
597
+ const rect = container.getBoundingClientRect();
598
+ mousePosRef.current = {
599
+ x: e.clientX - rect.left,
600
+ y: e.clientY - rect.top
601
+ };
602
+ };
603
+ container.addEventListener("mousemove", onMove);
604
+ return () => container.removeEventListener("mousemove", onMove);
605
+ }, []);
606
+ const incompleteBefore = incomplete?.before;
607
+ const incompleteAfter = incomplete?.after;
608
+ const markerColor = ChartPalette.text("primary", isDarkMode);
609
+ const axisTextColor = ChartPalette.text("primary", isDarkMode);
610
+ const gridLineColor = colorWithOpacity(axisTextColor, .2);
611
+ const markerLabelBackgroundColor = isDarkMode ? "rgba(0, 0, 0, 0.5)" : "rgba(255, 255, 255, 0.5)";
612
+ const options = useMemo(() => {
613
+ const transformSeries = [];
614
+ const seriesType = type === "bar" ? {
615
+ type: "bar",
616
+ stack: "total"
617
+ } : {
618
+ type: "line",
619
+ showSymbol: false
620
+ };
621
+ const thresholdAnnotations = buildTimeseriesThresholdAnnotations(thresholds);
622
+ const thresholdExtent = getThresholdValueExtent(thresholds);
623
+ const markerAnnotations = buildTimeseriesMarkerAnnotations(markers?.length ? clusterTimeseriesMarkers(markers, getApproximateMarkerClusterInterval(getTimestamps(data, markers), xAxisTickCount ?? DEFAULT_X_AXIS_TICK_COUNT)) : [], {
624
+ color: markerColor,
625
+ labelBackgroundColor: markerLabelBackgroundColor
626
+ });
627
+ for (const s of data) {
628
+ const incompleteBeforePoints = incompleteBefore && type === "line" ? s.data.filter((point) => point[0] <= incompleteBefore) : [];
629
+ const incompleteAfterPoints = incompleteAfter && type === "line" ? s.data.filter((point) => point[0] >= incompleteAfter) : [];
630
+ const completePoints = incompleteBeforePoints.length > 0 || incompleteAfterPoints.length > 0 ? s.data.slice(Math.max(0, incompleteBeforePoints.length - 1), Math.max(0, s.data.length - incompleteAfterPoints.length + 1)) : s.data;
631
+ const areaStyle = gradient && type === "line" ? { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
632
+ offset: 0,
633
+ color: colorWithOpacity(s.color, .4)
634
+ }, {
635
+ offset: 1,
636
+ color: colorWithOpacity(s.color, 0)
637
+ }]) } : void 0;
638
+ transformSeries.push({
639
+ data: completePoints,
640
+ color: s.color,
641
+ name: s.name,
642
+ emphasis: { focus: "series" },
643
+ ...areaStyle ? { areaStyle } : {},
644
+ ...seriesType
645
+ });
646
+ const incompleteSeriesConfig = {
647
+ color: s.color,
648
+ name: s.name,
649
+ type: "line",
650
+ lineStyle: { type: "dashed" },
651
+ showSymbol: false,
652
+ emphasis: { focus: "series" }
653
+ };
654
+ if (incompleteBeforePoints.length > 0) transformSeries.push({
655
+ ...incompleteSeriesConfig,
656
+ data: incompleteBeforePoints
657
+ });
658
+ if (incompleteAfterPoints.length > 0) transformSeries.push({
659
+ ...incompleteSeriesConfig,
660
+ data: incompleteAfterPoints
661
+ });
662
+ }
663
+ if (markerAnnotations) transformSeries.push({
664
+ data: [],
665
+ name: "Markers",
666
+ type: type === "bar" ? "bar" : "line",
667
+ animation: false,
668
+ markLine: markerAnnotations.markLine
669
+ });
670
+ if (thresholdAnnotations) transformSeries.push({
671
+ data: [],
672
+ name: "Thresholds",
673
+ type: type === "bar" ? "bar" : "line",
674
+ animation: false,
675
+ markLine: thresholdAnnotations.markLine
676
+ });
677
+ return {
678
+ aria: {
679
+ enabled: true,
680
+ ...ariaDescription && { label: { description: ariaDescription } }
681
+ },
682
+ brush: {
683
+ xAxisIndex: "all",
684
+ brushType: "lineX",
685
+ brushMode: "single",
686
+ outOfBrush: { colorAlpha: .3 },
687
+ brushStyle: {
688
+ borderWidth: 1,
689
+ color: "rgba(120,140,180,0.3)",
690
+ borderColor: "rgba(120,140,180,0.8)"
691
+ }
692
+ },
693
+ tooltip: {
694
+ trigger: "axis",
695
+ showContent: false,
696
+ axisPointer: { type: "shadow" }
697
+ },
698
+ backgroundColor: "transparent",
699
+ toolbox: { show: false },
700
+ ...enableLegendSelection ? { legend: { show: false } } : {},
701
+ xAxis: {
702
+ name: xAxisName,
703
+ nameLocation: "middle",
704
+ nameGap: 30,
705
+ nameTextStyle: { color: axisTextColor },
706
+ type: "time",
707
+ splitLine: { show: false },
708
+ axisLine: { show: false },
709
+ splitNumber: xAxisTickCount ?? DEFAULT_X_AXIS_TICK_COUNT,
710
+ axisLabel: {
711
+ color: axisTextColor,
712
+ hideOverlap: xAxisHideLabelOverlap,
713
+ ...xAxisTickFormat && { formatter: (value) => xAxisTickFormat(value) }
714
+ }
715
+ },
716
+ yAxis: {
717
+ name: yAxisName,
718
+ nameLocation: "middle",
719
+ nameGap: 40,
720
+ nameTextStyle: { color: axisTextColor },
721
+ type: "value",
722
+ axisTick: { show: true },
723
+ axisLabel: {
724
+ margin: 15,
725
+ color: axisTextColor,
726
+ ...yAxisTickFormat && { formatter: (value) => yAxisTickFormat(value) }
727
+ },
728
+ splitLine: {
729
+ show: true,
730
+ lineStyle: {
731
+ type: "dashed",
732
+ width: 1,
733
+ color: gridLineColor
734
+ }
735
+ },
736
+ splitNumber: yAxisTickCount,
737
+ ...yAxisMinInterval !== void 0 && { minInterval: yAxisMinInterval },
738
+ ...thresholdExtent && {
739
+ min: (value) => Math.min(value.min, thresholdExtent.min),
740
+ max: (value) => Math.max(value.max, thresholdExtent.max)
741
+ }
742
+ },
743
+ grid: {
744
+ left: yAxisName ? 30 : 24,
745
+ right: 24,
746
+ top: 24,
747
+ bottom: xAxisName ? 30 : 24
748
+ },
749
+ series: transformSeries
750
+ };
751
+ }, [
752
+ data,
753
+ xAxisName,
754
+ xAxisTickCount,
755
+ xAxisHideLabelOverlap,
756
+ xAxisTickFormat,
757
+ yAxisTickFormat,
758
+ yAxisName,
759
+ yAxisTickCount,
760
+ yAxisMinInterval,
761
+ incompleteBefore,
762
+ incompleteAfter,
763
+ type,
764
+ gradient,
765
+ enableLegendSelection,
766
+ echarts,
767
+ ariaDescription,
768
+ markers,
769
+ thresholds,
770
+ markerColor,
771
+ markerLabelBackgroundColor,
772
+ axisTextColor,
773
+ gridLineColor
774
+ ]);
775
+ const events = useMemo(() => {
776
+ return {
777
+ updateaxispointer: (params) => {
778
+ if (markerHoverRef.current) return;
779
+ const ts = params?.axesInfo?.[0]?.value;
780
+ if (ts == null) return;
781
+ const allRows = getAllTooltipRowsAtTimestamp(dataRef.current, ts, legendSelectedRef.current);
782
+ let rows;
783
+ let hiddenCount = 0;
784
+ if (tooltipModeRef.current === "single") {
785
+ const chart = chartRef.current;
786
+ const cursorValue = chart ? chart.convertFromPixel("grid", [0, mousePosRef.current.y])?.[1] : null;
787
+ if (cursorValue != null && allRows.length > 0) rows = [allRows.reduce((best, row) => Math.abs(row.value - cursorValue) < Math.abs(best.value - cursorValue) ? row : best)];
788
+ else rows = allRows.slice(0, 1);
789
+ } else ({rows, hiddenCount} = limitTooltipRows(allRows, tooltipMaxItemsRef.current));
790
+ const nextState = {
791
+ type: "series",
792
+ ts,
793
+ rows,
794
+ hiddenCount
795
+ };
796
+ setTooltipState((prev) => {
797
+ if (isSameTooltipState(prev, nextState)) return prev;
798
+ return nextState;
799
+ });
800
+ },
801
+ mouseover: (params) => {
802
+ const marker = getTimeseriesMarkerFromEvent(params);
803
+ if (!marker) return;
804
+ const markerKey = `${marker.timestamp}-${marker.label ?? ""}`;
805
+ if (activeMarkerKeyRef.current === markerKey) return;
806
+ activeMarkerKeyRef.current = markerKey;
807
+ markerHoverRef.current = true;
808
+ chartRef.current?.dispatchAction({ type: "hideTip" });
809
+ chartRef.current?.dispatchAction({
810
+ type: "updateAxisPointer",
811
+ currTrigger: "leave"
812
+ });
813
+ const { rows, hiddenCount } = getTooltipRowsAtTimestamp(dataRef.current, marker.timestamp, legendSelectedRef.current, tooltipMaxItemsRef.current);
814
+ setTooltipState({
815
+ type: "marker",
816
+ ts: marker.timestamp,
817
+ color: marker.color ?? markerColor,
818
+ markers: marker.markers,
819
+ rows,
820
+ hiddenCount
821
+ });
822
+ },
823
+ mouseout: (params) => {
824
+ if (!getTimeseriesMarkerFromEvent(params)) return;
825
+ closeTooltip();
826
+ },
827
+ globalout: closeTooltip,
828
+ legendselectchanged: (params) => {
829
+ legendSelectedRef.current = params.selected;
830
+ },
831
+ legendselected: (params) => {
832
+ legendSelectedRef.current = params.selected;
833
+ },
834
+ legendunselected: (params) => {
835
+ legendSelectedRef.current = params.selected;
836
+ },
837
+ ...onTimeRangeChange && { brushend: (params) => {
838
+ const range = params.areas[0].coordRange;
839
+ onTimeRangeChange(range[0], range[1]);
840
+ chartRef.current?.dispatchAction({
841
+ type: "brush",
842
+ areas: []
843
+ });
844
+ } }
845
+ };
846
+ }, [
847
+ onTimeRangeChange,
848
+ markerColor,
849
+ closeTooltip
850
+ ]);
851
+ const hasTimeRangeCallback = !!onTimeRangeChange;
852
+ const brushResetKey = optionUpdateBehavior?.notMerge ? options : void 0;
853
+ useEffect(() => {
854
+ const chart = chartRef.current;
855
+ if (chart && hasTimeRangeCallback) {
856
+ chart.dispatchAction({
857
+ type: "takeGlobalCursor",
858
+ key: "brush",
859
+ brushOption: {
860
+ brushType: "lineX",
861
+ brushMode: "single"
862
+ }
863
+ });
864
+ return () => {
865
+ chart.dispatchAction({
866
+ type: "takeGlobalCursor",
867
+ key: "brush",
868
+ brushOption: { brushType: false }
869
+ });
870
+ };
871
+ }
872
+ }, [
873
+ chartRef,
874
+ hasTimeRangeCallback,
875
+ loading,
876
+ brushResetKey
877
+ ]);
878
+ return /* @__PURE__ */ jsxs(TooltipRoot, {
879
+ open: tooltipOpen,
880
+ trackCursorAxis: tooltipFollowCursor,
881
+ children: [/* @__PURE__ */ jsx(TooltipTrigger, {
882
+ render: /* @__PURE__ */ jsx("div", {
883
+ ref: containerRef,
884
+ className: "relative w-full",
885
+ style: { height },
886
+ "aria-busy": loading || void 0
887
+ }),
888
+ children: loading ? /* @__PURE__ */ jsx(ChartSkeletonLoader, {
889
+ height,
890
+ isDarkMode,
891
+ type
892
+ }) : /* @__PURE__ */ jsx(Chart, {
893
+ echarts,
894
+ ref: mergedRef,
895
+ options,
896
+ height,
897
+ isDarkMode,
898
+ onEvents: events,
899
+ optionUpdateBehavior
900
+ })
901
+ }), tooltipOpen && /* @__PURE__ */ jsx(TooltipPortal, { children: /* @__PURE__ */ jsx(TooltipPositioner, {
902
+ side: "right",
903
+ align: "start",
904
+ sideOffset: 12,
905
+ collisionAvoidance: {
906
+ side: "flip",
907
+ align: "shift"
908
+ },
909
+ collisionBoundary: tooltipBoundary,
910
+ collisionPadding: 8,
911
+ children: /* @__PURE__ */ jsx(TooltipPopup, {
912
+ "data-mode": isDarkMode ? "dark" : "light",
913
+ className: "max-w-xs min-w-[150px] rounded-lg bg-kumo-base p-2 shadow-md outline-1 outline-kumo-line",
914
+ children: /* @__PURE__ */ jsx(TooltipContent, {
915
+ state: tooltipState,
916
+ formatValue: tooltipValueFormat ?? yAxisTickLabelFormat,
917
+ formatTimestamp: tooltipTimestampFormat ?? formatDefaultTimestamp,
918
+ footer: tooltipFooter
919
+ })
920
+ })
921
+ }) })]
922
+ });
923
+ });
924
+ TimeseriesChart.displayName = "TimeseriesChart";
925
+ /** Binary search for the value in `data` whose timestamp is closest to `ts`. */
926
+ function findNearest(data, ts) {
927
+ if (data.length === 0) return null;
928
+ let lo = 0, hi = data.length - 1;
929
+ while (lo < hi) {
930
+ const mid = lo + hi >> 1;
931
+ if (data[mid][0] < ts) lo = mid + 1;
932
+ else hi = mid;
933
+ }
934
+ if (lo > 0 && Math.abs(data[lo - 1][0] - ts) < Math.abs(data[lo][0] - ts)) lo--;
935
+ return data[lo][1];
936
+ }
937
+ function* getTimestamps(data, markers) {
938
+ for (const series of data) for (const [timestamp] of series.data) yield timestamp;
939
+ for (const marker of markers) yield marker.timestamp;
940
+ }
941
+ function getAllTooltipRowsAtTimestamp(data, ts, legendSelected) {
942
+ const seenNames = /* @__PURE__ */ new Set();
943
+ const rows = [];
944
+ for (const s of data) {
945
+ if (seenNames.has(s.name)) continue;
946
+ if (legendSelected && legendSelected[s.name] === false) continue;
947
+ seenNames.add(s.name);
948
+ const value = findNearest(s.data, ts);
949
+ if (value != null) rows.push({
950
+ name: s.name,
951
+ value,
952
+ color: s.color
953
+ });
954
+ }
955
+ return rows.sort((a, b) => b.value - a.value);
956
+ }
957
+ function limitTooltipRows(rows, max) {
958
+ return {
959
+ rows: rows.slice(0, max),
960
+ hiddenCount: Math.max(0, rows.length - max)
961
+ };
962
+ }
963
+ function getTooltipRowsAtTimestamp(data, ts, legendSelected, max) {
964
+ return limitTooltipRows(getAllTooltipRowsAtTimestamp(data, ts, legendSelected), max);
965
+ }
966
+ function isSameMarkerTooltipState(a, b) {
967
+ return a.ts === b.ts && a.color === b.color && a.hiddenCount === b.hiddenCount && a.rows.length === b.rows.length && isSameTooltipRows(a.rows, b.rows) && a.markers.length === b.markers.length && a.markers.every((marker, i) => {
968
+ const next = b.markers[i];
969
+ return marker.timestamp === next.timestamp && marker.label === next.label && marker.description === next.description && marker.color === next.color && marker.lineStyle === next.lineStyle;
970
+ });
971
+ }
972
+ /** Shallow-compare two tooltip states so React can skip renders when nothing changed. */
973
+ function isSameTooltipState(a, b) {
974
+ if (!a || a.type !== b.type) return false;
975
+ if (a.type === "marker" && b.type === "marker") return isSameMarkerTooltipState(a, b);
976
+ if (a.type !== "series" || b.type !== "series") return false;
977
+ if (a.ts !== b.ts || a.hiddenCount !== b.hiddenCount || a.rows.length !== b.rows.length) return false;
978
+ return isSameTooltipRows(a.rows, b.rows);
979
+ }
980
+ function isSameTooltipRows(a, b) {
981
+ return a.every((row, i) => {
982
+ const next = b[i];
983
+ return row.name === next.name && row.value === next.value && row.color === next.color;
984
+ });
985
+ }
986
+ /** Line/area or bar chart skeleton with a reduced-motion-aware shimmer. */
987
+ const CHART_LOADER_WIDTH = 400;
988
+ const CHART_LOADER_SAMPLES = 80;
989
+ const CHART_LOADER_BARS = 24;
990
+ /**
991
+ * Sum of harmonics used to shape both the area line and the bar heights, so the
992
+ * two skeleton variants share the same calm, organic silhouette.
993
+ * Returns a value roughly in the range `[-1, 1]`.
994
+ */
995
+ function chartLoaderWave(theta) {
996
+ return .45 * Math.sin(3 * theta) + .3 * Math.sin(5 * theta + .9) + .25 * Math.sin(7 * theta + 2.1);
997
+ }
998
+ function ChartSkeletonLoader({ height, isDarkMode, type = "line" }) {
999
+ const id = `kumo-chart-loader-${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`;
1000
+ const fillId = `${id}-fill`;
1001
+ const shineId = `${id}-shine`;
1002
+ const clipId = `${id}-clip`;
1003
+ const color = ChartPalette.semantic("Skeleton", isDarkMode);
1004
+ const strokeOpacity = isDarkMode ? .36 : .6;
1005
+ const fillOpacity = isDarkMode ? .07 : .1;
1006
+ const shineOpacity = isDarkMode ? .16 : .24;
1007
+ const barFillOpacity = isDarkMode ? .12 : .16;
1008
+ const slot = CHART_LOADER_WIDTH / CHART_LOADER_BARS;
1009
+ const barW = slot * .65;
1010
+ const minBarH = height * .15;
1011
+ const maxBarH = height * .85;
1012
+ const bars = Array.from({ length: CHART_LOADER_BARS }, (_, i) => {
1013
+ const norm = (chartLoaderWave((i + .5) / CHART_LOADER_BARS * 2 * Math.PI) + 1) / 2;
1014
+ const barH = minBarH + norm * (maxBarH - minBarH);
1015
+ return {
1016
+ x: i * slot + 5.833333333333334 / 2,
1017
+ y: height - barH,
1018
+ w: barW,
1019
+ h: barH
1020
+ };
1021
+ });
1022
+ const mid = height / 2;
1023
+ const amp = Math.min(height * .18, 40);
1024
+ const lineD = Array.from({ length: 81 }, (_, i) => {
1025
+ const x = i / CHART_LOADER_SAMPLES * CHART_LOADER_WIDTH;
1026
+ const theta = x / CHART_LOADER_WIDTH * 2 * Math.PI;
1027
+ const y = mid - chartLoaderWave(theta) * amp;
1028
+ return `${i === 0 ? "M" : "L"}${x.toFixed(2)},${y.toFixed(2)}`;
1029
+ }).join(" ");
1030
+ const areaD = `${lineD} L${CHART_LOADER_WIDTH},${height} L0,${height} Z`;
1031
+ const isBar = type === "bar";
1032
+ return /* @__PURE__ */ jsx("div", {
1033
+ role: "status",
1034
+ "aria-label": "Loading chart",
1035
+ className: "absolute inset-0 overflow-hidden",
1036
+ style: { height },
1037
+ children: /* @__PURE__ */ jsxs("svg", {
1038
+ "aria-hidden": "true",
1039
+ width: "100%",
1040
+ height,
1041
+ viewBox: `0 0 ${CHART_LOADER_WIDTH} ${height}`,
1042
+ preserveAspectRatio: "none",
1043
+ className: "block w-full",
1044
+ children: [
1045
+ /* @__PURE__ */ jsxs("defs", { children: [
1046
+ /* @__PURE__ */ jsxs("linearGradient", {
1047
+ id: fillId,
1048
+ x1: "0",
1049
+ y1: "0",
1050
+ x2: "0",
1051
+ y2: "1",
1052
+ children: [/* @__PURE__ */ jsx("stop", {
1053
+ offset: "0%",
1054
+ stopColor: color,
1055
+ stopOpacity: fillOpacity
1056
+ }), /* @__PURE__ */ jsx("stop", {
1057
+ offset: "100%",
1058
+ stopColor: color,
1059
+ stopOpacity: "0"
1060
+ })]
1061
+ }),
1062
+ /* @__PURE__ */ jsxs("linearGradient", {
1063
+ id: shineId,
1064
+ x1: "0",
1065
+ y1: "0",
1066
+ x2: "1",
1067
+ y2: "0",
1068
+ children: [
1069
+ /* @__PURE__ */ jsx("stop", {
1070
+ offset: "0%",
1071
+ stopColor: color,
1072
+ stopOpacity: "0"
1073
+ }),
1074
+ /* @__PURE__ */ jsx("stop", {
1075
+ offset: "50%",
1076
+ stopColor: color,
1077
+ stopOpacity: shineOpacity
1078
+ }),
1079
+ /* @__PURE__ */ jsx("stop", {
1080
+ offset: "100%",
1081
+ stopColor: color,
1082
+ stopOpacity: "0"
1083
+ })
1084
+ ]
1085
+ }),
1086
+ /* @__PURE__ */ jsx("clipPath", {
1087
+ id: clipId,
1088
+ children: isBar ? bars.map((b, i) => /* @__PURE__ */ jsx("rect", {
1089
+ x: b.x,
1090
+ y: b.y,
1091
+ width: b.w,
1092
+ height: b.h
1093
+ }, i)) : /* @__PURE__ */ jsx("path", { d: areaD })
1094
+ })
1095
+ ] }),
1096
+ isBar ? bars.map((b, i) => /* @__PURE__ */ jsx("rect", {
1097
+ x: b.x,
1098
+ y: b.y,
1099
+ width: b.w,
1100
+ height: b.h,
1101
+ fill: color,
1102
+ fillOpacity: barFillOpacity,
1103
+ stroke: "none"
1104
+ }, i)) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("path", {
1105
+ d: areaD,
1106
+ fill: `url(#${fillId})`,
1107
+ stroke: "none"
1108
+ }), /* @__PURE__ */ jsx("path", {
1109
+ d: lineD,
1110
+ fill: "none",
1111
+ stroke: color,
1112
+ strokeOpacity,
1113
+ strokeWidth: "1",
1114
+ vectorEffect: "non-scaling-stroke"
1115
+ })] }),
1116
+ /* @__PURE__ */ jsx("g", {
1117
+ clipPath: `url(#${clipId})`,
1118
+ children: /* @__PURE__ */ jsx("rect", {
1119
+ className: "kumo-chart-shimmer",
1120
+ x: "0",
1121
+ y: "0",
1122
+ width: CHART_LOADER_WIDTH,
1123
+ height,
1124
+ fill: `url(#${shineId})`
1125
+ })
1126
+ })
1127
+ ]
1128
+ })
1129
+ });
1130
+ }
1131
+ /**
1132
+ * Returns an `rgba(r, g, b, alpha)` string for any hex or rgb(a) color input,
1133
+ * replacing whatever opacity was already present with the given `alpha` (0–1).
1134
+ *
1135
+ * Handles:
1136
+ * - 6-digit hex: `#RRGGBB`
1137
+ * - 8-digit hex: `#RRGGBBAA` ← strips existing alpha
1138
+ * - 3-digit hex: `#RGB`
1139
+ * - `rgb(r, g, b)`
1140
+ * - `rgba(r, g, b, a)` ← replaces existing alpha
1141
+ */
1142
+ function colorWithOpacity(color, alpha) {
1143
+ const a = Math.max(0, Math.min(1, alpha));
1144
+ const rgbMatch = color.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/i);
1145
+ if (rgbMatch) return `rgba(${rgbMatch[1]}, ${rgbMatch[2]}, ${rgbMatch[3]}, ${a})`;
1146
+ let hex = color.replace(/^#/, "");
1147
+ if (hex.length === 3) hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
1148
+ if (hex.length === 8) hex = hex.slice(0, 6);
1149
+ return `rgba(${parseInt(hex.slice(0, 2), 16)}, ${parseInt(hex.slice(2, 4), 16)}, ${parseInt(hex.slice(4, 6), 16)}, ${a})`;
1150
+ }
1151
+ const tooltipDateFormat = new Intl.DateTimeFormat(void 0, {
1152
+ month: "short",
1153
+ day: "numeric",
1154
+ hour: "2-digit",
1155
+ minute: "2-digit",
1156
+ second: "2-digit",
1157
+ hour12: false
1158
+ });
1159
+ /**
1160
+ * Formats a Unix timestamp in milliseconds using the browser's locale and time zone.
1161
+ */
1162
+ function formatDefaultTimestamp(timestamp) {
1163
+ return tooltipDateFormat.format(timestamp);
1164
+ }
1165
+ //#endregion
1166
+ //#region src/components/chart/Legend.tsx
1167
+ const onInteractiveKeyDown = (event) => {
1168
+ if (event.key !== "Enter" && event.key !== " ") return;
1169
+ event.preventDefault();
1170
+ event.currentTarget.click();
1171
+ };
1172
+ /**
1173
+ * Large legend item — stacked layout with a colored dot + series name on top
1174
+ * and a large value with an optional small unit below. Use for prominent
1175
+ * single-metric displays such as dashboard cards.
1176
+ */
1177
+ function LargeItem({ color, value, name, unit, inactive, loading, onPointerEnter, onPointerLeave, onClick, className }) {
1178
+ if (loading) return /* @__PURE__ */ jsxs("div", {
1179
+ "aria-hidden": "true",
1180
+ className: cn("inline-flex min-w-42 flex-col gap-2 py-2", className),
1181
+ children: [/* @__PURE__ */ jsxs("div", {
1182
+ className: "flex items-center gap-2",
1183
+ children: [/* @__PURE__ */ jsx("span", { className: "inline-block size-2 rounded-full bg-kumo-fill" }), /* @__PURE__ */ jsx(SkeletonLine, { className: "h-3 w-[8ch]" })]
1184
+ }), /* @__PURE__ */ jsx(SkeletonLine, { className: "h-5 w-[5ch]" })]
1185
+ });
1186
+ return /* @__PURE__ */ jsxs("div", {
1187
+ role: "button",
1188
+ tabIndex: onClick ? 0 : -1,
1189
+ className: cn("inline-flex min-w-42 flex-col gap-2 py-2", { "cursor-pointer": !!onClick }, className),
1190
+ onPointerEnter,
1191
+ onPointerLeave,
1192
+ onClick,
1193
+ onKeyDown: onClick ? onInteractiveKeyDown : void 0,
1194
+ children: [/* @__PURE__ */ jsxs("div", {
1195
+ className: "flex items-center gap-2",
1196
+ children: [/* @__PURE__ */ jsx("span", {
1197
+ className: cn("inline-block size-2 rounded-full", { "opacity-50": inactive }),
1198
+ style: { backgroundColor: color }
1199
+ }), /* @__PURE__ */ jsx("span", {
1200
+ className: cn("text-xs", { "opacity-50": inactive }),
1201
+ children: name
1202
+ })]
1203
+ }), /* @__PURE__ */ jsxs("div", {
1204
+ className: "flex items-baseline gap-0.5",
1205
+ children: [/* @__PURE__ */ jsx("span", {
1206
+ className: cn("text-lg leading-none font-medium", { "opacity-50": inactive }),
1207
+ children: value
1208
+ }), unit && /* @__PURE__ */ jsx("span", {
1209
+ className: cn("text-xs leading-none text-kumo-subtle", { "opacity-50": inactive }),
1210
+ children: unit
1211
+ })]
1212
+ })]
1213
+ });
1214
+ }
1215
+ /**
1216
+ * Small legend item — inline layout with a colored dot, series name, and value
1217
+ * on a single row. Use for compact legends below or beside a chart.
1218
+ */
1219
+ function SmallItem({ color, value, name, inactive, loading, onPointerEnter, onPointerLeave, onClick, className }) {
1220
+ if (loading) return /* @__PURE__ */ jsxs("div", {
1221
+ "aria-hidden": "true",
1222
+ className: cn("inline-flex h-4 items-center gap-2", className),
1223
+ children: [
1224
+ /* @__PURE__ */ jsx("span", { className: "inline-block size-2 rounded-full bg-kumo-fill" }),
1225
+ /* @__PURE__ */ jsx(SkeletonLine, { className: "h-3 w-[5ch]" }),
1226
+ /* @__PURE__ */ jsx(SkeletonLine, { className: "h-3 w-[3ch]" })
1227
+ ]
1228
+ });
1229
+ return /* @__PURE__ */ jsxs("div", {
1230
+ role: "button",
1231
+ tabIndex: onClick ? 0 : -1,
1232
+ className: cn("inline-flex h-4 items-center gap-2", { "cursor-pointer": !!onClick }, className),
1233
+ onPointerEnter,
1234
+ onPointerLeave,
1235
+ onClick,
1236
+ onKeyDown: onClick ? onInteractiveKeyDown : void 0,
1237
+ children: [
1238
+ /* @__PURE__ */ jsx("span", {
1239
+ className: cn("inline-block size-2 rounded-full", { "opacity-50": inactive }),
1240
+ style: { backgroundColor: color }
1241
+ }),
1242
+ /* @__PURE__ */ jsx("span", {
1243
+ className: cn("text-xs", { "opacity-50": inactive }),
1244
+ children: name
1245
+ }),
1246
+ /* @__PURE__ */ jsx("span", {
1247
+ className: cn("text-xs font-medium", { "opacity-50": inactive }),
1248
+ children: value
1249
+ })
1250
+ ]
1251
+ });
1252
+ }
1253
+ /**
1254
+ * ChartLegend — pre-built legend item components for use alongside a chart.
1255
+ *
1256
+ * - `ChartLegend.SmallItem` — compact inline layout; suited for multi-series legends
1257
+ * - `ChartLegend.LargeItem` — stacked layout with a large value; suited for single-metric cards
1258
+ *
1259
+ * @example
1260
+ * ```tsx
1261
+ * <ChartLegend.SmallItem name="Requests" color="#086FFF" value="1,234" />
1262
+ * <ChartLegend.LargeItem name="Latency" color="#CF7EE9" value="42" unit="ms" inactive />
1263
+ *
1264
+ * // While data is loading, render skeleton placeholders:
1265
+ * <ChartLegend.SmallItem loading />
1266
+ * ```
1267
+ */
1268
+ const ChartLegend = {
1269
+ SmallItem,
1270
+ LargeItem
1271
+ };
1272
+ //#endregion
1273
+ //#region src/components/chart/tooltip-utils.ts
1274
+ const defaultValueFormat = (value) => value.toLocaleString();
1275
+ /** Escape HTML special characters to prevent XSS in default tooltips. */
1276
+ const escapeHtml = (str) => str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
1277
+ //#endregion
1278
+ //#region src/components/chart/SankeyChart.tsx
1279
+ function isTooltipParams(params) {
1280
+ return typeof params === "object" && params !== null;
1281
+ }
1282
+ /**
1283
+ * Escape ECharts rich text metacharacters to prevent formatting issues.
1284
+ * Rich text syntax uses {styleName|text}, so | and } must be escaped.
1285
+ */
1286
+ const escapeRichText = (str) => str.replace(/[{}|]/g, (char) => `\\${char}`);
1287
+ /**
1288
+ * Sanitize a CSS color value to prevent injection attacks.
1289
+ * Only allows valid hex colors, rgb/rgba, hsl/hsla, and named colors.
1290
+ */
1291
+ const sanitizeColor = (color) => {
1292
+ const fallback = "#666";
1293
+ if (!color || typeof color !== "string") return fallback;
1294
+ if (/^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(color)) return color;
1295
+ if (/^rgba?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*(?:,\s*[\d.]+\s*)?\)$/i.test(color)) return color;
1296
+ if (/^hsla?\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*(?:,\s*[\d.]+\s*)?\)$/i.test(color)) return color;
1297
+ if (/^[a-z]{3,20}$/i.test(color)) return color;
1298
+ return fallback;
1299
+ };
1300
+ function SankeyChart({ echarts, nodes, links, height = 400, nodeWidth = 8, nodePadding = 10, showTooltip: enableTooltip = true, showNodeValues, nodeLabelLayout = "stacked", formatValue = defaultValueFormat, tooltipFormatter, defaultNodeColor, left, right, linkColor = "gradient", linkOpacity = .5, className, isDarkMode, onNodeClick, onLinkClick }) {
1301
+ const hasNodeValues = nodes.some((n) => n.value !== void 0);
1302
+ const shouldShowValues = showNodeValues ?? hasNodeValues;
1303
+ const isInlineLayout = nodeLabelLayout === "inline";
1304
+ const options = useMemo(() => {
1305
+ const labelColor = ChartPalette.text("primary", isDarkMode);
1306
+ const secondaryColor = ChartPalette.text("secondary", isDarkMode);
1307
+ const nodeColors = nodes.map((node, index) => node.color ?? defaultNodeColor ?? ChartPalette.categorical(index, isDarkMode));
1308
+ const nodeDataMap = new Map(nodes.map((n, i) => [n.name, {
1309
+ ...n,
1310
+ computedColor: nodeColors[i]
1311
+ }]));
1312
+ const echartsNodes = nodes.map((node, index) => ({
1313
+ name: node.name,
1314
+ value: node.value,
1315
+ itemStyle: { color: nodeColors[index] }
1316
+ }));
1317
+ const echartsLinks = links.map((link) => ({
1318
+ source: nodes[link.source]?.name ?? "",
1319
+ target: nodes[link.target]?.name ?? "",
1320
+ value: link.value
1321
+ }));
1322
+ return {
1323
+ backgroundColor: "transparent",
1324
+ animation: true,
1325
+ animationDuration: 500,
1326
+ animationDurationUpdate: 300,
1327
+ animationEasingUpdate: "cubicInOut",
1328
+ tooltip: enableTooltip ? {
1329
+ trigger: "item",
1330
+ triggerOn: "mousemove",
1331
+ dangerousHtmlFormatter: (params) => {
1332
+ if (!isTooltipParams(params)) return "";
1333
+ if (params.dataType === "node" && params.name) {
1334
+ const nodeData = nodeDataMap.get(params.name);
1335
+ const color = sanitizeColor(nodeData?.computedColor ?? params.color ?? "#666");
1336
+ if (tooltipFormatter) return tooltipFormatter({
1337
+ type: "node",
1338
+ name: params.name,
1339
+ node: nodeData,
1340
+ color
1341
+ });
1342
+ return `<div style="display:flex;align-items:center;gap:6px;"><span style="display:inline-block;width:10px;height:10px;border-radius:50%;background:${color}"></span><strong>${escapeHtml(params.name)}</strong></div>`;
1343
+ }
1344
+ if (params.dataType === "edge" && params.data) {
1345
+ const { source, target, value } = params.data;
1346
+ if (tooltipFormatter) return tooltipFormatter({
1347
+ type: "link",
1348
+ name: `${source} → ${target}`,
1349
+ link: {
1350
+ source: source ?? "",
1351
+ target: target ?? "",
1352
+ value: value ?? 0
1353
+ }
1354
+ });
1355
+ const sourceNode = nodeDataMap.get(source ?? "");
1356
+ const targetNode = nodeDataMap.get(target ?? "");
1357
+ const sourceColor = sanitizeColor(sourceNode?.computedColor ?? "#666");
1358
+ const targetColor = sanitizeColor(targetNode?.computedColor ?? "#666");
1359
+ const safeSource = escapeHtml(source ?? "");
1360
+ const safeTarget = escapeHtml(target ?? "");
1361
+ return `<div style="display:flex;align-items:center;gap:6px;margin-bottom:4px;">
1362
+ <span style="display:inline-block;width:10px;height:10px;border-radius:50%;background:${sourceColor}"></span>
1363
+ <strong>${safeSource}</strong>
1364
+ <span style="color:${secondaryColor}">→</span>
1365
+ <span style="display:inline-block;width:10px;height:10px;border-radius:50%;background:${targetColor}"></span>
1366
+ <strong>${safeTarget}</strong>
1367
+ </div>
1368
+ <strong>${value !== void 0 ? escapeHtml(formatValue(value)) : ""}</strong>`;
1369
+ }
1370
+ return "";
1371
+ }
1372
+ } : void 0,
1373
+ series: [{
1374
+ type: "sankey",
1375
+ ...left !== void 0 && { left },
1376
+ ...right !== void 0 && { right },
1377
+ data: echartsNodes,
1378
+ links: echartsLinks,
1379
+ draggable: false,
1380
+ emphasis: { focus: "adjacency" },
1381
+ nodeWidth,
1382
+ nodeGap: nodePadding,
1383
+ lineStyle: {
1384
+ color: linkColor === "gradient" ? "source" : "#d1d5db",
1385
+ opacity: linkColor === "gradient" ? linkOpacity : .4,
1386
+ curveness: .5
1387
+ },
1388
+ label: {
1389
+ show: true,
1390
+ color: labelColor,
1391
+ fontSize: 12,
1392
+ formatter: shouldShowValues ? (params) => {
1393
+ const name = params.name ?? "";
1394
+ const nodeData = nodeDataMap.get(name);
1395
+ const safeName = escapeRichText(name);
1396
+ if (nodeData?.value !== void 0) {
1397
+ const formattedValue = escapeRichText(formatValue(nodeData.value));
1398
+ return isInlineLayout ? `{name|${safeName}} {value|${formattedValue}}` : `{value|${formattedValue}}\n{name|${safeName}}`;
1399
+ }
1400
+ return safeName;
1401
+ } : void 0,
1402
+ rich: shouldShowValues ? {
1403
+ value: {
1404
+ fontSize: 11,
1405
+ color: labelColor,
1406
+ lineHeight: isInlineLayout ? void 0 : 16
1407
+ },
1408
+ name: {
1409
+ fontSize: 12,
1410
+ color: labelColor,
1411
+ fontWeight: 700
1412
+ }
1413
+ } : void 0
1414
+ }
1415
+ }]
1416
+ };
1417
+ }, [
1418
+ nodes,
1419
+ links,
1420
+ enableTooltip,
1421
+ nodeWidth,
1422
+ nodePadding,
1423
+ defaultNodeColor,
1424
+ left,
1425
+ right,
1426
+ isDarkMode,
1427
+ linkColor,
1428
+ linkOpacity,
1429
+ shouldShowValues,
1430
+ isInlineLayout,
1431
+ formatValue,
1432
+ tooltipFormatter
1433
+ ]);
1434
+ const handleClick = useCallback((params) => {
1435
+ if (params.dataType === "node" && onNodeClick && params.name) {
1436
+ const nodeIndex = nodes.findIndex((n) => n.name === params.name);
1437
+ onNodeClick({
1438
+ ...nodeIndex >= 0 ? nodes[nodeIndex] : null,
1439
+ name: params.name
1440
+ });
1441
+ } else if (params.dataType === "edge" && onLinkClick && params.data) {
1442
+ const data = params.data;
1443
+ const source = typeof data === "object" && data !== null && "source" in data ? String(data.source) : "";
1444
+ const target = typeof data === "object" && data !== null && "target" in data ? String(data.target) : "";
1445
+ const sourceIndex = nodes.findIndex((n) => n.name === source);
1446
+ const targetIndex = nodes.findIndex((n) => n.name === target);
1447
+ if (sourceIndex === -1 || targetIndex === -1) return;
1448
+ const rawValue = params.value;
1449
+ const value = typeof rawValue === "number" ? rawValue : Array.isArray(rawValue) && typeof rawValue[0] === "number" ? rawValue[0] : 0;
1450
+ onLinkClick({
1451
+ ...links.find((l) => l.source === sourceIndex && l.target === targetIndex),
1452
+ source: sourceIndex,
1453
+ target: targetIndex,
1454
+ value
1455
+ });
1456
+ }
1457
+ }, [
1458
+ nodes,
1459
+ links,
1460
+ onNodeClick,
1461
+ onLinkClick
1462
+ ]);
1463
+ const onEvents = useMemo(() => ({ click: handleClick }), [handleClick]);
1464
+ return /* @__PURE__ */ jsx(Chart, {
1465
+ echarts,
1466
+ options,
1467
+ className,
1468
+ isDarkMode,
1469
+ height,
1470
+ onEvents
1471
+ });
1472
+ }
1473
+ SankeyChart.displayName = "SankeyChart";
1474
+ //#endregion
1475
+ //#region ../../node_modules/.pnpm/d3-array@3.2.4/node_modules/d3-array/src/fsum.js
1476
+ var Adder = class {
1477
+ constructor() {
1478
+ this._partials = /* @__PURE__ */ new Float64Array(32);
1479
+ this._n = 0;
1480
+ }
1481
+ add(x) {
1482
+ const p = this._partials;
1483
+ let i = 0;
1484
+ for (let j = 0; j < this._n && j < 32; j++) {
1485
+ const y = p[j], hi = x + y, lo = Math.abs(x) < Math.abs(y) ? x - (hi - y) : y - (hi - x);
1486
+ if (lo) p[i++] = lo;
1487
+ x = hi;
1488
+ }
1489
+ p[i] = x;
1490
+ this._n = i + 1;
1491
+ return this;
1492
+ }
1493
+ valueOf() {
1494
+ const p = this._partials;
1495
+ let n = this._n, x, y, lo, hi = 0;
1496
+ if (n > 0) {
1497
+ hi = p[--n];
1498
+ while (n > 0) {
1499
+ x = hi;
1500
+ y = p[--n];
1501
+ hi = x + y;
1502
+ lo = y - (hi - x);
1503
+ if (lo) break;
1504
+ }
1505
+ if (n > 0 && (lo < 0 && p[n - 1] < 0 || lo > 0 && p[n - 1] > 0)) {
1506
+ y = lo * 2;
1507
+ x = hi + y;
1508
+ if (y == x - hi) hi = x;
1509
+ }
1510
+ }
1511
+ return hi;
1512
+ }
1513
+ };
1514
+ //#endregion
1515
+ //#region ../../node_modules/.pnpm/d3-array@3.2.4/node_modules/d3-array/src/merge.js
1516
+ function* flatten(arrays) {
1517
+ for (const array of arrays) yield* array;
1518
+ }
1519
+ function merge(arrays) {
1520
+ return Array.from(flatten(arrays));
1521
+ }
1522
+ //#endregion
1523
+ //#region ../../node_modules/.pnpm/d3-array@3.2.4/node_modules/d3-array/src/range.js
1524
+ function range(start, stop, step) {
1525
+ start = +start, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start, start = 0, 1) : n < 3 ? 1 : +step;
1526
+ var i = -1, n = Math.max(0, Math.ceil((stop - start) / step)) | 0, range = new Array(n);
1527
+ while (++i < n) range[i] = start + i * step;
1528
+ return range;
1529
+ }
1530
+ //#endregion
1531
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/math.js
1532
+ var epsilon = 1e-6;
1533
+ var pi = Math.PI;
1534
+ var halfPi = pi / 2;
1535
+ var quarterPi = pi / 4;
1536
+ var tau = pi * 2;
1537
+ var degrees = 180 / pi;
1538
+ var radians = pi / 180;
1539
+ var abs = Math.abs;
1540
+ var atan = Math.atan;
1541
+ var atan2 = Math.atan2;
1542
+ var cos = Math.cos;
1543
+ var ceil = Math.ceil;
1544
+ var exp = Math.exp;
1545
+ var log = Math.log;
1546
+ var sin = Math.sin;
1547
+ var sign = Math.sign || function(x) {
1548
+ return x > 0 ? 1 : x < 0 ? -1 : 0;
1549
+ };
1550
+ var sqrt = Math.sqrt;
1551
+ var tan = Math.tan;
1552
+ function acos(x) {
1553
+ return x > 1 ? 0 : x < -1 ? pi : Math.acos(x);
1554
+ }
1555
+ function asin(x) {
1556
+ return x > 1 ? halfPi : x < -1 ? -halfPi : Math.asin(x);
1557
+ }
1558
+ //#endregion
1559
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/noop.js
1560
+ function noop() {}
1561
+ //#endregion
1562
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/stream.js
1563
+ function streamGeometry(geometry, stream) {
1564
+ if (geometry && streamGeometryType.hasOwnProperty(geometry.type)) streamGeometryType[geometry.type](geometry, stream);
1565
+ }
1566
+ var streamObjectType = {
1567
+ Feature: function(object, stream) {
1568
+ streamGeometry(object.geometry, stream);
1569
+ },
1570
+ FeatureCollection: function(object, stream) {
1571
+ var features = object.features, i = -1, n = features.length;
1572
+ while (++i < n) streamGeometry(features[i].geometry, stream);
1573
+ }
1574
+ };
1575
+ var streamGeometryType = {
1576
+ Sphere: function(object, stream) {
1577
+ stream.sphere();
1578
+ },
1579
+ Point: function(object, stream) {
1580
+ object = object.coordinates;
1581
+ stream.point(object[0], object[1], object[2]);
1582
+ },
1583
+ MultiPoint: function(object, stream) {
1584
+ var coordinates = object.coordinates, i = -1, n = coordinates.length;
1585
+ while (++i < n) object = coordinates[i], stream.point(object[0], object[1], object[2]);
1586
+ },
1587
+ LineString: function(object, stream) {
1588
+ streamLine(object.coordinates, stream, 0);
1589
+ },
1590
+ MultiLineString: function(object, stream) {
1591
+ var coordinates = object.coordinates, i = -1, n = coordinates.length;
1592
+ while (++i < n) streamLine(coordinates[i], stream, 0);
1593
+ },
1594
+ Polygon: function(object, stream) {
1595
+ streamPolygon(object.coordinates, stream);
1596
+ },
1597
+ MultiPolygon: function(object, stream) {
1598
+ var coordinates = object.coordinates, i = -1, n = coordinates.length;
1599
+ while (++i < n) streamPolygon(coordinates[i], stream);
1600
+ },
1601
+ GeometryCollection: function(object, stream) {
1602
+ var geometries = object.geometries, i = -1, n = geometries.length;
1603
+ while (++i < n) streamGeometry(geometries[i], stream);
1604
+ }
1605
+ };
1606
+ function streamLine(coordinates, stream, closed) {
1607
+ var i = -1, n = coordinates.length - closed, coordinate;
1608
+ stream.lineStart();
1609
+ while (++i < n) coordinate = coordinates[i], stream.point(coordinate[0], coordinate[1], coordinate[2]);
1610
+ stream.lineEnd();
1611
+ }
1612
+ function streamPolygon(coordinates, stream) {
1613
+ var i = -1, n = coordinates.length;
1614
+ stream.polygonStart();
1615
+ while (++i < n) streamLine(coordinates[i], stream, 1);
1616
+ stream.polygonEnd();
1617
+ }
1618
+ function stream_default(object, stream) {
1619
+ if (object && streamObjectType.hasOwnProperty(object.type)) streamObjectType[object.type](object, stream);
1620
+ else streamGeometry(object, stream);
1621
+ }
1622
+ //#endregion
1623
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/cartesian.js
1624
+ function spherical(cartesian) {
1625
+ return [atan2(cartesian[1], cartesian[0]), asin(cartesian[2])];
1626
+ }
1627
+ function cartesian(spherical) {
1628
+ var lambda = spherical[0], phi = spherical[1], cosPhi = cos(phi);
1629
+ return [
1630
+ cosPhi * cos(lambda),
1631
+ cosPhi * sin(lambda),
1632
+ sin(phi)
1633
+ ];
1634
+ }
1635
+ function cartesianDot(a, b) {
1636
+ return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
1637
+ }
1638
+ function cartesianCross(a, b) {
1639
+ return [
1640
+ a[1] * b[2] - a[2] * b[1],
1641
+ a[2] * b[0] - a[0] * b[2],
1642
+ a[0] * b[1] - a[1] * b[0]
1643
+ ];
1644
+ }
1645
+ function cartesianAddInPlace(a, b) {
1646
+ a[0] += b[0], a[1] += b[1], a[2] += b[2];
1647
+ }
1648
+ function cartesianScale(vector, k) {
1649
+ return [
1650
+ vector[0] * k,
1651
+ vector[1] * k,
1652
+ vector[2] * k
1653
+ ];
1654
+ }
1655
+ function cartesianNormalizeInPlace(d) {
1656
+ var l = sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]);
1657
+ d[0] /= l, d[1] /= l, d[2] /= l;
1658
+ }
1659
+ //#endregion
1660
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/compose.js
1661
+ function compose_default(a, b) {
1662
+ function compose(x, y) {
1663
+ return x = a(x, y), b(x[0], x[1]);
1664
+ }
1665
+ if (a.invert && b.invert) compose.invert = function(x, y) {
1666
+ return x = b.invert(x, y), x && a.invert(x[0], x[1]);
1667
+ };
1668
+ return compose;
1669
+ }
1670
+ //#endregion
1671
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/rotation.js
1672
+ function rotationIdentity(lambda, phi) {
1673
+ if (abs(lambda) > pi) lambda -= Math.round(lambda / tau) * tau;
1674
+ return [lambda, phi];
1675
+ }
1676
+ rotationIdentity.invert = rotationIdentity;
1677
+ function rotateRadians(deltaLambda, deltaPhi, deltaGamma) {
1678
+ return (deltaLambda %= tau) ? deltaPhi || deltaGamma ? compose_default(rotationLambda(deltaLambda), rotationPhiGamma(deltaPhi, deltaGamma)) : rotationLambda(deltaLambda) : deltaPhi || deltaGamma ? rotationPhiGamma(deltaPhi, deltaGamma) : rotationIdentity;
1679
+ }
1680
+ function forwardRotationLambda(deltaLambda) {
1681
+ return function(lambda, phi) {
1682
+ lambda += deltaLambda;
1683
+ if (abs(lambda) > pi) lambda -= Math.round(lambda / tau) * tau;
1684
+ return [lambda, phi];
1685
+ };
1686
+ }
1687
+ function rotationLambda(deltaLambda) {
1688
+ var rotation = forwardRotationLambda(deltaLambda);
1689
+ rotation.invert = forwardRotationLambda(-deltaLambda);
1690
+ return rotation;
1691
+ }
1692
+ function rotationPhiGamma(deltaPhi, deltaGamma) {
1693
+ var cosDeltaPhi = cos(deltaPhi), sinDeltaPhi = sin(deltaPhi), cosDeltaGamma = cos(deltaGamma), sinDeltaGamma = sin(deltaGamma);
1694
+ function rotation(lambda, phi) {
1695
+ var cosPhi = cos(phi), x = cos(lambda) * cosPhi, y = sin(lambda) * cosPhi, z = sin(phi), k = z * cosDeltaPhi + x * sinDeltaPhi;
1696
+ return [atan2(y * cosDeltaGamma - k * sinDeltaGamma, x * cosDeltaPhi - z * sinDeltaPhi), asin(k * cosDeltaGamma + y * sinDeltaGamma)];
1697
+ }
1698
+ rotation.invert = function(lambda, phi) {
1699
+ var cosPhi = cos(phi), x = cos(lambda) * cosPhi, y = sin(lambda) * cosPhi, z = sin(phi), k = z * cosDeltaGamma - y * sinDeltaGamma;
1700
+ return [atan2(y * cosDeltaGamma + z * sinDeltaGamma, x * cosDeltaPhi + k * sinDeltaPhi), asin(k * cosDeltaPhi - x * sinDeltaPhi)];
1701
+ };
1702
+ return rotation;
1703
+ }
1704
+ function rotation_default(rotate) {
1705
+ rotate = rotateRadians(rotate[0] * radians, rotate[1] * radians, rotate.length > 2 ? rotate[2] * radians : 0);
1706
+ function forward(coordinates) {
1707
+ coordinates = rotate(coordinates[0] * radians, coordinates[1] * radians);
1708
+ return coordinates[0] *= degrees, coordinates[1] *= degrees, coordinates;
1709
+ }
1710
+ forward.invert = function(coordinates) {
1711
+ coordinates = rotate.invert(coordinates[0] * radians, coordinates[1] * radians);
1712
+ return coordinates[0] *= degrees, coordinates[1] *= degrees, coordinates;
1713
+ };
1714
+ return forward;
1715
+ }
1716
+ //#endregion
1717
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/circle.js
1718
+ function circleStream(stream, radius, delta, direction, t0, t1) {
1719
+ if (!delta) return;
1720
+ var cosRadius = cos(radius), sinRadius = sin(radius), step = direction * delta;
1721
+ if (t0 == null) {
1722
+ t0 = radius + direction * tau;
1723
+ t1 = radius - step / 2;
1724
+ } else {
1725
+ t0 = circleRadius(cosRadius, t0);
1726
+ t1 = circleRadius(cosRadius, t1);
1727
+ if (direction > 0 ? t0 < t1 : t0 > t1) t0 += direction * tau;
1728
+ }
1729
+ for (var point, t = t0; direction > 0 ? t > t1 : t < t1; t -= step) {
1730
+ point = spherical([
1731
+ cosRadius,
1732
+ -sinRadius * cos(t),
1733
+ -sinRadius * sin(t)
1734
+ ]);
1735
+ stream.point(point[0], point[1]);
1736
+ }
1737
+ }
1738
+ function circleRadius(cosRadius, point) {
1739
+ point = cartesian(point), point[0] -= cosRadius;
1740
+ cartesianNormalizeInPlace(point);
1741
+ var radius = acos(-point[1]);
1742
+ return ((-point[2] < 0 ? -radius : radius) + tau - epsilon) % tau;
1743
+ }
1744
+ //#endregion
1745
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/clip/buffer.js
1746
+ function buffer_default() {
1747
+ var lines = [], line;
1748
+ return {
1749
+ point: function(x, y, m) {
1750
+ line.push([
1751
+ x,
1752
+ y,
1753
+ m
1754
+ ]);
1755
+ },
1756
+ lineStart: function() {
1757
+ lines.push(line = []);
1758
+ },
1759
+ lineEnd: noop,
1760
+ rejoin: function() {
1761
+ if (lines.length > 1) lines.push(lines.pop().concat(lines.shift()));
1762
+ },
1763
+ result: function() {
1764
+ var result = lines;
1765
+ lines = [];
1766
+ line = null;
1767
+ return result;
1768
+ }
1769
+ };
1770
+ }
1771
+ //#endregion
1772
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/pointEqual.js
1773
+ function pointEqual_default(a, b) {
1774
+ return abs(a[0] - b[0]) < 1e-6 && abs(a[1] - b[1]) < 1e-6;
1775
+ }
1776
+ //#endregion
1777
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/clip/rejoin.js
1778
+ function Intersection(point, points, other, entry) {
1779
+ this.x = point;
1780
+ this.z = points;
1781
+ this.o = other;
1782
+ this.e = entry;
1783
+ this.v = false;
1784
+ this.n = this.p = null;
1785
+ }
1786
+ function rejoin_default(segments, compareIntersection, startInside, interpolate, stream) {
1787
+ var subject = [], clip = [], i, n;
1788
+ segments.forEach(function(segment) {
1789
+ if ((n = segment.length - 1) <= 0) return;
1790
+ var n, p0 = segment[0], p1 = segment[n], x;
1791
+ if (pointEqual_default(p0, p1)) {
1792
+ if (!p0[2] && !p1[2]) {
1793
+ stream.lineStart();
1794
+ for (i = 0; i < n; ++i) stream.point((p0 = segment[i])[0], p0[1]);
1795
+ stream.lineEnd();
1796
+ return;
1797
+ }
1798
+ p1[0] += 2 * epsilon;
1799
+ }
1800
+ subject.push(x = new Intersection(p0, segment, null, true));
1801
+ clip.push(x.o = new Intersection(p0, null, x, false));
1802
+ subject.push(x = new Intersection(p1, segment, null, false));
1803
+ clip.push(x.o = new Intersection(p1, null, x, true));
1804
+ });
1805
+ if (!subject.length) return;
1806
+ clip.sort(compareIntersection);
1807
+ link(subject);
1808
+ link(clip);
1809
+ for (i = 0, n = clip.length; i < n; ++i) clip[i].e = startInside = !startInside;
1810
+ var start = subject[0], points, point;
1811
+ while (1) {
1812
+ var current = start, isSubject = true;
1813
+ while (current.v) if ((current = current.n) === start) return;
1814
+ points = current.z;
1815
+ stream.lineStart();
1816
+ do {
1817
+ current.v = current.o.v = true;
1818
+ if (current.e) {
1819
+ if (isSubject) for (i = 0, n = points.length; i < n; ++i) stream.point((point = points[i])[0], point[1]);
1820
+ else interpolate(current.x, current.n.x, 1, stream);
1821
+ current = current.n;
1822
+ } else {
1823
+ if (isSubject) {
1824
+ points = current.p.z;
1825
+ for (i = points.length - 1; i >= 0; --i) stream.point((point = points[i])[0], point[1]);
1826
+ } else interpolate(current.x, current.p.x, -1, stream);
1827
+ current = current.p;
1828
+ }
1829
+ current = current.o;
1830
+ points = current.z;
1831
+ isSubject = !isSubject;
1832
+ } while (!current.v);
1833
+ stream.lineEnd();
1834
+ }
1835
+ }
1836
+ function link(array) {
1837
+ if (!(n = array.length)) return;
1838
+ var n, i = 0, a = array[0], b;
1839
+ while (++i < n) {
1840
+ a.n = b = array[i];
1841
+ b.p = a;
1842
+ a = b;
1843
+ }
1844
+ a.n = b = array[0];
1845
+ b.p = a;
1846
+ }
1847
+ //#endregion
1848
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/polygonContains.js
1849
+ function longitude(point) {
1850
+ return abs(point[0]) <= pi ? point[0] : sign(point[0]) * ((abs(point[0]) + pi) % tau - pi);
1851
+ }
1852
+ function polygonContains_default(polygon, point) {
1853
+ var lambda = longitude(point), phi = point[1], sinPhi = sin(phi), normal = [
1854
+ sin(lambda),
1855
+ -cos(lambda),
1856
+ 0
1857
+ ], angle = 0, winding = 0;
1858
+ var sum = new Adder();
1859
+ if (sinPhi === 1) phi = halfPi + epsilon;
1860
+ else if (sinPhi === -1) phi = -halfPi - epsilon;
1861
+ for (var i = 0, n = polygon.length; i < n; ++i) {
1862
+ if (!(m = (ring = polygon[i]).length)) continue;
1863
+ var ring, m, point0 = ring[m - 1], lambda0 = longitude(point0), phi0 = point0[1] / 2 + quarterPi, sinPhi0 = sin(phi0), cosPhi0 = cos(phi0);
1864
+ for (var j = 0; j < m; ++j, lambda0 = lambda1, sinPhi0 = sinPhi1, cosPhi0 = cosPhi1, point0 = point1) {
1865
+ var point1 = ring[j], lambda1 = longitude(point1), phi1 = point1[1] / 2 + quarterPi, sinPhi1 = sin(phi1), cosPhi1 = cos(phi1), delta = lambda1 - lambda0, sign = delta >= 0 ? 1 : -1, absDelta = sign * delta, antimeridian = absDelta > pi, k = sinPhi0 * sinPhi1;
1866
+ sum.add(atan2(k * sign * sin(absDelta), cosPhi0 * cosPhi1 + k * cos(absDelta)));
1867
+ angle += antimeridian ? delta + sign * tau : delta;
1868
+ if (antimeridian ^ lambda0 >= lambda ^ lambda1 >= lambda) {
1869
+ var arc = cartesianCross(cartesian(point0), cartesian(point1));
1870
+ cartesianNormalizeInPlace(arc);
1871
+ var intersection = cartesianCross(normal, arc);
1872
+ cartesianNormalizeInPlace(intersection);
1873
+ var phiArc = (antimeridian ^ delta >= 0 ? -1 : 1) * asin(intersection[2]);
1874
+ if (phi > phiArc || phi === phiArc && (arc[0] || arc[1])) winding += antimeridian ^ delta >= 0 ? 1 : -1;
1875
+ }
1876
+ }
1877
+ }
1878
+ return (angle < -1e-6 || angle < 1e-6 && sum < -1e-12) ^ winding & 1;
1879
+ }
1880
+ //#endregion
1881
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/clip/index.js
1882
+ function clip_default(pointVisible, clipLine, interpolate, start) {
1883
+ return function(sink) {
1884
+ var line = clipLine(sink), ringBuffer = buffer_default(), ringSink = clipLine(ringBuffer), polygonStarted = false, polygon, segments, ring;
1885
+ var clip = {
1886
+ point,
1887
+ lineStart,
1888
+ lineEnd,
1889
+ polygonStart: function() {
1890
+ clip.point = pointRing;
1891
+ clip.lineStart = ringStart;
1892
+ clip.lineEnd = ringEnd;
1893
+ segments = [];
1894
+ polygon = [];
1895
+ },
1896
+ polygonEnd: function() {
1897
+ clip.point = point;
1898
+ clip.lineStart = lineStart;
1899
+ clip.lineEnd = lineEnd;
1900
+ segments = merge(segments);
1901
+ var startInside = polygonContains_default(polygon, start);
1902
+ if (segments.length) {
1903
+ if (!polygonStarted) sink.polygonStart(), polygonStarted = true;
1904
+ rejoin_default(segments, compareIntersection, startInside, interpolate, sink);
1905
+ } else if (startInside) {
1906
+ if (!polygonStarted) sink.polygonStart(), polygonStarted = true;
1907
+ sink.lineStart();
1908
+ interpolate(null, null, 1, sink);
1909
+ sink.lineEnd();
1910
+ }
1911
+ if (polygonStarted) sink.polygonEnd(), polygonStarted = false;
1912
+ segments = polygon = null;
1913
+ },
1914
+ sphere: function() {
1915
+ sink.polygonStart();
1916
+ sink.lineStart();
1917
+ interpolate(null, null, 1, sink);
1918
+ sink.lineEnd();
1919
+ sink.polygonEnd();
1920
+ }
1921
+ };
1922
+ function point(lambda, phi) {
1923
+ if (pointVisible(lambda, phi)) sink.point(lambda, phi);
1924
+ }
1925
+ function pointLine(lambda, phi) {
1926
+ line.point(lambda, phi);
1927
+ }
1928
+ function lineStart() {
1929
+ clip.point = pointLine;
1930
+ line.lineStart();
1931
+ }
1932
+ function lineEnd() {
1933
+ clip.point = point;
1934
+ line.lineEnd();
1935
+ }
1936
+ function pointRing(lambda, phi) {
1937
+ ring.push([lambda, phi]);
1938
+ ringSink.point(lambda, phi);
1939
+ }
1940
+ function ringStart() {
1941
+ ringSink.lineStart();
1942
+ ring = [];
1943
+ }
1944
+ function ringEnd() {
1945
+ pointRing(ring[0][0], ring[0][1]);
1946
+ ringSink.lineEnd();
1947
+ var clean = ringSink.clean(), ringSegments = ringBuffer.result(), i, n = ringSegments.length, m, segment, point;
1948
+ ring.pop();
1949
+ polygon.push(ring);
1950
+ ring = null;
1951
+ if (!n) return;
1952
+ if (clean & 1) {
1953
+ segment = ringSegments[0];
1954
+ if ((m = segment.length - 1) > 0) {
1955
+ if (!polygonStarted) sink.polygonStart(), polygonStarted = true;
1956
+ sink.lineStart();
1957
+ for (i = 0; i < m; ++i) sink.point((point = segment[i])[0], point[1]);
1958
+ sink.lineEnd();
1959
+ }
1960
+ return;
1961
+ }
1962
+ if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift()));
1963
+ segments.push(ringSegments.filter(validSegment));
1964
+ }
1965
+ return clip;
1966
+ };
1967
+ }
1968
+ function validSegment(segment) {
1969
+ return segment.length > 1;
1970
+ }
1971
+ function compareIntersection(a, b) {
1972
+ return ((a = a.x)[0] < 0 ? a[1] - halfPi - epsilon : halfPi - a[1]) - ((b = b.x)[0] < 0 ? b[1] - halfPi - epsilon : halfPi - b[1]);
1973
+ }
1974
+ //#endregion
1975
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/clip/antimeridian.js
1976
+ var antimeridian_default = clip_default(function() {
1977
+ return true;
1978
+ }, clipAntimeridianLine, clipAntimeridianInterpolate, [-pi, -halfPi]);
1979
+ function clipAntimeridianLine(stream) {
1980
+ var lambda0 = NaN, phi0 = NaN, sign0 = NaN, clean;
1981
+ return {
1982
+ lineStart: function() {
1983
+ stream.lineStart();
1984
+ clean = 1;
1985
+ },
1986
+ point: function(lambda1, phi1) {
1987
+ var sign1 = lambda1 > 0 ? pi : -pi, delta = abs(lambda1 - lambda0);
1988
+ if (abs(delta - pi) < 1e-6) {
1989
+ stream.point(lambda0, phi0 = (phi0 + phi1) / 2 > 0 ? halfPi : -halfPi);
1990
+ stream.point(sign0, phi0);
1991
+ stream.lineEnd();
1992
+ stream.lineStart();
1993
+ stream.point(sign1, phi0);
1994
+ stream.point(lambda1, phi0);
1995
+ clean = 0;
1996
+ } else if (sign0 !== sign1 && delta >= pi) {
1997
+ if (abs(lambda0 - sign0) < 1e-6) lambda0 -= sign0 * epsilon;
1998
+ if (abs(lambda1 - sign1) < 1e-6) lambda1 -= sign1 * epsilon;
1999
+ phi0 = clipAntimeridianIntersect(lambda0, phi0, lambda1, phi1);
2000
+ stream.point(sign0, phi0);
2001
+ stream.lineEnd();
2002
+ stream.lineStart();
2003
+ stream.point(sign1, phi0);
2004
+ clean = 0;
2005
+ }
2006
+ stream.point(lambda0 = lambda1, phi0 = phi1);
2007
+ sign0 = sign1;
2008
+ },
2009
+ lineEnd: function() {
2010
+ stream.lineEnd();
2011
+ lambda0 = phi0 = NaN;
2012
+ },
2013
+ clean: function() {
2014
+ return 2 - clean;
2015
+ }
2016
+ };
2017
+ }
2018
+ function clipAntimeridianIntersect(lambda0, phi0, lambda1, phi1) {
2019
+ var cosPhi0, cosPhi1, sinLambda0Lambda1 = sin(lambda0 - lambda1);
2020
+ return abs(sinLambda0Lambda1) > 1e-6 ? atan((sin(phi0) * (cosPhi1 = cos(phi1)) * sin(lambda1) - sin(phi1) * (cosPhi0 = cos(phi0)) * sin(lambda0)) / (cosPhi0 * cosPhi1 * sinLambda0Lambda1)) : (phi0 + phi1) / 2;
2021
+ }
2022
+ function clipAntimeridianInterpolate(from, to, direction, stream) {
2023
+ var phi;
2024
+ if (from == null) {
2025
+ phi = direction * halfPi;
2026
+ stream.point(-pi, phi);
2027
+ stream.point(0, phi);
2028
+ stream.point(pi, phi);
2029
+ stream.point(pi, 0);
2030
+ stream.point(pi, -phi);
2031
+ stream.point(0, -phi);
2032
+ stream.point(-pi, -phi);
2033
+ stream.point(-pi, 0);
2034
+ stream.point(-pi, phi);
2035
+ } else if (abs(from[0] - to[0]) > 1e-6) {
2036
+ var lambda = from[0] < to[0] ? pi : -pi;
2037
+ phi = direction * lambda / 2;
2038
+ stream.point(-lambda, phi);
2039
+ stream.point(0, phi);
2040
+ stream.point(lambda, phi);
2041
+ } else stream.point(to[0], to[1]);
2042
+ }
2043
+ //#endregion
2044
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/clip/circle.js
2045
+ function circle_default(radius) {
2046
+ var cr = cos(radius), delta = 2 * radians, smallRadius = cr > 0, notHemisphere = abs(cr) > epsilon;
2047
+ function interpolate(from, to, direction, stream) {
2048
+ circleStream(stream, radius, delta, direction, from, to);
2049
+ }
2050
+ function visible(lambda, phi) {
2051
+ return cos(lambda) * cos(phi) > cr;
2052
+ }
2053
+ function clipLine(stream) {
2054
+ var point0, c0, v0, v00, clean;
2055
+ return {
2056
+ lineStart: function() {
2057
+ v00 = v0 = false;
2058
+ clean = 1;
2059
+ },
2060
+ point: function(lambda, phi) {
2061
+ var point1 = [lambda, phi], point2, v = visible(lambda, phi), c = smallRadius ? v ? 0 : code(lambda, phi) : v ? code(lambda + (lambda < 0 ? pi : -pi), phi) : 0;
2062
+ if (!point0 && (v00 = v0 = v)) stream.lineStart();
2063
+ if (v !== v0) {
2064
+ point2 = intersect(point0, point1);
2065
+ if (!point2 || pointEqual_default(point0, point2) || pointEqual_default(point1, point2)) point1[2] = 1;
2066
+ }
2067
+ if (v !== v0) {
2068
+ clean = 0;
2069
+ if (v) {
2070
+ stream.lineStart();
2071
+ point2 = intersect(point1, point0);
2072
+ stream.point(point2[0], point2[1]);
2073
+ } else {
2074
+ point2 = intersect(point0, point1);
2075
+ stream.point(point2[0], point2[1], 2);
2076
+ stream.lineEnd();
2077
+ }
2078
+ point0 = point2;
2079
+ } else if (notHemisphere && point0 && smallRadius ^ v) {
2080
+ var t;
2081
+ if (!(c & c0) && (t = intersect(point1, point0, true))) {
2082
+ clean = 0;
2083
+ if (smallRadius) {
2084
+ stream.lineStart();
2085
+ stream.point(t[0][0], t[0][1]);
2086
+ stream.point(t[1][0], t[1][1]);
2087
+ stream.lineEnd();
2088
+ } else {
2089
+ stream.point(t[1][0], t[1][1]);
2090
+ stream.lineEnd();
2091
+ stream.lineStart();
2092
+ stream.point(t[0][0], t[0][1], 3);
2093
+ }
2094
+ }
2095
+ }
2096
+ if (v && (!point0 || !pointEqual_default(point0, point1))) stream.point(point1[0], point1[1]);
2097
+ point0 = point1, v0 = v, c0 = c;
2098
+ },
2099
+ lineEnd: function() {
2100
+ if (v0) stream.lineEnd();
2101
+ point0 = null;
2102
+ },
2103
+ clean: function() {
2104
+ return clean | (v00 && v0) << 1;
2105
+ }
2106
+ };
2107
+ }
2108
+ function intersect(a, b, two) {
2109
+ var pa = cartesian(a), pb = cartesian(b);
2110
+ var n1 = [
2111
+ 1,
2112
+ 0,
2113
+ 0
2114
+ ], n2 = cartesianCross(pa, pb), n2n2 = cartesianDot(n2, n2), n1n2 = n2[0], determinant = n2n2 - n1n2 * n1n2;
2115
+ if (!determinant) return !two && a;
2116
+ var c1 = cr * n2n2 / determinant, c2 = -cr * n1n2 / determinant, n1xn2 = cartesianCross(n1, n2), A = cartesianScale(n1, c1);
2117
+ cartesianAddInPlace(A, cartesianScale(n2, c2));
2118
+ var u = n1xn2, w = cartesianDot(A, u), uu = cartesianDot(u, u), t2 = w * w - uu * (cartesianDot(A, A) - 1);
2119
+ if (t2 < 0) return;
2120
+ var t = sqrt(t2), q = cartesianScale(u, (-w - t) / uu);
2121
+ cartesianAddInPlace(q, A);
2122
+ q = spherical(q);
2123
+ if (!two) return q;
2124
+ var lambda0 = a[0], lambda1 = b[0], phi0 = a[1], phi1 = b[1], z;
2125
+ if (lambda1 < lambda0) z = lambda0, lambda0 = lambda1, lambda1 = z;
2126
+ var delta = lambda1 - lambda0, polar = abs(delta - pi) < epsilon, meridian = polar || delta < 1e-6;
2127
+ if (!polar && phi1 < phi0) z = phi0, phi0 = phi1, phi1 = z;
2128
+ if (meridian ? polar ? phi0 + phi1 > 0 ^ q[1] < (abs(q[0] - lambda0) < 1e-6 ? phi0 : phi1) : phi0 <= q[1] && q[1] <= phi1 : delta > pi ^ (lambda0 <= q[0] && q[0] <= lambda1)) {
2129
+ var q1 = cartesianScale(u, (-w + t) / uu);
2130
+ cartesianAddInPlace(q1, A);
2131
+ return [q, spherical(q1)];
2132
+ }
2133
+ }
2134
+ function code(lambda, phi) {
2135
+ var r = smallRadius ? radius : pi - radius, code = 0;
2136
+ if (lambda < -r) code |= 1;
2137
+ else if (lambda > r) code |= 2;
2138
+ if (phi < -r) code |= 4;
2139
+ else if (phi > r) code |= 8;
2140
+ return code;
2141
+ }
2142
+ return clip_default(visible, clipLine, interpolate, smallRadius ? [0, -radius] : [-pi, radius - pi]);
2143
+ }
2144
+ //#endregion
2145
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/clip/line.js
2146
+ function line_default(a, b, x0, y0, x1, y1) {
2147
+ var ax = a[0], ay = a[1], bx = b[0], by = b[1], t0 = 0, t1 = 1, dx = bx - ax, dy = by - ay, r = x0 - ax;
2148
+ if (!dx && r > 0) return;
2149
+ r /= dx;
2150
+ if (dx < 0) {
2151
+ if (r < t0) return;
2152
+ if (r < t1) t1 = r;
2153
+ } else if (dx > 0) {
2154
+ if (r > t1) return;
2155
+ if (r > t0) t0 = r;
2156
+ }
2157
+ r = x1 - ax;
2158
+ if (!dx && r < 0) return;
2159
+ r /= dx;
2160
+ if (dx < 0) {
2161
+ if (r > t1) return;
2162
+ if (r > t0) t0 = r;
2163
+ } else if (dx > 0) {
2164
+ if (r < t0) return;
2165
+ if (r < t1) t1 = r;
2166
+ }
2167
+ r = y0 - ay;
2168
+ if (!dy && r > 0) return;
2169
+ r /= dy;
2170
+ if (dy < 0) {
2171
+ if (r < t0) return;
2172
+ if (r < t1) t1 = r;
2173
+ } else if (dy > 0) {
2174
+ if (r > t1) return;
2175
+ if (r > t0) t0 = r;
2176
+ }
2177
+ r = y1 - ay;
2178
+ if (!dy && r < 0) return;
2179
+ r /= dy;
2180
+ if (dy < 0) {
2181
+ if (r > t1) return;
2182
+ if (r > t0) t0 = r;
2183
+ } else if (dy > 0) {
2184
+ if (r < t0) return;
2185
+ if (r < t1) t1 = r;
2186
+ }
2187
+ if (t0 > 0) a[0] = ax + t0 * dx, a[1] = ay + t0 * dy;
2188
+ if (t1 < 1) b[0] = ax + t1 * dx, b[1] = ay + t1 * dy;
2189
+ return true;
2190
+ }
2191
+ //#endregion
2192
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/clip/rectangle.js
2193
+ var clipMax = 1e9;
2194
+ var clipMin = -clipMax;
2195
+ function clipRectangle(x0, y0, x1, y1) {
2196
+ function visible(x, y) {
2197
+ return x0 <= x && x <= x1 && y0 <= y && y <= y1;
2198
+ }
2199
+ function interpolate(from, to, direction, stream) {
2200
+ var a = 0, a1 = 0;
2201
+ if (from == null || (a = corner(from, direction)) !== (a1 = corner(to, direction)) || comparePoint(from, to) < 0 ^ direction > 0) do
2202
+ stream.point(a === 0 || a === 3 ? x0 : x1, a > 1 ? y1 : y0);
2203
+ while ((a = (a + direction + 4) % 4) !== a1);
2204
+ else stream.point(to[0], to[1]);
2205
+ }
2206
+ function corner(p, direction) {
2207
+ return abs(p[0] - x0) < 1e-6 ? direction > 0 ? 0 : 3 : abs(p[0] - x1) < 1e-6 ? direction > 0 ? 2 : 1 : abs(p[1] - y0) < 1e-6 ? direction > 0 ? 1 : 0 : direction > 0 ? 3 : 2;
2208
+ }
2209
+ function compareIntersection(a, b) {
2210
+ return comparePoint(a.x, b.x);
2211
+ }
2212
+ function comparePoint(a, b) {
2213
+ var ca = corner(a, 1), cb = corner(b, 1);
2214
+ return ca !== cb ? ca - cb : ca === 0 ? b[1] - a[1] : ca === 1 ? a[0] - b[0] : ca === 2 ? a[1] - b[1] : b[0] - a[0];
2215
+ }
2216
+ return function(stream) {
2217
+ var activeStream = stream, bufferStream = buffer_default(), segments, polygon, ring, x__, y__, v__, x_, y_, v_, first, clean;
2218
+ var clipStream = {
2219
+ point,
2220
+ lineStart,
2221
+ lineEnd,
2222
+ polygonStart,
2223
+ polygonEnd
2224
+ };
2225
+ function point(x, y) {
2226
+ if (visible(x, y)) activeStream.point(x, y);
2227
+ }
2228
+ function polygonInside() {
2229
+ var winding = 0;
2230
+ for (var i = 0, n = polygon.length; i < n; ++i) for (var ring = polygon[i], j = 1, m = ring.length, point = ring[0], a0, a1, b0 = point[0], b1 = point[1]; j < m; ++j) {
2231
+ a0 = b0, a1 = b1, point = ring[j], b0 = point[0], b1 = point[1];
2232
+ if (a1 <= y1) {
2233
+ if (b1 > y1 && (b0 - a0) * (y1 - a1) > (b1 - a1) * (x0 - a0)) ++winding;
2234
+ } else if (b1 <= y1 && (b0 - a0) * (y1 - a1) < (b1 - a1) * (x0 - a0)) --winding;
2235
+ }
2236
+ return winding;
2237
+ }
2238
+ function polygonStart() {
2239
+ activeStream = bufferStream, segments = [], polygon = [], clean = true;
2240
+ }
2241
+ function polygonEnd() {
2242
+ var startInside = polygonInside(), cleanInside = clean && startInside, visible = (segments = merge(segments)).length;
2243
+ if (cleanInside || visible) {
2244
+ stream.polygonStart();
2245
+ if (cleanInside) {
2246
+ stream.lineStart();
2247
+ interpolate(null, null, 1, stream);
2248
+ stream.lineEnd();
2249
+ }
2250
+ if (visible) rejoin_default(segments, compareIntersection, startInside, interpolate, stream);
2251
+ stream.polygonEnd();
2252
+ }
2253
+ activeStream = stream, segments = polygon = ring = null;
2254
+ }
2255
+ function lineStart() {
2256
+ clipStream.point = linePoint;
2257
+ if (polygon) polygon.push(ring = []);
2258
+ first = true;
2259
+ v_ = false;
2260
+ x_ = y_ = NaN;
2261
+ }
2262
+ function lineEnd() {
2263
+ if (segments) {
2264
+ linePoint(x__, y__);
2265
+ if (v__ && v_) bufferStream.rejoin();
2266
+ segments.push(bufferStream.result());
2267
+ }
2268
+ clipStream.point = point;
2269
+ if (v_) activeStream.lineEnd();
2270
+ }
2271
+ function linePoint(x, y) {
2272
+ var v = visible(x, y);
2273
+ if (polygon) ring.push([x, y]);
2274
+ if (first) {
2275
+ x__ = x, y__ = y, v__ = v;
2276
+ first = false;
2277
+ if (v) {
2278
+ activeStream.lineStart();
2279
+ activeStream.point(x, y);
2280
+ }
2281
+ } else if (v && v_) activeStream.point(x, y);
2282
+ else {
2283
+ var a = [x_ = Math.max(clipMin, Math.min(clipMax, x_)), y_ = Math.max(clipMin, Math.min(clipMax, y_))], b = [x = Math.max(clipMin, Math.min(clipMax, x)), y = Math.max(clipMin, Math.min(clipMax, y))];
2284
+ if (line_default(a, b, x0, y0, x1, y1)) {
2285
+ if (!v_) {
2286
+ activeStream.lineStart();
2287
+ activeStream.point(a[0], a[1]);
2288
+ }
2289
+ activeStream.point(b[0], b[1]);
2290
+ if (!v) activeStream.lineEnd();
2291
+ clean = false;
2292
+ } else if (v) {
2293
+ activeStream.lineStart();
2294
+ activeStream.point(x, y);
2295
+ clean = false;
2296
+ }
2297
+ }
2298
+ x_ = x, y_ = y, v_ = v;
2299
+ }
2300
+ return clipStream;
2301
+ };
2302
+ }
2303
+ //#endregion
2304
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/length.js
2305
+ var lengthSum$1;
2306
+ var lambda0;
2307
+ var sinPhi0;
2308
+ var cosPhi0;
2309
+ var lengthStream$1 = {
2310
+ sphere: noop,
2311
+ point: noop,
2312
+ lineStart: lengthLineStart,
2313
+ lineEnd: noop,
2314
+ polygonStart: noop,
2315
+ polygonEnd: noop
2316
+ };
2317
+ function lengthLineStart() {
2318
+ lengthStream$1.point = lengthPointFirst$1;
2319
+ lengthStream$1.lineEnd = lengthLineEnd;
2320
+ }
2321
+ function lengthLineEnd() {
2322
+ lengthStream$1.point = lengthStream$1.lineEnd = noop;
2323
+ }
2324
+ function lengthPointFirst$1(lambda, phi) {
2325
+ lambda *= radians, phi *= radians;
2326
+ lambda0 = lambda, sinPhi0 = sin(phi), cosPhi0 = cos(phi);
2327
+ lengthStream$1.point = lengthPoint$1;
2328
+ }
2329
+ function lengthPoint$1(lambda, phi) {
2330
+ lambda *= radians, phi *= radians;
2331
+ var sinPhi = sin(phi), cosPhi = cos(phi), delta = abs(lambda - lambda0), cosDelta = cos(delta), x = cosPhi * sin(delta), y = cosPhi0 * sinPhi - sinPhi0 * cosPhi * cosDelta, z = sinPhi0 * sinPhi + cosPhi0 * cosPhi * cosDelta;
2332
+ lengthSum$1.add(atan2(sqrt(x * x + y * y), z));
2333
+ lambda0 = lambda, sinPhi0 = sinPhi, cosPhi0 = cosPhi;
2334
+ }
2335
+ function length_default(object) {
2336
+ lengthSum$1 = new Adder();
2337
+ stream_default(object, lengthStream$1);
2338
+ return +lengthSum$1;
2339
+ }
2340
+ //#endregion
2341
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/distance.js
2342
+ var coordinates = [null, null];
2343
+ var object = {
2344
+ type: "LineString",
2345
+ coordinates
2346
+ };
2347
+ function distance_default(a, b) {
2348
+ coordinates[0] = a;
2349
+ coordinates[1] = b;
2350
+ return length_default(object);
2351
+ }
2352
+ //#endregion
2353
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/graticule.js
2354
+ function graticuleX(y0, y1, dy) {
2355
+ var y = range(y0, y1 - epsilon, dy).concat(y1);
2356
+ return function(x) {
2357
+ return y.map(function(y) {
2358
+ return [x, y];
2359
+ });
2360
+ };
2361
+ }
2362
+ function graticuleY(x0, x1, dx) {
2363
+ var x = range(x0, x1 - epsilon, dx).concat(x1);
2364
+ return function(y) {
2365
+ return x.map(function(x) {
2366
+ return [x, y];
2367
+ });
2368
+ };
2369
+ }
2370
+ function graticule() {
2371
+ var x1, x0, X1, X0, y1, y0, Y1, Y0, dx = 10, dy = dx, DX = 90, DY = 360, x, y, X, Y, precision = 2.5;
2372
+ function graticule() {
2373
+ return {
2374
+ type: "MultiLineString",
2375
+ coordinates: lines()
2376
+ };
2377
+ }
2378
+ function lines() {
2379
+ return range(ceil(X0 / DX) * DX, X1, DX).map(X).concat(range(ceil(Y0 / DY) * DY, Y1, DY).map(Y)).concat(range(ceil(x0 / dx) * dx, x1, dx).filter(function(x) {
2380
+ return abs(x % DX) > epsilon;
2381
+ }).map(x)).concat(range(ceil(y0 / dy) * dy, y1, dy).filter(function(y) {
2382
+ return abs(y % DY) > epsilon;
2383
+ }).map(y));
2384
+ }
2385
+ graticule.lines = function() {
2386
+ return lines().map(function(coordinates) {
2387
+ return {
2388
+ type: "LineString",
2389
+ coordinates
2390
+ };
2391
+ });
2392
+ };
2393
+ graticule.outline = function() {
2394
+ return {
2395
+ type: "Polygon",
2396
+ coordinates: [X(X0).concat(Y(Y1).slice(1), X(X1).reverse().slice(1), Y(Y0).reverse().slice(1))]
2397
+ };
2398
+ };
2399
+ graticule.extent = function(_) {
2400
+ if (!arguments.length) return graticule.extentMinor();
2401
+ return graticule.extentMajor(_).extentMinor(_);
2402
+ };
2403
+ graticule.extentMajor = function(_) {
2404
+ if (!arguments.length) return [[X0, Y0], [X1, Y1]];
2405
+ X0 = +_[0][0], X1 = +_[1][0];
2406
+ Y0 = +_[0][1], Y1 = +_[1][1];
2407
+ if (X0 > X1) _ = X0, X0 = X1, X1 = _;
2408
+ if (Y0 > Y1) _ = Y0, Y0 = Y1, Y1 = _;
2409
+ return graticule.precision(precision);
2410
+ };
2411
+ graticule.extentMinor = function(_) {
2412
+ if (!arguments.length) return [[x0, y0], [x1, y1]];
2413
+ x0 = +_[0][0], x1 = +_[1][0];
2414
+ y0 = +_[0][1], y1 = +_[1][1];
2415
+ if (x0 > x1) _ = x0, x0 = x1, x1 = _;
2416
+ if (y0 > y1) _ = y0, y0 = y1, y1 = _;
2417
+ return graticule.precision(precision);
2418
+ };
2419
+ graticule.step = function(_) {
2420
+ if (!arguments.length) return graticule.stepMinor();
2421
+ return graticule.stepMajor(_).stepMinor(_);
2422
+ };
2423
+ graticule.stepMajor = function(_) {
2424
+ if (!arguments.length) return [DX, DY];
2425
+ DX = +_[0], DY = +_[1];
2426
+ return graticule;
2427
+ };
2428
+ graticule.stepMinor = function(_) {
2429
+ if (!arguments.length) return [dx, dy];
2430
+ dx = +_[0], dy = +_[1];
2431
+ return graticule;
2432
+ };
2433
+ graticule.precision = function(_) {
2434
+ if (!arguments.length) return precision;
2435
+ precision = +_;
2436
+ x = graticuleX(y0, y1, 90);
2437
+ y = graticuleY(x0, x1, precision);
2438
+ X = graticuleX(Y0, Y1, 90);
2439
+ Y = graticuleY(X0, X1, precision);
2440
+ return graticule;
2441
+ };
2442
+ return graticule.extentMajor([[-180, -90 + epsilon], [180, 90 - epsilon]]).extentMinor([[-180, -80 - epsilon], [180, 80 + epsilon]]);
2443
+ }
2444
+ function graticule10() {
2445
+ return graticule()();
2446
+ }
2447
+ //#endregion
2448
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/identity.js
2449
+ var identity_default = (x) => x;
2450
+ //#endregion
2451
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/path/area.js
2452
+ var areaSum = new Adder();
2453
+ var areaRingSum = new Adder();
2454
+ var x00$2;
2455
+ var y00$2;
2456
+ var x0$3;
2457
+ var y0$3;
2458
+ var areaStream = {
2459
+ point: noop,
2460
+ lineStart: noop,
2461
+ lineEnd: noop,
2462
+ polygonStart: function() {
2463
+ areaStream.lineStart = areaRingStart;
2464
+ areaStream.lineEnd = areaRingEnd;
2465
+ },
2466
+ polygonEnd: function() {
2467
+ areaStream.lineStart = areaStream.lineEnd = areaStream.point = noop;
2468
+ areaSum.add(abs(areaRingSum));
2469
+ areaRingSum = new Adder();
2470
+ },
2471
+ result: function() {
2472
+ var area = areaSum / 2;
2473
+ areaSum = new Adder();
2474
+ return area;
2475
+ }
2476
+ };
2477
+ function areaRingStart() {
2478
+ areaStream.point = areaPointFirst;
2479
+ }
2480
+ function areaPointFirst(x, y) {
2481
+ areaStream.point = areaPoint;
2482
+ x00$2 = x0$3 = x, y00$2 = y0$3 = y;
2483
+ }
2484
+ function areaPoint(x, y) {
2485
+ areaRingSum.add(y0$3 * x - x0$3 * y);
2486
+ x0$3 = x, y0$3 = y;
2487
+ }
2488
+ function areaRingEnd() {
2489
+ areaPoint(x00$2, y00$2);
2490
+ }
2491
+ //#endregion
2492
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/path/bounds.js
2493
+ var x0$2 = Infinity;
2494
+ var y0$2 = x0$2;
2495
+ var x1 = -x0$2;
2496
+ var y1 = x1;
2497
+ var boundsStream = {
2498
+ point: boundsPoint,
2499
+ lineStart: noop,
2500
+ lineEnd: noop,
2501
+ polygonStart: noop,
2502
+ polygonEnd: noop,
2503
+ result: function() {
2504
+ var bounds = [[x0$2, y0$2], [x1, y1]];
2505
+ x1 = y1 = -(y0$2 = x0$2 = Infinity);
2506
+ return bounds;
2507
+ }
2508
+ };
2509
+ function boundsPoint(x, y) {
2510
+ if (x < x0$2) x0$2 = x;
2511
+ if (x > x1) x1 = x;
2512
+ if (y < y0$2) y0$2 = y;
2513
+ if (y > y1) y1 = y;
2514
+ }
2515
+ //#endregion
2516
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/path/centroid.js
2517
+ var X0 = 0;
2518
+ var Y0 = 0;
2519
+ var Z0 = 0;
2520
+ var X1 = 0;
2521
+ var Y1 = 0;
2522
+ var Z1 = 0;
2523
+ var X2 = 0;
2524
+ var Y2 = 0;
2525
+ var Z2 = 0;
2526
+ var x00$1;
2527
+ var y00$1;
2528
+ var x0$1;
2529
+ var y0$1;
2530
+ var centroidStream = {
2531
+ point: centroidPoint,
2532
+ lineStart: centroidLineStart,
2533
+ lineEnd: centroidLineEnd,
2534
+ polygonStart: function() {
2535
+ centroidStream.lineStart = centroidRingStart;
2536
+ centroidStream.lineEnd = centroidRingEnd;
2537
+ },
2538
+ polygonEnd: function() {
2539
+ centroidStream.point = centroidPoint;
2540
+ centroidStream.lineStart = centroidLineStart;
2541
+ centroidStream.lineEnd = centroidLineEnd;
2542
+ },
2543
+ result: function() {
2544
+ var centroid = Z2 ? [X2 / Z2, Y2 / Z2] : Z1 ? [X1 / Z1, Y1 / Z1] : Z0 ? [X0 / Z0, Y0 / Z0] : [NaN, NaN];
2545
+ X0 = Y0 = Z0 = X1 = Y1 = Z1 = X2 = Y2 = Z2 = 0;
2546
+ return centroid;
2547
+ }
2548
+ };
2549
+ function centroidPoint(x, y) {
2550
+ X0 += x;
2551
+ Y0 += y;
2552
+ ++Z0;
2553
+ }
2554
+ function centroidLineStart() {
2555
+ centroidStream.point = centroidPointFirstLine;
2556
+ }
2557
+ function centroidPointFirstLine(x, y) {
2558
+ centroidStream.point = centroidPointLine;
2559
+ centroidPoint(x0$1 = x, y0$1 = y);
2560
+ }
2561
+ function centroidPointLine(x, y) {
2562
+ var dx = x - x0$1, dy = y - y0$1, z = sqrt(dx * dx + dy * dy);
2563
+ X1 += z * (x0$1 + x) / 2;
2564
+ Y1 += z * (y0$1 + y) / 2;
2565
+ Z1 += z;
2566
+ centroidPoint(x0$1 = x, y0$1 = y);
2567
+ }
2568
+ function centroidLineEnd() {
2569
+ centroidStream.point = centroidPoint;
2570
+ }
2571
+ function centroidRingStart() {
2572
+ centroidStream.point = centroidPointFirstRing;
2573
+ }
2574
+ function centroidRingEnd() {
2575
+ centroidPointRing(x00$1, y00$1);
2576
+ }
2577
+ function centroidPointFirstRing(x, y) {
2578
+ centroidStream.point = centroidPointRing;
2579
+ centroidPoint(x00$1 = x0$1 = x, y00$1 = y0$1 = y);
2580
+ }
2581
+ function centroidPointRing(x, y) {
2582
+ var dx = x - x0$1, dy = y - y0$1, z = sqrt(dx * dx + dy * dy);
2583
+ X1 += z * (x0$1 + x) / 2;
2584
+ Y1 += z * (y0$1 + y) / 2;
2585
+ Z1 += z;
2586
+ z = y0$1 * x - x0$1 * y;
2587
+ X2 += z * (x0$1 + x);
2588
+ Y2 += z * (y0$1 + y);
2589
+ Z2 += z * 3;
2590
+ centroidPoint(x0$1 = x, y0$1 = y);
2591
+ }
2592
+ //#endregion
2593
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/path/context.js
2594
+ function PathContext(context) {
2595
+ this._context = context;
2596
+ }
2597
+ PathContext.prototype = {
2598
+ _radius: 4.5,
2599
+ pointRadius: function(_) {
2600
+ return this._radius = _, this;
2601
+ },
2602
+ polygonStart: function() {
2603
+ this._line = 0;
2604
+ },
2605
+ polygonEnd: function() {
2606
+ this._line = NaN;
2607
+ },
2608
+ lineStart: function() {
2609
+ this._point = 0;
2610
+ },
2611
+ lineEnd: function() {
2612
+ if (this._line === 0) this._context.closePath();
2613
+ this._point = NaN;
2614
+ },
2615
+ point: function(x, y) {
2616
+ switch (this._point) {
2617
+ case 0:
2618
+ this._context.moveTo(x, y);
2619
+ this._point = 1;
2620
+ break;
2621
+ case 1:
2622
+ this._context.lineTo(x, y);
2623
+ break;
2624
+ default:
2625
+ this._context.moveTo(x + this._radius, y);
2626
+ this._context.arc(x, y, this._radius, 0, tau);
2627
+ }
2628
+ },
2629
+ result: noop
2630
+ };
2631
+ //#endregion
2632
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/path/measure.js
2633
+ var lengthSum = new Adder();
2634
+ var lengthRing;
2635
+ var x00;
2636
+ var y00;
2637
+ var x0;
2638
+ var y0;
2639
+ var lengthStream = {
2640
+ point: noop,
2641
+ lineStart: function() {
2642
+ lengthStream.point = lengthPointFirst;
2643
+ },
2644
+ lineEnd: function() {
2645
+ if (lengthRing) lengthPoint(x00, y00);
2646
+ lengthStream.point = noop;
2647
+ },
2648
+ polygonStart: function() {
2649
+ lengthRing = true;
2650
+ },
2651
+ polygonEnd: function() {
2652
+ lengthRing = null;
2653
+ },
2654
+ result: function() {
2655
+ var length = +lengthSum;
2656
+ lengthSum = new Adder();
2657
+ return length;
2658
+ }
2659
+ };
2660
+ function lengthPointFirst(x, y) {
2661
+ lengthStream.point = lengthPoint;
2662
+ x00 = x0 = x, y00 = y0 = y;
2663
+ }
2664
+ function lengthPoint(x, y) {
2665
+ x0 -= x, y0 -= y;
2666
+ lengthSum.add(sqrt(x0 * x0 + y0 * y0));
2667
+ x0 = x, y0 = y;
2668
+ }
2669
+ //#endregion
2670
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/path/string.js
2671
+ let cacheDigits;
2672
+ let cacheAppend;
2673
+ let cacheRadius;
2674
+ let cacheCircle;
2675
+ var PathString = class {
2676
+ constructor(digits) {
2677
+ this._append = digits == null ? append : appendRound(digits);
2678
+ this._radius = 4.5;
2679
+ this._ = "";
2680
+ }
2681
+ pointRadius(_) {
2682
+ this._radius = +_;
2683
+ return this;
2684
+ }
2685
+ polygonStart() {
2686
+ this._line = 0;
2687
+ }
2688
+ polygonEnd() {
2689
+ this._line = NaN;
2690
+ }
2691
+ lineStart() {
2692
+ this._point = 0;
2693
+ }
2694
+ lineEnd() {
2695
+ if (this._line === 0) this._ += "Z";
2696
+ this._point = NaN;
2697
+ }
2698
+ point(x, y) {
2699
+ switch (this._point) {
2700
+ case 0:
2701
+ this._append`M${x},${y}`;
2702
+ this._point = 1;
2703
+ break;
2704
+ case 1:
2705
+ this._append`L${x},${y}`;
2706
+ break;
2707
+ default:
2708
+ this._append`M${x},${y}`;
2709
+ if (this._radius !== cacheRadius || this._append !== cacheAppend) {
2710
+ const r = this._radius;
2711
+ const s = this._;
2712
+ this._ = "";
2713
+ this._append`m0,${r}a${r},${r} 0 1,1 0,${-2 * r}a${r},${r} 0 1,1 0,${2 * r}z`;
2714
+ cacheRadius = r;
2715
+ cacheAppend = this._append;
2716
+ cacheCircle = this._;
2717
+ this._ = s;
2718
+ }
2719
+ this._ += cacheCircle;
2720
+ }
2721
+ }
2722
+ result() {
2723
+ const result = this._;
2724
+ this._ = "";
2725
+ return result.length ? result : null;
2726
+ }
2727
+ };
2728
+ function append(strings) {
2729
+ let i = 1;
2730
+ this._ += strings[0];
2731
+ for (const j = strings.length; i < j; ++i) this._ += arguments[i] + strings[i];
2732
+ }
2733
+ function appendRound(digits) {
2734
+ const d = Math.floor(digits);
2735
+ if (!(d >= 0)) throw new RangeError(`invalid digits: ${digits}`);
2736
+ if (d > 15) return append;
2737
+ if (d !== cacheDigits) {
2738
+ const k = 10 ** d;
2739
+ cacheDigits = d;
2740
+ cacheAppend = function append(strings) {
2741
+ let i = 1;
2742
+ this._ += strings[0];
2743
+ for (const j = strings.length; i < j; ++i) this._ += Math.round(arguments[i] * k) / k + strings[i];
2744
+ };
2745
+ }
2746
+ return cacheAppend;
2747
+ }
2748
+ //#endregion
2749
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/path/index.js
2750
+ function path_default(projection, context) {
2751
+ let digits = 3, pointRadius = 4.5, projectionStream, contextStream;
2752
+ function path(object) {
2753
+ if (object) {
2754
+ if (typeof pointRadius === "function") contextStream.pointRadius(+pointRadius.apply(this, arguments));
2755
+ stream_default(object, projectionStream(contextStream));
2756
+ }
2757
+ return contextStream.result();
2758
+ }
2759
+ path.area = function(object) {
2760
+ stream_default(object, projectionStream(areaStream));
2761
+ return areaStream.result();
2762
+ };
2763
+ path.measure = function(object) {
2764
+ stream_default(object, projectionStream(lengthStream));
2765
+ return lengthStream.result();
2766
+ };
2767
+ path.bounds = function(object) {
2768
+ stream_default(object, projectionStream(boundsStream));
2769
+ return boundsStream.result();
2770
+ };
2771
+ path.centroid = function(object) {
2772
+ stream_default(object, projectionStream(centroidStream));
2773
+ return centroidStream.result();
2774
+ };
2775
+ path.projection = function(_) {
2776
+ if (!arguments.length) return projection;
2777
+ projectionStream = _ == null ? (projection = null, identity_default) : (projection = _).stream;
2778
+ return path;
2779
+ };
2780
+ path.context = function(_) {
2781
+ if (!arguments.length) return context;
2782
+ contextStream = _ == null ? (context = null, new PathString(digits)) : new PathContext(context = _);
2783
+ if (typeof pointRadius !== "function") contextStream.pointRadius(pointRadius);
2784
+ return path;
2785
+ };
2786
+ path.pointRadius = function(_) {
2787
+ if (!arguments.length) return pointRadius;
2788
+ pointRadius = typeof _ === "function" ? _ : (contextStream.pointRadius(+_), +_);
2789
+ return path;
2790
+ };
2791
+ path.digits = function(_) {
2792
+ if (!arguments.length) return digits;
2793
+ if (_ == null) digits = null;
2794
+ else {
2795
+ const d = Math.floor(_);
2796
+ if (!(d >= 0)) throw new RangeError(`invalid digits: ${_}`);
2797
+ digits = d;
2798
+ }
2799
+ if (context === null) contextStream = new PathString(digits);
2800
+ return path;
2801
+ };
2802
+ return path.projection(projection).digits(digits).context(context);
2803
+ }
2804
+ //#endregion
2805
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/transform.js
2806
+ function transformer(methods) {
2807
+ return function(stream) {
2808
+ var s = new TransformStream();
2809
+ for (var key in methods) s[key] = methods[key];
2810
+ s.stream = stream;
2811
+ return s;
2812
+ };
2813
+ }
2814
+ function TransformStream() {}
2815
+ TransformStream.prototype = {
2816
+ constructor: TransformStream,
2817
+ point: function(x, y) {
2818
+ this.stream.point(x, y);
2819
+ },
2820
+ sphere: function() {
2821
+ this.stream.sphere();
2822
+ },
2823
+ lineStart: function() {
2824
+ this.stream.lineStart();
2825
+ },
2826
+ lineEnd: function() {
2827
+ this.stream.lineEnd();
2828
+ },
2829
+ polygonStart: function() {
2830
+ this.stream.polygonStart();
2831
+ },
2832
+ polygonEnd: function() {
2833
+ this.stream.polygonEnd();
2834
+ }
2835
+ };
2836
+ //#endregion
2837
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/projection/fit.js
2838
+ function fit(projection, fitBounds, object) {
2839
+ var clip = projection.clipExtent && projection.clipExtent();
2840
+ projection.scale(150).translate([0, 0]);
2841
+ if (clip != null) projection.clipExtent(null);
2842
+ stream_default(object, projection.stream(boundsStream));
2843
+ fitBounds(boundsStream.result());
2844
+ if (clip != null) projection.clipExtent(clip);
2845
+ return projection;
2846
+ }
2847
+ function fitExtent(projection, extent, object) {
2848
+ return fit(projection, function(b) {
2849
+ var w = extent[1][0] - extent[0][0], h = extent[1][1] - extent[0][1], k = Math.min(w / (b[1][0] - b[0][0]), h / (b[1][1] - b[0][1])), x = +extent[0][0] + (w - k * (b[1][0] + b[0][0])) / 2, y = +extent[0][1] + (h - k * (b[1][1] + b[0][1])) / 2;
2850
+ projection.scale(150 * k).translate([x, y]);
2851
+ }, object);
2852
+ }
2853
+ function fitSize(projection, size, object) {
2854
+ return fitExtent(projection, [[0, 0], size], object);
2855
+ }
2856
+ function fitWidth(projection, width, object) {
2857
+ return fit(projection, function(b) {
2858
+ var w = +width, k = w / (b[1][0] - b[0][0]), x = (w - k * (b[1][0] + b[0][0])) / 2, y = -k * b[0][1];
2859
+ projection.scale(150 * k).translate([x, y]);
2860
+ }, object);
2861
+ }
2862
+ function fitHeight(projection, height, object) {
2863
+ return fit(projection, function(b) {
2864
+ var h = +height, k = h / (b[1][1] - b[0][1]), x = -k * b[0][0], y = (h - k * (b[1][1] + b[0][1])) / 2;
2865
+ projection.scale(150 * k).translate([x, y]);
2866
+ }, object);
2867
+ }
2868
+ //#endregion
2869
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/projection/resample.js
2870
+ var maxDepth = 16;
2871
+ var cosMinDistance = cos(30 * radians);
2872
+ function resample_default(project, delta2) {
2873
+ return +delta2 ? resample(project, delta2) : resampleNone(project);
2874
+ }
2875
+ function resampleNone(project) {
2876
+ return transformer({ point: function(x, y) {
2877
+ x = project(x, y);
2878
+ this.stream.point(x[0], x[1]);
2879
+ } });
2880
+ }
2881
+ function resample(project, delta2) {
2882
+ function resampleLineTo(x0, y0, lambda0, a0, b0, c0, x1, y1, lambda1, a1, b1, c1, depth, stream) {
2883
+ var dx = x1 - x0, dy = y1 - y0, d2 = dx * dx + dy * dy;
2884
+ if (d2 > 4 * delta2 && depth--) {
2885
+ var a = a0 + a1, b = b0 + b1, c = c0 + c1, m = sqrt(a * a + b * b + c * c), phi2 = asin(c /= m), lambda2 = abs(abs(c) - 1) < 1e-6 || abs(lambda0 - lambda1) < 1e-6 ? (lambda0 + lambda1) / 2 : atan2(b, a), p = project(lambda2, phi2), x2 = p[0], y2 = p[1], dx2 = x2 - x0, dy2 = y2 - y0, dz = dy * dx2 - dx * dy2;
2886
+ if (dz * dz / d2 > delta2 || abs((dx * dx2 + dy * dy2) / d2 - .5) > .3 || a0 * a1 + b0 * b1 + c0 * c1 < cosMinDistance) {
2887
+ resampleLineTo(x0, y0, lambda0, a0, b0, c0, x2, y2, lambda2, a /= m, b /= m, c, depth, stream);
2888
+ stream.point(x2, y2);
2889
+ resampleLineTo(x2, y2, lambda2, a, b, c, x1, y1, lambda1, a1, b1, c1, depth, stream);
2890
+ }
2891
+ }
2892
+ }
2893
+ return function(stream) {
2894
+ var lambda00, x00, y00, a00, b00, c00, lambda0, x0, y0, a0, b0, c0;
2895
+ var resampleStream = {
2896
+ point,
2897
+ lineStart,
2898
+ lineEnd,
2899
+ polygonStart: function() {
2900
+ stream.polygonStart();
2901
+ resampleStream.lineStart = ringStart;
2902
+ },
2903
+ polygonEnd: function() {
2904
+ stream.polygonEnd();
2905
+ resampleStream.lineStart = lineStart;
2906
+ }
2907
+ };
2908
+ function point(x, y) {
2909
+ x = project(x, y);
2910
+ stream.point(x[0], x[1]);
2911
+ }
2912
+ function lineStart() {
2913
+ x0 = NaN;
2914
+ resampleStream.point = linePoint;
2915
+ stream.lineStart();
2916
+ }
2917
+ function linePoint(lambda, phi) {
2918
+ var c = cartesian([lambda, phi]), p = project(lambda, phi);
2919
+ resampleLineTo(x0, y0, lambda0, a0, b0, c0, x0 = p[0], y0 = p[1], lambda0 = lambda, a0 = c[0], b0 = c[1], c0 = c[2], maxDepth, stream);
2920
+ stream.point(x0, y0);
2921
+ }
2922
+ function lineEnd() {
2923
+ resampleStream.point = point;
2924
+ stream.lineEnd();
2925
+ }
2926
+ function ringStart() {
2927
+ lineStart();
2928
+ resampleStream.point = ringPoint;
2929
+ resampleStream.lineEnd = ringEnd;
2930
+ }
2931
+ function ringPoint(lambda, phi) {
2932
+ linePoint(lambda00 = lambda, phi), x00 = x0, y00 = y0, a00 = a0, b00 = b0, c00 = c0;
2933
+ resampleStream.point = linePoint;
2934
+ }
2935
+ function ringEnd() {
2936
+ resampleLineTo(x0, y0, lambda0, a0, b0, c0, x00, y00, lambda00, a00, b00, c00, maxDepth, stream);
2937
+ resampleStream.lineEnd = lineEnd;
2938
+ lineEnd();
2939
+ }
2940
+ return resampleStream;
2941
+ };
2942
+ }
2943
+ //#endregion
2944
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/projection/index.js
2945
+ var transformRadians = transformer({ point: function(x, y) {
2946
+ this.stream.point(x * radians, y * radians);
2947
+ } });
2948
+ function transformRotate(rotate) {
2949
+ return transformer({ point: function(x, y) {
2950
+ var r = rotate(x, y);
2951
+ return this.stream.point(r[0], r[1]);
2952
+ } });
2953
+ }
2954
+ function scaleTranslate(k, dx, dy, sx, sy) {
2955
+ function transform(x, y) {
2956
+ x *= sx;
2957
+ y *= sy;
2958
+ return [dx + k * x, dy - k * y];
2959
+ }
2960
+ transform.invert = function(x, y) {
2961
+ return [(x - dx) / k * sx, (dy - y) / k * sy];
2962
+ };
2963
+ return transform;
2964
+ }
2965
+ function scaleTranslateRotate(k, dx, dy, sx, sy, alpha) {
2966
+ if (!alpha) return scaleTranslate(k, dx, dy, sx, sy);
2967
+ var cosAlpha = cos(alpha), sinAlpha = sin(alpha), a = cosAlpha * k, b = sinAlpha * k, ai = cosAlpha / k, bi = sinAlpha / k, ci = (sinAlpha * dy - cosAlpha * dx) / k, fi = (sinAlpha * dx + cosAlpha * dy) / k;
2968
+ function transform(x, y) {
2969
+ x *= sx;
2970
+ y *= sy;
2971
+ return [a * x - b * y + dx, dy - b * x - a * y];
2972
+ }
2973
+ transform.invert = function(x, y) {
2974
+ return [sx * (ai * x - bi * y + ci), sy * (fi - bi * x - ai * y)];
2975
+ };
2976
+ return transform;
2977
+ }
2978
+ function projection(project) {
2979
+ return projectionMutator(function() {
2980
+ return project;
2981
+ })();
2982
+ }
2983
+ function projectionMutator(projectAt) {
2984
+ var project, k = 150, x = 480, y = 250, lambda = 0, phi = 0, deltaLambda = 0, deltaPhi = 0, deltaGamma = 0, rotate, alpha = 0, sx = 1, sy = 1, theta = null, preclip = antimeridian_default, x0 = null, y0, x1, y1, postclip = identity_default, delta2 = .5, projectResample, projectTransform, projectRotateTransform, cache, cacheStream;
2985
+ function projection(point) {
2986
+ return projectRotateTransform(point[0] * radians, point[1] * radians);
2987
+ }
2988
+ function invert(point) {
2989
+ point = projectRotateTransform.invert(point[0], point[1]);
2990
+ return point && [point[0] * degrees, point[1] * degrees];
2991
+ }
2992
+ projection.stream = function(stream) {
2993
+ return cache && cacheStream === stream ? cache : cache = transformRadians(transformRotate(rotate)(preclip(projectResample(postclip(cacheStream = stream)))));
2994
+ };
2995
+ projection.preclip = function(_) {
2996
+ return arguments.length ? (preclip = _, theta = void 0, reset()) : preclip;
2997
+ };
2998
+ projection.postclip = function(_) {
2999
+ return arguments.length ? (postclip = _, x0 = y0 = x1 = y1 = null, reset()) : postclip;
3000
+ };
3001
+ projection.clipAngle = function(_) {
3002
+ return arguments.length ? (preclip = +_ ? circle_default(theta = _ * radians) : (theta = null, antimeridian_default), reset()) : theta * degrees;
3003
+ };
3004
+ projection.clipExtent = function(_) {
3005
+ return arguments.length ? (postclip = _ == null ? (x0 = y0 = x1 = y1 = null, identity_default) : clipRectangle(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]), reset()) : x0 == null ? null : [[x0, y0], [x1, y1]];
3006
+ };
3007
+ projection.scale = function(_) {
3008
+ return arguments.length ? (k = +_, recenter()) : k;
3009
+ };
3010
+ projection.translate = function(_) {
3011
+ return arguments.length ? (x = +_[0], y = +_[1], recenter()) : [x, y];
3012
+ };
3013
+ projection.center = function(_) {
3014
+ return arguments.length ? (lambda = _[0] % 360 * radians, phi = _[1] % 360 * radians, recenter()) : [lambda * degrees, phi * degrees];
3015
+ };
3016
+ projection.rotate = function(_) {
3017
+ return arguments.length ? (deltaLambda = _[0] % 360 * radians, deltaPhi = _[1] % 360 * radians, deltaGamma = _.length > 2 ? _[2] % 360 * radians : 0, recenter()) : [
3018
+ deltaLambda * degrees,
3019
+ deltaPhi * degrees,
3020
+ deltaGamma * degrees
3021
+ ];
3022
+ };
3023
+ projection.angle = function(_) {
3024
+ return arguments.length ? (alpha = _ % 360 * radians, recenter()) : alpha * degrees;
3025
+ };
3026
+ projection.reflectX = function(_) {
3027
+ return arguments.length ? (sx = _ ? -1 : 1, recenter()) : sx < 0;
3028
+ };
3029
+ projection.reflectY = function(_) {
3030
+ return arguments.length ? (sy = _ ? -1 : 1, recenter()) : sy < 0;
3031
+ };
3032
+ projection.precision = function(_) {
3033
+ return arguments.length ? (projectResample = resample_default(projectTransform, delta2 = _ * _), reset()) : sqrt(delta2);
3034
+ };
3035
+ projection.fitExtent = function(extent, object) {
3036
+ return fitExtent(projection, extent, object);
3037
+ };
3038
+ projection.fitSize = function(size, object) {
3039
+ return fitSize(projection, size, object);
3040
+ };
3041
+ projection.fitWidth = function(width, object) {
3042
+ return fitWidth(projection, width, object);
3043
+ };
3044
+ projection.fitHeight = function(height, object) {
3045
+ return fitHeight(projection, height, object);
3046
+ };
3047
+ function recenter() {
3048
+ var center = scaleTranslateRotate(k, 0, 0, sx, sy, alpha).apply(null, project(lambda, phi)), transform = scaleTranslateRotate(k, x - center[0], y - center[1], sx, sy, alpha);
3049
+ rotate = rotateRadians(deltaLambda, deltaPhi, deltaGamma);
3050
+ projectTransform = compose_default(project, transform);
3051
+ projectRotateTransform = compose_default(rotate, projectTransform);
3052
+ projectResample = resample_default(projectTransform, delta2);
3053
+ return reset();
3054
+ }
3055
+ function reset() {
3056
+ cache = cacheStream = null;
3057
+ return projection;
3058
+ }
3059
+ return function() {
3060
+ project = projectAt.apply(this, arguments);
3061
+ projection.invert = project.invert && invert;
3062
+ return recenter();
3063
+ };
3064
+ }
3065
+ //#endregion
3066
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/projection/azimuthal.js
3067
+ function azimuthalInvert(angle) {
3068
+ return function(x, y) {
3069
+ var z = sqrt(x * x + y * y), c = angle(z), sc = sin(c), cc = cos(c);
3070
+ return [atan2(x * sc, z * cc), asin(z && y * sc / z)];
3071
+ };
3072
+ }
3073
+ //#endregion
3074
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/projection/mercator.js
3075
+ function mercatorRaw(lambda, phi) {
3076
+ return [lambda, log(tan((halfPi + phi) / 2))];
3077
+ }
3078
+ mercatorRaw.invert = function(x, y) {
3079
+ return [x, 2 * atan(exp(y)) - halfPi];
3080
+ };
3081
+ function mercator_default() {
3082
+ return mercatorProjection$1(mercatorRaw).scale(961 / tau);
3083
+ }
3084
+ function mercatorProjection$1(project) {
3085
+ var m = projection(project), center = m.center, scale = m.scale, translate = m.translate, clipExtent = m.clipExtent, x0 = null, y0, x1, y1;
3086
+ m.scale = function(_) {
3087
+ return arguments.length ? (scale(_), reclip()) : scale();
3088
+ };
3089
+ m.translate = function(_) {
3090
+ return arguments.length ? (translate(_), reclip()) : translate();
3091
+ };
3092
+ m.center = function(_) {
3093
+ return arguments.length ? (center(_), reclip()) : center();
3094
+ };
3095
+ m.clipExtent = function(_) {
3096
+ return arguments.length ? (_ == null ? x0 = y0 = x1 = y1 = null : (x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]), reclip()) : x0 == null ? null : [[x0, y0], [x1, y1]];
3097
+ };
3098
+ function reclip() {
3099
+ var k = pi * scale(), t = m(rotation_default(m.rotate()).invert([0, 0]));
3100
+ return clipExtent(x0 == null ? [[t[0] - k, t[1] - k], [t[0] + k, t[1] + k]] : project === mercatorRaw ? [[Math.max(t[0] - k, x0), y0], [Math.min(t[0] + k, x1), y1]] : [[x0, Math.max(t[1] - k, y0)], [x1, Math.min(t[1] + k, y1)]]);
3101
+ }
3102
+ return reclip();
3103
+ }
3104
+ //#endregion
3105
+ //#region ../../node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/projection/orthographic.js
3106
+ function orthographicRaw(x, y) {
3107
+ return [cos(y) * sin(x), sin(y)];
3108
+ }
3109
+ orthographicRaw.invert = azimuthalInvert(asin);
3110
+ function orthographic_default() {
3111
+ return projection(orthographicRaw).scale(249.5).clipAngle(90 + epsilon);
3112
+ }
3113
+ //#endregion
3114
+ //#region src/components/chart/Maps.tsx
3115
+ function resolve(row, accessor) {
3116
+ return typeof accessor === "function" ? accessor(row) : row[accessor];
3117
+ }
3118
+ function resolveStyle(row, style) {
3119
+ return typeof style === "function" ? style(row) : style;
3120
+ }
3121
+ /**
3122
+ * Mercator's latitude cutoff. It stretches toward ±90° to infinity, so we clamp
3123
+ * at ±85.0511° — otherwise Antarctica projects to an unbounded height and the
3124
+ * whole map shrinks to fit. Renders the poles as a flat edge, like web maps do.
3125
+ */
3126
+ const MERCATOR_MAX_LAT = 85.0511;
3127
+ /**
3128
+ * Default projection for all maps: latitude-clamped Mercator. A single shared
3129
+ * instance is fine - `project`/`unproject` are pure (no per-chart state).
3130
+ */
3131
+ const mercatorProjection = mercator_default();
3132
+ const DEFAULT_PROJECTION = {
3133
+ project: (point) => {
3134
+ const lat = Math.max(-85.0511, Math.min(MERCATOR_MAX_LAT, point[1]));
3135
+ return mercatorProjection([point[0], lat]) ?? [0, 0];
3136
+ },
3137
+ unproject: (point) => mercatorProjection.invert?.(point) ?? [0, 0]
3138
+ };
3139
+ /**
3140
+ * Default displayed window as ECharts `boundingCoords`
3141
+ * (`[[west, north], [east, south]]`). Crops the empty Arctic and most of
3142
+ * Antarctica so the populated landmasses fill the container.
3143
+ */
3144
+ const DEFAULT_BOUNDING_COORDS = [[-180, 80], [180, -58]];
3145
+ /**
3146
+ * Resolve the effective projection: `undefined` → the Mercator default,
3147
+ * `null` → none (raw plotting), otherwise the caller's projection.
3148
+ */
3149
+ function resolveProjection(projection) {
3150
+ if (projection === null) return void 0;
3151
+ return projection ?? DEFAULT_PROJECTION;
3152
+ }
3153
+ /**
3154
+ * Aspect ratio (`width / height`) of the projected window, used to size the
3155
+ * container so the map fills it (ECharts contain-fits the map, so a mismatched
3156
+ * container letterboxes it).
3157
+ *
3158
+ * Measures width at the equator and height down the central meridian - exact
3159
+ * for cylindrical projections (Mercator/equirectangular/raw), close enough for
3160
+ * curved ones (at worst a small letterbox).
3161
+ */
3162
+ function projectedAspect(projection, [[west, north], [east, south]]) {
3163
+ const project = projection ? projection.project : (p) => p;
3164
+ const midLat = Math.min(north, Math.max(south, 0));
3165
+ const w = Math.abs(project([east, midLat])[0] - project([west, midLat])[0]);
3166
+ const h = Math.abs(project([0, north])[1] - project([0, south])[1]);
3167
+ return w > 0 && h > 0 ? w / h : 16 / 9;
3168
+ }
3169
+ /** Furthest `roam` zoom-in, as a multiple of the auto-fit scale. */
3170
+ const MAX_ZOOM_FACTOR = 8;
3171
+ const geoJsonMapNames = /* @__PURE__ */ new WeakMap();
3172
+ function sanitizeMapName(name) {
3173
+ return name.replace(/[^a-zA-Z0-9_-]/g, "-");
3174
+ }
3175
+ function hashString(value) {
3176
+ let hash = 0;
3177
+ for (let i = 0; i < value.length; i++) hash = Math.imul(31, hash) + value.charCodeAt(i);
3178
+ return (hash >>> 0).toString(36);
3179
+ }
3180
+ function getMapName(geoJson, mapName) {
3181
+ if (mapName) return sanitizeMapName(mapName);
3182
+ const existing = geoJsonMapNames.get(geoJson);
3183
+ if (existing) return existing;
3184
+ const generated = `kumo-map-${hashString(JSON.stringify(geoJson))}`;
3185
+ geoJsonMapNames.set(geoJson, generated);
3186
+ return generated;
3187
+ }
3188
+ /** Build the `geo` coordinate-system config (land base for the bubbles). */
3189
+ function buildGeo(opts) {
3190
+ return {
3191
+ map: opts.mapName,
3192
+ nameProperty: "name",
3193
+ roam: opts.roam,
3194
+ ...opts.roam ? { scaleLimit: {
3195
+ min: Math.min(1, opts.zoom),
3196
+ max: opts.zoom * MAX_ZOOM_FACTOR
3197
+ } } : {},
3198
+ center: opts.center,
3199
+ zoom: opts.zoom,
3200
+ boundingCoords: DEFAULT_BOUNDING_COORDS,
3201
+ ...opts.projection ? { projection: opts.projection } : { aspectScale: 1 },
3202
+ silent: true,
3203
+ itemStyle: {
3204
+ areaColor: opts.areaColor,
3205
+ borderColor: opts.areaColor,
3206
+ borderWidth: .5
3207
+ },
3208
+ emphasis: { disabled: true }
3209
+ };
3210
+ }
3211
+ /**
3212
+ * BubbleMap — proportional bubbles plotted by coordinate over a blank GeoJSON
3213
+ * base. Land is rendered seamlessly (no internal borders) so the bubbles read
3214
+ * clearly; bubble area is proportional to value (`minRadius`…`maxRadius`).
3215
+ *
3216
+ * @example
3217
+ * ```tsx
3218
+ * import * as echarts from "echarts/core";
3219
+ * import { MapChart, ScatterChart } from "echarts/charts";
3220
+ * import { TooltipComponent } from "echarts/components";
3221
+ * import { CanvasRenderer } from "echarts/renderers";
3222
+ * echarts.use([MapChart, ScatterChart, TooltipComponent, CanvasRenderer]);
3223
+ *
3224
+ * <BubbleMap
3225
+ * echarts={echarts}
3226
+ * geoJson={world}
3227
+ * data={colos}
3228
+ * lng="lon" lat="lat" name="iata" value="requests"
3229
+ * onBubbleHover={(c) => setHovered(c?.iata)}
3230
+ * />
3231
+ * ```
3232
+ */
3233
+ function BubbleMapRoot({ echarts: ec, geoJson, mapName: mapNameProp, data, lng, lat, value, name, minRadius = 6, maxRadius = 26, bubbleSize, bubbleColor, bubbleBorderColor = "transparent", bubbleBorderWidth = 0, center, zoom = 1.25, roam = false, projection, showTooltip = true, valueFormat = defaultValueFormat, tooltipFormatter, onBubbleHover, onBubbleClick, aspectRatio, height, className, isDarkMode }, ref) {
3234
+ const mapName = useMemo(() => getMapName(geoJson, mapNameProp), [geoJson, mapNameProp]);
3235
+ useRegisterMap(ec, mapName, geoJson);
3236
+ const palette = useMemo(() => ChartPalette.mapColors(isDarkMode), [isDarkMode]);
3237
+ const centerX = center?.[0];
3238
+ const centerY = center?.[1];
3239
+ const geo = useMemo(() => buildGeo({
3240
+ mapName,
3241
+ areaColor: palette.area,
3242
+ center: centerX !== void 0 && centerY !== void 0 ? [centerX, centerY] : void 0,
3243
+ zoom,
3244
+ roam,
3245
+ projection: resolveProjection(projection)
3246
+ }), [
3247
+ mapName,
3248
+ geoJson,
3249
+ palette,
3250
+ centerX,
3251
+ centerY,
3252
+ zoom,
3253
+ roam,
3254
+ projection
3255
+ ]);
3256
+ const resolvedAspect = useMemo(() => {
3257
+ if (height !== void 0) return void 0;
3258
+ return aspectRatio ?? projectedAspect(resolveProjection(projection), DEFAULT_BOUNDING_COORDS);
3259
+ }, [
3260
+ aspectRatio,
3261
+ height,
3262
+ projection
3263
+ ]);
3264
+ const appliedGeoRef = useRef(void 0);
3265
+ const shouldIncludeGeo = appliedGeoRef.current !== geo;
3266
+ useEffect(() => {
3267
+ appliedGeoRef.current = geo;
3268
+ }, [geo]);
3269
+ const hoverRef = useRef(onBubbleHover);
3270
+ hoverRef.current = onBubbleHover;
3271
+ const mergedRef = useCallback((instance) => {
3272
+ if (typeof ref === "function") ref(instance);
3273
+ else if (ref) ref.current = instance;
3274
+ }, [ref]);
3275
+ const options = useMemo(() => {
3276
+ const values = data.map((row) => resolve(row, value));
3277
+ const vmax = values.length ? Math.max(...values) : 1;
3278
+ const radiusFor = (v) => {
3279
+ if (bubbleSize) return bubbleSize(v);
3280
+ if (vmax <= 0) return minRadius;
3281
+ return minRadius + Math.sqrt(Math.max(0, v) / vmax) * (maxRadius - minRadius);
3282
+ };
3283
+ const points = data.map((row) => {
3284
+ const v = resolve(row, value);
3285
+ return {
3286
+ name: name ? resolve(row, name) : void 0,
3287
+ value: [
3288
+ resolve(row, lng),
3289
+ resolve(row, lat),
3290
+ v
3291
+ ],
3292
+ symbolSize: radiusFor(v),
3293
+ itemStyle: {
3294
+ color: bubbleColor ? resolveStyle(row, bubbleColor) : palette.bubble,
3295
+ borderColor: resolveStyle(row, bubbleBorderColor),
3296
+ borderWidth: resolveStyle(row, bubbleBorderWidth)
3297
+ },
3298
+ datum: row
3299
+ };
3300
+ });
3301
+ return {
3302
+ backgroundColor: "transparent",
3303
+ animation: true,
3304
+ animationDuration: 500,
3305
+ animationDurationUpdate: 0,
3306
+ ...shouldIncludeGeo ? { geo } : {},
3307
+ tooltip: showTooltip ? {
3308
+ trigger: "item",
3309
+ triggerOn: "mousemove",
3310
+ backgroundColor: "var(--color-kumo-base)",
3311
+ borderColor: "var(--color-kumo-line)",
3312
+ borderWidth: 1,
3313
+ padding: 8,
3314
+ textStyle: {
3315
+ color: "var(--text-color-kumo-default)",
3316
+ fontSize: 13
3317
+ },
3318
+ extraCssText: "border-radius: 0.5rem;",
3319
+ dangerousHtmlFormatter: (params) => {
3320
+ const p = params;
3321
+ const row = p.data?.datum;
3322
+ if (tooltipFormatter && row !== void 0) return tooltipFormatter(row);
3323
+ const v = p.value?.[2];
3324
+ return `<div style="display:flex;flex-direction:column;gap:2px;">${p.name ? `<strong>${escapeHtml(p.name)}</strong>` : ""}${v !== void 0 ? `<span style="color:var(--text-color-kumo-subtle)">${escapeHtml(valueFormat(v))}</span>` : ""}</div>`;
3325
+ }
3326
+ } : void 0,
3327
+ series: [{
3328
+ id: "bubbles",
3329
+ type: "scatter",
3330
+ coordinateSystem: "geo",
3331
+ data: points,
3332
+ itemStyle: { opacity: .8 },
3333
+ emphasis: {
3334
+ scale: 1.2,
3335
+ itemStyle: { opacity: 1 }
3336
+ },
3337
+ z: 3
3338
+ }]
3339
+ };
3340
+ }, [
3341
+ palette,
3342
+ geo,
3343
+ shouldIncludeGeo,
3344
+ data,
3345
+ lng,
3346
+ lat,
3347
+ value,
3348
+ name,
3349
+ minRadius,
3350
+ maxRadius,
3351
+ bubbleSize,
3352
+ bubbleColor,
3353
+ bubbleBorderColor,
3354
+ bubbleBorderWidth,
3355
+ showTooltip,
3356
+ tooltipFormatter,
3357
+ valueFormat
3358
+ ]);
3359
+ const handleMouseOver = useCallback((params) => {
3360
+ const datum = params.data?.datum;
3361
+ if (datum !== void 0) hoverRef.current?.(datum);
3362
+ }, []);
3363
+ const handleMouseOut = useCallback(() => {
3364
+ hoverRef.current?.(void 0);
3365
+ }, []);
3366
+ const handleClick = useCallback((params) => {
3367
+ const datum = params.data?.datum;
3368
+ if (datum !== void 0) onBubbleClick?.(datum);
3369
+ }, [onBubbleClick]);
3370
+ const onEvents = useMemo(() => ({
3371
+ ...onBubbleHover ? {
3372
+ mouseover: handleMouseOver,
3373
+ mouseout: handleMouseOut,
3374
+ globalout: handleMouseOut
3375
+ } : {},
3376
+ ...onBubbleClick ? { click: handleClick } : {}
3377
+ }), [
3378
+ onBubbleHover,
3379
+ handleMouseOver,
3380
+ handleMouseOut,
3381
+ handleClick,
3382
+ onBubbleClick
3383
+ ]);
3384
+ return /* @__PURE__ */ jsx(Chart, {
3385
+ echarts: ec,
3386
+ ref: mergedRef,
3387
+ options,
3388
+ className,
3389
+ isDarkMode,
3390
+ height,
3391
+ aspectRatio: resolvedAspect,
3392
+ onEvents
3393
+ });
3394
+ }
3395
+ const BubbleMap = forwardRef(BubbleMapRoot);
3396
+ BubbleMap.displayName = "BubbleMap";
3397
+ /**
3398
+ * ChoroplethMap — shades GeoJSON regions by value, joining data rows to features
3399
+ * by `name`/`nameProperty`. A continuous `visualMap` legend maps value → colour.
3400
+ * Regions without a matching row render in `noDataColor`. For skewed data, scale
3401
+ * the `value` in the parent (e.g. log) before passing it in.
3402
+ *
3403
+ * @example
3404
+ * ```tsx
3405
+ * import * as echarts from "echarts/core";
3406
+ * import { MapChart } from "echarts/charts";
3407
+ * import { VisualMapComponent, TooltipComponent } from "echarts/components";
3408
+ * import { CanvasRenderer } from "echarts/renderers";
3409
+ * echarts.use([MapChart, VisualMapComponent, TooltipComponent, CanvasRenderer]);
3410
+ *
3411
+ * <ChoroplethMap
3412
+ * echarts={echarts}
3413
+ * geoJson={world}
3414
+ * data={countries}
3415
+ * name="country" value="requests"
3416
+ * />
3417
+ * ```
3418
+ */
3419
+ function ChoroplethMapRoot({ echarts: ec, geoJson, mapName: mapNameProp, data, name, value, nameProperty = "name", colorRange, min, max, noDataColor, showLegend = false, showTooltip = true, valueFormat = defaultValueFormat, tooltipFormatter, onRegionHover, onRegionClick, center, zoom = 1.25, roam = false, projection, aspectRatio, height, className, isDarkMode }, ref) {
3420
+ const mapName = useMemo(() => getMapName(geoJson, mapNameProp), [geoJson, mapNameProp]);
3421
+ useRegisterMap(ec, mapName, geoJson);
3422
+ const palette = useMemo(() => ChartPalette.mapColors(isDarkMode), [isDarkMode]);
3423
+ const centerX = center?.[0];
3424
+ const centerY = center?.[1];
3425
+ const view = useMemo(() => ({
3426
+ roam,
3427
+ ...roam ? { scaleLimit: {
3428
+ min: Math.min(1, zoom),
3429
+ max: zoom * MAX_ZOOM_FACTOR
3430
+ } } : {},
3431
+ center: centerX !== void 0 && centerY !== void 0 ? [centerX, centerY] : void 0,
3432
+ zoom,
3433
+ boundingCoords: DEFAULT_BOUNDING_COORDS,
3434
+ ...resolveProjection(projection) ? { projection: resolveProjection(projection) } : { aspectScale: 1 }
3435
+ }), [
3436
+ centerX,
3437
+ centerY,
3438
+ zoom,
3439
+ roam,
3440
+ isDarkMode,
3441
+ projection
3442
+ ]);
3443
+ const resolvedAspect = useMemo(() => {
3444
+ if (height !== void 0) return void 0;
3445
+ return aspectRatio ?? projectedAspect(resolveProjection(projection), DEFAULT_BOUNDING_COORDS);
3446
+ }, [
3447
+ aspectRatio,
3448
+ height,
3449
+ projection
3450
+ ]);
3451
+ const appliedViewRef = useRef(void 0);
3452
+ const shouldIncludeView = appliedViewRef.current !== view;
3453
+ useEffect(() => {
3454
+ appliedViewRef.current = view;
3455
+ }, [view]);
3456
+ const hoverRef = useRef(onRegionHover);
3457
+ hoverRef.current = onRegionHover;
3458
+ const mergedRef = useCallback((instance) => {
3459
+ if (typeof ref === "function") ref(instance);
3460
+ else if (ref) ref.current = instance;
3461
+ }, [ref]);
3462
+ const options = useMemo(() => {
3463
+ const colors = colorRange ?? palette.scale;
3464
+ const noData = noDataColor ?? palette.area;
3465
+ const regions = data.map((row) => ({
3466
+ name: resolve(row, name),
3467
+ value: resolve(row, value),
3468
+ datum: row
3469
+ }));
3470
+ const values = regions.map((r) => r.value);
3471
+ const vmin = values.length ? Math.min(...values) : 0;
3472
+ const vmax = values.length ? Math.max(...values) : 1;
3473
+ return {
3474
+ backgroundColor: "transparent",
3475
+ animation: true,
3476
+ animationDuration: 500,
3477
+ animationDurationUpdate: 0,
3478
+ visualMap: {
3479
+ type: "continuous",
3480
+ show: showLegend,
3481
+ min: min ?? vmin,
3482
+ max: max ?? (vmax > vmin ? vmax : vmin + 1),
3483
+ calculable: false,
3484
+ hoverLink: false,
3485
+ inRange: { color: colors },
3486
+ orient: "horizontal",
3487
+ text: ["High", "Low"],
3488
+ left: 0,
3489
+ bottom: 8,
3490
+ textStyle: {
3491
+ color: ChartPalette.text("primary", isDarkMode),
3492
+ fontSize: 11
3493
+ }
3494
+ },
3495
+ tooltip: showTooltip ? {
3496
+ trigger: "item",
3497
+ triggerOn: "mousemove",
3498
+ backgroundColor: "var(--color-kumo-base)",
3499
+ borderColor: "var(--color-kumo-line)",
3500
+ borderWidth: 1,
3501
+ padding: 8,
3502
+ textStyle: {
3503
+ color: "var(--text-color-kumo-default)",
3504
+ fontSize: 13
3505
+ },
3506
+ extraCssText: "border-radius: 0.5rem;",
3507
+ dangerousHtmlFormatter: (params) => {
3508
+ const p = params;
3509
+ const row = p.data?.datum;
3510
+ if (row === void 0) return "";
3511
+ if (tooltipFormatter) return tooltipFormatter(row);
3512
+ const v = typeof p.value === "number" && !Number.isNaN(p.value) ? p.value : void 0;
3513
+ return `<div style="display:flex;flex-direction:column;gap:2px;">${p.name ? `<strong>${escapeHtml(p.name)}</strong>` : ""}${v !== void 0 ? `<span style="color:var(--text-color-kumo-subtle)">${escapeHtml(valueFormat(v))}</span>` : ""}</div>`;
3514
+ }
3515
+ } : void 0,
3516
+ series: [{
3517
+ id: "regions",
3518
+ type: "map",
3519
+ map: mapName,
3520
+ nameProperty,
3521
+ ...shouldIncludeView ? view : {},
3522
+ data: regions,
3523
+ itemStyle: {
3524
+ areaColor: noData,
3525
+ borderColor: "transparent",
3526
+ borderWidth: 0
3527
+ },
3528
+ label: { show: false },
3529
+ emphasis: {
3530
+ focus: "self",
3531
+ label: { show: false },
3532
+ itemStyle: { areaColor: "inherit" }
3533
+ },
3534
+ blur: {
3535
+ label: { show: false },
3536
+ itemStyle: { opacity: .45 }
3537
+ },
3538
+ select: { disabled: true },
3539
+ z: 1
3540
+ }]
3541
+ };
3542
+ }, [
3543
+ isDarkMode,
3544
+ palette,
3545
+ geoJson,
3546
+ mapName,
3547
+ view,
3548
+ shouldIncludeView,
3549
+ data,
3550
+ name,
3551
+ value,
3552
+ nameProperty,
3553
+ colorRange,
3554
+ min,
3555
+ max,
3556
+ noDataColor,
3557
+ showLegend,
3558
+ showTooltip,
3559
+ tooltipFormatter,
3560
+ valueFormat
3561
+ ]);
3562
+ const handleMouseOver = useCallback((params) => {
3563
+ const datum = params.data?.datum;
3564
+ if (datum !== void 0) hoverRef.current?.(datum);
3565
+ }, []);
3566
+ const handleMouseOut = useCallback(() => {
3567
+ hoverRef.current?.(void 0);
3568
+ }, []);
3569
+ const handleClick = useCallback((params) => {
3570
+ const datum = params.data?.datum;
3571
+ if (datum !== void 0) onRegionClick?.(datum);
3572
+ }, [onRegionClick]);
3573
+ const onEvents = useMemo(() => ({
3574
+ ...onRegionHover ? {
3575
+ mouseover: handleMouseOver,
3576
+ mouseout: handleMouseOut,
3577
+ globalout: handleMouseOut
3578
+ } : {},
3579
+ ...onRegionClick ? { click: handleClick } : {}
3580
+ }), [
3581
+ onRegionHover,
3582
+ handleMouseOver,
3583
+ handleMouseOut,
3584
+ handleClick,
3585
+ onRegionClick
3586
+ ]);
3587
+ return /* @__PURE__ */ jsx(Chart, {
3588
+ echarts: ec,
3589
+ ref: mergedRef,
3590
+ options,
3591
+ className,
3592
+ isDarkMode,
3593
+ height,
3594
+ aspectRatio: resolvedAspect,
3595
+ onEvents
3596
+ });
3597
+ }
3598
+ const ChoroplethMap = forwardRef(ChoroplethMapRoot);
3599
+ ChoroplethMap.displayName = "ChoroplethMap";
3600
+ /** Register the GeoJSON with ECharts before the child Chart's setOption runs. */
3601
+ function useRegisterMap(ec, mapName, geoJson) {
3602
+ useLayoutEffect(() => {
3603
+ ec.registerMap(mapName, geoJson);
3604
+ }, [
3605
+ ec,
3606
+ mapName,
3607
+ geoJson
3608
+ ]);
3609
+ }
3610
+ //#endregion
3611
+ //#region src/components/chart/globe-land-mask.ts
3612
+ /**
3613
+ * One-degree land occupancy mask generated from Natural Earth 1:110m land.
3614
+ * Natural Earth data is public domain: https://www.naturalearthdata.com/about/terms-of-use/
3615
+ * Source: https://raw.githubusercontent.com/nvkelso/natural-earth-vector/ca96624a56bd078437bca8184e78163e5039ad19/geojson/ne_110m_land.geojson
3616
+ * Generated by: packages/kumo/scripts/generate-globe-land-mask.mjs
3617
+ */
3618
+ const LAND_MASK_BASE64 = "////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////f///////////////////////////////////////////////////////3x8AAP7///////////////////////////////////////////////////8/AAAA/P///////////////////////////////////////////////////x8AAAAA+P//////////////4f///////////////////////////////////wAAAAAA/v////////////8HAAD4////////////////////////////////HwAAAAAAAP7//////////wf8wD8AwP//////////////////////////////DwAAAAAcgP//////////fwAAAP4BwP//////////////////////////////HwAAAACH////////////PwAAAPgA/////////////////////////////////wcAAADA/////////////wEAAAAA8P///////////////////////////////wAAAAAAAPz//////////z8AAAAAAP///////////////////////////////wAAAAAAAPz///////////8HAAAAAAD+/////////////////////////////wAAAAAAAADwv/MXgP////8fAAAAAADw/////////////////////////////wMAAAAAAAAAYAYA4ON/OPh/AAAAAADw/////////////////////////////x8AAAAAAAAAAAAAAAAAAAB+AAAAAACA/////////////////////////////38AAAAAAAAAAAAAAAAAAP5+AAAAAAAA5v////////////D//////////////38AAAAAAAAAAAAAAAAAAHA/AAAAAAAAAAA8//P//////+D/////////////HwAAAAAAAAAAAAAAAAAAADAfAAAAAAAAAAAAAADw8////wP+////////////AwAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAgP///wH4//////////8DAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAAPD/AADA/////////z8AAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAIAfAAAAAAAeeADADwAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH4AAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8AAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP4DAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP4BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAP4BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHgAAAAAAAAAAAAAAAAAAPwHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAAAAPgHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAMABAAAAAAAAAAAAAAAAAPwfAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAIADAAAAAAAAAAAAAAAAAPwHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAALAAAAAAAAAAAAAAAAAPw/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAAAPg/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAAAPj/AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGgAAAA4AAAAAAAAAAAAAAAAAPz/BwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8DAAAIAAAAAAAAAAAAAAAAAPj/BwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8DAAAEAAAAAAAAAAAAAAAAAPj/BwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwP8DAAACAAAAAAAAAAAAAAAAAPD/OwAAAAAAAAAAgAEAAAAAAAAAAAAAAAcA6P8HAAAAAAAAAAAAAAAAAAAAAPD/fwAAAAAAAAAAwH8AAAAAAAAAAAAAgP8A2P8HAAAAAAAAAAAAAAAAAAAAAOD//wAAAAAAAAAAwP8BAAAAAAAAAAAAAP8D/P8PAAAAAAAAAAAAAAAAAAAAAPD//wEAAAAAAAAAwP8DAAAAAAAAAAAAAP////8fAAAAAAAAAAAAAAAAAAAAAPD//wMAAAAAAAAA4P8HAAAAAAAAAAAAgP////8fAAAAAAAAAAAAAAAAAAAAAOD//wMAAAAAAAAA4P8HAAAAAAAAAAAAgP////8fAAAAAAAAAAAAAAAAAAAAAOD//wcAAAAAAAAA8P8PAAAAAAAAAAAAgP////8/AAAAAAAAAAAAAAAAAAAAAOD//wcAAAAAAAAA+P8fAAAAAAAAAAAAwP////8fAAAAAAAAAAAAAAAAAAAAAOD//wcAAAAAAAAA+P8fAAAAAAAAAAAA4P////8fAAAAAAAAAAAAAAAAAAAAAOD//w8AAAAAAAAA+P8fAAIAAAAAAAAAwP////8fAAAAAAAAAAAAAAAAAAAAAOD//x8AAAAAAAAA+P9/AAcAAAAAAAAA4P////8PAAAAAAAAAAAAAAAAAAAAAMD//38AAAAAAAAA/P9/AA8AAAAAAAAAwP////8HAAAAAAAAAAAAAAAAAAAAAMD///8DAAAAAAAA/P//gA8AAAAAAAAAwP////8DAAAAAAAAAAAAAAAAAAAAAMD///8HAAAAAAAA/P9/gA8AAAAAAAAAgP////8BAAIAAAAAAAAAAAAAAAAAAMD///8PAAAAAAAA/v9/AB8AAAAAAAAAAPz///8BAAEAAAAAAAAAAAAAAAAAAMD///8PAAAAAAAA/v9/AB8AAAAAAAAAAOD//38AAAAAAAAAAAAAAAAAAAAAAMD///8PAAAAAAAA////AB8AAAAAAAAAAMD//z8AAAAAAAAAAAAAAAAAAAAAAOD///8fAAAAAAAA////Ax8AAAAAAAAAAMD//z4AAABAAAAAAAAAAAAAAAAAAPj///8fAAAAAAAA////Dz8AAAAAAAAAAAD/Pz4AAAiAAAAAAAAAAAAAAAAAAP7///8fAAAAAAAA////DzgAAAAAAAAAAAD/DxwAAAAAAAAAAAAAAAAAAAAAAP////8fAAAAAAAA////HzAAAAAAAAAAAADsDxwAAAAAAAAAAAAAAAAAAAAAAP////8fAAAAAAAA/v//HyAAAAAAAAAAAADADwwAAAAAAAAAAAAAAAAAAAAAgP////8/AAAAAAAA/v//HyAAAAAAAAAAAACAHwQAAAAAAAAAAAAAAAAAAAAAgP////9/AAAAAAAA/P//DwAAAAAAAAAAAAAAAQQAAAAAAAAAAAAAAAAAAAAAwP//////AAAAAAAA/v//DwAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAA4P//////AAAAAAAA/v//DwAAAAAAAAAAAAgBAIABMAAAAAAAAAAAAAAAAAAA4P//////AQAAAAAA/v//BwAAAAAAAAAAQFYEAMcAAAAAAAAAAAAAAAAAAAAA8P//////AQAAAAAA/v//BwAAAAAAAACAHwAAwH8ABAAAAAAAAAAAAAAAAAAA+P//////AQAAAAAA////BwAAAAAAAADAAQAAxP+AAAAAAAAAAAAAAAAAAAAA+P//////AQAAAAAA////BwAAAAAAAAAwAEAAxD8NAAAAAAAAAAAAAAAAAAAA+P////8/AAAAAACA////BwAAAAAAAAA4AEAA8B8AAAAAAAAAAAAAAAAAAAAA8P////8fAAAAAACA////DwAAAAAAAAA8wChE/gcAAAAAAAAAAAAAAAAAAAAA+P///38BAAAAAADA////HwAAAAAAAAA+/DkA8gAAAAAAAAAAAAAAAAAAAAAA+P///38AAAAAAADg////PwAAAAAAAAAO/DmAAwAAAAAAAAAAAAAAAAAAAAAA8P///wcAAAAAAADg////PwAAAAAAAAAP/gMAAQAAAAAAAAAAAAAAAAAAAAAA8P///wMAAAAAAADg////fwAAAAAAAIAH/vMQAAAAAAAAAAAAAAAAAAAAAAAA4P///wMAAAAAAADg/////wEAAAAAAIAL/gMQAAAAAAAAAAAAAAAAAAAAAAAA4P///wEAAAAAAADA/////wMAAAAAAMAM+AMAAAAAAAAAAAAAAAAAAAAAAAAAgP///wEAAAAAAADA/////wcAAAAAAGAG4AEAAAAAAAAAAAAAAAAAAAAAAAAAgP///wAAAAAAEAD8/////w8AAAAAADAGwAcAAAAAAAAAAAAAAAAAAAAAAAAAwP//fwAAAAAA/A/+/////x8AAAAAAAAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAgP//AwAAAAAA/v///////x8AAAAwAAADAAMBAAAAAAAAAAAAAAAAAAAAAAAAyP//AQAAAACA/////////z8AAAAwAIAAAEAHAAAAAAAAAAAAAAAAAAAAAAAAz///AAAAAACA/////////z8AAAASAMAAAIACAAAAAAAAAAAAAAAAAAAAAAAAE+9/AAAAAADA/////////38AAAAXAEAgAAQCAAAAAAAAAAAAAAAAAAAAAADAAe9TAAAAAADg/////////34AAAAPAEBwAAgAAAAAAAAAAAAAAAAAAAAAAADAAAgAAAAAAADw////////f2AAAAAPAID4AUACAAAAAAAAAAAAAAAAAAAAAADgAQAAAAAAAAD4////////fwAAAIAPAMD8AQABAAAAAAAAAAAAAAAAAAAAAAD8AAAAAAAAAAD4////////vwcAAIAPAMD/AcAAAAAAAAAAAAAAAAAAAAAAAAD/AQAAAAAAAAD4////////nx8AAMAPAMD/ATAAAAAAAAAAAAAAAAAAAAAAAID/AAAAAAAAAAD4////////j/8AAMAPAMD/ATAAAAAAAAAAAAAAAAAAAAAAAP4PAAAAAAAAAAD4////////h/8BAOA/APz/ADAAAAAAAAAAAAAAAAAAAAAAgP8PAAAAAAAAAADw////////x/8HAOB/APx/ADAAAAAAAAAAAAAAAAAAAAAA8J8PAPwCAAAAAADw////////4/8fAOD/APw/AgAAAAAAAAAAAAAAAQAAAAAA+A8eADgAAAAAAADw////////4f8/AOD/Afw/BgAAAAAAAAAAAAAAAAAAAAAA/AccgAEAAAAAAADw////////8f9/AOD/B/5/AAAAAAAAAAAAAAAAAAAAAAAA+AcAYAAAAAAAAAD4////////+f9/APz/B///BgAAAAAAAAAAAAAAAAAAAAAA/AMAHQAAAAAAAADw////////+P//APz/f///fxAAAAAAAAAAAAAAAAAAAAAA/gMAAAAAAAAAAADw////////+P9/AP///////xEAAAAAAAAAAAAAAAAAAAAQ/wMAAAAAAAAAAADg//////9//n8cgP///////ycAAAAAAAAAAAAAAAAAAACQ/wcACAAAAAAAAADg//////9//r+A/////////wcAAAAAAAAAAAAAAAAAAACI/wcALAAAAAAAAADA//////8//z/g/////////w8AAAAAAAAAAAAAAAAAAADu/wcADgAAAAAAAACA//////8f/x/+/////////x8AAAAAAAAAAAAAAAAAAAD0/w8ABgAAAAAAAAAA/v////+//4///////////z8AAAAAAAAAAAAAAAAAAADy/x8GBgAAAAAAAAAA/P/////v/8///////////z8AAAAAAAAAAAAAAAAAAAD5////BwAAAAAAAAAA/P//f////////////////x8AAAAAAAAAAAAAAAAAAID9////BwAAAAAAAAAA/P//D3+E/////////////z9AAAAAAAAAAAAAAAAAAID/////DwAAAAAAAAAA+P//BwaA/////////////x/AAAAAAAAAAAAAAAAAAMD/////HwAAAAAAAAAA8P9/AACA/////////////x/AAwAAAAAAAAAAAAAAAPD/////fwAAAAAAAAAA4P8/AAAA/////////////w+EGwAAAAAAAAAAAAAAAPj//////wAAAAAAAAAAQPx/AAAA/////////////w8Y/gEAAAAAAAAAAAAAAPz//////wAAAAAAAAAAQOB/AAQ2/////////////x8c8AEAAAAAAAAAAAAAAP7//////wAAAAAAAAAA+AcABob//z/8/////////zccwAEAAAAAAAAAAAAAAP7//////wEAAAAAAAAA+A8AAM7//x/8/////////wMOAAEAAAAAAAAAAAAAAP///////wMAAAAAAAAA+A8wEMf//x/+/////////0cOAAMAAAAAAAAAAAAAAP///////wMAAAAAAAAA+B8wuE/+/z/+/////////98fAAMAAAAAAAAAAAAAAP///////x8AAAAAAAAA+D8Aj//w4R/8//////////8/AAAAAAAAAAAAAAAAAP///////x8AAAAAAAAA+H+Aw/8AwA/+//////////9/AA8AAAAAAAAAAAAAAP///////z8AAAAAAAAAcPzH8/8A8I//////////////Bx4AAAAAAAAAAAAAAP////////8MAAAAAAAAAPj/+P8B/Mf/////////////DwQAAAAAAAAAAAAAAP////////9/AAAAAAAAAPj//f9j/g/+////////////HwAAAAAAAAAAAAAAAP////////+XAAAAAAAAAPz///93/D/+////////////PwwAAAAAAAAAAAAAAP3///////8HUAAAAAAAAP7/////////////////////fwQAAAAAAAAAAAAAAP7//////38HfgAAAAAAgP///////////////////////wQAAAAAAAAAAAAAYP////////8xLAAAAAAAAPz//////////////////////wwAAAAAAAAAAAAA0P//////////DAAAAAAAgOH//////////////////////w0AAAAAAAAAAAAA8P//////7///FwAAAAAAAB///////////////////////wUAAgAAAAAAAAAA8P//////4///DwAAAAAAGD///////////////////////wUAAwAAAAAAAACA+P//////4///DwAAAAAAOA74/////////////////////wUADwAAAIAAAAAA/v//////8///BwAAAAAAOAcgcP//////////////////HwAAHwAAAAAGAAAA//////8/wP//AAAAAAAAwAOwA/7/////////////////DwCAPwAAAAAwAAAA//////8PgP8/AAAAAAAAwAFwD/7/////////////////PwAAfwAAAADADgDA/////38AgP8/AAAAAAAAwANAH/T//////////////////wAAfgAAAACAAwD8/////38AwP8eAAAAAAAAgAGcH/D//////////////////wEAOAAAAAD8MwD//////x8AwH8MAAAAAAAAAAD+P2D///////////////////95cAAAAID///z//////z8AwD8AAMABAAAAAAD+P/z///////////////////9/wH8AAMD//////////z8AwA8AAPgBAAAAAAD+H/7/////////////////////Of8BAID///////////8AQ4ABAPwBAAAAAAD8P/7///////////////////////9fAAP4///////////BBPAHAP4HAAAAAADg//z///////////////////////9/QID4///////////Pw/0DAP8HAMAfAACA//F//v////////////////////8//vD///////////9fAPwYgP8PAOA/AAAA/+N/8P//////////////////////34H8////////////Afw/gP//AQAQAAAA/v8fH////+//////////////////DwD////////////vh/kPwP//BwAAAAAA/P//H/P//5//////////////////A+D///////8DB8TPB/4AAP///wAAAAAA8P//AwDjf77/////////////////AAD+///h/4//H+/Bg/8BwP7//w8AAAAAwP8fAAAAj9///////////////88/AAD4HwAAAAD4H/D4/38A4P///xMAAAAAAPAHAAAAgN//////////////DwAAAQAAAAAAAO//B3f8/wsA4P///z8AAAAAAAAAAAAPAG////////8f2f8HAAAAAAAAAAAAgN9/xzf8RwAA4P///z8AAAAAAAAAAAAPAB7g//////8fgD8AAAAAAAAAAAAAAP8Ahvc5OwAA8P///38AAAAAAAAAAAAcAADg////34cHAAcAAAAAAAAAAAAAAAAMAAB8AgAA+P////8AAAAAAAAAAABwAAAA/P//AwAAAAAAAAAAAAAAAAAAAIC/g7PfBwAA/v////8AAAAAAAAAAADgBwAAwP//PwAA4B8AAAAAAAAAAAAAADzAgPP5H8D//////38AAAAAAAAAAAAA4AEAAAD+DwAAAAAAAAAAAAAAAAAAAOAQACDwP4D///////8BAAAAPAQAAAAAAAAAAAAYAAAAAAAAAAAAAAAAAAAAAAA4+I73//n///////8AAAAAfwAAAAAAAAAAAAAfAAAAAAAAAAAAAAAAAAAAAAAAAOD//wP8//////8BAACAfx4AAAAAAAAAAP4AAAAAAAAAAAAAAAAAAAAAAAAAAPAH/j/+//////8PAAAAgB0AAHgAAAAAAH8AAAAAAAAAAAAAAAAAAAAAAAAAAAD+///D/////5//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADA/v8/AOD//z8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADg/wEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
3619
+ const LAND_MASK_WIDTH = 360;
3620
+ const landMask = Uint8Array.from(atob(LAND_MASK_BASE64), (value) => value.charCodeAt(0));
3621
+ function isCanonicalLand(longitude, latitude) {
3622
+ const column = Math.max(0, Math.min(359, Math.floor(longitude + 180)));
3623
+ const index = Math.max(0, Math.min(179, Math.floor(latitude + 90))) * LAND_MASK_WIDTH + column;
3624
+ return (landMask[index >> 3] & 1 << (index & 7)) !== 0;
3625
+ }
3626
+ //#endregion
3627
+ //#region src/components/chart/GlobeMap.tsx
3628
+ const GLOBE_VIEWBOX_SIZE = 640;
3629
+ const GLOBE_RADIUS = GLOBE_VIEWBOX_SIZE / 2 - 18;
3630
+ const MARKER_EDGE_FADE_DISTANCE = 24;
3631
+ const AUTO_ROTATE_INTERVAL = 1e3 / 30;
3632
+ function finiteNumber(value, fallback) {
3633
+ return Number.isFinite(value) ? value : fallback;
3634
+ }
3635
+ function normalizeRotation(rotation) {
3636
+ return [
3637
+ finiteNumber(rotation[0], -10),
3638
+ Math.max(-90, Math.min(90, finiteNumber(rotation[1], -20))),
3639
+ finiteNumber(rotation[2], 0)
3640
+ ];
3641
+ }
3642
+ function createLandHatchPath(projection, spacing) {
3643
+ if (spacing <= 0) return void 0;
3644
+ if (!projection.invert) return void 0;
3645
+ const commands = [];
3646
+ const sampleStep = 3;
3647
+ for (let offset = -640; offset < GLOBE_VIEWBOX_SIZE * 2; offset += spacing) {
3648
+ let drawing = false;
3649
+ for (let y = 0; y <= GLOBE_VIEWBOX_SIZE; y += sampleStep) {
3650
+ const x = y + offset;
3651
+ const coordinates = x >= 0 && x <= GLOBE_VIEWBOX_SIZE ? projection.invert?.([x, y]) : null;
3652
+ const onLand = coordinates !== null && isCanonicalLand(coordinates[0], coordinates[1]);
3653
+ if (onLand && !drawing) {
3654
+ commands.push(`M${x.toFixed(1)},${y.toFixed(1)}`);
3655
+ drawing = true;
3656
+ } else if (onLand) commands.push(`L${x.toFixed(1)},${y.toFixed(1)}`);
3657
+ else drawing = false;
3658
+ }
3659
+ }
3660
+ return commands.join("") || void 0;
3661
+ }
3662
+ /**
3663
+ * GlobeMap — an SVG orthographic globe with hatched land and geographic
3664
+ * markers. Rendering is SVG-only and does not use WebGL.
3665
+ */
3666
+ const GlobeMap = forwardRef(function GlobeMap({ landColor, landHatchSpacing = 10, oceanColor = "var(--color-kumo-base)", markers = [], markerColor, markerRadius = 7, onMarkerClick, defaultRotation = [
3667
+ -10,
3668
+ -20,
3669
+ 0
3670
+ ], draggable = true, autoRotate = false, autoRotateSpeed = 4, showGraticule = false, showTooltip = true, onUserRotationChange, "aria-label": ariaLabel = "Interactive globe map", height, className, isDarkMode }, ref) {
3671
+ const [rotation, setRotation] = useState(() => normalizeRotation(defaultRotation));
3672
+ const [tooltip, setTooltip] = useState(null);
3673
+ const sphereClipId = useId();
3674
+ const rotationRef = useRef(rotation);
3675
+ const svgRef = useRef(null);
3676
+ const dragRef = useRef(null);
3677
+ const isFocusedRef = useRef(false);
3678
+ const pointerMoveFrameRef = useRef(null);
3679
+ const pendingPointerMoveRef = useRef(null);
3680
+ const instructionsId = useId();
3681
+ const palette = useMemo(() => ChartPalette.mapColors(isDarkMode), [isDarkMode]);
3682
+ const resolvedLandColor = landColor ?? palette.area;
3683
+ const resolvedMarkerColor = markerColor ?? palette.bubble;
3684
+ const safeHatchSpacing = Math.max(3, finiteNumber(landHatchSpacing, 10));
3685
+ const safeMarkerRadius = Math.max(0, finiteNumber(markerRadius, 7));
3686
+ const safeAutoRotateSpeed = Math.max(-60, Math.min(60, finiteNumber(autoRotateSpeed, 4)));
3687
+ const projection = useMemo(() => orthographic_default().translate([GLOBE_VIEWBOX_SIZE / 2, GLOBE_VIEWBOX_SIZE / 2]).scale(GLOBE_RADIUS).clipAngle(90).rotate(rotation), [rotation]);
3688
+ const path = useMemo(() => path_default(projection), [projection]);
3689
+ const spherePath = useMemo(() => path({ type: "Sphere" }) ?? void 0, [path]);
3690
+ const graticulePath = useMemo(() => path(graticule10()) ?? void 0, [path]);
3691
+ const landHatchPath = useMemo(() => createLandHatchPath(projection, safeHatchSpacing), [projection, safeHatchSpacing]);
3692
+ const center = useMemo(() => projection.invert?.([GLOBE_VIEWBOX_SIZE / 2, GLOBE_VIEWBOX_SIZE / 2]), [projection]);
3693
+ const updateRotation = useCallback((nextRotation, notify = false) => {
3694
+ rotationRef.current = nextRotation;
3695
+ setRotation(nextRotation);
3696
+ if (notify) onUserRotationChange?.(nextRotation);
3697
+ }, [onUserRotationChange]);
3698
+ useEffect(() => {
3699
+ if (!autoRotate) return;
3700
+ if (typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches) return;
3701
+ let frame = null;
3702
+ let previousTime = null;
3703
+ const rotate = (time) => {
3704
+ if (dragRef.current || isFocusedRef.current) previousTime = time;
3705
+ else if (previousTime !== null && time - previousTime >= AUTO_ROTATE_INTERVAL) {
3706
+ const deltaSeconds = Math.min((time - previousTime) / 1e3, .1);
3707
+ const current = rotationRef.current;
3708
+ updateRotation([
3709
+ current[0] + safeAutoRotateSpeed * deltaSeconds,
3710
+ current[1],
3711
+ current[2]
3712
+ ]);
3713
+ previousTime = time;
3714
+ }
3715
+ if (previousTime === null) previousTime = time;
3716
+ frame = requestAnimationFrame(rotate);
3717
+ };
3718
+ const start = () => {
3719
+ if (frame === null) frame = requestAnimationFrame(rotate);
3720
+ };
3721
+ const stop = () => {
3722
+ if (frame !== null) cancelAnimationFrame(frame);
3723
+ frame = null;
3724
+ previousTime = null;
3725
+ };
3726
+ const observer = typeof IntersectionObserver === "undefined" ? null : new IntersectionObserver(([entry]) => {
3727
+ if (entry?.isIntersecting) start();
3728
+ else stop();
3729
+ });
3730
+ if (observer && svgRef.current) observer.observe(svgRef.current);
3731
+ else start();
3732
+ return () => {
3733
+ observer?.disconnect();
3734
+ stop();
3735
+ };
3736
+ }, [
3737
+ autoRotate,
3738
+ safeAutoRotateSpeed,
3739
+ updateRotation
3740
+ ]);
3741
+ const moveTooltip = useCallback((event, marker) => {
3742
+ if (!showTooltip) return;
3743
+ const bounds = event.currentTarget.ownerSVGElement?.getBoundingClientRect();
3744
+ if (!bounds) return;
3745
+ setTooltip({
3746
+ name: marker.name,
3747
+ detail: marker.description ?? `${marker.latitude.toFixed(2)}, ${marker.longitude.toFixed(2)}`,
3748
+ x: event.clientX - bounds.left,
3749
+ y: event.clientY - bounds.top
3750
+ });
3751
+ }, [showTooltip]);
3752
+ const handlePointerDown = (event) => {
3753
+ if (!draggable) return;
3754
+ if (event.isPrimary === false || event.button !== 0) return;
3755
+ if (event.target instanceof Element && event.target.closest("[data-globe-marker-interactive=\"true\"]")) return;
3756
+ event.currentTarget.setPointerCapture(event.pointerId);
3757
+ dragRef.current = {
3758
+ pointerId: event.pointerId,
3759
+ x: event.clientX,
3760
+ y: event.clientY,
3761
+ rotation: rotationRef.current
3762
+ };
3763
+ setTooltip(null);
3764
+ };
3765
+ const applyPointerMove = useCallback((pointerId, x, y) => {
3766
+ const drag = dragRef.current;
3767
+ if (!drag || drag.pointerId !== pointerId) return;
3768
+ const deltaX = x - drag.x;
3769
+ const deltaY = y - drag.y;
3770
+ updateRotation([
3771
+ drag.rotation[0] + deltaX * .3,
3772
+ Math.max(-90, Math.min(90, drag.rotation[1] - deltaY * .3)),
3773
+ drag.rotation[2]
3774
+ ], true);
3775
+ }, [updateRotation]);
3776
+ const handlePointerMove = (event) => {
3777
+ const drag = dragRef.current;
3778
+ if (!drag || drag.pointerId !== event.pointerId) return;
3779
+ pendingPointerMoveRef.current = {
3780
+ pointerId: event.pointerId,
3781
+ x: event.clientX,
3782
+ y: event.clientY
3783
+ };
3784
+ if (pointerMoveFrameRef.current !== null) return;
3785
+ pointerMoveFrameRef.current = requestAnimationFrame(() => {
3786
+ pointerMoveFrameRef.current = null;
3787
+ const pending = pendingPointerMoveRef.current;
3788
+ pendingPointerMoveRef.current = null;
3789
+ if (pending) applyPointerMove(pending.pointerId, pending.x, pending.y);
3790
+ });
3791
+ };
3792
+ const finishPointerDrag = (event) => {
3793
+ if (dragRef.current?.pointerId !== event.pointerId) return;
3794
+ if (pointerMoveFrameRef.current !== null) {
3795
+ cancelAnimationFrame(pointerMoveFrameRef.current);
3796
+ pointerMoveFrameRef.current = null;
3797
+ }
3798
+ const pending = pendingPointerMoveRef.current;
3799
+ pendingPointerMoveRef.current = null;
3800
+ if (pending) applyPointerMove(pending.pointerId, pending.x, pending.y);
3801
+ dragRef.current = null;
3802
+ if (event.currentTarget.hasPointerCapture?.(event.pointerId)) event.currentTarget.releasePointerCapture(event.pointerId);
3803
+ };
3804
+ useEffect(() => () => {
3805
+ if (pointerMoveFrameRef.current !== null) cancelAnimationFrame(pointerMoveFrameRef.current);
3806
+ }, []);
3807
+ return /* @__PURE__ */ jsxs("div", {
3808
+ ref,
3809
+ className: cn("relative w-full overflow-hidden", className),
3810
+ style: height === void 0 ? { aspectRatio: "1" } : { height },
3811
+ onFocusCapture: () => {
3812
+ isFocusedRef.current = true;
3813
+ },
3814
+ onBlurCapture: (event) => {
3815
+ if (!event.currentTarget.contains(event.relatedTarget)) isFocusedRef.current = false;
3816
+ },
3817
+ children: [
3818
+ draggable ? /* @__PURE__ */ jsx("span", {
3819
+ id: instructionsId,
3820
+ className: "sr-only",
3821
+ children: "Use the arrow keys to rotate the globe."
3822
+ }) : null,
3823
+ /* @__PURE__ */ jsxs("svg", {
3824
+ ref: svgRef,
3825
+ role: "group",
3826
+ "aria-label": ariaLabel,
3827
+ "aria-describedby": draggable ? instructionsId : void 0,
3828
+ tabIndex: draggable ? 0 : void 0,
3829
+ viewBox: `0 0 ${GLOBE_VIEWBOX_SIZE} ${GLOBE_VIEWBOX_SIZE}`,
3830
+ className: cn("block size-full touch-none select-none", draggable && "cursor-grab active:cursor-grabbing"),
3831
+ onPointerDown: handlePointerDown,
3832
+ onPointerMove: handlePointerMove,
3833
+ onPointerUp: finishPointerDrag,
3834
+ onPointerCancel: finishPointerDrag,
3835
+ onLostPointerCapture: (event) => {
3836
+ if (dragRef.current?.pointerId === event.pointerId) dragRef.current = null;
3837
+ },
3838
+ onKeyDown: (event) => {
3839
+ if (!draggable || event.target !== event.currentTarget) return;
3840
+ if (event.key !== "ArrowLeft" && event.key !== "ArrowRight" && event.key !== "ArrowUp" && event.key !== "ArrowDown") return;
3841
+ event.preventDefault();
3842
+ const [longitude, latitude, roll] = rotationRef.current;
3843
+ const nextRotation = event.key === "ArrowLeft" ? [
3844
+ longitude - 10,
3845
+ latitude,
3846
+ roll
3847
+ ] : event.key === "ArrowRight" ? [
3848
+ longitude + 10,
3849
+ latitude,
3850
+ roll
3851
+ ] : event.key === "ArrowUp" ? [
3852
+ longitude,
3853
+ Math.min(90, latitude + 10),
3854
+ roll
3855
+ ] : event.key === "ArrowDown" ? [
3856
+ longitude,
3857
+ Math.max(-90, latitude - 10),
3858
+ roll
3859
+ ] : [
3860
+ longitude,
3861
+ latitude,
3862
+ roll
3863
+ ];
3864
+ if (nextRotation[0] === longitude && nextRotation[1] === latitude) return;
3865
+ updateRotation(nextRotation, true);
3866
+ },
3867
+ onPointerLeave: () => {
3868
+ if (!dragRef.current) setTooltip(null);
3869
+ },
3870
+ children: [
3871
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("clipPath", {
3872
+ id: sphereClipId,
3873
+ children: /* @__PURE__ */ jsx("path", { d: spherePath })
3874
+ }) }),
3875
+ /* @__PURE__ */ jsx("path", {
3876
+ d: spherePath,
3877
+ fill: oceanColor,
3878
+ className: "stroke-kumo-line",
3879
+ strokeWidth: 1.5
3880
+ }),
3881
+ showGraticule ? /* @__PURE__ */ jsx("path", {
3882
+ d: graticulePath,
3883
+ fill: "none",
3884
+ className: "stroke-kumo-line",
3885
+ strokeWidth: .75
3886
+ }) : null,
3887
+ /* @__PURE__ */ jsx("path", {
3888
+ "data-land-style": "hatched",
3889
+ d: landHatchPath,
3890
+ fill: "none",
3891
+ stroke: resolvedLandColor,
3892
+ strokeWidth: 1.25,
3893
+ strokeLinecap: "round",
3894
+ strokeLinejoin: "round",
3895
+ clipPath: `url(#${sphereClipId})`,
3896
+ className: "pointer-events-none"
3897
+ }),
3898
+ /* @__PURE__ */ jsx("path", {
3899
+ "data-globe-outline": "",
3900
+ d: spherePath,
3901
+ fill: "none",
3902
+ className: "pointer-events-none stroke-kumo-line",
3903
+ strokeWidth: 2
3904
+ }),
3905
+ markers.map((marker, index) => {
3906
+ const position = projection([marker.longitude, marker.latitude]);
3907
+ const isVisible = center && distance_default(center, [marker.longitude, marker.latitude]) <= Math.PI / 2;
3908
+ const detail = marker.description ?? `${marker.latitude.toFixed(2)}, ${marker.longitude.toFixed(2)}`;
3909
+ const activateMarker = () => {
3910
+ onMarkerClick?.(marker);
3911
+ };
3912
+ if (!position || !isVisible) return null;
3913
+ const isInteractive = onMarkerClick !== void 0;
3914
+ const distanceFromCenter = Math.hypot(position[0] - GLOBE_VIEWBOX_SIZE / 2, position[1] - GLOBE_VIEWBOX_SIZE / 2);
3915
+ const edgeOpacity = Math.max(0, Math.min(1, (GLOBE_RADIUS - distanceFromCenter) / MARKER_EDGE_FADE_DISTANCE));
3916
+ return /* @__PURE__ */ jsx("circle", {
3917
+ cx: position[0],
3918
+ cy: position[1],
3919
+ r: Math.max(0, finiteNumber(marker.radius ?? safeMarkerRadius, safeMarkerRadius)),
3920
+ fill: marker.color ?? resolvedMarkerColor,
3921
+ opacity: edgeOpacity,
3922
+ className: "stroke-kumo-base transition-opacity outline-none",
3923
+ strokeWidth: 2,
3924
+ "data-globe-marker": "",
3925
+ "data-globe-marker-interactive": isInteractive,
3926
+ role: isInteractive ? "button" : void 0,
3927
+ "aria-label": isInteractive ? `${marker.name}: ${detail}` : void 0,
3928
+ "aria-hidden": isInteractive ? void 0 : true,
3929
+ tabIndex: isInteractive ? 0 : void 0,
3930
+ onPointerEnter: (event) => moveTooltip(event, marker),
3931
+ onPointerMove: (event) => {
3932
+ if (!dragRef.current) moveTooltip(event, marker);
3933
+ },
3934
+ onPointerLeave: () => setTooltip(null),
3935
+ onFocus: (event) => {
3936
+ if (!showTooltip) return;
3937
+ const svgBounds = event.currentTarget.ownerSVGElement?.getBoundingClientRect();
3938
+ if (!svgBounds) return;
3939
+ const markerBounds = event.currentTarget.getBoundingClientRect();
3940
+ setTooltip({
3941
+ name: marker.name,
3942
+ detail,
3943
+ x: markerBounds.left + markerBounds.width / 2 - svgBounds.left,
3944
+ y: markerBounds.top - svgBounds.top
3945
+ });
3946
+ },
3947
+ onBlur: () => setTooltip(null),
3948
+ onClick: isInteractive ? activateMarker : void 0,
3949
+ onKeyDown: isInteractive ? (event) => {
3950
+ if (event.key !== "Enter" && event.key !== " ") return;
3951
+ event.preventDefault();
3952
+ activateMarker();
3953
+ } : void 0
3954
+ }, `${marker.name}-${index}`);
3955
+ })
3956
+ ]
3957
+ }),
3958
+ onMarkerClick === void 0 && markers.length > 0 ? /* @__PURE__ */ jsx("ul", {
3959
+ className: "sr-only",
3960
+ "aria-label": `${ariaLabel} locations`,
3961
+ children: markers.map((marker, index) => /* @__PURE__ */ jsxs("li", { children: [
3962
+ marker.name,
3963
+ ":",
3964
+ " ",
3965
+ marker.description ?? `${marker.latitude.toFixed(2)}, ${marker.longitude.toFixed(2)}`
3966
+ ] }, `${marker.name}-${index}`))
3967
+ }) : null,
3968
+ tooltip ? /* @__PURE__ */ jsxs("div", {
3969
+ role: "tooltip",
3970
+ className: "pointer-events-none absolute z-10 flex -translate-x-1/2 -translate-y-full flex-col gap-0.5 rounded-lg border border-kumo-line bg-kumo-base px-2 py-1.5 text-xs text-kumo-default shadow-lg",
3971
+ style: {
3972
+ left: tooltip.x,
3973
+ top: tooltip.y - 8
3974
+ },
3975
+ children: [/* @__PURE__ */ jsx("strong", { children: tooltip.name }), /* @__PURE__ */ jsx("span", {
3976
+ className: "text-kumo-subtle",
3977
+ children: tooltip.detail
3978
+ })]
3979
+ }) : null
3980
+ ]
3981
+ });
3982
+ });
3983
+ GlobeMap.displayName = "GlobeMap";
3984
+ //#endregion
3985
+ export { ChartLegend as a, ChartPalette as c, SankeyChart as i, BubbleMap as n, TimeseriesChart as o, ChoroplethMap as r, Chart as s, GlobeMap as t };