@defra/interactive-map 0.0.40-alpha → 0.0.42-alpha

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 (374) hide show
  1. package/dist/css/index.css +1 -1
  2. package/dist/esm/im-core.js +1 -1
  3. package/dist/esm/im-shell.js +1 -1
  4. package/dist/umd/im-core.js +1 -1
  5. package/dist/umd/index.js +1 -1
  6. package/docs/api/button-definition.md +7 -8
  7. package/docs/api/control-definition.md +17 -1
  8. package/docs/api/panel-definition.md +5 -0
  9. package/docs/api/slots.md +50 -6
  10. package/docs/assets/images/slot-map.svg +61 -262
  11. package/docs/examples/add-polygons.mdx +8 -2
  12. package/docs/examples/add-symbols.mdx +8 -2
  13. package/docs/examples/draw-tools.mdx +3 -3
  14. package/docs/plugins/datasets.md +23 -15
  15. package/docs/plugins/draw.md +79 -16
  16. package/docs/plugins/map-key.md +147 -0
  17. package/docs/plugins/search.md +1 -1
  18. package/docs/plugins.md +5 -1
  19. package/govuk-prototype-kit.config.json +2 -0
  20. package/jest.setup.js +5 -0
  21. package/package.json +9 -1
  22. package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +1 -1
  23. package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -1
  24. package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -1
  25. package/plugins/beta/draw-ol/dist/esm/im-draw-ol-plugin.js +1 -1
  26. package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +1 -1
  27. package/plugins/beta/map-styles/dist/umd/index.js +1 -1
  28. package/plugins/beta/use-location/dist/esm/im-use-location-plugin.js +1 -1
  29. package/plugins/beta/use-location/dist/umd/im-use-location-plugin.js +1 -1
  30. package/plugins/beta/use-location/src/manifest.js +1 -1
  31. package/plugins/datasets/dist/css/index.css +1 -1
  32. package/plugins/datasets/dist/esm/esriLayerAdapter.js +1 -1
  33. package/plugins/datasets/dist/esm/im-datasets-ml-adapter.js +1 -1
  34. package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
  35. package/plugins/datasets/dist/umd/im-datasets-esri-adapter.js +1 -1
  36. package/plugins/datasets/dist/umd/im-datasets-ml-adapter.js +1 -1
  37. package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
  38. package/plugins/datasets/dist/umd/index.js +1 -1
  39. package/plugins/datasets/src/adapters/esri/esriLayerAdapter.test.js +175 -0
  40. package/plugins/datasets/src/adapters/esri/registry/esriDataset.test.js +55 -0
  41. package/plugins/datasets/src/adapters/loadLayerAdapter.test.js +61 -0
  42. package/plugins/datasets/src/adapters/maplibre/maplibreLayerAdapter.test.js +14 -0
  43. package/plugins/datasets/src/api/setOpacity.test.js +9 -0
  44. package/plugins/datasets/src/components/LayersMenu/LayersMenu.jsx +10 -25
  45. package/plugins/datasets/src/components/LayersMenu/LayersMenu.test.jsx +0 -42
  46. package/plugins/datasets/src/datasets.scss +0 -1
  47. package/plugins/datasets/src/fetch/createDynamicSource.js +135 -129
  48. package/plugins/datasets/src/fetch/createDynamicSource.test.js +318 -0
  49. package/plugins/datasets/src/fetch/fetchGeoJSON.test.js +83 -0
  50. package/plugins/datasets/src/index.test.js +36 -0
  51. package/plugins/datasets/src/initialise/DatasetsInit.jsx +17 -7
  52. package/plugins/datasets/src/initialise/DatasetsInit.test.jsx +262 -0
  53. package/plugins/datasets/src/initialise/initialiseDatasets.js +16 -4
  54. package/plugins/datasets/src/initialise/initialiseDatasets.test.js +42 -0
  55. package/plugins/datasets/src/manifest.js +0 -38
  56. package/plugins/datasets/src/manifest.test.js +49 -0
  57. package/plugins/datasets/src/reducers/datasetsToMenu.test.js +54 -1
  58. package/plugins/datasets/src/reducers/pluginState.js +3 -16
  59. package/plugins/datasets/src/reducers/pluginState.test.js +23 -0
  60. package/plugins/datasets/src/registry/dataset.js +13 -1
  61. package/plugins/datasets/src/registry/dataset.test.js +61 -0
  62. package/plugins/datasets/src/registry/datasetRegistry.js +12 -6
  63. package/plugins/datasets/src/registry/datasetRegistry.test.js +16 -4
  64. package/plugins/datasets/src/registry/isVisibleWhen.js +6 -3
  65. package/plugins/datasets/src/registry/isVisibleWhen.test.js +11 -1
  66. package/plugins/datasets/src/utils/bbox.test.js +125 -0
  67. package/plugins/draw/dist/esm/im-draw-ml-adapter.js +1 -1
  68. package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -1
  69. package/plugins/draw/dist/esm/im-draw-plugin.js +1 -1
  70. package/plugins/draw/dist/esm/index.js +1 -1
  71. package/plugins/draw/dist/umd/im-draw-ml-adapter.js +2 -1
  72. package/plugins/draw/dist/umd/im-draw-ml-adapter.js.LICENSE.txt +1 -0
  73. package/plugins/draw/dist/umd/im-draw-ol-adapter.js +1 -1
  74. package/plugins/draw/dist/umd/im-draw-plugin.js +1 -1
  75. package/plugins/draw/dist/umd/index.js +1 -1
  76. package/plugins/draw/src/DrawInit.jsx +10 -2
  77. package/plugins/draw/src/DrawInit.test.jsx +51 -10
  78. package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.js +91 -11
  79. package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.test.js +246 -4
  80. package/plugins/draw/src/adapters/maplibre/mapboxDraw.js +109 -14
  81. package/plugins/draw/src/adapters/maplibre/mapboxDraw.test.js +174 -11
  82. package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.test.js +12 -0
  83. package/plugins/draw/src/adapters/maplibre/modes/drawMode/lifecycle.js +9 -1
  84. package/plugins/draw/src/adapters/maplibre/modes/drawMode/lifecycle.test.js +24 -3
  85. package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.js +194 -0
  86. package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.test.js +457 -0
  87. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/__helpers__/harness.js +102 -0
  88. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/keyboardHandlers.js +82 -0
  89. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/keyboardHandlers.test.js +83 -0
  90. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointOperations.js +55 -0
  91. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointOperations.test.js +62 -0
  92. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointerHandlers.js +138 -0
  93. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointerHandlers.test.js +197 -0
  94. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/touchHandlers.js +92 -0
  95. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/touchHandlers.test.js +101 -0
  96. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/undoHandlers.js +46 -0
  97. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/undoHandlers.test.js +42 -0
  98. package/plugins/draw/src/adapters/maplibre/modes/editPointMode.js +151 -0
  99. package/plugins/draw/src/adapters/maplibre/modes/editPointMode.test.js +156 -0
  100. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/keyboardHandlers.js +4 -27
  101. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/keyboardHandlers.test.js +24 -39
  102. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/pointerHandlers.js +4 -5
  103. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/touchHandlers.js +20 -23
  104. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/touchHandlers.test.js +25 -5
  105. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.js +6 -36
  106. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.test.js +7 -49
  107. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/vertexOperations.js +3 -53
  108. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/vertexOperations.test.js +8 -33
  109. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode.js +29 -72
  110. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode.test.js +10 -3
  111. package/plugins/draw/src/adapters/maplibre/pointSymbolImages.js +158 -0
  112. package/plugins/draw/src/adapters/maplibre/pointSymbolImages.test.js +314 -0
  113. package/plugins/draw/src/adapters/maplibre/snap/prototypePatches.js +6 -1
  114. package/plugins/draw/src/adapters/maplibre/snap/prototypePatches.test.js +21 -0
  115. package/plugins/draw/src/adapters/maplibre/snap/snapInstance.js +6 -2
  116. package/plugins/draw/src/adapters/maplibre/snap/snapInstance.test.js +12 -0
  117. package/plugins/draw/src/adapters/maplibre/styles.js +38 -11
  118. package/plugins/draw/src/adapters/maplibre/styles.test.js +39 -0
  119. package/plugins/draw/src/adapters/maplibre/utils/editModeEvents.js +79 -0
  120. package/plugins/draw/src/adapters/maplibre/utils/editModeEvents.test.js +135 -0
  121. package/plugins/draw/src/adapters/maplibre/utils/geometryValidation.js +42 -0
  122. package/plugins/draw/src/adapters/maplibre/utils/geometryValidation.test.js +85 -0
  123. package/plugins/draw/src/adapters/maplibre/utils/keyboardShortcuts.js +34 -0
  124. package/plugins/draw/src/adapters/maplibre/utils/keyboardShortcuts.test.js +78 -0
  125. package/plugins/draw/src/adapters/maplibre/utils/snapHelpers.js +16 -3
  126. package/plugins/draw/src/adapters/maplibre/utils/snapHelpers.test.js +21 -3
  127. package/plugins/draw/src/adapters/maplibre/utils/snapMovement.js +59 -0
  128. package/plugins/draw/src/adapters/maplibre/utils/snapMovement.test.js +73 -0
  129. package/plugins/draw/src/adapters/maplibre/utils/touchDragMath.js +33 -0
  130. package/plugins/draw/src/adapters/maplibre/utils/touchDragMath.test.js +70 -0
  131. package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.js +27 -2
  132. package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.test.js +93 -0
  133. package/plugins/draw/src/adapters/openlayers/__helpers__/harness.js +9 -0
  134. package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.js +19 -1
  135. package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.test.js +34 -1
  136. package/plugins/draw/src/adapters/openlayers/core/styles.js +73 -1
  137. package/plugins/draw/src/adapters/openlayers/core/styles.test.js +122 -3
  138. package/plugins/draw/src/adapters/openlayers/draw/DrawMode.test.js +12 -0
  139. package/plugins/draw/src/adapters/openlayers/draw/drawInput.js +8 -2
  140. package/plugins/draw/src/adapters/openlayers/edit/EditMode.test.js +31 -0
  141. package/plugins/draw/src/adapters/openlayers/edit/keyboardHandler.js +9 -5
  142. package/plugins/draw/src/adapters/openlayers/edit/keyboardHandler.test.js +33 -0
  143. package/plugins/draw/src/adapters/openlayers/edit/modifyInteraction.js +5 -3
  144. package/plugins/draw/src/adapters/openlayers/edit/modifyInteraction.test.js +11 -0
  145. package/plugins/draw/src/adapters/openlayers/edit/nudge.js +10 -3
  146. package/plugins/draw/src/adapters/openlayers/edit/nudge.test.js +24 -1
  147. package/plugins/draw/src/adapters/openlayers/edit/touchHandler.js +18 -13
  148. package/plugins/draw/src/adapters/openlayers/edit/touchHandler.test.js +46 -1
  149. package/plugins/draw/src/adapters/openlayers/olDraw.js +11 -4
  150. package/plugins/draw/src/adapters/openlayers/olDraw.test.js +48 -6
  151. package/plugins/draw/src/adapters/openlayers/point/drawPointMode.js +156 -0
  152. package/plugins/draw/src/adapters/openlayers/point/drawPointMode.test.js +246 -0
  153. package/plugins/draw/src/adapters/openlayers/point/editPointMode.js +267 -0
  154. package/plugins/draw/src/adapters/openlayers/point/editPointMode.test.js +327 -0
  155. package/plugins/draw/src/adapters/openlayers/point/pointDragInteraction.js +71 -0
  156. package/plugins/draw/src/adapters/openlayers/point/pointOps.js +34 -0
  157. package/plugins/draw/src/adapters/openlayers/point/pointOps.test.js +32 -0
  158. package/plugins/draw/src/adapters/openlayers/point/pointSelectionState.js +82 -0
  159. package/plugins/draw/src/adapters/openlayers/point/pointSelectionState.test.js +107 -0
  160. package/plugins/draw/src/adapters/openlayers/point/pointSymbolImages.js +83 -0
  161. package/plugins/draw/src/adapters/openlayers/point/pointSymbolImages.test.js +214 -0
  162. package/plugins/draw/src/adapters/openlayers/snap/snapIndicator.js +3 -1
  163. package/plugins/draw/src/adapters/openlayers/snap/snapInteraction.js +6 -9
  164. package/plugins/draw/src/adapters/openlayers/snap/snapInteraction.test.js +15 -4
  165. package/plugins/draw/src/adapters/openlayers/utils/olCoords.js +1 -1
  166. package/plugins/draw/src/api/addFeature.js +16 -1
  167. package/plugins/draw/src/api/addFeature.test.js +62 -5
  168. package/plugins/draw/src/api/createNewShape.js +41 -0
  169. package/plugins/draw/src/api/createNewShape.test.js +63 -0
  170. package/plugins/draw/src/api/editFeature.js +7 -4
  171. package/plugins/draw/src/api/editFeature.test.js +16 -0
  172. package/plugins/draw/src/api/newLine.js +2 -40
  173. package/plugins/draw/src/api/newPoint.js +42 -0
  174. package/plugins/draw/src/api/newPoint.test.js +117 -0
  175. package/plugins/draw/src/api/newPolygon.js +2 -40
  176. package/plugins/draw/src/api/setStyle.js +43 -0
  177. package/plugins/draw/src/api/setStyle.test.js +75 -0
  178. package/plugins/draw/src/events.js +17 -10
  179. package/plugins/draw/src/events.test.js +14 -0
  180. package/plugins/draw/src/manifest.js +18 -6
  181. package/plugins/draw/src/manifest.test.js +32 -1
  182. package/plugins/draw/src/reducer.test.js +7 -0
  183. package/plugins/draw/src/utils/stripInternalProperties.js +19 -0
  184. package/plugins/draw/src/utils/stripInternalProperties.test.js +50 -0
  185. package/plugins/draw/src/utils/symbolKeys.js +5 -0
  186. package/plugins/draw/src/validation/liveDrawChecks.test.js +54 -0
  187. package/plugins/draw/src/validation/liveStroke.test.js +64 -1
  188. package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
  189. package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
  190. package/plugins/interact/dist/umd/index.js +1 -1
  191. package/plugins/interact/src/hooks/useHighlightSync.js +33 -12
  192. package/plugins/interact/src/hooks/useHighlightSync.test.js +96 -25
  193. package/plugins/interact/src/manifest.js +1 -1
  194. package/plugins/interact/src/utils/featureQueries.js +18 -0
  195. package/plugins/interact/src/utils/featureQueries.test.js +15 -0
  196. package/plugins/interact/src/utils/spatial.js +9 -3
  197. package/plugins/interact/src/utils/spatial.test.js +12 -1
  198. package/plugins/map-key/dist/css/index.css +68 -0
  199. package/plugins/map-key/dist/esm/im-map-key-plugin.js +1 -0
  200. package/plugins/map-key/dist/esm/index.js +1 -0
  201. package/plugins/map-key/dist/umd/im-map-key-plugin.js +2 -0
  202. package/plugins/map-key/dist/umd/im-map-key-plugin.js.LICENSE.txt +1 -0
  203. package/plugins/map-key/dist/umd/index.js +2 -0
  204. package/plugins/map-key/dist/umd/index.js.LICENSE.txt +1 -0
  205. package/plugins/map-key/package.json +28 -0
  206. package/plugins/map-key/src/components/Key/EmptyKey.jsx +7 -0
  207. package/plugins/{datasets → map-key}/src/components/Key/EmptyKey.test.jsx +2 -2
  208. package/plugins/map-key/src/components/Key/Key.jsx +43 -0
  209. package/plugins/{datasets → map-key}/src/components/Key/Key.module.scss +21 -14
  210. package/plugins/map-key/src/components/Key/Key.test.jsx +73 -0
  211. package/plugins/map-key/src/components/Key/KeyGroupItem.jsx +16 -0
  212. package/plugins/map-key/src/components/Key/KeyGroupItem.test.jsx +53 -0
  213. package/plugins/map-key/src/components/Key/KeyItem.jsx +26 -0
  214. package/plugins/map-key/src/components/Key/KeyItem.test.jsx +67 -0
  215. package/plugins/map-key/src/components/Key/KeySvg.jsx +41 -0
  216. package/plugins/{datasets → map-key}/src/components/Key/KeySvg.test.jsx +14 -12
  217. package/plugins/map-key/src/components/Key/KeySvgLine.jsx +22 -0
  218. package/plugins/{datasets → map-key}/src/components/Key/KeySvgLine.test.jsx +1 -1
  219. package/plugins/{datasets → map-key}/src/components/Key/KeySvgPattern.jsx +7 -2
  220. package/plugins/{datasets → map-key}/src/components/Key/KeySvgPattern.test.jsx +8 -2
  221. package/plugins/map-key/src/components/Key/KeySvgRect.jsx +26 -0
  222. package/plugins/{datasets → map-key}/src/components/Key/KeySvgRect.test.jsx +1 -1
  223. package/plugins/{datasets → map-key}/src/components/Key/KeySvgSymbol.jsx +8 -3
  224. package/plugins/{datasets → map-key}/src/components/Key/KeySvgSymbol.test.jsx +17 -6
  225. package/plugins/map-key/src/components/Key/MapKey.jsx +53 -0
  226. package/plugins/map-key/src/components/Key/MapKey.test.jsx +147 -0
  227. package/plugins/{datasets → map-key}/src/components/Key/svgProperties.js +2 -2
  228. package/plugins/{datasets → map-key}/src/components/Key/svgProperties.test.js +2 -2
  229. package/plugins/map-key/src/index.js +13 -0
  230. package/plugins/map-key/src/index.test.js +31 -0
  231. package/plugins/map-key/src/initialise/MapKeyInit.jsx +15 -0
  232. package/plugins/map-key/src/initialise/MapKeyInit.test.jsx +39 -0
  233. package/plugins/map-key/src/manifest.js +30 -0
  234. package/plugins/map-key/src/manifest.test.js +63 -0
  235. package/plugins/map-key/src/mapKey.scss +4 -0
  236. package/plugins/map-key/src/registry/getDatasetRegistry.js +6 -0
  237. package/plugins/map-key/src/registry/getDatasetRegistry.test.js +23 -0
  238. package/plugins/map-key/src/registry/index.js +3 -0
  239. package/plugins/map-key/src/registry/index.test.js +15 -0
  240. package/plugins/menu/dist/css/index.css +80 -0
  241. package/plugins/menu/dist/esm/im-menu-plugin.js +1 -0
  242. package/plugins/menu/dist/esm/index.js +1 -0
  243. package/plugins/menu/dist/umd/im-menu-plugin.js +1 -0
  244. package/plugins/menu/dist/umd/index.js +2 -0
  245. package/plugins/menu/dist/umd/index.js.LICENSE.txt +1 -0
  246. package/plugins/menu/package.json +28 -0
  247. package/plugins/menu/src/components/Menu/CheckboxGroupWrapper.jsx +21 -0
  248. package/plugins/menu/src/components/Menu/GroupLegend.jsx +17 -0
  249. package/plugins/menu/src/components/Menu/GroupLegend.test.jsx +68 -0
  250. package/plugins/menu/src/components/Menu/Menu.jsx +19 -0
  251. package/plugins/menu/src/components/Menu/Menu.module.scss +90 -0
  252. package/plugins/menu/src/components/Menu/Menu.test.jsx +161 -0
  253. package/plugins/menu/src/components/Menu/MenuCheckbox.jsx +35 -0
  254. package/plugins/menu/src/components/Menu/MenuCheckbox.test.jsx +93 -0
  255. package/plugins/menu/src/components/Menu/MenuGroup.jsx +11 -0
  256. package/plugins/{datasets/src/components/LayersMenu/LayersMenuRadio.jsx → menu/src/components/Menu/MenuRadio.jsx} +6 -4
  257. package/plugins/{datasets/src/components/LayersMenu/LayersMenuRadio.test.jsx → menu/src/components/Menu/MenuRadio.test.jsx} +18 -18
  258. package/plugins/menu/src/components/Menu/RadioGroupWrapper.jsx +32 -0
  259. package/plugins/{datasets/src/components/LayersMenu/LayersRadioGroupWrapper.test.jsx → menu/src/components/Menu/RadioGroupWrapper.test.jsx} +21 -21
  260. package/plugins/menu/src/components/Menu/useIdPrefix.jsx +4 -0
  261. package/plugins/menu/src/index.js +13 -0
  262. package/plugins/menu/src/index.test.js +31 -0
  263. package/plugins/menu/src/initialise/MenuInit.jsx +24 -0
  264. package/plugins/menu/src/initialise/MenuInit.test.jsx +50 -0
  265. package/plugins/menu/src/initialise/createMenu.js +10 -0
  266. package/plugins/menu/src/initialise/createMenu.test.js +37 -0
  267. package/plugins/menu/src/manifest.js +35 -0
  268. package/plugins/menu/src/manifest.test.js +63 -0
  269. package/plugins/menu/src/menu.scss +4 -0
  270. package/plugins/menu/src/reducers/menuStateReducer.test.js +38 -0
  271. package/plugins/menu/src/reducers/pluginState.js +35 -0
  272. package/plugins/menu/src/reducers/pluginState.test.js +57 -0
  273. package/plugins/menu/src/registry/getDatasetRegistry.js +9 -0
  274. package/plugins/menu/src/registry/getDatasetRegistry.test.js +23 -0
  275. package/plugins/menu/src/registry/index.js +3 -0
  276. package/plugins/menu/src/registry/index.test.js +15 -0
  277. package/plugins/menu/src/registry/isVisibleWhen.js +43 -0
  278. package/plugins/menu/src/registry/isVisibleWhen.test.js +48 -0
  279. package/plugins/search/dist/css/index.css +1 -1
  280. package/plugins/search/dist/esm/im-search-plugin.js +1 -1
  281. package/plugins/search/dist/esm/index.js +1 -1
  282. package/plugins/search/dist/umd/im-search-plugin.js +1 -1
  283. package/plugins/search/dist/umd/index.js +1 -1
  284. package/plugins/search/src/Search.jsx +2 -3
  285. package/plugins/search/src/components/Form/Form.module.scss +9 -20
  286. package/plugins/search/src/index.js +0 -1
  287. package/plugins/search/src/index.test.js +2 -4
  288. package/plugins/search/src/manifest.js +1 -1
  289. package/plugins/search/src/search.scss +17 -16
  290. package/providers/beta/openlayers/dist/esm/im-openlayers-provider.js +1 -1
  291. package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js +1 -1
  292. package/providers/beta/openlayers/dist/umd/index.js +1 -1
  293. package/providers/beta/openlayers/src/openlayersProvider.js +4 -1
  294. package/providers/beta/openlayers/src/openlayersProvider.test.js +18 -0
  295. package/providers/beta/openlayers/src/utils/highlightFeatures.js +52 -5
  296. package/providers/beta/openlayers/src/utils/highlightFeatures.test.js +176 -0
  297. package/providers/beta/openlayers/src/utils/symbolImages.js +40 -0
  298. package/providers/beta/openlayers/src/utils/symbolImages.test.js +58 -0
  299. package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
  300. package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
  301. package/providers/maplibre/dist/umd/index.js +1 -1
  302. package/providers/maplibre/src/utils/drawLayerBuckets.js +14 -0
  303. package/providers/maplibre/src/utils/drawLayerBuckets.test.js +18 -0
  304. package/providers/maplibre/src/utils/highlightFeatures.js +80 -55
  305. package/providers/maplibre/src/utils/highlightFeatures.test.js +156 -17
  306. package/providers/maplibre/src/utils/hoverCursor.js +30 -14
  307. package/providers/maplibre/src/utils/hoverCursor.test.js +35 -0
  308. package/providers/maplibre/src/utils/patternImages.js +1 -1
  309. package/providers/maplibre/src/utils/symbolImages.js +41 -3
  310. package/providers/maplibre/src/utils/symbolImages.test.js +40 -6
  311. package/rollup.esm.mjs +11 -1
  312. package/src/App/components/Actions/Actions.test.jsx +47 -0
  313. package/src/App/components/Hints/Hints.test.jsx +13 -0
  314. package/src/App/components/KeyboardHelp/KeyboardHelp.jsx +25 -23
  315. package/src/App/components/KeyboardHelp/KeyboardHelp.test.jsx +22 -5
  316. package/src/App/components/MoveControls/MoveControls.module.scss +41 -10
  317. package/src/App/components/Panel/Panel.jsx +65 -8
  318. package/src/App/components/Panel/Panel.module.scss +49 -15
  319. package/src/App/components/Panel/Panel.test.jsx +114 -1
  320. package/src/App/components/Tabs/Tabs.jsx +43 -17
  321. package/src/App/components/Tabs/Tabs.module.scss +32 -5
  322. package/src/App/components/Tabs/Tabs.test.jsx +40 -10
  323. package/src/App/components/Tooltip/Tooltip.test.jsx +12 -14
  324. package/src/App/hooks/useFeatureItems.js +16 -7
  325. package/src/App/hooks/useFeatureItems.test.js +57 -0
  326. package/src/App/hooks/useLayoutMeasurements.js +95 -84
  327. package/src/App/hooks/useLayoutMeasurements.test.js +61 -1
  328. package/src/App/layout/Layout.jsx +9 -10
  329. package/src/App/layout/Layout.test.jsx +2 -0
  330. package/src/App/layout/layout.module.scss +31 -17
  331. package/src/App/registry/pluginRegistry.js +1 -1
  332. package/src/App/registry/pluginRegistry.test.js +12 -0
  333. package/src/App/renderer/HtmlElementHost.jsx +18 -5
  334. package/src/App/renderer/HtmlElementHost.test.jsx +54 -0
  335. package/src/App/renderer/groupByKey.js +28 -0
  336. package/src/App/renderer/groupByKey.test.js +39 -0
  337. package/src/App/renderer/groupIntoTabs.js +42 -0
  338. package/src/App/renderer/groupIntoTabs.test.js +95 -0
  339. package/src/App/renderer/mapButtons.js +97 -129
  340. package/src/App/renderer/mapButtons.test.js +67 -83
  341. package/src/App/renderer/mapControls.js +4 -1
  342. package/src/App/renderer/mapControls.test.js +32 -0
  343. package/src/App/renderer/mapPanels.js +53 -11
  344. package/src/App/renderer/mapPanels.test.js +95 -2
  345. package/src/App/renderer/orderItems.js +28 -0
  346. package/src/App/renderer/orderItems.test.js +50 -0
  347. package/src/App/renderer/slotAggregator.js +2 -18
  348. package/src/App/renderer/slotHelpers.js +3 -1
  349. package/src/App/renderer/slotHelpers.test.js +5 -0
  350. package/src/App/renderer/slots.js +3 -0
  351. package/src/App/store/AppProvider.jsx +1 -0
  352. package/src/App/store/appDispatchMiddleware.js +1 -1
  353. package/src/App/store/appDispatchMiddleware.test.js +8 -0
  354. package/src/config/appConfig.js +2 -2
  355. package/src/config/events.js +2 -0
  356. package/src/scss/settings/_colors.scss +1 -0
  357. package/src/scss/settings/_dimensions.scss +2 -3
  358. package/src/scss/settings/_transition.scss +1 -1
  359. package/src/services/eventBus.js +44 -0
  360. package/src/services/eventBus.test.js +83 -0
  361. package/src/services/symbolRegistry.js +1 -1
  362. package/src/types.js +31 -3
  363. package/webpack.umd.mjs +2 -0
  364. package/plugins/datasets/src/components/Key/EmptyKey.jsx +0 -7
  365. package/plugins/datasets/src/components/Key/Key.jsx +0 -50
  366. package/plugins/datasets/src/components/Key/KeyGroupItem.jsx +0 -18
  367. package/plugins/datasets/src/components/Key/KeyItem.jsx +0 -23
  368. package/plugins/datasets/src/components/Key/KeySvg.jsx +0 -22
  369. package/plugins/datasets/src/components/Key/KeySvgLine.jsx +0 -19
  370. package/plugins/datasets/src/components/Key/KeySvgRect.jsx +0 -22
  371. package/plugins/datasets/src/components/LayersMenu/LayersRadioGroupWrapper.jsx +0 -41
  372. /package/plugins/{datasets → menu}/src/reducers/menuStateReducer.js +0 -0
  373. /package/{providers/maplibre/src → src}/utils/rasteriseToImageData.js +0 -0
  374. /package/{providers/maplibre/src → src}/utils/rasteriseToImageData.test.js +0 -0
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see im-draw-plugin.js.LICENSE.txt */
2
- "use strict";(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[568],{278(e,t,n){n.d(t,{Et:()=>h,Gf:()=>c,Lr:()=>u,n1:()=>a,nv:()=>f,tR:()=>p,wi:()=>l,zX:()=>r,zx:()=>s});var r=6371008.8,i={centimeters:100*r,centimetres:100*r,degrees:360/(2*Math.PI),feet:3.28084*r,inches:39.37*r,kilometers:r/1e3,kilometres:r/1e3,meters:r,metres:r,miles:r/1609.344,millimeters:1e3*r,millimetres:1e3*r,nauticalmiles:r/1852,radians:1,yards:1.0936*r};function o(e,t,n={}){const r={type:"Feature"};return(0===n.id||n.id)&&(r.id=n.id),n.bbox&&(r.bbox=n.bbox),r.properties=t||{},r.geometry=e,r}function s(e,t,n={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!h(e[0])||!h(e[1]))throw new Error("coordinates must contain numbers");return o({type:"Point",coordinates:e},t,n)}function a(e,t,n={}){for(const t of e){if(t.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(t[t.length-1].length!==t[0].length)throw new Error("First and last Position are not equivalent.");for(let e=0;e<t[t.length-1].length;e++)if(t[t.length-1][e]!==t[0][e])throw new Error("First and last Position are not equivalent.")}return o({type:"Polygon",coordinates:e},t,n)}function l(e,t,n={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return o({type:"LineString",coordinates:e},t,n)}function u(e,t={}){const n={type:"FeatureCollection"};return t.id&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.features=e,n}function c(e,t="kilometers"){const n=i[t];if(!n)throw new Error(t+" units is invalid");return e/n}function f(e){return e%(2*Math.PI)*180/Math.PI}function p(e){return e%360*Math.PI/180}function h(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}},850(e,t,n){function r(e,t,n){if(null!==e)for(var i,o,s,a,l,u,c,f,p=0,h=0,d=e.type,y="FeatureCollection"===d,g="Feature"===d,m=y?e.features.length:1,v=0;v<m;v++){l=(f=!!(c=y?e.features[v].geometry:g?e.geometry:e)&&"GeometryCollection"===c.type)?c.geometries.length:1;for(var b=0;b<l;b++){var E=0,w=0;if(null!==(a=f?c.geometries[b]:c)){u=a.coordinates;var S=a.type;switch(p=!n||"Polygon"!==S&&"MultiPolygon"!==S?0:1,S){case null:break;case"Point":if(!1===t(u,h,v,E,w))return!1;h++,E++;break;case"LineString":case"MultiPoint":for(i=0;i<u.length;i++){if(!1===t(u[i],h,v,E,w))return!1;h++,"MultiPoint"===S&&E++}"LineString"===S&&E++;break;case"Polygon":case"MultiLineString":for(i=0;i<u.length;i++){for(o=0;o<u[i].length-p;o++){if(!1===t(u[i][o],h,v,E,w))return!1;h++}"MultiLineString"===S&&E++,"Polygon"===S&&w++}"Polygon"===S&&E++;break;case"MultiPolygon":for(i=0;i<u.length;i++){for(w=0,o=0;o<u[i].length;o++){for(s=0;s<u[i][o].length-p;s++){if(!1===t(u[i][o][s],h,v,E,w))return!1;h++}w++}E++}break;case"GeometryCollection":for(i=0;i<a.geometries.length;i++)if(!1===r(a.geometries[i],t,n))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function i(e,t,n){var r=n;return function(e,t){var n,r,i,o,s,a,l,u,c,f,p=0,h="FeatureCollection"===e.type,d="Feature"===e.type,y=h?e.features.length:1;for(n=0;n<y;n++){for(a=h?e.features[n].geometry:d?e.geometry:e,u=h?e.features[n].properties:d?e.properties:{},c=h?e.features[n].bbox:d?e.bbox:void 0,f=h?e.features[n].id:d?e.id:void 0,s=(l=!!a&&"GeometryCollection"===a.type)?a.geometries.length:1,i=0;i<s;i++)if(null!==(o=l?a.geometries[i]:a))switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(o,p,u,c,f))return!1;break;case"GeometryCollection":for(r=0;r<o.geometries.length;r++)if(!1===t(o.geometries[r],p,u,c,f))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,u,c,f))return!1;p++}}(e,function(e,i,o,s,a){r=0===i&&void 0===n?e:t(r,e,i,o,s,a)}),r}n.d(t,{Fh:()=>r,jE:()=>i})},360(e,t,n){n.d(t,{k:()=>r});var r={CREATE:"create",EDIT_FINISH:"editfinish",CANCEL:"cancel",VERTEX_SELECTION:"vertexselection",VERTEX_CHANGE:"vertexchange",UNDO_CHANGE:"undochange",UPDATE:"update",GEOMETRY_CHANGE:"geometrychange",INTERFACE_TYPE_CHANGE:"interfacetypechange",PLACEMENT_BLOCKED:"placementblocked",VALIDITY_CHANGE:"validitychange",CAN_PLACE_CHANGE:"canplacechange"}},682(e,t,n){n.d(t,{$y:()=>f,F0:()=>l,WQ:()=>c,lm:()=>a,vf:()=>u});var r="rgba(29,112,184,1)",i="#ffffff",o="rgba(11,12,12,1)",s="rgba(212,53,28,0.5)",a={editStroke:{light:r,dark:i},editFill:{light:"rgba(29,112,184,0.1)",dark:"rgba(255,255,255,0.1)"},editVertex:{light:r,dark:i},editMidpoint:{light:r,dark:i},editHalo:{light:i,dark:o},editActive:{light:o,dark:i},splitInvalid:{light:r,dark:i},splitValid:{light:r,dark:i},invalidStroke:{light:r,dark:i},shapeStroke:"rgba(212,53,28,1)",shapeFill:s,snapVertex:s,snapMidpoint:"rgba(40,161,151,1)",snapEdge:"rgba(29,112,184,0.5)"},l={strokeWidth:2,vertexRadius:6,midpointRadius:4,vertexHaloRadius:8,midpointHaloRadius:6,touchTargetSize:48,touchIndicatorRadius:30},u={snapRadius:12},c={nudgeAmount:1,stepAmount:5},f={small:1,medium:1.5,large:2}},977(e,t,n){function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach(function(t){s(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function s(e,t,n){return(t=function(e){var t=function(e){if("object"!=r(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==r(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.r(t),n.d(t,{manifest:()=>re});var a=new Set(["draw_polygon","draw_line"]),l={SET_MODE:function(e,t){return o(o({},e),{},{mode:t,numVertices:a.has(t)?0:e.numVertices,geometryValid:!1,canAddPoint:!0})},SET_ACTION:function(e,t){return o(o({},e),{},{action:t.name,actionValid:t.isValid})},SET_FEATURE:function(e,t){return o(o({},e),{},{feature:void 0===t.feature?e.feature:t.feature,tempFeature:void 0===t.tempFeature?e.tempFeature:t.tempFeature})},SET_SELECTED_VERTEX_INDEX:function(e,t){return o(o({},e),{},{selectedVertexIndex:t.index,numVertices:t.numVertices})},TOGGLE_SNAP:function(e){return o(o({},e),{},{snap:!e.snap})},SET_HAS_SNAP_LAYERS:function(e,t){return o(o({},e),{},{hasSnapLayers:!!t})},SET_UNDO_STACK_LENGTH:function(e,t){return o(o({},e),{},{undoStackLength:t})},SET_GEOMETRY_VALID:function(e,t){return o(o({},e),{},{geometryValid:!!t})},SET_CAN_ADD_POINT:function(e,t){return o(o({},e),{},{canAddPoint:!!t})}},u=n(738),c={APP_ADD_MARKER:"app:addmarker",APP_UPDATE_MARKER:"app:updatemarker",APP_REMOVE_MARKER:"app:removemarker",APP_SET_MODE:"app:setmode",APP_REVERT_MODE:"app:revertmode",APP_ADD_BUTTON:"app:addbutton",APP_TOGGLE_BUTTON_STATE:"app:togglebuttonstate",APP_ADD_PANEL:"app:addpanel",APP_REMOVE_PANEL:"app:removepanel",APP_SHOW_PANEL:"app:showpanel",APP_HIDE_PANEL:"app:hidepanel",APP_ADD_CONTROL:"app:addcontrol",APP_SHOW_HINT:"app:showhint",APP_DISMISS_HINT:"app:dismisshint",APP_READY:"app:ready",APP_OPENED:"app:opened",APP_CLOSED:"app:closed",APP_FULLSCREEN_CHANGE:"app:fullscreenchange",APP_PANEL_OPENED:"app:panelopened",APP_PANEL_CLOSED:"app:panelclosed",MAP_SET_STYLE:"map:setstyle",MAP_SET_SIZE:"map:setsize",MAP_SET_FEATURES:"map:setfeatures",MAP_SET_ACTIVE_FEATURE:"map:setactivefeature",MAP_SELECT_FEATURE:"map:selectfeature",MAP_SET_PIXEL_RATIO:"map:setpixelratio",MAP_FIT_TO_BOUNDS:"map:fittobounds",MAP_SET_VIEW:"map:setview",MAP_INIT_MAP_STYLES:"map:initmapstyles",MAP_STYLE_CHANGE:"map:stylechange",MAP_LOADED:"map:loaded",MAP_READY:"map:ready",MAP_SIZE_CHANGE:"map:sizechange",MAP_FIRST_IDLE:"map:firstidle",MAP_MOVE_START:"map:movestart",MAP_MOVE:"map:move",MAP_MOVE_END:"map:moveend",MAP_STATE_UPDATED:"map:stateupdated",MAP_DATA_CHANGE:"map:datachange",MAP_RENDER:"map:render",MAP_CLICK:"map:click",MAP_DESTROY:"map:destroy"};function f(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var l=r&&r.prototype instanceof a?r:a,u=Object.create(l.prototype);return p(u,"_invoke",function(n,r,i){var o,a,l,u=0,c=i||[],f=!1,p={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,a=0,l=e,p.n=n,s}};function h(n,r){for(a=n,l=r,t=0;!f&&u&&!i&&t<c.length;t++){var i,o=c[t],h=p.p,d=o[2];n>3?(i=d===r)&&(l=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(a=0,p.v=r,p.n=o[1]):h<d&&(i=n<3||o[0]>r||r>d)&&(o[4]=n,o[5]=r,p.n=d,a=0))}if(i||n>1)return s;throw f=!0,r}return function(i,c,d){if(u>1)throw TypeError("Generator is already running");for(f&&1===c&&h(c,d),a=c,l=d;(t=a<2?e:l)||!f;){o||(a?a<3?(a>1&&(p.n=-1),h(a,l)):p.n=l:p.v=l);try{if(u=2,o){if(a||(i="next"),t=o[i]){if(!(t=t.call(o,l)))throw TypeError("iterator result is not an object");if(!t.done)return t;l=t.value,a<2&&(a=0)}else 1===a&&(t=o.return)&&t.call(o),a<2&&(l=TypeError("The iterator does not provide a '"+i+"' method"),a=1);o=e}else if((t=(f=p.n<0)?l:n.call(r,p))!==s)break}catch(t){o=e,a=1,l=t}finally{u=1}}return{value:t,done:f}}}(n,i,o),!0),u}var s={};function a(){}function l(){}function u(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(p(t={},r,function(){return this}),t),h=u.prototype=a.prototype=Object.create(c);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,p(e,i,"GeneratorFunction")),e.prototype=Object.create(h),e}return l.prototype=u,p(h,"constructor",u),p(u,"constructor",l),l.displayName="GeneratorFunction",p(u,i,"GeneratorFunction"),p(h),p(h,i,"Generator"),p(h,r,function(){return this}),p(h,"toString",function(){return"[object Generator]"}),(f=function(){return{w:o,m:d}})()}function p(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}p=function(e,t,n,r){function o(t,n){p(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},p(e,t,n,r)}function h(e,t,n,r,i,o,s){try{var a=e[o](s),l=a.value}catch(e){return void n(e)}a.done?t(l):Promise.resolve(l).then(r,i)}var d=function(){var e,t=(e=f().m(function e(t,r){var i,o,s,a,l;return f().w(function(e){for(;;)switch(e.n){case 0:l=t.name,e.n="MapLibreProvider"===l?1:"OpenLayersProvider"===l?3:5;break;case 1:return e.n=2,n.e(356).then(n.bind(n,24));case 2:return i=e.v,o=i.MaplibreDrawAdapter,e.a(2,new o(t,r));case 3:return e.n=4,n.e(722).then(n.bind(n,854));case 4:return s=e.v,a=s.OLDrawAdapter,e.a(2,new a(t,r));case 5:throw new Error('No draw adapter available for map provider "'.concat(t.name,'"'));case 6:return e.a(2)}},e)}),function(){var t=this,n=arguments;return new Promise(function(r,i){var o=e.apply(t,n);function s(e){h(o,r,i,s,a,"next",e)}function a(e){h(o,r,i,s,a,"throw",e)}s(void 0)})});return function(e,n){return t.apply(this,arguments)}}(),y=n(360),g=n(520),m=n(9),v=n(682);function b(e){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},b(e)}function E(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function w(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?E(Object(n),!0).forEach(function(t){S(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):E(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function S(e,t,n){return(t=function(e){var t=function(e){if("object"!=b(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=b(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==b(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var P="edit_vertex";function x(e){var t=e.appState,n=e.appConfig,r=e.mapState,i=e.pluginState,o=e.mapProvider,s=e.eventBus,a=e.hints,l=e.resetState,u=o.draw,c=function(e,t){return function(n){var r;e.emit("draw:geometryinvalid",n),n.reason&&(r=n.reason,!Object.values(m.PH).includes(r))&&t.show(n.reason)}}(s,a),f=i.feature,p=i.tempFeature,h=i.dispatch,d=null;return w(w({handleDone:function(){u.done()},handleCancel:function(){u.getMode()===P&&null!=p&&p.id&&u.add(f),d=null,u.cancel(),l(),s.emit("draw:cancelled",f)},handleUndo:function(){return u.undo()},handleDeleteVertex:function(){return u.deleteVertex()},handleSnap:function(){i.dispatch({type:"TOGGLE_SNAP"}),u.setSnapEnabled(!i.snap)},onCreate:function(e){var i=(0,g.$U)(e,{phase:"create",mode:u.getMode()},{onGeometryChange:u._geometryValidator}),o=i.valid,a=i.reason;if(!o)return d=e.id,c({feature:e,reason:a,phase:"create",mode:P}),void setTimeout(function(){return function(e,t){var n,r,i,o=e.draw,s=e.appState,a=e.appConfig,l=e.mapState,u=e.dispatch;o.changeMode(P,{container:null==s||null===(n=s.layoutRefs)||void 0===n||null===(n=n.viewportRef)||void 0===n?void 0:n.current,deleteVertexButtonId:"".concat(null==a?void 0:a.id,"-draw-delete-point"),undoButtonId:"".concat(null==a?void 0:a.id,"-draw-undo"),isPanEnabled:"keyboard"!==(null==s?void 0:s.interfaceType),interfaceType:null==s?void 0:s.interfaceType,scale:v.$y[null==l?void 0:l.mapSize],featureId:t,getSnapEnabled:function(){return o.isSnapEnabled()}});var c=o.get(t);u({type:"SET_FEATURE",payload:{feature:c,tempFeature:c}}),u({type:"SET_MODE",payload:P}),u({type:"SET_GEOMETRY_VALID",payload:!1}),null===(r=o.setGeometryValid)||void 0===r||r.call(o,!1),null===(i=o.setInvalid)||void 0===i||i.call(o,!0)}({draw:u,appState:t,appConfig:n,mapState:r,dispatch:h},e.id)},0);l(),setTimeout(function(){return u.changeMode("disabled")},0),s.emit("draw:created",e)},onEditFinish:function(e){l(),setTimeout(function(){return u.changeMode("disabled")},0),d&&e.id===d?(d=null,s.emit("draw:created",e)):s.emit("draw:edited",e)},onCancel:function(){}},function(e){var t=e.draw,n=e.pluginState,r=e.mapProvider,i=e.eventBus;return{onVertexSelection:function(e){n.dispatch({type:"SET_SELECTED_VERTEX_INDEX",payload:e}),r.activeMoveTarget=e.index>=0?function(e){return{move:function(t,n,r){return e.nudgeSelectedVertex(t,n,r)},label:"vertex"}}(t):null,i.emit("draw:vertexselection",e)},onVertexChange:function(e){n.dispatch({type:"SET_SELECTED_VERTEX_INDEX",payload:{index:-1,numVertices:e.numVertices}}),r.activeMoveTarget=null}}}({draw:u,pluginState:i,mapProvider:o,eventBus:s})),{},{onUndoChange:function(e){i.dispatch({type:"SET_UNDO_STACK_LENGTH",payload:e})},onUpdate:function(e){s.emit("draw:updated",e)},onGeometryChange:function(e){var t;if(null!=e&&e.phase){var n,r=u.getMode(),o={phase:e.phase,vertexIndex:e.vertexIndex,mode:r},s=(0,g.$U)(e.feature,o,{onGeometryChange:u._geometryValidator}),a=s.valid,l=s.reason;i.dispatch({type:"SET_GEOMETRY_VALID",payload:a}),null===(t=u.setGeometryValid)||void 0===t||t.call(u,a),r===P&&(null===(n=u.setInvalid)||void 0===n||n.call(u,!a)),a||c(w(w({reason:l},o),{},{feature:e.feature}))}},onPlacementBlocked:function(e){c(e)},onValidityChange:function(e){var t;i.dispatch({type:"SET_GEOMETRY_VALID",payload:e.valid}),null===(t=u.setGeometryValid)||void 0===t||t.call(u,e.valid)},onCanPlaceChange:function(e){i.dispatch({type:"SET_CAN_ADD_POINT",payload:e.canPlace})},onInterfaceTypeChange:function(e){s.emit("draw:interfacetypechange",{interfaceType:e.interfaceType})}})}function O(e){return O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},O(e)}function _(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,s,a=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(e){u=!0,i=e}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw i}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return T(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?T(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function T(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var A=new Set(["stroke","fill","strokeWidth"]),C=function(e){if(!e)return{};for(var t={},n=0,r=Object.entries(e);n<r.length;n++){var i=_(r[n],2),o=i[0],s=i[1];if(A.has(o)&&"object"===O(s)&&null!==s){var a=Object.entries(s);a.length>0&&(t[o]=a[0][1]);for(var l=0,u=a;l<u.length;l++){var c=_(u[l],2),f=c[0],p=c[1];t["".concat(o).concat(f.charAt(0).toUpperCase()+f.slice(1))]=p}}else t[o]=s}return t};function k(e){return k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},k(e)}var M=["stroke","fill","strokeWidth","properties","onGeometryChange"];function I(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function L(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?I(Object(n),!0).forEach(function(t){R(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):I(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function R(e,t,n){return(t=function(e){var t=function(e){if("object"!=k(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=k(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==k(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function N(e){return N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},N(e)}var j=["stroke","fill","strokeWidth","properties","onGeometryChange"];function D(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function G(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?D(Object(n),!0).forEach(function(t){F(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):D(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function F(e,t,n){return(t=function(e){var t=function(e){if("object"!=N(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=N(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==N(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function V(e){return V="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},V(e)}var B=["stroke","fill","strokeWidth","properties"];function U(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function H(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?U(Object(n),!0).forEach(function(t){q(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):U(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function q(e,t,n){return(t=function(e){var t=function(e){if("object"!=V(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=V(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==V(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Y=n(704);function z(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var W="_splitter",$=function(e){var t,n,r,i,o=e.draw,s=(t=e.polygonFeature,n=e.feature,!(!(i=null===(r=n.geometry)||void 0===r?void 0:r.coordinates)||i.length<2||!(0,Y.ns)(t,{id:W,geometry:n.geometry})));return o.setDrawingPreviewProperty("splitter",s?"valid":"invalid"),s};function X(e){return X="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},X(e)}function K(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Z(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?K(Object(n),!0).forEach(function(t){J(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):K(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function J(e,t,n){return(t=function(e){var t=function(e){if("object"!=X(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=X(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==X(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Q,ee="top-middle",te="undefined"!=typeof navigator&&/mac/i.test((null===(Q=navigator.userAgentData)||void 0===Q?void 0:Q.platform)||navigator.platform||"")?"<kbd>Command</kbd> + <kbd>Z</kbd>":"<kbd>Ctrl</kbd> + <kbd>Z</kbd>",ne=function(e){return{mobile:{slot:"actions",showLabel:e},tablet:{slot:"actions",showLabel:e},desktop:{slot:"actions",showLabel:e}}},re={reducer:{initialState:{mode:null,action:null,actionValid:!1,feature:null,tempFeature:null,selectedVertexIndex:-1,numVertices:null,geometryValid:!0,canAddPoint:!0,snap:!1,hasSnapLayers:!1,undoStackLength:0},actions:l},InitComponent:function(e){var t=e.appState,n=e.appConfig,r=e.mapState,i=e.pluginConfig,o=e.pluginState,s=e.services,a=e.mapProvider,l=e.buttonConfig,f=s.eventBus,p=s.hints,h=r.crossHair,g=["touch","keyboard"].includes(t.interfaceType);(0,u.useEffect)(function(){var e,n,s,l,u=null===(e=null===(n=i.includeModes)||void 0===n?void 0:n.includes(t.mode))||void 0===e||e,p=null!==(s=null===(l=i.excludeModes)||void 0===l?void 0:l.includes(t.mode))&&void 0!==s&&s;if(r.isMapReady&&u&&!p){var h=!0;return d(a,{mapStyle:r.mapStyle,snapLayers:i.snapLayers,pluginConfig:i,events:c,eventBus:f}).then(function(e){var t;h&&(a.draw=e,o.dispatch({type:"SET_HAS_SNAP_LAYERS",payload:(null===(t=i.snapLayers)||void 0===t?void 0:t.length)>0}),f.emit("draw:ready"))}),function(){var e;h=!1,null===(e=a.draw)||void 0===e||e.remove(),a.draw=null,a.activeMoveTarget=null}}},[r.isMapReady,t.mode]),(0,u.useEffect)(function(){if(["draw_polygon","draw_line"].includes(o.mode)&&g){var e=h.isVisible;return h.fixAtCenter(),function(){e||["touch","keyboard"].includes(t.interfaceType)||h.hide()}}},[o.mode,t.interfaceType]),(0,u.useEffect)(function(){["edit_vertex","draw_polygon","draw_line"].includes(o.mode)&&a.draw&&a.draw.setInterfaceType(t.interfaceType)},[t.interfaceType,o.mode]),(0,u.useEffect)(function(){if(a.draw)return function(e){var t=e.appState,n=e.appConfig,r=e.mapState,i=e.pluginState,o=e.mapProvider,s=e.buttonConfig,a=e.eventBus,l=e.hints,u=o.draw,c=x({appState:t,appConfig:n,mapState:r,pluginState:i,mapProvider:o,eventBus:a,hints:l,resetState:function(){i.dispatch({type:"SET_MODE",payload:null}),i.dispatch({type:"SET_FEATURE",payload:{feature:null,tempFeature:null}}),o.activeMoveTarget=null}});return function(e,t){var n=e.drawDone,r=e.drawCancel,i=e.drawUndo,o=e.drawDeletePoint,s=e.drawSnap;n.onClick=t.handleDone,r.onClick=t.handleCancel,i.onClick=t.handleUndo,o&&(o.onClick=t.handleDeleteVertex),s&&(s.onClick=t.handleSnap)}(s,c),function(e,t){e.on(y.k.CREATE,t.onCreate),e.on(y.k.EDIT_FINISH,t.onEditFinish),e.on(y.k.CANCEL,t.onCancel),e.on(y.k.VERTEX_SELECTION,t.onVertexSelection),e.on(y.k.VERTEX_CHANGE,t.onVertexChange),e.on(y.k.UNDO_CHANGE,t.onUndoChange),e.on(y.k.UPDATE,t.onUpdate),e.on(y.k.GEOMETRY_CHANGE,t.onGeometryChange),e.on(y.k.PLACEMENT_BLOCKED,t.onPlacementBlocked),e.on(y.k.VALIDITY_CHANGE,t.onValidityChange),e.on(y.k.CAN_PLACE_CHANGE,t.onCanPlaceChange),e.on(y.k.INTERFACE_TYPE_CHANGE,t.onInterfaceTypeChange)}(u,c),function(){!function(e){var t=e.drawDone,n=e.drawCancel,r=e.drawUndo,i=e.drawDeletePoint,o=e.drawSnap;t.onClick=null,n.onClick=null,r.onClick=null,i&&(i.onClick=null),o&&(o.onClick=null)}(s),function(e,t){e.off(y.k.CREATE,t.onCreate),e.off(y.k.EDIT_FINISH,t.onEditFinish),e.off(y.k.CANCEL,t.onCancel),e.off(y.k.VERTEX_SELECTION,t.onVertexSelection),e.off(y.k.VERTEX_CHANGE,t.onVertexChange),e.off(y.k.UNDO_CHANGE,t.onUndoChange),e.off(y.k.UPDATE,t.onUpdate),e.off(y.k.GEOMETRY_CHANGE,t.onGeometryChange),e.off(y.k.PLACEMENT_BLOCKED,t.onPlacementBlocked),e.off(y.k.VALIDITY_CHANGE,t.onValidityChange),e.off(y.k.CAN_PLACE_CHANGE,t.onCanPlaceChange),e.off(y.k.INTERFACE_TYPE_CHANGE,t.onInterfaceTypeChange)}(u,c)}}({appState:t,appConfig:n,mapState:r,mapProvider:a,buttonConfig:l,pluginState:o,events:c,eventBus:f,hints:p})},[a,t,o])},buttons:[Z({id:"drawCancel",label:"Cancel",variant:"tertiary",exclusiveSlot:!0,hiddenWhen:function(e){return!e.pluginState.mode}},ne(!0)),Z({id:"drawAddPoint",label:"Add point",variant:"primary",exclusiveSlot:!0,hiddenWhen:function(e){var t=e.appState,n=e.pluginState;return!["draw_polygon","draw_line"].includes(n.mode)||"touch"!==t.interfaceType},enableWhen:function(e){return e.pluginState.canAddPoint}},ne(!0)),Z({id:"drawDone",label:"Done",variant:"primary",exclusiveSlot:!0,hiddenWhen:function(e){var t=e.pluginState;return!["draw_polygon","draw_line","edit_vertex"].includes(t.mode)},enableWhen:function(e){var t=e.pluginState,n=t.mode,r=t.geometryValid;return["draw_polygon","draw_line","edit_vertex"].includes(n)&&r}},ne(!0)),{id:"drawMenu",label:function(e){return"edit_vertex"===e.pluginState.mode?"Edit actions":"Draw actions"},iconId:"menu",exclusiveSlot:!0,hiddenWhen:function(e){var t=e.pluginState;return!["draw_polygon","draw_line","edit_vertex"].includes(t.mode)},menuItems:[{id:"drawUndo",label:"Undo",iconId:"undo",hiddenWhen:function(e){var t=e.pluginState;return!["draw_polygon","draw_line","edit_vertex"].includes(t.mode)},enableWhen:function(e){var t=e.pluginState;return["draw_polygon","draw_line"].includes(t.mode)?t.numVertices>0:t.undoStackLength>0}},{id:"drawSnap",label:"Snap to feature",iconId:"magnet",hiddenWhen:function(e){var t=e.pluginState;return!t.mode||!t.hasSnapLayers},pressedWhen:function(e){return!!e.pluginState.snap}},{id:"drawDeletePoint",label:"Delete point",iconId:"trash",enableWhen:function(e){var t,n=e.pluginState;return!(n.selectedVertexIndex<0)&&("Polygon"===(null===(t=n.feature)||void 0===t||null===(t=t.geometry)||void 0===t?void 0:t.type)?n.numVertices>3:n.numVertices>2)},hiddenWhen:function(e){return"edit_vertex"!==e.pluginState.mode}}],mobile:{slot:ee},tablet:{slot:ee},desktop:{slot:ee}}],keyboardShortcuts:[{id:"drawAddPoint",group:"Drawing",title:"Add point (draw)",command:"<kbd>Enter</kbd>"},{id:"drawSelectPoint",group:"Drawing",title:"Select nearest point (edit)",command:"<kbd>Spacebar</kbd>"},{id:"drawSelectAdjacentPoint",group:"Drawing",title:"Select adjacent point (edit)",command:"<kbd>Alt</kbd> + <kbd>↑</kbd> <kbd>↓</kbd> <kbd>←</kbd> or <kbd>→</kbd>"},{id:"drawMovePoint",group:"Drawing",title:"Move point (edit)",command:"<kbd>↑</kbd> <kbd>↓</kbd> <kbd>←</kbd> or <kbd>→</kbd>"},{id:"drawNudgePoint",group:"Drawing",title:"Nudge point (edit)",command:"<kbd>Shift</kbd> + <kbd>↑</kbd> <kbd>↓</kbd> <kbd>←</kbd> or <kbd>→</kbd>"},{id:"drawDeletePoint",group:"Drawing",title:"Delete point (edit)",command:"<kbd>Delete</kbd>"},{id:"drawUndo",group:"Drawing",title:"Undo",command:te}],icons:[{id:"menu",svgContent:'<path d="m6 9 6 6 6-6"/>'},{id:"undo",svgContent:'<path d="M9 14 4 9l5-5"/><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11"/>'},{id:"magnet",svgContent:'<path d="m12 15 4 4"/><path d="M2.352 10.648a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.029-6.029a1 1 0 1 1 3 3l-6.029 6.029a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.365-6.367A1 1 0 0 0 8.716 4.282z"/><path d="m5 8 4 4"/>'},{id:"trash",svgContent:'<path d="M10 11v6"/><path d="M14 11v6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M3 6h18"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>'}],api:{newPolygon:function(e,t){var n,r=e.appState,i=e.appConfig,o=e.pluginConfig,s=e.pluginState,a=e.mapState,l=e.mapProvider,u=e.services,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},f=s.dispatch,p=l.draw,h=u.eventBus;if(p){h.emit("draw:started",{mode:"draw_polygon"});var d=void 0===c.snapLayers?null!==(n=o.snapLayers)&&void 0!==n?n:null:c.snapLayers;p.setSnapLayers(d),f({type:"SET_HAS_SNAP_LAYERS",payload:(null==d?void 0:d.length)>0});var y=c.stroke,g=c.fill,m=c.strokeWidth,v=c.properties,b=c.onGeometryChange,E=function(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(c,M);p._geometryValidator=null!=b?b:o.onGeometryChange;var w=L(L({},v),C({stroke:y,fill:g,strokeWidth:m}));p.changeMode("draw_polygon",L(L({container:r.layoutRefs.viewportRef.current,addVertexButtonId:"".concat(i.id,"-draw-add-point"),interfaceType:r.interfaceType,crossHair:a.crossHair,getSnapEnabled:function(){return p.isSnapEnabled()},featureId:t},E),{},{properties:w})),f({type:"SET_MODE",payload:"draw_polygon"})}},newLine:function(e,t){var n,r=e.appState,i=e.appConfig,o=e.pluginConfig,s=e.pluginState,a=e.mapState,l=e.mapProvider,u=e.services,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},f=s.dispatch,p=l.draw,h=u.eventBus;if(p){h.emit("draw:started",{mode:"draw_line"});var d=void 0===c.snapLayers?null!==(n=o.snapLayers)&&void 0!==n?n:null:c.snapLayers;p.setSnapLayers(d),f({type:"SET_HAS_SNAP_LAYERS",payload:(null==d?void 0:d.length)>0});var y=c.stroke,g=c.fill,m=c.strokeWidth,v=c.properties,b=c.onGeometryChange,E=function(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(c,j);p._geometryValidator=null!=b?b:o.onGeometryChange;var w=G(G({},v),C({stroke:y,fill:g,strokeWidth:m}));p.changeMode("draw_line",G(G({container:r.layoutRefs.viewportRef.current,addVertexButtonId:"".concat(i.id,"-draw-add-point"),interfaceType:r.interfaceType,crossHair:a.crossHair,getSnapEnabled:function(){return p.isSnapEnabled()},featureId:t},E),{},{properties:w})),f({type:"SET_MODE",payload:"draw_line"})}},editFeature:function(e,t){var n,r,i,o=e.appState,s=e.appConfig,a=e.mapState,l=e.pluginConfig,u=e.pluginState,c=e.mapProvider,f=e.services,p=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},h=u.dispatch,d=c.draw,y=f.eventBus;if(!d)return!1;var m=d.get(t);if(!m)return!1;d._geometryValidator=null!==(n=p.onGeometryChange)&&void 0!==n?n:l.onGeometryChange,y.emit("draw:editstart",{mode:{LineString:"edit_line",Polygon:"edit_polygon"}[m.geometry.type]});var b=void 0===p.snapLayers?null!==(r=l.snapLayers)&&void 0!==r?r:null:p.snapLayers;d.setSnapLayers(b),h({type:"SET_HAS_SNAP_LAYERS",payload:(null==b?void 0:b.length)>0}),d.changeMode("edit_vertex",{container:o.layoutRefs.viewportRef.current,deleteVertexButtonId:"".concat(s.id,"-draw-delete-point"),undoButtonId:"".concat(s.id,"-draw-undo"),isPanEnabled:"keyboard"!==o.interfaceType,interfaceType:o.interfaceType,scale:v.$y[a.mapSize],featureId:t,getSnapEnabled:function(){return d.isSnapEnabled()}});var E=d.get(t);h({type:"SET_FEATURE",payload:{feature:E,tempFeature:E}}),h({type:"SET_MODE",payload:"edit_vertex"});var w=(0,g.$U)(E,{phase:"edit-start",mode:"edit_vertex"},{onGeometryChange:d._geometryValidator}).valid;return h({type:"SET_GEOMETRY_VALID",payload:w}),null===(i=d.setInvalid)||void 0===i||i.call(d,!w),!0},addFeature:function(e,t){var n=e.mapProvider,r=e.services,i=n.draw,o=r.eventBus;if(i){var s=t.stroke,a=t.fill,l=t.strokeWidth,u=t.properties,c=H(H({},function(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(t,B)),{},{properties:H(H({},u),C({stroke:s,fill:a,strokeWidth:l}))});i.add(c),o.emit("draw:add",c)}},deleteFeature:function(e,t){var n=e.mapProvider,r=e.services,i=n.draw,o=r.eventBus;i&&(i.delete(t),o.emit("draw:delete",{featureId:t}))},split:function(e,t){var n,r=e.appState,i=e.appConfig,o=e.pluginState,s=e.mapState,a=e.mapProvider,l=e.services,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},c=o.dispatch,f=a.draw,p=l.eventBus;if(f){var h=f.get(t),d=f._geometryValidator;f._geometryValidator=function(e){var t=e.draw,n=e.dispatch,r=e.polygonFeature;return function(e){var i,o=e.feature,s=e.phase;if("preview"===s)i=$({draw:t,polygonFeature:r,feature:o});else{if(null==s||!s.startsWith("commit-"))return{valid:!0};i=function(e){var t=e.draw,n=e.dispatch,r=$({draw:t,polygonFeature:e.polygonFeature,feature:e.feature});return n({type:"SET_ACTION",payload:{name:"split",isValid:r}}),n({type:"SET_GEOMETRY_VALID",payload:r}),t.setGeometryValid(r),r}({draw:t,dispatch:n,polygonFeature:r,feature:o})}return i?{valid:!0}:{valid:!1,reason:"Line does not split the shape into two parts"}}}({draw:f,dispatch:c,polygonFeature:h});var g=["stroke-inactive.cold"].concat(function(e){if(Array.isArray(e))return z(e)}(n=u.snapLayers||[])||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||function(e,t){if(e){if("string"==typeof e)return z(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?z(e,t):void 0}}(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}());f.setSnapLayers(g),c({type:"SET_HAS_SNAP_LAYERS",payload:!0}),f.changeMode("draw_line",{container:r.layoutRefs.viewportRef.current,addVertexButtonId:"".concat(i.id,"-draw-add-point"),interfaceType:r.interfaceType,crossHair:null==s?void 0:s.crossHair,getSnapEnabled:function(){return f.isSnapEnabled()},featureId:W,properties:{splitter:"invalid"}});var m=function(){f._geometryValidator=d,f.off(y.k.CREATE,v),f.off(y.k.CANCEL,b)},v=function(e){m(),f.delete(W);var n=(0,Y.ns)(h,e);c({type:"SET_ACTION",payload:{name:"split",isValid:!!n}}),n&&p.emit("draw:split",{originalFeatureId:t,featureCollection:n})},b=function(){m()};f.on(y.k.CREATE,v),f.on(y.k.CANCEL,b),c({type:"SET_MODE",payload:"draw_line"}),c({type:"SET_ACTION",payload:{name:"split"}})}},merge:function(e,t){var n=e.mapProvider,r=e.services,i=n.draw,o=r.eventBus;if(!i)return null;var s=t.map(function(e){return i.get(e)}),a=(0,Y.OI)(s);return a&&o.emit("draw:merge",{originalFeatureIds:t,feature:a}),a}}}},704(e,t,n){function r(e){var t={type:"Feature"};return Object.keys(e).forEach(function(n){switch(n){case"type":case"properties":case"geometry":return;default:t[n]=e[n]}}),t.properties=i(e.properties),t.geometry=o(e.geometry),t}function i(e){var t={};return e?(Object.keys(e).forEach(function(n){var r=e[n];"object"==typeof r?null===r?t[n]=null:Array.isArray(r)?t[n]=r.map(function(e){return e}):t[n]=i(r):t[n]=r}),t):t}function o(e){var t={type:e.type};return e.bbox&&(t.bbox=e.bbox),"GeometryCollection"===e.type?(t.geometries=e.geometries.map(function(e){return o(e)}),t):(t.coordinates=s(e.coordinates),t)}function s(e){var t=e;return"object"!=typeof t[0]?t.slice():t.map(function(e){return s(e)})}n.d(t,{jK:()=>yt,DF:()=>dt,OI:()=>pt,cj:()=>gt,ns:()=>ft});function a(e){for(var t,n,r=function(e){if(Array.isArray(e))return e;if("Feature"===e.type){if(null!==e.geometry)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}(e),i=0,o=1;o<r.length;)t=n||r[0],i+=((n=r[o])[0]-t[0])*(n[1]+t[1]),o++;return i>0}function l(e,t){if("Feature"===e.type)t(e,0);else if("FeatureCollection"===e.type)for(var n=0;n<e.features.length&&!1!==t(e.features[n],n);n++);}function u(e,t){var n,r,i,o,s,a,l,u,c,f,p=0,h="FeatureCollection"===e.type,d="Feature"===e.type,y=h?e.features.length:1;for(n=0;n<y;n++){for(a=h?e.features[n].geometry:d?e.geometry:e,u=h?e.features[n].properties:d?e.properties:{},c=h?e.features[n].bbox:d?e.bbox:void 0,f=h?e.features[n].id:d?e.id:void 0,s=(l=!!a&&"GeometryCollection"===a.type)?a.geometries.length:1,i=0;i<s;i++)if(null!==(o=l?a.geometries[i]:a))switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(o,p,u,c,f))return!1;break;case"GeometryCollection":for(r=0;r<o.geometries.length;r++)if(!1===t(o.geometries[r],p,u,c,f))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,u,c,f))return!1;p++}}function c(e){if(Array.isArray(e))return e;if("Feature"===e.type){if(null!==e.geometry)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function f(e,t){switch("Feature"===e.type?e.geometry.type:e.type){case"GeometryCollection":return u(e,function(e){f(e,t)}),e;case"LineString":return p(c(e),t),e;case"Polygon":return h(c(e),t),e;case"MultiLineString":return c(e).forEach(function(e){p(e,t)}),e;case"MultiPolygon":return c(e).forEach(function(e){h(e,t)}),e;case"Point":case"MultiPoint":return e}}function p(e,t){a(e)===t&&e.reverse()}function h(e,t){a(e[0])!==t&&e[0].reverse();for(var n=1;n<e.length;n++)a(e[n])===t&&e[n].reverse()}const d=function(e,t){if(!(n=t=t||{})||n.constructor!==Object)throw new Error("options is invalid");var n,i=t.reverse||!1,s=t.mutate||!1;if(!e)throw new Error("<geojson> is required");if("boolean"!=typeof i)throw new Error("<reverse> must be a boolean");if("boolean"!=typeof s)throw new Error("<mutate> must be a boolean");!1===s&&(e=function(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return r(e);case"FeatureCollection":return function(e){var t={type:"FeatureCollection"};return Object.keys(e).forEach(function(n){switch(n){case"type":case"features":return;default:t[n]=e[n]}}),t.features=e.features.map(function(e){return r(e)}),t}(e);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return o(e);default:throw new Error("unknown GeoJSON type")}}(e));var a=[];switch(e.type){case"GeometryCollection":return u(e,function(e){f(e,i)}),e;case"FeatureCollection":return l(e,function(e){l(f(e,i),function(e){a.push(e)})}),function(e,t){void 0===t&&(t={});var n={type:"FeatureCollection"};return t.id&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.features=e,n}(a)}return f(e,i)},y=11102230246251565e-32,g=134217729,m=(3+8*y)*y;function v(e,t,n,r,i){let o,s,a,l,u=t[0],c=r[0],f=0,p=0;c>u==c>-u?(o=u,u=t[++f]):(o=c,c=r[++p]);let h=0;if(f<e&&p<n)for(c>u==c>-u?(s=u+o,a=o-(s-u),u=t[++f]):(s=c+o,a=o-(s-c),c=r[++p]),o=s,0!==a&&(i[h++]=a);f<e&&p<n;)c>u==c>-u?(s=o+u,l=s-o,a=o-(s-l)+(u-l),u=t[++f]):(s=o+c,l=s-o,a=o-(s-l)+(c-l),c=r[++p]),o=s,0!==a&&(i[h++]=a);for(;f<e;)s=o+u,l=s-o,a=o-(s-l)+(u-l),u=t[++f],o=s,0!==a&&(i[h++]=a);for(;p<n;)s=o+c,l=s-o,a=o-(s-l)+(c-l),c=r[++p],o=s,0!==a&&(i[h++]=a);return 0===o&&0!==h||(i[h++]=o),h}function b(e){return new Float64Array(e)}const E=b(4),w=b(8),S=b(12),P=b(16),x=b(4);function O(e,t,n,r,i,o){const s=(t-o)*(n-i),a=(e-i)*(r-o),l=s-a,u=Math.abs(s+a);return Math.abs(l)>=33306690738754716e-32*u?l:-function(e,t,n,r,i,o,s){let a,l,u,c,f,p,h,d,y,b,O,_,T,A,C,k,M,I;const L=e-i,R=n-i,N=t-o,j=r-o;A=L*j,p=g*L,h=p-(p-L),d=L-h,p=g*j,y=p-(p-j),b=j-y,C=d*b-(A-h*y-d*y-h*b),k=N*R,p=g*N,h=p-(p-N),d=N-h,p=g*R,y=p-(p-R),b=R-y,M=d*b-(k-h*y-d*y-h*b),O=C-M,f=C-O,E[0]=C-(O+f)+(f-M),_=A+O,f=_-A,T=A-(_-f)+(O-f),O=T-k,f=T-O,E[1]=T-(O+f)+(f-k),I=_+O,f=I-_,E[2]=_-(I-f)+(O-f),E[3]=I;let D=function(e,t){let n=t[0];for(let e=1;e<4;e++)n+=t[e];return n}(0,E),G=22204460492503146e-32*s;if(D>=G||-D>=G)return D;if(f=e-L,a=e-(L+f)+(f-i),f=n-R,u=n-(R+f)+(f-i),f=t-N,l=t-(N+f)+(f-o),f=r-j,c=r-(j+f)+(f-o),0===a&&0===l&&0===u&&0===c)return D;if(G=11093356479670487e-47*s+m*Math.abs(D),D+=L*c+j*a-(N*u+R*l),D>=G||-D>=G)return D;A=a*j,p=g*a,h=p-(p-a),d=a-h,p=g*j,y=p-(p-j),b=j-y,C=d*b-(A-h*y-d*y-h*b),k=l*R,p=g*l,h=p-(p-l),d=l-h,p=g*R,y=p-(p-R),b=R-y,M=d*b-(k-h*y-d*y-h*b),O=C-M,f=C-O,x[0]=C-(O+f)+(f-M),_=A+O,f=_-A,T=A-(_-f)+(O-f),O=T-k,f=T-O,x[1]=T-(O+f)+(f-k),I=_+O,f=I-_,x[2]=_-(I-f)+(O-f),x[3]=I;const F=v(4,E,4,x,w);A=L*c,p=g*L,h=p-(p-L),d=L-h,p=g*c,y=p-(p-c),b=c-y,C=d*b-(A-h*y-d*y-h*b),k=N*u,p=g*N,h=p-(p-N),d=N-h,p=g*u,y=p-(p-u),b=u-y,M=d*b-(k-h*y-d*y-h*b),O=C-M,f=C-O,x[0]=C-(O+f)+(f-M),_=A+O,f=_-A,T=A-(_-f)+(O-f),O=T-k,f=T-O,x[1]=T-(O+f)+(f-k),I=_+O,f=I-_,x[2]=_-(I-f)+(O-f),x[3]=I;const V=v(F,w,4,x,S);A=a*c,p=g*a,h=p-(p-a),d=a-h,p=g*c,y=p-(p-c),b=c-y,C=d*b-(A-h*y-d*y-h*b),k=l*u,p=g*l,h=p-(p-l),d=l-h,p=g*u,y=p-(p-u),b=u-y,M=d*b-(k-h*y-d*y-h*b),O=C-M,f=C-O,x[0]=C-(O+f)+(f-M),_=A+O,f=_-A,T=A-(_-f)+(O-f),O=T-k,f=T-O,x[1]=T-(O+f)+(f-k),I=_+O,f=I-_,x[2]=_-(I-f)+(O-f),x[3]=I;const B=v(V,S,4,x,P);return P[B-1]}(e,t,n,r,i,o,u)}function _(e,t){var n,r,i,o,s,a,l,u,c,f=0,p=e[0],h=e[1],d=t.length;for(n=0;n<d;n++){r=0;var y=t[n],g=y.length-1;if((u=y[0])[0]!==y[g][0]&&u[1]!==y[g][1])throw new Error("First and last coordinates in a ring must be the same");for(o=u[0]-p,s=u[1]-h;r<g;r++){if(a=(c=y[r+1])[0]-p,l=c[1]-h,0===s&&0===l){if(a<=0&&o>=0||o<=0&&a>=0)return 0}else if(l>=0&&s<=0||l<=0&&s>=0){if(0===(i=O(o,a,s,l,0,0)))return 0;(i>0&&l>0&&s<=0||i<0&&l<=0&&s>0)&&f++}u=c,s=l,o=a}}return f%2!=0}b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(8),b(8),b(8),b(4),b(8),b(8),b(8),b(12),b(192),b(192),b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(8),b(8),b(8),b(8),b(8),b(8),b(8),b(8),b(8),b(4),b(4),b(4),b(8),b(16),b(16),b(16),b(32),b(32),b(48),b(64),b(1152),b(1152),b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(24),b(24),b(24),b(24),b(24),b(24),b(24),b(24),b(24),b(24),b(1152),b(1152),b(1152),b(1152),b(1152),b(2304),b(2304),b(3456),b(5760),b(8),b(8),b(8),b(16),b(24),b(48),b(48),b(96),b(192),b(384),b(384),b(384),b(768),b(96),b(96),b(96),b(1152);const T=134217729;function A(e,t,n,r,i){let o,s,a,l,u=t[0],c=r[0],f=0,p=0;c>u==c>-u?(o=u,u=t[++f]):(o=c,c=r[++p]);let h=0;if(f<e&&p<n)for(c>u==c>-u?(s=u+o,a=o-(s-u),u=t[++f]):(s=c+o,a=o-(s-c),c=r[++p]),o=s,0!==a&&(i[h++]=a);f<e&&p<n;)c>u==c>-u?(s=o+u,l=s-o,a=o-(s-l)+(u-l),u=t[++f]):(s=o+c,l=s-o,a=o-(s-l)+(c-l),c=r[++p]),o=s,0!==a&&(i[h++]=a);for(;f<e;)s=o+u,l=s-o,a=o-(s-l)+(u-l),u=t[++f],o=s,0!==a&&(i[h++]=a);for(;p<n;)s=o+c,l=s-o,a=o-(s-l)+(c-l),c=r[++p],o=s,0!==a&&(i[h++]=a);return 0===o&&0!==h||(i[h++]=o),h}function C(e){return new Float64Array(e)}const k=C(4),M=C(8),I=C(12),L=C(16),R=C(4);function N(e,t,n,r,i,o){const s=(t-o)*(n-i),a=(e-i)*(r-o),l=s-a;if(0===s||0===a||s>0!=a>0)return l;const u=Math.abs(s+a);return Math.abs(l)>=33306690738754716e-32*u?l:-function(e,t,n,r,i,o,s){let a,l,u,c,f,p,h,d,y,g,m,v,b,E,w,S,P,x;const O=e-i,_=n-i,C=t-o,N=r-o;E=O*N,p=T*O,h=p-(p-O),d=O-h,p=T*N,y=p-(p-N),g=N-y,w=d*g-(E-h*y-d*y-h*g),S=C*_,p=T*C,h=p-(p-C),d=C-h,p=T*_,y=p-(p-_),g=_-y,P=d*g-(S-h*y-d*y-h*g),m=w-P,f=w-m,k[0]=w-(m+f)+(f-P),v=E+m,f=v-E,b=E-(v-f)+(m-f),m=b-S,f=b-m,k[1]=b-(m+f)+(f-S),x=v+m,f=x-v,k[2]=v-(x-f)+(m-f),k[3]=x;let j=function(e,t){let n=t[0];for(let e=1;e<4;e++)n+=t[e];return n}(0,k),D=22204460492503146e-32*s;if(j>=D||-j>=D)return j;if(f=e-O,a=e-(O+f)+(f-i),f=n-_,u=n-(_+f)+(f-i),f=t-C,l=t-(C+f)+(f-o),f=r-N,c=r-(N+f)+(f-o),0===a&&0===l&&0===u&&0===c)return j;if(D=11093356479670487e-47*s+33306690738754706e-32*Math.abs(j),j+=O*c+N*a-(C*u+_*l),j>=D||-j>=D)return j;E=a*N,p=T*a,h=p-(p-a),d=a-h,p=T*N,y=p-(p-N),g=N-y,w=d*g-(E-h*y-d*y-h*g),S=l*_,p=T*l,h=p-(p-l),d=l-h,p=T*_,y=p-(p-_),g=_-y,P=d*g-(S-h*y-d*y-h*g),m=w-P,f=w-m,R[0]=w-(m+f)+(f-P),v=E+m,f=v-E,b=E-(v-f)+(m-f),m=b-S,f=b-m,R[1]=b-(m+f)+(f-S),x=v+m,f=x-v,R[2]=v-(x-f)+(m-f),R[3]=x;const G=A(4,k,4,R,M);E=O*c,p=T*O,h=p-(p-O),d=O-h,p=T*c,y=p-(p-c),g=c-y,w=d*g-(E-h*y-d*y-h*g),S=C*u,p=T*C,h=p-(p-C),d=C-h,p=T*u,y=p-(p-u),g=u-y,P=d*g-(S-h*y-d*y-h*g),m=w-P,f=w-m,R[0]=w-(m+f)+(f-P),v=E+m,f=v-E,b=E-(v-f)+(m-f),m=b-S,f=b-m,R[1]=b-(m+f)+(f-S),x=v+m,f=x-v,R[2]=v-(x-f)+(m-f),R[3]=x;const F=A(G,M,4,R,I);E=a*c,p=T*a,h=p-(p-a),d=a-h,p=T*c,y=p-(p-c),g=c-y,w=d*g-(E-h*y-d*y-h*g),S=l*u,p=T*l,h=p-(p-l),d=l-h,p=T*u,y=p-(p-u),g=u-y,P=d*g-(S-h*y-d*y-h*g),m=w-P,f=w-m,R[0]=w-(m+f)+(f-P),v=E+m,f=v-E,b=E-(v-f)+(m-f),m=b-S,f=b-m,R[1]=b-(m+f)+(f-S),x=v+m,f=x-v,R[2]=v-(x-f)+(m-f),R[3]=x;const V=A(F,I,4,R,L);return L[V-1]}(e,t,n,r,i,o,u)}C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(8),C(8),C(8),C(4),C(8),C(8),C(8),C(12),C(192),C(192),C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(8),C(8),C(8),C(8),C(8),C(8),C(8),C(8),C(8),C(4),C(4),C(4),C(8),C(16),C(16),C(16),C(32),C(32),C(48),C(64),C(1152),C(1152),C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(24),C(24),C(24),C(24),C(24),C(24),C(24),C(24),C(24),C(24),C(1152),C(1152),C(1152),C(1152),C(1152),C(2304),C(2304),C(3456),C(5760),C(8),C(8),C(8),C(16),C(24),C(48),C(48),C(96),C(192),C(384),C(384),C(384),C(768),C(96),C(96),C(96),C(1152);var j=function(e,t,n,r,i){this.p1=e,this.p2=t,this.edgeType=n,this.originalIndex=r,this.polygonContourId=i,this.interiorRing=!1,this.minX=Math.min(e.p[0],t.p[0]),this.minY=Math.min(e.p[1],t.p[1]),this.maxX=Math.max(e.p[0],t.p[0]),this.maxY=Math.max(e.p[1],t.p[1]),this.intersectionPoints=[],this.nextEdge=null},D=function(e){this.p=e},G=function(e,t){this.id=e,this.rawCoords=t};function F(e,t){return!(e.maxX<t[0]||e.minX>t[2]||e.maxY<t[1]||e.minY>t[3])}var V=function(e,t,n,r){this.p=e,this.polylineEdge=t,this.polygonEdge=n,this.isHeadingIn=r,this.distanceFromPolylineEdgeStart=B(this.polylineEdge.p1.p,this.p),this.distanceFromPolygonEdgeStart=B(this.polygonEdge.p1.p,this.p),this.polygonEdge.intersectionPoints.push(this),this.polylineEdge.intersectionPoints.push(this),this.visitCount=0};function B(e,t){var n=t[0]-e[0],r=t[1]-e[1];return n*=n,r*=r,Math.sqrt(n+r)}function U(e,t){return e[0]*t[1]-e[1]*t[0]}function H(e,t){return e[0]*t[0]+e[1]*t[1]}function q(e,t,n){return[e[0]+t*n[0],e[1]+t*n[1]]}function Y(e,t,n){var r=[e.p2.p[0]-e.p1.p[0],e.p2.p[1]-e.p1.p[1]],i=[t.p2.p[0]-t.p1.p[0],t.p2.p[1]-t.p1.p[1]],o=[t.p1.p[0]-e.p1.p[0],t.p1.p[1]-e.p1.p[1]],s=U(r,i),a=s*s,l=H(r,r);if(a>0){var u=U(o,i)/s;if(u<0||u>1)return null;var c=U(o,r)/s;return c<0||c>1?null:0===u||1===u?n?null:[q(e.p1.p,u,r)]:0===c||1===c?n?null:[q(t.p1.p,c,i)]:[q(e.p1.p,u,r)]}var f=H(o,o);if((a=(s=U(o,r))*s)>1e-9*l*f)return null;var p=H(r,o)/l,h=p+H(r,i)/l,d=Math.min(p,h),y=Math.max(p,h);return d<=1&&y>=0?1===d?n?null:[q(e.p1.p,d>0?d:0,r)]:0===y?n?null:[q(e.p1.p,y<1?y:1,r)]:n&&0===d&&1===y?null:[q(e.p1.p,d>0?d:0,r),q(e.p1.p,y<1?y:1,r)]:null}function z(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(r.polygonContourId===t)return r}}function W(e,t){return t.find(function(t){return t.id===e.polygonContourId}).rawCoords}function $(e,t){for(var n=0;n<t.length;n++){var r=t[n];if(_(e[0],[r[0]]))return void r.push(e)}t.push([e])}function X(e,t){var n=e.polygonEdge;if(n.intersectionPoints.length>1&&n.intersectionPoints[n.intersectionPoints.length-1]!==e){var r=K(e,n.intersectionPoints),i=n.intersectionPoints[r+1];return t.push(i.p),i.incrementVisitCount(),i}for(var o=!0;o;){if(t.push(n.p2.p),null===(n=n.nextEdge))return e;n.intersectionPoints.length>0&&(o=!1)}return n.intersectionPoints[0].incrementVisitCount(),t.push(n.intersectionPoints[0].p),n.intersectionPoints[0]}function K(e,t){for(var n=0;n<t.length;n++)if(t[n]===e)return n;return null}function Z(e,t){var n=e.polylineEdge;if(2===n.intersectionPoints.length){var r=n.intersectionPoints[n.intersectionPoints.length-1];if(r===e){var i=n.intersectionPoints[0];return t.push(i.p),i.incrementVisitCount(),i}return t.push(r.p),r.incrementVisitCount(),r}if(n.intersectionPoints.length>2&&n.intersectionPoints[0]!==e){var o=K(e,n.intersectionPoints),s=n.intersectionPoints[o-1];return t.push(s.p),s.incrementVisitCount(),s}for(var a=!0;a;){if(t.push(n.p1.p),void 0===(n=n.prevEdge).originalIndex)return e;n.intersectionPoints.length>0&&(a=!1)}if(void 0===n.originalIndex)return e;var l=n.intersectionPoints[n.intersectionPoints.length-1];return l.incrementVisitCount(),t.push(l.p),l}function J(e,t){var n=e.polylineEdge;if(n.intersectionPoints.length>1&&n.intersectionPoints[n.intersectionPoints.length-1]!==e){var r=K(e,n.intersectionPoints),i=n.intersectionPoints[r+1];return t.push(i.p),i.incrementVisitCount(),i}for(var o=!0;o;){if(t.push(n.p2.p),null===(n=n.nextEdge))return e;n.intersectionPoints.length>0&&(o=!1)}if(void 0===n)return e;var s=n.intersectionPoints[0];return s.incrementVisitCount(),t.push(s.p),s}V.prototype.incrementVisitCount=function(){this.visitCount=this.visitCount+1};var Q=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,ee=Math.ceil,te=Math.floor,ne="[BigNumber Error] ",re=ne+"Number primitive has more than 15 significant digits: ",ie=1e14,oe=14,se=9007199254740991,ae=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],le=1e7,ue=1e9;function ce(e){var t=0|e;return e>0||e===t?t:t-1}function fe(e){for(var t,n,r=1,i=e.length,o=e[0]+"";r<i;){for(t=e[r++]+"",n=oe-t.length;n--;t="0"+t);o+=t}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function pe(e,t){var n,r,i=e.c,o=t.c,s=e.s,a=t.s,l=e.e,u=t.e;if(!s||!a)return null;if(n=i&&!i[0],r=o&&!o[0],n||r)return n?r?0:-a:s;if(s!=a)return s;if(n=s<0,r=l==u,!i||!o)return r?0:!i^n?1:-1;if(!r)return l>u^n?1:-1;for(a=(l=i.length)<(u=o.length)?l:u,s=0;s<a;s++)if(i[s]!=o[s])return i[s]>o[s]^n?1:-1;return l==u?0:l>u^n?1:-1}function he(e,t,n,r){if(e<t||e>n||e!==te(e))throw Error(ne+(r||"Argument")+("number"==typeof e?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function de(e){var t=e.c.length-1;return ce(e.e/oe)==t&&e.c[t]%2!=0}function ye(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function ge(e,t,n){var r,i;if(t<0){for(i=n+".";++t;i+=n);e=i+e}else if(++t>(r=e.length)){for(i=n,t-=r;--t;i+=n);e+=i}else t<r&&(e=e.slice(0,t)+"."+e.slice(t));return e}var me=function e(t){var n,r,i,o,s,a,l,u,c,f,p=_.prototype={constructor:_,toString:null,valueOf:null},h=new _(1),d=20,y=4,g=-7,m=21,v=-1e7,b=1e7,E=!1,w=1,S=0,P={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},x="0123456789abcdefghijklmnopqrstuvwxyz",O=!0;function _(e,t){var n,o,s,a,l,u,c,f,p=this;if(!(p instanceof _))return new _(e,t);if(null==t){if(e&&!0===e._isBigNumber)return p.s=e.s,void(!e.c||e.e>b?p.c=p.e=null:e.e<v?p.c=[p.e=0]:(p.e=e.e,p.c=e.c.slice()));if((u="number"==typeof e)&&0*e==0){if(p.s=1/e<0?(e=-e,-1):1,e===~~e){for(a=0,l=e;l>=10;l/=10,a++);return void(a>b?p.c=p.e=null:(p.e=a,p.c=[e]))}f=String(e)}else{if(!Q.test(f=String(e)))return i(p,f,u);p.s=45==f.charCodeAt(0)?(f=f.slice(1),-1):1}(a=f.indexOf("."))>-1&&(f=f.replace(".","")),(l=f.search(/e/i))>0?(a<0&&(a=l),a+=+f.slice(l+1),f=f.substring(0,l)):a<0&&(a=f.length)}else{if(he(t,2,x.length,"Base"),10==t&&O)return k(p=new _(e),d+p.e+1,y);if(f=String(e),u="number"==typeof e){if(0*e!=0)return i(p,f,u,t);if(p.s=1/e<0?(f=f.slice(1),-1):1,_.DEBUG&&f.replace(/^0\.0*|\./,"").length>15)throw Error(re+e)}else p.s=45===f.charCodeAt(0)?(f=f.slice(1),-1):1;for(n=x.slice(0,t),a=l=0,c=f.length;l<c;l++)if(n.indexOf(o=f.charAt(l))<0){if("."==o){if(l>a){a=c;continue}}else if(!s&&(f==f.toUpperCase()&&(f=f.toLowerCase())||f==f.toLowerCase()&&(f=f.toUpperCase()))){s=!0,l=-1,a=0;continue}return i(p,String(e),u,t)}u=!1,(a=(f=r(f,t,10,p.s)).indexOf("."))>-1?f=f.replace(".",""):a=f.length}for(l=0;48===f.charCodeAt(l);l++);for(c=f.length;48===f.charCodeAt(--c););if(f=f.slice(l,++c)){if(c-=l,u&&_.DEBUG&&c>15&&(e>se||e!==te(e)))throw Error(re+p.s*e);if((a=a-l-1)>b)p.c=p.e=null;else if(a<v)p.c=[p.e=0];else{if(p.e=a,p.c=[],l=(a+1)%oe,a<0&&(l+=oe),l<c){for(l&&p.c.push(+f.slice(0,l)),c-=oe;l<c;)p.c.push(+f.slice(l,l+=oe));l=oe-(f=f.slice(l)).length}else l-=c;for(;l--;f+="0");p.c.push(+f)}}else p.c=[p.e=0]}function T(e,t,n,r){var i,o,s,a,l;if(null==n?n=y:he(n,0,8),!e.c)return e.toString();if(i=e.c[0],s=e.e,null==t)l=fe(e.c),l=1==r||2==r&&(s<=g||s>=m)?ye(l,s):ge(l,s,"0");else if(o=(e=k(new _(e),t,n)).e,a=(l=fe(e.c)).length,1==r||2==r&&(t<=o||o<=g)){for(;a<t;l+="0",a++);l=ye(l,o)}else if(t-=s+(2===r&&o>s),l=ge(l,o,"0"),o+1>a){if(--t>0)for(l+=".";t--;l+="0");}else if((t+=o-a)>0)for(o+1==a&&(l+=".");t--;l+="0");return e.s<0&&i?"-"+l:l}function A(e,t){for(var n,r,i=1,o=new _(e[0]);i<e.length;i++)(!(r=new _(e[i])).s||(n=pe(o,r))===t||0===n&&o.s===t)&&(o=r);return o}function C(e,t,n){for(var r=1,i=t.length;!t[--i];t.pop());for(i=t[0];i>=10;i/=10,r++);return(n=r+n*oe-1)>b?e.c=e.e=null:n<v?e.c=[e.e=0]:(e.e=n,e.c=t),e}function k(e,t,n,r){var i,o,s,a,l,u,c,f=e.c,p=ae;if(f){e:{for(i=1,a=f[0];a>=10;a/=10,i++);if((o=t-i)<0)o+=oe,s=t,l=f[u=0],c=te(l/p[i-s-1]%10);else if((u=ee((o+1)/oe))>=f.length){if(!r)break e;for(;f.length<=u;f.push(0));l=c=0,i=1,s=(o%=oe)-oe+1}else{for(l=a=f[u],i=1;a>=10;a/=10,i++);c=(s=(o%=oe)-oe+i)<0?0:te(l/p[i-s-1]%10)}if(r=r||t<0||null!=f[u+1]||(s<0?l:l%p[i-s-1]),r=n<4?(c||r)&&(0==n||n==(e.s<0?3:2)):c>5||5==c&&(4==n||r||6==n&&(o>0?s>0?l/p[i-s]:0:f[u-1])%10&1||n==(e.s<0?8:7)),t<1||!f[0])return f.length=0,r?(t-=e.e+1,f[0]=p[(oe-t%oe)%oe],e.e=-t||0):f[0]=e.e=0,e;if(0==o?(f.length=u,a=1,u--):(f.length=u+1,a=p[oe-o],f[u]=s>0?te(l/p[i-s]%p[s])*a:0),r)for(;;){if(0==u){for(o=1,s=f[0];s>=10;s/=10,o++);for(s=f[0]+=a,a=1;s>=10;s/=10,a++);o!=a&&(e.e++,f[0]==ie&&(f[0]=1));break}if(f[u]+=a,f[u]!=ie)break;f[u--]=0,a=1}for(o=f.length;0===f[--o];f.pop());}e.e>b?e.c=e.e=null:e.e<v&&(e.c=[e.e=0])}return e}function M(e){var t,n=e.e;return null===n?e.toString():(t=fe(e.c),t=n<=g||n>=m?ye(t,n):ge(t,n,"0"),e.s<0?"-"+t:t)}return _.clone=e,_.ROUND_UP=0,_.ROUND_DOWN=1,_.ROUND_CEIL=2,_.ROUND_FLOOR=3,_.ROUND_HALF_UP=4,_.ROUND_HALF_DOWN=5,_.ROUND_HALF_EVEN=6,_.ROUND_HALF_CEIL=7,_.ROUND_HALF_FLOOR=8,_.EUCLID=9,_.config=_.set=function(e){var t,n;if(null!=e){if("object"!=typeof e)throw Error(ne+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(he(n=e[t],0,ue,t),d=n),e.hasOwnProperty(t="ROUNDING_MODE")&&(he(n=e[t],0,8,t),y=n),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((n=e[t])&&n.pop?(he(n[0],-ue,0,t),he(n[1],0,ue,t),g=n[0],m=n[1]):(he(n,-ue,ue,t),g=-(m=n<0?-n:n))),e.hasOwnProperty(t="RANGE"))if((n=e[t])&&n.pop)he(n[0],-ue,-1,t),he(n[1],1,ue,t),v=n[0],b=n[1];else{if(he(n,-ue,ue,t),!n)throw Error(ne+t+" cannot be zero: "+n);v=-(b=n<0?-n:n)}if(e.hasOwnProperty(t="CRYPTO")){if((n=e[t])!==!!n)throw Error(ne+t+" not true or false: "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw E=!n,Error(ne+"crypto unavailable");E=n}else E=n}if(e.hasOwnProperty(t="MODULO_MODE")&&(he(n=e[t],0,9,t),w=n),e.hasOwnProperty(t="POW_PRECISION")&&(he(n=e[t],0,ue,t),S=n),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(n=e[t]))throw Error(ne+t+" not an object: "+n);P=n}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(n=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(n))throw Error(ne+t+" invalid: "+n);O="0123456789"==n.slice(0,10),x=n}}return{DECIMAL_PLACES:d,ROUNDING_MODE:y,EXPONENTIAL_AT:[g,m],RANGE:[v,b],CRYPTO:E,MODULO_MODE:w,POW_PRECISION:S,FORMAT:P,ALPHABET:x}},_.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!_.DEBUG)return!0;var t,n,r=e.c,i=e.e,o=e.s;e:if("[object Array]"=={}.toString.call(r)){if((1===o||-1===o)&&i>=-ue&&i<=ue&&i===te(i)){if(0===r[0]){if(0===i&&1===r.length)return!0;break e}if((t=(i+1)%oe)<1&&(t+=oe),String(r[0]).length==t){for(t=0;t<r.length;t++)if((n=r[t])<0||n>=ie||n!==te(n))break e;if(0!==n)return!0}}}else if(null===r&&null===i&&(null===o||1===o||-1===o))return!0;throw Error(ne+"Invalid BigNumber: "+e)},_.maximum=_.max=function(){return A(arguments,-1)},_.minimum=_.min=function(){return A(arguments,1)},_.random=(o=9007199254740992,s=Math.random()*o&2097151?function(){return te(Math.random()*o)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,n,r,i,o,a=0,l=[],u=new _(h);if(null==e?e=d:he(e,0,ue),i=ee(e/oe),E)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(i*=2));a<i;)(o=131072*t[a]+(t[a+1]>>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),t[a]=n[0],t[a+1]=n[1]):(l.push(o%1e14),a+=2);a=i/2}else{if(!crypto.randomBytes)throw E=!1,Error(ne+"crypto unavailable");for(t=crypto.randomBytes(i*=7);a<i;)(o=281474976710656*(31&t[a])+1099511627776*t[a+1]+4294967296*t[a+2]+16777216*t[a+3]+(t[a+4]<<16)+(t[a+5]<<8)+t[a+6])>=9e15?crypto.randomBytes(7).copy(t,a):(l.push(o%1e14),a+=7);a=i/7}if(!E)for(;a<i;)(o=s())<9e15&&(l[a++]=o%1e14);for(i=l[--a],e%=oe,i&&e&&(o=ae[oe-e],l[a]=te(i/o)*o);0===l[a];l.pop(),a--);if(a<0)l=[r=0];else{for(r=-1;0===l[0];l.splice(0,1),r-=oe);for(a=1,o=l[0];o>=10;o/=10,a++);a<oe&&(r-=oe-a)}return u.e=r,u.c=l,u}),_.sum=function(){for(var e=1,t=arguments,n=new _(t[0]);e<t.length;)n=n.plus(t[e++]);return n},r=function(){var e="0123456789";function t(e,t,n,r){for(var i,o,s=[0],a=0,l=e.length;a<l;){for(o=s.length;o--;s[o]*=t);for(s[0]+=r.indexOf(e.charAt(a++)),i=0;i<s.length;i++)s[i]>n-1&&(null==s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/n|0,s[i]%=n)}return s.reverse()}return function(r,i,o,s,a){var l,u,c,f,p,h,g,m,v=r.indexOf("."),b=d,E=y;for(v>=0&&(f=S,S=0,r=r.replace(".",""),h=(m=new _(i)).pow(r.length-v),S=f,m.c=t(ge(fe(h.c),h.e,"0"),10,o,e),m.e=m.c.length),c=f=(g=t(r,i,o,a?(l=x,e):(l=e,x))).length;0==g[--f];g.pop());if(!g[0])return l.charAt(0);if(v<0?--c:(h.c=g,h.e=c,h.s=s,g=(h=n(h,m,b,E,o)).c,p=h.r,c=h.e),v=g[u=c+b+1],f=o/2,p=p||u<0||null!=g[u+1],p=E<4?(null!=v||p)&&(0==E||E==(h.s<0?3:2)):v>f||v==f&&(4==E||p||6==E&&1&g[u-1]||E==(h.s<0?8:7)),u<1||!g[0])r=p?ge(l.charAt(1),-b,l.charAt(0)):l.charAt(0);else{if(g.length=u,p)for(--o;++g[--u]>o;)g[u]=0,u||(++c,g=[1].concat(g));for(f=g.length;!g[--f];);for(v=0,r="";v<=f;r+=l.charAt(g[v++]));r=ge(r,c,l.charAt(0))}return r}}(),n=function(){function e(e,t,n){var r,i,o,s,a=0,l=e.length,u=t%le,c=t/le|0;for(e=e.slice();l--;)a=((i=u*(o=e[l]%le)+(r=c*o+(s=e[l]/le|0)*u)%le*le+a)/n|0)+(r/le|0)+c*s,e[l]=i%n;return a&&(e=[a].concat(e)),e}function t(e,t,n,r){var i,o;if(n!=r)o=n>r?1:-1;else for(i=o=0;i<n;i++)if(e[i]!=t[i]){o=e[i]>t[i]?1:-1;break}return o}function n(e,t,n,r){for(var i=0;n--;)e[n]-=i,i=e[n]<t[n]?1:0,e[n]=i*r+e[n]-t[n];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(r,i,o,s,a){var l,u,c,f,p,h,d,y,g,m,v,b,E,w,S,P,x,O=r.s==i.s?1:-1,T=r.c,A=i.c;if(!(T&&T[0]&&A&&A[0]))return new _(r.s&&i.s&&(T?!A||T[0]!=A[0]:A)?T&&0==T[0]||!A?0*O:O/0:NaN);for(g=(y=new _(O)).c=[],O=o+(u=r.e-i.e)+1,a||(a=ie,u=ce(r.e/oe)-ce(i.e/oe),O=O/oe|0),c=0;A[c]==(T[c]||0);c++);if(A[c]>(T[c]||0)&&u--,O<0)g.push(1),f=!0;else{for(w=T.length,P=A.length,c=0,O+=2,(p=te(a/(A[0]+1)))>1&&(A=e(A,p,a),T=e(T,p,a),P=A.length,w=T.length),E=P,v=(m=T.slice(0,P)).length;v<P;m[v++]=0);x=A.slice(),x=[0].concat(x),S=A[0],A[1]>=a/2&&S++;do{if(p=0,(l=t(A,m,P,v))<0){if(b=m[0],P!=v&&(b=b*a+(m[1]||0)),(p=te(b/S))>1)for(p>=a&&(p=a-1),d=(h=e(A,p,a)).length,v=m.length;1==t(h,m,d,v);)p--,n(h,P<d?x:A,d,a),d=h.length,l=1;else 0==p&&(l=p=1),d=(h=A.slice()).length;if(d<v&&(h=[0].concat(h)),n(m,h,v,a),v=m.length,-1==l)for(;t(A,m,P,v)<1;)p++,n(m,P<v?x:A,v,a),v=m.length}else 0===l&&(p++,m=[0]);g[c++]=p,m[0]?m[v++]=T[E]||0:(m=[T[E]],v=1)}while((E++<w||null!=m[0])&&O--);f=null!=m[0],g[0]||g.splice(0,1)}if(a==ie){for(c=1,O=g[0];O>=10;O/=10,c++);k(y,o+(y.e=c+u*oe-1)+1,s,f)}else y.e=u,y.r=+f;return y}}(),a=/^(-?)0([xbo])(?=\w[\w.]*$)/i,l=/^([^.]+)\.$/,u=/^\.([^.]+)$/,c=/^-?(Infinity|NaN)$/,f=/^\s*\+(?=[\w.])|^\s+|\s+$/g,i=function(e,t,n,r){var i,o=n?t:t.replace(f,"");if(c.test(o))e.s=isNaN(o)?null:o<0?-1:1;else{if(!n&&(o=o.replace(a,function(e,t,n){return i="x"==(n=n.toLowerCase())?16:"b"==n?2:8,r&&r!=i?e:t}),r&&(i=r,o=o.replace(l,"$1").replace(u,"0.$1")),t!=o))return new _(o,i);if(_.DEBUG)throw Error(ne+"Not a"+(r?" base "+r:"")+" number: "+t);e.s=null}e.c=e.e=null},p.absoluteValue=p.abs=function(){var e=new _(this);return e.s<0&&(e.s=1),e},p.comparedTo=function(e,t){return pe(this,new _(e,t))},p.decimalPlaces=p.dp=function(e,t){var n,r,i,o=this;if(null!=e)return he(e,0,ue),null==t?t=y:he(t,0,8),k(new _(o),e+o.e+1,t);if(!(n=o.c))return null;if(r=((i=n.length-1)-ce(this.e/oe))*oe,i=n[i])for(;i%10==0;i/=10,r--);return r<0&&(r=0),r},p.dividedBy=p.div=function(e,t){return n(this,new _(e,t),d,y)},p.dividedToIntegerBy=p.idiv=function(e,t){return n(this,new _(e,t),0,1)},p.exponentiatedBy=p.pow=function(e,t){var n,r,i,o,s,a,l,u,c=this;if((e=new _(e)).c&&!e.isInteger())throw Error(ne+"Exponent not an integer: "+M(e));if(null!=t&&(t=new _(t)),s=e.e>14,!c.c||!c.c[0]||1==c.c[0]&&!c.e&&1==c.c.length||!e.c||!e.c[0])return u=new _(Math.pow(+M(c),s?e.s*(2-de(e)):+M(e))),t?u.mod(t):u;if(a=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new _(NaN);(r=!a&&c.isInteger()&&t.isInteger())&&(c=c.mod(t))}else{if(e.e>9&&(c.e>0||c.e<-1||(0==c.e?c.c[0]>1||s&&c.c[1]>=24e7:c.c[0]<8e13||s&&c.c[0]<=9999975e7)))return o=c.s<0&&de(e)?-0:0,c.e>-1&&(o=1/o),new _(a?1/o:o);S&&(o=ee(S/oe+2))}for(s?(n=new _(.5),a&&(e.s=1),l=de(e)):l=(i=Math.abs(+M(e)))%2,u=new _(h);;){if(l){if(!(u=u.times(c)).c)break;o?u.c.length>o&&(u.c.length=o):r&&(u=u.mod(t))}if(i){if(0===(i=te(i/2)))break;l=i%2}else if(k(e=e.times(n),e.e+1,1),e.e>14)l=de(e);else{if(0===(i=+M(e)))break;l=i%2}c=c.times(c),o?c.c&&c.c.length>o&&(c.c.length=o):r&&(c=c.mod(t))}return r?u:(a&&(u=h.div(u)),t?u.mod(t):o?k(u,S,y,void 0):u)},p.integerValue=function(e){var t=new _(this);return null==e?e=y:he(e,0,8),k(t,t.e+1,e)},p.isEqualTo=p.eq=function(e,t){return 0===pe(this,new _(e,t))},p.isFinite=function(){return!!this.c},p.isGreaterThan=p.gt=function(e,t){return pe(this,new _(e,t))>0},p.isGreaterThanOrEqualTo=p.gte=function(e,t){return 1===(t=pe(this,new _(e,t)))||0===t},p.isInteger=function(){return!!this.c&&ce(this.e/oe)>this.c.length-2},p.isLessThan=p.lt=function(e,t){return pe(this,new _(e,t))<0},p.isLessThanOrEqualTo=p.lte=function(e,t){return-1===(t=pe(this,new _(e,t)))||0===t},p.isNaN=function(){return!this.s},p.isNegative=function(){return this.s<0},p.isPositive=function(){return this.s>0},p.isZero=function(){return!!this.c&&0==this.c[0]},p.minus=function(e,t){var n,r,i,o,s=this,a=s.s;if(t=(e=new _(e,t)).s,!a||!t)return new _(NaN);if(a!=t)return e.s=-t,s.plus(e);var l=s.e/oe,u=e.e/oe,c=s.c,f=e.c;if(!l||!u){if(!c||!f)return c?(e.s=-t,e):new _(f?s:NaN);if(!c[0]||!f[0])return f[0]?(e.s=-t,e):new _(c[0]?s:3==y?-0:0)}if(l=ce(l),u=ce(u),c=c.slice(),a=l-u){for((o=a<0)?(a=-a,i=c):(u=l,i=f),i.reverse(),t=a;t--;i.push(0));i.reverse()}else for(r=(o=(a=c.length)<(t=f.length))?a:t,a=t=0;t<r;t++)if(c[t]!=f[t]){o=c[t]<f[t];break}if(o&&(i=c,c=f,f=i,e.s=-e.s),(t=(r=f.length)-(n=c.length))>0)for(;t--;c[n++]=0);for(t=ie-1;r>a;){if(c[--r]<f[r]){for(n=r;n&&!c[--n];c[n]=t);--c[n],c[r]+=ie}c[r]-=f[r]}for(;0==c[0];c.splice(0,1),--u);return c[0]?C(e,c,u):(e.s=3==y?-1:1,e.c=[e.e=0],e)},p.modulo=p.mod=function(e,t){var r,i,o=this;return e=new _(e,t),!o.c||!e.s||e.c&&!e.c[0]?new _(NaN):!e.c||o.c&&!o.c[0]?new _(o):(9==w?(i=e.s,e.s=1,r=n(o,e,0,3),e.s=i,r.s*=i):r=n(o,e,0,w),(e=o.minus(r.times(e))).c[0]||1!=w||(e.s=o.s),e)},p.multipliedBy=p.times=function(e,t){var n,r,i,o,s,a,l,u,c,f,p,h,d,y,g,m=this,v=m.c,b=(e=new _(e,t)).c;if(!(v&&b&&v[0]&&b[0]))return!m.s||!e.s||v&&!v[0]&&!b||b&&!b[0]&&!v?e.c=e.e=e.s=null:(e.s*=m.s,v&&b?(e.c=[0],e.e=0):e.c=e.e=null),e;for(r=ce(m.e/oe)+ce(e.e/oe),e.s*=m.s,(l=v.length)<(f=b.length)&&(d=v,v=b,b=d,i=l,l=f,f=i),i=l+f,d=[];i--;d.push(0));for(y=ie,g=le,i=f;--i>=0;){for(n=0,p=b[i]%g,h=b[i]/g|0,o=i+(s=l);o>i;)n=((u=p*(u=v[--s]%g)+(a=h*u+(c=v[s]/g|0)*p)%g*g+d[o]+n)/y|0)+(a/g|0)+h*c,d[o--]=u%y;d[o]=n}return n?++r:d.splice(0,1),C(e,d,r)},p.negated=function(){var e=new _(this);return e.s=-e.s||null,e},p.plus=function(e,t){var n,r=this,i=r.s;if(t=(e=new _(e,t)).s,!i||!t)return new _(NaN);if(i!=t)return e.s=-t,r.minus(e);var o=r.e/oe,s=e.e/oe,a=r.c,l=e.c;if(!o||!s){if(!a||!l)return new _(i/0);if(!a[0]||!l[0])return l[0]?e:new _(a[0]?r:0*i)}if(o=ce(o),s=ce(s),a=a.slice(),i=o-s){for(i>0?(s=o,n=l):(i=-i,n=a),n.reverse();i--;n.push(0));n.reverse()}for((i=a.length)-(t=l.length)<0&&(n=l,l=a,a=n,t=i),i=0;t;)i=(a[--t]=a[t]+l[t]+i)/ie|0,a[t]=ie===a[t]?0:a[t]%ie;return i&&(a=[i].concat(a),++s),C(e,a,s)},p.precision=p.sd=function(e,t){var n,r,i,o=this;if(null!=e&&e!==!!e)return he(e,1,ue),null==t?t=y:he(t,0,8),k(new _(o),e,t);if(!(n=o.c))return null;if(r=(i=n.length-1)*oe+1,i=n[i]){for(;i%10==0;i/=10,r--);for(i=n[0];i>=10;i/=10,r++);}return e&&o.e+1>r&&(r=o.e+1),r},p.shiftedBy=function(e){return he(e,-9007199254740991,se),this.times("1e"+e)},p.squareRoot=p.sqrt=function(){var e,t,r,i,o,s=this,a=s.c,l=s.s,u=s.e,c=d+4,f=new _("0.5");if(1!==l||!a||!a[0])return new _(!l||l<0&&(!a||a[0])?NaN:a?s:1/0);if(0==(l=Math.sqrt(+M(s)))||l==1/0?(((t=fe(a)).length+u)%2==0&&(t+="0"),l=Math.sqrt(+t),u=ce((u+1)/2)-(u<0||u%2),r=new _(t=l==1/0?"5e"+u:(t=l.toExponential()).slice(0,t.indexOf("e")+1)+u)):r=new _(l+""),r.c[0])for((l=(u=r.e)+c)<3&&(l=0);;)if(o=r,r=f.times(o.plus(n(s,o,c,1))),fe(o.c).slice(0,l)===(t=fe(r.c)).slice(0,l)){if(r.e<u&&--l,"9999"!=(t=t.slice(l-3,l+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(k(r,r.e+d+2,1),e=!r.times(r).eq(s));break}if(!i&&(k(o,o.e+d+2,0),o.times(o).eq(s))){r=o;break}c+=4,l+=4,i=1}return k(r,r.e+d+1,y,e)},p.toExponential=function(e,t){return null!=e&&(he(e,0,ue),e++),T(this,e,t,1)},p.toFixed=function(e,t){return null!=e&&(he(e,0,ue),e=e+this.e+1),T(this,e,t)},p.toFormat=function(e,t,n){var r,i=this;if(null==n)null!=e&&t&&"object"==typeof t?(n=t,t=null):e&&"object"==typeof e?(n=e,e=t=null):n=P;else if("object"!=typeof n)throw Error(ne+"Argument not an object: "+n);if(r=i.toFixed(e,t),i.c){var o,s=r.split("."),a=+n.groupSize,l=+n.secondaryGroupSize,u=n.groupSeparator||"",c=s[0],f=s[1],p=i.s<0,h=p?c.slice(1):c,d=h.length;if(l&&(o=a,a=l,l=o,d-=o),a>0&&d>0){for(o=d%a||a,c=h.substr(0,o);o<d;o+=a)c+=u+h.substr(o,a);l>0&&(c+=u+h.slice(o)),p&&(c="-"+c)}r=f?c+(n.decimalSeparator||"")+((l=+n.fractionGroupSize)?f.replace(new RegExp("\\d{"+l+"}\\B","g"),"$&"+(n.fractionGroupSeparator||"")):f):c}return(n.prefix||"")+r+(n.suffix||"")},p.toFraction=function(e){var t,r,i,o,s,a,l,u,c,f,p,d,g=this,m=g.c;if(null!=e&&(!(l=new _(e)).isInteger()&&(l.c||1!==l.s)||l.lt(h)))throw Error(ne+"Argument "+(l.isInteger()?"out of range: ":"not an integer: ")+M(l));if(!m)return new _(g);for(t=new _(h),c=r=new _(h),i=u=new _(h),d=fe(m),s=t.e=d.length-g.e-1,t.c[0]=ae[(a=s%oe)<0?oe+a:a],e=!e||l.comparedTo(t)>0?s>0?t:c:l,a=b,b=1/0,l=new _(d),u.c[0]=0;f=n(l,t,0,1),1!=(o=r.plus(f.times(i))).comparedTo(e);)r=i,i=o,c=u.plus(f.times(o=c)),u=o,t=l.minus(f.times(o=t)),l=o;return o=n(e.minus(r),i,0,1),u=u.plus(o.times(c)),r=r.plus(o.times(i)),u.s=c.s=g.s,p=n(c,i,s*=2,y).minus(g).abs().comparedTo(n(u,r,s,y).minus(g).abs())<1?[c,i]:[u,r],b=a,p},p.toNumber=function(){return+M(this)},p.toPrecision=function(e,t){return null!=e&&he(e,1,ue),T(this,e,t,2)},p.toString=function(e){var t,n=this,i=n.s,o=n.e;return null===o?i?(t="Infinity",i<0&&(t="-"+t)):t="NaN":(null==e?t=o<=g||o>=m?ye(fe(n.c),o):ge(fe(n.c),o,"0"):10===e&&O?t=ge(fe((n=k(new _(n),d+o+1,y)).c),n.e,"0"):(he(e,2,x.length,"Base"),t=r(ge(fe(n.c),o,"0"),10,e,i,!0)),i<0&&n.c[0]&&(t="-"+t)),t},p.valueOf=p.toJSON=function(){return M(this)},p._isBigNumber=!0,p[Symbol.toStringTag]="BigNumber",p[Symbol.for("nodejs.util.inspect.custom")]=p.valueOf,null!=t&&_.set(t),_}();const ve=me;var be=class{key;left=null;right=null;constructor(e){this.key=e}},Ee=class extends be{constructor(e){super(e)}},we=class{size=0;modificationCount=0;splayCount=0;splay(e){const t=this.root;if(null==t)return this.compare(e,e),-1;let n=null,r=null,i=null,o=null,s=t;const a=this.compare;let l;for(;;)if(l=a(s.key,e),l>0){let t=s.left;if(null==t)break;if(l=a(t.key,e),l>0&&(s.left=t.right,t.right=s,s=t,t=s.left,null==t))break;null==n?r=s:n.left=s,n=s,s=t}else{if(!(l<0))break;{let t=s.right;if(null==t)break;if(l=a(t.key,e),l<0&&(s.right=t.left,t.left=s,s=t,t=s.right,null==t))break;null==i?o=s:i.right=s,i=s,s=t}}return null!=i&&(i.right=s.left,s.left=o),null!=n&&(n.left=s.right,s.right=r),this.root!==s&&(this.root=s,this.splayCount++),l}splayMin(e){let t=e,n=t.left;for(;null!=n;){const e=n;t.left=e.right,e.right=t,t=e,n=t.left}return t}splayMax(e){let t=e,n=t.right;for(;null!=n;){const e=n;t.right=e.left,e.left=t,t=e,n=t.right}return t}_delete(e){if(null==this.root)return null;if(0!=this.splay(e))return null;let t=this.root;const n=t,r=t.left;if(this.size--,null==r)this.root=t.right;else{const e=t.right;t=this.splayMax(r),t.right=e,this.root=t}return this.modificationCount++,n}addNewRoot(e,t){this.size++,this.modificationCount++;const n=this.root;null!=n?(t<0?(e.left=n,e.right=n.right,n.right=null):(e.right=n,e.left=n.left,n.left=null),this.root=e):this.root=e}_first(){const e=this.root;return null==e?null:(this.root=this.splayMin(e),this.root)}_last(){const e=this.root;return null==e?null:(this.root=this.splayMax(e),this.root)}clear(){this.root=null,this.size=0,this.modificationCount++}has(e){return this.validKey(e)&&0==this.splay(e)}defaultCompare(){return(e,t)=>e<t?-1:e>t?1:0}wrap(){return{getRoot:()=>this.root,setRoot:e=>{this.root=e},getSize:()=>this.size,getModificationCount:()=>this.modificationCount,getSplayCount:()=>this.splayCount,setSplayCount:e=>{this.splayCount=e},splay:e=>this.splay(e),has:e=>this.has(e)}}},Se=(Symbol.iterator,Symbol.toStringTag,class e extends we{root=null;compare;validKey;constructor(e,t){super(),this.compare=e??this.defaultCompare(),this.validKey=t??(e=>null!=e&&null!=e)}delete(e){return!!this.validKey(e)&&null!=this._delete(e)}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){const t=this[Symbol.iterator]();let n;for(;n=t.next(),!n.done;)e(n.value,n.value,this)}add(e){const t=this.splay(e);return 0!=t&&this.addNewRoot(new Ee(e),t),this}addAndReturn(e){const t=this.splay(e);return 0!=t&&this.addNewRoot(new Ee(e),t),this.root.key}addAll(e){for(const t of e)this.add(t)}isEmpty(){return null==this.root}isNotEmpty(){return null!=this.root}single(){if(0==this.size)throw"Bad state: No element";if(this.size>1)throw"Bad state: Too many element";return this.root.key}first(){if(0==this.size)throw"Bad state: No element";return this._first().key}last(){if(0==this.size)throw"Bad state: No element";return this._last().key}lastBefore(e){if(null==e)throw"Invalid arguments(s)";if(null==this.root)return null;if(this.splay(e)<0)return this.root.key;let t=this.root.left;if(null==t)return null;let n=t.right;for(;null!=n;)t=n,n=t.right;return t.key}firstAfter(e){if(null==e)throw"Invalid arguments(s)";if(null==this.root)return null;if(this.splay(e)>0)return this.root.key;let t=this.root.right;if(null==t)return null;let n=t.left;for(;null!=n;)t=n,n=t.left;return t.key}retainAll(t){const n=new e(this.compare,this.validKey),r=this.modificationCount;for(const e of t){if(r!=this.modificationCount)throw"Concurrent modification during iteration.";this.validKey(e)&&0==this.splay(e)&&n.add(this.root.key)}n.size!=this.size&&(this.root=n.root,this.size=n.size,this.modificationCount++)}lookup(e){return this.validKey(e)?0!=this.splay(e)?null:this.root.key:null}intersection(t){const n=new e(this.compare,this.validKey);for(const e of this)t.has(e)&&n.add(e);return n}difference(t){const n=new e(this.compare,this.validKey);for(const e of this)t.has(e)||n.add(e);return n}union(e){const t=this.clone();return t.addAll(e),t}clone(){const t=new e(this.compare,this.validKey);return t.size=this.size,t.root=this.copyNode(this.root),t}copyNode(e){if(null==e)return null;const t=new Ee(e.key);return function e(t,n){let r,i;do{if(r=t.left,i=t.right,null!=r){const t=new Ee(r.key);n.left=t,e(r,t)}if(null!=i){const e=new Ee(i.key);n.right=e,t=i,n=e}}while(null!=i)}(e,t),t}toSet(){return this.clone()}entries(){return new Oe(this.wrap())}keys(){return this[Symbol.iterator]()}values(){return this[Symbol.iterator]()}[Symbol.iterator](){return new xe(this.wrap())}[Symbol.toStringTag]="[object Set]"}),Pe=class{tree;path=new Array;modificationCount=null;splayCount;constructor(e){this.tree=e,this.splayCount=e.getSplayCount()}[Symbol.iterator](){return this}next(){return this.moveNext()?{done:!1,value:this.current()}:{done:!0,value:null}}current(){if(!this.path.length)return null;const e=this.path[this.path.length-1];return this.getValue(e)}rebuildPath(e){this.path.splice(0,this.path.length),this.tree.splay(e),this.path.push(this.tree.getRoot()),this.splayCount=this.tree.getSplayCount()}findLeftMostDescendent(e){for(;null!=e;)this.path.push(e),e=e.left}moveNext(){if(this.modificationCount!=this.tree.getModificationCount()){if(null==this.modificationCount){this.modificationCount=this.tree.getModificationCount();let e=this.tree.getRoot();for(;null!=e;)this.path.push(e),e=e.left;return this.path.length>0}throw"Concurrent modification during iteration."}if(!this.path.length)return!1;this.splayCount!=this.tree.getSplayCount()&&this.rebuildPath(this.path[this.path.length-1].key);let e=this.path[this.path.length-1],t=e.right;if(null!=t){for(;null!=t;)this.path.push(t),t=t.left;return!0}for(this.path.pop();this.path.length&&this.path[this.path.length-1].right===e;)e=this.path.pop();return this.path.length>0}},xe=class extends Pe{getValue(e){return e.key}},Oe=class extends Pe{getValue(e){return[e.key,e.key]}},_e=e=>()=>e,Te=e=>{const t=e?(t,n)=>n.minus(t).abs().isLessThanOrEqualTo(e):_e(!1);return(e,n)=>t(e,n)?0:e.comparedTo(n)};function Ae(e){const t=e?(t,n,r,i,o)=>t.exponentiatedBy(2).isLessThanOrEqualTo(i.minus(n).exponentiatedBy(2).plus(o.minus(r).exponentiatedBy(2)).times(e)):_e(!1);return(e,n,r)=>{const i=e.x,o=e.y,s=r.x,a=r.y,l=o.minus(a).times(n.x.minus(s)).minus(i.minus(s).times(n.y.minus(a)));return t(l,i,o,s,a)?0:l.comparedTo(0)}}var Ce=e=>e,ke=e=>{if(e){const t=new Se(Te(e)),n=new Se(Te(e)),r=(e,t)=>t.addAndReturn(e),i=e=>({x:r(e.x,t),y:r(e.y,n)});return i({x:new ve(0),y:new ve(0)}),i}return Ce},Me=e=>({set:e=>{Ie=Me(e)},reset:()=>Me(e),compare:Te(e),snap:ke(e),orient:Ae(e)}),Ie=Me(),Le=(e,t)=>e.ll.x.isLessThanOrEqualTo(t.x)&&t.x.isLessThanOrEqualTo(e.ur.x)&&e.ll.y.isLessThanOrEqualTo(t.y)&&t.y.isLessThanOrEqualTo(e.ur.y),Re=(e,t)=>{if(t.ur.x.isLessThan(e.ll.x)||e.ur.x.isLessThan(t.ll.x)||t.ur.y.isLessThan(e.ll.y)||e.ur.y.isLessThan(t.ll.y))return null;const n=e.ll.x.isLessThan(t.ll.x)?t.ll.x:e.ll.x,r=e.ur.x.isLessThan(t.ur.x)?e.ur.x:t.ur.x;return{ll:{x:n,y:e.ll.y.isLessThan(t.ll.y)?t.ll.y:e.ll.y},ur:{x:r,y:e.ur.y.isLessThan(t.ur.y)?e.ur.y:t.ur.y}}},Ne=(e,t)=>e.x.times(t.y).minus(e.y.times(t.x)),je=(e,t)=>e.x.times(t.x).plus(e.y.times(t.y)),De=e=>je(e,e).sqrt(),Ge=(e,t,n)=>{const r={x:t.x.minus(e.x),y:t.y.minus(e.y)},i={x:n.x.minus(e.x),y:n.y.minus(e.y)};return Ne(i,r).div(De(i)).div(De(r))},Fe=(e,t,n)=>{const r={x:t.x.minus(e.x),y:t.y.minus(e.y)},i={x:n.x.minus(e.x),y:n.y.minus(e.y)};return je(i,r).div(De(i)).div(De(r))},Ve=(e,t,n)=>t.y.isZero()?null:{x:e.x.plus(t.x.div(t.y).times(n.minus(e.y))),y:n},Be=(e,t,n)=>t.x.isZero()?null:{x:n,y:e.y.plus(t.y.div(t.x).times(n.minus(e.x)))},Ue=class e{point;isLeft;segment;otherSE;consumedBy;static compare(t,n){const r=e.comparePoints(t.point,n.point);return 0!==r?r:(t.point!==n.point&&t.link(n),t.isLeft!==n.isLeft?t.isLeft?1:-1:Ke.compare(t.segment,n.segment))}static comparePoints(e,t){return e.x.isLessThan(t.x)?-1:e.x.isGreaterThan(t.x)?1:e.y.isLessThan(t.y)?-1:e.y.isGreaterThan(t.y)?1:0}constructor(e,t){void 0===e.events?e.events=[this]:e.events.push(this),this.point=e,this.isLeft=t}link(e){if(e.point===this.point)throw new Error("Tried to link already linked events");const t=e.point.events;for(let e=0,n=t.length;e<n;e++){const n=t[e];this.point.events.push(n),n.point=this.point}this.checkForConsuming()}checkForConsuming(){const e=this.point.events.length;for(let t=0;t<e;t++){const n=this.point.events[t];if(void 0===n.segment.consumedBy)for(let r=t+1;r<e;r++){const e=this.point.events[r];void 0===e.consumedBy&&n.otherSE.point.events===e.otherSE.point.events&&n.segment.consume(e.segment)}}}getAvailableLinkedEvents(){const e=[];for(let t=0,n=this.point.events.length;t<n;t++){const n=this.point.events[t];n!==this&&!n.segment.ringOut&&n.segment.isInResult()&&e.push(n)}return e}getLeftmostComparator(e){const t=new Map,n=n=>{const r=n.otherSE;t.set(n,{sine:Ge(this.point,e.point,r.point),cosine:Fe(this.point,e.point,r.point)})};return(e,r)=>{t.has(e)||n(e),t.has(r)||n(r);const{sine:i,cosine:o}=t.get(e),{sine:s,cosine:a}=t.get(r);return i.isGreaterThanOrEqualTo(0)&&s.isGreaterThanOrEqualTo(0)?o.isLessThan(a)?1:o.isGreaterThan(a)?-1:0:i.isLessThan(0)&&s.isLessThan(0)?o.isLessThan(a)?-1:o.isGreaterThan(a)?1:0:s.isLessThan(i)?-1:s.isGreaterThan(i)?1:0}}},He=class e{events;poly;_isExteriorRing;_enclosingRing;static factory(t){const n=[];for(let r=0,i=t.length;r<i;r++){const i=t[r];if(!i.isInResult()||i.ringOut)continue;let o=null,s=i.leftSE,a=i.rightSE;const l=[s],u=s.point,c=[];for(;o=s,s=a,l.push(s),s.point!==u;)for(;;){const t=s.getAvailableLinkedEvents();if(0===t.length){const e=l[0].point,t=l[l.length-1].point;throw new Error(`Unable to complete output ring starting at [${e.x}, ${e.y}]. Last matching segment found ends at [${t.x}, ${t.y}].`)}if(1===t.length){a=t[0].otherSE;break}let r=null;for(let e=0,t=c.length;e<t;e++)if(c[e].point===s.point){r=e;break}if(null!==r){const t=c.splice(r)[0],i=l.splice(t.index);i.unshift(i[0].otherSE),n.push(new e(i.reverse()));continue}c.push({index:l.length,point:s.point});const i=s.getLeftmostComparator(o);a=t.sort(i)[0].otherSE;break}n.push(new e(l))}return n}constructor(e){this.events=e;for(let t=0,n=e.length;t<n;t++)e[t].segment.ringOut=this;this.poly=null}getGeom(){let e=this.events[0].point;const t=[e];for(let n=1,r=this.events.length-1;n<r;n++){const r=this.events[n].point,i=this.events[n+1].point;0!==Ie.orient(r,e,i)&&(t.push(r),e=r)}if(1===t.length)return null;const n=t[0],r=t[1];0===Ie.orient(n,e,r)&&t.shift(),t.push(t[0]);const i=this.isExteriorRing()?1:-1,o=this.isExteriorRing()?0:t.length-1,s=this.isExteriorRing()?t.length:-1,a=[];for(let e=o;e!=s;e+=i)a.push([t[e].x.toNumber(),t[e].y.toNumber()]);return a}isExteriorRing(){if(void 0===this._isExteriorRing){const e=this.enclosingRing();this._isExteriorRing=!e||!e.isExteriorRing()}return this._isExteriorRing}enclosingRing(){return void 0===this._enclosingRing&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}_calcEnclosingRing(){let e=this.events[0];for(let t=1,n=this.events.length;t<n;t++){const n=this.events[t];Ue.compare(e,n)>0&&(e=n)}let t=e.segment.prevInResult(),n=t?t.prevInResult():null;for(;;){if(!t)return null;if(!n)return t.ringOut;if(n.ringOut!==t.ringOut)return n.ringOut?.enclosingRing()!==t.ringOut?t.ringOut:t.ringOut?.enclosingRing();t=n.prevInResult(),n=t?t.prevInResult():null}}},qe=class{exteriorRing;interiorRings;constructor(e){this.exteriorRing=e,e.poly=this,this.interiorRings=[]}addInterior(e){this.interiorRings.push(e),e.poly=this}getGeom(){const e=this.exteriorRing.getGeom();if(null===e)return null;const t=[e];for(let e=0,n=this.interiorRings.length;e<n;e++){const n=this.interiorRings[e].getGeom();null!==n&&t.push(n)}return t}},Ye=class{rings;polys;constructor(e){this.rings=e,this.polys=this._composePolys(e)}getGeom(){const e=[];for(let t=0,n=this.polys.length;t<n;t++){const n=this.polys[t].getGeom();null!==n&&e.push(n)}return e}_composePolys(e){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];if(!r.poly)if(r.isExteriorRing())t.push(new qe(r));else{const e=r.enclosingRing();e?.poly||t.push(new qe(e)),e?.poly?.addInterior(r)}}return t}},ze=class{queue;tree;segments;constructor(e,t=Ke.compare){this.queue=e,this.tree=new Se(t),this.segments=[]}process(e){const t=e.segment,n=[];if(e.consumedBy)return e.isLeft?this.queue.delete(e.otherSE):this.tree.delete(t),n;e.isLeft&&this.tree.add(t);let r=t,i=t;do{r=this.tree.lastBefore(r)}while(null!=r&&null!=r.consumedBy);do{i=this.tree.firstAfter(i)}while(null!=i&&null!=i.consumedBy);if(e.isLeft){let o=null;if(r){const e=r.getIntersection(t);if(null!==e&&(t.isAnEndpoint(e)||(o=e),!r.isAnEndpoint(e))){const t=this._splitSafely(r,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}}let s=null;if(i){const e=i.getIntersection(t);if(null!==e&&(t.isAnEndpoint(e)||(s=e),!i.isAnEndpoint(e))){const t=this._splitSafely(i,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}}if(null!==o||null!==s){let e=null;e=null===o?s:null===s||Ue.comparePoints(o,s)<=0?o:s,this.queue.delete(t.rightSE),n.push(t.rightSE);const r=t.split(e);for(let e=0,t=r.length;e<t;e++)n.push(r[e])}n.length>0?(this.tree.delete(t),n.push(e)):(this.segments.push(t),t.prev=r)}else{if(r&&i){const e=r.getIntersection(i);if(null!==e){if(!r.isAnEndpoint(e)){const t=this._splitSafely(r,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}if(!i.isAnEndpoint(e)){const t=this._splitSafely(i,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}}}this.tree.delete(t)}return n}_splitSafely(e,t){this.tree.delete(e);const n=e.rightSE;this.queue.delete(n);const r=e.split(t);return r.push(n),void 0===e.consumedBy&&this.tree.add(e),r}},We=new class{type;numMultiPolys;run(e,t,n){We.type=e;const r=[new Qe(t,!0)];for(let e=0,t=n.length;e<t;e++)r.push(new Qe(n[e],!1));if(We.numMultiPolys=r.length,"difference"===We.type){const e=r[0];let t=1;for(;t<r.length;)null!==Re(r[t].bbox,e.bbox)?t++:r.splice(t,1)}if("intersection"===We.type)for(let e=0,t=r.length;e<t;e++){const t=r[e];for(let n=e+1,i=r.length;n<i;n++)if(null===Re(t.bbox,r[n].bbox))return[]}const i=new Se(Ue.compare);for(let e=0,t=r.length;e<t;e++){const t=r[e].getSweepEvents();for(let e=0,n=t.length;e<n;e++)i.add(t[e])}const o=new ze(i);let s=null;for(0!=i.size&&(s=i.first(),i.delete(s));s;){const e=o.process(s);for(let t=0,n=e.length;t<n;t++){const n=e[t];void 0===n.consumedBy&&i.add(n)}0!=i.size?(s=i.first(),i.delete(s)):s=null}Ie.reset();const a=He.factory(o.segments);return new Ye(a).getGeom()}},$e=We,Xe=0,Ke=class e{id;leftSE;rightSE;rings;windings;ringOut;consumedBy;prev;_prevInResult;_beforeState;_afterState;_isInResult;static compare(e,t){const n=e.leftSE.point.x,r=t.leftSE.point.x,i=e.rightSE.point.x,o=t.rightSE.point.x;if(o.isLessThan(n))return 1;if(i.isLessThan(r))return-1;const s=e.leftSE.point.y,a=t.leftSE.point.y,l=e.rightSE.point.y,u=t.rightSE.point.y;if(n.isLessThan(r)){if(a.isLessThan(s)&&a.isLessThan(l))return 1;if(a.isGreaterThan(s)&&a.isGreaterThan(l))return-1;const n=e.comparePoint(t.leftSE.point);if(n<0)return 1;if(n>0)return-1;const r=t.comparePoint(e.rightSE.point);return 0!==r?r:-1}if(n.isGreaterThan(r)){if(s.isLessThan(a)&&s.isLessThan(u))return-1;if(s.isGreaterThan(a)&&s.isGreaterThan(u))return 1;const n=t.comparePoint(e.leftSE.point);if(0!==n)return n;const r=e.comparePoint(t.rightSE.point);return r<0?1:r>0?-1:1}if(s.isLessThan(a))return-1;if(s.isGreaterThan(a))return 1;if(i.isLessThan(o)){const n=t.comparePoint(e.rightSE.point);if(0!==n)return n}if(i.isGreaterThan(o)){const n=e.comparePoint(t.rightSE.point);if(n<0)return 1;if(n>0)return-1}if(!i.eq(o)){const e=l.minus(s),t=i.minus(n),c=u.minus(a),f=o.minus(r);if(e.isGreaterThan(t)&&c.isLessThan(f))return 1;if(e.isLessThan(t)&&c.isGreaterThan(f))return-1}return i.isGreaterThan(o)?1:i.isLessThan(o)||l.isLessThan(u)?-1:l.isGreaterThan(u)?1:e.id<t.id?-1:e.id>t.id?1:0}constructor(e,t,n,r){this.id=++Xe,this.leftSE=e,e.segment=this,e.otherSE=t,this.rightSE=t,t.segment=this,t.otherSE=e,this.rings=n,this.windings=r}static fromRing(t,n,r){let i,o,s;const a=Ue.comparePoints(t,n);if(a<0)i=t,o=n,s=1;else{if(!(a>0))throw new Error(`Tried to create degenerate segment at [${t.x}, ${t.y}]`);i=n,o=t,s=-1}const l=new Ue(i,!0),u=new Ue(o,!1);return new e(l,u,[r],[s])}replaceRightSE(e){this.rightSE=e,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){const e=this.leftSE.point.y,t=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:e.isLessThan(t)?e:t},ur:{x:this.rightSE.point.x,y:e.isGreaterThan(t)?e:t}}}vector(){return{x:this.rightSE.point.x.minus(this.leftSE.point.x),y:this.rightSE.point.y.minus(this.leftSE.point.y)}}isAnEndpoint(e){return e.x.eq(this.leftSE.point.x)&&e.y.eq(this.leftSE.point.y)||e.x.eq(this.rightSE.point.x)&&e.y.eq(this.rightSE.point.y)}comparePoint(e){return Ie.orient(this.leftSE.point,e,this.rightSE.point)}getIntersection(e){const t=this.bbox(),n=e.bbox(),r=Re(t,n);if(null===r)return null;const i=this.leftSE.point,o=this.rightSE.point,s=e.leftSE.point,a=e.rightSE.point,l=Le(t,s)&&0===this.comparePoint(s),u=Le(n,i)&&0===e.comparePoint(i),c=Le(t,a)&&0===this.comparePoint(a),f=Le(n,o)&&0===e.comparePoint(o);if(u&&l)return f&&!c?o:!f&&c?a:null;if(u)return c&&i.x.eq(a.x)&&i.y.eq(a.y)?null:i;if(l)return f&&o.x.eq(s.x)&&o.y.eq(s.y)?null:s;if(f&&c)return null;if(f)return o;if(c)return a;const p=((e,t,n,r)=>{if(t.x.isZero())return Be(n,r,e.x);if(r.x.isZero())return Be(e,t,n.x);if(t.y.isZero())return Ve(n,r,e.y);if(r.y.isZero())return Ve(e,t,n.y);const i=Ne(t,r);if(i.isZero())return null;const o={x:n.x.minus(e.x),y:n.y.minus(e.y)},s=Ne(o,t).div(i),a=Ne(o,r).div(i),l=e.x.plus(a.times(t.x)),u=n.x.plus(s.times(r.x)),c=e.y.plus(a.times(t.y)),f=n.y.plus(s.times(r.y));return{x:l.plus(u).div(2),y:c.plus(f).div(2)}})(i,this.vector(),s,e.vector());return null===p?null:Le(r,p)?Ie.snap(p):null}split(t){const n=[],r=void 0!==t.events,i=new Ue(t,!0),o=new Ue(t,!1),s=this.rightSE;this.replaceRightSE(o),n.push(o),n.push(i);const a=new e(i,s,this.rings.slice(),this.windings.slice());return Ue.comparePoints(a.leftSE.point,a.rightSE.point)>0&&a.swapEvents(),Ue.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),r&&(i.checkForConsuming(),o.checkForConsuming()),n}swapEvents(){const e=this.rightSE;this.rightSE=this.leftSE,this.leftSE=e,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let e=0,t=this.windings.length;e<t;e++)this.windings[e]*=-1}consume(t){let n=this,r=t;for(;n.consumedBy;)n=n.consumedBy;for(;r.consumedBy;)r=r.consumedBy;const i=e.compare(n,r);if(0!==i){if(i>0){const e=n;n=r,r=e}if(n.prev===r){const e=n;n=r,r=e}for(let e=0,t=r.rings.length;e<t;e++){const t=r.rings[e],i=r.windings[e],o=n.rings.indexOf(t);-1===o?(n.rings.push(t),n.windings.push(i)):n.windings[o]+=i}r.rings=null,r.windings=null,r.consumedBy=n,r.leftSE.consumedBy=n.leftSE,r.rightSE.consumedBy=n.rightSE}}prevInResult(){return void 0!==this._prevInResult||(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null),this._prevInResult}beforeState(){if(void 0!==this._beforeState)return this._beforeState;if(this.prev){const e=this.prev.consumedBy||this.prev;this._beforeState=e.afterState()}else this._beforeState={rings:[],windings:[],multiPolys:[]};return this._beforeState}afterState(){if(void 0!==this._afterState)return this._afterState;const e=this.beforeState();this._afterState={rings:e.rings.slice(0),windings:e.windings.slice(0),multiPolys:[]};const t=this._afterState.rings,n=this._afterState.windings,r=this._afterState.multiPolys;for(let e=0,r=this.rings.length;e<r;e++){const r=this.rings[e],i=this.windings[e],o=t.indexOf(r);-1===o?(t.push(r),n.push(i)):n[o]+=i}const i=[],o=[];for(let e=0,r=t.length;e<r;e++){if(0===n[e])continue;const r=t[e],s=r.poly;if(-1===o.indexOf(s))if(r.isExterior)i.push(s);else{-1===o.indexOf(s)&&o.push(s);const e=i.indexOf(r.poly);-1!==e&&i.splice(e,1)}}for(let e=0,t=i.length;e<t;e++){const t=i[e].multiPoly;-1===r.indexOf(t)&&r.push(t)}return this._afterState}isInResult(){if(this.consumedBy)return!1;if(void 0!==this._isInResult)return this._isInResult;const e=this.beforeState().multiPolys,t=this.afterState().multiPolys;switch($e.type){case"union":{const n=0===e.length,r=0===t.length;this._isInResult=n!==r;break}case"intersection":{let n,r;e.length<t.length?(n=e.length,r=t.length):(n=t.length,r=e.length),this._isInResult=r===$e.numMultiPolys&&n<r;break}case"xor":{const n=Math.abs(e.length-t.length);this._isInResult=n%2==1;break}case"difference":{const n=e=>1===e.length&&e[0].isSubject;this._isInResult=n(e)!==n(t);break}}return this._isInResult}},Ze=class{poly;isExterior;segments;bbox;constructor(e,t,n){if(!Array.isArray(e)||0===e.length)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=t,this.isExterior=n,this.segments=[],"number"!=typeof e[0][0]||"number"!=typeof e[0][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const r=Ie.snap({x:new ve(e[0][0]),y:new ve(e[0][1])});this.bbox={ll:{x:r.x,y:r.y},ur:{x:r.x,y:r.y}};let i=r;for(let t=1,n=e.length;t<n;t++){if("number"!=typeof e[t][0]||"number"!=typeof e[t][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const n=Ie.snap({x:new ve(e[t][0]),y:new ve(e[t][1])});n.x.eq(i.x)&&n.y.eq(i.y)||(this.segments.push(Ke.fromRing(i,n,this)),n.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=n.x),n.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=n.y),n.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=n.x),n.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=n.y),i=n)}r.x.eq(i.x)&&r.y.eq(i.y)||this.segments.push(Ke.fromRing(i,r,this))}getSweepEvents(){const e=[];for(let t=0,n=this.segments.length;t<n;t++){const n=this.segments[t];e.push(n.leftSE),e.push(n.rightSE)}return e}},Je=class{multiPoly;exteriorRing;interiorRings;bbox;constructor(e,t){if(!Array.isArray(e))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new Ze(e[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(let t=1,n=e.length;t<n;t++){const n=new Ze(e[t],this,!1);n.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=n.bbox.ll.x),n.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=n.bbox.ll.y),n.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=n.bbox.ur.x),n.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=n.bbox.ur.y),this.interiorRings.push(n)}this.multiPoly=t}getSweepEvents(){const e=this.exteriorRing.getSweepEvents();for(let t=0,n=this.interiorRings.length;t<n;t++){const n=this.interiorRings[t].getSweepEvents();for(let t=0,r=n.length;t<r;t++)e.push(n[t])}return e}},Qe=class{isSubject;polys;bbox;constructor(e,t){if(!Array.isArray(e))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{"number"==typeof e[0][0][0]&&(e=[e])}catch(e){}this.polys=[],this.bbox={ll:{x:new ve(Number.POSITIVE_INFINITY),y:new ve(Number.POSITIVE_INFINITY)},ur:{x:new ve(Number.NEGATIVE_INFINITY),y:new ve(Number.NEGATIVE_INFINITY)}};for(let t=0,n=e.length;t<n;t++){const n=new Je(e[t],this);n.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=n.bbox.ll.x),n.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=n.bbox.ll.y),n.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=n.bbox.ur.x),n.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=n.bbox.ur.y),this.polys.push(n)}this.isSubject=t}getSweepEvents(){const e=[];for(let t=0,n=this.polys.length;t<n;t++){const n=this.polys[t].getSweepEvents();for(let t=0,r=n.length;t<r;t++)e.push(n[t])}return e}};Ie.set;function et(e,t,n={}){const r={type:"Feature"};return(0===n.id||n.id)&&(r.id=n.id),n.bbox&&(r.bbox=n.bbox),r.properties=t||{},r.geometry=e,r}Math.PI;var tt=function(e,t={}){const n=[];if(function(e,t){var n,r,i,o,s,a,l,u,c,f,p=0,h="FeatureCollection"===e.type,d="Feature"===e.type,y=h?e.features.length:1;for(n=0;n<y;n++){for(a=h?e.features[n].geometry:d?e.geometry:e,u=h?e.features[n].properties:d?e.properties:{},c=h?e.features[n].bbox:d?e.bbox:void 0,f=h?e.features[n].id:d?e.id:void 0,s=(l=!!a&&"GeometryCollection"===a.type)?a.geometries.length:1,i=0;i<s;i++)if(null!==(o=l?a.geometries[i]:a))switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(o,p,u,c,f))return!1;break;case"GeometryCollection":for(r=0;r<o.geometries.length;r++)if(!1===t(o.geometries[r],p,u,c,f))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,u,c,f))return!1;p++}}(e,e=>{n.push(e.coordinates)}),n.length<2)throw new Error("Must have at least 2 geometries");const r=((e,...t)=>$e.run("union",e,t))(n[0],...n.slice(1));return 0===r.length?null:1===r.length?function(e,t,n={}){for(const t of e){if(t.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(t[t.length-1].length!==t[0].length)throw new Error("First and last Position are not equivalent.");for(let e=0;e<t[t.length-1].length;e++)if(t[t.length-1][e]!==t[0][e])throw new Error("First and last Position are not equivalent.")}return et({type:"Polygon",coordinates:e},t,n)}(r[0],t.properties):function(e,t,n={}){return et({type:"MultiPolygon",coordinates:e},t,n)}(r,t.properties)},nt=n(278);function rt(e){return rt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},rt(e)}function it(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,s,a=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(e){u=!0,i=e}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw i}}return a}}(e,t)||ut(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ot(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function st(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ot(Object(n),!0).forEach(function(t){at(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ot(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function at(e,t,n){return(t=function(e){var t=function(e){if("object"!=rt(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=rt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==rt(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function lt(e){return function(e){if(Array.isArray(e))return ct(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||ut(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ut(e,t){if(e){if("string"==typeof e)return ct(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ct(e,t):void 0}}function ct(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var ft=function(e,t){var n,r,i,o,s=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.01,n=e.geometry.coordinates.map(function(e){return lt(e)}),r=n.length-1,i=function(e,n){return[e[0]+(e[0]-n[0])*t,e[1]+(e[1]-n[1])*t]},o=i(n[0],n[1]),s=i(n[r],n[r-1]);return n[0]=o,n[r]=s,(0,nt.wi)(n)}(t);try{o=function(e,t){var n=[],r=[],i=[],o=function(e,t,n,r,i){for(var o=0,s=[],a="Feature"===t.type?t.geometry:t,l="LineString"===a.type?[a.coordinates]:a.coordinates,u=0,c=0;c<l.length;c++){for(var f=l[c].length-1,p=new D(l[c][0]),h=null,d={nextEdge:null},y=0;y<f;y++){h=new D(l[c][y+1]),p.nextPoint=h,h.prevPoint=p;var g=new j(p,h,"polyline",u,null);r.push(g),d.nextEdge=g,g.prevEdge=d,i[0]=Math.min(i[0],p.p[0]),i[1]=Math.min(i[1],p.p[1]),i[2]=Math.max(i[2],p.p[0]),i[3]=Math.max(i[3],p.p[1]),p=h,u+=1,d=g}i[0]=Math.min(i[0],l[c][f][0]),i[1]=Math.min(i[1],l[c][f][1]),i[2]=Math.max(i[2],l[c][f][0]),i[3]=Math.max(i[3],l[c][f][1])}for(var m="Feature"===e.type?e.geometry:e,v="Polygon"===m.type?[m.coordinates]:m.coordinates,b=v.length,E=0;E<b;E++)for(var w=v[E].length,S=0;S<w;S++){o+=1;var P=v[E][S],x=P.length;s.push(new G(o,P));for(var O=new D(P[0]),_=O,T=void 0,A=null,C={nextEdge:null,prevEdge:null},k=null,M=1;M<x;M++)T=new D(P[M]),_.nextPoint=T,T.prevPoint=_,A=new j(_,T,"polygon",u,o),C.nextEdge=A,A.prevEdge=C,1===M&&(k=A),S>0&&(A.interiorRing=!0),A.intersectPolylineBbox=F(A,i),n.push(A),_=T,u+=1,C=A;A.nextEdge=k,k.prevEdge=A,T.nextPoint=O.nextPoint,O.prevPoint=T.prevPoint}return s}(d(e),t,r,i,[1/0,1/0,1/0,1/0]);if(function(e,t,n){var r,i,o,s=t.length,a=e.length;for(r=0;r<s;r++){var l=t[r];for(i=0;i<a;i++){var u=e[i];if(u.intersectPolylineBbox&&!(u.maxX<l.minX||u.minX>l.maxX||u.maxY<l.minY||u.minY>l.maxY)){var c=Y(l,u);if(null!==c)for(o=0;o<c.length;o++){var f=N(u.p1.p[0],u.p1.p[1],u.p2.p[0],u.p2.p[1],l.p1.p[0],l.p1.p[1]),p=new V(c[o],l,u,f>0);n.push(p)}}}}t.forEach(function(e){e.intersectionPoints.sort(function(e,t){return e.distanceFromPolylineEdgeStart-t.distanceFromPolylineEdgeStart})}),e.forEach(function(e){e.intersectionPoints.sort(function(e,t){return e.distanceFromPolygonEdgeStart-t.distanceFromPolygonEdgeStart})})}(r,i,n),0===n.length)return e;var s={};o.forEach(function(e){return s[e.id]=0}),n.forEach(function(e){var t=e.polygonEdge.polygonContourId;s[t]=s[t]+1});for(var a=0,l=[],u=null,c=0;c<i.length;c++){var f=i[c];if(f.intersectionPoints.length>0){u=f.intersectionPoints[0];break}}for(var p=u,h={visitCount:1};u!==h&&!(a>2*n.length);){if(a=a++,h.visitCount>=2){for(var y=!1,g=0;g<n.length;g++){var m=n[g];if(m.visitCount<2){p=m,y=!0;break}}if(!y)break}p.visitCount=p.visitCount+1;var v=[];l.push(v),v.push(p.p),p.visitCount=p.visitCount+1;var b=X(p,v),E=!1;if(b===(h=b)&&2===n.length)for(var w=0;w<n.length;w++)n[w].visitCount<2&&(E=!0);for(;b!==p||E;)(b=(b.isHeadingIn?J:Z)(b,v))!==p&&(b=X(b,v)),E=!1;if(h.visitCount>=2){for(var S=!1,P=0;P<n.length;P++){var x=n[P];if(x.visitCount<2){p=x,S=!0;break}}S&&(h=p)}p=h}for(var O=l.map(function(e){return[e]}),_=Object.keys(s),T=0;T<_.length;T++){var A=_[T];0===s[A]&&$(W(z(r,parseInt(A)),o),O)}return{type:"Feature",properties:{},geometry:{type:"MultiPolygon",coordinates:O}}}(e,s)}catch(e){return null}var a=[];if("MultiPolygon"!==o.geometry.type)return null;if(2!==o.geometry.coordinates.length)return null;a=o.geometry.coordinates.map(function(t){return(0,nt.n1)(t,e.properties)});var l=null!==(n=null!==(r=e.id)&&void 0!==r?r:null===(i=e.properties)||void 0===i?void 0:i.id)&&void 0!==n?n:"poly",u=a.map(function(t,n){return(0,nt.n1)(t.geometry.coordinates,st(st({},e.properties),{},{id:l}),{id:"".concat(l,"-").concat(n+1)})});return(0,nt.Lr)(u)},pt=function(e){var t,n,r,i,o;try{o=tt((0,nt.Lr)(e))}catch(e){return null}if("Polygon"!==(null===(t=o)||void 0===t||null===(t=t.geometry)||void 0===t?void 0:t.type))return null;var s=null!==(n=null!==(r=e[0].id)&&void 0!==r?r:null===(i=e[0].properties)||void 0===i?void 0:i.id)&&void 0!==n?n:"poly";return(0,nt.n1)(o.geometry.coordinates,st(st({},e[0].properties),{},{id:s}),{id:s})},ht=function(e,t){var n=it(e,2),r=n[0],i=n[1],o=it(t,2),s=o[0],a=o[1],l=function(e){return e*Math.PI/180},u=l(a-i),c=l(s-r),f=Math.pow(Math.sin(u/2),2)+Math.cos(l(i))*Math.cos(l(a))*Math.pow(Math.sin(c/2),2);return 12742e3*Math.atan2(Math.sqrt(f),Math.sqrt(1-f))},dt=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.01;if(e.length<=1)return!0;var n=e[e.length-1],r=e[e.length-2];return ht(n,r)>=t},yt=function(e){return e[0].length<=1||function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.01,n=e[0];return n.length<=1||!(n.length<=3&&function(e,t){for(var n=0;n<e.length;n++)for(var r=n+1;r<e.length;r++)if(ht(e[n],e[r])<t)return!0;return!1}(n,t))}(e)},gt=function(e,t,n){var r=t.filter(function(t){var r=Math.abs(t[0]-e[0]),i=Math.abs(t[1]-e[1]);return("ArrowUp"===n?t[1]<=e[1]&&i>=r:"ArrowDown"===n?t[1]>e[1]&&i>=r:"ArrowLeft"===n?t[0]<=e[0]&&i<r:"ArrowRight"!==n||t[0]>e[0]&&i<r)&&JSON.stringify(t)!==JSON.stringify(e)});r.length||r.push(e);var i=r.map(function(t){return n=Math.abs(e[0]-t[0]),r=Math.abs(e[1]-t[1]),Math.sqrt(Math.pow(n,2)+Math.pow(r,2));var n,r}),o=r[i.indexOf(Math.min.apply(Math,lt(i)))];return t.findIndex(function(e){return JSON.stringify(e)===JSON.stringify(o)})}},9(e,t,n){n.d(t,{Oo:()=>O,PI:()=>x,n8:()=>c,PH:()=>S,Nk:()=>P});var r=n(278),i=n(850);function o(e){let t=0;if(e&&e.length>0){t+=Math.abs(l(e[0]));for(let n=1;n<e.length;n++)t-=Math.abs(l(e[n]))}return t}var s=r.zX*r.zX/2,a=Math.PI/180;function l(e){const t=e.length-1;if(t<=2)return 0;let n=0,r=0;for(;r<t;){const i=e[r],o=e[r+1===t?0:r+1],s=e[r+2>=t?(r+2)%t:r+2],l=i[0]*a,u=o[1]*a;n+=(s[0]*a-l)*Math.sin(u),r++}return n*s}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var c={Polygon:3,LineString:2},f=function(e){var t;return null!==(t=null==e?void 0:e.geometry)&&void 0!==t?t:e},p=function(e){var t=f(e);return"Polygon"===(null==t?void 0:t.type)?t:null},h=function(e){for(var t,n,r=null!==(t=null===(n=e.coordinates)||void 0===n?void 0:n[0])&&void 0!==t?t:[],i=r.filter(function(e,t){return 0===t||e[0]!==r[t-1][0]||e[1]!==r[t-1][1]});i.length>1&&i[0][0]===i[i.length-1][0]&&i[0][1]===i[i.length-1][1];)i.pop();return i},d=function(e){return[].concat(function(e){if(Array.isArray(e))return u(e)}(t=e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e,t){if(e){if("string"==typeof e)return u(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),[e[0]]);var t},y=function(e,t,n){return(t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0])},g=function(e,t){return e>0&&t<0||e<0&&t>0},m=function(e,t,n,r){return 0===e&&function(e,t,n){return Math.min(e[0],n[0])<=t[0]&&t[0]<=Math.max(e[0],n[0])&&Math.min(e[1],n[1])<=t[1]&&t[1]<=Math.max(e[1],n[1])}(t,n,r)},v=function(e,t,n,r){var i=y(n,r,e),o=y(n,r,t),s=y(e,t,n),a=y(e,t,r);return!(!g(i,o)||!g(s,a))||m(i,n,e,r)||m(o,n,t,r)||m(s,e,n,t)||m(a,e,r,t)},b=function(e,t){for(var n=e.length,r=t?n:n-1,i=0;i<r;i++)for(var o=i+1;o<r;o++)if(!(o===i+1||t&&0===i&&o===r-1)&&v(e[i],e[(i+1)%n],e[o],e[(o+1)%n]))return!0;return!1},E=function(e){var t=p(e);if(!t)return{valid:!0};var n=h(t);return n.length<4?{valid:!0}:b(n,!0)?{valid:!1,reason:"Shape must not intersect itself"}:{valid:!0}},w=function(e){var t=p(e);if(!t)return{valid:!0};var n=h(t);if(n.length<c.Polygon)return{valid:!0};var r,s=0;try{r={type:"Feature",geometry:{type:"Polygon",coordinates:[d(n)]},properties:{}},s=(0,i.jE)(r,(e,t)=>e+function(e){let t,n=0;switch(e.type){case"Polygon":return o(e.coordinates);case"MultiPolygon":for(t=0;t<e.coordinates.length;t++)n+=o(e.coordinates[t]);return n;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}(t),0)}catch(e){return{valid:!0}}return s>0?{valid:!0}:{valid:!1,reason:"Shape must enclose an area"}},S={Polygon:"Shape needs at least 3 points",LineString:"Line needs at least 2 points"},P=[E,w,function(e){var t,n,r=f(e);return"Polygon"===(null==r?void 0:r.type)?h(r).length>=c.Polygon?{valid:!0}:{valid:!1,reason:S.Polygon}:"LineString"===(null==r?void 0:r.type)?(null!==(t=null===(n=r.coordinates)||void 0===n?void 0:n.length)&&void 0!==t?t:0)>=c.LineString?{valid:!0}:{valid:!1,reason:S.LineString}:{valid:!0}}],x=[E,w],O=[function(e){return function(e){var t=p(e);if(!t)return!1;var n=h(t);return!(n.length<4)&&b(n,!1)}(e)?{valid:!1,reason:"Shape must not intersect itself"}:{valid:!0}}]},520(e,t,n){n.d(t,{$U:()=>f,$b:()=>h,Uk:()=>d,dV:()=>p});var r=n(9);function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach(function(t){a(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function a(e,t,n){return(t=function(e){var t=function(e){if("object"!=i(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=i(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==i(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){if(e){if("string"==typeof e)return u(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var c=function(e){return void 0===e||!0===e?{valid:!0}:!1===e?{valid:!1,reason:null}:{valid:!1!==e.valid,reason:e.reason}},f=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=i.rules,a=void 0===o?r.Nk:o,u=i.onGeometryChange,f=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=l(e))){t&&(e=t);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,s=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return o=e.done,e},e:function(e){s=!0,i=e},f:function(){try{o||null==t.return||t.return()}finally{if(s)throw i}}}}(a);try{for(f.s();!(t=f.n()).done;){var p=t.value,h=c(p(e,n));if(!h.valid)return h}}catch(e){f.e(e)}finally{f.f()}return"function"==typeof u?c(u(s({feature:e},n))):{valid:!0}},p={Polygon:"draw_polygon",LineString:"draw_line"},h=function(e){var t,n=e.placed,i=e.point,o=e.geometryType,a=e.onGeometryChange,c=[].concat(function(e){if(Array.isArray(e))return u(e)}(t=n)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||l(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),[i]),h={type:"Feature",geometry:"Polygon"===o?{type:"Polygon",coordinates:[c]}:{type:"LineString",coordinates:c},properties:{}},d=p[o],y=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=n.rules,o=void 0===i?r.Oo:i,a=n.onGeometryChange;return f(e,s(s({},t),{},{phase:"place"}),{rules:o,onGeometryChange:a})}(h,{mode:d,vertexIndex:n.length},{onGeometryChange:a}),g=y.valid,m=y.reason;return g?{valid:!0}:{valid:!1,blocked:{feature:h,reason:null!=m?m:null,phase:"place",mode:d,vertexIndex:n.length}}},d=function(e){var t,n,i,o,a,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},c=u.rules,p=void 0===c?r.PI:c,h=u.onGeometryChange,d=null!==(t=null==e||null===(n=e.geometry)||void 0===n?void 0:n.type)&&void 0!==t?t:null==e?void 0:e.type,y=null!==(i=r.n8[d])&&void 0!==i?i:0,g=(null!==(o=l.numVertices)&&void 0!==o?o:0)<y?[]:p;return f(e,s(s({},l),{},{phase:null!==(a=l.phase)&&void 0!==a?a:"preview"}),{rules:g,onGeometryChange:h})}}}]);
2
+ "use strict";(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[568],{278(e,t,n){n.d(t,{Et:()=>h,Gf:()=>c,Lr:()=>u,n1:()=>s,nv:()=>f,tR:()=>p,wi:()=>l,zX:()=>r,zx:()=>a});var r=6371008.8,i={centimeters:100*r,centimetres:100*r,degrees:360/(2*Math.PI),feet:3.28084*r,inches:39.37*r,kilometers:r/1e3,kilometres:r/1e3,meters:r,metres:r,miles:r/1609.344,millimeters:1e3*r,millimetres:1e3*r,nauticalmiles:r/1852,radians:1,yards:1.0936*r};function o(e,t,n={}){const r={type:"Feature"};return(0===n.id||n.id)&&(r.id=n.id),n.bbox&&(r.bbox=n.bbox),r.properties=t||{},r.geometry=e,r}function a(e,t,n={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!h(e[0])||!h(e[1]))throw new Error("coordinates must contain numbers");return o({type:"Point",coordinates:e},t,n)}function s(e,t,n={}){for(const t of e){if(t.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(t[t.length-1].length!==t[0].length)throw new Error("First and last Position are not equivalent.");for(let e=0;e<t[t.length-1].length;e++)if(t[t.length-1][e]!==t[0][e])throw new Error("First and last Position are not equivalent.")}return o({type:"Polygon",coordinates:e},t,n)}function l(e,t,n={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return o({type:"LineString",coordinates:e},t,n)}function u(e,t={}){const n={type:"FeatureCollection"};return t.id&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.features=e,n}function c(e,t="kilometers"){const n=i[t];if(!n)throw new Error(t+" units is invalid");return e/n}function f(e){return e%(2*Math.PI)*180/Math.PI}function p(e){return e%360*Math.PI/180}function h(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}},850(e,t,n){function r(e,t,n){if(null!==e)for(var i,o,a,s,l,u,c,f,p=0,h=0,d=e.type,y="FeatureCollection"===d,g="Feature"===d,m=y?e.features.length:1,v=0;v<m;v++){l=(f=!!(c=y?e.features[v].geometry:g?e.geometry:e)&&"GeometryCollection"===c.type)?c.geometries.length:1;for(var b=0;b<l;b++){var E=0,S=0;if(null!==(s=f?c.geometries[b]:c)){u=s.coordinates;var w=s.type;switch(p=!n||"Polygon"!==w&&"MultiPolygon"!==w?0:1,w){case null:break;case"Point":if(!1===t(u,h,v,E,S))return!1;h++,E++;break;case"LineString":case"MultiPoint":for(i=0;i<u.length;i++){if(!1===t(u[i],h,v,E,S))return!1;h++,"MultiPoint"===w&&E++}"LineString"===w&&E++;break;case"Polygon":case"MultiLineString":for(i=0;i<u.length;i++){for(o=0;o<u[i].length-p;o++){if(!1===t(u[i][o],h,v,E,S))return!1;h++}"MultiLineString"===w&&E++,"Polygon"===w&&S++}"Polygon"===w&&E++;break;case"MultiPolygon":for(i=0;i<u.length;i++){for(S=0,o=0;o<u[i].length;o++){for(a=0;a<u[i][o].length-p;a++){if(!1===t(u[i][o][a],h,v,E,S))return!1;h++}S++}E++}break;case"GeometryCollection":for(i=0;i<s.geometries.length;i++)if(!1===r(s.geometries[i],t,n))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function i(e,t,n){var r=n;return function(e,t){var n,r,i,o,a,s,l,u,c,f,p=0,h="FeatureCollection"===e.type,d="Feature"===e.type,y=h?e.features.length:1;for(n=0;n<y;n++){for(s=h?e.features[n].geometry:d?e.geometry:e,u=h?e.features[n].properties:d?e.properties:{},c=h?e.features[n].bbox:d?e.bbox:void 0,f=h?e.features[n].id:d?e.id:void 0,a=(l=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,i=0;i<a;i++)if(null!==(o=l?s.geometries[i]:s))switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(o,p,u,c,f))return!1;break;case"GeometryCollection":for(r=0;r<o.geometries.length;r++)if(!1===t(o.geometries[r],p,u,c,f))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,u,c,f))return!1;p++}}(e,function(e,i,o,a,s){r=0===i&&void 0===n?e:t(r,e,i,o,a,s)}),r}n.d(t,{Fh:()=>r,jE:()=>i})},360(e,t,n){n.d(t,{k:()=>r});var r={CREATE:"create",EDIT_FINISH:"editfinish",CANCEL:"cancel",VERTEX_SELECTION:"vertexselection",VERTEX_CHANGE:"vertexchange",UNDO_CHANGE:"undochange",UPDATE:"update",GEOMETRY_CHANGE:"geometrychange",INTERFACE_TYPE_CHANGE:"interfacetypechange",PLACEMENT_BLOCKED:"placementblocked",VALIDITY_CHANGE:"validitychange",CAN_PLACE_CHANGE:"canplacechange"}},682(e,t,n){n.d(t,{$y:()=>f,F0:()=>l,WQ:()=>c,lm:()=>s,vf:()=>u});var r="rgba(29,112,184,1)",i="#ffffff",o="rgba(11,12,12,1)",a="rgba(212,53,28,0.5)",s={editStroke:{light:r,dark:i},editFill:{light:"rgba(29,112,184,0.1)",dark:"rgba(255,255,255,0.1)"},editVertex:{light:r,dark:i},editMidpoint:{light:r,dark:i},editHalo:{light:i,dark:o},editActive:{light:o,dark:i},splitInvalid:{light:r,dark:i},splitValid:{light:r,dark:i},invalidStroke:{light:r,dark:i},shapeStroke:"rgba(212,53,28,1)",shapeFill:a,snapVertex:a,snapMidpoint:"rgba(40,161,151,1)",snapEdge:"rgba(29,112,184,0.5)"},l={strokeWidth:2,vertexRadius:6,midpointRadius:4,vertexHaloRadius:8,midpointHaloRadius:6,touchTargetSize:48,touchIndicatorRadius:30},u={snapRadius:12},c={nudgeAmount:1,stepAmount:5},f={small:1,medium:1.5,large:2}},203(e,t,n){function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach(function(t){a(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function a(e,t,n){return(t=function(e){var t=function(e){if("object"!=r(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==r(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.r(t),n.d(t,{manifest:()=>Ae});var s=new Set(["draw_polygon","draw_line"]),l={SET_MODE:function(e,t){return o(o({},e),{},{mode:t,numVertices:s.has(t)?0:e.numVertices,geometryValid:!1,canAddPoint:!0})},SET_ACTION:function(e,t){return o(o({},e),{},{action:t.name,actionValid:t.isValid})},SET_FEATURE:function(e,t){return o(o({},e),{},{feature:void 0===t.feature?e.feature:t.feature,tempFeature:void 0===t.tempFeature?e.tempFeature:t.tempFeature})},SET_SELECTED_VERTEX_INDEX:function(e,t){return o(o({},e),{},{selectedVertexIndex:t.index,numVertices:t.numVertices})},TOGGLE_SNAP:function(e){return o(o({},e),{},{snap:!e.snap})},SET_HAS_SNAP_LAYERS:function(e,t){return o(o({},e),{},{hasSnapLayers:!!t})},SET_UNDO_STACK_LENGTH:function(e,t){return o(o({},e),{},{undoStackLength:t})},SET_GEOMETRY_VALID:function(e,t){return o(o({},e),{},{geometryValid:!!t})},SET_CAN_ADD_POINT:function(e,t){return o(o({},e),{},{canAddPoint:!!t})}},u=n(738),c={APP_ADD_MARKER:"app:addmarker",APP_UPDATE_MARKER:"app:updatemarker",APP_REMOVE_MARKER:"app:removemarker",APP_SET_MODE:"app:setmode",APP_REVERT_MODE:"app:revertmode",APP_ADD_BUTTON:"app:addbutton",APP_TOGGLE_BUTTON_STATE:"app:togglebuttonstate",APP_ADD_PANEL:"app:addpanel",APP_REMOVE_PANEL:"app:removepanel",APP_SHOW_PANEL:"app:showpanel",APP_HIDE_PANEL:"app:hidepanel",APP_ADD_CONTROL:"app:addcontrol",APP_SHOW_HINT:"app:showhint",APP_DISMISS_HINT:"app:dismisshint",APP_READY:"app:ready",APP_OPENED:"app:opened",APP_CLOSED:"app:closed",APP_FULLSCREEN_CHANGE:"app:fullscreenchange",APP_PANEL_OPENED:"app:panelopened",APP_PANEL_CLOSED:"app:panelclosed",MAP_SET_STYLE:"map:setstyle",MAP_SET_SIZE:"map:setsize",MAP_SET_FEATURES:"map:setfeatures",MAP_SET_FEATURES_SUPPRESSED:"map:setfeaturessuppressed",MAP_SET_ACTIVE_FEATURE:"map:setactivefeature",MAP_SELECT_FEATURE:"map:selectfeature",MAP_SET_PIXEL_RATIO:"map:setpixelratio",MAP_FIT_TO_BOUNDS:"map:fittobounds",MAP_SET_VIEW:"map:setview",MAP_INIT_MAP_STYLES:"map:initmapstyles",MAP_STYLE_CHANGE:"map:stylechange",MAP_LOADED:"map:loaded",MAP_READY:"map:ready",MAP_SIZE_CHANGE:"map:sizechange",MAP_FIRST_IDLE:"map:firstidle",MAP_MOVE_START:"map:movestart",MAP_MOVE:"map:move",MAP_MOVE_END:"map:moveend",MAP_STATE_UPDATED:"map:stateupdated",MAP_DATA_CHANGE:"map:datachange",MAP_RENDER:"map:render",MAP_CLICK:"map:click",MAP_DESTROY:"map:destroy"};function f(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var l=r&&r.prototype instanceof s?r:s,u=Object.create(l.prototype);return p(u,"_invoke",function(n,r,i){var o,s,l,u=0,c=i||[],f=!1,p={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,l=e,p.n=n,a}};function h(n,r){for(s=n,l=r,t=0;!f&&u&&!i&&t<c.length;t++){var i,o=c[t],h=p.p,d=o[2];n>3?(i=d===r)&&(l=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(s=0,p.v=r,p.n=o[1]):h<d&&(i=n<3||o[0]>r||r>d)&&(o[4]=n,o[5]=r,p.n=d,s=0))}if(i||n>1)return a;throw f=!0,r}return function(i,c,d){if(u>1)throw TypeError("Generator is already running");for(f&&1===c&&h(c,d),s=c,l=d;(t=s<2?e:l)||!f;){o||(s?s<3?(s>1&&(p.n=-1),h(s,l)):p.n=l:p.v=l);try{if(u=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,l)))throw TypeError("iterator result is not an object");if(!t.done)return t;l=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(l=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(f=p.n<0)?l:n.call(r,p))!==a)break}catch(t){o=e,s=1,l=t}finally{u=1}}return{value:t,done:f}}}(n,i,o),!0),u}var a={};function s(){}function l(){}function u(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(p(t={},r,function(){return this}),t),h=u.prototype=s.prototype=Object.create(c);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,p(e,i,"GeneratorFunction")),e.prototype=Object.create(h),e}return l.prototype=u,p(h,"constructor",u),p(u,"constructor",l),l.displayName="GeneratorFunction",p(u,i,"GeneratorFunction"),p(h),p(h,i,"Generator"),p(h,r,function(){return this}),p(h,"toString",function(){return"[object Generator]"}),(f=function(){return{w:o,m:d}})()}function p(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}p=function(e,t,n,r){function o(t,n){p(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},p(e,t,n,r)}function h(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}var d=function(){var e,t=(e=f().m(function e(t,r){var i,o,a,s,l;return f().w(function(e){for(;;)switch(e.n){case 0:l=t.name,e.n="MapLibreProvider"===l?1:"OpenLayersProvider"===l?3:5;break;case 1:return e.n=2,n.e(356).then(n.bind(n,826));case 2:return i=e.v,o=i.MaplibreDrawAdapter,e.a(2,new o(t,r));case 3:return e.n=4,n.e(722).then(n.bind(n,592));case 4:return a=e.v,s=a.OLDrawAdapter,e.a(2,new s(t,r));case 5:throw new Error('No draw adapter available for map provider "'.concat(t.name,'"'));case 6:return e.a(2)}},e)}),function(){var t=this,n=arguments;return new Promise(function(r,i){var o=e.apply(t,n);function a(e){h(o,r,i,a,s,"next",e)}function s(e){h(o,r,i,a,s,"throw",e)}a(void 0)})});return function(e,n){return t.apply(this,arguments)}}(),y=n(360),g=n(520),m=n(9),v=n(682),b=new Set(["symbol","symbolSvgContent","symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic","symbolViewBox","symbolAnchor"]);function E(e){return E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},E(e)}function S(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function w(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?S(Object(n),!0).forEach(function(t){P(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):S(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function P(e,t,n){return(t=function(e){var t=function(e){if("object"!=E(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=E(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==E(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function O(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){u=!0,i=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return x(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?x(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function x(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var _=function(e){if(null==e||!e.properties)return e;for(var t={},n=0,r=Object.entries(e.properties);n<r.length;n++){var i=O(r[n],2),o=i[0],a=i[1];"sortKey"===o||o.startsWith("symbol")&&!b.has(o)||(t[o]=a)}return w(w({},e),{},{properties:t})};function A(e){return A="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},A(e)}function T(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function C(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?T(Object(n),!0).forEach(function(t){k(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):T(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function k(e,t,n){return(t=function(e){var t=function(e){if("object"!=A(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=A(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==A(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var I="edit_vertex",j=new Set([I,"edit_point"]);function M(e){var t=e.appState,n=e.appConfig,r=e.mapState,i=e.pluginState,o=e.mapProvider,a=e.eventBus,s=e.hints,l=e.resetState,u=o.draw,c=function(e,t){return function(n){var r;e.emit("draw:geometryinvalid",n),n.reason&&(r=n.reason,!Object.values(m.PH).includes(r))&&t.show(n.reason)}}(a,s),f=i.feature,p=i.tempFeature,h=i.dispatch,d=null;return C(C({handleDone:function(){u.done()},handleCancel:function(){var e=u.getMode();j.has(e)&&null!=p&&p.id&&u.add(f),d=null,u.cancel(),l(),a.emit("draw:cancelled",_(f))},handleUndo:function(){return u.undo()},handleDeleteVertex:function(){return u.deleteVertex()},handleSnap:function(){i.dispatch({type:"TOGGLE_SNAP"}),u.setSnapEnabled(!i.snap)},onCreate:function(e){var i=(0,g.$U)(e,{phase:"create",mode:u.getMode()},{onGeometryChange:u._geometryValidator}),o=i.valid,s=i.reason;if(!o)return d=e.id,c({feature:_(e),reason:s,phase:"create",mode:I}),void setTimeout(function(){return function(e,t){var n,r,i,o=e.draw,a=e.appState,s=e.appConfig,l=e.mapState,u=e.dispatch;o.changeMode(I,{container:null==a||null===(n=a.layoutRefs)||void 0===n||null===(n=n.viewportRef)||void 0===n?void 0:n.current,deleteVertexButtonId:"".concat(null==s?void 0:s.id,"-draw-delete-point"),undoButtonId:"".concat(null==s?void 0:s.id,"-draw-undo"),isPanEnabled:"keyboard"!==(null==a?void 0:a.interfaceType),interfaceType:null==a?void 0:a.interfaceType,scale:v.$y[null==l?void 0:l.mapSize],featureId:t,getSnapEnabled:function(){return o.isSnapEnabled()}});var c=o.get(t);u({type:"SET_FEATURE",payload:{feature:c,tempFeature:c}}),u({type:"SET_MODE",payload:I}),u({type:"SET_GEOMETRY_VALID",payload:!1}),null===(r=o.setGeometryValid)||void 0===r||r.call(o,!1),null===(i=o.setInvalid)||void 0===i||i.call(o,!0)}({draw:u,appState:t,appConfig:n,mapState:r,dispatch:h},e.id)},0);l(),setTimeout(function(){return u.changeMode("disabled")},0),a.emit("draw:created",_(e))},onEditFinish:function(e){l(),setTimeout(function(){return u.changeMode("disabled")},0),d&&e.id===d?(d=null,a.emit("draw:created",_(e))):a.emit("draw:edited",_(e))},onCancel:function(){}},function(e){var t=e.draw,n=e.pluginState,r=e.mapProvider,i=e.eventBus;return{onVertexSelection:function(e){n.dispatch({type:"SET_SELECTED_VERTEX_INDEX",payload:e}),r.activeMoveTarget=e.index>=0?function(e){return{move:function(t,n,r){return e.nudgeSelectedVertex(t,n,r)},label:"vertex"}}(t):null,i.emit("draw:vertexselection",e)},onVertexChange:function(e){n.dispatch({type:"SET_SELECTED_VERTEX_INDEX",payload:{index:-1,numVertices:e.numVertices}}),r.activeMoveTarget=null}}}({draw:u,pluginState:i,mapProvider:o,eventBus:a})),{},{onUndoChange:function(e){i.dispatch({type:"SET_UNDO_STACK_LENGTH",payload:e})},onUpdate:function(e){a.emit("draw:updated",_(e))},onGeometryChange:function(e){var t;if(null!=e&&e.phase){var n,r=u.getMode(),o={phase:e.phase,vertexIndex:e.vertexIndex,mode:r},a=(0,g.$U)(e.feature,o,{onGeometryChange:u._geometryValidator}),s=a.valid,l=a.reason;i.dispatch({type:"SET_GEOMETRY_VALID",payload:s}),null===(t=u.setGeometryValid)||void 0===t||t.call(u,s),j.has(r)&&(null===(n=u.setInvalid)||void 0===n||n.call(u,!s)),s||c(C(C({reason:l},o),{},{feature:_(e.feature)}))}},onPlacementBlocked:function(e){c(C(C({},e),{},{feature:_(e.feature)}))},onValidityChange:function(e){var t;i.dispatch({type:"SET_GEOMETRY_VALID",payload:e.valid}),null===(t=u.setGeometryValid)||void 0===t||t.call(u,e.valid)},onCanPlaceChange:function(e){i.dispatch({type:"SET_CAN_ADD_POINT",payload:e.canPlace})},onInterfaceTypeChange:function(e){a.emit("draw:interfacetypechange",{interfaceType:e.interfaceType})}})}function L(e){return L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},L(e)}function R(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){u=!0,i=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return N(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?N(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function N(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var D=new Set(["stroke","fill","strokeWidth"]),G=function(e){if(!e)return{};for(var t={},n=0,r=Object.entries(e);n<r.length;n++){var i=R(r[n],2),o=i[0],a=i[1];if(D.has(o)&&"object"===L(a)&&null!==a){var s=Object.entries(a);s.length>0&&(t[o]=s[0][1]);for(var l=0,u=s;l<u.length;l++){var c=R(u[l],2),f=c[0],p=c[1];t["".concat(o).concat(f.charAt(0).toUpperCase()+f.slice(1))]=p}}else t[o]=a}return t};function F(e){return F="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},F(e)}var V=["stroke","fill","strokeWidth","properties","onGeometryChange"];function B(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function U(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?B(Object(n),!0).forEach(function(t){H(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):B(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function H(e,t,n){return(t=function(e){var t=function(e){if("object"!=F(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=F(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==F(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var q=function(e){return function(t,n){var r,i=t.appState,o=t.appConfig,a=t.pluginConfig,s=t.pluginState,l=t.mapState,u=t.mapProvider,c=t.services,f=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},p=s.dispatch,h=u.draw,d=c.eventBus;if(h){d.emit("draw:started",{mode:e});var y=void 0===f.snapLayers?null!==(r=a.snapLayers)&&void 0!==r?r:null:f.snapLayers;h.setSnapLayers(y),p({type:"SET_HAS_SNAP_LAYERS",payload:(null==y?void 0:y.length)>0});var g=f.stroke,m=f.fill,v=f.strokeWidth,b=f.properties,E=f.onGeometryChange,S=function(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(f,V);h._geometryValidator=null!=E?E:a.onGeometryChange;var w=U(U({},b),G({stroke:g,fill:m,strokeWidth:v}));h.changeMode(e,U(U({container:i.layoutRefs.viewportRef.current,addVertexButtonId:"".concat(o.id,"-draw-add-point"),interfaceType:i.interfaceType,crossHair:l.crossHair,getSnapEnabled:function(){return h.isSnapEnabled()},featureId:n},S),{},{properties:w})),p({type:"SET_MODE",payload:e})}}},Y=q("draw_polygon"),z=q("draw_line");function W(e){return W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},W(e)}var $=["properties","onGeometryChange"];function X(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function K(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?X(Object(n),!0).forEach(function(t){Z(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):X(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Z(e,t,n){return(t=function(e){var t=function(e){if("object"!=W(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=W(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==W(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var J="[interactive-map]",Q=function(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(e=console).warn.apply(e,[J].concat(n))};function ee(e){return ee="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ee(e)}var te=["stroke","fill","strokeWidth","properties"];function ne(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function re(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ne(Object(n),!0).forEach(function(t){ie(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ne(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ie(e,t,n){return(t=function(e){var t=function(e){if("object"!=ee(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=ee(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==ee(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var oe=new Set(["Point","LineString","Polygon"]);function ae(e){return ae="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ae(e)}function se(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function le(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?se(Object(n),!0).forEach(function(t){ue(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):se(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ue(e,t,n){return(t=function(e){var t=function(e){if("object"!=ae(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=ae(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==ae(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ce(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){u=!0,i=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return fe(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?fe(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function fe(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var pe=new Set(["stroke","fill","strokeWidth"]),he=n(704);function de(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var ye="_splitter",ge=function(e){var t,n,r,i,o=e.draw,a=(t=e.polygonFeature,n=e.feature,!(!(i=null===(r=n.geometry)||void 0===r?void 0:r.coordinates)||i.length<2||!(0,he.ns)(t,{id:ye,geometry:n.geometry})));return o.setDrawingPreviewProperty("splitter",a?"valid":"invalid"),a};function me(e){return me="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},me(e)}function ve(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function be(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ve(Object(n),!0).forEach(function(t){Ee(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ve(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ee(e,t,n){return(t=function(e){var t=function(e){if("object"!=me(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=me(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==me(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Se,we="top-middle",Pe=new Set(["edit_vertex","edit_point"]),Oe=function(e){return Pe.has(e)},xe="undefined"!=typeof navigator&&/mac/i.test((null===(Se=navigator.userAgentData)||void 0===Se?void 0:Se.platform)||navigator.platform||"")?"<kbd>Command</kbd> + <kbd>Z</kbd>":"<kbd>Ctrl</kbd> + <kbd>Z</kbd>",_e=function(e){return{mobile:{slot:"actions",showLabel:e},tablet:{slot:"actions",showLabel:e},desktop:{slot:"actions",showLabel:e}}},Ae={reducer:{initialState:{mode:null,action:null,actionValid:!1,feature:null,tempFeature:null,selectedVertexIndex:-1,numVertices:null,geometryValid:!0,canAddPoint:!0,snap:!1,hasSnapLayers:!1,undoStackLength:0},actions:l},InitComponent:function(e){var t=e.appState,n=e.appConfig,r=e.mapState,i=e.pluginConfig,o=e.pluginState,a=e.services,s=e.mapProvider,l=e.buttonConfig,f=a.eventBus,p=a.hints,h=r.crossHair,g=["touch","keyboard"].includes(t.interfaceType);(0,u.useEffect)(function(){var e,n,a,l,u=null===(e=null===(n=i.includeModes)||void 0===n?void 0:n.includes(t.mode))||void 0===e||e,p=null!==(a=null===(l=i.excludeModes)||void 0===l?void 0:l.includes(t.mode))&&void 0!==a&&a;if(r.isMapReady&&u&&!p){var h=!0;return d(s,{mapStyle:r.mapStyle,snapLayers:i.snapLayers,pluginConfig:i,events:c,eventBus:f}).then(function(e){var t;h&&(s.draw=e,o.dispatch({type:"SET_HAS_SNAP_LAYERS",payload:(null===(t=i.snapLayers)||void 0===t?void 0:t.length)>0}),f.emit("draw:ready"))}),function(){var e;h=!1,null===(e=s.draw)||void 0===e||e.remove(),s.draw=null,s.activeMoveTarget=null}}},[r.isMapReady,t.mode]),(0,u.useEffect)(function(){return f.emit(c.MAP_SET_FEATURES_SUPPRESSED,{suppressed:null!==o.mode}),function(){f.emit(c.MAP_SET_FEATURES_SUPPRESSED,{suppressed:!1})}},[o.mode,f]),(0,u.useEffect)(function(){if(["draw_polygon","draw_line","draw_point"].includes(o.mode)&&g){var e=h.isVisible;return h.fixAtCenter(),function(){e||["touch","keyboard"].includes(t.interfaceType)||h.hide()}}},[o.mode,t.interfaceType]),(0,u.useEffect)(function(){["edit_vertex","edit_point","draw_polygon","draw_line","draw_point"].includes(o.mode)&&s.draw&&s.draw.setInterfaceType(t.interfaceType)},[t.interfaceType,o.mode]),(0,u.useEffect)(function(){if(s.draw)return function(e){var t=e.appState,n=e.appConfig,r=e.mapState,i=e.pluginState,o=e.mapProvider,a=e.buttonConfig,s=e.eventBus,l=e.hints,u=o.draw,c=M({appState:t,appConfig:n,mapState:r,pluginState:i,mapProvider:o,eventBus:s,hints:l,resetState:function(){i.dispatch({type:"SET_MODE",payload:null}),i.dispatch({type:"SET_FEATURE",payload:{feature:null,tempFeature:null}}),o.activeMoveTarget=null}});return function(e,t){var n=e.drawDone,r=e.drawCancel,i=e.drawUndo,o=e.drawDeletePoint,a=e.drawSnap;n.onClick=t.handleDone,r.onClick=t.handleCancel,i.onClick=t.handleUndo,o&&(o.onClick=t.handleDeleteVertex),a&&(a.onClick=t.handleSnap)}(a,c),function(e,t){e.on(y.k.CREATE,t.onCreate),e.on(y.k.EDIT_FINISH,t.onEditFinish),e.on(y.k.CANCEL,t.onCancel),e.on(y.k.VERTEX_SELECTION,t.onVertexSelection),e.on(y.k.VERTEX_CHANGE,t.onVertexChange),e.on(y.k.UNDO_CHANGE,t.onUndoChange),e.on(y.k.UPDATE,t.onUpdate),e.on(y.k.GEOMETRY_CHANGE,t.onGeometryChange),e.on(y.k.PLACEMENT_BLOCKED,t.onPlacementBlocked),e.on(y.k.VALIDITY_CHANGE,t.onValidityChange),e.on(y.k.CAN_PLACE_CHANGE,t.onCanPlaceChange),e.on(y.k.INTERFACE_TYPE_CHANGE,t.onInterfaceTypeChange)}(u,c),function(){!function(e){var t=e.drawDone,n=e.drawCancel,r=e.drawUndo,i=e.drawDeletePoint,o=e.drawSnap;t.onClick=null,n.onClick=null,r.onClick=null,i&&(i.onClick=null),o&&(o.onClick=null)}(a),function(e,t){e.off(y.k.CREATE,t.onCreate),e.off(y.k.EDIT_FINISH,t.onEditFinish),e.off(y.k.CANCEL,t.onCancel),e.off(y.k.VERTEX_SELECTION,t.onVertexSelection),e.off(y.k.VERTEX_CHANGE,t.onVertexChange),e.off(y.k.UNDO_CHANGE,t.onUndoChange),e.off(y.k.UPDATE,t.onUpdate),e.off(y.k.GEOMETRY_CHANGE,t.onGeometryChange),e.off(y.k.PLACEMENT_BLOCKED,t.onPlacementBlocked),e.off(y.k.VALIDITY_CHANGE,t.onValidityChange),e.off(y.k.CAN_PLACE_CHANGE,t.onCanPlaceChange),e.off(y.k.INTERFACE_TYPE_CHANGE,t.onInterfaceTypeChange)}(u,c)}}({appState:t,appConfig:n,mapState:r,mapProvider:s,buttonConfig:l,pluginState:o,events:c,eventBus:f,hints:p})},[s,t,o])},buttons:[be({id:"drawCancel",label:"Cancel",variant:"tertiary",exclusiveSlot:!0,hiddenWhen:function(e){return!e.pluginState.mode}},_e(!0)),be({id:"drawAddPoint",label:"Add point",variant:"primary",exclusiveSlot:!0,hiddenWhen:function(e){var t=e.appState,n=e.pluginState;return!["draw_polygon","draw_line","draw_point"].includes(n.mode)||"touch"!==t.interfaceType},enableWhen:function(e){return e.pluginState.canAddPoint}},_e(!0)),be({id:"drawDone",label:"Done",variant:"primary",exclusiveSlot:!0,hiddenWhen:function(e){var t=e.pluginState;return!(["draw_polygon","draw_line"].includes(t.mode)||Oe(t.mode))},enableWhen:function(e){var t=e.pluginState,n=t.mode,r=t.geometryValid;return(["draw_polygon","draw_line"].includes(n)||Oe(n))&&r}},_e(!0)),{id:"drawMenu",label:function(e){var t=e.pluginState;return Oe(t.mode)?"Edit actions":"Draw actions"},iconId:"menu",exclusiveSlot:!0,hiddenWhen:function(e){var t=e.pluginState;return!(["draw_polygon","draw_line","draw_point"].includes(t.mode)||Oe(t.mode))},menuItems:[{id:"drawUndo",label:"Undo",iconId:"undo",hiddenWhen:function(e){var t=e.pluginState;return!(["draw_polygon","draw_line"].includes(t.mode)||Oe(t.mode))},enableWhen:function(e){var t=e.pluginState;return["draw_polygon","draw_line"].includes(t.mode)?t.numVertices>0:t.undoStackLength>0}},{id:"drawSnap",label:"Snap to feature",iconId:"magnet",hiddenWhen:function(e){var t=e.pluginState;return!t.mode||!t.hasSnapLayers},pressedWhen:function(e){return!!e.pluginState.snap}},{id:"drawDeletePoint",label:"Delete point",iconId:"trash",enableWhen:function(e){var t,n=e.pluginState;return!(n.selectedVertexIndex<0)&&("Polygon"===(null===(t=n.feature)||void 0===t||null===(t=t.geometry)||void 0===t?void 0:t.type)?n.numVertices>3:n.numVertices>2)},hiddenWhen:function(e){return"edit_vertex"!==e.pluginState.mode}}],mobile:{slot:we},tablet:{slot:we},desktop:{slot:we}}],keyboardShortcuts:[{id:"drawAddPoint",group:"Drawing",title:"Add point (draw)",command:"<kbd>Enter</kbd>"},{id:"drawSelectPoint",group:"Drawing",title:"Select nearest point (edit)",command:"<kbd>Spacebar</kbd>"},{id:"drawSelectAdjacentPoint",group:"Drawing",title:"Select adjacent point (edit)",command:"<kbd>Alt</kbd> + <kbd>↑</kbd> <kbd>↓</kbd> <kbd>←</kbd> or <kbd>→</kbd>"},{id:"drawMovePoint",group:"Drawing",title:"Move point (edit)",command:"<kbd>↑</kbd> <kbd>↓</kbd> <kbd>←</kbd> or <kbd>→</kbd>"},{id:"drawNudgePoint",group:"Drawing",title:"Nudge point (edit)",command:"<kbd>Shift</kbd> + <kbd>↑</kbd> <kbd>↓</kbd> <kbd>←</kbd> or <kbd>→</kbd>"},{id:"drawDeletePoint",group:"Drawing",title:"Delete point (edit)",command:"<kbd>Delete</kbd>"},{id:"drawUndo",group:"Drawing",title:"Undo",command:xe}],icons:[{id:"menu",svgContent:'<path d="m6 9 6 6 6-6"/>'},{id:"undo",svgContent:'<path d="M9 14 4 9l5-5"/><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11"/>'},{id:"magnet",svgContent:'<path d="m12 15 4 4"/><path d="M2.352 10.648a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.029-6.029a1 1 0 1 1 3 3l-6.029 6.029a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.365-6.367A1 1 0 0 0 8.716 4.282z"/><path d="m5 8 4 4"/>'},{id:"trash",svgContent:'<path d="M10 11v6"/><path d="M14 11v6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M3 6h18"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>'}],api:{newPolygon:Y,newLine:z,newPoint:function(e,t){var n,r=e.appState,i=e.appConfig,o=e.pluginConfig,a=e.pluginState,s=e.mapState,l=e.mapProvider,u=e.services,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},f=a.dispatch,p=l.draw,h=u.eventBus;if(p){h.emit("draw:started",{mode:"draw_point"});var d=void 0===c.snapLayers?null!==(n=o.snapLayers)&&void 0!==n?n:null:c.snapLayers;p.setSnapLayers(d),f({type:"SET_HAS_SNAP_LAYERS",payload:(null==d?void 0:d.length)>0});var y=c.properties,g=c.onGeometryChange,m=function(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(c,$);p._geometryValidator=null!=g?g:o.onGeometryChange;var v={};b.forEach(function(e){void 0!==m[e]&&(v[e]=m[e],delete m[e])}),p.changeMode("draw_point",K(K({container:r.layoutRefs.viewportRef.current,addVertexButtonId:"".concat(i.id,"-draw-add-point"),interfaceType:r.interfaceType,crossHair:s.crossHair,getSnapEnabled:function(){return p.isSnapEnabled()},featureId:t},m),{},{properties:K(K({},y),v)})),f({type:"SET_MODE",payload:"draw_point"})}},editFeature:function(e,t){var n,r,i,o=e.appState,a=e.appConfig,s=e.mapState,l=e.pluginConfig,u=e.pluginState,c=e.mapProvider,f=e.services,p=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},h=u.dispatch,d=c.draw,y=f.eventBus;if(!d)return!1;var m=d.get(t);if(!m)return!1;d._geometryValidator=null!==(n=p.onGeometryChange)&&void 0!==n?n:l.onGeometryChange;var b="Point"===m.geometry.type?"edit_point":"edit_vertex";y.emit("draw:editstart",{mode:{LineString:"edit_line",Polygon:"edit_polygon",Point:"edit_point"}[m.geometry.type]});var E=void 0===p.snapLayers?null!==(r=l.snapLayers)&&void 0!==r?r:null:p.snapLayers;d.setSnapLayers(E),h({type:"SET_HAS_SNAP_LAYERS",payload:(null==E?void 0:E.length)>0}),d.changeMode(b,{container:o.layoutRefs.viewportRef.current,deleteVertexButtonId:"".concat(a.id,"-draw-delete-point"),undoButtonId:"".concat(a.id,"-draw-undo"),isPanEnabled:"keyboard"!==o.interfaceType,interfaceType:o.interfaceType,scale:v.$y[s.mapSize],featureId:t,getSnapEnabled:function(){return d.isSnapEnabled()}});var S=d.get(t);h({type:"SET_FEATURE",payload:{feature:S,tempFeature:S}}),h({type:"SET_MODE",payload:b});var w=(0,g.$U)(S,{phase:"edit-start",mode:b},{onGeometryChange:d._geometryValidator}).valid;return h({type:"SET_GEOMETRY_VALID",payload:w}),null===(i=d.setInvalid)||void 0===i||i.call(d,!w),!0},addFeature:function(e,t){var n=e.mapProvider,r=e.services,i=n.draw,o=r.eventBus;if(i){var a=t.stroke,s=t.fill,l=t.strokeWidth,u=t.properties,c=re(re({type:"Feature"},function(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(t,te)),{},{properties:re(re({},u),G({stroke:a,fill:s,strokeWidth:l}))});!function(e){var t,n;return oe.has(null===(t=e.geometry)||void 0===t?void 0:t.type)&&void 0!==(null===(n=e.geometry)||void 0===n?void 0:n.coordinates)}(c)?Q("addFeature: ignoring invalid GeoJSON feature",c):(i.add(c),o.emit("draw:add",_(c)))}},setStyle:function(e,t){var n=e.mapProvider,r=e.services,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=n.draw,a=r.eventBus;if(!o)return!1;if(!o.get(t))return Q("setStyle: no feature found for id",t),!1;for(var s={},l={},u=0,c=Object.entries(i);u<c.length;u++){var f=ce(c[u],2),p=f[0],h=f[1];(pe.has(p)?s:l)[p]=h}var d=function(e){for(var t={},n=0,r=Object.entries(e);n<r.length;n++){var i=ce(r[n],2),o=i[0],a=i[1];void 0!==a&&(t[o]=a)}return t}(le(le({},G(s)),l));return o.setStyle(t,d),a.emit("draw:stylechange",{featureId:t,properties:d}),!0},deleteFeature:function(e,t){var n=e.mapProvider,r=e.services,i=n.draw,o=r.eventBus;i&&(i.delete(t),o.emit("draw:delete",{featureId:t}))},split:function(e,t){var n,r=e.appState,i=e.appConfig,o=e.pluginState,a=e.mapState,s=e.mapProvider,l=e.services,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},c=o.dispatch,f=s.draw,p=l.eventBus;if(f){var h=f.get(t),d=f._geometryValidator;f._geometryValidator=function(e){var t=e.draw,n=e.dispatch,r=e.polygonFeature;return function(e){var i,o=e.feature,a=e.phase;if("preview"===a)i=ge({draw:t,polygonFeature:r,feature:o});else{if(null==a||!a.startsWith("commit-"))return{valid:!0};i=function(e){var t=e.draw,n=e.dispatch,r=ge({draw:t,polygonFeature:e.polygonFeature,feature:e.feature});return n({type:"SET_ACTION",payload:{name:"split",isValid:r}}),n({type:"SET_GEOMETRY_VALID",payload:r}),t.setGeometryValid(r),r}({draw:t,dispatch:n,polygonFeature:r,feature:o})}return i?{valid:!0}:{valid:!1,reason:"Line does not split the shape into two parts"}}}({draw:f,dispatch:c,polygonFeature:h});var g=["stroke-inactive.cold"].concat(function(e){if(Array.isArray(e))return de(e)}(n=u.snapLayers||[])||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||function(e,t){if(e){if("string"==typeof e)return de(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?de(e,t):void 0}}(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}());f.setSnapLayers(g),c({type:"SET_HAS_SNAP_LAYERS",payload:!0}),f.changeMode("draw_line",{container:r.layoutRefs.viewportRef.current,addVertexButtonId:"".concat(i.id,"-draw-add-point"),interfaceType:r.interfaceType,crossHair:null==a?void 0:a.crossHair,getSnapEnabled:function(){return f.isSnapEnabled()},featureId:ye,properties:{splitter:"invalid"}});var m=function(){f._geometryValidator=d,f.off(y.k.CREATE,v),f.off(y.k.CANCEL,b)},v=function(e){m(),f.delete(ye);var n=(0,he.ns)(h,e);c({type:"SET_ACTION",payload:{name:"split",isValid:!!n}}),n&&p.emit("draw:split",{originalFeatureId:t,featureCollection:n})},b=function(){m()};f.on(y.k.CREATE,v),f.on(y.k.CANCEL,b),c({type:"SET_MODE",payload:"draw_line"}),c({type:"SET_ACTION",payload:{name:"split"}})}},merge:function(e,t){var n=e.mapProvider,r=e.services,i=n.draw,o=r.eventBus;if(!i)return null;var a=t.map(function(e){return i.get(e)}),s=(0,he.OI)(a);return s&&o.emit("draw:merge",{originalFeatureIds:t,feature:s}),s}}}},704(e,t,n){function r(e){var t={type:"Feature"};return Object.keys(e).forEach(function(n){switch(n){case"type":case"properties":case"geometry":return;default:t[n]=e[n]}}),t.properties=i(e.properties),t.geometry=o(e.geometry),t}function i(e){var t={};return e?(Object.keys(e).forEach(function(n){var r=e[n];"object"==typeof r?null===r?t[n]=null:Array.isArray(r)?t[n]=r.map(function(e){return e}):t[n]=i(r):t[n]=r}),t):t}function o(e){var t={type:e.type};return e.bbox&&(t.bbox=e.bbox),"GeometryCollection"===e.type?(t.geometries=e.geometries.map(function(e){return o(e)}),t):(t.coordinates=a(e.coordinates),t)}function a(e){var t=e;return"object"!=typeof t[0]?t.slice():t.map(function(e){return a(e)})}n.d(t,{jK:()=>yt,DF:()=>dt,OI:()=>pt,cj:()=>gt,ns:()=>ft});function s(e){for(var t,n,r=function(e){if(Array.isArray(e))return e;if("Feature"===e.type){if(null!==e.geometry)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}(e),i=0,o=1;o<r.length;)t=n||r[0],i+=((n=r[o])[0]-t[0])*(n[1]+t[1]),o++;return i>0}function l(e,t){if("Feature"===e.type)t(e,0);else if("FeatureCollection"===e.type)for(var n=0;n<e.features.length&&!1!==t(e.features[n],n);n++);}function u(e,t){var n,r,i,o,a,s,l,u,c,f,p=0,h="FeatureCollection"===e.type,d="Feature"===e.type,y=h?e.features.length:1;for(n=0;n<y;n++){for(s=h?e.features[n].geometry:d?e.geometry:e,u=h?e.features[n].properties:d?e.properties:{},c=h?e.features[n].bbox:d?e.bbox:void 0,f=h?e.features[n].id:d?e.id:void 0,a=(l=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,i=0;i<a;i++)if(null!==(o=l?s.geometries[i]:s))switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(o,p,u,c,f))return!1;break;case"GeometryCollection":for(r=0;r<o.geometries.length;r++)if(!1===t(o.geometries[r],p,u,c,f))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,u,c,f))return!1;p++}}function c(e){if(Array.isArray(e))return e;if("Feature"===e.type){if(null!==e.geometry)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function f(e,t){switch("Feature"===e.type?e.geometry.type:e.type){case"GeometryCollection":return u(e,function(e){f(e,t)}),e;case"LineString":return p(c(e),t),e;case"Polygon":return h(c(e),t),e;case"MultiLineString":return c(e).forEach(function(e){p(e,t)}),e;case"MultiPolygon":return c(e).forEach(function(e){h(e,t)}),e;case"Point":case"MultiPoint":return e}}function p(e,t){s(e)===t&&e.reverse()}function h(e,t){s(e[0])!==t&&e[0].reverse();for(var n=1;n<e.length;n++)s(e[n])===t&&e[n].reverse()}const d=function(e,t){if(!(n=t=t||{})||n.constructor!==Object)throw new Error("options is invalid");var n,i=t.reverse||!1,a=t.mutate||!1;if(!e)throw new Error("<geojson> is required");if("boolean"!=typeof i)throw new Error("<reverse> must be a boolean");if("boolean"!=typeof a)throw new Error("<mutate> must be a boolean");!1===a&&(e=function(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return r(e);case"FeatureCollection":return function(e){var t={type:"FeatureCollection"};return Object.keys(e).forEach(function(n){switch(n){case"type":case"features":return;default:t[n]=e[n]}}),t.features=e.features.map(function(e){return r(e)}),t}(e);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return o(e);default:throw new Error("unknown GeoJSON type")}}(e));var s=[];switch(e.type){case"GeometryCollection":return u(e,function(e){f(e,i)}),e;case"FeatureCollection":return l(e,function(e){l(f(e,i),function(e){s.push(e)})}),function(e,t){void 0===t&&(t={});var n={type:"FeatureCollection"};return t.id&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.features=e,n}(s)}return f(e,i)},y=11102230246251565e-32,g=134217729,m=(3+8*y)*y;function v(e,t,n,r,i){let o,a,s,l,u=t[0],c=r[0],f=0,p=0;c>u==c>-u?(o=u,u=t[++f]):(o=c,c=r[++p]);let h=0;if(f<e&&p<n)for(c>u==c>-u?(a=u+o,s=o-(a-u),u=t[++f]):(a=c+o,s=o-(a-c),c=r[++p]),o=a,0!==s&&(i[h++]=s);f<e&&p<n;)c>u==c>-u?(a=o+u,l=a-o,s=o-(a-l)+(u-l),u=t[++f]):(a=o+c,l=a-o,s=o-(a-l)+(c-l),c=r[++p]),o=a,0!==s&&(i[h++]=s);for(;f<e;)a=o+u,l=a-o,s=o-(a-l)+(u-l),u=t[++f],o=a,0!==s&&(i[h++]=s);for(;p<n;)a=o+c,l=a-o,s=o-(a-l)+(c-l),c=r[++p],o=a,0!==s&&(i[h++]=s);return 0===o&&0!==h||(i[h++]=o),h}function b(e){return new Float64Array(e)}const E=b(4),S=b(8),w=b(12),P=b(16),O=b(4);function x(e,t,n,r,i,o){const a=(t-o)*(n-i),s=(e-i)*(r-o),l=a-s,u=Math.abs(a+s);return Math.abs(l)>=33306690738754716e-32*u?l:-function(e,t,n,r,i,o,a){let s,l,u,c,f,p,h,d,y,b,x,_,A,T,C,k,I,j;const M=e-i,L=n-i,R=t-o,N=r-o;T=M*N,p=g*M,h=p-(p-M),d=M-h,p=g*N,y=p-(p-N),b=N-y,C=d*b-(T-h*y-d*y-h*b),k=R*L,p=g*R,h=p-(p-R),d=R-h,p=g*L,y=p-(p-L),b=L-y,I=d*b-(k-h*y-d*y-h*b),x=C-I,f=C-x,E[0]=C-(x+f)+(f-I),_=T+x,f=_-T,A=T-(_-f)+(x-f),x=A-k,f=A-x,E[1]=A-(x+f)+(f-k),j=_+x,f=j-_,E[2]=_-(j-f)+(x-f),E[3]=j;let D=function(e,t){let n=t[0];for(let e=1;e<4;e++)n+=t[e];return n}(0,E),G=22204460492503146e-32*a;if(D>=G||-D>=G)return D;if(f=e-M,s=e-(M+f)+(f-i),f=n-L,u=n-(L+f)+(f-i),f=t-R,l=t-(R+f)+(f-o),f=r-N,c=r-(N+f)+(f-o),0===s&&0===l&&0===u&&0===c)return D;if(G=11093356479670487e-47*a+m*Math.abs(D),D+=M*c+N*s-(R*u+L*l),D>=G||-D>=G)return D;T=s*N,p=g*s,h=p-(p-s),d=s-h,p=g*N,y=p-(p-N),b=N-y,C=d*b-(T-h*y-d*y-h*b),k=l*L,p=g*l,h=p-(p-l),d=l-h,p=g*L,y=p-(p-L),b=L-y,I=d*b-(k-h*y-d*y-h*b),x=C-I,f=C-x,O[0]=C-(x+f)+(f-I),_=T+x,f=_-T,A=T-(_-f)+(x-f),x=A-k,f=A-x,O[1]=A-(x+f)+(f-k),j=_+x,f=j-_,O[2]=_-(j-f)+(x-f),O[3]=j;const F=v(4,E,4,O,S);T=M*c,p=g*M,h=p-(p-M),d=M-h,p=g*c,y=p-(p-c),b=c-y,C=d*b-(T-h*y-d*y-h*b),k=R*u,p=g*R,h=p-(p-R),d=R-h,p=g*u,y=p-(p-u),b=u-y,I=d*b-(k-h*y-d*y-h*b),x=C-I,f=C-x,O[0]=C-(x+f)+(f-I),_=T+x,f=_-T,A=T-(_-f)+(x-f),x=A-k,f=A-x,O[1]=A-(x+f)+(f-k),j=_+x,f=j-_,O[2]=_-(j-f)+(x-f),O[3]=j;const V=v(F,S,4,O,w);T=s*c,p=g*s,h=p-(p-s),d=s-h,p=g*c,y=p-(p-c),b=c-y,C=d*b-(T-h*y-d*y-h*b),k=l*u,p=g*l,h=p-(p-l),d=l-h,p=g*u,y=p-(p-u),b=u-y,I=d*b-(k-h*y-d*y-h*b),x=C-I,f=C-x,O[0]=C-(x+f)+(f-I),_=T+x,f=_-T,A=T-(_-f)+(x-f),x=A-k,f=A-x,O[1]=A-(x+f)+(f-k),j=_+x,f=j-_,O[2]=_-(j-f)+(x-f),O[3]=j;const B=v(V,w,4,O,P);return P[B-1]}(e,t,n,r,i,o,u)}function _(e,t){var n,r,i,o,a,s,l,u,c,f=0,p=e[0],h=e[1],d=t.length;for(n=0;n<d;n++){r=0;var y=t[n],g=y.length-1;if((u=y[0])[0]!==y[g][0]&&u[1]!==y[g][1])throw new Error("First and last coordinates in a ring must be the same");for(o=u[0]-p,a=u[1]-h;r<g;r++){if(s=(c=y[r+1])[0]-p,l=c[1]-h,0===a&&0===l){if(s<=0&&o>=0||o<=0&&s>=0)return 0}else if(l>=0&&a<=0||l<=0&&a>=0){if(0===(i=x(o,s,a,l,0,0)))return 0;(i>0&&l>0&&a<=0||i<0&&l<=0&&a>0)&&f++}u=c,a=l,o=s}}return f%2!=0}b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(8),b(8),b(8),b(4),b(8),b(8),b(8),b(12),b(192),b(192),b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(8),b(8),b(8),b(8),b(8),b(8),b(8),b(8),b(8),b(4),b(4),b(4),b(8),b(16),b(16),b(16),b(32),b(32),b(48),b(64),b(1152),b(1152),b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(24),b(24),b(24),b(24),b(24),b(24),b(24),b(24),b(24),b(24),b(1152),b(1152),b(1152),b(1152),b(1152),b(2304),b(2304),b(3456),b(5760),b(8),b(8),b(8),b(16),b(24),b(48),b(48),b(96),b(192),b(384),b(384),b(384),b(768),b(96),b(96),b(96),b(1152);const A=134217729;function T(e,t,n,r,i){let o,a,s,l,u=t[0],c=r[0],f=0,p=0;c>u==c>-u?(o=u,u=t[++f]):(o=c,c=r[++p]);let h=0;if(f<e&&p<n)for(c>u==c>-u?(a=u+o,s=o-(a-u),u=t[++f]):(a=c+o,s=o-(a-c),c=r[++p]),o=a,0!==s&&(i[h++]=s);f<e&&p<n;)c>u==c>-u?(a=o+u,l=a-o,s=o-(a-l)+(u-l),u=t[++f]):(a=o+c,l=a-o,s=o-(a-l)+(c-l),c=r[++p]),o=a,0!==s&&(i[h++]=s);for(;f<e;)a=o+u,l=a-o,s=o-(a-l)+(u-l),u=t[++f],o=a,0!==s&&(i[h++]=s);for(;p<n;)a=o+c,l=a-o,s=o-(a-l)+(c-l),c=r[++p],o=a,0!==s&&(i[h++]=s);return 0===o&&0!==h||(i[h++]=o),h}function C(e){return new Float64Array(e)}const k=C(4),I=C(8),j=C(12),M=C(16),L=C(4);function R(e,t,n,r,i,o){const a=(t-o)*(n-i),s=(e-i)*(r-o),l=a-s;if(0===a||0===s||a>0!=s>0)return l;const u=Math.abs(a+s);return Math.abs(l)>=33306690738754716e-32*u?l:-function(e,t,n,r,i,o,a){let s,l,u,c,f,p,h,d,y,g,m,v,b,E,S,w,P,O;const x=e-i,_=n-i,C=t-o,R=r-o;E=x*R,p=A*x,h=p-(p-x),d=x-h,p=A*R,y=p-(p-R),g=R-y,S=d*g-(E-h*y-d*y-h*g),w=C*_,p=A*C,h=p-(p-C),d=C-h,p=A*_,y=p-(p-_),g=_-y,P=d*g-(w-h*y-d*y-h*g),m=S-P,f=S-m,k[0]=S-(m+f)+(f-P),v=E+m,f=v-E,b=E-(v-f)+(m-f),m=b-w,f=b-m,k[1]=b-(m+f)+(f-w),O=v+m,f=O-v,k[2]=v-(O-f)+(m-f),k[3]=O;let N=function(e,t){let n=t[0];for(let e=1;e<4;e++)n+=t[e];return n}(0,k),D=22204460492503146e-32*a;if(N>=D||-N>=D)return N;if(f=e-x,s=e-(x+f)+(f-i),f=n-_,u=n-(_+f)+(f-i),f=t-C,l=t-(C+f)+(f-o),f=r-R,c=r-(R+f)+(f-o),0===s&&0===l&&0===u&&0===c)return N;if(D=11093356479670487e-47*a+33306690738754706e-32*Math.abs(N),N+=x*c+R*s-(C*u+_*l),N>=D||-N>=D)return N;E=s*R,p=A*s,h=p-(p-s),d=s-h,p=A*R,y=p-(p-R),g=R-y,S=d*g-(E-h*y-d*y-h*g),w=l*_,p=A*l,h=p-(p-l),d=l-h,p=A*_,y=p-(p-_),g=_-y,P=d*g-(w-h*y-d*y-h*g),m=S-P,f=S-m,L[0]=S-(m+f)+(f-P),v=E+m,f=v-E,b=E-(v-f)+(m-f),m=b-w,f=b-m,L[1]=b-(m+f)+(f-w),O=v+m,f=O-v,L[2]=v-(O-f)+(m-f),L[3]=O;const G=T(4,k,4,L,I);E=x*c,p=A*x,h=p-(p-x),d=x-h,p=A*c,y=p-(p-c),g=c-y,S=d*g-(E-h*y-d*y-h*g),w=C*u,p=A*C,h=p-(p-C),d=C-h,p=A*u,y=p-(p-u),g=u-y,P=d*g-(w-h*y-d*y-h*g),m=S-P,f=S-m,L[0]=S-(m+f)+(f-P),v=E+m,f=v-E,b=E-(v-f)+(m-f),m=b-w,f=b-m,L[1]=b-(m+f)+(f-w),O=v+m,f=O-v,L[2]=v-(O-f)+(m-f),L[3]=O;const F=T(G,I,4,L,j);E=s*c,p=A*s,h=p-(p-s),d=s-h,p=A*c,y=p-(p-c),g=c-y,S=d*g-(E-h*y-d*y-h*g),w=l*u,p=A*l,h=p-(p-l),d=l-h,p=A*u,y=p-(p-u),g=u-y,P=d*g-(w-h*y-d*y-h*g),m=S-P,f=S-m,L[0]=S-(m+f)+(f-P),v=E+m,f=v-E,b=E-(v-f)+(m-f),m=b-w,f=b-m,L[1]=b-(m+f)+(f-w),O=v+m,f=O-v,L[2]=v-(O-f)+(m-f),L[3]=O;const V=T(F,j,4,L,M);return M[V-1]}(e,t,n,r,i,o,u)}C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(8),C(8),C(8),C(4),C(8),C(8),C(8),C(12),C(192),C(192),C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(8),C(8),C(8),C(8),C(8),C(8),C(8),C(8),C(8),C(4),C(4),C(4),C(8),C(16),C(16),C(16),C(32),C(32),C(48),C(64),C(1152),C(1152),C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(24),C(24),C(24),C(24),C(24),C(24),C(24),C(24),C(24),C(24),C(1152),C(1152),C(1152),C(1152),C(1152),C(2304),C(2304),C(3456),C(5760),C(8),C(8),C(8),C(16),C(24),C(48),C(48),C(96),C(192),C(384),C(384),C(384),C(768),C(96),C(96),C(96),C(1152);var N=function(e,t,n,r,i){this.p1=e,this.p2=t,this.edgeType=n,this.originalIndex=r,this.polygonContourId=i,this.interiorRing=!1,this.minX=Math.min(e.p[0],t.p[0]),this.minY=Math.min(e.p[1],t.p[1]),this.maxX=Math.max(e.p[0],t.p[0]),this.maxY=Math.max(e.p[1],t.p[1]),this.intersectionPoints=[],this.nextEdge=null},D=function(e){this.p=e},G=function(e,t){this.id=e,this.rawCoords=t};function F(e,t){return!(e.maxX<t[0]||e.minX>t[2]||e.maxY<t[1]||e.minY>t[3])}var V=function(e,t,n,r){this.p=e,this.polylineEdge=t,this.polygonEdge=n,this.isHeadingIn=r,this.distanceFromPolylineEdgeStart=B(this.polylineEdge.p1.p,this.p),this.distanceFromPolygonEdgeStart=B(this.polygonEdge.p1.p,this.p),this.polygonEdge.intersectionPoints.push(this),this.polylineEdge.intersectionPoints.push(this),this.visitCount=0};function B(e,t){var n=t[0]-e[0],r=t[1]-e[1];return n*=n,r*=r,Math.sqrt(n+r)}function U(e,t){return e[0]*t[1]-e[1]*t[0]}function H(e,t){return e[0]*t[0]+e[1]*t[1]}function q(e,t,n){return[e[0]+t*n[0],e[1]+t*n[1]]}function Y(e,t,n){var r=[e.p2.p[0]-e.p1.p[0],e.p2.p[1]-e.p1.p[1]],i=[t.p2.p[0]-t.p1.p[0],t.p2.p[1]-t.p1.p[1]],o=[t.p1.p[0]-e.p1.p[0],t.p1.p[1]-e.p1.p[1]],a=U(r,i),s=a*a,l=H(r,r);if(s>0){var u=U(o,i)/a;if(u<0||u>1)return null;var c=U(o,r)/a;return c<0||c>1?null:0===u||1===u?n?null:[q(e.p1.p,u,r)]:0===c||1===c?n?null:[q(t.p1.p,c,i)]:[q(e.p1.p,u,r)]}var f=H(o,o);if((s=(a=U(o,r))*a)>1e-9*l*f)return null;var p=H(r,o)/l,h=p+H(r,i)/l,d=Math.min(p,h),y=Math.max(p,h);return d<=1&&y>=0?1===d?n?null:[q(e.p1.p,d>0?d:0,r)]:0===y?n?null:[q(e.p1.p,y<1?y:1,r)]:n&&0===d&&1===y?null:[q(e.p1.p,d>0?d:0,r),q(e.p1.p,y<1?y:1,r)]:null}function z(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(r.polygonContourId===t)return r}}function W(e,t){return t.find(function(t){return t.id===e.polygonContourId}).rawCoords}function $(e,t){for(var n=0;n<t.length;n++){var r=t[n];if(_(e[0],[r[0]]))return void r.push(e)}t.push([e])}function X(e,t){var n=e.polygonEdge;if(n.intersectionPoints.length>1&&n.intersectionPoints[n.intersectionPoints.length-1]!==e){var r=K(e,n.intersectionPoints),i=n.intersectionPoints[r+1];return t.push(i.p),i.incrementVisitCount(),i}for(var o=!0;o;){if(t.push(n.p2.p),null===(n=n.nextEdge))return e;n.intersectionPoints.length>0&&(o=!1)}return n.intersectionPoints[0].incrementVisitCount(),t.push(n.intersectionPoints[0].p),n.intersectionPoints[0]}function K(e,t){for(var n=0;n<t.length;n++)if(t[n]===e)return n;return null}function Z(e,t){var n=e.polylineEdge;if(2===n.intersectionPoints.length){var r=n.intersectionPoints[n.intersectionPoints.length-1];if(r===e){var i=n.intersectionPoints[0];return t.push(i.p),i.incrementVisitCount(),i}return t.push(r.p),r.incrementVisitCount(),r}if(n.intersectionPoints.length>2&&n.intersectionPoints[0]!==e){var o=K(e,n.intersectionPoints),a=n.intersectionPoints[o-1];return t.push(a.p),a.incrementVisitCount(),a}for(var s=!0;s;){if(t.push(n.p1.p),void 0===(n=n.prevEdge).originalIndex)return e;n.intersectionPoints.length>0&&(s=!1)}if(void 0===n.originalIndex)return e;var l=n.intersectionPoints[n.intersectionPoints.length-1];return l.incrementVisitCount(),t.push(l.p),l}function J(e,t){var n=e.polylineEdge;if(n.intersectionPoints.length>1&&n.intersectionPoints[n.intersectionPoints.length-1]!==e){var r=K(e,n.intersectionPoints),i=n.intersectionPoints[r+1];return t.push(i.p),i.incrementVisitCount(),i}for(var o=!0;o;){if(t.push(n.p2.p),null===(n=n.nextEdge))return e;n.intersectionPoints.length>0&&(o=!1)}if(void 0===n)return e;var a=n.intersectionPoints[0];return a.incrementVisitCount(),t.push(a.p),a}V.prototype.incrementVisitCount=function(){this.visitCount=this.visitCount+1};var Q=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,ee=Math.ceil,te=Math.floor,ne="[BigNumber Error] ",re=ne+"Number primitive has more than 15 significant digits: ",ie=1e14,oe=14,ae=9007199254740991,se=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],le=1e7,ue=1e9;function ce(e){var t=0|e;return e>0||e===t?t:t-1}function fe(e){for(var t,n,r=1,i=e.length,o=e[0]+"";r<i;){for(t=e[r++]+"",n=oe-t.length;n--;t="0"+t);o+=t}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function pe(e,t){var n,r,i=e.c,o=t.c,a=e.s,s=t.s,l=e.e,u=t.e;if(!a||!s)return null;if(n=i&&!i[0],r=o&&!o[0],n||r)return n?r?0:-s:a;if(a!=s)return a;if(n=a<0,r=l==u,!i||!o)return r?0:!i^n?1:-1;if(!r)return l>u^n?1:-1;for(s=(l=i.length)<(u=o.length)?l:u,a=0;a<s;a++)if(i[a]!=o[a])return i[a]>o[a]^n?1:-1;return l==u?0:l>u^n?1:-1}function he(e,t,n,r){if(e<t||e>n||e!==te(e))throw Error(ne+(r||"Argument")+("number"==typeof e?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function de(e){var t=e.c.length-1;return ce(e.e/oe)==t&&e.c[t]%2!=0}function ye(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function ge(e,t,n){var r,i;if(t<0){for(i=n+".";++t;i+=n);e=i+e}else if(++t>(r=e.length)){for(i=n,t-=r;--t;i+=n);e+=i}else t<r&&(e=e.slice(0,t)+"."+e.slice(t));return e}var me=function e(t){var n,r,i,o,a,s,l,u,c,f,p=_.prototype={constructor:_,toString:null,valueOf:null},h=new _(1),d=20,y=4,g=-7,m=21,v=-1e7,b=1e7,E=!1,S=1,w=0,P={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},O="0123456789abcdefghijklmnopqrstuvwxyz",x=!0;function _(e,t){var n,o,a,s,l,u,c,f,p=this;if(!(p instanceof _))return new _(e,t);if(null==t){if(e&&!0===e._isBigNumber)return p.s=e.s,void(!e.c||e.e>b?p.c=p.e=null:e.e<v?p.c=[p.e=0]:(p.e=e.e,p.c=e.c.slice()));if((u="number"==typeof e)&&0*e==0){if(p.s=1/e<0?(e=-e,-1):1,e===~~e){for(s=0,l=e;l>=10;l/=10,s++);return void(s>b?p.c=p.e=null:(p.e=s,p.c=[e]))}f=String(e)}else{if(!Q.test(f=String(e)))return i(p,f,u);p.s=45==f.charCodeAt(0)?(f=f.slice(1),-1):1}(s=f.indexOf("."))>-1&&(f=f.replace(".","")),(l=f.search(/e/i))>0?(s<0&&(s=l),s+=+f.slice(l+1),f=f.substring(0,l)):s<0&&(s=f.length)}else{if(he(t,2,O.length,"Base"),10==t&&x)return k(p=new _(e),d+p.e+1,y);if(f=String(e),u="number"==typeof e){if(0*e!=0)return i(p,f,u,t);if(p.s=1/e<0?(f=f.slice(1),-1):1,_.DEBUG&&f.replace(/^0\.0*|\./,"").length>15)throw Error(re+e)}else p.s=45===f.charCodeAt(0)?(f=f.slice(1),-1):1;for(n=O.slice(0,t),s=l=0,c=f.length;l<c;l++)if(n.indexOf(o=f.charAt(l))<0){if("."==o){if(l>s){s=c;continue}}else if(!a&&(f==f.toUpperCase()&&(f=f.toLowerCase())||f==f.toLowerCase()&&(f=f.toUpperCase()))){a=!0,l=-1,s=0;continue}return i(p,String(e),u,t)}u=!1,(s=(f=r(f,t,10,p.s)).indexOf("."))>-1?f=f.replace(".",""):s=f.length}for(l=0;48===f.charCodeAt(l);l++);for(c=f.length;48===f.charCodeAt(--c););if(f=f.slice(l,++c)){if(c-=l,u&&_.DEBUG&&c>15&&(e>ae||e!==te(e)))throw Error(re+p.s*e);if((s=s-l-1)>b)p.c=p.e=null;else if(s<v)p.c=[p.e=0];else{if(p.e=s,p.c=[],l=(s+1)%oe,s<0&&(l+=oe),l<c){for(l&&p.c.push(+f.slice(0,l)),c-=oe;l<c;)p.c.push(+f.slice(l,l+=oe));l=oe-(f=f.slice(l)).length}else l-=c;for(;l--;f+="0");p.c.push(+f)}}else p.c=[p.e=0]}function A(e,t,n,r){var i,o,a,s,l;if(null==n?n=y:he(n,0,8),!e.c)return e.toString();if(i=e.c[0],a=e.e,null==t)l=fe(e.c),l=1==r||2==r&&(a<=g||a>=m)?ye(l,a):ge(l,a,"0");else if(o=(e=k(new _(e),t,n)).e,s=(l=fe(e.c)).length,1==r||2==r&&(t<=o||o<=g)){for(;s<t;l+="0",s++);l=ye(l,o)}else if(t-=a+(2===r&&o>a),l=ge(l,o,"0"),o+1>s){if(--t>0)for(l+=".";t--;l+="0");}else if((t+=o-s)>0)for(o+1==s&&(l+=".");t--;l+="0");return e.s<0&&i?"-"+l:l}function T(e,t){for(var n,r,i=1,o=new _(e[0]);i<e.length;i++)(!(r=new _(e[i])).s||(n=pe(o,r))===t||0===n&&o.s===t)&&(o=r);return o}function C(e,t,n){for(var r=1,i=t.length;!t[--i];t.pop());for(i=t[0];i>=10;i/=10,r++);return(n=r+n*oe-1)>b?e.c=e.e=null:n<v?e.c=[e.e=0]:(e.e=n,e.c=t),e}function k(e,t,n,r){var i,o,a,s,l,u,c,f=e.c,p=se;if(f){e:{for(i=1,s=f[0];s>=10;s/=10,i++);if((o=t-i)<0)o+=oe,a=t,l=f[u=0],c=te(l/p[i-a-1]%10);else if((u=ee((o+1)/oe))>=f.length){if(!r)break e;for(;f.length<=u;f.push(0));l=c=0,i=1,a=(o%=oe)-oe+1}else{for(l=s=f[u],i=1;s>=10;s/=10,i++);c=(a=(o%=oe)-oe+i)<0?0:te(l/p[i-a-1]%10)}if(r=r||t<0||null!=f[u+1]||(a<0?l:l%p[i-a-1]),r=n<4?(c||r)&&(0==n||n==(e.s<0?3:2)):c>5||5==c&&(4==n||r||6==n&&(o>0?a>0?l/p[i-a]:0:f[u-1])%10&1||n==(e.s<0?8:7)),t<1||!f[0])return f.length=0,r?(t-=e.e+1,f[0]=p[(oe-t%oe)%oe],e.e=-t||0):f[0]=e.e=0,e;if(0==o?(f.length=u,s=1,u--):(f.length=u+1,s=p[oe-o],f[u]=a>0?te(l/p[i-a]%p[a])*s:0),r)for(;;){if(0==u){for(o=1,a=f[0];a>=10;a/=10,o++);for(a=f[0]+=s,s=1;a>=10;a/=10,s++);o!=s&&(e.e++,f[0]==ie&&(f[0]=1));break}if(f[u]+=s,f[u]!=ie)break;f[u--]=0,s=1}for(o=f.length;0===f[--o];f.pop());}e.e>b?e.c=e.e=null:e.e<v&&(e.c=[e.e=0])}return e}function I(e){var t,n=e.e;return null===n?e.toString():(t=fe(e.c),t=n<=g||n>=m?ye(t,n):ge(t,n,"0"),e.s<0?"-"+t:t)}return _.clone=e,_.ROUND_UP=0,_.ROUND_DOWN=1,_.ROUND_CEIL=2,_.ROUND_FLOOR=3,_.ROUND_HALF_UP=4,_.ROUND_HALF_DOWN=5,_.ROUND_HALF_EVEN=6,_.ROUND_HALF_CEIL=7,_.ROUND_HALF_FLOOR=8,_.EUCLID=9,_.config=_.set=function(e){var t,n;if(null!=e){if("object"!=typeof e)throw Error(ne+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(he(n=e[t],0,ue,t),d=n),e.hasOwnProperty(t="ROUNDING_MODE")&&(he(n=e[t],0,8,t),y=n),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((n=e[t])&&n.pop?(he(n[0],-ue,0,t),he(n[1],0,ue,t),g=n[0],m=n[1]):(he(n,-ue,ue,t),g=-(m=n<0?-n:n))),e.hasOwnProperty(t="RANGE"))if((n=e[t])&&n.pop)he(n[0],-ue,-1,t),he(n[1],1,ue,t),v=n[0],b=n[1];else{if(he(n,-ue,ue,t),!n)throw Error(ne+t+" cannot be zero: "+n);v=-(b=n<0?-n:n)}if(e.hasOwnProperty(t="CRYPTO")){if((n=e[t])!==!!n)throw Error(ne+t+" not true or false: "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw E=!n,Error(ne+"crypto unavailable");E=n}else E=n}if(e.hasOwnProperty(t="MODULO_MODE")&&(he(n=e[t],0,9,t),S=n),e.hasOwnProperty(t="POW_PRECISION")&&(he(n=e[t],0,ue,t),w=n),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(n=e[t]))throw Error(ne+t+" not an object: "+n);P=n}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(n=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(n))throw Error(ne+t+" invalid: "+n);x="0123456789"==n.slice(0,10),O=n}}return{DECIMAL_PLACES:d,ROUNDING_MODE:y,EXPONENTIAL_AT:[g,m],RANGE:[v,b],CRYPTO:E,MODULO_MODE:S,POW_PRECISION:w,FORMAT:P,ALPHABET:O}},_.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!_.DEBUG)return!0;var t,n,r=e.c,i=e.e,o=e.s;e:if("[object Array]"=={}.toString.call(r)){if((1===o||-1===o)&&i>=-ue&&i<=ue&&i===te(i)){if(0===r[0]){if(0===i&&1===r.length)return!0;break e}if((t=(i+1)%oe)<1&&(t+=oe),String(r[0]).length==t){for(t=0;t<r.length;t++)if((n=r[t])<0||n>=ie||n!==te(n))break e;if(0!==n)return!0}}}else if(null===r&&null===i&&(null===o||1===o||-1===o))return!0;throw Error(ne+"Invalid BigNumber: "+e)},_.maximum=_.max=function(){return T(arguments,-1)},_.minimum=_.min=function(){return T(arguments,1)},_.random=(o=9007199254740992,a=Math.random()*o&2097151?function(){return te(Math.random()*o)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,n,r,i,o,s=0,l=[],u=new _(h);if(null==e?e=d:he(e,0,ue),i=ee(e/oe),E)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(i*=2));s<i;)(o=131072*t[s]+(t[s+1]>>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),t[s]=n[0],t[s+1]=n[1]):(l.push(o%1e14),s+=2);s=i/2}else{if(!crypto.randomBytes)throw E=!1,Error(ne+"crypto unavailable");for(t=crypto.randomBytes(i*=7);s<i;)(o=281474976710656*(31&t[s])+1099511627776*t[s+1]+4294967296*t[s+2]+16777216*t[s+3]+(t[s+4]<<16)+(t[s+5]<<8)+t[s+6])>=9e15?crypto.randomBytes(7).copy(t,s):(l.push(o%1e14),s+=7);s=i/7}if(!E)for(;s<i;)(o=a())<9e15&&(l[s++]=o%1e14);for(i=l[--s],e%=oe,i&&e&&(o=se[oe-e],l[s]=te(i/o)*o);0===l[s];l.pop(),s--);if(s<0)l=[r=0];else{for(r=-1;0===l[0];l.splice(0,1),r-=oe);for(s=1,o=l[0];o>=10;o/=10,s++);s<oe&&(r-=oe-s)}return u.e=r,u.c=l,u}),_.sum=function(){for(var e=1,t=arguments,n=new _(t[0]);e<t.length;)n=n.plus(t[e++]);return n},r=function(){var e="0123456789";function t(e,t,n,r){for(var i,o,a=[0],s=0,l=e.length;s<l;){for(o=a.length;o--;a[o]*=t);for(a[0]+=r.indexOf(e.charAt(s++)),i=0;i<a.length;i++)a[i]>n-1&&(null==a[i+1]&&(a[i+1]=0),a[i+1]+=a[i]/n|0,a[i]%=n)}return a.reverse()}return function(r,i,o,a,s){var l,u,c,f,p,h,g,m,v=r.indexOf("."),b=d,E=y;for(v>=0&&(f=w,w=0,r=r.replace(".",""),h=(m=new _(i)).pow(r.length-v),w=f,m.c=t(ge(fe(h.c),h.e,"0"),10,o,e),m.e=m.c.length),c=f=(g=t(r,i,o,s?(l=O,e):(l=e,O))).length;0==g[--f];g.pop());if(!g[0])return l.charAt(0);if(v<0?--c:(h.c=g,h.e=c,h.s=a,g=(h=n(h,m,b,E,o)).c,p=h.r,c=h.e),v=g[u=c+b+1],f=o/2,p=p||u<0||null!=g[u+1],p=E<4?(null!=v||p)&&(0==E||E==(h.s<0?3:2)):v>f||v==f&&(4==E||p||6==E&&1&g[u-1]||E==(h.s<0?8:7)),u<1||!g[0])r=p?ge(l.charAt(1),-b,l.charAt(0)):l.charAt(0);else{if(g.length=u,p)for(--o;++g[--u]>o;)g[u]=0,u||(++c,g=[1].concat(g));for(f=g.length;!g[--f];);for(v=0,r="";v<=f;r+=l.charAt(g[v++]));r=ge(r,c,l.charAt(0))}return r}}(),n=function(){function e(e,t,n){var r,i,o,a,s=0,l=e.length,u=t%le,c=t/le|0;for(e=e.slice();l--;)s=((i=u*(o=e[l]%le)+(r=c*o+(a=e[l]/le|0)*u)%le*le+s)/n|0)+(r/le|0)+c*a,e[l]=i%n;return s&&(e=[s].concat(e)),e}function t(e,t,n,r){var i,o;if(n!=r)o=n>r?1:-1;else for(i=o=0;i<n;i++)if(e[i]!=t[i]){o=e[i]>t[i]?1:-1;break}return o}function n(e,t,n,r){for(var i=0;n--;)e[n]-=i,i=e[n]<t[n]?1:0,e[n]=i*r+e[n]-t[n];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(r,i,o,a,s){var l,u,c,f,p,h,d,y,g,m,v,b,E,S,w,P,O,x=r.s==i.s?1:-1,A=r.c,T=i.c;if(!(A&&A[0]&&T&&T[0]))return new _(r.s&&i.s&&(A?!T||A[0]!=T[0]:T)?A&&0==A[0]||!T?0*x:x/0:NaN);for(g=(y=new _(x)).c=[],x=o+(u=r.e-i.e)+1,s||(s=ie,u=ce(r.e/oe)-ce(i.e/oe),x=x/oe|0),c=0;T[c]==(A[c]||0);c++);if(T[c]>(A[c]||0)&&u--,x<0)g.push(1),f=!0;else{for(S=A.length,P=T.length,c=0,x+=2,(p=te(s/(T[0]+1)))>1&&(T=e(T,p,s),A=e(A,p,s),P=T.length,S=A.length),E=P,v=(m=A.slice(0,P)).length;v<P;m[v++]=0);O=T.slice(),O=[0].concat(O),w=T[0],T[1]>=s/2&&w++;do{if(p=0,(l=t(T,m,P,v))<0){if(b=m[0],P!=v&&(b=b*s+(m[1]||0)),(p=te(b/w))>1)for(p>=s&&(p=s-1),d=(h=e(T,p,s)).length,v=m.length;1==t(h,m,d,v);)p--,n(h,P<d?O:T,d,s),d=h.length,l=1;else 0==p&&(l=p=1),d=(h=T.slice()).length;if(d<v&&(h=[0].concat(h)),n(m,h,v,s),v=m.length,-1==l)for(;t(T,m,P,v)<1;)p++,n(m,P<v?O:T,v,s),v=m.length}else 0===l&&(p++,m=[0]);g[c++]=p,m[0]?m[v++]=A[E]||0:(m=[A[E]],v=1)}while((E++<S||null!=m[0])&&x--);f=null!=m[0],g[0]||g.splice(0,1)}if(s==ie){for(c=1,x=g[0];x>=10;x/=10,c++);k(y,o+(y.e=c+u*oe-1)+1,a,f)}else y.e=u,y.r=+f;return y}}(),s=/^(-?)0([xbo])(?=\w[\w.]*$)/i,l=/^([^.]+)\.$/,u=/^\.([^.]+)$/,c=/^-?(Infinity|NaN)$/,f=/^\s*\+(?=[\w.])|^\s+|\s+$/g,i=function(e,t,n,r){var i,o=n?t:t.replace(f,"");if(c.test(o))e.s=isNaN(o)?null:o<0?-1:1;else{if(!n&&(o=o.replace(s,function(e,t,n){return i="x"==(n=n.toLowerCase())?16:"b"==n?2:8,r&&r!=i?e:t}),r&&(i=r,o=o.replace(l,"$1").replace(u,"0.$1")),t!=o))return new _(o,i);if(_.DEBUG)throw Error(ne+"Not a"+(r?" base "+r:"")+" number: "+t);e.s=null}e.c=e.e=null},p.absoluteValue=p.abs=function(){var e=new _(this);return e.s<0&&(e.s=1),e},p.comparedTo=function(e,t){return pe(this,new _(e,t))},p.decimalPlaces=p.dp=function(e,t){var n,r,i,o=this;if(null!=e)return he(e,0,ue),null==t?t=y:he(t,0,8),k(new _(o),e+o.e+1,t);if(!(n=o.c))return null;if(r=((i=n.length-1)-ce(this.e/oe))*oe,i=n[i])for(;i%10==0;i/=10,r--);return r<0&&(r=0),r},p.dividedBy=p.div=function(e,t){return n(this,new _(e,t),d,y)},p.dividedToIntegerBy=p.idiv=function(e,t){return n(this,new _(e,t),0,1)},p.exponentiatedBy=p.pow=function(e,t){var n,r,i,o,a,s,l,u,c=this;if((e=new _(e)).c&&!e.isInteger())throw Error(ne+"Exponent not an integer: "+I(e));if(null!=t&&(t=new _(t)),a=e.e>14,!c.c||!c.c[0]||1==c.c[0]&&!c.e&&1==c.c.length||!e.c||!e.c[0])return u=new _(Math.pow(+I(c),a?e.s*(2-de(e)):+I(e))),t?u.mod(t):u;if(s=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new _(NaN);(r=!s&&c.isInteger()&&t.isInteger())&&(c=c.mod(t))}else{if(e.e>9&&(c.e>0||c.e<-1||(0==c.e?c.c[0]>1||a&&c.c[1]>=24e7:c.c[0]<8e13||a&&c.c[0]<=9999975e7)))return o=c.s<0&&de(e)?-0:0,c.e>-1&&(o=1/o),new _(s?1/o:o);w&&(o=ee(w/oe+2))}for(a?(n=new _(.5),s&&(e.s=1),l=de(e)):l=(i=Math.abs(+I(e)))%2,u=new _(h);;){if(l){if(!(u=u.times(c)).c)break;o?u.c.length>o&&(u.c.length=o):r&&(u=u.mod(t))}if(i){if(0===(i=te(i/2)))break;l=i%2}else if(k(e=e.times(n),e.e+1,1),e.e>14)l=de(e);else{if(0===(i=+I(e)))break;l=i%2}c=c.times(c),o?c.c&&c.c.length>o&&(c.c.length=o):r&&(c=c.mod(t))}return r?u:(s&&(u=h.div(u)),t?u.mod(t):o?k(u,w,y,void 0):u)},p.integerValue=function(e){var t=new _(this);return null==e?e=y:he(e,0,8),k(t,t.e+1,e)},p.isEqualTo=p.eq=function(e,t){return 0===pe(this,new _(e,t))},p.isFinite=function(){return!!this.c},p.isGreaterThan=p.gt=function(e,t){return pe(this,new _(e,t))>0},p.isGreaterThanOrEqualTo=p.gte=function(e,t){return 1===(t=pe(this,new _(e,t)))||0===t},p.isInteger=function(){return!!this.c&&ce(this.e/oe)>this.c.length-2},p.isLessThan=p.lt=function(e,t){return pe(this,new _(e,t))<0},p.isLessThanOrEqualTo=p.lte=function(e,t){return-1===(t=pe(this,new _(e,t)))||0===t},p.isNaN=function(){return!this.s},p.isNegative=function(){return this.s<0},p.isPositive=function(){return this.s>0},p.isZero=function(){return!!this.c&&0==this.c[0]},p.minus=function(e,t){var n,r,i,o,a=this,s=a.s;if(t=(e=new _(e,t)).s,!s||!t)return new _(NaN);if(s!=t)return e.s=-t,a.plus(e);var l=a.e/oe,u=e.e/oe,c=a.c,f=e.c;if(!l||!u){if(!c||!f)return c?(e.s=-t,e):new _(f?a:NaN);if(!c[0]||!f[0])return f[0]?(e.s=-t,e):new _(c[0]?a:3==y?-0:0)}if(l=ce(l),u=ce(u),c=c.slice(),s=l-u){for((o=s<0)?(s=-s,i=c):(u=l,i=f),i.reverse(),t=s;t--;i.push(0));i.reverse()}else for(r=(o=(s=c.length)<(t=f.length))?s:t,s=t=0;t<r;t++)if(c[t]!=f[t]){o=c[t]<f[t];break}if(o&&(i=c,c=f,f=i,e.s=-e.s),(t=(r=f.length)-(n=c.length))>0)for(;t--;c[n++]=0);for(t=ie-1;r>s;){if(c[--r]<f[r]){for(n=r;n&&!c[--n];c[n]=t);--c[n],c[r]+=ie}c[r]-=f[r]}for(;0==c[0];c.splice(0,1),--u);return c[0]?C(e,c,u):(e.s=3==y?-1:1,e.c=[e.e=0],e)},p.modulo=p.mod=function(e,t){var r,i,o=this;return e=new _(e,t),!o.c||!e.s||e.c&&!e.c[0]?new _(NaN):!e.c||o.c&&!o.c[0]?new _(o):(9==S?(i=e.s,e.s=1,r=n(o,e,0,3),e.s=i,r.s*=i):r=n(o,e,0,S),(e=o.minus(r.times(e))).c[0]||1!=S||(e.s=o.s),e)},p.multipliedBy=p.times=function(e,t){var n,r,i,o,a,s,l,u,c,f,p,h,d,y,g,m=this,v=m.c,b=(e=new _(e,t)).c;if(!(v&&b&&v[0]&&b[0]))return!m.s||!e.s||v&&!v[0]&&!b||b&&!b[0]&&!v?e.c=e.e=e.s=null:(e.s*=m.s,v&&b?(e.c=[0],e.e=0):e.c=e.e=null),e;for(r=ce(m.e/oe)+ce(e.e/oe),e.s*=m.s,(l=v.length)<(f=b.length)&&(d=v,v=b,b=d,i=l,l=f,f=i),i=l+f,d=[];i--;d.push(0));for(y=ie,g=le,i=f;--i>=0;){for(n=0,p=b[i]%g,h=b[i]/g|0,o=i+(a=l);o>i;)n=((u=p*(u=v[--a]%g)+(s=h*u+(c=v[a]/g|0)*p)%g*g+d[o]+n)/y|0)+(s/g|0)+h*c,d[o--]=u%y;d[o]=n}return n?++r:d.splice(0,1),C(e,d,r)},p.negated=function(){var e=new _(this);return e.s=-e.s||null,e},p.plus=function(e,t){var n,r=this,i=r.s;if(t=(e=new _(e,t)).s,!i||!t)return new _(NaN);if(i!=t)return e.s=-t,r.minus(e);var o=r.e/oe,a=e.e/oe,s=r.c,l=e.c;if(!o||!a){if(!s||!l)return new _(i/0);if(!s[0]||!l[0])return l[0]?e:new _(s[0]?r:0*i)}if(o=ce(o),a=ce(a),s=s.slice(),i=o-a){for(i>0?(a=o,n=l):(i=-i,n=s),n.reverse();i--;n.push(0));n.reverse()}for((i=s.length)-(t=l.length)<0&&(n=l,l=s,s=n,t=i),i=0;t;)i=(s[--t]=s[t]+l[t]+i)/ie|0,s[t]=ie===s[t]?0:s[t]%ie;return i&&(s=[i].concat(s),++a),C(e,s,a)},p.precision=p.sd=function(e,t){var n,r,i,o=this;if(null!=e&&e!==!!e)return he(e,1,ue),null==t?t=y:he(t,0,8),k(new _(o),e,t);if(!(n=o.c))return null;if(r=(i=n.length-1)*oe+1,i=n[i]){for(;i%10==0;i/=10,r--);for(i=n[0];i>=10;i/=10,r++);}return e&&o.e+1>r&&(r=o.e+1),r},p.shiftedBy=function(e){return he(e,-9007199254740991,ae),this.times("1e"+e)},p.squareRoot=p.sqrt=function(){var e,t,r,i,o,a=this,s=a.c,l=a.s,u=a.e,c=d+4,f=new _("0.5");if(1!==l||!s||!s[0])return new _(!l||l<0&&(!s||s[0])?NaN:s?a:1/0);if(0==(l=Math.sqrt(+I(a)))||l==1/0?(((t=fe(s)).length+u)%2==0&&(t+="0"),l=Math.sqrt(+t),u=ce((u+1)/2)-(u<0||u%2),r=new _(t=l==1/0?"5e"+u:(t=l.toExponential()).slice(0,t.indexOf("e")+1)+u)):r=new _(l+""),r.c[0])for((l=(u=r.e)+c)<3&&(l=0);;)if(o=r,r=f.times(o.plus(n(a,o,c,1))),fe(o.c).slice(0,l)===(t=fe(r.c)).slice(0,l)){if(r.e<u&&--l,"9999"!=(t=t.slice(l-3,l+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(k(r,r.e+d+2,1),e=!r.times(r).eq(a));break}if(!i&&(k(o,o.e+d+2,0),o.times(o).eq(a))){r=o;break}c+=4,l+=4,i=1}return k(r,r.e+d+1,y,e)},p.toExponential=function(e,t){return null!=e&&(he(e,0,ue),e++),A(this,e,t,1)},p.toFixed=function(e,t){return null!=e&&(he(e,0,ue),e=e+this.e+1),A(this,e,t)},p.toFormat=function(e,t,n){var r,i=this;if(null==n)null!=e&&t&&"object"==typeof t?(n=t,t=null):e&&"object"==typeof e?(n=e,e=t=null):n=P;else if("object"!=typeof n)throw Error(ne+"Argument not an object: "+n);if(r=i.toFixed(e,t),i.c){var o,a=r.split("."),s=+n.groupSize,l=+n.secondaryGroupSize,u=n.groupSeparator||"",c=a[0],f=a[1],p=i.s<0,h=p?c.slice(1):c,d=h.length;if(l&&(o=s,s=l,l=o,d-=o),s>0&&d>0){for(o=d%s||s,c=h.substr(0,o);o<d;o+=s)c+=u+h.substr(o,s);l>0&&(c+=u+h.slice(o)),p&&(c="-"+c)}r=f?c+(n.decimalSeparator||"")+((l=+n.fractionGroupSize)?f.replace(new RegExp("\\d{"+l+"}\\B","g"),"$&"+(n.fractionGroupSeparator||"")):f):c}return(n.prefix||"")+r+(n.suffix||"")},p.toFraction=function(e){var t,r,i,o,a,s,l,u,c,f,p,d,g=this,m=g.c;if(null!=e&&(!(l=new _(e)).isInteger()&&(l.c||1!==l.s)||l.lt(h)))throw Error(ne+"Argument "+(l.isInteger()?"out of range: ":"not an integer: ")+I(l));if(!m)return new _(g);for(t=new _(h),c=r=new _(h),i=u=new _(h),d=fe(m),a=t.e=d.length-g.e-1,t.c[0]=se[(s=a%oe)<0?oe+s:s],e=!e||l.comparedTo(t)>0?a>0?t:c:l,s=b,b=1/0,l=new _(d),u.c[0]=0;f=n(l,t,0,1),1!=(o=r.plus(f.times(i))).comparedTo(e);)r=i,i=o,c=u.plus(f.times(o=c)),u=o,t=l.minus(f.times(o=t)),l=o;return o=n(e.minus(r),i,0,1),u=u.plus(o.times(c)),r=r.plus(o.times(i)),u.s=c.s=g.s,p=n(c,i,a*=2,y).minus(g).abs().comparedTo(n(u,r,a,y).minus(g).abs())<1?[c,i]:[u,r],b=s,p},p.toNumber=function(){return+I(this)},p.toPrecision=function(e,t){return null!=e&&he(e,1,ue),A(this,e,t,2)},p.toString=function(e){var t,n=this,i=n.s,o=n.e;return null===o?i?(t="Infinity",i<0&&(t="-"+t)):t="NaN":(null==e?t=o<=g||o>=m?ye(fe(n.c),o):ge(fe(n.c),o,"0"):10===e&&x?t=ge(fe((n=k(new _(n),d+o+1,y)).c),n.e,"0"):(he(e,2,O.length,"Base"),t=r(ge(fe(n.c),o,"0"),10,e,i,!0)),i<0&&n.c[0]&&(t="-"+t)),t},p.valueOf=p.toJSON=function(){return I(this)},p._isBigNumber=!0,p[Symbol.toStringTag]="BigNumber",p[Symbol.for("nodejs.util.inspect.custom")]=p.valueOf,null!=t&&_.set(t),_}();const ve=me;var be=class{key;left=null;right=null;constructor(e){this.key=e}},Ee=class extends be{constructor(e){super(e)}},Se=class{size=0;modificationCount=0;splayCount=0;splay(e){const t=this.root;if(null==t)return this.compare(e,e),-1;let n=null,r=null,i=null,o=null,a=t;const s=this.compare;let l;for(;;)if(l=s(a.key,e),l>0){let t=a.left;if(null==t)break;if(l=s(t.key,e),l>0&&(a.left=t.right,t.right=a,a=t,t=a.left,null==t))break;null==n?r=a:n.left=a,n=a,a=t}else{if(!(l<0))break;{let t=a.right;if(null==t)break;if(l=s(t.key,e),l<0&&(a.right=t.left,t.left=a,a=t,t=a.right,null==t))break;null==i?o=a:i.right=a,i=a,a=t}}return null!=i&&(i.right=a.left,a.left=o),null!=n&&(n.left=a.right,a.right=r),this.root!==a&&(this.root=a,this.splayCount++),l}splayMin(e){let t=e,n=t.left;for(;null!=n;){const e=n;t.left=e.right,e.right=t,t=e,n=t.left}return t}splayMax(e){let t=e,n=t.right;for(;null!=n;){const e=n;t.right=e.left,e.left=t,t=e,n=t.right}return t}_delete(e){if(null==this.root)return null;if(0!=this.splay(e))return null;let t=this.root;const n=t,r=t.left;if(this.size--,null==r)this.root=t.right;else{const e=t.right;t=this.splayMax(r),t.right=e,this.root=t}return this.modificationCount++,n}addNewRoot(e,t){this.size++,this.modificationCount++;const n=this.root;null!=n?(t<0?(e.left=n,e.right=n.right,n.right=null):(e.right=n,e.left=n.left,n.left=null),this.root=e):this.root=e}_first(){const e=this.root;return null==e?null:(this.root=this.splayMin(e),this.root)}_last(){const e=this.root;return null==e?null:(this.root=this.splayMax(e),this.root)}clear(){this.root=null,this.size=0,this.modificationCount++}has(e){return this.validKey(e)&&0==this.splay(e)}defaultCompare(){return(e,t)=>e<t?-1:e>t?1:0}wrap(){return{getRoot:()=>this.root,setRoot:e=>{this.root=e},getSize:()=>this.size,getModificationCount:()=>this.modificationCount,getSplayCount:()=>this.splayCount,setSplayCount:e=>{this.splayCount=e},splay:e=>this.splay(e),has:e=>this.has(e)}}},we=(Symbol.iterator,Symbol.toStringTag,class e extends Se{root=null;compare;validKey;constructor(e,t){super(),this.compare=e??this.defaultCompare(),this.validKey=t??(e=>null!=e&&null!=e)}delete(e){return!!this.validKey(e)&&null!=this._delete(e)}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){const t=this[Symbol.iterator]();let n;for(;n=t.next(),!n.done;)e(n.value,n.value,this)}add(e){const t=this.splay(e);return 0!=t&&this.addNewRoot(new Ee(e),t),this}addAndReturn(e){const t=this.splay(e);return 0!=t&&this.addNewRoot(new Ee(e),t),this.root.key}addAll(e){for(const t of e)this.add(t)}isEmpty(){return null==this.root}isNotEmpty(){return null!=this.root}single(){if(0==this.size)throw"Bad state: No element";if(this.size>1)throw"Bad state: Too many element";return this.root.key}first(){if(0==this.size)throw"Bad state: No element";return this._first().key}last(){if(0==this.size)throw"Bad state: No element";return this._last().key}lastBefore(e){if(null==e)throw"Invalid arguments(s)";if(null==this.root)return null;if(this.splay(e)<0)return this.root.key;let t=this.root.left;if(null==t)return null;let n=t.right;for(;null!=n;)t=n,n=t.right;return t.key}firstAfter(e){if(null==e)throw"Invalid arguments(s)";if(null==this.root)return null;if(this.splay(e)>0)return this.root.key;let t=this.root.right;if(null==t)return null;let n=t.left;for(;null!=n;)t=n,n=t.left;return t.key}retainAll(t){const n=new e(this.compare,this.validKey),r=this.modificationCount;for(const e of t){if(r!=this.modificationCount)throw"Concurrent modification during iteration.";this.validKey(e)&&0==this.splay(e)&&n.add(this.root.key)}n.size!=this.size&&(this.root=n.root,this.size=n.size,this.modificationCount++)}lookup(e){return this.validKey(e)?0!=this.splay(e)?null:this.root.key:null}intersection(t){const n=new e(this.compare,this.validKey);for(const e of this)t.has(e)&&n.add(e);return n}difference(t){const n=new e(this.compare,this.validKey);for(const e of this)t.has(e)||n.add(e);return n}union(e){const t=this.clone();return t.addAll(e),t}clone(){const t=new e(this.compare,this.validKey);return t.size=this.size,t.root=this.copyNode(this.root),t}copyNode(e){if(null==e)return null;const t=new Ee(e.key);return function e(t,n){let r,i;do{if(r=t.left,i=t.right,null!=r){const t=new Ee(r.key);n.left=t,e(r,t)}if(null!=i){const e=new Ee(i.key);n.right=e,t=i,n=e}}while(null!=i)}(e,t),t}toSet(){return this.clone()}entries(){return new xe(this.wrap())}keys(){return this[Symbol.iterator]()}values(){return this[Symbol.iterator]()}[Symbol.iterator](){return new Oe(this.wrap())}[Symbol.toStringTag]="[object Set]"}),Pe=class{tree;path=new Array;modificationCount=null;splayCount;constructor(e){this.tree=e,this.splayCount=e.getSplayCount()}[Symbol.iterator](){return this}next(){return this.moveNext()?{done:!1,value:this.current()}:{done:!0,value:null}}current(){if(!this.path.length)return null;const e=this.path[this.path.length-1];return this.getValue(e)}rebuildPath(e){this.path.splice(0,this.path.length),this.tree.splay(e),this.path.push(this.tree.getRoot()),this.splayCount=this.tree.getSplayCount()}findLeftMostDescendent(e){for(;null!=e;)this.path.push(e),e=e.left}moveNext(){if(this.modificationCount!=this.tree.getModificationCount()){if(null==this.modificationCount){this.modificationCount=this.tree.getModificationCount();let e=this.tree.getRoot();for(;null!=e;)this.path.push(e),e=e.left;return this.path.length>0}throw"Concurrent modification during iteration."}if(!this.path.length)return!1;this.splayCount!=this.tree.getSplayCount()&&this.rebuildPath(this.path[this.path.length-1].key);let e=this.path[this.path.length-1],t=e.right;if(null!=t){for(;null!=t;)this.path.push(t),t=t.left;return!0}for(this.path.pop();this.path.length&&this.path[this.path.length-1].right===e;)e=this.path.pop();return this.path.length>0}},Oe=class extends Pe{getValue(e){return e.key}},xe=class extends Pe{getValue(e){return[e.key,e.key]}},_e=e=>()=>e,Ae=e=>{const t=e?(t,n)=>n.minus(t).abs().isLessThanOrEqualTo(e):_e(!1);return(e,n)=>t(e,n)?0:e.comparedTo(n)};function Te(e){const t=e?(t,n,r,i,o)=>t.exponentiatedBy(2).isLessThanOrEqualTo(i.minus(n).exponentiatedBy(2).plus(o.minus(r).exponentiatedBy(2)).times(e)):_e(!1);return(e,n,r)=>{const i=e.x,o=e.y,a=r.x,s=r.y,l=o.minus(s).times(n.x.minus(a)).minus(i.minus(a).times(n.y.minus(s)));return t(l,i,o,a,s)?0:l.comparedTo(0)}}var Ce=e=>e,ke=e=>{if(e){const t=new we(Ae(e)),n=new we(Ae(e)),r=(e,t)=>t.addAndReturn(e),i=e=>({x:r(e.x,t),y:r(e.y,n)});return i({x:new ve(0),y:new ve(0)}),i}return Ce},Ie=e=>({set:e=>{je=Ie(e)},reset:()=>Ie(e),compare:Ae(e),snap:ke(e),orient:Te(e)}),je=Ie(),Me=(e,t)=>e.ll.x.isLessThanOrEqualTo(t.x)&&t.x.isLessThanOrEqualTo(e.ur.x)&&e.ll.y.isLessThanOrEqualTo(t.y)&&t.y.isLessThanOrEqualTo(e.ur.y),Le=(e,t)=>{if(t.ur.x.isLessThan(e.ll.x)||e.ur.x.isLessThan(t.ll.x)||t.ur.y.isLessThan(e.ll.y)||e.ur.y.isLessThan(t.ll.y))return null;const n=e.ll.x.isLessThan(t.ll.x)?t.ll.x:e.ll.x,r=e.ur.x.isLessThan(t.ur.x)?e.ur.x:t.ur.x;return{ll:{x:n,y:e.ll.y.isLessThan(t.ll.y)?t.ll.y:e.ll.y},ur:{x:r,y:e.ur.y.isLessThan(t.ur.y)?e.ur.y:t.ur.y}}},Re=(e,t)=>e.x.times(t.y).minus(e.y.times(t.x)),Ne=(e,t)=>e.x.times(t.x).plus(e.y.times(t.y)),De=e=>Ne(e,e).sqrt(),Ge=(e,t,n)=>{const r={x:t.x.minus(e.x),y:t.y.minus(e.y)},i={x:n.x.minus(e.x),y:n.y.minus(e.y)};return Re(i,r).div(De(i)).div(De(r))},Fe=(e,t,n)=>{const r={x:t.x.minus(e.x),y:t.y.minus(e.y)},i={x:n.x.minus(e.x),y:n.y.minus(e.y)};return Ne(i,r).div(De(i)).div(De(r))},Ve=(e,t,n)=>t.y.isZero()?null:{x:e.x.plus(t.x.div(t.y).times(n.minus(e.y))),y:n},Be=(e,t,n)=>t.x.isZero()?null:{x:n,y:e.y.plus(t.y.div(t.x).times(n.minus(e.x)))},Ue=class e{point;isLeft;segment;otherSE;consumedBy;static compare(t,n){const r=e.comparePoints(t.point,n.point);return 0!==r?r:(t.point!==n.point&&t.link(n),t.isLeft!==n.isLeft?t.isLeft?1:-1:Ke.compare(t.segment,n.segment))}static comparePoints(e,t){return e.x.isLessThan(t.x)?-1:e.x.isGreaterThan(t.x)?1:e.y.isLessThan(t.y)?-1:e.y.isGreaterThan(t.y)?1:0}constructor(e,t){void 0===e.events?e.events=[this]:e.events.push(this),this.point=e,this.isLeft=t}link(e){if(e.point===this.point)throw new Error("Tried to link already linked events");const t=e.point.events;for(let e=0,n=t.length;e<n;e++){const n=t[e];this.point.events.push(n),n.point=this.point}this.checkForConsuming()}checkForConsuming(){const e=this.point.events.length;for(let t=0;t<e;t++){const n=this.point.events[t];if(void 0===n.segment.consumedBy)for(let r=t+1;r<e;r++){const e=this.point.events[r];void 0===e.consumedBy&&n.otherSE.point.events===e.otherSE.point.events&&n.segment.consume(e.segment)}}}getAvailableLinkedEvents(){const e=[];for(let t=0,n=this.point.events.length;t<n;t++){const n=this.point.events[t];n!==this&&!n.segment.ringOut&&n.segment.isInResult()&&e.push(n)}return e}getLeftmostComparator(e){const t=new Map,n=n=>{const r=n.otherSE;t.set(n,{sine:Ge(this.point,e.point,r.point),cosine:Fe(this.point,e.point,r.point)})};return(e,r)=>{t.has(e)||n(e),t.has(r)||n(r);const{sine:i,cosine:o}=t.get(e),{sine:a,cosine:s}=t.get(r);return i.isGreaterThanOrEqualTo(0)&&a.isGreaterThanOrEqualTo(0)?o.isLessThan(s)?1:o.isGreaterThan(s)?-1:0:i.isLessThan(0)&&a.isLessThan(0)?o.isLessThan(s)?-1:o.isGreaterThan(s)?1:0:a.isLessThan(i)?-1:a.isGreaterThan(i)?1:0}}},He=class e{events;poly;_isExteriorRing;_enclosingRing;static factory(t){const n=[];for(let r=0,i=t.length;r<i;r++){const i=t[r];if(!i.isInResult()||i.ringOut)continue;let o=null,a=i.leftSE,s=i.rightSE;const l=[a],u=a.point,c=[];for(;o=a,a=s,l.push(a),a.point!==u;)for(;;){const t=a.getAvailableLinkedEvents();if(0===t.length){const e=l[0].point,t=l[l.length-1].point;throw new Error(`Unable to complete output ring starting at [${e.x}, ${e.y}]. Last matching segment found ends at [${t.x}, ${t.y}].`)}if(1===t.length){s=t[0].otherSE;break}let r=null;for(let e=0,t=c.length;e<t;e++)if(c[e].point===a.point){r=e;break}if(null!==r){const t=c.splice(r)[0],i=l.splice(t.index);i.unshift(i[0].otherSE),n.push(new e(i.reverse()));continue}c.push({index:l.length,point:a.point});const i=a.getLeftmostComparator(o);s=t.sort(i)[0].otherSE;break}n.push(new e(l))}return n}constructor(e){this.events=e;for(let t=0,n=e.length;t<n;t++)e[t].segment.ringOut=this;this.poly=null}getGeom(){let e=this.events[0].point;const t=[e];for(let n=1,r=this.events.length-1;n<r;n++){const r=this.events[n].point,i=this.events[n+1].point;0!==je.orient(r,e,i)&&(t.push(r),e=r)}if(1===t.length)return null;const n=t[0],r=t[1];0===je.orient(n,e,r)&&t.shift(),t.push(t[0]);const i=this.isExteriorRing()?1:-1,o=this.isExteriorRing()?0:t.length-1,a=this.isExteriorRing()?t.length:-1,s=[];for(let e=o;e!=a;e+=i)s.push([t[e].x.toNumber(),t[e].y.toNumber()]);return s}isExteriorRing(){if(void 0===this._isExteriorRing){const e=this.enclosingRing();this._isExteriorRing=!e||!e.isExteriorRing()}return this._isExteriorRing}enclosingRing(){return void 0===this._enclosingRing&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}_calcEnclosingRing(){let e=this.events[0];for(let t=1,n=this.events.length;t<n;t++){const n=this.events[t];Ue.compare(e,n)>0&&(e=n)}let t=e.segment.prevInResult(),n=t?t.prevInResult():null;for(;;){if(!t)return null;if(!n)return t.ringOut;if(n.ringOut!==t.ringOut)return n.ringOut?.enclosingRing()!==t.ringOut?t.ringOut:t.ringOut?.enclosingRing();t=n.prevInResult(),n=t?t.prevInResult():null}}},qe=class{exteriorRing;interiorRings;constructor(e){this.exteriorRing=e,e.poly=this,this.interiorRings=[]}addInterior(e){this.interiorRings.push(e),e.poly=this}getGeom(){const e=this.exteriorRing.getGeom();if(null===e)return null;const t=[e];for(let e=0,n=this.interiorRings.length;e<n;e++){const n=this.interiorRings[e].getGeom();null!==n&&t.push(n)}return t}},Ye=class{rings;polys;constructor(e){this.rings=e,this.polys=this._composePolys(e)}getGeom(){const e=[];for(let t=0,n=this.polys.length;t<n;t++){const n=this.polys[t].getGeom();null!==n&&e.push(n)}return e}_composePolys(e){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];if(!r.poly)if(r.isExteriorRing())t.push(new qe(r));else{const e=r.enclosingRing();e?.poly||t.push(new qe(e)),e?.poly?.addInterior(r)}}return t}},ze=class{queue;tree;segments;constructor(e,t=Ke.compare){this.queue=e,this.tree=new we(t),this.segments=[]}process(e){const t=e.segment,n=[];if(e.consumedBy)return e.isLeft?this.queue.delete(e.otherSE):this.tree.delete(t),n;e.isLeft&&this.tree.add(t);let r=t,i=t;do{r=this.tree.lastBefore(r)}while(null!=r&&null!=r.consumedBy);do{i=this.tree.firstAfter(i)}while(null!=i&&null!=i.consumedBy);if(e.isLeft){let o=null;if(r){const e=r.getIntersection(t);if(null!==e&&(t.isAnEndpoint(e)||(o=e),!r.isAnEndpoint(e))){const t=this._splitSafely(r,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}}let a=null;if(i){const e=i.getIntersection(t);if(null!==e&&(t.isAnEndpoint(e)||(a=e),!i.isAnEndpoint(e))){const t=this._splitSafely(i,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}}if(null!==o||null!==a){let e=null;e=null===o?a:null===a||Ue.comparePoints(o,a)<=0?o:a,this.queue.delete(t.rightSE),n.push(t.rightSE);const r=t.split(e);for(let e=0,t=r.length;e<t;e++)n.push(r[e])}n.length>0?(this.tree.delete(t),n.push(e)):(this.segments.push(t),t.prev=r)}else{if(r&&i){const e=r.getIntersection(i);if(null!==e){if(!r.isAnEndpoint(e)){const t=this._splitSafely(r,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}if(!i.isAnEndpoint(e)){const t=this._splitSafely(i,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}}}this.tree.delete(t)}return n}_splitSafely(e,t){this.tree.delete(e);const n=e.rightSE;this.queue.delete(n);const r=e.split(t);return r.push(n),void 0===e.consumedBy&&this.tree.add(e),r}},We=new class{type;numMultiPolys;run(e,t,n){We.type=e;const r=[new Qe(t,!0)];for(let e=0,t=n.length;e<t;e++)r.push(new Qe(n[e],!1));if(We.numMultiPolys=r.length,"difference"===We.type){const e=r[0];let t=1;for(;t<r.length;)null!==Le(r[t].bbox,e.bbox)?t++:r.splice(t,1)}if("intersection"===We.type)for(let e=0,t=r.length;e<t;e++){const t=r[e];for(let n=e+1,i=r.length;n<i;n++)if(null===Le(t.bbox,r[n].bbox))return[]}const i=new we(Ue.compare);for(let e=0,t=r.length;e<t;e++){const t=r[e].getSweepEvents();for(let e=0,n=t.length;e<n;e++)i.add(t[e])}const o=new ze(i);let a=null;for(0!=i.size&&(a=i.first(),i.delete(a));a;){const e=o.process(a);for(let t=0,n=e.length;t<n;t++){const n=e[t];void 0===n.consumedBy&&i.add(n)}0!=i.size?(a=i.first(),i.delete(a)):a=null}je.reset();const s=He.factory(o.segments);return new Ye(s).getGeom()}},$e=We,Xe=0,Ke=class e{id;leftSE;rightSE;rings;windings;ringOut;consumedBy;prev;_prevInResult;_beforeState;_afterState;_isInResult;static compare(e,t){const n=e.leftSE.point.x,r=t.leftSE.point.x,i=e.rightSE.point.x,o=t.rightSE.point.x;if(o.isLessThan(n))return 1;if(i.isLessThan(r))return-1;const a=e.leftSE.point.y,s=t.leftSE.point.y,l=e.rightSE.point.y,u=t.rightSE.point.y;if(n.isLessThan(r)){if(s.isLessThan(a)&&s.isLessThan(l))return 1;if(s.isGreaterThan(a)&&s.isGreaterThan(l))return-1;const n=e.comparePoint(t.leftSE.point);if(n<0)return 1;if(n>0)return-1;const r=t.comparePoint(e.rightSE.point);return 0!==r?r:-1}if(n.isGreaterThan(r)){if(a.isLessThan(s)&&a.isLessThan(u))return-1;if(a.isGreaterThan(s)&&a.isGreaterThan(u))return 1;const n=t.comparePoint(e.leftSE.point);if(0!==n)return n;const r=e.comparePoint(t.rightSE.point);return r<0?1:r>0?-1:1}if(a.isLessThan(s))return-1;if(a.isGreaterThan(s))return 1;if(i.isLessThan(o)){const n=t.comparePoint(e.rightSE.point);if(0!==n)return n}if(i.isGreaterThan(o)){const n=e.comparePoint(t.rightSE.point);if(n<0)return 1;if(n>0)return-1}if(!i.eq(o)){const e=l.minus(a),t=i.minus(n),c=u.minus(s),f=o.minus(r);if(e.isGreaterThan(t)&&c.isLessThan(f))return 1;if(e.isLessThan(t)&&c.isGreaterThan(f))return-1}return i.isGreaterThan(o)?1:i.isLessThan(o)||l.isLessThan(u)?-1:l.isGreaterThan(u)?1:e.id<t.id?-1:e.id>t.id?1:0}constructor(e,t,n,r){this.id=++Xe,this.leftSE=e,e.segment=this,e.otherSE=t,this.rightSE=t,t.segment=this,t.otherSE=e,this.rings=n,this.windings=r}static fromRing(t,n,r){let i,o,a;const s=Ue.comparePoints(t,n);if(s<0)i=t,o=n,a=1;else{if(!(s>0))throw new Error(`Tried to create degenerate segment at [${t.x}, ${t.y}]`);i=n,o=t,a=-1}const l=new Ue(i,!0),u=new Ue(o,!1);return new e(l,u,[r],[a])}replaceRightSE(e){this.rightSE=e,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){const e=this.leftSE.point.y,t=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:e.isLessThan(t)?e:t},ur:{x:this.rightSE.point.x,y:e.isGreaterThan(t)?e:t}}}vector(){return{x:this.rightSE.point.x.minus(this.leftSE.point.x),y:this.rightSE.point.y.minus(this.leftSE.point.y)}}isAnEndpoint(e){return e.x.eq(this.leftSE.point.x)&&e.y.eq(this.leftSE.point.y)||e.x.eq(this.rightSE.point.x)&&e.y.eq(this.rightSE.point.y)}comparePoint(e){return je.orient(this.leftSE.point,e,this.rightSE.point)}getIntersection(e){const t=this.bbox(),n=e.bbox(),r=Le(t,n);if(null===r)return null;const i=this.leftSE.point,o=this.rightSE.point,a=e.leftSE.point,s=e.rightSE.point,l=Me(t,a)&&0===this.comparePoint(a),u=Me(n,i)&&0===e.comparePoint(i),c=Me(t,s)&&0===this.comparePoint(s),f=Me(n,o)&&0===e.comparePoint(o);if(u&&l)return f&&!c?o:!f&&c?s:null;if(u)return c&&i.x.eq(s.x)&&i.y.eq(s.y)?null:i;if(l)return f&&o.x.eq(a.x)&&o.y.eq(a.y)?null:a;if(f&&c)return null;if(f)return o;if(c)return s;const p=((e,t,n,r)=>{if(t.x.isZero())return Be(n,r,e.x);if(r.x.isZero())return Be(e,t,n.x);if(t.y.isZero())return Ve(n,r,e.y);if(r.y.isZero())return Ve(e,t,n.y);const i=Re(t,r);if(i.isZero())return null;const o={x:n.x.minus(e.x),y:n.y.minus(e.y)},a=Re(o,t).div(i),s=Re(o,r).div(i),l=e.x.plus(s.times(t.x)),u=n.x.plus(a.times(r.x)),c=e.y.plus(s.times(t.y)),f=n.y.plus(a.times(r.y));return{x:l.plus(u).div(2),y:c.plus(f).div(2)}})(i,this.vector(),a,e.vector());return null===p?null:Me(r,p)?je.snap(p):null}split(t){const n=[],r=void 0!==t.events,i=new Ue(t,!0),o=new Ue(t,!1),a=this.rightSE;this.replaceRightSE(o),n.push(o),n.push(i);const s=new e(i,a,this.rings.slice(),this.windings.slice());return Ue.comparePoints(s.leftSE.point,s.rightSE.point)>0&&s.swapEvents(),Ue.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),r&&(i.checkForConsuming(),o.checkForConsuming()),n}swapEvents(){const e=this.rightSE;this.rightSE=this.leftSE,this.leftSE=e,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let e=0,t=this.windings.length;e<t;e++)this.windings[e]*=-1}consume(t){let n=this,r=t;for(;n.consumedBy;)n=n.consumedBy;for(;r.consumedBy;)r=r.consumedBy;const i=e.compare(n,r);if(0!==i){if(i>0){const e=n;n=r,r=e}if(n.prev===r){const e=n;n=r,r=e}for(let e=0,t=r.rings.length;e<t;e++){const t=r.rings[e],i=r.windings[e],o=n.rings.indexOf(t);-1===o?(n.rings.push(t),n.windings.push(i)):n.windings[o]+=i}r.rings=null,r.windings=null,r.consumedBy=n,r.leftSE.consumedBy=n.leftSE,r.rightSE.consumedBy=n.rightSE}}prevInResult(){return void 0!==this._prevInResult||(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null),this._prevInResult}beforeState(){if(void 0!==this._beforeState)return this._beforeState;if(this.prev){const e=this.prev.consumedBy||this.prev;this._beforeState=e.afterState()}else this._beforeState={rings:[],windings:[],multiPolys:[]};return this._beforeState}afterState(){if(void 0!==this._afterState)return this._afterState;const e=this.beforeState();this._afterState={rings:e.rings.slice(0),windings:e.windings.slice(0),multiPolys:[]};const t=this._afterState.rings,n=this._afterState.windings,r=this._afterState.multiPolys;for(let e=0,r=this.rings.length;e<r;e++){const r=this.rings[e],i=this.windings[e],o=t.indexOf(r);-1===o?(t.push(r),n.push(i)):n[o]+=i}const i=[],o=[];for(let e=0,r=t.length;e<r;e++){if(0===n[e])continue;const r=t[e],a=r.poly;if(-1===o.indexOf(a))if(r.isExterior)i.push(a);else{-1===o.indexOf(a)&&o.push(a);const e=i.indexOf(r.poly);-1!==e&&i.splice(e,1)}}for(let e=0,t=i.length;e<t;e++){const t=i[e].multiPoly;-1===r.indexOf(t)&&r.push(t)}return this._afterState}isInResult(){if(this.consumedBy)return!1;if(void 0!==this._isInResult)return this._isInResult;const e=this.beforeState().multiPolys,t=this.afterState().multiPolys;switch($e.type){case"union":{const n=0===e.length,r=0===t.length;this._isInResult=n!==r;break}case"intersection":{let n,r;e.length<t.length?(n=e.length,r=t.length):(n=t.length,r=e.length),this._isInResult=r===$e.numMultiPolys&&n<r;break}case"xor":{const n=Math.abs(e.length-t.length);this._isInResult=n%2==1;break}case"difference":{const n=e=>1===e.length&&e[0].isSubject;this._isInResult=n(e)!==n(t);break}}return this._isInResult}},Ze=class{poly;isExterior;segments;bbox;constructor(e,t,n){if(!Array.isArray(e)||0===e.length)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=t,this.isExterior=n,this.segments=[],"number"!=typeof e[0][0]||"number"!=typeof e[0][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const r=je.snap({x:new ve(e[0][0]),y:new ve(e[0][1])});this.bbox={ll:{x:r.x,y:r.y},ur:{x:r.x,y:r.y}};let i=r;for(let t=1,n=e.length;t<n;t++){if("number"!=typeof e[t][0]||"number"!=typeof e[t][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const n=je.snap({x:new ve(e[t][0]),y:new ve(e[t][1])});n.x.eq(i.x)&&n.y.eq(i.y)||(this.segments.push(Ke.fromRing(i,n,this)),n.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=n.x),n.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=n.y),n.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=n.x),n.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=n.y),i=n)}r.x.eq(i.x)&&r.y.eq(i.y)||this.segments.push(Ke.fromRing(i,r,this))}getSweepEvents(){const e=[];for(let t=0,n=this.segments.length;t<n;t++){const n=this.segments[t];e.push(n.leftSE),e.push(n.rightSE)}return e}},Je=class{multiPoly;exteriorRing;interiorRings;bbox;constructor(e,t){if(!Array.isArray(e))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new Ze(e[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(let t=1,n=e.length;t<n;t++){const n=new Ze(e[t],this,!1);n.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=n.bbox.ll.x),n.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=n.bbox.ll.y),n.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=n.bbox.ur.x),n.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=n.bbox.ur.y),this.interiorRings.push(n)}this.multiPoly=t}getSweepEvents(){const e=this.exteriorRing.getSweepEvents();for(let t=0,n=this.interiorRings.length;t<n;t++){const n=this.interiorRings[t].getSweepEvents();for(let t=0,r=n.length;t<r;t++)e.push(n[t])}return e}},Qe=class{isSubject;polys;bbox;constructor(e,t){if(!Array.isArray(e))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{"number"==typeof e[0][0][0]&&(e=[e])}catch(e){}this.polys=[],this.bbox={ll:{x:new ve(Number.POSITIVE_INFINITY),y:new ve(Number.POSITIVE_INFINITY)},ur:{x:new ve(Number.NEGATIVE_INFINITY),y:new ve(Number.NEGATIVE_INFINITY)}};for(let t=0,n=e.length;t<n;t++){const n=new Je(e[t],this);n.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=n.bbox.ll.x),n.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=n.bbox.ll.y),n.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=n.bbox.ur.x),n.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=n.bbox.ur.y),this.polys.push(n)}this.isSubject=t}getSweepEvents(){const e=[];for(let t=0,n=this.polys.length;t<n;t++){const n=this.polys[t].getSweepEvents();for(let t=0,r=n.length;t<r;t++)e.push(n[t])}return e}};je.set;function et(e,t,n={}){const r={type:"Feature"};return(0===n.id||n.id)&&(r.id=n.id),n.bbox&&(r.bbox=n.bbox),r.properties=t||{},r.geometry=e,r}Math.PI;var tt=function(e,t={}){const n=[];if(function(e,t){var n,r,i,o,a,s,l,u,c,f,p=0,h="FeatureCollection"===e.type,d="Feature"===e.type,y=h?e.features.length:1;for(n=0;n<y;n++){for(s=h?e.features[n].geometry:d?e.geometry:e,u=h?e.features[n].properties:d?e.properties:{},c=h?e.features[n].bbox:d?e.bbox:void 0,f=h?e.features[n].id:d?e.id:void 0,a=(l=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,i=0;i<a;i++)if(null!==(o=l?s.geometries[i]:s))switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(o,p,u,c,f))return!1;break;case"GeometryCollection":for(r=0;r<o.geometries.length;r++)if(!1===t(o.geometries[r],p,u,c,f))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,u,c,f))return!1;p++}}(e,e=>{n.push(e.coordinates)}),n.length<2)throw new Error("Must have at least 2 geometries");const r=((e,...t)=>$e.run("union",e,t))(n[0],...n.slice(1));return 0===r.length?null:1===r.length?function(e,t,n={}){for(const t of e){if(t.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(t[t.length-1].length!==t[0].length)throw new Error("First and last Position are not equivalent.");for(let e=0;e<t[t.length-1].length;e++)if(t[t.length-1][e]!==t[0][e])throw new Error("First and last Position are not equivalent.")}return et({type:"Polygon",coordinates:e},t,n)}(r[0],t.properties):function(e,t,n={}){return et({type:"MultiPolygon",coordinates:e},t,n)}(r,t.properties)},nt=n(278);function rt(e){return rt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},rt(e)}function it(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){u=!0,i=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||ut(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ot(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function at(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ot(Object(n),!0).forEach(function(t){st(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ot(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function st(e,t,n){return(t=function(e){var t=function(e){if("object"!=rt(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=rt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==rt(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function lt(e){return function(e){if(Array.isArray(e))return ct(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||ut(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ut(e,t){if(e){if("string"==typeof e)return ct(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ct(e,t):void 0}}function ct(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var ft=function(e,t){var n,r,i,o,a=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.01,n=e.geometry.coordinates.map(function(e){return lt(e)}),r=n.length-1,i=function(e,n){return[e[0]+(e[0]-n[0])*t,e[1]+(e[1]-n[1])*t]},o=i(n[0],n[1]),a=i(n[r],n[r-1]);return n[0]=o,n[r]=a,(0,nt.wi)(n)}(t);try{o=function(e,t){var n=[],r=[],i=[],o=function(e,t,n,r,i){for(var o=0,a=[],s="Feature"===t.type?t.geometry:t,l="LineString"===s.type?[s.coordinates]:s.coordinates,u=0,c=0;c<l.length;c++){for(var f=l[c].length-1,p=new D(l[c][0]),h=null,d={nextEdge:null},y=0;y<f;y++){h=new D(l[c][y+1]),p.nextPoint=h,h.prevPoint=p;var g=new N(p,h,"polyline",u,null);r.push(g),d.nextEdge=g,g.prevEdge=d,i[0]=Math.min(i[0],p.p[0]),i[1]=Math.min(i[1],p.p[1]),i[2]=Math.max(i[2],p.p[0]),i[3]=Math.max(i[3],p.p[1]),p=h,u+=1,d=g}i[0]=Math.min(i[0],l[c][f][0]),i[1]=Math.min(i[1],l[c][f][1]),i[2]=Math.max(i[2],l[c][f][0]),i[3]=Math.max(i[3],l[c][f][1])}for(var m="Feature"===e.type?e.geometry:e,v="Polygon"===m.type?[m.coordinates]:m.coordinates,b=v.length,E=0;E<b;E++)for(var S=v[E].length,w=0;w<S;w++){o+=1;var P=v[E][w],O=P.length;a.push(new G(o,P));for(var x=new D(P[0]),_=x,A=void 0,T=null,C={nextEdge:null,prevEdge:null},k=null,I=1;I<O;I++)A=new D(P[I]),_.nextPoint=A,A.prevPoint=_,T=new N(_,A,"polygon",u,o),C.nextEdge=T,T.prevEdge=C,1===I&&(k=T),w>0&&(T.interiorRing=!0),T.intersectPolylineBbox=F(T,i),n.push(T),_=A,u+=1,C=T;T.nextEdge=k,k.prevEdge=T,A.nextPoint=x.nextPoint,x.prevPoint=A.prevPoint}return a}(d(e),t,r,i,[1/0,1/0,1/0,1/0]);if(function(e,t,n){var r,i,o,a=t.length,s=e.length;for(r=0;r<a;r++){var l=t[r];for(i=0;i<s;i++){var u=e[i];if(u.intersectPolylineBbox&&!(u.maxX<l.minX||u.minX>l.maxX||u.maxY<l.minY||u.minY>l.maxY)){var c=Y(l,u);if(null!==c)for(o=0;o<c.length;o++){var f=R(u.p1.p[0],u.p1.p[1],u.p2.p[0],u.p2.p[1],l.p1.p[0],l.p1.p[1]),p=new V(c[o],l,u,f>0);n.push(p)}}}}t.forEach(function(e){e.intersectionPoints.sort(function(e,t){return e.distanceFromPolylineEdgeStart-t.distanceFromPolylineEdgeStart})}),e.forEach(function(e){e.intersectionPoints.sort(function(e,t){return e.distanceFromPolygonEdgeStart-t.distanceFromPolygonEdgeStart})})}(r,i,n),0===n.length)return e;var a={};o.forEach(function(e){return a[e.id]=0}),n.forEach(function(e){var t=e.polygonEdge.polygonContourId;a[t]=a[t]+1});for(var s=0,l=[],u=null,c=0;c<i.length;c++){var f=i[c];if(f.intersectionPoints.length>0){u=f.intersectionPoints[0];break}}for(var p=u,h={visitCount:1};u!==h&&!(s>2*n.length);){if(s=s++,h.visitCount>=2){for(var y=!1,g=0;g<n.length;g++){var m=n[g];if(m.visitCount<2){p=m,y=!0;break}}if(!y)break}p.visitCount=p.visitCount+1;var v=[];l.push(v),v.push(p.p),p.visitCount=p.visitCount+1;var b=X(p,v),E=!1;if(b===(h=b)&&2===n.length)for(var S=0;S<n.length;S++)n[S].visitCount<2&&(E=!0);for(;b!==p||E;)(b=(b.isHeadingIn?J:Z)(b,v))!==p&&(b=X(b,v)),E=!1;if(h.visitCount>=2){for(var w=!1,P=0;P<n.length;P++){var O=n[P];if(O.visitCount<2){p=O,w=!0;break}}w&&(h=p)}p=h}for(var x=l.map(function(e){return[e]}),_=Object.keys(a),A=0;A<_.length;A++){var T=_[A];0===a[T]&&$(W(z(r,parseInt(T)),o),x)}return{type:"Feature",properties:{},geometry:{type:"MultiPolygon",coordinates:x}}}(e,a)}catch(e){return null}var s=[];if("MultiPolygon"!==o.geometry.type)return null;if(2!==o.geometry.coordinates.length)return null;s=o.geometry.coordinates.map(function(t){return(0,nt.n1)(t,e.properties)});var l=null!==(n=null!==(r=e.id)&&void 0!==r?r:null===(i=e.properties)||void 0===i?void 0:i.id)&&void 0!==n?n:"poly",u=s.map(function(t,n){return(0,nt.n1)(t.geometry.coordinates,at(at({},e.properties),{},{id:l}),{id:"".concat(l,"-").concat(n+1)})});return(0,nt.Lr)(u)},pt=function(e){var t,n,r,i,o;try{o=tt((0,nt.Lr)(e))}catch(e){return null}if("Polygon"!==(null===(t=o)||void 0===t||null===(t=t.geometry)||void 0===t?void 0:t.type))return null;var a=null!==(n=null!==(r=e[0].id)&&void 0!==r?r:null===(i=e[0].properties)||void 0===i?void 0:i.id)&&void 0!==n?n:"poly";return(0,nt.n1)(o.geometry.coordinates,at(at({},e[0].properties),{},{id:a}),{id:a})},ht=function(e,t){var n=it(e,2),r=n[0],i=n[1],o=it(t,2),a=o[0],s=o[1],l=function(e){return e*Math.PI/180},u=l(s-i),c=l(a-r),f=Math.pow(Math.sin(u/2),2)+Math.cos(l(i))*Math.cos(l(s))*Math.pow(Math.sin(c/2),2);return 12742e3*Math.atan2(Math.sqrt(f),Math.sqrt(1-f))},dt=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.01;if(e.length<=1)return!0;var n=e[e.length-1],r=e[e.length-2];return ht(n,r)>=t},yt=function(e){return e[0].length<=1||function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.01,n=e[0];return n.length<=1||!(n.length<=3&&function(e,t){for(var n=0;n<e.length;n++)for(var r=n+1;r<e.length;r++)if(ht(e[n],e[r])<t)return!0;return!1}(n,t))}(e)},gt=function(e,t,n){var r=t.filter(function(t){var r=Math.abs(t[0]-e[0]),i=Math.abs(t[1]-e[1]);return("ArrowUp"===n?t[1]<=e[1]&&i>=r:"ArrowDown"===n?t[1]>e[1]&&i>=r:"ArrowLeft"===n?t[0]<=e[0]&&i<r:"ArrowRight"!==n||t[0]>e[0]&&i<r)&&JSON.stringify(t)!==JSON.stringify(e)});r.length||r.push(e);var i=r.map(function(t){return n=Math.abs(e[0]-t[0]),r=Math.abs(e[1]-t[1]),Math.sqrt(Math.pow(n,2)+Math.pow(r,2));var n,r}),o=r[i.indexOf(Math.min.apply(Math,lt(i)))];return t.findIndex(function(e){return JSON.stringify(e)===JSON.stringify(o)})}},9(e,t,n){n.d(t,{Oo:()=>x,PI:()=>O,n8:()=>c,PH:()=>w,Nk:()=>P});var r=n(278),i=n(850);function o(e){let t=0;if(e&&e.length>0){t+=Math.abs(l(e[0]));for(let n=1;n<e.length;n++)t-=Math.abs(l(e[n]))}return t}var a=r.zX*r.zX/2,s=Math.PI/180;function l(e){const t=e.length-1;if(t<=2)return 0;let n=0,r=0;for(;r<t;){const i=e[r],o=e[r+1===t?0:r+1],a=e[r+2>=t?(r+2)%t:r+2],l=i[0]*s,u=o[1]*s;n+=(a[0]*s-l)*Math.sin(u),r++}return n*a}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var c={Polygon:3,LineString:2},f=function(e){var t;return null!==(t=null==e?void 0:e.geometry)&&void 0!==t?t:e},p=function(e){var t=f(e);return"Polygon"===(null==t?void 0:t.type)?t:null},h=function(e){for(var t,n,r=null!==(t=null===(n=e.coordinates)||void 0===n?void 0:n[0])&&void 0!==t?t:[],i=r.filter(function(e,t){return 0===t||e[0]!==r[t-1][0]||e[1]!==r[t-1][1]});i.length>1&&i[0][0]===i[i.length-1][0]&&i[0][1]===i[i.length-1][1];)i.pop();return i},d=function(e){return[].concat(function(e){if(Array.isArray(e))return u(e)}(t=e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e,t){if(e){if("string"==typeof e)return u(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),[e[0]]);var t},y=function(e,t,n){return(t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0])},g=function(e,t){return e>0&&t<0||e<0&&t>0},m=function(e,t,n,r){return 0===e&&function(e,t,n){return Math.min(e[0],n[0])<=t[0]&&t[0]<=Math.max(e[0],n[0])&&Math.min(e[1],n[1])<=t[1]&&t[1]<=Math.max(e[1],n[1])}(t,n,r)},v=function(e,t,n,r){var i=y(n,r,e),o=y(n,r,t),a=y(e,t,n),s=y(e,t,r);return!(!g(i,o)||!g(a,s))||m(i,n,e,r)||m(o,n,t,r)||m(a,e,n,t)||m(s,e,r,t)},b=function(e,t){for(var n=e.length,r=t?n:n-1,i=0;i<r;i++)for(var o=i+1;o<r;o++)if(!(o===i+1||t&&0===i&&o===r-1)&&v(e[i],e[(i+1)%n],e[o],e[(o+1)%n]))return!0;return!1},E=function(e){var t=p(e);if(!t)return{valid:!0};var n=h(t);return n.length<4?{valid:!0}:b(n,!0)?{valid:!1,reason:"Shape must not intersect itself"}:{valid:!0}},S=function(e){var t=p(e);if(!t)return{valid:!0};var n=h(t);if(n.length<c.Polygon)return{valid:!0};var r,a=0;try{r={type:"Feature",geometry:{type:"Polygon",coordinates:[d(n)]},properties:{}},a=(0,i.jE)(r,(e,t)=>e+function(e){let t,n=0;switch(e.type){case"Polygon":return o(e.coordinates);case"MultiPolygon":for(t=0;t<e.coordinates.length;t++)n+=o(e.coordinates[t]);return n;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}(t),0)}catch(e){return{valid:!0}}return a>0?{valid:!0}:{valid:!1,reason:"Shape must enclose an area"}},w={Polygon:"Shape needs at least 3 points",LineString:"Line needs at least 2 points"},P=[E,S,function(e){var t,n,r=f(e);return"Polygon"===(null==r?void 0:r.type)?h(r).length>=c.Polygon?{valid:!0}:{valid:!1,reason:w.Polygon}:"LineString"===(null==r?void 0:r.type)?(null!==(t=null===(n=r.coordinates)||void 0===n?void 0:n.length)&&void 0!==t?t:0)>=c.LineString?{valid:!0}:{valid:!1,reason:w.LineString}:{valid:!0}}],O=[E,S],x=[function(e){return function(e){var t=p(e);if(!t)return!1;var n=h(t);return!(n.length<4)&&b(n,!1)}(e)?{valid:!1,reason:"Shape must not intersect itself"}:{valid:!0}}]},520(e,t,n){n.d(t,{$U:()=>f,$b:()=>d,Uk:()=>y,dV:()=>h,oK:()=>p});var r=n(9);function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach(function(t){s(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function s(e,t,n){return(t=function(e){var t=function(e){if("object"!=i(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=i(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==i(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){if(e){if("string"==typeof e)return u(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var c=function(e){return void 0===e||!0===e?{valid:!0}:!1===e?{valid:!1,reason:null}:{valid:!1!==e.valid,reason:e.reason}},f=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=i.rules,s=void 0===o?r.Nk:o,u=i.onGeometryChange,f=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=l(e))){t&&(e=t);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return o=e.done,e},e:function(e){a=!0,i=e},f:function(){try{o||null==t.return||t.return()}finally{if(a)throw i}}}}(s);try{for(f.s();!(t=f.n()).done;){var p=t.value,h=c(p(e,n));if(!h.valid)return h}}catch(e){f.e(e)}finally{f.f()}return"function"==typeof u?c(u(a({feature:e},n))):{valid:!0}},p=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=n.rules,o=void 0===i?r.Oo:i,s=n.onGeometryChange;return f(e,a(a({},t),{},{phase:"place"}),{rules:o,onGeometryChange:s})},h={Polygon:"draw_polygon",LineString:"draw_line"},d=function(e){var t,n=e.placed,r=e.point,i=e.geometryType,o=e.onGeometryChange,a=[].concat(function(e){if(Array.isArray(e))return u(e)}(t=n)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||l(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),[r]),s={type:"Feature",geometry:"Polygon"===i?{type:"Polygon",coordinates:[a]}:{type:"LineString",coordinates:a},properties:{}},c=h[i],f=p(s,{mode:c,vertexIndex:n.length},{onGeometryChange:o}),d=f.valid,y=f.reason;return d?{valid:!0}:{valid:!1,blocked:{feature:s,reason:null!=y?y:null,phase:"place",mode:c,vertexIndex:n.length}}},y=function(e){var t,n,i,o,s,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},c=u.rules,p=void 0===c?r.PI:c,h=u.onGeometryChange,d=null!==(t=null==e||null===(n=e.geometry)||void 0===n?void 0:n.type)&&void 0!==t?t:null==e?void 0:e.type,y=null!==(i=r.n8[d])&&void 0!==i?i:0,g=(null!==(o=l.numVertices)&&void 0!==o?o:0)<y?[]:p;return f(e,a(a({},l),{},{phase:null!==(s=l.phase)&&void 0!==s?s:"preview"}),{rules:g,onGeometryChange:h})}}}]);