@toclocoinc/lattice-grid 1.110.2 → 1.110.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (441) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/angular/package.json +1 -1
  4. package/docs/API.html +4 -4
  5. package/docs/api/adapters.html +1 -1
  6. package/docs/api/ai.html +1 -1
  7. package/docs/api/alarms.html +1 -1
  8. package/docs/api/calendar.html +1 -1
  9. package/docs/api/charts.html +1 -1
  10. package/docs/api/dashboard.html +1 -1
  11. package/docs/api/data-router.html +1 -1
  12. package/docs/api/dataview.html +1 -1
  13. package/docs/api/deckgl.html +1 -1
  14. package/docs/api/designer.html +1 -1
  15. package/docs/api/form.html +1 -1
  16. package/docs/api/gantt.html +1 -1
  17. package/docs/api/geometry.html +1 -1
  18. package/docs/api/grid.html +2 -2
  19. package/docs/api/index.html +1 -1
  20. package/docs/api/kanban.html +1 -1
  21. package/docs/api/kpi.html +1 -1
  22. package/docs/api/layout.html +1 -1
  23. package/docs/api/leaflet.html +1 -1
  24. package/docs/api/list.html +1 -1
  25. package/docs/api/listview.html +1 -1
  26. package/docs/api/mapview.html +1 -1
  27. package/docs/api/mock-socket.html +1 -1
  28. package/docs/api/presets.html +1 -1
  29. package/docs/api/scheduler.html +1 -1
  30. package/docs/api/shell.html +1 -1
  31. package/docs/api/tabs.html +1 -1
  32. package/docs/api/tree.html +1 -1
  33. package/docs/api/types.html +1 -1
  34. package/docs/api-detail.html +4 -4
  35. package/docs/warnings.json +1 -1
  36. package/lattice-grid.d.ts +1 -1
  37. package/lattice-grid.esm.min.js +2 -2
  38. package/lattice-grid.min.cjs +2 -2
  39. package/lattice-grid.min.js +2 -2
  40. package/locales/all.d.ts +1 -1
  41. package/locales/all.esm.min.js +1 -1
  42. package/locales/all.min.cjs +1 -1
  43. package/locales/all.min.js +1 -1
  44. package/locales/ar.d.ts +1 -1
  45. package/locales/ar.esm.min.js +1 -1
  46. package/locales/ar.min.cjs +1 -1
  47. package/locales/ar.min.js +1 -1
  48. package/locales/cs-CZ.d.ts +1 -1
  49. package/locales/cs-CZ.esm.min.js +1 -1
  50. package/locales/cs-CZ.min.cjs +1 -1
  51. package/locales/cs-CZ.min.js +1 -1
  52. package/locales/da-DK.d.ts +1 -1
  53. package/locales/da-DK.esm.min.js +1 -1
  54. package/locales/da-DK.min.cjs +1 -1
  55. package/locales/da-DK.min.js +1 -1
  56. package/locales/de-DE.d.ts +1 -1
  57. package/locales/de-DE.esm.min.js +1 -1
  58. package/locales/de-DE.min.cjs +1 -1
  59. package/locales/de-DE.min.js +1 -1
  60. package/locales/el-GR.d.ts +1 -1
  61. package/locales/el-GR.esm.min.js +1 -1
  62. package/locales/el-GR.min.cjs +1 -1
  63. package/locales/el-GR.min.js +1 -1
  64. package/locales/en-US.d.ts +1 -1
  65. package/locales/en-US.esm.min.js +1 -1
  66. package/locales/en-US.min.cjs +1 -1
  67. package/locales/en-US.min.js +1 -1
  68. package/locales/es-ES.d.ts +1 -1
  69. package/locales/es-ES.esm.min.js +1 -1
  70. package/locales/es-ES.min.cjs +1 -1
  71. package/locales/es-ES.min.js +1 -1
  72. package/locales/fi-FI.d.ts +1 -1
  73. package/locales/fi-FI.esm.min.js +1 -1
  74. package/locales/fi-FI.min.cjs +1 -1
  75. package/locales/fi-FI.min.js +1 -1
  76. package/locales/fr-CA.d.ts +1 -1
  77. package/locales/fr-CA.esm.min.js +1 -1
  78. package/locales/fr-CA.min.cjs +1 -1
  79. package/locales/fr-CA.min.js +1 -1
  80. package/locales/fr-FR.d.ts +1 -1
  81. package/locales/fr-FR.esm.min.js +1 -1
  82. package/locales/fr-FR.min.cjs +1 -1
  83. package/locales/fr-FR.min.js +1 -1
  84. package/locales/hu-HU.d.ts +1 -1
  85. package/locales/hu-HU.esm.min.js +1 -1
  86. package/locales/hu-HU.min.cjs +1 -1
  87. package/locales/hu-HU.min.js +1 -1
  88. package/locales/it-IT.d.ts +1 -1
  89. package/locales/it-IT.esm.min.js +1 -1
  90. package/locales/it-IT.min.cjs +1 -1
  91. package/locales/it-IT.min.js +1 -1
  92. package/locales/ja-JP.d.ts +1 -1
  93. package/locales/ja-JP.esm.min.js +1 -1
  94. package/locales/ja-JP.min.cjs +1 -1
  95. package/locales/ja-JP.min.js +1 -1
  96. package/locales/nb-NO.d.ts +1 -1
  97. package/locales/nb-NO.esm.min.js +1 -1
  98. package/locales/nb-NO.min.cjs +1 -1
  99. package/locales/nb-NO.min.js +1 -1
  100. package/locales/nl-NL.d.ts +1 -1
  101. package/locales/nl-NL.esm.min.js +1 -1
  102. package/locales/nl-NL.min.cjs +1 -1
  103. package/locales/nl-NL.min.js +1 -1
  104. package/locales/pl-PL.d.ts +1 -1
  105. package/locales/pl-PL.esm.min.js +1 -1
  106. package/locales/pl-PL.min.cjs +1 -1
  107. package/locales/pl-PL.min.js +1 -1
  108. package/locales/pt-BR.d.ts +1 -1
  109. package/locales/pt-BR.esm.min.js +1 -1
  110. package/locales/pt-BR.min.cjs +1 -1
  111. package/locales/pt-BR.min.js +1 -1
  112. package/locales/ro-RO.d.ts +1 -1
  113. package/locales/ro-RO.esm.min.js +1 -1
  114. package/locales/ro-RO.min.cjs +1 -1
  115. package/locales/ro-RO.min.js +1 -1
  116. package/locales/sv-SE.d.ts +1 -1
  117. package/locales/sv-SE.esm.min.js +1 -1
  118. package/locales/sv-SE.min.cjs +1 -1
  119. package/locales/sv-SE.min.js +1 -1
  120. package/locales/uk-UA.d.ts +1 -1
  121. package/locales/uk-UA.esm.min.js +1 -1
  122. package/locales/uk-UA.min.cjs +1 -1
  123. package/locales/uk-UA.min.js +1 -1
  124. package/modules/ai.d.ts +1 -1
  125. package/modules/ai.esm.min.js +1 -1
  126. package/modules/ai.min.cjs +1 -1
  127. package/modules/ai.min.js +1 -1
  128. package/modules/alarms.d.ts +1 -1
  129. package/modules/alarms.esm.min.js +1 -1
  130. package/modules/alarms.min.cjs +1 -1
  131. package/modules/alarms.min.js +1 -1
  132. package/modules/angular.d.ts +1 -1
  133. package/modules/angular.esm.min.js +1 -1
  134. package/modules/angular.min.cjs +1 -1
  135. package/modules/angular.min.js +1 -1
  136. package/modules/calendar.d.ts +1 -1
  137. package/modules/calendar.esm.min.js +1 -1
  138. package/modules/calendar.min.cjs +1 -1
  139. package/modules/calendar.min.js +1 -1
  140. package/modules/chart-alluvial.d.ts +1 -1
  141. package/modules/chart-alluvial.esm.min.js +1 -1
  142. package/modules/chart-alluvial.min.cjs +1 -1
  143. package/modules/chart-alluvial.min.js +1 -1
  144. package/modules/chart-arc.d.ts +1 -1
  145. package/modules/chart-arc.esm.min.js +1 -1
  146. package/modules/chart-arc.min.cjs +1 -1
  147. package/modules/chart-arc.min.js +1 -1
  148. package/modules/chart-barrace.d.ts +1 -1
  149. package/modules/chart-barrace.esm.min.js +1 -1
  150. package/modules/chart-barrace.min.cjs +1 -1
  151. package/modules/chart-barrace.min.js +1 -1
  152. package/modules/chart-bubblemap.d.ts +1 -1
  153. package/modules/chart-bubblemap.esm.min.js +1 -1
  154. package/modules/chart-bubblemap.min.cjs +1 -1
  155. package/modules/chart-bubblemap.min.js +1 -1
  156. package/modules/chart-bump.d.ts +1 -1
  157. package/modules/chart-bump.esm.min.js +1 -1
  158. package/modules/chart-bump.min.cjs +1 -1
  159. package/modules/chart-bump.min.js +1 -1
  160. package/modules/chart-calendar.d.ts +1 -1
  161. package/modules/chart-calendar.esm.min.js +1 -1
  162. package/modules/chart-calendar.min.cjs +1 -1
  163. package/modules/chart-calendar.min.js +1 -1
  164. package/modules/chart-choropleth.d.ts +1 -1
  165. package/modules/chart-choropleth.esm.min.js +1 -1
  166. package/modules/chart-choropleth.min.cjs +1 -1
  167. package/modules/chart-choropleth.min.js +1 -1
  168. package/modules/chart-decomposition.d.ts +1 -1
  169. package/modules/chart-decomposition.esm.min.js +1 -1
  170. package/modules/chart-decomposition.min.cjs +1 -1
  171. package/modules/chart-decomposition.min.js +1 -1
  172. package/modules/chart-diverging.d.ts +1 -1
  173. package/modules/chart-diverging.esm.min.js +1 -1
  174. package/modules/chart-diverging.min.cjs +1 -1
  175. package/modules/chart-diverging.min.js +1 -1
  176. package/modules/chart-dumbbell.d.ts +1 -1
  177. package/modules/chart-dumbbell.esm.min.js +1 -1
  178. package/modules/chart-dumbbell.min.cjs +1 -1
  179. package/modules/chart-dumbbell.min.js +1 -1
  180. package/modules/chart-fan.d.ts +1 -1
  181. package/modules/chart-fan.esm.min.js +1 -1
  182. package/modules/chart-fan.min.cjs +1 -1
  183. package/modules/chart-fan.min.js +1 -1
  184. package/modules/chart-forcetree.d.ts +1 -1
  185. package/modules/chart-forcetree.esm.min.js +1 -1
  186. package/modules/chart-forcetree.min.cjs +1 -1
  187. package/modules/chart-forcetree.min.js +1 -1
  188. package/modules/chart-hexbin.d.ts +1 -1
  189. package/modules/chart-hexbin.esm.min.js +1 -1
  190. package/modules/chart-hexbin.min.cjs +1 -1
  191. package/modules/chart-hexbin.min.js +1 -1
  192. package/modules/chart-hexmap.d.ts +1 -1
  193. package/modules/chart-hexmap.esm.min.js +1 -1
  194. package/modules/chart-hexmap.min.cjs +1 -1
  195. package/modules/chart-hexmap.min.js +1 -1
  196. package/modules/chart-icicle.d.ts +1 -1
  197. package/modules/chart-icicle.esm.min.js +1 -1
  198. package/modules/chart-icicle.min.cjs +1 -1
  199. package/modules/chart-icicle.min.js +1 -1
  200. package/modules/chart-markermap.d.ts +1 -1
  201. package/modules/chart-markermap.esm.min.js +1 -1
  202. package/modules/chart-markermap.min.cjs +1 -1
  203. package/modules/chart-markermap.min.js +1 -1
  204. package/modules/chart-motion.d.ts +1 -1
  205. package/modules/chart-motion.esm.min.js +1 -1
  206. package/modules/chart-motion.min.cjs +1 -1
  207. package/modules/chart-motion.min.js +1 -1
  208. package/modules/chart-pack.d.ts +1 -1
  209. package/modules/chart-pack.esm.min.js +1 -1
  210. package/modules/chart-pack.min.cjs +1 -1
  211. package/modules/chart-pack.min.js +1 -1
  212. package/modules/chart-parallel.d.ts +1 -1
  213. package/modules/chart-parallel.esm.min.js +1 -1
  214. package/modules/chart-parallel.min.cjs +1 -1
  215. package/modules/chart-parallel.min.js +1 -1
  216. package/modules/chart-pictorial.d.ts +1 -1
  217. package/modules/chart-pictorial.esm.min.js +1 -1
  218. package/modules/chart-pictorial.min.cjs +1 -1
  219. package/modules/chart-pictorial.min.js +1 -1
  220. package/modules/chart-polararea.d.ts +1 -1
  221. package/modules/chart-polararea.esm.min.js +1 -1
  222. package/modules/chart-polararea.min.cjs +1 -1
  223. package/modules/chart-polararea.min.js +1 -1
  224. package/modules/chart-polarscatter.d.ts +1 -1
  225. package/modules/chart-polarscatter.esm.min.js +1 -1
  226. package/modules/chart-polarscatter.min.cjs +1 -1
  227. package/modules/chart-polarscatter.min.js +1 -1
  228. package/modules/chart-pyramid.d.ts +1 -1
  229. package/modules/chart-pyramid.esm.min.js +1 -1
  230. package/modules/chart-pyramid.min.cjs +1 -1
  231. package/modules/chart-pyramid.min.js +1 -1
  232. package/modules/chart-radialbar.d.ts +1 -1
  233. package/modules/chart-radialbar.esm.min.js +1 -1
  234. package/modules/chart-radialbar.min.cjs +1 -1
  235. package/modules/chart-radialbar.min.js +1 -1
  236. package/modules/chart-ridgeline.d.ts +1 -1
  237. package/modules/chart-ridgeline.esm.min.js +1 -1
  238. package/modules/chart-ridgeline.min.cjs +1 -1
  239. package/modules/chart-ridgeline.min.js +1 -1
  240. package/modules/chart-roc.d.ts +1 -1
  241. package/modules/chart-roc.esm.min.js +1 -1
  242. package/modules/chart-roc.min.cjs +1 -1
  243. package/modules/chart-roc.min.js +1 -1
  244. package/modules/chart-scatter3d.d.ts +1 -1
  245. package/modules/chart-scatter3d.esm.min.js +1 -1
  246. package/modules/chart-scatter3d.min.cjs +1 -1
  247. package/modules/chart-scatter3d.min.js +1 -1
  248. package/modules/chart-serpentine.d.ts +1 -1
  249. package/modules/chart-serpentine.esm.min.js +1 -1
  250. package/modules/chart-serpentine.min.cjs +1 -1
  251. package/modules/chart-serpentine.min.js +1 -1
  252. package/modules/chart-slope.d.ts +1 -1
  253. package/modules/chart-slope.esm.min.js +1 -1
  254. package/modules/chart-slope.min.cjs +1 -1
  255. package/modules/chart-slope.min.js +1 -1
  256. package/modules/chart-spiral.d.ts +1 -1
  257. package/modules/chart-spiral.esm.min.js +1 -1
  258. package/modules/chart-spiral.min.cjs +1 -1
  259. package/modules/chart-spiral.min.js +1 -1
  260. package/modules/chart-splom.d.ts +1 -1
  261. package/modules/chart-splom.esm.min.js +1 -1
  262. package/modules/chart-splom.min.cjs +1 -1
  263. package/modules/chart-splom.min.js +1 -1
  264. package/modules/chart-tree.d.ts +1 -1
  265. package/modules/chart-tree.esm.min.js +1 -1
  266. package/modules/chart-tree.min.cjs +1 -1
  267. package/modules/chart-tree.min.js +1 -1
  268. package/modules/chart-venn.d.ts +1 -1
  269. package/modules/chart-venn.esm.min.js +1 -1
  270. package/modules/chart-venn.min.cjs +1 -1
  271. package/modules/chart-venn.min.js +1 -1
  272. package/modules/chart-voronoi.d.ts +1 -1
  273. package/modules/chart-voronoi.esm.min.js +1 -1
  274. package/modules/chart-voronoi.min.cjs +1 -1
  275. package/modules/chart-voronoi.min.js +1 -1
  276. package/modules/chart-waffle.d.ts +1 -1
  277. package/modules/chart-waffle.esm.min.js +1 -1
  278. package/modules/chart-waffle.min.cjs +1 -1
  279. package/modules/chart-waffle.min.js +1 -1
  280. package/modules/chart-wordcloud.d.ts +1 -1
  281. package/modules/chart-wordcloud.esm.min.js +1 -1
  282. package/modules/chart-wordcloud.min.cjs +1 -1
  283. package/modules/chart-wordcloud.min.js +1 -1
  284. package/modules/charts.d.ts +1 -1
  285. package/modules/charts.esm.min.js +1 -1
  286. package/modules/charts.min.cjs +1 -1
  287. package/modules/charts.min.js +1 -1
  288. package/modules/contextmenu.d.ts +1 -1
  289. package/modules/contextmenu.esm.min.js +1 -1
  290. package/modules/contextmenu.min.cjs +1 -1
  291. package/modules/contextmenu.min.js +1 -1
  292. package/modules/dashboard.d.ts +1 -1
  293. package/modules/dashboard.esm.min.js +1 -1
  294. package/modules/dashboard.min.cjs +1 -1
  295. package/modules/dashboard.min.js +1 -1
  296. package/modules/data-router.d.ts +1 -1
  297. package/modules/data-router.esm.min.js +1 -1
  298. package/modules/data-router.min.cjs +1 -1
  299. package/modules/data-router.min.js +1 -1
  300. package/modules/dataview.d.ts +1 -1
  301. package/modules/dataview.esm.min.js +1 -1
  302. package/modules/dataview.min.cjs +1 -1
  303. package/modules/dataview.min.js +1 -1
  304. package/modules/deckgl.d.ts +1 -1
  305. package/modules/deckgl.esm.min.js +1 -1
  306. package/modules/deckgl.min.cjs +1 -1
  307. package/modules/deckgl.min.js +1 -1
  308. package/modules/designer.d.ts +1 -1
  309. package/modules/designer.esm.min.js +1 -1
  310. package/modules/designer.min.cjs +1 -1
  311. package/modules/designer.min.js +1 -1
  312. package/modules/devtools.d.ts +1 -1
  313. package/modules/devtools.esm.min.js +1 -1
  314. package/modules/devtools.min.cjs +1 -1
  315. package/modules/devtools.min.js +1 -1
  316. package/modules/dhtmlx-compat.d.ts +1 -1
  317. package/modules/dhtmlx-compat.esm.min.js +1 -1
  318. package/modules/dhtmlx-compat.min.cjs +1 -1
  319. package/modules/dhtmlx-compat.min.js +1 -1
  320. package/modules/form.d.ts +1 -1
  321. package/modules/form.esm.min.js +1 -1
  322. package/modules/form.min.cjs +1 -1
  323. package/modules/form.min.js +1 -1
  324. package/modules/gantt.d.ts +1 -1
  325. package/modules/gantt.esm.min.js +1 -1
  326. package/modules/gantt.min.cjs +1 -1
  327. package/modules/gantt.min.js +1 -1
  328. package/modules/geo-europe-nuts.d.ts +1 -1
  329. package/modules/geo-europe-nuts.esm.min.js +1 -1
  330. package/modules/geo-europe-nuts.min.cjs +1 -1
  331. package/modules/geo-europe-nuts.min.js +1 -1
  332. package/modules/geo-uk.d.ts +1 -1
  333. package/modules/geo-uk.esm.min.js +1 -1
  334. package/modules/geo-uk.min.cjs +1 -1
  335. package/modules/geo-uk.min.js +1 -1
  336. package/modules/geo-us-states.d.ts +1 -1
  337. package/modules/geo-us-states.esm.min.js +1 -1
  338. package/modules/geo-us-states.min.cjs +1 -1
  339. package/modules/geo-us-states.min.js +1 -1
  340. package/modules/geo-world-110m.d.ts +1 -1
  341. package/modules/geo-world-110m.esm.min.js +1 -1
  342. package/modules/geo-world-110m.min.cjs +1 -1
  343. package/modules/geo-world-110m.min.js +1 -1
  344. package/modules/geo-world-50m.d.ts +1 -1
  345. package/modules/geo-world-50m.esm.min.js +1 -1
  346. package/modules/geo-world-50m.min.cjs +1 -1
  347. package/modules/geo-world-50m.min.js +1 -1
  348. package/modules/geometry.d.ts +1 -1
  349. package/modules/geometry.esm.min.js +1 -1
  350. package/modules/geometry.min.cjs +1 -1
  351. package/modules/geometry.min.js +1 -1
  352. package/modules/htmx.d.ts +1 -1
  353. package/modules/htmx.esm.min.js +2 -2
  354. package/modules/htmx.min.cjs +2 -2
  355. package/modules/htmx.min.js +2 -2
  356. package/modules/htmx.shared.esm.min.js +1 -1
  357. package/modules/htmx.shared.min.cjs +1 -1
  358. package/modules/htmx.shared.min.js +1 -1
  359. package/modules/kanban.d.ts +1 -1
  360. package/modules/kanban.esm.min.js +1 -1
  361. package/modules/kanban.min.cjs +1 -1
  362. package/modules/kanban.min.js +1 -1
  363. package/modules/kpi.d.ts +1 -1
  364. package/modules/kpi.esm.min.js +1 -1
  365. package/modules/kpi.min.cjs +1 -1
  366. package/modules/kpi.min.js +1 -1
  367. package/modules/layout.d.ts +1 -1
  368. package/modules/layout.esm.min.js +1 -1
  369. package/modules/layout.min.cjs +1 -1
  370. package/modules/layout.min.js +1 -1
  371. package/modules/leaflet.d.ts +1 -1
  372. package/modules/leaflet.esm.min.js +1 -1
  373. package/modules/leaflet.min.cjs +1 -1
  374. package/modules/leaflet.min.js +1 -1
  375. package/modules/list.d.ts +1 -1
  376. package/modules/list.esm.min.js +1 -1
  377. package/modules/list.min.cjs +1 -1
  378. package/modules/list.min.js +1 -1
  379. package/modules/listview.d.ts +1 -1
  380. package/modules/listview.esm.min.js +1 -1
  381. package/modules/listview.min.cjs +1 -1
  382. package/modules/listview.min.js +1 -1
  383. package/modules/mapview.d.ts +1 -1
  384. package/modules/mapview.esm.min.js +55 -55
  385. package/modules/mapview.esm.min.js.map +2 -2
  386. package/modules/mapview.min.cjs +55 -55
  387. package/modules/mapview.min.js +55 -55
  388. package/modules/mapview.min.js.map +2 -2
  389. package/modules/mock-socket.d.ts +1 -1
  390. package/modules/mock-socket.esm.min.js +1 -1
  391. package/modules/mock-socket.min.cjs +1 -1
  392. package/modules/mock-socket.min.js +1 -1
  393. package/modules/presets.d.ts +1 -1
  394. package/modules/presets.esm.min.js +1 -1
  395. package/modules/presets.min.cjs +1 -1
  396. package/modules/presets.min.js +1 -1
  397. package/modules/react.d.ts +1 -1
  398. package/modules/react.esm.min.js +1 -1
  399. package/modules/react.min.cjs +1 -1
  400. package/modules/react.min.js +1 -1
  401. package/modules/recordeditor.d.ts +1 -1
  402. package/modules/recordeditor.esm.min.js +1 -1
  403. package/modules/recordeditor.min.cjs +1 -1
  404. package/modules/recordeditor.min.js +1 -1
  405. package/modules/scheduler.d.ts +1 -1
  406. package/modules/scheduler.esm.min.js +1 -1
  407. package/modules/scheduler.min.cjs +1 -1
  408. package/modules/scheduler.min.js +1 -1
  409. package/modules/shell.d.ts +1 -1
  410. package/modules/shell.esm.min.js +1 -1
  411. package/modules/shell.min.cjs +1 -1
  412. package/modules/shell.min.js +1 -1
  413. package/modules/sidebar.d.ts +1 -1
  414. package/modules/sidebar.esm.min.js +1 -1
  415. package/modules/sidebar.min.cjs +1 -1
  416. package/modules/sidebar.min.js +1 -1
  417. package/modules/svelte.d.ts +1 -1
  418. package/modules/svelte.esm.min.js +1 -1
  419. package/modules/svelte.min.cjs +1 -1
  420. package/modules/svelte.min.js +1 -1
  421. package/modules/tabs.d.ts +1 -1
  422. package/modules/tabs.esm.min.js +1 -1
  423. package/modules/tabs.min.cjs +1 -1
  424. package/modules/tabs.min.js +1 -1
  425. package/modules/toolbar.d.ts +1 -1
  426. package/modules/toolbar.esm.min.js +1 -1
  427. package/modules/toolbar.min.cjs +1 -1
  428. package/modules/toolbar.min.js +1 -1
  429. package/modules/tree.d.ts +1 -1
  430. package/modules/tree.esm.min.js +1 -1
  431. package/modules/tree.min.cjs +1 -1
  432. package/modules/tree.min.js +1 -1
  433. package/modules/vue.d.ts +1 -1
  434. package/modules/vue.esm.min.js +1 -1
  435. package/modules/vue.min.cjs +1 -1
  436. package/modules/vue.min.js +1 -1
  437. package/modules/webcomponent.d.ts +1 -1
  438. package/modules/webcomponent.esm.min.js +2 -2
  439. package/modules/webcomponent.min.cjs +2 -2
  440. package/modules/webcomponent.min.js +2 -2
  441. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * Lattice Grid 1.110.2, mapview module
2
+ * Lattice Grid 1.110.3, mapview module
3
3
  * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
4
  * https://latticegrid.dev
5
5
  */
6
- (function(Cn){"use strict";var Mn=!0,Pn=Object.create(null),Nn=Object.create(null);function Ze(t,ue){Pn[t]=ue}function jn(t){var ue=Nn[t];if(ue)return ue;var Le=Object.create(null);Nn[t]=Le;var Y=Pn[t];if(!Y)throw new Error("[lattice] missing module: "+t);return Y(Le,jn),Le}Ze("packages/core/src/internal/warn.js",function(t,ue){"use strict";Object.defineProperty(t,"reportedWarnings",{enumerable:!0,get:function(){return T}}),Object.defineProperty(t,"warnOnce",{enumerable:!0,get:function(){return R}}),Object.defineProperty(t,"infoOnce",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"resetWarnings",{enumerable:!0,get:function(){return S}}),Object.defineProperty(t,"fail",{enumerable:!0,get:function(){return g}}),Object.defineProperty(t,"invariant",{enumerable:!0,get:function(){return P}}),Object.defineProperty(t,"DEV",{enumerable:!0,get:function(){return N}});const Le=new Set,Y=2e3;function fe(p){if(Le.add(p),Le.size>Y){const u=Le.values().next().value;u!==void 0&&Le.delete(u)}}const se=[],ne=500;function n(p,u,m){se.push({key:p,level:u,message:m.map(c=>typeof c=="string"?c:V(c)).join(" "),at:Date.now()}),se.length>ne&&se.shift()}function V(p){if(p instanceof Error)return p.message;try{return JSON.stringify(p)}catch{return String(p)}}function T(){return se.map(p=>({...p}))}function q(p){if(p.length===0||typeof p[0]!="string")return p;const u=p[0].replace(/^\[lattice\]\s*/,"");return u===p[0]?p:[u,...p.slice(1)]}function R(p,...u){if(Le.has(p))return;fe(p);const m=q(u);n(p,"warn",m),console.warn("[lattice]",...m)}function f(p,...u){if(Le.has(p))return;fe(p);const m=q(u);n(p,"info",m),console.info("[lattice]",...m)}function S(){Le.clear(),se.length=0}function g(p,u){const m=new Error(`[lattice] ${p}`);throw u!==void 0&&(m.cause=u),m}function P(p,u){p||g(u)}const N=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})()}),Ze("packages/core/src/internal/predicates.js",function(t,ue){"use strict";Object.defineProperty(t,"isObject",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(t,"isFunction",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(t,"isNil",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(t,"isBlank",{enumerable:!0,get:function(){return se}}),Object.defineProperty(t,"isCtor",{enumerable:!0,get:function(){return ne}});function Le(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function Y(n){return typeof n=="function"}function fe(n){return n==null}function se(n){return n==null||n===""}function ne(n){return typeof n!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(n))?!0:!!(n.prototype&&Object.getOwnPropertyNames(n.prototype).length>1)}}),Ze("packages/modules/geometry/geodata.js",function(t,ue){"use strict";Object.defineProperty(t,"GEOMETRY_KINDS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"SPATIAL_OPERATORS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(t,"GEOMETRY_OPERATORS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(t,"EARTH_RADIUS",{enumerable:!0,get:function(){return q}}),Object.defineProperty(t,"toWkt",{enumerable:!0,get:function(){return y}}),Object.defineProperty(t,"toWkb",{enumerable:!0,get:function(){return J}}),Object.defineProperty(t,"readGeometry",{enumerable:!0,get:function(){return a}}),Object.defineProperty(t,"parseGeometry",{enumerable:!0,get:function(){return $}}),Object.defineProperty(t,"haversine",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(t,"geometryInfo",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(t,"geometryKind",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(t,"spatialOperand",{enumerable:!0,get:function(){return H}}),Object.defineProperty(t,"spatialPredicate",{enumerable:!0,get:function(){return Me}});const Le=ue("packages/core/src/internal/predicates.js"),Y=Le.isNil,fe=Le.isObject,ne=ue("packages/core/src/internal/warn.js").warnOnce,n=Object.freeze(["Point","LineString","Polygon","MultiPoint","MultiLineString","MultiPolygon","GeometryCollection"]),V=Object.freeze(["withinBbox","withinPolygon","intersects","withinDistance"]),T=Object.freeze([...V,"blank","notBlank"]),q=63710088e-1,R=Math.PI/180,f=16,S=1e-12;class g extends Error{}function P(k){throw new g(k)}function N(k){(!Array.isArray(k)||k.length<2)&&P("a position needs at least two numbers");const j=Number(k[0]),X=Number(k[1]);return(typeof k[0]!="number"||typeof k[1]!="number"||!Number.isFinite(j)||!Number.isFinite(X))&&P("a coordinate is not a finite number"),[j,X]}function p(k,j,X){Array.isArray(k)||P(`${X} is not an array of positions`);const ae=k.map(N);return ae.length<j&&P(`${X} needs at least ${j} positions, found ${ae.length}`),ae}function u(k){const j=p(k,3,"a polygon ring"),X=j[0],ae=j[j.length-1];return(X[0]!==ae[0]||X[1]!==ae[1])&&j.push([X[0],X[1]]),j.length<4&&P(`a polygon ring needs at least 3 distinct corners, found ${j.length-1}`),j}function m(k){return(!Array.isArray(k)||k.length===0)&&P("a polygon needs at least an outer ring"),k.map(u)}function c(k,j){switch(j>f&&P("geometry collections nest too deeply"),fe(k)||P("GeoJSON must be an object"),k.type){case"Feature":return k.geometry==null?null:c(k.geometry,j+1);case"FeatureCollection":return P("a FeatureCollection holds many rows, not one value; load its features as rows");case"Point":return{type:"Point",coordinates:N(k.coordinates)};case"MultiPoint":return{type:"MultiPoint",coordinates:p(k.coordinates,1,"a MultiPoint")};case"LineString":return{type:"LineString",coordinates:p(k.coordinates,2,"a LineString")};case"MultiLineString":return(!Array.isArray(k.coordinates)||!k.coordinates.length)&&P("a MultiLineString needs at least one line"),{type:"MultiLineString",coordinates:k.coordinates.map(X=>p(X,2,"a LineString"))};case"Polygon":return{type:"Polygon",coordinates:m(k.coordinates)};case"MultiPolygon":return(!Array.isArray(k.coordinates)||!k.coordinates.length)&&P("a MultiPolygon needs at least one polygon"),{type:"MultiPolygon",coordinates:k.coordinates.map(m)};case"GeometryCollection":{(!Array.isArray(k.geometries)||!k.geometries.length)&&P("a GeometryCollection needs at least one geometry");const X=k.geometries.map(ae=>c(ae,j+1)).filter(Boolean);return X.length?{type:"GeometryCollection",geometries:X}:null}default:return P(`"${String(k.type)}" is not a GeoJSON geometry type`)}}const w=Object.freeze({POINT:"Point",LINESTRING:"LineString",POLYGON:"Polygon",MULTIPOINT:"MultiPoint",MULTILINESTRING:"MultiLineString",MULTIPOLYGON:"MultiPolygon",GEOMETRYCOLLECTION:"GeometryCollection"}),d=/[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/y,r=/[A-Za-z]+/y,v=/^\s*(?:SRID\s*=\s*\d+\s*;\s*)?[A-Za-z]+\s*(?:ZM|Z|M)?\s*(?:\(|EMPTY\b)/i;class l{text;at=0;constructor(j){this.text=j}space(){for(;this.at<this.text.length&&/\s/.test(this.text[this.at]);)this.at++}expect(j){this.space(),this.text[this.at]!==j&&P(`WKT expected "${j}" at character ${this.at+1}, found "${this.text[this.at]??"the end"}"`),this.at++}accept(j){return this.space(),this.text[this.at]===j?(this.at++,!0):!1}word(){this.space(),r.lastIndex=this.at;const j=r.exec(this.text);return j?(this.at+=j[0].length,j[0].toUpperCase()):""}numberNext(){return this.space(),d.lastIndex=this.at,d.test(this.text)}number(){this.space(),d.lastIndex=this.at;const j=d.exec(this.text);return j||P(`WKT expected a number at character ${this.at+1}`),this.at+=j[0].length,Number(j[0])}position(){const j=this.number(),X=this.number();for(;this.numberNext();)this.number();return[j,X]}positionList(){this.expect("(");const j=[this.position()];for(;this.accept(",");)j.push(this.position());return this.expect(")"),j}empty(){const j=this.at;return this.word()==="EMPTY"?!0:(this.at=j,!1)}geometry(j){j>f&&P("geometry collections nest too deeply");const X=this.word(),ae=w[X];ae||P(X?`"${X}" is not a WKT geometry type`:"WKT expected a geometry type");const be=this.at,Se=this.word();return Se!=="Z"&&Se!=="M"&&Se!=="ZM"&&(this.at=be),this.empty()?null:this.body(ae,j)}body(j,X){switch(j){case"Point":{this.expect("(");const ae=this.position();return this.expect(")"),{type:"Point",coordinates:ae}}case"LineString":return{type:"LineString",coordinates:p(this.positionList(),2,"a LineString")};case"Polygon":return{type:"Polygon",coordinates:this.polygonBody()};case"MultiPoint":{this.expect("(");const ae=[];do this.empty()||(this.accept("(")?(ae.push(this.position()),this.expect(")")):ae.push(this.position()));while(this.accept(","));return this.expect(")"),ae.length?{type:"MultiPoint",coordinates:ae}:null}case"MultiLineString":{const ae=this.parts(()=>p(this.positionList(),2,"a LineString"));return ae.length?{type:"MultiLineString",coordinates:ae}:null}case"MultiPolygon":{const ae=this.parts(()=>this.polygonBody());return ae.length?{type:"MultiPolygon",coordinates:ae}:null}default:{this.expect("(");const ae=[];do{const be=this.geometry(X+1);be&&ae.push(be)}while(this.accept(","));return this.expect(")"),ae.length?{type:"GeometryCollection",geometries:ae}:null}}}parts(j){this.expect("(");const X=[];do this.empty()||X.push(j());while(this.accept(","));return this.expect(")"),X}polygonBody(){return m(this.parts(()=>this.positionList()))}}function x(k){const j=new l(String(k).replace(/^\s*SRID\s*=\s*\d+\s*;/i,"")),X=j.geometry(0);return j.space(),j.at<j.text.length&&P(`WKT has unexpected text after the geometry at character ${j.at+1}`),X}function W(k){return Object.is(k,-0)?"0":String(k)}function Z(k){return`${W(k[0])} ${W(k[1])}`}function le(k){return`(${k.map(Z).join(", ")})`}function oe(k){return`(${k.map(le).join(", ")})`}function y(k){const j=$(k);return j?C(j):""}function C(k){switch(k.type){case"Point":return`POINT (${Z(k.coordinates)})`;case"LineString":return`LINESTRING ${le(k.coordinates)}`;case"Polygon":return`POLYGON ${oe(k.coordinates)}`;case"MultiPoint":return`MULTIPOINT (${k.coordinates.map(j=>`(${Z(j)})`).join(", ")})`;case"MultiLineString":return`MULTILINESTRING (${k.coordinates.map(le).join(", ")})`;case"MultiPolygon":return`MULTIPOLYGON (${k.coordinates.map(oe).join(", ")})`;default:return`GEOMETRYCOLLECTION (${k.geometries.map(C).join(", ")})`}}class D{view;at=0;constructor(j){this.view=new DataView(j.buffer,j.byteOffset,j.byteLength)}need(j){this.at+j>this.view.byteLength&&P(`WKB ends after ${this.view.byteLength} bytes, in the middle of a geometry`)}u8(){return this.need(1),this.view.getUint8(this.at++)}u32(j){this.need(4);const X=this.view.getUint32(this.at,j);return this.at+=4,X}f64(j){this.need(8);const X=this.view.getFloat64(this.at,j);return this.at+=8,X}count(j,X){const ae=this.u32(j);return ae*X>this.view.byteLength-this.at&&P(`WKB claims ${ae} elements, more than its bytes can hold`),ae}position(j,X){const ae=this.f64(j),be=this.f64(j);for(let Se=2;Se<X;Se++)this.f64(j);return[ae,be]}positions(j,X){const ae=this.count(j,8*X),be=new Array(ae);for(let Se=0;Se<ae;Se++)be[Se]=this.position(j,X);return be}geometry(j,X){j>f&&P("geometry collections nest too deeply");const ae=this.u8();ae!==0&&ae!==1&&P(`WKB byte-order mark is ${ae}, not 0 or 1`);const be=ae===1,Se=this.u32(be);let Ae=2;Se&2147483648&&Ae++,Se&1073741824&&Ae++,Se&536870912&&this.u32(be);let ze=Se&268435455;if(ze>=1e3){const qe=Math.floor(ze/1e3);qe>3&&P(`WKB geometry type ${ze} is not one this reads`),Ae=2+(qe===3?2:1),ze%=1e3}const Be=n[ze-1];switch(Be||P(`WKB geometry type ${ze} is not one this reads`),X&&Be!==X&&P(`a part of a WKB Multi${X} is a ${Be}`),Be){case"Point":{const qe=this.position(be,Ae);return Number.isNaN(qe[0])&&Number.isNaN(qe[1])?null:{type:"Point",coordinates:N(qe)}}case"LineString":return{type:"LineString",coordinates:p(this.positions(be,Ae),2,"a LineString")};case"Polygon":{const qe=this.count(be,4),Ue=[];for(let We=0;We<qe;We++)Ue.push(this.positions(be,Ae));return qe?{type:"Polygon",coordinates:m(Ue)}:null}default:{const qe=this.count(be,5),Ue=Be==="GeometryCollection"?void 0:Be.slice(5),We=[];for(let st=0;st<qe;st++){const tt=this.geometry(j+1,Ue);tt&&We.push(tt)}return We.length?Be==="GeometryCollection"?{type:Be,geometries:We}:{type:Be,coordinates:We.map(st=>st.coordinates)}:null}}}}function M(k){const j=new D(k),X=j.geometry(0);return j.at!==k.byteLength&&P(`WKB has ${k.byteLength-j.at} bytes left over after the geometry`),X}function J(k){const j=$(k);if(!j)return null;const X=[];let ae=0;const be=Ue=>{const We=new DataView(new ArrayBuffer(5));We.setUint8(0,1),We.setUint32(1,n.indexOf(Ue)+1,!0),X.push(We),ae+=5},Se=Ue=>{const We=new DataView(new ArrayBuffer(4));We.setUint32(0,Ue,!0),X.push(We),ae+=4},Ae=Ue=>{const We=new DataView(new ArrayBuffer(16*Ue.length));Ue.forEach((st,tt)=>{We.setFloat64(tt*16,st[0],!0),We.setFloat64(tt*16+8,st[1],!0)}),X.push(We),ae+=16*Ue.length},ze=Ue=>{switch(be(Ue.type),Ue.type){case"Point":Ae([Ue.coordinates]);break;case"LineString":Se(Ue.coordinates.length),Ae(Ue.coordinates);break;case"Polygon":Se(Ue.coordinates.length);for(const We of Ue.coordinates)Se(We.length),Ae(We);break;case"GeometryCollection":Se(Ue.geometries.length);for(const We of Ue.geometries)ze(We);break;default:{const We=Ue.type.slice(5);Se(Ue.coordinates.length);for(const st of Ue.coordinates)ze({type:We,coordinates:st})}}};ze(j);const Be=new Uint8Array(ae);let qe=0;for(const Ue of X)Be.set(new Uint8Array(Ue.buffer),qe),qe+=Ue.byteLength;return Be}const F=/^0[01](?:[0-9a-fA-F]{2})+$/,re=/^[A-Za-z0-9+/_-]+={0,2}$/,z=(()=>{const k=new Int16Array(128).fill(-1),j="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let X=0;X<j.length;X++)k[j.charCodeAt(X)]=X;return k[45]=62,k[95]=63,k})();function U(k){const j=new Uint8Array(k.length/2);for(let X=0;X<j.length;X++)j[X]=parseInt(k.slice(X*2,X*2+2),16);return j}function L(k){const j=k.replace(/=+$/,""),X=new Uint8Array(Math.floor(j.length*3/4));let ae=0,be=0,Se=0;for(let Ae=0;Ae<j.length;Ae++)be=be<<6|z[j.charCodeAt(Ae)],ae+=6,ae>=8&&(ae-=8,X[Se++]=be>>ae&255);return X.subarray(0,Se)}function e(k){const j=k.trim();if(j==="")return null;if(j[0]==="{"){let X;try{X=JSON.parse(j)}catch{return P("the text starts like GeoJSON but is not valid JSON")}return c(X,0)}if(F.test(j))return M(U(j));if(v.test(j))return x(j);if(re.test(j)){const X=L(j);if(X.length>=5&&(X[0]===0||X[0]===1))return M(X)}return P("the text is not WKT, GeoJSON, or hex or base64 WKB")}const i=new WeakSet;function a(k){if(Y(k))return{geometry:null,reason:null};if(typeof k=="object"&&i.has(k))return{geometry:k,reason:null};try{let j;return typeof k=="string"?j=e(k):k instanceof Uint8Array?j=M(k):k instanceof ArrayBuffer?j=M(new Uint8Array(k)):ArrayBuffer.isView(k)?j=M(new Uint8Array(k.buffer,k.byteOffset,k.byteLength)):fe(k)?j=c(k,0):P(`${Array.isArray(k)?"an array":`a ${typeof k}`} is not a geometry`),j&&A(j),{geometry:j||null,reason:null}}catch(j){if(j instanceof g)return{geometry:null,reason:j.message};throw j}}function A(k){if(i.add(k),k.type==="GeometryCollection")for(const j of k.geometries)A(j)}function $(k){return a(k).geometry}function te(k,j){switch(k.type){case"Point":j(k.coordinates);break;case"MultiPoint":case"LineString":k.coordinates.forEach(j);break;case"MultiLineString":case"Polygon":for(const X of k.coordinates)X.forEach(j);break;case"MultiPolygon":for(const X of k.coordinates)for(const ae of X)ae.forEach(j);break;default:for(const X of k.geometries)te(X,j)}}function ke(k,j){const X=k[1]*R,ae=j[1]*R,be=ae-X,Se=(j[0]-k[0])*R,Ae=Math.sin(be/2)**2+Math.cos(X)*Math.cos(ae)*Math.sin(Se/2)**2;return 2*q*Math.asin(Math.min(1,Math.sqrt(Ae)))}function ge(k){let j=0;for(let X=1;X<k.length;X++)j+=ke(k[X-1],k[X]);return j}function ve(k){const j=k.length-1;if(j<3)return 0;let X=0;for(let ae=0;ae<j;ae++){const be=k[(ae-1+j)%j],Se=k[(ae+1)%j];X+=(Se[0]-be[0])*R*Math.sin(k[ae][1]*R)}return Math.abs(X)*q*q/2}function Pe(k){let j=ve(k[0]);for(let X=1;X<k.length;X++)j-=ve(k[X]);return Math.max(0,j)}function Te(k){let j=0,X=0,ae=0;for(let be=0;be<k.length-1;be++){const[Se,Ae]=k[be],[ze,Be]=k[be+1],qe=Se*Be-ze*Ae;j+=qe,X+=(Se+ze)*qe,ae+=(Ae+Be)*qe}return{a:j,cx:X,cy:ae}}function _(){let k=0,j=0,X=0;return{add(ae,be,Se){k+=ae*Se,j+=be*Se,X+=Se},get(){return X>0?[k/X,j/X]:null}}}function pe(k){let j=0,X=0;for(const ae of k)j+=ae[0],X+=ae[1];return[j/k.length,X/k.length]}function me(k,j){switch(k.type){case"Point":j[0].add(k.coordinates[0],k.coordinates[1],1);break;case"MultiPoint":for(const X of k.coordinates)j[0].add(X[0],X[1],1);break;case"LineString":case"MultiLineString":{const X=k.type==="LineString"?[k.coordinates]:k.coordinates;for(const ae of X){for(let be=1;be<ae.length;be++){const[Se,Ae]=ae[be-1],[ze,Be]=ae[be],qe=Math.hypot(ze-Se,Be-Ae);j[1].add((Se+ze)/2,(Ae+Be)/2,qe)}for(const be of ae)j[0].add(be[0],be[1],1)}break}case"Polygon":case"MultiPolygon":{const X=k.type==="Polygon"?[k.coordinates]:k.coordinates;for(const ae of X){let be=0,Se=0,Ae=0;ae.forEach((Be,qe)=>{const Ue=Te(Be),We=(qe===0?1:-1)*(Ue.a<0?-1:1);be+=We*Ue.a,Se+=We*Ue.cx,Ae+=We*Ue.cy}),Math.abs(be)>S&&j[2].add(Se/(3*be),Ae/(3*be),Math.abs(be)/2);const ze=ae[0].slice(0,-1);for(const Be of ze)j[0].add(Be[0],Be[1],1)}break}default:for(const X of k.geometries)me(X,j)}}const ie=new WeakMap;function Q(k){const j=$(k);if(!j)return null;const X=ie.get(j);if(X)return X;const ae=[1/0,1/0,-1/0,-1/0];te(j,Ue=>{Ue[0]<ae[0]&&(ae[0]=Ue[0]),Ue[1]<ae[1]&&(ae[1]=Ue[1]),Ue[0]>ae[2]&&(ae[2]=Ue[0]),Ue[1]>ae[3]&&(ae[3]=Ue[1])});const be=[_(),_(),_()];me(j,be);const Se=be[2].get()||be[1].get()||be[0].get()||pe([[ae[0],ae[1]],[ae[2],ae[3]]]);let Ae=0,ze=0;const Be=Ue=>{switch(Ue.type){case"LineString":Ae+=ge(Ue.coordinates);break;case"MultiLineString":for(const We of Ue.coordinates)Ae+=ge(We);break;case"Polygon":ze+=Pe(Ue.coordinates);for(const We of Ue.coordinates)Ae+=ge(We);break;case"MultiPolygon":for(const We of Ue.coordinates){ze+=Pe(We);for(const st of We)Ae+=ge(st)}break;case"GeometryCollection":for(const We of Ue.geometries)Be(We);break;default:break}};Be(j);const qe=Object.freeze({kind:j.type,bbox:Object.freeze(ae),centroid:Object.freeze(Se),length:Ae,area:ze});return ie.set(j,qe),qe}function ye(k){const j=Q(k);return j?j.kind:null}function o(k,j){const X=typeof k=="string"?k.split(/[\s,;]+/).filter(Boolean):k;if(!Array.isArray(X)||X.length!==j)return null;const ae=X.map(be=>typeof be=="number"?be:typeof be=="string"?Number(be):NaN);return ae.every(Number.isFinite)?ae:null}function H(k,j){if(k==="withinBbox"){const X=o(j,4);return X?X[0]>X[2]?{reason:'the box crosses the antimeridian (its west edge is east of its east edge), which is not supported; split it into two withinBbox conditions joined by "or"'}:X[1]>X[3]?{reason:"the box's minLat is above its maxLat"}:{operand:X}:{reason:"withinBbox needs [minLon, minLat, maxLon, maxLat]"}}if(k==="withinDistance"){let X=null;if(fe(j)&&!Array.isArray(j)){const ae=j;X=o([ae.lon,ae.lat,ae.metres],3)}else X=o(j,3);return!X||X[2]<0?{reason:"withinDistance needs { lon, lat, metres } with metres of 0 or more"}:{operand:{lon:X[0],lat:X[1],metres:X[2]}}}if(k==="withinPolygon"||k==="intersects"){const X=k==="intersects"?o(j,4):null;if(X){if(X[0]>X[2]||X[1]>X[3])return{reason:"the box's minimum is above its maximum"};const[Se,Ae,ze,Be]=X;return{operand:{type:"Polygon",coordinates:[[[Se,Ae],[ze,Ae],[ze,Be],[Se,Be],[Se,Ae]]]}}}const{geometry:ae,reason:be}=a(j);return ae?k==="withinPolygon"&&ae.type!=="Polygon"&&ae.type!=="MultiPolygon"?{reason:`withinPolygon needs a Polygon or MultiPolygon, not a ${ae.type}`}:{operand:ae}:{reason:`${k} needs a geometry: ${be||"none was given"}`}}return{reason:`"${k}" is not a spatial operator`}}function s(k,j){const[X,ae]=k;let be=!1;for(let Se=0,Ae=j.length-2;Se<j.length-1;Ae=Se++){const[ze,Be]=j[Se],[qe,Ue]=j[Ae];Be>ae!=Ue>ae&&X<(qe-ze)*(ae-Be)/(Ue-Be)+ze&&(be=!be)}return be}function h(k,j){if(!s(k,j[0]))return!1;for(let X=1;X<j.length;X++)if(s(k,j[X]))return!1;return!0}function O(k,j={points:[],segments:[],polygons:[]}){const X=ae=>{for(let be=1;be<ae.length;be++)j.segments.push([ae[be-1],ae[be]]);for(const be of ae)j.points.push(be)};switch(k.type){case"Point":j.points.push(k.coordinates);break;case"MultiPoint":for(const ae of k.coordinates)j.points.push(ae);break;case"LineString":X(k.coordinates);break;case"MultiLineString":k.coordinates.forEach(X);break;case"Polygon":j.polygons.push(k.coordinates),k.coordinates.forEach(X);break;case"MultiPolygon":for(const ae of k.coordinates)j.polygons.push(ae),ae.forEach(X);break;default:for(const ae of k.geometries)O(ae,j)}return j}function I(k,j,X){const ae=(j[0]-k[0])*(X[1]-k[1])-(j[1]-k[1])*(X[0]-k[0]);return Math.abs(ae)<=S?0:Math.sign(ae)}function K(k,j,X){return k[0]>=Math.min(j[0],X[0])-S&&k[0]<=Math.max(j[0],X[0])+S&&k[1]>=Math.min(j[1],X[1])-S&&k[1]<=Math.max(j[1],X[1])+S}function ee(k,j){const[X,ae]=k,[be,Se]=j,Ae=I(X,ae,be),ze=I(X,ae,Se),Be=I(be,Se,X),qe=I(be,Se,ae);return Ae!==ze&&Be!==qe?!0:Ae===0&&K(be,X,ae)||ze===0&&K(Se,X,ae)||Be===0&&K(X,be,Se)||qe===0&&K(ae,be,Se)}function E(k,j){return k[0]<=j[2]&&j[0]<=k[2]&&k[1]<=j[3]&&j[1]<=k[3]}function G(k,j){const X=Q(k),ae=Q(j);if(!E(X.bbox,ae.bbox))return!1;const be=O(k),Se=O(j);for(const Ae of Se.polygons)for(const ze of be.points)if(h(ze,Ae))return!0;for(const Ae of be.polygons)for(const ze of Se.points)if(h(ze,Ae))return!0;for(const Ae of be.segments)for(const ze of Se.segments)if(ee(Ae,ze))return!0;for(const Ae of be.points){for(const ze of Se.points)if(Math.abs(Ae[0]-ze[0])<=S&&Math.abs(Ae[1]-ze[1])<=S)return!0;for(const ze of Se.segments)if(I(ze[0],ze[1],Ae)===0&&K(Ae,ze[0],ze[1]))return!0}for(const Ae of Se.points)for(const ze of be.segments)if(I(ze[0],ze[1],Ae)===0&&K(Ae,ze[0],ze[1]))return!0;return!1}function Me(k,j){const{operand:X,reason:ae}=H(k,j);if(ae)return ne(`filter:geometry:${k}`,`a "${k}" condition was refused: ${ae}. It matches no row rather than guessing.`),()=>!1;switch(k){case"withinBbox":return be=>{const Se=Q(be);if(!Se)return!1;const Ae=Se.bbox;return Ae[0]>=X[0]&&Ae[1]>=X[1]&&Ae[2]<=X[2]&&Ae[3]<=X[3]};case"withinPolygon":{const be=X.type==="Polygon"?[X.coordinates]:X.coordinates,Se=Ae=>be.some(ze=>h(Ae,ze));return Ae=>{const ze=$(Ae);return ze?ze.type==="Point"?Se(ze.coordinates):ze.type==="MultiPoint"?ze.coordinates.every(Se):Se(Q(ze).centroid):!1}}case"intersects":return be=>{const Se=$(be);return!!Se&&G(Se,X)};default:{const be=[X.lon,X.lat];return Se=>{const Ae=Q(Se);return!!Ae&&ke(Ae.centroid,be)<=X.metres}}}}}),Ze("packages/modules/shared/engine.js",function(t,ue){"use strict";Object.defineProperty(t,"sourceId",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(t,"engineSource",{enumerable:!0,get:function(){return se}}),Object.defineProperty(t,"gridPivoted",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(t,"loadedAndMatching",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"gridHoldsWindow",{enumerable:!0,get:function(){return V}}),Object.defineProperty(t,"gridEngineRequest",{enumerable:!0,get:function(){return q}}),Object.defineProperty(t,"EngineFlight",{enumerable:!0,get:function(){return R}});const Le=new WeakMap;let Y=0;function fe(f){let S=Le.get(f);return S===void 0&&(S=++Y,Le.set(f,S)),S}function se(f){const S=f&&typeof f.config=="function"?f.config():null,g=S&&S.source&&typeof S.source=="object"?S.source:null;if(!g||typeof g.aggregate!="function")return{reason:"the grid's source has no aggregate() — it is not a pushdown source"};const P=g.capabilitiesOf(g.adapter&&g.adapter.capabilities);return{source:g,caps:P,config:S}}function ne(f){const S=f&&typeof f.config=="function"?f.config():null,g=S&&S.source&&typeof S.source=="object"?S.source:null;if(!g||typeof g.lastPlan!="function")return!1;const P=f&&f.state&&typeof f.state.get=="function"?f.state.get():null,N=P&&P.pivot;return!!(N&&N.enabled&&Array.isArray(N.columns)&&N.columns.length>0)}function n(f){const S=f.rows&&typeof f.rows.residentCount=="function"?f.rows.residentCount():0,g=typeof f.rows.matchCount=="function"?f.rows.matchCount():NaN;return{loaded:S,total:Number.isFinite(g)?g:NaN}}function V(f){const S=f&&typeof f.config=="function"?f.config():null,g=S&&S.source&&typeof S.source=="object"?S.source:null;if(!g||g.mode!=="remote"&&g.mode!=="paged")return!1;if(typeof f.rows.matchCount=="function"&&f.rows.matchCount()===null)return!0;const{loaded:P,total:N}=n(f);return Number.isFinite(N)&&P<N}function T(f,S){return S?f?{op:"and",conditions:[f,S]}:S:f||null}function q(f,S,g=null){const P=f.filters&&typeof f.filters.where=="function"?f.filters.where():[];if(Array.isArray(P)&&P.length)return{reason:`a \`where\` predicate is in force (${P.join(", ")}), which only the browser can run`};const N=f.filters&&typeof f.filters.quickState=="function"?f.filters.quickState():{text:""},p=N&&N.text?String(N.text):"",{source:u,config:m,caps:c}=S,w={filters:u.wireFilters(T(f.filters.get(),g),{tz:m.timeZone,weekStartsOn:m.weekStartsOn}),sort:[],range:null,context:m.context??null,...p?{quick:p}:{}},d=u.planQuery(w,c);return d.unpushed.includes("filter")?{reason:g?"the grid's filter, or the viewport condition, did not fully push to the engine":"the grid's filter did not fully push to the engine"}:d.unpushed.includes("quick")?{reason:"the quick search did not push to the engine"}:{request:w,quick:p}}class R{#e=null;#t=null;#n=!1;answer(S){return this.#t&&this.#t.key===S?this.#t:null}last(){return this.#t}get busy(){return this.#e!==null}ask(S,g,P){const N=this.#e;if(N){N.key!==S&&N.controller&&N.controller.abort();return}const p=globalThis.AbortController,u=typeof p=="function"?new p:null,m={key:S,controller:u};this.#e=m;let c;Promise.resolve().then(()=>g(u?u.signal:null)).then(w=>{c={key:S,result:w}},w=>{c={key:S,error:w}}).then(()=>{this.#e===m&&(this.#e=null),!this.#n&&(u&&u.signal.aborted||(this.#t=c),P())})}abort(){const S=this.#e;S&&S.controller&&S.controller.abort()}close(){this.#n=!0,this.abort()}}}),Ze("packages/modules/charts/scale.js",function(t,ue){"use strict";Object.defineProperty(t,"isNumber",{enumerable:!0,get:function(){return T}}),Object.defineProperty(t,"toNumber",{enumerable:!0,get:function(){return q}}),Object.defineProperty(t,"toTime",{enumerable:!0,get:function(){return R}}),Object.defineProperty(t,"extent",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"niceStep",{enumerable:!0,get:function(){return S}}),Object.defineProperty(t,"niceDomain",{enumerable:!0,get:function(){return g}}),Object.defineProperty(t,"measureDomain",{enumerable:!0,get:function(){return P}}),Object.defineProperty(t,"linearTicks",{enumerable:!0,get:function(){return N}}),Object.defineProperty(t,"timeStepFor",{enumerable:!0,get:function(){return p}}),Object.defineProperty(t,"MONTH_STEPS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(t,"timeTicks",{enumerable:!0,get:function(){return l}}),Object.defineProperty(t,"linearScale",{enumerable:!0,get:function(){return x}}),Object.defineProperty(t,"timeScale",{enumerable:!0,get:function(){return W}}),Object.defineProperty(t,"key",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(t,"bandScale",{enumerable:!0,get:function(){return le}}),Object.defineProperty(t,"sqrtScale",{enumerable:!0,get:function(){return oe}});const Le=[1,2,2.5,5,10],Y=6e4,fe=36e5,se=864e5,ne=365.25*se,n=[1,2,5,10,20,25,50,100],V=[1,5,10,25,50,100,250,500,1e3,5e3,15e3,3e4,Y,5*Y,15*Y,30*Y,fe,3*fe,6*fe,12*fe,se,2*se,7*se,14*se,30*se,90*se,180*se,...n.map(y=>y*ne)];function T(y){return typeof y=="number"&&Number.isFinite(y)}function q(y){if(y==null||y==="")return null;if(y instanceof Date){const D=y.getTime();return Number.isFinite(D)?D:null}if(typeof y=="boolean")return y?1:0;const C=Number(y);return Number.isFinite(C)?C:null}function R(y){if(y==null||y==="")return null;if(y instanceof Date){const D=y.getTime();return Number.isFinite(D)?D:null}if(typeof y=="number")return Number.isFinite(y)?y:null;const C=Date.parse(String(y));return Number.isFinite(C)?C:null}function f(y){let C=1/0,D=-1/0;for(let M=0;M<y.length;M++){const J=y[M];T(J)&&(J<C&&(C=J),J>D&&(D=J))}return C===1/0?null:{min:C,max:D}}function S(y){if(!(y>0))return 1;const C=10**Math.floor(Math.log10(y));for(const D of Le)if(y<=D*C)return D*C;return 10*C}function g(y,C=5){const D=S((y.max-y.min)/Math.max(1,C));return{min:Math.floor(y.min/D)*D,max:Math.ceil(y.max/D)*D,step:D}}function P(y,C={}){const D=f(y)||{min:0,max:1};let{min:M,max:J}=D;if(C.zero&&(M>0&&(M=0),J<0&&(J=0)),M===J){const F=Math.abs(M)>0?Math.abs(M)/10:1;M-=F,J+=F}if(C.nice!==!1){const F=g({min:M,max:J},C.ticks||5);M=F.min,J=F.max}return T(C.min)&&(M=C.min),T(C.max)&&(J=C.max),M===J&&(J=M+1),{min:M,max:J}}function N(y,C=5){const D=S((y.max-y.min)/Math.max(1,C)),M=Math.ceil(y.min/D),J=Math.floor(y.max/D),F=[];for(let re=M;re<=J;re++){const z=re*D;F.push(Math.abs(z)<D/1e6?0:Number(z.toPrecision(12)))}return F}function p(y,C=5){const D=Math.max(1,C),M=y/D;let J=V[V.length-1];for(const z of V)if(z>=M){J=z;break}if(J<ne)return J;let F=J,re=Math.abs(y/J-D);for(const z of V){if(z<ne)continue;const U=Math.abs(y/z-D);U<re&&(re=U,F=z)}return F}const u=new Map;function m(y){let C=u.get(y);return C||(C=new Intl.DateTimeFormat("en-US",{timeZone:y,year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),u.set(y,C)),C}function c(y,C){const D={year:0,month:0,day:1,hour:0,minute:0,second:0};for(const M of m(C).formatToParts(new Date(y)))switch(M.type){case"year":D.year=Number(M.value);break;case"month":D.month=Number(M.value)-1;break;case"day":D.day=Number(M.value);break;case"hour":D.hour=Number(M.value)%24;break;case"minute":D.minute=Number(M.value);break;case"second":D.second=Number(M.value);break;default:break}return D}function w(y,C,D){const M=Date.UTC(y,C,1);let J=M;for(let F=0;F<2;F++){const re=c(J,D),z=Date.UTC(re.year,re.month,re.day,re.hour,re.minute,re.second),U=M-z;if(U===0)break;J+=U}return J}function d(y,C,D){const M=D?c(y.min,D).year:new Date(y.min).getUTCFullYear();let J=Math.ceil(M/C)*C;const F=z=>D?w(z,0,D):Date.UTC(z,0,1);F(J)<y.min&&(J+=C);const re=[];for(;F(J)<=y.max;J+=C)re.push(F(J));return re}const r=new Map([[30*se,1],[90*se,3],[180*se,6]]);function v(y,C,D){const M=D?c(y.min,D):{year:new Date(y.min).getUTCFullYear(),month:new Date(y.min).getUTCMonth()};let J=M.year*12+M.month;const F=z=>{const U=Math.floor(z/12),L=z-U*12;return D?w(U,L,D):Date.UTC(U,L,1)};F(J)<y.min&&(J+=1),J=Math.ceil(J/C)*C;const re=[];for(;;J+=C){const z=F(J);if(z>y.max)break;re.push(z)}return re}function l(y,C=5,D){const M=p(y.max-y.min,C);if(M>=ne)return d(y,Math.round(M/ne),D);const J=r.get(M);if(J)return v(y,J,D);const F=[],re=Math.ceil(y.min/M)*M;for(let z=re;z<=y.max;z+=M)F.push(z);return F}function x(y,C){const D=y.max-y.min||1,[M,J]=C;return{kind:"linear",domain:y,range:C,of(F){return M+(F-y.min)/D*(J-M)},invert(F){return y.min+(F-M)/(J-M||1)*D},ticks(F=5){return N(y,F)}}}function W(y,C){return{...x(y,C),kind:"time",ticks(M=5,J){return l(y,M,J)}}}function Z(y){if(y==null)return" null";if(y instanceof Date)return` date:${y.getTime()}`;if(typeof y=="object"){const C=y,D=C.id??C.key??C.value;return D!==void 0&&typeof D!="object"?` obj:${String(D)}`:` obj:${String(y)}`}return String(y)}function le(y,C,D=.2){const M=Math.min(.9,Math.max(0,D)),[J,F]=C,re=new Map;for(let L=0;L<y.length;L++){const e=Z(y[L]);re.has(e)||re.set(e,L)}const z=y.length?(F-J)/y.length:F-J,U=Math.max(0,z*(1-M));return{kind:"band",domain:y,range:C,bandwidth:U,step:z,of(L){const e=re.get(Z(L));return e===void 0?NaN:J+e*z+(z-U)/2},centre(L){const e=this.of(L);return Number.isNaN(e)?NaN:e+U/2},ticks(){return y}}}function oe(y,C){const[D,M]=C,J=Math.max(Math.abs(y.max),Math.abs(y.min),0)||1;return{kind:"sqrt",domain:y,range:C,of(F){const re=Math.sqrt(Math.abs(F)/J);return D+re*(M-D)}}}}),Ze("packages/modules/charts/svg.js",function(t,ue){"use strict";Object.defineProperty(t,"SVG_NS",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(t,"el",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(t,"svg",{enumerable:!0,get:function(){return se}}),Object.defineProperty(t,"attr",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(t,"attrs",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"setText",{enumerable:!0,get:function(){return V}}),Object.defineProperty(t,"clear",{enumerable:!0,get:function(){return T}}),Object.defineProperty(t,"append",{enumerable:!0,get:function(){return q}}),Object.defineProperty(t,"path",{enumerable:!0,get:function(){return R}}),Object.defineProperty(t,"ribbonPath",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"round",{enumerable:!0,get:function(){return S}}),Object.defineProperty(t,"pathRings",{enumerable:!0,get:function(){return g}}),Object.defineProperty(t,"insideRings",{enumerable:!0,get:function(){return P}});const Le="http://www.w3.org/2000/svg";function Y(N){const p=N.indexOf(")");return p<0?N:N.slice(p+1).trim()||"#0072b2"}function fe(N,p,u){const m=N.createElement(p);return u&&m.setAttribute("class",u),m}function se(N,p,u){const m=N.createElementNS(Le,p);if(u)for(const c of Object.keys(u))m.setAttribute(c,String(u[c]));return m}function ne(N,p,u){if(!N)return;if(u==null){N.removeAttribute(p);return}let m=String(u);m.startsWith("url(#")&&(p==="stroke"||p==="fill"&&N.localName==="text")&&(m=Y(m)),N.setAttribute(p,m)}function n(N,p){if(N)for(const u of Object.keys(p))ne(N,u,p[u])}function V(N,p){N&&(N.textContent=p==null?"":String(p))}function T(N){if(N)for(;N.firstChild;)N.removeChild(N.firstChild)}function q(N,p){for(const u of p)u&&N.appendChild(u);return N}function R(N){return N.join(" ")}function f(N){if(!N||N.length<2)return"";const p=["M",N[0].x,N[0].upper];for(let u=1;u<N.length;u++)p.push("L",N[u].x,N[u].upper);for(let u=N.length-1;u>=0;u--)p.push("L",N[u].x,N[u].lower);return p.push("Z"),R(p)}function S(N){return Math.round(N*100)/100}function g(N){const p=[];let u=[];const m=String(N||"").match(/[A-Za-z]|-?\d*\.?\d+(?:e[-+]?\d+)?/gi)||[];let c="",w=[];const d=()=>{if(!c||!w.length){w=[];return}if(c==="M"||c==="L")for(let r=0;r+1<w.length;r+=2)u.push([w[r],w[r+1]]);else c!=="Z"&&w.length>=2&&u.push([w[w.length-2],w[w.length-1]]);w=[]};for(const r of m){if(/[A-Za-z]/.test(r)){if(d(),r==="Z"||r==="z"){u.length>2&&p.push(u),u=[],c="";continue}r==="M"&&u.length>2&&(p.push(u),u=[]),c=r;continue}w.push(Number(r))}return d(),u.length>2&&p.push(u),p}function P(N,p,u){let m=!1;for(const c of N)for(let w=0,d=c.length-1;w<c.length;d=w++){const[r,v]=c[w],[l,x]=c[d];v>u!=x>u&&p<(l-r)*(u-v)/(x-v||1e-12)+r&&(m=!m)}return m}}),Ze("packages/modules/charts/typography.js",function(t,ue){"use strict";Object.defineProperty(t,"BASE_SIZE",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(t,"BASE_FAMILY",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(t,"CHAR_RATIO",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(t,"resolveType",{enumerable:!0,get:function(){return se}}),Object.defineProperty(t,"textWidth",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"widestLabel",{enumerable:!0,get:function(){return V}}),Object.defineProperty(t,"truncateTo",{enumerable:!0,get:function(){return T}}),Object.defineProperty(t,"applySize",{enumerable:!0,get:function(){return q}});const Le=12,Y="var(--lattice-font-family, system-ui, -apple-system, sans-serif)",fe=.62;function se(R){const f=R&&R.font,S=typeof f=="number"?{size:f}:f||{},g=ne(S.size,Le);return{family:S.family||Y,size:g,small:ne(S.small??S.tickSize,Math.max(9,g-1)),title:ne(S.title,Math.round(g*1.15)),axisTitle:ne(S.axisTitle,Math.max(10,g-1)),weight:S.weight||"inherit"}}function ne(R,f){const S=Number(R);return Number.isFinite(S)&&S>0?S:f}function n(R,f){return String(R??"").length*f*fe}function V(R,f){let S=0;for(const g of R||[]){const P=n(g,f);P>S&&(S=P)}return S}function T(R,f,S){const g=String(R??""),P=Math.floor(f/(S*fe));return P<=0?"":g.length<=P?g:P===1?"…":`${g.slice(0,P-1)}…`}function q(R,f){!R||!Number.isFinite(f)||(R.style?R.style.fontSize=`${f}px`:R.setAttribute("style",`font-size:${f}px`))}}),Ze("packages/modules/charts/frame.js",function(t,ue){"use strict";Object.defineProperty(t,"LABEL_GAP",{enumerable:!0,get:function(){return V}}),Object.defineProperty(t,"LABEL_GUTTER_SHARE",{enumerable:!0,get:function(){return T}}),Object.defineProperty(t,"resolveMargin",{enumerable:!0,get:function(){return q}}),Object.defineProperty(t,"plotRect",{enumerable:!0,get:function(){return R}}),Object.defineProperty(t,"shouldRotate",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"Pool",{enumerable:!0,get:function(){return S}});const Y=ue("packages/modules/charts/svg.js").SVG_NS,fe=ue("packages/modules/charts/typography.js"),se=fe.textWidth,ne=fe.widestLabel,n=8,V=6,T=.4;function q(g,P){const N=typeof g=="number"?g:P,p=g&&typeof g=="object"?g:{},u=m=>Number.isFinite(m)&&m>=0?Number(m):N;return{base:N,top:u(p.top),right:u(p.right),bottom:u(p.bottom),left:u(p.left)}}function R(g){const P=q(g.margin,typeof g.padding=="number"?g.padding:8),N=P.base,p=g.fontSize||12,u=g.yLabels||[],m=g.xLabels||[],c=g.ySide==="right"?"right":"left",w=c==="right"?"left":"right",d=g.titles||{},r=g.titleSize||p,v=re=>re?r+V:0,l=ne(u,p),x=u.length?Math.min(g.width*T,P[c]+l+V):Math.max(n,P[c]),W=P[w]+(g.rightGutter||0),Z=(c==="left"?x:W)+v(d.left),le=ne(m.map(re=>String(re).slice(0,14)),p),oe=m.length?(g.width-Z-(c==="right"?x:W)-v(d.right))/m.length*.85:0,y=g.rotated==="auto"?f(m,oe,p,g.every):!!g.rotated,C=(m.length?y?Math.min(g.height*T,V+le):p+V+P.bottom:Math.max(n,P.bottom))+v(d.bottom),D=(c==="right"?x:W)+v(d.right),M=P.top+(g.topGutter||0),J=Math.max(0,g.width-Z-D),F=Math.max(0,g.height-M-C);return{left:Z,top:M,width:J,height:F,right:Z+J,bottom:M+F,gutter:{left:Z,bottom:C,right:D,top:M}}}function f(g,P,N,p){if(!g.length||P<=0)return!1;const u=Number.isFinite(p)&&p>0?Number(p):1;return ne(g,N)>P*u-4}class S{#e;#t=0;static#n="data-pool-key";constructor(P,N=0){this.#e=P,this.#t=N>0?N:0}next(P,N,p){if(p!=null)return this.#r(P,N,String(p));const u=this.#e.childNodes[this.#t],m=u&&u.tagName,c=/(^|\s)\S*__axis-title(\s|$)/,w=m&&c.test(String(u.getAttribute("class")||"")),d=!!N&&c.test(String(N));if(m&&(!w||d)&&String(m).toLowerCase()===P.toLowerCase())return N&&u.setAttribute("class",N),this.#t++,u;const r=this.#e.ownerDocument.createElementNS(Y,P);return N&&r.setAttribute("class",N),u?this.#e.insertBefore(r,u):this.#e.appendChild(r),this.#t++,r}#r(P,N,p){const u=P.toLowerCase();for(let w=this.#t;w<this.#e.childNodes.length;w++){const d=this.#e.childNodes[w],r=d&&d.tagName;if(r&&String(r).toLowerCase()===u&&d.getAttribute(S.#n)===p)return w!==this.#t&&this.#e.insertBefore(d,this.#e.childNodes[this.#t]),N&&d.setAttribute("class",N),this.#t++,d}const m=this.#e.ownerDocument.createElementNS(Y,P);m.setAttribute(S.#n,p),N&&m.setAttribute("class",N);const c=this.#e.childNodes[this.#t];return c?this.#e.insertBefore(m,c):this.#e.appendChild(m),this.#t++,m}finish(){for(;this.#e.childNodes.length>this.#t;)this.#e.removeChild(this.#e.lastChild);this.#t=0}}}),Ze("packages/modules/charts/fills.js",function(t,ue){"use strict";Object.defineProperty(t,"PATTERNS",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(t,"GRADIENTS",{enumerable:!0,get:function(){return se}}),Object.defineProperty(t,"isFill",{enumerable:!0,get:function(){return q}}),Object.defineProperty(t,"isPaintRef",{enumerable:!0,get:function(){return R}}),Object.defineProperty(t,"paintFallback",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"normaliseFill",{enumerable:!0,get:function(){return g}}),Object.defineProperty(t,"swatchCss",{enumerable:!0,get:function(){return N}}),Object.defineProperty(t,"createFillRegistry",{enumerable:!0,get:function(){return p}}),Object.defineProperty(t,"rowPaint",{enumerable:!0,get:function(){return u}}),Object.defineProperty(t,"patternSeries",{enumerable:!0,get:function(){return m}}),Object.defineProperty(t,"paintSolid",{enumerable:!0,get:function(){return c}}),Object.defineProperty(t,"rowFillSource",{enumerable:!0,get:function(){return w}}),Object.defineProperty(t,"nodePaint",{enumerable:!0,get:function(){return d}});const Y=ue("packages/core/src/internal/warn.js").warnOnce,fe=Object.freeze(["hatch","crosshatch","dots","grid"]),se=Object.freeze(["linear","radial"]),ne=8,n="#0072b2";let V=0;const T=new Map;function q(r){return!!r&&typeof r=="object"&&!Array.isArray(r)&&(typeof r.gradient=="string"||typeof r.pattern=="string")}function R(r){return typeof r=="string"&&r.startsWith("url(#")}function f(r){if(typeof r!="string")return r==null?"":String(r);if(!r.startsWith("url("))return r;const v=r.indexOf(")");return(v<0?"":r.slice(v+1).trim())||n}function S(r,v){Y(`chart:fill:invalid:${r}`,`a chart fill object was ignored: ${v} The mark was drawn in a solid colour instead. A fill is a gradient object (gradient: "linear" or "radial", with stops of [offset, colour]) or a pattern object (pattern: "hatch", "crosshatch", "dots" or "grid", with a colour).`)}function g(r,v){if(!q(r))return null;const l=v||n;if(typeof r.gradient=="string"){if(!se.includes(r.gradient))return S("gradient",`the gradient "${r.gradient}" is not one of ${se.join(", ")}.`),null;const le=Array.isArray(r.stops)?r.stops:[],oe=[];for(const C of le){const D=Array.isArray(C)?Number(C[0]):Number(C&&C.offset),M=Array.isArray(C)?C[1]:C&&C.colour;!Number.isFinite(D)||typeof M!="string"||!M||oe.push({offset:Math.min(1,Math.max(0,D)),colour:M})}if(oe.length<2)return S("stops","a gradient needs at least two [offset, colour] stops."),null;oe.sort((C,D)=>C.offset-D.offset);const y=Number.isFinite(Number(r.angle))?Number(r.angle):180;return{kind:r.gradient,angle:y,stops:oe,solid:oe[0].colour}}if(!fe.includes(r.pattern))return S("pattern",`the pattern "${r.pattern}" is not one of ${fe.join(", ")}.`),null;const x=Number(r.size),W=Number(r.angle),Z=typeof r.colour=="string"&&r.colour?r.colour:l;return{kind:"pattern",pattern:r.pattern,colour:Z,background:typeof r.background=="string"&&r.background?r.background:null,size:Number.isFinite(x)&&x>=2?x:ne,angle:Number.isFinite(W)?W:r.pattern==="grid"||r.pattern==="dots"?0:45,solid:Z}}function P(r){if(r.kind==="pattern"){const l=r.colour,x=r.size,W=Math.max(1,x/5),Z=r.background||"transparent",le=oe=>`repeating-linear-gradient(${oe+90}deg,${l} 0 ${W}px,transparent ${W}px ${x}px)`;return r.pattern==="hatch"?`${le(r.angle)},${Z}`:r.pattern==="crosshatch"?`${le(r.angle)},${le(r.angle+90)},${Z}`:r.pattern==="grid"?`${le(r.angle)},${le(r.angle+90)},${Z}`:`radial-gradient(circle at 50% 50%,${l} ${x/6}px,transparent ${x/6+.5}px) 0 0/${x}px ${x}px,${Z}`}const v=r.stops.map(l=>`${l.colour} ${Math.round(l.offset*100)}%`).join(",");return r.kind==="radial"?`radial-gradient(circle,${v})`:`linear-gradient(${r.angle}deg,${v})`}function N(r){if(!R(r))return typeof r=="string"?r:"";const v=String(r).indexOf(")"),l=String(r).slice(5,v),x=T.get(l);return x?P(x):f(r)}function p(r){const v=`lattice-fill-${++V}`;let l=new Map,x=0;const W=(le,oe)=>{const y=r.ownerDocument.createElementNS("http://www.w3.org/2000/svg",le);for(const C of Object.keys(oe))y.setAttribute(C,String(oe[C]));return y},Z=(le,oe)=>{if(oe.kind==="pattern"){const C=oe.size,D=Math.max(1,C/5),M=W("pattern",{id:le,width:C,height:C,patternUnits:"userSpaceOnUse"});oe.angle&&M.setAttribute("patternTransform",`rotate(${oe.angle})`),oe.background&&M.appendChild(W("rect",{width:C,height:C,fill:oe.background}));const J={stroke:oe.colour,"stroke-width":D};oe.pattern==="dots"?M.appendChild(W("circle",{cx:C/2,cy:C/2,r:Math.max(1,C/6),fill:oe.colour})):(M.appendChild(W("line",{x1:C/2,y1:0,x2:C/2,y2:C,...J})),oe.pattern!=="hatch"&&M.appendChild(W("line",{x1:0,y1:C/2,x2:C,y2:C/2,...J}))),r.appendChild(M);return}let y;if(oe.kind==="radial")y=W("radialGradient",{id:le,cx:.5,cy:.5,r:.5});else{const C=oe.angle*Math.PI/180,D=Math.sin(C)/2,M=-Math.cos(C)/2;y=W("linearGradient",{id:le,x1:+(.5-D).toFixed(4),y1:+(.5-M).toFixed(4),x2:+(.5+D).toFixed(4),y2:+(.5+M).toFixed(4)})}for(const C of oe.stops)y.appendChild(W("stop",{offset:C.offset,"stop-color":C.colour}));r.appendChild(y)};return{prefix:v,paint(le,oe){const y=g(le,oe);if(!y)return oe||n;if(!r||!r.ownerDocument)return y.solid;const C=JSON.stringify(y);let D=l.get(C);if(!D){const M=`${v}-${x++}`;Z(M,y),T.set(M,y),D=`url(#${M}) ${y.solid}`,l.set(C,D)}return D},reset(){for(const le of l.values())T.delete(le.slice(5,le.indexOf(")")));if(l=new Map,x=0,r)for(;r.firstChild;)r.removeChild(r.firstChild)},ids(){return[...l.values()].map(le=>le.slice(5,le.indexOf(")")))}}}function u(r,v,l){if(r==null||r==="")return null;const x=f(l);if(q(r))return v?v.paint(r,x):(g(r,x)||{}).solid||null;if(typeof r=="string"){if(fe.includes(r)){const W={pattern:r,colour:x};return v?v.paint(W,x):x}return r}return null}function m(r){const v=[{pattern:"hatch",angle:45},{pattern:"dots"},{pattern:"crosshatch",angle:45},{pattern:"hatch",angle:135},{pattern:"grid"},{pattern:"dots",size:5},{pattern:"hatch",angle:0},{pattern:"crosshatch",angle:0,size:6}];return r.map((l,x)=>({...v[x%v.length],colour:l,background:"var(--lattice-chart-plot-bg,var(--lattice-chart-d-plot-bg))"}))}function c(r){return R(r)?String(r).replace(/^url\([^)]*\)\s*/,""):r}function w(r,v){const l=r.fill;if(q(l))return(W,Z)=>u(l,v.fills,c(Z));if(typeof l=="function")return(W,Z)=>{let le=null;try{le=l({label:W.label,x:W.x,y:W.y,rowKey:W.rowKey})}catch{le=null}return u(le,v.fills,c(Z))};const x=typeof l=="string"?l:l&&typeof l=="object"&&typeof l.col=="string"?l.col:null;return x?(W,Z)=>W.rowKey===void 0||W.rowKey===null?null:u(r.grid.rows.value(W.rowKey,x),v.fills,c(Z)):null}function d(r,v,l){return r&&r({label:v.label,x:v.value,y:v.total,rowKey:v.rowKey},l)||l}}),Ze("packages/modules/charts/scheme.js",function(t,ue){"use strict";Object.defineProperty(t,"PALETTE",{enumerable:!0,get:function(){return V}}),Object.defineProperty(t,"SCHEMES",{enumerable:!0,get:function(){return T}}),Object.defineProperty(t,"registerScheme",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"setDefaultScheme",{enumerable:!0,get:function(){return S}}),Object.defineProperty(t,"schemeNames",{enumerable:!0,get:function(){return g}}),Object.defineProperty(t,"resolveScheme",{enumerable:!0,get:function(){return u}}),Object.defineProperty(t,"RAMP_SCALES",{enumerable:!0,get:function(){return c}}),Object.defineProperty(t,"toRgb",{enumerable:!0,get:function(){return r}}),Object.defineProperty(t,"rampStops",{enumerable:!0,get:function(){return v}});const Y=ue("packages/core/src/internal/warn.js").warnOnce,fe=ue("packages/modules/charts/fills.js"),se=fe.isFill,ne=fe.patternSeries,n=fe.rowPaint,V=Object.freeze(["#0072b2","#e69f00","#009e73","#cc79a7","#56b4e9","#d55e00","#7a5195","#6b7d8c"]),T=Object.freeze({default:{series:V,sequential:["#ecf3f9","#005280"],diverging:["#b04a00","#f7f7f7","#005280"],positive:"#009e73",negative:"#d55e00"},bright:{series:["#1f77d0","#ff7f0e","#2ca02c","#d62728","#9467bd","#17becf","#e377c2","#7f7f7f"],sequential:["#eef4fb","#1f77d0"],diverging:["#d62728","#f7f7f7","#1f77d0"],positive:"#2ca02c",negative:"#d62728"},earth:{series:["#5b7c6f","#c08b52","#7a6a53","#a4553f","#4e6a83","#8f8259","#6d5566","#8c9196"],sequential:["#f2efe9","#4e6a83"],diverging:["#a4553f","#f2efe9","#4e6a83"],positive:"#5b7c6f",negative:"#a4553f"},mono:{series:["#0b2a3d","#17475f","#2c6480","#4a82a0","#6da0bd","#94bcd6","#bcd7e9","#dfecf5"],sequential:["#eef3f7","#0b2a3d"],diverging:["#7a5c00","#f5f5f5","#0b2a3d"],positive:"#17475f",negative:"#7a5c00"},patterns:{series:ne(V),sequential:["#ecf3f9","#005280"],diverging:["#b04a00","#f7f7f7","#005280"],positive:"#009e73",negative:"#d55e00"}}),q=new Map;let R="default";function f(l,x){!l||!x||q.set(String(l),x)}function S(l){if(typeof l=="string"){R=l;return}l&&typeof l=="object"&&(q.set("__default__",l),R="__default__")}function g(){return[...Object.keys(T),...q.keys()].filter(l=>!l.startsWith("__"))}function P(l){return q.has(l)?q.get(l):T[l]||null}const N=["series","sequential","diverging","positive","negative"];function p(l){return!l||typeof l!="object"||Array.isArray(l)?!1:!N.some(x=>x in l)}function u(l,x){const W=x&&x.fills||null,Z=P(R)||T.default,le=l&&l.scheme,oe=p(le)?le:null,y=Array.isArray(le)&&le.length?le:null,C=typeof le=="string"?P(le):oe||Array.isArray(le)?null:le||null,D=(l&&Array.isArray(l.palette)&&l.palette.length?l.palette:null)||y;oe&&D&&Y("chart:scheme:array-and-map",'chart "scheme" was given as a name map together with a "palette" array; the two do not combine. Colours came from the map and the array was ignored. Pass one or the other.');const M=oe?null:D,J={...T.default,...Z,...C||{}};M&&(J.series=M);const F=l&&l.ramp&&typeof l.ramp=="object"&&!Array.isArray(l.ramp)?l.ramp:null,re=F?F.colours:l&&l.ramp,z=Array.isArray(re)&&re.length>=2?re:null;z&&(J.sequential=z);const U=F?w(F.scale):null,L=!!(C||M||oe),e=J.series&&J.series.length?J.series:V,i=new Map;let a=0;return{...J,series:($,te)=>{if(oe&&te!==void 0&&te!==null){const ke=String(te);return Object.prototype.hasOwnProperty.call(oe,ke)?m(oe[ke],W,$):(i.has(ke)||i.set(ke,a++),m(d(e,i.get(ke),!0),W,i.get(ke)))}return m(d(e,$,L),W,$)},explicit:L,nameMap:!!oe,rampScale:U,fills:W}}function m(l,x,W){if(!se(l))return l;const Z=V[(W%V.length+V.length)%V.length];return n(l,x,Z)||Z}const c=Object.freeze(["linear","log","quantile"]);function w(l){return l==null?null:c.includes(l)?l:(Y(`chart:ramp:scale:${String(l)}`,`chart "ramp.scale" was "${String(l)}", which is not a ramp scale; the chart chose one from its values instead. Use "linear", "log" or "quantile".`),null)}function d(l,x,W){const Z=(x%l.length+l.length)%l.length;return W||typeof l[Z]!="string"?l[Z]:`var(--lattice-chart-${Z+1}, ${l[Z]})`}function r(l){if(typeof l!="string")return null;const x=l.trim(),W=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(x);if(W){const oe=W[1];return oe.length===3?[0,1,2].map(y=>parseInt(oe[y]+oe[y],16)):[0,2,4].map(y=>parseInt(oe.slice(y,y+2),16))}const Z=/^rgba?\(([^)]+)\)$/i.exec(x);if(!Z)return null;const le=Z[1].split(/[\s,/]+/).filter(Boolean).slice(0,3).map(Number);return le.length===3&&le.every(oe=>Number.isFinite(oe))?le:null}function v(l,x){const W=x?l.diverging:l.sequential,Z=x?T.default.diverging:T.default.sequential,le=(Array.isArray(W)?W:Z).map((oe,y)=>r(oe)||r(Z[y])||[0,0,0]);return le.length>=2?le:Z.map(oe=>r(oe))}}),Ze("packages/modules/charts/roles.js",function(t,ue){"use strict";Object.defineProperty(t,"expand",{enumerable:!0,get:function(){return T}}),Object.defineProperty(t,"readRole",{enumerable:!0,get:function(){return q}}),Object.defineProperty(t,"rolesCss",{enumerable:!0,get:function(){return S}});const Y=ue("packages/modules/charts/scheme.js").PALETTE,fe="lat-chartview",se=Object.freeze(["#4ea6dd","#f0b429","#34c79a","#e39ec4","#7cc7f0","#f07c3f","#a48ad4","#93a3b1"]),ne=":where(:root,.lattice,.lattice-tokens,[data-theme])",n=`
6
+ (function(Cn){"use strict";var Mn=!0,Pn=Object.create(null),Nn=Object.create(null);function qe(t,ce){Pn[t]=ce}function jn(t){var ce=Nn[t];if(ce)return ce;var _e=Object.create(null);Nn[t]=_e;var H=Pn[t];if(!H)throw new Error("[lattice] missing module: "+t);return H(_e,jn),_e}qe("packages/core/src/internal/warn.js",function(t,ce){"use strict";Object.defineProperty(t,"reportedWarnings",{enumerable:!0,get:function(){return E}}),Object.defineProperty(t,"warnOnce",{enumerable:!0,get:function(){return B}}),Object.defineProperty(t,"infoOnce",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"resetWarnings",{enumerable:!0,get:function(){return S}}),Object.defineProperty(t,"fail",{enumerable:!0,get:function(){return y}}),Object.defineProperty(t,"invariant",{enumerable:!0,get:function(){return P}}),Object.defineProperty(t,"DEV",{enumerable:!0,get:function(){return N}});const _e=new Set,H=2e3;function ue(p){if(_e.add(p),_e.size>H){const u=_e.values().next().value;u!==void 0&&_e.delete(u)}}const ie=[],te=500;function n(p,u,h){ie.push({key:p,level:u,message:h.map(c=>typeof c=="string"?c:V(c)).join(" "),at:Date.now()}),ie.length>te&&ie.shift()}function V(p){if(p instanceof Error)return p.message;try{return JSON.stringify(p)}catch{return String(p)}}function E(){return ie.map(p=>({...p}))}function q(p){if(p.length===0||typeof p[0]!="string")return p;const u=p[0].replace(/^\[lattice\]\s*/,"");return u===p[0]?p:[u,...p.slice(1)]}function B(p,...u){if(_e.has(p))return;ue(p);const h=q(u);n(p,"warn",h),console.warn("[lattice]",...h)}function f(p,...u){if(_e.has(p))return;ue(p);const h=q(u);n(p,"info",h),console.info("[lattice]",...h)}function S(){_e.clear(),ie.length=0}function y(p,u){const h=new Error(`[lattice] ${p}`);throw u!==void 0&&(h.cause=u),h}function P(p,u){p||y(u)}const N=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})()}),qe("packages/core/src/internal/predicates.js",function(t,ce){"use strict";Object.defineProperty(t,"isObject",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(t,"isFunction",{enumerable:!0,get:function(){return H}}),Object.defineProperty(t,"isNil",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(t,"isBlank",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(t,"isCtor",{enumerable:!0,get:function(){return te}});function _e(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function H(n){return typeof n=="function"}function ue(n){return n==null}function ie(n){return n==null||n===""}function te(n){return typeof n!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(n))?!0:!!(n.prototype&&Object.getOwnPropertyNames(n.prototype).length>1)}}),qe("packages/modules/geometry/geodata.js",function(t,ce){"use strict";Object.defineProperty(t,"GEOMETRY_KINDS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"SPATIAL_OPERATORS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(t,"GEOMETRY_OPERATORS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(t,"EARTH_RADIUS",{enumerable:!0,get:function(){return q}}),Object.defineProperty(t,"toWkt",{enumerable:!0,get:function(){return b}}),Object.defineProperty(t,"toWkb",{enumerable:!0,get:function(){return X}}),Object.defineProperty(t,"readGeometry",{enumerable:!0,get:function(){return a}}),Object.defineProperty(t,"parseGeometry",{enumerable:!0,get:function(){return $}}),Object.defineProperty(t,"haversine",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(t,"geometryInfo",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(t,"geometryKind",{enumerable:!0,get:function(){return we}}),Object.defineProperty(t,"spatialOperand",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(t,"spatialPredicate",{enumerable:!0,get:function(){return xe}});const _e=ce("packages/core/src/internal/predicates.js"),H=_e.isNil,ue=_e.isObject,te=ce("packages/core/src/internal/warn.js").warnOnce,n=Object.freeze(["Point","LineString","Polygon","MultiPoint","MultiLineString","MultiPolygon","GeometryCollection"]),V=Object.freeze(["withinBbox","withinPolygon","intersects","withinDistance"]),E=Object.freeze([...V,"blank","notBlank"]),q=63710088e-1,B=Math.PI/180,f=16,S=1e-12;class y extends Error{}function P(g){throw new y(g)}function N(g){(!Array.isArray(g)||g.length<2)&&P("a position needs at least two numbers");const A=Number(g[0]),K=Number(g[1]);return(typeof g[0]!="number"||typeof g[1]!="number"||!Number.isFinite(A)||!Number.isFinite(K))&&P("a coordinate is not a finite number"),[A,K]}function p(g,A,K){Array.isArray(g)||P(`${K} is not an array of positions`);const ae=g.map(N);return ae.length<A&&P(`${K} needs at least ${A} positions, found ${ae.length}`),ae}function u(g){const A=p(g,3,"a polygon ring"),K=A[0],ae=A[A.length-1];return(K[0]!==ae[0]||K[1]!==ae[1])&&A.push([K[0],K[1]]),A.length<4&&P(`a polygon ring needs at least 3 distinct corners, found ${A.length-1}`),A}function h(g){return(!Array.isArray(g)||g.length===0)&&P("a polygon needs at least an outer ring"),g.map(u)}function c(g,A){switch(A>f&&P("geometry collections nest too deeply"),ue(g)||P("GeoJSON must be an object"),g.type){case"Feature":return g.geometry==null?null:c(g.geometry,A+1);case"FeatureCollection":return P("a FeatureCollection holds many rows, not one value; load its features as rows");case"Point":return{type:"Point",coordinates:N(g.coordinates)};case"MultiPoint":return{type:"MultiPoint",coordinates:p(g.coordinates,1,"a MultiPoint")};case"LineString":return{type:"LineString",coordinates:p(g.coordinates,2,"a LineString")};case"MultiLineString":return(!Array.isArray(g.coordinates)||!g.coordinates.length)&&P("a MultiLineString needs at least one line"),{type:"MultiLineString",coordinates:g.coordinates.map(K=>p(K,2,"a LineString"))};case"Polygon":return{type:"Polygon",coordinates:h(g.coordinates)};case"MultiPolygon":return(!Array.isArray(g.coordinates)||!g.coordinates.length)&&P("a MultiPolygon needs at least one polygon"),{type:"MultiPolygon",coordinates:g.coordinates.map(h)};case"GeometryCollection":{(!Array.isArray(g.geometries)||!g.geometries.length)&&P("a GeometryCollection needs at least one geometry");const K=g.geometries.map(ae=>c(ae,A+1)).filter(Boolean);return K.length?{type:"GeometryCollection",geometries:K}:null}default:return P(`"${String(g.type)}" is not a GeoJSON geometry type`)}}const k=Object.freeze({POINT:"Point",LINESTRING:"LineString",POLYGON:"Polygon",MULTIPOINT:"MultiPoint",MULTILINESTRING:"MultiLineString",MULTIPOLYGON:"MultiPolygon",GEOMETRYCOLLECTION:"GeometryCollection"}),m=/[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/y,r=/[A-Za-z]+/y,v=/^\s*(?:SRID\s*=\s*\d+\s*;\s*)?[A-Za-z]+\s*(?:ZM|Z|M)?\s*(?:\(|EMPTY\b)/i;class l{text;at=0;constructor(A){this.text=A}space(){for(;this.at<this.text.length&&/\s/.test(this.text[this.at]);)this.at++}expect(A){this.space(),this.text[this.at]!==A&&P(`WKT expected "${A}" at character ${this.at+1}, found "${this.text[this.at]??"the end"}"`),this.at++}accept(A){return this.space(),this.text[this.at]===A?(this.at++,!0):!1}word(){this.space(),r.lastIndex=this.at;const A=r.exec(this.text);return A?(this.at+=A[0].length,A[0].toUpperCase()):""}numberNext(){return this.space(),m.lastIndex=this.at,m.test(this.text)}number(){this.space(),m.lastIndex=this.at;const A=m.exec(this.text);return A||P(`WKT expected a number at character ${this.at+1}`),this.at+=A[0].length,Number(A[0])}position(){const A=this.number(),K=this.number();for(;this.numberNext();)this.number();return[A,K]}positionList(){this.expect("(");const A=[this.position()];for(;this.accept(",");)A.push(this.position());return this.expect(")"),A}empty(){const A=this.at;return this.word()==="EMPTY"?!0:(this.at=A,!1)}geometry(A){A>f&&P("geometry collections nest too deeply");const K=this.word(),ae=k[K];ae||P(K?`"${K}" is not a WKT geometry type`:"WKT expected a geometry type");const ye=this.at,ke=this.word();return ke!=="Z"&&ke!=="M"&&ke!=="ZM"&&(this.at=ye),this.empty()?null:this.body(ae,A)}body(A,K){switch(A){case"Point":{this.expect("(");const ae=this.position();return this.expect(")"),{type:"Point",coordinates:ae}}case"LineString":return{type:"LineString",coordinates:p(this.positionList(),2,"a LineString")};case"Polygon":return{type:"Polygon",coordinates:this.polygonBody()};case"MultiPoint":{this.expect("(");const ae=[];do this.empty()||(this.accept("(")?(ae.push(this.position()),this.expect(")")):ae.push(this.position()));while(this.accept(","));return this.expect(")"),ae.length?{type:"MultiPoint",coordinates:ae}:null}case"MultiLineString":{const ae=this.parts(()=>p(this.positionList(),2,"a LineString"));return ae.length?{type:"MultiLineString",coordinates:ae}:null}case"MultiPolygon":{const ae=this.parts(()=>this.polygonBody());return ae.length?{type:"MultiPolygon",coordinates:ae}:null}default:{this.expect("(");const ae=[];do{const ye=this.geometry(K+1);ye&&ae.push(ye)}while(this.accept(","));return this.expect(")"),ae.length?{type:"GeometryCollection",geometries:ae}:null}}}parts(A){this.expect("(");const K=[];do this.empty()||K.push(A());while(this.accept(","));return this.expect(")"),K}polygonBody(){return h(this.parts(()=>this.positionList()))}}function x(g){const A=new l(String(g).replace(/^\s*SRID\s*=\s*\d+\s*;/i,"")),K=A.geometry(0);return A.space(),A.at<A.text.length&&P(`WKT has unexpected text after the geometry at character ${A.at+1}`),K}function W(g){return Object.is(g,-0)?"0":String(g)}function J(g){return`${W(g[0])} ${W(g[1])}`}function se(g){return`(${g.map(J).join(", ")})`}function re(g){return`(${g.map(se).join(", ")})`}function b(g){const A=$(g);return A?C(A):""}function C(g){switch(g.type){case"Point":return`POINT (${J(g.coordinates)})`;case"LineString":return`LINESTRING ${se(g.coordinates)}`;case"Polygon":return`POLYGON ${re(g.coordinates)}`;case"MultiPoint":return`MULTIPOINT (${g.coordinates.map(A=>`(${J(A)})`).join(", ")})`;case"MultiLineString":return`MULTILINESTRING (${g.coordinates.map(se).join(", ")})`;case"MultiPolygon":return`MULTIPOLYGON (${g.coordinates.map(re).join(", ")})`;default:return`GEOMETRYCOLLECTION (${g.geometries.map(C).join(", ")})`}}class I{view;at=0;constructor(A){this.view=new DataView(A.buffer,A.byteOffset,A.byteLength)}need(A){this.at+A>this.view.byteLength&&P(`WKB ends after ${this.view.byteLength} bytes, in the middle of a geometry`)}u8(){return this.need(1),this.view.getUint8(this.at++)}u32(A){this.need(4);const K=this.view.getUint32(this.at,A);return this.at+=4,K}f64(A){this.need(8);const K=this.view.getFloat64(this.at,A);return this.at+=8,K}count(A,K){const ae=this.u32(A);return ae*K>this.view.byteLength-this.at&&P(`WKB claims ${ae} elements, more than its bytes can hold`),ae}position(A,K){const ae=this.f64(A),ye=this.f64(A);for(let ke=2;ke<K;ke++)this.f64(A);return[ae,ye]}positions(A,K){const ae=this.count(A,8*K),ye=new Array(ae);for(let ke=0;ke<ae;ke++)ye[ke]=this.position(A,K);return ye}geometry(A,K){A>f&&P("geometry collections nest too deeply");const ae=this.u8();ae!==0&&ae!==1&&P(`WKB byte-order mark is ${ae}, not 0 or 1`);const ye=ae===1,ke=this.u32(ye);let Te=2;ke&2147483648&&Te++,ke&1073741824&&Te++,ke&536870912&&this.u32(ye);let ze=ke&268435455;if(ze>=1e3){const He=Math.floor(ze/1e3);He>3&&P(`WKB geometry type ${ze} is not one this reads`),Te=2+(He===3?2:1),ze%=1e3}const Ze=n[ze-1];switch(Ze||P(`WKB geometry type ${ze} is not one this reads`),K&&Ze!==K&&P(`a part of a WKB Multi${K} is a ${Ze}`),Ze){case"Point":{const He=this.position(ye,Te);return Number.isNaN(He[0])&&Number.isNaN(He[1])?null:{type:"Point",coordinates:N(He)}}case"LineString":return{type:"LineString",coordinates:p(this.positions(ye,Te),2,"a LineString")};case"Polygon":{const He=this.count(ye,4),Ke=[];for(let Fe=0;Fe<He;Fe++)Ke.push(this.positions(ye,Te));return He?{type:"Polygon",coordinates:h(Ke)}:null}default:{const He=this.count(ye,5),Ke=Ze==="GeometryCollection"?void 0:Ze.slice(5),Fe=[];for(let ct=0;ct<He;ct++){const tt=this.geometry(A+1,Ke);tt&&Fe.push(tt)}return Fe.length?Ze==="GeometryCollection"?{type:Ze,geometries:Fe}:{type:Ze,coordinates:Fe.map(ct=>ct.coordinates)}:null}}}}function M(g){const A=new I(g),K=A.geometry(0);return A.at!==g.byteLength&&P(`WKB has ${g.byteLength-A.at} bytes left over after the geometry`),K}function X(g){const A=$(g);if(!A)return null;const K=[];let ae=0;const ye=Ke=>{const Fe=new DataView(new ArrayBuffer(5));Fe.setUint8(0,1),Fe.setUint32(1,n.indexOf(Ke)+1,!0),K.push(Fe),ae+=5},ke=Ke=>{const Fe=new DataView(new ArrayBuffer(4));Fe.setUint32(0,Ke,!0),K.push(Fe),ae+=4},Te=Ke=>{const Fe=new DataView(new ArrayBuffer(16*Ke.length));Ke.forEach((ct,tt)=>{Fe.setFloat64(tt*16,ct[0],!0),Fe.setFloat64(tt*16+8,ct[1],!0)}),K.push(Fe),ae+=16*Ke.length},ze=Ke=>{switch(ye(Ke.type),Ke.type){case"Point":Te([Ke.coordinates]);break;case"LineString":ke(Ke.coordinates.length),Te(Ke.coordinates);break;case"Polygon":ke(Ke.coordinates.length);for(const Fe of Ke.coordinates)ke(Fe.length),Te(Fe);break;case"GeometryCollection":ke(Ke.geometries.length);for(const Fe of Ke.geometries)ze(Fe);break;default:{const Fe=Ke.type.slice(5);ke(Ke.coordinates.length);for(const ct of Ke.coordinates)ze({type:Fe,coordinates:ct})}}};ze(A);const Ze=new Uint8Array(ae);let He=0;for(const Ke of K)Ze.set(new Uint8Array(Ke.buffer),He),He+=Ke.byteLength;return Ze}const z=/^0[01](?:[0-9a-fA-F]{2})+$/,ne=/^[A-Za-z0-9+/_-]+={0,2}$/,R=(()=>{const g=new Int16Array(128).fill(-1),A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let K=0;K<A.length;K++)g[A.charCodeAt(K)]=K;return g[45]=62,g[95]=63,g})();function G(g){const A=new Uint8Array(g.length/2);for(let K=0;K<A.length;K++)A[K]=parseInt(g.slice(K*2,K*2+2),16);return A}function T(g){const A=g.replace(/=+$/,""),K=new Uint8Array(Math.floor(A.length*3/4));let ae=0,ye=0,ke=0;for(let Te=0;Te<A.length;Te++)ye=ye<<6|R[A.charCodeAt(Te)],ae+=6,ae>=8&&(ae-=8,K[ke++]=ye>>ae&255);return K.subarray(0,ke)}function e(g){const A=g.trim();if(A==="")return null;if(A[0]==="{"){let K;try{K=JSON.parse(A)}catch{return P("the text starts like GeoJSON but is not valid JSON")}return c(K,0)}if(z.test(A))return M(G(A));if(v.test(A))return x(A);if(ne.test(A)){const K=T(A);if(K.length>=5&&(K[0]===0||K[0]===1))return M(K)}return P("the text is not WKT, GeoJSON, or hex or base64 WKB")}const s=new WeakSet;function a(g){if(H(g))return{geometry:null,reason:null};if(typeof g=="object"&&s.has(g))return{geometry:g,reason:null};try{let A;return typeof g=="string"?A=e(g):g instanceof Uint8Array?A=M(g):g instanceof ArrayBuffer?A=M(new Uint8Array(g)):ArrayBuffer.isView(g)?A=M(new Uint8Array(g.buffer,g.byteOffset,g.byteLength)):ue(g)?A=c(g,0):P(`${Array.isArray(g)?"an array":`a ${typeof g}`} is not a geometry`),A&&_(A),{geometry:A||null,reason:null}}catch(A){if(A instanceof y)return{geometry:null,reason:A.message};throw A}}function _(g){if(s.add(g),g.type==="GeometryCollection")for(const A of g.geometries)_(A)}function $(g){return a(g).geometry}function Q(g,A){switch(g.type){case"Point":A(g.coordinates);break;case"MultiPoint":case"LineString":g.coordinates.forEach(A);break;case"MultiLineString":case"Polygon":for(const K of g.coordinates)K.forEach(A);break;case"MultiPolygon":for(const K of g.coordinates)for(const ae of K)ae.forEach(A);break;default:for(const K of g.geometries)Q(K,A)}}function ve(g,A){const K=g[1]*B,ae=A[1]*B,ye=ae-K,ke=(A[0]-g[0])*B,Te=Math.sin(ye/2)**2+Math.cos(K)*Math.cos(ae)*Math.sin(ke/2)**2;return 2*q*Math.asin(Math.min(1,Math.sqrt(Te)))}function ge(g){let A=0;for(let K=1;K<g.length;K++)A+=ve(g[K-1],g[K]);return A}function Se(g){const A=g.length-1;if(A<3)return 0;let K=0;for(let ae=0;ae<A;ae++){const ye=g[(ae-1+A)%A],ke=g[(ae+1)%A];K+=(ke[0]-ye[0])*B*Math.sin(g[ae][1]*B)}return Math.abs(K)*q*q/2}function Ne(g){let A=Se(g[0]);for(let K=1;K<g.length;K++)A-=Se(g[K]);return Math.max(0,A)}function Le(g){let A=0,K=0,ae=0;for(let ye=0;ye<g.length-1;ye++){const[ke,Te]=g[ye],[ze,Ze]=g[ye+1],He=ke*Ze-ze*Te;A+=He,K+=(ke+ze)*He,ae+=(Te+Ze)*He}return{a:A,cx:K,cy:ae}}function j(){let g=0,A=0,K=0;return{add(ae,ye,ke){g+=ae*ke,A+=ye*ke,K+=ke},get(){return K>0?[g/K,A/K]:null}}}function pe(g){let A=0,K=0;for(const ae of g)A+=ae[0],K+=ae[1];return[A/g.length,K/g.length]}function he(g,A){switch(g.type){case"Point":A[0].add(g.coordinates[0],g.coordinates[1],1);break;case"MultiPoint":for(const K of g.coordinates)A[0].add(K[0],K[1],1);break;case"LineString":case"MultiLineString":{const K=g.type==="LineString"?[g.coordinates]:g.coordinates;for(const ae of K){for(let ye=1;ye<ae.length;ye++){const[ke,Te]=ae[ye-1],[ze,Ze]=ae[ye],He=Math.hypot(ze-ke,Ze-Te);A[1].add((ke+ze)/2,(Te+Ze)/2,He)}for(const ye of ae)A[0].add(ye[0],ye[1],1)}break}case"Polygon":case"MultiPolygon":{const K=g.type==="Polygon"?[g.coordinates]:g.coordinates;for(const ae of K){let ye=0,ke=0,Te=0;ae.forEach((Ze,He)=>{const Ke=Le(Ze),Fe=(He===0?1:-1)*(Ke.a<0?-1:1);ye+=Fe*Ke.a,ke+=Fe*Ke.cx,Te+=Fe*Ke.cy}),Math.abs(ye)>S&&A[2].add(ke/(3*ye),Te/(3*ye),Math.abs(ye)/2);const ze=ae[0].slice(0,-1);for(const Ze of ze)A[0].add(Ze[0],Ze[1],1)}break}default:for(const K of g.geometries)he(K,A)}}const oe=new WeakMap;function fe(g){const A=$(g);if(!A)return null;const K=oe.get(A);if(K)return K;const ae=[1/0,1/0,-1/0,-1/0];Q(A,Ke=>{Ke[0]<ae[0]&&(ae[0]=Ke[0]),Ke[1]<ae[1]&&(ae[1]=Ke[1]),Ke[0]>ae[2]&&(ae[2]=Ke[0]),Ke[1]>ae[3]&&(ae[3]=Ke[1])});const ye=[j(),j(),j()];he(A,ye);const ke=ye[2].get()||ye[1].get()||ye[0].get()||pe([[ae[0],ae[1]],[ae[2],ae[3]]]);let Te=0,ze=0;const Ze=Ke=>{switch(Ke.type){case"LineString":Te+=ge(Ke.coordinates);break;case"MultiLineString":for(const Fe of Ke.coordinates)Te+=ge(Fe);break;case"Polygon":ze+=Ne(Ke.coordinates);for(const Fe of Ke.coordinates)Te+=ge(Fe);break;case"MultiPolygon":for(const Fe of Ke.coordinates){ze+=Ne(Fe);for(const ct of Fe)Te+=ge(ct)}break;case"GeometryCollection":for(const Fe of Ke.geometries)Ze(Fe);break;default:break}};Ze(A);const He=Object.freeze({kind:A.type,bbox:Object.freeze(ae),centroid:Object.freeze(ke),length:Te,area:ze});return oe.set(A,He),He}function we(g){const A=fe(g);return A?A.kind:null}function i(g,A){const K=typeof g=="string"?g.split(/[\s,;]+/).filter(Boolean):g;if(!Array.isArray(K)||K.length!==A)return null;const ae=K.map(ye=>typeof ye=="number"?ye:typeof ye=="string"?Number(ye):NaN);return ae.every(Number.isFinite)?ae:null}function Y(g,A){if(g==="withinBbox"){const K=i(A,4);return K?K[0]>K[2]?{reason:'the box crosses the antimeridian (its west edge is east of its east edge), which is not supported; split it into two withinBbox conditions joined by "or"'}:K[1]>K[3]?{reason:"the box's minLat is above its maxLat"}:{operand:K}:{reason:"withinBbox needs [minLon, minLat, maxLon, maxLat]"}}if(g==="withinDistance"){let K=null;if(ue(A)&&!Array.isArray(A)){const ae=A;K=i([ae.lon,ae.lat,ae.metres],3)}else K=i(A,3);return!K||K[2]<0?{reason:"withinDistance needs { lon, lat, metres } with metres of 0 or more"}:{operand:{lon:K[0],lat:K[1],metres:K[2]}}}if(g==="withinPolygon"||g==="intersects"){const K=g==="intersects"?i(A,4):null;if(K){if(K[0]>K[2]||K[1]>K[3])return{reason:"the box's minimum is above its maximum"};const[ke,Te,ze,Ze]=K;return{operand:{type:"Polygon",coordinates:[[[ke,Te],[ze,Te],[ze,Ze],[ke,Ze],[ke,Te]]]}}}const{geometry:ae,reason:ye}=a(A);return ae?g==="withinPolygon"&&ae.type!=="Polygon"&&ae.type!=="MultiPolygon"?{reason:`withinPolygon needs a Polygon or MultiPolygon, not a ${ae.type}`}:{operand:ae}:{reason:`${g} needs a geometry: ${ye||"none was given"}`}}return{reason:`"${g}" is not a spatial operator`}}function o(g,A){const[K,ae]=g;let ye=!1;for(let ke=0,Te=A.length-2;ke<A.length-1;Te=ke++){const[ze,Ze]=A[ke],[He,Ke]=A[Te];Ze>ae!=Ke>ae&&K<(He-ze)*(ae-Ze)/(Ke-Ze)+ze&&(ye=!ye)}return ye}function d(g,A){if(!o(g,A[0]))return!1;for(let K=1;K<A.length;K++)if(o(g,A[K]))return!1;return!0}function O(g,A={points:[],segments:[],polygons:[]}){const K=ae=>{for(let ye=1;ye<ae.length;ye++)A.segments.push([ae[ye-1],ae[ye]]);for(const ye of ae)A.points.push(ye)};switch(g.type){case"Point":A.points.push(g.coordinates);break;case"MultiPoint":for(const ae of g.coordinates)A.points.push(ae);break;case"LineString":K(g.coordinates);break;case"MultiLineString":g.coordinates.forEach(K);break;case"Polygon":A.polygons.push(g.coordinates),g.coordinates.forEach(K);break;case"MultiPolygon":for(const ae of g.coordinates)A.polygons.push(ae),ae.forEach(K);break;default:for(const ae of g.geometries)O(ae,A)}return A}function F(g,A,K){const ae=(A[0]-g[0])*(K[1]-g[1])-(A[1]-g[1])*(K[0]-g[0]);return Math.abs(ae)<=S?0:Math.sign(ae)}function U(g,A,K){return g[0]>=Math.min(A[0],K[0])-S&&g[0]<=Math.max(A[0],K[0])+S&&g[1]>=Math.min(A[1],K[1])-S&&g[1]<=Math.max(A[1],K[1])+S}function ee(g,A){const[K,ae]=g,[ye,ke]=A,Te=F(K,ae,ye),ze=F(K,ae,ke),Ze=F(ye,ke,K),He=F(ye,ke,ae);return Te!==ze&&Ze!==He?!0:Te===0&&U(ye,K,ae)||ze===0&&U(ke,K,ae)||Ze===0&&U(K,ye,ke)||He===0&&U(ae,ye,ke)}function L(g,A){return g[0]<=A[2]&&A[0]<=g[2]&&g[1]<=A[3]&&A[1]<=g[3]}function Z(g,A){const K=fe(g),ae=fe(A);if(!L(K.bbox,ae.bbox))return!1;const ye=O(g),ke=O(A);for(const Te of ke.polygons)for(const ze of ye.points)if(d(ze,Te))return!0;for(const Te of ye.polygons)for(const ze of ke.points)if(d(ze,Te))return!0;for(const Te of ye.segments)for(const ze of ke.segments)if(ee(Te,ze))return!0;for(const Te of ye.points){for(const ze of ke.points)if(Math.abs(Te[0]-ze[0])<=S&&Math.abs(Te[1]-ze[1])<=S)return!0;for(const ze of ke.segments)if(F(ze[0],ze[1],Te)===0&&U(Te,ze[0],ze[1]))return!0}for(const Te of ke.points)for(const ze of ye.segments)if(F(ze[0],ze[1],Te)===0&&U(Te,ze[0],ze[1]))return!0;return!1}function xe(g,A){const{operand:K,reason:ae}=Y(g,A);if(ae)return te(`filter:geometry:${g}`,`a "${g}" condition was refused: ${ae}. It matches no row rather than guessing.`),()=>!1;switch(g){case"withinBbox":return ye=>{const ke=fe(ye);if(!ke)return!1;const Te=ke.bbox;return Te[0]>=K[0]&&Te[1]>=K[1]&&Te[2]<=K[2]&&Te[3]<=K[3]};case"withinPolygon":{const ye=K.type==="Polygon"?[K.coordinates]:K.coordinates,ke=Te=>ye.some(ze=>d(Te,ze));return Te=>{const ze=$(Te);return ze?ze.type==="Point"?ke(ze.coordinates):ze.type==="MultiPoint"?ze.coordinates.every(ke):ke(fe(ze).centroid):!1}}case"intersects":return ye=>{const ke=$(ye);return!!ke&&Z(ke,K)};default:{const ye=[K.lon,K.lat];return ke=>{const Te=fe(ke);return!!Te&&ve(Te.centroid,ye)<=K.metres}}}}}),qe("packages/modules/shared/engine.js",function(t,ce){"use strict";Object.defineProperty(t,"sourceId",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(t,"engineSource",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(t,"gridPivoted",{enumerable:!0,get:function(){return te}}),Object.defineProperty(t,"loadedAndMatching",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"gridHoldsWindow",{enumerable:!0,get:function(){return V}}),Object.defineProperty(t,"gridEngineRequest",{enumerable:!0,get:function(){return q}}),Object.defineProperty(t,"EngineFlight",{enumerable:!0,get:function(){return B}});const _e=new WeakMap;let H=0;function ue(f){let S=_e.get(f);return S===void 0&&(S=++H,_e.set(f,S)),S}function ie(f){const S=f&&typeof f.config=="function"?f.config():null,y=S&&S.source&&typeof S.source=="object"?S.source:null;if(!y||typeof y.aggregate!="function")return{reason:"the grid's source has no aggregate() — it is not a pushdown source"};const P=y.capabilitiesOf(y.adapter&&y.adapter.capabilities);return{source:y,caps:P,config:S}}function te(f){const S=f&&typeof f.config=="function"?f.config():null,y=S&&S.source&&typeof S.source=="object"?S.source:null;if(!y||typeof y.lastPlan!="function")return!1;const P=f&&f.state&&typeof f.state.get=="function"?f.state.get():null,N=P&&P.pivot;return!!(N&&N.enabled&&Array.isArray(N.columns)&&N.columns.length>0)}function n(f){const S=f.rows&&typeof f.rows.residentCount=="function"?f.rows.residentCount():0,y=typeof f.rows.matchCount=="function"?f.rows.matchCount():NaN;return{loaded:S,total:Number.isFinite(y)?y:NaN}}function V(f){const S=f&&typeof f.config=="function"?f.config():null,y=S&&S.source&&typeof S.source=="object"?S.source:null;if(!y||y.mode!=="remote"&&y.mode!=="paged")return!1;if(typeof f.rows.matchCount=="function"&&f.rows.matchCount()===null)return!0;const{loaded:P,total:N}=n(f);return Number.isFinite(N)&&P<N}function E(f,S){return S?f?{op:"and",conditions:[f,S]}:S:f||null}function q(f,S,y=null){const P=f.filters&&typeof f.filters.where=="function"?f.filters.where():[];if(Array.isArray(P)&&P.length)return{reason:`a \`where\` predicate is in force (${P.join(", ")}), which only the browser can run`};const N=f.filters&&typeof f.filters.quickState=="function"?f.filters.quickState():{text:""},p=N&&N.text?String(N.text):"",{source:u,config:h,caps:c}=S,k={filters:u.wireFilters(E(f.filters.get(),y),{tz:h.timeZone,weekStartsOn:h.weekStartsOn}),sort:[],range:null,context:h.context??null,...p?{quick:p}:{}},m=u.planQuery(k,c);return m.unpushed.includes("filter")?{reason:y?"the grid's filter, or the viewport condition, did not fully push to the engine":"the grid's filter did not fully push to the engine"}:m.unpushed.includes("quick")?{reason:"the quick search did not push to the engine"}:{request:k,quick:p}}class B{#e=null;#t=null;#n=!1;answer(S){return this.#t&&this.#t.key===S?this.#t:null}last(){return this.#t}get busy(){return this.#e!==null}ask(S,y,P){const N=this.#e;if(N){N.key!==S&&N.controller&&N.controller.abort();return}const p=globalThis.AbortController,u=typeof p=="function"?new p:null,h={key:S,controller:u};this.#e=h;let c;Promise.resolve().then(()=>y(u?u.signal:null)).then(k=>{c={key:S,result:k}},k=>{c={key:S,error:k}}).then(()=>{this.#e===h&&(this.#e=null),!this.#n&&(u&&u.signal.aborted||(this.#t=c),P())})}abort(){const S=this.#e;S&&S.controller&&S.controller.abort()}close(){this.#n=!0,this.abort()}}}),qe("packages/modules/charts/scale.js",function(t,ce){"use strict";Object.defineProperty(t,"isNumber",{enumerable:!0,get:function(){return E}}),Object.defineProperty(t,"toNumber",{enumerable:!0,get:function(){return q}}),Object.defineProperty(t,"toTime",{enumerable:!0,get:function(){return B}}),Object.defineProperty(t,"extent",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"niceStep",{enumerable:!0,get:function(){return S}}),Object.defineProperty(t,"niceDomain",{enumerable:!0,get:function(){return y}}),Object.defineProperty(t,"measureDomain",{enumerable:!0,get:function(){return P}}),Object.defineProperty(t,"linearTicks",{enumerable:!0,get:function(){return N}}),Object.defineProperty(t,"timeStepFor",{enumerable:!0,get:function(){return p}}),Object.defineProperty(t,"MONTH_STEPS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(t,"timeTicks",{enumerable:!0,get:function(){return l}}),Object.defineProperty(t,"linearScale",{enumerable:!0,get:function(){return x}}),Object.defineProperty(t,"timeScale",{enumerable:!0,get:function(){return W}}),Object.defineProperty(t,"key",{enumerable:!0,get:function(){return J}}),Object.defineProperty(t,"bandScale",{enumerable:!0,get:function(){return se}}),Object.defineProperty(t,"sqrtScale",{enumerable:!0,get:function(){return re}});const _e=[1,2,2.5,5,10],H=6e4,ue=36e5,ie=864e5,te=365.25*ie,n=[1,2,5,10,20,25,50,100],V=[1,5,10,25,50,100,250,500,1e3,5e3,15e3,3e4,H,5*H,15*H,30*H,ue,3*ue,6*ue,12*ue,ie,2*ie,7*ie,14*ie,30*ie,90*ie,180*ie,...n.map(b=>b*te)];function E(b){return typeof b=="number"&&Number.isFinite(b)}function q(b){if(b==null||b==="")return null;if(b instanceof Date){const I=b.getTime();return Number.isFinite(I)?I:null}if(typeof b=="boolean")return b?1:0;const C=Number(b);return Number.isFinite(C)?C:null}function B(b){if(b==null||b==="")return null;if(b instanceof Date){const I=b.getTime();return Number.isFinite(I)?I:null}if(typeof b=="number")return Number.isFinite(b)?b:null;const C=Date.parse(String(b));return Number.isFinite(C)?C:null}function f(b){let C=1/0,I=-1/0;for(let M=0;M<b.length;M++){const X=b[M];E(X)&&(X<C&&(C=X),X>I&&(I=X))}return C===1/0?null:{min:C,max:I}}function S(b){if(!(b>0))return 1;const C=10**Math.floor(Math.log10(b));for(const I of _e)if(b<=I*C)return I*C;return 10*C}function y(b,C=5){const I=S((b.max-b.min)/Math.max(1,C));return{min:Math.floor(b.min/I)*I,max:Math.ceil(b.max/I)*I,step:I}}function P(b,C={}){const I=f(b)||{min:0,max:1};let{min:M,max:X}=I;if(C.zero&&(M>0&&(M=0),X<0&&(X=0)),M===X){const z=Math.abs(M)>0?Math.abs(M)/10:1;M-=z,X+=z}if(C.nice!==!1){const z=y({min:M,max:X},C.ticks||5);M=z.min,X=z.max}return E(C.min)&&(M=C.min),E(C.max)&&(X=C.max),M===X&&(X=M+1),{min:M,max:X}}function N(b,C=5){const I=S((b.max-b.min)/Math.max(1,C)),M=Math.ceil(b.min/I),X=Math.floor(b.max/I),z=[];for(let ne=M;ne<=X;ne++){const R=ne*I;z.push(Math.abs(R)<I/1e6?0:Number(R.toPrecision(12)))}return z}function p(b,C=5){const I=Math.max(1,C),M=b/I;let X=V[V.length-1];for(const R of V)if(R>=M){X=R;break}if(X<te)return X;let z=X,ne=Math.abs(b/X-I);for(const R of V){if(R<te)continue;const G=Math.abs(b/R-I);G<ne&&(ne=G,z=R)}return z}const u=new Map;function h(b){let C=u.get(b);return C||(C=new Intl.DateTimeFormat("en-US",{timeZone:b,year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),u.set(b,C)),C}function c(b,C){const I={year:0,month:0,day:1,hour:0,minute:0,second:0};for(const M of h(C).formatToParts(new Date(b)))switch(M.type){case"year":I.year=Number(M.value);break;case"month":I.month=Number(M.value)-1;break;case"day":I.day=Number(M.value);break;case"hour":I.hour=Number(M.value)%24;break;case"minute":I.minute=Number(M.value);break;case"second":I.second=Number(M.value);break;default:break}return I}function k(b,C,I){const M=Date.UTC(b,C,1);let X=M;for(let z=0;z<2;z++){const ne=c(X,I),R=Date.UTC(ne.year,ne.month,ne.day,ne.hour,ne.minute,ne.second),G=M-R;if(G===0)break;X+=G}return X}function m(b,C,I){const M=I?c(b.min,I).year:new Date(b.min).getUTCFullYear();let X=Math.ceil(M/C)*C;const z=R=>I?k(R,0,I):Date.UTC(R,0,1);z(X)<b.min&&(X+=C);const ne=[];for(;z(X)<=b.max;X+=C)ne.push(z(X));return ne}const r=new Map([[30*ie,1],[90*ie,3],[180*ie,6]]);function v(b,C,I){const M=I?c(b.min,I):{year:new Date(b.min).getUTCFullYear(),month:new Date(b.min).getUTCMonth()};let X=M.year*12+M.month;const z=R=>{const G=Math.floor(R/12),T=R-G*12;return I?k(G,T,I):Date.UTC(G,T,1)};z(X)<b.min&&(X+=1),X=Math.ceil(X/C)*C;const ne=[];for(;;X+=C){const R=z(X);if(R>b.max)break;ne.push(R)}return ne}function l(b,C=5,I){const M=p(b.max-b.min,C);if(M>=te)return m(b,Math.round(M/te),I);const X=r.get(M);if(X)return v(b,X,I);const z=[],ne=Math.ceil(b.min/M)*M;for(let R=ne;R<=b.max;R+=M)z.push(R);return z}function x(b,C){const I=b.max-b.min||1,[M,X]=C;return{kind:"linear",domain:b,range:C,of(z){return M+(z-b.min)/I*(X-M)},invert(z){return b.min+(z-M)/(X-M||1)*I},ticks(z=5){return N(b,z)}}}function W(b,C){return{...x(b,C),kind:"time",ticks(M=5,X){return l(b,M,X)}}}function J(b){if(b==null)return" null";if(b instanceof Date)return` date:${b.getTime()}`;if(typeof b=="object"){const C=b,I=C.id??C.key??C.value;return I!==void 0&&typeof I!="object"?` obj:${String(I)}`:` obj:${String(b)}`}return String(b)}function se(b,C,I=.2){const M=Math.min(.9,Math.max(0,I)),[X,z]=C,ne=new Map;for(let T=0;T<b.length;T++){const e=J(b[T]);ne.has(e)||ne.set(e,T)}const R=b.length?(z-X)/b.length:z-X,G=Math.max(0,R*(1-M));return{kind:"band",domain:b,range:C,bandwidth:G,step:R,of(T){const e=ne.get(J(T));return e===void 0?NaN:X+e*R+(R-G)/2},centre(T){const e=this.of(T);return Number.isNaN(e)?NaN:e+G/2},ticks(){return b}}}function re(b,C){const[I,M]=C,X=Math.max(Math.abs(b.max),Math.abs(b.min),0)||1;return{kind:"sqrt",domain:b,range:C,of(z){const ne=Math.sqrt(Math.abs(z)/X);return I+ne*(M-I)}}}}),qe("packages/modules/charts/svg.js",function(t,ce){"use strict";Object.defineProperty(t,"SVG_NS",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(t,"el",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(t,"svg",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(t,"attr",{enumerable:!0,get:function(){return te}}),Object.defineProperty(t,"attrs",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"setText",{enumerable:!0,get:function(){return V}}),Object.defineProperty(t,"clear",{enumerable:!0,get:function(){return E}}),Object.defineProperty(t,"append",{enumerable:!0,get:function(){return q}}),Object.defineProperty(t,"path",{enumerable:!0,get:function(){return B}}),Object.defineProperty(t,"ribbonPath",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"round",{enumerable:!0,get:function(){return S}}),Object.defineProperty(t,"pathRings",{enumerable:!0,get:function(){return y}}),Object.defineProperty(t,"insideRings",{enumerable:!0,get:function(){return P}});const _e="http://www.w3.org/2000/svg";function H(N){const p=N.indexOf(")");return p<0?N:N.slice(p+1).trim()||"#0072b2"}function ue(N,p,u){const h=N.createElement(p);return u&&h.setAttribute("class",u),h}function ie(N,p,u){const h=N.createElementNS(_e,p);if(u)for(const c of Object.keys(u))h.setAttribute(c,String(u[c]));return h}function te(N,p,u){if(!N)return;if(u==null){N.removeAttribute(p);return}let h=String(u);h.startsWith("url(#")&&(p==="stroke"||p==="fill"&&N.localName==="text")&&(h=H(h)),N.setAttribute(p,h)}function n(N,p){if(N)for(const u of Object.keys(p))te(N,u,p[u])}function V(N,p){N&&(N.textContent=p==null?"":String(p))}function E(N){if(N)for(;N.firstChild;)N.removeChild(N.firstChild)}function q(N,p){for(const u of p)u&&N.appendChild(u);return N}function B(N){return N.join(" ")}function f(N){if(!N||N.length<2)return"";const p=["M",N[0].x,N[0].upper];for(let u=1;u<N.length;u++)p.push("L",N[u].x,N[u].upper);for(let u=N.length-1;u>=0;u--)p.push("L",N[u].x,N[u].lower);return p.push("Z"),B(p)}function S(N){return Math.round(N*100)/100}function y(N){const p=[];let u=[];const h=String(N||"").match(/[A-Za-z]|-?\d*\.?\d+(?:e[-+]?\d+)?/gi)||[];let c="",k=[];const m=()=>{if(!c||!k.length){k=[];return}if(c==="M"||c==="L")for(let r=0;r+1<k.length;r+=2)u.push([k[r],k[r+1]]);else c!=="Z"&&k.length>=2&&u.push([k[k.length-2],k[k.length-1]]);k=[]};for(const r of h){if(/[A-Za-z]/.test(r)){if(m(),r==="Z"||r==="z"){u.length>2&&p.push(u),u=[],c="";continue}r==="M"&&u.length>2&&(p.push(u),u=[]),c=r;continue}k.push(Number(r))}return m(),u.length>2&&p.push(u),p}function P(N,p,u){let h=!1;for(const c of N)for(let k=0,m=c.length-1;k<c.length;m=k++){const[r,v]=c[k],[l,x]=c[m];v>u!=x>u&&p<(l-r)*(u-v)/(x-v||1e-12)+r&&(h=!h)}return h}}),qe("packages/modules/charts/typography.js",function(t,ce){"use strict";Object.defineProperty(t,"BASE_SIZE",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(t,"BASE_FAMILY",{enumerable:!0,get:function(){return H}}),Object.defineProperty(t,"CHAR_RATIO",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(t,"resolveType",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(t,"textWidth",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"widestLabel",{enumerable:!0,get:function(){return V}}),Object.defineProperty(t,"truncateTo",{enumerable:!0,get:function(){return E}}),Object.defineProperty(t,"applySize",{enumerable:!0,get:function(){return q}});const _e=12,H="var(--lattice-font-family, system-ui, -apple-system, sans-serif)",ue=.62;function ie(B){const f=B&&B.font,S=typeof f=="number"?{size:f}:f||{},y=te(S.size,_e);return{family:S.family||H,size:y,small:te(S.small??S.tickSize,Math.max(9,y-1)),title:te(S.title,Math.round(y*1.15)),axisTitle:te(S.axisTitle,Math.max(10,y-1)),weight:S.weight||"inherit"}}function te(B,f){const S=Number(B);return Number.isFinite(S)&&S>0?S:f}function n(B,f){return String(B??"").length*f*ue}function V(B,f){let S=0;for(const y of B||[]){const P=n(y,f);P>S&&(S=P)}return S}function E(B,f,S){const y=String(B??""),P=Math.floor(f/(S*ue));return P<=0?"":y.length<=P?y:P===1?"…":`${y.slice(0,P-1)}…`}function q(B,f){!B||!Number.isFinite(f)||(B.style?B.style.fontSize=`${f}px`:B.setAttribute("style",`font-size:${f}px`))}}),qe("packages/modules/charts/frame.js",function(t,ce){"use strict";Object.defineProperty(t,"LABEL_GAP",{enumerable:!0,get:function(){return V}}),Object.defineProperty(t,"LABEL_GUTTER_SHARE",{enumerable:!0,get:function(){return E}}),Object.defineProperty(t,"resolveMargin",{enumerable:!0,get:function(){return q}}),Object.defineProperty(t,"plotRect",{enumerable:!0,get:function(){return B}}),Object.defineProperty(t,"shouldRotate",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"Pool",{enumerable:!0,get:function(){return S}});const H=ce("packages/modules/charts/svg.js").SVG_NS,ue=ce("packages/modules/charts/typography.js"),ie=ue.textWidth,te=ue.widestLabel,n=8,V=6,E=.4;function q(y,P){const N=typeof y=="number"?y:P,p=y&&typeof y=="object"?y:{},u=h=>Number.isFinite(h)&&h>=0?Number(h):N;return{base:N,top:u(p.top),right:u(p.right),bottom:u(p.bottom),left:u(p.left)}}function B(y){const P=q(y.margin,typeof y.padding=="number"?y.padding:8),N=P.base,p=y.fontSize||12,u=y.yLabels||[],h=y.xLabels||[],c=y.ySide==="right"?"right":"left",k=c==="right"?"left":"right",m=y.titles||{},r=y.titleSize||p,v=ne=>ne?r+V:0,l=te(u,p),x=u.length?Math.min(y.width*E,P[c]+l+V):Math.max(n,P[c]),W=P[k]+(y.rightGutter||0),J=(c==="left"?x:W)+v(m.left),se=te(h.map(ne=>String(ne).slice(0,14)),p),re=h.length?(y.width-J-(c==="right"?x:W)-v(m.right))/h.length*.85:0,b=y.rotated==="auto"?f(h,re,p,y.every):!!y.rotated,C=(h.length?b?Math.min(y.height*E,V+se):p+V+P.bottom:Math.max(n,P.bottom))+v(m.bottom),I=(c==="right"?x:W)+v(m.right),M=P.top+(y.topGutter||0),X=Math.max(0,y.width-J-I),z=Math.max(0,y.height-M-C);return{left:J,top:M,width:X,height:z,right:J+X,bottom:M+z,gutter:{left:J,bottom:C,right:I,top:M}}}function f(y,P,N,p){if(!y.length||P<=0)return!1;const u=Number.isFinite(p)&&p>0?Number(p):1;return te(y,N)>P*u-4}class S{#e;#t=0;static#n="data-pool-key";constructor(P,N=0){this.#e=P,this.#t=N>0?N:0}next(P,N,p){if(p!=null)return this.#r(P,N,String(p));const u=this.#e.childNodes[this.#t],h=u&&u.tagName,c=/(^|\s)\S*__axis-title(\s|$)/,k=h&&c.test(String(u.getAttribute("class")||"")),m=!!N&&c.test(String(N));if(h&&(!k||m)&&String(h).toLowerCase()===P.toLowerCase())return N&&u.setAttribute("class",N),this.#t++,u;const r=this.#e.ownerDocument.createElementNS(H,P);return N&&r.setAttribute("class",N),u?this.#e.insertBefore(r,u):this.#e.appendChild(r),this.#t++,r}#r(P,N,p){const u=P.toLowerCase();for(let k=this.#t;k<this.#e.childNodes.length;k++){const m=this.#e.childNodes[k],r=m&&m.tagName;if(r&&String(r).toLowerCase()===u&&m.getAttribute(S.#n)===p)return k!==this.#t&&this.#e.insertBefore(m,this.#e.childNodes[this.#t]),N&&m.setAttribute("class",N),this.#t++,m}const h=this.#e.ownerDocument.createElementNS(H,P);h.setAttribute(S.#n,p),N&&h.setAttribute("class",N);const c=this.#e.childNodes[this.#t];return c?this.#e.insertBefore(h,c):this.#e.appendChild(h),this.#t++,h}finish(){for(;this.#e.childNodes.length>this.#t;)this.#e.removeChild(this.#e.lastChild);this.#t=0}}}),qe("packages/modules/charts/fills.js",function(t,ce){"use strict";Object.defineProperty(t,"PATTERNS",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(t,"GRADIENTS",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(t,"isFill",{enumerable:!0,get:function(){return q}}),Object.defineProperty(t,"isPaintRef",{enumerable:!0,get:function(){return B}}),Object.defineProperty(t,"paintFallback",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"normaliseFill",{enumerable:!0,get:function(){return y}}),Object.defineProperty(t,"swatchCss",{enumerable:!0,get:function(){return N}}),Object.defineProperty(t,"createFillRegistry",{enumerable:!0,get:function(){return p}}),Object.defineProperty(t,"rowPaint",{enumerable:!0,get:function(){return u}}),Object.defineProperty(t,"patternSeries",{enumerable:!0,get:function(){return h}}),Object.defineProperty(t,"paintSolid",{enumerable:!0,get:function(){return c}}),Object.defineProperty(t,"rowFillSource",{enumerable:!0,get:function(){return k}}),Object.defineProperty(t,"nodePaint",{enumerable:!0,get:function(){return m}});const H=ce("packages/core/src/internal/warn.js").warnOnce,ue=Object.freeze(["hatch","crosshatch","dots","grid"]),ie=Object.freeze(["linear","radial"]),te=8,n="#0072b2";let V=0;const E=new Map;function q(r){return!!r&&typeof r=="object"&&!Array.isArray(r)&&(typeof r.gradient=="string"||typeof r.pattern=="string")}function B(r){return typeof r=="string"&&r.startsWith("url(#")}function f(r){if(typeof r!="string")return r==null?"":String(r);if(!r.startsWith("url("))return r;const v=r.indexOf(")");return(v<0?"":r.slice(v+1).trim())||n}function S(r,v){H(`chart:fill:invalid:${r}`,`a chart fill object was ignored: ${v} The mark was drawn in a solid colour instead. A fill is a gradient object (gradient: "linear" or "radial", with stops of [offset, colour]) or a pattern object (pattern: "hatch", "crosshatch", "dots" or "grid", with a colour).`)}function y(r,v){if(!q(r))return null;const l=v||n;if(typeof r.gradient=="string"){if(!ie.includes(r.gradient))return S("gradient",`the gradient "${r.gradient}" is not one of ${ie.join(", ")}.`),null;const se=Array.isArray(r.stops)?r.stops:[],re=[];for(const C of se){const I=Array.isArray(C)?Number(C[0]):Number(C&&C.offset),M=Array.isArray(C)?C[1]:C&&C.colour;!Number.isFinite(I)||typeof M!="string"||!M||re.push({offset:Math.min(1,Math.max(0,I)),colour:M})}if(re.length<2)return S("stops","a gradient needs at least two [offset, colour] stops."),null;re.sort((C,I)=>C.offset-I.offset);const b=Number.isFinite(Number(r.angle))?Number(r.angle):180;return{kind:r.gradient,angle:b,stops:re,solid:re[0].colour}}if(!ue.includes(r.pattern))return S("pattern",`the pattern "${r.pattern}" is not one of ${ue.join(", ")}.`),null;const x=Number(r.size),W=Number(r.angle),J=typeof r.colour=="string"&&r.colour?r.colour:l;return{kind:"pattern",pattern:r.pattern,colour:J,background:typeof r.background=="string"&&r.background?r.background:null,size:Number.isFinite(x)&&x>=2?x:te,angle:Number.isFinite(W)?W:r.pattern==="grid"||r.pattern==="dots"?0:45,solid:J}}function P(r){if(r.kind==="pattern"){const l=r.colour,x=r.size,W=Math.max(1,x/5),J=r.background||"transparent",se=re=>`repeating-linear-gradient(${re+90}deg,${l} 0 ${W}px,transparent ${W}px ${x}px)`;return r.pattern==="hatch"?`${se(r.angle)},${J}`:r.pattern==="crosshatch"?`${se(r.angle)},${se(r.angle+90)},${J}`:r.pattern==="grid"?`${se(r.angle)},${se(r.angle+90)},${J}`:`radial-gradient(circle at 50% 50%,${l} ${x/6}px,transparent ${x/6+.5}px) 0 0/${x}px ${x}px,${J}`}const v=r.stops.map(l=>`${l.colour} ${Math.round(l.offset*100)}%`).join(",");return r.kind==="radial"?`radial-gradient(circle,${v})`:`linear-gradient(${r.angle}deg,${v})`}function N(r){if(!B(r))return typeof r=="string"?r:"";const v=String(r).indexOf(")"),l=String(r).slice(5,v),x=E.get(l);return x?P(x):f(r)}function p(r){const v=`lattice-fill-${++V}`;let l=new Map,x=0;const W=(se,re)=>{const b=r.ownerDocument.createElementNS("http://www.w3.org/2000/svg",se);for(const C of Object.keys(re))b.setAttribute(C,String(re[C]));return b},J=(se,re)=>{if(re.kind==="pattern"){const C=re.size,I=Math.max(1,C/5),M=W("pattern",{id:se,width:C,height:C,patternUnits:"userSpaceOnUse"});re.angle&&M.setAttribute("patternTransform",`rotate(${re.angle})`),re.background&&M.appendChild(W("rect",{width:C,height:C,fill:re.background}));const X={stroke:re.colour,"stroke-width":I};re.pattern==="dots"?M.appendChild(W("circle",{cx:C/2,cy:C/2,r:Math.max(1,C/6),fill:re.colour})):(M.appendChild(W("line",{x1:C/2,y1:0,x2:C/2,y2:C,...X})),re.pattern!=="hatch"&&M.appendChild(W("line",{x1:0,y1:C/2,x2:C,y2:C/2,...X}))),r.appendChild(M);return}let b;if(re.kind==="radial")b=W("radialGradient",{id:se,cx:.5,cy:.5,r:.5});else{const C=re.angle*Math.PI/180,I=Math.sin(C)/2,M=-Math.cos(C)/2;b=W("linearGradient",{id:se,x1:+(.5-I).toFixed(4),y1:+(.5-M).toFixed(4),x2:+(.5+I).toFixed(4),y2:+(.5+M).toFixed(4)})}for(const C of re.stops)b.appendChild(W("stop",{offset:C.offset,"stop-color":C.colour}));r.appendChild(b)};return{prefix:v,paint(se,re){const b=y(se,re);if(!b)return re||n;if(!r||!r.ownerDocument)return b.solid;const C=JSON.stringify(b);let I=l.get(C);if(!I){const M=`${v}-${x++}`;J(M,b),E.set(M,b),I=`url(#${M}) ${b.solid}`,l.set(C,I)}return I},reset(){for(const se of l.values())E.delete(se.slice(5,se.indexOf(")")));if(l=new Map,x=0,r)for(;r.firstChild;)r.removeChild(r.firstChild)},ids(){return[...l.values()].map(se=>se.slice(5,se.indexOf(")")))}}}function u(r,v,l){if(r==null||r==="")return null;const x=f(l);if(q(r))return v?v.paint(r,x):(y(r,x)||{}).solid||null;if(typeof r=="string"){if(ue.includes(r)){const W={pattern:r,colour:x};return v?v.paint(W,x):x}return r}return null}function h(r){const v=[{pattern:"hatch",angle:45},{pattern:"dots"},{pattern:"crosshatch",angle:45},{pattern:"hatch",angle:135},{pattern:"grid"},{pattern:"dots",size:5},{pattern:"hatch",angle:0},{pattern:"crosshatch",angle:0,size:6}];return r.map((l,x)=>({...v[x%v.length],colour:l,background:"var(--lattice-chart-plot-bg,var(--lattice-chart-d-plot-bg))"}))}function c(r){return B(r)?String(r).replace(/^url\([^)]*\)\s*/,""):r}function k(r,v){const l=r.fill;if(q(l))return(W,J)=>u(l,v.fills,c(J));if(typeof l=="function")return(W,J)=>{let se=null;try{se=l({label:W.label,x:W.x,y:W.y,rowKey:W.rowKey})}catch{se=null}return u(se,v.fills,c(J))};const x=typeof l=="string"?l:l&&typeof l=="object"&&typeof l.col=="string"?l.col:null;return x?(W,J)=>W.rowKey===void 0||W.rowKey===null?null:u(r.grid.rows.value(W.rowKey,x),v.fills,c(J)):null}function m(r,v,l){return r&&r({label:v.label,x:v.value,y:v.total,rowKey:v.rowKey},l)||l}}),qe("packages/modules/charts/scheme.js",function(t,ce){"use strict";Object.defineProperty(t,"PALETTE",{enumerable:!0,get:function(){return V}}),Object.defineProperty(t,"SCHEMES",{enumerable:!0,get:function(){return E}}),Object.defineProperty(t,"registerScheme",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"setDefaultScheme",{enumerable:!0,get:function(){return S}}),Object.defineProperty(t,"schemeNames",{enumerable:!0,get:function(){return y}}),Object.defineProperty(t,"resolveScheme",{enumerable:!0,get:function(){return u}}),Object.defineProperty(t,"RAMP_SCALES",{enumerable:!0,get:function(){return c}}),Object.defineProperty(t,"toRgb",{enumerable:!0,get:function(){return r}}),Object.defineProperty(t,"rampStops",{enumerable:!0,get:function(){return v}});const H=ce("packages/core/src/internal/warn.js").warnOnce,ue=ce("packages/modules/charts/fills.js"),ie=ue.isFill,te=ue.patternSeries,n=ue.rowPaint,V=Object.freeze(["#0072b2","#e69f00","#009e73","#cc79a7","#56b4e9","#d55e00","#7a5195","#6b7d8c"]),E=Object.freeze({default:{series:V,sequential:["#ecf3f9","#005280"],diverging:["#b04a00","#f7f7f7","#005280"],positive:"#009e73",negative:"#d55e00"},bright:{series:["#1f77d0","#ff7f0e","#2ca02c","#d62728","#9467bd","#17becf","#e377c2","#7f7f7f"],sequential:["#eef4fb","#1f77d0"],diverging:["#d62728","#f7f7f7","#1f77d0"],positive:"#2ca02c",negative:"#d62728"},earth:{series:["#5b7c6f","#c08b52","#7a6a53","#a4553f","#4e6a83","#8f8259","#6d5566","#8c9196"],sequential:["#f2efe9","#4e6a83"],diverging:["#a4553f","#f2efe9","#4e6a83"],positive:"#5b7c6f",negative:"#a4553f"},mono:{series:["#0b2a3d","#17475f","#2c6480","#4a82a0","#6da0bd","#94bcd6","#bcd7e9","#dfecf5"],sequential:["#eef3f7","#0b2a3d"],diverging:["#7a5c00","#f5f5f5","#0b2a3d"],positive:"#17475f",negative:"#7a5c00"},patterns:{series:te(V),sequential:["#ecf3f9","#005280"],diverging:["#b04a00","#f7f7f7","#005280"],positive:"#009e73",negative:"#d55e00"}}),q=new Map;let B="default";function f(l,x){!l||!x||q.set(String(l),x)}function S(l){if(typeof l=="string"){B=l;return}l&&typeof l=="object"&&(q.set("__default__",l),B="__default__")}function y(){return[...Object.keys(E),...q.keys()].filter(l=>!l.startsWith("__"))}function P(l){return q.has(l)?q.get(l):E[l]||null}const N=["series","sequential","diverging","positive","negative"];function p(l){return!l||typeof l!="object"||Array.isArray(l)?!1:!N.some(x=>x in l)}function u(l,x){const W=x&&x.fills||null,J=P(B)||E.default,se=l&&l.scheme,re=p(se)?se:null,b=Array.isArray(se)&&se.length?se:null,C=typeof se=="string"?P(se):re||Array.isArray(se)?null:se||null,I=(l&&Array.isArray(l.palette)&&l.palette.length?l.palette:null)||b;re&&I&&H("chart:scheme:array-and-map",'chart "scheme" was given as a name map together with a "palette" array; the two do not combine. Colours came from the map and the array was ignored. Pass one or the other.');const M=re?null:I,X={...E.default,...J,...C||{}};M&&(X.series=M);const z=l&&l.ramp&&typeof l.ramp=="object"&&!Array.isArray(l.ramp)?l.ramp:null,ne=z?z.colours:l&&l.ramp,R=Array.isArray(ne)&&ne.length>=2?ne:null;R&&(X.sequential=R);const G=z?k(z.scale):null,T=!!(C||M||re),e=X.series&&X.series.length?X.series:V,s=new Map;let a=0;return{...X,series:($,Q)=>{if(re&&Q!==void 0&&Q!==null){const ve=String(Q);return Object.prototype.hasOwnProperty.call(re,ve)?h(re[ve],W,$):(s.has(ve)||s.set(ve,a++),h(m(e,s.get(ve),!0),W,s.get(ve)))}return h(m(e,$,T),W,$)},explicit:T,nameMap:!!re,rampScale:G,fills:W}}function h(l,x,W){if(!ie(l))return l;const J=V[(W%V.length+V.length)%V.length];return n(l,x,J)||J}const c=Object.freeze(["linear","log","quantile"]);function k(l){return l==null?null:c.includes(l)?l:(H(`chart:ramp:scale:${String(l)}`,`chart "ramp.scale" was "${String(l)}", which is not a ramp scale; the chart chose one from its values instead. Use "linear", "log" or "quantile".`),null)}function m(l,x,W){const J=(x%l.length+l.length)%l.length;return W||typeof l[J]!="string"?l[J]:`var(--lattice-chart-${J+1}, ${l[J]})`}function r(l){if(typeof l!="string")return null;const x=l.trim(),W=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(x);if(W){const re=W[1];return re.length===3?[0,1,2].map(b=>parseInt(re[b]+re[b],16)):[0,2,4].map(b=>parseInt(re.slice(b,b+2),16))}const J=/^rgba?\(([^)]+)\)$/i.exec(x);if(!J)return null;const se=J[1].split(/[\s,/]+/).filter(Boolean).slice(0,3).map(Number);return se.length===3&&se.every(re=>Number.isFinite(re))?se:null}function v(l,x){const W=x?l.diverging:l.sequential,J=x?E.default.diverging:E.default.sequential,se=(Array.isArray(W)?W:J).map((re,b)=>r(re)||r(J[b])||[0,0,0]);return se.length>=2?se:J.map(re=>r(re))}}),qe("packages/modules/charts/roles.js",function(t,ce){"use strict";Object.defineProperty(t,"expand",{enumerable:!0,get:function(){return E}}),Object.defineProperty(t,"readRole",{enumerable:!0,get:function(){return q}}),Object.defineProperty(t,"rolesCss",{enumerable:!0,get:function(){return S}});const H=ce("packages/modules/charts/scheme.js").PALETTE,ue="lat-chartview",ie=Object.freeze(["#4ea6dd","#f0b429","#34c79a","#e39ec4","#7cc7f0","#f07c3f","#a48ad4","#93a3b1"]),te=":where(:root,.lattice,.lattice-tokens,[data-theme])",n=`
7
7
  --lattice-chart-d-sequential-start:var(--lattice-variant-info-fill,#ecf3f9);
8
8
  --lattice-chart-d-sequential-end:var(--lattice-accent,#005280);
9
9
  --lattice-chart-d-axis:var(--lattice-border-strong,#8c96a0);
@@ -34,10 +34,10 @@
34
34
  --lattice-chart-d-font-size-xs:calc(var(--lattice-font-size-sm,11px) * .82);
35
35
  --lattice-chart-d-empty:var(--lattice-surface,#eceff1);
36
36
  --lattice-chart-d-map-stroke:var(--lattice-border-color,#dfe3e6);
37
- `,V=new Set([...n.matchAll(/--lattice-chart-d-([a-z-]+):/g)].map(g=>g[1]));function T(g){return String(g).replace(/var\(--lattice-chart-([a-z-]+)\)/g,(P,N)=>V.has(N)?`var(--lattice-chart-${N},var(--lattice-chart-d-${N}))`:P)}function q(g,P){return String(g.getPropertyValue(`--lattice-chart-${P}`)).trim()||String(g.getPropertyValue(`--lattice-chart-d-${P}`)).trim()}function R(g){return g.map((P,N)=>`--lattice-chart-${N+1}:${P};`).join("")}function f(){return`${R(se)}--lattice-chart-basemap-fill:#3a4a55;--lattice-chart-basemap-stroke:#8fb0c2;`}function S(){return`:where(.${fe},.${fe}__tooltip){${n.replace(/\n\s*/g,"")}}
37
+ `,V=new Set([...n.matchAll(/--lattice-chart-d-([a-z-]+):/g)].map(y=>y[1]));function E(y){return String(y).replace(/var\(--lattice-chart-([a-z-]+)\)/g,(P,N)=>V.has(N)?`var(--lattice-chart-${N},var(--lattice-chart-d-${N}))`:P)}function q(y,P){return String(y.getPropertyValue(`--lattice-chart-${P}`)).trim()||String(y.getPropertyValue(`--lattice-chart-d-${P}`)).trim()}function B(y){return y.map((P,N)=>`--lattice-chart-${N+1}:${P};`).join("")}function f(){return`${B(ie)}--lattice-chart-basemap-fill:#3a4a55;--lattice-chart-basemap-stroke:#8fb0c2;`}function S(){return`:where(.${ue},.${ue}__tooltip){${n.replace(/\n\s*/g,"")}}
38
38
  @layer lattice.charts{
39
- ${ne}{
40
- ${R(Y)}
39
+ ${te}{
40
+ ${B(H)}
41
41
  /* The land under a shapes pack (BACKLOG-0001508): a fill the plot background
42
42
  cannot swallow (>=1.3:1 against it) and a border the fill cannot swallow
43
43
  either (>=3:1 against the fill). */
@@ -48,9 +48,9 @@ ${ne}{
48
48
  :where([data-theme="dark"]){${f()}}
49
49
  @media (prefers-color-scheme: dark){:where([data-theme="auto"]){${f()}}}
50
50
  }
51
- @scope ([data-theme="dark"]){:scope.${fe},.${fe}{color-scheme:dark}}
52
- @scope ([data-theme="light"],[data-theme="auto"]){:scope.${fe},.${fe}{color-scheme:light}}
53
- @media (prefers-color-scheme: dark){@scope ([data-theme="auto"]){:scope.${fe},.${fe}{color-scheme:dark}}}`}}),Ze("packages/modules/charts/styles.js",function(t,ue){"use strict";Object.defineProperty(t,"NS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"seriesColour",{enumerable:!0,get:function(){return T}}),Object.defineProperty(t,"css",{enumerable:!0,get:function(){return q}}),Object.defineProperty(t,"injectStyles",{enumerable:!0,get:function(){return R}});const Y=ue("packages/modules/charts/scheme.js").PALETTE,fe=ue("packages/modules/charts/roles.js"),se=fe.rolesCss,ne=fe.expand,n="lat-chartview",V="data-lattice-chartview";function T(f){const S=(f%Y.length+Y.length)%Y.length;return`var(--lattice-chart-${S+1}, ${Y[S]})`}function q(){return ne(`
51
+ @scope ([data-theme="dark"]){:scope.${ue},.${ue}{color-scheme:dark}}
52
+ @scope ([data-theme="light"],[data-theme="auto"]){:scope.${ue},.${ue}{color-scheme:light}}
53
+ @media (prefers-color-scheme: dark){@scope ([data-theme="auto"]){:scope.${ue},.${ue}{color-scheme:dark}}}`}}),qe("packages/modules/charts/styles.js",function(t,ce){"use strict";Object.defineProperty(t,"NS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"seriesColour",{enumerable:!0,get:function(){return E}}),Object.defineProperty(t,"css",{enumerable:!0,get:function(){return q}}),Object.defineProperty(t,"injectStyles",{enumerable:!0,get:function(){return B}});const H=ce("packages/modules/charts/scheme.js").PALETTE,ue=ce("packages/modules/charts/roles.js"),ie=ue.rolesCss,te=ue.expand,n="lat-chartview",V="data-lattice-chartview";function E(f){const S=(f%H.length+H.length)%H.length;return`var(--lattice-chart-${S+1}, ${H[S]})`}function q(){return te(`
54
54
  .${n}{position:relative;display:flex;flex-direction:column;min-width:0;min-height:0;
55
55
  width:100%;height:100%;box-sizing:border-box;
56
56
  font-family:var(--lattice-chart-font);
@@ -448,7 +448,7 @@ ${ne}{
448
448
  .${n}__table{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;
449
449
  clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0}
450
450
 
451
- ${se()}
451
+ ${ie()}
452
452
 
453
453
  @media (forced-colors: active){
454
454
  /* Fills are flattened to the system palette, so colour stops carrying
@@ -461,7 +461,7 @@ ${se()}
461
461
  .${n}__swatch{border:1px solid CanvasText}
462
462
  .${n}__mark[data-dim]{opacity:1;fill:GrayText}
463
463
  }
464
- `)}function R(f){const S=f.documentElement;if(!S||S.getAttribute(V))return;S.setAttribute(V,"1");const g=f.createElement("style");g.textContent=q(),(f.head||f.body||S).appendChild(g)}}),Ze("packages/core/src/format/mask.js",function(t,ue){"use strict";Object.defineProperty(t,"splitSections",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(t,"parseSection",{enumerable:!0,get:function(){return se}}),Object.defineProperty(t,"compileMask",{enumerable:!0,get:function(){return n}});const Le=new Set(["0","#","?",",","."]),Y="\0";function fe(T){const q=[];let R="",f=!1;for(let S=0;S<T.length;S++){const g=T[S];if(g==="\\"){R+=g+(T[S+1]??""),S+=1;continue}if(g==='"'){f=!f,R+=g;continue}if(g===";"&&!f){q.push(R),R="";continue}R+=g}return q.push(R),q}function se(T){let q="",R="",f="",S=1,g=!1,P=!1;const N=l=>{P?R+=l:q+=l};for(let l=0;l<T.length;l++){const x=T[l];if(x==="\\"){N(T[l+1]??""),l+=1;continue}if(x==='"'){const W=T.indexOf('"',l+1);N(W===-1?T.slice(l+1):T.slice(l+1,W)),l=W===-1?T.length:W;continue}if(x==="%"){S*=100,N("%");continue}if(x==="@"){g=!0,N("\0");continue}if(Le.has(x)){f+=x,P=!0;continue}N(x)}let p=-1;for(let l=f.length-1;l>=0;l--){const x=f[l];if(x==="0"||x==="#"||x==="?"){p=l;break}}let u=!1,m="";for(let l=0;l<f.length;l++){const x=f[l];if(x===","){l>p?S/=1e3:u=!0;continue}m+=x}const c=m.indexOf("."),w=c===-1?m:m.slice(0,c),d=c===-1?"":m.slice(c+1);let r=0;for(const l of w)l==="0"&&(r+=1);let v=0;for(const l of d)l==="0"&&(v+=1);return{prefix:q,suffix:R,minInt:r,minDec:v,maxDec:d.length,grouping:u,scale:S,hasNumber:p!==-1,isText:g}}function ne(T,q){const R=new Intl.NumberFormat(q,{minimumIntegerDigits:Math.max(T.minInt,1),minimumFractionDigits:T.minDec,maximumFractionDigits:Math.max(T.maxDec,T.minDec),useGrouping:T.grouping}),{prefix:f,suffix:S,scale:g,hasNumber:P}=T;return N=>{if(!P)return f+S;const p=g===1?N:N*g;return f+R.format(p)+S}}function n(T,q){const f=fe(String(T)).map(se),S=f.map(m=>ne(m,q)),g=0,P=f.length>1?1:-1,N=f.length>2?2:-1,p=f.length>3?3:-1,u=m=>{if(m==null||m==="")return"";if(typeof m!="number"||Number.isNaN(m)){const c=Number(m);if(Number.isNaN(c))return p===-1?String(m):(f[p].prefix+f[p].suffix).split("\0").join(String(m));m=c}return m===0&&N!==-1?S[N](0):m<0&&P!==-1?S[P](-m):S[g](m)};return u.spec={mask:T},{format:u,ooxml:V(String(T))}}function V(T){return T.trim()}}),Ze("packages/core/src/format/pattern.js",function(t,ue){"use strict";Object.defineProperty(t,"parseNumberPattern",{enumerable:!0,get:function(){return ne}});const Y=ue("packages/core/src/format/mask.js").splitSections;function fe(n){let V="",T="",q="",R="",f=!1,S=!1,g=!1,P=!1;const N=u=>{g?T+=u:V+=u};for(let u=0;u<n.length;u++){const m=n[u];if(m==="\\"){N(n[u+1]??""),u+=1;continue}if(m==='"'){const c=n.indexOf('"',u+1);N(c===-1?n.slice(u+1):n.slice(u+1,c)),u=c===-1?n.length:c;continue}if(m==="%"){S=!0;continue}if(m==="0"||m==="#"){g=!0,P?R+=m:q+=m;continue}if(m===","){P||(f=!0);continue}if(m==="."&&!P){P=!0;continue}N(m)}if(!g)return{hasDigit:!1,prefix:V,suffix:T,minDec:0,maxDec:0,grouping:!1,percent:S};let p=0;for(const u of R)u==="0"&&(p+=1);return{hasDigit:!0,prefix:V,suffix:T,minDec:p,maxDec:R.length,grouping:f,percent:S}}function se(n,V){const T=V.trim(),q=n.trim();return T.startsWith("(")&&T.endsWith(")")&&T.slice(1,-1).trim()===q?"parentheses":T.endsWith("-")?"suffix":"minus"}function ne(n){if(typeof n!="string")return null;const V=Y(n);if(V.length===0)return null;const T=fe(V[0]);if(!T.hasDigit)return null;const q={style:T.percent?"percent":"decimal",prefix:T.prefix,suffix:T.suffix,minDecimals:T.minDec,maxDecimals:Math.max(T.maxDec,T.minDec),thousandsSeparator:T.grouping?void 0:!1};if(V.length>1&&(q.negative=se(V[0],V[1])),V.length>2){const R=fe(V[2]);R.hasDigit||(q.zeroDisplay=R.prefix+R.suffix)}return q}}),Ze("packages/core/src/format/number.js",function(t,ue){"use strict";Object.defineProperty(t,"compileNumber",{enumerable:!0,get:function(){return V}});const Y=ue("packages/core/src/internal/predicates.js").isNil,se=ue("packages/core/src/internal/warn.js").warnOnce,n=ue("packages/core/src/format/pattern.js").parseNumberPattern;function V(T,q){const R=typeof T=="string"?{pattern:T}:T||{};let f=R;if(typeof R.pattern=="string"){const D=n(R.pattern);if(D){const{pattern:M,...J}=R;f={...D,...J}}else se(`format:pattern:${R.pattern}`,`invalid number format pattern "${R.pattern}"; the value will use the default number format`)}const S=f.locale||q||void 0,g=f.style||"decimal",P=typeof f.scale=="number"?f.scale:1,N=f.nullDisplay??"",p=f.zeroDisplay,u=f.prefix||"",m=f.suffix||"",c=f.negative||"minus",w=f.signed===!0,d={style:g,notation:f.notation||"standard"};g==="currency"&&(d.currency=f.currency||"USD",f.currencyDisplay&&(d.currencyDisplay=f.currencyDisplay)),typeof f.decimals=="number"?(d.minimumFractionDigits=f.decimals,d.maximumFractionDigits=f.decimals):(typeof f.minDecimals=="number"&&(d.minimumFractionDigits=f.minDecimals),typeof f.maxDecimals=="number"&&(d.maximumFractionDigits=f.maxDecimals),d.minimumFractionDigits>(d.maximumFractionDigits??20)&&(d.maximumFractionDigits=d.minimumFractionDigits)),f.thousandsSeparator===!1&&(d.useGrouping=!1),d.notation==="compact"&&(d.compactDisplay=f.compactDisplay||"short");const r=new Intl.NumberFormat(S,d),v=typeof f.thousandsSeparator=="string"?f.thousandsSeparator:null,l=typeof f.decimalSeparator=="string"?f.decimalSeparator:null;let x=",",W=".";if(v||l)for(const D of r.formatToParts(12345.6))D.type==="group"?x=D.value:D.type==="decimal"&&(W=D.value);const Z=D=>{let M=D;return v&&(M=M.split(x).join("")),l&&(M=M.split(W).join("")),v&&(M=M.split("").join(v)),l&&(M=M.split("").join(l)),M},le=!!(v||l),oe=u!==""&&g==="currency",y=D=>{let M;if(oe){const J=r.formatToParts(D);let F=!1;M="";for(const re of J)M+=re.value,!F&&re.type==="currency"&&(M+=u,F=!0);F||(M=u+M)}else M=u+r.format(D);return le&&(M=Z(M)),M+m},C=D=>{if(Y(D)||D==="")return N;const M=typeof D=="number"?D:Number(D);if(Number.isNaN(M))return N;const J=P===1?M:M*P;return J===0&&p!==void 0?p:J<0?c==="parentheses"?`(${y(-J)})`:c==="suffix"?`${y(-J)}-`:y(J):w&&J>0?`+${y(J)}`:y(J)};return C.negativeClass=f.negativeClass||null,C.spec=f,C}}),Ze("packages/core/src/format/date.js",function(t,ue){"use strict";Object.defineProperty(t,"scanPattern",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"toDate",{enumerable:!0,get:function(){return T}}),Object.defineProperty(t,"compilePattern",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"compileDate",{enumerable:!0,get:function(){return g}}),Object.defineProperty(t,"toIsoDate",{enumerable:!0,get:function(){return P}}),Object.defineProperty(t,"toIsoDateTime",{enumerable:!0,get:function(){return N}}),Object.defineProperty(t,"compareIso",{enumerable:!0,get:function(){return m}});const Y=ue("packages/core/src/internal/predicates.js").isNil,se=ue("packages/core/src/internal/warn.js").warnOnce,ne=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function n(c){const w=[];let d=0,r="";const v=()=>{r&&(w.push({token:null,text:r}),r="")};for(;d<c.length;){const l=c[d];if(l==="'"){if(c[d+1]==="'"){r+="'",d+=2;continue}const W=c.indexOf("'",d+1);if(W===-1){r+=c.slice(d+1),d=c.length;continue}r+=c.slice(d+1,W),d=W+1;continue}const x=ne.find(W=>c.startsWith(W,d));if(x){v(),w.push({token:x,text:x}),d+=x.length;continue}/[A-Za-z]/.test(l)&&se(`date.pattern.token:${l}`,`the date pattern "${c}" contains '${l}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${ne.join(" ")}.`),r+=l,d+=1}return v(),w}const V=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function T(c){if(Y(c)||c==="")return null;if(c instanceof Date)return Number.isNaN(c.getTime())?null:c;if(typeof c=="number")return Number.isNaN(c)?null:new Date(c);if(typeof c=="string"){const w=V.exec(c.trim());if(w){const[,r,v,l,x="0",W="0",Z="0"]=w;return new Date(+r,+v-1,+l,+x,+W,+Z)}const d=new Date(c);return Number.isNaN(d.getTime())?null:d}return null}function q(c,w){return String(c).padStart(w,"0")}function R(c){if(!c)return r=>({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate(),hour:r.getHours(),minute:r.getMinutes(),second:r.getSeconds(),ms:r.getMilliseconds(),weekday:r.getDay()});const w=new Intl.DateTimeFormat("en-US",{timeZone:c,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),d={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return r=>{const v={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:r.getMilliseconds(),weekday:0};for(const l of w.formatToParts(r))switch(l.type){case"year":v.year=Number(l.value);break;case"month":v.month=Number(l.value);break;case"day":v.day=Number(l.value);break;case"hour":v.hour=Number(l.value)%24;break;case"minute":v.minute=Number(l.value);break;case"second":v.second=Number(l.value);break;case"weekday":v.weekday=d[l.value]??0;break;default:break}return v}}function f(c,w,d){const r=n(c),v=R(d),l=new Set(r.filter(oe=>oe.token).map(oe=>oe.token)),x=l.has("MMM")?new Intl.DateTimeFormat(w,{month:"short",timeZone:d}):null,W=l.has("MMMM")?new Intl.DateTimeFormat(w,{month:"long",timeZone:d}):null,Z=l.has("EEE")?new Intl.DateTimeFormat(w,{weekday:"short",timeZone:d}):null,le=l.has("EEEE")?new Intl.DateTimeFormat(w,{weekday:"long",timeZone:d}):null;return oe=>{const y=v(oe);let C="";for(const D of r){if(!D.token){C+=D.text;continue}switch(D.token){case"yyyy":C+=q(y.year,4);break;case"yy":C+=q(y.year%100,2);break;case"MMMM":C+=W.format(oe);break;case"MMM":C+=x.format(oe);break;case"MM":C+=q(y.month,2);break;case"M":C+=String(y.month);break;case"dd":C+=q(y.day,2);break;case"d":C+=String(y.day);break;case"EEEE":C+=le.format(oe);break;case"EEE":C+=Z.format(oe);break;case"HH":C+=q(y.hour,2);break;case"H":C+=String(y.hour);break;case"hh":C+=q(y.hour%12===0?12:y.hour%12,2);break;case"h":C+=String(y.hour%12===0?12:y.hour%12);break;case"mm":C+=q(y.minute,2);break;case"m":C+=String(y.minute);break;case"ss":C+=q(y.second,2);break;case"s":C+=String(y.second);break;case"SSS":C+=q(y.ms,3);break;case"a":C+=y.hour<12?"AM":"PM";break;default:C+=D.text;break}}return C}}const S=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function g(c,w){const d=c||{},r=d.locale||w||void 0,v=d.nullDisplay??"",l=d.timeZone;let x;if(d.pattern)x=f(d.pattern,r,l);else if(d.dateStyle||d.timeStyle){const y={timeZone:l};d.dateStyle&&(y.dateStyle=d.dateStyle),d.timeStyle&&(y.timeStyle=d.timeStyle);const C=new Intl.DateTimeFormat(r,y);x=D=>C.format(D)}else{const y=new Intl.DateTimeFormat(r,{dateStyle:"medium",timeZone:l});x=C=>y.format(C)}const W=d.relative?new Intl.RelativeTimeFormat(r,{numeric:"auto"}):null,le=(typeof d.relative=="object"&&d.relative?d.relative.threshold??7:7)*24*36e5,oe=(y,C)=>{const D=T(y);if(!D)return v;if(W){const M=C&&typeof C.now=="number"?C.now:Date.now(),J=D.getTime()-M;if(Math.abs(J)<le){for(const[F,re]of S)if(Math.abs(J)>=re||F==="second")return W.format(Math.round(J/re),F)}}return x(D)};return oe.spec=d,oe}function P(c){if(Y(c)||c==="")return null;if(typeof c=="string"){const r=/^(\d{4}-\d{2}-\d{2})/.exec(c.trim());if(r)return r[1];const v=T(c);return v?P(v):null}const w=T(c);if(!w)return null;const d=r=>String(r).padStart(2,"0");return`${w.getFullYear()}-${d(w.getMonth()+1)}-${d(w.getDate())}`}function N(c,w){if(Y(c)||c==="")return null;if(typeof c=="string"){const r=c.trim();if(p.test(r)){const x=T(r);return x?u(x,w):null}const v=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(r);if(v){const[,x,W,Z,le]=v;return`${x}T${W}:${Z}${le&&le!=="00"?`:${le}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(r))return`${r}T00:00`;const l=T(r);return l?N(l):null}const d=T(c);return d?u(d,w):null}const p=/(?:Z|[+-]\d{2}:?\d{2})$/i;function u(c,w){const d=x=>String(x).padStart(2,"0");if(w)try{const x=new Intl.DateTimeFormat("en-CA",{timeZone:w,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(c).reduce((le,oe)=>(oe.type!=="literal"&&(le[oe.type]=oe.value),le),{}),W=x.hour==="24"?"00":x.hour,Z=Number(x.second);return`${x.year}-${x.month}-${x.day}T${W}:${x.minute}`+(Z?`:${x.second}`:"")}catch{}const r=`${c.getFullYear()}-${d(c.getMonth()+1)}-${d(c.getDate())}`,v=c.getSeconds(),l=`${d(c.getHours())}:${d(c.getMinutes())}${v?`:${d(v)}`:""}`;return`${r}T${l}`}function m(c,w){const d=Y(c)||c===""?null:String(c),r=Y(w)||w===""?null:String(w);return d===null?r===null?0:1:r===null||d<r?-1:d>r?1:0}}),Ze("packages/core/src/format/boolean.js",function(t,ue){"use strict";Object.defineProperty(t,"toTriState",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(t,"compileBoolean",{enumerable:!0,get:function(){return n}});const Y=ue("packages/core/src/internal/predicates.js").isNil,fe={true:"☑",false:"☐",null:""},se={true:"◉",false:"◯",null:""};function ne(V){if(Y(V)||V==="")return null;if(typeof V=="boolean")return V;if(typeof V=="number")return V!==0;const T=String(V).trim().toLowerCase();return T==="true"||T==="yes"||T==="y"||T==="1"?!0:T==="false"||T==="no"||T==="n"||T==="0"?!1:null}function n(V,T){const q=V||{},R=q.display||"text",f=q.trueLabel??"Yes",S=q.falseLabel??"No",g=q.nullLabel??"";let P=f,N=S;const p=g;R==="checkbox"?(P=fe.true,N=fe.false):R==="switch"?(P=se.true,N=se.false):R==="icon"&&(P=q.trueIcon??f,N=q.falseIcon??S);const u=m=>{const c=ne(m);return c===null?p:c?P:N};return u.display=R,u.labels={true:f,false:S,null:g},u.locale=T,u.spec=q,u}}),Ze("packages/core/src/internal/text.js",function(t,ue){"use strict";Object.defineProperty(t,"humanise",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(t,"escapeHtml",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(t,"titleCase",{enumerable:!0,get:function(){return se}});function Le(ne){return ne?(ne.includes(".")?ne.slice(ne.lastIndexOf(".")+1):ne).replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/\s+/g," ").trim().replace(/^./,V=>V.toUpperCase()):""}const Y={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function fe(ne){const n=ne==null?"":String(ne);return/[&<>"']/.test(n)?n.replace(/[&<>"']/g,V=>Y[V]):n}function se(ne){return String(ne).replace(/\w\S*/g,n=>n[0].toUpperCase()+n.slice(1).toLowerCase())}}),Ze("packages/core/src/format/text.js",function(t,ue){"use strict";Object.defineProperty(t,"compileText",{enumerable:!0,get:function(){return ne}});const Y=ue("packages/core/src/internal/predicates.js").isNil,se=ue("packages/core/src/internal/text.js").titleCase;function ne(n,V){const T=n||{},q=T.locale||V||void 0,R=T.nullDisplay??"",f=T.emptyDisplay??"",S=T.transform||"none",g=typeof T.truncate=="number"?{chars:T.truncate}:T.truncate||null,P=g?g.chars:0,N=g?g.ellipsis??"…":"",p=m=>{switch(S){case"upper":return q?m.toLocaleUpperCase(q):m.toUpperCase();case"lower":return q?m.toLocaleLowerCase(q):m.toLowerCase();case"title":return se(m);default:return m}},u=m=>{if(Y(m))return R;let c=typeof m=="string"?m:String(m);return c===""?f:(S!=="none"&&(c=p(c)),P>0&&c.length>P&&(c=c.slice(0,P)+N),c)};return u.spec=T,u}}),Ze("packages/core/src/format/shorthand.js",function(t,ue){"use strict";Object.defineProperty(t,"looksLikeMask",{enumerable:!0,get:function(){return se}}),Object.defineProperty(t,"looksLikeDatePattern",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(t,"parseShorthand",{enumerable:!0,get:function(){return V}});const Le=["currency","number","percent","date","boolean","text","relative"],Y=/[#0?@;"\\]/,fe=/(yyyy|yy|MMMM|MMM|MM|EEEE|EEE|dd|HH|hh|mm|ss|SSS)/;function se(T){return typeof T!="string"||T===""||n(T)?!1:Y.test(T)}function ne(T){return typeof T!="string"||T===""||n(T)?!1:fe.test(T)}function n(T){const q=T.indexOf(":"),R=q===-1?T:T.slice(0,q);return Le.includes(R)?R:null}function V(T){const q=n(T);if(!q)return null;const R=T.indexOf(":"),f=R===-1?"":T.slice(R+1),S=f===""?[]:f.split(":");switch(q){case"currency":{const g={type:"number",style:"currency",currency:S[0]||"USD"};return S[1]!==void 0&&S[1]!==""&&(g.decimals=Number(S[1])),g}case"number":{const g={type:"number",style:"decimal"};return S[0]!==void 0&&S[0]!==""&&(g.decimals=Number(S[0])),g}case"percent":{const g={type:"number",style:"percent"};return S[0]!==void 0&&S[0]!==""&&(g.decimals=Number(S[0])),g}case"date":return{type:"date",pattern:f||void 0};case"relative":return{type:"date",relative:!0};case"boolean":{const g=f.split("/"),P={type:"boolean",display:"text"};return g[0]!==void 0&&g[0]!==""&&(P.trueLabel=g[0]),g[1]!==void 0&&g[1]!==""&&(P.falseLabel=g[1]),g[2]!==void 0&&(P.nullLabel=g[2]),P}case"text":{const g={type:"text"};return S[0]&&(g.transform=S[0]),S[1]!==void 0&&S[1]!==""&&(g.truncate=Number(S[1])),g}default:return null}}}),Ze("packages/core/src/format/index.js",function(t,ue){"use strict";Object.defineProperty(t,"compileFormat",{enumerable:!0,get:function(){return C}}),Object.defineProperty(t,"specToOoxml",{enumerable:!0,get:function(){return M}});const Le=ue("packages/core/src/internal/predicates.js"),Y=Le.isFunction,fe=Le.isObject,ne=ue("packages/core/src/internal/warn.js").warnOnce,n=ue("packages/core/src/format/number.js"),V=n.compileNumber,T=ue("packages/core/src/format/date.js"),q=T.compileDate,R=T.scanPattern,f=ue("packages/core/src/format/boolean.js"),S=f.compileBoolean,g=ue("packages/core/src/format/text.js"),P=g.compileText,N=ue("packages/core/src/format/mask.js"),p=N.compileMask,u=ue("packages/core/src/format/shorthand.js"),m=u.parseShorthand,c=u.looksLikeMask,w=u.looksLikeDatePattern,r=ue("packages/core/src/format/pattern.js").parseNumberPattern;Object.defineProperty(t,"compileNumber",{enumerable:!0,get:function(){return n.compileNumber}}),Object.defineProperty(t,"compileDate",{enumerable:!0,get:function(){return T.compileDate}}),Object.defineProperty(t,"compilePattern",{enumerable:!0,get:function(){return T.compilePattern}}),Object.defineProperty(t,"scanPattern",{enumerable:!0,get:function(){return T.scanPattern}}),Object.defineProperty(t,"toDate",{enumerable:!0,get:function(){return T.toDate}}),Object.defineProperty(t,"compileBoolean",{enumerable:!0,get:function(){return f.compileBoolean}}),Object.defineProperty(t,"toTriState",{enumerable:!0,get:function(){return f.toTriState}}),Object.defineProperty(t,"compileText",{enumerable:!0,get:function(){return g.compileText}}),Object.defineProperty(t,"compileMask",{enumerable:!0,get:function(){return N.compileMask}}),Object.defineProperty(t,"splitSections",{enumerable:!0,get:function(){return N.splitSections}}),Object.defineProperty(t,"parseSection",{enumerable:!0,get:function(){return N.parseSection}}),Object.defineProperty(t,"parseShorthand",{enumerable:!0,get:function(){return u.parseShorthand}}),Object.defineProperty(t,"looksLikeMask",{enumerable:!0,get:function(){return u.looksLikeMask}}),Object.defineProperty(t,"looksLikeDatePattern",{enumerable:!0,get:function(){return u.looksLikeDatePattern}});const v=new Set(["decimal","currency","percent","unit"]),l=new Set(["type","locale"]),x={number:new Set(["style","currency","currencyDisplay","decimals","minDecimals","maxDecimals","thousandsSeparator","decimalSeparator","notation","compactDisplay","negative","negativeClass","signed","prefix","suffix","zeroDisplay","nullDisplay","messages","scale","pattern"]),date:new Set(["pattern","dateStyle","timeStyle","timeZone","relative","nullDisplay"]),boolean:new Set(["display","trueLabel","falseLabel","nullLabel","trueIcon","falseIcon"]),text:new Set(["transform","truncate","nullDisplay","emptyDisplay"])},W=new Set(["number","date","boolean","text"]);function Z(z,U){const L=z.type;if(L===void 0||W.has(L)||!v.has(String(L)))return;const e=U?`"${U}"`:"with no id";ne(`format:unknown-style-key:${U||""}:${L}`,`column ${e} has format: { type: "${L}" }, which is not a valid format type ("number", "date", "boolean" or "text") and is ignored; did you mean style: "${L}" instead?`)}function le(z,U,L){const e=x[U],i=L?`"${L}"`:"with no id";for(const a of z){if(l.has(a)||e.has(a))continue;const A=Object.keys(x).find($=>$!==U&&x[$].has(a));A?ne(`format:inapplicable:${L||""}:${a}`,`column ${i} has format key "${a}", which applies to a ${A} column, not the ${U} column it was applied to; it is ignored.`):ne(`format:unknown:${L||""}:${a}`,`column ${i} has an unrecognised format key "${a}" for its ${U} format; it is ignored.`)}}function oe(z){if(z.type==="number"||z.type==="date"||z.type==="boolean"||z.type==="text")return!0;const U=v.has(String(z.style));return!!(z.pattern||z.dateStyle||z.timeStyle||z.relative||z.timeZone||z.trueLabel||z.falseLabel||z.display||z.trueIcon||z.falseIcon||z.transform||z.truncate||z.emptyDisplay||U||z.currency||z.decimals!==void 0||z.minDecimals!==void 0||z.maxDecimals!==void 0||z.notation||z.negative||z.scale!==void 0||z.prefix||z.suffix||z.zeroDisplay!==void 0)}function y(z,U){if(z.type==="number"||z.type==="date"||z.type==="boolean"||z.type==="text")return z.type;if(z.pattern){if(c(z.pattern))return"number";if(w(z.pattern))return"date"}if(z.dateStyle||z.timeStyle||z.relative||z.timeZone)return"date";if(z.trueLabel||z.falseLabel||z.display||z.trueIcon||z.falseIcon)return"boolean";if(z.transform||z.truncate||z.emptyDisplay)return"text";if(z.style||z.currency||z.decimals!==void 0||z.minDecimals!==void 0||z.maxDecimals!==void 0||z.notation||z.negative||z.scale!==void 0||z.prefix||z.suffix||z.zeroDisplay!==void 0)return"number";const L=U&&U.base;return L==="number"?"number":L==="date"||L==="dateString"?"date":L==="boolean"?"boolean":"text"}function C(z,U=null,L=void 0,e=void 0,i=void 0){if(z==null||z==="")return null;const a=fe(z)?Object.keys(z):null;if(typeof z=="function"){const te=(ke,ge)=>String(z({...ge||{},value:ke,locale:L})??"");return te.ooxml=U&&U.excel||"General",te}if(typeof z=="string"){if(c(z)){const{format:ke,ooxml:ge}=p(z,L);return ke.ooxml=ge,ke}const te=m(z)||(w(z)?{type:"date",pattern:z}:null);return te?C(te,U,L,e,i):(ne(`format:${z}`,`unrecognised format string "${z}"; the value will be stringified`),null)}if(!fe(z))return ne("format:shape","format must be a spec object or a string; ignoring",z),null;if(U&&Y(U.format)&&!oe(z)||U&&Y(U.format)&&Array.isArray(U.formatPatterns)&&z.type===void 0)return null;const A=y(z,U);A==="date"&&e&&z.timeZone===void 0&&(z={...z,timeZone:e}),Z(z,i),le(a||Object.keys(z),A,i);let $;switch(A){case"number":$=V(z,L);break;case"date":$=q(z,L);break;case"boolean":$=S(z,L);break;default:$=P(z,L);break}return $.ooxml=M(z,A,L,U),$.kind=A,$}const D={yyyy:"yyyy",yy:"yy",MMMM:"mmmm",MMM:"mmm",MM:"mm",M:"m",dd:"dd",d:"d",EEEE:"dddd",EEE:"ddd",HH:"hh",H:"h",hh:"hh",h:"h",mm:"mm",m:"m",ss:"ss",s:"s",SSS:"000",a:"AM/PM"};function M(z,U,L=void 0,e=null){if(U==="date"){if(z.pattern){let te="";for(const ke of R(z.pattern))te+=ke.token?D[ke.token]??ke.text:ke.text;return te}return e&&e.excel||"yyyy-mm-dd"}if(U==="boolean")return"General";if(U==="text")return"@";if(typeof z.pattern=="string"&&r(z.pattern))return String(z.pattern).trim();if(z.notation==="compact"||z.notation==="scientific")return"General";const i=typeof z.decimals=="number"?z.decimals:typeof z.minDecimals=="number"?z.minDecimals:z.style==="currency"?2:0;let A=`${z.thousandsSeparator===!1?"":"#,#"}#0${i>0?`.${"0".repeat(i)}`:""}`,$="";return z.style==="currency"&&($+=J(re(z.currency||"USD",L))),z.prefix&&($+=J(z.prefix)),A=$+A,z.style==="percent"&&(A=`${A}%`),z.suffix&&(A+=J(z.suffix)),z.negative==="parentheses"?`${A};(${A})`:z.negative==="suffix"?`${A};${A}-`:A}function J(z){return`"${String(z).split('"').join("")}"`}const F=new Map;function re(z,U){const L=`${z}|${U||""}`;let e=F.get(L);if(e!==void 0)return e;e=z;try{const a=new Intl.NumberFormat(U,{style:"currency",currency:z}).formatToParts(0).find(A=>A.type==="currency");a&&(e=a.value)}catch{}return F.set(L,e),e}}),Ze("packages/modules/charts/format.js",function(t,ue){"use strict";Object.defineProperty(t,"precisionFor",{enumerable:!0,get:function(){return T}}),Object.defineProperty(t,"axisNumber",{enumerable:!0,get:function(){return q}}),Object.defineProperty(t,"r2Digits",{enumerable:!0,get:function(){return R}}),Object.defineProperty(t,"dateFormatFor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"resolveTimeZone",{enumerable:!0,get:function(){return g}}),Object.defineProperty(t,"formatters",{enumerable:!0,get:function(){return P}}),Object.defineProperty(t,"measureText",{enumerable:!0,get:function(){return N}}),Object.defineProperty(t,"measureFormat",{enumerable:!0,get:function(){return p}}),Object.defineProperty(t,"stringFormatter",{enumerable:!0,get:function(){return m}});const Le=ue("packages/modules/charts/scale.js"),Y=Le.MONTH_STEPS,fe=Le.timeStepFor,ne=ue("packages/core/src/format/index.js").compileFormat,V=ue("packages/core/src/internal/warn.js").warnOnce;function T(c){if(!Number.isFinite(c)||c<=0)return 0;const w=Math.ceil(-Math.log10(c));return Math.min(6,Math.max(0,w))}function q(c,w,d=0){return Number.isFinite(c)?Math.abs(c)>=1e4?w.number(c,{notation:"compact",maximumFractionDigits:1}):w.number(c,{minimumFractionDigits:d,maximumFractionDigits:d}):""}function R(c,w){const d=c&&c.messages;return!d||typeof d.number!="function"?Number(w).toFixed(2):d.number(w,{minimumFractionDigits:2,maximumFractionDigits:2})}function f(c){const d=c>0?fe(c):0;return d>0&&d<1e3?{minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}:d>0&&d<6e4?{hour:"2-digit",minute:"2-digit",second:"2-digit"}:c<=864e5?{hour:"2-digit",minute:"2-digit"}:c<=180*864e5?Y.has(d)?{month:"short"}:d>0&&d<864e5?{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}:{day:"numeric",month:"short"}:c<=3*365*864e5?{month:"short",year:"numeric"}:{year:"numeric"}}let S;function g(c,w){const d=w&&w.format&&w.format.timeZone;if(d)return d;const r=c&&typeof c.get=="function"&&c.get("timeZone");return r||(S||(S=Intl.DateTimeFormat().resolvedOptions().timeZone),S)}function P(c,w,d){const r=c.messages,v=r.locale,l=g(c,d);if(w.kind==="time"){const W=f(w.span||0),Z=new Intl.DateTimeFormat(v,{...W,timeZone:l}),le=new Intl.DateTimeFormat(v,{dateStyle:"medium",timeStyle:"short",timeZone:l});return{tick:oe=>Number.isFinite(Number(oe))?Z.format(new Date(Number(oe))):"",value:oe=>Number.isFinite(Number(oe))?le.format(new Date(Number(oe))):""}}const x=T(w.step||0);return{tick:W=>typeof W=="number"?q(W,r,x):String(W??""),value:W=>typeof W=="number"?r.number(W):String(W??"")}}function N(c,w){if(c==null||!Number.isFinite(c))return"";const d=Math.abs(c)>=1e-6?Number(c.toPrecision(6)):c;return w.number(d)}function p(c,w,d){return c==null||!Number.isFinite(Number(c))?"":w&&w.format&&typeof w.formatValue=="function"?String(w.formatValue(c,null)):N(Number(c),d&&d.messages)}const u=new Map;function m(c,w,d){const r=w&&w.messages&&w.messages.locale,v=`${r}\0${c}`;if(!u.has(v)){let x=null;try{x=ne(c,null,r)}catch{x=null}u.set(v,x)}const l=u.get(v);return l?x=>String(l(x)):(V(`chart.format.string:${d}:${c}`,`${d}: the format string "${c}" is not understood; values are drawn unformatted`),null)}}),Ze("packages/modules/charts/axis.js",function(t,ue){"use strict";Object.defineProperty(t,"pinXDomain",{enumerable:!0,get:function(){return r}}),Object.defineProperty(t,"labelGap",{enumerable:!0,get:function(){return x}}),Object.defineProperty(t,"TICK_FLOOR",{enumerable:!0,get:function(){return W}}),Object.defineProperty(t,"tickFloor",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(t,"fitBandLabels",{enumerable:!0,get:function(){return le}}),Object.defineProperty(t,"normaliseAxes",{enumerable:!0,get:function(){return D}}),Object.defineProperty(t,"tickValues",{enumerable:!0,get:function(){return M}}),Object.defineProperty(t,"tickLabeller",{enumerable:!0,get:function(){return J}}),Object.defineProperty(t,"drawAxisTitle",{enumerable:!0,get:function(){return F}}),Object.defineProperty(t,"labelEvery",{enumerable:!0,get:function(){return re}}),Object.defineProperty(t,"drawMeasureAxis",{enumerable:!0,get:function(){return z}}),Object.defineProperty(t,"heldInside",{enumerable:!0,get:function(){return U}}),Object.defineProperty(t,"drawCategoryAxis",{enumerable:!0,get:function(){return L}}),Object.defineProperty(t,"turnedFirstLabelBox",{enumerable:!0,get:function(){return e}}),Object.defineProperty(t,"leftLabelRoom",{enumerable:!0,get:function(){return i}}),Object.defineProperty(t,"setLabelText",{enumerable:!0,get:function(){return a}}),Object.defineProperty(t,"drawBandLabels",{enumerable:!0,get:function(){return A}}),Object.defineProperty(t,"drawContinuousAxis",{enumerable:!0,get:function(){return $}}),Object.defineProperty(t,"drawAxisLines",{enumerable:!0,get:function(){return te}}),Object.defineProperty(t,"createGroups",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(t,"MARK_OVERHANG",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(t,"overhangFor",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(t,"setPlotClip",{enumerable:!0,get:function(){return Te}});const Y=ue("packages/modules/charts/frame.js").Pool,fe=ue("packages/modules/charts/svg.js"),se=fe.attrs,ne=fe.round,n=fe.setText,V=fe.svg,T=ue("packages/modules/charts/typography.js"),q=T.applySize,R=T.CHAR_RATIO,f=T.truncateTo,g=ue("packages/modules/charts/styles.js").NS,P=ue("packages/modules/charts/scale.js"),N=P.toNumber,p=P.toTime,u=ue("packages/modules/charts/format.js"),m=u.resolveTimeZone,c=u.stringFormatter,d=ue("packages/core/src/internal/warn.js").warnOnce;function r(_,pe,me){const ie=pe&&pe.kind==="time"?p:N,Q=O=>O==null||O===""?null:ie(O),ye=Q(me&&me.min),o=Q(me&&me.max);if(ye===null&&o===null)return _;if(ye!==null&&o!==null)return ye<o?{min:ye,max:o}:(d("chart.axis.x.domain.inverted",`axis.x.min (${ye}) is not below axis.x.max (${o}), which is a mirrored axis rather than a narrow one, so both were ignored and the x domain was taken from the data. On a time axis both are epoch milliseconds.`),_);const H=ye!==null?ye:_.min,s=o!==null?o:_.max;if(H<s)return{min:H,max:s};const h=Math.abs(_.max-_.min)||1;return d("chart.axis.x.domain.beyond",`axis.x.${ye!==null?"min":"max"} is outside the x values entirely, so the plot is empty. The pin was kept and the other edge moved to hold the axis width; check the units (a time axis is pinned in epoch milliseconds).`),ye!==null?{min:H,max:H+h}:{min:s-h,max:s}}const v=6,l=.53;function x(_){return Number.isFinite(_)&&_>0?Math.max(v,Math.ceil(_)+1):v}const W=9;function Z(_){const pe=_&&_.ownerDocument,me=pe&&pe.defaultView;if(!me||typeof me.getComputedStyle!="function")return W;const ie=me.getComputedStyle(_).getPropertyValue("--lattice-chart-tick-min"),Q=parseFloat(ie);return Number.isFinite(Q)&&Q>0?Q:W}function le(_){const{size:pe,floor:me,slot:ie,per:Q}=_,ye=Number.isFinite(_.every)&&_.every>0?Number(_.every):null;if(ye!==null&&ye!==1)return{size:pe,every:ye,thinned:!1};if(!(ie>0)||!(Q>0))return{size:pe,every:1,thinned:!1};const o=Math.min(pe,ie/Q);return o>=me?{size:o,every:1,thinned:!1}:{size:me,every:Math.max(1,Math.ceil(me*Q/ie)),thinned:!0}}function oe(_,pe){d("chart.axis.band.every.impossible",`axis.x.every/axis.y.every is set to ${pe}, which on ${_} band(s) never shows a second label no matter how much room the axis is given. Lower it, or drop it to let the axis thin automatically.`)}function y(_,pe){const me=Number.isFinite(pe)&&pe>0?Number(pe):null;me!==null&&me>1&&_>1&&me>=_&&oe(_,me)}const C=1.2;function D(_){if(_===!1){const ie={labels:!1,grid:!1};return{x:{...ie},y:{...ie},y2:{...ie}}}const pe=_&&typeof _=="object"?_:{},me=ie=>typeof ie=="string"?{title:ie}:ie&&typeof ie=="object"?{...ie}:{};return{x:me(pe.x),y:me(pe.y),y2:me(pe.y2||pe.right)}}function M(_,pe,me){const ie=pe&&pe.ticks;if(Array.isArray(ie)){const ye=_.domain;return!ye||ye.min===void 0?ie:ie.filter(o=>Number(o)>=ye.min&&Number(o)<=ye.max)}const Q=Number.isFinite(ie)&&ie>0?Number(ie):5;return _.ticks(Q,me)}function J(_,pe,me,ie){const Q=_&&_.format;if(typeof Q=="function")return ye=>String(Q(ye));if(typeof Q=="string"){const ye=c(Q,me,"axis.<x|y|y2>.format");if(ye)return ye}return ie&&ie.format&&ie.format.pattern&&typeof ie.formatValue=="function"?ye=>String(ie.formatValue(ye,null)):pe.tick}function F(_){if(!_.text)return;const pe=_.side==="left"||_.side==="right"?_.plot.height:_.plot.width,me=Number.isFinite(pe)?f(String(_.text),Math.max(0,pe),_.size):String(_.text);if(!me||me==="…")return;const ie=V(_.group.ownerDocument,"text",{class:`${g}__axis-title`});if(q(ie,_.size),_.side==="left"){const Q=Math.max(_.size*1.15,_.plot.left-_.plot.gutter.left+_.size*1.15),ye=_.plot.top+_.plot.height/2;se(ie,{transform:`translate(${ne(Q)} ${ne(ye)}) rotate(-90)`,"text-anchor":"middle"})}else if(_.side==="right"){const Q=_.plot.right+_.plot.gutter.right-_.size*1.15,ye=_.plot.top+_.plot.height/2;se(ie,{transform:`translate(${ne(Q)} ${ne(ye)}) rotate(90)`,"text-anchor":"middle"})}else se(ie,{x:ne(_.plot.left+_.plot.width/2),y:ne(_.plot.bottom+_.plot.gutter.bottom-2),"text-anchor":"middle"});n(ie,me),me!==String(_.text)&&ie.setAttribute("aria-label",String(_.text)),_.group.appendChild(ie)}function re(_){const{values:pe,scale:me,size:ie,horizontal:Q,label:ye}=_;if(pe.length<2)return 1;let o=1/0;for(let s=1;s<pe.length;s++){const h=Math.abs(me.of(pe[s])-me.of(pe[s-1]));Number.isFinite(h)&&h<o&&(o=h)}if(!Number.isFinite(o))return 1;if(o<=0)return pe.length;let H=ie*C+2;if(Q){let s=0;for(const h of pe){const O=String(ye(h)||"").length*ie*R;O>s&&(s=O)}H=s+v}return Math.max(1,Math.ceil(H/o))}function z(_){const{gridGroup:pe,axisGroup:me,plot:ie,scale:Q,format:ye}=_,o=_.config||{},H=Q.kind==="time"&&_.grid?m(_.grid,_.column):void 0,s=M(Q,o,H),h=J(o,ye,_.grid),O=_.size||11,I=re({values:s,scale:Q,size:O,horizontal:!!_.horizontal,label:h}),K=x(_.overhang),ee=o.grid===!1?null:pe,E=ee?new Y(ee):null,G=new Y(me);for(let Me=0;Me<s.length;Me++){const k=s[Me],j=ne(Q.of(k)),X=k===0,ae=Me%I!==0;if(_.horizontal){if(E&&se(E.next("line",`${g}__gridline`),{x1:j,x2:j,y1:ne(ie.top),y2:ne(ie.bottom),"stroke-opacity":X?1:.6,"stroke-width":X?1.5:1}),o.labels===!1||ae)continue;const be=h(k),Se=String(be).length*O*R/2,Ae=ie.gutter;if(Ae&&(j-Se<ie.left-(Ae.left||0)||j+Se>ie.right+(Ae.right||0)))continue;const ze=G.next("text",`${g}__tick`);q(ze,O),se(ze,{x:j,y:ne(ie.bottom+K),"text-anchor":"middle","dominant-baseline":"hanging"}),n(ze,be)}else{if(E&&se(E.next("line",`${g}__gridline`),{x1:ne(ie.left),x2:ne(ie.right),y1:j,y2:j,"stroke-opacity":X?1:.6,"stroke-width":X?1.5:1}),o.labels===!1||ae)continue;const be=_.side==="right",Se=h(k),Ae=U(j,ie,O);if(_.dropBottom&&Math.abs(j-ie.bottom)<=1){if(_.dropBottom===!0)continue;const Be=String(Se).length*O*R,qe=be?{left:ie.right+K,right:ie.right+K+Be}:{left:ie.left-K-Be,right:ie.left-K};qe.top=Ae-O*.85,qe.bottom=Ae+O*.6;const Ue=_.dropBottom,We=3;if(qe.left<Ue.right+We&&qe.right>Ue.left-We&&qe.top<Ue.bottom+We&&qe.bottom>Ue.top-We)continue}const ze=G.next("text",`${g}__tick`);q(ze,O),se(ze,{x:ne(be?ie.right+K:ie.left-K),y:Ae,"text-anchor":be?"start":"end","dominant-baseline":"middle"}),n(ze,Se)}}return E?E.finish():new Y(pe).finish(),G.finish(),s}function U(_,pe,me){const ie=pe&&pe.gutter;if(!ie)return _;const Q=pe.top-(Number.isFinite(ie.top)?ie.top:0)+me*.85+1,ye=pe.bottom+(Number.isFinite(ie.bottom)?ie.bottom:0)-me*.6-1;return ne(Math.min(Math.max(_,Q),Math.max(Q,ye)))}function L(_){const{group:pe,plot:me,scale:ie,labels:Q}=_,ye=_.config||{};if(ye.labels===!1){new Y(pe).finish();return}const o=new Y(pe),H=ie.domain,s=ie.step,h=ye.rotate===void 0||ye.rotate==="auto"?_.rotated:!!ye.rotate,O=h?le({size:_.fontSize,floor:Z(pe),slot:s,per:Math.SQRT2,every:ye.every}):{size:_.fontSize,every:Number.isFinite(ye.every)&&ye.every>0?Number(ye.every):1,thinned:!1},{size:I,every:K}=O;y(H.length,ye.every);const ee=s*K;for(let E=0;E<H.length;E++){const G=ne(ie.centre(H[E]));if(Number.isNaN(G)||E%K!==0)continue;const Me=o.next("text",`${g}__tick`);q(Me,I);const k=Q[E]===void 0?"":Q[E];if(h){se(Me,{x:0,y:0,"text-anchor":"end","dominant-baseline":"middle",transform:`translate(${G} ${ne(me.bottom+v+2)}) rotate(-45)`});const j=ee*Math.SQRT2-I*1.5,X=Math.max(0,me.gutter.bottom-v)*Math.SQRT2;a(Me,k,Math.max(0,Math.min(X,j)),I)}else se(Me,{x:G,y:ne(me.bottom+v),"text-anchor":"middle","dominant-baseline":"hanging",transform:null}),a(Me,k,ee,I)}o.finish()}function e(_){const{group:pe,plot:me,scale:ie,labels:Q,fontSize:ye}=_,o=_.config||{};if(o.labels===!1)return null;const H=ie.domain;if(!H||!H.length||!me.gutter)return null;const s=ie.step,h=le({size:ye,floor:Z(pe),slot:s,per:Math.SQRT2,every:o.every}),{size:O,every:I}=h,K=ne(ie.centre(H[0]));if(Number.isNaN(K))return null;const E=s*I*Math.SQRT2-O*1.5,G=Math.max(0,me.gutter.bottom-v)*Math.SQRT2,Me=Math.max(0,Math.min(G,E)),k=String(Q[0]===void 0?"":Q[0]),X=f(k,Me,O).length*O*l,ae=O*.6,be=ne(me.bottom+v),Se=Math.SQRT1_2;return{left:K-Se*(X+ae),right:K+Se*ae,top:be-Se*ae,bottom:be+Se*(X+ae)}}function i(_){return Math.max(0,(_.gutter?_.gutter.left:_.left)-v)}function a(_,pe,me,ie){const Q=String(pe??""),ye=f(Q,me,ie);return n(_,ye),ye!==Q?_.setAttribute("aria-label",Q):_.removeAttribute("aria-label"),ye}function A(_){const{group:pe,plot:me,scale:ie,labels:Q}=_,ye=_.config||{},o=new Y(pe),H=ie.domain,s=i(me),h=Number.isFinite(_.per)&&_.per>0?_.per:C,O=le({size:_.fontSize,floor:Z(pe),slot:ie.step,per:h,every:ye.every}),{size:I,every:K}=O;y(H.length,ye.every);for(let ee=0;ee<H.length;ee++){if(ee%K!==0)continue;const E=ne(ie.centre(H[ee]));if(Number.isNaN(E))continue;const G=o.next("text",`${g}__tick`);se(G,{x:ne(me.left-v),y:E,"text-anchor":"end","dominant-baseline":"middle"}),q(G,I),a(G,Q[ee],s,I)}o.finish()}function $(_){const{group:pe,plot:me,scale:ie,format:Q}=_,ye=_.config||{};if(ye.labels===!1){new Y(pe).finish();return}const o=J(ye,Q,_.grid,_.column),H=_.size||11,s=me&&me.gutter,h=s&&Number.isFinite(s.left)?me.left-s.left:-1/0,O=s&&Number.isFinite(s.right)?me.right+s.right:1/0,I=x(_.overhang),K=new Y(pe),ee=ie.kind==="time"&&_.grid?m(_.grid,_.column):void 0;for(const E of M(ie,ye,ee)){const G=ne(ie.of(E));if(G<me.left-1||G>me.right+1)continue;const Me=o(E),k=String(Me).length*H*R/2;if(G-k<h||G+k>O)continue;const j=K.next("text",`${g}__tick`);q(j,H),se(j,{x:G,y:ne(me.bottom+I),"text-anchor":"middle","dominant-baseline":"hanging"}),n(j,Me)}K.finish()}function te(_){const{group:pe,plot:me}=_,ie=_.side==="right"?me.right:me.left,Q=new Y(pe);se(Q.next("line"),{x1:ne(ie),x2:ne(ie),y1:ne(me.top),y2:ne(me.bottom)}),se(Q.next("line"),{x1:ne(me.left),x2:ne(me.right),y1:ne(me.bottom),y2:ne(me.bottom)}),Q.finish()}let ke=0;function ge(_,pe){const me=`${g}-plot-clip-${++ke}`,ie=V(_,"rect"),Q=V(_,"clipPath",{id:me});Q.appendChild(ie);const ye=`${g}-box-clip-${ke}`,o=V(_,"clipPath",{id:ye});o.appendChild(V(_,"rect",{x:0,y:0,width:"100%",height:"100%"}));const H=V(_,"defs");H.appendChild(Q),H.appendChild(o);const s={grid:V(_,"g",{class:`${g}__grid`}),marks:V(_,"g",{class:`${g}__marks`}),rules:V(_,"g",{class:`${g}__axis`}),axis:V(_,"g",{class:`${g}__axis`}),labels:V(_,"g",{class:`${g}__labels`}),overlay:V(_,"g",{class:`${g}__overlay`}),clip:ie,clipId:me,boxClipId:ye};pe.appendChild(H);for(const h of["grid","marks","rules","axis","labels","overlay"])pe.appendChild(s[h]);return s}const ve=30;function Pe(_){return _==="bubble"?ve:_==="scatter"?6:3}function Te(_,pe,me){if(!_||!_.marks||!_.clip)return;if(!pe||!Number.isFinite(pe.width)||!Number.isFinite(pe.height)){_.marks.removeAttribute("clip-path");return}const ie=Number.isFinite(me)&&me>=0?Number(me):ve;se(_.clip,{x:ne(pe.left-ie),y:ne(pe.top-ie),width:ne(Math.max(0,pe.width)+ie*2),height:ne(Math.max(0,pe.height)+ie*2)}),_.marks.setAttribute("clip-path",`url(#${_.clipId})`)}}),Ze("packages/modules/charts/stack.js",function(t,ue){"use strict";Object.defineProperty(t,"measureValues",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(t,"stacker",{enumerable:!0,get:function(){return se}});const Y=ue("packages/modules/charts/scale.js").isNumber;function fe(ne,n,V){if(V)return[0,100];if(!n){const f=[];for(const S of ne)for(const g of S.points)f.push(g.y);return f}const T=[],q=[],R=ne[0]?ne[0].points.length:0;for(let f=0;f<R;f++){let S=0,g=0;for(const P of ne){const N=P.points[f]?P.points[f].y:null;Y(N)&&(N>=0?S+=N:g+=N)}T.push(S),q.push(g)}return[...T,...q]}function se(ne,n){const V=new Float64Array(ne),T=new Float64Array(ne);return{take(q,R){const f=n?n[q]:0,S=n?f?R/f*100:0:R;if(S>=0){const P=V[q];return V[q]+=S,[P,V[q]]}const g=T[q];return T[q]+=S,[g,T[q]]}}}}),Ze("packages/modules/charts/labels.js",function(t,ue){"use strict";Object.defineProperty(t,"resolveLabels",{enumerable:!0,get:function(){return p}}),Object.defineProperty(t,"collides",{enumerable:!0,get:function(){return u}}),Object.defineProperty(t,"placeLabels",{enumerable:!0,get:function(){return m}}),Object.defineProperty(t,"labelText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(t,"drawAnchoredLabels",{enumerable:!0,get:function(){return w}}),Object.defineProperty(t,"drawDataLabels",{enumerable:!0,get:function(){return d}});const Y=ue("packages/modules/charts/frame.js").Pool,fe=ue("packages/modules/charts/format.js"),se=fe.measureText,ne=fe.stringFormatter,n=ue("packages/modules/charts/svg.js"),V=n.attrs,T=n.round,q=n.setText,f=ue("packages/modules/charts/styles.js").NS,S=ue("packages/modules/charts/typography.js"),g=S.applySize,P=S.textWidth,N=4;function p(r){const v=r&&r.labels;if(!v)return{show:!1,names:v!==!1,position:"outside",format:null,minGap:2,total:!1};const l=typeof v=="object"?v:{};return{show:!0,names:!0,position:["outside","inside","auto"].includes(l.position)?l.position:"outside",format:l.format||null,minGap:Number.isFinite(l.minGap)?Number(l.minGap):2,total:!!l.total}}function u(r,v,l){for(const x of v)if(r.x-l<x.x+x.width&&r.x+r.width+l>x.x&&r.y-l<x.y+x.height&&r.y+r.height+l>x.y)return!0;return!1}function m(r){const{points:v,plot:l,size:x}=r,W=r.minGap===void 0?2:r.minGap,Z=[],le=[];for(const oe of v){if(oe.px===void 0||oe.py===void 0)continue;const y=r.text(oe);if(!y)continue;const C=P(y,x),D=x;let M=oe.px,J=oe.py-N,F="middle",re=!1;r.horizontal?(M=oe.px+N,J=oe.py,F="start",r.position!=="outside"&&oe.pbase!==void 0&&Math.abs(oe.px-oe.pbase)>C+N*2&&(M=oe.px-N,F="end",re=!0)):r.position!=="outside"&&oe.pbase!==void 0&&Math.abs(oe.pbase-oe.py)>D+N*2&&(J=oe.py+D+N,re=!0);const z=()=>({x:F==="middle"?M-C/2:F==="end"?M-C:M,y:J-D,width:C,height:D});let U=z();!(U.y>=l.top-1)&&!re&&!r.horizontal&&oe.pbase!==void 0&&Math.abs(oe.pbase-oe.py)>D+N*2&&(J=oe.py+D+N,re=!0,U=z()),!(U.x+U.width<=l.right+1)&&!re&&r.horizontal&&oe.pbase!==void 0&&Math.abs(oe.px-oe.pbase)>C+N*2&&(M=oe.px-N,F="end",re=!0,U=z()),!(U.x<l.left-1||U.x+U.width>l.right+1)&&(U.y<l.top-1||U.y+U.height>l.bottom+D||u(U,Z,W)||(Z.push(U),le.push({x:T(M),y:T(J),text:y,anchor:F,inside:re})))}return le}function c(r,v,l){if(r==null)return"";if(typeof v.format=="function")return String(v.format(r));if(typeof v.format=="string"){const x=ne(v.format,l,"labels.format");if(x)return x(r)}return se(r,l&&l.messages)}function w(r){const v=new Y(r.group),l=r.minGap===void 0?2:r.minGap,x=r.size,W=[];let Z=0;for(const le of r.anchors){if(!le||!le.text)continue;const oe=le.width===void 0?P(le.text,r.size):le.width,y=le.anchor||"middle",D={x:y==="end"?le.x-oe:y==="start"?le.x:le.x-oe/2,y:le.y-x/2,width:oe,height:x};if(r.plot&&(D.x<r.plot.left-1||D.x+D.width>r.plot.right+1||D.y<r.plot.top-1||D.y+D.height>r.plot.bottom+1)||le.width!==void 0&&oe>le.width||le.height!==void 0&&x>le.height||u(D,W,l))continue;W.push(D);const M=v.next("text",le.className||`${f}__data-label`);g(M,r.size),V(M,{x:T(le.x),y:T(le.y),"text-anchor":y,"dominant-baseline":le.baseline||"middle","data-inside":le.inside?"true":null}),q(M,le.text),Z++}return v.finish(),Z}function d(r){const v=new Y(r.group),{options:l}=r;let x=0;const W=Z=>typeof l.format=="function"&&Z.y!==null&&Z.y!==void 0?String(l.format(Z.y,Z)):c(Z.y,l,r.grid);for(const Z of r.series){const le=m({points:Z.points,plot:r.plot,size:r.size,position:l.position,horizontal:r.horizontal,minGap:l.minGap,text:W});for(const oe of le){const y=v.next("text",`${f}__data-label`);g(y,r.size),V(y,{x:oe.x,y:oe.y,"text-anchor":oe.anchor,"data-inside":oe.inside?"true":null}),q(y,oe.text),x++}}return v.finish(),x}}),Ze("packages/modules/charts/dense.js",function(t,ue){"use strict";Object.defineProperty(t,"CANVAS_THRESHOLD",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(t,"downsample",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(t,"markCount",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(t,"wantsCanvas",{enumerable:!0,get:function(){return se}}),Object.defineProperty(t,"paintDense",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(t,"sizeCanvas",{enumerable:!0,get:function(){return n}});const Le=3e3;function Y(V,T){const q=V.length;if(!Number.isFinite(T)||T>=q||T<3||q<3)return V;const R=[V[0]],f=(q-2)/(T-2);let S=0;for(let g=0;g<T-2;g++){const P=Math.floor(g*f)+1,N=Math.min(Math.floor((g+1)*f)+1,q-1),p=N,u=Math.min(Math.floor((g+2)*f)+1,q);let m=0,c=0,w=0;for(let l=p;l<u;l++){const x=V[l];!x||!Number.isFinite(x.y)||(m+=x.x,c+=x.y,w++)}w&&(m/=w,c/=w);const d=V[S];if(P>=N)continue;let r=P,v=-1;for(let l=P;l<N;l++){const x=V[l];if(!x||!Number.isFinite(x.y))continue;const W=Math.abs((d.x-m)*(x.y-d.y)-(d.x-x.x)*(c-d.y));W>v&&(v=W,r=l)}r<=S||(R.push(V[r]),S=r)}return R.push(V[q-1]),R}function fe(V){let T=0;for(const q of V)T+=q.points.length;return T}function se(V){if(V.canvas===!0)return!0;if(V.canvas===!1)return!1;const T=Number.isFinite(V.canvas)?Number(V.canvas):Le;return fe(V.series)>T}function ne(V){const{context:T,series:q,ratio:R}=V;T.save(),T.scale(R,R);for(const f of q){const S=V.colour(f.index);if(V.type==="scatter"||V.type==="bubble"){T.fillStyle=S;for(const P of f.points)P.px!==void 0&&(T.beginPath(),T.arc(P.px,P.py,P.pr||2,0,Math.PI*2),T.fill());continue}T.strokeStyle=S,T.lineWidth=2,T.lineJoin="round",T.beginPath();let g=!1;for(const P of f.points){if(P.px===void 0||P.py===void 0){g=!1;continue}g?T.lineTo(P.px,P.py):T.moveTo(P.px,P.py),g=!0}T.stroke()}T.restore()}function n(V){const{canvas:T}=V;return T.width=Math.max(1,Math.round(V.width*V.ratio)),T.height=Math.max(1,Math.round(V.height*V.ratio)),T.style&&(T.style.width=`${V.width}px`,T.style.height=`${V.height}px`),typeof T.getContext=="function"?T.getContext("2d"):null}}),Ze("packages/modules/charts/annotations.js",function(t,ue){"use strict";Object.defineProperty(t,"overlayLayer",{enumerable:!0,get:function(){return u}}),Object.defineProperty(t,"annotationValue",{enumerable:!0,get:function(){return x}}),Object.defineProperty(t,"annotationAxis",{enumerable:!0,get:function(){return W}}),Object.defineProperty(t,"annotationText",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(t,"drawAnnotations",{enumerable:!0,get:function(){return oe}});const Y=ue("packages/modules/charts/frame.js").Pool,fe=ue("packages/modules/charts/scale.js"),se=fe.isNumber,ne=fe.toNumber,n=fe.toTime,V=ue("packages/modules/charts/svg.js"),T=V.attrs,q=V.path,R=V.round,f=V.setText,S=V.SVG_NS,P=ue("packages/modules/charts/styles.js").NS,p=ue("packages/core/src/internal/warn.js").warnOnce;function u(y,C){for(const M of y.childNodes||[])if(M&&String(M.getAttribute&&M.getAttribute("class"))===C)return M;const D=y.ownerDocument.createElementNS(S,"g");return D.setAttribute("class",C),y.appendChild(D),D}const m=new Set(["line","target","band","callout","event"]);function c(y,C){return y.kind==="time"?n(C):ne(C)}function w(y,C,D){if(y.kind==="band"){const J=y.of(C);if(!Number.isFinite(J))return NaN;const F=Number(y.bandwidth)||0;return D==="right"?J+F:J}const M=c(y,C);return M===null?NaN:y.of(M)}function d(y,C,D){const M=y.kind||"line",J=y.label?` (${JSON.stringify(y.label)})`:"";p(`chart:annotation:dropped:${M}:${C}:${D}`,`chart annotation${J} of kind ${JSON.stringify(M)}, reading the ${C} axis, was not drawn: ${D}.`)}function r(y,C){if(y instanceof Date){const M=y.getTime();return Number.isFinite(M)?y.toISOString().slice(0,10):String(y)}if(typeof y=="number")return Number.isFinite(y)?C(y):String(y);const D=ne(y);return D===null||typeof y=="string"?String(y):C(D)}function v(y,C,D){const M=[];for(const J of y)if((J.axis==="right"?"right":"left")===D&&!(C.series!==void 0&&J.key!==C.series))for(const re of J.points)se(re.y)&&M.push(Number(re.y));return M}function l(y,C){if(!y.length)return null;const D=[...y].sort((re,z)=>re-z);if(D.length===1)return D[0];const M=Math.min(100,Math.max(0,C))/100*(D.length-1),J=Math.floor(M),F=Math.ceil(M);return J===F?D[J]:D[J]+(D[F]-D[J])*(M-J)}function x(y,C,D){if(!y.compute)return ne(y.value);const M=v(C,y,D);if(!M.length)return null;const J=String(y.compute).toLowerCase();if(J==="mean"||J==="avg")return M.reduce((re,z)=>re+z,0)/M.length;if(J==="median"||J==="p50")return l(M,50);if(J==="min")return Math.min(...M);if(J==="max")return Math.max(...M);const F=/^p(\d+(?:\.\d+)?)$/.exec(J);return F?l(M,Number(F[1])):null}function W(y){return y.axis==="right"||y.axis==="y2"?"right":"left"}function Z(y,C,D,M){const J=y.label?`${y.label}: `:"",F=M?` (${W(y)==="right"?"right axis":"left axis"})`:"",re=y.kind||"line";if(re==="band"){if(!Array.isArray(C)||C[0]===null||C[1]===null)return"";const[U,L]=C;return`${J||"Band: "}${D(Math.min(U,L))} to ${D(Math.max(U,L))}${F}`}return C==null?"":`${J||`${re==="target"?"Target":re==="callout"?"Callout":"Reference"}: `}${D(C)}${F}`}function le(y){return(y.kind||"line")==="band"?0:1}function oe(y){const{group:C,plot:D,xScale:M,yScale:J,rightScale:F,series:re,format:z}=y,U=new Y(u(C,`${P}__annotations`)),L=[],i=[...Array.isArray(y.annotations)?y.annotations:[]].sort((a,A)=>le(a)-le(A));for(const a of i){const A=a.kind||"line";if(!m.has(A))continue;const $=W(a),te=$==="right"&&F?F:J;if(A==="band"){if(a.orient==="vertical"){const me=w(M,a.from,"left"),ie=w(M,a.to,"right");if(Number.isNaN(me)||Number.isNaN(ie)){const H=Number.isNaN(me)&&Number.isNaN(ie)?"from and to":Number.isNaN(me)?"from":"to";d(a,$,`its ${H} value could not be placed on the x scale`);continue}const Q=R(Math.min(me,ie)),ye=R(Math.max(me,ie));if(T(U.next("rect",`${P}__annotation-band ${a.className||""}`.trim()),{x:Q,y:R(D.top),width:Math.max(0,ye-Q),height:R(Math.max(0,D.bottom-D.top)),fill:a.colour||"currentColor","fill-opacity":a.opacity===void 0?.12:a.opacity}),a.label){const H=U.next("text",`${P}__annotation-label`);T(H,{x:Q+4,y:R(D.top+12),"text-anchor":"start"}),f(H,a.label)}const o=a.label?`${a.label}: `:"Event window: ";L.push({text:`${o}${r(a.from,z)} to ${r(a.to,z)}`});continue}const Pe=x({...a,value:a.from,compute:a.fromCompute},re,$),Te=x({...a,value:a.to,compute:a.toCompute},re,$);if(Pe===null||Te===null){d(a,$,`its ${Pe===null&&Te===null?"from and to":Pe===null?"from":"to"} value could not be resolved (a number, or a compute that finds values)`);continue}const _=R(te.of(Pe)),pe=R(te.of(Te));if(T(U.next("rect",`${P}__annotation-band ${a.className||""}`.trim()),{x:R(D.left),y:Math.min(_,pe),width:R(Math.max(0,D.right-D.left)),height:Math.max(0,Math.abs(pe-_)),fill:a.colour||"currentColor","fill-opacity":a.opacity===void 0?.12:a.opacity}),a.label){const me=U.next("text",`${P}__annotation-label`);T(me,{x:R(D.left+4),y:Math.min(_,pe)+12,"text-anchor":"start"}),f(me,a.label)}L.push({text:Z(a,[Pe,Te],z,y.dual)});continue}if(A==="event"){const Pe=a.x!==void 0?a.x:a.at,Te=R(w(M,Pe,"left")+(M.kind==="band"?(Number(M.bandwidth)||0)/2:0));if(Number.isNaN(Te)){d(a,$,"its x value could not be placed on the x scale");continue}if(T(U.next("path",`${P}__annotation-event`),{d:q(["M",Te,R(D.top),"L",Te,R(D.bottom)]),stroke:a.colour||"currentColor",fill:"none"}),T(U.next("circle",`${P}__annotation-event-flag`),{cx:Te,cy:R(D.top),r:3,fill:a.colour||"currentColor"}),a.label){const pe=U.next("text",`${P}__annotation-label`);T(pe,{x:Te+5,y:R(D.top+10),"text-anchor":"start"}),f(pe,a.label)}const _=a.label?`${a.label} — `:"Event — ";L.push({text:`${_}at ${r(Pe,z)}`});continue}if(A==="callout"){const Pe=x(a,re,$);if(Pe===null){d(a,$,"its value could not be resolved (a number, or a compute that finds values)");continue}const Te=a.at!==void 0?R(M.kind==="band"?M.centre(a.at):M.of(c(M,a.at)??NaN)):R(D.right-4),_=R(te.of(Pe));if(Number.isNaN(Te)){d(a,$,"its x value could not be placed on the x scale");continue}if(T(U.next("circle",`${P}__annotation-point`),{cx:Te,cy:_,r:3.5,fill:a.colour||"currentColor"}),a.label){const pe=U.next("text",`${P}__annotation-label`);T(pe,{x:Te+6,y:_-6,"text-anchor":"start"}),f(pe,a.label)}L.push({text:Z(a,Pe,z,y.dual)});continue}if(a.orient==="vertical"||a.x!==void 0){const Pe=a.x!==void 0?a.x:a.value,Te=M.kind==="band"?R(M.centre(Pe)):R(M.of(c(M,Pe)??NaN));if(Number.isNaN(Te)){d(a,$,"its x value could not be placed on the x scale");continue}const _=A==="target"?`${P}__annotation-target`:`${P}__annotation-line`;if(T(U.next("path",_),{d:q(["M",Te,R(D.top),"L",Te,R(D.bottom)]),stroke:a.colour||"currentColor",fill:"none"}),a.label){const pe=U.next("text",`${P}__annotation-label`);T(pe,{x:Te+4,y:R(D.top+10),"text-anchor":"start"}),f(pe,a.label)}L.push({text:a.label?`${a.label} — at ${r(Pe,z)}`:""});continue}const ke=x(a,re,$);if(ke===null){d(a,$,"its value could not be resolved (a number, or a compute that finds values)");continue}const ge=R(te.of(ke)),ve=A==="target"?`${P}__annotation-target`:`${P}__annotation-line`;if(T(U.next("path",ve),{d:y.horizontal?q(["M",ge,R(D.top),"L",ge,R(D.bottom)]):q(["M",R(D.left),ge,"L",R(D.right),ge]),stroke:a.colour||"currentColor",fill:"none"}),a.label){const Pe=U.next("text",`${P}__annotation-label`);T(Pe,y.horizontal?{x:ge+4,y:R(D.top+10),"text-anchor":"start"}:{x:R(D.right-4),y:ge-4,"text-anchor":"end"}),f(Pe,a.label)}L.push({text:Z(a,ke,z,y.dual)})}return U.finish(),L.filter(a=>a.text)}}),Ze("packages/modules/charts/curve.js",function(t,ue){"use strict";Object.defineProperty(t,"CURVES",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(t,"STEP_MODES",{enumerable:!0,get:function(){return se}}),Object.defineProperty(t,"resolveCurve",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(t,"curveCommands",{enumerable:!0,get:function(){return n}});const Y=ue("packages/modules/charts/svg.js").round,fe=Object.freeze(["linear","monotone","catmullRom","step"]),se=Object.freeze(["after","before","middle"]);function ne(f,S){let g=f;if(g&&typeof g=="object"&&!Array.isArray(g)&&typeof g.type!="string"&&(g=S!=null&&Object.prototype.hasOwnProperty.call(g,S)?g[S]:void 0),g==null||g===!0||g===!1)return null;if(typeof g=="string")return g==="linear"?null:fe.includes(g)?{type:g,tension:1,mode:"after"}:null;if(typeof g=="object"){const P=typeof g.type=="string"&&fe.includes(g.type)?g.type:"linear";if(P==="linear")return null;const N=Number.isFinite(g.tension)?Math.max(0,Math.min(1,Number(g.tension))):1,p=se.includes(g.mode)?g.mode:"after";return{type:P,tension:N,mode:p}}return null}function n(f,S){return f.length?!S||S.type==="linear"?V(f):S.type==="step"?T(f,S.mode):S.type==="monotone"?q(f):S.type==="catmullRom"?R(f,S.tension):V(f):[]}function V(f){const S=["M",Y(f[0].x),Y(f[0].y)];for(let g=1;g<f.length;g++)S.push("L",Y(f[g].x),Y(f[g].y));return S}function T(f,S){const g=["M",Y(f[0].x),Y(f[0].y)];for(let P=1;P<f.length;P++){const N=f[P-1].x,p=f[P-1].y,u=f[P].x,m=f[P].y;if(S==="before")g.push("L",Y(N),Y(m),"L",Y(u),Y(m));else if(S==="middle"){const c=Y((N+u)/2);g.push("L",c,Y(p),"L",c,Y(m),"L",Y(u),Y(m))}else g.push("L",Y(u),Y(p),"L",Y(u),Y(m))}return g}function q(f){const S=f.length;if(S<2)return["M",Y(f[0].x),Y(f[0].y)];if(S===2)return["M",Y(f[0].x),Y(f[0].y),"L",Y(f[1].x),Y(f[1].y)];const g=[];for(let p=0;p<S-1;p++){const u=f[p+1].x-f[p].x,m=f[p+1].y-f[p].y;g[p]=u===0?0:m/u}const P=new Array(S);P[0]=g[0],P[S-1]=g[S-2];for(let p=1;p<S-1;p++)P[p]=g[p-1]*g[p]<=0?0:(g[p-1]+g[p])/2;for(let p=0;p<S-1;p++)g[p]===0&&(P[p]=0,P[p+1]=0);for(let p=0;p<10;p++){let u=!1;for(let m=0;m<S-1;m++){if(g[m]===0)continue;const c=P[m]/g[m],w=P[m+1]/g[m],d=c*c+w*w;if(d>9){const r=3/Math.sqrt(d);P[m]=r*c*g[m],P[m+1]=r*w*g[m],u=!0}}if(!u)break}const N=["M",Y(f[0].x),Y(f[0].y)];for(let p=0;p<S-1;p++){const u=f[p].x,m=f[p].y,c=f[p+1].x,w=f[p+1].y,d=c-u,r=u+d/3,v=m+P[p]*d/3,l=c-d/3,x=w-P[p+1]*d/3;N.push("C",Y(r),Y(v),Y(l),Y(x),Y(c),Y(w))}return N}function R(f,S){const g=f.length;if(g<2)return["M",Y(f[0].x),Y(f[0].y)];const P=Number.isFinite(S)?Math.max(0,Math.min(1,S)):1,N=["M",Y(f[0].x),Y(f[0].y)];for(let p=0;p<g-1;p++){const u=f[p-1]||f[p],m=f[p],c=f[p+1],w=f[p+2]||f[p+1],d=m.x+(c.x-u.x)/6*P,r=m.y+(c.y-u.y)/6*P,v=c.x-(w.x-m.x)/6*P,l=c.y-(w.y-m.y)/6*P;N.push("C",Y(d),Y(r),Y(v),Y(l),Y(c.x),Y(c.y))}return N}}),Ze("packages/modules/charts/combo.js",function(t,ue){"use strict";Object.defineProperty(t,"toPareto",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(t,"drawCombo",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(t,"drawRightAxis",{enumerable:!0,get:function(){return ye}});const Le=ue("packages/modules/charts/axis.js"),Y=Le.drawAxisLines,fe=Le.drawAxisTitle,se=Le.drawCategoryAxis,ne=Le.drawContinuousAxis,n=Le.drawMeasureAxis,V=Le.heldInside,T=Le.turnedFirstLabelBox,q=Le.labelGap,R=Le.overhangFor,f=Le.pinXDomain,S=Le.setPlotClip,g=Le.tickLabeller,P=Le.tickValues,N=ue("packages/modules/charts/frame.js"),p=N.Pool,u=N.shouldRotate,c=ue("packages/modules/charts/format.js").formatters,w=ue("packages/modules/charts/scale.js"),d=w.bandScale,r=w.extent,v=w.isNumber,l=w.linearScale,x=w.measureDomain,W=w.timeScale,Z=w.toNumber,le=w.toTime,oe=ue("packages/modules/charts/stack.js"),y=oe.measureValues,C=oe.stacker,D=ue("packages/modules/charts/svg.js"),M=D.attrs,J=D.path,F=D.round,z=ue("packages/modules/charts/styles.js").NS,L=ue("packages/modules/charts/scheme.js").resolveScheme,i=ue("packages/modules/charts/labels.js").drawDataLabels,A=ue("packages/modules/charts/annotations.js").drawAnnotations,$=ue("packages/modules/charts/curve.js"),te=$.curveCommands,ke=$.resolveCurve;function ge(o){return{left:o.filter(H=>H.axis!=="right"),right:o.filter(H=>H.axis==="right")}}function ve(o,H){const s=o&&o.seriesStyle&&o.seriesStyle[H];if(s)return{width:s.width!=null?String(s.width):null,dash:Array.isArray(s.dash)&&s.dash.length?s.dash.join(" "):null,opacity:null,emphasized:!1};const h=o&&Array.isArray(o.emphasis)?o.emphasis:null;if(!h||!h.length)return{width:null,dash:null,opacity:null,emphasized:!1};const O=h.includes(H);return{width:O?"var(--lattice-chart-emphasis-width, 3.5)":null,dash:null,opacity:O?null:"var(--lattice-chart-muted-opacity, .35)",emphasized:O}}function Pe(o,H,s,h,O=null){const I=[];let K=[];const ee=()=>{K.length===1?I.push("M",K[0].x,K[0].y):K.length>1&&I.push(...te(K,O)),K=[]};for(const E of H.points){if(E.px===void 0){ee();continue}K.push({x:E.px,y:E.py})}ee(),M(o.next("path",`${z}__line ${z}__mark`),{d:I.length?J(I):"",stroke:s,"data-series":H.index,"stroke-width":h.width,"stroke-dasharray":h.dash,opacity:h.opacity});for(const E of H.points)E.px!==void 0&&M(o.next("circle",`${z}__point ${z}__mark`),{cx:E.px,cy:E.py,r:3,fill:s})}function Te(o,H){return H?{tick:s=>`${o.tick(s)}%`,value:s=>`${o.value(s)}%`}:o}function _(o,H,s,h,O){const I=o.filter(E=>(E.mark||"bar")==="bar"),K=o.filter(E=>(E.mark||"bar")!=="bar"),ee=h?y(I,!0,!0):s?[...y(I,!0,!1),...K.length?y(K,!1,!1):[]]:y(o,!1,!1);return x(ee,{zero:H,min:O&&O.min,max:O&&O.max})}function pe(o){const H=o.series[0];if(!H)return o;const s=H.points.map((K,ee)=>({point:K,label:o.labels[ee],category:o.categories[ee]})).filter(K=>v(K.point.y)).sort((K,ee)=>ee.point.y-K.point.y),h=s.reduce((K,ee)=>K+ee.point.y,0);let O=0;const I=s.map(K=>(O+=K.point.y,h>0?O/h*100:0));return{...o,categories:s.map(K=>K.category),labels:s.map(K=>K.label),series:[{...H,index:0,mark:"bar",axis:"left",points:s.map(K=>K.point)},{key:"cumulative",label:o.cumulativeLabel||"%",index:1,mark:"line",axis:"right",points:s.map((K,ee)=>({x:K.category,xKey:K.point.xKey,label:K.label,y:I[ee],rows:K.point.rows,rowKey:K.point.rowKey}))}]}}function me(o,H,s){const h=[H.left,H.right];if(o.kind!=="time"&&o.kind!=="linear")return d(o.categories,h,.2);const O=o.kind==="time"?o.categories.map(le):o.categories.map(Z);if(o.kind==="time"){const ee=r(O);if(ee&&ee.min===ee.max)return W(f({min:ee.min-3e4,max:ee.max+3e4},o,s),h)}const I=o.xDomain||x(O,{zero:!1,nice:o.kind!=="time"}),K=o.xDomain?I:f(I,o,s);return o.kind==="time"?W(K,h):l(K,h)}function ie(o,H){const s=[...new Set(o.filter(ee=>Number.isFinite(ee)))].sort((ee,E)=>ee-E);if(s.length<2){const[ee,E]=H.range;return Math.max(4,(E-ee)/10)}const h=[];for(let ee=1;ee<s.length;ee++)h.push(s[ee]-s[ee-1]);h.sort((ee,E)=>ee-E);const O=Math.floor(h.length/2),I=h.length%2?h[O]:(h[O-1]+h[O])/2,K=Math.abs(H.of(s[0]+I)-H.of(s[0]));return Math.max(1,K*.8)}function Q(o){const H=o.scheme||L(),s=o.axis||{x:{},y:{},y2:{}},{plot:h}=o,O=o.pareto?pe(o.bound):o.bound,I=O.series.filter(Qe=>!o.hidden.has(Qe.key)),K=ge(I),ee=Qe=>(Qe.mark||"bar")==="bar",E=K.left.some(ee),G=K.left.filter(ee),Me=o.stack==="percent"&&G.length>1&&!K.right.length,k=(Me||!!o.stack)&&G.length>1&&!K.right.length,j=O.yDomain||_(K.left,E,k,Me,s.y),X=l(j,[h.bottom,h.top]),ae=K.right.length?o.pareto?{min:0,max:100}:_(K.right,K.right.some(ee),!1,!1,s.y2):null,be=ae?l(ae,[h.bottom,h.top]):null,Se=me(O,h,s.x),Ae=Se.kind!=="band",ze=Ae?O.categories.map(Qe=>O.kind==="time"?le(Qe):Z(Qe)):null,Be=Ae&&I.some(Qe=>(Qe.mark||"bar")==="bar")?ie(ze,Se)/2:0,Ue=!Ae&&(s.x.rotate===void 0||s.x.rotate==="auto"?u(O.labels,Se.step,o.fontSize):!!s.x.rotate)&&T({group:o.groups.overlay,plot:h,scale:Se,labels:O.labels,fontSize:o.fontSize,config:s.x}),We=s.y.position==="right"?"right":"left";n({gridGroup:o.groups.grid,axisGroup:o.groups.axis,plot:h,scale:X,format:Te(c(o.grid,{kind:"linear",step:(j.max-j.min)/5}),Me),config:s.y,grid:o.grid,size:o.fontSize,side:We,overhang:Be,dropBottom:Ue});const st=O.dimension&&O.dimension.col?o.grid.columns.get(O.dimension.col):void 0;Ae?ne({group:o.groups.overlay,plot:h,scale:Se,format:c(o.grid,{kind:O.kind,span:Se.domain.max-Se.domain.min,step:(Se.domain.max-Se.domain.min)/5},st),config:s.x,grid:o.grid,column:st,size:o.fontSize}):se({group:o.groups.overlay,plot:h,scale:Se,labels:O.labels,fontSize:o.fontSize,rotated:u(O.labels,Se.step,o.fontSize),config:s.x}),Y({group:o.groups.rules,plot:h,side:We});const tt=o.typography&&o.typography.axisTitle||o.fontSize;if(fe({group:o.groups.axis,plot:h,text:s.y.title,side:We,size:tt}),fe({group:o.groups.axis,plot:h,text:s.x.title,side:"bottom",size:tt}),be){ye({group:o.groups.axis,plot:h,scale:be,colour:H.series(K.right[0].index,K.right[0].label),format:c(o.grid,{kind:"linear",step:(ae.max-ae.min)/5}),config:s.y2,grid:o.grid,suffix:o.pareto?"%":"",side:We==="right"?"left":"right",overhang:Be});const Qe=s.y2.title||(K.right.length===1?K.right[0].label:"");fe({group:o.groups.axis,plot:h,text:Qe,side:We==="right"?"left":"right",size:tt})}S(o.groups,h,R(o.type));const wt=new p(o.groups.marks),Mt=I.filter(Qe=>(Qe.mark||"bar")==="bar"),Nt=Ae?ie(ze,Se):Se.bandwidth,pt=k?Nt:Mt.length?Nt/Mt.length:Nt,gt=Me?O.categories.map((Qe,It)=>G.reduce((At,jt)=>{const Wt=jt.points[It]?jt.points[It].y:null;return v(Wt)?At+Math.abs(Wt):At},0)):null,mt=k?C(O.categories.length,gt):null;let Ct=0;const kt=[];for(const Qe of I){const It=Qe.mark||"bar",At=Qe.axis==="right"&&be?be:X,jt=H.series(Qe.index,Qe.label);if(It==="bar"){const Ft=k?0:Ct*pt;Ct++;const Vt=At.of(Math.max(At.domain.min,0));for(let Gt=0;Gt<Qe.points.length;Gt++){const Et=Qe.points[Gt];if(!v(Et.y))continue;let _t;if(Ae){const Qt=O.kind==="time"?le(Et.x):Z(Et.x);_t=Qt===null?NaN:Se.of(Qt)-Nt/2}else _t=Se.of(Et.x);if(Number.isNaN(_t))continue;const Ht=mt?mt.take(Gt,Et.y):null,Kt=At.of(Ht?Ht[1]:Et.y),Xt=Ht?At.of(Ht[0]):Vt;M(wt.next("rect",`${z}__bar ${z}__mark`),{x:F(_t+Ft),y:F(Math.min(Kt,Xt)),width:F(Math.max(0,pt)),height:F(Math.max(1,Math.abs(Xt-Kt))),fill:jt,"data-series":Qe.index,"data-point":Gt}),Et.px=F(_t+Ft+pt/2),Et.py=F(Math.min(Kt,Xt))}continue}for(const Ft of Qe.points){if(!v(Ft.y)){Ft.px=void 0;continue}let Vt;if(Ae){const Et=O.kind==="time"?le(Ft.x):Z(Ft.x);Vt=Et===null?NaN:F(Se.of(Et))}else Vt=F(Se.centre(Ft.x));if(Number.isNaN(Vt)){Ft.px=void 0;continue}const Gt=F(At.of(Ft.y));Ft.px=Vt,Ft.py=Gt}const Wt=ve(o,Qe.label),Bt=ke(o.curve,Qe.label);Wt.emphasized?kt.push({series:Qe,colour:jt,style:Wt,curve:Bt}):Pe(wt,Qe,jt,Wt,Bt)}for(const Qe of kt)Pe(wt,Qe.series,Qe.colour,Qe.style,Qe.curve);wt.finish(),o.labels&&o.labels.show&&i({group:o.groups.labels,series:I,plot:h,options:o.labels,grid:o.grid,size:o.typography&&o.typography.small||o.fontSize});let dt=null;return o.annotations&&o.annotations.length&&(dt=A({group:o.groups.overlay,plot:h,xScale:Se,yScale:X,rightScale:be,series:I,annotations:o.annotations,dual:!!be,format:c(o.grid,{kind:"linear",step:(j.max-j.min)/5}).tick})),{xScale:Se,yScale:X,rightScale:be,dual:!!be,series:I,bound:O,annotations:dt,percent:Me,percentTotals:gt}}function ye(o){const{group:H,plot:s,scale:h,format:O}=o,I=o.config||{},K=o.side==="left"?"left":"right",ee=K==="right"?s.right:s.left,E=g(I,O,o.grid),G=new p(H,H.childNodes.length),Me=q(o.overhang);M(G.next("line",`${z}__axis-right`),{x1:F(ee),x2:F(ee),y1:F(s.top),y2:F(s.bottom),stroke:o.colour});for(const k of P(h,I)){const j=F(h.of(k)),X=G.next("text",`${z}__tick`);M(X,{x:F(K==="right"?s.right+Me:s.left-Me),y:V(j,s,11),"text-anchor":K==="right"?"start":"end","dominant-baseline":"middle",fill:o.colour}),X.textContent=`${E(k)}${o.suffix||""}`}G.finish()}}),Ze("packages/modules/charts/quantile.js",function(t,ue){"use strict";Object.defineProperty(t,"normalQuantile",{enumerable:!0,get:function(){return T}}),Object.defineProperty(t,"studentTQuantile",{enumerable:!0,get:function(){return R}});const Le=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),Y=3e-12,fe=1e-300;function se(f){if(f<.5)return Math.log(Math.PI/Math.sin(Math.PI*f))-se(1-f);const S=f-1;let g=.9999999999998099;const P=S+7.5;for(let N=0;N<Le.length;N++)g+=Le[N]/(S+N+1);return .5*Math.log(2*Math.PI)+(S+.5)*Math.log(P)-P+Math.log(g)}function ne(f,S,g){const P=f+S,N=f+1,p=f-1;let u=1,m=1-P*g/N;Math.abs(m)<fe&&(m=fe),m=1/m;let c=m;for(let w=1;w<=300;w++){const d=2*w;let r=w*(S-w)*g/((p+d)*(f+d));m=1+r*m,Math.abs(m)<fe&&(m=fe),u=1+r/u,Math.abs(u)<fe&&(u=fe),m=1/m,c*=m*u,r=-(f+w)*(P+w)*g/((f+d)*(N+d)),m=1+r*m,Math.abs(m)<fe&&(m=fe),u=1+r/u,Math.abs(u)<fe&&(u=fe),m=1/m;const v=m*u;if(c*=v,Math.abs(v-1)<Y)break}return c}function n(f,S,g){if(!(f>0)||!(S>0)||!Number.isFinite(g))return Number.NaN;if(g<=0)return 0;if(g>=1)return 1;const P=Math.exp(se(f+S)-se(f)-se(S)+f*Math.log(g)+S*Math.log(1-g));return g<(f+1)/(f+S+2)?P*ne(f,S,g)/f:1-P*ne(S,f,1-g)/S}function V(f){const S=Math.abs(f),g=2/(2+S),P=4*g-2,N=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let p=0,u=0,m;for(let w=N.length-1;w>0;w--)m=u,u=P*u-p+N[w],p=m;const c=g*Math.exp(-S*S+.5*(N[0]+P*u)-p);return f>=0?c:2-c}function T(f){if(!(f>0)||!(f<1))return f===0?-1/0:f===1?1/0:Number.NaN;const S=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],g=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],P=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],N=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],p=.02425;let u,m,c;f<p?(u=Math.sqrt(-2*Math.log(f)),c=(((((P[0]*u+P[1])*u+P[2])*u+P[3])*u+P[4])*u+P[5])/((((N[0]*u+N[1])*u+N[2])*u+N[3])*u+1)):f<=1-p?(u=f-.5,m=u*u,c=(((((S[0]*m+S[1])*m+S[2])*m+S[3])*m+S[4])*m+S[5])*u/(((((g[0]*m+g[1])*m+g[2])*m+g[3])*m+g[4])*m+1)):(u=Math.sqrt(-2*Math.log(1-f)),c=-(((((P[0]*u+P[1])*u+P[2])*u+P[3])*u+P[4])*u+P[5])/((((N[0]*u+N[1])*u+N[2])*u+N[3])*u+1));const d=(.5*V(-c/Math.SQRT2)-f)*Math.sqrt(2*Math.PI)*Math.exp(c*c/2);return c-d/(1+c*d/2)}function q(f,S){if(!(S>0)||!Number.isFinite(f))return Number.NaN;const g=.5*n(S/2,.5,S/(S+f*f));return f>0?1-g:g}function R(f,S){if(!(f>0)||!(f<1)||!(S>0))return Number.NaN;if(S>1e7)return T(f);let g=-1e4,P=1e4,N=T(f);const p=se(S/2)+se(.5)-se((S+1)/2);for(let u=0;u<60;u++){const m=q(N,S);m<f?g=N:P=N;const c=Math.exp(-((S+1)/2)*Math.log(1+N*N/S)-p)/Math.sqrt(S),w=c>0?(m-f)/c:0;if(Math.abs(w)<1e-12)break;const d=N-w;if(N=d>g&&d<P&&Number.isFinite(d)?d:(g+P)/2,P-g<1e-12)break}return N}}),Ze("packages/modules/charts/trendline.js",function(t,ue){"use strict";Object.defineProperty(t,"normaliseTrends",{enumerable:!0,get:function(){return x}}),Object.defineProperty(t,"linearTrend",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(t,"movingAverageTrend",{enumerable:!0,get:function(){return y}}),Object.defineProperty(t,"exponentialTrend",{enumerable:!0,get:function(){return J}}),Object.defineProperty(t,"computeTrend",{enumerable:!0,get:function(){return F}}),Object.defineProperty(t,"trendText",{enumerable:!0,get:function(){return re}}),Object.defineProperty(t,"drawTrendlines",{enumerable:!0,get:function(){return z}});const Y=ue("packages/modules/charts/frame.js").Pool,fe=ue("packages/modules/charts/svg.js"),se=fe.attrs,ne=fe.path,n=fe.ribbonPath,V=fe.round,T=fe.setText,q=fe.SVG_NS,f=ue("packages/modules/charts/typography.js").applySize,g=ue("packages/modules/charts/styles.js").NS,P=ue("packages/modules/charts/scale.js"),N=P.toNumber,p=P.toTime,m=ue("packages/modules/charts/quantile.js").studentTQuantile,w=ue("packages/modules/charts/format.js").r2Digits,d={linear:new Set(["linear","lr","ols","regression","least-squares"]),movingAverage:new Set(["movingaverage","moving-average","ma","sma","rolling"]),exponential:new Set(["exponential","exp","ewma","ses","holt","smoothing"])},r=1e-4,v=1-1e-4;function l(U){const L=String(U||"linear").toLowerCase();return d.linear.has(L)?"linear":d.movingAverage.has(L)?"movingAverage":d.exponential.has(L)?"exponential":null}function x(U){if(!U)return[];const L=Array.isArray(U)?U:[U],e=[];for(const i of L){if(i===!0){e.push({method:"linear"});continue}if(typeof i=="string"){const a=l(i);a&&e.push({method:a});continue}if(i&&typeof i=="object"){const a=l(i.method);a&&e.push({...i,method:a})}}return e}function W(U,L){if(U.kind==="band")return U.centre(L);const e=U.kind==="time"?p(L):N(L);return e===null?NaN:U.of(e)}function Z(U){const L=[];for(const e of U.points){const i=Number(e.y);L.push({value:Number.isFinite(i)?i:null,rawX:e.x})}return L}function le(U,L){const e=[];for(const i of U.points){const a=L.kind==="time"?p(i.x):N(i.x),A=Number(i.y);a===null||!Number.isFinite(a)||!Number.isFinite(A)||e.push({x:a,y:A})}return e.sort((i,a)=>i.x-a.x),e}function oe(U,L,e={}){const i=U.length;if(i<2)return null;let a=0,A=0;for(const o of U)a+=o.x,A+=o.y;a/=i,A/=i;let $=0,te=0,ke=0;for(const o of U){const H=o.x-a,s=o.y-A;$+=H*H,te+=H*s,ke+=s*s}if($===0)return null;const ge=te/$,ve=A-ge*a,Pe=ke===0?1:Math.max(0,Math.min(1,te*te/($*ke))),Te=U[0].x,_=U[i-1].x,pe=o=>({x:o,y:ve+ge*o}),me=[pe(Te),pe(_)],ie=[];let Q=null;const ye=Math.max(0,Math.floor(Number(L)||0));if(ye>0&&_>Te){const o=(_-Te)/(i-1);if(o>0&&(ie.push(pe(_),pe(_+ye*o)),i>2)){const H=Number.isFinite(e.confidence)&&e.confidence>0&&e.confidence<1?Number(e.confidence):.95,s=1-(1-H)/2,h=Math.max(0,ke-ge*te),O=Math.sqrt(h/(i-2)),I=m(s,i-2),K=[];for(let ee=0;ee<=ye;ee++){const E=_+ee*o,G=ve+ge*E,Me=1/i+(E-a)**2/$,k=O*Math.sqrt(1+Me),j=O*Math.sqrt(Me);K.push({x:E,mean:G,lower:G-I*k,upper:G+I*k,lowerMean:G-I*j,upperMean:G+I*j})}Q={confidence:H,points:K}}}return{fit:me,forecast:ie,band:Q,stats:{method:"linear",slope:ge,intercept:ve,r2:Pe,n:i,forecast:ie.length?ye:0,confidence:Q?Q.confidence:null}}}function y(U,L){const e=Math.max(1,Math.floor(Number(L)||3)),i=[];let a=0;const A=[];for(const $ of U)Number.isFinite($.value)&&(i.push($.value),a+=$.value,i.length>e&&(a-=i.shift())),i.length&&A.push({x:$.rawX,y:a/i.length});return A.length<2?null:{fit:A,stats:{method:"movingAverage",window:e}}}function C(U,L){const e=U.length,i=new Array(e).fill(null);let a=null,A=0;for(let $=0;$<e;$++){const te=U[$];if(!Number.isFinite(te)){a!==null&&(i[$]=a);continue}if(a===null){a=te,i[$]=te;continue}A+=(te-a)**2,a=L*te+(1-L)*a,i[$]=a}return{smoothed:i,sse:A}}function D(U,L,e){const i=U.length,a=new Array(i).fill(null);let A=null,$=null,te=0;for(let ke=0;ke<i;ke++){const ge=U[ke];if(!Number.isFinite(ge)){A!==null&&(A+=$,a[ke]=A);continue}if(A===null){A=ge,a[ke]=ge;continue}if($===null){$=ge-A;const Te=A+$;te+=(ge-Te)**2;const _=A;A=L*ge+(1-L)*(_+$),$=e*(A-_)+(1-e)*$,a[ke]=A;continue}const ve=A+$;te+=(ge-ve)**2;const Pe=A;A=L*ge+(1-L)*(Pe+$),$=e*(A-Pe)+(1-e)*$,a[ke]=A}return{smoothed:a,sse:te}}function M(U,L,e,i=80){const a=(Math.sqrt(5)-1)/2;let A=L,$=e,te=$-a*($-A),ke=A+a*($-A),ge=U(te),ve=U(ke);for(let Pe=0;Pe<i;Pe++)ge<ve?($=ke,ke=te,ve=ge,te=$-a*($-A),ge=U(te)):(A=te,te=ke,ge=ve,ke=A+a*($-A),ve=U(ke));return(A+$)/2}function J(U,L){const e=String(L.kind||L.model||"").toLowerCase()==="holt",i=U.map(ve=>Number.isFinite(ve.value)?ve.value:null);if(i.filter(ve=>ve!==null).length<(e?2:1))return null;const A=ve=>Math.min(v,Math.max(r,ve));let $=Number.isFinite(L.alpha)?A(Number(L.alpha)):null,te=e&&Number.isFinite(L.beta)?A(Number(L.beta)):null;if(e){if($===null||te===null){let ve=$===null?.5:$,Pe=te===null?.5:te;for(let Te=0;Te<6;Te++)$===null&&(ve=M(_=>D(i,_,Pe).sse,r,v)),te===null&&(Pe=M(_=>D(i,ve,_).sse,r,v));$=$===null?ve:$,te=te===null?Pe:te}}else $===null&&($=M(ve=>C(i,ve).sse,r,v));const ke=e?D(i,$,te):C(i,$),ge=[];for(let ve=0;ve<U.length;ve++){const Pe=ke.smoothed[ve];Pe===null||!Number.isFinite(Pe)||ge.push({x:U[ve].rawX,y:Pe})}return ge.length<2?null:{fit:ge,stats:{method:"exponential",kind:e?"holt":"ses",alpha:$,beta:e?te:null}}}function F(U,L,e){if(L.method==="linear"){const a=le(U,e);return oe(a,L.forecast,{confidence:L.confidence})}const i=Z(U);return L.method==="movingAverage"?y(i,L.window||L.period):J(i,L)}function re(U,L,e,i,a,A){const $=L?` for ${L}`:"";if(U.method==="linear"){const ve=Number.isFinite(U.r2)?`, R² ${U.r2.toFixed(2)}`:"";let Pe=`Trend (linear)${$}: slope ${e(U.slope)}${ve}`;if(U.forecast>0&&i&&i.length){const Te=i[i.length-1];if(Pe+=`; forecast ${U.forecast} step${U.forecast===1?"":"s"} ahead to ${e(Te.y)}`,a&&a.points.length){const _=a.points[a.points.length-1],pe=A==="confidence"||A==="mean",me=pe?_.lowerMean:_.lower,ie=pe?_.upperMean:_.upper,Q=pe?"confidence":"prediction",ye=Math.round(a.confidence*100);Pe+=`; ${ye}% ${Q} band ${e(me)} to ${e(ie)} at the horizon`}}return Pe}if(U.method==="movingAverage")return`Trend (moving average, window ${U.window})${$}`;const te=U.kind==="holt"?"Holt":"single",ke=Number.isFinite(U.alpha)?`, α ${U.alpha.toFixed(2)}`:"",ge=Number.isFinite(U.beta)?`, β ${U.beta.toFixed(2)}`:"";return`Trend (exponential, ${te})${$}${ke}${ge}`}function z(U){const L=x(U.trend);if(!L.length)return[];const e=U.group.ownerDocument;let i=null;for(const $ of U.group.childNodes||[])if($&&String($.getAttribute&&$.getAttribute("class"))===`${g}__trends`){i=$;break}i||(i=e.createElementNS(q,"g"),i.setAttribute("class",`${g}__trends`),U.group.appendChild(i)),U.clip?i.setAttribute("clip-path",`url(#${U.clip})`):i.removeAttribute("clip-path");const a=new Y(i),A=[];for(const $ of L)for(const te of U.series){const ke=te.axis==="right"&&U.rightScale?U.rightScale:U.yScale,ge=F(te,$,U.xScale);if(!ge)continue;const ve=U.scheme.series(te.index),Pe=[];for(const pe of ge.fit){const me=W(U.xScale,pe.x),ie=ke.of(pe.y);!Number.isFinite(me)||!Number.isFinite(ie)||Pe.push(Pe.length?"L":"M",V(me),V(ie))}if(Pe.length<4)continue;if(se(a.next("path",`${g}__trend`),{d:ne(Pe),fill:"none",stroke:ve,"data-series":te.index}),$.band!==!1&&ge.band&&ge.band.points.length>=2){const pe=$.band==="confidence"||$.band==="mean",me=[];for(const Q of ge.band.points){const ye=W(U.xScale,Q.x),o=pe?Q.lowerMean:Q.lower,H=pe?Q.upperMean:Q.upper,s=ke.of(o),h=ke.of(H);!Number.isFinite(ye)||!Number.isFinite(s)||!Number.isFinite(h)||me.push({x:V(ye),lower:V(s),upper:V(h)})}const ie=n(me);ie&&se(a.next("path",`${g}__trend-band`),{d:ie,fill:ve,"fill-opacity":.15,stroke:"none","data-series":te.index})}const _=ge.forecast||[];if(_.length>=2){const pe=[];for(const me of _){const ie=W(U.xScale,me.x),Q=ke.of(me.y);!Number.isFinite(ie)||!Number.isFinite(Q)||pe.push(pe.length?"L":"M",V(ie),V(Q))}pe.length>=4&&se(a.next("path",`${g}__trend-forecast`),{d:ne(pe),fill:"none",stroke:ve,"data-series":te.index})}if($.label!==!1&&ge.stats.method==="linear"&&Number.isFinite(ge.stats.r2)){const pe=ge.fit[ge.fit.length-1],me=a.next("text",`${g}__trend-label`);f(me,U.size),se(me,{x:V(W(U.xScale,pe.x)),y:V(ke.of(pe.y))-4,"text-anchor":"end",fill:ve}),T(me,U.grid.messages.t("chart.r2",{value:w(U.grid,ge.stats.r2)}))}A.push({text:re(ge.stats,te.label,U.format,_,$.band===!1?null:ge.band,$.band)})}return a.finish(),A.filter($=>$.text)}}),Ze("packages/modules/charts/rulecolour.js",function(t,ue){"use strict";Object.defineProperty(t,"colourOf",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(t,"ruleColour",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(t,"ruleLegend",{enumerable:!0,get:function(){return se}});const Le="*";function Y(ne){if(!ne||typeof ne!="object")return null;for(const n of["background","backgroundColor","color"]){const V=ne[n];if(typeof V=="string"&&V.trim())return V.trim()}return null}function fe(ne){const{grid:n,col:V,value:T}=ne;if(!n||!V||!n.formatting||typeof n.formatting.styleFor!="function")return null;try{return Y(n.formatting.styleFor(V,T))}catch{return null}}function se(ne){const{grid:n,col:V}=ne,T=new Set([...ne.colours||[]].filter(Boolean));if(!T.size||!n||!n.formatting||typeof n.formatting.list!="function")return[];let q;try{q=[...n.formatting.list(Le)||[],...V?n.formatting.list(V)||[]:[]]}catch{return[]}const R=[],f=new Set;for(const S of q){if(!S||S.enabled===!1)continue;const g=Y(S.style);!g||!T.has(g)||f.has(g)||(f.add(g),R.push({key:S.id||`rule:${R.length}`,label:S.label||S.id||g,colour:g,index:R.length}))}return R}}),Ze("packages/modules/charts/glyph.js",function(t,ue){"use strict";Object.defineProperty(t,"glyphFor",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(t,"glyphTransform",{enumerable:!0,get:function(){return n}});const Y=ue("packages/core/src/internal/warn.js").warnOnce,se=ue("packages/modules/charts/svg.js").round;function ne(V,T,q="node"){if(!T)return null;const R=q==="marker",f=R?"a chart image marker":"a network node",S=V&&V.icons;if(!S||typeof S.get!="function")return Y(`chart:icons:${T}`,`${f.charAt(0).toUpperCase()}${f.slice(1)} asked for the icon '${T}', but this grid publishes no icon registry — a headless grid has no sprites. The ${R?"point":"node"} drew as ${R?"its default marker":"a plain disc"}.`),null;const g=S.get(T);return g||(Y(`chart:icon:${T}`,`Unknown icon '${T}' on ${f}; ${R?"kept the default marker":"drew a plain disc"} instead. Register it with registerIcon or config.icons, or name a built-in.`),null)}function n(V,T){const q=String(V.viewBox||"0 0 16 16").trim().split(/[\s,]+/).map(Number),[R,f,S,g]=q.length===4&&q.every(Number.isFinite)?q:[0,0,16,16],P=Math.max(S||16,g||16),N=T.size/P,p=T.x-S*N/2,u=T.y-g*N/2;return`translate(${se(p-R*N)} ${se(u-f*N)}) scale(${se(N)})`}}),Ze("packages/modules/charts/markers.js",function(t,ue){"use strict";Object.defineProperty(t,"MARKER_SIZE",{enumerable:!0,get:function(){return T}}),Object.defineProperty(t,"clearMarkerImages",{enumerable:!0,get:function(){return g}}),Object.defineProperty(t,"resolveMarker",{enumerable:!0,get:function(){return P}}),Object.defineProperty(t,"safeImageUrl",{enumerable:!0,get:function(){return N}}),Object.defineProperty(t,"imageOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(t,"imageState",{enumerable:!0,get:function(){return u}}),Object.defineProperty(t,"markerFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(t,"placeMarker",{enumerable:!0,get:function(){return c}}),Object.defineProperty(t,"markerBoxHit",{enumerable:!0,get:function(){return w}});const Y=ue("packages/core/src/internal/warn.js").warnOnce,fe=ue("packages/modules/charts/glyph.js"),se=fe.glyphFor,ne=fe.glyphTransform,V=ue("packages/modules/charts/styles.js").NS,T=16,q=[6,64],R=/^data:image\/(png|jpe?g|gif|webp|avif|bmp|svg\+xml)[;,]/i,f=/^(https?:|blob:|data:|javascript:|vbscript:|file:|\/|\.\.?\/)|[/.]/i,S=new Map;function g(){S.clear()}function P(d){if(!d||typeof d!="object"||Array.isArray(d))return null;const r=d.image;if(r==null||r==="")return Y("chart:marker:no-image",'chart "marker" needs an "image": an icon name, a URL, { col } or a function. No markers were drawn from it.'),null;const v=Number(d.size);return{image:r,size:Number.isFinite(v)?Math.min(q[1],Math.max(q[0],v)):T,explicitSize:Number.isFinite(v)}}function N(d){const r=String(d).trim(),v=/^([a-z][a-z0-9+.-]*):/i.exec(r);if(v){const l=v[1].toLowerCase();return l==="data"?R.test(r)?r:null:l==="http"||l==="https"||l==="blob"?r:null}return/^[^/]*:/.test(r)?null:r}function p(d,r,v){let l=d.image;if(typeof l=="function")try{l=l(r)}catch{l=null}else l&&typeof l=="object"&&typeof l.col=="string"&&(l=v&&v.rows&&r&&r.rowKey!==void 0&&r.rowKey!==null?v.rows.value(r.rowKey,l.col):null);return typeof l=="string"&&l.trim()?l.trim():null}function u(d,r,v){let l=S.get(d);if(l)return l.state==="loading"&&v&&l.waiting.add(v),l.state;const x=r&&r.defaultView,W=x&&x.Image;if(typeof W!="function")return"ok";l={state:"loading",waiting:new Set(v?[v]:[])},S.set(d,l);const Z=new W,le=oe=>{if(l.state=oe,oe==="failed"){const y=d.length>80?d.slice(0,77):d;Y(`chart:marker:image-failed:${d}`,`a chart marker image could not be loaded (${y}); those points keep the default marker. Check the URL, and that the server allows the page to load it.`)}for(const y of l.waiting)try{y()}catch{}l.waiting.clear()};return Z.onload=()=>le("ok"),Z.onerror=()=>le("failed"),Z.src=d,"loading"}function m(d,r,v){const l=p(d,r,v.grid);if(!l)return null;if(!f.test(l)){const W=se(v.grid,l,"marker");return W?{kind:"icon",def:W}:null}const x=N(l);if(!x){const W=l.slice(0,40);return Y(`chart:marker:unsafe-url:${W}`,`a chart marker image URL was refused (${W}): only http, https, blob, relative and data:image URLs are drawn. Those points keep the default marker.`),null}return u(x,v.doc,v.redraw)==="ok"?{kind:"image",href:x}:null}function c(d,r,v){const l=v.size/2;if(r.kind==="icon"){const W=r.def,Z=W.paint==="stroke",le=d.next("path",`${V}__marker-icon ${V}__mark`);return v.attrs(le,{d:W.paths.join(" "),transform:ne(W,{x:v.x,y:v.y,size:v.size}),fill:Z?"none":v.colour,stroke:Z?v.colour:null,"stroke-width":Z?1.5:null,class:`${V}__marker-icon ${V}__mark`,...v.extra||{}}),le}const x=d.next("image",`${V}__marker-image ${V}__mark`);return v.attrs(x,{href:r.href,x:v.round(v.x-l),y:v.round(v.y-l),width:v.size,height:v.size,preserveAspectRatio:"xMidYMid meet",class:`${V}__marker-image ${V}__mark`,...v.extra||{}}),x}function w(d,r,v){return Math.abs(r-d.x)<=d.half&&Math.abs(v-d.y)<=d.half}}),Ze("packages/modules/charts/cartesian.js",function(t,ue){"use strict";Object.defineProperty(t,"CARTESIAN",{enumerable:!0,get:function(){return be}}),Object.defineProperty(t,"WATERFALL_TOTAL",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(t,"withWaterfallTotal",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(t,"axisWindowSpan",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(t,"axisWindowNow",{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(t,"rollingDomain",{enumerable:!0,get:function(){return We}}),Object.defineProperty(t,"WINDOW_LEAD",{enumerable:!0,get:function(){return st}}),Object.defineProperty(t,"aheadOfWindow",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(t,"staleWindow",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(t,"windowedBound",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(t,"slotPadFor",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(t,"pinnedContinuousX",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(t,"continuousX",{enumerable:!0,get:function(){return dt}}),Object.defineProperty(t,"bandedX",{enumerable:!0,get:function(){return Qe}}),Object.defineProperty(t,"dataInterval",{enumerable:!0,get:function(){return It}}),Object.defineProperty(t,"continuousSlot",{enumerable:!0,get:function(){return At}}),Object.defineProperty(t,"xDomainFor",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(t,"xScaleFor",{enumerable:!0,get:function(){return Wt}}),Object.defineProperty(t,"drawFits",{enumerable:!0,get:function(){return fn}}),Object.defineProperty(t,"drawConfidenceBand",{enumerable:!0,get:function(){return nn}}),Object.defineProperty(t,"drawBoundErrorBars",{enumerable:!0,get:function(){return on}}),Object.defineProperty(t,"drawForest",{enumerable:!0,get:function(){return pn}}),Object.defineProperty(t,"drawReferenceLines",{enumerable:!0,get:function(){return Yt}}),Object.defineProperty(t,"drawCartesian",{enumerable:!0,get:function(){return ln}}),Object.defineProperty(t,"HIT_TOLERANCE",{enumerable:!0,get:function(){return en}}),Object.defineProperty(t,"nearestDrawnPoint",{enumerable:!0,get:function(){return cn}}),Object.defineProperty(t,"nearestCategory",{enumerable:!0,get:function(){return dn}}),Object.defineProperty(t,"categoryKeyAt",{enumerable:!0,get:function(){return rn}});const Le=ue("packages/modules/charts/axis.js"),Y=Le.drawAxisLines,fe=Le.drawAxisTitle,se=Le.drawBandLabels,ne=Le.drawCategoryAxis,n=Le.drawContinuousAxis,V=Le.drawMeasureAxis,T=Le.overhangFor,q=Le.pinXDomain,R=Le.setPlotClip,f=Le.turnedFirstLabelBox,S=ue("packages/modules/charts/frame.js"),g=S.Pool,P=S.shouldRotate,N=ue("packages/modules/charts/format.js"),p=N.formatters,u=N.r2Digits,m=ue("packages/modules/charts/scale.js"),c=m.bandScale,w=m.extent,d=m.isNumber,r=m.key,v=m.linearScale,l=m.measureDomain,x=m.timeScale,W=m.toNumber,Z=m.toTime,le=ue("packages/modules/charts/stack.js"),oe=le.measureValues,y=le.stacker,C=ue("packages/modules/charts/svg.js"),D=C.attrs,M=C.path,J=C.ribbonPath,F=C.round,re=C.setText,z=C.SVG_NS,L=ue("packages/modules/charts/styles.js").NS,i=ue("packages/modules/charts/labels.js").drawDataLabels,A=ue("packages/modules/charts/dense.js").downsample,te=ue("packages/modules/charts/scheme.js").resolveScheme,ge=ue("packages/modules/charts/typography.js").applySize,Pe=ue("packages/modules/charts/combo.js").drawRightAxis,Te=ue("packages/modules/charts/annotations.js"),_=Te.drawAnnotations,pe=Te.overlayLayer,ie=ue("packages/modules/charts/trendline.js").drawTrendlines,Q=ue("packages/modules/charts/rulecolour.js"),ye=Q.ruleColour,o=Q.ruleLegend,H=ue("packages/modules/charts/curve.js"),s=H.curveCommands,h=H.resolveCurve,I=ue("packages/core/src/internal/warn.js").warnOnce,K=ue("packages/modules/charts/fills.js"),ee=K.isPaintRef,E=K.paintSolid,G=K.rowFillSource,Me=ue("packages/modules/charts/markers.js"),k=Me.markerFor,j=Me.placeMarker,X=Me.resolveMarker,ae=3.5,be=Object.freeze({line:{zero:!1,marks:"path"},step:{zero:!1,marks:"path"},area:{zero:!0,marks:"path"},rangeArea:{zero:!1,marks:"path"},bar:{zero:!0,marks:"rect"},horizontalBar:{zero:!0,marks:"rect",horizontal:!0},waterfall:{zero:!0,marks:"rect"},scatter:{zero:!1,marks:"circle"},bubble:{zero:!1,marks:"circle"},candlestick:{zero:!1,marks:"rect"},ohlc:{zero:!1,marks:"rect"}});function Se(b){const Oe=[];for(let de=0;de<b.length;de++){const xe=b[de];if(de===0){Oe.push("M",xe.x,xe.y);continue}Oe.push("L",xe.x,b[de-1].y),Oe.push("L",xe.x,xe.y)}return Oe}function Ae(b){const Oe=[0];if(!b)return Oe;let de=0;for(const xe of b.points)d(xe.y)&&xe.total!==!0&&(de+=xe.y,Oe.push(de));return Oe}const ze=Object.freeze({key:"lattice:waterfall-total"});function Be(b,Oe,de){if(!Oe||typeof Oe!="object"||!Oe.total||!b||b.empty||!Array.isArray(b.series)||!b.series.length)return b;const xe=typeof Oe.total=="string"&&Oe.total.trim()!==""?Oe.total:de,Ne=b.series.map($e=>{let _e=0,Re=0,je=!1;for(const Ge of $e.points)Re+=Number.isFinite(Ge.rows)?Ge.rows:0,d(Ge.y)&&(_e+=Ge.y,je=!0);const Fe={x:ze,xKey:r(ze),label:xe,y:je?_e:null,size:null,rows:Re,rowKey:null,values:null,total:!0};return{...$e,points:[...$e.points,Fe]}});return{...b,kind:"category",series:Ne,categories:[...b.categories||[],ze],labels:[...b.labels||[],xe]}}function qe(b){const Oe=b&&b.window;if(!Oe||typeof Oe!="object")return 0;const de=Number(Oe.span);return!Number.isFinite(de)||de<=0?0:Oe.kind!=="time"?(I("chart.axis.window.kind",`axis window kind "${Oe.kind}" is not supported on a chart axis; only { kind: "time", span } rolls the domain. Bound the row count with the source's maxRows instead.`),0):de}function Ue(b,Oe){const de=b&&b.window;if(!de||typeof de!="object"||typeof de.now!="function")return Oe;const xe=Number(de.now());return Number.isFinite(xe)?xe:(I("chart.axis.window.now","axis.x.window.now did not return a time, so the rolling window is measured from this device's clock instead. It must return epoch milliseconds — the same number Date.now() returns — because that is what the x values are compared against."),Oe)}function We(b,Oe,de){const xe=de+b*st;let Ne=de;for(const $e of Oe)Number.isFinite($e)&&$e>Ne&&$e<=xe&&(Ne=$e);return{min:Ne-b,max:Ne}}const st=.25;function tt(b,Oe,de){const xe=qe(Oe);if(!xe||!b||!Array.isArray(b.categories))return null;const Ne=be[de];if(!Ne||Ne.horizontal||b.kind==="category"||de==="bar"&&!dt(b,de,Oe))return null;const $e=b.categories.map(_e=>b.kind==="time"?Z(_e):W(_e));return{span:xe,values:$e}}function wt(b,Oe,de,xe){const Ne=tt(b,Oe,de);if(!Ne)return null;const $e=Ne.span*st;let _e=0,Re=0;for(const je of Ne.values)je===null||!Number.isFinite(je)||je-xe<=$e||(_e+=1,je-xe>Re&&(Re=je-xe));return _e?{span:Ne.span,limit:$e,count:_e,lead:Re}:null}function Mt(b,Oe,de,xe){const Ne=tt(b,Oe,de);if(!Ne)return null;const{span:$e}=Ne,_e=Ne.values.filter(Ge=>Ge!==null&&Number.isFinite(Ge));if(!_e.length)return null;const{min:Re,max:je}=We($e,_e,xe);let Fe=-1/0;for(const Ge of _e){if(Ge>=Re&&Ge<=je)return null;Ge<Re&&Ge>Fe&&(Fe=Ge)}return Fe===-1/0?{span:$e,newest:null,age:null,points:_e.length}:{span:$e,newest:Fe,age:xe-Fe,points:_e.length}}function Nt(b,Oe,de,xe){const Ne=tt(b,Oe,de);if(!Ne)return b;const{span:$e,values:_e}=Ne,Re=_e.filter(Ke=>Ke!==null&&Number.isFinite(Ke));if(!Re.length)return b;const{min:je,max:Fe}=We($e,Re,xe),Ge=[];for(let Ke=0;Ke<_e.length;Ke++){const nt=_e[Ke];(nt===null||!Number.isFinite(nt)||nt>=je&&nt<=Fe)&&Ge.push(Ke)}return Ge.length===_e.length?b:{...b,categories:Ge.map(Ke=>b.categories[Ke]),labels:Array.isArray(b.labels)?Ge.map(Ke=>b.labels[Ke]):b.labels,series:(b.series||[]).map(Ke=>({...Ke,points:Array.isArray(Ke.points)?Ge.map(nt=>Ke.points[nt]).filter(nt=>nt!==void 0):Ke.points})),windowed:_e.length-Ge.length}}const pt=Object.freeze({bar:.2,candlestick:.3,ohlc:.3}),gt=.4;function mt(b){return Object.hasOwn(pt,b)?pt[b]:gt}const Ct=new Set(["bar","candlestick","ohlc"]);function kt(b){const Oe=b&&typeof b.scale=="string"?b.scale:"";return Oe==="time"||Oe==="linear"}function dt(b,Oe,de){if(!b||b.kind==="category")return!1;const xe=be[Oe];return xe&&xe.horizontal?!1:Ct.has(Oe)?kt(de):!0}function Qe(b,Oe,de){return!dt(b,Oe,de)}function It(b){const Oe=b.filter(Ne=>typeof Ne=="number"&&Number.isFinite(Ne)).slice().sort((Ne,$e)=>Ne-$e),de=[];for(let Ne=1;Ne<Oe.length;Ne++){const $e=Oe[Ne]-Oe[Ne-1];$e>0&&de.push($e)}if(!de.length)return 0;de.sort((Ne,$e)=>Ne-$e);const xe=Math.floor(de.length/2);return de.length%2?de[xe]:(de[xe-1]+de[xe])/2}function At(b){const{bound:Oe,scale:de,config:xe,padding:Ne}=b,$e=xe?Number(xe.barWidth):NaN,_e=Number.isFinite($e)&&$e>0,Re=(Oe.categories||[]).map(Ke=>Oe.kind==="time"?Z(Ke):W(Ke)),je=_e?$e:It(Re),Fe=Math.abs(de.range[1]-de.range[0]);if(!je)return Math.max(1,Fe/20*(1-Ne));const Ge=Math.abs(de.of(de.domain.min+je)-de.of(de.domain.min));return Math.max(1,_e?Ge:Ge*(1-Ne))}function jt(b,Oe,de,xe){if(Qe(b,Oe,de))return null;const Ne=qe(de),$e=b.kind==="time"?b.categories.map(Z):b.categories.map(W);if(b.kind==="time"&&!Ne){const Re=w($e);if(Re&&Re.min===Re.max)return q({min:Re.min-3e4,max:Re.max+3e4},b,de)}const _e=Ne?We(Ne,$e,Number.isFinite(xe)?xe:Ue(de,Date.now())):l($e,{zero:!1,nice:b.kind!=="time"});return q(_e,b,de)}function Wt(b,Oe,de,xe){const Ne=[Oe.left,Oe.right];if(Qe(b,de,xe))return qe(xe)&&I("chart.axis.window.band","a rolling time window needs a continuous x axis; this chart bands its x values, so the window is ignored. Bind a date or numeric column to x, or put this type on a continuous axis with axis.x.scale."),c(b.categories,Ne,mt(de));const $e=b.xDomain||jt(b,de,xe);return b.kind==="time"?x($e,Ne):v($e,Ne)}function Bt(b,Oe){if(b.kind==="band")return b.centre(Oe.x);const de=b.kind==="time"?Z(Oe.x):W(Oe.x);return de===null?NaN:b.of(de)}function Ft(b,Oe){const de=b&&b.seriesStyle&&b.seriesStyle[Oe];if(de)return{width:de.width!=null?String(de.width):null,dash:Array.isArray(de.dash)&&de.dash.length?de.dash.join(" "):null,opacity:null,emphasized:!1};const xe=b&&Array.isArray(b.emphasis)?b.emphasis:null;if(!xe||!xe.length)return{width:null,dash:null,opacity:null,emphasized:!1};const Ne=xe.includes(Oe);return{width:Ne?"var(--lattice-chart-emphasis-width, 3.5)":null,dash:null,opacity:Ne?null:"var(--lattice-chart-muted-opacity, .35)",emphasized:Ne}}function Vt(b){const{series:Oe,xScale:de,yScale:xe,baseline:Ne,fill:$e,colour:_e,stack:Re,style:je}=b,Fe=[],Ge=[];let Ke=[];const nt=()=>{Ke.length===1?Fe.push("M",Ke[0].x,Ke[0].y):Ke.length>1&&Fe.push(...s(Ke,b.curve||null)),Ke=[]};for(let yt=0;yt<Oe.points.length;yt++){const he=Oe.points[yt],Ce=F(Bt(de,he));if(!d(he.y)||Number.isNaN(Ce)){nt();continue}Ge[yt]=!0;const He=he.y,Ie=b.lower?b.lower.points[yt]:null;if(b.lower&&!(Ie&&d(Ie.y))){nt();continue}const Ye=Re?Re.take(yt,He):null,ot=F(xe.of(Ye?Ye[1]:He)),ut=F(xe.of(Ye?Ye[0]:Ie?Ie.y:Ne));Ke.push({x:Ce,y:ot,base:ut}),he.px=Ce,he.py=ot,he.pbase=ut}nt(),D(b.pool.next("path",`${L}__line ${L}__mark`),{d:Fe.length?M(Fe):"",stroke:_e,"data-series":b.index,"stroke-width":je?je.width:null,"stroke-dasharray":je?je.dash:null,opacity:je?je.opacity:null});const Xe=!!b.marker&&!!b.markerEnv;if(Xe&&!$e&&Gt(b,Ge),!$e){Xe||Et({...b,placed:Ge});return}const at=[];let ct=[];const lt=()=>{if(ct.length<2){ct=[];return}const yt=s(ct,b.curve||null);yt[0]="L",at.push("M",ct[0].x,ct[0].base),at.push(...yt);for(let he=ct.length-1;he>=0;he--)at.push("L",ct[he].x,ct[he].base);at.push("Z"),ct=[]};for(const yt of Oe.points){if(!d(yt.y)||yt.px===void 0){lt();continue}ct.push({x:yt.px,y:yt.py,base:yt.pbase})}lt(),D(b.pool.next("path",`${L}__area ${L}__mark`),{d:at.length?M(at):"",fill:_e,"data-series":b.index,opacity:ee(_e)?"1":je?je.emphasized?"1":je.opacity:null}),Xe?Gt(b,Ge):Et({...b,placed:Ge})}function Gt(b,Oe){const{series:de}=b;for(let xe=0;xe<de.points.length;xe++){if(!Oe[xe])continue;const Ne=de.points[xe];an(b,Ne,xe,Ne.px,Ne.py,ae*2,b.colour)||D(b.pool.next("circle",`${L}__point ${L}__mark`),{cx:Ne.px,cy:Ne.py,r:ae,fill:b.colour,"data-series":b.index,"data-point":xe})}}function Et(b){const{series:Oe,placed:de}=b;for(let xe=0;xe<Oe.points.length;xe++){if(!de[xe]||de[xe-1]||de[xe+1])continue;const Ne=Oe.points[xe];D(b.pool.next("circle",`${L}__point ${L}__mark`),{cx:Ne.px,cy:Ne.py,r:ae,fill:b.colour,"data-series":b.index,"data-point":xe})}}function _t(b,Oe){const de=b&&b.range;if(!Array.isArray(de)||de.length!==2)return Oe;const[xe,Ne]=de;return!Number.isFinite(xe)||!Number.isFinite(Ne)||!Number.isFinite(Oe)?Oe:Math.min(Math.max(xe,Ne),Math.max(Math.min(xe,Ne),Oe))}function Ht(b){const{series:Oe,xScale:de,yScale:xe,baseline:Ne,colour:$e,stack:_e,slot:Re}=b;for(let je=0;je<Oe.points.length;je++){const Fe=Oe.points[je];if(!d(Fe.y))continue;const Ge=de.kind==="band"?de.of(Fe.x):Bt(de,Fe)-Re.span/2;if(Number.isNaN(Ge))continue;const Ke=Fe.y,nt=b.pointColour&&b.pointColour(Fe,$e)||$e,Xe=_e?_e.take(je,Ke):[Ne,Ke],at=_t(xe,xe.of(Xe[1])),ct=_t(xe,xe.of(Xe[0])),lt=Ge+Re.offset,yt=de.kind==="band"?lt:_t(de,lt),he=de.kind==="band"?lt+Re.width:_t(de,lt+Re.width),Ce=b.pool.next("rect",`${L}__bar ${L}__mark`,`${Oe.key}:${r(Fe.x)}`);D(Ce,{x:F(yt),y:F(Math.min(at,ct)),width:F(Math.max(0,he-yt)),height:F(Math.max(1,Math.abs(ct-at))),fill:nt,"data-series":b.index,"data-point":je}),Fe.px=F(Ge+Re.offset+Re.width/2),Fe.py=F(Math.min(at,ct)),Fe.pbase=F(Math.max(at,ct))}}function Kt(b){const{series:Oe,xScale:de,yScale:xe}=b;let Ne=0;for(let $e=0;$e<Oe.points.length;$e++){const _e=Oe.points[$e];if(!d(_e.y))continue;const Re=_e.y,je=_e.total===!0,Fe=je?0:Ne,Ge=je?Re:Ne+Re;je||(Ne+=Re);const Ke=_t(xe,xe.of(Math.max(Fe,Ge))),nt=_t(xe,xe.of(Math.min(Fe,Ge))),Xe=b.pool.next("rect",`${L}__bar ${L}__mark`,`${Oe.key}:${r(_e.x)}`);D(Xe,{x:F(de.of(_e.x)),y:F(Ke),width:F(de.bandwidth),height:F(Math.max(1,nt-Ke)),fill:Re>=0?b.positive:b.negative,"data-series":b.index,"data-point":$e,"data-total":je?"true":null}),_e.px=F(de.of(_e.x)+de.bandwidth/2),_e.py=F(Ke)}}function Xt(b){const{series:Oe,valueScale:de,baseline:xe,colour:Ne,stack:$e,slot:_e}=b;for(let Re=0;Re<Oe.points.length;Re++){const je=Oe.points[Re];if(!d(je.y))continue;const Fe=b.bandScale.of(je.x);if(Number.isNaN(Fe))continue;const Ge=je.y,Ke=b.pointColour&&b.pointColour(je,Ne)||Ne,nt=$e?$e.take(Re,Ge):[xe,Ge],Xe=_t(de,de.of(nt[0])),at=_t(de,de.of(nt[1]));D(b.pool.next("rect",`${L}__bar ${L}__mark`,`${Oe.key}:${r(je.x)}`),{x:F(Math.min(Xe,at)),y:F(Fe+_e.offset),width:F(Math.max(1,Math.abs(at-Xe))),height:F(Math.max(0,_e.width)),fill:Ke,"data-series":b.index,"data-point":Re}),je.px=F(at),je.py=F(Fe+_e.offset+_e.width/2),je.pbase=F(Xe)}}function Qt(b){const{series:Oe,xScale:de,yScale:xe,baseline:Ne,colour:$e,stack:_e,slot:Re}=b;for(let je=0;je<Oe.points.length;je++){const Fe=Oe.points[je];if(!d(Fe.y))continue;const Ge=de.kind==="band"?de.of(Fe.x):Bt(de,Fe)-Re.span/2;if(Number.isNaN(Ge))continue;const Ke=Fe.y,nt=b.pointColour&&b.pointColour(Fe,$e)||$e,Xe=_e?_e.take(je,Ke):[Ne,Ke],at=_t(xe,xe.of(Xe[1])),ct=_t(xe,xe.of(Xe[0])),lt=F(Ge+Re.offset+Re.width/2);D(b.pool.next("line",`${L}__lollipop-stem ${L}__mark`,`${Oe.key}:${r(Fe.x)}`),{x1:lt,y1:F(ct),x2:lt,y2:F(at),stroke:nt,"stroke-width":2,"data-series":b.index,"data-point":je}),D(b.pool.next("circle",`${L}__lollipop-dot ${L}__mark`,`${Oe.key}:${r(Fe.x)}`),{cx:lt,cy:F(at),r:4,fill:nt,"data-series":b.index,"data-point":je}),Fe.px=lt,Fe.py=F(at),Fe.pbase=F(ct)}}function hn(b){const{series:Oe,valueScale:de,baseline:xe,colour:Ne,stack:$e,slot:_e}=b;for(let Re=0;Re<Oe.points.length;Re++){const je=Oe.points[Re];if(!d(je.y))continue;const Fe=b.bandScale.of(je.x);if(Number.isNaN(Fe))continue;const Ge=je.y,Ke=b.pointColour&&b.pointColour(je,Ne)||Ne,nt=$e?$e.take(Re,Ge):[xe,Ge],Xe=_t(de,de.of(nt[0])),at=_t(de,de.of(nt[1])),ct=F(Fe+_e.offset+_e.width/2);D(b.pool.next("line",`${L}__lollipop-stem ${L}__mark`,`${Oe.key}:${r(je.x)}`),{x1:F(Xe),y1:ct,x2:F(at),y2:ct,stroke:Ke,"stroke-width":2,"data-series":b.index,"data-point":Re}),D(b.pool.next("circle",`${L}__lollipop-dot ${L}__mark`,`${Oe.key}:${r(je.x)}`),{cx:F(at),cy:ct,r:4,fill:Ke,"data-series":b.index,"data-point":Re}),je.px=F(at),je.py=ct,je.pbase=F(Xe)}}function fn(b){const Oe=b.group.ownerDocument;let de=null;for(const $e of b.group.childNodes||[])if($e&&String($e.getAttribute&&$e.getAttribute("class"))===`${L}__fits`){de=$e;break}de||(de=Oe.createElementNS(z,"g"),de.setAttribute("class",`${L}__fits`),b.group.appendChild(de));const xe=new g(de),Ne=[];for(const $e of b.series){const _e=$e.allPoints||$e.points;let Re=0,je=0,Fe=0;for(const Ie of _e){const Ye=Number(Ie.x),ot=Number(Ie.y);!Number.isFinite(Ye)||!Number.isFinite(ot)||(Re++,je+=Ye,Fe+=ot)}if(Re<2)continue;const Ge=je/Re,Ke=Fe/Re;let nt=0,Xe=0,at=0,ct=1/0,lt=-1/0;for(const Ie of _e){const Ye=Number(Ie.x),ot=Number(Ie.y);if(!Number.isFinite(Ye)||!Number.isFinite(ot))continue;const ut=Ye-Ge,Ot=ot-Ke;nt+=ut*ut,Xe+=ut*Ot,at+=Ot*Ot,Ye<ct&&(ct=Ye),Ye>lt&&(lt=Ye)}if(nt===0)continue;const yt=Xe/nt,he=Ke-yt*Ge,Ce=at===0?1:Math.max(0,Math.min(1,Xe*Xe/(nt*at))),He=b.scheme.series($e.index);if(D(xe.next("path",`${L}__fit`),{d:M(["M",F(b.xScale.of(ct)),F(b.yScale.of(he+yt*ct)),"L",F(b.xScale.of(lt)),F(b.yScale.of(he+yt*lt))]),fill:"none",stroke:He,"data-series":$e.index}),b.showR2){const Ie=xe.next("text",`${L}__fit-label`);ge(Ie,b.size),D(Ie,{x:F(b.xScale.of(lt)),y:F(b.yScale.of(he+yt*lt))-4,"text-anchor":"end",fill:He}),re(Ie,b.grid.messages.t("chart.r2",{value:u(b.grid,Ce)}))}Ne.push({key:$e.key,slope:yt,intercept:he,r2:Ce,n:Re})}return xe.finish(),Ne}function nn(b){const Oe=b.group.ownerDocument;let de=null;for(const Fe of b.group.childNodes||[])if(Fe&&String(Fe.getAttribute&&Fe.getAttribute("class"))===`${L}__band`){de=Fe;break}de||(de=Oe.createElementNS(z,"g"),de.setAttribute("class",`${L}__band`),b.group.firstChild?b.group.insertBefore(de,b.group.firstChild):b.group.appendChild(de));const xe=new g(de),Ne=b.band&&Array.isArray(b.band.points)?b.band.points:[],$e=Number.isFinite(b.index)?Number(b.index):0,_e=b.scheme.series($e),Re=Number.isFinite(b.opacity)?Number(b.opacity):.15,je=[];for(const Fe of Ne){const Ge=Number(Fe.x),Ke=Number(Fe.lower),nt=Number(Fe.upper);if(!Number.isFinite(Ge)||!Number.isFinite(Ke)||!Number.isFinite(nt))continue;const Xe=Number(Fe.yhat);je.push({x:F(b.xScale.of(Ge)),lower:F(b.yScale.of(Ke)),upper:F(b.yScale.of(nt)),yhat:Number.isFinite(Xe)?F(b.yScale.of(Xe)):null})}if(je.length>=2&&(D(xe.next("path",`${L}__band-fill`),{d:J(je),fill:_e,"fill-opacity":Re,stroke:"none","data-series":$e}),b.line!==!1)){const Fe=[];let Ge=!1;for(const Ke of je){if(Ke.yhat===null){Ge=!1;continue}Fe.push(Ge?"L":"M",Ke.x,Ke.yhat),Ge=!0}D(xe.next("path",`${L}__band-line`),{d:Fe.length?M(Fe):"",fill:"none",stroke:_e,"data-series":$e})}return xe.finish(),{points:je.length,confidence:b.band&&Number.isFinite(b.band.confidence)?Number(b.band.confidence):null}}function on(b){const Oe=b.group.ownerDocument;let de=null;for(const je of b.group.childNodes||[])if(je&&String(je.getAttribute&&je.getAttribute("class"))===`${L}__whiskers`){de=je;break}de||(de=Oe.createElementNS(z,"g"),de.setAttribute("class",`${L}__whiskers`),b.group.appendChild(de));const xe=new g(de),Ne=Number.isFinite(b.cap)?Number(b.cap):4,$e=b.colour||"currentColor",_e=b.orient!=="v";let Re=0;for(const je of b.points||[]){const Fe=Number(je.main),Ge=Number(je.lo),Ke=Number(je.hi);if(!Number.isFinite(Fe)||!Number.isFinite(Ge)||!Number.isFinite(Ke))continue;const nt=_e?["M",Ge,Fe,"L",Ke,Fe,"M",Ge,Fe-Ne,"L",Ge,Fe+Ne,"M",Ke,Fe-Ne,"L",Ke,Fe+Ne]:["M",Fe,Ge,"L",Fe,Ke,"M",Fe-Ne,Ge,"L",Fe+Ne,Ge,"M",Fe-Ne,Ke,"L",Fe+Ne,Ke];D(xe.next("path",`${L}__whisker`),{d:M(nt),stroke:$e,fill:"none"}),Re++}return xe.finish(),Re}function pn(b){const Oe=b.scheme||te(),de=b.typography||{small:b.fontSize||11,axisTitle:11},{bound:xe}=b,Ne=sn(b.plot,de.small),$e=xe.series[0]&&xe.series[0].points||[],_e=$e.map(Xe=>Xe.label),Re=Oe.series(0),je=c(_e,[Ne.top,Ne.bottom],.4),Fe=[0];for(const Xe of $e)for(const at of[Xe.x,Xe.lower,Xe.upper])Number.isFinite(at)&&Fe.push(at);const Ge=v(l(Fe,{zero:!1}),[Ne.left,Ne.right]);on({group:b.groups.overlay,orient:"h",colour:Re,points:$e.map(Xe=>({main:F(je.centre(Xe.label)),lo:F(Ge.of(Xe.lower)),hi:F(Ge.of(Xe.upper))}))});const Ke=new g(b.groups.marks);let nt=0;for(const Xe of $e)Number.isFinite(Xe.x)&&(D(Ke.next("circle",`${L}__point ${L}__mark`),{cx:F(Ge.of(Xe.x)),cy:F(je.centre(Xe.label)),r:ae,fill:Re}),nt++);return Ke.finish(),Yt({group:b.groups.rules,plot:Ne,scale:Ge,lines:[{value:0}]}),n({group:b.groups.axis,plot:Ne,scale:Ge,format:p(b.grid,{kind:"linear",step:(Ge.domain.max-Ge.domain.min)/5}),config:{},grid:b.grid,size:de.small}),se({group:b.groups.labels,plot:Ne,scale:je,labels:_e,fontSize:de.small,config:{}}),{series:[],marks:nt}}function sn(b,Oe){const de=6+Oe*1.3+2,xe=b&&b.gutter&&Number.isFinite(b.gutter.bottom)?b.gutter.bottom:de,Ne=Math.min(Math.max(0,de-xe),Math.max(0,b.height-10));return Ne>0?{...b,height:b.height-Ne,bottom:b.bottom-Ne,gutter:{...b.gutter,bottom:xe+Ne}}:b}function Yt(b){const Oe=new g(pe(b.group,`${L}__reflines`));for(const de of b.lines||[]){if(!d(de.value))continue;const xe=F(b.scale.of(de.value));if(D(Oe.next("path",`${L}__reference`),{d:b.vertical?M(["M",xe,F(b.plot.top),"L",xe,F(b.plot.bottom)]):M(["M",F(b.plot.left),xe,"L",F(b.plot.right),xe]),stroke:de.colour||"currentColor","stroke-dasharray":"4 3",fill:"none"}),!de.label)continue;const Ne=Oe.next("text",`${L}__reference-label`);D(Ne,b.vertical?{x:xe+4,y:F(b.plot.top+10),"text-anchor":"start"}:{x:F(b.plot.right-4),y:xe-4,"text-anchor":"end"}),re(Ne,de.label)}Oe.finish()}function Jt(b){const{series:Oe,xScale:de,yScale:xe,colour:Ne,plot:$e}=b,_e=b.size||null;for(let Re=0;Re<Oe.points.length;Re++){const je=Oe.points[Re];if(!d(je.y))continue;const Fe=F(Bt(de,je));if(Number.isNaN(Fe))continue;const Ge=F(xe.of(je.y));let Ke=_e&&d(je.size)?F(_e.of(je.size)):ae;if($e){const Xe=Math.min(Fe-$e.left,$e.right-Fe,Ge-$e.top,$e.bottom-Ge);Number.isFinite(Xe)&&(Ke=Math.max(1,Math.min(Ke,Xe)))}const nt=b.pointColour&&b.pointColour(je,Ne)||Ne;an(b,je,Re,Fe,Ge,Ke*2,nt)||D(b.pool.next("circle",`${L}__point ${L}__mark`),{cx:Fe,cy:Ge,r:Ke,fill:nt,"fill-opacity":_e?.7:1,"data-series":b.index,"data-point":Re}),je.px=Fe,je.py=Ge}}function an(b,Oe,de,xe,Ne,$e,_e){if(!b.marker||!b.markerEnv)return!1;const Re=k(b.marker,Oe,b.markerEnv);if(Oe.markerHalf=0,!Re)return!1;const je=b.marker.explicitSize?b.marker.size:Math.max(b.marker.size,$e);return j(b.pool,Re,{x:xe,y:Ne,size:je,colour:E(_e),attrs:D,round:F,extra:{"data-series":b.index,"data-point":de}}),Oe.markerHalf=je/2,!0}function gn(b){const{group:Oe,series:de,xScale:xe,yScale:Ne,options:$e}=b,_e=b.grid&&b.grid.statistics,Re=_e&&typeof _e.intervalOf=="function"?(ct,lt)=>_e.intervalOf(ct,lt):null,je=new g(pe(Oe,`${L}__errorbars`)),Fe=Number.isFinite(Number($e.confidence))?Number($e.confidence):.95,Ge=4;let Ke=0,nt=0,Xe=0,at=0;for(const ct of de)for(const lt of ct.points){if(lt.y===null||lt.y===void 0)continue;nt++;const yt=Array.isArray(lt.values)&&lt.values.length===1;yt&&Xe++;let he=null,Ce=null;if($e.of!==void 0&&Number.isFinite(Number(lt[$e.of]))){const ot=Math.abs(Number(lt[$e.of]));he=lt.y-ot,Ce=lt.y+ot}else if(Array.isArray(lt.values)&&lt.values.length>1&&Re){const ot=Re(lt.values,Fe);ot&&(he=ot.lower,Ce=ot.upper)}if(he===null||!Number.isFinite(he)||!Number.isFinite(Ce)){yt&&at++;continue}const He=F(xe.of(lt.xKey!==void 0?lt.xKey:lt.x)+(xe.bandwidth?xe.bandwidth/2:0)),Ie=F(Ne.of(Ce)),Ye=F(Ne.of(he));D(je.next("path",`${L}__error-bar ${L}__mark`),{d:M(["M",He-Ge,Ie,"L",He+Ge,Ie,"M",He,Ie,"L",He,Ye,"M",He-Ge,Ye,"L",He+Ge,Ye]),fill:"none",stroke:"currentColor","data-lower":he,"data-upper":Ce}),Ke++}return je.finish(),{drawn:Ke,marks:nt,single:Xe,singleSkipped:at}}function Dt(b,Oe){if(Oe&&Oe.size){const $e=new Set;for(let _e=0;_e<b.length;_e++)b[_e].rowKey!=null&&Oe.has(String(b[_e].rowKey))&&$e.add(_e);return $e}const de=5,xe=$e=>[...b.keys()].filter(_e=>Number.isFinite($e(b[_e]))).sort((_e,Re)=>$e(b[Re])-$e(b[_e])).slice(0,de),Ne=new Set(xe($e=>Math.abs(Number($e.y))));for(const $e of xe(_e=>Number(_e.x)))Ne.add($e);if(b.some($e=>d($e.size)))for(const $e of xe(_e=>d(_e.size)?Number(_e.size):-1/0))Ne.add($e);return Ne}function ln(b){const Oe=b.scheme||te(),de=b.axis||{x:{},y:{},y2:{}},xe=b.typography||{small:b.fontSize||11,axisTitle:11},{bound:Ne,plot:$e,type:_e}=b,Re=be[_e]||be.line,je=Ne.series.filter(et=>!b.hidden.has(et.key)),Fe=!!Re.horizontal,Ge=b.mark==="lollipop"&&(_e==="bar"||_e==="horizontalBar"),Ke=!Fe&&de.y.position==="right"?"right":"left",nt=Ke==="right"?"left":"right",Xe=(_e==="bar"||_e==="horizontalBar")&&b.byRuleColour&&je.length===1&&Ne.measure&&Ne.measure.col||null,at=Xe?new Set:null,ct=Xe?et=>{const ht=ye({grid:b.grid,col:Xe,value:et.y});return ht&&at.add(ht),ht}:null,yt=(_e==="bar"||_e==="horizontalBar")&&b.byRuleColour&&je.length===1&&Oe.nameMap?et=>Oe.series(0,et.label):null,he=b.fill?G(b,Oe):null,Ce=he||ct||yt?(et,ht)=>he&&he(et,ht)||ct&&ct(et)||yt&&yt(et)||null:null,He=X(b.marker),Ie=He?{grid:b.grid,doc:b.doc,redraw:b.redraw}:null,Ye=!Fe&&_e!=="waterfall"?je.filter(et=>et.axis==="right"):[],ot=Ye.length?je.filter(et=>et.axis!=="right"):je,ut=Ye.length>0,Ot=(_e==="bar"||_e==="area"||_e==="horizontalBar")&&!ut,it=b.stack==="percent"&&Ot&&ot.length>1,Pt=(it||!!b.stack)&&ot.length>1&&Ot,Rt=_e==="waterfall"?Ae(je[0]):oe(ot,Pt,it),$t=Ne.yDomain||b.domain||l(Rt,{zero:Re.zero,min:de.y.min,max:de.y.max}),vt=Fe?v($t,[$e.left,$e.right]):v($t,[$e.bottom,$e.top]),xt=Fe?c(Ne.categories,[$e.top,$e.bottom],.2):Wt(Ne,$e,_e,de.x),Zt=$t.min<=0&&$t.max>=0?0:$t.min,bn=Ye.some(et=>(et.mark||(_e==="bar"?"bar":_e))==="bar"),B=ut?l(oe(Ye,!1,!1),{zero:bn,min:de.y2.min,max:de.y2.max}):null,ce=B?v(B,[$e.bottom,$e.top]):null,we=p(b.grid,{kind:"linear",step:($t.max-$t.min)/5}),De=it?{tick:et=>`${we.tick(et)}%`,value:et=>`${we.value(et)}%`}:we,Ee=b.axes!==!1,Ve={left:0,right:0,bottom:0};if(_e==="scatter"||_e==="bubble")for(const et of je)for(const ht of et.points){if(!d(ht.y))continue;const Lt=Bt(xt,ht),zt=vt.of(ht.y);if(!Number.isFinite(Lt)||!Number.isFinite(zt))continue;const Tt=(b.sizes&&d(ht.size)?b.sizes.of(ht.size):ae)+2;Ve.left=Math.max(Ve.left,Tt-(Lt-$e.left)),Ve.right=Math.max(Ve.right,Tt-($e.right-Lt)),Ve.bottom=Math.max(Ve.bottom,Tt-($e.bottom-zt))}const ft=!Fe&&xt.kind==="band"&&(de.x.rotate===void 0||de.x.rotate==="auto"?P(Ne.labels,xt.step,xe.small,de.x.every):!!de.x.rotate)&&f({group:b.groups.overlay,plot:$e,scale:xt,labels:Ne.labels,fontSize:xe.small,config:de.x});if(Ee&&V({gridGroup:b.groups.grid,axisGroup:b.groups.axis,plot:$e,scale:vt,format:De,horizontal:Fe,side:Ke,config:de.y,grid:b.grid,size:xe.small,overhang:Ke==="right"?Ve.right:Ve.left,dropBottom:ft}),Ee)if(Fe)se({group:b.groups.overlay,plot:$e,scale:xt,labels:Ne.labels,fontSize:xe.small,config:de.x});else if(xt.kind==="band")ne({group:b.groups.overlay,plot:$e,scale:xt,labels:Ne.labels,fontSize:xe.small,rotated:P(Ne.labels,xt.step,xe.small,de.x.every),config:de.x});else{const et=Ne.dimension&&Ne.dimension.col?b.grid.columns.get(Ne.dimension.col):void 0;n({group:b.groups.overlay,plot:$e,scale:xt,format:p(b.grid,{kind:Ne.kind,span:xt.domain.max-xt.domain.min,step:(xt.domain.max-xt.domain.min)/5},et),config:de.x,grid:b.grid,column:et,size:xe.small,overhang:Ve.bottom})}if(Ee&&(Y({group:b.groups.rules,plot:$e,side:Ke}),fe({group:b.groups.axis,plot:$e,text:de.y.title,side:Fe?"bottom":Ke,size:xe.axisTitle}),fe({group:b.groups.axis,plot:$e,text:de.x.title,side:Fe?"left":"bottom",size:xe.axisTitle})),Ee&&ce){Pe({group:b.groups.axis,plot:$e,scale:ce,colour:Oe.series(Ye[0].index),side:nt,format:p(b.grid,{kind:"linear",step:(B.max-B.min)/5})});const et=de.y2.title||(Ye.length===1?Ye[0].label:"");fe({group:b.groups.axis,plot:$e,text:et,side:nt,size:xe.axisTitle}),!de.y.title&&ot.length===1&&ot[0].label&&fe({group:b.groups.axis,plot:$e,text:ot[0].label,side:Ke,size:xe.axisTitle})}const bt=Number.isFinite(b.downsampleTo)?Number(b.downsampleTo):Math.max(2,Math.round($e.width));let Je=!1;if(Re.marks==="path"||_e==="scatter"||_e==="bubble"){for(const et of je)if(et.kept=null,et.allPoints=et.points,et.points.length>bt*1.5){const ht=et.points.map((zt,Tt)=>({x:Tt,y:zt.y,point:zt})),Lt=A(ht,bt);if(b.keepInfluential){const zt=new Set(Lt.map(Tt=>Tt.x));for(const Tt of Dt(et.points,b.keepRows))zt.has(Tt)||(Lt.push({x:Tt,y:et.points[Tt].y,point:et.points[Tt]}),zt.add(Tt));Lt.sort((Tt,$n)=>Tt.x-$n.x)}et.points=Lt.map(zt=>zt.point),et.kept=Lt.map(zt=>zt.x),Je=!0}}b.pool||R(b.groups,$e,T(_e));const St=b.pool||new g(b.groups.marks),un=it?Ne.categories.map((et,ht)=>je.reduce((Lt,zt)=>{const Tt=zt.points[ht]?zt.points[ht].y:null;return d(Tt)?Lt+Math.abs(Tt):Lt},0)):null,Ut=Pt?y(Ne.categories.length,un):null,qt=ut?je.filter(et=>(et.mark||(_e==="bar"?"bar":_e))==="bar"):je,tn=ut?Math.max(1,qt.length):Math.max(1,je.length),wn=_e==="bar"||ut&&qt.length>0,mn=xt.kind==="band"?xt.bandwidth:wn?At({bound:Ne,scale:xt,config:de.x,padding:mt("bar")}):0,kn=Pt?mn:mn/tn,vn=new Map;for(const et of qt)vn.set(et.key,vn.size);const An=[],xn=_e==="rangeArea"&&Ne.series.length>=2?Ne.series[0]:null,_n=xn?Ne.series[1]:null;for(let et=0;et<je.length;et++){const ht=je[et],Lt=Oe.series(ht.index,ht.label),zt=ht.axis==="right"&&ce?ce:vt,Tt=ut?ht.mark||(_e==="bar"?"bar":_e):_e,$n=ut&&vn.has(ht.key)?vn.get(ht.key):et;if(_e==="horizontalBar")(Ge?hn:Xt)({pool:St,series:ht,bandScale:xt,valueScale:vt,baseline:Zt,colour:Lt,stack:Ut,index:ht.index,slot:{offset:Pt?0:et*kn,width:kn,span:mn},pointColour:Ce});else if(_e==="waterfall")Kt({pool:St,series:ht,xScale:xt,yScale:vt,index:ht.index,positive:Oe.positive,negative:Oe.negative});else if(Tt==="bar")(Ge?Qt:Ht)({pool:St,series:ht,xScale:xt,yScale:zt,baseline:zt===ce?B.min<=0&&B.max>=0?0:B.min:Zt,colour:Lt,stack:Ut,index:ht.index,slot:{offset:Pt?0:$n*kn,width:kn,span:mn},pointColour:Ce});else if(_e==="scatter"||_e==="bubble")Jt({pool:St,series:ht,xScale:xt,yScale:zt,colour:Lt,index:ht.index,size:_e==="bubble"?b.sizes:null,pointColour:Ce,marker:He,markerEnv:Ie,plot:$e});else{const Tn=Ft(b,ht.label),zn=Tt==="step"?{type:"step",tension:1,mode:"after"}:h(b.curve,ht.label),En={pool:St,series:ht,xScale:xt,yScale:zt,baseline:Zt,fill:xn?ht===_n:Tt==="area"||Tt==="rangeArea",lower:xn&&ht===_n?xn:null,curve:zn,colour:Lt,stack:Ut,index:ht.index,style:Tn,marker:He,markerEnv:Ie};Tn.emphasized?An.push(En):Vt(En)}}for(const et of An)Vt(et);b.pool||St.finish(),b.band&&typeof xt.invert=="function"&&nn({group:b.groups.overlay,band:b.band,xScale:xt,yScale:vt,scheme:Oe,index:0,line:b.band.line!==!1&&!b.fit}),b.fit&&(_e==="scatter"||_e==="bubble")&&typeof xt.invert=="function"&&fn({group:b.groups.overlay,series:je,xScale:xt,yScale:vt,plot:$e,scheme:Oe,grid:b.grid,size:xe.small,showR2:b.fit!=="line"});let yn=null;b.trend&&(yn=ie({group:b.groups.overlay,series:je,xScale:xt,yScale:vt,rightScale:ce,plot:$e,scheme:Oe,trend:b.trend,grid:b.grid,format:et=>De.tick(et),size:xe.small,clip:b.groups.boxClipId}));let Ln=null;if(b.error&&(Ln=gn({group:b.groups.overlay,series:je,xScale:xt,yScale:vt,grid:b.grid,options:b.error===!0?{}:b.error})),b.labels&&b.labels.show&&i({group:b.groups.labels,series:je,plot:$e,options:b.labels,grid:b.grid,size:xe.small,horizontal:Fe}),b.reference&&b.reference.length){const et=Fe?b.reference:b.reference.filter(Lt=>!(Lt.axis==="right"||Lt.axis==="y2")),ht=ce?b.reference.filter(Lt=>Lt.axis==="right"||Lt.axis==="y2"):[];et.length&&Yt({group:b.groups.overlay,plot:$e,scale:vt,lines:et,vertical:Fe}),ht.length&&Yt({group:b.groups.overlay,plot:$e,scale:ce,lines:ht})}let On=null;b.annotations&&b.annotations.length&&(On=_({group:b.groups.overlay,plot:$e,xScale:xt,yScale:vt,rightScale:ce,series:je,annotations:b.annotations,dual:ut,horizontal:Fe,format:et=>De.tick(et),size:xe.small}));const Fn=Array.isArray(yn)&&yn.length?[...On||[],...yn]:On;return{xScale:xt,yScale:vt,rightScale:ce,dual:ut,series:je,horizontal:Fe,percent:it,percentTotals:it?un:null,plot:$e,errorBars:Ln,annotations:Fn,trendlines:yn,reduced:Je,legend:Xe?o({grid:b.grid,col:Xe,colours:at}):null}}const en=32;function cn(b){const{series:Oe,xScale:de,at:xe}=b,Ne=Number.isFinite(b.tolerance)?Number(b.tolerance):en,$e=[];let _e=-1,Re=1/0;for(const je of Oe){let Fe=null,Ge=-1,Ke=1/0;const nt=je.points||[];for(let Xe=0;Xe<nt.length;Xe++){const at=nt[Xe];if(!at||!d(at.y))continue;const ct=Bt(de,at);if(Number.isNaN(ct))continue;const lt=Math.abs(ct-xe);lt>=Ke||(Ke=lt,Fe=at,Ge=Array.isArray(je.kept)?je.kept[Xe]:Xe)}!Fe||Ke>Ne||($e.push({series:je,point:Fe}),Ke<Re&&(Re=Ke,_e=Ge))}return _e<0?null:{index:_e,entries:$e}}function dn(b){const{bound:Oe,xScale:de,at:xe}=b;if(!Oe.categories.length)return-1;if(de.kind==="band"){const _e=Math.floor((xe-de.range[0])/(de.step||1));return _e>=0&&_e<Oe.categories.length?_e:-1}let Ne=-1,$e=1/0;for(let _e=0;_e<Oe.categories.length;_e++){const Re=de.kind==="time"?Z(Oe.categories[_e]):W(Oe.categories[_e]);if(Re===null)continue;const je=Math.abs(de.of(Re)-xe);je<$e&&($e=je,Ne=_e)}return Ne}function rn(b,Oe){return Oe<0||Oe>=b.categories.length?"":r(b.categories[Oe])}}),Ze("packages/modules/charts/drawable.js",function(t,ue){"use strict";Object.defineProperty(t,"REASONS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(t,"DRAWABLE",{enumerable:!0,get:function(){return T}}),Object.defineProperty(t,"namedColumns",{enumerable:!0,get:function(){return q}}),Object.defineProperty(t,"missingColumns",{enumerable:!0,get:function(){return R}}),Object.defineProperty(t,"bucketKey",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"bucketMessage",{enumerable:!0,get:function(){return S}}),Object.defineProperty(t,"continuousX",{enumerable:!0,get:function(){return g}}),Object.defineProperty(t,"drawability",{enumerable:!0,get:function(){return P}});const Le=ue("packages/modules/charts/scale.js"),Y=Le.extent,fe=Le.toNumber,se=Le.toTime,n=ue("packages/modules/charts/cartesian.js").staleWindow,V=Object.freeze({EMPTY:"empty",INCOMPLETE:"incomplete",STALE:"stale",MISSING_COLUMN:"missing-column",NO_DOMAIN:"no-domain",BUCKETED:"bucketed",TOO_MANY_SETS:"too-many-sets"}),T=Object.freeze({ok:!0});function q(N){if(!N||typeof N!="object")return[];const p=[],u=(m,c)=>{typeof c=="string"&&c?p.push({key:m,col:c}):c&&typeof c=="object"&&typeof c.col=="string"&&c.col&&p.push({key:m,col:c.col})};if(Array.isArray(N.points))return[];if(u("x",N.x),u("code",N.code),u("y",N.y),u("series",N.series),u("size",N.size),u("source",N.source),u("target",N.target),u("text",N.text),u("time",N.time),u("entity",N.entity),u("colour",N.colour),u("set",N.set),Array.isArray(N.sets))for(const m of N.sets)u("sets",m);if(typeof N.multiples=="string"&&u("multiples",N.multiples),Array.isArray(N.measures))for(const m of N.measures)u("measures",m);return p}function R(N,p){const u=N&&N.columns;return!u||typeof u.get!="function"?[]:q(p).filter(({col:m})=>!u.get(m))}function f(N){return`chart:x:date-bucket:${N}`}function S(N,p,u){return`chart x column ${JSON.stringify(N)} is a 'date', which stores a calendar day, so all ${p} rows collapsed into one point and were reduced by '${u}'. For a series inside a single day, type the column 'datetime' or bind epoch milliseconds.`}function g(N,p){return!p||p.kind!=="time"&&p.kind!=="linear"?!1:N!=="bar"&&N!=="horizontalBar"}function P(N){const{grid:p,spec:u,type:m,bound:c}=N,w=N.id===void 0?"":String(N.id),d=Number.isFinite(N.now)?Number(N.now):Date.now(),r=(x,W,Z,le=!0)=>({ok:!1,reason:x,key:Z||`chart:${w}:${x}`,message:W,tell:le}),v=R(p,u);if(v.length){const x=v.map(Z=>`${Z.key}: ${JSON.stringify(Z.col)}`).join(", "),W=p&&p.columns&&typeof p.columns.all=="function"?p.columns.all().map(Z=>Z.id||Z.field).filter(Boolean):[];return r(V.MISSING_COLUMN,`chart ${x} ${v.length>1?"name columns":"names a column"} this grid does not have, so there is nothing to read and nothing to draw.${W.length?` The columns it does have: ${W.slice(0,12).map(Z=>JSON.stringify(Z)).join(", ")}${W.length>12?", …":""}.`:""} Bind a column the grid declares, or declare the column.`)}if(c&&c.empty){const x=p&&p.rows&&typeof p.rows.count=="function"?p.rows.count():0;return r(V.EMPTY,x?`chart bound nothing from the ${x} row(s) the grid is showing, so it shows its empty state. The binding named no series to draw: check that the spec names the columns this chart needs — a flow type needs source and target, a measure needs a column with values in it.`:"chart has no rows to draw, so it shows its empty state.",void 0,x>0)}if(m==="venn"&&c&&c.tooMany)return r(V.TOO_MANY_SETS,`a venn chart draws two or three sets and was given ${c.tooMany.count} (${c.tooMany.names.slice(0,8).map(x=>JSON.stringify(x)).join(", ")}${c.tooMany.count>8?", …":""}). Four or more sets cannot each have a region of their own as circles. Name two or three in "sets" (or "members" for a set column), or use an UpSet-style chart instead: a bar chart of how many rows hold each combination of memberships — group the grid by the membership columns and chart the row count.`);if(m==="venn"&&c&&c.tooFew)return r(V.INCOMPLETE,`a venn chart needs two or three sets and was given ${c.tooFew.count}. Name the membership columns in "sets" (boolean columns), or a multi-value column in "set" with the "members" to compare.`);if((m==="candlestick"||m==="ohlc")&&(!c||!c.series||c.series.length<4)){const x=c&&c.series?c.series.length:0;return r(V.INCOMPLETE,`a ${m} chart needs four measures — open, high, low and close, in that order — and ${x===0?"none was":`only ${x} were`} bound. Pass them as measures: [open, high, low, close].`)}const l=n(c,N.axis&&N.axis.x,m,d);if(l){const x=l.newest===null?"and every one of them is stamped ahead of it":`and the newest of ${l.points} x value(s) is ${Math.round(l.age/1e3)}s old`;return r(V.STALE,`the rolling x window covers the last ${l.span} ms, ${x}, so every mark would be drawn outside the plot. The chart shows its empty state instead. Seed it with data inside the window, widen axis.x.window.span, or drop the window while showing history.`,`chart:${w}:x:window:stale:${u&&u.x||""}`,l.newest!==null)}if(g(m,c)){const x=Array.isArray(c.categories)?c.categories:[],W=c.kind==="time"?x.map(se):x.map(fe);if(x.length&&!Y(W)){const Z=u&&typeof u.x=="string"&&u.x||c.dimension&&c.dimension.col||"";return r(V.NO_DOMAIN,`chart x ${Z?`column ${JSON.stringify(Z)} `:""}is drawn on a ${c.kind==="time"?"time":"continuous"} axis, and not one of its ${x.length} value(s) reads as a ${c.kind==="time"?"date":"number"} — so the axis would be drawn over a domain invented from nothing rather than measured from the data. Remove axis.x.scale to let the column choose its own scale, or type the column so its values parse.`)}}if(c&&c.bucketed&&g(m,c)){const{col:x,rows:W,fn:Z}=c.bucketed;return r(V.BUCKETED,S(x,W,Z),f(x))}return T}}),Ze("packages/modules/charts/bind.js",function(t,ue){"use strict";Object.defineProperty(t,"AGGREGATIONS",{enumerable:!0,get:function(){return R}}),Object.defineProperty(t,"DEFAULT_AGGREGATION",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"resolveAggregation",{enumerable:!0,get:function(){return S}}),Object.defineProperty(t,"defaultAggregationFor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(t,"measureOf",{enumerable:!0,get:function(){return P}}),Object.defineProperty(t,"accumulateSeries",{enumerable:!0,get:function(){return N}}),Object.defineProperty(t,"walkRows",{enumerable:!0,get:function(){return p}}),Object.defineProperty(t,"leafRows",{enumerable:!0,get:function(){return u}}),Object.defineProperty(t,"selectedRows",{enumerable:!0,get:function(){return m}}),Object.defineProperty(t,"topGroups",{enumerable:!0,get:function(){return c}}),Object.defineProperty(t,"forcedScaleKind",{enumerable:!0,get:function(){return W}}),Object.defineProperty(t,"scaleKindFor",{enumerable:!0,get:function(){return le}}),Object.defineProperty(t,"bindSeries",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(t,"bindPoints",{enumerable:!0,get:function(){return y}}),Object.defineProperty(t,"bindMeasures",{enumerable:!0,get:function(){return C}}),Object.defineProperty(t,"bindLinks",{enumerable:!0,get:function(){return D}}),Object.defineProperty(t,"bindHierarchy",{enumerable:!0,get:function(){return M}});const Le=ue("packages/modules/charts/scale.js"),Y=Le.key,fe=Le.toNumber,se=Le.toTime,ne=ue("packages/modules/charts/drawable.js"),n=ne.bucketKey,V=ne.bucketMessage,q=ue("packages/core/src/internal/warn.js").warnOnce,R={sum:e=>e.length?e.reduce((i,a)=>i+a,0):null,avg:e=>e.length?e.reduce((i,a)=>i+a,0)/e.length:null,mean:e=>e.length?e.reduce((i,a)=>i+a,0)/e.length:null,min:e=>{let i=null;for(let a=0;a<e.length;a++)(i===null||e[a]<i)&&(i=e[a]);return i},max:e=>{let i=null;for(let a=0;a<e.length;a++)(i===null||e[a]>i)&&(i=e[a]);return i},median:e=>{if(!e.length)return null;const i=e.slice().sort((te,ke)=>te-ke),a=(i.length-1)/2,A=Math.floor(a),$=Math.ceil(a);return A===$?i[A]:(i[A]+i[$])/2},count:(e,i)=>i,countValues:e=>e.length,countDistinct:e=>new Set(e).size,first:e=>e.length?e[0]:null,last:e=>e.length?e[e.length-1]:null},f="sum";function S(e){return e==null?f:typeof e=="string"&&e in R?e:(q(`chart:measure:fn:${String(e)}`,`chart measure fn ${JSON.stringify(e)} is not a known aggregation; using '${f}'. Supported: ${Object.keys(R).join(", ")}.`),f)}function g(e){if(!e)return f;const i=e.groupTotal??e.total;if(typeof i=="string"&&i in R)return i;const a=e.dataType&&e.dataType.totals?e.dataType.totals.supported:null;if(Array.isArray(a)&&!a.includes(f)){const A=["avg","mean","max","min","countValues","count"].find($=>a.includes($)&&$ in R);if(A)return A}return f}function P(e,i){const a=g(i);return e?typeof e=="string"?{col:e,fn:a,cumulative:!1}:{col:e.col||null,fn:e.fn==null?a:S(e.fn),cumulative:e.cumulative===!0}:{col:null,fn:a,cumulative:!1}}function N(e){for(const i of e){let a=null;for(const A of i.points)A.y!==null&&A.y!==void 0&&(a=(a===null?0:a)+A.y),A.y=a}}function p(e,i){const a=new Set,A=$=>{if(!$||a.has($)||(a.add($),i($),!$.group)||$.expanded)return;const te=$.filteredChildren||$.children;if(Array.isArray(te))for(const ke of te)A(ke)};e.rows.forEach(A)}function u(e){const i=[];return p(e,a=>{!a.group&&a.data!==null&&a.data!==void 0&&i.push(a)}),i}function m(e){const i=new Set(e.selection.keys());if(!i.size)return[];const a=[];return p(e,A=>{!A.group&&i.has(A.key)&&a.push(A)}),a}function c(e){const i=[];let a=1/0;return p(e,A=>{A.group&&(A.level<a&&(a=A.level,i.length=0),A.level===a&&i.push(A))}),i}function w(e,i,a){return i.group&&i.totals&&a in i.totals?fe(i.totals[a]):fe(e.rows.value(i.key,a))}function d(e,i,a,A){if(!i.group){const $=e.rows.text(i.key,a);if($)return $}return A==null?"":A instanceof Date?A.toISOString().slice(0,10):String(A)}function r(e,i){return(R[i]||R[f])(e.values,e.rows)}const v=Object.freeze(["number","currency","percent"]),l=Object.freeze(["date","datetime","timestamp","dateString"]),x=Object.freeze({auto:"",band:"category",category:"category",linear:"linear",time:"time"});function W(e){const i=e&&typeof e=="object"?e.axis:null;if(!i||typeof i!="object")return"";const a=i.x;if(!a||typeof a!="object")return"";const A=typeof a.scale=="string"?a.scale:"";return A?Object.hasOwn(x,A)?x[A]:(q(`chart:x:scale:unknown:${A}`,`chart axis.x.scale ${JSON.stringify(A)} is not a scale this chart draws. Use one of: ${Object.keys(x).join(", ")}. The scale was chosen from the column instead.`),""):""}function Z(e){if(e.length<3)return"";let i=0,a=0;for(const A of e){if(A==null||A===""||typeof A=="boolean")return"";fe(A)!==null?i++:typeof A=="string"&&se(A)!==null&&a++}return a===e.length?"time":i===e.length?"linear":""}function le(e,i,a={}){if(a.forced)return a.forced;const A=e&&typeof e.type=="string"?e.type:"";if(l.includes(A)||i.length&&i.every(ke=>ke instanceof Date))return"time";if(v.includes(A))return"linear";const $=a.id?String(a.id):"";if(!$)return"category";const te=A&&A!=="text"?"":Z(i);return te&&q(`chart:x:banded:${$}`,`chart x column ${JSON.stringify($)} is typed ${JSON.stringify(A||"text")}, so its ${i.length} values are drawn as categories on a band scale even though they all read as ${te==="time"?"dates":"numbers"}. Type the column ${te==="time"?"'date' (or 'datetime'/'timestamp'/'dateString')":"'number'"} for a continuous axis, or pin it with axis: { x: { scale: '${te}' } }.`),"category"}function oe(e,i){const a=i.x||null,A=i.series||(typeof i.multiples=="string"?i.multiples:null)||null,$=e.columns,te=a?$.get(a):void 0,ke=P(i.y),ge=ke.col?$.get(ke.col):void 0,ve=P(i.y,ge);let Pe;const Te=typeof i.rows=="function"?i.rows(e):i.rows;let _=!1;if(Array.isArray(Te)){const ee=Te.filter(E=>E&&typeof E=="object"&&(typeof E.key=="string"||typeof E.key=="number")&&e.rows.byKey(E.key)!==void 0);ee.length<Te.length&&(q("chart:rows:not-grid-rows",`chart "rows" takes rows the grid holds (from grid.rows.get(i) or grid.rows.byKey(key)); ${Te.length-ee.length} of ${Te.length} given are not and were left out. To chart other data, put it in a grid and chart that grid.`),_=ee.length===0),Pe=ee}else i.from==="groups"?Pe=c(e):i.from==="selection"?Pe=m(e):Pe=u(e);const pe=Pe.length||_?Pe:u(e),me=!!i.perRow,ie=new Map,Q=new Map,ye=[];for(let ee=0;ee<pe.length;ee++){const E=pe[ee],G=a?E.group&&E.groupColumn===a?E.groupValue:e.rows.value(E.key,a):ee,Me=me?`${Y(G)} ${ee}`:Y(G);ie.has(Me)||(ie.set(Me,{value:G,label:a?d(e,E,a,G):String(ee),order:ie.size,key:Me}),ye.push(G));const k=A?E.group&&E.groupColumn===A?E.groupValue:e.rows.value(E.key,A):null,j=A?Y(k):"";Q.has(j)||Q.set(j,{label:A?d(e,E,A,k):ge?.title||"",points:new Map});const X=Q.get(j);let ae=X.points.get(Me);ae||(ae={values:[],rows:0,rowKey:E.key},X.points.set(Me,ae)),ae.rows+=E.group&&E.leafCount||1,(i.editable||i.selection)&&(ae.keys||(ae.keys=[])).push(E.key);const be=ve.col?w(e,E,ve.col):null;if(be!==null&&ae.values.push(be),i.size){const Se=fe(e.rows.value(E.key,i.size));Se!==null&&(ae.sizes=(ae.sizes||0)+Se)}}const o=[...ie.values()].sort((ee,E)=>ee.order-E.order),H=typeof i.limit=="number"&&i.limit>0?o.slice(0,i.limit):o,s=le(te,ye,{forced:W(i),id:a});let h=null;s==="time"&&pe.length>1&&ie.size===1&&te&&(te.type==="date"||te.type==="dateString")&&(h={col:String(a),rows:pe.length,fn:ve.fn},q(n(h.col),V(h.col,h.rows,h.fn)));const I=v.includes(te&&typeof te.type=="string"?te.type:"")?[...H].sort((ee,E)=>(fe(ee.value)??0)-(fe(E.value)??0)):s==="time"?[...H].sort((ee,E)=>(se(ee.value)??1/0)-(se(E.value)??1/0)||0):H,K=[...Q.entries()].map(([ee,E],G)=>({key:ee,label:E.label,index:G,points:I.map(Me=>{const k=E.points.get(Me.key);return{x:Me.value,xKey:Y(Me.value),label:Me.label,y:k?r(k,ve.fn):null,size:k&&k.sizes!==void 0?k.sizes:null,rows:k?k.rows:0,rowKey:k?k.rowKey:null,...(i.editable||i.selection)&&k&&k.keys?{rowKeys:k.keys}:{},values:k&&k.values?k.values:null}})}));return ve.cumulative&&N(K),{series:K,categories:I.map(ee=>ee.value),labels:I.map(ee=>ee.label),kind:s,measure:{...ve,title:ge?.title||ve.col||""},dimension:{col:a,title:te?.title||a||""},empty:K.length===0||I.length===0,rows:pe.length,truncated:o.length-I.length,bucketed:h}}function y(e){const i=Array.isArray(e.points)?e.points:[],a=i.length>0&&i.every(te=>typeof te.x=="number"&&Number.isFinite(te.x)),A=te=>typeof te=="number"&&Number.isFinite(te)?te:null,$=i.map((te,ke)=>({x:te.x,xKey:Y(te.x),label:te.label!=null?String(te.label):String(te.x),y:A(te.y),size:A(te.size),lower:A(te.lower),upper:A(te.upper),rows:1,rowKey:te.key!=null?String(te.key):String(ke),values:null}));return{series:[{key:e.seriesKey||"",label:e.seriesLabel||"",index:0,points:$}],categories:$.map(te=>te.x),labels:$.map(te=>te.label),kind:a?"linear":"category",measure:{col:null,fn:"sum",title:e.measureTitle||""},dimension:{col:null,title:e.dimensionTitle||""},empty:$.length===0,rows:$.length,truncated:0}}function C(e,i){const a=Array.isArray(i.measures)?i.measures:[];if(!a.length)return oe(e,i);const A=a.map(ge=>{const ve=typeof ge=="string"?{col:ge}:ge;return{spec:ve,result:oe(e,{x:i.x,from:i.from,limit:i.limit,axis:i.axis,y:{col:ve.col,fn:ve.fn,cumulative:ve.cumulative===!0}})}}),$=A[0].result,te=new Map($.categories.map((ge,ve)=>[Y(ge),ve])),ke=A.map(({spec:ge,result:ve},Pe)=>{const Te=e.columns.get(ge.col),_=$.categories.map(()=>null),pe=ve.series[0];if(pe)for(const me of pe.points){const ie=te.get(me.xKey);ie!==void 0&&(_[ie]=me)}return{key:ge.col,label:ge.title||ge.label||Te&&Te.title||ge.col,index:Pe,mark:ge.type||null,axis:ge.axis==="right"?"right":"left",points:$.categories.map((me,ie)=>_[ie]||{x:me,xKey:Y(me),label:$.labels[ie],y:null,rows:0,rowKey:null})}});return{series:ke,categories:$.categories,labels:$.labels,kind:$.kind,measure:{col:null,fn:"sum",title:ke.map(ge=>ge.label).join(", ")},dimension:$.dimension,empty:!ke.length||!$.categories.length,rows:$.rows,truncated:$.truncated}}function D(e,i,a={}){const A=P(i.y),$=!!a.perRow,te=Array.isArray(a.nodes)?a.nodes:[],ke=i.source||i.x||null,ge=i.target||null;if(!ke||!ge)return{nodes:[],links:[],measure:{...A,title:""},dimension:{col:null,title:""},series:[],categories:[],labels:[],empty:!0,total:0};const ve=A.col?e.columns.get(A.col):void 0,Pe=new Map,Te=new Map,_=(Q,ye,o)=>{const H=Y(Q);return Pe.has(H)||Pe.set(H,{key:H,value:Q,label:d(e,ye,o,Q),index:Pe.size,in:0,out:0}),Pe.get(H)},pe=new Map;for(const Q of te)!Q||Q.id===null||Q.id===void 0||pe.set(Y(Q.id),Q);for(const Q of u(e)){const ye=e.rows.value(Q.key,ke),o=e.rows.value(Q.key,ge);if(ye==null||o===null||o===void 0)continue;const H=A.col?fe(e.rows.value(Q.key,A.col)):1;if(H===null||H<=0)continue;const s=_(ye,Q,ke),h=_(o,Q,ge);if($){const O=s.key>h.key,I=O?h:s,K=O?s:h;Te.set(`${I.key}\0${K.key}\0${Te.size}`,{source:I,target:K,value:H,undirected:!0,pair:`${I.key}\0${K.key}`,rowKeys:[Q.key]})}else{const O=`${s.key}\0${h.key}`,I=Te.get(O)||{source:s,target:h,value:0,rowKeys:[]};I.value+=H,I.rowKeys.length<64&&I.rowKeys.push(Q.key),Te.set(O,I)}s.out+=H,h.in+=H}for(const[Q,ye]of pe)Pe.has(Q)||Pe.set(Q,{key:Q,value:ye.id,label:String(ye.label??ye.id),index:Pe.size,in:0,out:0});for(const[Q,ye]of pe){const o=Pe.get(Q);o&&(o.declared=!0,ye.label!==void 0&&ye.label!==null&&(o.label=String(ye.label)),typeof ye.icon=="string"&&ye.icon&&(o.icon=ye.icon),Number.isFinite(ye.x)&&Number.isFinite(ye.y)&&(o.fx=Number(ye.x),o.fy=Number(ye.y)))}const me=$?[...Te.values()]:[...Te.values()].sort((Q,ye)=>ye.value-Q.value),ie=typeof i.limit=="number"&&i.limit>0?me.slice(0,i.limit):me;return{nodes:[...Pe.values()],links:ie,measure:{...A,title:ve?.title||A.col||""},dimension:{col:ke,title:e.columns.get(ke)?.title||ke},series:[],categories:[],labels:[],empty:!ie.length,total:ie.reduce((Q,ye)=>Q+ye.value,0)}}function M(e,i,a={}){if(typeof i.parentId=="string"&&i.parentId)return re(e,i,a);if(typeof i.path=="string"&&i.path)return z(e,i,a);const A=P(i.y),$=typeof i.depth=="number"&&i.depth>0?i.depth:1/0,te=A.col?e.columns.get(A.col):void 0,ke=i.radius&&typeof i.radius=="object"?i.radius:null,ge=ke&&typeof ke.col=="string"?P(ke.col):null,ve=ge&&ge.col?e.columns.get(ge.col):void 0,Pe=(Q,ye,o)=>({label:Q,value:ye,depth:o,total:0,radius:0,children:[],rowKey:null,rowKeys:[]}),Te=Pe("",null,0),_=c(e),pe=new Map;if(_.length){const Q=[];p(e,ye=>{if(ye.group){for(;Q.length&&Q[Q.length-1].level>=ye.level;)Q.pop();Q.push(ye),pe.has(ye.key)||pe.set(ye.key,[])}else if(ye.data!==null&&ye.data!==void 0)for(const o of Q)pe.get(o.key).push(ye.key)})}if(_.length){const Q=(ye,o,H)=>{const s=ye.groupColumn?d(e,ye,ye.groupColumn,ye.groupValue):"",h=Pe(s,ye.groupValue,H);h.rowKey=ye.key;const O=A.col?w(e,ye,A.col):null;if(h.total=O===null?0:Math.abs(O),ge&&ge.col){const K=w(e,ye,ge.col);h.radius=K===null?0:Math.abs(K)}o.children.push(h);const I=ye.filteredChildren||ye.children;if(h.rowKeys=[...pe.get(ye.key)||[]],H<$&&Array.isArray(I))for(const K of I)K.group&&Q(K,h,H+1);return!A.col&&a.count&&(h.total=h.rowKeys.length),!h.total&&h.children.length&&(h.total=h.children.reduce((K,ee)=>K+ee.total,0)),!h.radius&&ge&&h.children.length&&(h.radius=h.children.reduce((K,ee)=>K+ee.radius,0)),h};for(const ye of _)Q(ye,Te,1)}else{if(Array.isArray(i.x)&&i.x.length)return L(e,i,a);{const ye=oe(e,{x:i.x,y:i.y,limit:i.limit,editable:i.editable,selection:i.selection}).series[0];if(ye){const o=ye.points.map(()=>0);if(ge&&ge.col){const H=new Map(ye.points.map((s,h)=>[Y(s.x),h]));for(const s of u(e)){const h=i.x?e.rows.value(s.key,i.x):null,O=H.get(Y(h));if(O===void 0)continue;const I=w(e,s,ge.col);I!==null&&(o[O]+=Math.abs(I))}}for(let H=0;H<ye.points.length;H++){const s=ye.points[H],h=Pe(s.label,s.x,1);h.total=s.y===null?0:Math.abs(s.y),h.rowKey=s.rowKey,h.rowKeys=s.rowKeys||(s.rowKey?[s.rowKey]:[]),h.radius=o[H],Te.children.push(h)}}}}Te.total=Te.children.reduce((Q,ye)=>Q+ye.total,0);let me=0;const ie=Q=>{Q.depth>me&&(me=Q.depth);for(const ye of Q.children)ie(ye)};return ie(Te),{root:Te,depth:me,measure:{...A,title:te?.title||A.col||""},radius:ge?{...ge,title:ve?.title||ge.col||""}:null,empty:Te.total<=0||Te.children.length===0}}function J(e,i,a,A,$){let te=0;const ke=(ve,Pe)=>{ve.depth=Pe,Pe>te&&(te=Pe);for(const Te of ve.children)ke(Te,Pe+1);if(ve.children.length){const Te=ve.children.reduce((_,pe)=>_+pe.total,0);Te>0||!ve.own?ve.total=Te:ve.total=ve.own;for(const _ of ve.children)for(const pe of _.rowKeys)ve.rowKeys.push(pe)}else ve.total=ve.own||(!a.col&&$?1:0)};ke(i,0);const ge=a.col?e.columns.get(a.col):void 0;return{root:i,depth:te,measure:{...a,title:ge?.title||a.col||""},dimension:A,radius:null,empty:i.total<=0||i.children.length===0}}function F(e,i){return{label:e,value:i,depth:0,total:0,own:0,radius:0,children:[],rowKey:null,rowKeys:[]}}function re(e,i,a){const A=P(i.y),$=i.id||null,te=i.label||i.x||$,ke=F("",null),ge=new Map,ve=new Map;for(const Te of u(e)){const _=$?e.rows.value(Te.key,$):null,pe=_==null||_===""?Te.key:_,me=String(pe);if(ge.has(me))continue;const ie=te?e.rows.text(Te.key,te):"",Q=F(ie||me,pe);Q.rowKey=Te.key,Q.rowKeys=[Te.key];const ye=A.col?w(e,Te,A.col):null;Q.own=ye===null?0:Math.abs(ye),ge.set(me,Q);const o=e.rows.value(Te.key,i.parentId);ve.set(me,o==null||o===""?"":String(o))}for(const[Te,_]of ge){let pe=ve.get(Te),me=0;for(;pe&&ge.has(pe)&&pe!==Te&&me<=ge.size;)pe=ve.get(pe),me+=1;((!(me>ge.size||pe===Te)&&ve.get(Te)&&ve.get(Te)!==Te?ge.get(ve.get(Te)):null)||ke).children.push(_)}const Pe={col:te||i.parentId,title:e.columns.get(te||i.parentId)?.title||te||i.parentId};return J(e,ke,A,Pe,!!a.count)}function z(e,i,a){const A=P(i.y),$=typeof i.pathSeparator=="string"&&i.pathSeparator?i.pathSeparator:"/",te=F("",null),ke=new Map([[te,new Map]]);for(const ve of u(e)){const Pe=e.rows.value(ve.key,i.path);if(Pe==null||Pe==="")continue;const Te=String(Pe).split($).map(me=>me.trim()).filter(Boolean);let _=te;for(const me of Te){let ie=ke.get(_).get(me);ie||(ie=F(me,me),ke.get(_).set(me,ie),ke.set(ie,new Map),_.children.push(ie)),_=ie}if(_===te)continue;_.rowKey=_.rowKey||ve.key,_.rowKeys.push(ve.key);const pe=A.col?w(e,ve,A.col):null;_.own+=pe===null?0:Math.abs(pe),!A.col&&a.count&&(_.own+=1)}const ge={col:i.path,title:e.columns.get(i.path)?.title||i.path};return J(e,te,A,ge,!!a.count)}function U(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(typeof e.field=="string"&&e.field)return e.field;if(typeof e.col=="string"&&e.col)return e.col}return null}function L(e,i,a){const A=P(i.y),$=(Array.isArray(i.x)?i.x:[]).map(U).filter(Boolean),te=F("",null);if(!$.length)return J(e,te,A,{col:"",title:""},!!a.count);const ke=new Map([[te,new Map]]);for(const ve of u(e)){let Pe=te;for(let _=0;_<$.length;_++){const pe=$[_],me=e.rows.value(ve.key,pe);if(me==null||me==="")break;const ie=Y(me);let Q=ke.get(Pe).get(ie);Q||(Q=F(d(e,ve,pe,me),me),ke.get(Pe).set(ie,Q),ke.set(Q,new Map),Pe.children.push(Q)),Pe=Q}Pe.rowKey=Pe.rowKey||ve.key,Pe.rowKeys.push(ve.key);const Te=A.col?w(e,ve,A.col):null;Pe.own+=Te===null?0:Math.abs(Te),!A.col&&a.count&&(Pe.own+=1)}const ge={col:$[0],title:e.columns.get($[0])?.title||$[0]};return J(e,te,A,ge,!!a.count)}}),Ze("packages/modules/charts/engine.js",function(t,ue){"use strict";Object.defineProperty(t,"AGGREGATE_MODES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(t,"ENGINE_TYPES",{enumerable:!0,get:function(){return m}}),Object.defineProperty(t,"aggregateMode",{enumerable:!0,get:function(){return x}}),Object.defineProperty(t,"planAggregate",{enumerable:!0,get:function(){return le}}),Object.defineProperty(t,"holdsWindow",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(t,"boundFromGroups",{enumerable:!0,get:function(){return D}}),Object.defineProperty(t,"measureProvenance",{enumerable:!0,get:function(){return M}}),Object.defineProperty(t,"specMeasures",{enumerable:!0,get:function(){return J}});const Le=ue("packages/modules/charts/scale.js"),Y=Le.key,fe=Le.toNumber,se=ue("packages/modules/charts/bind.js"),ne=se.accumulateSeries,n=se.forcedScaleKind,V=se.measureOf,T=se.scaleKindFor,R=ue("packages/core/src/internal/warn.js").warnOnce,f=ue("packages/modules/shared/engine.js"),S=f.engineSource,g=f.gridEngineRequest,P=f.gridHoldsWindow,N=f.loadedAndMatching,p=f.sourceId,u=Object.freeze(["auto","engine","client"]),m=Object.freeze(new Set(["line","step","area","bar","horizontalBar","waterfall","combo","pareto","heatmap","radar","funnel","stream","marimekko"])),c=Object.freeze(new Set(["combo","bar","line","step","area"])),w=Object.freeze({mean:"avg"}),d="__rows",r="m",v="__size",l=/^[A-Za-z_][A-Za-z0-9_$]*$/;function x(F){const re=F?F.aggregate:void 0;return re==null?"auto":typeof re=="string"&&u.includes(re)?re:(R(`chart:aggregate:mode:${String(re)}`,`chart aggregate ${JSON.stringify(re)} is not a mode; use one of ${u.join(", ")}. The chart used 'auto'.`),"auto")}function W(F,re,z){const U=F.columns.get(re);if(!U)return`the ${z} column "${re}" is not a column of the grid`;const L=U.value&&typeof U.value=="object"?U.value:null;return U.computed||L&&(typeof L.get=="function"||typeof L.compute=="function")?`the ${z} column "${re}" is computed by the grid, which the engine cannot reproduce`:(typeof U.field=="string"?U.field:re)!==re||!l.test(re)?`the ${z} column "${re}" is not a plain physical column the engine can name`:z!=="measure"&&U.type==="geometry"?`the ${z} column "${re}" is a geometry, which charts group in the browser for now`:""}function Z(F,re,z){const U=c.has(z)&&Array.isArray(re.measures)&&re.measures.length>0;return(U?re.measures:[re.y]).map((e,i)=>{const a=V(e),A=a.col?F.columns.get(a.col):void 0,$=V(e,A),te=e&&typeof e=="object"?e:{};return{id:`${r}${i}`,col:$.col,fn:$.fn,stat:w[$.fn]||$.fn,label:U?te.title||te.label||A&&A.title||$.col||"":A&&A.title||$.col||"",mark:U&&te.type||null,axis:U&&te.axis==="right"?"right":"left",cumulative:$.cumulative,multi:U}})}function le(F,re,z){const U=x(re),L=(ie,Q=!1)=>({mode:"client",asked:U,reason:ie,refused:U==="engine",windowed:Q});if(U==="client")return{...L("aggregate: 'client' was asked for"),refused:!1};if(!m.has(z))return L(`a "${z}" chart does not draw a grouped aggregate`);if(Array.isArray(re.points))return L("the chart draws an explicit point set");if(re.rows)return L("the chart was handed its own rows");if(re.from==="groups"||re.from==="selection")return L(`the chart reads the grid's ${re.from==="groups"?"group rows":"selection"}`);if(re.error)return L("error bars need the readings behind each mark");const e=S(F);if("reason"in e)return L(e.reason);const{source:i,caps:a}=e;if(!a.group)return L("the source's adapter does not declare the `group` capability");const A=typeof re.x=="string"&&re.x?re.x:null;if(!A)return L("the chart names no x column to group by");const $=typeof re.series=="string"&&re.series?re.series:typeof re.multiples=="string"?re.multiples:null,te=Z(F,re,z),ke=te.length>0&&te[0].multi,ge=$&&!ke?[A,$]:[A];for(const[ie,Q]of ge.entries()){const ye=W(F,Q,ie===0?"x":"series");if(ye)return L(ye)}for(const ie of te){if(!ie.col)return L("a measure names no column to reduce");const Q=W(F,ie.col,"measure");if(Q)return L(Q);const ye=i.STAT_PUSHDOWN[ie.stat];if(!ye||!ye.pushable)return L(`"${ie.fn}" of "${ie.col}" is not a reduction the engine can compute`)}if(re.size){const ie=typeof re.size=="string"?W(F,re.size,"measure"):"the size channel is not a column";if(ie)return L(ie)}const ve=[...te.map(ie=>({id:ie.id,col:ie.col,fn:ie.stat})),{id:d,col:A,fn:"count"},...re.size?[{id:v,col:re.size,fn:"sum"}]:[]],Pe=i.resolveAggregatePlan(ve);if(Pe.client.length){const ie=Pe.client[0];return L(`the source computes "${ie.fn}" client-side (${ie.reason}); set the pushdown source's \`aggregates: { default: 'engine' }\` to compute it in the engine`)}const Te=g(F,e);if("reason"in Te)return L(Te.reason);const{quick:_}=Te,pe={...Te.request,groupBy:ge};if(U==="auto"){const{loaded:ie,total:Q}=N(F);if(Number.isFinite(Q)&&ie>=Q)return L("the grid holds every matching row")}const me=JSON.stringify([p(i),pe.filters,_,ge,ve]);return{mode:"engine",asked:U,key:me,source:i,request:pe,requested:ve,groupBy:ge,measures:te}}function oe(F){return P(F)}function y(F,re){if(re==null)return"";if(F&&typeof F.formatValue=="function")try{const z=F.formatValue(re,null);if(typeof z=="string"&&z)return z}catch{}return re instanceof Date?re.toISOString().slice(0,10):String(re)}function C(F,re){if(F==null)return re==null?0:1;if(re==null)return-1;const z=F instanceof Date?F.getTime():fe(F),U=re instanceof Date?re.getTime():fe(re);return typeof F!="string"&&typeof re!="string"&&z!==null&&U!==null?z-U:String(F).localeCompare(String(re))}function D(F,re,z,U){const{groupBy:L,measures:e}=z,i=L[0],a=L[1]||null,A=e[0].multi,$=F.columns.get(i),te=a?F.columns.get(a):void 0,ke=(U||[]).filter(h=>h&&h.level===L.length),ge=new Map,ve=new Map,Pe=new Map;for(const h of ke){const O=h.keys[0],I=Y(O);ge.has(I)||ge.set(I,O);const K=a?h.keys[1]:null,ee=a?Y(K):"";ve.has(ee)||ve.set(ee,K),Pe.set(`${ee}\0${I}`,h.values||{})}const Te=F.sort&&typeof F.sort.get=="function"?F.sort.get():[],_=Array.isArray(Te)&&Te[0]&&Te[0].col===i&&Te[0].dir==="desc",pe=[...ge.entries()].sort((h,O)=>C(h[1],O[1]));_&&pe.reverse();const me=typeof re.limit=="number"&&re.limit>0?pe.slice(0,re.limit):pe,ie=me.map(([,h])=>y($,h)),Q=me.map(([,h])=>h),ye=(h,O,I,K,ee)=>{const E=Pe.get(`${h}\0${O}`),G=E?fe(E[d]):null;return{x:I,xKey:O,label:K,y:E?fe(E[ee]):null,size:E&&re.size?fe(E[v]):null,rows:G===null?0:G,rowKey:null,values:null}};let o;if(A){o=e.map((h,O)=>({key:h.col,label:h.label,index:O,mark:h.mark,axis:h.axis,points:me.map(([I,K],ee)=>ye("",I,K,ie[ee],h.id))}));for(const[h,O]of e.entries())O.cumulative&&ne([o[h]])}else o=[...ve.entries()].sort((O,I)=>C(O[1],I[1])).map(([O,I],K)=>({key:O,label:a?y(te,I):e[0].label,index:K,points:me.map(([ee,E],G)=>ye(O,ee,E,ie[G],e[0].id))})),e[0].cumulative&&ne(o);const H=ke.reduce((h,O)=>h+(fe(O.values&&O.values[d])||0),0),s=T($,Q,{forced:n(re),id:i});return{series:o,categories:Q,labels:ie,kind:s,measure:A?{col:null,fn:"sum",title:o.map(h=>h.label).join(", ")}:{col:e[0].col,fn:e[0].fn,title:e[0].label},dimension:{col:i,title:$&&$.title||i},empty:o.length===0||me.length===0,rows:H,truncated:pe.length-me.length,bucketed:null}}function M(F,re,z=[],U=""){return F.map(L=>{const e=z.find(i=>i.id===L.id);return{col:L.col||null,fn:L.fn,computed:re,...e&&e.class?{class:e.class}:{},...re==="client"&&U?{reason:U}:{}}})}function J(F,re,z){try{return Z(F,re,z).filter(U=>U.col)}catch{return[]}}}),Ze("packages/core/src/internal/merge.js",function(t,ue){"use strict";Object.defineProperty(t,"expand",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(t,"toArray",{enumerable:!0,get:function(){return se}}),Object.defineProperty(t,"merge",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"mergeRow",{enumerable:!0,get:function(){return V}});const Y=ue("packages/core/src/internal/predicates.js").isObject;function fe(T,q,R){if(T!==void 0)return T===!0?{enabled:!0,...R}:T===!1?{enabled:!1}:Y(T)?T:{[q]:T,enabled:!0}}function se(T){return T==null?[]:Array.isArray(T)?T:[T]}const ne=Object.freeze(new Set(["__proto__","constructor","prototype"]));function n(T,q){if(!Y(T))return Y(q)?{...q}:q;if(!Y(q))return q===void 0?T:q;const R={...T};for(const f of Object.keys(q)){if(ne.has(f))continue;const S=q[f];S!==void 0&&(R[f]=Y(S)&&Y(R[f])?n(R[f],S):S)}return R}function V(T,q){if(!Y(T)||!Y(q)||T===q)return q;const R=Object.create(Object.getPrototypeOf(T));return Object.assign(R,T,q),R}}),Ze("packages/core/src/internal/compare.js",function(t,ue){"use strict";Object.defineProperty(t,"collator",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(t,"defaultCompare",{enumerable:!0,get:function(){return fe}});const Le=new Map;function Y(se,ne){const n=`${se||""}|${ne?JSON.stringify(ne):""}`;let V=Le.get(n);return V||(V=new Intl.Collator(se||void 0,{numeric:!0,sensitivity:"variant",...ne}),Le.set(n,V)),V}function fe(se,ne){if(se===ne)return 0;if(se==null)return 1;if(ne==null)return-1;if(typeof se=="number"&&typeof ne=="number")return Number.isNaN(se)?Number.isNaN(ne)?0:1:Number.isNaN(ne)||se<ne?-1:se>ne?1:0;const n=String(se),V=String(ne);return n<V?-1:n>V?1:0}}),Ze("packages/core/src/compute/handle.js",function(t,ue){"use strict";Object.defineProperty(t,"identity",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"rowCount",{enumerable:!0,get:function(){return V}}),Object.defineProperty(t,"bitReader",{enumerable:!0,get:function(){return R}}),Object.defineProperty(t,"presenceReader",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"dictSize",{enumerable:!0,get:function(){return S}}),Object.defineProperty(t,"dictValue",{enumerable:!0,get:function(){return g}}),Object.defineProperty(t,"multiValue",{enumerable:!0,get:function(){return P}}),Object.defineProperty(t,"valueReader",{enumerable:!0,get:function(){return N}}),Object.defineProperty(t,"numericTotalOrder",{enumerable:!0,get:function(){return p}}),Object.defineProperty(t,"valueComparator",{enumerable:!0,get:function(){return u}}),Object.defineProperty(t,"dictRanks",{enumerable:!0,get:function(){return m}}),Object.defineProperty(t,"isMissing",{enumerable:!0,get:function(){return c}});const Le=ue("packages/core/src/internal/compare.js"),Y=Le.collator,fe=Le.defaultCompare,ne=ue("packages/core/src/internal/warn.js").warnOnce;function n(w){const d=new Uint32Array(w);for(let r=0;r<w;r++)d[r]=r;return d}function V(w,d){if(d&&typeof d.count=="number")return d.count;if(!w)return 0;if(typeof w.count=="number")return w.count;if(typeof w.length=="number")return w.length;const r=w.values;return w.kind==="multi"&&w.offsets?Math.max(0,w.offsets.length-1):r?w.kind==="bitset"?typeof r.size=="number"?r.size:w.presence&&typeof w.presence.size=="number"?w.presence.size:(ne(`count:${w.id}`,`column "${w.id}" is bitset-backed with no declared row count; assuming ${r.length*8}`),r.length*8):r.length:w.presence&&typeof w.presence.size=="number"?w.presence.size:0}const T=new WeakMap;function q(w){const d=w.constructor;if(!d)return"unknown";const r=T.get(d);if(r)return r;let v="unknown";try{let l=null;typeof d.from=="function"?l=d.from([!1,!0]):(l=new d(8),l.set(1));const x=l&&l.words;x&&x.length&&(x[0]===2?v="lsb":x[0]===64&&(v="msb"))}catch{v="unknown"}return T.set(d,v),v}function R(w){if(!w)return()=>0;const d=w instanceof Uint8Array?w:w.words;if(d instanceof Uint8Array){const r=w instanceof Uint8Array?"lsb":q(w);if(r==="lsb")return v=>d[v>>>3]>>>(v&7)&1;if(r==="msb")return v=>d[v>>>3]>>>7-(v&7)&1}return typeof w.get=="function"?r=>w.get(r)?1:0:()=>0}function f(w){return!w||!w.presence?null:R(w.presence)}function S(w){return w?typeof w.size=="number"?w.size:typeof w.values=="function"?w.values().length:0:0}function g(w,d){return w?typeof w.valueOf=="function"?w.valueOf(d):typeof w.values=="function"?w.values()[d]:null:null}function P(w,d){const r=w.offsets,v=w.values;if(!r||!v)return[];const l=r[d],x=r[d+1];if(!(x>l))return[];const W=w.dict,Z=new Array(x-l);for(let le=l;le<x;le++)Z[le-l]=W?g(W,v[le]):v[le];return Z}function N(w){if(!w)return()=>{};const d=w.values,r=f(w),v=w.kind;if(v==="dictionary"){const l=w.dict;return r?x=>r(x)?g(l,d[x]):null:x=>g(l,d[x])}if(v==="bitset"){const l=R(d);return r?x=>r(x)?l(x)===1:null:x=>l(x)===1}if(v==="multi")return r?l=>r(l)?P(w,l):null:l=>P(w,l);if(!d&&typeof w.get=="function"){const l=w.get.bind(w);return x=>{const W=l(x);return W===void 0?null:W}}return r?l=>{if(!r(l))return null;const x=d[l];return x===void 0?null:x}:l=>{const x=d[l];return x===void 0?null:x}}function p(w,d){if(w<d)return-1;if(w>d)return 1;if(w===d){const l=Object.is(w,-0),x=Object.is(d,-0);return l===x?0:l?-1:1}const r=Number.isNaN(w),v=Number.isNaN(d);return r&&v?0:r?1:-1}function u(w){const d=Y(w);return(r,v)=>{if(r===v)return 0;const l=typeof r,x=typeof v;if(l==="string"&&x==="string")return d.compare(r,v);if(l==="number"&&x==="number")return p(r,v);if(l==="boolean"&&x==="boolean")return r===v?0:r?1:-1;if(r instanceof Date||v instanceof Date){const W=r instanceof Date?r.getTime():Number(r),Z=v instanceof Date?v.getTime():Number(v);return p(W,Z)}return fe(r,v)}}function m(w,d){if(w&&typeof w.ranks=="function")return w.ranks(d);const r=w&&typeof w.values=="function"?w.values():[],v=r.length,l=u(d),x=new Array(v);for(let Z=0;Z<v;Z++)x[Z]=Z;x.sort((Z,le)=>l(r[Z],r[le])||Z-le);const W=new Uint32Array(v);for(let Z=0;Z<v;Z++)W[x[Z]]=Z;return W}function c(w){return w==null||typeof w=="number"&&Number.isNaN(w)}}),Ze("packages/core/src/compute/filter.js",function(t,ue){"use strict";Object.defineProperty(t,"releaseMask",{enumerable:!0,get:function(){return w}}),Object.defineProperty(t,"compilePredicate",{enumerable:!0,get:function(){return C}}),Object.defineProperty(t,"wallMs",{enumerable:!0,get:function(){return re}}),Object.defineProperty(t,"testValue",{enumerable:!0,get:function(){return L}}),Object.defineProperty(t,"itemwisePredicate",{enumerable:!0,get:function(){return a}}),Object.defineProperty(t,"evaluateCondition",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(t,"evaluateFilters",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(t,"pruneColumn",{enumerable:!0,get:function(){return _}}),Object.defineProperty(t,"mentionsColumn",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(t,"compact",{enumerable:!0,get:function(){return me}}),Object.defineProperty(t,"declareOperators",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(t,"declaredOperator",{enumerable:!0,get:function(){return ye}});const Y=ue("packages/core/src/internal/predicates.js").isBlank,se=ue("packages/core/src/internal/merge.js").toArray,n=ue("packages/core/src/internal/warn.js").warnOnce,V=ue("packages/core/src/format/date.js"),T=V.toDate,q=V.toIsoDate,R=ue("packages/core/src/compute/handle.js"),f=R.bitReader,S=R.dictSize,g=R.dictValue,P=R.presenceReader,N=R.valueComparator,p=R.valueReader,u=/^\d{4}-\d{2}-\d{2}$/,m="\0null\0";function c(o,H){const s=o&&o.pool;if(s){const h=s.mask||s.acquireMask||s.acquire||s.take;if(typeof h=="function"){const O=h.call(s,H);if(O&&O.length>=H)return O}}return new Uint8Array(H)}function w(o,H){const s=o&&o.pool;if(!s||!H)return;const h=s.release||s.releaseMask||s.free||s.recycle;typeof h=="function"&&h.call(s,H)}function d(o,H,s){return o.fill(s,0,H),o}function r(o){return o==null||typeof o=="number"&&Number.isNaN(o)}function v(o,H){if(o==null)return o;if(H==="number")return typeof o=="number"?o:Number(o);if(H==="date"||H==="dateString"){const s=q(o);return s===null?l(o):s}return H==="boolean"?typeof o=="boolean"?o:o==="true"||o===1?!0:o==="false"||o===0?!1:!!o:o}function l(o){return o instanceof Date?o.getTime():typeof o=="number"?o:Date.parse(String(o))}function x(o){return typeof o=="number"?o:o instanceof Date?o.getTime():o==null||o===""?NaN:Number(o)}function W(o,H){const s=typeof o=="string"?o:String(o);return H?s:s.toLowerCase()}function Z(o,H){return o==null?m:typeof o=="string"?H?o:o.toLowerCase():o instanceof Date?o.getTime():o}function le(o,H,s){const h=new Set;for(const O of se(o)){const I=v(O,s);h.add(Z(I,H)),typeof I=="string"&&I!==""&&Number.isFinite(Number(I))?h.add(Number(I)):typeof I=="number"&&Number.isFinite(I)&&h.add(Z(String(I),H))}return h}function oe(o,H,s){if(o==null||H===null||H===void 0)return o==null&&H==null;const h=typeof o,O=typeof H;return h==="string"&&O==="string"?s?o===H:o.toLowerCase()===H.toLowerCase():o instanceof Date||H instanceof Date?l(o)===l(H):h==="number"&&O==="number"?o===H||Number.isNaN(o)&&Number.isNaN(H):h==="number"&&O==="string"?o===Number(H):h==="string"&&O==="number"?Number(o)===H:h==="boolean"||O==="boolean"?o===H:Array.isArray(o)&&Array.isArray(H)?o.length===H.length&&o.every((I,K)=>oe(I,H[K],s)):o===H}function y(o,H){try{if(o instanceof RegExp){const s=o.flags.replace(/[gy]/g,"");return new RegExp(o.source,H||s.includes("i")?s:`${s}i`)}return new RegExp(String(o),H?"":"i")}catch(s){return n(`regex:${String(o)}`,`filter operator "matches" received an invalid pattern: ${String(o)}`,s),null}}function C(o,H){if(o&&o.type==="datetime"&&D.has(o.op))return z(o,H);const s=U(o,H),h=o&&o.type;return h!=="date"&&h!=="dateString"?s:O=>s(typeof O=="string"&&u.test(O)?O:q(O)??O)}const D=new Set(["eq","ne","lt","lte","gt","gte","between","notBetween","in","notIn"]),M=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3})\d*)?)?)?$/,J=new Map;function F(o,H){let s=J.get(H);if(s===void 0){try{s=new Intl.DateTimeFormat("en-CA",{timeZone:H,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch{s=null}J.set(H,s)}if(!s)return null;const h={};for(const O of s.formatToParts(o))O.type!=="literal"&&(h[O.type]=O.value);return h}function re(o,H){if(o==null||o==="")return null;if(typeof o=="string"){const I=M.exec(o.trim());if(I)return Date.UTC(+I[1],+I[2]-1,+I[3],+(I[4]||0),+(I[5]||0),+(I[6]||0),+(I[7]||"0").padEnd(3,"0"))}const s=T(o);if(!s)return null;const h=s.getUTCMilliseconds(),O=H?F(s,H):null;return O?Date.UTC(+O.year,+O.month-1,+O.day,O.hour==="24"?0:+O.hour,+O.minute,+O.second,h):Date.UTC(s.getFullYear(),s.getMonth(),s.getDate(),s.getHours(),s.getMinutes(),s.getSeconds(),h)}function z(o,H){const s=typeof o.timeZone=="string"&&o.timeZone?o.timeZone:void 0,h=K=>re(K,s),O=Array.isArray(o.value)?o.value.map(h):h(o.value),I=U({...o,type:"number",value:O},H);return K=>I(re(K))}function U(o,H){const s=o&&o.op,h=!!(o&&o.caseSensitive),O=o&&o.type,I=N(H),K=ee=>E=>!ee(E);switch(s){case"eq":{const ee=v(o.value,O);return E=>oe(E,ee,h)}case"ne":{const ee=v(o.value,O);return E=>!oe(E,ee,h)}case"lt":case"lte":case"gt":case"gte":{const ee=v(o.value,O);if(r(ee))return()=>!1;const E=s==="lt"?-1:s==="lte"?0:s==="gt"?1:2;return G=>{if(r(G))return!1;const Me=I(G,ee);return E===-1?Me<0:E===0?Me<=0:E===1?Me>0:Me>=0}}case"between":case"notBetween":{const ee=se(o.value),E=v(ee[0],O),G=v(ee[1],O),Me=o.bounds||"[]",k=Me.charAt(0)!=="(",j=Me.charAt(1)!==")";if(r(E)||r(G))return s==="between"?()=>!1:()=>!0;const X=ae=>{if(r(ae))return!1;const be=I(ae,E),Se=I(ae,G);return(k?be>=0:be>0)&&(j?Se<=0:Se<0)};return s==="between"?X:K(X)}case"in":case"notIn":{const ee=le(o.value,h,O),E=G=>ee.has(Z(G,h));return s==="in"?E:K(E)}case"contains":case"notContains":{const ee=W(v(o.value,O),h),E=G=>G==null?!1:W(G,h).includes(ee);return s==="contains"?E:K(E)}case"startsWith":{const ee=W(v(o.value,O),h);return E=>E==null?!1:W(E,h).startsWith(ee)}case"endsWith":{const ee=W(v(o.value,O),h);return E=>E==null?!1:W(E,h).endsWith(ee)}case"matches":{const ee=y(o.value,h);return ee?E=>E==null?!1:ee.test(String(E)):()=>!1}case"blank":case"notBlank":{const ee=o.trim===!0,E=G=>Y(G)||Array.isArray(G)&&G.length===0||ee&&typeof G=="string"&&G.trim()==="";return s==="blank"?E:G=>!E(G)}case"containsAny":case"containsNone":{const ee=le(o.value,h,O),E=G=>{const Me=G==null?[]:se(G);for(let k=0;k<Me.length;k++)if(ee.has(Z(Me[k],h)))return!0;return!1};return s==="containsAny"?E:K(E)}case"containsAll":{const ee=se(o.value).map(E=>Z(v(E,O),h));return E=>{const G=E==null?[]:se(E);if(ee.length===0)return!0;const Me=new Set(G.map(k=>Z(k,h)));for(let k=0;k<ee.length;k++)if(!Me.has(ee[k]))return!1;return!0}}default:{const ee=ye(s);return ee?ee.compile(o.value):(n(`op:${String(s)}`,`unknown filter operator "${String(s)}"; the condition is refused rather than matching every row`),()=>!1)}}}function L(o,H,s){return C(H,s)(o)}const e=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),i=new Set(["containsAny","containsAll","containsNone"]);function a(o,H,s){const h=o&&o.op,O=e[h]||h,I=C({...o,op:O,type:H.type},s),K=H.items,ee=E=>{const G=K(E);if(!G)return!1;for(let Me=0;Me<G.length;Me++)if(I(G[Me]))return!0;return!1};return e[h]?E=>!ee(E):ee}function A(o,H,s,h,O){const I=O?null:P(o);if(I){const E=H?1:0;for(let G=0;G<h;G++)s[G]=I(G)===E?1:0;return s}const K=o.kind;if(K==="float64"||K==="int32"||K==="bitset")return d(s,h,H?1:0);const ee=p(o);for(let E=0;E<h;E++){const G=ee(E),Me=Y(G)||Array.isArray(G)&&G.length===0||O&&typeof G=="string"&&G.trim()==="";s[E]=Me===H?0:1}return s}function $(o,H,s,h){const O=o.dict,I=S(O),K=new Uint8Array(I);for(let Me=0;Me<I;Me++)K[Me]=H(g(O,Me))?1:0;const ee=o.values,E=P(o);if(!E){for(let Me=0;Me<h;Me++)s[Me]=K[ee[Me]];return s}const G=H(null)?1:0;for(let Me=0;Me<h;Me++)s[Me]=E(Me)===1?K[ee[Me]]:G;return s}function te(o,H,s,h){const O=f(o.values),I=H(!0)?1:0,K=H(!1)?1:0,ee=P(o);if(!ee){for(let G=0;G<h;G++)s[G]=O(G)===1?I:K;return s}const E=H(null)?1:0;for(let G=0;G<h;G++)s[G]=ee(G)===0?E:O(G)===1?I:K;return s}function ke(o,H,s,h,O){const I=o.values,K=H.type,ee=H.op;let E=!0;switch(ee){case"eq":case"ne":{const Me=x(v(H.value,K)),k=typeof H.value=="number"&&Number.isNaN(H.value),j=ee==="ne"?1:0;if(k)for(let X=0;X<O;X++)h[X]=(Number.isNaN(I[X])?1:0)^j;else for(let X=0;X<O;X++)h[X]=(I[X]===Me?1:0)^j;break}case"lt":{const Me=x(v(H.value,K));for(let k=0;k<O;k++)h[k]=I[k]<Me?1:0;break}case"lte":{const Me=x(v(H.value,K));for(let k=0;k<O;k++)h[k]=I[k]<=Me?1:0;break}case"gt":{const Me=x(v(H.value,K));for(let k=0;k<O;k++)h[k]=I[k]>Me?1:0;break}case"gte":{const Me=x(v(H.value,K));for(let k=0;k<O;k++)h[k]=I[k]>=Me?1:0;break}case"between":case"notBetween":{const Me=se(H.value),k=x(v(Me[0],K)),j=x(v(Me[1],K)),X=H.bounds||"[]",ae=X.charAt(0)!=="(",be=X.charAt(1)!==")",Se=ee==="notBetween"?1:0;if(ae&&be)for(let Ae=0;Ae<O;Ae++)h[Ae]=(I[Ae]>=k&I[Ae]<=j?1:0)^Se;else if(ae)for(let Ae=0;Ae<O;Ae++)h[Ae]=(I[Ae]>=k&I[Ae]<j?1:0)^Se;else if(be)for(let Ae=0;Ae<O;Ae++)h[Ae]=(I[Ae]>k&I[Ae]<=j?1:0)^Se;else for(let Ae=0;Ae<O;Ae++)h[Ae]=(I[Ae]>k&I[Ae]<j?1:0)^Se;break}case"in":case"notIn":{const Me=new Set;for(const j of se(H.value)){const X=x(v(j,K));Number.isNaN(X)||Me.add(X)}const k=ee==="notIn"?1:0;for(let j=0;j<O;j++)h[j]=(Me.has(I[j])?1:0)^k;break}default:E=!1;break}if(!E)return!1;const G=P(o);if(G){const Me=s(null)?1:0;for(let k=0;k<O;k++)G(k)===0&&(h[k]=Me)}return!0}function ge(o,H,s,h){const O=p(o);for(let I=0;I<h;I++)s[I]=H(O(I))?1:0;return s}function ve(o,H,s){const h=H.count|0,O=s||c(H,h);if(!o)return d(O,h,1);const I=typeof H.handle=="function"?H.handle(o.col):void 0,K=typeof H.custom=="function"?H.custom:null;if(!I){if(K){for(let Me=0;Me<h;Me++)O[Me]=K(o,Me)?1:0;return O}return n(`filter:col:${String(o.col)}`,`filter references unknown column "${String(o.col)}"; the condition is refused rather than matching every row`),d(O,h,0)}const ee=o.op;if(ee==="blank"||ee==="notBlank")return A(I,ee==="notBlank",O,h,o.trim===!0);const E=typeof H.itemwise=="function"?H.itemwise(o.col):null;if(E&&!ye(ee)&&!i.has(ee))return ge(I,a(o,E,H.locale),O,h);const G=C(o,H.locale);switch(I.kind){case"dictionary":return $(I,G,O,h);case"bitset":return te(I,G,O,h);case"float64":case"int32":return ke(I,o,G,O,h)?O:ge(I,G,O,h);default:return ge(I,G,O,h)}}function Pe(o,H,s){if(!o)return d(c(H,s),s,1);if(Array.isArray(o.conditions)){const h=o.conditions.filter(K=>K!=null),O=o.op==="or"?"or":o.op==="not"?"not":"and";if(h.length===0)return d(c(H,s),s,1);const I=Pe(h[0],H,s);for(let K=1;K<h.length;K++){const ee=Pe(h[K],H,s);if(O==="or")for(let E=0;E<s;E++)I[E]|=ee[E];else for(let E=0;E<s;E++)I[E]&=ee[E];w(H,ee)}if(O==="not")for(let K=0;K<s;K++)I[K]^=1;return I}return ve(o,H,c(H,s))}function Te(o,H){return Pe(o,H,H.count|0)}function _(o,H){if(!o||!H)return o||null;const s=o;if(Array.isArray(s.conditions)){if((s.op==="or"?"or":s.op==="not"?"not":"and")!=="and")return pe(s,H)?null:o;const O=[];for(const I of s.conditions){const K=_(I,H);K&&O.push(K)}return O.length?{...s,op:"and",conditions:O}:null}return s.col===H?null:o}function pe(o,H){if(!o||typeof o!="object")return!1;const s=o;if(s.col===H)return!0;if(Array.isArray(s.conditions)){for(const h of s.conditions)if(pe(h,H))return!0}return!1}function me(o,H,s){if(s&&s.length>=H){let K=0;for(let ee=0;ee<H;ee++)o[ee]&&(s[K++]=ee);return s.subarray(0,K)}let h=0;for(let K=0;K<H;K++)h+=o[K]?1:0;const O=new Uint32Array(h);let I=0;for(let K=0;K<H;K++)o[K]&&(O[I++]=K);return O}const ie=new Map;function Q(o){if(!(!o||typeof o!="object"))for(const[H,s]of Object.entries(o))s&&typeof s.compile=="function"&&ie.set(H,s)}function ye(o){return typeof o=="string"?ie.get(o):void 0}}),Ze("packages/modules/charts/viewport-filter.js",function(t,ue){"use strict";Object.defineProperty(t,"VIEWPORT_FILTER_DEBOUNCE_MS",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(t,"resolveViewportFilter",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(t,"viewportTarget",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"viewportBbox",{enumerable:!0,get:function(){return V}}),Object.defineProperty(t,"sameBbox",{enumerable:!0,get:function(){return T}}),Object.defineProperty(t,"findColumnCondition",{enumerable:!0,get:function(){return q}}),Object.defineProperty(t,"viewportCondition",{enumerable:!0,get:function(){return R}}),Object.defineProperty(t,"conditionBbox",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"pruneTarget",{enumerable:!0,get:function(){return g}}),Object.defineProperty(t,"mergeViewportCondition",{enumerable:!0,get:function(){return P}}),Object.defineProperty(t,"adoptedGeoView",{enumerable:!0,get:function(){return N}});const Y=ue("packages/core/src/compute/filter.js").pruneColumn,fe=150,se=1e-6;function ne(p){const u={enabled:!1,column:null,debounce:fe};if(p==null||p===!1)return u;const m=p===!0?{}:p;if(typeof m!="object")return u;const c=typeof m.column=="string"&&m.column?m.column:null,w=Number.isFinite(m.debounce)&&m.debounce>=0?Number(m.debounce):fe;return{enabled:!0,column:c,debounce:w}}function n(p,u){return typeof u=="string"&&u?{kind:"geometry",column:u}:p&&typeof p.geometry=="string"&&p.geometry?{kind:"geometry",column:p.geometry}:p&&typeof p.lon=="string"&&p.lon&&typeof p.lat=="string"&&p.lat?{kind:"lonlat",lon:p.lon,lat:p.lat}:null}function V(p,u){if(!p||!u||typeof p.xScale?.invert!="function"||typeof p.yScale?.invert!="function")return null;const m=p.xScale.invert(u.left),c=p.xScale.invert(u.right),w=p.yScale.invert(u.bottom),d=p.yScale.invert(u.top);if(![m,c,w,d].every(Number.isFinite))return null;const r=Math.max(-180,Math.min(m,c)),v=Math.min(180,Math.max(m,c)),l=Math.max(-90,Math.min(w,d)),x=Math.min(90,Math.max(w,d));return!(v>r)||!(x>l)?null:[r,l,v,x]}function T(p,u){return!p||!u?!p&&!u:Math.abs(p[0]-u[0])<=se&&Math.abs(p[1]-u[1])<=se&&Math.abs(p[2]-u[2])<=se&&Math.abs(p[3]-u[3])<=se}function q(p,u){if(!p)return null;if(Array.isArray(p.conditions)){for(const m of p.conditions){const c=q(m,u);if(c)return c}return null}return p.col===u?p:null}function R(p,u,m){const[c,w,d,r]=u,v=m?{meta:{label:m}}:{};return p.kind==="geometry"?{col:p.column,op:"withinBbox",value:[c,w,d,r],...v}:{op:"and",conditions:[{col:p.lon,op:"between",value:[c,d]},{col:p.lat,op:"between",value:[w,r]}],...v}}function f(p,u){if(!p||!u)return null;if(u.kind==="geometry"){const l=q(p,u.column);if(!l||l.op!=="withinBbox"||!Array.isArray(l.value)||l.value.length<4)return null;const x=l.value.map(Number);return x.every(Number.isFinite)?x:null}const m=q(p,u.lon),c=q(p,u.lat);if(!m||m.op!=="between"||!Array.isArray(m.value)||m.value.length<2||!c||c.op!=="between"||!Array.isArray(c.value)||c.value.length<2)return null;const[w,d]=m.value.map(Number),[r,v]=c.value.map(Number);return[w,r,d,v].every(Number.isFinite)?[w,r,d,v]:null}function S(p){return p.kind==="geometry"?[p.column]:[p.lon,p.lat]}function g(p,u){let m=p||null;for(const c of S(u))m=Y(m,c);return m}function P(p,u,m){const c=g(p,u);return c?{op:"and",conditions:[...c.conditions||[c],m]}:m}function N(p,u,m,c){if(!p||!u||!m||!c||!(c.scale>0))return null;const[w,d,r,v]=p,[l,x,W,Z]=u,le=r-w,oe=v-d,y=W-l,C=Z-x;if(!(le>0)||!(oe>0)||!(y>0)||!(C>0))return null;const D=(l+W)/2,M=(x+Z)/2,J=m.left+(D-w)/le*(m.right-m.left),F=m.bottom-(M-d)/oe*(m.bottom-m.top);if(!Number.isFinite(J)||!Number.isFinite(F))return null;const re=(m.left+m.right)/2,z=(m.top+m.bottom)/2,U=re-J,L=z-F,[e,i]=c.offset,a=[e-U/c.scale,i+L/c.scale],A=Math.min(le/y,oe/C);return!Number.isFinite(A)||A<=0?null:{zoom:Math.min(8,Math.max(1,c.zoom*A)),offset:a}}}),Ze("packages/modules/charts/mapview.js",function(t,ue){"use strict";Object.defineProperty(t,"MAP_ENGINE_TYPES",{enumerable:!0,get:function(){return P}}),Object.defineProperty(t,"DEFAULT_VIEWPORT_CAP",{enumerable:!0,get:function(){return N}}),Object.defineProperty(t,"DENSITY_CELLS_ACROSS",{enumerable:!0,get:function(){return p}}),Object.defineProperty(t,"DENSITY_FIT_PASSES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(t,"FRAME_REFIT_RATIO",{enumerable:!0,get:function(){return m}}),Object.defineProperty(t,"viewportCap",{enumerable:!0,get:function(){return d}}),Object.defineProperty(t,"densityCellSize",{enumerable:!0,get:function(){return r}}),Object.defineProperty(t,"boxSpan",{enumerable:!0,get:function(){return v}}),Object.defineProperty(t,"ringsBox",{enumerable:!0,get:function(){return l}}),Object.defineProperty(t,"needsRefit",{enumerable:!0,get:function(){return x}}),Object.defineProperty(t,"frameMoved",{enumerable:!0,get:function(){return W}}),Object.defineProperty(t,"planMapViewport",{enumerable:!0,get:function(){return le}}),Object.defineProperty(t,"engineRowsReader",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(t,"frameOf",{enumerable:!0,get:function(){return y}}),Object.defineProperty(t,"capClientBound",{enumerable:!0,get:function(){return D}});const Y=ue("packages/core/src/internal/warn.js").warnOnce,fe=ue("packages/modules/shared/engine.js"),se=fe.engineSource,ne=fe.gridEngineRequest,n=fe.loadedAndMatching,V=fe.sourceId,q=ue("packages/modules/charts/engine.js").aggregateMode,R=ue("packages/modules/charts/viewport-filter.js"),f=R.conditionBbox,S=R.viewportCondition,g=R.viewportTarget,P=Object.freeze(new Set(["markermap","bubblemap","choropleth"])),N=2e4,p=24,u=8,m=2,c="__viewport_rows",w=/^[A-Za-z_][A-Za-z0-9_$]*$/;function d(M){const J=M?M.viewportCap:void 0;return J==null?N:typeof J=="number"&&Number.isInteger(J)&&J>0?J:(Y(`chart:viewportCap:${String(J)}`,`chart viewportCap ${JSON.stringify(J)} is not a positive whole number of rows; the map used ${N}.`),N)}function r(M){const J=Number.isFinite(M)&&M>0?Math.min(360,M):360,F=2**Math.floor(Math.log2(J/p));return Math.min(90,Math.max(2**-20,F))}function v(M){return Math.max(M[2]-M[0],M[3]-M[1])}function l(M){let J=1/0,F=1/0,re=-1/0,z=-1/0;for(const U of M||[])for(const[L,e]of U)!Number.isFinite(L)||!Number.isFinite(e)||(J=Math.min(J,L),re=Math.max(re,L),F=Math.min(F,e),z=Math.max(z,e));return re>=J&&z>=F?[J,F,re,z]:null}function x(M,J){if(!M||!J)return!1;for(const[F,re]of[[0,2],[1,3]]){const z=M[re]-M[F],U=J[re]-J[F];if(!(z>0)||!(U>0))continue;const L=z/U;if(L>m||L<1/m)return!0}return!1}function W(M,J){if(!M||!J)return!!J;const F=1e-9;return!(J[0]>=M[0]-F&&J[1]>=M[1]-F&&J[2]<=M[2]+F&&J[3]<=M[3]+F)||x(M,J)}function Z(M,J,F){const re=M.columns.get(J);if(!re)return`the ${F} column "${J}" is not a column of the grid`;const z=re.value&&typeof re.value=="object"?re.value:null;return re.computed||z&&(typeof z.get=="function"||typeof z.compute=="function")?`the ${F} column "${J}" is computed by the grid, which the engine cannot reproduce`:(typeof re.field=="string"?re.field:J)!==J||!w.test(J)?`the ${F} column "${J}" is not a plain physical column the engine can name`:""}function le(M,J,F,re){const z=q(J),U=I=>({mode:"client",asked:z,reason:I,refused:z==="engine"});if(z==="client")return{...U("aggregate: 'client' was asked for"),refused:!1};if(!P.has(F))return U(`a "${F}" chart does not draw a viewport`);if(J.rows)return U("the chart was handed its own rows");const L=g(J);if(!L)return U("the map names neither a geometry column nor lon/lat columns");if(L.kind==="geometry"&&(J.lon||J.lat))return U("the map names both a geometry column and lon/lat columns");const e=L.kind==="geometry"?[L.column]:[L.lon,L.lat];for(const I of e){const K=Z(M,I,"placement");if(K)return U(K)}const i=se(M);if("reason"in i)return U(i.reason);const{source:a,caps:A}=i,$=a.adapter;if(!$||typeof $.execute!="function")return U("the source's adapter has no execute() to fetch rows with");const te=e[0],ke=a.resolveAggregatePlan([{id:c,col:te,fn:"count"}]);if(ke.client.length)return U(`the source computes "count" client-side (${ke.client[0].reason}); set the pushdown source's \`aggregates: { default: 'engine' }\` to count in the engine`);const ge=Array.isArray(re&&re.bbox)?re.bbox:null,ve=ge?S(L,ge):null,Pe=ne(M,i,ve);if("reason"in Pe)return U(Pe.reason);if(z==="auto"){const{loaded:I,total:K}=n(M);if(Number.isFinite(K)&&I>=K)return U("the grid holds every matching row")}const Te=d(J),_=ge||f(M.filters&&typeof M.filters.get=="function"?M.filters.get():null,L),pe=_?r(v(_)):null,me=L.kind==="geometry"&&F!=="choropleth"&&Array.isArray(A.buckets)&&A.buckets.includes("grid")&&typeof $.executeGroupedAggregates=="function",ie=F==="choropleth"?"a choropleth draws each shape, and has no density form":L.kind!=="geometry"?"the engine bins a geometry column, and this map places its rows by lon/lat":"the source's adapter cannot bin a geometry column into grid cells (no `buckets` capability)",{request:Q,quick:ye}=Pe,o=ne(M,i),H=JSON.stringify([V(a),"request"in o?o.request.filters:null,ye]),s=JSON.stringify([V(a),Q.filters,ye,L,Te,F]),h=JSON.stringify([s,me?pe||"fit":0]);return{mode:"engine",asked:z,key:h,rowsKey:s,baseKey:H,cap:Te,bbox:ge,box:_,cellSize:pe,run:async I=>{const K=I?{signal:I}:{},ee=await a.aggregate({...Q,...K},[{id:c,col:te,fn:"count"}]);if(ee&&Array.isArray(ee.client)&&ee.client.length)return{map:!0,refused:`the source counted client-side (${ee.client[0].reason})`};const E=Number(ee&&ee.values?ee.values[c]:NaN);if(!Number.isFinite(E))return{map:!0,refused:"the engine did not report a count for the view"};if(E<=Te){const k={...Q,range:{start:0,end:Te}},j=a.planQuery(k,A).pushed,X=await $.execute({...j,...K},{...k,...K});return{map:!0,kind:"rows",rows:(X&&Array.isArray(X.rows)?X.rows:[]).slice(0,Te),count:E,cap:Te,bbox:ge,rowsKey:s}}if(!me)return{map:!0,kind:"over",count:E,cap:Te,bbox:ge,reason:ie};let G=pe||r(360),Me=[];for(let k=1;;k++){const j=await a.aggregate({...Q,groupBy:[{col:L.column,bucket:"grid",size:G}],...K},[{id:c,col:te,fn:"count"}]);if(j&&Array.isArray(j.client)&&j.client.length)return{map:!0,kind:"over",count:E,cap:Te,bbox:ge,reason:`the source binned client-side (${j.client[0].reason})`};Me=[];for(const be of j&&j.groups||[]){if(!be||be.level!==1||!Array.isArray(be.keys)||!Array.isArray(be.keys[0]))continue;const[Se,Ae]=be.keys[0].map(Number),ze=Number(be.values?be.values[c]:NaN);!Number.isFinite(Se)||!Number.isFinite(Ae)||!(ze>0)||Me.push({west:Se*G,south:Ae*G,east:(Se+1)*G,north:(Ae+1)*G,count:ze})}if(pe||k>=u)break;const X=l(y([],Me));if(!X)break;const ae=r(v(X));if(ae>=G)break;G=ae}return{map:!0,kind:"density",cells:Me,count:E,cap:Te,bbox:ge,size:G}}}}function oe(M,J){const F=typeof M.config=="function"?M.config():{},re=F&&typeof F.rowKey=="string"?F.rowKey:null,z=M.permissions&&typeof M.permissions.levelOf=="function"?M.permissions:null,U=new Map,L=J.map((a,A)=>{const $=re&&a&&a[re]!==void 0&&a[re]!==null?a[re]:`engine:${A}`,te=U.has($)?`engine:${A}`:$,ke={key:te,data:a,group:!1};return U.set(te,ke),ke}),e=a=>{if(!z)return!0;const A=z.levelOf(a);return A==="read"||A==="write"},i=(a,A)=>{const $=U.get(a);if(!$||!e(A))return;const te=M.columns.get(A),ke=te&&typeof te.field=="string"?te.field:A,ge=$.data?$.data[ke]:void 0,ve=te&&te.dataType;if(ve&&typeof ve.toStorage=="function"&&ge!==null&&ge!==void 0)try{return ve.toStorage(ge,{colId:A})}catch{return null}return ge};return{columns:M.columns,formatting:M.formatting,messages:M.messages,rows:{count:()=>L.length,get:a=>L[a],value:i,text:(a,A)=>{const $=i(a,A);if($==null)return"";const te=M.columns.get(A);if(te&&typeof te.formatValue=="function")try{const ke=te.formatValue($,U.get(a));if(typeof ke=="string")return ke}catch{}return String($)}}}}function y(M,J=[]){let F=1/0,re=1/0,z=-1/0,U=-1/0;for(const $ of M||[])!Number.isFinite($.lon)||!Number.isFinite($.lat)||(F=Math.min(F,$.lon),z=Math.max(z,$.lon),re=Math.min(re,$.lat),U=Math.max(U,$.lat));for(const $ of J||[])F=Math.min(F,$.west),z=Math.max(z,$.east),re=Math.min(re,$.south),U=Math.max(U,$.north);if(!(z>=F)||!(U>=re))return null;const L=($,te)=>Math.max(-te,Math.min(te,$)),e=L(F,180),i=L(z,180),a=L(re,90),A=L(U,90);return[[[e,a],[i,a],[i,A],[e,A]]]}function C(M,J){if(!J)return!0;const[F,re,z,U]=J,L=(e,i)=>e>=F&&e<=z&&i>=re&&i<=U;if(M.point)return L(M.point[0],M.point[1]);for(const e of M.polygons||[])for(const i of e)for(const[a,A]of i)if(L(a,A))return!0;return!1}function D(M,J,F,re){const z=d(F),U=re&&Array.isArray(re.bbox)?re.bbox:null;if(!J||!P.has(M))return{bound:J,viewport:null};if(M==="choropleth"){const Pe=J.features||[];if(Pe.length<=z)return{bound:J,viewport:null};let Te=0;for(const me of Pe)C(me,U)&&Te++;if(Te<=z)return{bound:J,viewport:null};const _=[];for(const me of Pe){me.point&&_.push({lon:me.point[0],lat:me.point[1]});for(const ie of me.polygons||[])for(const Q of ie)for(const[ye,o]of Q)_.push({lon:ye,lat:o})}const pe="a choropleth draws each shape, and has no density form";return{bound:{...J,features:[],empty:!1,over:{count:Te,cap:z,reason:pe},frame:J.frame||y(_)},viewport:{rows:0,matched:Te,cap:z,binned:!1,cells:0,over:pe,bbox:U?[...U]:null,computed:"client"}}}const L=J.points||[];if(L.length<=z)return{bound:J,viewport:null};const[e,i,a,A]=U||[-1/0,-1/0,1/0,1/0],$=L.filter(Pe=>Pe.lon>=e&&Pe.lon<=a&&Pe.lat>=i&&Pe.lat<=A);if($.length<=z)return{bound:J,viewport:null};const te=U||l([$.map(Pe=>[Pe.lon,Pe.lat])]),ke=r(te?v(te):360),ge=new Map;for(const Pe of $){const Te=Math.floor(Pe.lon/ke),_=Math.floor(Pe.lat/ke),pe=`${Te}:${_}`,me=ge.get(pe)||{west:Te*ke,south:_*ke,east:(Te+1)*ke,north:(_+1)*ke,count:0};me.count++,ge.set(pe,me)}const ve=[...ge.values()];return{bound:{...J,density:{cells:ve,size:ke},frame:J.frame||y(L)},viewport:{rows:0,matched:$.length,cap:z,binned:!0,cells:ve.length,over:null,bbox:U?[...U]:null,computed:"client"}}}}),Ze("packages/modules/shared/map-binding.js",function(t,ue){"use strict";Object.defineProperty(t,"clampBox",{enumerable:!0,get:function(){return u}}),Object.defineProperty(t,"resolvePosition",{enumerable:!0,get:function(){return m}}),Object.defineProperty(t,"createMapFeed",{enumerable:!0,get:function(){return c}}),Object.defineProperty(t,"createViewportSync",{enumerable:!0,get:function(){return w}});const Y=ue("packages/modules/geometry/geodata.js").readGeometry,se=ue("packages/modules/shared/engine.js").EngineFlight,ne=ue("packages/modules/charts/mapview.js"),n=ne.planMapViewport,V=ne.engineRowsReader,T=ne.viewportCap,q=ue("packages/modules/charts/viewport-filter.js"),R=q.resolveViewportFilter,f=q.viewportTarget,S=q.viewportCondition,g=q.mergeViewportCondition,P=q.conditionBbox,N=q.pruneTarget,p=q.sameBbox;function u(d){if(!Array.isArray(d)||d.length<4)return null;const[r,v,l,x]=d.map(Number);if(![r,v,l,x].every(Number.isFinite))return null;const W=Math.max(-180,Math.min(r,l)),Z=Math.min(180,Math.max(r,l)),le=Math.max(-90,Math.min(v,x)),oe=Math.min(90,Math.max(v,x));return!(Z>W)||!(oe>le)?null:[W,le,Z,oe]}function m(d,r){const v=Z=>typeof Z=="string"&&Z!==""&&!!(d.columns&&d.columns.get(Z));if(!r||typeof r!="object")return"options.position is missing; pass { lon, lat } or { geometry } naming the grid's columns";const{lon:l,lat:x,geometry:W}=r;return W!==void 0?v(W)?{geometry:W}:`options.position.geometry ${JSON.stringify(W)} is not a column of the grid`:l!==void 0||x!==void 0?v(l)?v(x)?{lon:l,lat:x}:`options.position.lat ${JSON.stringify(x)} is not a column of the grid`:`options.position.lon ${JSON.stringify(l)} is not a column of the grid`:"options.position names neither { lon, lat } nor { geometry }"}function c(d,r,v={}){const l={...r,...v.viewportCap!==void 0?{viewportCap:v.viewportCap}:{}},x=v.ids===!0,W=typeof v.onAnswer=="function"?v.onAnswer:()=>{},Z=v.leaves===!0,le=typeof v.readPlace=="function"?v.readPlace:null,oe=new se,y=M=>{const J=[],F=[],re=M.rows.count();for(let z=0;z<re;z++){const U=M.rows.get(z);if(!U||U.group||U.data===null||U.data===void 0)continue;let L=null;if(r.geometry){const e=M.rows.value(U.key,r.geometry);L=le?le(e):Y(e).geometry}else{const e=M.rows.value(U.key,r.lon),i=M.rows.value(U.key,r.lat),a=te=>te==null||te==="",A=Number(e),$=Number(i);L=!a(e)&&!a(i)&&Number.isFinite(A)&&Number.isFinite($)?{type:"Point",coordinates:[A,$]}:null}L&&(J.push(x?{type:"Feature",id:U.key,geometry:L,properties:U.data}:{type:"Feature",geometry:L,properties:U.data}),F.push(U.key))}return{features:J,keys:F}},C=()=>{const M=[];d.rows.forEach(F=>{if(F){if(F.group){if(Z&&!F.expanded&&typeof d.rows.leavesOf=="function")for(const re of d.rows.leavesOf(F.key))re&&!re.group&&re.data!==null&&re.data!==void 0&&M.push(re);return}F.data!==null&&F.data!==void 0&&M.push(F)}});const J={rows:{count:()=>M.length,get:F=>M[F],value:(F,re)=>d.rows.value(F,re)}};return{rows:M.map(F=>F.data),reader:J}};return{spec:l,read:M=>{const J=T(l),F=n(d,l,"markermap",{bbox:M});let re=[],z={features:[],keys:[]},U=!1,L=!1,e=null,i;if(F.mode==="engine"){const a=oe.answer(F.key);a||oe.ask(F.key,F.run,W);const A=a||oe.last();L=oe.busy;const $=A&&!("error"in A)?A.result:null;if($&&$.kind==="rows")re=$.rows,z=y(V(d,re)),i={rows:z.features.length,skipped:re.length-z.features.length,matched:$.count,cap:J,binned:!1,cells:0,over:null,bbox:$.bbox?[...$.bbox]:null,computed:"engine"};else if($&&$.kind==="density")re=$.cells,U=!0,i={rows:0,skipped:0,matched:$.count,cap:J,binned:!0,cells:re.length,over:null,bbox:$.bbox?[...$.bbox]:null,computed:"engine"};else if($&&$.kind==="over")e={count:$.count,cap:$.cap,reason:String($.reason)},i={rows:0,skipped:0,matched:$.count,cap:J,binned:!1,cells:0,over:$.reason,bbox:$.bbox?[...$.bbox]:null,computed:"engine"};else{const te=$&&$.refused?String($.refused):A&&"error"in A?String(A.error?.message||A.error):null;i={rows:0,skipped:0,matched:0,cap:J,binned:!1,cells:0,over:te,bbox:M?[...M]:null,computed:"engine"}}}else{const a=C();re=a.rows,z=y(a.reader),i={rows:z.features.length,skipped:re.length-z.features.length,matched:re.length,cap:J,binned:!1,cells:0,over:null,bbox:M?[...M]:null,computed:"client"}}return{rows:re,features:z.features,keys:z.keys,binned:U,pending:L,provenance:i,over:e}},close:()=>oe.close()}}function w(d,r,v){const l=R(v),x=f(r,null);let W=null;return{settings:l,target:x,incoming(){if(!l.enabled||!x)return null;const Z=P(d.filters.get(),x);return Z?p(Z,W)?null:(W=Z,Z):(W=null,null)},write(Z){if(!x||!Z||p(Z,W))return!1;const le=d.messages&&typeof d.messages.t=="function"?d.messages.t("chart.viewportFilter.label"):void 0,oe=g(d.filters.get(),x,S(x,Z,le));return W=Z,d.filters.set(oe),!0},release(){if(W&&x){const Z=d.filters.get(),le=N(Z,x);le!==Z&&d.filters.set(le)}W=null}}}}),Ze("packages/modules/charts/rampscale.js",function(t,ue){"use strict";Object.defineProperty(t,"AUTO_LOG_RATIO",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(t,"QUANTILE_CLASSES",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(t,"chooseRampScale",{enumerable:!0,get:function(){return se}}),Object.defineProperty(t,"logTicks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"quantileCuts",{enumerable:!0,get:function(){return V}}),Object.defineProperty(t,"placeOnRamp",{enumerable:!0,get:function(){return T}});const Le=100,Y=5;function fe(q){const R=[];for(const f of q||[])typeof f=="number"&&Number.isFinite(f)&&f>0&&R.push(f);return R}function se(q,R){const f=fe(q);let S=1/0,g=0;for(const N of f)N<S&&(S=N),N>g&&(g=N);const P=f.length?g/S:0;return R?{scale:R,auto:!1,ratio:P}:P>Le?{scale:"log",auto:!0,ratio:P}:{scale:"linear",auto:!1,ratio:P}}function ne(q){return Number(q.toPrecision(12))}function n(q,R){if(!(q>0)||!(R>=q)||!Number.isFinite(R))return[];const f=p=>p>=q*(1-1e-9)&&p<=R*(1+1e-9),S=Math.floor(Math.log10(q)+1e-9),g=Math.floor(Math.log10(R)+1e-9),P=[],N=Math.log10(R/q);for(let p=S;p<=g;p++){const u=N>=2?[1]:[1,2,5];for(const m of u){const c=ne(m*10**p);f(c)&&P.push(c)}}return P}function V(q,R=Y){const f=[];for(const g of q||[])typeof g=="number"&&Number.isFinite(g)&&f.push(g);if(!f.length)return[];f.sort((g,P)=>g-P);const S=[];for(let g=1;g<R;g++){const P=(f.length-1)*(g/R),N=Math.floor(P),p=Math.min(f.length-1,N+1);S.push(ne(f[N]+(P-N)*(f[p]-f[N])))}return S}function T(q,R,f){if(q==="log"){let g=fe(f);g.length||(g=fe([R.min,R.max]));let P=1/0,N=0;for(const c of g)c<P&&(P=c),c>N&&(N=c);g.length||(P=1,N=1);const p=Math.log10(P),u=Math.log10(N)-p||1,m=c=>typeof c!="number"||!Number.isFinite(c)||c<=0?0:Math.min(1,Math.max(0,(Math.log10(c)-p)/u));return{position:m,domain:{min:P,max:N},ticks:n(P,N).map(c=>({value:c,t:m(c)})),classes:0}}if(q==="quantile"){const g=V(f),P=g.length+1;let N=1/0,p=-1/0;for(const m of f||[])typeof m!="number"||!Number.isFinite(m)||(m<N&&(N=m),m>p&&(p=m));return N>p&&(N=R.min,p=R.max),{position:m=>{if(typeof m!="number"||!Number.isFinite(m))return 0;let c=0;for(;c<g.length&&m>=g[c];)c++;return P>1?c/(P-1):0},domain:{min:N,max:p},ticks:g.map((m,c)=>({value:m,t:(c+1)/P})),classes:P}}const S=R.max-R.min||1;return{position:g=>(g-R.min)/S,domain:{min:R.min,max:R.max},ticks:[],classes:0}}}),Ze("packages/modules/mapview/model.js",function(t,ue){"use strict";Object.defineProperty(t,"DEFAULT_BASEMAP",{enumerable:!0,get:function(){return g}}),Object.defineProperty(t,"DEFAULT_DARK_BASEMAP",{enumerable:!0,get:function(){return P}}),Object.defineProperty(t,"BUILDINGS_LAYER",{enumerable:!0,get:function(){return N}}),Object.defineProperty(t,"LAYERS",{enumerable:!0,get:function(){return p}}),Object.defineProperty(t,"ROUTE_ELEVATION",{enumerable:!0,get:function(){return m}}),Object.defineProperty(t,"POINT_ELEVATION",{enumerable:!0,get:function(){return c}}),Object.defineProperty(t,"ROUTE_WIDTH_RANGE",{enumerable:!0,get:function(){return w}}),Object.defineProperty(t,"DASH_PATTERNS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(t,"ROUTE_AGGREGATES",{enumerable:!0,get:function(){return r}}),Object.defineProperty(t,"BADGES",{enumerable:!0,get:function(){return v}}),Object.defineProperty(t,"HIGHLIGHT",{enumerable:!0,get:function(){return l}}),Object.defineProperty(t,"HALO",{enumerable:!0,get:function(){return x}}),Object.defineProperty(t,"FALLBACK_COLOUR",{enumerable:!0,get:function(){return W}}),Object.defineProperty(t,"OVER_BUILDINGS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(t,"resolveGeometry",{enumerable:!0,get:function(){return le}}),Object.defineProperty(t,"readPath",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(t,"familyOf",{enumerable:!0,get:function(){return y}}),Object.defineProperty(t,"layerFor",{enumerable:!0,get:function(){return C}}),Object.defineProperty(t,"checkLayer",{enumerable:!0,get:function(){return D}}),Object.defineProperty(t,"toDeckColour",{enumerable:!0,get:function(){return re}}),Object.defineProperty(t,"isBlank",{enumerable:!0,get:function(){return z}}),Object.defineProperty(t,"colourRule",{enumerable:!0,get:function(){return i}}),Object.defineProperty(t,"numberRule",{enumerable:!0,get:function(){return a}}),Object.defineProperty(t,"dashRule",{enumerable:!0,get:function(){return $}}),Object.defineProperty(t,"legendSections",{enumerable:!0,get:function(){return te}}),Object.defineProperty(t,"resolveIcon",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(t,"iconRule",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(t,"pathTimestamps",{enumerable:!0,get:function(){return _}}),Object.defineProperty(t,"isSelected",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(t,"buildItems",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(t,"drawColour",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(t,"boundsOf",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(t,"tooltipColumns",{enumerable:!0,get:function(){return o}}),Object.defineProperty(t,"tooltipLines",{enumerable:!0,get:function(){return H}});const Y=ue("packages/core/src/internal/warn.js").warnOnce,se=ue("packages/modules/geometry/geodata.js").readGeometry,ne=ue("packages/modules/charts/rampscale.js"),n=ne.chooseRampScale,V=ne.placeOnRamp,T=ue("packages/modules/charts/scheme.js"),q=T.toRgb,R=T.rampStops,f=T.SCHEMES,S=T.PALETTE,g="https://tiles.openfreemap.org/styles/positron",P="https://tiles.openfreemap.org/styles/dark",N="lattice-mapview-buildings",p=Object.freeze(["point","column","polygon","path"]),u=Object.freeze({point:"point",column:"point",polygon:"polygon",path:"path"}),m=2,c=4,w=Object.freeze([2,30]),d=Object.freeze({solid:null,dashed:Object.freeze([10,6]),dotted:Object.freeze([2,5])}),r=Object.freeze(["first","last","min","max"]),v=Object.freeze(["circle","square","diamond"]),l=Object.freeze([255,87,34,255]),x=Object.freeze([255,255,255,180]),W=Object.freeze([0,114,178,220]),Z=Object.freeze({depthCompare:"always",depthWriteEnabled:!1});function le(s,h){const O=E=>typeof E=="string"&&E!==""&&!!(s&&s.columns&&s.columns.get(E));if(!h||typeof h!="object")return"options.geometry is missing; pass { lat, lng }, { geojson } or { path } naming the grid's columns";const I=h;if(I.geojson!==void 0){if(!O(I.geojson))return`options.geometry.geojson ${JSON.stringify(I.geojson)} is not a column of the grid`;const E=I.geojson;return{kind:"geojson",position:{geometry:E},columns:[E],readPlace:null,segment:null,route:null}}if(I.path!==void 0){if(!O(I.path))return`options.geometry.path ${JSON.stringify(I.path)} is not a column of the grid`;const E=I.path;return{kind:"path",position:{geometry:E},columns:[E],readPlace:oe,segment:null,route:null}}if(I.from!==void 0||I.to!==void 0){const E=I.from&&typeof I.from=="object"?I.from:{},G=I.to&&typeof I.to=="object"?I.to:{},Me=E.lng!==void 0?E.lng:E.lon,k=G.lng!==void 0?G.lng:G.lon;for(const[j,X]of[["from.lat",E.lat],["from.lng",Me],["to.lat",G.lat],["to.lng",k]])if(!O(X))return`options.geometry.${j} ${JSON.stringify(X)} is not a column of the grid`;return{kind:"segment",position:{lon:Me,lat:E.lat},columns:[E.lat,Me,G.lat,k],readPlace:null,segment:{lat:G.lat,lng:k},route:null}}const K=I.lng!==void 0?I.lng:I.lon,{lat:ee}=I;if(K!==void 0||ee!==void 0){if(!O(ee))return`options.geometry.lat ${JSON.stringify(ee)} is not a column of the grid`;if(!O(K))return`options.geometry.lng ${JSON.stringify(K)} is not a column of the grid`;let E=null;if(I.route!==void 0){const G=I.route;if(!G||typeof G!="object"||!O(G.by))return`options.geometry.route.by ${JSON.stringify(G&&typeof G=="object"?G.by:G)} is not a column of the grid`;if(G.order!==void 0&&G.order!==null&&!O(G.order))return`options.geometry.route.order ${JSON.stringify(G.order)} is not a column of the grid`;G.aggregate!==void 0&&!r.includes(G.aggregate)&&Y("mapview:route",`createMapView: route.aggregate ${JSON.stringify(G.aggregate)} is not an aggregate; a route's style is read from its first row. Use ${r.map(Me=>`"${Me}"`).join(", ")}.`),E={by:G.by,order:typeof G.order=="string"?G.order:null,aggregate:r.includes(G.aggregate)?G.aggregate:"first"}}return{kind:"point",position:{lon:K,lat:ee},columns:[ee,K,...E&&E.order?[E.order]:[]],readPlace:null,segment:null,route:E}}return"options.geometry names none of { lat, lng }, { from, to }, { geojson } or { path }"}function oe(s){let h=s;if(typeof h=="string"){const O=h.trim();if(O==="")return null;if(O[0]==="[")try{h=JSON.parse(O)}catch{return null}else return se(O).geometry}if(Array.isArray(h)){const O=[];for(const I of h){if(!Array.isArray(I)||I.length<2)return null;const K=Number(I[0]),ee=Number(I[1]);if(!Number.isFinite(K)||!Number.isFinite(ee))return null;O.push([K,ee])}return O.length>=2?{type:"LineString",coordinates:O}:null}return h&&typeof h=="object"?se(h).geometry:null}function y(s){if(!s||typeof s!="object")return null;switch(s.type){case"Point":case"MultiPoint":return"point";case"LineString":case"MultiLineString":return"path";case"Polygon":case"MultiPolygon":return"polygon";case"GeometryCollection":return Array.isArray(s.geometries)&&s.geometries.length?y(s.geometries[0]):null;default:return null}}function C(s,h){const O=h.layer;return typeof O=="string"&&u[O]===s?O:s==="point"?h.elevation!==void 0&&h.elevation!==null?"column":"point":s}function D(s){return s==null||p.includes(s)?!0:(Y(`mapview:layer:${String(s)}`,`createMapView: layer "${String(s)}" is not a layer kind; each row is drawn by the default for its geometry. Use "point", "column", "polygon" or "path".`),!1)}function M(s){return s.type==="Point"?s.coordinates:s.type==="MultiPoint"?s.coordinates[0]||null:s.type==="GeometryCollection"?M(s.geometries[0]):null}function J(s){return s.type==="LineString"?[s.coordinates]:s.type==="MultiLineString"?s.coordinates:s.type==="GeometryCollection"?J(s.geometries[0]):[]}function F(s,h,O){const I=Math.max(0,Math.min(1,Number.isFinite(O)?O:0));return[0,1,2].map(K=>Math.round(s[K]+(h[K]-s[K])*I))}function re(s,h=230){if(Array.isArray(s)&&s.length>=3&&s.slice(0,3).every(I=>Number.isFinite(Number(I)))){const I=s.slice(0,4).map(Number);return I.length===3&&I.push(h),I}const O=q(s);return O?[...O,h]:null}function z(s){return s==null||s===""}function U(s,h,O,I){let K;try{K=s.rows.value(h,I)}catch{K=void 0}return K===void 0&&O&&typeof O=="object"&&(K=O[I]),K}function L(s,h,O){const I=h.aggregate||"first",K=E=>U(s,h.keys[E],h.rows[E],O);if(I==="first")return K(0);if(I==="last")return K(h.keys.length-1);let ee;for(let E=0;E<h.keys.length;E++){const G=K(E);if(z(G))continue;if(ee===void 0){ee=G;continue}const k=Number.isFinite(Number(G))&&Number.isFinite(Number(ee))?Number(G)-Number(ee):String(G)<String(ee)?-1:String(G)>String(ee)?1:0;(I==="max"?k>0:k<0)&&(ee=G)}return ee}function e(s,h,O){return h.isRoute?L(s,h,O):U(s,h.key,h.row,O)}function i(s,h,O,I,K){const ee=I||[...W];if(h==null)return{colourOf:()=>ee,legend:[]};const E=typeof h=="string"||Array.isArray(h)?re(h):null;if(E)return{colourOf:()=>E,legend:[]};if(typeof h!="object"||typeof h.field!="string")return Y("mapview:color","createMapView: color is neither a colour nor { field, map } nor { field, scale: 'ramp' }; every row is drawn in the theme's colour."),{colourOf:()=>ee,legend:[]};const G=h,{field:Me}=G;if(G.scale==="ramp"){const ae=O.map(We=>Number(e(s,We,Me))).filter(Number.isFinite);let be=1/0,Se=-1/0;for(const We of ae)We<be&&(be=We),We>Se&&(Se=We);Array.isArray(G.domain)&&G.domain.length>=2&&G.domain.every(We=>Number.isFinite(Number(We)))&&(be=Number(G.domain[0]),Se=Number(G.domain[1])),Se>=be||(be=0,Se=1);const Ae=Array.isArray(G.colours)&&G.colours.length>=2?{sequential:G.colours}:K&&K.sequential?{sequential:K.sequential.map(We=>`rgb(${We[0]} ${We[1]} ${We[2]})`)}:f.default,ze=R(Ae,!1),Be=n(ae.length?ae:[be,Se],G.rampScale||null),qe=V(Be.scale,{min:be,max:Se},ae.length?ae:[be,Se]),Ue=We=>{const st=Math.max(0,Math.min(1,Number.isFinite(We)?We:0))*(ze.length-1),tt=Math.min(ze.length-2,Math.floor(st));return[...F(ze[tt],ze[tt+1],st-tt),ee[3]??230]};return{colourOf(We){const st=Number(e(s,We,Me));return Number.isFinite(st)?Ue(qe.position(st)):ee},legend:[{label:String(be),colour:Ue(0)},{label:String(Se),colour:Ue(1)}],field:Me,categorical:!1}}const k=G.map&&typeof G.map=="object"?G.map:{},j=new Map;for(const[ae,be]of Object.entries(k)){const Se=re(be);Se&&j.set(ae,Se)}let X=0;return{colourOf(ae){const be=e(s,ae,Me),Se=be==null?"":String(be);let Ae=j.get(Se);return Ae||(Ae=(K&&K.series&&K.series.length?[...K.series[X%K.series.length]]:null)||re(S[X%S.length])||ee,X++,j.set(Se,Ae)),Ae},get legend(){return[...j].map(([ae,be])=>({label:ae,colour:be}))},field:Me,categorical:!0}}function a(s,h,O){return typeof h=="number"&&Number.isFinite(h)?()=>h:typeof h=="string"&&h!==""?I=>{const K=Number(e(s,I,h));return Number.isFinite(K)?K:O}:()=>O}function A(s){if(typeof s=="string")return Object.hasOwn(d,s)?d[s]?[...d[s]]:null:void 0;if(Array.isArray(s)&&s.length>=2){const h=Number(s[0]),O=Number(s[1]);return Number.isFinite(h)&&Number.isFinite(O)&&h>0&&O>0?[h,O]:void 0}}function $(s,h){const O={dashOf:()=>null,legend:[],any:!1};if(h==null||h===!1)return O;const I=E=>Y("mapview:dash:spec",`createMapView: dash ${E} is not a line style; the lines are drawn solid. Use "dashed", "dotted", [dash, gap] in pixels, or { field, map } naming one of those per value.`);if(typeof h=="string"||Array.isArray(h)){const E=A(h);return E===void 0?(I(JSON.stringify(h)),O):{dashOf:()=>E,legend:[],any:E!==null}}const K=h;if(typeof K!="object"||typeof K.field!="string"||!K.map||typeof K.map!="object")return I(JSON.stringify(h)),O;const ee=new Map;for(const[E,G]of Object.entries(K.map)){const Me=A(G);Me===void 0?I(`${JSON.stringify(G)} for "${E}"`):ee.set(E,Me)}return{dashOf(E){const G=e(s,E,K.field);return ee.get(z(G)?"":String(G))||null},legend:[...ee].map(([E,G])=>({label:E,dash:G})),any:[...ee.values()].some(E=>E!==null),field:K.field}}function te(s,h,O,I){const K=E=>{if(!E)return"";let G=null;try{G=s.columns.get(E)}catch{G=null}return G&&G.title||E},ee=[];if(O.categorical&&I.field&&O.field===I.field&&I.legend.length){const E=new Set;for(const j of h){if(j.layer!=="path")continue;const X=e(s,j,O.field);E.add(z(X)?"":String(X))}const G=new Map(I.legend.map(j=>[j.label,j.dash])),Me=new Map(O.legend.map(j=>[j.label,j.colour])),k=[...new Set([...Me.keys(),...G.keys()])];return ee.push({field:O.field,title:K(O.field),merged:!0,entries:k.map(j=>({label:j,colour:Me.get(j)||null,dash:G.get(j)||null,line:G.has(j)||E.has(j)}))}),ee}return O.legend.length&&ee.push({field:O.field||null,title:K(O.field),merged:!1,entries:O.legend.map(E=>({label:E.label,colour:E.colour,dash:null,line:!1}))}),I.legend.length&&ee.push({field:I.field||null,title:K(I.field),merged:!1,entries:I.legend.map(E=>({label:E.label,colour:null,dash:E.dash,line:!0}))}),ee}function ke(s){if(typeof s=="string")return{viewBox:"0 0 16 16",paths:[s],paint:"fill"};const h=s||{};return{viewBox:h.viewBox||"0 0 16 16",paths:Array.isArray(h.paths)?h.paths.slice():h.path?[h.path]:[],paint:h.paint==="stroke"?"stroke":"fill"}}function ge(s){return/^[Mm][\s\d.,+-]/.test(s)&&/^[MmLlHhVvCcSsQqTtAaZz\d\s.,+\-eE]+$/.test(s)}function ve(s){return/^(https?:|data:|blob:|\/|\.\.?\/)/i.test(s)||/\.(svg|png|jpe?g|webp|gif)(\?.*)?$/i.test(s)}function Pe(s,h){if(h&&typeof h=="object"){const K=ke(h);return K.paths.length?{kind:"glyph",def:K}:null}if(typeof h!="string"||h.trim()==="")return null;const O=h.trim();let I=null;try{I=s&&s.icons&&typeof s.icons.get=="function"?s.icons.get(O):null}catch{I=null}return I?{kind:"glyph",def:I}:ge(O)?{kind:"glyph",def:ke(O)}:ve(O)?{kind:"url",url:O}:null}function Te(s,h){if(h==null||h===!1)return null;const O=typeof h=="string"?{default:h}:h;if(typeof O!="object")return Y("mapview:icon","createMapView: icon is neither an icon name nor { field, map, default, size, anchor }; points are drawn as circles."),null;let I=typeof O.field=="string"&&O.field!==""?O.field:null;I&&!(s.columns&&s.columns.get(I))&&(Y("mapview:icon",`createMapView: icon.field ${JSON.stringify(I)} is not a column of the grid; its default icon is used for every point.`),I=null);const K=O.map&&typeof O.map=="object"?O.map:null,ee=Me=>typeof Me=="string"?Me.trim():`object:${JSON.stringify(Me)}`,E=a(s,O.size,24);return{refOf(Me){let k;if(I){const j=e(s,Me,I),X=z(j)?"":String(j);K?k=Object.hasOwn(K,X)?K[X]:O.default:k=z(j)?O.default:j}else k=O.default;return k==null||k===""?null:{key:ee(k),ref:k}},sizeOf:E,anchor:["center","bottom","top","left","right"].includes(O.anchor)?O.anchor:"center",badge:O.badge===!0?"circle":v.includes(O.badge)?O.badge:null}}function _(s){const h=[0];for(let O=1;O<s.length;O++){const I=s[O][0]-s[O-1][0],K=s[O][1]-s[O-1][1];h.push(h[O-1]+Math.hypot(I,K))}return h}function pe(s,h){return s.keys?s.keys.some(O=>h.has(O)):h.has(s.key)}function me(s,h){const O=z(s),I=z(h);if(O||I)return O&&I?0:O?1:-1;const K=Number(s),ee=Number(h);if(Number.isFinite(K)&&Number.isFinite(ee))return K-ee;const E=String(s),G=String(h);return E<G?-1:E>G?1:0}function ie(s,h,O,I,K,ee={}){const E=ee.placement||null,G=E&&E.route?E.route:null,Me=E&&E.segment?E.segment:null,k=ee.routeCache instanceof Map?ee.routeCache:new Map,j=[];let X=0;const ae=new Map;for(let tt=0;tt<h.features.length;tt++){const wt=h.features[tt],Mt=wt.geometry,Nt=y(Mt);if(!Nt){X++;continue}const pt=h.keys[tt]!==void 0?h.keys[tt]:wt.id,gt=wt.properties;if(Nt==="point"&&Me){const Ct=M(Mt),kt=U(s,pt,gt,Me.lng),dt=U(s,pt,gt,Me.lat),Qe=z(kt)||z(dt)?null:[Number(kt),Number(dt)];if(!Ct||!Qe||!Number.isFinite(Qe[0])||!Number.isFinite(Qe[1])){X++;continue}const It=[Ct,Qe];j.push({key:pt,row:gt,geometry:{type:"LineString",coordinates:It},family:"path",layer:"path",position:null,lines:[It],colour:null,elevation:0,radius:0,width:0,dash:null,selected:K.has(pt)});continue}if(Nt==="point"&&G){const Ct=U(s,pt,gt,G.by);if(!z(Ct)){const kt=M(Mt);if(!kt){X++;continue}const dt=String(Ct);ae.has(dt)||ae.set(dt,[]),ae.get(dt).push({key:pt,row:gt,position:kt,order:G.order?U(s,pt,gt,G.order):null,seq:tt});continue}}const mt={key:pt,row:gt,geometry:Mt,family:Nt,layer:C(Nt,O),position:Nt==="point"?M(Mt):null,lines:Nt==="path"?J(Mt):null,colour:null,elevation:0,radius:0,width:0,dash:null,selected:K.has(pt)};if(Nt==="point"&&!mt.position){X++;continue}j.push(mt)}const be={drawn:0,skipped:0,rebuilt:0};if(G){const tt=O.color&&typeof O.color=="object"&&typeof O.color.field=="string"?O.color.field:null,wt=O.dash&&typeof O.dash=="object"&&!Array.isArray(O.dash)&&typeof O.dash.field=="string"?O.dash.field:null,Mt=[...new Set([tt,wt,O.width,O.elevation].filter(pt=>typeof pt=="string"&&pt!==""))],Nt=new Set;for(const[pt,gt]of ae){if(gt.length<2){be.skipped++,X+=gt.length;continue}gt.sort((dt,Qe)=>me(dt.order,Qe.order)||dt.seq-Qe.seq);const mt=gt.map(dt=>`${String(dt.key)}${dt.position[0]},${dt.position[1]}${String(dt.order)}`).join("")+Mt.map(dt=>`${gt.map(Qe=>String(U(s,Qe.key,Qe.row,dt))).join("")}`).join("");Nt.add(pt);const Ct=k.get(pt);let kt;if(Ct&&Ct.signature===mt)kt=Ct.item;else{const dt=gt.map(Qe=>[Qe.position[0],Qe.position[1]]);kt={key:gt[0].key,keys:gt.map(Qe=>Qe.key),route:pt,isRoute:!0,aggregate:G.aggregate,geometry:{type:"LineString",coordinates:dt},family:"path",layer:"path",position:null,lines:[dt],colour:null,elevation:0,radius:0,width:0,dash:null},k.set(pt,{signature:mt,item:kt}),be.rebuilt++}kt.rows=gt.map(dt=>dt.row),kt.row=kt.rows[0],kt.selected=pe(kt,K),j.push(kt),be.drawn++}for(const pt of[...k.keys()])Nt.has(pt)||k.delete(pt)}const Se=i(s,O.color,j,I.accent,I),Ae=$(s,O.dash),ze=Te(s,O.icon),Be=a(s,O.elevation,0),qe=a(s,O.radius,O.radiusUnits==="pixels"?6:30),Ue=a(s,O.width,3),We={point:[],column:[],polygon:[],path:[]},st=new Map;for(const tt of j){if(tt.colour=Se.colourOf(tt),tt.elevation=Be(tt),tt.radius=qe(tt),tt.width=Ue(tt),tt.dash=tt.layer==="path"?Ae.dashOf(tt):null,tt.icon=null,ze&&tt.layer==="point"){const wt=ze.refOf(tt);wt&&(tt.icon=wt.key,tt.iconSize=ze.sizeOf(tt),st.set(wt.key,wt.ref))}We[tt.layer].push(tt)}return{items:j,skipped:X,byLayer:We,legend:Se.legend,dashLegend:Ae.legend,legendSections:te(s,j,Se,Ae),dashed:Ae.any,routes:be,icon:ze?{anchor:ze.anchor,badge:ze.badge,refs:st}:null}}function Q(s,h){return s.selected?h.highlight:s.colour}function ye(s){let h=1/0,O=1/0,I=-1/0,K=-1/0;const ee=G=>{!Array.isArray(G)||!Number.isFinite(G[0])||!Number.isFinite(G[1])||(G[0]<h&&(h=G[0]),G[0]>I&&(I=G[0]),G[1]<O&&(O=G[1]),G[1]>K&&(K=G[1]))},E=G=>{if(Array.isArray(G)){if(typeof G[0]=="number"){ee(G);return}for(const Me of G)E(Me)}};for(const G of s){const Me=G.geometry;if(Me.type==="GeometryCollection")for(const k of Me.geometries||[])E(k.coordinates);else E(Me.coordinates)}return h<=I&&O<=K?[h,O,I,K]:null}function o(s,h,O,I){if(h===!1)return[];const K=E=>I&&s.columns.get(I)?[I,...E.filter(G=>G!==I)]:E;if(Array.isArray(h))return K(h.filter(E=>typeof E=="string"&&s.columns.get(E)));const ee=typeof s.columns.visible=="function"?s.columns.visible():s.columns.all();return K(ee.map(E=>E.id).filter(E=>!O.includes(E)&&E!==I).slice(0,3))}function H(s,h,O,I){return O.map(K=>{const ee=s.columns.get(K);let E;try{E=s.rows.byKey&&s.rows.byKey(h)?s.rows.text(h,K):void 0}catch{E=void 0}if(E===void 0){const G=I&&typeof I=="object"?I[K]:void 0;E=G==null?"":String(G)}return{column:K,title:ee?ee.title:K,text:E}})}}),Ze("packages/modules/mapview/icons.js",function(t,ue){"use strict";Object.defineProperty(t,"CELL",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(t,"badgeCell",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(t,"anchorPoint",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"createAtlas",{enumerable:!0,get:function(){return q}});const Y=ue("packages/modules/mapview/model.js").resolveIcon,fe=64,se=8,ne=R=>`__badge:${R}`;function n(R){const f=fe/2;switch(R){case"bottom":return{anchorX:f,anchorY:fe};case"top":return{anchorX:f,anchorY:0};case"left":return{anchorX:0,anchorY:f};case"right":return{anchorX:fe,anchorY:f};default:return{anchorX:f,anchorY:f}}}function V(R,f,S,g){const P=fe/2;R.fillStyle="#fff",R.beginPath(),f==="circle"?R.arc(S+P,g+P,P-2,0,Math.PI*2):f==="square"?R.rect(S+4,g+4,fe-8,fe-8):(R.moveTo(S+P,g+1),R.lineTo(S+fe-1,g+P),R.lineTo(S+P,g+fe-1),R.lineTo(S+1,g+P),R.closePath()),R.fill()}function T(R,f,S,g,P){const[N,p,u,m]=String(S.viewBox||"0 0 16 16").trim().split(/[\s,]+/).map(Number),c=4,w=fe-c*2,d=Math.min(w/(u||16),w/(m||16));R.save(),R.translate(g+c+(w-(u||16)*d)/2-(N||0)*d,P+c+(w-(m||16)*d)/2-(p||0)*d),R.scale(d,d),R.fillStyle="#fff",R.strokeStyle="#fff",R.lineWidth=1.5,R.lineCap="round",R.lineJoin="round";for(const r of S.paths){const v=new f(r);S.paint==="stroke"?R.stroke(v):R.fill(v)}R.restore()}function q(R,f,S,g){const P=f&&f.Path2D||globalThis.Path2D,N=f&&f.Image||globalThis.Image;let p=new Map,u=[],m=new Map,c=null,w=0,d=!1;const r=new Set,v=new Map,l=()=>{const W=S.createElement("canvas"),Z=Math.max(1,Math.ceil(u.length/se));W.width=Math.min(u.length,se)*fe||fe,W.height=Z*fe;const le=typeof W.getContext=="function"?W.getContext("2d"):null;if(!le||typeof P!="function"){d=!0,c=null;return}m=new Map,u.forEach((oe,y)=>{const C=y%se*fe,D=Math.floor(y/se)*fe,M=p.get(oe);oe.startsWith("__badge:")?(V(le,oe.slice(8),C,D),m.set(oe,{x:C,y:D,mask:!0})):M.kind==="glyph"?(T(le,P,M.def,C,D),m.set(oe,{x:C,y:D,mask:!0})):M.ready&&M.img&&(le.drawImage(M.img,C,D,fe,fe),m.set(oe,{x:C,y:D,mask:!1}))});try{c=W.toDataURL("image/png")}catch{d=!0,c=null}w++},x=(W,Z,le)=>{if(v.has(W)||typeof N!="function")return;const oe=new N;v.set(W,oe),oe.onload=()=>{Z.ready=!0,Z.img=oe,l(),g()},oe.onerror=()=>{Z.ready=!1,r.add(le),g()};try{oe.crossOrigin="anonymous",oe.src=W}catch{}};return{ensure(W,Z){if([...W.keys(),...[...Z].map(ne)].every(y=>p.has(y)||r.has(y)))return;const oe=new Map(p);for(const[y,C]of W){if(oe.has(y))continue;const D=Y(R,C);D?oe.set(y,D.kind==="url"?{kind:"url",url:D.url,ready:!1}:{kind:"glyph",def:D.def}):r.add(y)}for(const y of Z)oe.set(ne(y),{kind:"badge"});p=oe,u=[...p.keys()],l();for(const[y,C]of p)C.kind==="url"&&!C.ready&&x(C.url,C,y)},has:W=>m.has(W),image:()=>c,mapping(W){const Z={};for(const[le,oe]of m){const y=le.startsWith("__badge:")?n("center"):n(W);Z[le]={x:oe.x,y:oe.y,width:fe,height:fe,...y,mask:oe.mask}}return Z},unknown:()=>[...r],builds:()=>w,unavailable:()=>d}}}),Ze("packages/modules/mapview/theme.js",function(t,ue){"use strict";Object.defineProperty(t,"parseComputed",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(t,"readRole",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(t,"readRoleCss",{enumerable:!0,get:function(){return fe}});function Le(se){const ne=/^color\(srgb\s+([^)]+)\)$/i.exec(se);if(ne){const[S,g,P,N=1]=ne[1].split(/[\s/]+/).filter(Boolean).map(Number);return[S,g,P,N].every(Number.isFinite)?[S,g,P].map(p=>Math.round(p*255)).concat(Math.round(N*255)):null}const n=/^rgba?\(([^)]+)\)$/i.exec(se);if(!n)return null;const V=n[1].split(/[\s,/]+/).filter(Boolean),[T,q,R]=V.slice(0,3).map(Number),f=V[3]===void 0?1:Number(V[3].replace("%",""))/(V[3].endsWith("%")?100:1);return[T,q,R,f].every(Number.isFinite)?[T,q,R,Math.round(f*255)]:null}function Y(se,ne,n,V){try{if(!se||!ne||typeof ne.getComputedStyle!="function"||!se.ownerDocument)return null;const T=se.ownerDocument.createElement("span");T.style.cssText=`position:absolute;visibility:hidden;pointer-events:none;color:var(${n},var(${n.replace(/^--lattice-(map|chart)-/,"--lattice-$1-d-")},transparent))`,se.appendChild(T);const q=Le(ne.getComputedStyle(T).color);return se.removeChild(T),!q||q[3]===0?null:V!==void 0&&q[3]===255?[q[0],q[1],q[2],V]:q}catch{return null}}function fe(se,ne,n){const V=Y(se,ne,n);return V?`rgba(${V[0]},${V[1]},${V[2]},${+(V[3]/255).toFixed(3)})`:null}}),Ze("packages/modules/mapview/roles.js",function(t,ue){"use strict";Object.defineProperty(t,"BUILDING",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(t,"expand",{enumerable:!0,get:function(){return se}}),Object.defineProperty(t,"rolesCss",{enumerable:!0,get:function(){return ne}});const Le=Object.freeze({light:"#d6d2ca",dark:"#3b4048"}),Y=`
464
+ `)}function B(f){const S=f.documentElement;if(!S||S.getAttribute(V))return;S.setAttribute(V,"1");const y=f.createElement("style");y.textContent=q(),(f.head||f.body||S).appendChild(y)}}),qe("packages/core/src/format/mask.js",function(t,ce){"use strict";Object.defineProperty(t,"splitSections",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(t,"parseSection",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(t,"compileMask",{enumerable:!0,get:function(){return n}});const _e=new Set(["0","#","?",",","."]),H="\0";function ue(E){const q=[];let B="",f=!1;for(let S=0;S<E.length;S++){const y=E[S];if(y==="\\"){B+=y+(E[S+1]??""),S+=1;continue}if(y==='"'){f=!f,B+=y;continue}if(y===";"&&!f){q.push(B),B="";continue}B+=y}return q.push(B),q}function ie(E){let q="",B="",f="",S=1,y=!1,P=!1;const N=l=>{P?B+=l:q+=l};for(let l=0;l<E.length;l++){const x=E[l];if(x==="\\"){N(E[l+1]??""),l+=1;continue}if(x==='"'){const W=E.indexOf('"',l+1);N(W===-1?E.slice(l+1):E.slice(l+1,W)),l=W===-1?E.length:W;continue}if(x==="%"){S*=100,N("%");continue}if(x==="@"){y=!0,N("\0");continue}if(_e.has(x)){f+=x,P=!0;continue}N(x)}let p=-1;for(let l=f.length-1;l>=0;l--){const x=f[l];if(x==="0"||x==="#"||x==="?"){p=l;break}}let u=!1,h="";for(let l=0;l<f.length;l++){const x=f[l];if(x===","){l>p?S/=1e3:u=!0;continue}h+=x}const c=h.indexOf("."),k=c===-1?h:h.slice(0,c),m=c===-1?"":h.slice(c+1);let r=0;for(const l of k)l==="0"&&(r+=1);let v=0;for(const l of m)l==="0"&&(v+=1);return{prefix:q,suffix:B,minInt:r,minDec:v,maxDec:m.length,grouping:u,scale:S,hasNumber:p!==-1,isText:y}}function te(E,q){const B=new Intl.NumberFormat(q,{minimumIntegerDigits:Math.max(E.minInt,1),minimumFractionDigits:E.minDec,maximumFractionDigits:Math.max(E.maxDec,E.minDec),useGrouping:E.grouping}),{prefix:f,suffix:S,scale:y,hasNumber:P}=E;return N=>{if(!P)return f+S;const p=y===1?N:N*y;return f+B.format(p)+S}}function n(E,q){const f=ue(String(E)).map(ie),S=f.map(h=>te(h,q)),y=0,P=f.length>1?1:-1,N=f.length>2?2:-1,p=f.length>3?3:-1,u=h=>{if(h==null||h==="")return"";if(typeof h!="number"||Number.isNaN(h)){const c=Number(h);if(Number.isNaN(c))return p===-1?String(h):(f[p].prefix+f[p].suffix).split("\0").join(String(h));h=c}return h===0&&N!==-1?S[N](0):h<0&&P!==-1?S[P](-h):S[y](h)};return u.spec={mask:E},{format:u,ooxml:V(String(E))}}function V(E){return E.trim()}}),qe("packages/core/src/format/pattern.js",function(t,ce){"use strict";Object.defineProperty(t,"parseNumberPattern",{enumerable:!0,get:function(){return te}});const H=ce("packages/core/src/format/mask.js").splitSections;function ue(n){let V="",E="",q="",B="",f=!1,S=!1,y=!1,P=!1;const N=u=>{y?E+=u:V+=u};for(let u=0;u<n.length;u++){const h=n[u];if(h==="\\"){N(n[u+1]??""),u+=1;continue}if(h==='"'){const c=n.indexOf('"',u+1);N(c===-1?n.slice(u+1):n.slice(u+1,c)),u=c===-1?n.length:c;continue}if(h==="%"){S=!0;continue}if(h==="0"||h==="#"){y=!0,P?B+=h:q+=h;continue}if(h===","){P||(f=!0);continue}if(h==="."&&!P){P=!0;continue}N(h)}if(!y)return{hasDigit:!1,prefix:V,suffix:E,minDec:0,maxDec:0,grouping:!1,percent:S};let p=0;for(const u of B)u==="0"&&(p+=1);return{hasDigit:!0,prefix:V,suffix:E,minDec:p,maxDec:B.length,grouping:f,percent:S}}function ie(n,V){const E=V.trim(),q=n.trim();return E.startsWith("(")&&E.endsWith(")")&&E.slice(1,-1).trim()===q?"parentheses":E.endsWith("-")?"suffix":"minus"}function te(n){if(typeof n!="string")return null;const V=H(n);if(V.length===0)return null;const E=ue(V[0]);if(!E.hasDigit)return null;const q={style:E.percent?"percent":"decimal",prefix:E.prefix,suffix:E.suffix,minDecimals:E.minDec,maxDecimals:Math.max(E.maxDec,E.minDec),thousandsSeparator:E.grouping?void 0:!1};if(V.length>1&&(q.negative=ie(V[0],V[1])),V.length>2){const B=ue(V[2]);B.hasDigit||(q.zeroDisplay=B.prefix+B.suffix)}return q}}),qe("packages/core/src/format/number.js",function(t,ce){"use strict";Object.defineProperty(t,"compileNumber",{enumerable:!0,get:function(){return V}});const H=ce("packages/core/src/internal/predicates.js").isNil,ie=ce("packages/core/src/internal/warn.js").warnOnce,n=ce("packages/core/src/format/pattern.js").parseNumberPattern;function V(E,q){const B=typeof E=="string"?{pattern:E}:E||{};let f=B;if(typeof B.pattern=="string"){const I=n(B.pattern);if(I){const{pattern:M,...X}=B;f={...I,...X}}else ie(`format:pattern:${B.pattern}`,`invalid number format pattern "${B.pattern}"; the value will use the default number format`)}const S=f.locale||q||void 0,y=f.style||"decimal",P=typeof f.scale=="number"?f.scale:1,N=f.nullDisplay??"",p=f.zeroDisplay,u=f.prefix||"",h=f.suffix||"",c=f.negative||"minus",k=f.signed===!0,m={style:y,notation:f.notation||"standard"};y==="currency"&&(m.currency=f.currency||"USD",f.currencyDisplay&&(m.currencyDisplay=f.currencyDisplay)),typeof f.decimals=="number"?(m.minimumFractionDigits=f.decimals,m.maximumFractionDigits=f.decimals):(typeof f.minDecimals=="number"&&(m.minimumFractionDigits=f.minDecimals),typeof f.maxDecimals=="number"&&(m.maximumFractionDigits=f.maxDecimals),m.minimumFractionDigits>(m.maximumFractionDigits??20)&&(m.maximumFractionDigits=m.minimumFractionDigits)),f.thousandsSeparator===!1&&(m.useGrouping=!1),m.notation==="compact"&&(m.compactDisplay=f.compactDisplay||"short");const r=new Intl.NumberFormat(S,m),v=typeof f.thousandsSeparator=="string"?f.thousandsSeparator:null,l=typeof f.decimalSeparator=="string"?f.decimalSeparator:null;let x=",",W=".";if(v||l)for(const I of r.formatToParts(12345.6))I.type==="group"?x=I.value:I.type==="decimal"&&(W=I.value);const J=I=>{let M=I;return v&&(M=M.split(x).join("")),l&&(M=M.split(W).join("")),v&&(M=M.split("").join(v)),l&&(M=M.split("").join(l)),M},se=!!(v||l),re=u!==""&&y==="currency",b=I=>{let M;if(re){const X=r.formatToParts(I);let z=!1;M="";for(const ne of X)M+=ne.value,!z&&ne.type==="currency"&&(M+=u,z=!0);z||(M=u+M)}else M=u+r.format(I);return se&&(M=J(M)),M+h},C=I=>{if(H(I)||I==="")return N;const M=typeof I=="number"?I:Number(I);if(Number.isNaN(M))return N;const X=P===1?M:M*P;return X===0&&p!==void 0?p:X<0?c==="parentheses"?`(${b(-X)})`:c==="suffix"?`${b(-X)}-`:b(X):k&&X>0?`+${b(X)}`:b(X)};return C.negativeClass=f.negativeClass||null,C.spec=f,C}}),qe("packages/core/src/format/date.js",function(t,ce){"use strict";Object.defineProperty(t,"scanPattern",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"toDate",{enumerable:!0,get:function(){return E}}),Object.defineProperty(t,"compilePattern",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"compileDate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(t,"toIsoDate",{enumerable:!0,get:function(){return P}}),Object.defineProperty(t,"toIsoDateTime",{enumerable:!0,get:function(){return N}}),Object.defineProperty(t,"compareIso",{enumerable:!0,get:function(){return h}});const H=ce("packages/core/src/internal/predicates.js").isNil,ie=ce("packages/core/src/internal/warn.js").warnOnce,te=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function n(c){const k=[];let m=0,r="";const v=()=>{r&&(k.push({token:null,text:r}),r="")};for(;m<c.length;){const l=c[m];if(l==="'"){if(c[m+1]==="'"){r+="'",m+=2;continue}const W=c.indexOf("'",m+1);if(W===-1){r+=c.slice(m+1),m=c.length;continue}r+=c.slice(m+1,W),m=W+1;continue}const x=te.find(W=>c.startsWith(W,m));if(x){v(),k.push({token:x,text:x}),m+=x.length;continue}/[A-Za-z]/.test(l)&&ie(`date.pattern.token:${l}`,`the date pattern "${c}" contains '${l}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${te.join(" ")}.`),r+=l,m+=1}return v(),k}const V=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function E(c){if(H(c)||c==="")return null;if(c instanceof Date)return Number.isNaN(c.getTime())?null:c;if(typeof c=="number")return Number.isNaN(c)?null:new Date(c);if(typeof c=="string"){const k=V.exec(c.trim());if(k){const[,r,v,l,x="0",W="0",J="0"]=k;return new Date(+r,+v-1,+l,+x,+W,+J)}const m=new Date(c);return Number.isNaN(m.getTime())?null:m}return null}function q(c,k){return String(c).padStart(k,"0")}function B(c){if(!c)return r=>({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate(),hour:r.getHours(),minute:r.getMinutes(),second:r.getSeconds(),ms:r.getMilliseconds(),weekday:r.getDay()});const k=new Intl.DateTimeFormat("en-US",{timeZone:c,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),m={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return r=>{const v={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:r.getMilliseconds(),weekday:0};for(const l of k.formatToParts(r))switch(l.type){case"year":v.year=Number(l.value);break;case"month":v.month=Number(l.value);break;case"day":v.day=Number(l.value);break;case"hour":v.hour=Number(l.value)%24;break;case"minute":v.minute=Number(l.value);break;case"second":v.second=Number(l.value);break;case"weekday":v.weekday=m[l.value]??0;break;default:break}return v}}function f(c,k,m){const r=n(c),v=B(m),l=new Set(r.filter(re=>re.token).map(re=>re.token)),x=l.has("MMM")?new Intl.DateTimeFormat(k,{month:"short",timeZone:m}):null,W=l.has("MMMM")?new Intl.DateTimeFormat(k,{month:"long",timeZone:m}):null,J=l.has("EEE")?new Intl.DateTimeFormat(k,{weekday:"short",timeZone:m}):null,se=l.has("EEEE")?new Intl.DateTimeFormat(k,{weekday:"long",timeZone:m}):null;return re=>{const b=v(re);let C="";for(const I of r){if(!I.token){C+=I.text;continue}switch(I.token){case"yyyy":C+=q(b.year,4);break;case"yy":C+=q(b.year%100,2);break;case"MMMM":C+=W.format(re);break;case"MMM":C+=x.format(re);break;case"MM":C+=q(b.month,2);break;case"M":C+=String(b.month);break;case"dd":C+=q(b.day,2);break;case"d":C+=String(b.day);break;case"EEEE":C+=se.format(re);break;case"EEE":C+=J.format(re);break;case"HH":C+=q(b.hour,2);break;case"H":C+=String(b.hour);break;case"hh":C+=q(b.hour%12===0?12:b.hour%12,2);break;case"h":C+=String(b.hour%12===0?12:b.hour%12);break;case"mm":C+=q(b.minute,2);break;case"m":C+=String(b.minute);break;case"ss":C+=q(b.second,2);break;case"s":C+=String(b.second);break;case"SSS":C+=q(b.ms,3);break;case"a":C+=b.hour<12?"AM":"PM";break;default:C+=I.text;break}}return C}}const S=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function y(c,k){const m=c||{},r=m.locale||k||void 0,v=m.nullDisplay??"",l=m.timeZone;let x;if(m.pattern)x=f(m.pattern,r,l);else if(m.dateStyle||m.timeStyle){const b={timeZone:l};m.dateStyle&&(b.dateStyle=m.dateStyle),m.timeStyle&&(b.timeStyle=m.timeStyle);const C=new Intl.DateTimeFormat(r,b);x=I=>C.format(I)}else{const b=new Intl.DateTimeFormat(r,{dateStyle:"medium",timeZone:l});x=C=>b.format(C)}const W=m.relative?new Intl.RelativeTimeFormat(r,{numeric:"auto"}):null,se=(typeof m.relative=="object"&&m.relative?m.relative.threshold??7:7)*24*36e5,re=(b,C)=>{const I=E(b);if(!I)return v;if(W){const M=C&&typeof C.now=="number"?C.now:Date.now(),X=I.getTime()-M;if(Math.abs(X)<se){for(const[z,ne]of S)if(Math.abs(X)>=ne||z==="second")return W.format(Math.round(X/ne),z)}}return x(I)};return re.spec=m,re}function P(c){if(H(c)||c==="")return null;if(typeof c=="string"){const r=/^(\d{4}-\d{2}-\d{2})/.exec(c.trim());if(r)return r[1];const v=E(c);return v?P(v):null}const k=E(c);if(!k)return null;const m=r=>String(r).padStart(2,"0");return`${k.getFullYear()}-${m(k.getMonth()+1)}-${m(k.getDate())}`}function N(c,k){if(H(c)||c==="")return null;if(typeof c=="string"){const r=c.trim();if(p.test(r)){const x=E(r);return x?u(x,k):null}const v=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(r);if(v){const[,x,W,J,se]=v;return`${x}T${W}:${J}${se&&se!=="00"?`:${se}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(r))return`${r}T00:00`;const l=E(r);return l?N(l):null}const m=E(c);return m?u(m,k):null}const p=/(?:Z|[+-]\d{2}:?\d{2})$/i;function u(c,k){const m=x=>String(x).padStart(2,"0");if(k)try{const x=new Intl.DateTimeFormat("en-CA",{timeZone:k,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(c).reduce((se,re)=>(re.type!=="literal"&&(se[re.type]=re.value),se),{}),W=x.hour==="24"?"00":x.hour,J=Number(x.second);return`${x.year}-${x.month}-${x.day}T${W}:${x.minute}`+(J?`:${x.second}`:"")}catch{}const r=`${c.getFullYear()}-${m(c.getMonth()+1)}-${m(c.getDate())}`,v=c.getSeconds(),l=`${m(c.getHours())}:${m(c.getMinutes())}${v?`:${m(v)}`:""}`;return`${r}T${l}`}function h(c,k){const m=H(c)||c===""?null:String(c),r=H(k)||k===""?null:String(k);return m===null?r===null?0:1:r===null||m<r?-1:m>r?1:0}}),qe("packages/core/src/format/boolean.js",function(t,ce){"use strict";Object.defineProperty(t,"toTriState",{enumerable:!0,get:function(){return te}}),Object.defineProperty(t,"compileBoolean",{enumerable:!0,get:function(){return n}});const H=ce("packages/core/src/internal/predicates.js").isNil,ue={true:"☑",false:"☐",null:""},ie={true:"◉",false:"◯",null:""};function te(V){if(H(V)||V==="")return null;if(typeof V=="boolean")return V;if(typeof V=="number")return V!==0;const E=String(V).trim().toLowerCase();return E==="true"||E==="yes"||E==="y"||E==="1"?!0:E==="false"||E==="no"||E==="n"||E==="0"?!1:null}function n(V,E){const q=V||{},B=q.display||"text",f=q.trueLabel??"Yes",S=q.falseLabel??"No",y=q.nullLabel??"";let P=f,N=S;const p=y;B==="checkbox"?(P=ue.true,N=ue.false):B==="switch"?(P=ie.true,N=ie.false):B==="icon"&&(P=q.trueIcon??f,N=q.falseIcon??S);const u=h=>{const c=te(h);return c===null?p:c?P:N};return u.display=B,u.labels={true:f,false:S,null:y},u.locale=E,u.spec=q,u}}),qe("packages/core/src/internal/text.js",function(t,ce){"use strict";Object.defineProperty(t,"humanise",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(t,"escapeHtml",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(t,"titleCase",{enumerable:!0,get:function(){return ie}});function _e(te){return te?(te.includes(".")?te.slice(te.lastIndexOf(".")+1):te).replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/\s+/g," ").trim().replace(/^./,V=>V.toUpperCase()):""}const H={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function ue(te){const n=te==null?"":String(te);return/[&<>"']/.test(n)?n.replace(/[&<>"']/g,V=>H[V]):n}function ie(te){return String(te).replace(/\w\S*/g,n=>n[0].toUpperCase()+n.slice(1).toLowerCase())}}),qe("packages/core/src/format/text.js",function(t,ce){"use strict";Object.defineProperty(t,"compileText",{enumerable:!0,get:function(){return te}});const H=ce("packages/core/src/internal/predicates.js").isNil,ie=ce("packages/core/src/internal/text.js").titleCase;function te(n,V){const E=n||{},q=E.locale||V||void 0,B=E.nullDisplay??"",f=E.emptyDisplay??"",S=E.transform||"none",y=typeof E.truncate=="number"?{chars:E.truncate}:E.truncate||null,P=y?y.chars:0,N=y?y.ellipsis??"…":"",p=h=>{switch(S){case"upper":return q?h.toLocaleUpperCase(q):h.toUpperCase();case"lower":return q?h.toLocaleLowerCase(q):h.toLowerCase();case"title":return ie(h);default:return h}},u=h=>{if(H(h))return B;let c=typeof h=="string"?h:String(h);return c===""?f:(S!=="none"&&(c=p(c)),P>0&&c.length>P&&(c=c.slice(0,P)+N),c)};return u.spec=E,u}}),qe("packages/core/src/format/shorthand.js",function(t,ce){"use strict";Object.defineProperty(t,"looksLikeMask",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(t,"looksLikeDatePattern",{enumerable:!0,get:function(){return te}}),Object.defineProperty(t,"parseShorthand",{enumerable:!0,get:function(){return V}});const _e=["currency","number","percent","date","boolean","text","relative"],H=/[#0?@;"\\]/,ue=/(yyyy|yy|MMMM|MMM|MM|EEEE|EEE|dd|HH|hh|mm|ss|SSS)/;function ie(E){return typeof E!="string"||E===""||n(E)?!1:H.test(E)}function te(E){return typeof E!="string"||E===""||n(E)?!1:ue.test(E)}function n(E){const q=E.indexOf(":"),B=q===-1?E:E.slice(0,q);return _e.includes(B)?B:null}function V(E){const q=n(E);if(!q)return null;const B=E.indexOf(":"),f=B===-1?"":E.slice(B+1),S=f===""?[]:f.split(":");switch(q){case"currency":{const y={type:"number",style:"currency",currency:S[0]||"USD"};return S[1]!==void 0&&S[1]!==""&&(y.decimals=Number(S[1])),y}case"number":{const y={type:"number",style:"decimal"};return S[0]!==void 0&&S[0]!==""&&(y.decimals=Number(S[0])),y}case"percent":{const y={type:"number",style:"percent"};return S[0]!==void 0&&S[0]!==""&&(y.decimals=Number(S[0])),y}case"date":return{type:"date",pattern:f||void 0};case"relative":return{type:"date",relative:!0};case"boolean":{const y=f.split("/"),P={type:"boolean",display:"text"};return y[0]!==void 0&&y[0]!==""&&(P.trueLabel=y[0]),y[1]!==void 0&&y[1]!==""&&(P.falseLabel=y[1]),y[2]!==void 0&&(P.nullLabel=y[2]),P}case"text":{const y={type:"text"};return S[0]&&(y.transform=S[0]),S[1]!==void 0&&S[1]!==""&&(y.truncate=Number(S[1])),y}default:return null}}}),qe("packages/core/src/format/index.js",function(t,ce){"use strict";Object.defineProperty(t,"compileFormat",{enumerable:!0,get:function(){return C}}),Object.defineProperty(t,"specToOoxml",{enumerable:!0,get:function(){return M}});const _e=ce("packages/core/src/internal/predicates.js"),H=_e.isFunction,ue=_e.isObject,te=ce("packages/core/src/internal/warn.js").warnOnce,n=ce("packages/core/src/format/number.js"),V=n.compileNumber,E=ce("packages/core/src/format/date.js"),q=E.compileDate,B=E.scanPattern,f=ce("packages/core/src/format/boolean.js"),S=f.compileBoolean,y=ce("packages/core/src/format/text.js"),P=y.compileText,N=ce("packages/core/src/format/mask.js"),p=N.compileMask,u=ce("packages/core/src/format/shorthand.js"),h=u.parseShorthand,c=u.looksLikeMask,k=u.looksLikeDatePattern,r=ce("packages/core/src/format/pattern.js").parseNumberPattern;Object.defineProperty(t,"compileNumber",{enumerable:!0,get:function(){return n.compileNumber}}),Object.defineProperty(t,"compileDate",{enumerable:!0,get:function(){return E.compileDate}}),Object.defineProperty(t,"compilePattern",{enumerable:!0,get:function(){return E.compilePattern}}),Object.defineProperty(t,"scanPattern",{enumerable:!0,get:function(){return E.scanPattern}}),Object.defineProperty(t,"toDate",{enumerable:!0,get:function(){return E.toDate}}),Object.defineProperty(t,"compileBoolean",{enumerable:!0,get:function(){return f.compileBoolean}}),Object.defineProperty(t,"toTriState",{enumerable:!0,get:function(){return f.toTriState}}),Object.defineProperty(t,"compileText",{enumerable:!0,get:function(){return y.compileText}}),Object.defineProperty(t,"compileMask",{enumerable:!0,get:function(){return N.compileMask}}),Object.defineProperty(t,"splitSections",{enumerable:!0,get:function(){return N.splitSections}}),Object.defineProperty(t,"parseSection",{enumerable:!0,get:function(){return N.parseSection}}),Object.defineProperty(t,"parseShorthand",{enumerable:!0,get:function(){return u.parseShorthand}}),Object.defineProperty(t,"looksLikeMask",{enumerable:!0,get:function(){return u.looksLikeMask}}),Object.defineProperty(t,"looksLikeDatePattern",{enumerable:!0,get:function(){return u.looksLikeDatePattern}});const v=new Set(["decimal","currency","percent","unit"]),l=new Set(["type","locale"]),x={number:new Set(["style","currency","currencyDisplay","decimals","minDecimals","maxDecimals","thousandsSeparator","decimalSeparator","notation","compactDisplay","negative","negativeClass","signed","prefix","suffix","zeroDisplay","nullDisplay","messages","scale","pattern"]),date:new Set(["pattern","dateStyle","timeStyle","timeZone","relative","nullDisplay"]),boolean:new Set(["display","trueLabel","falseLabel","nullLabel","trueIcon","falseIcon"]),text:new Set(["transform","truncate","nullDisplay","emptyDisplay"])},W=new Set(["number","date","boolean","text"]);function J(R,G){const T=R.type;if(T===void 0||W.has(T)||!v.has(String(T)))return;const e=G?`"${G}"`:"with no id";te(`format:unknown-style-key:${G||""}:${T}`,`column ${e} has format: { type: "${T}" }, which is not a valid format type ("number", "date", "boolean" or "text") and is ignored; did you mean style: "${T}" instead?`)}function se(R,G,T){const e=x[G],s=T?`"${T}"`:"with no id";for(const a of R){if(l.has(a)||e.has(a))continue;const _=Object.keys(x).find($=>$!==G&&x[$].has(a));_?te(`format:inapplicable:${T||""}:${a}`,`column ${s} has format key "${a}", which applies to a ${_} column, not the ${G} column it was applied to; it is ignored.`):te(`format:unknown:${T||""}:${a}`,`column ${s} has an unrecognised format key "${a}" for its ${G} format; it is ignored.`)}}function re(R){if(R.type==="number"||R.type==="date"||R.type==="boolean"||R.type==="text")return!0;const G=v.has(String(R.style));return!!(R.pattern||R.dateStyle||R.timeStyle||R.relative||R.timeZone||R.trueLabel||R.falseLabel||R.display||R.trueIcon||R.falseIcon||R.transform||R.truncate||R.emptyDisplay||G||R.currency||R.decimals!==void 0||R.minDecimals!==void 0||R.maxDecimals!==void 0||R.notation||R.negative||R.scale!==void 0||R.prefix||R.suffix||R.zeroDisplay!==void 0)}function b(R,G){if(R.type==="number"||R.type==="date"||R.type==="boolean"||R.type==="text")return R.type;if(R.pattern){if(c(R.pattern))return"number";if(k(R.pattern))return"date"}if(R.dateStyle||R.timeStyle||R.relative||R.timeZone)return"date";if(R.trueLabel||R.falseLabel||R.display||R.trueIcon||R.falseIcon)return"boolean";if(R.transform||R.truncate||R.emptyDisplay)return"text";if(R.style||R.currency||R.decimals!==void 0||R.minDecimals!==void 0||R.maxDecimals!==void 0||R.notation||R.negative||R.scale!==void 0||R.prefix||R.suffix||R.zeroDisplay!==void 0)return"number";const T=G&&G.base;return T==="number"?"number":T==="date"||T==="dateString"?"date":T==="boolean"?"boolean":"text"}function C(R,G=null,T=void 0,e=void 0,s=void 0){if(R==null||R==="")return null;const a=ue(R)?Object.keys(R):null;if(typeof R=="function"){const Q=(ve,ge)=>String(R({...ge||{},value:ve,locale:T})??"");return Q.ooxml=G&&G.excel||"General",Q}if(typeof R=="string"){if(c(R)){const{format:ve,ooxml:ge}=p(R,T);return ve.ooxml=ge,ve}const Q=h(R)||(k(R)?{type:"date",pattern:R}:null);return Q?C(Q,G,T,e,s):(te(`format:${R}`,`unrecognised format string "${R}"; the value will be stringified`),null)}if(!ue(R))return te("format:shape","format must be a spec object or a string; ignoring",R),null;if(G&&H(G.format)&&!re(R)||G&&H(G.format)&&Array.isArray(G.formatPatterns)&&R.type===void 0)return null;const _=b(R,G);_==="date"&&e&&R.timeZone===void 0&&(R={...R,timeZone:e}),J(R,s),se(a||Object.keys(R),_,s);let $;switch(_){case"number":$=V(R,T);break;case"date":$=q(R,T);break;case"boolean":$=S(R,T);break;default:$=P(R,T);break}return $.ooxml=M(R,_,T,G),$.kind=_,$}const I={yyyy:"yyyy",yy:"yy",MMMM:"mmmm",MMM:"mmm",MM:"mm",M:"m",dd:"dd",d:"d",EEEE:"dddd",EEE:"ddd",HH:"hh",H:"h",hh:"hh",h:"h",mm:"mm",m:"m",ss:"ss",s:"s",SSS:"000",a:"AM/PM"};function M(R,G,T=void 0,e=null){if(G==="date"){if(R.pattern){let Q="";for(const ve of B(R.pattern))Q+=ve.token?I[ve.token]??ve.text:ve.text;return Q}return e&&e.excel||"yyyy-mm-dd"}if(G==="boolean")return"General";if(G==="text")return"@";if(typeof R.pattern=="string"&&r(R.pattern))return String(R.pattern).trim();if(R.notation==="compact"||R.notation==="scientific")return"General";const s=typeof R.decimals=="number"?R.decimals:typeof R.minDecimals=="number"?R.minDecimals:R.style==="currency"?2:0;let _=`${R.thousandsSeparator===!1?"":"#,#"}#0${s>0?`.${"0".repeat(s)}`:""}`,$="";return R.style==="currency"&&($+=X(ne(R.currency||"USD",T))),R.prefix&&($+=X(R.prefix)),_=$+_,R.style==="percent"&&(_=`${_}%`),R.suffix&&(_+=X(R.suffix)),R.negative==="parentheses"?`${_};(${_})`:R.negative==="suffix"?`${_};${_}-`:_}function X(R){return`"${String(R).split('"').join("")}"`}const z=new Map;function ne(R,G){const T=`${R}|${G||""}`;let e=z.get(T);if(e!==void 0)return e;e=R;try{const a=new Intl.NumberFormat(G,{style:"currency",currency:R}).formatToParts(0).find(_=>_.type==="currency");a&&(e=a.value)}catch{}return z.set(T,e),e}}),qe("packages/modules/charts/format.js",function(t,ce){"use strict";Object.defineProperty(t,"precisionFor",{enumerable:!0,get:function(){return E}}),Object.defineProperty(t,"axisNumber",{enumerable:!0,get:function(){return q}}),Object.defineProperty(t,"r2Digits",{enumerable:!0,get:function(){return B}}),Object.defineProperty(t,"dateFormatFor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"resolveTimeZone",{enumerable:!0,get:function(){return y}}),Object.defineProperty(t,"formatters",{enumerable:!0,get:function(){return P}}),Object.defineProperty(t,"measureText",{enumerable:!0,get:function(){return N}}),Object.defineProperty(t,"measureFormat",{enumerable:!0,get:function(){return p}}),Object.defineProperty(t,"stringFormatter",{enumerable:!0,get:function(){return h}});const _e=ce("packages/modules/charts/scale.js"),H=_e.MONTH_STEPS,ue=_e.timeStepFor,te=ce("packages/core/src/format/index.js").compileFormat,V=ce("packages/core/src/internal/warn.js").warnOnce;function E(c){if(!Number.isFinite(c)||c<=0)return 0;const k=Math.ceil(-Math.log10(c));return Math.min(6,Math.max(0,k))}function q(c,k,m=0){return Number.isFinite(c)?Math.abs(c)>=1e4?k.number(c,{notation:"compact",maximumFractionDigits:1}):k.number(c,{minimumFractionDigits:m,maximumFractionDigits:m}):""}function B(c,k){const m=c&&c.messages;return!m||typeof m.number!="function"?Number(k).toFixed(2):m.number(k,{minimumFractionDigits:2,maximumFractionDigits:2})}function f(c){const m=c>0?ue(c):0;return m>0&&m<1e3?{minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}:m>0&&m<6e4?{hour:"2-digit",minute:"2-digit",second:"2-digit"}:c<=864e5?{hour:"2-digit",minute:"2-digit"}:c<=180*864e5?H.has(m)?{month:"short"}:m>0&&m<864e5?{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}:{day:"numeric",month:"short"}:c<=3*365*864e5?{month:"short",year:"numeric"}:{year:"numeric"}}let S;function y(c,k){const m=k&&k.format&&k.format.timeZone;if(m)return m;const r=c&&typeof c.get=="function"&&c.get("timeZone");return r||(S||(S=Intl.DateTimeFormat().resolvedOptions().timeZone),S)}function P(c,k,m){const r=c.messages,v=r.locale,l=y(c,m);if(k.kind==="time"){const W=f(k.span||0),J=new Intl.DateTimeFormat(v,{...W,timeZone:l}),se=new Intl.DateTimeFormat(v,{dateStyle:"medium",timeStyle:"short",timeZone:l});return{tick:re=>Number.isFinite(Number(re))?J.format(new Date(Number(re))):"",value:re=>Number.isFinite(Number(re))?se.format(new Date(Number(re))):""}}const x=E(k.step||0);return{tick:W=>typeof W=="number"?q(W,r,x):String(W??""),value:W=>typeof W=="number"?r.number(W):String(W??"")}}function N(c,k){if(c==null||!Number.isFinite(c))return"";const m=Math.abs(c)>=1e-6?Number(c.toPrecision(6)):c;return k.number(m)}function p(c,k,m){return c==null||!Number.isFinite(Number(c))?"":k&&k.format&&typeof k.formatValue=="function"?String(k.formatValue(c,null)):N(Number(c),m&&m.messages)}const u=new Map;function h(c,k,m){const r=k&&k.messages&&k.messages.locale,v=`${r}\0${c}`;if(!u.has(v)){let x=null;try{x=te(c,null,r)}catch{x=null}u.set(v,x)}const l=u.get(v);return l?x=>String(l(x)):(V(`chart.format.string:${m}:${c}`,`${m}: the format string "${c}" is not understood; values are drawn unformatted`),null)}}),qe("packages/modules/charts/axis.js",function(t,ce){"use strict";Object.defineProperty(t,"pinXDomain",{enumerable:!0,get:function(){return r}}),Object.defineProperty(t,"labelGap",{enumerable:!0,get:function(){return x}}),Object.defineProperty(t,"TICK_FLOOR",{enumerable:!0,get:function(){return W}}),Object.defineProperty(t,"tickFloor",{enumerable:!0,get:function(){return J}}),Object.defineProperty(t,"fitBandLabels",{enumerable:!0,get:function(){return se}}),Object.defineProperty(t,"normaliseAxes",{enumerable:!0,get:function(){return I}}),Object.defineProperty(t,"tickValues",{enumerable:!0,get:function(){return M}}),Object.defineProperty(t,"tickLabeller",{enumerable:!0,get:function(){return X}}),Object.defineProperty(t,"drawAxisTitle",{enumerable:!0,get:function(){return z}}),Object.defineProperty(t,"labelEvery",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(t,"drawMeasureAxis",{enumerable:!0,get:function(){return R}}),Object.defineProperty(t,"heldInside",{enumerable:!0,get:function(){return G}}),Object.defineProperty(t,"drawCategoryAxis",{enumerable:!0,get:function(){return T}}),Object.defineProperty(t,"turnedFirstLabelBox",{enumerable:!0,get:function(){return e}}),Object.defineProperty(t,"leftLabelRoom",{enumerable:!0,get:function(){return s}}),Object.defineProperty(t,"setLabelText",{enumerable:!0,get:function(){return a}}),Object.defineProperty(t,"drawBandLabels",{enumerable:!0,get:function(){return _}}),Object.defineProperty(t,"drawContinuousAxis",{enumerable:!0,get:function(){return $}}),Object.defineProperty(t,"drawAxisLines",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(t,"createGroups",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(t,"MARK_OVERHANG",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(t,"overhangFor",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(t,"setPlotClip",{enumerable:!0,get:function(){return Le}});const H=ce("packages/modules/charts/frame.js").Pool,ue=ce("packages/modules/charts/svg.js"),ie=ue.attrs,te=ue.round,n=ue.setText,V=ue.svg,E=ce("packages/modules/charts/typography.js"),q=E.applySize,B=E.CHAR_RATIO,f=E.truncateTo,y=ce("packages/modules/charts/styles.js").NS,P=ce("packages/modules/charts/scale.js"),N=P.toNumber,p=P.toTime,u=ce("packages/modules/charts/format.js"),h=u.resolveTimeZone,c=u.stringFormatter,m=ce("packages/core/src/internal/warn.js").warnOnce;function r(j,pe,he){const oe=pe&&pe.kind==="time"?p:N,fe=O=>O==null||O===""?null:oe(O),we=fe(he&&he.min),i=fe(he&&he.max);if(we===null&&i===null)return j;if(we!==null&&i!==null)return we<i?{min:we,max:i}:(m("chart.axis.x.domain.inverted",`axis.x.min (${we}) is not below axis.x.max (${i}), which is a mirrored axis rather than a narrow one, so both were ignored and the x domain was taken from the data. On a time axis both are epoch milliseconds.`),j);const Y=we!==null?we:j.min,o=i!==null?i:j.max;if(Y<o)return{min:Y,max:o};const d=Math.abs(j.max-j.min)||1;return m("chart.axis.x.domain.beyond",`axis.x.${we!==null?"min":"max"} is outside the x values entirely, so the plot is empty. The pin was kept and the other edge moved to hold the axis width; check the units (a time axis is pinned in epoch milliseconds).`),we!==null?{min:Y,max:Y+d}:{min:o-d,max:o}}const v=6,l=.53;function x(j){return Number.isFinite(j)&&j>0?Math.max(v,Math.ceil(j)+1):v}const W=9;function J(j){const pe=j&&j.ownerDocument,he=pe&&pe.defaultView;if(!he||typeof he.getComputedStyle!="function")return W;const oe=he.getComputedStyle(j).getPropertyValue("--lattice-chart-tick-min"),fe=parseFloat(oe);return Number.isFinite(fe)&&fe>0?fe:W}function se(j){const{size:pe,floor:he,slot:oe,per:fe}=j,we=Number.isFinite(j.every)&&j.every>0?Number(j.every):null;if(we!==null&&we!==1)return{size:pe,every:we,thinned:!1};if(!(oe>0)||!(fe>0))return{size:pe,every:1,thinned:!1};const i=Math.min(pe,oe/fe);return i>=he?{size:i,every:1,thinned:!1}:{size:he,every:Math.max(1,Math.ceil(he*fe/oe)),thinned:!0}}function re(j,pe){m("chart.axis.band.every.impossible",`axis.x.every/axis.y.every is set to ${pe}, which on ${j} band(s) never shows a second label no matter how much room the axis is given. Lower it, or drop it to let the axis thin automatically.`)}function b(j,pe){const he=Number.isFinite(pe)&&pe>0?Number(pe):null;he!==null&&he>1&&j>1&&he>=j&&re(j,he)}const C=1.2;function I(j){if(j===!1){const oe={labels:!1,grid:!1};return{x:{...oe},y:{...oe},y2:{...oe}}}const pe=j&&typeof j=="object"?j:{},he=oe=>typeof oe=="string"?{title:oe}:oe&&typeof oe=="object"?{...oe}:{};return{x:he(pe.x),y:he(pe.y),y2:he(pe.y2||pe.right)}}function M(j,pe,he){const oe=pe&&pe.ticks;if(Array.isArray(oe)){const we=j.domain;return!we||we.min===void 0?oe:oe.filter(i=>Number(i)>=we.min&&Number(i)<=we.max)}const fe=Number.isFinite(oe)&&oe>0?Number(oe):5;return j.ticks(fe,he)}function X(j,pe,he,oe){const fe=j&&j.format;if(typeof fe=="function")return we=>String(fe(we));if(typeof fe=="string"){const we=c(fe,he,"axis.<x|y|y2>.format");if(we)return we}return oe&&oe.format&&oe.format.pattern&&typeof oe.formatValue=="function"?we=>String(oe.formatValue(we,null)):pe.tick}function z(j){if(!j.text)return;const pe=j.side==="left"||j.side==="right"?j.plot.height:j.plot.width,he=Number.isFinite(pe)?f(String(j.text),Math.max(0,pe),j.size):String(j.text);if(!he||he==="…")return;const oe=V(j.group.ownerDocument,"text",{class:`${y}__axis-title`});if(q(oe,j.size),j.side==="left"){const fe=Math.max(j.size*1.15,j.plot.left-j.plot.gutter.left+j.size*1.15),we=j.plot.top+j.plot.height/2;ie(oe,{transform:`translate(${te(fe)} ${te(we)}) rotate(-90)`,"text-anchor":"middle"})}else if(j.side==="right"){const fe=j.plot.right+j.plot.gutter.right-j.size*1.15,we=j.plot.top+j.plot.height/2;ie(oe,{transform:`translate(${te(fe)} ${te(we)}) rotate(90)`,"text-anchor":"middle"})}else ie(oe,{x:te(j.plot.left+j.plot.width/2),y:te(j.plot.bottom+j.plot.gutter.bottom-2),"text-anchor":"middle"});n(oe,he),he!==String(j.text)&&oe.setAttribute("aria-label",String(j.text)),j.group.appendChild(oe)}function ne(j){const{values:pe,scale:he,size:oe,horizontal:fe,label:we}=j;if(pe.length<2)return 1;let i=1/0;for(let o=1;o<pe.length;o++){const d=Math.abs(he.of(pe[o])-he.of(pe[o-1]));Number.isFinite(d)&&d<i&&(i=d)}if(!Number.isFinite(i))return 1;if(i<=0)return pe.length;let Y=oe*C+2;if(fe){let o=0;for(const d of pe){const O=String(we(d)||"").length*oe*B;O>o&&(o=O)}Y=o+v}return Math.max(1,Math.ceil(Y/i))}function R(j){const{gridGroup:pe,axisGroup:he,plot:oe,scale:fe,format:we}=j,i=j.config||{},Y=fe.kind==="time"&&j.grid?h(j.grid,j.column):void 0,o=M(fe,i,Y),d=X(i,we,j.grid),O=j.size||11,F=ne({values:o,scale:fe,size:O,horizontal:!!j.horizontal,label:d}),U=x(j.overhang),ee=i.grid===!1?null:pe,L=ee?new H(ee):null,Z=new H(he);for(let xe=0;xe<o.length;xe++){const g=o[xe],A=te(fe.of(g)),K=g===0,ae=xe%F!==0;if(j.horizontal){if(L&&ie(L.next("line",`${y}__gridline`),{x1:A,x2:A,y1:te(oe.top),y2:te(oe.bottom),"stroke-opacity":K?1:.6,"stroke-width":K?1.5:1}),i.labels===!1||ae)continue;const ye=d(g),ke=String(ye).length*O*B/2,Te=oe.gutter;if(Te&&(A-ke<oe.left-(Te.left||0)||A+ke>oe.right+(Te.right||0)))continue;const ze=Z.next("text",`${y}__tick`);q(ze,O),ie(ze,{x:A,y:te(oe.bottom+U),"text-anchor":"middle","dominant-baseline":"hanging"}),n(ze,ye)}else{if(L&&ie(L.next("line",`${y}__gridline`),{x1:te(oe.left),x2:te(oe.right),y1:A,y2:A,"stroke-opacity":K?1:.6,"stroke-width":K?1.5:1}),i.labels===!1||ae)continue;const ye=j.side==="right",ke=d(g),Te=G(A,oe,O);if(j.dropBottom&&Math.abs(A-oe.bottom)<=1){if(j.dropBottom===!0)continue;const Ze=String(ke).length*O*B,He=ye?{left:oe.right+U,right:oe.right+U+Ze}:{left:oe.left-U-Ze,right:oe.left-U};He.top=Te-O*.85,He.bottom=Te+O*.6;const Ke=j.dropBottom,Fe=3;if(He.left<Ke.right+Fe&&He.right>Ke.left-Fe&&He.top<Ke.bottom+Fe&&He.bottom>Ke.top-Fe)continue}const ze=Z.next("text",`${y}__tick`);q(ze,O),ie(ze,{x:te(ye?oe.right+U:oe.left-U),y:Te,"text-anchor":ye?"start":"end","dominant-baseline":"middle"}),n(ze,ke)}}return L?L.finish():new H(pe).finish(),Z.finish(),o}function G(j,pe,he){const oe=pe&&pe.gutter;if(!oe)return j;const fe=pe.top-(Number.isFinite(oe.top)?oe.top:0)+he*.85+1,we=pe.bottom+(Number.isFinite(oe.bottom)?oe.bottom:0)-he*.6-1;return te(Math.min(Math.max(j,fe),Math.max(fe,we)))}function T(j){const{group:pe,plot:he,scale:oe,labels:fe}=j,we=j.config||{};if(we.labels===!1){new H(pe).finish();return}const i=new H(pe),Y=oe.domain,o=oe.step,d=we.rotate===void 0||we.rotate==="auto"?j.rotated:!!we.rotate,O=d?se({size:j.fontSize,floor:J(pe),slot:o,per:Math.SQRT2,every:we.every}):{size:j.fontSize,every:Number.isFinite(we.every)&&we.every>0?Number(we.every):1,thinned:!1},{size:F,every:U}=O;b(Y.length,we.every);const ee=o*U;for(let L=0;L<Y.length;L++){const Z=te(oe.centre(Y[L]));if(Number.isNaN(Z)||L%U!==0)continue;const xe=i.next("text",`${y}__tick`);q(xe,F);const g=fe[L]===void 0?"":fe[L];if(d){ie(xe,{x:0,y:0,"text-anchor":"end","dominant-baseline":"middle",transform:`translate(${Z} ${te(he.bottom+v+2)}) rotate(-45)`});const A=ee*Math.SQRT2-F*1.5,K=Math.max(0,he.gutter.bottom-v)*Math.SQRT2;a(xe,g,Math.max(0,Math.min(K,A)),F)}else ie(xe,{x:Z,y:te(he.bottom+v),"text-anchor":"middle","dominant-baseline":"hanging",transform:null}),a(xe,g,ee,F)}i.finish()}function e(j){const{group:pe,plot:he,scale:oe,labels:fe,fontSize:we}=j,i=j.config||{};if(i.labels===!1)return null;const Y=oe.domain;if(!Y||!Y.length||!he.gutter)return null;const o=oe.step,d=se({size:we,floor:J(pe),slot:o,per:Math.SQRT2,every:i.every}),{size:O,every:F}=d,U=te(oe.centre(Y[0]));if(Number.isNaN(U))return null;const L=o*F*Math.SQRT2-O*1.5,Z=Math.max(0,he.gutter.bottom-v)*Math.SQRT2,xe=Math.max(0,Math.min(Z,L)),g=String(fe[0]===void 0?"":fe[0]),K=f(g,xe,O).length*O*l,ae=O*.6,ye=te(he.bottom+v),ke=Math.SQRT1_2;return{left:U-ke*(K+ae),right:U+ke*ae,top:ye-ke*ae,bottom:ye+ke*(K+ae)}}function s(j){return Math.max(0,(j.gutter?j.gutter.left:j.left)-v)}function a(j,pe,he,oe){const fe=String(pe??""),we=f(fe,he,oe);return n(j,we),we!==fe?j.setAttribute("aria-label",fe):j.removeAttribute("aria-label"),we}function _(j){const{group:pe,plot:he,scale:oe,labels:fe}=j,we=j.config||{},i=new H(pe),Y=oe.domain,o=s(he),d=Number.isFinite(j.per)&&j.per>0?j.per:C,O=se({size:j.fontSize,floor:J(pe),slot:oe.step,per:d,every:we.every}),{size:F,every:U}=O;b(Y.length,we.every);for(let ee=0;ee<Y.length;ee++){if(ee%U!==0)continue;const L=te(oe.centre(Y[ee]));if(Number.isNaN(L))continue;const Z=i.next("text",`${y}__tick`);ie(Z,{x:te(he.left-v),y:L,"text-anchor":"end","dominant-baseline":"middle"}),q(Z,F),a(Z,fe[ee],o,F)}i.finish()}function $(j){const{group:pe,plot:he,scale:oe,format:fe}=j,we=j.config||{};if(we.labels===!1){new H(pe).finish();return}const i=X(we,fe,j.grid,j.column),Y=j.size||11,o=he&&he.gutter,d=o&&Number.isFinite(o.left)?he.left-o.left:-1/0,O=o&&Number.isFinite(o.right)?he.right+o.right:1/0,F=x(j.overhang),U=new H(pe),ee=oe.kind==="time"&&j.grid?h(j.grid,j.column):void 0;for(const L of M(oe,we,ee)){const Z=te(oe.of(L));if(Z<he.left-1||Z>he.right+1)continue;const xe=i(L),g=String(xe).length*Y*B/2;if(Z-g<d||Z+g>O)continue;const A=U.next("text",`${y}__tick`);q(A,Y),ie(A,{x:Z,y:te(he.bottom+F),"text-anchor":"middle","dominant-baseline":"hanging"}),n(A,xe)}U.finish()}function Q(j){const{group:pe,plot:he}=j,oe=j.side==="right"?he.right:he.left,fe=new H(pe);ie(fe.next("line"),{x1:te(oe),x2:te(oe),y1:te(he.top),y2:te(he.bottom)}),ie(fe.next("line"),{x1:te(he.left),x2:te(he.right),y1:te(he.bottom),y2:te(he.bottom)}),fe.finish()}let ve=0;function ge(j,pe){const he=`${y}-plot-clip-${++ve}`,oe=V(j,"rect"),fe=V(j,"clipPath",{id:he});fe.appendChild(oe);const we=`${y}-box-clip-${ve}`,i=V(j,"clipPath",{id:we});i.appendChild(V(j,"rect",{x:0,y:0,width:"100%",height:"100%"}));const Y=V(j,"defs");Y.appendChild(fe),Y.appendChild(i);const o={grid:V(j,"g",{class:`${y}__grid`}),marks:V(j,"g",{class:`${y}__marks`}),rules:V(j,"g",{class:`${y}__axis`}),axis:V(j,"g",{class:`${y}__axis`}),labels:V(j,"g",{class:`${y}__labels`}),overlay:V(j,"g",{class:`${y}__overlay`}),clip:oe,clipId:he,boxClipId:we};pe.appendChild(Y);for(const d of["grid","marks","rules","axis","labels","overlay"])pe.appendChild(o[d]);return o}const Se=30;function Ne(j){return j==="bubble"?Se:j==="scatter"?6:3}function Le(j,pe,he){if(!j||!j.marks||!j.clip)return;if(!pe||!Number.isFinite(pe.width)||!Number.isFinite(pe.height)){j.marks.removeAttribute("clip-path");return}const oe=Number.isFinite(he)&&he>=0?Number(he):Se;ie(j.clip,{x:te(pe.left-oe),y:te(pe.top-oe),width:te(Math.max(0,pe.width)+oe*2),height:te(Math.max(0,pe.height)+oe*2)}),j.marks.setAttribute("clip-path",`url(#${j.clipId})`)}}),qe("packages/modules/charts/stack.js",function(t,ce){"use strict";Object.defineProperty(t,"measureValues",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(t,"stacker",{enumerable:!0,get:function(){return ie}});const H=ce("packages/modules/charts/scale.js").isNumber;function ue(te,n,V){if(V)return[0,100];if(!n){const f=[];for(const S of te)for(const y of S.points)f.push(y.y);return f}const E=[],q=[],B=te[0]?te[0].points.length:0;for(let f=0;f<B;f++){let S=0,y=0;for(const P of te){const N=P.points[f]?P.points[f].y:null;H(N)&&(N>=0?S+=N:y+=N)}E.push(S),q.push(y)}return[...E,...q]}function ie(te,n){const V=new Float64Array(te),E=new Float64Array(te);return{take(q,B){const f=n?n[q]:0,S=n?f?B/f*100:0:B;if(S>=0){const P=V[q];return V[q]+=S,[P,V[q]]}const y=E[q];return E[q]+=S,[y,E[q]]}}}}),qe("packages/modules/charts/labels.js",function(t,ce){"use strict";Object.defineProperty(t,"resolveLabels",{enumerable:!0,get:function(){return p}}),Object.defineProperty(t,"collides",{enumerable:!0,get:function(){return u}}),Object.defineProperty(t,"placeLabels",{enumerable:!0,get:function(){return h}}),Object.defineProperty(t,"labelText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(t,"drawAnchoredLabels",{enumerable:!0,get:function(){return k}}),Object.defineProperty(t,"drawDataLabels",{enumerable:!0,get:function(){return m}});const H=ce("packages/modules/charts/frame.js").Pool,ue=ce("packages/modules/charts/format.js"),ie=ue.measureText,te=ue.stringFormatter,n=ce("packages/modules/charts/svg.js"),V=n.attrs,E=n.round,q=n.setText,f=ce("packages/modules/charts/styles.js").NS,S=ce("packages/modules/charts/typography.js"),y=S.applySize,P=S.textWidth,N=4;function p(r){const v=r&&r.labels;if(!v)return{show:!1,names:v!==!1,position:"outside",format:null,minGap:2,total:!1};const l=typeof v=="object"?v:{};return{show:!0,names:!0,position:["outside","inside","auto"].includes(l.position)?l.position:"outside",format:l.format||null,minGap:Number.isFinite(l.minGap)?Number(l.minGap):2,total:!!l.total}}function u(r,v,l){for(const x of v)if(r.x-l<x.x+x.width&&r.x+r.width+l>x.x&&r.y-l<x.y+x.height&&r.y+r.height+l>x.y)return!0;return!1}function h(r){const{points:v,plot:l,size:x}=r,W=r.minGap===void 0?2:r.minGap,J=[],se=[];for(const re of v){if(re.px===void 0||re.py===void 0)continue;const b=r.text(re);if(!b)continue;const C=P(b,x),I=x;let M=re.px,X=re.py-N,z="middle",ne=!1;r.horizontal?(M=re.px+N,X=re.py,z="start",r.position!=="outside"&&re.pbase!==void 0&&Math.abs(re.px-re.pbase)>C+N*2&&(M=re.px-N,z="end",ne=!0)):r.position!=="outside"&&re.pbase!==void 0&&Math.abs(re.pbase-re.py)>I+N*2&&(X=re.py+I+N,ne=!0);const R=()=>({x:z==="middle"?M-C/2:z==="end"?M-C:M,y:X-I,width:C,height:I});let G=R();!(G.y>=l.top-1)&&!ne&&!r.horizontal&&re.pbase!==void 0&&Math.abs(re.pbase-re.py)>I+N*2&&(X=re.py+I+N,ne=!0,G=R()),!(G.x+G.width<=l.right+1)&&!ne&&r.horizontal&&re.pbase!==void 0&&Math.abs(re.px-re.pbase)>C+N*2&&(M=re.px-N,z="end",ne=!0,G=R()),!(G.x<l.left-1||G.x+G.width>l.right+1)&&(G.y<l.top-1||G.y+G.height>l.bottom+I||u(G,J,W)||(J.push(G),se.push({x:E(M),y:E(X),text:b,anchor:z,inside:ne})))}return se}function c(r,v,l){if(r==null)return"";if(typeof v.format=="function")return String(v.format(r));if(typeof v.format=="string"){const x=te(v.format,l,"labels.format");if(x)return x(r)}return ie(r,l&&l.messages)}function k(r){const v=new H(r.group),l=r.minGap===void 0?2:r.minGap,x=r.size,W=[];let J=0;for(const se of r.anchors){if(!se||!se.text)continue;const re=se.width===void 0?P(se.text,r.size):se.width,b=se.anchor||"middle",I={x:b==="end"?se.x-re:b==="start"?se.x:se.x-re/2,y:se.y-x/2,width:re,height:x};if(r.plot&&(I.x<r.plot.left-1||I.x+I.width>r.plot.right+1||I.y<r.plot.top-1||I.y+I.height>r.plot.bottom+1)||se.width!==void 0&&re>se.width||se.height!==void 0&&x>se.height||u(I,W,l))continue;W.push(I);const M=v.next("text",se.className||`${f}__data-label`);y(M,r.size),V(M,{x:E(se.x),y:E(se.y),"text-anchor":b,"dominant-baseline":se.baseline||"middle","data-inside":se.inside?"true":null}),q(M,se.text),J++}return v.finish(),J}function m(r){const v=new H(r.group),{options:l}=r;let x=0;const W=J=>typeof l.format=="function"&&J.y!==null&&J.y!==void 0?String(l.format(J.y,J)):c(J.y,l,r.grid);for(const J of r.series){const se=h({points:J.points,plot:r.plot,size:r.size,position:l.position,horizontal:r.horizontal,minGap:l.minGap,text:W});for(const re of se){const b=v.next("text",`${f}__data-label`);y(b,r.size),V(b,{x:re.x,y:re.y,"text-anchor":re.anchor,"data-inside":re.inside?"true":null}),q(b,re.text),x++}}return v.finish(),x}}),qe("packages/modules/charts/dense.js",function(t,ce){"use strict";Object.defineProperty(t,"CANVAS_THRESHOLD",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(t,"downsample",{enumerable:!0,get:function(){return H}}),Object.defineProperty(t,"markCount",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(t,"wantsCanvas",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(t,"paintDense",{enumerable:!0,get:function(){return te}}),Object.defineProperty(t,"sizeCanvas",{enumerable:!0,get:function(){return n}});const _e=3e3;function H(V,E){const q=V.length;if(!Number.isFinite(E)||E>=q||E<3||q<3)return V;const B=[V[0]],f=(q-2)/(E-2);let S=0;for(let y=0;y<E-2;y++){const P=Math.floor(y*f)+1,N=Math.min(Math.floor((y+1)*f)+1,q-1),p=N,u=Math.min(Math.floor((y+2)*f)+1,q);let h=0,c=0,k=0;for(let l=p;l<u;l++){const x=V[l];!x||!Number.isFinite(x.y)||(h+=x.x,c+=x.y,k++)}k&&(h/=k,c/=k);const m=V[S];if(P>=N)continue;let r=P,v=-1;for(let l=P;l<N;l++){const x=V[l];if(!x||!Number.isFinite(x.y))continue;const W=Math.abs((m.x-h)*(x.y-m.y)-(m.x-x.x)*(c-m.y));W>v&&(v=W,r=l)}r<=S||(B.push(V[r]),S=r)}return B.push(V[q-1]),B}function ue(V){let E=0;for(const q of V)E+=q.points.length;return E}function ie(V){if(V.canvas===!0)return!0;if(V.canvas===!1)return!1;const E=Number.isFinite(V.canvas)?Number(V.canvas):_e;return ue(V.series)>E}function te(V){const{context:E,series:q,ratio:B}=V;E.save(),E.scale(B,B);for(const f of q){const S=V.colour(f.index);if(V.type==="scatter"||V.type==="bubble"){E.fillStyle=S;for(const P of f.points)P.px!==void 0&&(E.beginPath(),E.arc(P.px,P.py,P.pr||2,0,Math.PI*2),E.fill());continue}E.strokeStyle=S,E.lineWidth=2,E.lineJoin="round",E.beginPath();let y=!1;for(const P of f.points){if(P.px===void 0||P.py===void 0){y=!1;continue}y?E.lineTo(P.px,P.py):E.moveTo(P.px,P.py),y=!0}E.stroke()}E.restore()}function n(V){const{canvas:E}=V;return E.width=Math.max(1,Math.round(V.width*V.ratio)),E.height=Math.max(1,Math.round(V.height*V.ratio)),E.style&&(E.style.width=`${V.width}px`,E.style.height=`${V.height}px`),typeof E.getContext=="function"?E.getContext("2d"):null}}),qe("packages/modules/charts/annotations.js",function(t,ce){"use strict";Object.defineProperty(t,"overlayLayer",{enumerable:!0,get:function(){return u}}),Object.defineProperty(t,"annotationValue",{enumerable:!0,get:function(){return x}}),Object.defineProperty(t,"annotationAxis",{enumerable:!0,get:function(){return W}}),Object.defineProperty(t,"annotationText",{enumerable:!0,get:function(){return J}}),Object.defineProperty(t,"drawAnnotations",{enumerable:!0,get:function(){return re}});const H=ce("packages/modules/charts/frame.js").Pool,ue=ce("packages/modules/charts/scale.js"),ie=ue.isNumber,te=ue.toNumber,n=ue.toTime,V=ce("packages/modules/charts/svg.js"),E=V.attrs,q=V.path,B=V.round,f=V.setText,S=V.SVG_NS,P=ce("packages/modules/charts/styles.js").NS,p=ce("packages/core/src/internal/warn.js").warnOnce;function u(b,C){for(const M of b.childNodes||[])if(M&&String(M.getAttribute&&M.getAttribute("class"))===C)return M;const I=b.ownerDocument.createElementNS(S,"g");return I.setAttribute("class",C),b.appendChild(I),I}const h=new Set(["line","target","band","callout","event"]);function c(b,C){return b.kind==="time"?n(C):te(C)}function k(b,C,I){if(b.kind==="band"){const X=b.of(C);if(!Number.isFinite(X))return NaN;const z=Number(b.bandwidth)||0;return I==="right"?X+z:X}const M=c(b,C);return M===null?NaN:b.of(M)}function m(b,C,I){const M=b.kind||"line",X=b.label?` (${JSON.stringify(b.label)})`:"";p(`chart:annotation:dropped:${M}:${C}:${I}`,`chart annotation${X} of kind ${JSON.stringify(M)}, reading the ${C} axis, was not drawn: ${I}.`)}function r(b,C){if(b instanceof Date){const M=b.getTime();return Number.isFinite(M)?b.toISOString().slice(0,10):String(b)}if(typeof b=="number")return Number.isFinite(b)?C(b):String(b);const I=te(b);return I===null||typeof b=="string"?String(b):C(I)}function v(b,C,I){const M=[];for(const X of b)if((X.axis==="right"?"right":"left")===I&&!(C.series!==void 0&&X.key!==C.series))for(const ne of X.points)ie(ne.y)&&M.push(Number(ne.y));return M}function l(b,C){if(!b.length)return null;const I=[...b].sort((ne,R)=>ne-R);if(I.length===1)return I[0];const M=Math.min(100,Math.max(0,C))/100*(I.length-1),X=Math.floor(M),z=Math.ceil(M);return X===z?I[X]:I[X]+(I[z]-I[X])*(M-X)}function x(b,C,I){if(!b.compute)return te(b.value);const M=v(C,b,I);if(!M.length)return null;const X=String(b.compute).toLowerCase();if(X==="mean"||X==="avg")return M.reduce((ne,R)=>ne+R,0)/M.length;if(X==="median"||X==="p50")return l(M,50);if(X==="min")return Math.min(...M);if(X==="max")return Math.max(...M);const z=/^p(\d+(?:\.\d+)?)$/.exec(X);return z?l(M,Number(z[1])):null}function W(b){return b.axis==="right"||b.axis==="y2"?"right":"left"}function J(b,C,I,M){const X=b.label?`${b.label}: `:"",z=M?` (${W(b)==="right"?"right axis":"left axis"})`:"",ne=b.kind||"line";if(ne==="band"){if(!Array.isArray(C)||C[0]===null||C[1]===null)return"";const[G,T]=C;return`${X||"Band: "}${I(Math.min(G,T))} to ${I(Math.max(G,T))}${z}`}return C==null?"":`${X||`${ne==="target"?"Target":ne==="callout"?"Callout":"Reference"}: `}${I(C)}${z}`}function se(b){return(b.kind||"line")==="band"?0:1}function re(b){const{group:C,plot:I,xScale:M,yScale:X,rightScale:z,series:ne,format:R}=b,G=new H(u(C,`${P}__annotations`)),T=[],s=[...Array.isArray(b.annotations)?b.annotations:[]].sort((a,_)=>se(a)-se(_));for(const a of s){const _=a.kind||"line";if(!h.has(_))continue;const $=W(a),Q=$==="right"&&z?z:X;if(_==="band"){if(a.orient==="vertical"){const he=k(M,a.from,"left"),oe=k(M,a.to,"right");if(Number.isNaN(he)||Number.isNaN(oe)){const Y=Number.isNaN(he)&&Number.isNaN(oe)?"from and to":Number.isNaN(he)?"from":"to";m(a,$,`its ${Y} value could not be placed on the x scale`);continue}const fe=B(Math.min(he,oe)),we=B(Math.max(he,oe));if(E(G.next("rect",`${P}__annotation-band ${a.className||""}`.trim()),{x:fe,y:B(I.top),width:Math.max(0,we-fe),height:B(Math.max(0,I.bottom-I.top)),fill:a.colour||"currentColor","fill-opacity":a.opacity===void 0?.12:a.opacity}),a.label){const Y=G.next("text",`${P}__annotation-label`);E(Y,{x:fe+4,y:B(I.top+12),"text-anchor":"start"}),f(Y,a.label)}const i=a.label?`${a.label}: `:"Event window: ";T.push({text:`${i}${r(a.from,R)} to ${r(a.to,R)}`});continue}const Ne=x({...a,value:a.from,compute:a.fromCompute},ne,$),Le=x({...a,value:a.to,compute:a.toCompute},ne,$);if(Ne===null||Le===null){m(a,$,`its ${Ne===null&&Le===null?"from and to":Ne===null?"from":"to"} value could not be resolved (a number, or a compute that finds values)`);continue}const j=B(Q.of(Ne)),pe=B(Q.of(Le));if(E(G.next("rect",`${P}__annotation-band ${a.className||""}`.trim()),{x:B(I.left),y:Math.min(j,pe),width:B(Math.max(0,I.right-I.left)),height:Math.max(0,Math.abs(pe-j)),fill:a.colour||"currentColor","fill-opacity":a.opacity===void 0?.12:a.opacity}),a.label){const he=G.next("text",`${P}__annotation-label`);E(he,{x:B(I.left+4),y:Math.min(j,pe)+12,"text-anchor":"start"}),f(he,a.label)}T.push({text:J(a,[Ne,Le],R,b.dual)});continue}if(_==="event"){const Ne=a.x!==void 0?a.x:a.at,Le=B(k(M,Ne,"left")+(M.kind==="band"?(Number(M.bandwidth)||0)/2:0));if(Number.isNaN(Le)){m(a,$,"its x value could not be placed on the x scale");continue}if(E(G.next("path",`${P}__annotation-event`),{d:q(["M",Le,B(I.top),"L",Le,B(I.bottom)]),stroke:a.colour||"currentColor",fill:"none"}),E(G.next("circle",`${P}__annotation-event-flag`),{cx:Le,cy:B(I.top),r:3,fill:a.colour||"currentColor"}),a.label){const pe=G.next("text",`${P}__annotation-label`);E(pe,{x:Le+5,y:B(I.top+10),"text-anchor":"start"}),f(pe,a.label)}const j=a.label?`${a.label} — `:"Event — ";T.push({text:`${j}at ${r(Ne,R)}`});continue}if(_==="callout"){const Ne=x(a,ne,$);if(Ne===null){m(a,$,"its value could not be resolved (a number, or a compute that finds values)");continue}const Le=a.at!==void 0?B(M.kind==="band"?M.centre(a.at):M.of(c(M,a.at)??NaN)):B(I.right-4),j=B(Q.of(Ne));if(Number.isNaN(Le)){m(a,$,"its x value could not be placed on the x scale");continue}if(E(G.next("circle",`${P}__annotation-point`),{cx:Le,cy:j,r:3.5,fill:a.colour||"currentColor"}),a.label){const pe=G.next("text",`${P}__annotation-label`);E(pe,{x:Le+6,y:j-6,"text-anchor":"start"}),f(pe,a.label)}T.push({text:J(a,Ne,R,b.dual)});continue}if(a.orient==="vertical"||a.x!==void 0){const Ne=a.x!==void 0?a.x:a.value,Le=M.kind==="band"?B(M.centre(Ne)):B(M.of(c(M,Ne)??NaN));if(Number.isNaN(Le)){m(a,$,"its x value could not be placed on the x scale");continue}const j=_==="target"?`${P}__annotation-target`:`${P}__annotation-line`;if(E(G.next("path",j),{d:q(["M",Le,B(I.top),"L",Le,B(I.bottom)]),stroke:a.colour||"currentColor",fill:"none"}),a.label){const pe=G.next("text",`${P}__annotation-label`);E(pe,{x:Le+4,y:B(I.top+10),"text-anchor":"start"}),f(pe,a.label)}T.push({text:a.label?`${a.label} — at ${r(Ne,R)}`:""});continue}const ve=x(a,ne,$);if(ve===null){m(a,$,"its value could not be resolved (a number, or a compute that finds values)");continue}const ge=B(Q.of(ve)),Se=_==="target"?`${P}__annotation-target`:`${P}__annotation-line`;if(E(G.next("path",Se),{d:b.horizontal?q(["M",ge,B(I.top),"L",ge,B(I.bottom)]):q(["M",B(I.left),ge,"L",B(I.right),ge]),stroke:a.colour||"currentColor",fill:"none"}),a.label){const Ne=G.next("text",`${P}__annotation-label`);E(Ne,b.horizontal?{x:ge+4,y:B(I.top+10),"text-anchor":"start"}:{x:B(I.right-4),y:ge-4,"text-anchor":"end"}),f(Ne,a.label)}T.push({text:J(a,ve,R,b.dual)})}return G.finish(),T.filter(a=>a.text)}}),qe("packages/modules/charts/curve.js",function(t,ce){"use strict";Object.defineProperty(t,"CURVES",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(t,"STEP_MODES",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(t,"resolveCurve",{enumerable:!0,get:function(){return te}}),Object.defineProperty(t,"curveCommands",{enumerable:!0,get:function(){return n}});const H=ce("packages/modules/charts/svg.js").round,ue=Object.freeze(["linear","monotone","catmullRom","step"]),ie=Object.freeze(["after","before","middle"]);function te(f,S){let y=f;if(y&&typeof y=="object"&&!Array.isArray(y)&&typeof y.type!="string"&&(y=S!=null&&Object.prototype.hasOwnProperty.call(y,S)?y[S]:void 0),y==null||y===!0||y===!1)return null;if(typeof y=="string")return y==="linear"?null:ue.includes(y)?{type:y,tension:1,mode:"after"}:null;if(typeof y=="object"){const P=typeof y.type=="string"&&ue.includes(y.type)?y.type:"linear";if(P==="linear")return null;const N=Number.isFinite(y.tension)?Math.max(0,Math.min(1,Number(y.tension))):1,p=ie.includes(y.mode)?y.mode:"after";return{type:P,tension:N,mode:p}}return null}function n(f,S){return f.length?!S||S.type==="linear"?V(f):S.type==="step"?E(f,S.mode):S.type==="monotone"?q(f):S.type==="catmullRom"?B(f,S.tension):V(f):[]}function V(f){const S=["M",H(f[0].x),H(f[0].y)];for(let y=1;y<f.length;y++)S.push("L",H(f[y].x),H(f[y].y));return S}function E(f,S){const y=["M",H(f[0].x),H(f[0].y)];for(let P=1;P<f.length;P++){const N=f[P-1].x,p=f[P-1].y,u=f[P].x,h=f[P].y;if(S==="before")y.push("L",H(N),H(h),"L",H(u),H(h));else if(S==="middle"){const c=H((N+u)/2);y.push("L",c,H(p),"L",c,H(h),"L",H(u),H(h))}else y.push("L",H(u),H(p),"L",H(u),H(h))}return y}function q(f){const S=f.length;if(S<2)return["M",H(f[0].x),H(f[0].y)];if(S===2)return["M",H(f[0].x),H(f[0].y),"L",H(f[1].x),H(f[1].y)];const y=[];for(let p=0;p<S-1;p++){const u=f[p+1].x-f[p].x,h=f[p+1].y-f[p].y;y[p]=u===0?0:h/u}const P=new Array(S);P[0]=y[0],P[S-1]=y[S-2];for(let p=1;p<S-1;p++)P[p]=y[p-1]*y[p]<=0?0:(y[p-1]+y[p])/2;for(let p=0;p<S-1;p++)y[p]===0&&(P[p]=0,P[p+1]=0);for(let p=0;p<10;p++){let u=!1;for(let h=0;h<S-1;h++){if(y[h]===0)continue;const c=P[h]/y[h],k=P[h+1]/y[h],m=c*c+k*k;if(m>9){const r=3/Math.sqrt(m);P[h]=r*c*y[h],P[h+1]=r*k*y[h],u=!0}}if(!u)break}const N=["M",H(f[0].x),H(f[0].y)];for(let p=0;p<S-1;p++){const u=f[p].x,h=f[p].y,c=f[p+1].x,k=f[p+1].y,m=c-u,r=u+m/3,v=h+P[p]*m/3,l=c-m/3,x=k-P[p+1]*m/3;N.push("C",H(r),H(v),H(l),H(x),H(c),H(k))}return N}function B(f,S){const y=f.length;if(y<2)return["M",H(f[0].x),H(f[0].y)];const P=Number.isFinite(S)?Math.max(0,Math.min(1,S)):1,N=["M",H(f[0].x),H(f[0].y)];for(let p=0;p<y-1;p++){const u=f[p-1]||f[p],h=f[p],c=f[p+1],k=f[p+2]||f[p+1],m=h.x+(c.x-u.x)/6*P,r=h.y+(c.y-u.y)/6*P,v=c.x-(k.x-h.x)/6*P,l=c.y-(k.y-h.y)/6*P;N.push("C",H(m),H(r),H(v),H(l),H(c.x),H(c.y))}return N}}),qe("packages/modules/charts/combo.js",function(t,ce){"use strict";Object.defineProperty(t,"toPareto",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(t,"drawCombo",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(t,"drawRightAxis",{enumerable:!0,get:function(){return we}});const _e=ce("packages/modules/charts/axis.js"),H=_e.drawAxisLines,ue=_e.drawAxisTitle,ie=_e.drawCategoryAxis,te=_e.drawContinuousAxis,n=_e.drawMeasureAxis,V=_e.heldInside,E=_e.turnedFirstLabelBox,q=_e.labelGap,B=_e.overhangFor,f=_e.pinXDomain,S=_e.setPlotClip,y=_e.tickLabeller,P=_e.tickValues,N=ce("packages/modules/charts/frame.js"),p=N.Pool,u=N.shouldRotate,c=ce("packages/modules/charts/format.js").formatters,k=ce("packages/modules/charts/scale.js"),m=k.bandScale,r=k.extent,v=k.isNumber,l=k.linearScale,x=k.measureDomain,W=k.timeScale,J=k.toNumber,se=k.toTime,re=ce("packages/modules/charts/stack.js"),b=re.measureValues,C=re.stacker,I=ce("packages/modules/charts/svg.js"),M=I.attrs,X=I.path,z=I.round,R=ce("packages/modules/charts/styles.js").NS,T=ce("packages/modules/charts/scheme.js").resolveScheme,s=ce("packages/modules/charts/labels.js").drawDataLabels,_=ce("packages/modules/charts/annotations.js").drawAnnotations,$=ce("packages/modules/charts/curve.js"),Q=$.curveCommands,ve=$.resolveCurve;function ge(i){return{left:i.filter(Y=>Y.axis!=="right"),right:i.filter(Y=>Y.axis==="right")}}function Se(i,Y){const o=i&&i.seriesStyle&&i.seriesStyle[Y];if(o)return{width:o.width!=null?String(o.width):null,dash:Array.isArray(o.dash)&&o.dash.length?o.dash.join(" "):null,opacity:null,emphasized:!1};const d=i&&Array.isArray(i.emphasis)?i.emphasis:null;if(!d||!d.length)return{width:null,dash:null,opacity:null,emphasized:!1};const O=d.includes(Y);return{width:O?"var(--lattice-chart-emphasis-width, 3.5)":null,dash:null,opacity:O?null:"var(--lattice-chart-muted-opacity, .35)",emphasized:O}}function Ne(i,Y,o,d,O=null){const F=[];let U=[];const ee=()=>{U.length===1?F.push("M",U[0].x,U[0].y):U.length>1&&F.push(...Q(U,O)),U=[]};for(const L of Y.points){if(L.px===void 0){ee();continue}U.push({x:L.px,y:L.py})}ee(),M(i.next("path",`${R}__line ${R}__mark`),{d:F.length?X(F):"",stroke:o,"data-series":Y.index,"stroke-width":d.width,"stroke-dasharray":d.dash,opacity:d.opacity});for(const L of Y.points)L.px!==void 0&&M(i.next("circle",`${R}__point ${R}__mark`),{cx:L.px,cy:L.py,r:3,fill:o})}function Le(i,Y){return Y?{tick:o=>`${i.tick(o)}%`,value:o=>`${i.value(o)}%`}:i}function j(i,Y,o,d,O){const F=i.filter(L=>(L.mark||"bar")==="bar"),U=i.filter(L=>(L.mark||"bar")!=="bar"),ee=d?b(F,!0,!0):o?[...b(F,!0,!1),...U.length?b(U,!1,!1):[]]:b(i,!1,!1);return x(ee,{zero:Y,min:O&&O.min,max:O&&O.max})}function pe(i){const Y=i.series[0];if(!Y)return i;const o=Y.points.map((U,ee)=>({point:U,label:i.labels[ee],category:i.categories[ee]})).filter(U=>v(U.point.y)).sort((U,ee)=>ee.point.y-U.point.y),d=o.reduce((U,ee)=>U+ee.point.y,0);let O=0;const F=o.map(U=>(O+=U.point.y,d>0?O/d*100:0));return{...i,categories:o.map(U=>U.category),labels:o.map(U=>U.label),series:[{...Y,index:0,mark:"bar",axis:"left",points:o.map(U=>U.point)},{key:"cumulative",label:i.cumulativeLabel||"%",index:1,mark:"line",axis:"right",points:o.map((U,ee)=>({x:U.category,xKey:U.point.xKey,label:U.label,y:F[ee],rows:U.point.rows,rowKey:U.point.rowKey}))}]}}function he(i,Y,o){const d=[Y.left,Y.right];if(i.kind!=="time"&&i.kind!=="linear")return m(i.categories,d,.2);const O=i.kind==="time"?i.categories.map(se):i.categories.map(J);if(i.kind==="time"){const ee=r(O);if(ee&&ee.min===ee.max)return W(f({min:ee.min-3e4,max:ee.max+3e4},i,o),d)}const F=i.xDomain||x(O,{zero:!1,nice:i.kind!=="time"}),U=i.xDomain?F:f(F,i,o);return i.kind==="time"?W(U,d):l(U,d)}function oe(i,Y){const o=[...new Set(i.filter(ee=>Number.isFinite(ee)))].sort((ee,L)=>ee-L);if(o.length<2){const[ee,L]=Y.range;return Math.max(4,(L-ee)/10)}const d=[];for(let ee=1;ee<o.length;ee++)d.push(o[ee]-o[ee-1]);d.sort((ee,L)=>ee-L);const O=Math.floor(d.length/2),F=d.length%2?d[O]:(d[O-1]+d[O])/2,U=Math.abs(Y.of(o[0]+F)-Y.of(o[0]));return Math.max(1,U*.8)}function fe(i){const Y=i.scheme||T(),o=i.axis||{x:{},y:{},y2:{}},{plot:d}=i,O=i.pareto?pe(i.bound):i.bound,F=O.series.filter(et=>!i.hidden.has(et.key)),U=ge(F),ee=et=>(et.mark||"bar")==="bar",L=U.left.some(ee),Z=U.left.filter(ee),xe=i.stack==="percent"&&Z.length>1&&!U.right.length,g=(xe||!!i.stack)&&Z.length>1&&!U.right.length,A=O.yDomain||j(U.left,L,g,xe,o.y),K=l(A,[d.bottom,d.top]),ae=U.right.length?i.pareto?{min:0,max:100}:j(U.right,U.right.some(ee),!1,!1,o.y2):null,ye=ae?l(ae,[d.bottom,d.top]):null,ke=he(O,d,o.x),Te=ke.kind!=="band",ze=Te?O.categories.map(et=>O.kind==="time"?se(et):J(et)):null,Ze=Te&&F.some(et=>(et.mark||"bar")==="bar")?oe(ze,ke)/2:0,Ke=!Te&&(o.x.rotate===void 0||o.x.rotate==="auto"?u(O.labels,ke.step,i.fontSize):!!o.x.rotate)&&E({group:i.groups.overlay,plot:d,scale:ke,labels:O.labels,fontSize:i.fontSize,config:o.x}),Fe=o.y.position==="right"?"right":"left";n({gridGroup:i.groups.grid,axisGroup:i.groups.axis,plot:d,scale:K,format:Le(c(i.grid,{kind:"linear",step:(A.max-A.min)/5}),xe),config:o.y,grid:i.grid,size:i.fontSize,side:Fe,overhang:Ze,dropBottom:Ke});const ct=O.dimension&&O.dimension.col?i.grid.columns.get(O.dimension.col):void 0;Te?te({group:i.groups.overlay,plot:d,scale:ke,format:c(i.grid,{kind:O.kind,span:ke.domain.max-ke.domain.min,step:(ke.domain.max-ke.domain.min)/5},ct),config:o.x,grid:i.grid,column:ct,size:i.fontSize}):ie({group:i.groups.overlay,plot:d,scale:ke,labels:O.labels,fontSize:i.fontSize,rotated:u(O.labels,ke.step,i.fontSize),config:o.x}),H({group:i.groups.rules,plot:d,side:Fe});const tt=i.typography&&i.typography.axisTitle||i.fontSize;if(ue({group:i.groups.axis,plot:d,text:o.y.title,side:Fe,size:tt}),ue({group:i.groups.axis,plot:d,text:o.x.title,side:"bottom",size:tt}),ye){we({group:i.groups.axis,plot:d,scale:ye,colour:Y.series(U.right[0].index,U.right[0].label),format:c(i.grid,{kind:"linear",step:(ae.max-ae.min)/5}),config:o.y2,grid:i.grid,suffix:i.pareto?"%":"",side:Fe==="right"?"left":"right",overhang:Ze});const et=o.y2.title||(U.right.length===1?U.right[0].label:"");ue({group:i.groups.axis,plot:d,text:et,side:Fe==="right"?"left":"right",size:tt})}S(i.groups,d,B(i.type));const pt=new p(i.groups.marks),Lt=F.filter(et=>(et.mark||"bar")==="bar"),jt=Te?oe(ze,ke):ke.bandwidth,wt=g?jt:Lt.length?jt/Lt.length:jt,gt=xe?O.categories.map((et,Bt)=>Z.reduce((Dt,Ut)=>{const Ht=Ut.points[Bt]?Ut.points[Bt].y:null;return v(Ht)?Dt+Math.abs(Ht):Dt},0)):null,mt=g?C(O.categories.length,gt):null;let Mt=0;const ft=[];for(const et of F){const Bt=et.mark||"bar",Dt=et.axis==="right"&&ye?ye:K,Ut=Y.series(et.index,et.label);if(Bt==="bar"){const xt=g?0:Mt*wt;Mt++;const Wt=Dt.of(Math.max(Dt.domain.min,0));for(let Gt=0;Gt<et.points.length;Gt++){const It=et.points[Gt];if(!v(It.y))continue;let _t;if(Te){const Jt=O.kind==="time"?se(It.x):J(It.x);_t=Jt===null?NaN:ke.of(Jt)-jt/2}else _t=ke.of(It.x);if(Number.isNaN(_t))continue;const Xt=mt?mt.take(Gt,It.y):null,Yt=Dt.of(Xt?Xt[1]:It.y),qt=Xt?Dt.of(Xt[0]):Wt;M(pt.next("rect",`${R}__bar ${R}__mark`),{x:z(_t+xt),y:z(Math.min(Yt,qt)),width:z(Math.max(0,wt)),height:z(Math.max(1,Math.abs(qt-Yt))),fill:Ut,"data-series":et.index,"data-point":Gt}),It.px=z(_t+xt+wt/2),It.py=z(Math.min(Yt,qt))}continue}for(const xt of et.points){if(!v(xt.y)){xt.px=void 0;continue}let Wt;if(Te){const It=O.kind==="time"?se(xt.x):J(xt.x);Wt=It===null?NaN:z(ke.of(It))}else Wt=z(ke.centre(xt.x));if(Number.isNaN(Wt)){xt.px=void 0;continue}const Gt=z(Dt.of(xt.y));xt.px=Wt,xt.py=Gt}const Ht=Se(i,et.label),Ft=ve(i.curve,et.label);Ht.emphasized?ft.push({series:et,colour:Ut,style:Ht,curve:Ft}):Ne(pt,et,Ut,Ht,Ft)}for(const et of ft)Ne(pt,et.series,et.colour,et.style,et.curve);pt.finish(),i.labels&&i.labels.show&&s({group:i.groups.labels,series:F,plot:d,options:i.labels,grid:i.grid,size:i.typography&&i.typography.small||i.fontSize});let ht=null;return i.annotations&&i.annotations.length&&(ht=_({group:i.groups.overlay,plot:d,xScale:ke,yScale:K,rightScale:ye,series:F,annotations:i.annotations,dual:!!ye,format:c(i.grid,{kind:"linear",step:(A.max-A.min)/5}).tick})),{xScale:ke,yScale:K,rightScale:ye,dual:!!ye,series:F,bound:O,annotations:ht,percent:xe,percentTotals:gt}}function we(i){const{group:Y,plot:o,scale:d,format:O}=i,F=i.config||{},U=i.side==="left"?"left":"right",ee=U==="right"?o.right:o.left,L=y(F,O,i.grid),Z=new p(Y,Y.childNodes.length),xe=q(i.overhang);M(Z.next("line",`${R}__axis-right`),{x1:z(ee),x2:z(ee),y1:z(o.top),y2:z(o.bottom),stroke:i.colour});for(const g of P(d,F)){const A=z(d.of(g)),K=Z.next("text",`${R}__tick`);M(K,{x:z(U==="right"?o.right+xe:o.left-xe),y:V(A,o,11),"text-anchor":U==="right"?"start":"end","dominant-baseline":"middle",fill:i.colour}),K.textContent=`${L(g)}${i.suffix||""}`}Z.finish()}}),qe("packages/modules/charts/quantile.js",function(t,ce){"use strict";Object.defineProperty(t,"normalQuantile",{enumerable:!0,get:function(){return E}}),Object.defineProperty(t,"studentTQuantile",{enumerable:!0,get:function(){return B}});const _e=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),H=3e-12,ue=1e-300;function ie(f){if(f<.5)return Math.log(Math.PI/Math.sin(Math.PI*f))-ie(1-f);const S=f-1;let y=.9999999999998099;const P=S+7.5;for(let N=0;N<_e.length;N++)y+=_e[N]/(S+N+1);return .5*Math.log(2*Math.PI)+(S+.5)*Math.log(P)-P+Math.log(y)}function te(f,S,y){const P=f+S,N=f+1,p=f-1;let u=1,h=1-P*y/N;Math.abs(h)<ue&&(h=ue),h=1/h;let c=h;for(let k=1;k<=300;k++){const m=2*k;let r=k*(S-k)*y/((p+m)*(f+m));h=1+r*h,Math.abs(h)<ue&&(h=ue),u=1+r/u,Math.abs(u)<ue&&(u=ue),h=1/h,c*=h*u,r=-(f+k)*(P+k)*y/((f+m)*(N+m)),h=1+r*h,Math.abs(h)<ue&&(h=ue),u=1+r/u,Math.abs(u)<ue&&(u=ue),h=1/h;const v=h*u;if(c*=v,Math.abs(v-1)<H)break}return c}function n(f,S,y){if(!(f>0)||!(S>0)||!Number.isFinite(y))return Number.NaN;if(y<=0)return 0;if(y>=1)return 1;const P=Math.exp(ie(f+S)-ie(f)-ie(S)+f*Math.log(y)+S*Math.log(1-y));return y<(f+1)/(f+S+2)?P*te(f,S,y)/f:1-P*te(S,f,1-y)/S}function V(f){const S=Math.abs(f),y=2/(2+S),P=4*y-2,N=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let p=0,u=0,h;for(let k=N.length-1;k>0;k--)h=u,u=P*u-p+N[k],p=h;const c=y*Math.exp(-S*S+.5*(N[0]+P*u)-p);return f>=0?c:2-c}function E(f){if(!(f>0)||!(f<1))return f===0?-1/0:f===1?1/0:Number.NaN;const S=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],y=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],P=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],N=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],p=.02425;let u,h,c;f<p?(u=Math.sqrt(-2*Math.log(f)),c=(((((P[0]*u+P[1])*u+P[2])*u+P[3])*u+P[4])*u+P[5])/((((N[0]*u+N[1])*u+N[2])*u+N[3])*u+1)):f<=1-p?(u=f-.5,h=u*u,c=(((((S[0]*h+S[1])*h+S[2])*h+S[3])*h+S[4])*h+S[5])*u/(((((y[0]*h+y[1])*h+y[2])*h+y[3])*h+y[4])*h+1)):(u=Math.sqrt(-2*Math.log(1-f)),c=-(((((P[0]*u+P[1])*u+P[2])*u+P[3])*u+P[4])*u+P[5])/((((N[0]*u+N[1])*u+N[2])*u+N[3])*u+1));const m=(.5*V(-c/Math.SQRT2)-f)*Math.sqrt(2*Math.PI)*Math.exp(c*c/2);return c-m/(1+c*m/2)}function q(f,S){if(!(S>0)||!Number.isFinite(f))return Number.NaN;const y=.5*n(S/2,.5,S/(S+f*f));return f>0?1-y:y}function B(f,S){if(!(f>0)||!(f<1)||!(S>0))return Number.NaN;if(S>1e7)return E(f);let y=-1e4,P=1e4,N=E(f);const p=ie(S/2)+ie(.5)-ie((S+1)/2);for(let u=0;u<60;u++){const h=q(N,S);h<f?y=N:P=N;const c=Math.exp(-((S+1)/2)*Math.log(1+N*N/S)-p)/Math.sqrt(S),k=c>0?(h-f)/c:0;if(Math.abs(k)<1e-12)break;const m=N-k;if(N=m>y&&m<P&&Number.isFinite(m)?m:(y+P)/2,P-y<1e-12)break}return N}}),qe("packages/modules/charts/trendline.js",function(t,ce){"use strict";Object.defineProperty(t,"normaliseTrends",{enumerable:!0,get:function(){return x}}),Object.defineProperty(t,"linearTrend",{enumerable:!0,get:function(){return re}}),Object.defineProperty(t,"movingAverageTrend",{enumerable:!0,get:function(){return b}}),Object.defineProperty(t,"exponentialTrend",{enumerable:!0,get:function(){return X}}),Object.defineProperty(t,"computeTrend",{enumerable:!0,get:function(){return z}}),Object.defineProperty(t,"trendText",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(t,"drawTrendlines",{enumerable:!0,get:function(){return R}});const H=ce("packages/modules/charts/frame.js").Pool,ue=ce("packages/modules/charts/svg.js"),ie=ue.attrs,te=ue.path,n=ue.ribbonPath,V=ue.round,E=ue.setText,q=ue.SVG_NS,f=ce("packages/modules/charts/typography.js").applySize,y=ce("packages/modules/charts/styles.js").NS,P=ce("packages/modules/charts/scale.js"),N=P.toNumber,p=P.toTime,h=ce("packages/modules/charts/quantile.js").studentTQuantile,k=ce("packages/modules/charts/format.js").r2Digits,m={linear:new Set(["linear","lr","ols","regression","least-squares"]),movingAverage:new Set(["movingaverage","moving-average","ma","sma","rolling"]),exponential:new Set(["exponential","exp","ewma","ses","holt","smoothing"])},r=1e-4,v=1-1e-4;function l(G){const T=String(G||"linear").toLowerCase();return m.linear.has(T)?"linear":m.movingAverage.has(T)?"movingAverage":m.exponential.has(T)?"exponential":null}function x(G){if(!G)return[];const T=Array.isArray(G)?G:[G],e=[];for(const s of T){if(s===!0){e.push({method:"linear"});continue}if(typeof s=="string"){const a=l(s);a&&e.push({method:a});continue}if(s&&typeof s=="object"){const a=l(s.method);a&&e.push({...s,method:a})}}return e}function W(G,T){if(G.kind==="band")return G.centre(T);const e=G.kind==="time"?p(T):N(T);return e===null?NaN:G.of(e)}function J(G){const T=[];for(const e of G.points){const s=Number(e.y);T.push({value:Number.isFinite(s)?s:null,rawX:e.x})}return T}function se(G,T){const e=[];for(const s of G.points){const a=T.kind==="time"?p(s.x):N(s.x),_=Number(s.y);a===null||!Number.isFinite(a)||!Number.isFinite(_)||e.push({x:a,y:_})}return e.sort((s,a)=>s.x-a.x),e}function re(G,T,e={}){const s=G.length;if(s<2)return null;let a=0,_=0;for(const i of G)a+=i.x,_+=i.y;a/=s,_/=s;let $=0,Q=0,ve=0;for(const i of G){const Y=i.x-a,o=i.y-_;$+=Y*Y,Q+=Y*o,ve+=o*o}if($===0)return null;const ge=Q/$,Se=_-ge*a,Ne=ve===0?1:Math.max(0,Math.min(1,Q*Q/($*ve))),Le=G[0].x,j=G[s-1].x,pe=i=>({x:i,y:Se+ge*i}),he=[pe(Le),pe(j)],oe=[];let fe=null;const we=Math.max(0,Math.floor(Number(T)||0));if(we>0&&j>Le){const i=(j-Le)/(s-1);if(i>0&&(oe.push(pe(j),pe(j+we*i)),s>2)){const Y=Number.isFinite(e.confidence)&&e.confidence>0&&e.confidence<1?Number(e.confidence):.95,o=1-(1-Y)/2,d=Math.max(0,ve-ge*Q),O=Math.sqrt(d/(s-2)),F=h(o,s-2),U=[];for(let ee=0;ee<=we;ee++){const L=j+ee*i,Z=Se+ge*L,xe=1/s+(L-a)**2/$,g=O*Math.sqrt(1+xe),A=O*Math.sqrt(xe);U.push({x:L,mean:Z,lower:Z-F*g,upper:Z+F*g,lowerMean:Z-F*A,upperMean:Z+F*A})}fe={confidence:Y,points:U}}}return{fit:he,forecast:oe,band:fe,stats:{method:"linear",slope:ge,intercept:Se,r2:Ne,n:s,forecast:oe.length?we:0,confidence:fe?fe.confidence:null}}}function b(G,T){const e=Math.max(1,Math.floor(Number(T)||3)),s=[];let a=0;const _=[];for(const $ of G)Number.isFinite($.value)&&(s.push($.value),a+=$.value,s.length>e&&(a-=s.shift())),s.length&&_.push({x:$.rawX,y:a/s.length});return _.length<2?null:{fit:_,stats:{method:"movingAverage",window:e}}}function C(G,T){const e=G.length,s=new Array(e).fill(null);let a=null,_=0;for(let $=0;$<e;$++){const Q=G[$];if(!Number.isFinite(Q)){a!==null&&(s[$]=a);continue}if(a===null){a=Q,s[$]=Q;continue}_+=(Q-a)**2,a=T*Q+(1-T)*a,s[$]=a}return{smoothed:s,sse:_}}function I(G,T,e){const s=G.length,a=new Array(s).fill(null);let _=null,$=null,Q=0;for(let ve=0;ve<s;ve++){const ge=G[ve];if(!Number.isFinite(ge)){_!==null&&(_+=$,a[ve]=_);continue}if(_===null){_=ge,a[ve]=ge;continue}if($===null){$=ge-_;const Le=_+$;Q+=(ge-Le)**2;const j=_;_=T*ge+(1-T)*(j+$),$=e*(_-j)+(1-e)*$,a[ve]=_;continue}const Se=_+$;Q+=(ge-Se)**2;const Ne=_;_=T*ge+(1-T)*(Ne+$),$=e*(_-Ne)+(1-e)*$,a[ve]=_}return{smoothed:a,sse:Q}}function M(G,T,e,s=80){const a=(Math.sqrt(5)-1)/2;let _=T,$=e,Q=$-a*($-_),ve=_+a*($-_),ge=G(Q),Se=G(ve);for(let Ne=0;Ne<s;Ne++)ge<Se?($=ve,ve=Q,Se=ge,Q=$-a*($-_),ge=G(Q)):(_=Q,Q=ve,ge=Se,ve=_+a*($-_),Se=G(ve));return(_+$)/2}function X(G,T){const e=String(T.kind||T.model||"").toLowerCase()==="holt",s=G.map(Se=>Number.isFinite(Se.value)?Se.value:null);if(s.filter(Se=>Se!==null).length<(e?2:1))return null;const _=Se=>Math.min(v,Math.max(r,Se));let $=Number.isFinite(T.alpha)?_(Number(T.alpha)):null,Q=e&&Number.isFinite(T.beta)?_(Number(T.beta)):null;if(e){if($===null||Q===null){let Se=$===null?.5:$,Ne=Q===null?.5:Q;for(let Le=0;Le<6;Le++)$===null&&(Se=M(j=>I(s,j,Ne).sse,r,v)),Q===null&&(Ne=M(j=>I(s,Se,j).sse,r,v));$=$===null?Se:$,Q=Q===null?Ne:Q}}else $===null&&($=M(Se=>C(s,Se).sse,r,v));const ve=e?I(s,$,Q):C(s,$),ge=[];for(let Se=0;Se<G.length;Se++){const Ne=ve.smoothed[Se];Ne===null||!Number.isFinite(Ne)||ge.push({x:G[Se].rawX,y:Ne})}return ge.length<2?null:{fit:ge,stats:{method:"exponential",kind:e?"holt":"ses",alpha:$,beta:e?Q:null}}}function z(G,T,e){if(T.method==="linear"){const a=se(G,e);return re(a,T.forecast,{confidence:T.confidence})}const s=J(G);return T.method==="movingAverage"?b(s,T.window||T.period):X(s,T)}function ne(G,T,e,s,a,_){const $=T?` for ${T}`:"";if(G.method==="linear"){const Se=Number.isFinite(G.r2)?`, R² ${G.r2.toFixed(2)}`:"";let Ne=`Trend (linear)${$}: slope ${e(G.slope)}${Se}`;if(G.forecast>0&&s&&s.length){const Le=s[s.length-1];if(Ne+=`; forecast ${G.forecast} step${G.forecast===1?"":"s"} ahead to ${e(Le.y)}`,a&&a.points.length){const j=a.points[a.points.length-1],pe=_==="confidence"||_==="mean",he=pe?j.lowerMean:j.lower,oe=pe?j.upperMean:j.upper,fe=pe?"confidence":"prediction",we=Math.round(a.confidence*100);Ne+=`; ${we}% ${fe} band ${e(he)} to ${e(oe)} at the horizon`}}return Ne}if(G.method==="movingAverage")return`Trend (moving average, window ${G.window})${$}`;const Q=G.kind==="holt"?"Holt":"single",ve=Number.isFinite(G.alpha)?`, α ${G.alpha.toFixed(2)}`:"",ge=Number.isFinite(G.beta)?`, β ${G.beta.toFixed(2)}`:"";return`Trend (exponential, ${Q})${$}${ve}${ge}`}function R(G){const T=x(G.trend);if(!T.length)return[];const e=G.group.ownerDocument;let s=null;for(const $ of G.group.childNodes||[])if($&&String($.getAttribute&&$.getAttribute("class"))===`${y}__trends`){s=$;break}s||(s=e.createElementNS(q,"g"),s.setAttribute("class",`${y}__trends`),G.group.appendChild(s)),G.clip?s.setAttribute("clip-path",`url(#${G.clip})`):s.removeAttribute("clip-path");const a=new H(s),_=[];for(const $ of T)for(const Q of G.series){const ve=Q.axis==="right"&&G.rightScale?G.rightScale:G.yScale,ge=z(Q,$,G.xScale);if(!ge)continue;const Se=G.scheme.series(Q.index),Ne=[];for(const pe of ge.fit){const he=W(G.xScale,pe.x),oe=ve.of(pe.y);!Number.isFinite(he)||!Number.isFinite(oe)||Ne.push(Ne.length?"L":"M",V(he),V(oe))}if(Ne.length<4)continue;if(ie(a.next("path",`${y}__trend`),{d:te(Ne),fill:"none",stroke:Se,"data-series":Q.index}),$.band!==!1&&ge.band&&ge.band.points.length>=2){const pe=$.band==="confidence"||$.band==="mean",he=[];for(const fe of ge.band.points){const we=W(G.xScale,fe.x),i=pe?fe.lowerMean:fe.lower,Y=pe?fe.upperMean:fe.upper,o=ve.of(i),d=ve.of(Y);!Number.isFinite(we)||!Number.isFinite(o)||!Number.isFinite(d)||he.push({x:V(we),lower:V(o),upper:V(d)})}const oe=n(he);oe&&ie(a.next("path",`${y}__trend-band`),{d:oe,fill:Se,"fill-opacity":.15,stroke:"none","data-series":Q.index})}const j=ge.forecast||[];if(j.length>=2){const pe=[];for(const he of j){const oe=W(G.xScale,he.x),fe=ve.of(he.y);!Number.isFinite(oe)||!Number.isFinite(fe)||pe.push(pe.length?"L":"M",V(oe),V(fe))}pe.length>=4&&ie(a.next("path",`${y}__trend-forecast`),{d:te(pe),fill:"none",stroke:Se,"data-series":Q.index})}if($.label!==!1&&ge.stats.method==="linear"&&Number.isFinite(ge.stats.r2)){const pe=ge.fit[ge.fit.length-1],he=a.next("text",`${y}__trend-label`);f(he,G.size),ie(he,{x:V(W(G.xScale,pe.x)),y:V(ve.of(pe.y))-4,"text-anchor":"end",fill:Se}),E(he,G.grid.messages.t("chart.r2",{value:k(G.grid,ge.stats.r2)}))}_.push({text:ne(ge.stats,Q.label,G.format,j,$.band===!1?null:ge.band,$.band)})}return a.finish(),_.filter($=>$.text)}}),qe("packages/modules/charts/rulecolour.js",function(t,ce){"use strict";Object.defineProperty(t,"colourOf",{enumerable:!0,get:function(){return H}}),Object.defineProperty(t,"ruleColour",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(t,"ruleLegend",{enumerable:!0,get:function(){return ie}});const _e="*";function H(te){if(!te||typeof te!="object")return null;for(const n of["background","backgroundColor","color"]){const V=te[n];if(typeof V=="string"&&V.trim())return V.trim()}return null}function ue(te){const{grid:n,col:V,value:E}=te;if(!n||!V||!n.formatting||typeof n.formatting.styleFor!="function")return null;try{return H(n.formatting.styleFor(V,E))}catch{return null}}function ie(te){const{grid:n,col:V}=te,E=new Set([...te.colours||[]].filter(Boolean));if(!E.size||!n||!n.formatting||typeof n.formatting.list!="function")return[];let q;try{q=[...n.formatting.list(_e)||[],...V?n.formatting.list(V)||[]:[]]}catch{return[]}const B=[],f=new Set;for(const S of q){if(!S||S.enabled===!1)continue;const y=H(S.style);!y||!E.has(y)||f.has(y)||(f.add(y),B.push({key:S.id||`rule:${B.length}`,label:S.label||S.id||y,colour:y,index:B.length}))}return B}}),qe("packages/modules/charts/glyph.js",function(t,ce){"use strict";Object.defineProperty(t,"glyphFor",{enumerable:!0,get:function(){return te}}),Object.defineProperty(t,"glyphTransform",{enumerable:!0,get:function(){return n}});const H=ce("packages/core/src/internal/warn.js").warnOnce,ie=ce("packages/modules/charts/svg.js").round;function te(V,E,q="node"){if(!E)return null;const B=q==="marker",f=B?"a chart image marker":"a network node",S=V&&V.icons;if(!S||typeof S.get!="function")return H(`chart:icons:${E}`,`${f.charAt(0).toUpperCase()}${f.slice(1)} asked for the icon '${E}', but this grid publishes no icon registry — a headless grid has no sprites. The ${B?"point":"node"} drew as ${B?"its default marker":"a plain disc"}.`),null;const y=S.get(E);return y||(H(`chart:icon:${E}`,`Unknown icon '${E}' on ${f}; ${B?"kept the default marker":"drew a plain disc"} instead. Register it with registerIcon or config.icons, or name a built-in.`),null)}function n(V,E){const q=String(V.viewBox||"0 0 16 16").trim().split(/[\s,]+/).map(Number),[B,f,S,y]=q.length===4&&q.every(Number.isFinite)?q:[0,0,16,16],P=Math.max(S||16,y||16),N=E.size/P,p=E.x-S*N/2,u=E.y-y*N/2;return`translate(${ie(p-B*N)} ${ie(u-f*N)}) scale(${ie(N)})`}}),qe("packages/modules/charts/markers.js",function(t,ce){"use strict";Object.defineProperty(t,"MARKER_SIZE",{enumerable:!0,get:function(){return E}}),Object.defineProperty(t,"clearMarkerImages",{enumerable:!0,get:function(){return y}}),Object.defineProperty(t,"resolveMarker",{enumerable:!0,get:function(){return P}}),Object.defineProperty(t,"safeImageUrl",{enumerable:!0,get:function(){return N}}),Object.defineProperty(t,"imageOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(t,"imageState",{enumerable:!0,get:function(){return u}}),Object.defineProperty(t,"markerFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(t,"placeMarker",{enumerable:!0,get:function(){return c}}),Object.defineProperty(t,"markerBoxHit",{enumerable:!0,get:function(){return k}});const H=ce("packages/core/src/internal/warn.js").warnOnce,ue=ce("packages/modules/charts/glyph.js"),ie=ue.glyphFor,te=ue.glyphTransform,V=ce("packages/modules/charts/styles.js").NS,E=16,q=[6,64],B=/^data:image\/(png|jpe?g|gif|webp|avif|bmp|svg\+xml)[;,]/i,f=/^(https?:|blob:|data:|javascript:|vbscript:|file:|\/|\.\.?\/)|[/.]/i,S=new Map;function y(){S.clear()}function P(m){if(!m||typeof m!="object"||Array.isArray(m))return null;const r=m.image;if(r==null||r==="")return H("chart:marker:no-image",'chart "marker" needs an "image": an icon name, a URL, { col } or a function. No markers were drawn from it.'),null;const v=Number(m.size);return{image:r,size:Number.isFinite(v)?Math.min(q[1],Math.max(q[0],v)):E,explicitSize:Number.isFinite(v)}}function N(m){const r=String(m).trim(),v=/^([a-z][a-z0-9+.-]*):/i.exec(r);if(v){const l=v[1].toLowerCase();return l==="data"?B.test(r)?r:null:l==="http"||l==="https"||l==="blob"?r:null}return/^[^/]*:/.test(r)?null:r}function p(m,r,v){let l=m.image;if(typeof l=="function")try{l=l(r)}catch{l=null}else l&&typeof l=="object"&&typeof l.col=="string"&&(l=v&&v.rows&&r&&r.rowKey!==void 0&&r.rowKey!==null?v.rows.value(r.rowKey,l.col):null);return typeof l=="string"&&l.trim()?l.trim():null}function u(m,r,v){let l=S.get(m);if(l)return l.state==="loading"&&v&&l.waiting.add(v),l.state;const x=r&&r.defaultView,W=x&&x.Image;if(typeof W!="function")return"ok";l={state:"loading",waiting:new Set(v?[v]:[])},S.set(m,l);const J=new W,se=re=>{if(l.state=re,re==="failed"){const b=m.length>80?m.slice(0,77):m;H(`chart:marker:image-failed:${m}`,`a chart marker image could not be loaded (${b}); those points keep the default marker. Check the URL, and that the server allows the page to load it.`)}for(const b of l.waiting)try{b()}catch{}l.waiting.clear()};return J.onload=()=>se("ok"),J.onerror=()=>se("failed"),J.src=m,"loading"}function h(m,r,v){const l=p(m,r,v.grid);if(!l)return null;if(!f.test(l)){const W=ie(v.grid,l,"marker");return W?{kind:"icon",def:W}:null}const x=N(l);if(!x){const W=l.slice(0,40);return H(`chart:marker:unsafe-url:${W}`,`a chart marker image URL was refused (${W}): only http, https, blob, relative and data:image URLs are drawn. Those points keep the default marker.`),null}return u(x,v.doc,v.redraw)==="ok"?{kind:"image",href:x}:null}function c(m,r,v){const l=v.size/2;if(r.kind==="icon"){const W=r.def,J=W.paint==="stroke",se=m.next("path",`${V}__marker-icon ${V}__mark`);return v.attrs(se,{d:W.paths.join(" "),transform:te(W,{x:v.x,y:v.y,size:v.size}),fill:J?"none":v.colour,stroke:J?v.colour:null,"stroke-width":J?1.5:null,class:`${V}__marker-icon ${V}__mark`,...v.extra||{}}),se}const x=m.next("image",`${V}__marker-image ${V}__mark`);return v.attrs(x,{href:r.href,x:v.round(v.x-l),y:v.round(v.y-l),width:v.size,height:v.size,preserveAspectRatio:"xMidYMid meet",class:`${V}__marker-image ${V}__mark`,...v.extra||{}}),x}function k(m,r,v){return Math.abs(r-m.x)<=m.half&&Math.abs(v-m.y)<=m.half}}),qe("packages/modules/charts/cartesian.js",function(t,ce){"use strict";Object.defineProperty(t,"CARTESIAN",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(t,"WATERFALL_TOTAL",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(t,"withWaterfallTotal",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(t,"axisWindowSpan",{enumerable:!0,get:function(){return He}}),Object.defineProperty(t,"axisWindowNow",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(t,"rollingDomain",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(t,"WINDOW_LEAD",{enumerable:!0,get:function(){return ct}}),Object.defineProperty(t,"aheadOfWindow",{enumerable:!0,get:function(){return pt}}),Object.defineProperty(t,"staleWindow",{enumerable:!0,get:function(){return Lt}}),Object.defineProperty(t,"windowedBound",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(t,"slotPadFor",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(t,"pinnedContinuousX",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(t,"continuousX",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(t,"bandedX",{enumerable:!0,get:function(){return et}}),Object.defineProperty(t,"dataInterval",{enumerable:!0,get:function(){return Bt}}),Object.defineProperty(t,"continuousSlot",{enumerable:!0,get:function(){return Dt}}),Object.defineProperty(t,"xDomainFor",{enumerable:!0,get:function(){return Ut}}),Object.defineProperty(t,"xScaleFor",{enumerable:!0,get:function(){return Ht}}),Object.defineProperty(t,"drawFits",{enumerable:!0,get:function(){return mn}}),Object.defineProperty(t,"drawConfidenceBand",{enumerable:!0,get:function(){return rn}}),Object.defineProperty(t,"drawBoundErrorBars",{enumerable:!0,get:function(){return fn}}),Object.defineProperty(t,"drawForest",{enumerable:!0,get:function(){return gn}}),Object.defineProperty(t,"drawReferenceLines",{enumerable:!0,get:function(){return ln}}),Object.defineProperty(t,"drawCartesian",{enumerable:!0,get:function(){return yn}}),Object.defineProperty(t,"HIT_TOLERANCE",{enumerable:!0,get:function(){return en}}),Object.defineProperty(t,"nearestDrawnPoint",{enumerable:!0,get:function(){return tn}}),Object.defineProperty(t,"nearestCategory",{enumerable:!0,get:function(){return sn}}),Object.defineProperty(t,"categoryKeyAt",{enumerable:!0,get:function(){return un}});const _e=ce("packages/modules/charts/axis.js"),H=_e.drawAxisLines,ue=_e.drawAxisTitle,ie=_e.drawBandLabels,te=_e.drawCategoryAxis,n=_e.drawContinuousAxis,V=_e.drawMeasureAxis,E=_e.overhangFor,q=_e.pinXDomain,B=_e.setPlotClip,f=_e.turnedFirstLabelBox,S=ce("packages/modules/charts/frame.js"),y=S.Pool,P=S.shouldRotate,N=ce("packages/modules/charts/format.js"),p=N.formatters,u=N.r2Digits,h=ce("packages/modules/charts/scale.js"),c=h.bandScale,k=h.extent,m=h.isNumber,r=h.key,v=h.linearScale,l=h.measureDomain,x=h.timeScale,W=h.toNumber,J=h.toTime,se=ce("packages/modules/charts/stack.js"),re=se.measureValues,b=se.stacker,C=ce("packages/modules/charts/svg.js"),I=C.attrs,M=C.path,X=C.ribbonPath,z=C.round,ne=C.setText,R=C.SVG_NS,T=ce("packages/modules/charts/styles.js").NS,s=ce("packages/modules/charts/labels.js").drawDataLabels,_=ce("packages/modules/charts/dense.js").downsample,Q=ce("packages/modules/charts/scheme.js").resolveScheme,ge=ce("packages/modules/charts/typography.js").applySize,Ne=ce("packages/modules/charts/combo.js").drawRightAxis,Le=ce("packages/modules/charts/annotations.js"),j=Le.drawAnnotations,pe=Le.overlayLayer,oe=ce("packages/modules/charts/trendline.js").drawTrendlines,fe=ce("packages/modules/charts/rulecolour.js"),we=fe.ruleColour,i=fe.ruleLegend,Y=ce("packages/modules/charts/curve.js"),o=Y.curveCommands,d=Y.resolveCurve,F=ce("packages/core/src/internal/warn.js").warnOnce,U=ce("packages/modules/charts/fills.js"),ee=U.isPaintRef,L=U.paintSolid,Z=U.rowFillSource,xe=ce("packages/modules/charts/markers.js"),g=xe.markerFor,A=xe.placeMarker,K=xe.resolveMarker,ae=3.5,ye=Object.freeze({line:{zero:!1,marks:"path"},step:{zero:!1,marks:"path"},area:{zero:!0,marks:"path"},rangeArea:{zero:!1,marks:"path"},bar:{zero:!0,marks:"rect"},horizontalBar:{zero:!0,marks:"rect",horizontal:!0},waterfall:{zero:!0,marks:"rect"},scatter:{zero:!1,marks:"circle"},bubble:{zero:!1,marks:"circle"},candlestick:{zero:!1,marks:"rect"},ohlc:{zero:!1,marks:"rect"}});function ke(w){const Me=[];for(let de=0;de<w.length;de++){const $e=w[de];if(de===0){Me.push("M",$e.x,$e.y);continue}Me.push("L",$e.x,w[de-1].y),Me.push("L",$e.x,$e.y)}return Me}function Te(w){const Me=[0];if(!w)return Me;let de=0;for(const $e of w.points)m($e.y)&&$e.total!==!0&&(de+=$e.y,Me.push(de));return Me}const ze=Object.freeze({key:"lattice:waterfall-total"});function Ze(w,Me,de){if(!Me||typeof Me!="object"||!Me.total||!w||w.empty||!Array.isArray(w.series)||!w.series.length)return w;const $e=typeof Me.total=="string"&&Me.total.trim()!==""?Me.total:de,Pe=w.series.map(Oe=>{let Ae=0,Be=0,je=!1;for(const Ie of Oe.points)Be+=Number.isFinite(Ie.rows)?Ie.rows:0,m(Ie.y)&&(Ae+=Ie.y,je=!0);const De={x:ze,xKey:r(ze),label:$e,y:je?Ae:null,size:null,rows:Be,rowKey:null,values:null,total:!0};return{...Oe,points:[...Oe.points,De]}});return{...w,kind:"category",series:Pe,categories:[...w.categories||[],ze],labels:[...w.labels||[],$e]}}function He(w){const Me=w&&w.window;if(!Me||typeof Me!="object")return 0;const de=Number(Me.span);return!Number.isFinite(de)||de<=0?0:Me.kind!=="time"?(F("chart.axis.window.kind",`axis window kind "${Me.kind}" is not supported on a chart axis; only { kind: "time", span } rolls the domain. Bound the row count with the source's maxRows instead.`),0):de}function Ke(w,Me){const de=w&&w.window;if(!de||typeof de!="object"||typeof de.now!="function")return Me;const $e=Number(de.now());return Number.isFinite($e)?$e:(F("chart.axis.window.now","axis.x.window.now did not return a time, so the rolling window is measured from this device's clock instead. It must return epoch milliseconds — the same number Date.now() returns — because that is what the x values are compared against."),Me)}function Fe(w,Me,de){const $e=de+w*ct;let Pe=de;for(const Oe of Me)Number.isFinite(Oe)&&Oe>Pe&&Oe<=$e&&(Pe=Oe);return{min:Pe-w,max:Pe}}const ct=.25;function tt(w,Me,de){const $e=He(Me);if(!$e||!w||!Array.isArray(w.categories))return null;const Pe=ye[de];if(!Pe||Pe.horizontal||w.kind==="category"||de==="bar"&&!ht(w,de,Me))return null;const Oe=w.categories.map(Ae=>w.kind==="time"?J(Ae):W(Ae));return{span:$e,values:Oe}}function pt(w,Me,de,$e){const Pe=tt(w,Me,de);if(!Pe)return null;const Oe=Pe.span*ct;let Ae=0,Be=0;for(const je of Pe.values)je===null||!Number.isFinite(je)||je-$e<=Oe||(Ae+=1,je-$e>Be&&(Be=je-$e));return Ae?{span:Pe.span,limit:Oe,count:Ae,lead:Be}:null}function Lt(w,Me,de,$e){const Pe=tt(w,Me,de);if(!Pe)return null;const{span:Oe}=Pe,Ae=Pe.values.filter(Ie=>Ie!==null&&Number.isFinite(Ie));if(!Ae.length)return null;const{min:Be,max:je}=Fe(Oe,Ae,$e);let De=-1/0;for(const Ie of Ae){if(Ie>=Be&&Ie<=je)return null;Ie<Be&&Ie>De&&(De=Ie)}return De===-1/0?{span:Oe,newest:null,age:null,points:Ae.length}:{span:Oe,newest:De,age:$e-De,points:Ae.length}}function jt(w,Me,de,$e){const Pe=tt(w,Me,de);if(!Pe)return w;const{span:Oe,values:Ae}=Pe,Be=Ae.filter(Ge=>Ge!==null&&Number.isFinite(Ge));if(!Be.length)return w;const{min:je,max:De}=Fe(Oe,Be,$e),Ie=[];for(let Ge=0;Ge<Ae.length;Ge++){const nt=Ae[Ge];(nt===null||!Number.isFinite(nt)||nt>=je&&nt<=De)&&Ie.push(Ge)}return Ie.length===Ae.length?w:{...w,categories:Ie.map(Ge=>w.categories[Ge]),labels:Array.isArray(w.labels)?Ie.map(Ge=>w.labels[Ge]):w.labels,series:(w.series||[]).map(Ge=>({...Ge,points:Array.isArray(Ge.points)?Ie.map(nt=>Ge.points[nt]).filter(nt=>nt!==void 0):Ge.points})),windowed:Ae.length-Ie.length}}const wt=Object.freeze({bar:.2,candlestick:.3,ohlc:.3}),gt=.4;function mt(w){return Object.hasOwn(wt,w)?wt[w]:gt}const Mt=new Set(["bar","candlestick","ohlc"]);function ft(w){const Me=w&&typeof w.scale=="string"?w.scale:"";return Me==="time"||Me==="linear"}function ht(w,Me,de){if(!w||w.kind==="category")return!1;const $e=ye[Me];return $e&&$e.horizontal?!1:Mt.has(Me)?ft(de):!0}function et(w,Me,de){return!ht(w,Me,de)}function Bt(w){const Me=w.filter(Pe=>typeof Pe=="number"&&Number.isFinite(Pe)).slice().sort((Pe,Oe)=>Pe-Oe),de=[];for(let Pe=1;Pe<Me.length;Pe++){const Oe=Me[Pe]-Me[Pe-1];Oe>0&&de.push(Oe)}if(!de.length)return 0;de.sort((Pe,Oe)=>Pe-Oe);const $e=Math.floor(de.length/2);return de.length%2?de[$e]:(de[$e-1]+de[$e])/2}function Dt(w){const{bound:Me,scale:de,config:$e,padding:Pe}=w,Oe=$e?Number($e.barWidth):NaN,Ae=Number.isFinite(Oe)&&Oe>0,Be=(Me.categories||[]).map(Ge=>Me.kind==="time"?J(Ge):W(Ge)),je=Ae?Oe:Bt(Be),De=Math.abs(de.range[1]-de.range[0]);if(!je)return Math.max(1,De/20*(1-Pe));const Ie=Math.abs(de.of(de.domain.min+je)-de.of(de.domain.min));return Math.max(1,Ae?Ie:Ie*(1-Pe))}function Ut(w,Me,de,$e){if(et(w,Me,de))return null;const Pe=He(de),Oe=w.kind==="time"?w.categories.map(J):w.categories.map(W);if(w.kind==="time"&&!Pe){const Be=k(Oe);if(Be&&Be.min===Be.max)return q({min:Be.min-3e4,max:Be.max+3e4},w,de)}const Ae=Pe?Fe(Pe,Oe,Number.isFinite($e)?$e:Ke(de,Date.now())):l(Oe,{zero:!1,nice:w.kind!=="time"});return q(Ae,w,de)}function Ht(w,Me,de,$e){const Pe=[Me.left,Me.right];if(et(w,de,$e))return He($e)&&F("chart.axis.window.band","a rolling time window needs a continuous x axis; this chart bands its x values, so the window is ignored. Bind a date or numeric column to x, or put this type on a continuous axis with axis.x.scale."),c(w.categories,Pe,mt(de));const Oe=w.xDomain||Ut(w,de,$e);return w.kind==="time"?x(Oe,Pe):v(Oe,Pe)}function Ft(w,Me){if(w.kind==="band")return w.centre(Me.x);const de=w.kind==="time"?J(Me.x):W(Me.x);return de===null?NaN:w.of(de)}function xt(w,Me){const de=w&&w.seriesStyle&&w.seriesStyle[Me];if(de)return{width:de.width!=null?String(de.width):null,dash:Array.isArray(de.dash)&&de.dash.length?de.dash.join(" "):null,opacity:null,emphasized:!1};const $e=w&&Array.isArray(w.emphasis)?w.emphasis:null;if(!$e||!$e.length)return{width:null,dash:null,opacity:null,emphasized:!1};const Pe=$e.includes(Me);return{width:Pe?"var(--lattice-chart-emphasis-width, 3.5)":null,dash:null,opacity:Pe?null:"var(--lattice-chart-muted-opacity, .35)",emphasized:Pe}}function Wt(w){const{series:Me,xScale:de,yScale:$e,baseline:Pe,fill:Oe,colour:Ae,stack:Be,style:je}=w,De=[],Ie=[];let Ge=[];const nt=()=>{Ge.length===1?De.push("M",Ge[0].x,Ge[0].y):Ge.length>1&&De.push(...o(Ge,w.curve||null)),Ge=[]};for(let bt=0;bt<Me.points.length;bt++){const kt=Me.points[bt],Ot=z(Ft(de,kt));if(!m(kt.y)||Number.isNaN(Ot)){nt();continue}Ie[bt]=!0;const zt=kt.y,At=w.lower?w.lower.points[bt]:null;if(w.lower&&!(At&&m(At.y))){nt();continue}const me=Be?Be.take(bt,zt):null,Ce=z($e.of(me?me[1]:zt)),Ve=z($e.of(me?me[0]:At?At.y:Pe));Ge.push({x:Ot,y:Ce,base:Ve}),kt.px=Ot,kt.py=Ce,kt.pbase=Ve}nt(),I(w.pool.next("path",`${T}__line ${T}__mark`),{d:De.length?M(De):"",stroke:Ae,"data-series":w.index,"stroke-width":je?je.width:null,"stroke-dasharray":je?je.dash:null,opacity:je?je.opacity:null});const Ye=!!w.marker&&!!w.markerEnv;if(Ye&&!Oe&&Gt(w,Ie),!Oe){Ye||It({...w,placed:Ie});return}const st=[];let at=[];const lt=()=>{if(at.length<2){at=[];return}const bt=o(at,w.curve||null);bt[0]="L",st.push("M",at[0].x,at[0].base),st.push(...bt);for(let kt=at.length-1;kt>=0;kt--)st.push("L",at[kt].x,at[kt].base);st.push("Z"),at=[]};for(const bt of Me.points){if(!m(bt.y)||bt.px===void 0){lt();continue}at.push({x:bt.px,y:bt.py,base:bt.pbase})}lt(),I(w.pool.next("path",`${T}__area ${T}__mark`),{d:st.length?M(st):"",fill:Ae,"data-series":w.index,opacity:ee(Ae)?"1":je?je.emphasized?"1":je.opacity:null}),Ye?Gt(w,Ie):It({...w,placed:Ie})}function Gt(w,Me){const{series:de}=w;for(let $e=0;$e<de.points.length;$e++){if(!Me[$e])continue;const Pe=de.points[$e];cn(w,Pe,$e,Pe.px,Pe.py,ae*2,w.colour)||I(w.pool.next("circle",`${T}__point ${T}__mark`),{cx:Pe.px,cy:Pe.py,r:ae,fill:w.colour,"data-series":w.index,"data-point":$e})}}function It(w){const{series:Me,placed:de}=w;for(let $e=0;$e<Me.points.length;$e++){if(!de[$e]||de[$e-1]||de[$e+1])continue;const Pe=Me.points[$e];I(w.pool.next("circle",`${T}__point ${T}__mark`),{cx:Pe.px,cy:Pe.py,r:ae,fill:w.colour,"data-series":w.index,"data-point":$e})}}function _t(w,Me){const de=w&&w.range;if(!Array.isArray(de)||de.length!==2)return Me;const[$e,Pe]=de;return!Number.isFinite($e)||!Number.isFinite(Pe)||!Number.isFinite(Me)?Me:Math.min(Math.max($e,Pe),Math.max(Math.min($e,Pe),Me))}function Xt(w){const{series:Me,xScale:de,yScale:$e,baseline:Pe,colour:Oe,stack:Ae,slot:Be}=w;for(let je=0;je<Me.points.length;je++){const De=Me.points[je];if(!m(De.y))continue;const Ie=de.kind==="band"?de.of(De.x):Ft(de,De)-Be.span/2;if(Number.isNaN(Ie))continue;const Ge=De.y,nt=w.pointColour&&w.pointColour(De,Oe)||Oe,Ye=Ae?Ae.take(je,Ge):[Pe,Ge],st=_t($e,$e.of(Ye[1])),at=_t($e,$e.of(Ye[0])),lt=Ie+Be.offset,bt=de.kind==="band"?lt:_t(de,lt),kt=de.kind==="band"?lt+Be.width:_t(de,lt+Be.width),Ot=w.pool.next("rect",`${T}__bar ${T}__mark`,`${Me.key}:${r(De.x)}`);I(Ot,{x:z(bt),y:z(Math.min(st,at)),width:z(Math.max(0,kt-bt)),height:z(Math.max(1,Math.abs(at-st))),fill:nt,"data-series":w.index,"data-point":je}),De.px=z(Ie+Be.offset+Be.width/2),De.py=z(Math.min(st,at)),De.pbase=z(Math.max(st,at))}}function Yt(w){const{series:Me,xScale:de,yScale:$e}=w;let Pe=0;for(let Oe=0;Oe<Me.points.length;Oe++){const Ae=Me.points[Oe];if(!m(Ae.y))continue;const Be=Ae.y,je=Ae.total===!0,De=je?0:Pe,Ie=je?Be:Pe+Be;je||(Pe+=Be);const Ge=_t($e,$e.of(Math.max(De,Ie))),nt=_t($e,$e.of(Math.min(De,Ie))),Ye=w.pool.next("rect",`${T}__bar ${T}__mark`,`${Me.key}:${r(Ae.x)}`);I(Ye,{x:z(de.of(Ae.x)),y:z(Ge),width:z(de.bandwidth),height:z(Math.max(1,nt-Ge)),fill:Be>=0?w.positive:w.negative,"data-series":w.index,"data-point":Oe,"data-total":je?"true":null}),Ae.px=z(de.of(Ae.x)+de.bandwidth/2),Ae.py=z(Ge)}}function qt(w){const{series:Me,valueScale:de,baseline:$e,colour:Pe,stack:Oe,slot:Ae}=w;for(let Be=0;Be<Me.points.length;Be++){const je=Me.points[Be];if(!m(je.y))continue;const De=w.bandScale.of(je.x);if(Number.isNaN(De))continue;const Ie=je.y,Ge=w.pointColour&&w.pointColour(je,Pe)||Pe,nt=Oe?Oe.take(Be,Ie):[$e,Ie],Ye=_t(de,de.of(nt[0])),st=_t(de,de.of(nt[1]));I(w.pool.next("rect",`${T}__bar ${T}__mark`,`${Me.key}:${r(je.x)}`),{x:z(Math.min(Ye,st)),y:z(De+Ae.offset),width:z(Math.max(1,Math.abs(st-Ye))),height:z(Math.max(0,Ae.width)),fill:Ge,"data-series":w.index,"data-point":Be}),je.px=z(st),je.py=z(De+Ae.offset+Ae.width/2),je.pbase=z(Ye)}}function Jt(w){const{series:Me,xScale:de,yScale:$e,baseline:Pe,colour:Oe,stack:Ae,slot:Be}=w;for(let je=0;je<Me.points.length;je++){const De=Me.points[je];if(!m(De.y))continue;const Ie=de.kind==="band"?de.of(De.x):Ft(de,De)-Be.span/2;if(Number.isNaN(Ie))continue;const Ge=De.y,nt=w.pointColour&&w.pointColour(De,Oe)||Oe,Ye=Ae?Ae.take(je,Ge):[Pe,Ge],st=_t($e,$e.of(Ye[1])),at=_t($e,$e.of(Ye[0])),lt=z(Ie+Be.offset+Be.width/2);I(w.pool.next("line",`${T}__lollipop-stem ${T}__mark`,`${Me.key}:${r(De.x)}`),{x1:lt,y1:z(at),x2:lt,y2:z(st),stroke:nt,"stroke-width":2,"data-series":w.index,"data-point":je}),I(w.pool.next("circle",`${T}__lollipop-dot ${T}__mark`,`${Me.key}:${r(De.x)}`),{cx:lt,cy:z(st),r:4,fill:nt,"data-series":w.index,"data-point":je}),De.px=lt,De.py=z(st),De.pbase=z(at)}}function nn(w){const{series:Me,valueScale:de,baseline:$e,colour:Pe,stack:Oe,slot:Ae}=w;for(let Be=0;Be<Me.points.length;Be++){const je=Me.points[Be];if(!m(je.y))continue;const De=w.bandScale.of(je.x);if(Number.isNaN(De))continue;const Ie=je.y,Ge=w.pointColour&&w.pointColour(je,Pe)||Pe,nt=Oe?Oe.take(Be,Ie):[$e,Ie],Ye=_t(de,de.of(nt[0])),st=_t(de,de.of(nt[1])),at=z(De+Ae.offset+Ae.width/2);I(w.pool.next("line",`${T}__lollipop-stem ${T}__mark`,`${Me.key}:${r(je.x)}`),{x1:z(Ye),y1:at,x2:z(st),y2:at,stroke:Ge,"stroke-width":2,"data-series":w.index,"data-point":Be}),I(w.pool.next("circle",`${T}__lollipop-dot ${T}__mark`,`${Me.key}:${r(je.x)}`),{cx:z(st),cy:at,r:4,fill:Ge,"data-series":w.index,"data-point":Be}),je.px=z(st),je.py=at,je.pbase=z(Ye)}}function mn(w){const Me=w.group.ownerDocument;let de=null;for(const Oe of w.group.childNodes||[])if(Oe&&String(Oe.getAttribute&&Oe.getAttribute("class"))===`${T}__fits`){de=Oe;break}de||(de=Me.createElementNS(R,"g"),de.setAttribute("class",`${T}__fits`),w.group.appendChild(de));const $e=new y(de),Pe=[];for(const Oe of w.series){const Ae=Oe.allPoints||Oe.points;let Be=0,je=0,De=0;for(const At of Ae){const me=Number(At.x),Ce=Number(At.y);!Number.isFinite(me)||!Number.isFinite(Ce)||(Be++,je+=me,De+=Ce)}if(Be<2)continue;const Ie=je/Be,Ge=De/Be;let nt=0,Ye=0,st=0,at=1/0,lt=-1/0;for(const At of Ae){const me=Number(At.x),Ce=Number(At.y);if(!Number.isFinite(me)||!Number.isFinite(Ce))continue;const Ve=me-Ie,Ue=Ce-Ge;nt+=Ve*Ve,Ye+=Ve*Ue,st+=Ue*Ue,me<at&&(at=me),me>lt&&(lt=me)}if(nt===0)continue;const bt=Ye/nt,kt=Ge-bt*Ie,Ot=st===0?1:Math.max(0,Math.min(1,Ye*Ye/(nt*st))),zt=w.scheme.series(Oe.index);if(I($e.next("path",`${T}__fit`),{d:M(["M",z(w.xScale.of(at)),z(w.yScale.of(kt+bt*at)),"L",z(w.xScale.of(lt)),z(w.yScale.of(kt+bt*lt))]),fill:"none",stroke:zt,"data-series":Oe.index}),w.showR2){const At=$e.next("text",`${T}__fit-label`);ge(At,w.size),I(At,{x:z(w.xScale.of(lt)),y:z(w.yScale.of(kt+bt*lt))-4,"text-anchor":"end",fill:zt}),ne(At,w.grid.messages.t("chart.r2",{value:u(w.grid,Ot)}))}Pe.push({key:Oe.key,slope:bt,intercept:kt,r2:Ot,n:Be})}return $e.finish(),Pe}function rn(w){const Me=w.group.ownerDocument;let de=null;for(const De of w.group.childNodes||[])if(De&&String(De.getAttribute&&De.getAttribute("class"))===`${T}__band`){de=De;break}de||(de=Me.createElementNS(R,"g"),de.setAttribute("class",`${T}__band`),w.group.firstChild?w.group.insertBefore(de,w.group.firstChild):w.group.appendChild(de));const $e=new y(de),Pe=w.band&&Array.isArray(w.band.points)?w.band.points:[],Oe=Number.isFinite(w.index)?Number(w.index):0,Ae=w.scheme.series(Oe),Be=Number.isFinite(w.opacity)?Number(w.opacity):.15,je=[];for(const De of Pe){const Ie=Number(De.x),Ge=Number(De.lower),nt=Number(De.upper);if(!Number.isFinite(Ie)||!Number.isFinite(Ge)||!Number.isFinite(nt))continue;const Ye=Number(De.yhat);je.push({x:z(w.xScale.of(Ie)),lower:z(w.yScale.of(Ge)),upper:z(w.yScale.of(nt)),yhat:Number.isFinite(Ye)?z(w.yScale.of(Ye)):null})}if(je.length>=2&&(I($e.next("path",`${T}__band-fill`),{d:X(je),fill:Ae,"fill-opacity":Be,stroke:"none","data-series":Oe}),w.line!==!1)){const De=[];let Ie=!1;for(const Ge of je){if(Ge.yhat===null){Ie=!1;continue}De.push(Ie?"L":"M",Ge.x,Ge.yhat),Ie=!0}I($e.next("path",`${T}__band-line`),{d:De.length?M(De):"",fill:"none",stroke:Ae,"data-series":Oe})}return $e.finish(),{points:je.length,confidence:w.band&&Number.isFinite(w.band.confidence)?Number(w.band.confidence):null}}function fn(w){const Me=w.group.ownerDocument;let de=null;for(const je of w.group.childNodes||[])if(je&&String(je.getAttribute&&je.getAttribute("class"))===`${T}__whiskers`){de=je;break}de||(de=Me.createElementNS(R,"g"),de.setAttribute("class",`${T}__whiskers`),w.group.appendChild(de));const $e=new y(de),Pe=Number.isFinite(w.cap)?Number(w.cap):4,Oe=w.colour||"currentColor",Ae=w.orient!=="v";let Be=0;for(const je of w.points||[]){const De=Number(je.main),Ie=Number(je.lo),Ge=Number(je.hi);if(!Number.isFinite(De)||!Number.isFinite(Ie)||!Number.isFinite(Ge))continue;const nt=Ae?["M",Ie,De,"L",Ge,De,"M",Ie,De-Pe,"L",Ie,De+Pe,"M",Ge,De-Pe,"L",Ge,De+Pe]:["M",De,Ie,"L",De,Ge,"M",De-Pe,Ie,"L",De+Pe,Ie,"M",De-Pe,Ge,"L",De+Pe,Ge];I($e.next("path",`${T}__whisker`),{d:M(nt),stroke:Oe,fill:"none"}),Be++}return $e.finish(),Be}function gn(w){const Me=w.scheme||Q(),de=w.typography||{small:w.fontSize||11,axisTitle:11},{bound:$e}=w,Pe=hn(w.plot,de.small),Oe=$e.series[0]&&$e.series[0].points||[],Ae=Oe.map(Ye=>Ye.label),Be=Me.series(0),je=c(Ae,[Pe.top,Pe.bottom],.4),De=[0];for(const Ye of Oe)for(const st of[Ye.x,Ye.lower,Ye.upper])Number.isFinite(st)&&De.push(st);const Ie=v(l(De,{zero:!1}),[Pe.left,Pe.right]);fn({group:w.groups.overlay,orient:"h",colour:Be,points:Oe.map(Ye=>({main:z(je.centre(Ye.label)),lo:z(Ie.of(Ye.lower)),hi:z(Ie.of(Ye.upper))}))});const Ge=new y(w.groups.marks);let nt=0;for(const Ye of Oe)Number.isFinite(Ye.x)&&(I(Ge.next("circle",`${T}__point ${T}__mark`),{cx:z(Ie.of(Ye.x)),cy:z(je.centre(Ye.label)),r:ae,fill:Be}),nt++);return Ge.finish(),ln({group:w.groups.rules,plot:Pe,scale:Ie,lines:[{value:0}]}),n({group:w.groups.axis,plot:Pe,scale:Ie,format:p(w.grid,{kind:"linear",step:(Ie.domain.max-Ie.domain.min)/5}),config:{},grid:w.grid,size:de.small}),ie({group:w.groups.labels,plot:Pe,scale:je,labels:Ae,fontSize:de.small,config:{}}),{series:[],marks:nt}}function hn(w,Me){const de=6+Me*1.3+2,$e=w&&w.gutter&&Number.isFinite(w.gutter.bottom)?w.gutter.bottom:de,Pe=Math.min(Math.max(0,de-$e),Math.max(0,w.height-10));return Pe>0?{...w,height:w.height-Pe,bottom:w.bottom-Pe,gutter:{...w.gutter,bottom:$e+Pe}}:w}function ln(w){const Me=new y(pe(w.group,`${T}__reflines`));for(const de of w.lines||[]){if(!m(de.value))continue;const $e=z(w.scale.of(de.value));if(I(Me.next("path",`${T}__reference`),{d:w.vertical?M(["M",$e,z(w.plot.top),"L",$e,z(w.plot.bottom)]):M(["M",z(w.plot.left),$e,"L",z(w.plot.right),$e]),stroke:de.colour||"currentColor","stroke-dasharray":"4 3",fill:"none"}),!de.label)continue;const Pe=Me.next("text",`${T}__reference-label`);I(Pe,w.vertical?{x:$e+4,y:z(w.plot.top+10),"text-anchor":"start"}:{x:z(w.plot.right-4),y:$e-4,"text-anchor":"end"}),ne(Pe,de.label)}Me.finish()}function Qt(w){const{series:Me,xScale:de,yScale:$e,colour:Pe,plot:Oe}=w,Ae=w.size||null;for(let Be=0;Be<Me.points.length;Be++){const je=Me.points[Be];if(!m(je.y))continue;const De=z(Ft(de,je));if(Number.isNaN(De))continue;const Ie=z($e.of(je.y));let Ge=Ae&&m(je.size)?z(Ae.of(je.size)):ae;if(Oe){const Ye=Math.min(De-Oe.left,Oe.right-De,Ie-Oe.top,Oe.bottom-Ie);Number.isFinite(Ye)&&(Ge=Math.max(1,Math.min(Ge,Ye)))}const nt=w.pointColour&&w.pointColour(je,Pe)||Pe;cn(w,je,Be,De,Ie,Ge*2,nt)||I(w.pool.next("circle",`${T}__point ${T}__mark`),{cx:De,cy:Ie,r:Ge,fill:nt,"fill-opacity":Ae?.7:1,"data-series":w.index,"data-point":Be}),je.px=De,je.py=Ie}}function cn(w,Me,de,$e,Pe,Oe,Ae){if(!w.marker||!w.markerEnv)return!1;const Be=g(w.marker,Me,w.markerEnv);if(Me.markerHalf=0,!Be)return!1;const je=w.marker.explicitSize?w.marker.size:Math.max(w.marker.size,Oe);return A(w.pool,Be,{x:$e,y:Pe,size:je,colour:L(Ae),attrs:I,round:z,extra:{"data-series":w.index,"data-point":de}}),Me.markerHalf=je/2,!0}function on(w){const{group:Me,series:de,xScale:$e,yScale:Pe,options:Oe}=w,Ae=w.grid&&w.grid.statistics,Be=Ae&&typeof Ae.intervalOf=="function"?(at,lt)=>Ae.intervalOf(at,lt):null,je=new y(pe(Me,`${T}__errorbars`)),De=Number.isFinite(Number(Oe.confidence))?Number(Oe.confidence):.95,Ie=4;let Ge=0,nt=0,Ye=0,st=0;for(const at of de)for(const lt of at.points){if(lt.y===null||lt.y===void 0)continue;nt++;const bt=Array.isArray(lt.values)&&lt.values.length===1;bt&&Ye++;let kt=null,Ot=null;if(Oe.of!==void 0&&Number.isFinite(Number(lt[Oe.of]))){const Ce=Math.abs(Number(lt[Oe.of]));kt=lt.y-Ce,Ot=lt.y+Ce}else if(Array.isArray(lt.values)&&lt.values.length>1&&Be){const Ce=Be(lt.values,De);Ce&&(kt=Ce.lower,Ot=Ce.upper)}if(kt===null||!Number.isFinite(kt)||!Number.isFinite(Ot)){bt&&st++;continue}const zt=z($e.of(lt.xKey!==void 0?lt.xKey:lt.x)+($e.bandwidth?$e.bandwidth/2:0)),At=z(Pe.of(Ot)),me=z(Pe.of(kt));I(je.next("path",`${T}__error-bar ${T}__mark`),{d:M(["M",zt-Ie,At,"L",zt+Ie,At,"M",zt,At,"L",zt,me,"M",zt-Ie,me,"L",zt+Ie,me]),fill:"none",stroke:"currentColor","data-lower":kt,"data-upper":Ot}),Ge++}return je.finish(),{drawn:Ge,marks:nt,single:Ye,singleSkipped:st}}function Kt(w,Me){if(Me&&Me.size){const Oe=new Set;for(let Ae=0;Ae<w.length;Ae++)w[Ae].rowKey!=null&&Me.has(String(w[Ae].rowKey))&&Oe.add(Ae);return Oe}const de=5,$e=Oe=>[...w.keys()].filter(Ae=>Number.isFinite(Oe(w[Ae]))).sort((Ae,Be)=>Oe(w[Be])-Oe(w[Ae])).slice(0,de),Pe=new Set($e(Oe=>Math.abs(Number(Oe.y))));for(const Oe of $e(Ae=>Number(Ae.x)))Pe.add(Oe);if(w.some(Oe=>m(Oe.size)))for(const Oe of $e(Ae=>m(Ae.size)?Number(Ae.size):-1/0))Pe.add(Oe);return Pe}function yn(w){const Me=w.scheme||Q(),de=w.axis||{x:{},y:{},y2:{}},$e=w.typography||{small:w.fontSize||11,axisTitle:11},{bound:Pe,plot:Oe,type:Ae}=w,Be=ye[Ae]||ye.line,je=Pe.series.filter(Qe=>!w.hidden.has(Qe.key)),De=!!Be.horizontal,Ie=w.mark==="lollipop"&&(Ae==="bar"||Ae==="horizontalBar"),Ge=!De&&de.y.position==="right"?"right":"left",nt=Ge==="right"?"left":"right",Ye=(Ae==="bar"||Ae==="horizontalBar")&&w.byRuleColour&&je.length===1&&Pe.measure&&Pe.measure.col||null,st=Ye?new Set:null,at=Ye?Qe=>{const dt=we({grid:w.grid,col:Ye,value:Qe.y});return dt&&st.add(dt),dt}:null,bt=(Ae==="bar"||Ae==="horizontalBar")&&w.byRuleColour&&je.length===1&&Me.nameMap?Qe=>Me.series(0,Qe.label):null,kt=w.fill?Z(w,Me):null,Ot=kt||at||bt?(Qe,dt)=>kt&&kt(Qe,dt)||at&&at(Qe)||bt&&bt(Qe)||null:null,zt=K(w.marker),At=zt?{grid:w.grid,doc:w.doc,redraw:w.redraw}:null,me=!De&&Ae!=="waterfall"?je.filter(Qe=>Qe.axis==="right"):[],Ce=me.length?je.filter(Qe=>Qe.axis!=="right"):je,Ve=me.length>0,Ue=(Ae==="bar"||Ae==="area"||Ae==="horizontalBar")&&!Ve,Je=w.stack==="percent"&&Ue&&Ce.length>1,vt=(Je||!!w.stack)&&Ce.length>1&&Ue,$t=Ae==="waterfall"?Te(je[0]):re(Ce,vt,Je),Pt=Pe.yDomain||w.domain||l($t,{zero:Be.zero,min:de.y.min,max:de.y.max}),it=De?v(Pt,[Oe.left,Oe.right]):v(Pt,[Oe.bottom,Oe.top]),ot=De?c(Pe.categories,[Oe.top,Oe.bottom],.2):Ht(Pe,Oe,Ae,de.x),Nt=Pt.min<=0&&Pt.max>=0?0:Pt.min,Tt=me.some(Qe=>(Qe.mark||(Ae==="bar"?"bar":Ae))==="bar"),D=Ve?l(re(me,!1,!1),{zero:Tt,min:de.y2.min,max:de.y2.max}):null,le=D?v(D,[Oe.bottom,Oe.top]):null,be=p(w.grid,{kind:"linear",step:(Pt.max-Pt.min)/5}),Re=Je?{tick:Qe=>`${be.tick(Qe)}%`,value:Qe=>`${be.value(Qe)}%`}:be,Ee=w.axes!==!1,We={left:0,right:0,bottom:0};if(Ae==="scatter"||Ae==="bubble")for(const Qe of je)for(const dt of Qe.points){if(!m(dt.y))continue;const Et=Ft(ot,dt),Rt=it.of(dt.y);if(!Number.isFinite(Et)||!Number.isFinite(Rt))continue;const Ct=(w.sizes&&m(dt.size)?w.sizes.of(dt.size):ae)+2;We.left=Math.max(We.left,Ct-(Et-Oe.left)),We.right=Math.max(We.right,Ct-(Oe.right-Et)),We.bottom=Math.max(We.bottom,Ct-(Oe.bottom-Rt))}const ut=!De&&ot.kind==="band"&&(de.x.rotate===void 0||de.x.rotate==="auto"?P(Pe.labels,ot.step,$e.small,de.x.every):!!de.x.rotate)&&f({group:w.groups.overlay,plot:Oe,scale:ot,labels:Pe.labels,fontSize:$e.small,config:de.x});if(Ee&&V({gridGroup:w.groups.grid,axisGroup:w.groups.axis,plot:Oe,scale:it,format:Re,horizontal:De,side:Ge,config:de.y,grid:w.grid,size:$e.small,overhang:Ge==="right"?We.right:We.left,dropBottom:ut}),Ee)if(De)ie({group:w.groups.overlay,plot:Oe,scale:ot,labels:Pe.labels,fontSize:$e.small,config:de.x});else if(ot.kind==="band")te({group:w.groups.overlay,plot:Oe,scale:ot,labels:Pe.labels,fontSize:$e.small,rotated:P(Pe.labels,ot.step,$e.small,de.x.every),config:de.x});else{const Qe=Pe.dimension&&Pe.dimension.col?w.grid.columns.get(Pe.dimension.col):void 0;n({group:w.groups.overlay,plot:Oe,scale:ot,format:p(w.grid,{kind:Pe.kind,span:ot.domain.max-ot.domain.min,step:(ot.domain.max-ot.domain.min)/5},Qe),config:de.x,grid:w.grid,column:Qe,size:$e.small,overhang:We.bottom})}if(Ee&&(H({group:w.groups.rules,plot:Oe,side:Ge}),ue({group:w.groups.axis,plot:Oe,text:de.y.title,side:De?"bottom":Ge,size:$e.axisTitle}),ue({group:w.groups.axis,plot:Oe,text:de.x.title,side:De?"left":"bottom",size:$e.axisTitle})),Ee&&le){Ne({group:w.groups.axis,plot:Oe,scale:le,colour:Me.series(me[0].index),side:nt,format:p(w.grid,{kind:"linear",step:(D.max-D.min)/5})});const Qe=de.y2.title||(me.length===1?me[0].label:"");ue({group:w.groups.axis,plot:Oe,text:Qe,side:nt,size:$e.axisTitle}),!de.y.title&&Ce.length===1&&Ce[0].label&&ue({group:w.groups.axis,plot:Oe,text:Ce[0].label,side:Ge,size:$e.axisTitle})}const yt=Number.isFinite(w.downsampleTo)?Number(w.downsampleTo):Math.max(2,Math.round(Oe.width));let Xe=!1;if(Be.marks==="path"||Ae==="scatter"||Ae==="bubble"){for(const Qe of je)if(Qe.kept=null,Qe.allPoints=Qe.points,Qe.points.length>yt*1.5){const dt=Qe.points.map((Rt,Ct)=>({x:Ct,y:Rt.y,point:Rt})),Et=_(dt,yt);if(w.keepInfluential){const Rt=new Set(Et.map(Ct=>Ct.x));for(const Ct of Kt(Qe.points,w.keepRows))Rt.has(Ct)||(Et.push({x:Ct,y:Qe.points[Ct].y,point:Qe.points[Ct]}),Rt.add(Ct));Et.sort((Ct,$n)=>Ct.x-$n.x)}Qe.points=Et.map(Rt=>Rt.point),Qe.kept=Et.map(Rt=>Rt.x),Xe=!0}}w.pool||B(w.groups,Oe,E(Ae));const St=w.pool||new y(w.groups.marks),dn=Je?Pe.categories.map((Qe,dt)=>je.reduce((Et,Rt)=>{const Ct=Rt.points[dt]?Rt.points[dt].y:null;return m(Ct)?Et+Math.abs(Ct):Et},0)):null,Vt=vt?b(Pe.categories.length,dn):null,Zt=Ve?je.filter(Qe=>(Qe.mark||(Ae==="bar"?"bar":Ae))==="bar"):je,an=Ve?Math.max(1,Zt.length):Math.max(1,je.length),wn=Ae==="bar"||Ve&&Zt.length>0,pn=ot.kind==="band"?ot.bandwidth:wn?Dt({bound:Pe,scale:ot,config:de.x,padding:mt("bar")}):0,kn=vt?pn:pn/an,vn=new Map;for(const Qe of Zt)vn.set(Qe.key,vn.size);const An=[],xn=Ae==="rangeArea"&&Pe.series.length>=2?Pe.series[0]:null,_n=xn?Pe.series[1]:null;for(let Qe=0;Qe<je.length;Qe++){const dt=je[Qe],Et=Me.series(dt.index,dt.label),Rt=dt.axis==="right"&&le?le:it,Ct=Ve?dt.mark||(Ae==="bar"?"bar":Ae):Ae,$n=Ve&&vn.has(dt.key)?vn.get(dt.key):Qe;if(Ae==="horizontalBar")(Ie?nn:qt)({pool:St,series:dt,bandScale:ot,valueScale:it,baseline:Nt,colour:Et,stack:Vt,index:dt.index,slot:{offset:vt?0:Qe*kn,width:kn,span:pn},pointColour:Ot});else if(Ae==="waterfall")Yt({pool:St,series:dt,xScale:ot,yScale:it,index:dt.index,positive:Me.positive,negative:Me.negative});else if(Ct==="bar")(Ie?Jt:Xt)({pool:St,series:dt,xScale:ot,yScale:Rt,baseline:Rt===le?D.min<=0&&D.max>=0?0:D.min:Nt,colour:Et,stack:Vt,index:dt.index,slot:{offset:vt?0:$n*kn,width:kn,span:pn},pointColour:Ot});else if(Ae==="scatter"||Ae==="bubble")Qt({pool:St,series:dt,xScale:ot,yScale:Rt,colour:Et,index:dt.index,size:Ae==="bubble"?w.sizes:null,pointColour:Ot,marker:zt,markerEnv:At,plot:Oe});else{const Tn=xt(w,dt.label),zn=Ct==="step"?{type:"step",tension:1,mode:"after"}:d(w.curve,dt.label),En={pool:St,series:dt,xScale:ot,yScale:Rt,baseline:Nt,fill:xn?dt===_n:Ct==="area"||Ct==="rangeArea",lower:xn&&dt===_n?xn:null,curve:zn,colour:Et,stack:Vt,index:dt.index,style:Tn,marker:zt,markerEnv:At};Tn.emphasized?An.push(En):Wt(En)}}for(const Qe of An)Wt(Qe);w.pool||St.finish(),w.band&&typeof ot.invert=="function"&&rn({group:w.groups.overlay,band:w.band,xScale:ot,yScale:it,scheme:Me,index:0,line:w.band.line!==!1&&!w.fit}),w.fit&&(Ae==="scatter"||Ae==="bubble")&&typeof ot.invert=="function"&&mn({group:w.groups.overlay,series:je,xScale:ot,yScale:it,plot:Oe,scheme:Me,grid:w.grid,size:$e.small,showR2:w.fit!=="line"});let bn=null;w.trend&&(bn=oe({group:w.groups.overlay,series:je,xScale:ot,yScale:it,rightScale:le,plot:Oe,scheme:Me,trend:w.trend,grid:w.grid,format:Qe=>Re.tick(Qe),size:$e.small,clip:w.groups.boxClipId}));let Ln=null;if(w.error&&(Ln=on({group:w.groups.overlay,series:je,xScale:ot,yScale:it,grid:w.grid,options:w.error===!0?{}:w.error})),w.labels&&w.labels.show&&s({group:w.groups.labels,series:je,plot:Oe,options:w.labels,grid:w.grid,size:$e.small,horizontal:De}),w.reference&&w.reference.length){const Qe=De?w.reference:w.reference.filter(Et=>!(Et.axis==="right"||Et.axis==="y2")),dt=le?w.reference.filter(Et=>Et.axis==="right"||Et.axis==="y2"):[];Qe.length&&ln({group:w.groups.overlay,plot:Oe,scale:it,lines:Qe,vertical:De}),dt.length&&ln({group:w.groups.overlay,plot:Oe,scale:le,lines:dt})}let On=null;w.annotations&&w.annotations.length&&(On=j({group:w.groups.overlay,plot:Oe,xScale:ot,yScale:it,rightScale:le,series:je,annotations:w.annotations,dual:Ve,horizontal:De,format:Qe=>Re.tick(Qe),size:$e.small}));const Fn=Array.isArray(bn)&&bn.length?[...On||[],...bn]:On;return{xScale:ot,yScale:it,rightScale:le,dual:Ve,series:je,horizontal:De,percent:Je,percentTotals:Je?dn:null,plot:Oe,errorBars:Ln,annotations:Fn,trendlines:bn,reduced:Xe,legend:Ye?i({grid:w.grid,col:Ye,colours:st}):null}}const en=32;function tn(w){const{series:Me,xScale:de,at:$e}=w,Pe=Number.isFinite(w.tolerance)?Number(w.tolerance):en,Oe=[];let Ae=-1,Be=1/0;for(const je of Me){let De=null,Ie=-1,Ge=1/0;const nt=je.points||[];for(let Ye=0;Ye<nt.length;Ye++){const st=nt[Ye];if(!st||!m(st.y))continue;const at=Ft(de,st);if(Number.isNaN(at))continue;const lt=Math.abs(at-$e);lt>=Ge||(Ge=lt,De=st,Ie=Array.isArray(je.kept)?je.kept[Ye]:Ye)}!De||Ge>Pe||(Oe.push({series:je,point:De}),Ge<Be&&(Be=Ge,Ae=Ie))}return Ae<0?null:{index:Ae,entries:Oe}}function sn(w){const{bound:Me,xScale:de,at:$e}=w;if(!Me.categories.length)return-1;if(de.kind==="band"){const Ae=Math.floor(($e-de.range[0])/(de.step||1));return Ae>=0&&Ae<Me.categories.length?Ae:-1}let Pe=-1,Oe=1/0;for(let Ae=0;Ae<Me.categories.length;Ae++){const Be=de.kind==="time"?J(Me.categories[Ae]):W(Me.categories[Ae]);if(Be===null)continue;const je=Math.abs(de.of(Be)-$e);je<Oe&&(Oe=je,Pe=Ae)}return Pe}function un(w,Me){return Me<0||Me>=w.categories.length?"":r(w.categories[Me])}}),qe("packages/modules/charts/drawable.js",function(t,ce){"use strict";Object.defineProperty(t,"REASONS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(t,"DRAWABLE",{enumerable:!0,get:function(){return E}}),Object.defineProperty(t,"namedColumns",{enumerable:!0,get:function(){return q}}),Object.defineProperty(t,"missingColumns",{enumerable:!0,get:function(){return B}}),Object.defineProperty(t,"bucketKey",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"bucketMessage",{enumerable:!0,get:function(){return S}}),Object.defineProperty(t,"continuousX",{enumerable:!0,get:function(){return y}}),Object.defineProperty(t,"drawability",{enumerable:!0,get:function(){return P}});const _e=ce("packages/modules/charts/scale.js"),H=_e.extent,ue=_e.toNumber,ie=_e.toTime,n=ce("packages/modules/charts/cartesian.js").staleWindow,V=Object.freeze({EMPTY:"empty",INCOMPLETE:"incomplete",STALE:"stale",MISSING_COLUMN:"missing-column",NO_DOMAIN:"no-domain",BUCKETED:"bucketed",TOO_MANY_SETS:"too-many-sets"}),E=Object.freeze({ok:!0});function q(N){if(!N||typeof N!="object")return[];const p=[],u=(h,c)=>{typeof c=="string"&&c?p.push({key:h,col:c}):c&&typeof c=="object"&&typeof c.col=="string"&&c.col&&p.push({key:h,col:c.col})};if(Array.isArray(N.points))return[];if(u("x",N.x),u("code",N.code),u("y",N.y),u("series",N.series),u("size",N.size),u("source",N.source),u("target",N.target),u("text",N.text),u("time",N.time),u("entity",N.entity),u("colour",N.colour),u("set",N.set),Array.isArray(N.sets))for(const h of N.sets)u("sets",h);if(typeof N.multiples=="string"&&u("multiples",N.multiples),Array.isArray(N.measures))for(const h of N.measures)u("measures",h);return p}function B(N,p){const u=N&&N.columns;return!u||typeof u.get!="function"?[]:q(p).filter(({col:h})=>!u.get(h))}function f(N){return`chart:x:date-bucket:${N}`}function S(N,p,u){return`chart x column ${JSON.stringify(N)} is a 'date', which stores a calendar day, so all ${p} rows collapsed into one point and were reduced by '${u}'. For a series inside a single day, type the column 'datetime' or bind epoch milliseconds.`}function y(N,p){return!p||p.kind!=="time"&&p.kind!=="linear"?!1:N!=="bar"&&N!=="horizontalBar"}function P(N){const{grid:p,spec:u,type:h,bound:c}=N,k=N.id===void 0?"":String(N.id),m=Number.isFinite(N.now)?Number(N.now):Date.now(),r=(x,W,J,se=!0)=>({ok:!1,reason:x,key:J||`chart:${k}:${x}`,message:W,tell:se}),v=B(p,u);if(v.length){const x=v.map(J=>`${J.key}: ${JSON.stringify(J.col)}`).join(", "),W=p&&p.columns&&typeof p.columns.all=="function"?p.columns.all().map(J=>J.id||J.field).filter(Boolean):[];return r(V.MISSING_COLUMN,`chart ${x} ${v.length>1?"name columns":"names a column"} this grid does not have, so there is nothing to read and nothing to draw.${W.length?` The columns it does have: ${W.slice(0,12).map(J=>JSON.stringify(J)).join(", ")}${W.length>12?", …":""}.`:""} Bind a column the grid declares, or declare the column.`)}if(c&&c.empty){const x=p&&p.rows&&typeof p.rows.count=="function"?p.rows.count():0;return r(V.EMPTY,x?`chart bound nothing from the ${x} row(s) the grid is showing, so it shows its empty state. The binding named no series to draw: check that the spec names the columns this chart needs — a flow type needs source and target, a measure needs a column with values in it.`:"chart has no rows to draw, so it shows its empty state.",void 0,x>0)}if(h==="venn"&&c&&c.tooMany)return r(V.TOO_MANY_SETS,`a venn chart draws two or three sets and was given ${c.tooMany.count} (${c.tooMany.names.slice(0,8).map(x=>JSON.stringify(x)).join(", ")}${c.tooMany.count>8?", …":""}). Four or more sets cannot each have a region of their own as circles. Name two or three in "sets" (or "members" for a set column), or use an UpSet-style chart instead: a bar chart of how many rows hold each combination of memberships — group the grid by the membership columns and chart the row count.`);if(h==="venn"&&c&&c.tooFew)return r(V.INCOMPLETE,`a venn chart needs two or three sets and was given ${c.tooFew.count}. Name the membership columns in "sets" (boolean columns), or a multi-value column in "set" with the "members" to compare.`);if((h==="candlestick"||h==="ohlc")&&(!c||!c.series||c.series.length<4)){const x=c&&c.series?c.series.length:0;return r(V.INCOMPLETE,`a ${h} chart needs four measures — open, high, low and close, in that order — and ${x===0?"none was":`only ${x} were`} bound. Pass them as measures: [open, high, low, close].`)}const l=n(c,N.axis&&N.axis.x,h,m);if(l){const x=l.newest===null?"and every one of them is stamped ahead of it":`and the newest of ${l.points} x value(s) is ${Math.round(l.age/1e3)}s old`;return r(V.STALE,`the rolling x window covers the last ${l.span} ms, ${x}, so every mark would be drawn outside the plot. The chart shows its empty state instead. Seed it with data inside the window, widen axis.x.window.span, or drop the window while showing history.`,`chart:${k}:x:window:stale:${u&&u.x||""}`,l.newest!==null)}if(y(h,c)){const x=Array.isArray(c.categories)?c.categories:[],W=c.kind==="time"?x.map(ie):x.map(ue);if(x.length&&!H(W)){const J=u&&typeof u.x=="string"&&u.x||c.dimension&&c.dimension.col||"";return r(V.NO_DOMAIN,`chart x ${J?`column ${JSON.stringify(J)} `:""}is drawn on a ${c.kind==="time"?"time":"continuous"} axis, and not one of its ${x.length} value(s) reads as a ${c.kind==="time"?"date":"number"} — so the axis would be drawn over a domain invented from nothing rather than measured from the data. Remove axis.x.scale to let the column choose its own scale, or type the column so its values parse.`)}}if(c&&c.bucketed&&y(h,c)){const{col:x,rows:W,fn:J}=c.bucketed;return r(V.BUCKETED,S(x,W,J),f(x))}return E}}),qe("packages/modules/charts/bind.js",function(t,ce){"use strict";Object.defineProperty(t,"AGGREGATIONS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(t,"DEFAULT_AGGREGATION",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"resolveAggregation",{enumerable:!0,get:function(){return S}}),Object.defineProperty(t,"defaultAggregationFor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(t,"measureOf",{enumerable:!0,get:function(){return P}}),Object.defineProperty(t,"accumulateSeries",{enumerable:!0,get:function(){return N}}),Object.defineProperty(t,"walkRows",{enumerable:!0,get:function(){return p}}),Object.defineProperty(t,"leafRows",{enumerable:!0,get:function(){return u}}),Object.defineProperty(t,"selectedRows",{enumerable:!0,get:function(){return h}}),Object.defineProperty(t,"topGroups",{enumerable:!0,get:function(){return c}}),Object.defineProperty(t,"forcedScaleKind",{enumerable:!0,get:function(){return W}}),Object.defineProperty(t,"scaleKindFor",{enumerable:!0,get:function(){return se}}),Object.defineProperty(t,"bindSeries",{enumerable:!0,get:function(){return re}}),Object.defineProperty(t,"bindPoints",{enumerable:!0,get:function(){return b}}),Object.defineProperty(t,"bindMeasures",{enumerable:!0,get:function(){return C}}),Object.defineProperty(t,"bindLinks",{enumerable:!0,get:function(){return I}}),Object.defineProperty(t,"bindHierarchy",{enumerable:!0,get:function(){return M}});const _e=ce("packages/modules/charts/scale.js"),H=_e.key,ue=_e.toNumber,ie=_e.toTime,te=ce("packages/modules/charts/drawable.js"),n=te.bucketKey,V=te.bucketMessage,q=ce("packages/core/src/internal/warn.js").warnOnce,B={sum:e=>e.length?e.reduce((s,a)=>s+a,0):null,avg:e=>e.length?e.reduce((s,a)=>s+a,0)/e.length:null,mean:e=>e.length?e.reduce((s,a)=>s+a,0)/e.length:null,min:e=>{let s=null;for(let a=0;a<e.length;a++)(s===null||e[a]<s)&&(s=e[a]);return s},max:e=>{let s=null;for(let a=0;a<e.length;a++)(s===null||e[a]>s)&&(s=e[a]);return s},median:e=>{if(!e.length)return null;const s=e.slice().sort((Q,ve)=>Q-ve),a=(s.length-1)/2,_=Math.floor(a),$=Math.ceil(a);return _===$?s[_]:(s[_]+s[$])/2},count:(e,s)=>s,countValues:e=>e.length,countDistinct:e=>new Set(e).size,first:e=>e.length?e[0]:null,last:e=>e.length?e[e.length-1]:null},f="sum";function S(e){return e==null?f:typeof e=="string"&&e in B?e:(q(`chart:measure:fn:${String(e)}`,`chart measure fn ${JSON.stringify(e)} is not a known aggregation; using '${f}'. Supported: ${Object.keys(B).join(", ")}.`),f)}function y(e){if(!e)return f;const s=e.groupTotal??e.total;if(typeof s=="string"&&s in B)return s;const a=e.dataType&&e.dataType.totals?e.dataType.totals.supported:null;if(Array.isArray(a)&&!a.includes(f)){const _=["avg","mean","max","min","countValues","count"].find($=>a.includes($)&&$ in B);if(_)return _}return f}function P(e,s){const a=y(s);return e?typeof e=="string"?{col:e,fn:a,cumulative:!1}:{col:e.col||null,fn:e.fn==null?a:S(e.fn),cumulative:e.cumulative===!0}:{col:null,fn:a,cumulative:!1}}function N(e){for(const s of e){let a=null;for(const _ of s.points)_.y!==null&&_.y!==void 0&&(a=(a===null?0:a)+_.y),_.y=a}}function p(e,s){const a=new Set,_=$=>{if(!$||a.has($)||(a.add($),s($),!$.group)||$.expanded)return;const Q=$.filteredChildren||$.children;if(Array.isArray(Q))for(const ve of Q)_(ve)};e.rows.forEach(_)}function u(e){const s=[];return p(e,a=>{!a.group&&a.data!==null&&a.data!==void 0&&s.push(a)}),s}function h(e){const s=new Set(e.selection.keys());if(!s.size)return[];const a=[];return p(e,_=>{!_.group&&s.has(_.key)&&a.push(_)}),a}function c(e){const s=[];let a=1/0;return p(e,_=>{_.group&&(_.level<a&&(a=_.level,s.length=0),_.level===a&&s.push(_))}),s}function k(e,s,a){return s.group&&s.totals&&a in s.totals?ue(s.totals[a]):ue(e.rows.value(s.key,a))}function m(e,s,a,_){if(!s.group){const $=e.rows.text(s.key,a);if($)return $}return _==null?"":_ instanceof Date?_.toISOString().slice(0,10):String(_)}function r(e,s){return(B[s]||B[f])(e.values,e.rows)}const v=Object.freeze(["number","currency","percent"]),l=Object.freeze(["date","datetime","timestamp","dateString"]),x=Object.freeze({auto:"",band:"category",category:"category",linear:"linear",time:"time"});function W(e){const s=e&&typeof e=="object"?e.axis:null;if(!s||typeof s!="object")return"";const a=s.x;if(!a||typeof a!="object")return"";const _=typeof a.scale=="string"?a.scale:"";return _?Object.hasOwn(x,_)?x[_]:(q(`chart:x:scale:unknown:${_}`,`chart axis.x.scale ${JSON.stringify(_)} is not a scale this chart draws. Use one of: ${Object.keys(x).join(", ")}. The scale was chosen from the column instead.`),""):""}function J(e){if(e.length<3)return"";let s=0,a=0;for(const _ of e){if(_==null||_===""||typeof _=="boolean")return"";ue(_)!==null?s++:typeof _=="string"&&ie(_)!==null&&a++}return a===e.length?"time":s===e.length?"linear":""}function se(e,s,a={}){if(a.forced)return a.forced;const _=e&&typeof e.type=="string"?e.type:"";if(l.includes(_)||s.length&&s.every(ve=>ve instanceof Date))return"time";if(v.includes(_))return"linear";const $=a.id?String(a.id):"";if(!$)return"category";const Q=_&&_!=="text"?"":J(s);return Q&&q(`chart:x:banded:${$}`,`chart x column ${JSON.stringify($)} is typed ${JSON.stringify(_||"text")}, so its ${s.length} values are drawn as categories on a band scale even though they all read as ${Q==="time"?"dates":"numbers"}. Type the column ${Q==="time"?"'date' (or 'datetime'/'timestamp'/'dateString')":"'number'"} for a continuous axis, or pin it with axis: { x: { scale: '${Q}' } }.`),"category"}function re(e,s){const a=s.x||null,_=s.series||(typeof s.multiples=="string"?s.multiples:null)||null,$=e.columns,Q=a?$.get(a):void 0,ve=P(s.y),ge=ve.col?$.get(ve.col):void 0,Se=P(s.y,ge);let Ne;const Le=typeof s.rows=="function"?s.rows(e):s.rows;let j=!1;if(Array.isArray(Le)){const ee=Le.filter(L=>L&&typeof L=="object"&&(typeof L.key=="string"||typeof L.key=="number")&&e.rows.byKey(L.key)!==void 0);ee.length<Le.length&&(q("chart:rows:not-grid-rows",`chart "rows" takes rows the grid holds (from grid.rows.get(i) or grid.rows.byKey(key)); ${Le.length-ee.length} of ${Le.length} given are not and were left out. To chart other data, put it in a grid and chart that grid.`),j=ee.length===0),Ne=ee}else s.from==="groups"?Ne=c(e):s.from==="selection"?Ne=h(e):Ne=u(e);const pe=Ne.length||j?Ne:u(e),he=!!s.perRow,oe=new Map,fe=new Map,we=[];for(let ee=0;ee<pe.length;ee++){const L=pe[ee],Z=a?L.group&&L.groupColumn===a?L.groupValue:e.rows.value(L.key,a):ee,xe=he?`${H(Z)} ${ee}`:H(Z);oe.has(xe)||(oe.set(xe,{value:Z,label:a?m(e,L,a,Z):String(ee),order:oe.size,key:xe}),we.push(Z));const g=_?L.group&&L.groupColumn===_?L.groupValue:e.rows.value(L.key,_):null,A=_?H(g):"";fe.has(A)||fe.set(A,{label:_?m(e,L,_,g):ge?.title||"",points:new Map});const K=fe.get(A);let ae=K.points.get(xe);ae||(ae={values:[],rows:0,rowKey:L.key},K.points.set(xe,ae)),ae.rows+=L.group&&L.leafCount||1,(s.editable||s.selection)&&(ae.keys||(ae.keys=[])).push(L.key);const ye=Se.col?k(e,L,Se.col):null;if(ye!==null&&ae.values.push(ye),s.size){const ke=ue(e.rows.value(L.key,s.size));ke!==null&&(ae.sizes=(ae.sizes||0)+ke)}}const i=[...oe.values()].sort((ee,L)=>ee.order-L.order),Y=typeof s.limit=="number"&&s.limit>0?i.slice(0,s.limit):i,o=se(Q,we,{forced:W(s),id:a});let d=null;o==="time"&&pe.length>1&&oe.size===1&&Q&&(Q.type==="date"||Q.type==="dateString")&&(d={col:String(a),rows:pe.length,fn:Se.fn},q(n(d.col),V(d.col,d.rows,d.fn)));const F=v.includes(Q&&typeof Q.type=="string"?Q.type:"")?[...Y].sort((ee,L)=>(ue(ee.value)??0)-(ue(L.value)??0)):o==="time"?[...Y].sort((ee,L)=>(ie(ee.value)??1/0)-(ie(L.value)??1/0)||0):Y,U=[...fe.entries()].map(([ee,L],Z)=>({key:ee,label:L.label,index:Z,points:F.map(xe=>{const g=L.points.get(xe.key);return{x:xe.value,xKey:H(xe.value),label:xe.label,y:g?r(g,Se.fn):null,size:g&&g.sizes!==void 0?g.sizes:null,rows:g?g.rows:0,rowKey:g?g.rowKey:null,...(s.editable||s.selection)&&g&&g.keys?{rowKeys:g.keys}:{},values:g&&g.values?g.values:null}})}));return Se.cumulative&&N(U),{series:U,categories:F.map(ee=>ee.value),labels:F.map(ee=>ee.label),kind:o,measure:{...Se,title:ge?.title||Se.col||""},dimension:{col:a,title:Q?.title||a||""},empty:U.length===0||F.length===0,rows:pe.length,truncated:i.length-F.length,bucketed:d}}function b(e){const s=Array.isArray(e.points)?e.points:[],a=s.length>0&&s.every(Q=>typeof Q.x=="number"&&Number.isFinite(Q.x)),_=Q=>typeof Q=="number"&&Number.isFinite(Q)?Q:null,$=s.map((Q,ve)=>({x:Q.x,xKey:H(Q.x),label:Q.label!=null?String(Q.label):String(Q.x),y:_(Q.y),size:_(Q.size),lower:_(Q.lower),upper:_(Q.upper),rows:1,rowKey:Q.key!=null?String(Q.key):String(ve),values:null}));return{series:[{key:e.seriesKey||"",label:e.seriesLabel||"",index:0,points:$}],categories:$.map(Q=>Q.x),labels:$.map(Q=>Q.label),kind:a?"linear":"category",measure:{col:null,fn:"sum",title:e.measureTitle||""},dimension:{col:null,title:e.dimensionTitle||""},empty:$.length===0,rows:$.length,truncated:0}}function C(e,s){const a=Array.isArray(s.measures)?s.measures:[];if(!a.length)return re(e,s);const _=a.map(ge=>{const Se=typeof ge=="string"?{col:ge}:ge;return{spec:Se,result:re(e,{x:s.x,from:s.from,limit:s.limit,axis:s.axis,y:{col:Se.col,fn:Se.fn,cumulative:Se.cumulative===!0}})}}),$=_[0].result,Q=new Map($.categories.map((ge,Se)=>[H(ge),Se])),ve=_.map(({spec:ge,result:Se},Ne)=>{const Le=e.columns.get(ge.col),j=$.categories.map(()=>null),pe=Se.series[0];if(pe)for(const he of pe.points){const oe=Q.get(he.xKey);oe!==void 0&&(j[oe]=he)}return{key:ge.col,label:ge.title||ge.label||Le&&Le.title||ge.col,index:Ne,mark:ge.type||null,axis:ge.axis==="right"?"right":"left",points:$.categories.map((he,oe)=>j[oe]||{x:he,xKey:H(he),label:$.labels[oe],y:null,rows:0,rowKey:null})}});return{series:ve,categories:$.categories,labels:$.labels,kind:$.kind,measure:{col:null,fn:"sum",title:ve.map(ge=>ge.label).join(", ")},dimension:$.dimension,empty:!ve.length||!$.categories.length,rows:$.rows,truncated:$.truncated}}function I(e,s,a={}){const _=P(s.y),$=!!a.perRow,Q=Array.isArray(a.nodes)?a.nodes:[],ve=s.source||s.x||null,ge=s.target||null;if(!ve||!ge)return{nodes:[],links:[],measure:{..._,title:""},dimension:{col:null,title:""},series:[],categories:[],labels:[],empty:!0,total:0};const Se=_.col?e.columns.get(_.col):void 0,Ne=new Map,Le=new Map,j=(fe,we,i)=>{const Y=H(fe);return Ne.has(Y)||Ne.set(Y,{key:Y,value:fe,label:m(e,we,i,fe),index:Ne.size,in:0,out:0}),Ne.get(Y)},pe=new Map;for(const fe of Q)!fe||fe.id===null||fe.id===void 0||pe.set(H(fe.id),fe);for(const fe of u(e)){const we=e.rows.value(fe.key,ve),i=e.rows.value(fe.key,ge);if(we==null||i===null||i===void 0)continue;const Y=_.col?ue(e.rows.value(fe.key,_.col)):1;if(Y===null||Y<=0)continue;const o=j(we,fe,ve),d=j(i,fe,ge);if($){const O=o.key>d.key,F=O?d:o,U=O?o:d;Le.set(`${F.key}\0${U.key}\0${Le.size}`,{source:F,target:U,value:Y,undirected:!0,pair:`${F.key}\0${U.key}`,rowKeys:[fe.key]})}else{const O=`${o.key}\0${d.key}`,F=Le.get(O)||{source:o,target:d,value:0,rowKeys:[]};F.value+=Y,F.rowKeys.length<64&&F.rowKeys.push(fe.key),Le.set(O,F)}o.out+=Y,d.in+=Y}for(const[fe,we]of pe)Ne.has(fe)||Ne.set(fe,{key:fe,value:we.id,label:String(we.label??we.id),index:Ne.size,in:0,out:0});for(const[fe,we]of pe){const i=Ne.get(fe);i&&(i.declared=!0,we.label!==void 0&&we.label!==null&&(i.label=String(we.label)),typeof we.icon=="string"&&we.icon&&(i.icon=we.icon),Number.isFinite(we.x)&&Number.isFinite(we.y)&&(i.fx=Number(we.x),i.fy=Number(we.y)))}const he=$?[...Le.values()]:[...Le.values()].sort((fe,we)=>we.value-fe.value),oe=typeof s.limit=="number"&&s.limit>0?he.slice(0,s.limit):he;return{nodes:[...Ne.values()],links:oe,measure:{..._,title:Se?.title||_.col||""},dimension:{col:ve,title:e.columns.get(ve)?.title||ve},series:[],categories:[],labels:[],empty:!oe.length,total:oe.reduce((fe,we)=>fe+we.value,0)}}function M(e,s,a={}){if(typeof s.parentId=="string"&&s.parentId)return ne(e,s,a);if(typeof s.path=="string"&&s.path)return R(e,s,a);const _=P(s.y),$=typeof s.depth=="number"&&s.depth>0?s.depth:1/0,Q=_.col?e.columns.get(_.col):void 0,ve=s.radius&&typeof s.radius=="object"?s.radius:null,ge=ve&&typeof ve.col=="string"?P(ve.col):null,Se=ge&&ge.col?e.columns.get(ge.col):void 0,Ne=(fe,we,i)=>({label:fe,value:we,depth:i,total:0,radius:0,children:[],rowKey:null,rowKeys:[]}),Le=Ne("",null,0),j=c(e),pe=new Map;if(j.length){const fe=[];p(e,we=>{if(we.group){for(;fe.length&&fe[fe.length-1].level>=we.level;)fe.pop();fe.push(we),pe.has(we.key)||pe.set(we.key,[])}else if(we.data!==null&&we.data!==void 0)for(const i of fe)pe.get(i.key).push(we.key)})}if(j.length){const fe=(we,i,Y)=>{const o=we.groupColumn?m(e,we,we.groupColumn,we.groupValue):"",d=Ne(o,we.groupValue,Y);d.rowKey=we.key;const O=_.col?k(e,we,_.col):null;if(d.total=O===null?0:Math.abs(O),ge&&ge.col){const U=k(e,we,ge.col);d.radius=U===null?0:Math.abs(U)}i.children.push(d);const F=we.filteredChildren||we.children;if(d.rowKeys=[...pe.get(we.key)||[]],Y<$&&Array.isArray(F))for(const U of F)U.group&&fe(U,d,Y+1);return!_.col&&a.count&&(d.total=d.rowKeys.length),!d.total&&d.children.length&&(d.total=d.children.reduce((U,ee)=>U+ee.total,0)),!d.radius&&ge&&d.children.length&&(d.radius=d.children.reduce((U,ee)=>U+ee.radius,0)),d};for(const we of j)fe(we,Le,1)}else{if(Array.isArray(s.x)&&s.x.length)return T(e,s,a);{const we=re(e,{x:s.x,y:s.y,limit:s.limit,editable:s.editable,selection:s.selection}).series[0];if(we){const i=we.points.map(()=>0);if(ge&&ge.col){const Y=new Map(we.points.map((o,d)=>[H(o.x),d]));for(const o of u(e)){const d=s.x?e.rows.value(o.key,s.x):null,O=Y.get(H(d));if(O===void 0)continue;const F=k(e,o,ge.col);F!==null&&(i[O]+=Math.abs(F))}}for(let Y=0;Y<we.points.length;Y++){const o=we.points[Y],d=Ne(o.label,o.x,1);d.total=o.y===null?0:Math.abs(o.y),d.rowKey=o.rowKey,d.rowKeys=o.rowKeys||(o.rowKey?[o.rowKey]:[]),d.radius=i[Y],Le.children.push(d)}}}}Le.total=Le.children.reduce((fe,we)=>fe+we.total,0);let he=0;const oe=fe=>{fe.depth>he&&(he=fe.depth);for(const we of fe.children)oe(we)};return oe(Le),{root:Le,depth:he,measure:{..._,title:Q?.title||_.col||""},radius:ge?{...ge,title:Se?.title||ge.col||""}:null,empty:Le.total<=0||Le.children.length===0}}function X(e,s,a,_,$){let Q=0;const ve=(Se,Ne)=>{Se.depth=Ne,Ne>Q&&(Q=Ne);for(const Le of Se.children)ve(Le,Ne+1);if(Se.children.length){const Le=Se.children.reduce((j,pe)=>j+pe.total,0);Le>0||!Se.own?Se.total=Le:Se.total=Se.own;for(const j of Se.children)for(const pe of j.rowKeys)Se.rowKeys.push(pe)}else Se.total=Se.own||(!a.col&&$?1:0)};ve(s,0);const ge=a.col?e.columns.get(a.col):void 0;return{root:s,depth:Q,measure:{...a,title:ge?.title||a.col||""},dimension:_,radius:null,empty:s.total<=0||s.children.length===0}}function z(e,s){return{label:e,value:s,depth:0,total:0,own:0,radius:0,children:[],rowKey:null,rowKeys:[]}}function ne(e,s,a){const _=P(s.y),$=s.id||null,Q=s.label||s.x||$,ve=z("",null),ge=new Map,Se=new Map;for(const Le of u(e)){const j=$?e.rows.value(Le.key,$):null,pe=j==null||j===""?Le.key:j,he=String(pe);if(ge.has(he))continue;const oe=Q?e.rows.text(Le.key,Q):"",fe=z(oe||he,pe);fe.rowKey=Le.key,fe.rowKeys=[Le.key];const we=_.col?k(e,Le,_.col):null;fe.own=we===null?0:Math.abs(we),ge.set(he,fe);const i=e.rows.value(Le.key,s.parentId);Se.set(he,i==null||i===""?"":String(i))}for(const[Le,j]of ge){let pe=Se.get(Le),he=0;for(;pe&&ge.has(pe)&&pe!==Le&&he<=ge.size;)pe=Se.get(pe),he+=1;((!(he>ge.size||pe===Le)&&Se.get(Le)&&Se.get(Le)!==Le?ge.get(Se.get(Le)):null)||ve).children.push(j)}const Ne={col:Q||s.parentId,title:e.columns.get(Q||s.parentId)?.title||Q||s.parentId};return X(e,ve,_,Ne,!!a.count)}function R(e,s,a){const _=P(s.y),$=typeof s.pathSeparator=="string"&&s.pathSeparator?s.pathSeparator:"/",Q=z("",null),ve=new Map([[Q,new Map]]);for(const Se of u(e)){const Ne=e.rows.value(Se.key,s.path);if(Ne==null||Ne==="")continue;const Le=String(Ne).split($).map(he=>he.trim()).filter(Boolean);let j=Q;for(const he of Le){let oe=ve.get(j).get(he);oe||(oe=z(he,he),ve.get(j).set(he,oe),ve.set(oe,new Map),j.children.push(oe)),j=oe}if(j===Q)continue;j.rowKey=j.rowKey||Se.key,j.rowKeys.push(Se.key);const pe=_.col?k(e,Se,_.col):null;j.own+=pe===null?0:Math.abs(pe),!_.col&&a.count&&(j.own+=1)}const ge={col:s.path,title:e.columns.get(s.path)?.title||s.path};return X(e,Q,_,ge,!!a.count)}function G(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(typeof e.field=="string"&&e.field)return e.field;if(typeof e.col=="string"&&e.col)return e.col}return null}function T(e,s,a){const _=P(s.y),$=(Array.isArray(s.x)?s.x:[]).map(G).filter(Boolean),Q=z("",null);if(!$.length)return X(e,Q,_,{col:"",title:""},!!a.count);const ve=new Map([[Q,new Map]]);for(const Se of u(e)){let Ne=Q;for(let j=0;j<$.length;j++){const pe=$[j],he=e.rows.value(Se.key,pe);if(he==null||he==="")break;const oe=H(he);let fe=ve.get(Ne).get(oe);fe||(fe=z(m(e,Se,pe,he),he),ve.get(Ne).set(oe,fe),ve.set(fe,new Map),Ne.children.push(fe)),Ne=fe}Ne.rowKey=Ne.rowKey||Se.key,Ne.rowKeys.push(Se.key);const Le=_.col?k(e,Se,_.col):null;Ne.own+=Le===null?0:Math.abs(Le),!_.col&&a.count&&(Ne.own+=1)}const ge={col:$[0],title:e.columns.get($[0])?.title||$[0]};return X(e,Q,_,ge,!!a.count)}}),qe("packages/modules/charts/engine.js",function(t,ce){"use strict";Object.defineProperty(t,"AGGREGATE_MODES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(t,"ENGINE_TYPES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(t,"aggregateMode",{enumerable:!0,get:function(){return x}}),Object.defineProperty(t,"planAggregate",{enumerable:!0,get:function(){return se}}),Object.defineProperty(t,"holdsWindow",{enumerable:!0,get:function(){return re}}),Object.defineProperty(t,"boundFromGroups",{enumerable:!0,get:function(){return I}}),Object.defineProperty(t,"measureProvenance",{enumerable:!0,get:function(){return M}}),Object.defineProperty(t,"specMeasures",{enumerable:!0,get:function(){return X}});const _e=ce("packages/modules/charts/scale.js"),H=_e.key,ue=_e.toNumber,ie=ce("packages/modules/charts/bind.js"),te=ie.accumulateSeries,n=ie.forcedScaleKind,V=ie.measureOf,E=ie.scaleKindFor,B=ce("packages/core/src/internal/warn.js").warnOnce,f=ce("packages/modules/shared/engine.js"),S=f.engineSource,y=f.gridEngineRequest,P=f.gridHoldsWindow,N=f.loadedAndMatching,p=f.sourceId,u=Object.freeze(["auto","engine","client"]),h=Object.freeze(new Set(["line","step","area","bar","horizontalBar","waterfall","combo","pareto","heatmap","radar","funnel","stream","marimekko"])),c=Object.freeze(new Set(["combo","bar","line","step","area"])),k=Object.freeze({mean:"avg"}),m="__rows",r="m",v="__size",l=/^[A-Za-z_][A-Za-z0-9_$]*$/;function x(z){const ne=z?z.aggregate:void 0;return ne==null?"auto":typeof ne=="string"&&u.includes(ne)?ne:(B(`chart:aggregate:mode:${String(ne)}`,`chart aggregate ${JSON.stringify(ne)} is not a mode; use one of ${u.join(", ")}. The chart used 'auto'.`),"auto")}function W(z,ne,R){const G=z.columns.get(ne);if(!G)return`the ${R} column "${ne}" is not a column of the grid`;const T=G.value&&typeof G.value=="object"?G.value:null;return G.computed||T&&(typeof T.get=="function"||typeof T.compute=="function")?`the ${R} column "${ne}" is computed by the grid, which the engine cannot reproduce`:(typeof G.field=="string"?G.field:ne)!==ne||!l.test(ne)?`the ${R} column "${ne}" is not a plain physical column the engine can name`:R!=="measure"&&G.type==="geometry"?`the ${R} column "${ne}" is a geometry, which charts group in the browser for now`:""}function J(z,ne,R){const G=c.has(R)&&Array.isArray(ne.measures)&&ne.measures.length>0;return(G?ne.measures:[ne.y]).map((e,s)=>{const a=V(e),_=a.col?z.columns.get(a.col):void 0,$=V(e,_),Q=e&&typeof e=="object"?e:{};return{id:`${r}${s}`,col:$.col,fn:$.fn,stat:k[$.fn]||$.fn,label:G?Q.title||Q.label||_&&_.title||$.col||"":_&&_.title||$.col||"",mark:G&&Q.type||null,axis:G&&Q.axis==="right"?"right":"left",cumulative:$.cumulative,multi:G}})}function se(z,ne,R){const G=x(ne),T=(oe,fe=!1)=>({mode:"client",asked:G,reason:oe,refused:G==="engine",windowed:fe});if(G==="client")return{...T("aggregate: 'client' was asked for"),refused:!1};if(!h.has(R))return T(`a "${R}" chart does not draw a grouped aggregate`);if(Array.isArray(ne.points))return T("the chart draws an explicit point set");if(ne.rows)return T("the chart was handed its own rows");if(ne.from==="groups"||ne.from==="selection")return T(`the chart reads the grid's ${ne.from==="groups"?"group rows":"selection"}`);if(ne.error)return T("error bars need the readings behind each mark");const e=S(z);if("reason"in e)return T(e.reason);const{source:s,caps:a}=e;if(!a.group)return T("the source's adapter does not declare the `group` capability");const _=typeof ne.x=="string"&&ne.x?ne.x:null;if(!_)return T("the chart names no x column to group by");const $=typeof ne.series=="string"&&ne.series?ne.series:typeof ne.multiples=="string"?ne.multiples:null,Q=J(z,ne,R),ve=Q.length>0&&Q[0].multi,ge=$&&!ve?[_,$]:[_];for(const[oe,fe]of ge.entries()){const we=W(z,fe,oe===0?"x":"series");if(we)return T(we)}for(const oe of Q){if(!oe.col)return T("a measure names no column to reduce");const fe=W(z,oe.col,"measure");if(fe)return T(fe);const we=s.STAT_PUSHDOWN[oe.stat];if(!we||!we.pushable)return T(`"${oe.fn}" of "${oe.col}" is not a reduction the engine can compute`)}if(ne.size){const oe=typeof ne.size=="string"?W(z,ne.size,"measure"):"the size channel is not a column";if(oe)return T(oe)}const Se=[...Q.map(oe=>({id:oe.id,col:oe.col,fn:oe.stat})),{id:m,col:_,fn:"count"},...ne.size?[{id:v,col:ne.size,fn:"sum"}]:[]],Ne=s.resolveAggregatePlan(Se);if(Ne.client.length){const oe=Ne.client[0];return T(`the source computes "${oe.fn}" client-side (${oe.reason}); set the pushdown source's \`aggregates: { default: 'engine' }\` to compute it in the engine`)}const Le=y(z,e);if("reason"in Le)return T(Le.reason);const{quick:j}=Le,pe={...Le.request,groupBy:ge};if(G==="auto"){const{loaded:oe,total:fe}=N(z);if(Number.isFinite(fe)&&oe>=fe)return T("the grid holds every matching row")}const he=JSON.stringify([p(s),pe.filters,j,ge,Se]);return{mode:"engine",asked:G,key:he,source:s,request:pe,requested:Se,groupBy:ge,measures:Q}}function re(z){return P(z)}function b(z,ne){if(ne==null)return"";if(z&&typeof z.formatValue=="function")try{const R=z.formatValue(ne,null);if(typeof R=="string"&&R)return R}catch{}return ne instanceof Date?ne.toISOString().slice(0,10):String(ne)}function C(z,ne){if(z==null)return ne==null?0:1;if(ne==null)return-1;const R=z instanceof Date?z.getTime():ue(z),G=ne instanceof Date?ne.getTime():ue(ne);return typeof z!="string"&&typeof ne!="string"&&R!==null&&G!==null?R-G:String(z).localeCompare(String(ne))}function I(z,ne,R,G){const{groupBy:T,measures:e}=R,s=T[0],a=T[1]||null,_=e[0].multi,$=z.columns.get(s),Q=a?z.columns.get(a):void 0,ve=(G||[]).filter(d=>d&&d.level===T.length),ge=new Map,Se=new Map,Ne=new Map;for(const d of ve){const O=d.keys[0],F=H(O);ge.has(F)||ge.set(F,O);const U=a?d.keys[1]:null,ee=a?H(U):"";Se.has(ee)||Se.set(ee,U),Ne.set(`${ee}\0${F}`,d.values||{})}const Le=z.sort&&typeof z.sort.get=="function"?z.sort.get():[],j=Array.isArray(Le)&&Le[0]&&Le[0].col===s&&Le[0].dir==="desc",pe=[...ge.entries()].sort((d,O)=>C(d[1],O[1]));j&&pe.reverse();const he=typeof ne.limit=="number"&&ne.limit>0?pe.slice(0,ne.limit):pe,oe=he.map(([,d])=>b($,d)),fe=he.map(([,d])=>d),we=(d,O,F,U,ee)=>{const L=Ne.get(`${d}\0${O}`),Z=L?ue(L[m]):null;return{x:F,xKey:O,label:U,y:L?ue(L[ee]):null,size:L&&ne.size?ue(L[v]):null,rows:Z===null?0:Z,rowKey:null,values:null}};let i;if(_){i=e.map((d,O)=>({key:d.col,label:d.label,index:O,mark:d.mark,axis:d.axis,points:he.map(([F,U],ee)=>we("",F,U,oe[ee],d.id))}));for(const[d,O]of e.entries())O.cumulative&&te([i[d]])}else i=[...Se.entries()].sort((O,F)=>C(O[1],F[1])).map(([O,F],U)=>({key:O,label:a?b(Q,F):e[0].label,index:U,points:he.map(([ee,L],Z)=>we(O,ee,L,oe[Z],e[0].id))})),e[0].cumulative&&te(i);const Y=ve.reduce((d,O)=>d+(ue(O.values&&O.values[m])||0),0),o=E($,fe,{forced:n(ne),id:s});return{series:i,categories:fe,labels:oe,kind:o,measure:_?{col:null,fn:"sum",title:i.map(d=>d.label).join(", ")}:{col:e[0].col,fn:e[0].fn,title:e[0].label},dimension:{col:s,title:$&&$.title||s},empty:i.length===0||he.length===0,rows:Y,truncated:pe.length-he.length,bucketed:null}}function M(z,ne,R=[],G=""){return z.map(T=>{const e=R.find(s=>s.id===T.id);return{col:T.col||null,fn:T.fn,computed:ne,...e&&e.class?{class:e.class}:{},...ne==="client"&&G?{reason:G}:{}}})}function X(z,ne,R){try{return J(z,ne,R).filter(G=>G.col)}catch{return[]}}}),qe("packages/core/src/internal/merge.js",function(t,ce){"use strict";Object.defineProperty(t,"expand",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(t,"toArray",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(t,"merge",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"mergeRow",{enumerable:!0,get:function(){return V}});const H=ce("packages/core/src/internal/predicates.js").isObject;function ue(E,q,B){if(E!==void 0)return E===!0?{enabled:!0,...B}:E===!1?{enabled:!1}:H(E)?E:{[q]:E,enabled:!0}}function ie(E){return E==null?[]:Array.isArray(E)?E:[E]}const te=Object.freeze(new Set(["__proto__","constructor","prototype"]));function n(E,q){if(!H(E))return H(q)?{...q}:q;if(!H(q))return q===void 0?E:q;const B={...E};for(const f of Object.keys(q)){if(te.has(f))continue;const S=q[f];S!==void 0&&(B[f]=H(S)&&H(B[f])?n(B[f],S):S)}return B}function V(E,q){if(!H(E)||!H(q)||E===q)return q;const B=Object.create(Object.getPrototypeOf(E));return Object.assign(B,E,q),B}}),qe("packages/core/src/internal/compare.js",function(t,ce){"use strict";Object.defineProperty(t,"collator",{enumerable:!0,get:function(){return H}}),Object.defineProperty(t,"defaultCompare",{enumerable:!0,get:function(){return ue}});const _e=new Map;function H(ie,te){const n=`${ie||""}|${te?JSON.stringify(te):""}`;let V=_e.get(n);return V||(V=new Intl.Collator(ie||void 0,{numeric:!0,sensitivity:"variant",...te}),_e.set(n,V)),V}function ue(ie,te){if(ie===te)return 0;if(ie==null)return 1;if(te==null)return-1;if(typeof ie=="number"&&typeof te=="number")return Number.isNaN(ie)?Number.isNaN(te)?0:1:Number.isNaN(te)||ie<te?-1:ie>te?1:0;const n=String(ie),V=String(te);return n<V?-1:n>V?1:0}}),qe("packages/core/src/compute/handle.js",function(t,ce){"use strict";Object.defineProperty(t,"identity",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"rowCount",{enumerable:!0,get:function(){return V}}),Object.defineProperty(t,"bitReader",{enumerable:!0,get:function(){return B}}),Object.defineProperty(t,"presenceReader",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"dictSize",{enumerable:!0,get:function(){return S}}),Object.defineProperty(t,"dictValue",{enumerable:!0,get:function(){return y}}),Object.defineProperty(t,"multiValue",{enumerable:!0,get:function(){return P}}),Object.defineProperty(t,"valueReader",{enumerable:!0,get:function(){return N}}),Object.defineProperty(t,"numericTotalOrder",{enumerable:!0,get:function(){return p}}),Object.defineProperty(t,"valueComparator",{enumerable:!0,get:function(){return u}}),Object.defineProperty(t,"dictRanks",{enumerable:!0,get:function(){return h}}),Object.defineProperty(t,"isMissing",{enumerable:!0,get:function(){return c}});const _e=ce("packages/core/src/internal/compare.js"),H=_e.collator,ue=_e.defaultCompare,te=ce("packages/core/src/internal/warn.js").warnOnce;function n(k){const m=new Uint32Array(k);for(let r=0;r<k;r++)m[r]=r;return m}function V(k,m){if(m&&typeof m.count=="number")return m.count;if(!k)return 0;if(typeof k.count=="number")return k.count;if(typeof k.length=="number")return k.length;const r=k.values;return k.kind==="multi"&&k.offsets?Math.max(0,k.offsets.length-1):r?k.kind==="bitset"?typeof r.size=="number"?r.size:k.presence&&typeof k.presence.size=="number"?k.presence.size:(te(`count:${k.id}`,`column "${k.id}" is bitset-backed with no declared row count; assuming ${r.length*8}`),r.length*8):r.length:k.presence&&typeof k.presence.size=="number"?k.presence.size:0}const E=new WeakMap;function q(k){const m=k.constructor;if(!m)return"unknown";const r=E.get(m);if(r)return r;let v="unknown";try{let l=null;typeof m.from=="function"?l=m.from([!1,!0]):(l=new m(8),l.set(1));const x=l&&l.words;x&&x.length&&(x[0]===2?v="lsb":x[0]===64&&(v="msb"))}catch{v="unknown"}return E.set(m,v),v}function B(k){if(!k)return()=>0;const m=k instanceof Uint8Array?k:k.words;if(m instanceof Uint8Array){const r=k instanceof Uint8Array?"lsb":q(k);if(r==="lsb")return v=>m[v>>>3]>>>(v&7)&1;if(r==="msb")return v=>m[v>>>3]>>>7-(v&7)&1}return typeof k.get=="function"?r=>k.get(r)?1:0:()=>0}function f(k){return!k||!k.presence?null:B(k.presence)}function S(k){return k?typeof k.size=="number"?k.size:typeof k.values=="function"?k.values().length:0:0}function y(k,m){return k?typeof k.valueOf=="function"?k.valueOf(m):typeof k.values=="function"?k.values()[m]:null:null}function P(k,m){const r=k.offsets,v=k.values;if(!r||!v)return[];const l=r[m],x=r[m+1];if(!(x>l))return[];const W=k.dict,J=new Array(x-l);for(let se=l;se<x;se++)J[se-l]=W?y(W,v[se]):v[se];return J}function N(k){if(!k)return()=>{};const m=k.values,r=f(k),v=k.kind;if(v==="dictionary"){const l=k.dict;return r?x=>r(x)?y(l,m[x]):null:x=>y(l,m[x])}if(v==="bitset"){const l=B(m);return r?x=>r(x)?l(x)===1:null:x=>l(x)===1}if(v==="multi")return r?l=>r(l)?P(k,l):null:l=>P(k,l);if(!m&&typeof k.get=="function"){const l=k.get.bind(k);return x=>{const W=l(x);return W===void 0?null:W}}return r?l=>{if(!r(l))return null;const x=m[l];return x===void 0?null:x}:l=>{const x=m[l];return x===void 0?null:x}}function p(k,m){if(k<m)return-1;if(k>m)return 1;if(k===m){const l=Object.is(k,-0),x=Object.is(m,-0);return l===x?0:l?-1:1}const r=Number.isNaN(k),v=Number.isNaN(m);return r&&v?0:r?1:-1}function u(k){const m=H(k);return(r,v)=>{if(r===v)return 0;const l=typeof r,x=typeof v;if(l==="string"&&x==="string")return m.compare(r,v);if(l==="number"&&x==="number")return p(r,v);if(l==="boolean"&&x==="boolean")return r===v?0:r?1:-1;if(r instanceof Date||v instanceof Date){const W=r instanceof Date?r.getTime():Number(r),J=v instanceof Date?v.getTime():Number(v);return p(W,J)}return ue(r,v)}}function h(k,m){if(k&&typeof k.ranks=="function")return k.ranks(m);const r=k&&typeof k.values=="function"?k.values():[],v=r.length,l=u(m),x=new Array(v);for(let J=0;J<v;J++)x[J]=J;x.sort((J,se)=>l(r[J],r[se])||J-se);const W=new Uint32Array(v);for(let J=0;J<v;J++)W[x[J]]=J;return W}function c(k){return k==null||typeof k=="number"&&Number.isNaN(k)}}),qe("packages/core/src/compute/filter.js",function(t,ce){"use strict";Object.defineProperty(t,"releaseMask",{enumerable:!0,get:function(){return k}}),Object.defineProperty(t,"compilePredicate",{enumerable:!0,get:function(){return C}}),Object.defineProperty(t,"wallMs",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(t,"testValue",{enumerable:!0,get:function(){return T}}),Object.defineProperty(t,"itemwisePredicate",{enumerable:!0,get:function(){return a}}),Object.defineProperty(t,"evaluateCondition",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(t,"evaluateFilters",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(t,"pruneColumn",{enumerable:!0,get:function(){return j}}),Object.defineProperty(t,"mentionsColumn",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(t,"compact",{enumerable:!0,get:function(){return he}}),Object.defineProperty(t,"declareOperators",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(t,"declaredOperator",{enumerable:!0,get:function(){return we}});const H=ce("packages/core/src/internal/predicates.js").isBlank,ie=ce("packages/core/src/internal/merge.js").toArray,n=ce("packages/core/src/internal/warn.js").warnOnce,V=ce("packages/core/src/format/date.js"),E=V.toDate,q=V.toIsoDate,B=ce("packages/core/src/compute/handle.js"),f=B.bitReader,S=B.dictSize,y=B.dictValue,P=B.presenceReader,N=B.valueComparator,p=B.valueReader,u=/^\d{4}-\d{2}-\d{2}$/,h="\0null\0";function c(i,Y){const o=i&&i.pool;if(o){const d=o.mask||o.acquireMask||o.acquire||o.take;if(typeof d=="function"){const O=d.call(o,Y);if(O&&O.length>=Y)return O}}return new Uint8Array(Y)}function k(i,Y){const o=i&&i.pool;if(!o||!Y)return;const d=o.release||o.releaseMask||o.free||o.recycle;typeof d=="function"&&d.call(o,Y)}function m(i,Y,o){return i.fill(o,0,Y),i}function r(i){return i==null||typeof i=="number"&&Number.isNaN(i)}function v(i,Y){if(i==null)return i;if(Y==="number")return typeof i=="number"?i:Number(i);if(Y==="date"||Y==="dateString"){const o=q(i);return o===null?l(i):o}return Y==="boolean"?typeof i=="boolean"?i:i==="true"||i===1?!0:i==="false"||i===0?!1:!!i:i}function l(i){return i instanceof Date?i.getTime():typeof i=="number"?i:Date.parse(String(i))}function x(i){return typeof i=="number"?i:i instanceof Date?i.getTime():i==null||i===""?NaN:Number(i)}function W(i,Y){const o=typeof i=="string"?i:String(i);return Y?o:o.toLowerCase()}function J(i,Y){return i==null?h:typeof i=="string"?Y?i:i.toLowerCase():i instanceof Date?i.getTime():i}function se(i,Y,o){const d=new Set;for(const O of ie(i)){const F=v(O,o);d.add(J(F,Y)),typeof F=="string"&&F!==""&&Number.isFinite(Number(F))?d.add(Number(F)):typeof F=="number"&&Number.isFinite(F)&&d.add(J(String(F),Y))}return d}function re(i,Y,o){if(i==null||Y===null||Y===void 0)return i==null&&Y==null;const d=typeof i,O=typeof Y;return d==="string"&&O==="string"?o?i===Y:i.toLowerCase()===Y.toLowerCase():i instanceof Date||Y instanceof Date?l(i)===l(Y):d==="number"&&O==="number"?i===Y||Number.isNaN(i)&&Number.isNaN(Y):d==="number"&&O==="string"?i===Number(Y):d==="string"&&O==="number"?Number(i)===Y:d==="boolean"||O==="boolean"?i===Y:Array.isArray(i)&&Array.isArray(Y)?i.length===Y.length&&i.every((F,U)=>re(F,Y[U],o)):i===Y}function b(i,Y){try{if(i instanceof RegExp){const o=i.flags.replace(/[gy]/g,"");return new RegExp(i.source,Y||o.includes("i")?o:`${o}i`)}return new RegExp(String(i),Y?"":"i")}catch(o){return n(`regex:${String(i)}`,`filter operator "matches" received an invalid pattern: ${String(i)}`,o),null}}function C(i,Y){if(i&&i.type==="datetime"&&I.has(i.op))return R(i,Y);const o=G(i,Y),d=i&&i.type;return d!=="date"&&d!=="dateString"?o:O=>o(typeof O=="string"&&u.test(O)?O:q(O)??O)}const I=new Set(["eq","ne","lt","lte","gt","gte","between","notBetween","in","notIn"]),M=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3})\d*)?)?)?$/,X=new Map;function z(i,Y){let o=X.get(Y);if(o===void 0){try{o=new Intl.DateTimeFormat("en-CA",{timeZone:Y,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch{o=null}X.set(Y,o)}if(!o)return null;const d={};for(const O of o.formatToParts(i))O.type!=="literal"&&(d[O.type]=O.value);return d}function ne(i,Y){if(i==null||i==="")return null;if(typeof i=="string"){const F=M.exec(i.trim());if(F)return Date.UTC(+F[1],+F[2]-1,+F[3],+(F[4]||0),+(F[5]||0),+(F[6]||0),+(F[7]||"0").padEnd(3,"0"))}const o=E(i);if(!o)return null;const d=o.getUTCMilliseconds(),O=Y?z(o,Y):null;return O?Date.UTC(+O.year,+O.month-1,+O.day,O.hour==="24"?0:+O.hour,+O.minute,+O.second,d):Date.UTC(o.getFullYear(),o.getMonth(),o.getDate(),o.getHours(),o.getMinutes(),o.getSeconds(),d)}function R(i,Y){const o=typeof i.timeZone=="string"&&i.timeZone?i.timeZone:void 0,d=U=>ne(U,o),O=Array.isArray(i.value)?i.value.map(d):d(i.value),F=G({...i,type:"number",value:O},Y);return U=>F(ne(U))}function G(i,Y){const o=i&&i.op,d=!!(i&&i.caseSensitive),O=i&&i.type,F=N(Y),U=ee=>L=>!ee(L);switch(o){case"eq":{const ee=v(i.value,O);return L=>re(L,ee,d)}case"ne":{const ee=v(i.value,O);return L=>!re(L,ee,d)}case"lt":case"lte":case"gt":case"gte":{const ee=v(i.value,O);if(r(ee))return()=>!1;const L=o==="lt"?-1:o==="lte"?0:o==="gt"?1:2;return Z=>{if(r(Z))return!1;const xe=F(Z,ee);return L===-1?xe<0:L===0?xe<=0:L===1?xe>0:xe>=0}}case"between":case"notBetween":{const ee=ie(i.value),L=v(ee[0],O),Z=v(ee[1],O),xe=i.bounds||"[]",g=xe.charAt(0)!=="(",A=xe.charAt(1)!==")";if(r(L)||r(Z))return o==="between"?()=>!1:()=>!0;const K=ae=>{if(r(ae))return!1;const ye=F(ae,L),ke=F(ae,Z);return(g?ye>=0:ye>0)&&(A?ke<=0:ke<0)};return o==="between"?K:U(K)}case"in":case"notIn":{const ee=se(i.value,d,O),L=Z=>ee.has(J(Z,d));return o==="in"?L:U(L)}case"contains":case"notContains":{const ee=W(v(i.value,O),d),L=Z=>Z==null?!1:W(Z,d).includes(ee);return o==="contains"?L:U(L)}case"startsWith":{const ee=W(v(i.value,O),d);return L=>L==null?!1:W(L,d).startsWith(ee)}case"endsWith":{const ee=W(v(i.value,O),d);return L=>L==null?!1:W(L,d).endsWith(ee)}case"matches":{const ee=b(i.value,d);return ee?L=>L==null?!1:ee.test(String(L)):()=>!1}case"blank":case"notBlank":{const ee=i.trim===!0,L=Z=>H(Z)||Array.isArray(Z)&&Z.length===0||ee&&typeof Z=="string"&&Z.trim()==="";return o==="blank"?L:Z=>!L(Z)}case"containsAny":case"containsNone":{const ee=se(i.value,d,O),L=Z=>{const xe=Z==null?[]:ie(Z);for(let g=0;g<xe.length;g++)if(ee.has(J(xe[g],d)))return!0;return!1};return o==="containsAny"?L:U(L)}case"containsAll":{const ee=ie(i.value).map(L=>J(v(L,O),d));return L=>{const Z=L==null?[]:ie(L);if(ee.length===0)return!0;const xe=new Set(Z.map(g=>J(g,d)));for(let g=0;g<ee.length;g++)if(!xe.has(ee[g]))return!1;return!0}}default:{const ee=we(o);return ee?ee.compile(i.value):(n(`op:${String(o)}`,`unknown filter operator "${String(o)}"; the condition is refused rather than matching every row`),()=>!1)}}}function T(i,Y,o){return C(Y,o)(i)}const e=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),s=new Set(["containsAny","containsAll","containsNone"]);function a(i,Y,o){const d=i&&i.op,O=e[d]||d,F=C({...i,op:O,type:Y.type},o),U=Y.items,ee=L=>{const Z=U(L);if(!Z)return!1;for(let xe=0;xe<Z.length;xe++)if(F(Z[xe]))return!0;return!1};return e[d]?L=>!ee(L):ee}function _(i,Y,o,d,O){const F=O?null:P(i);if(F){const L=Y?1:0;for(let Z=0;Z<d;Z++)o[Z]=F(Z)===L?1:0;return o}const U=i.kind;if(U==="float64"||U==="int32"||U==="bitset")return m(o,d,Y?1:0);const ee=p(i);for(let L=0;L<d;L++){const Z=ee(L),xe=H(Z)||Array.isArray(Z)&&Z.length===0||O&&typeof Z=="string"&&Z.trim()==="";o[L]=xe===Y?0:1}return o}function $(i,Y,o,d){const O=i.dict,F=S(O),U=new Uint8Array(F);for(let xe=0;xe<F;xe++)U[xe]=Y(y(O,xe))?1:0;const ee=i.values,L=P(i);if(!L){for(let xe=0;xe<d;xe++)o[xe]=U[ee[xe]];return o}const Z=Y(null)?1:0;for(let xe=0;xe<d;xe++)o[xe]=L(xe)===1?U[ee[xe]]:Z;return o}function Q(i,Y,o,d){const O=f(i.values),F=Y(!0)?1:0,U=Y(!1)?1:0,ee=P(i);if(!ee){for(let Z=0;Z<d;Z++)o[Z]=O(Z)===1?F:U;return o}const L=Y(null)?1:0;for(let Z=0;Z<d;Z++)o[Z]=ee(Z)===0?L:O(Z)===1?F:U;return o}function ve(i,Y,o,d,O){const F=i.values,U=Y.type,ee=Y.op;let L=!0;switch(ee){case"eq":case"ne":{const xe=x(v(Y.value,U)),g=typeof Y.value=="number"&&Number.isNaN(Y.value),A=ee==="ne"?1:0;if(g)for(let K=0;K<O;K++)d[K]=(Number.isNaN(F[K])?1:0)^A;else for(let K=0;K<O;K++)d[K]=(F[K]===xe?1:0)^A;break}case"lt":{const xe=x(v(Y.value,U));for(let g=0;g<O;g++)d[g]=F[g]<xe?1:0;break}case"lte":{const xe=x(v(Y.value,U));for(let g=0;g<O;g++)d[g]=F[g]<=xe?1:0;break}case"gt":{const xe=x(v(Y.value,U));for(let g=0;g<O;g++)d[g]=F[g]>xe?1:0;break}case"gte":{const xe=x(v(Y.value,U));for(let g=0;g<O;g++)d[g]=F[g]>=xe?1:0;break}case"between":case"notBetween":{const xe=ie(Y.value),g=x(v(xe[0],U)),A=x(v(xe[1],U)),K=Y.bounds||"[]",ae=K.charAt(0)!=="(",ye=K.charAt(1)!==")",ke=ee==="notBetween"?1:0;if(ae&&ye)for(let Te=0;Te<O;Te++)d[Te]=(F[Te]>=g&F[Te]<=A?1:0)^ke;else if(ae)for(let Te=0;Te<O;Te++)d[Te]=(F[Te]>=g&F[Te]<A?1:0)^ke;else if(ye)for(let Te=0;Te<O;Te++)d[Te]=(F[Te]>g&F[Te]<=A?1:0)^ke;else for(let Te=0;Te<O;Te++)d[Te]=(F[Te]>g&F[Te]<A?1:0)^ke;break}case"in":case"notIn":{const xe=new Set;for(const A of ie(Y.value)){const K=x(v(A,U));Number.isNaN(K)||xe.add(K)}const g=ee==="notIn"?1:0;for(let A=0;A<O;A++)d[A]=(xe.has(F[A])?1:0)^g;break}default:L=!1;break}if(!L)return!1;const Z=P(i);if(Z){const xe=o(null)?1:0;for(let g=0;g<O;g++)Z(g)===0&&(d[g]=xe)}return!0}function ge(i,Y,o,d){const O=p(i);for(let F=0;F<d;F++)o[F]=Y(O(F))?1:0;return o}function Se(i,Y,o){const d=Y.count|0,O=o||c(Y,d);if(!i)return m(O,d,1);const F=typeof Y.handle=="function"?Y.handle(i.col):void 0,U=typeof Y.custom=="function"?Y.custom:null;if(!F){if(U){for(let xe=0;xe<d;xe++)O[xe]=U(i,xe)?1:0;return O}return n(`filter:col:${String(i.col)}`,`filter references unknown column "${String(i.col)}"; the condition is refused rather than matching every row`),m(O,d,0)}const ee=i.op;if(ee==="blank"||ee==="notBlank")return _(F,ee==="notBlank",O,d,i.trim===!0);const L=typeof Y.itemwise=="function"?Y.itemwise(i.col):null;if(L&&!we(ee)&&!s.has(ee))return ge(F,a(i,L,Y.locale),O,d);const Z=C(i,Y.locale);switch(F.kind){case"dictionary":return $(F,Z,O,d);case"bitset":return Q(F,Z,O,d);case"float64":case"int32":return ve(F,i,Z,O,d)?O:ge(F,Z,O,d);default:return ge(F,Z,O,d)}}function Ne(i,Y,o){if(!i)return m(c(Y,o),o,1);if(Array.isArray(i.conditions)){const d=i.conditions.filter(U=>U!=null),O=i.op==="or"?"or":i.op==="not"?"not":"and";if(d.length===0)return m(c(Y,o),o,1);const F=Ne(d[0],Y,o);for(let U=1;U<d.length;U++){const ee=Ne(d[U],Y,o);if(O==="or")for(let L=0;L<o;L++)F[L]|=ee[L];else for(let L=0;L<o;L++)F[L]&=ee[L];k(Y,ee)}if(O==="not")for(let U=0;U<o;U++)F[U]^=1;return F}return Se(i,Y,c(Y,o))}function Le(i,Y){return Ne(i,Y,Y.count|0)}function j(i,Y){if(!i||!Y)return i||null;const o=i;if(Array.isArray(o.conditions)){if((o.op==="or"?"or":o.op==="not"?"not":"and")!=="and")return pe(o,Y)?null:i;const O=[];for(const F of o.conditions){const U=j(F,Y);U&&O.push(U)}return O.length?{...o,op:"and",conditions:O}:null}return o.col===Y?null:i}function pe(i,Y){if(!i||typeof i!="object")return!1;const o=i;if(o.col===Y)return!0;if(Array.isArray(o.conditions)){for(const d of o.conditions)if(pe(d,Y))return!0}return!1}function he(i,Y,o){if(o&&o.length>=Y){let U=0;for(let ee=0;ee<Y;ee++)i[ee]&&(o[U++]=ee);return o.subarray(0,U)}let d=0;for(let U=0;U<Y;U++)d+=i[U]?1:0;const O=new Uint32Array(d);let F=0;for(let U=0;U<Y;U++)i[U]&&(O[F++]=U);return O}const oe=new Map;function fe(i){if(!(!i||typeof i!="object"))for(const[Y,o]of Object.entries(i))o&&typeof o.compile=="function"&&oe.set(Y,o)}function we(i){return typeof i=="string"?oe.get(i):void 0}}),qe("packages/modules/charts/viewport-filter.js",function(t,ce){"use strict";Object.defineProperty(t,"VIEWPORT_FILTER_DEBOUNCE_MS",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(t,"resolveViewportFilter",{enumerable:!0,get:function(){return te}}),Object.defineProperty(t,"viewportTarget",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"viewportBbox",{enumerable:!0,get:function(){return V}}),Object.defineProperty(t,"sameBbox",{enumerable:!0,get:function(){return E}}),Object.defineProperty(t,"findColumnCondition",{enumerable:!0,get:function(){return q}}),Object.defineProperty(t,"viewportCondition",{enumerable:!0,get:function(){return B}}),Object.defineProperty(t,"conditionBbox",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"pruneTarget",{enumerable:!0,get:function(){return y}}),Object.defineProperty(t,"mergeViewportCondition",{enumerable:!0,get:function(){return P}}),Object.defineProperty(t,"adoptedGeoView",{enumerable:!0,get:function(){return N}});const H=ce("packages/core/src/compute/filter.js").pruneColumn,ue=150,ie=1e-6;function te(p){const u={enabled:!1,column:null,debounce:ue};if(p==null||p===!1)return u;const h=p===!0?{}:p;if(typeof h!="object")return u;const c=typeof h.column=="string"&&h.column?h.column:null,k=Number.isFinite(h.debounce)&&h.debounce>=0?Number(h.debounce):ue;return{enabled:!0,column:c,debounce:k}}function n(p,u){return typeof u=="string"&&u?{kind:"geometry",column:u}:p&&typeof p.geometry=="string"&&p.geometry?{kind:"geometry",column:p.geometry}:p&&typeof p.lon=="string"&&p.lon&&typeof p.lat=="string"&&p.lat?{kind:"lonlat",lon:p.lon,lat:p.lat}:null}function V(p,u){if(!p||!u||typeof p.xScale?.invert!="function"||typeof p.yScale?.invert!="function")return null;const h=p.xScale.invert(u.left),c=p.xScale.invert(u.right),k=p.yScale.invert(u.bottom),m=p.yScale.invert(u.top);if(![h,c,k,m].every(Number.isFinite))return null;const r=Math.max(-180,Math.min(h,c)),v=Math.min(180,Math.max(h,c)),l=Math.max(-90,Math.min(k,m)),x=Math.min(90,Math.max(k,m));return!(v>r)||!(x>l)?null:[r,l,v,x]}function E(p,u){return!p||!u?!p&&!u:Math.abs(p[0]-u[0])<=ie&&Math.abs(p[1]-u[1])<=ie&&Math.abs(p[2]-u[2])<=ie&&Math.abs(p[3]-u[3])<=ie}function q(p,u){if(!p)return null;if(Array.isArray(p.conditions)){for(const h of p.conditions){const c=q(h,u);if(c)return c}return null}return p.col===u?p:null}function B(p,u,h){const[c,k,m,r]=u,v=h?{meta:{label:h}}:{};return p.kind==="geometry"?{col:p.column,op:"withinBbox",value:[c,k,m,r],...v}:{op:"and",conditions:[{col:p.lon,op:"between",value:[c,m]},{col:p.lat,op:"between",value:[k,r]}],...v}}function f(p,u){if(!p||!u)return null;if(u.kind==="geometry"){const l=q(p,u.column);if(!l||l.op!=="withinBbox"||!Array.isArray(l.value)||l.value.length<4)return null;const x=l.value.map(Number);return x.every(Number.isFinite)?x:null}const h=q(p,u.lon),c=q(p,u.lat);if(!h||h.op!=="between"||!Array.isArray(h.value)||h.value.length<2||!c||c.op!=="between"||!Array.isArray(c.value)||c.value.length<2)return null;const[k,m]=h.value.map(Number),[r,v]=c.value.map(Number);return[k,r,m,v].every(Number.isFinite)?[k,r,m,v]:null}function S(p){return p.kind==="geometry"?[p.column]:[p.lon,p.lat]}function y(p,u){let h=p||null;for(const c of S(u))h=H(h,c);return h}function P(p,u,h){const c=y(p,u);return c?{op:"and",conditions:[...c.conditions||[c],h]}:h}function N(p,u,h,c){if(!p||!u||!h||!c||!(c.scale>0))return null;const[k,m,r,v]=p,[l,x,W,J]=u,se=r-k,re=v-m,b=W-l,C=J-x;if(!(se>0)||!(re>0)||!(b>0)||!(C>0))return null;const I=(l+W)/2,M=(x+J)/2,X=h.left+(I-k)/se*(h.right-h.left),z=h.bottom-(M-m)/re*(h.bottom-h.top);if(!Number.isFinite(X)||!Number.isFinite(z))return null;const ne=(h.left+h.right)/2,R=(h.top+h.bottom)/2,G=ne-X,T=R-z,[e,s]=c.offset,a=[e-G/c.scale,s+T/c.scale],_=Math.min(se/b,re/C);return!Number.isFinite(_)||_<=0?null:{zoom:Math.min(8,Math.max(1,c.zoom*_)),offset:a}}}),qe("packages/modules/charts/mapview.js",function(t,ce){"use strict";Object.defineProperty(t,"MAP_ENGINE_TYPES",{enumerable:!0,get:function(){return P}}),Object.defineProperty(t,"DEFAULT_VIEWPORT_CAP",{enumerable:!0,get:function(){return N}}),Object.defineProperty(t,"DENSITY_CELLS_ACROSS",{enumerable:!0,get:function(){return p}}),Object.defineProperty(t,"DENSITY_FIT_PASSES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(t,"FRAME_REFIT_RATIO",{enumerable:!0,get:function(){return h}}),Object.defineProperty(t,"viewportCap",{enumerable:!0,get:function(){return m}}),Object.defineProperty(t,"densityCellSize",{enumerable:!0,get:function(){return r}}),Object.defineProperty(t,"boxSpan",{enumerable:!0,get:function(){return v}}),Object.defineProperty(t,"ringsBox",{enumerable:!0,get:function(){return l}}),Object.defineProperty(t,"needsRefit",{enumerable:!0,get:function(){return x}}),Object.defineProperty(t,"frameMoved",{enumerable:!0,get:function(){return W}}),Object.defineProperty(t,"planMapViewport",{enumerable:!0,get:function(){return se}}),Object.defineProperty(t,"engineRowsReader",{enumerable:!0,get:function(){return re}}),Object.defineProperty(t,"frameOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(t,"capClientBound",{enumerable:!0,get:function(){return I}});const H=ce("packages/core/src/internal/warn.js").warnOnce,ue=ce("packages/modules/shared/engine.js"),ie=ue.engineSource,te=ue.gridEngineRequest,n=ue.loadedAndMatching,V=ue.sourceId,q=ce("packages/modules/charts/engine.js").aggregateMode,B=ce("packages/modules/charts/viewport-filter.js"),f=B.conditionBbox,S=B.viewportCondition,y=B.viewportTarget,P=Object.freeze(new Set(["markermap","bubblemap","choropleth"])),N=2e4,p=24,u=8,h=2,c="__viewport_rows",k=/^[A-Za-z_][A-Za-z0-9_$]*$/;function m(M){const X=M?M.viewportCap:void 0;return X==null?N:typeof X=="number"&&Number.isInteger(X)&&X>0?X:(H(`chart:viewportCap:${String(X)}`,`chart viewportCap ${JSON.stringify(X)} is not a positive whole number of rows; the map used ${N}.`),N)}function r(M){const X=Number.isFinite(M)&&M>0?Math.min(360,M):360,z=2**Math.floor(Math.log2(X/p));return Math.min(90,Math.max(2**-20,z))}function v(M){return Math.max(M[2]-M[0],M[3]-M[1])}function l(M){let X=1/0,z=1/0,ne=-1/0,R=-1/0;for(const G of M||[])for(const[T,e]of G)!Number.isFinite(T)||!Number.isFinite(e)||(X=Math.min(X,T),ne=Math.max(ne,T),z=Math.min(z,e),R=Math.max(R,e));return ne>=X&&R>=z?[X,z,ne,R]:null}function x(M,X){if(!M||!X)return!1;for(const[z,ne]of[[0,2],[1,3]]){const R=M[ne]-M[z],G=X[ne]-X[z];if(!(R>0)||!(G>0))continue;const T=R/G;if(T>h||T<1/h)return!0}return!1}function W(M,X){if(!M||!X)return!!X;const z=1e-9;return!(X[0]>=M[0]-z&&X[1]>=M[1]-z&&X[2]<=M[2]+z&&X[3]<=M[3]+z)||x(M,X)}function J(M,X,z){const ne=M.columns.get(X);if(!ne)return`the ${z} column "${X}" is not a column of the grid`;const R=ne.value&&typeof ne.value=="object"?ne.value:null;return ne.computed||R&&(typeof R.get=="function"||typeof R.compute=="function")?`the ${z} column "${X}" is computed by the grid, which the engine cannot reproduce`:(typeof ne.field=="string"?ne.field:X)!==X||!k.test(X)?`the ${z} column "${X}" is not a plain physical column the engine can name`:""}function se(M,X,z,ne){const R=q(X),G=F=>({mode:"client",asked:R,reason:F,refused:R==="engine"});if(R==="client")return{...G("aggregate: 'client' was asked for"),refused:!1};if(!P.has(z))return G(`a "${z}" chart does not draw a viewport`);if(X.rows)return G("the chart was handed its own rows");const T=y(X);if(!T)return G("the map names neither a geometry column nor lon/lat columns");if(T.kind==="geometry"&&(X.lon||X.lat))return G("the map names both a geometry column and lon/lat columns");const e=T.kind==="geometry"?[T.column]:[T.lon,T.lat];for(const F of e){const U=J(M,F,"placement");if(U)return G(U)}const s=ie(M);if("reason"in s)return G(s.reason);const{source:a,caps:_}=s,$=a.adapter;if(!$||typeof $.execute!="function")return G("the source's adapter has no execute() to fetch rows with");const Q=e[0],ve=a.resolveAggregatePlan([{id:c,col:Q,fn:"count"}]);if(ve.client.length)return G(`the source computes "count" client-side (${ve.client[0].reason}); set the pushdown source's \`aggregates: { default: 'engine' }\` to count in the engine`);const ge=Array.isArray(ne&&ne.bbox)?ne.bbox:null,Se=ge?S(T,ge):null,Ne=te(M,s,Se);if("reason"in Ne)return G(Ne.reason);if(R==="auto"){const{loaded:F,total:U}=n(M);if(Number.isFinite(U)&&F>=U)return G("the grid holds every matching row")}const Le=m(X),j=ge||f(M.filters&&typeof M.filters.get=="function"?M.filters.get():null,T),pe=j?r(v(j)):null,he=T.kind==="geometry"&&z!=="choropleth"&&Array.isArray(_.buckets)&&_.buckets.includes("grid")&&typeof $.executeGroupedAggregates=="function",oe=z==="choropleth"?"a choropleth draws each shape, and has no density form":T.kind!=="geometry"?"the engine bins a geometry column, and this map places its rows by lon/lat":"the source's adapter cannot bin a geometry column into grid cells (no `buckets` capability)",{request:fe,quick:we}=Ne,i=te(M,s),Y=JSON.stringify([V(a),"request"in i?i.request.filters:null,we]),o=JSON.stringify([V(a),fe.filters,we,T,Le,z]),d=JSON.stringify([o,he?pe||"fit":0]);return{mode:"engine",asked:R,key:d,rowsKey:o,baseKey:Y,cap:Le,bbox:ge,box:j,cellSize:pe,run:async F=>{const U=F?{signal:F}:{},ee=await a.aggregate({...fe,...U},[{id:c,col:Q,fn:"count"}]);if(ee&&Array.isArray(ee.client)&&ee.client.length)return{map:!0,refused:`the source counted client-side (${ee.client[0].reason})`};const L=Number(ee&&ee.values?ee.values[c]:NaN);if(!Number.isFinite(L))return{map:!0,refused:"the engine did not report a count for the view"};if(L<=Le){const g={...fe,range:{start:0,end:Le}},A=a.planQuery(g,_).pushed,K=await $.execute({...A,...U},{...g,...U});return{map:!0,kind:"rows",rows:(K&&Array.isArray(K.rows)?K.rows:[]).slice(0,Le),count:L,cap:Le,bbox:ge,rowsKey:o}}if(!he)return{map:!0,kind:"over",count:L,cap:Le,bbox:ge,reason:oe};let Z=pe||r(360),xe=[];for(let g=1;;g++){const A=await a.aggregate({...fe,groupBy:[{col:T.column,bucket:"grid",size:Z}],...U},[{id:c,col:Q,fn:"count"}]);if(A&&Array.isArray(A.client)&&A.client.length)return{map:!0,kind:"over",count:L,cap:Le,bbox:ge,reason:`the source binned client-side (${A.client[0].reason})`};xe=[];for(const ye of A&&A.groups||[]){if(!ye||ye.level!==1||!Array.isArray(ye.keys)||!Array.isArray(ye.keys[0]))continue;const[ke,Te]=ye.keys[0].map(Number),ze=Number(ye.values?ye.values[c]:NaN);!Number.isFinite(ke)||!Number.isFinite(Te)||!(ze>0)||xe.push({west:ke*Z,south:Te*Z,east:(ke+1)*Z,north:(Te+1)*Z,count:ze})}if(pe||g>=u)break;const K=l(b([],xe));if(!K)break;const ae=r(v(K));if(ae>=Z)break;Z=ae}return{map:!0,kind:"density",cells:xe,count:L,cap:Le,bbox:ge,size:Z}}}}function re(M,X){const z=typeof M.config=="function"?M.config():{},ne=z&&typeof z.rowKey=="string"?z.rowKey:null,R=M.permissions&&typeof M.permissions.levelOf=="function"?M.permissions:null,G=new Map,T=X.map((a,_)=>{const $=ne&&a&&a[ne]!==void 0&&a[ne]!==null?a[ne]:`engine:${_}`,Q=G.has($)?`engine:${_}`:$,ve={key:Q,data:a,group:!1};return G.set(Q,ve),ve}),e=a=>{if(!R)return!0;const _=R.levelOf(a);return _==="read"||_==="write"},s=(a,_)=>{const $=G.get(a);if(!$||!e(_))return;const Q=M.columns.get(_),ve=Q&&typeof Q.field=="string"?Q.field:_,ge=$.data?$.data[ve]:void 0,Se=Q&&Q.dataType;if(Se&&typeof Se.toStorage=="function"&&ge!==null&&ge!==void 0)try{return Se.toStorage(ge,{colId:_})}catch{return null}return ge};return{columns:M.columns,formatting:M.formatting,messages:M.messages,rows:{count:()=>T.length,get:a=>T[a],value:s,text:(a,_)=>{const $=s(a,_);if($==null)return"";const Q=M.columns.get(_);if(Q&&typeof Q.formatValue=="function")try{const ve=Q.formatValue($,G.get(a));if(typeof ve=="string")return ve}catch{}return String($)}}}}function b(M,X=[]){let z=1/0,ne=1/0,R=-1/0,G=-1/0;for(const $ of M||[])!Number.isFinite($.lon)||!Number.isFinite($.lat)||(z=Math.min(z,$.lon),R=Math.max(R,$.lon),ne=Math.min(ne,$.lat),G=Math.max(G,$.lat));for(const $ of X||[])z=Math.min(z,$.west),R=Math.max(R,$.east),ne=Math.min(ne,$.south),G=Math.max(G,$.north);if(!(R>=z)||!(G>=ne))return null;const T=($,Q)=>Math.max(-Q,Math.min(Q,$)),e=T(z,180),s=T(R,180),a=T(ne,90),_=T(G,90);return[[[e,a],[s,a],[s,_],[e,_]]]}function C(M,X){if(!X)return!0;const[z,ne,R,G]=X,T=(e,s)=>e>=z&&e<=R&&s>=ne&&s<=G;if(M.point)return T(M.point[0],M.point[1]);for(const e of M.polygons||[])for(const s of e)for(const[a,_]of s)if(T(a,_))return!0;return!1}function I(M,X,z,ne){const R=m(z),G=ne&&Array.isArray(ne.bbox)?ne.bbox:null;if(!X||!P.has(M))return{bound:X,viewport:null};if(M==="choropleth"){const Ne=X.features||[];if(Ne.length<=R)return{bound:X,viewport:null};let Le=0;for(const he of Ne)C(he,G)&&Le++;if(Le<=R)return{bound:X,viewport:null};const j=[];for(const he of Ne){he.point&&j.push({lon:he.point[0],lat:he.point[1]});for(const oe of he.polygons||[])for(const fe of oe)for(const[we,i]of fe)j.push({lon:we,lat:i})}const pe="a choropleth draws each shape, and has no density form";return{bound:{...X,features:[],empty:!1,over:{count:Le,cap:R,reason:pe},frame:X.frame||b(j)},viewport:{rows:0,matched:Le,cap:R,binned:!1,cells:0,over:pe,bbox:G?[...G]:null,computed:"client"}}}const T=X.points||[];if(T.length<=R)return{bound:X,viewport:null};const[e,s,a,_]=G||[-1/0,-1/0,1/0,1/0],$=T.filter(Ne=>Ne.lon>=e&&Ne.lon<=a&&Ne.lat>=s&&Ne.lat<=_);if($.length<=R)return{bound:X,viewport:null};const Q=G||l([$.map(Ne=>[Ne.lon,Ne.lat])]),ve=r(Q?v(Q):360),ge=new Map;for(const Ne of $){const Le=Math.floor(Ne.lon/ve),j=Math.floor(Ne.lat/ve),pe=`${Le}:${j}`,he=ge.get(pe)||{west:Le*ve,south:j*ve,east:(Le+1)*ve,north:(j+1)*ve,count:0};he.count++,ge.set(pe,he)}const Se=[...ge.values()];return{bound:{...X,density:{cells:Se,size:ve},frame:X.frame||b(T)},viewport:{rows:0,matched:$.length,cap:R,binned:!0,cells:Se.length,over:null,bbox:G?[...G]:null,computed:"client"}}}}),qe("packages/modules/shared/map-binding.js",function(t,ce){"use strict";Object.defineProperty(t,"clampBox",{enumerable:!0,get:function(){return u}}),Object.defineProperty(t,"resolvePosition",{enumerable:!0,get:function(){return h}}),Object.defineProperty(t,"createMapFeed",{enumerable:!0,get:function(){return c}}),Object.defineProperty(t,"createViewportSync",{enumerable:!0,get:function(){return k}});const H=ce("packages/modules/geometry/geodata.js").readGeometry,ie=ce("packages/modules/shared/engine.js").EngineFlight,te=ce("packages/modules/charts/mapview.js"),n=te.planMapViewport,V=te.engineRowsReader,E=te.viewportCap,q=ce("packages/modules/charts/viewport-filter.js"),B=q.resolveViewportFilter,f=q.viewportTarget,S=q.viewportCondition,y=q.mergeViewportCondition,P=q.conditionBbox,N=q.pruneTarget,p=q.sameBbox;function u(m){if(!Array.isArray(m)||m.length<4)return null;const[r,v,l,x]=m.map(Number);if(![r,v,l,x].every(Number.isFinite))return null;const W=Math.max(-180,Math.min(r,l)),J=Math.min(180,Math.max(r,l)),se=Math.max(-90,Math.min(v,x)),re=Math.min(90,Math.max(v,x));return!(J>W)||!(re>se)?null:[W,se,J,re]}function h(m,r){const v=J=>typeof J=="string"&&J!==""&&!!(m.columns&&m.columns.get(J));if(!r||typeof r!="object")return"options.position is missing; pass { lon, lat } or { geometry } naming the grid's columns";const{lon:l,lat:x,geometry:W}=r;return W!==void 0?v(W)?{geometry:W}:`options.position.geometry ${JSON.stringify(W)} is not a column of the grid`:l!==void 0||x!==void 0?v(l)?v(x)?{lon:l,lat:x}:`options.position.lat ${JSON.stringify(x)} is not a column of the grid`:`options.position.lon ${JSON.stringify(l)} is not a column of the grid`:"options.position names neither { lon, lat } nor { geometry }"}function c(m,r,v={}){const l={...r,...v.viewportCap!==void 0?{viewportCap:v.viewportCap}:{}},x=v.ids===!0,W=typeof v.onAnswer=="function"?v.onAnswer:()=>{},J=v.leaves===!0,se=typeof v.readPlace=="function"?v.readPlace:null,re=new ie,b=M=>{const X=[],z=[],ne=M.rows.count();for(let R=0;R<ne;R++){const G=M.rows.get(R);if(!G||G.group||G.data===null||G.data===void 0)continue;let T=null;if(r.geometry){const e=M.rows.value(G.key,r.geometry);T=se?se(e):H(e).geometry}else{const e=M.rows.value(G.key,r.lon),s=M.rows.value(G.key,r.lat),a=Q=>Q==null||Q==="",_=Number(e),$=Number(s);T=!a(e)&&!a(s)&&Number.isFinite(_)&&Number.isFinite($)?{type:"Point",coordinates:[_,$]}:null}T&&(X.push(x?{type:"Feature",id:G.key,geometry:T,properties:G.data}:{type:"Feature",geometry:T,properties:G.data}),z.push(G.key))}return{features:X,keys:z}},C=()=>{const M=[];m.rows.forEach(z=>{if(z){if(z.group){if(J&&!z.expanded&&typeof m.rows.leavesOf=="function")for(const ne of m.rows.leavesOf(z.key))ne&&!ne.group&&ne.data!==null&&ne.data!==void 0&&M.push(ne);return}z.data!==null&&z.data!==void 0&&M.push(z)}});const X={rows:{count:()=>M.length,get:z=>M[z],value:(z,ne)=>m.rows.value(z,ne)}};return{rows:M.map(z=>z.data),reader:X}};return{spec:l,read:M=>{const X=E(l),z=n(m,l,"markermap",{bbox:M});let ne=[],R={features:[],keys:[]},G=!1,T=!1,e=null,s;if(z.mode==="engine"){const a=re.answer(z.key);a||re.ask(z.key,z.run,W);const _=a||re.last();T=re.busy;const $=_&&!("error"in _)?_.result:null;if($&&$.kind==="rows")ne=$.rows,R=b(V(m,ne)),s={rows:R.features.length,skipped:ne.length-R.features.length,matched:$.count,cap:X,binned:!1,cells:0,over:null,bbox:$.bbox?[...$.bbox]:null,computed:"engine"};else if($&&$.kind==="density")ne=$.cells,G=!0,s={rows:0,skipped:0,matched:$.count,cap:X,binned:!0,cells:ne.length,over:null,bbox:$.bbox?[...$.bbox]:null,computed:"engine"};else if($&&$.kind==="over")e={count:$.count,cap:$.cap,reason:String($.reason)},s={rows:0,skipped:0,matched:$.count,cap:X,binned:!1,cells:0,over:$.reason,bbox:$.bbox?[...$.bbox]:null,computed:"engine"};else{const Q=$&&$.refused?String($.refused):_&&"error"in _?String(_.error?.message||_.error):null;s={rows:0,skipped:0,matched:0,cap:X,binned:!1,cells:0,over:Q,bbox:M?[...M]:null,computed:"engine"}}}else{const a=C();ne=a.rows,R=b(a.reader),s={rows:R.features.length,skipped:ne.length-R.features.length,matched:ne.length,cap:X,binned:!1,cells:0,over:null,bbox:M?[...M]:null,computed:"client"}}return{rows:ne,features:R.features,keys:R.keys,binned:G,pending:T,provenance:s,over:e}},close:()=>re.close()}}function k(m,r,v){const l=B(v),x=f(r,null);let W=null;return{settings:l,target:x,incoming(){if(!l.enabled||!x)return null;const J=P(m.filters.get(),x);return J?p(J,W)?null:(W=J,J):(W=null,null)},write(J){if(!x||!J||p(J,W))return!1;const se=m.messages&&typeof m.messages.t=="function"?m.messages.t("chart.viewportFilter.label"):void 0,re=y(m.filters.get(),x,S(x,J,se));return W=J,m.filters.set(re),!0},release(){if(W&&x){const J=m.filters.get(),se=N(J,x);se!==J&&m.filters.set(se)}W=null}}}}),qe("packages/modules/charts/rampscale.js",function(t,ce){"use strict";Object.defineProperty(t,"AUTO_LOG_RATIO",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(t,"QUANTILE_CLASSES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(t,"chooseRampScale",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(t,"logTicks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"quantileCuts",{enumerable:!0,get:function(){return V}}),Object.defineProperty(t,"placeOnRamp",{enumerable:!0,get:function(){return E}});const _e=100,H=5;function ue(q){const B=[];for(const f of q||[])typeof f=="number"&&Number.isFinite(f)&&f>0&&B.push(f);return B}function ie(q,B){const f=ue(q);let S=1/0,y=0;for(const N of f)N<S&&(S=N),N>y&&(y=N);const P=f.length?y/S:0;return B?{scale:B,auto:!1,ratio:P}:P>_e?{scale:"log",auto:!0,ratio:P}:{scale:"linear",auto:!1,ratio:P}}function te(q){return Number(q.toPrecision(12))}function n(q,B){if(!(q>0)||!(B>=q)||!Number.isFinite(B))return[];const f=p=>p>=q*(1-1e-9)&&p<=B*(1+1e-9),S=Math.floor(Math.log10(q)+1e-9),y=Math.floor(Math.log10(B)+1e-9),P=[],N=Math.log10(B/q);for(let p=S;p<=y;p++){const u=N>=2?[1]:[1,2,5];for(const h of u){const c=te(h*10**p);f(c)&&P.push(c)}}return P}function V(q,B=H){const f=[];for(const y of q||[])typeof y=="number"&&Number.isFinite(y)&&f.push(y);if(!f.length)return[];f.sort((y,P)=>y-P);const S=[];for(let y=1;y<B;y++){const P=(f.length-1)*(y/B),N=Math.floor(P),p=Math.min(f.length-1,N+1);S.push(te(f[N]+(P-N)*(f[p]-f[N])))}return S}function E(q,B,f){if(q==="log"){let y=ue(f);y.length||(y=ue([B.min,B.max]));let P=1/0,N=0;for(const c of y)c<P&&(P=c),c>N&&(N=c);y.length||(P=1,N=1);const p=Math.log10(P),u=Math.log10(N)-p||1,h=c=>typeof c!="number"||!Number.isFinite(c)||c<=0?0:Math.min(1,Math.max(0,(Math.log10(c)-p)/u));return{position:h,domain:{min:P,max:N},ticks:n(P,N).map(c=>({value:c,t:h(c)})),classes:0}}if(q==="quantile"){const y=V(f),P=y.length+1;let N=1/0,p=-1/0;for(const h of f||[])typeof h!="number"||!Number.isFinite(h)||(h<N&&(N=h),h>p&&(p=h));return N>p&&(N=B.min,p=B.max),{position:h=>{if(typeof h!="number"||!Number.isFinite(h))return 0;let c=0;for(;c<y.length&&h>=y[c];)c++;return P>1?c/(P-1):0},domain:{min:N,max:p},ticks:y.map((h,c)=>({value:h,t:(c+1)/P})),classes:P}}const S=B.max-B.min||1;return{position:y=>(y-B.min)/S,domain:{min:B.min,max:B.max},ticks:[],classes:0}}}),qe("packages/modules/mapview/model.js",function(t,ce){"use strict";Object.defineProperty(t,"DEFAULT_BASEMAP",{enumerable:!0,get:function(){return y}}),Object.defineProperty(t,"DEFAULT_DARK_BASEMAP",{enumerable:!0,get:function(){return P}}),Object.defineProperty(t,"BUILDINGS_LAYER",{enumerable:!0,get:function(){return N}}),Object.defineProperty(t,"LAYERS",{enumerable:!0,get:function(){return p}}),Object.defineProperty(t,"ROUTE_ELEVATION",{enumerable:!0,get:function(){return h}}),Object.defineProperty(t,"POINT_ELEVATION",{enumerable:!0,get:function(){return c}}),Object.defineProperty(t,"ROUTE_WIDTH_RANGE",{enumerable:!0,get:function(){return k}}),Object.defineProperty(t,"DASH_PATTERNS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(t,"ROUTE_AGGREGATES",{enumerable:!0,get:function(){return r}}),Object.defineProperty(t,"BADGES",{enumerable:!0,get:function(){return v}}),Object.defineProperty(t,"HIGHLIGHT",{enumerable:!0,get:function(){return l}}),Object.defineProperty(t,"HALO",{enumerable:!0,get:function(){return x}}),Object.defineProperty(t,"FALLBACK_COLOUR",{enumerable:!0,get:function(){return W}}),Object.defineProperty(t,"OVER_BUILDINGS",{enumerable:!0,get:function(){return J}}),Object.defineProperty(t,"resolveGeometry",{enumerable:!0,get:function(){return se}}),Object.defineProperty(t,"readPath",{enumerable:!0,get:function(){return re}}),Object.defineProperty(t,"familyOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(t,"layerFor",{enumerable:!0,get:function(){return C}}),Object.defineProperty(t,"checkLayer",{enumerable:!0,get:function(){return I}}),Object.defineProperty(t,"toDeckColour",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(t,"isBlank",{enumerable:!0,get:function(){return R}}),Object.defineProperty(t,"colourRule",{enumerable:!0,get:function(){return s}}),Object.defineProperty(t,"numberRule",{enumerable:!0,get:function(){return a}}),Object.defineProperty(t,"dashRule",{enumerable:!0,get:function(){return $}}),Object.defineProperty(t,"legendSections",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(t,"resolveIcon",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(t,"iconRule",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(t,"pathTimestamps",{enumerable:!0,get:function(){return j}}),Object.defineProperty(t,"isSelected",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(t,"buildItems",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(t,"drawColour",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(t,"boundsOf",{enumerable:!0,get:function(){return we}}),Object.defineProperty(t,"tooltipColumns",{enumerable:!0,get:function(){return i}}),Object.defineProperty(t,"tooltipLines",{enumerable:!0,get:function(){return Y}});const H=ce("packages/core/src/internal/warn.js").warnOnce,ie=ce("packages/modules/geometry/geodata.js").readGeometry,te=ce("packages/modules/charts/rampscale.js"),n=te.chooseRampScale,V=te.placeOnRamp,E=ce("packages/modules/charts/scheme.js"),q=E.toRgb,B=E.rampStops,f=E.SCHEMES,S=E.PALETTE,y="https://tiles.openfreemap.org/styles/positron",P="https://tiles.openfreemap.org/styles/dark",N="lattice-mapview-buildings",p=Object.freeze(["point","column","polygon","path"]),u=Object.freeze({point:"point",column:"point",polygon:"polygon",path:"path"}),h=2,c=4,k=Object.freeze([2,30]),m=Object.freeze({solid:null,dashed:Object.freeze([10,6]),dotted:Object.freeze([2,5])}),r=Object.freeze(["first","last","min","max"]),v=Object.freeze(["circle","square","diamond"]),l=Object.freeze([255,87,34,255]),x=Object.freeze([255,255,255,180]),W=Object.freeze([0,114,178,220]),J=Object.freeze({depthCompare:"always",depthWriteEnabled:!1});function se(o,d){const O=L=>typeof L=="string"&&L!==""&&!!(o&&o.columns&&o.columns.get(L));if(!d||typeof d!="object")return"options.geometry is missing; pass { lat, lng }, { geojson } or { path } naming the grid's columns";const F=d;if(F.geojson!==void 0){if(!O(F.geojson))return`options.geometry.geojson ${JSON.stringify(F.geojson)} is not a column of the grid`;const L=F.geojson;return{kind:"geojson",position:{geometry:L},columns:[L],readPlace:null,segment:null,route:null}}if(F.path!==void 0){if(!O(F.path))return`options.geometry.path ${JSON.stringify(F.path)} is not a column of the grid`;const L=F.path;return{kind:"path",position:{geometry:L},columns:[L],readPlace:re,segment:null,route:null}}if(F.from!==void 0||F.to!==void 0){const L=F.from&&typeof F.from=="object"?F.from:{},Z=F.to&&typeof F.to=="object"?F.to:{},xe=L.lng!==void 0?L.lng:L.lon,g=Z.lng!==void 0?Z.lng:Z.lon;for(const[A,K]of[["from.lat",L.lat],["from.lng",xe],["to.lat",Z.lat],["to.lng",g]])if(!O(K))return`options.geometry.${A} ${JSON.stringify(K)} is not a column of the grid`;return{kind:"segment",position:{lon:xe,lat:L.lat},columns:[L.lat,xe,Z.lat,g],readPlace:null,segment:{lat:Z.lat,lng:g},route:null}}const U=F.lng!==void 0?F.lng:F.lon,{lat:ee}=F;if(U!==void 0||ee!==void 0){if(!O(ee))return`options.geometry.lat ${JSON.stringify(ee)} is not a column of the grid`;if(!O(U))return`options.geometry.lng ${JSON.stringify(U)} is not a column of the grid`;let L=null;if(F.route!==void 0){const Z=F.route;if(!Z||typeof Z!="object"||!O(Z.by))return`options.geometry.route.by ${JSON.stringify(Z&&typeof Z=="object"?Z.by:Z)} is not a column of the grid`;if(Z.order!==void 0&&Z.order!==null&&!O(Z.order))return`options.geometry.route.order ${JSON.stringify(Z.order)} is not a column of the grid`;Z.aggregate!==void 0&&!r.includes(Z.aggregate)&&H("mapview:route",`createMapView: route.aggregate ${JSON.stringify(Z.aggregate)} is not an aggregate; a route's style is read from its first row. Use ${r.map(xe=>`"${xe}"`).join(", ")}.`),L={by:Z.by,order:typeof Z.order=="string"?Z.order:null,aggregate:r.includes(Z.aggregate)?Z.aggregate:"first"}}return{kind:"point",position:{lon:U,lat:ee},columns:[ee,U,...L&&L.order?[L.order]:[]],readPlace:null,segment:null,route:L}}return"options.geometry names none of { lat, lng }, { from, to }, { geojson } or { path }"}function re(o){let d=o;if(typeof d=="string"){const O=d.trim();if(O==="")return null;if(O[0]==="[")try{d=JSON.parse(O)}catch{return null}else return ie(O).geometry}if(Array.isArray(d)){const O=[];for(const F of d){if(!Array.isArray(F)||F.length<2)return null;const U=Number(F[0]),ee=Number(F[1]);if(!Number.isFinite(U)||!Number.isFinite(ee))return null;O.push([U,ee])}return O.length>=2?{type:"LineString",coordinates:O}:null}return d&&typeof d=="object"?ie(d).geometry:null}function b(o){if(!o||typeof o!="object")return null;switch(o.type){case"Point":case"MultiPoint":return"point";case"LineString":case"MultiLineString":return"path";case"Polygon":case"MultiPolygon":return"polygon";case"GeometryCollection":return Array.isArray(o.geometries)&&o.geometries.length?b(o.geometries[0]):null;default:return null}}function C(o,d){const O=d.layer;return typeof O=="string"&&u[O]===o?O:o==="point"?d.elevation!==void 0&&d.elevation!==null?"column":"point":o}function I(o){return o==null||p.includes(o)?!0:(H(`mapview:layer:${String(o)}`,`createMapView: layer "${String(o)}" is not a layer kind; each row is drawn by the default for its geometry. Use "point", "column", "polygon" or "path".`),!1)}function M(o){return o.type==="Point"?o.coordinates:o.type==="MultiPoint"?o.coordinates[0]||null:o.type==="GeometryCollection"?M(o.geometries[0]):null}function X(o){return o.type==="LineString"?[o.coordinates]:o.type==="MultiLineString"?o.coordinates:o.type==="GeometryCollection"?X(o.geometries[0]):[]}function z(o,d,O){const F=Math.max(0,Math.min(1,Number.isFinite(O)?O:0));return[0,1,2].map(U=>Math.round(o[U]+(d[U]-o[U])*F))}function ne(o,d=230){if(Array.isArray(o)&&o.length>=3&&o.slice(0,3).every(F=>Number.isFinite(Number(F)))){const F=o.slice(0,4).map(Number);return F.length===3&&F.push(d),F}const O=q(o);return O?[...O,d]:null}function R(o){return o==null||o===""}function G(o,d,O,F){let U;try{U=o.rows.value(d,F)}catch{U=void 0}return U===void 0&&O&&typeof O=="object"&&(U=O[F]),U}function T(o,d,O){const F=d.aggregate||"first",U=L=>G(o,d.keys[L],d.rows[L],O);if(F==="first")return U(0);if(F==="last")return U(d.keys.length-1);let ee;for(let L=0;L<d.keys.length;L++){const Z=U(L);if(R(Z))continue;if(ee===void 0){ee=Z;continue}const g=Number.isFinite(Number(Z))&&Number.isFinite(Number(ee))?Number(Z)-Number(ee):String(Z)<String(ee)?-1:String(Z)>String(ee)?1:0;(F==="max"?g>0:g<0)&&(ee=Z)}return ee}function e(o,d,O){return d.isRoute?T(o,d,O):G(o,d.key,d.row,O)}function s(o,d,O,F,U){const ee=F||[...W];if(d==null)return{colourOf:()=>ee,legend:[]};const L=typeof d=="string"||Array.isArray(d)?ne(d):null;if(L)return{colourOf:()=>L,legend:[]};if(typeof d!="object"||typeof d.field!="string")return H("mapview:color","createMapView: color is neither a colour nor { field, map } nor { field, scale: 'ramp' }; every row is drawn in the theme's colour."),{colourOf:()=>ee,legend:[]};const Z=d,{field:xe}=Z;if(Z.scale==="ramp"){const ae=O.map(Fe=>Number(e(o,Fe,xe))).filter(Number.isFinite);let ye=1/0,ke=-1/0;for(const Fe of ae)Fe<ye&&(ye=Fe),Fe>ke&&(ke=Fe);Array.isArray(Z.domain)&&Z.domain.length>=2&&Z.domain.every(Fe=>Number.isFinite(Number(Fe)))&&(ye=Number(Z.domain[0]),ke=Number(Z.domain[1])),ke>=ye||(ye=0,ke=1);const Te=Array.isArray(Z.colours)&&Z.colours.length>=2?{sequential:Z.colours}:U&&U.sequential?{sequential:U.sequential.map(Fe=>`rgb(${Fe[0]} ${Fe[1]} ${Fe[2]})`)}:f.default,ze=B(Te,!1),Ze=n(ae.length?ae:[ye,ke],Z.rampScale||null),He=V(Ze.scale,{min:ye,max:ke},ae.length?ae:[ye,ke]),Ke=Fe=>{const ct=Math.max(0,Math.min(1,Number.isFinite(Fe)?Fe:0))*(ze.length-1),tt=Math.min(ze.length-2,Math.floor(ct));return[...z(ze[tt],ze[tt+1],ct-tt),ee[3]??230]};return{colourOf(Fe){const ct=Number(e(o,Fe,xe));return Number.isFinite(ct)?Ke(He.position(ct)):ee},legend:[{label:String(ye),colour:Ke(0)},{label:String(ke),colour:Ke(1)}],field:xe,categorical:!1}}const g=Z.map&&typeof Z.map=="object"?Z.map:{},A=new Map;for(const[ae,ye]of Object.entries(g)){const ke=ne(ye);ke&&A.set(ae,ke)}let K=0;return{colourOf(ae){const ye=e(o,ae,xe),ke=ye==null?"":String(ye);let Te=A.get(ke);return Te||(Te=(U&&U.series&&U.series.length?[...U.series[K%U.series.length]]:null)||ne(S[K%S.length])||ee,K++,A.set(ke,Te)),Te},get legend(){return[...A].map(([ae,ye])=>({label:ae,colour:ye}))},field:xe,categorical:!0}}function a(o,d,O){return typeof d=="number"&&Number.isFinite(d)?()=>d:typeof d=="string"&&d!==""?F=>{const U=Number(e(o,F,d));return Number.isFinite(U)?U:O}:()=>O}function _(o){if(typeof o=="string")return Object.hasOwn(m,o)?m[o]?[...m[o]]:null:void 0;if(Array.isArray(o)&&o.length>=2){const d=Number(o[0]),O=Number(o[1]);return Number.isFinite(d)&&Number.isFinite(O)&&d>0&&O>0?[d,O]:void 0}}function $(o,d){const O={dashOf:()=>null,legend:[],any:!1};if(d==null||d===!1)return O;const F=L=>H("mapview:dash:spec",`createMapView: dash ${L} is not a line style; the lines are drawn solid. Use "dashed", "dotted", [dash, gap] in pixels, or { field, map } naming one of those per value.`);if(typeof d=="string"||Array.isArray(d)){const L=_(d);return L===void 0?(F(JSON.stringify(d)),O):{dashOf:()=>L,legend:[],any:L!==null}}const U=d;if(typeof U!="object"||typeof U.field!="string"||!U.map||typeof U.map!="object")return F(JSON.stringify(d)),O;const ee=new Map;for(const[L,Z]of Object.entries(U.map)){const xe=_(Z);xe===void 0?F(`${JSON.stringify(Z)} for "${L}"`):ee.set(L,xe)}return{dashOf(L){const Z=e(o,L,U.field);return ee.get(R(Z)?"":String(Z))||null},legend:[...ee].map(([L,Z])=>({label:L,dash:Z})),any:[...ee.values()].some(L=>L!==null),field:U.field}}function Q(o,d,O,F){const U=L=>{if(!L)return"";let Z=null;try{Z=o.columns.get(L)}catch{Z=null}return Z&&Z.title||L},ee=[];if(O.categorical&&F.field&&O.field===F.field&&F.legend.length){const L=new Set;for(const A of d){if(A.layer!=="path")continue;const K=e(o,A,O.field);L.add(R(K)?"":String(K))}const Z=new Map(F.legend.map(A=>[A.label,A.dash])),xe=new Map(O.legend.map(A=>[A.label,A.colour])),g=[...new Set([...xe.keys(),...Z.keys()])];return ee.push({field:O.field,title:U(O.field),merged:!0,entries:g.map(A=>({label:A,colour:xe.get(A)||null,dash:Z.get(A)||null,line:Z.has(A)||L.has(A)}))}),ee}return O.legend.length&&ee.push({field:O.field||null,title:U(O.field),merged:!1,entries:O.legend.map(L=>({label:L.label,colour:L.colour,dash:null,line:!1}))}),F.legend.length&&ee.push({field:F.field||null,title:U(F.field),merged:!1,entries:F.legend.map(L=>({label:L.label,colour:null,dash:L.dash,line:!0}))}),ee}function ve(o){if(typeof o=="string")return{viewBox:"0 0 16 16",paths:[o],paint:"fill"};const d=o||{};return{viewBox:d.viewBox||"0 0 16 16",paths:Array.isArray(d.paths)?d.paths.slice():d.path?[d.path]:[],paint:d.paint==="stroke"?"stroke":"fill"}}function ge(o){return/^[Mm][\s\d.,+-]/.test(o)&&/^[MmLlHhVvCcSsQqTtAaZz\d\s.,+\-eE]+$/.test(o)}function Se(o){return/^(https?:|data:|blob:|\/|\.\.?\/)/i.test(o)||/\.(svg|png|jpe?g|webp|gif)(\?.*)?$/i.test(o)}function Ne(o,d){if(d&&typeof d=="object"){const U=ve(d);return U.paths.length?{kind:"glyph",def:U}:null}if(typeof d!="string"||d.trim()==="")return null;const O=d.trim();let F=null;try{F=o&&o.icons&&typeof o.icons.get=="function"?o.icons.get(O):null}catch{F=null}return F?{kind:"glyph",def:F}:ge(O)?{kind:"glyph",def:ve(O)}:Se(O)?{kind:"url",url:O}:null}function Le(o,d){if(d==null||d===!1)return null;const O=typeof d=="string"?{default:d}:d;if(typeof O!="object")return H("mapview:icon","createMapView: icon is neither an icon name nor { field, map, default, size, anchor }; points are drawn as circles."),null;let F=typeof O.field=="string"&&O.field!==""?O.field:null;F&&!(o.columns&&o.columns.get(F))&&(H("mapview:icon",`createMapView: icon.field ${JSON.stringify(F)} is not a column of the grid; its default icon is used for every point.`),F=null);const U=O.map&&typeof O.map=="object"?O.map:null,ee=xe=>typeof xe=="string"?xe.trim():`object:${JSON.stringify(xe)}`,L=a(o,O.size,24);return{refOf(xe){let g;if(F){const A=e(o,xe,F),K=R(A)?"":String(A);U?g=Object.hasOwn(U,K)?U[K]:O.default:g=R(A)?O.default:A}else g=O.default;return g==null||g===""?null:{key:ee(g),ref:g}},sizeOf:L,anchor:["center","bottom","top","left","right"].includes(O.anchor)?O.anchor:"center",badge:O.badge===!0?"circle":v.includes(O.badge)?O.badge:null}}function j(o){const d=[0];for(let O=1;O<o.length;O++){const F=o[O][0]-o[O-1][0],U=o[O][1]-o[O-1][1];d.push(d[O-1]+Math.hypot(F,U))}return d}function pe(o,d){return o.keys?o.keys.some(O=>d.has(O)):d.has(o.key)}function he(o,d){const O=R(o),F=R(d);if(O||F)return O&&F?0:O?1:-1;const U=Number(o),ee=Number(d);if(Number.isFinite(U)&&Number.isFinite(ee))return U-ee;const L=String(o),Z=String(d);return L<Z?-1:L>Z?1:0}function oe(o,d,O,F,U,ee={}){const L=ee.placement||null,Z=L&&L.route?L.route:null,xe=L&&L.segment?L.segment:null,g=ee.routeCache instanceof Map?ee.routeCache:new Map,A=[];let K=0;const ae=new Map;for(let tt=0;tt<d.features.length;tt++){const pt=d.features[tt],Lt=pt.geometry,jt=b(Lt);if(!jt){K++;continue}const wt=d.keys[tt]!==void 0?d.keys[tt]:pt.id,gt=pt.properties;if(jt==="point"&&xe){const Mt=M(Lt),ft=G(o,wt,gt,xe.lng),ht=G(o,wt,gt,xe.lat),et=R(ft)||R(ht)?null:[Number(ft),Number(ht)];if(!Mt||!et||!Number.isFinite(et[0])||!Number.isFinite(et[1])){K++;continue}const Bt=[Mt,et];A.push({key:wt,row:gt,geometry:{type:"LineString",coordinates:Bt},family:"path",layer:"path",position:null,lines:[Bt],colour:null,elevation:0,radius:0,width:0,dash:null,selected:U.has(wt)});continue}if(jt==="point"&&Z){const Mt=G(o,wt,gt,Z.by);if(!R(Mt)){const ft=M(Lt);if(!ft){K++;continue}const ht=String(Mt);ae.has(ht)||ae.set(ht,[]),ae.get(ht).push({key:wt,row:gt,position:ft,order:Z.order?G(o,wt,gt,Z.order):null,seq:tt});continue}}const mt={key:wt,row:gt,geometry:Lt,family:jt,layer:C(jt,O),position:jt==="point"?M(Lt):null,lines:jt==="path"?X(Lt):null,colour:null,elevation:0,radius:0,width:0,dash:null,selected:U.has(wt)};if(jt==="point"&&!mt.position){K++;continue}A.push(mt)}const ye={drawn:0,skipped:0,rebuilt:0};if(Z){const tt=O.color&&typeof O.color=="object"&&typeof O.color.field=="string"?O.color.field:null,pt=O.dash&&typeof O.dash=="object"&&!Array.isArray(O.dash)&&typeof O.dash.field=="string"?O.dash.field:null,Lt=[...new Set([tt,pt,O.width,O.elevation].filter(wt=>typeof wt=="string"&&wt!==""))],jt=new Set;for(const[wt,gt]of ae){if(gt.length<2){ye.skipped++,K+=gt.length;continue}gt.sort((ht,et)=>he(ht.order,et.order)||ht.seq-et.seq);const mt=gt.map(ht=>`${String(ht.key)}${ht.position[0]},${ht.position[1]}${String(ht.order)}`).join("")+Lt.map(ht=>`${gt.map(et=>String(G(o,et.key,et.row,ht))).join("")}`).join("");jt.add(wt);const Mt=g.get(wt);let ft;if(Mt&&Mt.signature===mt)ft=Mt.item;else{const ht=gt.map(et=>[et.position[0],et.position[1]]);ft={key:gt[0].key,keys:gt.map(et=>et.key),route:wt,isRoute:!0,aggregate:Z.aggregate,geometry:{type:"LineString",coordinates:ht},family:"path",layer:"path",position:null,lines:[ht],colour:null,elevation:0,radius:0,width:0,dash:null},g.set(wt,{signature:mt,item:ft}),ye.rebuilt++}ft.rows=gt.map(ht=>ht.row),ft.row=ft.rows[0],ft.selected=pe(ft,U),A.push(ft),ye.drawn++}for(const wt of[...g.keys()])jt.has(wt)||g.delete(wt)}const ke=s(o,O.color,A,F.accent,F),Te=$(o,O.dash),ze=Le(o,O.icon),Ze=a(o,O.elevation,0),He=a(o,O.radius,O.radiusUnits==="pixels"?6:30),Ke=a(o,O.width,3),Fe={point:[],column:[],polygon:[],path:[]},ct=new Map;for(const tt of A){if(tt.colour=ke.colourOf(tt),tt.elevation=Ze(tt),tt.radius=He(tt),tt.width=Ke(tt),tt.dash=tt.layer==="path"?Te.dashOf(tt):null,tt.icon=null,ze&&tt.layer==="point"){const pt=ze.refOf(tt);pt&&(tt.icon=pt.key,tt.iconSize=ze.sizeOf(tt),ct.set(pt.key,pt.ref))}Fe[tt.layer].push(tt)}return{items:A,skipped:K,byLayer:Fe,legend:ke.legend,dashLegend:Te.legend,legendSections:Q(o,A,ke,Te),dashed:Te.any,routes:ye,icon:ze?{anchor:ze.anchor,badge:ze.badge,refs:ct}:null}}function fe(o,d){return o.selected?d.highlight:o.colour}function we(o){let d=1/0,O=1/0,F=-1/0,U=-1/0;const ee=Z=>{!Array.isArray(Z)||!Number.isFinite(Z[0])||!Number.isFinite(Z[1])||(Z[0]<d&&(d=Z[0]),Z[0]>F&&(F=Z[0]),Z[1]<O&&(O=Z[1]),Z[1]>U&&(U=Z[1]))},L=Z=>{if(Array.isArray(Z)){if(typeof Z[0]=="number"){ee(Z);return}for(const xe of Z)L(xe)}};for(const Z of o){const xe=Z.geometry;if(xe.type==="GeometryCollection")for(const g of xe.geometries||[])L(g.coordinates);else L(xe.coordinates)}return d<=F&&O<=U?[d,O,F,U]:null}function i(o,d,O,F){if(d===!1)return[];const U=L=>F&&o.columns.get(F)?[F,...L.filter(Z=>Z!==F)]:L;if(Array.isArray(d))return U(d.filter(L=>typeof L=="string"&&o.columns.get(L)));const ee=typeof o.columns.visible=="function"?o.columns.visible():o.columns.all();return U(ee.map(L=>L.id).filter(L=>!O.includes(L)&&L!==F).slice(0,3))}function Y(o,d,O,F){return O.map(U=>{const ee=o.columns.get(U);let L;try{L=o.rows.byKey&&o.rows.byKey(d)?o.rows.text(d,U):void 0}catch{L=void 0}if(L===void 0){const Z=F&&typeof F=="object"?F[U]:void 0;L=Z==null?"":String(Z)}return{column:U,title:ee?ee.title:U,text:L}})}}),qe("packages/modules/mapview/icons.js",function(t,ce){"use strict";Object.defineProperty(t,"CELL",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(t,"badgeCell",{enumerable:!0,get:function(){return te}}),Object.defineProperty(t,"anchorPoint",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"createAtlas",{enumerable:!0,get:function(){return q}});const H=ce("packages/modules/mapview/model.js").resolveIcon,ue=64,ie=8,te=B=>`__badge:${B}`;function n(B){const f=ue/2;switch(B){case"bottom":return{anchorX:f,anchorY:ue};case"top":return{anchorX:f,anchorY:0};case"left":return{anchorX:0,anchorY:f};case"right":return{anchorX:ue,anchorY:f};default:return{anchorX:f,anchorY:f}}}function V(B,f,S,y){const P=ue/2;B.fillStyle="#fff",B.beginPath(),f==="circle"?B.arc(S+P,y+P,P-2,0,Math.PI*2):f==="square"?B.rect(S+4,y+4,ue-8,ue-8):(B.moveTo(S+P,y+1),B.lineTo(S+ue-1,y+P),B.lineTo(S+P,y+ue-1),B.lineTo(S+1,y+P),B.closePath()),B.fill()}function E(B,f,S,y,P){const[N,p,u,h]=String(S.viewBox||"0 0 16 16").trim().split(/[\s,]+/).map(Number),c=4,k=ue-c*2,m=Math.min(k/(u||16),k/(h||16));B.save(),B.translate(y+c+(k-(u||16)*m)/2-(N||0)*m,P+c+(k-(h||16)*m)/2-(p||0)*m),B.scale(m,m),B.fillStyle="#fff",B.strokeStyle="#fff",B.lineWidth=1.5,B.lineCap="round",B.lineJoin="round";for(const r of S.paths){const v=new f(r);S.paint==="stroke"?B.stroke(v):B.fill(v)}B.restore()}function q(B,f,S,y){const P=f&&f.Path2D||globalThis.Path2D,N=f&&f.Image||globalThis.Image;let p=new Map,u=[],h=new Map,c=null,k=0,m=!1;const r=new Set,v=new Map,l=()=>{const W=S.createElement("canvas"),J=Math.max(1,Math.ceil(u.length/ie));W.width=Math.min(u.length,ie)*ue||ue,W.height=J*ue;const se=typeof W.getContext=="function"?W.getContext("2d"):null;if(!se||typeof P!="function"){m=!0,c=null;return}h=new Map,u.forEach((re,b)=>{const C=b%ie*ue,I=Math.floor(b/ie)*ue,M=p.get(re);re.startsWith("__badge:")?(V(se,re.slice(8),C,I),h.set(re,{x:C,y:I,mask:!0})):M.kind==="glyph"?(E(se,P,M.def,C,I),h.set(re,{x:C,y:I,mask:!0})):M.ready&&M.img&&(se.drawImage(M.img,C,I,ue,ue),h.set(re,{x:C,y:I,mask:!1}))});try{c=W.toDataURL("image/png")}catch{m=!0,c=null}k++},x=(W,J,se)=>{if(v.has(W)||typeof N!="function")return;const re=new N;v.set(W,re),re.onload=()=>{J.ready=!0,J.img=re,l(),y()},re.onerror=()=>{J.ready=!1,r.add(se),y()};try{re.crossOrigin="anonymous",re.src=W}catch{}};return{ensure(W,J){if([...W.keys(),...[...J].map(te)].every(b=>p.has(b)||r.has(b)))return;const re=new Map(p);for(const[b,C]of W){if(re.has(b))continue;const I=H(B,C);I?re.set(b,I.kind==="url"?{kind:"url",url:I.url,ready:!1}:{kind:"glyph",def:I.def}):r.add(b)}for(const b of J)re.set(te(b),{kind:"badge"});p=re,u=[...p.keys()],l();for(const[b,C]of p)C.kind==="url"&&!C.ready&&x(C.url,C,b)},has:W=>h.has(W),image:()=>c,mapping(W){const J={};for(const[se,re]of h){const b=se.startsWith("__badge:")?n("center"):n(W);J[se]={x:re.x,y:re.y,width:ue,height:ue,...b,mask:re.mask}}return J},unknown:()=>[...r],builds:()=>k,unavailable:()=>m}}}),qe("packages/modules/mapview/theme.js",function(t,ce){"use strict";Object.defineProperty(t,"parseComputed",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(t,"readRole",{enumerable:!0,get:function(){return H}}),Object.defineProperty(t,"readRoleCss",{enumerable:!0,get:function(){return ue}});function _e(ie){const te=/^color\(srgb\s+([^)]+)\)$/i.exec(ie);if(te){const[S,y,P,N=1]=te[1].split(/[\s/]+/).filter(Boolean).map(Number);return[S,y,P,N].every(Number.isFinite)?[S,y,P].map(p=>Math.round(p*255)).concat(Math.round(N*255)):null}const n=/^rgba?\(([^)]+)\)$/i.exec(ie);if(!n)return null;const V=n[1].split(/[\s,/]+/).filter(Boolean),[E,q,B]=V.slice(0,3).map(Number),f=V[3]===void 0?1:Number(V[3].replace("%",""))/(V[3].endsWith("%")?100:1);return[E,q,B,f].every(Number.isFinite)?[E,q,B,Math.round(f*255)]:null}function H(ie,te,n,V){try{if(!ie||!te||typeof te.getComputedStyle!="function"||!ie.ownerDocument)return null;const E=ie.ownerDocument.createElement("span");E.style.cssText=`position:absolute;visibility:hidden;pointer-events:none;color:var(${n},var(${n.replace(/^--lattice-(map|chart)-/,"--lattice-$1-d-")},transparent))`,ie.appendChild(E);const q=_e(te.getComputedStyle(E).color);return ie.removeChild(E),!q||q[3]===0?null:V!==void 0&&q[3]===255?[q[0],q[1],q[2],V]:q}catch{return null}}function ue(ie,te,n){const V=H(ie,te,n);return V?`rgba(${V[0]},${V[1]},${V[2]},${+(V[3]/255).toFixed(3)})`:null}}),qe("packages/modules/mapview/roles.js",function(t,ce){"use strict";Object.defineProperty(t,"BUILDING",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(t,"expand",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(t,"rolesCss",{enumerable:!0,get:function(){return te}});const _e=Object.freeze({light:"#d6d2ca",dark:"#3b4048"}),H=`
465
465
  --lattice-map-d-background:var(--lattice-background,#fff);
466
466
  --lattice-map-d-layer-fill:var(--lattice-accent,#0072b2);
467
467
  --lattice-map-d-layer-stroke:var(--lattice-border-strong,#8c96a0);
@@ -481,20 +481,20 @@ ${se()}
481
481
  --lattice-map-d-font:var(--lattice-font-family,system-ui,sans-serif);
482
482
  --lattice-map-d-font-size:var(--lattice-font-size,13px);
483
483
  --lattice-map-d-font-size-sm:var(--lattice-font-size-sm,12px);
484
- `,fe=new Set([...Y.matchAll(/--lattice-map-d-([a-z-]+):/g)].map(n=>n[1]));function se(n){return String(n).replace(/var\(--lattice-map-([a-z-]+)\)/g,(V,T)=>fe.has(T)?`var(--lattice-map-${T},var(--lattice-map-d-${T}))`:V)}function ne(){return`.lat-mapview,.lat-mapview-split,.lat-mapview-tabs,.lat-mapview-float{${Y.replace(/\n\s*/g,"")}}
484
+ `,ue=new Set([...H.matchAll(/--lattice-map-d-([a-z-]+):/g)].map(n=>n[1]));function ie(n){return String(n).replace(/var\(--lattice-map-([a-z-]+)\)/g,(V,E)=>ue.has(E)?`var(--lattice-map-${E},var(--lattice-map-d-${E}))`:V)}function te(){return`.lat-mapview,.lat-mapview-split,.lat-mapview-tabs,.lat-mapview-float,.lattice{${H.replace(/\n\s*/g,"")}}
485
485
  @layer lattice.mapview{
486
- :where(:root,.lattice,.lattice-tokens,[data-theme]){--lattice-map-building:${Le.light}}
487
- :where([data-theme="dark"]){--lattice-map-building:${Le.dark}}
488
- @media (prefers-color-scheme: dark){:where([data-theme="auto"]){--lattice-map-building:${Le.dark}}}
489
- }`}}),Ze("packages/modules/mapview/styles.js",function(t,ue){"use strict";Object.defineProperty(t,"NS",{enumerable:!0,get:function(){return se}}),Object.defineProperty(t,"css",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"injectStyles",{enumerable:!0,get:function(){return V}});const Le=ue("packages/modules/mapview/roles.js"),Y=Le.rolesCss,fe=Le.expand,se="lat-mapview",ne="data-lattice-mapview-styles";function n(){return fe(`
490
- .${se}{
486
+ :where(:root,.lattice,.lattice-tokens,[data-theme]){--lattice-map-building:${_e.light}}
487
+ :where([data-theme="dark"]){--lattice-map-building:${_e.dark}}
488
+ @media (prefers-color-scheme: dark){:where([data-theme="auto"]){--lattice-map-building:${_e.dark}}}
489
+ }`}}),qe("packages/modules/mapview/styles.js",function(t,ce){"use strict";Object.defineProperty(t,"NS",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(t,"css",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"injectStyles",{enumerable:!0,get:function(){return V}});const _e=ce("packages/modules/mapview/roles.js"),H=_e.rolesCss,ue=_e.expand,ie="lat-mapview",te="data-lattice-mapview-styles";function n(){return ue(`
490
+ .${ie}{
491
491
  position:relative; box-sizing:border-box; width:100%; height:100%; min-height:0; min-width:0; overflow:hidden;
492
492
  background:var(--lattice-map-background); color:var(--lattice-map-fg);
493
493
  font-family:var(--lattice-map-font); font-size:var(--lattice-map-font-size);
494
494
  }
495
- .${se}[hidden]{display:none}
496
- .${se}__map{ position:absolute; inset:0; }
497
- .${se}__tooltip{
495
+ .${ie}[hidden]{display:none}
496
+ .${ie}__map{ position:absolute; inset:0; }
497
+ .${ie}__tooltip{
498
498
  position:absolute; z-index:3; pointer-events:none; max-width:280px;
499
499
  padding:6px 8px; border-radius:var(--lattice-map-radius);
500
500
  background:var(--lattice-map-popup-bg); color:var(--lattice-map-popup-fg);
@@ -502,60 +502,60 @@ ${se()}
502
502
  box-shadow:var(--lattice-map-shadow);
503
503
  font-variant-numeric:tabular-nums; line-height:1.4;
504
504
  }
505
- .${se}__tooltip[hidden]{display:none}
506
- .${se}__legend{
505
+ .${ie}__tooltip[hidden]{display:none}
506
+ .${ie}__legend{
507
507
  position:absolute; z-index:2; left:8px; bottom:24px; max-width:220px; padding:6px 8px;
508
508
  border-radius:var(--lattice-map-radius); font-size:var(--lattice-map-font-size-sm); line-height:1.5;
509
509
  background:var(--lattice-map-legend-bg); color:var(--lattice-map-fg);
510
510
  border:var(--lattice-border-width,1px) solid var(--lattice-map-border);
511
511
  box-shadow:var(--lattice-map-shadow);
512
512
  }
513
- .${se}__legend[hidden]{display:none}
514
- .${se}__legend-row{ display:flex; align-items:center; gap:8px; }
515
- .${se}__legend-swatch{ flex:0 0 auto; width:14px; height:14px; border-radius:var(--lattice-map-radius-sm); }
516
- .${se}__legend-line{ flex:0 0 auto; width:28px; height:3px; }
517
- .${se}__legend-title{ font-weight:600; margin-top:2px; }
518
- .${se}__tip-title{ color:var(--lattice-map-muted); margin-right:6px; }
519
- .${se}-split{ display:flex; box-sizing:border-box; width:100%; min-height:0; }
520
- .${se}-split__pane{ position:relative; min-width:0; min-height:0; overflow:hidden; }
521
- .${se}-split__divider{
513
+ .${ie}__legend[hidden]{display:none}
514
+ .${ie}__legend-row{ display:flex; align-items:center; gap:8px; }
515
+ .${ie}__legend-swatch{ flex:0 0 auto; width:14px; height:14px; border-radius:var(--lattice-map-radius-sm); }
516
+ .${ie}__legend-line{ flex:0 0 auto; width:28px; height:3px; }
517
+ .${ie}__legend-title{ font-weight:600; margin-top:2px; }
518
+ .${ie}__tip-title{ color:var(--lattice-map-muted); margin-right:6px; }
519
+ .${ie}-split{ display:flex; box-sizing:border-box; width:100%; min-height:0; }
520
+ .${ie}-split__pane{ position:relative; min-width:0; min-height:0; overflow:hidden; }
521
+ .${ie}-split__divider{
522
522
  flex:0 0 6px; cursor:col-resize; touch-action:none;
523
523
  background:var(--lattice-map-border);
524
524
  }
525
- .${se}-split__divider:focus-visible{ outline:2px solid var(--lattice-map-accent); outline-offset:-2px; }
526
- .${se}-tabs{ display:flex; flex-direction:column; box-sizing:border-box; width:100%; min-height:0; }
527
- .${se}-tabs__strip{ display:flex; gap:2px; flex:0 0 auto; border-bottom:var(--lattice-border-width,1px) solid var(--lattice-map-border); }
528
- .${se}-tabs__tab{
525
+ .${ie}-split__divider:focus-visible{ outline:2px solid var(--lattice-map-accent); outline-offset:-2px; }
526
+ .${ie}-tabs{ display:flex; flex-direction:column; box-sizing:border-box; width:100%; min-height:0; }
527
+ .${ie}-tabs__strip{ display:flex; gap:2px; flex:0 0 auto; border-bottom:var(--lattice-border-width,1px) solid var(--lattice-map-border); }
528
+ .${ie}-tabs__tab{
529
529
  font:inherit; padding:6px 14px; border:0; border-bottom:2px solid transparent; cursor:pointer;
530
530
  background:transparent; color:var(--lattice-map-fg);
531
531
  }
532
- .${se}-tabs__tab[aria-selected="true"]{ border-bottom-color:var(--lattice-map-accent); }
533
- .${se}-tabs__tab:focus-visible{ outline:2px solid var(--lattice-map-accent); }
534
- .${se}-tabs__panel{ position:relative; flex:1 1 auto; min-height:0; }
535
- .${se}-tabs__panel[hidden]{display:none}
536
- .${se}-float{
532
+ .${ie}-tabs__tab[aria-selected="true"]{ border-bottom-color:var(--lattice-map-accent); }
533
+ .${ie}-tabs__tab:focus-visible{ outline:2px solid var(--lattice-map-accent); }
534
+ .${ie}-tabs__panel{ position:relative; flex:1 1 auto; min-height:0; }
535
+ .${ie}-tabs__panel[hidden]{display:none}
536
+ .${ie}-float{
537
537
  position:fixed; right:16px; bottom:16px; z-index:1000; width:480px; height:360px;
538
538
  display:flex; flex-direction:column; resize:both; overflow:hidden; min-width:240px; min-height:180px;
539
539
  background:var(--lattice-map-popup-bg); color:var(--lattice-map-popup-fg);
540
540
  border:var(--lattice-border-width,1px) solid var(--lattice-map-border);
541
541
  border-radius:var(--lattice-map-radius); box-shadow:var(--lattice-map-float-shadow);
542
542
  }
543
- .${se}-float__bar{ display:flex; align-items:center; gap:8px; padding:4px 8px; cursor:move; touch-action:none; flex:0 0 auto;
543
+ .${ie}-float__bar{ display:flex; align-items:center; gap:8px; padding:4px 8px; cursor:move; touch-action:none; flex:0 0 auto;
544
544
  border-bottom:var(--lattice-border-width,1px) solid var(--lattice-map-border); }
545
- .${se}-float__title{ flex:1 1 auto; }
546
- .${se}-float__close{ font:inherit; border:0; background:transparent; color:inherit; cursor:pointer; }
547
- .${se}-float__body{ position:relative; flex:1 1 auto; min-height:0; }
548
- ${Y()}
549
- `).trim()}function V(T){const q=T&&T.documentElement;if(!q||q.getAttribute(ne))return;q.setAttribute(ne,"1");const R=T.createElement("style");R.textContent=n(),(T.head||T.body||q).appendChild(R)}}),Ze("packages/modules/mapview/view.js",function(t,ue){"use strict";Object.defineProperty(t,"MODES",{enumerable:!0,get:function(){return se}}),Object.defineProperty(t,"FALLBACK_EN",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(t,"message",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"themeMode",{enumerable:!0,get:function(){return T}}),Object.defineProperty(t,"resolveContainer",{enumerable:!0,get:function(){return R}}),Object.defineProperty(t,"place",{enumerable:!0,get:function(){return f}});const Le=ue("packages/modules/mapview/styles.js"),Y=Le.NS,fe=Le.injectStyles,se=Object.freeze(["container","split","tab","popout"]),ne=Object.freeze({"mapview.label":"Map of the grid’s rows","mapview.title":"Map","mapview.tab.grid":"Grid","mapview.tab.map":"Map","mapview.divider":"Resize the map","mapview.close":"Close the map","mapview.legend":"Map legend","mapview.draw.segment":"Segment","mapview.draw.perimeter":"Perimeter","mapview.draw.refused.geometry-type":"Not allowed: this kind of shape","mapview.draw.refused.max-vertices":"Not allowed: too many vertices","mapview.draw.refused.min-segment-length":"Not allowed: segment too short","mapview.draw.refused.self-intersection":"Not allowed: crosses itself"});function n(u,m){const c=u&&u.messages&&typeof u.messages.t=="function"?u.messages:null;if(c){let w;try{w=c.t(m)}catch{w=null}if(typeof w=="string"&&w&&w!==m)return w}return ne[m]||m}function V(u,m,c){const w=u.createElement(m);return w.className=c,w}function T(u,m){let c=u;for(;c&&typeof c.getAttribute=="function";){const w=c.getAttribute("data-theme");if(w==="dark"||w==="light")return w;if(w==="auto")break;c=c.parentElement||c.parentNode}try{if(m&&typeof m.matchMedia=="function"&&m.matchMedia("(prefers-color-scheme: dark)").matches)return"dark"}catch{}return"light"}function q(u,m,c){fe(u);const w=V(u,"div",Y);w.setAttribute("role","region"),w.setAttribute("aria-label",n(c,"mapview.label"));const d=V(u,"div",`${Y}__map`),r=V(u,"div",`${Y}__tooltip`);return r.setAttribute("role","tooltip"),r.hidden=!0,w.appendChild(d),w.appendChild(r),m.appendChild(w),{root:w,mapEl:d,tooltip:r}}function R(u,m){if(u&&typeof u=="object"&&"appendChild"in u)return u;if(typeof u=="string"&&m&&typeof m.querySelector=="function")try{return m.querySelector(u)}catch{return null}return null}function f(u,m,c){const w=u&&u.element?u.element:null,d=w?w.ownerDocument:typeof document<"u"?document:null,r=m.mode!==void 0?m.mode:m.container!==void 0?"container":"split";if(!se.includes(r))return`mode ${JSON.stringify(r)} is not one of ${se.join(", ")}`;if(r==="container"){const v=R(m.container,d);if(!v)return`container ${typeof m.container=="string"?JSON.stringify(m.container):"option"} names no element`;const l=v.ownerDocument,x=q(l,v,u);return{...x,doc:l,win:l.defaultView||globalThis,mode:r,unmount(){x.root.remove()}}}return!w||!w.parentNode?`mode "${r}" needs the grid's element in the page (a grid from createGrid), and this grid has none`:r==="split"?g(u,w,c):r==="tab"?P(u,w,c):N(u,w,m,c)}function S(u,m){const c=u.parentNode,w=u.nextSibling,d=u.getAttribute("style"),r=typeof u.getBoundingClientRect=="function"?u.getBoundingClientRect():null;return r&&r.height>0&&(m.style.height=`${Math.round(r.height)}px`),c.insertBefore(m,u),()=>{w&&w.parentNode===c?c.insertBefore(u,w):c.insertBefore(u,m),d===null?u.removeAttribute("style"):u.setAttribute("style",d),m.remove()}}function g(u,m,c){const w=m.ownerDocument;fe(w);const d=V(w,"div",`${Y}-split`),r=S(m,d),v=V(w,"div",`${Y}-split__pane`),l=V(w,"div",`${Y}-split__divider`),x=V(w,"div",`${Y}-split__pane`);l.setAttribute("role","separator"),l.setAttribute("aria-orientation","vertical"),l.setAttribute("aria-label",n(u,"mapview.divider")),l.setAttribute("aria-valuemin","15"),l.setAttribute("aria-valuemax","85"),l.tabIndex=0,d.appendChild(v),d.appendChild(l),d.appendChild(x),v.appendChild(m),m.style.width="100%",m.style.height="100%";const W=q(w,x,u);let Z=.5;const le=J=>{Z=Math.max(.15,Math.min(.85,Number.isFinite(J)?J:.5)),v.style.flex=`0 0 ${(Z*100).toFixed(2)}%`,x.style.flex="1 1 0",l.setAttribute("aria-valuenow",String(Math.round(Z*100))),c.onResize()};le(.5);let oe=!1;const y=J=>{oe=!0,typeof l.setPointerCapture=="function"&&J.pointerId!==void 0&&l.setPointerCapture(J.pointerId),typeof J.preventDefault=="function"&&J.preventDefault()},C=J=>{if(!oe)return;const F=d.getBoundingClientRect();F.width>0&&le((J.clientX-F.left)/F.width)},D=()=>{oe=!1},M=J=>{const F={ArrowLeft:-.05,ArrowRight:.05}[J.key];if(F!==void 0)le(Z+F);else if(J.key==="Home")le(.15);else if(J.key==="End")le(.85);else return;typeof J.preventDefault=="function"&&J.preventDefault()};return l.addEventListener("pointerdown",y),l.addEventListener("pointermove",C),l.addEventListener("pointerup",D),l.addEventListener("pointercancel",D),l.addEventListener("keydown",M),{...W,doc:w,win:w.defaultView||globalThis,mode:"split",setRatio:le,ratio:()=>Z,unmount(){l.removeEventListener("pointerdown",y),l.removeEventListener("pointermove",C),l.removeEventListener("pointerup",D),l.removeEventListener("pointercancel",D),l.removeEventListener("keydown",M),r()}}}function P(u,m,c){const w=m.ownerDocument;fe(w);const d=V(w,"div",`${Y}-tabs`),r=S(m,d),v=V(w,"div",`${Y}-tabs__strip`);v.setAttribute("role","tablist");const l=`${Y}-${Math.random().toString(36).slice(2,8)}`,x={};for(const y of["grid","map"]){const C=V(w,"button",`${Y}-tabs__tab`);C.setAttribute("type","button"),C.setAttribute("role","tab"),C.id=`${l}-${y}-tab`,C.setAttribute("aria-controls",`${l}-${y}`),C.setAttribute("data-tab",y),C.textContent=n(u,`mapview.tab.${y}`);const D=V(w,"div",`${Y}-tabs__panel`);D.id=`${l}-${y}`,D.setAttribute("role","tabpanel"),D.setAttribute("aria-labelledby",C.id),v.appendChild(C),x[y]={tab:C,panel:D}}d.appendChild(v),d.appendChild(x.grid.panel),d.appendChild(x.map.panel),x.grid.panel.appendChild(m),m.style.width="100%",m.style.height="100%";const W=q(w,x.map.panel,u),Z=y=>{for(const C of["grid","map"]){const D=C===y;x[C].tab.setAttribute("aria-selected",D?"true":"false"),x[C].tab.tabIndex=D?0:-1,x[C].panel.hidden=!D}c.onResize()},le=y=>{const C=y.target&&typeof y.target.closest=="function"?y.target.closest("[data-tab]"):null;C&&Z(C.getAttribute("data-tab"))},oe=y=>{if(y.key!=="ArrowLeft"&&y.key!=="ArrowRight")return;const C=x.grid.tab.getAttribute("aria-selected")==="true"?"map":"grid";Z(C),x[C].tab.focus(),typeof y.preventDefault=="function"&&y.preventDefault()};return v.addEventListener("click",le),v.addEventListener("keydown",oe),Z("grid"),{...W,doc:w,win:w.defaultView||globalThis,mode:"tab",activate:Z,unmount(){v.removeEventListener("click",le),v.removeEventListener("keydown",oe),r()}}}function N(u,m,c,w){const d=m.ownerDocument,r=d.defaultView||globalThis;let v=null;try{v=typeof r.open=="function"?r.open("","lattice-mapview","popup,width=960,height=640"):null}catch{v=null}const l=v&&v.document;if(l&&l.body){l.title=n(u,"mapview.title");for(const oe of d.querySelectorAll('link[rel="stylesheet"],style'))typeof l.importNode=="function"&&l.head.appendChild(l.importNode(oe,!0));const x=T(m,r);l.documentElement.setAttribute("data-theme",x),l.body.style.margin="0",l.body.style.height="100vh";const W=q(l,l.body,u),Z=()=>w.onClose(),le=()=>w.onResize();return v.addEventListener("pagehide",Z),v.addEventListener("resize",le),{...W,doc:l,win:v,mode:"popout",unmount(){v.removeEventListener("pagehide",Z),v.removeEventListener("resize",le);try{v.closed||v.close()}catch{}}}}return p(u,m,w)}function p(u,m,c){const w=m.ownerDocument,d=w.defaultView||globalThis;fe(w);const r=V(w,"div",`${Y}-float`);r.setAttribute("role","dialog"),r.setAttribute("aria-label",n(u,"mapview.title")),r.setAttribute("data-theme",T(m,d));const v=V(w,"div",`${Y}-float__bar`),l=V(w,"span",`${Y}-float__title`);l.textContent=n(u,"mapview.title");const x=V(w,"button",`${Y}-float__close`);x.setAttribute("type","button"),x.setAttribute("aria-label",n(u,"mapview.close")),x.textContent="×",v.appendChild(l),v.appendChild(x);const W=V(w,"div",`${Y}-float__body`);r.appendChild(v),r.appendChild(W),(w.body||w.documentElement).appendChild(r);const Z=q(w,W,u);let le=null;const oe=F=>{if(F.target===x)return;const re=r.getBoundingClientRect();le={dx:F.clientX-re.left,dy:F.clientY-re.top},typeof v.setPointerCapture=="function"&&F.pointerId!==void 0&&v.setPointerCapture(F.pointerId)},y=F=>{le&&(r.style.left=`${Math.max(0,F.clientX-le.dx)}px`,r.style.top=`${Math.max(0,F.clientY-le.dy)}px`,r.style.right="auto",r.style.bottom="auto")},C=()=>{le=null},D=()=>c.onClose();v.addEventListener("pointerdown",oe),v.addEventListener("pointermove",y),v.addEventListener("pointerup",C),x.addEventListener("click",D);const M=d.ResizeObserver||globalThis.ResizeObserver,J=typeof M=="function"?new M(()=>c.onResize()):null;return J&&J.observe(W),{...Z,doc:w,win:d,mode:"float",unmount(){v.removeEventListener("pointerdown",oe),v.removeEventListener("pointermove",y),v.removeEventListener("pointerup",C),x.removeEventListener("click",D),J&&J.disconnect(),r.remove()}}}}),Ze("packages/modules/shared/require-core.js",function(t,ue){"use strict";Object.defineProperty(t,"coreMissing",{enumerable:!0,get:function(){return Le}});function Le(){if(typeof Mn>"u"||!Mn||typeof globalThis>"u")return!1;const Y=globalThis.LatticeGrid;return!Y||typeof Y.createGrid!="function"}}),Ze("packages/core/src/registry/free-tier-notice.js",function(t,ue){"use strict";Object.defineProperty(t,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(t,"WATERMARK_TEXT",{enumerable:!0,get:function(){return Y}});const Le="Free for non-commercial use: latticegrid.dev/free",Y="Unlicensed: Lattice Grid trial"}),Ze("packages/core/src/registry/licence.js",function(t,ue){"use strict";Object.defineProperty(t,"PRODUCT",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(t,"LICENCE_VERSION",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"PUBLIC_KEY",{enumerable:!0,get:function(){return q}}),Object.defineProperty(t,"fromBase64Url",{enumerable:!0,get:function(){return S}}),Object.defineProperty(t,"toBase64Url",{enumerable:!0,get:function(){return g}}),Object.defineProperty(t,"asciiBytes",{enumerable:!0,get:function(){return P}}),Object.defineProperty(t,"parseLicence",{enumerable:!0,get:function(){return p}}),Object.defineProperty(t,"hasEd25519",{enumerable:!0,get:function(){return l}}),Object.defineProperty(t,"verifyLicence",{enumerable:!0,get:function(){return x}}),Object.defineProperty(t,"isLocalHost",{enumerable:!0,get:function(){return W}}),Object.defineProperty(t,"currentHost",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(t,"matchesDomain",{enumerable:!0,get:function(){return le}}),Object.defineProperty(t,"LicenceHolder",{enumerable:!0,get:function(){return y}}),Object.defineProperty(t,"setLicence",{enumerable:!0,get:function(){return J}}),Object.defineProperty(t,"licenceInfo",{enumerable:!0,get:function(){return F}}),Object.defineProperty(t,"watermark",{enumerable:!0,get:function(){return re}}),Object.defineProperty(t,"licenceState",{enumerable:!0,get:function(){return z}}),Object.defineProperty(t,"sharedLicence",{enumerable:!0,get:function(){return U}});const Y=ue("packages/core/src/internal/warn.js").warnOnce,fe=ue("packages/core/src/registry/free-tier-notice.js"),se=fe.FREE_TIER_NOTICE;Object.defineProperty(t,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return fe.FREE_TIER_NOTICE}});const ne="lattice-grid",n=1,V="LG1",T=64,q="GwmaCOkGedHulqsa-DOV1TU8On1rsalWv519c_dW4j4",R="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",f=(()=>{const L=new Int16Array(128).fill(-1);for(let e=0;e<R.length;e++)L[R.charCodeAt(e)]=e;return L[43]=62,L[47]=63,L})();function S(L){if(typeof L!="string")return null;let e="";for(let ke=0;ke<L.length;ke++){const ge=L.charCodeAt(ke);if(ge!==61){if(ge>127||f[ge]<0)return null;e+=L[ke]}}const i=e.length;if(i%4===1)return null;const a=new Uint8Array(Math.floor(i*3/4));let A=0,$=0,te=0;for(let ke=0;ke<i;ke++)A=A<<6|f[e.charCodeAt(ke)],$+=6,$>=8&&($-=8,a[te++]=A>>$&255);return te===a.length?a:a.subarray(0,te)}function g(L){let e="",i=0;for(;i+2<L.length;i+=3){const A=L[i]<<16|L[i+1]<<8|L[i+2];e+=R[A>>18&63]+R[A>>12&63]+R[A>>6&63]+R[A&63]}const a=L.length-i;if(a===1){const A=L[i]<<16;e+=R[A>>18&63]+R[A>>12&63]}else if(a===2){const A=L[i]<<16|L[i+1]<<8;e+=R[A>>18&63]+R[A>>12&63]+R[A>>6&63]}return e}function P(L){const e=new Uint8Array(L.length);for(let i=0;i<L.length;i++)e[i]=L.charCodeAt(i)&127;return e}function N(L){if(typeof TextDecoder=="function")return new TextDecoder().decode(L);let e="";for(let i=0;i<L.length;i++)e+=String.fromCharCode(L[i]);return e}function p(L){const e={ok:!1,reason:"malformed",product:null,issuedTo:null,expires:null,terms:null,features:[],deployments:[],version:0,message:null,signature:null,raw:typeof L=="string"?L:""};if(typeof L!="string"||L.length===0)return{...e,reason:"missing"};const i=L.trim(),a=i.split(".");if(a.length!==3)return e;const[A,$,te]=a;if(A!==V)return{...e,reason:"prefix"};const ke=S($),ge=S(te);if(!ke||!ge)return e;let ve;try{ve=JSON.parse(N(ke))}catch{return e}return ve===null||typeof ve!="object"?e:{ok:!0,reason:null,product:typeof ve.p=="string"?ve.p:null,issuedTo:typeof ve.t=="string"?ve.t:null,expires:typeof ve.e=="string"?ve.e:null,terms:typeof ve.terms=="string"?ve.terms:null,features:Array.isArray(ve.f)?ve.f.slice():[],deployments:Array.isArray(ve.d)?ve.d.slice():[],version:typeof ve.v=="number"?ve.v:0,message:P($),signature:ge,raw:i}}function u(L,e){if(!L)return!1;const i=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(L)?`${L}T23:59:59.999Z`:L);return Number.isNaN(i)?!0:e>i}function m(L){return L==="non-commercial"?"non-commercial":"commercial"}let c=null,w=null,d=null;function r(){const L=globalThis.crypto;return L&&L.subtle?L.subtle:null}async function v(L){if(c&&w===L)return c;const e=r();if(!e)return null;const i=S(L);if(!i)return null;try{const a=await e.importKey("raw",i,{name:"Ed25519"},!1,["verify"]);return c=a,w=L,a}catch{return null}}async function l(){return d!==null||(d=await v(q)!==null),d}async function x(L,e={}){const i=e.warn!==!1,a=e.product||ne,A=e.publicKey||q,$=e.now??Date.now(),te=e.host??Z(),ke=W(te)?"":` ${se}`,ge=p(L);if(!ge.ok){const pe=ge.reason==="missing"?"missing":"malformed";return i&&Y(`licence.${pe}`,pe==="missing"?`no licence key supplied. The grid renders in full and carries a trial watermark on any host other than localhost. Get a key at latticegrid.dev.${ke}`:`licence key could not be read. The grid will render with a watermark.${ke}`),{valid:!1,reason:pe,terms:"commercial"}}const ve={product:ge.product||void 0,issuedTo:ge.issuedTo||void 0,expires:ge.expires||void 0,terms:m(ge.terms)};if(ge.product!==a)return i&&Y("licence.product",`licence key is for '${ge.product}', not '${a}'. The grid will render with a watermark.`),{valid:!1,...ve,reason:"product"};if(u(ge.expires,$))return i&&Y("licence.expired",`licence expired on ${ge.expires}. The grid will render with a watermark. Renew at latticegrid.dev.`),{valid:!1,...ve,reason:"expired"};const Pe=ge.deployments||[];if(Pe.length&&te&&!W(te)&&!le(te,Pe))return i&&Y("licence.domain",`licence key is not valid for ${te}; it covers ${Pe.join(", ")}. The grid will render with a watermark.`),{valid:!1,...ve,reason:"domain"};const Te=await v(A);if(!Te){const pe=!!ge.signature&&ge.signature.length===T;return i&&Y("licence.algorithm","this host does not provide crypto.subtle Ed25519, so the licence signature could not be verified. A structural check was used instead."),pe?{valid:!0,...ve,reason:"unverified"}:{valid:!1,...ve,reason:"signature"}}let _=!1;try{_=await r().verify({name:"Ed25519"},Te,ge.signature,ge.message)}catch{_=!1}return _?{valid:!0,...ve}:(i&&Y("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...ve,reason:"signature"})}function W(L){const e=String(L??Z()??"").trim().toLowerCase().replace(/^\[/,"").replace(/\]$/,"");return!e||e==="localhost"||e.endsWith(".localhost")||e==="::1"||e==="0:0:0:0:0:0:0:1"?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(e)}function Z(){const L=globalThis.location;return L&&typeof L.hostname=="string"?L.hostname:null}function le(L,e){const i=oe(L);return!i||!Array.isArray(e)?!1:e.some(a=>{const A=oe(a);if(!A)return!1;if(A==="*")return!0;if(A.startsWith("*.")){const $=A.slice(2);return i===$||i.endsWith(`.${$}`)}return i===A})}function oe(L){return String(L??"").trim().toLowerCase().replace(/\.$/,"")}class y{#e="";#t={valid:!1,reason:"missing",terms:"commercial"};#n=null;#r=null;#s;#o=new Set;constructor(e={}){this.#s=e}set(e){this.#e=typeof e=="string"?e.trim():"";const i=p(this.#e);return this.#t=i.ok?{valid:!u(i.expires,Date.now())&&i.product===(this.#s.product||ne),product:i.product||void 0,issuedTo:i.issuedTo||void 0,expires:i.expires||void 0,terms:m(i.terms),reason:"pending"}:{valid:!1,reason:i.reason||"malformed",terms:"commercial"},this.#n=null,this.#e&&this.verify(),this.#t}verify(){if(this.#n)return this.#n;const e=this.#e;return this.#n=x(e,this.#s).then(i=>{if(this.#e===e){this.#t=i;for(const a of this.#o)a(i)}return i}),this.#n}onSettled(e){return this.#o.add(e),()=>this.#o.delete(e)}info(){return{...this.#t}}watermark(){return this.#t.valid?!1:!W(this.#r)}setHost(e){this.#r=e}state(){return this.#t.valid?"licensed":W(this.#r)?"localhost":"trial"}reset(){this.#e="",this.#t={valid:!1,reason:"missing",terms:"commercial"},this.#n=null,this.#o.clear()}}const C=Symbol.for("lattice-grid/licence/holder");function D(){const L=globalThis,e=L&&L[C];if(e&&typeof e.set=="function"&&typeof e.watermark=="function")return e;const i=new y;if(L)try{L[C]=i}catch{}return i}const M=D();function J(L){return M.set(L)}function F(){return M.info()}function re(){return M.watermark()}function z(){return M.state()}function U(){return M}}),Ze("packages/dom/src/watermark.js",function(t,ue){"use strict";Object.defineProperty(t,"WATERMARK_CLASS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(t,"WATERMARK_LAYER_CLASS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(t,"Watermark",{enumerable:!0,get:function(){return d}}),Object.defineProperty(t,"viewLicenceHost",{enumerable:!0,get:function(){return r}}),Object.defineProperty(t,"mountViewWatermark",{enumerable:!0,get:function(){return v}}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return l}});const Y=ue("packages/core/src/internal/predicates.js").isFunction,fe=ue("packages/core/src/registry/free-tier-notice.js"),se=fe.FREE_TIER_NOTICE,ne=fe.WATERMARK_TEXT,n=ue("packages/core/src/registry/licence.js"),V=n.watermark,T=n.setLicence,q=Object.freeze({t:x=>x==="licence.watermark.free"?se:ne});function R(x,W,Z={}){const le=x.createElement(W);if(Z.class)for(const oe of Z.class.split(/\s+/))oe&&le.classList.add(oe);if(Z.text!==void 0&&(le.textContent=Z.text),Z.attrs)for(const[oe,y]of Object.entries(Z.attrs))le.setAttribute(oe,y);if(Z.children)for(const oe of Z.children)le.appendChild(oe);return le}function f(x,W,Z){return x.addEventListener(W,Z),()=>x.removeEventListener(W,Z)}const S="lat-watermark",g="https://www.latticegrid.dev",P=["br","bl","tl","tr"],N=4e3,p=Symbol.for("lattice-grid/licence/holder"),u="data-lat-watermark-owner",m="lat-watermark-layer",c="lat-watermark-style",w=`
550
- .${m}{position:absolute;inset:0;pointer-events:none;z-index:2147483000;overflow:hidden}
551
- .${m} .${S}{position:absolute;z-index:6;padding:10px 18px;border-radius:var(--lattice-radius-sm,4px);background:var(--lattice-accent,#2563eb);box-shadow:0 2px 10px rgb(0 0 0 / 25%);color:var(--lattice-accent-contrast,#fff);font:700 15px/1.3 system-ui,sans-serif;letter-spacing:.02em;white-space:nowrap;pointer-events:none;opacity:.94}
552
- .${m} .${S}--br{inset-inline-end:0;bottom:0}
553
- .${m} .${S}--bl{inset-inline-start:0;bottom:0}
554
- .${m} .${S}--tl{inset-inline-start:0;top:0}
555
- .${m} .${S}--tr{inset-inline-end:0;top:0}
556
- .${m} .${S}__link{color:inherit;pointer-events:auto;text-decoration:underline;text-underline-offset:2px}
557
- .${m} .${S}__free{display:block;margin-top:2px;font-size:12px;font-weight:500;letter-spacing:0;opacity:.92}
558
- @media print{.${m} .${S}{opacity:1}}
559
- `;class d{#e;#t;#n;#r=null;#s=[];#o;#u=0;#a=null;#i=null;#f=!1;constructor(W){this.#i=W.owner||null,this.#i&&Y(this.#i.setAttribute)&&this.#i.setAttribute(u,""),this.#e=W.grid,this.#t=W.document,this.#n=W.element,this.#o=W.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.refresh(),Y(this.#e.on)&&this.#s.push(this.#e.on("licence:changed",()=>this.refresh()));const W=this.#e.licence&&this.#e.licence.ready;W&&Y(W.then)&&W.then(()=>this.refresh(),()=>this.refresh())}refresh(){const W=this.#h()&&!this.#d();W&&!this.#r?(this.#p(),this.#m()):!W&&this.#r&&(this.#l(),this.#c())}#d(){const W=this.#n;let Z=W&&W.parentNode;for(this.#i&&Z===this.#i&&(Z=Z.parentNode);Z&&Z.nodeType===1;){if(Y(Z.hasAttribute)&&Z.hasAttribute(u))return!0;Z=Z.parentNode}return!1}#g(){const W=this.#o;if(!W||!Y(W.matchMedia))return!1;try{return!!W.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#m(){this.#c(),Y(this.#o.setTimeout)&&(this.#g()||(this.#a=this.#o.setTimeout(()=>{if(this.#a=null,!this.#h()||this.#d()){this.#l();return}this.#u=(this.#u+1)%P.length,this.#l(),this.#p(),this.#m()},N)))}#c(){this.#a!==null&&Y(this.#o.clearTimeout)&&this.#o.clearTimeout(this.#a),this.#a=null}#h(){const W=this.#e.licence;return!!(W&&Y(W.watermark)&&W.watermark())}#p(){const W=this.#e.messages&&Y(this.#e.messages.t)?this.#e.messages:q,Z=R(this.#t,"a",{class:`${S}__link`,text:W.t("licence.watermark"),attrs:{href:g,target:"_blank",rel:"noopener noreferrer"}}),le=R(this.#t,"span",{class:`${S}__free`,text:W.t("licence.watermark.free")});this.#r=R(this.#t,"div",{class:`${S} ${S}--${P[this.#u]}`,attrs:{role:"note",title:"This grid is unlicensed for this domain. Visit latticegrid.dev for a licence."},children:[Z,le]}),this.#s.push(f(this.#r,"pointerdown",oe=>{Y(oe.stopPropagation)&&oe.stopPropagation()})),this.#n&&Y(this.#n.appendChild)&&this.#n.appendChild(this.#r),typeof queueMicrotask=="function"&&!this.#f&&(this.#f=!0,queueMicrotask(()=>{this.#f=!1,this.#r&&this.#d()&&(this.#l(),this.#c())}))}#l(){this.#r&&Y(this.#r.remove)&&this.#r.remove(),this.#r=null}destroy(){this.#c(),this.#i&&Y(this.#i.removeAttribute)&&this.#i.removeAttribute(u);for(const W of this.#s)W();this.#s=[],this.#l()}}function r(x={},W=void 0){const Z=globalThis[p],le=!x.licence&&W&&Y(W.querySelector)?W.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,oe=x.licence||le;return oe&&T(oe),{licence:{watermark:()=>V(),get ready(){return Z?Z.verify():Promise.resolve()}},on:(y,C)=>y==="licence:changed"&&Z?Z.onSettled(()=>C()):()=>{}}}function v(x,W={}){const Z=x&&x.ownerDocument;if(!Z||!Y(Z.createElement))return{destroy(){},refresh(){}};const le=Z.defaultView||void 0,oe=r(W,Z);let y=null,C=null,D=null,M=!1;const J=()=>{if(!Z.getElementById(c)&&Z.head){const z=Z.createElement("style");z.id=c,z.textContent=w,Z.head.appendChild(z)}le&&Y(le.getComputedStyle)&&le.getComputedStyle(x).position==="static"&&(x.style.position="relative"),y=Z.createElement("div"),y.className=m,x.appendChild(y),C=new d({grid:oe,document:Z,element:y,window:le,owner:x}),C.mount(),le&&Y(le.MutationObserver)&&(D=new le.MutationObserver(()=>{!M&&y&&y.parentNode!==x&&x.appendChild(y)}),D.observe(x,{childList:!0}))},F=()=>{M||(C?C.refresh():oe.licence.watermark()&&J())};F();const re=oe.on("licence:changed",F);return oe.licence.ready,{refresh:F,destroy(){M||(M=!0,re(),D&&D.disconnect(),C&&C.destroy(),y&&y.parentNode&&y.parentNode.removeChild(y))}}}const l=d}),Ze("packages/modules/mapview/draw.js",function(t,ue){"use strict";Object.defineProperty(t,"DRAW_MODES",{enumerable:!0,get:function(){return se}}),Object.defineProperty(t,"metresBetween",{enumerable:!0,get:function(){return m}}),Object.defineProperty(t,"destinationPoint",{enumerable:!0,get:function(){return c}}),Object.defineProperty(t,"circlePolygon",{enumerable:!0,get:function(){return w}}),Object.defineProperty(t,"closeRing",{enumerable:!0,get:function(){return d}}),Object.defineProperty(t,"rectanglePolygon",{enumerable:!0,get:function(){return r}}),Object.defineProperty(t,"pathLength",{enumerable:!0,get:function(){return v}}),Object.defineProperty(t,"ringArea",{enumerable:!0,get:function(){return l}}),Object.defineProperty(t,"formatLength",{enumerable:!0,get:function(){return W}}),Object.defineProperty(t,"formatArea",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(t,"segmentsCross",{enumerable:!0,get:function(){return y}}),Object.defineProperty(t,"pathSelfIntersects",{enumerable:!0,get:function(){return C}}),Object.defineProperty(t,"createDraw",{enumerable:!0,get:function(){return U}}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return L}});const Y=ue("packages/modules/mapview/roles.js").expand,fe=63710088e-1,se=Object.freeze(["point","line","polygon","circle","rectangle"]),ne=10,n=9,V=7,T=14,q=12,R=10,f=500,S=10,g=1600,P=Object.freeze({point:"Point",line:"LineString",polygon:"Polygon",circle:"Polygon",rectangle:"Polygon"}),N=100;function p(e){return e*Math.PI/180}function u(e){return e*180/Math.PI}function m(e,i){const[a,A]=e,[$,te]=i,ke=p(te-A),ge=p($-a),ve=Math.sin(ke/2)**2+Math.cos(p(A))*Math.cos(p(te))*Math.sin(ge/2)**2;return 2*fe*Math.asin(Math.min(1,Math.sqrt(ve)))}function c(e,i,a){const[A,$]=e,te=a/fe,ke=p(i),ge=p($),ve=p(A),Pe=Math.asin(Math.sin(ge)*Math.cos(te)+Math.cos(ge)*Math.sin(te)*Math.cos(ke)),Te=ve+Math.atan2(Math.sin(ke)*Math.sin(te)*Math.cos(ge),Math.cos(te)-Math.sin(ge)*Math.sin(Pe));return[u(Te),u(Pe)]}function w(e,i,a=64){const A=Math.max(0,i),$=Array.from({length:a},(te,ke)=>c(e,360*ke/a,A));return d($)}function d(e){if(e.length<1)return e.slice();const i=e[0],a=e[e.length-1];return i[0]===a[0]&&i[1]===a[1]?e.slice():[...e,[...i]]}function r(e,i){const[a,A]=e,[$,te]=i;return d([[a,A],[$,A],[$,te],[a,te]])}function v(e){let i=0;for(let a=1;a<e.length;a+=1)i+=m(e[a-1],e[a]);return i}function l(e){const i=e.length;if(i<3)return 0;let a=0;for(let A=0;A<i;A+=1){const $=e[A],te=e[(A+1)%i];a+=p(te[0]-$[0])*(2+Math.sin(p($[1]))+Math.sin(p(te[1])))}return Math.abs(a*fe*fe/2)}const x=(e,i)=>new Intl.NumberFormat(void 0,i).format(e);function W(e,i=x){return e<995?`${i(e,{maximumFractionDigits:e<10?1:0})} m`:`${i(e/1e3,{minimumFractionDigits:2,maximumFractionDigits:2})} km`}function Z(e,i=x){return e<9950?`${i(e,{maximumFractionDigits:0})} m²`:`${i(e/1e4,{minimumFractionDigits:2,maximumFractionDigits:2})} ha`}const le=(e,i,a)=>(i[0]-e[0])*(a[1]-e[1])-(i[1]-e[1])*(a[0]-e[0]),oe=(e,i,a)=>Math.min(e[0],i[0])<=a[0]&&a[0]<=Math.max(e[0],i[0])&&Math.min(e[1],i[1])<=a[1]&&a[1]<=Math.max(e[1],i[1]);function y(e,i,a,A){const $=le(e,i,a),te=le(e,i,A),ke=le(a,A,e),ge=le(a,A,i);return $*te<0&&ke*ge<0?!0:$===0&&oe(e,i,a)||te===0&&oe(e,i,A)||ke===0&&oe(a,A,e)||ge===0&&oe(a,A,i)}function C(e,i){const a=e.length,A=i?a:a-1;for(let $=0;$<A;$+=1)for(let te=$+2;te<A;te+=1)if(!(i&&$===0&&te===A-1)&&y(e[$],e[($+1)%a],e[te],e[(te+1)%a]))return!0;return!1}function D(e,i){if(!e||typeof e!="object")return;if(e.type==="FeatureCollection"&&Array.isArray(e.features)){e.features.forEach($=>D($,i));return}if(e.type==="Feature"){D(e.geometry,i);return}if(e.type==="GeometryCollection"&&Array.isArray(e.geometries)){e.geometries.forEach($=>D($,i));return}const a=$=>{if(Array.isArray($))for(let te=0;te<$.length;te+=1)!Array.isArray($[te])||!Number.isFinite($[te][0])||!Number.isFinite($[te][1])||(i.verts.push($[te]),te>0&&Array.isArray($[te-1])&&i.segs.push([$[te-1],$[te]]))},A=e.coordinates;e.type==="Point"?a([A]):e.type==="MultiPoint"?A.forEach($=>a([$])):e.type==="LineString"?a(A):e.type==="MultiLineString"||e.type==="Polygon"?A.forEach(a):e.type==="MultiPolygon"&&A.forEach($=>$.forEach(a))}function M(e){return JSON.parse(JSON.stringify(e))}function J(e){return Array.isArray(e)?e:e&&typeof e=="object"&&e.type==="FeatureCollection"&&Array.isArray(e.features)?e.features:null}function F(e){if(!e||typeof e!="object"||!Array.isArray(e.layers))return null;const i=e.layers.filter(A=>typeof A=="string"&&A);if(!i.length)return null;const a=Number.isFinite(e.tolerance)&&e.tolerance>0?Math.min(e.tolerance,100):S;return{layers:i,tolerance:a}}function re(e){const i={};return!e||typeof e!="object"||(Array.isArray(e.geometryTypes)&&(i.geometryTypes=e.geometryTypes.filter(a=>typeof a=="string")),Number.isFinite(e.maxVertices)&&e.maxVertices>=1&&(i.maxVertices=Math.floor(e.maxVertices)),Number.isFinite(e.minSegmentLength)&&e.minSegmentLength>0&&(i.minSegmentLength=e.minSegmentLength),e.noSelfIntersection===!0&&(i.noSelfIntersection=!0)),i}function z(e,i,a,A){const{format:$,text:te}=A;if(e==="circle"&&Number.isFinite(A.radius))return[Z(Math.PI*A.radius*A.radius,$),`${te("mapview.draw.perimeter")} ${W(2*Math.PI*A.radius,$)}`];if(e==="line"||i.length<3){const ke=[W(v(i),$)],ge=a||(i.length>2?[i[i.length-2],i[i.length-1]]:null);return ge&&i.length>2&&ke.push(`${te("mapview.draw.segment")} ${W(m(ge[0],ge[1]),$)}`),ke}return[Z(l(i),$),`${te("mapview.draw.perimeter")} ${W(v(d(i)),$)}`]}function U({map:e,deck:i,doc:a,theme:A,emit:$,pick:te,setLayers:ke,format:ge=x,text:ve=Pe=>Pe}){let Pe=null,Te="",_=null,pe={},me=[],ie=null,Q=null,ye=0,o=0,H=[0,114,178,90],s=[255,87,34,255],h=[255,87,34,110],O=[255,255,255,255],I=new Set,K=[],ee=[],E=null,G=null,Me=!1,k=!1,j=null,X={},ae=null,be=null,Se=null,Ae=0,ze=null,Be=null,qe=!1,Ue=null,We=!1,st={x:0,y:0},tt=!1,wt=null;const Mt=()=>(ye+=1,`draw-${ye}-${Math.random().toString(36).slice(2,8)}`),Nt=(B,ce,we={})=>({type:"Feature",id:Mt(),geometry:ce,properties:{...pe,...we,shape:B,readonly:!1}}),pt=()=>{const B=A()||{};H=Array.isArray(B.accent)?[B.accent[0],B.accent[1],B.accent[2],90]:H,s=Array.isArray(B.highlight)?B.highlight:s,h=[s[0],s[1],s[2],110],O=Array.isArray(B.halo)?[B.halo[0],B.halo[1],B.halo[2],255]:O,mt()},gt=(B,ce,we,De)=>{for(const Ee of B){const Ve=Ee.geometry&&Ee.geometry.type;Ve==="Polygon"?ce.push(Ee):Ve==="LineString"?we.push(Ee):Ve==="Point"&&De.push(Ee)}};function mt(){o+=1;const B=[],ce=[],we=[];if(gt(me,B,ce,we),Q)gt([Q.feature],B,ce,we);else if(ie){const Je=ae?[...ie.verts,ae]:ie.verts;ce.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:Je.length>1?Je:[Je[0],Je[0]]}});for(const St of ie.verts)we.push({type:"Feature",properties:{},geometry:{type:"Point",coordinates:St}})}const De=[],Ee={getFillColor:o,getLineColor:o,getLineWidth:o,getRadius:o},Ve=Je=>I.has(Je.id),rt={depthCompare:"always",depthWriteEnabled:!1};B.length&&De.push(new i.GeoJsonLayer({id:"lattice-mapview-draw-fill",data:B,pickable:!1,filled:!0,stroked:!0,parameters:rt,lineWidthMinPixels:2,lineWidthUnits:"pixels",getFillColor:Je=>Ve(Je)?h:H,getLineColor:()=>s,getLineWidth:Je=>Ve(Je)?4:2,updateTriggers:Ee})),ce.length&&De.push(new i.GeoJsonLayer({id:"lattice-mapview-draw-line",data:ce,pickable:!1,filled:!1,stroked:!0,parameters:rt,lineWidthMinPixels:2,lineWidthUnits:"pixels",getLineColor:()=>s,getLineWidth:Je=>Ve(Je)?4:2,updateTriggers:Ee})),we.length&&De.push(new i.ScatterplotLayer({id:"lattice-mapview-draw-point",data:we,pickable:!1,stroked:!0,parameters:rt,radiusUnits:"pixels",getRadius:Je=>Ve(Je)?8:5,lineWidthMinPixels:1,getFillColor:()=>s,getLineColor:Je=>Ve(Je)?O:[255,255,255,220],getPosition:Je=>Je.geometry.coordinates,updateTriggers:Ee}));const ft=Oe();ft.length&&De.push(new i.ScatterplotLayer({id:"lattice-mapview-draw-handle",data:ft,pickable:!1,stroked:!0,parameters:rt,radiusUnits:"pixels",getRadius:Je=>Je.mid?qe?9:4:qe?13:6,lineWidthUnits:"pixels",getLineWidth:2,getFillColor:Je=>Je.mid?h.slice(0,3).concat(170):O,getLineColor:()=>s,getPosition:Je=>Je.pos,updateTriggers:Ee}));const bt=[];be&&bt.push({pos:be,refused:!1}),Se&&bt.push({pos:Se,refused:!0}),bt.length&&De.push(new i.ScatterplotLayer({id:"lattice-mapview-draw-cue",data:bt,pickable:!1,stroked:!0,filled:!1,parameters:rt,radiusUnits:"pixels",getRadius:Je=>Je.refused?14:11,lineWidthUnits:"pixels",getLineWidth:Je=>Je.refused?4:3,getLineColor:Je=>Je.refused?s:[H[0],H[1],H[2],255],getPosition:Je=>Je.pos,updateTriggers:Ee})),ke(De)}const Ct=B=>{xe(),me.push(B),ae=null,be=null,Be=an(B),mt(),Dt(),$("draw:finish",{feature:M(B)})},kt=()=>{ie=null,Q=null,ae=null,be=null,Be=null,mt(),Dt()},dt=(B,ce)=>{try{B&&typeof B.enable=="function"&&typeof B.disable=="function"&&(ce?B.enable():B.disable())}catch{}};function Qe(B,ce){if(B!==null&&B!=="edit"&&!se.includes(B))return;kt(),_==="edit"&&B!=="edit"&&(Ce(!0),de([]),G=null),_=B,pe=ce&&typeof ce=="object"&&ce.properties&&typeof ce.properties=="object"?{...ce.properties}:{},j=F(ce&&ce.snap),X=re(ce&&ce.constraints),wt=null,Se=null,clearTimeout(Ae),Dt(),dt(e.doubleClickZoom,!_);const we=_==="circle"||_==="rectangle";dt(e.dragPan,!we),dt(e.dragRotate,!we),dt(e.boxZoom,!we&&_!=="edit"),It(_&&_!=="edit"?"crosshair":"")}function It(B){Te=B}function At(){return{type:"FeatureCollection",features:me.map(M)}}function jt(B){const ce=J(B);ce&&(kt(),Re(),me=ce.map(we=>{const De=we&&we.properties&&typeof we.properties=="object"?{...we.properties}:{};return De.readonly===void 0&&(De.readonly=!1),{type:"Feature",id:we&&we.id!==void 0&&we.id!==null?we.id:Mt(),geometry:we&&we.geometry?JSON.parse(JSON.stringify(we.geometry)):null,properties:De}}),mt())}function Wt(){kt(),Re(),me=[],mt()}const Bt=B=>{if(!ie||!ie.verts.length)return 1/0;const ce=e.project(ie.verts[0]);return Math.hypot(ce.x-B.x,ce.y-B.y)},Ft=()=>{const B=ie.verts.map(De=>[...De]),ce=_==="line"?{type:"LineString",coordinates:B}:{type:"Polygon",coordinates:[d(B)]},we=Nt(_,ce);ie=null,Ct(we)},Vt=(B,ce)=>{if(st=ce,Pe=null,!ie&&!on(_)){Jt("geometry-type",B);return}if(_==="point"){const Ee=Nt("point",{type:"Point",coordinates:B});$("draw:start",{mode:_,feature:M(Ee)}),Ct(Ee);return}if(!ie){ie={verts:[B]},Be=null,$("draw:start",{mode:_,feature:{type:"Feature",id:null,geometry:{type:"Point",coordinates:B},properties:{shape:_}}}),mt();return}const we=_==="polygon"?3:2;if(ie.verts.length>=we&&Bt(ce)<=ne){const Ee=sn();Ee?(Pe=ce,Jt(Ee,B)):Ft();return}const De=pn(B);if(De){Pe=ce,Jt(De,B);return}ie.verts.push(B),ae=null,be=null,$("draw:change",{mode:_,feature:{type:"Feature",id:null,geometry:{type:"LineString",coordinates:ie.verts.map(Ee=>[...Ee])},properties:{shape:_}}}),mt(),Dt()},Gt=B=>{if(Et(B.lngLat.lng,B.lngLat.lat,B.point),_==="edit"){Ye(B);return}_===null||_==="circle"||_==="rectangle"||B.originalEvent&&B.originalEvent.detail>=2||Vt(nn(B.point,void 0,B.lngLat).pos,B.point)};function Et(B,ce,we){const De=typeof te=="function"?te(we.x,we.y)||[]:[];$("map:click",{lng:B,lat:ce,features:De.map(Ee=>Ee&&Ee.object).filter(Ee=>Ee!=null)})}const _t=B=>{if(_===null||_==="point"||_==="circle"||_==="rectangle"||_==="edit"||!ie)return;if(typeof B.preventDefault=="function"&&B.preventDefault(),Pe&&B.point&&Math.hypot(B.point.x-Pe.x,B.point.y-Pe.y)<=ne){Pe=null;return}const ce=ie.verts.length;if(ce>1){const Ee=je(ie.verts[ce-1]),Ve=je(ie.verts[ce-2]);Math.hypot(Ee.x-Ve.x,Ee.y-Ve.y)<=ne&&ie.verts.pop()}const we=_==="polygon"?3:2;if(ie.verts.length<we){kt();return}const De=sn();if(De){Jt(De,ie.verts[ie.verts.length-1]);return}Ft()},Ht=B=>{if(_!=="circle"&&_!=="rectangle")return;const ce=[B.lngLat.lng,B.lngLat.lat];if(!on(_)){Jt("geometry-type",ce);return}Be=null;const we=_==="circle"?{type:"Polygon",coordinates:[w(ce,0)]}:{type:"Polygon",coordinates:[r(ce,ce)]},De=Nt(_,we,_==="circle"?{center:[...ce],radius:0}:{});Q={start:ce,feature:De},$("draw:start",{mode:_,feature:M(De)}),mt()},Kt=B=>{if(_==="edit"&&!E){const we=Ke(B.point);It(we?we.kind==="body"&&cn(we.f)?"move":"pointer":"")}if(!Q){ln(B);return}B.point&&(st=B.point);const ce=[B.lngLat.lng,B.lngLat.lat];if(_==="circle"){const we=m(Q.start,ce);Q.feature.geometry={type:"Polygon",coordinates:[w(Q.start,we)]},Q.feature.properties.radius=we}else Q.feature.geometry={type:"Polygon",coordinates:[r(Q.start,ce)]};$("draw:change",{mode:_,feature:M(Q.feature)}),mt(),Dt()},Xt=()=>{if(!Q)return;const B=Q.feature,ce=_==="circle"?!(B.properties.radius>0):Qt(B.geometry.coordinates[0][0],B.geometry.coordinates[0][2]);if(Q=null,ce){mt(),Dt();return}Ct(B)};function Qt(B,ce){return B[0]===ce[0]&&B[1]===ce[1]}const hn=(B,ce)=>{const we={verts:[],segs:[]},{layers:De,tolerance:Ee}=j;for(const Ve of me)Ve.id!==ce&&Ve.properties&&De.includes(Ve.properties.layer)&&D(Ve.geometry,we);for(const Ve of De){let rt=null;try{rt=typeof e.getLayer=="function"?e.getLayer(Ve):null}catch{rt=null}if(!rt)continue;let ft=null;try{const bt=e.getSource(rt.source);ft=bt&&bt._data}catch{ft=null}if(ft&&typeof ft=="object"){D(ft,we);continue}try{const bt=e.queryRenderedFeatures([[B.x-Ee,B.y-Ee],[B.x+Ee,B.y+Ee]],{layers:[Ve]});for(const Je of bt)D(Je.geometry,we)}catch{}}return we},fn=(B,ce)=>{if(!j)return null;const we=j.tolerance,De=hn(B,ce);let Ee=null,Ve=we;for(const bt of De.verts){const Je=je(bt),St=Math.hypot(Je.x-B.x,Je.y-B.y);St<=Ve&&(Ee=bt,Ve=St)}if(Ee)return{pos:[Ee[0],Ee[1]],kind:"vertex"};let rt=null;Ve=we;for(const[bt,Je]of De.segs){const St=je(bt),un=je(Je),Ut=Fe(B,St,un);if(Ut>Ve)continue;const qt=un.x-St.x,tn=un.y-St.y,wn=qt*qt+tn*tn,mn=wn===0?0:Math.max(0,Math.min(1,((B.x-St.x)*qt+(B.y-St.y)*tn)/wn));rt=[St.x+mn*qt,St.y+mn*tn],Ve=Ut}if(!rt)return null;const ft=e.unproject(rt);return{pos:[ft.lng,ft.lat],kind:"segment"}};function nn(B,ce,we){const De=fn(B,ce);if(De)return{pos:De.pos,snapped:!0};const Ee=we||e.unproject([B.x,B.y]);return{pos:[Ee.lng,Ee.lat],snapped:!1}}const on=B=>{const ce=X.geometryTypes;return!Array.isArray(ce)||ce.includes(P[B])},pn=B=>{const ce=X,we=ie.verts,De=we[we.length-1];if(ce.maxVertices!==void 0&&we.length+1>ce.maxVertices)return"max-vertices";if(ce.minSegmentLength!==void 0&&De&&m(De,B)<ce.minSegmentLength)return"min-segment-length";if(ce.noSelfIntersection&&_==="polygon"&&we.length>=2){for(let Ee=0;Ee<we.length-2;Ee+=1)if(y(we[Ee],we[Ee+1],De,B))return"self-intersection";for(let Ee=1;Ee<we.length-1;Ee+=1)if(y(we[Ee],we[Ee+1],B,we[0]))return"self-intersection"}return null},sn=()=>{const B=ie.verts,ce=X.minSegmentLength;return _==="polygon"&&ce!==void 0&&B.length>1&&m(B[B.length-1],B[0])<ce?"min-segment-length":null},Yt=(B,ce,we)=>{const De=X,Ee=rn(B).slice();Ee[ce]=we;const Ve=B.geometry.type==="Polygon";if(De.minSegmentLength!==void 0){const rt=ce>0?Ee[ce-1]:Ve?Ee[Ee.length-1]:null,ft=ce<Ee.length-1?Ee[ce+1]:Ve?Ee[0]:null;if(rt&&m(rt,we)<De.minSegmentLength||ft&&m(ft,we)<De.minSegmentLength)return"min-segment-length"}return De.noSelfIntersection&&Ve&&C(Ee,!0)?"self-intersection":null};function Jt(B,ce){wt=B,Se=ce,clearTimeout(Ae),Ae=setTimeout(()=>{wt=null,Se=null,mt(),Dt()},g),$("draw:refused",{mode:_,rule:B,position:[ce[0],ce[1]]}),mt(),Dt()}function an(B,ce){const we=B.geometry,De=B.properties&&B.properties.shape;if(!we)return null;const Ee={format:ge,text:ve,radius:De==="circle"&&B.properties?B.properties.radius:void 0};if(we.type==="LineString"){const Ve=ce===void 0?null:ce>0?[we.coordinates[ce-1],we.coordinates[ce]]:[we.coordinates[0],we.coordinates[1]];return z("line",we.coordinates,Ve,Ee)}return we.type==="Polygon"?z(De==="circle"?"circle":"polygon",we.coordinates[0].slice(0,-1),null,Ee):null}const gn=()=>{if(ze)return ze;const B=typeof e.getContainer=="function"?e.getContainer():null;return!B||!a||typeof a.createElement!="function"?null:(ze=a.createElement("div"),ze.className="lat-mapview__readout",ze.hidden=!0,ze.style.cssText=`position:absolute;left:0;top:0;z-index:4;pointer-events:none;white-space:nowrap;padding:4px 8px;line-height:1.4;font-variant-numeric:tabular-nums;${Y("background:var(--lattice-map-popup-bg);color:var(--lattice-map-popup-fg);font-family:var(--lattice-map-font);font-size:var(--lattice-map-font-size-sm);border:1px solid var(--lattice-map-border);border-radius:var(--lattice-map-radius);box-shadow:var(--lattice-map-shadow)")}`,B.appendChild(ze),ze)};function Dt(){let B=null;const ce={format:ge,text:ve};if(E){const Ut=en(E.ids[0]);B=Ut?an(Ut,E.kind==="vertex"?E.index:void 0):null}else if(Q)B=an(Q.feature);else if(ie){const Ut=ie.verts,qt=ae&&!Qt(ae,Ut[Ut.length-1])?[...Ut,ae]:Ut;B=_==="line"||_==="polygon"?z(_,qt,null,ce):null}else B=Be;const we=gn();if(!we)return;if((!B||!B.length)&&!wt){we.hidden=!0;return}const De=wt?[ve(`mapview.draw.refused.${wt}`),...B||[]]:B||[];we.textContent="",De.forEach((Ut,qt)=>{const tn=a.createElement("div");tn.textContent=Ut,wt&&qt===0&&tn.setAttribute("data-rule",wt),we.appendChild(tn)}),we.style.borderColor=wt?Y("var(--lattice-map-highlight)"):"",wt?we.setAttribute("data-refused",wt):we.removeAttribute("data-refused"),we.hidden=!1;const Ee=e.getContainer(),Ve=Ee.clientWidth,rt=Ee.clientHeight,ft=we.offsetWidth,bt=we.offsetHeight,Je=16;let St=st.x+Je;St+ft>Ve-4&&(St=st.x-Je-ft);const un=tt?st.y-bt-3*Je:st.y+Je;we.style.left=`${Math.max(4,Math.min(St,Ve-ft-4))}px`,we.style.top=`${Math.max(4,Math.min(un,rt-bt-4))}px`}function ln(B){if(!B.point)return;st=B.point,tt=!1;const ce=Be!==null;if(Be=null,_!=="point"&&_!=="line"&&_!=="polygon"){ce&&Dt();return}const we=nn(B.point,void 0,B.lngLat),De=we.snapped?we.pos:null,Ee=De===null!=(be===null)||De!==null&&be!==null&&!Qt(De,be);be=De,ie&&(ae=we.pos),(ie||Ee)&&mt(),Dt()}const en=B=>me.find(ce=>ce.id===B),cn=B=>!(B.properties&&B.properties.readonly),dn=B=>cn(B)&&!!B.geometry&&B.properties.shape!=="circle"&&(B.geometry.type==="LineString"||B.geometry.type==="Polygon"),rn=B=>B.geometry.type==="Polygon"?B.geometry.coordinates[0].slice(0,-1):B.geometry.coordinates,b=B=>{const ce=rn(B),we=B.geometry.type==="Polygon"?ce.length:ce.length-1;return Array.from({length:we},(De,Ee)=>{const Ve=ce[Ee],rt=ce[(Ee+1)%ce.length];return[(Ve[0]+rt[0])/2,(Ve[1]+rt[1])/2]})},Oe=()=>{const B=[];for(const ce of me)if(!(!I.has(ce.id)||!dn(ce))){for(const we of rn(ce))B.push({pos:we,mid:!1});for(const we of b(ce))B.push({pos:we,mid:!0})}return B};function de(B){const ce=new Set(B),we=ce.size!==I.size||[...ce].some(De=>!I.has(De));I=ce,we&&$("feature:select",{ids:[...ce]}),mt()}function xe(B){K.push(B||me.map(M)),K.length>N&&K.shift(),ee=[]}const Ne=B=>{me=B,G=null,de([...I].filter(ce=>en(ce)))};function $e(){E||!K.length||(ee.push(me.map(M)),Ne(K.pop()))}function _e(){E||!ee.length||(K.push(me.map(M)),Ne(ee.pop()))}function Re(){Ce(!0),K=[],ee=[],G=null,de([])}const je=B=>{const ce=e.project(B);return{x:ce.x,y:ce.y}},Fe=(B,ce,we)=>{const De=we.x-ce.x,Ee=we.y-ce.y,Ve=De*De+Ee*Ee,rt=Ve===0?0:Math.max(0,Math.min(1,((B.x-ce.x)*De+(B.y-ce.y)*Ee)/Ve));return Math.hypot(B.x-(ce.x+rt*De),B.y-(ce.y+rt*Ee))},Ge=(B,ce)=>{let we=!1;for(let De=0,Ee=ce.length-1;De<ce.length;Ee=De,De+=1){const Ve=ce[De],rt=ce[Ee];Ve.y>B.y!=rt.y>B.y&&B.x<(rt.x-Ve.x)*(B.y-Ve.y)/(rt.y-Ve.y)+Ve.x&&(we=!we)}return we},Ke=(B,ce=!1)=>{const we=ce?T:n,De=ce?q:V,Ee=me.filter(Ve=>I.has(Ve.id)&&dn(Ve));for(const Ve of Ee){const rt=rn(Ve);for(let ft=0;ft<rt.length;ft+=1)if(Math.hypot(je(rt[ft]).x-B.x,je(rt[ft]).y-B.y)<=we)return{kind:"vertex",f:Ve,index:ft}}for(const Ve of Ee){const rt=b(Ve);for(let ft=0;ft<rt.length;ft+=1)if(Math.hypot(je(rt[ft]).x-B.x,je(rt[ft]).y-B.y)<=we)return{kind:"mid",f:Ve,index:ft}}for(let Ve=me.length-1;Ve>=0;Ve-=1){const rt=me[Ve],ft=rt.geometry;if(!ft)continue;if(ft.type==="Point"){if(Math.hypot(je(ft.coordinates).x-B.x,je(ft.coordinates).y-B.y)<=De+2)return{kind:"body",f:rt,index:-1};continue}const bt=(ft.type==="Polygon"?ft.coordinates[0]:ft.coordinates).map(je);let Je=ft.type==="Polygon"&&Ge(B,bt);for(let St=0;!Je&&St<bt.length-1;St+=1)Je=Fe(B,bt[St],bt[St+1])<=De;if(Je)return{kind:"body",f:rt,index:-1}}return null};function nt(){const B=me.filter(we=>I.has(we.id)&&cn(we)).map(we=>we.id);if(!B.length)return;xe();const ce=[...I].filter(we=>!B.includes(we));me=me.filter(we=>!B.includes(we.id)),G=null,$("feature:delete",{ids:B}),de(ce)}function Xe(B,ce){const we=en(B);if(!we||!dn(we))return!1;const De=rn(we);if(De.length<=(we.geometry.type==="Polygon"?3:2)||ce<0||ce>=De.length)return!1;xe();const Ee=De.filter((Ve,rt)=>rt!==ce);return we.geometry=we.geometry.type==="Polygon"?{type:"Polygon",coordinates:[d(Ee)]}:{type:"LineString",coordinates:Ee},G=null,mt(),$("edit:change",{id:we.id,geometry:JSON.parse(JSON.stringify(we.geometry)),feature:M(we)}),!0}const at=(B,ce,we)=>{if(typeof B[0]=="number"){const De=je(B),Ee=e.unproject([De.x+ce,De.y+we]);return[Ee.lng,Ee.lat]}return B.map(De=>at(De,ce,we))},ct=(B,ce)=>{const we=e.getCanvas().getBoundingClientRect();return{x:B-we.left,y:ce-we.top}},lt=B=>{E&&yt(ct(B.clientX,B.clientY))};function yt(B){if(!E)return;st=B;const ce=B.x-E.startPx.x,we=B.y-E.startPx.y;if(!(!E.moved&&!E.reach&&Math.hypot(ce,we)<2)){if(E.reach=!0,E.kind==="vertex"){const De=en(E.ids[0]);if(!De)return;const Ee=nn(B,De.id);be=Ee.snapped?Ee.pos:null;const Ve=Yt(De,E.index,Ee.pos);if(Ve){E.refused!==Ve&&(E.refused=Ve,Jt(Ve,Ee.pos)),mt();return}E.refused=null,E.moved=!0;const rt=De.geometry.type==="Polygon"?De.geometry.coordinates[0]:De.geometry.coordinates;rt[E.index]=Ee.pos,De.geometry.type==="Polygon"&&E.index===0&&(rt[rt.length-1]=[...Ee.pos])}else{E.moved=!0;for(const De of E.ids){const Ee=en(De),Ve=E.originals.get(De);!Ee||!Ve||(Ee.geometry={type:Ve.geometry.type,coordinates:at(Ve.geometry.coordinates,ce,we)},Ve.center&&(Ee.properties.center=at(Ve.center,ce,we)))}}mt(),Dt()}}const he=()=>Ce(!1);function Ce(B){if(!E)return;const ce=E;if(E=null,be=null,a&&typeof a.removeEventListener=="function"&&(a.removeEventListener("mousemove",lt),a.removeEventListener("mouseup",he)),dt(e.dragPan,!0),B){me=ce.pre,mt(),Dt();return}if(Dt(),!ce.moved&&!ce.inserted){mt();return}xe(ce.pre),ce.moved&&(Me=!0,setTimeout(()=>{Me=!1},0));for(const we of ce.ids){const De=en(we);De&&$("edit:change",{id:De.id,geometry:JSON.parse(JSON.stringify(De.geometry)),feature:M(De)})}mt()}const He=B=>{_!=="edit"||B.button!==0||E||Ie(ct(B.clientX,B.clientY),B,()=>{B.stopPropagation()},"mouse")};function Ie(B,ce,we,De){const Ee=Ke(B,De==="touch");if(!Ee)return!1;const Ve=me.map(M);if(Ee.kind==="vertex"&&ce.altKey)return we(),Xe(Ee.f.id,Ee.index),Me=!0,setTimeout(()=>{Me=!1},0),!0;let rt=null;if(Ee.kind==="vertex"||Ee.kind==="mid"){we();let bt=Ee.index;if(Ee.kind==="mid"){bt+=1;const Je=b(Ee.f)[Ee.index];(Ee.f.geometry.type==="Polygon"?Ee.f.geometry.coordinates[0]:Ee.f.geometry.coordinates).splice(bt,0,Je),mt()}G={id:Ee.f.id,index:bt},rt={kind:"vertex",ids:[Ee.f.id],index:bt,inserted:Ee.kind==="mid"}}else{G=null,k=!0,a.addEventListener("mouseup",()=>setTimeout(()=>{k=!1},0),{once:!0}),ce.shiftKey?de(I.has(Ee.f.id)?[...I].filter(Je=>Je!==Ee.f.id):[...I,Ee.f.id]):I.has(Ee.f.id)||de([Ee.f.id]);const bt=me.filter(Je=>I.has(Je.id)&&cn(Je)).map(Je=>Je.id);if(!I.has(Ee.f.id)||!bt.includes(Ee.f.id))return!1;we(),rt={kind:"move",ids:bt,index:-1,inserted:!1}}dt(e.dragPan,!1);const ft=new Map;for(const bt of rt.ids){const Je=Ve.find(St=>St.id===bt);Je&&ft.set(bt,{geometry:Je.geometry,center:Je.properties.center})}return E={...rt,pre:Ve,startPx:B,originals:ft,moved:!1,input:De},De==="mouse"&&(a.addEventListener("mousemove",lt),a.addEventListener("mouseup",he)),!0}const Ye=B=>{if(Me)return;const ce=Ke(B.point),we=!!(B.originalEvent&&B.originalEvent.shiftKey);if(ce){ce.kind==="body"&&!k&&!I.has(ce.f.id)&&de(we?[...I,ce.f.id]:[ce.f.id]);return}we||(G=null,de([]))},ot=B=>{const ce=B.target;if(!ce||ce===a||ce===a.body||ce===a.documentElement)return!0;if(ce.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(ce.tagName||""))return!1;const we=typeof e.getContainer=="function"?e.getContainer():null;return!we||typeof we.contains=="function"&&we.contains(ce)},ut=B=>{if(B.key==="Escape"){if(E){Ce(!0);return}if(ie||Q){kt();return}_==="edit"&&(G=null,de([]),mt());return}if(_===null||!ot(B))return;const ce=B.key==="z"||B.key==="Z"||B.code==="KeyZ",we=B.key==="y"||B.key==="Y"||B.code==="KeyY";if((B.metaKey||B.ctrlKey)&&!B.altKey&&(ce||we)){B.preventDefault(),we||B.shiftKey?_e():$e();return}_==="edit"&&(B.key==="Delete"||B.key==="Backspace")&&(B.preventDefault(),G?Xe(G.id,G.index):nt())},Ot=B=>{const ce=B.touches&&B.touches[0]||B.changedTouches[0];return ct(ce.clientX,ce.clientY)},it=()=>{Ue&&clearTimeout(Ue.timer),Ue=null},Pt=()=>{if(!Ue||We)return;if(Ue.fired=!0,_==="edit"){const we=E;if(!we||we.moved||we.kind!=="vertex"||we.inserted)return;Ce(!0),Xe(we.ids[0],we.index);return}if(!ie)return;const B=_==="polygon"?3:2;if(ie.verts.length<B)return;const ce=sn();ce?Jt(ce,ie.verts[ie.verts.length-1]):Ft()},Rt=B=>{if(qe||(qe=!0,mt()),B.touches.length>1){We=!0,it(),E&&Ce(!0),Q&&kt();return}if(We=!1,_===null)return;const ce=Ot(B);st=ce,tt=!0,Be=null;const we=()=>{B.stopPropagation(),B.cancelable&&B.preventDefault()};if(Ue={startPx:ce,moved:!1,timer:0,fired:!1,mode:_},_==="edit"){if(E||!Ie(ce,{},we,"touch")){it();return}Ue.timer=setTimeout(Pt,f);return}if(_==="circle"||_==="rectangle"){const De=e.unproject([ce.x,ce.y]);Ht({lngLat:De}),Q&&we();return}ie&&(Ue.timer=setTimeout(Pt,f))},$t=B=>{if(We||B.touches.length!==1)return;const ce=Ot(B);if(Ue&&!Ue.moved&&Math.hypot(ce.x-Ue.startPx.x,ce.y-Ue.startPx.y)>R&&(Ue.moved=!0,clearTimeout(Ue.timer)),E&&E.input==="touch")B.cancelable&&B.preventDefault(),yt(ce);else if(Q){B.cancelable&&B.preventDefault(),st=ce;const we=e.unproject([ce.x,ce.y]);Kt({lngLat:we,point:ce})}},vt=B=>{if(B.touches.length>0)return;const ce=We;We=!1;const we=Ue;if(it(),ce)return;if(E&&E.input==="touch"){B.cancelable&&B.preventDefault(),Ce(!1);return}if(Q){B.cancelable&&B.preventDefault(),Xt();return}if(!we||we.fired||we.moved||_!=="point"&&_!=="line"&&_!=="polygon")return;B.cancelable&&B.preventDefault();const De=we.startPx,Ee=e.unproject([De.x,De.y]);Et(Ee.lng,Ee.lat,De),Vt(nn(De).pos,De)},xt=()=>{We=!1,it(),E&&E.input==="touch"&&Ce(!0),Q&&kt()};e.on("click",Gt),e.on("dblclick",_t),e.on("mousedown",Ht),e.on("mousemove",Kt),e.on("mouseup",Xt),a&&typeof a.addEventListener=="function"&&a.addEventListener("keydown",ut);const Zt=typeof e.getCanvasContainer=="function"?e.getCanvasContainer():null;Zt&&Zt.addEventListener("mousedown",He,!0);const bn=[["touchstart",Rt],["touchmove",$t],["touchend",vt],["touchcancel",xt]];if(Zt)for(const[B,ce]of bn)Zt.addEventListener(B,ce,{capture:!0,passive:!1});return{setMode:Qe,getFeatures:At,setFeatures:jt,clear:Wt,undo:$e,redo:_e,applyTheme:pt,active:()=>_!==null,cursor:()=>Te,mode:()=>_,shapeAt:B=>Ke(B)!==null,destroy(){if(e.off("click",Gt),e.off("dblclick",_t),e.off("mousedown",Ht),e.off("mousemove",Kt),e.off("mouseup",Xt),a&&typeof a.removeEventListener=="function"&&a.removeEventListener("keydown",ut),Ce(!0),Zt&&Zt.removeEventListener("mousedown",He,!0),Zt)for(const[B,ce]of bn)Zt.removeEventListener(B,ce,{capture:!0});it(),clearTimeout(Ae),ze&&ze.parentNode&&ze.parentNode.removeChild(ze),ze=null,It(""),ke([])}}}const L=U}),Ze("packages/modules/mapview/rowmove.js",function(t,ue){"use strict";Object.defineProperty(t,"createRowMove",{enumerable:!0,get:function(){return se}}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return ne}});const Le=10,Y=2,fe=6;function se({map:n,doc:V,grid:T,draw:q,enabled:R,columns:f,items:S,redraw:g}){let P="",N=new Map,p=null;const u=(y,C)=>{const D=n.getCanvas().getBoundingClientRect();return{x:y-D.left,y:C-D.top}},m=()=>R()&&q.mode()==="edit"&&!!f(),c=y=>{if(N.has(y.key))return N.get(y.key);const C=f();let D=!1;try{D=!!C&&!!C.lat&&!!C.lon&&["lon","lat"].every((M,J)=>{const F=T.edit.previewPaste({key:y.key,colId:C[M]},String(y.position[J]),{rows:1,columns:1});return F.changes.length===1&&F.rejected.length===0})}catch{D=!1}return N.set(y.key,D),D},w=y=>{let C=null,D=Le;for(const M of S()){if(!M.position||M.isRoute||M.layer!=="point"&&M.layer!=="column")continue;const J=n.project(M.position),F=Math.hypot(J.x-y.x,J.y-y.y);F<=D&&(C=M,D=F)}return C&&c(C)?C:null},d=y=>{if(p)return;const C=u(y.clientX,y.clientY);P=m()&&!q.shapeAt(C)&&w(C)?"move":""},r=(y,C)=>{y.position=C,g()},v=(y,C,D)=>{const M=f(),J=[{key:y.key,colId:M.lat,value:D[1]},{key:y.key,colId:M.lon,value:D[0]}];try{if(!J.every(U=>{const L=T.edit.previewPaste({key:U.key,colId:U.colId},String(U.value),{rows:1,columns:1});return L.changes.length!==1||L.rejected.length!==0?!1:!(T.validation&&typeof T.validation.check=="function"?T.validation.check(U.colId,U.value,y.row):null)})){r(y,C);return}const re=U=>{U!==2&&(Number(U)>0&&T.edit&&typeof T.edit.undo=="function"&&T.edit.undo(),r(y,C))},z=T.edit.setCells(J,"cell",{origin:"user"});z&&typeof z.then=="function"?z.then(re,()=>r(y,C)):re(z)}catch{r(y,C)}},l=y=>{if(!p)return;const C=u(y.clientX,y.clientY);if(!p.moved&&Math.hypot(C.x-p.startPx.x,C.y-p.startPx.y)<Y)return;p.moved=!0;const D=n.unproject([C.x,C.y]);p.item.position=[D.lng,D.lat],g()},x=()=>{V.removeEventListener("mousemove",l),V.removeEventListener("mouseup",W),V.removeEventListener("keydown",Z);try{n.dragPan&&typeof n.dragPan.enable=="function"&&n.dragPan.enable()}catch{}};function W(){if(!p)return;const{item:y,from:C,moved:D}=p,M=y.position;p=null,x(),D&&v(y,C,[Number(M[0].toFixed(fe)),Number(M[1].toFixed(fe))])}function Z(y){if(y.key!=="Escape"||!p)return;const{item:C,from:D}=p;p=null,x(),r(C,D)}const le=y=>{if(p||y.button!==0||!m())return;const C=u(y.clientX,y.clientY);if(q.shapeAt(C))return;const D=w(C);if(D){y.stopPropagation();try{n.dragPan&&typeof n.dragPan.disable=="function"&&n.dragPan.disable()}catch{}p={item:D,from:D.position,startPx:C,moved:!1},V.addEventListener("mousemove",l),V.addEventListener("mouseup",W),V.addEventListener("keydown",Z)}},oe=typeof n.getCanvasContainer=="function"?n.getCanvasContainer():null;return oe&&oe.addEventListener("mousedown",le,!0),oe&&oe.addEventListener("mousemove",d,!0),{cursor:()=>m()?P:"",invalidate(){N=new Map},destroy(){if(p){const{item:y,from:C}=p;p=null,x(),y.position=C}oe&&oe.removeEventListener("mousedown",le,!0),oe&&oe.removeEventListener("mousemove",d,!0)}}}const ne=se}),Ze("packages/modules/mapview/index.js",function(t,ue){"use strict";Object.defineProperty(t,"createMapView",{enumerable:!0,get:function(){return me}}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return ie}});const Y=ue("packages/core/src/internal/warn.js").warnOnce,se=ue("packages/modules/shared/map-binding.js").createMapFeed,ne=ue("packages/modules/mapview/model.js"),n=ne.resolveGeometry,V=ne.checkLayer,T=ne.buildItems,q=ne.drawColour,R=ne.boundsOf,f=ne.toDeckColour,S=ne.tooltipColumns,g=ne.tooltipLines,P=ne.pathTimestamps,N=ne.isSelected,p=ne.HIGHLIGHT,u=ne.HALO,m=ne.FALLBACK_COLOUR,c=ne.DEFAULT_BASEMAP,w=ne.DEFAULT_DARK_BASEMAP,d=ne.BUILDINGS_LAYER,r=ne.ROUTE_ELEVATION,v=ne.POINT_ELEVATION,l=ne.ROUTE_WIDTH_RANGE,x=ne.OVER_BUILDINGS,W=ue("packages/modules/mapview/icons.js"),Z=W.createAtlas,le=W.badgeCell,oe=ue("packages/modules/mapview/theme.js"),y=oe.readRole,C=oe.readRoleCss,M=ue("packages/modules/mapview/roles.js").BUILDING,J=ue("packages/modules/mapview/view.js"),F=J.place,re=J.themeMode,z=J.message,L=ue("packages/modules/mapview/styles.js").NS,i=ue("packages/modules/shared/require-core.js").coreMissing,A=ue("packages/dom/src/watermark.js").mountViewWatermark,te=ue("packages/modules/mapview/draw.js").createDraw,ge=ue("packages/modules/mapview/rowmove.js").createRowMove;i()&&Y("mapview:requires-core","the map view module needs the Lattice core; load lattice-grid (or its script build) before modules/mapview.");const ve=Object.freeze(["feature:click","feature:hover","draw","load","close","map:click","draw:start","draw:change","draw:finish","edit:change","feature:select","feature:delete","draw:refused"]);function Pe(Q,ye,o){const H=o==="dark"||o==="light"?o:re(Q,ye);let s=null,h=null,O=null,I=null,K=null,ee=null;try{if(Q&&ye&&typeof ye.getComputedStyle=="function"){s=y(Q,ye,"--lattice-map-layer-fill",220),h=y(Q,ye,"--lattice-map-highlight",255),O=y(Q,ye,"--lattice-map-halo",180),I=C(Q,ye,"--lattice-map-building"),K=Array.from({length:8},(G,Me)=>y(Q,ye,`--lattice-chart-${Me+1}`,230));const E=[y(Q,ye,"--lattice-chart-sequential-start"),y(Q,ye,"--lattice-chart-sequential-end")];E.every(Boolean)&&(ee=E),K.every(Boolean)||(K=null)}}catch{}return{mode:H,accent:s||[...m],highlight:h||[...p],halo:O||[...u],series:K,sequential:ee,building:o==="dark"||o==="light"?M[o]:I||M[H]}}function Te(Q,ye=null){let o=!1;const H={drawn:0,skipped:0,matched:0,rows:0,layers:{},computed:"client"};return{element:ye,map:null,overlay:null,getMap(){return null},draw:{setMode(){},getFeatures(){return{type:"FeatureCollection",features:[]}},setFeatures(){},clear(){},undo(){},redo(){}},update(){},flyTo(){},setLayer(){},provenance(){return{...H}},layers(){return[]},legend(){return{colours:[],dashes:[],sections:[]}},on(){return()=>{}},off(){},destroy(){o||(o=!0,Q&&Q())}}}const _=24;function pe(Q){if(Q.radiusUnits==="pixels")return{radiusUnits:"pixels",radiusMinPixels:0};const ye=Number.isFinite(Q.radiusMaxPixels)&&Q.radiusMaxPixels>0?Q.radiusMaxPixels:_;return{radiusUnits:"meters",radiusMinPixels:3,radiusMaxPixels:Math.max(3,ye)}}function me(Q,ye){let o={...ye&&typeof ye=="object"?ye:{}};if(!Q||!Q.rows||!Q.columns)return Y("mapview:grid","createMapView: the first argument is not a grid; pass the grid whose rows the map shows. Nothing was drawn."),Te();let H=n(Q,o.geometry);if(typeof H=="string")return Y("mapview:geometry",`createMapView: the grid has no place to draw rows at: ${H}. Nothing was drawn.`),Te();V(o.layer);const s=o.libs&&typeof o.libs=="object"?o.libs:{},h=s.deck!==void 0?s.deck:globalThis.deck,O=s.maplibregl!==void 0?s.maplibregl:globalThis.maplibregl,I=new Map(ve.map(he=>[he,new Set])),K=(he,Ce)=>{for(const He of[...I.get(he)||[]])try{He(Ce)}catch(Ie){Y(`mapview:listener:${he}`,`createMapView: a "${he}" listener threw: ${Ie&&Ie.message}`)}};let ee=!1,E=null,G=null;const k=F(Q,o,{onResize:()=>{if(G&&typeof G.resize=="function")try{G.resize()}catch{}},onClose(){K("close",{}),E&&E.destroy()}});if(typeof k=="string")return Y("mapview:container",`createMapView: the map has nowhere to go: ${k}. Nothing was drawn.`),Te();const j=[];if((!h||typeof h.MapboxOverlay!="function")&&j.push("deck.gl (with MapboxOverlay)"),(!O||typeof O.Map!="function")&&j.push("MapLibre GL (maplibregl.Map)"),j.length){Y("mapview:libs",`createMapView: ${j.join(" and ")} ${j.length>1?"are":"is"} not on the page; load the UMD build (it sets the global) or pass options.libs = { deck, maplibregl }. The map was left empty.`);const he=A(k.root,o).destroy;return Te(()=>{he(),k.unmount()},k.root)}const{win:X,doc:ae}=k;let be=Pe(k.root,X,o.theme);const Se=()=>o.basemap!==void 0&&o.basemap!==null?o.basemap:be.mode==="dark"?w:c,Ae=o.view&&typeof o.view=="object"?o.view:null;G=new O.Map({container:k.mapEl,style:Se(),center:Ae&&Array.isArray(Ae.center)?Ae.center:[0,20],zoom:Ae&&Number.isFinite(Ae.zoom)?Ae.zoom:1,pitch:Ae&&Number.isFinite(Ae.pitch)?Ae.pitch:o.elevation!==void 0||o.buildings?45:0,bearing:Ae&&Number.isFinite(Ae.bearing)?Ae.bearing:0});let ze=new Set(Q.selection&&typeof Q.selection.keys=="function"?Q.selection.keys():[]),Be={items:[],skipped:0,byLayer:{point:[],column:[],polygon:[],path:[]},legend:[],dashLegend:[],legendSections:[],dashed:!1,routes:{drawn:0,skipped:0,rebuilt:0},icon:null,paths:[]},qe=new Map,Ue={drawn:0,skipped:0,matched:0,rows:0,layers:{},computed:"client"},We=[],st=[],tt=[],wt=[],Mt=0,Nt=0,pt=0,gt=0,mt=0,Ct=!!Ae,kt=!1,dt=1,Qe=S(Q,o.tooltip,H.columns,H.route?H.route.by:null);const It=new Map,At=Z(Q,X,ae,()=>ln());let jt=null;const Wt=he=>typeof X.requestAnimationFrame=="function"?X.requestAnimationFrame(he):setTimeout(()=>he(Date.now()),16),Bt=he=>{typeof X.requestAnimationFrame=="function"&&typeof X.cancelAnimationFrame=="function"?X.cancelAnimationFrame(he):clearTimeout(he)},Ft=()=>{try{return!!(X&&typeof X.matchMedia=="function"&&X.matchMedia("(prefers-reduced-motion: reduce)").matches)}catch{return!1}},Vt=()=>{const he=o.flow;if(!he)return null;const Ce=he===!0?{}:he,He=Number.isFinite(Ce.speed)&&Ce.speed>0?Ce.speed:.25,Ie=Number.isFinite(Ce.trail)&&Ce.trail>0?Math.min(1,Ce.trail):.3;return{speed:He,trail:Ie}},Gt=he=>{if(!(!he||typeof he!="object"))return he.item?he.item.key:he.properties&&he.properties.__mapview?he.properties.key:he.__mapview?he.key:void 0},Et=()=>{const{byLayer:he}=Be,Ce={getFillColor:Mt,getLineColor:Mt,getColor:Mt,getPosition:Nt},He=it=>q(it,be),Ie=[],Ye=[];if(he.polygon.length){const it=o.elevation!==void 0&&o.elevation!==null;Ie.push(new h.GeoJsonLayer({id:"lattice-mapview-polygon",data:he.polygon.map(Pt=>Pt.feature),pickable:!0,filled:!0,stroked:!0,extruded:it,wireframe:!1,elevationScale:Number.isFinite(o.elevationScale)?o.elevationScale:1,lineWidthMinPixels:1,...it?{}:{parameters:x},getElevation:Pt=>Pt.properties.elevation,getFillColor:Pt=>{const Rt=He(Pt.properties);return[Rt[0],Rt[1],Rt[2],Math.min(Rt[3]??255,170)]},getLineColor:Pt=>Pt.properties.selected?be.highlight:He(Pt.properties),updateTriggers:Ce}))}if(he.path.length){const[it,Pt]=l,Rt=vt=>Math.max(it,Math.min(Pt,(vt.item.selected?vt.item.width+3:vt.item.width)*dt));let $t={};Be.dashed&&(typeof h.PathStyleExtension=="function"?$t={extensions:[new h.PathStyleExtension({dash:!0})],dashGapPickable:!0,getDashArray:vt=>vt.item.dash?[2*vt.item.dash[0]/Rt(vt),2*vt.item.dash[1]/Rt(vt)]:[0,0]}:Y("mapview:dash","createMapView: dash is set but deck.gl has no PathStyleExtension (the page's deck.gl build does not export it); the lines are drawn solid. Load deck.gl's full bundle, or pass it as options.libs.deck.")),Ie.push(new h.PathLayer({id:"lattice-mapview-path",data:Be.paths,pickable:!0,widthUnits:"pixels",widthScale:dt,widthMinPixels:it,widthMaxPixels:Pt,capRounded:!$t.extensions,jointRounded:!$t.extensions,getPath:vt=>vt.path,getWidth:vt=>vt.item.selected?vt.item.width+3:vt.item.width,getColor:vt=>He(vt.item),updateTriggers:{...Ce,getWidth:Mt,getDashArray:Mt},...$t}))}he.column.length&&Ye.push(new h.ColumnLayer({id:"lattice-mapview-column",data:he.column,pickable:!0,extruded:!0,diskResolution:12,radius:typeof o.radius=="number"&&o.radius>0&&o.radiusUnits!=="pixels"?o.radius:30,elevationScale:Number.isFinite(o.elevationScale)?o.elevationScale:1,getPosition:it=>it.position,getElevation:it=>it.elevation,getFillColor:He,updateTriggers:Ce}));const ot=Be.paths.length>0,ut=Be.icon&&!At.unavailable()?he.point.filter(it=>it.icon&&At.has(it.icon)):[],Ot=ut.length?he.point.filter(it=>!(it.icon&&At.has(it.icon))):he.point;if(Ot.length&&Ye.push(new h.ScatterplotLayer({id:"lattice-mapview-point",data:Ot,pickable:!0,stroked:!0,...pe(o),lineWidthUnits:"pixels",getLineWidth:1,parameters:x,getPosition:ot?it=>[it.position[0],it.position[1],v]:it=>it.position,getRadius:it=>it.radius,getFillColor:He,getLineColor:it=>it.selected?be.highlight:be.halo,updateTriggers:Ce})),ut.length){const{badge:it}=Be.icon,Pt=[255,255,255,255],Rt={data:ut,iconAtlas:At.image(),iconMapping:At.mapping(Be.icon.anchor),billboard:!0,sizeUnits:"pixels",alphaCutoff:.05,parameters:{depthCompare:"always",depthWriteEnabled:!1},getPosition:$t=>$t.position,updateTriggers:{...Ce,getIcon:Mt,getSize:Mt}};it?(Ye.push(new h.IconLayer({...Rt,id:"lattice-mapview-icon-ring",pickable:!1,getIcon:()=>le(it),getSize:$t=>$t.iconSize*1.16,getColor:()=>Pt})),Ye.push(new h.IconLayer({...Rt,id:"lattice-mapview-icon",pickable:!0,getIcon:()=>le(it),getSize:$t=>$t.iconSize,getColor:He})),Ye.push(new h.IconLayer({...Rt,id:"lattice-mapview-icon-glyph",pickable:!1,getIcon:$t=>$t.icon,getSize:$t=>$t.iconSize*.56,getColor:()=>Pt}))):Ye.push(new h.IconLayer({...Rt,id:"lattice-mapview-icon",pickable:!0,getIcon:$t=>$t.icon,getSize:$t=>$t.iconSize,getColor:He}))}return{under:Ie,over:Ye}},_t=he=>{const Ce=Vt();if(!Ce||!Be.paths.length||typeof h.TripsLayer!="function")return null;const He=100+Ce.trail*100,Ie=(he-mt)/1e3*Ce.speed*100%He;return new h.TripsLayer({id:"lattice-mapview-flow",data:Be.paths,widthUnits:"pixels",widthScale:dt,widthMinPixels:3,capRounded:!0,jointRounded:!0,fadeTrail:!0,trailLength:Ce.trail*100,currentTime:Ie,getPath:Ye=>Ye.path,getTimestamps:Ye=>Ye.timestamps,getWidth:Ye=>Ye.item.width+1,getColor:be.mode==="dark"?[255,255,255,230]:[255,214,0,240]})},Ht=()=>!!Vt()&&Be.paths.length>0&&!Ft()&&typeof h.TripsLayer=="function"&&!(ae&&ae.visibilityState==="hidden"),Kt=he=>{const Ce=Ht()?_t(he):null;tt=Ce?[...We,Ce,...st]:[...We,...st],de.setProps({layers:[...tt,...wt]})},Xt=he=>{gt=0,!(ee||!Ht())&&(Kt(typeof he=="number"?he:Date.now()),gt=Wt(Xt))},Qt=()=>{ee||gt||!Ht()||(mt||(mt=Date.now()),gt=Wt(Xt))},hn=()=>{ae.visibilityState==="hidden"?(gt&&(Bt(gt),gt=0),Kt(Date.now())):Qt()};ae&&typeof ae.addEventListener=="function"&&ae.addEventListener("visibilitychange",hn);const fn=()=>{try{const he=typeof G.getPitch=="function"?Number(G.getPitch()):0;return Number.isFinite(he)?Math.round(1/Math.max(Math.cos(Math.min(Math.max(he,0),85)*Math.PI/180),.5)*20)/20:1}catch{return 1}},nn=()=>{if(!ee){Mt++;for(const he of Be.items)he.selected=N(he,ze);({under:We,over:st}=Et()),Kt(Date.now())}},on=()=>{const he=fn();ee||he===dt||(dt=he,Be.paths.length&&(Mt++,{under:We,over:st}=Et(),Kt(Date.now())))},pn=()=>{try{const he=G.getBounds();if(he&&typeof he.getWest=="function")return[he.getWest(),he.getSouth(),he.getEast(),he.getNorth()]}catch{}return null},sn=(he,Ce)=>{if(!he.length)return;const He=R(he);if(!He)return;const[Ie,Ye,ot,ut]=He;if(Ie===ot&&Ye===ut){const Ot=Math.max(typeof G.getZoom=="function"?G.getZoom():0,15);Ce?G.flyTo({center:[Ie,Ye],zoom:Ot}):G.jumpTo({center:[Ie,Ye],zoom:Ot});return}G.fitBounds([[Ie,Ye],[ot,ut]],{padding:48,maxZoom:16,...Ce?{}:{duration:0}})};let Yt=null;const Jt=()=>{Yt&&Yt.close(),Yt=se(Q,H.position,{ids:!0,leaves:!0,readPlace:H.readPlace||void 0,viewportCap:o.viewportCap,onAnswer:()=>ln()})};Jt();const an=he=>`rgba(${he[0]},${he[1]},${he[2]},${(he[3]??255)/255})`,gn=()=>{if(!o.legend){jt&&(jt.hidden=!0);return}jt||(jt=k.doc.createElement("div"),jt.className=`${L}__legend`,jt.setAttribute("role","group"),jt.setAttribute("aria-label",z(Q,"mapview.legend")),k.root.appendChild(jt)),jt.replaceChildren();const he=(Ie,Ye)=>{const ot=k.doc.createElement("div");ot.className=`${L}__legend-row`;const ut=k.doc.createElement("span");ut.textContent=Ie,ot.appendChild(Ye),ot.appendChild(ut),jt.appendChild(ot)},Ce=(Ie,Ye)=>Ie?`repeating-linear-gradient(90deg, ${Ye} 0 ${Ie[0]}px, transparent ${Ie[0]}px ${Ie[0]+Ie[1]}px)`:Ye,He=Be.legendSections;for(const Ie of He){if(He.length>1&&Ie.title){const Ye=k.doc.createElement("div");Ye.className=`${L}__legend-title`,Ye.textContent=Ie.title,jt.appendChild(Ye)}for(const Ye of Ie.entries){const ot=k.doc.createElement("span"),ut=Ye.colour?an(Ye.colour):"currentColor";Ye.line?(ot.className=`${L}__legend-line`,ot.style.background=Ce(Ye.dash,ut)):(ot.className=`${L}__legend-swatch`,ot.style.background=ut),he(Ye.label,ot)}}jt.hidden=jt.children.length===0},Dt=()=>{if(ee)return;pt&&(Bt(pt),pt=0),je.invalidate();const he=Yt.read(pn());he.over&&Y("mapview:over",`createMapView: the map's view holds ${he.over.count} matching rows, more than its viewportCap of ${he.over.cap}, and ${he.over.reason}, so none were drawn. Zoom in, narrow the filter, or raise viewportCap.`),Mt++,Be=T(Q,he.binned?{features:[],keys:[]}:he,o,be,ze,{placement:H,routeCache:It}),Be.paths=[];for(const Ie of Be.items)if(Ie.layer==="polygon"&&(Ie.feature={type:"Feature",geometry:Ie.geometry,properties:Ie}),Ie.__mapview=!0,Ie.layer==="path")for(const Ye of Ie.lines){const ot=P(Ye),ut=ot[ot.length-1]||1;Be.paths.push({item:Ie,path:Ye.map(Ot=>[Ot[0],Ot[1],r]),timestamps:ot.map(Ot=>Ot/ut*100)})}qe=new Map;for(const Ie of Be.items)for(const Ye of Ie.keys||[Ie.key])qe.set(Ye,Ie);if(Be.icon&&At.ensure(Be.icon.refs,Be.icon.badge?[Be.icon.badge]:[]),Be.icon)for(const Ie of At.unknown())Y(`mapview:icon:${Ie}`,`createMapView: icon "${Ie}" is not a glyph of the grid's icon registry, an SVG path or an image URL; the points that ask for it are drawn as circles.`);Be.icon&&At.unavailable()&&Y("mapview:icons","createMapView: icon is set but there is no canvas to draw the icon atlas on; points are drawn as circles."),dt=fn(),{under:We,over:st}=Et();const Ce={};for(const[Ie,Ye]of Object.entries(Be.byLayer))Ye.length&&(Ce[Ie]=Ye.length);const He=Be.icon&&!At.unavailable()?Be.byLayer.point.filter(Ie=>Ie.icon&&At.has(Ie.icon)).length:0;He&&(Ce.icon=He,He===Be.byLayer.point.length?delete Ce.point:Ce.point=Be.byLayer.point.length-He),Ue={...he.provenance,drawn:Be.items.reduce((Ie,Ye)=>Ie+(Ye.keys?Ye.keys.length:1),0),skipped:(he.provenance.skipped||0)+Be.skipped,matched:he.provenance.matched,layers:Ce,...H.route?{routes:Be.routes.drawn,routesSkipped:Be.routes.skipped,routesRebuilt:Be.routes.rebuilt}:{}},gn(),Kt(Date.now()),Qt(),!Ct&&Be.items.length&&(Ct=!0,sn(Be.items,!1)),K("draw",{provenance:{...Ue}})};function ln(){ee||pt||(pt=Wt(()=>{pt=0,Dt()}))}const en=he=>{const Ce=Q.rows;if(!(typeof Ce.leavesOf!="function"||typeof Ce.expand!="function"))for(let He=0;He<12;He++){let Ie=!1;const Ye=[];if(Ce.forEach(ut=>{ut&&(ut.group?ut.expanded||Ye.push(ut):ut.key===he&&(Ie=!0))}),Ie)return;const ot=Ye.find(ut=>Ce.leavesOf(ut.key).some(Ot=>Ot&&Ot.key===he));if(!ot)return;Ce.expand(ot.key)}},cn=he=>{if(ee||!Q.selection||typeof Q.selection.set!="function")return;const Ce=he[0];kt=!0;try{Q.selection.set(he)}finally{kt=!1}if(typeof Q.selection.keys=="function"&&!Q.selection.keys().some(He=>he.includes(He))&&Y("mapview:selection",`createMapView: row ${JSON.stringify(Ce)} was clicked on the map but the grid did not select it: a grid selects nothing unless it is created with selection: 'single' or 'multiple', and a beforeSelect handler can refuse it.`),en(Ce),Q.scroll&&typeof Q.scroll.toRow=="function")try{Q.scroll.toRow(Ce,"center")}catch{}},dn=he=>{if(ee)return;const Ce=Gt(he&&he.object),He=k.tooltip;if(Ce===void 0||!Qe.length){He.hidden=!0,Ce===void 0&&K("feature:hover",{key:null,row:null,lines:[]});return}const Ie=qe.get(Ce),Ye=H.route?H.route.by:null,ot=Ye&&!(Ie&&Ie.isRoute)?Qe.filter(Ot=>Ot!==Ye):Qe,ut=g(Q,Ce,ot,Ie?Ie.row:null);He.replaceChildren();for(const Ot of ut){const it=k.doc.createElement("div"),Pt=k.doc.createElement("span");Pt.className=`${L}__tip-title`,Pt.textContent=Ot.title;const Rt=k.doc.createElement("span");Rt.textContent=Ot.text,it.appendChild(Pt),it.appendChild(Rt),He.appendChild(it)}He.style.left=`${Math.round((he.x||0)+12)}px`,He.style.top=`${Math.round((he.y||0)+12)}px`,He.hidden=!1,K("feature:hover",{key:Ce,row:Ie?Ie.row:null,lines:ut})},rn=he=>{if(Re.active())return;const Ce=Gt(he&&he.object);if(Ce===void 0)return;const He=qe.get(Ce);cn(He&&He.keys?[...He.keys]:[Ce]),K("feature:click",{key:Ce,row:He?He.row:null,...He&&He.isRoute?{route:He.route,keys:[...He.keys]}:{}})};let b=()=>"",Oe=()=>"";const de=new h.MapboxOverlay({interleaved:!0,layers:[],onClick:rn,onHover:dn,getCursor:({isDragging:he})=>b()||Oe()||(he?"grabbing":"grab")});(()=>{const he=G.transform;if(!(!he||typeof he!="object"||"_nearZ"in he||!("nearZ"in he)))try{Object.defineProperty(he,"_nearZ",{configurable:!0,get(){return this.nearZ}}),Object.defineProperty(he,"_farZ",{configurable:!0,get(){return this.farZ}})}catch{}})(),G.addControl(de);const Re=te({map:G,deck:h,doc:ae,theme:()=>be,emit:K,pick:(he,Ce)=>{try{return de.pickMultipleObjects({x:he,y:Ce,radius:4})||[]}catch{return[]}},setLayers:he=>{wt=he,de.setProps({layers:[...tt,...wt]})},format:(he,Ce)=>Q.messages&&typeof Q.messages.number=="function"?Q.messages.number(he,Ce):new Intl.NumberFormat(void 0,Ce).format(he),text:he=>z(Q,he)});Re.applyTheme(),b=()=>Re.cursor();const je=ge({map:G,doc:ae,grid:Q,draw:Re,enabled:()=>!!o.moveRows,columns:()=>H.kind==="point"&&!H.route&&!H.segment?H.position:null,items:()=>Be.items,redraw(){ee||(Nt++,{under:We,over:st}=Et(),Kt(Date.now()))}});Oe=()=>je.cursor();const Fe=()=>{if(ee||!o.buildings||typeof G.getLayer=="function"&&G.getLayer(d))return;const he=typeof G.getStyle=="function"?G.getStyle():null,Ce=he&&he.sources?he.sources:{},He=Object.keys(Ce).find(Ie=>Ie==="openmaptiles"&&Ce[Ie].type==="vector")||Object.keys(Ce).find(Ie=>Ce[Ie]&&Ce[Ie].type==="vector");if(!He){Y("mapview:buildings",'createMapView: buildings is on but the basemap style has no vector source with an OpenMapTiles "building" layer; no buildings were drawn. Use an OpenMapTiles style such as the default.');return}G.addLayer({id:d,type:"fill-extrusion",source:He,"source-layer":"building",minzoom:13,paint:{"fill-extrusion-color":be.building,"fill-extrusion-height":["coalesce",["get","render_height"],0],"fill-extrusion-base":["coalesce",["get","render_min_height"],0],"fill-extrusion-opacity":.75}})},Ge=()=>{typeof G.getLayer=="function"&&G.getLayer(d)&&G.removeLayer(d)},Ke=()=>{Fe(),K("load",{map:G})},nt=()=>{Ue.computed==="engine"&&ln()};G.on("style.load",Ke),G.on("moveend",nt),G.on("pitch",on);const Xe=()=>ln(),ct=[["model:changed",Xe],["rows:changed",Xe],["selection:changed",()=>{ze=new Set(Q.selection&&typeof Q.selection.keys=="function"?Q.selection.keys():[]),nn(),!kt&&ze.size&&lt([...ze])}]].map(([he,Ce])=>{const He=Q.on(he,Ce);return typeof He=="function"?He:()=>Q.off(he,Ce)});function lt(he){if(ee)return;const He=(Array.isArray(he)?he:[he]).map(Ie=>qe.get(Ie)).filter(Boolean);sn(He,!0)}Dt();const yt=A(k.root,o).destroy;return E={element:k.root,map:G,overlay:de,getMap(){return G},draw:{setMode(he,Ce){Re.setMode(he,Ce)},getFeatures(){return Re.getFeatures()},setFeatures(he){Re.setFeatures(he)},clear(){Re.clear()},undo(){Re.undo()},redo(){Re.redo()}},update(he){if(ee)return;const Ce=he&&typeof he=="object"?he:{},He=o;if(o={...o,...Ce},"layer"in Ce&&V(Ce.layer),"geometry"in Ce){const Ie=n(Q,o.geometry);typeof Ie=="string"?(Y("mapview:geometry",`createMapView: the grid has no place to draw rows at: ${Ie}. Nothing was drawn.`),o=He):(H=Ie,It.clear(),Jt())}if(("tooltip"in Ce||"geometry"in Ce)&&(Qe=S(Q,o.tooltip,H.columns,H.route?H.route.by:null)),"theme"in Ce&&(be=Pe(k.root,X,o.theme),Re.applyTheme()),("basemap"in Ce||"theme"in Ce)&&G.setStyle(Se()),"buildings"in Ce&&(o.buildings?Fe():Ge()),"view"in Ce&&Ce.view&&typeof Ce.view=="object"){const Ie=Ce.view;G.jumpTo({...Array.isArray(Ie.center)?{center:Ie.center}:{},...Number.isFinite(Ie.zoom)?{zoom:Ie.zoom}:{},...Number.isFinite(Ie.pitch)?{pitch:Ie.pitch}:{},...Number.isFinite(Ie.bearing)?{bearing:Ie.bearing}:{}})}Dt()},flyTo:lt,setLayer(he){E.update({layer:he})},view(){if(!G||typeof G.getCenter!="function"||typeof G.getZoom!="function")return{center:null,zoom:1,pitch:0,bearing:0};const he=G.getCenter();return{center:Array.isArray(he)?he:he&&Number.isFinite(he.lng)&&Number.isFinite(he.lat)?[he.lng,he.lat]:null,zoom:Number(G.getZoom())||0,pitch:typeof G.getPitch=="function"&&Number(G.getPitch())||0,bearing:typeof G.getBearing=="function"&&Number(G.getBearing())||0}},layer(){return o.layer||null},provenance(){return{...Ue}},layers(){return tt},legend(){return{colours:Be.legend.map(he=>({...he})),dashes:Be.dashLegend.map(he=>({label:he.label,dash:he.dash?[...he.dash]:null})),sections:Be.legendSections.map(he=>({...he,entries:he.entries.map(Ce=>({...Ce,colour:Ce.colour?[...Ce.colour]:null,dash:Ce.dash?[...Ce.dash]:null}))}))}},on(he,Ce){return!I.has(he)||typeof Ce!="function"?(Y(`mapview:event:${String(he)}`,`createMapView: "${String(he)}" is not an event a map view emits; use ${ve.join(", ")}.`),()=>{}):(I.get(he).add(Ce),()=>I.get(he).delete(Ce))},off(he,Ce){const He=I.get(he);He&&He.delete(Ce)},destroy(){if(!ee){ee=!0,pt&&Bt(pt),gt&&Bt(gt),pt=0,gt=0;for(const he of ct)he();je.destroy(),Re.destroy(),ae&&typeof ae.removeEventListener=="function"&&ae.removeEventListener("visibilitychange",hn),Yt&&Yt.close();try{G.off("style.load",Ke),G.off("moveend",nt),G.off("pitch",on)}catch{}try{G.removeControl(de)}catch{}try{G.remove()}catch{}for(const he of I.values())he.clear();yt(),k.unmount()}}},E}const ie=me});var Sn=jn("packages/modules/mapview/index.js");typeof module=="object"&&module.exports?module.exports=Sn:typeof define=="function"&&define.amd?define(function(){return Sn}):Cn.LatticeGridMapView=Sn})(typeof globalThis<"u"?globalThis:this);
545
+ .${ie}-float__title{ flex:1 1 auto; }
546
+ .${ie}-float__close{ font:inherit; border:0; background:transparent; color:inherit; cursor:pointer; }
547
+ .${ie}-float__body{ position:relative; flex:1 1 auto; min-height:0; }
548
+ ${H()}
549
+ `).trim()}function V(E){const q=E&&E.documentElement;if(!q||q.getAttribute(te))return;q.setAttribute(te,"1");const B=E.createElement("style");B.textContent=n(),(E.head||E.body||q).appendChild(B)}}),qe("packages/modules/mapview/view.js",function(t,ce){"use strict";Object.defineProperty(t,"MODES",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(t,"FALLBACK_EN",{enumerable:!0,get:function(){return te}}),Object.defineProperty(t,"message",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"themeMode",{enumerable:!0,get:function(){return E}}),Object.defineProperty(t,"resolveContainer",{enumerable:!0,get:function(){return B}}),Object.defineProperty(t,"place",{enumerable:!0,get:function(){return f}});const _e=ce("packages/modules/mapview/styles.js"),H=_e.NS,ue=_e.injectStyles,ie=Object.freeze(["container","split","tab","popout"]),te=Object.freeze({"mapview.label":"Map of the grid’s rows","mapview.title":"Map","mapview.tab.grid":"Grid","mapview.tab.map":"Map","mapview.divider":"Resize the map","mapview.close":"Close the map","mapview.legend":"Map legend","mapview.draw.segment":"Segment","mapview.draw.perimeter":"Perimeter","mapview.draw.refused.geometry-type":"Not allowed: this kind of shape","mapview.draw.refused.max-vertices":"Not allowed: too many vertices","mapview.draw.refused.min-segment-length":"Not allowed: segment too short","mapview.draw.refused.self-intersection":"Not allowed: crosses itself"});function n(u,h){const c=u&&u.messages&&typeof u.messages.t=="function"?u.messages:null;if(c){let k;try{k=c.t(h)}catch{k=null}if(typeof k=="string"&&k&&k!==h)return k}return te[h]||h}function V(u,h,c){const k=u.createElement(h);return k.className=c,k}function E(u,h){let c=u;for(;c&&typeof c.getAttribute=="function";){const k=c.getAttribute("data-theme");if(k==="dark"||k==="light")return k;if(k==="auto"){try{if(h&&typeof h.matchMedia=="function"&&h.matchMedia("(prefers-color-scheme: dark)").matches)return"dark"}catch{}return"light"}c=c.parentElement||c.parentNode}return"light"}function q(u,h,c){ue(u);const k=V(u,"div",H);k.setAttribute("role","region"),k.setAttribute("aria-label",n(c,"mapview.label"));const m=V(u,"div",`${H}__map`),r=V(u,"div",`${H}__tooltip`);return r.setAttribute("role","tooltip"),r.hidden=!0,k.appendChild(m),k.appendChild(r),h.appendChild(k),{root:k,mapEl:m,tooltip:r}}function B(u,h){if(u&&typeof u=="object"&&"appendChild"in u)return u;if(typeof u=="string"&&h&&typeof h.querySelector=="function")try{return h.querySelector(u)}catch{return null}return null}function f(u,h,c){const k=u&&u.element?u.element:null,m=k?k.ownerDocument:typeof document<"u"?document:null,r=h.mode!==void 0?h.mode:h.container!==void 0?"container":"split";if(!ie.includes(r))return`mode ${JSON.stringify(r)} is not one of ${ie.join(", ")}`;if(r==="container"){const v=B(h.container,m);if(!v)return`container ${typeof h.container=="string"?JSON.stringify(h.container):"option"} names no element`;const l=v.ownerDocument,x=q(l,v,u);return{...x,doc:l,win:l.defaultView||globalThis,mode:r,unmount(){x.root.remove()}}}return!k||!k.parentNode?`mode "${r}" needs the grid's element in the page (a grid from createGrid), and this grid has none`:r==="split"?y(u,k,c):r==="tab"?P(u,k,c):N(u,k,h,c)}function S(u,h){const c=u.parentNode,k=u.nextSibling,m=u.getAttribute("style"),r=typeof u.getBoundingClientRect=="function"?u.getBoundingClientRect():null;return r&&r.height>0&&(h.style.height=`${Math.round(r.height)}px`),c.insertBefore(h,u),()=>{k&&k.parentNode===c?c.insertBefore(u,k):c.insertBefore(u,h),m===null?u.removeAttribute("style"):u.setAttribute("style",m),h.remove()}}function y(u,h,c){const k=h.ownerDocument;ue(k);const m=V(k,"div",`${H}-split`),r=S(h,m),v=V(k,"div",`${H}-split__pane`),l=V(k,"div",`${H}-split__divider`),x=V(k,"div",`${H}-split__pane`);l.setAttribute("role","separator"),l.setAttribute("aria-orientation","vertical"),l.setAttribute("aria-label",n(u,"mapview.divider")),l.setAttribute("aria-valuemin","15"),l.setAttribute("aria-valuemax","85"),l.tabIndex=0,m.appendChild(v),m.appendChild(l),m.appendChild(x),v.appendChild(h),h.style.width="100%",h.style.height="100%";const W=q(k,x,u);let J=.5;const se=X=>{J=Math.max(.15,Math.min(.85,Number.isFinite(X)?X:.5)),v.style.flex=`0 0 ${(J*100).toFixed(2)}%`,x.style.flex="1 1 0",l.setAttribute("aria-valuenow",String(Math.round(J*100))),c.onResize()};se(.5);let re=!1;const b=X=>{re=!0,typeof l.setPointerCapture=="function"&&X.pointerId!==void 0&&l.setPointerCapture(X.pointerId),typeof X.preventDefault=="function"&&X.preventDefault()},C=X=>{if(!re)return;const z=m.getBoundingClientRect();z.width>0&&se((X.clientX-z.left)/z.width)},I=()=>{re=!1},M=X=>{const z={ArrowLeft:-.05,ArrowRight:.05}[X.key];if(z!==void 0)se(J+z);else if(X.key==="Home")se(.15);else if(X.key==="End")se(.85);else return;typeof X.preventDefault=="function"&&X.preventDefault()};return l.addEventListener("pointerdown",b),l.addEventListener("pointermove",C),l.addEventListener("pointerup",I),l.addEventListener("pointercancel",I),l.addEventListener("keydown",M),{...W,doc:k,win:k.defaultView||globalThis,mode:"split",setRatio:se,ratio:()=>J,unmount(){l.removeEventListener("pointerdown",b),l.removeEventListener("pointermove",C),l.removeEventListener("pointerup",I),l.removeEventListener("pointercancel",I),l.removeEventListener("keydown",M),r()}}}function P(u,h,c){const k=h.ownerDocument;ue(k);const m=V(k,"div",`${H}-tabs`),r=S(h,m),v=V(k,"div",`${H}-tabs__strip`);v.setAttribute("role","tablist");const l=`${H}-${Math.random().toString(36).slice(2,8)}`,x={};for(const b of["grid","map"]){const C=V(k,"button",`${H}-tabs__tab`);C.setAttribute("type","button"),C.setAttribute("role","tab"),C.id=`${l}-${b}-tab`,C.setAttribute("aria-controls",`${l}-${b}`),C.setAttribute("data-tab",b),C.textContent=n(u,`mapview.tab.${b}`);const I=V(k,"div",`${H}-tabs__panel`);I.id=`${l}-${b}`,I.setAttribute("role","tabpanel"),I.setAttribute("aria-labelledby",C.id),v.appendChild(C),x[b]={tab:C,panel:I}}m.appendChild(v),m.appendChild(x.grid.panel),m.appendChild(x.map.panel),x.grid.panel.appendChild(h),h.style.width="100%",h.style.height="100%";const W=q(k,x.map.panel,u),J=b=>{for(const C of["grid","map"]){const I=C===b;x[C].tab.setAttribute("aria-selected",I?"true":"false"),x[C].tab.tabIndex=I?0:-1,x[C].panel.hidden=!I}c.onResize()},se=b=>{const C=b.target&&typeof b.target.closest=="function"?b.target.closest("[data-tab]"):null;C&&J(C.getAttribute("data-tab"))},re=b=>{if(b.key!=="ArrowLeft"&&b.key!=="ArrowRight")return;const C=x.grid.tab.getAttribute("aria-selected")==="true"?"map":"grid";J(C),x[C].tab.focus(),typeof b.preventDefault=="function"&&b.preventDefault()};return v.addEventListener("click",se),v.addEventListener("keydown",re),J("grid"),{...W,doc:k,win:k.defaultView||globalThis,mode:"tab",activate:J,unmount(){v.removeEventListener("click",se),v.removeEventListener("keydown",re),r()}}}function N(u,h,c,k){const m=h.ownerDocument,r=m.defaultView||globalThis;let v=null;try{v=typeof r.open=="function"?r.open("","lattice-mapview","popup,width=960,height=640"):null}catch{v=null}const l=v&&v.document;if(l&&l.body){l.title=n(u,"mapview.title");for(const re of m.querySelectorAll('link[rel="stylesheet"],style'))typeof l.importNode=="function"&&l.head.appendChild(l.importNode(re,!0));const x=E(h,r);l.documentElement.setAttribute("data-theme",x),l.body.style.margin="0",l.body.style.height="100vh";const W=q(l,l.body,u),J=()=>k.onClose(),se=()=>k.onResize();return v.addEventListener("pagehide",J),v.addEventListener("resize",se),{...W,doc:l,win:v,mode:"popout",unmount(){v.removeEventListener("pagehide",J),v.removeEventListener("resize",se);try{v.closed||v.close()}catch{}}}}return p(u,h,k)}function p(u,h,c){const k=h.ownerDocument,m=k.defaultView||globalThis;ue(k);const r=V(k,"div",`${H}-float`);r.setAttribute("role","dialog"),r.setAttribute("aria-label",n(u,"mapview.title")),r.setAttribute("data-theme",E(h,m));const v=V(k,"div",`${H}-float__bar`),l=V(k,"span",`${H}-float__title`);l.textContent=n(u,"mapview.title");const x=V(k,"button",`${H}-float__close`);x.setAttribute("type","button"),x.setAttribute("aria-label",n(u,"mapview.close")),x.textContent="×",v.appendChild(l),v.appendChild(x);const W=V(k,"div",`${H}-float__body`);r.appendChild(v),r.appendChild(W),(k.body||k.documentElement).appendChild(r);const J=q(k,W,u);let se=null;const re=z=>{if(z.target===x)return;const ne=r.getBoundingClientRect();se={dx:z.clientX-ne.left,dy:z.clientY-ne.top},typeof v.setPointerCapture=="function"&&z.pointerId!==void 0&&v.setPointerCapture(z.pointerId)},b=z=>{se&&(r.style.left=`${Math.max(0,z.clientX-se.dx)}px`,r.style.top=`${Math.max(0,z.clientY-se.dy)}px`,r.style.right="auto",r.style.bottom="auto")},C=()=>{se=null},I=()=>c.onClose();v.addEventListener("pointerdown",re),v.addEventListener("pointermove",b),v.addEventListener("pointerup",C),x.addEventListener("click",I);const M=m.ResizeObserver||globalThis.ResizeObserver,X=typeof M=="function"?new M(()=>c.onResize()):null;return X&&X.observe(W),{...J,doc:k,win:m,mode:"float",unmount(){v.removeEventListener("pointerdown",re),v.removeEventListener("pointermove",b),v.removeEventListener("pointerup",C),x.removeEventListener("click",I),X&&X.disconnect(),r.remove()}}}}),qe("packages/modules/shared/require-core.js",function(t,ce){"use strict";Object.defineProperty(t,"coreMissing",{enumerable:!0,get:function(){return _e}});function _e(){if(typeof Mn>"u"||!Mn||typeof globalThis>"u")return!1;const H=globalThis.LatticeGrid;return!H||typeof H.createGrid!="function"}}),qe("packages/core/src/registry/free-tier-notice.js",function(t,ce){"use strict";Object.defineProperty(t,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(t,"WATERMARK_TEXT",{enumerable:!0,get:function(){return H}});const _e="Free for non-commercial use: latticegrid.dev/free",H="Unlicensed: Lattice Grid trial"}),qe("packages/core/src/registry/licence.js",function(t,ce){"use strict";Object.defineProperty(t,"PRODUCT",{enumerable:!0,get:function(){return te}}),Object.defineProperty(t,"LICENCE_VERSION",{enumerable:!0,get:function(){return n}}),Object.defineProperty(t,"PUBLIC_KEY",{enumerable:!0,get:function(){return q}}),Object.defineProperty(t,"fromBase64Url",{enumerable:!0,get:function(){return S}}),Object.defineProperty(t,"toBase64Url",{enumerable:!0,get:function(){return y}}),Object.defineProperty(t,"asciiBytes",{enumerable:!0,get:function(){return P}}),Object.defineProperty(t,"parseLicence",{enumerable:!0,get:function(){return p}}),Object.defineProperty(t,"hasEd25519",{enumerable:!0,get:function(){return l}}),Object.defineProperty(t,"verifyLicence",{enumerable:!0,get:function(){return x}}),Object.defineProperty(t,"isLocalHost",{enumerable:!0,get:function(){return W}}),Object.defineProperty(t,"currentHost",{enumerable:!0,get:function(){return J}}),Object.defineProperty(t,"matchesDomain",{enumerable:!0,get:function(){return se}}),Object.defineProperty(t,"LicenceHolder",{enumerable:!0,get:function(){return b}}),Object.defineProperty(t,"setLicence",{enumerable:!0,get:function(){return X}}),Object.defineProperty(t,"licenceInfo",{enumerable:!0,get:function(){return z}}),Object.defineProperty(t,"watermark",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(t,"licenceState",{enumerable:!0,get:function(){return R}}),Object.defineProperty(t,"sharedLicence",{enumerable:!0,get:function(){return G}});const H=ce("packages/core/src/internal/warn.js").warnOnce,ue=ce("packages/core/src/registry/free-tier-notice.js"),ie=ue.FREE_TIER_NOTICE;Object.defineProperty(t,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return ue.FREE_TIER_NOTICE}});const te="lattice-grid",n=1,V="LG1",E=64,q="GwmaCOkGedHulqsa-DOV1TU8On1rsalWv519c_dW4j4",B="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",f=(()=>{const T=new Int16Array(128).fill(-1);for(let e=0;e<B.length;e++)T[B.charCodeAt(e)]=e;return T[43]=62,T[47]=63,T})();function S(T){if(typeof T!="string")return null;let e="";for(let ve=0;ve<T.length;ve++){const ge=T.charCodeAt(ve);if(ge!==61){if(ge>127||f[ge]<0)return null;e+=T[ve]}}const s=e.length;if(s%4===1)return null;const a=new Uint8Array(Math.floor(s*3/4));let _=0,$=0,Q=0;for(let ve=0;ve<s;ve++)_=_<<6|f[e.charCodeAt(ve)],$+=6,$>=8&&($-=8,a[Q++]=_>>$&255);return Q===a.length?a:a.subarray(0,Q)}function y(T){let e="",s=0;for(;s+2<T.length;s+=3){const _=T[s]<<16|T[s+1]<<8|T[s+2];e+=B[_>>18&63]+B[_>>12&63]+B[_>>6&63]+B[_&63]}const a=T.length-s;if(a===1){const _=T[s]<<16;e+=B[_>>18&63]+B[_>>12&63]}else if(a===2){const _=T[s]<<16|T[s+1]<<8;e+=B[_>>18&63]+B[_>>12&63]+B[_>>6&63]}return e}function P(T){const e=new Uint8Array(T.length);for(let s=0;s<T.length;s++)e[s]=T.charCodeAt(s)&127;return e}function N(T){if(typeof TextDecoder=="function")return new TextDecoder().decode(T);let e="";for(let s=0;s<T.length;s++)e+=String.fromCharCode(T[s]);return e}function p(T){const e={ok:!1,reason:"malformed",product:null,issuedTo:null,expires:null,terms:null,features:[],deployments:[],version:0,message:null,signature:null,raw:typeof T=="string"?T:""};if(typeof T!="string"||T.length===0)return{...e,reason:"missing"};const s=T.trim(),a=s.split(".");if(a.length!==3)return e;const[_,$,Q]=a;if(_!==V)return{...e,reason:"prefix"};const ve=S($),ge=S(Q);if(!ve||!ge)return e;let Se;try{Se=JSON.parse(N(ve))}catch{return e}return Se===null||typeof Se!="object"?e:{ok:!0,reason:null,product:typeof Se.p=="string"?Se.p:null,issuedTo:typeof Se.t=="string"?Se.t:null,expires:typeof Se.e=="string"?Se.e:null,terms:typeof Se.terms=="string"?Se.terms:null,features:Array.isArray(Se.f)?Se.f.slice():[],deployments:Array.isArray(Se.d)?Se.d.slice():[],version:typeof Se.v=="number"?Se.v:0,message:P($),signature:ge,raw:s}}function u(T,e){if(!T)return!1;const s=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(T)?`${T}T23:59:59.999Z`:T);return Number.isNaN(s)?!0:e>s}function h(T){return T==="non-commercial"?"non-commercial":"commercial"}let c=null,k=null,m=null;function r(){const T=globalThis.crypto;return T&&T.subtle?T.subtle:null}async function v(T){if(c&&k===T)return c;const e=r();if(!e)return null;const s=S(T);if(!s)return null;try{const a=await e.importKey("raw",s,{name:"Ed25519"},!1,["verify"]);return c=a,k=T,a}catch{return null}}async function l(){return m!==null||(m=await v(q)!==null),m}async function x(T,e={}){const s=e.warn!==!1,a=e.product||te,_=e.publicKey||q,$=e.now??Date.now(),Q=e.host??J(),ve=W(Q)?"":` ${ie}`,ge=p(T);if(!ge.ok){const pe=ge.reason==="missing"?"missing":"malformed";return s&&H(`licence.${pe}`,pe==="missing"?`no licence key supplied. The grid renders in full and carries a trial watermark on any host other than localhost. Get a key at latticegrid.dev.${ve}`:`licence key could not be read. The grid will render with a watermark.${ve}`),{valid:!1,reason:pe,terms:"commercial"}}const Se={product:ge.product||void 0,issuedTo:ge.issuedTo||void 0,expires:ge.expires||void 0,terms:h(ge.terms)};if(ge.product!==a)return s&&H("licence.product",`licence key is for '${ge.product}', not '${a}'. The grid will render with a watermark.`),{valid:!1,...Se,reason:"product"};if(u(ge.expires,$))return s&&H("licence.expired",`licence expired on ${ge.expires}. The grid will render with a watermark. Renew at latticegrid.dev.`),{valid:!1,...Se,reason:"expired"};const Ne=ge.deployments||[];if(Ne.length&&Q&&!W(Q)&&!se(Q,Ne))return s&&H("licence.domain",`licence key is not valid for ${Q}; it covers ${Ne.join(", ")}. The grid will render with a watermark.`),{valid:!1,...Se,reason:"domain"};const Le=await v(_);if(!Le){const pe=!!ge.signature&&ge.signature.length===E;return s&&H("licence.algorithm","this host does not provide crypto.subtle Ed25519, so the licence signature could not be verified. A structural check was used instead."),pe?{valid:!0,...Se,reason:"unverified"}:{valid:!1,...Se,reason:"signature"}}let j=!1;try{j=await r().verify({name:"Ed25519"},Le,ge.signature,ge.message)}catch{j=!1}return j?{valid:!0,...Se}:(s&&H("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...Se,reason:"signature"})}function W(T){const e=String(T??J()??"").trim().toLowerCase().replace(/^\[/,"").replace(/\]$/,"");return!e||e==="localhost"||e.endsWith(".localhost")||e==="::1"||e==="0:0:0:0:0:0:0:1"?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(e)}function J(){const T=globalThis.location;return T&&typeof T.hostname=="string"?T.hostname:null}function se(T,e){const s=re(T);return!s||!Array.isArray(e)?!1:e.some(a=>{const _=re(a);if(!_)return!1;if(_==="*")return!0;if(_.startsWith("*.")){const $=_.slice(2);return s===$||s.endsWith(`.${$}`)}return s===_})}function re(T){return String(T??"").trim().toLowerCase().replace(/\.$/,"")}class b{#e="";#t={valid:!1,reason:"missing",terms:"commercial"};#n=null;#r=null;#s;#o=new Set;constructor(e={}){this.#s=e}set(e){this.#e=typeof e=="string"?e.trim():"";const s=p(this.#e);return this.#t=s.ok?{valid:!u(s.expires,Date.now())&&s.product===(this.#s.product||te),product:s.product||void 0,issuedTo:s.issuedTo||void 0,expires:s.expires||void 0,terms:h(s.terms),reason:"pending"}:{valid:!1,reason:s.reason||"malformed",terms:"commercial"},this.#n=null,this.#e&&this.verify(),this.#t}verify(){if(this.#n)return this.#n;const e=this.#e;return this.#n=x(e,this.#s).then(s=>{if(this.#e===e){this.#t=s;for(const a of this.#o)a(s)}return s}),this.#n}onSettled(e){return this.#o.add(e),()=>this.#o.delete(e)}info(){return{...this.#t}}watermark(){return this.#t.valid?!1:!W(this.#r)}setHost(e){this.#r=e}state(){return this.#t.valid?"licensed":W(this.#r)?"localhost":"trial"}reset(){this.#e="",this.#t={valid:!1,reason:"missing",terms:"commercial"},this.#n=null,this.#o.clear()}}const C=Symbol.for("lattice-grid/licence/holder");function I(){const T=globalThis,e=T&&T[C];if(e&&typeof e.set=="function"&&typeof e.watermark=="function")return e;const s=new b;if(T)try{T[C]=s}catch{}return s}const M=I();function X(T){return M.set(T)}function z(){return M.info()}function ne(){return M.watermark()}function R(){return M.state()}function G(){return M}}),qe("packages/dom/src/watermark.js",function(t,ce){"use strict";Object.defineProperty(t,"WATERMARK_CLASS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(t,"WATERMARK_LAYER_CLASS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(t,"Watermark",{enumerable:!0,get:function(){return m}}),Object.defineProperty(t,"viewLicenceHost",{enumerable:!0,get:function(){return r}}),Object.defineProperty(t,"mountViewWatermark",{enumerable:!0,get:function(){return v}}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return l}});const H=ce("packages/core/src/internal/predicates.js").isFunction,ue=ce("packages/core/src/registry/free-tier-notice.js"),ie=ue.FREE_TIER_NOTICE,te=ue.WATERMARK_TEXT,n=ce("packages/core/src/registry/licence.js"),V=n.watermark,E=n.setLicence,q=Object.freeze({t:x=>x==="licence.watermark.free"?ie:te});function B(x,W,J={}){const se=x.createElement(W);if(J.class)for(const re of J.class.split(/\s+/))re&&se.classList.add(re);if(J.text!==void 0&&(se.textContent=J.text),J.attrs)for(const[re,b]of Object.entries(J.attrs))se.setAttribute(re,b);if(J.children)for(const re of J.children)se.appendChild(re);return se}function f(x,W,J){return x.addEventListener(W,J),()=>x.removeEventListener(W,J)}const S="lat-watermark",y="https://www.latticegrid.dev",P=["br","bl","tl","tr"],N=4e3,p=Symbol.for("lattice-grid/licence/holder"),u="data-lat-watermark-owner",h="lat-watermark-layer",c="lat-watermark-style",k=`
550
+ .${h}{position:absolute;inset:0;pointer-events:none;z-index:2147483000;overflow:hidden}
551
+ .${h} .${S}{position:absolute;z-index:6;padding:10px 18px;border-radius:var(--lattice-radius-sm,4px);background:var(--lattice-accent,#2563eb);box-shadow:0 2px 10px rgb(0 0 0 / 25%);color:var(--lattice-accent-contrast,#fff);font:700 15px/1.3 system-ui,sans-serif;letter-spacing:.02em;white-space:nowrap;pointer-events:none;opacity:.94}
552
+ .${h} .${S}--br{inset-inline-end:0;bottom:0}
553
+ .${h} .${S}--bl{inset-inline-start:0;bottom:0}
554
+ .${h} .${S}--tl{inset-inline-start:0;top:0}
555
+ .${h} .${S}--tr{inset-inline-end:0;top:0}
556
+ .${h} .${S}__link{color:inherit;pointer-events:auto;text-decoration:underline;text-underline-offset:2px}
557
+ .${h} .${S}__free{display:block;margin-top:2px;font-size:12px;font-weight:500;letter-spacing:0;opacity:.92}
558
+ @media print{.${h} .${S}{opacity:1}}
559
+ `;class m{#e;#t;#n;#r=null;#s=[];#o;#u=0;#a=null;#i=null;#f=!1;constructor(W){this.#i=W.owner||null,this.#i&&H(this.#i.setAttribute)&&this.#i.setAttribute(u,""),this.#e=W.grid,this.#t=W.document,this.#n=W.element,this.#o=W.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.refresh(),H(this.#e.on)&&this.#s.push(this.#e.on("licence:changed",()=>this.refresh()));const W=this.#e.licence&&this.#e.licence.ready;W&&H(W.then)&&W.then(()=>this.refresh(),()=>this.refresh())}refresh(){const W=this.#h()&&!this.#d();W&&!this.#r?(this.#p(),this.#m()):!W&&this.#r&&(this.#l(),this.#c())}#d(){const W=this.#n;let J=W&&W.parentNode;for(this.#i&&J===this.#i&&(J=J.parentNode);J&&J.nodeType===1;){if(H(J.hasAttribute)&&J.hasAttribute(u))return!0;J=J.parentNode}return!1}#g(){const W=this.#o;if(!W||!H(W.matchMedia))return!1;try{return!!W.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#m(){this.#c(),H(this.#o.setTimeout)&&(this.#g()||(this.#a=this.#o.setTimeout(()=>{if(this.#a=null,!this.#h()||this.#d()){this.#l();return}this.#u=(this.#u+1)%P.length,this.#l(),this.#p(),this.#m()},N)))}#c(){this.#a!==null&&H(this.#o.clearTimeout)&&this.#o.clearTimeout(this.#a),this.#a=null}#h(){const W=this.#e.licence;return!!(W&&H(W.watermark)&&W.watermark())}#p(){const W=this.#e.messages&&H(this.#e.messages.t)?this.#e.messages:q,J=B(this.#t,"a",{class:`${S}__link`,text:W.t("licence.watermark"),attrs:{href:y,target:"_blank",rel:"noopener noreferrer"}}),se=B(this.#t,"span",{class:`${S}__free`,text:W.t("licence.watermark.free")});this.#r=B(this.#t,"div",{class:`${S} ${S}--${P[this.#u]}`,attrs:{role:"note",title:"This grid is unlicensed for this domain. Visit latticegrid.dev for a licence."},children:[J,se]}),this.#s.push(f(this.#r,"pointerdown",re=>{H(re.stopPropagation)&&re.stopPropagation()})),this.#n&&H(this.#n.appendChild)&&this.#n.appendChild(this.#r),typeof queueMicrotask=="function"&&!this.#f&&(this.#f=!0,queueMicrotask(()=>{this.#f=!1,this.#r&&this.#d()&&(this.#l(),this.#c())}))}#l(){this.#r&&H(this.#r.remove)&&this.#r.remove(),this.#r=null}destroy(){this.#c(),this.#i&&H(this.#i.removeAttribute)&&this.#i.removeAttribute(u);for(const W of this.#s)W();this.#s=[],this.#l()}}function r(x={},W=void 0){const J=globalThis[p],se=!x.licence&&W&&H(W.querySelector)?W.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,re=x.licence||se;return re&&E(re),{licence:{watermark:()=>V(),get ready(){return J?J.verify():Promise.resolve()}},on:(b,C)=>b==="licence:changed"&&J?J.onSettled(()=>C()):()=>{}}}function v(x,W={}){const J=x&&x.ownerDocument;if(!J||!H(J.createElement))return{destroy(){},refresh(){}};const se=J.defaultView||void 0,re=r(W,J);let b=null,C=null,I=null,M=!1;const X=()=>{if(!J.getElementById(c)&&J.head){const R=J.createElement("style");R.id=c,R.textContent=k,J.head.appendChild(R)}se&&H(se.getComputedStyle)&&se.getComputedStyle(x).position==="static"&&(x.style.position="relative"),b=J.createElement("div"),b.className=h,x.appendChild(b),C=new m({grid:re,document:J,element:b,window:se,owner:x}),C.mount(),se&&H(se.MutationObserver)&&(I=new se.MutationObserver(()=>{!M&&b&&b.parentNode!==x&&x.appendChild(b)}),I.observe(x,{childList:!0}))},z=()=>{M||(C?C.refresh():re.licence.watermark()&&X())};z();const ne=re.on("licence:changed",z);return re.licence.ready,{refresh:z,destroy(){M||(M=!0,ne(),I&&I.disconnect(),C&&C.destroy(),b&&b.parentNode&&b.parentNode.removeChild(b))}}}const l=m}),qe("packages/modules/mapview/draw.js",function(t,ce){"use strict";Object.defineProperty(t,"DRAW_MODES",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(t,"metresBetween",{enumerable:!0,get:function(){return h}}),Object.defineProperty(t,"destinationPoint",{enumerable:!0,get:function(){return c}}),Object.defineProperty(t,"circlePolygon",{enumerable:!0,get:function(){return k}}),Object.defineProperty(t,"closeRing",{enumerable:!0,get:function(){return m}}),Object.defineProperty(t,"rectanglePolygon",{enumerable:!0,get:function(){return r}}),Object.defineProperty(t,"pathLength",{enumerable:!0,get:function(){return v}}),Object.defineProperty(t,"ringArea",{enumerable:!0,get:function(){return l}}),Object.defineProperty(t,"formatLength",{enumerable:!0,get:function(){return W}}),Object.defineProperty(t,"formatArea",{enumerable:!0,get:function(){return J}}),Object.defineProperty(t,"segmentsCross",{enumerable:!0,get:function(){return b}}),Object.defineProperty(t,"pathSelfIntersects",{enumerable:!0,get:function(){return C}}),Object.defineProperty(t,"createDraw",{enumerable:!0,get:function(){return G}}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return T}});const H=ce("packages/modules/mapview/roles.js").expand,ue=63710088e-1,ie=Object.freeze(["point","line","polygon","circle","rectangle"]),te=10,n=9,V=7,E=14,q=12,B=10,f=500,S=10,y=1600,P=Object.freeze({point:"Point",line:"LineString",polygon:"Polygon",circle:"Polygon",rectangle:"Polygon"}),N=100;function p(e){return e*Math.PI/180}function u(e){return e*180/Math.PI}function h(e,s){const[a,_]=e,[$,Q]=s,ve=p(Q-_),ge=p($-a),Se=Math.sin(ve/2)**2+Math.cos(p(_))*Math.cos(p(Q))*Math.sin(ge/2)**2;return 2*ue*Math.asin(Math.min(1,Math.sqrt(Se)))}function c(e,s,a){const[_,$]=e,Q=a/ue,ve=p(s),ge=p($),Se=p(_),Ne=Math.asin(Math.sin(ge)*Math.cos(Q)+Math.cos(ge)*Math.sin(Q)*Math.cos(ve)),Le=Se+Math.atan2(Math.sin(ve)*Math.sin(Q)*Math.cos(ge),Math.cos(Q)-Math.sin(ge)*Math.sin(Ne));return[u(Le),u(Ne)]}function k(e,s,a=64){const _=Math.max(0,s),$=Array.from({length:a},(Q,ve)=>c(e,360*ve/a,_));return m($)}function m(e){if(e.length<1)return e.slice();const s=e[0],a=e[e.length-1];return s[0]===a[0]&&s[1]===a[1]?e.slice():[...e,[...s]]}function r(e,s){const[a,_]=e,[$,Q]=s;return m([[a,_],[$,_],[$,Q],[a,Q]])}function v(e){let s=0;for(let a=1;a<e.length;a+=1)s+=h(e[a-1],e[a]);return s}function l(e){const s=e.length;if(s<3)return 0;let a=0;for(let _=0;_<s;_+=1){const $=e[_],Q=e[(_+1)%s];a+=p(Q[0]-$[0])*(2+Math.sin(p($[1]))+Math.sin(p(Q[1])))}return Math.abs(a*ue*ue/2)}const x=(e,s)=>new Intl.NumberFormat(void 0,s).format(e);function W(e,s=x){return e<995?`${s(e,{maximumFractionDigits:e<10?1:0})} m`:`${s(e/1e3,{minimumFractionDigits:2,maximumFractionDigits:2})} km`}function J(e,s=x){return e<9950?`${s(e,{maximumFractionDigits:0})} m²`:`${s(e/1e4,{minimumFractionDigits:2,maximumFractionDigits:2})} ha`}const se=(e,s,a)=>(s[0]-e[0])*(a[1]-e[1])-(s[1]-e[1])*(a[0]-e[0]),re=(e,s,a)=>Math.min(e[0],s[0])<=a[0]&&a[0]<=Math.max(e[0],s[0])&&Math.min(e[1],s[1])<=a[1]&&a[1]<=Math.max(e[1],s[1]);function b(e,s,a,_){const $=se(e,s,a),Q=se(e,s,_),ve=se(a,_,e),ge=se(a,_,s);return $*Q<0&&ve*ge<0?!0:$===0&&re(e,s,a)||Q===0&&re(e,s,_)||ve===0&&re(a,_,e)||ge===0&&re(a,_,s)}function C(e,s){const a=e.length,_=s?a:a-1;for(let $=0;$<_;$+=1)for(let Q=$+2;Q<_;Q+=1)if(!(s&&$===0&&Q===_-1)&&b(e[$],e[($+1)%a],e[Q],e[(Q+1)%a]))return!0;return!1}function I(e,s){if(!e||typeof e!="object")return;if(e.type==="FeatureCollection"&&Array.isArray(e.features)){e.features.forEach($=>I($,s));return}if(e.type==="Feature"){I(e.geometry,s);return}if(e.type==="GeometryCollection"&&Array.isArray(e.geometries)){e.geometries.forEach($=>I($,s));return}const a=$=>{if(Array.isArray($))for(let Q=0;Q<$.length;Q+=1)!Array.isArray($[Q])||!Number.isFinite($[Q][0])||!Number.isFinite($[Q][1])||(s.verts.push($[Q]),Q>0&&Array.isArray($[Q-1])&&s.segs.push([$[Q-1],$[Q]]))},_=e.coordinates;e.type==="Point"?a([_]):e.type==="MultiPoint"?_.forEach($=>a([$])):e.type==="LineString"?a(_):e.type==="MultiLineString"||e.type==="Polygon"?_.forEach(a):e.type==="MultiPolygon"&&_.forEach($=>$.forEach(a))}function M(e){return JSON.parse(JSON.stringify(e))}function X(e){return Array.isArray(e)?e:e&&typeof e=="object"&&e.type==="FeatureCollection"&&Array.isArray(e.features)?e.features:null}function z(e){if(!e||typeof e!="object"||!Array.isArray(e.layers))return null;const s=e.layers.filter(_=>typeof _=="string"&&_);if(!s.length)return null;const a=Number.isFinite(e.tolerance)&&e.tolerance>0?Math.min(e.tolerance,100):S;return{layers:s,tolerance:a}}function ne(e){const s={};return!e||typeof e!="object"||(Array.isArray(e.geometryTypes)&&(s.geometryTypes=e.geometryTypes.filter(a=>typeof a=="string")),Number.isFinite(e.maxVertices)&&e.maxVertices>=1&&(s.maxVertices=Math.floor(e.maxVertices)),Number.isFinite(e.minSegmentLength)&&e.minSegmentLength>0&&(s.minSegmentLength=e.minSegmentLength),e.noSelfIntersection===!0&&(s.noSelfIntersection=!0)),s}function R(e,s,a,_){const{format:$,text:Q}=_;if(e==="circle"&&Number.isFinite(_.radius))return[J(Math.PI*_.radius*_.radius,$),`${Q("mapview.draw.perimeter")} ${W(2*Math.PI*_.radius,$)}`];if(e==="line"||s.length<3){const ve=[W(v(s),$)],ge=a||(s.length>2?[s[s.length-2],s[s.length-1]]:null);return ge&&s.length>2&&ve.push(`${Q("mapview.draw.segment")} ${W(h(ge[0],ge[1]),$)}`),ve}return[J(l(s),$),`${Q("mapview.draw.perimeter")} ${W(v(m(s)),$)}`]}function G({map:e,deck:s,doc:a,theme:_,emit:$,pick:Q,setLayers:ve,format:ge=x,text:Se=Ne=>Ne}){let Ne=null,Le="",j=null,pe={},he=[],oe=null,fe=null,we=0,i=0,Y=[0,114,178,90],o=[255,87,34,255],d=[255,87,34,110],O=[255,255,255,255],F=new Set,U=[],ee=[],L=null,Z=null,xe=!1,g=!1,A=null,K={},ae=null,ye=null,ke=null,Te=0,ze=null,Ze=null,He=!1,Ke=null,Fe=!1,ct={x:0,y:0},tt=!1,pt=null;const Lt=()=>(we+=1,`draw-${we}-${Math.random().toString(36).slice(2,8)}`),jt=(D,le,be={})=>({type:"Feature",id:Lt(),geometry:le,properties:{...pe,...be,shape:D,readonly:!1}}),wt=()=>{const D=_()||{};Y=Array.isArray(D.accent)?[D.accent[0],D.accent[1],D.accent[2],90]:Y,o=Array.isArray(D.highlight)?D.highlight:o,d=[o[0],o[1],o[2],110],O=Array.isArray(D.halo)?[D.halo[0],D.halo[1],D.halo[2],255]:O,mt()},gt=(D,le,be,Re)=>{for(const Ee of D){const We=Ee.geometry&&Ee.geometry.type;We==="Polygon"?le.push(Ee):We==="LineString"?be.push(Ee):We==="Point"&&Re.push(Ee)}};function mt(){i+=1;const D=[],le=[],be=[];if(gt(he,D,le,be),fe)gt([fe.feature],D,le,be);else if(oe){const Xe=ae?[...oe.verts,ae]:oe.verts;le.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:Xe.length>1?Xe:[Xe[0],Xe[0]]}});for(const St of oe.verts)be.push({type:"Feature",properties:{},geometry:{type:"Point",coordinates:St}})}const Re=[],Ee={getFillColor:i,getLineColor:i,getLineWidth:i,getRadius:i},We=Xe=>F.has(Xe.id),rt={depthCompare:"always",depthWriteEnabled:!1};D.length&&Re.push(new s.GeoJsonLayer({id:"lattice-mapview-draw-fill",data:D,pickable:!1,filled:!0,stroked:!0,parameters:rt,lineWidthMinPixels:2,lineWidthUnits:"pixels",getFillColor:Xe=>We(Xe)?d:Y,getLineColor:()=>o,getLineWidth:Xe=>We(Xe)?4:2,updateTriggers:Ee})),le.length&&Re.push(new s.GeoJsonLayer({id:"lattice-mapview-draw-line",data:le,pickable:!1,filled:!1,stroked:!0,parameters:rt,lineWidthMinPixels:2,lineWidthUnits:"pixels",getLineColor:()=>o,getLineWidth:Xe=>We(Xe)?4:2,updateTriggers:Ee})),be.length&&Re.push(new s.ScatterplotLayer({id:"lattice-mapview-draw-point",data:be,pickable:!1,stroked:!0,parameters:rt,radiusUnits:"pixels",getRadius:Xe=>We(Xe)?8:5,lineWidthMinPixels:1,getFillColor:()=>o,getLineColor:Xe=>We(Xe)?O:[255,255,255,220],getPosition:Xe=>Xe.geometry.coordinates,updateTriggers:Ee}));const ut=Me();ut.length&&Re.push(new s.ScatterplotLayer({id:"lattice-mapview-draw-handle",data:ut,pickable:!1,stroked:!0,parameters:rt,radiusUnits:"pixels",getRadius:Xe=>Xe.mid?He?9:4:He?13:6,lineWidthUnits:"pixels",getLineWidth:2,getFillColor:Xe=>Xe.mid?d.slice(0,3).concat(170):O,getLineColor:()=>o,getPosition:Xe=>Xe.pos,updateTriggers:Ee}));const yt=[];ye&&yt.push({pos:ye,refused:!1}),ke&&yt.push({pos:ke,refused:!0}),yt.length&&Re.push(new s.ScatterplotLayer({id:"lattice-mapview-draw-cue",data:yt,pickable:!1,stroked:!0,filled:!1,parameters:rt,radiusUnits:"pixels",getRadius:Xe=>Xe.refused?14:11,lineWidthUnits:"pixels",getLineWidth:Xe=>Xe.refused?4:3,getLineColor:Xe=>Xe.refused?o:[Y[0],Y[1],Y[2],255],getPosition:Xe=>Xe.pos,updateTriggers:Ee})),ve(Re)}const Mt=D=>{$e(),he.push(D),ae=null,ye=null,Ze=cn(D),mt(),Kt(),$("draw:finish",{feature:M(D)})},ft=()=>{oe=null,fe=null,ae=null,ye=null,Ze=null,mt(),Kt()},ht=(D,le)=>{try{D&&typeof D.enable=="function"&&typeof D.disable=="function"&&(le?D.enable():D.disable())}catch{}};function et(D,le){if(D!==null&&D!=="edit"&&!ie.includes(D))return;ft(),j==="edit"&&D!=="edit"&&(Ot(!0),de([]),Z=null),j=D,pe=le&&typeof le=="object"&&le.properties&&typeof le.properties=="object"?{...le.properties}:{},A=z(le&&le.snap),K=ne(le&&le.constraints),pt=null,ke=null,clearTimeout(Te),Kt(),ht(e.doubleClickZoom,!j);const be=j==="circle"||j==="rectangle";ht(e.dragPan,!be),ht(e.dragRotate,!be),ht(e.boxZoom,!be&&j!=="edit"),Bt(j&&j!=="edit"?"crosshair":"")}function Bt(D){Le=D}function Dt(){return{type:"FeatureCollection",features:he.map(M)}}function Ut(D){const le=X(D);le&&(ft(),Be(),he=le.map(be=>{const Re=be&&be.properties&&typeof be.properties=="object"?{...be.properties}:{};return Re.readonly===void 0&&(Re.readonly=!1),{type:"Feature",id:be&&be.id!==void 0&&be.id!==null?be.id:Lt(),geometry:be&&be.geometry?JSON.parse(JSON.stringify(be.geometry)):null,properties:Re}}),mt())}function Ht(){ft(),Be(),he=[],mt()}const Ft=D=>{if(!oe||!oe.verts.length)return 1/0;const le=e.project(oe.verts[0]);return Math.hypot(le.x-D.x,le.y-D.y)},xt=()=>{const D=oe.verts.map(Re=>[...Re]),le=j==="line"?{type:"LineString",coordinates:D}:{type:"Polygon",coordinates:[m(D)]},be=jt(j,le);oe=null,Mt(be)},Wt=(D,le)=>{if(ct=le,Ne=null,!oe&&!fn(j)){Qt("geometry-type",D);return}if(j==="point"){const Ee=jt("point",{type:"Point",coordinates:D});$("draw:start",{mode:j,feature:M(Ee)}),Mt(Ee);return}if(!oe){oe={verts:[D]},Ze=null,$("draw:start",{mode:j,feature:{type:"Feature",id:null,geometry:{type:"Point",coordinates:D},properties:{shape:j}}}),mt();return}const be=j==="polygon"?3:2;if(oe.verts.length>=be&&Ft(le)<=te){const Ee=hn();Ee?(Ne=le,Qt(Ee,D)):xt();return}const Re=gn(D);if(Re){Ne=le,Qt(Re,D);return}oe.verts.push(D),ae=null,ye=null,$("draw:change",{mode:j,feature:{type:"Feature",id:null,geometry:{type:"LineString",coordinates:oe.verts.map(Ee=>[...Ee])},properties:{shape:j}}}),mt(),Kt()},Gt=D=>{if(It(D.lngLat.lng,D.lngLat.lat,D.point),j==="edit"){me(D);return}j===null||j==="circle"||j==="rectangle"||D.originalEvent&&D.originalEvent.detail>=2||Wt(rn(D.point,void 0,D.lngLat).pos,D.point)};function It(D,le,be){const Re=typeof Q=="function"?Q(be.x,be.y)||[]:[];$("map:click",{lng:D,lat:le,features:Re.map(Ee=>Ee&&Ee.object).filter(Ee=>Ee!=null)})}const _t=D=>{if(j===null||j==="point"||j==="circle"||j==="rectangle"||j==="edit"||!oe)return;if(typeof D.preventDefault=="function"&&D.preventDefault(),Ne&&D.point&&Math.hypot(D.point.x-Ne.x,D.point.y-Ne.y)<=te){Ne=null;return}const le=oe.verts.length;if(le>1){const Ee=je(oe.verts[le-1]),We=je(oe.verts[le-2]);Math.hypot(Ee.x-We.x,Ee.y-We.y)<=te&&oe.verts.pop()}const be=j==="polygon"?3:2;if(oe.verts.length<be){ft();return}const Re=hn();if(Re){Qt(Re,oe.verts[oe.verts.length-1]);return}xt()},Xt=D=>{if(j!=="circle"&&j!=="rectangle")return;const le=[D.lngLat.lng,D.lngLat.lat];if(!fn(j)){Qt("geometry-type",le);return}Ze=null;const be=j==="circle"?{type:"Polygon",coordinates:[k(le,0)]}:{type:"Polygon",coordinates:[r(le,le)]},Re=jt(j,be,j==="circle"?{center:[...le],radius:0}:{});fe={start:le,feature:Re},$("draw:start",{mode:j,feature:M(Re)}),mt()},Yt=D=>{if(j==="edit"&&!L){const be=Ge(D.point);Bt(be?be.kind==="body"&&tn(be.f)?"move":"pointer":"")}if(!fe){yn(D);return}D.point&&(ct=D.point);const le=[D.lngLat.lng,D.lngLat.lat];if(j==="circle"){const be=h(fe.start,le);fe.feature.geometry={type:"Polygon",coordinates:[k(fe.start,be)]},fe.feature.properties.radius=be}else fe.feature.geometry={type:"Polygon",coordinates:[r(fe.start,le)]};$("draw:change",{mode:j,feature:M(fe.feature)}),mt(),Kt()},qt=()=>{if(!fe)return;const D=fe.feature,le=j==="circle"?!(D.properties.radius>0):Jt(D.geometry.coordinates[0][0],D.geometry.coordinates[0][2]);if(fe=null,le){mt(),Kt();return}Mt(D)};function Jt(D,le){return D[0]===le[0]&&D[1]===le[1]}const nn=(D,le)=>{const be={verts:[],segs:[]},{layers:Re,tolerance:Ee}=A;for(const We of he)We.id!==le&&We.properties&&Re.includes(We.properties.layer)&&I(We.geometry,be);for(const We of Re){let rt=null;try{rt=typeof e.getLayer=="function"?e.getLayer(We):null}catch{rt=null}if(!rt)continue;let ut=null;try{const yt=e.getSource(rt.source);ut=yt&&yt._data}catch{ut=null}if(ut&&typeof ut=="object"){I(ut,be);continue}try{const yt=e.queryRenderedFeatures([[D.x-Ee,D.y-Ee],[D.x+Ee,D.y+Ee]],{layers:[We]});for(const Xe of yt)I(Xe.geometry,be)}catch{}}return be},mn=(D,le)=>{if(!A)return null;const be=A.tolerance,Re=nn(D,le);let Ee=null,We=be;for(const yt of Re.verts){const Xe=je(yt),St=Math.hypot(Xe.x-D.x,Xe.y-D.y);St<=We&&(Ee=yt,We=St)}if(Ee)return{pos:[Ee[0],Ee[1]],kind:"vertex"};let rt=null;We=be;for(const[yt,Xe]of Re.segs){const St=je(yt),dn=je(Xe),Vt=De(D,St,dn);if(Vt>We)continue;const Zt=dn.x-St.x,an=dn.y-St.y,wn=Zt*Zt+an*an,pn=wn===0?0:Math.max(0,Math.min(1,((D.x-St.x)*Zt+(D.y-St.y)*an)/wn));rt=[St.x+pn*Zt,St.y+pn*an],We=Vt}if(!rt)return null;const ut=e.unproject(rt);return{pos:[ut.lng,ut.lat],kind:"segment"}};function rn(D,le,be){const Re=mn(D,le);if(Re)return{pos:Re.pos,snapped:!0};const Ee=be||e.unproject([D.x,D.y]);return{pos:[Ee.lng,Ee.lat],snapped:!1}}const fn=D=>{const le=K.geometryTypes;return!Array.isArray(le)||le.includes(P[D])},gn=D=>{const le=K,be=oe.verts,Re=be[be.length-1];if(le.maxVertices!==void 0&&be.length+1>le.maxVertices)return"max-vertices";if(le.minSegmentLength!==void 0&&Re&&h(Re,D)<le.minSegmentLength)return"min-segment-length";if(le.noSelfIntersection&&j==="polygon"&&be.length>=2){for(let Ee=0;Ee<be.length-2;Ee+=1)if(b(be[Ee],be[Ee+1],Re,D))return"self-intersection";for(let Ee=1;Ee<be.length-1;Ee+=1)if(b(be[Ee],be[Ee+1],D,be[0]))return"self-intersection"}return null},hn=()=>{const D=oe.verts,le=K.minSegmentLength;return j==="polygon"&&le!==void 0&&D.length>1&&h(D[D.length-1],D[0])<le?"min-segment-length":null},ln=(D,le,be)=>{const Re=K,Ee=un(D).slice();Ee[le]=be;const We=D.geometry.type==="Polygon";if(Re.minSegmentLength!==void 0){const rt=le>0?Ee[le-1]:We?Ee[Ee.length-1]:null,ut=le<Ee.length-1?Ee[le+1]:We?Ee[0]:null;if(rt&&h(rt,be)<Re.minSegmentLength||ut&&h(ut,be)<Re.minSegmentLength)return"min-segment-length"}return Re.noSelfIntersection&&We&&C(Ee,!0)?"self-intersection":null};function Qt(D,le){pt=D,ke=le,clearTimeout(Te),Te=setTimeout(()=>{pt=null,ke=null,mt(),Kt()},y),$("draw:refused",{mode:j,rule:D,position:[le[0],le[1]]}),mt(),Kt()}function cn(D,le){const be=D.geometry,Re=D.properties&&D.properties.shape;if(!be)return null;const Ee={format:ge,text:Se,radius:Re==="circle"&&D.properties?D.properties.radius:void 0};if(be.type==="LineString"){const We=le===void 0?null:le>0?[be.coordinates[le-1],be.coordinates[le]]:[be.coordinates[0],be.coordinates[1]];return R("line",be.coordinates,We,Ee)}return be.type==="Polygon"?R(Re==="circle"?"circle":"polygon",be.coordinates[0].slice(0,-1),null,Ee):null}const on=()=>{if(ze)return ze;const D=typeof e.getContainer=="function"?e.getContainer():null;return!D||!a||typeof a.createElement!="function"?null:(ze=a.createElement("div"),ze.className="lat-mapview__readout",ze.hidden=!0,ze.style.cssText=`position:absolute;left:0;top:0;z-index:4;pointer-events:none;white-space:nowrap;padding:4px 8px;line-height:1.4;font-variant-numeric:tabular-nums;${H("background:var(--lattice-map-popup-bg);color:var(--lattice-map-popup-fg);font-family:var(--lattice-map-font);font-size:var(--lattice-map-font-size-sm);border:1px solid var(--lattice-map-border);border-radius:var(--lattice-map-radius);box-shadow:var(--lattice-map-shadow)")}`,D.appendChild(ze),ze)};function Kt(){let D=null;const le={format:ge,text:Se};if(L){const Vt=en(L.ids[0]);D=Vt?cn(Vt,L.kind==="vertex"?L.index:void 0):null}else if(fe)D=cn(fe.feature);else if(oe){const Vt=oe.verts,Zt=ae&&!Jt(ae,Vt[Vt.length-1])?[...Vt,ae]:Vt;D=j==="line"||j==="polygon"?R(j,Zt,null,le):null}else D=Ze;const be=on();if(!be)return;if((!D||!D.length)&&!pt){be.hidden=!0;return}const Re=pt?[Se(`mapview.draw.refused.${pt}`),...D||[]]:D||[];be.textContent="",Re.forEach((Vt,Zt)=>{const an=a.createElement("div");an.textContent=Vt,pt&&Zt===0&&an.setAttribute("data-rule",pt),be.appendChild(an)}),be.style.borderColor=pt?H("var(--lattice-map-highlight)"):"",pt?be.setAttribute("data-refused",pt):be.removeAttribute("data-refused"),be.hidden=!1;const Ee=e.getContainer(),We=Ee.clientWidth,rt=Ee.clientHeight,ut=be.offsetWidth,yt=be.offsetHeight,Xe=16;let St=ct.x+Xe;St+ut>We-4&&(St=ct.x-Xe-ut);const dn=tt?ct.y-yt-3*Xe:ct.y+Xe;be.style.left=`${Math.max(4,Math.min(St,We-ut-4))}px`,be.style.top=`${Math.max(4,Math.min(dn,rt-yt-4))}px`}function yn(D){if(!D.point)return;ct=D.point,tt=!1;const le=Ze!==null;if(Ze=null,j!=="point"&&j!=="line"&&j!=="polygon"){le&&Kt();return}const be=rn(D.point,void 0,D.lngLat),Re=be.snapped?be.pos:null,Ee=Re===null!=(ye===null)||Re!==null&&ye!==null&&!Jt(Re,ye);ye=Re,oe&&(ae=be.pos),(oe||Ee)&&mt(),Kt()}const en=D=>he.find(le=>le.id===D),tn=D=>!(D.properties&&D.properties.readonly),sn=D=>tn(D)&&!!D.geometry&&D.properties.shape!=="circle"&&(D.geometry.type==="LineString"||D.geometry.type==="Polygon"),un=D=>D.geometry.type==="Polygon"?D.geometry.coordinates[0].slice(0,-1):D.geometry.coordinates,w=D=>{const le=un(D),be=D.geometry.type==="Polygon"?le.length:le.length-1;return Array.from({length:be},(Re,Ee)=>{const We=le[Ee],rt=le[(Ee+1)%le.length];return[(We[0]+rt[0])/2,(We[1]+rt[1])/2]})},Me=()=>{const D=[];for(const le of he)if(!(!F.has(le.id)||!sn(le))){for(const be of un(le))D.push({pos:be,mid:!1});for(const be of w(le))D.push({pos:be,mid:!0})}return D};function de(D){const le=new Set(D),be=le.size!==F.size||[...le].some(Re=>!F.has(Re));F=le,be&&$("feature:select",{ids:[...le]}),mt()}function $e(D){U.push(D||he.map(M)),U.length>N&&U.shift(),ee=[]}const Pe=D=>{he=D,Z=null,de([...F].filter(le=>en(le)))};function Oe(){L||!U.length||(ee.push(he.map(M)),Pe(U.pop()))}function Ae(){L||!ee.length||(U.push(he.map(M)),Pe(ee.pop()))}function Be(){Ot(!0),U=[],ee=[],Z=null,de([])}const je=D=>{const le=e.project(D);return{x:le.x,y:le.y}},De=(D,le,be)=>{const Re=be.x-le.x,Ee=be.y-le.y,We=Re*Re+Ee*Ee,rt=We===0?0:Math.max(0,Math.min(1,((D.x-le.x)*Re+(D.y-le.y)*Ee)/We));return Math.hypot(D.x-(le.x+rt*Re),D.y-(le.y+rt*Ee))},Ie=(D,le)=>{let be=!1;for(let Re=0,Ee=le.length-1;Re<le.length;Ee=Re,Re+=1){const We=le[Re],rt=le[Ee];We.y>D.y!=rt.y>D.y&&D.x<(rt.x-We.x)*(D.y-We.y)/(rt.y-We.y)+We.x&&(be=!be)}return be},Ge=(D,le=!1)=>{const be=le?E:n,Re=le?q:V,Ee=he.filter(We=>F.has(We.id)&&sn(We));for(const We of Ee){const rt=un(We);for(let ut=0;ut<rt.length;ut+=1)if(Math.hypot(je(rt[ut]).x-D.x,je(rt[ut]).y-D.y)<=be)return{kind:"vertex",f:We,index:ut}}for(const We of Ee){const rt=w(We);for(let ut=0;ut<rt.length;ut+=1)if(Math.hypot(je(rt[ut]).x-D.x,je(rt[ut]).y-D.y)<=be)return{kind:"mid",f:We,index:ut}}for(let We=he.length-1;We>=0;We-=1){const rt=he[We],ut=rt.geometry;if(!ut)continue;if(ut.type==="Point"){if(Math.hypot(je(ut.coordinates).x-D.x,je(ut.coordinates).y-D.y)<=Re+2)return{kind:"body",f:rt,index:-1};continue}const yt=(ut.type==="Polygon"?ut.coordinates[0]:ut.coordinates).map(je);let Xe=ut.type==="Polygon"&&Ie(D,yt);for(let St=0;!Xe&&St<yt.length-1;St+=1)Xe=De(D,yt[St],yt[St+1])<=Re;if(Xe)return{kind:"body",f:rt,index:-1}}return null};function nt(){const D=he.filter(be=>F.has(be.id)&&tn(be)).map(be=>be.id);if(!D.length)return;$e();const le=[...F].filter(be=>!D.includes(be));he=he.filter(be=>!D.includes(be.id)),Z=null,$("feature:delete",{ids:D}),de(le)}function Ye(D,le){const be=en(D);if(!be||!sn(be))return!1;const Re=un(be);if(Re.length<=(be.geometry.type==="Polygon"?3:2)||le<0||le>=Re.length)return!1;$e();const Ee=Re.filter((We,rt)=>rt!==le);return be.geometry=be.geometry.type==="Polygon"?{type:"Polygon",coordinates:[m(Ee)]}:{type:"LineString",coordinates:Ee},Z=null,mt(),$("edit:change",{id:be.id,geometry:JSON.parse(JSON.stringify(be.geometry)),feature:M(be)}),!0}const st=(D,le,be)=>{if(typeof D[0]=="number"){const Re=je(D),Ee=e.unproject([Re.x+le,Re.y+be]);return[Ee.lng,Ee.lat]}return D.map(Re=>st(Re,le,be))},at=(D,le)=>{const be=e.getCanvas().getBoundingClientRect();return{x:D-be.left,y:le-be.top}},lt=D=>{L&&bt(at(D.clientX,D.clientY))};function bt(D){if(!L)return;ct=D;const le=D.x-L.startPx.x,be=D.y-L.startPx.y;if(!(!L.moved&&!L.reach&&Math.hypot(le,be)<2)){if(L.reach=!0,L.kind==="vertex"){const Re=en(L.ids[0]);if(!Re)return;const Ee=rn(D,Re.id);ye=Ee.snapped?Ee.pos:null;const We=ln(Re,L.index,Ee.pos);if(We){L.refused!==We&&(L.refused=We,Qt(We,Ee.pos)),mt();return}L.refused=null,L.moved=!0;const rt=Re.geometry.type==="Polygon"?Re.geometry.coordinates[0]:Re.geometry.coordinates;rt[L.index]=Ee.pos,Re.geometry.type==="Polygon"&&L.index===0&&(rt[rt.length-1]=[...Ee.pos])}else{L.moved=!0;for(const Re of L.ids){const Ee=en(Re),We=L.originals.get(Re);!Ee||!We||(Ee.geometry={type:We.geometry.type,coordinates:st(We.geometry.coordinates,le,be)},We.center&&(Ee.properties.center=st(We.center,le,be)))}}mt(),Kt()}}const kt=()=>Ot(!1);function Ot(D){if(!L)return;const le=L;if(L=null,ye=null,a&&typeof a.removeEventListener=="function"&&(a.removeEventListener("mousemove",lt),a.removeEventListener("mouseup",kt)),ht(e.dragPan,!0),D){he=le.pre,mt(),Kt();return}if(Kt(),!le.moved&&!le.inserted){mt();return}$e(le.pre),le.moved&&(xe=!0,setTimeout(()=>{xe=!1},0));for(const be of le.ids){const Re=en(be);Re&&$("edit:change",{id:Re.id,geometry:JSON.parse(JSON.stringify(Re.geometry)),feature:M(Re)})}mt()}const zt=D=>{j!=="edit"||D.button!==0||L||At(at(D.clientX,D.clientY),D,()=>{D.stopPropagation()},"mouse")};function At(D,le,be,Re){const Ee=Ge(D,Re==="touch");if(!Ee)return!1;const We=he.map(M);if(Ee.kind==="vertex"&&le.altKey)return be(),Ye(Ee.f.id,Ee.index),xe=!0,setTimeout(()=>{xe=!1},0),!0;let rt=null;if(Ee.kind==="vertex"||Ee.kind==="mid"){be();let yt=Ee.index;if(Ee.kind==="mid"){yt+=1;const Xe=w(Ee.f)[Ee.index];(Ee.f.geometry.type==="Polygon"?Ee.f.geometry.coordinates[0]:Ee.f.geometry.coordinates).splice(yt,0,Xe),mt()}Z={id:Ee.f.id,index:yt},rt={kind:"vertex",ids:[Ee.f.id],index:yt,inserted:Ee.kind==="mid"}}else{Z=null,g=!0,a.addEventListener("mouseup",()=>setTimeout(()=>{g=!1},0),{once:!0}),le.shiftKey?de(F.has(Ee.f.id)?[...F].filter(Xe=>Xe!==Ee.f.id):[...F,Ee.f.id]):F.has(Ee.f.id)||de([Ee.f.id]);const yt=he.filter(Xe=>F.has(Xe.id)&&tn(Xe)).map(Xe=>Xe.id);if(!F.has(Ee.f.id)||!yt.includes(Ee.f.id))return!1;be(),rt={kind:"move",ids:yt,index:-1,inserted:!1}}ht(e.dragPan,!1);const ut=new Map;for(const yt of rt.ids){const Xe=We.find(St=>St.id===yt);Xe&&ut.set(yt,{geometry:Xe.geometry,center:Xe.properties.center})}return L={...rt,pre:We,startPx:D,originals:ut,moved:!1,input:Re},Re==="mouse"&&(a.addEventListener("mousemove",lt),a.addEventListener("mouseup",kt)),!0}const me=D=>{if(xe)return;const le=Ge(D.point),be=!!(D.originalEvent&&D.originalEvent.shiftKey);if(le){le.kind==="body"&&!g&&!F.has(le.f.id)&&de(be?[...F,le.f.id]:[le.f.id]);return}be||(Z=null,de([]))},Ce=D=>{const le=D.target;if(!le||le===a||le===a.body||le===a.documentElement)return!0;if(le.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(le.tagName||""))return!1;const be=typeof e.getContainer=="function"?e.getContainer():null;return!be||typeof be.contains=="function"&&be.contains(le)},Ve=D=>{if(D.key==="Escape"){if(L){Ot(!0);return}if(oe||fe){ft();return}j==="edit"&&(Z=null,de([]),mt());return}if(j===null||!Ce(D))return;const le=D.key==="z"||D.key==="Z"||D.code==="KeyZ",be=D.key==="y"||D.key==="Y"||D.code==="KeyY";if((D.metaKey||D.ctrlKey)&&!D.altKey&&(le||be)){D.preventDefault(),be||D.shiftKey?Ae():Oe();return}j==="edit"&&(D.key==="Delete"||D.key==="Backspace")&&(D.preventDefault(),Z?Ye(Z.id,Z.index):nt())},Ue=D=>{const le=D.touches&&D.touches[0]||D.changedTouches[0];return at(le.clientX,le.clientY)},Je=()=>{Ke&&clearTimeout(Ke.timer),Ke=null},vt=()=>{if(!Ke||Fe)return;if(Ke.fired=!0,j==="edit"){const be=L;if(!be||be.moved||be.kind!=="vertex"||be.inserted)return;Ot(!0),Ye(be.ids[0],be.index);return}if(!oe)return;const D=j==="polygon"?3:2;if(oe.verts.length<D)return;const le=hn();le?Qt(le,oe.verts[oe.verts.length-1]):xt()},$t=D=>{if(He||(He=!0,mt()),D.touches.length>1){Fe=!0,Je(),L&&Ot(!0),fe&&ft();return}if(Fe=!1,j===null)return;const le=Ue(D);ct=le,tt=!0,Ze=null;const be=()=>{D.stopPropagation(),D.cancelable&&D.preventDefault()};if(Ke={startPx:le,moved:!1,timer:0,fired:!1,mode:j},j==="edit"){if(L||!At(le,{},be,"touch")){Je();return}Ke.timer=setTimeout(vt,f);return}if(j==="circle"||j==="rectangle"){const Re=e.unproject([le.x,le.y]);Xt({lngLat:Re}),fe&&be();return}oe&&(Ke.timer=setTimeout(vt,f))},Pt=D=>{if(Fe||D.touches.length!==1)return;const le=Ue(D);if(Ke&&!Ke.moved&&Math.hypot(le.x-Ke.startPx.x,le.y-Ke.startPx.y)>B&&(Ke.moved=!0,clearTimeout(Ke.timer)),L&&L.input==="touch")D.cancelable&&D.preventDefault(),bt(le);else if(fe){D.cancelable&&D.preventDefault(),ct=le;const be=e.unproject([le.x,le.y]);Yt({lngLat:be,point:le})}},it=D=>{if(D.touches.length>0)return;const le=Fe;Fe=!1;const be=Ke;if(Je(),le)return;if(L&&L.input==="touch"){D.cancelable&&D.preventDefault(),Ot(!1);return}if(fe){D.cancelable&&D.preventDefault(),qt();return}if(!be||be.fired||be.moved||j!=="point"&&j!=="line"&&j!=="polygon")return;D.cancelable&&D.preventDefault();const Re=be.startPx,Ee=e.unproject([Re.x,Re.y]);It(Ee.lng,Ee.lat,Re),Wt(rn(Re).pos,Re)},ot=()=>{Fe=!1,Je(),L&&L.input==="touch"&&Ot(!0),fe&&ft()};e.on("click",Gt),e.on("dblclick",_t),e.on("mousedown",Xt),e.on("mousemove",Yt),e.on("mouseup",qt),a&&typeof a.addEventListener=="function"&&a.addEventListener("keydown",Ve);const Nt=typeof e.getCanvasContainer=="function"?e.getCanvasContainer():null;Nt&&Nt.addEventListener("mousedown",zt,!0);const Tt=[["touchstart",$t],["touchmove",Pt],["touchend",it],["touchcancel",ot]];if(Nt)for(const[D,le]of Tt)Nt.addEventListener(D,le,{capture:!0,passive:!1});return{setMode:et,getFeatures:Dt,setFeatures:Ut,clear:Ht,undo:Oe,redo:Ae,applyTheme:wt,active:()=>j!==null,cursor:()=>Le,mode:()=>j,shapeAt:D=>Ge(D)!==null,destroy(){if(e.off("click",Gt),e.off("dblclick",_t),e.off("mousedown",Xt),e.off("mousemove",Yt),e.off("mouseup",qt),a&&typeof a.removeEventListener=="function"&&a.removeEventListener("keydown",Ve),Ot(!0),Nt&&Nt.removeEventListener("mousedown",zt,!0),Nt)for(const[D,le]of Tt)Nt.removeEventListener(D,le,{capture:!0});Je(),clearTimeout(Te),ze&&ze.parentNode&&ze.parentNode.removeChild(ze),ze=null,Bt(""),ve([])}}}const T=G}),qe("packages/modules/mapview/rowmove.js",function(t,ce){"use strict";Object.defineProperty(t,"createRowMove",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return te}});const _e=10,H=2,ue=6;function ie({map:n,doc:V,grid:E,draw:q,enabled:B,columns:f,items:S,redraw:y}){let P="",N=new Map,p=null;const u=(b,C)=>{const I=n.getCanvas().getBoundingClientRect();return{x:b-I.left,y:C-I.top}},h=()=>B()&&q.mode()==="edit"&&!!f(),c=b=>{if(N.has(b.key))return N.get(b.key);const C=f();let I=!1;try{I=!!C&&!!C.lat&&!!C.lon&&["lon","lat"].every((M,X)=>{const z=E.edit.previewPaste({key:b.key,colId:C[M]},String(b.position[X]),{rows:1,columns:1});return z.changes.length===1&&z.rejected.length===0})}catch{I=!1}return N.set(b.key,I),I},k=b=>{let C=null,I=_e;for(const M of S()){if(!M.position||M.isRoute||M.layer!=="point"&&M.layer!=="column")continue;const X=n.project(M.position),z=Math.hypot(X.x-b.x,X.y-b.y);z<=I&&(C=M,I=z)}return C&&c(C)?C:null},m=b=>{if(p)return;const C=u(b.clientX,b.clientY);P=h()&&!q.shapeAt(C)&&k(C)?"move":""},r=(b,C)=>{b.position=C,y()},v=(b,C,I)=>{const M=f(),X=[{key:b.key,colId:M.lat,value:I[1]},{key:b.key,colId:M.lon,value:I[0]}];try{if(!X.every(G=>{const T=E.edit.previewPaste({key:G.key,colId:G.colId},String(G.value),{rows:1,columns:1});return T.changes.length!==1||T.rejected.length!==0?!1:!(E.validation&&typeof E.validation.check=="function"?E.validation.check(G.colId,G.value,b.row):null)})){r(b,C);return}const ne=G=>{G!==2&&(Number(G)>0&&E.edit&&typeof E.edit.undo=="function"&&E.edit.undo(),r(b,C))},R=E.edit.setCells(X,"cell",{origin:"user"});R&&typeof R.then=="function"?R.then(ne,()=>r(b,C)):ne(R)}catch{r(b,C)}},l=b=>{if(!p)return;const C=u(b.clientX,b.clientY);if(!p.moved&&Math.hypot(C.x-p.startPx.x,C.y-p.startPx.y)<H)return;p.moved=!0;const I=n.unproject([C.x,C.y]);p.item.position=[I.lng,I.lat],y()},x=()=>{V.removeEventListener("mousemove",l),V.removeEventListener("mouseup",W),V.removeEventListener("keydown",J);try{n.dragPan&&typeof n.dragPan.enable=="function"&&n.dragPan.enable()}catch{}};function W(){if(!p)return;const{item:b,from:C,moved:I}=p,M=b.position;p=null,x(),I&&v(b,C,[Number(M[0].toFixed(ue)),Number(M[1].toFixed(ue))])}function J(b){if(b.key!=="Escape"||!p)return;const{item:C,from:I}=p;p=null,x(),r(C,I)}const se=b=>{if(p||b.button!==0||!h())return;const C=u(b.clientX,b.clientY);if(q.shapeAt(C))return;const I=k(C);if(I){b.stopPropagation();try{n.dragPan&&typeof n.dragPan.disable=="function"&&n.dragPan.disable()}catch{}p={item:I,from:I.position,startPx:C,moved:!1},V.addEventListener("mousemove",l),V.addEventListener("mouseup",W),V.addEventListener("keydown",J)}},re=typeof n.getCanvasContainer=="function"?n.getCanvasContainer():null;return re&&re.addEventListener("mousedown",se,!0),re&&re.addEventListener("mousemove",m,!0),{cursor:()=>h()?P:"",invalidate(){N=new Map},destroy(){if(p){const{item:b,from:C}=p;p=null,x(),b.position=C}re&&re.removeEventListener("mousedown",se,!0),re&&re.removeEventListener("mousemove",m,!0)}}}const te=ie}),qe("packages/modules/mapview/index.js",function(t,ce){"use strict";Object.defineProperty(t,"createMapView",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return we}});const H=ce("packages/core/src/internal/warn.js").warnOnce,ie=ce("packages/modules/shared/map-binding.js").createMapFeed,te=ce("packages/modules/mapview/model.js"),n=te.resolveGeometry,V=te.checkLayer,E=te.buildItems,q=te.drawColour,B=te.boundsOf,f=te.toDeckColour,S=te.tooltipColumns,y=te.tooltipLines,P=te.pathTimestamps,N=te.isSelected,p=te.HIGHLIGHT,u=te.HALO,h=te.FALLBACK_COLOUR,c=te.DEFAULT_BASEMAP,k=te.DEFAULT_DARK_BASEMAP,m=te.BUILDINGS_LAYER,r=te.ROUTE_ELEVATION,v=te.POINT_ELEVATION,l=te.ROUTE_WIDTH_RANGE,x=te.OVER_BUILDINGS,W=ce("packages/modules/mapview/icons.js"),J=W.createAtlas,se=W.badgeCell,re=ce("packages/modules/mapview/theme.js"),b=re.readRole,C=re.readRoleCss,M=ce("packages/modules/mapview/roles.js").BUILDING,X=ce("packages/modules/mapview/view.js"),z=X.place,ne=X.themeMode,R=X.message,T=ce("packages/modules/mapview/styles.js").NS,s=ce("packages/modules/shared/require-core.js").coreMissing,_=ce("packages/dom/src/watermark.js").mountViewWatermark,Q=ce("packages/modules/mapview/draw.js").createDraw,ge=ce("packages/modules/mapview/rowmove.js").createRowMove;s()&&H("mapview:requires-core","the map view module needs the Lattice core; load lattice-grid (or its script build) before modules/mapview.");const Se=Object.freeze(["feature:click","feature:hover","draw","load","close","map:click","draw:start","draw:change","draw:finish","edit:change","feature:select","feature:delete","draw:refused"]);function Ne(i,Y){const o=i&&i.element;return o&&typeof o.querySelector=="function"?o.querySelector(".lattice")||o:Y||o||null}function Le(i,Y){try{const o=i&&i.ownerDocument;if(!o||typeof o.createElement!="function")return i;const d=o.body||o.documentElement;if(!d||typeof d.appendChild!="function")return i;const O=o.createElement("div");return O.className="lattice",O.setAttribute("data-theme",Y),O.setAttribute("aria-hidden","true"),O.style.cssText="position:absolute;visibility:hidden;pointer-events:none;width:0;height:0;overflow:hidden",d.appendChild(O),O}catch{return i}}function j(i,Y,o){const d=o==="dark"||o==="light"?o:ne(i,Y),O=o==="dark"||o==="light",F=O?Le(i,o):i;let U=null,ee=null,L=null,Z=null,xe=null,g=null;try{if(F&&Y&&typeof Y.getComputedStyle=="function"){U=b(F,Y,"--lattice-map-layer-fill",220),ee=b(F,Y,"--lattice-map-highlight",255),L=b(F,Y,"--lattice-map-halo",180),Z=C(F,Y,"--lattice-map-building"),xe=Array.from({length:8},(K,ae)=>b(F,Y,`--lattice-chart-${ae+1}`,230));const A=[b(F,Y,"--lattice-chart-sequential-start"),b(F,Y,"--lattice-chart-sequential-end")];A.every(Boolean)&&(g=A),xe.every(Boolean)||(xe=null)}}catch{}return O&&F!==i&&F&&typeof F.remove=="function"&&F.remove(),{mode:d,accent:U||[...h],highlight:ee||[...p],halo:L||[...u],series:xe,sequential:g,building:o==="dark"||o==="light"?M[o]:Z||M[d]}}function pe(i,Y=null){let o=!1;const d={drawn:0,skipped:0,matched:0,rows:0,layers:{},computed:"client"};return{element:Y,map:null,overlay:null,getMap(){return null},draw:{setMode(){},getFeatures(){return{type:"FeatureCollection",features:[]}},setFeatures(){},clear(){},undo(){},redo(){}},update(){},flyTo(){},setLayer(){},provenance(){return{...d}},layers(){return[]},legend(){return{colours:[],dashes:[],sections:[]}},on(){return()=>{}},off(){},destroy(){o||(o=!0,i&&i())}}}const he=24;function oe(i){if(i.radiusUnits==="pixels")return{radiusUnits:"pixels",radiusMinPixels:0};const Y=Number.isFinite(i.radiusMaxPixels)&&i.radiusMaxPixels>0?i.radiusMaxPixels:he;return{radiusUnits:"meters",radiusMinPixels:3,radiusMaxPixels:Math.max(3,Y)}}function fe(i,Y){let o={...Y&&typeof Y=="object"?Y:{}};if(!i||!i.rows||!i.columns)return H("mapview:grid","createMapView: the first argument is not a grid; pass the grid whose rows the map shows. Nothing was drawn."),pe();let d=n(i,o.geometry);if(typeof d=="string")return H("mapview:geometry",`createMapView: the grid has no place to draw rows at: ${d}. Nothing was drawn.`),pe();V(o.layer);const O=o.libs&&typeof o.libs=="object"?o.libs:{},F=O.deck!==void 0?O.deck:globalThis.deck,U=O.maplibregl!==void 0?O.maplibregl:globalThis.maplibregl,ee=new Map(Se.map(me=>[me,new Set])),L=(me,Ce)=>{for(const Ve of[...ee.get(me)||[]])try{Ve(Ce)}catch(Ue){H(`mapview:listener:${me}`,`createMapView: a "${me}" listener threw: ${Ue&&Ue.message}`)}};let Z=!1,xe=null,g=null;const K=z(i,o,{onResize:()=>{if(g&&typeof g.resize=="function")try{g.resize()}catch{}},onClose(){L("close",{}),xe&&xe.destroy()}});if(typeof K=="string")return H("mapview:container",`createMapView: the map has nowhere to go: ${K}. Nothing was drawn.`),pe();const ae=[];if((!F||typeof F.MapboxOverlay!="function")&&ae.push("deck.gl (with MapboxOverlay)"),(!U||typeof U.Map!="function")&&ae.push("MapLibre GL (maplibregl.Map)"),ae.length){H("mapview:libs",`createMapView: ${ae.join(" and ")} ${ae.length>1?"are":"is"} not on the page; load the UMD build (it sets the global) or pass options.libs = { deck, maplibregl }. The map was left empty.`);const me=_(K.root,o).destroy;return pe(()=>{me(),K.unmount()},K.root)}const{win:ye,doc:ke}=K,Te=Ne(i,K.root);let ze=j(Te,ye,o.theme);const Ze=()=>o.basemap!==void 0&&o.basemap!==null?o.basemap:ze.mode==="dark"?k:c,He=o.view&&typeof o.view=="object"?o.view:null;g=new U.Map({container:K.mapEl,style:Ze(),center:He&&Array.isArray(He.center)?He.center:[0,20],zoom:He&&Number.isFinite(He.zoom)?He.zoom:1,pitch:He&&Number.isFinite(He.pitch)?He.pitch:o.elevation!==void 0||o.buildings?45:0,bearing:He&&Number.isFinite(He.bearing)?He.bearing:0});let Ke=new Set(i.selection&&typeof i.selection.keys=="function"?i.selection.keys():[]),Fe={items:[],skipped:0,byLayer:{point:[],column:[],polygon:[],path:[]},legend:[],dashLegend:[],legendSections:[],dashed:!1,routes:{drawn:0,skipped:0,rebuilt:0},icon:null,paths:[]},ct=new Map,tt={drawn:0,skipped:0,matched:0,rows:0,layers:{},computed:"client"},pt=[],Lt=[],jt=[],wt=[],gt=0,mt=0,Mt=0,ft=0,ht=0,et=!!He,Bt=!1,Dt=1,Ut=S(i,o.tooltip,d.columns,d.route?d.route.by:null);const Ht=new Map,Ft=J(i,ye,ke,()=>sn());let xt=null;const Wt=me=>typeof ye.requestAnimationFrame=="function"?ye.requestAnimationFrame(me):setTimeout(()=>me(Date.now()),16),Gt=me=>{typeof ye.requestAnimationFrame=="function"&&typeof ye.cancelAnimationFrame=="function"?ye.cancelAnimationFrame(me):clearTimeout(me)},It=()=>{try{return!!(ye&&typeof ye.matchMedia=="function"&&ye.matchMedia("(prefers-reduced-motion: reduce)").matches)}catch{return!1}},_t=()=>{const me=o.flow;if(!me)return null;const Ce=me===!0?{}:me,Ve=Number.isFinite(Ce.speed)&&Ce.speed>0?Ce.speed:.25,Ue=Number.isFinite(Ce.trail)&&Ce.trail>0?Math.min(1,Ce.trail):.3;return{speed:Ve,trail:Ue}},Xt=me=>{if(!(!me||typeof me!="object"))return me.item?me.item.key:me.properties&&me.properties.__mapview?me.properties.key:me.__mapview?me.key:void 0},Yt=()=>{const{byLayer:me}=Fe,Ce={getFillColor:gt,getLineColor:gt,getColor:gt,getPosition:mt},Ve=it=>q(it,ze),Ue=[],Je=[];if(me.polygon.length){const it=o.elevation!==void 0&&o.elevation!==null;Ue.push(new F.GeoJsonLayer({id:"lattice-mapview-polygon",data:me.polygon.map(ot=>ot.feature),pickable:!0,filled:!0,stroked:!0,extruded:it,wireframe:!1,elevationScale:Number.isFinite(o.elevationScale)?o.elevationScale:1,lineWidthMinPixels:1,...it?{}:{parameters:x},getElevation:ot=>ot.properties.elevation,getFillColor:ot=>{const Nt=Ve(ot.properties);return[Nt[0],Nt[1],Nt[2],Math.min(Nt[3]??255,170)]},getLineColor:ot=>ot.properties.selected?ze.highlight:Ve(ot.properties),updateTriggers:Ce}))}if(me.path.length){const[it,ot]=l,Nt=D=>Math.max(it,Math.min(ot,(D.item.selected?D.item.width+3:D.item.width)*Dt));let Tt={};Fe.dashed&&(typeof F.PathStyleExtension=="function"?Tt={extensions:[new F.PathStyleExtension({dash:!0})],dashGapPickable:!0,getDashArray:D=>D.item.dash?[2*D.item.dash[0]/Nt(D),2*D.item.dash[1]/Nt(D)]:[0,0]}:H("mapview:dash","createMapView: dash is set but deck.gl has no PathStyleExtension (the page's deck.gl build does not export it); the lines are drawn solid. Load deck.gl's full bundle, or pass it as options.libs.deck.")),Ue.push(new F.PathLayer({id:"lattice-mapview-path",data:Fe.paths,pickable:!0,widthUnits:"pixels",widthScale:Dt,widthMinPixels:it,widthMaxPixels:ot,capRounded:!Tt.extensions,jointRounded:!Tt.extensions,getPath:D=>D.path,getWidth:D=>D.item.selected?D.item.width+3:D.item.width,getColor:D=>Ve(D.item),updateTriggers:{...Ce,getWidth:gt,getDashArray:gt},...Tt}))}me.column.length&&Je.push(new F.ColumnLayer({id:"lattice-mapview-column",data:me.column,pickable:!0,extruded:!0,diskResolution:12,radius:typeof o.radius=="number"&&o.radius>0&&o.radiusUnits!=="pixels"?o.radius:30,elevationScale:Number.isFinite(o.elevationScale)?o.elevationScale:1,getPosition:it=>it.position,getElevation:it=>it.elevation,getFillColor:Ve,updateTriggers:Ce}));const vt=Fe.paths.length>0,$t=Fe.icon&&!Ft.unavailable()?me.point.filter(it=>it.icon&&Ft.has(it.icon)):[],Pt=$t.length?me.point.filter(it=>!(it.icon&&Ft.has(it.icon))):me.point;if(Pt.length&&Je.push(new F.ScatterplotLayer({id:"lattice-mapview-point",data:Pt,pickable:!0,stroked:!0,...oe(o),lineWidthUnits:"pixels",getLineWidth:1,parameters:x,getPosition:vt?it=>[it.position[0],it.position[1],v]:it=>it.position,getRadius:it=>it.radius,getFillColor:Ve,getLineColor:it=>it.selected?ze.highlight:ze.halo,updateTriggers:Ce})),$t.length){const{badge:it}=Fe.icon,ot=[255,255,255,255],Nt={data:$t,iconAtlas:Ft.image(),iconMapping:Ft.mapping(Fe.icon.anchor),billboard:!0,sizeUnits:"pixels",alphaCutoff:.05,parameters:{depthCompare:"always",depthWriteEnabled:!1},getPosition:Tt=>Tt.position,updateTriggers:{...Ce,getIcon:gt,getSize:gt}};it?(Je.push(new F.IconLayer({...Nt,id:"lattice-mapview-icon-ring",pickable:!1,getIcon:()=>se(it),getSize:Tt=>Tt.iconSize*1.16,getColor:()=>ot})),Je.push(new F.IconLayer({...Nt,id:"lattice-mapview-icon",pickable:!0,getIcon:()=>se(it),getSize:Tt=>Tt.iconSize,getColor:Ve})),Je.push(new F.IconLayer({...Nt,id:"lattice-mapview-icon-glyph",pickable:!1,getIcon:Tt=>Tt.icon,getSize:Tt=>Tt.iconSize*.56,getColor:()=>ot}))):Je.push(new F.IconLayer({...Nt,id:"lattice-mapview-icon",pickable:!0,getIcon:Tt=>Tt.icon,getSize:Tt=>Tt.iconSize,getColor:Ve}))}return{under:Ue,over:Je}},qt=me=>{const Ce=_t();if(!Ce||!Fe.paths.length||typeof F.TripsLayer!="function")return null;const Ve=100+Ce.trail*100,Ue=(me-ht)/1e3*Ce.speed*100%Ve;return new F.TripsLayer({id:"lattice-mapview-flow",data:Fe.paths,widthUnits:"pixels",widthScale:Dt,widthMinPixels:3,capRounded:!0,jointRounded:!0,fadeTrail:!0,trailLength:Ce.trail*100,currentTime:Ue,getPath:Je=>Je.path,getTimestamps:Je=>Je.timestamps,getWidth:Je=>Je.item.width+1,getColor:ze.mode==="dark"?[255,255,255,230]:[255,214,0,240]})},Jt=()=>!!_t()&&Fe.paths.length>0&&!It()&&typeof F.TripsLayer=="function"&&!(ke&&ke.visibilityState==="hidden"),nn=me=>{const Ce=Jt()?qt(me):null;jt=Ce?[...pt,Ce,...Lt]:[...pt,...Lt],Oe.setProps({layers:[...jt,...wt]})},mn=me=>{ft=0,!(Z||!Jt())&&(nn(typeof me=="number"?me:Date.now()),ft=Wt(mn))},rn=()=>{Z||ft||!Jt()||(ht||(ht=Date.now()),ft=Wt(mn))},fn=()=>{ke.visibilityState==="hidden"?(ft&&(Gt(ft),ft=0),nn(Date.now())):rn()};ke&&typeof ke.addEventListener=="function"&&ke.addEventListener("visibilitychange",fn);const gn=()=>{try{const me=typeof g.getPitch=="function"?Number(g.getPitch()):0;return Number.isFinite(me)?Math.round(1/Math.max(Math.cos(Math.min(Math.max(me,0),85)*Math.PI/180),.5)*20)/20:1}catch{return 1}},hn=()=>{if(!Z){gt++;for(const me of Fe.items)me.selected=N(me,Ke);({under:pt,over:Lt}=Yt()),nn(Date.now())}},ln=()=>{const me=gn();Z||me===Dt||(Dt=me,Fe.paths.length&&(gt++,{under:pt,over:Lt}=Yt(),nn(Date.now())))},Qt=()=>{try{const me=g.getBounds();if(me&&typeof me.getWest=="function")return[me.getWest(),me.getSouth(),me.getEast(),me.getNorth()]}catch{}return null},cn=(me,Ce)=>{if(!me.length)return;const Ve=B(me);if(!Ve)return;const[Ue,Je,vt,$t]=Ve;if(Ue===vt&&Je===$t){const Pt=Math.max(typeof g.getZoom=="function"?g.getZoom():0,15);Ce?g.flyTo({center:[Ue,Je],zoom:Pt}):g.jumpTo({center:[Ue,Je],zoom:Pt});return}g.fitBounds([[Ue,Je],[vt,$t]],{padding:48,maxZoom:16,...Ce?{}:{duration:0}})};let on=null;const Kt=()=>{on&&on.close(),on=ie(i,d.position,{ids:!0,leaves:!0,readPlace:d.readPlace||void 0,viewportCap:o.viewportCap,onAnswer:()=>sn()})};Kt();const yn=me=>`rgba(${me[0]},${me[1]},${me[2]},${(me[3]??255)/255})`,en=()=>{if(!o.legend){xt&&(xt.hidden=!0);return}xt||(xt=K.doc.createElement("div"),xt.className=`${T}__legend`,xt.setAttribute("role","group"),xt.setAttribute("aria-label",R(i,"mapview.legend")),K.root.appendChild(xt)),xt.replaceChildren();const me=(Ue,Je)=>{const vt=K.doc.createElement("div");vt.className=`${T}__legend-row`;const $t=K.doc.createElement("span");$t.textContent=Ue,vt.appendChild(Je),vt.appendChild($t),xt.appendChild(vt)},Ce=(Ue,Je)=>Ue?`repeating-linear-gradient(90deg, ${Je} 0 ${Ue[0]}px, transparent ${Ue[0]}px ${Ue[0]+Ue[1]}px)`:Je,Ve=Fe.legendSections;for(const Ue of Ve){if(Ve.length>1&&Ue.title){const Je=K.doc.createElement("div");Je.className=`${T}__legend-title`,Je.textContent=Ue.title,xt.appendChild(Je)}for(const Je of Ue.entries){const vt=K.doc.createElement("span"),$t=Je.colour?yn(Je.colour):"currentColor";Je.line?(vt.className=`${T}__legend-line`,vt.style.background=Ce(Je.dash,$t)):(vt.className=`${T}__legend-swatch`,vt.style.background=$t),me(Je.label,vt)}}xt.hidden=xt.children.length===0},tn=()=>{if(Z)return;Mt&&(Gt(Mt),Mt=0),Ge.invalidate();const me=on.read(Qt());me.over&&H("mapview:over",`createMapView: the map's view holds ${me.over.count} matching rows, more than its viewportCap of ${me.over.cap}, and ${me.over.reason}, so none were drawn. Zoom in, narrow the filter, or raise viewportCap.`),gt++,Fe=E(i,me.binned?{features:[],keys:[]}:me,o,ze,Ke,{placement:d,routeCache:Ht}),Fe.paths=[];for(const Ue of Fe.items)if(Ue.layer==="polygon"&&(Ue.feature={type:"Feature",geometry:Ue.geometry,properties:Ue}),Ue.__mapview=!0,Ue.layer==="path")for(const Je of Ue.lines){const vt=P(Je),$t=vt[vt.length-1]||1;Fe.paths.push({item:Ue,path:Je.map(Pt=>[Pt[0],Pt[1],r]),timestamps:vt.map(Pt=>Pt/$t*100)})}ct=new Map;for(const Ue of Fe.items)for(const Je of Ue.keys||[Ue.key])ct.set(Je,Ue);if(Fe.icon&&Ft.ensure(Fe.icon.refs,Fe.icon.badge?[Fe.icon.badge]:[]),Fe.icon)for(const Ue of Ft.unknown())H(`mapview:icon:${Ue}`,`createMapView: icon "${Ue}" is not a glyph of the grid's icon registry, an SVG path or an image URL; the points that ask for it are drawn as circles.`);Fe.icon&&Ft.unavailable()&&H("mapview:icons","createMapView: icon is set but there is no canvas to draw the icon atlas on; points are drawn as circles."),Dt=gn(),{under:pt,over:Lt}=Yt();const Ce={};for(const[Ue,Je]of Object.entries(Fe.byLayer))Je.length&&(Ce[Ue]=Je.length);const Ve=Fe.icon&&!Ft.unavailable()?Fe.byLayer.point.filter(Ue=>Ue.icon&&Ft.has(Ue.icon)).length:0;Ve&&(Ce.icon=Ve,Ve===Fe.byLayer.point.length?delete Ce.point:Ce.point=Fe.byLayer.point.length-Ve),tt={...me.provenance,drawn:Fe.items.reduce((Ue,Je)=>Ue+(Je.keys?Je.keys.length:1),0),skipped:(me.provenance.skipped||0)+Fe.skipped,matched:me.provenance.matched,layers:Ce,...d.route?{routes:Fe.routes.drawn,routesSkipped:Fe.routes.skipped,routesRebuilt:Fe.routes.rebuilt}:{}},en(),nn(Date.now()),rn(),!et&&Fe.items.length&&(et=!0,cn(Fe.items,!1)),L("draw",{provenance:{...tt}})};function sn(){Z||Mt||(Mt=Wt(()=>{Mt=0,tn()}))}const un=me=>{const Ce=i.rows;if(!(typeof Ce.leavesOf!="function"||typeof Ce.expand!="function"))for(let Ve=0;Ve<12;Ve++){let Ue=!1;const Je=[];if(Ce.forEach($t=>{$t&&($t.group?$t.expanded||Je.push($t):$t.key===me&&(Ue=!0))}),Ue)return;const vt=Je.find($t=>Ce.leavesOf($t.key).some(Pt=>Pt&&Pt.key===me));if(!vt)return;Ce.expand(vt.key)}},w=me=>{if(Z||!i.selection||typeof i.selection.set!="function")return;const Ce=me[0];Bt=!0;try{i.selection.set(me)}finally{Bt=!1}if(typeof i.selection.keys=="function"&&!i.selection.keys().some(Ve=>me.includes(Ve))&&H("mapview:selection",`createMapView: row ${JSON.stringify(Ce)} was clicked on the map but the grid did not select it: a grid selects nothing unless it is created with selection: 'single' or 'multiple', and a beforeSelect handler can refuse it.`),un(Ce),i.scroll&&typeof i.scroll.toRow=="function")try{i.scroll.toRow(Ce,"center")}catch{}},Me=me=>{if(Z)return;const Ce=Xt(me&&me.object),Ve=K.tooltip;if(Ce===void 0||!Ut.length){Ve.hidden=!0,Ce===void 0&&L("feature:hover",{key:null,row:null,lines:[]});return}const Ue=ct.get(Ce),Je=d.route?d.route.by:null,vt=Je&&!(Ue&&Ue.isRoute)?Ut.filter(Pt=>Pt!==Je):Ut,$t=y(i,Ce,vt,Ue?Ue.row:null);Ve.replaceChildren();for(const Pt of $t){const it=K.doc.createElement("div"),ot=K.doc.createElement("span");ot.className=`${T}__tip-title`,ot.textContent=Pt.title;const Nt=K.doc.createElement("span");Nt.textContent=Pt.text,it.appendChild(ot),it.appendChild(Nt),Ve.appendChild(it)}Ve.style.left=`${Math.round((me.x||0)+12)}px`,Ve.style.top=`${Math.round((me.y||0)+12)}px`,Ve.hidden=!1,L("feature:hover",{key:Ce,row:Ue?Ue.row:null,lines:$t})},de=me=>{if(Ie.active())return;const Ce=Xt(me&&me.object);if(Ce===void 0)return;const Ve=ct.get(Ce);w(Ve&&Ve.keys?[...Ve.keys]:[Ce]),L("feature:click",{key:Ce,row:Ve?Ve.row:null,...Ve&&Ve.isRoute?{route:Ve.route,keys:[...Ve.keys]}:{}})};let $e=()=>"",Pe=()=>"";const Oe=new F.MapboxOverlay({interleaved:!0,layers:[],onClick:de,onHover:Me,getCursor:({isDragging:me})=>$e()||Pe()||(me?"grabbing":"grab")});(()=>{const me=g.transform;if(!(!me||typeof me!="object"||"_nearZ"in me||!("nearZ"in me)))try{Object.defineProperty(me,"_nearZ",{configurable:!0,get(){return this.nearZ}}),Object.defineProperty(me,"_farZ",{configurable:!0,get(){return this.farZ}})}catch{}})(),g.addControl(Oe);const Ie=Q({map:g,deck:F,doc:ke,theme:()=>ze,emit:L,pick:(me,Ce)=>{try{return Oe.pickMultipleObjects({x:me,y:Ce,radius:4})||[]}catch{return[]}},setLayers:me=>{wt=me,Oe.setProps({layers:[...jt,...wt]})},format:(me,Ce)=>i.messages&&typeof i.messages.number=="function"?i.messages.number(me,Ce):new Intl.NumberFormat(void 0,Ce).format(me),text:me=>R(i,me)});Ie.applyTheme(),$e=()=>Ie.cursor();const Ge=ge({map:g,doc:ke,grid:i,draw:Ie,enabled:()=>!!o.moveRows,columns:()=>d.kind==="point"&&!d.route&&!d.segment?d.position:null,items:()=>Fe.items,redraw(){Z||(mt++,{under:pt,over:Lt}=Yt(),nn(Date.now()))}});Pe=()=>Ge.cursor();const nt=()=>{if(Z||!o.buildings||typeof g.getLayer=="function"&&g.getLayer(m))return;const me=typeof g.getStyle=="function"?g.getStyle():null,Ce=me&&me.sources?me.sources:{},Ve=Object.keys(Ce).find(Ue=>Ue==="openmaptiles"&&Ce[Ue].type==="vector")||Object.keys(Ce).find(Ue=>Ce[Ue]&&Ce[Ue].type==="vector");if(!Ve){H("mapview:buildings",'createMapView: buildings is on but the basemap style has no vector source with an OpenMapTiles "building" layer; no buildings were drawn. Use an OpenMapTiles style such as the default.');return}g.addLayer({id:m,type:"fill-extrusion",source:Ve,"source-layer":"building",minzoom:13,paint:{"fill-extrusion-color":ze.building,"fill-extrusion-height":["coalesce",["get","render_height"],0],"fill-extrusion-base":["coalesce",["get","render_min_height"],0],"fill-extrusion-opacity":.75}})},Ye=()=>{typeof g.getLayer=="function"&&g.getLayer(m)&&g.removeLayer(m)},st=()=>{nt(),L("load",{map:g})},at=()=>{tt.computed==="engine"&&sn()};g.on("style.load",st),g.on("moveend",at),g.on("pitch",ln);const lt=()=>sn(),Ot=[["model:changed",lt],["rows:changed",lt],["selection:changed",()=>{Ke=new Set(i.selection&&typeof i.selection.keys=="function"?i.selection.keys():[]),hn(),!Bt&&Ke.size&&zt([...Ke])}],["config:changed",me=>{if(!me||me.key!=="theme"&&!(Array.isArray(me.keys)&&me.keys.includes("theme")))return;const Ce=j(Te,ye,o.theme);Ce.mode!==ze.mode&&(ze=Ce,Ie.applyTheme(),tn(),g.setStyle(Ze()))}]].map(([me,Ce])=>{const Ve=i.on(me,Ce);return typeof Ve=="function"?Ve:()=>i.off(me,Ce)});function zt(me){if(Z)return;const Ve=(Array.isArray(me)?me:[me]).map(Ue=>ct.get(Ue)).filter(Boolean);cn(Ve,!0)}tn();const At=_(K.root,o).destroy;return xe={element:K.root,map:g,overlay:Oe,getMap(){return g},draw:{setMode(me,Ce){Ie.setMode(me,Ce)},getFeatures(){return Ie.getFeatures()},setFeatures(me){Ie.setFeatures(me)},clear(){Ie.clear()},undo(){Ie.undo()},redo(){Ie.redo()}},update(me){if(Z)return;const Ce=me&&typeof me=="object"?me:{},Ve=o;if(o={...o,...Ce},"layer"in Ce&&V(Ce.layer),"geometry"in Ce){const Ue=n(i,o.geometry);typeof Ue=="string"?(H("mapview:geometry",`createMapView: the grid has no place to draw rows at: ${Ue}. Nothing was drawn.`),o=Ve):(d=Ue,Ht.clear(),Kt())}if(("tooltip"in Ce||"geometry"in Ce)&&(Ut=S(i,o.tooltip,d.columns,d.route?d.route.by:null)),"theme"in Ce&&(ze=j(Te,ye,o.theme),Ie.applyTheme()),("basemap"in Ce||"theme"in Ce)&&g.setStyle(Ze()),"buildings"in Ce&&(o.buildings?nt():Ye()),"view"in Ce&&Ce.view&&typeof Ce.view=="object"){const Ue=Ce.view;g.jumpTo({...Array.isArray(Ue.center)?{center:Ue.center}:{},...Number.isFinite(Ue.zoom)?{zoom:Ue.zoom}:{},...Number.isFinite(Ue.pitch)?{pitch:Ue.pitch}:{},...Number.isFinite(Ue.bearing)?{bearing:Ue.bearing}:{}})}tn()},flyTo:zt,setLayer(me){xe.update({layer:me})},view(){if(!g||typeof g.getCenter!="function"||typeof g.getZoom!="function")return{center:null,zoom:1,pitch:0,bearing:0};const me=g.getCenter();return{center:Array.isArray(me)?me:me&&Number.isFinite(me.lng)&&Number.isFinite(me.lat)?[me.lng,me.lat]:null,zoom:Number(g.getZoom())||0,pitch:typeof g.getPitch=="function"&&Number(g.getPitch())||0,bearing:typeof g.getBearing=="function"&&Number(g.getBearing())||0}},layer(){return o.layer||null},provenance(){return{...tt}},layers(){return jt},legend(){return{colours:Fe.legend.map(me=>({...me})),dashes:Fe.dashLegend.map(me=>({label:me.label,dash:me.dash?[...me.dash]:null})),sections:Fe.legendSections.map(me=>({...me,entries:me.entries.map(Ce=>({...Ce,colour:Ce.colour?[...Ce.colour]:null,dash:Ce.dash?[...Ce.dash]:null}))}))}},on(me,Ce){return!ee.has(me)||typeof Ce!="function"?(H(`mapview:event:${String(me)}`,`createMapView: "${String(me)}" is not an event a map view emits; use ${Se.join(", ")}.`),()=>{}):(ee.get(me).add(Ce),()=>ee.get(me).delete(Ce))},off(me,Ce){const Ve=ee.get(me);Ve&&Ve.delete(Ce)},destroy(){if(!Z){Z=!0,Mt&&Gt(Mt),ft&&Gt(ft),Mt=0,ft=0;for(const me of Ot)me();Ge.destroy(),Ie.destroy(),ke&&typeof ke.removeEventListener=="function"&&ke.removeEventListener("visibilitychange",fn),on&&on.close();try{g.off("style.load",st),g.off("moveend",at),g.off("pitch",ln)}catch{}try{g.removeControl(Oe)}catch{}try{g.remove()}catch{}for(const me of ee.values())me.clear();At(),K.unmount()}}},xe}const we=fe});var Sn=jn("packages/modules/mapview/index.js");typeof module=="object"&&module.exports?module.exports=Sn:typeof define=="function"&&define.amd?define(function(){return Sn}):Cn.LatticeGridMapView=Sn})(typeof globalThis<"u"?globalThis:this);
560
560
 
561
561
  //# sourceMappingURL=mapview.min.js.map